@viu/emporix-sdk 2.22.0 → 2.23.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 (105) hide show
  1. package/CHANGELOG.md +122 -0
  2. package/dist/availability.cjs +118 -0
  3. package/dist/availability.cjs.map +1 -1
  4. package/dist/availability.d.cts +178 -2
  5. package/dist/availability.d.ts +178 -2
  6. package/dist/availability.js +1 -1
  7. package/dist/cart.cjs +156 -11
  8. package/dist/cart.cjs.map +1 -1
  9. package/dist/cart.d.cts +176 -3
  10. package/dist/cart.d.ts +176 -3
  11. package/dist/cart.js +1 -1
  12. package/dist/category.cjs +192 -2
  13. package/dist/category.cjs.map +1 -1
  14. package/dist/category.d.cts +398 -1
  15. package/dist/category.d.ts +398 -1
  16. package/dist/category.js +1 -1
  17. package/dist/{chunk-HD5RBCM6.js → chunk-27NLS646.js} +10 -2
  18. package/dist/chunk-27NLS646.js.map +1 -0
  19. package/dist/{chunk-MMX5FGMI.js → chunk-6PJFOX3A.js} +109 -2
  20. package/dist/chunk-6PJFOX3A.js.map +1 -0
  21. package/dist/chunk-HWVFF6B2.js +378 -0
  22. package/dist/chunk-HWVFF6B2.js.map +1 -0
  23. package/dist/chunk-LQFRJSVT.js +224 -0
  24. package/dist/chunk-LQFRJSVT.js.map +1 -0
  25. package/dist/chunk-P7G4LOOV.js +264 -0
  26. package/dist/chunk-P7G4LOOV.js.map +1 -0
  27. package/dist/{chunk-44F52KRE.js → chunk-QQMLN76U.js} +27 -2
  28. package/dist/chunk-QQMLN76U.js.map +1 -0
  29. package/dist/chunk-UNW6SFSB.js +363 -0
  30. package/dist/chunk-UNW6SFSB.js.map +1 -0
  31. package/dist/chunk-V3275BA7.js +181 -0
  32. package/dist/chunk-V3275BA7.js.map +1 -0
  33. package/dist/chunk-W2KBVWJ2.js +323 -0
  34. package/dist/chunk-W2KBVWJ2.js.map +1 -0
  35. package/dist/{chunk-5DWCYDQD.js → chunk-YVZ6GOLE.js} +158 -13
  36. package/dist/chunk-YVZ6GOLE.js.map +1 -0
  37. package/dist/chunk-ZOFGDNSX.js +305 -0
  38. package/dist/chunk-ZOFGDNSX.js.map +1 -0
  39. package/dist/companies.cjs +25 -0
  40. package/dist/companies.cjs.map +1 -1
  41. package/dist/companies.d.cts +14 -0
  42. package/dist/companies.d.ts +14 -0
  43. package/dist/companies.js +1 -1
  44. package/dist/contacts.cjs +8 -0
  45. package/dist/contacts.cjs.map +1 -1
  46. package/dist/contacts.d.cts +2 -0
  47. package/dist/contacts.d.ts +2 -0
  48. package/dist/contacts.js +1 -1
  49. package/dist/customer-groups-BxSNFHq1.d.cts +706 -0
  50. package/dist/customer-groups-GlzWhDsi.d.ts +706 -0
  51. package/dist/customer-groups.cjs +200 -17
  52. package/dist/customer-groups.cjs.map +1 -1
  53. package/dist/customer-groups.d.cts +2 -110
  54. package/dist/customer-groups.d.ts +2 -110
  55. package/dist/customer-groups.js +1 -1
  56. package/dist/index.cjs +2220 -391
  57. package/dist/index.cjs.map +1 -1
  58. package/dist/index.d.cts +433 -11
  59. package/dist/index.d.ts +433 -11
  60. package/dist/index.js +668 -340
  61. package/dist/index.js.map +1 -1
  62. package/dist/orders.cjs +160 -2
  63. package/dist/orders.cjs.map +1 -1
  64. package/dist/orders.d.cts +221 -1
  65. package/dist/orders.d.ts +221 -1
  66. package/dist/orders.js +1 -1
  67. package/dist/payment.cjs +107 -0
  68. package/dist/payment.cjs.map +1 -1
  69. package/dist/payment.d.cts +299 -1
  70. package/dist/payment.d.ts +299 -1
  71. package/dist/payment.js +1 -1
  72. package/dist/price.cjs +197 -0
  73. package/dist/price.cjs.map +1 -1
  74. package/dist/price.d.cts +577 -1
  75. package/dist/price.d.ts +577 -1
  76. package/dist/price.js +1 -1
  77. package/dist/product.cjs +190 -0
  78. package/dist/product.cjs.map +1 -1
  79. package/dist/product.d.cts +503 -1
  80. package/dist/product.d.ts +503 -1
  81. package/dist/product.js +1 -1
  82. package/dist/segment.cjs +179 -0
  83. package/dist/segment.cjs.map +1 -1
  84. package/dist/segment.d.cts +181 -1
  85. package/dist/segment.d.ts +181 -1
  86. package/dist/segment.js +1 -1
  87. package/package.json +1 -1
  88. package/dist/chunk-36T4YPQJ.js +0 -106
  89. package/dist/chunk-36T4YPQJ.js.map +0 -1
  90. package/dist/chunk-3BTPX7IJ.js +0 -41
  91. package/dist/chunk-3BTPX7IJ.js.map +0 -1
  92. package/dist/chunk-44F52KRE.js.map +0 -1
  93. package/dist/chunk-5DWCYDQD.js.map +0 -1
  94. package/dist/chunk-A3LYJUD4.js +0 -108
  95. package/dist/chunk-A3LYJUD4.js.map +0 -1
  96. package/dist/chunk-DXOLWAOY.js +0 -188
  97. package/dist/chunk-DXOLWAOY.js.map +0 -1
  98. package/dist/chunk-FZMP5NQZ.js +0 -173
  99. package/dist/chunk-FZMP5NQZ.js.map +0 -1
  100. package/dist/chunk-HD5RBCM6.js.map +0 -1
  101. package/dist/chunk-IVCCGJN5.js +0 -63
  102. package/dist/chunk-IVCCGJN5.js.map +0 -1
  103. package/dist/chunk-MMX5FGMI.js.map +0 -1
  104. package/dist/chunk-NE7MIZPR.js +0 -144
  105. package/dist/chunk-NE7MIZPR.js.map +0 -1
