@proveanything/smartlinks 3.0.0-alpha.1 → 3.0.0-alpha.3
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 +741 -741
- package/dist/README.md +573 -573
- package/dist/adminCardsView.js +55 -55
- package/dist/api/analytics.d.ts +5 -4
- package/dist/api/analytics.js +5 -4
- package/dist/api/appConfiguration.d.ts +23 -18
- package/dist/api/appConfiguration.js +24 -18
- package/dist/api/appObjects.d.ts +54 -10
- package/dist/api/appObjects.js +75 -40
- package/dist/api/asset.d.ts +28 -22
- package/dist/api/asset.js +45 -56
- package/dist/api/attestation.d.ts +11 -3
- package/dist/api/attestation.js +12 -3
- package/dist/api/attestations.d.ts +12 -8
- package/dist/api/attestations.js +18 -21
- package/dist/api/authKit.d.ts +15 -10
- package/dist/api/authKit.js +17 -11
- package/dist/api/batch.d.ts +36 -25
- package/dist/api/batch.js +46 -39
- package/dist/api/bookings.d.ts +67 -11
- package/dist/api/bookings.js +82 -15
- package/dist/api/broadcasts.js +3 -17
- package/dist/api/claimSet.d.ts +26 -12
- package/dist/api/claimSet.js +32 -24
- package/dist/api/collection.d.ts +15 -10
- package/dist/api/collection.js +17 -11
- package/dist/api/comms.d.ts +12 -6
- package/dist/api/comms.js +12 -6
- package/dist/api/conditions.d.ts +7 -6
- package/dist/api/conditions.js +8 -6
- package/dist/api/contact.d.ts +6 -2
- package/dist/api/contact.js +25 -60
- package/dist/api/containers.d.ts +14 -10
- package/dist/api/containers.js +19 -14
- package/dist/api/crate.js +7 -9
- package/dist/api/dpp.d.ts +20 -13
- package/dist/api/dpp.js +23 -15
- package/dist/api/facets.d.ts +38 -13
- package/dist/api/facets.js +40 -15
- package/dist/api/files.d.ts +5 -2
- package/dist/api/files.js +7 -4
- package/dist/api/form.d.ts +8 -5
- package/dist/api/form.js +9 -5
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/integrations.d.ts +29 -17
- package/dist/api/integrations.js +32 -25
- package/dist/api/interactions.d.ts +11 -6
- package/dist/api/interactions.js +14 -23
- package/dist/api/jobs.d.ts +16 -6
- package/dist/api/jobs.js +30 -20
- package/dist/api/journeys.js +2 -14
- package/dist/api/journeysAnalytics.d.ts +8 -5
- package/dist/api/journeysAnalytics.js +8 -5
- package/dist/api/knowledge.d.ts +20 -14
- package/dist/api/knowledge.js +22 -15
- package/dist/api/location.d.ts +6 -3
- package/dist/api/location.js +8 -22
- package/dist/api/lots.d.ts +9 -5
- package/dist/api/lots.js +22 -26
- package/dist/api/loyalty.d.ts +25 -16
- package/dist/api/loyalty.js +33 -32
- package/dist/api/nfc.d.ts +3 -1
- package/dist/api/nfc.js +3 -1
- package/dist/api/order.d.ts +45 -39
- package/dist/api/order.js +48 -65
- package/dist/api/partner.d.ts +17 -14
- package/dist/api/partner.js +21 -22
- package/dist/api/payments.d.ts +60 -0
- package/dist/api/payments.js +94 -0
- package/dist/api/products.d.ts +35 -12
- package/dist/api/products.js +36 -13
- package/dist/api/proof.d.ts +41 -19
- package/dist/api/proof.js +44 -23
- package/dist/api/realtime.d.ts +3 -0
- package/dist/api/realtime.js +10 -2
- package/dist/api/segments.js +3 -15
- package/dist/api/serviceAccounts.d.ts +8 -5
- package/dist/api/serviceAccounts.js +9 -6
- package/dist/api/shop.d.ts +7 -5
- package/dist/api/shop.js +13 -19
- package/dist/api/subscriptions.d.ts +12 -10
- package/dist/api/subscriptions.js +17 -25
- package/dist/api/tags.d.ts +23 -20
- package/dist/api/tags.js +40 -52
- package/dist/api/template.d.ts +16 -11
- package/dist/api/template.js +19 -13
- package/dist/api/translations.js +2 -12
- package/dist/api/userGroups.d.ts +26 -16
- package/dist/api/userGroups.js +43 -30
- package/dist/api/variant.d.ts +10 -7
- package/dist/api/variant.js +11 -7
- package/dist/api/wallet.d.ts +14 -11
- package/dist/api/wallet.js +15 -12
- package/dist/baseline.css +194 -194
- package/dist/dataChanged.d.ts +74 -0
- package/dist/dataChanged.js +162 -0
- package/dist/docs/API_SUMMARY.md +1443 -1409
- 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 +1 -1
- package/dist/docs/api-versions.md +85 -85
- 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-objects.md +4 -4
- 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/attestations.md +8 -8
- package/dist/docs/bookings.md +105 -8
- package/dist/docs/caching.md +32 -3
- package/dist/docs/comms.md +689 -689
- package/dist/docs/connectors.md +340 -340
- package/dist/docs/contact-search.md +2 -3
- package/dist/docs/css-baseline.md +133 -133
- package/dist/docs/customer-guide.md +70 -70
- package/dist/docs/data-changed.md +91 -0
- package/dist/docs/deploying-apps.md +340 -340
- package/dist/docs/dpp.md +115 -115
- package/dist/docs/entitlements.md +90 -90
- package/dist/docs/files.md +69 -69
- package/dist/docs/host-dependency-contract.md +252 -252
- package/dist/docs/iframe-responder.md +11 -0
- package/dist/docs/integrations.md +322 -322
- package/dist/docs/interactions.md +544 -544
- package/dist/docs/item-context.md +181 -181
- package/dist/docs/knowledge.md +105 -105
- package/dist/docs/lists.md +157 -114
- package/dist/docs/lots.md +112 -112
- package/dist/docs/loyalty.md +348 -348
- package/dist/docs/members.md +183 -183
- package/dist/docs/memberships.md +150 -150
- package/dist/docs/mobile-admin-container.md +693 -693
- package/dist/docs/operations.md +281 -281
- package/dist/docs/overview.md +487 -485
- package/dist/docs/payments.md +94 -0
- 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 +149 -139
- package/dist/docs/records-admin-pattern.md +304 -304
- package/dist/docs/service-accounts.md +64 -64
- package/dist/docs/standard-query.md +196 -187
- package/dist/docs/tag-codes.md +97 -97
- package/dist/docs/tag-ranges.md +106 -106
- package/dist/docs/theme-tokens.md +252 -252
- package/dist/docs/upgrading-to-3.md +550 -430
- package/dist/docs/wallet-passes.md +107 -107
- package/dist/docs/websites.md +123 -123
- package/dist/http.d.ts +6 -3
- package/dist/http.js +48 -19
- package/dist/iframeResponder.d.ts +7 -0
- package/dist/iframeResponder.js +10 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/list.d.ts +12 -0
- package/dist/list.js +59 -0
- package/dist/openapi.yaml +722 -660
- package/dist/testing/bookingsMemory.d.ts +29 -1
- package/dist/testing/bookingsMemory.js +89 -1
- package/dist/testing/index.js +4 -1
- package/dist/theme-boot.js +82 -82
- package/dist/theme.css +75 -75
- package/dist/types/analytics.d.ts +7 -3
- package/dist/types/appManifest.d.ts +26 -4
- package/dist/types/appObjects.d.ts +27 -12
- package/dist/types/appOptions.d.ts +2 -2
- package/dist/types/asset.d.ts +5 -6
- package/dist/types/attestations.d.ts +7 -9
- package/dist/types/batch.d.ts +5 -5
- package/dist/types/bookings.d.ts +109 -6
- package/dist/types/comms.d.ts +9 -5
- package/dist/types/contact.d.ts +7 -4
- package/dist/types/containers.d.ts +2 -1
- package/dist/types/facets.d.ts +14 -2
- package/dist/types/files.d.ts +3 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/integrations.d.ts +2 -1
- package/dist/types/interaction.d.ts +15 -7
- package/dist/types/jobs.d.ts +1 -1
- package/dist/types/journeysAnalytics.d.ts +3 -2
- package/dist/types/knowledge.d.ts +6 -3
- package/dist/types/knowledge.js +0 -1
- package/dist/types/list.d.ts +30 -2
- package/dist/types/location.d.ts +7 -2
- package/dist/types/location.js +0 -1
- package/dist/types/lots.d.ts +5 -2
- package/dist/types/lots.js +0 -6
- package/dist/types/order.d.ts +22 -20
- package/dist/types/payments.d.ts +101 -0
- package/dist/types/payments.js +5 -0
- package/dist/types/product.d.ts +28 -11
- package/dist/types/proof.d.ts +7 -8
- package/dist/types/realtime.d.ts +5 -1
- package/dist/types/tags.d.ts +5 -3
- package/dist/types/userGroups.d.ts +3 -3
- package/dist/types/userGroups.js +0 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/API_SUMMARY.md +1443 -1409
- 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 +1 -1
- package/docs/api-versions.md +85 -85
- 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-objects.md +4 -4
- 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/attestations.md +8 -8
- package/docs/bookings.md +105 -8
- package/docs/caching.md +32 -3
- package/docs/comms.md +689 -689
- package/docs/connectors.md +340 -340
- package/docs/contact-search.md +2 -3
- package/docs/css-baseline.md +133 -133
- package/docs/customer-guide.md +70 -70
- package/docs/data-changed.md +91 -0
- package/docs/deploying-apps.md +340 -340
- package/docs/dpp.md +115 -115
- package/docs/entitlements.md +90 -90
- package/docs/files.md +69 -69
- package/docs/host-dependency-contract.md +252 -252
- package/docs/iframe-responder.md +11 -0
- package/docs/integrations.md +322 -322
- package/docs/interactions.md +544 -544
- package/docs/item-context.md +181 -181
- package/docs/knowledge.md +105 -105
- package/docs/lists.md +157 -114
- package/docs/lots.md +112 -112
- package/docs/loyalty.md +348 -348
- package/docs/members.md +183 -183
- package/docs/memberships.md +150 -150
- package/docs/mobile-admin-container.md +693 -693
- package/docs/operations.md +281 -281
- package/docs/overview.md +487 -485
- package/docs/payments.md +94 -0
- 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 +149 -139
- package/docs/service-accounts.md +64 -64
- package/docs/standard-query.md +196 -187
- package/docs/tag-codes.md +97 -97
- package/docs/tag-ranges.md +106 -106
- package/docs/theme-lookbook.v1.json +120 -120
- package/docs/theme-tokens.md +252 -252
- package/docs/upgrading-to-3.md +550 -430
- package/docs/wallet-passes.md +107 -107
- package/docs/websites.md +123 -123
- package/openapi.yaml +722 -660
- package/package.json +91 -91
- 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/lib/upgrade.mjs +708 -512
- package/scripts/publish.mjs +272 -272
- package/scripts/register-release.mjs +91 -91
- package/scripts/upgrade.mjs +79 -56
- package/upgrade/3.json +2731 -2213
package/docs/contact-search.md
CHANGED
|
@@ -24,7 +24,7 @@ await contact.search({ collectionId, id: "uuid-here" })
|
|
|
24
24
|
await contact.search({
|
|
25
25
|
collectionId,
|
|
26
26
|
tags: ["vip"],
|
|
27
|
-
|
|
27
|
+
createdAt: { gte: "2026-01-01T00:00:00Z" },
|
|
28
28
|
})
|
|
29
29
|
|
|
30
30
|
// Find by external ID (e.g. Shopify customer ID)
|
|
@@ -72,8 +72,7 @@ All filters are ANDed with each other and with any text search.
|
|
|
72
72
|
| `tagsAll` | `string \| string[]` | Contacts must have **all** of these tags. |
|
|
73
73
|
| `source` | `string` | Exact match on the `source` field. |
|
|
74
74
|
| `locale` | `string` | Exact match on the `locale` field (e.g. `"en-US"`). |
|
|
75
|
-
| `
|
|
76
|
-
| `createdTo` | `string` (ISO-8601) | Upper bound on `created_at`. |
|
|
75
|
+
| `createdAt` | `{ gte?, lte? }` (ISO-8601 or `Date`) | When the contact was created: on or after `gte`, on or before `lte`. |
|
|
77
76
|
|
|
78
77
|
### JSONB field filters
|
|
79
78
|
|
package/docs/css-baseline.md
CHANGED
|
@@ -1,133 +1,133 @@
|
|
|
1
|
-
# SmartLinks CSS baseline (`sl-baseline`)
|
|
2
|
-
|
|
3
|
-
> **Status: SHIPPED — `v1`, frozen.** The SDK ships `@proveanything/smartlinks/baseline.css`
|
|
4
|
-
> (+ `baseline.classes.json`); the Portal/Hub serve it and apps opt in via
|
|
5
|
-
> `meta.cssBaseline: "v1"`. `v1` is frozen: an existing `sl-*` rule's meaning never changes;
|
|
6
|
-
> new capability ships as `v2` alongside. Supersedes the earlier "shared Tailwind base" idea —
|
|
7
|
-
> that approach (sharing raw generated Tailwind) was too large and could never safely change;
|
|
8
|
-
> this is the version that survives being frozen for years.
|
|
9
|
-
|
|
10
|
-
A small, **frozen, namespaced** set of structural CSS helpers the platform guarantees are
|
|
11
|
-
present, so any sub-app — and any AI/markdown/dynamic content renderer inside one — can rely
|
|
12
|
-
on them. It is **mechanics, not aesthetics**: layout, spacing, sizing, type scale,
|
|
13
|
-
responsive flow, radius/border/shadow, and a little motion. It never defines colours, fonts,
|
|
14
|
-
or components — those are brand data and per-app.
|
|
15
|
-
|
|
16
|
-
It is the CSS sibling of the JS shared-dependency contract, and like that contract **the SDK
|
|
17
|
-
is the source of truth**: the SDK authors and ships the baseline; hosts and apps consume it.
|
|
18
|
-
|
|
19
|
-
## Why this shape (and not the alternatives)
|
|
20
|
-
|
|
21
|
-
- **Small + frozen** → maintainable for years. A 60–120-rule hand-authored contract can be
|
|
22
|
-
honoured indefinitely; a giant generated Tailwind sheet can't.
|
|
23
|
-
- **Namespaced (`sl-`)** → zero collision with an app's own Tailwind (`flex`, `p-4`) or the
|
|
24
|
-
host. Apps use `sl-*` for the guaranteed floor *and* their own utilities side by side. This
|
|
25
|
-
is what removes the cascade/coexistence fragility.
|
|
26
|
-
- **A stable contract, decoupled from Tailwind underneath** → the SDK may build it with
|
|
27
|
-
Tailwind 4/5/6 internally, but apps target `sl-*`, so Tailwind upgrades are free.
|
|
28
|
-
- **Teachable** → ~100 stable primitives can be put in an AI prompt; the full Tailwind
|
|
29
|
-
surface cannot. Dynamic/AI content gets a guaranteed floor instead of hand-rolling CSS.
|
|
30
|
-
- **A floor, not a ceiling** → opt-in, additive; apps are free to ignore it or write their
|
|
31
|
-
own CSS. It just guarantees a consistent structural baseline when they want it.
|
|
32
|
-
|
|
33
|
-
## Responsive: container-query-backed, breakpoint-named
|
|
34
|
-
|
|
35
|
-
Apps render **both** as containers (in the host document) and as iframes. Plain viewport
|
|
36
|
-
`@media` is inconsistent across those — in an iframe it sees the iframe size (usually right),
|
|
37
|
-
in a container it sees the *host* viewport (wrong for a sub-region). So the responsive
|
|
38
|
-
primitives are **container-query based** (`@container`), exposed with familiar breakpoint
|
|
39
|
-
names so authors/AI still think "phone / tablet / desktop":
|
|
40
|
-
|
|
41
|
-
- The app's mount root is a **container context** (`sl-container`, i.e. `container-type:
|
|
42
|
-
inline-size`) — set by the host on container mounts and by the app root in iframe mode.
|
|
43
|
-
- `sl-md-grid-2` then means "when **my** box is ≥ tablet width", correct in both embed modes.
|
|
44
|
-
- Breakpoints (container widths): `sm` ≥ 480px, `md` ≥ 768px, `lg` ≥ 1024px.
|
|
45
|
-
|
|
46
|
-
This is the "works well on mobile / tablet / desktop" house opinion, done correctly for an
|
|
47
|
-
embed-first platform.
|
|
48
|
-
|
|
49
|
-
## The v1 surface (frozen)
|
|
50
|
-
|
|
51
|
-
All names `sl-`-prefixed. Responsive variants exist only for the layout-flow primitives
|
|
52
|
-
marked ✦ (as `sl-{sm|md|lg}-<name>`), to keep the set teachable and small.
|
|
53
|
-
|
|
54
|
-
**Reset & a11y**
|
|
55
|
-
`sl-reset` (border-box + margin:0 on self/descendants) · `sl-media` (max-width:100%,
|
|
56
|
-
height:auto) · `sl-focus` (keyboard-only focus ring) · `sl-sr-only` · `sl-container`
|
|
57
|
-
(responsive container context)
|
|
58
|
-
|
|
59
|
-
**Display ✦** `sl-block` · `sl-inline-block` · `sl-inline` · `sl-flex` · `sl-inline-flex` ·
|
|
60
|
-
`sl-grid` · `sl-hidden`
|
|
61
|
-
|
|
62
|
-
**Flex ✦(direction)** `sl-flex-row` · `sl-flex-col` · `sl-flex-wrap` · `sl-flex-nowrap` ·
|
|
63
|
-
`sl-items-{start,center,end,stretch,baseline}` · `sl-justify-{start,center,end,between,around}`
|
|
64
|
-
· `sl-flex-1` · `sl-flex-auto` · `sl-grow-0` · `sl-shrink-0`
|
|
65
|
-
|
|
66
|
-
**Grid ✦(columns)** `sl-grid-{2,3,4}` (collapse to 1 col below `sm`) · `sl-grid-auto`
|
|
67
|
-
(auto-fit minmax) · `sl-col-span-full`
|
|
68
|
-
|
|
69
|
-
**Spacing** — curated 8-step scale `0,1,2,3,4,5,6,7` ≈ `0, .25, .5, .75, 1, 1.5, 2, 3 rem`.
|
|
70
|
-
Logical properties (RTL-safe): `sl-gap-{0..7}` · `sl-p-{0..7}` · `sl-px-{0..7}` ·
|
|
71
|
-
`sl-py-{0..7}` · `sl-ps-{0..7}` / `sl-pe-{0..7}` (inline start/end) · `sl-m-{0..7}` ·
|
|
72
|
-
`sl-mx-auto` · `sl-mt-{0..7}` · `sl-mb-{0..7}`
|
|
73
|
-
|
|
74
|
-
**Sizing** `sl-w-full` · `sl-h-full` · `sl-min-w-0` · `sl-max-w-{reading(42rem),prose(65ch),
|
|
75
|
-
page(72rem)}` · `sl-aspect-{square,wide(16/9)}`
|
|
76
|
-
|
|
77
|
-
**Typography** — static rem scale (predictable in any embed; use the responsive `✦` align
|
|
78
|
-
and per-breakpoint sizing where you want type to change). `sl-text-{xs,sm,base,lg,xl,2xl,3xl,
|
|
79
|
-
4xl}` · `sl-font-{normal,medium,semibold,bold}` · `sl-leading-{tight,normal,relaxed}` ·
|
|
80
|
-
`sl-tracking-{tight,normal}` · `sl-text-{left,center,right}` ✦(align) · `sl-truncate` ·
|
|
81
|
-
`sl-line-clamp-{2,3}` · `sl-balance` (text-wrap:balance) · `sl-pretty`
|
|
82
|
-
|
|
83
|
-
**Radius / border / shadow** — neutral mechanics only (no brand colour). `sl-rounded-{sm,md,
|
|
84
|
-
lg,xl,full}` · `sl-border` / `sl-border-0` (colour = `--sl-border`, a subtle
|
|
85
|
-
`color-mix(currentColor 14%, transparent)` default, overridable) · `sl-shadow-{sm,md,lg}`
|
|
86
|
-
(neutral)
|
|
87
|
-
|
|
88
|
-
**Object-fit / overflow** `sl-cover` · `sl-contain` · `sl-overflow-hidden` · `sl-overflow-auto`
|
|
89
|
-
|
|
90
|
-
**Position & layering** `sl-relative` · `sl-absolute` · `sl-sticky` · `sl-inset-0` ·
|
|
91
|
-
`sl-z-{base,raised,overlay}` (named levels — a house layering convention so apps don't fight
|
|
92
|
-
over z-index)
|
|
93
|
-
|
|
94
|
-
**Motion** (small, reduced-motion-safe; keyframes are `sl-`-namespaced) `sl-transition`
|
|
95
|
-
(standard ease/duration) · `sl-reveal` (fade-up on view) · `sl-hover-lift` · all motion is
|
|
96
|
-
**disabled under `prefers-reduced-motion`**. Rich motion vocabularies stay per-app (and may
|
|
97
|
-
become a separate versioned motion contract later if several apps want to share one).
|
|
98
|
-
|
|
99
|
-
### Explicitly NOT in the baseline (non-goals)
|
|
100
|
-
- **No colours** — brand data, delivered via CSS variables / theme params.
|
|
101
|
-
- **No fonts** — per-app; the baseline sets a *scale*, never a family.
|
|
102
|
-
- **No components** — no buttons/cards/nav; those are per-app aesthetics.
|
|
103
|
-
- **No full utility surface** — anything bespoke ships in the app's own scoped CSS.
|
|
104
|
-
|
|
105
|
-
## Delivery — one SDK source, two paths
|
|
106
|
-
|
|
107
|
-
The SDK ships the compiled baseline as `@proveanything/smartlinks/baseline.css` (+ the
|
|
108
|
-
machine-readable class list for the doctor). One authored source; two delivery mechanisms:
|
|
109
|
-
|
|
110
|
-
| Embed mode | How the app gets it |
|
|
111
|
-
|---|---|
|
|
112
|
-
| **Container (ESM/UMD)** — same document as host | Host has already loaded `baseline.css`; the app **ships nothing** and just uses `sl-*`. Declares `meta.cssBaseline: "v1"`. |
|
|
113
|
-
| **Iframe** — its own document | The app **imports the SDK's `baseline.css`** into its own document (it inherits nothing, exactly like it must carry its own modules). Byte-identical to the host copy. |
|
|
114
|
-
|
|
115
|
-
Cascade: baseline loads first; app CSS after → app rules win ties. `sl-*` never collides with
|
|
116
|
-
app utilities regardless.
|
|
117
|
-
|
|
118
|
-
## SDK / build support (kept minimal — no CSS surgery)
|
|
119
|
-
- The SDK **exports `baseline.css`** (and `baseline.classes.json`), built in the SDK's own
|
|
120
|
-
build so the file and the class list can't drift.
|
|
121
|
-
- Manifest field **`meta.cssBaseline: "v1"`** — declares reliance so the host can guarantee
|
|
122
|
-
it's present.
|
|
123
|
-
- `smartlinks-doctor`: warn if an app declares `cssBaseline` but uses an `sl-*` class outside
|
|
124
|
-
the declared version (the useful invariant — spirit of the JS import check). No subtraction
|
|
125
|
-
tooling needed: `sl-*` is a fixed vocabulary apps just use.
|
|
126
|
-
|
|
127
|
-
## Versioning & freeze
|
|
128
|
-
- `v1` is **frozen**: an existing `sl-*` class's meaning/output never changes in place.
|
|
129
|
-
- New capability ships as `v2` **alongside** `v1` (both served), never a silent mutation.
|
|
130
|
-
- Tailwind (or whatever builds it) may be upgraded underneath as long as the `sl-*` contract
|
|
131
|
-
keeps its meaning.
|
|
132
|
-
- Governance: additions to the surface go through review (it's a decades-long contract);
|
|
133
|
-
err toward *stable and generous* over minimal, since the AI builders target it.
|
|
1
|
+
# SmartLinks CSS baseline (`sl-baseline`)
|
|
2
|
+
|
|
3
|
+
> **Status: SHIPPED — `v1`, frozen.** The SDK ships `@proveanything/smartlinks/baseline.css`
|
|
4
|
+
> (+ `baseline.classes.json`); the Portal/Hub serve it and apps opt in via
|
|
5
|
+
> `meta.cssBaseline: "v1"`. `v1` is frozen: an existing `sl-*` rule's meaning never changes;
|
|
6
|
+
> new capability ships as `v2` alongside. Supersedes the earlier "shared Tailwind base" idea —
|
|
7
|
+
> that approach (sharing raw generated Tailwind) was too large and could never safely change;
|
|
8
|
+
> this is the version that survives being frozen for years.
|
|
9
|
+
|
|
10
|
+
A small, **frozen, namespaced** set of structural CSS helpers the platform guarantees are
|
|
11
|
+
present, so any sub-app — and any AI/markdown/dynamic content renderer inside one — can rely
|
|
12
|
+
on them. It is **mechanics, not aesthetics**: layout, spacing, sizing, type scale,
|
|
13
|
+
responsive flow, radius/border/shadow, and a little motion. It never defines colours, fonts,
|
|
14
|
+
or components — those are brand data and per-app.
|
|
15
|
+
|
|
16
|
+
It is the CSS sibling of the JS shared-dependency contract, and like that contract **the SDK
|
|
17
|
+
is the source of truth**: the SDK authors and ships the baseline; hosts and apps consume it.
|
|
18
|
+
|
|
19
|
+
## Why this shape (and not the alternatives)
|
|
20
|
+
|
|
21
|
+
- **Small + frozen** → maintainable for years. A 60–120-rule hand-authored contract can be
|
|
22
|
+
honoured indefinitely; a giant generated Tailwind sheet can't.
|
|
23
|
+
- **Namespaced (`sl-`)** → zero collision with an app's own Tailwind (`flex`, `p-4`) or the
|
|
24
|
+
host. Apps use `sl-*` for the guaranteed floor *and* their own utilities side by side. This
|
|
25
|
+
is what removes the cascade/coexistence fragility.
|
|
26
|
+
- **A stable contract, decoupled from Tailwind underneath** → the SDK may build it with
|
|
27
|
+
Tailwind 4/5/6 internally, but apps target `sl-*`, so Tailwind upgrades are free.
|
|
28
|
+
- **Teachable** → ~100 stable primitives can be put in an AI prompt; the full Tailwind
|
|
29
|
+
surface cannot. Dynamic/AI content gets a guaranteed floor instead of hand-rolling CSS.
|
|
30
|
+
- **A floor, not a ceiling** → opt-in, additive; apps are free to ignore it or write their
|
|
31
|
+
own CSS. It just guarantees a consistent structural baseline when they want it.
|
|
32
|
+
|
|
33
|
+
## Responsive: container-query-backed, breakpoint-named
|
|
34
|
+
|
|
35
|
+
Apps render **both** as containers (in the host document) and as iframes. Plain viewport
|
|
36
|
+
`@media` is inconsistent across those — in an iframe it sees the iframe size (usually right),
|
|
37
|
+
in a container it sees the *host* viewport (wrong for a sub-region). So the responsive
|
|
38
|
+
primitives are **container-query based** (`@container`), exposed with familiar breakpoint
|
|
39
|
+
names so authors/AI still think "phone / tablet / desktop":
|
|
40
|
+
|
|
41
|
+
- The app's mount root is a **container context** (`sl-container`, i.e. `container-type:
|
|
42
|
+
inline-size`) — set by the host on container mounts and by the app root in iframe mode.
|
|
43
|
+
- `sl-md-grid-2` then means "when **my** box is ≥ tablet width", correct in both embed modes.
|
|
44
|
+
- Breakpoints (container widths): `sm` ≥ 480px, `md` ≥ 768px, `lg` ≥ 1024px.
|
|
45
|
+
|
|
46
|
+
This is the "works well on mobile / tablet / desktop" house opinion, done correctly for an
|
|
47
|
+
embed-first platform.
|
|
48
|
+
|
|
49
|
+
## The v1 surface (frozen)
|
|
50
|
+
|
|
51
|
+
All names `sl-`-prefixed. Responsive variants exist only for the layout-flow primitives
|
|
52
|
+
marked ✦ (as `sl-{sm|md|lg}-<name>`), to keep the set teachable and small.
|
|
53
|
+
|
|
54
|
+
**Reset & a11y**
|
|
55
|
+
`sl-reset` (border-box + margin:0 on self/descendants) · `sl-media` (max-width:100%,
|
|
56
|
+
height:auto) · `sl-focus` (keyboard-only focus ring) · `sl-sr-only` · `sl-container`
|
|
57
|
+
(responsive container context)
|
|
58
|
+
|
|
59
|
+
**Display ✦** `sl-block` · `sl-inline-block` · `sl-inline` · `sl-flex` · `sl-inline-flex` ·
|
|
60
|
+
`sl-grid` · `sl-hidden`
|
|
61
|
+
|
|
62
|
+
**Flex ✦(direction)** `sl-flex-row` · `sl-flex-col` · `sl-flex-wrap` · `sl-flex-nowrap` ·
|
|
63
|
+
`sl-items-{start,center,end,stretch,baseline}` · `sl-justify-{start,center,end,between,around}`
|
|
64
|
+
· `sl-flex-1` · `sl-flex-auto` · `sl-grow-0` · `sl-shrink-0`
|
|
65
|
+
|
|
66
|
+
**Grid ✦(columns)** `sl-grid-{2,3,4}` (collapse to 1 col below `sm`) · `sl-grid-auto`
|
|
67
|
+
(auto-fit minmax) · `sl-col-span-full`
|
|
68
|
+
|
|
69
|
+
**Spacing** — curated 8-step scale `0,1,2,3,4,5,6,7` ≈ `0, .25, .5, .75, 1, 1.5, 2, 3 rem`.
|
|
70
|
+
Logical properties (RTL-safe): `sl-gap-{0..7}` · `sl-p-{0..7}` · `sl-px-{0..7}` ·
|
|
71
|
+
`sl-py-{0..7}` · `sl-ps-{0..7}` / `sl-pe-{0..7}` (inline start/end) · `sl-m-{0..7}` ·
|
|
72
|
+
`sl-mx-auto` · `sl-mt-{0..7}` · `sl-mb-{0..7}`
|
|
73
|
+
|
|
74
|
+
**Sizing** `sl-w-full` · `sl-h-full` · `sl-min-w-0` · `sl-max-w-{reading(42rem),prose(65ch),
|
|
75
|
+
page(72rem)}` · `sl-aspect-{square,wide(16/9)}`
|
|
76
|
+
|
|
77
|
+
**Typography** — static rem scale (predictable in any embed; use the responsive `✦` align
|
|
78
|
+
and per-breakpoint sizing where you want type to change). `sl-text-{xs,sm,base,lg,xl,2xl,3xl,
|
|
79
|
+
4xl}` · `sl-font-{normal,medium,semibold,bold}` · `sl-leading-{tight,normal,relaxed}` ·
|
|
80
|
+
`sl-tracking-{tight,normal}` · `sl-text-{left,center,right}` ✦(align) · `sl-truncate` ·
|
|
81
|
+
`sl-line-clamp-{2,3}` · `sl-balance` (text-wrap:balance) · `sl-pretty`
|
|
82
|
+
|
|
83
|
+
**Radius / border / shadow** — neutral mechanics only (no brand colour). `sl-rounded-{sm,md,
|
|
84
|
+
lg,xl,full}` · `sl-border` / `sl-border-0` (colour = `--sl-border`, a subtle
|
|
85
|
+
`color-mix(currentColor 14%, transparent)` default, overridable) · `sl-shadow-{sm,md,lg}`
|
|
86
|
+
(neutral)
|
|
87
|
+
|
|
88
|
+
**Object-fit / overflow** `sl-cover` · `sl-contain` · `sl-overflow-hidden` · `sl-overflow-auto`
|
|
89
|
+
|
|
90
|
+
**Position & layering** `sl-relative` · `sl-absolute` · `sl-sticky` · `sl-inset-0` ·
|
|
91
|
+
`sl-z-{base,raised,overlay}` (named levels — a house layering convention so apps don't fight
|
|
92
|
+
over z-index)
|
|
93
|
+
|
|
94
|
+
**Motion** (small, reduced-motion-safe; keyframes are `sl-`-namespaced) `sl-transition`
|
|
95
|
+
(standard ease/duration) · `sl-reveal` (fade-up on view) · `sl-hover-lift` · all motion is
|
|
96
|
+
**disabled under `prefers-reduced-motion`**. Rich motion vocabularies stay per-app (and may
|
|
97
|
+
become a separate versioned motion contract later if several apps want to share one).
|
|
98
|
+
|
|
99
|
+
### Explicitly NOT in the baseline (non-goals)
|
|
100
|
+
- **No colours** — brand data, delivered via CSS variables / theme params.
|
|
101
|
+
- **No fonts** — per-app; the baseline sets a *scale*, never a family.
|
|
102
|
+
- **No components** — no buttons/cards/nav; those are per-app aesthetics.
|
|
103
|
+
- **No full utility surface** — anything bespoke ships in the app's own scoped CSS.
|
|
104
|
+
|
|
105
|
+
## Delivery — one SDK source, two paths
|
|
106
|
+
|
|
107
|
+
The SDK ships the compiled baseline as `@proveanything/smartlinks/baseline.css` (+ the
|
|
108
|
+
machine-readable class list for the doctor). One authored source; two delivery mechanisms:
|
|
109
|
+
|
|
110
|
+
| Embed mode | How the app gets it |
|
|
111
|
+
|---|---|
|
|
112
|
+
| **Container (ESM/UMD)** — same document as host | Host has already loaded `baseline.css`; the app **ships nothing** and just uses `sl-*`. Declares `meta.cssBaseline: "v1"`. |
|
|
113
|
+
| **Iframe** — its own document | The app **imports the SDK's `baseline.css`** into its own document (it inherits nothing, exactly like it must carry its own modules). Byte-identical to the host copy. |
|
|
114
|
+
|
|
115
|
+
Cascade: baseline loads first; app CSS after → app rules win ties. `sl-*` never collides with
|
|
116
|
+
app utilities regardless.
|
|
117
|
+
|
|
118
|
+
## SDK / build support (kept minimal — no CSS surgery)
|
|
119
|
+
- The SDK **exports `baseline.css`** (and `baseline.classes.json`), built in the SDK's own
|
|
120
|
+
build so the file and the class list can't drift.
|
|
121
|
+
- Manifest field **`meta.cssBaseline: "v1"`** — declares reliance so the host can guarantee
|
|
122
|
+
it's present.
|
|
123
|
+
- `smartlinks-doctor`: warn if an app declares `cssBaseline` but uses an `sl-*` class outside
|
|
124
|
+
the declared version (the useful invariant — spirit of the JS import check). No subtraction
|
|
125
|
+
tooling needed: `sl-*` is a fixed vocabulary apps just use.
|
|
126
|
+
|
|
127
|
+
## Versioning & freeze
|
|
128
|
+
- `v1` is **frozen**: an existing `sl-*` class's meaning/output never changes in place.
|
|
129
|
+
- New capability ships as `v2` **alongside** `v1` (both served), never a silent mutation.
|
|
130
|
+
- Tailwind (or whatever builds it) may be upgraded underneath as long as the `sl-*` contract
|
|
131
|
+
keeps its meaning.
|
|
132
|
+
- Governance: additions to the surface go through review (it's a decades-long contract);
|
|
133
|
+
err toward *stable and generous* over minimal, since the AI builders target it.
|
package/docs/customer-guide.md
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
# The customer guide
|
|
2
|
-
|
|
3
|
-
A business's assistant for its visitors, in Portal and the Hub, by voice or by text. It knows the business
|
|
4
|
-
(a brief written for visitors), where the visitor is (the product, the item scanned, the app on screen) and
|
|
5
|
-
what that screen says, and it can open another app for them. The business switches it on and shapes it in
|
|
6
|
-
Studio (Configure → Guide). Design: prove `server/docs/design/customer-assistant.md`.
|
|
7
|
-
|
|
8
|
-
Everything that shapes the guide — its instructions, voice, tools and limits — is fixed by SmartLinks when a
|
|
9
|
-
conversation starts. A page only says where the visitor is and what is on their screen.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## For a host (Portal, the Hub, a custom site)
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
import * as SL from '@proveanything/smartlinks'
|
|
17
|
-
|
|
18
|
-
const info = await SL.ai.guide.get(collectionId, 'portal') // { enabled, name, modes, suggestions, handoff }
|
|
19
|
-
if (!info.enabled) return
|
|
20
|
-
|
|
21
|
-
const chat = await SL.ai.guide.start(collectionId, {
|
|
22
|
-
surface: 'portal', // or 'hub'
|
|
23
|
-
mode: info.modes.start, // 'voice' or 'text'
|
|
24
|
-
productId, proofId,
|
|
25
|
-
apps: [{ id: 'recipes', title: 'Recipes' }], // the apps on the visitor's page: their pages come from the deep-link registry
|
|
26
|
-
where: { appId: 'recipes', path: '/method' }, // where the visitor is now
|
|
27
|
-
screen: await SL.ai.content.request({ frame: appIframe.contentWindow }),
|
|
28
|
-
showApp: (appId) => openApp(appId),
|
|
29
|
-
openPage: ({ appId, path, params }) => openApp(appId, path, params), // a page the guide chose (look_in → open_page)
|
|
30
|
-
goTo: (productId) => openProduct(productId), // another product it found (find → go_to)
|
|
31
|
-
onShow: (card) => showFound(card), // what find found, rows with goTo
|
|
32
|
-
offerPerson: (handoff) => showContact(handoff),
|
|
33
|
-
onState: setState, // idle | connecting | listening | hearing | thinking | speaking | paused | error
|
|
34
|
-
onCaption: setCaption, // what it is saying or writing, as it goes
|
|
35
|
-
onError: setError,
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
chat.pause(); chat.resume(); chat.stop()
|
|
39
|
-
chat.send('What is it made of?') // text mode (works in voice mode too)
|
|
40
|
-
chat.note('The visitor is now on Dishwasher DW-60 (product id p9), in Manual at /troubleshooting.') // where they are; it doesn't answer
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
The guide knows the pages around the visitor from SmartLinks' deep-link registry (`linkable` in each app's
|
|
44
|
-
manifest, and each app's config `linkable` per collection and per product; see deep-link-discovery.md).
|
|
45
|
-
Register your pages there and the guide can open them by name.
|
|
46
|
-
|
|
47
|
-
- Voice needs the microphone; ask for it on a tap (browsers require it).
|
|
48
|
-
- A signed-in visitor (Auth Kit bearer on the SDK) owns their conversation; otherwise it is anonymous.
|
|
49
|
-
- The guide's `read_screen` tool asks the app on screen what it shows (below). Pass `readScreen` to answer
|
|
50
|
-
it yourself.
|
|
51
|
-
- Limits per visitor and per business are set in Studio; a refusal comes back as `GUIDE_LIMIT` (429).
|
|
52
|
-
|
|
53
|
-
## For an app: say what your screen shows
|
|
54
|
-
|
|
55
|
-
```ts
|
|
56
|
-
useEffect(() => SL.ai.content.provide(() => ({
|
|
57
|
-
appId: 'pages',
|
|
58
|
-
title: page.title,
|
|
59
|
-
content: page.text, // plain words: the exhibit, the recipe, what this form is for
|
|
60
|
-
})), [page])
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
`provide` works the same in an iframe (the host asks by message) and as a direct component. Return what a
|
|
64
|
-
person reading the screen would take in, not markup. Without it, a host may fall back to the page's text.
|
|
65
|
-
|
|
66
|
-
## Your own live conversation
|
|
67
|
-
|
|
68
|
-
`SL.ai.live.start({ endpoints: { mint, tool, event }, mode, screenTools, … })` is the client the guide and the
|
|
69
|
-
Studio assistant use: WebRTC straight to the realtime service with a key your server minted, tools split
|
|
70
|
-
between the page (`screenTools`) and your server (`endpoints.tool`). See `src/live.ts`.
|
|
1
|
+
# The customer guide
|
|
2
|
+
|
|
3
|
+
A business's assistant for its visitors, in Portal and the Hub, by voice or by text. It knows the business
|
|
4
|
+
(a brief written for visitors), where the visitor is (the product, the item scanned, the app on screen) and
|
|
5
|
+
what that screen says, and it can open another app for them. The business switches it on and shapes it in
|
|
6
|
+
Studio (Configure → Guide). Design: prove `server/docs/design/customer-assistant.md`.
|
|
7
|
+
|
|
8
|
+
Everything that shapes the guide — its instructions, voice, tools and limits — is fixed by SmartLinks when a
|
|
9
|
+
conversation starts. A page only says where the visitor is and what is on their screen.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## For a host (Portal, the Hub, a custom site)
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import * as SL from '@proveanything/smartlinks'
|
|
17
|
+
|
|
18
|
+
const info = await SL.ai.guide.get(collectionId, 'portal') // { enabled, name, modes, suggestions, handoff }
|
|
19
|
+
if (!info.enabled) return
|
|
20
|
+
|
|
21
|
+
const chat = await SL.ai.guide.start(collectionId, {
|
|
22
|
+
surface: 'portal', // or 'hub'
|
|
23
|
+
mode: info.modes.start, // 'voice' or 'text'
|
|
24
|
+
productId, proofId,
|
|
25
|
+
apps: [{ id: 'recipes', title: 'Recipes' }], // the apps on the visitor's page: their pages come from the deep-link registry
|
|
26
|
+
where: { appId: 'recipes', path: '/method' }, // where the visitor is now
|
|
27
|
+
screen: await SL.ai.content.request({ frame: appIframe.contentWindow }),
|
|
28
|
+
showApp: (appId) => openApp(appId),
|
|
29
|
+
openPage: ({ appId, path, params }) => openApp(appId, path, params), // a page the guide chose (look_in → open_page)
|
|
30
|
+
goTo: (productId) => openProduct(productId), // another product it found (find → go_to)
|
|
31
|
+
onShow: (card) => showFound(card), // what find found, rows with goTo
|
|
32
|
+
offerPerson: (handoff) => showContact(handoff),
|
|
33
|
+
onState: setState, // idle | connecting | listening | hearing | thinking | speaking | paused | error
|
|
34
|
+
onCaption: setCaption, // what it is saying or writing, as it goes
|
|
35
|
+
onError: setError,
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
chat.pause(); chat.resume(); chat.stop()
|
|
39
|
+
chat.send('What is it made of?') // text mode (works in voice mode too)
|
|
40
|
+
chat.note('The visitor is now on Dishwasher DW-60 (product id p9), in Manual at /troubleshooting.') // where they are; it doesn't answer
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The guide knows the pages around the visitor from SmartLinks' deep-link registry (`linkable` in each app's
|
|
44
|
+
manifest, and each app's config `linkable` per collection and per product; see deep-link-discovery.md).
|
|
45
|
+
Register your pages there and the guide can open them by name.
|
|
46
|
+
|
|
47
|
+
- Voice needs the microphone; ask for it on a tap (browsers require it).
|
|
48
|
+
- A signed-in visitor (Auth Kit bearer on the SDK) owns their conversation; otherwise it is anonymous.
|
|
49
|
+
- The guide's `read_screen` tool asks the app on screen what it shows (below). Pass `readScreen` to answer
|
|
50
|
+
it yourself.
|
|
51
|
+
- Limits per visitor and per business are set in Studio; a refusal comes back as `GUIDE_LIMIT` (429).
|
|
52
|
+
|
|
53
|
+
## For an app: say what your screen shows
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
useEffect(() => SL.ai.content.provide(() => ({
|
|
57
|
+
appId: 'pages',
|
|
58
|
+
title: page.title,
|
|
59
|
+
content: page.text, // plain words: the exhibit, the recipe, what this form is for
|
|
60
|
+
})), [page])
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`provide` works the same in an iframe (the host asks by message) and as a direct component. Return what a
|
|
64
|
+
person reading the screen would take in, not markup. Without it, a host may fall back to the page's text.
|
|
65
|
+
|
|
66
|
+
## Your own live conversation
|
|
67
|
+
|
|
68
|
+
`SL.ai.live.start({ endpoints: { mint, tool, event }, mode, screenTools, … })` is the client the guide and the
|
|
69
|
+
Studio assistant use: WebRTC straight to the realtime service with a key your server minted, tools split
|
|
70
|
+
between the page (`screenTools`) and your server (`endpoints.tool`). See `src/live.ts`.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Data changed: an open screen reads again
|
|
2
|
+
|
|
3
|
+
Since 2.2.3 (and in SDK 3).
|
|
4
|
+
|
|
5
|
+
An admin screen is not the only thing that changes records. The assistant applies a change, another app
|
|
6
|
+
saves, another person edits. The screen that is open keeps showing what it loaded, and the person has to
|
|
7
|
+
reload to see the change. **Data changed** is the host telling the app, so it can read again.
|
|
8
|
+
|
|
9
|
+
It is one message, host to app:
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
{ type: 'smartlinks:data-changed', collectionId: 'acme', changes: [{ type: 'product', id: 'p_1', status: 'updated' }], source: 'assistant' }
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Ids only, never data. The app reads again through the normal API, with the normal permissions.
|
|
16
|
+
|
|
17
|
+
## In an app
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import * as SL from '@proveanything/smartlinks'
|
|
21
|
+
|
|
22
|
+
useEffect(() => SL.onDataChanged((e) => {
|
|
23
|
+
if (e.collectionId && e.collectionId !== collectionId) return
|
|
24
|
+
if (e.touches({ type: 'product' })) queryClient.invalidateQueries({ queryKey: ['products'] })
|
|
25
|
+
if (e.touches({ type: 'product', id: productId })) queryClient.invalidateQueries({ queryKey: ['product', collectionId, productId] })
|
|
26
|
+
}), [collectionId, productId])
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- `SL.onDataChanged(listener)` returns a function that stops listening. It does nothing outside a frame.
|
|
30
|
+
- Before your listener runs, the SDK has already forgotten the reads it kept for what changed, so the
|
|
31
|
+
next read returns what the server has now. This happens even in an app that never calls `onDataChanged`.
|
|
32
|
+
- `e.changes` is what changed. It is **empty when the host can't say**: treat everything you show from
|
|
33
|
+
the collection as possibly changed.
|
|
34
|
+
- `e.touches({ type, id })` answers "might this be about my record?". It is true when a change matches
|
|
35
|
+
every field you give, and always true when `e.changes` is empty.
|
|
36
|
+
- `e.source` is who made the change when the host knows (`'assistant'`, `'app'`, `'person'`).
|
|
37
|
+
|
|
38
|
+
### A form the person is filling in
|
|
39
|
+
|
|
40
|
+
Reading again must not throw away typing.
|
|
41
|
+
|
|
42
|
+
- **Untouched form:** fill it again from the new record.
|
|
43
|
+
- **Form with changes in it:** keep what the person typed. Say plainly that the record was changed
|
|
44
|
+
elsewhere, and offer to load the new version. Do not save the old copy over the new one without asking.
|
|
45
|
+
|
|
46
|
+
Compare the record you loaded with the one you just read (its `updatedAt`, or the fields the form shows)
|
|
47
|
+
before saying anything: "something changed" is not always about the record on screen.
|
|
48
|
+
|
|
49
|
+
### One change word per kind of record
|
|
50
|
+
|
|
51
|
+
`type` uses the same words as realtime changes (`docs/realtime.md`): `product`, `proof`, `asset`, `record`,
|
|
52
|
+
`collection`, `collection.apps`, `settings`. A host may also send its own words for other records
|
|
53
|
+
(`contact`, `appConfig`). `id` is the record's id; `productId`, `proofId`, `appId` and `recordType` say
|
|
54
|
+
where it lives when that helps.
|
|
55
|
+
|
|
56
|
+
## In a host
|
|
57
|
+
|
|
58
|
+
Send it after a change the app did not make itself.
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
// Any host
|
|
62
|
+
SL.postDataChanged(iframe.contentWindow, { collectionId, changes: [{ type: 'product', id }], source: 'assistant' })
|
|
63
|
+
|
|
64
|
+
// With IframeResponder
|
|
65
|
+
responder.dataChanged({ collectionId, changes: [{ type: 'product', id }] })
|
|
66
|
+
|
|
67
|
+
// When you can't say what changed
|
|
68
|
+
SL.postDataChanged(iframe.contentWindow, { collectionId })
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Studio sends it to every open app frame when an assistant change set is applied or undone, when the
|
|
72
|
+
assistant finishes a step that writes, and when its turn ends.
|
|
73
|
+
|
|
74
|
+
## What it is not
|
|
75
|
+
|
|
76
|
+
- It is not the realtime feed. `SL.realtime.onChange` (`docs/realtime.md`) is the server telling a page
|
|
77
|
+
that something changed, over a live connection. Data changed is the host passing a change it already
|
|
78
|
+
knows about into a frame, with no connection of the app's own. A host that listens to the realtime
|
|
79
|
+
feed can pass those changes on with the same message, so an app needs only `onDataChanged`.
|
|
80
|
+
- It does not carry data and it is not a save. Nothing is written by sending or hearing it.
|
|
81
|
+
|
|
82
|
+
## What the SDK forgets
|
|
83
|
+
|
|
84
|
+
| The host says | The SDK forgets |
|
|
85
|
+
|---|---|
|
|
86
|
+
| Only products and proofs changed | Everything kept under that collection's products (the product, its lists, its proofs) |
|
|
87
|
+
| Anything else, or nothing specific | Everything kept for that collection |
|
|
88
|
+
| No collection given | Everything kept |
|
|
89
|
+
|
|
90
|
+
Admin reads are never kept in the first place (`docs/caching.md`), so this matters for public reads an
|
|
91
|
+
admin screen makes, and for apps on an SDK before 2.2.2.
|