@viu/emporix-sdk 2.11.0 → 2.13.1
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 +14 -0
- 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/{chunk-KVBCTXVH.js → chunk-WW3H7VJ5.js} +10 -6
- package/dist/chunk-WW3H7VJ5.js.map +1 -0
- 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-CmShWI_R.d.cts → context-CD7F_LHT.d.cts} +10 -0
- package/dist/{context-CmShWI_R.d.ts → context-CD7F_LHT.d.ts} +10 -0
- 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 +58 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +52 -27
- 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.cjs +8 -4
- package/dist/orders.cjs.map +1 -1
- package/dist/orders.d.cts +1 -1
- package/dist/orders.d.ts +1 -1
- package/dist/orders.js +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/chunk-KVBCTXVH.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ClientContext, b as AuthContext, P as PaginatedItems, T as TokenProvider, n as ResolvedConfig, E as EmporixConfig, j as LogLevel, o as ServiceName, e as CustomerTokenRefresher } from './context-
|
|
2
|
-
export { A as AnonymousSession, a as AnonymousSessionStore, c as AuthKind, d as CustomerRefreshRegistry, D as DEFAULT_HOST, f as DefaultTokenProvider, H as HttpClient, g as HttpClientOptions, L as LEVEL, h as LevelResolver, i as LogFields, k as Logger, l as LoggerConfig, m as LoggerObjectConfig, R as RequestOptions, S as ServiceCredentials, p as StorefrontCredentials, q as auth, r as createConsoleLogger, s as createNoopLogger, t as iterateAll, u as redact, v as resolveToken, w as validateConfig } from './context-
|
|
1
|
+
import { C as ClientContext, b as AuthContext, P as PaginatedItems, T as TokenProvider, n as ResolvedConfig, E as EmporixConfig, j as LogLevel, o as ServiceName, e as CustomerTokenRefresher } from './context-CD7F_LHT.cjs';
|
|
2
|
+
export { A as AnonymousSession, a as AnonymousSessionStore, c as AuthKind, d as CustomerRefreshRegistry, D as DEFAULT_HOST, f as DefaultTokenProvider, H as HttpClient, g as HttpClientOptions, L as LEVEL, h as LevelResolver, i as LogFields, k as Logger, l as LoggerConfig, m as LoggerObjectConfig, R as RequestOptions, S as ServiceCredentials, p as StorefrontCredentials, q as auth, r as createConsoleLogger, s as createNoopLogger, t as iterateAll, u as redact, v as resolveToken, w as validateConfig } from './context-CD7F_LHT.cjs';
|
|
3
3
|
import { CustomerService } from './customer.cjs';
|
|
4
4
|
export { Address, AddressCreateInput, AddressUpdateInput, Customer, CustomerSession, CustomerSignupInput, CustomerUpdateInput, PasswordChangeInput, PasswordResetConfirmInput, PasswordResetRequestInput } from './customer.cjs';
|
|
5
5
|
import { ProductService } from './product.cjs';
|
|
@@ -7135,6 +7135,7 @@ declare class EmporixClient {
|
|
|
7135
7135
|
readonly config: ResolvedConfig;
|
|
7136
7136
|
private readonly resolver;
|
|
7137
7137
|
private readonly customerRefresh;
|
|
7138
|
+
private readonly requestContext;
|
|
7138
7139
|
constructor(config: EmporixConfig);
|
|
7139
7140
|
/**
|
|
7140
7141
|
* Re-binds the storefront price context (currency / siteCode / targetLocation)
|
|
@@ -7142,11 +7143,15 @@ declare class EmporixClient {
|
|
|
7142
7143
|
* next request re-mints a token bound to the new context. Use this to switch
|
|
7143
7144
|
* currency at runtime. Carts are currency-bound — clear the cart after a
|
|
7144
7145
|
* currency change (the React `setCurrency` does this for you).
|
|
7146
|
+
*
|
|
7147
|
+
* Also sets the storefront `language` (an `Accept-Language` header on every
|
|
7148
|
+
* read); a language-only change does NOT re-mint the token.
|
|
7145
7149
|
*/
|
|
7146
7150
|
setStorefrontContext(ctx: {
|
|
7147
7151
|
currency?: string;
|
|
7148
7152
|
siteCode?: string;
|
|
7149
7153
|
targetLocation?: string;
|
|
7154
|
+
language?: string;
|
|
7150
7155
|
}): void;
|
|
7151
7156
|
/** Sets the runtime log level globally or for one service. */
|
|
7152
7157
|
setLogLevel(level: LogLevel, opts?: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ClientContext, b as AuthContext, P as PaginatedItems, T as TokenProvider, n as ResolvedConfig, E as EmporixConfig, j as LogLevel, o as ServiceName, e as CustomerTokenRefresher } from './context-
|
|
2
|
-
export { A as AnonymousSession, a as AnonymousSessionStore, c as AuthKind, d as CustomerRefreshRegistry, D as DEFAULT_HOST, f as DefaultTokenProvider, H as HttpClient, g as HttpClientOptions, L as LEVEL, h as LevelResolver, i as LogFields, k as Logger, l as LoggerConfig, m as LoggerObjectConfig, R as RequestOptions, S as ServiceCredentials, p as StorefrontCredentials, q as auth, r as createConsoleLogger, s as createNoopLogger, t as iterateAll, u as redact, v as resolveToken, w as validateConfig } from './context-
|
|
1
|
+
import { C as ClientContext, b as AuthContext, P as PaginatedItems, T as TokenProvider, n as ResolvedConfig, E as EmporixConfig, j as LogLevel, o as ServiceName, e as CustomerTokenRefresher } from './context-CD7F_LHT.js';
|
|
2
|
+
export { A as AnonymousSession, a as AnonymousSessionStore, c as AuthKind, d as CustomerRefreshRegistry, D as DEFAULT_HOST, f as DefaultTokenProvider, H as HttpClient, g as HttpClientOptions, L as LEVEL, h as LevelResolver, i as LogFields, k as Logger, l as LoggerConfig, m as LoggerObjectConfig, R as RequestOptions, S as ServiceCredentials, p as StorefrontCredentials, q as auth, r as createConsoleLogger, s as createNoopLogger, t as iterateAll, u as redact, v as resolveToken, w as validateConfig } from './context-CD7F_LHT.js';
|
|
3
3
|
import { CustomerService } from './customer.js';
|
|
4
4
|
export { Address, AddressCreateInput, AddressUpdateInput, Customer, CustomerSession, CustomerSignupInput, CustomerUpdateInput, PasswordChangeInput, PasswordResetConfirmInput, PasswordResetRequestInput } from './customer.js';
|
|
5
5
|
import { ProductService } from './product.js';
|
|
@@ -7135,6 +7135,7 @@ declare class EmporixClient {
|
|
|
7135
7135
|
readonly config: ResolvedConfig;
|
|
7136
7136
|
private readonly resolver;
|
|
7137
7137
|
private readonly customerRefresh;
|
|
7138
|
+
private readonly requestContext;
|
|
7138
7139
|
constructor(config: EmporixConfig);
|
|
7139
7140
|
/**
|
|
7140
7141
|
* Re-binds the storefront price context (currency / siteCode / targetLocation)
|
|
@@ -7142,11 +7143,15 @@ declare class EmporixClient {
|
|
|
7142
7143
|
* next request re-mints a token bound to the new context. Use this to switch
|
|
7143
7144
|
* currency at runtime. Carts are currency-bound — clear the cart after a
|
|
7144
7145
|
* currency change (the React `setCurrency` does this for you).
|
|
7146
|
+
*
|
|
7147
|
+
* Also sets the storefront `language` (an `Accept-Language` header on every
|
|
7148
|
+
* read); a language-only change does NOT re-mint the token.
|
|
7145
7149
|
*/
|
|
7146
7150
|
setStorefrontContext(ctx: {
|
|
7147
7151
|
currency?: string;
|
|
7148
7152
|
siteCode?: string;
|
|
7149
7153
|
targetLocation?: string;
|
|
7154
|
+
language?: string;
|
|
7150
7155
|
}): void;
|
|
7151
7156
|
/** Sets the runtime log level globally or for one service. */
|
|
7152
7157
|
setLogLevel(level: LogLevel, opts?: {
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import { LocationsService } from './chunk-LGLFJL3S.js';
|
|
|
2
2
|
export { LocationsService } from './chunk-LGLFJL3S.js';
|
|
3
3
|
import { MediaService } from './chunk-WSXRUYBE.js';
|
|
4
4
|
export { MediaService } from './chunk-WSXRUYBE.js';
|
|
5
|
-
import { OrdersService, SalesOrdersService } from './chunk-
|
|
6
|
-
export { OrdersService, SalesOrdersService } from './chunk-
|
|
5
|
+
import { OrdersService, SalesOrdersService } from './chunk-WW3H7VJ5.js';
|
|
6
|
+
export { OrdersService, SalesOrdersService } from './chunk-WW3H7VJ5.js';
|
|
7
7
|
import { PaymentGatewayService } from './chunk-HKPZI7Y5.js';
|
|
8
8
|
export { PaymentGatewayService } from './chunk-HKPZI7Y5.js';
|
|
9
9
|
import { PriceService } from './chunk-BK25FDTH.js';
|
|
@@ -533,6 +533,16 @@ var HttpClient = class {
|
|
|
533
533
|
}
|
|
534
534
|
opts;
|
|
535
535
|
sleep;
|
|
536
|
+
buildHeaders(o, token, isFormData) {
|
|
537
|
+
return {
|
|
538
|
+
...this.opts.requestContext?.language ? { "Accept-Language": this.opts.requestContext.language } : {},
|
|
539
|
+
...o.headers ?? {},
|
|
540
|
+
Authorization: `Bearer ${token}`,
|
|
541
|
+
// JSON bodies: set Content-Type. FormData bodies: let `fetch`
|
|
542
|
+
// emit `multipart/form-data; boundary=...` itself.
|
|
543
|
+
...o.body !== void 0 && !isFormData ? { "Content-Type": "application/json" } : {}
|
|
544
|
+
};
|
|
545
|
+
}
|
|
536
546
|
async request(o) {
|
|
537
547
|
const requestId = `req-${++requestSeq}`;
|
|
538
548
|
const log = this.opts.logger.child({ requestId });
|
|
@@ -561,13 +571,7 @@ var HttpClient = class {
|
|
|
561
571
|
const isFormData = typeof FormData !== "undefined" && o.body instanceof FormData;
|
|
562
572
|
const init = {
|
|
563
573
|
method: o.method,
|
|
564
|
-
headers:
|
|
565
|
-
...o.headers ?? {},
|
|
566
|
-
Authorization: `Bearer ${token}`,
|
|
567
|
-
// JSON bodies: set Content-Type. FormData bodies: let `fetch`
|
|
568
|
-
// emit `multipart/form-data; boundary=...` itself.
|
|
569
|
-
...o.body !== void 0 && !isFormData ? { "Content-Type": "application/json" } : {}
|
|
570
|
-
},
|
|
574
|
+
headers: this.buildHeaders(o, token, isFormData),
|
|
571
575
|
signal: controller.signal
|
|
572
576
|
};
|
|
573
577
|
if (o.body !== void 0) {
|
|
@@ -655,11 +659,7 @@ var HttpClient = class {
|
|
|
655
659
|
const isFormData = typeof FormData !== "undefined" && o.body instanceof FormData;
|
|
656
660
|
const init = {
|
|
657
661
|
method: o.method,
|
|
658
|
-
headers:
|
|
659
|
-
...o.headers ?? {},
|
|
660
|
-
Authorization: `Bearer ${token}`,
|
|
661
|
-
...o.body !== void 0 && !isFormData ? { "Content-Type": "application/json" } : {}
|
|
662
|
-
},
|
|
662
|
+
headers: this.buildHeaders(o, token, isFormData),
|
|
663
663
|
signal: controller.signal,
|
|
664
664
|
...extra?.redirect ? { redirect: extra.redirect } : {}
|
|
665
665
|
};
|
|
@@ -2022,19 +2022,31 @@ var RewardPointsService = class {
|
|
|
2022
2022
|
// --- Storefront: the signed-in customer's own points (customer token required) ---
|
|
2023
2023
|
/** The signed-in customer's reward-points balance. Requires a customer `auth`. */
|
|
2024
2024
|
async getMyPoints(auth2) {
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2025
|
+
try {
|
|
2026
|
+
return await this.ctx.http.request({
|
|
2027
|
+
method: "GET",
|
|
2028
|
+
path: `${this.base()}/public/customer`,
|
|
2029
|
+
auth: auth2
|
|
2030
|
+
});
|
|
2031
|
+
} catch (err) {
|
|
2032
|
+
if (err instanceof EmporixNotFoundError) return 0;
|
|
2033
|
+
throw err;
|
|
2034
|
+
}
|
|
2030
2035
|
}
|
|
2031
2036
|
/** The signed-in customer's reward-points summary. Requires a customer `auth`. */
|
|
2032
2037
|
async getMySummary(auth2) {
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
+
try {
|
|
2039
|
+
return await this.ctx.http.request({
|
|
2040
|
+
method: "GET",
|
|
2041
|
+
path: `${this.base()}/public/customer/summary`,
|
|
2042
|
+
auth: auth2
|
|
2043
|
+
});
|
|
2044
|
+
} catch (err) {
|
|
2045
|
+
if (err instanceof EmporixNotFoundError) {
|
|
2046
|
+
return { activePoints: 0, summary: { addedPointsList: [] } };
|
|
2047
|
+
}
|
|
2048
|
+
throw err;
|
|
2049
|
+
}
|
|
2038
2050
|
}
|
|
2039
2051
|
/**
|
|
2040
2052
|
* Redeem the signed-in customer's points for a coupon code. Requires a
|
|
@@ -3468,7 +3480,7 @@ var ApprovalService = class {
|
|
|
3468
3480
|
};
|
|
3469
3481
|
|
|
3470
3482
|
// package.json
|
|
3471
|
-
var version = "2.
|
|
3483
|
+
var version = "2.13.1";
|
|
3472
3484
|
|
|
3473
3485
|
// src/version.ts
|
|
3474
3486
|
var SDK_VERSION = version;
|
|
@@ -3537,6 +3549,7 @@ var EmporixClient = class {
|
|
|
3537
3549
|
config;
|
|
3538
3550
|
resolver;
|
|
3539
3551
|
customerRefresh;
|
|
3552
|
+
requestContext;
|
|
3540
3553
|
constructor(config) {
|
|
3541
3554
|
const cfg = validateConfig(config);
|
|
3542
3555
|
this.tenant = cfg.tenant;
|
|
@@ -3560,6 +3573,8 @@ var EmporixClient = class {
|
|
|
3560
3573
|
this.tokenProvider = tokenProvider;
|
|
3561
3574
|
const customerRefresh = new CustomerRefreshRegistry();
|
|
3562
3575
|
this.customerRefresh = customerRefresh;
|
|
3576
|
+
this.requestContext = { language: cfg.credentials.storefront?.context?.language };
|
|
3577
|
+
const requestContext = this.requestContext;
|
|
3563
3578
|
const mk = (service) => ({
|
|
3564
3579
|
tenant: cfg.tenant,
|
|
3565
3580
|
tokenProvider,
|
|
@@ -3570,7 +3585,8 @@ var EmporixClient = class {
|
|
|
3570
3585
|
logger: root.child({ service: "http" }),
|
|
3571
3586
|
retry: cfg.retry,
|
|
3572
3587
|
timeouts: cfg.timeouts,
|
|
3573
|
-
customerRefresh
|
|
3588
|
+
customerRefresh,
|
|
3589
|
+
requestContext
|
|
3574
3590
|
})
|
|
3575
3591
|
});
|
|
3576
3592
|
this.customers = new CustomerService(mk("customer"));
|
|
@@ -3628,9 +3644,18 @@ var EmporixClient = class {
|
|
|
3628
3644
|
* next request re-mints a token bound to the new context. Use this to switch
|
|
3629
3645
|
* currency at runtime. Carts are currency-bound — clear the cart after a
|
|
3630
3646
|
* currency change (the React `setCurrency` does this for you).
|
|
3647
|
+
*
|
|
3648
|
+
* Also sets the storefront `language` (an `Accept-Language` header on every
|
|
3649
|
+
* read); a language-only change does NOT re-mint the token.
|
|
3631
3650
|
*/
|
|
3632
3651
|
setStorefrontContext(ctx) {
|
|
3633
|
-
|
|
3652
|
+
if (ctx.language !== void 0) {
|
|
3653
|
+
this.requestContext.language = ctx.language || void 0;
|
|
3654
|
+
}
|
|
3655
|
+
const { language: _language, ...priceContext } = ctx;
|
|
3656
|
+
if (Object.keys(priceContext).length > 0) {
|
|
3657
|
+
this.tokenProvider.setAnonymousContext?.(priceContext);
|
|
3658
|
+
}
|
|
3634
3659
|
}
|
|
3635
3660
|
/** Sets the runtime log level globally or for one service. */
|
|
3636
3661
|
setLogLevel(level, opts = {}) {
|