TypeScript
Types are shipped in index.d.ts and can be imported directly — no @types/... installation is required.
import {
SpmClient,
SpmCustomers,
SpmCustomerData,
SpmEnvelope,
SpmChunkedEnvelope,
SpmHelpers,
} from '@shopimind/sdk-shopimind';
const client = SpmClient.getClient('v1', process.env.SHOPIMIND_API_KEY!);
const items: SpmCustomerData[] = [/* ... */];
const res: SpmEnvelope | SpmChunkedEnvelope =
await SpmCustomers.bulkSave(client, items, { chunk: true });
if (res.ok) {
const counts = SpmHelpers.extractCounts(res);
console.log(`${counts.sent} sent, ${counts.rejected} rejected`);
}The typed envelope
interface SpmEnvelope<T = unknown> {
ok: boolean;
statusCode: number;
data: T | null;
error: SpmEnvelopeError | null;
}
interface SpmEnvelopeError {
message: string;
code: string;
retryable: boolean;
attempts: number;
details?: unknown;
}Available data interfaces
SpmCustomerData, SpmCustomerAddressData, SpmBulkCustomerAddressData, SpmCustomerGroupData, SpmProductData, SpmProductCategoryData, SpmProductImageData, SpmBulkProductImageData, SpmProductManufacturerData, SpmProductVariationData, SpmBulkProductVariationData, SpmOrderData, SpmOrderProduct, SpmOrderCustomer, SpmOrderCarrierData, SpmOrderStatusData, SpmVoucherData, SpmShopConnectionData, SpmDataSourceData, SpmCreateDataSourceData, SpmEnvelope, SpmChunkedEnvelope, SpmBulkOptions, SpmRetryOptions.
End-to-end typed example
import { SpmClient, SpmOrders, SpmOrderData } from '@shopimind/sdk-shopimind';
const client = SpmClient.getClient('v1', process.env.SHOPIMIND_API_KEY!, {
retry: { maxRetries: 5 },
});
const orders: SpmOrderData[] = [
{
order_id: 'ord_1',
reference: 'CMD-1',
// … typed fields, autocompleted by your IDE
} as SpmOrderData,
];
const res = await SpmOrders.bulkSave(client, orders, { chunk: true });
if (!res.ok) throw new Error(res.error!.message);ESM vs CommonJS
The SDK works with import (ESM / TypeScript) as well as require (CommonJS). In TypeScript, enable esModuleInterop (on by default in most recent configs).