@spscommerce/asst-api 4.2.2 → 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 (40) hide show
  1. package/dist/{CompanyBriefByOrg-Dy2omcT0.d.cts → SpsItemIdResponse-0VgfCmG_.d.cts} +26 -37
  2. package/dist/{CompanyBriefByOrg-Dy2omcT0.d.ts → SpsItemIdResponse-0VgfCmG_.d.ts} +26 -37
  3. package/dist/SpsItemIdResponse-CI_Ao86P.d.cts +87 -0
  4. package/dist/SpsItemIdResponse-CI_Ao86P.d.ts +87 -0
  5. package/dist/SpsItemIdResponse-s0vCXepG.d.cts +74 -0
  6. package/dist/SpsItemIdResponse-s0vCXepG.d.ts +74 -0
  7. package/dist/chunk-355LPVI6.js +126 -0
  8. package/dist/{chunk-BVCWT7AV.js → chunk-55ECRTUX.js} +1 -1
  9. package/dist/chunk-63KIELUR.js +128 -0
  10. package/dist/{chunk-4RARACQK.js → chunk-CI3ZSIT4.js} +29 -13
  11. package/dist/chunk-DK2OMRWR.js +134 -0
  12. package/dist/chunk-FCUIJXCD.js +544 -0
  13. package/dist/{chunk-MH76527N.js → chunk-L4AWOEED.js} +6 -6
  14. package/dist/chunk-LKUGPDIT.js +4896 -0
  15. package/dist/chunk-NFZI7D22.js +544 -0
  16. package/dist/chunk-NUUQDRHD.js +4899 -0
  17. package/dist/chunk-RPGGEEFE.js +79 -0
  18. package/dist/index.cjs +14 -10
  19. package/dist/index.d.cts +18 -7
  20. package/dist/index.d.ts +18 -7
  21. package/dist/index.js +5 -17
  22. package/dist/msw.cjs +71 -25
  23. package/dist/msw.d.cts +58 -4
  24. package/dist/msw.d.ts +58 -4
  25. package/dist/msw.js +61 -13
  26. package/dist/{zod-BRmUARvM.d.cts → zod-C3fOiO-H.d.cts} +38 -17
  27. package/dist/zod-C41Rts8D.d.cts +5903 -0
  28. package/dist/{zod-CFNzalN6.d.ts → zod-CJ6AFTQr.d.ts} +38 -17
  29. package/dist/zod-CJmsC_DX.d.cts +5900 -0
  30. package/dist/zod-COyz02Lh.d.ts +5903 -0
  31. package/dist/zod-CzPw-bfk.d.cts +5900 -0
  32. package/dist/zod-vDuspd-x.d.ts +5900 -0
  33. package/dist/zod-xWM6u1LJ.d.ts +5900 -0
  34. package/dist/zod.cjs +14 -10
  35. package/dist/zod.d.cts +2 -2
  36. package/dist/zod.d.ts +2 -2
  37. package/dist/zod.js +2 -2
  38. package/package.json +3 -3
  39. package/dist/index-9KKchLwe.d.cts +0 -14
  40. package/dist/index-DeivEdv0.d.ts +0 -14
@@ -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,40 +81,4 @@ declare const spsItemIdResponseSchema: z.ZodObject<{
56
81
  }>;
57
82
  type SpsItemIdResponse = z.infer<typeof spsItemIdResponseSchema>;
58
83
 
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 };
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,40 +81,4 @@ declare const spsItemIdResponseSchema: z.ZodObject<{
56
81
  }>;
57
82
  type SpsItemIdResponse = z.infer<typeof spsItemIdResponseSchema>;
