@proveanything/smartlinks 2.1.47 → 2.2.0

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 (131) 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/dpp.d.ts +6 -0
  5. package/dist/api/dpp.js +12 -0
  6. package/dist/api/shop.d.ts +5 -1
  7. package/dist/api/shop.js +7 -7
  8. package/dist/api/subscriptions.d.ts +2 -1
  9. package/dist/api/subscriptions.js +4 -12
  10. package/dist/apiVersion.d.ts +9 -0
  11. package/dist/apiVersion.js +15 -0
  12. package/dist/baseline.css +194 -194
  13. package/dist/docs/API_SUMMARY.md +821 -811
  14. package/dist/docs/admin-cards.md +189 -189
  15. package/dist/docs/agent-tools.md +156 -156
  16. package/dist/docs/ai-tools-and-skills.md +180 -180
  17. package/dist/docs/ai.md +1721 -1721
  18. package/dist/docs/analytics.md +39 -39
  19. package/dist/docs/api-versions.md +76 -0
  20. package/dist/docs/app-data-storage.md +277 -277
  21. package/dist/docs/app-docs.md +73 -73
  22. package/dist/docs/app-manifest.md +852 -852
  23. package/dist/docs/app-records-pattern.md +388 -388
  24. package/dist/docs/appConfig.md +550 -550
  25. package/dist/docs/assistant-apps.md +172 -172
  26. package/dist/docs/assistant-context.md +119 -119
  27. package/dist/docs/bookings.md +442 -442
  28. package/dist/docs/comms.md +686 -686
  29. package/dist/docs/connectors.md +340 -340
  30. package/dist/docs/css-baseline.md +133 -133
  31. package/dist/docs/customer-guide.md +70 -70
  32. package/dist/docs/deploying-apps.md +340 -340
  33. package/dist/docs/dpp.md +115 -99
  34. package/dist/docs/entitlements.md +90 -90
  35. package/dist/docs/files.md +69 -69
  36. package/dist/docs/host-dependency-contract.md +210 -210
  37. package/dist/docs/i18n.md +9 -9
  38. package/dist/docs/integrations.md +322 -322
  39. package/dist/docs/interactions.md +545 -545
  40. package/dist/docs/item-context.md +181 -181
  41. package/dist/docs/knowledge.md +102 -102
  42. package/dist/docs/lots.md +111 -111
  43. package/dist/docs/loyalty.md +352 -352
  44. package/dist/docs/members.md +183 -183
  45. package/dist/docs/memberships.md +149 -149
  46. package/dist/docs/mobile-admin-container.md +693 -693
  47. package/dist/docs/operations.md +281 -281
  48. package/dist/docs/overview.md +485 -485
  49. package/dist/docs/proof-comms-triggers.md +142 -142
  50. package/dist/docs/proof-ownership-transfer.md +155 -155
  51. package/dist/docs/proof-product-data-scoping.md +462 -462
  52. package/dist/docs/proof-share-grants.md +305 -305
  53. package/dist/docs/realtime.md +138 -138
  54. package/dist/docs/records-admin-pattern.md +304 -304
  55. package/dist/docs/server-functions.md +1 -1
  56. package/dist/docs/service-accounts.md +64 -64
  57. package/dist/docs/standard-query.md +187 -187
  58. package/dist/docs/tag-codes.md +97 -97
  59. package/dist/docs/theme-tokens.md +252 -252
  60. package/dist/docs/wallet-passes.md +107 -107
  61. package/dist/docs/websites.md +123 -123
  62. package/dist/http.d.ts +14 -0
  63. package/dist/http.js +65 -3
  64. package/dist/index.d.ts +2 -1
  65. package/dist/index.js +3 -1
  66. package/dist/openapi.yaml +6 -3
  67. package/dist/theme-boot.js +82 -82
  68. package/dist/theme.css +75 -75
  69. package/dist/types/dpp.d.ts +14 -5
  70. package/dist/utils/index.d.ts +1 -0
  71. package/dist/utils/index.js +1 -0
  72. package/dist/utils/money.d.ts +15 -0
  73. package/dist/utils/money.js +72 -0
  74. package/dist/version.d.ts +1 -0
  75. package/dist/version.js +2 -0
  76. package/docs/API_SUMMARY.md +821 -811
  77. package/docs/admin-cards.md +189 -189
  78. package/docs/agent-tools.md +156 -156
  79. package/docs/ai-tools-and-skills.md +180 -180
  80. package/docs/ai.md +1721 -1721
  81. package/docs/analytics.md +39 -39
  82. package/docs/api-versions.md +76 -0
  83. package/docs/app-data-storage.md +277 -277
  84. package/docs/app-docs.md +73 -73
  85. package/docs/app-manifest.md +852 -852
  86. package/docs/app-records-pattern.md +388 -388
  87. package/docs/appConfig.md +550 -550
  88. package/docs/assistant-apps.md +172 -172
  89. package/docs/assistant-context.md +119 -119
  90. package/docs/bookings.md +442 -442
  91. package/docs/comms.md +686 -686
  92. package/docs/connectors.md +340 -340
  93. package/docs/css-baseline.md +133 -133
  94. package/docs/customer-guide.md +70 -70
  95. package/docs/deploying-apps.md +340 -340
  96. package/docs/dpp.md +115 -99
  97. package/docs/entitlements.md +90 -90
  98. package/docs/files.md +69 -69
  99. package/docs/host-dependency-contract.md +210 -210
  100. package/docs/i18n.md +9 -9
  101. package/docs/integrations.md +322 -322
  102. package/docs/interactions.md +545 -545
  103. package/docs/item-context.md +181 -181
  104. package/docs/knowledge.md +102 -102
  105. package/docs/lots.md +111 -111
  106. package/docs/loyalty.md +352 -352
  107. package/docs/members.md +183 -183
  108. package/docs/memberships.md +149 -149
  109. package/docs/mobile-admin-container.md +693 -693
  110. package/docs/operations.md +281 -281
  111. package/docs/overview.md +485 -485
  112. package/docs/proof-comms-triggers.md +142 -142
  113. package/docs/proof-ownership-transfer.md +155 -155
  114. package/docs/proof-product-data-scoping.md +462 -462
  115. package/docs/proof-share-grants.md +305 -305
  116. package/docs/realtime.md +138 -138
  117. package/docs/server-functions.md +1 -1
  118. package/docs/service-accounts.md +64 -64
  119. package/docs/standard-query.md +187 -187
  120. package/docs/tag-codes.md +97 -97
  121. package/docs/theme-lookbook.v1.json +120 -120
  122. package/docs/theme-tokens.md +252 -252
  123. package/docs/wallet-passes.md +107 -107
  124. package/docs/websites.md +123 -123
  125. package/openapi.yaml +6 -3
  126. package/package.json +87 -87
  127. package/scripts/headless-check.mjs +87 -87
  128. package/scripts/lib/bare-imports.mjs +57 -57
  129. package/scripts/lib/keyed-app-data.mjs +21 -21
  130. package/scripts/publish.mjs +272 -272
  131. package/scripts/register-release.mjs +91 -91
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { initializeApi, isInitialized, hasAuthCredentials, configureSdkCache, invalidateCache, getHttpCacheDiagnostics, resetHttpCacheDiagnostics, request, post, put, patch, del, sendCustomProxyMessage, getApiHeaders, getBaseURL, isProxyEnabled, setBearerToken, getBearerToken, setGrantToken, getGrantToken, getAppContext, setAppContext, getAppChannel, setAppChannel } from "./http.js";
1
+ export { initializeApi, isInitialized, hasAuthCredentials, configureSdkCache, invalidateCache, getHttpCacheDiagnostics, resetHttpCacheDiagnostics, request, post, put, patch, del, sendCustomProxyMessage, getApiHeaders, getClientHeaders, getApiVersion, getBaseURL, isProxyEnabled, setBearerToken, getBearerToken, setGrantToken, getGrantToken, getAppContext, setAppContext, getAppChannel, setAppChannel } from "./http.js";
2
2
  export * from "./api/index.js";
