@viu/emporix-sdk 2.33.5 → 2.35.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 +60 -0
- package/dist/index.cjs +83 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +207 -2
- package/dist/index.d.ts +207 -2
- package/dist/index.js +82 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -39,6 +39,17 @@ export { EmporixAuthError, EmporixError, EmporixForbiddenError, EmporixInsuffici
|
|
|
39
39
|
// src/core/config.ts
|
|
40
40
|
var DEFAULT_HOST = "https://api.emporix.io";
|
|
41
41
|
var TENANT_RE = /^[a-z][a-z0-9]{2,15}$/;
|
|
42
|
+
function warnOnMisplacedContext(input) {
|
|
43
|
+
if (!("context" in input)) return;
|
|
44
|
+
const logger = input.logger;
|
|
45
|
+
if (logger === false) return;
|
|
46
|
+
const message = "EmporixConfig has no top-level `context` \u2014 it is being ignored. Move it into `credentials.storefront.context`, otherwise the anonymous token carries no site/currency/country and price matching returns an empty list without erroring.";
|
|
47
|
+
if (logger && typeof logger.warn === "function") {
|
|
48
|
+
logger.warn(message);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
console.warn(`[emporix] ${message}`);
|
|
52
|
+
}
|
|
42
53
|
function validateConfig(input) {
|
|
43
54
|
if (!TENANT_RE.test(input.tenant)) {
|
|
44
55
|
throw new Error(
|
|
@@ -48,6 +59,7 @@ function validateConfig(input) {
|
|
|
48
59
|
if (!input.credentials) {
|
|
49
60
|
throw new Error("credentials is required (provide at least one of backend/storefront/custom)");
|
|
50
61
|
}
|
|
62
|
+
warnOnMisplacedContext(input);
|
|
51
63
|
return {
|
|
52
64
|
tenant: input.tenant,
|
|
53
65
|
host: input.host ?? DEFAULT_HOST,
|
|
@@ -686,7 +698,7 @@ var HttpClient = class {
|
|
|
686
698
|
};
|
|
687
699
|
|
|
688
700
|
// package.json
|
|
689
|
-
var version = "2.
|
|
701
|
+
var version = "2.35.0";
|
|
690
702
|
|
|
691
703
|
// src/version.ts
|
|
692
704
|
var SDK_VERSION = version;
|
|
@@ -4604,6 +4616,9 @@ var CustomerAdminService = class {
|
|
|
4604
4616
|
customerPath(customerNumber) {
|
|
4605
4617
|
return `${this.base()}/${encodeURIComponent(customerNumber)}`;
|
|
4606
4618
|
}
|
|
4619
|
+
configPath() {
|
|
4620
|
+
return `/customer/${this.ctx.tenant}/config/password-migration-retention`;
|
|
4621
|
+
}
|
|
4607
4622
|
addressPath(customerNumber, addressId) {
|
|
4608
4623
|
return `${this.customerPath(customerNumber)}/addresses/${encodeURIComponent(addressId)}`;
|
|
4609
4624
|
}
|
|
@@ -4694,6 +4709,59 @@ var CustomerAdminService = class {
|
|
|
4694
4709
|
query: { tags: tags.join(",") }
|
|
4695
4710
|
});
|
|
4696
4711
|
}
|
|
4712
|
+
// --- Password-migration retention ---
|
|
4713
|
+
/**
|
|
4714
|
+
* Retrieves the tenant's password-migration retention config. Requires the
|
|
4715
|
+
* `customer.import_read` scope. An unconfigured tenant answers with an empty
|
|
4716
|
+
* object rather than a 404.
|
|
4717
|
+
*/
|
|
4718
|
+
async getPasswordMigrationRetention(auth2 = SERVICE28) {
|
|
4719
|
+
return this.ctx.http.request({
|
|
4720
|
+
method: "GET",
|
|
4721
|
+
path: this.configPath(),
|
|
4722
|
+
auth: auth2
|
|
4723
|
+
});
|
|
4724
|
+
}
|
|
4725
|
+
/**
|
|
4726
|
+
* Creates or updates the retention config (`POST`). Requires the
|
|
4727
|
+
* `customer.import_manage` scope. **Call this before importing customers with
|
|
4728
|
+
* `legacyAuth`** — that import is rejected without an active config. Re-POST with
|
|
4729
|
+
* an earlier `retentionEndDate` to shorten a running window.
|
|
4730
|
+
*/
|
|
4731
|
+
async configurePasswordMigrationRetention(input, auth2 = SERVICE28) {
|
|
4732
|
+
return this.ctx.http.request({
|
|
4733
|
+
method: "POST",
|
|
4734
|
+
path: this.configPath(),
|
|
4735
|
+
auth: auth2,
|
|
4736
|
+
body: input
|
|
4737
|
+
});
|
|
4738
|
+
}
|
|
4739
|
+
/**
|
|
4740
|
+
* Removes the retention config. Requires the `customer.import_manage` scope.
|
|
4741
|
+
* Intended for after the migration window: when the window ends, unmigrated
|
|
4742
|
+
* accounts need a password reset and their legacy credentials are cleared.
|
|
4743
|
+
*/
|
|
4744
|
+
async deletePasswordMigrationRetention(auth2 = SERVICE28) {
|
|
4745
|
+
await this.ctx.http.request({ method: "DELETE", path: this.configPath(), auth: auth2 });
|
|
4746
|
+
}
|
|
4747
|
+
// --- Bulk import ---
|
|
4748
|
+
/**
|
|
4749
|
+
* Bulk-imports customers (`POST /customers/import`). Requires the
|
|
4750
|
+
* `customer.import_manage` scope.
|
|
4751
|
+
*
|
|
4752
|
+
* Responds **207 Multi-Status**: per-item failures do **not** throw — inspect each
|
|
4753
|
+
* entry's `code`. Each item must carry exactly one of `account.passwordHash` or
|
|
4754
|
+
* `account.legacyAuth`, and importing `legacyAuth` requires an active retention
|
|
4755
|
+
* config (see `configurePasswordMigrationRetention`).
|
|
4756
|
+
*/
|
|
4757
|
+
async importCustomers(input, auth2 = SERVICE28) {
|
|
4758
|
+
return this.ctx.http.request({
|
|
4759
|
+
method: "POST",
|
|
4760
|
+
path: `${this.base()}/import`,
|
|
4761
|
+
auth: auth2,
|
|
4762
|
+
body: input
|
|
4763
|
+
});
|
|
4764
|
+
}
|
|
4697
4765
|
};
|
|
4698
4766
|
|
|
4699
4767
|
// src/services/approval.ts
|
|
@@ -4769,6 +4837,15 @@ var ApprovalService = class {
|
|
|
4769
4837
|
});
|
|
4770
4838
|
}
|
|
4771
4839
|
};
|
|
4840
|
+
function approvalStatusPatch(status, approverComment) {
|
|
4841
|
+
const comment = approverComment?.trim() ?? "";
|
|
4842
|
+
return [
|
|
4843
|
+
{ op: "replace", path: "/status", value: status },
|
|
4844
|
+
// `as const` on both fields: the generated type narrows `path` to an enum too, so
|
|
4845
|
+
// a widened `string` from the spread would not be assignable.
|
|
4846
|
+
...comment !== "" ? [{ op: "add", path: "/approverComment", value: comment }] : []
|
|
4847
|
+
];
|
|
4848
|
+
}
|
|
4772
4849
|
|
|
4773
4850
|
// src/client.ts
|
|
4774
4851
|
var EmporixClient = class {
|
|
@@ -4959,7 +5036,10 @@ function productIdFromYrn(yrn) {
|
|
|
4959
5036
|
const semi = yrn.lastIndexOf(";");
|
|
4960
5037
|
return semi >= 0 ? yrn.slice(semi + 1) : "";
|
|
4961
5038
|
}
|
|
5039
|
+
function productYrn(tenant, productId) {
|
|
5040
|
+
return `urn:yaas:hybris:product:product:${tenant};${productId}`;
|
|
5041
|
+
}
|
|
4962
5042
|
|
|
4963
|
-
export { AiService, ApprovalService, BrandService, CatalogService, ClientConfigService, CloudFunctionsService, CountryService, CouponService, CurrencyService, CustomerAdminService, DEFAULT_HOST, EmporixClient, FeeService, HttpClient, ImportService, IndexingService, InvoiceService, LEVEL, LabelService, LevelResolver, PickPackService, QuoteService, RagIndexerService, ReturnsService, RewardPointsService, STORAGE_KEYS, SchemaService, SepaExportService, SequentialIdService, SessionContextService, ShippingService, ShoppingListService, SiteService, TaxService, TenantConfigService, UnitHandlingService, VendorService, WebhookService, createConsoleLogger, createCookieBackedStorage, createCore, createEmporixClient, createNoopLogger, createServerStorage, parseAnonymousSession, pickFee, productIdFromYrn, redact, resolveZone, serverAuth, validateConfig };
|
|
5043
|
+
export { AiService, ApprovalService, BrandService, CatalogService, ClientConfigService, CloudFunctionsService, CountryService, CouponService, CurrencyService, CustomerAdminService, DEFAULT_HOST, EmporixClient, FeeService, HttpClient, ImportService, IndexingService, InvoiceService, LEVEL, LabelService, LevelResolver, PickPackService, QuoteService, RagIndexerService, ReturnsService, RewardPointsService, STORAGE_KEYS, SchemaService, SepaExportService, SequentialIdService, SessionContextService, ShippingService, ShoppingListService, SiteService, TaxService, TenantConfigService, UnitHandlingService, VendorService, WebhookService, approvalStatusPatch, createConsoleLogger, createCookieBackedStorage, createCore, createEmporixClient, createNoopLogger, createServerStorage, parseAnonymousSession, pickFee, productIdFromYrn, productYrn, redact, resolveZone, serverAuth, validateConfig };
|
|
4964
5044
|
//# sourceMappingURL=index.js.map
|
|
4965
5045
|
//# sourceMappingURL=index.js.map
|