@01.software/sdk 0.68.0 → 0.70.1

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.
Files changed (65) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +28 -7
  3. package/dist/client.cjs +38 -7
  4. package/dist/client.cjs.map +1 -1
  5. package/dist/client.d.cts +6 -6
  6. package/dist/client.d.ts +6 -6
  7. package/dist/client.js +38 -7
  8. package/dist/client.js.map +1 -1
  9. package/dist/{collection-client-IOaWsTMI.d.ts → collection-client-B1FSJ24_.d.ts} +5 -5
  10. package/dist/{collection-client-MbIJ5KzW.d.cts → collection-client-BHLStm1K.d.cts} +5 -5
  11. package/dist/{const-Dw5ElJs_.d.cts → const-BfQfV-rr.d.cts} +1 -1
  12. package/dist/{const-Do27Udj6.d.ts → const-ty8u0TDI.d.ts} +1 -1
  13. package/dist/embedded-admin/server.cjs +8 -0
  14. package/dist/embedded-admin/server.cjs.map +1 -1
  15. package/dist/embedded-admin/server.js +8 -0
  16. package/dist/embedded-admin/server.js.map +1 -1
  17. package/dist/embedded-admin.cjs +8 -0
  18. package/dist/embedded-admin.cjs.map +1 -1
  19. package/dist/embedded-admin.js +8 -0
  20. package/dist/embedded-admin.js.map +1 -1
  21. package/dist/errors.cjs +8 -0
  22. package/dist/errors.cjs.map +1 -1
  23. package/dist/errors.d.cts +3 -3
  24. package/dist/errors.d.ts +3 -3
  25. package/dist/errors.js +8 -0
  26. package/dist/errors.js.map +1 -1
  27. package/dist/{index-gnVxTKXu.d.cts → index-CX6si6YC.d.cts} +3 -3
  28. package/dist/{index-DcYsLOja.d.ts → index-DnKgjPGM.d.ts} +3 -3
  29. package/dist/index.cjs +38 -7
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +7 -7
  32. package/dist/index.d.ts +7 -7
  33. package/dist/index.js +38 -7
  34. package/dist/index.js.map +1 -1
  35. package/dist/{payload-types-BY1uZFRf.d.cts → payload-types-DTAaWKrp.d.cts} +32 -4
  36. package/dist/{payload-types-BY1uZFRf.d.ts → payload-types-DTAaWKrp.d.ts} +32 -4
  37. package/dist/query.cjs +17 -0
  38. package/dist/query.cjs.map +1 -1
  39. package/dist/query.d.cts +5 -5
  40. package/dist/query.d.ts +5 -5
  41. package/dist/query.js +17 -0
  42. package/dist/query.js.map +1 -1
  43. package/dist/realtime.d.cts +2 -2
  44. package/dist/realtime.d.ts +2 -2
  45. package/dist/server.cjs +38 -7
  46. package/dist/server.cjs.map +1 -1
  47. package/dist/server.d.cts +7 -7
  48. package/dist/server.d.ts +7 -7
  49. package/dist/server.js +38 -7
  50. package/dist/server.js.map +1 -1
  51. package/dist/storefront-cache.cjs +8 -0
  52. package/dist/storefront-cache.cjs.map +1 -1
  53. package/dist/storefront-cache.js +8 -0
  54. package/dist/storefront-cache.js.map +1 -1
  55. package/dist/{types-csjaig4G.d.cts → types-Bzgf4mTo.d.cts} +3 -3
  56. package/dist/{types-DnIuxgu2.d.cts → types-CpSiyJud.d.cts} +8 -2
  57. package/dist/{types-AWSVpuPE.d.ts → types-DX8Z44yQ.d.ts} +8 -2
  58. package/dist/{types-CLRw0aDa.d.ts → types-DdlhpNVv.d.ts} +3 -3
  59. package/dist/ui/form.d.cts +1 -1
  60. package/dist/ui/form.d.ts +1 -1
  61. package/dist/ui/video.d.cts +1 -1
  62. package/dist/ui/video.d.ts +1 -1
  63. package/dist/webhook.d.cts +5 -5
  64. package/dist/webhook.d.ts +5 -5
  65. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,58 @@
