@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,305 @@
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
+ // --- Admin CRUD (flat prices). Default auth: service. ---
105
+ /** Creates a flat price. Default auth: service. */
106
+ async create(input, authCtx = SERVICE) {
107
+ return this.ctx.http.request({
108
+ method: "POST",
109
+ path: `/price/${this.ctx.tenant}/prices`,
110
+ auth: authCtx,
111
+ body: input
112
+ });
113
+ }
114
+ /** Lists flat prices. Default auth: service. */
115
+ async list(query, authCtx = SERVICE) {
116
+ return this.ctx.http.request({
117
+ method: "GET",
118
+ path: `/price/${this.ctx.tenant}/prices`,
119
+ auth: authCtx,
120
+ ...query ? { query } : {}
121
+ });
122
+ }
123
+ /** Retrieves one flat price by id. Default auth: service. */
124
+ async get(priceId, authCtx = SERVICE) {
125
+ return this.ctx.http.request({
126
+ method: "GET",
127
+ path: `/price/${this.ctx.tenant}/prices/${priceId}`,
128
+ auth: authCtx
129
+ });
130
+ }
131
+ /** Upserts a flat price by id (PUT). Default auth: service. */
132
+ async upsert(priceId, input, authCtx = SERVICE) {
133
+ return this.ctx.http.request({
134
+ method: "PUT",
135
+ path: `/price/${this.ctx.tenant}/prices/${priceId}`,
136
+ auth: authCtx,
137
+ body: input
138
+ });
139
+ }
140
+ /** Deletes a flat price by id. Default auth: service. */
141
+ async delete(priceId, authCtx = SERVICE) {
142
+ await this.ctx.http.request({
143
+ method: "DELETE",
144
+ path: `/price/${this.ctx.tenant}/prices/${priceId}`,
145
+ auth: authCtx
146
+ });
147
+ }
148
+ /** Searches flat prices (POST body query). Default auth: service. */
149
+ async search(query, authCtx = SERVICE) {
150
+ return this.ctx.http.request({
151
+ method: "POST",
152
+ path: `/price/${this.ctx.tenant}/prices/search`,
153
+ auth: authCtx,
154
+ body: query
155
+ });
156
+ }
157
+ /** Creates multiple flat prices in one request. Default auth: service. */
158
+ async bulkCreate(inputs, authCtx = SERVICE) {
159
+ return this.ctx.http.request({
160
+ method: "POST",
161
+ path: `/price/${this.ctx.tenant}/prices/bulk`,
162
+ auth: authCtx,
163
+ body: inputs
164
+ });
165
+ }
166
+ /** Upserts multiple flat prices in one request (PUT). Default auth: service. */
167
+ async bulkUpsert(inputs, authCtx = SERVICE) {
168
+ return this.ctx.http.request({
169
+ method: "PUT",
170
+ path: `/price/${this.ctx.tenant}/prices/bulk`,
171
+ auth: authCtx,
172
+ body: inputs
173
+ });
174
+ }
175
+ /** Price-model admin CRUD (`/priceModels`). Default auth: service. */
176
+ models = {
177
+ list: async (query, authCtx = SERVICE) => this.ctx.http.request({
178
+ method: "GET",
179
+ path: `/price/${this.ctx.tenant}/priceModels`,
180
+ auth: authCtx,
181
+ ...query ? { query } : {}
182
+ }),
183
+ create: async (input, authCtx = SERVICE) => this.ctx.http.request({
184
+ method: "POST",
185
+ path: `/price/${this.ctx.tenant}/priceModels`,
186
+ auth: authCtx,
187
+ body: input
188
+ }),
189
+ get: async (modelId, authCtx = SERVICE) => this.ctx.http.request({
190
+ method: "GET",
191
+ path: `/price/${this.ctx.tenant}/priceModels/${modelId}`,
192
+ auth: authCtx
193
+ }),
194
+ upsert: async (modelId, input, authCtx = SERVICE) => this.ctx.http.request({
195
+ method: "PUT",
196
+ path: `/price/${this.ctx.tenant}/priceModels/${modelId}`,
197
+ auth: authCtx,
198
+ body: input
199
+ }),
200
+ delete: async (modelId, authCtx = SERVICE) => {
201
+ await this.ctx.http.request({
202
+ method: "DELETE",
203
+ path: `/price/${this.ctx.tenant}/priceModels/${modelId}`,
204
+ auth: authCtx
205
+ });
206
+ }
207
+ };
208
+ /** Price-list admin CRUD (`/price-lists`) + nested price management. Default auth: service. */
209
+ lists = {
210
+ list: async (query, authCtx = SERVICE) => this.ctx.http.request({
211
+ method: "GET",
212
+ path: `/price/${this.ctx.tenant}/price-lists`,
213
+ auth: authCtx,
214
+ ...query ? { query } : {}
215
+ }),
216
+ create: async (input, authCtx = SERVICE) => this.ctx.http.request({
217
+ method: "POST",
218
+ path: `/price/${this.ctx.tenant}/price-lists`,
219
+ auth: authCtx,
220
+ body: input
221
+ }),
222
+ search: async (query, authCtx = SERVICE) => this.ctx.http.request({
223
+ method: "POST",
224
+ path: `/price/${this.ctx.tenant}/price-lists/search`,
225
+ auth: authCtx,
226
+ body: query
227
+ }),
228
+ get: async (listId, authCtx = SERVICE) => this.ctx.http.request({
229
+ method: "GET",
230
+ path: `/price/${this.ctx.tenant}/price-lists/${listId}`,
231
+ auth: authCtx
232
+ }),
233
+ upsert: async (listId, input, authCtx = SERVICE) => this.ctx.http.request({
234
+ method: "PUT",
235
+ path: `/price/${this.ctx.tenant}/price-lists/${listId}`,
236
+ auth: authCtx,
237
+ body: input
238
+ }),
239
+ delete: async (listId, authCtx = SERVICE) => {
240
+ await this.ctx.http.request({
241
+ method: "DELETE",
242
+ path: `/price/${this.ctx.tenant}/price-lists/${listId}`,
243
+ auth: authCtx
244
+ });
245
+ },
246
+ listPrices: async (listId, query, authCtx = SERVICE) => this.ctx.http.request({
247
+ method: "GET",
248
+ path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices`,
249
+ auth: authCtx,
250
+ ...query ? { query } : {}
251
+ }),
252
+ addPrice: async (listId, input, authCtx = SERVICE) => this.ctx.http.request({
253
+ method: "POST",
254
+ path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices`,
255
+ auth: authCtx,
256
+ body: input
257
+ }),
258
+ getPrice: async (listId, priceId, authCtx = SERVICE) => this.ctx.http.request({
259
+ method: "GET",
260
+ path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/${priceId}`,
261
+ auth: authCtx
262
+ }),
263
+ upsertPrice: async (listId, priceId, input, authCtx = SERVICE) => this.ctx.http.request({
264
+ method: "PUT",
265
+ path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/${priceId}`,
266
+ auth: authCtx,
267
+ body: input
268
+ }),
269
+ deletePrice: async (listId, priceId, authCtx = SERVICE) => {
270
+ await this.ctx.http.request({
271
+ method: "DELETE",
272
+ path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/${priceId}`,
273
+ auth: authCtx
274
+ });
275
+ },
276
+ searchPrices: async (listId, query, authCtx = SERVICE) => this.ctx.http.request({
277
+ method: "POST",
278
+ path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/search`,
279
+ auth: authCtx,
280
+ body: query
281
+ }),
282
+ bulkCreatePrices: async (listId, inputs, authCtx = SERVICE) => this.ctx.http.request({
283
+ method: "POST",
284
+ path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/bulk`,
285
+ auth: authCtx,
286
+ body: inputs
287
+ }),
288
+ bulkUpsertPrices: async (listId, inputs, authCtx = SERVICE) => this.ctx.http.request({
289
+ method: "PUT",
290
+ path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/bulk`,
291
+ auth: authCtx,
292
+ body: inputs
293
+ }),
294
+ bulkDeletePrices: async (listId, body, authCtx = SERVICE) => this.ctx.http.request({
295
+ method: "DELETE",
296
+ path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/bulk`,
297
+ auth: authCtx,
298
+ body
299
+ })
300
+ };
301
+ };
302
+
303
+ export { PriceService };
304
+ //# sourceMappingURL=chunk-ZOFGDNSX.js.map
305
+ //# sourceMappingURL=chunk-ZOFGDNSX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/services/price.ts"],"names":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AAgB,MAAM,CAAA,YAAA,CAAA;AAAA,MACrD,IAAA,EAAM,OAAA;AAAA,MACN,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,IACH,gBAAA,EAAkB,OAChB,MAAA,EACA,IAAA,EACA,UAAuB,OAAA,KAEvB,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAA2B;AAAA,MACvC,MAAA,EAAQ,QAAA;AAAA,MACR,MAAM,CAAA,OAAA,EAAU,IAAA,CAAK,GAAA,CAAI,MAAM,gBAAgB,MAAM,CAAA,YAAA,CAAA;AAAA,MACrD,IAAA,EAAM,OAAA;AAAA,MACN;AAAA,KACD;AAAA,GACL;AACF","file":"chunk-ZOFGDNSX.js","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport { EmporixAuthError } from \"../core/errors\";\nimport type {\n Match,\n MatchByContext,\n MatchResponse,\n CreatePrice,\n GetPrice,\n PriceModelDefinitionCreation,\n PriceModelRetrieval,\n PriceListCreation,\n PriceListUpdate,\n PriceList as GenPriceList,\n PriceListPriceCreation,\n PriceListPriceUpdate,\n PriceListPrice as GenPriceListPrice,\n PriceBulkResponseEntry,\n} 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\n/** A resolved/stored price (generated read shape). */\nexport type Price = GetPrice;\n/** Create/upsert body for a flat price (generated). */\nexport type PriceCreateInput = CreatePrice;\n/** A price model (read). */\nexport type PriceModel = PriceModelRetrieval;\n/** Create/upsert body for a price model (generated). */\nexport type PriceModelInput = PriceModelDefinitionCreation;\n/** A price list (read). */\nexport type PriceList = GenPriceList;\n/** Create body for a price list (generated). */\nexport type PriceListInput = PriceListCreation;\n/** Upsert body for a price list (generated). */\nexport type PriceListUpdateInput = PriceListUpdate;\n/** A price inside a price list (read). */\nexport type PriceListPrice = GenPriceListPrice;\n/** Add body for a price-list price (generated). */\nexport type PriceListPriceInput = PriceListPriceCreation;\n/** Upsert body for a price-list price (generated). */\nexport type PriceListPriceUpdateInput = PriceListPriceUpdate;\n/** Per-entry result of a bulk price operation (generated). */\nexport type PriceBulkResult = PriceBulkResponseEntry;\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 // --- Admin CRUD (flat prices). Default auth: service. ---\n\n /** Creates a flat price. Default auth: service. */\n async create(input: PriceCreateInput, authCtx: AuthContext = SERVICE): Promise<Price> {\n return this.ctx.http.request<Price>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/prices`,\n auth: authCtx,\n body: input,\n });\n }\n\n /** Lists flat prices. Default auth: service. */\n async list(\n query?: Record<string, string | number>,\n authCtx: AuthContext = SERVICE,\n ): Promise<Price[]> {\n return this.ctx.http.request<Price[]>({\n method: \"GET\",\n path: `/price/${this.ctx.tenant}/prices`,\n auth: authCtx,\n ...(query ? { query } : {}),\n });\n }\n\n /** Retrieves one flat price by id. Default auth: service. */\n async get(priceId: string, authCtx: AuthContext = SERVICE): Promise<Price> {\n return this.ctx.http.request<Price>({\n method: \"GET\",\n path: `/price/${this.ctx.tenant}/prices/${priceId}`,\n auth: authCtx,\n });\n }\n\n /** Upserts a flat price by id (PUT). Default auth: service. */\n async upsert(priceId: string, input: PriceCreateInput, authCtx: AuthContext = SERVICE): Promise<Price> {\n return this.ctx.http.request<Price>({\n method: \"PUT\",\n path: `/price/${this.ctx.tenant}/prices/${priceId}`,\n auth: authCtx,\n body: input,\n });\n }\n\n /** Deletes a flat price by id. Default auth: service. */\n async delete(priceId: string, authCtx: AuthContext = SERVICE): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/price/${this.ctx.tenant}/prices/${priceId}`,\n auth: authCtx,\n });\n }\n\n /** Searches flat prices (POST body query). Default auth: service. */\n async search(query: Record<string, unknown>, authCtx: AuthContext = SERVICE): Promise<Price[]> {\n return this.ctx.http.request<Price[]>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/prices/search`,\n auth: authCtx,\n body: query,\n });\n }\n\n /** Creates multiple flat prices in one request. Default auth: service. */\n async bulkCreate(inputs: PriceCreateInput[], authCtx: AuthContext = SERVICE): Promise<PriceBulkResult[]> {\n return this.ctx.http.request<PriceBulkResult[]>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/prices/bulk`,\n auth: authCtx,\n body: inputs,\n });\n }\n\n /** Upserts multiple flat prices in one request (PUT). Default auth: service. */\n async bulkUpsert(inputs: PriceCreateInput[], authCtx: AuthContext = SERVICE): Promise<PriceBulkResult[]> {\n return this.ctx.http.request<PriceBulkResult[]>({\n method: \"PUT\",\n path: `/price/${this.ctx.tenant}/prices/bulk`,\n auth: authCtx,\n body: inputs,\n });\n }\n\n /** Price-model admin CRUD (`/priceModels`). Default auth: service. */\n readonly models = {\n list: async (\n query?: Record<string, string | number>,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceModel[]> =>\n this.ctx.http.request<PriceModel[]>({\n method: \"GET\",\n path: `/price/${this.ctx.tenant}/priceModels`,\n auth: authCtx,\n ...(query ? { query } : {}),\n }),\n create: async (input: PriceModelInput, authCtx: AuthContext = SERVICE): Promise<PriceModel> =>\n this.ctx.http.request<PriceModel>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/priceModels`,\n auth: authCtx,\n body: input,\n }),\n get: async (modelId: string, authCtx: AuthContext = SERVICE): Promise<PriceModel> =>\n this.ctx.http.request<PriceModel>({\n method: \"GET\",\n path: `/price/${this.ctx.tenant}/priceModels/${modelId}`,\n auth: authCtx,\n }),\n upsert: async (\n modelId: string,\n input: PriceModelInput,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceModel> =>\n this.ctx.http.request<PriceModel>({\n method: \"PUT\",\n path: `/price/${this.ctx.tenant}/priceModels/${modelId}`,\n auth: authCtx,\n body: input,\n }),\n delete: async (modelId: string, authCtx: AuthContext = SERVICE): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/price/${this.ctx.tenant}/priceModels/${modelId}`,\n auth: authCtx,\n });\n },\n };\n\n /** Price-list admin CRUD (`/price-lists`) + nested price management. Default auth: service. */\n readonly lists = {\n list: async (\n query?: Record<string, string | number>,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceList[]> =>\n this.ctx.http.request<PriceList[]>({\n method: \"GET\",\n path: `/price/${this.ctx.tenant}/price-lists`,\n auth: authCtx,\n ...(query ? { query } : {}),\n }),\n create: async (input: PriceListInput, authCtx: AuthContext = SERVICE): Promise<PriceList> =>\n this.ctx.http.request<PriceList>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/price-lists`,\n auth: authCtx,\n body: input,\n }),\n search: async (query: Record<string, unknown>, authCtx: AuthContext = SERVICE): Promise<PriceList[]> =>\n this.ctx.http.request<PriceList[]>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/price-lists/search`,\n auth: authCtx,\n body: query,\n }),\n get: async (listId: string, authCtx: AuthContext = SERVICE): Promise<PriceList> =>\n this.ctx.http.request<PriceList>({\n method: \"GET\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}`,\n auth: authCtx,\n }),\n upsert: async (\n listId: string,\n input: PriceListUpdateInput,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceList> =>\n this.ctx.http.request<PriceList>({\n method: \"PUT\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}`,\n auth: authCtx,\n body: input,\n }),\n delete: async (listId: string, authCtx: AuthContext = SERVICE): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}`,\n auth: authCtx,\n });\n },\n listPrices: async (\n listId: string,\n query?: Record<string, string | number>,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceListPrice[]> =>\n this.ctx.http.request<PriceListPrice[]>({\n method: \"GET\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices`,\n auth: authCtx,\n ...(query ? { query } : {}),\n }),\n addPrice: async (\n listId: string,\n input: PriceListPriceInput,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceListPrice> =>\n this.ctx.http.request<PriceListPrice>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices`,\n auth: authCtx,\n body: input,\n }),\n getPrice: async (\n listId: string,\n priceId: string,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceListPrice> =>\n this.ctx.http.request<PriceListPrice>({\n method: \"GET\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/${priceId}`,\n auth: authCtx,\n }),\n upsertPrice: async (\n listId: string,\n priceId: string,\n input: PriceListPriceUpdateInput,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceListPrice> =>\n this.ctx.http.request<PriceListPrice>({\n method: \"PUT\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/${priceId}`,\n auth: authCtx,\n body: input,\n }),\n deletePrice: async (\n listId: string,\n priceId: string,\n authCtx: AuthContext = SERVICE,\n ): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/${priceId}`,\n auth: authCtx,\n });\n },\n searchPrices: async (\n listId: string,\n query: Record<string, unknown>,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceListPrice[]> =>\n this.ctx.http.request<PriceListPrice[]>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/search`,\n auth: authCtx,\n body: query,\n }),\n bulkCreatePrices: async (\n listId: string,\n inputs: PriceListPriceInput[],\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceBulkResult[]> =>\n this.ctx.http.request<PriceBulkResult[]>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/bulk`,\n auth: authCtx,\n body: inputs,\n }),\n bulkUpsertPrices: async (\n listId: string,\n inputs: PriceListPriceInput[],\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceBulkResult[]> =>\n this.ctx.http.request<PriceBulkResult[]>({\n method: \"PUT\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/bulk`,\n auth: authCtx,\n body: inputs,\n }),\n bulkDeletePrices: async (\n listId: string,\n body: Record<string, unknown>,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceBulkResult[]> =>\n this.ctx.http.request<PriceBulkResult[]>({\n method: \"DELETE\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/bulk`,\n auth: authCtx,\n body,\n }),\n };\n}\n"]}
@@ -57,6 +57,31 @@ var CompaniesService = class {
57
57
  auth
58
58
  });
59
59
  }
