@tryvitris/website-admin-contracts 0.1.0-alpha.2 → 1.0.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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Vitris contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vitris contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
- # Website Admin Contracts
2
-
3
- Validated installation manifests, roles, permissions and module contracts for `@tryvitris/website-admin-harness`. Node.js 24+. MIT licensed.
1
+ # Website Admin Contracts
2
+
3
+ Validated installation manifests, roles, permissions and module contracts for `@tryvitris/website-admin-harness`. Node.js 24+. MIT licensed.
@@ -0,0 +1,117 @@
1
+ /** Local preview contracts. These are not a production Stripe integration. */
2
+ export declare const billingPermissions: readonly ["billing:read", "billing:customers:write", "billing:catalog:read", "billing:subscriptions:write", "billing:invoices:write", "billing:collect", "billing:connection:manage", "account-billing:read", "account-billing:manage"];
3
+ export interface BillingCustomer {
4
+ id: string;
5
+ name: string;
6
+ contact: string;
7
+ email: string;
8
+ initials: string;
9
+ color: string;
10
+ websites: string[];
11
+ note: string;
12
+ }
13
+ export interface BillingPlan {
14
+ id: string;
15
+ name: string;
16
+ description: string;
17
+ amount: number;
18
+ interval: 'month' | 'year';
19
+ features: string[];
20
+ selfService: boolean;
21
+ }
22
+ export interface BillingSubscription {
23
+ id: string;
24
+ customerId: string;
25
+ planId: string;
26
+ status: 'active' | 'past_due' | 'trialing' | 'canceled';
27
+ renewal: string;
28
+ cancelAtPeriodEnd: boolean;
29
+ scheduledPlanId: string | null;
30
+ }
31
+ export interface BillingLine {
32
+ description: string;
33
+ quantity: number;
34
+ unitAmount: number;
35
+ }
36
+ export interface BillingInvoice {
37
+ id: string;
38
+ customerId: string;
39
+ number: string;
40
+ description: string;
41
+ lines: BillingLine[];
42
+ status: 'draft' | 'open' | 'paid' | 'void';
43
+ issued: string;
44
+ due: string;
45
+ paidAt: string | null;
46
+ kind: 'subscription' | 'one_off';
47
+ }
48
+ export interface BillingPayment {
49
+ id: string;
50
+ customerId: string;
51
+ invoiceId: string;
52
+ amount: number;
53
+ status: 'succeeded' | 'failed' | 'refunded';
54
+ date: string;
55
+ }
56
+ export interface BillingActivity {
57
+ id: string;
58
+ customerId: string | null;
59
+ text: string;
60
+ at: string;
61
+ }
62
+ export interface BillingState {
63
+ customers: BillingCustomer[];
64
+ plans: BillingPlan[];
65
+ subscriptions: BillingSubscription[];
66
+ invoices: BillingInvoice[];
67
+ payments: BillingPayment[];
68
+ activity: BillingActivity[];
69
+ connection: boolean;
70
+ card: {
71
+ brand: string;
72
+ last4: string;
73
+ expiry: string;
74
+ };
75
+ }
76
+ export interface BillingResponse extends BillingState {
77
+ revision: number;
78
+ simulated: true;
79
+ audience: 'seller' | 'customer';
80
+ customerId: string | null;
81
+ supplier: string;
82
+ asOf: string;
83
+ currency: 'USD';
84
+ }
85
+ export type BillingCommand = {
86
+ action: 'plan';
87
+ subscriptionId: string;
88
+ planId: string;
89
+ timing: 'renewal' | 'now';
90
+ reviewed: boolean;
91
+ } | {
92
+ action: 'cancel' | 'resume';
93
+ subscriptionId: string;
94
+ reviewed: boolean;
95
+ } | {
96
+ action: 'draft';
97
+ invoiceId?: string;
98
+ customerId: string;
99
+ description: string;
100
+ due: string;
101
+ lines: BillingLine[];
102
+ } | {
103
+ action: 'send' | 'void' | 'pay';
104
+ invoiceId: string;
105
+ reviewed: boolean;
106
+ } | {
107
+ action: 'card';
108
+ reviewed: boolean;
109
+ } | {
110
+ action: 'connection';
111
+ connected: boolean;
112
+ };
113
+ export type BillingMutation = BillingCommand & {
114
+ revision: number;
115
+ idempotencyKey: string;
116
+ };
117
+ export declare const invoiceTotal: (invoice: Pick<BillingInvoice, "lines">) => number;
@@ -0,0 +1,7 @@
1
+ // packages/contracts/src/billing.ts
2
+ var billingPermissions = ["billing:read", "billing:customers:write", "billing:catalog:read", "billing:subscriptions:write", "billing:invoices:write", "billing:collect", "billing:connection:manage", "account-billing:read", "account-billing:manage"];
3
+ var invoiceTotal = (invoice) => invoice.lines.reduce((sum, line) => sum + line.quantity * line.unitAmount, 0);
4
+ export {
5
+ billingPermissions,
6
+ invoiceTotal
7
+ };
@@ -0,0 +1,69 @@
1
+ export declare const clientOnboardingPermissions: readonly ["prospects:read", "prospects:write"];
2
+ export interface OnboardingField {
3
+ id: string;
4
+ label: string;
5
+ required: boolean;
6
+ value: string;
7
+ kind?: 'text' | 'textarea' | 'tel' | 'url';
8
+ section?: 'business' | 'website';
9
+ help?: string;
10
+ }
11
+ export interface OnboardingTemplate {
12
+ id: string;
13
+ name: string;
14
+ businessType: string;
15
+ title: string;
16
+ intro: string;
17
+ message: string;
18
+ fields: OnboardingField[];
19
+ requiresPayment: boolean;
20
+ revision: number;
21
+ updatedAt: string | null;
22
+ source: 'starter' | 'saved';
23
+ }
24
+ export interface OnboardingConfig {
25
+ templateId?: string;
26
+ templateName?: string;
27
+ templateRevision?: number;
28
+ title: string;
29
+ intro: string;
30
+ }
31
+ export interface OnboardingDraft {
32
+ name?: string;
33
+ fields?: OnboardingField[];
34
+ step?: 'business' | 'website' | 'account';
35
+ savedAt?: string;
36
+ }
37
+ export interface Prospect {
38
+ id: string;
39
+ business: string;
40
+ name: string;
41
+ email: string;
42
+ previewUrl: string;
43
+ message: string;
44
+ status: 'draft' | 'invited' | 'expired' | 'active' | 'revoked';
45
+ createdAt: string;
46
+ invitedAt: string | null;
47
+ expiresAt: string | null;
48
+ activatedAt: string | null;
49
+ feedback: string;
50
+ feedbackAt: string | null;
51
+ fields: OnboardingField[];
52
+ requiresPayment: boolean;
53
+ paymentStatus: 'not_requested' | 'pending' | 'demo_complete';
54
+ onboarding?: OnboardingConfig;
55
+ }
56
+ export interface ProspectWorkspace {
57
+ rows: Prospect[];
58
+ templates: OnboardingTemplate[];
59
+ localOnly: true;
60
+ delivery: 'copy-link';
61
+ }
62
+ export type ProspectPortal = Pick<Prospect, 'business' | 'name' | 'email' | 'previewUrl' | 'message' | 'feedback' | 'feedbackAt' | 'fields' | 'requiresPayment' | 'paymentStatus'> & {
63
+ onboarding?: Pick<OnboardingConfig, 'title' | 'intro'>;
64
+ draft?: OnboardingDraft;
65
+ inviteId?: string;
66
+ };
67
+ export declare function normalizeOnboardingFields(value: unknown): OnboardingField[] | null;
68
+ export declare function onboardingFieldError(field: OnboardingField): string | null;
69
+ export declare function onboardingAnswersMatch(answers: OnboardingField[], original: OnboardingField[], complete?: boolean): boolean;
@@ -0,0 +1,35 @@
1
+ // packages/contracts/src/client-onboarding.ts
2
+ var clientOnboardingPermissions = ["prospects:read", "prospects:write"];
3
+ function normalizeOnboardingFields(value) {
4
+ if (!Array.isArray(value) || value.length > 10) return null;
5
+ const result = [];
6
+ for (const item of value) {
7
+ if (!item || typeof item !== "object" || Array.isArray(item)) return null;
8
+ const f = item;
9
+ if (typeof f.id !== "string" || !/^[\w-]{1,60}$/.test(f.id) || result.some((v) => v.id === f.id) || typeof f.label !== "string" || !f.label.trim() || f.label.trim().length > 80 || typeof f.required !== "boolean" || typeof f.value !== "string" || f.value.trim().length > 1e3 || f.kind !== void 0 && !["text", "textarea", "tel", "url"].includes(String(f.kind)) || f.section !== void 0 && !["business", "website"].includes(String(f.section)) || f.help !== void 0 && (typeof f.help !== "string" || f.help.length > 180)) return null;
10
+ result.push({ id: f.id, label: f.label.trim(), required: f.required, value: f.value.trim(), ...f.kind ? { kind: f.kind } : {}, ...f.section ? { section: f.section } : {}, ...f.help ? { help: String(f.help).trim() } : {} });
11
+ }
12
+ return result;
13
+ }
14
+ function onboardingFieldError(field) {
15
+ if (!field.value.trim()) return field.required ? "Please complete this field." : null;
16
+ if (field.kind === "tel" && field.value.replace(/[^0-9]/g, "").length < 5) return "Enter a phone number.";
17
+ if (field.kind === "url") {
18
+ try {
19
+ const u = new URL(field.value);
20
+ if (!["http:", "https:"].includes(u.protocol) || !u.hostname.includes(".") || u.username || u.password) return "Enter a complete website URL.";
21
+ } catch {
22
+ return "Enter a complete website URL, including https://.";
23
+ }
24
+ }
25
+ return null;
26
+ }
27
+ function onboardingAnswersMatch(answers, original, complete = false) {
28
+ return answers.length === original.length && original.every((f) => answers.some((a) => a.id === f.id && a.label === f.label && a.required === f.required && (a.kind || "text") === (f.kind || "text") && (a.section || "business") === (f.section || "business") && (a.help || "") === (f.help || "") && (!complete || !onboardingFieldError(a))));
29
+ }
30
+ export {
31
+ clientOnboardingPermissions,
32
+ normalizeOnboardingFields,
33
+ onboardingAnswersMatch,
34
+ onboardingFieldError
35
+ };
@@ -0,0 +1,64 @@
1
+ import type { AnalyticsRow, AnalyticsResponse } from './index.ts';
2
+ export declare const clientPortfolioPermissions: readonly ["clients:read", "client-changes:request", "client-releases:publish"];
3
+ export type PortfolioStatus = 'requested' | 'in_progress' | 'preview_ready' | 'queued' | 'published' | 'failed' | 'canceled';
4
+ export interface PortfolioClient {
5
+ id: string;
6
+ name: string;
7
+ contact: string;
8
+ sector: string;
9
+ }
10
+ export interface PortfolioWebsite {
11
+ id: string;
12
+ clientId: string;
13
+ name: string;
14
+ origin: string;
15
+ initials: string;
16
+ color: string;
17
+ connection: 'healthy' | 'unavailable' | 'not_configured';
18
+ lastSuccess: string | null;
19
+ rows: AnalyticsRow[];
20
+ previousRows: AnalyticsRow[];
21
+ source?: 'synthetic' | 'connected' | 'not-connected';
22
+ message?: string;
23
+ windows?: Partial<Record<'14' | '30', AnalyticsResponse>>;
24
+ /** Verified collector activation, independent of padded/reporting-window rows. */
25
+ trackingStartedAt?: string;
26
+ }
27
+ export interface PortfolioChange {
28
+ id: string;
29
+ websiteId: string;
30
+ title: string;
31
+ request: string;
32
+ status: PortfolioStatus;
33
+ candidate: string | null;
34
+ createdAt: string;
35
+ updatedAt: string;
36
+ idempotencyKey: string;
37
+ history: {
38
+ label: string;
39
+ at: string;
40
+ }[];
41
+ checks: {
42
+ label: string;
43
+ result: 'simulated' | 'failed';
44
+ }[];
45
+ receipt: {
46
+ id: string;
47
+ candidate: string;
48
+ publishedAt: string;
49
+ simulated: true;
50
+ } | null;
51
+ }
52
+ export interface PortfolioState {
53
+ clients: PortfolioClient[];
54
+ websites: PortfolioWebsite[];
55
+ changes: PortfolioChange[];
56
+ runnerOnline: boolean;
57
+ }
58
+ export interface PortfolioResponse extends PortfolioState {
59
+ revision: number;
60
+ simulated: true;
61
+ analyticsMode?: 'live';
62
+ }
63
+ export type PortfolioAction = 'start' | 'prepare' | 'fail' | 'retry' | 'cancel' | 'queue' | 'publish';
64
+ export declare function isTrackingTimestamp(value: unknown): value is string;
@@ -0,0 +1,9 @@
1
+ // packages/contracts/src/client-portfolio.ts
2
+ var clientPortfolioPermissions = ["clients:read", "client-changes:request", "client-releases:publish"];
3
+ function isTrackingTimestamp(value) {
4
+ return typeof value === "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(value) && Number.isFinite(Date.parse(value)) && new Date(value).toISOString() === value;
5
+ }
6
+ export {
7
+ clientPortfolioPermissions,
8
+ isTrackingTimestamp
9
+ };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,11 @@
1
+ export * from './billing.js';
2
+ export * from './stripe-billing.js';
3
+ export * from './client-portfolio.js';
4
+ export * from './client-onboarding.js';
1
5
  export * from './scheduling.js';