3
3
  export * from "./types/index.js";
4
4
  export { iframe } from "./iframe.js";
@@ -23,6 +23,7 @@ export { SHARED_DEPENDENCY_CONTRACT_VERSION, SHARED_DEPENDENCIES, SHARED_DEPENDE
23
23
  export type { SharedDependency, HostSharedDependencies } from './shared-dependencies.js';
24
24
  export type { GuideSurface, GuideInfo, ScreenContent, GuideWhere, GuideNavigate, GuideCard, GuideStartOptions } from './api/aiGuide.js';
25
25
  export type { LiveState, LiveHandle, LiveOptions, LiveEndpoints, LiveEvent, LiveMintReply, LiveToolReply, LiveToolHandler } from './live.js';
26
+ export { API_VERSION, SDK_VERSION, API_VERSION_HEADER, SDK_HEADER, APP_HEADER, CLIENT_HEADER_NAMES } from './apiVersion.js';
26
27
  export { AI_TOOL_NAMES, BUILTIN_AI_TOOLS, getBuiltinAiTool } from './ai-tools.js';
27
28
  export type { BuiltinAiToolDescriptor } from './ai-tools.js';
28
29
  export type { PortalPathParams, Gs1DigitalLinkParams, ConditionParams, ConditionDebugOptions, ConditionDebugLogger, ConditionSet, Condition, UserInfo, ProductInfo, ProofInfo, CollectionInfo, } from './utils/index.js';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/index.ts
2
2
  // Top-level entrypoint of the npm package. Re-export initializeApi + all namespaces.
3
- export { initializeApi, isInitialized, hasAuthCredentials, configureSdkCache, invalidateCache, getHttpCacheDiagnostics, resetHttpCacheDiagnostics, request, post, put, patch, del, sendCustomProxyMessage, getApiHeaders, getBaseURL, isProxyEnabled, setBearerToken, getBearerToken, setGrantToken, getGrantToken, getAppContext, setAppContext, getAppChannel, setAppChannel } from "./http.js";
3
+ export { initializeApi, isInitialized, hasAuthCredentials, configureSdkCache, invalidateCache, getHttpCacheDiagnostics, resetHttpCacheDiagnostics, request, post, put, patch, del, sendCustomProxyMessage, getApiHeaders, getClientHeaders, getApiVersion, getBaseURL, isProxyEnabled, setBearerToken, getBearerToken, setGrantToken, getGrantToken, getAppContext, setAppContext, getAppChannel, setAppChannel } from "./http.js";
4
4
  export * from "./api/index.js";
5
5
  export * from "./types/index.js";
6
6
  // Iframe namespace
@@ -29,5 +29,7 @@ export { createAdminCardViews, collectAdminCardTodo, adminCardAge, injectAdminCa
29
29
  export { normaliseAdminCardPayload, ADMIN_CARD_MAX_BYTES } from './adminCardPayload.js';
30
30
  // Shared dependency contract (host↔app) — one source of truth for externalized deps
31
31
  export { SHARED_DEPENDENCY_CONTRACT_VERSION, SHARED_DEPENDENCIES, SHARED_DEPENDENCY_SPECIFIERS, importMapPathFor, getHostSharedDependencies, } from './shared-dependencies.js';
32
+ // API versions: the contract this SDK release is built for, and the headers that carry it (docs/api-versions.md)
33
+ export { API_VERSION, SDK_VERSION, API_VERSION_HEADER, SDK_HEADER, APP_HEADER, CLIENT_HEADER_NAMES } from './apiVersion.js';
32
34
  export { AI_TOOL_NAMES, BUILTIN_AI_TOOLS, getBuiltinAiTool } from './ai-tools.js';
33
35
  export { HostCapabilityUnavailableError, HostPermissionDeniedError, HostTimeoutError, HostCancelledError, } from './mobile-admin/errors.js';
package/dist/openapi.yaml CHANGED
@@ -6596,7 +6596,7 @@ paths:
6596
6596
  post:
6597
6597
  tags:
6598
6598
  - order
6599
- summary: Get comprehensive scan analytics for all tags in an order.
6599
+ summary: order.getAnalytics
6600
6600
  operationId: order_getAnalytics
6601
6601
  security:
6602
6602
  - bearerAuth: []
@@ -8509,7 +8509,7 @@ paths:
8509
8509
  post:
8510
8510
  tags:
8511
8511
  - proof
8512
- summary: "The standard query on proofs (admin only): filter, sort, page, count and total a collection's proofs in one call, and follow a proof to its `product` and its `owner` (the owner's contact)."
8512
+ summary: proof.query
8513
8513
  operationId: proof_query
8514
8514
  security:
8515
8515
  - bearerAuth: []
@@ -10182,7 +10182,7 @@ paths:
10182
10182
  post:
10183
10183
  tags:
10184
10184
  - authKit
10185
- summary: Sign in with LinkedIn (OpenID Connect) via a server-side authorization code (public).
10185
+ summary: authKit.linkedInLogin
10186
10186
  operationId: authKit_linkedInLogin
10187
10187
  security: []
10188
10188
  parameters:
@@ -30211,6 +30211,8 @@ components:
30211
30211
  $ref: "#/components/schemas/DppEnvironment"
30212
30212
  label:
30213
30213
  type: string
30214
+ practice:
30215
+ type: boolean
30214
30216
  portal:
30215
30217
  type: string
30216
30218
  clientId:
@@ -30242,6 +30244,7 @@ components:
30242
30244
  required:
30243
30245
  - environment
30244
30246
  - label
30247
+ - practice
30245
30248
  - portal
30246
30249
  - clientId
30247
30250
  - kid
@@ -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
+ */
@@ -1,14 +1,23 @@
1
- /** The EU registry's environments: `acc` = the EU test registry, `prod` = the live one, `local` = a development stand-in. */
2
- export type DppEnvironment = "acc" | "prod" | "local" | (string & {});
1
+ /**
2
+ * The registry environments: `acc` = the EU test registry, `prod` = the live EU registry, `practice` = the SmartLinks
3
+ * practice registry (never the EU — for trying the whole flow before a brand is verified with the EU), `local` = a
4
+ * development stand-in.
5
+ */
6
+ export type DppEnvironment = "acc" | "prod" | "practice" | "local" | (string & {});
3
7
  /** How specific a passport is: one item (e.g. one battery), a batch, or a model. */
4
8
  export type DppGranularity = "item" | "batch" | "model";
5
- /** What the admin still has to do to connect a brand to the registry, in order (null = connected). */
6
- export type DppRegistryNextStep = "make-key" | "enter-service-account" | "enter-organisation-id" | "check" | null;
9
+ /**
10
+ * What the admin still has to do to connect a brand to the registry, in order (null = connected). The practice
11
+ * registry has one step: `enrol-practice` (`dpp.registry.enrolPractice`).
12
+ */
13
+ export type DppRegistryNextStep = "make-key" | "enter-service-account" | "enter-organisation-id" | "check" | "enrol-practice" | null;
7
14
  /** A brand's EU registry Service Account, as SmartLinks uses it. Never includes the private key. */
8
15
  export interface DppRegistry {
9
16
  environment: DppEnvironment;
10
- /** e.g. "EU test registry" */
17
+ /** e.g. "EU test registry", "SmartLinks practice registry (not the EU)" */
11
18
  label: string;
19
+ /** The SmartLinks practice registry: nothing sent there reaches the EU. Say so wherever it's shown. */
20
+ practice: boolean;
12
21
  /** The registry's web address, where the brand enrols and manages its Service Account. */
13
22
  portal: string | null;
14
23
  /** The Service Account's Client ID, from the registry. */
@@ -6,3 +6,4 @@ export * from './paths.js';
6
6
  export * from './conditions.js';
7
7
  export * from './anonId.js';
8
8
  export * from './freeTimes.js';
9
+ export * from './money.js';
@@ -7,3 +7,4 @@ export * from './paths.js';
7
7
  export * from './conditions.js';
8
8
  export * from './anonId.js';
9
9
  export * from './freeTimes.js';
10
+ export * from './money.js';
@@ -0,0 +1,15 @@
1
+ /** The language the page is showing: `<html lang>` (Portal, Hub and Studio keep it set), else the browser's, else English. */
2
+ export declare function pageLocale(): string;
3
+ /** Decimal places a currency uses: 2 for GBP, EUR and USD; 0 for JPY and KRW. Minor units follow it. */
4
+ export declare function currencyDecimals(currency: string): number;
5
+ /** Minor units → money for people, in `locale` (default: the page's language). */
6
+ export declare function formatMinor(amount: number, currency: string, locale?: string, options?: {
7
+ trimZeroCents?: boolean;
8
+ }): string;
9
+ /** "£15 a month", "15 € pro Monat", "15,00 € alle 3 Monate", "99 € einmalig": a price and how often, in the page's language. */
10
+ export declare function describeRecurring(p: {
11
+ amount: number;
12
+ currency: string;
13
+ interval: 'month' | 'year' | null;
14
+ intervalCount?: number;
15
+ }, locale?: string): string;
@@ -0,0 +1,72 @@
1
+ // Money and the person's language: amounts are kept in minor units (Stripe's rule: cents for GBP/EUR/USD,
2
+ // whole units for zero-decimal currencies such as JPY and KRW) and shown in the language the page is in,
3
+ // so a German visitor sees "12,99 €", an English one "€12.99".
4
+ /** The language the page is showing: `<html lang>` (Portal, Hub and Studio keep it set), else the browser's, else English. */
5
+ export function pageLocale() {
6
+ try {
7
+ const lang = typeof document !== 'undefined' ? document.documentElement.getAttribute('lang') : null;
8
+ if (lang)
9
+ return lang;
10
+ }
11
+ catch (_a) {
12
+ /* no DOM */
13
+ }
14
+ if (typeof navigator !== 'undefined' && navigator.language)
15
+ return navigator.language;
16
+ return 'en';
17
+ }
18
+ /** Decimal places a currency uses: 2 for GBP, EUR and USD; 0 for JPY and KRW. Minor units follow it. */
19
+ export function currencyDecimals(currency) {
20
+ var _a;
21
+ try {
22
+ return (_a = new Intl.NumberFormat('en', { style: 'currency', currency }).resolvedOptions().maximumFractionDigits) !== null && _a !== void 0 ? _a : 2;
23
+ }
24
+ catch (_b) {
25
+ return 2;
26
+ }
27
+ }
28
+ /** Minor units → money for people, in `locale` (default: the page's language). */
29
+ export function formatMinor(amount, currency, locale, options) {
30
+ const decimals = currencyDecimals(currency);
31
+ const value = amount / 10 ** decimals;
32
+ const lang = locale || pageLocale();
33
+ const trim = (options === null || options === void 0 ? void 0 : options.trimZeroCents) && amount % 10 ** decimals === 0;
34
+ try {
35
+ return new Intl.NumberFormat(lang, Object.assign({ style: 'currency', currency }, (trim ? { minimumFractionDigits: 0, maximumFractionDigits: 0 } : {}))).format(value);
36
+ }
37
+ catch (_a) {
38
+ try {
39
+ return new Intl.NumberFormat('en', { style: 'currency', currency }).format(value);
40
+ }
41
+ catch (_b) {
42
+ return `${value.toFixed(decimals)} ${currency}`;
43
+ }
44
+ }
45
+ }
46
+ // "{m}" is the money, "{n}" the count. One entry per language the platform's screens speak.
47
+ const TERMS = {
48
+ en: { once: '{m} once', month: '{m} a month', year: '{m} a year', months: '{m} every {n} months', years: '{m} every {n} years' },
49
+ de: { once: '{m} einmalig', month: '{m} pro Monat', year: '{m} pro Jahr', months: '{m} alle {n} Monate', years: '{m} alle {n} Jahre' },
50
+ fr: { once: '{m} une fois', month: '{m} par mois', year: '{m} par an', months: '{m} tous les {n} mois', years: '{m} tous les {n} ans' },
51
+ nl: { once: '{m} eenmalig', month: '{m} per maand', year: '{m} per jaar', months: '{m} elke {n} maanden', years: '{m} elke {n} jaar' },
52
+ es: { once: '{m} pago único', month: '{m} al mes', year: '{m} al año', months: '{m} cada {n} meses', years: '{m} cada {n} años' },
53
+ pt: { once: '{m} pagamento único', month: '{m} por mês', year: '{m} por ano', months: '{m} a cada {n} meses', years: '{m} a cada {n} anos' },
54
+ it: { once: '{m} una tantum', month: '{m} al mese', year: "{m} all'anno", months: '{m} ogni {n} mesi', years: '{m} ogni {n} anni' },
55
+ 'zh-Hans': { once: '{m}(一次性)', month: '{m}/月', year: '{m}/年', months: '每 {n} 个月 {m}', years: '每 {n} 年 {m}' },
56
+ ar: { once: '{m} مرة واحدة', month: '{m} شهريًا', year: '{m} سنويًا', months: '{m} كل {n} أشهر', years: '{m} كل {n} سنوات' },
57
+ };
58
+ function termsFor(locale) {
59
+ const l = locale.toLowerCase();
60
+ if (/^zh(-(cn|sg|hans)|$)/.test(l))
61
+ return TERMS['zh-Hans'];
62
+ return TERMS[l.split('-')[0]] || TERMS.en;
63
+ }
64
+ /** "£15 a month", "15 € pro Monat", "15,00 € alle 3 Monate", "99 € einmalig": a price and how often, in the page's language. */
65
+ export function describeRecurring(p, locale) {
66
+ const lang = locale || pageLocale();
67
+ const money = formatMinor(p.amount, p.currency, lang, { trimZeroCents: true });
68
+ const t = termsFor(lang);
69
+ const n = p.intervalCount || 1;
70
+ const pattern = !p.interval ? t.once : n === 1 ? t[p.interval] : t[p.interval === 'month' ? 'months' : 'years'];
71
+ return pattern.replace('{m}', money).replace('{n}', String(n));
72
+ }
@@ -0,0 +1 @@
1
+ export declare const SDK_VERSION = "2.2.0";
@@ -0,0 +1,2 @@
1
+ // Generated by scripts/write-version.mjs from package.json. Do not edit.
2
+ export const SDK_VERSION = "2.2.0";