@proveanything/smartlinks 2.1.46 → 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.
- package/README.md +754 -754
- package/dist/README.md +573 -573
- package/dist/adminCardsView.js +55 -55
- package/dist/api/dpp.d.ts +99 -0
- package/dist/api/dpp.js +194 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/shop.d.ts +5 -1
- package/dist/api/shop.js +7 -7
- package/dist/api/subscriptions.d.ts +2 -1
- package/dist/api/subscriptions.js +4 -12
- package/dist/apiVersion.d.ts +9 -0
- package/dist/apiVersion.js +15 -0
- package/dist/baseline.css +194 -194
- package/dist/docs/API_SUMMARY.md +1136 -809
- package/dist/docs/admin-cards.md +189 -189
- package/dist/docs/agent-tools.md +156 -156
- package/dist/docs/ai-tools-and-skills.md +180 -180
- package/dist/docs/ai.md +1721 -1721
- package/dist/docs/analytics.md +39 -39
- package/dist/docs/api-versions.md +76 -0
- package/dist/docs/app-data-storage.md +277 -277
- package/dist/docs/app-docs.md +73 -73
- package/dist/docs/app-manifest.md +852 -852
- package/dist/docs/app-records-pattern.md +388 -388
- package/dist/docs/appConfig.md +550 -550
- package/dist/docs/assistant-apps.md +172 -172
- package/dist/docs/assistant-context.md +119 -119
- package/dist/docs/bookings.md +442 -442
- package/dist/docs/comms.md +686 -686
- package/dist/docs/connectors.md +340 -340
- package/dist/docs/css-baseline.md +133 -133
- package/dist/docs/customer-guide.md +70 -70
- package/dist/docs/deploying-apps.md +340 -340
- package/dist/docs/dpp.md +115 -0
- package/dist/docs/entitlements.md +90 -90
- package/dist/docs/files.md +69 -69
- package/dist/docs/host-dependency-contract.md +210 -210
- package/dist/docs/i18n.md +9 -9
- package/dist/docs/integrations.md +322 -322
- package/dist/docs/interactions.md +545 -545
- package/dist/docs/item-context.md +181 -181
- package/dist/docs/knowledge.md +102 -102
- package/dist/docs/lots.md +111 -111
- package/dist/docs/loyalty.md +352 -352
- package/dist/docs/members.md +183 -183
- package/dist/docs/memberships.md +149 -149
- package/dist/docs/mobile-admin-container.md +693 -693
- package/dist/docs/operations.md +281 -281
- package/dist/docs/overview.md +485 -484
- package/dist/docs/proof-comms-triggers.md +142 -142
- package/dist/docs/proof-ownership-transfer.md +155 -155
- package/dist/docs/proof-product-data-scoping.md +462 -462
- package/dist/docs/proof-share-grants.md +305 -305
- package/dist/docs/realtime.md +138 -138
- package/dist/docs/records-admin-pattern.md +304 -304
- package/dist/docs/server-functions.md +1 -1
- package/dist/docs/service-accounts.md +64 -64
- package/dist/docs/standard-query.md +187 -187
- package/dist/docs/tag-codes.md +97 -97
- package/dist/docs/theme-tokens.md +252 -252
- package/dist/docs/wallet-passes.md +107 -107
- package/dist/docs/websites.md +123 -123
- package/dist/http.d.ts +14 -0
- package/dist/http.js +65 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/openapi.yaml +509 -3
- package/dist/theme-boot.js +82 -82
- package/dist/theme.css +75 -75
- package/dist/types/dpp.d.ts +273 -0
- package/dist/types/dpp.js +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/money.d.ts +15 -0
- package/dist/utils/money.js +72 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +2 -0
- package/docs/API_SUMMARY.md +1136 -809
- package/docs/admin-cards.md +189 -189
- package/docs/agent-tools.md +156 -156
- package/docs/ai-tools-and-skills.md +180 -180
- package/docs/ai.md +1721 -1721
- package/docs/analytics.md +39 -39
- package/docs/api-versions.md +76 -0
- package/docs/app-data-storage.md +277 -277
- package/docs/app-docs.md +73 -73
- package/docs/app-manifest.md +852 -852
- package/docs/app-records-pattern.md +388 -388
- package/docs/appConfig.md +550 -550
- package/docs/assistant-apps.md +172 -172
- package/docs/assistant-context.md +119 -119
- package/docs/bookings.md +442 -442
- package/docs/comms.md +686 -686
- package/docs/connectors.md +340 -340
- package/docs/css-baseline.md +133 -133
- package/docs/customer-guide.md +70 -70
- package/docs/deploying-apps.md +340 -340
- package/docs/dpp.md +115 -0
- package/docs/entitlements.md +90 -90
- package/docs/files.md +69 -69
- package/docs/host-dependency-contract.md +210 -210
- package/docs/i18n.md +9 -9
- package/docs/integrations.md +322 -322
- package/docs/interactions.md +545 -545
- package/docs/item-context.md +181 -181
- package/docs/knowledge.md +102 -102
- package/docs/lots.md +111 -111
- package/docs/loyalty.md +352 -352
- package/docs/members.md +183 -183
- package/docs/memberships.md +149 -149
- package/docs/mobile-admin-container.md +693 -693
- package/docs/operations.md +281 -281
- package/docs/overview.md +485 -484
- package/docs/proof-comms-triggers.md +142 -142
- package/docs/proof-ownership-transfer.md +155 -155
- package/docs/proof-product-data-scoping.md +462 -462
- package/docs/proof-share-grants.md +305 -305
- package/docs/realtime.md +138 -138
- package/docs/server-functions.md +1 -1
- package/docs/service-accounts.md +64 -64
- package/docs/standard-query.md +187 -187
- package/docs/tag-codes.md +97 -97
- package/docs/theme-lookbook.v1.json +120 -120
- package/docs/theme-tokens.md +252 -252
- package/docs/wallet-passes.md +107 -107
- package/docs/websites.md +123 -123
- package/openapi.yaml +509 -3
- package/package.json +87 -87
- package/scripts/headless-check.mjs +87 -87
- package/scripts/lib/bare-imports.mjs +57 -57
- package/scripts/lib/keyed-app-data.mjs +21 -21
- package/scripts/publish.mjs +272 -272
- package/scripts/register-release.mjs +91 -91
package/dist/theme-boot.js
CHANGED
|
@@ -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
|
+
*/
|
|
@@ -0,0 +1,273 @@
|
|
|
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 & {});
|
|
7
|
+
/** How specific a passport is: one item (e.g. one battery), a batch, or a model. */
|
|
8
|
+
export type DppGranularity = "item" | "batch" | "model";
|
|
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;
|
|
14
|
+
/** A brand's EU registry Service Account, as SmartLinks uses it. Never includes the private key. */
|
|
15
|
+
export interface DppRegistry {
|
|
16
|
+
environment: DppEnvironment;
|
|
17
|
+
/** e.g. "EU test registry", "SmartLinks practice registry (not the EU)" */
|
|
18
|
+
label: string;
|
|
19
|
+
/** The SmartLinks practice registry: nothing sent there reaches the EU. Say so wherever it's shown. */
|
|
20
|
+
practice: boolean;
|
|
21
|
+
/** The registry's web address, where the brand enrols and manages its Service Account. */
|
|
22
|
+
portal: string | null;
|
|
23
|
+
/** The Service Account's Client ID, from the registry. */
|
|
24
|
+
clientId: string | null;
|
|
25
|
+
/** The key ID (kid) the registry gave our public key. */
|
|
26
|
+
kid: string | null;
|
|
27
|
+
/** ES256 | ES384 | ES512 */
|
|
28
|
+
alg: string | null;
|
|
29
|
+
/** The brand's verified Organisation ID (registry: Organisation > Verification), copied exactly. */
|
|
30
|
+
orgIdentifier: string | null;
|
|
31
|
+
hasKey: boolean;
|
|
32
|
+
/** The public key to upload to the Service Account (PEM). */
|
|
33
|
+
publicPem: string | null;
|
|
34
|
+
/** The same public key as a JWK. */
|
|
35
|
+
publicJwk: {
|
|
36
|
+
kty: string;
|
|
37
|
+
crv: string;
|
|
38
|
+
x: string;
|
|
39
|
+
y: string;
|
|
40
|
+
} | null;
|
|
41
|
+
/** RFC 7638 thumbprint of the public key. */
|
|
42
|
+
thumbprint: string | null;
|
|
43
|
+
keyCreatedAt: string | null;
|
|
44
|
+
/** The last connection check: signed in and read the product groups, or why not. */
|
|
45
|
+
lastCheck: {
|
|
46
|
+
ok: boolean;
|
|
47
|
+
at: string;
|
|
48
|
+
message: string;
|
|
49
|
+
status?: number | null;
|
|
50
|
+
} | null;
|
|
51
|
+
/** Key, Service Account and Organisation ID all set. */
|
|
52
|
+
ready: boolean;
|
|
53
|
+
nextStep: DppRegistryNextStep;
|
|
54
|
+
}
|
|
55
|
+
export interface SetDppRegistryInput {
|
|
56
|
+
clientId?: string | null;
|
|
57
|
+
kid?: string | null;
|
|
58
|
+
orgIdentifier?: string | null;
|
|
59
|
+
}
|
|
60
|
+
/** A registry product group, from the registry itself. */
|
|
61
|
+
export interface DppRegistryProductGroup {
|
|
62
|
+
code: string;
|
|
63
|
+
label: string;
|
|
64
|
+
productSubGroups: {
|
|
65
|
+
code: string;
|
|
66
|
+
label: string;
|
|
67
|
+
}[];
|
|
68
|
+
}
|
|
69
|
+
export interface DppRegistryCheckResult {
|
|
70
|
+
registry: DppRegistry;
|
|
71
|
+
productGroups: DppRegistryProductGroup[];
|
|
72
|
+
}
|
|
73
|
+
/** Field names per view: `pub` (anyone) and the restricted views `res1`–`res3`. */
|
|
74
|
+
export interface DppViewFields {
|
|
75
|
+
pub: string[];
|
|
76
|
+
res1: string[];
|
|
77
|
+
res2: string[];
|
|
78
|
+
res3: string[];
|
|
79
|
+
}
|
|
80
|
+
/** What can be made: a product group, its kinds, and their fields (from the Commission's schemas). */
|
|
81
|
+
export interface DppGroup {
|
|
82
|
+
/** e.g. "BATTERIES" */
|
|
83
|
+
productGroup: string;
|
|
84
|
+
/** e.g. "battery" */
|
|
85
|
+
label: string;
|
|
86
|
+
subGroups: {
|
|
87
|
+
/** e.g. "EV" */
|
|
88
|
+
productSubGroup: string;
|
|
89
|
+
/** e.g. "electric vehicle" */
|
|
90
|
+
label: string;
|
|
91
|
+
/** Every field each view may carry. */
|
|
92
|
+
fields: DppViewFields;
|
|
93
|
+
/** The fields each view must carry. */
|
|
94
|
+
required: DppViewFields;
|
|
95
|
+
}[];
|
|
96
|
+
}
|
|
97
|
+
/** What a passport is still missing before the registry will take it. */
|
|
98
|
+
export interface DppPassportCheck {
|
|
99
|
+
ready: boolean;
|
|
100
|
+
missing: Partial<DppViewFields>;
|
|
101
|
+
/** When the passport's classification itself is invalid. */
|
|
102
|
+
problem?: string;
|
|
103
|
+
}
|
|
104
|
+
/** A passport's registration in one registry environment. */
|
|
105
|
+
export interface DppRegistration {
|
|
106
|
+
/** processing → registered | rejected | not-sent (another item in the same request failed) | error */
|
|
107
|
+
status: "processing" | "registered" | "rejected" | "not-sent" | "error";
|
|
108
|
+
taskId?: string;
|
|
109
|
+
submittedAt?: string;
|
|
110
|
+
correlationId?: string | null;
|
|
111
|
+
/** The registry's unique registration identifier, once registered. */
|
|
112
|
+
registryId?: string | null;
|
|
113
|
+
registeredAt?: string;
|
|
114
|
+
problems?: {
|
|
115
|
+
code: string;
|
|
116
|
+
message: string;
|
|
117
|
+
}[] | null;
|
|
118
|
+
checkedAt?: string;
|
|
119
|
+
}
|
|
120
|
+
/** Fields of a passport, named as in the Commission's schemas (e.g. batteryChemistry, manufacturerIdentification). */
|
|
121
|
+
export type DppFields = Record<string, unknown>;
|
|
122
|
+
export interface DppPassport {
|
|
123
|
+
id: string;
|
|
124
|
+
/** Its address — the unique product identifier registered with the EU. */
|
|
125
|
+
url: string;
|
|
126
|
+
status: "active" | "withdrawn";
|
|
127
|
+
productGroup: string;
|
|
128
|
+
productSubGroup: string | null;
|
|
129
|
+
granularity: DppGranularity;
|
|
130
|
+
modelIdentifier: string | null;
|
|
131
|
+
batchIdentifier: string | null;
|
|
132
|
+
/** What it's for. */
|
|
133
|
+
productId: string | null;
|
|
134
|
+
batchId: string | null;
|
|
135
|
+
proofId: string | null;
|
|
136
|
+
/** The public view: anyone reading the passport sees these. */
|
|
137
|
+
public: DppFields;
|
|
138
|
+
/** The restricted views (res1–res3): served only to the EU registry for this brand. */
|
|
139
|
+
restricted: DppFields;
|
|
140
|
+
/** Goes up by one each time what it says changes. */
|
|
141
|
+
version: number;
|
|
142
|
+
contentUpdatedAt: string | null;
|
|
143
|
+
/** By registry environment. */
|
|
144
|
+
registration: Partial<Record<DppEnvironment, DppRegistration>>;
|
|
145
|
+
check: DppPassportCheck;
|
|
146
|
+
createdAt: string;
|
|
147
|
+
updatedAt: string;
|
|
148
|
+
}
|
|
149
|
+
/** A passport's content. productGroup and (for batteries) productSubGroup are required when making one. */
|
|
150
|
+
export interface DppPassportInput {
|
|
151
|
+
productGroup?: string;
|
|
152
|
+
productSubGroup?: string | null;
|
|
153
|
+
granularity?: DppGranularity;
|
|
154
|
+
modelIdentifier?: string | null;
|
|
155
|
+
batchIdentifier?: string | null;
|
|
156
|
+
productId?: string | null;
|
|
157
|
+
batchId?: string | null;
|
|
158
|
+
proofId?: string | null;
|
|
159
|
+
public?: DppFields | null;
|
|
160
|
+
restricted?: DppFields | null;
|
|
161
|
+
}
|
|
162
|
+
/** A passport saved by what it's for: at least one of productId, batchId, proofId. */
|
|
163
|
+
export interface DppPassportUpsertInput extends DppPassportInput {
|
|
164
|
+
productGroup: string;
|
|
165
|
+
granularity: DppGranularity;
|
|
166
|
+
}
|
|
167
|
+
export interface DppPassportSaveResult {
|
|
168
|
+
passport: DppPassport;
|
|
169
|
+
/** false when the content was the same as before (no new version). */
|
|
170
|
+
changed: boolean;
|
|
171
|
+
}
|
|
172
|
+
export interface DppPassportUpsertResult extends DppPassportSaveResult {
|
|
173
|
+
created: boolean;
|
|
174
|
+
}
|
|
175
|
+
export interface DppPassportBulkResult {
|
|
176
|
+
results: ({
|
|
177
|
+
index: number;
|
|
178
|
+
ok: true;
|
|
179
|
+
id: string;
|
|
180
|
+
url: string;
|
|
181
|
+
created: boolean;
|
|
182
|
+
changed: boolean;
|
|
183
|
+
version: number;
|
|
184
|
+
check: DppPassportCheck;
|
|
185
|
+
} | {
|
|
186
|
+
index: number;
|
|
187
|
+
ok: false;
|
|
188
|
+
errorCode: string;
|
|
189
|
+
errorText: string;
|
|
190
|
+
})[];
|
|
191
|
+
created: number;
|
|
192
|
+
changed: number;
|
|
193
|
+
unchanged: number;
|
|
194
|
+
failed: number;
|
|
195
|
+
}
|
|
196
|
+
export interface DppPassportVersion {
|
|
197
|
+
version: number;
|
|
198
|
+
savedAt: string;
|
|
199
|
+
savedBy: string | null;
|
|
200
|
+
}
|
|
201
|
+
export interface DppPassportListQuery {
|
|
202
|
+
productId?: string;
|
|
203
|
+
batchId?: string;
|
|
204
|
+
proofId?: string;
|
|
205
|
+
status?: "active" | "withdrawn";
|
|
206
|
+
limit?: number;
|
|
207
|
+
offset?: number;
|
|
208
|
+
}
|
|
209
|
+
export interface DppRegisterResult {
|
|
210
|
+
/** One registry request per product group (and kind), up to 100 passports each. */
|
|
211
|
+
tasks: {
|
|
212
|
+
taskId: string;
|
|
213
|
+
environment: DppEnvironment;
|
|
214
|
+
productGroup: string;
|
|
215
|
+
productSubGroup: string | null;
|
|
216
|
+
passportIds: string[];
|
|
217
|
+
/** ISO 8601 duration the registry estimated, e.g. "PT10S". */
|
|
218
|
+
estimated: string | null;
|
|
219
|
+
/** With `wait`: the outcome. */
|
|
220
|
+
status?: string;
|
|
221
|
+
outcome?: DppTaskOutcome | null;
|
|
222
|
+
passports?: ({
|
|
223
|
+
id: string;
|
|
224
|
+
} & Partial<DppRegistration>)[];
|
|
225
|
+
}[];
|
|
226
|
+
/** Not sent, and why (not found, withdrawn, already registered, missing required fields). */
|
|
227
|
+
skipped: {
|
|
228
|
+
id: string;
|
|
229
|
+
reason: string;
|
|
230
|
+
missing?: Partial<DppViewFields>;
|
|
231
|
+
registryId?: string;
|
|
232
|
+
}[];
|
|
233
|
+
}
|
|
234
|
+
export interface DppTaskOutcome {
|
|
235
|
+
outcomeResult: "SUCCEEDED" | "FAILED";
|
|
236
|
+
outcomeMessage?: {
|
|
237
|
+
code: string;
|
|
238
|
+
message: string;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
export interface DppTask {
|
|
242
|
+
taskId: string;
|
|
243
|
+
environment: DppEnvironment;
|
|
244
|
+
/** PENDING | PROCESSING | COMPLETED | ERROR */
|
|
245
|
+
status: string | null;
|
|
246
|
+
outcome: DppTaskOutcome | null;
|
|
247
|
+
passportIds: string[];
|
|
248
|
+
createdAt: string;
|
|
249
|
+
checkedAt: string | null;
|
|
250
|
+
}
|
|
251
|
+
export interface DppTaskRefreshResult {
|
|
252
|
+
taskId: string;
|
|
253
|
+
status: string | null;
|
|
254
|
+
outcome: DppTaskOutcome | null;
|
|
255
|
+
processingInfo: {
|
|
256
|
+
submittedItems: number;
|
|
257
|
+
compliantItems: number;
|
|
258
|
+
nonCompliantItems: number;
|
|
259
|
+
} | null;
|
|
260
|
+
passports: ({
|
|
261
|
+
id: string;
|
|
262
|
+
} & Partial<DppRegistration>)[];
|
|
263
|
+
}
|
|
264
|
+
/** A passport document as served at its address, in the EU's JSON format. */
|
|
265
|
+
export interface DppDocument {
|
|
266
|
+
digitalProductPassportId: string;
|
|
267
|
+
uniqueProductIdentifier: string;
|
|
268
|
+
granularity: string;
|
|
269
|
+
dppStatus: string;
|
|
270
|
+
lastUpdate: string;
|
|
271
|
+
contentSpecificationIds: string[];
|
|
272
|
+
[field: string]: unknown;
|
|
273
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export * from "./broadcasts.js";
|
|
|
17
17
|
export * from "./segments.js";
|
|
18
18
|
export * from "./userGroups.js";
|
|
19
19
|
export * from "./serviceAccounts.js";
|
|
20
|
+
export * from "./dpp.js";
|
|
20
21
|
export * from "./operations.js";
|
|
21
22
|
export * from "./common.js";
|
|
22
23
|
export * from "./query.js";
|
package/dist/types/index.js
CHANGED
|
@@ -19,6 +19,7 @@ export * from "./broadcasts.js";
|
|
|
19
19
|
export * from "./segments.js";
|
|
20
20
|
export * from "./userGroups.js";
|
|
21
21
|
export * from "./serviceAccounts.js";
|
|
22
|
+
export * from "./dpp.js";
|
|
22
23
|
export * from "./operations.js";
|
|
23
24
|
export * from "./common.js";
|
|
24
25
|
export * from "./query.js";
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -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;
|