1
1
  # @01.software/sdk
2
2
 
3
+ ## 0.70.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 063fa7b: Guarantee one safe request resend after a successful token_expired refresh independently of the transient retry budget, including maxRetries: 0 and expiry on the final attempt. Preserve the single-refresh bound, unsafe-method replay restriction, and typed errors with request IDs.
8
+
9
+ Keep the refreshed response's retry admission authoritative, including canonical retry denial and an excessive Retry-After hint, while retaining retries for actual transport failures.
10
+
11
+ - 86272b6: Sync the generated Order return-status help with the Console display label
12
+ “No return”. Field types and stored status values are unchanged.
13
+ - 45817d4: Synchronize generated Payload types for the internal `audit-logs` collection. `AuditLog` and `AuditLogsSelect` gain one optional, nullable `entryKey` field, a private deduplication digest that every caller-facing read denies.
14
+
15
+ Additive only. No collection becomes addressable, no existing field changes, and no SDK runtime behavior changes.
16
+
17
+ - d2a88cd: Keep unavailable refund funding fields out of public collection types and
18
+ native reads, including populated refund relationships. Preserve existing
19
+ server-only collection availability, ordinary refund fields, and internal
20
+ funding evidence.
21
+
22
+ Exclude owning Refund metadata from caller responses and unavailable fields from
23
+ tenant schema discovery. Reject private metadata predicates, whole-metadata
24
+ comparisons other than existence, whole-metadata sorting (including subpath
25
+ sort spellings), and caller Local distinct over Refund metadata. These native
26
+ 400 query errors preserve ordinary metadata subpath filters, non-metadata sorts,
27
+ server collection access and internal overrideAccess owning reads/replay.
28
+
29
+ ## 0.70.0
30
+
31
+ ### Minor Changes
32
+
33
+ - e5849e7: Preserve `admission_not_eligible`, `admission_eligibility_unavailable`, `admission_authority_unavailable`, `admission_customer_binding_required`, and `admission_eligibility_unproven` as typed commerce error reasons across Cart, Checkout, and PaymentSession operations. Their existing meanings and HTTP statuses are unchanged. Older SDKs retain unrecognized reasons as `unknown_commerce_error` with `rawReason`.
34
+
35
+ ### Patch Changes
36
+
37
+ - 729e6cc: Synchronize generated internal Refund types with frozen funding attribution and optional capture linkage for refunds without a provider leg. Public credit operations remain unavailable.
38
+ - 6e7f1e3: Sync the generated customer collection documentation with its neutral Admin description.
39
+ - c93137c: Use the shared HTTP operation manifest for the existing event registration and guest helpers, preserving their request signatures and terminal rate-limit errors.
40
+ - 054184f: After a token-expired 401, refresh the customer token but resend the original request only for GET, HEAD, or OPTIONS. Unsafe requests retain the original authentication error so callers can explicitly retry.
41
+
42
+ ## 0.69.0
43
+
44
+ ### Minor Changes
45
+
46
+ - 88a5db7: 상품의 고객별 누적 구매 한도 타입과 `purchase_limit_exceeded` 오류 reason을 추가합니다.
47
+
48
+ 운영 주의: 애플리케이션을 rollback하면 이 상한 집행이 사라집니다. **rollback 전 한도 상품 판매 중지**가 필요합니다. 스키마 마이그레이션은 forward-only이며, 컬럼·미검증 CHECK 추가 → CHECK 검증 → 트랜잭션 밖 동시 인덱스 생성 순서로 적용합니다.
49
+
50
+ - 349785e: Add the `product_not_eligible` commerce reason for products restricted to eligible Customer Groups. Restricted purchases require a Customer-bound Cart and verified Customer session or server delegation; unrestricted products retain existing behavior.
51
+ - 7488329: Add the stable `admission_required` error reason for public event registration.
52
+ RSVP/approval registration now rejects applicable non-deleted admission types,
53
+ including inactive, out-of-sale and zero-price types. Use the admission purchase
54
+ flow for these events; the SDK preserves the 409 reason without retrying.
55
+
3
56
  ## 0.68.0
