@spscommerce/asst-api 4.2.3 → 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.
Files changed (111) hide show
  1. package/dist/{SpsItemIdResponse-CkHdH_QJ.d.cts → SpsItemIdResponse-0VgfCmG_.d.cts} +26 -1
  2. package/dist/{SpsItemIdResponse-CkHdH_QJ.d.ts → SpsItemIdResponse-0VgfCmG_.d.ts} +26 -1
  3. package/dist/{CompanyBriefByOrg-Dy2omcT0.d.cts → SpsItemIdResponse-CI_Ao86P.d.cts} +29 -37
  4. package/dist/{CompanyBriefByOrg-Dy2omcT0.d.ts → SpsItemIdResponse-CI_Ao86P.d.ts} +29 -37
  5. package/dist/chunk-355LPVI6.js +126 -0
  6. package/dist/{chunk-BVCWT7AV.js → chunk-55ECRTUX.js} +1 -1
  7. package/dist/chunk-63KIELUR.js +128 -0
  8. package/dist/{chunk-C73WZRUL.js → chunk-CI3ZSIT4.js} +1 -1
  9. package/dist/chunk-DK2OMRWR.js +134 -0
  10. package/dist/{chunk-HHJDDPFR.js → chunk-LKUGPDIT.js} +21 -11
  11. package/dist/{chunk-SPR77CVW.js → chunk-NFZI7D22.js} +29 -14
  12. package/dist/{chunk-MH76527N.js → chunk-NUUQDRHD.js} +14 -7
  13. package/dist/index.cjs +8 -4
  14. package/dist/index.d.cts +18 -7
  15. package/dist/index.d.ts +18 -7
  16. package/dist/index.js +5 -17
  17. package/dist/msw.cjs +65 -19
  18. package/dist/msw.d.cts +58 -4
  19. package/dist/msw.d.ts +58 -4
  20. package/dist/msw.js +61 -13
  21. package/dist/{zod-VuA-QJOT.d.ts → zod-C41Rts8D.d.cts} +11 -23
  22. package/dist/{zod-CFNzalN6.d.ts → zod-CJmsC_DX.d.cts} +60 -39
  23. package/dist/zod-COyz02Lh.d.ts +5903 -0
  24. package/dist/{zod-BRmUARvM.d.cts → zod-CzPw-bfk.d.cts} +60 -39
  25. package/dist/{zod-jDi_gO0s.d.cts → zod-vDuspd-x.d.ts} +29 -44
  26. package/dist/zod-xWM6u1LJ.d.ts +5900 -0
  27. package/dist/zod.cjs +8 -4
  28. package/dist/zod.d.cts +2 -2
  29. package/dist/zod.d.ts +2 -2
  30. package/dist/zod.js +2 -2
  31. package/package.json +3 -3
  32. package/dist/CompanyBriefByOrg-57oGCtjK.d.ts +0 -3427
  33. package/dist/CompanyBriefByOrg-LTdsUKm4.d.ts +0 -3427
  34. package/dist/CompanyBriefByOrg-itus4RMD.d.cts +0 -131
  35. package/dist/CompanyBriefByOrg-itus4RMD.d.ts +0 -131
  36. package/dist/chunk-27XV7TS2.js +0 -522
  37. package/dist/chunk-2ETQHIXC.js +0 -528
  38. package/dist/chunk-2VJS5KPH.js +0 -5182
  39. package/dist/chunk-2W3LZ4AO.js +0 -513
  40. package/dist/chunk-3XNXQYIB.js +0 -521
  41. package/dist/chunk-4C475UZX.js +0 -5164
  42. package/dist/chunk-4RARACQK.js +0 -528
  43. package/dist/chunk-5AROSGQB.js +0 -5034
  44. package/dist/chunk-7CGKH3QQ.js +0 -528
  45. package/dist/chunk-7F5CQRS2.js +0 -567
  46. package/dist/chunk-7OEXJIWW.js +0 -565
  47. package/dist/chunk-A22SEYVL.js +0 -530
  48. package/dist/chunk-AH5MG2WF.js +0 -5040
  49. package/dist/chunk-BDSSH6MN.js +0 -574
  50. package/dist/chunk-BFIQVABZ.js +0 -528
  51. package/dist/chunk-BJTO4CRW.js +0 -558
  52. package/dist/chunk-BLMS4KUD.js +0 -5164
  53. package/dist/chunk-BTNVA4NZ.js +0 -568
  54. package/dist/chunk-CNQTNX3M.js +0 -567
  55. package/dist/chunk-CUVSWUIQ.js +0 -5040
  56. package/dist/chunk-DP2ZMQG5.js +0 -4881
  57. package/dist/chunk-EMBJNPTB.js +0 -5040
  58. package/dist/chunk-EO2UMCWY.js +0 -574
  59. package/dist/chunk-FTB465WY.js +0 -575
  60. package/dist/chunk-G6A4EVAL.js +0 -528
  61. package/dist/chunk-GDARBI5R.js +0 -5185
  62. package/dist/chunk-HY2SRD5L.js +0 -5003
  63. package/dist/chunk-ISQ3LQRI.js +0 -565
  64. package/dist/chunk-KKX3CXHP.js +0 -558
  65. package/dist/chunk-LCK4AEWB.js +0 -79
  66. package/dist/chunk-LJVJ4SYE.js +0 -568
  67. package/dist/chunk-LYMA4XGG.js +0 -5181
  68. package/dist/chunk-MLAU3LFL.js +0 -527
  69. package/dist/chunk-MQREZR54.js +0 -5164
  70. package/dist/chunk-N4A4BVKV.js +0 -5163
  71. package/dist/chunk-QVEV57JA.js +0 -5185
  72. package/dist/chunk-SI7CWAHC.js +0 -574
  73. package/dist/chunk-SK6U2JDX.js +0 -566
  74. package/dist/chunk-SQBB5K5J.js +0 -574
  75. package/dist/chunk-TQ2IQDSM.js +0 -568
  76. package/dist/chunk-TTT6PM27.js +0 -558
  77. package/dist/chunk-VFMKDLXO.js +0 -570
  78. package/dist/chunk-VKPQOGVS.js +0 -565
  79. package/dist/chunk-VLLI4AYA.js +0 -520
  80. package/dist/chunk-VNFLJ5FV.js +0 -530
  81. package/dist/chunk-WNCDQJEM.js +0 -5034
  82. package/dist/chunk-XYZVRJF3.js +0 -5162
  83. package/dist/chunk-YJCJB4OT.js +0 -79
  84. package/dist/chunk-YJMQ4PGM.js +0 -559
  85. package/dist/chunk-Z6PXGHNC.js +0 -570
  86. package/dist/chunk-ZQ32XEVW.js +0 -79
  87. package/dist/chunk-ZXXDLGW7.js +0 -513
  88. package/dist/index-9KKchLwe.d.cts +0 -14
  89. package/dist/index-B8ovDTs5.d.cts +0 -14
  90. package/dist/index-BFKgtuVI.d.ts +0 -14
  91. package/dist/index-DeivEdv0.d.ts +0 -14
  92. package/dist/index-Zz-6wNSh.d.ts +0 -106
  93. package/dist/index-fgr_c5Wj.d.ts +0 -106
  94. package/dist/zod-6gU8y6oS.d.cts +0 -6712
  95. package/dist/zod-B4sIVoVX.d.ts +0 -6712
  96. package/dist/zod-BI81QHVK.d.ts +0 -6715
  97. package/dist/zod-BUCQsGOm.d.ts +0 -6712
  98. package/dist/zod-BdDmL7rg.d.ts +0 -6718
  99. package/dist/zod-Bl_5j5Nx.d.ts +0 -6712
  100. package/dist/zod-Bxu34bbp.d.ts +0 -6718
  101. package/dist/zod-C4kEHhO8.d.cts +0 -6718
  102. package/dist/zod-C5pRCHei.d.ts +0 -6712
  103. package/dist/zod-CIacR1Kf.d.cts +0 -6712
  104. package/dist/zod-DBbdP-KT.d.cts +0 -6718
  105. package/dist/zod-DyBGOUbG.d.ts +0 -5876
  106. package/dist/zod-DzhoVlw_.d.cts +0 -6712
  107. package/dist/zod-FdtLO2-F.d.cts +0 -6715
  108. package/dist/zod-NE2xXWlK.d.ts +0 -3416
  109. package/dist/zod-lSiFMzqK.d.cts +0 -6712
  110. package/dist/zod-rs54beS2.d.cts +0 -5876
  111. package/dist/zod-zxqlYYMG.d.ts +0 -3416
