@viu/emporix-sdk 2.29.0 → 2.31.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 +104 -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-6PJFOX3A.js → chunk-4VRUMCS2.js} +8 -5
- package/dist/chunk-4VRUMCS2.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-B5rWL6QD.d.cts → context-CpLIDl0P.d.cts} +24 -9
- package/dist/{context-B5rWL6QD.d.ts → context-CpLIDl0P.d.ts} +24 -9
- package/dist/{customer-groups-_czUdHab.d.cts → customer-groups-DJVbdrEP.d.cts} +1 -1
- package/dist/{customer-groups-BRN6I23C.d.ts → customer-groups-DhpCTCTg.d.ts} +1 -1
- package/dist/customer-groups.d.cts +2 -2
- package/dist/customer-groups.d.ts +2 -2
- package/dist/customer.d.cts +1 -1
- package/dist/customer.d.ts +1 -1
- package/dist/index.cjs +84 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +179 -4
- package/dist/index.d.ts +179 -4
- package/dist/index.js +76 -4
- package/dist/index.js.map +1 -1
- package/dist/locations.d.cts +1 -1
- package/dist/locations.d.ts +1 -1
- package/dist/media.d.cts +1 -1
- package/dist/media.d.ts +1 -1
- package/dist/orders.d.cts +1 -1
- package/dist/orders.d.ts +1 -1
- package/dist/payment.cjs.map +1 -1
- package/dist/payment.d.cts +1 -1
- package/dist/payment.d.ts +1 -1
- package/dist/payment.js +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-6PJFOX3A.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
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,
|
|
1
|
+
import { p as StoredAnonymousSession, b as AuthContext, C as ClientContext, P as PaginatedItems, T as TokenProvider, n as ResolvedConfig, E as EmporixConfig, j as LogLevel, o as ServiceName, e as CustomerTokenRefresher } from './context-CpLIDl0P.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, q as StorefrontCredentials, r as auth, s as createConsoleLogger, t as createNoopLogger, u as iterateAll, v as redact, w as resolveToken, x as validateConfig } from './context-CpLIDl0P.cjs';
|
|
3
3
|
import { CustomerService } from './customer.cjs';
|
|
4
4
|
export { Address, AddressCreateInput, AddressUpdateInput, ChangeEmailInput, ConfirmEmailChangeInput, Customer, CustomerSession, CustomerSignupInput, CustomerUpdateInput, PasswordChangeInput, PasswordResetConfirmInput, PasswordResetRequestInput, ResendActivationInput } from './customer.cjs';
|
|
5
5
|
import { ProductService } from './product.cjs';
|
|
@@ -21,7 +21,7 @@ export { Segment, SegmentAssignmentBulkResult, SegmentBulkItem, SegmentBulkResul
|
|
|
21
21
|
import { CompaniesService } from './companies.cjs';
|
|
22
22
|
import { ContactsService } from './contacts.cjs';
|
|
23
23
|
import { LocationsService } from './locations.cjs';
|
|
24
|
-
import { m as UserResponse, U as UserCreateRequest, l as UserIdResponse, k as UserExtendedResponse, o as UserUpdateRequest, j as GroupsQueryDocument, n as UserScopesResponse, a as AccessControlQueryDocument, G as GroupCreateRequest, h as GroupIdResponse, i as GroupUpdateRequest, c as AssignmentCreateRequest, d as AssignmentIdResponse, b as AccessControlUpsertRequest, A as AccessControlIdResponse, e as CustomScopeQueryDocument, f as CustomScopeUpsertRequest, C as CustomScopeIdResponse, g as CustomerGroupsService } from './customer-groups-
|
|
24
|
+
import { m as UserResponse, U as UserCreateRequest, l as UserIdResponse, k as UserExtendedResponse, o as UserUpdateRequest, j as GroupsQueryDocument, n as UserScopesResponse, a as AccessControlQueryDocument, G as GroupCreateRequest, h as GroupIdResponse, i as GroupUpdateRequest, c as AssignmentCreateRequest, d as AssignmentIdResponse, b as AccessControlUpsertRequest, A as AccessControlIdResponse, e as CustomScopeQueryDocument, f as CustomScopeUpsertRequest, C as CustomScopeIdResponse, g as CustomerGroupsService } from './customer-groups-DJVbdrEP.cjs';
|
|
25
25
|
import { OrdersService, SalesOrdersService } from './orders.cjs';
|
|
26
26
|
export { GetOrderOptions, ListLegalEntityOrdersOptions, ListMyOrdersOptions, ListSalesOrdersOptions, Order, OrderEntry, OrderStatus, OrderTransitionOptions, SalesOrder, SalesOrderCalculationInput, SalesOrderCreateInput, SalesOrderCreated, SalesOrderEntriesInput, SalesOrderHistoricalTransitions, SalesOrderPatch, SalesOrderReplaceInput, SalesOrderSearchInput, SalesOrderSplitInput, SalesOrderSplitResult, Transition, UpdateSalesOrderOptions } from './orders.cjs';
|
|
27
27
|
import { AvailabilityService } from './availability.cjs';
|
|
@@ -70,6 +70,170 @@ declare class EmporixInsufficientScopeError extends EmporixForbiddenError {
|
|
|
70
70
|
/** Maps an HTTP status to the matching {@link EmporixError} subclass. */
|
|
71
71
|
declare function errorFromResponse(status: number, message: string, body: unknown): EmporixError;
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* The persisted session-state contract, shared by every host.
|
|
75
|
+
*
|
|
76
|
+
* It lives in the core SDK rather than in `@viu/emporix-sdk-react` because it is
|
|
77
|
+
* not a React concern: the same eight keys are cookie names in a Next
|
|
78
|
+
* `proxy.ts`, Web Storage keys in a browser adapter, and record fields in a
|
|
79
|
+
* server-side session store. Keeping it here is what let
|
|
80
|
+
* `@viu/emporix-sdk-next` drop its dependency on the React package — it needed
|
|
81
|
+
* these strings, not React.
|
|
82
|
+
*
|
|
83
|
+
* `@viu/emporix-sdk-react` re-exports both from `./storage` and `/ssr`, so
|
|
84
|
+
* existing imports keep working.
|
|
85
|
+
*/
|
|
86
|
+
/** Keys that participate in {@link EmporixStorage.subscribeAll}. */
|
|
87
|
+
type EmporixStorageKey = "customerToken" | "cartId" | "siteCode" | "language" | "anonymousSession" | "activeLegalEntityId" | "refreshToken" | "saasToken";
|
|
88
|
+
/**
|
|
89
|
+
* The eight persisted session keys, as the strings each backend actually uses.
|
|
90
|
+
* Same strings on purpose — a value written by one backend must be readable by
|
|
91
|
+
* the next, and the cookie set by a Next `proxy.ts` has to be the one
|
|
92
|
+
* `createCookieStorage` looks for.
|
|
93
|
+
*
|
|
94
|
+
* The `satisfies` is the point, not the deduplication: a ninth
|
|
95
|
+
* {@link EmporixStorageKey} without an entry here is a compile error, and an
|
|
96
|
+
* entry here without a union member is too. `as const` stays in front of it so
|
|
97
|
+
* the literal types survive for consumers.
|
|
98
|
+
*/
|
|
99
|
+
declare const STORAGE_KEYS: {
|
|
100
|
+
readonly customerToken: "emporix.customerToken";
|
|
101
|
+
readonly cartId: "emporix.cartId";
|
|
102
|
+
readonly anonymousSession: "emporix.anonymousSession";
|
|
103
|
+
readonly siteCode: "emporix.siteCode";
|
|
104
|
+
readonly language: "emporix.language";
|
|
105
|
+
readonly activeLegalEntityId: "emporix.activeLegalEntityId";
|
|
106
|
+
readonly refreshToken: "emporix.refreshToken";
|
|
107
|
+
readonly saasToken: "emporix.saasToken";
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The persisted-session layer: the {@link EmporixStorage} contract and the two
|
|
112
|
+
* framework-free implementations of it that are not browser-specific.
|
|
113
|
+
*
|
|
114
|
+
* It lives in the core SDK for the same reason {@link STORAGE_KEYS} does — none
|
|
115
|
+
* of it is a React concern. A cookie-backed storage fits Next, Remix, SvelteKit,
|
|
116
|
+
* Nitro or a plain Node handler equally, and `@viu/emporix-sdk-next` needed
|
|
117
|
+
* exactly this and nothing else from `@viu/emporix-sdk-react`.
|
|
118
|
+
*
|
|
119
|
+
* `@viu/emporix-sdk-react` re-exports all of it and keeps the browser backends
|
|
120
|
+
* (memory, localStorage, sessionStorage, document.cookie), which genuinely belong
|
|
121
|
+
* there.
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The subset of an anonymous session a browser storage keeps.
|
|
126
|
+
*
|
|
127
|
+
* Derived from {@link StoredAnonymousSession} rather than re-declared: a server
|
|
128
|
+
* store may additionally persist the access token and its expiry, a browser one
|
|
129
|
+
* deliberately does not (the client is long-lived and holds the token in memory,
|
|
130
|
+
* so writing it would only expose a bearer token to JavaScript).
|
|
131
|
+
*/
|
|
132
|
+
type PersistedAnonymousSession = Pick<StoredAnonymousSession, "refreshToken" | "sessionId">;
|
|
133
|
+
/** Pluggable persistence for SDK session state. SSR-safe by default (memory). */
|
|
134
|
+
interface EmporixStorage {
|
|
135
|
+
getCustomerToken(): string | null;
|
|
136
|
+
setCustomerToken(token: string | null): void;
|
|
137
|
+
subscribe?(listener: (token: string | null) => void): () => void;
|
|
138
|
+
getCartId(): string | null;
|
|
139
|
+
setCartId(id: string | null): void;
|
|
140
|
+
getAnonymousSession(): PersistedAnonymousSession | null;
|
|
141
|
+
setAnonymousSession(session: PersistedAnonymousSession | null): void;
|
|
142
|
+
getSiteCode(): string | null;
|
|
143
|
+
setSiteCode(code: string | null): void;
|
|
144
|
+
getLanguage(): string | null;
|
|
145
|
+
setLanguage(language: string | null): void;
|
|
146
|
+
getActiveLegalEntityId(): string | null;
|
|
147
|
+
setActiveLegalEntityId(id: string | null): void;
|
|
148
|
+
getRefreshToken(): string | null;
|
|
149
|
+
setRefreshToken(token: string | null): void;
|
|
150
|
+
getSaasToken?(): string | null;
|
|
151
|
+
setSaasToken?(token: string | null): void;
|
|
152
|
+
/**
|
|
153
|
+
* Subscribe to any storage write. The listener receives the key that
|
|
154
|
+
* changed. Returns an unsubscribe function. Optional — backends may no-op.
|
|
155
|
+
* Used by the telemetry layer to emit `storage.write` events.
|
|
156
|
+
*/
|
|
157
|
+
subscribeAll?(listener: (key: EmporixStorageKey) => void): () => void;
|
|
158
|
+
}
|
|
159
|
+
/** Backward-compat alias. New code should prefer {@link EmporixStorage}. */
|
|
160
|
+
type TokenStorage = EmporixStorage;
|
|
161
|
+
/**
|
|
162
|
+
* Parses a stored anonymous session (from Web Storage or a cookie) into a
|
|
163
|
+
* {@link PersistedAnonymousSession}. Returns `null` for absent, malformed or
|
|
164
|
+
* incomplete values — a half-written session must not become a half-valid one.
|
|
165
|
+
*/
|
|
166
|
+
declare function parseAnonymousSession(raw: string | null): PersistedAnonymousSession | null;
|
|
167
|
+
/** Backend-agnostic cookie accessor. `set` absent means the storage is read-only. */
|
|
168
|
+
interface CookieIo {
|
|
169
|
+
get(name: string): string | null;
|
|
170
|
+
/** `null` deletes the cookie. */
|
|
171
|
+
set?(name: string, value: string | null): void;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Builds an {@link EmporixStorage} over a cookie accessor. Contains the whole
|
|
175
|
+
* name-to-accessor mapping so no backend repeats it.
|
|
176
|
+
*
|
|
177
|
+
* `opts.notify` is a callback rather than a flag so this module stays free of
|
|
178
|
+
* listener-set lifetime: the browser backend owns a `createListenerSet`, passes
|
|
179
|
+
* its `notify` here, and attaches `subscribeAll` to the result itself. This
|
|
180
|
+
* function never sets `subscribeAll` — the server backend therefore has none,
|
|
181
|
+
* which is correct: a server render has no lifetime to observe.
|
|
182
|
+
*/
|
|
183
|
+
declare function createCookieBackedStorage(io: CookieIo, opts?: {
|
|
184
|
+
tokenName?: string;
|
|
185
|
+
notify?: (key: EmporixStorageKey) => void;
|
|
186
|
+
}): EmporixStorage;
|
|
187
|
+
/**
|
|
188
|
+
* A synchronous cookie accessor supplied by the caller. Deliberately
|
|
189
|
+
* synchronous: {@link EmporixStorage} is synchronous throughout, so any
|
|
190
|
+
* `await` (e.g. Next's `await cookies()`) belongs to the caller.
|
|
191
|
+
*
|
|
192
|
+
* Omit `set` for a read-only storage. Next.js forbids cookie writes during a
|
|
193
|
+
* Server Component render — only Server Actions and Route Handlers may write.
|
|
194
|
+
*/
|
|
195
|
+
interface ServerCookieJar {
|
|
196
|
+
get(name: string): string | null;
|
|
197
|
+
/** `null` deletes the cookie. */
|
|
198
|
+
set?(name: string, value: string | null): void;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* An {@link EmporixStorage} reading (and optionally writing) through a
|
|
202
|
+
* caller-supplied cookie jar — for RSC, Server Actions, Route Handlers, or any
|
|
203
|
+
* other server runtime. No framework import: the jar shape fits Next, Remix,
|
|
204
|
+
* SvelteKit, Nitro or a plain Node handler.
|
|
205
|
+
*
|
|
206
|
+
* `subscribe` / `subscribeAll` are absent: a server render has no lifetime over
|
|
207
|
+
* which to observe changes.
|
|
208
|
+
*
|
|
209
|
+
* ```ts
|
|
210
|
+
* // Next.js Server Component (read-only)
|
|
211
|
+
* const jar = await cookies();
|
|
212
|
+
* const storage = createServerStorage({ get: (n) => jar.get(n)?.value ?? null });
|
|
213
|
+
*
|
|
214
|
+
* // Next.js Server Action (read-write)
|
|
215
|
+
* const jar = await cookies();
|
|
216
|
+
* const storage = createServerStorage({
|
|
217
|
+
* get: (n) => jar.get(n)?.value ?? null,
|
|
218
|
+
* set: (n, v) =>
|
|
219
|
+
* v === null
|
|
220
|
+
* ? jar.delete(n)
|
|
221
|
+
* : jar.set(n, v, { httpOnly: true, sameSite: "lax", secure: true, path: "/" }),
|
|
222
|
+
* });
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
declare function createServerStorage(jar: ServerCookieJar): EmporixStorage;
|
|
226
|
+
/**
|
|
227
|
+
* Resolves the {@link AuthContext} a server-side read should use, mirroring
|
|
228
|
+
* exactly what the React `useEmporixQuery` resolves on the client: the customer
|
|
229
|
+
* context when a token is stored, anonymous otherwise.
|
|
230
|
+
*
|
|
231
|
+
* Use this rather than hand-rolling it — `authKind` is part of every React-Query
|
|
232
|
+
* key, so a mismatch here produces a silent cache miss (a second fetch after
|
|
233
|
+
* hydration, no error).
|
|
234
|
+
*/
|
|
235
|
+
declare function serverAuth(storage: EmporixStorage): AuthContext;
|
|
236
|
+
|
|
73
237
|
/**
|
|
74
238
|
* Site address.
|
|
75
239
|
*/
|
|
@@ -1716,6 +1880,17 @@ type SchemaAttribute$1 = {
|
|
|
1716
1880
|
[key: string]: unknown;
|
|
1717
1881
|
};
|
|
1718
1882
|
type: SchemaAttributeType;
|
|
1883
|
+
/**
|
|
1884
|
+
* Decimal precision for attributes of `DECIMAL` type. Defines the allowed decimal step for attribute values
|
|
1885
|
+
* (for example `0.1`, `0.01`, `0.001`).
|
|
1886
|
+
* Allowed values:
|
|
1887
|
+
* * `-1` – no precision constraint
|
|
1888
|
+
* * a positive decimal step of the form `0.1`, `0.01`, `0.001`, and so on (`10^-n` where `n >= 1`)
|
|
1889
|
+
* This property can only be provided when `type` is `DECIMAL` (or, for arrays, when `arrayType.type` is `DECIMAL`).
|
|
1890
|
+
* If omitted for a `DECIMAL` attribute, the default precision `0.01` is applied.
|
|
1891
|
+
*
|
|
1892
|
+
*/
|
|
1893
|
+
precision?: number;
|
|
1719
1894
|
metadata: SchemaAttributeMetadata;
|
|
1720
1895
|
/**
|
|
1721
1896
|
* List of available values for the attribute. Only valid for `ENUM` and `REFERENCE` type.
|
|
@@ -10751,4 +10926,4 @@ declare function createEmporixClient<S extends Record<string, ServiceClass<unkno
|
|
|
10751
10926
|
*/
|
|
10752
10927
|
declare function productIdFromYrn(yrn: string | undefined): string;
|
|
10753
10928
|
|
|
10754
|
-
export { type AddedPoints, type AdminCustomer, type AdminCustomerAddress, type AdminCustomerAddressInput, type AdminCustomerAddressList, type AdminCustomerAddressUpdate, type AdminCustomerCreated, type AdminCustomerInput, type AdminCustomerList, type AdminCustomerPatch, type AdminCustomerSearchQuery, type AdminCustomerUpdate, type Agent, type AgentAnalytics, type AgentExecutions, type AgentFromTemplate, type AgentInput, type AgentPatchOp, type AgentRequestLog, type AgentSearchQuery, type AgentSessionLog, type AgentTemplate, type AgenticPatchOp, type AgentsExport, type AgentsExportRequest, type AgentsImport, type AgentsImportRequest, AiService, type AnalyticsQuery, type Approval, type ApprovalCreated, type ApprovalInput, type ApprovalList, type ApprovalPatch, type ApprovalPermittedInput, type ApprovalPermittedResult, ApprovalService, type ApprovalUsersQuery, type ApprovalUsersResult, type Assignee, type Attachment, type AttachmentOptions, AuthContext, AvailabilityService, type BatchNextIdEntry, type Brand, type BrandInput, type BrandList, BrandService, type BrandUpdate, type BulkInstanceResult, type BulkPatchInstanceItem, CartService, type Catalog, type CatalogCreated, type CatalogInput, type CatalogList, type CatalogPatch, CatalogService, type CatalogUpdate, CategoryService, type CgRelation, type CgRelationList, type ChatRequest, type ChatResponse, type ChatStreamOptions, CheckoutService, ClientConfigService, type ClientConfiguration, ClientContext, CloudFunctionsService, type CommerceEvents, CompaniesService, type CompletionMessage, type CompletionRequest, type CompletionResponse, type Configuration$1 as Configuration, type ConfigurationDraft, ContactsService, type Conversation, type ConversationSearchQuery, type ConversionFactorInput, type ConversionFactorResult, type ConvertUnitInput, type ConvertUnitResult, type Country, type CountryList, CountryService, type CountryUpdate, type Coupon$1 as Coupon, type CouponCreated, type CouponInput, type CouponList, CouponService, type CouponUpdate, type Created, type Currency, type CurrencyCreated, type CurrencyInput, type CurrencyList, CurrencyService, type CurrencyUpdate, type CustomEntity, type CustomEntityDraft, type CustomInstance, type CustomInstanceDraft, CustomerAdminService, CustomerGroupsService, CustomerService, type CustomerSummaryBatch, CustomerTokenRefresher, type DeleteAgentOptions, type DeleteConfigOptions, type DeliveryCreated, type DeliveryCycleInput, type DeliverySlot, type DeliverySlotList, type DeliveryTime$1 as DeliveryTime, type DeliveryTimeInput, type DeliveryTimeList, type DeliveryTimeUpdate, type DeliveryWindow$2 as DeliveryWindow, type DeliveryWindowList, type DeliveryWindowValidation, EmporixAuthError, EmporixClient, EmporixConfig, type EmporixCore, EmporixError, EmporixForbiddenError, EmporixInsufficientScopeError, EmporixNetworkError, EmporixNotFoundError, EmporixServerError, EmporixTimeoutError, EmporixValidationError, type ExchangeRate, type ExchangeRateCreated, type ExchangeRateInput, type ExchangeRateList, type ExchangeRateUpdate, type ExecutionsQuery, type Fee$1 as Fee, type FeeDraft, FeeService, type FindSiteInput, type GetOptions, type IamAccessControl, type IamAccessControlCreated, type IamAccessControlUpsert, type IamGroup, type IamGroupCreate, type IamGroupCreated, AssignmentCreateRequest as IamGroupMemberAssignment, type IamGroupMemberCreated, type IamGroupMemberInput, type IamGroupUpdate, type IamScope, type IamScopeCreated, type IamScopeUpsert, IamService, type IamUser, type IamUserCreate, type IamUserCreated, type IamUserDetail, type IamUserScopes, type IamUserUpdate, type ImportCancelResult, type ImportConfig, type ImportErrorRecord, type ImportPage, type ImportPageOptions, type ImportRecordOutcome, type ImportRun, type ImportRunDetail, type ImportRunEvent, type ImportRunInput, type ImportRunMode, type ImportRunStatus, type ImportRunStream, type ImportSchedule, ImportService, type ImportStream, type ImportedRecord, type IndexConfig, type IndexConfigCreated, type IndexPublicConfig, IndexingService, type InstanceSearchBody, type InvoiceJob, type InvoiceJobCreated, type InvoiceJobDraft, InvoiceService, type InvokeCloudFunctionOptions, type ItemFee, type ItemFeeDraft, type ItemFeeSearch, type ItemFeeSearchByProductId, type ItemFeeSearchByProductIds, type Job, type JobIdResponse, type Label, type LabelInput, type LabelList, LabelService, type LabelUpdate, type ListConfigOptions, type ListCustomEntitiesOptions, type ListFeesQuery, type ListInstancesQuery, type ListQuery, type ListQuoteReasonsQuery, type ListQuotesQuery, type ListReindexJobsOptions, type ListSchemaReferencesQuery, type ListSchemasQuery, LocationsService, LogLevel, type McpServer, type McpServerInput, MediaService, type MetadataFilter, type MinimumFee, type MutateOptions, type NewPointsEntry, type NextIdCommandRequest, type NextIdOptions, type NextIdResponse, type NextIdsBatchRequest, type NextIdsBatchResponse, type OAuthConfig, type OAuthInput, type OrderCycleList, type OrderEntryEventCreate, type OrderStatusChange, OrdersService, type PackagingProductsChange, type PackingEvent, type PackingEventList, PaginatedItems, PaymentGatewayService, type PickOrder, type PickOrderList, type PickPackAck, PickPackService, type PointsSummary, PriceService, ProductService, type ProviderModels, QueryFor, type Quote, type QuoteCreated, type QuoteDraft, type QuoteHistory, type QuoteInput, type QuoteReason, type QuoteReasonCreated, type QuoteReasonDraft, type QuoteReasonUpdate, type QuoteResult, QuoteService, type QuoteSlotInput, type QuoteUpdate, RagIndexerService, type RagType, type RecalculationJob, type RecalculationJobCreated, type RecalculationJobInput, type RedeemCouponResult, type RedeemMyPointsInput, type RedeemOption, type RedeemOptionList, type RedeemedPoints, type Redemption, type RedemptionCreated, type RedemptionInput, type ReferralCoupon, type Region, type RegionList, type ReindexEntityType, type ReindexInput, type ReindexJob, type ReindexJobInput, type ReindexJobStatus, ResolvedConfig, type ResourceCreated, type Return, type ReturnCreated, type ReturnInput, type ReturnList, type ReturnPatch, type ReturnUpdate, ReturnsService, RewardPointsService, SalesOrdersService, type Schema, type SchemaAttribute, type SchemaDraft, type SchemaExport, type SchemaImportInput, type SchemaInstanceBulkCreateItem, type SchemaInstanceBulkUpsertItem, type SchemaReference, type SchemaReferenceCreated, type SchemaReferenceInput, type SchemaReferenceUpdateInput, SchemaService, type SchemaTypeName, type SchemaUpdate, type SearchImportedRecordsOptions, type SearchQuery, type SearchStreamRecordsOptions, SegmentService, SepaExportService, type SepaJob, type SepaJobCreated, type SepaJobInput, type SequenceSchema, type SequenceSchemaCreate, SequentialIdService, type ServiceClass, ServiceName, type SessionAttributeInput, type SessionContext, type SessionContextPatch, SessionContextService, type SetItemFeesOptions, type ShippingFee, type ShippingGroup, type ShippingGroupList, type ShippingMethod, type ShippingMethodList, type ShippingPatch, ShippingService, type ShoppingList, type ShoppingListDraft, type ShoppingListItem, ShoppingListService, type Site$1 as Site, type SiteCreated, type SiteInput, type SiteList, type SiteMixin, type SiteMixinCreated, type SiteMixins, SiteService, type TaxCalculationInput, type TaxCalculationRequest, type TaxCalculationResult, type TaxClass, type TaxConfig, type TaxConfigCreated, type TaxCreation as TaxConfigInput, type TaxUpdate as TaxConfigUpdate, type TaxLocation, TaxService, TenantConfigService, type TextRequest, type TextResponse, type Token, type TokenInput, TokenProvider, type Tool, type ToolInput, type Unit, type UnitCreated, UnitHandlingService, type UnitInput, type UnitUpdate, type Vendor, type VendorCreated, type VendorInput, type VendorList, type VendorLocation, type VendorLocationInput, type VendorLocationList, type VendorLocationUpdate, type VendorSearchQuery, VendorService, type VendorUpdate, type WebhookConfig, type WebhookConfigCreated, type WebhookConfigDraft, type WebhookConfigPatch, type WebhookDashboardAccess, WebhookService, type WebhookStatistics, type WebhookStatisticsQuery, type WebhookSubscription, type WebhookSubscriptionUpdateItem, type WebhookSubscriptionUpdateResultItem, type Zone, type ZoneList, createCore, createEmporixClient, errorFromResponse, pickFee, productIdFromYrn, resolveZone };
|
|
10929
|
+
export { type AddedPoints, type AdminCustomer, type AdminCustomerAddress, type AdminCustomerAddressInput, type AdminCustomerAddressList, type AdminCustomerAddressUpdate, type AdminCustomerCreated, type AdminCustomerInput, type AdminCustomerList, type AdminCustomerPatch, type AdminCustomerSearchQuery, type AdminCustomerUpdate, type Agent, type AgentAnalytics, type AgentExecutions, type AgentFromTemplate, type AgentInput, type AgentPatchOp, type AgentRequestLog, type AgentSearchQuery, type AgentSessionLog, type AgentTemplate, type AgenticPatchOp, type AgentsExport, type AgentsExportRequest, type AgentsImport, type AgentsImportRequest, AiService, type AnalyticsQuery, type Approval, type ApprovalCreated, type ApprovalInput, type ApprovalList, type ApprovalPatch, type ApprovalPermittedInput, type ApprovalPermittedResult, ApprovalService, type ApprovalUsersQuery, type ApprovalUsersResult, type Assignee, type Attachment, type AttachmentOptions, AuthContext, AvailabilityService, type BatchNextIdEntry, type Brand, type BrandInput, type BrandList, BrandService, type BrandUpdate, type BulkInstanceResult, type BulkPatchInstanceItem, CartService, type Catalog, type CatalogCreated, type CatalogInput, type CatalogList, type CatalogPatch, CatalogService, type CatalogUpdate, CategoryService, type CgRelation, type CgRelationList, type ChatRequest, type ChatResponse, type ChatStreamOptions, CheckoutService, ClientConfigService, type ClientConfiguration, ClientContext, CloudFunctionsService, type CommerceEvents, CompaniesService, type CompletionMessage, type CompletionRequest, type CompletionResponse, type Configuration$1 as Configuration, type ConfigurationDraft, ContactsService, type Conversation, type ConversationSearchQuery, type ConversionFactorInput, type ConversionFactorResult, type ConvertUnitInput, type ConvertUnitResult, type CookieIo, type Country, type CountryList, CountryService, type CountryUpdate, type Coupon$1 as Coupon, type CouponCreated, type CouponInput, type CouponList, CouponService, type CouponUpdate, type Created, type Currency, type CurrencyCreated, type CurrencyInput, type CurrencyList, CurrencyService, type CurrencyUpdate, type CustomEntity, type CustomEntityDraft, type CustomInstance, type CustomInstanceDraft, CustomerAdminService, CustomerGroupsService, CustomerService, type CustomerSummaryBatch, CustomerTokenRefresher, type DeleteAgentOptions, type DeleteConfigOptions, type DeliveryCreated, type DeliveryCycleInput, type DeliverySlot, type DeliverySlotList, type DeliveryTime$1 as DeliveryTime, type DeliveryTimeInput, type DeliveryTimeList, type DeliveryTimeUpdate, type DeliveryWindow$2 as DeliveryWindow, type DeliveryWindowList, type DeliveryWindowValidation, EmporixAuthError, EmporixClient, EmporixConfig, type EmporixCore, EmporixError, EmporixForbiddenError, EmporixInsufficientScopeError, EmporixNetworkError, EmporixNotFoundError, EmporixServerError, type EmporixStorage, type EmporixStorageKey, EmporixTimeoutError, EmporixValidationError, type ExchangeRate, type ExchangeRateCreated, type ExchangeRateInput, type ExchangeRateList, type ExchangeRateUpdate, type ExecutionsQuery, type Fee$1 as Fee, type FeeDraft, FeeService, type FindSiteInput, type GetOptions, type IamAccessControl, type IamAccessControlCreated, type IamAccessControlUpsert, type IamGroup, type IamGroupCreate, type IamGroupCreated, AssignmentCreateRequest as IamGroupMemberAssignment, type IamGroupMemberCreated, type IamGroupMemberInput, type IamGroupUpdate, type IamScope, type IamScopeCreated, type IamScopeUpsert, IamService, type IamUser, type IamUserCreate, type IamUserCreated, type IamUserDetail, type IamUserScopes, type IamUserUpdate, type ImportCancelResult, type ImportConfig, type ImportErrorRecord, type ImportPage, type ImportPageOptions, type ImportRecordOutcome, type ImportRun, type ImportRunDetail, type ImportRunEvent, type ImportRunInput, type ImportRunMode, type ImportRunStatus, type ImportRunStream, type ImportSchedule, ImportService, type ImportStream, type ImportedRecord, type IndexConfig, type IndexConfigCreated, type IndexPublicConfig, IndexingService, type InstanceSearchBody, type InvoiceJob, type InvoiceJobCreated, type InvoiceJobDraft, InvoiceService, type InvokeCloudFunctionOptions, type ItemFee, type ItemFeeDraft, type ItemFeeSearch, type ItemFeeSearchByProductId, type ItemFeeSearchByProductIds, type Job, type JobIdResponse, type Label, type LabelInput, type LabelList, LabelService, type LabelUpdate, type ListConfigOptions, type ListCustomEntitiesOptions, type ListFeesQuery, type ListInstancesQuery, type ListQuery, type ListQuoteReasonsQuery, type ListQuotesQuery, type ListReindexJobsOptions, type ListSchemaReferencesQuery, type ListSchemasQuery, LocationsService, LogLevel, type McpServer, type McpServerInput, MediaService, type MetadataFilter, type MinimumFee, type MutateOptions, type NewPointsEntry, type NextIdCommandRequest, type NextIdOptions, type NextIdResponse, type NextIdsBatchRequest, type NextIdsBatchResponse, type OAuthConfig, type OAuthInput, type OrderCycleList, type OrderEntryEventCreate, type OrderStatusChange, OrdersService, type PackagingProductsChange, type PackingEvent, type PackingEventList, PaginatedItems, PaymentGatewayService, type PersistedAnonymousSession, type PickOrder, type PickOrderList, type PickPackAck, PickPackService, type PointsSummary, PriceService, ProductService, type ProviderModels, QueryFor, type Quote, type QuoteCreated, type QuoteDraft, type QuoteHistory, type QuoteInput, type QuoteReason, type QuoteReasonCreated, type QuoteReasonDraft, type QuoteReasonUpdate, type QuoteResult, QuoteService, type QuoteSlotInput, type QuoteUpdate, RagIndexerService, type RagType, type RecalculationJob, type RecalculationJobCreated, type RecalculationJobInput, type RedeemCouponResult, type RedeemMyPointsInput, type RedeemOption, type RedeemOptionList, type RedeemedPoints, type Redemption, type RedemptionCreated, type RedemptionInput, type ReferralCoupon, type Region, type RegionList, type ReindexEntityType, type ReindexInput, type ReindexJob, type ReindexJobInput, type ReindexJobStatus, ResolvedConfig, type ResourceCreated, type Return, type ReturnCreated, type ReturnInput, type ReturnList, type ReturnPatch, type ReturnUpdate, ReturnsService, RewardPointsService, STORAGE_KEYS, SalesOrdersService, type Schema, type SchemaAttribute, type SchemaDraft, type SchemaExport, type SchemaImportInput, type SchemaInstanceBulkCreateItem, type SchemaInstanceBulkUpsertItem, type SchemaReference, type SchemaReferenceCreated, type SchemaReferenceInput, type SchemaReferenceUpdateInput, SchemaService, type SchemaTypeName, type SchemaUpdate, type SearchImportedRecordsOptions, type SearchQuery, type SearchStreamRecordsOptions, SegmentService, SepaExportService, type SepaJob, type SepaJobCreated, type SepaJobInput, type SequenceSchema, type SequenceSchemaCreate, SequentialIdService, type ServerCookieJar, type ServiceClass, ServiceName, type SessionAttributeInput, type SessionContext, type SessionContextPatch, SessionContextService, type SetItemFeesOptions, type ShippingFee, type ShippingGroup, type ShippingGroupList, type ShippingMethod, type ShippingMethodList, type ShippingPatch, ShippingService, type ShoppingList, type ShoppingListDraft, type ShoppingListItem, ShoppingListService, type Site$1 as Site, type SiteCreated, type SiteInput, type SiteList, type SiteMixin, type SiteMixinCreated, type SiteMixins, SiteService, StoredAnonymousSession, type TaxCalculationInput, type TaxCalculationRequest, type TaxCalculationResult, type TaxClass, type TaxConfig, type TaxConfigCreated, type TaxCreation as TaxConfigInput, type TaxUpdate as TaxConfigUpdate, type TaxLocation, TaxService, TenantConfigService, type TextRequest, type TextResponse, type Token, type TokenInput, TokenProvider, type TokenStorage, type Tool, type ToolInput, type Unit, type UnitCreated, UnitHandlingService, type UnitInput, type UnitUpdate, type Vendor, type VendorCreated, type VendorInput, type VendorList, type VendorLocation, type VendorLocationInput, type VendorLocationList, type VendorLocationUpdate, type VendorSearchQuery, VendorService, type VendorUpdate, type WebhookConfig, type WebhookConfigCreated, type WebhookConfigDraft, type WebhookConfigPatch, type WebhookDashboardAccess, WebhookService, type WebhookStatistics, type WebhookStatisticsQuery, type WebhookSubscription, type WebhookSubscriptionUpdateItem, type WebhookSubscriptionUpdateResultItem, type Zone, type ZoneList, createCookieBackedStorage, createCore, createEmporixClient, createServerStorage, errorFromResponse, parseAnonymousSession, pickFee, productIdFromYrn, resolveZone, serverAuth };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
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,
|
|
1
|
+
import { p as StoredAnonymousSession, b as AuthContext, C as ClientContext, P as PaginatedItems, T as TokenProvider, n as ResolvedConfig, E as EmporixConfig, j as LogLevel, o as ServiceName, e as CustomerTokenRefresher } from './context-CpLIDl0P.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, q as StorefrontCredentials, r as auth, s as createConsoleLogger, t as createNoopLogger, u as iterateAll, v as redact, w as resolveToken, x as validateConfig } from './context-CpLIDl0P.js';
|
|
3
3
|
import { CustomerService } from './customer.js';
|
|
4
4
|
export { Address, AddressCreateInput, AddressUpdateInput, ChangeEmailInput, ConfirmEmailChangeInput, Customer, CustomerSession, CustomerSignupInput, CustomerUpdateInput, PasswordChangeInput, PasswordResetConfirmInput, PasswordResetRequestInput, ResendActivationInput } from './customer.js';
|
|
5
5
|
import { ProductService } from './product.js';
|
|
@@ -21,7 +21,7 @@ export { Segment, SegmentAssignmentBulkResult, SegmentBulkItem, SegmentBulkResul
|
|
|
21
21
|
import { CompaniesService } from './companies.js';
|
|
22
22
|
import { ContactsService } from './contacts.js';
|
|
23
23
|
import { LocationsService } from './locations.js';
|
|
24
|
-
import { m as UserResponse, U as UserCreateRequest, l as UserIdResponse, k as UserExtendedResponse, o as UserUpdateRequest, j as GroupsQueryDocument, n as UserScopesResponse, a as AccessControlQueryDocument, G as GroupCreateRequest, h as GroupIdResponse, i as GroupUpdateRequest, c as AssignmentCreateRequest, d as AssignmentIdResponse, b as AccessControlUpsertRequest, A as AccessControlIdResponse, e as CustomScopeQueryDocument, f as CustomScopeUpsertRequest, C as CustomScopeIdResponse, g as CustomerGroupsService } from './customer-groups-
|
|
24
|
+
import { m as UserResponse, U as UserCreateRequest, l as UserIdResponse, k as UserExtendedResponse, o as UserUpdateRequest, j as GroupsQueryDocument, n as UserScopesResponse, a as AccessControlQueryDocument, G as GroupCreateRequest, h as GroupIdResponse, i as GroupUpdateRequest, c as AssignmentCreateRequest, d as AssignmentIdResponse, b as AccessControlUpsertRequest, A as AccessControlIdResponse, e as CustomScopeQueryDocument, f as CustomScopeUpsertRequest, C as CustomScopeIdResponse, g as CustomerGroupsService } from './customer-groups-DhpCTCTg.js';
|
|
25
25
|
import { OrdersService, SalesOrdersService } from './orders.js';
|
|
26
26
|
export { GetOrderOptions, ListLegalEntityOrdersOptions, ListMyOrdersOptions, ListSalesOrdersOptions, Order, OrderEntry, OrderStatus, OrderTransitionOptions, SalesOrder, SalesOrderCalculationInput, SalesOrderCreateInput, SalesOrderCreated, SalesOrderEntriesInput, SalesOrderHistoricalTransitions, SalesOrderPatch, SalesOrderReplaceInput, SalesOrderSearchInput, SalesOrderSplitInput, SalesOrderSplitResult, Transition, UpdateSalesOrderOptions } from './orders.js';
|
|
27
27
|
import { AvailabilityService } from './availability.js';
|
|
@@ -70,6 +70,170 @@ declare class EmporixInsufficientScopeError extends EmporixForbiddenError {
|
|
|
70
70
|
/** Maps an HTTP status to the matching {@link EmporixError} subclass. */
|
|
71
71
|
declare function errorFromResponse(status: number, message: string, body: unknown): EmporixError;
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* The persisted session-state contract, shared by every host.
|
|
75
|
+
*
|
|
76
|
+
* It lives in the core SDK rather than in `@viu/emporix-sdk-react` because it is
|
|
77
|
+
* not a React concern: the same eight keys are cookie names in a Next
|
|
78
|
+
* `proxy.ts`, Web Storage keys in a browser adapter, and record fields in a
|
|
79
|
+
* server-side session store. Keeping it here is what let
|
|
80
|
+
* `@viu/emporix-sdk-next` drop its dependency on the React package — it needed
|
|
81
|
+
* these strings, not React.
|
|
82
|
+
*
|
|
83
|
+
* `@viu/emporix-sdk-react` re-exports both from `./storage` and `/ssr`, so
|
|
84
|
+
* existing imports keep working.
|
|
85
|
+
*/
|
|
86
|
+
/** Keys that participate in {@link EmporixStorage.subscribeAll}. */
|
|
87
|
+
type EmporixStorageKey = "customerToken" | "cartId" | "siteCode" | "language" | "anonymousSession" | "activeLegalEntityId" | "refreshToken" | "saasToken";
|
|
88
|
+
/**
|
|
89
|
+
* The eight persisted session keys, as the strings each backend actually uses.
|
|
90
|
+
* Same strings on purpose — a value written by one backend must be readable by
|
|
91
|
+
* the next, and the cookie set by a Next `proxy.ts` has to be the one
|
|
92
|
+
* `createCookieStorage` looks for.
|
|
93
|
+
*
|
|
94
|
+
* The `satisfies` is the point, not the deduplication: a ninth
|
|
95
|
+
* {@link EmporixStorageKey} without an entry here is a compile error, and an
|
|
96
|
+
* entry here without a union member is too. `as const` stays in front of it so
|
|
97
|
+
* the literal types survive for consumers.
|
|
98
|
+
*/
|
|
99
|
+
declare const STORAGE_KEYS: {
|
|
100
|
+
readonly customerToken: "emporix.customerToken";
|
|
101
|
+
readonly cartId: "emporix.cartId";
|
|
102
|
+
readonly anonymousSession: "emporix.anonymousSession";
|
|
103
|
+
readonly siteCode: "emporix.siteCode";
|
|
104
|
+
readonly language: "emporix.language";
|
|
105
|
+
readonly activeLegalEntityId: "emporix.activeLegalEntityId";
|
|
106
|
+
readonly refreshToken: "emporix.refreshToken";
|
|
107
|
+
readonly saasToken: "emporix.saasToken";
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The persisted-session layer: the {@link EmporixStorage} contract and the two
|
|
112
|
+
* framework-free implementations of it that are not browser-specific.
|
|
113
|
+
*
|
|
114
|
+
* It lives in the core SDK for the same reason {@link STORAGE_KEYS} does — none
|
|
115
|
+
* of it is a React concern. A cookie-backed storage fits Next, Remix, SvelteKit,
|
|
116
|
+
* Nitro or a plain Node handler equally, and `@viu/emporix-sdk-next` needed
|
|
117
|
+
* exactly this and nothing else from `@viu/emporix-sdk-react`.
|
|
118
|
+
*
|
|
119
|
+
* `@viu/emporix-sdk-react` re-exports all of it and keeps the browser backends
|
|
120
|
+
* (memory, localStorage, sessionStorage, document.cookie), which genuinely belong
|
|
121
|
+
* there.
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The subset of an anonymous session a browser storage keeps.
|
|
126
|
+
*
|
|
127
|
+
* Derived from {@link StoredAnonymousSession} rather than re-declared: a server
|
|
128
|
+
* store may additionally persist the access token and its expiry, a browser one
|
|
129
|
+
* deliberately does not (the client is long-lived and holds the token in memory,
|
|
130
|
+
* so writing it would only expose a bearer token to JavaScript).
|
|
131
|
+
*/
|
|
132
|
+
type PersistedAnonymousSession = Pick<StoredAnonymousSession, "refreshToken" | "sessionId">;
|
|
133
|
+
/** Pluggable persistence for SDK session state. SSR-safe by default (memory). */
|
|
134
|
+
interface EmporixStorage {
|
|
135
|
+
getCustomerToken(): string | null;
|
|
136
|
+
setCustomerToken(token: string | null): void;
|
|
137
|
+
subscribe?(listener: (token: string | null) => void): () => void;
|
|
138
|
+
getCartId(): string | null;
|
|
139
|
+
setCartId(id: string | null): void;
|
|
140
|
+
getAnonymousSession(): PersistedAnonymousSession | null;
|
|
141
|
+
setAnonymousSession(session: PersistedAnonymousSession | null): void;
|
|
142
|
+
getSiteCode(): string | null;
|
|
143
|
+
setSiteCode(code: string | null): void;
|
|
144
|
+
getLanguage(): string | null;
|
|
145
|
+
setLanguage(language: string | null): void;
|
|
146
|
+
getActiveLegalEntityId(): string | null;
|
|
147
|
+
setActiveLegalEntityId(id: string | null): void;
|
|
148
|
+
getRefreshToken(): string | null;
|
|
149
|
+
setRefreshToken(token: string | null): void;
|
|
150
|
+
getSaasToken?(): string | null;
|
|
151
|
+
setSaasToken?(token: string | null): void;
|
|
152
|
+
/**
|
|
153
|
+
* Subscribe to any storage write. The listener receives the key that
|
|
154
|
+
* changed. Returns an unsubscribe function. Optional — backends may no-op.
|
|
155
|
+
* Used by the telemetry layer to emit `storage.write` events.
|
|
156
|
+
*/
|
|
157
|
+
subscribeAll?(listener: (key: EmporixStorageKey) => void): () => void;
|
|
158
|
+
}
|
|
159
|
+
/** Backward-compat alias. New code should prefer {@link EmporixStorage}. */
|
|
160
|
+
type TokenStorage = EmporixStorage;
|
|
161
|
+
/**
|
|
162
|
+
* Parses a stored anonymous session (from Web Storage or a cookie) into a
|
|
163
|
+
* {@link PersistedAnonymousSession}. Returns `null` for absent, malformed or
|
|
164
|
+
* incomplete values — a half-written session must not become a half-valid one.
|
|
165
|
+
*/
|
|
166
|
+
declare function parseAnonymousSession(raw: string | null): PersistedAnonymousSession | null;
|
|
167
|
+
/** Backend-agnostic cookie accessor. `set` absent means the storage is read-only. */
|
|
168
|
+
interface CookieIo {
|
|
169
|
+
get(name: string): string | null;
|
|
170
|
+
/** `null` deletes the cookie. */
|
|
171
|
+
set?(name: string, value: string | null): void;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Builds an {@link EmporixStorage} over a cookie accessor. Contains the whole
|
|
175
|
+
* name-to-accessor mapping so no backend repeats it.
|
|
176
|
+
*
|
|
177
|
+
* `opts.notify` is a callback rather than a flag so this module stays free of
|
|
178
|
+
* listener-set lifetime: the browser backend owns a `createListenerSet`, passes
|
|
179
|
+
* its `notify` here, and attaches `subscribeAll` to the result itself. This
|
|
180
|
+
* function never sets `subscribeAll` — the server backend therefore has none,
|
|
181
|
+
* which is correct: a server render has no lifetime to observe.
|
|
182
|
+
*/
|
|
183
|
+
declare function createCookieBackedStorage(io: CookieIo, opts?: {
|
|
184
|
+
tokenName?: string;
|
|
185
|
+
notify?: (key: EmporixStorageKey) => void;
|
|
186
|
+
}): EmporixStorage;
|
|
187
|
+
/**
|
|
188
|
+
* A synchronous cookie accessor supplied by the caller. Deliberately
|
|
189
|
+
* synchronous: {@link EmporixStorage} is synchronous throughout, so any
|
|
190
|
+
* `await` (e.g. Next's `await cookies()`) belongs to the caller.
|
|
191
|
+
*
|
|
192
|
+
* Omit `set` for a read-only storage. Next.js forbids cookie writes during a
|
|
193
|
+
* Server Component render — only Server Actions and Route Handlers may write.
|
|
194
|
+
*/
|
|
195
|
+
interface ServerCookieJar {
|
|
196
|
+
get(name: string): string | null;
|
|
197
|
+
/** `null` deletes the cookie. */
|
|
198
|
+
set?(name: string, value: string | null): void;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* An {@link EmporixStorage} reading (and optionally writing) through a
|
|
202
|
+
* caller-supplied cookie jar — for RSC, Server Actions, Route Handlers, or any
|
|
203
|
+
* other server runtime. No framework import: the jar shape fits Next, Remix,
|
|
204
|
+
* SvelteKit, Nitro or a plain Node handler.
|
|
205
|
+
*
|
|
206
|
+
* `subscribe` / `subscribeAll` are absent: a server render has no lifetime over
|
|
207
|
+
* which to observe changes.
|
|
208
|
+
*
|
|
209
|
+
* ```ts
|
|
210
|
+
* // Next.js Server Component (read-only)
|
|
211
|
+
* const jar = await cookies();
|
|
212
|
+
* const storage = createServerStorage({ get: (n) => jar.get(n)?.value ?? null });
|
|
213
|
+
*
|
|
214
|
+
* // Next.js Server Action (read-write)
|
|
215
|
+
* const jar = await cookies();
|
|
216
|
+
* const storage = createServerStorage({
|
|
217
|
+
* get: (n) => jar.get(n)?.value ?? null,
|
|
218
|
+
* set: (n, v) =>
|
|
219
|
+
* v === null
|
|
220
|
+
* ? jar.delete(n)
|
|
221
|
+
* : jar.set(n, v, { httpOnly: true, sameSite: "lax", secure: true, path: "/" }),
|
|
222
|
+
* });
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
declare function createServerStorage(jar: ServerCookieJar): EmporixStorage;
|
|
226
|
+
/**
|
|
227
|
+
* Resolves the {@link AuthContext} a server-side read should use, mirroring
|
|
228
|
+
* exactly what the React `useEmporixQuery` resolves on the client: the customer
|
|
229
|
+
* context when a token is stored, anonymous otherwise.
|
|
230
|
+
*
|
|
231
|
+
* Use this rather than hand-rolling it — `authKind` is part of every React-Query
|
|
232
|
+
* key, so a mismatch here produces a silent cache miss (a second fetch after
|
|
233
|
+
* hydration, no error).
|
|
234
|
+
*/
|
|
235
|
+
declare function serverAuth(storage: EmporixStorage): AuthContext;
|
|
236
|
+
|
|
73
237
|
/**
|
|
74
238
|
* Site address.
|
|
75
239
|
*/
|
|
@@ -1716,6 +1880,17 @@ type SchemaAttribute$1 = {
|
|
|
1716
1880
|
[key: string]: unknown;
|
|
1717
1881
|
};
|
|
1718
1882
|
type: SchemaAttributeType;
|
|
1883
|
+
/**
|
|
1884
|
+
* Decimal precision for attributes of `DECIMAL` type. Defines the allowed decimal step for attribute values
|
|
1885
|
+
* (for example `0.1`, `0.01`, `0.001`).
|
|
1886
|
+
* Allowed values:
|
|
1887
|
+
* * `-1` – no precision constraint
|
|
1888
|
+
* * a positive decimal step of the form `0.1`, `0.01`, `0.001`, and so on (`10^-n` where `n >= 1`)
|
|
1889
|
+
* This property can only be provided when `type` is `DECIMAL` (or, for arrays, when `arrayType.type` is `DECIMAL`).
|
|
1890
|
+
* If omitted for a `DECIMAL` attribute, the default precision `0.01` is applied.
|
|
1891
|
+
*
|
|
1892
|
+
*/
|
|
1893
|
+
precision?: number;
|
|
1719
1894
|
metadata: SchemaAttributeMetadata;
|
|
1720
1895
|
/**
|
|
1721
1896
|
* List of available values for the attribute. Only valid for `ENUM` and `REFERENCE` type.
|
|
@@ -10751,4 +10926,4 @@ declare function createEmporixClient<S extends Record<string, ServiceClass<unkno
|
|
|
10751
10926
|
*/
|
|
10752
10927
|
declare function productIdFromYrn(yrn: string | undefined): string;
|
|
10753
10928
|
|
|
10754
|
-
export { type AddedPoints, type AdminCustomer, type AdminCustomerAddress, type AdminCustomerAddressInput, type AdminCustomerAddressList, type AdminCustomerAddressUpdate, type AdminCustomerCreated, type AdminCustomerInput, type AdminCustomerList, type AdminCustomerPatch, type AdminCustomerSearchQuery, type AdminCustomerUpdate, type Agent, type AgentAnalytics, type AgentExecutions, type AgentFromTemplate, type AgentInput, type AgentPatchOp, type AgentRequestLog, type AgentSearchQuery, type AgentSessionLog, type AgentTemplate, type AgenticPatchOp, type AgentsExport, type AgentsExportRequest, type AgentsImport, type AgentsImportRequest, AiService, type AnalyticsQuery, type Approval, type ApprovalCreated, type ApprovalInput, type ApprovalList, type ApprovalPatch, type ApprovalPermittedInput, type ApprovalPermittedResult, ApprovalService, type ApprovalUsersQuery, type ApprovalUsersResult, type Assignee, type Attachment, type AttachmentOptions, AuthContext, AvailabilityService, type BatchNextIdEntry, type Brand, type BrandInput, type BrandList, BrandService, type BrandUpdate, type BulkInstanceResult, type BulkPatchInstanceItem, CartService, type Catalog, type CatalogCreated, type CatalogInput, type CatalogList, type CatalogPatch, CatalogService, type CatalogUpdate, CategoryService, type CgRelation, type CgRelationList, type ChatRequest, type ChatResponse, type ChatStreamOptions, CheckoutService, ClientConfigService, type ClientConfiguration, ClientContext, CloudFunctionsService, type CommerceEvents, CompaniesService, type CompletionMessage, type CompletionRequest, type CompletionResponse, type Configuration$1 as Configuration, type ConfigurationDraft, ContactsService, type Conversation, type ConversationSearchQuery, type ConversionFactorInput, type ConversionFactorResult, type ConvertUnitInput, type ConvertUnitResult, type Country, type CountryList, CountryService, type CountryUpdate, type Coupon$1 as Coupon, type CouponCreated, type CouponInput, type CouponList, CouponService, type CouponUpdate, type Created, type Currency, type CurrencyCreated, type CurrencyInput, type CurrencyList, CurrencyService, type CurrencyUpdate, type CustomEntity, type CustomEntityDraft, type CustomInstance, type CustomInstanceDraft, CustomerAdminService, CustomerGroupsService, CustomerService, type CustomerSummaryBatch, CustomerTokenRefresher, type DeleteAgentOptions, type DeleteConfigOptions, type DeliveryCreated, type DeliveryCycleInput, type DeliverySlot, type DeliverySlotList, type DeliveryTime$1 as DeliveryTime, type DeliveryTimeInput, type DeliveryTimeList, type DeliveryTimeUpdate, type DeliveryWindow$2 as DeliveryWindow, type DeliveryWindowList, type DeliveryWindowValidation, EmporixAuthError, EmporixClient, EmporixConfig, type EmporixCore, EmporixError, EmporixForbiddenError, EmporixInsufficientScopeError, EmporixNetworkError, EmporixNotFoundError, EmporixServerError, EmporixTimeoutError, EmporixValidationError, type ExchangeRate, type ExchangeRateCreated, type ExchangeRateInput, type ExchangeRateList, type ExchangeRateUpdate, type ExecutionsQuery, type Fee$1 as Fee, type FeeDraft, FeeService, type FindSiteInput, type GetOptions, type IamAccessControl, type IamAccessControlCreated, type IamAccessControlUpsert, type IamGroup, type IamGroupCreate, type IamGroupCreated, AssignmentCreateRequest as IamGroupMemberAssignment, type IamGroupMemberCreated, type IamGroupMemberInput, type IamGroupUpdate, type IamScope, type IamScopeCreated, type IamScopeUpsert, IamService, type IamUser, type IamUserCreate, type IamUserCreated, type IamUserDetail, type IamUserScopes, type IamUserUpdate, type ImportCancelResult, type ImportConfig, type ImportErrorRecord, type ImportPage, type ImportPageOptions, type ImportRecordOutcome, type ImportRun, type ImportRunDetail, type ImportRunEvent, type ImportRunInput, type ImportRunMode, type ImportRunStatus, type ImportRunStream, type ImportSchedule, ImportService, type ImportStream, type ImportedRecord, type IndexConfig, type IndexConfigCreated, type IndexPublicConfig, IndexingService, type InstanceSearchBody, type InvoiceJob, type InvoiceJobCreated, type InvoiceJobDraft, InvoiceService, type InvokeCloudFunctionOptions, type ItemFee, type ItemFeeDraft, type ItemFeeSearch, type ItemFeeSearchByProductId, type ItemFeeSearchByProductIds, type Job, type JobIdResponse, type Label, type LabelInput, type LabelList, LabelService, type LabelUpdate, type ListConfigOptions, type ListCustomEntitiesOptions, type ListFeesQuery, type ListInstancesQuery, type ListQuery, type ListQuoteReasonsQuery, type ListQuotesQuery, type ListReindexJobsOptions, type ListSchemaReferencesQuery, type ListSchemasQuery, LocationsService, LogLevel, type McpServer, type McpServerInput, MediaService, type MetadataFilter, type MinimumFee, type MutateOptions, type NewPointsEntry, type NextIdCommandRequest, type NextIdOptions, type NextIdResponse, type NextIdsBatchRequest, type NextIdsBatchResponse, type OAuthConfig, type OAuthInput, type OrderCycleList, type OrderEntryEventCreate, type OrderStatusChange, OrdersService, type PackagingProductsChange, type PackingEvent, type PackingEventList, PaginatedItems, PaymentGatewayService, type PickOrder, type PickOrderList, type PickPackAck, PickPackService, type PointsSummary, PriceService, ProductService, type ProviderModels, QueryFor, type Quote, type QuoteCreated, type QuoteDraft, type QuoteHistory, type QuoteInput, type QuoteReason, type QuoteReasonCreated, type QuoteReasonDraft, type QuoteReasonUpdate, type QuoteResult, QuoteService, type QuoteSlotInput, type QuoteUpdate, RagIndexerService, type RagType, type RecalculationJob, type RecalculationJobCreated, type RecalculationJobInput, type RedeemCouponResult, type RedeemMyPointsInput, type RedeemOption, type RedeemOptionList, type RedeemedPoints, type Redemption, type RedemptionCreated, type RedemptionInput, type ReferralCoupon, type Region, type RegionList, type ReindexEntityType, type ReindexInput, type ReindexJob, type ReindexJobInput, type ReindexJobStatus, ResolvedConfig, type ResourceCreated, type Return, type ReturnCreated, type ReturnInput, type ReturnList, type ReturnPatch, type ReturnUpdate, ReturnsService, RewardPointsService, SalesOrdersService, type Schema, type SchemaAttribute, type SchemaDraft, type SchemaExport, type SchemaImportInput, type SchemaInstanceBulkCreateItem, type SchemaInstanceBulkUpsertItem, type SchemaReference, type SchemaReferenceCreated, type SchemaReferenceInput, type SchemaReferenceUpdateInput, SchemaService, type SchemaTypeName, type SchemaUpdate, type SearchImportedRecordsOptions, type SearchQuery, type SearchStreamRecordsOptions, SegmentService, SepaExportService, type SepaJob, type SepaJobCreated, type SepaJobInput, type SequenceSchema, type SequenceSchemaCreate, SequentialIdService, type ServiceClass, ServiceName, type SessionAttributeInput, type SessionContext, type SessionContextPatch, SessionContextService, type SetItemFeesOptions, type ShippingFee, type ShippingGroup, type ShippingGroupList, type ShippingMethod, type ShippingMethodList, type ShippingPatch, ShippingService, type ShoppingList, type ShoppingListDraft, type ShoppingListItem, ShoppingListService, type Site$1 as Site, type SiteCreated, type SiteInput, type SiteList, type SiteMixin, type SiteMixinCreated, type SiteMixins, SiteService, type TaxCalculationInput, type TaxCalculationRequest, type TaxCalculationResult, type TaxClass, type TaxConfig, type TaxConfigCreated, type TaxCreation as TaxConfigInput, type TaxUpdate as TaxConfigUpdate, type TaxLocation, TaxService, TenantConfigService, type TextRequest, type TextResponse, type Token, type TokenInput, TokenProvider, type Tool, type ToolInput, type Unit, type UnitCreated, UnitHandlingService, type UnitInput, type UnitUpdate, type Vendor, type VendorCreated, type VendorInput, type VendorList, type VendorLocation, type VendorLocationInput, type VendorLocationList, type VendorLocationUpdate, type VendorSearchQuery, VendorService, type VendorUpdate, type WebhookConfig, type WebhookConfigCreated, type WebhookConfigDraft, type WebhookConfigPatch, type WebhookDashboardAccess, WebhookService, type WebhookStatistics, type WebhookStatisticsQuery, type WebhookSubscription, type WebhookSubscriptionUpdateItem, type WebhookSubscriptionUpdateResultItem, type Zone, type ZoneList, createCore, createEmporixClient, errorFromResponse, pickFee, productIdFromYrn, resolveZone };
|
|
10929
|
+
export { type AddedPoints, type AdminCustomer, type AdminCustomerAddress, type AdminCustomerAddressInput, type AdminCustomerAddressList, type AdminCustomerAddressUpdate, type AdminCustomerCreated, type AdminCustomerInput, type AdminCustomerList, type AdminCustomerPatch, type AdminCustomerSearchQuery, type AdminCustomerUpdate, type Agent, type AgentAnalytics, type AgentExecutions, type AgentFromTemplate, type AgentInput, type AgentPatchOp, type AgentRequestLog, type AgentSearchQuery, type AgentSessionLog, type AgentTemplate, type AgenticPatchOp, type AgentsExport, type AgentsExportRequest, type AgentsImport, type AgentsImportRequest, AiService, type AnalyticsQuery, type Approval, type ApprovalCreated, type ApprovalInput, type ApprovalList, type ApprovalPatch, type ApprovalPermittedInput, type ApprovalPermittedResult, ApprovalService, type ApprovalUsersQuery, type ApprovalUsersResult, type Assignee, type Attachment, type AttachmentOptions, AuthContext, AvailabilityService, type BatchNextIdEntry, type Brand, type BrandInput, type BrandList, BrandService, type BrandUpdate, type BulkInstanceResult, type BulkPatchInstanceItem, CartService, type Catalog, type CatalogCreated, type CatalogInput, type CatalogList, type CatalogPatch, CatalogService, type CatalogUpdate, CategoryService, type CgRelation, type CgRelationList, type ChatRequest, type ChatResponse, type ChatStreamOptions, CheckoutService, ClientConfigService, type ClientConfiguration, ClientContext, CloudFunctionsService, type CommerceEvents, CompaniesService, type CompletionMessage, type CompletionRequest, type CompletionResponse, type Configuration$1 as Configuration, type ConfigurationDraft, ContactsService, type Conversation, type ConversationSearchQuery, type ConversionFactorInput, type ConversionFactorResult, type ConvertUnitInput, type ConvertUnitResult, type CookieIo, type Country, type CountryList, CountryService, type CountryUpdate, type Coupon$1 as Coupon, type CouponCreated, type CouponInput, type CouponList, CouponService, type CouponUpdate, type Created, type Currency, type CurrencyCreated, type CurrencyInput, type CurrencyList, CurrencyService, type CurrencyUpdate, type CustomEntity, type CustomEntityDraft, type CustomInstance, type CustomInstanceDraft, CustomerAdminService, CustomerGroupsService, CustomerService, type CustomerSummaryBatch, CustomerTokenRefresher, type DeleteAgentOptions, type DeleteConfigOptions, type DeliveryCreated, type DeliveryCycleInput, type DeliverySlot, type DeliverySlotList, type DeliveryTime$1 as DeliveryTime, type DeliveryTimeInput, type DeliveryTimeList, type DeliveryTimeUpdate, type DeliveryWindow$2 as DeliveryWindow, type DeliveryWindowList, type DeliveryWindowValidation, EmporixAuthError, EmporixClient, EmporixConfig, type EmporixCore, EmporixError, EmporixForbiddenError, EmporixInsufficientScopeError, EmporixNetworkError, EmporixNotFoundError, EmporixServerError, type EmporixStorage, type EmporixStorageKey, EmporixTimeoutError, EmporixValidationError, type ExchangeRate, type ExchangeRateCreated, type ExchangeRateInput, type ExchangeRateList, type ExchangeRateUpdate, type ExecutionsQuery, type Fee$1 as Fee, type FeeDraft, FeeService, type FindSiteInput, type GetOptions, type IamAccessControl, type IamAccessControlCreated, type IamAccessControlUpsert, type IamGroup, type IamGroupCreate, type IamGroupCreated, AssignmentCreateRequest as IamGroupMemberAssignment, type IamGroupMemberCreated, type IamGroupMemberInput, type IamGroupUpdate, type IamScope, type IamScopeCreated, type IamScopeUpsert, IamService, type IamUser, type IamUserCreate, type IamUserCreated, type IamUserDetail, type IamUserScopes, type IamUserUpdate, type ImportCancelResult, type ImportConfig, type ImportErrorRecord, type ImportPage, type ImportPageOptions, type ImportRecordOutcome, type ImportRun, type ImportRunDetail, type ImportRunEvent, type ImportRunInput, type ImportRunMode, type ImportRunStatus, type ImportRunStream, type ImportSchedule, ImportService, type ImportStream, type ImportedRecord, type IndexConfig, type IndexConfigCreated, type IndexPublicConfig, IndexingService, type InstanceSearchBody, type InvoiceJob, type InvoiceJobCreated, type InvoiceJobDraft, InvoiceService, type InvokeCloudFunctionOptions, type ItemFee, type ItemFeeDraft, type ItemFeeSearch, type ItemFeeSearchByProductId, type ItemFeeSearchByProductIds, type Job, type JobIdResponse, type Label, type LabelInput, type LabelList, LabelService, type LabelUpdate, type ListConfigOptions, type ListCustomEntitiesOptions, type ListFeesQuery, type ListInstancesQuery, type ListQuery, type ListQuoteReasonsQuery, type ListQuotesQuery, type ListReindexJobsOptions, type ListSchemaReferencesQuery, type ListSchemasQuery, LocationsService, LogLevel, type McpServer, type McpServerInput, MediaService, type MetadataFilter, type MinimumFee, type MutateOptions, type NewPointsEntry, type NextIdCommandRequest, type NextIdOptions, type NextIdResponse, type NextIdsBatchRequest, type NextIdsBatchResponse, type OAuthConfig, type OAuthInput, type OrderCycleList, type OrderEntryEventCreate, type OrderStatusChange, OrdersService, type PackagingProductsChange, type PackingEvent, type PackingEventList, PaginatedItems, PaymentGatewayService, type PersistedAnonymousSession, type PickOrder, type PickOrderList, type PickPackAck, PickPackService, type PointsSummary, PriceService, ProductService, type ProviderModels, QueryFor, type Quote, type QuoteCreated, type QuoteDraft, type QuoteHistory, type QuoteInput, type QuoteReason, type QuoteReasonCreated, type QuoteReasonDraft, type QuoteReasonUpdate, type QuoteResult, QuoteService, type QuoteSlotInput, type QuoteUpdate, RagIndexerService, type RagType, type RecalculationJob, type RecalculationJobCreated, type RecalculationJobInput, type RedeemCouponResult, type RedeemMyPointsInput, type RedeemOption, type RedeemOptionList, type RedeemedPoints, type Redemption, type RedemptionCreated, type RedemptionInput, type ReferralCoupon, type Region, type RegionList, type ReindexEntityType, type ReindexInput, type ReindexJob, type ReindexJobInput, type ReindexJobStatus, ResolvedConfig, type ResourceCreated, type Return, type ReturnCreated, type ReturnInput, type ReturnList, type ReturnPatch, type ReturnUpdate, ReturnsService, RewardPointsService, STORAGE_KEYS, SalesOrdersService, type Schema, type SchemaAttribute, type SchemaDraft, type SchemaExport, type SchemaImportInput, type SchemaInstanceBulkCreateItem, type SchemaInstanceBulkUpsertItem, type SchemaReference, type SchemaReferenceCreated, type SchemaReferenceInput, type SchemaReferenceUpdateInput, SchemaService, type SchemaTypeName, type SchemaUpdate, type SearchImportedRecordsOptions, type SearchQuery, type SearchStreamRecordsOptions, SegmentService, SepaExportService, type SepaJob, type SepaJobCreated, type SepaJobInput, type SequenceSchema, type SequenceSchemaCreate, SequentialIdService, type ServerCookieJar, type ServiceClass, ServiceName, type SessionAttributeInput, type SessionContext, type SessionContextPatch, SessionContextService, type SetItemFeesOptions, type ShippingFee, type ShippingGroup, type ShippingGroupList, type ShippingMethod, type ShippingMethodList, type ShippingPatch, ShippingService, type ShoppingList, type ShoppingListDraft, type ShoppingListItem, ShoppingListService, type Site$1 as Site, type SiteCreated, type SiteInput, type SiteList, type SiteMixin, type SiteMixinCreated, type SiteMixins, SiteService, StoredAnonymousSession, type TaxCalculationInput, type TaxCalculationRequest, type TaxCalculationResult, type TaxClass, type TaxConfig, type TaxConfigCreated, type TaxCreation as TaxConfigInput, type TaxUpdate as TaxConfigUpdate, type TaxLocation, TaxService, TenantConfigService, type TextRequest, type TextResponse, type Token, type TokenInput, TokenProvider, type TokenStorage, type Tool, type ToolInput, type Unit, type UnitCreated, UnitHandlingService, type UnitInput, type UnitUpdate, type Vendor, type VendorCreated, type VendorInput, type VendorList, type VendorLocation, type VendorLocationInput, type VendorLocationList, type VendorLocationUpdate, type VendorSearchQuery, VendorService, type VendorUpdate, type WebhookConfig, type WebhookConfigCreated, type WebhookConfigDraft, type WebhookConfigPatch, type WebhookDashboardAccess, WebhookService, type WebhookStatistics, type WebhookStatisticsQuery, type WebhookSubscription, type WebhookSubscriptionUpdateItem, type WebhookSubscriptionUpdateResultItem, type Zone, type ZoneList, createCookieBackedStorage, createCore, createEmporixClient, createServerStorage, errorFromResponse, parseAnonymousSession, pickFee, productIdFromYrn, resolveZone, serverAuth };
|
package/dist/index.js
CHANGED
|
@@ -4,8 +4,8 @@ import { MediaService } from './chunk-OTG2S2L4.js';
|
|
|
4
4
|
export { MediaService } from './chunk-OTG2S2L4.js';
|
|
5
5
|
import { OrdersService, SalesOrdersService } from './chunk-P7G4LOOV.js';
|
|
6
6
|
export { OrdersService, SalesOrdersService } from './chunk-P7G4LOOV.js';
|
|
7
|
-
import { auth, resolveToken, DefaultTokenProvider, CustomerRefreshRegistry, PaymentGatewayService } from './chunk-
|
|
8
|
-
export { CustomerRefreshRegistry, DefaultTokenProvider, PaymentGatewayService, auth, resolveToken } from './chunk-
|
|
7
|
+
import { auth, resolveToken, DefaultTokenProvider, CustomerRefreshRegistry, PaymentGatewayService } from './chunk-4VRUMCS2.js';
|
|
8
|
+
export { CustomerRefreshRegistry, DefaultTokenProvider, PaymentGatewayService, auth, resolveToken } from './chunk-4VRUMCS2.js';
|
|
9
9
|
import { PriceService } from './chunk-ZOFGDNSX.js';
|
|
10
10
|
export { PriceService } from './chunk-ZOFGDNSX.js';
|
|
11
11
|
import { ProductService } from './chunk-7W22KLUL.js';
|
|
@@ -297,6 +297,78 @@ function createNoopLogger() {
|
|
|
297
297
|
return new NoopLogger();
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
+
// src/core/session-keys.ts
|
|
301
|
+
var STORAGE_KEYS = {
|
|
302
|
+
customerToken: "emporix.customerToken",
|
|
303
|
+
cartId: "emporix.cartId",
|
|
304
|
+
anonymousSession: "emporix.anonymousSession",
|
|
305
|
+
siteCode: "emporix.siteCode",
|
|
306
|
+
language: "emporix.language",
|
|
307
|
+
activeLegalEntityId: "emporix.activeLegalEntityId",
|
|
308
|
+
refreshToken: "emporix.refreshToken",
|
|
309
|
+
saasToken: "emporix.saasToken"
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
// src/core/session-storage.ts
|
|
313
|
+
function parseAnonymousSession(raw) {
|
|
314
|
+
if (raw === null) return null;
|
|
315
|
+
try {
|
|
316
|
+
const parsed = JSON.parse(raw);
|
|
317
|
+
return typeof parsed.refreshToken === "string" && typeof parsed.sessionId === "string" ? { refreshToken: parsed.refreshToken, sessionId: parsed.sessionId } : null;
|
|
318
|
+
} catch {
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
function createCookieBackedStorage(io, opts = {}) {
|
|
323
|
+
const tokenName = opts.tokenName ?? STORAGE_KEYS.customerToken;
|
|
324
|
+
const notify = opts.notify;
|
|
325
|
+
const warned = /* @__PURE__ */ new Set();
|
|
326
|
+
const write = (name, value, key) => {
|
|
327
|
+
if (io.set === void 0) {
|
|
328
|
+
if (!warned.has(key)) {
|
|
329
|
+
warned.add(key);
|
|
330
|
+
console.warn(
|
|
331
|
+
`[emporix] storage is read-only; ignoring write to "${key}". Provide a \`set\` accessor to enable writes (e.g. from a Server Action).`
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
io.set(name, value);
|
|
337
|
+
notify?.(key);
|
|
338
|
+
};
|
|
339
|
+
return {
|
|
340
|
+
getCustomerToken: () => io.get(tokenName),
|
|
341
|
+
setCustomerToken: (t) => write(tokenName, t, "customerToken"),
|
|
342
|
+
getCartId: () => io.get(STORAGE_KEYS.cartId),
|
|
343
|
+
setCartId: (id) => write(STORAGE_KEYS.cartId, id, "cartId"),
|
|
344
|
+
getAnonymousSession: () => parseAnonymousSession(io.get(STORAGE_KEYS.anonymousSession)),
|
|
345
|
+
setAnonymousSession: (s) => write(
|
|
346
|
+
STORAGE_KEYS.anonymousSession,
|
|
347
|
+
s === null ? null : JSON.stringify({ refreshToken: s.refreshToken, sessionId: s.sessionId }),
|
|
348
|
+
"anonymousSession"
|
|
349
|
+
),
|
|
350
|
+
getSiteCode: () => io.get(STORAGE_KEYS.siteCode),
|
|
351
|
+
setSiteCode: (code) => write(STORAGE_KEYS.siteCode, code, "siteCode"),
|
|
352
|
+
getLanguage: () => io.get(STORAGE_KEYS.language),
|
|
353
|
+
setLanguage: (l) => write(STORAGE_KEYS.language, l, "language"),
|
|
354
|
+
getActiveLegalEntityId: () => io.get(STORAGE_KEYS.activeLegalEntityId),
|
|
355
|
+
setActiveLegalEntityId: (id) => write(STORAGE_KEYS.activeLegalEntityId, id, "activeLegalEntityId"),
|
|
356
|
+
getRefreshToken: () => io.get(STORAGE_KEYS.refreshToken),
|
|
357
|
+
setRefreshToken: (t) => write(STORAGE_KEYS.refreshToken, t, "refreshToken"),
|
|
358
|
+
getSaasToken: () => io.get(STORAGE_KEYS.saasToken),
|
|
359
|
+
setSaasToken: (t) => write(STORAGE_KEYS.saasToken, t, "saasToken")
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
function createServerStorage(jar) {
|
|
363
|
+
return createCookieBackedStorage(
|
|
364
|
+
jar.set !== void 0 ? { get: jar.get, set: jar.set } : { get: jar.get }
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
function serverAuth(storage) {
|
|
368
|
+
const token = storage.getCustomerToken();
|
|
369
|
+
return token !== null ? auth.customer(token) : auth.anonymous();
|
|
370
|
+
}
|
|
371
|
+
|
|
300
372
|
// src/core/sse.ts
|
|
301
373
|
function parseFrame(frame) {
|
|
302
374
|
const ev = { data: "" };
|
|
@@ -595,7 +667,7 @@ var HttpClient = class {
|
|
|
595
667
|
};
|
|
596
668
|
|
|
597
669
|
// package.json
|
|
598
|
-
var version = "2.
|
|
670
|
+
var version = "2.31.0";
|
|
599
671
|
|
|
600
672
|
// src/version.ts
|
|
601
673
|
var SDK_VERSION = version;
|
|
@@ -4791,6 +4863,6 @@ function productIdFromYrn(yrn) {
|
|
|
4791
4863
|
return semi >= 0 ? yrn.slice(semi + 1) : "";
|
|
4792
4864
|
}
|
|
4793
4865
|
|
|
4794
|
-
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, SchemaService, SepaExportService, SequentialIdService, SessionContextService, ShippingService, ShoppingListService, SiteService, TaxService, TenantConfigService, UnitHandlingService, VendorService, WebhookService, createConsoleLogger, createCore, createEmporixClient, createNoopLogger, pickFee, productIdFromYrn, redact, resolveZone, validateConfig };
|
|
4866
|
+
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 };
|
|
4795
4867
|
//# sourceMappingURL=index.js.map
|
|
4796
4868
|
//# sourceMappingURL=index.js.map
|