@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/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
|
+
*/
|
|
@@ -715,6 +715,38 @@ export interface ServerFunctionSl {
|
|
|
715
715
|
messages: {
|
|
716
716
|
send(input: ServerFunctionMessage): Promise<ServerFunctionMessageResult>;
|
|
717
717
|
};
|
|
718
|
+
/**
|
|
719
|
+
* Memberships (`sl:subscriptions:read` / `sl:subscriptions:write`): plans, and who holds which. Check a
|
|
720
|
+
* members-only page with `memberOf()` (the caller, or `{ contactId | userId }`). Write: grant a plan by hand
|
|
721
|
+
* (free, honorary, paid another way), end or cancel one. Joining with a payment is always the member's own
|
|
722
|
+
* Stripe checkout (`subscriptions.start` in the browser), never here. docs/memberships.md.
|
|
723
|
+
*/
|
|
724
|
+
subscriptions: {
|
|
725
|
+
plans(): Promise<Array<import('./subscriptions.js').Plan & {
|
|
726
|
+
prices: import('./subscriptions.js').PlanPrice[];
|
|
727
|
+
}>>;
|
|
728
|
+
list(params?: import('./subscriptions.js').SubscriptionListParams): Promise<import('./subscriptions.js').SubscriptionPage<import('./subscriptions.js').Membership>>;
|
|
729
|
+
get(subscriptionId: string): Promise<import('./subscriptions.js').Membership | null>;
|
|
730
|
+
mine(): Promise<import('./subscriptions.js').Membership[]>;
|
|
731
|
+
memberOf(who?: {
|
|
732
|
+
contactId?: string;
|
|
733
|
+
userId?: string;
|
|
734
|
+
}): Promise<import('./subscriptions.js').MembershipStatus>;
|
|
735
|
+
grant(input: import('./subscriptions.js').SubscriptionGrantInput): Promise<import('./subscriptions.js').Membership>;
|
|
736
|
+
end(subscriptionId: string, opts?: {
|
|
737
|
+
reason?: string;
|
|
738
|
+
}): Promise<import('./subscriptions.js').Membership>;
|
|
739
|
+
cancel(subscriptionId: string, opts?: {
|
|
740
|
+
atPeriodEnd?: boolean;
|
|
741
|
+
}): Promise<import('./subscriptions.js').Membership>;
|
|
742
|
+
reapply(who: {
|
|
743
|
+
contactId?: string;
|
|
744
|
+
userId?: string;
|
|
745
|
+
}): Promise<{
|
|
746
|
+
level?: string | null;
|
|
747
|
+
groups: string[];
|
|
748
|
+
}>;
|
|
749
|
+
};
|
|
718
750
|
/**
|
|
719
751
|
* Platform tools (`tools:<name>` or `tools:<family>.*`, e.g. `tools:pdf.create`, `tools:pdf.*`):
|
|
720
752
|
* pdf.create, pdf.merge, pdf.fill, pdf.inspect, pdf.render, pdf.decodeBarcodes, pdf.inspectGraphics,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export * from "./appManifest.js";
|
|
|
43
43
|
export * from "./appObjects.js";
|
|
44
44
|
export * from "./bookings.js";
|
|
45
45
|
export * from "./shop.js";
|
|
46
|
+
export * from "./subscriptions.js";
|
|
46
47
|
export * from "./loyalty.js";
|
|
47
48
|
export * from "./translations.js";
|
|
48
49
|
export * from "./integrations.js";
|
package/dist/types/index.js
CHANGED
|
@@ -45,6 +45,7 @@ export * from "./appManifest.js";
|
|
|
45
45
|
export * from "./appObjects.js";
|
|
46
46
|
export * from "./bookings.js";
|
|
47
47
|
export * from "./shop.js";
|
|
48
|
+
export * from "./subscriptions.js";
|
|
48
49
|
export * from "./loyalty.js";
|
|
49
50
|
export * from "./translations.js";
|
|
50
51
|
export * from "./integrations.js";
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/** `recurring` renews until cancelled; `fixed` is one payment that lasts `length`, then ends. */
|
|
2
|
+
export type PlanTerm = 'recurring' | 'fixed';
|
|
3
|
+
export interface PlanLength {
|
|
4
|
+
unit: 'month' | 'year';
|
|
5
|
+
count: number;
|
|
6
|
+
}
|
|
7
|
+
/** What a live subscription to the plan gives. `rank`: when someone holds two plans, the highest sets the level. */
|
|
8
|
+
export interface PlanGrants {
|
|
9
|
+
level?: string;
|
|
10
|
+
/** User group ids the member joins (members-only content, screens). */
|
|
11
|
+
groups?: string[];
|
|
12
|
+
rank?: number;
|
|
13
|
+
}
|
|
14
|
+
/** Products sent each period (a wine club's quarterly case). */
|
|
15
|
+
export interface PlanIncludes {
|
|
16
|
+
items?: Array<{
|
|
17
|
+
productId: string;
|
|
18
|
+
variantId?: string;
|
|
19
|
+
quantity: number;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
/** A plan as the business manages it. */
|
|
23
|
+
export interface Plan {
|
|
24
|
+
id: string;
|
|
25
|
+
collectionId: string;
|
|
26
|
+
name: string;
|
|
27
|
+
description: string | null;
|
|
28
|
+
image: string | null;
|
|
29
|
+
term: PlanTerm;
|
|
30
|
+
length: PlanLength | null;
|
|
31
|
+
grants: PlanGrants;
|
|
32
|
+
includes: PlanIncludes;
|
|
33
|
+
/** Open to new members. */
|
|
34
|
+
active: boolean;
|
|
35
|
+
sort: number;
|
|
36
|
+
metadata: Record<string, any>;
|
|
37
|
+
createdAt: string;
|
|
38
|
+
updatedAt: string;
|
|
39
|
+
}
|
|
40
|
+
export interface PlanInput {
|
|
41
|
+
name: string;
|
|
42
|
+
description?: string | null;
|
|
43
|
+
image?: string | null;
|
|
44
|
+
term?: PlanTerm;
|
|
45
|
+
/** Required for a `fixed` plan. */
|
|
46
|
+
length?: PlanLength;
|
|
47
|
+
grants?: PlanGrants;
|
|
48
|
+
includes?: PlanIncludes;
|
|
49
|
+
active?: boolean;
|
|
50
|
+
sort?: number;
|
|
51
|
+
metadata?: Record<string, any>;
|
|
52
|
+
}
|
|
53
|
+
export type PlanUpdate = Partial<PlanInput>;
|
|
54
|
+
/** One of a plan's prices: a currency and a billing period (`interval` null = paid once, for a fixed plan). */
|
|
55
|
+
export interface PlanPrice {
|
|
56
|
+
id: string;
|
|
57
|
+
planId: string;
|
|
58
|
+
currency: string;
|
|
59
|
+
amount: number;
|
|
60
|
+
compareAtAmount: number | null;
|
|
61
|
+
/** `month` or `year`, every `intervalCount` of them (every 3 months = month, 3). Null for a fixed plan. */
|
|
62
|
+
interval: 'month' | 'year' | null;
|
|
63
|
+
intervalCount: number;
|
|
64
|
+
/** Free days before the first payment (recurring plans only). */
|
|
65
|
+
trialDays: number | null;
|
|
66
|
+
active: boolean;
|
|
67
|
+
sort: number;
|
|
68
|
+
}
|
|
69
|
+
export interface PlanPriceInput {
|
|
70
|
+
/** Defaults to the shop's currency. */
|
|
71
|
+
currency?: string;
|
|
72
|
+
amount: number;
|
|
73
|
+
compareAtAmount?: number | null;
|
|
74
|
+
/** Required for a recurring plan; not allowed for a fixed one. */
|
|
75
|
+
interval?: 'month' | 'year';
|
|
76
|
+
intervalCount?: number;
|
|
77
|
+
trialDays?: number | null;
|
|
78
|
+
active?: boolean;
|
|
79
|
+
sort?: number;
|
|
80
|
+
}
|
|
81
|
+
/** A plan with its prices, as the admin lists it. */
|
|
82
|
+
export interface PlanWithPrices extends Plan {
|
|
83
|
+
prices: PlanPrice[];
|
|
84
|
+
/** Live members (on `admin.getPlan`). */
|
|
85
|
+
members?: number;
|
|
86
|
+
}
|
|
87
|
+
/** A plan as a join page shows it: no private fields. */
|
|
88
|
+
export interface PublicPlan {
|
|
89
|
+
id: string;
|
|
90
|
+
name: string;
|
|
91
|
+
description: string | null;
|
|
92
|
+
image: string | null;
|
|
93
|
+
term: PlanTerm;
|
|
94
|
+
length: PlanLength | null;
|
|
95
|
+
level: string | null;
|
|
96
|
+
prices: Array<Pick<PlanPrice, 'id' | 'currency' | 'amount' | 'compareAtAmount' | 'interval' | 'intervalCount' | 'trialDays'>>;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* - `trialing` in a free trial
|
|
100
|
+
* - `active` paid up
|
|
101
|
+
* - `past_due` a payment failed and Stripe is retrying; access is kept meanwhile
|
|
102
|
+
* - `cancelling` ends at the end of the paid period; access is kept until then
|
|
103
|
+
* - `ended`
|
|
104
|
+
*/
|
|
105
|
+
export type SubscriptionStatus = 'trialing' | 'active' | 'past_due' | 'cancelling' | 'ended';
|
|
106
|
+
/** `stripe`: paid. `manual`: granted by staff (free, honorary, paid another way). */
|
|
107
|
+
export type SubscriptionSource = 'stripe' | 'manual';
|
|
108
|
+
export interface Membership {
|
|
109
|
+
id: string;
|
|
110
|
+
collectionId: string;
|
|
111
|
+
contactId: string | null;
|
|
112
|
+
userId: string | null;
|
|
113
|
+
planId: string;
|
|
114
|
+
priceId: string | null;
|
|
115
|
+
source: SubscriptionSource;
|
|
116
|
+
status: SubscriptionStatus;
|
|
117
|
+
/** trialing, active, past_due or cancelling: the plan's grants apply. */
|
|
118
|
+
live: boolean;
|
|
119
|
+
currentPeriodStart: string | null;
|
|
120
|
+
currentPeriodEnd: string | null;
|
|
121
|
+
/** When it ends (a fixed plan, a grant with an end, a cancelled one). */
|
|
122
|
+
endsAt: string | null;
|
|
123
|
+
endedAt: string | null;
|
|
124
|
+
cancelReason: 'member' | 'staff' | 'payment_failed' | 'expired' | string | null;
|
|
125
|
+
cancelledBy: string | null;
|
|
126
|
+
/** A downgrade waiting for the next renewal. */
|
|
127
|
+
pendingPriceId: string | null;
|
|
128
|
+
metadata: Record<string, any>;
|
|
129
|
+
createdAt: string;
|
|
130
|
+
updatedAt: string;
|
|
131
|
+
plan?: {
|
|
132
|
+
id: string;
|
|
133
|
+
name: string;
|
|
134
|
+
grants: PlanGrants;
|
|
135
|
+
term: PlanTerm;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/** A member's own membership, as `subscriptions.mine` returns it. */
|
|
139
|
+
export interface MySubscription {
|
|
140
|
+
id: string;
|
|
141
|
+
planId: string;
|
|
142
|
+
priceId: string | null;
|
|
143
|
+
status: SubscriptionStatus;
|
|
144
|
+
live: boolean;
|
|
145
|
+
source: SubscriptionSource;
|
|
146
|
+
currentPeriodEnd: string | null;
|
|
147
|
+
endsAt: string | null;
|
|
148
|
+
pendingPriceId: string | null;
|
|
149
|
+
plan: {
|
|
150
|
+
id: string;
|
|
151
|
+
name: string;
|
|
152
|
+
level: string | null;
|
|
153
|
+
} | null;
|
|
154
|
+
}
|
|
155
|
+
export interface SubscriptionStartInput {
|
|
156
|
+
priceId: string;
|
|
157
|
+
/** Where Stripe sends them after paying, and if they turn back. https, on your site. Default: the shop's. */
|
|
158
|
+
successUrl?: string;
|
|
159
|
+
cancelUrl?: string;
|
|
160
|
+
}
|
|
161
|
+
export interface SubscriptionStartResult {
|
|
162
|
+
checkoutUrl: string;
|
|
163
|
+
sessionId: string;
|
|
164
|
+
}
|
|
165
|
+
export interface SubscriptionListParams {
|
|
166
|
+
status?: SubscriptionStatus;
|
|
167
|
+
/** Only live ones (trialing, active, past_due, cancelling). */
|
|
168
|
+
live?: boolean;
|
|
169
|
+
planId?: string;
|
|
170
|
+
contactId?: string;
|
|
171
|
+
userId?: string;
|
|
172
|
+
limit?: number;
|
|
173
|
+
offset?: number;
|
|
174
|
+
}
|
|
175
|
+
/** Staff give someone a plan, no payment. */
|
|
176
|
+
export interface SubscriptionGrantInput {
|
|
177
|
+
planId: string;
|
|
178
|
+
contactId?: string;
|
|
179
|
+
userId?: string;
|
|
180
|
+
/** ISO date; never ends if left out. */
|
|
181
|
+
endsAt?: string;
|
|
182
|
+
note?: string;
|
|
183
|
+
}
|
|
184
|
+
export interface SubscriptionPage<T> {
|
|
185
|
+
items: T[];
|
|
186
|
+
total: number;
|
|
187
|
+
limit: number;
|
|
188
|
+
offset: number;
|
|
189
|
+
}
|
|
190
|
+
/** Someone's live memberships and the level they give (server functions: `ctx.sl.subscriptions.memberOf`). */
|
|
191
|
+
export interface MembershipStatus {
|
|
192
|
+
member: boolean;
|
|
193
|
+
level: string | null;
|
|
194
|
+
subscriptions: Membership[];
|
|
195
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// src/types/subscriptions.ts
|
|
2
|
+
// Memberships: plans, their prices, and subscriptions — see docs/memberships.md.
|
|
3
|
+
//
|
|
4
|
+
// A PLAN is what members pay for (never a product). A SUBSCRIPTION is one person's membership of a plan,
|
|
5
|
+
// paid through Stripe or granted by staff. While it is live, the platform applies the plan's grants: the
|
|
6
|
+
// contact's `level` and `memberUntil` (customFields) and the plan's user groups.
|
|
7
|
+
//
|
|
8
|
+
// Money is always a whole number of MINOR units (pence, cents): 1299 = £12.99. Prices include VAT.
|
|
9
|
+
export {};
|