@@ -28,6 +28,16 @@ type Listener = (config: AsstClientOptions) => void;
28
28
  declare class AsstClient {
29
29
  #private;
30
30
  constructor(options?: AsstClientOptions);
31
+ /**
32
+ * Set company type that will be automatically added to all requests
33
+ * @param companyType Company type to add to all requests (e.g., 'RETAILER', 'SUPPLIER')
34
+ */
35
+ setCompanyType(companyType: string | undefined): this;
36
+ /**
37
+ * Get the current company type
38
+ * @returns Current company type or undefined if not set
39
+ */
40
+ getCompanyType(): string | undefined;
31
41
  updateConfig(options: AsstClientOptions): void;
32
42
  getBaseUrl(): AsstUrl;
33
43
  /**
@@ -44,6 +54,21 @@ declare class AsstClient {
44
54
  delete(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
45
55
  }
46
56
 
57
+ type Hierarchy = {
58
+ id: string;
59
+ name?: string | null;
60
+ description?: string | null;
61
+ type?: string | null;
62
+ child?: Hierarchy | null;
63
+ };
64
+ type ItemHierarchyResponse = {
65
+ itemHierarchies: Array<{
66
+ itemId: string;
67
+ hierarchies: Array<Hierarchy>;
68
+ }>;
69
+ };
70
+ declare const itemHierarchyResponseSchema: z.ZodType<ItemHierarchyResponse>;
71
+
47
72
  declare const spsItemIdResponseSchema: z.ZodObject<{
48
73
  id: z.ZodString;
49
74
  ref: z.ZodString;
@@ -56,4 +81,4 @@ declare const spsItemIdResponseSchema: z.ZodObject<{
56
81
  }>;
57
82
  type SpsItemIdResponse = z.infer<typeof spsItemIdResponseSchema>;
58
83
 
59
- export { AsstClient as A, BASE_URLS as B, type Env as E, type SpsItemIdResponse as S, type AsstClientOptions as a, type AsstUrl as b, envSchema as e, spsItemIdResponseSchema as s };
84
+ export { AsstClient as A, BASE_URLS as B, type Env as E, type ItemHierarchyResponse as I, type SpsItemIdResponse as S, type AsstClientOptions as a, type AsstUrl as b, envSchema as e, itemHierarchyResponseSchema as i, spsItemIdResponseSchema as s };
@@ -28,6 +28,16 @@ type Listener = (config: AsstClientOptions) => void;
28
28
  declare class AsstClient {
29
29
  #private;
30
30
  constructor(options?: AsstClientOptions);
31
+ /**
32
+ * Set company type that will be automatically added to all requests
33
+ * @param companyType Company type to add to all requests (e.g., 'RETAILER', 'SUPPLIER')
34
+ */
35
+ setCompanyType(companyType: string | undefined): this;
36
+ /**
37
+ * Get the current company type
38
+ * @returns Current company type or undefined if not set
39
+ */
40
+ getCompanyType(): string | undefined;
31
41
  updateConfig(options: AsstClientOptions): void;
32
42
  getBaseUrl(): AsstUrl;
33
43
  /**
@@ -44,6 +54,21 @@ declare class AsstClient {
44
54
  delete(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
45
55
  }
46
56
 
57
+ type Hierarchy = {
58
+ id: string;
59
+ name?: string | null;
60
+ description?: string | null;
61
+ type?: string | null;
62
+ child?: Hierarchy | null;
63
+ };
64
+ type ItemHierarchyResponse = {
65
+ itemHierarchies: Array<{
66
+ itemId: string;
67
+ hierarchies: Array<Hierarchy>;
68
+ }>;
69
+ };
70
+ declare const itemHierarchyResponseSchema: z.ZodType<ItemHierarchyResponse>;
71
+
47
72
  declare const spsItemIdResponseSchema: z.ZodObject<{
48
73
  id: z.ZodString;
49
74
  ref: z.ZodString;
@@ -56,4 +81,4 @@ declare const spsItemIdResponseSchema: z.ZodObject<{
56
81
  }>;
57
82
  type SpsItemIdResponse = z.infer<typeof spsItemIdResponseSchema>;
58
83
 
59
- export { AsstClient as A, BASE_URLS as B, type Env as E, type SpsItemIdResponse as S, type AsstClientOptions as a, type AsstUrl as b, envSchema as e, spsItemIdResponseSchema as s };
84
+ export { AsstClient as A, BASE_URLS as B, type Env as E, type ItemHierarchyResponse as I, type SpsItemIdResponse as S, type AsstClientOptions as a, type AsstUrl as b, envSchema as e, itemHierarchyResponseSchema as i, spsItemIdResponseSchema as s };
@@ -2,6 +2,9 @@ import * as ky from 'ky';
2
2
  import { Options } from 'ky';
3
3
  import { z } from 'zod';
4
4
 
5
+ declare const companyTypeEnumSchema: z.ZodEnum<["RETAILER", "SUPPLIER"]>;
6
+ type CompanyType = z.infer<typeof companyTypeEnumSchema>;
7
+
5
8
  declare const baseUrlsSchema: z.ZodObject<{
6
9
  local: z.ZodLiteral<"https://localhost:8443/">;
7
10
  test: z.ZodLiteral<"https://integration.api.spscommerce.com/assortment/gateway/">;
@@ -28,6 +31,16 @@ type Listener = (config: AsstClientOptions) => void;
28
31
  declare class AsstClient {
29
32
  #private;
30
33
  constructor(options?: AsstClientOptions);
34
+ /**
35
+ * Set company type that will be automatically added to all requests
36
+ * @param companyType Company type to add to all requests ('RETAILER' | 'SUPPLIER')
37
+ */
38
+ setCompanyType(companyType: CompanyType | undefined): this;
39
+ /**
40
+ * Get the current company type
41
+ * @returns Current company type or undefined if not set
42
+ */
43
+ getCompanyType(): CompanyType | undefined;
31
44
  updateConfig(options: AsstClientOptions): void;
32
45
  getBaseUrl(): AsstUrl;
33
46
  /**
@@ -44,6 +57,21 @@ declare class AsstClient {
44
57
  delete(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
45
58
  }
46
59
 
60
+ type Hierarchy = {
61
+ id: string;
62
+ name?: string | null;
63
+ description?: string | null;
64
+ type?: string | null;
65
+ child?: Hierarchy | null;
66
+ };
67
+ type ItemHierarchyResponse = {
68
+ itemHierarchies: Array<{
69
+ itemId: string;
70
+ hierarchies: Array<Hierarchy>;
71
+ }>;
72
+ };
73
+ declare const itemHierarchyResponseSchema: z.ZodType<ItemHierarchyResponse>;
74
+
47
75
  declare const spsItemIdResponseSchema: z.ZodObject<{
48
76
  id: z.ZodString;
49
77
  ref: z.ZodString;
@@ -56,40 +84,4 @@ declare const spsItemIdResponseSchema: z.ZodObject<{
56
84
  }>;
57
85
  type SpsItemIdResponse = z.infer<typeof spsItemIdResponseSchema>;
58
86
 
59
- declare const companyBriefByOrgSchema: z.ZodObject<{
60
- companyId: z.ZodNumber;
61
- name: z.ZodString;
62
- orgId: z.ZodString;
63
- companyType: z.ZodObject<{
64
- type: z.ZodEnum<["SUPPLIER", "RETAILER"]>;
65
- display: z.ZodEnum<["SUPPLIER", "RETAILER"]>;
66
- }, "strip", z.ZodTypeAny, {
67
- type: "SUPPLIER" | "RETAILER";
68
- display: "SUPPLIER" | "RETAILER";
69
- }, {
70
- type: "SUPPLIER" | "RETAILER";
71
- display: "SUPPLIER" | "RETAILER";
72
- }>;
73
- dc4Id: z.ZodNumber;
74
- }, "strip", z.ZodTypeAny, {
75
- name: string;
76
- orgId: string;
77
- companyId: number;
78
- companyType: {
79
- type: "SUPPLIER" | "RETAILER";
80
- display: "SUPPLIER" | "RETAILER";
81
- };
82
- dc4Id: number;
83
- }, {
84
- name: string;
85
- orgId: string;
86
- companyId: number;
87
- companyType: {
88
- type: "SUPPLIER" | "RETAILER";
89
- display: "SUPPLIER" | "RETAILER";
90
- };
91
- dc4Id: number;
92
- }>;
93
- type CompanyBriefByOrg = z.infer<typeof companyBriefByOrgSchema>;
94
-
95
- export { AsstClient as A, BASE_URLS as B, type CompanyBriefByOrg as C, type Env as E, type SpsItemIdResponse as S, type AsstClientOptions as a, type AsstUrl as b, companyBriefByOrgSchema as c, envSchema as e, spsItemIdResponseSchema as s };
87
+ export { AsstClient as A, BASE_URLS as B, type CompanyType as C, type Env as E, type ItemHierarchyResponse as I, type SpsItemIdResponse as S, type AsstClientOptions as a, type AsstUrl as b, companyTypeEnumSchema as c, envSchema as e, itemHierarchyResponseSchema as i, spsItemIdResponseSchema as s };
@@ -2,6 +2,9 @@ import * as ky from 'ky';
2
2
  import { Options } from 'ky';
3
3
  import { z } from 'zod';
4
4
 
5
+ declare const companyTypeEnumSchema: z.ZodEnum<["RETAILER", "SUPPLIER"]>;
6
+ type CompanyType = z.infer<typeof companyTypeEnumSchema>;
7
+
5
8
  declare const baseUrlsSchema: z.ZodObject<{
6
9
  local: z.ZodLiteral<"https://localhost:8443/">;
7
10
  test: z.ZodLiteral<"https://integration.api.spscommerce.com/assortment/gateway/">;
@@ -28,6 +31,16 @@ type Listener = (config: AsstClientOptions) => void;
28
31
  declare class AsstClient {
29
32
  #private;
30
33
  constructor(options?: AsstClientOptions);
34
+ /**
35
+ * Set company type that will be automatically added to all requests
36
+ * @param companyType Company type to add to all requests ('RETAILER' | 'SUPPLIER')
37
+ */
38
+ setCompanyType(companyType: CompanyType | undefined): this;
39
+ /**
40
+ * Get the current company type
41
+ * @returns Current company type or undefined if not set
42
+ */
43
+ getCompanyType(): CompanyType | undefined;
31
44
  updateConfig(options: AsstClientOptions): void;
32
45
  getBaseUrl(): AsstUrl;
33
46
  /**
@@ -44,6 +57,21 @@ declare class AsstClient {
44
57
  delete(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
45
58
  }
46
59
 
60
+ type Hierarchy = {
61
+ id: string;
62
+ name?: string | null;
63
+ description?: string | null;
64
+ type?: string | null;
65
+ child?: Hierarchy | null;
66
+ };
67
+ type ItemHierarchyResponse = {
68
+ itemHierarchies: Array<{
69
+ itemId: string;
70
+ hierarchies: Array<Hierarchy>;
71
+ }>;
72
+ };
73
+ declare const itemHierarchyResponseSchema: z.ZodType<ItemHierarchyResponse>;
74
+
47
75
  declare const spsItemIdResponseSchema: z.ZodObject<{
48
76
  id: z.ZodString;
49
77
  ref: z.ZodString;
@@ -56,40 +84,4 @@ declare const spsItemIdResponseSchema: z.ZodObject<{
56
84
  }>;
57
85
  type SpsItemIdResponse = z.infer<typeof spsItemIdResponseSchema>;
58
86
 
59
- declare const companyBriefByOrgSchema: z.ZodObject<{
60
- companyId: z.ZodNumber;
61
- name: z.ZodString;
62
- orgId: z.ZodString;
63
- companyType: z.ZodObject<{
64
- type: z.ZodEnum<["SUPPLIER", "RETAILER"]>;
65
- display: z.ZodEnum<["SUPPLIER", "RETAILER"]>;
66
- }, "strip", z.ZodTypeAny, {
67
- type: "SUPPLIER" | "RETAILER";
68
- display: "SUPPLIER" | "RETAILER";
69
- }, {
70
- type: "SUPPLIER" | "RETAILER";
71
- display: "SUPPLIER" | "RETAILER";
72
- }>;
73
- dc4Id: z.ZodNumber;
74
- }, "strip", z.ZodTypeAny, {
75
- name: string;
76
- orgId: string;
77
- companyId: number;
78
- companyType: {
79
- type: "SUPPLIER" | "RETAILER";
80
- display: "SUPPLIER" | "RETAILER";
81
- };
82
- dc4Id: number;
83
- }, {
84
- name: string;
85
- orgId: string;
86
- companyId: number;
87
- companyType: {
88
- type: "SUPPLIER" | "RETAILER";
89
- display: "SUPPLIER" | "RETAILER";
90
- };
91
- dc4Id: number;
92
- }>;
93
- type CompanyBriefByOrg = z.infer<typeof companyBriefByOrgSchema>;
94
-
95
- export { AsstClient as A, BASE_URLS as B, type CompanyBriefByOrg as C, type Env as E, type SpsItemIdResponse as S, type AsstClientOptions as a, type AsstUrl as b, companyBriefByOrgSchema as c, envSchema as e, spsItemIdResponseSchema as s };
87
+ export { AsstClient as A, BASE_URLS as B, type CompanyType as C, type Env as E, type ItemHierarchyResponse as I, type SpsItemIdResponse as S, type AsstClientOptions as a, type AsstUrl as b, companyTypeEnumSchema as c, envSchema as e, itemHierarchyResponseSchema as i, spsItemIdResponseSchema as s };
@@ -0,0 +1,126 @@
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
+ if (!this.#companyType) return options;
55
+ const mergedOptions = { ...options };
56
+ let searchParams;
57
+ if (options.searchParams) {
58
+ if (options.searchParams instanceof URLSearchParams) {
59
+ searchParams = new URLSearchParams(options.searchParams);
60
+ } else if (typeof options.searchParams === "string") {
61
+ searchParams = new URLSearchParams(options.searchParams);
62
+ } else {
63
+ searchParams = new URLSearchParams();
64
+ Object.entries(options.searchParams).forEach(([key, value]) => {
65
+ if (Array.isArray(value)) {
66
+ value.forEach((v) => searchParams.append(key, String(v)));
67
+ } else if (value !== void 0 && value !== null) {
68
+ searchParams.append(key, String(value));
69
+ }
70
+ });
71
+ }
72
+ } else {
73
+ searchParams = new URLSearchParams();
74
+ }
75
+ if (!searchParams.has("companyType")) {
76
+ searchParams.set("companyType", this.#companyType);
77
+ }
78
+ mergedOptions.searchParams = searchParams;
79
+ return mergedOptions;
80
+ }
81
+ updateConfig(options) {
82
+ this.#client = this.#client.extend(options);
83
+ this.#currentConfig = options;
84
+ if (options.prefixUrl) {
85
+ this.#baseUrl = options.prefixUrl;
86
+ }
87
+ this.#listeners.forEach((listener) => listener(options));
88
+ }
89
+ getBaseUrl() {
90
+ return this.#baseUrl;
91
+ }
92
+ /**
93
+ * Subscribe to config changes. The callback will be immediately invoked with the current config.
94
+ * @param subscriptionCallback Function that will be called with the new config every time it is changed
95
+ * @returns Function to unsubscribe to config changes
96
+ */
97
+ subscribeToConfigChange(listener) {
98
+ this.#listeners.add(listener);
99
+ listener(this.#currentConfig);
100
+ return () => this.#listeners.delete(listener);
101
+ }
102
+ get(url, options) {
103
+ return this.#client.get(url, this.#mergeCompanyTypeParam(options));
104
+ }
105
+ post(url, options) {
106
+ return this.#client.post(url, this.#mergeCompanyTypeParam(options));
107
+ }
108
+ put(url, options) {
109
+ return this.#client.put(url, this.#mergeCompanyTypeParam(options));
110
+ }
111
+ patch(url, options) {
112
+ return this.#client.patch(url, this.#mergeCompanyTypeParam(options));
113
+ }
114
+ head(url, options) {
115
+ return this.#client.head(url, this.#mergeCompanyTypeParam(options));
116
+ }
117
+ delete(url, options) {
118
+ return this.#client.delete(url, this.#mergeCompanyTypeParam(options));
119
+ }
120
+ };
121
+
122
+ export {
123
+ BASE_URLS,
124
+ envSchema,
125
+ AsstClient
126
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  external_exports
3
- } from "./chunk-MH76527N.js";
3
+ } from "./chunk-LKUGPDIT.js";
4
4
 
5
5
  // lib/asstClient.ts
6
6
  import ky from "ky";
@@ -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
+ };
@@ -20,7 +20,7 @@ import {
20
20
  tradingPartnerAccessByCompanyIdSchema,
21
21
  userAccountSchema,
22
22
  vendorPartnerAttGroupsSchema
23
- } from "./chunk-MH76527N.js";
23
+ } from "./chunk-NUUQDRHD.js";
24
24
 
25
25
  // lib/imports/index.ts
26
26
  var BASE_URL = "imports";
@@ -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
+ };