@viu/emporix-sdk 4.2.3 → 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 CHANGED
@@ -1,5 +1,11 @@
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
+
3
9
  ## 4.2.3
4
10
 
5
11
  ### 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`, `orders.listMine(auth, { q })`,
76
- `customerAdmin.searchCustomers({ q })` and `vendors.searchVendors({ q })` accept a
77
- raw Emporix `q` string **or** a type-safe filter built with `mixinQuery` from
78
- [`@viu/emporix-mixins`](../mixins). The filter is entity-gated (a filter built for
79
- one entity is a compile error on another) and an `or()` filter is rejected on
80
- services that don't support `compoundLogicalQuery`.
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 last argument of every service method is the
119
- `AuthContext`; defaults below apply when omitted.
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`. Full details in [`../../docs/auth.md`](../../docs/auth.md).
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`), list (paginated, `PaginatedItems<Asset>`),
165
- get, update (JSON metadata or BLOB multipart file-replacement via the
166
- `replaceFile` sugar), remove, and download (resolves to either a redirect
167
- URL for `PUBLIC` assets or an `ArrayBuffer` for `PRIVATE`). All endpoints
168
- require a server-only scope — every call defaults to a `service`
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. Tree-shakeable subpaths are published for the high-traffic
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
@@ -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 };
@@ -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/index.cjs CHANGED
@@ -1242,7 +1242,7 @@ var HttpClient = class {
1242
1242
  };
1243
1243
 
1244
1244
  // package.json
1245
- var version = "4.2.3";
1245
+ var version = "4.2.4";
1246
1246
 
1247
1247
  // src/version.ts
1248
1248
  var SDK_VERSION = version;