UNPKG

@mastra/core

Version:
1 lines 28.7 kB
{"version":3,"file":"filesystem-Buug7_j8.cjs","names":["VersionedStorageDomain","normalizePerPage","deepEqual","calculatePagination","FilesystemVersionedHelpers"],"sources":["../src/storage/domains/workspaces/base.ts","../src/storage/domains/workspaces/inmemory.ts","../src/storage/domains/workspaces/filesystem.ts"],"sourcesContent":["import type {\n StorageWorkspaceType,\n StorageWorkspaceSnapshotType,\n StorageResolvedWorkspaceType,\n StorageCreateWorkspaceInput,\n StorageUpdateWorkspaceInput,\n StorageListWorkspacesInput,\n StorageListWorkspacesOutput,\n StorageListWorkspacesResolvedOutput,\n} from '../../types';\nimport { VersionedStorageDomain } from '../versioned';\nimport type { VersionBase, CreateVersionInputBase, ListVersionsInputBase, ListVersionsOutputBase } from '../versioned';\n\n// ============================================================================\n// Workspace Version Types\n// ============================================================================\n\n/**\n * Represents a stored version of a workspace's configuration.\n * Config fields are top-level on the version row (no nested snapshot object).\n */\nexport interface WorkspaceVersion extends StorageWorkspaceSnapshotType, VersionBase {\n /** ID of the workspace this version belongs to */\n workspaceId: string;\n}\n\n/**\n * Input for creating a new workspace version.\n * Config fields are top-level (no nested snapshot object).\n */\nexport interface CreateWorkspaceVersionInput extends StorageWorkspaceSnapshotType, CreateVersionInputBase {\n /** ID of the workspace this version belongs to */\n workspaceId: string;\n}\n\n/**\n * Sort direction for version listings.\n */\nexport type WorkspaceVersionSortDirection = 'ASC' | 'DESC';\n\n/**\n * Fields that can be used for ordering version listings.\n */\nexport type WorkspaceVersionOrderBy = 'versionNumber' | 'createdAt';\n\n/**\n * Input for listing workspace versions with pagination and sorting.\n */\nexport interface ListWorkspaceVersionsInput extends ListVersionsInputBase {\n /** ID of the workspace to list versions for */\n workspaceId: string;\n}\n\n/**\n * Output for listing workspace versions with pagination info.\n */\nexport interface ListWorkspaceVersionsOutput extends ListVersionsOutputBase<WorkspaceVersion> {}\n\n// ============================================================================\n// WorkspacesStorage Base Class\n// ============================================================================\n\nexport abstract class WorkspacesStorage extends VersionedStorageDomain<\n StorageWorkspaceType,\n StorageWorkspaceSnapshotType,\n StorageResolvedWorkspaceType,\n WorkspaceVersion,\n CreateWorkspaceVersionInput,\n ListWorkspaceVersionsInput,\n ListWorkspaceVersionsOutput,\n { workspace: StorageCreateWorkspaceInput },\n StorageUpdateWorkspaceInput,\n StorageListWorkspacesInput | undefined,\n StorageListWorkspacesOutput,\n StorageListWorkspacesResolvedOutput\n> {\n protected readonly listKey = 'workspaces';\n protected readonly versionMetadataFields = [\n 'id',\n 'workspaceId',\n 'versionNumber',\n 'changedFields',\n 'changeMessage',\n 'createdAt',\n ] satisfies (keyof WorkspaceVersion)[];\n\n constructor() {\n super({\n component: 'STORAGE',\n name: 'WORKSPACES',\n });\n }\n}\n","import { deepEqual } from '../../../utils';\nimport { normalizePerPage, calculatePagination } from '../../base';\nimport type {\n StorageWorkspaceType,\n StorageCreateWorkspaceInput,\n StorageUpdateWorkspaceInput,\n StorageListWorkspacesInput,\n StorageListWorkspacesOutput,\n ThreadOrderBy,\n ThreadSortDirection,\n} from '../../types';\nimport type { InMemoryDB } from '../inmemory-db';\nimport type {\n WorkspaceVersion,\n CreateWorkspaceVersionInput,\n ListWorkspaceVersionsInput,\n ListWorkspaceVersionsOutput,\n WorkspaceVersionOrderBy,\n WorkspaceVersionSortDirection,\n} from './base';\nimport { WorkspacesStorage } from './base';\n\nexport class InMemoryWorkspacesStorage extends WorkspacesStorage {\n private db: InMemoryDB;\n\n constructor({ db }: { db: InMemoryDB }) {\n super();\n this.db = db;\n }\n\n async dangerouslyClearAll(): Promise<void> {\n this.db.workspaces.clear();\n this.db.workspaceVersions.clear();\n }\n\n // ==========================================================================\n // Workspace CRUD Methods\n // ==========================================================================\n\n async getById(id: string): Promise<StorageWorkspaceType | null> {\n const config = this.db.workspaces.get(id);\n return config ? this.deepCopyConfig(config) : null;\n }\n\n async create(input: { workspace: StorageCreateWorkspaceInput }): Promise<StorageWorkspaceType> {\n const { workspace } = input;\n\n if (this.db.workspaces.has(workspace.id)) {\n throw new Error(`Workspace with id ${workspace.id} already exists`);\n }\n\n const now = new Date();\n const newConfig: StorageWorkspaceType = {\n id: workspace.id,\n status: 'draft',\n activeVersionId: undefined,\n authorId: workspace.authorId,\n metadata: workspace.metadata,\n createdAt: now,\n updatedAt: now,\n };\n\n this.db.workspaces.set(workspace.id, newConfig);\n\n // Extract config fields from the flat input (everything except record fields)\n const { id: _id, authorId: _authorId, metadata: _metadata, ...snapshotConfig } = workspace;\n\n // Create version 1 from the config\n const versionId = crypto.randomUUID();\n await this.createVersion({\n id: versionId,\n workspaceId: workspace.id,\n versionNumber: 1,\n ...snapshotConfig,\n changedFields: Object.keys(snapshotConfig),\n changeMessage: 'Initial version',\n });\n\n // Return the thin record\n return this.deepCopyConfig(newConfig);\n }\n\n async update(input: StorageUpdateWorkspaceInput): Promise<StorageWorkspaceType> {\n const { id, ...updates } = input;\n\n const existingConfig = this.db.workspaces.get(id);\n if (!existingConfig) {\n throw new Error(`Workspace with id ${id} not found`);\n }\n\n // Separate metadata fields from config fields\n const { authorId, activeVersionId, metadata, status, ...rawConfigFields } = updates;\n\n // Strip undefined keys so omitted PATCH fields don't overwrite persisted values\n const configFields: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rawConfigFields)) {\n if (value !== undefined) configFields[key] = value;\n }\n\n // Config field names from StorageWorkspaceSnapshotType\n const configFieldNames = [\n 'name',\n 'description',\n 'filesystem',\n 'sandbox',\n 'mounts',\n 'search',\n 'skills',\n 'tools',\n 'autoSync',\n 'operationTimeout',\n ];\n\n // Check if any config fields are present in the update\n const hasConfigUpdate = configFieldNames.some(field => field in configFields);\n\n // Update metadata fields on the record\n const updatedConfig: StorageWorkspaceType = {\n ...existingConfig,\n ...(authorId !== undefined && { authorId }),\n ...(activeVersionId !== undefined && { activeVersionId }),\n ...(status !== undefined && { status: status as StorageWorkspaceType['status'] }),\n ...(metadata !== undefined && {\n metadata: { ...existingConfig.metadata, ...metadata },\n }),\n updatedAt: new Date(),\n };\n\n // Auto-set status to 'published' when activeVersionId is set, only if status is not explicitly provided\n if (activeVersionId !== undefined && status === undefined) {\n updatedConfig.status = 'published';\n }\n\n // If config fields are being updated, create a new version\n if (hasConfigUpdate) {\n // Get the latest version to use as base\n const latestVersion = await this.getLatestVersion(id);\n if (!latestVersion) {\n throw new Error(`No versions found for workspace ${id}`);\n }\n\n // Extract config from latest version\n const {\n id: _versionId,\n workspaceId: _workspaceId,\n versionNumber: _versionNumber,\n changedFields: _changedFields,\n changeMessage: _changeMessage,\n createdAt: _createdAt,\n ...latestConfig\n } = latestVersion;\n\n // Merge updates into latest config\n const newConfig = {\n ...latestConfig,\n ...configFields,\n };\n\n // Identify which fields changed\n const changedFields = configFieldNames.filter(\n field =>\n field in configFields &&\n JSON.stringify(configFields[field as keyof typeof configFields]) !==\n JSON.stringify(latestConfig[field as keyof typeof latestConfig]),\n );\n\n // Only create a new version if something actually changed\n if (changedFields.length > 0) {\n const newVersionId = crypto.randomUUID();\n const newVersionNumber = latestVersion.versionNumber + 1;\n\n await this.createVersion({\n id: newVersionId,\n workspaceId: id,\n versionNumber: newVersionNumber,\n ...newConfig,\n changedFields,\n changeMessage: `Updated ${changedFields.join(', ')}`,\n });\n }\n }\n\n // Save the updated record\n this.db.workspaces.set(id, updatedConfig);\n return this.deepCopyConfig(updatedConfig);\n }\n\n async delete(id: string): Promise<void> {\n // Idempotent delete\n this.db.workspaces.delete(id);\n // Also delete all versions for this workspace\n await this.deleteVersionsByParentId(id);\n }\n\n async list(args?: StorageListWorkspacesInput): Promise<StorageListWorkspacesOutput> {\n const { page = 0, perPage: perPageInput, orderBy, authorId, metadata } = args || {};\n const { field, direction } = this.parseOrderBy(orderBy);\n\n // Normalize perPage for query (false → MAX_SAFE_INTEGER, 0 → 0, undefined → 100)\n const perPage = normalizePerPage(perPageInput, 100);\n\n if (page < 0) {\n throw new Error('page must be >= 0');\n }\n\n // Prevent unreasonably large page values\n const maxOffset = Number.MAX_SAFE_INTEGER / 2;\n if (page * perPage > maxOffset) {\n throw new Error('page value too large');\n }\n\n // Get all workspaces and apply filters\n let configs = Array.from(this.db.workspaces.values());\n\n // Filter by authorId if provided\n if (authorId !== undefined) {\n configs = configs.filter(config => config.authorId === authorId);\n }\n\n // Filter by metadata if provided (AND logic)\n if (metadata && Object.keys(metadata).length > 0) {\n configs = configs.filter(config => {\n if (!config.metadata) return false;\n return Object.entries(metadata).every(([key, value]) => deepEqual(config.metadata![key], value));\n });\n }\n\n // Sort filtered configs\n const sortedConfigs = this.sortConfigs(configs, field, direction);\n\n // Deep clone to avoid mutation\n const clonedConfigs = sortedConfigs.map(config => this.deepCopyConfig(config));\n\n const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);\n\n return {\n workspaces: clonedConfigs.slice(offset, offset + perPage),\n total: clonedConfigs.length,\n page,\n perPage: perPageForResponse,\n hasMore: offset + perPage < clonedConfigs.length,\n };\n }\n\n // ==========================================================================\n // Workspace Version Methods\n // ==========================================================================\n\n async createVersion(input: CreateWorkspaceVersionInput): Promise<WorkspaceVersion> {\n // Check if version with this ID already exists\n if (this.db.workspaceVersions.has(input.id)) {\n throw new Error(`Version with id ${input.id} already exists`);\n }\n\n // Check for duplicate (workspaceId, versionNumber) pair\n for (const version of this.db.workspaceVersions.values()) {\n if (version.workspaceId === input.workspaceId && version.versionNumber === input.versionNumber) {\n throw new Error(`Version number ${input.versionNumber} already exists for workspace ${input.workspaceId}`);\n }\n }\n\n const version: WorkspaceVersion = {\n ...input,\n createdAt: new Date(),\n };\n\n // Deep clone before storing\n this.db.workspaceVersions.set(input.id, this.deepCopyVersion(version));\n return this.deepCopyVersion(version);\n }\n\n async getVersion(id: string): Promise<WorkspaceVersion | null> {\n const version = this.db.workspaceVersions.get(id);\n return version ? this.deepCopyVersion(version) : null;\n }\n\n async getVersionByNumber(workspaceId: string, versionNumber: number): Promise<WorkspaceVersion | null> {\n for (const version of this.db.workspaceVersions.values()) {\n if (version.workspaceId === workspaceId && version.versionNumber === versionNumber) {\n return this.deepCopyVersion(version);\n }\n }\n return null;\n }\n\n async getLatestVersion(workspaceId: string): Promise<WorkspaceVersion | null> {\n let latest: WorkspaceVersion | null = null;\n for (const version of this.db.workspaceVersions.values()) {\n if (version.workspaceId === workspaceId) {\n if (!latest || version.versionNumber > latest.versionNumber) {\n latest = version;\n }\n }\n }\n return latest ? this.deepCopyVersion(latest) : null;\n }\n\n async listVersions(input: ListWorkspaceVersionsInput): Promise<ListWorkspaceVersionsOutput> {\n const { workspaceId, page = 0, perPage: perPageInput, orderBy } = input;\n const { field, direction } = this.parseVersionOrderBy(orderBy);\n\n // Normalize perPage (false -> MAX_SAFE_INTEGER, 0 -> 0, undefined -> 20)\n const perPage = normalizePerPage(perPageInput, 20);\n\n if (page < 0) {\n throw new Error('page must be >= 0');\n }\n\n const maxOffset = Number.MAX_SAFE_INTEGER / 2;\n if (page * perPage > maxOffset) {\n throw new Error('page value too large');\n }\n\n // Filter versions by workspaceId\n let versions = Array.from(this.db.workspaceVersions.values()).filter(v => v.workspaceId === workspaceId);\n\n // Sort versions\n versions = this.sortVersions(versions, field, direction);\n\n // Deep clone\n const clonedVersions = versions.map(v => this.deepCopyVersion(v));\n\n const total = clonedVersions.length;\n const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);\n const paginatedVersions = clonedVersions.slice(offset, offset + perPage);\n\n return {\n versions: paginatedVersions,\n total,\n page,\n perPage: perPageForResponse,\n hasMore: offset + perPage < total,\n };\n }\n\n async deleteVersion(id: string): Promise<void> {\n this.db.workspaceVersions.delete(id);\n }\n\n async deleteVersionsByParentId(entityId: string): Promise<void> {\n const idsToDelete: string[] = [];\n for (const [id, version] of this.db.workspaceVersions.entries()) {\n if (version.workspaceId === entityId) {\n idsToDelete.push(id);\n }\n }\n\n for (const id of idsToDelete) {\n this.db.workspaceVersions.delete(id);\n }\n }\n\n async countVersions(workspaceId: string): Promise<number> {\n let count = 0;\n for (const version of this.db.workspaceVersions.values()) {\n if (version.workspaceId === workspaceId) {\n count++;\n }\n }\n return count;\n }\n\n // ==========================================================================\n // Private Helper Methods\n // ==========================================================================\n\n private deepCopyConfig(config: StorageWorkspaceType): StorageWorkspaceType {\n return {\n ...config,\n metadata: config.metadata ? { ...config.metadata } : config.metadata,\n };\n }\n\n private deepCopyVersion(version: WorkspaceVersion): WorkspaceVersion {\n return structuredClone(version);\n }\n\n private sortConfigs(\n configs: StorageWorkspaceType[],\n field: ThreadOrderBy,\n direction: ThreadSortDirection,\n ): StorageWorkspaceType[] {\n return configs.sort((a, b) => {\n const aValue = a[field].getTime();\n const bValue = b[field].getTime();\n\n return direction === 'ASC' ? aValue - bValue : bValue - aValue;\n });\n }\n\n private sortVersions(\n versions: WorkspaceVersion[],\n field: WorkspaceVersionOrderBy,\n direction: WorkspaceVersionSortDirection,\n ): WorkspaceVersion[] {\n return versions.sort((a, b) => {\n let aVal: number;\n let bVal: number;\n\n if (field === 'createdAt') {\n aVal = a.createdAt.getTime();\n bVal = b.createdAt.getTime();\n } else {\n // versionNumber\n aVal = a.versionNumber;\n bVal = b.versionNumber;\n }\n\n return direction === 'ASC' ? aVal - bVal : bVal - aVal;\n });\n }\n}\n","import type { FilesystemDB } from '../../filesystem-db';\nimport { FilesystemVersionedHelpers } from '../../filesystem-versioned';\nimport type {\n StorageWorkspaceType,\n StorageCreateWorkspaceInput,\n StorageUpdateWorkspaceInput,\n StorageListWorkspacesInput,\n StorageListWorkspacesOutput,\n} from '../../types';\nimport type {\n WorkspaceVersion,\n CreateWorkspaceVersionInput,\n ListWorkspaceVersionsInput,\n ListWorkspaceVersionsOutput,\n} from './base';\nimport { WorkspacesStorage } from './base';\n\nexport class FilesystemWorkspacesStorage extends WorkspacesStorage {\n private helpers: FilesystemVersionedHelpers<StorageWorkspaceType, WorkspaceVersion>;\n\n constructor({ db }: { db: FilesystemDB }) {\n super();\n this.helpers = new FilesystemVersionedHelpers({\n db,\n entitiesFile: 'workspaces.json',\n parentIdField: 'workspaceId',\n name: 'FilesystemWorkspacesStorage',\n versionMetadataFields: ['id', 'workspaceId', 'versionNumber', 'changedFields', 'changeMessage', 'createdAt'],\n });\n }\n\n override async init(): Promise<void> {\n await this.helpers.db.init();\n }\n\n async dangerouslyClearAll(): Promise<void> {\n await this.helpers.dangerouslyClearAll();\n }\n\n async getById(id: string): Promise<StorageWorkspaceType | null> {\n return this.helpers.getById(id);\n }\n\n async create(input: { workspace: StorageCreateWorkspaceInput }): Promise<StorageWorkspaceType> {\n const { workspace } = input;\n const now = new Date();\n const entity: StorageWorkspaceType = {\n id: workspace.id,\n status: 'draft',\n activeVersionId: undefined,\n authorId: workspace.authorId,\n metadata: workspace.metadata,\n createdAt: now,\n updatedAt: now,\n };\n\n await this.helpers.createEntity(workspace.id, entity);\n\n const { id: _id, authorId: _authorId, metadata: _metadata, ...snapshotConfig } = workspace;\n const versionId = crypto.randomUUID();\n await this.createVersion({\n id: versionId,\n workspaceId: workspace.id,\n versionNumber: 1,\n ...snapshotConfig,\n changedFields: Object.keys(snapshotConfig),\n changeMessage: 'Initial version',\n } as CreateWorkspaceVersionInput);\n\n return structuredClone(entity);\n }\n\n async update(input: StorageUpdateWorkspaceInput): Promise<StorageWorkspaceType> {\n const { id, ...updates } = input;\n return this.helpers.updateEntity(id, updates);\n }\n\n async delete(id: string): Promise<void> {\n await this.helpers.deleteEntity(id);\n }\n\n async list(args?: StorageListWorkspacesInput): Promise<StorageListWorkspacesOutput> {\n const { page, perPage, orderBy, authorId, metadata } = args || {};\n const result = await this.helpers.listEntities({\n page,\n perPage,\n orderBy,\n listKey: 'workspaces',\n filters: { authorId, metadata },\n });\n return result as unknown as StorageListWorkspacesOutput;\n }\n\n async createVersion(input: CreateWorkspaceVersionInput): Promise<WorkspaceVersion> {\n return this.helpers.createVersion(input as WorkspaceVersion);\n }\n\n async getVersion(id: string): Promise<WorkspaceVersion | null> {\n return this.helpers.getVersion(id);\n }\n\n async getVersionByNumber(workspaceId: string, versionNumber: number): Promise<WorkspaceVersion | null> {\n return this.helpers.getVersionByNumber(workspaceId, versionNumber);\n }\n\n async getLatestVersion(workspaceId: string): Promise<WorkspaceVersion | null> {\n return this.helpers.getLatestVersion(workspaceId);\n }\n\n async listVersions(input: ListWorkspaceVersionsInput): Promise<ListWorkspaceVersionsOutput> {\n const result = await this.helpers.listVersions(input, 'workspaceId');\n return result as ListWorkspaceVersionsOutput;\n }\n\n async deleteVersion(id: string): Promise<void> {\n await this.helpers.deleteVersion(id);\n }\n\n async deleteVersionsByParentId(entityId: string): Promise<void> {\n await this.helpers.deleteVersionsByParentId(entityId);\n }\n\n async countVersions(workspaceId: string): Promise<number> {\n return this.helpers.countVersions(workspaceId);\n }\n}\n"],"mappings":";;;AA8DA,IAAsB,oBAAtB,cAAgDA,6BAAAA,uBAa9C;CACA,UAA6B;CAC7B,wBAA2C;EACzC;EACA;EACA;EACA;EACA;EACA;CACF;CAEA,cAAc;EACZ,MAAM;GACJ,WAAW;GACX,MAAM;EACR,CAAC;CACH;AACF;;;ACtEA,IAAa,4BAAb,cAA+C,kBAAkB;CAC/D;CAEA,YAAY,EAAE,MAA0B;EACtC,MAAM;EACN,KAAK,KAAK;CACZ;CAEA,MAAM,sBAAqC;EACzC,KAAK,GAAG,WAAW,MAAM;EACzB,KAAK,GAAG,kBAAkB,MAAM;CAClC;CAMA,MAAM,QAAQ,IAAkD;EAC9D,MAAM,SAAS,KAAK,GAAG,WAAW,IAAI,EAAE;EACxC,OAAO,SAAS,KAAK,eAAe,MAAM,IAAI;CAChD;CAEA,MAAM,OAAO,OAAkF;EAC7F,MAAM,EAAE,cAAc;EAEtB,IAAI,KAAK,GAAG,WAAW,IAAI,UAAU,EAAE,GACrC,MAAM,IAAI,MAAM,qBAAqB,UAAU,GAAG,gBAAgB;EAGpE,MAAM,sBAAM,IAAI,KAAK;EACrB,MAAM,YAAkC;GACtC,IAAI,UAAU;GACd,QAAQ;GACR,iBAAiB,KAAA;GACjB,UAAU,UAAU;GACpB,UAAU,UAAU;G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