@01.software/sdk 0.46.1 → 0.48.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 (57) hide show
  1. package/CHANGELOG.md +69 -1
  2. package/README.md +81 -7
  3. package/dist/client.cjs +304 -63
  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 +304 -63
  8. package/dist/client.js.map +1 -1
  9. package/dist/{collection-client-L2rEgBaR.d.cts → collection-client-CBup9yOx.d.cts} +4 -4
  10. package/dist/{collection-client-BEGXnfQe.d.ts → collection-client-D3ExJU-7.d.ts} +4 -4
  11. package/dist/{const-y0eipvnQ.d.cts → const-BXEi1Kix.d.cts} +4 -4
  12. package/dist/{const-GYVwlXLr.d.ts → const-k9gHylYa.d.ts} +4 -4
  13. package/dist/errors.cjs +49 -1
  14. package/dist/errors.cjs.map +1 -1
  15. package/dist/errors.d.cts +3 -3
  16. package/dist/errors.d.ts +3 -3
  17. package/dist/errors.js +49 -1
  18. package/dist/errors.js.map +1 -1
  19. package/dist/{index-BfYL6Qb1.d.cts → index-BCM9CTL7.d.cts} +3 -3
  20. package/dist/{index-Bei4WlVw.d.ts → index-CHGGkcLj.d.ts} +3 -3
  21. package/dist/index.cjs +308 -64
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +7 -7
  24. package/dist/index.d.ts +7 -7
  25. package/dist/index.js +308 -64
  26. package/dist/index.js.map +1 -1
  27. package/dist/{payload-types-3WNyC0gk.d.cts → payload-types-B6AZQcB7.d.cts} +177 -15
  28. package/dist/{payload-types-3WNyC0gk.d.ts → payload-types-B6AZQcB7.d.ts} +177 -15
  29. package/dist/query.cjs +144 -43
  30. package/dist/query.cjs.map +1 -1
  31. package/dist/query.d.cts +5 -5
  32. package/dist/query.d.ts +5 -5
  33. package/dist/query.js +144 -43
  34. package/dist/query.js.map +1 -1
  35. package/dist/realtime.d.cts +2 -2
  36. package/dist/realtime.d.ts +2 -2
  37. package/dist/server.cjs +385 -63
  38. package/dist/server.cjs.map +1 -1
  39. package/dist/server.d.cts +7 -7
  40. package/dist/server.d.ts +7 -7
  41. package/dist/server.js +385 -63
  42. package/dist/server.js.map +1 -1
  43. package/dist/storefront-cache.cjs +49 -1
  44. package/dist/storefront-cache.cjs.map +1 -1
  45. package/dist/storefront-cache.js +49 -1
  46. package/dist/storefront-cache.js.map +1 -1
  47. package/dist/{types-CAicTn-o.d.cts → types-8us-_C-Q.d.cts} +2 -2
  48. package/dist/{types-DpSyNTxy.d.ts → types-ByD2zii1.d.ts} +2 -2
  49. package/dist/{types-mIROvhhP.d.ts → types-CM2je9Kw.d.cts} +84 -7
  50. package/dist/{types-CDJ2M-MJ.d.cts → types-DbA5V3mt.d.ts} +84 -7
  51. package/dist/ui/form.d.cts +1 -1
  52. package/dist/ui/form.d.ts +1 -1
  53. package/dist/ui/video.d.cts +1 -1
  54. package/dist/ui/video.d.ts +1 -1
  55. package/dist/webhook.d.cts +4 -4
  56. package/dist/webhook.d.ts +4 -4
  57. package/package.json +6 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,73 @@
1
1
  # @01.software/sdk
2
2
 
