@spscommerce/asst-api 0.0.1-beta.3 → 0.0.1-beta.5
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/ItemCategoriesSearch-e0870a34.d.ts +318 -0
- package/dist/ItemCategoriesSearch-e3298650.d.ts +319 -0
- package/dist/ItemCategoriesSearch-ec43591f.d.ts +319 -0
- package/dist/chunk-3FMMM7IS.js +80 -0
- package/dist/chunk-6ZNFOWTV.js +78 -0
- package/dist/chunk-FS6LHGAR.js +87 -0
- package/dist/chunk-GDFX3WTX.js +78 -0
- package/dist/chunk-LYMGZWSR.js +80 -0
- package/dist/chunk-N2OYWNHF.js +80 -0
- package/dist/chunk-OA6PO3QG.js +78 -0
- package/dist/chunk-OBXZRDPY.js +77 -0
- package/dist/chunk-OI47EFQH.js +82 -0
- package/dist/chunk-T3UCSW2B.js +81 -0
- package/dist/chunk-XMNYZGXF.js +84 -0
- package/dist/chunk-YCQUK6KV.js +85 -0
- package/dist/index.cjs +67 -49
- package/dist/index.d.ts +4 -6
- package/dist/index.js +4 -52
- package/dist/msw.d.ts +3 -4
- package/dist/zod.cjs +32 -0
- package/dist/zod.d.ts +3 -2
- package/dist/zod.js +4 -0
- package/package.json +4 -4
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import * as ky_universal from 'ky-universal';
|
|
2
|
+
import { Options } from 'ky';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
declare const baseUrlsSchema: z.ZodObject<{
|
|
6
|
+
local: z.ZodLiteral<"https://localhost:8443">;
|
|
7
|
+
test: z.ZodLiteral<"https://integration.api.spscommerce.com/assortment/gateway">;
|
|
8
|
+
prod: z.ZodLiteral<"https://api.spscommerce.com/assortment/gateway">;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
local: "https://localhost:8443";
|
|
11
|
+
test: "https://integration.api.spscommerce.com/assortment/gateway";
|
|
12
|
+
prod: "https://api.spscommerce.com/assortment/gateway";
|
|
13
|
+
}, {
|
|
14
|
+
local: "https://localhost:8443";
|
|
15
|
+
test: "https://integration.api.spscommerce.com/assortment/gateway";
|
|
16
|
+
prod: "https://api.spscommerce.com/assortment/gateway";
|
|
17
|
+
}>;
|
|
18
|
+
type BaseUrls = z.infer<typeof baseUrlsSchema>;
|
|
19
|
+
declare const BASE_URLS: BaseUrls;
|
|
20
|
+
declare const envSchema: z.ZodEnum<["local", "test", "prod"]>;
|
|
21
|
+
type Env = z.infer<typeof envSchema>;
|
|
22
|
+
type AsstUrl = BaseUrls[Env];
|
|
23
|
+
interface AsstClientOptions extends Options {
|
|
24
|
+
prefixUrl?: AsstUrl;
|
|
25
|
+
}
|
|
26
|
+
type Input = string | URL | Request;
|
|
27
|
+
type Listener = (config: AsstClientOptions) => void;
|
|
28
|
+
declare class AsstClient {
|
|
29
|
+
#private;
|
|
30
|
+
constructor(options?: AsstClientOptions);
|
|
31
|
+
updateConfig(options: AsstClientOptions): void;
|
|
32
|
+
getBaseUrl(): AsstUrl;
|
|
33
|
+
/**
|
|
34
|
+
* Subscribe to config changes. The callback will be immediately invoked with the current config.
|
|
35
|
+
* @param subscriptionCallback Function that will be called with the new config every time it is changed
|
|
36
|
+
* @returns Function to unsubscribe to config changes
|
|
37
|
+
*/
|
|
38
|
+
subscribeToConfigChange(listener: Listener): () => boolean;
|
|
39
|
+
get(url: Input, options?: AsstClientOptions): ky_universal.ResponsePromise;
|
|
40
|
+
post(url: Input, options?: AsstClientOptions): ky_universal.ResponsePromise;
|
|
41
|
+
put(url: Input, options?: AsstClientOptions): ky_universal.ResponsePromise;
|
|
42
|
+
patch(url: Input, options?: AsstClientOptions): ky_universal.ResponsePromise;
|
|
43
|
+
head(url: Input, options?: AsstClientOptions): ky_universal.ResponsePromise;
|
|
44
|
+
delete(url: Input, options?: AsstClientOptions): ky_universal.ResponsePromise;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
declare const importSchema: z.ZodObject<{
|
|
48
|
+
count: z.ZodNumber;
|
|
49
|
+
imports: z.ZodArray<z.ZodObject<{
|
|
50
|
+
completedAt: z.ZodNullable<z.ZodNumber>;
|
|
51
|
+
errorCount: z.ZodNumber;
|
|
52
|
+
importId: z.ZodNumber;
|
|
53
|
+
name: z.ZodString;
|
|
54
|
+
startedAt: z.ZodNullable<z.ZodString>;
|
|
55
|
+
status: z.ZodString;
|
|
56
|
+
uploadedAt: z.ZodString;
|
|
57
|
+
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
status: string;
|
|
59
|
+
completedAt: number | null;
|
|
60
|
+
errorCount: number;
|
|
61
|
+
importId: number;
|
|
62
|
+
name: string;
|
|
63
|
+
startedAt: string | null;
|
|
64
|
+
uploadedAt: string;
|
|
65
|
+
}, {
|
|
66
|
+
status: string;
|
|
67
|
+
completedAt: number | null;
|
|
68
|
+
errorCount: number;
|
|
69
|
+
importId: number;
|
|
70
|
+
name: string;
|
|
71
|
+
startedAt: string | null;
|
|
72
|
+
uploadedAt: string;
|
|
73
|
+
}>, "many">;
|
|
74
|
+
}, "strip", z.ZodTypeAny, {
|
|
75
|
+
count: number;
|
|
76
|
+
imports: {
|
|
77
|
+
status: string;
|
|
78
|
+
completedAt: number | null;
|
|
79
|
+
errorCount: number;
|
|
80
|
+
importId: number;
|
|
81
|
+
name: string;
|
|
82
|
+
startedAt: string | null;
|
|
83
|
+
uploadedAt: string;
|
|
84
|
+
}[];
|
|
85
|
+
}, {
|
|
86
|
+
count: number;
|
|
87
|
+
imports: {
|
|
88
|
+
status: string;
|
|
89
|
+
completedAt: number | null;
|
|
90
|
+
errorCount: number;
|
|
91
|
+
importId: number;
|
|
92
|
+
name: string;
|
|
93
|
+
startedAt: string | null;
|
|
94
|
+
uploadedAt: string;
|
|
95
|
+
}[];
|
|
96
|
+
}>;
|
|
97
|
+
type Import = z.infer<typeof importSchema>;
|
|
98
|
+
|
|
99
|
+
declare const importErrorsSchema: z.ZodObject<{
|
|
100
|
+
count: z.ZodNumber;
|
|
101
|
+
errors: z.ZodArray<z.ZodObject<{
|
|
102
|
+
attribute: z.ZodString;
|
|
103
|
+
description: z.ZodString;
|
|
104
|
+
importErrorId: z.ZodNumber;
|
|
105
|
+
row: z.ZodNumber;
|
|
106
|
+
}, "strip", z.ZodTypeAny, {
|
|
107
|
+
attribute: string;
|
|
108
|
+
description: string;
|
|
109
|
+
importErrorId: number;
|
|
110
|
+
row: number;
|
|
111
|
+
}, {
|
|
112
|
+
attribute: string;
|
|
113
|
+
description: string;
|
|
114
|
+
importErrorId: number;
|
|
115
|
+
row: number;
|
|
116
|
+
}>, "many">;
|
|
117
|
+
hasNext: z.ZodBoolean;
|
|
118
|
+
importId: z.ZodNumber;
|
|
119
|
+
totalCount: z.ZodNumber;
|
|
120
|
+
}, "strip", z.ZodTypeAny, {
|
|
121
|
+
importId: number;
|
|
122
|
+
count: number;
|
|
123
|
+
errors: {
|
|
124
|
+
attribute: string;
|
|
125
|
+
description: string;
|
|
126
|
+
importErrorId: number;
|
|
127
|
+
row: number;
|
|
128
|
+
}[];
|
|
129
|
+
hasNext: boolean;
|
|
130
|
+
totalCount: number;
|
|
131
|
+
}, {
|
|
132
|
+
importId: number;
|
|
133
|
+
count: number;
|
|
134
|
+
errors: {
|
|
135
|
+
attribute: string;
|
|
136
|
+
description: string;
|
|
137
|
+
importErrorId: number;
|
|
138
|
+
row: number;
|
|
139
|
+
}[];
|
|
140
|
+
hasNext: boolean;
|
|
141
|
+
totalCount: number;
|
|
142
|
+
}>;
|
|
143
|
+
type ImportErrors = z.infer<typeof importErrorsSchema>;
|
|
144
|
+
|
|
145
|
+
declare const importsStatusSchema: z.ZodObject<{
|
|
146
|
+
completedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
147
|
+
docInEventId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
148
|
+
errorCount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
149
|
+
importId: z.ZodNumber;
|
|
150
|
+
invalidItemCount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
151
|
+
name: z.ZodString;
|
|
152
|
+
status: z.ZodEnum<["QUEUED_FOR_IMPORT", "IN_PROGRESS", "DOC_FAILED", "VALIDATION_FAILED", "COMPLETED"]>;
|
|
153
|
+
totalItemCount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
154
|
+
validItemCount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
155
|
+
}, "strip", z.ZodTypeAny, {
|
|
156
|
+
status: "QUEUED_FOR_IMPORT" | "IN_PROGRESS" | "DOC_FAILED" | "VALIDATION_FAILED" | "COMPLETED";
|
|
157
|
+
importId: number;
|
|
158
|
+
name: string;
|
|
159
|
+
completedAt?: string | null | undefined;
|
|
160
|
+
docInEventId?: string | null | undefined;
|
|
161
|
+
errorCount?: number | null | undefined;
|
|
162
|
+
invalidItemCount?: number | null | undefined;
|
|
163
|
+
totalItemCount?: number | null | undefined;
|
|
164
|
+
validItemCount?: number | null | undefined;
|
|
165
|
+
}, {
|
|
166
|
+
status: "QUEUED_FOR_IMPORT" | "IN_PROGRESS" | "DOC_FAILED" | "VALIDATION_FAILED" | "COMPLETED";
|
|
167
|
+
importId: number;
|
|
168
|
+
name: string;
|
|
169
|
+
completedAt?: string | null | undefined;
|
|
170
|
+
docInEventId?: string | null | undefined;
|
|
171
|
+
errorCount?: number | null | undefined;
|
|
172
|
+
invalidItemCount?: number | null | undefined;
|
|
173
|
+
totalItemCount?: number | null | undefined;
|
|
174
|
+
validItemCount?: number | null | undefined;
|
|
175
|
+
}>;
|
|
176
|
+
type ImportsStatus = z.infer<typeof importsStatusSchema>;
|
|
177
|
+
|
|
178
|
+
declare const exportSchema: z.ZodObject<{
|
|
179
|
+
exportName: z.ZodString;
|
|
180
|
+
exportDescription: z.ZodString;
|
|
181
|
+
isActive: z.ZodBoolean;
|
|
182
|
+
exportType: z.ZodEnum<["ALL", "UPDATES", "DELTAS_UPDATE", "NO_BUYER_PART_NUMBER"]>;
|
|
183
|
+
exportFrequency: z.ZodEnum<["IMMEDIATE", "ONETIME", "DAILY", "WEEKLY", "MONTHLY"]>;
|
|
184
|
+
includeValidAttributes: z.ZodOptional<z.ZodBoolean>;
|
|
185
|
+
dayOfMonth: z.ZodOptional<z.ZodNumber>;
|
|
186
|
+
dayOfWeek: z.ZodOptional<z.ZodEnum<["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"]>>;
|
|
187
|
+
hourOfDay: z.ZodOptional<z.ZodNumber>;
|
|
188
|
+
date: z.ZodOptional<z.ZodString>;
|
|
189
|
+
catalogIds: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
190
|
+
itemInfoIds: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
191
|
+
excludeItemInfoIds: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
192
|
+
selectionCodeIds: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
193
|
+
productCodeIds: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
194
|
+
productTypes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
195
|
+
deliveryType: z.ZodOptional<z.ZodString>;
|
|
196
|
+
spreadsheetTemplateId: z.ZodOptional<z.ZodNumber>;
|
|
197
|
+
emailAddresses: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
198
|
+
subjectLine: z.ZodOptional<z.ZodString>;
|
|
199
|
+
additionalLocales: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
200
|
+
}, "strip", z.ZodTypeAny, {
|
|
201
|
+
exportName: string;
|
|
202
|
+
exportDescription: string;
|
|
203
|
+
isActive: boolean;
|
|
204
|
+
exportType: "ALL" | "UPDATES" | "DELTAS_UPDATE" | "NO_BUYER_PART_NUMBER";
|
|
205
|
+
exportFrequency: "IMMEDIATE" | "ONETIME" | "DAILY" | "WEEKLY" | "MONTHLY";
|
|
206
|
+
includeValidAttributes?: boolean | undefined;
|
|
207
|
+
dayOfMonth?: number | undefined;
|
|
208
|
+
dayOfWeek?: "MON" | "TUE" | "WED" | "THU" | "FRI" | "SAT" | "SUN" | undefined;
|
|
209
|
+
hourOfDay?: number | undefined;
|
|
210
|
+
date?: string | undefined;
|
|
211
|
+
catalogIds?: number[] | undefined;
|
|
212
|
+
itemInfoIds?: number[] | undefined;
|
|
213
|
+
excludeItemInfoIds?: number[] | undefined;
|
|
214
|
+
selectionCodeIds?: number[] | undefined;
|
|
215
|
+
productCodeIds?: number[] | undefined;
|
|
216
|
+
productTypes?: string[] | undefined;
|
|
217
|
+
deliveryType?: string | undefined;
|
|
218
|
+
spreadsheetTemplateId?: number | undefined;
|
|
219
|
+
emailAddresses?: string[] | undefined;
|
|
220
|
+
subjectLine?: string | undefined;
|
|
221
|
+
additionalLocales?: string[] | undefined;
|
|
222
|
+
}, {
|
|
223
|
+
exportName: string;
|
|
224
|
+
exportDescription: string;
|
|
225
|
+
isActive: boolean;
|
|
226
|
+
exportType: "ALL" | "UPDATES" | "DELTAS_UPDATE" | "NO_BUYER_PART_NUMBER";
|
|
227
|
+
exportFrequency: "IMMEDIATE" | "ONETIME" | "DAILY" | "WEEKLY" | "MONTHLY";
|
|
228
|
+
includeValidAttributes?: boolean | undefined;
|
|
229
|
+
dayOfMonth?: number | undefined;
|
|
230
|
+
dayOfWeek?: "MON" | "TUE" | "WED" | "THU" | "FRI" | "SAT" | "SUN" | undefined;
|
|
231
|
+
hourOfDay?: number | undefined;
|
|
232
|
+
date?: string | undefined;
|
|
233
|
+
catalogIds?: number[] | undefined;
|
|
234
|
+
itemInfoIds?: number[] | undefined;
|
|
235
|
+
excludeItemInfoIds?: number[] | undefined;
|
|
236
|
+
selectionCodeIds?: number[] | undefined;
|
|
237
|
+
productCodeIds?: number[] | undefined;
|
|
238
|
+
productTypes?: string[] | undefined;
|
|
239
|
+
deliveryType?: string | undefined;
|
|
240
|
+
spreadsheetTemplateId?: number | undefined;
|
|
241
|
+
emailAddresses?: string[] | undefined;
|
|
242
|
+
subjectLine?: string | undefined;
|
|
243
|
+
additionalLocales?: string[] | undefined;
|
|
244
|
+
}>;
|
|
245
|
+
type Export = z.infer<typeof exportSchema>;
|
|
246
|
+
|
|
247
|
+
declare const itemCategoriesSearchSchema: z.ZodObject<{
|
|
248
|
+
count: z.ZodNumber;
|
|
249
|
+
data: z.ZodArray<z.ZodObject<{
|
|
250
|
+
categoryid: z.ZodNumber;
|
|
251
|
+
companyId: z.ZodNumber;
|
|
252
|
+
name: z.ZodString;
|
|
253
|
+
isActive: z.ZodNumber;
|
|
254
|
+
createdDate: z.ZodNullable<z.ZodNumber>;
|
|
255
|
+
categorytimestamp: z.ZodNullable<z.ZodNumber>;
|
|
256
|
+
typeId: z.ZodNumber;
|
|
257
|
+
type: z.ZodString;
|
|
258
|
+
categorykey: z.ZodOptional<z.ZodString>;
|
|
259
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
260
|
+
categoryCatalogName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
261
|
+
}, "strip", z.ZodTypeAny, {
|
|
262
|
+
type: string;
|
|
263
|
+
name: string;
|
|
264
|
+
isActive: number;
|
|
265
|
+
createdDate: number | null;
|
|
266
|
+
companyId: number;
|
|
267
|
+
categoryid: number;
|
|
268
|
+
categorytimestamp: number | null;
|
|
269
|
+
typeId: number;
|
|
270
|
+
categorykey?: string | undefined;
|
|
271
|
+
description?: string | null | undefined;
|
|
272
|
+
categoryCatalogName?: string | null | undefined;
|
|
273
|
+
}, {
|
|
274
|
+
type: string;
|
|
275
|
+
name: string;
|
|
276
|
+
isActive: number;
|
|
277
|
+
createdDate: number | null;
|
|
278
|
+
companyId: number;
|
|
279
|
+
categoryid: number;
|
|
280
|
+
categorytimestamp: number | null;
|
|
281
|
+
typeId: number;
|
|
282
|
+
categorykey?: string | undefined;
|
|
283
|
+
description?: string | null | undefined;
|
|
284
|
+
categoryCatalogName?: string | null | undefined;
|
|
285
|
+
}>, "many">;
|
|
286
|
+
}, "strip", z.ZodTypeAny, {
|
|
287
|
+
data: {
|
|
288
|
+
type: string;
|
|
289
|
+
name: string;
|
|
290
|
+
isActive: number;
|
|
291
|
+
createdDate: number | null;
|
|
292
|
+
companyId: number;
|
|
293
|
+
categoryid: number;
|
|
294
|
+
categorytimestamp: number | null;
|
|
295
|
+
typeId: number;
|
|
296
|
+
categorykey?: string | undefined;
|
|
297
|
+
description?: string | null | undefined;
|
|
298
|
+
categoryCatalogName?: string | null | undefined;
|
|
299
|
+
}[];
|
|
300
|
+
count: number;
|
|
301
|
+
}, {
|
|
302
|
+
data: {
|
|
303
|
+
type: string;
|
|
304
|
+
name: string;
|
|
305
|
+
isActive: number;
|
|
306
|
+
createdDate: number | null;
|
|
307
|
+
companyId: number;
|
|
308
|
+
categoryid: number;
|
|
309
|
+
categorytimestamp: number | null;
|
|
310
|
+
typeId: number;
|
|
311
|
+
categorykey?: string | undefined;
|
|
312
|
+
description?: string | null | undefined;
|
|
313
|
+
categoryCatalogName?: string | null | undefined;
|
|
314
|
+
}[];
|
|
315
|
+
count: number;
|
|
316
|
+
}>;
|
|
317
|
+
type ItemCategoriesSearch = z.infer<typeof itemCategoriesSearchSchema>;
|
|
318
|
+
|
|
319
|
+
export { AsstClient as A, BASE_URLS as B, Export as E, Import as I, ImportsStatus as a, ItemCategoriesSearch as b, AsstClientOptions as c, AsstUrl as d, Env as e, ImportErrors as f, envSchema as g, importSchema as h, importErrorsSchema as i, importsStatusSchema as j, exportSchema as k, itemCategoriesSearchSchema as l };
|
|
@@ -0,0 +1,80 @@
|
|
|
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: ${JSON.stringify(options)}`);
|
|
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
|
+
this.#subscriptionCallback = subscriptionCallback;
|
|
51
|
+
subscriptionCallback(this.#currentConfig);
|
|
52
|
+
}
|
|
53
|
+
unsubscribeToConfigChange() {
|
|
54
|
+
this.#subscriptionCallback = void 0;
|
|
55
|
+
}
|
|
56
|
+
get(url, options) {
|
|
57
|
+
return this.#client.get(url, options);
|
|
58
|
+
}
|
|
59
|
+
post(url, options) {
|
|
60
|
+
return this.#client.post(url, options);
|
|
61
|
+
}
|
|
62
|
+
put(url, options) {
|
|
63
|
+
return this.#client.put(url, options);
|
|
64
|
+
}
|
|
65
|
+
patch(url, options) {
|
|
66
|
+
return this.#client.patch(url, options);
|
|
67
|
+
}
|
|
68
|
+
head(url, options) {
|
|
69
|
+
return this.#client.head(url, options);
|
|
70
|
+
}
|
|
71
|
+
delete(url, options) {
|
|
72
|
+
return this.#client.delete(url, options);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
BASE_URLS,
|
|
78
|
+
envSchema,
|
|
79
|
+
AsstClient
|
|
80
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
#listeners = /* @__PURE__ */ new Set();
|
|
26
|
+
// #subscriptionCallback?: (config: AsstClientOptions) => void;
|
|
27
|
+
#currentConfig = initialConfig;
|
|
28
|
+
constructor(options) {
|
|
29
|
+
if (options) {
|
|
30
|
+
this.updateConfig(options);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
updateConfig(options) {
|
|
34
|
+
this.#client = this.#client.extend(options);
|
|
35
|
+
this.#currentConfig = options;
|
|
36
|
+
if (options.prefixUrl) {
|
|
37
|
+
this.#baseUrl = options.prefixUrl;
|
|
38
|
+
}
|
|
39
|
+
this.#listeners.forEach((listener) => listener(options));
|
|
40
|
+
}
|
|
41
|
+
getBaseUrl() {
|
|
42
|
+
return this.#baseUrl;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Subscribe to config changes. The callback will be immediately invoked with the current config.
|
|
46
|
+
* @param subscriptionCallback Function that will be called with the new config every time it is changed
|
|
47
|
+
* @returns Function to unsubscribe to config changes
|
|
48
|
+
*/
|
|
49
|
+
subscribeToConfigChange(listener) {
|
|
50
|
+
this.#listeners.add(listener);
|
|
51
|
+
listener(this.#currentConfig);
|
|
52
|
+
return () => this.#listeners.delete(listener);
|
|
53
|
+
}
|
|
54
|
+
get(url, options) {
|
|
55
|
+
return this.#client.get(url, options);
|
|
56
|
+
}
|
|
57
|
+
post(url, options) {
|
|
58
|
+
return this.#client.post(url, options);
|
|
59
|
+
}
|
|
60
|
+
put(url, options) {
|
|
61
|
+
return this.#client.put(url, options);
|
|
62
|
+
}
|
|
63
|
+
patch(url, options) {
|
|
64
|
+
return this.#client.patch(url, options);
|
|
65
|
+
}
|
|
66
|
+
head(url, options) {
|
|
67
|
+
return this.#client.head(url, options);
|
|
68
|
+
}
|
|
69
|
+
delete(url, options) {
|
|
70
|
+
return this.#client.delete(url, options);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export {
|
|
75
|
+
BASE_URLS,
|
|
76
|
+
envSchema,
|
|
77
|
+
AsstClient
|
|
78
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
} else {
|
|
45
|
+
console.log(`No subscription callback`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
getBaseUrl() {
|
|
49
|
+
return this.#baseUrl;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Subscribe to config changes. The callback will be immediately invoked with the current config.
|
|
53
|
+
* @param subscriptionCallback Function that will be called with the new config every time it is changed
|
|
54
|
+
*/
|
|
55
|
+
subscribeToConfigChange(subscriptionCallback) {
|
|
56
|
+
console.log(`Subscription added`);
|
|
57
|
+
this.#subscriptionCallback = subscriptionCallback;
|
|
58
|
+
subscriptionCallback(this.#currentConfig);
|
|
59
|
+
}
|
|
60
|
+
unsubscribeToConfigChange() {
|
|
61
|
+
this.#subscriptionCallback = void 0;
|
|
62
|
+
}
|
|
63
|
+
get(url, options) {
|
|
64
|
+
return this.#client.get(url, options);
|
|
65
|
+
}
|
|
66
|
+
post(url, options) {
|
|
67
|
+
return this.#client.post(url, options);
|
|
68
|
+
}
|
|
69
|
+
put(url, options) {
|
|
70
|
+
return this.#client.put(url, options);
|
|
71
|
+
}
|
|
72
|
+
patch(url, options) {
|
|
73
|
+
return this.#client.patch(url, options);
|
|
74
|
+
}
|
|
75
|
+
head(url, options) {
|
|
76
|
+
return this.#client.head(url, options);
|
|
77
|
+
}
|
|
78
|
+
delete(url, options) {
|
|
79
|
+
return this.#client.delete(url, options);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export {
|
|
84
|
+
BASE_URLS,
|
|
85
|
+
envSchema,
|
|
86
|
+
AsstClient
|
|
87
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
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: ${JSON.stringify(options)}`);
|
|
28
|
+
this.updateConfig(options);
|
|
29
|
+
}
|
|
30
|
+
updateConfig(options) {
|
|
31
|
+
this.#client = this.#client.extend(options);
|
|
32
|
+
this.#currentConfig = options;
|
|
33
|
+
if (options.prefixUrl) {
|
|
34
|
+
this.#baseUrl = options.prefixUrl;
|
|
35
|
+
}
|
|
36
|
+
if (this.#subscriptionCallback) {
|
|
37
|
+
this.#subscriptionCallback(options);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
getBaseUrl() {
|
|
41
|
+
return this.#baseUrl;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Subscribe to config changes. The callback will be immediately invoked with the current config.
|
|
45
|
+
* @param subscriptionCallback Function that will be called with the new config every time it is changed
|
|
46
|
+
*/
|
|
47
|
+
subscribeToConfigChange(subscriptionCallback) {
|
|
48
|
+
this.#subscriptionCallback = subscriptionCallback;
|
|
49
|
+
subscriptionCallback(this.#currentConfig);
|
|
50
|
+
}
|
|
51
|
+
unsubscribeToConfigChange() {
|
|
52
|
+
this.#subscriptionCallback = void 0;
|
|
53
|
+
}
|
|
54
|
+
get(url, options) {
|
|
55
|
+
return this.#client.get(url, options);
|
|
56
|
+
}
|
|
57
|
+
post(url, options) {
|
|
58
|
+
return this.#client.post(url, options);
|
|
59
|
+
}
|
|
60
|
+
put(url, options) {
|
|
61
|
+
return this.#client.put(url, options);
|
|
62
|
+
}
|
|
63
|
+
patch(url, options) {
|
|
64
|
+
return this.#client.patch(url, options);
|
|
65
|
+
}
|
|
66
|
+
head(url, options) {
|
|
67
|
+
return this.#client.head(url, options);
|
|
68
|
+
}
|
|
69
|
+
delete(url, options) {
|
|
70
|
+
return this.#client.delete(url, options);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export {
|
|
75
|
+
BASE_URLS,
|
|
76
|
+
envSchema,
|
|
77
|
+
AsstClient
|
|
78
|
+
};
|