@spscommerce/asst-api 4.3.0 → 4.4.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/{chunk-CI3ZSIT4.js → chunk-V2XRXJIJ.js} +129 -33
- package/dist/{chunk-RPGGEEFE.js → chunk-WODMKML4.js} +1 -1
- package/dist/{chunk-LKUGPDIT.js → chunk-YT2B4UAK.js} +33 -0
- package/dist/index.cjs +157 -32
- package/dist/index.d.cts +127 -11
- package/dist/index.d.ts +127 -11
- package/dist/index.js +3 -3
- package/dist/msw.cjs +70 -1
- package/dist/msw.d.cts +27 -6
- package/dist/msw.d.ts +27 -6
- package/dist/msw.js +36 -3
- package/dist/zod.cjs +31 -0
- package/dist/zod.d.cts +1 -1
- package/dist/zod.d.ts +1 -1
- package/dist/zod.js +2 -2
- package/package.json +1 -1
- package/dist/SpsItemIdResponse-0VgfCmG_.d.cts +0 -84
- package/dist/SpsItemIdResponse-0VgfCmG_.d.ts +0 -84
- package/dist/SpsItemIdResponse-CI_Ao86P.d.cts +0 -87
- package/dist/SpsItemIdResponse-CI_Ao86P.d.ts +0 -87
- package/dist/chunk-355LPVI6.js +0 -126
- package/dist/chunk-55ECRTUX.js +0 -79
- package/dist/chunk-63KIELUR.js +0 -128
- package/dist/chunk-DK2OMRWR.js +0 -134
- package/dist/chunk-FCUIJXCD.js +0 -544
- package/dist/chunk-L4AWOEED.js +0 -4892
- package/dist/chunk-NFZI7D22.js +0 -544
- package/dist/chunk-NUUQDRHD.js +0 -4899
- package/dist/zod-C3fOiO-H.d.cts +0 -5900
- package/dist/zod-CJ6AFTQr.d.ts +0 -5900
- package/dist/zod-CJmsC_DX.d.cts +0 -5900
- package/dist/zod-CzPw-bfk.d.cts +0 -5900
- package/dist/zod-vDuspd-x.d.ts +0 -5900
- package/dist/zod-xWM6u1LJ.d.ts +0 -5900
- package/dist/{zod-C41Rts8D.d.cts → zod-CJ7lvFQH.d.cts} +44 -44
- package/dist/{zod-COyz02Lh.d.ts → zod-j6CrX5vY.d.ts} +44 -44
package/dist/chunk-63KIELUR.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/chunk-DK2OMRWR.js
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
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
|
-
};
|