@viu/emporix-sdk 2.21.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 (114) hide show
  1. package/CHANGELOG.md +146 -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 +215 -9
  8. package/dist/cart.cjs.map +1 -1
  9. package/dist/cart.d.cts +281 -3
  10. package/dist/cart.d.ts +281 -3
  11. package/dist/cart.js +1 -1
  12. package/dist/category.cjs +220 -2
  13. package/dist/category.cjs.map +1 -1
  14. package/dist/category.d.cts +408 -1
  15. package/dist/category.d.ts +408 -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-PYLWZZC4.js → chunk-6PJFOX3A.js} +126 -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-HBEQEIT6.js → chunk-PRN3T6TY.js} +63 -3
  28. package/dist/chunk-PRN3T6TY.js.map +1 -0
  29. package/dist/{chunk-44F52KRE.js → chunk-QQMLN76U.js} +27 -2
  30. package/dist/chunk-QQMLN76U.js.map +1 -0
  31. package/dist/chunk-UNW6SFSB.js +363 -0
  32. package/dist/chunk-UNW6SFSB.js.map +1 -0
  33. package/dist/chunk-V3275BA7.js +181 -0
  34. package/dist/chunk-V3275BA7.js.map +1 -0
  35. package/dist/chunk-W2KBVWJ2.js +323 -0
  36. package/dist/chunk-W2KBVWJ2.js.map +1 -0
  37. package/dist/chunk-YVZ6GOLE.js +399 -0
  38. package/dist/chunk-YVZ6GOLE.js.map +1 -0
  39. package/dist/chunk-ZOFGDNSX.js +305 -0
  40. package/dist/chunk-ZOFGDNSX.js.map +1 -0
  41. package/dist/companies.cjs +25 -0
  42. package/dist/companies.cjs.map +1 -1
  43. package/dist/companies.d.cts +14 -0
  44. package/dist/companies.d.ts +14 -0
  45. package/dist/companies.js +1 -1
  46. package/dist/contacts.cjs +8 -0
  47. package/dist/contacts.cjs.map +1 -1
  48. package/dist/contacts.d.cts +2 -0
  49. package/dist/contacts.d.ts +2 -0
  50. package/dist/contacts.js +1 -1
  51. package/dist/customer-groups-BxSNFHq1.d.cts +706 -0
  52. package/dist/customer-groups-GlzWhDsi.d.ts +706 -0
  53. package/dist/customer-groups.cjs +200 -17
  54. package/dist/customer-groups.cjs.map +1 -1
  55. package/dist/customer-groups.d.cts +2 -110
  56. package/dist/customer-groups.d.ts +2 -110
  57. package/dist/customer-groups.js +1 -1
  58. package/dist/customer.cjs +61 -1
  59. package/dist/customer.cjs.map +1 -1
  60. package/dist/customer.d.cts +48 -1
  61. package/dist/customer.d.ts +48 -1
  62. package/dist/customer.js +1 -1
  63. package/dist/index.cjs +2566 -554
  64. package/dist/index.cjs.map +1 -1
  65. package/dist/index.d.cts +455 -12
  66. package/dist/index.d.ts +455 -12
  67. package/dist/index.js +687 -342
  68. package/dist/index.js.map +1 -1
  69. package/dist/orders.cjs +160 -2
  70. package/dist/orders.cjs.map +1 -1
  71. package/dist/orders.d.cts +221 -1
  72. package/dist/orders.d.ts +221 -1
  73. package/dist/orders.js +1 -1
  74. package/dist/payment.cjs +124 -0
  75. package/dist/payment.cjs.map +1 -1
  76. package/dist/payment.d.cts +335 -1
  77. package/dist/payment.d.ts +335 -1
  78. package/dist/payment.js +1 -1
  79. package/dist/price.cjs +197 -0
  80. package/dist/price.cjs.map +1 -1
  81. package/dist/price.d.cts +577 -1
  82. package/dist/price.d.ts +577 -1
  83. package/dist/price.js +1 -1
  84. package/dist/product.cjs +190 -0
  85. package/dist/product.cjs.map +1 -1
  86. package/dist/product.d.cts +503 -1
  87. package/dist/product.d.ts +503 -1
  88. package/dist/product.js +1 -1
  89. package/dist/segment.cjs +179 -0
  90. package/dist/segment.cjs.map +1 -1
  91. package/dist/segment.d.cts +181 -1
  92. package/dist/segment.d.ts +181 -1
  93. package/dist/segment.js +1 -1
  94. package/package.json +1 -1
  95. package/dist/chunk-36T4YPQJ.js +0 -106
  96. package/dist/chunk-36T4YPQJ.js.map +0 -1
  97. package/dist/chunk-3BTPX7IJ.js +0 -41
  98. package/dist/chunk-3BTPX7IJ.js.map +0 -1
  99. package/dist/chunk-44F52KRE.js.map +0 -1
  100. package/dist/chunk-A3LYJUD4.js +0 -108
  101. package/dist/chunk-A3LYJUD4.js.map +0 -1
  102. package/dist/chunk-FZMP5NQZ.js +0 -173
  103. package/dist/chunk-FZMP5NQZ.js.map +0 -1
  104. package/dist/chunk-HBEQEIT6.js.map +0 -1
  105. package/dist/chunk-HD5RBCM6.js.map +0 -1
  106. package/dist/chunk-HUEMYP2L.js +0 -193
  107. package/dist/chunk-HUEMYP2L.js.map +0 -1
  108. package/dist/chunk-IVCCGJN5.js +0 -63
  109. package/dist/chunk-IVCCGJN5.js.map +0 -1
  110. package/dist/chunk-NE7MIZPR.js +0 -144
  111. package/dist/chunk-NE7MIZPR.js.map +0 -1
  112. package/dist/chunk-PYLWZZC4.js.map +0 -1
  113. package/dist/chunk-ZNLHLFQM.js +0 -160
  114. package/dist/chunk-ZNLHLFQM.js.map +0 -1