58
83
 
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 };
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 };
@@ -0,0 +1,87 @@
1
+ import * as ky from 'ky';
2
+ import { Options } from 'ky';
3
+ import { z } from 'zod';
4
+
5
+ declare const companyTypeEnumSchema: z.ZodEnum<["RETAILER", "SUPPLIER"]>;
6
+ type CompanyType = z.infer<typeof companyTypeEnumSchema>;
7
+
8
+ declare const baseUrlsSchema: z.ZodObject<{
9
+ local: z.ZodLiteral<"https://localhost:8443/">;
10
+ test: z.ZodLiteral<"https://integration.api.spscommerce.com/assortment/gateway/">;
11
+ prod: z.ZodLiteral<"https://api.spscommerce.com/assortment/gateway/">;
12
+ }, "strip", z.ZodTypeAny, {
13
+ local: "https://localhost:8443/";
14
+ test: "https://integration.api.spscommerce.com/assortment/gateway/";
15
+ prod: "https://api.spscommerce.com/assortment/gateway/";
16
+ }, {
17
+ local: "https://localhost:8443/";
18
+ test: "https://integration.api.spscommerce.com/assortment/gateway/";
19
+ prod: "https://api.spscommerce.com/assortment/gateway/";
20
+ }>;
21
+ type BaseUrls = z.infer<typeof baseUrlsSchema>;
22
+ declare const BASE_URLS: BaseUrls;
23
+ declare const envSchema: z.ZodEnum<["local", "test", "prod"]>;
24
+ type Env = z.infer<typeof envSchema>;
25
+ type AsstUrl = BaseUrls[Env];
26
+ interface AsstClientOptions extends Options {
27
+ prefixUrl?: AsstUrl;
28
+ }
29
+ type Input = string | URL | Request;
30
+ type Listener = (config: AsstClientOptions) => void;
31
+ declare class AsstClient {
32
+ #private;
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;
44
+ updateConfig(options: AsstClientOptions): void;
45
+ getBaseUrl(): AsstUrl;
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
+ * @returns Function to unsubscribe to config changes
50
+ */
51
+ subscribeToConfigChange(listener: Listener): () => boolean;
52
+ get(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
53
+ post(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
54
+ put(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
55
+ patch(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
56
+ head(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
57
+ delete(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
58
+ }
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
+
75
+ declare const spsItemIdResponseSchema: z.ZodObject<{
76
+ id: z.ZodString;
77
+ ref: z.ZodString;
78
+ }, "strip", z.ZodTypeAny, {
79
+ id: string;
80
+ ref: string;
81
+ }, {
82
+ id: string;
83
+ ref: string;
84
+ }>;
85
+ type SpsItemIdResponse = z.infer<typeof spsItemIdResponseSchema>;
86
+
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,87 @@
1
+ import * as ky from 'ky';
2
+ import { Options } from 'ky';
3
+ import { z } from 'zod';
4
+
5
+ declare const companyTypeEnumSchema: z.ZodEnum<["RETAILER", "SUPPLIER"]>;
6
+ type CompanyType = z.infer<typeof companyTypeEnumSchema>;
7
+
8
+ declare const baseUrlsSchema: z.ZodObject<{
9
+ local: z.ZodLiteral<"https://localhost:8443/">;
10
+ test: z.ZodLiteral<"https://integration.api.spscommerce.com/assortment/gateway/">;
11
+ prod: z.ZodLiteral<"https://api.spscommerce.com/assortment/gateway/">;
12
+ }, "strip", z.ZodTypeAny, {
13
+ local: "https://localhost:8443/";
14
+ test: "https://integration.api.spscommerce.com/assortment/gateway/";
15
+ prod: "https://api.spscommerce.com/assortment/gateway/";
16
+ }, {
17
+ local: "https://localhost:8443/";
18
+ test: "https://integration.api.spscommerce.com/assortment/gateway/";
19
+ prod: "https://api.spscommerce.com/assortment/gateway/";
20
+ }>;
21
+ type BaseUrls = z.infer<typeof baseUrlsSchema>;
22
+ declare const BASE_URLS: BaseUrls;
23
+ declare const envSchema: z.ZodEnum<["local", "test", "prod"]>;
24
+ type Env = z.infer<typeof envSchema>;
25
+ type AsstUrl = BaseUrls[Env];
26
+ interface AsstClientOptions extends Options {
27
+ prefixUrl?: AsstUrl;
28
+ }
29
+ type Input = string | URL | Request;
30
+ type Listener = (config: AsstClientOptions) => void;
31
+ declare class AsstClient {
32
+ #private;
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;
44
+ updateConfig(options: AsstClientOptions): void;
45
+ getBaseUrl(): AsstUrl;
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
+ * @returns Function to unsubscribe to config changes
50
+ */
51
+ subscribeToConfigChange(listener: Listener): () => boolean;
52
+ get(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
53
+ post(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
54
+ put(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
55
+ patch(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
56
+ head(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
57
+ delete(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
58
+ }
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
+
75
+ declare const spsItemIdResponseSchema: z.ZodObject<{
76
+ id: z.ZodString;
77
+ ref: z.ZodString;
78
+ }, "strip", z.ZodTypeAny, {
79
+ id: string;
80
+ ref: string;
81
+ }, {
82
+ id: string;
83
+ ref: string;
84
+ }>;
85
+ type SpsItemIdResponse = z.infer<typeof spsItemIdResponseSchema>;
86
+
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,74 @@
1
+ import * as ky from 'ky';
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.ResponsePromise;
40
+ post(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
41
+ put(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
42
+ patch(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
43
+ head(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
44
+ delete(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
45
+ }
46
+
47
+ type Hierarchy = {
48
+ id: string;
49
+ name?: string | null;
50
+ description?: string | null;
51
+ type?: string | null;
52
+ child?: Hierarchy | null;
53
+ };
54
+ type ItemHierarchyResponse = {
55
+ itemHierarchies: Array<{
56
+ itemId: string;
57
+ hierarchies: Array<Hierarchy>;
58
+ }>;
59
+ };
60
+ declare const itemHierarchyResponseSchema: z.ZodType<ItemHierarchyResponse>;
61
+
62
+ declare const spsItemIdResponseSchema: z.ZodObject<{
63
+ id: z.ZodString;
64
+ ref: z.ZodString;
65
+ }, "strip", z.ZodTypeAny, {
66
+ id: string;
67
+ ref: string;
68
+ }, {
69
+ id: string;
70
+ ref: string;
71
+ }>;
72
+ type SpsItemIdResponse = z.infer<typeof spsItemIdResponseSchema>;
73
+
74
+ 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 };
@@ -0,0 +1,74 @@
1
+ import * as ky from 'ky';
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.ResponsePromise;
40
+ post(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
41
+ put(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
42
+ patch(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
43
+ head(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
44
+ delete(url: Input, options?: AsstClientOptions): ky.ResponsePromise;
45
+ }
46
+
47
+ type Hierarchy = {
48
+ id: string;
49
+ name?: string | null;
50
+ description?: string | null;
51
+ type?: string | null;
52
+ child?: Hierarchy | null;
53
+ };
54
+ type ItemHierarchyResponse = {
55
+ itemHierarchies: Array<{
56
+ itemId: string;
57
+ hierarchies: Array<Hierarchy>;
58
+ }>;
59
+ };
60
+ declare const itemHierarchyResponseSchema: z.ZodType<ItemHierarchyResponse>;
61
+
62
+ declare const spsItemIdResponseSchema: z.ZodObject<{
63
+ id: z.ZodString;
64
+ ref: z.ZodString;
65
+ }, "strip", z.ZodTypeAny, {
66
+ id: string;
67
+ ref: string;
68
+ }, {
69
+ id: string;
70
+ ref: string;
71
+ }>;
72
+ type SpsItemIdResponse = z.infer<typeof spsItemIdResponseSchema>;
73
+
74
+ 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 };
@@ -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";