@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.cjs
CHANGED
|
@@ -366,6 +366,26 @@ async function resolveToken(ctx, provider) {
|
|
|
366
366
|
return ctx.token;
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
|
+
var CustomerRefreshRegistry = class {
|
|
370
|
+
refresher = null;
|
|
371
|
+
inflight = null;
|
|
372
|
+
set(refresher) {
|
|
373
|
+
this.refresher = refresher;
|
|
374
|
+
}
|
|
375
|
+
get enabled() {
|
|
376
|
+
return this.refresher !== null;
|
|
377
|
+
}
|
|
378
|
+
/** Concurrent callers share one in-flight refresh. */
|
|
379
|
+
refresh(expiredToken) {
|
|
380
|
+
if (!this.refresher) return Promise.resolve(null);
|
|
381
|
+
if (this.inflight) return this.inflight;
|
|
382
|
+
const p = Promise.resolve(this.refresher.refresh(expiredToken)).finally(() => {
|
|
383
|
+
this.inflight = null;
|
|
384
|
+
});
|
|
385
|
+
this.inflight = p;
|
|
386
|
+
return p;
|
|
387
|
+
}
|
|
388
|
+
};
|
|
369
389
|
var DefaultTokenProvider = class {
|
|
370
390
|
constructor(cfg) {
|
|
371
391
|
this.cfg = cfg;
|
|
@@ -567,8 +587,10 @@ var HttpClient = class {
|
|
|
567
587
|
const sdkManaged = o.auth.kind === "service" || o.auth.kind === "anonymous";
|
|
568
588
|
const maxAttempts = this.opts.retry.maxAttempts;
|
|
569
589
|
let reauthed = false;
|
|
590
|
+
let customerToken = o.auth.kind === "customer" ? o.auth.token : void 0;
|
|
591
|
+
let customerReauthed = false;
|
|
570
592
|
for (let attempt = 1; ; attempt++) {
|
|
571
|
-
const token = await resolveToken(o.auth, this.opts.provider);
|
|
593
|
+
const token = customerToken ?? await resolveToken(o.auth, this.opts.provider);
|
|
572
594
|
log.debug("http request", {
|
|
573
595
|
authKind: o.auth.kind,
|
|
574
596
|
method: o.method,
|
|
@@ -620,6 +642,15 @@ var HttpClient = class {
|
|
|
620
642
|
log.warn("sdk-managed 401, re-authing once", { authKind: o.auth.kind });
|
|
621
643
|
continue;
|
|
622
644
|
}
|
|
645
|
+
if (o.auth.kind === "customer" && !customerReauthed && this.opts.customerRefresh?.enabled) {
|
|
646
|
+
customerReauthed = true;
|
|
647
|
+
const fresh = await this.opts.customerRefresh.refresh(customerToken);
|
|
648
|
+
if (fresh) {
|
|
649
|
+
customerToken = fresh;
|
|
650
|
+
log.warn("customer 401, refreshed once", { authKind: o.auth.kind });
|
|
651
|
+
continue;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
623
654
|
throw errorFromResponse(res.status, `${o.method} ${o.path} \u2192 401`, parsed);
|
|
624
655
|
}
|
|
625
656
|
const retryable = res.status >= 500 || res.status === 429;
|
|
@@ -4507,8 +4538,442 @@ var UnitHandlingService = class {
|
|
|
4507
4538
|
}
|
|
4508
4539
|
};
|
|
4509
4540
|
|
|
4541
|
+
// src/services/catalog.ts
|
|
4542
|
+
var SERVICE23 = { kind: "service" };
|
|
4543
|
+
var CatalogService = class {
|
|
4544
|
+
constructor(ctx) {
|
|
4545
|
+
this.ctx = ctx;
|
|
4546
|
+
}
|
|
4547
|
+
ctx;
|
|
4548
|
+
base() {
|
|
4549
|
+
return `/catalog/${this.ctx.tenant}/catalogs`;
|
|
4550
|
+
}
|
|
4551
|
+
/** List catalogs (filtered/sorted). */
|
|
4552
|
+
async listCatalogs(query = {}, auth2 = SERVICE23) {
|
|
4553
|
+
return this.ctx.http.request({
|
|
4554
|
+
method: "GET",
|
|
4555
|
+
path: this.base(),
|
|
4556
|
+
auth: auth2,
|
|
4557
|
+
...Object.keys(query).length ? { query } : {}
|
|
4558
|
+
});
|
|
4559
|
+
}
|
|
4560
|
+
/** Retrieve a catalog by id. */
|
|
4561
|
+
async getCatalog(catalogId, auth2 = SERVICE23) {
|
|
4562
|
+
return this.ctx.http.request({
|
|
4563
|
+
method: "GET",
|
|
4564
|
+
path: `${this.base()}/${encodeURIComponent(catalogId)}`,
|
|
4565
|
+
auth: auth2
|
|
4566
|
+
});
|
|
4567
|
+
}
|
|
4568
|
+
/** Retrieve all catalogs that contain a category. */
|
|
4569
|
+
async getCatalogsForCategory(categoryId, auth2 = SERVICE23) {
|
|
4570
|
+
return this.ctx.http.request({
|
|
4571
|
+
method: "GET",
|
|
4572
|
+
path: `${this.base()}/categories/${encodeURIComponent(categoryId)}`,
|
|
4573
|
+
auth: auth2
|
|
4574
|
+
});
|
|
4575
|
+
}
|
|
4576
|
+
/** Create a catalog. */
|
|
4577
|
+
async createCatalog(input, auth2 = SERVICE23) {
|
|
4578
|
+
return this.ctx.http.request({ method: "POST", path: this.base(), auth: auth2, body: input });
|
|
4579
|
+
}
|
|
4580
|
+
/** Upsert a catalog by id (`PUT`). */
|
|
4581
|
+
async updateCatalog(catalogId, input, auth2 = SERVICE23) {
|
|
4582
|
+
return this.ctx.http.request({
|
|
4583
|
+
method: "PUT",
|
|
4584
|
+
path: `${this.base()}/${encodeURIComponent(catalogId)}`,
|
|
4585
|
+
auth: auth2,
|
|
4586
|
+
body: input
|
|
4587
|
+
});
|
|
4588
|
+
}
|
|
4589
|
+
/** Partially update a catalog by id (`PATCH`). */
|
|
4590
|
+
async patchCatalog(catalogId, patch, auth2 = SERVICE23) {
|
|
4591
|
+
await this.ctx.http.request({
|
|
4592
|
+
method: "PATCH",
|
|
4593
|
+
path: `${this.base()}/${encodeURIComponent(catalogId)}`,
|
|
4594
|
+
auth: auth2,
|
|
4595
|
+
body: patch
|
|
4596
|
+
});
|
|
4597
|
+
}
|
|
4598
|
+
/** Remove a catalog by id. */
|
|
4599
|
+
async deleteCatalog(catalogId, auth2 = SERVICE23) {
|
|
4600
|
+
await this.ctx.http.request({
|
|
4601
|
+
method: "DELETE",
|
|
4602
|
+
path: `${this.base()}/${encodeURIComponent(catalogId)}`,
|
|
4603
|
+
auth: auth2
|
|
4604
|
+
});
|
|
4605
|
+
}
|
|
4606
|
+
};
|
|
4607
|
+
|
|
4608
|
+
// src/services/vendor.ts
|
|
4609
|
+
var SERVICE24 = { kind: "service" };
|
|
4610
|
+
var VendorService = class {
|
|
4611
|
+
constructor(ctx) {
|
|
4612
|
+
this.ctx = ctx;
|
|
4613
|
+
}
|
|
4614
|
+
ctx;
|
|
4615
|
+
base() {
|
|
4616
|
+
return `/vendor/${this.ctx.tenant}`;
|
|
4617
|
+
}
|
|
4618
|
+
// --- Vendors ---
|
|
4619
|
+
/** List all vendors. */
|
|
4620
|
+
async listVendors(query = {}, auth2 = SERVICE24) {
|
|
4621
|
+
return this.ctx.http.request({
|
|
4622
|
+
method: "GET",
|
|
4623
|
+
path: `${this.base()}/vendors`,
|
|
4624
|
+
auth: auth2,
|
|
4625
|
+
...Object.keys(query).length ? { query } : {}
|
|
4626
|
+
});
|
|
4627
|
+
}
|
|
4628
|
+
/** Retrieve a vendor by id. */
|
|
4629
|
+
async getVendor(vendorId, auth2 = SERVICE24) {
|
|
4630
|
+
return this.ctx.http.request({
|
|
4631
|
+
method: "GET",
|
|
4632
|
+
path: `${this.base()}/vendors/${encodeURIComponent(vendorId)}`,
|
|
4633
|
+
auth: auth2
|
|
4634
|
+
});
|
|
4635
|
+
}
|
|
4636
|
+
/** Search vendors (`POST /vendors/search`). */
|
|
4637
|
+
async searchVendors(query, auth2 = SERVICE24) {
|
|
4638
|
+
return this.ctx.http.request({
|
|
4639
|
+
method: "POST",
|
|
4640
|
+
path: `${this.base()}/vendors/search`,
|
|
4641
|
+
auth: auth2,
|
|
4642
|
+
body: query
|
|
4643
|
+
});
|
|
4644
|
+
}
|
|
4645
|
+
/** Create a vendor. */
|
|
4646
|
+
async createVendor(input, auth2 = SERVICE24) {
|
|
4647
|
+
return this.ctx.http.request({ method: "POST", path: `${this.base()}/vendors`, auth: auth2, body: input });
|
|
4648
|
+
}
|
|
4649
|
+
/** Upsert a vendor by id (`PUT`). */
|
|
4650
|
+
async updateVendor(vendorId, input, auth2 = SERVICE24) {
|
|
4651
|
+
await this.ctx.http.request({
|
|
4652
|
+
method: "PUT",
|
|
4653
|
+
path: `${this.base()}/vendors/${encodeURIComponent(vendorId)}`,
|
|
4654
|
+
auth: auth2,
|
|
4655
|
+
body: input
|
|
4656
|
+
});
|
|
4657
|
+
}
|
|
4658
|
+
/** Delete a vendor by id. */
|
|
4659
|
+
async deleteVendor(vendorId, auth2 = SERVICE24) {
|
|
4660
|
+
await this.ctx.http.request({
|
|
4661
|
+
method: "DELETE",
|
|
4662
|
+
path: `${this.base()}/vendors/${encodeURIComponent(vendorId)}`,
|
|
4663
|
+
auth: auth2
|
|
4664
|
+
});
|
|
4665
|
+
}
|
|
4666
|
+
// --- Vendor locations ---
|
|
4667
|
+
/** List all vendor locations. */
|
|
4668
|
+
async listVendorLocations(query = {}, auth2 = SERVICE24) {
|
|
4669
|
+
return this.ctx.http.request({
|
|
4670
|
+
method: "GET",
|
|
4671
|
+
path: `${this.base()}/locations`,
|
|
4672
|
+
auth: auth2,
|
|
4673
|
+
...Object.keys(query).length ? { query } : {}
|
|
4674
|
+
});
|
|
4675
|
+
}
|
|
4676
|
+
/** Retrieve a vendor location by id. */
|
|
4677
|
+
async getVendorLocation(locationId, auth2 = SERVICE24) {
|
|
4678
|
+
return this.ctx.http.request({
|
|
4679
|
+
method: "GET",
|
|
4680
|
+
path: `${this.base()}/locations/${encodeURIComponent(locationId)}`,
|
|
4681
|
+
auth: auth2
|
|
4682
|
+
});
|
|
4683
|
+
}
|
|
4684
|
+
/** Create a vendor location. */
|
|
4685
|
+
async createVendorLocation(input, auth2 = SERVICE24) {
|
|
4686
|
+
return this.ctx.http.request({ method: "POST", path: `${this.base()}/locations`, auth: auth2, body: input });
|
|
4687
|
+
}
|
|
4688
|
+
/** Upsert a vendor location by id (`PUT`). */
|
|
4689
|
+
async updateVendorLocation(locationId, input, auth2 = SERVICE24) {
|
|
4690
|
+
await this.ctx.http.request({
|
|
4691
|
+
method: "PUT",
|
|
4692
|
+
path: `${this.base()}/locations/${encodeURIComponent(locationId)}`,
|
|
4693
|
+
auth: auth2,
|
|
4694
|
+
body: input
|
|
4695
|
+
});
|
|
4696
|
+
}
|
|
4697
|
+
/** Delete a vendor location by id. */
|
|
4698
|
+
async deleteVendorLocation(locationId, auth2 = SERVICE24) {
|
|
4699
|
+
await this.ctx.http.request({
|
|
4700
|
+
method: "DELETE",
|
|
4701
|
+
path: `${this.base()}/locations/${encodeURIComponent(locationId)}`,
|
|
4702
|
+
auth: auth2
|
|
4703
|
+
});
|
|
4704
|
+
}
|
|
4705
|
+
};
|
|
4706
|
+
|
|
4707
|
+
// src/services/pick-pack.ts
|
|
4708
|
+
var SERVICE25 = { kind: "service" };
|
|
4709
|
+
var PickPackService = class {
|
|
4710
|
+
constructor(ctx) {
|
|
4711
|
+
this.ctx = ctx;
|
|
4712
|
+
}
|
|
4713
|
+
ctx;
|
|
4714
|
+
base() {
|
|
4715
|
+
return `/pick-pack/${this.ctx.tenant}`;
|
|
4716
|
+
}
|
|
4717
|
+
orderPath(orderId) {
|
|
4718
|
+
return `${this.base()}/orders/${encodeURIComponent(orderId)}`;
|
|
4719
|
+
}
|
|
4720
|
+
/** List packlist orders. */
|
|
4721
|
+
async listOrders(query = {}, auth2 = SERVICE25) {
|
|
4722
|
+
return this.ctx.http.request({
|
|
4723
|
+
method: "GET",
|
|
4724
|
+
path: `${this.base()}/orders`,
|
|
4725
|
+
auth: auth2,
|
|
4726
|
+
...Object.keys(query).length ? { query } : {}
|
|
4727
|
+
});
|
|
4728
|
+
}
|
|
4729
|
+
/** Retrieve a packlist order by id. */
|
|
4730
|
+
async getOrder(orderId, auth2 = SERVICE25) {
|
|
4731
|
+
return this.ctx.http.request({ method: "GET", path: this.orderPath(orderId), auth: auth2 });
|
|
4732
|
+
}
|
|
4733
|
+
/** Update an order's status (`PATCH`). Returns an acknowledgement. */
|
|
4734
|
+
async updateOrder(orderId, change, auth2 = SERVICE25) {
|
|
4735
|
+
return this.ctx.http.request({ method: "PATCH", path: this.orderPath(orderId), auth: auth2, body: change });
|
|
4736
|
+
}
|
|
4737
|
+
/** Finish an order. Returns an acknowledgement. */
|
|
4738
|
+
async finishOrder(orderId, auth2 = SERVICE25) {
|
|
4739
|
+
return this.ctx.http.request({ method: "POST", path: `${this.orderPath(orderId)}/finish`, auth: auth2 });
|
|
4740
|
+
}
|
|
4741
|
+
/** List order cycles (ids). */
|
|
4742
|
+
async listOrderCycles(query = {}, auth2 = SERVICE25) {
|
|
4743
|
+
return this.ctx.http.request({
|
|
4744
|
+
method: "GET",
|
|
4745
|
+
path: `${this.base()}/orderCycles`,
|
|
4746
|
+
auth: auth2,
|
|
4747
|
+
...Object.keys(query).length ? { query } : {}
|
|
4748
|
+
});
|
|
4749
|
+
}
|
|
4750
|
+
/** Add an assignee to an order. Returns an acknowledgement. */
|
|
4751
|
+
async addAssignee(orderId, assignee, auth2 = SERVICE25) {
|
|
4752
|
+
return this.ctx.http.request({ method: "POST", path: `${this.orderPath(orderId)}/assignees`, auth: auth2, body: assignee });
|
|
4753
|
+
}
|
|
4754
|
+
/** Remove an assignee from an order. */
|
|
4755
|
+
async removeAssignee(orderId, assigneeId, auth2 = SERVICE25) {
|
|
4756
|
+
await this.ctx.http.request({
|
|
4757
|
+
method: "DELETE",
|
|
4758
|
+
path: `${this.orderPath(orderId)}/assignees/${encodeURIComponent(assigneeId)}`,
|
|
4759
|
+
auth: auth2
|
|
4760
|
+
});
|
|
4761
|
+
}
|
|
4762
|
+
/** Update packaging products for an order (`PUT`). Returns an acknowledgement. */
|
|
4763
|
+
async updatePackaging(orderId, change, auth2 = SERVICE25) {
|
|
4764
|
+
return this.ctx.http.request({ method: "PUT", path: `${this.orderPath(orderId)}/packaging`, auth: auth2, body: change });
|
|
4765
|
+
}
|
|
4766
|
+
/** Create a packing event. Returns an acknowledgement. */
|
|
4767
|
+
async createEvent(event, auth2 = SERVICE25) {
|
|
4768
|
+
return this.ctx.http.request({ method: "POST", path: `${this.base()}/events`, auth: auth2, body: event });
|
|
4769
|
+
}
|
|
4770
|
+
/** List packing events. */
|
|
4771
|
+
async listEvents(query = {}, auth2 = SERVICE25) {
|
|
4772
|
+
return this.ctx.http.request({
|
|
4773
|
+
method: "GET",
|
|
4774
|
+
path: `${this.base()}/events`,
|
|
4775
|
+
auth: auth2,
|
|
4776
|
+
...Object.keys(query).length ? { query } : {}
|
|
4777
|
+
});
|
|
4778
|
+
}
|
|
4779
|
+
/** Trigger an order recalculation. Returns the created job's id. */
|
|
4780
|
+
async triggerRecalculation(input, auth2 = SERVICE25) {
|
|
4781
|
+
return this.ctx.http.request({
|
|
4782
|
+
method: "POST",
|
|
4783
|
+
path: `${this.base()}/jobs/recalculations`,
|
|
4784
|
+
auth: auth2,
|
|
4785
|
+
body: input
|
|
4786
|
+
});
|
|
4787
|
+
}
|
|
4788
|
+
/** Retrieve a recalculation job by id. */
|
|
4789
|
+
async getRecalculationJob(jobId, auth2 = SERVICE25) {
|
|
4790
|
+
return this.ctx.http.request({
|
|
4791
|
+
method: "GET",
|
|
4792
|
+
path: `${this.base()}/jobs/recalculations/${encodeURIComponent(jobId)}`,
|
|
4793
|
+
auth: auth2
|
|
4794
|
+
});
|
|
4795
|
+
}
|
|
4796
|
+
};
|
|
4797
|
+
|
|
4798
|
+
// src/services/customer-admin.ts
|
|
4799
|
+
var SERVICE26 = { kind: "service" };
|
|
4800
|
+
var CustomerAdminService = class {
|
|
4801
|
+
constructor(ctx) {
|
|
4802
|
+
this.ctx = ctx;
|
|
4803
|
+
}
|
|
4804
|
+
ctx;
|
|
4805
|
+
base() {
|
|
4806
|
+
return `/customer/${this.ctx.tenant}/customers`;
|
|
4807
|
+
}
|
|
4808
|
+
customerPath(customerNumber) {
|
|
4809
|
+
return `${this.base()}/${encodeURIComponent(customerNumber)}`;
|
|
4810
|
+
}
|
|
4811
|
+
addressPath(customerNumber, addressId) {
|
|
4812
|
+
return `${this.customerPath(customerNumber)}/addresses/${encodeURIComponent(addressId)}`;
|
|
4813
|
+
}
|
|
4814
|
+
// --- Customers ---
|
|
4815
|
+
/** List customers. */
|
|
4816
|
+
async listCustomers(query = {}, auth2 = SERVICE26) {
|
|
4817
|
+
return this.ctx.http.request({
|
|
4818
|
+
method: "GET",
|
|
4819
|
+
path: this.base(),
|
|
4820
|
+
auth: auth2,
|
|
4821
|
+
...Object.keys(query).length ? { query } : {}
|
|
4822
|
+
});
|
|
4823
|
+
}
|
|
4824
|
+
/** Search customers (`POST /customers/search`). */
|
|
4825
|
+
async searchCustomers(query, auth2 = SERVICE26) {
|
|
4826
|
+
return this.ctx.http.request({ method: "POST", path: `${this.base()}/search`, auth: auth2, body: query });
|
|
4827
|
+
}
|
|
4828
|
+
/** Retrieve a customer profile by number. */
|
|
4829
|
+
async getCustomer(customerNumber, auth2 = SERVICE26) {
|
|
4830
|
+
return this.ctx.http.request({ method: "GET", path: this.customerPath(customerNumber), auth: auth2 });
|
|
4831
|
+
}
|
|
4832
|
+
/** Create a customer. */
|
|
4833
|
+
async createCustomer(input, auth2 = SERVICE26) {
|
|
4834
|
+
return this.ctx.http.request({ method: "POST", path: this.base(), auth: auth2, body: input });
|
|
4835
|
+
}
|
|
4836
|
+
/** Upsert a customer profile by number (`PUT`). */
|
|
4837
|
+
async upsertCustomer(customerNumber, input, auth2 = SERVICE26) {
|
|
4838
|
+
return this.ctx.http.request({ method: "PUT", path: this.customerPath(customerNumber), auth: auth2, body: input });
|
|
4839
|
+
}
|
|
4840
|
+
/** Partially update a customer profile (`PATCH`). */
|
|
4841
|
+
async patchCustomer(customerNumber, patch, auth2 = SERVICE26) {
|
|
4842
|
+
await this.ctx.http.request({ method: "PATCH", path: this.customerPath(customerNumber), auth: auth2, body: patch });
|
|
4843
|
+
}
|
|
4844
|
+
/** Delete a customer profile. */
|
|
4845
|
+
async deleteCustomer(customerNumber, auth2 = SERVICE26) {
|
|
4846
|
+
await this.ctx.http.request({ method: "DELETE", path: this.customerPath(customerNumber), auth: auth2 });
|
|
4847
|
+
}
|
|
4848
|
+
// --- Addresses ---
|
|
4849
|
+
/** List a customer's addresses. */
|
|
4850
|
+
async listAddresses(customerNumber, auth2 = SERVICE26) {
|
|
4851
|
+
return this.ctx.http.request({
|
|
4852
|
+
method: "GET",
|
|
4853
|
+
path: `${this.customerPath(customerNumber)}/addresses`,
|
|
4854
|
+
auth: auth2
|
|
4855
|
+
});
|
|
4856
|
+
}
|
|
4857
|
+
/** Retrieve one address. */
|
|
4858
|
+
async getAddress(customerNumber, addressId, auth2 = SERVICE26) {
|
|
4859
|
+
return this.ctx.http.request({ method: "GET", path: this.addressPath(customerNumber, addressId), auth: auth2 });
|
|
4860
|
+
}
|
|
4861
|
+
/** Add an address. */
|
|
4862
|
+
async addAddress(customerNumber, input, auth2 = SERVICE26) {
|
|
4863
|
+
return this.ctx.http.request({
|
|
4864
|
+
method: "POST",
|
|
4865
|
+
path: `${this.customerPath(customerNumber)}/addresses`,
|
|
4866
|
+
auth: auth2,
|
|
4867
|
+
body: input
|
|
4868
|
+
});
|
|
4869
|
+
}
|
|
4870
|
+
/** Upsert an address by id (`PUT`). */
|
|
4871
|
+
async upsertAddress(customerNumber, addressId, input, auth2 = SERVICE26) {
|
|
4872
|
+
return this.ctx.http.request({ method: "PUT", path: this.addressPath(customerNumber, addressId), auth: auth2, body: input });
|
|
4873
|
+
}
|
|
4874
|
+
/** Partially update an address by id (`PATCH`). */
|
|
4875
|
+
async patchAddress(customerNumber, addressId, patch, auth2 = SERVICE26) {
|
|
4876
|
+
await this.ctx.http.request({ method: "PATCH", path: this.addressPath(customerNumber, addressId), auth: auth2, body: patch });
|
|
4877
|
+
}
|
|
4878
|
+
/** Delete an address by id. */
|
|
4879
|
+
async deleteAddress(customerNumber, addressId, auth2 = SERVICE26) {
|
|
4880
|
+
await this.ctx.http.request({ method: "DELETE", path: this.addressPath(customerNumber, addressId), auth: auth2 });
|
|
4881
|
+
}
|
|
4882
|
+
/** Add tags to an address (`?tags=` query). */
|
|
4883
|
+
async addAddressTags(customerNumber, addressId, tags, auth2 = SERVICE26) {
|
|
4884
|
+
await this.ctx.http.request({
|
|
4885
|
+
method: "POST",
|
|
4886
|
+
path: `${this.addressPath(customerNumber, addressId)}/tags`,
|
|
4887
|
+
auth: auth2,
|
|
4888
|
+
query: { tags: tags.join(",") }
|
|
4889
|
+
});
|
|
4890
|
+
}
|
|
4891
|
+
/** Remove tags from an address (`?tags=` query). */
|
|
4892
|
+
async removeAddressTags(customerNumber, addressId, tags, auth2 = SERVICE26) {
|
|
4893
|
+
await this.ctx.http.request({
|
|
4894
|
+
method: "DELETE",
|
|
4895
|
+
path: `${this.addressPath(customerNumber, addressId)}/tags`,
|
|
4896
|
+
auth: auth2,
|
|
4897
|
+
query: { tags: tags.join(",") }
|
|
4898
|
+
});
|
|
4899
|
+
}
|
|
4900
|
+
};
|
|
4901
|
+
|
|
4902
|
+
// src/services/approval.ts
|
|
4903
|
+
var SERVICE27 = { kind: "service" };
|
|
4904
|
+
var ApprovalService = class {
|
|
4905
|
+
constructor(ctx) {
|
|
4906
|
+
this.ctx = ctx;
|
|
4907
|
+
}
|
|
4908
|
+
ctx;
|
|
4909
|
+
base() {
|
|
4910
|
+
return `/approval/${this.ctx.tenant}`;
|
|
4911
|
+
}
|
|
4912
|
+
/** List approvals (paged via `pageNumber`/`pageSize`/`sort`/`q`). Returns an array. */
|
|
4913
|
+
async listApprovals(query = {}, auth2 = SERVICE27) {
|
|
4914
|
+
return this.ctx.http.request({
|
|
4915
|
+
method: "GET",
|
|
4916
|
+
path: `${this.base()}/approvals`,
|
|
4917
|
+
auth: auth2,
|
|
4918
|
+
...Object.keys(query).length ? { query } : {}
|
|
4919
|
+
});
|
|
4920
|
+
}
|
|
4921
|
+
/** Retrieve a single approval by id. */
|
|
4922
|
+
async getApproval(approvalId, auth2 = SERVICE27) {
|
|
4923
|
+
return this.ctx.http.request({
|
|
4924
|
+
method: "GET",
|
|
4925
|
+
path: `${this.base()}/approvals/${encodeURIComponent(approvalId)}`,
|
|
4926
|
+
auth: auth2
|
|
4927
|
+
});
|
|
4928
|
+
}
|
|
4929
|
+
/** Create an approval request (cart or quote). Returns the created `{ id }`. */
|
|
4930
|
+
async createApproval(input, auth2 = SERVICE27) {
|
|
4931
|
+
return this.ctx.http.request({
|
|
4932
|
+
method: "POST",
|
|
4933
|
+
path: `${this.base()}/approvals`,
|
|
4934
|
+
auth: auth2,
|
|
4935
|
+
body: input
|
|
4936
|
+
});
|
|
4937
|
+
}
|
|
4938
|
+
/** Approve/reject/amend an approval via a JSON-Patch op-array (`PATCH`). */
|
|
4939
|
+
async updateApproval(approvalId, ops, auth2 = SERVICE27) {
|
|
4940
|
+
await this.ctx.http.request({
|
|
4941
|
+
method: "PATCH",
|
|
4942
|
+
path: `${this.base()}/approvals/${encodeURIComponent(approvalId)}`,
|
|
4943
|
+
auth: auth2,
|
|
4944
|
+
body: ops
|
|
4945
|
+
});
|
|
4946
|
+
}
|
|
4947
|
+
/** Delete an approval by id. */
|
|
4948
|
+
async deleteApproval(approvalId, auth2 = SERVICE27) {
|
|
4949
|
+
await this.ctx.http.request({
|
|
4950
|
+
method: "DELETE",
|
|
4951
|
+
path: `${this.base()}/approvals/${encodeURIComponent(approvalId)}`,
|
|
4952
|
+
auth: auth2
|
|
4953
|
+
});
|
|
4954
|
+
}
|
|
4955
|
+
/** Check whether an operation on a resource is permitted / needs approval. */
|
|
4956
|
+
async checkPermitted(input, auth2 = SERVICE27) {
|
|
4957
|
+
return this.ctx.http.request({
|
|
4958
|
+
method: "POST",
|
|
4959
|
+
path: `${this.base()}/approval/permitted`,
|
|
4960
|
+
auth: auth2,
|
|
4961
|
+
body: input
|
|
4962
|
+
});
|
|
4963
|
+
}
|
|
4964
|
+
/** Search for users eligible to approve a resource. Returns an array. */
|
|
4965
|
+
async searchApprovers(input, auth2 = SERVICE27) {
|
|
4966
|
+
return this.ctx.http.request({
|
|
4967
|
+
method: "POST",
|
|
4968
|
+
path: `${this.base()}/search/users`,
|
|
4969
|
+
auth: auth2,
|
|
4970
|
+
body: input
|
|
4971
|
+
});
|
|
4972
|
+
}
|
|
4973
|
+
};
|
|
4974
|
+
|
|
4510
4975
|
// package.json
|
|
4511
|
-
var version = "2.
|
|
4976
|
+
var version = "2.6.0";
|
|
4512
4977
|
|
|
4513
4978
|
// src/version.ts
|
|
4514
4979
|
var SDK_VERSION = version;
|
|
@@ -4554,6 +5019,11 @@ var EmporixClient = class {
|
|
|
4554
5019
|
sepaExport;
|
|
4555
5020
|
indexing;
|
|
4556
5021
|
units;
|
|
5022
|
+
catalogs;
|
|
5023
|
+
vendors;
|
|
5024
|
+
pickPack;
|
|
5025
|
+
customerAdmin;
|
|
5026
|
+
approvals;
|
|
4557
5027
|
/** The validated tenant this client is bound to. */
|
|
4558
5028
|
tenant;
|
|
4559
5029
|
/**
|
|
@@ -4570,6 +5040,7 @@ var EmporixClient = class {
|
|
|
4570
5040
|
*/
|
|
4571
5041
|
config;
|
|
4572
5042
|
resolver;
|
|
5043
|
+
customerRefresh;
|
|
4573
5044
|
constructor(config) {
|
|
4574
5045
|
const cfg = validateConfig(config);
|
|
4575
5046
|
this.tenant = cfg.tenant;
|
|
@@ -4591,6 +5062,8 @@ var EmporixClient = class {
|
|
|
4591
5062
|
});
|
|
4592
5063
|
const tokenProvider = cfg.tokenProvider ?? new DefaultTokenProvider(cfg);
|
|
4593
5064
|
this.tokenProvider = tokenProvider;
|
|
5065
|
+
const customerRefresh = new CustomerRefreshRegistry();
|
|
5066
|
+
this.customerRefresh = customerRefresh;
|
|
4594
5067
|
const mk = (service) => ({
|
|
4595
5068
|
tenant: cfg.tenant,
|
|
4596
5069
|
tokenProvider,
|
|
@@ -4600,7 +5073,8 @@ var EmporixClient = class {
|
|
|
4600
5073
|
provider: tokenProvider,
|
|
4601
5074
|
logger: root.child({ service: "http" }),
|
|
4602
5075
|
retry: cfg.retry,
|
|
4603
|
-
timeouts: cfg.timeouts
|
|
5076
|
+
timeouts: cfg.timeouts,
|
|
5077
|
+
customerRefresh
|
|
4604
5078
|
})
|
|
4605
5079
|
});
|
|
4606
5080
|
this.customers = new CustomerService(mk("customer"));
|
|
@@ -4645,6 +5119,11 @@ var EmporixClient = class {
|
|
|
4645
5119
|
this.sepaExport = new SepaExportService(mk("sepa-export"));
|
|
4646
5120
|
this.indexing = new IndexingService(mk("indexing"));
|
|
4647
5121
|
this.units = new UnitHandlingService(mk("unit-handling"));
|
|
5122
|
+
this.catalogs = new CatalogService(mk("catalog"));
|
|
5123
|
+
this.vendors = new VendorService(mk("vendor"));
|
|
5124
|
+
this.pickPack = new PickPackService(mk("pick-pack"));
|
|
5125
|
+
this.customerAdmin = new CustomerAdminService(mk("customer-admin"));
|
|
5126
|
+
this.approvals = new ApprovalService(mk("approval"));
|
|
4648
5127
|
}
|
|
4649
5128
|
/** Sets the runtime log level globally or for one service. */
|
|
4650
5129
|
setLogLevel(level, opts = {}) {
|
|
@@ -4654,12 +5133,23 @@ var EmporixClient = class {
|
|
|
4654
5133
|
getLogLevel(service) {
|
|
4655
5134
|
return this.resolver.get(service);
|
|
4656
5135
|
}
|
|
5136
|
+
/**
|
|
5137
|
+
* Registers (or clears with `null`) a customer-token refresher. When set, a
|
|
5138
|
+
* `customer`-kind 401 triggers one refresh-and-retry. Off by default — the
|
|
5139
|
+
* customer token stays caller-owned. The React `EmporixProvider` wires this
|
|
5140
|
+
* automatically via `autoRefreshCustomerToken`.
|
|
5141
|
+
*/
|
|
5142
|
+
setCustomerTokenRefresher(refresher) {
|
|
5143
|
+
this.customerRefresh.set(refresher);
|
|
5144
|
+
}
|
|
4657
5145
|
};
|
|
4658
5146
|
|
|
4659
5147
|
exports.AiService = AiService;
|
|
5148
|
+
exports.ApprovalService = ApprovalService;
|
|
4660
5149
|
exports.AvailabilityService = AvailabilityService;
|
|
4661
5150
|
exports.BrandService = BrandService;
|
|
4662
5151
|
exports.CartService = CartService;
|
|
5152
|
+
exports.CatalogService = CatalogService;
|
|
4663
5153
|
exports.CategoryService = CategoryService;
|
|
4664
5154
|
exports.CheckoutService = CheckoutService;
|
|
4665
5155
|
exports.ClientConfigService = ClientConfigService;
|
|
@@ -4668,7 +5158,9 @@ exports.ContactsService = ContactsService;
|
|
|
4668
5158
|
exports.CountryService = CountryService;
|
|
4669
5159
|
exports.CouponService = CouponService;
|
|
4670
5160
|
exports.CurrencyService = CurrencyService;
|
|
5161
|
+
exports.CustomerAdminService = CustomerAdminService;
|
|
4671
5162
|
exports.CustomerGroupsService = CustomerGroupsService;
|
|
5163
|
+
exports.CustomerRefreshRegistry = CustomerRefreshRegistry;
|
|
4672
5164
|
exports.CustomerService = CustomerService;
|
|
4673
5165
|
exports.DEFAULT_HOST = DEFAULT_HOST;
|
|
4674
5166
|
exports.DefaultTokenProvider = DefaultTokenProvider;
|
|
@@ -4690,6 +5182,7 @@ exports.LocationsService = LocationsService;
|
|
|
4690
5182
|
exports.MediaService = MediaService;
|
|
4691
5183
|
exports.OrdersService = OrdersService;
|
|
4692
5184
|
exports.PaymentGatewayService = PaymentGatewayService;
|
|
5185
|
+
exports.PickPackService = PickPackService;
|
|
4693
5186
|
exports.PriceService = PriceService;
|
|
4694
5187
|
exports.ProductService = ProductService;
|
|
4695
5188
|
exports.RagIndexerService = RagIndexerService;
|
|
@@ -4707,6 +5200,7 @@ exports.SiteService = SiteService;
|
|
|
4707
5200
|
exports.TaxService = TaxService;
|
|
4708
5201
|
exports.TenantConfigService = TenantConfigService;
|
|
4709
5202
|
exports.UnitHandlingService = UnitHandlingService;
|
|
5203
|
+
exports.VendorService = VendorService;
|
|
4710
5204
|
exports.WebhookService = WebhookService;
|
|
4711
5205
|
exports.auth = auth;
|
|
4712
5206
|
exports.createConsoleLogger = createConsoleLogger;
|