4
57
 
5
58
  ### Minor Changes
package/README.md CHANGED
@@ -80,7 +80,7 @@ entry.
80
80
  | `@01.software/sdk/ui/form` | `FormRenderer` | `react`, `react-dom` |
81
81
  | `@01.software/sdk/ui/code-block` | `CodeBlock`, `highlight` | `react`, `react-dom`, `shiki`, `hast-util-to-jsx-runtime` |
82
82
  | `@01.software/sdk/ui/canvas` | `CanvasRenderer`, `CanvasFrame`, `useCanvas`, `prefetchCanvas` | `react`, `react-dom`, `@tanstack/react-query`, `@xyflow/react`, `quickjs-emscripten`, `postcss`, `sucrase` |
83
- | `@01.software/sdk/ui/canvas/server` | canvas server helpers | none |
83
+ | `@01.software/sdk/ui/canvas/server` | canvas server helpers | `postcss` >=8 (optional peer) |
84
84
  | `@01.software/sdk/ui/video` | `VideoPlayer` | `react`, `react-dom`, `@mux/mux-player-react` |
85
85
  | `@01.software/sdk/ui/image` | `Image` | `react`, `react-dom` |
86
86
 
@@ -896,6 +896,10 @@ const query = createQueryHooks(client, getStorefrontQueryClient())
896
896
 
897
897
  Most consumers should use the helper APIs above (`commerce.product.detail`, etc.). The query builder below is the escape hatch for advanced cases the helpers do not cover: bulk operations, custom filter combinations, or fields the helper response does not expose.
898
898
 
899
+ Refund and refund-line-item collection reads remain server-only. Their public
900
+ types and native reads omit private funding fields, including populated refund
901
+ relationships. Generated storage types do not grant access to those fields.
902
+
899
903
  ### `depth` — how deep to populate relationship fields
900
904
 
901
905
  `depth` is the primary control for populating relationships like `category`, `images`, `brand`. Browser publishable-key raw collection reads are constrained to `depth: 0` with `joins: false` and no `populate`; relationship-rich storefront reads should use shaped helpers such as `commerce.product.detail()` / `listingPage()`, or a `createServerClient()` raw query when server credentials are appropriate. Browser SDK raw reads add those safe defaults automatically and reject relationship-expanded raw read options before making a request.
@@ -1509,11 +1513,14 @@ their state fields before reading state-specific data such as `nextAction` or
1509
1513
  customer JWT when a resource is customer-bound. Server calls use the secret
1510
1514
  credential and never expose provider secrets in returned DTOs.
1511
1515
 
1512
- Browser and server commerce writes use separate transports even when their JSON
1513
- shapes match. `createServerClient()` routes every Cart operation, Checkout
1514
- create/retrieve/query, and PaymentSession create/retrieve/cancel/confirm through
1515
- the resource-owned `/server/*` namespace. Public paths retain only their exact
1516
- capability/customer bodies and never advertise the server credential.
1516
+ Cart and Checkout browser/server aliases reuse the same registered operations
1517
+ in their respective credential contexts; sharing an endpoint does not grant the
1518
+ same permissions. SDK alias mappings follow the `@01.software/http-contracts`
1519
+ manifest. Managed PaymentSession server operations use the resource-owned
1520
+ `/server/*` transport, while the server-only custom PaymentSession bridge uses
1521
+ separate orders-owned manifest operations. Keep Secret Keys on trusted servers;
1522
+ public calls retain their capability/customer bodies and never include server
1523
+ credentials.
1517
1524
 
1518
1525
  Generate one idempotency key per logical mutation, persist it with the pending
1519
1526
  operation, and reuse it after timeouts or lost responses. Creating a fresh key
@@ -2023,7 +2030,7 @@ your own baseline, retaining every option, value, and variant you intend to
2023
2030
  keep. Media IDs must already belong to the saved product's image pool.
2024
2031
 
