@viu/emporix-sdk 4.6.7 → 4.7.1
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 +30 -0
- package/dist/availability.cjs.map +1 -1
- package/dist/availability.js +2 -2
- package/dist/cart.cjs +3 -0
- package/dist/cart.cjs.map +1 -1
- package/dist/cart.js +2 -2
- package/dist/checkout.cjs.map +1 -1
- package/dist/checkout.js +2 -2
- package/dist/{chunk-J2AN2FMK.js → chunk-3JO2O4BY.js} +25 -14
- package/dist/chunk-3JO2O4BY.js.map +1 -0
- package/dist/{chunk-UWGGF4MC.js → chunk-4Q76UV4J.js} +6 -3
- package/dist/chunk-4Q76UV4J.js.map +1 -0
- package/dist/{chunk-RYQVMR26.js → chunk-BHNYGUSD.js} +3 -3
- package/dist/{chunk-RYQVMR26.js.map → chunk-BHNYGUSD.js.map} +1 -1
- package/dist/{chunk-IYNT5BQW.js → chunk-CXTVY4SI.js} +8 -4
- package/dist/chunk-CXTVY4SI.js.map +1 -0
- package/dist/{chunk-K4KXT6NX.js → chunk-ENMMDGUB.js} +3 -3
- package/dist/{chunk-K4KXT6NX.js.map → chunk-ENMMDGUB.js.map} +1 -1
- package/dist/{chunk-UA4BM6OP.js → chunk-EQE5WGME.js} +4 -4
- package/dist/{chunk-UA4BM6OP.js.map → chunk-EQE5WGME.js.map} +1 -1
- package/dist/{chunk-4VRUMCS2.js → chunk-PK4DQHJO.js} +4 -4
- package/dist/{chunk-4VRUMCS2.js.map → chunk-PK4DQHJO.js.map} +1 -1
- package/dist/{chunk-NFSO7WUA.js → chunk-SIGXBN4F.js} +3 -3
- package/dist/{chunk-NFSO7WUA.js.map → chunk-SIGXBN4F.js.map} +1 -1
- package/dist/{chunk-N2CE3J4M.js → chunk-U3ZIJZYH.js} +3 -3
- package/dist/{chunk-N2CE3J4M.js.map → chunk-U3ZIJZYH.js.map} +1 -1
- package/dist/{chunk-S2ERKGYL.js → chunk-ZLGLI4KC.js} +3 -3
- package/dist/{chunk-S2ERKGYL.js.map → chunk-ZLGLI4KC.js.map} +1 -1
- package/dist/{chunk-3BDDYX3V.js → chunk-ZVIEFW3X.js} +3 -3
- package/dist/{chunk-3BDDYX3V.js.map → chunk-ZVIEFW3X.js.map} +1 -1
- package/dist/{chunk-XQAOHHXL.js → chunk-ZZ3X3DDL.js} +3 -3
- package/dist/{chunk-XQAOHHXL.js.map → chunk-ZZ3X3DDL.js.map} +1 -1
- package/dist/customer.cjs.map +1 -1
- package/dist/customer.js +3 -3
- package/dist/index.cjs +62 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +137 -42
- package/dist/index.d.ts +137 -42
- package/dist/index.js +52 -38
- package/dist/index.js.map +1 -1
- package/dist/media.cjs +3 -0
- package/dist/media.cjs.map +1 -1
- package/dist/media.js +2 -2
- package/dist/orders.cjs +6 -2
- package/dist/orders.cjs.map +1 -1
- package/dist/orders.d.cts +6 -2
- package/dist/orders.d.ts +6 -2
- package/dist/orders.js +1 -1
- package/dist/payment.cjs.map +1 -1
- package/dist/payment.js +3 -3
- package/dist/price.cjs.map +1 -1
- package/dist/price.js +2 -2
- package/dist/product.cjs +23 -12
- package/dist/product.cjs.map +1 -1
- package/dist/product.d.cts +197 -14
- package/dist/product.d.ts +197 -14
- package/dist/product.js +1 -1
- package/dist/segment.cjs.map +1 -1
- package/dist/segment.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-IYNT5BQW.js.map +0 -1
- package/dist/chunk-J2AN2FMK.js.map +0 -1
- package/dist/chunk-UWGGF4MC.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/product.ts"],"names":[],"mappings":";;;;;AA4BA,IAAM,IAAA,GAAoB,EAAE,IAAA,EAAM,WAAA,EAAY;AAC9C,IAAM,OAAA,GAAuB,EAAE,IAAA,EAAM,SAAA,EAAU;AA8ExC,IAAM,iBAAN,MAAqB;AAAA,EAE1B,YAA6B,GAAA,E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K,GAAA,CAAI,IAAA,CAAK,OAAA,CAAc;AAAA,QAChC,MAAA,EAAQ,QAAA;AAAA,QACR,MAAM,CAAA,SAAA,EAAY,IAAA,CAAK,GAAA,CAAI,MAAM,sBAAsB,UAAU,CAAA,CAAA;AAAA,QACjE;AAAA,OACD,CAAA;AAAA,IACH;AAAA,GACF;AACF","file":"chunk-3JO2O4BY.js","sourcesContent":["import type { ClientContext, PaginatedItems } from \"../core/context\";\nimport { iterateAll } from \"../core/context\";\nimport { requestPage } from \"../core/paged\";\nimport type { AuthContext } from \"../core/auth\";\nimport { resolveQuery, type QueryFor } from \"../core/query\";\nimport type {\n BasicProductWithId,\n BundleProductWithId,\n ParentVariantProductWithId,\n VariantProductWithId,\n DynamicVariantProductWithId,\n ProductMedia,\n ProductCreateBody,\n ProductUpdateBody,\n ProductPartialUpdateBody,\n ProductBulkCreateBody,\n ProductBulkUpdateBody,\n BulkResponse,\n ResourceLocation,\n DynamicVariantRecalculationRequest,\n DynamicVariantRecalculationResponse,\n DynamicVariantRecalculationJobResponse,\n DynamicVariantRecalculationJobStatus,\n ProductTemplateResponse,\n ProductTemplateCreation,\n ProductTemplateUpdate,\n} from \"../generated/product\";\n\nconst ANON: AuthContext = { kind: \"anonymous\" };\nconst SERVICE: AuthContext = { kind: \"service\" };\n\n/** A product as returned by the Product service (all generated fields). */\nexport type Product =\n | BasicProductWithId\n | BundleProductWithId\n | ParentVariantProductWithId\n | ProductVariant;\n\n/**\n * A product below a parent: a `VARIANT` of a `PARENT_VARIANT` (`parentVariantId`),\n * or a `DYNAMIC_VARIANT` of any level (`parentVariantId` is the direct parent,\n * `parentVariantPath` lists every ancestor up to the root).\n */\nexport type ProductVariant = VariantProductWithId | DynamicVariantProductWithId;\n\n/** A single product media entry (generated; `ProductMedia` is the list type). */\nexport type Media = ProductMedia[number];\n\n/** Body for creating a product (`POST /products`) — any of the 5 product shapes. */\nexport type ProductCreateInput = ProductCreateBody;\n\n/** Body for a full product replace (`PUT /products/{id}`). */\nexport type ProductUpdateInput = ProductUpdateBody;\n\n/** Body for a partial product update (`PATCH /products/{id}`). */\nexport type ProductPatchInput = ProductPartialUpdateBody;\n\n/** Id/location envelope returned when a product is created. */\nexport type ProductCreated = ResourceLocation;\n\n/** Body for bulk-creating products (`POST /products/bulk`). */\nexport type ProductBulkCreateInput = ProductBulkCreateBody;\n\n/** Body for bulk-updating products (`PUT /products/bulk`). */\nexport type ProductBulkUpdateInput = ProductBulkUpdateBody;\n\n/** Per-entry result of a bulk product operation (207 Multi-Status). */\nexport type ProductBulkResult = BulkResponse;\n\n/** Body for triggering a dynamic-variant recalculation. */\nexport type ProductRecalculationInput = DynamicVariantRecalculationRequest;\n\n/** Result of triggering a recalculation — created jobs plus skipped product ids. */\nexport type ProductRecalculationResult = DynamicVariantRecalculationResponse;\n\n/** A dynamic-variant recalculation job. */\nexport type ProductRecalculationJob = DynamicVariantRecalculationJobResponse;\n\n/** Status of a recalculation job. */\nexport type ProductRecalculationJobStatus = DynamicVariantRecalculationJobStatus;\n\n/** A product template as returned by the Product service. */\nexport type ProductTemplate = ProductTemplateResponse;\n\n/** Body for creating a product template. */\nexport type ProductTemplateCreateInput = ProductTemplateCreation;\n\n/** Body for updating a product template (`PUT`, full replace). */\nexport type ProductTemplateUpdateInput = ProductTemplateUpdate;\n\n/** Id envelope returned when a product template is created. */\nexport type ProductTemplateCreated = { id?: string };\n\n/** Options shared by the product write endpoints. */\nexport interface ProductWriteOptions {\n skipVariantGeneration?: boolean;\n doIndex?: boolean;\n skipRelatedItemsValidation?: boolean;\n /**\n * `Content-Language` for this call, overriding `EmporixConfig.contentLanguage`:\n * `\"*\"` when `name`, `description` and the other localized fields are maps of\n * translations, a language code such as `\"de\"` when they are plain strings.\n */\n contentLanguage?: string;\n}\n\n/** Catalog reads. Default auth: anonymous; pass customer for personalized pricing. */\nexport class ProductService {\n static readonly channel = \"product\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n /** Fetches one product by id. */\n async get(productId: string, auth?: AuthContext): Promise<Product>;\n /** @deprecated The second parameter is unused — pass the auth context second: `get(id, auth)`. */\n async get(productId: string, opts: Record<string, never> | undefined, auth?: AuthContext): Promise<Product>;\n async get(\n productId: string,\n authOrOpts?: AuthContext | Record<string, never>,\n legacyAuth?: AuthContext,\n ): Promise<Product> {\n // The legacy options slot is `{}` or `undefined`; an auth context always has a `kind`.\n const auth =\n legacyAuth ?? (authOrOpts !== undefined && \"kind\" in authOrOpts ? (authOrOpts as AuthContext) : ANON);\n return this.ctx.http.request<Product>({\n method: \"GET\",\n path: `/product/${this.ctx.tenant}/products/${productId}`,\n auth,\n });\n }\n\n /** Fetches one product by its code. */\n async getByCode(code: string, auth: AuthContext = ANON): Promise<Product> {\n const rows = await this.ctx.http.request<Product[]>({\n method: \"GET\",\n path: `/product/${this.ctx.tenant}/products`,\n query: { q: `code:${code}` },\n auth,\n });\n const first = rows[0];\n if (!first) throw new Error(`No product with code \"${code}\"`);\n return first;\n }\n\n /** One page of products. */\n async list(\n params: { pageNumber?: number; pageSize?: number; totalCount?: boolean } = {},\n auth: AuthContext = ANON,\n ): Promise<PaginatedItems<Product>> {\n const pageNumber = params.pageNumber ?? 1;\n const pageSize = params.pageSize ?? 50;\n return requestPage<Product>(\n this.ctx.http,\n {\n method: \"GET\",\n path: `/product/${this.ctx.tenant}/products`,\n query: { pageNumber, pageSize },\n auth,\n },\n {\n pageNumber,\n pageSize,\n ...(params.totalCount === undefined ? {} : { totalCount: params.totalCount }),\n },\n );\n }\n\n /** Async-iterates every product across pages. */\n listAll(params: { pageSize?: number } = {}, auth: AuthContext = ANON): AsyncIterable<Product> {\n const pageSize = params.pageSize ?? 50;\n return iterateAll<Product>((pageNumber) => this.list({ pageNumber, pageSize }, auth));\n }\n\n /**\n * Searches products by a `q` filter — a raw Emporix DSL string or a built\n * filter (e.g. `@viu/emporix-mixins`' `mixinQuery(...)`). Product supports\n * `compoundLogicalQuery`, so `or()` filters are allowed.\n */\n async search(\n query: QueryFor<\"PRODUCT\">,\n params: { pageNumber?: number; pageSize?: number; totalCount?: boolean } = {},\n auth: AuthContext = ANON,\n ): Promise<PaginatedItems<Product>> {\n const q = resolveQuery(query, { compoundLogicalQuery: true });\n const pageNumber = params.pageNumber ?? 1;\n const pageSize = params.pageSize ?? 50;\n return requestPage<Product>(\n this.ctx.http,\n {\n method: \"GET\",\n path: `/product/${this.ctx.tenant}/products`,\n query: { q, pageNumber, pageSize },\n auth,\n },\n {\n pageNumber,\n pageSize,\n ...(params.totalCount === undefined ? {} : { totalCount: params.totalCount }),\n },\n );\n }\n\n /**\n * Free-text product search by name. The product `q` is a `field:value` DSL,\n * so a bare term (e.g. \"in time\") 400s with \"No value for key …\". This builds\n * a `name:(~<term>)` regex filter (regex metacharacters escaped) and delegates\n * to {@link search}.\n *\n * Safe for text a shopper typed: `( ) \"` are **removed** rather than escaped,\n * because Emporix parses the filter's own structure before it looks at the\n * regex. `name:(~a \\()` is rejected with «Missing closing parenthesis in value»\n * even though the paren is escaped, so a search box would 400 on an opening\n * bracket. Measured against a live tenant on 2026-08-03: of every regex\n * metacharacter only those three break; the rest survive escaping.\n *\n * A query consisting solely of those characters leaves nothing to search for and\n * returns an empty page without a request — `name:(~)` is a 400.\n */\n async searchByName(\n query: string,\n // Makes no request of its own — `totalCount` is here purely so it can be\n // forwarded to `search`, which is where the header actually gets sent.\n params: { pageNumber?: number; pageSize?: number; totalCount?: boolean } = {},\n auth: AuthContext = ANON,\n ): Promise<PaginatedItems<Product>> {\n // Replaced by a space rather than dropped, so «Access(JIT)» does not become\n // one run-together word — and then collapsed, because a leftover double space\n // is two LITERAL spaces in the regex and would match nothing.\n const term = query\n .replace(/[()\"]/g, \" \")\n .replace(/\\s+/g, \" \")\n .trim();\n if (term === \"\") {\n // Defaults mirror `search`, so the shape matches a real answer.\n return {\n items: [],\n pageNumber: params.pageNumber ?? 1,\n pageSize: params.pageSize ?? 50,\n hasNextPage: false,\n };\n }\n const escaped = term.replace(/[.*+?^${}|[\\]\\\\]/g, \"\\\\$&\");\n return this.search(`name:(~${escaped})`, params, auth);\n }\n\n /**\n * Bulk fetch by id. POSTs `/products/search` with `q=\"id:(id1,id2,…)\"`,\n * chunking when the list is larger than `options.chunkSize` (default\n * 100). An empty list short-circuits with no HTTP call. **Order is not\n * guaranteed** across chunks — re-index by `id` if order matters.\n */\n async searchByIds(\n ids: string[],\n options: { chunkSize?: number } = {},\n auth: AuthContext = ANON,\n ): Promise<Product[]> {\n if (ids.length === 0) return [];\n const chunkSize = options.chunkSize ?? 100;\n const chunks: string[][] = [];\n for (let i = 0; i < ids.length; i += chunkSize) {\n chunks.push(ids.slice(i, i + chunkSize));\n }\n const pages = await Promise.all(\n chunks.map((chunk) =>\n this.ctx.http.request<Product[]>({\n method: \"POST\",\n path: `/product/${this.ctx.tenant}/products/search`,\n query: { pageSize: chunk.length },\n auth,\n body: { q: `id:(${chunk.join(\",\")})` },\n idempotent: true, // pure read over POST — safe to replay on 5xx/429\n }),\n ),\n );\n return pages.flat();\n }\n\n /**\n * Bulk fetch by code. POSTs `/products/search` with `q=\"code:(c1,c2,…)\"`,\n * chunking when the list is larger than `options.chunkSize` (default 100).\n * Duplicate codes are de-duplicated. Codes containing query-delimiter\n * characters (`(`, `)`, `,`, whitespace, `\"`) are dropped with a logged\n * warning, because the Emporix `q` syntax uses them as delimiters and does\n * not support escaping them in a plain IN-list. An empty list — or one with\n * no safe codes — short-circuits with no HTTP call. **Order is not\n * guaranteed** across chunks — re-index by `code` if order matters.\n */\n async searchByCodes(\n codes: string[],\n options: { chunkSize?: number } = {},\n auth: AuthContext = ANON,\n ): Promise<Product[]> {\n const unique = [...new Set(codes)];\n const unsafe = /[(),\"\\s]/;\n const safe = unique.filter((c) => !unsafe.test(c));\n const dropped = unique.filter((c) => unsafe.test(c));\n if (dropped.length > 0) {\n this.ctx.logger.warn(\n \"products.searchByCodes: dropped codes containing query-delimiter characters\",\n { dropped },\n );\n }\n if (safe.length === 0) return [];\n const chunkSize = options.chunkSize ?? 100;\n const chunks: string[][] = [];\n for (let i = 0; i < safe.length; i += chunkSize) {\n chunks.push(safe.slice(i, i + chunkSize));\n }\n const pages = await Promise.all(\n chunks.map((chunk) =>\n this.ctx.http.request<Product[]>({\n method: \"POST\",\n path: `/product/${this.ctx.tenant}/products/search`,\n query: { pageSize: chunk.length },\n auth,\n body: { q: `code:(${chunk.join(\",\")})` },\n idempotent: true, // pure read over POST — safe to replay on 5xx/429\n }),\n ),\n );\n return pages.flat();\n }\n\n /**\n * Streams the variants below a product, page by page, in two searches: the\n * VARIANT children of a PARENT_VARIANT (`productType:VARIANT\n * parentVariantId:<id>`), then the DYNAMIC_VARIANT descendants of every level\n * (`parentVariantPath:<id>` — every ancestor is in the path). Only one of the\n * two finds anything for a given product. Default pageSize 200. The query\n * syntax (space-separated fields = implicit AND) is encapsulated here so\n * consumers don't build it themselves.\n */\n async *listVariantChildrenAll(\n parentVariantId: string,\n params: { pageSize?: number } = {},\n auth: AuthContext = ANON,\n ): AsyncIterable<ProductVariant> {\n const pageSize = params.pageSize ?? 200;\n for (const q of [\n `productType:VARIANT parentVariantId:${parentVariantId}`,\n `parentVariantPath:${parentVariantId}`,\n ]) {\n // Both queries can only match variants.\n yield* iterateAll((pageNumber) =>\n this.search(q, { pageNumber, pageSize }, auth) as Promise<PaginatedItems<ProductVariant>>,\n );\n }\n }\n\n /**\n * Resolves every variant below a product into a flat array (loads every\n * page): the VARIANT children of a PARENT_VARIANT, or the DYNAMIC_VARIANT\n * descendants of all levels — tell them apart by `parentVariantId` (the\n * direct parent) or pick the purchasable ones by `sellable`. Default pageSize\n * 200. Returns `[]` when there are none — never throws.\n */\n async listVariantChildren(\n parentVariantId: string,\n params: { pageSize?: number } = {},\n auth: AuthContext = ANON,\n ): Promise<ProductVariant[]> {\n const out: ProductVariant[] = [];\n for await (const child of this.listVariantChildrenAll(parentVariantId, params, auth)) {\n out.push(child);\n }\n return out;\n }\n\n // --- Admin writes. Default auth: service. ---\n\n /**\n * Creates a product (`POST /products`). Default auth: service. Accepts any of\n * the five product shapes (basic, bundle, parent-variant, variant,\n * dynamic-variant).\n */\n async create(\n input: ProductCreateInput,\n options: ProductWriteOptions = {},\n auth: AuthContext = SERVICE,\n ): Promise<ProductCreated> {\n const query = {\n ...(options.skipVariantGeneration === undefined ? {} : { skipVariantGeneration: String(options.skipVariantGeneration) }),\n ...(options.doIndex === undefined ? {} : { doIndex: String(options.doIndex) }),\n ...(options.skipRelatedItemsValidation === undefined ? {} : { skipRelatedItemsValidation: String(options.skipRelatedItemsValidation) }),\n };\n return this.ctx.http.request<ProductCreated>({\n method: \"POST\",\n path: `/product/${this.ctx.tenant}/products`,\n ...(Object.keys(query).length > 0 ? { query } : {}),\n ...(options.contentLanguage === undefined\n ? {}\n : { headers: { \"Content-Language\": options.contentLanguage } }),\n body: input,\n auth,\n });\n }\n\n /**\n * Partially updates a product (`PATCH /products/{productId}`). Default auth:\n * service. Use {@link replace} for a full replace (PUT).\n *\n * Omitted fields stay as they are. **Mixins merge rather than replace**, and\n * the corollary catches people out: there is no way to delete a mixin here.\n * - a mixin name you omit stays on the product;\n * - fields you send inside a mixin are merged recursively, and fields you\n * omit inside that mixin keep their values;\n * - `null` does **not** delete a mixin — it stores `null` as its value.\n *\n * To actually remove one, read the product and send it back through\n * {@link replace} with `partial: false`, leaving the mixin out of both\n * `mixins` and `metadata.mixins`.\n *\n * Despite the HTTP verb this is **not** a JSON-Patch endpoint: an op-array of\n * `{ op, path, value }` is rejected. Send a partial product document.\n */\n async update(\n productId: string,\n input: ProductPatchInput,\n options: ProductWriteOptions = {},\n auth: AuthContext = SERVICE,\n ): Promise<void> {\n const query = {\n ...(options.skipVariantGeneration === undefined ? {} : { skipVariantGeneration: String(options.skipVariantGeneration) }),\n ...(options.doIndex === undefined ? {} : { doIndex: String(options.doIndex) }),\n ...(options.skipRelatedItemsValidation === undefined ? {} : { skipRelatedItemsValidation: String(options.skipRelatedItemsValidation) }),\n };\n await this.ctx.http.request<void>({\n method: \"PATCH\",\n path: `/product/${this.ctx.tenant}/products/${productId}`,\n ...(Object.keys(query).length > 0 ? { query } : {}),\n ...(options.contentLanguage === undefined\n ? {}\n : { headers: { \"Content-Language\": options.contentLanguage } }),\n body: input,\n auth,\n });\n }\n\n /**\n * Full-replaces a product (`PUT /products/{productId}`). Returns the created\n * resource on 201 (upsert) and nothing on 204. `options.partial` sends\n * `?partial=true` for a merge-style replace. Default auth: service.\n *\n * With `partial: false` (the default) the body must be the **complete**\n * product document, and any mixin name missing from it is removed — which is\n * what makes this the only way to delete a mixin, since {@link update} merges\n * them. The flip side is that a body you did not build from a fresh read will\n * silently drop mixins.\n */\n async replace(\n productId: string,\n input: ProductUpdateInput,\n options: ProductWriteOptions & { partial?: boolean } = {},\n auth: AuthContext = SERVICE,\n ): Promise<ProductCreated | void> {\n const query = {\n ...(options.partial === undefined ? {} : { partial: String(options.partial) }),\n ...(options.skipVariantGeneration === undefined ? {} : { skipVariantGeneration: String(options.skipVariantGeneration) }),\n ...(options.doIndex === undefined ? {} : { doIndex: String(options.doIndex) }),\n ...(options.skipRelatedItemsValidation === undefined ? {} : { skipRelatedItemsValidation: String(options.skipRelatedItemsValidation) }),\n };\n return this.ctx.http.request<ProductCreated | void>({\n method: \"PUT\",\n path: `/product/${this.ctx.tenant}/products/${productId}`,\n ...(Object.keys(query).length > 0 ? { query } : {}),\n ...(options.contentLanguage === undefined\n ? {}\n : { headers: { \"Content-Language\": options.contentLanguage } }),\n body: input,\n auth,\n });\n }\n\n /**\n * Deletes a product (`DELETE /products/{productId}`). `options.force` deletes\n * even when the product is referenced. Default auth: service.\n */\n async delete(\n productId: string,\n options: { force?: boolean; doIndex?: boolean } = {},\n auth: AuthContext = SERVICE,\n ): Promise<void> {\n const query = {\n ...(options.force === undefined ? {} : { force: String(options.force) }),\n ...(options.doIndex === undefined ? {} : { doIndex: String(options.doIndex) }),\n };\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/product/${this.ctx.tenant}/products/${productId}`,\n ...(Object.keys(query).length > 0 ? { query } : {}),\n auth,\n });\n }\n\n /**\n * Bulk-creates products (`POST /products/bulk`). Responds 207 Multi-Status:\n * partial failures do **not** throw — inspect each entry. Default auth: service.\n */\n async bulkCreate(\n input: ProductBulkCreateInput,\n options: ProductWriteOptions = {},\n auth: AuthContext = SERVICE,\n ): Promise<ProductBulkResult[]> {\n const query = {\n ...(options.skipVariantGeneration === undefined ? {} : { skipVariantGeneration: String(options.skipVariantGeneration) }),\n ...(options.doIndex === undefined ? {} : { doIndex: String(options.doIndex) }),\n ...(options.skipRelatedItemsValidation === undefined ? {} : { skipRelatedItemsValidation: String(options.skipRelatedItemsValidation) }),\n };\n return this.ctx.http.request<ProductBulkResult[]>({\n method: \"POST\",\n path: `/product/${this.ctx.tenant}/products/bulk`,\n ...(Object.keys(query).length > 0 ? { query } : {}),\n ...(options.contentLanguage === undefined\n ? {}\n : { headers: { \"Content-Language\": options.contentLanguage } }),\n body: input,\n auth,\n });\n }\n\n /**\n * Bulk-updates products (`PUT /products/bulk`). Responds 207 Multi-Status:\n * partial failures do **not** throw — inspect each entry. Default auth: service.\n */\n async bulkUpdate(\n input: ProductBulkUpdateInput,\n options: ProductWriteOptions = {},\n auth: AuthContext = SERVICE,\n ): Promise<ProductBulkResult[]> {\n const query = {\n ...(options.skipVariantGeneration === undefined ? {} : { skipVariantGeneration: String(options.skipVariantGeneration) }),\n ...(options.doIndex === undefined ? {} : { doIndex: String(options.doIndex) }),\n ...(options.skipRelatedItemsValidation === undefined ? {} : { skipRelatedItemsValidation: String(options.skipRelatedItemsValidation) }),\n };\n return this.ctx.http.request<ProductBulkResult[]>({\n method: \"PUT\",\n path: `/product/${this.ctx.tenant}/products/bulk`,\n ...(Object.keys(query).length > 0 ? { query } : {}),\n ...(options.contentLanguage === undefined\n ? {}\n : { headers: { \"Content-Language\": options.contentLanguage } }),\n body: input,\n auth,\n });\n }\n\n /**\n * Triggers a dynamic-variant recalculation for the given product ids\n * (`POST /products/recalculate`, 202). The result carries the created or\n * already-referenced `jobs` plus `skippedProductIds` — products whose root\n * already has a PENDING/PROCESSING job. Default auth: service.\n */\n async recalculate(\n input: ProductRecalculationInput,\n auth: AuthContext = SERVICE,\n ): Promise<ProductRecalculationResult> {\n return this.ctx.http.request<ProductRecalculationResult>({\n method: \"POST\",\n path: `/product/${this.ctx.tenant}/products/recalculate`,\n body: input,\n auth,\n });\n }\n\n /** Lists dynamic-variant recalculation jobs, optionally filtered by status. Default auth: anonymous. */\n async listRecalculationJobs(\n params: { status?: ProductRecalculationJobStatus } = {},\n auth: AuthContext = ANON,\n ): Promise<ProductRecalculationJob[]> {\n return this.ctx.http.request<ProductRecalculationJob[]>({\n method: \"GET\",\n path: `/product/${this.ctx.tenant}/products/recalculate/jobs`,\n ...(params.status === undefined ? {} : { query: { status: params.status } }),\n auth,\n });\n }\n\n /** Fetches one dynamic-variant recalculation job by id. Default auth: anonymous. */\n async getRecalculationJob(jobId: string, auth: AuthContext = ANON): Promise<ProductRecalculationJob> {\n return this.ctx.http.request<ProductRecalculationJob>({\n method: \"GET\",\n path: `/product/${this.ctx.tenant}/products/recalculate/jobs/${jobId}`,\n auth,\n });\n }\n\n /**\n * Product templates (`/product-templates`). Reads default to anonymous,\n * writes to service auth.\n */\n readonly templates = {\n /** One page of product templates. Default auth: anonymous. */\n list: async (\n params: { pageNumber?: number; pageSize?: number; sort?: string; q?: string } = {},\n auth: AuthContext = ANON,\n ): Promise<ProductTemplate[]> =>\n this.ctx.http.request<ProductTemplate[]>({\n method: \"GET\",\n path: `/product/${this.ctx.tenant}/product-templates`,\n query: {\n ...(params.pageNumber === undefined ? {} : { pageNumber: params.pageNumber }),\n ...(params.pageSize === undefined ? {} : { pageSize: params.pageSize }),\n ...(params.sort === undefined ? {} : { sort: params.sort }),\n ...(params.q === undefined ? {} : { q: params.q }),\n },\n auth,\n }),\n\n /** Fetches one product template by id. Default auth: anonymous. */\n get: async (templateId: string, auth: AuthContext = ANON): Promise<ProductTemplate> =>\n this.ctx.http.request<ProductTemplate>({\n method: \"GET\",\n path: `/product/${this.ctx.tenant}/product-templates/${templateId}`,\n auth,\n }),\n\n /** Creates a product template. Default auth: service. */\n create: async (\n input: ProductTemplateCreateInput,\n auth: AuthContext = SERVICE,\n ): Promise<ProductTemplateCreated> =>\n this.ctx.http.request<ProductTemplateCreated>({\n method: \"POST\",\n path: `/product/${this.ctx.tenant}/product-templates`,\n body: input,\n auth,\n }),\n\n /** Full-replaces a product template (`PUT`). Default auth: service. */\n update: async (\n templateId: string,\n input: ProductTemplateUpdateInput,\n auth: AuthContext = SERVICE,\n ): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"PUT\",\n path: `/product/${this.ctx.tenant}/product-templates/${templateId}`,\n body: input,\n auth,\n });\n },\n\n /** Deletes a product template. Default auth: service. */\n delete: async (templateId: string, auth: AuthContext = SERVICE): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/product/${this.ctx.tenant}/product-templates/${templateId}`,\n auth,\n });\n },\n };\n}\n"]}
|
|
@@ -44,6 +44,8 @@ var EmporixNotFoundError = class extends EmporixError {
|
|
|
44
44
|
};
|
|
45
45
|
var EmporixValidationError = class extends EmporixError {
|
|
46
46
|
};
|
|
47
|
+
var EmporixConflictError = class extends EmporixError {
|
|
48
|
+
};
|
|
47
49
|
var EmporixServerError = class extends EmporixError {
|
|
48
50
|
};
|
|
49
51
|
var EmporixTimeoutError = class extends EmporixError {
|
|
@@ -81,10 +83,11 @@ function errorFromResponse(status, message, body) {
|
|
|
81
83
|
}
|
|
82
84
|
if (status === 404) return new EmporixNotFoundError(message, status, body);
|
|
83
85
|
if (status === 400 || status === 422) return new EmporixValidationError(message, status, body);
|
|
86
|
+
if (status === 409) return new EmporixConflictError(message, status, body);
|
|
84
87
|
if (status >= 500) return new EmporixServerError(message, status, body);
|
|
85
88
|
return new EmporixError(message, status, body);
|
|
86
89
|
}
|
|
87
90
|
|
|
88
|
-
export { EmporixAuthError, EmporixError, EmporixForbiddenError, EmporixInsufficientScopeError, EmporixNetworkError, EmporixNotFoundError, EmporixServerError, EmporixTimeoutError, EmporixValidationError, errorFromResponse };
|
|
89
|
-
//# sourceMappingURL=chunk-
|
|
90
|
-
//# sourceMappingURL=chunk-
|
|
91
|
+
export { EmporixAuthError, EmporixConflictError, EmporixError, EmporixForbiddenError, EmporixInsufficientScopeError, EmporixNetworkError, EmporixNotFoundError, EmporixServerError, EmporixTimeoutError, EmporixValidationError, errorFromResponse };
|
|
92
|
+
//# sourceMappingURL=chunk-4Q76UV4J.js.map
|
|
93
|
+
//# sourceMappingURL=chunk-4Q76UV4J.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/errors.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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IAAI,CAAA;AAC7F,EAAA,IAAI,WAAW,GAAA,EAAK,OAAO,IAAI,oBAAA,CAAqB,OAAA,EAAS,QAAQ,IAAI,CAAA;AACzE,EAAA,IAAI,UAAU,GAAA,EAAK,OAAO,IAAI,kBAAA,CAAmB,OAAA,EAAS,QAAQ,IAAI,CAAA;AACtE,EAAA,OAAO,IAAI,YAAA,CAAa,OAAA,EAAS,MAAA,EAAQ,IAAI,CAAA;AAC/C","file":"chunk-4Q76UV4J.js","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/** 409 — conflict: a stale `metadata.version`, or an id that already exists. */\nexport class EmporixConflictError 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 === 409) return new EmporixConflictError(message, status, body);\n if (status >= 500) return new EmporixServerError(message, status, body);\n return new EmporixError(message, status, body);\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EmporixAuthError } from './chunk-
|
|
1
|
+
import { EmporixAuthError } from './chunk-4Q76UV4J.js';
|
|
2
2
|
|
|
3
3
|
// src/services/checkout.ts
|
|
4
4
|
function isGuest(customer) {
|
|
@@ -54,5 +54,5 @@ var CheckoutService = class {
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
export { CheckoutService };
|
|
57
|
-
//# sourceMappingURL=chunk-
|
|
58
|
-
//# sourceMappingURL=chunk-
|
|
57
|
+
//# sourceMappingURL=chunk-BHNYGUSD.js.map
|
|
58
|
+
//# sourceMappingURL=chunk-BHNYGUSD.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/services/checkout.ts"],"names":[],"mappings":";;;AA2BA,SAAS,QAAQ,QAAA,EAA6C;AAC5D,EAAA,OAAO,UAAU,KAAA,KAAU,IAAA;AAC7B;AAEA,SAAS,WAAA,CAAY,MAA+B,KAAA,EAA6B;AAC/E,EAAA,IAAI,SAAS,IAAA,CAAK,IAAA,KAAS,cAAc,IAAA,CAAK,IAAA,KAAS,QAAQ,OAAO,IAAA;AACtE,EAAA,IAAI,KAAA,IAAS,IAAA,IAAQ,IAAA,CAAK,IAAA,KAAS,aAAa,OAAO,IAAA;AACvD,EAAA,MAAM,IAAI,gBAAA;AAAA,IACR;AAAA,GACF;AACF;AAGO,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,UAAA;AAAA,EAGlB,OAAA,CAAQ,MAAuB,KAAA,EAAoD;AACzF,IAAA,IAAI,KAAA,IAAS,CAAC,IAAA,CAAK,SAAA,EAAW,OAAO,MAAA;AACrC,IAAA,OAAO,EAAE,YAAA,EAAc,IAAA,CAAK,SAAA,EAAU;AAAA,EACxC;AAAA,EAEQ,MAAM,IAAA,EAA2D;AACvE,IAAA,OAAO,KAAK,QAAA,GAAW,EAAE,QAAA,EAAU,IAAA,CAAK,UAAS,GAAI,MAAA;AAAA,EACvD;AAAA;AAAA,EAGA,MAAM,UAAA,CACJ,KAAA,EACA,IAAA,EACA,IAAA,GAAwB,EAAC,EACA;AACzB,IAAA,MAAM,KAAA,GAAQ,O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IAAI,CAAA;AAC7B,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAwB;AAAA,MAC3C,MAAA,EAAQ,MAAA;AAAA,MACR,IAAA,EAAM,CAAA,UAAA,EAAa,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,gBAAA,CAAA;AAAA,MAClC,IAAA,EAAM,WAAA,CAAY,IAAA,EAAM,KAAK,CAAA;AAAA,MAC7B,GAAI,KAAA,GAAQ,EAAE,KAAA,KAAU,EAAC;AAAA,MACzB,GAAI,OAAA,GAAU,EAAE,OAAA,KAAY,EAAC;AAAA,MAC7B,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,mBAAA,CACJ,KAAA,EACA,IAAA,EACA,IAAA,GAAwB,EAAC,EACA;AACzB,IAAA,MAAM,OAAA,GAAU,IAAA,CAAK,OAAA,CAAQ,IAAA,EAAM,KAAK,CAAA;AACxC,IAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,CAAM,IAAI,CAAA;AAC7B,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAwB;AAAA,MAC3C,MAAA,EAAQ,MAAA;AAAA,MACR,IAAA,EAAM,CAAA,UAAA,EAAa,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,gBAAA,CAAA;AAAA,MAClC,IAAA,EAAM,WAAA,CAAY,IAAA,EAAM,KAAK,CAAA;AAAA,MAC7B,GAAI,KAAA,GAAQ,EAAE,KAAA,KAAU,EAAC;AAAA,MACzB,GAAI,OAAA,GAAU,EAAE,OAAA,KAAY,EAAC;AAAA,MAC7B,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACF","file":"chunk-BHNYGUSD.js","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport { EmporixAuthError } from \"../core/errors\";\nimport type {\n ResponseCheckout,\n RequestCheckout,\n RequestFromQuoteCheckout,\n CustomerJson,\n} from \"../generated/checkout\";\n\n/** `requestCheckout` body (cart-based, generated). */\nexport type CheckoutInput = RequestCheckout;\n\n/** `requestFromQuoteCheckout` body (quote-based, generated). */\nexport type QuoteCheckoutInput = RequestFromQuoteCheckout;\n\n/** `responseCheckout` — the full generated checkout response. */\nexport type CheckoutResult = ResponseCheckout;\n\n/** Options for a checkout call. */\nexport interface CheckoutOptions {\n /** Customer `saasToken` from `customers.login()` — required for logged-in checkout. */\n saasToken?: string;\n /** Site code (`?siteCode=`). */\n siteCode?: string;\n}\n\nfunction isGuest(customer: CustomerJson | undefined): boolean {\n return customer?.guest === true;\n}\n\nfunction resolveAuth(auth: AuthContext | undefined, guest: boolean): AuthContext {\n if (auth && (auth.kind === \"customer\" || auth.kind === \"raw\")) return auth;\n if (guest && auth && auth.kind === \"anonymous\") return auth;\n throw new EmporixAuthError(\n \"checkout requires a customer/raw AuthContext (or anonymous for a guest checkout)\",\n );\n}\n\n/** Triggers Emporix checkout (atomic: validate → order → payment → close cart). */\nexport class CheckoutService {\n static readonly channel = \"checkout\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private headers(opts: CheckoutOptions, guest: boolean): Record<string, string> | undefined {\n if (guest || !opts.saasToken) return undefined;\n return { \"saas-token\": opts.saasToken };\n }\n\n private query(opts: CheckoutOptions): Record<string, string> | undefined {\n return opts.siteCode ? { siteCode: opts.siteCode } : undefined;\n }\n\n /** Checkout from a cart. Requires customer/raw auth (or anonymous for guest). */\n async placeOrder(\n input: CheckoutInput,\n auth?: AuthContext,\n opts: CheckoutOptions = {},\n ): Promise<CheckoutResult> {\n const guest = isGuest(input.customer);\n const headers = this.headers(opts, guest);\n const query = this.query(opts);\n return this.ctx.http.request<CheckoutResult>({\n method: \"POST\",\n path: `/checkout/${this.ctx.tenant}/checkouts/order`,\n auth: resolveAuth(auth, guest),\n ...(query ? { query } : {}),\n ...(headers ? { headers } : {}),\n body: input,\n });\n }\n\n /** Checkout from a quote. */\n async placeOrderFromQuote(\n input: QuoteCheckoutInput,\n auth?: AuthContext,\n opts: CheckoutOptions = {},\n ): Promise<CheckoutResult> {\n const headers = this.headers(opts, false);\n const query = this.query(opts);\n return this.ctx.http.request<CheckoutResult>({\n method: \"POST\",\n path: `/checkout/${this.ctx.tenant}/checkouts/order`,\n auth: resolveAuth(auth, false),\n ...(query ? { query } : {}),\n ...(headers ? { headers } : {}),\n body: input,\n });\n }\n}\n"]}
|
|
@@ -152,11 +152,15 @@ var SalesOrdersService = class {
|
|
|
152
152
|
auth
|
|
153
153
|
});
|
|
154
154
|
}
|
|
155
|
-
/**
|
|
155
|
+
/**
|
|
156
|
+
* Patches an existing order (status, mixins, customAttributes, metadata).
|
|
157
|
+
* Resolves on the `204`, which carries no body — read the order back with
|
|
158
|
+
* {@link get} for its new state.
|
|
159
|
+
*/
|
|
156
160
|
async update(orderId, patch, auth, opts = {}) {
|
|
157
161
|
const query = {};
|
|
158
162
|
if (opts.recalculate === false) query.recalculate = "false";
|
|
159
|
-
|
|
163
|
+
await this.ctx.http.request({
|
|
160
164
|
method: "PATCH",
|
|
161
165
|
path: `${this.base()}/${orderId}`,
|
|
162
166
|
auth,
|
|
@@ -296,5 +300,5 @@ var SalesOrdersService = class {
|
|
|
296
300
|
};
|
|
297
301
|
|
|
298
302
|
export { OrdersService, SalesOrdersService };
|
|
299
|
-
//# sourceMappingURL=chunk-
|
|
300
|
-
//# sourceMappingURL=chunk-
|
|
303
|
+
//# sourceMappingURL=chunk-CXTVY4SI.js.map
|
|
304
|
+
//# sourceMappingURL=chunk-CXTVY4SI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/orders.ts"],"names":[],"mappings":";;;;AA6GA,SAAS,YAAA,CACP,CAAA,EACA,GAAA,EACA,KAAA,EACM;AACN,EAAA,IAAI,KAAA,KAAU,MAAA,IAAa,KAAA,KAAU,EAAA,EAAI;AACvC,IAAA,CAAA,CAAE,GAAG,CAAA,GAAI,KAAA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,EAAQ,MAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,OAAO,CAAA,aAAA,CAAA;AAAA,MAC/B,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,aAAA,CAAc,OAAA,EAAiB,KAAA,EAA+B,IAAA,EAAwC;AAC1G,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAoB;AAAA,MACvC,MAAA,EAAQ,MAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,OAAO,CAAA,QAAA,CAAA;AAAA,MAC/B,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,KAAA,CAAM,OAAA,EAAiB,KAAA,EAA6B,IAAA,EAAmD;AAC3G,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAA+B;AAAA,MAClD,MAAA,EAAQ,MAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,OAAO,CAAA,MAAA,CAAA;AAAA,MAC/B,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACF","file":"chunk-CXTVY4SI.js","sourcesContent":["import type { ClientContext, PaginatedItems } from \"../core/context\";\nimport { requestPage } from \"../core/paged\";\nimport type { AuthContext } from \"../core/auth\";\nimport { resolveQuery, type QueryFor } from \"../core/query\";\nimport type {\n Order,\n OrderStatus,\n OrderUpdateDto,\n SalesOrder,\n Transition,\n SalesOrderCreationDto,\n ResourceLocation,\n SearchRequest,\n HistoricalTransitionsResponse,\n OrderCalculationDto,\n OrderEntriesDto,\n OrderSplitRequest,\n OrderSplitResponse,\n} from \"../generated/order-v2\";\n\n/**\n * Salesorder PATCH body. The generated `orderUpdateDto` models a full order\n * (it requires `entries`/`customer`), but `PATCH /salesorders/{id}` accepts a\n * subset — so the SDK exposes a partial of it.\n */\nexport type SalesOrderPatch = Partial<OrderUpdateDto>;\n\n/** Body for creating a sales-order as an employee (`POST /salesorders`). */\nexport type SalesOrderCreateInput = SalesOrderCreationDto;\n\n/** Id/location envelope returned when a sales-order is created. */\nexport type SalesOrderCreated = ResourceLocation;\n\n/** Body for a full sales-order replace (`PUT /salesorders/{id}`). */\nexport type SalesOrderReplaceInput = OrderUpdateDto;\n\n/** Body for `salesOrders.search` (`POST /salesorders/search`). */\nexport type SalesOrderSearchInput = SearchRequest;\n\n/** Response of `salesOrders.listHistoricalTransitions`. */\nexport type SalesOrderHistoricalTransitions = HistoricalTransitionsResponse;\n\n/** Body for `salesOrders.calculate` (`POST /salesorders/{id}/calculations`). */\nexport type SalesOrderCalculationInput = OrderCalculationDto;\n\n/** Body for `salesOrders.updateEntries` (`POST /salesorders/{id}/entries`). */\nexport type SalesOrderEntriesInput = OrderEntriesDto;\n\n/** Body for `salesOrders.split` (`POST /salesorders/{id}/split`). */\nexport type SalesOrderSplitInput = OrderSplitRequest;\n\n/** Response of `salesOrders.split`. */\nexport type SalesOrderSplitResult = OrderSplitResponse;\n\n/** Options for `salesOrders.list`. */\nexport interface ListSalesOrdersOptions {\n pageNumber?: number;\n pageSize?: number;\n sort?: string;\n fields?: string;\n /** A `q` filter — raw DSL string or a built filter for entity \"ORDER\". */\n q?: QueryFor<\"ORDER\">;\n /** Ask for `X-Total-Count` — becomes a request header, not a query parameter. */\n totalCount?: boolean;\n}\n\n/** Options for `orders.listForLegalEntity`. */\nexport interface ListLegalEntityOrdersOptions {\n pageNumber?: number;\n pageSize?: number;\n sort?: string;\n saasToken?: string;\n /** A `q` filter — raw DSL string or a built filter for entity \"ORDER\". */\n q?: QueryFor<\"ORDER\">;\n /** Ask for `X-Total-Count` — becomes a request header, not a query parameter. */\n totalCount?: boolean;\n}\n\n/** Optional fields supported by the order-v2 list endpoint. */\nexport interface ListMyOrdersOptions {\n pageNumber?: number;\n pageSize?: number;\n status?: OrderStatus;\n legalEntityId?: string;\n siteCode?: string;\n saasToken?: string;\n /** A `q` filter — raw DSL string or a built filter (e.g. mixinQuery for entity \"ORDER\"). */\n q?: QueryFor<\"ORDER\">;\n /** Ask for `X-Total-Count` — becomes a request header, not a query parameter. */\n totalCount?: boolean;\n}\n\n/** Options for single-order reads (saas-token only). */\nexport interface GetOrderOptions {\n saasToken?: string;\n}\n\n/** Options for status transitions. */\nexport interface OrderTransitionOptions {\n saasToken?: string;\n comment?: string;\n}\n\n/** Options for `salesOrders.update`. */\nexport interface UpdateSalesOrderOptions {\n /** Forwarded as `?recalculate=`. Omit to use the server default (true). */\n recalculate?: boolean;\n}\n\nfunction setIfDefined<V>(\n q: Record<string, string | number | undefined>,\n key: string,\n value: V | undefined,\n): void {\n if (value !== undefined && value !== \"\") {\n q[key] = value as unknown as string | number;\n }\n}\n\n/**\n * Storefront-customer access to Order-v2's customer endpoints.\n *\n * `listMine`/`get` require `order.order_read_own`; transitions require\n * `order.order_manage_own`. All methods accept an optional `saasToken` that\n * is passed as the `saas-token` header (mirrors `checkout.placeOrder`).\n */\nexport class OrdersService {\n static readonly channel = \"orders\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/order-v2/${this.ctx.tenant}/orders`;\n }\n\n private saasHeader(saasToken: string | undefined): Record<string, string> | undefined {\n return saasToken ? { \"saas-token\": saasToken } : undefined;\n }\n\n /** Lists the calling customer's orders. */\n async listMine(\n auth: AuthContext,\n opts: ListMyOrdersOptions = {},\n ): Promise<PaginatedItems<Order>> {\n const pageNumber = opts.pageNumber ?? 1;\n const pageSize = opts.pageSize ?? 50;\n const query: Record<string, string | number | undefined> = {\n pageNumber,\n pageSize,\n };\n setIfDefined(query, \"status\", opts.status);\n setIfDefined(query, \"legalEntityId\", opts.legalEntityId);\n setIfDefined(query, \"siteCode\", opts.siteCode);\n if (opts.q !== undefined) {\n setIfDefined(query, \"q\", resolveQuery(opts.q, { compoundLogicalQuery: false }));\n }\n const headers = this.saasHeader(opts.saasToken);\n // order-v2 returns a bare JSON array, not a {items,...} envelope — the total\n // lives in the X-Total-Count header, which `requestPage` reads when the\n // caller opts in with `totalCount: true`.\n return requestPage<Order>(\n this.ctx.http,\n {\n method: \"GET\",\n path: this.base(),\n query,\n auth,\n ...(headers ? { headers } : {}),\n },\n {\n pageNumber,\n pageSize,\n ...(opts.totalCount === undefined ? {} : { totalCount: opts.totalCount }),\n },\n );\n }\n\n /** Fetches one of the calling customer's orders by id. */\n async get(\n orderId: string,\n auth: AuthContext,\n opts: GetOrderOptions = {},\n ): Promise<Order> {\n const headers = this.saasHeader(opts.saasToken);\n return this.ctx.http.request<Order>({\n method: \"GET\",\n path: `${this.base()}/${orderId}`,\n auth,\n ...(headers ? { headers } : {}),\n });\n }\n\n /**\n * The status transitions the customer may trigger on one of their orders\n * (`GET /orders/{orderId}/transitions`) — for example whether it can still be\n * cancelled, before offering {@link cancel}.\n */\n async listTransitions(\n orderId: string,\n auth: AuthContext,\n opts: GetOrderOptions = {},\n ): Promise<Transition[]> {\n const headers = this.saasHeader(opts.saasToken);\n return this.ctx.http.request<Transition[]>({\n method: \"GET\",\n path: `${this.base()}/${encodeURIComponent(orderId)}/transitions`,\n auth,\n ...(headers ? { headers } : {}),\n });\n }\n\n /** Transitions an order to a new status. Server enforces legal transitions. */\n async transition(\n orderId: string,\n status: OrderStatus,\n auth: AuthContext,\n opts: OrderTransitionOptions = {},\n ): Promise<void> {\n const body: { status: OrderStatus; comment?: string } = { status };\n if (opts.comment !== undefined) body.comment = opts.comment;\n const headers = this.saasHeader(opts.saasToken);\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `${this.base()}/${orderId}/transitions`,\n auth,\n body,\n ...(headers ? { headers } : {}),\n });\n }\n\n /** Convenience: transitions to `DECLINED` (customer cancel). */\n async cancel(\n orderId: string,\n auth: AuthContext,\n opts: { saasToken?: string } = {},\n ): Promise<void> {\n await this.transition(orderId, \"DECLINED\", auth, opts);\n }\n\n /**\n * Lists a legal entity's orders (`GET /legal-entity-orders/{legalEntityId}`),\n * wrapped into `PaginatedItems`. B2B storefront view — requires a customer\n * token with access to the legal entity.\n */\n async listForLegalEntity(\n legalEntityId: string,\n auth: AuthContext,\n opts: ListLegalEntityOrdersOptions = {},\n ): Promise<PaginatedItems<SalesOrder>> {\n const pageNumber = opts.pageNumber ?? 1;\n const pageSize = opts.pageSize ?? 50;\n const query: Record<string, string | number | undefined> = { pageNumber, pageSize };\n setIfDefined(query, \"sort\", opts.sort);\n if (opts.q !== undefined) {\n setIfDefined(query, \"q\", resolveQuery(opts.q, { compoundLogicalQuery: false }));\n }\n const headers = this.saasHeader(opts.saasToken);\n return requestPage<SalesOrder>(\n this.ctx.http,\n {\n method: \"GET\",\n path: `/order-v2/${this.ctx.tenant}/legal-entity-orders/${legalEntityId}`,\n query,\n auth,\n ...(headers ? { headers } : {}),\n },\n {\n pageNumber,\n pageSize,\n ...(opts.totalCount === undefined ? {} : { totalCount: opts.totalCount }),\n },\n );\n }\n\n /**\n * Fetches one order within a legal entity\n * (`GET /legal-entity-orders/{legalEntityId}/{orderId}`).\n */\n async getForLegalEntity(\n legalEntityId: string,\n orderId: string,\n auth: AuthContext,\n opts: { saasToken?: string } = {},\n ): Promise<SalesOrder> {\n const headers = this.saasHeader(opts.saasToken);\n return this.ctx.http.request<SalesOrder>({\n method: \"GET\",\n path: `/order-v2/${this.ctx.tenant}/legal-entity-orders/${legalEntityId}/${orderId}`,\n auth,\n ...(headers ? { headers } : {}),\n });\n }\n}\n\n/**\n * Backend / service-account access to the merchant-facing\n * `/salesorders/{id}` resource. Requires `order.order_read` (read) /\n * `order.order_manage` (update) scopes on a service token.\n *\n * The full admin list + filter surface is deferred to a follow-up\n * sub-spec. This service ships only single-resource read + patch — the\n * common backend use case (e.g. mixin updates after fulfilment).\n */\nexport class SalesOrdersService {\n static readonly channel = \"sales-orders\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/order-v2/${this.ctx.tenant}/salesorders`;\n }\n\n /** Fetches a single sales-order by id. */\n async get(orderId: string, auth: AuthContext): Promise<Order> {\n return this.ctx.http.request<Order>({\n method: \"GET\",\n path: `${this.base()}/${orderId}`,\n auth,\n });\n }\n\n /**\n * Patches an existing order (status, mixins, customAttributes, metadata).\n * Resolves on the `204`, which carries no body — read the order back with\n * {@link get} for its new state.\n */\n async update(\n orderId: string,\n patch: SalesOrderPatch,\n auth: AuthContext,\n opts: UpdateSalesOrderOptions = {},\n ): Promise<void> {\n const query: Record<string, string> = {};\n if (opts.recalculate === false) query.recalculate = \"false\";\n await this.ctx.http.request<void>({\n method: \"PATCH\",\n path: `${this.base()}/${orderId}`,\n auth,\n ...(Object.keys(query).length > 0 ? { query } : {}),\n body: patch,\n });\n }\n\n /** Lists tenant sales-orders (`GET /salesorders`), wrapped into `PaginatedItems`. */\n async list(auth: AuthContext, opts: ListSalesOrdersOptions = {}): Promise<PaginatedItems<SalesOrder>> {\n const pageNumber = opts.pageNumber ?? 1;\n const pageSize = opts.pageSize ?? 50;\n const query: Record<string, string | number | undefined> = { pageNumber, pageSize };\n setIfDefined(query, \"sort\", opts.sort);\n setIfDefined(query, \"fields\", opts.fields);\n if (opts.q !== undefined) {\n setIfDefined(query, \"q\", resolveQuery(opts.q, { compoundLogicalQuery: false }));\n }\n return requestPage<SalesOrder>(\n this.ctx.http,\n {\n method: \"GET\",\n path: this.base(),\n query,\n auth,\n },\n {\n pageNumber,\n pageSize,\n ...(opts.totalCount === undefined ? {} : { totalCount: opts.totalCount }),\n },\n );\n }\n\n /** Searches tenant sales-orders (`POST /salesorders/search`, body carries the `q` filter). */\n async search(\n query: SalesOrderSearchInput,\n auth: AuthContext,\n opts: { pageNumber?: number; pageSize?: number; sort?: string; fields?: string } = {},\n ): Promise<SalesOrder[]> {\n const q: Record<string, string | number | undefined> = {};\n setIfDefined(q, \"pageNumber\", opts.pageNumber);\n setIfDefined(q, \"pageSize\", opts.pageSize);\n setIfDefined(q, \"sort\", opts.sort);\n setIfDefined(q, \"fields\", opts.fields);\n return this.ctx.http.request<SalesOrder[]>({\n method: \"POST\",\n path: `${this.base()}/search`,\n ...(Object.keys(q).length > 0 ? { query: q } : {}),\n body: query,\n idempotent: true, // pure read over POST — safe to replay on 5xx/429\n auth,\n });\n }\n\n /** Creates a sales-order as an employee (`POST /salesorders`). Returns the created resource location. */\n async create(input: SalesOrderCreateInput, auth: AuthContext): Promise<SalesOrderCreated> {\n return this.ctx.http.request<SalesOrderCreated>({\n method: \"POST\",\n path: this.base(),\n auth,\n body: input,\n });\n }\n\n /**\n * Full-replaces a sales-order (`PUT /salesorders/{orderId}`, body `OrderUpdateDto`).\n * The endpoint returns 204, so the order is re-fetched (direct GET) and returned.\n * Note: `update` on this class is the PATCH (partial); `replace` is the PUT (full).\n */\n async replace(orderId: string, input: SalesOrderReplaceInput, auth: AuthContext): Promise<SalesOrder> {\n await this.ctx.http.request<void>({\n method: \"PUT\",\n path: `${this.base()}/${orderId}`,\n auth,\n body: input,\n });\n return this.ctx.http.request<SalesOrder>({\n method: \"GET\",\n path: `${this.base()}/${orderId}`,\n auth,\n });\n }\n\n /** Deletes a sales-order (`DELETE /salesorders/{orderId}`). */\n async delete(orderId: string, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${orderId}`,\n auth,\n });\n }\n\n /** Lists the available transitions for a sales-order (`GET /salesorders/{orderId}/transitions`). */\n async listTransitions(orderId: string, auth: AuthContext): Promise<Transition[]> {\n return this.ctx.http.request<Transition[]>({\n method: \"GET\",\n path: `${this.base()}/${orderId}/transitions`,\n auth,\n });\n }\n\n /** Transitions a sales-order to a new status (`POST /salesorders/{orderId}/transitions`). */\n async transition(orderId: string, input: Transition, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `${this.base()}/${orderId}/transitions`,\n auth,\n body: input,\n });\n }\n\n /** Lists the historical transitions of a sales-order (`GET /salesorders/{orderId}/historical-transitions`). */\n async listHistoricalTransitions(orderId: string, auth: AuthContext): Promise<SalesOrderHistoricalTransitions> {\n return this.ctx.http.request<SalesOrderHistoricalTransitions>({\n method: \"GET\",\n path: `${this.base()}/${orderId}/historical-transitions`,\n auth,\n });\n }\n\n /** Calculates order-entry totals for a sales-order (`POST /salesorders/{orderId}/calculations`). */\n async calculate(orderId: string, input: SalesOrderCalculationInput, auth: AuthContext): Promise<unknown> {\n return this.ctx.http.request<unknown>({\n method: \"POST\",\n path: `${this.base()}/${orderId}/calculations`,\n auth,\n body: input,\n });\n }\n\n /** Updates a sales-order's entries (`POST /salesorders/{orderId}/entries`). Returns the updated order. */\n async updateEntries(orderId: string, input: SalesOrderEntriesInput, auth: AuthContext): Promise<SalesOrder> {\n return this.ctx.http.request<SalesOrder>({\n method: \"POST\",\n path: `${this.base()}/${orderId}/entries`,\n auth,\n body: input,\n });\n }\n\n /** Splits a sales-order (`POST /salesorders/{orderId}/split`). */\n async split(orderId: string, input: SalesOrderSplitInput, auth: AuthContext): Promise<SalesOrderSplitResult> {\n return this.ctx.http.request<SalesOrderSplitResult>({\n method: \"POST\",\n path: `${this.base()}/${orderId}/split`,\n auth,\n body: input,\n });\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { splitQuery } from './chunk-ZWJUDXTK.js';
|
|
2
|
-
import { EmporixAuthError } from './chunk-
|
|
2
|
+
import { EmporixAuthError } from './chunk-4Q76UV4J.js';
|
|
3
3
|
|
|
4
4
|
// src/services/price.ts
|
|
5
5
|
function normalizeMatch(raw) {
|
|
@@ -307,5 +307,5 @@ var PriceService = class {
|
|
|
307
307
|
};
|
|
308
308
|
|
|
309
309
|
export { PriceService };
|
|
310
|
-
//# sourceMappingURL=chunk-
|
|
311
|
-
//# sourceMappingURL=chunk-
|
|
310
|
+
//# sourceMappingURL=chunk-ENMMDGUB.js.map
|
|
311
|
+
//# sourceMappingURL=chunk-ENMMDGUB.js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AA,MACN,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,IACH,gBAAA,EAAkB,OAChB,MAAA,EACA,MAAA,EACA,UAAuB,OAAA,KAEvB,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAA2B;AAAA,MACvC,MAAA,EAAQ,KAAA;AAAA,MACR,MAAM,CAAA,OAAA,EAAU,IAAA,CAAK,GAAA,CAAI,MAAM,gBAAgB,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-K4KXT6NX.js","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport { EmporixAuthError } from \"../core/errors\";\nimport { splitQuery, type SearchPaging } from \"../core/search\";\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 /**\n * Searches flat prices: the criteria go in the body, `expand` in the query\n * string. Default auth: service.\n */\n async search(query: Record<string, unknown> & { expand?: string }, 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 ...splitQuery(query, [\"expand\"]),\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 /** `q` in the body; `pageNumber`, `pageSize` and `sort` in the query string. */\n search: async (\n query: Record<string, unknown> & Omit<SearchPaging, \"fields\">,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceList[]> =>\n this.ctx.http.request<PriceList[]>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/price-lists/search`,\n auth: authCtx,\n ...splitQuery(query, [\"pageNumber\", \"pageSize\", \"sort\"]),\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 /** `q` in the body; `pageNumber`, `pageSize` and `sort` in the query string. */\n searchPrices: async (\n listId: string,\n query: Record<string, unknown> & Omit<SearchPaging, \"fields\">,\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 ...splitQuery(query, [\"pageNumber\", \"pageSize\", \"sort\"]),\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"]}
|
|
1
|
+
{"version":3,"sources":["../src/services/price.ts"],"names":[],"mappings":";;;;AAuDA,SAAS,eAAe,GAAA,EAAgC;AACtD,EAAA,MAAM,MAAA,GAAU,GAAA,CAAuD,MAAA,IAAU,GAAA,CAAI,OAAA;AACrF,EAAA,MAAM,IAAA,GAAO,GAAA;AACb,EAAA,IAAI,CAAC,QAAQ,OAAO,IAAA;AAGpB,EAAA,MAAM,OAAA,GAA6B;AAAA,IACjC,GAAI,OAAO,QAAA,KAAa,MAAA,GAAY,EAAE,QAAA,EAAU,MAAA,CAAO,QAAA,EAAS,GAAI,EAAC;AAAA,IACrE,GAAI,OAAO,EAAA,KAAO,MAAA,GAAY,EAAE,EAAA,EAAI,MAAA,CAAO,EAAA,EAAG,GAAI;AAAC,GACrD;AACA,EAAA,OAAO,EAAE,GAAG,IAAA,EAAM,MAAA,EAAQ,OAAA,EAAQ;AACpC;AAqCA,IAAM,IAAA,GAAoB,EAAE,IAAA,EAAM,WAAA,EAAY;AAC9C,IAAM,OAAA,GAAuB,EAAE,IAAA,EAAM,SAAA,EAAU;AAE/C,SAAS,mBAAmB,IAAA,EAA4C;AACtE,EAAA,MAAM,IAAI,IAAA,IAAQ,IAAA;AAClB,EAAA,IAAI,CAAA,CAAE,SAAS,WAAA,IAAe,CAAA,CAAE,SAAS,UAAA,IAAc,CAAA,CAAE,IAAA,KAAS,KAAA,EAAO,OAAO,CAAA;AAChF,EAAA,MAAM,IAAI,gBAAA;AAAA,IACR;AAAA,GACF;AACF;AAOO,IAAM,eAAN,MAAmB;AAAA,EAExB,YAA6B,GAAA,E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OAAA,KAEvB,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAA2B;AAAA,MACvC,MAAA,EAAQ,MAAA;AAAA,MACR,MAAM,CAAA,OAAA,EAAU,IAAA,CAAK,GAAA,CAAI,MAAM,gBAAgB,MAAM,CAAA,YAAA,CAAA;AAAA,MACrD,IAAA,EAAM,OAAA;AAAA,MACN,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,IACH,gBAAA,EAAkB,OAChB,MAAA,EACA,MAAA,EACA,UAAuB,OAAA,KAEvB,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAA2B;AAAA,MACvC,MAAA,EAAQ,KAAA;AAAA,MACR,MAAM,CAAA,OAAA,EAAU,IAAA,CAAK,GAAA,CAAI,MAAM,gBAAgB,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-ENMMDGUB.js","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport { EmporixAuthError } from \"../core/errors\";\nimport { splitQuery, type SearchPaging } from \"../core/search\";\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 /**\n * Searches flat prices: the criteria go in the body, `expand` in the query\n * string. Default auth: service.\n */\n async search(query: Record<string, unknown> & { expand?: string }, 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 ...splitQuery(query, [\"expand\"]),\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 /** `q` in the body; `pageNumber`, `pageSize` and `sort` in the query string. */\n search: async (\n query: Record<string, unknown> & Omit<SearchPaging, \"fields\">,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceList[]> =>\n this.ctx.http.request<PriceList[]>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/price-lists/search`,\n auth: authCtx,\n ...splitQuery(query, [\"pageNumber\", \"pageSize\", \"sort\"]),\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 /** `q` in the body; `pageNumber`, `pageSize` and `sort` in the query string. */\n searchPrices: async (\n listId: string,\n query: Record<string, unknown> & Omit<SearchPaging, \"fields\">,\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 ...splitQuery(query, [\"pageNumber\", \"pageSize\", \"sort\"]),\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"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { requireCustomer } from './chunk-
|
|
2
|
-
import { EmporixAuthError } from './chunk-
|
|
1
|
+
import { requireCustomer } from './chunk-ZVIEFW3X.js';
|
|
2
|
+
import { EmporixAuthError } from './chunk-4Q76UV4J.js';
|
|
3
3
|
|
|
4
4
|
// src/services/customer.ts
|
|
5
5
|
function toSession(endpoint, wire, opts = {}) {
|
|
@@ -283,5 +283,5 @@ var CustomerService = class {
|
|
|
283
283
|
};
|
|
284
284
|
|
|
285
285
|
export { CustomerService };
|
|
286
|
-
//# sourceMappingURL=chunk-
|
|
287
|
-
//# sourceMappingURL=chunk-
|
|
286
|
+
//# sourceMappingURL=chunk-EQE5WGME.js.map
|
|
287
|
+
//# sourceMappingURL=chunk-EQE5WGME.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/services/customer.ts"],"names":[],"mappings":";;;;AAoFA,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;A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,QACR,MAAM,CAAA,UAAA,EAAa,IAAA,CAAK,GAAA,CAAI,MAAM,iBAAiB,EAAE,CAAA,KAAA,CAAA;AAAA,QACrD,OAAO,EAAE,IAAA,EAAM,IAAA,CAAK,IAAA,CAAK,GAAG,CAAA,EAAE;AAAA,QAC9B,IAAA,EAAM,gBAAgB,IAAI;AAAA,OAC3B,CAAA;AAAA,IACH;AAAA,GACF;AACF","file":"chunk-UA4BM6OP.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 ChangeEmailRequestDto,\n UpdateEmail,\n RefreshToken,\n ValidateTokenResponse,\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;\nexport type ChangeEmailInput = ChangeEmailRequestDto;\nexport type ConfirmEmailChangeInput = UpdateEmail;\nexport type ResendActivationInput = RefreshToken;\n/**\n * What `validateToken` reports about a customer token: `scope` is the\n * space-separated scope list, plus `sessionId`, `email`, `legalEntityId` and\n * `expires_in`. Every field is optional upstream.\n */\nexport type CustomerTokenValidation = ValidateTokenResponse;\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 /**\n * Validates a customer token and returns what the tenant knows about it —\n * `scope`, `sessionId`, `email`, `legalEntityId`, `expires_in`\n * (`GET /validateauthtoken`). Requires customer/raw auth.\n *\n * An invalid or expired token answers `401`, which surfaces as\n * {@link EmporixAuthError} rather than a falsy result: this is a check, not a\n * predicate. Reach for it when you hold a token from elsewhere — an SSO\n * exchange, a Managed Dashboard host — and need its scopes before deciding\n * what to render, instead of discovering them from a failed call.\n */\n async validateToken(auth?: AuthContext): Promise<CustomerTokenValidation> {\n return this.ctx.http.request<CustomerTokenValidation>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/validateauthtoken`,\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 /**\n * Completes double opt-in signup with the emailed token, creating the account\n * and returning a logged-in {@link CustomerSession}. Default auth: anonymous.\n */\n async confirmSignup(\n token: string,\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<CustomerSession> {\n const wire = await this.ctx.http.request<WireSession>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/signup/optin/${encodeURIComponent(token)}`,\n auth,\n });\n return toSession(\"confirmSignup\", wire);\n }\n\n /** Resends the double opt-in activation link. Default auth: anonymous. */\n async resendActivation(\n input: ResendActivationInput,\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/signup/optin/refresh_token`,\n auth,\n body: input,\n });\n }\n\n /** Requests a login-email change (emails a confirmation token). Requires customer/raw auth. */\n async changeEmail(input: ChangeEmailInput, auth?: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/me/accounts/internal/email/change`,\n auth: requireCustomer(auth),\n body: input,\n });\n }\n\n /** Confirms a login-email change with the emailed token. Default auth: anonymous. */\n async confirmEmailChange(\n input: ConfirmEmailChangeInput,\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/me/accounts/internal/email/change/confirm`,\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 get: async (id: string, auth?: AuthContext): Promise<Address> =>\n this.ctx.http.request<Address>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/me/addresses/${id}`,\n auth: requireCustomer(auth),\n }),\n addTags: async (id: string, tags: string[], auth?: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/me/addresses/${id}/tags`,\n query: { tags: tags.join(\",\") },\n auth: requireCustomer(auth),\n });\n },\n removeTags: async (id: string, tags: string[], auth?: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/customer/${this.ctx.tenant}/me/addresses/${id}/tags`,\n query: { tags: tags.join(\",\") },\n auth: requireCustomer(auth),\n });\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/services/customer.ts"],"names":[],"mappings":";;;;AAoFA,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,+B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iB,EAAE,CAAA,KAAA,CAAA;AAAA,QACrD,OAAO,EAAE,IAAA,EAAM,IAAA,CAAK,IAAA,CAAK,GAAG,CAAA,EAAE;AAAA,QAC9B,IAAA,EAAM,gBAAgB,IAAI;AAAA,OAC3B,CAAA;AAAA,IACH;AAAA,GACF;AACF","file":"chunk-EQE5WGME.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 ChangeEmailRequestDto,\n UpdateEmail,\n RefreshToken,\n ValidateTokenResponse,\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;\nexport type ChangeEmailInput = ChangeEmailRequestDto;\nexport type ConfirmEmailChangeInput = UpdateEmail;\nexport type ResendActivationInput = RefreshToken;\n/**\n * What `validateToken` reports about a customer token: `scope` is the\n * space-separated scope list, plus `sessionId`, `email`, `legalEntityId` and\n * `expires_in`. Every field is optional upstream.\n */\nexport type CustomerTokenValidation = ValidateTokenResponse;\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 /**\n * Validates a customer token and returns what the tenant knows about it —\n * `scope`, `sessionId`, `email`, `legalEntityId`, `expires_in`\n * (`GET /validateauthtoken`). Requires customer/raw auth.\n *\n * An invalid or expired token answers `401`, which surfaces as\n * {@link EmporixAuthError} rather than a falsy result: this is a check, not a\n * predicate. Reach for it when you hold a token from elsewhere — an SSO\n * exchange, a Managed Dashboard host — and need its scopes before deciding\n * what to render, instead of discovering them from a failed call.\n */\n async validateToken(auth?: AuthContext): Promise<CustomerTokenValidation> {\n return this.ctx.http.request<CustomerTokenValidation>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/validateauthtoken`,\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 /**\n * Completes double opt-in signup with the emailed token, creating the account\n * and returning a logged-in {@link CustomerSession}. Default auth: anonymous.\n */\n async confirmSignup(\n token: string,\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<CustomerSession> {\n const wire = await this.ctx.http.request<WireSession>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/signup/optin/${encodeURIComponent(token)}`,\n auth,\n });\n return toSession(\"confirmSignup\", wire);\n }\n\n /** Resends the double opt-in activation link. Default auth: anonymous. */\n async resendActivation(\n input: ResendActivationInput,\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/signup/optin/refresh_token`,\n auth,\n body: input,\n });\n }\n\n /** Requests a login-email change (emails a confirmation token). Requires customer/raw auth. */\n async changeEmail(input: ChangeEmailInput, auth?: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/me/accounts/internal/email/change`,\n auth: requireCustomer(auth),\n body: input,\n });\n }\n\n /** Confirms a login-email change with the emailed token. Default auth: anonymous. */\n async confirmEmailChange(\n input: ConfirmEmailChangeInput,\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/me/accounts/internal/email/change/confirm`,\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 get: async (id: string, auth?: AuthContext): Promise<Address> =>\n this.ctx.http.request<Address>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/me/addresses/${id}`,\n auth: requireCustomer(auth),\n }),\n addTags: async (id: string, tags: string[], auth?: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/me/addresses/${id}/tags`,\n query: { tags: tags.join(\",\") },\n auth: requireCustomer(auth),\n });\n },\n removeTags: async (id: string, tags: string[], auth?: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/customer/${this.ctx.tenant}/me/addresses/${id}/tags`,\n query: { tags: tags.join(\",\") },\n auth: requireCustomer(auth),\n });\n },\n };\n}\n"]}
|