2
6
  export declare const contractVersion = 1;
3
7
  export declare const coreSections: readonly ["overview", "leads", "analytics", "settings", "access", "activity"];
4
- export declare const permissions: readonly ["leads:read", "leads:write", "analytics:read", "settings:write", "access:read", "activity:read", "tasks:read", "tasks:write", "appointments:read", "appointments:write", "availability:write", "scheduling:configure", "calendar-connections:manage"];
8
+ export declare const permissions: readonly ["leads:read", "leads:write", "analytics:read", "settings:write", "access:read", "access:write", "activity:read", "tasks:read", "tasks:write", "appointments:read", "appointments:write", "availability:write", "scheduling:configure", "calendar-connections:manage", "clients:read", "client-changes:request", "client-releases:publish", "prospects:read", "prospects:write", "billing:read", "billing:customers:write", "billing:catalog:read", "billing:subscriptions:write", "billing:invoices:write", "billing:collect", "billing:connection:manage", "account-billing:read", "account-billing:manage"];
5
9
  export type Permission = typeof permissions[number];
6
10
  export type Role = 'owner' | 'administrator' | 'editor' | 'analyst';
7
11
  export declare const roles: Record<Role, readonly Permission[]>;
@@ -32,6 +36,7 @@ export type WebsiteTheme = Partial<Record<typeof websiteColorKeys[number], strin
32
36
  export declare function isThemeColor(value: unknown): value is string;