2025
2032
  ```ts
2026
- await client.commerce.product.upsert({
2033
+ await server.commerce.product.upsert({
2027
2034
  productId: 'prod_123',
2028
2035
  graphRevision: draft.graphRevision,
2029
2036
  options: [
@@ -2520,6 +2527,18 @@ try {
2520
2527
 
2521
2528
  Error classes: `SDKError`, `ApiError`, `NetworkError`, `ValidationError`, `ConfigError`, `TimeoutError`
2522
2529
 
2530
+ A customer-token `401 token_expired` permits at most one configured token
2531
+ refresh. After a successful refresh, GET/HEAD/OPTIONS may be resent once
2532
+ independently of the transient retry budget, including `retry.maxRetries: 0`
2533
+ or expiry on the final attempt. This does not reset the transient retry budget.
2534
+ Another 401 returns its typed authentication error and request ID without a
2535
+ second refresh; unsafe methods return the original authentication error without
2536
+ resending the request.
2537
+
2538
+ After refresh, a canonical commerce response with `retryable: false` or no
2539
+ `retryable` field, or a `Retry-After` beyond the automatic wait bound, returns
2540
+ its typed error and request ID without another automatic retry.
2541
+
2523
2542
  ## Environment Variables
2524
2543
 
2525
2544
  ```bash
@@ -2659,3 +2678,5 @@ Reuse the same sourceNamespace/sourceRef and identical issue input on an unknown
2659
2678
  `client.benefitVouchers.listMine({ status: 'available', limit: 20 })` uses the Customer JWT and returns only identity, customer-visible copy, state and timestamps. Use `status: 'all'` for history and the returned `nextCursor` for another page (maximum 100). The response is private, no-store. Server lists return the server DTO and require customerId; cross-customer/tenant targets are masked as 404. Console customer detail shows a read-only list; Console action buttons follow separately.
2660
2679
 
2661
2680
  The staff app server must verify the staff member and Customer before redeeming: voucherId is not a bearer capability. `actorRef` is app-attested evidence, never a platform-verified staff identity or an authorization input. Use opaque references without personal data in sourceRef and actorRef. Definitions snapshot name, description and expiry at issue; later edits do not change issued vouchers. Voucher history survives Customer erasure and blocks tenant hard deletion. Referenced definitions must be archived.