3
+ ## 0.48.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 715fe57: Expose active tenant custom-field structure in the optional version-1
8
+ collection schema response and preserve it through Agent CLI schema output.
9
+ - b23608d: Preserve canonical strict commerce errors through the mounted Console handlers and public Cart, Checkout, and PaymentSession facades, including the additive handler reason vocabulary.
10
+
11
+ ### Patch Changes
12
+
13
+ - 3096b74: Align the SDK build and test toolchain with the Payload release that removes
14
+ the vulnerable archived image parser dependency.
15
+ - d98f7b3: Synchronize generated Payload types for internal settlement receipt and reconciliation evidence. These collections remain absent from every public SDK collection bucket and add no public SDK API.
16
+
17
+ ## 0.47.0
18
+
19
+ ### Minor Changes
20
+
21
+ - 5a523e8: Add the managed PortOne Hosted v2 payment-session flow, provider-specific
22
+ checkout action parsing, CLI dispatch, and compatible event-template recovery
23
+ behavior. Expose the full current Hosted v2 payment-method vocabulary while
24
+ preserving per-connection allowlists.
25
+ - 5e68929: Add a browser-safe shaped `community.getPost({ postId })` helper while keeping
26
+ raw community posts server-only, and update the generated community template to
27
+ consume that helper without a raw collection workaround.
28
+ - 5a523e8: Add a server-only exact custom PaymentSession recovery lookup by provider
29
+ session or payment identity.
30
+ - 5a523e8: Expose the additive `tenantPurpose` and `testExpiresAt` fields on the generated
31
+ `Tenant` type for time-limited, externally fenced test tenants.
32
+ - d63c3c8: Reclassify `tenants` from the browser-public `COLLECTIONS` bucket to
33
+ `SERVER_ONLY_COLLECTIONS`. The tenant document denies reads without an
34
+ authenticated user, so a publishable key never reached it; the bucket promised a
35
+ browser surface that always failed at runtime. `tenant-metadata` remains the
36
+ browser-public tenant identity slug, and server (secret key) access to `tenants`
37
+ is unchanged because `SERVER_COLLECTIONS` still contains it.
38
+
39
+ Runtime behavior changes for one case, and the change is a narrowing.
40
+ `SERVER_ONLY_COLLECTIONS` is a runtime guard input, not only a type: the Console
41
+ REST route imports it and refuses a publishable-key raw read of any member. A
42
+ browser request to `/api/tenants` that previously reached Payload and was denied
43
+ by collection access now stops at that guard and returns **404** instead of 403.
44
+ Both were failures before and after; only the status and the point of denial
45
+ move. No caller could have succeeded on this path.
46
+
47
+ Type-level impact: `tenants` leaves the `PublicCollection` union, so a browser
48
+ client typed against it now fails to compile instead of failing at request time.
49
+
50
+ ### Patch Changes
51
+
52
+ - 05f7b8d: Send the publishable-key raw-read safety query when listing community post
53
+ categories, post tags, and reaction types.
54
+ - 2fd5f57: Synchronize generated types for the new Discount operator field descriptions (validity window, scope target requirement, usage limit minimums, unsupported each-line allocation). Comment-only; the Discount type shape and every public wire contract are unchanged.
55
+ - 5a523e8: Synchronize generated types for the write-only provider-credential inputs on the SDK-hidden `commerce-payment-accounts` collection. The public SDK surface is unchanged: the collection remains internal, and the two added fields are virtual Admin-only inputs that are never persisted or returned.
56
+ - 07db902: Send the publishable-key raw-read safety query when listing or resolving
57
+ community customer profile lists.
58
+ - 309418a: Correct three drifted README examples. The realtime sub-path import now names
59
+ `RealtimeConnection`, which the package actually exports (`createRealtimeClient`
60
+ does not exist), and publishable-key placeholders use the real `pk01_` prefix
61
+ instead of `pk_xxx` / `pk_live_...`. Documentation only; no runtime or type
62
+ change.
63
+ - c5e896c: Correct the generated `ShippingPolicy` field documentation. The
64
+ `freeShippingMinAmount` doc comment previously pointed at the shipping rates
65
+ array, which owns no free-shipping condition; it now names the two surfaces
66
+ that do — an order-amount rate row priced at 0, or an automatic
67
+ `free_shipping` discount with a minimum order amount. `isActive` and
68
+ `isDefault` gain doc comments describing their pricing side effects. Types and
69
+ runtime behavior are unchanged.
70
+
3
71
  ## 0.46.1
4
72
 
5
73
  ### Patch Changes
@@ -993,7 +1061,7 @@ displayStatus` JSDoc comment from `Order.status`. The Console removed that
993
1061
  customer auth rather than public request body input. **Breaking:** **`POST
994
1062
  /api/event-registrations/register` rejects `body.customer` with `400
995
1063
  bad_request`;** bind customers with `Authorization: Bearer` only. See
996
- `docs/events/public-api-contract.md` for migration. Guest-token lookup/cancel
1064
+ `docs/events/public-api-reference.md` for migration. Guest-token lookup/cancel
997
1065
  helpers send tokens in POST bodies. Range helpers support calendar, category,
998
1066
  and tag filters aligned with the Console public range endpoint. Exported
999
1067
  structural `RootClient` / `RootServerClient` keep `events` optional for
package/README.md CHANGED
@@ -38,7 +38,7 @@ import {
38
38
  } from '@01.software/sdk/webhook'
39
39
 
40
40
  // Realtime only
41
- import { createRealtimeClient } from '@01.software/sdk/realtime'
41
+ import { RealtimeConnection } from '@01.software/sdk/realtime'
42
42
 
43
43
  // Storefront cache resource names for SSG/ISR adapters
44
44
  import { storefrontCacheResources } from '@01.software/sdk/storefront-cache'
@@ -109,7 +109,7 @@ Migration quick reference:
109
109
  // Pageviews + custom events (browser)
110
110
  import { createAnalytics } from '@01.software/sdk/analytics'
111
111
 
112
- const analytics = createAnalytics({ publishableKey: 'pk_xxx' })
112
+ const analytics = createAnalytics({ publishableKey: 'pk01_xxx' })
113
113
  // auto-tracks pageviews; call analytics.pageview('/custom-path') manually if needed
114
114
  analytics.track('signup', { plan: 'pro', trial: false })
115
115
  ```
