@proveanything/smartlinks 2.1.41 → 2.1.43

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 (122) hide show
  1. package/README.md +754 -754
  2. package/dist/README.md +573 -573
  3. package/dist/adminCardsView.js +55 -55
  4. package/dist/adminViews.js +1 -1
  5. package/dist/api/index.d.ts +1 -0
  6. package/dist/api/index.js +1 -0
  7. package/dist/api/product.d.ts +2 -1
  8. package/dist/api/product.js +2 -1
  9. package/dist/api/subscriptions.d.ts +97 -0
  10. package/dist/api/subscriptions.js +178 -0
  11. package/dist/baseline.css +194 -194
  12. package/dist/docs/API_SUMMARY.md +1135 -832
  13. package/dist/docs/admin-cards.md +189 -189
  14. package/dist/docs/admin-views.md +9 -4
  15. package/dist/docs/agent-tools.md +156 -156
  16. package/dist/docs/ai-tools-and-skills.md +180 -180
  17. package/dist/docs/ai.md +1721 -1721
  18. package/dist/docs/analytics.md +39 -39
  19. package/dist/docs/app-data-storage.md +277 -277
  20. package/dist/docs/app-docs.md +73 -73
  21. package/dist/docs/app-manifest.md +852 -852
  22. package/dist/docs/app-records-pattern.md +388 -388
  23. package/dist/docs/appConfig.md +550 -550
  24. package/dist/docs/assistant-apps.md +172 -172
  25. package/dist/docs/assistant-context.md +119 -119
  26. package/dist/docs/bookings.md +442 -442
  27. package/dist/docs/comms.md +686 -686
  28. package/dist/docs/connectors.md +340 -340
  29. package/dist/docs/css-baseline.md +133 -133
  30. package/dist/docs/customer-guide.md +70 -70
  31. package/dist/docs/deploying-apps.md +340 -340
  32. package/dist/docs/entitlements.md +90 -90
  33. package/dist/docs/files.md +69 -69
  34. package/dist/docs/host-dependency-contract.md +210 -210
  35. package/dist/docs/i18n.md +9 -0
  36. package/dist/docs/integrations.md +322 -322
  37. package/dist/docs/interactions.md +545 -545
  38. package/dist/docs/item-context.md +181 -181
  39. package/dist/docs/knowledge.md +102 -102
  40. package/dist/docs/lots.md +111 -111
  41. package/dist/docs/loyalty.md +352 -352
  42. package/dist/docs/members.md +183 -182
  43. package/dist/docs/memberships.md +149 -0
  44. package/dist/docs/mobile-admin-container.md +693 -693
  45. package/dist/docs/operations.md +281 -281
  46. package/dist/docs/overview.md +483 -482
  47. package/dist/docs/proof-comms-triggers.md +142 -142
  48. package/dist/docs/proof-ownership-transfer.md +155 -155
  49. package/dist/docs/proof-product-data-scoping.md +462 -462
  50. package/dist/docs/proof-share-grants.md +305 -305
  51. package/dist/docs/realtime.md +138 -138
  52. package/dist/docs/records-admin-pattern.md +304 -304
  53. package/dist/docs/server-functions.md +1 -0
  54. package/dist/docs/standard-query.md +187 -187
  55. package/dist/docs/tag-codes.md +97 -97
  56. package/dist/docs/theme-tokens.md +252 -252
  57. package/dist/docs/wallet-passes.md +107 -107
  58. package/dist/docs/websites.md +123 -123
  59. package/dist/i18n.d.ts +6 -0
  60. package/dist/i18n.js +10 -0
  61. package/dist/openapi.yaml +426 -3
  62. package/dist/theme-boot.js +82 -78
  63. package/dist/theme.css +75 -75
  64. package/dist/types/appManifest.d.ts +32 -0
  65. package/dist/types/index.d.ts +1 -0
  66. package/dist/types/index.js +1 -0
  67. package/dist/types/subscriptions.d.ts +195 -0
  68. package/dist/types/subscriptions.js +9 -0
  69. package/docs/API_SUMMARY.md +1135 -832
  70. package/docs/admin-cards.md +189 -189
  71. package/docs/admin-views.md +9 -4
  72. package/docs/agent-tools.md +156 -156
  73. package/docs/ai-tools-and-skills.md +180 -180
  74. package/docs/ai.md +1721 -1721
  75. package/docs/analytics.md +39 -39
  76. package/docs/app-data-storage.md +277 -277
  77. package/docs/app-docs.md +73 -73
  78. package/docs/app-manifest.md +852 -852
  79. package/docs/app-records-pattern.md +388 -388
  80. package/docs/appConfig.md +550 -550
  81. package/docs/assistant-apps.md +172 -172
  82. package/docs/assistant-context.md +119 -119
  83. package/docs/bookings.md +442 -442
  84. package/docs/comms.md +686 -686
  85. package/docs/connectors.md +340 -340
  86. package/docs/css-baseline.md +133 -133
  87. package/docs/customer-guide.md +70 -70
  88. package/docs/deploying-apps.md +340 -340
  89. package/docs/entitlements.md +90 -90
  90. package/docs/files.md +69 -69
  91. package/docs/host-dependency-contract.md +210 -210
  92. package/docs/i18n.md +9 -0
  93. package/docs/integrations.md +322 -322
  94. package/docs/interactions.md +545 -545
  95. package/docs/item-context.md +181 -181
  96. package/docs/knowledge.md +102 -102
  97. package/docs/lots.md +111 -111
  98. package/docs/loyalty.md +352 -352
  99. package/docs/members.md +183 -182
  100. package/docs/memberships.md +149 -0
  101. package/docs/mobile-admin-container.md +693 -693
  102. package/docs/operations.md +281 -281
  103. package/docs/overview.md +483 -482
  104. package/docs/proof-comms-triggers.md +142 -142
  105. package/docs/proof-ownership-transfer.md +155 -155
  106. package/docs/proof-product-data-scoping.md +462 -462
  107. package/docs/proof-share-grants.md +305 -305
  108. package/docs/realtime.md +138 -138
  109. package/docs/server-functions.md +1 -0
  110. package/docs/standard-query.md +187 -187
  111. package/docs/tag-codes.md +97 -97
  112. package/docs/theme-lookbook.v1.json +120 -120
  113. package/docs/theme-tokens.md +252 -252
  114. package/docs/wallet-passes.md +107 -107
  115. package/docs/websites.md +123 -123
  116. package/openapi.yaml +426 -3
  117. package/package.json +87 -87
  118. package/scripts/headless-check.mjs +87 -87
  119. package/scripts/lib/bare-imports.mjs +57 -57
  120. package/scripts/lib/keyed-app-data.mjs +21 -21
  121. package/scripts/publish.mjs +272 -272
  122. package/scripts/register-release.mjs +91 -91