2681
+
2682
+ Product purchase quantity policies are enforced by Console at Cart ingress and Checkout creation. A product's optional `maxQuantityPerCustomer` combines all variants, committed Orders minus completed Returns, and open Checkouts. Limited products require a verified Customer; delegated server purchases use the existing `customerToken`. Handle `409 purchase_limit_exceeded` by its scalar `details.productId`, `maxQuantityPerCustomer` and `remainingQuantity`; guests receive `product_not_eligible`. See the [Commerce guide](https://docs.01.software/en/commerce).
package/dist/client.cjs CHANGED
@@ -153,7 +153,13 @@ var COMMERCE_ERROR_CODES = [
153
153
  "checkout_reservation_release_requires_transaction",
154
154
  "admission_metadata_invalid",
155
155
  "admission_metadata_required",
156
+ "admission_not_eligible",
157
+ "admission_eligibility_unavailable",
158
+ "admission_authority_unavailable",
159
+ "admission_customer_binding_required",
160
+ "admission_eligibility_unproven",
156
161
  "capacity_exceeded",
162
+ "admission_required",
157
163
  "occurrence_lock_unavailable",
158
164
  "occurrence_not_open",
159
165
  "admission_type_capacity_exceeded",
@@ -172,6 +178,8 @@ var COMMERCE_ERROR_CODES = [
172
178
  "variant_inactive",
173
179
  "variant_product_mismatch",
174
180
  "product_not_public",
181
+ "product_not_eligible",
182
+ "purchase_limit_exceeded",
175
183
  "market_not_found",
176
184
  "market_shipping_currency_unsupported",
177
185
  "missing_market_rate",
@@ -819,6 +827,7 @@ async function httpFetch(url, options) {
819
827
  let lastError;
820
828
  let hasRetried401 = false;
821
829
  for (let attempt = 0; attempt <= retryConfig.maxRetries; attempt++) {
830
+ let terminalResponseError;
822
831
  try {
823
832
  const headers = new Headers(requestInit.headers);
824
833
  if (publishableKey) {
@@ -887,8 +896,9 @@ async function httpFetch(url, options) {
887
896
  hasRetried401 = true;
888
897
  try {
889
898
  const newToken = await onUnauthorized();
890
- if (newToken) {
899
+ if (newToken && SAFE_METHODS.includes((requestInit.method || "GET").toUpperCase())) {
891
900
  authToken = newToken;
901
+ attempt--;
892
902
  continue;
893
903
  }
894
904
  } catch {
@@ -921,11 +931,15 @@ async function httpFetch(url, options) {
921
931
  await delay(retryDelay);
922
932
  continue;
923
933
  }
934
+ terminalResponseError = error;
924
935
  throw error;
925
936
  }
926
937
  return response;
927
938
  } catch (error) {
928
939
  debugLog(debug, "error", url, error);
940
+ if (terminalResponseError && error === terminalResponseError) {
941
+ throw error;
942
+ }
929
943
  const method2 = (requestInit.method || "GET").toUpperCase();
930
944
  const isSafe = SAFE_METHODS.includes(method2);
931
945
  if (error instanceof Error && error.name === "AbortError") {
@@ -1337,6 +1351,15 @@ var EMBEDDED_ADMIN_ENDPOINT_OPERATIONS = {
1337
1351
  };
1338
1352
  var EVENTS_ENDPOINT_OPERATIONS = {
1339
1353
  registrations: {
1354
+ register: operation("event-registrations", "post", "/register"),
1355
+ guestLookup: operation("event-registrations", "post", "/guest/lookup"),
1356
+ guestLookupByUrl: operation("event-registrations", "get", "/guest/:token"),
1357
+ guestCancel: operation("event-registrations", "post", "/guest/cancel"),
1358
+ guestCancelByUrl: operation(
1359
+ "event-registrations",
1360
+ "post",
1361
+ "/guest/:token/cancel"
1362
+ ),
1340
1363
  listMine: operation("event-registrations", "get", "/my")
1341
1364
  },
1342
1365
  events: {
@@ -6355,24 +6378,32 @@ var EventsClient = class {
6355
6378
  }
6356
6379
  register(params) {
6357
6380
  return this.execute(
6358
- "/api/event-registrations/register",
6359
- "POST",
6381
+ resolveOperationPath(EVENTS_ENDPOINT_OPERATIONS.registrations.register),
6382
+ resolveOperationMethod(EVENTS_ENDPOINT_OPERATIONS.registrations.register),
6360
6383
  buildRegistrationRequestBody(params),
6361
6384
  { useCustomerAuth: true }
6362
6385
  );
6363
6386
  }
6364
6387
  getGuestRegistration(token) {
6365
6388
  return this.execute(
6366
- "/api/event-registrations/guest/lookup",
6367
- "POST",
6389
+ resolveOperationPath(
6390
+ EVENTS_ENDPOINT_OPERATIONS.registrations.guestLookup
6391
+ ),
6392
+ resolveOperationMethod(
6393
+ EVENTS_ENDPOINT_OPERATIONS.registrations.guestLookup
6394
+ ),
6368
6395
  { token },
6369
6396
  { useCustomerAuth: false }
6370
6397
  );
6371
6398
  }
6372
6399
  cancelGuestRegistration(token, params = {}) {
6373
6400
  return this.execute(
6374
- "/api/event-registrations/guest/cancel",
6375
- "POST",
6401
+ resolveOperationPath(
6402
+ EVENTS_ENDPOINT_OPERATIONS.registrations.guestCancel
6403
+ ),
6404
+ resolveOperationMethod(
6405
+ EVENTS_ENDPOINT_OPERATIONS.registrations.guestCancel
6406
+ ),
6376
6407
  buildGuestCancelRequestBody(token, params),
6377
6408
  { useCustomerAuth: false }
6378
6409
  );