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

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 (56) hide show
  1. package/dist/ImportsStatus-52d26b01.d.ts +134 -0
  2. package/dist/ImportsStatusEnum-22c03a0b.d.ts +51 -0
  3. package/dist/ItemCategoriesSearch-1bb945de.d.ts +275 -0
  4. package/dist/ItemCategoriesSearch-44b87663.d.ts +318 -0
  5. package/dist/ItemCategoriesSearch-e0870a34.d.ts +318 -0
  6. package/dist/ItemCategoriesSearch-e3298650.d.ts +319 -0
  7. package/dist/ItemCategoriesSearch-ec43591f.d.ts +319 -0
  8. package/dist/ItemCategory-14816deb.d.ts +99 -0
  9. package/dist/ItemCategory-768179bd.d.ts +99 -0
  10. package/dist/ItemErrorDetails-1bd2821e.d.ts +3137 -0
  11. package/dist/ItemErrorDetails-e6e400aa.d.ts +3197 -0
  12. package/dist/ItemErrorDetailsResult-0b4a628c.d.ts +3032 -0
  13. package/dist/ItemErrorDetailsResult-859368da.d.ts +3032 -0
  14. package/dist/ItemErrorDetailsResult-9ac97c24.d.ts +3032 -0
  15. package/dist/ItemErrorDetailsResult-c62caeae.d.ts +3092 -0
  16. package/dist/TradingPartnerAccessByCompanyId-29866586.d.ts +97 -0
  17. package/dist/TradingPartnerAccessByCompanyId-43f83fb6.d.ts +130 -0
  18. package/dist/TradingPartnerAccessByCompanyId-479e3e57.d.ts +124 -0
  19. package/dist/TradingPartnerAccessByCompanyId-53b868a8.d.ts +125 -0
  20. package/dist/TradingPartnerAccessByCompanyId-b227f0c5.d.ts +125 -0
  21. package/dist/TradingPartnerAccessByCompanyId-e7a1d443.d.ts +129 -0
  22. package/dist/asstClient-f6a1693a.d.ts +29 -0
  23. package/dist/chunk-3FMMM7IS.js +80 -0
  24. package/dist/chunk-4WER3ZLX.js +4576 -0
  25. package/dist/chunk-6ZNFOWTV.js +78 -0
  26. package/dist/chunk-7HCJJATJ.js +40 -0
  27. package/dist/chunk-B7B2ACF4.js +3794 -0
  28. package/dist/chunk-D3ML6E4G.js +3787 -0
  29. package/dist/chunk-ETURPA7W.js +326 -0
  30. package/dist/chunk-F3KCLICG.js +77 -0
  31. package/dist/chunk-FS6LHGAR.js +87 -0
  32. package/dist/chunk-G36FM5OA.js +327 -0
  33. package/dist/chunk-GDFX3WTX.js +78 -0
  34. package/dist/chunk-IHIEBLQV.js +4576 -0
  35. package/dist/chunk-ITWMRXLD.js +328 -0
  36. package/dist/chunk-LGP22FRF.js +0 -0
  37. package/dist/chunk-LYMGZWSR.js +80 -0
  38. package/dist/chunk-N2OYWNHF.js +80 -0
  39. package/dist/chunk-OA6PO3QG.js +78 -0
  40. package/dist/chunk-OBXZRDPY.js +77 -0
  41. package/dist/chunk-OI47EFQH.js +82 -0
  42. package/dist/chunk-RNUSCCKB.js +183 -0
  43. package/dist/chunk-RRGAJ4ZS.js +4576 -0
  44. package/dist/chunk-T3UCSW2B.js +81 -0
  45. package/dist/chunk-XMNYZGXF.js +84 -0
  46. package/dist/chunk-YCQUK6KV.js +85 -0
  47. package/dist/index.cjs +10 -8
  48. package/dist/index.d.ts +4 -4
  49. package/dist/index.js +2 -2
  50. package/dist/msw.cjs +4 -4
  51. package/dist/msw.d.ts +41 -25
  52. package/dist/msw.js +2 -2
  53. package/dist/zod.cjs +4 -4
  54. package/dist/zod.d.ts +2 -2
  55. package/dist/zod.js +1 -1
  56. 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 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,40 @@
1
+ import {
2
+ importErrorsSchema,
3
+ importSchema,
4
+ importsStatusSchema,
5
+ z
6
+ } from "./chunk-B7B2ACF4.js";
7
+
8
+ // lib/imports/index.ts
9
+ var BASE_URL = "imports";
10
+ function createImportsApi(client) {
11
+ async function getImportErrors(importId, params, signal) {
12
+ const data = await client.get(`${BASE_URL}/${importId}/errors`, { searchParams: params, signal }).json();
13
+ return importErrorsSchema.parse(data);
14
+ }
15
+ async function getImports(params, signal) {
16
+ const data = await client.get(`${BASE_URL}`, {
17
+ searchParams: params,
18
+ signal
19
+ }).json();
20
+ return importSchema.parse(data);
21
+ }
22
+ async function getImportsStatus(signal) {
23
+ const data = await client.get(`${BASE_URL}/status`, { signal }).json();
24
+ return z.array(importsStatusSchema).parse(data);
25
+ }
26
+ async function uploadImport(file) {
27
+ await client.post(`${BASE_URL}`, { body: file });
28
+ }
29
+ return {
30
+ getImportErrors,
31
+ getImports,
32
+ getImportsStatus,
33
+ uploadImport
34
+ };
35
+ }
36
+
37
+ export {
38
+ BASE_URL,
39
+ createImportsApi
40
+ };