@spscommerce/asst-api 0.0.1-beta.2 → 0.0.1-beta.4
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-44b87663.d.ts +318 -0
- package/dist/ItemCategoriesSearch-e0870a34.d.ts +318 -0
- package/dist/ItemCategoriesSearch-ec43591f.d.ts +319 -0
- package/dist/ItemCategory-14816deb.d.ts +99 -0
- package/dist/TradingPartnerAccessByCompanyId-29866586.d.ts +97 -0
- package/dist/TradingPartnerAccessByCompanyId-43f83fb6.d.ts +130 -0
- package/dist/TradingPartnerAccessByCompanyId-53b868a8.d.ts +125 -0
- package/dist/TradingPartnerAccessByCompanyId-b227f0c5.d.ts +125 -0
- package/dist/TradingPartnerAccessByCompanyId-e7a1d443.d.ts +129 -0
- package/dist/chunk-3FMMM7IS.js +80 -0
- package/dist/chunk-6ZNFOWTV.js +78 -0
- package/dist/chunk-F3KCLICG.js +77 -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 -5
- package/dist/index.js +4 -52
- package/dist/msw.d.ts +3 -3
- package/dist/zod.cjs +32 -0
- package/dist/zod.d.ts +4 -2
- package/dist/zod.js +4 -0
- package/package.json +1 -1
|
@@ -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
|
+
};
|
|
@@ -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 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
|
+
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,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: ${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
|
+
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 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`);
|
|
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
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
#currentConfig = initialConfig;
|
|
27
|
+
constructor(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
|
+
this.#listeners.forEach((listener) => listener(options));
|
|
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
|
+
* @returns Function to unsubscribe to config changes
|
|
47
|
+
*/
|
|
48
|
+
subscribeToConfigChange(listener) {
|
|
49
|
+
this.#listeners.add(listener);
|
|
50
|
+
listener(this.#currentConfig);
|
|
51
|
+
return () => this.#listeners.delete(listener);
|
|
52
|
+
}
|
|
53
|
+
get(url, options) {
|
|
54
|
+
return this.#client.get(url, options);
|
|
55
|
+
}
|
|
56
|
+
post(url, options) {
|
|
57
|
+
return this.#client.post(url, options);
|
|
58
|
+
}
|
|
59
|
+
put(url, options) {
|
|
60
|
+
return this.#client.put(url, options);
|
|
61
|
+
}
|
|
62
|
+
patch(url, options) {
|
|
63
|
+
return this.#client.patch(url, options);
|
|
64
|
+
}
|
|
65
|
+
head(url, options) {
|
|
66
|
+
return this.#client.head(url, options);
|
|
67
|
+
}
|
|
68
|
+
delete(url, options) {
|
|
69
|
+
return this.#client.delete(url, options);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export {
|
|
74
|
+
BASE_URLS,
|
|
75
|
+
envSchema,
|
|
76
|
+
AsstClient
|
|
77
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
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(`AsstClient created! Config: ${options ? JSON.stringify(options) : "default"}`);
|
|
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
|
+
if (this.#subscriptionCallback) {
|
|
40
|
+
this.#subscriptionCallback(options);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
getBaseUrl() {
|
|
44
|
+
return this.#baseUrl;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Subscribe to config changes. The callback will be immediately invoked with the current config.
|
|
48
|
+
* @param subscriptionCallback Function that will be called with the new config every time it is changed
|
|
49
|
+
*/
|
|
50
|
+
subscribeToConfigChange(subscriptionCallback) {
|
|
51
|
+
console.log(`Subscription added`);
|
|
52
|
+
this.#subscriptionCallback = subscriptionCallback;
|
|
53
|
+
subscriptionCallback(this.#currentConfig);
|
|
54
|
+
}
|
|
55
|
+
unsubscribeToConfigChange() {
|
|
56
|
+
this.#subscriptionCallback = void 0;
|
|
57
|
+
}
|
|
58
|
+
get(url, options) {
|
|
59
|
+
return this.#client.get(url, options);
|
|
60
|
+
}
|
|
61
|
+
post(url, options) {
|
|
62
|
+
return this.#client.post(url, options);
|
|
63
|
+
}
|
|
64
|
+
put(url, options) {
|
|
65
|
+
return this.#client.put(url, options);
|
|
66
|
+
}
|
|
67
|
+
patch(url, options) {
|
|
68
|
+
return this.#client.patch(url, options);
|
|
69
|
+
}
|
|
70
|
+
head(url, options) {
|
|
71
|
+
return this.#client.head(url, options);
|
|
72
|
+
}
|
|
73
|
+
delete(url, options) {
|
|
74
|
+
return this.#client.delete(url, options);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export {
|
|
79
|
+
BASE_URLS,
|
|
80
|
+
envSchema,
|
|
81
|
+
AsstClient
|
|
82
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
};
|