@viu/emporix-sdk 2.20.1 → 2.21.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.
- package/CHANGELOG.md +51 -0
- package/dist/availability.d.cts +1 -1
- package/dist/availability.d.ts +1 -1
- package/dist/cart.cjs +23 -8
- package/dist/cart.cjs.map +1 -1
- package/dist/cart.d.cts +13 -3
- package/dist/cart.d.ts +13 -3
- package/dist/cart.js +1 -1
- package/dist/category.d.cts +1 -1
- package/dist/category.d.ts +1 -1
- package/dist/checkout.d.cts +1 -1
- package/dist/checkout.d.ts +1 -1
- package/dist/{chunk-BNX3JULF.js → chunk-44F52KRE.js} +7 -5
- package/dist/chunk-44F52KRE.js.map +1 -0
- package/dist/{chunk-NEXUWPHW.js → chunk-HBEQEIT6.js} +5 -5
- package/dist/chunk-HBEQEIT6.js.map +1 -0
- package/dist/{chunk-EAWGUZHS.js → chunk-HD5RBCM6.js} +7 -5
- package/dist/chunk-HD5RBCM6.js.map +1 -0
- package/dist/{chunk-PAT4CS36.js → chunk-HUEMYP2L.js} +25 -10
- package/dist/chunk-HUEMYP2L.js.map +1 -0
- package/dist/{chunk-DUVIIWFG.js → chunk-IAOWDMTA.js} +7 -5
- package/dist/chunk-IAOWDMTA.js.map +1 -0
- package/dist/companies.cjs +5 -3
- package/dist/companies.cjs.map +1 -1
- package/dist/companies.d.cts +5 -3
- package/dist/companies.d.ts +5 -3
- package/dist/companies.js +1 -1
- package/dist/contacts.cjs +5 -3
- package/dist/contacts.cjs.map +1 -1
- package/dist/contacts.d.cts +5 -3
- package/dist/contacts.d.ts +5 -3
- package/dist/contacts.js +1 -1
- package/dist/{context-Dawv2AtS.d.cts → context-CfXJcYKP.d.cts} +1 -1
- package/dist/{context-Dawv2AtS.d.ts → context-CfXJcYKP.d.ts} +1 -1
- package/dist/customer-groups.d.cts +1 -1
- package/dist/customer-groups.d.ts +1 -1
- package/dist/customer.cjs +3 -3
- package/dist/customer.cjs.map +1 -1
- package/dist/customer.d.cts +1 -1
- package/dist/customer.d.ts +1 -1
- package/dist/customer.js +1 -1
- package/dist/index.cjs +687 -235
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2123 -123
- package/dist/index.d.ts +2123 -123
- package/dist/index.js +655 -226
- package/dist/index.js.map +1 -1
- package/dist/locations.cjs +5 -3
- package/dist/locations.cjs.map +1 -1
- package/dist/locations.d.cts +5 -3
- package/dist/locations.d.ts +5 -3
- package/dist/locations.js +1 -1
- package/dist/media.d.cts +1 -1
- package/dist/media.d.ts +1 -1
- package/dist/orders.d.cts +1 -1
- package/dist/orders.d.ts +1 -1
- package/dist/payment.d.cts +1 -1
- package/dist/payment.d.ts +1 -1
- package/dist/price.d.cts +6 -6
- package/dist/price.d.ts +6 -6
- package/dist/product.d.cts +1 -1
- package/dist/product.d.ts +1 -1
- package/dist/segment.d.cts +1 -1
- package/dist/segment.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-BNX3JULF.js.map +0 -1
- package/dist/chunk-DUVIIWFG.js.map +0 -1
- package/dist/chunk-EAWGUZHS.js.map +0 -1
- package/dist/chunk-NEXUWPHW.js.map +0 -1
- package/dist/chunk-PAT4CS36.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,56 @@
|
|
|
1
1
|
# @viu/emporix-sdk
|
|
2
2
|
|
|
3
|
+
## 2.21.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#154](https://github.com/viuteam/emporix-sdk/pull/154) [`2c170d1`](https://github.com/viuteam/emporix-sdk/commit/2c170d182a2839bb39aba47a4075ee820195813a) Thanks [@amnael1](https://github.com/amnael1)! - Add full `AiService` parity with the ai-service API. New CRUD sub-resources
|
|
8
|
+
`ai.tools`, `ai.mcpServers`, `ai.tokens`, `ai.oauths` (list/search/get/upsert/patch/delete);
|
|
9
|
+
new resource groups `ai.jobs`, `ai.templates`, `ai.logs`, `ai.analytics`; and
|
|
10
|
+
new methods `ai.listModels`, `ai.listCommerceEvents`, `ai.uploadAttachment`,
|
|
11
|
+
`ai.exportAgents`, `ai.importAgents`.
|
|
12
|
+
|
|
13
|
+
- [#157](https://github.com/viuteam/emporix-sdk/pull/157) [`f7e9839`](https://github.com/viuteam/emporix-sdk/commit/f7e983928c3d91d3093c875a3fef5c15d59133c0) Thanks [@amnael1](https://github.com/amnael1)! - Add `client.invoices` (invoice-generation jobs) and `client.quotes` (B2B quotes
|
|
14
|
+
CRUD + PDF + history, with a `client.quotes.reasons` config sub-resource),
|
|
15
|
+
backed by the generated `invoice` / `quote` types. Quote-domain methods take a
|
|
16
|
+
required `auth` argument (customer or admin token — quotes are never
|
|
17
|
+
anonymous). The OAuth Service is intentionally not wrapped — its token grant is
|
|
18
|
+
owned by the SDK auth core.
|
|
19
|
+
|
|
20
|
+
- [#156](https://github.com/viuteam/emporix-sdk/pull/156) [`61df99e`](https://github.com/viuteam/emporix-sdk/commit/61df99ec09be5ff69327a3f70b82be58b7c90d34) Thanks [@amnael1](https://github.com/amnael1)! - Derive `SiteService` and `SessionContextService` public types from the
|
|
21
|
+
generated `site-settings-service` / `session-context` types. `Site` now
|
|
22
|
+
inherits every generated field (shipping/payment/tax/assistedBuying/mixins/
|
|
23
|
+
taxDeterminationBasedOn, richer address) while keeping `active`/`default`
|
|
24
|
+
required; `SessionContext.sessionId` stays required and the ergonomic flat
|
|
25
|
+
`patch({ …, version })` DX is unchanged. Note: `SessionContext.context` /
|
|
26
|
+
`SessionContextPatch.context` are now the accurate nested map type
|
|
27
|
+
(`Record<string, Record<string, unknown>>`) instead of `Record<string, unknown>`.
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- [#151](https://github.com/viuteam/emporix-sdk/pull/151) [`7aa5fc9`](https://github.com/viuteam/emporix-sdk/commit/7aa5fc93c5ef6a83f7235b76e4e5ccc9bb545d33) Thanks [@viu-release-bot](https://github.com/apps/viu-release-bot)! - chore(sdk): sync generated types with upstream Emporix API specs
|
|
32
|
+
|
|
33
|
+
Updated services: ai-service
|
|
34
|
+
|
|
35
|
+
- [#159](https://github.com/viuteam/emporix-sdk/pull/159) [`7a7c90c`](https://github.com/viuteam/emporix-sdk/commit/7a7c90c7d569988dfdce8ca84ea261d311a419e7) Thanks [@amnael1](https://github.com/amnael1)! - Fix four facade methods that targeted HTTP paths/methods the live Emporix API
|
|
36
|
+
rejects (verified against the tenant). Signatures are unchanged.
|
|
37
|
+
- `cart.applyCoupon` / `cart.removeCoupon` used `…/carts/{id}/coupons`, which
|
|
38
|
+
returns 404 "No endpoint". Coupons are applied via the cart **discounts**
|
|
39
|
+
endpoint: `applyCoupon` now `POST …/discounts` (coupon-code payload),
|
|
40
|
+
`removeCoupon` now `DELETE …/discounts?codes=<code>`. Both re-fetch and return
|
|
41
|
+
the updated cart.
|
|
42
|
+
- `customer.changePassword` used `PUT …/password` (404). Now `POST …/password/change`.
|
|
43
|
+
- `customer.confirmPasswordReset` used `POST …/password/reset/confirm` (404). Now
|
|
44
|
+
`POST …/password/reset/update`.
|
|
45
|
+
- `companies.update` / `contacts.update` / `locations.update` used `PATCH`, which
|
|
46
|
+
the customer-management API rejects with 405 Method Not Allowed. Now `PUT`
|
|
47
|
+
(upsert). Send the complete entity, as the server replaces the resource.
|
|
48
|
+
|
|
49
|
+
- [#155](https://github.com/viuteam/emporix-sdk/pull/155) [`c78ce7b`](https://github.com/viuteam/emporix-sdk/commit/c78ce7bb25c0208b02a4469904c56c38b11cc6cf) Thanks [@amnael1](https://github.com/amnael1)! - Register the five remaining Emporix OpenAPI specs that were missing from the
|
|
50
|
+
fetch registry — `oauth-service`, `site-settings-service`, `invoice`, `quote`,
|
|
51
|
+
`session-context` — so the SDK vendors and generates types for all 43 listed
|
|
52
|
+
API services. Generated types only; no new service facades.
|
|
53
|
+
|
|
3
54
|
## 2.20.1
|
|
4
55
|
|
|
5
56
|
### Patch Changes
|
package/dist/availability.d.cts
CHANGED
package/dist/availability.d.ts
CHANGED
package/dist/cart.cjs
CHANGED
|
@@ -163,22 +163,37 @@ var CartService = class {
|
|
|
163
163
|
auth: requireCartAuth(auth)
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
|
-
/**
|
|
166
|
+
/**
|
|
167
|
+
* Applies a coupon by code. Coupon application goes through the cart's
|
|
168
|
+
* `discounts` endpoint (`POST …/discounts` with a coupon-code-only payload) —
|
|
169
|
+
* the live API has no `…/coupons` path. The apply response only carries the
|
|
170
|
+
* applied-discount reference (`{ discountId, discountIndex }`), so the updated
|
|
171
|
+
* cart is re-fetched and returned to preserve the `Cart` contract.
|
|
172
|
+
*/
|
|
167
173
|
async applyCoupon(cartId, code, auth) {
|
|
168
|
-
|
|
174
|
+
const cartAuth = requireCartAuth(auth);
|
|
175
|
+
await this.ctx.http.request({
|
|
169
176
|
method: "POST",
|
|
170
|
-
path: `${this.base()}/${cartId}/
|
|
171
|
-
auth:
|
|
177
|
+
path: `${this.base()}/${cartId}/discounts`,
|
|
178
|
+
auth: cartAuth,
|
|
172
179
|
body: { code }
|
|
173
180
|
});
|
|
181
|
+
return this.get(cartId, cartAuth);
|
|
174
182
|
}
|
|
175
|
-
/**
|
|
183
|
+
/**
|
|
184
|
+
* Removes a coupon by code via `DELETE …/discounts?codes=<code>` — the live
|
|
185
|
+
* API has no `…/coupons/<code>` path. The delete responds 204 No Content, so
|
|
186
|
+
* the updated cart is re-fetched and returned.
|
|
187
|
+
*/
|
|
176
188
|
async removeCoupon(cartId, code, auth) {
|
|
177
|
-
|
|
189
|
+
const cartAuth = requireCartAuth(auth);
|
|
190
|
+
await this.ctx.http.request({
|
|
178
191
|
method: "DELETE",
|
|
179
|
-
path: `${this.base()}/${cartId}/
|
|
180
|
-
|
|
192
|
+
path: `${this.base()}/${cartId}/discounts`,
|
|
193
|
+
query: { codes: code },
|
|
194
|
+
auth: cartAuth
|
|
181
195
|
});
|
|
196
|
+
return this.get(cartId, cartAuth);
|
|
182
197
|
}
|
|
183
198
|
/** Sets the shipping address. */
|
|
184
199
|
async setShippingAddress(cartId, address, auth) {
|
package/dist/cart.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/errors.ts","../src/services/cart.ts"],"names":[],"mappings":";;;AACA,IAAM,kBAAA,uBAAyB,GAAA,CAAI;AAAA,EACjC,cAAA;AAAA,EAAgB,eAAA;AAAA,EAAiB,OAAA;AAAA,EAAS,eAAA;AAAA,EAAiB,WAAA;AAAA,EAC3D,QAAA;AAAA,EAAU,eAAA;AAAA,EAAiB,eAAA;AAAA,EAAiB;AAC9C,CAAC,CAAA;AAED,SAAS,MAAM,IAAA,EAAwB;AACrC,EAAA,IAAI,MAAM,OAAA,CAAQ,IAAI,GAAG,OAAO,IAAA,CAAK,IAAI,KAAK,CAAA;AAC9C,EAAA,IAAI,IAAA,IAAQ,OAAO,IAAA,KAAS,QAAA,EAAU;AACpC,IAAA,MAAM,MAA+B,EAAC;AACtC,IAAA,KAAA,MAAW,CAAC,CAAA,EAAG,CAAC,KAAK,MAAA,CAAO,OAAA,CAAQ,IAA+B,CAAA,EAAG;AACpE,MAAA,GAAA,CAAI,CAAC,CAAA,GAAI,kBAAA,CAAmB,GAAA,CAAI,CAAA,CAAE,aAAa,CAAA,GAAI,gBAAA,GAAmB,KAAA,CAAM,CAAC,CAAA;AAAA,IAC/E;AACA,IAAA,OAAO,GAAA;AAAA,EACT;AACA,EAAA,OAAO,IAAA;AACT;AAGO,IAAM,YAAA,GAAN,cAA2B,KAAA,CAAM;AAAA,EAC7B,MAAA;AAAA,EACA,IAAA;AAAA,EACT,WAAA,CAAY,OAAA,EAAiB,MAAA,EAAiB,IAAA,EAAgB;AAC5D,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,OAAO,GAAA,CAAA,MAAA,CAAW,IAAA;AACvB,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,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AAoB,IAAI,CAAA;AAAA,MAC9B,IAAA,EAAM,EAAE,KAAA,EAAO,gBAAA;AAAiB,KACjC,CAAA;AAAA,EACH;AACF","file":"cart.cjs","sourcesContent":["/** Keys whose values are stripped from any serialised error body. */\nconst REDACTED_BODY_KEYS = new Set([\n \"access_token\", \"refresh_token\", \"token\", \"customertoken\", \"saastoken\",\n \"secret\", \"client_secret\", \"authorization\", \"password\",\n]);\n\nfunction scrub(body: unknown): unknown {\n if (Array.isArray(body)) return body.map(scrub);\n if (body && typeof body === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(body as Record<string, unknown>)) {\n out[k] = REDACTED_BODY_KEYS.has(k.toLowerCase()) ? \"***redacted***\" : scrub(v);\n }\n return out;\n }\n return body;\n}\n\n/** Base class for every error thrown by the SDK. */\nexport class EmporixError extends Error {\n readonly status: number | undefined;\n readonly body: unknown;\n constructor(message: string, status?: number, body?: unknown) {\n super(message);\n this.name = new.target.name;\n this.status = status;\n this.body = body;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n /** Safe serialisation — token-like body fields are redacted. */\n toJSON(): Record<string, unknown> {\n return { name: this.name, message: this.message, status: this.status, body: scrub(this.body) };\n }\n}\n\n/** 401 — authentication failed or token expired. */\nexport class EmporixAuthError extends EmporixError {}\n/** 403 — authenticated but not permitted. */\nexport class EmporixForbiddenError extends EmporixError {}\n/** 404 — resource not found. */\nexport class EmporixNotFoundError extends EmporixError {}\n/** 400/422 — request validation failed. */\nexport class EmporixValidationError extends EmporixError {}\n/** 5xx — server-side failure. */\nexport class EmporixServerError extends EmporixError {}\n/** Request aborted by the configured connect/read timeout. No HTTP status. */\nexport class EmporixTimeoutError extends EmporixError {}\n/** DNS/TLS/connection-level failure before or during the exchange. No HTTP status. */\nexport class EmporixNetworkError extends EmporixError {}\n\n/**\n * 403 with a `missing scope: <name>` hint in the body's `details` array.\n * Subclasses {@link EmporixForbiddenError} so existing 403 catches still work.\n */\nexport class EmporixInsufficientScopeError extends EmporixForbiddenError {\n readonly requiredScope: string | undefined;\n constructor(message: string, status: number, body: unknown, requiredScope?: string) {\n super(message, status, body);\n this.requiredScope = requiredScope;\n }\n}\n\nconst SCOPE_HINT_RE = /missing scope[: ]+([a-z0-9._-]+)/i;\n\nfunction extractRequiredScope(body: unknown): string | undefined {\n if (body && typeof body === \"object\" && \"details\" in body) {\n const details = (body as { details?: unknown }).details;\n if (Array.isArray(details)) {\n for (const d of details) {\n if (typeof d === \"string\") {\n const m = d.match(SCOPE_HINT_RE);\n if (m) return m[1];\n }\n }\n }\n }\n return undefined;\n}\n\n/** Maps an HTTP status to the matching {@link EmporixError} subclass. */\nexport function errorFromResponse(status: number, message: string, body: unknown): EmporixError {\n if (status === 401) return new EmporixAuthError(message, status, body);\n if (status === 403) {\n const scope = extractRequiredScope(body);\n if (scope) return new EmporixInsufficientScopeError(message, status, body, scope);\n return new EmporixForbiddenError(message, status, body);\n }\n if (status === 404) return new EmporixNotFoundError(message, status, body);\n if (status === 400 || status === 422) return new EmporixValidationError(message, status, body);\n if (status >= 500) return new EmporixServerError(message, status, body);\n return new EmporixError(message, status, body);\n}\n","import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport { EmporixNotFoundError, EmporixValidationError } from \"../core/errors\";\nimport type {\n Cart as GeneratedCart,\n CreateCart,\n CreatedCart,\n CartItemRequest,\n UpdateCartItem,\n AddressRequest,\n BatchResponse as GeneratedBatchResponse,\n SingleBatchResponse as GeneratedSingleBatchResponse,\n} from \"../generated/cart\";\n\n/** A cart as returned by the Cart service (all generated fields). */\nexport type Cart = GeneratedCart;\n\n/** The cart-create response (`{ cartId, yrn }`, generated). */\nexport type CartCreated = CreatedCart;\n\n/** Generated request bodies (caller sends the exact wire shape). */\nexport type CreateCartInput = CreateCart;\nexport type CartItemInput = CartItemRequest;\nexport type CartItemUpdate = UpdateCartItem;\n\n/** Per-entry result of `addItemsBatch`. `status` is HTTP-style per entry (e.g. 201 = added, 4xx = failed). */\nexport type CartItemBatchEntry = GeneratedSingleBatchResponse;\n/** Response shape of `addItemsBatch` — one entry per input item, matching by `index`. */\nexport type CartItemsBatchResponse = GeneratedBatchResponse;\n\n/** An address payload for cart shipping/billing (generated). */\nexport type CartAddress = AddressRequest;\n\nfunction requireCartAuth(auth: AuthContext | undefined): AuthContext {\n if (auth && (auth.kind === \"customer\" || auth.kind === \"anonymous\")) return auth;\n throw new EmporixValidationError(\n \"CartService requires an explicit { kind: 'customer' } or { kind: 'anonymous' } AuthContext\",\n );\n}\n\nfunction requireCustomerAuth(auth: AuthContext | undefined): AuthContext {\n if (auth && auth.kind === \"customer\") return auth;\n throw new EmporixValidationError(\"cart.merge requires a { kind: 'customer' } AuthContext\");\n}\n\n/** Cart operations. Every method requires an explicit customer/anonymous context. */\nexport class CartService {\n static readonly channel = \"cart\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/cart/${this.ctx.tenant}/carts`;\n }\n\n /** Creates a cart. */\n async create(\n input: CreateCartInput | undefined,\n auth: AuthContext,\n ): Promise<CartCreated> {\n return this.ctx.http.request<CartCreated>({\n method: \"POST\",\n path: this.base(),\n auth: requireCartAuth(auth),\n body: input ?? {},\n });\n }\n\n /** Fetches a cart by id. */\n async get(cartId: string, auth: AuthContext): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"GET\",\n path: `${this.base()}/${cartId}`,\n auth: requireCartAuth(auth),\n });\n }\n\n /** Returns the current cart for the session, or null if none. */\n /**\n * Get the customer / anonymous cart matching the given criteria. Per Emporix:\n * uniqueness is defined by `siteCode` + `type` + `legalEntityId` +\n * (`customerId` derived from a customer token, or `sessionId` derived from an\n * anonymous token). With `create: true`, Emporix creates a new cart if none\n * matches.\n *\n * Returns `null` on 404 (no cart found and `create` was not set). All other\n * errors are propagated.\n */\n async getCurrent(\n auth: AuthContext,\n opts: { siteCode: string; type?: string; legalEntityId?: string; create?: boolean },\n ): Promise<Cart | null> {\n const query: Record<string, string | number> = { siteCode: opts.siteCode };\n if (opts.type !== undefined) query.type = opts.type;\n if (opts.legalEntityId !== undefined) query.legalEntityId = opts.legalEntityId;\n if (opts.create) query.create = \"true\";\n try {\n return await this.ctx.http.request<Cart>({\n method: \"GET\",\n path: this.base(),\n query,\n auth: requireCartAuth(auth),\n });\n } catch (e) {\n if (e instanceof EmporixNotFoundError) return null;\n throw e;\n }\n }\n\n /** Adds an item. */\n async addItem(\n cartId: string,\n item: CartItemInput,\n auth: AuthContext,\n ): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"POST\",\n path: `${this.base()}/${cartId}/items`,\n auth: requireCartAuth(auth),\n body: item,\n });\n }\n\n /**\n * Adds multiple items in a single request via `POST /carts/{id}/itemsBatch`.\n * Server-side limit is 200 entries per call — callers handling larger sets\n * must chunk. The response carries a per-entry `status` (HTTP-style: 201\n * for added, 4xx/5xx for failed) and `index` matching the input position;\n * partial failures do **not** throw — inspect `status` per entry.\n */\n async addItemsBatch(\n cartId: string,\n items: CartItemInput[],\n auth: AuthContext,\n ): Promise<CartItemsBatchResponse> {\n return this.ctx.http.request<CartItemsBatchResponse>({\n method: \"POST\",\n path: `${this.base()}/${cartId}/itemsBatch`,\n auth: requireCartAuth(auth),\n body: items,\n });\n }\n\n /**\n * Updates an item. By default this is a **full replace** — the server expects\n * the complete item (e.g. `itemYrn` + the `price` row). Pass\n * `{ partial: true }` to send a **partial update** (`?partial=true`), e.g. a\n * quantity-only change with just `{ quantity }`.\n */\n async updateItem(\n cartId: string,\n itemId: string,\n patch: CartItemUpdate,\n auth: AuthContext,\n opts: { partial?: boolean } = {},\n ): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"PUT\",\n path: `${this.base()}/${cartId}/items/${itemId}`,\n auth: requireCartAuth(auth),\n body: patch,\n ...(opts.partial ? { query: { partial: \"true\" } } : {}),\n });\n }\n\n /** Removes an item. */\n async removeItem(cartId: string, itemId: string, auth: AuthContext): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"DELETE\",\n path: `${this.base()}/${cartId}/items/${itemId}`,\n auth: requireCartAuth(auth),\n });\n }\n\n /** Empties the cart. */\n async clear(cartId: string, auth: AuthContext): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"DELETE\",\n path: `${this.base()}/${cartId}/items`,\n auth: requireCartAuth(auth),\n });\n }\n\n /** Applies a coupon. */\n async applyCoupon(cartId: string, code: string, auth: AuthContext): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"POST\",\n path: `${this.base()}/${cartId}/coupons`,\n auth: requireCartAuth(auth),\n body: { code },\n });\n }\n\n /** Removes a coupon. */\n async removeCoupon(cartId: string, code: string, auth: AuthContext): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"DELETE\",\n path: `${this.base()}/${cartId}/coupons/${code}`,\n auth: requireCartAuth(auth),\n });\n }\n\n /** Sets the shipping address. */\n async setShippingAddress(\n cartId: string,\n address: CartAddress,\n auth: AuthContext,\n ): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"PUT\",\n path: `${this.base()}/${cartId}/shipping-address`,\n auth: requireCartAuth(auth),\n body: address,\n });\n }\n\n /** Sets the billing address. */\n async setBillingAddress(\n cartId: string,\n address: CartAddress,\n auth: AuthContext,\n ): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"PUT\",\n path: `${this.base()}/${cartId}/billing-address`,\n auth: requireCartAuth(auth),\n body: address,\n });\n }\n\n /**\n * Merges one or more anonymous carts into the specified customer cart.\n * Per Emporix: the target cart in the path **must belong to the logged-in\n * customer**, and each id in `anonymousCartIds` must belong to an anonymous\n * customer. Anonymous carts go `CLOSED` on success.\n *\n * Requires a customer `AuthContext`.\n */\n async merge(\n customerCartId: string,\n anonymousCartIds: string[],\n auth: AuthContext,\n ): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"POST\",\n path: `${this.base()}/${customerCartId}/merge`,\n auth: requireCustomerAuth(auth),\n body: { carts: anonymousCartIds },\n });\n }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,IAAA,EACe;AACf,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAc;AAAA,MACjC,MAAA,EAAQ,MAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,cAAc,CAAA,MAAA,CAAA;AAAA,MACtC,IAAA,EAAM,oBAAoB,IAAI,CAAA;AAAA,MAC9B,IAAA,EAAM,EAAE,KAAA,EAAO,gBAAA;AAAiB,KACjC,CAAA;AAAA,EACH;AACF","file":"cart.cjs","sourcesContent":["/** Keys whose values are stripped from any serialised error body. */\nconst REDACTED_BODY_KEYS = new Set([\n \"access_token\", \"refresh_token\", \"token\", \"customertoken\", \"saastoken\",\n \"secret\", \"client_secret\", \"authorization\", \"password\",\n]);\n\nfunction scrub(body: unknown): unknown {\n if (Array.isArray(body)) return body.map(scrub);\n if (body && typeof body === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(body as Record<string, unknown>)) {\n out[k] = REDACTED_BODY_KEYS.has(k.toLowerCase()) ? \"***redacted***\" : scrub(v);\n }\n return out;\n }\n return body;\n}\n\n/** Base class for every error thrown by the SDK. */\nexport class EmporixError extends Error {\n readonly status: number | undefined;\n readonly body: unknown;\n constructor(message: string, status?: number, body?: unknown) {\n super(message);\n this.name = new.target.name;\n this.status = status;\n this.body = body;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n /** Safe serialisation — token-like body fields are redacted. */\n toJSON(): Record<string, unknown> {\n return { name: this.name, message: this.message, status: this.status, body: scrub(this.body) };\n }\n}\n\n/** 401 — authentication failed or token expired. */\nexport class EmporixAuthError extends EmporixError {}\n/** 403 — authenticated but not permitted. */\nexport class EmporixForbiddenError extends EmporixError {}\n/** 404 — resource not found. */\nexport class EmporixNotFoundError extends EmporixError {}\n/** 400/422 — request validation failed. */\nexport class EmporixValidationError extends EmporixError {}\n/** 5xx — server-side failure. */\nexport class EmporixServerError extends EmporixError {}\n/** Request aborted by the configured connect/read timeout. No HTTP status. */\nexport class EmporixTimeoutError extends EmporixError {}\n/** DNS/TLS/connection-level failure before or during the exchange. No HTTP status. */\nexport class EmporixNetworkError extends EmporixError {}\n\n/**\n * 403 with a `missing scope: <name>` hint in the body's `details` array.\n * Subclasses {@link EmporixForbiddenError} so existing 403 catches still work.\n */\nexport class EmporixInsufficientScopeError extends EmporixForbiddenError {\n readonly requiredScope: string | undefined;\n constructor(message: string, status: number, body: unknown, requiredScope?: string) {\n super(message, status, body);\n this.requiredScope = requiredScope;\n }\n}\n\nconst SCOPE_HINT_RE = /missing scope[: ]+([a-z0-9._-]+)/i;\n\nfunction extractRequiredScope(body: unknown): string | undefined {\n if (body && typeof body === \"object\" && \"details\" in body) {\n const details = (body as { details?: unknown }).details;\n if (Array.isArray(details)) {\n for (const d of details) {\n if (typeof d === \"string\") {\n const m = d.match(SCOPE_HINT_RE);\n if (m) return m[1];\n }\n }\n }\n }\n return undefined;\n}\n\n/** Maps an HTTP status to the matching {@link EmporixError} subclass. */\nexport function errorFromResponse(status: number, message: string, body: unknown): EmporixError {\n if (status === 401) return new EmporixAuthError(message, status, body);\n if (status === 403) {\n const scope = extractRequiredScope(body);\n if (scope) return new EmporixInsufficientScopeError(message, status, body, scope);\n return new EmporixForbiddenError(message, status, body);\n }\n if (status === 404) return new EmporixNotFoundError(message, status, body);\n if (status === 400 || status === 422) return new EmporixValidationError(message, status, body);\n if (status >= 500) return new EmporixServerError(message, status, body);\n return new EmporixError(message, status, body);\n}\n","import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport { EmporixNotFoundError, EmporixValidationError } from \"../core/errors\";\nimport type {\n Cart as GeneratedCart,\n CreateCart,\n CreatedCart,\n CartItemRequest,\n UpdateCartItem,\n AddressRequest,\n AppliedDiscount,\n BatchResponse as GeneratedBatchResponse,\n SingleBatchResponse as GeneratedSingleBatchResponse,\n} from \"../generated/cart\";\n\n/** A cart as returned by the Cart service (all generated fields). */\nexport type Cart = GeneratedCart;\n\n/** The cart-create response (`{ cartId, yrn }`, generated). */\nexport type CartCreated = CreatedCart;\n\n/** Generated request bodies (caller sends the exact wire shape). */\nexport type CreateCartInput = CreateCart;\nexport type CartItemInput = CartItemRequest;\nexport type CartItemUpdate = UpdateCartItem;\n\n/** Per-entry result of `addItemsBatch`. `status` is HTTP-style per entry (e.g. 201 = added, 4xx = failed). */\nexport type CartItemBatchEntry = GeneratedSingleBatchResponse;\n/** Response shape of `addItemsBatch` — one entry per input item, matching by `index`. */\nexport type CartItemsBatchResponse = GeneratedBatchResponse;\n\n/** An address payload for cart shipping/billing (generated). */\nexport type CartAddress = AddressRequest;\n\nfunction requireCartAuth(auth: AuthContext | undefined): AuthContext {\n if (auth && (auth.kind === \"customer\" || auth.kind === \"anonymous\")) return auth;\n throw new EmporixValidationError(\n \"CartService requires an explicit { kind: 'customer' } or { kind: 'anonymous' } AuthContext\",\n );\n}\n\nfunction requireCustomerAuth(auth: AuthContext | undefined): AuthContext {\n if (auth && auth.kind === \"customer\") return auth;\n throw new EmporixValidationError(\"cart.merge requires a { kind: 'customer' } AuthContext\");\n}\n\n/** Cart operations. Every method requires an explicit customer/anonymous context. */\nexport class CartService {\n static readonly channel = \"cart\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/cart/${this.ctx.tenant}/carts`;\n }\n\n /** Creates a cart. */\n async create(\n input: CreateCartInput | undefined,\n auth: AuthContext,\n ): Promise<CartCreated> {\n return this.ctx.http.request<CartCreated>({\n method: \"POST\",\n path: this.base(),\n auth: requireCartAuth(auth),\n body: input ?? {},\n });\n }\n\n /** Fetches a cart by id. */\n async get(cartId: string, auth: AuthContext): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"GET\",\n path: `${this.base()}/${cartId}`,\n auth: requireCartAuth(auth),\n });\n }\n\n /** Returns the current cart for the session, or null if none. */\n /**\n * Get the customer / anonymous cart matching the given criteria. Per Emporix:\n * uniqueness is defined by `siteCode` + `type` + `legalEntityId` +\n * (`customerId` derived from a customer token, or `sessionId` derived from an\n * anonymous token). With `create: true`, Emporix creates a new cart if none\n * matches.\n *\n * Returns `null` on 404 (no cart found and `create` was not set). All other\n * errors are propagated.\n */\n async getCurrent(\n auth: AuthContext,\n opts: { siteCode: string; type?: string; legalEntityId?: string; create?: boolean },\n ): Promise<Cart | null> {\n const query: Record<string, string | number> = { siteCode: opts.siteCode };\n if (opts.type !== undefined) query.type = opts.type;\n if (opts.legalEntityId !== undefined) query.legalEntityId = opts.legalEntityId;\n if (opts.create) query.create = \"true\";\n try {\n return await this.ctx.http.request<Cart>({\n method: \"GET\",\n path: this.base(),\n query,\n auth: requireCartAuth(auth),\n });\n } catch (e) {\n if (e instanceof EmporixNotFoundError) return null;\n throw e;\n }\n }\n\n /** Adds an item. */\n async addItem(\n cartId: string,\n item: CartItemInput,\n auth: AuthContext,\n ): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"POST\",\n path: `${this.base()}/${cartId}/items`,\n auth: requireCartAuth(auth),\n body: item,\n });\n }\n\n /**\n * Adds multiple items in a single request via `POST /carts/{id}/itemsBatch`.\n * Server-side limit is 200 entries per call — callers handling larger sets\n * must chunk. The response carries a per-entry `status` (HTTP-style: 201\n * for added, 4xx/5xx for failed) and `index` matching the input position;\n * partial failures do **not** throw — inspect `status` per entry.\n */\n async addItemsBatch(\n cartId: string,\n items: CartItemInput[],\n auth: AuthContext,\n ): Promise<CartItemsBatchResponse> {\n return this.ctx.http.request<CartItemsBatchResponse>({\n method: \"POST\",\n path: `${this.base()}/${cartId}/itemsBatch`,\n auth: requireCartAuth(auth),\n body: items,\n });\n }\n\n /**\n * Updates an item. By default this is a **full replace** — the server expects\n * the complete item (e.g. `itemYrn` + the `price` row). Pass\n * `{ partial: true }` to send a **partial update** (`?partial=true`), e.g. a\n * quantity-only change with just `{ quantity }`.\n */\n async updateItem(\n cartId: string,\n itemId: string,\n patch: CartItemUpdate,\n auth: AuthContext,\n opts: { partial?: boolean } = {},\n ): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"PUT\",\n path: `${this.base()}/${cartId}/items/${itemId}`,\n auth: requireCartAuth(auth),\n body: patch,\n ...(opts.partial ? { query: { partial: \"true\" } } : {}),\n });\n }\n\n /** Removes an item. */\n async removeItem(cartId: string, itemId: string, auth: AuthContext): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"DELETE\",\n path: `${this.base()}/${cartId}/items/${itemId}`,\n auth: requireCartAuth(auth),\n });\n }\n\n /** Empties the cart. */\n async clear(cartId: string, auth: AuthContext): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"DELETE\",\n path: `${this.base()}/${cartId}/items`,\n auth: requireCartAuth(auth),\n });\n }\n\n /**\n * Applies a coupon by code. Coupon application goes through the cart's\n * `discounts` endpoint (`POST …/discounts` with a coupon-code-only payload) —\n * the live API has no `…/coupons` path. The apply response only carries the\n * applied-discount reference (`{ discountId, discountIndex }`), so the updated\n * cart is re-fetched and returned to preserve the `Cart` contract.\n */\n async applyCoupon(cartId: string, code: string, auth: AuthContext): Promise<Cart> {\n const cartAuth = requireCartAuth(auth);\n await this.ctx.http.request<AppliedDiscount>({\n method: \"POST\",\n path: `${this.base()}/${cartId}/discounts`,\n auth: cartAuth,\n body: { code },\n });\n return this.get(cartId, cartAuth);\n }\n\n /**\n * Removes a coupon by code via `DELETE …/discounts?codes=<code>` — the live\n * API has no `…/coupons/<code>` path. The delete responds 204 No Content, so\n * the updated cart is re-fetched and returned.\n */\n async removeCoupon(cartId: string, code: string, auth: AuthContext): Promise<Cart> {\n const cartAuth = requireCartAuth(auth);\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${cartId}/discounts`,\n query: { codes: code },\n auth: cartAuth,\n });\n return this.get(cartId, cartAuth);\n }\n\n /** Sets the shipping address. */\n async setShippingAddress(\n cartId: string,\n address: CartAddress,\n auth: AuthContext,\n ): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"PUT\",\n path: `${this.base()}/${cartId}/shipping-address`,\n auth: requireCartAuth(auth),\n body: address,\n });\n }\n\n /** Sets the billing address. */\n async setBillingAddress(\n cartId: string,\n address: CartAddress,\n auth: AuthContext,\n ): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"PUT\",\n path: `${this.base()}/${cartId}/billing-address`,\n auth: requireCartAuth(auth),\n body: address,\n });\n }\n\n /**\n * Merges one or more anonymous carts into the specified customer cart.\n * Per Emporix: the target cart in the path **must belong to the logged-in\n * customer**, and each id in `anonymousCartIds` must belong to an anonymous\n * customer. Anonymous carts go `CLOSED` on success.\n *\n * Requires a customer `AuthContext`.\n */\n async merge(\n customerCartId: string,\n anonymousCartIds: string[],\n auth: AuthContext,\n ): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"POST\",\n path: `${this.base()}/${customerCartId}/merge`,\n auth: requireCustomerAuth(auth),\n body: { carts: anonymousCartIds },\n });\n }\n}\n"]}
|
package/dist/cart.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ClientContext, b as AuthContext } from './context-
|
|
1
|
+
import { C as ClientContext, b as AuthContext } from './context-CfXJcYKP.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Access control identifier that determines who can view or manage the cart.
|
|
@@ -1793,9 +1793,19 @@ declare class CartService {
|
|
|
1793
1793
|
removeItem(cartId: string, itemId: string, auth: AuthContext): Promise<Cart>;
|
|
1794
1794
|
/** Empties the cart. */
|
|
1795
1795
|
clear(cartId: string, auth: AuthContext): Promise<Cart>;
|
|
1796
|
-
/**
|
|
1796
|
+
/**
|
|
1797
|
+
* Applies a coupon by code. Coupon application goes through the cart's
|
|
1798
|
+
* `discounts` endpoint (`POST …/discounts` with a coupon-code-only payload) —
|
|
1799
|
+
* the live API has no `…/coupons` path. The apply response only carries the
|
|
1800
|
+
* applied-discount reference (`{ discountId, discountIndex }`), so the updated
|
|
1801
|
+
* cart is re-fetched and returned to preserve the `Cart` contract.
|
|
1802
|
+
*/
|
|
1797
1803
|
applyCoupon(cartId: string, code: string, auth: AuthContext): Promise<Cart>;
|
|
1798
|
-
/**
|
|
1804
|
+
/**
|
|
1805
|
+
* Removes a coupon by code via `DELETE …/discounts?codes=<code>` — the live
|
|
1806
|
+
* API has no `…/coupons/<code>` path. The delete responds 204 No Content, so
|
|
1807
|
+
* the updated cart is re-fetched and returned.
|
|
1808
|
+
*/
|
|
1799
1809
|
removeCoupon(cartId: string, code: string, auth: AuthContext): Promise<Cart>;
|
|
1800
1810
|
/** Sets the shipping address. */
|
|
1801
1811
|
setShippingAddress(cartId: string, address: CartAddress, auth: AuthContext): Promise<Cart>;
|
package/dist/cart.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ClientContext, b as AuthContext } from './context-
|
|
1
|
+
import { C as ClientContext, b as AuthContext } from './context-CfXJcYKP.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Access control identifier that determines who can view or manage the cart.
|
|
@@ -1793,9 +1793,19 @@ declare class CartService {
|
|
|
1793
1793
|
removeItem(cartId: string, itemId: string, auth: AuthContext): Promise<Cart>;
|
|
1794
1794
|
/** Empties the cart. */
|
|
1795
1795
|
clear(cartId: string, auth: AuthContext): Promise<Cart>;
|
|
1796
|
-
/**
|
|
1796
|
+
/**
|
|
1797
|
+
* Applies a coupon by code. Coupon application goes through the cart's
|
|
1798
|
+
* `discounts` endpoint (`POST …/discounts` with a coupon-code-only payload) —
|
|
1799
|
+
* the live API has no `…/coupons` path. The apply response only carries the
|
|
1800
|
+
* applied-discount reference (`{ discountId, discountIndex }`), so the updated
|
|
1801
|
+
* cart is re-fetched and returned to preserve the `Cart` contract.
|
|
1802
|
+
*/
|
|
1797
1803
|
applyCoupon(cartId: string, code: string, auth: AuthContext): Promise<Cart>;
|
|
1798
|
-
/**
|
|
1804
|
+
/**
|
|
1805
|
+
* Removes a coupon by code via `DELETE …/discounts?codes=<code>` — the live
|
|
1806
|
+
* API has no `…/coupons/<code>` path. The delete responds 204 No Content, so
|
|
1807
|
+
* the updated cart is re-fetched and returned.
|
|
1808
|
+
*/
|
|
1799
1809
|
removeCoupon(cartId: string, code: string, auth: AuthContext): Promise<Cart>;
|
|
1800
1810
|
/** Sets the shipping address. */
|
|
1801
1811
|
setShippingAddress(cartId: string, address: CartAddress, auth: AuthContext): Promise<Cart>;
|
package/dist/cart.js
CHANGED
package/dist/category.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-
|
|
1
|
+
import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-CfXJcYKP.cjs';
|
|
2
2
|
import { a as QueryFor } from './query-mLQs2WFr.cjs';
|
|
3
3
|
import { Product } from './product.cjs';
|
|
4
4
|
|
package/dist/category.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-
|
|
1
|
+
import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-CfXJcYKP.js';
|
|
2
2
|
import { a as QueryFor } from './query-mLQs2WFr.js';
|
|
3
3
|
import { Product } from './product.js';
|
|
4
4
|
|
package/dist/checkout.d.cts
CHANGED
package/dist/checkout.d.ts
CHANGED
|
@@ -34,12 +34,14 @@ var CompaniesService = class {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
37
|
+
* Updates a legal entity via `PUT …/legal-entities/{id}` (upsert / full
|
|
38
|
+
* replace). The live API rejects `PATCH` on this path with 405; send the
|
|
39
|
+
* complete entity, as the server replaces the resource. The body stays typed
|
|
40
|
+
* as a partial of `LegalEntityUpdate` for backward compatibility.
|
|
39
41
|
*/
|
|
40
42
|
async update(legalEntityId, patch, auth) {
|
|
41
43
|
return this.ctx.http.request({
|
|
42
|
-
method: "
|
|
44
|
+
method: "PUT",
|
|
43
45
|
path: `${this.base()}/${legalEntityId}`,
|
|
44
46
|
auth,
|
|
45
47
|
body: patch
|
|
@@ -56,5 +58,5 @@ var CompaniesService = class {
|
|
|
56
58
|
};
|
|
57
59
|
|
|
58
60
|
export { CompaniesService };
|
|
59
|
-
//# sourceMappingURL=chunk-
|
|
60
|
-
//# sourceMappingURL=chunk-
|
|
61
|
+
//# sourceMappingURL=chunk-44F52KRE.js.map
|
|
62
|
+
//# sourceMappingURL=chunk-44F52KRE.js.map
|
|
@@ -0,0 +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":"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"]}
|
|
@@ -153,8 +153,8 @@ var CustomerService = class {
|
|
|
153
153
|
/** Changes the password. Requires customer/raw auth. */
|
|
154
154
|
async changePassword(input, auth) {
|
|
155
155
|
await this.ctx.http.request({
|
|
156
|
-
method: "
|
|
157
|
-
path: `/customer/${this.ctx.tenant}/password`,
|
|
156
|
+
method: "POST",
|
|
157
|
+
path: `/customer/${this.ctx.tenant}/password/change`,
|
|
158
158
|
auth: requireCustomer(auth),
|
|
159
159
|
body: input
|
|
160
160
|
});
|
|
@@ -172,7 +172,7 @@ var CustomerService = class {
|
|
|
172
172
|
async confirmPasswordReset(input, auth = { kind: "anonymous" }) {
|
|
173
173
|
await this.ctx.http.request({
|
|
174
174
|
method: "POST",
|
|
175
|
-
path: `/customer/${this.ctx.tenant}/password/reset/
|
|
175
|
+
path: `/customer/${this.ctx.tenant}/password/reset/update`,
|
|
176
176
|
auth,
|
|
177
177
|
body: input
|
|
178
178
|
});
|
|
@@ -205,5 +205,5 @@ var CustomerService = class {
|
|
|
205
205
|
};
|
|
206
206
|
|
|
207
207
|
export { CustomerService };
|
|
208
|
-
//# sourceMappingURL=chunk-
|
|
209
|
-
//# sourceMappingURL=chunk-
|
|
208
|
+
//# sourceMappingURL=chunk-HBEQEIT6.js.map
|
|
209
|
+
//# sourceMappingURL=chunk-HBEQEIT6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/customer.ts"],"names":[],"mappings":";;;;AAuEA,SAAS,SAAA,CACP,QAAA,EACA,IAAA,EACA,IAAA,GAAoC,EAAC,EACpB;AACjB,EAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,YAAA,IAAgB,IAAA,CAAK,WAAA;AAChD,EAAA,IAAI,CAAC,aAAA,EAAe;AAClB,IAAA,MAAM,IAAI,gBAAA,CAAiB,CAAA,EAAG,QAAQ,CAAA,+BAAA,CAAA,EAAmC,QAAW,IAAI,CAAA;AAAA,EAC1F;AACA,EAAA,OAAO;AAAA,IACL,aAAA;AAAA,IACA,WAAW,IAAA,CAAK,UAAA,IAAc,IAAA,CAAK,SAAA,IAAa,KAAK,cAAA,IAAkB,EAAA;AAAA,IACvE,YAAA,EAAc,IAAA,CAAK,aAAA,IAAiB,IAAA,CAAK,YAAA,IAAgB,EAAA;AAAA,IACzD,WAAW,IAAA,CAAK,UAAA;AAAA,IAChB,WAAW,IAAA,CAAK,UAAA,IAAc,OAAO,MAAA,CAAO,IAAA,CAAK,UAAU,CAAA,GAAI,MAAA;AA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AA,IACH,MAAA,EAAQ,OAAO,EAAA,EAAY,KAAA,EAA2B,SACpD,IAAA,CAAK,GAAA,CAAI,KAAK,OAAA,CAAiB;AAAA,MAC7B,MAAA,EAAQ,KAAA;AAAA,MACR,MAAM,CAAA,UAAA,EAAa,IAAA,CAAK,GAAA,CAAI,MAAM,iBAAiB,EAAE,CAAA,CAAA;AAAA,MACrD,IAAA,EAAM,gBAAgB,IAAI,CAAA;AAAA,MAC1B,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,IACH,QAAQ,OAAO,EAAA,EAAY,SACzB,IAAA,CAAK,GAAA,CAAI,KAAK,OAAA,CAAc;AAAA,MAC1B,MAAA,EAAQ,QAAA;AAAA,MACR,MAAM,CAAA,UAAA,EAAa,IAAA,CAAK,GAAA,CAAI,MAAM,iBAAiB,EAAE,CAAA,CAAA;AAAA,MACrD,IAAA,EAAM,gBAAgB,IAAI;AAAA,KAC3B;AAAA,GACL;AACF","file":"chunk-HBEQEIT6.js","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext, AnonymousSession } from \"../core/auth\";\nimport { EmporixAuthError } from \"../core/errors\";\nimport { requireCustomer } from \"../core/require-customer\";\nimport type {\n Customer as GeneratedCustomer,\n Address as GeneratedAddress,\n CustomerSignup,\n CustomerUpdateDto,\n PasswordChangeDto,\n PasswordResetRequestDto,\n PasswordUpdate,\n AddressCreateDto,\n AddressUpdateDto,\n} from \"../generated/customer\";\n\n/**\n * Caller-owned customer session. Maps the Emporix `CustomerToken` wire shape to\n * idiomatic names: `access_token` → `customerToken`, `saas_token` →\n * `saasToken`. `saasToken` is a JWT required for the checkout (`saas-token`\n * header). The wire's `*_token` (snake_case) fields are canonical; the\n * camelCase variants are deprecated in the Emporix spec.\n */\nexport interface CustomerSession {\n customerToken: string;\n /** JWT required for completing checkout (sent as the `saas-token` header). */\n saasToken: string;\n refreshToken: string;\n /** Same session as the anonymous token — preserves the cart across login. */\n sessionId: string | undefined;\n /** Customer access-token lifetime in seconds. */\n expiresIn: number | undefined;\n /** Only set by `socialLogin`: the IdP access token echoed by Emporix. */\n socialAccessToken?: string;\n /** Only set by `socialLogin`: the IdP ID token echoed by Emporix. */\n socialIdToken?: string;\n}\n\n/** Customer profile as returned by the Customer service (all generated fields). */\nexport type Customer = GeneratedCustomer;\n\n/** A customer address as returned by the Customer service (all generated fields). */\nexport type Address = GeneratedAddress;\n\n/** Generated request bodies (caller sends the exact wire shape). */\nexport type CustomerSignupInput = CustomerSignup;\nexport type CustomerUpdateInput = CustomerUpdateDto;\nexport type PasswordChangeInput = PasswordChangeDto;\nexport type PasswordResetRequestInput = PasswordResetRequestDto;\nexport type PasswordResetConfirmInput = PasswordUpdate;\nexport type AddressCreateInput = AddressCreateDto;\nexport type AddressUpdateInput = AddressUpdateDto;\n\n/** Union of the wire shapes the four session endpoints return. snake_case is\n * canonical; camelCase is the deprecated fallback (vendored spec, design §2). */\ninterface WireSession {\n access_token?: string;\n saas_token?: string;\n refresh_token?: string;\n session_id?: string;\n expires_in?: string | number;\n accessToken?: string;\n saasToken?: string;\n refreshToken?: string;\n social_access_token?: string;\n social_id_token?: string;\n}\n\n/** Wire→facade mapping shared by login/refresh/socialLogin/exchangeToken.\n * Throws instead of fabricating an empty session: `customerToken: \"\"` would\n * read as authenticated downstream and 401-loop every subsequent call. */\nfunction toSession(\n endpoint: string,\n wire: WireSession,\n opts: { carrySaasToken?: string } = {},\n): CustomerSession {\n const customerToken = wire.access_token ?? wire.accessToken;\n if (!customerToken) {\n throw new EmporixAuthError(`${endpoint}: response missing access_token`, undefined, wire);\n }\n return {\n customerToken,\n saasToken: wire.saas_token ?? wire.saasToken ?? opts.carrySaasToken ?? \"\",\n refreshToken: wire.refresh_token ?? wire.refreshToken ?? \"\",\n sessionId: wire.session_id,\n expiresIn: wire.expires_in != null ? Number(wire.expires_in) : undefined,\n ...(wire.social_access_token ? { socialAccessToken: wire.social_access_token } : {}),\n ...(wire.social_id_token ? { socialIdToken: wire.social_id_token } : {}),\n };\n}\n\n/** Customer signup, session, profile and addresses. */\nexport class CustomerService {\n static readonly channel = \"customer\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n /** Obtains an anonymous storefront session (accessToken + sessionId + refreshToken). */\n async anonymous(): Promise<AnonymousSession> {\n return this.ctx.tokenProvider.getAnonymousToken();\n }\n\n /** Registers a customer. Default auth: anonymous. */\n async signup(\n input: CustomerSignupInput,\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<Customer> {\n return this.ctx.http.request<Customer>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/signup`,\n auth,\n body: input,\n });\n }\n\n /**\n * Logs a customer in. Threads the anonymous token so the session (and its\n * cart) survives — losing it silently creates a new session per Emporix docs.\n * Wire `accessToken` is mapped to `customerToken`.\n */\n async login(\n creds: { email: string; password: string },\n opts: { anonymousToken?: string } = {},\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<CustomerSession> {\n const effective: AuthContext = opts.anonymousToken\n ? { kind: \"raw\", token: opts.anonymousToken }\n : auth;\n const wire = await this.ctx.http.request<WireSession>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/login`,\n auth: effective,\n body: creds,\n });\n return toSession(\"login\", wire);\n }\n\n /**\n * Refreshes an authenticated customer session via its refresh token,\n * preserving the same `sessionId`. Calls\n * `GET /customer/{tenant}/refreshauthtoken?refreshToken=…`, which **must be\n * authorized with an anonymous token** (default auth: anonymous) — not the\n * expired customer token. The refresh response does **not** include a\n * `saas_token`; pass the original `saasToken` to carry it forward (it has\n * its own, independent lifetime).\n */\n async refresh(\n input: { refreshToken: string; saasToken?: string; legalEntityId?: string },\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<CustomerSession> {\n const query: Record<string, string> = { refreshToken: input.refreshToken };\n if (input.legalEntityId) query.legalEntityId = input.legalEntityId;\n const wire = await this.ctx.http.request<WireSession>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/refreshauthtoken`,\n query,\n auth,\n });\n // Refresh does not return a saas_token — carry the original forward.\n return toSession(\n \"refresh\",\n wire,\n input.saasToken !== undefined ? { carrySaasToken: input.saasToken } : {},\n );\n }\n\n /**\n * Logs the customer out server-side: `GET /customer/{tenant}/logout?\n * accessToken=…` authorized with the customer token. Invalidates the\n * access token (204 No Content). Requires customer/raw auth — the token is\n * sent both as the bearer and the `accessToken` query param (per Emporix).\n */\n async logout(auth?: AuthContext): Promise<void> {\n const ctx = requireCustomer(auth);\n const token = (ctx as { token: string }).token;\n await this.ctx.http.request<void>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/logout`,\n query: { accessToken: token },\n auth: ctx,\n });\n }\n\n /**\n * Authorization-Code SSO: exchanges the IdP `code` for an Emporix customer\n * session via `POST /customer/{tenant}/socialLogin`. The browser performs\n * the IdP redirect itself; the SDK only does this Emporix exchange.\n * Default auth: anonymous (Emporix requires an anonymous Bearer). The\n * response has no `session_id` and returns `expires_in` as a string —\n * normalized to a number here.\n */\n async socialLogin(\n input: { code: string; redirectUri: string; codeVerifier?: string; sessionId?: string },\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<CustomerSession> {\n const query: Record<string, string> = {\n code: input.code,\n redirect_uri: input.redirectUri,\n };\n if (input.codeVerifier) query.code_verifier = input.codeVerifier;\n const wire = await this.ctx.http.request<WireSession>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/socialLogin`,\n query,\n auth,\n ...(input.sessionId ? { headers: { \"session-id\": input.sessionId } } : {}),\n });\n return toSession(\"socialLogin\", wire);\n }\n\n /**\n * RFC 8693 token exchange: exchanges an external IdP JWT for an Emporix\n * customer session via `POST /customer/{tenant}/exchangeauthtoken`.\n * Emporix uses a proprietary query-param wire (not the RFC form body).\n * Default auth: anonymous. `config` selects a site-specific IdP config\n * (multi-site); omit for the tenant default. Returns `session_id` and a\n * fresh `saas_token`; `expires_in` is an integer (normalized anyway).\n */\n async exchangeToken(\n input: { subjectToken: string; config?: string },\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<CustomerSession> {\n const query: Record<string, string> = { subjectAccessToken: input.subjectToken };\n if (input.config) query.config = input.config;\n const wire = await this.ctx.http.request<WireSession>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/exchangeauthtoken`,\n query,\n auth,\n });\n return toSession(\"exchangeToken\", wire);\n }\n\n /** Returns the authenticated customer. Requires customer/raw auth. */\n async me(auth?: AuthContext): Promise<Customer> {\n return this.ctx.http.request<Customer>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/me`,\n auth: requireCustomer(auth),\n });\n }\n\n /** Updates the authenticated customer. Requires customer/raw auth. */\n async update(patch: CustomerUpdateInput, auth?: AuthContext): Promise<Customer> {\n return this.ctx.http.request<Customer>({\n method: \"PUT\",\n path: `/customer/${this.ctx.tenant}/me`,\n auth: requireCustomer(auth),\n body: patch,\n });\n }\n\n /** Changes the password. Requires customer/raw auth. */\n async changePassword(input: PasswordChangeInput, auth?: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/password/change`,\n auth: requireCustomer(auth),\n body: input,\n });\n }\n\n /** Requests a password reset email. Default auth: anonymous. */\n async requestPasswordReset(\n input: PasswordResetRequestInput,\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/password/reset`,\n auth,\n body: input,\n });\n }\n\n /** Confirms a password reset. Default auth: anonymous. */\n async confirmPasswordReset(\n input: PasswordResetConfirmInput,\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/password/reset/update`,\n auth,\n body: input,\n });\n }\n\n /** Address sub-resource. All operations require customer/raw auth. */\n readonly addresses = {\n list: async (auth?: AuthContext): Promise<Address[]> =>\n this.ctx.http.request<Address[]>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/me/addresses`,\n auth: requireCustomer(auth),\n }),\n add: async (address: AddressCreateInput, auth?: AuthContext): Promise<Address> =>\n this.ctx.http.request<Address>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/me/addresses`,\n auth: requireCustomer(auth),\n body: address,\n }),\n update: async (id: string, patch: AddressUpdateInput, auth?: AuthContext): Promise<Address> =>\n this.ctx.http.request<Address>({\n method: \"PUT\",\n path: `/customer/${this.ctx.tenant}/me/addresses/${id}`,\n auth: requireCustomer(auth),\n body: patch,\n }),\n remove: async (id: string, auth?: AuthContext): Promise<void> =>\n this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/customer/${this.ctx.tenant}/me/addresses/${id}`,\n auth: requireCustomer(auth),\n }),\n };\n}\n"]}
|
|
@@ -27,12 +27,14 @@ var ContactsService = class {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
30
|
+
* Updates a contact assignment via `PUT …/contact-assignments/{id}` (upsert /
|
|
31
|
+
* full replace). The live API rejects `PATCH` on this path with 405; send the
|
|
32
|
+
* complete entity, as the server replaces the resource. The body stays typed
|
|
33
|
+
* as a partial of `ContactAssignmentUpdate` for backward compatibility.
|
|
32
34
|
*/
|
|
33
35
|
async update(contactAssignmentId, patch, auth) {
|
|
34
36
|
return this.ctx.http.request({
|
|
35
|
-
method: "
|
|
37
|
+
method: "PUT",
|
|
36
38
|
path: `${this.base()}/${contactAssignmentId}`,
|
|
37
39
|
auth,
|
|
38
40
|
body: patch
|
|
@@ -49,5 +51,5 @@ var ContactsService = class {
|
|
|
49
51
|
};
|
|
50
52
|
|
|
51
53
|
export { ContactsService };
|
|
52
|
-
//# sourceMappingURL=chunk-
|
|
53
|
-
//# sourceMappingURL=chunk-
|
|
54
|
+
//# sourceMappingURL=chunk-HD5RBCM6.js.map
|
|
55
|
+
//# sourceMappingURL=chunk-HD5RBCM6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src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H;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;AACF","file":"chunk-HD5RBCM6.js","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"]}
|
|
@@ -120,22 +120,37 @@ var CartService = class {
|
|
|
120
120
|
auth: requireCartAuth(auth)
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
|
-
/**
|
|
123
|
+
/**
|
|
124
|
+
* Applies a coupon by code. Coupon application goes through the cart's
|
|
125
|
+
* `discounts` endpoint (`POST …/discounts` with a coupon-code-only payload) —
|
|
126
|
+
* the live API has no `…/coupons` path. The apply response only carries the
|
|
127
|
+
* applied-discount reference (`{ discountId, discountIndex }`), so the updated
|
|
128
|
+
* cart is re-fetched and returned to preserve the `Cart` contract.
|
|
129
|
+
*/
|
|
124
130
|
async applyCoupon(cartId, code, auth) {
|
|
125
|
-
|
|
131
|
+
const cartAuth = requireCartAuth(auth);
|
|
132
|
+
await this.ctx.http.request({
|
|
126
133
|
method: "POST",
|
|
127
|
-
path: `${this.base()}/${cartId}/
|
|
128
|
-
auth:
|
|
134
|
+
path: `${this.base()}/${cartId}/discounts`,
|
|
135
|
+
auth: cartAuth,
|
|
129
136
|
body: { code }
|
|
130
137
|
});
|
|
138
|
+
return this.get(cartId, cartAuth);
|
|
131
139
|
}
|
|
132
|
-
/**
|
|
140
|
+
/**
|
|
141
|
+
* Removes a coupon by code via `DELETE …/discounts?codes=<code>` — the live
|
|
142
|
+
* API has no `…/coupons/<code>` path. The delete responds 204 No Content, so
|
|
143
|
+
* the updated cart is re-fetched and returned.
|
|
144
|
+
*/
|
|
133
145
|
async removeCoupon(cartId, code, auth) {
|
|
134
|
-
|
|
146
|
+
const cartAuth = requireCartAuth(auth);
|
|
147
|
+
await this.ctx.http.request({
|
|
135
148
|
method: "DELETE",
|
|
136
|
-
path: `${this.base()}/${cartId}/
|
|
137
|
-
|
|
149
|
+
path: `${this.base()}/${cartId}/discounts`,
|
|
150
|
+
query: { codes: code },
|
|
151
|
+
auth: cartAuth
|
|
138
152
|
});
|
|
153
|
+
return this.get(cartId, cartAuth);
|
|
139
154
|
}
|
|
140
155
|
/** Sets the shipping address. */
|
|
141
156
|
async setShippingAddress(cartId, address, auth) {
|
|
@@ -174,5 +189,5 @@ var CartService = class {
|
|
|
174
189
|
};
|
|
175
190
|
|
|
176
191
|
export { CartService };
|
|
177
|
-
//# sourceMappingURL=chunk-
|
|
178
|
-
//# sourceMappingURL=chunk-
|
|
192
|
+
//# sourceMappingURL=chunk-HUEMYP2L.js.map
|
|
193
|
+
//# sourceMappingURL=chunk-HUEMYP2L.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/cart.ts"],"names":[],"mappings":";;;AAkCA,SAAS,gBAAgB,IAAA,EAA4C;AACnE,EAAA,IAAI,SAAS,IAAA,CAAK,IAAA,KAAS,cAAc,IAAA,CAAK,IAAA,KAAS,cAAc,OAAO,IAAA;AAC5E,EAAA,MAAM,IAAI,sBAAA;AAAA,IACR;AAAA,GACF;AACF;AAEA,SAAS,oBAAoB,IAAA,EAA4C;AACvE,EAAA,IAAI,IAAA,IAAQ,IAAA,CAAK,IAAA,KAAS,UAAA,EAAY,OAAO,IAAA;AAC7C,EAAA,MAAM,IAAI,uBAAuB,wDAAwD,CAAA;AAC3F;AAGO,IAAM,cAAN,MAAkB;AAAA,EAEvB,YAA6B,GAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAAA,EAAqB;AAAA,EAArB,GAAA;AAAA,EAD7B,OAAgB,OAAA,GAAU,MAAA;AAAA,EAGlB,IAAA,GAAe;AACrB,IAAA,OAAO,CAAA,MAAA,EAAS,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,MAAA,CAAA;AAAA,EACjC;AAAA;AAAA,EAGA,MA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;AAAA,MAC9B,IAAA,EAAM,gBAAgB,IAAI,CAAA;AAAA,MAC1B,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,KAAA,CACJ,cAAA,EACA,gBAAA,EACA,IAAA,EACe;AACf,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAc;AAAA,MACjC,MAAA,EAAQ,MAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,cAAc,CAAA,MAAA,CAAA;AAAA,MACtC,IAAA,EAAM,oBAAoB,IAAI,CAAA;AAAA,MAC9B,IAAA,EAAM,EAAE,KAAA,EAAO,gBAAA;AAAiB,KACjC,CAAA;AAAA,EACH;AACF","file":"chunk-HUEMYP2L.js","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport { EmporixNotFoundError, EmporixValidationError } from \"../core/errors\";\nimport type {\n Cart as GeneratedCart,\n CreateCart,\n CreatedCart,\n CartItemRequest,\n UpdateCartItem,\n AddressRequest,\n AppliedDiscount,\n BatchResponse as GeneratedBatchResponse,\n SingleBatchResponse as GeneratedSingleBatchResponse,\n} from \"../generated/cart\";\n\n/** A cart as returned by the Cart service (all generated fields). */\nexport type Cart = GeneratedCart;\n\n/** The cart-create response (`{ cartId, yrn }`, generated). */\nexport type CartCreated = CreatedCart;\n\n/** Generated request bodies (caller sends the exact wire shape). */\nexport type CreateCartInput = CreateCart;\nexport type CartItemInput = CartItemRequest;\nexport type CartItemUpdate = UpdateCartItem;\n\n/** Per-entry result of `addItemsBatch`. `status` is HTTP-style per entry (e.g. 201 = added, 4xx = failed). */\nexport type CartItemBatchEntry = GeneratedSingleBatchResponse;\n/** Response shape of `addItemsBatch` — one entry per input item, matching by `index`. */\nexport type CartItemsBatchResponse = GeneratedBatchResponse;\n\n/** An address payload for cart shipping/billing (generated). */\nexport type CartAddress = AddressRequest;\n\nfunction requireCartAuth(auth: AuthContext | undefined): AuthContext {\n if (auth && (auth.kind === \"customer\" || auth.kind === \"anonymous\")) return auth;\n throw new EmporixValidationError(\n \"CartService requires an explicit { kind: 'customer' } or { kind: 'anonymous' } AuthContext\",\n );\n}\n\nfunction requireCustomerAuth(auth: AuthContext | undefined): AuthContext {\n if (auth && auth.kind === \"customer\") return auth;\n throw new EmporixValidationError(\"cart.merge requires a { kind: 'customer' } AuthContext\");\n}\n\n/** Cart operations. Every method requires an explicit customer/anonymous context. */\nexport class CartService {\n static readonly channel = \"cart\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/cart/${this.ctx.tenant}/carts`;\n }\n\n /** Creates a cart. */\n async create(\n input: CreateCartInput | undefined,\n auth: AuthContext,\n ): Promise<CartCreated> {\n return this.ctx.http.request<CartCreated>({\n method: \"POST\",\n path: this.base(),\n auth: requireCartAuth(auth),\n body: input ?? {},\n });\n }\n\n /** Fetches a cart by id. */\n async get(cartId: string, auth: AuthContext): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"GET\",\n path: `${this.base()}/${cartId}`,\n auth: requireCartAuth(auth),\n });\n }\n\n /** Returns the current cart for the session, or null if none. */\n /**\n * Get the customer / anonymous cart matching the given criteria. Per Emporix:\n * uniqueness is defined by `siteCode` + `type` + `legalEntityId` +\n * (`customerId` derived from a customer token, or `sessionId` derived from an\n * anonymous token). With `create: true`, Emporix creates a new cart if none\n * matches.\n *\n * Returns `null` on 404 (no cart found and `create` was not set). All other\n * errors are propagated.\n */\n async getCurrent(\n auth: AuthContext,\n opts: { siteCode: string; type?: string; legalEntityId?: string; create?: boolean },\n ): Promise<Cart | null> {\n const query: Record<string, string | number> = { siteCode: opts.siteCode };\n if (opts.type !== undefined) query.type = opts.type;\n if (opts.legalEntityId !== undefined) query.legalEntityId = opts.legalEntityId;\n if (opts.create) query.create = \"true\";\n try {\n return await this.ctx.http.request<Cart>({\n method: \"GET\",\n path: this.base(),\n query,\n auth: requireCartAuth(auth),\n });\n } catch (e) {\n if (e instanceof EmporixNotFoundError) return null;\n throw e;\n }\n }\n\n /** Adds an item. */\n async addItem(\n cartId: string,\n item: CartItemInput,\n auth: AuthContext,\n ): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"POST\",\n path: `${this.base()}/${cartId}/items`,\n auth: requireCartAuth(auth),\n body: item,\n });\n }\n\n /**\n * Adds multiple items in a single request via `POST /carts/{id}/itemsBatch`.\n * Server-side limit is 200 entries per call — callers handling larger sets\n * must chunk. The response carries a per-entry `status` (HTTP-style: 201\n * for added, 4xx/5xx for failed) and `index` matching the input position;\n * partial failures do **not** throw — inspect `status` per entry.\n */\n async addItemsBatch(\n cartId: string,\n items: CartItemInput[],\n auth: AuthContext,\n ): Promise<CartItemsBatchResponse> {\n return this.ctx.http.request<CartItemsBatchResponse>({\n method: \"POST\",\n path: `${this.base()}/${cartId}/itemsBatch`,\n auth: requireCartAuth(auth),\n body: items,\n });\n }\n\n /**\n * Updates an item. By default this is a **full replace** — the server expects\n * the complete item (e.g. `itemYrn` + the `price` row). Pass\n * `{ partial: true }` to send a **partial update** (`?partial=true`), e.g. a\n * quantity-only change with just `{ quantity }`.\n */\n async updateItem(\n cartId: string,\n itemId: string,\n patch: CartItemUpdate,\n auth: AuthContext,\n opts: { partial?: boolean } = {},\n ): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"PUT\",\n path: `${this.base()}/${cartId}/items/${itemId}`,\n auth: requireCartAuth(auth),\n body: patch,\n ...(opts.partial ? { query: { partial: \"true\" } } : {}),\n });\n }\n\n /** Removes an item. */\n async removeItem(cartId: string, itemId: string, auth: AuthContext): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"DELETE\",\n path: `${this.base()}/${cartId}/items/${itemId}`,\n auth: requireCartAuth(auth),\n });\n }\n\n /** Empties the cart. */\n async clear(cartId: string, auth: AuthContext): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"DELETE\",\n path: `${this.base()}/${cartId}/items`,\n auth: requireCartAuth(auth),\n });\n }\n\n /**\n * Applies a coupon by code. Coupon application goes through the cart's\n * `discounts` endpoint (`POST …/discounts` with a coupon-code-only payload) —\n * the live API has no `…/coupons` path. The apply response only carries the\n * applied-discount reference (`{ discountId, discountIndex }`), so the updated\n * cart is re-fetched and returned to preserve the `Cart` contract.\n */\n async applyCoupon(cartId: string, code: string, auth: AuthContext): Promise<Cart> {\n const cartAuth = requireCartAuth(auth);\n await this.ctx.http.request<AppliedDiscount>({\n method: \"POST\",\n path: `${this.base()}/${cartId}/discounts`,\n auth: cartAuth,\n body: { code },\n });\n return this.get(cartId, cartAuth);\n }\n\n /**\n * Removes a coupon by code via `DELETE …/discounts?codes=<code>` — the live\n * API has no `…/coupons/<code>` path. The delete responds 204 No Content, so\n * the updated cart is re-fetched and returned.\n */\n async removeCoupon(cartId: string, code: string, auth: AuthContext): Promise<Cart> {\n const cartAuth = requireCartAuth(auth);\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${cartId}/discounts`,\n query: { codes: code },\n auth: cartAuth,\n });\n return this.get(cartId, cartAuth);\n }\n\n /** Sets the shipping address. */\n async setShippingAddress(\n cartId: string,\n address: CartAddress,\n auth: AuthContext,\n ): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"PUT\",\n path: `${this.base()}/${cartId}/shipping-address`,\n auth: requireCartAuth(auth),\n body: address,\n });\n }\n\n /** Sets the billing address. */\n async setBillingAddress(\n cartId: string,\n address: CartAddress,\n auth: AuthContext,\n ): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"PUT\",\n path: `${this.base()}/${cartId}/billing-address`,\n auth: requireCartAuth(auth),\n body: address,\n });\n }\n\n /**\n * Merges one or more anonymous carts into the specified customer cart.\n * Per Emporix: the target cart in the path **must belong to the logged-in\n * customer**, and each id in `anonymousCartIds` must belong to an anonymous\n * customer. Anonymous carts go `CLOSED` on success.\n *\n * Requires a customer `AuthContext`.\n */\n async merge(\n customerCartId: string,\n anonymousCartIds: string[],\n auth: AuthContext,\n ): Promise<Cart> {\n return this.ctx.http.request<Cart>({\n method: \"POST\",\n path: `${this.base()}/${customerCartId}/merge`,\n auth: requireCustomerAuth(auth),\n body: { carts: anonymousCartIds },\n });\n }\n}\n"]}
|
|
@@ -35,12 +35,14 @@ var LocationsService = class {
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
38
|
+
* Updates a location via `PUT …/locations/{id}` (upsert / full replace). The
|
|
39
|
+
* live API rejects `PATCH` on this path with 405; send the complete entity,
|
|
40
|
+
* as the server replaces the resource. The body stays typed as a partial of
|
|
41
|
+
* `LocationUpdate` for backward compatibility.
|
|
40
42
|
*/
|
|
41
43
|
async update(locationId, patch, auth) {
|
|
42
44
|
return this.ctx.http.request({
|
|
43
|
-
method: "
|
|
45
|
+
method: "PUT",
|
|
44
46
|
path: `${this.base()}/${locationId}`,
|
|
45
47
|
auth,
|
|
46
48
|
body: patch
|
|
@@ -57,5 +59,5 @@ var LocationsService = class {
|
|
|
57
59
|
};
|
|
58
60
|
|
|
59
61
|
export { LocationsService };
|
|
60
|
-
//# sourceMappingURL=chunk-
|
|
61
|
-
//# sourceMappingURL=chunk-
|
|
62
|
+
//# sourceMappingURL=chunk-IAOWDMTA.js.map
|
|
63
|
+
//# sourceMappingURL=chunk-IAOWDMTA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/locations.ts"],"names":[],"mappings":";AAeO,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,I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,EACH;AAAA;AAAA,EAGA,MAAM,MAAA,CAAO,UAAA,EAAoB,IAAA,EAAkC;AACjE,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,UAAU,CAAA,CAAA;AAAA,MAClC;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"chunk-IAOWDMTA.js","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type {\n Location,\n LocationCreate,\n LocationUpdate,\n} from \"../generated/customer-management\";\n\n/**\n * Manages locations owned by a legal entity. Three types are supported:\n * HEADQUARTER, WAREHOUSE, OFFICE.\n *\n * Reads require `customermanagement.location_read`; mutations require\n * `_manage`.\n */\nexport class LocationsService {\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}/locations`;\n }\n\n /** Lists locations owned by one legal entity. */\n async listForCompany(legalEntityId: string, auth: AuthContext): Promise<Location[]> {\n return this.ctx.http.request<Location[]>({\n method: \"GET\",\n path: this.base(),\n query: { legalEntityId },\n auth,\n });\n }\n\n /** Fetches one location by id. */\n async get(locationId: string, auth: AuthContext): Promise<Location> {\n return this.ctx.http.request<Location>({\n method: \"GET\",\n path: `${this.base()}/${locationId}`,\n auth,\n });\n }\n\n /** Creates a location for a legal entity. */\n async create(input: LocationCreate, 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 location via `PUT …/locations/{id}` (upsert / full replace). The\n * live API rejects `PATCH` on this path with 405; send the complete entity,\n * as the server replaces the resource. The body stays typed as a partial of\n * `LocationUpdate` for backward compatibility.\n */\n async update(\n locationId: string,\n patch: Partial<LocationUpdate>,\n auth: AuthContext,\n ): Promise<Location> {\n return this.ctx.http.request<Location>({\n method: \"PUT\",\n path: `${this.base()}/${locationId}`,\n auth,\n body: patch,\n });\n }\n\n /** Deletes a location. */\n async delete(locationId: string, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${locationId}`,\n auth,\n });\n }\n}\n"]}
|
package/dist/companies.cjs
CHANGED
|
@@ -36,12 +36,14 @@ var CompaniesService = class {
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
39
|
+
* Updates a legal entity via `PUT …/legal-entities/{id}` (upsert / full
|
|
40
|
+
* replace). The live API rejects `PATCH` on this path with 405; send the
|
|
41
|
+
* complete entity, as the server replaces the resource. The body stays typed
|
|
42
|
+
* as a partial of `LegalEntityUpdate` for backward compatibility.
|
|
41
43
|
*/
|
|
42
44
|
async update(legalEntityId, patch, auth) {
|
|
43
45
|
return this.ctx.http.request({
|
|
44
|
-
method: "
|
|
46
|
+
method: "PUT",
|
|
45
47
|
path: `${this.base()}/${legalEntityId}`,
|
|
46
48
|
auth,
|
|
47
49
|
body: patch
|