package/dist/segment.d.ts CHANGED
@@ -40,6 +40,21 @@ type CommonSegment = {
40
40
  } & {
41
41
  metadata?: MetadataCreate;
42
42
  };
43
+ type SegmentCreation = {
44
+ /**
45
+ * Unique identifier of the customer segment. It will be auto-generated if not provided.
46
+ */
47
+ id?: string;
48
+ } & CommonSegment;
49
+ type SegmentsSearch = {
50
+ /**
51
+ * A standard query parameter is used to search for specific values.
52
+ *
53
+ * See: [Standard practises - Query parameter](https://developer.emporix.io/api-references/standard-practices/q-param/)
54
+ *
55
+ */
56
+ q?: string;
57
+ };
43
58
  type SegmentUpdate = CommonSegment & {
44
59
  metadata?: MetadataUpdate;
45
60
  };
@@ -52,6 +67,46 @@ type SegmentUpdateBulk = {
52
67
  type SegmentResponse = SegmentUpdateBulk & {
53
68
  metadata?: MetadataResponse;
54
69
  };
70
+ type MatchItem = {
71
+ /**
72
+ * Id of the product.
73
+ */
74
+ id?: string;
75
+ };
76
+ type Match = {
77
+ items: Array<MatchItem>;
78
+ segmentIds: Array<string>;
79
+ site: string;
80
+ };
81
+ type CustomerAssignmentUpsert = {
82
+ /**
83
+ * A key-value map of additional attributes.
84
+ */
85
+ mixins?: {
86
+ [key: string]: unknown;
87
+ };
88
+ metadata?: MetadataUpdate;
89
+ };
90
+ type CustomerAssignmentUpsertBulk = CustomerAssignmentUpsert & {
91
+ /**
92
+ * Unique identifier of an existing customer.
93
+ */
94
+ customerId?: string;
95
+ /**
96
+ * Unique identifier of an existing legal entity. It should be omitted for B2C.
97
+ */
98
+ legalEntityId?: string;
99
+ };
100
+ type CustomerAssignmentB2cResponse = {
101
+ customer?: Customer;
102
+ } & {
103
+ assignmentType?: 'MANUAL' | 'AUTOMATIC';
104
+ } & CustomerAssignmentUpsert & {
105
+ metadata?: MetadataResponse;
106
+ };
107
+ type CustomerAssignmentResponse = {
108
+ legalEntity?: LegalEntity;
109
+ } & CustomerAssignmentB2cResponse;
55
110
  type ItemAssignmentUpsert = {
56
111
  /**
57
112
  * A key-value map of additional attributes.
@@ -62,6 +117,12 @@ type ItemAssignmentUpsert = {
62
117
  } & {
63
118
  metadata?: MetadataUpdate;
64
119
  };
120
+ type ItemAssignmentUpsertBulk = ItemAssignmentUpsert & {
121
+ /**
122
+ * Unique identifier of an existing product/category (itemId).
123
+ */
124
+ id: string;
125
+ };
65
126
  type ItemAssignmentResponse = {
66
127
  /**
67
128
  * Unique identifier of the customer segment.
@@ -168,12 +229,91 @@ type MetadataResponse = {
168
229
  */
169
230
  modifiedAt?: string;
170
231
  } & MetadataUpdate;
232
+ type BulkAssignmentResponse = {
233
+ /**
234
+ * Index of the processed item, matching the item position in request body.
235
+ *
236
+ */
237
+ index?: number;
238
+ /**
239
+ * HTTP Status Code.
240
+ */
241
+ code?: number;
242
+ /**
243
+ * HTTP Status description.
244
+ */
245
+ status?: string;
246
+ /**
247
+ * Error message.
248
+ */
249
+ message?: string;
250
+ };
251
+ type BulkResponse = {
252
+ /**
253
+ * Item's unique identifier.
254
+ */
255
+ id?: string;
256
+ } & BulkAssignmentResponse;
257
+ type Customer = {
258
+ /**
259
+ * Unique identifier of an existing customer.
260
+ */
261
+ id?: string;
262
+ /**
263
+ * Customer's first name.
264
+ */
265
+ firstName?: string;
266
+ /**
267
+ * Customer's last name.
268
+ */
269
+ lastName?: string;
270
+ /**
271
+ * Customer's e-mail address.
272
+ */
273
+ email?: string;
274
+ };
275
+ type LegalEntity = {
276
+ /**
277
+ * Unique identifier of an existing legal entity.
278
+ */
279
+ id?: string;
280
+ /**
281
+ * Name of a legal entity.
282
+ */
283
+ name?: string;
284
+ };
171
285
 
172
286
  /** Generated segment types (read shapes — storefront `segment_read_own`). */
173
287
  type Segment = SegmentResponse;
174
288
  type SegmentItem = ItemAssignmentResponse;
175
289
  type SegmentCategoryTree = CategoryTreeResponse;
176
290
  type SegmentCategoryTreeNode = CategoryTreeResponse[number];
291
+ /** Create body for a segment (generated). */
292
+ type SegmentInput = SegmentCreation;
293
+ /** Full-replace (PUT) body for a segment (generated). */
294
+ type SegmentUpdateInput = SegmentUpdate;
295
+ /** Partial (PATCH) body for a segment. */
296
+ type SegmentPatchInput = Partial<SegmentUpdate>;
297
+ /** Search body for segments (generated). */
298
+ type SegmentSearchQuery = SegmentsSearch;
299
+ /** Body for a segment match check (generated). */
300
+ type SegmentMatchInput = Match;
301
+ /** One entry of a segment bulk request (generated). */
302
+ type SegmentBulkItem = SegmentUpdateBulk;
303
+ /** Per-entry result of a segment bulk operation (generated). */
304
+ type SegmentBulkResult = BulkResponse;
305
+ /** Customer→segment assignment body (generated). */
306
+ type SegmentCustomerInput = CustomerAssignmentUpsert;
307
+ /** One entry of a customer-assignment bulk request (generated). */
308
+ type SegmentCustomerBulkInput = CustomerAssignmentUpsertBulk;
309
+ /** A customer→segment assignment (read). */
310
+ type SegmentCustomer = CustomerAssignmentResponse;
311
+ /** Item→segment assignment body (generated). */
312
+ type SegmentItemInput = ItemAssignmentUpsert;
313
+ /** One entry of an item-assignment bulk request (generated). */
314
+ type SegmentItemBulkInput = ItemAssignmentUpsertBulk;
315
+ /** Per-entry result of an assignment bulk operation (generated). */
316
+ type SegmentAssignmentBulkResult = BulkAssignmentResponse;
177
317
  /** Cross-service hydrate dependencies, injected from `EmporixClient`. */
178
318
  interface SegmentServiceDeps {
179
319
  products: ProductService;
@@ -239,6 +379,46 @@ declare class SegmentService {
239
379
  * `hasNextPage` semantic as `listMyProducts`.
240
380
  */
241
381
  listMyCategories(query?: Parameters<SegmentService["listItems"]>[0], auth?: AuthContext): Promise<PaginatedItems<Awaited<ReturnType<CategoryService["get"]>>>>;
382
+ /** Creates a segment. Default auth: service. */
383
+ create(input: SegmentInput, authCtx?: AuthContext): Promise<Segment>;
384
+ /** Searches segments (POST body). Default auth: service. */
385
+ search(query: SegmentSearchQuery, authCtx?: AuthContext): Promise<Segment[]>;
386
+ /** Full-replaces a segment (PUT). Default auth: service. */
387
+ update(segmentId: string, input: SegmentUpdateInput, authCtx?: AuthContext): Promise<Segment>;
388
+ /** Partially updates a segment (PATCH). Default auth: service. */
389
+ patch(segmentId: string, input: SegmentPatchInput, authCtx?: AuthContext): Promise<Segment>;
390
+ /** Deletes a segment. Default auth: service. */
391
+ delete(segmentId: string, authCtx?: AuthContext): Promise<void>;
392
+ /** Checks which segments the given items/customers match. Default auth: service. */
393
+ match(input: SegmentMatchInput, authCtx?: AuthContext): Promise<Segment[]>;
394
+ /** Creates multiple segments. Default auth: service. */
395
+ bulkCreate(inputs: SegmentBulkItem[], authCtx?: AuthContext): Promise<SegmentBulkResult[]>;
396
+ /** Upserts multiple segments (PUT). Default auth: service. */
397
+ bulkUpdate(inputs: SegmentBulkItem[], authCtx?: AuthContext): Promise<SegmentBulkResult[]>;
398
+ /** Deletes multiple segments (DELETE with a body of ids). Default auth: service. */
399
+ bulkDelete(body: Record<string, unknown>, authCtx?: AuthContext): Promise<SegmentBulkResult[]>;
400
+ /** Customer→segment assignments (`segment_manage`). Default auth: service. */
401
+ readonly customers: {
402
+ list: (segmentId: string, query?: Record<string, string | number>, authCtx?: AuthContext) => Promise<SegmentCustomer[]>;
403
+ search: (segmentId: string, query: Record<string, unknown>, authCtx?: AuthContext) => Promise<SegmentCustomer[]>;
404
+ get: (segmentId: string, customerId: string, authCtx?: AuthContext) => Promise<SegmentCustomer>;
405
+ assign: (segmentId: string, customerId: string, input: SegmentCustomerInput, authCtx?: AuthContext) => Promise<SegmentCustomer>;
406
+ remove: (segmentId: string, customerId: string, authCtx?: AuthContext) => Promise<void>;
407
+ getForEntity: (segmentId: string, customerId: string, legalEntityId: string, authCtx?: AuthContext) => Promise<SegmentCustomer>;
408
+ assignForEntity: (segmentId: string, customerId: string, legalEntityId: string, input: SegmentCustomerInput, authCtx?: AuthContext) => Promise<SegmentCustomer>;
409
+ removeForEntity: (segmentId: string, customerId: string, legalEntityId: string, authCtx?: AuthContext) => Promise<void>;
410
+ bulkAssign: (segmentId: string, inputs: SegmentCustomerBulkInput[], authCtx?: AuthContext) => Promise<SegmentAssignmentBulkResult[]>;
411
+ bulkRemove: (segmentId: string, body: Record<string, unknown>, authCtx?: AuthContext) => Promise<SegmentAssignmentBulkResult[]>;
412
+ };
413
+ /** Item→segment assignments (`type` = PRODUCT | CATEGORY). Default auth: service. */
414
+ readonly items: {
415
+ search: (segmentId: string, query: Record<string, unknown>, authCtx?: AuthContext) => Promise<SegmentItem[]>;
416
+ get: (segmentId: string, type: string, itemId: string, authCtx?: AuthContext) => Promise<SegmentItem>;
417
+ assign: (segmentId: string, type: string, itemId: string, input: SegmentItemInput, authCtx?: AuthContext) => Promise<SegmentItem>;
418
+ remove: (segmentId: string, type: string, itemId: string, authCtx?: AuthContext) => Promise<void>;
419
+ bulkAssign: (segmentId: string, type: string, inputs: SegmentItemBulkInput[], authCtx?: AuthContext) => Promise<SegmentAssignmentBulkResult[]>;
420
+ bulkRemove: (segmentId: string, type: string, body: Record<string, unknown>, authCtx?: AuthContext) => Promise<SegmentAssignmentBulkResult[]>;
421
+ };
242
422
  }
243
423
 
244
- export { type Segment, type SegmentCategoryTree, type SegmentCategoryTreeNode, type SegmentItem, SegmentService, type SegmentServiceDeps };
424
+ export { type Segment, type SegmentAssignmentBulkResult, type SegmentBulkItem, type SegmentBulkResult, type SegmentCategoryTree, type SegmentCategoryTreeNode, type SegmentCustomer, type SegmentCustomerBulkInput, type SegmentCustomerInput, type SegmentInput, type SegmentItem, type SegmentItemBulkInput, type SegmentItemInput, type SegmentMatchInput, type SegmentPatchInput, type SegmentSearchQuery, SegmentService, type SegmentServiceDeps, type SegmentUpdateInput };
package/dist/segment.js CHANGED
@@ -1,4 +1,4 @@
1
- export { SegmentService } from './chunk-NE7MIZPR.js';
1
+ export { SegmentService } from './chunk-W2KBVWJ2.js';
2
2
  import './chunk-3BDDYX3V.js';
3
3
  import './chunk-UWGGF4MC.js';
4
4
  //# sourceMappingURL=segment.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viu/emporix-sdk",
3
- "version": "2.21.0",
3
+ "version": "2.23.0",
4
4
  "description": "TypeScript SDK for the Emporix Commerce Engine",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -1,106 +0,0 @@
1
- import { resolveQuery } from './chunk-S5HEIQDK.js';
2
-
3
- // src/services/orders.ts
4
- function setIfDefined(q, key, value) {
5
- if (value !== void 0 && value !== "") {
6
- q[key] = value;
7
- }
8
- }
9
- var OrdersService = class {
10
- constructor(ctx) {
11
- this.ctx = ctx;
12
- }
13
- ctx;
14
- static channel = "orders";
15
- base() {
16
- return `/order-v2/${this.ctx.tenant}/orders`;
17
- }
18
- saasHeader(saasToken) {
19
- return saasToken ? { "saas-token": saasToken } : void 0;
20
- }
21
- /** Lists the calling customer's orders. */
22
- async listMine(auth, opts = {}) {
23
- const pageNumber = opts.pageNumber ?? 1;
24
- const pageSize = opts.pageSize ?? 50;
25
- const query = {
26
- pageNumber,
27
- pageSize
28
- };
29
- setIfDefined(query, "status", opts.status);
30
- setIfDefined(query, "legalEntityId", opts.legalEntityId);
31
- setIfDefined(query, "siteCode", opts.siteCode);
32
- if (opts.q !== void 0) {
33
- setIfDefined(query, "q", resolveQuery(opts.q, { compoundLogicalQuery: false }));
34
- }
35
- const headers = this.saasHeader(opts.saasToken);
36
- const items = await this.ctx.http.request({
37
- method: "GET",
38
- path: this.base(),
39
- query,
40
- auth,
41
- ...headers ? { headers } : {}
42
- });
43
- return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };
44
- }
45
- /** Fetches one of the calling customer's orders by id. */
46
- async get(orderId, auth, opts = {}) {
47
- const headers = this.saasHeader(opts.saasToken);
48
- return this.ctx.http.request({
49
- method: "GET",
50
- path: `${this.base()}/${orderId}`,
51
- auth,
52
- ...headers ? { headers } : {}
53
- });
54
- }
55
- /** Transitions an order to a new status. Server enforces legal transitions. */
56
- async transition(orderId, status, auth, opts = {}) {
57
- const body = { status };
58
- if (opts.comment !== void 0) body.comment = opts.comment;
59
- const headers = this.saasHeader(opts.saasToken);
60
- await this.ctx.http.request({
61
- method: "POST",
62
- path: `${this.base()}/${orderId}/transitions`,
63
- auth,
64
- body,
65
- ...headers ? { headers } : {}
66
- });
67
- }
68
- /** Convenience: transitions to `DECLINED` (customer cancel). */
69
- async cancel(orderId, auth, opts = {}) {
70
- await this.transition(orderId, "DECLINED", auth, opts);
71
- }
72
- };
73
- var SalesOrdersService = class {
74
- constructor(ctx) {
75
- this.ctx = ctx;
76
- }
77
- ctx;
78
- static channel = "sales-orders";
79
- base() {
80
- return `/order-v2/${this.ctx.tenant}/salesorders`;
81
- }
82
- /** Fetches a single sales-order by id. */
83
- async get(orderId, auth) {
84
- return this.ctx.http.request({
85
- method: "GET",
86
- path: `${this.base()}/${orderId}`,
87
- auth
88
- });
89
- }
90
- /** Patches an existing order (status, mixins, customAttributes, metadata). */
91
- async update(orderId, patch, auth, opts = {}) {
92
- const query = {};
93
- if (opts.recalculate === false) query.recalculate = "false";
94
- return this.ctx.http.request({
95
- method: "PATCH",
96
- path: `${this.base()}/${orderId}`,
97
- auth,
98
- ...Object.keys(query).length > 0 ? { query } : {},
99
- body: patch
100
- });
101
- }
102
- };
103
-
104
- export { OrdersService, SalesOrdersService };
105
- //# sourceMappingURL=chunk-36T4YPQJ.js.map
106
- //# sourceMappingURL=chunk-36T4YPQJ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/services/orders.ts"],"names":[],"mappings":";;;AAyCA,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;AASO,IAAM,gBAAN,MAAoB;AAAA,EAEzB,YAA6B,GAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAAA,EAAqB;AAAA,EAArB,GAAA;AAAA,EAD7B,OAAgB,OAAA,GAAU,QAAA;AAAA,EAGlB,IAAA,GAAe;AACrB,IAAA,OAAO,CAAA,UAAA,EAAa,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,OAAA,CAAA;AAAA,EACrC;AAAA,EAEQ,WAAW,SAAA,EAAmE;AACpF,IAAA,OAAO,SAAA,GAAY,EAAE,YAAA,EAAc,SAAA,EAAU,GAAI,MAAA;AAAA,EACnD;AAAA;A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;AAAA,EAGlB,IAAA,GAAe;AACrB,IAAA,OAAO,CAAA,UAAA,EAAa,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,YAAA,CAAA;AAAA,EACrC;AAAA;AAAA,EAGA,MAAM,GAAA,CAAI,OAAA,EAAiB,IAAA,EAAmC;AAC5D,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAe;AAAA,MAClC,MAAA,EAAQ,KAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,OAAO,CAAA,CAAA;AAAA,MAC/B;AAAA,KACD,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,MAAA,CACJ,OAAA,EACA,OACA,IAAA,EACA,IAAA,GAAgC,EAAC,EACjB;AAChB,IAAA,MAAM,QAAgC,EAAC;AACvC,IAAA,IAAI,IAAA,CAAK,WAAA,KAAgB,KAAA,EAAO,KAAA,CAAM,WAAA,GAAc,OAAA;AACpD,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAe;AAAA,MAClC,MAAA,EAAQ,OAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,OAAO,CAAA,CAAA;AAAA,MAC/B,IAAA;AAAA,MACA,GAAI,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA,CAAE,SAAS,CAAA,GAAI,EAAE,KAAA,EAAM,GAAI,EAAC;AAAA,MACjD,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACF","file":"chunk-36T4YPQJ.js","sourcesContent":["import type { ClientContext, PaginatedItems } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport { resolveQuery, type QueryFor } from \"../core/query\";\nimport type { Order, OrderStatus, OrderUpdateDto } from \"../generated/order-v2\";\n\n/**\n * Salesorder PATCH body. The generated `orderUpdateDto` models a full order\n * (it requires `entries`/`customer`), but `PATCH /salesorders/{id}` accepts a\n * subset — so the SDK exposes a partial of it.\n */\nexport type SalesOrderPatch = Partial<OrderUpdateDto>;\n\n/** Optional fields supported by the order-v2 list endpoint. */\nexport interface ListMyOrdersOptions {\n pageNumber?: number;\n pageSize?: number;\n status?: OrderStatus;\n legalEntityId?: string;\n siteCode?: string;\n saasToken?: string;\n /** A `q` filter — raw DSL string or a built filter (e.g. mixinQuery for entity \"ORDER\"). */\n q?: QueryFor<\"ORDER\">;\n}\n\n/** Options for single-order reads (saas-token only). */\nexport interface GetOrderOptions {\n saasToken?: string;\n}\n\n/** Options for status transitions. */\nexport interface OrderTransitionOptions {\n saasToken?: string;\n comment?: string;\n}\n\n/** Options for `salesOrders.update`. */\nexport interface UpdateSalesOrderOptions {\n /** Forwarded as `?recalculate=`. Omit to use the server default (true). */\n recalculate?: boolean;\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/**\n * Storefront-customer access to Order-v2's customer endpoints.\n *\n * `listMine`/`get` require `order.order_read_own`; transitions require\n * `order.order_manage_own`. All methods accept an optional `saasToken` that\n * is passed as the `saas-token` header (mirrors `checkout.placeOrder`).\n */\nexport class OrdersService {\n static readonly channel = \"orders\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/order-v2/${this.ctx.tenant}/orders`;\n }\n\n private saasHeader(saasToken: string | undefined): Record<string, string> | undefined {\n return saasToken ? { \"saas-token\": saasToken } : undefined;\n }\n\n /** Lists the calling customer's orders. */\n async listMine(\n auth: AuthContext,\n opts: ListMyOrdersOptions = {},\n ): Promise<PaginatedItems<Order>> {\n const pageNumber = opts.pageNumber ?? 1;\n const pageSize = opts.pageSize ?? 50;\n const query: Record<string, string | number | undefined> = {\n pageNumber,\n pageSize,\n };\n setIfDefined(query, \"status\", opts.status);\n setIfDefined(query, \"legalEntityId\", opts.legalEntityId);\n setIfDefined(query, \"siteCode\", opts.siteCode);\n if (opts.q !== undefined) {\n setIfDefined(query, \"q\", resolveQuery(opts.q, { compoundLogicalQuery: false }));\n }\n const headers = this.saasHeader(opts.saasToken);\n // order-v2 returns a bare JSON array (the total count lives in the\n // X-Total-Count header), not a {items,...} envelope — so wrap it into the\n // shared PaginatedItems shape like every other paginated service.\n // hasNextPage is inferred from the page being full.\n const items = await this.ctx.http.request<Order[]>({\n method: \"GET\",\n path: this.base(),\n query,\n auth,\n ...(headers ? { headers } : {}),\n });\n return { items, pageNumber, pageSize, hasNextPage: items.length === pageSize };\n }\n\n /** Fetches one of the calling customer's orders by id. */\n async get(\n orderId: string,\n auth: AuthContext,\n opts: GetOrderOptions = {},\n ): Promise<Order> {\n const headers = this.saasHeader(opts.saasToken);\n return this.ctx.http.request<Order>({\n method: \"GET\",\n path: `${this.base()}/${orderId}`,\n auth,\n ...(headers ? { headers } : {}),\n });\n }\n\n /** Transitions an order to a new status. Server enforces legal transitions. */\n async transition(\n orderId: string,\n status: OrderStatus,\n auth: AuthContext,\n opts: OrderTransitionOptions = {},\n ): Promise<void> {\n const body: { status: OrderStatus; comment?: string } = { status };\n if (opts.comment !== undefined) body.comment = opts.comment;\n const headers = this.saasHeader(opts.saasToken);\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `${this.base()}/${orderId}/transitions`,\n auth,\n body,\n ...(headers ? { headers } : {}),\n });\n }\n\n /** Convenience: transitions to `DECLINED` (customer cancel). */\n async cancel(\n orderId: string,\n auth: AuthContext,\n opts: { saasToken?: string } = {},\n ): Promise<void> {\n await this.transition(orderId, \"DECLINED\", auth, opts);\n }\n}\n\n/**\n * Backend / service-account access to the merchant-facing\n * `/salesorders/{id}` resource. Requires `order.order_read` (read) /\n * `order.order_manage` (update) scopes on a service token.\n *\n * The full admin list + filter surface is deferred to a follow-up\n * sub-spec. This service ships only single-resource read + patch — the\n * common backend use case (e.g. mixin updates after fulfilment).\n */\nexport class SalesOrdersService {\n static readonly channel = \"sales-orders\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/order-v2/${this.ctx.tenant}/salesorders`;\n }\n\n /** Fetches a single sales-order by id. */\n async get(orderId: string, auth: AuthContext): Promise<Order> {\n return this.ctx.http.request<Order>({\n method: \"GET\",\n path: `${this.base()}/${orderId}`,\n auth,\n });\n }\n\n /** Patches an existing order (status, mixins, customAttributes, metadata). */\n async update(\n orderId: string,\n patch: SalesOrderPatch,\n auth: AuthContext,\n opts: UpdateSalesOrderOptions = {},\n ): Promise<Order> {\n const query: Record<string, string> = {};\n if (opts.recalculate === false) query.recalculate = \"false\";\n return this.ctx.http.request<Order>({\n method: \"PATCH\",\n path: `${this.base()}/${orderId}`,\n auth,\n ...(Object.keys(query).length > 0 ? { query } : {}),\n body: patch,\n });\n }\n}\n"]}
@@ -1,41 +0,0 @@
1
- // src/services/customer-groups.ts
2
- var CustomerGroupsService = class {
3
- constructor(ctx) {
4
- this.ctx = ctx;
5
- }
6
- ctx;
7
- static channel = "iam";
8
- base() {
9
- return `/iam/${this.ctx.tenant}/groups`;
10
- }
11
- /** Lists customer groups belonging to one legal entity. */
12
- async listForCompany(legalEntityId, auth) {
13
- return this.ctx.http.request({
14
- method: "GET",
15
- path: this.base(),
16
- query: { "b2b.legalEntityId": legalEntityId },
17
- auth
18
- });
19
- }
20
- /** Adds a user (customer or employee) to a group. */
21
- async addMember(groupId, member, auth) {
22
- return this.ctx.http.request({
23
- method: "POST",
24
- path: `${this.base()}/${groupId}/users`,
25
- auth,
26
- body: member
27
- });
28
- }
29
- /** Removes a user from a group. */
30
- async removeMember(groupId, userId, auth) {
31
- await this.ctx.http.request({
32
- method: "DELETE",
33
- path: `${this.base()}/${groupId}/users/${userId}`,
34
- auth
35
- });
36
- }
37
- };
38
-
39
- export { CustomerGroupsService };
40
- //# sourceMappingURL=chunk-3BTPX7IJ.js.map
41
- //# sourceMappingURL=chunk-3BTPX7IJ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/services/customer-groups.ts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CAAA;AAAA,EACH;AACF","file":"chunk-3BTPX7IJ.js","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type {\n GroupsQueryDocument,\n AssignmentCreateRequest,\n} from \"../generated/iam\";\n\n/**\n * Access to IAM customer groups for a legal entity.\n *\n * `listForCompany` requires `iam.group_read`; the member mutations\n * (`addMember`/`removeMember`) require `iam.group_manage` — typically only\n * granted to Admin-group customers; a 403 surfaces as\n * `EmporixInsufficientScopeError`.\n */\nexport class CustomerGroupsService {\n static readonly channel = \"iam\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/iam/${this.ctx.tenant}/groups`;\n }\n\n /** Lists customer groups belonging to one legal entity. */\n async listForCompany(legalEntityId: string, auth: AuthContext): Promise<GroupsQueryDocument[]> {\n return this.ctx.http.request<GroupsQueryDocument[]>({\n method: \"GET\",\n path: this.base(),\n query: { \"b2b.legalEntityId\": legalEntityId },\n auth,\n });\n }\n\n /** Adds a user (customer or employee) to a group. */\n async addMember(\n groupId: string,\n member: AssignmentCreateRequest,\n auth: AuthContext,\n ): Promise<{ id: string }> {\n return this.ctx.http.request<{ id: string }>({\n method: \"POST\",\n path: `${this.base()}/${groupId}/users`,\n auth,\n body: member,\n });\n }\n\n /** Removes a user from a group. */\n async removeMember(groupId: string, userId: string, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${groupId}/users/${userId}`,\n auth,\n });\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/services/companies.ts"],"names":[],"mappings":";AAgBO,IAAM,mBAAN,MAAuB;AAAA,EAE5B,YAA6B,GAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAAA,EAAqB;AAAA,EAArB,GAAA;AAAA,EAD7B,OAAgB,OAAA,GAAU,qBAAA;AAAA,EAGlB,IAAA,GAAe;AACrB,IAAA,OAAO,CAAA,qBAAA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uB,IAAA,EAAkC;AACpE,IAAA,MAAM,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAc;AAAA,MAChC,MAAA,EAAQ,QAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,aAAa,CAAA,CAAA;AAAA,MACrC;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"chunk-44F52KRE.js","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type {\n LegalEntity,\n LegalEntityCreate,\n LegalEntityUpdate,\n} from \"../generated/customer-management\";\n\n/**\n * Storefront-customer access to Legal Entities.\n *\n * `listMine`/`get` require `customermanagement.legalentity_read_own` on the\n * customer token. `create`/`update`/`delete` require the corresponding\n * `_manage` scopes — typically only granted to Admin-group customers; a 403\n * surfaces as `EmporixInsufficientScopeError`.\n */\nexport class CompaniesService {\n static readonly channel = \"customer-management\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/customer-management/${this.ctx.tenant}/legal-entities`;\n }\n\n /** Lists the legal entities the calling customer is assigned to. */\n async listMine(auth: AuthContext): Promise<LegalEntity[]> {\n return this.ctx.http.request<LegalEntity[]>({\n method: \"GET\",\n path: this.base(),\n auth,\n });\n }\n\n /** Fetches a single legal entity by id. */\n async get(legalEntityId: string, auth: AuthContext): Promise<LegalEntity> {\n return this.ctx.http.request<LegalEntity>({\n method: \"GET\",\n path: `${this.base()}/${legalEntityId}`,\n auth,\n });\n }\n\n /** Creates a legal entity. Requires `customermanagement.legalentity_manage`. */\n async create(input: LegalEntityCreate, auth: AuthContext): Promise<{ id: string }> {\n return this.ctx.http.request<{ id: string }>({\n method: \"POST\",\n path: this.base(),\n auth,\n body: input,\n });\n }\n\n /**\n * Updates a legal entity via `PUT …/legal-entities/{id}` (upsert / full\n * replace). The live API rejects `PATCH` on this path with 405; send the\n * complete entity, as the server replaces the resource. The body stays typed\n * as a partial of `LegalEntityUpdate` for backward compatibility.\n */\n async update(\n legalEntityId: string,\n patch: Partial<LegalEntityUpdate>,\n auth: AuthContext,\n ): Promise<LegalEntity> {\n return this.ctx.http.request<LegalEntity>({\n method: \"PUT\",\n path: `${this.base()}/${legalEntityId}`,\n auth,\n body: patch,\n });\n }\n\n /** Deletes a legal entity (async cascade on the server). */\n async delete(legalEntityId: string, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${legalEntityId}`,\n auth,\n });\n }\n}\n"]}
@@ -1,108 +0,0 @@
1
- import { EmporixAuthError } from './chunk-UWGGF4MC.js';
2
-
3
- // src/services/price.ts
4
- function normalizeMatch(raw) {
5
- const itemId = raw.itemId ?? raw.itemRef;
6
- const base = raw;
7
- if (!itemId) return base;
8
- const itemRef = {
9
- ...itemId.itemType !== void 0 ? { itemType: itemId.itemType } : {},
10
- ...itemId.id !== void 0 ? { id: itemId.id } : {}
11
- };
12
- return { ...base, itemId, itemRef };
13
- }
14
- var ANON = { kind: "anonymous" };
15
- var SERVICE = { kind: "service" };
16
- function requireContextAuth(auth) {
17
- const a = auth ?? ANON;
18
- if (a.kind === "anonymous" || a.kind === "customer" || a.kind === "raw") return a;
19
- throw new EmporixAuthError(
20
- "match-prices-by-context requires an anonymous, customer, or raw AuthContext"
21
- );
22
- }
23
- var PriceService = class {
24
- constructor(ctx) {
25
- this.ctx = ctx;
26
- }
27
- ctx;
28
- static channel = "price";
29
- /**
30
- * Resolves prices using the session context bound to the bearer token
31
- * (currency/site/country were set at anonymous-login time). Default auth:
32
- * anonymous; pass a customer/raw context for personalized pricing.
33
- */
34
- async matchByContext(input, auth) {
35
- const rows = await this.ctx.http.request({
36
- method: "POST",
37
- path: `/price/${this.ctx.tenant}/match-prices-by-context`,
38
- auth: requireContextAuth(auth),
39
- body: input,
40
- idempotent: true
41
- // pure read over POST — safe to replay on 5xx/429
42
- });
43
- return rows.map(normalizeMatch);
44
- }
45
- /**
46
- * Resolves prices from an explicit context. Default auth: service
47
- * (requires `price.price_read` / `price.price_manage`).
48
- */
49
- async match(input, auth = SERVICE) {
50
- const rows = await this.ctx.http.request({
51
- method: "POST",
52
- path: `/price/${this.ctx.tenant}/match-prices`,
53
- auth,
54
- body: input,
55
- idempotent: true
56
- // pure read over POST — safe to replay on 5xx/429
57
- });
58
- return rows.map(normalizeMatch);
59
- }
60
- /**
61
- * Chunked variant of {@link matchByContext} for large `items` arrays. The
62
- * Emporix backend handles only a limited number of items per request
63
- * (production limit ~50), so this splits `input.items` into chunks and runs
64
- * `matchByContext` with bounded concurrency.
65
- *
66
- * By default a failing chunk is skipped (its items are absent from the
67
- * result) and `opts.onChunkError` is called once for it; pass
68
- * `throwOnAnyChunkError: true` to reject on the first failure instead.
69
- *
70
- * **Result order is not guaranteed** — match entries back to your items by
71
- * `priceId` / `itemId.id`.
72
- */
73
- async matchByContextChunked(input, opts = {}, auth) {
74
- const chunkSize = opts.chunkSize ?? 50;
75
- const concurrency = opts.concurrency ?? 4;
76
- if (chunkSize < 1) throw new Error("chunkSize must be >= 1");
77
- if (concurrency < 1) throw new Error("concurrency must be >= 1");
78
- const items = input.items ?? [];
79
- if (items.length === 0) return [];
80
- const chunks = [];
81
- for (let i = 0; i < items.length; i += chunkSize) {
82
- chunks.push({ ...input, items: items.slice(i, i + chunkSize) });
83
- }
84
- const results = new Array(chunks.length);
85
- let cursor = 0;
86
- const worker = async () => {
87
- for (; ; ) {
88
- const idx = cursor++;
89
- const chunk = chunks[idx];
90
- if (chunk === void 0) return;
91
- try {
92
- results[idx] = await this.matchByContext(chunk, auth);
93
- } catch (err) {
94
- if (opts.throwOnAnyChunkError) throw err;
95
- results[idx] = [];
96
- opts.onChunkError?.(err, idx);
97
- }
98
- }
99
- };
100
- const workerCount = Math.min(concurrency, chunks.length);
101
- await Promise.all(Array.from({ length: workerCount }, () => worker()));
102
- return results.flat();
103
- }
104
- };
105
-
106
- export { PriceService };
107
- //# sourceMappingURL=chunk-A3LYJUD4.js.map
108
- //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AAQ,CAAC,CAAA;AAErE,IAAA,OAAO,QAAQ,IAAA,EAAK;AAAA,EACtB;AACF","file":"chunk-A3LYJUD4.js","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport { EmporixAuthError } from \"../core/errors\";\nimport type { Match, MatchByContext, MatchResponse } from \"../generated/price\";\n\n/** Session-context match request body (generated). */\nexport type PriceMatchByContextInput = MatchByContext;\n\n/** Explicit-context match request body (generated). */\nexport type PriceMatchInput = Match;\n\n/** Item (product or price) a price was matched for. */\nexport interface PriceMatchItemRef {\n itemType?: string;\n id?: string;\n /** Localized (or plain) product name — present on the live API, absent from the OpenAPI doc. */\n name?: Record<string, string> | string;\n}\n\n/**\n * A resolved price. Superset of the generated match-response schema: the\n * deployed API returns the matched item under `itemId` (with a localized\n * `name`), while the OpenAPI doc/codegen call it `itemRef`.\n */\nexport type PriceMatch = Omit<MatchResponse, \"itemRef\"> & {\n /** Item the price was matched for, as returned by the API. */\n itemId?: PriceMatchItemRef;\n /**\n * @deprecated The OpenAPI doc names this `itemRef`, but the deployed API\n * returns `itemId`. Mirrored from `itemId` for back-compat — prefer `itemId`.\n */\n itemRef?: PriceMatchItemRef;\n};\n\n/**\n * Normalizes a raw match row: the deployed API returns `itemId`, while the\n * codegen type calls it `itemRef`. Expose `itemId` canonically and mirror it\n * to the deprecated `itemRef` so existing consumers keep working.\n */\nfunction normalizeMatch(raw: MatchResponse): PriceMatch {\n const itemId = (raw as MatchResponse & { itemId?: PriceMatchItemRef }).itemId ?? raw.itemRef;\n const base = raw as PriceMatch;\n if (!itemId) return base;\n // Mirror only id/type into the deprecated itemRef (drop name); build without\n // explicit `undefined` for exactOptionalPropertyTypes.\n const itemRef: PriceMatchItemRef = {\n ...(itemId.itemType !== undefined ? { itemType: itemId.itemType } : {}),\n ...(itemId.id !== undefined ? { id: itemId.id } : {}),\n };\n return { ...base, itemId, itemRef };\n}\n\n/** Options for {@link PriceService.matchByContextChunked}. */\nexport interface MatchByContextChunkedOptions {\n /** Items per request. Default 50. Must be >= 1. */\n chunkSize?: number;\n /** Maximum number of requests in flight at once. Default 4. Must be >= 1. */\n concurrency?: number;\n /** Invoked once per failed chunk (default mode only — not when throwing). */\n onChunkError?: (err: unknown, chunkIndex: number) => void;\n /** When true, the first failing chunk rejects the whole call. Default false. */\n throwOnAnyChunkError?: boolean;\n}\n\nconst ANON: AuthContext = { kind: \"anonymous\" };\nconst SERVICE: AuthContext = { kind: \"service\" };\n\nfunction requireContextAuth(auth: AuthContext | undefined): AuthContext {\n const a = auth ?? ANON;\n if (a.kind === \"anonymous\" || a.kind === \"customer\" || a.kind === \"raw\") return a;\n throw new EmporixAuthError(\n \"match-prices-by-context requires an anonymous, customer, or raw AuthContext\",\n );\n}\n\n/**\n * Price matching. The Cart service does not resolve prices — call this\n * explicitly before rendering money and again right before placing an order.\n * The SDK is stateless: it never caches or revalidates prices.\n */\nexport class PriceService {\n static readonly channel = \"price\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n /**\n * Resolves prices using the session context bound to the bearer token\n * (currency/site/country were set at anonymous-login time). Default auth:\n * anonymous; pass a customer/raw context for personalized pricing.\n */\n async matchByContext(\n input: PriceMatchByContextInput,\n auth?: AuthContext,\n ): Promise<PriceMatch[]> {\n const rows = await this.ctx.http.request<MatchResponse[]>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/match-prices-by-context`,\n auth: requireContextAuth(auth),\n body: input,\n idempotent: true, // pure read over POST — safe to replay on 5xx/429\n });\n return rows.map(normalizeMatch);\n }\n\n /**\n * Resolves prices from an explicit context. Default auth: service\n * (requires `price.price_read` / `price.price_manage`).\n */\n async match(input: PriceMatchInput, auth: AuthContext = SERVICE): Promise<PriceMatch[]> {\n const rows = await this.ctx.http.request<MatchResponse[]>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/match-prices`,\n auth,\n body: input,\n idempotent: true, // pure read over POST — safe to replay on 5xx/429\n });\n return rows.map(normalizeMatch);\n }\n\n /**\n * Chunked variant of {@link matchByContext} for large `items` arrays. The\n * Emporix backend handles only a limited number of items per request\n * (production limit ~50), so this splits `input.items` into chunks and runs\n * `matchByContext` with bounded concurrency.\n *\n * By default a failing chunk is skipped (its items are absent from the\n * result) and `opts.onChunkError` is called once for it; pass\n * `throwOnAnyChunkError: true` to reject on the first failure instead.\n *\n * **Result order is not guaranteed** — match entries back to your items by\n * `priceId` / `itemId.id`.\n */\n async matchByContextChunked(\n input: PriceMatchByContextInput,\n opts: MatchByContextChunkedOptions = {},\n auth?: AuthContext,\n ): Promise<PriceMatch[]> {\n const chunkSize = opts.chunkSize ?? 50;\n const concurrency = opts.concurrency ?? 4;\n if (chunkSize < 1) throw new Error(\"chunkSize must be >= 1\");\n if (concurrency < 1) throw new Error(\"concurrency must be >= 1\");\n\n const items = input.items ?? [];\n if (items.length === 0) return [];\n\n const chunks: PriceMatchByContextInput[] = [];\n for (let i = 0; i < items.length; i += chunkSize) {\n chunks.push({ ...input, items: items.slice(i, i + chunkSize) });\n }\n\n const results: PriceMatch[][] = new Array(chunks.length);\n let cursor = 0;\n\n const worker = async (): Promise<void> => {\n for (;;) {\n const idx = cursor++;\n const chunk = chunks[idx];\n if (chunk === undefined) return; // past the end\n try {\n results[idx] = await this.matchByContext(chunk, auth);\n } catch (err) {\n if (opts.throwOnAnyChunkError) throw err;\n results[idx] = [];\n opts.onChunkError?.(err, idx);\n }\n }\n };\n\n const workerCount = Math.min(concurrency, chunks.length);\n await Promise.all(Array.from({ length: workerCount }, () => worker()));\n\n return results.flat();\n }\n}\n"]}