@01.software/sdk 0.67.0 → 0.68.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.
Files changed (61) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +122 -6
  3. package/dist/client.cjs +419 -319
  4. package/dist/client.cjs.map +1 -1
  5. package/dist/client.d.cts +11 -6
  6. package/dist/client.d.ts +11 -6
  7. package/dist/client.js +419 -319
  8. package/dist/client.js.map +1 -1
  9. package/dist/{collection-client-D4HEOoO_.d.ts → collection-client-IOaWsTMI.d.ts} +4 -4
  10. package/dist/{collection-client-jrNFGbrO.d.cts → collection-client-MbIJ5KzW.d.cts} +4 -4
  11. package/dist/{const-BU79hCFB.d.ts → const-Do27Udj6.d.ts} +2 -2
  12. package/dist/{const-CCQ3MdLE.d.cts → const-Dw5ElJs_.d.cts} +2 -2
  13. package/dist/embedded-admin/server.cjs +16 -1
  14. package/dist/embedded-admin/server.cjs.map +1 -1
  15. package/dist/embedded-admin/server.d.cts +4 -2
  16. package/dist/embedded-admin/server.d.ts +4 -2
  17. package/dist/embedded-admin/server.js +16 -1
  18. package/dist/embedded-admin/server.js.map +1 -1
  19. package/dist/embedded-admin.cjs +19 -0
  20. package/dist/embedded-admin.cjs.map +1 -1
  21. package/dist/embedded-admin.d.cts +7 -1
  22. package/dist/embedded-admin.d.ts +7 -1
  23. package/dist/embedded-admin.js +19 -0
  24. package/dist/embedded-admin.js.map +1 -1
  25. package/dist/errors.d.cts +2 -2
  26. package/dist/errors.d.ts +2 -2
  27. package/dist/{index-CwKxWHIa.d.ts → index-DcYsLOja.d.ts} +3 -3
  28. package/dist/{index-DiyhsVHd.d.cts → index-gnVxTKXu.d.cts} +3 -3
  29. package/dist/index.cjs +424 -323
  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 +424 -323
  34. package/dist/index.js.map +1 -1
  35. package/dist/{payload-types-jdsUXunB.d.cts → payload-types-BY1uZFRf.d.cts} +34 -1
  36. package/dist/{payload-types-jdsUXunB.d.ts → payload-types-BY1uZFRf.d.ts} +34 -1
  37. package/dist/query.cjs +8 -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 +8 -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 +1183 -1071
  46. package/dist/server.cjs.map +1 -1
  47. package/dist/server.d.cts +9 -8
  48. package/dist/server.d.ts +9 -8
  49. package/dist/server.js +1183 -1071
  50. package/dist/server.js.map +1 -1
  51. package/dist/{types-BusejG-v.d.ts → types-AWSVpuPE.d.ts} +2 -2
  52. package/dist/{types-I2k6Laad.d.ts → types-CLRw0aDa.d.ts} +147 -40
  53. package/dist/{types-BPwXAFZ7.d.cts → types-DnIuxgu2.d.cts} +2 -2
  54. package/dist/{types-CvdBV3ri.d.cts → types-csjaig4G.d.cts} +147 -40
  55. package/dist/ui/form.d.cts +1 -1
  56. package/dist/ui/form.d.ts +1 -1
  57. package/dist/ui/video.d.cts +1 -1
  58. package/dist/ui/video.d.ts +1 -1
  59. package/dist/webhook.d.cts +5 -5
  60. package/dist/webhook.d.ts +5 -5
  61. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @01.software/sdk
2
2
 
3
+ ## 0.68.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 0211dc7: Add server benefitVouchers issue/get/list/redeem/voidVoucher commands and Customer listMine. Vouchers are single-use non-monetary benefits; source identity and request UUIDs make explicit retries safe.
8
+ - 0211dc7: Support explicit embedded app execution-role opt-in on both the tenant binding
9
+ and receiver verifier, preserving administrator-only defaults. Add CLI
10
+ allowed-role configuration and binding-state readback.
11
+
12
+ ### Patch Changes
13
+
14
+ - 342cda2: Sync the generated benefit voucher definition documentation with its bilingual Admin description.
15
+
3
16
  ## 0.67.0
4
17
 
5
18
  ### Minor Changes