60
+ /**
61
+ * Searches legal entities via `POST /legal-entities/search` with an Emporix
62
+ * `q`-syntax filter body. Requires the same read scope as {@link listMine}.
63
+ */
64
+ async search(query, auth) {
65
+ return this.ctx.http.request({
66
+ method: "POST",
67
+ path: `${this.base()}/search`,
68
+ auth,
69
+ body: query,
70
+ idempotent: true
71
+ // pure read over POST — safe to replay on 5xx/429
72
+ });
73
+ }
74
+ /**
75
+ * Retrieves a legal entity's chain of parent entities
76
+ * (`GET /legal-entities/{id}/parent-hierarchy`).
77
+ */
78
+ async parentHierarchy(legalEntityId, auth) {
79
+ return this.ctx.http.request({
80
+ method: "GET",
81
+ path: `${this.base()}/${legalEntityId}/parent-hierarchy`,
82
+ auth
83
+ });
84
+ }
60
85
  };
61
86
 
62
87
  exports.CompaniesService = CompaniesService;
@@ -1 +1 @@
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,EAAwB,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,eAAA,CAAA;AAAA,EAChD;AAAA;AAAA,EAGA,MAAM,SAAS,IAAA,EAA2C;AACxD,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAuB;AAAA,MAC1C,MAAA,EAAQ,KAAA;AAAA,MACR,IAAA,EAAM,KAAK,IAAA,EAAK;AAAA,MAChB;AAAA,KACD,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,GAAA,CAAI,aAAA,EAAuB,IAAA,EAAyC;AACxE,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAqB;AAAA,MACxC,MAAA,EAAQ,KAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,aAAa,CAAA,CAAA;AAAA,MACrC;AAAA,KACD,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,MAAA,CAAO,KAAA,EAA0B,IAAA,EAA4C;AACjF,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAwB;AAAA,MAC3C,MAAA,EAAQ,MAAA;AAAA,MACR,IAAA,EAAM,KAAK,IAAA,EAAK;AAAA,MAChB,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,MAAA,CACJ,aAAA,EACA,KAAA,EACA,IAAA,EACsB;AACtB,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAqB;AAAA,MACxC,MAAA,EAAQ,KAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,aAAa,CAAA,CAAA;AAAA,MACrC,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,MAAA,CAAO,aAAA,EAAuB,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":"companies.cjs","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
+ {"version":3,"sources":["../src/services/companies.ts"],"names":[],"mappings":";;;AAmBO,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,EAAwB,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,eAAA,CAAA;AAAA,EAChD;AAAA;AAAA,EAGA,MAAM,SAAS,IAA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AAQ,QAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,aAAa,CAAA,CAAA;AAAA,MACrC;AAAA,KACD,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,MAAA,CAAO,KAAA,EAA+B,IAAA,EAA2C;AACrF,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAuB;AAAA,MAC1C,MAAA,EAAQ,MAAA;AAAA,MACR,IAAA,EAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,CAAA,OAAA,CAAA;AAAA,MACpB,IAAA;AAAA,MACA,IAAA,EAAM,KAAA;AAAA,MACN,UAAA,EAAY;AAAA;AAAA,KACb,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,eAAA,CAAgB,aAAA,EAAuB,IAAA,EAA2C;AACtF,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAuB;AAAA,MAC1C,MAAA,EAAQ,KAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,aAAa,CAAA,iBAAA,CAAA;AAAA,MACrC;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"companies.cjs","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/** Body for `companies.search` — an Emporix `q`-syntax filter. */\nexport type LegalEntitySearchInput = { q?: string };\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 /**\n * Searches legal entities via `POST /legal-entities/search` with an Emporix\n * `q`-syntax filter body. Requires the same read scope as {@link listMine}.\n */\n async search(query: LegalEntitySearchInput, auth: AuthContext): Promise<LegalEntity[]> {\n return this.ctx.http.request<LegalEntity[]>({\n method: \"POST\",\n path: `${this.base()}/search`,\n auth,\n body: query,\n idempotent: true, // pure read over POST — safe to replay on 5xx/429\n });\n }\n\n /**\n * Retrieves a legal entity's chain of parent entities\n * (`GET /legal-entities/{id}/parent-hierarchy`).\n */\n async parentHierarchy(legalEntityId: string, auth: AuthContext): Promise<LegalEntity[]> {\n return this.ctx.http.request<LegalEntity[]>({\n method: \"GET\",\n path: `${this.base()}/${legalEntityId}/parent-hierarchy`,\n auth,\n });\n }\n}\n"]}
@@ -2,6 +2,10 @@ import { C as ClientContext, b as AuthContext } from './context-CfXJcYKP.cjs';
2
2
  import { L as LegalEntity, e as LegalEntityCreate, f as LegalEntityUpdate } from './types.gen-C_wOXYZB.cjs';
3
3
  export { A as AccountLimit, d as CustomerGroup, g as LegalInfo } from './types.gen-C_wOXYZB.cjs';
4
4
 
5
+ /** Body for `companies.search` — an Emporix `q`-syntax filter. */
6
+ type LegalEntitySearchInput = {
7
+ q?: string;
8
+ };
5
9
  /**
6
10
  * Storefront-customer access to Legal Entities.
7
11
  *
@@ -32,6 +36,16 @@ declare class CompaniesService {
32
36
  update(legalEntityId: string, patch: Partial<LegalEntityUpdate>, auth: AuthContext): Promise<LegalEntity>;
33
37
  /** Deletes a legal entity (async cascade on the server). */
34
38
  delete(legalEntityId: string, auth: AuthContext): Promise<void>;
39
+ /**
40
+ * Searches legal entities via `POST /legal-entities/search` with an Emporix
41
+ * `q`-syntax filter body. Requires the same read scope as {@link listMine}.
42
+ */
43
+ search(query: LegalEntitySearchInput, auth: AuthContext): Promise<LegalEntity[]>;
44
+ /**
45
+ * Retrieves a legal entity's chain of parent entities
46
+ * (`GET /legal-entities/{id}/parent-hierarchy`).
47
+ */
48
+ parentHierarchy(legalEntityId: string, auth: AuthContext): Promise<LegalEntity[]>;
35
49
  }
36
50
 
37
51
  export { CompaniesService, LegalEntity, LegalEntityCreate, LegalEntityUpdate };
@@ -2,6 +2,10 @@ import { C as ClientContext, b as AuthContext } from './context-CfXJcYKP.js';
2
2
  import { L as LegalEntity, e as LegalEntityCreate, f as LegalEntityUpdate } from './types.gen-C_wOXYZB.js';
3
3
  export { A as AccountLimit, d as CustomerGroup, g as LegalInfo } from './types.gen-C_wOXYZB.js';
4
4
 
5
+ /** Body for `companies.search` — an Emporix `q`-syntax filter. */
6
+ type LegalEntitySearchInput = {
7
+ q?: string;
8
+ };
5
9
  /**
6
10
  * Storefront-customer access to Legal Entities.
7
11
  *
@@ -32,6 +36,16 @@ declare class CompaniesService {
32
36
  update(legalEntityId: string, patch: Partial<LegalEntityUpdate>, auth: AuthContext): Promise<LegalEntity>;
33
37
  /** Deletes a legal entity (async cascade on the server). */
34
38
  delete(legalEntityId: string, auth: AuthContext): Promise<void>;
39
+ /**
40
+ * Searches legal entities via `POST /legal-entities/search` with an Emporix
41
+ * `q`-syntax filter body. Requires the same read scope as {@link listMine}.
42
+ */
43
+ search(query: LegalEntitySearchInput, auth: AuthContext): Promise<LegalEntity[]>;
44
+ /**
45
+ * Retrieves a legal entity's chain of parent entities
46
+ * (`GET /legal-entities/{id}/parent-hierarchy`).
47
+ */
48
+ parentHierarchy(legalEntityId: string, auth: AuthContext): Promise<LegalEntity[]>;
35
49
  }
