@proveanything/smartlinks 2.1.41 → 2.1.43
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/adminViews.js +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/product.d.ts +2 -1
- package/dist/api/product.js +2 -1
- package/dist/api/subscriptions.d.ts +97 -0
- package/dist/api/subscriptions.js +178 -0
- package/dist/baseline.css +194 -194
- package/dist/docs/API_SUMMARY.md +1135 -832
- package/dist/docs/admin-cards.md +189 -189
- package/dist/docs/admin-views.md +9 -4
- 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/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/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 -0
- 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 -182
- package/dist/docs/memberships.md +149 -0
- package/dist/docs/mobile-admin-container.md +693 -693
- package/dist/docs/operations.md +281 -281
- package/dist/docs/overview.md +483 -482
- 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 -0
- 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/i18n.d.ts +6 -0
- package/dist/i18n.js +10 -0
- package/dist/openapi.yaml +426 -3
- package/dist/theme-boot.js +82 -78
- package/dist/theme.css +75 -75
- package/dist/types/appManifest.d.ts +32 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/subscriptions.d.ts +195 -0
- package/dist/types/subscriptions.js +9 -0
- package/docs/API_SUMMARY.md +1135 -832
- package/docs/admin-cards.md +189 -189
- package/docs/admin-views.md +9 -4
- 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/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/entitlements.md +90 -90
- package/docs/files.md +69 -69
- package/docs/host-dependency-contract.md +210 -210
- package/docs/i18n.md +9 -0
- 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 -182
- package/docs/memberships.md +149 -0
- package/docs/mobile-admin-container.md +693 -693
- package/docs/operations.md +281 -281
- package/docs/overview.md +483 -482
- 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 -0
- 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 +426 -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/adminCardsView.js
CHANGED
|
@@ -28,61 +28,61 @@ export function adminCardAge(at, now = Date.now()) {
|
|
|
28
28
|
return `${Math.round(s / 3600)} h ago`;
|
|
29
29
|
return `${Math.round(s / 86400)} d ago`;
|
|
30
30
|
}
|
|
31
|
-
const CSS = `
|
|
32
|
-
.slc-grid{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:var(--slc-gap,16px)}
|
|
33
|
-
.slc-grid>*{grid-column:span 12}
|
|
34
|
-
@media (min-width:768px){.slc-grid>.slc-size-small{grid-column:span 6}.slc-grid>.slc-size-medium,.slc-grid>.slc-size-wide{grid-column:span 12}}
|
|
35
|
-
@media (min-width:1100px){.slc-grid>.slc-size-small{grid-column:span 3}.slc-grid>.slc-size-medium{grid-column:span 6}.slc-grid>.slc-size-wide{grid-column:span 8}}
|
|
36
|
-
.slc-card{--_bg:var(--slc-bg,var(--sl-color-surface,#fff));--_fg:var(--slc-fg,var(--sl-color-fg,#0f172a));--_muted:var(--slc-muted,var(--sl-color-muted,#64748b));--_border:var(--slc-border,var(--sl-color-border,#e2e8f0));--_accent:var(--slc-accent,var(--sl-color-accent,#2563eb));--_ok:var(--slc-ok,var(--sl-color-success,#059669));--_warn:var(--slc-attention,#b45309);--_err:var(--slc-error,var(--sl-color-danger,#dc2626));
|
|
37
|
-
box-sizing:border-box;display:flex;flex-direction:column;gap:12px;min-height:148px;padding:16px 18px;border:1px solid var(--_border);border-radius:var(--slc-radius,var(--sl-radius-lg,14px));background:var(--_bg);color:var(--_fg);font:inherit;position:relative}
|
|
38
|
-
.slc-head{display:flex;align-items:center;gap:8px;min-width:0}
|
|
39
|
-
.slc-title{margin:0;font-size:.95rem;font-weight:600;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
40
|
-
.slc-age{font-size:.75rem;color:var(--_muted);white-space:nowrap}
|
|
41
|
-
.slc-refresh{all:unset;cursor:pointer;width:24px;height:24px;display:grid;place-items:center;border-radius:6px;color:var(--_muted)}
|
|
42
|
-
.slc-refresh:hover{background:color-mix(in srgb,var(--_muted) 12%,transparent);color:var(--_fg)}
|
|
43
|
-
.slc-refresh:focus-visible{outline:2px solid var(--_accent)}
|
|
44
|
-
.slc-spin{animation:slc-spin 1s linear infinite}
|
|
45
|
-
@keyframes slc-spin{to{transform:rotate(360deg)}}
|
|
46
|
-
.slc-valuerow{display:flex;align-items:baseline;flex-wrap:wrap;gap:6px 10px}
|
|
47
|
-
.slc-value{font-size:2rem;line-height:1.1;font-weight:700;letter-spacing:-.02em;min-width:0;overflow-wrap:anywhere}
|
|
48
|
-
.slc-value.slc-text{font-size:1.375rem;letter-spacing:-.01em}
|
|
49
|
-
.slc-unit{font-size:1rem;font-weight:600;margin-left:2px;color:var(--_muted)}
|
|
50
|
-
.slc-label{font-size:.875rem;color:var(--_muted)}
|
|
51
|
-
.slc-trend{font-size:.75rem;font-weight:600;padding:2px 8px;border-radius:999px;background:color-mix(in srgb,var(--_muted) 12%,transparent);color:var(--_muted)}
|
|
52
|
-
.slc-trend.slc-good{background:color-mix(in srgb,var(--_ok) 14%,transparent);color:var(--_ok)}
|
|
53
|
-
.slc-trend.slc-bad{background:color-mix(in srgb,var(--_err) 12%,transparent);color:var(--_err)}
|
|
54
|
-
.slc-status{display:flex;align-items:flex-start;gap:8px;font-size:.875rem}
|
|
55
|
-
.slc-dot{flex:none;width:8px;height:8px;border-radius:50%;margin-top:6px;background:var(--_muted)}
|
|
56
|
-
.slc-tone-ok .slc-dot{background:var(--_ok)}.slc-tone-attention .slc-dot{background:var(--_warn)}.slc-tone-error .slc-dot{background:var(--_err)}
|
|
57
|
-
.slc-progress{display:flex;flex-direction:column;gap:4px;font-size:.75rem;color:var(--_muted)}
|
|
58
|
-
.slc-bar{height:6px;border-radius:999px;background:color-mix(in srgb,var(--_muted) 18%,transparent);overflow:hidden}
|
|
59
|
-
.slc-bar>span{display:block;height:100%;background:var(--_accent);border-radius:inherit}
|
|
60
|
-
.slc-items{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}
|
|
61
|
-
.slc-item{display:flex;align-items:center;gap:8px;padding:7px 0;border-top:1px solid var(--_border);font-size:.875rem;min-width:0}
|
|
62
|
-
.slc-item:first-child{border-top:0}
|
|
63
|
-
.slc-item-main{flex:1;min-width:0}
|
|
64
|
-
.slc-item-img{width:36px;height:36px;flex:none;border-radius:8px;object-fit:cover;background:color-mix(in srgb,var(--_muted) 12%,transparent)}
|
|
65
|
-
.slc-item-title,.slc-item-sub{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
66
|
-
.slc-item-sub,.slc-item-meta{color:var(--_muted);font-size:.75rem}
|
|
67
|
-
.slc-link{all:unset;cursor:pointer}
|
|
68
|
-
.slc-link:hover .slc-item-title{text-decoration:underline}
|
|
69
|
-
.slc-link:focus-visible{outline:2px solid var(--_accent);border-radius:4px}
|
|
70
|
-
.slc-empty{font-size:.875rem;color:var(--_muted)}
|
|
71
|
-
.slc-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:auto}
|
|
72
|
-
.slc-btn{all:unset;cursor:pointer;font-size:.8125rem;font-weight:600;padding:6px 12px;border-radius:8px;border:1px solid var(--_border);color:var(--_fg)}
|
|
73
|
-
.slc-btn:hover{background:color-mix(in srgb,var(--_muted) 10%,transparent)}
|
|
74
|
-
.slc-btn.slc-primary{background:var(--_accent);border-color:var(--_accent);color:var(--slc-on-accent,var(--sl-color-on-accent,#fff))}
|
|
75
|
-
.slc-btn:focus-visible{outline:2px solid var(--_accent);outline-offset:2px}
|
|
76
|
-
.slc-note{font-size:.75rem;color:var(--_muted)}
|
|
77
|
-
.slc-note.slc-err{color:var(--_err)}
|
|
78
|
-
.slc-skel{height:12px;border-radius:6px;background:color-mix(in srgb,var(--_muted) 16%,transparent);animation:slc-pulse 1.4s ease-in-out infinite}
|
|
79
|
-
@keyframes slc-pulse{50%{opacity:.5}}
|
|
80
|
-
.slc-todo{display:flex;flex-direction:column;gap:6px;padding:12px 16px;border-radius:var(--slc-radius,var(--sl-radius-lg,14px));border:1px solid color-mix(in srgb,var(--slc-attention,#b45309) 35%,transparent);background:color-mix(in srgb,var(--slc-attention,#b45309) 7%,var(--slc-bg,var(--sl-color-surface,#fff)));color:var(--slc-fg,var(--sl-color-fg,#0f172a))}
|
|
81
|
-
.slc-todo-title{margin:0 0 2px;font-size:.875rem;font-weight:600}
|
|
82
|
-
.slc-todo-row{display:flex;align-items:center;gap:10px;font-size:.875rem}
|
|
83
|
-
.slc-todo-row .slc-dot{margin-top:0;background:var(--slc-attention,#b45309)}
|
|
84
|
-
.slc-todo-row.slc-tone-error .slc-dot{background:var(--slc-error,var(--sl-color-danger,#dc2626))}
|
|
85
|
-
.slc-todo-text{flex:1;min-width:0}
|
|
31
|
+
const CSS = `
|
|
32
|
+
.slc-grid{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:var(--slc-gap,16px)}
|
|
33
|
+
.slc-grid>*{grid-column:span 12}
|
|
34
|
+
@media (min-width:768px){.slc-grid>.slc-size-small{grid-column:span 6}.slc-grid>.slc-size-medium,.slc-grid>.slc-size-wide{grid-column:span 12}}
|
|
35
|
+
@media (min-width:1100px){.slc-grid>.slc-size-small{grid-column:span 3}.slc-grid>.slc-size-medium{grid-column:span 6}.slc-grid>.slc-size-wide{grid-column:span 8}}
|
|
36
|
+
.slc-card{--_bg:var(--slc-bg,var(--sl-color-surface,#fff));--_fg:var(--slc-fg,var(--sl-color-fg,#0f172a));--_muted:var(--slc-muted,var(--sl-color-muted,#64748b));--_border:var(--slc-border,var(--sl-color-border,#e2e8f0));--_accent:var(--slc-accent,var(--sl-color-accent,#2563eb));--_ok:var(--slc-ok,var(--sl-color-success,#059669));--_warn:var(--slc-attention,#b45309);--_err:var(--slc-error,var(--sl-color-danger,#dc2626));
|
|
37
|
+
box-sizing:border-box;display:flex;flex-direction:column;gap:12px;min-height:148px;padding:16px 18px;border:1px solid var(--_border);border-radius:var(--slc-radius,var(--sl-radius-lg,14px));background:var(--_bg);color:var(--_fg);font:inherit;position:relative}
|
|
38
|
+
.slc-head{display:flex;align-items:center;gap:8px;min-width:0}
|
|
39
|
+
.slc-title{margin:0;font-size:.95rem;font-weight:600;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
40
|
+
.slc-age{font-size:.75rem;color:var(--_muted);white-space:nowrap}
|
|
41
|
+
.slc-refresh{all:unset;cursor:pointer;width:24px;height:24px;display:grid;place-items:center;border-radius:6px;color:var(--_muted)}
|
|
42
|
+
.slc-refresh:hover{background:color-mix(in srgb,var(--_muted) 12%,transparent);color:var(--_fg)}
|
|
43
|
+
.slc-refresh:focus-visible{outline:2px solid var(--_accent)}
|
|
44
|
+
.slc-spin{animation:slc-spin 1s linear infinite}
|
|
45
|
+
@keyframes slc-spin{to{transform:rotate(360deg)}}
|
|
46
|
+
.slc-valuerow{display:flex;align-items:baseline;flex-wrap:wrap;gap:6px 10px}
|
|
47
|
+
.slc-value{font-size:2rem;line-height:1.1;font-weight:700;letter-spacing:-.02em;min-width:0;overflow-wrap:anywhere}
|
|
48
|
+
.slc-value.slc-text{font-size:1.375rem;letter-spacing:-.01em}
|
|
49
|
+
.slc-unit{font-size:1rem;font-weight:600;margin-left:2px;color:var(--_muted)}
|
|
50
|
+
.slc-label{font-size:.875rem;color:var(--_muted)}
|
|
51
|
+
.slc-trend{font-size:.75rem;font-weight:600;padding:2px 8px;border-radius:999px;background:color-mix(in srgb,var(--_muted) 12%,transparent);color:var(--_muted)}
|
|
52
|
+
.slc-trend.slc-good{background:color-mix(in srgb,var(--_ok) 14%,transparent);color:var(--_ok)}
|
|
53
|
+
.slc-trend.slc-bad{background:color-mix(in srgb,var(--_err) 12%,transparent);color:var(--_err)}
|
|
54
|
+
.slc-status{display:flex;align-items:flex-start;gap:8px;font-size:.875rem}
|
|
55
|
+
.slc-dot{flex:none;width:8px;height:8px;border-radius:50%;margin-top:6px;background:var(--_muted)}
|
|
56
|
+
.slc-tone-ok .slc-dot{background:var(--_ok)}.slc-tone-attention .slc-dot{background:var(--_warn)}.slc-tone-error .slc-dot{background:var(--_err)}
|
|
57
|
+
.slc-progress{display:flex;flex-direction:column;gap:4px;font-size:.75rem;color:var(--_muted)}
|
|
58
|
+
.slc-bar{height:6px;border-radius:999px;background:color-mix(in srgb,var(--_muted) 18%,transparent);overflow:hidden}
|
|
59
|
+
.slc-bar>span{display:block;height:100%;background:var(--_accent);border-radius:inherit}
|
|
60
|
+
.slc-items{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}
|
|
61
|
+
.slc-item{display:flex;align-items:center;gap:8px;padding:7px 0;border-top:1px solid var(--_border);font-size:.875rem;min-width:0}
|
|
62
|
+
.slc-item:first-child{border-top:0}
|
|
63
|
+
.slc-item-main{flex:1;min-width:0}
|
|
64
|
+
.slc-item-img{width:36px;height:36px;flex:none;border-radius:8px;object-fit:cover;background:color-mix(in srgb,var(--_muted) 12%,transparent)}
|
|
65
|
+
.slc-item-title,.slc-item-sub{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
66
|
+
.slc-item-sub,.slc-item-meta{color:var(--_muted);font-size:.75rem}
|
|
67
|
+
.slc-link{all:unset;cursor:pointer}
|
|
68
|
+
.slc-link:hover .slc-item-title{text-decoration:underline}
|
|
69
|
+
.slc-link:focus-visible{outline:2px solid var(--_accent);border-radius:4px}
|
|
70
|
+
.slc-empty{font-size:.875rem;color:var(--_muted)}
|
|
71
|
+
.slc-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:auto}
|
|
72
|
+
.slc-btn{all:unset;cursor:pointer;font-size:.8125rem;font-weight:600;padding:6px 12px;border-radius:8px;border:1px solid var(--_border);color:var(--_fg)}
|
|
73
|
+
.slc-btn:hover{background:color-mix(in srgb,var(--_muted) 10%,transparent)}
|
|
74
|
+
.slc-btn.slc-primary{background:var(--_accent);border-color:var(--_accent);color:var(--slc-on-accent,var(--sl-color-on-accent,#fff))}
|
|
75
|
+
.slc-btn:focus-visible{outline:2px solid var(--_accent);outline-offset:2px}
|
|
76
|
+
.slc-note{font-size:.75rem;color:var(--_muted)}
|
|
77
|
+
.slc-note.slc-err{color:var(--_err)}
|
|
78
|
+
.slc-skel{height:12px;border-radius:6px;background:color-mix(in srgb,var(--_muted) 16%,transparent);animation:slc-pulse 1.4s ease-in-out infinite}
|
|
79
|
+
@keyframes slc-pulse{50%{opacity:.5}}
|
|
80
|
+
.slc-todo{display:flex;flex-direction:column;gap:6px;padding:12px 16px;border-radius:var(--slc-radius,var(--sl-radius-lg,14px));border:1px solid color-mix(in srgb,var(--slc-attention,#b45309) 35%,transparent);background:color-mix(in srgb,var(--slc-attention,#b45309) 7%,var(--slc-bg,var(--sl-color-surface,#fff)));color:var(--slc-fg,var(--sl-color-fg,#0f172a))}
|
|
81
|
+
.slc-todo-title{margin:0 0 2px;font-size:.875rem;font-weight:600}
|
|
82
|
+
.slc-todo-row{display:flex;align-items:center;gap:10px;font-size:.875rem}
|
|
83
|
+
.slc-todo-row .slc-dot{margin-top:0;background:var(--slc-attention,#b45309)}
|
|
84
|
+
.slc-todo-row.slc-tone-error .slc-dot{background:var(--slc-error,var(--sl-color-danger,#dc2626))}
|
|
85
|
+
.slc-todo-text{flex:1;min-width:0}
|
|
86
86
|
`;
|
|
87
87
|
let injected = false;
|
|
88
88
|
/** Add the card styles to the page once (the views call it; hosts rendering on the server can too). */
|
package/dist/adminViews.js
CHANGED
|
@@ -271,7 +271,7 @@ export const DESTINATIONS = [
|
|
|
271
271
|
// Messages
|
|
272
272
|
{ name: 'message.compose', required: [], optional: ['contactId', 'about'], description: 'The Messages composer: write to one person (or choose who).' },
|
|
273
273
|
{ name: 'message.log', required: [], optional: ['contactId', 'about'], description: 'The Message log, filtered by person or by what the messages were about.' },
|
|
274
|
-
{ name: 'campaign.new', required: [], optional: ['segmentId'], description: 'A new campaign: one message to many people, with opt-in and unsubscribe.' },
|
|
274
|
+
{ name: 'campaign.new', required: [], optional: ['segmentId', 'interactionId'], description: 'A new campaign: one message to many people, with opt-in and unsubscribe. interactionId = everyone who had that interaction.' },
|
|
275
275
|
{ name: 'campaign', required: ['campaignId'], description: 'One campaign in Messages.' },
|
|
276
276
|
{ name: 'templates', required: [], description: 'The email and message templates.' },
|
|
277
277
|
{ name: 'template', required: ['templateId'], description: 'One template, open in the template editor.' },
|
package/dist/api/index.d.ts
CHANGED
|
@@ -47,6 +47,7 @@ export { order } from "./order.js";
|
|
|
47
47
|
export { app } from "./appObjects.js";
|
|
48
48
|
export { bookings } from "./bookings.js";
|
|
49
49
|
export { shop } from "./shop.js";
|
|
50
|
+
export { subscriptions } from "./subscriptions.js";
|
|
50
51
|
export { attestations } from "./attestations.js";
|
|
51
52
|
export { containers } from "./containers.js";
|
|
52
53
|
export { lots } from "./lots.js";
|
package/dist/api/index.js
CHANGED
|
@@ -50,6 +50,7 @@ export { order } from "./order.js";
|
|
|
50
50
|
export { app } from "./appObjects.js";
|
|
51
51
|
export { bookings } from "./bookings.js";
|
|
52
52
|
export { shop } from "./shop.js";
|
|
53
|
+
export { subscriptions } from "./subscriptions.js";
|
|
53
54
|
export { attestations } from "./attestations.js";
|
|
54
55
|
export { containers } from "./containers.js";
|
|
55
56
|
export { lots } from "./lots.js";
|
package/dist/api/product.d.ts
CHANGED
|
@@ -86,7 +86,8 @@ export declare namespace product {
|
|
|
86
86
|
*/
|
|
87
87
|
function find(collectionId: string, body: ProductQueryRequest): Promise<ProductQueryResponse>;
|
|
88
88
|
/**
|
|
89
|
-
* @deprecated
|
|
89
|
+
* @deprecated Retired on the server (2026-11-22): the outside-system id lookup it called is gone, so this now
|
|
90
|
+
* answers 404. Use `products.get(...)` when the product id is known, or `products.query(...)` to search.
|
|
90
91
|
*/
|
|
91
92
|
function publicFind(collectionId: string, params?: ProductPublicFindParams): Promise<ProductResponse[]>;
|
|
92
93
|
/**
|
package/dist/api/product.js
CHANGED
|
@@ -113,7 +113,8 @@ export var product;
|
|
|
113
113
|
}
|
|
114
114
|
product.find = find;
|
|
115
115
|
/**
|
|
116
|
-
* @deprecated
|
|
116
|
+
* @deprecated Retired on the server (2026-11-22): the outside-system id lookup it called is gone, so this now
|
|
117
|
+
* answers 404. Use `products.get(...)` when the product id is known, or `products.query(...)` to search.
|
|
117
118
|
*/
|
|
118
119
|
async function publicFind(collectionId, params) {
|
|
119
120
|
const searchParams = new URLSearchParams();
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { PublicPlan, MySubscription, SubscriptionStartInput, SubscriptionStartResult, PlanWithPrices, Plan, PlanInput, PlanUpdate, PlanPrice, PlanPriceInput, Membership, SubscriptionListParams, SubscriptionGrantInput, SubscriptionPage, PlanGrants } from '../types/subscriptions.js';
|
|
2
|
+
export declare namespace subscriptions {
|
|
3
|
+
/** Plans open to new members, each with its prices (monthly, yearly, one-off). */
|
|
4
|
+
function plans(collectionId: string): Promise<PublicPlan[]>;
|
|
5
|
+
/**
|
|
6
|
+
* Join a plan: Stripe's checkout page for the chosen price. Send them to `checkoutUrl`. Signed in only (a
|
|
7
|
+
* membership belongs to an account). The membership exists once Stripe confirms the payment.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const plans = await subscriptions.plans(collectionId)
|
|
12
|
+
* const yearly = plans[0].prices.find((p) => p.interval === 'year')
|
|
13
|
+
* const { checkoutUrl } = await subscriptions.start(collectionId, {
|
|
14
|
+
* priceId: yearly.id,
|
|
15
|
+
* successUrl: `${location.origin}/welcome`,
|
|
16
|
+
* cancelUrl: `${location.origin}/join`,
|
|
17
|
+
* })
|
|
18
|
+
* location.href = checkoutUrl
|
|
19
|
+
* ```
|
|
20
|
+
* @throws `SIGN_IN_REQUIRED`, `ALREADY_MEMBER`, `NOT_FOUND` (closed plan or price), `PAYMENTS_NOT_READY`, `INVALID_INPUT`
|
|
21
|
+
*/
|
|
22
|
+
function start(collectionId: string, input: SubscriptionStartInput): Promise<SubscriptionStartResult>;
|
|
23
|
+
/** The signed-in member's memberships, newest first (ended ones too: check `live`). */
|
|
24
|
+
function mine(collectionId: string): Promise<MySubscription[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Cancel: it ends at the end of the paid period, and access stays until then. A one-off plan or a staff
|
|
27
|
+
* grant ends now. Undo with `resume` before the period ends.
|
|
28
|
+
*/
|
|
29
|
+
function cancel(collectionId: string, subscriptionId: string): Promise<MySubscription>;
|
|
30
|
+
/** Undo a cancel before the period ends. @throws `NOT_CANCELLING` */
|
|
31
|
+
function resume(collectionId: string, subscriptionId: string): Promise<MySubscription>;
|
|
32
|
+
/**
|
|
33
|
+
* Move to another plan's price. Up (a higher-ranked or dearer plan): at once, charging the difference.
|
|
34
|
+
* Down: from the next renewal (`pendingPriceId` until then). @throws `CANNOT_CHANGE`, `NOT_FOUND`
|
|
35
|
+
*/
|
|
36
|
+
function change(collectionId: string, subscriptionId: string, priceId: string): Promise<MySubscription>;
|
|
37
|
+
/** Stripe's page for the member's card, invoices and cancelling. Send them to `url`. @throws `NO_BILLING` */
|
|
38
|
+
function billingLink(collectionId: string, subscriptionId: string, returnUrl: string): Promise<{
|
|
39
|
+
url: string;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Format a plan price for people: "£15 a month", "£150 a year", "£40 every 3 months", "£99 once".
|
|
43
|
+
*/
|
|
44
|
+
function describePrice(p: {
|
|
45
|
+
amount: number;
|
|
46
|
+
currency: string;
|
|
47
|
+
interval: 'month' | 'year' | null;
|
|
48
|
+
intervalCount?: number;
|
|
49
|
+
}, locale?: string): string;
|
|
50
|
+
/** The business's side: plans, prices and members (collection admins). Payments use the shop's Stripe set-up. */
|
|
51
|
+
namespace admin {
|
|
52
|
+
function listPlans(collectionId: string, params?: {
|
|
53
|
+
active?: boolean;
|
|
54
|
+
limit?: number;
|
|
55
|
+
offset?: number;
|
|
56
|
+
}): Promise<SubscriptionPage<PlanWithPrices>>;
|
|
57
|
+
/** A plan with its prices and how many live members it has. */
|
|
58
|
+
function getPlan(collectionId: string, planId: string): Promise<PlanWithPrices>;
|
|
59
|
+
/** @throws `INVALID_INPUT` */
|
|
60
|
+
function createPlan(collectionId: string, input: PlanInput): Promise<Plan>;
|
|
61
|
+
/**
|
|
62
|
+
* Change a plan. Its term can't change once it has prices. Changed grants reach members when their
|
|
63
|
+
* membership next changes, or at once with `reapply`. @throws `PLAN_HAS_PRICES`
|
|
64
|
+
*/
|
|
65
|
+
function updatePlan(collectionId: string, planId: string, changes: PlanUpdate): Promise<Plan>;
|
|
66
|
+
/** Only a plan nobody has held; otherwise close it to new members (`active: false`). @throws `PLAN_HAS_MEMBERS` */
|
|
67
|
+
function removePlan(collectionId: string, planId: string): Promise<{
|
|
68
|
+
ok: true;
|
|
69
|
+
}>;
|
|
70
|
+
/** Set a plan's price for a currency and billing period (one each): replaces it if there is one. */
|
|
71
|
+
function setPrice(collectionId: string, planId: string, input: PlanPriceInput): Promise<PlanPrice>;
|
|
72
|
+
function updatePrice(collectionId: string, priceId: string, changes: Partial<PlanPriceInput>): Promise<PlanPrice>;
|
|
73
|
+
/** A price nobody pays. One that members pay is kept: close it with `active: false`. @throws `PRICE_IN_USE` */
|
|
74
|
+
function removePrice(collectionId: string, priceId: string): Promise<{
|
|
75
|
+
ok: true;
|
|
76
|
+
}>;
|
|
77
|
+
/** Memberships, newest first, with each one's plan. */
|
|
78
|
+
function list(collectionId: string, params?: SubscriptionListParams): Promise<SubscriptionPage<Membership>>;
|
|
79
|
+
function get(collectionId: string, subscriptionId: string): Promise<Membership>;
|
|
80
|
+
/** Give someone a plan without payment (free, honorary, paid in cash). Its grants apply at once. */
|
|
81
|
+
function grant(collectionId: string, input: SubscriptionGrantInput): Promise<Membership>;
|
|
82
|
+
/** Cancel at the end of the paid period (default), or now with `atPeriodEnd: false`. */
|
|
83
|
+
function cancel(collectionId: string, subscriptionId: string, opts?: {
|
|
84
|
+
atPeriodEnd?: boolean;
|
|
85
|
+
}): Promise<Membership>;
|
|
86
|
+
function resume(collectionId: string, subscriptionId: string): Promise<Membership>;
|
|
87
|
+
function change(collectionId: string, subscriptionId: string, priceId: string): Promise<Membership>;
|
|
88
|
+
/** End now. A paid one is stopped in Stripe at once (no refund is made here). */
|
|
89
|
+
function end(collectionId: string, subscriptionId: string): Promise<Membership>;
|
|
90
|
+
/** Re-apply what the plan grants now (after the plan's grants were changed). */
|
|
91
|
+
function reapply(collectionId: string, subscriptionId: string): Promise<{
|
|
92
|
+
level?: string | null;
|
|
93
|
+
groups: string[];
|
|
94
|
+
}>;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export type { PlanGrants };
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// src/api/subscriptions.ts
|
|
2
|
+
// Memberships — see docs/memberships.md. A site's join page and "my membership" use the public calls (signed in
|
|
3
|
+
// to join or manage); the Memberships app and Studio use `subscriptions.admin`. Prices and "paid" are never
|
|
4
|
+
// taken from the browser: Stripe's webhook makes the membership, and the platform applies what it grants
|
|
5
|
+
// (the member's `level` and user groups).
|
|
6
|
+
import { request, post, put, patch, del } from '../http.js';
|
|
7
|
+
const pub = (collectionId) => `/public/collection/${encodeURIComponent(collectionId)}/memberships`;
|
|
8
|
+
const adm = (collectionId) => `/admin/collection/${encodeURIComponent(collectionId)}/memberships`;
|
|
9
|
+
function qs(params) {
|
|
10
|
+
if (!params)
|
|
11
|
+
return '';
|
|
12
|
+
const parts = [];
|
|
13
|
+
for (const [k, v] of Object.entries(params)) {
|
|
14
|
+
if (v === undefined || v === null || v === '')
|
|
15
|
+
continue;
|
|
16
|
+
parts.push(`${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`);
|
|
17
|
+
}
|
|
18
|
+
return parts.length ? `?${parts.join('&')}` : '';
|
|
19
|
+
}
|
|
20
|
+
export var subscriptions;
|
|
21
|
+
(function (subscriptions) {
|
|
22
|
+
/** Plans open to new members, each with its prices (monthly, yearly, one-off). */
|
|
23
|
+
async function plans(collectionId) {
|
|
24
|
+
return request(`${pub(collectionId)}/plans`);
|
|
25
|
+
}
|
|
26
|
+
subscriptions.plans = plans;
|
|
27
|
+
/**
|
|
28
|
+
* Join a plan: Stripe's checkout page for the chosen price. Send them to `checkoutUrl`. Signed in only (a
|
|
29
|
+
* membership belongs to an account). The membership exists once Stripe confirms the payment.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const plans = await subscriptions.plans(collectionId)
|
|
34
|
+
* const yearly = plans[0].prices.find((p) => p.interval === 'year')
|
|
35
|
+
* const { checkoutUrl } = await subscriptions.start(collectionId, {
|
|
36
|
+
* priceId: yearly.id,
|
|
37
|
+
* successUrl: `${location.origin}/welcome`,
|
|
38
|
+
* cancelUrl: `${location.origin}/join`,
|
|
39
|
+
* })
|
|
40
|
+
* location.href = checkoutUrl
|
|
41
|
+
* ```
|
|
42
|
+
* @throws `SIGN_IN_REQUIRED`, `ALREADY_MEMBER`, `NOT_FOUND` (closed plan or price), `PAYMENTS_NOT_READY`, `INVALID_INPUT`
|
|
43
|
+
*/
|
|
44
|
+
async function start(collectionId, input) {
|
|
45
|
+
return post(`${pub(collectionId)}/start`, input);
|
|
46
|
+
}
|
|
47
|
+
subscriptions.start = start;
|
|
48
|
+
/** The signed-in member's memberships, newest first (ended ones too: check `live`). */
|
|
49
|
+
async function mine(collectionId) {
|
|
50
|
+
return request(`${pub(collectionId)}/mine`);
|
|
51
|
+
}
|
|
52
|
+
subscriptions.mine = mine;
|
|
53
|
+
/**
|
|
54
|
+
* Cancel: it ends at the end of the paid period, and access stays until then. A one-off plan or a staff
|
|
55
|
+
* grant ends now. Undo with `resume` before the period ends.
|
|
56
|
+
*/
|
|
57
|
+
async function cancel(collectionId, subscriptionId) {
|
|
58
|
+
return post(`${pub(collectionId)}/${encodeURIComponent(subscriptionId)}/cancel`, {});
|
|
59
|
+
}
|
|
60
|
+
subscriptions.cancel = cancel;
|
|
61
|
+
/** Undo a cancel before the period ends. @throws `NOT_CANCELLING` */
|
|
62
|
+
async function resume(collectionId, subscriptionId) {
|
|
63
|
+
return post(`${pub(collectionId)}/${encodeURIComponent(subscriptionId)}/resume`, {});
|
|
64
|
+
}
|
|
65
|
+
subscriptions.resume = resume;
|
|
66
|
+
/**
|
|
67
|
+
* Move to another plan's price. Up (a higher-ranked or dearer plan): at once, charging the difference.
|
|
68
|
+
* Down: from the next renewal (`pendingPriceId` until then). @throws `CANNOT_CHANGE`, `NOT_FOUND`
|
|
69
|
+
*/
|
|
70
|
+
async function change(collectionId, subscriptionId, priceId) {
|
|
71
|
+
return post(`${pub(collectionId)}/${encodeURIComponent(subscriptionId)}/change`, { priceId });
|
|
72
|
+
}
|
|
73
|
+
subscriptions.change = change;
|
|
74
|
+
/** Stripe's page for the member's card, invoices and cancelling. Send them to `url`. @throws `NO_BILLING` */
|
|
75
|
+
async function billingLink(collectionId, subscriptionId, returnUrl) {
|
|
76
|
+
return post(`${pub(collectionId)}/${encodeURIComponent(subscriptionId)}/billing`, { returnUrl });
|
|
77
|
+
}
|
|
78
|
+
subscriptions.billingLink = billingLink;
|
|
79
|
+
/**
|
|
80
|
+
* Format a plan price for people: "£15 a month", "£150 a year", "£40 every 3 months", "£99 once".
|
|
81
|
+
*/
|
|
82
|
+
function describePrice(p, locale) {
|
|
83
|
+
let money;
|
|
84
|
+
try {
|
|
85
|
+
money = new Intl.NumberFormat(locale, { style: 'currency', currency: p.currency, minimumFractionDigits: p.amount % 100 ? 2 : 0 }).format(p.amount / 100);
|
|
86
|
+
}
|
|
87
|
+
catch (_a) {
|
|
88
|
+
money = `${(p.amount / 100).toFixed(2)} ${p.currency}`;
|
|
89
|
+
}
|
|
90
|
+
if (!p.interval)
|
|
91
|
+
return `${money} once`;
|
|
92
|
+
const n = p.intervalCount || 1;
|
|
93
|
+
return n === 1 ? `${money} a ${p.interval}` : `${money} every ${n} ${p.interval}s`;
|
|
94
|
+
}
|
|
95
|
+
subscriptions.describePrice = describePrice;
|
|
96
|
+
/** The business's side: plans, prices and members (collection admins). Payments use the shop's Stripe set-up. */
|
|
97
|
+
let admin;
|
|
98
|
+
(function (admin) {
|
|
99
|
+
async function listPlans(collectionId, params) {
|
|
100
|
+
return request(`${adm(collectionId)}/plans${qs(params)}`);
|
|
101
|
+
}
|
|
102
|
+
admin.listPlans = listPlans;
|
|
103
|
+
/** A plan with its prices and how many live members it has. */
|
|
104
|
+
async function getPlan(collectionId, planId) {
|
|
105
|
+
return request(`${adm(collectionId)}/plans/${encodeURIComponent(planId)}`);
|
|
106
|
+
}
|
|
107
|
+
admin.getPlan = getPlan;
|
|
108
|
+
/** @throws `INVALID_INPUT` */
|
|
109
|
+
async function createPlan(collectionId, input) {
|
|
110
|
+
return post(`${adm(collectionId)}/plans`, input);
|
|
111
|
+
}
|
|
112
|
+
admin.createPlan = createPlan;
|
|
113
|
+
/**
|
|
114
|
+
* Change a plan. Its term can't change once it has prices. Changed grants reach members when their
|
|
115
|
+
* membership next changes, or at once with `reapply`. @throws `PLAN_HAS_PRICES`
|
|
116
|
+
*/
|
|
117
|
+
async function updatePlan(collectionId, planId, changes) {
|
|
118
|
+
return patch(`${adm(collectionId)}/plans/${encodeURIComponent(planId)}`, changes);
|
|
119
|
+
}
|
|
120
|
+
admin.updatePlan = updatePlan;
|
|
121
|
+
/** Only a plan nobody has held; otherwise close it to new members (`active: false`). @throws `PLAN_HAS_MEMBERS` */
|
|
122
|
+
async function removePlan(collectionId, planId) {
|
|
123
|
+
return del(`${adm(collectionId)}/plans/${encodeURIComponent(planId)}`);
|
|
124
|
+
}
|
|
125
|
+
admin.removePlan = removePlan;
|
|
126
|
+
/** Set a plan's price for a currency and billing period (one each): replaces it if there is one. */
|
|
127
|
+
async function setPrice(collectionId, planId, input) {
|
|
128
|
+
return put(`${adm(collectionId)}/plans/${encodeURIComponent(planId)}/prices`, input);
|
|
129
|
+
}
|
|
130
|
+
admin.setPrice = setPrice;
|
|
131
|
+
async function updatePrice(collectionId, priceId, changes) {
|
|
132
|
+
return patch(`${adm(collectionId)}/prices/${encodeURIComponent(priceId)}`, changes);
|
|
133
|
+
}
|
|
134
|
+
admin.updatePrice = updatePrice;
|
|
135
|
+
/** A price nobody pays. One that members pay is kept: close it with `active: false`. @throws `PRICE_IN_USE` */
|
|
136
|
+
async function removePrice(collectionId, priceId) {
|
|
137
|
+
return del(`${adm(collectionId)}/prices/${encodeURIComponent(priceId)}`);
|
|
138
|
+
}
|
|
139
|
+
admin.removePrice = removePrice;
|
|
140
|
+
/** Memberships, newest first, with each one's plan. */
|
|
141
|
+
async function list(collectionId, params) {
|
|
142
|
+
return request(`${adm(collectionId)}/subscriptions${qs(params)}`);
|
|
143
|
+
}
|
|
144
|
+
admin.list = list;
|
|
145
|
+
async function get(collectionId, subscriptionId) {
|
|
146
|
+
return request(`${adm(collectionId)}/subscriptions/${encodeURIComponent(subscriptionId)}`);
|
|
147
|
+
}
|
|
148
|
+
admin.get = get;
|
|
149
|
+
/** Give someone a plan without payment (free, honorary, paid in cash). Its grants apply at once. */
|
|
150
|
+
async function grant(collectionId, input) {
|
|
151
|
+
return post(`${adm(collectionId)}/subscriptions`, input);
|
|
152
|
+
}
|
|
153
|
+
admin.grant = grant;
|
|
154
|
+
/** Cancel at the end of the paid period (default), or now with `atPeriodEnd: false`. */
|
|
155
|
+
async function cancel(collectionId, subscriptionId, opts = {}) {
|
|
156
|
+
return post(`${adm(collectionId)}/subscriptions/${encodeURIComponent(subscriptionId)}/cancel`, opts);
|
|
157
|
+
}
|
|
158
|
+
admin.cancel = cancel;
|
|
159
|
+
async function resume(collectionId, subscriptionId) {
|
|
160
|
+
return post(`${adm(collectionId)}/subscriptions/${encodeURIComponent(subscriptionId)}/resume`, {});
|
|
161
|
+
}
|
|
162
|
+
admin.resume = resume;
|
|
163
|
+
async function change(collectionId, subscriptionId, priceId) {
|
|
164
|
+
return post(`${adm(collectionId)}/subscriptions/${encodeURIComponent(subscriptionId)}/change`, { priceId });
|
|
165
|
+
}
|
|
166
|
+
admin.change = change;
|
|
167
|
+
/** End now. A paid one is stopped in Stripe at once (no refund is made here). */
|
|
168
|
+
async function end(collectionId, subscriptionId) {
|
|
169
|
+
return post(`${adm(collectionId)}/subscriptions/${encodeURIComponent(subscriptionId)}/end`, {});
|
|
170
|
+
}
|
|
171
|
+
admin.end = end;
|
|
172
|
+
/** Re-apply what the plan grants now (after the plan's grants were changed). */
|
|
173
|
+
async function reapply(collectionId, subscriptionId) {
|
|
174
|
+
return post(`${adm(collectionId)}/subscriptions/${encodeURIComponent(subscriptionId)}/reapply`, {});
|
|
175
|
+
}
|
|
176
|
+
admin.reapply = reapply;
|
|
177
|
+
})(admin = subscriptions.admin || (subscriptions.admin = {}));
|
|
178
|
+
})(subscriptions || (subscriptions = {}));
|