@@ -0,0 +1,323 @@
1
+ import { requireCustomer } from './chunk-3BDDYX3V.js';
2
+
3
+ // src/services/segment.ts
4
+ function setIfDefined(q, key, value) {
5
+ if (value !== void 0 && value !== "") {
6
+ q[key] = value;
7
+ }
8
+ }
9
+ var SERVICE = { kind: "service" };
10
+ var SegmentService = class {
11
+ constructor(ctx, deps) {
12
+ this.ctx = ctx;
13
+ this.deps = deps;
14
+ }
15
+ ctx;
16
+ deps;
17
+ static channel = "segment";
18
+ static deps = ["products", "categories"];
19
+ base() {
20
+ return `/customer-segment/${this.ctx.tenant}/segments`;
21
+ }
22
+ /** Lists segments the caller belongs to (with `segment_read_own`). */
23
+ async list(query = {}, auth) {
24
+ const q = {};
25
+ setIfDefined(q, "q", query.q);
26
+ setIfDefined(q, "pageNumber", query.pageNumber);
27
+ setIfDefined(q, "pageSize", query.pageSize);
28
+ return this.ctx.http.request({
29
+ method: "GET",
30
+ path: this.base(),
31
+ auth: requireCustomer(auth),
32
+ ...Object.keys(q).length ? { query: q } : {}
33
+ });
34
+ }
35
+ /** Fetches a single segment by id. */
36
+ async get(segmentId, auth) {
37
+ return this.ctx.http.request({
38
+ method: "GET",
39
+ path: `${this.base()}/${segmentId}`,
40
+ auth: requireCustomer(auth)
41
+ });
42
+ }
43
+ /** Item assignments (PRODUCT + CATEGORY) across all the caller's active segments. */
44
+ async listItems(query = {}, auth) {
45
+ const q = {};
46
+ setIfDefined(q, "q", query.q);
47
+ setIfDefined(q, "siteCode", query.siteCode);
48
+ setIfDefined(q, "legalEntityId", query.legalEntityId);
49
+ setIfDefined(q, "pageNumber", query.pageNumber);
50
+ setIfDefined(q, "pageSize", query.pageSize);
51
+ if (query.onlyActive !== void 0) q.onlyActive = String(query.onlyActive);
52
+ return this.ctx.http.request({
53
+ method: "GET",
54
+ path: `${this.base()}/items`,
55
+ auth: requireCustomer(auth),
56
+ ...Object.keys(q).length ? { query: q } : {}
57
+ });
58
+ }
59
+ /** Item assignments of one specific segment. */
60
+ async listSegmentItems(segmentId, query = {}, auth) {
61
+ const q = {};
62
+ setIfDefined(q, "q", query.q);
63
+ setIfDefined(q, "legalEntityId", query.legalEntityId);
64
+ setIfDefined(q, "pageNumber", query.pageNumber);
65
+ setIfDefined(q, "pageSize", query.pageSize);
66
+ return this.ctx.http.request({
67
+ method: "GET",
68
+ path: `${this.base()}/${segmentId}/items`,
69
+ auth: requireCustomer(auth),
70
+ ...Object.keys(q).length ? { query: q } : {}
71
+ });
72
+ }
73
+ /** Category tree built only from the caller's active segments. */
74
+ async getCategoryTree(query = {}, auth) {
75
+ const q = {};
76
+ setIfDefined(q, "siteCode", query.siteCode);
77
+ setIfDefined(q, "legalEntityId", query.legalEntityId);
78
+ return this.ctx.http.request({
79
+ method: "GET",
80
+ path: `${this.base()}/items/category-trees`,
81
+ auth: requireCustomer(auth),
82
+ ...Object.keys(q).length ? { query: q } : {}
83
+ });
84
+ }
85
+ async pickItemIds(kind, query, auth) {
86
+ const rows = await this.listItems(query, auth);
87
+ const ids = [];
88
+ for (const r of rows) {
89
+ const id = r.item?.id;
90
+ if (r.type === kind && typeof id === "string") ids.push(id);
91
+ }
92
+ return ids;
93
+ }
94
+ /** Product ids assigned to the caller's active segments. */
95
+ async listMyProductIds(query, auth) {
96
+ return this.pickItemIds("PRODUCT", query ?? {}, auth);
97
+ }
98
+ /** Category ids assigned to the caller's active segments. */
99
+ async listMyCategoryIds(query, auth) {
100
+ return this.pickItemIds("CATEGORY", query ?? {}, auth);
101
+ }
102
+ /**
103
+ * Hydrates `listMyProductIds` via `ProductService.get` in parallel.
104
+ * Resolves in the same order as the id list. Any single failure rejects
105
+ * the whole batch (`Promise.all`); use the id-list method + your own
106
+ * tolerance strategy if partial success matters.
107
+ */
108
+ async listMyProducts(query, auth) {
109
+ const pageNumber = query?.pageNumber ?? 1;
110
+ const pageSize = query?.pageSize ?? 20;
111
+ const sourceItems = await this.listItems(
112
+ { ...query ?? {}, pageNumber, pageSize },
113
+ auth
114
+ );
115
+ const ids = [];
116
+ for (const r of sourceItems) {
117
+ if (r.type === "PRODUCT" && typeof r.item?.id === "string") ids.push(r.item.id);
118
+ }
119
+ const items = await this.deps.products.searchByIds(ids, void 0, auth);
120
+ return { items, pageNumber, pageSize, hasNextPage: sourceItems.length === pageSize };
121
+ }
122
+ /**
123
+ * Hydrates a page of the caller's segment CATEGORY assignments into
124
+ * real categories via one bulk `categories.searchByIds` call. Same
125
+ * `hasNextPage` semantic as `listMyProducts`.
126
+ */
127
+ async listMyCategories(query, auth) {
128
+ const pageNumber = query?.pageNumber ?? 1;
129
+ const pageSize = query?.pageSize ?? 20;
130
+ const sourceItems = await this.listItems(
131
+ { ...query ?? {}, pageNumber, pageSize },
132
+ auth
133
+ );
134
+ const ids = [];
135
+ for (const r of sourceItems) {
136
+ if (r.type === "CATEGORY" && typeof r.item?.id === "string") ids.push(r.item.id);
137
+ }
138
+ const items = await this.deps.categories.searchByIds(ids, void 0, auth);
139
+ return { items, pageNumber, pageSize, hasNextPage: sourceItems.length === pageSize };
140
+ }
141
+ // --- Admin CRUD (segment_manage). Default auth: service. ---
142
+ /** Creates a segment. Default auth: service. */
143
+ async create(input, authCtx = SERVICE) {
144
+ return this.ctx.http.request({ method: "POST", path: this.base(), auth: authCtx, body: input });
145
+ }
146
+ /** Searches segments (POST body). Default auth: service. */
147
+ async search(query, authCtx = SERVICE) {
148
+ return this.ctx.http.request({
149
+ method: "POST",
150
+ path: `${this.base()}/search`,
151
+ auth: authCtx,
152
+ body: query
153
+ });
154
+ }
155
+ /** Full-replaces a segment (PUT). Default auth: service. */
156
+ async update(segmentId, input, authCtx = SERVICE) {
157
+ return this.ctx.http.request({
158
+ method: "PUT",
159
+ path: `${this.base()}/${segmentId}`,
160
+ auth: authCtx,
161
+ body: input
162
+ });
163
+ }
164
+ /** Partially updates a segment (PATCH). Default auth: service. */
165
+ async patch(segmentId, input, authCtx = SERVICE) {
166
+ return this.ctx.http.request({
167
+ method: "PATCH",
168
+ path: `${this.base()}/${segmentId}`,
169
+ auth: authCtx,
170
+ body: input
171
+ });
172
+ }
173
+ /** Deletes a segment. Default auth: service. */
174
+ async delete(segmentId, authCtx = SERVICE) {
175
+ await this.ctx.http.request({
176
+ method: "DELETE",
177
+ path: `${this.base()}/${segmentId}`,
178
+ auth: authCtx
179
+ });
180
+ }
181
+ /** Checks which segments the given items/customers match. Default auth: service. */
182
+ async match(input, authCtx = SERVICE) {
183
+ return this.ctx.http.request({
184
+ method: "POST",
185
+ path: `${this.base()}/match`,
186
+ auth: authCtx,
187
+ body: input
188
+ });
189
+ }
190
+ /** Creates multiple segments. Default auth: service. */
191
+ async bulkCreate(inputs, authCtx = SERVICE) {
192
+ return this.ctx.http.request({
193
+ method: "POST",
194
+ path: `${this.base()}/bulk`,
195
+ auth: authCtx,
196
+ body: inputs
197
+ });
198
+ }
199
+ /** Upserts multiple segments (PUT). Default auth: service. */
200
+ async bulkUpdate(inputs, authCtx = SERVICE) {
201
+ return this.ctx.http.request({
202
+ method: "PUT",
203
+ path: `${this.base()}/bulk`,
204
+ auth: authCtx,
205
+ body: inputs
206
+ });
207
+ }
208
+ /** Deletes multiple segments (DELETE with a body of ids). Default auth: service. */
209
+ async bulkDelete(body, authCtx = SERVICE) {
210
+ return this.ctx.http.request({
211
+ method: "DELETE",
212
+ path: `${this.base()}/bulk`,
213
+ auth: authCtx,
214
+ body
215
+ });
216
+ }
217
+ /** Customer→segment assignments (`segment_manage`). Default auth: service. */
218
+ customers = {
219
+ list: async (segmentId, query, authCtx = SERVICE) => this.ctx.http.request({
220
+ method: "GET",
221
+ path: `${this.base()}/${segmentId}/customers`,
222
+ auth: authCtx,
223
+ ...query ? { query } : {}
224
+ }),
225
+ search: async (segmentId, query, authCtx = SERVICE) => this.ctx.http.request({
226
+ method: "POST",
227
+ path: `${this.base()}/${segmentId}/customers/search`,
228
+ auth: authCtx,
229
+ body: query
230
+ }),
231
+ get: async (segmentId, customerId, authCtx = SERVICE) => this.ctx.http.request({
232
+ method: "GET",
233
+ path: `${this.base()}/${segmentId}/customers/${customerId}`,
234
+ auth: authCtx
235
+ }),
236
+ assign: async (segmentId, customerId, input, authCtx = SERVICE) => this.ctx.http.request({
237
+ method: "PUT",
238
+ path: `${this.base()}/${segmentId}/customers/${customerId}`,
239
+ auth: authCtx,
240
+ body: input
241
+ }),
242
+ remove: async (segmentId, customerId, authCtx = SERVICE) => {
243
+ await this.ctx.http.request({
244
+ method: "DELETE",
245
+ path: `${this.base()}/${segmentId}/customers/${customerId}`,
246
+ auth: authCtx
247
+ });
248
+ },
249
+ getForEntity: async (segmentId, customerId, legalEntityId, authCtx = SERVICE) => this.ctx.http.request({
250
+ method: "GET",
251
+ path: `${this.base()}/${segmentId}/customers/${customerId}/${legalEntityId}`,
252
+ auth: authCtx
253
+ }),
254
+ assignForEntity: async (segmentId, customerId, legalEntityId, input, authCtx = SERVICE) => this.ctx.http.request({
255
+ method: "PUT",
256
+ path: `${this.base()}/${segmentId}/customers/${customerId}/${legalEntityId}`,
257
+ auth: authCtx,
258
+ body: input
259
+ }),
260
+ removeForEntity: async (segmentId, customerId, legalEntityId, authCtx = SERVICE) => {
261
+ await this.ctx.http.request({
262
+ method: "DELETE",
263
+ path: `${this.base()}/${segmentId}/customers/${customerId}/${legalEntityId}`,
264
+ auth: authCtx
265
+ });
266
+ },
267
+ bulkAssign: async (segmentId, inputs, authCtx = SERVICE) => this.ctx.http.request({
268
+ method: "PUT",
269
+ path: `${this.base()}/${segmentId}/customers/bulk`,
270
+ auth: authCtx,
271
+ body: inputs
272
+ }),
273
+ bulkRemove: async (segmentId, body, authCtx = SERVICE) => this.ctx.http.request({
274
+ method: "DELETE",
275
+ path: `${this.base()}/${segmentId}/customers/bulk`,
276
+ auth: authCtx,
277
+ body
278
+ })
279
+ };
280
+ /** Item→segment assignments (`type` = PRODUCT | CATEGORY). Default auth: service. */
281
+ items = {
282
+ search: async (segmentId, query, authCtx = SERVICE) => this.ctx.http.request({
283
+ method: "POST",
284
+ path: `${this.base()}/${segmentId}/items/search`,
285
+ auth: authCtx,
286
+ body: query
287
+ }),
288
+ get: async (segmentId, type, itemId, authCtx = SERVICE) => this.ctx.http.request({
289
+ method: "GET",
290
+ path: `${this.base()}/${segmentId}/items/${type}/${itemId}`,
291
+ auth: authCtx
292
+ }),
293
+ assign: async (segmentId, type, itemId, input, authCtx = SERVICE) => this.ctx.http.request({
294
+ method: "PUT",
295
+ path: `${this.base()}/${segmentId}/items/${type}/${itemId}`,
296
+ auth: authCtx,
297
+ body: input
298
+ }),
299
+ remove: async (segmentId, type, itemId, authCtx = SERVICE) => {
300
+ await this.ctx.http.request({
301
+ method: "DELETE",
302
+ path: `${this.base()}/${segmentId}/items/${type}/${itemId}`,
303
+ auth: authCtx
304
+ });
305
+ },
306
+ bulkAssign: async (segmentId, type, inputs, authCtx = SERVICE) => this.ctx.http.request({
307
+ method: "PUT",
308
+ path: `${this.base()}/${segmentId}/items/${type}/bulk`,
309
+ auth: authCtx,
310
+ body: inputs
311
+ }),
312
+ bulkRemove: async (segmentId, type, body, authCtx = SERVICE) => this.ctx.http.request({
313
+ method: "DELETE",
314
+ path: `${this.base()}/${segmentId}/items/${type}/bulk`,
315
+ auth: authCtx,
316
+ body
317
+ })
318
+ };
319
+ };
320
+
321
+ export { SegmentService };
322
+ //# sourceMappingURL=chunk-W2KBVWJ2.js.map
323
+ //# sourceMappingURL=chunk-W2KBVWJ2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/services/segment.ts"],"names":[],"mappings":";;;AA8DA,SAAS,YAAA,CACP,CAAA,EACA,GAAA,EACA,KAAA,EACM;AACN,EAAA,IAAI,KAAA,KAAU,MAAA,IAAa,KAAA,KAAU,EAAA,EAAI;AACvC,IAAA,CAAA,CAAE,GAAG,CAAA,GAAI,KAAA;AAAA,EACX;AACF;AAGA,IAAM,OAAA,GAAuB,EAAE,IAAA,EAAM,SAAA,EAAU;AAQxC,IAAM,iBAAN,MAAqB;AAAA,EAG1B,WAAA,CACmB,KACA,IAAA,EACjB;AAFiB,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AACA,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AAAA,EAChB;AAAA,EAFgB,GAAA;AAAA,EACA,IAAA;AAAA,EAJnB,OAAgB,OAAA,GAAU,SAAA;AAAA,EAC1B,OAAgB,IAAA,GAAO,CAAC,UAAA,EAAY,YAAY,CAAA;AAAA,EAMxC,IAAA,GAAe;AACrB,IAAA,OAAO,CAAA,kBAAA,EAAqB,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,SAAA,CAAA;AAAA,EAC7C;AAAA;AAAA,EAGA,MAAM,IAAA,CACJ,KAAA,GAAgE,IAChE,IAAA,EACoB;AACpB,IAAA,MAAM,IAAiD,EAAC;AACxD,IAAA,YA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EAAmB,IAAA,EAAc,IAAA,EAA+B,UAAuB,OAAA,KACxG,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAuC;AAAA,MACnD,MAAA,EAAQ,QAAA;AAAA,MACR,IAAA,EAAM,GAAG,IAAA,CAAK,IAAA,EAAM,CAAA,CAAA,EAAI,SAAS,UAAU,IAAI,CAAA,KAAA,CAAA;AAAA,MAC/C,IAAA,EAAM,OAAA;AAAA,MACN;AAAA,KACD;AAAA,GACL;AACF","file":"chunk-W2KBVWJ2.js","sourcesContent":["import type { ClientContext, PaginatedItems } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport { requireCustomer } from \"../core/require-customer\";\nimport type { ProductService } from \"./product\";\nimport type { CategoryService } from \"./category\";\nimport type {\n SegmentResponse,\n ItemAssignmentResponse,\n CategoryTreeResponse,\n SegmentCreation,\n SegmentUpdate,\n SegmentsSearch,\n SegmentUpdateBulk,\n Match,\n CustomerAssignmentUpsert,\n CustomerAssignmentUpsertBulk,\n CustomerAssignmentResponse,\n ItemAssignmentUpsert,\n ItemAssignmentUpsertBulk,\n BulkResponse,\n BulkAssignmentResponse,\n} from \"../generated/customer-segment\";\n\n/** Generated segment types (read shapes — storefront `segment_read_own`). */\nexport type Segment = SegmentResponse;\nexport type SegmentItem = ItemAssignmentResponse;\nexport type SegmentCategoryTree = CategoryTreeResponse;\nexport type SegmentCategoryTreeNode = CategoryTreeResponse[number];\n\n/** Create body for a segment (generated). */\nexport type SegmentInput = SegmentCreation;\n/** Full-replace (PUT) body for a segment (generated). */\nexport type SegmentUpdateInput = SegmentUpdate;\n/** Partial (PATCH) body for a segment. */\nexport type SegmentPatchInput = Partial<SegmentUpdate>;\n/** Search body for segments (generated). */\nexport type SegmentSearchQuery = SegmentsSearch;\n/** Body for a segment match check (generated). */\nexport type SegmentMatchInput = Match;\n/** One entry of a segment bulk request (generated). */\nexport type SegmentBulkItem = SegmentUpdateBulk;\n/** Per-entry result of a segment bulk operation (generated). */\nexport type SegmentBulkResult = BulkResponse;\n/** Customer→segment assignment body (generated). */\nexport type SegmentCustomerInput = CustomerAssignmentUpsert;\n/** One entry of a customer-assignment bulk request (generated). */\nexport type SegmentCustomerBulkInput = CustomerAssignmentUpsertBulk;\n/** A customer→segment assignment (read). */\nexport type SegmentCustomer = CustomerAssignmentResponse;\n/** Item→segment assignment body (generated). */\nexport type SegmentItemInput = ItemAssignmentUpsert;\n/** One entry of an item-assignment bulk request (generated). */\nexport type SegmentItemBulkInput = ItemAssignmentUpsertBulk;\n/** Per-entry result of an assignment bulk operation (generated). */\nexport type SegmentAssignmentBulkResult = BulkAssignmentResponse;\n\n/** Cross-service hydrate dependencies, injected from `EmporixClient`. */\nexport interface SegmentServiceDeps {\n products: ProductService;\n categories: CategoryService;\n}\n\nfunction setIfDefined<V>(\n q: Record<string, string | number | undefined>,\n key: string,\n value: V | undefined,\n): void {\n if (value !== undefined && value !== \"\") {\n q[key] = value as unknown as string | number;\n }\n}\n\n/** Admin default: segment-manage operations use a service token. */\nconst SERVICE: AuthContext = { kind: \"service\" };\n\n/**\n * Customer-segment reads. Every method requires a customer/raw\n * `AuthContext` — the `segment_read_own` scope is on the customer token.\n * The standard product/category endpoints do **not** auto-filter by\n * segment; the storefront uses these reads to discover what to fetch.\n */\nexport class SegmentService {\n static readonly channel = \"segment\" as const;\n static readonly deps = [\"products\", \"categories\"] as const;\n constructor(\n private readonly ctx: ClientContext,\n private readonly deps: SegmentServiceDeps,\n ) {}\n\n private base(): string {\n return `/customer-segment/${this.ctx.tenant}/segments`;\n }\n\n /** Lists segments the caller belongs to (with `segment_read_own`). */\n async list(\n query: { q?: string; pageNumber?: number; pageSize?: number } = {},\n auth?: AuthContext,\n ): Promise<Segment[]> {\n const q: Record<string, string | number | undefined> = {};\n setIfDefined(q, \"q\", query.q);\n setIfDefined(q, \"pageNumber\", query.pageNumber);\n setIfDefined(q, \"pageSize\", query.pageSize);\n return this.ctx.http.request<Segment[]>({\n method: \"GET\",\n path: this.base(),\n auth: requireCustomer(auth),\n ...(Object.keys(q).length ? { query: q } : {}),\n });\n }\n\n /** Fetches a single segment by id. */\n async get(segmentId: string, auth?: AuthContext): Promise<Segment> {\n return this.ctx.http.request<Segment>({\n method: \"GET\",\n path: `${this.base()}/${segmentId}`,\n auth: requireCustomer(auth),\n });\n }\n\n /** Item assignments (PRODUCT + CATEGORY) across all the caller's active segments. */\n async listItems(\n query: {\n q?: string;\n siteCode?: string;\n legalEntityId?: string;\n onlyActive?: boolean;\n pageNumber?: number;\n pageSize?: number;\n } = {},\n auth?: AuthContext,\n ): Promise<SegmentItem[]> {\n const q: Record<string, string | number | undefined> = {};\n setIfDefined(q, \"q\", query.q);\n setIfDefined(q, \"siteCode\", query.siteCode);\n setIfDefined(q, \"legalEntityId\", query.legalEntityId);\n setIfDefined(q, \"pageNumber\", query.pageNumber);\n setIfDefined(q, \"pageSize\", query.pageSize);\n if (query.onlyActive !== undefined) q.onlyActive = String(query.onlyActive);\n return this.ctx.http.request<SegmentItem[]>({\n method: \"GET\",\n path: `${this.base()}/items`,\n auth: requireCustomer(auth),\n ...(Object.keys(q).length ? { query: q } : {}),\n });\n }\n\n /** Item assignments of one specific segment. */\n async listSegmentItems(\n segmentId: string,\n query: {\n q?: string;\n legalEntityId?: string;\n pageNumber?: number;\n pageSize?: number;\n } = {},\n auth?: AuthContext,\n ): Promise<SegmentItem[]> {\n const q: Record<string, string | number | undefined> = {};\n setIfDefined(q, \"q\", query.q);\n setIfDefined(q, \"legalEntityId\", query.legalEntityId);\n setIfDefined(q, \"pageNumber\", query.pageNumber);\n setIfDefined(q, \"pageSize\", query.pageSize);\n return this.ctx.http.request<SegmentItem[]>({\n method: \"GET\",\n path: `${this.base()}/${segmentId}/items`,\n auth: requireCustomer(auth),\n ...(Object.keys(q).length ? { query: q } : {}),\n });\n }\n\n /** Category tree built only from the caller's active segments. */\n async getCategoryTree(\n query: { siteCode?: string; legalEntityId?: string } = {},\n auth?: AuthContext,\n ): Promise<SegmentCategoryTree> {\n const q: Record<string, string | number | undefined> = {};\n setIfDefined(q, \"siteCode\", query.siteCode);\n setIfDefined(q, \"legalEntityId\", query.legalEntityId);\n return this.ctx.http.request<SegmentCategoryTree>({\n method: \"GET\",\n path: `${this.base()}/items/category-trees`,\n auth: requireCustomer(auth),\n ...(Object.keys(q).length ? { query: q } : {}),\n });\n }\n\n private async pickItemIds(\n kind: \"PRODUCT\" | \"CATEGORY\",\n query: Parameters<SegmentService[\"listItems\"]>[0],\n auth: AuthContext | undefined,\n ): Promise<string[]> {\n const rows = await this.listItems(query, auth);\n const ids: string[] = [];\n for (const r of rows) {\n const id = r.item?.id;\n if (r.type === kind && typeof id === \"string\") ids.push(id);\n }\n return ids;\n }\n\n /** Product ids assigned to the caller's active segments. */\n async listMyProductIds(\n query?: Parameters<SegmentService[\"listItems\"]>[0],\n auth?: AuthContext,\n ): Promise<string[]> {\n return this.pickItemIds(\"PRODUCT\", query ?? {}, auth);\n }\n\n /** Category ids assigned to the caller's active segments. */\n async listMyCategoryIds(\n query?: Parameters<SegmentService[\"listItems\"]>[0],\n auth?: AuthContext,\n ): Promise<string[]> {\n return this.pickItemIds(\"CATEGORY\", query ?? {}, auth);\n }\n\n /**\n * Hydrates `listMyProductIds` via `ProductService.get` in parallel.\n * Resolves in the same order as the id list. Any single failure rejects\n * the whole batch (`Promise.all`); use the id-list method + your own\n * tolerance strategy if partial success matters.\n */\n async listMyProducts(\n query?: Parameters<SegmentService[\"listItems\"]>[0],\n auth?: AuthContext,\n ): Promise<PaginatedItems<Awaited<ReturnType<ProductService[\"get\"]>>>> {\n const pageNumber = query?.pageNumber ?? 1;\n const pageSize = query?.pageSize ?? 20;\n const sourceItems = await this.listItems(\n { ...(query ?? {}), pageNumber, pageSize },\n auth,\n );\n const ids: string[] = [];\n for (const r of sourceItems) {\n if (r.type === \"PRODUCT\" && typeof r.item?.id === \"string\") ids.push(r.item.id);\n }\n const items = await this.deps.products.searchByIds(ids, undefined, auth);\n return { items, pageNumber, pageSize, hasNextPage: sourceItems.length === pageSize };\n }\n\n /**\n * Hydrates a page of the caller's segment CATEGORY assignments into\n * real categories via one bulk `categories.searchByIds` call. Same\n * `hasNextPage` semantic as `listMyProducts`.\n */\n async listMyCategories(\n query?: Parameters<SegmentService[\"listItems\"]>[0],\n auth?: AuthContext,\n ): Promise<PaginatedItems<Awaited<ReturnType<CategoryService[\"get\"]>>>> {\n const pageNumber = query?.pageNumber ?? 1;\n const pageSize = query?.pageSize ?? 20;\n const sourceItems = await this.listItems(\n { ...(query ?? {}), pageNumber, pageSize },\n auth,\n );\n const ids: string[] = [];\n for (const r of sourceItems) {\n if (r.type === \"CATEGORY\" && typeof r.item?.id === \"string\") ids.push(r.item.id);\n }\n const items = await this.deps.categories.searchByIds(ids, undefined, auth);\n return { items, pageNumber, pageSize, hasNextPage: sourceItems.length === pageSize };\n }\n\n // --- Admin CRUD (segment_manage). Default auth: service. ---\n\n /** Creates a segment. Default auth: service. */\n async create(input: SegmentInput, authCtx: AuthContext = SERVICE): Promise<Segment> {\n return this.ctx.http.request<Segment>({ method: \"POST\", path: this.base(), auth: authCtx, body: input });\n }\n\n /** Searches segments (POST body). Default auth: service. */\n async search(query: SegmentSearchQuery, authCtx: AuthContext = SERVICE): Promise<Segment[]> {\n return this.ctx.http.request<Segment[]>({\n method: \"POST\",\n path: `${this.base()}/search`,\n auth: authCtx,\n body: query,\n });\n }\n\n /** Full-replaces a segment (PUT). Default auth: service. */\n async update(segmentId: string, input: SegmentUpdateInput, authCtx: AuthContext = SERVICE): Promise<Segment> {\n return this.ctx.http.request<Segment>({\n method: \"PUT\",\n path: `${this.base()}/${segmentId}`,\n auth: authCtx,\n body: input,\n });\n }\n\n /** Partially updates a segment (PATCH). Default auth: service. */\n async patch(segmentId: string, input: SegmentPatchInput, authCtx: AuthContext = SERVICE): Promise<Segment> {\n return this.ctx.http.request<Segment>({\n method: \"PATCH\",\n path: `${this.base()}/${segmentId}`,\n auth: authCtx,\n body: input,\n });\n }\n\n /** Deletes a segment. Default auth: service. */\n async delete(segmentId: string, authCtx: AuthContext = SERVICE): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${segmentId}`,\n auth: authCtx,\n });\n }\n\n /** Checks which segments the given items/customers match. Default auth: service. */\n async match(input: SegmentMatchInput, authCtx: AuthContext = SERVICE): Promise<Segment[]> {\n return this.ctx.http.request<Segment[]>({\n method: \"POST\",\n path: `${this.base()}/match`,\n auth: authCtx,\n body: input,\n });\n }\n\n /** Creates multiple segments. Default auth: service. */\n async bulkCreate(inputs: SegmentBulkItem[], authCtx: AuthContext = SERVICE): Promise<SegmentBulkResult[]> {\n return this.ctx.http.request<SegmentBulkResult[]>({\n method: \"POST\",\n path: `${this.base()}/bulk`,\n auth: authCtx,\n body: inputs,\n });\n }\n\n /** Upserts multiple segments (PUT). Default auth: service. */\n async bulkUpdate(inputs: SegmentBulkItem[], authCtx: AuthContext = SERVICE): Promise<SegmentBulkResult[]> {\n return this.ctx.http.request<SegmentBulkResult[]>({\n method: \"PUT\",\n path: `${this.base()}/bulk`,\n auth: authCtx,\n body: inputs,\n });\n }\n\n /** Deletes multiple segments (DELETE with a body of ids). Default auth: service. */\n async bulkDelete(body: Record<string, unknown>, authCtx: AuthContext = SERVICE): Promise<SegmentBulkResult[]> {\n return this.ctx.http.request<SegmentBulkResult[]>({\n method: \"DELETE\",\n path: `${this.base()}/bulk`,\n auth: authCtx,\n body,\n });\n }\n\n /** Customer→segment assignments (`segment_manage`). Default auth: service. */\n readonly customers = {\n list: async (segmentId: string, query?: Record<string, string | number>, authCtx: AuthContext = SERVICE): Promise<SegmentCustomer[]> =>\n this.ctx.http.request<SegmentCustomer[]>({\n method: \"GET\",\n path: `${this.base()}/${segmentId}/customers`,\n auth: authCtx,\n ...(query ? { query } : {}),\n }),\n search: async (segmentId: string, query: Record<string, unknown>, authCtx: AuthContext = SERVICE): Promise<SegmentCustomer[]> =>\n this.ctx.http.request<SegmentCustomer[]>({\n method: \"POST\",\n path: `${this.base()}/${segmentId}/customers/search`,\n auth: authCtx,\n body: query,\n }),\n get: async (segmentId: string, customerId: string, authCtx: AuthContext = SERVICE): Promise<SegmentCustomer> =>\n this.ctx.http.request<SegmentCustomer>({\n method: \"GET\",\n path: `${this.base()}/${segmentId}/customers/${customerId}`,\n auth: authCtx,\n }),\n assign: async (segmentId: string, customerId: string, input: SegmentCustomerInput, authCtx: AuthContext = SERVICE): Promise<SegmentCustomer> =>\n this.ctx.http.request<SegmentCustomer>({\n method: \"PUT\",\n path: `${this.base()}/${segmentId}/customers/${customerId}`,\n auth: authCtx,\n body: input,\n }),\n remove: async (segmentId: string, customerId: string, authCtx: AuthContext = SERVICE): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${segmentId}/customers/${customerId}`,\n auth: authCtx,\n });\n },\n getForEntity: async (segmentId: string, customerId: string, legalEntityId: string, authCtx: AuthContext = SERVICE): Promise<SegmentCustomer> =>\n this.ctx.http.request<SegmentCustomer>({\n method: \"GET\",\n path: `${this.base()}/${segmentId}/customers/${customerId}/${legalEntityId}`,\n auth: authCtx,\n }),\n assignForEntity: async (segmentId: string, customerId: string, legalEntityId: string, input: SegmentCustomerInput, authCtx: AuthContext = SERVICE): Promise<SegmentCustomer> =>\n this.ctx.http.request<SegmentCustomer>({\n method: \"PUT\",\n path: `${this.base()}/${segmentId}/customers/${customerId}/${legalEntityId}`,\n auth: authCtx,\n body: input,\n }),\n removeForEntity: async (segmentId: string, customerId: string, legalEntityId: string, authCtx: AuthContext = SERVICE): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${segmentId}/customers/${customerId}/${legalEntityId}`,\n auth: authCtx,\n });\n },\n bulkAssign: async (segmentId: string, inputs: SegmentCustomerBulkInput[], authCtx: AuthContext = SERVICE): Promise<SegmentAssignmentBulkResult[]> =>\n this.ctx.http.request<SegmentAssignmentBulkResult[]>({\n method: \"PUT\",\n path: `${this.base()}/${segmentId}/customers/bulk`,\n auth: authCtx,\n body: inputs,\n }),\n bulkRemove: async (segmentId: string, body: Record<string, unknown>, authCtx: AuthContext = SERVICE): Promise<SegmentAssignmentBulkResult[]> =>\n this.ctx.http.request<SegmentAssignmentBulkResult[]>({\n method: \"DELETE\",\n path: `${this.base()}/${segmentId}/customers/bulk`,\n auth: authCtx,\n body,\n }),\n };\n\n /** Item→segment assignments (`type` = PRODUCT | CATEGORY). Default auth: service. */\n readonly items = {\n search: async (segmentId: string, query: Record<string, unknown>, authCtx: AuthContext = SERVICE): Promise<SegmentItem[]> =>\n this.ctx.http.request<SegmentItem[]>({\n method: \"POST\",\n path: `${this.base()}/${segmentId}/items/search`,\n auth: authCtx,\n body: query,\n }),\n get: async (segmentId: string, type: string, itemId: string, authCtx: AuthContext = SERVICE): Promise<SegmentItem> =>\n this.ctx.http.request<SegmentItem>({\n method: \"GET\",\n path: `${this.base()}/${segmentId}/items/${type}/${itemId}`,\n auth: authCtx,\n }),\n assign: async (segmentId: string, type: string, itemId: string, input: SegmentItemInput, authCtx: AuthContext = SERVICE): Promise<SegmentItem> =>\n this.ctx.http.request<SegmentItem>({\n method: \"PUT\",\n path: `${this.base()}/${segmentId}/items/${type}/${itemId}`,\n auth: authCtx,\n body: input,\n }),\n remove: async (segmentId: string, type: string, itemId: string, authCtx: AuthContext = SERVICE): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${segmentId}/items/${type}/${itemId}`,\n auth: authCtx,\n });\n },\n bulkAssign: async (segmentId: string, type: string, inputs: SegmentItemBulkInput[], authCtx: AuthContext = SERVICE): Promise<SegmentAssignmentBulkResult[]> =>\n this.ctx.http.request<SegmentAssignmentBulkResult[]>({\n method: \"PUT\",\n path: `${this.base()}/${segmentId}/items/${type}/bulk`,\n auth: authCtx,\n body: inputs,\n }),\n bulkRemove: async (segmentId: string, type: string, body: Record<string, unknown>, authCtx: AuthContext = SERVICE): Promise<SegmentAssignmentBulkResult[]> =>\n this.ctx.http.request<SegmentAssignmentBulkResult[]>({\n method: \"DELETE\",\n path: `${this.base()}/${segmentId}/items/${type}/bulk`,\n auth: authCtx,\n body,\n }),\n };\n}\n"]}
@@ -213,23 +213,62 @@ var CartService = class {
213
213
  body: items
214
214
  });