36
50
 
37
51
  export { CompaniesService, LegalEntity, LegalEntityCreate, LegalEntityUpdate };
package/dist/companies.js CHANGED
@@ -1,3 +1,3 @@
1
- export { CompaniesService } from './chunk-44F52KRE.js';
1
+ export { CompaniesService } from './chunk-QQMLN76U.js';
2
2
  //# sourceMappingURL=companies.js.map
3
3
  //# sourceMappingURL=companies.js.map
package/dist/contacts.cjs CHANGED
@@ -50,6 +50,14 @@ var ContactsService = class {
50
50
  auth
51
51
  });
52
52
  }
53
+ /** Fetches a single contact assignment by id. */
54
+ async get(contactAssignmentId, auth) {
55
+ return this.ctx.http.request({
56
+ method: "GET",
57
+ path: `${this.base()}/${contactAssignmentId}`,
58
+ auth
59
+ });
60
+ }
53
61
  };
54
62
 
55
63
  exports.ContactsService = ContactsService;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/services/contacts.ts"],"names":[],"mappings":";;;AAeO,IAAM,kBAAN,MAAsB;AAAA,EAE3B,YAA6B,GAAA,EAAoB;AAApB,IAAA,IAAA,CAA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,IAAA,CAAK,OAAA,CAAc;AAAA,MAChC,MAAA,EAAQ,QAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,mBAAmB,CAAA,CAAA;AAAA,MAC3C;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"contacts.cjs","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type {\n ContactAssignment,\n ContactAssignmentCreate,\n ContactAssignmentUpdate,\n} from \"../generated/customer-management\";\n\n/**\n * Manages contact assignments linking customers to legal entities.\n *\n * `listForCompany` requires `customermanagement.contactassignment_read`;\n * `assign`/`update`/`unassign` require `_manage`. The query param\n * `legalEntityId` scopes the list to one company.\n */\nexport class ContactsService {\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}/contact-assignments`;\n }\n\n /** Lists contact assignments for one legal entity. */\n async listForCompany(legalEntityId: string, auth: AuthContext): Promise<ContactAssignment[]> {\n return this.ctx.http.request<ContactAssignment[]>({\n method: \"GET\",\n path: this.base(),\n query: { legalEntityId },\n auth,\n });\n }\n\n /** Creates a contact assignment. */\n async assign(input: ContactAssignmentCreate, 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 contact assignment via `PUT …/contact-assignments/{id}` (upsert /\n * full 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 `ContactAssignmentUpdate` for backward compatibility.\n */\n async update(\n contactAssignmentId: string,\n patch: Partial<ContactAssignmentUpdate>,\n auth: AuthContext,\n ): Promise<ContactAssignment> {\n return this.ctx.http.request<ContactAssignment>({\n method: \"PUT\",\n path: `${this.base()}/${contactAssignmentId}`,\n auth,\n body: patch,\n });\n }\n\n /** Deletes a contact assignment. */\n async unassign(contactAssignmentId: string, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${contactAssignmentId}`,\n auth,\n });\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/services/contacts.ts"],"names":[],"mappings":";;;AAeO,IAAM,kBAAN,MAAsB;AAAA,EAE3B,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,EAAwB,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,oBAAA,CAAA;AAAA,EAChD;AAAA;AAAA,EAGA,MAAM,cAAA,CAAe,aAAA,EAAuB,IAAA,EAAiD;AAC3F,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAA6B;AAAA,MAChD,MAAA,EAAQ,KAAA;AAAA,MACR,IAAA,EAAM,KAAK,IAAA,EAAK;AAAA,MAChB,KAAA,EAAO,EAAE,aAAA,EAAc;AAAA,MACvB;AAAA,KACD,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,MAAA,CAAO,KAAA,EAAgC,IAAA,EAA4C;AACvF,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAwB;AAAA,MAC3C,MAAA,EAAQ,MAAA;AAAA,MACR,IAAA,EAAM,KAAK,IAAA,EAAK;AAAA,MAChB,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,MAAA,CACJ,mBAAA,EACA,KAAA,EACA,IAAA,EAC4B;AAC5B,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAA2B;AAAA,MAC9C,MAAA,EAAQ,KAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,mBAAmB,CAAA,CAAA;AAAA,MAC3C,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,QAAA,CAAS,mBAAA,EAA6B,IAAA,EAAkC;AAC5E,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,mBAAmB,CAAA,CAAA;AAAA,MAC3C;AAAA,KACD,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,GAAA,CAAI,mBAAA,EAA6B,IAAA,EAA+C;AACpF,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAA2B;AAAA,MAC9C,MAAA,EAAQ,KAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,mBAAmB,CAAA,CAAA;AAAA,MAC3C;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"contacts.cjs","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type {\n ContactAssignment,\n ContactAssignmentCreate,\n ContactAssignmentUpdate,\n} from \"../generated/customer-management\";\n\n/**\n * Manages contact assignments linking customers to legal entities.\n *\n * `listForCompany` requires `customermanagement.contactassignment_read`;\n * `assign`/`update`/`unassign` require `_manage`. The query param\n * `legalEntityId` scopes the list to one company.\n */\nexport class ContactsService {\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}/contact-assignments`;\n }\n\n /** Lists contact assignments for one legal entity. */\n async listForCompany(legalEntityId: string, auth: AuthContext): Promise<ContactAssignment[]> {\n return this.ctx.http.request<ContactAssignment[]>({\n method: \"GET\",\n path: this.base(),\n query: { legalEntityId },\n auth,\n });\n }\n\n /** Creates a contact assignment. */\n async assign(input: ContactAssignmentCreate, 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 contact assignment via `PUT …/contact-assignments/{id}` (upsert /\n * full 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 `ContactAssignmentUpdate` for backward compatibility.\n */\n async update(\n contactAssignmentId: string,\n patch: Partial<ContactAssignmentUpdate>,\n auth: AuthContext,\n ): Promise<ContactAssignment> {\n return this.ctx.http.request<ContactAssignment>({\n method: \"PUT\",\n path: `${this.base()}/${contactAssignmentId}`,\n auth,\n body: patch,\n });\n }\n\n /** Deletes a contact assignment. */\n async unassign(contactAssignmentId: string, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${contactAssignmentId}`,\n auth,\n });\n }\n\n /** Fetches a single contact assignment by id. */\n async get(contactAssignmentId: string, auth: AuthContext): Promise<ContactAssignment> {\n return this.ctx.http.request<ContactAssignment>({\n method: \"GET\",\n path: `${this.base()}/${contactAssignmentId}`,\n auth,\n });\n }\n}\n"]}
