@proveanything/smartlinks 2.1.47 → 2.2.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 (133) 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/api/dpp.d.ts +6 -0
  5. package/dist/api/dpp.js +12 -0
  6. package/dist/api/shop.d.ts +5 -1
  7. package/dist/api/shop.js +7 -7
  8. package/dist/api/subscriptions.d.ts +2 -1
  9. package/dist/api/subscriptions.js +4 -12
  10. package/dist/apiVersion.d.ts +9 -0
  11. package/dist/apiVersion.js +15 -0
  12. package/dist/baseline.css +194 -194
  13. package/dist/docs/API_SUMMARY.md +821 -811
  14. package/dist/docs/admin-cards.md +189 -189
  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/api-versions.md +76 -0
  20. package/dist/docs/app-data-storage.md +277 -277
  21. package/dist/docs/app-docs.md +73 -73
  22. package/dist/docs/app-manifest.md +852 -852
  23. package/dist/docs/app-records-pattern.md +388 -388
  24. package/dist/docs/appConfig.md +550 -550
  25. package/dist/docs/assistant-apps.md +172 -172
  26. package/dist/docs/assistant-context.md +119 -119
  27. package/dist/docs/bookings.md +442 -442
  28. package/dist/docs/comms.md +686 -686
  29. package/dist/docs/connectors.md +340 -340
  30. package/dist/docs/css-baseline.md +133 -133
  31. package/dist/docs/customer-guide.md +70 -70
  32. package/dist/docs/deploying-apps.md +340 -340
  33. package/dist/docs/dpp.md +115 -99
  34. package/dist/docs/entitlements.md +90 -90
  35. package/dist/docs/files.md +69 -69
  36. package/dist/docs/host-dependency-contract.md +210 -210
  37. package/dist/docs/i18n.md +46 -292
  38. package/dist/docs/integrations.md +322 -322
  39. package/dist/docs/interactions.md +545 -545
  40. package/dist/docs/item-context.md +181 -181
  41. package/dist/docs/knowledge.md +102 -102
  42. package/dist/docs/lots.md +111 -111
  43. package/dist/docs/loyalty.md +352 -352
  44. package/dist/docs/members.md +183 -183
  45. package/dist/docs/memberships.md +149 -149
  46. package/dist/docs/mobile-admin-container.md +693 -693
  47. package/dist/docs/operations.md +281 -281
  48. package/dist/docs/overview.md +485 -485
  49. package/dist/docs/proof-comms-triggers.md +142 -142
  50. package/dist/docs/proof-ownership-transfer.md +155 -155
  51. package/dist/docs/proof-product-data-scoping.md +462 -462
  52. package/dist/docs/proof-share-grants.md +305 -305
  53. package/dist/docs/realtime.md +138 -138
  54. package/dist/docs/records-admin-pattern.md +304 -304
  55. package/dist/docs/server-functions.md +1 -1
  56. package/dist/docs/service-accounts.md +64 -64
  57. package/dist/docs/standard-query.md +187 -187
  58. package/dist/docs/tag-codes.md +97 -97
  59. package/dist/docs/theme-tokens.md +252 -252
  60. package/dist/docs/wallet-passes.md +107 -107
  61. package/dist/docs/websites.md +123 -123
  62. package/dist/http.d.ts +14 -0
  63. package/dist/http.js +65 -3
  64. package/dist/i18n.d.ts +14 -2
  65. package/dist/i18n.js +23 -6
  66. package/dist/index.d.ts +2 -1
  67. package/dist/index.js +3 -1
  68. package/dist/openapi.yaml +6 -3
  69. package/dist/theme-boot.js +82 -82
  70. package/dist/theme.css +75 -75
  71. package/dist/types/dpp.d.ts +14 -5
  72. package/dist/utils/index.d.ts +1 -0
  73. package/dist/utils/index.js +1 -0
  74. package/dist/utils/money.d.ts +15 -0
  75. package/dist/utils/money.js +72 -0
  76. package/dist/version.d.ts +1 -0
  77. package/dist/version.js +2 -0
  78. package/docs/API_SUMMARY.md +821 -811
  79. package/docs/admin-cards.md +189 -189
  80. package/docs/agent-tools.md +156 -156
  81. package/docs/ai-tools-and-skills.md +180 -180
  82. package/docs/ai.md +1721 -1721
  83. package/docs/analytics.md +39 -39
  84. package/docs/api-versions.md +76 -0
  85. package/docs/app-data-storage.md +277 -277
  86. package/docs/app-docs.md +73 -73
  87. package/docs/app-manifest.md +852 -852
  88. package/docs/app-records-pattern.md +388 -388
  89. package/docs/appConfig.md +550 -550
  90. package/docs/assistant-apps.md +172 -172
  91. package/docs/assistant-context.md +119 -119
  92. package/docs/bookings.md +442 -442
  93. package/docs/comms.md +686 -686
  94. package/docs/connectors.md +340 -340
  95. package/docs/css-baseline.md +133 -133
  96. package/docs/customer-guide.md +70 -70
  97. package/docs/deploying-apps.md +340 -340
  98. package/docs/dpp.md +115 -99
  99. package/docs/entitlements.md +90 -90
  100. package/docs/files.md +69 -69
  101. package/docs/host-dependency-contract.md +210 -210
  102. package/docs/i18n.md +46 -292
  103. package/docs/integrations.md +322 -322
  104. package/docs/interactions.md +545 -545
  105. package/docs/item-context.md +181 -181
  106. package/docs/knowledge.md +102 -102
  107. package/docs/lots.md +111 -111
  108. package/docs/loyalty.md +352 -352
  109. package/docs/members.md +183 -183
  110. package/docs/memberships.md +149 -149
  111. package/docs/mobile-admin-container.md +693 -693
  112. package/docs/operations.md +281 -281
  113. package/docs/overview.md +485 -485
  114. package/docs/proof-comms-triggers.md +142 -142
  115. package/docs/proof-ownership-transfer.md +155 -155
  116. package/docs/proof-product-data-scoping.md +462 -462
  117. package/docs/proof-share-grants.md +305 -305
  118. package/docs/realtime.md +138 -138
  119. package/docs/server-functions.md +1 -1
  120. package/docs/service-accounts.md +64 -64
  121. package/docs/standard-query.md +187 -187
  122. package/docs/tag-codes.md +97 -97
  123. package/docs/theme-lookbook.v1.json +120 -120
  124. package/docs/theme-tokens.md +252 -252
  125. package/docs/wallet-passes.md +107 -107
  126. package/docs/websites.md +123 -123
  127. package/openapi.yaml +6 -3
  128. package/package.json +87 -87
  129. package/scripts/headless-check.mjs +87 -87
  130. package/scripts/lib/bare-imports.mjs +57 -57
  131. package/scripts/lib/keyed-app-data.mjs +21 -21
  132. package/scripts/publish.mjs +272 -272
  133. 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`).