@spscommerce/asst-api 4.2.2 → 4.3.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/{CompanyBriefByOrg-Dy2omcT0.d.cts → SpsItemIdResponse-0VgfCmG_.d.cts} +26 -37
- package/dist/{CompanyBriefByOrg-Dy2omcT0.d.ts → SpsItemIdResponse-0VgfCmG_.d.ts} +26 -37
- package/dist/SpsItemIdResponse-CI_Ao86P.d.cts +87 -0
- package/dist/SpsItemIdResponse-CI_Ao86P.d.ts +87 -0
- package/dist/SpsItemIdResponse-s0vCXepG.d.cts +74 -0
- package/dist/SpsItemIdResponse-s0vCXepG.d.ts +74 -0
- package/dist/chunk-355LPVI6.js +126 -0
- package/dist/{chunk-BVCWT7AV.js → chunk-55ECRTUX.js} +1 -1
- package/dist/chunk-63KIELUR.js +128 -0
- package/dist/{chunk-4RARACQK.js → chunk-CI3ZSIT4.js} +29 -13
- package/dist/chunk-DK2OMRWR.js +134 -0
- package/dist/chunk-FCUIJXCD.js +544 -0
- package/dist/{chunk-MH76527N.js → chunk-L4AWOEED.js} +6 -6
- package/dist/chunk-LKUGPDIT.js +4896 -0
- package/dist/chunk-NFZI7D22.js +544 -0
- package/dist/chunk-NUUQDRHD.js +4899 -0
- package/dist/chunk-RPGGEEFE.js +79 -0
- package/dist/index.cjs +14 -10
- package/dist/index.d.cts +18 -7
- package/dist/index.d.ts +18 -7
- package/dist/index.js +5 -17
- package/dist/msw.cjs +71 -25
- package/dist/msw.d.cts +58 -4
- package/dist/msw.d.ts +58 -4
- package/dist/msw.js +61 -13
- package/dist/{zod-BRmUARvM.d.cts → zod-C3fOiO-H.d.cts} +38 -17
- package/dist/zod-C41Rts8D.d.cts +5903 -0
- package/dist/{zod-CFNzalN6.d.ts → zod-CJ6AFTQr.d.ts} +38 -17
- package/dist/zod-CJmsC_DX.d.cts +5900 -0
- package/dist/zod-COyz02Lh.d.ts +5903 -0
- package/dist/zod-CzPw-bfk.d.cts +5900 -0
- package/dist/zod-vDuspd-x.d.ts +5900 -0
- package/dist/zod-xWM6u1LJ.d.ts +5900 -0
- package/dist/zod.cjs +14 -10
- package/dist/zod.d.cts +2 -2
- package/dist/zod.d.ts +2 -2
- package/dist/zod.js +2 -2
- package/package.json +3 -3
- package/dist/index-9KKchLwe.d.cts +0 -14
- package/dist/index-DeivEdv0.d.ts +0 -14
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import {
|
|
2
|
+
external_exports
|
|
3
|
+
} from "./chunk-L4AWOEED.js";
|
|
4
|
+
|
|
5
|
+
// lib/asstClient.ts
|
|
6
|
+
import ky from "ky";
|
|
7
|
+
var baseUrlsSchema = external_exports.object({
|
|
8
|
+
local: external_exports.literal("https://localhost:8443/"),
|
|
9
|
+
test: external_exports.literal(
|
|
10
|
+
"https://integration.api.spscommerce.com/assortment/gateway/"
|
|
11
|
+
),
|
|
12
|
+
prod: external_exports.literal("https://api.spscommerce.com/assortment/gateway/")
|
|
13
|
+
});
|
|
14
|
+
var BASE_URLS = {
|
|
15
|
+
local: "https://localhost:8443/",
|
|
16
|
+
test: "https://integration.api.spscommerce.com/assortment/gateway/",
|
|
17
|
+
prod: "https://api.spscommerce.com/assortment/gateway/"
|
|
18
|
+
};
|
|
19
|
+
var envSchema = baseUrlsSchema.keyof();
|
|
20
|
+
var initialConfig = {
|
|
21
|
+
prefixUrl: BASE_URLS["test"],
|
|
22
|
+
retry: 0
|
|
23
|
+
};
|
|
24
|
+
var AsstClient = class {
|
|
25
|
+
#client = ky.create(initialConfig);
|
|
26
|
+
#baseUrl = BASE_URLS["test"];
|
|
27
|
+
#listeners = /* @__PURE__ */ new Set();
|
|
28
|
+
#currentConfig = initialConfig;
|
|
29
|
+
#companyType;
|
|
30
|
+
constructor(options) {
|
|
31
|
+
if (options) {
|
|
32
|
+
this.updateConfig(options);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Set company type that will be automatically added to all requests
|
|
37
|
+
* @param companyType Company type to add to all requests (e.g., 'RETAILER', 'SUPPLIER')
|
|
38
|
+
*/
|
|
39
|
+
setCompanyType(companyType) {
|
|
40
|
+
this.#companyType = companyType;
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get the current company type
|
|
45
|
+
* @returns Current company type or undefined if not set
|
|
46
|
+
*/
|
|
47
|
+
getCompanyType() {
|
|
48
|
+
return this.#companyType;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Private method to merge companyType with existing searchParams
|
|
52
|
+
*/
|
|
53
|
+
#mergeCompanyTypeParam(options = {}) {
|
|
54
|
+
console.log("AsstClient: mergeCompanyTypeParam called with companyType:", this.#companyType);
|
|
55
|
+
if (!this.#companyType) return options;
|
|
56
|
+
const mergedOptions = { ...options };
|
|
57
|
+
let searchParams;
|
|
58
|
+
if (options.searchParams) {
|
|
59
|
+
if (options.searchParams instanceof URLSearchParams) {
|
|
60
|
+
searchParams = new URLSearchParams(options.searchParams);
|
|
61
|
+
} else if (typeof options.searchParams === "string") {
|
|
62
|
+
searchParams = new URLSearchParams(options.searchParams);
|
|
63
|
+
} else {
|
|
64
|
+
searchParams = new URLSearchParams();
|
|
65
|
+
Object.entries(options.searchParams).forEach(([key, value]) => {
|
|
66
|
+
if (Array.isArray(value)) {
|
|
67
|
+
value.forEach((v) => searchParams.append(key, String(v)));
|
|
68
|
+
} else if (value !== void 0 && value !== null) {
|
|
69
|
+
searchParams.append(key, String(value));
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
searchParams = new URLSearchParams();
|
|
75
|
+
}
|
|
76
|
+
if (!searchParams.has("companyType")) {
|
|
77
|
+
searchParams.set("companyType", this.#companyType);
|
|
78
|
+
console.log("AsstClient: Added companyType parameter:", this.#companyType);
|
|
79
|
+
}
|
|
80
|
+
mergedOptions.searchParams = searchParams;
|
|
81
|
+
return mergedOptions;
|
|
82
|
+
}
|
|
83
|
+
updateConfig(options) {
|
|
84
|
+
this.#client = this.#client.extend(options);
|
|
85
|
+
this.#currentConfig = options;
|
|
86
|
+
if (options.prefixUrl) {
|
|
87
|
+
this.#baseUrl = options.prefixUrl;
|
|
88
|
+
}
|
|
89
|
+
this.#listeners.forEach((listener) => listener(options));
|
|
90
|
+
}
|
|
91
|
+
getBaseUrl() {
|
|
92
|
+
return this.#baseUrl;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Subscribe to config changes. The callback will be immediately invoked with the current config.
|
|
96
|
+
* @param subscriptionCallback Function that will be called with the new config every time it is changed
|
|
97
|
+
* @returns Function to unsubscribe to config changes
|
|
98
|
+
*/
|
|
99
|
+
subscribeToConfigChange(listener) {
|
|
100
|
+
this.#listeners.add(listener);
|
|
101
|
+
listener(this.#currentConfig);
|
|
102
|
+
return () => this.#listeners.delete(listener);
|
|
103
|
+
}
|
|
104
|
+
get(url, options) {
|
|
105
|
+
return this.#client.get(url, this.#mergeCompanyTypeParam(options));
|
|
106
|
+
}
|
|
107
|
+
post(url, options) {
|
|
108
|
+
return this.#client.post(url, this.#mergeCompanyTypeParam(options));
|
|
109
|
+
}
|
|
110
|
+
put(url, options) {
|
|
111
|
+
return this.#client.put(url, this.#mergeCompanyTypeParam(options));
|
|
112
|
+
}
|
|
113
|
+
patch(url, options) {
|
|
114
|
+
return this.#client.patch(url, this.#mergeCompanyTypeParam(options));
|
|
115
|
+
}
|
|
116
|
+
head(url, options) {
|
|
117
|
+
return this.#client.head(url, this.#mergeCompanyTypeParam(options));
|
|
118
|
+
}
|
|
119
|
+
delete(url, options) {
|
|
120
|
+
return this.#client.delete(url, this.#mergeCompanyTypeParam(options));
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export {
|
|
125
|
+
BASE_URLS,
|
|
126
|
+
envSchema,
|
|
127
|
+
AsstClient
|
|
128
|
+
};
|
|
@@ -13,13 +13,14 @@ import {
|
|
|
13
13
|
itemHierarchyResponseSchema,
|
|
14
14
|
itemSearchViewSchema,
|
|
15
15
|
itemStatusResponseSchema,
|
|
16
|
+
itemStatusV2ResponseSchema,
|
|
16
17
|
localeSchema,
|
|
17
18
|
spreadsheetTemplateSchema,
|
|
18
19
|
spsItemIdResponseSchema,
|
|
19
20
|
tradingPartnerAccessByCompanyIdSchema,
|
|
20
21
|
userAccountSchema,
|
|
21
22
|
vendorPartnerAttGroupsSchema
|
|
22
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-NUUQDRHD.js";
|
|
23
24
|
|
|
24
25
|
// lib/imports/index.ts
|
|
25
26
|
var BASE_URL = "imports";
|
|
@@ -386,11 +387,23 @@ function createItemsApi(client) {
|
|
|
386
387
|
};
|
|
387
388
|
}
|
|
388
389
|
|
|
390
|
+
// lib/items/v2/index.ts
|
|
391
|
+
var BASE_URL13 = "v2/items";
|
|
392
|
+
function createItemsApiV2(client) {
|
|
393
|
+
async function getItemStatus(itemIds) {
|
|
394
|
+
const data = await client.post(`${BASE_URL13}/status`, { json: { itemIds } }).json();
|
|
395
|
+
return itemStatusV2ResponseSchema.parse(data);
|
|
396
|
+
}
|
|
397
|
+
return {
|
|
398
|
+
getItemStatus
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
|
|
389
402
|
// lib/errors/v1/index.ts
|
|
390
|
-
var
|
|
403
|
+
var BASE_URL14 = "errors";
|
|
391
404
|
function createErrorsApi(client) {
|
|
392
405
|
async function getInvalidItemErrorDetails(itemInfoId, signal) {
|
|
393
|
-
const data = await client.get(`${
|
|
406
|
+
const data = await client.get(`${BASE_URL14}/items/${itemInfoId}`, {
|
|
394
407
|
signal
|
|
395
408
|
}).json();
|
|
396
409
|
return itemErrorDetailsResultSchema.parse(data);
|
|
@@ -401,7 +414,7 @@ function createErrorsApi(client) {
|
|
|
401
414
|
}
|
|
402
415
|
|
|
403
416
|
// lib/errors/v2/index.ts
|
|
404
|
-
var
|
|
417
|
+
var BASE_URL15 = "errors/v2";
|
|
405
418
|
function createErrorsApiV2(client) {
|
|
406
419
|
async function getItemErrorSummary(params, signal) {
|
|
407
420
|
const searchParams = new URLSearchParams();
|
|
@@ -414,11 +427,11 @@ function createErrorsApiV2(client) {
|
|
|
414
427
|
if (params.limit) searchParams.append("limit", params.limit.toString());
|
|
415
428
|
if (params.docInEventId) searchParams.append("docInEventId", params.docInEventId);
|
|
416
429
|
if (params.importId) searchParams.append("importId", params.importId);
|
|
417
|
-
const data = await client.get(`${
|
|
430
|
+
const data = await client.get(`${BASE_URL15}/summary`, { signal, searchParams }).json();
|
|
418
431
|
return itemErrorSummaryResultV2Schema.parse(data);
|
|
419
432
|
}
|
|
420
433
|
async function getItemErrorDetails(itemInfoId, signal) {
|
|
421
|
-
const data = await client.get(`${
|
|
434
|
+
const data = await client.get(`${BASE_URL15}/items/${itemInfoId}`, { signal }).json();
|
|
422
435
|
return itemErrorDetailsResultV2Schema.parse(data);
|
|
423
436
|
}
|
|
424
437
|
return {
|
|
@@ -458,17 +471,17 @@ var FlattenedItemIdentifierKeysSchema = external_exports.enum(
|
|
|
458
471
|
);
|
|
459
472
|
|
|
460
473
|
// lib/uniqueCriteria/index.ts
|
|
461
|
-
var
|
|
474
|
+
var BASE_URL16 = "uniquecriteria";
|
|
462
475
|
function createUniqueCriteriaApi(client) {
|
|
463
476
|
async function getUniqueCriteriaByOrg(params, signal) {
|
|
464
|
-
const data = await client.get(`${
|
|
477
|
+
const data = await client.get(`${BASE_URL16}/org`, {
|
|
465
478
|
searchParams: params,
|
|
466
479
|
signal
|
|
467
480
|
}).json();
|
|
468
481
|
return external_exports.array(external_exports.string()).parse(data);
|
|
469
482
|
}
|
|
470
483
|
async function getProductUniqueCriteriaByOrg(params, signal) {
|
|
471
|
-
const data = await client.get(`${
|
|
484
|
+
const data = await client.get(`${BASE_URL16}/product/org`, {
|
|
472
485
|
searchParams: params,
|
|
473
486
|
signal
|
|
474
487
|
}).json();
|
|
@@ -478,10 +491,10 @@ function createUniqueCriteriaApi(client) {
|
|
|
478
491
|
}
|
|
479
492
|
|
|
480
493
|
// lib/companies/index.ts
|
|
481
|
-
var
|
|
494
|
+
var BASE_URL17 = "companys";
|
|
482
495
|
function createCompaniesApi(client) {
|
|
483
496
|
async function getCompanyBriefInfoByOrg(params, signal) {
|
|
484
|
-
const data = await client.get(`${
|
|
497
|
+
const data = await client.get(`${BASE_URL17}/brief`, {
|
|
485
498
|
searchParams: params,
|
|
486
499
|
signal
|
|
487
500
|
}).json();
|
|
@@ -518,11 +531,14 @@ export {
|
|
|
518
531
|
BASE_URL12,
|
|
519
532
|
createItemsApi,
|
|
520
533
|
BASE_URL13,
|
|
521
|
-
|
|
534
|
+
createItemsApiV2,
|
|
522
535
|
BASE_URL14,
|
|
536
|
+
createErrorsApi,
|
|
537
|
+
BASE_URL15,
|
|
523
538
|
createErrorsApiV2,
|
|
524
539
|
FlattenedItemIdentifierKeysSchema,
|
|
525
|
-
|
|
540
|
+
BASE_URL16,
|
|
526
541
|
createUniqueCriteriaApi,
|
|
542
|
+
BASE_URL17,
|
|
527
543
|
createCompaniesApi
|
|
528
544
|
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import {
|
|
2
|
+
external_exports
|
|
3
|
+
} from "./chunk-NUUQDRHD.js";
|
|
4
|
+
|
|
5
|
+
// lib/asstClient.ts
|
|
6
|
+
import ky from "ky";
|
|
7
|
+
var baseUrlsSchema = external_exports.object({
|
|
8
|
+
local: external_exports.literal("https://localhost:8443/"),
|
|
9
|
+
test: external_exports.literal(
|
|
10
|
+
"https://integration.api.spscommerce.com/assortment/gateway/"
|
|
11
|
+
),
|
|
12
|
+
prod: external_exports.literal("https://api.spscommerce.com/assortment/gateway/")
|
|
13
|
+
});
|
|
14
|
+
var BASE_URLS = {
|
|
15
|
+
local: "https://localhost:8443/",
|
|
16
|
+
test: "https://integration.api.spscommerce.com/assortment/gateway/",
|
|
17
|
+
prod: "https://api.spscommerce.com/assortment/gateway/"
|
|
18
|
+
};
|
|
19
|
+
var envSchema = baseUrlsSchema.keyof();
|
|
20
|
+
var initialConfig = {
|
|
21
|
+
prefixUrl: BASE_URLS["test"],
|
|
22
|
+
retry: 0
|
|
23
|
+
};
|
|
24
|
+
var AsstClient = class {
|
|
25
|
+
#client = ky.create(initialConfig);
|
|
26
|
+
#baseUrl = BASE_URLS["test"];
|
|
27
|
+
#listeners = /* @__PURE__ */ new Set();
|
|
28
|
+
#currentConfig = initialConfig;
|
|
29
|
+
#companyType;
|
|
30
|
+
constructor(options) {
|
|
31
|
+
if (options) {
|
|
32
|
+
this.updateConfig(options);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Set company type that will be automatically added to all requests
|
|
37
|
+
* @param companyType Company type to add to all requests ('RETAILER' | 'SUPPLIER')
|
|
38
|
+
*/
|
|
39
|
+
setCompanyType(companyType) {
|
|
40
|
+
this.#companyType = companyType;
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get the current company type
|
|
45
|
+
* @returns Current company type or undefined if not set
|
|
46
|
+
*/
|
|
47
|
+
getCompanyType() {
|
|
48
|
+
return this.#companyType;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Private method to merge companyType with existing searchParams
|
|
52
|
+
*/
|
|
53
|
+
#mergeCompanyTypeParam(options = {}) {
|
|
54
|
+
console.log(
|
|
55
|
+
"AsstClient: mergeCompanyTypeParam called with companyType:",
|
|
56
|
+
this.#companyType
|
|
57
|
+
);
|
|
58
|
+
if (!this.#companyType) return options;
|
|
59
|
+
const mergedOptions = { ...options };
|
|
60
|
+
let searchParams;
|
|
61
|
+
if (options.searchParams) {
|
|
62
|
+
if (options.searchParams instanceof URLSearchParams) {
|
|
63
|
+
searchParams = new URLSearchParams(options.searchParams);
|
|
64
|
+
} else if (typeof options.searchParams === "string") {
|
|
65
|
+
searchParams = new URLSearchParams(options.searchParams);
|
|
66
|
+
} else {
|
|
67
|
+
searchParams = new URLSearchParams();
|
|
68
|
+
Object.entries(options.searchParams).forEach(([key, value]) => {
|
|
69
|
+
if (Array.isArray(value)) {
|
|
70
|
+
value.forEach((v) => searchParams.append(key, String(v)));
|
|
71
|
+
} else if (value !== void 0 && value !== null) {
|
|
72
|
+
searchParams.append(key, String(value));
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
searchParams = new URLSearchParams();
|
|
78
|
+
}
|
|
79
|
+
if (!searchParams.has("companyType")) {
|
|
80
|
+
searchParams.set("companyType", this.#companyType);
|
|
81
|
+
console.log(
|
|
82
|
+
"AsstClient: Added companyType parameter:",
|
|
83
|
+
this.#companyType
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
mergedOptions.searchParams = searchParams;
|
|
87
|
+
return mergedOptions;
|
|
88
|
+
}
|
|
89
|
+
updateConfig(options) {
|
|
90
|
+
this.#client = this.#client.extend(options);
|
|
91
|
+
this.#currentConfig = options;
|
|
92
|
+
if (options.prefixUrl) {
|
|
93
|
+
this.#baseUrl = options.prefixUrl;
|
|
94
|
+
}
|
|
95
|
+
this.#listeners.forEach((listener) => listener(options));
|
|
96
|
+
}
|
|
97
|
+
getBaseUrl() {
|
|
98
|
+
return this.#baseUrl;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Subscribe to config changes. The callback will be immediately invoked with the current config.
|
|
102
|
+
* @param subscriptionCallback Function that will be called with the new config every time it is changed
|
|
103
|
+
* @returns Function to unsubscribe to config changes
|
|
104
|
+
*/
|
|
105
|
+
subscribeToConfigChange(listener) {
|
|
106
|
+
this.#listeners.add(listener);
|
|
107
|
+
listener(this.#currentConfig);
|
|
108
|
+
return () => this.#listeners.delete(listener);
|
|
109
|
+
}
|
|
110
|
+
get(url, options) {
|
|
111
|
+
return this.#client.get(url, this.#mergeCompanyTypeParam(options));
|
|
112
|
+
}
|
|
113
|
+
post(url, options) {
|
|
114
|
+
return this.#client.post(url, this.#mergeCompanyTypeParam(options));
|
|
115
|
+
}
|
|
116
|
+
put(url, options) {
|
|
117
|
+
return this.#client.put(url, this.#mergeCompanyTypeParam(options));
|
|
118
|
+
}
|
|
119
|
+
patch(url, options) {
|
|
120
|
+
return this.#client.patch(url, this.#mergeCompanyTypeParam(options));
|
|
121
|
+
}
|
|
122
|
+
head(url, options) {
|
|
123
|
+
return this.#client.head(url, this.#mergeCompanyTypeParam(options));
|
|
124
|
+
}
|
|
125
|
+
delete(url, options) {
|
|
126
|
+
return this.#client.delete(url, this.#mergeCompanyTypeParam(options));
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export {
|
|
131
|
+
BASE_URLS,
|
|
132
|
+
envSchema,
|
|
133
|
+
AsstClient
|
|
134
|
+
};
|