@omnixdp/impex
v0.2.0
Published
TypeScript client for the Omni xDP IMPEX API.
Readme
@omnixdp/impex
TypeScript SDK for the Omni xDP IMPEX API.
The package wraps /v1/impex with OAuth client_credentials helpers, request builders, response parsing, and a small fetch client that works in browsers, Next.js Client Components, and React Server Components.
Install
npm install @omnixdp/impexCreate a client
import { createImpexClient } from "@omnixdp/impex";
const impex = createImpexClient({
baseUrl: "https://api.example.com",
clientCredentials: {
clientId: process.env.OMNIXDP_IMPEX_CLIENT_ID!,
clientSecret: process.env.OMNIXDP_IMPEX_CLIENT_SECRET!
}
});Next.js usage
Keep API client secrets on the server when possible.
import { createImpexClient } from "@omnixdp/impex";
const impex = createImpexClient({
baseUrl: process.env.OMNIXDP_API_URL!,
clientCredentials: {
clientId: process.env.OMNIXDP_IMPEX_CLIENT_ID!,
clientSecret: process.env.OMNIXDP_IMPEX_CLIENT_SECRET!
}
});
export default async function JobsPage() {
const jobs = await impex.listJobs({ limit: 20 });
return <pre>{JSON.stringify(jobs, null, 2)}</pre>;
}Browser warning
This API uses OAuth client_credentials. If you configure clientCredentials in a browser context, the SDK logs a warning because the secret may be exposed in the JavaScript bundle. Use a server-side proxy or route handler when possible.
Generated resource types
Use @omnixdp/typegen --impex to emit the static IMPEX client alias alongside any schema-driven CMS, Business Objects, or Ratings and Reviews types.
npx omnixdp-typegen \
--api-url https://api.example.com \
--impex \
--out src/omnixdp.generated.tsimport { createImpexClient, createTypedImpexClient } from "@omnixdp/impex";
import type { ImpexClient } from "./omnixdp.generated";
const impex: ImpexClient = createTypedImpexClient(
createImpexClient({
baseUrl: process.env.OMNIXDP_API_URL!,
accessToken: process.env.OMNIXDP_IMPEX_TOKEN!
})
);
const jobs = await impex.listJobs({ limit: 20 });
jobs[0]?.id;Methods
getAccessToken(options)request(method, pathSegments, options)rawRequest(method, pathSegments, options)getSettings,updateSettingslistSourceFiles,listSourceFileDirectories,createSourceFileDirectory,uploadSourceFile,getSourceFileContent,getSourceFileText,updateSourceFileText,updateSourceFile,deleteSourceFilelistSourceApis,createSourceApi,testSourceApi,getSourceApi,updateSourceApi,deleteSourceApilistBoImportWorkflows,createBoImportWorkflow,getBoImportWorkflow,updateBoImportWorkflow,executeBoImportWorkflow,deleteBoImportWorkflowlistJobs,createJob,getJob,updateJob,runJob,stopJob,listJobExecutions,deleteJob
Failed IMPEX API responses throw ImpexApiError with status, code, details, and the parsed response body when available.