@@ -28,6 +28,8 @@ declare class ContactsService {
28
28
  update(contactAssignmentId: string, patch: Partial<ContactAssignmentUpdate>, auth: AuthContext): Promise<ContactAssignment>;
29
29
  /** Deletes a contact assignment. */
30
30
  unassign(contactAssignmentId: string, auth: AuthContext): Promise<void>;
31
+ /** Fetches a single contact assignment by id. */
32
+ get(contactAssignmentId: string, auth: AuthContext): Promise<ContactAssignment>;
31
33
  }
32
34
 
33
35
  export { ContactAssignment, ContactAssignmentCreate, ContactAssignmentUpdate, ContactsService };
@@ -28,6 +28,8 @@ declare class ContactsService {
28
28
  update(contactAssignmentId: string, patch: Partial<ContactAssignmentUpdate>, auth: AuthContext): Promise<ContactAssignment>;
29
29
  /** Deletes a contact assignment. */
30
30
  unassign(contactAssignmentId: string, auth: AuthContext): Promise<void>;
31
+ /** Fetches a single contact assignment by id. */
32
+ get(contactAssignmentId: string, auth: AuthContext): Promise<ContactAssignment>;
31
33
  }
32
34
 
33
35
  export { ContactAssignment, ContactAssignmentCreate, ContactAssignmentUpdate, ContactsService };
package/dist/contacts.js CHANGED
@@ -1,3 +1,3 @@
1
- export { ContactsService } from './chunk-HD5RBCM6.js';
1
+ export { ContactsService } from './chunk-27NLS646.js';
2
2
  //# sourceMappingURL=contacts.js.map
3
3
  //# sourceMappingURL=contacts.js.map