@proveanything/smartlinks 2.1.40 → 2.1.41

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 (104) 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/collection.d.ts +8 -1
  5. package/dist/api/collection.js +10 -0
  6. package/dist/baseline.css +194 -194
  7. package/dist/docs/API_SUMMARY.md +863 -835
  8. package/dist/docs/admin-cards.md +189 -189
  9. package/dist/docs/agent-tools.md +156 -156
  10. package/dist/docs/ai-tools-and-skills.md +180 -180
  11. package/dist/docs/ai.md +1721 -1721
  12. package/dist/docs/analytics.md +39 -39
  13. package/dist/docs/app-data-storage.md +277 -277
  14. package/dist/docs/app-docs.md +73 -73
  15. package/dist/docs/app-manifest.md +852 -852
  16. package/dist/docs/app-records-pattern.md +388 -388
  17. package/dist/docs/appConfig.md +550 -550
  18. package/dist/docs/assistant-apps.md +172 -172
  19. package/dist/docs/assistant-context.md +119 -119
  20. package/dist/docs/bookings.md +442 -442
  21. package/dist/docs/comms.md +686 -686
  22. package/dist/docs/connectors.md +340 -340
  23. package/dist/docs/css-baseline.md +133 -133
  24. package/dist/docs/customer-guide.md +70 -70
  25. package/dist/docs/deploying-apps.md +340 -340
  26. package/dist/docs/entitlements.md +90 -90
  27. package/dist/docs/files.md +69 -69
  28. package/dist/docs/host-dependency-contract.md +210 -210
  29. package/dist/docs/integrations.md +322 -322
  30. package/dist/docs/interactions.md +545 -545
  31. package/dist/docs/item-context.md +181 -181
  32. package/dist/docs/knowledge.md +102 -102
  33. package/dist/docs/lots.md +111 -111
  34. package/dist/docs/loyalty.md +352 -352
  35. package/dist/docs/members.md +182 -182
  36. package/dist/docs/mobile-admin-container.md +693 -693
  37. package/dist/docs/operations.md +281 -281
  38. package/dist/docs/overview.md +482 -482
  39. package/dist/docs/proof-comms-triggers.md +142 -142
  40. package/dist/docs/proof-ownership-transfer.md +155 -155
  41. package/dist/docs/proof-product-data-scoping.md +462 -462
  42. package/dist/docs/proof-share-grants.md +305 -305
  43. package/dist/docs/realtime.md +138 -138
  44. package/dist/docs/records-admin-pattern.md +304 -304
  45. package/dist/docs/standard-query.md +187 -187
  46. package/dist/docs/tag-codes.md +97 -97
  47. package/dist/docs/theme-tokens.md +252 -252
  48. package/dist/docs/wallet-passes.md +107 -107
  49. package/dist/docs/websites.md +123 -123
  50. package/dist/openapi.yaml +80 -3
  51. package/dist/theme-boot.js +78 -78
  52. package/dist/theme.css +75 -75
  53. package/dist/types/appManifest.d.ts +21 -0
  54. package/dist/types/collection.d.ts +26 -0
  55. package/docs/API_SUMMARY.md +863 -835
  56. package/docs/admin-cards.md +189 -189
  57. package/docs/agent-tools.md +156 -156
  58. package/docs/ai-tools-and-skills.md +180 -180
  59. package/docs/ai.md +1721 -1721
  60. package/docs/analytics.md +39 -39
  61. package/docs/app-data-storage.md +277 -277
  62. package/docs/app-docs.md +73 -73
  63. package/docs/app-manifest.md +852 -852
  64. package/docs/app-records-pattern.md +388 -388
  65. package/docs/appConfig.md +550 -550
  66. package/docs/assistant-apps.md +172 -172
  67. package/docs/assistant-context.md +119 -119
  68. package/docs/bookings.md +442 -442
  69. package/docs/comms.md +686 -686
  70. package/docs/connectors.md +340 -340
  71. package/docs/css-baseline.md +133 -133
  72. package/docs/customer-guide.md +70 -70
  73. package/docs/deploying-apps.md +340 -340
  74. package/docs/entitlements.md +90 -90
  75. package/docs/files.md +69 -69
  76. package/docs/host-dependency-contract.md +210 -210
  77. package/docs/integrations.md +322 -322
  78. package/docs/interactions.md +545 -545
  79. package/docs/item-context.md +181 -181
  80. package/docs/knowledge.md +102 -102
  81. package/docs/lots.md +111 -111
  82. package/docs/loyalty.md +352 -352
  83. package/docs/members.md +182 -182
  84. package/docs/mobile-admin-container.md +693 -693
  85. package/docs/operations.md +281 -281
  86. package/docs/overview.md +482 -482
  87. package/docs/proof-comms-triggers.md +142 -142
  88. package/docs/proof-ownership-transfer.md +155 -155
  89. package/docs/proof-product-data-scoping.md +462 -462
  90. package/docs/proof-share-grants.md +305 -305
  91. package/docs/realtime.md +138 -138
  92. package/docs/standard-query.md +187 -187
  93. package/docs/tag-codes.md +97 -97
  94. package/docs/theme-lookbook.v1.json +120 -120
  95. package/docs/theme-tokens.md +252 -252
  96. package/docs/wallet-passes.md +107 -107
  97. package/docs/websites.md +123 -123
  98. package/openapi.yaml +80 -3
  99. package/package.json +87 -87
  100. package/scripts/headless-check.mjs +87 -87
  101. package/scripts/lib/bare-imports.mjs +57 -57
  102. package/scripts/lib/keyed-app-data.mjs +21 -21
  103. package/scripts/publish.mjs +272 -272
  104. package/scripts/register-release.mjs +91 -91
package/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`).