@spscommerce/asst-api 0.0.1-beta.6 → 0.0.1-beta.8

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.
Files changed (47) hide show
  1. package/dist/ItemErrorDetails-1614b511.d.ts +3137 -0
  2. package/dist/ItemErrorDetailsResult-c12c4eac.d.ts +3032 -0
  3. package/dist/{chunk-D3ML6E4G.js → chunk-3JRE7YYE.js} +805 -16
  4. package/dist/chunk-OVOZIZA2.js +326 -0
  5. package/dist/index.cjs +814 -28
  6. package/dist/index.d.ts +86 -46
  7. package/dist/index.js +18 -5
  8. package/dist/msw.cjs +926 -63
  9. package/dist/msw.d.ts +582 -75
  10. package/dist/msw.js +246 -54
  11. package/dist/zod.cjs +719 -17
  12. package/dist/zod.d.ts +3 -2
  13. package/dist/zod.js +103 -55
  14. package/package.json +3 -4
  15. package/dist/ImportsStatus-52d26b01.d.ts +0 -134
  16. package/dist/ImportsStatusEnum-22c03a0b.d.ts +0 -51
  17. package/dist/ItemCategoriesSearch-1bb945de.d.ts +0 -275
  18. package/dist/ItemCategoriesSearch-44b87663.d.ts +0 -318
  19. package/dist/ItemCategoriesSearch-e0870a34.d.ts +0 -318
  20. package/dist/ItemCategoriesSearch-e3298650.d.ts +0 -319
  21. package/dist/ItemCategoriesSearch-ec43591f.d.ts +0 -319
  22. package/dist/ItemCategory-14816deb.d.ts +0 -99
  23. package/dist/ItemCategory-768179bd.d.ts +0 -99
  24. package/dist/TradingPartnerAccessByCompanyId-29866586.d.ts +0 -97
  25. package/dist/TradingPartnerAccessByCompanyId-43f83fb6.d.ts +0 -130
  26. package/dist/TradingPartnerAccessByCompanyId-479e3e57.d.ts +0 -124
  27. package/dist/TradingPartnerAccessByCompanyId-53b868a8.d.ts +0 -125
  28. package/dist/TradingPartnerAccessByCompanyId-b227f0c5.d.ts +0 -125
  29. package/dist/TradingPartnerAccessByCompanyId-e7a1d443.d.ts +0 -129
  30. package/dist/asstClient-f6a1693a.d.ts +0 -29
  31. package/dist/chunk-3FMMM7IS.js +0 -80
  32. package/dist/chunk-6ZNFOWTV.js +0 -78
  33. package/dist/chunk-7HCJJATJ.js +0 -40
  34. package/dist/chunk-B7B2ACF4.js +0 -3794
  35. package/dist/chunk-F3KCLICG.js +0 -77
  36. package/dist/chunk-FS6LHGAR.js +0 -87
  37. package/dist/chunk-GDFX3WTX.js +0 -78
  38. package/dist/chunk-LGP22FRF.js +0 -0
  39. package/dist/chunk-LYMGZWSR.js +0 -80
  40. package/dist/chunk-N2OYWNHF.js +0 -80
  41. package/dist/chunk-OA6PO3QG.js +0 -78
  42. package/dist/chunk-OBXZRDPY.js +0 -77
  43. package/dist/chunk-OI47EFQH.js +0 -82
  44. package/dist/chunk-RNUSCCKB.js +0 -183
  45. package/dist/chunk-T3UCSW2B.js +0 -81
  46. package/dist/chunk-XMNYZGXF.js +0 -84
  47. package/dist/chunk-YCQUK6KV.js +0 -85
