@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
@@ -1,90 +1,90 @@
1
- # Entitlements: "can this person do this?" without a mirror of their member base
2
-
3
- A brand with twenty million members wants a game only Gold members can play. SmartLinks never copies
4
- the member base to find out. A **gate** says what it needs — a predicate such as `tier>=gold` — and the
5
- platform asks the collection's configured **sources**, in order, stopping at the first that answers.
6
- The brand's system stays the record of truth; every answer says where it came from (`basis`) and how
7
- old it is (`asOf`).
8
-
9
- | Source | Data kept here | When it fits |
10
- |---|---|---|
11
- | **claims** | none | the brand's SSO or app issues a short-lived signed token carrying the tier; the caller presents it |
12
- | **lookup** | a hashed key → a small answer, for minutes | the loyalty connector's `lookup` step answers for one person; cached in Valkey under an HMAC of the identity for the TTL the brand sets (default 15 min; "not a member" 5 min); one in-flight lookup per key; the connector's own rate limit applies |
13
- | **contact** | what the contact already holds | `customFields.loyalty` / `loyaltyTier` written by the connector's member webhook (`ctx.sl.members.apply`) |
14
- | **fallback** | — | when nothing answered: `deny` (default), `allow`, or `degrade` (allow, flagged `degraded: true`) |
15
-
16
- Every decision is one structured log line — gate, predicate, allowed, basis, age, an identity **hash**
17
- — and never an identifier. A caller sees `attributes` (tier, points, status, member) and never a member
18
- id.
19
-
20
- ## Predicates
21
-
22
- ```
23
- 'tier>=gold' 'tier=silver' 'tier in gold,platinum' 'points>=500' 'member'
24
- { tier: { gte: 'gold' } } { tier: { in: ['gold', 'platinum'] } } { member: true }
25
- { attribute: { path: 'status', eq: 'active' } }
26
- { all: [p1, p2] } { any: [p1, p2] } { not: p }
27
- ```
28
-
29
- Tier comparisons use the collection's ordered `tiers` list (lowest first); a tier the list doesn't know
30
- never satisfies an ordered comparison. A malformed predicate is a configuration error (`BAD_PREDICATE`),
31
- never a silent denial.
32
-
33
- ## Where gates live
34
-
35
- **An interaction type** — the public submit route checks it; the caller may present a claim:
36
-
37
- ```ts
38
- await SL.interactions.updateInteraction(collectionId, appId, typeId, {
39
- permissions: { allowPublicSubmit: true, requires: { entitlement: 'tier>=gold', fallback: 'deny' } },
40
- })
41
- // A refused submit: 403 { error: 'FORBIDDEN', reason: 'entitlement_denied' }
42
- // With a claim: body.entitlementToken = '<jwt>' or header X-SmartLinks-Entitlement: <jwt>
43
- ```
44
-
45
- **A server function** — for the signed-in caller by default:
46
-
47
- ```ts
48
- const d = await ctx.sl.entitlements.check('tier>=gold') // needs sl:entitlements:read
49
- // → { allowed: true, basis: 'lookup-cache', asOf: '2026-11-08T09:00:00.000Z', attributes: { tier: 'gold', points: 1500, member: true } }
50
- if (!d.allowed) return new Response(JSON.stringify({ error: 'gold_only' }), { status: 403 })
51
- // Someone else, or a presented claim:
52
- await ctx.sl.entitlements.check({ points: { gte: 500 } }, { identity: { email }, token, fallback: 'degrade' })
53
- ```
54
-
55
- ## Configuring a collection
56
-
57
- The `entitlements` setting group (`settings.set(collectionId, 'entitlements', {...})`):
58
-
59
- ```jsonc
60
- {
61
- "sources": ["claims", "lookup", "contact"], // tried in this order
62
- "fallback": "deny",
63
- "tiers": ["bronze", "silver", "gold", "platinum"], // lowest first
64
- "claims": {
65
- "secretRef": "sec_brand_sso", // HS256 shared secret in the secret store …
66
- "publicKeyPem": "-----BEGIN PUBLIC KEY-----…", // … or an RS256 / ES256 public key
67
- "issuer": "https://login.brand.example", "audience": "smartlinks",
68
- "tierClaim": "tier", "memberIdClaim": "sub", "attributesClaim": "entitlements", "maxAgeSec": 900
69
- },
70
- "lookup": {
71
- "connectorAppId": "acme-loyalty", "provider": "acme-loyalty",
72
- "ttlSec": 900, "negativeTtlSec": 300,
73
- "identity": "raw", // what the connector's lookup receives: 'raw' (email/phone) or 'hashed'
74
- "want": ["tier", "points", "status"]
75
- }
76
- }
77
- ```
78
-
79
- The connector side (`lookup`) is one step: one identity in, `{ found, memberId, tier, points, status,
80
- asOf }` out; throw on an outage so the next source is tried — see
81
- [connectors.md](connectors.md#loyalty-and-crm-connectors).
82
-
83
- ## What a brand can be told
84
-
85
- - We never need a copy of your member base: claims and lookups hold nothing, or a minutes-old answer per
86
- active person.
87
- - Where you want a local copy, it holds no identifiers (the HMAC mirror — on request).
88
- - Your system remains the record of truth: every answer carries `asOf` and `basis`; TTLs are yours to set.
89
- - You see every call: the connector's calls are rate-limited, logged, and leave from a fixed egress IP.
90
- - Nothing leaves without a policy: the envelope's identity policy per flow.
1
+ # Entitlements: "can this person do this?" without a mirror of their member base
2
+
3
+ A brand with twenty million members wants a game only Gold members can play. SmartLinks never copies
4
+ the member base to find out. A **gate** says what it needs — a predicate such as `tier>=gold` — and the
5
+ platform asks the collection's configured **sources**, in order, stopping at the first that answers.
6
+ The brand's system stays the record of truth; every answer says where it came from (`basis`) and how
7
+ old it is (`asOf`).
8
+
9
+ | Source | Data kept here | When it fits |
10
+ |---|---|---|
11
+ | **claims** | none | the brand's SSO or app issues a short-lived signed token carrying the tier; the caller presents it |
12
+ | **lookup** | a hashed key → a small answer, for minutes | the loyalty connector's `lookup` step answers for one person; cached in Valkey under an HMAC of the identity for the TTL the brand sets (default 15 min; "not a member" 5 min); one in-flight lookup per key; the connector's own rate limit applies |
13
+ | **contact** | what the contact already holds | `customFields.loyalty` / `loyaltyTier` written by the connector's member webhook (`ctx.sl.members.apply`) |
14
+ | **fallback** | — | when nothing answered: `deny` (default), `allow`, or `degrade` (allow, flagged `degraded: true`) |
15
+
16
+ Every decision is one structured log line — gate, predicate, allowed, basis, age, an identity **hash**
17
+ — and never an identifier. A caller sees `attributes` (tier, points, status, member) and never a member
18
+ id.
19
+
20
+ ## Predicates
21
+
22
+ ```
23
+ 'tier>=gold' 'tier=silver' 'tier in gold,platinum' 'points>=500' 'member'
24
+ { tier: { gte: 'gold' } } { tier: { in: ['gold', 'platinum'] } } { member: true }
25
+ { attribute: { path: 'status', eq: 'active' } }
26
+ { all: [p1, p2] } { any: [p1, p2] } { not: p }
27
+ ```
28
+
29
+ Tier comparisons use the collection's ordered `tiers` list (lowest first); a tier the list doesn't know
30
+ never satisfies an ordered comparison. A malformed predicate is a configuration error (`BAD_PREDICATE`),
31
+ never a silent denial.
32
+
33
+ ## Where gates live
34
+
35
+ **An interaction type** — the public submit route checks it; the caller may present a claim:
36
+
37
+ ```ts
38
+ await SL.interactions.updateInteraction(collectionId, appId, typeId, {
39
+ permissions: { allowPublicSubmit: true, requires: { entitlement: 'tier>=gold', fallback: 'deny' } },
40
+ })
41
+ // A refused submit: 403 { error: 'FORBIDDEN', reason: 'entitlement_denied' }
42
+ // With a claim: body.entitlementToken = '<jwt>' or header X-SmartLinks-Entitlement: <jwt>
43
+ ```
44
+
45
+ **A server function** — for the signed-in caller by default:
46
+
47
+ ```ts
48
+ const d = await ctx.sl.entitlements.check('tier>=gold') // needs sl:entitlements:read
49
+ // → { allowed: true, basis: 'lookup-cache', asOf: '2026-11-08T09:00:00.000Z', attributes: { tier: 'gold', points: 1500, member: true } }
50
+ if (!d.allowed) return new Response(JSON.stringify({ error: 'gold_only' }), { status: 403 })
51
+ // Someone else, or a presented claim:
52
+ await ctx.sl.entitlements.check({ points: { gte: 500 } }, { identity: { email }, token, fallback: 'degrade' })
53
+ ```
54
+
55
+ ## Configuring a collection
56
+
57
+ The `entitlements` setting group (`settings.set(collectionId, 'entitlements', {...})`):
58
+
59
+ ```jsonc
60
+ {
61
+ "sources": ["claims", "lookup", "contact"], // tried in this order
62
+ "fallback": "deny",
63
+ "tiers": ["bronze", "silver", "gold", "platinum"], // lowest first
64
+ "claims": {
65
+ "secretRef": "sec_brand_sso", // HS256 shared secret in the secret store …
66
+ "publicKeyPem": "-----BEGIN PUBLIC KEY-----…", // … or an RS256 / ES256 public key
67
+ "issuer": "https://login.brand.example", "audience": "smartlinks",
68
+ "tierClaim": "tier", "memberIdClaim": "sub", "attributesClaim": "entitlements", "maxAgeSec": 900
69
+ },
70
+ "lookup": {
71
+ "connectorAppId": "acme-loyalty", "provider": "acme-loyalty",
72
+ "ttlSec": 900, "negativeTtlSec": 300,
73
+ "identity": "raw", // what the connector's lookup receives: 'raw' (email/phone) or 'hashed'
74
+ "want": ["tier", "points", "status"]
75
+ }
76
+ }
77
+ ```
78
+
79
+ The connector side (`lookup`) is one step: one identity in, `{ found, memberId, tier, points, status,
80
+ asOf }` out; throw on an outage so the next source is tried — see
81
+ [connectors.md](connectors.md#loyalty-and-crm-connectors).
82
+
83
+ ## What a brand can be told
84
+
85
+ - We never need a copy of your member base: claims and lookups hold nothing, or a minutes-old answer per
86
+ active person.
87
+ - Where you want a local copy, it holds no identifiers (the HMAC mirror — on request).
88
+ - Your system remains the record of truth: every answer carries `asOf` and `basis`; TTLs are yours to set.
89
+ - You see every call: the connector's calls are rate-limited, logged, and leave from a fixed egress IP.
90
+ - Nothing leaves without a policy: the envelope's identity policy per flow.
package/docs/files.md CHANGED
@@ -1,69 +1,69 @@
1
- # Files
2
-
3
- Files are for the things an app or an AI tool needs to hold onto that nobody browses: a supplier's spec sheet fetched
4
- to read product details from, a web page with a recipe, a deck to summarise, an image to read text from, a JSON result
5
- to pass between steps.
6
-
7
- A file is an asset, with three differences:
8
-
9
- - **It can be temporary.** It's removed at `expiresAt` (`ttl` from `1h` to `30d`, default `1d`).
10
- - **It's private** until kept. You read it through `files.read` or a signed link from `files.link`.
11
- - **It stays out of asset lists.** Pickers, the media library, the Hub and the portal never show temporary or
12
- extracted files. `files.keep` makes a file permanent and public (with an `assetUrl`), and it then shows like any
13
- upload.
14
-
15
- ## Fetch once, extract once
16
-
17
- ```typescript
18
- import { files } from '@proveanything/smartlinks'
19
-
20
- // The same address returns the same file while it's fresh; once stale, an unchanged page isn't downloaded again.
21
- const { file } = await files.fetch(collectionId, { url: 'https://supplier.example/spec.pdf', ttl: '7d' })
22
-
23
- // Each file is read each way once: asking again returns the same result (cached: true).
24
- const { text } = await files.extract(collectionId, file.id, { variant: 'markdown' })
25
-
26
- const { data } = await files.extract(collectionId, file.id, {
27
- variant: 'json',
28
- schema: { type: 'object', properties: { gtin: { type: 'string' }, weightKg: { type: 'number' } } },
29
- })
30
- ```
31
-
32
- | Variant | Gives | Works on |
33
- |---|---|---|
34
- | `text` | plain text | PDFs, HTML, text, JSON, and web pages / documents |
35
- | `markdown` | Markdown | web pages, PDFs, decks, documents |
36
- | `ocr` | text read from an image | images |
37
- | `json` | typed fields (`schema` and/or `prompt`) | anything readable |
38
-
39
- What's extracted is kept beside its source as a derived file (`origin: 'derived'`, `derivedFromId`, `variant`) and
40
- lives as long as the source does.
41
-
42
- ## Your own files
43
-
44
- ```typescript
45
- const { file } = await files.put(collectionId, { name: 'notes.json', json: { step: 2 }, ttl: '1d' })
46
- const { text } = await files.read(collectionId, file.id) // or 'base64'
47
- const { url } = await files.link(collectionId, file.id, 15) // a signed link for 15 minutes
48
- await files.keep(collectionId, file.id) // permanent, public, shows in pickers
49
- await files.remove(collectionId, file.id)
50
- const { files: mine } = await files.list(collectionId, { appId: 'my-app', origin: 'fetched' })
51
- ```
52
-
53
- ## In a server function
54
-
55
- The same calls are on `ctx.sl.files` (manifest scopes `sl:files:read` and `sl:files:write`), without the collection
56
- id. AI tools get `file.fetch`, `file.extract` and `file.read`, which hand back file references rather than pasting
57
- whole documents into the conversation.
58
-
59
- ```js
60
- const page = await ctx.sl.files.fetch('https://cook.example/pancakes', { ttl: '7d' })
61
- const { data } = await ctx.sl.files.extract(page.id, 'json', { schema })
62
- ```
63
-
64
- ## Limits
65
-
66
- - Fetching: public web addresses only (checked on every redirect), up to 50 MB.
67
- - Reading contents: up to 25 MB.
68
- - Temporary files per site: 5,000 files or 2 GB at once; past that the oldest temporary files go first. Kept files
69
- aren't capped here.
1
+ # Files
2
+
3
+ Files are for the things an app or an AI tool needs to hold onto that nobody browses: a supplier's spec sheet fetched
4
+ to read product details from, a web page with a recipe, a deck to summarise, an image to read text from, a JSON result
5
+ to pass between steps.
6
+
7
+ A file is an asset, with three differences:
8
+
9
+ - **It can be temporary.** It's removed at `expiresAt` (`ttl` from `1h` to `30d`, default `1d`).
10
+ - **It's private** until kept. You read it through `files.read` or a signed link from `files.link`.
11
+ - **It stays out of asset lists.** Pickers, the media library, the Hub and the portal never show temporary or
12
+ extracted files. `files.keep` makes a file permanent and public (with an `assetUrl`), and it then shows like any
13
+ upload.
14
+
15
+ ## Fetch once, extract once
16
+
17
+ ```typescript
18
+ import { files } from '@proveanything/smartlinks'
19
+
20
+ // The same address returns the same file while it's fresh; once stale, an unchanged page isn't downloaded again.
21
+ const { file } = await files.fetch(collectionId, { url: 'https://supplier.example/spec.pdf', ttl: '7d' })
22
+
23
+ // Each file is read each way once: asking again returns the same result (cached: true).
24
+ const { text } = await files.extract(collectionId, file.id, { variant: 'markdown' })
25
+
26
+ const { data } = await files.extract(collectionId, file.id, {
27
+ variant: 'json',
28
+ schema: { type: 'object', properties: { gtin: { type: 'string' }, weightKg: { type: 'number' } } },
29
+ })
30
+ ```
31
+
32
+ | Variant | Gives | Works on |
33
+ |---|---|---|
34
+ | `text` | plain text | PDFs, HTML, text, JSON, and web pages / documents |
35
+ | `markdown` | Markdown | web pages, PDFs, decks, documents |
36
+ | `ocr` | text read from an image | images |
37
+ | `json` | typed fields (`schema` and/or `prompt`) | anything readable |
38
+
39
+ What's extracted is kept beside its source as a derived file (`origin: 'derived'`, `derivedFromId`, `variant`) and
40
+ lives as long as the source does.
41
+
42
+ ## Your own files
43
+
44
+ ```typescript
45
+ const { file } = await files.put(collectionId, { name: 'notes.json', json: { step: 2 }, ttl: '1d' })
46
+ const { text } = await files.read(collectionId, file.id) // or 'base64'
47
+ const { url } = await files.link(collectionId, file.id, 15) // a signed link for 15 minutes
48
+ await files.keep(collectionId, file.id) // permanent, public, shows in pickers
49
+ await files.remove(collectionId, file.id)
50
+ const { files: mine } = await files.list(collectionId, { appId: 'my-app', origin: 'fetched' })
51
+ ```
52
+
53
+ ## In a server function
54
+
55
+ The same calls are on `ctx.sl.files` (manifest scopes `sl:files:read` and `sl:files:write`), without the collection
56
+ id. AI tools get `file.fetch`, `file.extract` and `file.read`, which hand back file references rather than pasting
57
+ whole documents into the conversation.
58
+
59
+ ```js
60
+ const page = await ctx.sl.files.fetch('https://cook.example/pancakes', { ttl: '7d' })
61
+ const { data } = await ctx.sl.files.extract(page.id, 'json', { schema })
62
+ ```
63
+
64
+ ## Limits
65
+
66
+ - Fetching: public web addresses only (checked on every redirect), up to 50 MB.
67
+ - Reading contents: up to 25 MB.
68
+ - Temporary files per site: 5,000 files or 2 GB at once; past that the oldest temporary files go first. Kept files
69
+ aren't capped here.