@spscommerce/asst-api 0.0.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ImportsStatus-52d26b01.d.ts +134 -0
- package/dist/ImportsStatusEnum-22c03a0b.d.ts +51 -0
- package/dist/ItemCategoriesSearch-1bb945de.d.ts +275 -0
- package/dist/ItemCategory-768179bd.d.ts +99 -0
- package/dist/TradingPartnerAccessByCompanyId-479e3e57.d.ts +124 -0
- package/dist/asstClient-f6a1693a.d.ts +29 -0
- package/dist/chunk-7HCJJATJ.js +40 -0
- package/dist/chunk-B7B2ACF4.js +3794 -0
- package/dist/chunk-D3ML6E4G.js +3787 -0
- package/dist/chunk-LGP22FRF.js +0 -0
- package/dist/chunk-RNUSCCKB.js +183 -0
- package/dist/index.cjs +4038 -0
- package/dist/index.d.ts +125 -0
- package/dist/index.js +69 -0
- package/dist/msw.cjs +4036 -0
- package/dist/msw.d.ts +228 -0
- package/dist/msw.js +190 -0
- package/dist/zod.cjs +3874 -0
- package/dist/zod.d.ts +3 -0
- package/dist/zod.js +74 -0
- package/package.json +67 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as ky from 'ky';
|
|
2
|
+
import { Options } from 'ky';
|
|
3
|
+
|
|
4
|
+
declare const BASE_URLS: {
|
|
5
|
+
readonly local: "https://localhost:8443";
|
|
6
|
+
readonly test: "https://integration.api.spscommerce.com/assortment/gateway";
|
|
7
|
+
readonly prod: "https://api.spscommerce.com/assortment/gateway";
|
|
8
|
+
};
|
|
9
|
+
type Env = keyof typeof BASE_URLS;
|
|
10
|
+
type AsstUrl = typeof BASE_URLS[Env];
|
|
11
|
+
interface AsstClientOptions extends Options {
|
|
12
|
+
prefixUrl?: AsstUrl;
|
|
13
|
+
}
|
|
14
|
+
type Input = string | URL | Request;
|
|
15
|
+
declare class AsstClient {
|
|
16
|
+
#private;
|
|
17
|
+
constructor(options: AsstClientOptions);
|
|
18
|
+
updateConfig(options: AsstClientOptions): void;
|
|
19
|
+
getBaseUrl(): AsstUrl;
|
|
20
|
+
subscribeToConfigChange(subscriptionCallback: (newConfig: AsstClientOptions) => void): void;
|
|
21
|
+
get(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
|
|
22
|
+
post(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
|
|
23
|
+
put(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
|
|
24
|
+
patch(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
|
|
25
|
+
head(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
|
|
26
|
+
delete(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { AsstClient as A, BASE_URLS as B, Env as E, AsstClientOptions as a, AsstUrl as b };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
importErrorsSchema,
|
|
3
|
+
importSchema,
|
|
4
|
+
importsStatusSchema,
|
|
5
|
+
z
|
|
6
|
+
} from "./chunk-B7B2ACF4.js";
|
|
7
|
+
|
|
8
|
+
// lib/imports/index.ts
|
|
9
|
+
var BASE_URL = "imports";
|
|
10
|
+
function createImportsApi(client) {
|
|
11
|
+
async function getImportErrors(importId, params, signal) {
|
|
12
|
+
const data = await client.get(`${BASE_URL}/${importId}/errors`, { searchParams: params, signal }).json();
|
|
13
|
+
return importErrorsSchema.parse(data);
|
|
14
|
+
}
|
|
15
|
+
async function getImports(params, signal) {
|
|
16
|
+
const data = await client.get(`${BASE_URL}`, {
|
|
17
|
+
searchParams: params,
|
|
18
|
+
signal
|
|
19
|
+
}).json();
|
|
20
|
+
return importSchema.parse(data);
|
|
21
|
+
}
|
|
22
|
+
async function getImportsStatus(signal) {
|
|
23
|
+
const data = await client.get(`${BASE_URL}/status`, { signal }).json();
|
|
24
|
+
return z.array(importsStatusSchema).parse(data);
|
|
25
|
+
}
|
|
26
|
+
async function uploadImport(file) {
|
|
27
|
+
await client.post(`${BASE_URL}`, { body: file });
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
getImportErrors,
|
|
31
|
+
getImports,
|
|
32
|
+
getImportsStatus,
|
|
33
|
+
uploadImport
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
BASE_URL,
|
|
39
|
+
createImportsApi
|
|
40
|
+
};
|