@viu/emporix-sdk 2.4.0 → 2.6.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 +58 -0
- package/README.md +23 -3
- package/dist/availability.d.cts +1 -1
- package/dist/availability.d.ts +1 -1
- package/dist/cart.d.cts +1 -1
- package/dist/cart.d.ts +1 -1
- package/dist/category.d.cts +1 -1
- package/dist/category.d.ts +1 -1
- package/dist/checkout.d.cts +1 -1
- package/dist/checkout.d.ts +1 -1
- package/dist/companies.d.cts +1 -1
- package/dist/companies.d.ts +1 -1
- package/dist/contacts.d.cts +1 -1
- package/dist/contacts.d.ts +1 -1
- package/dist/{context-hksRbb95.d.cts → context-DJDTlhLW.d.cts} +31 -2
- package/dist/{context-hksRbb95.d.ts → context-DJDTlhLW.d.ts} +31 -2
- package/dist/customer-groups.d.cts +1 -1
- package/dist/customer-groups.d.ts +1 -1
- package/dist/customer.d.cts +1 -1
- package/dist/customer.d.ts +1 -1
- package/dist/index.cjs +497 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1927 -110
- package/dist/index.d.ts +1927 -110
- package/dist/index.js +492 -4
- package/dist/index.js.map +1 -1
- package/dist/locations.d.cts +1 -1
- package/dist/locations.d.ts +1 -1
- package/dist/media.d.cts +1 -1
- package/dist/media.d.ts +1 -1
- package/dist/orders.d.cts +1 -1
- package/dist/orders.d.ts +1 -1
- package/dist/payment.d.cts +1 -1
- package/dist/payment.d.ts +1 -1
- package/dist/price.d.cts +1 -1
- package/dist/price.d.ts +1 -1
- package/dist/product.d.cts +1 -1
- package/dist/product.d.ts +1 -1
- package/dist/segment.d.cts +1 -1
- package/dist/segment.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -316,6 +316,26 @@ async function resolveToken(ctx, provider) {
|
|
|
316
316
|
return ctx.token;
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
|
+
var CustomerRefreshRegistry = class {
|
|
320
|
+
refresher = null;
|
|
321
|
+
inflight = null;
|
|
322
|
+
set(refresher) {
|
|
323
|
+
this.refresher = refresher;
|
|
324
|
+
}
|
|
325
|
+
get enabled() {
|
|
326
|
+
return this.refresher !== null;
|
|
327
|
+
}
|
|
328
|
+
/** Concurrent callers share one in-flight refresh. */
|
|
329
|
+
refresh(expiredToken) {
|
|
330
|
+
if (!this.refresher) return Promise.resolve(null);
|
|
331
|
+
if (this.inflight) return this.inflight;
|
|
332
|
+
const p = Promise.resolve(this.refresher.refresh(expiredToken)).finally(() => {
|
|
333
|
+
this.inflight = null;
|
|
334
|
+
});
|
|
335
|
+
this.inflight = p;
|
|
336
|
+
return p;
|
|
337
|
+
}
|
|
338
|
+
};
|
|
319
339
|
var DefaultTokenProvider = class {
|
|
320
340
|
constructor(cfg) {
|
|
321
341
|
this.cfg = cfg;
|
|
@@ -517,8 +537,10 @@ var HttpClient = class {
|
|
|
517
537
|
const sdkManaged = o.auth.kind === "service" || o.auth.kind === "anonymous";
|
|
518
538
|
const maxAttempts = this.opts.retry.maxAttempts;
|
|
519
539
|
let reauthed = false;
|
|
540
|
+
let customerToken = o.auth.kind === "customer" ? o.auth.token : void 0;
|
|
541
|
+
let customerReauthed = false;
|
|
520
542
|
for (let attempt = 1; ; attempt++) {
|
|
521
|
-
const token = await resolveToken(o.auth, this.opts.provider);
|
|
543
|
+
const token = customerToken ?? await resolveToken(o.auth, this.opts.provider);
|
|
522
544
|
log.debug("http request", {
|
|
523
545
|
authKind: o.auth.kind,
|
|
524
546
|
method: o.method,
|
|
@@ -570,6 +592,15 @@ var HttpClient = class {
|
|
|
570
592
|
log.warn("sdk-managed 401, re-authing once", { authKind: o.auth.kind });
|
|
571
593
|
continue;
|
|
572
594
|
}
|
|
595
|
+
if (o.auth.kind === "customer" && !customerReauthed && this.opts.customerRefresh?.enabled) {
|
|
596
|
+
customerReauthed = true;
|
|
597
|
+
const fresh = await this.opts.customerRefresh.refresh(customerToken);
|
|
598
|
+
if (fresh) {
|
|
599
|
+
customerToken = fresh;
|
|
600
|
+
log.warn("customer 401, refreshed once", { authKind: o.auth.kind });
|
|
601
|
+
continue;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
573
604
|
throw errorFromResponse(res.status, `${o.method} ${o.path} \u2192 401`, parsed);
|
|
574
605
|
}
|
|
575
606
|
const retryable = res.status >= 500 || res.status === 429;
|
|
@@ -2974,8 +3005,442 @@ var UnitHandlingService = class {
|
|
|
2974
3005
|
}
|
|
2975
3006
|
};
|
|
2976
3007
|
|
|
3008
|
+
// src/services/catalog.ts
|
|
3009
|
+
var SERVICE21 = { kind: "service" };
|
|
3010
|
+
var CatalogService = class {
|
|
3011
|
+
constructor(ctx) {
|
|
3012
|
+
this.ctx = ctx;
|
|
3013
|
+
}
|
|
3014
|
+
ctx;
|
|
3015
|
+
base() {
|
|
3016
|
+
return `/catalog/${this.ctx.tenant}/catalogs`;
|
|
3017
|
+
}
|
|
3018
|
+
/** List catalogs (filtered/sorted). */
|
|
3019
|
+
async listCatalogs(query = {}, auth2 = SERVICE21) {
|
|
3020
|
+
return this.ctx.http.request({
|
|
3021
|
+
method: "GET",
|
|
3022
|
+
path: this.base(),
|
|
3023
|
+
auth: auth2,
|
|
3024
|
+
...Object.keys(query).length ? { query } : {}
|
|
3025
|
+
});
|
|
3026
|
+
}
|
|
3027
|
+
/** Retrieve a catalog by id. */
|
|
3028
|
+
async getCatalog(catalogId, auth2 = SERVICE21) {
|
|
3029
|
+
return this.ctx.http.request({
|
|
3030
|
+
method: "GET",
|
|
3031
|
+
path: `${this.base()}/${encodeURIComponent(catalogId)}`,
|
|
3032
|
+
auth: auth2
|
|
3033
|
+
});
|
|
3034
|
+
}
|
|
3035
|
+
/** Retrieve all catalogs that contain a category. */
|
|
3036
|
+
async getCatalogsForCategory(categoryId, auth2 = SERVICE21) {
|
|
3037
|
+
return this.ctx.http.request({
|
|
3038
|
+
method: "GET",
|
|
3039
|
+
path: `${this.base()}/categories/${encodeURIComponent(categoryId)}`,
|
|
3040
|
+
auth: auth2
|
|
3041
|
+
});
|
|
3042
|
+
}
|
|
3043
|
+
/** Create a catalog. */
|
|
3044
|
+
async createCatalog(input, auth2 = SERVICE21) {
|
|
3045
|
+
return this.ctx.http.request({ method: "POST", path: this.base(), auth: auth2, body: input });
|
|
3046
|
+
}
|
|
3047
|
+
/** Upsert a catalog by id (`PUT`). */
|
|
3048
|
+
async updateCatalog(catalogId, input, auth2 = SERVICE21) {
|
|
3049
|
+
return this.ctx.http.request({
|
|
3050
|
+
method: "PUT",
|
|
3051
|
+
path: `${this.base()}/${encodeURIComponent(catalogId)}`,
|
|
3052
|
+
auth: auth2,
|
|
3053
|
+
body: input
|
|
3054
|
+
});
|
|
3055
|
+
}
|
|
3056
|
+
/** Partially update a catalog by id (`PATCH`). */
|
|
3057
|
+
async patchCatalog(catalogId, patch, auth2 = SERVICE21) {
|
|
3058
|
+
await this.ctx.http.request({
|
|
3059
|
+
method: "PATCH",
|
|
3060
|
+
path: `${this.base()}/${encodeURIComponent(catalogId)}`,
|
|
3061
|
+
auth: auth2,
|
|
3062
|
+
body: patch
|
|
3063
|
+
});
|
|
3064
|
+
}
|
|
3065
|
+
/** Remove a catalog by id. */
|
|
3066
|
+
async deleteCatalog(catalogId, auth2 = SERVICE21) {
|
|
3067
|
+
await this.ctx.http.request({
|
|
3068
|
+
method: "DELETE",
|
|
3069
|
+
path: `${this.base()}/${encodeURIComponent(catalogId)}`,
|
|
3070
|
+
auth: auth2
|
|
3071
|
+
});
|
|
3072
|
+
}
|
|
3073
|
+
};
|
|
3074
|
+
|
|
3075
|
+
// src/services/vendor.ts
|
|
3076
|
+
var SERVICE22 = { kind: "service" };
|
|
3077
|
+
var VendorService = class {
|
|
3078
|
+
constructor(ctx) {
|
|
3079
|
+
this.ctx = ctx;
|
|
3080
|
+
}
|
|
3081
|
+
ctx;
|
|
3082
|
+
base() {
|
|
3083
|
+
return `/vendor/${this.ctx.tenant}`;
|
|
3084
|
+
}
|
|
3085
|
+
// --- Vendors ---
|
|
3086
|
+
/** List all vendors. */
|
|
3087
|
+
async listVendors(query = {}, auth2 = SERVICE22) {
|
|
3088
|
+
return this.ctx.http.request({
|
|
3089
|
+
method: "GET",
|
|
3090
|
+
path: `${this.base()}/vendors`,
|
|
3091
|
+
auth: auth2,
|
|
3092
|
+
...Object.keys(query).length ? { query } : {}
|
|
3093
|
+
});
|
|
3094
|
+
}
|
|
3095
|
+
/** Retrieve a vendor by id. */
|
|
3096
|
+
async getVendor(vendorId, auth2 = SERVICE22) {
|
|
3097
|
+
return this.ctx.http.request({
|
|
3098
|
+
method: "GET",
|
|
3099
|
+
path: `${this.base()}/vendors/${encodeURIComponent(vendorId)}`,
|
|
3100
|
+
auth: auth2
|
|
3101
|
+
});
|
|
3102
|
+
}
|
|
3103
|
+
/** Search vendors (`POST /vendors/search`). */
|
|
3104
|
+
async searchVendors(query, auth2 = SERVICE22) {
|
|
3105
|
+
return this.ctx.http.request({
|
|
3106
|
+
method: "POST",
|
|
3107
|
+
path: `${this.base()}/vendors/search`,
|
|
3108
|
+
auth: auth2,
|
|
3109
|
+
body: query
|
|
3110
|
+
});
|
|
3111
|
+
}
|
|
3112
|
+
/** Create a vendor. */
|
|
3113
|
+
async createVendor(input, auth2 = SERVICE22) {
|
|
3114
|
+
return this.ctx.http.request({ method: "POST", path: `${this.base()}/vendors`, auth: auth2, body: input });
|
|
3115
|
+
}
|
|
3116
|
+
/** Upsert a vendor by id (`PUT`). */
|
|
3117
|
+
async updateVendor(vendorId, input, auth2 = SERVICE22) {
|
|
3118
|
+
await this.ctx.http.request({
|
|
3119
|
+
method: "PUT",
|
|
3120
|
+
path: `${this.base()}/vendors/${encodeURIComponent(vendorId)}`,
|
|
3121
|
+
auth: auth2,
|
|
3122
|
+
body: input
|
|
3123
|
+
});
|
|
3124
|
+
}
|
|
3125
|
+
/** Delete a vendor by id. */
|
|
3126
|
+
async deleteVendor(vendorId, auth2 = SERVICE22) {
|
|
3127
|
+
await this.ctx.http.request({
|
|
3128
|
+
method: "DELETE",
|
|
3129
|
+
path: `${this.base()}/vendors/${encodeURIComponent(vendorId)}`,
|
|
3130
|
+
auth: auth2
|
|
3131
|
+
});
|
|
3132
|
+
}
|
|
3133
|
+
// --- Vendor locations ---
|
|
3134
|
+
/** List all vendor locations. */
|
|
3135
|
+
async listVendorLocations(query = {}, auth2 = SERVICE22) {
|
|
3136
|
+
return this.ctx.http.request({
|
|
3137
|
+
method: "GET",
|
|
3138
|
+
path: `${this.base()}/locations`,
|
|
3139
|
+
auth: auth2,
|
|
3140
|
+
...Object.keys(query).length ? { query } : {}
|
|
3141
|
+
});
|
|
3142
|
+
}
|
|
3143
|
+
/** Retrieve a vendor location by id. */
|
|
3144
|
+
async getVendorLocation(locationId, auth2 = SERVICE22) {
|
|
3145
|
+
return this.ctx.http.request({
|
|
3146
|
+
method: "GET",
|
|
3147
|
+
path: `${this.base()}/locations/${encodeURIComponent(locationId)}`,
|
|
3148
|
+
auth: auth2
|
|
3149
|
+
});
|
|
3150
|
+
}
|
|
3151
|
+
/** Create a vendor location. */
|
|
3152
|
+
async createVendorLocation(input, auth2 = SERVICE22) {
|
|
3153
|
+
return this.ctx.http.request({ method: "POST", path: `${this.base()}/locations`, auth: auth2, body: input });
|
|
3154
|
+
}
|
|
3155
|
+
/** Upsert a vendor location by id (`PUT`). */
|
|
3156
|
+
async updateVendorLocation(locationId, input, auth2 = SERVICE22) {
|
|
3157
|
+
await this.ctx.http.request({
|
|
3158
|
+
method: "PUT",
|
|
3159
|
+
path: `${this.base()}/locations/${encodeURIComponent(locationId)}`,
|
|
3160
|
+
auth: auth2,
|
|
3161
|
+
body: input
|
|
3162
|
+
});
|
|
3163
|
+
}
|
|
3164
|
+
/** Delete a vendor location by id. */
|
|
3165
|
+
async deleteVendorLocation(locationId, auth2 = SERVICE22) {
|
|
3166
|
+
await this.ctx.http.request({
|
|
3167
|
+
method: "DELETE",
|
|
3168
|
+
path: `${this.base()}/locations/${encodeURIComponent(locationId)}`,
|
|
3169
|
+
auth: auth2
|
|
3170
|
+
});
|
|
3171
|
+
}
|
|
3172
|
+
};
|
|
3173
|
+
|
|
3174
|
+
// src/services/pick-pack.ts
|
|
3175
|
+
var SERVICE23 = { kind: "service" };
|
|
3176
|
+
var PickPackService = class {
|
|
3177
|
+
constructor(ctx) {
|
|
3178
|
+
this.ctx = ctx;
|
|
3179
|
+
}
|
|
3180
|
+
ctx;
|
|
3181
|
+
base() {
|
|
3182
|
+
return `/pick-pack/${this.ctx.tenant}`;
|
|
3183
|
+
}
|
|
3184
|
+
orderPath(orderId) {
|
|
3185
|
+
return `${this.base()}/orders/${encodeURIComponent(orderId)}`;
|
|
3186
|
+
}
|
|
3187
|
+
/** List packlist orders. */
|
|
3188
|
+
async listOrders(query = {}, auth2 = SERVICE23) {
|
|
3189
|
+
return this.ctx.http.request({
|
|
3190
|
+
method: "GET",
|
|
3191
|
+
path: `${this.base()}/orders`,
|
|
3192
|
+
auth: auth2,
|
|
3193
|
+
...Object.keys(query).length ? { query } : {}
|
|
3194
|
+
});
|
|
3195
|
+
}
|
|
3196
|
+
/** Retrieve a packlist order by id. */
|
|
3197
|
+
async getOrder(orderId, auth2 = SERVICE23) {
|
|
3198
|
+
return this.ctx.http.request({ method: "GET", path: this.orderPath(orderId), auth: auth2 });
|
|
3199
|
+
}
|
|
3200
|
+
/** Update an order's status (`PATCH`). Returns an acknowledgement. */
|
|
3201
|
+
async updateOrder(orderId, change, auth2 = SERVICE23) {
|
|
3202
|
+
return this.ctx.http.request({ method: "PATCH", path: this.orderPath(orderId), auth: auth2, body: change });
|
|
3203
|
+
}
|
|
3204
|
+
/** Finish an order. Returns an acknowledgement. */
|
|
3205
|
+
async finishOrder(orderId, auth2 = SERVICE23) {
|
|
3206
|
+
return this.ctx.http.request({ method: "POST", path: `${this.orderPath(orderId)}/finish`, auth: auth2 });
|
|
3207
|
+
}
|
|
3208
|
+
/** List order cycles (ids). */
|
|
3209
|
+
async listOrderCycles(query = {}, auth2 = SERVICE23) {
|
|
3210
|
+
return this.ctx.http.request({
|
|
3211
|
+
method: "GET",
|
|
3212
|
+
path: `${this.base()}/orderCycles`,
|
|
3213
|
+
auth: auth2,
|
|
3214
|
+
...Object.keys(query).length ? { query } : {}
|
|
3215
|
+
});
|
|
3216
|
+
}
|
|
3217
|
+
/** Add an assignee to an order. Returns an acknowledgement. */
|
|
3218
|
+
async addAssignee(orderId, assignee, auth2 = SERVICE23) {
|
|
3219
|
+
return this.ctx.http.request({ method: "POST", path: `${this.orderPath(orderId)}/assignees`, auth: auth2, body: assignee });
|
|
3220
|
+
}
|
|
3221
|
+
/** Remove an assignee from an order. */
|
|
3222
|
+
async removeAssignee(orderId, assigneeId, auth2 = SERVICE23) {
|
|
3223
|
+
await this.ctx.http.request({
|
|
3224
|
+
method: "DELETE",
|
|
3225
|
+
path: `${this.orderPath(orderId)}/assignees/${encodeURIComponent(assigneeId)}`,
|
|
3226
|
+
auth: auth2
|
|
3227
|
+
});
|
|
3228
|
+
}
|
|
3229
|
+
/** Update packaging products for an order (`PUT`). Returns an acknowledgement. */
|
|
3230
|
+
async updatePackaging(orderId, change, auth2 = SERVICE23) {
|
|
3231
|
+
return this.ctx.http.request({ method: "PUT", path: `${this.orderPath(orderId)}/packaging`, auth: auth2, body: change });
|
|
3232
|
+
}
|
|
3233
|
+
/** Create a packing event. Returns an acknowledgement. */
|
|
3234
|
+
async createEvent(event, auth2 = SERVICE23) {
|
|
3235
|
+
return this.ctx.http.request({ method: "POST", path: `${this.base()}/events`, auth: auth2, body: event });
|
|
3236
|
+
}
|
|
3237
|
+
/** List packing events. */
|
|
3238
|
+
async listEvents(query = {}, auth2 = SERVICE23) {
|
|
3239
|
+
return this.ctx.http.request({
|
|
3240
|
+
method: "GET",
|
|
3241
|
+
path: `${this.base()}/events`,
|
|
3242
|
+
auth: auth2,
|
|
3243
|
+
...Object.keys(query).length ? { query } : {}
|
|
3244
|
+
});
|
|
3245
|
+
}
|
|
3246
|
+
/** Trigger an order recalculation. Returns the created job's id. */
|
|
3247
|
+
async triggerRecalculation(input, auth2 = SERVICE23) {
|
|
3248
|
+
return this.ctx.http.request({
|
|
3249
|
+
method: "POST",
|
|
3250
|
+
path: `${this.base()}/jobs/recalculations`,
|
|
3251
|
+
auth: auth2,
|
|
3252
|
+
body: input
|
|
3253
|
+
});
|
|
3254
|
+
}
|
|
3255
|
+
/** Retrieve a recalculation job by id. */
|
|
3256
|
+
async getRecalculationJob(jobId, auth2 = SERVICE23) {
|
|
3257
|
+
return this.ctx.http.request({
|
|
3258
|
+
method: "GET",
|
|
3259
|
+
path: `${this.base()}/jobs/recalculations/${encodeURIComponent(jobId)}`,
|
|
3260
|
+
auth: auth2
|
|
3261
|
+
});
|
|
3262
|
+
}
|
|
3263
|
+
};
|
|
3264
|
+
|
|
3265
|
+
// src/services/customer-admin.ts
|
|
3266
|
+
var SERVICE24 = { kind: "service" };
|
|
3267
|
+
var CustomerAdminService = class {
|
|
3268
|
+
constructor(ctx) {
|
|
3269
|
+
this.ctx = ctx;
|
|
3270
|
+
}
|
|
3271
|
+
ctx;
|
|
3272
|
+
base() {
|
|
3273
|
+
return `/customer/${this.ctx.tenant}/customers`;
|
|
3274
|
+
}
|
|
3275
|
+
customerPath(customerNumber) {
|
|
3276
|
+
return `${this.base()}/${encodeURIComponent(customerNumber)}`;
|
|
3277
|
+
}
|
|
3278
|
+
addressPath(customerNumber, addressId) {
|
|
3279
|
+
return `${this.customerPath(customerNumber)}/addresses/${encodeURIComponent(addressId)}`;
|
|
3280
|
+
}
|
|
3281
|
+
// --- Customers ---
|
|
3282
|
+
/** List customers. */
|
|
3283
|
+
async listCustomers(query = {}, auth2 = SERVICE24) {
|
|
3284
|
+
return this.ctx.http.request({
|
|
3285
|
+
method: "GET",
|
|
3286
|
+
path: this.base(),
|
|
3287
|
+
auth: auth2,
|
|
3288
|
+
...Object.keys(query).length ? { query } : {}
|
|
3289
|
+
});
|
|
3290
|
+
}
|
|
3291
|
+
/** Search customers (`POST /customers/search`). */
|
|
3292
|
+
async searchCustomers(query, auth2 = SERVICE24) {
|
|
3293
|
+
return this.ctx.http.request({ method: "POST", path: `${this.base()}/search`, auth: auth2, body: query });
|
|
3294
|
+
}
|
|
3295
|
+
/** Retrieve a customer profile by number. */
|
|
3296
|
+
async getCustomer(customerNumber, auth2 = SERVICE24) {
|
|
3297
|
+
return this.ctx.http.request({ method: "GET", path: this.customerPath(customerNumber), auth: auth2 });
|
|
3298
|
+
}
|
|
3299
|
+
/** Create a customer. */
|
|
3300
|
+
async createCustomer(input, auth2 = SERVICE24) {
|
|
3301
|
+
return this.ctx.http.request({ method: "POST", path: this.base(), auth: auth2, body: input });
|
|
3302
|
+
}
|
|
3303
|
+
/** Upsert a customer profile by number (`PUT`). */
|
|
3304
|
+
async upsertCustomer(customerNumber, input, auth2 = SERVICE24) {
|
|
3305
|
+
return this.ctx.http.request({ method: "PUT", path: this.customerPath(customerNumber), auth: auth2, body: input });
|
|
3306
|
+
}
|
|
3307
|
+
/** Partially update a customer profile (`PATCH`). */
|
|
3308
|
+
async patchCustomer(customerNumber, patch, auth2 = SERVICE24) {
|
|
3309
|
+
await this.ctx.http.request({ method: "PATCH", path: this.customerPath(customerNumber), auth: auth2, body: patch });
|
|
3310
|
+
}
|
|
3311
|
+
/** Delete a customer profile. */
|
|
3312
|
+
async deleteCustomer(customerNumber, auth2 = SERVICE24) {
|
|
3313
|
+
await this.ctx.http.request({ method: "DELETE", path: this.customerPath(customerNumber), auth: auth2 });
|
|
3314
|
+
}
|
|
3315
|
+
// --- Addresses ---
|
|
3316
|
+
/** List a customer's addresses. */
|
|
3317
|
+
async listAddresses(customerNumber, auth2 = SERVICE24) {
|
|
3318
|
+
return this.ctx.http.request({
|
|
3319
|
+
method: "GET",
|
|
3320
|
+
path: `${this.customerPath(customerNumber)}/addresses`,
|
|
3321
|
+
auth: auth2
|
|
3322
|
+
});
|
|
3323
|
+
}
|
|
3324
|
+
/** Retrieve one address. */
|
|
3325
|
+
async getAddress(customerNumber, addressId, auth2 = SERVICE24) {
|
|
3326
|
+
return this.ctx.http.request({ method: "GET", path: this.addressPath(customerNumber, addressId), auth: auth2 });
|
|
3327
|
+
}
|
|
3328
|
+
/** Add an address. */
|
|
3329
|
+
async addAddress(customerNumber, input, auth2 = SERVICE24) {
|
|
3330
|
+
return this.ctx.http.request({
|
|
3331
|
+
method: "POST",
|
|
3332
|
+
path: `${this.customerPath(customerNumber)}/addresses`,
|
|
3333
|
+
auth: auth2,
|
|
3334
|
+
body: input
|
|
3335
|
+
});
|
|
3336
|
+
}
|
|
3337
|
+
/** Upsert an address by id (`PUT`). */
|
|
3338
|
+
async upsertAddress(customerNumber, addressId, input, auth2 = SERVICE24) {
|
|
3339
|
+
return this.ctx.http.request({ method: "PUT", path: this.addressPath(customerNumber, addressId), auth: auth2, body: input });
|
|
3340
|
+
}
|
|
3341
|
+
/** Partially update an address by id (`PATCH`). */
|
|
3342
|
+
async patchAddress(customerNumber, addressId, patch, auth2 = SERVICE24) {
|
|
3343
|
+
await this.ctx.http.request({ method: "PATCH", path: this.addressPath(customerNumber, addressId), auth: auth2, body: patch });
|
|
3344
|
+
}
|
|
3345
|
+
/** Delete an address by id. */
|
|
3346
|
+
async deleteAddress(customerNumber, addressId, auth2 = SERVICE24) {
|
|
3347
|
+
await this.ctx.http.request({ method: "DELETE", path: this.addressPath(customerNumber, addressId), auth: auth2 });
|
|
3348
|
+
}
|
|
3349
|
+
/** Add tags to an address (`?tags=` query). */
|
|
3350
|
+
async addAddressTags(customerNumber, addressId, tags, auth2 = SERVICE24) {
|
|
3351
|
+
await this.ctx.http.request({
|
|
3352
|
+
method: "POST",
|
|
3353
|
+
path: `${this.addressPath(customerNumber, addressId)}/tags`,
|
|
3354
|
+
auth: auth2,
|
|
3355
|
+
query: { tags: tags.join(",") }
|
|
3356
|
+
});
|
|
3357
|
+
}
|
|
3358
|
+
/** Remove tags from an address (`?tags=` query). */
|
|
3359
|
+
async removeAddressTags(customerNumber, addressId, tags, auth2 = SERVICE24) {
|
|
3360
|
+
await this.ctx.http.request({
|
|
3361
|
+
method: "DELETE",
|
|
3362
|
+
path: `${this.addressPath(customerNumber, addressId)}/tags`,
|
|
3363
|
+
auth: auth2,
|
|
3364
|
+
query: { tags: tags.join(",") }
|
|
3365
|
+
});
|
|
3366
|
+
}
|
|
3367
|
+
};
|
|
3368
|
+
|
|
3369
|
+
// src/services/approval.ts
|
|
3370
|
+
var SERVICE25 = { kind: "service" };
|
|
3371
|
+
var ApprovalService = class {
|
|
3372
|
+
constructor(ctx) {
|
|
3373
|
+
this.ctx = ctx;
|
|
3374
|
+
}
|
|
3375
|
+
ctx;
|
|
3376
|
+
base() {
|
|
3377
|
+
return `/approval/${this.ctx.tenant}`;
|
|
3378
|
+
}
|
|
3379
|
+
/** List approvals (paged via `pageNumber`/`pageSize`/`sort`/`q`). Returns an array. */
|
|
3380
|
+
async listApprovals(query = {}, auth2 = SERVICE25) {
|
|
3381
|
+
return this.ctx.http.request({
|
|
3382
|
+
method: "GET",
|
|
3383
|
+
path: `${this.base()}/approvals`,
|
|
3384
|
+
auth: auth2,
|
|
3385
|
+
...Object.keys(query).length ? { query } : {}
|
|
3386
|
+
});
|
|
3387
|
+
}
|
|
3388
|
+
/** Retrieve a single approval by id. */
|
|
3389
|
+
async getApproval(approvalId, auth2 = SERVICE25) {
|
|
3390
|
+
return this.ctx.http.request({
|
|
3391
|
+
method: "GET",
|
|
3392
|
+
path: `${this.base()}/approvals/${encodeURIComponent(approvalId)}`,
|
|
3393
|
+
auth: auth2
|
|
3394
|
+
});
|
|
3395
|
+
}
|
|
3396
|
+
/** Create an approval request (cart or quote). Returns the created `{ id }`. */
|
|
3397
|
+
async createApproval(input, auth2 = SERVICE25) {
|
|
3398
|
+
return this.ctx.http.request({
|
|
3399
|
+
method: "POST",
|
|
3400
|
+
path: `${this.base()}/approvals`,
|
|
3401
|
+
auth: auth2,
|
|
3402
|
+
body: input
|
|
3403
|
+
});
|
|
3404
|
+
}
|
|
3405
|
+
/** Approve/reject/amend an approval via a JSON-Patch op-array (`PATCH`). */
|
|
3406
|
+
async updateApproval(approvalId, ops, auth2 = SERVICE25) {
|
|
3407
|
+
await this.ctx.http.request({
|
|
3408
|
+
method: "PATCH",
|
|
3409
|
+
path: `${this.base()}/approvals/${encodeURIComponent(approvalId)}`,
|
|
3410
|
+
auth: auth2,
|
|
3411
|
+
body: ops
|
|
3412
|
+
});
|
|
3413
|
+
}
|
|
3414
|
+
/** Delete an approval by id. */
|
|
3415
|
+
async deleteApproval(approvalId, auth2 = SERVICE25) {
|
|
3416
|
+
await this.ctx.http.request({
|
|
3417
|
+
method: "DELETE",
|
|
3418
|
+
path: `${this.base()}/approvals/${encodeURIComponent(approvalId)}`,
|
|
3419
|
+
auth: auth2
|
|
3420
|
+
});
|
|
3421
|
+
}
|
|
3422
|
+
/** Check whether an operation on a resource is permitted / needs approval. */
|
|
3423
|
+
async checkPermitted(input, auth2 = SERVICE25) {
|
|
3424
|
+
return this.ctx.http.request({
|
|
3425
|
+
method: "POST",
|
|
3426
|
+
path: `${this.base()}/approval/permitted`,
|
|
3427
|
+
auth: auth2,
|
|
3428
|
+
body: input
|
|
3429
|
+
});
|
|
3430
|
+
}
|
|
3431
|
+
/** Search for users eligible to approve a resource. Returns an array. */
|
|
3432
|
+
async searchApprovers(input, auth2 = SERVICE25) {
|
|
3433
|
+
return this.ctx.http.request({
|
|
3434
|
+
method: "POST",
|
|
3435
|
+
path: `${this.base()}/search/users`,
|
|
3436
|
+
auth: auth2,
|
|
3437
|
+
body: input
|
|
3438
|
+
});
|
|
3439
|
+
}
|
|
3440
|
+
};
|
|
3441
|
+
|
|
2977
3442
|
// package.json
|
|
2978
|
-
var version = "2.
|
|
3443
|
+
var version = "2.6.0";
|
|
2979
3444
|
|
|
2980
3445
|
// src/version.ts
|
|
2981
3446
|
var SDK_VERSION = version;
|
|
@@ -3021,6 +3486,11 @@ var EmporixClient = class {
|
|
|
3021
3486
|
sepaExport;
|
|
3022
3487
|
indexing;
|
|
3023
3488
|
units;
|
|
3489
|
+
catalogs;
|
|
3490
|
+
vendors;
|
|
3491
|
+
pickPack;
|
|
3492
|
+
customerAdmin;
|
|
3493
|
+
approvals;
|
|
3024
3494
|
/** The validated tenant this client is bound to. */
|
|
3025
3495
|
tenant;
|
|
3026
3496
|
/**
|
|
@@ -3037,6 +3507,7 @@ var EmporixClient = class {
|
|
|
3037
3507
|
*/
|
|
3038
3508
|
config;
|
|
3039
3509
|
resolver;
|
|
3510
|
+
customerRefresh;
|
|
3040
3511
|
constructor(config) {
|
|
3041
3512
|
const cfg = validateConfig(config);
|
|
3042
3513
|
this.tenant = cfg.tenant;
|
|
@@ -3058,6 +3529,8 @@ var EmporixClient = class {
|
|
|
3058
3529
|
});
|
|
3059
3530
|
const tokenProvider = cfg.tokenProvider ?? new DefaultTokenProvider(cfg);
|
|
3060
3531
|
this.tokenProvider = tokenProvider;
|
|
3532
|
+
const customerRefresh = new CustomerRefreshRegistry();
|
|
3533
|
+
this.customerRefresh = customerRefresh;
|
|
3061
3534
|
const mk = (service) => ({
|
|
3062
3535
|
tenant: cfg.tenant,
|
|
3063
3536
|
tokenProvider,
|
|
@@ -3067,7 +3540,8 @@ var EmporixClient = class {
|
|
|
3067
3540
|
provider: tokenProvider,
|
|
3068
3541
|
logger: root.child({ service: "http" }),
|
|
3069
3542
|
retry: cfg.retry,
|
|
3070
|
-
timeouts: cfg.timeouts
|
|
3543
|
+
timeouts: cfg.timeouts,
|
|
3544
|
+
customerRefresh
|
|
3071
3545
|
})
|
|
3072
3546
|
});
|
|
3073
3547
|
this.customers = new CustomerService(mk("customer"));
|
|
@@ -3112,6 +3586,11 @@ var EmporixClient = class {
|
|
|
3112
3586
|
this.sepaExport = new SepaExportService(mk("sepa-export"));
|
|
3113
3587
|
this.indexing = new IndexingService(mk("indexing"));
|
|
3114
3588
|
this.units = new UnitHandlingService(mk("unit-handling"));
|
|
3589
|
+
this.catalogs = new CatalogService(mk("catalog"));
|
|
3590
|
+
this.vendors = new VendorService(mk("vendor"));
|
|
3591
|
+
this.pickPack = new PickPackService(mk("pick-pack"));
|
|
3592
|
+
this.customerAdmin = new CustomerAdminService(mk("customer-admin"));
|
|
3593
|
+
this.approvals = new ApprovalService(mk("approval"));
|
|
3115
3594
|
}
|
|
3116
3595
|
/** Sets the runtime log level globally or for one service. */
|
|
3117
3596
|
setLogLevel(level, opts = {}) {
|
|
@@ -3121,8 +3600,17 @@ var EmporixClient = class {
|
|
|
3121
3600
|
getLogLevel(service) {
|
|
3122
3601
|
return this.resolver.get(service);
|
|
3123
3602
|
}
|
|
3603
|
+
/**
|
|
3604
|
+
* Registers (or clears with `null`) a customer-token refresher. When set, a
|
|
3605
|
+
* `customer`-kind 401 triggers one refresh-and-retry. Off by default — the
|
|
3606
|
+
* customer token stays caller-owned. The React `EmporixProvider` wires this
|
|
3607
|
+
* automatically via `autoRefreshCustomerToken`.
|
|
3608
|
+
*/
|
|
3609
|
+
setCustomerTokenRefresher(refresher) {
|
|
3610
|
+
this.customerRefresh.set(refresher);
|
|
3611
|
+
}
|
|
3124
3612
|
};
|
|
3125
3613
|
|
|
3126
|
-
export { AiService, BrandService, ClientConfigService, CountryService, CouponService, CurrencyService, DEFAULT_HOST, DefaultTokenProvider, EmporixClient, FeeService, HttpClient, IndexingService, LEVEL, LabelService, LevelResolver, RagIndexerService, ReturnsService, RewardPointsService, SchemaService, SepaExportService, SequentialIdService, SessionContextService, ShippingService, ShoppingListService, SiteService, TaxService, TenantConfigService, UnitHandlingService, WebhookService, auth, createConsoleLogger, createNoopLogger, redact, resolveToken, validateConfig };
|
|
3614
|
+
export { AiService, ApprovalService, BrandService, CatalogService, ClientConfigService, CountryService, CouponService, CurrencyService, CustomerAdminService, CustomerRefreshRegistry, DEFAULT_HOST, DefaultTokenProvider, EmporixClient, FeeService, HttpClient, IndexingService, LEVEL, LabelService, LevelResolver, PickPackService, RagIndexerService, ReturnsService, RewardPointsService, SchemaService, SepaExportService, SequentialIdService, SessionContextService, ShippingService, ShoppingListService, SiteService, TaxService, TenantConfigService, UnitHandlingService, VendorService, WebhookService, auth, createConsoleLogger, createNoopLogger, redact, resolveToken, validateConfig };
|
|
3127
3615
|
//# sourceMappingURL=index.js.map
|
|
3128
3616
|
//# sourceMappingURL=index.js.map
|