215
215
  }
216
- /** Sets the shipping address. */
216
+ /**
217
+ * Sets the cart's shipping address, preserving the billing address.
218
+ *
219
+ * The API has no per-type address endpoint: addresses live in the cart's
220
+ * `addresses` array, written via `PUT /carts/{cartId}`. That array is a **full
221
+ * replace** — sending only one type leaves the other as an empty stub — so
222
+ * this method reads the cart, merges, writes, and re-fetches. Use
223
+ * {@link setAddresses} to set both in a single request.
224
+ */
217
225
  async setShippingAddress(cartId, address, auth) {
218
- return this.ctx.http.request({
226
+ return this.mergeAddress(cartId, address, "SHIPPING", requireCartAuth(auth));
227
+ }
228
+ /**
229
+ * Sets the cart's billing address, preserving the shipping address. See
230
+ * {@link setShippingAddress} for why this reads before writing.
231
+ */
232
+ async setBillingAddress(cartId, address, auth) {
233
+ return this.mergeAddress(cartId, address, "BILLING", requireCartAuth(auth));
234
+ }
235
+ /**
236
+ * Sets both cart addresses in one request (`PUT /carts/{cartId}`), skipping
237
+ * the read that {@link setShippingAddress} needs.
238
+ *
239
+ * **This replaces the cart's address set**: a type you omit is cleared, and
240
+ * `{}` clears both. Use it when you already hold both addresses (a checkout
241
+ * form submitting them together); use the per-type setters to change one and
242
+ * keep the other.
243
+ */
244
+ async setAddresses(cartId, addresses, auth) {
245
+ const cartAuth = requireCartAuth(auth);
246
+ const next = [];
247
+ if (addresses.shipping) next.push({ ...addresses.shipping, type: "SHIPPING" });
248
+ if (addresses.billing) next.push({ ...addresses.billing, type: "BILLING" });
249
+ await this.ctx.http.request({
219
250
  method: "PUT",
220
- path: `${this.base()}/${cartId}/shipping-address`,
221
- auth: requireCartAuth(auth),
222
- body: address
251
+ path: `${this.base()}/${cartId}`,
252
+ auth: cartAuth,
253
+ body: { addresses: next }
223
254
  });
255
+ return this.get(cartId, cartAuth);
224
256
  }
225
- /** Sets the billing address. */
226
- async setBillingAddress(cartId, address, auth) {
227
- return this.ctx.http.request({
257
+ /**
258
+ * Reads the cart, replaces the entry of `type` with `address` (keeping every
259
+ * other type verbatim — resending it unchanged is what stops the server from
260
+ * wiping it), writes, and returns the re-fetched cart.
261
+ */
262
+ async mergeAddress(cartId, address, type, cartAuth) {
263
+ const current = await this.get(cartId, cartAuth);
264
+ const others = (current.addresses ?? []).filter((a) => a.type !== type);
265
+ await this.ctx.http.request({
228
266
  method: "PUT",
229
- path: `${this.base()}/${cartId}/billing-address`,
230
- auth: requireCartAuth(auth),
231
- body: address
267
+ path: `${this.base()}/${cartId}`,
268
+ auth: cartAuth,
269
+ body: { addresses: [...others, { ...address, type }] }
232
270
  });
271
+ return this.get(cartId, cartAuth);
233
272
  }
234
273
  /**
235
274
  * Merges one or more anonymous carts into the specified customer cart.
@@ -247,8 +286,114 @@ var CartService = class {
247
286
  body: { carts: anonymousCartIds }
248
287
  });
249
288
  }
289
+ /**
290
+ * Searches carts tenant-wide (`POST /carts/search`, body `{ q }`). This is a
291
+ * backend/admin operation — a customer token cannot scan other customers'
292
+ * carts, so `auth` is forwarded unguarded (pass a service token for admin
293
+ * use). The server enforces scope (403 on insufficient).
294
+ */
295
+ async search(query, auth, params = {}) {
296
+ return this.ctx.http.request({
297
+ method: "POST",
298
+ path: `${this.base()}/search`,
299
+ query: {
300
+ ...params.pageNumber === void 0 ? {} : { pageNumber: params.pageNumber },
301
+ ...params.pageSize === void 0 ? {} : { pageSize: params.pageSize },
302
+ ...params.sort === void 0 ? {} : { sort: params.sort },
303
+ ...params.fields === void 0 ? {} : { fields: params.fields }
304
+ },
305
+ body: query,
306
+ idempotent: true,
307
+ // pure read over POST — safe to replay on 5xx/429
308
+ auth
309
+ });
310
+ }
311
+ /**
312
+ * Deletes a cart (`DELETE /carts/{cartId}`). Backend/admin or owner
313
+ * operation — `auth` is forwarded unguarded (service or customer). Returns
314
+ * nothing; the cart no longer exists.
315
+ */
316
+ async delete(cartId, auth) {
317
+ await this.ctx.http.request({
318
+ method: "DELETE",
319
+ path: `${this.base()}/${cartId}`,
320
+ auth
321
+ });
322
+ }
323
+ /**
324
+ * Full-updates a cart (`PUT /carts/{cartId}`, body `UpdateCart`). Backend or
325
+ * owner operation — `auth` is forwarded unguarded. The endpoint returns 204,
326
+ * so the cart is re-fetched with the same `auth` (via a direct GET, not
327
+ * `get()`, so a service token is not rejected by the cart-auth guard) and
328
+ * returned.
329
+ */
330
+ async update(cartId, input, auth) {
331
+ await this.ctx.http.request({
332
+ method: "PUT",
333
+ path: `${this.base()}/${cartId}`,
334
+ auth,
335
+ body: input
336
+ });
337
+ return this.ctx.http.request({
338
+ method: "GET",
339
+ path: `${this.base()}/${cartId}`,
340
+ auth
341
+ });
342
+ }
343
+ /** Fetches a single cart item's details (`GET /carts/{cartId}/items/{itemId}`). */
344
+ async getItem(cartId, itemId, auth) {
345
+ return this.ctx.http.request({
346
+ method: "GET",
347
+ path: `${this.base()}/${cartId}/items/${itemId}`,
348
+ auth: requireCartAuth(auth)
349
+ });
350
+ }
351
+ /** Lists the discounts applied to a cart (`GET /carts/{cartId}/discounts`). */
352
+ async listDiscounts(cartId, auth) {
353
+ return this.ctx.http.request({
354
+ method: "GET",
355
+ path: `${this.base()}/${cartId}/discounts`,
356
+ auth: requireCartAuth(auth)
357
+ });
358
+ }
359
+ /**
360
+ * Removes all discounts from a cart (`DELETE /carts/{cartId}/discounts` with
361
+ * no `codes` filter), then re-fetches and returns the updated cart. Use
362
+ * `removeCoupon(code)` to remove a specific coupon by code.
363
+ */
364
+ async removeAllDiscounts(cartId, auth) {
365
+ const cartAuth = requireCartAuth(auth);
366
+ await this.ctx.http.request({
367
+ method: "DELETE",
368
+ path: `${this.base()}/${cartId}/discounts`,
369
+ auth: cartAuth
370
+ });
371
+ return this.get(cartId, cartAuth);
372
+ }
373
+ /**
374
+ * Removes a single discount by its index (`DELETE
375
+ * /carts/{cartId}/discounts/{discountIndex}`), then re-fetches and returns
376
+ * the updated cart.
377
+ */
378
+ async removeDiscountByIndex(cartId, discountIndex, auth) {
379
+ const cartAuth = requireCartAuth(auth);
380
+ await this.ctx.http.request({
381
+ method: "DELETE",
382
+ path: `${this.base()}/${cartId}/discounts/${discountIndex}`,
383
+ auth: cartAuth
384
+ });
385
+ return this.get(cartId, cartAuth);
386
+ }
387
+ /** Retrieves the cart's lead-time and non-delivery-time restrictions (`GET /carts/{cartId}/dtRestrictions`). */
388
+ async getDeliveryRestrictions(cartId, auth) {
389
+ return this.ctx.http.request({
390
+ method: "GET",
391
+ path: `${this.base()}/${cartId}/dtRestrictions`,
392
+ auth: requireCartAuth(auth)
393
+ });
394
+ }
250
395
  };
251
396
 
252
397
  export { CartService };
253
- //# sourceMappingURL=chunk-5DWCYDQD.js.map
254
- //# sourceMappingURL=chunk-5DWCYDQD.js.map
398
+ //# sourceMappingURL=chunk-YVZ6GOLE.js.map
399
+ //# sourceMappingURL=chunk-YVZ6GOLE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/services/cart.ts"],"names":[],"mappings":";;;AAsEA,SAAS,gBAAgB,IAAA,EAA4C;AACnE,EAAA,IAAI,SAAS,IAAA,CAAK,IAAA,KAAS,cAAc,IAAA,CAAK,IAAA,KAAS,cAAc,OAAO,IAAA;AAC5E,EAAA,MAAM,IAAI,sBAAA;AAAA,IACR;AAAA,GACF;AACF;AAEA,SAAS,oBAAoB,IAAA,EAA4C;AACvE,EAAA,IAAI,IAAA,IAAQ,IAAA,CAAK,IAAA,KAAS,UAAA,EAAY,OAAO,IAAA;AAC7C,EAAA,MAAM,IAAI,uBAAuB,wDAAwD,CAAA;AAC3F;AAGO,IAAM,cAAN,MAAkB;AAAA,EAEvB,YAA6B,GAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAAA,EAAqB;AAAA,EAArB,GAAA;AAAA,EAD7B,OAAgB,OAA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AK,IAAA,EAAM,CAAA,CAAA,EAAI,MAAM,cAAc,aAAa,CAAA,CAAA;AAAA,MACzD,IAAA,EAAM;AAAA,KACP,CAAA;AACD,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,MAAA,EAAQ,QAAQ,CAAA;AAAA,EAClC;AAAA;AAAA,EAGA,MAAM,uBAAA,CAAwB,MAAA,EAAgB,IAAA,EAAsD;AAClG,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAkC;AAAA,MACrD,MAAA,EAAQ,KAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,MAAM,CAAA,eAAA,CAAA;AAAA,MAC9B,IAAA,EAAM,gBAAgB,IAAI;AAAA,KAC3B,CAAA;AAAA,EACH;AACF","file":"chunk-YVZ6GOLE.js","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport { EmporixNotFoundError, EmporixValidationError } from \"../core/errors\";\nimport type {\n Cart as GeneratedCart,\n CreateCart,\n CreatedCart,\n CartItemRequest,\n UpdateCartItem,\n AddressRequest,\n AppliedDiscount,\n BatchResponse as GeneratedBatchResponse,\n SingleBatchResponse as GeneratedSingleBatchResponse,\n CartValidationResult as GeneratedCartValidationResult,\n CartItemResponse,\n CartItemsBatchUpdateRequest,\n CartItemsBatchUpdateResponse,\n Search,\n CartGetAll,\n UpdateCart,\n DiscountResponse,\n CartDtRestrictions,\n} from \"../generated/cart\";\n\n/** A cart as returned by the Cart service (all generated fields). */\nexport type Cart = GeneratedCart;\n\n/** The cart-create response (`{ cartId, yrn }`, generated). */\nexport type CartCreated = CreatedCart;\n\n/** Generated request bodies (caller sends the exact wire shape). */\nexport type CreateCartInput = CreateCart;\nexport type CartItemInput = CartItemRequest;\nexport type CartItemUpdate = UpdateCartItem;\n\n/** Per-entry result of `addItemsBatch`. `status` is HTTP-style per entry (e.g. 201 = added, 4xx = failed). */\nexport type CartItemBatchEntry = GeneratedSingleBatchResponse;\n/** Response shape of `addItemsBatch` — one entry per input item, matching by `index`. */\nexport type CartItemsBatchResponse = GeneratedBatchResponse;\n\n/** An address payload for cart shipping/billing (generated). */\nexport type CartAddress = AddressRequest;\n\n/** Result of validating a cart's items (generated). */\nexport type CartValidationResult = GeneratedCartValidationResult;\n\n/** A single cart item as returned by the Cart service (generated). */\nexport type CartItem = CartItemResponse;\n\n/** Request body for updating multiple cart items (generated). */\nexport type CartItemsBatchUpdateInput = CartItemsBatchUpdateRequest;\n\n/** Per-entry response for a multi-item update (generated). */\nexport type CartItemsBatchUpdateResult = CartItemsBatchUpdateResponse;\n\n/** Body for searching carts (`POST /carts/search`) — a `q` filter. */\nexport type CartSearchInput = Search;\n\n/** A cart summary as returned by `POST /carts/search`. */\nexport type CartSummary = CartGetAll;\n\n/** Body for a full cart update (`PUT /carts/{id}`). */\nexport type CartUpdateInput = UpdateCart;\n\n/** A discount entry as returned by `GET /carts/{id}/discounts`. */\nexport type CartDiscount = DiscountResponse;\n\n/** Lead-time and non-delivery-time restrictions for a cart (`GET …/dtRestrictions`). */\nexport type CartDeliveryRestrictions = CartDtRestrictions;\n\nfunction requireCartAuth(auth: AuthContext | undefined): AuthContext {\n if (auth && (auth.kind === \"customer\" || auth.kind === \"anonymous\")) return auth;\n throw new EmporixValidationError(\n \"CartService requires an explicit { kind: 'customer' } or { kind: 'anonymous' } AuthContext\",\n );\n}\n\nfunction requireCustomerAuth(auth: AuthContext | undefined): AuthContext {\n if (auth && auth.kind === \"customer\") return auth;\n throw new EmporixValidationError(\"cart.merge requires a { kind: 'customer' } AuthContext\");\n}\n\n/** Cart operations. Every method requires an explicit customer/anonymous context. */\nexport class CartService {\n static readonly channel = \"cart\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/cart/${this.ctx.tenant}/carts`;\n }\n\n /** Creates a cart. */\n async create(\n input: CreateCartInput | undefined,\n auth: AuthContext,\n ): Promise<CartCreated> {\n return this.ctx.http.request<CartCreated>({\n method: \"POST\",\n path: this.base(),\n auth: requireCartAuth(auth),\n body: input ?? {},\n });\n }\n\n /** Fetches a cart by id. */\n async get(cartId: string, auth: AuthContext): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"GET\",\n path: `${this.base()}/${cartId}`,\n auth: requireCartAuth(auth),\n });\n }\n\n /** Returns the current cart for the session, or null if none. */\n /**\n * Get the customer / anonymous cart matching the given criteria. Per Emporix:\n * uniqueness is defined by `siteCode` + `type` + `legalEntityId` +\n * (`customerId` derived from a customer token, or `sessionId` derived from an\n * anonymous token). With `create: true`, Emporix creates a new cart if none\n * matches.\n *\n * Returns `null` on 404 (no cart found and `create` was not set). All other\n * errors are propagated.\n */\n async getCurrent(\n auth: AuthContext,\n opts: { siteCode: string; type?: string; legalEntityId?: string; create?: boolean },\n ): Promise<Cart | null> {\n const query: Record<string, string | number> = { siteCode: opts.siteCode };\n if (opts.type !== undefined) query.type = opts.type;\n if (opts.legalEntityId !== undefined) query.legalEntityId = opts.legalEntityId;\n if (opts.create) query.create = \"true\";\n try {\n return await this.ctx.http.request<Cart>({\n method: \"GET\",\n path: this.base(),\n query,\n auth: requireCartAuth(auth),\n });\n } catch (e) {\n if (e instanceof EmporixNotFoundError) return null;\n throw e;\n }\n }\n\n /** Adds an item. */\n async addItem(\n cartId: string,\n item: CartItemInput,\n auth: AuthContext,\n ): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"POST\",\n path: `${this.base()}/${cartId}/items`,\n auth: requireCartAuth(auth),\n body: item,\n });\n }\n\n /**\n * Adds multiple items in a single request via `POST /carts/{id}/itemsBatch`.\n * Server-side limit is 200 entries per call — callers handling larger sets\n * must chunk. The response carries a per-entry `status` (HTTP-style: 201\n * for added, 4xx/5xx for failed) and `index` matching the input position;\n * partial failures do **not** throw — inspect `status` per entry.\n */\n async addItemsBatch(\n cartId: string,\n items: CartItemInput[],\n auth: AuthContext,\n ): Promise<CartItemsBatchResponse> {\n return this.ctx.http.request<CartItemsBatchResponse>({\n method: \"POST\",\n path: `${this.base()}/${cartId}/itemsBatch`,\n auth: requireCartAuth(auth),\n body: items,\n });\n }\n\n /**\n * Updates an item. By default this is a **full replace** — the server expects\n * the complete item (e.g. `itemYrn` + the `price` row). Pass\n * `{ partial: true }` to send a **partial update** (`?partial=true`), e.g. a\n * quantity-only change with just `{ quantity }`.\n */\n async updateItem(\n cartId: string,\n itemId: string,\n patch: CartItemUpdate,\n auth: AuthContext,\n opts: { partial?: boolean } = {},\n ): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"PUT\",\n path: `${this.base()}/${cartId}/items/${itemId}`,\n auth: requireCartAuth(auth),\n body: patch,\n ...(opts.partial ? { query: { partial: \"true\" } } : {}),\n });\n }\n\n /** Removes an item. */\n async removeItem(cartId: string, itemId: string, auth: AuthContext): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"DELETE\",\n path: `${this.base()}/${cartId}/items/${itemId}`,\n auth: requireCartAuth(auth),\n });\n }\n\n /** Empties the cart. */\n async clear(cartId: string, auth: AuthContext): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"DELETE\",\n path: `${this.base()}/${cartId}/items`,\n auth: requireCartAuth(auth),\n });\n }\n\n /**\n * Applies a coupon by code. Coupon application goes through the cart's\n * `discounts` endpoint (`POST …/discounts` with a coupon-code-only payload) —\n * the live API has no `…/coupons` path. The apply response only carries the\n * applied-discount reference (`{ discountId, discountIndex }`), so the updated\n * cart is re-fetched and returned to preserve the `Cart` contract.\n */\n async applyCoupon(cartId: string, code: string, auth: AuthContext): Promise<Cart> {\n const cartAuth = requireCartAuth(auth);\n await this.ctx.http.request<AppliedDiscount>({\n method: \"POST\",\n path: `${this.base()}/${cartId}/discounts`,\n auth: cartAuth,\n body: { code },\n });\n return this.get(cartId, cartAuth);\n }\n\n /**\n * Removes a coupon by code via `DELETE …/discounts?codes=<code>` — the live\n * API has no `…/coupons/<code>` path. The delete responds 204 No Content, so\n * the updated cart is re-fetched and returned.\n */\n async removeCoupon(cartId: string, code: string, auth: AuthContext): Promise<Cart> {\n const cartAuth = requireCartAuth(auth);\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${cartId}/discounts`,\n query: { codes: code },\n auth: cartAuth,\n });\n return this.get(cartId, cartAuth);\n }\n\n /** Validates the cart's items (pricing/consistency checks). */\n async validate(cartId: string, auth: AuthContext): Promise<CartValidationResult> {\n return this.ctx.http.request<CartValidationResult>({\n method: \"GET\",\n path: `${this.base()}/${cartId}/validate`,\n auth: requireCartAuth(auth),\n });\n }\n\n /** Lists the items in a cart with calculated prices. */\n async listItems(cartId: string, auth: AuthContext): Promise<CartItem[]> {\n return this.ctx.http.request<CartItem[]>({\n method: \"GET\",\n path: `${this.base()}/${cartId}/items`,\n auth: requireCartAuth(auth),\n });\n }\n\n /** Refreshes a cart and its items (re-prices), then returns the updated cart. */\n async refresh(cartId: string, auth: AuthContext): Promise<Cart> {\n const cartAuth = requireCartAuth(auth);\n await this.ctx.http.request<void>({\n method: \"PUT\",\n path: `${this.base()}/${cartId}/refresh`,\n auth: cartAuth,\n });\n return this.get(cartId, cartAuth);\n }\n\n /** Changes the cart's site (re-prices to the new site's currency), then returns the updated cart. */\n async changeSite(cartId: string, siteCode: string, auth: AuthContext): Promise<Cart> {\n const cartAuth = requireCartAuth(auth);\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `${this.base()}/${cartId}/changeSite`,\n auth: cartAuth,\n body: { siteCode },\n });\n return this.get(cartId, cartAuth);\n }\n\n /** Changes the cart's currency (re-prices), then returns the updated cart. */\n async changeCurrency(cartId: string, currency: string, auth: AuthContext): Promise<Cart> {\n const cartAuth = requireCartAuth(auth);\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `${this.base()}/${cartId}/changeCurrency`,\n auth: cartAuth,\n body: { currency },\n });\n return this.get(cartId, cartAuth);\n }\n\n /**\n * Updates multiple cart items in one request (`PUT …/itemsBatch`). Like\n * `addItemsBatch`, the response carries a per-entry `status`; partial failures\n * do not throw — inspect each entry.\n */\n async updateItemsBatch(\n cartId: string,\n items: CartItemsBatchUpdateInput,\n auth: AuthContext,\n ): Promise<CartItemsBatchUpdateResult> {\n return this.ctx.http.request<CartItemsBatchUpdateResult>({\n method: \"PUT\",\n path: `${this.base()}/${cartId}/itemsBatch`,\n auth: requireCartAuth(auth),\n body: items,\n });\n }\n\n /**\n * Sets the cart's shipping address, preserving the billing address.\n *\n * The API has no per-type address endpoint: addresses live in the cart's\n * `addresses` array, written via `PUT /carts/{cartId}`. That array is a **full\n * replace** — sending only one type leaves the other as an empty stub — so\n * this method reads the cart, merges, writes, and re-fetches. Use\n * {@link setAddresses} to set both in a single request.\n */\n async setShippingAddress(\n cartId: string,\n address: CartAddress,\n auth: AuthContext,\n ): Promise<Cart> {\n return this.mergeAddress(cartId, address, \"SHIPPING\", requireCartAuth(auth));\n }\n\n /**\n * Sets the cart's billing address, preserving the shipping address. See\n * {@link setShippingAddress} for why this reads before writing.\n */\n async setBillingAddress(\n cartId: string,\n address: CartAddress,\n auth: AuthContext,\n ): Promise<Cart> {\n return this.mergeAddress(cartId, address, \"BILLING\", requireCartAuth(auth));\n }\n\n /**\n * Sets both cart addresses in one request (`PUT /carts/{cartId}`), skipping\n * the read that {@link setShippingAddress} needs.\n *\n * **This replaces the cart's address set**: a type you omit is cleared, and\n * `{}` clears both. Use it when you already hold both addresses (a checkout\n * form submitting them together); use the per-type setters to change one and\n * keep the other.\n */\n async setAddresses(\n cartId: string,\n addresses: { shipping?: CartAddress; billing?: CartAddress },\n auth: AuthContext,\n ): Promise<Cart> {\n const cartAuth = requireCartAuth(auth);\n const next: CartAddress[] = [];\n if (addresses.shipping) next.push({ ...addresses.shipping, type: \"SHIPPING\" });\n if (addresses.billing) next.push({ ...addresses.billing, type: \"BILLING\" });\n await this.ctx.http.request<void>({\n method: \"PUT\",\n path: `${this.base()}/${cartId}`,\n auth: cartAuth,\n body: { addresses: next },\n });\n return this.get(cartId, cartAuth);\n }\n\n /**\n * Reads the cart, replaces the entry of `type` with `address` (keeping every\n * other type verbatim — resending it unchanged is what stops the server from\n * wiping it), writes, and returns the re-fetched cart.\n */\n private async mergeAddress(\n cartId: string,\n address: CartAddress,\n type: \"SHIPPING\" | \"BILLING\",\n cartAuth: AuthContext,\n ): Promise<Cart> {\n const current = await this.get(cartId, cartAuth);\n const others = (current.addresses ?? []).filter((a) => a.type !== type);\n await this.ctx.http.request<void>({\n method: \"PUT\",\n path: `${this.base()}/${cartId}`,\n auth: cartAuth,\n body: { addresses: [...others, { ...address, type }] },\n });\n return this.get(cartId, cartAuth);\n }\n\n /**\n * Merges one or more anonymous carts into the specified customer cart.\n * Per Emporix: the target cart in the path **must belong to the logged-in\n * customer**, and each id in `anonymousCartIds` must belong to an anonymous\n * customer. Anonymous carts go `CLOSED` on success.\n *\n * Requires a customer `AuthContext`.\n */\n async merge(\n customerCartId: string,\n anonymousCartIds: string[],\n auth: AuthContext,\n ): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"POST\",\n path: `${this.base()}/${customerCartId}/merge`,\n auth: requireCustomerAuth(auth),\n body: { carts: anonymousCartIds },\n });\n }\n\n /**\n * Searches carts tenant-wide (`POST /carts/search`, body `{ q }`). This is a\n * backend/admin operation — a customer token cannot scan other customers'\n * carts, so `auth` is forwarded unguarded (pass a service token for admin\n * use). The server enforces scope (403 on insufficient).\n */\n async search(\n query: CartSearchInput,\n auth: AuthContext,\n params: { pageNumber?: number; pageSize?: number; sort?: string; fields?: string } = {},\n ): Promise<CartSummary[]> {\n return this.ctx.http.request<CartSummary[]>({\n method: \"POST\",\n path: `${this.base()}/search`,\n query: {\n ...(params.pageNumber === undefined ? {} : { pageNumber: params.pageNumber }),\n ...(params.pageSize === undefined ? {} : { pageSize: params.pageSize }),\n ...(params.sort === undefined ? {} : { sort: params.sort }),\n ...(params.fields === undefined ? {} : { fields: params.fields }),\n },\n body: query,\n idempotent: true, // pure read over POST — safe to replay on 5xx/429\n auth,\n });\n }\n\n /**\n * Deletes a cart (`DELETE /carts/{cartId}`). Backend/admin or owner\n * operation — `auth` is forwarded unguarded (service or customer). Returns\n * nothing; the cart no longer exists.\n */\n async delete(cartId: string, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${cartId}`,\n auth,\n });\n }\n\n /**\n * Full-updates a cart (`PUT /carts/{cartId}`, body `UpdateCart`). Backend or\n * owner operation — `auth` is forwarded unguarded. The endpoint returns 204,\n * so the cart is re-fetched with the same `auth` (via a direct GET, not\n * `get()`, so a service token is not rejected by the cart-auth guard) and\n * returned.\n */\n async update(cartId: string, input: CartUpdateInput, auth: AuthContext): Promise<Cart> {\n await this.ctx.http.request<void>({\n method: \"PUT\",\n path: `${this.base()}/${cartId}`,\n auth,\n body: input,\n });\n return this.ctx.http.request<Cart>({\n method: \"GET\",\n path: `${this.base()}/${cartId}`,\n auth,\n });\n }\n\n /** Fetches a single cart item's details (`GET /carts/{cartId}/items/{itemId}`). */\n async getItem(cartId: string, itemId: string, auth: AuthContext): Promise<CartItem> {\n return this.ctx.http.request<CartItem>({\n method: \"GET\",\n path: `${this.base()}/${cartId}/items/${itemId}`,\n auth: requireCartAuth(auth),\n });\n }\n\n /** Lists the discounts applied to a cart (`GET /carts/{cartId}/discounts`). */\n async listDiscounts(cartId: string, auth: AuthContext): Promise<CartDiscount[]> {\n return this.ctx.http.request<CartDiscount[]>({\n method: \"GET\",\n path: `${this.base()}/${cartId}/discounts`,\n auth: requireCartAuth(auth),\n });\n }\n\n /**\n * Removes all discounts from a cart (`DELETE /carts/{cartId}/discounts` with\n * no `codes` filter), then re-fetches and returns the updated cart. Use\n * `removeCoupon(code)` to remove a specific coupon by code.\n */\n async removeAllDiscounts(cartId: string, auth: AuthContext): Promise<Cart> {\n const cartAuth = requireCartAuth(auth);\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${cartId}/discounts`,\n auth: cartAuth,\n });\n return this.get(cartId, cartAuth);\n }\n\n /**\n * Removes a single discount by its index (`DELETE\n * /carts/{cartId}/discounts/{discountIndex}`), then re-fetches and returns\n * the updated cart.\n */\n async removeDiscountByIndex(cartId: string, discountIndex: string, auth: AuthContext): Promise<Cart> {\n const cartAuth = requireCartAuth(auth);\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${cartId}/discounts/${discountIndex}`,\n auth: cartAuth,\n });\n return this.get(cartId, cartAuth);\n }\n\n /** Retrieves the cart's lead-time and non-delivery-time restrictions (`GET /carts/{cartId}/dtRestrictions`). */\n async getDeliveryRestrictions(cartId: string, auth: AuthContext): Promise<CartDeliveryRestrictions> {\n return this.ctx.http.request<CartDeliveryRestrictions>({\n method: \"GET\",\n path: `${this.base()}/${cartId}/dtRestrictions`,\n auth: requireCartAuth(auth),\n });\n }\n}\n"]}