pocketbase-zod-schema 0.1.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/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/README.md +167 -0
- package/dist/cli/index.cjs +3383 -0
- package/dist/cli/index.cjs.map +1 -0
- package/dist/cli/index.d.cts +30 -0
- package/dist/cli/index.d.ts +30 -0
- package/dist/cli/index.js +3331 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/migrate.cjs +3380 -0
- package/dist/cli/migrate.cjs.map +1 -0
- package/dist/cli/migrate.d.cts +1 -0
- package/dist/cli/migrate.d.ts +1 -0
- package/dist/cli/migrate.js +3353 -0
- package/dist/cli/migrate.js.map +1 -0
- package/dist/cli/utils/index.cjs +540 -0
- package/dist/cli/utils/index.cjs.map +1 -0
- package/dist/cli/utils/index.d.cts +232 -0
- package/dist/cli/utils/index.d.ts +232 -0
- package/dist/cli/utils/index.js +487 -0
- package/dist/cli/utils/index.js.map +1 -0
- package/dist/enums.cjs +19 -0
- package/dist/enums.cjs.map +1 -0
- package/dist/enums.d.cts +6 -0
- package/dist/enums.d.ts +6 -0
- package/dist/enums.js +17 -0
- package/dist/enums.js.map +1 -0
- package/dist/index.cjs +4900 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +4726 -0
- package/dist/index.js.map +1 -0
- package/dist/migration/analyzer.cjs +1267 -0
- package/dist/migration/analyzer.cjs.map +1 -0
- package/dist/migration/analyzer.d.cts +186 -0
- package/dist/migration/analyzer.d.ts +186 -0
- package/dist/migration/analyzer.js +1232 -0
- package/dist/migration/analyzer.js.map +1 -0
- package/dist/migration/diff.cjs +557 -0
- package/dist/migration/diff.cjs.map +1 -0
- package/dist/migration/diff.d.cts +291 -0
- package/dist/migration/diff.d.ts +291 -0
- package/dist/migration/diff.js +534 -0
- package/dist/migration/diff.js.map +1 -0
- package/dist/migration/generator.cjs +778 -0
- package/dist/migration/generator.cjs.map +1 -0
- package/dist/migration/generator.d.cts +225 -0
- package/dist/migration/generator.d.ts +225 -0
- package/dist/migration/generator.js +737 -0
- package/dist/migration/generator.js.map +1 -0
- package/dist/migration/index.cjs +3390 -0
- package/dist/migration/index.cjs.map +1 -0
- package/dist/migration/index.d.cts +103 -0
- package/dist/migration/index.d.ts +103 -0
- package/dist/migration/index.js +3265 -0
- package/dist/migration/index.js.map +1 -0
- package/dist/migration/snapshot.cjs +609 -0
- package/dist/migration/snapshot.cjs.map +1 -0
- package/dist/migration/snapshot.d.cts +167 -0
- package/dist/migration/snapshot.d.ts +167 -0
- package/dist/migration/snapshot.js +575 -0
- package/dist/migration/snapshot.js.map +1 -0
- package/dist/migration/utils/index.cjs +672 -0
- package/dist/migration/utils/index.cjs.map +1 -0
- package/dist/migration/utils/index.d.cts +207 -0
- package/dist/migration/utils/index.d.ts +207 -0
- package/dist/migration/utils/index.js +641 -0
- package/dist/migration/utils/index.js.map +1 -0
- package/dist/mutator.cjs +427 -0
- package/dist/mutator.cjs.map +1 -0
- package/dist/mutator.d.cts +190 -0
- package/dist/mutator.d.ts +190 -0
- package/dist/mutator.js +425 -0
- package/dist/mutator.js.map +1 -0
- package/dist/permissions-ZHafVSIx.d.cts +71 -0
- package/dist/permissions-ZHafVSIx.d.ts +71 -0
- package/dist/schema.cjs +430 -0
- package/dist/schema.cjs.map +1 -0
- package/dist/schema.d.cts +316 -0
- package/dist/schema.d.ts +316 -0
- package/dist/schema.js +396 -0
- package/dist/schema.js.map +1 -0
- package/dist/types-BbTgmg6H.d.cts +91 -0
- package/dist/types-z1Dkjg8m.d.ts +91 -0
- package/dist/types.cjs +4 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +14 -0
- package/dist/types.d.ts +14 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/user-jS1aYoeD.d.cts +123 -0
- package/dist/user-jS1aYoeD.d.ts +123 -0
- package/package.json +165 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/migration/errors.ts","../../src/migration/snapshot.ts"],"names":["path","fs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,IAAM,cAAA,GAAN,MAAM,eAAA,SAAuB,KAAA,CAAM;AAAA,EACxC,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,gBAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,eAAA,CAAe,SAAS,CAAA;AAAA,EACtD;AACF,CAAA;AAwCO,IAAM,aAAA,GAAN,MAAM,cAAA,SAAsB,cAAA,CAAe;AAAA,EAChC,YAAA;AAAA,EACA,SAAA;AAAA,EACA,aAAA;AAAA,EAEhB,WAAA,CACE,OAAA,EACA,YAAA,EACA,SAAA,EACA,aAAA,EACA;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,eAAA;AACZ,IAAA,IAAA,CAAK,YAAA,GAAe,YAAA;AACpB,IAAA,IAAA,CAAK,SAAA,GAAY,SAAA;AACjB,IAAA,IAAA,CAAK,aAAA,GAAgB,aAAA;AACrB,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,cAAA,CAAc,SAAS,CAAA;AAAA,EACrD;AAAA;AAAA;AAAA;AAAA,EAKO,kBAAA,GAA6B;AAClC,IAAA,MAAM,KAAA,GAAkB,CAAC,IAAA,CAAK,OAAO,CAAA;AAErC,IAAA,IAAI,KAAK,SAAA,EAAW;AAClB,MAAA,KAAA,CAAM,IAAA,CAAK;AAAA,WAAA,EAAgB,IAAA,CAAK,SAAS,CAAA,CAAE,CAAA;AAAA,IAC7C;AAEA,IAAA,IAAI,KAAK,YAAA,EAAc;AACrB,MAAA,KAAA,CAAM,IAAA,CAAK;AAAA,UAAA,EAAe,IAAA,CAAK,YAAY,CAAA,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AK,MAAA,GAAS,YAAY,MAAM,CAAA;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA,EAKA,YAAA,GAA+B;AAC7B,IAAA,OAAO,YAAA,CAAa,KAAK,MAAM,CAAA;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA,EAKA,aAAa,MAAA,EAAgC;AAC3C,IAAA,YAAA,CAAa,MAAA,EAAQ,KAAK,MAAM,CAAA;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA,EAKA,oBAAA,GAA8C;AAC5C,IAAA,OAAO,oBAAA,CAAqB,KAAK,MAAM,CAAA;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA,EAKA,cAAA,GAA0B;AACxB,IAAA,OAAO,cAAA,CAAe,KAAK,MAAM,CAAA;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA,EAKA,2BAA2B,OAAA,EAAiC;AAC1D,IAAA,OAAO,2BAA2B,OAAO,CAAA;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA,EAKA,eAAA,GAA0B;AACxB,IAAA,OAAO,eAAA,CAAgB,KAAK,MAAM,CAAA;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA,EAKA,iBAAiB,QAAA,EAAgE;AAC/E,IAAA,OAAO,iBAAiB,QAAQ,CAAA;AAAA,EAClC;AACF","file":"snapshot.cjs","sourcesContent":["/**\n * Custom error classes for migration tool\n * Provides specific error types for better error handling and user feedback\n */\n\n/**\n * Base error class for all migration-related errors\n */\nexport class MigrationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"MigrationError\";\n Object.setPrototypeOf(this, MigrationError.prototype);\n }\n}\n\n/**\n * Error thrown when schema parsing fails\n * Used when Zod schemas cannot be parsed or are invalid\n */\nexport class SchemaParsingError extends MigrationError {\n public readonly filePath?: string;\n public readonly originalError?: Error;\n\n constructor(message: string, filePath?: string, originalError?: Error) {\n super(message);\n this.name = \"SchemaParsingError\";\n this.filePath = filePath;\n this.originalError = originalError;\n Object.setPrototypeOf(this, SchemaParsingError.prototype);\n }\n\n /**\n * Creates a formatted error message with file path and original error details\n */\n public getDetailedMessage(): string {\n const parts: string[] = [this.message];\n\n if (this.filePath) {\n parts.push(`\\nFile: ${this.filePath}`);\n }\n\n if (this.originalError) {\n parts.push(`\\nCause: ${this.originalError.message}`);\n }\n\n return parts.join(\"\");\n }\n}\n\n/**\n * Error thrown when snapshot operations fail\n * Used for snapshot file read/write/parse errors\n */\nexport class SnapshotError extends MigrationError {\n public readonly snapshotPath?: string;\n public readonly operation?: \"read\" | \"write\" | \"parse\" | \"validate\";\n public readonly originalError?: Error;\n\n constructor(\n message: string,\n snapshotPath?: string,\n operation?: \"read\" | \"write\" | \"parse\" | \"validate\",\n originalError?: Error\n ) {\n super(message);\n this.name = \"SnapshotError\";\n this.snapshotPath = snapshotPath;\n this.operation = operation;\n this.originalError = originalError;\n Object.setPrototypeOf(this, SnapshotError.prototype);\n }\n\n /**\n * Creates a formatted error message with snapshot path and operation details\n */\n public getDetailedMessage(): string {\n const parts: string[] = [this.message];\n\n if (this.operation) {\n parts.push(`\\nOperation: ${this.operation}`);\n }\n\n if (this.snapshotPath) {\n parts.push(`\\nSnapshot: ${this.snapshotPath}`);\n }\n\n if (this.originalError) {\n parts.push(`\\nCause: ${this.originalError.message}`);\n }\n\n return parts.join(\"\");\n }\n}\n\n/**\n * Error thrown when migration file generation fails\n * Used when migration files cannot be created or written\n */\nexport class MigrationGenerationError extends MigrationError {\n public readonly migrationPath?: string;\n public readonly originalError?: Error;\n\n constructor(message: string, migrationPath?: string, originalError?: Error) {\n super(message);\n this.name = \"MigrationGenerationError\";\n this.migrationPath = migrationPath;\n this.originalError = originalError;\n Object.setPrototypeOf(this, MigrationGenerationError.prototype);\n }\n\n /**\n * Creates a formatted error message with migration path and original error details\n */\n public getDetailedMessage(): string {\n const parts: string[] = [this.message];\n\n if (this.migrationPath) {\n parts.push(`\\nMigration: ${this.migrationPath}`);\n }\n\n if (this.originalError) {\n parts.push(`\\nCause: ${this.originalError.message}`);\n }\n\n return parts.join(\"\");\n }\n}\n\n/**\n * Error thrown when file system operations fail\n * Used for directory creation, file permissions, disk space issues\n */\nexport class FileSystemError extends MigrationError {\n public readonly path?: string;\n public readonly operation?: \"read\" | \"write\" | \"create\" | \"delete\" | \"access\";\n public readonly code?: string;\n public readonly originalError?: Error;\n\n constructor(\n message: string,\n path?: string,\n operation?: \"read\" | \"write\" | \"create\" | \"delete\" | \"access\",\n code?: string,\n originalError?: Error\n ) {\n super(message);\n this.name = \"FileSystemError\";\n this.path = path;\n this.operation = operation;\n this.code = code;\n this.originalError = originalError;\n Object.setPrototypeOf(this, FileSystemError.prototype);\n }\n\n /**\n * Creates a formatted error message with path, operation, and error code details\n */\n public getDetailedMessage(): string {\n const parts: string[] = [this.message];\n\n if (this.operation) {\n parts.push(`\\nOperation: ${this.operation}`);\n }\n\n if (this.path) {\n parts.push(`\\nPath: ${this.path}`);\n }\n\n if (this.code) {\n parts.push(`\\nError Code: ${this.code}`);\n }\n\n if (this.originalError) {\n parts.push(`\\nCause: ${this.originalError.message}`);\n }\n\n return parts.join(\"\");\n }\n}\n\n/**\n * Error thrown when configuration is invalid\n * Used for configuration file parsing, validation, and path resolution errors\n */\nexport class ConfigurationError extends MigrationError {\n public readonly configPath?: string;\n public readonly invalidFields?: string[];\n public readonly originalError?: Error;\n\n constructor(message: string, configPath?: string, invalidFields?: string[], originalError?: Error) {\n super(message);\n this.name = \"ConfigurationError\";\n this.configPath = configPath;\n this.invalidFields = invalidFields;\n this.originalError = originalError;\n Object.setPrototypeOf(this, ConfigurationError.prototype);\n }\n\n /**\n * Creates a formatted error message with configuration details\n */\n public getDetailedMessage(): string {\n const parts: string[] = [this.message];\n\n if (this.configPath) {\n parts.push(`\\nConfiguration File: ${this.configPath}`);\n }\n\n if (this.invalidFields && this.invalidFields.length > 0) {\n parts.push(`\\nInvalid Fields: ${this.invalidFields.join(\", \")}`);\n }\n\n if (this.originalError) {\n parts.push(`\\nCause: ${this.originalError.message}`);\n }\n\n return parts.join(\"\");\n }\n}\n\n/**\n * Error thrown when CLI command usage is incorrect\n * Used for invalid arguments, missing required options, etc.\n */\nexport class CLIUsageError extends MigrationError {\n public readonly command?: string;\n public readonly suggestion?: string;\n\n constructor(message: string, command?: string, suggestion?: string) {\n super(message);\n this.name = \"CLIUsageError\";\n this.command = command;\n this.suggestion = suggestion;\n Object.setPrototypeOf(this, CLIUsageError.prototype);\n }\n\n /**\n * Creates a formatted error message with usage suggestions\n */\n public getDetailedMessage(): string {\n const parts: string[] = [this.message];\n\n if (this.command) {\n parts.push(`\\nCommand: ${this.command}`);\n }\n\n if (this.suggestion) {\n parts.push(`\\nSuggestion: ${this.suggestion}`);\n }\n\n return parts.join(\"\");\n }\n}\n","/**\n * Snapshot Manager component\n * Handles saving and loading schema snapshots\n *\n * This module provides a standalone, configurable snapshot manager that can be used\n * by consumer projects to manage schema snapshots and convert PocketBase migrations.\n */\n\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport { FileSystemError, SnapshotError } from \"./errors\";\nimport type { CollectionSchema, SchemaDefinition, SchemaSnapshot } from \"./types\";\n\nconst SNAPSHOT_VERSION = \"1.0.0\";\nconst DEFAULT_SNAPSHOT_FILENAME = \".migration-snapshot.json\";\n\n/**\n * Configuration for snapshot operations\n */\nexport interface SnapshotConfig {\n /**\n * Path to the snapshot file\n * Can be absolute or relative to workspaceRoot\n */\n snapshotPath?: string;\n\n /**\n * Workspace root directory for resolving relative paths\n * Defaults to process.cwd()\n */\n workspaceRoot?: string;\n\n /**\n * Path to the migrations directory for finding PocketBase snapshots\n */\n migrationsPath?: string;\n\n /**\n * Whether to auto-migrate old snapshot formats\n * Defaults to true\n */\n autoMigrate?: boolean;\n\n /**\n * Custom snapshot version for testing\n */\n version?: string;\n}\n\n/**\n * Snapshot format versions and their migration functions\n */\ninterface SnapshotMigration {\n fromVersion: string;\n toVersion: string;\n migrate: (data: any) => any;\n}\n\n/**\n * Registry of snapshot format migrations\n */\nconst SNAPSHOT_MIGRATIONS: SnapshotMigration[] = [\n // Add migrations here as the format evolves\n // Example:\n // {\n // fromVersion: '0.9.0',\n // toVersion: '1.0.0',\n // migrate: (data) => ({ ...data, newField: 'default' })\n // }\n];\n\n/**\n * Default configuration values\n */\nconst DEFAULT_CONFIG: Omit<Required<SnapshotConfig>, \"migrationsPath\"> & { migrationsPath?: string } = {\n snapshotPath: DEFAULT_SNAPSHOT_FILENAME,\n workspaceRoot: process.cwd(),\n autoMigrate: true,\n version: SNAPSHOT_VERSION,\n};\n\n/**\n * Merges user config with defaults\n */\nfunction mergeConfig(config: SnapshotConfig = {}): typeof DEFAULT_CONFIG {\n return {\n ...DEFAULT_CONFIG,\n ...config,\n };\n}\n\n/**\n * Gets the snapshot file path from configuration\n *\n * @param config - Snapshot configuration\n * @returns Absolute path to the snapshot file\n */\nexport function getSnapshotPath(config: SnapshotConfig = {}): string {\n const mergedConfig = mergeConfig(config);\n const workspaceRoot = mergedConfig.workspaceRoot;\n const snapshotFilename = mergedConfig.snapshotPath;\n\n // If snapshotPath is absolute, use it directly\n if (path.isAbsolute(snapshotFilename)) {\n return snapshotFilename;\n }\n\n // Otherwise, resolve relative to workspaceRoot\n return path.join(workspaceRoot, snapshotFilename);\n}\n\n/**\n * Checks if snapshot file exists\n *\n * @param config - Snapshot configuration\n * @returns True if snapshot file exists\n */\nexport function snapshotExists(config: SnapshotConfig = {}): boolean {\n try {\n const snapshotPath = getSnapshotPath(config);\n return fs.existsSync(snapshotPath);\n } catch {\n // If there's any error checking existence, treat as non-existent\n return false;\n }\n}\n\n/**\n * Handles file system errors with descriptive messages\n *\n * @param error - The error object\n * @param operation - The operation being performed\n * @param filePath - The file path involved\n * @throws SnapshotError or FileSystemError with descriptive message\n */\nfunction handleFileSystemError(error: any, operation: \"read\" | \"write\", filePath: string): never {\n const fsError = error as NodeJS.ErrnoException;\n\n if (fsError.code === \"ENOENT\") {\n throw new SnapshotError(`Snapshot file not found: ${filePath}`, filePath, operation, error);\n } else if (fsError.code === \"EACCES\" || fsError.code === \"EPERM\") {\n throw new FileSystemError(\n `Permission denied ${operation === \"read\" ? \"reading\" : \"writing\"} snapshot file. Check file permissions.`,\n filePath,\n operation,\n fsError.code,\n error\n );\n } else if (fsError.code === \"ENOSPC\") {\n throw new FileSystemError(\n `No space left on device when ${operation === \"read\" ? \"reading\" : \"writing\"} snapshot file.`,\n filePath,\n operation,\n fsError.code,\n error\n );\n } else {\n throw new SnapshotError(`Failed to ${operation} snapshot file: ${error.message}`, filePath, operation, error);\n }\n}\n\n/**\n * Serializes a Map to a plain object for JSON serialization\n *\n * @param map - Map to serialize\n * @returns Plain object representation\n */\nfunction serializeMap<K extends string, V>(map: Map<K, V>): Record<K, V> {\n const obj: Record<string, V> = {};\n for (const [key, value] of map.entries()) {\n obj[key] = value;\n }\n return obj as Record<K, V>;\n}\n\n/**\n * Deserializes a plain object to a Map\n *\n * @param obj - Plain object to deserialize\n * @returns Map representation\n */\nfunction deserializeMap<K extends string, V>(obj: Record<K, V>): Map<K, V> {\n const map = new Map<K, V>();\n for (const [key, value] of Object.entries(obj)) {\n map.set(key as K, value as V);\n }\n return map;\n}\n\n/**\n * Serializes SchemaDefinition to JSON format\n * Converts Map to plain object for JSON compatibility\n *\n * @param schema - Schema definition to serialize\n * @returns JSON-serializable object\n */\nfunction serializeSchemaDefinition(schema: SchemaDefinition): any {\n return {\n collections: serializeMap(schema.collections),\n };\n}\n\n/**\n * Adds version and timestamp metadata to snapshot\n *\n * @param schema - Schema definition\n * @param config - Optional configuration with custom version\n * @returns Snapshot with metadata\n */\nfunction addSnapshotMetadata(schema: SchemaDefinition, config?: SnapshotConfig): any {\n const mergedConfig = mergeConfig(config);\n return {\n version: mergedConfig.version,\n timestamp: new Date().toISOString(),\n ...serializeSchemaDefinition(schema),\n };\n}\n\n/**\n * Saves schema snapshot to file\n * Serializes SchemaDefinition to JSON with version and timestamp metadata\n * Writes with pretty printing for readability\n *\n * @param schema - Schema definition to save\n * @param config - Snapshot configuration\n */\nexport function saveSnapshot(schema: SchemaDefinition, config: SnapshotConfig = {}): void {\n const snapshotPath = getSnapshotPath(config);\n\n try {\n // Ensure directory exists\n const snapshotDir = path.dirname(snapshotPath);\n if (!fs.existsSync(snapshotDir)) {\n fs.mkdirSync(snapshotDir, { recursive: true });\n }\n\n // Add metadata and serialize\n const snapshotData = addSnapshotMetadata(schema, config);\n\n // Write with pretty printing (2 spaces indentation)\n const jsonContent = JSON.stringify(snapshotData, null, 2);\n fs.writeFileSync(snapshotPath, jsonContent, \"utf-8\");\n } catch (error) {\n handleFileSystemError(error, \"write\", snapshotPath);\n }\n}\n\n/**\n * Parses JSON and validates snapshot format\n *\n * @param jsonContent - Raw JSON content\n * @param snapshotPath - Path to snapshot file (for error messages)\n * @returns Parsed snapshot data\n */\nfunction parseAndValidateSnapshot(jsonContent: string, snapshotPath: string): any {\n try {\n const data = JSON.parse(jsonContent);\n\n // Validate required fields\n if (!data.version) {\n throw new SnapshotError(\n \"Snapshot file is missing version field. The snapshot may be corrupted.\",\n snapshotPath,\n \"validate\"\n );\n }\n\n if (!data.timestamp) {\n throw new SnapshotError(\n \"Snapshot file is missing timestamp field. The snapshot may be corrupted.\",\n snapshotPath,\n \"validate\"\n );\n }\n\n if (!data.collections) {\n throw new SnapshotError(\n \"Snapshot file is missing collections field. The snapshot may be corrupted.\",\n snapshotPath,\n \"validate\"\n );\n }\n\n return data;\n } catch (error) {\n if (error instanceof SnapshotError) {\n throw error;\n }\n\n if (error instanceof SyntaxError) {\n throw new SnapshotError(\n `Invalid JSON in snapshot file. The file may be corrupted or manually edited incorrectly.`,\n snapshotPath,\n \"parse\",\n error\n );\n }\n throw error;\n }\n}\n\n/**\n * Compares two version strings\n * Returns -1 if a < b, 0 if a == b, 1 if a > b\n */\nfunction compareVersions(a: string, b: string): number {\n const partsA = a.split(\".\").map(Number);\n const partsB = b.split(\".\").map(Number);\n\n for (let i = 0; i < Math.max(partsA.length, partsB.length); i++) {\n const numA = partsA[i] || 0;\n const numB = partsB[i] || 0;\n\n if (numA < numB) return -1;\n if (numA > numB) return 1;\n }\n\n return 0;\n}\n\n/**\n * Migrates old snapshot formats to current version\n * Applies migrations in sequence from old version to current\n *\n * @param data - Parsed snapshot data\n * @param config - Optional configuration\n * @returns Migrated snapshot data\n */\nfunction migrateSnapshotFormat(data: any, config?: SnapshotConfig): any {\n const mergedConfig = mergeConfig(config);\n const currentVersion = data.version;\n const targetVersion = mergedConfig.version;\n\n // If versions match, no migration needed\n if (currentVersion === targetVersion) {\n return data;\n }\n\n // If auto-migrate is disabled, just return the data with a warning\n if (!mergedConfig.autoMigrate) {\n console.warn(\n `Snapshot version ${currentVersion} differs from current ${targetVersion}, but auto-migrate is disabled.`\n );\n return data;\n }\n\n // Find and apply migrations in sequence\n let migratedData = { ...data };\n let currentMigrationVersion = currentVersion;\n\n // Sort migrations by fromVersion\n const sortedMigrations = [...SNAPSHOT_MIGRATIONS].sort((a, b) => compareVersions(a.fromVersion, b.fromVersion));\n\n for (const migration of sortedMigrations) {\n if (compareVersions(currentMigrationVersion, migration.fromVersion) === 0) {\n console.log(`Migrating snapshot from ${migration.fromVersion} to ${migration.toVersion}...`);\n migratedData = migration.migrate(migratedData);\n migratedData.version = migration.toVersion;\n currentMigrationVersion = migration.toVersion;\n }\n }\n\n // If we couldn't migrate to the target version, log a warning\n if (compareVersions(currentMigrationVersion, targetVersion) !== 0) {\n console.warn(`Unknown snapshot version ${currentVersion}, attempting to load anyway...`);\n }\n\n return migratedData;\n}\n\n/**\n * Deserializes snapshot data to SchemaSnapshot\n *\n * @param data - Parsed and validated snapshot data\n * @returns SchemaSnapshot object\n */\nfunction deserializeSnapshot(data: any): SchemaSnapshot {\n return {\n version: data.version,\n timestamp: data.timestamp,\n collections: deserializeMap<string, CollectionSchema>(data.collections),\n };\n}\n\n/**\n * Loads schema snapshot from file\n * Reads snapshot file, parses JSON, validates format, and handles migrations\n *\n * @param config - Snapshot configuration\n * @returns SchemaSnapshot object\n * @throws Error if snapshot file doesn't exist or is invalid\n */\nexport function loadSnapshot(config: SnapshotConfig = {}): SchemaSnapshot {\n const snapshotPath = getSnapshotPath(config);\n\n try {\n // Read file\n const jsonContent = fs.readFileSync(snapshotPath, \"utf-8\");\n\n // Parse and validate\n const data = parseAndValidateSnapshot(jsonContent, snapshotPath);\n\n // Migrate format if needed\n const migratedData = migrateSnapshotFormat(data, config);\n\n // Deserialize to SchemaSnapshot\n return deserializeSnapshot(migratedData);\n } catch (error) {\n // If it's already a SnapshotError or FileSystemError, re-throw it\n if (error instanceof SnapshotError || error instanceof FileSystemError) {\n throw error;\n }\n\n // If file doesn't exist, throw specific error\n if ((error as any).code === \"ENOENT\") {\n throw new SnapshotError(\n `Snapshot file not found. This may be the first migration run.`,\n snapshotPath,\n \"read\",\n error as Error\n );\n }\n\n // Handle other file system errors\n handleFileSystemError(error, \"read\", snapshotPath);\n }\n}\n\n/**\n * Merges base schema with custom snapshot\n * Base schema collections are preserved, custom collections are added\n * Custom collections override base collections if they have the same name\n *\n * @param baseSnapshot - PocketBase base schema\n * @param customSnapshot - User's custom schema snapshot (may be null)\n * @returns Merged SchemaSnapshot\n */\nexport function mergeSnapshots(baseSnapshot: SchemaSnapshot, customSnapshot: SchemaSnapshot | null): SchemaSnapshot {\n // If no custom snapshot, return base snapshot\n if (!customSnapshot) {\n return baseSnapshot;\n }\n\n // Create a new collections map starting with base collections\n const mergedCollections = new Map<string, CollectionSchema>(baseSnapshot.collections);\n\n // Add or override with custom collections\n for (const [name, schema] of customSnapshot.collections.entries()) {\n mergedCollections.set(name, schema);\n }\n\n return {\n version: customSnapshot.version || baseSnapshot.version,\n timestamp: customSnapshot.timestamp || baseSnapshot.timestamp,\n collections: mergedCollections,\n };\n}\n\n/**\n * Finds the most recent snapshot file in the migrations directory\n * Identifies snapshot files by naming pattern (e.g., *_collections_snapshot.js)\n *\n * @param migrationsPath - Path to pb_migrations directory\n * @returns Path to most recent snapshot file or null if none exist\n */\nexport function findLatestSnapshot(migrationsPath: string): string | null {\n try {\n // Check if migrations directory exists\n if (!fs.existsSync(migrationsPath)) {\n return null;\n }\n\n // Read all files in migrations directory\n const files = fs.readdirSync(migrationsPath);\n\n // Filter for snapshot files (files ending with _collections_snapshot.js or _snapshot.js)\n const snapshotFiles = files.filter(\n (file) => file.endsWith(\"_collections_snapshot.js\") || file.endsWith(\"_snapshot.js\")\n );\n\n if (snapshotFiles.length === 0) {\n return null;\n }\n\n // Sort by filename (timestamp prefix) to get most recent\n // Snapshot files are named with timestamp prefix: [timestamp]_collections_snapshot.js\n snapshotFiles.sort().reverse();\n\n // Return full path to most recent snapshot\n const latestSnapshot = snapshotFiles[0];\n if (!latestSnapshot) {\n return null;\n }\n return path.join(migrationsPath, latestSnapshot);\n } catch (error) {\n // If there's any error reading directory, return null\n console.warn(`Error finding latest snapshot: ${error}`);\n return null;\n }\n}\n\n/**\n * Loads snapshot if it exists, returns null for first run\n * Convenience method that handles missing snapshot gracefully\n * Finds the most recent snapshot file from migrations directory\n *\n * @param config - Snapshot configuration (must include migrationsPath)\n * @returns SchemaSnapshot object or null if snapshot doesn't exist\n */\nexport function loadSnapshotIfExists(config: SnapshotConfig = {}): SchemaSnapshot | null {\n const migrationsPath = config.migrationsPath;\n\n if (!migrationsPath) {\n // No migrations path provided - return null\n return null;\n }\n\n // Check if migrationsPath is actually a file (for backward compatibility with tests)\n // If it's a file, treat it as a direct snapshot file path\n if (fs.existsSync(migrationsPath) && fs.statSync(migrationsPath).isFile()) {\n try {\n const migrationContent = fs.readFileSync(migrationsPath, \"utf-8\");\n return convertPocketBaseMigration(migrationContent);\n } catch (error) {\n console.warn(`Failed to load snapshot from ${migrationsPath}: ${error}`);\n return null;\n }\n }\n\n // It's a directory, find the latest snapshot\n const latestSnapshotPath = findLatestSnapshot(migrationsPath);\n\n if (latestSnapshotPath) {\n try {\n // Read and convert the PocketBase snapshot file\n const migrationContent = fs.readFileSync(latestSnapshotPath, \"utf-8\");\n return convertPocketBaseMigration(migrationContent);\n } catch (error) {\n console.warn(`Failed to load snapshot from ${latestSnapshotPath}: ${error}`);\n return null;\n }\n }\n\n // No snapshot found - return null (empty database)\n return null;\n}\n\n/**\n * Converts a PocketBase collection object to CollectionSchema format\n *\n * @param pbCollection - PocketBase collection object from migration file\n * @returns CollectionSchema object\n */\nfunction convertPocketBaseCollection(pbCollection: any): CollectionSchema {\n const fields: any[] = [];\n\n // System field names that should always be excluded\n const systemFieldNames = [\"id\", \"created\", \"updated\", \"collectionId\", \"collectionName\", \"expand\"];\n\n // Auth collection system field names\n const authSystemFieldNames = [\"email\", \"emailVisibility\", \"verified\", \"password\", \"tokenKey\"];\n\n // Convert PocketBase fields to our FieldDefinition format\n if (pbCollection.fields && Array.isArray(pbCollection.fields)) {\n for (const pbField of pbCollection.fields) {\n // Skip system fields by checking both the system flag and field name\n // Some PocketBase exports mark created/updated as system: false\n if (pbField.system || systemFieldNames.includes(pbField.name)) {\n continue;\n }\n\n // Skip auth system fields for auth collections\n if (pbCollection.type === \"auth\" && authSystemFieldNames.includes(pbField.name)) {\n continue;\n }\n\n const field: any = {\n name: pbField.name,\n type: pbField.type,\n required: pbField.required || false,\n };\n\n // Add options if present\n if (pbField.options) {\n field.options = pbField.options;\n }\n\n // Handle relation fields\n if (pbField.type === \"relation\") {\n field.relation = {\n collection: pbField.options?.collectionId || \"\",\n cascadeDelete: pbField.options?.cascadeDelete || false,\n maxSelect: pbField.options?.maxSelect,\n minSelect: pbField.options?.minSelect,\n };\n }\n\n fields.push(field);\n }\n }\n\n const schema: CollectionSchema = {\n name: pbCollection.name,\n type: pbCollection.type || \"base\",\n fields,\n };\n\n // Add indexes if present\n if (pbCollection.indexes && Array.isArray(pbCollection.indexes)) {\n schema.indexes = pbCollection.indexes;\n }\n\n // Add rules/permissions\n const rules: any = {};\n if (pbCollection.listRule !== undefined) rules.listRule = pbCollection.listRule;\n if (pbCollection.viewRule !== undefined) rules.viewRule = pbCollection.viewRule;\n if (pbCollection.createRule !== undefined) rules.createRule = pbCollection.createRule;\n if (pbCollection.updateRule !== undefined) rules.updateRule = pbCollection.updateRule;\n if (pbCollection.deleteRule !== undefined) rules.deleteRule = pbCollection.deleteRule;\n if (pbCollection.manageRule !== undefined) rules.manageRule = pbCollection.manageRule;\n\n if (Object.keys(rules).length > 0) {\n schema.rules = rules;\n }\n\n return schema;\n}\n\n/**\n * Converts PocketBase migration format to SchemaSnapshot\n * Extracts the snapshot array from the migration file content\n *\n * @param migrationContent - Raw migration file content\n * @returns SchemaSnapshot with collections map\n */\nexport function convertPocketBaseMigration(migrationContent: string): SchemaSnapshot {\n try {\n // Extract the snapshot array from the migration file\n // The format is: migrate((app) => { const snapshot = [...]; ... })\n const snapshotMatch = migrationContent.match(/const\\s+snapshot\\s*=\\s*(\\[[\\s\\S]*?\\]);/);\n\n if (!snapshotMatch) {\n throw new Error(\"Could not find snapshot array in migration file\");\n }\n\n // Parse the snapshot array as JSON\n // We need to evaluate it as JavaScript since it's not pure JSON\n const snapshotArrayStr = snapshotMatch[1];\n let snapshotArray: any[];\n\n try {\n // Use Function constructor to safely evaluate the array\n // This is safer than eval() and works for our use case\n snapshotArray = new Function(`return ${snapshotArrayStr}`)();\n } catch (parseError) {\n throw new Error(`Failed to parse snapshot array: ${parseError}`);\n }\n\n if (!Array.isArray(snapshotArray)) {\n throw new Error(\"Snapshot is not an array\");\n }\n\n // Convert each collection to our format\n const collections = new Map<string, CollectionSchema>();\n\n for (const pbCollection of snapshotArray) {\n if (!pbCollection.name) {\n console.warn(\"Skipping collection without name\");\n continue;\n }\n\n const schema = convertPocketBaseCollection(pbCollection);\n collections.set(pbCollection.name, schema);\n }\n\n return {\n version: SNAPSHOT_VERSION,\n timestamp: new Date().toISOString(),\n collections,\n };\n } catch (error) {\n throw new SnapshotError(\n `Failed to convert PocketBase migration: ${error instanceof Error ? error.message : String(error)}`,\n undefined,\n \"parse\",\n error instanceof Error ? error : undefined\n );\n }\n}\n\n/**\n * Loads the base PocketBase schema from the initial migration file\n *\n * @param migrationPath - Path to pocketbase/pb_migrations/000000000_collections_snapshot.js\n * @returns SchemaSnapshot representing PocketBase's initial state\n * @throws SnapshotError if file not found or invalid format\n */\nexport function loadBaseMigration(migrationPath: string): SchemaSnapshot {\n try {\n // Check if file exists\n if (!fs.existsSync(migrationPath)) {\n throw new SnapshotError(\n `Base migration file not found: ${migrationPath}\\n\\n` +\n `This file should contain PocketBase's initial schema.\\n` +\n `Please ensure PocketBase is properly set up by running 'yarn setup'.\\n` +\n `If the file exists in a different location, update the configuration.`,\n migrationPath,\n \"read\"\n );\n }\n\n // Read the migration file\n const migrationContent = fs.readFileSync(migrationPath, \"utf-8\");\n\n // Convert to SchemaSnapshot\n const snapshot = convertPocketBaseMigration(migrationContent);\n\n return snapshot;\n } catch (error) {\n // If it's already a SnapshotError, re-throw it\n if (error instanceof SnapshotError) {\n throw error;\n }\n\n // Handle file system errors\n if ((error as any).code === \"ENOENT\") {\n throw new SnapshotError(\n `Base migration file not found: ${migrationPath}\\n\\n` +\n `This file should contain PocketBase's initial schema.\\n` +\n `Please ensure PocketBase is properly set up by running 'yarn setup'.`,\n migrationPath,\n \"read\",\n error as Error\n );\n }\n\n if ((error as any).code === \"EACCES\" || (error as any).code === \"EPERM\") {\n throw new FileSystemError(\n `Permission denied reading base migration file. Check file permissions.`,\n migrationPath,\n \"read\",\n (error as any).code,\n error as Error\n );\n }\n\n // Other errors\n throw new SnapshotError(\n `Failed to load base migration: ${error instanceof Error ? error.message : String(error)}`,\n migrationPath,\n \"read\",\n error instanceof Error ? error : undefined\n );\n }\n}\n\n/**\n * Gets the current snapshot version\n */\nexport function getSnapshotVersion(): string {\n return SNAPSHOT_VERSION;\n}\n\n/**\n * Validates a snapshot against the current version\n * Returns validation result with any issues found\n */\nexport function validateSnapshot(snapshot: SchemaSnapshot): { valid: boolean; issues: string[] } {\n const issues: string[] = [];\n\n // Check version\n if (!snapshot.version) {\n issues.push(\"Missing version field\");\n } else if (compareVersions(snapshot.version, SNAPSHOT_VERSION) > 0) {\n issues.push(`Snapshot version ${snapshot.version} is newer than supported version ${SNAPSHOT_VERSION}`);\n }\n\n // Check timestamp\n if (!snapshot.timestamp) {\n issues.push(\"Missing timestamp field\");\n }\n\n // Check collections\n if (!snapshot.collections) {\n issues.push(\"Missing collections field\");\n } else if (!(snapshot.collections instanceof Map)) {\n issues.push(\"Collections field is not a Map\");\n }\n\n return {\n valid: issues.length === 0,\n issues,\n };\n}\n\n/**\n * SnapshotManager class for object-oriented usage\n * Provides a stateful interface for snapshot management\n */\nexport class SnapshotManager {\n private config: SnapshotConfig;\n\n constructor(config: SnapshotConfig = {}) {\n this.config = mergeConfig(config);\n }\n\n /**\n * Loads the current snapshot\n */\n loadSnapshot(): SchemaSnapshot {\n return loadSnapshot(this.config);\n }\n\n /**\n * Saves a schema as a snapshot\n */\n saveSnapshot(schema: SchemaDefinition): void {\n saveSnapshot(schema, this.config);\n }\n\n /**\n * Loads snapshot if it exists, returns null otherwise\n */\n loadSnapshotIfExists(): SchemaSnapshot | null {\n return loadSnapshotIfExists(this.config);\n }\n\n /**\n * Checks if a snapshot exists\n */\n snapshotExists(): boolean {\n return snapshotExists(this.config);\n }\n\n /**\n * Converts a PocketBase migration to a snapshot\n */\n convertPocketBaseMigration(content: string): SchemaSnapshot {\n return convertPocketBaseMigration(content);\n }\n\n /**\n * Gets the snapshot file path\n */\n getSnapshotPath(): string {\n return getSnapshotPath(this.config);\n }\n\n /**\n * Validates a snapshot\n */\n validateSnapshot(snapshot: SchemaSnapshot): { valid: boolean; issues: string[] } {\n return validateSnapshot(snapshot);\n }\n}\n"]}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { a as SchemaSnapshot, S as SchemaDefinition } from '../types-BbTgmg6H.cjs';
|
|
2
|
+
import '../permissions-ZHafVSIx.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Snapshot Manager component
|
|
6
|
+
* Handles saving and loading schema snapshots
|
|
7
|
+
*
|
|
8
|
+
* This module provides a standalone, configurable snapshot manager that can be used
|
|
9
|
+
* by consumer projects to manage schema snapshots and convert PocketBase migrations.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Configuration for snapshot operations
|
|
14
|
+
*/
|
|
15
|
+
interface SnapshotConfig {
|
|
16
|
+
/**
|
|
17
|
+
* Path to the snapshot file
|
|
18
|
+
* Can be absolute or relative to workspaceRoot
|
|
19
|
+
*/
|
|
20
|
+
snapshotPath?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Workspace root directory for resolving relative paths
|
|
23
|
+
* Defaults to process.cwd()
|
|
24
|
+
*/
|
|
25
|
+
workspaceRoot?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Path to the migrations directory for finding PocketBase snapshots
|
|
28
|
+
*/
|
|
29
|
+
migrationsPath?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to auto-migrate old snapshot formats
|
|
32
|
+
* Defaults to true
|
|
33
|
+
*/
|
|
34
|
+
autoMigrate?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Custom snapshot version for testing
|
|
37
|
+
*/
|
|
38
|
+
version?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Gets the snapshot file path from configuration
|
|
42
|
+
*
|
|
43
|
+
* @param config - Snapshot configuration
|
|
44
|
+
* @returns Absolute path to the snapshot file
|
|
45
|
+
*/
|
|
46
|
+
declare function getSnapshotPath(config?: SnapshotConfig): string;
|
|
47
|
+
/**
|
|
48
|
+
* Checks if snapshot file exists
|
|
49
|
+
*
|
|
50
|
+
* @param config - Snapshot configuration
|
|
51
|
+
* @returns True if snapshot file exists
|
|
52
|
+
*/
|
|
53
|
+
declare function snapshotExists(config?: SnapshotConfig): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Saves schema snapshot to file
|
|
56
|
+
* Serializes SchemaDefinition to JSON with version and timestamp metadata
|
|
57
|
+
* Writes with pretty printing for readability
|
|
58
|
+
*
|
|
59
|
+
* @param schema - Schema definition to save
|
|
60
|
+
* @param config - Snapshot configuration
|
|
61
|
+
*/
|
|
62
|
+
declare function saveSnapshot(schema: SchemaDefinition, config?: SnapshotConfig): void;
|
|
63
|
+
/**
|
|
64
|
+
* Loads schema snapshot from file
|
|
65
|
+
* Reads snapshot file, parses JSON, validates format, and handles migrations
|
|
66
|
+
*
|
|
67
|
+
* @param config - Snapshot configuration
|
|
68
|
+
* @returns SchemaSnapshot object
|
|
69
|
+
* @throws Error if snapshot file doesn't exist or is invalid
|
|
70
|
+
*/
|
|
71
|
+
declare function loadSnapshot(config?: SnapshotConfig): SchemaSnapshot;
|
|
72
|
+
/**
|
|
73
|
+
* Merges base schema with custom snapshot
|
|
74
|
+
* Base schema collections are preserved, custom collections are added
|
|
75
|
+
* Custom collections override base collections if they have the same name
|
|
76
|
+
*
|
|
77
|
+
* @param baseSnapshot - PocketBase base schema
|
|
78
|
+
* @param customSnapshot - User's custom schema snapshot (may be null)
|
|
79
|
+
* @returns Merged SchemaSnapshot
|
|
80
|
+
*/
|
|
81
|
+
declare function mergeSnapshots(baseSnapshot: SchemaSnapshot, customSnapshot: SchemaSnapshot | null): SchemaSnapshot;
|
|
82
|
+
/**
|
|
83
|
+
* Finds the most recent snapshot file in the migrations directory
|
|
84
|
+
* Identifies snapshot files by naming pattern (e.g., *_collections_snapshot.js)
|
|
85
|
+
*
|
|
86
|
+
* @param migrationsPath - Path to pb_migrations directory
|
|
87
|
+
* @returns Path to most recent snapshot file or null if none exist
|
|
88
|
+
*/
|
|
89
|
+
declare function findLatestSnapshot(migrationsPath: string): string | null;
|
|
90
|
+
/**
|
|
91
|
+
* Loads snapshot if it exists, returns null for first run
|
|
92
|
+
* Convenience method that handles missing snapshot gracefully
|
|
93
|
+
* Finds the most recent snapshot file from migrations directory
|
|
94
|
+
*
|
|
95
|
+
* @param config - Snapshot configuration (must include migrationsPath)
|
|
96
|
+
* @returns SchemaSnapshot object or null if snapshot doesn't exist
|
|
97
|
+
*/
|
|
98
|
+
declare function loadSnapshotIfExists(config?: SnapshotConfig): SchemaSnapshot | null;
|
|
99
|
+
/**
|
|
100
|
+
* Converts PocketBase migration format to SchemaSnapshot
|
|
101
|
+
* Extracts the snapshot array from the migration file content
|
|
102
|
+
*
|
|
103
|
+
* @param migrationContent - Raw migration file content
|
|
104
|
+
* @returns SchemaSnapshot with collections map
|
|
105
|
+
*/
|
|
106
|
+
declare function convertPocketBaseMigration(migrationContent: string): SchemaSnapshot;
|
|
107
|
+
/**
|
|
108
|
+
* Loads the base PocketBase schema from the initial migration file
|
|
109
|
+
*
|
|
110
|
+
* @param migrationPath - Path to pocketbase/pb_migrations/000000000_collections_snapshot.js
|
|
111
|
+
* @returns SchemaSnapshot representing PocketBase's initial state
|
|
112
|
+
* @throws SnapshotError if file not found or invalid format
|
|
113
|
+
*/
|
|
114
|
+
declare function loadBaseMigration(migrationPath: string): SchemaSnapshot;
|
|
115
|
+
/**
|
|
116
|
+
* Gets the current snapshot version
|
|
117
|
+
*/
|
|
118
|
+
declare function getSnapshotVersion(): string;
|
|
119
|
+
/**
|
|
120
|
+
* Validates a snapshot against the current version
|
|
121
|
+
* Returns validation result with any issues found
|
|
122
|
+
*/
|
|
123
|
+
declare function validateSnapshot(snapshot: SchemaSnapshot): {
|
|
124
|
+
valid: boolean;
|
|
125
|
+
issues: string[];
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* SnapshotManager class for object-oriented usage
|
|
129
|
+
* Provides a stateful interface for snapshot management
|
|
130
|
+
*/
|
|
131
|
+
declare class SnapshotManager {
|
|
132
|
+
private config;
|
|
133
|
+
constructor(config?: SnapshotConfig);
|
|
134
|
+
/**
|
|
135
|
+
* Loads the current snapshot
|
|
136
|
+
*/
|
|
137
|
+
loadSnapshot(): SchemaSnapshot;
|
|
138
|
+
/**
|
|
139
|
+
* Saves a schema as a snapshot
|
|
140
|
+
*/
|
|
141
|
+
saveSnapshot(schema: SchemaDefinition): void;
|
|
142
|
+
/**
|
|
143
|
+
* Loads snapshot if it exists, returns null otherwise
|
|
144
|
+
*/
|
|
145
|
+
loadSnapshotIfExists(): SchemaSnapshot | null;
|
|
146
|
+
/**
|
|
147
|
+
* Checks if a snapshot exists
|
|
148
|
+
*/
|
|
149
|
+
snapshotExists(): boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Converts a PocketBase migration to a snapshot
|
|
152
|
+
*/
|
|
153
|
+
convertPocketBaseMigration(content: string): SchemaSnapshot;
|
|
154
|
+
/**
|
|
155
|
+
* Gets the snapshot file path
|
|
156
|
+
*/
|
|
157
|
+
getSnapshotPath(): string;
|
|
158
|
+
/**
|
|
159
|
+
* Validates a snapshot
|
|
160
|
+
*/
|
|
161
|
+
validateSnapshot(snapshot: SchemaSnapshot): {
|
|
162
|
+
valid: boolean;
|
|
163
|
+
issues: string[];
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export { type SnapshotConfig, SnapshotManager, convertPocketBaseMigration, findLatestSnapshot, getSnapshotPath, getSnapshotVersion, loadBaseMigration, loadSnapshot, loadSnapshotIfExists, mergeSnapshots, saveSnapshot, snapshotExists, validateSnapshot };
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { a as SchemaSnapshot, S as SchemaDefinition } from '../types-z1Dkjg8m.js';
|
|
2
|
+
import '../permissions-ZHafVSIx.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Snapshot Manager component
|
|
6
|
+
* Handles saving and loading schema snapshots
|
|
7
|
+
*
|
|
8
|
+
* This module provides a standalone, configurable snapshot manager that can be used
|
|
9
|
+
* by consumer projects to manage schema snapshots and convert PocketBase migrations.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Configuration for snapshot operations
|
|
14
|
+
*/
|
|
15
|
+
interface SnapshotConfig {
|
|
16
|
+
/**
|
|
17
|
+
* Path to the snapshot file
|
|
18
|
+
* Can be absolute or relative to workspaceRoot
|
|
19
|
+
*/
|
|
20
|
+
snapshotPath?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Workspace root directory for resolving relative paths
|
|
23
|
+
* Defaults to process.cwd()
|
|
24
|
+
*/
|
|
25
|
+
workspaceRoot?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Path to the migrations directory for finding PocketBase snapshots
|
|
28
|
+
*/
|
|
29
|
+
migrationsPath?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to auto-migrate old snapshot formats
|
|
32
|
+
* Defaults to true
|
|
33
|
+
*/
|
|
34
|
+
autoMigrate?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Custom snapshot version for testing
|
|
37
|
+
*/
|
|
38
|
+
version?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Gets the snapshot file path from configuration
|
|
42
|
+
*
|
|
43
|
+
* @param config - Snapshot configuration
|
|
44
|
+
* @returns Absolute path to the snapshot file
|
|
45
|
+
*/
|
|
46
|
+
declare function getSnapshotPath(config?: SnapshotConfig): string;
|
|
47
|
+
/**
|
|
48
|
+
* Checks if snapshot file exists
|
|
49
|
+
*
|
|
50
|
+
* @param config - Snapshot configuration
|
|
51
|
+
* @returns True if snapshot file exists
|
|
52
|
+
*/
|
|
53
|
+
declare function snapshotExists(config?: SnapshotConfig): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Saves schema snapshot to file
|
|
56
|
+
* Serializes SchemaDefinition to JSON with version and timestamp metadata
|
|
57
|
+
* Writes with pretty printing for readability
|
|
58
|
+
*
|
|
59
|
+
* @param schema - Schema definition to save
|
|
60
|
+
* @param config - Snapshot configuration
|
|
61
|
+
*/
|
|
62
|
+
declare function saveSnapshot(schema: SchemaDefinition, config?: SnapshotConfig): void;
|
|
63
|
+
/**
|
|
64
|
+
* Loads schema snapshot from file
|
|
65
|
+
* Reads snapshot file, parses JSON, validates format, and handles migrations
|
|
66
|
+
*
|
|
67
|
+
* @param config - Snapshot configuration
|
|
68
|
+
* @returns SchemaSnapshot object
|
|
69
|
+
* @throws Error if snapshot file doesn't exist or is invalid
|
|
70
|
+
*/
|
|
71
|
+
declare function loadSnapshot(config?: SnapshotConfig): SchemaSnapshot;
|
|
72
|
+
/**
|
|
73
|
+
* Merges base schema with custom snapshot
|
|
74
|
+
* Base schema collections are preserved, custom collections are added
|
|
75
|
+
* Custom collections override base collections if they have the same name
|
|
76
|
+
*
|
|
77
|
+
* @param baseSnapshot - PocketBase base schema
|
|
78
|
+
* @param customSnapshot - User's custom schema snapshot (may be null)
|
|
79
|
+
* @returns Merged SchemaSnapshot
|
|
80
|
+
*/
|
|
81
|
+
declare function mergeSnapshots(baseSnapshot: SchemaSnapshot, customSnapshot: SchemaSnapshot | null): SchemaSnapshot;
|
|
82
|
+
/**
|
|
83
|
+
* Finds the most recent snapshot file in the migrations directory
|
|
84
|
+
* Identifies snapshot files by naming pattern (e.g., *_collections_snapshot.js)
|
|
85
|
+
*
|
|
86
|
+
* @param migrationsPath - Path to pb_migrations directory
|
|
87
|
+
* @returns Path to most recent snapshot file or null if none exist
|
|
88
|
+
*/
|
|
89
|
+
declare function findLatestSnapshot(migrationsPath: string): string | null;
|
|
90
|
+
/**
|
|
91
|
+
* Loads snapshot if it exists, returns null for first run
|
|
92
|
+
* Convenience method that handles missing snapshot gracefully
|
|
93
|
+
* Finds the most recent snapshot file from migrations directory
|
|
94
|
+
*
|
|
95
|
+
* @param config - Snapshot configuration (must include migrationsPath)
|
|
96
|
+
* @returns SchemaSnapshot object or null if snapshot doesn't exist
|
|
97
|
+
*/
|
|
98
|
+
declare function loadSnapshotIfExists(config?: SnapshotConfig): SchemaSnapshot | null;
|
|
99
|
+
/**
|
|
100
|
+
* Converts PocketBase migration format to SchemaSnapshot
|
|
101
|
+
* Extracts the snapshot array from the migration file content
|
|
102
|
+
*
|
|
103
|
+
* @param migrationContent - Raw migration file content
|
|
104
|
+
* @returns SchemaSnapshot with collections map
|
|
105
|
+
*/
|
|
106
|
+
declare function convertPocketBaseMigration(migrationContent: string): SchemaSnapshot;
|
|
107
|
+
/**
|
|
108
|
+
* Loads the base PocketBase schema from the initial migration file
|
|
109
|
+
*
|
|
110
|
+
* @param migrationPath - Path to pocketbase/pb_migrations/000000000_collections_snapshot.js
|
|
111
|
+
* @returns SchemaSnapshot representing PocketBase's initial state
|
|
112
|
+
* @throws SnapshotError if file not found or invalid format
|
|
113
|
+
*/
|
|
114
|
+
declare function loadBaseMigration(migrationPath: string): SchemaSnapshot;
|
|
115
|
+
/**
|
|
116
|
+
* Gets the current snapshot version
|
|
117
|
+
*/
|
|
118
|
+
declare function getSnapshotVersion(): string;
|
|
119
|
+
/**
|
|
120
|
+
* Validates a snapshot against the current version
|
|
121
|
+
* Returns validation result with any issues found
|
|
122
|
+
*/
|
|
123
|
+
declare function validateSnapshot(snapshot: SchemaSnapshot): {
|
|
124
|
+
valid: boolean;
|
|
125
|
+
issues: string[];
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* SnapshotManager class for object-oriented usage
|
|
129
|
+
* Provides a stateful interface for snapshot management
|
|
130
|
+
*/
|
|
131
|
+
declare class SnapshotManager {
|
|
132
|
+
private config;
|
|
133
|
+
constructor(config?: SnapshotConfig);
|
|
134
|
+
/**
|
|
135
|
+
* Loads the current snapshot
|
|
136
|
+
*/
|
|
137
|
+
loadSnapshot(): SchemaSnapshot;
|
|
138
|
+
/**
|
|
139
|
+
* Saves a schema as a snapshot
|
|
140
|
+
*/
|
|
141
|
+
saveSnapshot(schema: SchemaDefinition): void;
|
|
142
|
+
/**
|
|
143
|
+
* Loads snapshot if it exists, returns null otherwise
|
|
144
|
+
*/
|
|
145
|
+
loadSnapshotIfExists(): SchemaSnapshot | null;
|
|
146
|
+
/**
|
|
147
|
+
* Checks if a snapshot exists
|
|
148
|
+
*/
|
|
149
|
+
snapshotExists(): boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Converts a PocketBase migration to a snapshot
|
|
152
|
+
*/
|
|
153
|
+
convertPocketBaseMigration(content: string): SchemaSnapshot;
|
|
154
|
+
/**
|
|
155
|
+
* Gets the snapshot file path
|
|
156
|
+
*/
|
|
157
|
+
getSnapshotPath(): string;
|
|
158
|
+
/**
|
|
159
|
+
* Validates a snapshot
|
|
160
|
+
*/
|
|
161
|
+
validateSnapshot(snapshot: SchemaSnapshot): {
|
|
162
|
+
valid: boolean;
|
|
163
|
+
issues: string[];
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export { type SnapshotConfig, SnapshotManager, convertPocketBaseMigration, findLatestSnapshot, getSnapshotPath, getSnapshotVersion, loadBaseMigration, loadSnapshot, loadSnapshotIfExists, mergeSnapshots, saveSnapshot, snapshotExists, validateSnapshot };
|