@viu/emporix-sdk 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/dist/{chunk-QQMLN76U.js → chunk-2OTFVTG6.js} +7 -4
- package/dist/chunk-2OTFVTG6.js.map +1 -0
- package/dist/{chunk-CSYXGTOH.js → chunk-5MPL4XBD.js} +68 -4
- package/dist/chunk-5MPL4XBD.js.map +1 -0
- package/dist/{chunk-P3RANRGB.js → chunk-IYNT5BQW.js} +16 -2
- package/dist/chunk-IYNT5BQW.js.map +1 -0
- package/dist/{chunk-ZOFGDNSX.js → chunk-K4KXT6NX.js} +12 -6
- package/dist/chunk-K4KXT6NX.js.map +1 -0
- package/dist/{chunk-XJJDCK2Z.js → chunk-N2CE3J4M.js} +12 -7
- package/dist/chunk-N2CE3J4M.js.map +1 -0
- package/dist/{chunk-5XZ6MSXW.js → chunk-VXORPTMP.js} +19 -2
- package/dist/chunk-VXORPTMP.js.map +1 -0
- package/dist/chunk-ZWJUDXTK.js +15 -0
- package/dist/chunk-ZWJUDXTK.js.map +1 -0
- package/dist/companies.cjs +15 -2
- package/dist/companies.cjs.map +1 -1
- package/dist/companies.d.cts +5 -3
- package/dist/companies.d.ts +5 -3
- package/dist/companies.js +2 -1
- package/dist/customer-groups.cjs +17 -0
- package/dist/customer-groups.cjs.map +1 -1
- package/dist/customer-groups.js +1 -1
- package/dist/index.cjs +214 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -21
- package/dist/index.d.ts +72 -21
- package/dist/index.js +97 -57
- package/dist/index.js.map +1 -1
- package/dist/media.cjs +66 -2
- package/dist/media.cjs.map +1 -1
- package/dist/media.d.cts +194 -15
- package/dist/media.d.ts +194 -15
- package/dist/media.js +1 -1
- package/dist/orders.cjs +14 -0
- package/dist/orders.cjs.map +1 -1
- package/dist/orders.d.cts +6 -0
- package/dist/orders.d.ts +6 -0
- package/dist/orders.js +1 -1
- package/dist/price.cjs +20 -4
- package/dist/price.cjs.map +1 -1
- package/dist/price.d.cts +12 -4
- package/dist/price.d.ts +12 -4
- package/dist/price.js +2 -1
- package/dist/search-DU6tE356.d.cts +15 -0
- package/dist/search-DU6tE356.d.ts +15 -0
- package/dist/segment.cjs +21 -5
- package/dist/segment.cjs.map +1 -1
- package/dist/segment.d.cts +16 -6
- package/dist/segment.d.ts +16 -6
- package/dist/segment.js +2 -1
- package/package.json +1 -1
- package/dist/chunk-5XZ6MSXW.js.map +0 -1
- package/dist/chunk-CSYXGTOH.js.map +0 -1
- package/dist/chunk-P3RANRGB.js.map +0 -1
- package/dist/chunk-QQMLN76U.js.map +0 -1
- package/dist/chunk-XJJDCK2Z.js.map +0 -1
- package/dist/chunk-ZOFGDNSX.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# @viu/emporix-sdk
|
|
2
2
|
|
|
3
|
+
## 4.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#354](https://github.com/viuteam/emporix-sdk/pull/354) [`f83f908`](https://github.com/viuteam/emporix-sdk/commit/f83f9083024e9dba2e96119118debee616ae9a9a) Thanks [@amnael1](https://github.com/amnael1)! - feat(sdk): page listAgents and listConversations
|
|
8
|
+
|
|
9
|
+
Both took only `auth`, so they returned the server's first page with no way to reach the rest. They now take a query first — `q`, `pageNumber`, `pageSize`, `sort`, `fields`, and for agents `expand` — like every other AI list method: `listAgents({ pageNumber: 2 }, auth)`. The original `listAgents(auth)` still works: an auth context in the first position is recognised and never sent as query parameters.
|
|
10
|
+
|
|
11
|
+
- [#350](https://github.com/viuteam/emporix-sdk/pull/350) [`7def25c`](https://github.com/viuteam/emporix-sdk/commit/7def25c7a082ba6c0214e8a890395376162ff9a6) Thanks [@amnael1](https://github.com/amnael1)! - feat(sdk): send paging, sort and fields on every AI search
|
|
12
|
+
|
|
13
|
+
The ten AI search methods — `searchAgents`, `searchConversations`, `search` on `tools`, `mcpServers`, `tokens`, `oauths`, `templates` and `jobs`, and `logs.searchRequests` / `logs.searchSessions` — sent their input as the request body only. Emporix reads paging, sort and fields from the query string, so every search returned the server's first page with no way to reach the rest.
|
|
14
|
+
|
|
15
|
+
They now take `pageNumber`, `pageSize`, `sort` and `fields` next to `q` (the new `SearchPaging` type) and send them as query parameters; `q` stays in the body. A call without them goes out exactly as before.
|
|
16
|
+
|
|
17
|
+
- [#354](https://github.com/viuteam/emporix-sdk/pull/354) [`6e4c051`](https://github.com/viuteam/emporix-sdk/commit/6e4c0515b51285b6bcdddfb7a04de39a94751cc4) Thanks [@amnael1](https://github.com/amnael1)! - feat(sdk): wrap the last four never-built endpoints, and fix employee shopping-list edits
|
|
18
|
+
|
|
19
|
+
- `orders.listTransitions(orderId, auth, { saasToken? })` — the status transitions the customer may trigger on one of their orders, for example whether it can still be cancelled. React gets `useOrderTransitions(orderId)` and Angular `injectOrderTransitions(orderId)`; both refresh after a cancel or transition.
|
|
20
|
+
- `iam.users.listForVendor(vendorId, auth)` lists a vendor's Management Dashboard users with their groups; `iam.users.removeFromAllGroups(userId, auth)` takes a user out of every group at once.
|
|
21
|
+
- `shoppingLists.getForCustomer(customerId, auth, { name? })` reads one customer's lists.
|
|
22
|
+
|
|
23
|
+
**Fix:** with a service token, `shoppingLists.addItem`, `removeItem` and `setItemQuantity` now read the target customer's list through `getForCustomer`. They read through `list()`, which for an employee returns every customer's lists and ignores the name — so the first list of that name could belong to another customer, and its items were written into this one. A customer token still reads the caller's own lists.
|
|
24
|
+
|
|
25
|
+
- [#350](https://github.com/viuteam/emporix-sdk/pull/350) [`758b023`](https://github.com/viuteam/emporix-sdk/commit/758b02396392181fd316c2c9c839b359cce263ab) Thanks [@amnael1](https://github.com/amnael1)! - feat(media): add getDownloadUrl and startUploadSession for direct storage transfers
|
|
26
|
+
|
|
27
|
+
`client.media.getDownloadUrl(assetId, { disposition? })` returns a URL that serves the file straight from storage — signed for 15 minutes for a private asset, permanent for a public one — with no size limit and no Emporix token needed to open it. Emporix now recommends it over `download()`, which answers `413` once a file exceeds 30 MB.
|
|
28
|
+
|
|
29
|
+
`client.media.startUploadSession(input)` creates a `PENDING` asset and returns the storage request to send the file with, which a browser can make without an Emporix token. Direct upload has to be enabled for the tenant by Emporix Support; until then the call throws a `403` whose message is `direct upload is not enabled for this tenant`.
|
|
30
|
+
|
|
31
|
+
`AssetDownloadUrl`, `AssetDownloadUrlQuery`, `AssetUploadSession` and `AssetUploadSessionInput` are exported from the package root, and so is `AssetPatch`, which was missing there.
|
|
32
|
+
|
|
33
|
+
- [#352](https://github.com/viuteam/emporix-sdk/pull/352) [`54464af`](https://github.com/viuteam/emporix-sdk/commit/54464af75fdfb0e2cc51f16c6d99373f50664faf) Thanks [@amnael1](https://github.com/amnael1)! - feat(sdk): send paging and sort on every remaining POST search
|
|
34
|
+
|
|
35
|
+
Nine search methods outside the AI service sent their whole input as the request body: `companies.search`, `customerAdmin.searchCustomers`, `vendors.searchVendors`, `segments.search`, `segments.customers.search`, `segments.groups.search`, `segments.items.search`, `prices.lists.search` and `prices.lists.searchPrices`. Emporix reads paging and sort for these endpoints from the query string, so each one returned only the first page — a `pageNumber` passed in the input went into the body and was ignored.
|
|
36
|
+
|
|
37
|
+
They now send `pageNumber`, `pageSize` and `sort`, and — where the endpoint declares them — `fields`, `expand`, `legalEntityId` and `customerId` as query parameters, keeping the rest in the body. `prices.search` sends `expand` and `fees.searchItemFeesByProductIds` sends `siteFallback` the same way. The input types gained these keys, and `SearchPaging` is exported from the package root. A call without them goes out exactly as before.
|
|
38
|
+
|
|
39
|
+
## 4.0.1
|
|
40
|
+
|
|
41
|
+
### Patch Changes
|
|
42
|
+
|
|
43
|
+
- [#347](https://github.com/viuteam/emporix-sdk/pull/347) [`56be0ea`](https://github.com/viuteam/emporix-sdk/commit/56be0ea9dba7d9bd5c27d0eb41d59fcc046f75e3) Thanks [@viu-release-bot](https://github.com/apps/viu-release-bot)! - chore(sdk): sync generated types with upstream Emporix API specs
|
|
44
|
+
|
|
45
|
+
Updated services: media
|
|
46
|
+
|
|
3
47
|
## 4.0.0
|
|
4
48
|
|
|
5
49
|
### Major Changes
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { splitQuery, SEARCH_PAGING } from './chunk-ZWJUDXTK.js';
|
|
2
|
+
|
|
1
3
|
// src/services/companies.ts
|
|
2
4
|
var CompaniesService = class {
|
|
3
5
|
constructor(ctx) {
|
|
@@ -57,14 +59,15 @@ var CompaniesService = class {
|
|
|
57
59
|
}
|
|
58
60
|
/**
|
|
59
61
|
* Searches legal entities via `POST /legal-entities/search` with an Emporix
|
|
60
|
-
* `q`-syntax filter body
|
|
62
|
+
* `q`-syntax filter body; paging, sort and fields go in the query string.
|
|
63
|
+
* Requires the same read scope as {@link listMine}.
|
|
61
64
|
*/
|
|
62
65
|
async search(query, auth) {
|
|
63
66
|
return this.ctx.http.request({
|
|
64
67
|
method: "POST",
|
|
65
68
|
path: `${this.base()}/search`,
|
|
66
69
|
auth,
|
|
67
|
-
|
|
70
|
+
...splitQuery(query, SEARCH_PAGING),
|
|
68
71
|
idempotent: true
|
|
69
72
|
// pure read over POST — safe to replay on 5xx/429
|
|
70
73
|
});
|
|
@@ -83,5 +86,5 @@ var CompaniesService = class {
|
|
|
83
86
|
};
|
|
84
87
|
|
|
85
88
|
export { CompaniesService };
|
|
86
|
-
//# sourceMappingURL=chunk-
|
|
87
|
-
//# sourceMappingURL=chunk-
|
|
89
|
+
//# sourceMappingURL=chunk-2OTFVTG6.js.map
|
|
90
|
+
//# sourceMappingURL=chunk-2OTFVTG6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/companies.ts"],"names":[],"mappings":";;;AAoBO,IAAM,mBAAN,MAAuB;AAAA,EAE5B,YAA6B,GAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAAA,EAAqB;AAAA,EAArB,GAA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;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,MAAA,CAAO,aAAA,EAAuB,IAAA,EAAkC;AACpE,IAAA,MAAM,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAc;AAAA,MAChC,MAAA,EAAQ,QAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,aAAa,CAAA,CAAA;AAAA,MACrC;AAAA,KACD,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,MAAA,CAAO,KAAA,EAA+B,IAAA,EAA2C;AACrF,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAuB;AAAA,MAC1C,MAAA,EAAQ,MAAA;AAAA,MACR,IAAA,EAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,CAAA,OAAA,CAAA;AAAA,MACpB,IAAA;AAAA,MACA,GAAG,UAAA,CAAW,KAAA,EAAO,aAAa,CAAA;AAAA,MAClC,UAAA,EAAY;AAAA;AAAA,KACb,CAAA;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,eAAA,CAAgB,aAAA,EAAuB,IAAA,EAA2C;AACtF,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAuB;AAAA,MAC1C,MAAA,EAAQ,KAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,aAAa,CAAA,iBAAA,CAAA;AAAA,MACrC;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"chunk-2OTFVTG6.js","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport { SEARCH_PAGING, splitQuery, type SearchPaging } from \"../core/search\";\nimport type {\n LegalEntity,\n LegalEntityCreate,\n LegalEntityUpdate,\n} from \"../generated/customer-management\";\n\n/** Input for `companies.search`: an Emporix `q`-syntax filter (body) plus {@link SearchPaging} (query). */\nexport type LegalEntitySearchInput = { q?: string } & SearchPaging;\n\n/**\n * Storefront-customer access to Legal Entities.\n *\n * `listMine`/`get` require `customermanagement.legalentity_read_own` on the\n * customer token. `create`/`update`/`delete` require the corresponding\n * `_manage` scopes — typically only granted to Admin-group customers; a 403\n * surfaces as `EmporixInsufficientScopeError`.\n */\nexport class CompaniesService {\n static readonly channel = \"customer-management\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/customer-management/${this.ctx.tenant}/legal-entities`;\n }\n\n /** Lists the legal entities the calling customer is assigned to. */\n async listMine(auth: AuthContext): Promise<LegalEntity[]> {\n return this.ctx.http.request<LegalEntity[]>({\n method: \"GET\",\n path: this.base(),\n auth,\n });\n }\n\n /** Fetches a single legal entity by id. */\n async get(legalEntityId: string, auth: AuthContext): Promise<LegalEntity> {\n return this.ctx.http.request<LegalEntity>({\n method: \"GET\",\n path: `${this.base()}/${legalEntityId}`,\n auth,\n });\n }\n\n /** Creates a legal entity. Requires `customermanagement.legalentity_manage`. */\n async create(input: LegalEntityCreate, auth: AuthContext): Promise<{ id: string }> {\n return this.ctx.http.request<{ id: string }>({\n method: \"POST\",\n path: this.base(),\n auth,\n body: input,\n });\n }\n\n /**\n * Updates a legal entity via `PUT …/legal-entities/{id}` (upsert / full\n * replace). The live API rejects `PATCH` on this path with 405; send the\n * complete entity, as the server replaces the resource. The body stays typed\n * as a partial of `LegalEntityUpdate` for backward compatibility.\n */\n async update(\n legalEntityId: string,\n patch: Partial<LegalEntityUpdate>,\n auth: AuthContext,\n ): Promise<LegalEntity> {\n return this.ctx.http.request<LegalEntity>({\n method: \"PUT\",\n path: `${this.base()}/${legalEntityId}`,\n auth,\n body: patch,\n });\n }\n\n /** Deletes a legal entity (async cascade on the server). */\n async delete(legalEntityId: string, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/${legalEntityId}`,\n auth,\n });\n }\n\n /**\n * Searches legal entities via `POST /legal-entities/search` with an Emporix\n * `q`-syntax filter body; paging, sort and fields go in the query string.\n * Requires the same read scope as {@link listMine}.\n */\n async search(query: LegalEntitySearchInput, auth: AuthContext): Promise<LegalEntity[]> {\n return this.ctx.http.request<LegalEntity[]>({\n method: \"POST\",\n path: `${this.base()}/search`,\n auth,\n ...splitQuery(query, SEARCH_PAGING),\n idempotent: true, // pure read over POST — safe to replay on 5xx/429\n });\n }\n\n /**\n * Retrieves a legal entity's chain of parent entities\n * (`GET /legal-entities/{id}/parent-hierarchy`).\n */\n async parentHierarchy(legalEntityId: string, auth: AuthContext): Promise<LegalEntity[]> {\n return this.ctx.http.request<LegalEntity[]>({\n method: \"GET\",\n path: `${this.base()}/${legalEntityId}/parent-hierarchy`,\n auth,\n });\n }\n}\n"]}
|
|
@@ -15,7 +15,10 @@ var MediaService = class {
|
|
|
15
15
|
base() {
|
|
16
16
|
return `/media/${this.ctx.tenant}/assets`;
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Create an asset. BLOB uploads via multipart (max 30 MB); LINK via JSON.
|
|
20
|
+
* {@link startUploadSession} sends the file straight to storage instead.
|
|
21
|
+
*/
|
|
19
22
|
async create(input, auth = SERVICE) {
|
|
20
23
|
if (input.kind === "blob") {
|
|
21
24
|
const fd = new FormData();
|
|
@@ -73,7 +76,7 @@ var MediaService = class {
|
|
|
73
76
|
* Sends `application/json`. Used for `refIds`, `details`, `metadata`,
|
|
74
77
|
* or `url` changes.
|
|
75
78
|
* - `{ kind: "blob", file, body }` — replaces the BLOB file content
|
|
76
|
-
* (max
|
|
79
|
+
* (max 30 MB) AND patches metadata in the same request. Sends
|
|
77
80
|
* `multipart/form-data`.
|
|
78
81
|
*
|
|
79
82
|
* `type` and `access` are immutable per Emporix — they must match the
|
|
@@ -147,6 +150,12 @@ var MediaService = class {
|
|
|
147
150
|
* an `ArrayBuffer` transparently; binary Content-Types are passed
|
|
148
151
|
* through verbatim.
|
|
149
152
|
*
|
|
153
|
+
* Emporix recommends {@link getDownloadUrl} for every download: here the file
|
|
154
|
+
* passes through the Media API. A `413` means the asset's known size exceeds
|
|
155
|
+
* the streaming limit (30 MB by default) — only {@link getDownloadUrl} can
|
|
156
|
+
* serve it. A `409` means the asset is still `PENDING` from a direct upload
|
|
157
|
+
* whose file has not reached storage.
|
|
158
|
+
*
|
|
150
159
|
* Implementation note: uses `redirect: "manual"` so the redirect-location
|
|
151
160
|
* is observable. In Node.js this works; in a browser the redirect Location
|
|
152
161
|
* is intentionally hidden by fetch — there, `PUBLIC` downloads will
|
|
@@ -202,6 +211,61 @@ var MediaService = class {
|
|
|
202
211
|
}
|
|
203
212
|
throw errorFromResponse(res.status, `GET ${path} \u2192 ${res.status}`, parsed);
|
|
204
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* Get a URL that serves the stored file straight from storage
|
|
216
|
+
* (`GET /assets/{assetId}/download-url`). Emporix recommends it for every
|
|
217
|
+
* download: the file never passes through the Media API, there is no size
|
|
218
|
+
* limit, and the URL can be handed to a browser as it is.
|
|
219
|
+
*
|
|
220
|
+
* - `PRIVATE` BLOB → `provider: "GCS"`, a signed Google Cloud Storage URL that
|
|
221
|
+
* works without an Emporix token until `expiresAt` (15 minutes by default).
|
|
222
|
+
* - `PUBLIC` BLOB → `provider: "CLOUDINARY"`, the permanent URL.
|
|
223
|
+
* - `LINK` → `provider: "LINK"`, the stored URL.
|
|
224
|
+
*
|
|
225
|
+
* `disposition` (`attachment` by default, or `inline`) affects private URLs
|
|
226
|
+
* only. Unlike {@link startUploadSession}, this works whether or not direct
|
|
227
|
+
* upload is enabled for the tenant. A `409` means a direct upload is still
|
|
228
|
+
* `PENDING` and its file has not reached storage; once it has, this call
|
|
229
|
+
* completes the asset before answering.
|
|
230
|
+
*/
|
|
231
|
+
async getDownloadUrl(assetId, query = {}, auth = SERVICE) {
|
|
232
|
+
return this.ctx.http.request({
|
|
233
|
+
method: "GET",
|
|
234
|
+
path: `${this.base()}/${encodeURIComponent(assetId)}/download-url`,
|
|
235
|
+
auth,
|
|
236
|
+
query: { ...query }
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Start a direct upload of a `BLOB` asset (`POST /assets/upload-session`,
|
|
241
|
+
* `201`). Emporix creates the asset as `PENDING` — `id` is its id — and
|
|
242
|
+
* returns where to send the file. **This method does not send it**:
|
|
243
|
+
*
|
|
244
|
+
* - `upload.method === "PUT"` (a `PRIVATE` asset, `uploadType: "put"` or
|
|
245
|
+
* omitted): `PUT` the file to `upload.url` with every `upload.headers` entry.
|
|
246
|
+
* - `upload.method === "POST"` (every `PUBLIC` asset, or `uploadType: "form"`):
|
|
247
|
+
* a multipart `POST` to `upload.url` with every `upload.fields` entry
|
|
248
|
+
* unchanged and the file part last.
|
|
249
|
+
*
|
|
250
|
+
* That request goes to Google Cloud Storage or Cloudinary, not to Emporix, so
|
|
251
|
+
* it must not carry the Emporix token — which is also why a browser can make
|
|
252
|
+
* it. The asset turns `READY` once storage confirms; until then, calls that
|
|
253
|
+
* need the file answer `409`. The instruction is valid for 15 minutes (GCS) or
|
|
254
|
+
* an hour (Cloudinary), and an unused session expires at `expiresAt`.
|
|
255
|
+
*
|
|
256
|
+
* Direct upload is enabled per tenant by Emporix Support. Without it the call
|
|
257
|
+
* throws an `EmporixForbiddenError` whose `body.message` is `direct upload is
|
|
258
|
+
* not enabled for this tenant`, and nothing is created — the same status as a
|
|
259
|
+
* missing scope, so read the message.
|
|
260
|
+
*/
|
|
261
|
+
async startUploadSession(input, auth = SERVICE) {
|
|
262
|
+
return this.ctx.http.request({
|
|
263
|
+
method: "POST",
|
|
264
|
+
path: `${this.base()}/upload-session`,
|
|
265
|
+
auth,
|
|
266
|
+
body: input
|
|
267
|
+
});
|
|
268
|
+
}
|
|
205
269
|
/** Multipart upload sugar: builds `AssetCreateBlob` from input. */
|
|
206
270
|
async uploadFile(input, auth = SERVICE) {
|
|
207
271
|
const body = {
|
|
@@ -274,5 +338,5 @@ var MediaService = class {
|
|
|
274
338
|
var _internalMedia = { isProductRef };
|
|
275
339
|
|
|
276
340
|
export { MediaService, _internalMedia };
|
|
277
|
-
//# sourceMappingURL=chunk-
|
|
278
|
-
//# sourceMappingURL=chunk-
|
|
341
|
+
//# sourceMappingURL=chunk-5MPL4XBD.js.map
|
|
342
|
+
//# sourceMappingURL=chunk-5MPL4XBD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/media.ts"],"names":["text"],"mappings":";;;;AA6EA,IAAM,OAAA,GAAuB,EAAE,IAAA,EAAM,SAAA,EAAU;AAE/C,SAAS,YAAA,CAAa,GAAe,SAAA,EAA4B;AAC/D,EAAA,OAAO,CAAA,CAAE,IAAA,KAAS,SAAA,IAAa,CAAA,CAAE,EAAA,KAAO,SAAA;AAC1C;AAMO,IAAM,eAAN,MAAmB;AAAA,EAExB,YAA6B,GAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAAA,EAAqB;AAAA,EAArB,GAAA;AAAA,EAD7B,OAAgB,OAAA,GAAU,OAAA;AAAA,EAGlB,IAAA,GAAe;AACrB,IAAA,OAAO,CAAA,OAAA,EAAU,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,OAAA,CAAA;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,MAAA,CACJ,KAAA,EAGA,IAAA,GAAoB,OAAA,EACK;AACzB,IAAA,IAAI,KAAA,CAAM,SAAS,MAAA,EAAQ;AACzB,MAAA,MAAM,EAAA,GAAK,IAAI,QAAA,EAAS;AACxB,MAAA,EAAA,CAAG,GAAA,CAAI,MAAA,EAAQ,KAAA,CAAM,IAAI,CAAA;AACzB,MAAA,EAAA,CAAG,IAAI,MAAA,EAAQ,IAAA,CAAK,SAAA,CAAU,KAAA,CAAM,IAAI,CAAC,CAAA;AACzC,MAAA,OA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,CAAC,GAAG,MAAA,EAAQ,EAAE,IAAA,EAAM,SAAA,EAAW,EAAA,EAAI,SAAA,EAAW,CAAA;AAGzE,IAAA,MAAM,QAAQ,EAAE,IAAA,EAAM,CAAA,CAAE,IAAA,EAAM,QAAQ,IAAA,EAAK;AAC3C,IAAA,OAAO,IAAA,CAAK,OAAO,OAAA,EAAS,EAAE,MAAM,MAAA,EAAQ,IAAA,EAAM,KAAA,EAAM,EAAG,IAAI,CAAA;AAAA,EACjE;AAAA;AAAA,EAGA,MAAM,iBAAA,CACJ,OAAA,EACA,SAAA,EACA,OAAoB,OAAA,EACJ;AAChB,IAAA,MAAM,CAAA,GAAI,MAAM,IAAA,CAAK,GAAA,CAAI,SAAS,IAAI,CAAA;AACtC,IAAA,MAAM,MAAA,GAAuB,CAAA,CAAE,MAAA,IAAU,EAAC;AAC1C,IAAA,MAAM,IAAA,GAAO,OAAO,MAAA,CAAO,CAAC,MAAM,CAAC,YAAA,CAAa,CAAA,EAAG,SAAS,CAAC,CAAA;AAC7D,IAAA,IAAI,IAAA,CAAK,MAAA,KAAW,MAAA,CAAO,MAAA,EAAQ,OAAO,CAAA;AAC1C,IAAA,MAAM,QAAQ,EAAE,IAAA,EAAM,CAAA,CAAE,IAAA,EAAM,QAAQ,IAAA,EAAK;AAC3C,IAAA,OAAO,IAAA,CAAK,OAAO,OAAA,EAAS,EAAE,MAAM,MAAA,EAAQ,IAAA,EAAM,KAAA,EAAM,EAAG,IAAI,CAAA;AAAA,EACjE;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":"chunk-5MPL4XBD.js","sourcesContent":["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 PatchOperation,\n RefId,\n UploadSession,\n UploadSessionRequest,\n} from \"../generated/media\";\n\n/** Generated media types (caller sends the exact wire shape). */\nexport type AssetCreateBlobInput = AssetCreateBlob;\nexport type AssetCreateLinkInput = AssetCreateLink;\nexport type AssetUpdateBlobInput = AssetUpdateBlob;\nexport type AssetUpdateLinkInput = AssetUpdateLink;\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 * Update an asset. The input is a discriminated union mirroring\n * {@link create}:\n * - `{ kind: \"json\", body }` — metadata-only patch (BLOB or LINK).\n * Sends `application/json`. Used for `refIds`, `details`, `metadata`,\n * or `url` changes.\n * - `{ kind: \"blob\", file, body }` — replaces the BLOB file content\n * (max 30 MB) AND patches metadata in the same request. Sends\n * `multipart/form-data`.\n *\n * `type` and `access` are immutable per Emporix — they must match the\n * existing asset's values. Optimistic-locking is via `body.metadata.version`;\n * the server returns 409 Conflict on a stale version.\n */\n async update(\n assetId: string,\n input:\n | { kind: \"json\"; body: AssetUpdateInput }\n | { kind: \"blob\"; file: Blob; body: AssetUpdateBlobInput },\n auth: AuthContext = SERVICE,\n ): Promise<Asset> {\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<Asset>({\n method: \"PUT\",\n path: `${this.base()}/${assetId}`,\n auth,\n body: fd,\n });\n }\n return this.ctx.http.request<Asset>({\n method: \"PUT\",\n path: `${this.base()}/${assetId}`,\n auth,\n body: input.body,\n });\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\"`. `access` is required because the\n * field is immutable and the server validates that the patch matches.\n * Pass `version` from `asset.metadata.version` if you want optimistic\n * locking (recommended when concurrent writers are possible).\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<Asset> {\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 ...(input.version !== undefined\n ? { metadata: { version: input.version } }\n : {}),\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 /** Idempotently add a PRODUCT refId to an asset. */\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 next: AssetRefId[] = [...refIds, { type: \"PRODUCT\", id: productId }];\n // Preserve the asset's type discriminator so the update body satisfies\n // the AssetUpdateBlob | AssetUpdateLink union.\n const patch = { type: a.type, refIds: next } as unknown as AssetUpdateInput;\n return this.update(assetId, { kind: \"json\", body: patch }, auth);\n }\n\n /** Remove a PRODUCT refId from an asset (no-op if absent). */\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 const patch = { type: a.type, refIds: next } as unknown as AssetUpdateInput;\n return this.update(assetId, { kind: \"json\", body: patch }, 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"]}
|
|
@@ -60,6 +60,20 @@ var OrdersService = class {
|
|
|
60
60
|
...headers ? { headers } : {}
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* The status transitions the customer may trigger on one of their orders
|
|
65
|
+
* (`GET /orders/{orderId}/transitions`) — for example whether it can still be
|
|
66
|
+
* cancelled, before offering {@link cancel}.
|
|
67
|
+
*/
|
|
68
|
+
async listTransitions(orderId, auth, opts = {}) {
|
|
69
|
+
const headers = this.saasHeader(opts.saasToken);
|
|
70
|
+
return this.ctx.http.request({
|
|
71
|
+
method: "GET",
|
|
72
|
+
path: `${this.base()}/${encodeURIComponent(orderId)}/transitions`,
|
|
73
|
+
auth,
|
|
74
|
+
...headers ? { headers } : {}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
63
77
|
/** Transitions an order to a new status. Server enforces legal transitions. */
|
|
64
78
|
async transition(orderId, status, auth, opts = {}) {
|
|
65
79
|
const body = { status };
|
|
@@ -282,5 +296,5 @@ var SalesOrdersService = class {
|
|
|
282
296
|
};
|
|
283
297
|
|
|
284
298
|
export { OrdersService, SalesOrdersService };
|
|
285
|
-
//# sourceMappingURL=chunk-
|
|
286
|
-
//# sourceMappingURL=chunk-
|
|
299
|
+
//# sourceMappingURL=chunk-IYNT5BQW.js.map
|
|
300
|
+
//# sourceMappingURL=chunk-IYNT5BQW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/orders.ts"],"names":[],"mappings":";;;;AA6GA,SAAS,YAAA,CACP,CAAA,EACA,GAAA,EACA,KAAA,EACM;AACN,EAAA,IAAI,KAAA,KAAU,MAAA,IAAa,KAAA,KAAU,EAAA,EAAI;AACvC,IAAA,CAAA,CAAE,GAAG,CAAA,GAAI,KAAA;AAAA,EACX;AACF;AASO,IAAM,gBAAN,MAAoB;AAAA,EAEzB,YAA6B,GAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAAA,EAAqB;AAAA,EAArB,GAAA;AAAA,EAD7B,OAAgB,OAAA,GAAU,QAAA;AAAA,EAGlB,IAAA,GAAe;AACrB,IAAA,OAAO,CAAA,UAAA,EAAa,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,OAAA,CAAA;AAAA,EACrC;AAAA,EAEQ,WAAW,SAAA,EAAmE;AACpF,IAAA,OAAO,SAAA,GAAY,EAAE,YAAA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O,CAAA,QAAA,CAAA;AAAA,MAC/B,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,KAAA,CAAM,OAAA,EAAiB,KAAA,EAA6B,IAAA,EAAmD;AAC3G,IAAA,OAAO,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAA+B;AAAA,MAClD,MAAA,EAAQ,MAAA;AAAA,MACR,MAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,IAAI,OAAO,CAAA,MAAA,CAAA;AAAA,MAC/B,IAAA;AAAA,MACA,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACF","file":"chunk-IYNT5BQW.js","sourcesContent":["import type { ClientContext, PaginatedItems } from \"../core/context\";\nimport { requestPage } from \"../core/paged\";\nimport type { AuthContext } from \"../core/auth\";\nimport { resolveQuery, type QueryFor } from \"../core/query\";\nimport type {\n Order,\n OrderStatus,\n OrderUpdateDto,\n SalesOrder,\n Transition,\n SalesOrderCreationDto,\n ResourceLocation,\n SearchRequest,\n HistoricalTransitionsResponse,\n OrderCalculationDto,\n OrderEntriesDto,\n OrderSplitRequest,\n OrderSplitResponse,\n} from \"../generated/order-v2\";\n\n/**\n * Salesorder PATCH body. The generated `orderUpdateDto` models a full order\n * (it requires `entries`/`customer`), but `PATCH /salesorders/{id}` accepts a\n * subset — so the SDK exposes a partial of it.\n */\nexport type SalesOrderPatch = Partial<OrderUpdateDto>;\n\n/** Body for creating a sales-order as an employee (`POST /salesorders`). */\nexport type SalesOrderCreateInput = SalesOrderCreationDto;\n\n/** Id/location envelope returned when a sales-order is created. */\nexport type SalesOrderCreated = ResourceLocation;\n\n/** Body for a full sales-order replace (`PUT /salesorders/{id}`). */\nexport type SalesOrderReplaceInput = OrderUpdateDto;\n\n/** Body for `salesOrders.search` (`POST /salesorders/search`). */\nexport type SalesOrderSearchInput = SearchRequest;\n\n/** Response of `salesOrders.listHistoricalTransitions`. */\nexport type SalesOrderHistoricalTransitions = HistoricalTransitionsResponse;\n\n/** Body for `salesOrders.calculate` (`POST /salesorders/{id}/calculations`). */\nexport type SalesOrderCalculationInput = OrderCalculationDto;\n\n/** Body for `salesOrders.updateEntries` (`POST /salesorders/{id}/entries`). */\nexport type SalesOrderEntriesInput = OrderEntriesDto;\n\n/** Body for `salesOrders.split` (`POST /salesorders/{id}/split`). */\nexport type SalesOrderSplitInput = OrderSplitRequest;\n\n/** Response of `salesOrders.split`. */\nexport type SalesOrderSplitResult = OrderSplitResponse;\n\n/** Options for `salesOrders.list`. */\nexport interface ListSalesOrdersOptions {\n pageNumber?: number;\n pageSize?: number;\n sort?: string;\n fields?: string;\n /** A `q` filter — raw DSL string or a built filter for entity \"ORDER\". */\n q?: QueryFor<\"ORDER\">;\n /** Ask for `X-Total-Count` — becomes a request header, not a query parameter. */\n totalCount?: boolean;\n}\n\n/** Options for `orders.listForLegalEntity`. */\nexport interface ListLegalEntityOrdersOptions {\n pageNumber?: number;\n pageSize?: number;\n sort?: string;\n saasToken?: string;\n /** A `q` filter — raw DSL string or a built filter for entity \"ORDER\". */\n q?: QueryFor<\"ORDER\">;\n /** Ask for `X-Total-Count` — becomes a request header, not a query parameter. */\n totalCount?: boolean;\n}\n\n/** Optional fields supported by the order-v2 list endpoint. */\nexport interface ListMyOrdersOptions {\n pageNumber?: number;\n pageSize?: number;\n status?: OrderStatus;\n legalEntityId?: string;\n siteCode?: string;\n saasToken?: string;\n /** A `q` filter — raw DSL string or a built filter (e.g. mixinQuery for entity \"ORDER\"). */\n q?: QueryFor<\"ORDER\">;\n /** Ask for `X-Total-Count` — becomes a request header, not a query parameter. */\n totalCount?: boolean;\n}\n\n/** Options for single-order reads (saas-token only). */\nexport interface GetOrderOptions {\n saasToken?: string;\n}\n\n/** Options for status transitions. */\nexport interface OrderTransitionOptions {\n saasToken?: string;\n comment?: string;\n}\n\n/** Options for `salesOrders.update`. */\nexport interface UpdateSalesOrderOptions {\n /** Forwarded as `?recalculate=`. Omit to use the server default (true). */\n recalculate?: boolean;\n}\n\nfunction setIfDefined<V>(\n q: Record<string, string | number | undefined>,\n key: string,\n value: V | undefined,\n): void {\n if (value !== undefined && value !== \"\") {\n q[key] = value as unknown as string | number;\n }\n}\n\n/**\n * Storefront-customer access to Order-v2's customer endpoints.\n *\n * `listMine`/`get` require `order.order_read_own`; transitions require\n * `order.order_manage_own`. All methods accept an optional `saasToken` that\n * is passed as the `saas-token` header (mirrors `checkout.placeOrder`).\n */\nexport class OrdersService {\n static readonly channel = \"orders\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/order-v2/${this.ctx.tenant}/orders`;\n }\n\n private saasHeader(saasToken: string | undefined): Record<string, string> | undefined {\n return saasToken ? { \"saas-token\": saasToken } : undefined;\n }\n\n /** Lists the calling customer's orders. */\n async listMine(\n auth: AuthContext,\n opts: ListMyOrdersOptions = {},\n ): Promise<PaginatedItems<Order>> {\n const pageNumber = opts.pageNumber ?? 1;\n const pageSize = opts.pageSize ?? 50;\n const query: Record<string, string | number | undefined> = {\n pageNumber,\n pageSize,\n };\n setIfDefined(query, \"status\", opts.status);\n setIfDefined(query, \"legalEntityId\", opts.legalEntityId);\n setIfDefined(query, \"siteCode\", opts.siteCode);\n if (opts.q !== undefined) {\n setIfDefined(query, \"q\", resolveQuery(opts.q, { compoundLogicalQuery: false }));\n }\n const headers = this.saasHeader(opts.saasToken);\n // order-v2 returns a bare JSON array, not a {items,...} envelope — the total\n // lives in the X-Total-Count header, which `requestPage` reads when the\n // caller opts in with `totalCount: true`.\n return requestPage<Order>(\n this.ctx.http,\n {\n method: \"GET\",\n path: this.base(),\n query,\n auth,\n ...(headers ? { headers } : {}),\n },\n {\n pageNumber,\n pageSize,\n ...(opts.totalCount === undefined ? {} : { totalCount: opts.totalCount }),\n },\n );\n }\n\n /** Fetches one of the calling customer's orders by id. */\n async get(\n orderId: string,\n auth: AuthContext,\n opts: GetOrderOptions = {},\n ): Promise<Order> {\n const headers = this.saasHeader(opts.saasToken);\n return this.ctx.http.request<Order>({\n method: \"GET\",\n path: `${this.base()}/${orderId}`,\n auth,\n ...(headers ? { headers } : {}),\n });\n }\n\n /**\n * The status transitions the customer may trigger on one of their orders\n * (`GET /orders/{orderId}/transitions`) — for example whether it can still be\n * cancelled, before offering {@link cancel}.\n */\n async listTransitions(\n orderId: string,\n auth: AuthContext,\n opts: GetOrderOptions = {},\n ): Promise<Transition[]> {\n const headers = this.saasHeader(opts.saasToken);\n return this.ctx.http.request<Transition[]>({\n method: \"GET\",\n path: `${this.base()}/${encodeURIComponent(orderId)}/transitions`,\n auth,\n ...(headers ? { headers } : {}),\n });\n }\n\n /** Transitions an order to a new status. Server enforces legal transitions. */\n async transition(\n orderId: string,\n status: OrderStatus,\n auth: AuthContext,\n opts: OrderTransitionOptions = {},\n ): Promise<void> {\n const body: { status: OrderStatus; comment?: string } = { status };\n if (opts.comment !== undefined) body.comment = opts.comment;\n const headers = this.saasHeader(opts.saasToken);\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `${this.base()}/${orderId}/transitions`,\n auth,\n body,\n ...(headers ? { headers } : {}),\n });\n }\n\n /** Convenience: transitions to `DECLINED` (customer cancel). */\n async cancel(\n orderId: string,\n auth: AuthContext,\n opts: { saasToken?: string } = {},\n ): Promise<void> {\n await this.transition(orderId, \"DECLINED\", auth, opts);\n }\n\n /**\n * Lists a legal entity's orders (`GET /legal-entity-orders/{legalEntityId}`),\n * wrapped into `PaginatedItems`. B2B storefront view — requires a customer\n * token with access to the legal entity.\n */\n async listForLegalEntity(\n legalEntityId: string,\n auth: AuthContext,\n opts: ListLegalEntityOrdersOptions = {},\n ): Promise<PaginatedItems<SalesOrder>> {\n const pageNumber = opts.pageNumber ?? 1;\n const pageSize = opts.pageSize ?? 50;\n const query: Record<string, string | number | undefined> = { pageNumber, pageSize };\n setIfDefined(query, \"sort\", opts.sort);\n if (opts.q !== undefined) {\n setIfDefined(query, \"q\", resolveQuery(opts.q, { compoundLogicalQuery: false }));\n }\n const headers = this.saasHeader(opts.saasToken);\n return requestPage<SalesOrder>(\n this.ctx.http,\n {\n method: \"GET\",\n path: `/order-v2/${this.ctx.tenant}/legal-entity-orders/${legalEntityId}`,\n query,\n auth,\n ...(headers ? { headers } : {}),\n },\n {\n pageNumber,\n pageSize,\n ...(opts.totalCount === undefined ? {} : { totalCount: opts.totalCount }),\n },\n );\n }\n\n /**\n * Fetches one order within a legal entity\n * (`GET /legal-entity-orders/{legalEntityId}/{orderId}`).\n */\n async getForLegalEntity(\n legalEntityId: string,\n orderId: string,\n auth: AuthContext,\n opts: { saasToken?: string } = {},\n ): Promise<SalesOrder> {\n const headers = this.saasHeader(opts.saasToken);\n return this.ctx.http.request<SalesOrder>({\n method: \"GET\",\n path: `/order-v2/${this.ctx.tenant}/legal-entity-orders/${legalEntityId}/${orderId}`,\n auth,\n ...(headers ? { headers } : {}),\n });\n }\n}\n\n/**\n * Backend / service-account access to the merchant-facing\n * `/salesorders/{id}` resource. Requires `order.order_read` (read) /\n * `order.order_manage` (update) scopes on a service token.\n *\n * The full admin list + filter surface is deferred to a follow-up\n * sub-spec. This service ships only single-resource read + patch — the\n * common backend use case (e.g. mixin updates after fulfilment).\n */\nexport class SalesOrdersService {\n static readonly channel = \"sales-orders\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/order-v2/${this.ctx.tenant}/salesorders`;\n }\n\n /** Fetches a single sales-order by id. */\n async get(orderId: string, auth: AuthContext): Promise<Order> {\n return this.ctx.http.request<Order>({\n method: \"GET\",\n path: `${this.base()}/${orderId}`,\n auth,\n });\n }\n\n /** 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,3 +1,4 @@
|
|
|
1
|
+
import { splitQuery } from './chunk-ZWJUDXTK.js';
|
|
1
2
|
import { EmporixAuthError } from './chunk-UWGGF4MC.js';
|
|
2
3
|
|
|
3
4
|
// src/services/price.ts
|
|
@@ -145,13 +146,16 @@ var PriceService = class {
|
|
|
145
146
|
auth: authCtx
|
|
146
147
|
});
|
|
147
148
|
}
|
|
148
|
-
/**
|
|
149
|
+
/**
|
|
150
|
+
* Searches flat prices: the criteria go in the body, `expand` in the query
|
|
151
|
+
* string. Default auth: service.
|
|
152
|
+
*/
|
|
149
153
|
async search(query, authCtx = SERVICE) {
|
|
150
154
|
return this.ctx.http.request({
|
|
151
155
|
method: "POST",
|
|
152
156
|
path: `/price/${this.ctx.tenant}/prices/search`,
|
|
153
157
|
auth: authCtx,
|
|
154
|
-
|
|
158
|
+
...splitQuery(query, ["expand"])
|
|
155
159
|
});
|
|
156
160
|
}
|
|
157
161
|
/** Creates multiple flat prices in one request. Default auth: service. */
|
|
@@ -219,11 +223,12 @@ var PriceService = class {
|
|
|
219
223
|
auth: authCtx,
|
|
220
224
|
body: input
|
|
221
225
|
}),
|
|
226
|
+
/** `q` in the body; `pageNumber`, `pageSize` and `sort` in the query string. */
|
|
222
227
|
search: async (query, authCtx = SERVICE) => this.ctx.http.request({
|
|
223
228
|
method: "POST",
|
|
224
229
|
path: `/price/${this.ctx.tenant}/price-lists/search`,
|
|
225
230
|
auth: authCtx,
|
|
226
|
-
|
|
231
|
+
...splitQuery(query, ["pageNumber", "pageSize", "sort"])
|
|
227
232
|
}),
|
|
228
233
|
get: async (listId, authCtx = SERVICE) => this.ctx.http.request({
|
|
229
234
|
method: "GET",
|
|
@@ -273,11 +278,12 @@ var PriceService = class {
|
|
|
273
278
|
auth: authCtx
|
|
274
279
|
});
|
|
275
280
|
},
|
|
281
|
+
/** `q` in the body; `pageNumber`, `pageSize` and `sort` in the query string. */
|
|
276
282
|
searchPrices: async (listId, query, authCtx = SERVICE) => this.ctx.http.request({
|
|
277
283
|
method: "POST",
|
|
278
284
|
path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/search`,
|
|
279
285
|
auth: authCtx,
|
|
280
|
-
|
|
286
|
+
...splitQuery(query, ["pageNumber", "pageSize", "sort"])
|
|
281
287
|
}),
|
|
282
288
|
bulkCreatePrices: async (listId, inputs, authCtx = SERVICE) => this.ctx.http.request({
|
|
283
289
|
method: "POST",
|
|
@@ -301,5 +307,5 @@ var PriceService = class {
|
|
|
301
307
|
};
|
|
302
308
|
|
|
303
309
|
export { PriceService };
|
|
304
|
-
//# sourceMappingURL=chunk-
|
|
305
|
-
//# sourceMappingURL=chunk-
|
|
310
|
+
//# sourceMappingURL=chunk-K4KXT6NX.js.map
|
|
311
|
+
//# sourceMappingURL=chunk-K4KXT6NX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/price.ts"],"names":[],"mappings":";;;;AAuDA,SAAS,eAAe,GAAA,EAAgC;AACtD,EAAA,MAAM,MAAA,GAAU,GAAA,CAAuD,MAAA,IAAU,GAAA,CAAI,OAAA;AACrF,EAAA,MAAM,IAAA,GAAO,GAAA;AACb,EAAA,IAAI,CAAC,QAAQ,OAAO,IAAA;AAGpB,EAAA,MAAM,OAAA,GAA6B;AAAA,IACjC,GAAI,OAAO,QAAA,KAAa,MAAA,GAAY,EAAE,QAAA,EAAU,MAAA,CAAO,QAAA,EAAS,GAAI,EAAC;AAAA,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,EACA,UAAuB,OAAA,KAEvB,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAA2B;AAAA,MACvC,MAAA,EAAQ,QAAA;AAAA,MACR,MAAM,CAAA,OAAA,EAAU,IAAA,CAAK,GAAA,CAAI,MAAM,gBAAgB,MAAM,CAAA,YAAA,CAAA;AAAA,MACrD,IAAA,EAAM,OAAA;AAAA,MACN;AAAA,KACD;AAAA,GACL;AACF","file":"chunk-K4KXT6NX.js","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport { EmporixAuthError } from \"../core/errors\";\nimport { splitQuery, type SearchPaging } from \"../core/search\";\nimport type {\n Match,\n MatchByContext,\n MatchResponse,\n CreatePrice,\n GetPrice,\n PriceModelDefinitionCreation,\n PriceModelRetrieval,\n PriceListCreation,\n PriceListUpdate,\n PriceList as GenPriceList,\n PriceListPriceCreation,\n PriceListPriceUpdate,\n PriceListPrice as GenPriceListPrice,\n PriceBulkResponseEntry,\n} from \"../generated/price\";\n\n/** Session-context match request body (generated). */\nexport type PriceMatchByContextInput = MatchByContext;\n\n/** Explicit-context match request body (generated). */\nexport type PriceMatchInput = Match;\n\n/** Item (product or price) a price was matched for. */\nexport interface PriceMatchItemRef {\n itemType?: string;\n id?: string;\n /** Localized (or plain) product name — present on the live API, absent from the OpenAPI doc. */\n name?: Record<string, string> | string;\n}\n\n/**\n * A resolved price. Superset of the generated match-response schema: the\n * deployed API returns the matched item under `itemId` (with a localized\n * `name`), while the OpenAPI doc/codegen call it `itemRef`.\n */\nexport type PriceMatch = Omit<MatchResponse, \"itemRef\"> & {\n /** Item the price was matched for, as returned by the API. */\n itemId?: PriceMatchItemRef;\n /**\n * @deprecated The OpenAPI doc names this `itemRef`, but the deployed API\n * returns `itemId`. Mirrored from `itemId` for back-compat — prefer `itemId`.\n */\n itemRef?: PriceMatchItemRef;\n};\n\n/**\n * Normalizes a raw match row: the deployed API returns `itemId`, while the\n * codegen type calls it `itemRef`. Expose `itemId` canonically and mirror it\n * to the deprecated `itemRef` so existing consumers keep working.\n */\nfunction normalizeMatch(raw: MatchResponse): PriceMatch {\n const itemId = (raw as MatchResponse & { itemId?: PriceMatchItemRef }).itemId ?? raw.itemRef;\n const base = raw as PriceMatch;\n if (!itemId) return base;\n // Mirror only id/type into the deprecated itemRef (drop name); build without\n // explicit `undefined` for exactOptionalPropertyTypes.\n const itemRef: PriceMatchItemRef = {\n ...(itemId.itemType !== undefined ? { itemType: itemId.itemType } : {}),\n ...(itemId.id !== undefined ? { id: itemId.id } : {}),\n };\n return { ...base, itemId, itemRef };\n}\n\n/** Options for {@link PriceService.matchByContextChunked}. */\nexport interface MatchByContextChunkedOptions {\n /** Items per request. Default 50. Must be >= 1. */\n chunkSize?: number;\n /** Maximum number of requests in flight at once. Default 4. Must be >= 1. */\n concurrency?: number;\n /** Invoked once per failed chunk (default mode only — not when throwing). */\n onChunkError?: (err: unknown, chunkIndex: number) => void;\n /** When true, the first failing chunk rejects the whole call. Default false. */\n throwOnAnyChunkError?: boolean;\n}\n\n/** A resolved/stored price (generated read shape). */\nexport type Price = GetPrice;\n/** Create/upsert body for a flat price (generated). */\nexport type PriceCreateInput = CreatePrice;\n/** A price model (read). */\nexport type PriceModel = PriceModelRetrieval;\n/** Create/upsert body for a price model (generated). */\nexport type PriceModelInput = PriceModelDefinitionCreation;\n/** A price list (read). */\nexport type PriceList = GenPriceList;\n/** Create body for a price list (generated). */\nexport type PriceListInput = PriceListCreation;\n/** Upsert body for a price list (generated). */\nexport type PriceListUpdateInput = PriceListUpdate;\n/** A price inside a price list (read). */\nexport type PriceListPrice = GenPriceListPrice;\n/** Add body for a price-list price (generated). */\nexport type PriceListPriceInput = PriceListPriceCreation;\n/** Upsert body for a price-list price (generated). */\nexport type PriceListPriceUpdateInput = PriceListPriceUpdate;\n/** Per-entry result of a bulk price operation (generated). */\nexport type PriceBulkResult = PriceBulkResponseEntry;\n\nconst ANON: AuthContext = { kind: \"anonymous\" };\nconst SERVICE: AuthContext = { kind: \"service\" };\n\nfunction requireContextAuth(auth: AuthContext | undefined): AuthContext {\n const a = auth ?? ANON;\n if (a.kind === \"anonymous\" || a.kind === \"customer\" || a.kind === \"raw\") return a;\n throw new EmporixAuthError(\n \"match-prices-by-context requires an anonymous, customer, or raw AuthContext\",\n );\n}\n\n/**\n * Price matching. The Cart service does not resolve prices — call this\n * explicitly before rendering money and again right before placing an order.\n * The SDK is stateless: it never caches or revalidates prices.\n */\nexport class PriceService {\n static readonly channel = \"price\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n /**\n * Resolves prices using the session context bound to the bearer token\n * (currency/site/country were set at anonymous-login time). Default auth:\n * anonymous; pass a customer/raw context for personalized pricing.\n */\n async matchByContext(\n input: PriceMatchByContextInput,\n auth?: AuthContext,\n ): Promise<PriceMatch[]> {\n const rows = await this.ctx.http.request<MatchResponse[]>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/match-prices-by-context`,\n auth: requireContextAuth(auth),\n body: input,\n idempotent: true, // pure read over POST — safe to replay on 5xx/429\n });\n return rows.map(normalizeMatch);\n }\n\n /**\n * Resolves prices from an explicit context. Default auth: service\n * (requires `price.price_read` / `price.price_manage`).\n */\n async match(input: PriceMatchInput, auth: AuthContext = SERVICE): Promise<PriceMatch[]> {\n const rows = await this.ctx.http.request<MatchResponse[]>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/match-prices`,\n auth,\n body: input,\n idempotent: true, // pure read over POST — safe to replay on 5xx/429\n });\n return rows.map(normalizeMatch);\n }\n\n /**\n * Chunked variant of {@link matchByContext} for large `items` arrays. The\n * Emporix backend handles only a limited number of items per request\n * (production limit ~50), so this splits `input.items` into chunks and runs\n * `matchByContext` with bounded concurrency.\n *\n * By default a failing chunk is skipped (its items are absent from the\n * result) and `opts.onChunkError` is called once for it; pass\n * `throwOnAnyChunkError: true` to reject on the first failure instead.\n *\n * **Result order is not guaranteed** — match entries back to your items by\n * `priceId` / `itemId.id`.\n */\n async matchByContextChunked(\n input: PriceMatchByContextInput,\n opts: MatchByContextChunkedOptions = {},\n auth?: AuthContext,\n ): Promise<PriceMatch[]> {\n const chunkSize = opts.chunkSize ?? 50;\n const concurrency = opts.concurrency ?? 4;\n if (chunkSize < 1) throw new Error(\"chunkSize must be >= 1\");\n if (concurrency < 1) throw new Error(\"concurrency must be >= 1\");\n\n const items = input.items ?? [];\n if (items.length === 0) return [];\n\n const chunks: PriceMatchByContextInput[] = [];\n for (let i = 0; i < items.length; i += chunkSize) {\n chunks.push({ ...input, items: items.slice(i, i + chunkSize) });\n }\n\n const results: PriceMatch[][] = new Array(chunks.length);\n let cursor = 0;\n\n const worker = async (): Promise<void> => {\n for (;;) {\n const idx = cursor++;\n const chunk = chunks[idx];\n if (chunk === undefined) return; // past the end\n try {\n results[idx] = await this.matchByContext(chunk, auth);\n } catch (err) {\n if (opts.throwOnAnyChunkError) throw err;\n results[idx] = [];\n opts.onChunkError?.(err, idx);\n }\n }\n };\n\n const workerCount = Math.min(concurrency, chunks.length);\n await Promise.all(Array.from({ length: workerCount }, () => worker()));\n\n return results.flat();\n }\n\n // --- Admin CRUD (flat prices). Default auth: service. ---\n\n /** Creates a flat price. Default auth: service. */\n async create(input: PriceCreateInput, authCtx: AuthContext = SERVICE): Promise<Price> {\n return this.ctx.http.request<Price>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/prices`,\n auth: authCtx,\n body: input,\n });\n }\n\n /** Lists flat prices. Default auth: service. */\n async list(\n query?: Record<string, string | number>,\n authCtx: AuthContext = SERVICE,\n ): Promise<Price[]> {\n return this.ctx.http.request<Price[]>({\n method: \"GET\",\n path: `/price/${this.ctx.tenant}/prices`,\n auth: authCtx,\n ...(query ? { query } : {}),\n });\n }\n\n /** Retrieves one flat price by id. Default auth: service. */\n async get(priceId: string, authCtx: AuthContext = SERVICE): Promise<Price> {\n return this.ctx.http.request<Price>({\n method: \"GET\",\n path: `/price/${this.ctx.tenant}/prices/${priceId}`,\n auth: authCtx,\n });\n }\n\n /** Upserts a flat price by id (PUT). Default auth: service. */\n async upsert(priceId: string, input: PriceCreateInput, authCtx: AuthContext = SERVICE): Promise<Price> {\n return this.ctx.http.request<Price>({\n method: \"PUT\",\n path: `/price/${this.ctx.tenant}/prices/${priceId}`,\n auth: authCtx,\n body: input,\n });\n }\n\n /** Deletes a flat price by id. Default auth: service. */\n async delete(priceId: string, authCtx: AuthContext = SERVICE): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/price/${this.ctx.tenant}/prices/${priceId}`,\n auth: authCtx,\n });\n }\n\n /**\n * Searches flat prices: the criteria go in the body, `expand` in the query\n * string. Default auth: service.\n */\n async search(query: Record<string, unknown> & { expand?: string }, authCtx: AuthContext = SERVICE): Promise<Price[]> {\n return this.ctx.http.request<Price[]>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/prices/search`,\n auth: authCtx,\n ...splitQuery(query, [\"expand\"]),\n });\n }\n\n /** Creates multiple flat prices in one request. Default auth: service. */\n async bulkCreate(inputs: PriceCreateInput[], authCtx: AuthContext = SERVICE): Promise<PriceBulkResult[]> {\n return this.ctx.http.request<PriceBulkResult[]>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/prices/bulk`,\n auth: authCtx,\n body: inputs,\n });\n }\n\n /** Upserts multiple flat prices in one request (PUT). Default auth: service. */\n async bulkUpsert(inputs: PriceCreateInput[], authCtx: AuthContext = SERVICE): Promise<PriceBulkResult[]> {\n return this.ctx.http.request<PriceBulkResult[]>({\n method: \"PUT\",\n path: `/price/${this.ctx.tenant}/prices/bulk`,\n auth: authCtx,\n body: inputs,\n });\n }\n\n /** Price-model admin CRUD (`/priceModels`). Default auth: service. */\n readonly models = {\n list: async (\n query?: Record<string, string | number>,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceModel[]> =>\n this.ctx.http.request<PriceModel[]>({\n method: \"GET\",\n path: `/price/${this.ctx.tenant}/priceModels`,\n auth: authCtx,\n ...(query ? { query } : {}),\n }),\n create: async (input: PriceModelInput, authCtx: AuthContext = SERVICE): Promise<PriceModel> =>\n this.ctx.http.request<PriceModel>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/priceModels`,\n auth: authCtx,\n body: input,\n }),\n get: async (modelId: string, authCtx: AuthContext = SERVICE): Promise<PriceModel> =>\n this.ctx.http.request<PriceModel>({\n method: \"GET\",\n path: `/price/${this.ctx.tenant}/priceModels/${modelId}`,\n auth: authCtx,\n }),\n upsert: async (\n modelId: string,\n input: PriceModelInput,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceModel> =>\n this.ctx.http.request<PriceModel>({\n method: \"PUT\",\n path: `/price/${this.ctx.tenant}/priceModels/${modelId}`,\n auth: authCtx,\n body: input,\n }),\n delete: async (modelId: string, authCtx: AuthContext = SERVICE): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/price/${this.ctx.tenant}/priceModels/${modelId}`,\n auth: authCtx,\n });\n },\n };\n\n /** Price-list admin CRUD (`/price-lists`) + nested price management. Default auth: service. */\n readonly lists = {\n list: async (\n query?: Record<string, string | number>,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceList[]> =>\n this.ctx.http.request<PriceList[]>({\n method: \"GET\",\n path: `/price/${this.ctx.tenant}/price-lists`,\n auth: authCtx,\n ...(query ? { query } : {}),\n }),\n create: async (input: PriceListInput, authCtx: AuthContext = SERVICE): Promise<PriceList> =>\n this.ctx.http.request<PriceList>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/price-lists`,\n auth: authCtx,\n body: input,\n }),\n /** `q` in the body; `pageNumber`, `pageSize` and `sort` in the query string. */\n search: async (\n query: Record<string, unknown> & Omit<SearchPaging, \"fields\">,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceList[]> =>\n this.ctx.http.request<PriceList[]>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/price-lists/search`,\n auth: authCtx,\n ...splitQuery(query, [\"pageNumber\", \"pageSize\", \"sort\"]),\n }),\n get: async (listId: string, authCtx: AuthContext = SERVICE): Promise<PriceList> =>\n this.ctx.http.request<PriceList>({\n method: \"GET\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}`,\n auth: authCtx,\n }),\n upsert: async (\n listId: string,\n input: PriceListUpdateInput,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceList> =>\n this.ctx.http.request<PriceList>({\n method: \"PUT\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}`,\n auth: authCtx,\n body: input,\n }),\n delete: async (listId: string, authCtx: AuthContext = SERVICE): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}`,\n auth: authCtx,\n });\n },\n listPrices: async (\n listId: string,\n query?: Record<string, string | number>,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceListPrice[]> =>\n this.ctx.http.request<PriceListPrice[]>({\n method: \"GET\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices`,\n auth: authCtx,\n ...(query ? { query } : {}),\n }),\n addPrice: async (\n listId: string,\n input: PriceListPriceInput,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceListPrice> =>\n this.ctx.http.request<PriceListPrice>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices`,\n auth: authCtx,\n body: input,\n }),\n getPrice: async (\n listId: string,\n priceId: string,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceListPrice> =>\n this.ctx.http.request<PriceListPrice>({\n method: \"GET\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/${priceId}`,\n auth: authCtx,\n }),\n upsertPrice: async (\n listId: string,\n priceId: string,\n input: PriceListPriceUpdateInput,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceListPrice> =>\n this.ctx.http.request<PriceListPrice>({\n method: \"PUT\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/${priceId}`,\n auth: authCtx,\n body: input,\n }),\n deletePrice: async (\n listId: string,\n priceId: string,\n authCtx: AuthContext = SERVICE,\n ): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/${priceId}`,\n auth: authCtx,\n });\n },\n /** `q` in the body; `pageNumber`, `pageSize` and `sort` in the query string. */\n searchPrices: async (\n listId: string,\n query: Record<string, unknown> & Omit<SearchPaging, \"fields\">,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceListPrice[]> =>\n this.ctx.http.request<PriceListPrice[]>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/search`,\n auth: authCtx,\n ...splitQuery(query, [\"pageNumber\", \"pageSize\", \"sort\"]),\n }),\n bulkCreatePrices: async (\n listId: string,\n inputs: PriceListPriceInput[],\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceBulkResult[]> =>\n this.ctx.http.request<PriceBulkResult[]>({\n method: \"POST\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/bulk`,\n auth: authCtx,\n body: inputs,\n }),\n bulkUpsertPrices: async (\n listId: string,\n inputs: PriceListPriceInput[],\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceBulkResult[]> =>\n this.ctx.http.request<PriceBulkResult[]>({\n method: \"PUT\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/bulk`,\n auth: authCtx,\n body: inputs,\n }),\n bulkDeletePrices: async (\n listId: string,\n body: Record<string, unknown>,\n authCtx: AuthContext = SERVICE,\n ): Promise<PriceBulkResult[]> =>\n this.ctx.http.request<PriceBulkResult[]>({\n method: \"DELETE\",\n path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/bulk`,\n auth: authCtx,\n body,\n }),\n };\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { splitQuery, SEARCH_PAGING } from './chunk-ZWJUDXTK.js';
|
|
1
2
|
import { requireCustomer } from './chunk-3BDDYX3V.js';
|
|
2
3
|
|
|
3
4
|
// src/services/segment.ts
|
|
@@ -174,13 +175,17 @@ var SegmentService = class {
|
|
|
174
175
|
async create(input, authCtx = SERVICE) {
|
|
175
176
|
return this.ctx.http.request({ method: "POST", path: this.base(), auth: authCtx, body: input });
|
|
176
177
|
}
|
|
177
|
-
/**
|
|
178
|
+
/**
|
|
179
|
+
* Searches segments: `q` in the body; paging, sort, fields, `legalEntityId`
|
|
180
|
+
* and `customerId` in the query string. `customerId` returns that customer's
|
|
181
|
+
* segments and needs `customersegment.segment_read`. Default auth: service.
|
|
182
|
+
*/
|
|
178
183
|
async search(query, authCtx = SERVICE) {
|
|
179
184
|
return this.ctx.http.request({
|
|
180
185
|
method: "POST",
|
|
181
186
|
path: `${this.base()}/search`,
|
|
182
187
|
auth: authCtx,
|
|
183
|
-
|
|
188
|
+
...splitQuery(query, [...SEARCH_PAGING, "legalEntityId", "customerId"])
|
|
184
189
|
});
|
|
185
190
|
}
|
|
186
191
|
/** Full-replaces a segment (PUT). Default auth: service. */
|
|
@@ -257,7 +262,7 @@ var SegmentService = class {
|
|
|
257
262
|
method: "POST",
|
|
258
263
|
path: `${this.base()}/${segmentId}/customers/search`,
|
|
259
264
|
auth: authCtx,
|
|
260
|
-
|
|
265
|
+
...splitQuery(query, SEARCH_PAGING)
|
|
261
266
|
}),
|
|
262
267
|
get: async (segmentId, customerId, authCtx = SERVICE) => this.ctx.http.request({
|
|
263
268
|
method: "GET",
|
|
@@ -332,7 +337,7 @@ var SegmentService = class {
|
|
|
332
337
|
method: "POST",
|
|
333
338
|
path: `${this.base()}/${encodeURIComponent(segmentId)}/groups/search`,
|
|
334
339
|
auth: authCtx,
|
|
335
|
-
|
|
340
|
+
...splitQuery(query, SEARCH_PAGING)
|
|
336
341
|
}),
|
|
337
342
|
get: async (segmentId, groupId, authCtx = SERVICE) => this.ctx.http.request({
|
|
338
343
|
method: "GET",
|
|
@@ -366,7 +371,7 @@ var SegmentService = class {
|
|
|
366
371
|
method: "POST",
|
|
367
372
|
path: `${this.base()}/${segmentId}/items/search`,
|
|
368
373
|
auth: authCtx,
|
|
369
|
-
|
|
374
|
+
...splitQuery(query, [...SEARCH_PAGING, "legalEntityId"])
|
|
370
375
|
}),
|
|
371
376
|
get: async (segmentId, type, itemId, authCtx = SERVICE) => this.ctx.http.request({
|
|
372
377
|
method: "GET",
|
|
@@ -402,5 +407,5 @@ var SegmentService = class {
|
|
|
402
407
|
};
|
|
403
408
|
|
|
404
409
|
export { SegmentService };
|
|
405
|
-
//# sourceMappingURL=chunk-
|
|
406
|
-
//# sourceMappingURL=chunk-
|
|
410
|
+
//# sourceMappingURL=chunk-N2CE3J4M.js.map
|
|
411
|
+
//# sourceMappingURL=chunk-N2CE3J4M.js.map
|