package/README.md CHANGED
@@ -158,6 +158,20 @@ The assertion proves operator and tenant context only. It is not a Console API
158
158
  credential; the external backend must use its own server-held credential and
159
159
  authorization policy for tenant data.
160
160
 
161
+ The verifier defaults to `super-admin` and `tenant-admin` only. To allow an
162
+ editor or viewer, both the administrator-managed binding `allowedRoles` and the
163
+ receiver's trusted server `allowedRoles` option must include that exact role.
164
+ For example, a receiver can pass
165
+ `allowedRoles: ['super-admin', 'tenant-admin', 'tenant-viewer']`; never take this
166
+ allowlist from browser input. Only opted-in operators see the execution view;
167
+ binding configuration remains administrator-only.
168
+
169
+ The receiver server must enforce each app feature's permissions from verified
170
+ `tenant_role` and `operator_id`, independently of its server credential. Direct
171
+ platform viewer mutation denial remains unchanged. The 60-second assertion
172
+ expiry does not revoke an app-local session; the receiver owns its session
173
+ expiry, authorization rechecks, and revocation.
174
+
161
175
  Migration quick reference:
162
176
 
163
177
  - `createClient` remains available from `@01.software/sdk` and
@@ -1998,20 +2012,92 @@ if (!result.ok) {
1998
2012
  }
1999
2013
  ```
2000
2014
 
2001
- Existing product graph edits send the saved product id and the composer draft
2002
- baseline, without product document fields:
2015
+ Existing product graph edits send the saved product id and the revision from
2016
+ the composer draft baseline, without product document fields. The draft is an
2017
+ editor read model, not an SDK mutation payload: construct `options` and
2018
+ `variants` explicitly instead of forwarding `draft.options` / `draft.variants`.
2019
+
2020
+ This example assumes the complete persisted graph has one Color option, two
2021
+ values, and two variants. Replace the sample IDs and reviewed values with
2022
+ your own baseline, retaining every option, value, and variant you intend to
2023
+ keep. Media IDs must already belong to the saved product's image pool.
2003
2024
 
2004
2025
  ```ts
2005
2026
  await client.commerce.product.upsert({
2006
2027
  productId: 'prod_123',
2007
2028
  graphRevision: draft.graphRevision,
2008
- options: draft.options,
2009
- variants: draft.variants,
2029
+ options: [
2030
+ {
2031
+ id: 'opt_color',
2032
+ title: 'Color',
2033
+ slug: 'color',
2034
+ values: [
2035
+ {
2036
+ id: 'val_black',
2037
+ value: 'Black',
2038
+ slug: 'black',
2039
+ swatch: { type: 'color', color: '#111111' },
2040
+ },
2041
+ {
2042
+ id: 'val_white',
2043
+ value: 'White',
2044
+ slug: 'white',
2045
+ swatch: { type: 'media', mediaItemId: 'img_white' },
2046
+ },
2047
+ ],
2048
+ },
2049
+ ],
2050
+ variants: [
2051
+ {
2052
+ id: 'var_black',
2053
+ optionValues: { color: { valueId: 'val_black' } },
2054
+ price: 29000,
2055
+ images: ['img_black'],
2056
+ },
2057
+ {
2058
+ id: 'var_white',
2059
+ optionValues: { color: { valueId: 'val_white' } },
2060
+ price: 29000,
2061
+ images: ['img_white'],
2062
+ },
2063
+ ],
2010
2064
  })