33
37
  export declare function isWebsiteTheme(value: unknown): value is WebsiteTheme;
34
38
  export interface ModuleDefinition {
39
+ ui?: 'stripe-billing' | 'stripe-account';
35
40
  id: string;
36
41
  version: number;
37
42
  label: string;
@@ -53,6 +58,9 @@ export interface BootstrapResponse {
53
58
  capabilities: string[];
54
59
  theme?: WebsiteTheme | null;
55
60
  themeStatus?: 'website' | 'installation' | 'unavailable' | 'default';
61
+ accountAuth?: AccountCapabilities;
62
+ emailLoginConfigured?: boolean;
63
+ privateLocalSignIn?: boolean;
56
64
  }
57
65
  export type DataSource = 'synthetic' | 'connected' | 'not-connected';
58
66
  export interface LeadRow {
@@ -68,7 +76,28 @@ export interface LeadRow {
68
76
  notification_policy?: string | null;
69
77
  notification_status?: string | null;
70
78
  notification_error?: string | null;
79
+ followUp?: LeadFollowUp;
71
80
  }
81
+ export interface LeadFollowUp {
82
+ assignedTo: string | null;
83
+ dueDate: string | null;
84
+ notes: string;
85
+ completed: boolean;
86
+ revision: number;
87
+ updatedAt: string | null;
88
+ }
89
+ export interface LeadPagination {
90
+ version: 1;
91
+ total: number;
92
+ newCount: number;
93
+ nextCursor: string | null;
94
+ }
95
+ export interface LeadTeamMember {
96
+ id: string;
97
+ email: string;
98
+ }
99
+ export declare function isLeadFollowUp(value: unknown): value is LeadFollowUp;
100
+ export declare function isLeadPagination(value: unknown): value is LeadPagination;
72
101
  export declare const analyticsMetricKeys: readonly ["sessions", "bounces", "engaged", "duration_ms", "leave_count", "scroll_25", "scroll_50", "scroll_75", "scroll_100", "converts_form", "converts_tel", "converts_mailto", "converts_maps", "engage_nav", "engage_btn", "engage_img", "engage_carousel"];
73
102
  export declare const analyticsBreakdownKeys: readonly ["top_paths_json", "top_refs_json", "channels_json", "devices_json", "hours_json", "top_engage_json"];
74
103
  export type AnalyticsMetric = 'views' | 'visitors' | 'enquiries' | typeof analyticsMetricKeys[number];
@@ -89,6 +118,9 @@ export interface LeadsResponse {
89
118
  writable?: boolean;
90
119
  message?: string;
91
120
  mode?: string;
121
+ followUpsEnabled?: boolean;
122
+ pagination?: LeadPagination;
123
+ truncated?: boolean;
92
124
  }
93
125
  export interface AnalyticsResponse {
94
126
  rows: AnalyticsRow[];
@@ -105,6 +137,33 @@ export interface SettingsResponse {
105
137
  export interface AccessRow extends User {
106
138
  active: number;
107
139
  }
140
+ export interface AccountCapabilities {
141
+ enabled: boolean;
142
+ emailReady: boolean;
143
+ setupAvailable: boolean;
144
+ emailVerified: boolean;
145
+ canInvite: boolean;
146
+ }
147
+ export interface AccountAction {
148
+ purpose: 'owner' | 'invite' | 'verify' | 'reset';
149
+ email: string;
150
+ expiresAt: number;
151
+ business: string;
152
+ }
153
+ export interface TeamInvitation {
154
+ id: string;
155
+ email: string;
156
+ role: string;
157
+ expiresAt: number;
158
+ status: 'accepted' | 'canceled' | 'expired' | 'pending';
159
+ delivery: 'pending' | 'sending' | 'sent' | 'failed' | 'superseded';
160
+ }
161
+ export interface AccessResponse extends RowsResponse<AccessRow & {
162
+ email_verified_at?: number | null;
163
+ }> {
164
+ invitations?: TeamInvitation[];
165
+ accountAuth?: AccountCapabilities;
166
+ }
108
167
  export interface ActivityRow {
109
168
  id: string;
110
169
  actor: string;
package/dist/index.js CHANGED
@@ -1,11 +1,18 @@
1
1
  import { schedulingPermissions } from "./scheduling.js";
2
+ import { clientPortfolioPermissions } from "./client-portfolio.js";
3
+ import { clientOnboardingPermissions } from "./client-onboarding.js";
4
+ import { billingPermissions } from "./billing.js";
5
+ export * from "./billing.js";
6
+ export * from "./stripe-billing.js";
7
+ export * from "./client-portfolio.js";
8
+ export * from "./client-onboarding.js";
2
9
  export * from "./scheduling.js";
3
10
  const contractVersion = 1;
4
11
  const coreSections = ["overview", "leads", "analytics", "settings", "access", "activity"];
5
- const permissions = ["leads:read", "leads:write", "analytics:read", "settings:write", "access:read", "activity:read", "tasks:read", "tasks:write", ...schedulingPermissions];
12
+ const permissions = ["leads:read", "leads:write", "analytics:read", "settings:write", "access:read", "access:write", "activity:read", "tasks:read", "tasks:write", ...schedulingPermissions, ...clientPortfolioPermissions, ...clientOnboardingPermissions, ...billingPermissions];
6
13
  const roles = {
7
14
  owner: permissions,
8
- administrator: permissions,
15
+ administrator: permissions.filter((p) => p !== "access:write" && !clientPortfolioPermissions.includes(p) && !clientOnboardingPermissions.includes(p) && !billingPermissions.includes(p)),
9
16
  editor: ["leads:read", "leads:write", "activity:read", "tasks:read", "tasks:write"],
10
17
  analyst: ["analytics:read", "activity:read"]
11
18
  };
@@ -27,6 +34,13 @@ function isThemeColor(value) {
27
34
  function isWebsiteTheme(value) {
28
35
  return isObject(value) && Object.keys(value).length > 0 && Object.entries(value).every(([key, color]) => websiteColorKeys.includes(key) && isThemeColor(color));
29
36
  }
37
+ function isLeadFollowUp(value) {
38
+ if (!isObject(value)) return false;
39
+ return (value.assignedTo === null || typeof value.assignedTo === "string" && value.assignedTo.length > 0 && value.assignedTo.length <= 100) && (value.dueDate === null || typeof value.dueDate === "string" && /^\d{4}-\d{2}-\d{2}$/.test(value.dueDate) && Number.isFinite(Date.parse(value.dueDate + "T00:00:00Z")) && (/* @__PURE__ */ new Date(value.dueDate + "T00:00:00Z")).toISOString().slice(0, 10) === value.dueDate) && typeof value.notes === "string" && value.notes.length <= 3e3 && typeof value.completed === "boolean" && Number.isSafeInteger(value.revision) && Number(value.revision) >= 0 && (value.updatedAt === null || typeof value.updatedAt === "string");
40
+ }
41
+ function isLeadPagination(value) {
42
+ return isObject(value) && value.version === 1 && [value.total, value.newCount].every((n) => Number.isSafeInteger(n) && Number(n) >= 0) && (value.nextCursor === null || typeof value.nextCursor === "string" && value.nextCursor.length <= 4096);
43
+ }
30
44
  const analyticsMetricKeys = ["sessions", "bounces", "engaged", "duration_ms", "leave_count", "scroll_25", "scroll_50", "scroll_75", "scroll_100", "converts_form", "converts_tel", "converts_mailto", "converts_maps", "engage_nav", "engage_btn", "engage_img", "engage_carousel"];
31
45
  const analyticsBreakdownKeys = ["top_paths_json", "top_refs_json", "channels_json", "devices_json", "hours_json", "top_engage_json"];
32
46
  function isObject(value) {
@@ -34,7 +48,7 @@ function isObject(value) {
34
48
  }
35
49
  function isLeadRow(value) {
36
50
  if (!isObject(value)) return false;
37
- return ["id", "name", "email", "message", "status", "created_at"].every((key) => typeof value[key] === "string") && ["source", "phone", "fields_json", "notification_policy", "notification_status", "notification_error"].every((key) => value[key] === void 0 || value[key] === null || typeof value[key] === "string");
51
+ return ["id", "name", "email", "message", "status", "created_at"].every((key) => typeof value[key] === "string") && ["source", "phone", "fields_json", "notification_policy", "notification_status", "notification_error"].every((key) => value[key] === void 0 || value[key] === null || typeof value[key] === "string") && (value.followUp === void 0 || isLeadFollowUp(value.followUp));
38
52
  }
39
53
  function isAnalyticsRow(value) {
40
54
  if (!isObject(value) || typeof value.day !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(value.day)) return false;
@@ -128,6 +142,8 @@ export {
128
142
  contractVersion,
129
143
  coreSections,
130
144
  isAnalyticsRow,
145
+ isLeadFollowUp,
146
+ isLeadPagination,
131
147
  isLeadRow,
132
148
  isLoopback,
133
149
  isObject,
@@ -0,0 +1,103 @@
1
+ /** Installation choices, supplied by trusted source rather than browser input. */
2
+ export interface StripeBillingConfig {
3
+ accountId: string;
4
+ mode: 'test' | 'live';
5
+ currency: string;
6
+ prices: string[];
7
+ portalConfigurationId?: string;
8
+ allowLiveWrites?: boolean;
9
+ grants?: BillingAccountGrant[];
10
+ }
11
+ export interface BillingAccountGrant {
12
+ id: string;
13
+ tokenHash: string;
14
+ customerId: string;
15
+ installationId: string;
16
+ siteId: string;
17
+ adminOrigin: string;
18
+ manage: boolean;
19
+ enabled: boolean;
20
+ }
21
+ export interface BillingAccountConfig {
22
+ sellerOrigin: string;
23
+ sellerInstallationId: string;
24
+ sellerSiteId: string;
25
+ grantId: string;
26
+ customerId: string;
27
+ mode: 'test' | 'live';
28
+ }
29
+ export interface StripeCustomer {
30
+ id: string;
31
+ name: string;
32
+ email: string;
33
+ stripeId: string;
34
+ createdAt: number;
35
+ }
36
+ export interface StripePrice {
37
+ id: string;
38
+ name: string;
39
+ amount: number;
40
+ currency: string;
41
+ interval: 'month' | 'year' | null;
42
+ intervalCount: number;
43
+ }
44
+ export interface StripeRecord {
45
+ id: string;
46
+ customerId: string;
47
+ kind: 'invoice' | 'subscription' | 'checkout' | 'payment';
48
+ status: string;
49
+ amount: number;
50
+ paid: number;
51
+ remaining: number;
52
+ currency: string;
53
+ label: string;
54
+ date: number | null;
55
+ cancelAtPeriodEnd: boolean;
56
+ cancelAt?: number | null;
57
+ priceIds: string[];
58
+ }
59
+ export interface StripeInvoiceDraft {
60
+ id: string;
61
+ customerId: string;
62
+ description: string;
63
+ lines: {
64
+ description: string;
65
+ quantity: number;
66
+ unitAmount: number;
67
+ }[];
68
+ dueDays: number;
69
+ revision: number;
70
+ state: 'draft' | 'issuing' | 'issued';
71
+ stripeId: string | null;
72
+ }
73
+ export interface StripeBillingView {
74
+ provider: 'stripe';
75
+ simulated: false;
76
+ audience: 'seller' | 'customer';
77
+ installationId: string;
78
+ siteId: string;
79
+ mode: 'test' | 'live';
80
+ currency: string;
81
+ business: string;
82
+ setup: {
83
+ configured: boolean;
84
+ verified: boolean;
85
+ webhookConfigured: boolean;
86
+ liveWritesAllowed: boolean;
87
+ verifiedAt: number | null;
88
+ };
89
+ customers: StripeCustomer[];
90
+ records: StripeRecord[];
91
+ drafts: StripeInvoiceDraft[];
92
+ prices: StripePrice[];
93
+ operations: {
94
+ id: string;
95
+ kind: string;
96
+ state: string;
97
+ createdAt: number;
98
+ }[];
99
+ sync: {
100
+ pending: number;
101
+ failed: number;
102
+ };
103
+ }
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvitris/website-admin-contracts",
3
- "version": "0.1.0-alpha.2",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Validated installation and module contracts for Cloudflare business admin apps",
@@ -19,7 +19,7 @@
19
19
  ],
20
20
  "publishConfig": {
21
21
  "access": "public",
22
- "tag": "alpha"
22
+ "tag": "latest"
23
23
  },
24
24
  "engines": {
25
25
  "node": ">=24"