@viu/emporix-sdk 4.6.7 → 4.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/availability.cjs.map +1 -1
- package/dist/availability.js +2 -2
- package/dist/cart.cjs +3 -0
- package/dist/cart.cjs.map +1 -1
- package/dist/cart.js +2 -2
- package/dist/checkout.cjs.map +1 -1
- package/dist/checkout.js +2 -2
- package/dist/{chunk-J2AN2FMK.js → chunk-3JO2O4BY.js} +25 -14
- package/dist/chunk-3JO2O4BY.js.map +1 -0
- package/dist/{chunk-UWGGF4MC.js → chunk-4Q76UV4J.js} +6 -3
- package/dist/chunk-4Q76UV4J.js.map +1 -0
- package/dist/{chunk-RYQVMR26.js → chunk-BHNYGUSD.js} +3 -3
- package/dist/{chunk-RYQVMR26.js.map → chunk-BHNYGUSD.js.map} +1 -1
- package/dist/{chunk-IYNT5BQW.js → chunk-CXTVY4SI.js} +8 -4
- package/dist/chunk-CXTVY4SI.js.map +1 -0
- package/dist/{chunk-K4KXT6NX.js → chunk-ENMMDGUB.js} +3 -3
- package/dist/{chunk-K4KXT6NX.js.map → chunk-ENMMDGUB.js.map} +1 -1
- package/dist/{chunk-UA4BM6OP.js → chunk-EQE5WGME.js} +4 -4
- package/dist/{chunk-UA4BM6OP.js.map → chunk-EQE5WGME.js.map} +1 -1
- package/dist/{chunk-4VRUMCS2.js → chunk-PK4DQHJO.js} +4 -4
- package/dist/{chunk-4VRUMCS2.js.map → chunk-PK4DQHJO.js.map} +1 -1
- package/dist/{chunk-NFSO7WUA.js → chunk-SIGXBN4F.js} +3 -3
- package/dist/{chunk-NFSO7WUA.js.map → chunk-SIGXBN4F.js.map} +1 -1
- package/dist/{chunk-N2CE3J4M.js → chunk-U3ZIJZYH.js} +3 -3
- package/dist/{chunk-N2CE3J4M.js.map → chunk-U3ZIJZYH.js.map} +1 -1
- package/dist/{chunk-S2ERKGYL.js → chunk-ZLGLI4KC.js} +3 -3
- package/dist/{chunk-S2ERKGYL.js.map → chunk-ZLGLI4KC.js.map} +1 -1
- package/dist/{chunk-3BDDYX3V.js → chunk-ZVIEFW3X.js} +3 -3
- package/dist/{chunk-3BDDYX3V.js.map → chunk-ZVIEFW3X.js.map} +1 -1
- package/dist/{chunk-XQAOHHXL.js → chunk-ZZ3X3DDL.js} +3 -3
- package/dist/{chunk-XQAOHHXL.js.map → chunk-ZZ3X3DDL.js.map} +1 -1
- package/dist/customer.cjs.map +1 -1
- package/dist/customer.js +3 -3
- package/dist/index.cjs +62 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +137 -42
- package/dist/index.d.ts +137 -42
- package/dist/index.js +52 -38
- package/dist/index.js.map +1 -1
- package/dist/media.cjs +3 -0
- package/dist/media.cjs.map +1 -1
- package/dist/media.js +2 -2
- package/dist/orders.cjs +6 -2
- package/dist/orders.cjs.map +1 -1
- package/dist/orders.d.cts +6 -2
- package/dist/orders.d.ts +6 -2
- package/dist/orders.js +1 -1
- package/dist/payment.cjs.map +1 -1
- package/dist/payment.js +3 -3
- package/dist/price.cjs.map +1 -1
- package/dist/price.js +2 -2
- package/dist/product.cjs +23 -12
- package/dist/product.cjs.map +1 -1
- package/dist/product.d.cts +197 -14
- package/dist/product.d.ts +197 -14
- package/dist/product.js +1 -1
- package/dist/segment.cjs.map +1 -1
- package/dist/segment.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-IYNT5BQW.js.map +0 -1
- package/dist/chunk-J2AN2FMK.js.map +0 -1
- package/dist/chunk-UWGGF4MC.js.map +0 -1
package/dist/media.cjs
CHANGED
|
@@ -73,6 +73,8 @@ var EmporixNotFoundError = class extends EmporixError {
|
|
|
73
73
|
};
|
|
74
74
|
var EmporixValidationError = class extends EmporixError {
|
|
75
75
|
};
|
|
76
|
+
var EmporixConflictError = class extends EmporixError {
|
|
77
|
+
};
|
|
76
78
|
var EmporixServerError = class extends EmporixError {
|
|
77
79
|
};
|
|
78
80
|
var EmporixInsufficientScopeError = class extends EmporixForbiddenError {
|
|
@@ -106,6 +108,7 @@ function errorFromResponse(status, message, body) {
|
|
|
106
108
|
}
|
|
107
109
|
if (status === 404) return new EmporixNotFoundError(message, status, body);
|
|
108
110
|
if (status === 400 || status === 422) return new EmporixValidationError(message, status, body);
|
|
111
|
+
if (status === 409) return new EmporixConflictError(message, status, body);
|
|
109
112
|
if (status >= 500) return new EmporixServerError(message, status, body);
|
|
110
113
|
return new EmporixError(message, status, body);
|
|
111
114
|
}
|
package/dist/media.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/paged.ts","../src/core/errors.ts","../src/services/media.ts"],"names":["text"],"mappings":";;;AAyBA,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,GAAa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A,CAAK,EAAE,WAAA,EAAa,SAAA,IAAa,IAAI,CAAA;AAAA,EACnD;AACF;AAIO,IAAM,cAAA,GAAiB,EAAE,YAAA","file":"media.cjs","sourcesContent":["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","/** Keys whose values are stripped from any serialised error body. */\nconst REDACTED_BODY_KEYS = new Set([\n \"access_token\", \"refresh_token\", \"token\", \"customertoken\", \"saastoken\",\n \"secret\", \"client_secret\", \"authorization\", \"password\",\n]);\n\nfunction scrub(body: unknown): unknown {\n if (Array.isArray(body)) return body.map(scrub);\n if (body && typeof body === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(body as Record<string, unknown>)) {\n out[k] = REDACTED_BODY_KEYS.has(k.toLowerCase()) ? \"***redacted***\" : scrub(v);\n }\n return out;\n }\n return body;\n}\n\n/** Base class for every error thrown by the SDK. */\nexport class EmporixError extends Error {\n readonly status: number | undefined;\n readonly body: unknown;\n constructor(message: string, status?: number, body?: unknown) {\n super(message);\n this.name = new.target.name;\n this.status = status;\n this.body = body;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n /** Safe serialisation — token-like body fields are redacted. */\n toJSON(): Record<string, unknown> {\n return { name: this.name, message: this.message, status: this.status, body: scrub(this.body) };\n }\n}\n\n/** 401 — authentication failed or token expired. */\nexport class EmporixAuthError extends EmporixError {}\n/** 403 — authenticated but not permitted. */\nexport class EmporixForbiddenError extends EmporixError {}\n/** 404 — resource not found. */\nexport class EmporixNotFoundError extends EmporixError {}\n/** 400/422 — request validation failed. */\nexport class EmporixValidationError extends EmporixError {}\n/** 5xx — server-side failure. */\nexport class EmporixServerError extends EmporixError {}\n/** Request aborted by the configured connect/read timeout. No HTTP status. */\nexport class EmporixTimeoutError extends EmporixError {}\n/** DNS/TLS/connection-level failure before or during the exchange. No HTTP status. */\nexport class EmporixNetworkError extends EmporixError {}\n\n/**\n * 403 with a `missing scope: <name>` hint in the body's `details` array.\n * Subclasses {@link EmporixForbiddenError} so existing 403 catches still work.\n */\nexport class EmporixInsufficientScopeError extends EmporixForbiddenError {\n readonly requiredScope: string | undefined;\n constructor(message: string, status: number, body: unknown, requiredScope?: string) {\n super(message, status, body);\n this.requiredScope = requiredScope;\n }\n}\n\nconst SCOPE_HINT_RE = /missing scope[: ]+([a-z0-9._-]+)/i;\n\nfunction extractRequiredScope(body: unknown): string | undefined {\n if (body && typeof body === \"object\" && \"details\" in body) {\n const details = (body as { details?: unknown }).details;\n if (Array.isArray(details)) {\n for (const d of details) {\n if (typeof d === \"string\") {\n const m = d.match(SCOPE_HINT_RE);\n if (m) return m[1];\n }\n }\n }\n }\n return undefined;\n}\n\n/** Maps an HTTP status to the matching {@link EmporixError} subclass. */\nexport function errorFromResponse(status: number, message: string, body: unknown): EmporixError {\n if (status === 401) return new EmporixAuthError(message, status, body);\n if (status === 403) {\n const scope = extractRequiredScope(body);\n if (scope) return new EmporixInsufficientScopeError(message, status, body, scope);\n return new EmporixForbiddenError(message, status, body);\n }\n if (status === 404) return new EmporixNotFoundError(message, status, body);\n if (status === 400 || status === 422) return new EmporixValidationError(message, status, body);\n if (status >= 500) return new EmporixServerError(message, status, body);\n return new EmporixError(message, status, body);\n}\n","import type { ClientContext, PaginatedItems } from \"../core/context\";\nimport { requestPage } from \"../core/paged\";\nimport type { AuthContext } from \"../core/auth\";\nimport { EmporixError, errorFromResponse } from \"../core/errors\";\nimport type {\n AssetCreateBlob,\n AssetCreateLink,\n AssetUpdateBlob,\n AssetUpdateLink,\n DownloadUrl,\n GetAsset,\n GetMediaRetrieveDownloadUrlData,\n MetadataUpdate,\n PatchOperation,\n RefId,\n UploadSession,\n UploadSessionRequest,\n} from \"../generated/media\";\n\n/**\n * The spec marks `metadata` optional on both update bodies; the live API rejects\n * an update without it — «`metadata.version` is required for update» (measured\n * 2026-10-06 on BLOB and LINK assets). Required here, so leaving it out is a\n * compile error rather than a 400.\n */\ntype Versioned<T> = Omit<T, \"metadata\"> & { metadata: MetadataUpdate };\n\n/** Generated media types (caller sends the exact wire shape). */\nexport type AssetCreateBlobInput = AssetCreateBlob;\nexport type AssetCreateLinkInput = AssetCreateLink;\nexport type AssetUpdateBlobInput = Versioned<AssetUpdateBlob>;\nexport type AssetUpdateLinkInput = Versioned<AssetUpdateLink>;\n/**\n * @deprecated `update()` takes {@link AssetUpdateLinkInput} as its JSON body and\n * {@link AssetUpdateBlobInput} next to a file; a BLOB is never sent as JSON.\n */\nexport type AssetUpdateInput = AssetUpdateBlob | AssetUpdateLink;\nexport type Asset = GetAsset;\nexport type AssetRefId = RefId;\n/** Partial-update body (`PATCH /assets/{id}`) — an RFC-6902 JSON-Patch op-array. */\nexport type AssetPatch = PatchOperation[];\n/** Result of {@link MediaService.getDownloadUrl} — `{ provider, url, expiresAt? }`. */\nexport type AssetDownloadUrl = DownloadUrl;\n/** Query for {@link MediaService.getDownloadUrl} — `{ disposition? }`. */\nexport type AssetDownloadUrlQuery = NonNullable<GetMediaRetrieveDownloadUrlData[\"query\"]>;\n/** Body for {@link MediaService.startUploadSession}: a BLOB create payload plus `uploadType`. */\nexport type AssetUploadSessionInput = UploadSessionRequest;\n/** The storage instruction {@link MediaService.startUploadSession} returns. */\nexport type AssetUploadSession = UploadSession;\n\n/**\n * Filter / pagination options for {@link MediaService.list}. The explicit\n * fields are typed for autocomplete; the index signature stays open so\n * Emporix `q`-syntax filters like `\"refIds.id\"` can be passed verbatim.\n */\nexport interface ListAssetsQuery {\n pageNumber?: number;\n pageSize?: number;\n /** Emporix sort syntax, e.g. `\"name,metadata.createdAt:desc\"`. */\n sort?: string;\n /** Emporix `q`-syntax filter, e.g. `\"name:hero\"`. */\n q?: string;\n /**\n * Ask for `X-Total-Count`. An SDK-side flag, not an Emporix query parameter:\n * it becomes a request header.\n */\n totalCount?: boolean;\n [key: string]: string | number | boolean | undefined;\n}\n\n/**\n * Result of {@link MediaService.download}. The endpoint's behaviour depends\n * on the asset's `access`:\n * - `PUBLIC` assets respond with a 30x redirect whose `Location` header\n * carries the externally-cacheable storage URL — useful when the\n * storefront wants to send the user there directly.\n * - `PRIVATE` assets respond with the raw bytes (plus an `ETag` header\n * for caching). The file lives in Google Cloud Storage and is reachable\n * without the service token only through a signed URL from\n * {@link MediaService.getDownloadUrl}.\n */\nexport type DownloadResult =\n | { kind: \"redirect\"; url: string }\n | {\n kind: \"bytes\";\n data: ArrayBuffer;\n etag?: string;\n contentType?: string;\n };\n\nconst SERVICE: AuthContext = { kind: \"service\" };\n\nfunction isProductRef(r: AssetRefId, productId: string): boolean {\n return r.type === \"PRODUCT\" && r.id === productId;\n}\n\n/**\n * Media assets (BLOB/LINK). All endpoints require a backend-only scope\n * (`media.asset_manage` / `media.asset_read`) — default auth: service.\n */\nexport class MediaService {\n static readonly channel = \"media\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/media/${this.ctx.tenant}/assets`;\n }\n\n /**\n * Create an asset. BLOB uploads via multipart (max 30 MB); LINK via JSON.\n * {@link startUploadSession} sends the file straight to storage instead.\n */\n async create(\n input:\n | { kind: \"blob\"; file: Blob; body: AssetCreateBlobInput }\n | { kind: \"link\"; body: AssetCreateLinkInput },\n auth: AuthContext = SERVICE,\n ): Promise<{ id: string }> {\n if (input.kind === \"blob\") {\n const fd = new FormData();\n fd.set(\"file\", input.file);\n fd.set(\"body\", JSON.stringify(input.body));\n return this.ctx.http.request<{ id: string }>({\n method: \"POST\",\n path: this.base(),\n auth,\n body: fd,\n });\n }\n return this.ctx.http.request<{ id: string }>({\n method: \"POST\",\n path: this.base(),\n auth,\n body: input.body,\n });\n }\n\n /**\n * List assets, wrapped in the shared {@link PaginatedItems} envelope so\n * callers can iterate over pages consistently with the rest of the SDK.\n * `hasNextPage` is the standard SDK heuristic: `true` when the returned\n * page is full (`items.length === requested pageSize`). Pagination\n * defaults match Emporix's server defaults (`pageNumber: 1`,\n * `pageSize: 60`) so an empty `query` produces stable expectations.\n */\n async list(\n query: ListAssetsQuery = {},\n auth: AuthContext = SERVICE,\n ): Promise<PaginatedItems<Asset>> {\n const pageNumber = query.pageNumber ?? 1;\n const pageSize = query.pageSize ?? 60;\n // Destructured out because the rest of `query` is spread into the query\n // string: `totalCount` is an SDK-side flag that becomes a request header,\n // and would otherwise ride along as a stray `?totalCount=true`.\n const { totalCount, ...rest } = query;\n return requestPage<Asset>(\n this.ctx.http,\n {\n method: \"GET\",\n path: this.base(),\n auth,\n query: { ...rest, pageNumber, pageSize },\n },\n { pageNumber, pageSize, ...(totalCount === undefined ? {} : { totalCount }) },\n );\n }\n\n /** Fetch an asset by id. */\n async get(assetId: string, auth: AuthContext = SERVICE): Promise<Asset> {\n return this.ctx.http.request<Asset>({\n method: \"GET\",\n path: `${this.base()}/${assetId}`,\n auth,\n });\n }\n\n /**\n * Replace an asset (`PUT`, HTTP 204 — nothing is returned). The spec takes one\n * body per asset type, mirrored by the discriminated input:\n * - `{ kind: \"json\", body }` — a LINK asset, sent as `application/json`. The\n * body is the whole asset: `type: \"LINK\"`, `access` and `url` are required.\n * - `{ kind: \"blob\", file, body }` — a BLOB asset, sent as\n * `multipart/form-data`: the file (max 30 MB) and the asset body, both\n * required, so this always replaces the bytes.\n *\n * A BLOB's metadata alone — `refIds`, `details`, mixins — goes through\n * {@link patch}. Earlier versions also took a BLOB as the JSON body and\n * promised the updated asset in return; the spec allows neither.\n *\n * `type` and `access` are immutable. Optimistic locking is via\n * `body.metadata.version`; a stale one gets a 409.\n */\n async update(\n assetId: string,\n input:\n | { kind: \"json\"; body: AssetUpdateLinkInput }\n | { kind: \"blob\"; file: Blob; body: AssetUpdateBlobInput },\n auth: AuthContext = SERVICE,\n ): Promise<void> {\n const path = `${this.base()}/${encodeURIComponent(assetId)}`;\n if (input.kind === \"blob\") {\n const fd = new FormData();\n fd.set(\"file\", input.file);\n fd.set(\"body\", JSON.stringify(input.body));\n await this.ctx.http.request<void>({ method: \"PUT\", path, auth, body: fd });\n return;\n }\n await this.ctx.http.request<void>({ method: \"PUT\", path, auth, body: input.body });\n }\n\n /**\n * Partially update an asset with an RFC-6902 JSON-Patch op-array\n * (`PATCH /assets/{id}`, HTTP 204 — nothing is returned).\n *\n * This is the way to change one field without resending the whole asset, and\n * the only way to touch a `BLOB` asset's metadata **without re-uploading the\n * file** — {@link update} in `blob` mode always replaces the bytes.\n *\n * Append to an array with a path ending in `/-`, which preserves the existing\n * entries:\n *\n * ```ts\n * await client.media.patch(assetId, [\n * { op: \"add\", path: \"/refIds/-\", value: { id: \"product1\", type: \"PRODUCT\" } },\n * ]);\n * ```\n *\n * `type` and `access` are immutable here too, as with {@link update}. Only\n * `add`, `remove` and `replace` are accepted, and optimistic locking still\n * applies — a stale `metadata.version` gets a 409.\n */\n async patch(assetId: string, ops: AssetPatch, auth: AuthContext = SERVICE): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"PATCH\",\n path: `${this.base()}/${encodeURIComponent(assetId)}`,\n auth,\n body: ops,\n });\n }\n\n /** Remove an asset. */\n async remove(assetId: string, auth: AuthContext = SERVICE): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${assetId}`,\n auth,\n });\n }\n\n /**\n * Download an asset by id. Returns a discriminated union:\n * - `{ kind: \"redirect\", url }` for `PUBLIC` assets (server-side 30x with\n * the storage URL in `Location`).\n * - `{ kind: \"bytes\", data }` for `PRIVATE` assets (server-side 200 with\n * the asset bytes; `etag` + `contentType` headers are exposed for\n * caching). When the server reports `text/plain` Content-Type (the\n * OpenAPI-documented format), the SDK decodes the base64 stream into\n * an `ArrayBuffer` transparently; binary Content-Types are passed\n * through verbatim.\n *\n * Emporix recommends {@link getDownloadUrl} for every download: here the file\n * passes through the Media API. A `413` means the asset's known size exceeds\n * the streaming limit (30 MB by default) — only {@link getDownloadUrl} can\n * serve it. A `409` means the asset is still `PENDING` from a direct upload\n * whose file has not reached storage.\n *\n * Implementation note: uses `redirect: \"manual\"` so the redirect-location\n * is observable. In Node.js this works; in a browser the redirect Location\n * is intentionally hidden by fetch — there, `PUBLIC` downloads will\n * surface as an opaque-redirect and the SDK throws. Browser code should\n * use the asset's `url` field from `get()` for `LINK` assets, or the\n * direct storage URL for `PUBLIC` `BLOB` assets (typically delivered via\n * an `<img>` tag rather than `download()`).\n */\n async download(\n assetId: string,\n auth: AuthContext = SERVICE,\n ): Promise<DownloadResult> {\n const path = `${this.base()}/${assetId}/download`;\n const res = await this.ctx.http.requestRaw(\n { method: \"GET\", path, auth },\n { redirect: \"manual\" },\n );\n\n // PUBLIC: server-side redirect — capture Location.\n if (res.status >= 300 && res.status < 400) {\n const url = res.headers.get(\"location\");\n if (!url) {\n throw new EmporixError(\n `media.download: ${res.status} response without a Location header`,\n res.status,\n );\n }\n return { kind: \"redirect\", url };\n }\n\n // PRIVATE: bytes.\n if (res.ok) {\n const etag = res.headers.get(\"etag\") ?? undefined;\n const contentType = res.headers.get(\"content-type\") ?? undefined;\n let data: ArrayBuffer;\n if (contentType?.startsWith(\"text/plain\")) {\n // Per OpenAPI spec the server returns the byte stream as a\n // base64-encoded text/plain body. Decode once into raw bytes\n // so callers always see an ArrayBuffer.\n const text = await res.text();\n const bin = atob(text);\n const arr = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; i++) arr[i] = bin.charCodeAt(i);\n data = arr.buffer;\n } else {\n data = await res.arrayBuffer();\n }\n return {\n kind: \"bytes\",\n data,\n ...(etag !== undefined ? { etag } : {}),\n ...(contentType !== undefined ? { contentType } : {}),\n };\n }\n\n // Error: surface via the standard EmporixError hierarchy.\n const text = await res.text();\n let parsed: unknown = undefined;\n if (text) {\n try {\n parsed = JSON.parse(text);\n } catch {\n parsed = text;\n }\n }\n throw errorFromResponse(res.status, `GET ${path} → ${res.status}`, parsed);\n }\n\n /**\n * Get a URL that serves the stored file straight from storage\n * (`GET /assets/{assetId}/download-url`). Emporix recommends it for every\n * download: the file never passes through the Media API, there is no size\n * limit, and the URL can be handed to a browser as it is.\n *\n * - `PRIVATE` BLOB → `provider: \"GCS\"`, a signed Google Cloud Storage URL that\n * works without an Emporix token until `expiresAt` (15 minutes by default).\n * - `PUBLIC` BLOB → `provider: \"CLOUDINARY\"`, the permanent URL.\n * - `LINK` → `provider: \"LINK\"`, the stored URL.\n *\n * `disposition` (`attachment` by default, or `inline`) affects private URLs\n * only. Unlike {@link startUploadSession}, this works whether or not direct\n * upload is enabled for the tenant. A `409` means a direct upload is still\n * `PENDING` and its file has not reached storage; once it has, this call\n * completes the asset before answering.\n */\n async getDownloadUrl(\n assetId: string,\n query: AssetDownloadUrlQuery = {},\n auth: AuthContext = SERVICE,\n ): Promise<AssetDownloadUrl> {\n return this.ctx.http.request<AssetDownloadUrl>({\n method: \"GET\",\n path: `${this.base()}/${encodeURIComponent(assetId)}/download-url`,\n auth,\n query: { ...query },\n });\n }\n\n /**\n * Start a direct upload of a `BLOB` asset (`POST /assets/upload-session`,\n * `201`). Emporix creates the asset as `PENDING` — `id` is its id — and\n * returns where to send the file. **This method does not send it**:\n *\n * - `upload.method === \"PUT\"` (a `PRIVATE` asset, `uploadType: \"put\"` or\n * omitted): `PUT` the file to `upload.url` with every `upload.headers` entry.\n * - `upload.method === \"POST\"` (every `PUBLIC` asset, or `uploadType: \"form\"`):\n * a multipart `POST` to `upload.url` with every `upload.fields` entry\n * unchanged and the file part last.\n *\n * That request goes to Google Cloud Storage or Cloudinary, not to Emporix, so\n * it must not carry the Emporix token — which is also why a browser can make\n * it. The asset turns `READY` once storage confirms; until then, calls that\n * need the file answer `409`. The instruction is valid for 15 minutes (GCS) or\n * an hour (Cloudinary), and an unused session expires at `expiresAt`.\n *\n * Direct upload is enabled per tenant by Emporix Support. Without it the call\n * throws an `EmporixForbiddenError` whose `body.message` is `direct upload is\n * not enabled for this tenant`, and nothing is created — the same status as a\n * missing scope, so read the message.\n */\n async startUploadSession(\n input: AssetUploadSessionInput,\n auth: AuthContext = SERVICE,\n ): Promise<AssetUploadSession> {\n return this.ctx.http.request<AssetUploadSession>({\n method: \"POST\",\n path: `${this.base()}/upload-session`,\n auth,\n body: input,\n });\n }\n\n /** Multipart upload sugar: builds `AssetCreateBlob` from input. */\n async uploadFile(\n input: {\n file: Blob;\n productId?: string;\n filename?: string;\n mimeType?: string;\n access?: \"PUBLIC\" | \"PRIVATE\";\n },\n auth: AuthContext = SERVICE,\n ): Promise<{ id: string }> {\n const body: AssetCreateBlobInput = {\n type: \"BLOB\",\n access: input.access ?? \"PUBLIC\",\n ...(input.productId\n ? { refIds: [{ type: \"PRODUCT\", id: input.productId }] }\n : {}),\n ...(input.filename || input.mimeType\n ? {\n details: {\n ...(input.filename ? { filename: input.filename } : {}),\n ...(input.mimeType ? { mimeType: input.mimeType } : {}),\n },\n }\n : {}),\n };\n return this.create({ kind: \"blob\", file: input.file, body }, auth);\n }\n\n /**\n * Replace the file content of an existing BLOB asset. Sugar over\n * {@link update} with `kind: \"blob\"`, and like it resolves to nothing — the\n * PUT answers 204. `access` is required because the field is immutable and\n * the server validates that the body matches.\n *\n * Pass `version` from `asset.metadata.version` for optimistic locking\n * (recommended when concurrent writers are possible) — a stale one gets a 409.\n * Without it the current version is read first, because the live API rejects\n * an update that carries none; the write then wins over any in between.\n */\n async replaceFile(\n assetId: string,\n input: {\n file: Blob;\n access: \"PUBLIC\" | \"PRIVATE\";\n filename?: string;\n mimeType?: string;\n version?: number;\n },\n auth: AuthContext = SERVICE,\n ): Promise<void> {\n const version =\n input.version ?? (await this.get(assetId, auth)).metadata?.version ?? 1;\n const body: AssetUpdateBlobInput = {\n type: \"BLOB\",\n access: input.access,\n ...(input.filename || input.mimeType\n ? {\n details: {\n ...(input.filename ? { filename: input.filename } : {}),\n ...(input.mimeType ? { mimeType: input.mimeType } : {}),\n },\n }\n : {}),\n metadata: { version },\n };\n return this.update(assetId, { kind: \"blob\", file: input.file, body }, auth);\n }\n\n /** External-URL sugar: builds `AssetCreateLink`. */\n async link(\n input: { url: string; productId?: string; access?: \"PUBLIC\" | \"PRIVATE\" },\n auth: AuthContext = SERVICE,\n ): Promise<{ id: string }> {\n const body: AssetCreateLinkInput = {\n type: \"LINK\",\n access: input.access ?? \"PUBLIC\",\n url: input.url,\n ...(input.productId\n ? { refIds: [{ type: \"PRODUCT\", id: input.productId }] }\n : {}),\n };\n return this.create({ kind: \"link\", body }, auth);\n }\n\n /**\n * Idempotently add a PRODUCT refId to an asset, through a JSON Patch that\n * appends the one reference, so it works for BLOB and LINK alike and leaves\n * the rest of the asset alone.\n *\n * Resolves to the asset as read back after the patch, because Emporix answers\n * 204 to a reference to a product that does not exist and drops it — check\n * `refIds` rather than trusting the call. Only a PUBLIC asset takes a product\n * reference; a PRIVATE one answers 400.\n *\n * Earlier versions sent a JSON PUT of `{ type, refIds }`, which the spec\n * rejects for both types: a BLOB takes no JSON PUT, and a LINK's requires\n * `access` and `url`.\n */\n async attachToProduct(\n assetId: string,\n productId: string,\n auth: AuthContext = SERVICE,\n ): Promise<Asset> {\n const a = await this.get(assetId, auth);\n const refIds: AssetRefId[] = a.refIds ?? [];\n if (refIds.some((r) => isProductRef(r, productId))) return a;\n const ref: AssetRefId = { type: \"PRODUCT\", id: productId };\n // `/refIds/-` appends to an existing array only (RFC 6902).\n const op =\n a.refIds === undefined\n ? { op: \"add\" as const, path: \"/refIds\", value: [ref] }\n : { op: \"add\" as const, path: \"/refIds/-\", value: ref };\n await this.patch(assetId, [op], auth);\n return this.get(assetId, auth);\n }\n\n /**\n * Remove a PRODUCT refId from an asset (no-op if absent), through a JSON Patch\n * that replaces the references and nothing else. Resolves to the asset as\n * read back after the patch, like {@link attachToProduct}. Earlier versions\n * sent a spec-invalid JSON PUT, as that one did.\n */\n async detachFromProduct(\n assetId: string,\n productId: string,\n auth: AuthContext = SERVICE,\n ): Promise<Asset> {\n const a = await this.get(assetId, auth);\n const refIds: AssetRefId[] = a.refIds ?? [];\n const next = refIds.filter((r) => !isProductRef(r, productId));\n if (next.length === refIds.length) return a;\n await this.patch(assetId, [{ op: \"replace\", path: \"/refIds\", value: next }], auth);\n return this.get(assetId, auth);\n }\n\n /** Convenience: list assets attached to a product (server-side filter). */\n async listForProduct(\n productId: string,\n auth: AuthContext = SERVICE,\n ): Promise<PaginatedItems<Asset>> {\n return this.list({ \"refIds.id\": productId }, auth);\n }\n}\n\n// Re-export so consumers can `import { isProductRef } from \"@viu/emporix-sdk/media\"`?\n// Internal helper — kept module-private; convenience methods in Task 4 use it.\nexport const _internalMedia = { isProductRef };\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/core/paged.ts","../src/core/errors.ts","../src/services/media.ts"],"names":["text"],"mappings":";;;AAyBA,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;A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AA,EAAS,CAAC,EAAE,EAAA,EAAI,SAAA,EAAW,IAAA,EAAM,SAAA,EAAW,KAAA,EAAO,IAAA,EAAM,GAAG,IAAI,CAAA;AACjF,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,OAAA,EAAS,IAAI,CAAA;AAAA,EAC/B;AAAA;AAAA,EAGA,MAAM,cAAA,CACJ,SAAA,EACA,IAAA,GAAoB,OAAA,EACY;AAChC,IAAA,OAAO,KAAK,IAAA,CAAK,EAAE,WAAA,EAAa,SAAA,IAAa,IAAI,CAAA;AAAA,EACnD;AACF;AAIO,IAAM,cAAA,GAAiB,EAAE,YAAA","file":"media.cjs","sourcesContent":["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","/** Keys whose values are stripped from any serialised error body. */\nconst REDACTED_BODY_KEYS = new Set([\n \"access_token\", \"refresh_token\", \"token\", \"customertoken\", \"saastoken\",\n \"secret\", \"client_secret\", \"authorization\", \"password\",\n]);\n\nfunction scrub(body: unknown): unknown {\n if (Array.isArray(body)) return body.map(scrub);\n if (body && typeof body === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(body as Record<string, unknown>)) {\n out[k] = REDACTED_BODY_KEYS.has(k.toLowerCase()) ? \"***redacted***\" : scrub(v);\n }\n return out;\n }\n return body;\n}\n\n/** Base class for every error thrown by the SDK. */\nexport class EmporixError extends Error {\n readonly status: number | undefined;\n readonly body: unknown;\n constructor(message: string, status?: number, body?: unknown) {\n super(message);\n this.name = new.target.name;\n this.status = status;\n this.body = body;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n /** Safe serialisation — token-like body fields are redacted. */\n toJSON(): Record<string, unknown> {\n return { name: this.name, message: this.message, status: this.status, body: scrub(this.body) };\n }\n}\n\n/** 401 — authentication failed or token expired. */\nexport class EmporixAuthError extends EmporixError {}\n/** 403 — authenticated but not permitted. */\nexport class EmporixForbiddenError extends EmporixError {}\n/** 404 — resource not found. */\nexport class EmporixNotFoundError extends EmporixError {}\n/** 400/422 — request validation failed. */\nexport class EmporixValidationError extends EmporixError {}\n/** 409 — conflict: a stale `metadata.version`, or an id that already exists. */\nexport class EmporixConflictError extends EmporixError {}\n/** 5xx — server-side failure. */\nexport class EmporixServerError extends EmporixError {}\n/** Request aborted by the configured connect/read timeout. No HTTP status. */\nexport class EmporixTimeoutError extends EmporixError {}\n/** DNS/TLS/connection-level failure before or during the exchange. No HTTP status. */\nexport class EmporixNetworkError extends EmporixError {}\n\n/**\n * 403 with a `missing scope: <name>` hint in the body's `details` array.\n * Subclasses {@link EmporixForbiddenError} so existing 403 catches still work.\n */\nexport class EmporixInsufficientScopeError extends EmporixForbiddenError {\n readonly requiredScope: string | undefined;\n constructor(message: string, status: number, body: unknown, requiredScope?: string) {\n super(message, status, body);\n this.requiredScope = requiredScope;\n }\n}\n\nconst SCOPE_HINT_RE = /missing scope[: ]+([a-z0-9._-]+)/i;\n\nfunction extractRequiredScope(body: unknown): string | undefined {\n if (body && typeof body === \"object\" && \"details\" in body) {\n const details = (body as { details?: unknown }).details;\n if (Array.isArray(details)) {\n for (const d of details) {\n if (typeof d === \"string\") {\n const m = d.match(SCOPE_HINT_RE);\n if (m) return m[1];\n }\n }\n }\n }\n return undefined;\n}\n\n/** Maps an HTTP status to the matching {@link EmporixError} subclass. */\nexport function errorFromResponse(status: number, message: string, body: unknown): EmporixError {\n if (status === 401) return new EmporixAuthError(message, status, body);\n if (status === 403) {\n const scope = extractRequiredScope(body);\n if (scope) return new EmporixInsufficientScopeError(message, status, body, scope);\n return new EmporixForbiddenError(message, status, body);\n }\n if (status === 404) return new EmporixNotFoundError(message, status, body);\n if (status === 400 || status === 422) return new EmporixValidationError(message, status, body);\n if (status === 409) return new EmporixConflictError(message, status, body);\n if (status >= 500) return new EmporixServerError(message, status, body);\n return new EmporixError(message, status, body);\n}\n","import type { ClientContext, PaginatedItems } from \"../core/context\";\nimport { requestPage } from \"../core/paged\";\nimport type { AuthContext } from \"../core/auth\";\nimport { EmporixError, errorFromResponse } from \"../core/errors\";\nimport type {\n AssetCreateBlob,\n AssetCreateLink,\n AssetUpdateBlob,\n AssetUpdateLink,\n DownloadUrl,\n GetAsset,\n GetMediaRetrieveDownloadUrlData,\n MetadataUpdate,\n PatchOperation,\n RefId,\n UploadSession,\n UploadSessionRequest,\n} from \"../generated/media\";\n\n/**\n * The spec marks `metadata` optional on both update bodies; the live API rejects\n * an update without it — «`metadata.version` is required for update» (measured\n * 2026-10-06 on BLOB and LINK assets). Required here, so leaving it out is a\n * compile error rather than a 400.\n */\ntype Versioned<T> = Omit<T, \"metadata\"> & { metadata: MetadataUpdate };\n\n/** Generated media types (caller sends the exact wire shape). */\nexport type AssetCreateBlobInput = AssetCreateBlob;\nexport type AssetCreateLinkInput = AssetCreateLink;\nexport type AssetUpdateBlobInput = Versioned<AssetUpdateBlob>;\nexport type AssetUpdateLinkInput = Versioned<AssetUpdateLink>;\n/**\n * @deprecated `update()` takes {@link AssetUpdateLinkInput} as its JSON body and\n * {@link AssetUpdateBlobInput} next to a file; a BLOB is never sent as JSON.\n */\nexport type AssetUpdateInput = AssetUpdateBlob | AssetUpdateLink;\nexport type Asset = GetAsset;\nexport type AssetRefId = RefId;\n/** Partial-update body (`PATCH /assets/{id}`) — an RFC-6902 JSON-Patch op-array. */\nexport type AssetPatch = PatchOperation[];\n/** Result of {@link MediaService.getDownloadUrl} — `{ provider, url, expiresAt? }`. */\nexport type AssetDownloadUrl = DownloadUrl;\n/** Query for {@link MediaService.getDownloadUrl} — `{ disposition? }`. */\nexport type AssetDownloadUrlQuery = NonNullable<GetMediaRetrieveDownloadUrlData[\"query\"]>;\n/** Body for {@link MediaService.startUploadSession}: a BLOB create payload plus `uploadType`. */\nexport type AssetUploadSessionInput = UploadSessionRequest;\n/** The storage instruction {@link MediaService.startUploadSession} returns. */\nexport type AssetUploadSession = UploadSession;\n\n/**\n * Filter / pagination options for {@link MediaService.list}. The explicit\n * fields are typed for autocomplete; the index signature stays open so\n * Emporix `q`-syntax filters like `\"refIds.id\"` can be passed verbatim.\n */\nexport interface ListAssetsQuery {\n pageNumber?: number;\n pageSize?: number;\n /** Emporix sort syntax, e.g. `\"name,metadata.createdAt:desc\"`. */\n sort?: string;\n /** Emporix `q`-syntax filter, e.g. `\"name:hero\"`. */\n q?: string;\n /**\n * Ask for `X-Total-Count`. An SDK-side flag, not an Emporix query parameter:\n * it becomes a request header.\n */\n totalCount?: boolean;\n [key: string]: string | number | boolean | undefined;\n}\n\n/**\n * Result of {@link MediaService.download}. The endpoint's behaviour depends\n * on the asset's `access`:\n * - `PUBLIC` assets respond with a 30x redirect whose `Location` header\n * carries the externally-cacheable storage URL — useful when the\n * storefront wants to send the user there directly.\n * - `PRIVATE` assets respond with the raw bytes (plus an `ETag` header\n * for caching). The file lives in Google Cloud Storage and is reachable\n * without the service token only through a signed URL from\n * {@link MediaService.getDownloadUrl}.\n */\nexport type DownloadResult =\n | { kind: \"redirect\"; url: string }\n | {\n kind: \"bytes\";\n data: ArrayBuffer;\n etag?: string;\n contentType?: string;\n };\n\nconst SERVICE: AuthContext = { kind: \"service\" };\n\nfunction isProductRef(r: AssetRefId, productId: string): boolean {\n return r.type === \"PRODUCT\" && r.id === productId;\n}\n\n/**\n * Media assets (BLOB/LINK). All endpoints require a backend-only scope\n * (`media.asset_manage` / `media.asset_read`) — default auth: service.\n */\nexport class MediaService {\n static readonly channel = \"media\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/media/${this.ctx.tenant}/assets`;\n }\n\n /**\n * Create an asset. BLOB uploads via multipart (max 30 MB); LINK via JSON.\n * {@link startUploadSession} sends the file straight to storage instead.\n */\n async create(\n input:\n | { kind: \"blob\"; file: Blob; body: AssetCreateBlobInput }\n | { kind: \"link\"; body: AssetCreateLinkInput },\n auth: AuthContext = SERVICE,\n ): Promise<{ id: string }> {\n if (input.kind === \"blob\") {\n const fd = new FormData();\n fd.set(\"file\", input.file);\n fd.set(\"body\", JSON.stringify(input.body));\n return this.ctx.http.request<{ id: string }>({\n method: \"POST\",\n path: this.base(),\n auth,\n body: fd,\n });\n }\n return this.ctx.http.request<{ id: string }>({\n method: \"POST\",\n path: this.base(),\n auth,\n body: input.body,\n });\n }\n\n /**\n * List assets, wrapped in the shared {@link PaginatedItems} envelope so\n * callers can iterate over pages consistently with the rest of the SDK.\n * `hasNextPage` is the standard SDK heuristic: `true` when the returned\n * page is full (`items.length === requested pageSize`). Pagination\n * defaults match Emporix's server defaults (`pageNumber: 1`,\n * `pageSize: 60`) so an empty `query` produces stable expectations.\n */\n async list(\n query: ListAssetsQuery = {},\n auth: AuthContext = SERVICE,\n ): Promise<PaginatedItems<Asset>> {\n const pageNumber = query.pageNumber ?? 1;\n const pageSize = query.pageSize ?? 60;\n // Destructured out because the rest of `query` is spread into the query\n // string: `totalCount` is an SDK-side flag that becomes a request header,\n // and would otherwise ride along as a stray `?totalCount=true`.\n const { totalCount, ...rest } = query;\n return requestPage<Asset>(\n this.ctx.http,\n {\n method: \"GET\",\n path: this.base(),\n auth,\n query: { ...rest, pageNumber, pageSize },\n },\n { pageNumber, pageSize, ...(totalCount === undefined ? {} : { totalCount }) },\n );\n }\n\n /** Fetch an asset by id. */\n async get(assetId: string, auth: AuthContext = SERVICE): Promise<Asset> {\n return this.ctx.http.request<Asset>({\n method: \"GET\",\n path: `${this.base()}/${assetId}`,\n auth,\n });\n }\n\n /**\n * Replace an asset (`PUT`, HTTP 204 — nothing is returned). The spec takes one\n * body per asset type, mirrored by the discriminated input:\n * - `{ kind: \"json\", body }` — a LINK asset, sent as `application/json`. The\n * body is the whole asset: `type: \"LINK\"`, `access` and `url` are required.\n * - `{ kind: \"blob\", file, body }` — a BLOB asset, sent as\n * `multipart/form-data`: the file (max 30 MB) and the asset body, both\n * required, so this always replaces the bytes.\n *\n * A BLOB's metadata alone — `refIds`, `details`, mixins — goes through\n * {@link patch}. Earlier versions also took a BLOB as the JSON body and\n * promised the updated asset in return; the spec allows neither.\n *\n * `type` and `access` are immutable. Optimistic locking is via\n * `body.metadata.version`; a stale one gets a 409.\n */\n async update(\n assetId: string,\n input:\n | { kind: \"json\"; body: AssetUpdateLinkInput }\n | { kind: \"blob\"; file: Blob; body: AssetUpdateBlobInput },\n auth: AuthContext = SERVICE,\n ): Promise<void> {\n const path = `${this.base()}/${encodeURIComponent(assetId)}`;\n if (input.kind === \"blob\") {\n const fd = new FormData();\n fd.set(\"file\", input.file);\n fd.set(\"body\", JSON.stringify(input.body));\n await this.ctx.http.request<void>({ method: \"PUT\", path, auth, body: fd });\n return;\n }\n await this.ctx.http.request<void>({ method: \"PUT\", path, auth, body: input.body });\n }\n\n /**\n * Partially update an asset with an RFC-6902 JSON-Patch op-array\n * (`PATCH /assets/{id}`, HTTP 204 — nothing is returned).\n *\n * This is the way to change one field without resending the whole asset, and\n * the only way to touch a `BLOB` asset's metadata **without re-uploading the\n * file** — {@link update} in `blob` mode always replaces the bytes.\n *\n * Append to an array with a path ending in `/-`, which preserves the existing\n * entries:\n *\n * ```ts\n * await client.media.patch(assetId, [\n * { op: \"add\", path: \"/refIds/-\", value: { id: \"product1\", type: \"PRODUCT\" } },\n * ]);\n * ```\n *\n * `type` and `access` are immutable here too, as with {@link update}. Only\n * `add`, `remove` and `replace` are accepted, and optimistic locking still\n * applies — a stale `metadata.version` gets a 409.\n */\n async patch(assetId: string, ops: AssetPatch, auth: AuthContext = SERVICE): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"PATCH\",\n path: `${this.base()}/${encodeURIComponent(assetId)}`,\n auth,\n body: ops,\n });\n }\n\n /** Remove an asset. */\n async remove(assetId: string, auth: AuthContext = SERVICE): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${assetId}`,\n auth,\n });\n }\n\n /**\n * Download an asset by id. Returns a discriminated union:\n * - `{ kind: \"redirect\", url }` for `PUBLIC` assets (server-side 30x with\n * the storage URL in `Location`).\n * - `{ kind: \"bytes\", data }` for `PRIVATE` assets (server-side 200 with\n * the asset bytes; `etag` + `contentType` headers are exposed for\n * caching). When the server reports `text/plain` Content-Type (the\n * OpenAPI-documented format), the SDK decodes the base64 stream into\n * an `ArrayBuffer` transparently; binary Content-Types are passed\n * through verbatim.\n *\n * Emporix recommends {@link getDownloadUrl} for every download: here the file\n * passes through the Media API. A `413` means the asset's known size exceeds\n * the streaming limit (30 MB by default) — only {@link getDownloadUrl} can\n * serve it. A `409` means the asset is still `PENDING` from a direct upload\n * whose file has not reached storage.\n *\n * Implementation note: uses `redirect: \"manual\"` so the redirect-location\n * is observable. In Node.js this works; in a browser the redirect Location\n * is intentionally hidden by fetch — there, `PUBLIC` downloads will\n * surface as an opaque-redirect and the SDK throws. Browser code should\n * use the asset's `url` field from `get()` for `LINK` assets, or the\n * direct storage URL for `PUBLIC` `BLOB` assets (typically delivered via\n * an `<img>` tag rather than `download()`).\n */\n async download(\n assetId: string,\n auth: AuthContext = SERVICE,\n ): Promise<DownloadResult> {\n const path = `${this.base()}/${assetId}/download`;\n const res = await this.ctx.http.requestRaw(\n { method: \"GET\", path, auth },\n { redirect: \"manual\" },\n );\n\n // PUBLIC: server-side redirect — capture Location.\n if (res.status >= 300 && res.status < 400) {\n const url = res.headers.get(\"location\");\n if (!url) {\n throw new EmporixError(\n `media.download: ${res.status} response without a Location header`,\n res.status,\n );\n }\n return { kind: \"redirect\", url };\n }\n\n // PRIVATE: bytes.\n if (res.ok) {\n const etag = res.headers.get(\"etag\") ?? undefined;\n const contentType = res.headers.get(\"content-type\") ?? undefined;\n let data: ArrayBuffer;\n if (contentType?.startsWith(\"text/plain\")) {\n // Per OpenAPI spec the server returns the byte stream as a\n // base64-encoded text/plain body. Decode once into raw bytes\n // so callers always see an ArrayBuffer.\n const text = await res.text();\n const bin = atob(text);\n const arr = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; i++) arr[i] = bin.charCodeAt(i);\n data = arr.buffer;\n } else {\n data = await res.arrayBuffer();\n }\n return {\n kind: \"bytes\",\n data,\n ...(etag !== undefined ? { etag } : {}),\n ...(contentType !== undefined ? { contentType } : {}),\n };\n }\n\n // Error: surface via the standard EmporixError hierarchy.\n const text = await res.text();\n let parsed: unknown = undefined;\n if (text) {\n try {\n parsed = JSON.parse(text);\n } catch {\n parsed = text;\n }\n }\n throw errorFromResponse(res.status, `GET ${path} → ${res.status}`, parsed);\n }\n\n /**\n * Get a URL that serves the stored file straight from storage\n * (`GET /assets/{assetId}/download-url`). Emporix recommends it for every\n * download: the file never passes through the Media API, there is no size\n * limit, and the URL can be handed to a browser as it is.\n *\n * - `PRIVATE` BLOB → `provider: \"GCS\"`, a signed Google Cloud Storage URL that\n * works without an Emporix token until `expiresAt` (15 minutes by default).\n * - `PUBLIC` BLOB → `provider: \"CLOUDINARY\"`, the permanent URL.\n * - `LINK` → `provider: \"LINK\"`, the stored URL.\n *\n * `disposition` (`attachment` by default, or `inline`) affects private URLs\n * only. Unlike {@link startUploadSession}, this works whether or not direct\n * upload is enabled for the tenant. A `409` means a direct upload is still\n * `PENDING` and its file has not reached storage; once it has, this call\n * completes the asset before answering.\n */\n async getDownloadUrl(\n assetId: string,\n query: AssetDownloadUrlQuery = {},\n auth: AuthContext = SERVICE,\n ): Promise<AssetDownloadUrl> {\n return this.ctx.http.request<AssetDownloadUrl>({\n method: \"GET\",\n path: `${this.base()}/${encodeURIComponent(assetId)}/download-url`,\n auth,\n query: { ...query },\n });\n }\n\n /**\n * Start a direct upload of a `BLOB` asset (`POST /assets/upload-session`,\n * `201`). Emporix creates the asset as `PENDING` — `id` is its id — and\n * returns where to send the file. **This method does not send it**:\n *\n * - `upload.method === \"PUT\"` (a `PRIVATE` asset, `uploadType: \"put\"` or\n * omitted): `PUT` the file to `upload.url` with every `upload.headers` entry.\n * - `upload.method === \"POST\"` (every `PUBLIC` asset, or `uploadType: \"form\"`):\n * a multipart `POST` to `upload.url` with every `upload.fields` entry\n * unchanged and the file part last.\n *\n * That request goes to Google Cloud Storage or Cloudinary, not to Emporix, so\n * it must not carry the Emporix token — which is also why a browser can make\n * it. The asset turns `READY` once storage confirms; until then, calls that\n * need the file answer `409`. The instruction is valid for 15 minutes (GCS) or\n * an hour (Cloudinary), and an unused session expires at `expiresAt`.\n *\n * Direct upload is enabled per tenant by Emporix Support. Without it the call\n * throws an `EmporixForbiddenError` whose `body.message` is `direct upload is\n * not enabled for this tenant`, and nothing is created — the same status as a\n * missing scope, so read the message.\n */\n async startUploadSession(\n input: AssetUploadSessionInput,\n auth: AuthContext = SERVICE,\n ): Promise<AssetUploadSession> {\n return this.ctx.http.request<AssetUploadSession>({\n method: \"POST\",\n path: `${this.base()}/upload-session`,\n auth,\n body: input,\n });\n }\n\n /** Multipart upload sugar: builds `AssetCreateBlob` from input. */\n async uploadFile(\n input: {\n file: Blob;\n productId?: string;\n filename?: string;\n mimeType?: string;\n access?: \"PUBLIC\" | \"PRIVATE\";\n },\n auth: AuthContext = SERVICE,\n ): Promise<{ id: string }> {\n const body: AssetCreateBlobInput = {\n type: \"BLOB\",\n access: input.access ?? \"PUBLIC\",\n ...(input.productId\n ? { refIds: [{ type: \"PRODUCT\", id: input.productId }] }\n : {}),\n ...(input.filename || input.mimeType\n ? {\n details: {\n ...(input.filename ? { filename: input.filename } : {}),\n ...(input.mimeType ? { mimeType: input.mimeType } : {}),\n },\n }\n : {}),\n };\n return this.create({ kind: \"blob\", file: input.file, body }, auth);\n }\n\n /**\n * Replace the file content of an existing BLOB asset. Sugar over\n * {@link update} with `kind: \"blob\"`, and like it resolves to nothing — the\n * PUT answers 204. `access` is required because the field is immutable and\n * the server validates that the body matches.\n *\n * Pass `version` from `asset.metadata.version` for optimistic locking\n * (recommended when concurrent writers are possible) — a stale one gets a 409.\n * Without it the current version is read first, because the live API rejects\n * an update that carries none; the write then wins over any in between.\n */\n async replaceFile(\n assetId: string,\n input: {\n file: Blob;\n access: \"PUBLIC\" | \"PRIVATE\";\n filename?: string;\n mimeType?: string;\n version?: number;\n },\n auth: AuthContext = SERVICE,\n ): Promise<void> {\n const version =\n input.version ?? (await this.get(assetId, auth)).metadata?.version ?? 1;\n const body: AssetUpdateBlobInput = {\n type: \"BLOB\",\n access: input.access,\n ...(input.filename || input.mimeType\n ? {\n details: {\n ...(input.filename ? { filename: input.filename } : {}),\n ...(input.mimeType ? { mimeType: input.mimeType } : {}),\n },\n }\n : {}),\n metadata: { version },\n };\n return this.update(assetId, { kind: \"blob\", file: input.file, body }, auth);\n }\n\n /** External-URL sugar: builds `AssetCreateLink`. */\n async link(\n input: { url: string; productId?: string; access?: \"PUBLIC\" | \"PRIVATE\" },\n auth: AuthContext = SERVICE,\n ): Promise<{ id: string }> {\n const body: AssetCreateLinkInput = {\n type: \"LINK\",\n access: input.access ?? \"PUBLIC\",\n url: input.url,\n ...(input.productId\n ? { refIds: [{ type: \"PRODUCT\", id: input.productId }] }\n : {}),\n };\n return this.create({ kind: \"link\", body }, auth);\n }\n\n /**\n * Idempotently add a PRODUCT refId to an asset, through a JSON Patch that\n * appends the one reference, so it works for BLOB and LINK alike and leaves\n * the rest of the asset alone.\n *\n * Resolves to the asset as read back after the patch, because Emporix answers\n * 204 to a reference to a product that does not exist and drops it — check\n * `refIds` rather than trusting the call. Only a PUBLIC asset takes a product\n * reference; a PRIVATE one answers 400.\n *\n * Earlier versions sent a JSON PUT of `{ type, refIds }`, which the spec\n * rejects for both types: a BLOB takes no JSON PUT, and a LINK's requires\n * `access` and `url`.\n */\n async attachToProduct(\n assetId: string,\n productId: string,\n auth: AuthContext = SERVICE,\n ): Promise<Asset> {\n const a = await this.get(assetId, auth);\n const refIds: AssetRefId[] = a.refIds ?? [];\n if (refIds.some((r) => isProductRef(r, productId))) return a;\n const ref: AssetRefId = { type: \"PRODUCT\", id: productId };\n // `/refIds/-` appends to an existing array only (RFC 6902).\n const op =\n a.refIds === undefined\n ? { op: \"add\" as const, path: \"/refIds\", value: [ref] }\n : { op: \"add\" as const, path: \"/refIds/-\", value: ref };\n await this.patch(assetId, [op], auth);\n return this.get(assetId, auth);\n }\n\n /**\n * Remove a PRODUCT refId from an asset (no-op if absent), through a JSON Patch\n * that replaces the references and nothing else. Resolves to the asset as\n * read back after the patch, like {@link attachToProduct}. Earlier versions\n * sent a spec-invalid JSON PUT, as that one did.\n */\n async detachFromProduct(\n assetId: string,\n productId: string,\n auth: AuthContext = SERVICE,\n ): Promise<Asset> {\n const a = await this.get(assetId, auth);\n const refIds: AssetRefId[] = a.refIds ?? [];\n const next = refIds.filter((r) => !isProductRef(r, productId));\n if (next.length === refIds.length) return a;\n await this.patch(assetId, [{ op: \"replace\", path: \"/refIds\", value: next }], auth);\n return this.get(assetId, auth);\n }\n\n /** Convenience: list assets attached to a product (server-side filter). */\n async listForProduct(\n productId: string,\n auth: AuthContext = SERVICE,\n ): Promise<PaginatedItems<Asset>> {\n return this.list({ \"refIds.id\": productId }, auth);\n }\n}\n\n// Re-export so consumers can `import { isProductRef } from \"@viu/emporix-sdk/media\"`?\n// Internal helper — kept module-private; convenience methods in Task 4 use it.\nexport const _internalMedia = { isProductRef };\n"]}
|
package/dist/media.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { MediaService, _internalMedia } from './chunk-
|
|
1
|
+
export { MediaService, _internalMedia } from './chunk-SIGXBN4F.js';
|
|
2
2
|
import './chunk-LKHKFF7B.js';
|
|
3
|
-
import './chunk-
|
|
3
|
+
import './chunk-4Q76UV4J.js';
|
|
4
4
|
//# sourceMappingURL=media.js.map
|
|
5
5
|
//# sourceMappingURL=media.js.map
|
package/dist/orders.cjs
CHANGED
|
@@ -189,11 +189,15 @@ var SalesOrdersService = class {
|
|
|
189
189
|
auth
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
|
-
/**
|
|
192
|
+
/**
|
|
193
|
+
* Patches an existing order (status, mixins, customAttributes, metadata).
|
|
194
|
+
* Resolves on the `204`, which carries no body — read the order back with
|
|
195
|
+
* {@link get} for its new state.
|
|
196
|
+
*/
|
|
193
197
|
async update(orderId, patch, auth, opts = {}) {
|
|
194
198
|
const query = {};
|
|
195
199
|
if (opts.recalculate === false) query.recalculate = "false";
|
|
196
|
-
|
|
200
|
+
await this.ctx.http.request({
|
|
197
201
|
method: "PATCH",
|
|
198
202
|
path: `${this.base()}/${orderId}`,
|
|
199
203
|
auth,
|
package/dist/orders.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/paged.ts","../src/core/query.ts","../src/services/orders.ts"],"names":[],"mappings":";;;AAyBA,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;A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CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,OAAO,CAAA,aAAA,CAAA;AAAA,MAC/B,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,aAAA,CAAc,OAAA,EAAiB,KAAA,EAA+B,IAAA,EAAwC;AAC1G,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAoB;AAAA,MACvC,MAAA,EAAQ,MAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,OAAO,CAAA,QAAA,CAAA;AAAA,MAC/B,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,KAAA,CAAM,OAAA,EAAiB,KAAA,EAA6B,IAAA,EAAmD;AAC3G,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAA+B;AAAA,MAClD,MAAA,EAAQ,MAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,OAAO,CAAA,MAAA,CAAA;AAAA,MAC/B,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACF","file":"orders.cjs","sourcesContent":["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 { requestPage } from \"../core/paged\";\nimport type { AuthContext } from \"../core/auth\";\nimport { resolveQuery, type QueryFor } from \"../core/query\";\nimport type {\n Order,\n OrderStatus,\n OrderUpdateDto,\n SalesOrder,\n Transition,\n SalesOrderCreationDto,\n ResourceLocation,\n SearchRequest,\n HistoricalTransitionsResponse,\n OrderCalculationDto,\n OrderEntriesDto,\n OrderSplitRequest,\n OrderSplitResponse,\n} from \"../generated/order-v2\";\n\n/**\n * Salesorder PATCH body. The generated `orderUpdateDto` models a full order\n * (it requires `entries`/`customer`), but `PATCH /salesorders/{id}` accepts a\n * subset — so the SDK exposes a partial of it.\n */\nexport type SalesOrderPatch = Partial<OrderUpdateDto>;\n\n/** Body for creating a sales-order as an employee (`POST /salesorders`). */\nexport type SalesOrderCreateInput = SalesOrderCreationDto;\n\n/** Id/location envelope returned when a sales-order is created. */\nexport type SalesOrderCreated = ResourceLocation;\n\n/** Body for a full sales-order replace (`PUT /salesorders/{id}`). */\nexport type SalesOrderReplaceInput = OrderUpdateDto;\n\n/** Body for `salesOrders.search` (`POST /salesorders/search`). */\nexport type SalesOrderSearchInput = SearchRequest;\n\n/** Response of `salesOrders.listHistoricalTransitions`. */\nexport type SalesOrderHistoricalTransitions = HistoricalTransitionsResponse;\n\n/** Body for `salesOrders.calculate` (`POST /salesorders/{id}/calculations`). */\nexport type SalesOrderCalculationInput = OrderCalculationDto;\n\n/** Body for `salesOrders.updateEntries` (`POST /salesorders/{id}/entries`). */\nexport type SalesOrderEntriesInput = OrderEntriesDto;\n\n/** Body for `salesOrders.split` (`POST /salesorders/{id}/split`). */\nexport type SalesOrderSplitInput = OrderSplitRequest;\n\n/** Response of `salesOrders.split`. */\nexport type SalesOrderSplitResult = OrderSplitResponse;\n\n/** Options for `salesOrders.list`. */\nexport interface ListSalesOrdersOptions {\n pageNumber?: number;\n pageSize?: number;\n sort?: string;\n fields?: string;\n /** A `q` filter — raw DSL string or a built filter for entity \"ORDER\". */\n q?: QueryFor<\"ORDER\">;\n /** Ask for `X-Total-Count` — becomes a request header, not a query parameter. */\n totalCount?: boolean;\n}\n\n/** Options for `orders.listForLegalEntity`. */\nexport interface ListLegalEntityOrdersOptions {\n pageNumber?: number;\n pageSize?: number;\n sort?: string;\n saasToken?: string;\n /** A `q` filter — raw DSL string or a built filter for entity \"ORDER\". */\n q?: QueryFor<\"ORDER\">;\n /** Ask for `X-Total-Count` — becomes a request header, not a query parameter. */\n totalCount?: boolean;\n}\n\n/** Optional fields supported by the order-v2 list endpoint. */\nexport interface ListMyOrdersOptions {\n pageNumber?: number;\n pageSize?: number;\n status?: OrderStatus;\n legalEntityId?: string;\n siteCode?: string;\n saasToken?: string;\n /** A `q` filter — raw DSL string or a built filter (e.g. mixinQuery for entity \"ORDER\"). */\n q?: QueryFor<\"ORDER\">;\n /** Ask for `X-Total-Count` — becomes a request header, not a query parameter. */\n totalCount?: boolean;\n}\n\n/** Options for single-order reads (saas-token only). */\nexport interface GetOrderOptions {\n saasToken?: string;\n}\n\n/** Options for status transitions. */\nexport interface OrderTransitionOptions {\n saasToken?: string;\n comment?: string;\n}\n\n/** Options for `salesOrders.update`. */\nexport interface UpdateSalesOrderOptions {\n /** Forwarded as `?recalculate=`. Omit to use the server default (true). */\n recalculate?: boolean;\n}\n\nfunction setIfDefined<V>(\n q: Record<string, string | number | undefined>,\n key: string,\n value: V | undefined,\n): void {\n if (value !== undefined && value !== \"\") {\n q[key] = value as unknown as string | number;\n }\n}\n\n/**\n * Storefront-customer access to Order-v2's customer endpoints.\n *\n * `listMine`/`get` require `order.order_read_own`; transitions require\n * `order.order_manage_own`. All methods accept an optional `saasToken` that\n * is passed as the `saas-token` header (mirrors `checkout.placeOrder`).\n */\nexport class OrdersService {\n static readonly channel = \"orders\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/order-v2/${this.ctx.tenant}/orders`;\n }\n\n private saasHeader(saasToken: string | undefined): Record<string, string> | undefined {\n return saasToken ? { \"saas-token\": saasToken } : undefined;\n }\n\n /** Lists the calling customer's orders. */\n async listMine(\n auth: AuthContext,\n opts: ListMyOrdersOptions = {},\n ): Promise<PaginatedItems<Order>> {\n const pageNumber = opts.pageNumber ?? 1;\n const pageSize = opts.pageSize ?? 50;\n const query: Record<string, string | number | undefined> = {\n pageNumber,\n pageSize,\n };\n setIfDefined(query, \"status\", opts.status);\n setIfDefined(query, \"legalEntityId\", opts.legalEntityId);\n setIfDefined(query, \"siteCode\", opts.siteCode);\n if (opts.q !== undefined) {\n setIfDefined(query, \"q\", resolveQuery(opts.q, { compoundLogicalQuery: false }));\n }\n const headers = this.saasHeader(opts.saasToken);\n // order-v2 returns a bare JSON array, not a {items,...} envelope — the total\n // lives in the X-Total-Count header, which `requestPage` reads when the\n // caller opts in with `totalCount: true`.\n return requestPage<Order>(\n this.ctx.http,\n {\n method: \"GET\",\n path: this.base(),\n query,\n auth,\n ...(headers ? { headers } : {}),\n },\n {\n pageNumber,\n pageSize,\n ...(opts.totalCount === undefined ? {} : { totalCount: opts.totalCount }),\n },\n );\n }\n\n /** Fetches one of the calling customer's orders by id. */\n async get(\n orderId: string,\n auth: AuthContext,\n opts: GetOrderOptions = {},\n ): Promise<Order> {\n const headers = this.saasHeader(opts.saasToken);\n return this.ctx.http.request<Order>({\n method: \"GET\",\n path: `${this.base()}/${orderId}`,\n auth,\n ...(headers ? { headers } : {}),\n });\n }\n\n /**\n * The status transitions the customer may trigger on one of their orders\n * (`GET /orders/{orderId}/transitions`) — for example whether it can still be\n * cancelled, before offering {@link cancel}.\n */\n async listTransitions(\n orderId: string,\n auth: AuthContext,\n opts: GetOrderOptions = {},\n ): Promise<Transition[]> {\n const headers = this.saasHeader(opts.saasToken);\n return this.ctx.http.request<Transition[]>({\n method: \"GET\",\n path: `${this.base()}/${encodeURIComponent(orderId)}/transitions`,\n auth,\n ...(headers ? { headers } : {}),\n });\n }\n\n /** Transitions an order to a new status. Server enforces legal transitions. */\n async transition(\n orderId: string,\n status: OrderStatus,\n auth: AuthContext,\n opts: OrderTransitionOptions = {},\n ): Promise<void> {\n const body: { status: OrderStatus; comment?: string } = { status };\n if (opts.comment !== undefined) body.comment = opts.comment;\n const headers = this.saasHeader(opts.saasToken);\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `${this.base()}/${orderId}/transitions`,\n auth,\n body,\n ...(headers ? { headers } : {}),\n });\n }\n\n /** Convenience: transitions to `DECLINED` (customer cancel). */\n async cancel(\n orderId: string,\n auth: AuthContext,\n opts: { saasToken?: string } = {},\n ): Promise<void> {\n await this.transition(orderId, \"DECLINED\", auth, opts);\n }\n\n /**\n * Lists a legal entity's orders (`GET /legal-entity-orders/{legalEntityId}`),\n * wrapped into `PaginatedItems`. B2B storefront view — requires a customer\n * token with access to the legal entity.\n */\n async listForLegalEntity(\n legalEntityId: string,\n auth: AuthContext,\n opts: ListLegalEntityOrdersOptions = {},\n ): Promise<PaginatedItems<SalesOrder>> {\n const pageNumber = opts.pageNumber ?? 1;\n const pageSize = opts.pageSize ?? 50;\n const query: Record<string, string | number | undefined> = { pageNumber, pageSize };\n setIfDefined(query, \"sort\", opts.sort);\n if (opts.q !== undefined) {\n setIfDefined(query, \"q\", resolveQuery(opts.q, { compoundLogicalQuery: false }));\n }\n const headers = this.saasHeader(opts.saasToken);\n return requestPage<SalesOrder>(\n this.ctx.http,\n {\n method: \"GET\",\n path: `/order-v2/${this.ctx.tenant}/legal-entity-orders/${legalEntityId}`,\n query,\n auth,\n ...(headers ? { headers } : {}),\n },\n {\n pageNumber,\n pageSize,\n ...(opts.totalCount === undefined ? {} : { totalCount: opts.totalCount }),\n },\n );\n }\n\n /**\n * Fetches one order within a legal entity\n * (`GET /legal-entity-orders/{legalEntityId}/{orderId}`).\n */\n async getForLegalEntity(\n legalEntityId: string,\n orderId: string,\n auth: AuthContext,\n opts: { saasToken?: string } = {},\n ): Promise<SalesOrder> {\n const headers = this.saasHeader(opts.saasToken);\n return this.ctx.http.request<SalesOrder>({\n method: \"GET\",\n path: `/order-v2/${this.ctx.tenant}/legal-entity-orders/${legalEntityId}/${orderId}`,\n auth,\n ...(headers ? { headers } : {}),\n });\n }\n}\n\n/**\n * Backend / service-account access to the merchant-facing\n * `/salesorders/{id}` resource. Requires `order.order_read` (read) /\n * `order.order_manage` (update) scopes on a service token.\n *\n * The full admin list + filter surface is deferred to a follow-up\n * sub-spec. This service ships only single-resource read + patch — the\n * common backend use case (e.g. mixin updates after fulfilment).\n */\nexport class SalesOrdersService {\n static readonly channel = \"sales-orders\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/order-v2/${this.ctx.tenant}/salesorders`;\n }\n\n /** Fetches a single sales-order by id. */\n async get(orderId: string, auth: AuthContext): Promise<Order> {\n return this.ctx.http.request<Order>({\n method: \"GET\",\n path: `${this.base()}/${orderId}`,\n auth,\n });\n }\n\n /** Patches an existing order (status, mixins, customAttributes, metadata). */\n async update(\n orderId: string,\n patch: SalesOrderPatch,\n auth: AuthContext,\n opts: UpdateSalesOrderOptions = {},\n ): Promise<Order> {\n const query: Record<string, string> = {};\n if (opts.recalculate === false) query.recalculate = \"false\";\n return this.ctx.http.request<Order>({\n method: \"PATCH\",\n path: `${this.base()}/${orderId}`,\n auth,\n ...(Object.keys(query).length > 0 ? { query } : {}),\n body: patch,\n });\n }\n\n /** Lists tenant sales-orders (`GET /salesorders`), wrapped into `PaginatedItems`. */\n async list(auth: AuthContext, opts: ListSalesOrdersOptions = {}): Promise<PaginatedItems<SalesOrder>> {\n const pageNumber = opts.pageNumber ?? 1;\n const pageSize = opts.pageSize ?? 50;\n const query: Record<string, string | number | undefined> = { pageNumber, pageSize };\n setIfDefined(query, \"sort\", opts.sort);\n setIfDefined(query, \"fields\", opts.fields);\n if (opts.q !== undefined) {\n setIfDefined(query, \"q\", resolveQuery(opts.q, { compoundLogicalQuery: false }));\n }\n return requestPage<SalesOrder>(\n this.ctx.http,\n {\n method: \"GET\",\n path: this.base(),\n query,\n auth,\n },\n {\n pageNumber,\n pageSize,\n ...(opts.totalCount === undefined ? {} : { totalCount: opts.totalCount }),\n },\n );\n }\n\n /** Searches tenant sales-orders (`POST /salesorders/search`, body carries the `q` filter). */\n async search(\n query: SalesOrderSearchInput,\n auth: AuthContext,\n opts: { pageNumber?: number; pageSize?: number; sort?: string; fields?: string } = {},\n ): Promise<SalesOrder[]> {\n const q: Record<string, string | number | undefined> = {};\n setIfDefined(q, \"pageNumber\", opts.pageNumber);\n setIfDefined(q, \"pageSize\", opts.pageSize);\n setIfDefined(q, \"sort\", opts.sort);\n setIfDefined(q, \"fields\", opts.fields);\n return this.ctx.http.request<SalesOrder[]>({\n method: \"POST\",\n path: `${this.base()}/search`,\n ...(Object.keys(q).length > 0 ? { query: q } : {}),\n body: query,\n idempotent: true, // pure read over POST — safe to replay on 5xx/429\n auth,\n });\n }\n\n /** Creates a sales-order as an employee (`POST /salesorders`). Returns the created resource location. */\n async create(input: SalesOrderCreateInput, auth: AuthContext): Promise<SalesOrderCreated> {\n return this.ctx.http.request<SalesOrderCreated>({\n method: \"POST\",\n path: this.base(),\n auth,\n body: input,\n });\n }\n\n /**\n * Full-replaces a sales-order (`PUT /salesorders/{orderId}`, body `OrderUpdateDto`).\n * The endpoint returns 204, so the order is re-fetched (direct GET) and returned.\n * Note: `update` on this class is the PATCH (partial); `replace` is the PUT (full).\n */\n async replace(orderId: string, input: SalesOrderReplaceInput, auth: AuthContext): Promise<SalesOrder> {\n await this.ctx.http.request<void>({\n method: \"PUT\",\n path: `${this.base()}/${orderId}`,\n auth,\n body: input,\n });\n return this.ctx.http.request<SalesOrder>({\n method: \"GET\",\n path: `${this.base()}/${orderId}`,\n auth,\n });\n }\n\n /** Deletes a sales-order (`DELETE /salesorders/{orderId}`). */\n async delete(orderId: string, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${orderId}`,\n auth,\n });\n }\n\n /** Lists the available transitions for a sales-order (`GET /salesorders/{orderId}/transitions`). */\n async listTransitions(orderId: string, auth: AuthContext): Promise<Transition[]> {\n return this.ctx.http.request<Transition[]>({\n method: \"GET\",\n path: `${this.base()}/${orderId}/transitions`,\n auth,\n });\n }\n\n /** Transitions a sales-order to a new status (`POST /salesorders/{orderId}/transitions`). */\n async transition(orderId: string, input: Transition, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `${this.base()}/${orderId}/transitions`,\n auth,\n body: input,\n });\n }\n\n /** Lists the historical transitions of a sales-order (`GET /salesorders/{orderId}/historical-transitions`). */\n async listHistoricalTransitions(orderId: string, auth: AuthContext): Promise<SalesOrderHistoricalTransitions> {\n return this.ctx.http.request<SalesOrderHistoricalTransitions>({\n method: \"GET\",\n path: `${this.base()}/${orderId}/historical-transitions`,\n auth,\n });\n }\n\n /** Calculates order-entry totals for a sales-order (`POST /salesorders/{orderId}/calculations`). */\n async calculate(orderId: string, input: SalesOrderCalculationInput, auth: AuthContext): Promise<unknown> {\n return this.ctx.http.request<unknown>({\n method: \"POST\",\n path: `${this.base()}/${orderId}/calculations`,\n auth,\n body: input,\n });\n }\n\n /** Updates a sales-order's entries (`POST /salesorders/{orderId}/entries`). Returns the updated order. */\n async updateEntries(orderId: string, input: SalesOrderEntriesInput, auth: AuthContext): Promise<SalesOrder> {\n return this.ctx.http.request<SalesOrder>({\n method: \"POST\",\n path: `${this.base()}/${orderId}/entries`,\n auth,\n body: input,\n });\n }\n\n /** Splits a sales-order (`POST /salesorders/{orderId}/split`). */\n async split(orderId: string, input: SalesOrderSplitInput, auth: AuthContext): Promise<SalesOrderSplitResult> {\n return this.ctx.http.request<SalesOrderSplitResult>({\n method: \"POST\",\n path: `${this.base()}/${orderId}/split`,\n auth,\n body: input,\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/core/paged.ts","../src/core/query.ts","../src/services/orders.ts"],"names":[],"mappings":";;;AAyBA,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,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,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAiB;AAAA,MACpC,MAAA,EAAQ,MAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,OAAO,CAAA,aAAA,CAAA;AAAA,MAC/B,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,aAAA,CAAc,OAAA,EAAiB,KAAA,EAA+B,IAAA,EAAwC;AAC1G,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAoB;AAAA,MACvC,MAAA,EAAQ,MAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,OAAO,CAAA,QAAA,CAAA;AAAA,MAC/B,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,KAAA,CAAM,OAAA,EAAiB,KAAA,EAA6B,IAAA,EAAmD;AAC3G,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAA+B;AAAA,MAClD,MAAA,EAAQ,MAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,OAAO,CAAA,MAAA,CAAA;AAAA,MAC/B,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACF","file":"orders.cjs","sourcesContent":["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 { requestPage } from \"../core/paged\";\nimport type { AuthContext } from \"../core/auth\";\nimport { resolveQuery, type QueryFor } from \"../core/query\";\nimport type {\n Order,\n OrderStatus,\n OrderUpdateDto,\n SalesOrder,\n Transition,\n SalesOrderCreationDto,\n ResourceLocation,\n SearchRequest,\n HistoricalTransitionsResponse,\n OrderCalculationDto,\n OrderEntriesDto,\n OrderSplitRequest,\n OrderSplitResponse,\n} from \"../generated/order-v2\";\n\n/**\n * Salesorder PATCH body. The generated `orderUpdateDto` models a full order\n * (it requires `entries`/`customer`), but `PATCH /salesorders/{id}` accepts a\n * subset — so the SDK exposes a partial of it.\n */\nexport type SalesOrderPatch = Partial<OrderUpdateDto>;\n\n/** Body for creating a sales-order as an employee (`POST /salesorders`). */\nexport type SalesOrderCreateInput = SalesOrderCreationDto;\n\n/** Id/location envelope returned when a sales-order is created. */\nexport type SalesOrderCreated = ResourceLocation;\n\n/** Body for a full sales-order replace (`PUT /salesorders/{id}`). */\nexport type SalesOrderReplaceInput = OrderUpdateDto;\n\n/** Body for `salesOrders.search` (`POST /salesorders/search`). */\nexport type SalesOrderSearchInput = SearchRequest;\n\n/** Response of `salesOrders.listHistoricalTransitions`. */\nexport type SalesOrderHistoricalTransitions = HistoricalTransitionsResponse;\n\n/** Body for `salesOrders.calculate` (`POST /salesorders/{id}/calculations`). */\nexport type SalesOrderCalculationInput = OrderCalculationDto;\n\n/** Body for `salesOrders.updateEntries` (`POST /salesorders/{id}/entries`). */\nexport type SalesOrderEntriesInput = OrderEntriesDto;\n\n/** Body for `salesOrders.split` (`POST /salesorders/{id}/split`). */\nexport type SalesOrderSplitInput = OrderSplitRequest;\n\n/** Response of `salesOrders.split`. */\nexport type SalesOrderSplitResult = OrderSplitResponse;\n\n/** Options for `salesOrders.list`. */\nexport interface ListSalesOrdersOptions {\n pageNumber?: number;\n pageSize?: number;\n sort?: string;\n fields?: string;\n /** A `q` filter — raw DSL string or a built filter for entity \"ORDER\". */\n q?: QueryFor<\"ORDER\">;\n /** Ask for `X-Total-Count` — becomes a request header, not a query parameter. */\n totalCount?: boolean;\n}\n\n/** Options for `orders.listForLegalEntity`. */\nexport interface ListLegalEntityOrdersOptions {\n pageNumber?: number;\n pageSize?: number;\n sort?: string;\n saasToken?: string;\n /** A `q` filter — raw DSL string or a built filter for entity \"ORDER\". */\n q?: QueryFor<\"ORDER\">;\n /** Ask for `X-Total-Count` — becomes a request header, not a query parameter. */\n totalCount?: boolean;\n}\n\n/** Optional fields supported by the order-v2 list endpoint. */\nexport interface ListMyOrdersOptions {\n pageNumber?: number;\n pageSize?: number;\n status?: OrderStatus;\n legalEntityId?: string;\n siteCode?: string;\n saasToken?: string;\n /** A `q` filter — raw DSL string or a built filter (e.g. mixinQuery for entity \"ORDER\"). */\n q?: QueryFor<\"ORDER\">;\n /** Ask for `X-Total-Count` — becomes a request header, not a query parameter. */\n totalCount?: boolean;\n}\n\n/** Options for single-order reads (saas-token only). */\nexport interface GetOrderOptions {\n saasToken?: string;\n}\n\n/** Options for status transitions. */\nexport interface OrderTransitionOptions {\n saasToken?: string;\n comment?: string;\n}\n\n/** Options for `salesOrders.update`. */\nexport interface UpdateSalesOrderOptions {\n /** Forwarded as `?recalculate=`. Omit to use the server default (true). */\n recalculate?: boolean;\n}\n\nfunction setIfDefined<V>(\n q: Record<string, string | number | undefined>,\n key: string,\n value: V | undefined,\n): void {\n if (value !== undefined && value !== \"\") {\n q[key] = value as unknown as string | number;\n }\n}\n\n/**\n * Storefront-customer access to Order-v2's customer endpoints.\n *\n * `listMine`/`get` require `order.order_read_own`; transitions require\n * `order.order_manage_own`. All methods accept an optional `saasToken` that\n * is passed as the `saas-token` header (mirrors `checkout.placeOrder`).\n */\nexport class OrdersService {\n static readonly channel = \"orders\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/order-v2/${this.ctx.tenant}/orders`;\n }\n\n private saasHeader(saasToken: string | undefined): Record<string, string> | undefined {\n return saasToken ? { \"saas-token\": saasToken } : undefined;\n }\n\n /** Lists the calling customer's orders. */\n async listMine(\n auth: AuthContext,\n opts: ListMyOrdersOptions = {},\n ): Promise<PaginatedItems<Order>> {\n const pageNumber = opts.pageNumber ?? 1;\n const pageSize = opts.pageSize ?? 50;\n const query: Record<string, string | number | undefined> = {\n pageNumber,\n pageSize,\n };\n setIfDefined(query, \"status\", opts.status);\n setIfDefined(query, \"legalEntityId\", opts.legalEntityId);\n setIfDefined(query, \"siteCode\", opts.siteCode);\n if (opts.q !== undefined) {\n setIfDefined(query, \"q\", resolveQuery(opts.q, { compoundLogicalQuery: false }));\n }\n const headers = this.saasHeader(opts.saasToken);\n // order-v2 returns a bare JSON array, not a {items,...} envelope — the total\n // lives in the X-Total-Count header, which `requestPage` reads when the\n // caller opts in with `totalCount: true`.\n return requestPage<Order>(\n this.ctx.http,\n {\n method: \"GET\",\n path: this.base(),\n query,\n auth,\n ...(headers ? { headers } : {}),\n },\n {\n pageNumber,\n pageSize,\n ...(opts.totalCount === undefined ? {} : { totalCount: opts.totalCount }),\n },\n );\n }\n\n /** Fetches one of the calling customer's orders by id. */\n async get(\n orderId: string,\n auth: AuthContext,\n opts: GetOrderOptions = {},\n ): Promise<Order> {\n const headers = this.saasHeader(opts.saasToken);\n return this.ctx.http.request<Order>({\n method: \"GET\",\n path: `${this.base()}/${orderId}`,\n auth,\n ...(headers ? { headers } : {}),\n });\n }\n\n /**\n * The status transitions the customer may trigger on one of their orders\n * (`GET /orders/{orderId}/transitions`) — for example whether it can still be\n * cancelled, before offering {@link cancel}.\n */\n async listTransitions(\n orderId: string,\n auth: AuthContext,\n opts: GetOrderOptions = {},\n ): Promise<Transition[]> {\n const headers = this.saasHeader(opts.saasToken);\n return this.ctx.http.request<Transition[]>({\n method: \"GET\",\n path: `${this.base()}/${encodeURIComponent(orderId)}/transitions`,\n auth,\n ...(headers ? { headers } : {}),\n });\n }\n\n /** Transitions an order to a new status. Server enforces legal transitions. */\n async transition(\n orderId: string,\n status: OrderStatus,\n auth: AuthContext,\n opts: OrderTransitionOptions = {},\n ): Promise<void> {\n const body: { status: OrderStatus; comment?: string } = { status };\n if (opts.comment !== undefined) body.comment = opts.comment;\n const headers = this.saasHeader(opts.saasToken);\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `${this.base()}/${orderId}/transitions`,\n auth,\n body,\n ...(headers ? { headers } : {}),\n });\n }\n\n /** Convenience: transitions to `DECLINED` (customer cancel). */\n async cancel(\n orderId: string,\n auth: AuthContext,\n opts: { saasToken?: string } = {},\n ): Promise<void> {\n await this.transition(orderId, \"DECLINED\", auth, opts);\n }\n\n /**\n * Lists a legal entity's orders (`GET /legal-entity-orders/{legalEntityId}`),\n * wrapped into `PaginatedItems`. B2B storefront view — requires a customer\n * token with access to the legal entity.\n */\n async listForLegalEntity(\n legalEntityId: string,\n auth: AuthContext,\n opts: ListLegalEntityOrdersOptions = {},\n ): Promise<PaginatedItems<SalesOrder>> {\n const pageNumber = opts.pageNumber ?? 1;\n const pageSize = opts.pageSize ?? 50;\n const query: Record<string, string | number | undefined> = { pageNumber, pageSize };\n setIfDefined(query, \"sort\", opts.sort);\n if (opts.q !== undefined) {\n setIfDefined(query, \"q\", resolveQuery(opts.q, { compoundLogicalQuery: false }));\n }\n const headers = this.saasHeader(opts.saasToken);\n return requestPage<SalesOrder>(\n this.ctx.http,\n {\n method: \"GET\",\n path: `/order-v2/${this.ctx.tenant}/legal-entity-orders/${legalEntityId}`,\n query,\n auth,\n ...(headers ? { headers } : {}),\n },\n {\n pageNumber,\n pageSize,\n ...(opts.totalCount === undefined ? {} : { totalCount: opts.totalCount }),\n },\n );\n }\n\n /**\n * Fetches one order within a legal entity\n * (`GET /legal-entity-orders/{legalEntityId}/{orderId}`).\n */\n async getForLegalEntity(\n legalEntityId: string,\n orderId: string,\n auth: AuthContext,\n opts: { saasToken?: string } = {},\n ): Promise<SalesOrder> {\n const headers = this.saasHeader(opts.saasToken);\n return this.ctx.http.request<SalesOrder>({\n method: \"GET\",\n path: `/order-v2/${this.ctx.tenant}/legal-entity-orders/${legalEntityId}/${orderId}`,\n auth,\n ...(headers ? { headers } : {}),\n });\n }\n}\n\n/**\n * Backend / service-account access to the merchant-facing\n * `/salesorders/{id}` resource. Requires `order.order_read` (read) /\n * `order.order_manage` (update) scopes on a service token.\n *\n * The full admin list + filter surface is deferred to a follow-up\n * sub-spec. This service ships only single-resource read + patch — the\n * common backend use case (e.g. mixin updates after fulfilment).\n */\nexport class SalesOrdersService {\n static readonly channel = \"sales-orders\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/order-v2/${this.ctx.tenant}/salesorders`;\n }\n\n /** Fetches a single sales-order by id. */\n async get(orderId: string, auth: AuthContext): Promise<Order> {\n return this.ctx.http.request<Order>({\n method: \"GET\",\n path: `${this.base()}/${orderId}`,\n auth,\n });\n }\n\n /**\n * Patches an existing order (status, mixins, customAttributes, metadata).\n * Resolves on the `204`, which carries no body — read the order back with\n * {@link get} for its new state.\n */\n async update(\n orderId: string,\n patch: SalesOrderPatch,\n auth: AuthContext,\n opts: UpdateSalesOrderOptions = {},\n ): Promise<void> {\n const query: Record<string, string> = {};\n if (opts.recalculate === false) query.recalculate = \"false\";\n await this.ctx.http.request<void>({\n method: \"PATCH\",\n path: `${this.base()}/${orderId}`,\n auth,\n ...(Object.keys(query).length > 0 ? { query } : {}),\n body: patch,\n });\n }\n\n /** Lists tenant sales-orders (`GET /salesorders`), wrapped into `PaginatedItems`. */\n async list(auth: AuthContext, opts: ListSalesOrdersOptions = {}): Promise<PaginatedItems<SalesOrder>> {\n const pageNumber = opts.pageNumber ?? 1;\n const pageSize = opts.pageSize ?? 50;\n const query: Record<string, string | number | undefined> = { pageNumber, pageSize };\n setIfDefined(query, \"sort\", opts.sort);\n setIfDefined(query, \"fields\", opts.fields);\n if (opts.q !== undefined) {\n setIfDefined(query, \"q\", resolveQuery(opts.q, { compoundLogicalQuery: false }));\n }\n return requestPage<SalesOrder>(\n this.ctx.http,\n {\n method: \"GET\",\n path: this.base(),\n query,\n auth,\n },\n {\n pageNumber,\n pageSize,\n ...(opts.totalCount === undefined ? {} : { totalCount: opts.totalCount }),\n },\n );\n }\n\n /** Searches tenant sales-orders (`POST /salesorders/search`, body carries the `q` filter). */\n async search(\n query: SalesOrderSearchInput,\n auth: AuthContext,\n opts: { pageNumber?: number; pageSize?: number; sort?: string; fields?: string } = {},\n ): Promise<SalesOrder[]> {\n const q: Record<string, string | number | undefined> = {};\n setIfDefined(q, \"pageNumber\", opts.pageNumber);\n setIfDefined(q, \"pageSize\", opts.pageSize);\n setIfDefined(q, \"sort\", opts.sort);\n setIfDefined(q, \"fields\", opts.fields);\n return this.ctx.http.request<SalesOrder[]>({\n method: \"POST\",\n path: `${this.base()}/search`,\n ...(Object.keys(q).length > 0 ? { query: q } : {}),\n body: query,\n idempotent: true, // pure read over POST — safe to replay on 5xx/429\n auth,\n });\n }\n\n /** Creates a sales-order as an employee (`POST /salesorders`). Returns the created resource location. */\n async create(input: SalesOrderCreateInput, auth: AuthContext): Promise<SalesOrderCreated> {\n return this.ctx.http.request<SalesOrderCreated>({\n method: \"POST\",\n path: this.base(),\n auth,\n body: input,\n });\n }\n\n /**\n * Full-replaces a sales-order (`PUT /salesorders/{orderId}`, body `OrderUpdateDto`).\n * The endpoint returns 204, so the order is re-fetched (direct GET) and returned.\n * Note: `update` on this class is the PATCH (partial); `replace` is the PUT (full).\n */\n async replace(orderId: string, input: SalesOrderReplaceInput, auth: AuthContext): Promise<SalesOrder> {\n await this.ctx.http.request<void>({\n method: \"PUT\",\n path: `${this.base()}/${orderId}`,\n auth,\n body: input,\n });\n return this.ctx.http.request<SalesOrder>({\n method: \"GET\",\n path: `${this.base()}/${orderId}`,\n auth,\n });\n }\n\n /** Deletes a sales-order (`DELETE /salesorders/{orderId}`). */\n async delete(orderId: string, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${orderId}`,\n auth,\n });\n }\n\n /** Lists the available transitions for a sales-order (`GET /salesorders/{orderId}/transitions`). */\n async listTransitions(orderId: string, auth: AuthContext): Promise<Transition[]> {\n return this.ctx.http.request<Transition[]>({\n method: \"GET\",\n path: `${this.base()}/${orderId}/transitions`,\n auth,\n });\n }\n\n /** Transitions a sales-order to a new status (`POST /salesorders/{orderId}/transitions`). */\n async transition(orderId: string, input: Transition, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `${this.base()}/${orderId}/transitions`,\n auth,\n body: input,\n });\n }\n\n /** Lists the historical transitions of a sales-order (`GET /salesorders/{orderId}/historical-transitions`). */\n async listHistoricalTransitions(orderId: string, auth: AuthContext): Promise<SalesOrderHistoricalTransitions> {\n return this.ctx.http.request<SalesOrderHistoricalTransitions>({\n method: \"GET\",\n path: `${this.base()}/${orderId}/historical-transitions`,\n auth,\n });\n }\n\n /** Calculates order-entry totals for a sales-order (`POST /salesorders/{orderId}/calculations`). */\n async calculate(orderId: string, input: SalesOrderCalculationInput, auth: AuthContext): Promise<unknown> {\n return this.ctx.http.request<unknown>({\n method: \"POST\",\n path: `${this.base()}/${orderId}/calculations`,\n auth,\n body: input,\n });\n }\n\n /** Updates a sales-order's entries (`POST /salesorders/{orderId}/entries`). Returns the updated order. */\n async updateEntries(orderId: string, input: SalesOrderEntriesInput, auth: AuthContext): Promise<SalesOrder> {\n return this.ctx.http.request<SalesOrder>({\n method: \"POST\",\n path: `${this.base()}/${orderId}/entries`,\n auth,\n body: input,\n });\n }\n\n /** Splits a sales-order (`POST /salesorders/{orderId}/split`). */\n async split(orderId: string, input: SalesOrderSplitInput, auth: AuthContext): Promise<SalesOrderSplitResult> {\n return this.ctx.http.request<SalesOrderSplitResult>({\n method: \"POST\",\n path: `${this.base()}/${orderId}/split`,\n auth,\n body: input,\n });\n }\n}\n"]}
|
package/dist/orders.d.cts
CHANGED
|
@@ -2141,8 +2141,12 @@ declare class SalesOrdersService {
|
|
|
2141
2141
|
private base;
|
|
2142
2142
|
/** Fetches a single sales-order by id. */
|
|
2143
2143
|
get(orderId: string, auth: AuthContext): Promise<Order>;
|
|
2144
|
-
/**
|
|
2145
|
-
|
|
2144
|
+
/**
|
|
2145
|
+
* Patches an existing order (status, mixins, customAttributes, metadata).
|
|
2146
|
+
* Resolves on the `204`, which carries no body — read the order back with
|
|
2147
|
+
* {@link get} for its new state.
|
|
2148
|
+
*/
|
|
2149
|
+
update(orderId: string, patch: SalesOrderPatch, auth: AuthContext, opts?: UpdateSalesOrderOptions): Promise<void>;
|
|
2146
2150
|
/** Lists tenant sales-orders (`GET /salesorders`), wrapped into `PaginatedItems`. */
|
|
2147
2151
|
list(auth: AuthContext, opts?: ListSalesOrdersOptions): Promise<PaginatedItems<SalesOrder>>;
|
|
2148
2152
|
/** Searches tenant sales-orders (`POST /salesorders/search`, body carries the `q` filter). */
|
package/dist/orders.d.ts
CHANGED
|
@@ -2141,8 +2141,12 @@ declare class SalesOrdersService {
|
|
|
2141
2141
|
private base;
|
|
2142
2142
|
/** Fetches a single sales-order by id. */
|
|
2143
2143
|
get(orderId: string, auth: AuthContext): Promise<Order>;
|
|
2144
|
-
/**
|
|
2145
|
-
|
|
2144
|
+
/**
|
|
2145
|
+
* Patches an existing order (status, mixins, customAttributes, metadata).
|
|
2146
|
+
* Resolves on the `204`, which carries no body — read the order back with
|
|
2147
|
+
* {@link get} for its new state.
|
|
2148
|
+
*/
|
|
2149
|
+
update(orderId: string, patch: SalesOrderPatch, auth: AuthContext, opts?: UpdateSalesOrderOptions): Promise<void>;
|
|
2146
2150
|
/** Lists tenant sales-orders (`GET /salesorders`), wrapped into `PaginatedItems`. */
|
|
2147
2151
|
list(auth: AuthContext, opts?: ListSalesOrdersOptions): Promise<PaginatedItems<SalesOrder>>;
|
|
2148
2152
|
/** Searches tenant sales-orders (`POST /salesorders/search`, body carries the `q` filter). */
|
package/dist/orders.js
CHANGED