@viu/emporix-sdk 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/README.md +1 -0
- package/dist/availability.d.cts +1 -1
- package/dist/availability.d.ts +1 -1
- package/dist/cart.d.cts +1 -1
- package/dist/cart.d.ts +1 -1
- package/dist/category.cjs +3 -0
- package/dist/category.cjs.map +1 -1
- package/dist/category.d.cts +17 -11
- package/dist/category.d.ts +17 -11
- package/dist/category.js +1 -1
- package/dist/checkout.d.cts +1 -1
- package/dist/checkout.d.ts +1 -1
- package/dist/{chunk-2SHTDVOC.js → chunk-J2AN2FMK.js} +7 -2
- package/dist/chunk-J2AN2FMK.js.map +1 -0
- package/dist/{chunk-MSQ3GEIW.js → chunk-KJEBG7MP.js} +5 -2
- package/dist/chunk-KJEBG7MP.js.map +1 -0
- package/dist/companies.d.cts +1 -1
- package/dist/companies.d.ts +1 -1
- package/dist/contacts.d.cts +1 -1
- package/dist/contacts.d.ts +1 -1
- package/dist/{context-5lt8Q0MT.d.ts → context-C-A10NL3.d.cts} +23 -0
- package/dist/{context-5lt8Q0MT.d.cts → context-C-A10NL3.d.ts} +23 -0
- package/dist/{customer-groups-8cgS8S5d.d.cts → customer-groups-C6jPLdvd.d.cts} +1 -1
- package/dist/{customer-groups-DizW_a-w.d.ts → customer-groups-E1fY1FR2.d.ts} +1 -1
- package/dist/customer-groups.d.cts +2 -2
- package/dist/customer-groups.d.ts +2 -2
- package/dist/customer.d.cts +1 -1
- package/dist/customer.d.ts +1 -1
- package/dist/index.cjs +16 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -27
- package/dist/index.d.ts +8 -27
- package/dist/index.js +12 -9
- package/dist/index.js.map +1 -1
- package/dist/locations.d.cts +1 -1
- package/dist/locations.d.ts +1 -1
- package/dist/media.d.cts +1 -1
- package/dist/media.d.ts +1 -1
- package/dist/orders.d.cts +1 -1
- package/dist/orders.d.ts +1 -1
- package/dist/payment.d.cts +1 -1
- package/dist/payment.d.ts +1 -1
- package/dist/price.d.cts +1 -1
- package/dist/price.d.ts +1 -1
- package/dist/product.cjs +5 -0
- package/dist/product.cjs.map +1 -1
- package/dist/product.d.cts +8 -2
- package/dist/product.d.ts +8 -2
- package/dist/product.js +1 -1
- package/dist/segment.d.cts +1 -1
- package/dist/segment.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-2SHTDVOC.js.map +0 -1
- package/dist/chunk-MSQ3GEIW.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @viu/emporix-sdk
|
|
2
2
|
|
|
3
|
+
## 4.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#392](https://github.com/viuteam/emporix-sdk/pull/392) [`049afee`](https://github.com/viuteam/emporix-sdk/commit/049afee59ee6a3c582a3cc32f395e5bf447df935) Thanks [@amnael1](https://github.com/amnael1)! - feat(sdk): send Content-Language on writes
|
|
8
|
+
|
|
9
|
+
Localized fields sent as maps of translations (`name: { de: "Stuhl", en: "Chair" }`)
|
|
10
|
+
now reach Emporix without a `fetch` override. Without a `Content-Language` header,
|
|
11
|
+
most services read localized fields as plain strings in the tenant's default
|
|
12
|
+
language and answer a map with a 400 — «localized values must be of String type
|
|
13
|
+
when the Content-Language header is not set to all languages».
|
|
14
|
+
|
|
15
|
+
- **`contentLanguage` in `EmporixConfig`** — sent as `Content-Language` on every
|
|
16
|
+
request that carries a body, never on a `GET`: `"*"` for maps, a language code
|
|
17
|
+
such as `"de"` for plain strings. Unset, nothing changes and no header is sent.
|
|
18
|
+
- **Per call on product and category writes** — `contentLanguage` in
|
|
19
|
+
`ProductWriteOptions` (`create`, `update`, `replace`, `bulkCreate`, `bulkUpdate`)
|
|
20
|
+
and in the new `CategoryWriteOptions` (`create`, `update`, `patch`) overrides the
|
|
21
|
+
client default for that request.
|
|
22
|
+
|
|
23
|
+
The other writes with localized payloads — product templates, price models,
|
|
24
|
+
catalogs, brands, currencies and the rest — have no options argument and use the
|
|
25
|
+
client default. The template and price-model input types allow only maps, so those
|
|
26
|
+
writes need `contentLanguage: "*"`. `docs/products.md` shows how to send a single
|
|
27
|
+
call in another language through a second client that shares the token provider.
|
|
28
|
+
|
|
29
|
+
## 4.3.1
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- [#389](https://github.com/viuteam/emporix-sdk/pull/389) [`784d80e`](https://github.com/viuteam/emporix-sdk/commit/784d80e4fc24b01e9e9fc5667d8e85dc0cad2433) Thanks [@viu-release-bot](https://github.com/apps/viu-release-bot)! - chore(sdk): sync generated types with upstream Emporix API specs
|
|
34
|
+
|
|
35
|
+
Updated services: ai-service
|
|
36
|
+
|
|
3
37
|
## 4.3.0
|
|
4
38
|
|
|
5
39
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -107,6 +107,7 @@ See [`../../docs/mixin-search.md`](../../docs/mixin-search.md) for the capabilit
|
|
|
107
107
|
| `logger` | console @ `warn` | `false`, a `Logger`, or `{ level, services, pretty, redact }` |
|
|
108
108
|
| `tokenProvider` | built-in | inject for SSO/token-exchange |
|
|
109
109
|
| `fetch` | global `fetch` | replaces `fetch` for API requests; token requests and SSE streams keep the global one |
|
|
110
|
+
| `contentLanguage` | — (no header) | `Content-Language` on every request with a body: `"*"` when localized fields are maps of translations, a language code when they are plain strings. Product and category writes override it per call — see [`../../docs/products.md`](../../docs/products.md#localized-writes) |
|
|
110
111
|
|
|
111
112
|
`credentials: {}` is legal: a client that never mints its own token, for when the
|
|
112
113
|
token comes from outside. The Managed Dashboard module in
|
package/dist/availability.d.cts
CHANGED
package/dist/availability.d.ts
CHANGED
package/dist/cart.d.cts
CHANGED
package/dist/cart.d.ts
CHANGED
package/dist/category.cjs
CHANGED
|
@@ -274,6 +274,7 @@ var CategoryService = class {
|
|
|
274
274
|
method: "POST",
|
|
275
275
|
path: `/category/${this.ctx.tenant}/categories`,
|
|
276
276
|
...options.publish === void 0 ? {} : { query: { publish: String(options.publish) } },
|
|
277
|
+
...options.contentLanguage === void 0 ? {} : { headers: { "Content-Language": options.contentLanguage } },
|
|
277
278
|
body: input,
|
|
278
279
|
auth
|
|
279
280
|
});
|
|
@@ -288,6 +289,7 @@ var CategoryService = class {
|
|
|
288
289
|
method: "PUT",
|
|
289
290
|
path: `/category/${this.ctx.tenant}/categories/${categoryId}`,
|
|
290
291
|
...options.publish === void 0 ? {} : { query: { publish: String(options.publish) } },
|
|
292
|
+
...options.contentLanguage === void 0 ? {} : { headers: { "Content-Language": options.contentLanguage } },
|
|
291
293
|
body: input,
|
|
292
294
|
auth
|
|
293
295
|
});
|
|
@@ -301,6 +303,7 @@ var CategoryService = class {
|
|
|
301
303
|
method: "PATCH",
|
|
302
304
|
path: `/category/${this.ctx.tenant}/categories/${categoryId}`,
|
|
303
305
|
...options.publish === void 0 ? {} : { query: { publish: String(options.publish) } },
|
|
306
|
+
...options.contentLanguage === void 0 ? {} : { headers: { "Content-Language": options.contentLanguage } },
|
|
304
307
|
body: input,
|
|
305
308
|
auth
|
|
306
309
|
});
|
package/dist/category.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/context.ts","../src/core/paged.ts","../src/core/query.ts","../src/services/category.ts"],"names":[],"mappings":";;;AAmDA,gBAAuB,UAAA,CACrB,SAAA,EACA,KAAA,GAAQ,CAAA,EACU;AAClB,EAAA,IAAI,CAAA,GAAI,KAAA;AACR,EAAA,WAAS;AACP,IAAA,MAAM,IAAA,GAAO,MAAM,SAAA,CAAU,CAAC,CAAA;AAC9B,IAAA,KAAA,MAAW,EAAA,IAAM,IAAA,CAAK,KAAA,EAAO,MAAM,EAAA;AACnC,IAAA,IAAI,CAAC,KAAK,WAAA,EAAa;AACvB,IAAA,CAAA,IAAK,CAAA;AAAA,EACP;AACF;;;ACrCA,SAAS,SAAA,CAAU,SA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AAA,QACxE;AAAA,OACD,CAAA;AAAA,IACH;AAAA,GACF;AACF","file":"category.cjs","sourcesContent":["import type { HttpClient } from \"./http\";\nimport type { TokenProvider, AuthContext } from \"./auth\";\nimport type { Logger } from \"./logger\";\n\n/** Shared dependencies every service facade receives. */\nexport interface ClientContext {\n tenant: string;\n http: HttpClient;\n tokenProvider: TokenProvider;\n logger: Logger;\n}\n\n/**\n * A cursor-paged collection — `pageNumber`/`pageSize` indexing with a\n * `hasNextPage` signal driven by the source page being full. Used by all\n * paginated services and hooks across the SDK.\n */\nexport interface PaginatedItems<T> {\n items: T[];\n pageNumber: number;\n pageSize: number;\n hasNextPage: boolean;\n /**\n * Absolute number of matches, when the caller asked for it and the endpoint\n * answered. Opt-in per call (`totalCount: true`), because Emporix computes it\n * with a second query — see `core/paged.ts`.\n *\n * Always `undefined` in cursor mode: the server ignores the request header\n * and omits the response header there.\n */\n totalCount?: number;\n /**\n * Opaque cursor for the next page, on the endpoints that offer one (today:\n * the schema service's custom instances). Pass it back as the `next` query\n * parameter. Absence means \"this endpoint said nothing\", NOT \"last page\".\n */\n nextCursor?: string;\n /** Opaque cursor for the previous page. Same caveat as {@link nextCursor}. */\n prevCursor?: string;\n}\n\n/** Default `AuthContext` applied by a service when the caller passes none. */\nexport type DefaultAuth = AuthContext | undefined;\n\n/**\n * Async-iterates every item across pages of a `PaginatedItems<T>` source.\n * Stops when the source reports `hasNextPage: false`.\n *\n * @param fetchPage - given a 1-based page number, returns the page.\n * @param start - first page to fetch (default `1`).\n */\nexport async function* iterateAll<T>(\n fetchPage: (pageNumber: number) => Promise<PaginatedItems<T>>,\n start = 1,\n): AsyncIterable<T> {\n let p = start;\n for (;;) {\n const page = await fetchPage(p);\n for (const it of page.items) yield it;\n if (!page.hasNextPage) return;\n p += 1;\n }\n}\n\n","import type { PaginatedItems } from \"./context\";\nimport type { HttpClient, RequestOptions } from \"./http\";\n\n/** Pagination inputs for {@link requestPage}. */\nexport interface PageParams {\n /** 1-based, as Emporix counts. */\n pageNumber: number;\n pageSize: number;\n /**\n * Ask Emporix for the absolute match count via the `X-Total-Count: true`\n * request header.\n *\n * Off by default and opt-in per call, not a client-wide setting: the count\n * costs the server a second query, and defaulting it on would put that cost\n * on every list every storefront issues.\n */\n totalCount?: boolean;\n}\n\n/**\n * Reads a non-negative integer header, or `undefined` when it is missing or is\n * not one. A malformed value must not reach the `hasNextPage` arithmetic —\n * `Number(\"lots\")` is `NaN`, and every comparison against `NaN` is `false`,\n * which would silently report \"last page\" on every page.\n */\nfunction intHeader(headers: Headers, name: string): number | undefined {\n const raw = headers.get(name);\n if (raw === null || raw.trim() === \"\") return undefined;\n const n = Number(raw);\n return Number.isInteger(n) && n >= 0 ? n : undefined;\n}\n\n/**\n * Issues one page of a list endpoint and assembles {@link PaginatedItems} from\n * the body plus Emporix's pagination response headers.\n *\n * Cursors travel in opposite directions: the caller sends one as the `next` or\n * `prev` **query parameter** (so it belongs in `o.query`), and the server\n * returns the following one as the `X-Next-Cursor` **response header**. This\n * helper only ever reads them.\n */\nexport async function requestPage<T>(\n http: HttpClient,\n o: RequestOptions,\n page: PageParams,\n): Promise<PaginatedItems<T>> {\n const { data, headers } = await http.requestWithMeta<T[]>(\n page.totalCount === true\n ? { ...o, headers: { ...(o.headers ?? {}), \"X-Total-Count\": \"true\" } }\n : o,\n );\n\n // A 204 or empty body parses to `undefined`. Facades used to index straight\n // into the result and would throw; an empty page is the honest answer.\n const items = data ?? [];\n const totalCount = intHeader(headers, \"X-Total-Count\");\n const nextCursor = headers.get(\"X-Next-Cursor\") ?? undefined;\n const prevCursor = headers.get(\"X-Prev-Cursor\") ?? undefined;\n\n // Three tiers, most precise first. Tier 1 is ONE-DIRECTIONAL on purpose: only\n // two endpoints in the whole API emit a cursor header, so its absence says\n // nothing at all and has to fall through to the other two.\n const hasNextPage =\n nextCursor !== undefined\n ? true\n : totalCount !== undefined\n ? page.pageNumber * page.pageSize < totalCount\n : items.length === page.pageSize;\n\n // Spread conditionally — `exactOptionalPropertyTypes` rejects an explicit\n // `undefined` for an optional property.\n return {\n items,\n pageNumber: page.pageNumber,\n pageSize: page.pageSize,\n hasNextPage,\n ...(totalCount === undefined ? {} : { totalCount }),\n ...(nextCursor === undefined ? {} : { nextCursor }),\n ...(prevCursor === undefined ? {} : { prevCursor }),\n };\n}\n","/**\n * A built query filter — structurally matched, NOT imported, so the SDK stays\n * decoupled from `@viu/emporix-mixins` (which lists the SDK as an optional\n * peer; a real import would be circular). `@viu/emporix-mixins`' `MixinFilter<E>`\n * satisfies this shape.\n */\nexport interface BuiltQuery<E extends string = string> {\n toString(): string;\n readonly usesCompound?: boolean;\n /** Phantom entity tag — gates which service a filter may be passed to. */\n readonly __entity?: E;\n}\n\n/** A `q` value a service method accepts: a raw DSL string or a built filter for entity `E`. */\nexport type QueryFor<E extends string = string> = string | BuiltQuery<E>;\n\n/** Per-service capability flags consulted by {@link resolveQuery}. */\nexport interface QueryCapability {\n /** Whether the target service supports the `compoundLogicalQuery` (OR) operator. */\n compoundLogicalQuery: boolean;\n}\n\n/**\n * Normalizes a `string | BuiltQuery` into a `q` string and enforces the\n * `compoundLogicalQuery` capability gate: an `or()`-built filter passed to a\n * service that does not support it throws rather than silently producing a\n * query the backend cannot execute.\n */\nexport function resolveQuery(q: QueryFor, cap: QueryCapability): string {\n if (typeof q === \"string\") return q;\n if (q.usesCompound === true && !cap.compoundLogicalQuery) {\n throw new Error(\n \"This filter uses or()/compoundLogicalQuery, which the target service does not support. \" +\n \"Combine conditions with and() (space-separated AND) instead.\",\n );\n }\n return q.toString();\n}\n","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 { Product } from \"./product\";\nimport type {\n Category as GeneratedCategory,\n CategoryTree,\n CategoryCreateRequest,\n CategoryUpdateRequest,\n CategoryPartialUpdateRequest,\n CategoryIdResponse,\n CategoryTreeSearchRequest,\n CategoryAssignment as GeneratedCategoryAssignment,\n AssignmentRequest,\n BulkAssignmentRequest,\n BulkAssignmentUpsertRequest,\n BulkAssignmentResponse,\n AssignmentIdResponse,\n} from \"../generated/category\";\n\nconst ANON: AuthContext = { kind: \"anonymous\" };\nconst SERVICE: AuthContext = { kind: \"service\" };\n\n/** A category as returned by the Category service (all generated fields). */\nexport type Category = GeneratedCategory;\n\n/** The category tree as returned by the Category service. */\nexport type CategoryNode = CategoryTree;\n\n/** Body for creating a category (`POST /categories`). */\nexport type CategoryCreateInput = CategoryCreateRequest;\n\n/** Body for a full category replace (`PUT /categories/{id}`). */\nexport type CategoryUpdateInput = CategoryUpdateRequest;\n\n/** Body for a partial category update (`PATCH /categories/{id}`). */\nexport type CategoryPatchInput = CategoryPartialUpdateRequest;\n\n/** Id envelope returned when a category is created. */\nexport type CategoryCreated = CategoryIdResponse;\n\n/** Body for searching category trees (`POST /category-trees/search`). */\nexport type CategoryTreeSearchInput = CategoryTreeSearchRequest;\n\n/** A category assignment (a resource reference bound to a category). */\nexport type CategoryAssignment = GeneratedCategoryAssignment;\n\n/** Body for assigning a single resource to a category. */\nexport type CategoryAssignmentInput = AssignmentRequest;\n\n/** Body for bulk-assigning resources to a category. */\nexport type CategoryAssignmentBulkInput = BulkAssignmentRequest;\n\n/** Body for bulk-upserting assignment references (`ref.id` only). */\nexport type CategoryAssignmentRefBulkInput = BulkAssignmentUpsertRequest;\n\n/** Multi-status result of a bulk assignment operation. */\nexport type CategoryAssignmentBulkResult = BulkAssignmentResponse;\n\n/** Id envelope returned when an assignment is created. */\nexport type CategoryAssignmentCreated = AssignmentIdResponse;\n\n/** Category reads. Default auth: anonymous. */\nexport class CategoryService {\n static readonly channel = \"category\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n /** Fetches one category by id. */\n async get(categoryId: string, auth: AuthContext = ANON): Promise<Category> {\n return this.ctx.http.request<Category>({\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}`,\n auth,\n });\n }\n\n /** One page of categories. */\n async list(\n params: { pageNumber?: number; pageSize?: number; totalCount?: boolean } = {},\n auth: AuthContext = ANON,\n ): Promise<PaginatedItems<Category>> {\n const pageNumber = params.pageNumber ?? 1;\n const pageSize = params.pageSize ?? 50;\n return requestPage<Category>(\n this.ctx.http,\n {\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/categories`,\n query: { pageNumber, pageSize },\n auth,\n },\n {\n pageNumber,\n pageSize,\n ...(params.totalCount === undefined ? {} : { totalCount: params.totalCount }),\n },\n );\n }\n\n /**\n * Searches categories by a `q` filter — a raw Emporix DSL string or a built\n * filter (e.g. `@viu/emporix-mixins`' `mixinQuery(...)`). Category does not\n * support `compoundLogicalQuery`, so `or()` filters are rejected.\n */\n async search(\n query: QueryFor<\"CATEGORY\">,\n params: { pageNumber?: number; pageSize?: number; totalCount?: boolean } = {},\n auth: AuthContext = ANON,\n ): Promise<PaginatedItems<Category>> {\n const q = resolveQuery(query, { compoundLogicalQuery: false });\n const pageNumber = params.pageNumber ?? 1;\n const pageSize = params.pageSize ?? 50;\n return requestPage<Category>(\n this.ctx.http,\n {\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/categories`,\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 /** Async-iterates every category across pages. */\n listAll(params: { pageSize?: number } = {}, auth: AuthContext = ANON): AsyncIterable<Category> {\n const pageSize = params.pageSize ?? 50;\n return iterateAll<Category>((pageNumber) => this.list({ pageNumber, pageSize }, auth));\n }\n\n /**\n * The catalogue's **root categories** — the published category trees\n * (`GET /category-trees`).\n *\n * Returns `CategoryNode[]` (the generated `CategoryTree`), not `Category[]`.\n * The two differ: `Category` carries `parentId` and no `subcategories`,\n * `CategoryTree` the reverse, and this endpoint answers with the latter.\n * Measured against a live tenant on 2026-08-04 — every node had\n * `subcategories` or nothing, none had `parentId`.\n *\n * **Children arrive inline in `subcategories`.** Do not reach for\n * {@link subcategories} to drill down: that method reads category-to-category\n * *assignments* (`/categories/{id}/assignments`, filtered to\n * `ref.type === \"CATEGORY\"`), which is a different feature — on the tenant this\n * was measured on, that filter answered empty for every category while the\n * `\"PRODUCT\"` filter behind {@link productsIn} worked fine.\n * {@link childCategories} hits `/categories/{id}/subcategories` and answers\n * **404** for a tree root. One call gives you the whole hierarchy.\n */\n async tree(auth: AuthContext = ANON): Promise<CategoryNode[]> {\n return this.ctx.http.request<CategoryNode[]>({\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/category-trees`,\n auth,\n });\n }\n\n /**\n * Rebuild a category tree from its root (`POST /category-trees/{rootCategoryId}/rebuild`).\n * Admin write — defaults to the service token. Returns the rebuilt tree.\n */\n async rebuildTree(rootCategoryId: string, auth: AuthContext = SERVICE): Promise<CategoryNode> {\n return this.ctx.http.request<CategoryNode>({\n method: \"POST\",\n path: `/category/${this.ctx.tenant}/category-trees/${encodeURIComponent(rootCategoryId)}/rebuild`,\n auth,\n });\n }\n\n /**\n * Direct child categories of a category (for hierarchy drill-down). Mirrors\n * {@link productsIn}: reads the category's **assignments** and keeps the\n * `CATEGORY` references, resolving them to full categories. Returns an empty\n * array when the category has no child categories.\n */\n async subcategories(\n categoryId: string,\n params: { pageNumber?: number; pageSize?: number } = {},\n auth: AuthContext = ANON,\n ): Promise<Category[]> {\n const pageNumber = params.pageNumber ?? 1;\n const pageSize = params.pageSize ?? 50;\n const assignments = await this.ctx.http.request<Array<{ ref?: { id?: string; type?: string } }>>({\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments`,\n query: { pageNumber, pageSize },\n auth,\n });\n const categoryIds = assignments\n .map((a) => (a.ref?.type?.toUpperCase() === \"CATEGORY\" ? a.ref.id : undefined))\n .filter((id): id is string => Boolean(id));\n if (categoryIds.length === 0) return [];\n return this.searchByIds(categoryIds, {}, auth);\n }\n\n /**\n * One page of products in a category. The category service exposes products\n * as **assignments** (`/categories/{id}/assignments`) — references, not full\n * products — so this fetches a page of assignments, keeps the `PRODUCT`\n * references, and resolves them to full products via `/products/search`.\n * `hasNextPage` reflects the assignments page (the source of truth for\n * pagination).\n *\n * No `totalCount` opt-in here, deliberately. `X-Total-Count` on the\n * assignments request would count **assignments** — including the `CATEGORY`\n * references filtered out below — not the products this returns. A number\n * that is wrong in the way that is hardest to notice. Same reason\n * `segments.listMyProducts` stays on the guess.\n */\n async productsIn(\n categoryId: string,\n params: { pageNumber?: number; pageSize?: number } = {},\n auth: AuthContext = ANON,\n ): Promise<PaginatedItems<Product>> {\n const pageNumber = params.pageNumber ?? 1;\n const pageSize = params.pageSize ?? 50;\n const assignments = await this.ctx.http.request<Array<{ ref?: { id?: string; type?: string } }>>({\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments`,\n query: { pageNumber, pageSize },\n auth,\n });\n const hasNextPage = assignments.length === pageSize;\n const productIds = assignments\n .map((a) => (a.ref?.type?.toUpperCase() === \"PRODUCT\" ? a.ref.id : undefined))\n .filter((id): id is string => Boolean(id));\n if (productIds.length === 0) {\n return { items: [], pageNumber, pageSize, hasNextPage };\n }\n const items = await this.ctx.http.request<Product[]>({\n method: \"POST\",\n path: `/product/${this.ctx.tenant}/products/search`,\n query: { pageSize: productIds.length },\n auth,\n body: { q: `id:(${productIds.join(\",\")})` },\n idempotent: true, // pure read over POST — safe to replay on 5xx/429\n });\n return { items, pageNumber, pageSize, hasNextPage };\n }\n\n /**\n * Bulk fetch by id. POSTs `/categories/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<Category[]> {\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<Category[]>({\n method: \"POST\",\n path: `/category/${this.ctx.tenant}/categories/search`,\n query: { pageSize: chunk.length },\n auth,\n body: { q: `id:(${chunk.join(\",\")})` },\n }),\n ),\n );\n return pages.flat();\n }\n\n /** Lists a category's ancestor categories (breadcrumb-up). Default auth: anonymous. */\n async parents(categoryId: string, auth: AuthContext = ANON): Promise<Category[]> {\n return this.ctx.http.request<Category[]>({\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/parents`,\n auth,\n });\n }\n\n /**\n * Lists a category's direct child categories via the dedicated\n * `…/subcategories` endpoint. (The older `subcategories()` reads `/assignments`\n * and is kept for backward compatibility.) Default auth: anonymous.\n */\n async childCategories(categoryId: string, auth: AuthContext = ANON): Promise<Category[]> {\n return this.ctx.http.request<Category[]>({\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/subcategories`,\n auth,\n });\n }\n\n /** Retrieves one category tree by its root category id. Default auth: anonymous. */\n async getTree(categoryId: string, auth: AuthContext = ANON): Promise<CategoryNode> {\n return this.ctx.http.request<CategoryNode>({\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/category-trees/${encodeURIComponent(categoryId)}`,\n auth,\n });\n }\n\n // --- Admin write CRUD. Default auth: service. ---\n\n /**\n * Creates a category (`POST /categories`). Default auth: service.\n * `options.publish` sets the `publish` query flag (needs the\n * `category.category_publish` scope).\n */\n async create(\n input: CategoryCreateInput,\n options: { publish?: boolean } = {},\n auth: AuthContext = SERVICE,\n ): Promise<CategoryCreated> {\n return this.ctx.http.request<CategoryCreated>({\n method: \"POST\",\n path: `/category/${this.ctx.tenant}/categories`,\n ...(options.publish === undefined ? {} : { query: { publish: String(options.publish) } }),\n body: input,\n auth,\n });\n }\n\n /**\n * Full-replaces a category (`PUT /categories/{categoryId}`). This is an\n * upsert: with a caller-supplied id it may create (201, returns the id) or\n * update an existing one (204, returns nothing). Default auth: service.\n */\n async update(\n categoryId: string,\n input: CategoryUpdateInput,\n options: { publish?: boolean } = {},\n auth: AuthContext = SERVICE,\n ): Promise<CategoryCreated | void> {\n return this.ctx.http.request<CategoryCreated | void>({\n method: \"PUT\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}`,\n ...(options.publish === undefined ? {} : { query: { publish: String(options.publish) } }),\n body: input,\n auth,\n });\n }\n\n /**\n * Partially updates a category (`PATCH /categories/{categoryId}`). Default\n * auth: service. `options.publish` sets the `publish` query flag.\n */\n async patch(\n categoryId: string,\n input: CategoryPatchInput,\n options: { publish?: boolean } = {},\n auth: AuthContext = SERVICE,\n ): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"PATCH\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}`,\n ...(options.publish === undefined ? {} : { query: { publish: String(options.publish) } }),\n body: input,\n auth,\n });\n }\n\n /** Deletes a category (`DELETE /categories/{categoryId}`). Default auth: service. */\n async delete(categoryId: string, auth: AuthContext = SERVICE): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}`,\n auth,\n });\n }\n\n /**\n * Searches categories via `POST /categories/search`. Same query capability\n * as {@link search} (`compoundLogicalQuery: false` — Category rejects `or()`\n * filters); the POST body avoids URL-length limits for large `q` filters.\n * `params.showRoots` / `params.showUnpublished` are POST-only flags. Default\n * auth: anonymous.\n */\n async searchByQuery(\n query: QueryFor<\"CATEGORY\">,\n params: { pageNumber?: number; pageSize?: number; sort?: string; showRoots?: boolean; showUnpublished?: boolean; totalCount?: boolean } = {},\n auth: AuthContext = ANON,\n ): Promise<PaginatedItems<Category>> {\n const q = resolveQuery(query, { compoundLogicalQuery: false });\n const pageNumber = params.pageNumber ?? 1;\n const pageSize = params.pageSize ?? 50;\n return requestPage<Category>(\n this.ctx.http,\n {\n method: \"POST\",\n path: `/category/${this.ctx.tenant}/categories/search`,\n query: {\n pageNumber,\n pageSize,\n ...(params.sort === undefined ? {} : { sort: params.sort }),\n ...(params.showRoots === undefined ? {} : { showRoots: String(params.showRoots) }),\n ...(params.showUnpublished === undefined ? {} : { showUnpublished: String(params.showUnpublished) }),\n },\n body: { q },\n idempotent: true, // pure read over POST — safe to replay on 5xx/429\n auth,\n },\n {\n pageNumber,\n pageSize,\n ...(params.totalCount === undefined ? {} : { totalCount: params.totalCount }),\n },\n );\n }\n\n /**\n * Searches category trees via `POST /category-trees/search` — returns the\n * trees that include at least one of the given `categoryIds`. Default auth:\n * anonymous.\n */\n async searchTrees(\n input: CategoryTreeSearchInput,\n options: { showUnpublished?: boolean } = {},\n auth: AuthContext = ANON,\n ): Promise<CategoryNode[]> {\n return this.ctx.http.request<CategoryNode[]>({\n method: \"POST\",\n path: `/category/${this.ctx.tenant}/category-trees/search`,\n ...(options.showUnpublished === undefined ? {} : { query: { showUnpublished: String(options.showUnpublished) } }),\n body: input,\n idempotent: true, // pure read over POST — safe to replay on 5xx/429\n auth,\n });\n }\n\n /**\n * Category ↔ resource assignments. Writes default to service auth. The\n * assignment `ref.type` is `'PRODUCT'` (per the API); category hierarchy is\n * managed via `parentId` on the category, not via assignments.\n */\n readonly assignments = {\n /** One page of a category's assignments. Default auth: anonymous. */\n list: async (\n categoryId: string,\n params: { pageNumber?: number; pageSize?: number; sort?: string; expandSupercategoriesIds?: boolean; showUnpublished?: boolean } = {},\n auth: AuthContext = ANON,\n ): Promise<CategoryAssignment[]> =>\n this.ctx.http.request<CategoryAssignment[]>({\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments`,\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.expandSupercategoriesIds === undefined ? {} : { expandSupercategoriesIds: String(params.expandSupercategoriesIds) }),\n ...(params.showUnpublished === undefined ? {} : { showUnpublished: String(params.showUnpublished) }),\n },\n auth,\n }),\n\n /** Assigns a single resource to a category (`POST …/assignments`). Default auth: service. */\n create: async (categoryId: string, input: CategoryAssignmentInput, auth: AuthContext = SERVICE): Promise<CategoryAssignmentCreated> =>\n this.ctx.http.request<CategoryAssignmentCreated>({\n method: \"POST\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments`,\n body: input,\n auth,\n }),\n\n /** Bulk-assigns resources to a category (`POST …/assignments/bulk`). Default auth: service. */\n bulkCreate: async (categoryId: string, input: CategoryAssignmentBulkInput, auth: AuthContext = SERVICE): Promise<CategoryAssignmentBulkResult> =>\n this.ctx.http.request<CategoryAssignmentBulkResult>({\n method: \"POST\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments/bulk`,\n body: input,\n auth,\n }),\n\n /** Removes one assignment by id (`DELETE …/assignments/{assignmentId}`). Default auth: service. */\n remove: async (categoryId: string, assignmentId: string, auth: AuthContext = SERVICE): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments/${assignmentId}`,\n auth,\n });\n },\n\n /** Removes all of a category's assignments (`DELETE …/assignments`). Default auth: service. */\n removeAll: async (categoryId: string, options: { assignmentType?: \"PRODUCT\" } = {}, auth: AuthContext = SERVICE): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments`,\n ...(options.assignmentType === undefined ? {} : { query: { assignmentType: options.assignmentType } }),\n auth,\n });\n },\n\n /** Upserts an assignment by reference id — no body (`PUT …/assignments/references/{referenceId}`). Default auth: service. */\n upsertByReference: async (categoryId: string, referenceId: string, auth: AuthContext = SERVICE): Promise<CategoryAssignmentCreated> =>\n this.ctx.http.request<CategoryAssignmentCreated>({\n method: \"PUT\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments/references/${referenceId}`,\n auth,\n }),\n\n /** Removes an assignment by reference id (`DELETE …/assignments/references/{referenceId}`). Default auth: service. */\n removeByReference: async (categoryId: string, referenceId: string, auth: AuthContext = SERVICE): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments/references/${referenceId}`,\n auth,\n });\n },\n\n /** Bulk-upserts assignment references (`PUT …/assignments/references/bulk`). Default auth: service. */\n bulkUpsertByReference: async (categoryId: string, input: CategoryAssignmentRefBulkInput, auth: AuthContext = SERVICE): Promise<CategoryAssignmentBulkResult> =>\n this.ctx.http.request<CategoryAssignmentBulkResult>({\n method: \"PUT\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments/references/bulk`,\n body: input,\n auth,\n }),\n\n /**\n * Lists every category assigned to the given reference id — tenant-wide\n * (`GET /assignments/references/{referenceId}`). Default auth: anonymous.\n */\n listCategoriesByReference: async (\n referenceId: string,\n params: { pageNumber?: number; pageSize?: number; sort?: string; showUnpublished?: boolean; expandSupercategoriesIds?: boolean } = {},\n auth: AuthContext = ANON,\n ): Promise<Category[]> =>\n this.ctx.http.request<Category[]>({\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/assignments/references/${referenceId}`,\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.showUnpublished === undefined ? {} : { showUnpublished: String(params.showUnpublished) }),\n ...(params.expandSupercategoriesIds === undefined ? {} : { expandSupercategoriesIds: String(params.expandSupercategoriesIds) }),\n },\n auth,\n }),\n\n /** Removes all assignments to a given reference id — tenant-wide (`DELETE /assignments/references/{referenceId}`). Default auth: service. */\n removeAllByReference: async (referenceId: string, auth: AuthContext = SERVICE): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/category/${this.ctx.tenant}/assignments/references/${referenceId}`,\n auth,\n });\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/core/context.ts","../src/core/paged.ts","../src/core/query.ts","../src/services/category.ts"],"names":[],"mappings":";;;AAmDA,gBAAuB,UAAA,CACrB,SAAA,EACA,KAAA,GAAQ,CAAA,EACU;AAClB,EAAA,IAAI,CAAA,GAAI,KAAA;AACR,EAAA,WAAS;AACP,IAAA,MAAM,IAAA,GAAO,MAAM,SAAA,CAAU,CAAC,CAAA;AAC9B,IAAA,KAAA,MAAW,EAAA,IAAM,IAAA,CAAK,KAAA,EAAO,MAAM,EAAA;AACnC,IAAA,IAAI,CAAC,KAAK,WAAA,EAAa;AACvB,IAAA,CAAA,IAAK,CAAA;AAAA,EACP;AACF;;;ACrCA,SAAS,SAAA,CAAU,SAAkB,IAAA,EAAkC;AACrE,EAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,GAAA,CAAI,IAAI,CAAA;AAC5B,EAAA,IAAI,QAAQ,IAAA,IAAQ,GAAA,CAAI,IAAA,EAAK,KAAM,IAAI,OAAO,MAAA;AAC9C,EAAA,MAAM,CAAA,GAAI,OAAO,GAAG,CAAA;AACpB,EAAA,OAAO,OAAO,SAAA,CAAU,CAAC,CAAA,IAAK,CAAA,IAAK,IAAI,CAAA,GAAI,MAAA;AAC7C;AAWA,eAAsB,WAAA,CACpB,IAAA,EACA,CAAA,EACA,IAAA,EAC4B;AAC5B,EAAA,MAAM,EAAE,IAAA,EAAM,OAAA,EAAQ,GAAI,MAAM,IAAA,CAAK,eAAA;AAAA,IACnC,KAAK,UAAA,KAAe,IAAA,GAChB,EAAE,GAAG,GAAG,OAAA,EAAS,EAAE,GAAI,CAAA,CAAE,WAAW,EAAC,EAAI,eAAA,EAAiB,MAAA,IAAS,GACnE;AAAA,GACN;AAIA,EAAA,MAAM,KAAA,GAAQ,QAAQ,EAAC;AACvB,EAAA,MAAM,UAAA,GAAa,SAAA,CAAU,OAAA,EAAS,eAAe,CAAA;AACrD,EAAA,MAAM,UAAA,GA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A;AAAA,MACxE,KAAA,EAAO;AAAA,QACL,GAAI,OAAO,UAAA,KAAe,MAAA,GAAY,EAAC,GAAI,EAAE,UAAA,EAAY,MAAA,CAAO,UAAA,EAAW;AAAA,QAC3E,GAAI,OAAO,QAAA,KAAa,MAAA,GAAY,EAAC,GAAI,EAAE,QAAA,EAAU,MAAA,CAAO,QAAA,EAAS;AAAA,QACrE,GAAI,OAAO,IAAA,KAAS,MAAA,GAAY,EAAC,GAAI,EAAE,IAAA,EAAM,MAAA,CAAO,IAAA,EAAK;AAAA,QACzD,GAAI,MAAA,CAAO,eAAA,KAAoB,MAAA,GAAY,EAAC,GAAI,EAAE,eAAA,EAAiB,MAAA,CAAO,MAAA,CAAO,eAAe,CAAA,EAAE;AAAA,QAClG,GAAI,MAAA,CAAO,wBAAA,KAA6B,MAAA,GAAY,EAAC,GAAI,EAAE,wBAAA,EAA0B,MAAA,CAAO,MAAA,CAAO,wBAAwB,CAAA;AAAE,OAC/H;AAAA,MACA;AAAA,KACD,CAAA;AAAA;AAAA,IAGH,oBAAA,EAAsB,OAAO,WAAA,EAAqB,IAAA,GAAoB,OAAA,KAA2B;AAC/F,MAAA,MAAM,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAc;AAAA,QAChC,MAAA,EAAQ,QAAA;AAAA,QACR,MAAM,CAAA,UAAA,EAAa,IAAA,CAAK,GAAA,CAAI,MAAM,2BAA2B,WAAW,CAAA,CAAA;AAAA,QACxE;AAAA,OACD,CAAA;AAAA,IACH;AAAA,GACF;AACF","file":"category.cjs","sourcesContent":["import type { HttpClient } from \"./http\";\nimport type { TokenProvider, AuthContext } from \"./auth\";\nimport type { Logger } from \"./logger\";\n\n/** Shared dependencies every service facade receives. */\nexport interface ClientContext {\n tenant: string;\n http: HttpClient;\n tokenProvider: TokenProvider;\n logger: Logger;\n}\n\n/**\n * A cursor-paged collection — `pageNumber`/`pageSize` indexing with a\n * `hasNextPage` signal driven by the source page being full. Used by all\n * paginated services and hooks across the SDK.\n */\nexport interface PaginatedItems<T> {\n items: T[];\n pageNumber: number;\n pageSize: number;\n hasNextPage: boolean;\n /**\n * Absolute number of matches, when the caller asked for it and the endpoint\n * answered. Opt-in per call (`totalCount: true`), because Emporix computes it\n * with a second query — see `core/paged.ts`.\n *\n * Always `undefined` in cursor mode: the server ignores the request header\n * and omits the response header there.\n */\n totalCount?: number;\n /**\n * Opaque cursor for the next page, on the endpoints that offer one (today:\n * the schema service's custom instances). Pass it back as the `next` query\n * parameter. Absence means \"this endpoint said nothing\", NOT \"last page\".\n */\n nextCursor?: string;\n /** Opaque cursor for the previous page. Same caveat as {@link nextCursor}. */\n prevCursor?: string;\n}\n\n/** Default `AuthContext` applied by a service when the caller passes none. */\nexport type DefaultAuth = AuthContext | undefined;\n\n/**\n * Async-iterates every item across pages of a `PaginatedItems<T>` source.\n * Stops when the source reports `hasNextPage: false`.\n *\n * @param fetchPage - given a 1-based page number, returns the page.\n * @param start - first page to fetch (default `1`).\n */\nexport async function* iterateAll<T>(\n fetchPage: (pageNumber: number) => Promise<PaginatedItems<T>>,\n start = 1,\n): AsyncIterable<T> {\n let p = start;\n for (;;) {\n const page = await fetchPage(p);\n for (const it of page.items) yield it;\n if (!page.hasNextPage) return;\n p += 1;\n }\n}\n\n","import type { PaginatedItems } from \"./context\";\nimport type { HttpClient, RequestOptions } from \"./http\";\n\n/** Pagination inputs for {@link requestPage}. */\nexport interface PageParams {\n /** 1-based, as Emporix counts. */\n pageNumber: number;\n pageSize: number;\n /**\n * Ask Emporix for the absolute match count via the `X-Total-Count: true`\n * request header.\n *\n * Off by default and opt-in per call, not a client-wide setting: the count\n * costs the server a second query, and defaulting it on would put that cost\n * on every list every storefront issues.\n */\n totalCount?: boolean;\n}\n\n/**\n * Reads a non-negative integer header, or `undefined` when it is missing or is\n * not one. A malformed value must not reach the `hasNextPage` arithmetic —\n * `Number(\"lots\")` is `NaN`, and every comparison against `NaN` is `false`,\n * which would silently report \"last page\" on every page.\n */\nfunction intHeader(headers: Headers, name: string): number | undefined {\n const raw = headers.get(name);\n if (raw === null || raw.trim() === \"\") return undefined;\n const n = Number(raw);\n return Number.isInteger(n) && n >= 0 ? n : undefined;\n}\n\n/**\n * Issues one page of a list endpoint and assembles {@link PaginatedItems} from\n * the body plus Emporix's pagination response headers.\n *\n * Cursors travel in opposite directions: the caller sends one as the `next` or\n * `prev` **query parameter** (so it belongs in `o.query`), and the server\n * returns the following one as the `X-Next-Cursor` **response header**. This\n * helper only ever reads them.\n */\nexport async function requestPage<T>(\n http: HttpClient,\n o: RequestOptions,\n page: PageParams,\n): Promise<PaginatedItems<T>> {\n const { data, headers } = await http.requestWithMeta<T[]>(\n page.totalCount === true\n ? { ...o, headers: { ...(o.headers ?? {}), \"X-Total-Count\": \"true\" } }\n : o,\n );\n\n // A 204 or empty body parses to `undefined`. Facades used to index straight\n // into the result and would throw; an empty page is the honest answer.\n const items = data ?? [];\n const totalCount = intHeader(headers, \"X-Total-Count\");\n const nextCursor = headers.get(\"X-Next-Cursor\") ?? undefined;\n const prevCursor = headers.get(\"X-Prev-Cursor\") ?? undefined;\n\n // Three tiers, most precise first. Tier 1 is ONE-DIRECTIONAL on purpose: only\n // two endpoints in the whole API emit a cursor header, so its absence says\n // nothing at all and has to fall through to the other two.\n const hasNextPage =\n nextCursor !== undefined\n ? true\n : totalCount !== undefined\n ? page.pageNumber * page.pageSize < totalCount\n : items.length === page.pageSize;\n\n // Spread conditionally — `exactOptionalPropertyTypes` rejects an explicit\n // `undefined` for an optional property.\n return {\n items,\n pageNumber: page.pageNumber,\n pageSize: page.pageSize,\n hasNextPage,\n ...(totalCount === undefined ? {} : { totalCount }),\n ...(nextCursor === undefined ? {} : { nextCursor }),\n ...(prevCursor === undefined ? {} : { prevCursor }),\n };\n}\n","/**\n * A built query filter — structurally matched, NOT imported, so the SDK stays\n * decoupled from `@viu/emporix-mixins` (which lists the SDK as an optional\n * peer; a real import would be circular). `@viu/emporix-mixins`' `MixinFilter<E>`\n * satisfies this shape.\n */\nexport interface BuiltQuery<E extends string = string> {\n toString(): string;\n readonly usesCompound?: boolean;\n /** Phantom entity tag — gates which service a filter may be passed to. */\n readonly __entity?: E;\n}\n\n/** A `q` value a service method accepts: a raw DSL string or a built filter for entity `E`. */\nexport type QueryFor<E extends string = string> = string | BuiltQuery<E>;\n\n/** Per-service capability flags consulted by {@link resolveQuery}. */\nexport interface QueryCapability {\n /** Whether the target service supports the `compoundLogicalQuery` (OR) operator. */\n compoundLogicalQuery: boolean;\n}\n\n/**\n * Normalizes a `string | BuiltQuery` into a `q` string and enforces the\n * `compoundLogicalQuery` capability gate: an `or()`-built filter passed to a\n * service that does not support it throws rather than silently producing a\n * query the backend cannot execute.\n */\nexport function resolveQuery(q: QueryFor, cap: QueryCapability): string {\n if (typeof q === \"string\") return q;\n if (q.usesCompound === true && !cap.compoundLogicalQuery) {\n throw new Error(\n \"This filter uses or()/compoundLogicalQuery, which the target service does not support. \" +\n \"Combine conditions with and() (space-separated AND) instead.\",\n );\n }\n return q.toString();\n}\n","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 { Product } from \"./product\";\nimport type {\n Category as GeneratedCategory,\n CategoryTree,\n CategoryCreateRequest,\n CategoryUpdateRequest,\n CategoryPartialUpdateRequest,\n CategoryIdResponse,\n CategoryTreeSearchRequest,\n CategoryAssignment as GeneratedCategoryAssignment,\n AssignmentRequest,\n BulkAssignmentRequest,\n BulkAssignmentUpsertRequest,\n BulkAssignmentResponse,\n AssignmentIdResponse,\n} from \"../generated/category\";\n\nconst ANON: AuthContext = { kind: \"anonymous\" };\nconst SERVICE: AuthContext = { kind: \"service\" };\n\n/** A category as returned by the Category service (all generated fields). */\nexport type Category = GeneratedCategory;\n\n/** The category tree as returned by the Category service. */\nexport type CategoryNode = CategoryTree;\n\n/** Body for creating a category (`POST /categories`). */\nexport type CategoryCreateInput = CategoryCreateRequest;\n\n/** Body for a full category replace (`PUT /categories/{id}`). */\nexport type CategoryUpdateInput = CategoryUpdateRequest;\n\n/** Body for a partial category update (`PATCH /categories/{id}`). */\nexport type CategoryPatchInput = CategoryPartialUpdateRequest;\n\n/** Id envelope returned when a category is created. */\nexport type CategoryCreated = CategoryIdResponse;\n\n/** Body for searching category trees (`POST /category-trees/search`). */\nexport type CategoryTreeSearchInput = CategoryTreeSearchRequest;\n\n/** A category assignment (a resource reference bound to a category). */\nexport type CategoryAssignment = GeneratedCategoryAssignment;\n\n/** Body for assigning a single resource to a category. */\nexport type CategoryAssignmentInput = AssignmentRequest;\n\n/** Body for bulk-assigning resources to a category. */\nexport type CategoryAssignmentBulkInput = BulkAssignmentRequest;\n\n/** Body for bulk-upserting assignment references (`ref.id` only). */\nexport type CategoryAssignmentRefBulkInput = BulkAssignmentUpsertRequest;\n\n/** Multi-status result of a bulk assignment operation. */\nexport type CategoryAssignmentBulkResult = BulkAssignmentResponse;\n\n/** Id envelope returned when an assignment is created. */\nexport type CategoryAssignmentCreated = AssignmentIdResponse;\n\n/** Options shared by the category write endpoints (create, update, patch). */\nexport interface CategoryWriteOptions {\n /** Sets the `publish` query flag (needs the `category.category_publish` scope). */\n publish?: boolean;\n /**\n * `Content-Language` for this call, overriding `EmporixConfig.contentLanguage`.\n * Category localized fields are maps whatever it says; the header limits the\n * languages they may contain (`\"de\"`, `\"en,de\"`), and without one the\n * service allows every tenant language.\n */\n contentLanguage?: string;\n}\n\n/** Category reads. Default auth: anonymous. */\nexport class CategoryService {\n static readonly channel = \"category\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n /** Fetches one category by id. */\n async get(categoryId: string, auth: AuthContext = ANON): Promise<Category> {\n return this.ctx.http.request<Category>({\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}`,\n auth,\n });\n }\n\n /** One page of categories. */\n async list(\n params: { pageNumber?: number; pageSize?: number; totalCount?: boolean } = {},\n auth: AuthContext = ANON,\n ): Promise<PaginatedItems<Category>> {\n const pageNumber = params.pageNumber ?? 1;\n const pageSize = params.pageSize ?? 50;\n return requestPage<Category>(\n this.ctx.http,\n {\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/categories`,\n query: { pageNumber, pageSize },\n auth,\n },\n {\n pageNumber,\n pageSize,\n ...(params.totalCount === undefined ? {} : { totalCount: params.totalCount }),\n },\n );\n }\n\n /**\n * Searches categories by a `q` filter — a raw Emporix DSL string or a built\n * filter (e.g. `@viu/emporix-mixins`' `mixinQuery(...)`). Category does not\n * support `compoundLogicalQuery`, so `or()` filters are rejected.\n */\n async search(\n query: QueryFor<\"CATEGORY\">,\n params: { pageNumber?: number; pageSize?: number; totalCount?: boolean } = {},\n auth: AuthContext = ANON,\n ): Promise<PaginatedItems<Category>> {\n const q = resolveQuery(query, { compoundLogicalQuery: false });\n const pageNumber = params.pageNumber ?? 1;\n const pageSize = params.pageSize ?? 50;\n return requestPage<Category>(\n this.ctx.http,\n {\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/categories`,\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 /** Async-iterates every category across pages. */\n listAll(params: { pageSize?: number } = {}, auth: AuthContext = ANON): AsyncIterable<Category> {\n const pageSize = params.pageSize ?? 50;\n return iterateAll<Category>((pageNumber) => this.list({ pageNumber, pageSize }, auth));\n }\n\n /**\n * The catalogue's **root categories** — the published category trees\n * (`GET /category-trees`).\n *\n * Returns `CategoryNode[]` (the generated `CategoryTree`), not `Category[]`.\n * The two differ: `Category` carries `parentId` and no `subcategories`,\n * `CategoryTree` the reverse, and this endpoint answers with the latter.\n * Measured against a live tenant on 2026-08-04 — every node had\n * `subcategories` or nothing, none had `parentId`.\n *\n * **Children arrive inline in `subcategories`.** Do not reach for\n * {@link subcategories} to drill down: that method reads category-to-category\n * *assignments* (`/categories/{id}/assignments`, filtered to\n * `ref.type === \"CATEGORY\"`), which is a different feature — on the tenant this\n * was measured on, that filter answered empty for every category while the\n * `\"PRODUCT\"` filter behind {@link productsIn} worked fine.\n * {@link childCategories} hits `/categories/{id}/subcategories` and answers\n * **404** for a tree root. One call gives you the whole hierarchy.\n */\n async tree(auth: AuthContext = ANON): Promise<CategoryNode[]> {\n return this.ctx.http.request<CategoryNode[]>({\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/category-trees`,\n auth,\n });\n }\n\n /**\n * Rebuild a category tree from its root (`POST /category-trees/{rootCategoryId}/rebuild`).\n * Admin write — defaults to the service token. Returns the rebuilt tree.\n */\n async rebuildTree(rootCategoryId: string, auth: AuthContext = SERVICE): Promise<CategoryNode> {\n return this.ctx.http.request<CategoryNode>({\n method: \"POST\",\n path: `/category/${this.ctx.tenant}/category-trees/${encodeURIComponent(rootCategoryId)}/rebuild`,\n auth,\n });\n }\n\n /**\n * Direct child categories of a category (for hierarchy drill-down). Mirrors\n * {@link productsIn}: reads the category's **assignments** and keeps the\n * `CATEGORY` references, resolving them to full categories. Returns an empty\n * array when the category has no child categories.\n */\n async subcategories(\n categoryId: string,\n params: { pageNumber?: number; pageSize?: number } = {},\n auth: AuthContext = ANON,\n ): Promise<Category[]> {\n const pageNumber = params.pageNumber ?? 1;\n const pageSize = params.pageSize ?? 50;\n const assignments = await this.ctx.http.request<Array<{ ref?: { id?: string; type?: string } }>>({\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments`,\n query: { pageNumber, pageSize },\n auth,\n });\n const categoryIds = assignments\n .map((a) => (a.ref?.type?.toUpperCase() === \"CATEGORY\" ? a.ref.id : undefined))\n .filter((id): id is string => Boolean(id));\n if (categoryIds.length === 0) return [];\n return this.searchByIds(categoryIds, {}, auth);\n }\n\n /**\n * One page of products in a category. The category service exposes products\n * as **assignments** (`/categories/{id}/assignments`) — references, not full\n * products — so this fetches a page of assignments, keeps the `PRODUCT`\n * references, and resolves them to full products via `/products/search`.\n * `hasNextPage` reflects the assignments page (the source of truth for\n * pagination).\n *\n * No `totalCount` opt-in here, deliberately. `X-Total-Count` on the\n * assignments request would count **assignments** — including the `CATEGORY`\n * references filtered out below — not the products this returns. A number\n * that is wrong in the way that is hardest to notice. Same reason\n * `segments.listMyProducts` stays on the guess.\n */\n async productsIn(\n categoryId: string,\n params: { pageNumber?: number; pageSize?: number } = {},\n auth: AuthContext = ANON,\n ): Promise<PaginatedItems<Product>> {\n const pageNumber = params.pageNumber ?? 1;\n const pageSize = params.pageSize ?? 50;\n const assignments = await this.ctx.http.request<Array<{ ref?: { id?: string; type?: string } }>>({\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments`,\n query: { pageNumber, pageSize },\n auth,\n });\n const hasNextPage = assignments.length === pageSize;\n const productIds = assignments\n .map((a) => (a.ref?.type?.toUpperCase() === \"PRODUCT\" ? a.ref.id : undefined))\n .filter((id): id is string => Boolean(id));\n if (productIds.length === 0) {\n return { items: [], pageNumber, pageSize, hasNextPage };\n }\n const items = await this.ctx.http.request<Product[]>({\n method: \"POST\",\n path: `/product/${this.ctx.tenant}/products/search`,\n query: { pageSize: productIds.length },\n auth,\n body: { q: `id:(${productIds.join(\",\")})` },\n idempotent: true, // pure read over POST — safe to replay on 5xx/429\n });\n return { items, pageNumber, pageSize, hasNextPage };\n }\n\n /**\n * Bulk fetch by id. POSTs `/categories/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<Category[]> {\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<Category[]>({\n method: \"POST\",\n path: `/category/${this.ctx.tenant}/categories/search`,\n query: { pageSize: chunk.length },\n auth,\n body: { q: `id:(${chunk.join(\",\")})` },\n }),\n ),\n );\n return pages.flat();\n }\n\n /** Lists a category's ancestor categories (breadcrumb-up). Default auth: anonymous. */\n async parents(categoryId: string, auth: AuthContext = ANON): Promise<Category[]> {\n return this.ctx.http.request<Category[]>({\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/parents`,\n auth,\n });\n }\n\n /**\n * Lists a category's direct child categories via the dedicated\n * `…/subcategories` endpoint. (The older `subcategories()` reads `/assignments`\n * and is kept for backward compatibility.) Default auth: anonymous.\n */\n async childCategories(categoryId: string, auth: AuthContext = ANON): Promise<Category[]> {\n return this.ctx.http.request<Category[]>({\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/subcategories`,\n auth,\n });\n }\n\n /** Retrieves one category tree by its root category id. Default auth: anonymous. */\n async getTree(categoryId: string, auth: AuthContext = ANON): Promise<CategoryNode> {\n return this.ctx.http.request<CategoryNode>({\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/category-trees/${encodeURIComponent(categoryId)}`,\n auth,\n });\n }\n\n // --- Admin write CRUD. Default auth: service. ---\n\n /**\n * Creates a category (`POST /categories`). Default auth: service.\n * `options.publish` sets the `publish` query flag (needs the\n * `category.category_publish` scope).\n */\n async create(\n input: CategoryCreateInput,\n options: CategoryWriteOptions = {},\n auth: AuthContext = SERVICE,\n ): Promise<CategoryCreated> {\n return this.ctx.http.request<CategoryCreated>({\n method: \"POST\",\n path: `/category/${this.ctx.tenant}/categories`,\n ...(options.publish === undefined ? {} : { query: { publish: String(options.publish) } }),\n ...(options.contentLanguage === undefined\n ? {}\n : { headers: { \"Content-Language\": options.contentLanguage } }),\n body: input,\n auth,\n });\n }\n\n /**\n * Full-replaces a category (`PUT /categories/{categoryId}`). This is an\n * upsert: with a caller-supplied id it may create (201, returns the id) or\n * update an existing one (204, returns nothing). Default auth: service.\n */\n async update(\n categoryId: string,\n input: CategoryUpdateInput,\n options: CategoryWriteOptions = {},\n auth: AuthContext = SERVICE,\n ): Promise<CategoryCreated | void> {\n return this.ctx.http.request<CategoryCreated | void>({\n method: \"PUT\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}`,\n ...(options.publish === undefined ? {} : { query: { publish: String(options.publish) } }),\n ...(options.contentLanguage === undefined\n ? {}\n : { headers: { \"Content-Language\": options.contentLanguage } }),\n body: input,\n auth,\n });\n }\n\n /**\n * Partially updates a category (`PATCH /categories/{categoryId}`). Default\n * auth: service. `options.publish` sets the `publish` query flag.\n */\n async patch(\n categoryId: string,\n input: CategoryPatchInput,\n options: CategoryWriteOptions = {},\n auth: AuthContext = SERVICE,\n ): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"PATCH\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}`,\n ...(options.publish === undefined ? {} : { query: { publish: String(options.publish) } }),\n ...(options.contentLanguage === undefined\n ? {}\n : { headers: { \"Content-Language\": options.contentLanguage } }),\n body: input,\n auth,\n });\n }\n\n /** Deletes a category (`DELETE /categories/{categoryId}`). Default auth: service. */\n async delete(categoryId: string, auth: AuthContext = SERVICE): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}`,\n auth,\n });\n }\n\n /**\n * Searches categories via `POST /categories/search`. Same query capability\n * as {@link search} (`compoundLogicalQuery: false` — Category rejects `or()`\n * filters); the POST body avoids URL-length limits for large `q` filters.\n * `params.showRoots` / `params.showUnpublished` are POST-only flags. Default\n * auth: anonymous.\n */\n async searchByQuery(\n query: QueryFor<\"CATEGORY\">,\n params: { pageNumber?: number; pageSize?: number; sort?: string; showRoots?: boolean; showUnpublished?: boolean; totalCount?: boolean } = {},\n auth: AuthContext = ANON,\n ): Promise<PaginatedItems<Category>> {\n const q = resolveQuery(query, { compoundLogicalQuery: false });\n const pageNumber = params.pageNumber ?? 1;\n const pageSize = params.pageSize ?? 50;\n return requestPage<Category>(\n this.ctx.http,\n {\n method: \"POST\",\n path: `/category/${this.ctx.tenant}/categories/search`,\n query: {\n pageNumber,\n pageSize,\n ...(params.sort === undefined ? {} : { sort: params.sort }),\n ...(params.showRoots === undefined ? {} : { showRoots: String(params.showRoots) }),\n ...(params.showUnpublished === undefined ? {} : { showUnpublished: String(params.showUnpublished) }),\n },\n body: { q },\n idempotent: true, // pure read over POST — safe to replay on 5xx/429\n auth,\n },\n {\n pageNumber,\n pageSize,\n ...(params.totalCount === undefined ? {} : { totalCount: params.totalCount }),\n },\n );\n }\n\n /**\n * Searches category trees via `POST /category-trees/search` — returns the\n * trees that include at least one of the given `categoryIds`. Default auth:\n * anonymous.\n */\n async searchTrees(\n input: CategoryTreeSearchInput,\n options: { showUnpublished?: boolean } = {},\n auth: AuthContext = ANON,\n ): Promise<CategoryNode[]> {\n return this.ctx.http.request<CategoryNode[]>({\n method: \"POST\",\n path: `/category/${this.ctx.tenant}/category-trees/search`,\n ...(options.showUnpublished === undefined ? {} : { query: { showUnpublished: String(options.showUnpublished) } }),\n body: input,\n idempotent: true, // pure read over POST — safe to replay on 5xx/429\n auth,\n });\n }\n\n /**\n * Category ↔ resource assignments. Writes default to service auth. The\n * assignment `ref.type` is `'PRODUCT'` (per the API); category hierarchy is\n * managed via `parentId` on the category, not via assignments.\n */\n readonly assignments = {\n /** One page of a category's assignments. Default auth: anonymous. */\n list: async (\n categoryId: string,\n params: { pageNumber?: number; pageSize?: number; sort?: string; expandSupercategoriesIds?: boolean; showUnpublished?: boolean } = {},\n auth: AuthContext = ANON,\n ): Promise<CategoryAssignment[]> =>\n this.ctx.http.request<CategoryAssignment[]>({\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments`,\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.expandSupercategoriesIds === undefined ? {} : { expandSupercategoriesIds: String(params.expandSupercategoriesIds) }),\n ...(params.showUnpublished === undefined ? {} : { showUnpublished: String(params.showUnpublished) }),\n },\n auth,\n }),\n\n /** Assigns a single resource to a category (`POST …/assignments`). Default auth: service. */\n create: async (categoryId: string, input: CategoryAssignmentInput, auth: AuthContext = SERVICE): Promise<CategoryAssignmentCreated> =>\n this.ctx.http.request<CategoryAssignmentCreated>({\n method: \"POST\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments`,\n body: input,\n auth,\n }),\n\n /** Bulk-assigns resources to a category (`POST …/assignments/bulk`). Default auth: service. */\n bulkCreate: async (categoryId: string, input: CategoryAssignmentBulkInput, auth: AuthContext = SERVICE): Promise<CategoryAssignmentBulkResult> =>\n this.ctx.http.request<CategoryAssignmentBulkResult>({\n method: \"POST\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments/bulk`,\n body: input,\n auth,\n }),\n\n /** Removes one assignment by id (`DELETE …/assignments/{assignmentId}`). Default auth: service. */\n remove: async (categoryId: string, assignmentId: string, auth: AuthContext = SERVICE): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments/${assignmentId}`,\n auth,\n });\n },\n\n /** Removes all of a category's assignments (`DELETE …/assignments`). Default auth: service. */\n removeAll: async (categoryId: string, options: { assignmentType?: \"PRODUCT\" } = {}, auth: AuthContext = SERVICE): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments`,\n ...(options.assignmentType === undefined ? {} : { query: { assignmentType: options.assignmentType } }),\n auth,\n });\n },\n\n /** Upserts an assignment by reference id — no body (`PUT …/assignments/references/{referenceId}`). Default auth: service. */\n upsertByReference: async (categoryId: string, referenceId: string, auth: AuthContext = SERVICE): Promise<CategoryAssignmentCreated> =>\n this.ctx.http.request<CategoryAssignmentCreated>({\n method: \"PUT\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments/references/${referenceId}`,\n auth,\n }),\n\n /** Removes an assignment by reference id (`DELETE …/assignments/references/{referenceId}`). Default auth: service. */\n removeByReference: async (categoryId: string, referenceId: string, auth: AuthContext = SERVICE): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments/references/${referenceId}`,\n auth,\n });\n },\n\n /** Bulk-upserts assignment references (`PUT …/assignments/references/bulk`). Default auth: service. */\n bulkUpsertByReference: async (categoryId: string, input: CategoryAssignmentRefBulkInput, auth: AuthContext = SERVICE): Promise<CategoryAssignmentBulkResult> =>\n this.ctx.http.request<CategoryAssignmentBulkResult>({\n method: \"PUT\",\n path: `/category/${this.ctx.tenant}/categories/${categoryId}/assignments/references/bulk`,\n body: input,\n auth,\n }),\n\n /**\n * Lists every category assigned to the given reference id — tenant-wide\n * (`GET /assignments/references/{referenceId}`). Default auth: anonymous.\n */\n listCategoriesByReference: async (\n referenceId: string,\n params: { pageNumber?: number; pageSize?: number; sort?: string; showUnpublished?: boolean; expandSupercategoriesIds?: boolean } = {},\n auth: AuthContext = ANON,\n ): Promise<Category[]> =>\n this.ctx.http.request<Category[]>({\n method: \"GET\",\n path: `/category/${this.ctx.tenant}/assignments/references/${referenceId}`,\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.showUnpublished === undefined ? {} : { showUnpublished: String(params.showUnpublished) }),\n ...(params.expandSupercategoriesIds === undefined ? {} : { expandSupercategoriesIds: String(params.expandSupercategoriesIds) }),\n },\n auth,\n }),\n\n /** Removes all assignments to a given reference id — tenant-wide (`DELETE /assignments/references/{referenceId}`). Default auth: service. */\n removeAllByReference: async (referenceId: string, auth: AuthContext = SERVICE): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/category/${this.ctx.tenant}/assignments/references/${referenceId}`,\n auth,\n });\n },\n };\n}\n"]}
|
package/dist/category.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-
|
|
1
|
+
import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-C-A10NL3.cjs';
|
|
2
2
|
import { a as QueryFor } from './query-mLQs2WFr.cjs';
|
|
3
3
|
import { Product } from './product.cjs';
|
|
4
4
|
|
|
@@ -593,6 +593,18 @@ type CategoryAssignmentRefBulkInput = BulkAssignmentUpsertRequest;
|
|
|
593
593
|
type CategoryAssignmentBulkResult = BulkAssignmentResponse;
|
|
594
594
|
/** Id envelope returned when an assignment is created. */
|
|
595
595
|
type CategoryAssignmentCreated = AssignmentIdResponse;
|
|
596
|
+
/** Options shared by the category write endpoints (create, update, patch). */
|
|
597
|
+
interface CategoryWriteOptions {
|
|
598
|
+
/** Sets the `publish` query flag (needs the `category.category_publish` scope). */
|
|
599
|
+
publish?: boolean;
|
|
600
|
+
/**
|
|
601
|
+
* `Content-Language` for this call, overriding `EmporixConfig.contentLanguage`.
|
|
602
|
+
* Category localized fields are maps whatever it says; the header limits the
|
|
603
|
+
* languages they may contain (`"de"`, `"en,de"`), and without one the
|
|
604
|
+
* service allows every tenant language.
|
|
605
|
+
*/
|
|
606
|
+
contentLanguage?: string;
|
|
607
|
+
}
|
|
596
608
|
/** Category reads. Default auth: anonymous. */
|
|
597
609
|
declare class CategoryService {
|
|
598
610
|
private readonly ctx;
|
|
@@ -697,24 +709,18 @@ declare class CategoryService {
|
|
|
697
709
|
* `options.publish` sets the `publish` query flag (needs the
|
|
698
710
|
* `category.category_publish` scope).
|
|
699
711
|
*/
|
|
700
|
-
create(input: CategoryCreateInput, options?:
|
|
701
|
-
publish?: boolean;
|
|
702
|
-
}, auth?: AuthContext): Promise<CategoryCreated>;
|
|
712
|
+
create(input: CategoryCreateInput, options?: CategoryWriteOptions, auth?: AuthContext): Promise<CategoryCreated>;
|
|
703
713
|
/**
|
|
704
714
|
* Full-replaces a category (`PUT /categories/{categoryId}`). This is an
|
|
705
715
|
* upsert: with a caller-supplied id it may create (201, returns the id) or
|
|
706
716
|
* update an existing one (204, returns nothing). Default auth: service.
|
|
707
717
|
*/
|
|
708
|
-
update(categoryId: string, input: CategoryUpdateInput, options?:
|
|
709
|
-
publish?: boolean;
|
|
710
|
-
}, auth?: AuthContext): Promise<CategoryCreated | void>;
|
|
718
|
+
update(categoryId: string, input: CategoryUpdateInput, options?: CategoryWriteOptions, auth?: AuthContext): Promise<CategoryCreated | void>;
|
|
711
719
|
/**
|
|
712
720
|
* Partially updates a category (`PATCH /categories/{categoryId}`). Default
|
|
713
721
|
* auth: service. `options.publish` sets the `publish` query flag.
|
|
714
722
|
*/
|
|
715
|
-
patch(categoryId: string, input: CategoryPatchInput, options?:
|
|
716
|
-
publish?: boolean;
|
|
717
|
-
}, auth?: AuthContext): Promise<void>;
|
|
723
|
+
patch(categoryId: string, input: CategoryPatchInput, options?: CategoryWriteOptions, auth?: AuthContext): Promise<void>;
|
|
718
724
|
/** Deletes a category (`DELETE /categories/{categoryId}`). Default auth: service. */
|
|
719
725
|
delete(categoryId: string, auth?: AuthContext): Promise<void>;
|
|
720
726
|
/**
|
|
@@ -786,4 +792,4 @@ declare class CategoryService {
|
|
|
786
792
|
};
|
|
787
793
|
}
|
|
788
794
|
|
|
789
|
-
export { type Category, type CategoryAssignment, type CategoryAssignmentBulkInput, type CategoryAssignmentBulkResult, type CategoryAssignmentCreated, type CategoryAssignmentInput, type CategoryAssignmentRefBulkInput, type CategoryCreateInput, type CategoryCreated, type CategoryNode, type CategoryPatchInput, CategoryService, type CategoryTreeSearchInput, type CategoryUpdateInput };
|
|
795
|
+
export { type Category, type CategoryAssignment, type CategoryAssignmentBulkInput, type CategoryAssignmentBulkResult, type CategoryAssignmentCreated, type CategoryAssignmentInput, type CategoryAssignmentRefBulkInput, type CategoryCreateInput, type CategoryCreated, type CategoryNode, type CategoryPatchInput, CategoryService, type CategoryTreeSearchInput, type CategoryUpdateInput, type CategoryWriteOptions };
|
package/dist/category.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-
|
|
1
|
+
import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-C-A10NL3.js';
|
|
2
2
|
import { a as QueryFor } from './query-mLQs2WFr.js';
|
|
3
3
|
import { Product } from './product.js';
|
|
4
4
|
|
|
@@ -593,6 +593,18 @@ type CategoryAssignmentRefBulkInput = BulkAssignmentUpsertRequest;
|
|
|
593
593
|
type CategoryAssignmentBulkResult = BulkAssignmentResponse;
|
|
594
594
|
/** Id envelope returned when an assignment is created. */
|
|
595
595
|
type CategoryAssignmentCreated = AssignmentIdResponse;
|
|
596
|
+
/** Options shared by the category write endpoints (create, update, patch). */
|
|
597
|
+
interface CategoryWriteOptions {
|
|
598
|
+
/** Sets the `publish` query flag (needs the `category.category_publish` scope). */
|
|
599
|
+
publish?: boolean;
|
|
600
|
+
/**
|
|
601
|
+
* `Content-Language` for this call, overriding `EmporixConfig.contentLanguage`.
|
|
602
|
+
* Category localized fields are maps whatever it says; the header limits the
|
|
603
|
+
* languages they may contain (`"de"`, `"en,de"`), and without one the
|
|
604
|
+
* service allows every tenant language.
|
|
605
|
+
*/
|
|
606
|
+
contentLanguage?: string;
|
|
607
|
+
}
|
|
596
608
|
/** Category reads. Default auth: anonymous. */
|
|
597
609
|
declare class CategoryService {
|
|
598
610
|
private readonly ctx;
|
|
@@ -697,24 +709,18 @@ declare class CategoryService {
|
|
|
697
709
|
* `options.publish` sets the `publish` query flag (needs the
|
|
698
710
|
* `category.category_publish` scope).
|
|
699
711
|
*/
|
|
700
|
-
create(input: CategoryCreateInput, options?:
|
|
701
|
-
publish?: boolean;
|
|
702
|
-
}, auth?: AuthContext): Promise<CategoryCreated>;
|
|
712
|
+
create(input: CategoryCreateInput, options?: CategoryWriteOptions, auth?: AuthContext): Promise<CategoryCreated>;
|
|
703
713
|
/**
|
|
704
714
|
* Full-replaces a category (`PUT /categories/{categoryId}`). This is an
|
|
705
715
|
* upsert: with a caller-supplied id it may create (201, returns the id) or
|
|
706
716
|
* update an existing one (204, returns nothing). Default auth: service.
|
|
707
717
|
*/
|
|
708
|
-
update(categoryId: string, input: CategoryUpdateInput, options?:
|
|
709
|
-
publish?: boolean;
|
|
710
|
-
}, auth?: AuthContext): Promise<CategoryCreated | void>;
|
|
718
|
+
update(categoryId: string, input: CategoryUpdateInput, options?: CategoryWriteOptions, auth?: AuthContext): Promise<CategoryCreated | void>;
|
|
711
719
|
/**
|
|
712
720
|
* Partially updates a category (`PATCH /categories/{categoryId}`). Default
|
|
713
721
|
* auth: service. `options.publish` sets the `publish` query flag.
|
|
714
722
|
*/
|
|
715
|
-
patch(categoryId: string, input: CategoryPatchInput, options?:
|
|
716
|
-
publish?: boolean;
|
|
717
|
-
}, auth?: AuthContext): Promise<void>;
|
|
723
|
+
patch(categoryId: string, input: CategoryPatchInput, options?: CategoryWriteOptions, auth?: AuthContext): Promise<void>;
|
|
718
724
|
/** Deletes a category (`DELETE /categories/{categoryId}`). Default auth: service. */
|
|
719
725
|
delete(categoryId: string, auth?: AuthContext): Promise<void>;
|
|
720
726
|
/**
|
|
@@ -786,4 +792,4 @@ declare class CategoryService {
|
|
|
786
792
|
};
|
|
787
793
|
}
|
|
788
794
|
|
|
789
|
-
export { type Category, type CategoryAssignment, type CategoryAssignmentBulkInput, type CategoryAssignmentBulkResult, type CategoryAssignmentCreated, type CategoryAssignmentInput, type CategoryAssignmentRefBulkInput, type CategoryCreateInput, type CategoryCreated, type CategoryNode, type CategoryPatchInput, CategoryService, type CategoryTreeSearchInput, type CategoryUpdateInput };
|
|
795
|
+
export { type Category, type CategoryAssignment, type CategoryAssignmentBulkInput, type CategoryAssignmentBulkResult, type CategoryAssignmentCreated, type CategoryAssignmentInput, type CategoryAssignmentRefBulkInput, type CategoryCreateInput, type CategoryCreated, type CategoryNode, type CategoryPatchInput, CategoryService, type CategoryTreeSearchInput, type CategoryUpdateInput, type CategoryWriteOptions };
|
package/dist/category.js
CHANGED
package/dist/checkout.d.cts
CHANGED
package/dist/checkout.d.ts
CHANGED
|
@@ -217,6 +217,7 @@ var ProductService = class {
|
|
|
217
217
|
method: "POST",
|
|
218
218
|
path: `/product/${this.ctx.tenant}/products`,
|
|
219
219
|
...Object.keys(query).length > 0 ? { query } : {},
|
|
220
|
+
...options.contentLanguage === void 0 ? {} : { headers: { "Content-Language": options.contentLanguage } },
|
|
220
221
|
body: input,
|
|
221
222
|
auth
|
|
222
223
|
});
|
|
@@ -249,6 +250,7 @@ var ProductService = class {
|
|
|
249
250
|
method: "PATCH",
|
|
250
251
|
path: `/product/${this.ctx.tenant}/products/${productId}`,
|
|
251
252
|
...Object.keys(query).length > 0 ? { query } : {},
|
|
253
|
+
...options.contentLanguage === void 0 ? {} : { headers: { "Content-Language": options.contentLanguage } },
|
|
252
254
|
body: input,
|
|
253
255
|
auth
|
|
254
256
|
});
|
|
@@ -275,6 +277,7 @@ var ProductService = class {
|
|
|
275
277
|
method: "PUT",
|
|
276
278
|
path: `/product/${this.ctx.tenant}/products/${productId}`,
|
|
277
279
|
...Object.keys(query).length > 0 ? { query } : {},
|
|
280
|
+
...options.contentLanguage === void 0 ? {} : { headers: { "Content-Language": options.contentLanguage } },
|
|
278
281
|
body: input,
|
|
279
282
|
auth
|
|
280
283
|
});
|
|
@@ -309,6 +312,7 @@ var ProductService = class {
|
|
|
309
312
|
method: "POST",
|
|
310
313
|
path: `/product/${this.ctx.tenant}/products/bulk`,
|
|
311
314
|
...Object.keys(query).length > 0 ? { query } : {},
|
|
315
|
+
...options.contentLanguage === void 0 ? {} : { headers: { "Content-Language": options.contentLanguage } },
|
|
312
316
|
body: input,
|
|
313
317
|
auth
|
|
314
318
|
});
|
|
@@ -327,6 +331,7 @@ var ProductService = class {
|
|
|
327
331
|
method: "PUT",
|
|
328
332
|
path: `/product/${this.ctx.tenant}/products/bulk`,
|
|
329
333
|
...Object.keys(query).length > 0 ? { query } : {},
|
|
334
|
+
...options.contentLanguage === void 0 ? {} : { headers: { "Content-Language": options.contentLanguage } },
|
|
330
335
|
body: input,
|
|
331
336
|
auth
|
|
332
337
|
});
|
|
@@ -413,5 +418,5 @@ var ProductService = class {
|
|
|
413
418
|
};
|
|
414
419
|
|
|
415
420
|
export { ProductService };
|
|
416
|
-
//# sourceMappingURL=chunk-
|
|
417
|
-
//# sourceMappingURL=chunk-
|
|
421
|
+
//# sourceMappingURL=chunk-J2AN2FMK.js.map
|
|
422
|
+
//# sourceMappingURL=chunk-J2AN2FMK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/product.ts"],"names":[],"mappings":";;;;;AA0BA,IAAM,IAAA,GAAoB,EAAE,IAAA,EAAM,WAAA,EAAY;AAC9C,IAAM,OAAA,GAAuB,EAAE,IAAA,EAAM,SAAA,EAAU;AAmExC,IAAM,iBAAN,MAAqB;AAAA,EAE1B,YAA6B,GAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAAA,EAAqB;AAAA,EAArB,GAAA;AAAA,EAD7B,OAAgB,OAAA,GAAU,SAAA;AAAA;AAAA,EAI1B,MAAM,GAAA,CACJ,SAAA,EACA,KAAA,EACA,OAAoB,IAAA,EACF;AAClB,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAiB;AAAA,MACpC,MAAA,EAAQ,KAAA;AAAA,MACR,MAAM,CAAA,SAAA,EAAY,IAAA,CAAK,GAAA,CAAI,MAAM,aAAa,SAAS,CAAA,CAAA;AAAA,MACvD;AAAA,KACD,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,SAAA,CAAU,IAAA,EAAc,IAAA,GAAoB,IAA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,CAAK,GAAA,CAAI,MAAM,CAAA,kBAAA,CAAA;AAAA,MACjC,IAAA,EAAM,KAAA;AAAA,MACN;AAAA,KACD,CAAA;AAAA;AAAA,IAGH,MAAA,EAAQ,OACN,UAAA,EACA,KAAA,EACA,OAAoB,OAAA,KACF;AAClB,MAAA,MAAM,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAc;AAAA,QAChC,MAAA,EAAQ,KAAA;AAAA,QACR,MAAM,CAAA,SAAA,EAAY,IAAA,CAAK,GAAA,CAAI,MAAM,sBAAsB,UAAU,CAAA,CAAA;AAAA,QACjE,IAAA,EAAM,KAAA;AAAA,QACN;AAAA,OACD,CAAA;AAAA,IACH,CAAA;AAAA;AAAA,IAGA,MAAA,EAAQ,OAAO,UAAA,EAAoB,IAAA,GAAoB,OAAA,KAA2B;AAChF,MAAA,MAAM,IAAA,CAAK,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-J2AN2FMK.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 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 = BasicProductWithId | BundleProductWithId | ParentVariantProductWithId;\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(\n productId: string,\n _opts?: Record<string, never>,\n auth: AuthContext = ANON,\n ): Promise<Product> {\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 VARIANT children of a PARENT_VARIANT product, page by page,\n * via the search query `productType:VARIANT parentVariantId:<id>`. Default\n * pageSize 200. The query syntax (space-separated fields = implicit AND) is\n * encapsulated here so consumers don't build it themselves.\n */\n listVariantChildrenAll(\n parentVariantId: string,\n params: { pageSize?: number } = {},\n auth: AuthContext = ANON,\n ): AsyncIterable<Product> {\n const pageSize = params.pageSize ?? 200;\n const q = `productType:VARIANT parentVariantId:${parentVariantId}`;\n return iterateAll<Product>((pageNumber) => this.search(q, { pageNumber, pageSize }, auth));\n }\n\n /**\n * Resolves ALL VARIANT children of a PARENT_VARIANT product into a flat\n * array (loads every page). Default pageSize 200. Returns `[]` when there are\n * no children — never throws.\n */\n async listVariantChildren(\n parentVariantId: string,\n params: { pageSize?: number } = {},\n auth: AuthContext = ANON,\n ): Promise<Product[]> {\n const out: Product[] = [];\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"]}
|