@tryvitris/website-admin-contracts 1.0.0 → 1.1.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/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from './stripe-billing.js';
3
3
  export * from './client-portfolio.js';
4
4
  export * from './client-onboarding.js';
5
5
  export * from './scheduling.js';
6
+ export * from './webmaster.js';
6
7
  export declare const contractVersion = 1;
7
8
  export declare const coreSections: readonly ["overview", "leads", "analytics", "settings", "access", "activity"];
8
9
  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"];
@@ -47,7 +48,14 @@ export interface User {
47
48
  id: string;
48
49
  email: string;
49
50
  role: Role;
51
+ webmaster?: {
52
+ organizationId: string;
53
+ organizationName: string;
54
+ permissions: Permission[];
55
+ revision: number;
56
+ };
50
57
  }
58
+ export declare function userCan(user: User, permission: Permission): boolean;
51
59
  export interface BootstrapResponse {
52
60
  manifest: AdminManifest;
53
61
  user: User | null;
@@ -61,6 +69,7 @@ export interface BootstrapResponse {
61
69
  accountAuth?: AccountCapabilities;
62
70
  emailLoginConfigured?: boolean;
63
71
  privateLocalSignIn?: boolean;
72
+ webmasterEnabled?: boolean;
64
73
  }
65
74
  export type DataSource = 'synthetic' | 'connected' | 'not-connected';
66
75
  export interface LeadRow {
@@ -169,6 +178,9 @@ export interface ActivityRow {
169
178
  actor: string;
170
179
  action: string;
171
180
  created_at: string;
181
+ person_id?: string | null;
182
+ organization_id?: string | null;
183
+ organization_name?: string | null;
172
184
  }
173
185
  export interface TaskRow {
174
186
  id: string;
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ export * from "./stripe-billing.js";
7
7
  export * from "./client-portfolio.js";
8
8
  export * from "./client-onboarding.js";
9
9
  export * from "./scheduling.js";
10
+ export * from "./webmaster.js";
10
11
  const contractVersion = 1;
11
12
  const coreSections = ["overview", "leads", "analytics", "settings", "access", "activity"];
12
13
  const permissions = ["leads:read", "leads:write", "analytics:read", "settings:write", "access:read", "access:write", "activity:read", "tasks:read", "tasks:write", ...schedulingPermissions, ...clientPortfolioPermissions, ...clientOnboardingPermissions, ...billingPermissions];
@@ -34,6 +35,9 @@ function isThemeColor(value) {
34
35
  function isWebsiteTheme(value) {
35
36
  return isObject(value) && Object.keys(value).length > 0 && Object.entries(value).every(([key, color]) => websiteColorKeys.includes(key) && isThemeColor(color));
36
37
  }
38
+ function userCan(user, permission) {
39
+ return user.webmaster ? user.webmaster.permissions.includes(permission) : can(user.role, permission);
40
+ }
37
41
  function isLeadFollowUp(value) {
38
42
  if (!isObject(value)) return false;
39
43
  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");
@@ -152,6 +156,7 @@ export {
152
156
  parseManifest,
153
157
  permissions,
154
158
  roles,
159
+ userCan,
155
160
  validateModules,
156
161
  websiteColorKeys,
157
162
  workQueueModule
@@ -0,0 +1,25 @@
1
+ /** Operational access never includes ownership, access administration or billing. */
2
+ export declare const webmasterScopes: readonly ["analytics:read", "settings:write", "tasks:read", "tasks:write", "leads:read", "leads:write"];
3
+ export type WebmasterScope = typeof webmasterScopes[number];
4
+ export interface WebmasterMember {
5
+ userId: string;
6
+ permissions: WebmasterScope[];
7
+ }
8
+ export interface WebmasterConnection {
9
+ organizationId: string;
10
+ organizationName: string;
11
+ billingProvider: boolean;
12
+ status: 'connected' | 'disconnected';
13
+ revision: number;
14
+ members: WebmasterMember[];
15
+ permissions: WebmasterScope[];
16
+ }
17
+ export interface WebmasterResponse {
18
+ connection: WebmasterConnection | null;
19
+ canManage: boolean;
20
+ eligibleUsers: Array<{
21
+ id: string;
22
+ email: string;
23
+ }>;
24
+ }
25
+ export declare function validWebmasterScopes(value: unknown): value is WebmasterScope[];
@@ -0,0 +1,9 @@
1
+ // packages/contracts/src/webmaster.ts
2
+ var webmasterScopes = ["analytics:read", "settings:write", "tasks:read", "tasks:write", "leads:read", "leads:write"];
3
+ function validWebmasterScopes(value) {
4
+ return Array.isArray(value) && value.length <= webmasterScopes.length && new Set(value).size === value.length && value.every((p) => webmasterScopes.includes(p)) && (!value.includes("leads:write") || value.includes("leads:read")) && (!value.includes("tasks:write") || value.includes("tasks:read"));
5
+ }
6
+ export {
7
+ validWebmasterScopes,
8
+ webmasterScopes
9
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvitris/website-admin-contracts",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Validated installation and module contracts for Cloudflare business admin apps",