deepspace 0.19.0 → 0.19.2

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/schema.d.ts CHANGED
@@ -62,7 +62,7 @@ interface RolePermissions {
62
62
  create: boolean;
63
63
  update: PermissionLevel;
64
64
  delete: PermissionLevel;
65
- /** If set, only these columns can be updated by this role. */
65
+ /** If set, only these caller-supplied columns can be created or updated by this role. */
66
66
  writableFields?: string[];
67
67
  }
68
68
  interface CollectionSchema {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server/schemas/registry.ts","../src/server/schemas/ai-chat.ts","../src/server/schemas/messaging.ts","../src/server/schemas/conversation.ts","../src/server/schemas/directory.ts","../src/server/schemas/workspace.ts"],"sourcesContent":["/**\n * Collection Schema Definitions & Validation\n *\n * All collections use typed SQL columns. No document-mode / fields-based storage.\n */\n\nimport type {\n CollectionSchema,\n ColumnDefinition,\n ColumnInterpretation,\n PermissionLevel,\n RolePermissions,\n} from '../../shared/types'\n\nexport type {\n CollectionSchema,\n ColumnDefinition,\n ColumnInterpretation,\n PermissionLevel,\n RolePermissions,\n} from '../../shared/types'\n\n// ============================================================================\n// Column Definitions\n// ============================================================================\n\nexport interface ResolvedColumn {\n id: string\n name: string\n storage: 'number' | 'text'\n interpretation: ColumnInterpretation\n expression?: string\n readonly: boolean\n userBound?: boolean\n immutable?: boolean\n required?: boolean\n default?: unknown\n timestampTrigger?: { field: string; value?: unknown }\n}\n\n// ============================================================================\n// Column Helpers\n// ============================================================================\n\nexport function collectionTableName(name: string): string {\n return `c_${name.replace(/[^a-zA-Z0-9_]/g, '_')}`\n}\n\nexport function columnId(name: string): string {\n return `col_${name.toLowerCase().replace(/[^a-z0-9]/g, '_')}`\n}\n\nexport function resolveColumn(col: ColumnDefinition): ResolvedColumn {\n const interp: ColumnInterpretation =\n typeof col.interpretation === 'string'\n ? ({ kind: col.interpretation } as ColumnInterpretation)\n : col.interpretation\n return {\n id: col.id ?? columnId(col.name),\n name: col.name,\n storage: col.storage,\n interpretation: interp,\n expression: col.expression,\n readonly: !!col.expression,\n userBound: col.userBound,\n immutable: col.immutable,\n required: col.required,\n default: col.default,\n timestampTrigger: col.timestampTrigger,\n }\n}\n\nexport function rowToData(\n row: Record<string, unknown>,\n columns: ResolvedColumn[],\n): Record<string, unknown> {\n const data: Record<string, unknown> = {}\n for (const col of columns) {\n if (row[col.id] !== undefined && row[col.id] !== null) {\n let val = row[col.id]\n if (col.interpretation.kind === 'json' && typeof val === 'string') {\n try {\n val = JSON.parse(val as string)\n } catch {\n /* keep as string */\n }\n }\n data[col.name] = val\n }\n }\n return data\n}\n\nexport function dataToColumnValues(\n data: Record<string, unknown>,\n columns: ResolvedColumn[],\n): Record<string, unknown> {\n const values: Record<string, unknown> = {}\n for (const col of columns) {\n if (col.expression || col.readonly) continue\n // Record mutations use public schema names only. Accepting physical column\n // ids here lets a second key bypass name-based RBAC/userBound checks.\n const val = data[col.name]\n if (val !== undefined) {\n values[col.id] = coerceValue(val, col.storage, col.interpretation)\n }\n }\n return values\n}\n\nexport function coerceValue(\n value: unknown,\n storage: 'number' | 'text',\n interpretation: ColumnInterpretation,\n): unknown {\n if (value === null || value === undefined || value === '') return null\n\n if (storage === 'text') {\n if (interpretation.kind === 'json') {\n if (typeof value === 'string') return value\n try {\n return JSON.stringify(value)\n } catch {\n return null\n }\n }\n return typeof value === 'string' ? value : String(value)\n }\n\n if (typeof value === 'number') return isFinite(value) ? value : null\n if (typeof value === 'boolean') return value ? 1 : 0\n if (typeof value !== 'string') return String(value)\n\n const s = value.trim()\n\n if (interpretation.kind === 'boolean') {\n const lower = s.toLowerCase()\n if (lower === 'true' || lower === '1' || lower === 'yes') return 1\n if (lower === 'false' || lower === '0' || lower === 'no') return 0\n return s\n }\n\n if (interpretation.kind === 'percent') {\n const m = s.match(/^(-?\\d+(?:\\.\\d+)?)\\s*%$/)\n if (m) return parseFloat(m[1]) / 100\n }\n\n if (interpretation.kind === 'currency') {\n const cleaned = s.replace(/[^0-9.-]/g, '')\n const n = parseFloat(cleaned)\n if (!isNaN(n)) return n\n return s\n }\n\n if (interpretation.kind === 'date' || interpretation.kind === 'datetime') {\n const d = new Date(s)\n if (!isNaN(d.getTime())) return Math.floor(d.getTime() / 1000)\n return s\n }\n\n const cleaned = s.replace(/[$€£¥,\\s]/g, '')\n const n = parseFloat(cleaned)\n if (!isNaN(n) && isFinite(n)) return n\n\n return s\n}\n\nexport function buildTableSelect(collectionName: string, columns: ResolvedColumn[]): string {\n const tbl = collectionTableName(collectionName)\n const parts: string[] = ['_row_id', '_created_by', '_created_at', '_updated_at']\n for (const col of columns) {\n if (col.expression) {\n parts.push(`(${col.expression}) AS \"${col.id}\"`)\n } else {\n parts.push(`\"${col.id}\"`)\n }\n }\n return `SELECT ${parts.join(', ')} FROM \"${tbl}\"`\n}\n\nexport interface User {\n id: string\n email: string\n name: string\n imageUrl?: string\n role: string\n createdAt: string\n lastSeenAt: string\n}\n\nexport interface StoredRecord {\n collection: string\n recordId: string\n data: Record<string, unknown>\n createdBy: string\n createdAt: string\n updatedAt: string\n}\n\n// ============================================================================\n// Permission Checking\n// ============================================================================\n\nexport interface PermissionContext {\n isTeamMember: (teamId: string, userId: string) => boolean\n}\n\nexport const noopPermissionContext: PermissionContext = {\n isTeamMember: () => false,\n}\n\nexport function getRolePermissions(schema: CollectionSchema, role: string): RolePermissions {\n if (schema.permissions[role]) return schema.permissions[role]\n if (schema.permissions['*']) return schema.permissions['*']\n return { read: false, create: false, update: false, delete: false }\n}\n\nexport function isOwner(\n schema: CollectionSchema,\n record: { data: Record<string, unknown>; createdBy: string },\n userId: string,\n): boolean {\n if (schema.ownerField) return record.data[schema.ownerField] === userId\n return record.createdBy === userId\n}\n\nfunction isCollaborator(\n schema: CollectionSchema,\n record: { data: Record<string, unknown> },\n userId: string,\n): boolean {\n if (!schema.collaboratorsField) return false\n const collab = record.data[schema.collaboratorsField]\n if (typeof collab === 'string') {\n try {\n return (JSON.parse(collab) as string[]).includes(userId)\n } catch {\n return false\n }\n }\n if (Array.isArray(collab)) return collab.includes(userId)\n return false\n}\n\nfunction passesVisibilityCheck(\n schema: CollectionSchema,\n record: { data: Record<string, unknown> },\n): boolean {\n if (!schema.visibilityField) return false\n if (typeof schema.visibilityField === 'string') {\n return record.data[schema.visibilityField] === 'public'\n }\n return record.data[schema.visibilityField.field] === schema.visibilityField.value\n}\n\nfunction checkPermissionLevel(\n level: PermissionLevel,\n schema: CollectionSchema,\n record: { data: Record<string, unknown>; createdBy: string; recordId?: string },\n userId: string,\n ctx: PermissionContext = noopPermissionContext,\n): boolean {\n if (level === true) return true\n if (level === false) return false\n if (level === 'own') return isOwner(schema, record, userId)\n if (level === 'unclaimed-or-own') {\n if (schema.ownerField) {\n const ownerVal = record.data[schema.ownerField]\n if (!ownerVal || ownerVal === '') return true\n }\n return isOwner(schema, record, userId)\n }\n if (level === 'collaborator') {\n return isOwner(schema, record, userId) || isCollaborator(schema, record, userId)\n }\n if (level === 'team' || level === 'access') {\n if (isOwner(schema, record, userId)) return true\n if (isCollaborator(schema, record, userId)) return true\n if (schema.teamField) {\n const teamId = record.data[schema.teamField]\n if (typeof teamId === 'string' && ctx.isTeamMember(teamId, userId)) return true\n }\n return false\n }\n if (level === 'published') {\n return isOwner(schema, record, userId) || passesVisibilityCheck(schema, record)\n }\n if (level === 'shared') {\n return (\n isOwner(schema, record, userId) ||\n isCollaborator(schema, record, userId) ||\n passesVisibilityCheck(schema, record)\n )\n }\n return false\n}\n\nexport function canRead(\n schema: CollectionSchema,\n role: string,\n record: { data: Record<string, unknown>; createdBy: string; recordId?: string },\n userId: string,\n ctx: PermissionContext = noopPermissionContext,\n): boolean {\n return checkPermissionLevel(getRolePermissions(schema, role).read, schema, record, userId, ctx)\n}\n\nexport function canCreate(schema: CollectionSchema, role: string): boolean {\n return getRolePermissions(schema, role).create === true\n}\n\nexport function canUpdate(\n schema: CollectionSchema,\n role: string,\n record: { data: Record<string, unknown>; createdBy: string; recordId?: string },\n userId: string,\n ctx: PermissionContext = noopPermissionContext,\n): boolean {\n return checkPermissionLevel(getRolePermissions(schema, role).update, schema, record, userId, ctx)\n}\n\nexport function canDelete(\n schema: CollectionSchema,\n role: string,\n record: { data: Record<string, unknown>; createdBy: string; recordId?: string },\n userId: string,\n ctx: PermissionContext = noopPermissionContext,\n): boolean {\n return checkPermissionLevel(getRolePermissions(schema, role).delete, schema, record, userId, ctx)\n}\n\n/** Check if a field update violates writableFields restrictions. */\nexport function checkFieldPermissions(\n schema: CollectionSchema,\n role: string,\n newData: Record<string, unknown>,\n existingData?: Record<string, unknown>,\n): string | null {\n const perms = getRolePermissions(schema, role)\n if (!perms.writableFields) return null // no restrictions\n\n const allowedFields = new Set(perms.writableFields)\n for (const key of Object.keys(newData)) {\n if (existingData && newData[key] === existingData[key]) continue\n if (!allowedFields.has(key)) {\n return `Role '${role}' cannot modify field '${key}'`\n }\n }\n return null\n}\n\n/**\n * `unclaimed-or-own` lets a client claim an empty owner field, but never lets\n * them choose another user's id. Check the post-write record so the invariant\n * covers both creation and updates while still allowing an owner to unclaim.\n */\nexport function checkUnclaimedOwnerTransition(\n schema: CollectionSchema,\n role: string,\n nextData: Record<string, unknown>,\n userId: string,\n): string | null {\n const permissions = getRolePermissions(schema, role)\n if (permissions.update !== 'unclaimed-or-own' || !schema.ownerField) return null\n\n const nextOwner = nextData[schema.ownerField]\n if (nextOwner === undefined || nextOwner === null || nextOwner === '' || nextOwner === userId) {\n return null\n }\n\n return `Role '${role}' can set '${schema.ownerField}' only to their own user id or leave it unclaimed`\n}\n\n// ============================================================================\n// System-Managed Columns (users collection)\n// ============================================================================\n\n/** Names of columns managed by the system (registerUser), not client mutations. */\nexport const SYSTEM_MANAGED_COLUMNS = new Set([\n 'email',\n 'name',\n 'imageUrl',\n 'role',\n 'createdAt',\n 'lastSeenAt',\n])\n\n/** Standard user columns. Apps spread these into their users schema. */\nexport const USERS_COLUMNS: ColumnDefinition[] = [\n { name: 'email', storage: 'text', interpretation: 'plain' },\n { name: 'name', storage: 'text', interpretation: 'plain' },\n { name: 'imageUrl', storage: 'text', interpretation: 'plain' },\n { name: 'role', storage: 'text', interpretation: 'plain' },\n { name: 'createdAt', storage: 'text', interpretation: { kind: 'datetime' } },\n { name: 'lastSeenAt', storage: 'text', interpretation: { kind: 'datetime' } },\n]\n\nexport const BASE_USERS_SCHEMA: CollectionSchema = {\n name: 'users',\n columns: [...USERS_COLUMNS],\n permissions: {\n '*': { read: 'own', create: false, update: false, delete: false },\n admin: { read: true, create: false, update: true, delete: true },\n },\n}\n\n// ============================================================================\n// Schema Registry\n// ============================================================================\n\n/**\n * Lint a CollectionSchema for declarations that look like they should\n * enforce something but don't, due to interactions between top-level\n * fields (visibilityField, ownerField) and per-role permission levels.\n *\n * The SDK has historically silently accepted schemas that imply more\n * enforcement than they actually deliver — e.g., `visibilityField` set\n * but every role's `read: true` means \"anyone can read everything\"\n * regardless of `visibility`. Warn loudly at registration so app\n * authors notice before shipping a privacy bug.\n *\n * Returns an array of warning messages. Empty = clean.\n */\nexport function lintSchema(schema: CollectionSchema): string[] {\n const warnings: string[] = []\n const VISIBILITY_AWARE: ReadonlyArray<PermissionLevel> = ['published', 'shared']\n\n // Roles that grant unconditional read despite visibilityField being declared.\n if (schema.visibilityField) {\n const offendingRoles = Object.entries(schema.permissions)\n .filter(([, perms]) => perms.read === true)\n .map(([role]) => role)\n if (offendingRoles.length > 0) {\n const usesAware = Object.values(schema.permissions).some(\n (p) => typeof p.read === 'string' && VISIBILITY_AWARE.includes(p.read as PermissionLevel),\n )\n if (!usesAware) {\n warnings.push(\n `[${schema.name}] visibilityField is declared but no role uses read: 'published' or 'shared'. ` +\n `Roles with read: true (${offendingRoles.join(', ')}) will see every row regardless of visibility. ` +\n `Change those to read: 'published' (owner OR public) or 'shared' (owner OR collaborator OR public) ` +\n `to actually enforce the filter, or remove visibilityField if you don't intend to gate reads by it.`,\n )\n }\n }\n }\n\n // An ordinary client role that can create rows must not be able to claim\n // someone else's ownership. Server-written collections legitimately carry\n // a recipient/subject id instead: their non-privileged roles all have\n // create:false, while owner/admin writes are already fully trusted.\n if (schema.ownerField) {\n const col = schema.columns.find((c) => c.name === schema.ownerField)\n const spoofableRoles = Object.entries(schema.permissions)\n .filter(\n ([role, permissions]) =>\n role !== 'owner' &&\n role !== 'admin' &&\n permissions.create === true &&\n permissions.update !== 'unclaimed-or-own',\n )\n .map(([role]) => role)\n if (col && !col.userBound && spoofableRoles.length > 0) {\n warnings.push(\n `[${schema.name}] ownerField is '${schema.ownerField}' but that column is not marked userBound: true. ` +\n `Client role(s) ${spoofableRoles.join(', ')} can create a row with someone else's id in this field, bypassing 'own' permission checks. ` +\n `Add userBound: true (and ideally immutable: true) to the column.`,\n )\n }\n }\n\n // userBound columns that aren't text storage — userBound sets the\n // field to the caller's userId (a string), so non-text storage is a\n // schema mistake that will surface as a coercion error at write time.\n for (const col of schema.columns) {\n if (col.userBound && col.storage !== 'text') {\n warnings.push(\n `[${schema.name}] column '${col.name}' is userBound but storage is '${col.storage}'. ` +\n `userBound stamps the user id (a string); use storage: 'text'.`,\n )\n }\n }\n\n return warnings\n}\n\nexport class SchemaRegistry {\n private trusted: Map<string, CollectionSchema> = new Map()\n\n constructor(schemas: CollectionSchema[] = []) {\n for (const schema of schemas) {\n this.registerTrusted(schema)\n }\n }\n\n registerTrusted(schema: CollectionSchema): void {\n for (const w of lintSchema(schema)) {\n console.warn(`[schema-lint] ${w}`)\n }\n this.trusted.set(schema.name, schema)\n }\n\n get(name: string): CollectionSchema | undefined {\n return this.trusted.get(name)\n }\n\n has(name: string): boolean {\n return this.trusted.has(name)\n }\n\n all(): CollectionSchema[] {\n return Array.from(this.trusted.values())\n }\n\n names(): string[] {\n return Array.from(this.trusted.keys())\n }\n}\n\n// ============================================================================\n// Permission Analysis\n// ============================================================================\n\nexport type PermissionSource = 'explicit' | 'wildcard' | 'default-deny'\n\nexport interface ResolvedPermission {\n level: PermissionLevel | boolean\n source: PermissionSource\n}\n\nexport interface CollectionPermissionSummary {\n collection: string\n ownerField?: string\n collaboratorsField?: string\n teamField?: string\n columns: ColumnDefinition[]\n permissions: Record<\n string,\n {\n read: ResolvedPermission\n create: ResolvedPermission\n update: ResolvedPermission\n delete: ResolvedPermission\n writableFields?: string[]\n }\n >\n}\n\nexport interface PermissionAnalysis {\n roles: string[]\n collections: CollectionPermissionSummary[]\n}\n\nexport function analyzePermissions(schemas: CollectionSchema[]): PermissionAnalysis {\n const roleSet = new Set<string>()\n for (const schema of schemas) {\n for (const role of Object.keys(schema.permissions)) roleSet.add(role)\n }\n roleSet.delete('*')\n const roles = Array.from(roleSet)\n\n const collections: CollectionPermissionSummary[] = schemas.map((schema) => {\n const permissions: CollectionPermissionSummary['permissions'] = {}\n for (const role of roles) {\n let source: PermissionSource\n let perms: RolePermissions\n if (schema.permissions[role]) {\n source = 'explicit'\n perms = schema.permissions[role]\n } else if (schema.permissions['*']) {\n source = 'wildcard'\n perms = schema.permissions['*']\n } else {\n source = 'default-deny'\n perms = { read: false, create: false, update: false, delete: false }\n }\n permissions[role] = {\n read: { level: perms.read, source },\n create: { level: perms.create, source },\n update: { level: perms.update, source },\n delete: { level: perms.delete, source },\n writableFields: perms.writableFields,\n }\n }\n return {\n collection: schema.name,\n ownerField: schema.ownerField,\n collaboratorsField: schema.collaboratorsField,\n teamField: schema.teamField,\n columns: schema.columns,\n permissions,\n }\n })\n\n return { roles, collections }\n}\n","/**\n * AI Chat Schemas\n *\n * Pre-built collection schemas for DO-backed AI chat history.\n * The worker is the only writer; the client reads via `useQuery`.\n */\n\nimport type { CollectionSchema } from './registry'\n\n// member.create is false on both collections: writes flow exclusively through\n// the worker's /api/ai/* routes, which use X-App-Action to bypass RBAC.\n// Allowing direct WS creates would let a user PUT fake `role: 'assistant'`\n// rows into their own chats and have the next turn's loadMessages feed them\n// to the LLM as if they were real assistant outputs.\nexport const AI_CHATS_SCHEMA: CollectionSchema = {\n name: 'ai-chats',\n columns: [\n { name: 'userId', storage: 'text', interpretation: 'plain', userBound: true, immutable: true, required: true },\n { name: 'title', storage: 'text', interpretation: 'plain' },\n { name: 'model', storage: 'text', interpretation: 'plain' },\n { name: 'compactedSummary', storage: 'text', interpretation: 'plain' },\n { name: 'compactedThroughId', storage: 'text', interpretation: 'plain' },\n ],\n ownerField: 'userId',\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: 'own', create: false, update: 'own', delete: 'own' },\n viewer: { read: 'own', create: false, update: false, delete: false },\n },\n}\n\nexport const AI_MESSAGES_SCHEMA: CollectionSchema = {\n name: 'ai-messages',\n columns: [\n { name: 'chatId', storage: 'text', interpretation: 'plain', immutable: true, required: true },\n { name: 'userId', storage: 'text', interpretation: 'plain', userBound: true, immutable: true, required: true },\n { name: 'role', storage: 'text', interpretation: 'plain', required: true },\n { name: 'content', storage: 'text', interpretation: 'plain' },\n { name: 'parts', storage: 'text', interpretation: { kind: 'json' } },\n ],\n ownerField: 'userId',\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: 'own', create: false, update: 'own', delete: 'own' },\n viewer: { read: 'own', create: false, update: false, delete: false },\n },\n}\n","/**\n * Messaging Schemas\n *\n * Pre-built collection schemas for messaging functionality.\n * Any app can import these to add channels, messages, reactions, etc.\n *\n * @example\n * ```typescript\n * import { CHANNELS_SCHEMA, MESSAGES_SCHEMA, REACTIONS_SCHEMA } from 'deepspace/worker'\n * export const schemas = [usersSchema, CHANNELS_SCHEMA, MESSAGES_SCHEMA, REACTIONS_SCHEMA]\n * ```\n */\n\nimport type { CollectionSchema } from './registry'\n\nexport const CHANNELS_SCHEMA: CollectionSchema = {\n name: 'channels',\n columns: [\n { name: 'name', storage: 'text', interpretation: 'plain' },\n { name: 'description', storage: 'text', interpretation: 'plain' },\n {\n name: 'type',\n storage: 'text',\n interpretation: { kind: 'select', options: ['public', 'private', 'dm'] },\n },\n {\n name: 'createdBy',\n storage: 'text',\n interpretation: 'plain',\n userBound: true,\n immutable: true,\n },\n { name: 'archived', storage: 'number', interpretation: { kind: 'boolean' } },\n ],\n ownerField: 'createdBy',\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: true, create: true, update: 'own', delete: false },\n viewer: { read: true, create: false, update: false, delete: false },\n },\n}\n\nexport const MESSAGES_SCHEMA: CollectionSchema = {\n name: 'messages',\n columns: [\n { name: 'channelId', storage: 'text', interpretation: 'plain' },\n { name: 'content', storage: 'text', interpretation: 'plain' },\n {\n name: 'authorId',\n storage: 'text',\n interpretation: 'plain',\n userBound: true,\n immutable: true,\n },\n { name: 'parentMessageId', storage: 'text', interpretation: 'plain' },\n { name: 'edited', storage: 'number', interpretation: { kind: 'boolean' } },\n { name: 'editedAt', storage: 'text', interpretation: { kind: 'datetime' } },\n // Soft-delete flag. Slack-style messaging keeps the row + parent IDs\n // intact (so threads remain coherent) and renders a tombstone instead.\n // Hard-delete via remove() still works if an app wants it.\n { name: 'deleted', storage: 'number', interpretation: { kind: 'boolean' } },\n ],\n ownerField: 'authorId',\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: true, create: true, update: 'own', delete: 'own' },\n viewer: { read: true, create: false, update: false, delete: false },\n },\n}\n\nexport const REACTIONS_SCHEMA: CollectionSchema = {\n name: 'reactions',\n columns: [\n { name: 'messageId', storage: 'text', interpretation: 'plain' },\n { name: 'channelId', storage: 'text', interpretation: 'plain' },\n { name: 'emoji', storage: 'text', interpretation: 'plain' },\n { name: 'userId', storage: 'text', interpretation: 'plain', userBound: true, immutable: true },\n ],\n ownerField: 'userId',\n uniqueOn: ['messageId', 'emoji', 'userId'],\n permissions: {\n admin: { read: true, create: true, update: false, delete: true },\n member: { read: true, create: true, update: false, delete: 'own' },\n viewer: { read: true, create: false, update: false, delete: false },\n },\n}\n\nexport const CHANNEL_MEMBERS_SCHEMA: CollectionSchema = {\n name: 'channel-members',\n columns: [\n { name: 'channelId', storage: 'text', interpretation: 'plain' },\n { name: 'userId', storage: 'text', interpretation: 'plain', userBound: true, immutable: true },\n { name: 'joinedAt', storage: 'text', interpretation: { kind: 'datetime' } },\n ],\n ownerField: 'userId',\n uniqueOn: ['channelId', 'userId'],\n permissions: {\n admin: { read: true, create: true, update: false, delete: true },\n member: { read: true, create: true, update: false, delete: 'own' },\n viewer: { read: true, create: false, update: false, delete: false },\n },\n}\n\nexport const CHANNEL_INVITATIONS_SCHEMA: CollectionSchema = {\n name: 'channel-invitations',\n columns: [\n {\n name: 'channelId',\n storage: 'text',\n interpretation: 'plain',\n required: true,\n immutable: true,\n },\n {\n name: 'invitedUserId',\n storage: 'text',\n interpretation: 'plain',\n required: true,\n immutable: true,\n },\n {\n name: 'invitedBy',\n storage: 'text',\n interpretation: 'plain',\n userBound: true,\n immutable: true,\n },\n {\n name: 'status',\n storage: 'text',\n interpretation: { kind: 'select', options: ['pending', 'accepted', 'declined'] },\n required: true,\n },\n ],\n uniqueOn: ['channelId', 'invitedUserId'],\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: true, create: true, update: true, delete: false },\n viewer: { read: true, create: false, update: false, delete: false },\n },\n}\n\nexport const READ_RECEIPTS_SCHEMA: CollectionSchema = {\n name: 'read-receipts',\n columns: [\n { name: 'channelId', storage: 'text', interpretation: 'plain' },\n { name: 'userId', storage: 'text', interpretation: 'plain', userBound: true, immutable: true },\n { name: 'lastReadAt', storage: 'text', interpretation: { kind: 'datetime' } },\n ],\n ownerField: 'userId',\n uniqueOn: ['channelId', 'userId'],\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: true, create: true, update: 'own', delete: 'own' },\n viewer: { read: false, create: false, update: false, delete: false },\n },\n}\n","/**\n * Shared conversation schemas for RecordRoom-based conversations.\n *\n * These define the collections inside a per-conversation RecordRoom DO.\n * Used by apps that have messaging/conversation features (slack-clone,\n * helpdesk, mail, reddit-clone, etc.).\n *\n * Each conversation gets its own RecordRoom DO keyed by `conv:{id}`.\n */\n\nimport type { CollectionSchema } from './registry'\n\n// Re-export data interfaces from types (single source of truth)\nexport type {\n ConvMessageData,\n ConvReactionData,\n ConvMemberData,\n ConvReadCursorData,\n ConvVoteData,\n} from '../../shared/types'\n\n// ============================================================================\n// Schemas\n// ============================================================================\n\nexport const CONVERSATION_SCHEMAS: CollectionSchema[] = [\n {\n name: 'conv_messages',\n columns: [\n { name: 'Content', storage: 'text', interpretation: 'plain' },\n { name: 'AuthorId', storage: 'text', interpretation: 'plain' },\n { name: 'ParentId', storage: 'text', interpretation: 'plain' },\n { name: 'Edited', storage: 'number', interpretation: 'boolean' },\n { name: 'MessageType', storage: 'text', interpretation: 'plain' },\n { name: 'Metadata', storage: 'text', interpretation: 'json' },\n ],\n permissions: {\n viewer: { read: true, create: false, update: false, delete: false },\n member: { read: true, create: true, update: 'own', delete: 'own' },\n admin: { read: true, create: true, update: true, delete: true },\n },\n ownerField: 'AuthorId',\n },\n {\n name: 'conv_reactions',\n columns: [\n { name: 'MessageId', storage: 'text', interpretation: 'plain' },\n { name: 'Emoji', storage: 'text', interpretation: 'plain' },\n { name: 'UserId', storage: 'text', interpretation: 'plain' },\n ],\n uniqueOn: ['MessageId', 'Emoji', 'UserId'],\n permissions: {\n viewer: { read: true, create: false, update: false, delete: false },\n member: { read: true, create: true, update: false, delete: 'own' },\n admin: { read: true, create: true, update: false, delete: true },\n },\n ownerField: 'UserId',\n },\n {\n name: 'conv_members',\n columns: [\n { name: 'UserId', storage: 'text', interpretation: 'plain' },\n { name: 'UserName', storage: 'text', interpretation: 'plain' },\n { name: 'Role', storage: 'text', interpretation: 'plain' },\n ],\n uniqueOn: ['UserId'],\n permissions: {\n viewer: { read: true, create: false, update: false, delete: false },\n member: { read: true, create: true, update: 'own', delete: false },\n admin: { read: true, create: true, update: true, delete: true },\n },\n ownerField: 'UserId',\n },\n {\n name: 'conv_read_cursors',\n columns: [\n { name: 'UserId', storage: 'text', interpretation: 'plain' },\n { name: 'LastReadAt', storage: 'text', interpretation: 'plain' },\n ],\n uniqueOn: ['UserId'],\n permissions: {\n viewer: { read: true, create: false, update: false, delete: false },\n member: { read: true, create: true, update: 'own', delete: false },\n admin: { read: true, create: true, update: true, delete: true },\n },\n ownerField: 'UserId',\n },\n]\n\n/**\n * Voting schemas for Reddit-style apps.\n * Add these alongside CONVERSATION_SCHEMAS for apps that need voting.\n */\nexport const VOTING_SCHEMAS: CollectionSchema[] = [\n {\n name: 'conv_votes',\n columns: [\n { name: 'TargetId', storage: 'text', interpretation: 'plain' },\n { name: 'UserId', storage: 'text', interpretation: 'plain' },\n { name: 'Direction', storage: 'number', interpretation: 'plain' },\n ],\n uniqueOn: ['TargetId', 'UserId'],\n permissions: {\n viewer: { read: true, create: false, update: false, delete: false },\n member: { read: true, create: true, update: 'own', delete: 'own' },\n admin: { read: true, create: true, update: true, delete: true },\n },\n ownerField: 'UserId',\n },\n]\n","/**\n * Directory DO Schemas\n *\n * Purpose-built collections for the `dir:{appName}` global DO type.\n * This is the cross-app-visible directory layer — any app can subscribe\n * to another app's directory in real-time via SHARED_CONNECTIONS.\n *\n * Five collections covering all standard communication/social patterns:\n * - conversations: channels, DMs, email threads, support chats\n * - conversation_state: per-user metadata (read cursor, stars, labels, folders)\n * - communities: groups, forums, boards, projects\n * - memberships: user membership in communities\n * - posts: feed items, tweets, Q&A questions, announcements\n *\n * Domain-specific data (tickets, CRM, procurement) stays in app DOs.\n * Message content stays in conv:{id} DOs (CONVERSATION_SCHEMAS).\n */\n\nimport type { CollectionSchema } from './registry'\n\n// Re-export data interfaces from types (single source of truth)\nexport type {\n DirectoryConversationData,\n ConversationStateData,\n DirectoryCommunityData,\n DirectoryMembershipData,\n DirectoryPostData,\n} from '../../shared/types'\n\n// ============================================================================\n// Schemas\n// ============================================================================\n\nconst conversationsSchema: CollectionSchema = {\n name: 'conversations',\n columns: [\n { name: 'Name', storage: 'text', interpretation: 'plain' },\n { name: 'Description', storage: 'text', interpretation: 'plain' },\n { name: 'Type', storage: 'text', interpretation: { kind: 'select', options: ['public', 'private', 'dm', 'group', 'email', 'outbound-email', 'support', 'announcement'] } },\n { name: 'Visibility', storage: 'text', interpretation: { kind: 'select', options: ['public', 'private', 'restricted'] } },\n { name: 'CreatedBy', storage: 'text', interpretation: 'plain' },\n { name: 'ParticipantHash', storage: 'text', interpretation: 'plain' },\n { name: 'ParticipantIds', storage: 'text', interpretation: 'json' },\n { name: 'Status', storage: 'text', interpretation: { kind: 'select', options: ['active', 'archived', 'resolved', 'closed'] } },\n { name: 'AssigneeId', storage: 'text', interpretation: 'plain' },\n { name: 'LinkedRef', storage: 'text', interpretation: 'json' },\n { name: 'LastMessageAt', storage: 'text', interpretation: { kind: 'datetime' } },\n { name: 'LastMessagePreview', storage: 'text', interpretation: 'plain' },\n { name: 'LastMessageAuthor', storage: 'text', interpretation: 'plain' },\n { name: 'MessageCount', storage: 'number', interpretation: 'plain' },\n ],\n collaboratorsField: 'ParticipantIds',\n visibilityField: 'Visibility',\n permissions: {\n viewer: { read: 'shared', create: false, update: false, delete: false },\n member: { read: 'shared', create: true, update: true, delete: 'own' },\n admin: { read: true, create: true, update: true, delete: true },\n },\n ownerField: 'CreatedBy',\n}\n\nconst conversationStateSchema: CollectionSchema = {\n name: 'conversation_state',\n columns: [\n { name: 'ConversationId', storage: 'text', interpretation: 'plain' },\n { name: 'UserId', storage: 'text', interpretation: 'plain' },\n { name: 'LastReadAt', storage: 'text', interpretation: { kind: 'datetime' } },\n { name: 'LastReadMessageCount', storage: 'number', interpretation: 'plain' },\n { name: 'Starred', storage: 'number', interpretation: 'boolean' },\n { name: 'Archived', storage: 'number', interpretation: 'boolean' },\n { name: 'Trashed', storage: 'number', interpretation: 'boolean' },\n { name: 'Labels', storage: 'text', interpretation: 'json' },\n { name: 'Folder', storage: 'text', interpretation: 'plain' },\n ],\n uniqueOn: ['ConversationId', 'UserId'],\n ownerField: 'UserId',\n permissions: {\n viewer: { read: false, create: false, update: false, delete: false },\n member: { read: 'own', create: true, update: 'own', delete: false },\n admin: { read: true, create: true, update: true, delete: true },\n },\n}\n\nconst communitiesSchema: CollectionSchema = {\n name: 'communities',\n columns: [\n { name: 'Name', storage: 'text', interpretation: 'plain' },\n { name: 'Description', storage: 'text', interpretation: 'plain' },\n { name: 'CreatedBy', storage: 'text', interpretation: 'plain' },\n { name: 'Type', storage: 'text', interpretation: { kind: 'select', options: ['community', 'forum', 'board', 'project', 'server'] } },\n { name: 'Visibility', storage: 'text', interpretation: { kind: 'select', options: ['public', 'private', 'restricted'] } },\n { name: 'MemberCount', storage: 'number', interpretation: 'plain' },\n { name: 'Rules', storage: 'text', interpretation: 'json' },\n { name: 'IconUrl', storage: 'text', interpretation: 'plain' },\n { name: 'CoverUrl', storage: 'text', interpretation: 'plain' },\n ],\n uniqueOn: ['Name'],\n permissions: {\n viewer: { read: true, create: false, update: false, delete: false },\n member: { read: true, create: true, update: 'own', delete: false },\n admin: { read: true, create: true, update: true, delete: true },\n },\n ownerField: 'CreatedBy',\n}\n\nconst membershipsSchema: CollectionSchema = {\n name: 'memberships',\n columns: [\n { name: 'CommunityId', storage: 'text', interpretation: 'plain' },\n { name: 'UserId', storage: 'text', interpretation: 'plain' },\n { name: 'UserName', storage: 'text', interpretation: 'plain' },\n { name: 'Role', storage: 'text', interpretation: { kind: 'select', options: ['member', 'moderator', 'admin'] } },\n { name: 'JoinedAt', storage: 'text', interpretation: { kind: 'datetime' } },\n ],\n uniqueOn: ['CommunityId', 'UserId'],\n permissions: {\n viewer: { read: true, create: false, update: false, delete: false },\n member: { read: true, create: true, update: 'own', delete: 'own' },\n admin: { read: true, create: true, update: true, delete: true },\n },\n ownerField: 'UserId',\n}\n\nconst postsSchema: CollectionSchema = {\n name: 'posts',\n columns: [\n { name: 'Title', storage: 'text', interpretation: 'plain' },\n { name: 'Content', storage: 'text', interpretation: 'plain' },\n { name: 'AuthorId', storage: 'text', interpretation: 'plain' },\n { name: 'Type', storage: 'text', interpretation: { kind: 'select', options: ['post', 'question', 'answer', 'tweet', 'announcement', 'link'] } },\n { name: 'CommunityId', storage: 'text', interpretation: 'plain' },\n { name: 'ParentId', storage: 'text', interpretation: 'plain' },\n { name: 'ConversationId', storage: 'text', interpretation: 'plain' },\n { name: 'Status', storage: 'text', interpretation: { kind: 'select', options: ['draft', 'published', 'pinned', 'archived', 'accepted'] } },\n { name: 'Tags', storage: 'text', interpretation: 'json' },\n { name: 'LinkUrl', storage: 'text', interpretation: 'plain' },\n ],\n permissions: {\n viewer: { read: true, create: false, update: false, delete: false },\n member: { read: true, create: true, update: 'own', delete: 'own' },\n admin: { read: true, create: true, update: true, delete: true },\n },\n ownerField: 'AuthorId',\n}\n\n// ============================================================================\n// Exports\n// ============================================================================\n\n/** All directory schemas for the `dir:{appName}` global DO type. */\nexport const DIRECTORY_SCHEMAS: CollectionSchema[] = [\n conversationsSchema,\n conversationStateSchema,\n communitiesSchema,\n membershipsSchema,\n postsSchema,\n]\n","/**\n * Workspace DO Schemas\n *\n * All collections for the workspace:default Durable Object.\n * This DO consolidates shared, cross-app business data:\n *\n * - teams / team_members — workspace-wide team management (replaces built-in teams)\n * - tasks / projects / tags — team-scoped task management\n * - people — shared contacts directory\n * - transactions / accounts — shared financial ledger\n *\n * Team-scoped collections use teamField RBAC: members see only\n * their team's records; admins see everything.\n */\n\nimport type { CollectionSchema } from './registry'\n\n// ============================================================================\n// Teams\n// ============================================================================\n\nexport const workspaceTeamsSchema: CollectionSchema = {\n name: 'teams',\n columns: [\n { name: 'Name', storage: 'text', interpretation: 'plain' },\n { name: 'CreatedBy', storage: 'text', interpretation: 'plain' },\n { name: 'IsOpen', storage: 'number', interpretation: { kind: 'boolean' } },\n ],\n teamField: '_rowId',\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: 'team', create: true, update: 'team', delete: 'own' },\n },\n}\n\nexport const workspaceTeamMembersSchema: CollectionSchema = {\n name: 'team_members',\n columns: [\n { name: 'TeamId', storage: 'text', interpretation: 'plain' },\n { name: 'UserId', storage: 'text', interpretation: 'plain' },\n { name: 'RoleInTeam', storage: 'text', interpretation: { kind: 'select', options: ['admin', 'member'] } },\n { name: 'JoinedAt', storage: 'text', interpretation: { kind: 'datetime' } },\n { name: 'Email', storage: 'text', interpretation: { kind: 'email' } },\n { name: 'Status', storage: 'text', interpretation: { kind: 'select', options: ['active', 'invited'] } },\n ],\n teamField: 'TeamId',\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: 'team', create: true, update: 'team', delete: 'team' },\n },\n}\n\n// ============================================================================\n// Tasks / Projects / Tags (team-scoped)\n// ============================================================================\n\nexport const workspaceTasksSchema: CollectionSchema = {\n name: 'tasks',\n columns: [\n { name: 'TeamId', storage: 'text', interpretation: 'plain' },\n { name: 'Title', storage: 'text', interpretation: 'plain' },\n { name: 'Notes', storage: 'text', interpretation: 'plain' },\n { name: 'Completed', storage: 'number', interpretation: { kind: 'boolean' } },\n { name: 'CompletedAt', storage: 'number', interpretation: 'plain' },\n { name: 'Deleted', storage: 'number', interpretation: { kind: 'boolean' } },\n { name: 'DeletedAt', storage: 'number', interpretation: 'plain' },\n { name: 'Priority', storage: 'text', interpretation: { kind: 'select', options: ['none', 'low', 'medium', 'high'] } },\n { name: 'DueDate', storage: 'text', interpretation: 'plain' },\n { name: 'ProjectId', storage: 'text', interpretation: 'plain' },\n { name: 'KanbanStatus', storage: 'text', interpretation: { kind: 'select', options: ['backlog', 'ready', 'in_progress', 'review', 'done'] } },\n { name: 'Order', storage: 'number', interpretation: 'plain' },\n { name: 'AssignedUser', storage: 'text', interpretation: { kind: 'json' } },\n { name: 'AssignedBy', storage: 'text', interpretation: { kind: 'json' } },\n { name: 'TagIds', storage: 'text', interpretation: { kind: 'json' } },\n { name: 'CreatedAt', storage: 'number', interpretation: 'plain' },\n ],\n teamField: 'TeamId',\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: 'team', create: true, update: 'team', delete: 'team' },\n viewer: { read: false, create: false, update: false, delete: false },\n },\n}\n\nexport const workspaceProjectsSchema: CollectionSchema = {\n name: 'projects',\n columns: [\n { name: 'TeamId', storage: 'text', interpretation: 'plain' },\n { name: 'Title', storage: 'text', interpretation: 'plain' },\n { name: 'Notes', storage: 'text', interpretation: 'plain' },\n { name: 'Color', storage: 'text', interpretation: 'plain' },\n { name: 'ParentId', storage: 'text', interpretation: 'plain' },\n { name: 'Order', storage: 'number', interpretation: 'plain' },\n { name: 'CreatedAt', storage: 'number', interpretation: 'plain' },\n ],\n teamField: 'TeamId',\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: 'team', create: true, update: 'team', delete: 'team' },\n viewer: { read: false, create: false, update: false, delete: false },\n },\n}\n\nexport const workspaceTagsSchema: CollectionSchema = {\n name: 'tags',\n columns: [\n { name: 'TeamId', storage: 'text', interpretation: 'plain' },\n { name: 'Name', storage: 'text', interpretation: 'plain' },\n { name: 'Color', storage: 'text', interpretation: 'plain' },\n { name: 'CreatedAt', storage: 'number', interpretation: 'plain' },\n ],\n teamField: 'TeamId',\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: 'team', create: true, update: 'team', delete: 'team' },\n viewer: { read: false, create: false, update: false, delete: false },\n },\n}\n\n// ============================================================================\n// People (shared contacts directory)\n// ============================================================================\n\nexport const workspacePeopleSchema: CollectionSchema = {\n name: 'people',\n columns: [\n { name: 'Name', storage: 'text', interpretation: 'plain' },\n { name: 'Email', storage: 'text', interpretation: { kind: 'email' } },\n { name: 'Type', storage: 'text', interpretation: { kind: 'select', options: ['employee', 'customer', 'vendor', 'contact'] } },\n { name: 'Status', storage: 'text', interpretation: { kind: 'select', options: ['active', 'inactive', 'archived'] } },\n { name: 'CompanyId', storage: 'text', interpretation: 'plain' },\n { name: 'Department', storage: 'text', interpretation: 'plain' },\n { name: 'Title', storage: 'text', interpretation: 'plain' },\n { name: 'LastContactedAt', storage: 'text', interpretation: { kind: 'datetime' } },\n { name: 'Metadata', storage: 'text', interpretation: { kind: 'json' } },\n ],\n permissions: {\n '*': { read: true, create: true, update: true, delete: false },\n admin: { read: true, create: true, update: true, delete: true },\n },\n}\n\n// ============================================================================\n// Ledger (shared financial data)\n// ============================================================================\n\nexport const workspaceTransactionsSchema: CollectionSchema = {\n name: 'transactions',\n columns: [\n { name: 'Type', storage: 'text', interpretation: { kind: 'select', options: ['revenue', 'expense', 'payment', 'transfer', 'invoice', 'refund'] } },\n { name: 'Amount', storage: 'number', interpretation: { kind: 'currency', symbol: '$', decimals: 2 } },\n { name: 'Currency', storage: 'text', interpretation: 'plain' },\n { name: 'Description', storage: 'text', interpretation: 'plain' },\n { name: 'Category', storage: 'text', interpretation: 'plain' },\n { name: 'CounterpartyRef', storage: 'text', interpretation: 'plain' },\n { name: 'OrderRef', storage: 'text', interpretation: 'plain' },\n { name: 'Account', storage: 'text', interpretation: 'plain' },\n ],\n permissions: {\n '*': { read: true, create: true, update: true, delete: false },\n admin: { read: true, create: true, update: true, delete: true },\n },\n}\n\nexport const workspaceAccountsSchema: CollectionSchema = {\n name: 'accounts',\n columns: [\n { name: 'Name', storage: 'text', interpretation: 'plain' },\n { name: 'Balance', storage: 'number', interpretation: { kind: 'currency', symbol: '$', decimals: 2 } },\n { name: 'Currency', storage: 'text', interpretation: 'plain' },\n ],\n permissions: {\n '*': { read: true, create: true, update: true, delete: false },\n admin: { read: true, create: true, update: true, delete: true },\n },\n}\n\n// ============================================================================\n// Content Sharing (universal cross-app content discovery)\n// ============================================================================\n\n/**\n * Universal sharing index. Any app can create share records for any content type.\n *\n * ContentType: 'document' | 'slide' | 'spreadsheet' | ... (extensible)\n * ShareType: 'channel' | 'team' | 'direct' | 'link' | 'org' (extensible)\n * ShareTarget: the ID of the target (channelId, teamId, userId, linkId, orgId)\n * Permission: 'view' | 'edit' — what the share grants\n *\n * Content itself lives in the owner's app DO.\n * This table is the discovery layer: \"what has been shared, with whom, and how\".\n */\nexport const workspaceContentSharesSchema: CollectionSchema = {\n name: 'content_shares',\n ownerField: 'OwnerId',\n columns: [\n { name: 'ContentType', storage: 'text', interpretation: { kind: 'select', options: ['document', 'slide', 'spreadsheet'] } },\n { name: 'ContentId', storage: 'text', interpretation: 'plain' },\n { name: 'OwnerId', storage: 'text', interpretation: 'plain' },\n { name: 'OwnerName', storage: 'text', interpretation: 'plain' },\n { name: 'Title', storage: 'text', interpretation: 'plain' },\n { name: 'ShareType', storage: 'text', interpretation: { kind: 'select', options: ['self', 'channel', 'team', 'direct', 'link', 'org'] } },\n { name: 'ShareTarget', storage: 'text', interpretation: 'plain' },\n { name: 'Permission', storage: 'text', interpretation: { kind: 'select', options: ['view', 'edit'] } },\n { name: 'SharedAt', storage: 'text', interpretation: { kind: 'datetime' } },\n { name: 'SharedBy', storage: 'text', interpretation: 'plain' },\n { name: 'SourceApp', storage: 'text', interpretation: 'plain' },\n { name: 'WordCount', storage: 'number', interpretation: 'plain' },\n { name: 'LastEditedAt', storage: 'text', interpretation: { kind: 'datetime' } },\n ],\n permissions: {\n '*': { read: true, create: true, update: true, delete: 'own' },\n admin: { read: true, create: true, update: true, delete: true },\n },\n}\n\n// ============================================================================\n// Form Responses (cross-app: deepspace-forms → sheets-editor)\n// ============================================================================\n\nexport const workspaceFormResponsesSchema: CollectionSchema = {\n name: 'form_responses',\n columns: [\n { name: 'FormId', storage: 'text', interpretation: 'plain' },\n { name: 'FormTitle', storage: 'text', interpretation: 'plain' },\n { name: 'RespondentId', storage: 'text', interpretation: 'plain' },\n { name: 'RespondentEmail', storage: 'text', interpretation: { kind: 'email' } },\n { name: 'RespondentName', storage: 'text', interpretation: 'plain' },\n { name: 'Data', storage: 'text', interpretation: { kind: 'json' } },\n { name: 'SubmittedAt', storage: 'text', interpretation: { kind: 'datetime' } },\n ],\n permissions: {\n '*': { read: true, create: true, update: false, delete: false },\n admin: { read: true, create: true, update: true, delete: true },\n },\n}\n\n// ============================================================================\n// Email Handles (cross-app user identity)\n// ============================================================================\n\n/**\n * Maps DeepSpace users to their claimed @app.space email handles.\n * Shared across all apps so any app can look up a user's email address.\n * All handles are under the @app.space domain.\n */\nexport const workspaceEmailHandlesSchema: CollectionSchema = {\n name: 'email_handles',\n columns: [\n { name: 'UserId', storage: 'text', interpretation: 'plain' },\n { name: 'Handle', storage: 'text', interpretation: 'plain' },\n { name: 'EmailAddress', storage: 'text', interpretation: { kind: 'email' } },\n { name: 'Status', storage: 'text', interpretation: { kind: 'select', options: ['active', 'disabled'] } },\n ],\n uniqueOn: ['Handle'],\n ownerField: 'UserId',\n permissions: {\n '*': { read: true, create: true, update: 'own', delete: false },\n admin: { read: true, create: true, update: true, delete: true },\n },\n}\n\n// ============================================================================\n// Export\n// ============================================================================\n\nexport const WORKSPACE_SCHEMAS: CollectionSchema[] = [\n workspaceTeamsSchema,\n workspaceTeamMembersSchema,\n workspaceTasksSchema,\n workspaceProjectsSchema,\n workspaceTagsSchema,\n workspacePeopleSchema,\n workspaceTransactionsSchema,\n workspaceAccountsSchema,\n workspaceContentSharesSchema,\n workspaceFormResponsesSchema,\n workspaceEmailHandlesSchema,\n]\n"],"mappings":";AAoYO,IAAM,gBAAoC;AAAA,EAC/C,EAAE,MAAM,SAAS,SAAS,QAAQ,gBAAgB,QAAQ;AAAA,EAC1D,EAAE,MAAM,QAAQ,SAAS,QAAQ,gBAAgB,QAAQ;AAAA,EACzD,EAAE,MAAM,YAAY,SAAS,QAAQ,gBAAgB,QAAQ;AAAA,EAC7D,EAAE,MAAM,QAAQ,SAAS,QAAQ,gBAAgB,QAAQ;AAAA,EACzD,EAAE,MAAM,aAAa,SAAS,QAAQ,gBAAgB,EAAE,MAAM,WAAW,EAAE;AAAA,EAC3E,EAAE,MAAM,cAAc,SAAS,QAAQ,gBAAgB,EAAE,MAAM,WAAW,EAAE;AAC9E;AAEO,IAAM,oBAAsC;AAAA,EACjD,MAAM;AAAA,EACN,SAAS,CAAC,GAAG,aAAa;AAAA,EAC1B,aAAa;AAAA,IACX,KAAK,EAAE,MAAM,OAAO,QAAQ,OAAO,QAAQ,OAAO,QAAQ,MAAM;AAAA,IAChE,OAAO,EAAE,MAAM,MAAM,QAAQ,OAAO,QAAQ,MAAM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AAA,IAClE,EAAE,MAAM,eAAe,SAAS,QAAQ,gBAAgB,EAAE,MAAM,WAAW,EAAE;AAAA,EAC/E;AAAA,EACA,aAAa;AAAA,IACX,KAAK,EAAE,MAAM,MAAM,QAAQ,MAAM,QAAQ,OAAO,QAAQ,MAAM;AAAA,IAC9D,OAAO,EAAE,MAAM,MAAM,QAAQ,MAAM,QAAQ,MAAM,QAAQ,KAAK;AAAA,EAChE;AACF;AAWO,IAAM,8BAAgD;AAAA,EAC3D,MAAM;AAAA,EACN,SAAS;AAAA,IACP,EAAE,MAAM,UAAU,SAAS,QAAQ,gBAAgB,QAAQ;AAAA,IAC3D,EAAE,MAAM,UAAU,SAAS,QAAQ,gBAAgB,QAAQ;AAAA,IAC3D,EAAE,MAAM,gBAAgB,SAAS,QAAQ,gBAAgB,EAAE,MAAM,QAAQ,EAAE;AAAA,IAC3E,EAAE,MAAM,UAAU,SAAS,QAAQ,gBAAgB,EAAE,MAAM,UAAU,SAAS,CAAC,UAAU,UAAU,EAAE,EAAE;AAAA,EACzG;AAAA,EACA,UAAU,CAAC,QAAQ;AAAA,EACnB,YAAY;AAAA,EACZ,aAAa;AAAA,IACX,KAAK,EAAE,MAAM,MAAM,QAAQ,MAAM,QAAQ,OAAO,QAAQ,MAAM;AAAA,IAC9D,OAAO,EAAE,MAAM,MAAM,QAAQ,MAAM,QAAQ,MAAM,QAAQ,KAAK;AAAA,EAChE;AACF;AAMO,IAAM,oBAAwC;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/server/schemas/registry.ts","../src/server/schemas/ai-chat.ts","../src/server/schemas/messaging.ts","../src/server/schemas/conversation.ts","../src/server/schemas/directory.ts","../src/server/schemas/workspace.ts"],"sourcesContent":["/**\n * Collection Schema Definitions & Validation\n *\n * All collections use typed SQL columns. No document-mode / fields-based storage.\n */\n\nimport type {\n CollectionSchema,\n ColumnDefinition,\n ColumnInterpretation,\n PermissionLevel,\n RolePermissions,\n} from '../../shared/types'\n\nexport type {\n CollectionSchema,\n ColumnDefinition,\n ColumnInterpretation,\n PermissionLevel,\n RolePermissions,\n} from '../../shared/types'\n\n// ============================================================================\n// Column Definitions\n// ============================================================================\n\nexport interface ResolvedColumn {\n id: string\n name: string\n storage: 'number' | 'text'\n interpretation: ColumnInterpretation\n expression?: string\n readonly: boolean\n userBound?: boolean\n immutable?: boolean\n required?: boolean\n default?: unknown\n timestampTrigger?: { field: string; value?: unknown }\n}\n\n// ============================================================================\n// Column Helpers\n// ============================================================================\n\nexport function collectionTableName(name: string): string {\n return `c_${name.replace(/[^a-zA-Z0-9_]/g, '_')}`\n}\n\nexport function columnId(name: string): string {\n return `col_${name.toLowerCase().replace(/[^a-z0-9]/g, '_')}`\n}\n\nexport function resolveColumn(col: ColumnDefinition): ResolvedColumn {\n const interp: ColumnInterpretation =\n typeof col.interpretation === 'string'\n ? ({ kind: col.interpretation } as ColumnInterpretation)\n : col.interpretation\n return {\n id: col.id ?? columnId(col.name),\n name: col.name,\n storage: col.storage,\n interpretation: interp,\n expression: col.expression,\n readonly: !!col.expression,\n userBound: col.userBound,\n immutable: col.immutable,\n required: col.required,\n default: col.default,\n timestampTrigger: col.timestampTrigger,\n }\n}\n\nexport function rowToData(\n row: Record<string, unknown>,\n columns: ResolvedColumn[],\n): Record<string, unknown> {\n const data: Record<string, unknown> = {}\n for (const col of columns) {\n if (row[col.id] !== undefined && row[col.id] !== null) {\n let val = row[col.id]\n if (col.interpretation.kind === 'json' && typeof val === 'string') {\n try {\n val = JSON.parse(val as string)\n } catch {\n /* keep as string */\n }\n }\n data[col.name] = val\n }\n }\n return data\n}\n\nexport function dataToColumnValues(\n data: Record<string, unknown>,\n columns: ResolvedColumn[],\n): Record<string, unknown> {\n const values: Record<string, unknown> = {}\n for (const col of columns) {\n if (col.expression || col.readonly) continue\n // Record mutations use public schema names only. Accepting physical column\n // ids here lets a second key bypass name-based RBAC/userBound checks.\n const val = data[col.name]\n if (val !== undefined) {\n values[col.id] = coerceValue(val, col.storage, col.interpretation)\n }\n }\n return values\n}\n\nexport function coerceValue(\n value: unknown,\n storage: 'number' | 'text',\n interpretation: ColumnInterpretation,\n): unknown {\n if (value === null || value === undefined || value === '') return null\n\n if (storage === 'text') {\n if (interpretation.kind === 'json') {\n if (typeof value === 'string') return value\n try {\n return JSON.stringify(value)\n } catch {\n return null\n }\n }\n return typeof value === 'string' ? value : String(value)\n }\n\n if (typeof value === 'number') return isFinite(value) ? value : null\n if (typeof value === 'boolean') return value ? 1 : 0\n if (typeof value !== 'string') return String(value)\n\n const s = value.trim()\n\n if (interpretation.kind === 'boolean') {\n const lower = s.toLowerCase()\n if (lower === 'true' || lower === '1' || lower === 'yes') return 1\n if (lower === 'false' || lower === '0' || lower === 'no') return 0\n return s\n }\n\n if (interpretation.kind === 'percent') {\n const m = s.match(/^(-?\\d+(?:\\.\\d+)?)\\s*%$/)\n if (m) return parseFloat(m[1]) / 100\n }\n\n if (interpretation.kind === 'currency') {\n const cleaned = s.replace(/[^0-9.-]/g, '')\n const n = parseFloat(cleaned)\n if (!isNaN(n)) return n\n return s\n }\n\n if (interpretation.kind === 'date' || interpretation.kind === 'datetime') {\n const d = new Date(s)\n if (!isNaN(d.getTime())) return Math.floor(d.getTime() / 1000)\n return s\n }\n\n const cleaned = s.replace(/[$€£¥,\\s]/g, '')\n const n = parseFloat(cleaned)\n if (!isNaN(n) && isFinite(n)) return n\n\n return s\n}\n\nexport function buildTableSelect(collectionName: string, columns: ResolvedColumn[]): string {\n const tbl = collectionTableName(collectionName)\n const parts: string[] = ['_row_id', '_created_by', '_created_at', '_updated_at']\n for (const col of columns) {\n if (col.expression) {\n parts.push(`(${col.expression}) AS \"${col.id}\"`)\n } else {\n parts.push(`\"${col.id}\"`)\n }\n }\n return `SELECT ${parts.join(', ')} FROM \"${tbl}\"`\n}\n\nexport interface User {\n id: string\n email: string\n name: string\n imageUrl?: string\n role: string\n createdAt: string\n lastSeenAt: string\n}\n\nexport interface StoredRecord {\n collection: string\n recordId: string\n data: Record<string, unknown>\n createdBy: string\n createdAt: string\n updatedAt: string\n}\n\n// ============================================================================\n// Permission Checking\n// ============================================================================\n\nexport interface PermissionContext {\n isTeamMember: (teamId: string, userId: string) => boolean\n}\n\nexport const noopPermissionContext: PermissionContext = {\n isTeamMember: () => false,\n}\n\nexport function getRolePermissions(schema: CollectionSchema, role: string): RolePermissions {\n if (schema.permissions[role]) return schema.permissions[role]\n if (schema.permissions['*']) return schema.permissions['*']\n return { read: false, create: false, update: false, delete: false }\n}\n\nexport function isOwner(\n schema: CollectionSchema,\n record: { data: Record<string, unknown>; createdBy: string },\n userId: string,\n): boolean {\n if (schema.ownerField) return record.data[schema.ownerField] === userId\n return record.createdBy === userId\n}\n\nfunction isCollaborator(\n schema: CollectionSchema,\n record: { data: Record<string, unknown> },\n userId: string,\n): boolean {\n if (!schema.collaboratorsField) return false\n const collab = record.data[schema.collaboratorsField]\n if (typeof collab === 'string') {\n try {\n return (JSON.parse(collab) as string[]).includes(userId)\n } catch {\n return false\n }\n }\n if (Array.isArray(collab)) return collab.includes(userId)\n return false\n}\n\nfunction passesVisibilityCheck(\n schema: CollectionSchema,\n record: { data: Record<string, unknown> },\n): boolean {\n if (!schema.visibilityField) return false\n if (typeof schema.visibilityField === 'string') {\n return record.data[schema.visibilityField] === 'public'\n }\n return record.data[schema.visibilityField.field] === schema.visibilityField.value\n}\n\nfunction checkPermissionLevel(\n level: PermissionLevel,\n schema: CollectionSchema,\n record: { data: Record<string, unknown>; createdBy: string; recordId?: string },\n userId: string,\n ctx: PermissionContext = noopPermissionContext,\n): boolean {\n if (level === true) return true\n if (level === false) return false\n if (level === 'own') return isOwner(schema, record, userId)\n if (level === 'unclaimed-or-own') {\n if (schema.ownerField) {\n const ownerVal = record.data[schema.ownerField]\n if (!ownerVal || ownerVal === '') return true\n }\n return isOwner(schema, record, userId)\n }\n if (level === 'collaborator') {\n return isOwner(schema, record, userId) || isCollaborator(schema, record, userId)\n }\n if (level === 'team' || level === 'access') {\n if (isOwner(schema, record, userId)) return true\n if (isCollaborator(schema, record, userId)) return true\n if (schema.teamField) {\n const teamId = record.data[schema.teamField]\n if (typeof teamId === 'string' && ctx.isTeamMember(teamId, userId)) return true\n }\n return false\n }\n if (level === 'published') {\n return isOwner(schema, record, userId) || passesVisibilityCheck(schema, record)\n }\n if (level === 'shared') {\n return (\n isOwner(schema, record, userId) ||\n isCollaborator(schema, record, userId) ||\n passesVisibilityCheck(schema, record)\n )\n }\n return false\n}\n\nexport function canRead(\n schema: CollectionSchema,\n role: string,\n record: { data: Record<string, unknown>; createdBy: string; recordId?: string },\n userId: string,\n ctx: PermissionContext = noopPermissionContext,\n): boolean {\n return checkPermissionLevel(getRolePermissions(schema, role).read, schema, record, userId, ctx)\n}\n\nexport function canCreate(schema: CollectionSchema, role: string): boolean {\n return getRolePermissions(schema, role).create === true\n}\n\nexport function canUpdate(\n schema: CollectionSchema,\n role: string,\n record: { data: Record<string, unknown>; createdBy: string; recordId?: string },\n userId: string,\n ctx: PermissionContext = noopPermissionContext,\n): boolean {\n return checkPermissionLevel(getRolePermissions(schema, role).update, schema, record, userId, ctx)\n}\n\nexport function canDelete(\n schema: CollectionSchema,\n role: string,\n record: { data: Record<string, unknown>; createdBy: string; recordId?: string },\n userId: string,\n ctx: PermissionContext = noopPermissionContext,\n): boolean {\n return checkPermissionLevel(getRolePermissions(schema, role).delete, schema, record, userId, ctx)\n}\n\n/** Check if a caller-supplied field write violates writableFields restrictions. */\nexport function checkFieldPermissions(\n schema: CollectionSchema,\n role: string,\n newData: Record<string, unknown>,\n existingData?: Record<string, unknown>,\n): string | null {\n const perms = getRolePermissions(schema, role)\n if (!perms.writableFields) return null // no restrictions\n\n const allowedFields = new Set(perms.writableFields)\n for (const key of Object.keys(newData)) {\n if (existingData && newData[key] === existingData[key]) continue\n if (!allowedFields.has(key)) {\n return `Role '${role}' cannot modify field '${key}'`\n }\n }\n return null\n}\n\n/**\n * `unclaimed-or-own` lets a client claim an empty owner field, but never lets\n * them choose another user's id. Check the post-write record so the invariant\n * covers both creation and updates while still allowing an owner to unclaim.\n */\nexport function checkUnclaimedOwnerTransition(\n schema: CollectionSchema,\n role: string,\n nextData: Record<string, unknown>,\n userId: string,\n): string | null {\n const permissions = getRolePermissions(schema, role)\n if (permissions.update !== 'unclaimed-or-own' || !schema.ownerField) return null\n\n const nextOwner = nextData[schema.ownerField]\n if (nextOwner === undefined || nextOwner === null || nextOwner === '' || nextOwner === userId) {\n return null\n }\n\n return `Role '${role}' can set '${schema.ownerField}' only to their own user id or leave it unclaimed`\n}\n\n// ============================================================================\n// System-Managed Columns (users collection)\n// ============================================================================\n\n/** Names of columns managed by the system (registerUser), not client mutations. */\nexport const SYSTEM_MANAGED_COLUMNS = new Set([\n 'email',\n 'name',\n 'imageUrl',\n 'role',\n 'createdAt',\n 'lastSeenAt',\n])\n\n/** Standard user columns. Apps spread these into their users schema. */\nexport const USERS_COLUMNS: ColumnDefinition[] = [\n { name: 'email', storage: 'text', interpretation: 'plain' },\n { name: 'name', storage: 'text', interpretation: 'plain' },\n { name: 'imageUrl', storage: 'text', interpretation: 'plain' },\n { name: 'role', storage: 'text', interpretation: 'plain' },\n { name: 'createdAt', storage: 'text', interpretation: { kind: 'datetime' } },\n { name: 'lastSeenAt', storage: 'text', interpretation: { kind: 'datetime' } },\n]\n\nexport const BASE_USERS_SCHEMA: CollectionSchema = {\n name: 'users',\n columns: [...USERS_COLUMNS],\n permissions: {\n '*': { read: 'own', create: false, update: false, delete: false },\n admin: { read: true, create: false, update: true, delete: true },\n },\n}\n\n// ============================================================================\n// Schema Registry\n// ============================================================================\n\n/**\n * Lint a CollectionSchema for declarations that look like they should\n * enforce something but don't, due to interactions between top-level\n * fields (visibilityField, ownerField) and per-role permission levels.\n *\n * The SDK has historically silently accepted schemas that imply more\n * enforcement than they actually deliver — e.g., `visibilityField` set\n * but every role's `read: true` means \"anyone can read everything\"\n * regardless of `visibility`. Warn loudly at registration so app\n * authors notice before shipping a privacy bug.\n *\n * Returns an array of warning messages. Empty = clean.\n */\nexport function lintSchema(schema: CollectionSchema): string[] {\n const warnings: string[] = []\n const VISIBILITY_AWARE: ReadonlyArray<PermissionLevel> = ['published', 'shared']\n\n // Roles that grant unconditional read despite visibilityField being declared.\n if (schema.visibilityField) {\n const offendingRoles = Object.entries(schema.permissions)\n .filter(([, perms]) => perms.read === true)\n .map(([role]) => role)\n if (offendingRoles.length > 0) {\n const usesAware = Object.values(schema.permissions).some(\n (p) => typeof p.read === 'string' && VISIBILITY_AWARE.includes(p.read as PermissionLevel),\n )\n if (!usesAware) {\n warnings.push(\n `[${schema.name}] visibilityField is declared but no role uses read: 'published' or 'shared'. ` +\n `Roles with read: true (${offendingRoles.join(', ')}) will see every row regardless of visibility. ` +\n `Change those to read: 'published' (owner OR public) or 'shared' (owner OR collaborator OR public) ` +\n `to actually enforce the filter, or remove visibilityField if you don't intend to gate reads by it.`,\n )\n }\n }\n }\n\n // An ordinary client role that can create rows must not be able to claim\n // someone else's ownership. Server-written collections legitimately carry\n // a recipient/subject id instead: their non-privileged roles all have\n // create:false, while owner/admin writes are already fully trusted.\n if (schema.ownerField) {\n const col = schema.columns.find((c) => c.name === schema.ownerField)\n const spoofableRoles = Object.entries(schema.permissions)\n .filter(\n ([role, permissions]) =>\n role !== 'owner' &&\n role !== 'admin' &&\n permissions.create === true &&\n permissions.update !== 'unclaimed-or-own',\n )\n .map(([role]) => role)\n if (col && !col.userBound && spoofableRoles.length > 0) {\n warnings.push(\n `[${schema.name}] ownerField is '${schema.ownerField}' but that column is not marked userBound: true. ` +\n `Client role(s) ${spoofableRoles.join(', ')} can create a row with someone else's id in this field, bypassing 'own' permission checks. ` +\n `Add userBound: true (and ideally immutable: true) to the column.`,\n )\n }\n }\n\n // userBound columns that aren't text storage — userBound sets the\n // field to the caller's userId (a string), so non-text storage is a\n // schema mistake that will surface as a coercion error at write time.\n for (const col of schema.columns) {\n if (col.userBound && col.storage !== 'text') {\n warnings.push(\n `[${schema.name}] column '${col.name}' is userBound but storage is '${col.storage}'. ` +\n `userBound stamps the user id (a string); use storage: 'text'.`,\n )\n }\n }\n\n return warnings\n}\n\nexport class SchemaRegistry {\n private trusted: Map<string, CollectionSchema> = new Map()\n\n constructor(schemas: CollectionSchema[] = []) {\n for (const schema of schemas) {\n this.registerTrusted(schema)\n }\n }\n\n registerTrusted(schema: CollectionSchema): void {\n for (const w of lintSchema(schema)) {\n console.warn(`[schema-lint] ${w}`)\n }\n this.trusted.set(schema.name, schema)\n }\n\n get(name: string): CollectionSchema | undefined {\n return this.trusted.get(name)\n }\n\n has(name: string): boolean {\n return this.trusted.has(name)\n }\n\n all(): CollectionSchema[] {\n return Array.from(this.trusted.values())\n }\n\n names(): string[] {\n return Array.from(this.trusted.keys())\n }\n}\n\n// ============================================================================\n// Permission Analysis\n// ============================================================================\n\nexport type PermissionSource = 'explicit' | 'wildcard' | 'default-deny'\n\nexport interface ResolvedPermission {\n level: PermissionLevel | boolean\n source: PermissionSource\n}\n\nexport interface CollectionPermissionSummary {\n collection: string\n ownerField?: string\n collaboratorsField?: string\n teamField?: string\n columns: ColumnDefinition[]\n permissions: Record<\n string,\n {\n read: ResolvedPermission\n create: ResolvedPermission\n update: ResolvedPermission\n delete: ResolvedPermission\n writableFields?: string[]\n }\n >\n}\n\nexport interface PermissionAnalysis {\n roles: string[]\n collections: CollectionPermissionSummary[]\n}\n\nexport function analyzePermissions(schemas: CollectionSchema[]): PermissionAnalysis {\n const roleSet = new Set<string>()\n for (const schema of schemas) {\n for (const role of Object.keys(schema.permissions)) roleSet.add(role)\n }\n roleSet.delete('*')\n const roles = Array.from(roleSet)\n\n const collections: CollectionPermissionSummary[] = schemas.map((schema) => {\n const permissions: CollectionPermissionSummary['permissions'] = {}\n for (const role of roles) {\n let source: PermissionSource\n let perms: RolePermissions\n if (schema.permissions[role]) {\n source = 'explicit'\n perms = schema.permissions[role]\n } else if (schema.permissions['*']) {\n source = 'wildcard'\n perms = schema.permissions['*']\n } else {\n source = 'default-deny'\n perms = { read: false, create: false, update: false, delete: false }\n }\n permissions[role] = {\n read: { level: perms.read, source },\n create: { level: perms.create, source },\n update: { level: perms.update, source },\n delete: { level: perms.delete, source },\n writableFields: perms.writableFields,\n }\n }\n return {\n collection: schema.name,\n ownerField: schema.ownerField,\n collaboratorsField: schema.collaboratorsField,\n teamField: schema.teamField,\n columns: schema.columns,\n permissions,\n }\n })\n\n return { roles, collections }\n}\n","/**\n * AI Chat Schemas\n *\n * Pre-built collection schemas for DO-backed AI chat history.\n * The worker is the only writer; the client reads via `useQuery`.\n */\n\nimport type { CollectionSchema } from './registry'\n\n// member.create is false on both collections: writes flow exclusively through\n// the worker's /api/ai/* routes, which use X-App-Action to bypass RBAC.\n// Allowing direct WS creates would let a user PUT fake `role: 'assistant'`\n// rows into their own chats and have the next turn's loadMessages feed them\n// to the LLM as if they were real assistant outputs.\nexport const AI_CHATS_SCHEMA: CollectionSchema = {\n name: 'ai-chats',\n columns: [\n { name: 'userId', storage: 'text', interpretation: 'plain', userBound: true, immutable: true, required: true },\n { name: 'title', storage: 'text', interpretation: 'plain' },\n { name: 'model', storage: 'text', interpretation: 'plain' },\n { name: 'compactedSummary', storage: 'text', interpretation: 'plain' },\n { name: 'compactedThroughId', storage: 'text', interpretation: 'plain' },\n ],\n ownerField: 'userId',\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: 'own', create: false, update: 'own', delete: 'own' },\n viewer: { read: 'own', create: false, update: false, delete: false },\n },\n}\n\nexport const AI_MESSAGES_SCHEMA: CollectionSchema = {\n name: 'ai-messages',\n columns: [\n { name: 'chatId', storage: 'text', interpretation: 'plain', immutable: true, required: true },\n { name: 'userId', storage: 'text', interpretation: 'plain', userBound: true, immutable: true, required: true },\n { name: 'role', storage: 'text', interpretation: 'plain', required: true },\n { name: 'content', storage: 'text', interpretation: 'plain' },\n { name: 'parts', storage: 'text', interpretation: { kind: 'json' } },\n ],\n ownerField: 'userId',\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: 'own', create: false, update: 'own', delete: 'own' },\n viewer: { read: 'own', create: false, update: false, delete: false },\n },\n}\n","/**\n * Messaging Schemas\n *\n * Pre-built collection schemas for messaging functionality.\n * Any app can import these to add channels, messages, reactions, etc.\n *\n * @example\n * ```typescript\n * import { CHANNELS_SCHEMA, MESSAGES_SCHEMA, REACTIONS_SCHEMA } from 'deepspace/worker'\n * export const schemas = [usersSchema, CHANNELS_SCHEMA, MESSAGES_SCHEMA, REACTIONS_SCHEMA]\n * ```\n */\n\nimport type { CollectionSchema } from './registry'\n\nexport const CHANNELS_SCHEMA: CollectionSchema = {\n name: 'channels',\n columns: [\n { name: 'name', storage: 'text', interpretation: 'plain' },\n { name: 'description', storage: 'text', interpretation: 'plain' },\n {\n name: 'type',\n storage: 'text',\n interpretation: { kind: 'select', options: ['public', 'private', 'dm'] },\n },\n {\n name: 'createdBy',\n storage: 'text',\n interpretation: 'plain',\n userBound: true,\n immutable: true,\n },\n { name: 'archived', storage: 'number', interpretation: { kind: 'boolean' } },\n ],\n ownerField: 'createdBy',\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: true, create: true, update: 'own', delete: false },\n viewer: { read: true, create: false, update: false, delete: false },\n },\n}\n\nexport const MESSAGES_SCHEMA: CollectionSchema = {\n name: 'messages',\n columns: [\n { name: 'channelId', storage: 'text', interpretation: 'plain' },\n { name: 'content', storage: 'text', interpretation: 'plain' },\n {\n name: 'authorId',\n storage: 'text',\n interpretation: 'plain',\n userBound: true,\n immutable: true,\n },\n { name: 'parentMessageId', storage: 'text', interpretation: 'plain' },\n { name: 'edited', storage: 'number', interpretation: { kind: 'boolean' } },\n { name: 'editedAt', storage: 'text', interpretation: { kind: 'datetime' } },\n // Soft-delete flag. Slack-style messaging keeps the row + parent IDs\n // intact (so threads remain coherent) and renders a tombstone instead.\n // Hard-delete via remove() still works if an app wants it.\n { name: 'deleted', storage: 'number', interpretation: { kind: 'boolean' } },\n ],\n ownerField: 'authorId',\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: true, create: true, update: 'own', delete: 'own' },\n viewer: { read: true, create: false, update: false, delete: false },\n },\n}\n\nexport const REACTIONS_SCHEMA: CollectionSchema = {\n name: 'reactions',\n columns: [\n { name: 'messageId', storage: 'text', interpretation: 'plain' },\n { name: 'channelId', storage: 'text', interpretation: 'plain' },\n { name: 'emoji', storage: 'text', interpretation: 'plain' },\n { name: 'userId', storage: 'text', interpretation: 'plain', userBound: true, immutable: true },\n ],\n ownerField: 'userId',\n uniqueOn: ['messageId', 'emoji', 'userId'],\n permissions: {\n admin: { read: true, create: true, update: false, delete: true },\n member: { read: true, create: true, update: false, delete: 'own' },\n viewer: { read: true, create: false, update: false, delete: false },\n },\n}\n\nexport const CHANNEL_MEMBERS_SCHEMA: CollectionSchema = {\n name: 'channel-members',\n columns: [\n { name: 'channelId', storage: 'text', interpretation: 'plain' },\n { name: 'userId', storage: 'text', interpretation: 'plain', userBound: true, immutable: true },\n { name: 'joinedAt', storage: 'text', interpretation: { kind: 'datetime' } },\n ],\n ownerField: 'userId',\n uniqueOn: ['channelId', 'userId'],\n permissions: {\n admin: { read: true, create: true, update: false, delete: true },\n member: { read: true, create: true, update: false, delete: 'own' },\n viewer: { read: true, create: false, update: false, delete: false },\n },\n}\n\nexport const CHANNEL_INVITATIONS_SCHEMA: CollectionSchema = {\n name: 'channel-invitations',\n columns: [\n {\n name: 'channelId',\n storage: 'text',\n interpretation: 'plain',\n required: true,\n immutable: true,\n },\n {\n name: 'invitedUserId',\n storage: 'text',\n interpretation: 'plain',\n required: true,\n immutable: true,\n },\n {\n name: 'invitedBy',\n storage: 'text',\n interpretation: 'plain',\n userBound: true,\n immutable: true,\n },\n {\n name: 'status',\n storage: 'text',\n interpretation: { kind: 'select', options: ['pending', 'accepted', 'declined'] },\n required: true,\n },\n ],\n uniqueOn: ['channelId', 'invitedUserId'],\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: true, create: true, update: true, delete: false },\n viewer: { read: true, create: false, update: false, delete: false },\n },\n}\n\nexport const READ_RECEIPTS_SCHEMA: CollectionSchema = {\n name: 'read-receipts',\n columns: [\n { name: 'channelId', storage: 'text', interpretation: 'plain' },\n { name: 'userId', storage: 'text', interpretation: 'plain', userBound: true, immutable: true },\n { name: 'lastReadAt', storage: 'text', interpretation: { kind: 'datetime' } },\n ],\n ownerField: 'userId',\n uniqueOn: ['channelId', 'userId'],\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: true, create: true, update: 'own', delete: 'own' },\n viewer: { read: false, create: false, update: false, delete: false },\n },\n}\n","/**\n * Shared conversation schemas for RecordRoom-based conversations.\n *\n * These define the collections inside a per-conversation RecordRoom DO.\n * Used by apps that have messaging/conversation features (slack-clone,\n * helpdesk, mail, reddit-clone, etc.).\n *\n * Each conversation gets its own RecordRoom DO keyed by `conv:{id}`.\n */\n\nimport type { CollectionSchema } from './registry'\n\n// Re-export data interfaces from types (single source of truth)\nexport type {\n ConvMessageData,\n ConvReactionData,\n ConvMemberData,\n ConvReadCursorData,\n ConvVoteData,\n} from '../../shared/types'\n\n// ============================================================================\n// Schemas\n// ============================================================================\n\nexport const CONVERSATION_SCHEMAS: CollectionSchema[] = [\n {\n name: 'conv_messages',\n columns: [\n { name: 'Content', storage: 'text', interpretation: 'plain' },\n { name: 'AuthorId', storage: 'text', interpretation: 'plain' },\n { name: 'ParentId', storage: 'text', interpretation: 'plain' },\n { name: 'Edited', storage: 'number', interpretation: 'boolean' },\n { name: 'MessageType', storage: 'text', interpretation: 'plain' },\n { name: 'Metadata', storage: 'text', interpretation: 'json' },\n ],\n permissions: {\n viewer: { read: true, create: false, update: false, delete: false },\n member: { read: true, create: true, update: 'own', delete: 'own' },\n admin: { read: true, create: true, update: true, delete: true },\n },\n ownerField: 'AuthorId',\n },\n {\n name: 'conv_reactions',\n columns: [\n { name: 'MessageId', storage: 'text', interpretation: 'plain' },\n { name: 'Emoji', storage: 'text', interpretation: 'plain' },\n { name: 'UserId', storage: 'text', interpretation: 'plain' },\n ],\n uniqueOn: ['MessageId', 'Emoji', 'UserId'],\n permissions: {\n viewer: { read: true, create: false, update: false, delete: false },\n member: { read: true, create: true, update: false, delete: 'own' },\n admin: { read: true, create: true, update: false, delete: true },\n },\n ownerField: 'UserId',\n },\n {\n name: 'conv_members',\n columns: [\n { name: 'UserId', storage: 'text', interpretation: 'plain' },\n { name: 'UserName', storage: 'text', interpretation: 'plain' },\n { name: 'Role', storage: 'text', interpretation: 'plain' },\n ],\n uniqueOn: ['UserId'],\n permissions: {\n viewer: { read: true, create: false, update: false, delete: false },\n member: { read: true, create: true, update: 'own', delete: false },\n admin: { read: true, create: true, update: true, delete: true },\n },\n ownerField: 'UserId',\n },\n {\n name: 'conv_read_cursors',\n columns: [\n { name: 'UserId', storage: 'text', interpretation: 'plain' },\n { name: 'LastReadAt', storage: 'text', interpretation: 'plain' },\n ],\n uniqueOn: ['UserId'],\n permissions: {\n viewer: { read: true, create: false, update: false, delete: false },\n member: { read: true, create: true, update: 'own', delete: false },\n admin: { read: true, create: true, update: true, delete: true },\n },\n ownerField: 'UserId',\n },\n]\n\n/**\n * Voting schemas for Reddit-style apps.\n * Add these alongside CONVERSATION_SCHEMAS for apps that need voting.\n */\nexport const VOTING_SCHEMAS: CollectionSchema[] = [\n {\n name: 'conv_votes',\n columns: [\n { name: 'TargetId', storage: 'text', interpretation: 'plain' },\n { name: 'UserId', storage: 'text', interpretation: 'plain' },\n { name: 'Direction', storage: 'number', interpretation: 'plain' },\n ],\n uniqueOn: ['TargetId', 'UserId'],\n permissions: {\n viewer: { read: true, create: false, update: false, delete: false },\n member: { read: true, create: true, update: 'own', delete: 'own' },\n admin: { read: true, create: true, update: true, delete: true },\n },\n ownerField: 'UserId',\n },\n]\n","/**\n * Directory DO Schemas\n *\n * Purpose-built collections for the `dir:{appName}` global DO type.\n * This is the cross-app-visible directory layer — any app can subscribe\n * to another app's directory in real-time via SHARED_CONNECTIONS.\n *\n * Five collections covering all standard communication/social patterns:\n * - conversations: channels, DMs, email threads, support chats\n * - conversation_state: per-user metadata (read cursor, stars, labels, folders)\n * - communities: groups, forums, boards, projects\n * - memberships: user membership in communities\n * - posts: feed items, tweets, Q&A questions, announcements\n *\n * Domain-specific data (tickets, CRM, procurement) stays in app DOs.\n * Message content stays in conv:{id} DOs (CONVERSATION_SCHEMAS).\n */\n\nimport type { CollectionSchema } from './registry'\n\n// Re-export data interfaces from types (single source of truth)\nexport type {\n DirectoryConversationData,\n ConversationStateData,\n DirectoryCommunityData,\n DirectoryMembershipData,\n DirectoryPostData,\n} from '../../shared/types'\n\n// ============================================================================\n// Schemas\n// ============================================================================\n\nconst conversationsSchema: CollectionSchema = {\n name: 'conversations',\n columns: [\n { name: 'Name', storage: 'text', interpretation: 'plain' },\n { name: 'Description', storage: 'text', interpretation: 'plain' },\n { name: 'Type', storage: 'text', interpretation: { kind: 'select', options: ['public', 'private', 'dm', 'group', 'email', 'outbound-email', 'support', 'announcement'] } },\n { name: 'Visibility', storage: 'text', interpretation: { kind: 'select', options: ['public', 'private', 'restricted'] } },\n { name: 'CreatedBy', storage: 'text', interpretation: 'plain' },\n { name: 'ParticipantHash', storage: 'text', interpretation: 'plain' },\n { name: 'ParticipantIds', storage: 'text', interpretation: 'json' },\n { name: 'Status', storage: 'text', interpretation: { kind: 'select', options: ['active', 'archived', 'resolved', 'closed'] } },\n { name: 'AssigneeId', storage: 'text', interpretation: 'plain' },\n { name: 'LinkedRef', storage: 'text', interpretation: 'json' },\n { name: 'LastMessageAt', storage: 'text', interpretation: { kind: 'datetime' } },\n { name: 'LastMessagePreview', storage: 'text', interpretation: 'plain' },\n { name: 'LastMessageAuthor', storage: 'text', interpretation: 'plain' },\n { name: 'MessageCount', storage: 'number', interpretation: 'plain' },\n ],\n collaboratorsField: 'ParticipantIds',\n visibilityField: 'Visibility',\n permissions: {\n viewer: { read: 'shared', create: false, update: false, delete: false },\n member: { read: 'shared', create: true, update: true, delete: 'own' },\n admin: { read: true, create: true, update: true, delete: true },\n },\n ownerField: 'CreatedBy',\n}\n\nconst conversationStateSchema: CollectionSchema = {\n name: 'conversation_state',\n columns: [\n { name: 'ConversationId', storage: 'text', interpretation: 'plain' },\n { name: 'UserId', storage: 'text', interpretation: 'plain' },\n { name: 'LastReadAt', storage: 'text', interpretation: { kind: 'datetime' } },\n { name: 'LastReadMessageCount', storage: 'number', interpretation: 'plain' },\n { name: 'Starred', storage: 'number', interpretation: 'boolean' },\n { name: 'Archived', storage: 'number', interpretation: 'boolean' },\n { name: 'Trashed', storage: 'number', interpretation: 'boolean' },\n { name: 'Labels', storage: 'text', interpretation: 'json' },\n { name: 'Folder', storage: 'text', interpretation: 'plain' },\n ],\n uniqueOn: ['ConversationId', 'UserId'],\n ownerField: 'UserId',\n permissions: {\n viewer: { read: false, create: false, update: false, delete: false },\n member: { read: 'own', create: true, update: 'own', delete: false },\n admin: { read: true, create: true, update: true, delete: true },\n },\n}\n\nconst communitiesSchema: CollectionSchema = {\n name: 'communities',\n columns: [\n { name: 'Name', storage: 'text', interpretation: 'plain' },\n { name: 'Description', storage: 'text', interpretation: 'plain' },\n { name: 'CreatedBy', storage: 'text', interpretation: 'plain' },\n { name: 'Type', storage: 'text', interpretation: { kind: 'select', options: ['community', 'forum', 'board', 'project', 'server'] } },\n { name: 'Visibility', storage: 'text', interpretation: { kind: 'select', options: ['public', 'private', 'restricted'] } },\n { name: 'MemberCount', storage: 'number', interpretation: 'plain' },\n { name: 'Rules', storage: 'text', interpretation: 'json' },\n { name: 'IconUrl', storage: 'text', interpretation: 'plain' },\n { name: 'CoverUrl', storage: 'text', interpretation: 'plain' },\n ],\n uniqueOn: ['Name'],\n permissions: {\n viewer: { read: true, create: false, update: false, delete: false },\n member: { read: true, create: true, update: 'own', delete: false },\n admin: { read: true, create: true, update: true, delete: true },\n },\n ownerField: 'CreatedBy',\n}\n\nconst membershipsSchema: CollectionSchema = {\n name: 'memberships',\n columns: [\n { name: 'CommunityId', storage: 'text', interpretation: 'plain' },\n { name: 'UserId', storage: 'text', interpretation: 'plain' },\n { name: 'UserName', storage: 'text', interpretation: 'plain' },\n { name: 'Role', storage: 'text', interpretation: { kind: 'select', options: ['member', 'moderator', 'admin'] } },\n { name: 'JoinedAt', storage: 'text', interpretation: { kind: 'datetime' } },\n ],\n uniqueOn: ['CommunityId', 'UserId'],\n permissions: {\n viewer: { read: true, create: false, update: false, delete: false },\n member: { read: true, create: true, update: 'own', delete: 'own' },\n admin: { read: true, create: true, update: true, delete: true },\n },\n ownerField: 'UserId',\n}\n\nconst postsSchema: CollectionSchema = {\n name: 'posts',\n columns: [\n { name: 'Title', storage: 'text', interpretation: 'plain' },\n { name: 'Content', storage: 'text', interpretation: 'plain' },\n { name: 'AuthorId', storage: 'text', interpretation: 'plain' },\n { name: 'Type', storage: 'text', interpretation: { kind: 'select', options: ['post', 'question', 'answer', 'tweet', 'announcement', 'link'] } },\n { name: 'CommunityId', storage: 'text', interpretation: 'plain' },\n { name: 'ParentId', storage: 'text', interpretation: 'plain' },\n { name: 'ConversationId', storage: 'text', interpretation: 'plain' },\n { name: 'Status', storage: 'text', interpretation: { kind: 'select', options: ['draft', 'published', 'pinned', 'archived', 'accepted'] } },\n { name: 'Tags', storage: 'text', interpretation: 'json' },\n { name: 'LinkUrl', storage: 'text', interpretation: 'plain' },\n ],\n permissions: {\n viewer: { read: true, create: false, update: false, delete: false },\n member: { read: true, create: true, update: 'own', delete: 'own' },\n admin: { read: true, create: true, update: true, delete: true },\n },\n ownerField: 'AuthorId',\n}\n\n// ============================================================================\n// Exports\n// ============================================================================\n\n/** All directory schemas for the `dir:{appName}` global DO type. */\nexport const DIRECTORY_SCHEMAS: CollectionSchema[] = [\n conversationsSchema,\n conversationStateSchema,\n communitiesSchema,\n membershipsSchema,\n postsSchema,\n]\n","/**\n * Workspace DO Schemas\n *\n * All collections for the workspace:default Durable Object.\n * This DO consolidates shared, cross-app business data:\n *\n * - teams / team_members — workspace-wide team management (replaces built-in teams)\n * - tasks / projects / tags — team-scoped task management\n * - people — shared contacts directory\n * - transactions / accounts — shared financial ledger\n *\n * Team-scoped collections use teamField RBAC: members see only\n * their team's records; admins see everything.\n */\n\nimport type { CollectionSchema } from './registry'\n\n// ============================================================================\n// Teams\n// ============================================================================\n\nexport const workspaceTeamsSchema: CollectionSchema = {\n name: 'teams',\n columns: [\n { name: 'Name', storage: 'text', interpretation: 'plain' },\n { name: 'CreatedBy', storage: 'text', interpretation: 'plain' },\n { name: 'IsOpen', storage: 'number', interpretation: { kind: 'boolean' } },\n ],\n teamField: '_rowId',\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: 'team', create: true, update: 'team', delete: 'own' },\n },\n}\n\nexport const workspaceTeamMembersSchema: CollectionSchema = {\n name: 'team_members',\n columns: [\n { name: 'TeamId', storage: 'text', interpretation: 'plain' },\n { name: 'UserId', storage: 'text', interpretation: 'plain' },\n { name: 'RoleInTeam', storage: 'text', interpretation: { kind: 'select', options: ['admin', 'member'] } },\n { name: 'JoinedAt', storage: 'text', interpretation: { kind: 'datetime' } },\n { name: 'Email', storage: 'text', interpretation: { kind: 'email' } },\n { name: 'Status', storage: 'text', interpretation: { kind: 'select', options: ['active', 'invited'] } },\n ],\n teamField: 'TeamId',\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: 'team', create: true, update: 'team', delete: 'team' },\n },\n}\n\n// ============================================================================\n// Tasks / Projects / Tags (team-scoped)\n// ============================================================================\n\nexport const workspaceTasksSchema: CollectionSchema = {\n name: 'tasks',\n columns: [\n { name: 'TeamId', storage: 'text', interpretation: 'plain' },\n { name: 'Title', storage: 'text', interpretation: 'plain' },\n { name: 'Notes', storage: 'text', interpretation: 'plain' },\n { name: 'Completed', storage: 'number', interpretation: { kind: 'boolean' } },\n { name: 'CompletedAt', storage: 'number', interpretation: 'plain' },\n { name: 'Deleted', storage: 'number', interpretation: { kind: 'boolean' } },\n { name: 'DeletedAt', storage: 'number', interpretation: 'plain' },\n { name: 'Priority', storage: 'text', interpretation: { kind: 'select', options: ['none', 'low', 'medium', 'high'] } },\n { name: 'DueDate', storage: 'text', interpretation: 'plain' },\n { name: 'ProjectId', storage: 'text', interpretation: 'plain' },\n { name: 'KanbanStatus', storage: 'text', interpretation: { kind: 'select', options: ['backlog', 'ready', 'in_progress', 'review', 'done'] } },\n { name: 'Order', storage: 'number', interpretation: 'plain' },\n { name: 'AssignedUser', storage: 'text', interpretation: { kind: 'json' } },\n { name: 'AssignedBy', storage: 'text', interpretation: { kind: 'json' } },\n { name: 'TagIds', storage: 'text', interpretation: { kind: 'json' } },\n { name: 'CreatedAt', storage: 'number', interpretation: 'plain' },\n ],\n teamField: 'TeamId',\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: 'team', create: true, update: 'team', delete: 'team' },\n viewer: { read: false, create: false, update: false, delete: false },\n },\n}\n\nexport const workspaceProjectsSchema: CollectionSchema = {\n name: 'projects',\n columns: [\n { name: 'TeamId', storage: 'text', interpretation: 'plain' },\n { name: 'Title', storage: 'text', interpretation: 'plain' },\n { name: 'Notes', storage: 'text', interpretation: 'plain' },\n { name: 'Color', storage: 'text', interpretation: 'plain' },\n { name: 'ParentId', storage: 'text', interpretation: 'plain' },\n { name: 'Order', storage: 'number', interpretation: 'plain' },\n { name: 'CreatedAt', storage: 'number', interpretation: 'plain' },\n ],\n teamField: 'TeamId',\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: 'team', create: true, update: 'team', delete: 'team' },\n viewer: { read: false, create: false, update: false, delete: false },\n },\n}\n\nexport const workspaceTagsSchema: CollectionSchema = {\n name: 'tags',\n columns: [\n { name: 'TeamId', storage: 'text', interpretation: 'plain' },\n { name: 'Name', storage: 'text', interpretation: 'plain' },\n { name: 'Color', storage: 'text', interpretation: 'plain' },\n { name: 'CreatedAt', storage: 'number', interpretation: 'plain' },\n ],\n teamField: 'TeamId',\n permissions: {\n admin: { read: true, create: true, update: true, delete: true },\n member: { read: 'team', create: true, update: 'team', delete: 'team' },\n viewer: { read: false, create: false, update: false, delete: false },\n },\n}\n\n// ============================================================================\n// People (shared contacts directory)\n// ============================================================================\n\nexport const workspacePeopleSchema: CollectionSchema = {\n name: 'people',\n columns: [\n { name: 'Name', storage: 'text', interpretation: 'plain' },\n { name: 'Email', storage: 'text', interpretation: { kind: 'email' } },\n { name: 'Type', storage: 'text', interpretation: { kind: 'select', options: ['employee', 'customer', 'vendor', 'contact'] } },\n { name: 'Status', storage: 'text', interpretation: { kind: 'select', options: ['active', 'inactive', 'archived'] } },\n { name: 'CompanyId', storage: 'text', interpretation: 'plain' },\n { name: 'Department', storage: 'text', interpretation: 'plain' },\n { name: 'Title', storage: 'text', interpretation: 'plain' },\n { name: 'LastContactedAt', storage: 'text', interpretation: { kind: 'datetime' } },\n { name: 'Metadata', storage: 'text', interpretation: { kind: 'json' } },\n ],\n permissions: {\n '*': { read: true, create: true, update: true, delete: false },\n admin: { read: true, create: true, update: true, delete: true },\n },\n}\n\n// ============================================================================\n// Ledger (shared financial data)\n// ============================================================================\n\nexport const workspaceTransactionsSchema: CollectionSchema = {\n name: 'transactions',\n columns: [\n { name: 'Type', storage: 'text', interpretation: { kind: 'select', options: ['revenue', 'expense', 'payment', 'transfer', 'invoice', 'refund'] } },\n { name: 'Amount', storage: 'number', interpretation: { kind: 'currency', symbol: '$', decimals: 2 } },\n { name: 'Currency', storage: 'text', interpretation: 'plain' },\n { name: 'Description', storage: 'text', interpretation: 'plain' },\n { name: 'Category', storage: 'text', interpretation: 'plain' },\n { name: 'CounterpartyRef', storage: 'text', interpretation: 'plain' },\n { name: 'OrderRef', storage: 'text', interpretation: 'plain' },\n { name: 'Account', storage: 'text', interpretation: 'plain' },\n ],\n permissions: {\n '*': { read: true, create: true, update: true, delete: false },\n admin: { read: true, create: true, update: true, delete: true },\n },\n}\n\nexport const workspaceAccountsSchema: CollectionSchema = {\n name: 'accounts',\n columns: [\n { name: 'Name', storage: 'text', interpretation: 'plain' },\n { name: 'Balance', storage: 'number', interpretation: { kind: 'currency', symbol: '$', decimals: 2 } },\n { name: 'Currency', storage: 'text', interpretation: 'plain' },\n ],\n permissions: {\n '*': { read: true, create: true, update: true, delete: false },\n admin: { read: true, create: true, update: true, delete: true },\n },\n}\n\n// ============================================================================\n// Content Sharing (universal cross-app content discovery)\n// ============================================================================\n\n/**\n * Universal sharing index. Any app can create share records for any content type.\n *\n * ContentType: 'document' | 'slide' | 'spreadsheet' | ... (extensible)\n * ShareType: 'channel' | 'team' | 'direct' | 'link' | 'org' (extensible)\n * ShareTarget: the ID of the target (channelId, teamId, userId, linkId, orgId)\n * Permission: 'view' | 'edit' — what the share grants\n *\n * Content itself lives in the owner's app DO.\n * This table is the discovery layer: \"what has been shared, with whom, and how\".\n */\nexport const workspaceContentSharesSchema: CollectionSchema = {\n name: 'content_shares',\n ownerField: 'OwnerId',\n columns: [\n { name: 'ContentType', storage: 'text', interpretation: { kind: 'select', options: ['document', 'slide', 'spreadsheet'] } },\n { name: 'ContentId', storage: 'text', interpretation: 'plain' },\n { name: 'OwnerId', storage: 'text', interpretation: 'plain' },\n { name: 'OwnerName', storage: 'text', interpretation: 'plain' },\n { name: 'Title', storage: 'text', interpretation: 'plain' },\n { name: 'ShareType', storage: 'text', interpretation: { kind: 'select', options: ['self', 'channel', 'team', 'direct', 'link', 'org'] } },\n { name: 'ShareTarget', storage: 'text', interpretation: 'plain' },\n { name: 'Permission', storage: 'text', interpretation: { kind: 'select', options: ['view', 'edit'] } },\n { name: 'SharedAt', storage: 'text', interpretation: { kind: 'datetime' } },\n { name: 'SharedBy', storage: 'text', interpretation: 'plain' },\n { name: 'SourceApp', storage: 'text', interpretation: 'plain' },\n { name: 'WordCount', storage: 'number', interpretation: 'plain' },\n { name: 'LastEditedAt', storage: 'text', interpretation: { kind: 'datetime' } },\n ],\n permissions: {\n '*': { read: true, create: true, update: true, delete: 'own' },\n admin: { read: true, create: true, update: true, delete: true },\n },\n}\n\n// ============================================================================\n// Form Responses (cross-app: deepspace-forms → sheets-editor)\n// ============================================================================\n\nexport const workspaceFormResponsesSchema: CollectionSchema = {\n name: 'form_responses',\n columns: [\n { name: 'FormId', storage: 'text', interpretation: 'plain' },\n { name: 'FormTitle', storage: 'text', interpretation: 'plain' },\n { name: 'RespondentId', storage: 'text', interpretation: 'plain' },\n { name: 'RespondentEmail', storage: 'text', interpretation: { kind: 'email' } },\n { name: 'RespondentName', storage: 'text', interpretation: 'plain' },\n { name: 'Data', storage: 'text', interpretation: { kind: 'json' } },\n { name: 'SubmittedAt', storage: 'text', interpretation: { kind: 'datetime' } },\n ],\n permissions: {\n '*': { read: true, create: true, update: false, delete: false },\n admin: { read: true, create: true, update: true, delete: true },\n },\n}\n\n// ============================================================================\n// Email Handles (cross-app user identity)\n// ============================================================================\n\n/**\n * Maps DeepSpace users to their claimed @app.space email handles.\n * Shared across all apps so any app can look up a user's email address.\n * All handles are under the @app.space domain.\n */\nexport const workspaceEmailHandlesSchema: CollectionSchema = {\n name: 'email_handles',\n columns: [\n { name: 'UserId', storage: 'text', interpretation: 'plain' },\n { name: 'Handle', storage: 'text', interpretation: 'plain' },\n { name: 'EmailAddress', storage: 'text', interpretation: { kind: 'email' } },\n { name: 'Status', storage: 'text', interpretation: { kind: 'select', options: ['active', 'disabled'] } },\n ],\n uniqueOn: ['Handle'],\n ownerField: 'UserId',\n permissions: {\n '*': { read: true, create: true, update: 'own', delete: false },\n admin: { read: true, create: true, update: true, delete: true },\n },\n}\n\n// ============================================================================\n// Export\n// ============================================================================\n\nexport const WORKSPACE_SCHEMAS: CollectionSchema[] = [\n workspaceTeamsSchema,\n workspaceTeamMembersSchema,\n workspaceTasksSchema,\n workspaceProjectsSchema,\n workspaceTagsSchema,\n workspacePeopleSchema,\n workspaceTransactionsSchema,\n workspaceAccountsSchema,\n workspaceContentSharesSchema,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AE;AAAA,IAC3E,EAAE,MAAM,UAAU,SAAS,QAAQ,gBAAgB,EAAE,MAAM,UAAU,SAAS,CAAC,UAAU,UAAU,EAAE,EAAE;AAAA,EACzG;AAAA,EACA,UAAU,CAAC,QAAQ;AAAA,EACnB,YAAY;AAAA,EACZ,aAAa;AAAA,IACX,KAAK,EAAE,MAAM,MAAM,QAAQ,MAAM,QAAQ,OAAO,QAAQ,MAAM;AAAA,IAC9D,OAAO,EAAE,MAAM,MAAM,QAAQ,MAAM,QAAQ,MAAM,QAAQ,KAAK;AAAA,EAChE;AACF;AAMO,IAAM,oBAAwC;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
package/dist/server.d.ts CHANGED
@@ -423,7 +423,7 @@ interface RolePermissions {
423
423
  create: boolean;
424
424
  update: PermissionLevel;
425
425
  delete: PermissionLevel;
426
- /** If set, only these columns can be updated by this role. */
426
+ /** If set, only these caller-supplied columns can be created or updated by this role. */
427
427
  writableFields?: string[];
428
428
  }
429
429
  interface CollectionSchema {
@@ -1961,7 +1961,7 @@ declare function canDelete(schema: CollectionSchema, role: string, record: {
1961
1961
  createdBy: string;
1962
1962
  recordId?: string;
1963
1963
  }, userId: string, ctx?: PermissionContext): boolean;
1964
- /** Check if a field update violates writableFields restrictions. */
1964
+ /** Check if a caller-supplied field write violates writableFields restrictions. */
1965
1965
  declare function checkFieldPermissions(schema: CollectionSchema, role: string, newData: Record<string, unknown>, existingData?: Record<string, unknown>): string | null;
1966
1966
  /**
1967
1967
  * `unclaimed-or-own` lets a client claim an empty owner field, but never lets
@@ -2401,6 +2401,8 @@ interface JobRoomConfig {
2401
2401
  retryBackoffMs?: number;
2402
2402
  /** Re-check whether a connected user may mutate the queue. Defaults to member/admin roles. */
2403
2403
  authorizeWrite?: (user: UserAttachment) => boolean | Promise<boolean>;
2404
+ /** Re-check whether a connected user may observe the queue. Defaults to authorizeWrite. */
2405
+ authorizeRead?: (user: UserAttachment) => boolean | Promise<boolean>;
2404
2406
  }
2405
2407
  interface JobAttachment extends UserAttachment {
2406
2408
  canWrite: boolean;
@@ -2412,6 +2414,8 @@ declare abstract class JobRoom<E = Record<string, unknown>, P = unknown, R = unk
2412
2414
  private readonly snapshotLimit;
2413
2415
  private readonly retryBackoffMs;
2414
2416
  private readonly authorizeWrite;
2417
+ private readonly authorizeRead;
2418
+ private broadcastQueue;
2415
2419
  /** In-flight jobs in this isolate; lets same-isolate JOB_CANCEL fire the signal. */
2416
2420
  private readonly inFlight;
2417
2421
  /** Set by `ctx.continue` inside `executeJob`; reset before every run. */
@@ -2465,6 +2469,9 @@ declare abstract class JobRoom<E = Record<string, unknown>, P = unknown, R = unk
2465
2469
  private executeJob;
2466
2470
  private makeContext;
2467
2471
  private readStatus;
2472
+ /** Reauthorize every live event so role revocation does not leave a stale reader. */
2473
+ protected broadcast(message: ServerMessage, exclude?: WebSocket): void;
2474
+ private resolveAccess;
2468
2475
  private scheduleNextAlarm;
2469
2476
  private recoverStuckRunning;
2470
2477
  private pruneExpired;
@@ -3062,6 +3069,7 @@ interface UserContext {
3062
3069
  sql: SqlStorage;
3063
3070
  state: DurableObjectState;
3064
3071
  schemaRegistry: SchemaRegistry;
3072
+ getPermissionContext(): PermissionContext;
3065
3073
  send(ws: WebSocket, message: {
3066
3074
  type: string;
3067
3075
  payload: unknown;
@@ -3090,11 +3098,8 @@ declare function getAllUsers(sql: SqlStorage, schemaRegistry?: SchemaRegistry):
3090
3098
  * ensuring admins and owners always have full access.
3091
3099
  */
3092
3100
  declare function registerUser(sql: SqlStorage, userId: string, name: string, email: string, imageUrl: string | undefined, isAdmin: boolean, defaultRole?: string, schemaRegistry?: SchemaRegistry): Promise<User>;
3093
- /**
3094
- * Handle user list request.
3095
- * Returns all users with full data (system + app fields).
3096
- */
3097
- declare function handleUserList(ctx: UserContext, ws: WebSocket, _attachment: ConnectionAttachment): void;
3101
+ /** Handle user list requests without bypassing the users collection's privacy boundary. */
3102
+ declare function handleUserList(ctx: UserContext, ws: WebSocket, attachment: ConnectionAttachment): void;
3098
3103
  /**
3099
3104
  * Handle user profile update.
3100
3105
  *
package/dist/server.js CHANGED
@@ -2952,10 +2952,6 @@ function putRecord(ctx, collection, recordId, data, userId, userRole, skipUserRb
2952
2952
  error: `UPDATE DENIED: role=${userRole}, collection=${collection}`
2953
2953
  };
2954
2954
  }
2955
- const fieldError = checkFieldPermissions(schema, userRole, finalData, existing.data);
2956
- if (fieldError) {
2957
- return { success: false, error: `FIELD ERROR: ${fieldError}` };
2958
- }
2959
2955
  } else {
2960
2956
  if (!canCreate(schema, userRole)) {
2961
2957
  return {
@@ -2964,6 +2960,15 @@ function putRecord(ctx, collection, recordId, data, userId, userRole, skipUserRb
2964
2960
  };
2965
2961
  }
2966
2962
  }
2963
+ const fieldError = checkFieldPermissions(
2964
+ schema,
2965
+ userRole,
2966
+ data,
2967
+ isUpdate ? existing.data : void 0
2968
+ );
2969
+ if (fieldError) {
2970
+ return { success: false, error: `FIELD ERROR: ${fieldError}` };
2971
+ }
2967
2972
  const ownerError = checkUnclaimedOwnerTransition(schema, userRole, finalData, userId);
2968
2973
  if (ownerError) {
2969
2974
  return { success: false, error: `FIELD ERROR: ${ownerError}` };
@@ -3621,6 +3626,7 @@ function getAllUserRecords(sql, schemaRegistry) {
3621
3626
  const r = row;
3622
3627
  return {
3623
3628
  recordId: r._row_id,
3629
+ createdBy: r._created_by,
3624
3630
  data: columns.length > 0 ? rowToUserRecord(r, columns) : {
3625
3631
  email: r.col_email || "",
3626
3632
  name: r.col_name || "",
@@ -3682,12 +3688,28 @@ async function registerUser(sql, userId, name, email, imageUrl, isAdmin, default
3682
3688
  );
3683
3689
  return { id: userId, email, name, imageUrl, role, createdAt: now, lastSeenAt: now };
3684
3690
  }
3685
- function handleUserList(ctx, ws, _attachment) {
3686
- const userRecords = getAllUserRecords(ctx.sql, ctx.schemaRegistry);
3687
- const users = userRecords.map((r) => ({
3688
- id: r.recordId,
3689
- ...r.data
3690
- }));
3691
+ function handleUserList(ctx, ws, attachment) {
3692
+ const schema = ctx.schemaRegistry.get("users");
3693
+ const permissionContext = ctx.getPermissionContext();
3694
+ const visibleRecords = attachment.userId.startsWith("anon-") || !schema ? [] : getAllUserRecords(ctx.sql, ctx.schemaRegistry).filter(
3695
+ (record) => canRead(
3696
+ schema,
3697
+ attachment.role,
3698
+ record,
3699
+ attachment.userId,
3700
+ permissionContext
3701
+ )
3702
+ );
3703
+ const users = visibleRecords.map((record) => {
3704
+ if (attachment.role === "admin") return { id: record.recordId, ...record.data };
3705
+ const { name, imageUrl, role } = record.data;
3706
+ return {
3707
+ id: record.recordId,
3708
+ name,
3709
+ ...imageUrl ? { imageUrl } : {},
3710
+ role
3711
+ };
3712
+ });
3691
3713
  ctx.send(ws, { type: MSG.USER_LIST, payload: { users } });
3692
3714
  }
3693
3715
  function handleUserUpdate(ctx, _ws, attachment, payload) {
@@ -3716,11 +3738,6 @@ async function handleSetRole(ctx, ws, attachment, payload) {
3716
3738
  now,
3717
3739
  payload.userId
3718
3740
  );
3719
- const userRecords = getAllUserRecords(ctx.sql, ctx.schemaRegistry);
3720
- const users = userRecords.map((r) => ({
3721
- id: r.recordId,
3722
- ...r.data
3723
- }));
3724
3741
  for (const otherWs of ctx.state.getWebSockets()) {
3725
3742
  const otherAttachment = otherWs.deserializeAttachment();
3726
3743
  if (!otherAttachment) continue;
@@ -3732,7 +3749,7 @@ async function handleSetRole(ctx, ws, attachment, payload) {
3732
3749
  continue;
3733
3750
  }
3734
3751
  if (otherAttachment.role === "admin") {
3735
- ctx.send(otherWs, { type: MSG.USER_LIST, payload: { users } });
3752
+ handleUserList(ctx, otherWs, otherAttachment);
3736
3753
  }
3737
3754
  }
3738
3755
  }
@@ -4603,6 +4620,7 @@ var RecordRoom = class extends BaseRoom {
4603
4620
  sql: this.sql,
4604
4621
  state: this.state,
4605
4622
  schemaRegistry: this.schemaRegistry,
4623
+ getPermissionContext: () => this.getPermissionContext(),
4606
4624
  send: (ws, msg) => this.send(ws, msg)
4607
4625
  };
4608
4626
  }
@@ -5705,6 +5723,8 @@ var JobRoom = class extends BaseRoom {
5705
5723
  snapshotLimit;
5706
5724
  retryBackoffMs;
5707
5725
  authorizeWrite;
5726
+ authorizeRead;
5727
+ broadcastQueue = Promise.resolve();
5708
5728
  /** In-flight jobs in this isolate; lets same-isolate JOB_CANCEL fire the signal. */
5709
5729
  inFlight = /* @__PURE__ */ new Map();
5710
5730
  /** Set by `ctx.continue` inside `executeJob`; reset before every run. */
@@ -5716,6 +5736,7 @@ var JobRoom = class extends BaseRoom {
5716
5736
  this.snapshotLimit = Math.max(1, config.snapshotLimit ?? DEFAULT_SNAPSHOT_LIMIT);
5717
5737
  this.retryBackoffMs = Math.max(0, config.retryBackoffMs ?? 1e3);
5718
5738
  this.authorizeWrite = config.authorizeWrite ?? ((user) => user.role === ROLES.MEMBER || user.role === ROLES.ADMIN);
5739
+ this.authorizeRead = config.authorizeRead ?? this.authorizeWrite;
5719
5740
  }
5720
5741
  ensureInitialized() {
5721
5742
  if (this.initialized) return;
@@ -5758,9 +5779,9 @@ var JobRoom = class extends BaseRoom {
5758
5779
  }
5759
5780
  async onConnect(ws, user) {
5760
5781
  this.ensureInitialized();
5761
- const canWrite = await this.authorizeWrite(user);
5782
+ const { canRead: canRead2, canWrite } = await this.resolveAccess(user);
5762
5783
  this.sendTo(ws, { type: MSG.AUTH, payload: { canWrite } });
5763
- this.sendTo(ws, serverBuild.jobSnapshot(this.getRecentJobs(this.snapshotLimit)));
5784
+ this.sendTo(ws, serverBuild.jobSnapshot(canRead2 ? this.getRecentJobs(this.snapshotLimit) : []));
5764
5785
  return { ...user, canWrite };
5765
5786
  }
5766
5787
  async onMessage(ws, user, message) {
@@ -5768,7 +5789,7 @@ var JobRoom = class extends BaseRoom {
5768
5789
  const { type, payload } = message;
5769
5790
  if (type === MSG.JOB_ENQUEUE || type === MSG.JOB_CANCEL || type === MSG.JOB_RETRY) {
5770
5791
  const attachment = user;
5771
- const canWrite = await this.authorizeWrite(user);
5792
+ const { canWrite } = await this.resolveAccess(user);
5772
5793
  if (attachment.canWrite !== canWrite) {
5773
5794
  attachment.canWrite = canWrite;
5774
5795
  ws.serializeAttachment(attachment);
@@ -6123,6 +6144,29 @@ var JobRoom = class extends BaseRoom {
6123
6144
  const row = this.sql.exec(`SELECT status FROM jobs WHERE id = ?`, jobId).toArray()[0];
6124
6145
  return row?.status ?? null;
6125
6146
  }
6147
+ /** Reauthorize every live event so role revocation does not leave a stale reader. */
6148
+ broadcast(message, exclude) {
6149
+ this.broadcastQueue = this.broadcastQueue.then(async () => {
6150
+ await Promise.all(
6151
+ this.getWebSockets().map(async (ws) => {
6152
+ if (ws === exclude) return;
6153
+ try {
6154
+ const user = this.getAttachment(ws);
6155
+ if (!user) return;
6156
+ if (await this.authorizeRead(user)) this.sendTo(ws, message);
6157
+ } catch {
6158
+ }
6159
+ })
6160
+ );
6161
+ });
6162
+ this.state.waitUntil(this.broadcastQueue);
6163
+ }
6164
+ async resolveAccess(user) {
6165
+ const canRead2 = await this.authorizeRead(user);
6166
+ if (!canRead2) return { canRead: false, canWrite: false };
6167
+ const canWrite = this.authorizeRead === this.authorizeWrite || await this.authorizeWrite(user);
6168
+ return { canRead: true, canWrite };
6169
+ }
6126
6170
  // ==========================================================================
6127
6171
  // Scheduling / recovery / pruning
6128
6172
  // ==========================================================================