@viu/emporix-sdk 4.0.1 → 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 +36 -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 +184 -5
- package/dist/media.d.ts +184 -5
- 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/dist/index.cjs
CHANGED
|
@@ -1242,7 +1242,7 @@ var HttpClient = class {
|
|
|
1242
1242
|
};
|
|
1243
1243
|
|
|
1244
1244
|
// package.json
|
|
1245
|
-
var version = "4.0
|
|
1245
|
+
var version = "4.1.0";
|
|
1246
1246
|
|
|
1247
1247
|
// src/version.ts
|
|
1248
1248
|
var SDK_VERSION = version;
|
|
@@ -3075,6 +3075,18 @@ var PaymentGatewayService = class {
|
|
|
3075
3075
|
};
|
|
3076
3076
|
};
|
|
3077
3077
|
|
|
3078
|
+
// src/core/search.ts
|
|
3079
|
+
var SEARCH_PAGING = ["pageNumber", "pageSize", "sort", "fields"];
|
|
3080
|
+
function splitQuery(input, queryKeys) {
|
|
3081
|
+
const body = {};
|
|
3082
|
+
const query = {};
|
|
3083
|
+
for (const [key, value] of Object.entries(input)) {
|
|
3084
|
+
if (queryKeys.includes(key)) query[key] = value;
|
|
3085
|
+
else body[key] = value;
|
|
3086
|
+
}
|
|
3087
|
+
return { body, query };
|
|
3088
|
+
}
|
|
3089
|
+
|
|
3078
3090
|
// src/services/price.ts
|
|
3079
3091
|
function normalizeMatch(raw) {
|
|
3080
3092
|
const itemId = raw.itemId ?? raw.itemRef;
|
|
@@ -3220,13 +3232,16 @@ var PriceService = class {
|
|
|
3220
3232
|
auth: authCtx
|
|
3221
3233
|
});
|
|
3222
3234
|
}
|
|
3223
|
-
/**
|
|
3235
|
+
/**
|
|
3236
|
+
* Searches flat prices: the criteria go in the body, `expand` in the query
|
|
3237
|
+
* string. Default auth: service.
|
|
3238
|
+
*/
|
|
3224
3239
|
async search(query, authCtx = SERVICE4) {
|
|
3225
3240
|
return this.ctx.http.request({
|
|
3226
3241
|
method: "POST",
|
|
3227
3242
|
path: `/price/${this.ctx.tenant}/prices/search`,
|
|
3228
3243
|
auth: authCtx,
|
|
3229
|
-
|
|
3244
|
+
...splitQuery(query, ["expand"])
|
|
3230
3245
|
});
|
|
3231
3246
|
}
|
|
3232
3247
|
/** Creates multiple flat prices in one request. Default auth: service. */
|
|
@@ -3294,11 +3309,12 @@ var PriceService = class {
|
|
|
3294
3309
|
auth: authCtx,
|
|
3295
3310
|
body: input
|
|
3296
3311
|
}),
|
|
3312
|
+
/** `q` in the body; `pageNumber`, `pageSize` and `sort` in the query string. */
|
|
3297
3313
|
search: async (query, authCtx = SERVICE4) => this.ctx.http.request({
|
|
3298
3314
|
method: "POST",
|
|
3299
3315
|
path: `/price/${this.ctx.tenant}/price-lists/search`,
|
|
3300
3316
|
auth: authCtx,
|
|
3301
|
-
|
|
3317
|
+
...splitQuery(query, ["pageNumber", "pageSize", "sort"])
|
|
3302
3318
|
}),
|
|
3303
3319
|
get: async (listId, authCtx = SERVICE4) => this.ctx.http.request({
|
|
3304
3320
|
method: "GET",
|
|
@@ -3348,11 +3364,12 @@ var PriceService = class {
|
|
|
3348
3364
|
auth: authCtx
|
|
3349
3365
|
});
|
|
3350
3366
|
},
|
|
3367
|
+
/** `q` in the body; `pageNumber`, `pageSize` and `sort` in the query string. */
|
|
3351
3368
|
searchPrices: async (listId, query, authCtx = SERVICE4) => this.ctx.http.request({
|
|
3352
3369
|
method: "POST",
|
|
3353
3370
|
path: `/price/${this.ctx.tenant}/price-lists/${listId}/prices/search`,
|
|
3354
3371
|
auth: authCtx,
|
|
3355
|
-
|
|
3372
|
+
...splitQuery(query, ["pageNumber", "pageSize", "sort"])
|
|
3356
3373
|
}),
|
|
3357
3374
|
bulkCreatePrices: async (listId, inputs, authCtx = SERVICE4) => this.ctx.http.request({
|
|
3358
3375
|
method: "POST",
|
|
@@ -3389,7 +3406,10 @@ var MediaService = class {
|
|
|
3389
3406
|
base() {
|
|
3390
3407
|
return `/media/${this.ctx.tenant}/assets`;
|
|
3391
3408
|
}
|
|
3392
|
-
/**
|
|
3409
|
+
/**
|
|
3410
|
+
* Create an asset. BLOB uploads via multipart (max 30 MB); LINK via JSON.
|
|
3411
|
+
* {@link startUploadSession} sends the file straight to storage instead.
|
|
3412
|
+
*/
|
|
3393
3413
|
async create(input, auth2 = SERVICE5) {
|
|
3394
3414
|
if (input.kind === "blob") {
|
|
3395
3415
|
const fd = new FormData();
|
|
@@ -3447,7 +3467,7 @@ var MediaService = class {
|
|
|
3447
3467
|
* Sends `application/json`. Used for `refIds`, `details`, `metadata`,
|
|
3448
3468
|
* or `url` changes.
|
|
3449
3469
|
* - `{ kind: "blob", file, body }` — replaces the BLOB file content
|
|
3450
|
-
* (max
|
|
3470
|
+
* (max 30 MB) AND patches metadata in the same request. Sends
|
|
3451
3471
|
* `multipart/form-data`.
|
|
3452
3472
|
*
|
|
3453
3473
|
* `type` and `access` are immutable per Emporix — they must match the
|
|
@@ -3521,6 +3541,12 @@ var MediaService = class {
|
|
|
3521
3541
|
* an `ArrayBuffer` transparently; binary Content-Types are passed
|
|
3522
3542
|
* through verbatim.
|
|
3523
3543
|
*
|
|
3544
|
+
* Emporix recommends {@link getDownloadUrl} for every download: here the file
|
|
3545
|
+
* passes through the Media API. A `413` means the asset's known size exceeds
|
|
3546
|
+
* the streaming limit (30 MB by default) — only {@link getDownloadUrl} can
|
|
3547
|
+
* serve it. A `409` means the asset is still `PENDING` from a direct upload
|
|
3548
|
+
* whose file has not reached storage.
|
|
3549
|
+
*
|
|
3524
3550
|
* Implementation note: uses `redirect: "manual"` so the redirect-location
|
|
3525
3551
|
* is observable. In Node.js this works; in a browser the redirect Location
|
|
3526
3552
|
* is intentionally hidden by fetch — there, `PUBLIC` downloads will
|
|
@@ -3576,6 +3602,61 @@ var MediaService = class {
|
|
|
3576
3602
|
}
|
|
3577
3603
|
throw errorFromResponse(res.status, `GET ${path} \u2192 ${res.status}`, parsed);
|
|
3578
3604
|
}
|
|
3605
|
+
/**
|
|
3606
|
+
* Get a URL that serves the stored file straight from storage
|
|
3607
|
+
* (`GET /assets/{assetId}/download-url`). Emporix recommends it for every
|
|
3608
|
+
* download: the file never passes through the Media API, there is no size
|
|
3609
|
+
* limit, and the URL can be handed to a browser as it is.
|
|
3610
|
+
*
|
|
3611
|
+
* - `PRIVATE` BLOB → `provider: "GCS"`, a signed Google Cloud Storage URL that
|
|
3612
|
+
* works without an Emporix token until `expiresAt` (15 minutes by default).
|
|
3613
|
+
* - `PUBLIC` BLOB → `provider: "CLOUDINARY"`, the permanent URL.
|
|
3614
|
+
* - `LINK` → `provider: "LINK"`, the stored URL.
|
|
3615
|
+
*
|
|
3616
|
+
* `disposition` (`attachment` by default, or `inline`) affects private URLs
|
|
3617
|
+
* only. Unlike {@link startUploadSession}, this works whether or not direct
|
|
3618
|
+
* upload is enabled for the tenant. A `409` means a direct upload is still
|
|
3619
|
+
* `PENDING` and its file has not reached storage; once it has, this call
|
|
3620
|
+
* completes the asset before answering.
|
|
3621
|
+
*/
|
|
3622
|
+
async getDownloadUrl(assetId, query = {}, auth2 = SERVICE5) {
|
|
3623
|
+
return this.ctx.http.request({
|
|
3624
|
+
method: "GET",
|
|
3625
|
+
path: `${this.base()}/${encodeURIComponent(assetId)}/download-url`,
|
|
3626
|
+
auth: auth2,
|
|
3627
|
+
query: { ...query }
|
|
3628
|
+
});
|
|
3629
|
+
}
|
|
3630
|
+
/**
|
|
3631
|
+
* Start a direct upload of a `BLOB` asset (`POST /assets/upload-session`,
|
|
3632
|
+
* `201`). Emporix creates the asset as `PENDING` — `id` is its id — and
|
|
3633
|
+
* returns where to send the file. **This method does not send it**:
|
|
3634
|
+
*
|
|
3635
|
+
* - `upload.method === "PUT"` (a `PRIVATE` asset, `uploadType: "put"` or
|
|
3636
|
+
* omitted): `PUT` the file to `upload.url` with every `upload.headers` entry.
|
|
3637
|
+
* - `upload.method === "POST"` (every `PUBLIC` asset, or `uploadType: "form"`):
|
|
3638
|
+
* a multipart `POST` to `upload.url` with every `upload.fields` entry
|
|
3639
|
+
* unchanged and the file part last.
|
|
3640
|
+
*
|
|
3641
|
+
* That request goes to Google Cloud Storage or Cloudinary, not to Emporix, so
|
|
3642
|
+
* it must not carry the Emporix token — which is also why a browser can make
|
|
3643
|
+
* it. The asset turns `READY` once storage confirms; until then, calls that
|
|
3644
|
+
* need the file answer `409`. The instruction is valid for 15 minutes (GCS) or
|
|
3645
|
+
* an hour (Cloudinary), and an unused session expires at `expiresAt`.
|
|
3646
|
+
*
|
|
3647
|
+
* Direct upload is enabled per tenant by Emporix Support. Without it the call
|
|
3648
|
+
* throws an `EmporixForbiddenError` whose `body.message` is `direct upload is
|
|
3649
|
+
* not enabled for this tenant`, and nothing is created — the same status as a
|
|
3650
|
+
* missing scope, so read the message.
|
|
3651
|
+
*/
|
|
3652
|
+
async startUploadSession(input, auth2 = SERVICE5) {
|
|
3653
|
+
return this.ctx.http.request({
|
|
3654
|
+
method: "POST",
|
|
3655
|
+
path: `${this.base()}/upload-session`,
|
|
3656
|
+
auth: auth2,
|
|
3657
|
+
body: input
|
|
3658
|
+
});
|
|
3659
|
+
}
|
|
3579
3660
|
/** Multipart upload sugar: builds `AssetCreateBlob` from input. */
|
|
3580
3661
|
async uploadFile(input, auth2 = SERVICE5) {
|
|
3581
3662
|
const body = {
|
|
@@ -3820,13 +3901,17 @@ var SegmentService = class {
|
|
|
3820
3901
|
async create(input, authCtx = SERVICE6) {
|
|
3821
3902
|
return this.ctx.http.request({ method: "POST", path: this.base(), auth: authCtx, body: input });
|
|
3822
3903
|
}
|
|
3823
|
-
/**
|
|
3904
|
+
/**
|
|
3905
|
+
* Searches segments: `q` in the body; paging, sort, fields, `legalEntityId`
|
|
3906
|
+
* and `customerId` in the query string. `customerId` returns that customer's
|
|
3907
|
+
* segments and needs `customersegment.segment_read`. Default auth: service.
|
|
3908
|
+
*/
|
|
3824
3909
|
async search(query, authCtx = SERVICE6) {
|
|
3825
3910
|
return this.ctx.http.request({
|
|
3826
3911
|
method: "POST",
|
|
3827
3912
|
path: `${this.base()}/search`,
|
|
3828
3913
|
auth: authCtx,
|
|
3829
|
-
|
|
3914
|
+
...splitQuery(query, [...SEARCH_PAGING, "legalEntityId", "customerId"])
|
|
3830
3915
|
});
|
|
3831
3916
|
}
|
|
3832
3917
|
/** Full-replaces a segment (PUT). Default auth: service. */
|
|
@@ -3903,7 +3988,7 @@ var SegmentService = class {
|
|
|
3903
3988
|
method: "POST",
|
|
3904
3989
|
path: `${this.base()}/${segmentId}/customers/search`,
|
|
3905
3990
|
auth: authCtx,
|
|
3906
|
-
|
|
3991
|
+
...splitQuery(query, SEARCH_PAGING)
|
|
3907
3992
|
}),
|
|
3908
3993
|
get: async (segmentId, customerId, authCtx = SERVICE6) => this.ctx.http.request({
|
|
3909
3994
|
method: "GET",
|
|
@@ -3978,7 +4063,7 @@ var SegmentService = class {
|
|
|
3978
4063
|
method: "POST",
|
|
3979
4064
|
path: `${this.base()}/${encodeURIComponent(segmentId)}/groups/search`,
|
|
3980
4065
|
auth: authCtx,
|
|
3981
|
-
|
|
4066
|
+
...splitQuery(query, SEARCH_PAGING)
|
|
3982
4067
|
}),
|
|
3983
4068
|
get: async (segmentId, groupId, authCtx = SERVICE6) => this.ctx.http.request({
|
|
3984
4069
|
method: "GET",
|
|
@@ -4012,7 +4097,7 @@ var SegmentService = class {
|
|
|
4012
4097
|
method: "POST",
|
|
4013
4098
|
path: `${this.base()}/${segmentId}/items/search`,
|
|
4014
4099
|
auth: authCtx,
|
|
4015
|
-
|
|
4100
|
+
...splitQuery(query, [...SEARCH_PAGING, "legalEntityId"])
|
|
4016
4101
|
}),
|
|
4017
4102
|
get: async (segmentId, type, itemId, authCtx = SERVICE6) => this.ctx.http.request({
|
|
4018
4103
|
method: "GET",
|
|
@@ -4336,14 +4421,15 @@ var CompaniesService = class {
|
|
|
4336
4421
|
}
|
|
4337
4422
|
/**
|
|
4338
4423
|
* Searches legal entities via `POST /legal-entities/search` with an Emporix
|
|
4339
|
-
* `q`-syntax filter body
|
|
4424
|
+
* `q`-syntax filter body; paging, sort and fields go in the query string.
|
|
4425
|
+
* Requires the same read scope as {@link listMine}.
|
|
4340
4426
|
*/
|
|
4341
4427
|
async search(query, auth2) {
|
|
4342
4428
|
return this.ctx.http.request({
|
|
4343
4429
|
method: "POST",
|
|
4344
4430
|
path: `${this.base()}/search`,
|
|
4345
4431
|
auth: auth2,
|
|
4346
|
-
|
|
4432
|
+
...splitQuery(query, SEARCH_PAGING),
|
|
4347
4433
|
idempotent: true
|
|
4348
4434
|
// pure read over POST — safe to replay on 5xx/429
|
|
4349
4435
|
});
|
|
@@ -4529,11 +4615,28 @@ var IamService = class {
|
|
|
4529
4615
|
auth: auth2
|
|
4530
4616
|
});
|
|
4531
4617
|
},
|
|
4618
|
+
/**
|
|
4619
|
+
* Lists one vendor's Management Dashboard users, with their groups
|
|
4620
|
+
* (`GET /users/vendors/{vendorId}`).
|
|
4621
|
+
*/
|
|
4622
|
+
listForVendor: async (vendorId, auth2) => this.ctx.http.request({
|
|
4623
|
+
method: "GET",
|
|
4624
|
+
path: `${this.base()}/users/vendors/${encodeURIComponent(vendorId)}`,
|
|
4625
|
+
auth: auth2
|
|
4626
|
+
}),
|
|
4532
4627
|
getGroups: async (userId, auth2) => this.ctx.http.request({
|
|
4533
4628
|
method: "GET",
|
|
4534
4629
|
path: `${this.base()}/users/${userId}/groups`,
|
|
4535
4630
|
auth: auth2
|
|
4536
4631
|
}),
|
|
4632
|
+
/** Removes a user from every group at once (`DELETE /users/{userId}/groups`, `204`). */
|
|
4633
|
+
removeFromAllGroups: async (userId, auth2) => {
|
|
4634
|
+
await this.ctx.http.request({
|
|
4635
|
+
method: "DELETE",
|
|
4636
|
+
path: `${this.base()}/users/${encodeURIComponent(userId)}/groups`,
|
|
4637
|
+
auth: auth2
|
|
4638
|
+
});
|
|
4639
|
+
},
|
|
4537
4640
|
/**
|
|
4538
4641
|
* Reads one of a user's groups (`GET /users/{userId}/groups/{groupId}`).
|
|
4539
4642
|
* The collection read above returns the same shape per entry; this exists
|
|
@@ -4772,6 +4875,20 @@ var OrdersService = class {
|
|
|
4772
4875
|
...headers ? { headers } : {}
|
|
4773
4876
|
});
|
|
4774
4877
|
}
|
|
4878
|
+
/**
|
|
4879
|
+
* The status transitions the customer may trigger on one of their orders
|
|
4880
|
+
* (`GET /orders/{orderId}/transitions`) — for example whether it can still be
|
|
4881
|
+
* cancelled, before offering {@link cancel}.
|
|
4882
|
+
*/
|
|
4883
|
+
async listTransitions(orderId, auth2, opts = {}) {
|
|
4884
|
+
const headers = this.saasHeader(opts.saasToken);
|
|
4885
|
+
return this.ctx.http.request({
|
|
4886
|
+
method: "GET",
|
|
4887
|
+
path: `${this.base()}/${encodeURIComponent(orderId)}/transitions`,
|
|
4888
|
+
auth: auth2,
|
|
4889
|
+
...headers ? { headers } : {}
|
|
4890
|
+
});
|
|
4891
|
+
}
|
|
4775
4892
|
/** Transitions an order to a new status. Server enforces legal transitions. */
|
|
4776
4893
|
async transition(orderId, status, auth2, opts = {}) {
|
|
4777
4894
|
const body = { status };
|
|
@@ -5317,6 +5434,21 @@ var ClientConfigService = class {
|
|
|
5317
5434
|
|
|
5318
5435
|
// src/services/shopping-list.ts
|
|
5319
5436
|
var RESERVED = /* @__PURE__ */ new Set(["customerId", "metadata"]);
|
|
5437
|
+
function toLists(env) {
|
|
5438
|
+
const out = [];
|
|
5439
|
+
for (const [key, value] of Object.entries(env)) {
|
|
5440
|
+
if (RESERVED.has(key) || value === null || typeof value !== "object") continue;
|
|
5441
|
+
const v = value;
|
|
5442
|
+
out.push({
|
|
5443
|
+
key,
|
|
5444
|
+
name: v.name ?? key,
|
|
5445
|
+
items: v.items ?? [],
|
|
5446
|
+
...v.mixins ? { mixins: v.mixins } : {},
|
|
5447
|
+
...v.metadata ? { metadata: v.metadata } : {}
|
|
5448
|
+
});
|
|
5449
|
+
}
|
|
5450
|
+
return out;
|
|
5451
|
+
}
|
|
5320
5452
|
var ShoppingListService = class {
|
|
5321
5453
|
constructor(ctx) {
|
|
5322
5454
|
this.ctx = ctx;
|
|
@@ -5326,7 +5458,11 @@ var ShoppingListService = class {
|
|
|
5326
5458
|
base() {
|
|
5327
5459
|
return `/shoppinglist/${this.ctx.tenant}/shopping-lists`;
|
|
5328
5460
|
}
|
|
5329
|
-
/**
|
|
5461
|
+
/**
|
|
5462
|
+
* The caller's lists, normalized to an array. With employee scope Emporix
|
|
5463
|
+
* returns **every customer's** lists and ignores `name` — read one customer's
|
|
5464
|
+
* with {@link getForCustomer} instead.
|
|
5465
|
+
*/
|
|
5330
5466
|
async list(auth2, opts = {}) {
|
|
5331
5467
|
const envelopes = await this.ctx.http.request({
|
|
5332
5468
|
method: "GET",
|
|
@@ -5334,21 +5470,20 @@ var ShoppingListService = class {
|
|
|
5334
5470
|
auth: auth2,
|
|
5335
5471
|
...opts.name ? { query: { name: opts.name } } : {}
|
|
5336
5472
|
});
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
return out;
|
|
5473
|
+
return (envelopes ?? []).flatMap(toLists);
|
|
5474
|
+
}
|
|
5475
|
+
/**
|
|
5476
|
+
* One customer's lists (`GET /shopping-lists/{customerId}`), normalized to an
|
|
5477
|
+
* array — the employee read; `name` narrows it to one list.
|
|
5478
|
+
*/
|
|
5479
|
+
async getForCustomer(customerId, auth2, opts = {}) {
|
|
5480
|
+
const envelope = await this.ctx.http.request({
|
|
5481
|
+
method: "GET",
|
|
5482
|
+
path: `${this.base()}/${encodeURIComponent(customerId)}`,
|
|
5483
|
+
auth: auth2,
|
|
5484
|
+
...opts.name ? { query: { name: opts.name } } : {}
|
|
5485
|
+
});
|
|
5486
|
+
return envelope ? toLists(envelope) : [];
|
|
5352
5487
|
}
|
|
5353
5488
|
/** Create a list; returns the new list id. */
|
|
5354
5489
|
async create(draft, auth2) {
|
|
@@ -5377,8 +5512,8 @@ var ShoppingListService = class {
|
|
|
5377
5512
|
...opts.name ? { query: { name: opts.name } } : {}
|
|
5378
5513
|
});
|
|
5379
5514
|
}
|
|
5380
|
-
async loadList(listName, auth2) {
|
|
5381
|
-
const lists = await this.list(auth2, { name: listName });
|
|
5515
|
+
async loadList(customerId, listName, auth2) {
|
|
5516
|
+
const lists = auth2.kind === "service" ? await this.getForCustomer(customerId, auth2, { name: listName }) : await this.list(auth2, { name: listName });
|
|
5382
5517
|
const found = lists.find((l) => l.name === listName);
|
|
5383
5518
|
if (!found) throw new EmporixNotFoundError(`Shopping list "${listName}" not found`, 404);
|
|
5384
5519
|
return found;
|
|
@@ -5392,20 +5527,20 @@ var ShoppingListService = class {
|
|
|
5392
5527
|
}
|
|
5393
5528
|
/** Add/replace an item by `productId` (read-modify-write, last-write-wins). */
|
|
5394
5529
|
async addItem(customerId, listName, item, auth2) {
|
|
5395
|
-
const list = await this.loadList(listName, auth2);
|
|
5530
|
+
const list = await this.loadList(customerId, listName, auth2);
|
|
5396
5531
|
const items = [...list.items.filter((i) => i.productId !== item.productId), item];
|
|
5397
5532
|
await this.put(customerId, list, items, auth2);
|
|
5398
5533
|
}
|
|
5399
5534
|
/** Remove an item by `productId` (no-op if absent). */
|
|
5400
5535
|
async removeItem(customerId, listName, productId, auth2) {
|
|
5401
|
-
const list = await this.loadList(listName, auth2);
|
|
5536
|
+
const list = await this.loadList(customerId, listName, auth2);
|
|
5402
5537
|
const items = list.items.filter((i) => i.productId !== productId);
|
|
5403
5538
|
await this.put(customerId, list, items, auth2);
|
|
5404
5539
|
}
|
|
5405
5540
|
/** Set an item's quantity; `quantity <= 0` removes it. Adds the item if absent. */
|
|
5406
5541
|
async setItemQuantity(customerId, listName, productId, quantity, auth2) {
|
|
5407
5542
|
if (quantity <= 0) return this.removeItem(customerId, listName, productId, auth2);
|
|
5408
|
-
const list = await this.loadList(listName, auth2);
|
|
5543
|
+
const list = await this.loadList(customerId, listName, auth2);
|
|
5409
5544
|
let items = list.items.map((i) => i.productId === productId ? { ...i, quantity } : i);
|
|
5410
5545
|
if (!items.some((i) => i.productId === productId)) items = [...items, { productId, quantity }];
|
|
5411
5546
|
await this.put(customerId, list, items, auth2);
|
|
@@ -5738,13 +5873,14 @@ var FeeService = class {
|
|
|
5738
5873
|
* Finds item fees for several products on one site
|
|
5739
5874
|
* (`POST /itemFees/searchByProductIds`). Note the upstream asymmetry:
|
|
5740
5875
|
* `productIds` is a comma-separated **string** and `siteCode` is singular.
|
|
5876
|
+
* `siteFallback` goes in the query string, everything else in the body.
|
|
5741
5877
|
*/
|
|
5742
5878
|
async searchItemFeesByProductIds(search, auth2 = SERVICE13) {
|
|
5743
5879
|
return this.ctx.http.request({
|
|
5744
5880
|
method: "POST",
|
|
5745
5881
|
path: `${this.itemFeesBase()}/searchByProductIds`,
|
|
5746
5882
|
auth: auth2,
|
|
5747
|
-
|
|
5883
|
+
...splitQuery(search, ["siteFallback"]),
|
|
5748
5884
|
idempotent: true
|
|
5749
5885
|
// pure read over POST — safe to replay on 5xx/429
|
|
5750
5886
|
});
|
|
@@ -6350,9 +6486,9 @@ var AgenticCrudResource = class {
|
|
|
6350
6486
|
list(query = {}, auth2 = SERVICE16) {
|
|
6351
6487
|
return this.ctx.http.request({ method: "GET", path: this.path, auth: auth2, query: { ...query } });
|
|
6352
6488
|
}
|
|
6353
|
-
/** Structured search (`POST {path}/search`)
|
|
6489
|
+
/** Structured search (`POST {path}/search`): `q` in the body, paging/sort/fields in the query. */
|
|
6354
6490
|
search(query, auth2 = SERVICE16) {
|
|
6355
|
-
return this.ctx.http.request({ method: "POST", path: `${this.path}/search`, auth: auth2,
|
|
6491
|
+
return this.ctx.http.request({ method: "POST", path: `${this.path}/search`, auth: auth2, ...splitQuery(query, SEARCH_PAGING) });
|
|
6356
6492
|
}
|
|
6357
6493
|
/** Retrieve one entry by id (`GET {path}/{id}`). */
|
|
6358
6494
|
get(id, opts = {}, auth2 = SERVICE16) {
|
|
@@ -6402,7 +6538,7 @@ var JobsResource = class {
|
|
|
6402
6538
|
}
|
|
6403
6539
|
/** Structured job search (`POST /jobs/search`). */
|
|
6404
6540
|
search(query, auth2 = SERVICE16) {
|
|
6405
|
-
return this.ctx.http.request({ method: "POST", path: `${this.base}/jobs/search`, auth: auth2,
|
|
6541
|
+
return this.ctx.http.request({ method: "POST", path: `${this.base}/jobs/search`, auth: auth2, ...splitQuery(query, SEARCH_PAGING) });
|
|
6406
6542
|
}
|
|
6407
6543
|
/** Retrieve one job (`GET /jobs/{jobId}`). */
|
|
6408
6544
|
get(jobId, auth2 = SERVICE16) {
|
|
@@ -6426,7 +6562,7 @@ var TemplatesResource = class {
|
|
|
6426
6562
|
}
|
|
6427
6563
|
/** Structured template search (`POST /agentic/templates/search`). */
|
|
6428
6564
|
search(query, auth2 = SERVICE16) {
|
|
6429
|
-
return this.ctx.http.request({ method: "POST", path: `${this.path}/search`, auth: auth2,
|
|
6565
|
+
return this.ctx.http.request({ method: "POST", path: `${this.path}/search`, auth: auth2, ...splitQuery(query, SEARCH_PAGING) });
|
|
6430
6566
|
}
|
|
6431
6567
|
/**
|
|
6432
6568
|
* Instantiate a new agent from a template
|
|
@@ -6459,7 +6595,7 @@ var LogsResource = class {
|
|
|
6459
6595
|
}
|
|
6460
6596
|
/** Structured request-log search (`POST /agentic/logs/requests/search`). */
|
|
6461
6597
|
searchRequests(query, auth2 = SERVICE16) {
|
|
6462
|
-
return this.ctx.http.request({ method: "POST", path: `${this.path}/requests/search`, auth: auth2,
|
|
6598
|
+
return this.ctx.http.request({ method: "POST", path: `${this.path}/requests/search`, auth: auth2, ...splitQuery(query, SEARCH_PAGING) });
|
|
6463
6599
|
}
|
|
6464
6600
|
/** List session logs (`GET /agentic/logs/sessions`). */
|
|
6465
6601
|
listSessions(query = {}, auth2 = SERVICE16) {
|
|
@@ -6471,7 +6607,7 @@ var LogsResource = class {
|
|
|
6471
6607
|
}
|
|
6472
6608
|
/** Structured session-log search (`POST /agentic/logs/sessions/search`). */
|
|
6473
6609
|
searchSessions(query, auth2 = SERVICE16) {
|
|
6474
|
-
return this.ctx.http.request({ method: "POST", path: `${this.path}/sessions/search`, auth: auth2,
|
|
6610
|
+
return this.ctx.http.request({ method: "POST", path: `${this.path}/sessions/search`, auth: auth2, ...splitQuery(query, SEARCH_PAGING) });
|
|
6475
6611
|
}
|
|
6476
6612
|
};
|
|
6477
6613
|
var AnalyticsResource = class {
|
|
@@ -6503,6 +6639,10 @@ function assertChatOptions(opts, method) {
|
|
|
6503
6639
|
function sessionHeader(opts) {
|
|
6504
6640
|
return opts.sessionId ? { headers: { "session-id": opts.sessionId } } : {};
|
|
6505
6641
|
}
|
|
6642
|
+
var AUTH_KINDS = /* @__PURE__ */ new Set(["service", "anonymous", "customer", "raw"]);
|
|
6643
|
+
function isAuthContext(value) {
|
|
6644
|
+
return AUTH_KINDS.has(String(value.kind));
|
|
6645
|
+
}
|
|
6506
6646
|
var AiService = class {
|
|
6507
6647
|
constructor(ctx) {
|
|
6508
6648
|
this.ctx = ctx;
|
|
@@ -6571,12 +6711,13 @@ var AiService = class {
|
|
|
6571
6711
|
body: input
|
|
6572
6712
|
});
|
|
6573
6713
|
}
|
|
6574
|
-
|
|
6575
|
-
|
|
6714
|
+
async listAgents(queryOrAuth = {}, auth2 = SERVICE17) {
|
|
6715
|
+
const [query, ctx] = isAuthContext(queryOrAuth) ? [{}, queryOrAuth] : [queryOrAuth, auth2];
|
|
6576
6716
|
return this.ctx.http.request({
|
|
6577
6717
|
method: "GET",
|
|
6578
6718
|
path: `${this.base()}/agentic/agents`,
|
|
6579
|
-
auth:
|
|
6719
|
+
auth: ctx,
|
|
6720
|
+
query: { ...query }
|
|
6580
6721
|
});
|
|
6581
6722
|
}
|
|
6582
6723
|
/** Retrieve one agent by id. */
|
|
@@ -6621,13 +6762,16 @@ var AiService = class {
|
|
|
6621
6762
|
...opts.force ? { query: { force: "true" } } : {}
|
|
6622
6763
|
});
|
|
6623
6764
|
}
|
|
6624
|
-
/**
|
|
6765
|
+
/**
|
|
6766
|
+
* Server-side agent search (`POST /agentic/agents/search`). `q` goes in the
|
|
6767
|
+
* body; `pageNumber`, `pageSize`, `sort` and `fields` in the query string.
|
|
6768
|
+
*/
|
|
6625
6769
|
async searchAgents(query, auth2 = SERVICE17) {
|
|
6626
6770
|
return this.ctx.http.request({
|
|
6627
6771
|
method: "POST",
|
|
6628
6772
|
path: `${this.base()}/agentic/agents/search`,
|
|
6629
6773
|
auth: auth2,
|
|
6630
|
-
|
|
6774
|
+
...splitQuery(query, SEARCH_PAGING)
|
|
6631
6775
|
});
|
|
6632
6776
|
}
|
|
6633
6777
|
/**
|
|
@@ -6680,21 +6824,22 @@ var AiService = class {
|
|
|
6680
6824
|
});
|
|
6681
6825
|
for await (const ev of events) yield ev.data;
|
|
6682
6826
|
}
|
|
6683
|
-
|
|
6684
|
-
|
|
6827
|
+
async listConversations(queryOrAuth = {}, auth2 = SERVICE17) {
|
|
6828
|
+
const [query, ctx] = isAuthContext(queryOrAuth) ? [{}, queryOrAuth] : [queryOrAuth, auth2];
|
|
6685
6829
|
return this.ctx.http.request({
|
|
6686
6830
|
method: "GET",
|
|
6687
6831
|
path: `${this.base()}/agentic/conversations`,
|
|
6688
|
-
auth:
|
|
6832
|
+
auth: ctx,
|
|
6833
|
+
query: { ...query }
|
|
6689
6834
|
});
|
|
6690
6835
|
}
|
|
6691
|
-
/** Server-side conversation search (`POST /agentic/conversations/search`). */
|
|
6836
|
+
/** Server-side conversation search (`POST /agentic/conversations/search`), paged like {@link searchAgents}. */
|
|
6692
6837
|
async searchConversations(query, auth2 = SERVICE17) {
|
|
6693
6838
|
return this.ctx.http.request({
|
|
6694
6839
|
method: "POST",
|
|
6695
6840
|
path: `${this.base()}/agentic/conversations/search`,
|
|
6696
6841
|
auth: auth2,
|
|
6697
|
-
|
|
6842
|
+
...splitQuery(query, SEARCH_PAGING)
|
|
6698
6843
|
});
|
|
6699
6844
|
}
|
|
6700
6845
|
// --- Standalone agentic reads / bulk operations ------------------------
|
|
@@ -8890,14 +9035,17 @@ var VendorService = class {
|
|
|
8890
9035
|
auth: auth2
|
|
8891
9036
|
});
|
|
8892
9037
|
}
|
|
8893
|
-
/**
|
|
9038
|
+
/**
|
|
9039
|
+
* Search vendors (`POST /vendors/search`). A built filter in `q` is resolved to
|
|
9040
|
+
* a string; paging, sort and fields go in the query string.
|
|
9041
|
+
*/
|
|
8894
9042
|
async searchVendors(query, auth2 = SERVICE33) {
|
|
8895
|
-
const
|
|
9043
|
+
const input = query.q !== void 0 ? { ...query, q: resolveQuery(query.q, { compoundLogicalQuery: false }) } : query;
|
|
8896
9044
|
return this.ctx.http.request({
|
|
8897
9045
|
method: "POST",
|
|
8898
9046
|
path: `${this.base()}/vendors/search`,
|
|
8899
9047
|
auth: auth2,
|
|
8900
|
-
|
|
9048
|
+
...splitQuery(input, SEARCH_PAGING)
|
|
8901
9049
|
});
|
|
8902
9050
|
}
|
|
8903
9051
|
/** Create a vendor. */
|
|
@@ -8992,10 +9140,18 @@ var CustomerAdminService = class {
|
|
|
8992
9140
|
...Object.keys(query).length ? { query } : {}
|
|
8993
9141
|
});
|
|
8994
9142
|
}
|
|
8995
|
-
/**
|
|
9143
|
+
/**
|
|
9144
|
+
* Search customers (`POST /customers/search`). A built filter in `q` is resolved
|
|
9145
|
+
* to a string; `pageNumber`, `pageSize`, `sort` and `expand` go in the query string.
|
|
9146
|
+
*/
|
|
8996
9147
|
async searchCustomers(query, auth2 = SERVICE34) {
|
|
8997
|
-
const
|
|
8998
|
-
return this.ctx.http.request({
|
|
9148
|
+
const input = query.q !== void 0 ? { ...query, q: resolveQuery(query.q, { compoundLogicalQuery: false }) } : query;
|
|
9149
|
+
return this.ctx.http.request({
|
|
9150
|
+
method: "POST",
|
|
9151
|
+
path: `${this.base()}/search`,
|
|
9152
|
+
auth: auth2,
|
|
9153
|
+
...splitQuery(input, ["pageNumber", "pageSize", "sort", "expand"])
|
|
9154
|
+
});
|
|
8999
9155
|
}
|
|
9000
9156
|
/** Retrieve a customer profile by number. */
|
|
9001
9157
|
async getCustomer(customerNumber, auth2 = SERVICE34) {
|