@@ -1,183 +0,0 @@
1
- import {
2
- importErrorsSchema,
3
- importSchema,
4
- importsStatusSchema,
5
- itemCategoriesSearchSchema,
6
- vendorPartnerAttGroupsSchema,
7
- z
8
- } from "./chunk-D3ML6E4G.js";
9
-
10
- // lib/imports/index.ts
11
- import QueryString from "query-string";
12
- var BASE_URL = "imports";
13
- function createImportsApi(client) {
14
- async function getImportErrors(importId, params, signal) {
15
- const data = await client.get(`${BASE_URL}/${importId}/errors`, { searchParams: params, signal }).json();
16
- return importErrorsSchema.parse(data);
17
- }
18
- async function getImports(params, signal) {
19
- const data = await client.get(`${BASE_URL}`, {
20
- searchParams: params,
21
- signal
22
- }).json();
23
- return importSchema.parse(data);
24
- }
25
- async function getImportsStatus(signal) {
26
- const data = await client.get(`${BASE_URL}/status`, { signal }).json();
27
- return z.array(importsStatusSchema).parse(data);
28
- }
29
- async function uploadImport(file) {
30
- await client.post(`${BASE_URL}`, { body: file });
31
- }
32
- async function getVendorPartnerGroups(signal) {
33
- const data = await client.get(`${BASE_URL}/template/vendor-partner-groups`, { signal }).json();
34
- return z.array(vendorPartnerAttGroupsSchema).parse(data);
35
- }
36
- async function generateImportTemplate(params) {
37
- const searchParams = params ? QueryString.stringify(params, {
38
- arrayFormat: "comma",
39
- skipEmptyString: true
40
- }) : void 0;
41
- const response = await client.get(`${BASE_URL}/template/generate`, {
42
- searchParams,
43
- headers: {
44
- Accept: "application/octet-stream"
45
- }
46
- });
47
- const disposition = response.headers.get("content-disposition") || "";
48
- const filename = disposition.match(/filename="(.+)"/)?.[1];
49
- const downloadUrl = window.URL.createObjectURL(
50
- new Blob([await response.blob()])
51
- );
52
- const link = document.createElement("a");
53
- link.href = downloadUrl;
54
- if (filename) {
55
- link.download = filename;
56
- }
57
- document.body.appendChild(link);
58
- link.click();
59
- link.remove();
60
- }
61
- return {
62
- getImportErrors,
63
- getImports,
64
- getImportsStatus,
65
- uploadImport,
66
- getVendorPartnerGroups,
67
- generateImportTemplate
68
- };
69
- }
70
-
71
- // lib/exports/index.ts
72
- var BASE_URL2 = "v2/exports";
73
- function createExportsApi(client) {
74
- async function createExport(data) {
75
- await client.post(`${BASE_URL2}/add`, { json: data });
76
- }
77
- return {
78
- createExport
79
- };
80
- }
81
-
82
- // lib/productTypes/models/AttrProdType.ts
83
- var attrProdTypeSchema = z.object({
84
- attrProdTypeId: z.number(),
85
- productType: z.string(),
86
- description: z.string(),
87
- createdDate: z.number(),
88
- createdBy: z.string(),
89
- modifiedDate: z.number().optional(),
90
- modifiedBy: z.string().optional(),
91
- retailerId: z.number().optional()
92
- });
93
-
94
- // lib/productTypes/index.ts
95
- import QueryString2 from "query-string";
96
- var BASE_URL3 = "product-types";
97
- function createProductTypesApi(client) {
98
- async function getProductTypes(params, signal) {
99
- const searchParams = params ? QueryString2.stringify(params, { arrayFormat: "comma" }) : void 0;
100
- const data = await client.get(`${BASE_URL3}/all`, {
101
- searchParams,
102
- signal
103
- }).json();
104
- return z.array(attrProdTypeSchema).parse(data.results);
105
- }
106
- return {
107
- getProductTypes
108
- };
109
- }
110
-
111
- // lib/tradingPartners/models/Connection.ts
112
- var connectionSchema = z.object({
113
- catalog_id: z.number(),
114
- catalog_name: z.string(),
115
- partner_company_name: z.string(),
116
- partner_company_id: z.number()
117
- });
118
-
119
- // lib/tradingPartners/models/TradingPartnerAccessByCompanyId.ts
120
- var tradingPartnerAccessByCompanyIdSchema = z.object({
121
- companyId: z.number(),
122
- companyType: z.string(),
123
- identityOrgId: z.string(),
124
- companyName: z.string(),
125
- count: z.number(),
126
- connections: z.array(connectionSchema)
127
- });
128
-
129
- // lib/tradingPartners/index.ts
130
- var BASE_URL4 = "trading-partner-access";
131
- function createTradingPartnerAccessApi(client) {
132
- async function getAllTradingPartners(signal) {
133
- const data = await client.get(`${BASE_URL4}/connections`, {
134
- signal
135
- }).json();
136
- return tradingPartnerAccessByCompanyIdSchema.parse(data);
137
- }
138
- return {
139
- getAllTradingPartners
140
- };
141
- }
142
-
143
- // lib/categories/index.ts
144
- var BASE_URL5 = "categories";
145
- function createCategoriesApi(client) {
146
- async function getCatalogs(params, signal) {
147
- const data = await client.get(`${BASE_URL5}/search-category`, {
148
- searchParams: { ...params, type: "CATALOG" },
149
- signal
150
- }).json();
151
- return itemCategoriesSearchSchema.parse(data);
152
- }
153
- async function getProductCodes(params, signal) {
154
- const data = await client.get(`${BASE_URL5}/search-category`, {
155
- searchParams: { ...params, type: "PRODUCT_CODE" },
156
- signal
157
- }).json();
158
- return itemCategoriesSearchSchema.parse(data);
159
- }
160
- async function getSelectionCodes(params, signal) {
161
- const data = await client.get(`${BASE_URL5}/search-category`, {
162
- searchParams: { ...params, type: "SELECTION_CODE" },
163
- signal
164
- }).json();
165
- return itemCategoriesSearchSchema.parse(data);
166
- }
167
- return { getCatalogs, getProductCodes, getSelectionCodes };
168
- }
169
-
170
- export {
171
- BASE_URL,
172
- createImportsApi,
173
- BASE_URL2,
174
- createExportsApi,
175
- attrProdTypeSchema,
176
- BASE_URL3,
177
- createProductTypesApi,
178
- tradingPartnerAccessByCompanyIdSchema,
179
- BASE_URL4,
180
- createTradingPartnerAccessApi,
181
- BASE_URL5,
182
- createCategoriesApi
183
- };
@@ -1,81 +0,0 @@
1
- import {
2
- z
3
- } from "./chunk-D3ML6E4G.js";
4
-
5
- // lib/asstClient.ts
6
- import ky from "ky-universal";
7
- var baseUrlsSchema = z.object({
8
- local: z.literal("https://localhost:8443"),
9
- test: z.literal("https://integration.api.spscommerce.com/assortment/gateway"),
10
- prod: z.literal("https://api.spscommerce.com/assortment/gateway")
11
- });
12
- var BASE_URLS = {
13
- local: "https://localhost:8443",
14
- test: "https://integration.api.spscommerce.com/assortment/gateway",
15
- prod: "https://api.spscommerce.com/assortment/gateway"
16
- };
17
- var envSchema = baseUrlsSchema.keyof();
18
- var AsstClient = class {
19
- #client = ky.create({
20
- prefixUrl: BASE_URLS["test"],
21
- retry: 0
22
- });
23
- #baseUrl = BASE_URLS["test"];
24
- #subscriptionCallback;
25
- #currentConfig = {};
26
- constructor(options) {
27
- console.log(`AsstClient created! Config: ${options ? JSON.stringify(options) : "default"}`);
28
- if (options) {
29
- this.updateConfig(options);
30
- }
31
- }
32
- updateConfig(options) {
33
- this.#client = this.#client.extend(options);
34
- this.#currentConfig = options;
35
- if (options.prefixUrl) {
36
- this.#baseUrl = options.prefixUrl;
37
- }
38
- if (this.#subscriptionCallback) {
39
- this.#subscriptionCallback(options);
40
- }
41
- }
42
- getBaseUrl() {
43
- return this.#baseUrl;
44
- }
45
- /**
46
- * Subscribe to config changes. The callback will be immediately invoked with the current config.
47
- * @param subscriptionCallback Function that will be called with the new config every time it is changed
48
- */
49
- subscribeToConfigChange(subscriptionCallback) {
50
- console.log(`Subscription added`);
51
- this.#subscriptionCallback = subscriptionCallback;
52
- subscriptionCallback(this.#currentConfig);
53
- }
54
- unsubscribeToConfigChange() {
55
- this.#subscriptionCallback = void 0;
56
- }
57
- get(url, options) {
58
- return this.#client.get(url, options);
59
- }
60
- post(url, options) {
61
- return this.#client.post(url, options);
62
- }
63
- put(url, options) {
64
- return this.#client.put(url, options);
65
- }
66
- patch(url, options) {
67
- return this.#client.patch(url, options);
68
- }
69
- head(url, options) {
70
- return this.#client.head(url, options);
71
- }
72
- delete(url, options) {
73
- return this.#client.delete(url, options);
74
- }
75
- };
76
-
77
- export {
78
- BASE_URLS,
79
- envSchema,
80
- AsstClient
81
- };
@@ -1,84 +0,0 @@
1
- import {
2
- z
3
- } from "./chunk-D3ML6E4G.js";
4
-
5
- // lib/asstClient.ts
6
- import ky from "ky-universal";
7
- var baseUrlsSchema = z.object({
8
- local: z.literal("https://localhost:8443"),
9
- test: z.literal("https://integration.api.spscommerce.com/assortment/gateway"),
10
- prod: z.literal("https://api.spscommerce.com/assortment/gateway")
11
- });
12
- var BASE_URLS = {
13
- local: "https://localhost:8443",
14
- test: "https://integration.api.spscommerce.com/assortment/gateway",
15
- prod: "https://api.spscommerce.com/assortment/gateway"
16
- };
17
- var envSchema = baseUrlsSchema.keyof();
18
- var initialConfig = {
19
- prefixUrl: BASE_URLS["test"],
20
- retry: 0
21
- };
22
- var AsstClient = class {
23
- #client = ky.create(initialConfig);
24
- #baseUrl = BASE_URLS["test"];
25
- #subscriptionCallback;
26
- #currentConfig = initialConfig;
27
- constructor(options) {
28
- console.log(
29
- `AsstClient created! Config: ${options ? JSON.stringify(options) : "default"}`
30
- );
31
- if (options) {
32
- this.updateConfig(options);
33
- }
34
- }
35
- updateConfig(options) {
36
- this.#client = this.#client.extend(options);
37
- this.#currentConfig = options;
38
- if (options.prefixUrl) {
39
- this.#baseUrl = options.prefixUrl;
40
- }
41
- if (this.#subscriptionCallback) {
42
- this.#subscriptionCallback(options);
43
- }
44
- }
45
- getBaseUrl() {
46
- return this.#baseUrl;
47
- }
48
- /**
49
- * Subscribe to config changes. The callback will be immediately invoked with the current config.
50
- * @param subscriptionCallback Function that will be called with the new config every time it is changed
51
- */
52
- subscribeToConfigChange(subscriptionCallback) {
53
- console.log(`Subscription added`);
54
- this.#subscriptionCallback = subscriptionCallback;
55
- subscriptionCallback(this.#currentConfig);
56
- }
57
- unsubscribeToConfigChange() {
58
- this.#subscriptionCallback = void 0;
59
- }
60
- get(url, options) {
61
- return this.#client.get(url, options);
62
- }
63
- post(url, options) {
64
- return this.#client.post(url, options);
65
- }
66
- put(url, options) {
67
- return this.#client.put(url, options);
68
- }
69
- patch(url, options) {
70
- return this.#client.patch(url, options);
71
- }
72
- head(url, options) {
73
- return this.#client.head(url, options);
74
- }
75
- delete(url, options) {
76
- return this.#client.delete(url, options);
77
- }
78
- };
79
-
80
- export {
81
- BASE_URLS,
82
- envSchema,
83
- AsstClient
84
- };
@@ -1,85 +0,0 @@
1
- import {
2
- z
3
- } from "./chunk-D3ML6E4G.js";
4
-
5
- // lib/asstClient.ts
6
- import ky from "ky-universal";
7
- var baseUrlsSchema = z.object({
8
- local: z.literal("https://localhost:8443"),
9
- test: z.literal("https://integration.api.spscommerce.com/assortment/gateway"),
10
- prod: z.literal("https://api.spscommerce.com/assortment/gateway")
11
- });
12
- var BASE_URLS = {
13
- local: "https://localhost:8443",
14
- test: "https://integration.api.spscommerce.com/assortment/gateway",
15
- prod: "https://api.spscommerce.com/assortment/gateway"
16
- };
17
- var envSchema = baseUrlsSchema.keyof();
18
- var initialConfig = {
19
- prefixUrl: BASE_URLS["test"],
20
- retry: 0
21
- };
22
- var AsstClient = class {
23
- #client = ky.create(initialConfig);
24
- #baseUrl = BASE_URLS["test"];
25
- #subscriptionCallback;
26
- #currentConfig = initialConfig;
27
- constructor(options) {
28
- console.log(
29
- `AsstClient created! Config: ${options ? JSON.stringify(options) : "default"}`
30
- );
31
- if (options) {
32
- this.updateConfig(options);
33
- }
34
- }
35
- updateConfig(options) {
36
- console.log(`Config updated! ${JSON.stringify(options)}`);
37
- this.#client = this.#client.extend(options);
38
- this.#currentConfig = options;
39
- if (options.prefixUrl) {
40
- this.#baseUrl = options.prefixUrl;
41
- }
42
- if (this.#subscriptionCallback) {
43
- this.#subscriptionCallback(options);
44
- }
45
- }
46
- getBaseUrl() {
47
- return this.#baseUrl;
48
- }
49
- /**
50
- * Subscribe to config changes. The callback will be immediately invoked with the current config.
51
- * @param subscriptionCallback Function that will be called with the new config every time it is changed
52
- */
53
- subscribeToConfigChange(subscriptionCallback) {
54
- console.log(`Subscription added`);
55
- this.#subscriptionCallback = subscriptionCallback;
56
- subscriptionCallback(this.#currentConfig);
57
- }
58
- unsubscribeToConfigChange() {
59
- this.#subscriptionCallback = void 0;
60
- }
61
- get(url, options) {
62
- return this.#client.get(url, options);
63
- }
64
- post(url, options) {
65
- return this.#client.post(url, options);
66
- }
67
- put(url, options) {
68
- return this.#client.put(url, options);
69
- }
70
- patch(url, options) {
71
- return this.#client.patch(url, options);
72
- }
73
- head(url, options) {
74
- return this.#client.head(url, options);
75
- }
76
- delete(url, options) {
77
- return this.#client.delete(url, options);
78
- }
79
- };
80
-
81
- export {
82
- BASE_URLS,
83
- envSchema,
84
- AsstClient
85
- };