@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.
- package/README.md +754 -754
- package/dist/README.md +573 -573
- package/dist/adminCardsView.js +55 -55
- package/dist/api/collection.d.ts +8 -1
- package/dist/api/collection.js +10 -0
- package/dist/baseline.css +194 -194
- package/dist/docs/API_SUMMARY.md +863 -835
- package/dist/docs/admin-cards.md +189 -189
- package/dist/docs/agent-tools.md +156 -156
- package/dist/docs/ai-tools-and-skills.md +180 -180
- package/dist/docs/ai.md +1721 -1721
- package/dist/docs/analytics.md +39 -39
- package/dist/docs/app-data-storage.md +277 -277
- package/dist/docs/app-docs.md +73 -73
- package/dist/docs/app-manifest.md +852 -852
- package/dist/docs/app-records-pattern.md +388 -388
- package/dist/docs/appConfig.md +550 -550
- package/dist/docs/assistant-apps.md +172 -172
- package/dist/docs/assistant-context.md +119 -119
- package/dist/docs/bookings.md +442 -442
- package/dist/docs/comms.md +686 -686
- package/dist/docs/connectors.md +340 -340
- package/dist/docs/css-baseline.md +133 -133
- package/dist/docs/customer-guide.md +70 -70
- package/dist/docs/deploying-apps.md +340 -340
- package/dist/docs/entitlements.md +90 -90
- package/dist/docs/files.md +69 -69
- package/dist/docs/host-dependency-contract.md +210 -210
- package/dist/docs/integrations.md +322 -322
- package/dist/docs/interactions.md +545 -545
- package/dist/docs/item-context.md +181 -181
- package/dist/docs/knowledge.md +102 -102
- package/dist/docs/lots.md +111 -111
- package/dist/docs/loyalty.md +352 -352
- package/dist/docs/members.md +182 -182
- package/dist/docs/mobile-admin-container.md +693 -693
- package/dist/docs/operations.md +281 -281
- package/dist/docs/overview.md +482 -482
- package/dist/docs/proof-comms-triggers.md +142 -142
- package/dist/docs/proof-ownership-transfer.md +155 -155
- package/dist/docs/proof-product-data-scoping.md +462 -462
- package/dist/docs/proof-share-grants.md +305 -305
- package/dist/docs/realtime.md +138 -138
- package/dist/docs/records-admin-pattern.md +304 -304
- package/dist/docs/standard-query.md +187 -187
- package/dist/docs/tag-codes.md +97 -97
- package/dist/docs/theme-tokens.md +252 -252
- package/dist/docs/wallet-passes.md +107 -107
- package/dist/docs/websites.md +123 -123
- package/dist/openapi.yaml +80 -3
- package/dist/theme-boot.js +78 -78
- package/dist/theme.css +75 -75
- package/dist/types/appManifest.d.ts +21 -0
- package/dist/types/collection.d.ts +26 -0
- package/docs/API_SUMMARY.md +863 -835
- package/docs/admin-cards.md +189 -189
- package/docs/agent-tools.md +156 -156
- package/docs/ai-tools-and-skills.md +180 -180
- package/docs/ai.md +1721 -1721
- package/docs/analytics.md +39 -39
- package/docs/app-data-storage.md +277 -277
- package/docs/app-docs.md +73 -73
- package/docs/app-manifest.md +852 -852
- package/docs/app-records-pattern.md +388 -388
- package/docs/appConfig.md +550 -550
- package/docs/assistant-apps.md +172 -172
- package/docs/assistant-context.md +119 -119
- package/docs/bookings.md +442 -442
- package/docs/comms.md +686 -686
- package/docs/connectors.md +340 -340
- package/docs/css-baseline.md +133 -133
- package/docs/customer-guide.md +70 -70
- package/docs/deploying-apps.md +340 -340
- package/docs/entitlements.md +90 -90
- package/docs/files.md +69 -69
- package/docs/host-dependency-contract.md +210 -210
- package/docs/integrations.md +322 -322
- package/docs/interactions.md +545 -545
- package/docs/item-context.md +181 -181
- package/docs/knowledge.md +102 -102
- package/docs/lots.md +111 -111
- package/docs/loyalty.md +352 -352
- package/docs/members.md +182 -182
- package/docs/mobile-admin-container.md +693 -693
- package/docs/operations.md +281 -281
- package/docs/overview.md +482 -482
- package/docs/proof-comms-triggers.md +142 -142
- package/docs/proof-ownership-transfer.md +155 -155
- package/docs/proof-product-data-scoping.md +462 -462
- package/docs/proof-share-grants.md +305 -305
- package/docs/realtime.md +138 -138
- package/docs/standard-query.md +187 -187
- package/docs/tag-codes.md +97 -97
- package/docs/theme-lookbook.v1.json +120 -120
- package/docs/theme-tokens.md +252 -252
- package/docs/wallet-passes.md +107 -107
- package/docs/websites.md +123 -123
- package/openapi.yaml +80 -3
- package/package.json +87 -87
- package/scripts/headless-check.mjs +87 -87
- package/scripts/lib/bare-imports.mjs +57 -57
- package/scripts/lib/keyed-app-data.mjs +21 -21
- package/scripts/publish.mjs +272 -272
- 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`).
|