@proveanything/smartlinks 3.0.0-alpha.2 → 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.
Files changed (151) hide show
  1. package/README.md +741 -741
  2. package/dist/README.md +573 -573
  3. package/dist/adminCardsView.js +55 -55
  4. package/dist/api/bookings.d.ts +49 -2
  5. package/dist/api/bookings.js +59 -2
  6. package/dist/api/index.d.ts +1 -0
  7. package/dist/api/index.js +1 -0
  8. package/dist/api/payments.d.ts +60 -0
  9. package/dist/api/payments.js +94 -0
  10. package/dist/api/realtime.d.ts +3 -0
  11. package/dist/api/realtime.js +10 -2
  12. package/dist/baseline.css +194 -194
  13. package/dist/dataChanged.d.ts +74 -0
  14. package/dist/dataChanged.js +162 -0
  15. package/dist/docs/API_SUMMARY.md +1086 -858
  16. package/dist/docs/admin-cards.md +189 -189
  17. package/dist/docs/agent-tools.md +156 -156
  18. package/dist/docs/ai-tools-and-skills.md +180 -180
  19. package/dist/docs/ai.md +1721 -1721
  20. package/dist/docs/api-versions.md +85 -85
  21. package/dist/docs/app-data-storage.md +277 -277
  22. package/dist/docs/app-docs.md +73 -73
  23. package/dist/docs/app-manifest.md +852 -852
  24. package/dist/docs/app-records-pattern.md +388 -388
  25. package/dist/docs/appConfig.md +550 -550
  26. package/dist/docs/assistant-apps.md +172 -172
  27. package/dist/docs/assistant-context.md +119 -119
  28. package/dist/docs/bookings.md +105 -8
  29. package/dist/docs/caching.md +32 -3
  30. package/dist/docs/comms.md +689 -689
  31. package/dist/docs/connectors.md +340 -340
  32. package/dist/docs/css-baseline.md +133 -133
  33. package/dist/docs/customer-guide.md +70 -70
  34. package/dist/docs/data-changed.md +91 -0
  35. package/dist/docs/deploying-apps.md +340 -340
  36. package/dist/docs/dpp.md +115 -115
  37. package/dist/docs/entitlements.md +90 -90
  38. package/dist/docs/files.md +69 -69
  39. package/dist/docs/host-dependency-contract.md +252 -252
  40. package/dist/docs/iframe-responder.md +11 -0
  41. package/dist/docs/integrations.md +322 -322
  42. package/dist/docs/interactions.md +544 -544
  43. package/dist/docs/item-context.md +181 -181
  44. package/dist/docs/knowledge.md +105 -105
  45. package/dist/docs/lists.md +157 -157
  46. package/dist/docs/lots.md +112 -112
  47. package/dist/docs/loyalty.md +348 -348
  48. package/dist/docs/members.md +183 -183
  49. package/dist/docs/memberships.md +150 -150
  50. package/dist/docs/mobile-admin-container.md +693 -693
  51. package/dist/docs/operations.md +281 -281
  52. package/dist/docs/overview.md +487 -485
  53. package/dist/docs/payments.md +94 -0
  54. package/dist/docs/proof-comms-triggers.md +142 -142
  55. package/dist/docs/proof-ownership-transfer.md +155 -155
  56. package/dist/docs/proof-product-data-scoping.md +462 -462
  57. package/dist/docs/proof-share-grants.md +305 -305
  58. package/dist/docs/realtime.md +149 -139
  59. package/dist/docs/records-admin-pattern.md +304 -304
  60. package/dist/docs/service-accounts.md +64 -64
  61. package/dist/docs/standard-query.md +196 -187
  62. package/dist/docs/tag-codes.md +97 -97
  63. package/dist/docs/tag-ranges.md +106 -106
  64. package/dist/docs/theme-tokens.md +252 -252
  65. package/dist/docs/upgrading-to-3.md +550 -532
  66. package/dist/docs/wallet-passes.md +107 -107
  67. package/dist/docs/websites.md +123 -123
  68. package/dist/http.d.ts +6 -3
  69. package/dist/http.js +48 -19
  70. package/dist/iframeResponder.d.ts +7 -0
  71. package/dist/iframeResponder.js +10 -0
  72. package/dist/index.d.ts +2 -0
  73. package/dist/index.js +2 -0
  74. package/dist/openapi.yaml +426 -3
  75. package/dist/testing/bookingsMemory.d.ts +29 -1
  76. package/dist/testing/bookingsMemory.js +89 -1
  77. package/dist/testing/index.js +4 -1
  78. package/dist/theme-boot.js +82 -82
  79. package/dist/theme.css +75 -75
  80. package/dist/types/appManifest.d.ts +26 -4
  81. package/dist/types/bookings.d.ts +99 -1
  82. package/dist/types/index.d.ts +1 -0
  83. package/dist/types/index.js +1 -0
  84. package/dist/types/payments.d.ts +101 -0
  85. package/dist/types/payments.js +5 -0
  86. package/dist/types/realtime.d.ts +5 -1
  87. package/dist/version.d.ts +1 -1
  88. package/dist/version.js +1 -1
  89. package/docs/API_SUMMARY.md +1086 -858
  90. package/docs/admin-cards.md +189 -189
  91. package/docs/agent-tools.md +156 -156
  92. package/docs/ai-tools-and-skills.md +180 -180
  93. package/docs/ai.md +1721 -1721
  94. package/docs/api-versions.md +85 -85
  95. package/docs/app-data-storage.md +277 -277
  96. package/docs/app-docs.md +73 -73
  97. package/docs/app-manifest.md +852 -852
  98. package/docs/app-records-pattern.md +388 -388
  99. package/docs/appConfig.md +550 -550
  100. package/docs/assistant-apps.md +172 -172
  101. package/docs/assistant-context.md +119 -119
  102. package/docs/bookings.md +105 -8
  103. package/docs/caching.md +32 -3
  104. package/docs/comms.md +689 -689
  105. package/docs/connectors.md +340 -340
  106. package/docs/css-baseline.md +133 -133
  107. package/docs/customer-guide.md +70 -70
  108. package/docs/data-changed.md +91 -0
  109. package/docs/deploying-apps.md +340 -340
  110. package/docs/dpp.md +115 -115
  111. package/docs/entitlements.md +90 -90
  112. package/docs/files.md +69 -69
  113. package/docs/host-dependency-contract.md +252 -252
  114. package/docs/iframe-responder.md +11 -0
  115. package/docs/integrations.md +322 -322
  116. package/docs/interactions.md +544 -544
  117. package/docs/item-context.md +181 -181
  118. package/docs/knowledge.md +105 -105
  119. package/docs/lists.md +157 -157
  120. package/docs/lots.md +112 -112
  121. package/docs/loyalty.md +348 -348
  122. package/docs/members.md +183 -183
  123. package/docs/memberships.md +150 -150
  124. package/docs/mobile-admin-container.md +693 -693
  125. package/docs/operations.md +281 -281
  126. package/docs/overview.md +487 -485
  127. package/docs/payments.md +94 -0
  128. package/docs/proof-comms-triggers.md +142 -142
  129. package/docs/proof-ownership-transfer.md +155 -155
  130. package/docs/proof-product-data-scoping.md +462 -462
  131. package/docs/proof-share-grants.md +305 -305
  132. package/docs/realtime.md +149 -139
  133. package/docs/service-accounts.md +64 -64
  134. package/docs/standard-query.md +196 -187
  135. package/docs/tag-codes.md +97 -97
  136. package/docs/tag-ranges.md +106 -106
  137. package/docs/theme-lookbook.v1.json +120 -120
  138. package/docs/theme-tokens.md +252 -252
  139. package/docs/upgrading-to-3.md +550 -532
  140. package/docs/wallet-passes.md +107 -107
  141. package/docs/websites.md +123 -123
  142. package/openapi.yaml +426 -3
  143. package/package.json +91 -91
  144. package/scripts/headless-check.mjs +87 -87
  145. package/scripts/lib/bare-imports.mjs +57 -57
  146. package/scripts/lib/keyed-app-data.mjs +21 -21
  147. package/scripts/lib/upgrade.mjs +708 -668
  148. package/scripts/publish.mjs +272 -272
  149. package/scripts/register-release.mjs +91 -91
  150. package/scripts/upgrade.mjs +79 -79
  151. package/upgrade/3.json +2 -2