package/dist/docs/lots.md CHANGED
@@ -1,111 +1,111 @@
1
- # Lots
2
-
3
- A **Lot** is a collection-scoped production grouping that spans one or more products
4
- (SKUs) — a single identifier applied across many SKUs and/or many production runs. It's
5
- the right tool when a manufacturer wants one lot number (e.g. `LOT-2026-09`) across a whole
6
- range, rather than a per-product **batch** (a single run of a single product).
7
-
8
- Lots are a first-class entity (not app records): cross-app readable, admin-written, with a
9
- real lifecycle. They are **never fanned out into batches** — the lot is the single source of
10
- truth for its shared data.
11
-
12
- ---
13
-
14
- ## Concepts
15
-
16
- - **Selector** — how member products are matched. Two modes:
17
- - `{ mode: 'facets', rules: [{ key, values }] }` — AND across rules, OR within a rule's values (resolved against the facet index, so it scales to thousands of SKUs).
18
- - `{ mode: 'products', productIds: [...] }` — an explicit list.
19
- - **`productIds` / `productCount`** — the materialised snapshot of resolved members (re-resolved on create, on selector change, and on demand via `resolve`).
20
- - **`payload`** — shared lot data (dates, supplier ref, custom fields). Lives only on the lot.
21
- - **`status`** — `open` → `closed` → `recalled` → `archived`. A live lifecycle state, distinct from deletion.
22
- - **`destination`** — optional lot-level redirect; wins over the product's on a lot-scoped scan.
23
-
24
- ### Archive vs delete
25
-
26
- Two separate ideas — mirroring the platform's `deletedAt` convention:
27
-
28
- | | `archive` (`status: 'archived'`) | `remove` (soft-delete, `deletedAt`) |
29
- |---|---|---|
30
- | Record | stays **live** & visible | **hidden** from reads unless `includeDeleted: true` |
31
- | `lotNumber` | **stays reserved** | **freed** for reuse by a new lot |
32
- | AI(10) scan | not resolved (excluded) | not resolved |
33
- | Reversible | change status back | `restore` (409 if the number was taken by a live lot) |
34
-
35
- Nothing is ever hard-deleted (joins/history stay intact). Use **archive** for "this run is done, keep it around"; use **remove** for "this was a mistake, and I want the number back."
36
-
37
- ---
38
-
39
- ## SDK — `SL.lots.*`
40
-
41
- Writes and admin reads hit `/admin/collection/:cid/lots`; the `public*` reads hit
42
- `/public/collection/:cid/lots` for cross-app consumers (auth is the ambient bearer token —
43
- there's no `admin` flag).
44
-
45
- ```ts
46
- import { lots } from '@proveanything/smartlinks'
47
-
48
- // Create — facet-targeted lot
49
- const lot = await lots.create(collectionId, {
50
- lotNumber: 'LOT-2026-09',
51
- name: 'September Oak run',
52
- selector: { mode: 'facets', rules: [
53
- { key: 'supplier', values: ['Acme Timber'] },
54
- { key: 'range', values: ['Oslo', 'Bergen'] },
55
- ]},
56
- payload: { manufacturedAt: '2026-09-01', custom: { supplierBatchRef: 'ACM-7741' } },
57
- })
58
-
59
- const list = await lots.list(collectionId, { status: 'open' })
60
- const byId = await lots.get(collectionId, lot.id)
61
- const byNumber = await lots.getByNumber(collectionId, 'LOT-2026-09') // case-insensitive
62
- const containing = await lots.list(collectionId, { productId: 'prd_abc' }) // reverse lookup
63
- const updated = await lots.update(collectionId, lot.id, { status: 'closed' })
64
- const { diff } = await lots.resolve(collectionId, lot.id) // { added, removed }
65
- const members = await lots.listProducts(collectionId, lot.id, { page: 1, limit: 50 })
66
-
67
- await lots.archive(collectionId, lot.id) // live, keeps its number
68
- await lots.remove(collectionId, lot.id) // soft-delete, frees the number
69
- const withDeleted = await lots.list(collectionId, { includeDeleted: true })
70
- const restored = await lots.restore(collectionId, lot.id) // undo a soft-delete
71
-
72
- // Cross-app reads
73
- const publicLots = await lots.publicList(collectionId)
74
- ```
75
-
76
- Exported types: `Lot`, `LotStatus`, `LotSelector`, `LotPayload`, `LotCreateInput`,
77
- `LotUpdateInput`, `ListLotsParams`, `ResolveLotResponse`, `ListLotProductsResponse`,
78
- `LotResolutionResult`.
79
-
80
- ---
81
-
82
- ## GS1 Digital Link resolution — AI(10)
83
-
84
- GS1 gives batch and lot a **single** slot: AI(10) ("Batch or Lot Number"), in a Digital Link
85
- as `/01/{gtin}/10/{value}`. A physical code carries exactly one value there, so the server
86
- decides which namespace it belongs to, driven by two **feature flags** — `batches` and `lots`
87
- — in the platform feature-flag system (`appConfig.system.features`), resolved the standard way
88
- (`appConfiguration.isFeatureEnabled(collectionId, 'lots')`):
89
-
90
- - Explicit `true`/`false` in `system.features` wins; otherwise **enterprise** accounts default
91
- a flag on and everyone else defaults off. So AI(10) batch/lot resolution is opt-in — no
92
- existing scan changes until `batches`/`lots` is enabled for the collection.
93
-
94
- Resolution order — **batch first, then lot** (a hierarchy, not a collision):
95
-
96
- 1. **Batch** is the narrowest scope (one product). If the scanned product has a batch whose id
97
- or name matches the AI(10) value, it wins — a batch is a **specific-SKU override**.
98
- 2. **Lot** is broad (many products). If no batch matches and the value is a lot number *and the
99
- scanned product is a member*, the lot resolves.
100
- 3. Otherwise it resolves at the product level.
101
-
102
- This means a range can share one lot code, and a single SKU can be given richer/overriding
103
- detail by creating a batch with the **same** identifier — the batch simply takes precedence for
104
- that SKU. A recalled lot (`status: 'recalled'`) still resolves so the destination page can show
105
- a recall notice (a `&recall=1` context param is added).
106
-
107
- The server returns a typed shape ({@link LotResolutionResult}); the front end renders it — clients
108
- should not implement their own fallback.
109
-
110
- See also [proof-product-data-scoping.md](proof-product-data-scoping.md) and the GS1 link
111
- generator in [utils.md](utils.md) (`buildGs1DigitalLink`).
1
+ # Lots
2
+
3
+ A **Lot** is a collection-scoped production grouping that spans one or more products
4
+ (SKUs) — a single identifier applied across many SKUs and/or many production runs. It's
5
+ the right tool when a manufacturer wants one lot number (e.g. `LOT-2026-09`) across a whole
6
+ range, rather than a per-product **batch** (a single run of a single product).
7
+
8
+ Lots are a first-class entity (not app records): cross-app readable, admin-written, with a
9
+ real lifecycle. They are **never fanned out into batches** — the lot is the single source of
10
+ truth for its shared data.
11
+
12
+ ---
13
+
14
+ ## Concepts
15
+
16
+ - **Selector** — how member products are matched. Two modes:
17
+ - `{ mode: 'facets', rules: [{ key, values }] }` — AND across rules, OR within a rule's values (resolved against the facet index, so it scales to thousands of SKUs).
18
+ - `{ mode: 'products', productIds: [...] }` — an explicit list.
19
+ - **`productIds` / `productCount`** — the materialised snapshot of resolved members (re-resolved on create, on selector change, and on demand via `resolve`).
20
+ - **`payload`** — shared lot data (dates, supplier ref, custom fields). Lives only on the lot.
21
+ - **`status`** — `open` → `closed` → `recalled` → `archived`. A live lifecycle state, distinct from deletion.
22
+ - **`destination`** — optional lot-level redirect; wins over the product's on a lot-scoped scan.
23
+
24
+ ### Archive vs delete
25
+
26
+ Two separate ideas — mirroring the platform's `deletedAt` convention:
27
+
28
+ | | `archive` (`status: 'archived'`) | `remove` (soft-delete, `deletedAt`) |
29
+ |---|---|---|
30
+ | Record | stays **live** & visible | **hidden** from reads unless `includeDeleted: true` |
31
+ | `lotNumber` | **stays reserved** | **freed** for reuse by a new lot |
32
+ | AI(10) scan | not resolved (excluded) | not resolved |
33
+ | Reversible | change status back | `restore` (409 if the number was taken by a live lot) |
34
+
35
+ Nothing is ever hard-deleted (joins/history stay intact). Use **archive** for "this run is done, keep it around"; use **remove** for "this was a mistake, and I want the number back."
36
+
37
+ ---
38
+
39
+ ## SDK — `SL.lots.*`
40
+
41
+ Writes and admin reads hit `/admin/collection/:cid/lots`; the `public*` reads hit
42
+ `/public/collection/:cid/lots` for cross-app consumers (auth is the ambient bearer token —
43
+ there's no `admin` flag).
44
+
45
+ ```ts
46
+ import { lots } from '@proveanything/smartlinks'
47
+
48
+ // Create — facet-targeted lot
49
+ const lot = await lots.create(collectionId, {
50
+ lotNumber: 'LOT-2026-09',
51
+ name: 'September Oak run',
52
+ selector: { mode: 'facets', rules: [
53
+ { key: 'supplier', values: ['Acme Timber'] },
54
+ { key: 'range', values: ['Oslo', 'Bergen'] },
55
+ ]},
56
+ payload: { manufacturedAt: '2026-09-01', custom: { supplierBatchRef: 'ACM-7741' } },
57
+ })
58
+
59
+ const list = await lots.list(collectionId, { status: 'open' })
60
+ const byId = await lots.get(collectionId, lot.id)
61
+ const byNumber = await lots.getByNumber(collectionId, 'LOT-2026-09') // case-insensitive
62
+ const containing = await lots.list(collectionId, { productId: 'prd_abc' }) // reverse lookup
63
+ const updated = await lots.update(collectionId, lot.id, { status: 'closed' })
64
+ const { diff } = await lots.resolve(collectionId, lot.id) // { added, removed }
65
+ const members = await lots.listProducts(collectionId, lot.id, { page: 1, limit: 50 })
66
+
67
+ await lots.archive(collectionId, lot.id) // live, keeps its number
68
+ await lots.remove(collectionId, lot.id) // soft-delete, frees the number
69
+ const withDeleted = await lots.list(collectionId, { includeDeleted: true })
70
+ const restored = await lots.restore(collectionId, lot.id) // undo a soft-delete
71
+
72
+ // Cross-app reads
73
+ const publicLots = await lots.publicList(collectionId)
74
+ ```
75
+
76
+ Exported types: `Lot`, `LotStatus`, `LotSelector`, `LotPayload`, `LotCreateInput`,
77
+ `LotUpdateInput`, `ListLotsParams`, `ResolveLotResponse`, `ListLotProductsResponse`,
78
+ `LotResolutionResult`.
79
+
80
+ ---
81
+
82
+ ## GS1 Digital Link resolution — AI(10)
83
+
84
+ GS1 gives batch and lot a **single** slot: AI(10) ("Batch or Lot Number"), in a Digital Link
85
+ as `/01/{gtin}/10/{value}`. A physical code carries exactly one value there, so the server
86
+ decides which namespace it belongs to, driven by two **feature flags** — `batches` and `lots`
87
+ — in the platform feature-flag system (`appConfig.system.features`), resolved the standard way
88
+ (`appConfiguration.isFeatureEnabled(collectionId, 'lots')`):
89
+
90
+ - Explicit `true`/`false` in `system.features` wins; otherwise **enterprise** accounts default
91
+ a flag on and everyone else defaults off. So AI(10) batch/lot resolution is opt-in — no
92
+ existing scan changes until `batches`/`lots` is enabled for the collection.
93
+
94
+ Resolution order — **batch first, then lot** (a hierarchy, not a collision):
95
+
96
+ 1. **Batch** is the narrowest scope (one product). If the scanned product has a batch whose id
97
+ or name matches the AI(10) value, it wins — a batch is a **specific-SKU override**.
98
+ 2. **Lot** is broad (many products). If no batch matches and the value is a lot number *and the
99
+ scanned product is a member*, the lot resolves.
100
+ 3. Otherwise it resolves at the product level.
101
+
102
+ This means a range can share one lot code, and a single SKU can be given richer/overriding
103
+ detail by creating a batch with the **same** identifier — the batch simply takes precedence for
104
+ that SKU. A recalled lot (`status: 'recalled'`) still resolves so the destination page can show
105
+ a recall notice (a `&recall=1` context param is added).
106
+
107
+ The server returns a typed shape ({@link LotResolutionResult}); the front end renders it — clients
108
+ should not implement their own fallback.
109
+
110
+ See also [proof-product-data-scoping.md](proof-product-data-scoping.md) and the GS1 link
111
+ generator in [utils.md](utils.md) (`buildGs1DigitalLink`).