@viu/emporix-sdk 2.14.0 → 2.16.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 +15 -0
- package/dist/availability.cjs +1 -0
- package/dist/availability.cjs.map +1 -1
- package/dist/availability.d.cts +1 -0
- package/dist/availability.d.ts +1 -0
- package/dist/availability.js +1 -1
- package/dist/cart.cjs +1 -0
- package/dist/cart.cjs.map +1 -1
- package/dist/cart.d.cts +1 -0
- package/dist/cart.d.ts +1 -0
- package/dist/cart.js +1 -1
- package/dist/category.cjs +1 -0
- package/dist/category.cjs.map +1 -1
- package/dist/category.d.cts +1 -0
- package/dist/category.d.ts +1 -0
- package/dist/category.js +1 -1
- package/dist/checkout.cjs +1 -0
- package/dist/checkout.cjs.map +1 -1
- package/dist/checkout.d.cts +1 -0
- package/dist/checkout.d.ts +1 -0
- package/dist/checkout.js +1 -1
- package/dist/{chunk-LGOC5XOI.js → chunk-3BTPX7IJ.js} +3 -2
- package/dist/chunk-3BTPX7IJ.js.map +1 -0
- package/dist/{chunk-MIUVJEGR.js → chunk-5VTBLBXJ.js} +3 -2
- package/dist/chunk-5VTBLBXJ.js.map +1 -0
- package/dist/{chunk-WW3H7VJ5.js → chunk-62PCCHZ2.js} +4 -2
- package/dist/chunk-62PCCHZ2.js.map +1 -0
- package/dist/{chunk-BDFOD7W3.js → chunk-A3LYJUD4.js} +3 -2
- package/dist/chunk-A3LYJUD4.js.map +1 -0
- package/dist/{chunk-MM6JF3Z7.js → chunk-BNX3JULF.js} +3 -2
- package/dist/chunk-BNX3JULF.js.map +1 -0
- package/dist/{chunk-LGLFJL3S.js → chunk-DUVIIWFG.js} +3 -2
- package/dist/chunk-DUVIIWFG.js.map +1 -0
- package/dist/{chunk-HAEVK6IS.js → chunk-EAWGUZHS.js} +3 -2
- package/dist/chunk-EAWGUZHS.js.map +1 -0
- package/dist/{chunk-WWCCB22A.js → chunk-GIZS4BY3.js} +3 -2
- package/dist/chunk-GIZS4BY3.js.map +1 -0
- package/dist/{chunk-BPVMQFO4.js → chunk-K3VQLW3P.js} +3 -2
- package/dist/chunk-K3VQLW3P.js.map +1 -0
- package/dist/{chunk-CR2JRH7T.js → chunk-NE7MIZPR.js} +4 -2
- package/dist/chunk-NE7MIZPR.js.map +1 -0
- package/dist/{chunk-UOBOFCFU.js → chunk-NEXUWPHW.js} +3 -2
- package/dist/chunk-NEXUWPHW.js.map +1 -0
- package/dist/{chunk-FU5WQALW.js → chunk-OTG2S2L4.js} +3 -2
- package/dist/chunk-OTG2S2L4.js.map +1 -0
- package/dist/{chunk-P3UHYMDH.js → chunk-PAT4CS36.js} +3 -2
- package/dist/chunk-PAT4CS36.js.map +1 -0
- package/dist/chunk-PYLWZZC4.js +280 -0
- package/dist/chunk-PYLWZZC4.js.map +1 -0
- package/dist/{chunk-XG2TKFY5.js → chunk-RYQVMR26.js} +3 -2
- package/dist/chunk-RYQVMR26.js.map +1 -0
- package/dist/companies.cjs +1 -0
- package/dist/companies.cjs.map +1 -1
- package/dist/companies.d.cts +1 -0
- package/dist/companies.d.ts +1 -0
- package/dist/companies.js +1 -1
- package/dist/contacts.cjs +1 -0
- package/dist/contacts.cjs.map +1 -1
- package/dist/contacts.d.cts +1 -0
- package/dist/contacts.d.ts +1 -0
- package/dist/contacts.js +1 -1
- package/dist/customer-groups.cjs +1 -0
- package/dist/customer-groups.cjs.map +1 -1
- package/dist/customer-groups.d.cts +1 -0
- package/dist/customer-groups.d.ts +1 -0
- package/dist/customer-groups.js +1 -1
- package/dist/customer.cjs +1 -0
- package/dist/customer.cjs.map +1 -1
- package/dist/customer.d.cts +1 -0
- package/dist/customer.d.ts +1 -0
- package/dist/customer.js +1 -1
- package/dist/index.cjs +219 -119
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -4
- package/dist/index.d.ts +76 -4
- package/dist/index.js +210 -377
- package/dist/index.js.map +1 -1
- package/dist/locations.cjs +1 -0
- package/dist/locations.cjs.map +1 -1
- package/dist/locations.d.cts +1 -0
- package/dist/locations.d.ts +1 -0
- package/dist/locations.js +1 -1
- package/dist/media.cjs +1 -0
- package/dist/media.cjs.map +1 -1
- package/dist/media.d.cts +1 -0
- package/dist/media.d.ts +1 -0
- package/dist/media.js +1 -1
- package/dist/orders.cjs +2 -0
- package/dist/orders.cjs.map +1 -1
- package/dist/orders.d.cts +2 -0
- package/dist/orders.d.ts +2 -0
- package/dist/orders.js +1 -1
- package/dist/payment.cjs +25 -7
- package/dist/payment.cjs.map +1 -1
- package/dist/payment.d.cts +8 -3
- package/dist/payment.d.ts +8 -3
- package/dist/payment.js +1 -1
- package/dist/price.cjs +1 -0
- package/dist/price.cjs.map +1 -1
- package/dist/price.d.cts +1 -0
- package/dist/price.d.ts +1 -0
- package/dist/price.js +1 -1
- package/dist/product.cjs +1 -0
- package/dist/product.cjs.map +1 -1
- package/dist/product.d.cts +1 -0
- package/dist/product.d.ts +1 -0
- package/dist/product.js +1 -1
- package/dist/segment.cjs +2 -0
- package/dist/segment.cjs.map +1 -1
- package/dist/segment.d.cts +2 -0
- package/dist/segment.d.ts +2 -0
- package/dist/segment.js +1 -1
- package/package.json +2 -1
- package/dist/chunk-BDFOD7W3.js.map +0 -1
- package/dist/chunk-BPVMQFO4.js.map +0 -1
- package/dist/chunk-CR2JRH7T.js.map +0 -1
- package/dist/chunk-EINAVCV2.js +0 -30
- package/dist/chunk-EINAVCV2.js.map +0 -1
- package/dist/chunk-FU5WQALW.js.map +0 -1
- package/dist/chunk-HAEVK6IS.js.map +0 -1
- package/dist/chunk-LGLFJL3S.js.map +0 -1
- package/dist/chunk-LGOC5XOI.js.map +0 -1
- package/dist/chunk-MIUVJEGR.js.map +0 -1
- package/dist/chunk-MM6JF3Z7.js.map +0 -1
- package/dist/chunk-P3UHYMDH.js.map +0 -1
- package/dist/chunk-UOBOFCFU.js.map +0 -1
- package/dist/chunk-WW3H7VJ5.js.map +0 -1
- package/dist/chunk-WWCCB22A.js.map +0 -1
- package/dist/chunk-XG2TKFY5.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { LocationsService } from './chunk-
|
|
2
|
-
export { LocationsService } from './chunk-
|
|
3
|
-
import { MediaService } from './chunk-
|
|
4
|
-
export { MediaService } from './chunk-
|
|
5
|
-
import { OrdersService, SalesOrdersService } from './chunk-
|
|
6
|
-
export { OrdersService, SalesOrdersService } from './chunk-
|
|
7
|
-
import { PaymentGatewayService } from './chunk-
|
|
8
|
-
export { PaymentGatewayService } from './chunk-
|
|
9
|
-
import { PriceService } from './chunk-
|
|
10
|
-
export { PriceService } from './chunk-
|
|
11
|
-
import { ProductService } from './chunk-
|
|
12
|
-
export { ProductService } from './chunk-
|
|
13
|
-
import { SegmentService } from './chunk-
|
|
14
|
-
export { SegmentService } from './chunk-
|
|
15
|
-
import { AvailabilityService } from './chunk-
|
|
16
|
-
export { AvailabilityService } from './chunk-
|
|
17
|
-
import { CartService } from './chunk-
|
|
18
|
-
export { CartService } from './chunk-
|
|
19
|
-
import { CategoryService } from './chunk-
|
|
20
|
-
export { CategoryService } from './chunk-
|
|
1
|
+
import { LocationsService } from './chunk-DUVIIWFG.js';
|
|
2
|
+
export { LocationsService } from './chunk-DUVIIWFG.js';
|
|
3
|
+
import { MediaService } from './chunk-OTG2S2L4.js';
|
|
4
|
+
export { MediaService } from './chunk-OTG2S2L4.js';
|
|
5
|
+
import { OrdersService, SalesOrdersService } from './chunk-62PCCHZ2.js';
|
|
6
|
+
export { OrdersService, SalesOrdersService } from './chunk-62PCCHZ2.js';
|
|
7
|
+
import { auth, resolveToken, DefaultTokenProvider, CustomerRefreshRegistry, PaymentGatewayService } from './chunk-PYLWZZC4.js';
|
|
8
|
+
export { CustomerRefreshRegistry, DefaultTokenProvider, PaymentGatewayService, auth, resolveToken } from './chunk-PYLWZZC4.js';
|
|
9
|
+
import { PriceService } from './chunk-A3LYJUD4.js';
|
|
10
|
+
export { PriceService } from './chunk-A3LYJUD4.js';
|
|
11
|
+
import { ProductService } from './chunk-5VTBLBXJ.js';
|
|
12
|
+
export { ProductService } from './chunk-5VTBLBXJ.js';
|
|
13
|
+
import { SegmentService } from './chunk-NE7MIZPR.js';
|
|
14
|
+
export { SegmentService } from './chunk-NE7MIZPR.js';
|
|
15
|
+
import { AvailabilityService } from './chunk-K3VQLW3P.js';
|
|
16
|
+
export { AvailabilityService } from './chunk-K3VQLW3P.js';
|
|
17
|
+
import { CartService } from './chunk-PAT4CS36.js';
|
|
18
|
+
export { CartService } from './chunk-PAT4CS36.js';
|
|
19
|
+
import { CategoryService } from './chunk-GIZS4BY3.js';
|
|
20
|
+
export { CategoryService } from './chunk-GIZS4BY3.js';
|
|
21
21
|
export { iterateAll } from './chunk-GWJ2U2CP.js';
|
|
22
|
-
import { CheckoutService } from './chunk-
|
|
23
|
-
export { CheckoutService } from './chunk-
|
|
24
|
-
import { CompaniesService } from './chunk-
|
|
25
|
-
export { CompaniesService } from './chunk-
|
|
26
|
-
import { ContactsService } from './chunk-
|
|
27
|
-
export { ContactsService } from './chunk-
|
|
28
|
-
import { CustomerGroupsService } from './chunk-
|
|
29
|
-
export { CustomerGroupsService } from './chunk-
|
|
30
|
-
import { CustomerService } from './chunk-
|
|
31
|
-
export { CustomerService } from './chunk-
|
|
22
|
+
import { CheckoutService } from './chunk-RYQVMR26.js';
|
|
23
|
+
export { CheckoutService } from './chunk-RYQVMR26.js';
|
|
24
|
+
import { CompaniesService } from './chunk-BNX3JULF.js';
|
|
25
|
+
export { CompaniesService } from './chunk-BNX3JULF.js';
|
|
26
|
+
import { ContactsService } from './chunk-EAWGUZHS.js';
|
|
27
|
+
export { ContactsService } from './chunk-EAWGUZHS.js';
|
|
28
|
+
import { CustomerGroupsService } from './chunk-3BTPX7IJ.js';
|
|
29
|
+
export { CustomerGroupsService } from './chunk-3BTPX7IJ.js';
|
|
30
|
+
import { CustomerService } from './chunk-NEXUWPHW.js';
|
|
31
|
+
export { CustomerService } from './chunk-NEXUWPHW.js';
|
|
32
32
|
import './chunk-3BDDYX3V.js';
|
|
33
|
-
import {
|
|
33
|
+
import { EmporixTimeoutError, EmporixNetworkError, errorFromResponse, EmporixNotFoundError, EmporixError } from './chunk-UWGGF4MC.js';
|
|
34
34
|
export { EmporixAuthError, EmporixError, EmporixForbiddenError, EmporixInsufficientScopeError, EmporixNetworkError, EmporixNotFoundError, EmporixServerError, EmporixTimeoutError, EmporixValidationError, errorFromResponse } from './chunk-UWGGF4MC.js';
|
|
35
35
|
|
|
36
36
|
// src/core/config.ts
|
|
@@ -294,249 +294,6 @@ function createNoopLogger() {
|
|
|
294
294
|
return new NoopLogger();
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
// src/core/auth.ts
|
|
298
|
-
var auth = {
|
|
299
|
-
/** Service/custom credential set (default `backend`). */
|
|
300
|
-
service: (credentials) => credentials === void 0 ? { kind: "service" } : { kind: "service", credentials },
|
|
301
|
-
/** Cached anonymous storefront token. */
|
|
302
|
-
anonymous: () => ({ kind: "anonymous" }),
|
|
303
|
-
/** Caller-owned customer bearer token. */
|
|
304
|
-
customer: (token) => ({ kind: "customer", token }),
|
|
305
|
-
/** Exact token, no transformation (SSO / token-exchange). */
|
|
306
|
-
raw: (token) => ({ kind: "raw", token })
|
|
307
|
-
};
|
|
308
|
-
async function resolveToken(ctx, provider) {
|
|
309
|
-
switch (ctx.kind) {
|
|
310
|
-
case "service":
|
|
311
|
-
return provider.getToken(ctx.credentials ?? "backend");
|
|
312
|
-
case "anonymous":
|
|
313
|
-
return (await provider.getAnonymousToken()).accessToken;
|
|
314
|
-
case "customer":
|
|
315
|
-
case "raw":
|
|
316
|
-
return ctx.token;
|
|
317
|
-
}
|
|
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
|
-
};
|
|
339
|
-
var DefaultTokenProvider = class {
|
|
340
|
-
constructor(cfg) {
|
|
341
|
-
this.cfg = cfg;
|
|
342
|
-
}
|
|
343
|
-
cfg;
|
|
344
|
-
serviceCache = /* @__PURE__ */ new Map();
|
|
345
|
-
serviceLocks = /* @__PURE__ */ new Map();
|
|
346
|
-
anon;
|
|
347
|
-
anonLock;
|
|
348
|
-
anonStore;
|
|
349
|
-
contextOverride;
|
|
350
|
-
refreshListeners = /* @__PURE__ */ new Set();
|
|
351
|
-
onRefresh(listener) {
|
|
352
|
-
this.refreshListeners.add(listener);
|
|
353
|
-
return () => {
|
|
354
|
-
this.refreshListeners.delete(listener);
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
notifyRefresh(kind, success) {
|
|
358
|
-
for (const l of this.refreshListeners) {
|
|
359
|
-
try {
|
|
360
|
-
l({ kind, success });
|
|
361
|
-
} catch {
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
attachAnonymousStore(store) {
|
|
366
|
-
this.anonStore = store;
|
|
367
|
-
if (!this.anon) {
|
|
368
|
-
const persisted = store.read();
|
|
369
|
-
if (persisted) {
|
|
370
|
-
this.anon = {
|
|
371
|
-
accessToken: "",
|
|
372
|
-
refreshToken: persisted.refreshToken,
|
|
373
|
-
sessionId: persisted.sessionId,
|
|
374
|
-
expiresIn: 0,
|
|
375
|
-
expiresAt: 0
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
creds(set) {
|
|
381
|
-
if (set === "backend") {
|
|
382
|
-
const b = this.cfg.credentials.backend;
|
|
383
|
-
if (!b?.clientId || !b.secret) {
|
|
384
|
-
throw new EmporixAuthError(
|
|
385
|
-
"A 'service' AuthContext was used but credentials.backend is not configured"
|
|
386
|
-
);
|
|
387
|
-
}
|
|
388
|
-
return b;
|
|
389
|
-
}
|
|
390
|
-
const c = this.cfg.credentials.custom?.[set];
|
|
391
|
-
if (!c) throw new Error(`Unknown credential set "${set}"`);
|
|
392
|
-
return c;
|
|
393
|
-
}
|
|
394
|
-
fresh(e) {
|
|
395
|
-
if (!e) return false;
|
|
396
|
-
const now = Date.now();
|
|
397
|
-
if (now - e.obtainedAt >= this.cfg.cache.maxLifetimeSeconds * 1e3) return false;
|
|
398
|
-
return now < e.expiresAt;
|
|
399
|
-
}
|
|
400
|
-
async getToken(set) {
|
|
401
|
-
this.creds(set);
|
|
402
|
-
const cached = this.serviceCache.get(set);
|
|
403
|
-
if (this.fresh(cached)) return cached.token;
|
|
404
|
-
const inflight = this.serviceLocks.get(set);
|
|
405
|
-
if (inflight) return inflight;
|
|
406
|
-
const p = this.requestServiceToken(set).finally(() => this.serviceLocks.delete(set));
|
|
407
|
-
this.serviceLocks.set(set, p);
|
|
408
|
-
return p;
|
|
409
|
-
}
|
|
410
|
-
/**
|
|
411
|
-
* fetch with the configured read timeout. Token endpoints sit in front of
|
|
412
|
-
* single-flight locks — one hung call would otherwise block every request
|
|
413
|
-
* on this credential set forever.
|
|
414
|
-
*/
|
|
415
|
-
async boundedFetch(url, init = {}) {
|
|
416
|
-
const ms = this.cfg.timeouts?.readMs ?? 6e4;
|
|
417
|
-
const controller = new AbortController();
|
|
418
|
-
const timer = setTimeout(() => controller.abort(), ms);
|
|
419
|
-
try {
|
|
420
|
-
return await fetch(url, { ...init, signal: controller.signal });
|
|
421
|
-
} catch (err) {
|
|
422
|
-
if (err.name === "AbortError") {
|
|
423
|
-
throw new EmporixTimeoutError(`token request timed out after ${ms}ms`);
|
|
424
|
-
}
|
|
425
|
-
throw new EmporixNetworkError(`token request network failure: ${err.message}`);
|
|
426
|
-
} finally {
|
|
427
|
-
clearTimeout(timer);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
async requestServiceToken(set) {
|
|
431
|
-
const c = this.creds(set);
|
|
432
|
-
const body = new URLSearchParams({
|
|
433
|
-
grant_type: "client_credentials",
|
|
434
|
-
client_id: c.clientId,
|
|
435
|
-
client_secret: c.secret
|
|
436
|
-
});
|
|
437
|
-
if (c.scope) body.set("scope", c.scope);
|
|
438
|
-
const res = await this.boundedFetch(`${this.cfg.host}/oauth/token`, {
|
|
439
|
-
method: "POST",
|
|
440
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
441
|
-
body
|
|
442
|
-
});
|
|
443
|
-
const json = await res.json().catch(() => ({}));
|
|
444
|
-
if (!res.ok) {
|
|
445
|
-
throw new EmporixAuthError(`Token request failed for "${set}"`, res.status, json);
|
|
446
|
-
}
|
|
447
|
-
const obtainedAt = Date.now();
|
|
448
|
-
const ttl = Number(json.expires_in ?? 3600);
|
|
449
|
-
this.serviceCache.set(set, {
|
|
450
|
-
token: json.access_token,
|
|
451
|
-
obtainedAt,
|
|
452
|
-
expiresAt: obtainedAt + (ttl - this.cfg.cache.expirationBufferSeconds) * 1e3
|
|
453
|
-
});
|
|
454
|
-
return this.serviceCache.get(set).token;
|
|
455
|
-
}
|
|
456
|
-
invalidate(set) {
|
|
457
|
-
this.serviceCache.delete(set);
|
|
458
|
-
}
|
|
459
|
-
anonFresh() {
|
|
460
|
-
return !!this.anon && Date.now() < this.anon.expiresAt;
|
|
461
|
-
}
|
|
462
|
-
async getAnonymousToken() {
|
|
463
|
-
if (this.anonFresh()) return this.stripExpiry(this.anon);
|
|
464
|
-
if (this.anonLock) return this.anonLock;
|
|
465
|
-
const canRefresh = !!this.anon?.refreshToken;
|
|
466
|
-
const obtain = canRefresh ? this.fetchAnonymous("refresh").catch(() => this.fetchAnonymous("login")) : this.fetchAnonymous("login");
|
|
467
|
-
const p = obtain.finally(() => {
|
|
468
|
-
this.anonLock = void 0;
|
|
469
|
-
});
|
|
470
|
-
this.anonLock = p;
|
|
471
|
-
return p;
|
|
472
|
-
}
|
|
473
|
-
/** Refreshes the anonymous session, preserving its sessionId. */
|
|
474
|
-
async refreshAnonymous() {
|
|
475
|
-
if (!this.anon) return this.getAnonymousToken();
|
|
476
|
-
return this.fetchAnonymous("refresh");
|
|
477
|
-
}
|
|
478
|
-
invalidateAnonymous() {
|
|
479
|
-
this.anon = void 0;
|
|
480
|
-
this.anonStore?.write(null);
|
|
481
|
-
}
|
|
482
|
-
setAnonymousContext(ctx) {
|
|
483
|
-
const base = this.contextOverride ?? this.cfg.credentials.storefront?.context ?? {};
|
|
484
|
-
this.contextOverride = { ...base, ...ctx };
|
|
485
|
-
this.invalidateAnonymous();
|
|
486
|
-
}
|
|
487
|
-
/** Force a stale access token while keeping the refresh token + sessionId. */
|
|
488
|
-
expireAnonymous() {
|
|
489
|
-
if (this.anon) this.anon = { ...this.anon, expiresAt: 0 };
|
|
490
|
-
}
|
|
491
|
-
stripExpiry(s) {
|
|
492
|
-
const { expiresAt: _expiresAt, ...rest } = s;
|
|
493
|
-
return rest;
|
|
494
|
-
}
|
|
495
|
-
async fetchAnonymous(mode) {
|
|
496
|
-
const sf = this.cfg.credentials.storefront;
|
|
497
|
-
if (!sf?.clientId) {
|
|
498
|
-
throw new Error("credentials.storefront.clientId is required for anonymous tokens");
|
|
499
|
-
}
|
|
500
|
-
const url = new URL(`${this.cfg.host}/customerlogin/auth/anonymous/${mode}`);
|
|
501
|
-
url.searchParams.set("tenant", this.cfg.tenant);
|
|
502
|
-
url.searchParams.set("client_id", sf.clientId);
|
|
503
|
-
const c = this.contextOverride ?? sf.context;
|
|
504
|
-
if (c?.currency) url.searchParams.set("currency", c.currency);
|
|
505
|
-
if (c?.siteCode) url.searchParams.set("siteCode", c.siteCode);
|
|
506
|
-
if (c?.targetLocation) url.searchParams.set("targetLocation", c.targetLocation);
|
|
507
|
-
if (mode === "refresh" && this.anon) {
|
|
508
|
-
url.searchParams.set("refresh_token", this.anon.refreshToken);
|
|
509
|
-
}
|
|
510
|
-
try {
|
|
511
|
-
const res = await this.boundedFetch(url, { method: "GET" });
|
|
512
|
-
const json = await res.json().catch(() => ({}));
|
|
513
|
-
if (!res.ok) {
|
|
514
|
-
this.notifyRefresh("anonymous", false);
|
|
515
|
-
throw new EmporixAuthError(`Anonymous token ${mode} failed`, res.status, json);
|
|
516
|
-
}
|
|
517
|
-
const obtainedAt = Date.now();
|
|
518
|
-
this.anon = {
|
|
519
|
-
accessToken: json.access_token,
|
|
520
|
-
refreshToken: json.refresh_token,
|
|
521
|
-
sessionId: json.sessionId,
|
|
522
|
-
expiresIn: json.expires_in,
|
|
523
|
-
expiresAt: obtainedAt + (json.expires_in - this.cfg.cache.expirationBufferSeconds) * 1e3
|
|
524
|
-
};
|
|
525
|
-
this.anonStore?.write({
|
|
526
|
-
refreshToken: this.anon.refreshToken,
|
|
527
|
-
sessionId: this.anon.sessionId
|
|
528
|
-
});
|
|
529
|
-
this.notifyRefresh("anonymous", true);
|
|
530
|
-
return this.stripExpiry(this.anon);
|
|
531
|
-
} catch (err) {
|
|
532
|
-
if (!(err instanceof EmporixAuthError)) {
|
|
533
|
-
this.notifyRefresh("anonymous", false);
|
|
534
|
-
}
|
|
535
|
-
throw err;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
};
|
|
539
|
-
|
|
540
297
|
// src/core/http.ts
|
|
541
298
|
var requestSeq = 0;
|
|
542
299
|
function safeJson(text) {
|
|
@@ -728,6 +485,75 @@ var HttpClient = class {
|
|
|
728
485
|
}
|
|
729
486
|
};
|
|
730
487
|
|
|
488
|
+
// package.json
|
|
489
|
+
var version = "2.16.0";
|
|
490
|
+
|
|
491
|
+
// src/version.ts
|
|
492
|
+
var SDK_VERSION = version;
|
|
493
|
+
|
|
494
|
+
// src/core/create-core.ts
|
|
495
|
+
function createCore(config) {
|
|
496
|
+
const cfg = validateConfig(config);
|
|
497
|
+
let loggerObj = {};
|
|
498
|
+
let baseLogger;
|
|
499
|
+
if (cfg.logger === false) {
|
|
500
|
+
baseLogger = createNoopLogger();
|
|
501
|
+
} else if (cfg.logger && typeof cfg.logger.child === "function") {
|
|
502
|
+
baseLogger = cfg.logger;
|
|
503
|
+
} else if (cfg.logger) {
|
|
504
|
+
loggerObj = cfg.logger;
|
|
505
|
+
}
|
|
506
|
+
const resolver = new LevelResolver(loggerObj);
|
|
507
|
+
const root = baseLogger ?? createConsoleLogger(resolver, {
|
|
508
|
+
sdk: "emporix",
|
|
509
|
+
sdkVersion: SDK_VERSION,
|
|
510
|
+
tenant: cfg.tenant
|
|
511
|
+
});
|
|
512
|
+
const tokenProvider = cfg.tokenProvider ?? new DefaultTokenProvider(cfg);
|
|
513
|
+
const customerRefresh = new CustomerRefreshRegistry();
|
|
514
|
+
const requestContext = {
|
|
515
|
+
language: cfg.credentials.storefront?.context?.language
|
|
516
|
+
};
|
|
517
|
+
const mk = (service) => ({
|
|
518
|
+
tenant: cfg.tenant,
|
|
519
|
+
tokenProvider,
|
|
520
|
+
logger: root.child({ service }),
|
|
521
|
+
http: new HttpClient({
|
|
522
|
+
host: cfg.host,
|
|
523
|
+
provider: tokenProvider,
|
|
524
|
+
logger: root.child({ service: "http" }),
|
|
525
|
+
retry: cfg.retry,
|
|
526
|
+
timeouts: cfg.timeouts,
|
|
527
|
+
customerRefresh,
|
|
528
|
+
requestContext
|
|
529
|
+
})
|
|
530
|
+
});
|
|
531
|
+
return {
|
|
532
|
+
tenant: cfg.tenant,
|
|
533
|
+
config: cfg,
|
|
534
|
+
tokenProvider,
|
|
535
|
+
mk,
|
|
536
|
+
setStorefrontContext(ctx) {
|
|
537
|
+
if (ctx.language !== void 0) {
|
|
538
|
+
requestContext.language = ctx.language || void 0;
|
|
539
|
+
}
|
|
540
|
+
const { language: _language, ...priceContext } = ctx;
|
|
541
|
+
if (Object.keys(priceContext).length > 0) {
|
|
542
|
+
tokenProvider.setAnonymousContext?.(priceContext);
|
|
543
|
+
}
|
|
544
|
+
},
|
|
545
|
+
setLogLevel(level, opts = {}) {
|
|
546
|
+
resolver.set(level, opts.service, opts.force ?? false);
|
|
547
|
+
},
|
|
548
|
+
getLogLevel(service) {
|
|
549
|
+
return resolver.get(service);
|
|
550
|
+
},
|
|
551
|
+
setCustomerTokenRefresher(refresher) {
|
|
552
|
+
customerRefresh.set(refresher);
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
|
|
731
557
|
// src/services/site.ts
|
|
732
558
|
var ANON = auth.anonymous();
|
|
733
559
|
var SiteService = class {
|
|
@@ -735,6 +561,7 @@ var SiteService = class {
|
|
|
735
561
|
this.ctx = ctx;
|
|
736
562
|
}
|
|
737
563
|
ctx;
|
|
564
|
+
static channel = "site";
|
|
738
565
|
/** Lists active sites. */
|
|
739
566
|
async list(authCtx = ANON) {
|
|
740
567
|
return this.ctx.http.request({
|
|
@@ -774,6 +601,7 @@ var SessionContextService = class {
|
|
|
774
601
|
this.ctx = ctx;
|
|
775
602
|
}
|
|
776
603
|
ctx;
|
|
604
|
+
static channel = "session-context";
|
|
777
605
|
/**
|
|
778
606
|
* Retrieves the current session context, or `null` when the server returns
|
|
779
607
|
* 404 (no session exists yet — the session-context is created server-side
|
|
@@ -837,6 +665,7 @@ var TenantConfigService = class {
|
|
|
837
665
|
this.ctx = ctx;
|
|
838
666
|
}
|
|
839
667
|
ctx;
|
|
668
|
+
static channel = "configuration";
|
|
840
669
|
base() {
|
|
841
670
|
return `/configuration/${this.ctx.tenant}/configurations`;
|
|
842
671
|
}
|
|
@@ -893,6 +722,7 @@ var ClientConfigService = class {
|
|
|
893
722
|
this.ctx = ctx;
|
|
894
723
|
}
|
|
895
724
|
ctx;
|
|
725
|
+
static channel = "configuration";
|
|
896
726
|
base(client) {
|
|
897
727
|
return `/configuration/${this.ctx.tenant}/clients/${encodeURIComponent(client)}/configurations`;
|
|
898
728
|
}
|
|
@@ -950,6 +780,7 @@ var ShoppingListService = class {
|
|
|
950
780
|
this.ctx = ctx;
|
|
951
781
|
}
|
|
952
782
|
ctx;
|
|
783
|
+
static channel = "shopping-list";
|
|
953
784
|
base() {
|
|
954
785
|
return `/shoppinglist/${this.ctx.tenant}/shopping-lists`;
|
|
955
786
|
}
|
|
@@ -1046,6 +877,7 @@ var RagIndexerService = class {
|
|
|
1046
877
|
this.ctx = ctx;
|
|
1047
878
|
}
|
|
1048
879
|
ctx;
|
|
880
|
+
static channel = "ai-rag-indexer";
|
|
1049
881
|
base(type) {
|
|
1050
882
|
return `/ai-rag-indexer/${this.ctx.tenant}/${encodeURIComponent(type)}`;
|
|
1051
883
|
}
|
|
@@ -1086,6 +918,7 @@ var SequentialIdService = class {
|
|
|
1086
918
|
this.ctx = ctx;
|
|
1087
919
|
}
|
|
1088
920
|
ctx;
|
|
921
|
+
static channel = "sequential-id";
|
|
1089
922
|
base() {
|
|
1090
923
|
return `/sequential-id/${this.ctx.tenant}/schemas`;
|
|
1091
924
|
}
|
|
@@ -1175,6 +1008,7 @@ var FeeService = class {
|
|
|
1175
1008
|
this.ctx = ctx;
|
|
1176
1009
|
}
|
|
1177
1010
|
ctx;
|
|
1011
|
+
static channel = "fee";
|
|
1178
1012
|
feesBase() {
|
|
1179
1013
|
return `/fee/${this.ctx.tenant}/fees`;
|
|
1180
1014
|
}
|
|
@@ -1334,6 +1168,7 @@ var CloudFunctionsService = class {
|
|
|
1334
1168
|
this.ctx = ctx;
|
|
1335
1169
|
}
|
|
1336
1170
|
ctx;
|
|
1171
|
+
static channel = "cloud-functions";
|
|
1337
1172
|
base() {
|
|
1338
1173
|
return `/cloud-functions/${this.ctx.tenant}/functions`;
|
|
1339
1174
|
}
|
|
@@ -1357,6 +1192,7 @@ var WebhookService = class {
|
|
|
1357
1192
|
this.ctx = ctx;
|
|
1358
1193
|
}
|
|
1359
1194
|
ctx;
|
|
1195
|
+
static channel = "webhook";
|
|
1360
1196
|
base() {
|
|
1361
1197
|
return `/webhook/${this.ctx.tenant}`;
|
|
1362
1198
|
}
|
|
@@ -1469,6 +1305,7 @@ var SchemaService = class {
|
|
|
1469
1305
|
this.ctx = ctx;
|
|
1470
1306
|
}
|
|
1471
1307
|
ctx;
|
|
1308
|
+
static channel = "schema";
|
|
1472
1309
|
schemasBase() {
|
|
1473
1310
|
return `/schema/${this.ctx.tenant}/schemas`;
|
|
1474
1311
|
}
|
|
@@ -1696,6 +1533,7 @@ var AiService = class {
|
|
|
1696
1533
|
this.ctx = ctx;
|
|
1697
1534
|
}
|
|
1698
1535
|
ctx;
|
|
1536
|
+
static channel = "ai";
|
|
1699
1537
|
base() {
|
|
1700
1538
|
return `/ai-service/${this.ctx.tenant}`;
|
|
1701
1539
|
}
|
|
@@ -1809,6 +1647,7 @@ var TaxService = class {
|
|
|
1809
1647
|
this.ctx = ctx;
|
|
1810
1648
|
}
|
|
1811
1649
|
ctx;
|
|
1650
|
+
static channel = "tax";
|
|
1812
1651
|
base() {
|
|
1813
1652
|
return `/tax/${this.ctx.tenant}`;
|
|
1814
1653
|
}
|
|
@@ -1878,6 +1717,7 @@ var CouponService = class {
|
|
|
1878
1717
|
this.ctx = ctx;
|
|
1879
1718
|
}
|
|
1880
1719
|
ctx;
|
|
1720
|
+
static channel = "coupon";
|
|
1881
1721
|
base() {
|
|
1882
1722
|
return `/coupon/${this.ctx.tenant}`;
|
|
1883
1723
|
}
|
|
@@ -2004,6 +1844,7 @@ var RewardPointsService = class {
|
|
|
2004
1844
|
this.ctx = ctx;
|
|
2005
1845
|
}
|
|
2006
1846
|
ctx;
|
|
1847
|
+
static channel = "reward-points";
|
|
2007
1848
|
/** Base without tenant (customer / public / batch endpoints). */
|
|
2008
1849
|
base() {
|
|
2009
1850
|
return `/reward-points`;
|
|
@@ -2158,6 +1999,7 @@ var BrandService = class {
|
|
|
2158
1999
|
this.ctx = ctx;
|
|
2159
2000
|
}
|
|
2160
2001
|
ctx;
|
|
2002
|
+
static channel = "brand";
|
|
2161
2003
|
base() {
|
|
2162
2004
|
return `/brand/brands`;
|
|
2163
2005
|
}
|
|
@@ -2222,6 +2064,7 @@ var LabelService = class {
|
|
|
2222
2064
|
this.ctx = ctx;
|
|
2223
2065
|
}
|
|
2224
2066
|
ctx;
|
|
2067
|
+
static channel = "label";
|
|
2225
2068
|
base() {
|
|
2226
2069
|
return `/label/labels`;
|
|
2227
2070
|
}
|
|
@@ -2286,6 +2129,7 @@ var CountryService = class {
|
|
|
2286
2129
|
this.ctx = ctx;
|
|
2287
2130
|
}
|
|
2288
2131
|
ctx;
|
|
2132
|
+
static channel = "country";
|
|
2289
2133
|
base() {
|
|
2290
2134
|
return `/country/${this.ctx.tenant}`;
|
|
2291
2135
|
}
|
|
@@ -2341,6 +2185,7 @@ var CurrencyService = class {
|
|
|
2341
2185
|
this.ctx = ctx;
|
|
2342
2186
|
}
|
|
2343
2187
|
ctx;
|
|
2188
|
+
static channel = "currency";
|
|
2344
2189
|
base() {
|
|
2345
2190
|
return `/currency/${this.ctx.tenant}`;
|
|
2346
2191
|
}
|
|
@@ -2441,6 +2286,7 @@ var ShippingService = class {
|
|
|
2441
2286
|
this.ctx = ctx;
|
|
2442
2287
|
}
|
|
2443
2288
|
ctx;
|
|
2289
|
+
static channel = "shipping";
|
|
2444
2290
|
base() {
|
|
2445
2291
|
return `/shipping/${this.ctx.tenant}`;
|
|
2446
2292
|
}
|
|
@@ -2855,6 +2701,7 @@ var ReturnsService = class {
|
|
|
2855
2701
|
this.ctx = ctx;
|
|
2856
2702
|
}
|
|
2857
2703
|
ctx;
|
|
2704
|
+
static channel = "returns";
|
|
2858
2705
|
base() {
|
|
2859
2706
|
return `/return/${this.ctx.tenant}/returns`;
|
|
2860
2707
|
}
|
|
@@ -2919,6 +2766,7 @@ var SepaExportService = class {
|
|
|
2919
2766
|
this.ctx = ctx;
|
|
2920
2767
|
}
|
|
2921
2768
|
ctx;
|
|
2769
|
+
static channel = "sepa-export";
|
|
2922
2770
|
base() {
|
|
2923
2771
|
return `/sepa-export/${this.ctx.tenant}`;
|
|
2924
2772
|
}
|
|
@@ -2959,6 +2807,7 @@ var IndexingService = class {
|
|
|
2959
2807
|
this.ctx = ctx;
|
|
2960
2808
|
}
|
|
2961
2809
|
ctx;
|
|
2810
|
+
static channel = "indexing";
|
|
2962
2811
|
base() {
|
|
2963
2812
|
return `/indexing/${this.ctx.tenant}`;
|
|
2964
2813
|
}
|
|
@@ -3025,6 +2874,7 @@ var UnitHandlingService = class {
|
|
|
3025
2874
|
this.ctx = ctx;
|
|
3026
2875
|
}
|
|
3027
2876
|
ctx;
|
|
2877
|
+
static channel = "unit-handling";
|
|
3028
2878
|
base() {
|
|
3029
2879
|
return `/unit-handling/${this.ctx.tenant}`;
|
|
3030
2880
|
}
|
|
@@ -3106,6 +2956,7 @@ var CatalogService = class {
|
|
|
3106
2956
|
this.ctx = ctx;
|
|
3107
2957
|
}
|
|
3108
2958
|
ctx;
|
|
2959
|
+
static channel = "catalog";
|
|
3109
2960
|
base() {
|
|
3110
2961
|
return `/catalog/${this.ctx.tenant}/catalogs`;
|
|
3111
2962
|
}
|
|
@@ -3173,6 +3024,7 @@ var VendorService = class {
|
|
|
3173
3024
|
this.ctx = ctx;
|
|
3174
3025
|
}
|
|
3175
3026
|
ctx;
|
|
3027
|
+
static channel = "vendor";
|
|
3176
3028
|
base() {
|
|
3177
3029
|
return `/vendor/${this.ctx.tenant}`;
|
|
3178
3030
|
}
|
|
@@ -3272,6 +3124,7 @@ var PickPackService = class {
|
|
|
3272
3124
|
this.ctx = ctx;
|
|
3273
3125
|
}
|
|
3274
3126
|
ctx;
|
|
3127
|
+
static channel = "pick-pack";
|
|
3275
3128
|
base() {
|
|
3276
3129
|
return `/pick-pack/${this.ctx.tenant}`;
|
|
3277
3130
|
}
|
|
@@ -3363,6 +3216,7 @@ var CustomerAdminService = class {
|
|
|
3363
3216
|
this.ctx = ctx;
|
|
3364
3217
|
}
|
|
3365
3218
|
ctx;
|
|
3219
|
+
static channel = "customer-admin";
|
|
3366
3220
|
base() {
|
|
3367
3221
|
return `/customer/${this.ctx.tenant}/customers`;
|
|
3368
3222
|
}
|
|
@@ -3467,6 +3321,7 @@ var ApprovalService = class {
|
|
|
3467
3321
|
this.ctx = ctx;
|
|
3468
3322
|
}
|
|
3469
3323
|
ctx;
|
|
3324
|
+
static channel = "approval";
|
|
3470
3325
|
base() {
|
|
3471
3326
|
return `/approval/${this.ctx.tenant}`;
|
|
3472
3327
|
}
|
|
@@ -3533,12 +3388,6 @@ var ApprovalService = class {
|
|
|
3533
3388
|
}
|
|
3534
3389
|
};
|
|
3535
3390
|
|
|
3536
|
-
// package.json
|
|
3537
|
-
var version = "2.14.0";
|
|
3538
|
-
|
|
3539
|
-
// src/version.ts
|
|
3540
|
-
var SDK_VERSION = version;
|
|
3541
|
-
|
|
3542
3391
|
// src/client.ts
|
|
3543
3392
|
var EmporixClient = class {
|
|
3544
3393
|
customers;
|
|
@@ -3601,96 +3450,62 @@ var EmporixClient = class {
|
|
|
3601
3450
|
* Provider tree. Treat as read-only.
|
|
3602
3451
|
*/
|
|
3603
3452
|
config;
|
|
3604
|
-
|
|
3605
|
-
customerRefresh;
|
|
3606
|
-
requestContext;
|
|
3453
|
+
core;
|
|
3607
3454
|
constructor(config) {
|
|
3608
|
-
const
|
|
3609
|
-
this.
|
|
3610
|
-
this.
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
this.
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
sdkVersion: SDK_VERSION,
|
|
3624
|
-
tenant: cfg.tenant
|
|
3625
|
-
});
|
|
3626
|
-
const tokenProvider = cfg.tokenProvider ?? new DefaultTokenProvider(cfg);
|
|
3627
|
-
this.tokenProvider = tokenProvider;
|
|
3628
|
-
const customerRefresh = new CustomerRefreshRegistry();
|
|
3629
|
-
this.customerRefresh = customerRefresh;
|
|
3630
|
-
this.requestContext = { language: cfg.credentials.storefront?.context?.language };
|
|
3631
|
-
const requestContext = this.requestContext;
|
|
3632
|
-
const mk = (service) => ({
|
|
3633
|
-
tenant: cfg.tenant,
|
|
3634
|
-
tokenProvider,
|
|
3635
|
-
logger: root.child({ service }),
|
|
3636
|
-
http: new HttpClient({
|
|
3637
|
-
host: cfg.host,
|
|
3638
|
-
provider: tokenProvider,
|
|
3639
|
-
logger: root.child({ service: "http" }),
|
|
3640
|
-
retry: cfg.retry,
|
|
3641
|
-
timeouts: cfg.timeouts,
|
|
3642
|
-
customerRefresh,
|
|
3643
|
-
requestContext
|
|
3644
|
-
})
|
|
3645
|
-
});
|
|
3646
|
-
this.customers = new CustomerService(mk("customer"));
|
|
3647
|
-
this.products = new ProductService(mk("product"));
|
|
3648
|
-
this.categories = new CategoryService(mk("category"));
|
|
3649
|
-
this.carts = new CartService(mk("cart"));
|
|
3650
|
-
this.checkout = new CheckoutService(mk("checkout"));
|
|
3651
|
-
this.payments = new PaymentGatewayService(mk("payment"));
|
|
3652
|
-
this.prices = new PriceService(mk("price"));
|
|
3653
|
-
this.media = new MediaService(mk("media"));
|
|
3654
|
-
this.segments = new SegmentService(mk("segment"), {
|
|
3455
|
+
const core = createCore(config);
|
|
3456
|
+
this.core = core;
|
|
3457
|
+
this.tenant = core.tenant;
|
|
3458
|
+
this.config = core.config;
|
|
3459
|
+
this.tokenProvider = core.tokenProvider;
|
|
3460
|
+
const mk = core.mk;
|
|
3461
|
+
this.customers = new CustomerService(mk(CustomerService.channel));
|
|
3462
|
+
this.products = new ProductService(mk(ProductService.channel));
|
|
3463
|
+
this.categories = new CategoryService(mk(CategoryService.channel));
|
|
3464
|
+
this.carts = new CartService(mk(CartService.channel));
|
|
3465
|
+
this.checkout = new CheckoutService(mk(CheckoutService.channel));
|
|
3466
|
+
this.payments = new PaymentGatewayService(mk(PaymentGatewayService.channel));
|
|
3467
|
+
this.prices = new PriceService(mk(PriceService.channel));
|
|
3468
|
+
this.media = new MediaService(mk(MediaService.channel));
|
|
3469
|
+
this.segments = new SegmentService(mk(SegmentService.channel), {
|
|
3655
3470
|
products: this.products,
|
|
3656
3471
|
categories: this.categories
|
|
3657
3472
|
});
|
|
3658
|
-
this.sites = new SiteService(mk(
|
|
3659
|
-
this.sessionContext = new SessionContextService(mk(
|
|
3660
|
-
this.companies = new CompaniesService(mk(
|
|
3661
|
-
this.contacts = new ContactsService(mk(
|
|
3662
|
-
this.locations = new LocationsService(mk(
|
|
3663
|
-
this.customerGroups = new CustomerGroupsService(mk(
|
|
3664
|
-
this.orders = new OrdersService(mk(
|
|
3665
|
-
this.salesOrders = new SalesOrdersService(mk(
|
|
3666
|
-
this.availability = new AvailabilityService(mk(
|
|
3667
|
-
this.tenantConfig = new TenantConfigService(mk(
|
|
3668
|
-
this.clientConfig = new ClientConfigService(mk(
|
|
3669
|
-
this.shoppingLists = new ShoppingListService(mk(
|
|
3670
|
-
this.ragIndexer = new RagIndexerService(mk(
|
|
3671
|
-
this.sequentialIds = new SequentialIdService(mk(
|
|
3672
|
-
this.fees = new FeeService(mk(
|
|
3673
|
-
this.cloudFunctions = new CloudFunctionsService(mk(
|
|
3674
|
-
this.webhooks = new WebhookService(mk(
|
|
3675
|
-
this.schemas = new SchemaService(mk(
|
|
3676
|
-
this.ai = new AiService(mk(
|
|
3677
|
-
this.taxes = new TaxService(mk(
|
|
3678
|
-
this.coupons = new CouponService(mk(
|
|
3679
|
-
this.rewardPoints = new RewardPointsService(mk(
|
|
3680
|
-
this.brands = new BrandService(mk(
|
|
3681
|
-
this.labels = new LabelService(mk(
|
|
3682
|
-
this.countries = new CountryService(mk(
|
|
3683
|
-
this.currencies = new CurrencyService(mk(
|
|
3684
|
-
this.shipping = new ShippingService(mk(
|
|
3685
|
-
this.returns = new ReturnsService(mk(
|
|
3686
|
-
this.sepaExport = new SepaExportService(mk(
|
|
3687
|
-
this.indexing = new IndexingService(mk(
|
|
3688
|
-
this.units = new UnitHandlingService(mk(
|
|
3689
|
-
this.catalogs = new CatalogService(mk(
|
|
3690
|
-
this.vendors = new VendorService(mk(
|
|
3691
|
-
this.pickPack = new PickPackService(mk(
|
|
3692
|
-
this.customerAdmin = new CustomerAdminService(mk(
|
|
3693
|
-
this.approvals = new ApprovalService(mk(
|
|
3473
|
+
this.sites = new SiteService(mk(SiteService.channel));
|
|
3474
|
+
this.sessionContext = new SessionContextService(mk(SessionContextService.channel));
|
|
3475
|
+
this.companies = new CompaniesService(mk(CompaniesService.channel));
|
|
3476
|
+
this.contacts = new ContactsService(mk(ContactsService.channel));
|
|
3477
|
+
this.locations = new LocationsService(mk(LocationsService.channel));
|
|
3478
|
+
this.customerGroups = new CustomerGroupsService(mk(CustomerGroupsService.channel));
|
|
3479
|
+
this.orders = new OrdersService(mk(OrdersService.channel));
|
|
3480
|
+
this.salesOrders = new SalesOrdersService(mk(SalesOrdersService.channel));
|
|
3481
|
+
this.availability = new AvailabilityService(mk(AvailabilityService.channel));
|
|
3482
|
+
this.tenantConfig = new TenantConfigService(mk(TenantConfigService.channel));
|
|
3483
|
+
this.clientConfig = new ClientConfigService(mk(ClientConfigService.channel));
|
|
3484
|
+
this.shoppingLists = new ShoppingListService(mk(ShoppingListService.channel));
|
|
3485
|
+
this.ragIndexer = new RagIndexerService(mk(RagIndexerService.channel));
|
|
3486
|
+
this.sequentialIds = new SequentialIdService(mk(SequentialIdService.channel));
|
|
3487
|
+
this.fees = new FeeService(mk(FeeService.channel));
|
|
3488
|
+
this.cloudFunctions = new CloudFunctionsService(mk(CloudFunctionsService.channel));
|
|
3489
|
+
this.webhooks = new WebhookService(mk(WebhookService.channel));
|
|
3490
|
+
this.schemas = new SchemaService(mk(SchemaService.channel));
|
|
3491
|
+
this.ai = new AiService(mk(AiService.channel));
|
|
3492
|
+
this.taxes = new TaxService(mk(TaxService.channel));
|
|
3493
|
+
this.coupons = new CouponService(mk(CouponService.channel));
|
|
3494
|
+
this.rewardPoints = new RewardPointsService(mk(RewardPointsService.channel));
|
|
3495
|
+
this.brands = new BrandService(mk(BrandService.channel));
|
|
3496
|
+
this.labels = new LabelService(mk(LabelService.channel));
|
|
3497
|
+
this.countries = new CountryService(mk(CountryService.channel));
|
|
3498
|
+
this.currencies = new CurrencyService(mk(CurrencyService.channel));
|
|
3499
|
+
this.shipping = new ShippingService(mk(ShippingService.channel));
|
|
3500
|
+
this.returns = new ReturnsService(mk(ReturnsService.channel));
|
|
3501
|
+
this.sepaExport = new SepaExportService(mk(SepaExportService.channel));
|
|
3502
|
+
this.indexing = new IndexingService(mk(IndexingService.channel));
|
|
3503
|
+
this.units = new UnitHandlingService(mk(UnitHandlingService.channel));
|
|
3504
|
+
this.catalogs = new CatalogService(mk(CatalogService.channel));
|
|
3505
|
+
this.vendors = new VendorService(mk(VendorService.channel));
|
|
3506
|
+
this.pickPack = new PickPackService(mk(PickPackService.channel));
|
|
3507
|
+
this.customerAdmin = new CustomerAdminService(mk(CustomerAdminService.channel));
|
|
3508
|
+
this.approvals = new ApprovalService(mk(ApprovalService.channel));
|
|
3694
3509
|
}
|
|
3695
3510
|
/**
|
|
3696
3511
|
* Re-binds the storefront price context (currency / siteCode / targetLocation)
|
|
@@ -3703,21 +3518,15 @@ var EmporixClient = class {
|
|
|
3703
3518
|
* read); a language-only change does NOT re-mint the token.
|
|
3704
3519
|
*/
|
|
3705
3520
|
setStorefrontContext(ctx) {
|
|
3706
|
-
|
|
3707
|
-
this.requestContext.language = ctx.language || void 0;
|
|
3708
|
-
}
|
|
3709
|
-
const { language: _language, ...priceContext } = ctx;
|
|
3710
|
-
if (Object.keys(priceContext).length > 0) {
|
|
3711
|
-
this.tokenProvider.setAnonymousContext?.(priceContext);
|
|
3712
|
-
}
|
|
3521
|
+
this.core.setStorefrontContext(ctx);
|
|
3713
3522
|
}
|
|
3714
3523
|
/** Sets the runtime log level globally or for one service. */
|
|
3715
3524
|
setLogLevel(level, opts = {}) {
|
|
3716
|
-
this.
|
|
3525
|
+
this.core.setLogLevel(level, opts);
|
|
3717
3526
|
}
|
|
3718
3527
|
/** Returns the effective log level for a service. */
|
|
3719
3528
|
getLogLevel(service) {
|
|
3720
|
-
return this.
|
|
3529
|
+
return this.core.getLogLevel(service);
|
|
3721
3530
|
}
|
|
3722
3531
|
/**
|
|
3723
3532
|
* Registers (or clears with `null`) a customer-token refresher. When set, a
|
|
@@ -3726,10 +3535,34 @@ var EmporixClient = class {
|
|
|
3726
3535
|
* automatically via `autoRefreshCustomerToken`.
|
|
3727
3536
|
*/
|
|
3728
3537
|
setCustomerTokenRefresher(refresher) {
|
|
3729
|
-
this.
|
|
3538
|
+
this.core.setCustomerTokenRefresher(refresher);
|
|
3730
3539
|
}
|
|
3731
3540
|
};
|
|
3732
3541
|
|
|
3542
|
+
// src/create-emporix-client.ts
|
|
3543
|
+
function createEmporixClient(config, services) {
|
|
3544
|
+
const { mk, ...core } = createCore(config);
|
|
3545
|
+
const built = {};
|
|
3546
|
+
const entries = Object.entries(services);
|
|
3547
|
+
for (const [key, Svc] of entries) {
|
|
3548
|
+
if (!Svc.deps?.length) built[key] = new Svc(mk(Svc.channel));
|
|
3549
|
+
}
|
|
3550
|
+
for (const [key, Svc] of entries) {
|
|
3551
|
+
if (!Svc.deps?.length) continue;
|
|
3552
|
+
const deps = {};
|
|
3553
|
+
for (const dep of Svc.deps) {
|
|
3554
|
+
if (!(dep in built)) {
|
|
3555
|
+
throw new EmporixError(
|
|
3556
|
+
`createEmporixClient: "${key}" requires "${dep}" in the services map`
|
|
3557
|
+
);
|
|
3558
|
+
}
|
|
3559
|
+
deps[dep] = built[dep];
|
|
3560
|
+
}
|
|
3561
|
+
built[key] = new Svc(mk(Svc.channel), deps);
|
|
3562
|
+
}
|
|
3563
|
+
return { ...core, ...built };
|
|
3564
|
+
}
|
|
3565
|
+
|
|
3733
3566
|
// src/core/yrn.ts
|
|
3734
3567
|
function productIdFromYrn(yrn) {
|
|
3735
3568
|
if (!yrn) return "";
|
|
@@ -3737,6 +3570,6 @@ function productIdFromYrn(yrn) {
|
|
|
3737
3570
|
return semi >= 0 ? yrn.slice(semi + 1) : "";
|
|
3738
3571
|
}
|
|
3739
3572
|
|
|
3740
|
-
export { AiService, ApprovalService, BrandService, CatalogService, ClientConfigService, CloudFunctionsService, CountryService, CouponService, CurrencyService, CustomerAdminService,
|
|
3573
|
+
export { AiService, ApprovalService, BrandService, CatalogService, ClientConfigService, CloudFunctionsService, CountryService, CouponService, CurrencyService, CustomerAdminService, DEFAULT_HOST, EmporixClient, FeeService, HttpClient, IndexingService, LEVEL, LabelService, LevelResolver, PickPackService, RagIndexerService, ReturnsService, RewardPointsService, SchemaService, SepaExportService, SequentialIdService, SessionContextService, ShippingService, ShoppingListService, SiteService, TaxService, TenantConfigService, UnitHandlingService, VendorService, WebhookService, createConsoleLogger, createCore, createEmporixClient, createNoopLogger, productIdFromYrn, redact, validateConfig };
|
|
3741
3574
|
//# sourceMappingURL=index.js.map
|
|
3742
3575
|
//# sourceMappingURL=index.js.map
|