@@ -1,82 +1,82 @@
1
- /* @proveanything/smartlinks/theme-boot.js — iframe theme + viewer-prefs bootstrap (theme tokens v1)
2
- *
3
- * ONLY for iframe / standalone app entries (admin.html, index.html). Container & widget apps do NOT
4
- * need this — they inherit the host's :root tokens through the DOM. See docs/theme-tokens.md.
5
- *
6
- * What it does, and nothing more:
7
- * 1. BOOT (synchronous, before first paint): reads the initial theme + viewer prefs from the URL
8
- * (`#slt=<base64url JSON>` plus convenience params ?theme=&contrast=&lang=&fontScale=) and applies
9
- * them to :root. Put this in <head>, inline, so it runs before the app's stylesheet — no flash.
10
- * 2. LIVE: applies generic root-state updates the host posts (`smartlinks:root-state`) — viewer /
11
- * accessibility prefs (dark, contrast, font-scale, lang) and, if the host chooses, editor
12
- * brand-preview. The app AUTHORS CSS against these root hooks; it never writes a message handler.
13
- *
14
- * Root hooks the app styles against:
15
- * - theme: the `.dark` class (Tailwind/shadcn convention) AND `[data-theme="dark|light"]`
16
- * - contrast: `[data-contrast="high"]` (also honour @media (prefers-contrast: more) natively)
17
- * - font size: `--sl-font-scale` (e.g. 1.25) — scale your rem/base type off it
18
- * - language: `lang` attribute, and `dir` (rtl for Arabic, Hebrew, ...; use start/end CSS so it mirrors)
19
- * - brand: the --sl-* theme tokens (see theme.css)
20
- *
21
- * Brand THEME changes are expected via iframe reload (rare, operator-driven). Viewer / a11y prefs are
22
- * applied LIVE here (a reload on an accessibility toggle is itself an accessibility failure).
23
- */
24
- (function () {
25
- if (typeof document === 'undefined') return;
26
- var root = document.documentElement;
27
-
28
- function setVar(k, val) {
29
- root.style.setProperty(k.charAt(0) === '-' ? k : '--sl-' + k, String(val));
30
- }
31
- function applyTheme(mode) { // 'dark' | 'light'
32
- if (!mode) return;
33
- root.classList.toggle('dark', mode === 'dark');
34
- root.setAttribute('data-theme', mode);
35
- }
36
- function applyState(s) {
37
- if (!s || typeof s !== 'object') return;
38
- var v = s.values || s.vars;
39
- if (v) for (var k in v) if (Object.prototype.hasOwnProperty.call(v, k)) setVar(k, v[k]);
40
- if (s.theme) applyTheme(s.theme);
41
- if (s.contrast != null) {
42
- if (s.contrast === 'normal' || s.contrast === false) root.removeAttribute('data-contrast');
43
- else root.setAttribute('data-contrast', String(s.contrast));
44
- }
45
- if (s.fontScale != null) setVar('font-scale', s.fontScale);
46
- if (s.lang) {
47
- root.setAttribute('lang', String(s.lang));
48
- // Right-to-left languages mirror the page (Arabic, Hebrew, Persian, Urdu, ...); see i18n.textDirection.
49
- root.setAttribute('dir', /^(ar|he|iw|fa|ur|ps|yi|dv|ckb|sd|ug)(-|$)/i.test(String(s.lang)) ? 'rtl' : 'ltr');
50
- }
51
- var a = s.attrs;
52
- if (a) for (var name in a) if (Object.prototype.hasOwnProperty.call(a, name)) {
53
- if (a[name] == null || a[name] === false) root.removeAttribute(name);
54
- else root.setAttribute(name, a[name] === true ? '' : String(a[name]));
55
- }
56
- }
57
-
58
- // 1) BOOT from the URL — synchronous, before paint.
59
- try {
60
- var hash = location.hash || '';
61
- var m = hash.match(/[#&]slt=([^&]+)/);
62
- if (m) {
63
- var b64 = m[1].replace(/-/g, '+').replace(/_/g, '/');
64
- applyState(JSON.parse(decodeURIComponent(escape(atob(b64)))));
65
- }
66
- var q = new URLSearchParams(location.search);
67
- var boot = {};
68
- if (q.get('theme')) boot.theme = q.get('theme');
69
- if (q.get('contrast')) boot.contrast = q.get('contrast');
70
- if (q.get('lang')) boot.lang = q.get('lang');
71
- if (q.get('fontScale')) boot.fontScale = q.get('fontScale');
72
- applyState(boot);
73
- } catch (e) { /* never block the app on a malformed theme payload */ }
74
-
75
- // 2) LIVE updates — generic; the app never writes this.
76
- try {
77
- window.addEventListener('message', function (e) {
78
- var d = e && e.data;
79
- if (d && d.type === 'smartlinks:root-state') applyState(d);
80
- });
81
- } catch (e) {}
82
- })();
1
+ /* @proveanything/smartlinks/theme-boot.js — iframe theme + viewer-prefs bootstrap (theme tokens v1)
2
+ *
3
+ * ONLY for iframe / standalone app entries (admin.html, index.html). Container & widget apps do NOT
4
+ * need this — they inherit the host's :root tokens through the DOM. See docs/theme-tokens.md.
5
+ *
6
+ * What it does, and nothing more:
7
+ * 1. BOOT (synchronous, before first paint): reads the initial theme + viewer prefs from the URL
8
+ * (`#slt=<base64url JSON>` plus convenience params ?theme=&contrast=&lang=&fontScale=) and applies
9
+ * them to :root. Put this in <head>, inline, so it runs before the app's stylesheet — no flash.
10
+ * 2. LIVE: applies generic root-state updates the host posts (`smartlinks:root-state`) — viewer /
11
+ * accessibility prefs (dark, contrast, font-scale, lang) and, if the host chooses, editor
12
+ * brand-preview. The app AUTHORS CSS against these root hooks; it never writes a message handler.
13
+ *
14
+ * Root hooks the app styles against:
15
+ * - theme: the `.dark` class (Tailwind/shadcn convention) AND `[data-theme="dark|light"]`
16
+ * - contrast: `[data-contrast="high"]` (also honour @media (prefers-contrast: more) natively)
17
+ * - font size: `--sl-font-scale` (e.g. 1.25) — scale your rem/base type off it
18
+ * - language: `lang` attribute, and `dir` (rtl for Arabic, Hebrew, ...; use start/end CSS so it mirrors)
19
+ * - brand: the --sl-* theme tokens (see theme.css)
20
+ *
21
+ * Brand THEME changes are expected via iframe reload (rare, operator-driven). Viewer / a11y prefs are
22
+ * applied LIVE here (a reload on an accessibility toggle is itself an accessibility failure).
23
+ */
24
+ (function () {
25
+ if (typeof document === 'undefined') return;
26
+ var root = document.documentElement;
27
+
28
+ function setVar(k, val) {
29
+ root.style.setProperty(k.charAt(0) === '-' ? k : '--sl-' + k, String(val));
30
+ }
31
+ function applyTheme(mode) { // 'dark' | 'light'
32
+ if (!mode) return;
33
+ root.classList.toggle('dark', mode === 'dark');
34
+ root.setAttribute('data-theme', mode);
35
+ }
36
+ function applyState(s) {
37
+ if (!s || typeof s !== 'object') return;
38
+ var v = s.values || s.vars;
39
+ if (v) for (var k in v) if (Object.prototype.hasOwnProperty.call(v, k)) setVar(k, v[k]);
40
+ if (s.theme) applyTheme(s.theme);
41
+ if (s.contrast != null) {
42
+ if (s.contrast === 'normal' || s.contrast === false) root.removeAttribute('data-contrast');
43
+ else root.setAttribute('data-contrast', String(s.contrast));
44
+ }
45
+ if (s.fontScale != null) setVar('font-scale', s.fontScale);
46
+ if (s.lang) {
47
+ root.setAttribute('lang', String(s.lang));
48
+ // Right-to-left languages mirror the page (Arabic, Hebrew, Persian, Urdu, ...); see i18n.textDirection.
49
+ root.setAttribute('dir', /^(ar|he|iw|fa|ur|ps|yi|dv|ckb|sd|ug)(-|$)/i.test(String(s.lang)) ? 'rtl' : 'ltr');
50
+ }
51
+ var a = s.attrs;
52
+ if (a) for (var name in a) if (Object.prototype.hasOwnProperty.call(a, name)) {
53
+ if (a[name] == null || a[name] === false) root.removeAttribute(name);
54
+ else root.setAttribute(name, a[name] === true ? '' : String(a[name]));
55
+ }
56
+ }
57
+
58
+ // 1) BOOT from the URL — synchronous, before paint.
59
+ try {
60
+ var hash = location.hash || '';
61
+ var m = hash.match(/[#&]slt=([^&]+)/);
62
+ if (m) {
63
+ var b64 = m[1].replace(/-/g, '+').replace(/_/g, '/');
64
+ applyState(JSON.parse(decodeURIComponent(escape(atob(b64)))));
65
+ }
66
+ var q = new URLSearchParams(location.search);
67
+ var boot = {};
68
+ if (q.get('theme')) boot.theme = q.get('theme');
69
+ if (q.get('contrast')) boot.contrast = q.get('contrast');
70
+ if (q.get('lang')) boot.lang = q.get('lang');
71
+ if (q.get('fontScale')) boot.fontScale = q.get('fontScale');
72
+ applyState(boot);
73
+ } catch (e) { /* never block the app on a malformed theme payload */ }
74
+
75
+ // 2) LIVE updates — generic; the app never writes this.
76
+ try {
77
+ window.addEventListener('message', function (e) {
78
+ var d = e && e.data;
79
+ if (d && d.type === 'smartlinks:root-state') applyState(d);
80
+ });
81
+ } catch (e) {}
82
+ })();
package/dist/theme.css CHANGED
@@ -1,75 +1,75 @@
1
- /* @proveanything/smartlinks/theme.css — SmartLinks host theming preset (theme tokens v1)
2
- *
3
- * Maps Tailwind 4's design tokens onto the SmartLinks semantic theme tokens (--sl-color-*,
4
- * --sl-radius-*, --sl-font-*) that the host sets on each app's mount root. After importing this,
5
- * an app's `bg-primary` / `text-foreground` / `border-border` / `rounded-md` / `font-heading`
6
- * resolve to whatever brand the host is running — no per-app mapping, no hardcoded palette.
7
- *
8
- * app styles.css:
9
- * @import "tailwindcss";
10
- * @import "@proveanything/smartlinks/theme.css";
11
- *
12
- * Requires Tailwind 4 (@theme). Every value has a neutral fallback, so the app renders correctly
13
- * even against a host that sets none of the --sl-* tokens. See docs/theme-tokens.md.
14
- */
15
-
16
- @theme {
17
- /* ── Colour (semantic roles) ─────────────────────────────────────────── */
18
- --color-background: var(--sl-color-bg, #ffffff);
19
- --color-surface: var(--sl-color-surface, #f7f7f8);
20
- --color-surface-raised:var(--sl-color-surface-raised, var(--sl-color-surface, #ffffff));
21
- --color-foreground: var(--sl-color-fg, #18181b);
22
- --color-muted: var(--sl-color-muted, #71717a);
23
- --color-border: var(--sl-color-border, #e4e4e7);
24
- --color-primary: var(--sl-color-accent, #4f46e5);
25
- --color-on-primary: var(--sl-color-on-accent, #ffffff);
26
- --color-primary-soft: var(--sl-color-accent-soft, color-mix(in oklab, var(--sl-color-accent, #4f46e5) 12%, transparent));
27
- --color-success: var(--sl-color-success, #16a34a);
28
- --color-danger: var(--sl-color-danger, #dc2626);
29
-
30
- /* ── Shape ───────────────────────────────────────────────────────────── */
31
- --radius-sm: var(--sl-radius-sm, 4px);
32
- --radius-md: var(--sl-radius-md, 8px);
33
- --radius-lg: var(--sl-radius-lg, 16px);
34
-
35
- /* ── Type ────────────────────────────────────────────────────────────── */
36
- --font-heading: var(--sl-font-heading, var(--sl-font-body, ui-sans-serif, system-ui, sans-serif));
37
- --font-body: var(--sl-font-body, ui-sans-serif, system-ui, sans-serif);
38
-
39
- /* ── Elevation (extended; no shadow unless the host sets one) ─────────── */
40
- --shadow-sm: var(--sl-shadow-sm, 0 0 #0000);
41
- --shadow-md: var(--sl-shadow-md, 0 0 #0000);
42
- }
43
-
44
- /* Dark mode without values. A host in dark mode should send a dark value-set (the --sl-* tokens); one
45
- * that only sets the hook (.dark / data-theme="dark") left every colour on its light fallback — white
46
- * cards and near-black text on a dark page. Under the hook the fallbacks are dark too; whatever the host
47
- * does send still wins. (Re-declared on the hook's element, so it works wherever the host puts it.) */
48
- .dark,
49
- [data-theme="dark"] {
50
- --color-background: var(--sl-color-bg, #09090b);
51
- --color-surface: var(--sl-color-surface, #18181b);
52
- --color-surface-raised:var(--sl-color-surface-raised, var(--sl-color-surface, #27272a));
53
- --color-foreground: var(--sl-color-fg, #fafafa);
54
- --color-muted: var(--sl-color-muted, #a1a1aa);
55
- --color-border: var(--sl-color-border, #3f3f46);
56
- --color-primary: var(--sl-color-accent, #6366f1);
57
- --color-on-primary: var(--sl-color-on-accent, #ffffff);
58
- --color-primary-soft: var(--sl-color-accent-soft, color-mix(in oklab, var(--sl-color-accent, #6366f1) 20%, transparent));
59
- --color-success: var(--sl-color-success, #22c55e);
60
- --color-danger: var(--sl-color-danger, #f87171);
61
- color-scheme: dark;
62
- }
63
-
64
- /* shadcn bridge (optional): if the app uses shadcn's --primary/--background/etc. HSL variables,
65
- * uncomment to drive them from the SmartLinks tokens too. Left commented so it never overrides an
66
- * app that has deliberately customised its shadcn palette — opt in per app (see migration step 17).
67
- *
68
- * :where([data-sl-app]) {
69
- * --primary: var(--sl-color-accent);
70
- * --background: var(--sl-color-bg);
71
- * --foreground: var(--sl-color-fg);
72
- * --border: var(--sl-color-border);
73
- * --radius: var(--sl-radius-md);
74
- * }
75
- */
1
+ /* @proveanything/smartlinks/theme.css — SmartLinks host theming preset (theme tokens v1)
2
+ *
3
+ * Maps Tailwind 4's design tokens onto the SmartLinks semantic theme tokens (--sl-color-*,
4
+ * --sl-radius-*, --sl-font-*) that the host sets on each app's mount root. After importing this,
5
+ * an app's `bg-primary` / `text-foreground` / `border-border` / `rounded-md` / `font-heading`
6
+ * resolve to whatever brand the host is running — no per-app mapping, no hardcoded palette.
7
+ *
8
+ * app styles.css:
9
+ * @import "tailwindcss";
10
+ * @import "@proveanything/smartlinks/theme.css";
11
+ *
12
+ * Requires Tailwind 4 (@theme). Every value has a neutral fallback, so the app renders correctly
13
+ * even against a host that sets none of the --sl-* tokens. See docs/theme-tokens.md.
14
+ */
15
+
16
+ @theme {
17
+ /* ── Colour (semantic roles) ─────────────────────────────────────────── */
18
+ --color-background: var(--sl-color-bg, #ffffff);
19
+ --color-surface: var(--sl-color-surface, #f7f7f8);
20
+ --color-surface-raised:var(--sl-color-surface-raised, var(--sl-color-surface, #ffffff));
21
+ --color-foreground: var(--sl-color-fg, #18181b);
22
+ --color-muted: var(--sl-color-muted, #71717a);
23
+ --color-border: var(--sl-color-border, #e4e4e7);
24
+ --color-primary: var(--sl-color-accent, #4f46e5);
25
+ --color-on-primary: var(--sl-color-on-accent, #ffffff);
26
+ --color-primary-soft: var(--sl-color-accent-soft, color-mix(in oklab, var(--sl-color-accent, #4f46e5) 12%, transparent));
27
+ --color-success: var(--sl-color-success, #16a34a);
28
+ --color-danger: var(--sl-color-danger, #dc2626);
29
+
30
+ /* ── Shape ───────────────────────────────────────────────────────────── */
31
+ --radius-sm: var(--sl-radius-sm, 4px);
32
+ --radius-md: var(--sl-radius-md, 8px);
33
+ --radius-lg: var(--sl-radius-lg, 16px);
34
+
35
+ /* ── Type ────────────────────────────────────────────────────────────── */
36
+ --font-heading: var(--sl-font-heading, var(--sl-font-body, ui-sans-serif, system-ui, sans-serif));
37
+ --font-body: var(--sl-font-body, ui-sans-serif, system-ui, sans-serif);
38
+
39
+ /* ── Elevation (extended; no shadow unless the host sets one) ─────────── */
40
+ --shadow-sm: var(--sl-shadow-sm, 0 0 #0000);
41
+ --shadow-md: var(--sl-shadow-md, 0 0 #0000);
42
+ }
43
+
44
+ /* Dark mode without values. A host in dark mode should send a dark value-set (the --sl-* tokens); one
45
+ * that only sets the hook (.dark / data-theme="dark") left every colour on its light fallback — white
46
+ * cards and near-black text on a dark page. Under the hook the fallbacks are dark too; whatever the host
47
+ * does send still wins. (Re-declared on the hook's element, so it works wherever the host puts it.) */
48
+ .dark,
49
+ [data-theme="dark"] {
50
+ --color-background: var(--sl-color-bg, #09090b);
51
+ --color-surface: var(--sl-color-surface, #18181b);
52
+ --color-surface-raised:var(--sl-color-surface-raised, var(--sl-color-surface, #27272a));
53
+ --color-foreground: var(--sl-color-fg, #fafafa);
54
+ --color-muted: var(--sl-color-muted, #a1a1aa);
55
+ --color-border: var(--sl-color-border, #3f3f46);
56
+ --color-primary: var(--sl-color-accent, #6366f1);
57
+ --color-on-primary: var(--sl-color-on-accent, #ffffff);
58
+ --color-primary-soft: var(--sl-color-accent-soft, color-mix(in oklab, var(--sl-color-accent, #6366f1) 20%, transparent));
59
+ --color-success: var(--sl-color-success, #22c55e);
60
+ --color-danger: var(--sl-color-danger, #f87171);
61
+ color-scheme: dark;
62
+ }
63
+
64
+ /* shadcn bridge (optional): if the app uses shadcn's --primary/--background/etc. HSL variables,
65
+ * uncomment to drive them from the SmartLinks tokens too. Left commented so it never overrides an
66
+ * app that has deliberately customised its shadcn palette — opt in per app (see migration step 17).
67
+ *
68
+ * :where([data-sl-app]) {
69
+ * --primary: var(--sl-color-accent);
70
+ * --background: var(--sl-color-bg);
71
+ * --foreground: var(--sl-color-fg);
72
+ * --border: var(--sl-color-border);
73
+ * --radius: var(--sl-radius-md);
74
+ * }
75
+ */
@@ -6,7 +6,7 @@ import type { AppManifestAdminCards } from './adminCards.js';
6
6
  import type { PaginatedResponse } from './appObjects.js';
7
7
  import type { TypedMessage, MessageAbout, EmailAttachmentSpec } from './comms.js';
8
8
  import type { WorkOrdersApi, StockApi, BomsApi, MadeFromApi, OperationsApi } from './operations.js';
9
- import type { Booking, BookingSlot, BookingAllocation, CreateBookingInput, UpdateBookingInput, MoveBookingInput, BookingListQueryParams, CreateSlotInput, UpdateSlotInput, SlotListQueryParams, CreateBlockInput, BlockListQueryParams, FreeBusyQuery, FreeBusyResponse, MessageBookersInput, MessageBookersResult } from './bookings.js';
9
+ import type { Booking, BookingSlot, BookingAllocation, CreateBookingInput, BookingCheckoutInput, BookingCheckoutResult, UpdateBookingInput, MoveBookingInput, BookingListQueryParams, CreateSlotInput, UpdateSlotInput, SlotListQueryParams, CreateBlockInput, BlockListQueryParams, FreeBusyQuery, FreeBusyResponse, MessageBookersInput, MessageBookersResult } from './bookings.js';
10
10
  /**
11
11
  * A bundle (widget or container) as returned by the collection widgets endpoint.
12
12
  *
@@ -464,12 +464,34 @@ export interface ServerFunctionBookings {
464
464
  /** The signed-in caller's own bookings (empty when anonymous). */
465
465
  mine(params?: BookingListQueryParams): Promise<PaginatedResponse<Booking>>;
466
466
  update(bookingId: string, fields: UpdateBookingInput): Promise<Booking>;
467
- /** held / pending / waitlisted → confirmed (idempotent). */
468
- confirm(bookingId: string): Promise<Booking>;
469
- /** Cancel and give the places back (idempotent). */
467
+ /**
468
+ * held / pending / waitlisted → confirmed (idempotent). A booking waiting for its payment: a request
469
+ * becomes a hold with a pay link; `{ payment: 'waive' }` confirms without payment.
470
+ */
471
+ confirm(bookingId: string, opts?: {
472
+ payment?: 'waive';
473
+ }): Promise<Booking>;
474
+ /** Cancel and give the places back (idempotent). A paid booking is refunded: 'full' (default) | 'none' | an amount. */
470
475
  cancel(bookingId: string, opts?: {
471
476
  reason?: string;
477
+ refund?: 'full' | 'none' | number;
472
478
  }): Promise<Booking>;
479
+ /**
480
+ * Book and pay (docs/bookings.md, "Paid bookings"): held while the person pays on Stripe
481
+ * (`status: 'held'`, the default), or a priced request (`status: 'pending'`). → `checkoutUrl` to send them to.
482
+ */
483
+ checkout(input: BookingCheckoutInput): Promise<Omit<BookingCheckoutResult, 'editToken'> & {
484
+ replayed?: boolean;
485
+ }>;
486
+ /** Refund a paid booking without cancelling it: all that's left, or `amount` (minor units). */
487
+ refund(bookingId: string, opts?: {
488
+ amount?: number;
489
+ reason?: string;
490
+ }): Promise<{
491
+ booking: Booking;
492
+ refunded: number;
493
+ pending: boolean;
494
+ }>;
473
495
  /** All-or-nothing move to new claims. */
474
496
  move(bookingId: string, input: MoveBookingInput): Promise<Booking>;
475
497
  extendHold(bookingId: string, holdMinutes: number): Promise<Booking>;
@@ -58,6 +58,8 @@ export interface Booking {
58
58
  * Returned ONCE — store it to let the guest view / cancel / move / confirm their booking.
59
59
  */
60
60
  editToken?: string;
61
+ /** A paid booking's payment (read-only; absent when the booking has none). See "Paid bookings". */
62
+ payment?: BookingPayment;
61
63
  }
62
64
  export interface BookingSlot {
63
65
  id: string;
@@ -330,7 +332,7 @@ export type SlotList = ListResult<BookingSlot>;
330
332
  /** What `bookings.blocks.list` returns. */
331
333
  export type BlockList = ListResult<BookingAllocation>;
332
334
  /** Error codes a booking call can fail with (HTTP 409 unless noted). */
333
- export type BookingErrorCode = 'SLOT_FULL' | 'SLOT_CLOSED' | 'RESOURCE_TAKEN' | 'PER_CONTACT_LIMIT' | 'QUANTITY_LIMIT' | 'HOLD_EXPIRED' | 'INVALID_STATE' | 'SLOT_OVERBOOKED' | 'SLOT_HAS_BOOKINGS' | 'TOO_SOON' | 'TOO_FAR_AHEAD' | 'IN_THE_PAST' | 'DURATION_NOT_ALLOWED' | 'OUTSIDE_SCHEDULE' | 'NO_SCHEDULE' | 'SCHEDULE_INVALID' | 'CUTOFF_PASSED' | 'FORBIDDEN' | 'NOT_FOUND' | 'BAD_REQUEST';
335
+ export type BookingErrorCode = 'SLOT_FULL' | 'SLOT_CLOSED' | 'RESOURCE_TAKEN' | 'PER_CONTACT_LIMIT' | 'QUANTITY_LIMIT' | 'HOLD_EXPIRED' | 'INVALID_STATE' | 'SLOT_OVERBOOKED' | 'SLOT_HAS_BOOKINGS' | 'TOO_SOON' | 'TOO_FAR_AHEAD' | 'IN_THE_PAST' | 'DURATION_NOT_ALLOWED' | 'OUTSIDE_SCHEDULE' | 'NO_SCHEDULE' | 'SCHEDULE_INVALID' | 'CUTOFF_PASSED' | 'FORBIDDEN' | 'NOT_FOUND' | 'BAD_REQUEST' | 'PAYMENT_REQUIRED' | 'PAYMENTS_NOT_READY' | 'PRICE_MISMATCH' | 'NOT_PAID' | 'PRICE_NOT_FOUND' | 'PAYMENT_REFUSED' | 'PAYMENTS_NOT_CONFIGURED';
334
336
  export interface ScheduleHours {
335
337
  /** 'HH:MM' (24h) */
336
338
  start: string;
@@ -355,3 +357,99 @@ export interface StandardSchedule {
355
357
  /** Dated exceptions; the last matching one wins over `weekly`. */
356
358
  overrides?: ScheduleOverride[];
357
359
  }
360
+ /** One priced line of a paid booking. Amounts are minor units (pence, cents). */
361
+ export interface BookingPaymentLine {
362
+ priceId: string;
363
+ label: string;
364
+ unitAmount: number;
365
+ quantity: number;
366
+ }
367
+ /** A booking's payment, as every booking response shows it (built from the server's own record). */
368
+ export interface BookingPayment {
369
+ status: 'awaiting' | 'paid' | 'partially_refunded' | 'refunded' | 'waived';
370
+ total: number;
371
+ currency: string;
372
+ refunded: number;
373
+ lines: BookingPaymentLine[];
374
+ paidAt?: string;
375
+ /** An approved request: pay by then, or the place goes back. */
376
+ payBy?: string;
377
+ /** An approved request waiting for its payment. */
378
+ requested?: boolean;
379
+ /** The pay link of an approved request (the booker and staff only). */
380
+ link?: string;
381
+ }
382
+ /** A price, in a slot's `data.prices` (ticket types) or the app's `bookingPayments.prices` (services). */
383
+ export interface BookingPrice {
384
+ id: string;
385
+ label: string;
386
+ /** Minor units (pence). 0 = free. */
387
+ amount: number;
388
+ /** Appointments: the booked length must be this. */
389
+ durationMinutes?: number;
390
+ /** Appointments: only these resources (staff, rooms) offer it; empty = all. */
391
+ resourceIds?: string[];
392
+ }
393
+ /** The app's `bookingPayments` config (sites/{collectionId}/apps/{appId}), written by admins only. */
394
+ export interface BookingPaymentsConfig {
395
+ /** Close the free way in: a plain create of a priced booking fails with PAYMENT_REQUIRED. */
396
+ required?: boolean;
397
+ currency?: string;
398
+ /** Appointments' price list (slots carry their own `data.prices`). */
399
+ prices?: BookingPrice[];
400
+ /** How long the person has on Stripe's page, 30–120 (default 30). The place is held 10 minutes longer. */
401
+ sessionMinutes?: number;
402
+ /** The booker cancelling a paid booking: 'full' refund (default) or 'none'. */
403
+ ownerCancelRefund?: 'full' | 'none';
404
+ /** Requests: hours to pay once approved, 1–168 (default 48). */
405
+ payWithinHours?: number;
406
+ /** Where Stripe sends the person back; `{CHECKOUT_SESSION_ID}` (or `session_id` added) for bySession. */
407
+ successUrl?: string;
408
+ cancelUrl?: string;
409
+ /** Other hosts a page may pass as successUrl / cancelUrl. */
410
+ allowedHosts?: string[];
411
+ }
412
+ export interface BookingPriceLine {
413
+ priceId: string;
414
+ quantity?: number;
415
+ }
416
+ export interface BookingCheckoutInput extends CreateBookingInput {
417
+ /** Ticket types on a slot: the quantities add up to the places taken. */
418
+ lines?: BookingPriceLine[];
419
+ /** An appointment's service (from the price list), or a slot's only ticket type. */
420
+ priceId?: string;
421
+ /** For Stripe's receipt. */
422
+ email?: string;
423
+ /** Default: the app's bookingPayments.successUrl / cancelUrl. Must be on the business's own hosts. */
424
+ successUrl?: string;
425
+ cancelUrl?: string;
426
+ /** A guest's details (as for create): gives them a contact for the confirmation email. */
427
+ customer?: {
428
+ email?: string;
429
+ phone?: string;
430
+ name?: string;
431
+ [k: string]: any;
432
+ };
433
+ }
434
+ export interface BookingCheckoutResult {
435
+ booking: Booking;
436
+ /** Anonymous guests, once (as for create). */
437
+ editToken?: string;
438
+ /** Go here to pay. null for a free booking, or a request (pay link once approved). */
439
+ checkoutUrl: string | null;
440
+ expiresAt: string | null;
441
+ /** Minor units; 0 when free. */
442
+ total: number;
443
+ currency: string | null;
444
+ /** A request waiting for approval: "we'll email you a link to pay once it's confirmed". */
445
+ request?: boolean;
446
+ }
447
+ export interface BookingPayLinkResult {
448
+ checkoutUrl?: string;
449
+ done?: 'paid' | 'closed';
450
+ url?: string | null;
451
+ }
452
+ export type BookingRefundResult = Booking & {
453
+ refunded: number;
454
+ refundPending: boolean;
455
+ };
@@ -45,6 +45,7 @@ export * from "./appManifest.js";
45
45
  export * from "./appObjects.js";
46
46
  export * from "./bookings.js";
47
47
  export * from "./shop.js";
48
+ export * from "./payments.js";
48
49
  export * from "./subscriptions.js";
49
50
  export * from "./loyalty.js";
50
51
  export * from "./translations.js";
@@ -47,6 +47,7 @@ export * from "./appManifest.js";
47
47
  export * from "./appObjects.js";
48
48
  export * from "./bookings.js";
49
49
  export * from "./shop.js";
50
+ export * from "./payments.js";
50
51
  export * from "./subscriptions.js";
51
52
  export * from "./loyalty.js";
52
53
  export * from "./translations.js";
@@ -0,0 +1,101 @@
1
+ /** What a page needs before it shows a payment form. */
2
+ export interface PaymentsPublicConfig {
3
+ /** True when the business has connected Stripe and this server can take payments. */
4
+ ready: boolean;
5
+ /** SmartLinks' Stripe publishable key: `loadStripe(publishableKey, { stripeAccount: accountId })`. */
6
+ publishableKey: string | null;
7
+ /** The business's connected Stripe account. */
8
+ accountId: string | null;
9
+ }
10
+ export interface PaymentIntentInput {
11
+ /** The app taking the payment. It must be installed and switched on in the collection. */
12
+ appId: string;
13
+ /** Minor units (pence, cents), a whole number: 500 = £5.00. */
14
+ amount: number;
15
+ /** Three-letter code: 'GBP'. */
16
+ currency: string;
17
+ /** Stripe emails its receipt here. */
18
+ email?: string;
19
+ /** Shown in the business's Stripe dashboard and on Stripe's receipt. */
20
+ description?: string;
21
+ /** Your own reference (a campaign, a ticket batch), kept on the payment as metadata.reference. */
22
+ reference?: string;
23
+ /** Up to 15 of your own values (strings or numbers), kept on the payment. `kind`, `collectionId`, `appId` and `reference` are ours. */
24
+ metadata?: Record<string, string | number | boolean>;
25
+ /** Card only (no Link, no other methods). Apple Pay and Google Pay are cards. */
26
+ cardOnly?: boolean;
27
+ /** The same key twice gives the same payment, not a second one. */
28
+ idempotencyKey?: string;
29
+ }
30
+ export interface PaymentIntentResult {
31
+ paymentIntentId: string;
32
+ /** Pass to Stripe Elements (`elements({ clientSecret })`) or `stripe.confirmPayment`. */
33
+ clientSecret: string;
34
+ publishableKey: string;
35
+ accountId: string;
36
+ amount: number;
37
+ currency: string;
38
+ /** What SmartLinks takes from this payment for this app (minor units). Often 0. */
39
+ fee: number;
40
+ }
41
+ /** The business's payments account, as Studio → Payments shows it. */
42
+ export interface PaymentsStatus {
43
+ connected: boolean;
44
+ accountId?: string;
45
+ /** Stripe can take payments for this business. Null when this server can't ask Stripe. */
46
+ chargesEnabled?: boolean | null;
47
+ /** The business has given Stripe all it asked for. */
48
+ detailsSubmitted?: boolean | null;
49
+ /** Stripe can pay money out to the business's bank. */
50
+ payoutsEnabled?: boolean | null;
51
+ /** This server has SmartLinks' Stripe platform key. */
52
+ platformReady: boolean;
53
+ /** This server can give pages the publishable key (in-page payments). */
54
+ publishableKeySet: boolean;
55
+ /** What SmartLinks takes from each app asked about (`appIds`). */
56
+ fees: Array<{
57
+ appId: string;
58
+ bps: number;
59
+ percent: number;
60
+ }>;
61
+ }
62
+ export interface PaymentsConnectInput {
63
+ /** Where Stripe sends the person back when they finish (or stop): check `payments.admin.status`. */
64
+ returnUrl: string;
65
+ /** Where Stripe sends them if the link ran out: make a new link there. */
66
+ refreshUrl: string;
67
+ /** Two-letter country for a new account ('GB' unless you say). */
68
+ country?: string;
69
+ }
70
+ /** One payment on the business's account. */
71
+ export interface PaymentRecord {
72
+ id: string;
73
+ amount: number;
74
+ amountReceived: number;
75
+ currency: string;
76
+ /** Stripe's status: 'succeeded', 'requires_payment_method', 'processing', 'canceled', … */
77
+ status: string;
78
+ created: string;
79
+ email: string | null;
80
+ metadata: Record<string, string>;
81
+ }
82
+ export interface PaymentListParams {
83
+ appId?: string;
84
+ /** ISO date: only payments made since. */
85
+ since?: string;
86
+ /** Up to 500 (100 unless you say). */
87
+ limit?: number;
88
+ /** The `next` of the previous page. */
89
+ after?: string;
90
+ }
91
+ export interface PaymentList {
92
+ data: PaymentRecord[];
93
+ hasMore: boolean;
94
+ next: string | null;
95
+ }
96
+ export interface PaymentDomainResult {
97
+ domain: string;
98
+ /** Stripe's status for Apple Pay on the domain: 'active', 'inactive', … */
99
+ applePay: string;
100
+ googlePay: string;
101
+ }
@@ -0,0 +1,5 @@
1
+ // src/types/payments.ts
2
+ // Payments: the business's one Stripe Connect account, and in-page payments for any app. See docs/payments.md.
3
+ //
4
+ // Money is always a whole number of MINOR units (pence, cents): 500 = £5.00.
5
+ export {};
@@ -33,6 +33,7 @@ export interface RealtimeChangeEvent {
33
33
  * and, on an app's staff feed (`onStaffChange`): 'workOrder' | 'container' | 'stock'.
34
34
  */
35
35
  type: string;
36
+ /** The thing that changed. Absent when many of this type changed at once (an import): read them all again. */
36
37
  id?: string;
37
38
  appId?: string;
38
39
  recordType?: string;
@@ -44,7 +45,10 @@ export interface RealtimeChangeEvent {
44
45
  kind?: string;
45
46
  at: number;
46
47
  }
47
- /** Which changes to hear about — every field given must match. */
48
+ /**
49
+ * Which changes to hear about — every field given must match. One exception: with `type` and `id`
50
+ * given, a change of that type that names no id ("many changed") is heard too.
51
+ */
48
52
  export interface RealtimeChangeFilter {
49
53
  type?: string;
50
54
  id?: string;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "3.0.0-alpha.2";
1
+ export declare const SDK_VERSION = "3.0.0-alpha.3";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by scripts/write-version.mjs from package.json. Do not edit.
2
- export const SDK_VERSION = "3.0.0-alpha.2";
2
+ export const SDK_VERSION = "3.0.0-alpha.3";