@viu/emporix-sdk 4.2.2 → 4.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +45 -17
- package/dist/cart.d.cts +2 -2
- package/dist/cart.d.ts +2 -2
- package/dist/checkout.d.cts +3 -3
- package/dist/checkout.d.ts +3 -3
- package/dist/companies.d.cts +1 -1
- package/dist/companies.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -9
- package/dist/index.d.ts +16 -9
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/orders.d.cts +1 -1
- package/dist/orders.d.ts +1 -1
- package/dist/segment.d.cts +1 -1
- package/dist/segment.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @viu/emporix-sdk
|
|
2
2
|
|
|
3
|
+
## 4.2.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#381](https://github.com/viuteam/emporix-sdk/pull/381) [`f151f7c`](https://github.com/viuteam/emporix-sdk/commit/f151f7ca11c32d1aa68355a5efbf36286e7b78ac) Thanks [@amnael1](https://github.com/amnael1)! - Export from the package root every type a public method takes or returns. These were reachable only through a subpath or not at all, so a call like `imports.getLicense()` returned an `ImportLicense` that could not be named: `ImportStats`, `ImportStatsQuery`, `ImportJobGroup`, `ImportHealthThresholds`, `ImportLicense`, `LegalEntitySearchInput`, `QuoteReasonsResource`, `CustomerTokenValidation`, `CartItemBatchEntry`, `CartItemsBatchResponse`, `SegmentGroup`, `SegmentGroupInput`, `SessionContextData`, `SiteAddress`, `SiteHomeBase`, and the AI sub-resources `AgenticCrudResource`, `JobsResource`, `TemplatesResource`, `LogsResource` and `AnalyticsResource`. Type-only; no runtime change.
|
|
8
|
+
|
|
9
|
+
## 4.2.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#374](https://github.com/viuteam/emporix-sdk/pull/374) [`3418d90`](https://github.com/viuteam/emporix-sdk/commit/3418d9066fa2f9f1ec83a0499f1fa365cbee21b0) Thanks [@viu-release-bot](https://github.com/apps/viu-release-bot)! - chore(sdk): sync generated types with upstream Emporix API specs
|
|
14
|
+
|
|
15
|
+
Updated services: ai-rag-indexer,ai-service,approval-service,audit-logs-changelog,availability,cart,category,checkout,customer,customer-segment,customer-service,import-service,indexing-service,label-service,order-v2,price,product,sequential-id,session-context,shopping-list
|
|
16
|
+
|
|
3
17
|
## 4.2.2
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -72,12 +72,14 @@ The sections below highlight the most-used services; per-service guides live in
|
|
|
72
72
|
|
|
73
73
|
## Searching by mixin (custom) fields
|
|
74
74
|
|
|
75
|
-
`products.search`, `categories.search`, `
|
|
76
|
-
`
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
`products.search`, `categories.search`, `categories.searchByQuery`,
|
|
76
|
+
`orders.listMine(auth, { q })`, `orders.listForLegalEntity(id, auth, { q })`,
|
|
77
|
+
`salesOrders.list(auth, { q })`, `customerAdmin.searchCustomers({ q })` and
|
|
78
|
+
`vendors.searchVendors({ q })` accept a raw Emporix `q` string **or** a type-safe
|
|
79
|
+
filter built with `mixinQuery` from [`@viu/emporix-mixins`](../mixins). The
|
|
80
|
+
filter is entity-gated (a filter built for one entity is a compile error on
|
|
81
|
+
another) and an `or()` filter is rejected on services that don't support
|
|
82
|
+
`compoundLogicalQuery`.
|
|
81
83
|
|
|
82
84
|
```ts
|
|
83
85
|
import { mixinQuery } from "@viu/emporix-mixins";
|
|
@@ -96,7 +98,7 @@ See [`../../docs/mixin-search.md`](../../docs/mixin-search.md) for the capabilit
|
|
|
96
98
|
| `tenant` (required) | — | lowercase, 3–16 chars, `^[a-z][a-z0-9]{2,15}$` |
|
|
97
99
|
| `credentials` (required) | — | the object itself is required; which sets it holds is up to you |
|
|
98
100
|
| `credentials.backend` | — | `{ clientId, secret, scope? }` — service token |
|
|
99
|
-
| `credentials.storefront` | — | `{ clientId }` — anonymous token (no secret) |
|
|
101
|
+
| `credentials.storefront` | — | `{ clientId, context? }` — anonymous token (no secret). `context` holds `currency` / `siteCode` / `targetLocation`, bound to the anonymous token and needed by `prices.matchByContext`, plus `language` (`Accept-Language`); `sdk.setStorefrontContext()` switches it at runtime |
|
|
100
102
|
| `credentials.custom` | — | `Record<name, { clientId, secret, scope? }>` |
|
|
101
103
|
| `host` | `https://api.emporix.io` | |
|
|
102
104
|
| `timeouts` | `{ connectMs: 10000, readMs: 60000 }` | |
|
|
@@ -104,6 +106,7 @@ See [`../../docs/mixin-search.md`](../../docs/mixin-search.md) for the capabilit
|
|
|
104
106
|
| `cache` | `{ expirationBufferSeconds: 60, maxLifetimeSeconds: 3600 }` | token cache |
|
|
105
107
|
| `logger` | console @ `warn` | `false`, a `Logger`, or `{ level, services, pretty, redact }` |
|
|
106
108
|
| `tokenProvider` | built-in | inject for SSO/token-exchange |
|
|
109
|
+
| `fetch` | global `fetch` | replaces `fetch` for API requests; token requests and SSE streams keep the global one |
|
|
107
110
|
|
|
108
111
|
`credentials: {}` is legal: a client that never mints its own token, for when the
|
|
109
112
|
token comes from outside. The Managed Dashboard module in
|
|
@@ -115,8 +118,10 @@ anonymous browsing, both when you need both.
|
|
|
115
118
|
## AuthContext per method
|
|
116
119
|
|
|
117
120
|
`auth.service(name?)`, `auth.anonymous()`, `auth.customer(token)`,
|
|
118
|
-
`auth.raw(token)`. The
|
|
119
|
-
|
|
121
|
+
`auth.raw(token)`. The `AuthContext` is usually a service method's last
|
|
122
|
+
argument — some take options after it (`orders.listMine(auth, opts)`,
|
|
123
|
+
`availability.get(productId, siteCode, auth, opts)`); defaults below apply when
|
|
124
|
+
omitted.
|
|
120
125
|
|
|
121
126
|
| Method | Default | Required kind |
|
|
122
127
|
| --- | --- | --- |
|
|
@@ -124,7 +129,8 @@ anonymous browsing, both when you need both.
|
|
|
124
129
|
| `customers.me` / `.update` / `.changePassword` / `.addresses.*` | — | `customer` or `raw` |
|
|
125
130
|
| `customers.anonymous()` | — | obtains anonymous session (token ignored) |
|
|
126
131
|
| `products.*` / `categories.*` (reads) | `anonymous` | — (pass `customer` for personalized pricing) |
|
|
127
|
-
| `carts.*` | — | explicit `customer` or `anonymous` |
|
|
132
|
+
| `carts.*` (shopper methods) | — | explicit `customer` or `anonymous` |
|
|
133
|
+
| `carts.search` / `.delete` / `.update` | — | any kind, unguarded — `service` for admin use; the server enforces scope |
|
|
128
134
|
| `carts.merge` | — | `customer` |
|
|
129
135
|
| `carts.execute` ([command chains](../../docs/cart.md)) | — | `customer`, `anonymous`, or `service` with `cart.cart_manage` |
|
|
130
136
|
| `companies.*` / `contacts.*` / `locations.*` / `customerGroups.*` (B2B) | — | `customer` (reads need `*_read_own`; mutations need `*_manage`) |
|
|
@@ -133,7 +139,9 @@ anonymous browsing, both when you need both.
|
|
|
133
139
|
`AuthContext` is **per call, never stored** — one client safely serves many
|
|
134
140
|
concurrent shoppers (SSR/edge/multi-tenant). SDK-managed (`service`/`anonymous`)
|
|
135
141
|
401s refresh-and-retry once; caller-managed (`customer`/`raw`) 401s propagate as
|
|
136
|
-
`EmporixAuthError
|
|
142
|
+
`EmporixAuthError` — unless a refresher is registered with
|
|
143
|
+
`sdk.setCustomerTokenRefresher(...)`, which refreshes and retries a `customer`
|
|
144
|
+
401 once. Full details in [`../../docs/auth.md`](../../docs/auth.md).
|
|
137
145
|
|
|
138
146
|
## Logging
|
|
139
147
|
|
|
@@ -161,11 +169,16 @@ customer's role lacks scope for surface as `EmporixInsufficientScopeError`
|
|
|
161
169
|
## Media
|
|
162
170
|
|
|
163
171
|
`sdk.media` covers the full `/media/{tenant}/assets/*` surface: create
|
|
164
|
-
(`uploadFile` / `link` / `create`
|
|
165
|
-
|
|
166
|
-
`
|
|
167
|
-
|
|
168
|
-
|
|
172
|
+
(`uploadFile` / `link` / `create`, or `startUploadSession` for a direct upload
|
|
173
|
+
to storage once Emporix Support enables it for the tenant), list (paginated,
|
|
174
|
+
`PaginatedItems<Asset>`), get, update (JSON metadata or BLOB multipart
|
|
175
|
+
file-replacement via the `replaceFile` sugar), `patch` (JSON Patch — the way to
|
|
176
|
+
change a BLOB's metadata without re-uploading the file), remove,
|
|
177
|
+
`getDownloadUrl` (a storage URL with no size limit, which Emporix recommends for
|
|
178
|
+
every download), and download (resolves to either a redirect URL for `PUBLIC`
|
|
179
|
+
assets or an `ArrayBuffer` for `PRIVATE`; above the streaming limit, 30 MB by
|
|
180
|
+
default, it fails with a `413` and only `getDownloadUrl` serves the file). All
|
|
181
|
+
endpoints require a server-only scope — every call defaults to a `service`
|
|
169
182
|
`AuthContext`. Storefronts read media via `product.productMedia` (denormalised
|
|
170
183
|
on the product) or the `useProductMedia(productId)` hook, not by calling
|
|
171
184
|
the Media service directly. See [`../../docs/media.md`](../../docs/media.md).
|
|
@@ -186,13 +199,28 @@ stock record. There is no restock-date field.
|
|
|
186
199
|
## Subpath exports
|
|
187
200
|
|
|
188
201
|
`@viu/emporix-sdk` (the package root) re-exports **everything** — every service,
|
|
189
|
-
type, and helper.
|
|
202
|
+
type, and helper. Subpaths are published for the high-traffic
|
|
190
203
|
services: `./customer`, `./product`, `./category`, `./cart`, `./checkout`,
|
|
191
204
|
`./payment`, `./price`, `./media`, `./segment`, `./companies`, `./contacts`,
|
|
192
205
|
`./locations`, `./customer-groups`, `./orders`, `./availability`. All other
|
|
193
206
|
services (Tax, Coupon, RewardPoints, Shipping, Returns, Catalog, Vendor,
|
|
194
207
|
CustomerAdmin, Approval, …) are reached from the package root.
|
|
195
208
|
|
|
209
|
+
A subpath import alone does not shrink a bundle: `EmporixClient` imports every
|
|
210
|
+
service. When bundle size matters, build the client with `createEmporixClient`,
|
|
211
|
+
which instantiates only the service classes you pass (`segments` also needs
|
|
212
|
+
`products` and `categories` in the map):
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
import { createEmporixClient, ProductService, CartService } from "@viu/emporix-sdk";
|
|
216
|
+
|
|
217
|
+
const sdk = createEmporixClient(
|
|
218
|
+
{ tenant: "mytenant", credentials: { storefront: { clientId: "..." } } },
|
|
219
|
+
{ products: ProductService, carts: CartService },
|
|
220
|
+
);
|
|
221
|
+
const products = await sdk.products.list(); // no other service is bundled
|
|
222
|
+
```
|
|
223
|
+
|
|
196
224
|
## Changelog
|
|
197
225
|
|
|
198
226
|
npmjs.com renders only this README, never a changelog — the registry has no field
|
package/dist/cart.d.cts
CHANGED
|
@@ -21,7 +21,7 @@ type Search = {
|
|
|
21
21
|
/**
|
|
22
22
|
* A standard query parameter is used to search for specific values.
|
|
23
23
|
*
|
|
24
|
-
* See: [Standard
|
|
24
|
+
* See: [Standard Practices - Query parameter](https://developer.emporix.io/api-documentation/standard-practices/q-param)
|
|
25
25
|
*
|
|
26
26
|
*/
|
|
27
27
|
q?: string;
|
|
@@ -76,7 +76,7 @@ type BaseCart = {
|
|
|
76
76
|
* * If the cart has a legal entity, it gets the first location of the legal entity that has both `country` and `zipCode`, and matches the required `type` - then the address has origin=`LEGAL_ENTITY`.
|
|
77
77
|
* * Otherwise, if the cart has a logged-in customer, it finds the `default` address that has both `country` and `zipCode`, and matches the required `type`. If there is no matching default address with the required information, it uses the first customer address that meets the criteria. The address has origin=`CUSTOMER`.
|
|
78
78
|
* * Otherwise, the cart uses the site homebase address. Then the address has origin=`SITE`.
|
|
79
|
-
* These addresses are used in the tax country code determination [How to determine a tax country at cart level](https://developer.emporix.io/api-
|
|
79
|
+
* These addresses are used in the tax country code determination [How to determine a tax country at cart level](https://developer.emporix.io/api-documentation/api-guides/checkout/cart/cart#how-to-determine-a-tax-country-at-cart-level) and shipping cost calculation [How to calculate shipping cost at cart level](https://developer.emporix.io/api-documentation/api-guides/checkout/cart/cart#how-to-calculate-shipping-cost-at-cart-level).
|
|
80
80
|
*/
|
|
81
81
|
addresses?: Array<AddressResponse>;
|
|
82
82
|
channel?: Channel;
|
package/dist/cart.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ type Search = {
|
|
|
21
21
|
/**
|
|
22
22
|
* A standard query parameter is used to search for specific values.
|
|
23
23
|
*
|
|
24
|
-
* See: [Standard
|
|
24
|
+
* See: [Standard Practices - Query parameter](https://developer.emporix.io/api-documentation/standard-practices/q-param)
|
|
25
25
|
*
|
|
26
26
|
*/
|
|
27
27
|
q?: string;
|
|
@@ -76,7 +76,7 @@ type BaseCart = {
|
|
|
76
76
|
* * If the cart has a legal entity, it gets the first location of the legal entity that has both `country` and `zipCode`, and matches the required `type` - then the address has origin=`LEGAL_ENTITY`.
|
|
77
77
|
* * Otherwise, if the cart has a logged-in customer, it finds the `default` address that has both `country` and `zipCode`, and matches the required `type`. If there is no matching default address with the required information, it uses the first customer address that meets the criteria. The address has origin=`CUSTOMER`.
|
|
78
78
|
* * Otherwise, the cart uses the site homebase address. Then the address has origin=`SITE`.
|
|
79
|
-
* These addresses are used in the tax country code determination [How to determine a tax country at cart level](https://developer.emporix.io/api-
|
|
79
|
+
* These addresses are used in the tax country code determination [How to determine a tax country at cart level](https://developer.emporix.io/api-documentation/api-guides/checkout/cart/cart#how-to-determine-a-tax-country-at-cart-level) and shipping cost calculation [How to calculate shipping cost at cart level](https://developer.emporix.io/api-documentation/api-guides/checkout/cart/cart#how-to-calculate-shipping-cost-at-cart-level).
|
|
80
80
|
*/
|
|
81
81
|
addresses?: Array<AddressResponse>;
|
|
82
82
|
channel?: Channel;
|
package/dist/checkout.d.cts
CHANGED
|
@@ -156,7 +156,7 @@ type RequestFromQuoteCheckout = {
|
|
|
156
156
|
type RequestPaymentMethodJson = {
|
|
157
157
|
/**
|
|
158
158
|
* Payment provider, possible values:
|
|
159
|
-
* * `payment-gateway` - When the Emporix Payment-Gateway service
|
|
159
|
+
* * `payment-gateway` - When the Emporix Payment-Gateway service is used to handle a payment. For details about custom attributes that are required for a particular payment mode, check https://developer.emporix.io/api-documentation/api-guides/checkout/payment-gateway.
|
|
160
160
|
* * `custom` - When a custom provider is used. In this case the created order has the `IN_CHECKOUT` status.
|
|
161
161
|
* * `none` - For payment by cash or invoice.
|
|
162
162
|
*
|
|
@@ -167,11 +167,11 @@ type RequestPaymentMethodJson = {
|
|
|
167
167
|
*/
|
|
168
168
|
customAttributes?: {
|
|
169
169
|
/**
|
|
170
|
-
* Payment token used for the tokenized credit card flows. The field is used when provider type is `payment-gateway`. For more details, check https://developer.emporix.io/
|
|
170
|
+
* Payment token used for the tokenized credit card flows. The field is used when provider type is `payment-gateway`. For more details, check https://developer.emporix.io/api-documentation/api-guides/checkout/payment-gateway
|
|
171
171
|
*/
|
|
172
172
|
token?: string;
|
|
173
173
|
/**
|
|
174
|
-
* Identifier of a payment mode. The payment mode has to be configured in the Emporix Payment Gateway service beforehand. For more details, check https://developer.emporix.io/
|
|
174
|
+
* Identifier of a payment mode. The payment mode has to be configured in the Emporix Payment Gateway service beforehand. For more details, check https://developer.emporix.io/api-documentation/api-guides/checkout/payment-gateway
|
|
175
175
|
*/
|
|
176
176
|
modeId?: string;
|
|
177
177
|
/**
|
package/dist/checkout.d.ts
CHANGED
|
@@ -156,7 +156,7 @@ type RequestFromQuoteCheckout = {
|
|
|
156
156
|
type RequestPaymentMethodJson = {
|
|
157
157
|
/**
|
|
158
158
|
* Payment provider, possible values:
|
|
159
|
-
* * `payment-gateway` - When the Emporix Payment-Gateway service
|
|
159
|
+
* * `payment-gateway` - When the Emporix Payment-Gateway service is used to handle a payment. For details about custom attributes that are required for a particular payment mode, check https://developer.emporix.io/api-documentation/api-guides/checkout/payment-gateway.
|
|
160
160
|
* * `custom` - When a custom provider is used. In this case the created order has the `IN_CHECKOUT` status.
|
|
161
161
|
* * `none` - For payment by cash or invoice.
|
|
162
162
|
*
|
|
@@ -167,11 +167,11 @@ type RequestPaymentMethodJson = {
|
|
|
167
167
|
*/
|
|
168
168
|
customAttributes?: {
|
|
169
169
|
/**
|
|
170
|
-
* Payment token used for the tokenized credit card flows. The field is used when provider type is `payment-gateway`. For more details, check https://developer.emporix.io/
|
|
170
|
+
* Payment token used for the tokenized credit card flows. The field is used when provider type is `payment-gateway`. For more details, check https://developer.emporix.io/api-documentation/api-guides/checkout/payment-gateway
|
|
171
171
|
*/
|
|
172
172
|
token?: string;
|
|
173
173
|
/**
|
|
174
|
-
* Identifier of a payment mode. The payment mode has to be configured in the Emporix Payment Gateway service beforehand. For more details, check https://developer.emporix.io/
|
|
174
|
+
* Identifier of a payment mode. The payment mode has to be configured in the Emporix Payment Gateway service beforehand. For more details, check https://developer.emporix.io/api-documentation/api-guides/checkout/payment-gateway
|
|
175
175
|
*/
|
|
176
176
|
modeId?: string;
|
|
177
177
|
/**
|
package/dist/companies.d.cts
CHANGED
|
@@ -50,4 +50,4 @@ declare class CompaniesService {
|
|
|
50
50
|
parentHierarchy(legalEntityId: string, auth: AuthContext): Promise<LegalEntity[]>;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
export { CompaniesService, LegalEntity, LegalEntityCreate, LegalEntityUpdate };
|
|
53
|
+
export { CompaniesService, LegalEntity, LegalEntityCreate, type LegalEntitySearchInput, LegalEntityUpdate };
|
package/dist/companies.d.ts
CHANGED
|
@@ -50,4 +50,4 @@ declare class CompaniesService {
|
|
|
50
50
|
parentHierarchy(legalEntityId: string, auth: AuthContext): Promise<LegalEntity[]>;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
export { CompaniesService, LegalEntity, LegalEntityCreate, LegalEntityUpdate };
|
|
53
|
+
export { CompaniesService, LegalEntity, LegalEntityCreate, type LegalEntitySearchInput, LegalEntityUpdate };
|