@viu/emporix-sdk 1.0.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 +407 -0
- package/LICENSE +21 -0
- package/README.md +115 -0
- package/dist/cart.cjs +214 -0
- package/dist/cart.cjs.map +1 -0
- package/dist/cart.d.cts +1807 -0
- package/dist/cart.d.ts +1807 -0
- package/dist/cart.js +4 -0
- package/dist/cart.js.map +1 -0
- package/dist/category.cjs +97 -0
- package/dist/category.cjs.map +1 -0
- package/dist/category.d.cts +313 -0
- package/dist/category.d.ts +313 -0
- package/dist/category.js +4 -0
- package/dist/category.js.map +1 -0
- package/dist/checkout.cjs +98 -0
- package/dist/checkout.cjs.map +1 -0
- package/dist/checkout.d.cts +252 -0
- package/dist/checkout.d.ts +252 -0
- package/dist/checkout.js +4 -0
- package/dist/checkout.js.map +1 -0
- package/dist/chunk-4BJUCCKJ.js +86 -0
- package/dist/chunk-4BJUCCKJ.js.map +1 -0
- package/dist/chunk-6UNFMCHZ.js +95 -0
- package/dist/chunk-6UNFMCHZ.js.map +1 -0
- package/dist/chunk-B56JZNI7.js +49 -0
- package/dist/chunk-B56JZNI7.js.map +1 -0
- package/dist/chunk-BFQ732VZ.js +11 -0
- package/dist/chunk-BFQ732VZ.js.map +1 -0
- package/dist/chunk-F3WAQH2E.js +120 -0
- package/dist/chunk-F3WAQH2E.js.map +1 -0
- package/dist/chunk-GWJ2U2CP.js +14 -0
- package/dist/chunk-GWJ2U2CP.js.map +1 -0
- package/dist/chunk-HEO34WLO.js +47 -0
- package/dist/chunk-HEO34WLO.js.map +1 -0
- package/dist/chunk-HKPZI7Y5.js +30 -0
- package/dist/chunk-HKPZI7Y5.js.map +1 -0
- package/dist/chunk-IEZHGU7F.js +171 -0
- package/dist/chunk-IEZHGU7F.js.map +1 -0
- package/dist/chunk-KTODT6DV.js +86 -0
- package/dist/chunk-KTODT6DV.js.map +1 -0
- package/dist/chunk-NM7VDXBR.js +57 -0
- package/dist/chunk-NM7VDXBR.js.map +1 -0
- package/dist/chunk-OMYVOOSX.js +57 -0
- package/dist/chunk-OMYVOOSX.js.map +1 -0
- package/dist/chunk-QDABAMVN.js +89 -0
- package/dist/chunk-QDABAMVN.js.map +1 -0
- package/dist/chunk-RXVVFNYN.js +56 -0
- package/dist/chunk-RXVVFNYN.js.map +1 -0
- package/dist/chunk-SKX7KCMH.js +23 -0
- package/dist/chunk-SKX7KCMH.js.map +1 -0
- package/dist/chunk-TLH6SLAF.js +215 -0
- package/dist/chunk-TLH6SLAF.js.map +1 -0
- package/dist/chunk-Z6PNI5VT.js +142 -0
- package/dist/chunk-Z6PNI5VT.js.map +1 -0
- package/dist/companies.cjs +58 -0
- package/dist/companies.cjs.map +1 -0
- package/dist/companies.d.cts +31 -0
- package/dist/companies.d.ts +31 -0
- package/dist/companies.js +3 -0
- package/dist/companies.js.map +1 -0
- package/dist/contacts.cjs +51 -0
- package/dist/contacts.cjs.map +1 -0
- package/dist/contacts.d.cts +28 -0
- package/dist/contacts.d.ts +28 -0
- package/dist/contacts.js +3 -0
- package/dist/contacts.js.map +1 -0
- package/dist/context-vKgzZ-5f.d.cts +329 -0
- package/dist/context-vKgzZ-5f.d.ts +329 -0
- package/dist/customer-groups.cjs +25 -0
- package/dist/customer-groups.cjs.map +1 -0
- package/dist/customer-groups.d.cts +36 -0
- package/dist/customer-groups.d.ts +36 -0
- package/dist/customer-groups.js +3 -0
- package/dist/customer-groups.js.map +1 -0
- package/dist/customer.cjs +262 -0
- package/dist/customer.cjs.map +1 -0
- package/dist/customer.d.cts +386 -0
- package/dist/customer.d.ts +386 -0
- package/dist/customer.js +5 -0
- package/dist/customer.js.map +1 -0
- package/dist/index.cjs +2075 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +218 -0
- package/dist/index.d.ts +218 -0
- package/dist/index.js +791 -0
- package/dist/index.js.map +1 -0
- package/dist/locations.cjs +59 -0
- package/dist/locations.cjs.map +1 -0
- package/dist/locations.d.cts +30 -0
- package/dist/locations.d.ts +30 -0
- package/dist/locations.js +3 -0
- package/dist/locations.js.map +1 -0
- package/dist/media.cjs +123 -0
- package/dist/media.cjs.map +1 -0
- package/dist/media.d.cts +219 -0
- package/dist/media.d.ts +219 -0
- package/dist/media.js +3 -0
- package/dist/media.js.map +1 -0
- package/dist/orders.cjs +98 -0
- package/dist/orders.cjs.map +1 -0
- package/dist/orders.d.cts +167 -0
- package/dist/orders.d.ts +167 -0
- package/dist/orders.js +3 -0
- package/dist/orders.js.map +1 -0
- package/dist/payment.cjs +77 -0
- package/dist/payment.cjs.map +1 -0
- package/dist/payment.d.cts +110 -0
- package/dist/payment.d.ts +110 -0
- package/dist/payment.js +5 -0
- package/dist/payment.js.map +1 -0
- package/dist/price.cjs +88 -0
- package/dist/price.cjs.map +1 -0
- package/dist/price.d.cts +445 -0
- package/dist/price.d.ts +445 -0
- package/dist/price.js +4 -0
- package/dist/price.js.map +1 -0
- package/dist/product.cjs +100 -0
- package/dist/product.cjs.map +1 -0
- package/dist/product.d.cts +400 -0
- package/dist/product.d.ts +400 -0
- package/dist/product.js +4 -0
- package/dist/product.js.map +1 -0
- package/dist/segment.cjs +189 -0
- package/dist/segment.cjs.map +1 -0
- package/dist/segment.d.cts +241 -0
- package/dist/segment.d.ts +241 -0
- package/dist/segment.js +5 -0
- package/dist/segment.js.map +1 -0
- package/dist/types.gen-D1QuqPLs.d.cts +166 -0
- package/dist/types.gen-D1QuqPLs.d.ts +166 -0
- package/package.json +141 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { C as ClientContext, b as AuthContext, T as TokenProvider, l as ResolvedConfig, E as EmporixConfig, h as LogLevel, m as ServiceName } from './context-vKgzZ-5f.cjs';
|
|
2
|
+
export { A as AnonymousSession, a as AnonymousSessionStore, c as AuthKind, D as DEFAULT_HOST, d as DefaultTokenProvider, H as HttpClient, e as HttpClientOptions, L as LEVEL, f as LevelResolver, g as LogFields, i as Logger, j as LoggerConfig, k as LoggerObjectConfig, P as PaginatedItems, R as RequestOptions, S as ServiceCredentials, n as StorefrontCredentials, o as auth, p as createConsoleLogger, q as createNoopLogger, r as iterateAll, s as redact, t as resolveToken, v as validateConfig } from './context-vKgzZ-5f.cjs';
|
|
3
|
+
import { CustomerService } from './customer.cjs';
|
|
4
|
+
export { Address, AddressCreateInput, AddressUpdateInput, Customer, CustomerSession, CustomerSignupInput, CustomerUpdateInput, PasswordChangeInput, PasswordResetConfirmInput, PasswordResetRequestInput } from './customer.cjs';
|
|
5
|
+
import { ProductService } from './product.cjs';
|
|
6
|
+
export { Media, Product } from './product.cjs';
|
|
7
|
+
import { CategoryService } from './category.cjs';
|
|
8
|
+
export { Category, CategoryNode } from './category.cjs';
|
|
9
|
+
import { CartService } from './cart.cjs';
|
|
10
|
+
export { Cart, CartAddress, CartCreated, CartItemInput, CartItemUpdate, CreateCartInput } from './cart.cjs';
|
|
11
|
+
import { CheckoutService } from './checkout.cjs';
|
|
12
|
+
export { CheckoutInput, CheckoutOptions, CheckoutResult, QuoteCheckoutInput } from './checkout.cjs';
|
|
13
|
+
import { PaymentGatewayService } from './payment.cjs';
|
|
14
|
+
export { AuthorizePaymentInput, AuthorizePaymentResult, PaymentMode } from './payment.cjs';
|
|
15
|
+
import { PriceService } from './price.cjs';
|
|
16
|
+
export { PriceMatch, PriceMatchByContextInput, PriceMatchInput } from './price.cjs';
|
|
17
|
+
import { MediaService } from './media.cjs';
|
|
18
|
+
export { Asset, AssetCreateBlobInput, AssetCreateLinkInput, AssetRefId, AssetUpdateInput } from './media.cjs';
|
|
19
|
+
import { SegmentService } from './segment.cjs';
|
|
20
|
+
export { Segment, SegmentCategoryTree, SegmentCategoryTreeNode, SegmentItem, SegmentServiceDeps } from './segment.cjs';
|
|
21
|
+
import { CompaniesService } from './companies.cjs';
|
|
22
|
+
import { ContactsService } from './contacts.cjs';
|
|
23
|
+
import { LocationsService } from './locations.cjs';
|
|
24
|
+
import { CustomerGroupsService } from './customer-groups.cjs';
|
|
25
|
+
export { IamGroup, IamGroupB2B } from './customer-groups.cjs';
|
|
26
|
+
import { OrdersService, SalesOrdersService } from './orders.cjs';
|
|
27
|
+
export { GetOrderOptions, ListMyOrdersOptions, Order, OrderAddress, OrderCustomer, OrderDelivery, OrderItem, OrderMetadata, OrderMoney, OrderPayment, OrderStatus, OrderTaxLine, OrderTransition, OrderTransitionOptions, SalesOrderPatch, UpdateSalesOrderOptions } from './orders.cjs';
|
|
28
|
+
export { A as AccountLimit, C as ContactAssignment, a as ContactAssignmentCreate, b as ContactAssignmentType, c as ContactAssignmentUpdate, d as ContactDetails, e as CustomerGroupRef, L as LegalEntity, f as LegalEntityCreate, g as LegalEntityType, h as LegalEntityUpdate, i as LegalInfo, j as Location, k as LocationCreate, l as LocationType, m as LocationUpdate } from './types.gen-D1QuqPLs.cjs';
|
|
29
|
+
|
|
30
|
+
/** Base class for every error thrown by the SDK. */
|
|
31
|
+
declare class EmporixError extends Error {
|
|
32
|
+
readonly status: number | undefined;
|
|
33
|
+
readonly body: unknown;
|
|
34
|
+
constructor(message: string, status?: number, body?: unknown);
|
|
35
|
+
/** Safe serialisation — token-like body fields are redacted. */
|
|
36
|
+
toJSON(): Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
/** 401 — authentication failed or token expired. */
|
|
39
|
+
declare class EmporixAuthError extends EmporixError {
|
|
40
|
+
}
|
|
41
|
+
/** 403 — authenticated but not permitted. */
|
|
42
|
+
declare class EmporixForbiddenError extends EmporixError {
|
|
43
|
+
}
|
|
44
|
+
/** 404 — resource not found. */
|
|
45
|
+
declare class EmporixNotFoundError extends EmporixError {
|
|
46
|
+
}
|
|
47
|
+
/** 400/422 — request validation failed. */
|
|
48
|
+
declare class EmporixValidationError extends EmporixError {
|
|
49
|
+
}
|
|
50
|
+
/** 5xx — server-side failure. */
|
|
51
|
+
declare class EmporixServerError extends EmporixError {
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 403 with a `missing scope: <name>` hint in the body's `details` array.
|
|
55
|
+
* Subclasses {@link EmporixForbiddenError} so existing 403 catches still work.
|
|
56
|
+
*/
|
|
57
|
+
declare class EmporixInsufficientScopeError extends EmporixForbiddenError {
|
|
58
|
+
readonly requiredScope: string | undefined;
|
|
59
|
+
constructor(message: string, status: number, body: unknown, requiredScope?: string);
|
|
60
|
+
}
|
|
61
|
+
/** Maps an HTTP status to the matching {@link EmporixError} subclass. */
|
|
62
|
+
declare function errorFromResponse(status: number, message: string, body: unknown): EmporixError;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* One site as returned by the Site Settings Service. Mirrors the public
|
|
66
|
+
* SiteDto schema with the fields a storefront actually consumes.
|
|
67
|
+
*/
|
|
68
|
+
interface Site {
|
|
69
|
+
code: string;
|
|
70
|
+
name: string;
|
|
71
|
+
active: boolean;
|
|
72
|
+
default: boolean;
|
|
73
|
+
includesTax?: boolean;
|
|
74
|
+
defaultLanguage: string;
|
|
75
|
+
languages: string[];
|
|
76
|
+
currency: string;
|
|
77
|
+
availableCurrencies?: string[];
|
|
78
|
+
homeBase: {
|
|
79
|
+
address: {
|
|
80
|
+
country: string;
|
|
81
|
+
zipCode: string;
|
|
82
|
+
street?: string;
|
|
83
|
+
city?: string;
|
|
84
|
+
state?: string;
|
|
85
|
+
};
|
|
86
|
+
timezone?: string;
|
|
87
|
+
};
|
|
88
|
+
shipToCountries: string[];
|
|
89
|
+
cartCalculationScale?: number;
|
|
90
|
+
metadata?: {
|
|
91
|
+
version?: number;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Read-only access to the tenant's site catalog. List returns active sites
|
|
96
|
+
* visible to the storefront context (the `site_manage` scope is only needed
|
|
97
|
+
* to read inactive sites).
|
|
98
|
+
*/
|
|
99
|
+
declare class SiteService {
|
|
100
|
+
private readonly ctx;
|
|
101
|
+
constructor(ctx: ClientContext);
|
|
102
|
+
/** Lists active sites. */
|
|
103
|
+
list(authCtx?: AuthContext): Promise<Site[]>;
|
|
104
|
+
/** Retrieves one site by code. */
|
|
105
|
+
get(code: string, authCtx?: AuthContext): Promise<Site>;
|
|
106
|
+
/**
|
|
107
|
+
* Returns the tenant's default site (the one with `default: true`).
|
|
108
|
+
* Throws if no default is configured — a tenant should always have one.
|
|
109
|
+
*/
|
|
110
|
+
current(authCtx?: AuthContext): Promise<Site>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* One session context as returned by `GET /session-context/{tenant}/me/context`.
|
|
115
|
+
* Created server-side when the user creates a cart. Until then, the server
|
|
116
|
+
* returns 404 and {@link SessionContextService.get} resolves to `null`.
|
|
117
|
+
*/
|
|
118
|
+
interface SessionContext {
|
|
119
|
+
sessionId: string;
|
|
120
|
+
customerId?: string;
|
|
121
|
+
siteCode?: string;
|
|
122
|
+
currency?: string;
|
|
123
|
+
cartId?: string;
|
|
124
|
+
targetLocation?: string;
|
|
125
|
+
language?: string;
|
|
126
|
+
context?: Record<string, unknown>;
|
|
127
|
+
metadata?: {
|
|
128
|
+
version?: number;
|
|
129
|
+
createdAt?: string;
|
|
130
|
+
modifiedAt?: string;
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Input for {@link SessionContextService.patch}. Only the listed fields are
|
|
135
|
+
* accepted by the server; everything else is ignored.
|
|
136
|
+
*
|
|
137
|
+
* If `version` is omitted, the service fetches the current version via GET
|
|
138
|
+
* before PATCHing (one extra round-trip). Pass it explicitly when you already
|
|
139
|
+
* know it (e.g. after a `get()` call earlier in the same flow).
|
|
140
|
+
*/
|
|
141
|
+
interface SessionContextPatch {
|
|
142
|
+
siteCode?: string;
|
|
143
|
+
currency?: string;
|
|
144
|
+
targetLocation?: string;
|
|
145
|
+
language?: string;
|
|
146
|
+
context?: Record<string, unknown>;
|
|
147
|
+
/** Override for optimistic-locking version. If omitted, GET resolves it. */
|
|
148
|
+
version?: number;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Session-context binding for the current storefront session. Both endpoints
|
|
152
|
+
* resolve the session-id from the `Authorization` token — no path/query
|
|
153
|
+
* parameter required.
|
|
154
|
+
*/
|
|
155
|
+
declare class SessionContextService {
|
|
156
|
+
private readonly ctx;
|
|
157
|
+
constructor(ctx: ClientContext);
|
|
158
|
+
/**
|
|
159
|
+
* Retrieves the current session context, or `null` when the server returns
|
|
160
|
+
* 404 (no session exists yet — the session-context is created server-side
|
|
161
|
+
* only after the user creates a cart).
|
|
162
|
+
*/
|
|
163
|
+
get(authCtx?: AuthContext): Promise<SessionContext | null>;
|
|
164
|
+
/**
|
|
165
|
+
* Partially updates the current session context. Returns `true` when the
|
|
166
|
+
* PATCH was applied, `false` when there is no session context yet (the
|
|
167
|
+
* server returned 404 on the version-lookup GET, so there is nothing to
|
|
168
|
+
* update). Non-404 errors propagate.
|
|
169
|
+
*/
|
|
170
|
+
patch(input: SessionContextPatch, authCtx?: AuthContext): Promise<boolean>;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** The Emporix SDK entry point. One instance safely serves many concurrent shoppers. */
|
|
174
|
+
declare class EmporixClient {
|
|
175
|
+
readonly customers: CustomerService;
|
|
176
|
+
readonly products: ProductService;
|
|
177
|
+
readonly categories: CategoryService;
|
|
178
|
+
readonly carts: CartService;
|
|
179
|
+
readonly checkout: CheckoutService;
|
|
180
|
+
readonly payments: PaymentGatewayService;
|
|
181
|
+
readonly prices: PriceService;
|
|
182
|
+
readonly media: MediaService;
|
|
183
|
+
readonly segments: SegmentService;
|
|
184
|
+
readonly sites: SiteService;
|
|
185
|
+
readonly sessionContext: SessionContextService;
|
|
186
|
+
readonly companies: CompaniesService;
|
|
187
|
+
readonly contacts: ContactsService;
|
|
188
|
+
readonly locations: LocationsService;
|
|
189
|
+
readonly customerGroups: CustomerGroupsService;
|
|
190
|
+
readonly orders: OrdersService;
|
|
191
|
+
readonly salesOrders: SalesOrdersService;
|
|
192
|
+
/** The validated tenant this client is bound to. */
|
|
193
|
+
readonly tenant: string;
|
|
194
|
+
/**
|
|
195
|
+
* The token provider in use by this client. Exposed so React/Next hosts can
|
|
196
|
+
* call `attachAnonymousStore` to wire session persistence. Treat as
|
|
197
|
+
* read-only — replacing it after construction is not supported.
|
|
198
|
+
*/
|
|
199
|
+
readonly tokenProvider: TokenProvider;
|
|
200
|
+
/**
|
|
201
|
+
* The validated config used to construct this client. Exposed so React /
|
|
202
|
+
* Next hosts can read static settings such as `credentials.storefront.context`
|
|
203
|
+
* (siteCode, currency, targetLocation) without re-plumbing them through the
|
|
204
|
+
* Provider tree. Treat as read-only.
|
|
205
|
+
*/
|
|
206
|
+
readonly config: ResolvedConfig;
|
|
207
|
+
private readonly resolver;
|
|
208
|
+
constructor(config: EmporixConfig);
|
|
209
|
+
/** Sets the runtime log level globally or for one service. */
|
|
210
|
+
setLogLevel(level: LogLevel, opts?: {
|
|
211
|
+
service?: ServiceName;
|
|
212
|
+
force?: boolean;
|
|
213
|
+
}): void;
|
|
214
|
+
/** Returns the effective log level for a service. */
|
|
215
|
+
getLogLevel(service: ServiceName): LogLevel;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export { AuthContext, CartService, CategoryService, CheckoutService, ClientContext, CompaniesService, ContactsService, CustomerGroupsService, CustomerService, EmporixAuthError, EmporixClient, EmporixConfig, EmporixError, EmporixForbiddenError, EmporixInsufficientScopeError, EmporixNotFoundError, EmporixServerError, EmporixValidationError, LocationsService, LogLevel, MediaService, OrdersService, PaymentGatewayService, PriceService, ProductService, ResolvedConfig, SalesOrdersService, SegmentService, ServiceName, type SessionContext, type SessionContextPatch, SessionContextService, type Site, SiteService, TokenProvider, errorFromResponse };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { C as ClientContext, b as AuthContext, T as TokenProvider, l as ResolvedConfig, E as EmporixConfig, h as LogLevel, m as ServiceName } from './context-vKgzZ-5f.js';
|
|
2
|
+
export { A as AnonymousSession, a as AnonymousSessionStore, c as AuthKind, D as DEFAULT_HOST, d as DefaultTokenProvider, H as HttpClient, e as HttpClientOptions, L as LEVEL, f as LevelResolver, g as LogFields, i as Logger, j as LoggerConfig, k as LoggerObjectConfig, P as PaginatedItems, R as RequestOptions, S as ServiceCredentials, n as StorefrontCredentials, o as auth, p as createConsoleLogger, q as createNoopLogger, r as iterateAll, s as redact, t as resolveToken, v as validateConfig } from './context-vKgzZ-5f.js';
|
|
3
|
+
import { CustomerService } from './customer.js';
|
|
4
|
+
export { Address, AddressCreateInput, AddressUpdateInput, Customer, CustomerSession, CustomerSignupInput, CustomerUpdateInput, PasswordChangeInput, PasswordResetConfirmInput, PasswordResetRequestInput } from './customer.js';
|
|
5
|
+
import { ProductService } from './product.js';
|
|
6
|
+
export { Media, Product } from './product.js';
|
|
7
|
+
import { CategoryService } from './category.js';
|
|
8
|
+
export { Category, CategoryNode } from './category.js';
|
|
9
|
+
import { CartService } from './cart.js';
|
|
10
|
+
export { Cart, CartAddress, CartCreated, CartItemInput, CartItemUpdate, CreateCartInput } from './cart.js';
|
|
11
|
+
import { CheckoutService } from './checkout.js';
|
|
12
|
+
export { CheckoutInput, CheckoutOptions, CheckoutResult, QuoteCheckoutInput } from './checkout.js';
|
|
13
|
+
import { PaymentGatewayService } from './payment.js';
|
|
14
|
+
export { AuthorizePaymentInput, AuthorizePaymentResult, PaymentMode } from './payment.js';
|
|
15
|
+
import { PriceService } from './price.js';
|
|
16
|
+
export { PriceMatch, PriceMatchByContextInput, PriceMatchInput } from './price.js';
|
|
17
|
+
import { MediaService } from './media.js';
|
|
18
|
+
export { Asset, AssetCreateBlobInput, AssetCreateLinkInput, AssetRefId, AssetUpdateInput } from './media.js';
|
|
19
|
+
import { SegmentService } from './segment.js';
|
|
20
|
+
export { Segment, SegmentCategoryTree, SegmentCategoryTreeNode, SegmentItem, SegmentServiceDeps } from './segment.js';
|
|
21
|
+
import { CompaniesService } from './companies.js';
|
|
22
|
+
import { ContactsService } from './contacts.js';
|
|
23
|
+
import { LocationsService } from './locations.js';
|
|
24
|
+
import { CustomerGroupsService } from './customer-groups.js';
|
|
25
|
+
export { IamGroup, IamGroupB2B } from './customer-groups.js';
|
|
26
|
+
import { OrdersService, SalesOrdersService } from './orders.js';
|
|
27
|
+
export { GetOrderOptions, ListMyOrdersOptions, Order, OrderAddress, OrderCustomer, OrderDelivery, OrderItem, OrderMetadata, OrderMoney, OrderPayment, OrderStatus, OrderTaxLine, OrderTransition, OrderTransitionOptions, SalesOrderPatch, UpdateSalesOrderOptions } from './orders.js';
|
|
28
|
+
export { A as AccountLimit, C as ContactAssignment, a as ContactAssignmentCreate, b as ContactAssignmentType, c as ContactAssignmentUpdate, d as ContactDetails, e as CustomerGroupRef, L as LegalEntity, f as LegalEntityCreate, g as LegalEntityType, h as LegalEntityUpdate, i as LegalInfo, j as Location, k as LocationCreate, l as LocationType, m as LocationUpdate } from './types.gen-D1QuqPLs.js';
|
|
29
|
+
|
|
30
|
+
/** Base class for every error thrown by the SDK. */
|
|
31
|
+
declare class EmporixError extends Error {
|
|
32
|
+
readonly status: number | undefined;
|
|
33
|
+
readonly body: unknown;
|
|
34
|
+
constructor(message: string, status?: number, body?: unknown);
|
|
35
|
+
/** Safe serialisation — token-like body fields are redacted. */
|
|
36
|
+
toJSON(): Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
/** 401 — authentication failed or token expired. */
|
|
39
|
+
declare class EmporixAuthError extends EmporixError {
|
|
40
|
+
}
|
|
41
|
+
/** 403 — authenticated but not permitted. */
|
|
42
|
+
declare class EmporixForbiddenError extends EmporixError {
|
|
43
|
+
}
|
|
44
|
+
/** 404 — resource not found. */
|
|
45
|
+
declare class EmporixNotFoundError extends EmporixError {
|
|
46
|
+
}
|
|
47
|
+
/** 400/422 — request validation failed. */
|
|
48
|
+
declare class EmporixValidationError extends EmporixError {
|
|
49
|
+
}
|
|
50
|
+
/** 5xx — server-side failure. */
|
|
51
|
+
declare class EmporixServerError extends EmporixError {
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 403 with a `missing scope: <name>` hint in the body's `details` array.
|
|
55
|
+
* Subclasses {@link EmporixForbiddenError} so existing 403 catches still work.
|
|
56
|
+
*/
|
|
57
|
+
declare class EmporixInsufficientScopeError extends EmporixForbiddenError {
|
|
58
|
+
readonly requiredScope: string | undefined;
|
|
59
|
+
constructor(message: string, status: number, body: unknown, requiredScope?: string);
|
|
60
|
+
}
|
|
61
|
+
/** Maps an HTTP status to the matching {@link EmporixError} subclass. */
|
|
62
|
+
declare function errorFromResponse(status: number, message: string, body: unknown): EmporixError;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* One site as returned by the Site Settings Service. Mirrors the public
|
|
66
|
+
* SiteDto schema with the fields a storefront actually consumes.
|
|
67
|
+
*/
|
|
68
|
+
interface Site {
|
|
69
|
+
code: string;
|
|
70
|
+
name: string;
|
|
71
|
+
active: boolean;
|
|
72
|
+
default: boolean;
|
|
73
|
+
includesTax?: boolean;
|
|
74
|
+
defaultLanguage: string;
|
|
75
|
+
languages: string[];
|
|
76
|
+
currency: string;
|
|
77
|
+
availableCurrencies?: string[];
|
|
78
|
+
homeBase: {
|
|
79
|
+
address: {
|
|
80
|
+
country: string;
|
|
81
|
+
zipCode: string;
|
|
82
|
+
street?: string;
|
|
83
|
+
city?: string;
|
|
84
|
+
state?: string;
|
|
85
|
+
};
|
|
86
|
+
timezone?: string;
|
|
87
|
+
};
|
|
88
|
+
shipToCountries: string[];
|
|
89
|
+
cartCalculationScale?: number;
|
|
90
|
+
metadata?: {
|
|
91
|
+
version?: number;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Read-only access to the tenant's site catalog. List returns active sites
|
|
96
|
+
* visible to the storefront context (the `site_manage` scope is only needed
|
|
97
|
+
* to read inactive sites).
|
|
98
|
+
*/
|
|
99
|
+
declare class SiteService {
|
|
100
|
+
private readonly ctx;
|
|
101
|
+
constructor(ctx: ClientContext);
|
|
102
|
+
/** Lists active sites. */
|
|
103
|
+
list(authCtx?: AuthContext): Promise<Site[]>;
|
|
104
|
+
/** Retrieves one site by code. */
|
|
105
|
+
get(code: string, authCtx?: AuthContext): Promise<Site>;
|
|
106
|
+
/**
|
|
107
|
+
* Returns the tenant's default site (the one with `default: true`).
|
|
108
|
+
* Throws if no default is configured — a tenant should always have one.
|
|
109
|
+
*/
|
|
110
|
+
current(authCtx?: AuthContext): Promise<Site>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* One session context as returned by `GET /session-context/{tenant}/me/context`.
|
|
115
|
+
* Created server-side when the user creates a cart. Until then, the server
|
|
116
|
+
* returns 404 and {@link SessionContextService.get} resolves to `null`.
|
|
117
|
+
*/
|
|
118
|
+
interface SessionContext {
|
|
119
|
+
sessionId: string;
|
|
120
|
+
customerId?: string;
|
|
121
|
+
siteCode?: string;
|
|
122
|
+
currency?: string;
|
|
123
|
+
cartId?: string;
|
|
124
|
+
targetLocation?: string;
|
|
125
|
+
language?: string;
|
|
126
|
+
context?: Record<string, unknown>;
|
|
127
|
+
metadata?: {
|
|
128
|
+
version?: number;
|
|
129
|
+
createdAt?: string;
|
|
130
|
+
modifiedAt?: string;
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Input for {@link SessionContextService.patch}. Only the listed fields are
|
|
135
|
+
* accepted by the server; everything else is ignored.
|
|
136
|
+
*
|
|
137
|
+
* If `version` is omitted, the service fetches the current version via GET
|
|
138
|
+
* before PATCHing (one extra round-trip). Pass it explicitly when you already
|
|
139
|
+
* know it (e.g. after a `get()` call earlier in the same flow).
|
|
140
|
+
*/
|
|
141
|
+
interface SessionContextPatch {
|
|
142
|
+
siteCode?: string;
|
|
143
|
+
currency?: string;
|
|
144
|
+
targetLocation?: string;
|
|
145
|
+
language?: string;
|
|
146
|
+
context?: Record<string, unknown>;
|
|
147
|
+
/** Override for optimistic-locking version. If omitted, GET resolves it. */
|
|
148
|
+
version?: number;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Session-context binding for the current storefront session. Both endpoints
|
|
152
|
+
* resolve the session-id from the `Authorization` token — no path/query
|
|
153
|
+
* parameter required.
|
|
154
|
+
*/
|
|
155
|
+
declare class SessionContextService {
|
|
156
|
+
private readonly ctx;
|
|
157
|
+
constructor(ctx: ClientContext);
|
|
158
|
+
/**
|
|
159
|
+
* Retrieves the current session context, or `null` when the server returns
|
|
160
|
+
* 404 (no session exists yet — the session-context is created server-side
|
|
161
|
+
* only after the user creates a cart).
|
|
162
|
+
*/
|
|
163
|
+
get(authCtx?: AuthContext): Promise<SessionContext | null>;
|
|
164
|
+
/**
|
|
165
|
+
* Partially updates the current session context. Returns `true` when the
|
|
166
|
+
* PATCH was applied, `false` when there is no session context yet (the
|
|
167
|
+
* server returned 404 on the version-lookup GET, so there is nothing to
|
|
168
|
+
* update). Non-404 errors propagate.
|
|
169
|
+
*/
|
|
170
|
+
patch(input: SessionContextPatch, authCtx?: AuthContext): Promise<boolean>;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** The Emporix SDK entry point. One instance safely serves many concurrent shoppers. */
|
|
174
|
+
declare class EmporixClient {
|
|
175
|
+
readonly customers: CustomerService;
|
|
176
|
+
readonly products: ProductService;
|
|
177
|
+
readonly categories: CategoryService;
|
|
178
|
+
readonly carts: CartService;
|
|
179
|
+
readonly checkout: CheckoutService;
|
|
180
|
+
readonly payments: PaymentGatewayService;
|
|
181
|
+
readonly prices: PriceService;
|
|
182
|
+
readonly media: MediaService;
|
|
183
|
+
readonly segments: SegmentService;
|
|
184
|
+
readonly sites: SiteService;
|
|
185
|
+
readonly sessionContext: SessionContextService;
|
|
186
|
+
readonly companies: CompaniesService;
|
|
187
|
+
readonly contacts: ContactsService;
|
|
188
|
+
readonly locations: LocationsService;
|
|
189
|
+
readonly customerGroups: CustomerGroupsService;
|
|
190
|
+
readonly orders: OrdersService;
|
|
191
|
+
readonly salesOrders: SalesOrdersService;
|
|
192
|
+
/** The validated tenant this client is bound to. */
|
|
193
|
+
readonly tenant: string;
|
|
194
|
+
/**
|
|
195
|
+
* The token provider in use by this client. Exposed so React/Next hosts can
|
|
196
|
+
* call `attachAnonymousStore` to wire session persistence. Treat as
|
|
197
|
+
* read-only — replacing it after construction is not supported.
|
|
198
|
+
*/
|
|
199
|
+
readonly tokenProvider: TokenProvider;
|
|
200
|
+
/**
|
|
201
|
+
* The validated config used to construct this client. Exposed so React /
|
|
202
|
+
* Next hosts can read static settings such as `credentials.storefront.context`
|
|
203
|
+
* (siteCode, currency, targetLocation) without re-plumbing them through the
|
|
204
|
+
* Provider tree. Treat as read-only.
|
|
205
|
+
*/
|
|
206
|
+
readonly config: ResolvedConfig;
|
|
207
|
+
private readonly resolver;
|
|
208
|
+
constructor(config: EmporixConfig);
|
|
209
|
+
/** Sets the runtime log level globally or for one service. */
|
|
210
|
+
setLogLevel(level: LogLevel, opts?: {
|
|
211
|
+
service?: ServiceName;
|
|
212
|
+
force?: boolean;
|
|
213
|
+
}): void;
|
|
214
|
+
/** Returns the effective log level for a service. */
|
|
215
|
+
getLogLevel(service: ServiceName): LogLevel;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export { AuthContext, CartService, CategoryService, CheckoutService, ClientContext, CompaniesService, ContactsService, CustomerGroupsService, CustomerService, EmporixAuthError, EmporixClient, EmporixConfig, EmporixError, EmporixForbiddenError, EmporixInsufficientScopeError, EmporixNotFoundError, EmporixServerError, EmporixValidationError, LocationsService, LogLevel, MediaService, OrdersService, PaymentGatewayService, PriceService, ProductService, ResolvedConfig, SalesOrdersService, SegmentService, ServiceName, type SessionContext, type SessionContextPatch, SessionContextService, type Site, SiteService, TokenProvider, errorFromResponse };
|