2011
2065
  ```
2012
2066
 
2013
- For updates to existing options or option-values, prefer `id` / `valueId` when
2014
- available so rename-safe updates do not depend on slugs.
2067
+ Keep persisted option/value/variant `id`s and select existing values by
2068
+ `valueId`; do not regenerate identity from labels or change stored slugs.
2069
+ Resolve editor `optionValueKeys` (client keys) to SDK `optionValues`, as above,
2070
+ whose record keys are option slugs or titles, not option IDs. Do not send
2071
+ unsaved matrix proposal rows (`included: false` with no `id`). Preserve IDs
2072
+ for persisted rows you retain, and send `isActive: false` when deliberately
2073
+ deactivating one. Copy only mutation fields, excluding `clientKey`, `included`,
2074
+ and other editor state. SDK `images` contains string IDs, not hydrated media
2075
+ objects.
2076
+ An SDK swatch object requires `type: 'color'` with a color string or
2077
+ `type: 'media'` with a `mediaItemId` string. For an existing value, omit
2078
+ `swatch` to preserve its stored swatch. The SDK type also accepts `swatch: null`;
2079
+ runtime clearing with it is not verified here. Do not copy a draft swatch
2080
+ with a missing/null tag or null active value into that object shape.
2081
+
2082
+ Upsert synchronizes the full graph, not just changed rows: omitted options or
2083
+ values can be deleted, and omitted variants can be deleted or deactivated.
2084
+ If reservation history prevents variant deletion, omission can instead reject
2085
+ the write with `409` and roll it back.
2086
+ Keep the revision of the reviewed baseline and review fresh values after a
2087
+ `graph_conflict`; do not substitute a newer revision onto stale values.
2088
+ `graphRevision` excludes inventory-only changes, so this graph edit omits
2089
+ loaded `stock` on persisted variants. New finite variants may carry initial
2090
+ stock. An intentional stock write is different from replaying loaded stock;
2091
+ this example does not perform one.
2092
+
2093
+ This example is for a persisted option graph. For editor-only placeholders,
2094
+ use the simple-variant branch only when `editorPlaceholderGraph` is true and
2095
+ the structure still matches: one unsaved `Default` option, one unsaved value
2096
+ with a nonempty label (not necessarily `Standard`), and one included variant
2097
+ selecting only that value. Send `options: []` and that simple variant with
2098
+ `optionValues: {}`. Preserve its variant ID if persisted; a new variant has
2099
+ no saved ID. Omit loaded stock on persisted variants. Base-price-only changes
2100
+ use `updateVariantPrices()` above, rather than a full graph upsert.
2015
2101
 
2016
2102
  ```typescript
2017
2103
  // Batch stock check (point-in-time read, NOT a reservation)
@@ -2543,3 +2629,33 @@ P5 also adds JWT-`jti` revocation: `revokeCustomerJti(jti, ttl)` on the server i
2543
2629
  **Boolean field renames** (6 collections):
2544
2630
 
2545
2631
  - `status: 'active' | 'inactive'` → `isActive: boolean` on Forms, ArticleAuthors, CustomerGroups, ShippingPolicies, ProductVariants
2632
+
2633
+ ### Customer benefit vouchers
2634
+
2635
+ Tenant-admins manage benefit voucher definitions in Console. These are single-use, non-monetary benefits, with no Checkout discount or credit effect. Your server decides recipients and timing (for example from a membership webhook or your own cron); source uniqueness prevents duplicate effects only.
2636
+
2637
+ ```ts
2638
+ import { createServerClient } from '@01.software/sdk/server'
2639
+
2640
+ const server = createServerClient({ publishableKey, secretKey })
2641
+ const { voucher, created } = await server.benefitVouchers.issue({
2642
+ definitionId,
2643
+ customerId,
2644
+ sourceNamespace: 'member-benefits',
2645
+ sourceRef: 'period:2030-01:member-opaque-id',
2646
+ })
2647
+ const redeemed = await server.benefitVouchers.redeem({
2648
+ customerId,
2649
+ voucherId: voucher.id,
2650
+ requestId,
2651
+ actorRef: 'staff:opaque-id',
2652
+ })
2653
+ ```
2654
+
2655
+ `server.benefitVouchers.get({ customerId, voucherId })` and `list({ customerId, state?, definitionId?, limit?, cursor? })` require a read-scoped server key. `issue`, `redeem`, and `voidVoucher({ customerId, voucherId, requestId, actorRef, reason })` require write scope, sk01 credentials and no browser Origin. Void reasons are `issued_in_error`, `benefit_revoked`, `customer_request`, and `other`. Issuing and redeeming require effective Ecommerce and Customers; reads and void remain available after feature loss.
2656
+
2657
+ Reuse the same sourceNamespace/sourceRef and identical issue input on an unknown outcome. For redeem/void, create a request UUID once and reuse it on retries; these POSTs are not automatically retried. Reusing an identity with different input returns 409. A successful transition is irreversible. Expiry uses database time and is inclusive at expiresAt. Correct an issued benefit by voiding it and issuing a new source identity.
2658
+
2659
+ `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
+
2661
+ 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.