@@ -137,7 +137,7 @@ type ShopEvents = {
137
137
  checkout_start: undefined // no props
138
138
  }
139
139
 
140
- const analytics = createAnalytics<ShopEvents>({ publishableKey: 'pk_xxx' })
140
+ const analytics = createAnalytics<ShopEvents>({ publishableKey: 'pk01_xxx' })
141
141
  analytics.track('signup', { plan: 'pro', trial: false }) // ✅
142
142
  analytics.track('checkout_start') // ✅ no props
143
143
  // analytics.track('signpu', { plan: 'pro', trial: false }) // ❌ unknown event
@@ -145,7 +145,7 @@ analytics.track('checkout_start') // ✅ no props
145
145
 
146
146
  // Bind the map once to avoid repeating the generic:
147
147
  const create = defineAnalyticsEvents<ShopEvents>()
148
- const a2 = create({ publishableKey: 'pk_xxx' })
148
+ const a2 = create({ publishableKey: 'pk01_xxx' })
149
149
  ```
150
150
 
151
151
  **React.** Use `AnalyticsProvider` + `useAnalytics()` to fire events from
@@ -256,10 +256,12 @@ without calling the Console endpoint directly:
256
256
 
257
257
  ```typescript
258
258
  const context = await server.tenant.context()
259
+ const productSchema = await server.tenant.collectionSchema('products')
259
260
 
260
261
  console.log(context.features)
261
262
  console.log(context.collections.active)
262
263
  console.log(context.fieldConfigs)
264
+ console.log(productSchema.collection.customFields)
263
265
  ```
264
266
 
265
267
  Pass `{ includeCounts: true }` only when document counts and webhook
@@ -267,6 +269,12 @@ configuration are needed. That mode bypasses the endpoint cache and performs
267
269
  additional collection reads. Tenant introspection is server-only and is not
268
270
  exported from the browser-safe root entry.
269
271
 
272
+ `collection.customFields` is optional and currently applies to `customers` and
273
+ `products`. It exposes `storagePath: 'customData'`, active definition machine
274
+ keys and types, optional `required: true`, and select option storage values.
275
+ Operator labels and stored document values are excluded; this schema metadata
276
+ does not grant collection read or write access.
277
+
270
278
  Server-rendered preview routes can use `server.preview.detail()` with the
271
279
  short-lived preview token issued by Console:
272
280
 
@@ -714,7 +722,7 @@ Membership self-service is split by credential boundary:
714
722
  import { createClient } from '@01.software/sdk'
715
723
  import { createServerClient } from '@01.software/sdk/server'
716
724
 
717
- const client = createClient({ publishableKey: 'pk_live_...' })
725
+ const client = createClient({ publishableKey: 'pk01_...' })
718
726
 
719
727
  const membership = await client.memberships.me()
720
728
  if (
@@ -725,7 +733,7 @@ if (
725
733
  }
726
734
 
727
735
  const server = createServerClient({
728
- publishableKey: 'pk_live_...',
736
+ publishableKey: 'pk01_...',
729
737
  secretKey: process.env.SOFTWARE_SECRET_KEY!,
730
738
  })
731
739
 
@@ -1345,12 +1353,39 @@ if (
1345
1353
  // Initialize the Toss widget with the returned public client/variant fields.
1346
1354
  }
1347
1355
 
1356
+ // PortOne Hosted V2 uses the same canonical lifecycle with a provider-specific
1357
+ // HTTPS action. Redirect completion is not payment finality; retrieve the
1358
+ // PaymentSession and let Console converge from PortOne's authenticated API.
1359
+ const portOneSession = await client.commerce.paymentSessions.createPortOne({
1360
+ checkoutToken,
1361
+ provider: 'portone',
1362
+ providerOptions: { profile: 'hosted_v2', paymentMethod: 'CARD_KR' },
1363
+ idempotencyKey: createCommerceIdempotencyKey(),
1364
+ })
1365
+ if (
1366
+ portOneSession.presentationStatus === 'actionable' &&
1367
+ portOneSession.nextAction.type === 'portone_checkout'
1368
+ ) {
1369
+ window.location.assign(portOneSession.nextAction.checkoutUrl)
1370
+ }
1371
+
1348
1372
  // Browser recovery requires the parent capability.
1349
1373
  await client.commerce.paymentSessions.retrieve({
1350
1374
  paymentSessionId: paymentSession.id,
1351
1375
  checkoutToken,
1352
1376
  })
1353
1377
 
1378
+ await client.commerce.paymentSessions.retrievePortOne({
1379
+ paymentSessionId: portOneSession.id,
1380
+ checkoutToken,
1381
+ })
1382
+
1383
+ // The server equivalent requires a write-capable credential because the
1384
+ // provider-authoritative lookup can converge and finalize domain state.
1385
+ await server.commerce.paymentSessions.retrievePortOne({
1386
+ paymentSessionId: portOneSession.id,
1387
+ })
1388
+
1354
1389
  // Toss confirmation is a typed server-only adapter action. There is no generic
1355
1390
  // `confirmVerified` or provider-paid Order creation escape hatch.
1356
1391
  const confirmationIdempotencyKey = createCommerceIdempotencyKey()
@@ -1396,6 +1431,12 @@ const customSession = await server.commerce.paymentSessions.custom.create({
1396
1431
  idempotencyKey: createCommerceIdempotencyKey(),
1397
1432
  })
1398
1433
 
1434
+ // A recovery path can resolve the custom session without a 01 session ID.
1435
+ const pending = await server.commerce.paymentSessions.custom.retrieve({
1436
+ provider: customSession.provider,
1437
+ by: { providerSessionId: customSession.providerSessionId },
1438
+ })
1439
+
1399
1440
  const verifiedCapture = await verifyMyProviderCapture({
1400
1441
  expectedAmount: customSession.money.amountMinor,
1401
1442
  expectedCurrency: customSession.money.currency,
@@ -1416,8 +1457,22 @@ const customConfirmation = await server.commerce.paymentSessions.custom.confirm(
1416
1457
  )
1417
1458
 
1418
1459
  console.log(customConfirmation.orderId)
1460
+
1461
+ const recovered = await server.commerce.paymentSessions.custom.retrieve({
1462
+ provider: customSession.provider,
1463
+ by: { providerPaymentId: verifiedCapture.paymentId },
1464
+ })
1465
+ if (recovered.finalizationStatus === 'committed') {
1466
+ console.log(recovered.orderId)
1467
+ }
1419
1468
  ```
1420
1469
 
1470
+ `custom.retrieve` is an exact lookup by either `providerSessionId` or
1471
+ `providerPaymentId` (exactly one). It returns only bounded recovery state:
1472
+ provider identity, session/provider/finalization status, Money, and the resolved
1473
+ `orderId`. It does not list sessions or expose raw PaymentSession relations,
1474
+ provider evidence, credentials, or fingerprints.
1475
+
1421
1476
  If the tenant's custom-provider policy requires HMAC, pass
1422
1477
  `{ createProof(rawBody) }` as the second argument to `custom.confirm`. The
1423
1478
  callback receives the exact JSON bytes the SDK sends and returns `{ timestamp,
@@ -1693,6 +1748,25 @@ replacement API. Pass an empty list to clear codes. Singular `admission`,
1693
1748
  Browser `mine()`/`merge({ guestCartToken })` derive customer identity from the
1694
1749
  JWT; server calls require an explicit `customerToken`.
1695
1750
 
1751
+ ### Community public reads
1752
+
1753
+ Use the shaped `community` helpers for browser/customer community screens. A
1754
+ publishable key is sufficient for list and detail reads; a customer JWT may be
1755
+ attached for the same response shape, but no secret key is needed.
1756
+
1757
+ ```typescript
1758
+ const page = await client.community.listPosts({ limit: 20 })
1759
+ const post = await client.community.getPost({ postId: page.docs[0].id })
1760
+
1761
+ if (!post) {
1762
+ // Missing, hidden, and cross-tenant posts are intentionally indistinguishable.
1763
+ }
1764
+ ```
1765
+
1766
+ `getPost()` returns the allowlisted `CommunityPost` DTO and resolves `404
1767
+ not_found` to `null`. Raw `client.collections.from('posts')` remains
1768
+ server-only; do not use it in browser or customer template code.
1769
+
1696
1770
  ### Community Moderation (ServerClient-only)
1697
1771
 
1698
1772
  Available only on ServerClient via `server.community.moderation.*`.
@@ -1802,7 +1876,7 @@ Source of truth: `packages/published/sdk/src/core/collection/const.ts` (`COLLECT
1802
1876
 
1803
1877
  | Category | Browser-public generic collections |
1804
1878
  | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
1805
- | Tenant | `tenants`, `tenant-metadata` |
1879
+ | Tenant | `tenant-metadata` |
1806
1880
  | Products | `products`, `product-variants`, `product-options`, `product-option-values`, `product-categories`, `product-tags`, `product-collections`, `markets`, `brands` |
1807
1881
  | Customers | `customer-profiles` |
1808
1882
  | Commerce | `discounts`, `shipping-policies`, `shipping-zones` |