{"version":3,"sources":["../../../node_modules/tsup/assets/cjs_shims.js","../../src/migration/errors.ts","../../src/migration/analyzer/config.ts","../../src/schema/base.ts","../../src/schema/fields.ts","../../src/utils/permission-templates.ts","../../src/migration/utils/collection-id-generator.ts","../../src/migration/rule-validator.ts","../../src/migration/permission-analyzer.ts","../../src/migration/utils/type-mapper.ts","../../src/schema/view.ts","../../src/migration/analyzer/extractors.ts","../../src/migration/generator/utils.ts","../../src/migration/analyzer/converter.ts","../../src/migration/analyzer/loader.ts","../../src/migration/analyzer/index.ts","../../src/migration/engine/fields.ts","../../src/migration/engine/fields-list.ts","../../src/migration/engine/collection.ts","../../src/migration/engine/expression.ts","../../src/migration/engine/dbx.ts","../../src/migration/engine/records.ts","../../src/migration/engine/data-api.ts","../../src/migration/engine/app.ts","../../src/migration/engine/unmarshal.ts","../../src/migration/engine/globals.ts","../../src/migration/engine/runner.ts","../../src/migration/engine/applied-migrations.ts","../../src/migration/engine/migration-plan.ts","../../src/migration/pocketbase-converter.ts","../../src/migration/engine/store.ts","../../src/migration/engine/replayer.ts","../../src/migration/snapshot.ts","../../src/migration/diff/config.ts","../../src/migration/diff/utils.ts","../../src/migration/diff/fields.ts","../../src/migration/diff/indexes.ts","../../src/migration/diff/rules.ts","../../src/migration/diff/collections.ts","../../src/migration/diff/filter.ts","../../src/migration/diff/summary.ts","../../src/migration/diff/index.ts","../../src/migration/validation.ts","../../src/migration/generator/config.ts","../../src/migration/generator/file-writer.ts","../../src/migration/generator/fields.ts","../../src/migration/generator/indexes.ts","../../src/migration/generator/rules.ts","../../src/migration/generator/collections.ts","../../src/migration/generator/migrator.ts","../../src/migration/utils/dependency-sorter.ts","../../src/migration/generator/operations.ts","../../src/migration/generator/index.ts","../../src/migration/engine/goja-lint.ts","../../src/migration/engine/state-compare.ts","../../src/migration/engine/verify.ts","../../src/cli/utils/config.ts","../../src/cli/utils/logger.ts","../../src/cli/commands/generate.ts","../../src/type-gen/utils.ts","../../src/type-gen/generator.ts","../../src/cli/commands/generate-types.ts","../../src/cli/commands/lint.ts","../../src/cli/commands/status.ts","../../src/cli/migrate.ts"],"names":["path","z","randomBytes","createHash","expression","required","options","fieldDef","relationMetadata","fs","path2","fs2","negated","fs3","vm","path3","fs4","fs5","path4","snapshot","extractFieldOptions","fs6","DEFAULT_CONFIG","mergeConfig","compare","path5","fs7","hasChanges","fs8","path6","program","fs9","acorn","compareIndexes","path7","fs10","ora","chalk","path8","Command","ZodIntersection","ZodTuple","ZodMap","ZodSet","path9","fs11","path10","hasDestructiveChanges","__filename","fileURLToPath","dirname","join","readFileSync"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAM,gBAAA,GAAmB,MACvB,OAAO,QAAA,KAAa,WAAA,GAChB,IAAI,GAAA,CAAI,CAAA,KAAA,EAAQ,UAAU,CAAA,CAAE,CAAA,CAAE,IAAA,GAC7B,QAAA,CAAS,aAAA,IAAiB,QAAA,CAAS,aAAA,CAAc,OAAA,CAAQ,WAAA,EAAY,KAAM,QAAA,GAC1E,QAAA,CAAS,aAAA,CAAc,GAAA,GACvB,IAAI,GAAA,CAAI,SAAA,EAAW,QAAA,CAAS,OAAO,CAAA,CAAE,IAAA;AAEtC,IAAM,gCAAgC,gBAAA,EAAiB;;;ACJvD,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;AAMO,IAAM,kBAAA,GAAN,MAAM,mBAAA,SAA2B,cAAA,CAAe;AAAA,EACrC,QAAA;AAAA,EACA,aAAA;AAAA,EAEhB,WAAA,CAAY,OAAA,EAAiB,QAAA,EAAmB,aAAA,EAAuB;AACrE,IAAA,KA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,EAO5BA,sBAAAA,CAAM,IAAA,CAAK,gBAAgB,CAAC;AAAA;AAAA;AAG9B,CAAA;AAGA,OAAA,CAAQ,YAAA,CAAa,CAAC,GAAA,KAAQ;AAM5B,EAAA,MAAM,MAAA,GAAS,GAAA;AAGf,EAAA,IAAI,MAAA,EAAQ,IAAA,KAAS,gBAAA,IAAoB,MAAA,EAAQ,SAAS,yBAAA,EAA2B;AACnF,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACA,EAAA,IAAI,MAAA,EAAQ,SAAS,mBAAA,EAAqB;AACxC,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AAGA,EAAA,IAAI,OAAO,MAAA,EAAQ,QAAA,KAAa,QAAA,EAAU;AACxC,IAAA,OAAA,CAAQ,IAAA,CAAK,OAAO,QAAQ,CAAA;AAAA,EAC9B;AAEA,EAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAChB,CAAC,CAAA;AAGD,IAAI,OAAA,CAAQ,IAAA,CAAK,MAAA,KAAW,CAAA,EAAG;AAC7B,EAAA,aAAA,EAAc;AACd,EAAA,OAAA,CAAQ,IAAA,EAAK;AACf;AAGA,OAAA,CAAQ,KAAA,CAAM,QAAQ,IAAI,CAAA","file":"migrate.cjs","sourcesContent":["// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () => \n  typeof document === \"undefined\" \n    ? new URL(`file:${__filename}`).href \n    : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') \n      ? document.currentScript.src \n      : new URL(\"main.js\", document.baseURI).href;\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","/**\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 the execution engine fails to run a migration file\n * Carries the file path and the phase that failed so the user can pinpoint\n * (and fix or exclude) the offending migration\n */\nexport class MigrationExecutionError extends MigrationError {\n  public readonly filePath?: string;\n  public readonly phase?: \"evaluate\" | \"up\" | \"down\";\n  public readonly originalError?: Error;\n\n  constructor(message: string, filePath?: string, phase?: \"evaluate\" | \"up\" | \"down\", originalError?: Error) {\n    super(message);\n    this.name = \"MigrationExecutionError\";\n    this.filePath = filePath;\n    this.phase = phase;\n    this.originalError = originalError;\n    Object.setPrototypeOf(this, MigrationExecutionError.prototype);\n  }\n\n  /**\n   * Creates a formatted error message with file path and phase 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.phase) {\n      parts.push(`\\nPhase: ${this.phase}`);\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","import * as path from \"path\";\n\n/**\n * Configuration options for schema discovery and parsing\n */\nexport interface SchemaAnalyzerConfig {\n  /**\n   * Directory containing schema files (source or compiled)\n   * Can be absolute or relative to workspaceRoot\n   */\n  schemaDir: string;\n\n  /**\n   * Workspace root directory for resolving relative paths\n   * Defaults to process.cwd()\n   */\n  workspaceRoot?: string;\n\n  /**\n   * File patterns to exclude from schema discovery\n   * Defaults to ['base.ts', 'index.ts', 'permissions.ts', 'permission-templates.ts']\n   */\n  excludePatterns?: string[];\n\n  /**\n   * File extensions to include in schema discovery\n   * Defaults to ['.ts', '.js']\n   */\n  includeExtensions?: string[];\n\n  /**\n   * Whether to use compiled JavaScript files instead of TypeScript source\n   * When true, looks for .js files; when false, looks for .ts files\n   * Defaults to true (use compiled files for dynamic import)\n   */\n  useCompiledFiles?: boolean;\n\n  /**\n   * Custom path transformation function for converting source paths to import paths\n   * Useful for monorepo setups where source and dist directories differ\n   * If not provided, uses the schemaDir directly\n   */\n  pathTransformer?: (sourcePath: string) => string;\n}\n\n/**\n * Default configuration values\n */\nexport const DEFAULT_CONFIG: Required<Omit<SchemaAnalyzerConfig, \"schemaDir\" | \"pathTransformer\">> = {\n  workspaceRoot: process.cwd(),\n  excludePatterns: [\n    \"base.ts\",\n    \"index.ts\",\n    \"permissions.ts\",\n    \"permission-templates.ts\",\n    \"base.js\",\n    \"index.js\",\n    \"permissions.js\",\n    \"permission-templates.js\",\n  ],\n  includeExtensions: [\".ts\", \".js\"],\n  useCompiledFiles: true,\n};\n\n/**\n * Merges user config with defaults\n */\nexport function mergeConfig(\n  config: SchemaAnalyzerConfig\n): Required<Omit<SchemaAnalyzerConfig, \"pathTransformer\">> & { pathTransformer?: (sourcePath: string) => string } {\n  return {\n    ...DEFAULT_CONFIG,\n    ...config,\n    excludePatterns: config.excludePatterns || DEFAULT_CONFIG.excludePatterns,\n    includeExtensions: config.includeExtensions || DEFAULT_CONFIG.includeExtensions,\n  };\n}\n\n/**\n * Resolves the schema directory path\n */\nexport function resolveSchemaDir(config: SchemaAnalyzerConfig): string {\n  const workspaceRoot = config.workspaceRoot || process.cwd();\n\n  if (path.isAbsolute(config.schemaDir)) {\n    return config.schemaDir;\n  }\n\n  return path.join(workspaceRoot, config.schemaDir);\n}\n","import { z } from \"zod\";\nimport type { PermissionSchema, PermissionTemplateConfig } from \"../utils/permissions\";\n\n/**\n * Base schema fields that PocketBase automatically adds to all records\n * These fields are managed by PocketBase and should not be set manually\n */\nexport const baseSchema = {\n  id: z.string().describe(\"unique id\"),\n  collectionId: z.string().describe(\"collection id\"),\n  collectionName: z.string().describe(\"collection name\"),\n  expand: z.record(z.string(), z.any()).describe(\"expandable fields\"),\n  created: z.string().describe(\"creation timestamp\"),\n  updated: z.string().describe(\"last update timestamp\"),\n};\n\n// ============================================================================\n// Common PocketBase Field Type Patterns\n// ============================================================================\n// Note: Field type helpers are now exported from ./fields.ts with PascalCase names\n// (e.g., TextField, EmailField, JSONField, etc.) to ensure consistent naming.\n\n// ============================================================================\n// Relation Field Helpers - Explicit Relationship Definitions\n// ============================================================================\n\n/**\n * Relation field configuration options\n */\nexport interface RelationConfig {\n  /**\n   * Target collection name (e.g., 'users', 'posts', 'tags')\n   * This is the PocketBase collection that the relation points to\n   */\n  collection: string;\n\n  /**\n   * Whether to cascade delete related records when this record is deleted\n   * @default false\n   */\n  cascadeDelete?: boolean;\n\n  /**\n   * Fields to display in the admin UI\n   */\n  displayFields?: string[] | null;\n}\n\n/**\n * Multiple relation field configuration options\n */\nexport interface RelationsConfig extends RelationConfig {\n  /**\n   * Minimum number of relations required\n   * @default 0\n   */\n  minSelect?: number;\n\n  /**\n   * Maximum number of relations allowed\n   * @default 999\n   */\n  maxSelect?: number;\n}\n\n/**\n * Internal marker for relation metadata\n * Used by the analyzer to detect explicit relation definitions\n */\nconst RELATION_METADATA_KEY = \"__pocketbase_relation__\";\n\n/**\n * Creates a single relation field schema with explicit collection target\n * Maps to PocketBase 'relation' field type with maxSelect=1\n *\n * This is the recommended way to define relations - it's explicit and doesn't\n * rely on naming conventions.\n *\n * @param config - Relation configuration with target collection\n * @returns Zod string schema with relation metadata\n *\n * @example\n * // Single relation to users collection\n * const PostSchema = z.object({\n *   title: z.string(),\n *   author: RelationField({ collection: 'users' }),\n * });\n *\n * @example\n * // Relation with cascade delete\n * const CommentSchema = z.object({\n *   content: z.string(),\n *   post: RelationField({ collection: 'posts', cascadeDelete: true }),\n * });\n */\nexport function RelationField(config: RelationConfig) {\n  const metadata = {\n    [RELATION_METADATA_KEY]: {\n      type: \"single\",\n      collection: config.collection,\n      cascadeDelete: config.cascadeDelete ?? false,\n      maxSelect: 1,\n      minSelect: 0,\n      displayFields: config.displayFields ?? null,\n    },\n  };\n\n  return z.string().describe(JSON.stringify(metadata));\n}\n\n/**\n * Creates a multiple relation field schema with explicit collection target\n * Maps to PocketBase 'relation' field type with maxSelect>1\n *\n * This is the recommended way to define multi-relations - it's explicit and\n * doesn't rely on naming conventions.\n *\n * @param config - Relations configuration with target collection and limits\n * @returns Zod array of strings schema with relation metadata\n *\n * @example\n * // Multiple relations to tags collection\n * const PostSchema = z.object({\n *   title: z.string(),\n *   tags: RelationsField({ collection: 'tags' }),\n * });\n *\n * @example\n * // Relations with min/max constraints\n * const ProjectSchema = z.object({\n *   title: z.string(),\n *   collaborators: RelationsField({\n *     collection: 'users',\n *     minSelect: 1,\n *     maxSelect: 10,\n *   }),\n * });\n */\nexport function RelationsField(config: RelationsConfig) {\n  const metadata = {\n    [RELATION_METADATA_KEY]: {\n      type: \"multiple\",\n      collection: config.collection,\n      cascadeDelete: config.cascadeDelete ?? false,\n      maxSelect: config.maxSelect ?? 999,\n      minSelect: config.minSelect ?? 0,\n      displayFields: config.displayFields ?? null,\n    },\n  };\n\n  let schema = z.array(z.string());\n\n  // Apply array constraints for Zod validation\n  if (config.minSelect !== undefined) {\n    schema = schema.min(config.minSelect);\n  }\n  if (config.maxSelect !== undefined) {\n    schema = schema.max(config.maxSelect);\n  }\n\n  return schema.describe(JSON.stringify(metadata));\n}\n\n/**\n * Extracts relation metadata from a Zod type's description\n * Used internally by the analyzer to detect explicit relation definitions\n *\n * @param description - The Zod type's description string\n * @returns Relation metadata if present, null otherwise\n */\nexport function extractRelationMetadata(description: string | undefined): {\n  type: \"single\" | \"multiple\";\n  collection: string;\n  cascadeDelete: boolean;\n  maxSelect: number;\n  minSelect: number;\n  displayFields?: string[] | null;\n} | null {\n  if (!description) return null;\n\n  try {\n    const parsed = JSON.parse(description);\n    if (parsed[RELATION_METADATA_KEY]) {\n      return parsed[RELATION_METADATA_KEY];\n    }\n  } catch {\n    // Not JSON, ignore\n  }\n\n  return null;\n}\n\n/**\n * Configuration options for defining a collection\n */\nexport interface CollectionConfig {\n  /**\n   * The name of the PocketBase collection\n   * This will be used when generating migrations\n   */\n  collectionName: string;\n\n  /**\n   * The Zod schema definition for the collection\n   */\n  schema: z.ZodObject<any>;\n\n  /**\n   * Optional permission configuration\n   * Can be a template-based config or custom permission rules\n   */\n  permissions?: PermissionTemplateConfig | PermissionSchema;\n\n  /**\n   * Optional array of index SQL statements\n   * Example: ['CREATE UNIQUE INDEX idx_users_email ON users (email)']\n   */\n  indexes?: string[];\n\n  /**\n   * Optional collection type\n   * - \"base\": Standard collection (default)\n   * - \"auth\": Authentication collection with system auth fields\n   * - \"view\": Read-only collection backed by a SQL query (requires viewQuery)\n   *\n   * Defaults to \"base\". Auth collections must set type: \"auth\" explicitly.\n   *\n   * Prefer defineView() over type: \"view\" - it enforces the constraints\n   * PocketBase places on view collections at compile time.\n   */\n  type?: \"base\" | \"auth\" | \"view\";\n\n  /**\n   * SQL SELECT statement backing a view collection\n   *\n   * Only valid when type is \"view\", where it is required. PocketBase derives\n   * the collection's fields by running this query, so the Zod schema is used\n   * for TypeScript types only.\n   */\n  viewQuery?: string;\n}\n\n/**\n * High-level wrapper for defining a PocketBase collection with all metadata\n *\n * This is the recommended way to define collections as it provides a single\n * entry point for collection name, schema, permissions, indexes, and future features.\n *\n * @param config - Collection configuration object\n * @returns The schema with all metadata attached\n *\n * @example\n * // Recommended: Use default export for clarity\n * const PostCollection = defineCollection({\n *   collectionName: \"posts\",\n *   schema: z.object({\n *     title: z.string(),\n *     content: z.string(),\n *     author: RelationField({ collection: \"users\" }),\n *   }),\n *   permissions: {\n *     template: \"owner-only\",\n *     ownerField: \"author\",\n *   },\n * });\n * export default PostCollection;\n *\n * @example\n * // Also supported: Named export (backward compatible)\n * export const PostCollection = defineCollection({\n *   collectionName: \"posts\",\n *   schema: z.object({\n *     title: z.string(),\n *     content: z.string(),\n *     author: RelationField({ collection: \"users\" }),\n *   }),\n *   permissions: {\n *     template: \"owner-only\",\n *     ownerField: \"author\",\n *   },\n * });\n *\n * @example\n * // Collection with permissions and indexes\n * export const UserSchema = defineCollection({\n *   collectionName: \"users\",\n *   schema: z.object({\n *     name: z.string(),\n *     email: z.string().email(),\n *   }),\n *   permissions: {\n *     listRule: \"id = @request.auth.id\",\n *     viewRule: \"id = @request.auth.id\",\n *     createRule: \"\",\n *     updateRule: \"id = @request.auth.id\",\n *     deleteRule: \"id = @request.auth.id\",\n *   },\n *   indexes: [\n *     \"CREATE UNIQUE INDEX idx_users_email ON users (email)\",\n *   ],\n * });\n *\n * @example\n * // Collection with template and custom rule overrides\n * export const ProjectSchema = defineCollection({\n *   collectionName: \"projects\",\n *   schema: z.object({\n *     title: z.string(),\n *     owner: RelationField({ collection: \"users\" }),\n *   }),\n *   permissions: {\n *     template: \"owner-only\",\n *     ownerField: \"owner\",\n *     customRules: {\n *       listRule: '@request.auth.id != \"\"',\n *     },\n *   },\n * });\n */\nexport function defineCollection(config: CollectionConfig): z.ZodObject<any> {\n  const { collectionName, schema, permissions, indexes, type, viewQuery } = config;\n\n  // Build metadata object\n  const metadata: any = {\n    collectionName,\n  };\n\n  // Add type if provided\n  if (type) {\n    metadata.type = type;\n  }\n\n  // Add the SQL query backing a view collection\n  if (viewQuery !== undefined) {\n    metadata.viewQuery = viewQuery;\n  }\n\n  // Add permissions if provided\n  if (permissions) {\n    metadata.permissions = permissions;\n  }\n\n  // Add indexes if provided\n  if (indexes) {\n    metadata.indexes = indexes;\n  }\n\n  // Attach all metadata to schema using Zod's describe() method\n  return schema.describe(JSON.stringify(metadata)) as z.ZodObject<any>;\n}\n","import { z } from \"zod\";\n\n// ============================================================================\n// Field Metadata System\n// ============================================================================\n\n/**\n * Internal marker for field metadata\n * Used by the migration generator to detect explicit field type definitions\n */\nexport const FIELD_METADATA_KEY = \"__pocketbase_field__\";\n\n/**\n * PocketBase field types\n */\nexport type PocketBaseFieldType =\n  | \"text\"\n  | \"email\"\n  | \"url\"\n  | \"editor\"\n  | \"number\"\n  | \"bool\"\n  | \"date\"\n  | \"autodate\"\n  | \"select\"\n  | \"relation\"\n  | \"file\"\n  | \"json\"\n  | \"geoPoint\"\n  | \"password\";\n\n/**\n * Field metadata structure embedded in Zod schema descriptions\n */\nexport interface FieldMetadata {\n  type: PocketBaseFieldType;\n  options?: Record<string, any>;\n}\n\n/**\n * Extracts field metadata from a Zod type's description\n * Used by the migration generator to detect explicit field type definitions\n *\n * @param description - The Zod type's description string\n * @returns Field metadata if present, null otherwise\n *\n * @example\n * const schema = TextField({ min: 1, max: 100 });\n * const metadata = extractFieldMetadata(schema.description);\n * // Returns: { type: \"text\", options: { min: 1, max: 100 } }\n */\nexport function extractFieldMetadata(description: string | undefined): FieldMetadata | null {\n  if (!description) return null;\n\n  try {\n    const parsed = JSON.parse(description);\n    if (parsed[FIELD_METADATA_KEY]) {\n      return parsed[FIELD_METADATA_KEY];\n    }\n  } catch {\n    // Not JSON, ignore\n  }\n\n  return null;\n}\n\n// ============================================================================\n// Field Options Interfaces\n// ============================================================================\n\n/**\n * Text field configuration options\n */\nexport interface TextFieldOptions {\n  /**\n   * Minimum length constraint\n   */\n  min?: number;\n\n  /**\n   * Maximum length constraint\n   */\n  max?: number;\n\n  /**\n   * Pattern constraint (regex)\n   */\n  pattern?: RegExp | string;\n\n  /**\n   * Auto-generate pattern for automatic value generation\n   * Example: \"[A-Z]{3}-[0-9]{6}\" generates values like \"ABC-123456\"\n   */\n  autogeneratePattern?: string;\n}\n\n/**\n * Number field configuration options\n */\nexport interface NumberFieldOptions {\n  /**\n   * Minimum value constraint\n   */\n  min?: number;\n\n  /**\n   * Maximum value constraint\n   */\n  max?: number;\n\n  /**\n   * Whether to disallow decimal values (integers only)\n   */\n  noDecimal?: boolean;\n\n  /**\n   * Whether the field is required\n   * @default false\n   *\n   * Note: In PocketBase, `required: true` for number fields means the value must be non-zero.\n   * If you want to allow zero values (e.g., for progress: 0-100), keep this as `false`.\n   * Set to `true` only if you want to enforce non-zero values.\n   */\n  required?: boolean;\n}\n\n/**\n * Date field configuration options\n */\nexport interface DateFieldOptions {\n  /**\n   * Minimum date constraint\n   */\n  min?: Date | string;\n\n  /**\n   * Maximum date constraint\n   */\n  max?: Date | string;\n}\n\n/**\n * Autodate field configuration options\n */\nexport interface AutodateFieldOptions {\n  /**\n   * Set date automatically on record creation\n   * @default false\n   */\n  onCreate?: boolean;\n\n  /**\n   * Update date automatically on record update\n   * @default false\n   */\n  onUpdate?: boolean;\n}\n\n/**\n * Select field configuration options\n */\nexport interface SelectFieldOptions {\n  /**\n   * Maximum number of selections allowed\n   * If > 1, enables multiple selection\n   * @default 1\n   */\n  maxSelect?: number;\n}\n\nexport type EnumFromArray<T extends readonly [string, ...string[]]> = z.ZodEnum<z.core.util.ToEnum<T[number]>>;\n\n/**\n * Human-friendly byte size input.\n *\n * - Use a number for raw bytes (e.g. `5242880`)\n * - Use a string with unit suffix for kibibytes/mebibytes/gibibytes (e.g. `\"5M\"`, `\"1G\"`)\n *\n * Supported suffixes: `K`, `M`, `G` (case-insensitive).\n */\nexport type ByteSize = number | `${number}${\"K\" | \"M\" | \"G\" | \"k\" | \"m\" | \"g\"}`;\n\n/**\n * File field configuration options\n */\nexport interface FileFieldOptions {\n  /**\n   * Allowed MIME types\n   * Example: [\"image/*\", \"application/pdf\"]\n   */\n  mimeTypes?: string[];\n\n  /**\n   * Maximum file size.\n   *\n   * - Provide a number for raw bytes\n   * - Or use a string with `K`, `M`, `G` suffix (case-insensitive)\n   *\n   * Max allowed is `8G`.\n   *\n   * @example\n   * maxSize: 5242880\n   * maxSize: \"5M\"\n   * maxSize: \"1G\"\n   */\n  maxSize?: ByteSize;\n\n  /**\n   * Thumbnail sizes to generate\n   * Example: [\"100x100\", \"200x200\"]\n   * Set to null to explicitly disable thumbnails\n   */\n  thumbs?: string[];\n\n  /**\n   * Whether the file is protected (requires auth to access)\n   * @default false\n   */\n  protected?: boolean;\n}\n\n/**\n * Multiple files field configuration options\n */\nexport interface FilesFieldOptions extends FileFieldOptions {\n  /**\n   * Minimum number of files required\n   */\n  minSelect?: number;\n\n  /**\n   * Maximum number of files allowed\n   */\n  maxSelect?: number;\n}\n\n/**\n * JSON field configuration options\n */\nexport interface JSONFieldOptions {\n  /**\n   * Maximum size of the serialized JSON value.\n   *\n   * - Provide a number for raw bytes\n   * - Or use a string with `K`, `M`, `G` suffix (case-insensitive)\n   *\n   * PocketBase applies a **1MB** default when this is unset (or `0`), so a field\n   * holding anything larger has to declare its own limit. The maximum PocketBase\n   * accepts is 2^53-1 bytes.\n   *\n   * @example\n   * maxSize: 5242880\n   * maxSize: \"5M\"\n   * maxSize: \"200K\"\n   */\n  maxSize?: ByteSize;\n}\n\nconst MAX_FILE_SIZE_BYTES = 8 * 1024 * 1024 * 1024; // 8G\n\n/**\n * PocketBase validates a json field's `maxSize` against `maxSafeJSONInt`\n * (2^53-1) — the field is stored as a JS-safe integer, not a file size, so the\n * file ceiling does not apply here.\n */\nconst MAX_JSON_SIZE_BYTES = Number.MAX_SAFE_INTEGER; // 2^53 - 1\n\nfunction parseByteSizeToBytes(\n  value: ByteSize,\n  context: string,\n  limit: { bytes: number; label: string } = { bytes: MAX_FILE_SIZE_BYTES, label: \"8G\" }\n): number {\n  let bytes: number;\n\n  if (typeof value === \"number\") {\n    if (!Number.isFinite(value)) {\n      throw new Error(`${context}: maxSize must be a finite number of bytes`);\n    }\n    bytes = Math.round(value);\n  } else {\n    const trimmed = value.trim();\n    const match = /^(\\d+(?:\\.\\d+)?)\\s*([KMG])$/i.exec(trimmed);\n    if (!match) {\n      throw new Error(`${context}: maxSize string must be like \"10K\", \"5M\", or \"1G\" (case-insensitive)`);\n    }\n\n    const amount = Number(match[1]);\n    const unit = match[2].toUpperCase() as \"K\" | \"M\" | \"G\";\n\n    if (!Number.isFinite(amount)) {\n      throw new Error(`${context}: maxSize must be a valid number`);\n    }\n\n    const multiplier = unit === \"K\" ? 1024 : unit === \"M\" ? 1024 * 1024 : 1024 * 1024 * 1024;\n    bytes = Math.round(amount * multiplier);\n  }\n\n  if (bytes < 0) {\n    throw new Error(`${context}: maxSize must be >= 0`);\n  }\n\n  if (bytes > limit.bytes) {\n    throw new Error(`${context}: maxSize cannot exceed ${limit.label} (${limit.bytes} bytes)`);\n  }\n\n  return bytes;\n}\n\nfunction normalizeFileFieldOptions(\n  options: FileFieldOptions | undefined,\n  context: string\n): FileFieldOptions | undefined {\n  if (!options) return options;\n  if (options.maxSize === undefined) return options;\n\n  return {\n    ...options,\n    // PocketBase expects bytes; normalize any human-friendly inputs to bytes here.\n    maxSize: parseByteSizeToBytes(options.maxSize, context),\n  };\n}\n\nfunction normalizeJSONFieldOptions(\n  options: JSONFieldOptions | undefined,\n  context: string\n): JSONFieldOptions | undefined {\n  if (!options) return options;\n  if (options.maxSize === undefined) return options;\n\n  return {\n    ...options,\n    maxSize: parseByteSizeToBytes(options.maxSize, context, {\n      bytes: MAX_JSON_SIZE_BYTES,\n      label: \"2^53-1\",\n    }),\n  };\n}\n\n// ============================================================================\n// Field Helper Functions\n// ============================================================================\n\n/**\n * Creates a boolean field schema\n * Maps to PocketBase 'bool' field type\n *\n * @returns Zod boolean schema with PocketBase metadata\n *\n * @example\n * const ProductSchema = z.object({\n *   active: BoolField(),\n *   featured: BoolField().optional(),\n * });\n */\nexport function BoolField(): z.ZodBoolean {\n  const metadata = {\n    [FIELD_METADATA_KEY]: {\n      type: \"bool\" as const,\n    },\n  };\n\n  return z.boolean().describe(JSON.stringify(metadata));\n}\n\n/**\n * Creates a number field schema with optional constraints\n * Maps to PocketBase 'number' field type\n *\n * @param options - Optional constraints for the number field\n * @returns Zod number schema with PocketBase metadata\n *\n * @example\n * const ProductSchema = z.object({\n *   price: NumberField({ min: 0 }),\n *   quantity: NumberField({ min: 0, noDecimal: true }),\n *   rating: NumberField({ min: 0, max: 5 }),\n *   progress: NumberField({ min: 0, max: 100 }), // required defaults to false, allowing zero\n *   score: NumberField({ min: 1, max: 10, required: true }), // requires non-zero value\n * });\n *\n * @remarks\n * By default, number fields are not required (`required: false`), which allows zero values.\n * In PocketBase, `required: true` for number fields means the value must be non-zero.\n * If you set `min: 0` and want to allow zero, keep `required: false` (the default).\n */\nexport function NumberField(options?: NumberFieldOptions): z.ZodNumber {\n  // Validate options\n  if (options?.min !== undefined && options?.max !== undefined) {\n    if (options.min > options.max) {\n      throw new Error(\"NumberField: min cannot be greater than max\");\n    }\n  }\n\n  // Create base schema\n  let schema = z.number();\n\n  // Apply Zod validations\n  if (options?.min !== undefined) {\n    schema = schema.min(options.min);\n  }\n  if (options?.max !== undefined) {\n    schema = schema.max(options.max);\n  }\n\n  // Build metadata\n  const metadata = {\n    [FIELD_METADATA_KEY]: {\n      type: \"number\" as const,\n      options: options || {},\n    },\n  };\n\n  return schema.describe(JSON.stringify(metadata));\n}\n\n/**\n * Creates a text field schema with optional constraints\n * Maps to PocketBase 'text' field type\n *\n * @param options - Optional constraints for the text field\n * @returns Zod string schema with PocketBase metadata\n *\n * @example\n * const ProductSchema = z.object({\n *   name: TextField({ min: 1, max: 200 }),\n *   sku: TextField({ autogeneratePattern: \"[A-Z]{3}-[0-9]{6}\" }),\n *   description: TextField({ max: 1000 }),\n * });\n */\nexport function TextField(options?: TextFieldOptions): z.ZodString {\n  // Validate options\n  if (options?.min !== undefined && options?.max !== undefined) {\n    if (options.min > options.max) {\n      throw new Error(\"TextField: min cannot be greater than max\");\n    }\n  }\n\n  // Create base schema\n  let schema = z.string();\n\n  // Apply Zod validations\n  if (options?.min !== undefined) {\n    schema = schema.min(options.min);\n  }\n  if (options?.max !== undefined) {\n    schema = schema.max(options.max);\n  }\n  if (options?.pattern !== undefined) {\n    const pattern = options.pattern instanceof RegExp ? options.pattern : new RegExp(options.pattern);\n    schema = schema.regex(pattern);\n  }\n\n  // Build metadata\n  //\n  // The metadata travels as JSON in the description, and `JSON.stringify` turns\n  // a RegExp into `{}` — the pattern would be silently lost between here and\n  // the analyzer. PocketBase stores the pattern as a string anyway, so a RegExp\n  // is recorded as its source.\n  const metadata = {\n    [FIELD_METADATA_KEY]: {\n      type: \"text\" as const,\n      options: options\n        ? { ...options, ...(options.pattern instanceof RegExp ? { pattern: options.pattern.source } : {}) }\n        : {},\n    },\n  };\n\n  return schema.describe(JSON.stringify(metadata));\n}\n\n/**\n * Creates an email field schema\n * Maps to PocketBase 'email' field type\n *\n * @returns Zod string schema with email validation and PocketBase metadata\n *\n * @example\n * const UserSchema = z.object({\n *   email: EmailField(),\n *   alternateEmail: EmailField().optional(),\n * });\n */\nexport function EmailField(): z.ZodString {\n  const metadata = {\n    [FIELD_METADATA_KEY]: {\n      type: \"email\" as const,\n    },\n  };\n\n  return z.string().email().describe(JSON.stringify(metadata));\n}\n\n/**\n * Creates a URL field schema\n * Maps to PocketBase 'url' field type\n *\n * @returns Zod string schema with URL validation and PocketBase metadata\n *\n * @example\n * const ProductSchema = z.object({\n *   website: URLField(),\n *   documentation: URLField().optional(),\n * });\n */\nexport function URLField(): z.ZodString {\n  const metadata = {\n    [FIELD_METADATA_KEY]: {\n      type: \"url\" as const,\n    },\n  };\n\n  return z.string().url().describe(JSON.stringify(metadata));\n}\n\n/**\n * Creates a rich text editor field schema\n * Maps to PocketBase 'editor' field type\n *\n * @returns Zod string schema with PocketBase metadata\n *\n * @example\n * const PostSchema = z.object({\n *   content: EditorField(),\n *   summary: EditorField().optional(),\n * });\n */\nexport function EditorField(): z.ZodString {\n  const metadata = {\n    [FIELD_METADATA_KEY]: {\n      type: \"editor\" as const,\n    },\n  };\n\n  return z.string().describe(JSON.stringify(metadata));\n}\n\n/**\n * Creates a date field schema with optional constraints\n * Maps to PocketBase 'date' field type\n *\n * @param options - Optional date constraints\n * @returns Zod string schema with PocketBase metadata\n *\n * @example\n * const EventSchema = z.object({\n *   startDate: DateField(),\n *   endDate: DateField({ min: new Date('2024-01-01') }),\n *   releaseDate: DateField().optional(),\n * });\n */\nexport function DateField(options?: DateFieldOptions): z.ZodString {\n  // Validate options\n  if (options?.min !== undefined && options?.max !== undefined) {\n    const minDate = typeof options.min === \"string\" ? new Date(options.min) : options.min;\n    const maxDate = typeof options.max === \"string\" ? new Date(options.max) : options.max;\n    if (minDate > maxDate) {\n      throw new Error(\"DateField: min cannot be greater than max\");\n    }\n  }\n\n  // Create base schema\n  const schema = z.string();\n\n  // Build metadata\n  const metadata = {\n    [FIELD_METADATA_KEY]: {\n      type: \"date\" as const,\n      options: options || {},\n    },\n  };\n\n  return schema.describe(JSON.stringify(metadata));\n}\n\n/**\n * Creates an autodate field schema with automatic timestamp management\n * Maps to PocketBase 'autodate' field type\n *\n * @param options - Optional autodate configuration\n * @returns Zod string schema with PocketBase metadata\n *\n * @example\n * const PostSchema = z.object({\n *   createdAt: AutodateField({ onCreate: true }),\n *   updatedAt: AutodateField({ onUpdate: true }),\n *   publishedAt: AutodateField({ onCreate: true, onUpdate: false }),\n * });\n */\nexport function AutodateField(options?: AutodateFieldOptions): z.ZodString {\n  const schema = z.string();\n\n  // Build metadata\n  const metadata = {\n    [FIELD_METADATA_KEY]: {\n      type: \"autodate\" as const,\n      options: options || {},\n    },\n  };\n\n  return schema.describe(JSON.stringify(metadata));\n}\n\n/**\n * Creates a select field schema from enum values\n * Maps to PocketBase 'select' field type\n *\n * A `maxSelect` of 1 (or no options) produces a single-select enum schema;\n * `maxSelect` greater than 1 produces a multi-select array schema.\n *\n * Pass `maxSelect` as a literal so the overloads can pick the right return\n * type — a widened `number` variable resolves to the array overload even when\n * its runtime value is 1.\n *\n * @param values - Array of allowed string values\n * @param options - Optional select configuration\n * @returns Zod enum schema (single select) or array schema (multiple select) with PocketBase metadata\n *\n * @example\n * // Single select\n * const PostSchema = z.object({\n *   status: SelectField([\"draft\", \"published\", \"archived\"]),\n * });\n *\n * @example\n * // Multiple select\n * const ProductSchema = z.object({\n *   categories: SelectField([\"electronics\", \"clothing\", \"food\"], { maxSelect: 3 }),\n * });\n */\nexport function SelectField<const T extends readonly [string, ...string[]]>(\n  values: T,\n  options?: { maxSelect?: 1 }\n): EnumFromArray<T>;\nexport function SelectField<const T extends readonly [string, ...string[]]>(\n  values: T,\n  options: { maxSelect: number }\n): z.ZodArray<EnumFromArray<T>>;\nexport function SelectField<const T extends readonly [string, ...string[]]>(\n  values: T,\n  options?: SelectFieldOptions\n): EnumFromArray<T> | z.ZodArray<EnumFromArray<T>> {\n  const maxSelect = options?.maxSelect ?? 1;\n\n  if (maxSelect < 1) {\n    throw new Error(\"SelectField: maxSelect must be >= 1\");\n  }\n\n  const metadata = {\n    [FIELD_METADATA_KEY]: {\n      type: \"select\" as const,\n      options: {\n        values,\n        maxSelect,\n      },\n    },\n  };\n\n  if (maxSelect > 1) {\n    return z.array(z.enum(values)).describe(JSON.stringify(metadata)) as z.ZodArray<EnumFromArray<T>>;\n  }\n\n  return z.enum(values).describe(JSON.stringify(metadata)) as EnumFromArray<T>;\n}\n\n/**\n * Creates a single file field schema\n * Maps to PocketBase 'file' field type with maxSelect=1\n *\n * @param options - Optional file constraints\n * @returns Zod schema that accepts File on input and returns string when reading from database\n *\n * @example\n * const ProductSchema = z.object({\n *   thumbnail: FileField({ mimeTypes: [\"image/*\"], maxSize: 5242880 }),\n *   document: FileField({ mimeTypes: [\"application/pdf\"] }),\n * });\n *\n * @remarks\n * - When creating/updating records: accepts File objects\n * - When reading from PocketBase: returns string (filename)\n */\nexport function FileField(options?: FileFieldOptions): z.ZodType<string, File | string> {\n  // Accept File for input (when creating/updating) or string (when reading from DB)\n  // Output is always string (as returned by PocketBase)\n  const schema = z.preprocess((val) => {\n    // If it's a File, return its name (or empty string if no name)\n    // If it's already a string (from DB), return as-is\n    return val instanceof File ? val.name || \"\" : val;\n  }, z.string()) as z.ZodType<string, File | string>;\n\n  const normalizedOptions = normalizeFileFieldOptions(options, \"FileField\");\n\n  // Build metadata\n  const metadata = {\n    [FIELD_METADATA_KEY]: {\n      type: \"file\" as const,\n      options: normalizedOptions || {},\n    },\n  };\n\n  return schema.describe(JSON.stringify(metadata));\n}\n\n/**\n * Creates a multiple files field schema\n * Maps to PocketBase 'file' field type with maxSelect>1\n *\n * @param options - Optional file constraints\n * @returns Zod array schema that accepts File[] on input and returns string[] when reading from database\n *\n * @example\n * const ProductSchema = z.object({\n *   images: FilesField({ mimeTypes: [\"image/*\"], maxSelect: 5 }),\n *   attachments: FilesField({ minSelect: 1, maxSelect: 10 }),\n * });\n *\n * @remarks\n * - When creating/updating records: accepts File[]\n * - When reading from PocketBase: returns string[] (filenames)\n */\nexport function FilesField(options?: FilesFieldOptions): z.ZodType<string[], (File | string)[]> {\n  // Validate options\n  if (options?.minSelect !== undefined && options?.maxSelect !== undefined) {\n    if (options.minSelect > options.maxSelect) {\n      throw new Error(\"FilesField: minSelect cannot be greater than maxSelect\");\n    }\n  }\n\n  // Accept File[] for input (when creating/updating) or string[] (when reading from DB)\n  // Output is always string[] (as returned by PocketBase)\n  let baseArraySchema = z.array(z.string());\n\n  // Apply Zod validations first\n  if (options?.minSelect !== undefined) {\n    baseArraySchema = baseArraySchema.min(options.minSelect);\n  }\n  if (options?.maxSelect !== undefined) {\n    baseArraySchema = baseArraySchema.max(options.maxSelect);\n  }\n\n  const schema = z.preprocess((val) => {\n    // Handle array of Files or strings\n    if (Array.isArray(val)) {\n      return val.map((item) => (item instanceof File ? item.name || \"\" : item));\n    }\n    return val;\n  }, baseArraySchema);\n\n  const normalizedOptions = normalizeFileFieldOptions(options, \"FilesField\");\n\n  // Build metadata\n  const metadata = {\n    [FIELD_METADATA_KEY]: {\n      type: \"file\" as const,\n      options: normalizedOptions || {},\n    },\n  };\n\n  return schema.describe(JSON.stringify(metadata)) as z.ZodType<string[], (File | string)[]>;\n}\n\n/**\n * Distinguishes `JSONField(schema)` from `JSONField(options)`.\n *\n * Both arguments are plain objects at runtime, so the Zod schema is identified\n * by its parse surface rather than by shape.\n */\nfunction isZodSchema(value: unknown): value is z.ZodTypeAny {\n  if (value instanceof z.ZodType) {\n    return true;\n  }\n\n  return (\n    typeof value === \"object\" &&\n    value !== null &&\n    typeof (value as { parse?: unknown }).parse === \"function\" &&\n    typeof (value as { safeParse?: unknown }).safeParse === \"function\"\n  );\n}\n\n/**\n * Creates a JSON field schema with optional inner schema validation\n * Maps to PocketBase 'json' field type\n *\n * @param schema - Optional Zod schema for the JSON structure\n * @param options - Optional PocketBase constraints (`maxSize`)\n * @returns Zod schema with PocketBase metadata\n *\n * @example\n * // Any JSON\n * const ProductSchema = z.object({\n *   metadata: JSONField(),\n * });\n *\n * @example\n * // Typed JSON\n * const ProductSchema = z.object({\n *   settings: JSONField(z.object({\n *     theme: z.string(),\n *     notifications: z.boolean(),\n *   })),\n * });\n *\n * @example\n * // A payload larger than PocketBase's 1MB default needs its own limit\n * const TimelineSchema = z.object({\n *   timelineData: JSONField({ maxSize: \"5M\" }),\n *   outputSettings: JSONField(z.object({ fps: z.number() }), { maxSize: \"200K\" }),\n * });\n */\nexport function JSONField(options?: JSONFieldOptions): z.ZodRecord<z.ZodString, z.ZodAny>;\nexport function JSONField(schema: undefined, options?: JSONFieldOptions): z.ZodRecord<z.ZodString, z.ZodAny>;\nexport function JSONField<T extends z.ZodTypeAny>(schema: T, options?: JSONFieldOptions): T;\nexport function JSONField<T extends z.ZodTypeAny>(\n  schemaOrOptions?: T | JSONFieldOptions,\n  maybeOptions?: JSONFieldOptions\n): T | z.ZodRecord<z.ZodString, z.ZodAny> {\n  const schema = isZodSchema(schemaOrOptions) ? schemaOrOptions : undefined;\n  // A caller passing the schema conditionally (`JSONField(shape ?? undefined,\n  // { maxSize })`) leaves the options in the second slot, so both are read —\n  // otherwise the size cap would be dropped without a word\n  const options = schema ? maybeOptions : ((schemaOrOptions as JSONFieldOptions | undefined) ?? maybeOptions);\n\n  const baseSchema = schema ?? z.record(z.string(), z.any());\n  const normalizedOptions = normalizeJSONFieldOptions(options, \"JSONField\");\n\n  // Build metadata — `options` is omitted when the field carries no constraint,\n  // so an unconstrained JSONField serializes exactly as it always has\n  const metadata = {\n    [FIELD_METADATA_KEY]: {\n      type: \"json\" as const,\n      ...(normalizedOptions && Object.keys(normalizedOptions).length > 0 ? { options: normalizedOptions } : {}),\n    },\n  };\n\n  return baseSchema.describe(JSON.stringify(metadata)) as T | z.ZodRecord<z.ZodString, z.ZodAny>;\n}\n\n/**\n * Creates a geographic point field schema\n * Maps to PocketBase 'geoPoint' field type\n *\n * @returns Zod object schema with lon/lat fields and PocketBase metadata\n *\n * @example\n * const LocationSchema = z.object({\n *   coordinates: GeoPointField(),\n *   homeLocation: GeoPointField().optional(),\n * });\n */\nexport function GeoPointField(): z.ZodObject<{\n  lon: z.ZodNumber;\n  lat: z.ZodNumber;\n}> {\n  const schema = z.object({\n    lon: z.number(),\n    lat: z.number(),\n  });\n\n  // Build metadata\n  const metadata = {\n    [FIELD_METADATA_KEY]: {\n      type: \"geoPoint\" as const,\n    },\n  };\n\n  return schema.describe(JSON.stringify(metadata));\n}\n","import type { PermissionSchema, PermissionTemplateConfig } from \"../utils/permissions\";\n\n/**\n * Predefined permission templates for common access control patterns\n */\nexport const PermissionTemplates = {\n  /**\n   * Public access - anyone can perform all operations\n   */\n  public: (): PermissionSchema => ({\n    listRule: \"\",\n    viewRule: \"\",\n    createRule: \"\",\n    updateRule: \"\",\n    deleteRule: \"\",\n  }),\n\n  /**\n   * Authenticated users only - requires valid authentication for all operations\n   */\n  authenticated: (): PermissionSchema => ({\n    listRule: '@request.auth.id != \"\"',\n    viewRule: '@request.auth.id != \"\"',\n    createRule: '@request.auth.id != \"\"',\n    updateRule: '@request.auth.id != \"\"',\n    deleteRule: '@request.auth.id != \"\"',\n  }),\n\n  /**\n   * Owner-only access - users can only manage their own records\n   * @param ownerField - Name of the relation field pointing to user (default: 'User')\n   */\n  ownerOnly: (ownerField: string = \"User\"): PermissionSchema => ({\n    listRule: `@request.auth.id != \"\" && ${ownerField} = @request.auth.id`,\n    viewRule: `@request.auth.id != \"\" && ${ownerField} = @request.auth.id`,\n    createRule: '@request.auth.id != \"\"',\n    updateRule: `@request.auth.id != \"\" && ${ownerField} = @request.auth.id`,\n    deleteRule: `@request.auth.id != \"\" && ${ownerField} = @request.auth.id`,\n  }),\n\n  /**\n   * Admin/superuser only access\n   * Assumes a 'role' field exists with 'admin' value\n   * @param roleField - Name of the role field (default: 'role')\n   */\n  adminOnly: (roleField: string = \"role\"): PermissionSchema => ({\n    listRule: `@request.auth.id != \"\" && @request.auth.${roleField} = \"admin\"`,\n    viewRule: `@request.auth.id != \"\" && @request.auth.${roleField} = \"admin\"`,\n    createRule: `@request.auth.id != \"\" && @request.auth.${roleField} = \"admin\"`,\n    updateRule: `@request.auth.id != \"\" && @request.auth.${roleField} = \"admin\"`,\n    deleteRule: `@request.auth.id != \"\" && @request.auth.${roleField} = \"admin\"`,\n  }),\n\n  /**\n   * Public read, authenticated write\n   * Anyone can list/view, but only authenticated users can create/update/delete\n   */\n  readPublic: (): PermissionSchema => ({\n    listRule: \"\",\n    viewRule: \"\",\n    createRule: '@request.auth.id != \"\"',\n    updateRule: '@request.auth.id != \"\"',\n    deleteRule: '@request.auth.id != \"\"',\n  }),\n\n  /**\n   * Locked access - only superusers can perform operations\n   * All rules are set to null (locked)\n   */\n  locked: (): PermissionSchema => ({\n    listRule: null,\n    viewRule: null,\n    createRule: null,\n    updateRule: null,\n    deleteRule: null,\n  }),\n\n  /**\n   * Read-only authenticated - authenticated users can read, no write access\n   */\n  readOnlyAuthenticated: (): PermissionSchema => ({\n    listRule: '@request.auth.id != \"\"',\n    viewRule: '@request.auth.id != \"\"',\n    createRule: null,\n    updateRule: null,\n    deleteRule: null,\n  }),\n};\n\n/**\n * Resolve template configuration to concrete permission schema\n * @param config - Template configuration or direct permission schema\n * @returns Resolved permission schema with all rules defined\n */\nexport function resolveTemplate(config: PermissionTemplateConfig): PermissionSchema {\n  let baseRules: PermissionSchema;\n\n  switch (config.template) {\n    case \"public\":\n      baseRules = PermissionTemplates.public();\n      break;\n    case \"authenticated\":\n      baseRules = PermissionTemplates.authenticated();\n      break;\n    case \"owner-only\":\n      baseRules = PermissionTemplates.ownerOnly(config.ownerField);\n      break;\n    case \"admin-only\":\n      baseRules = PermissionTemplates.adminOnly(config.roleField);\n      break;\n    case \"read-public\":\n      baseRules = PermissionTemplates.readPublic();\n      break;\n    case \"custom\":\n      baseRules = {};\n      break;\n    default: {\n      // Exhaustive check - TypeScript will error if we miss a template type\n      const _exhaustive: never = config.template;\n      throw new Error(`Unknown template type: ${_exhaustive}`);\n    }\n  }\n\n  // Merge with custom rules if provided (custom rules override template rules)\n  return {\n    ...baseRules,\n    ...config.customRules,\n  };\n}\n\n","/**\n * Collection ID generation utilities for PocketBase migrations\n */\n\nimport { createHash, randomBytes } from \"crypto\";\n\n/**\n * Generates a unique collection ID in PocketBase format\n * Format: pb_ followed by 15 alphanumeric lowercase characters\n *\n * @returns A unique collection ID string (e.g., \"pb_a1b2c3d4e5f6g7h\")\n */\nexport function generateCollectionId(): string {\n  const chars = \"abcdefghijklmnopqrstuvwxyz0123456789\";\n  const idLength = 15;\n\n  // Generate cryptographically secure random bytes\n  const bytes = randomBytes(idLength);\n\n  // Convert bytes to alphanumeric characters\n  let id = \"pb_\";\n  for (let i = 0; i < idLength; i++) {\n    const index = bytes[i] % chars.length;\n    id += chars[index];\n  }\n\n  return id;\n}\n\n/**\n * Generates a unique field ID based on type and name\n * Format: type followed by 10 alphanumeric lowercase characters\n * If name is provided, the ID is deterministic\n *\n * @param type - PocketBase field type\n * @param name - Optional field name for deterministic ID\n * @returns A unique field ID string\n */\nexport function generateFieldId(type: string, name?: string): string {\n  const chars = \"abcdefghijklmnopqrstuvwxyz0123456789\";\n  const idLength = 10;\n\n  let bytes: Buffer | Uint8Array;\n  if (name) {\n    // Deterministic based on name to ensure stability across runs\n    bytes = createHash(\"sha256\").update(name).digest();\n  } else {\n    // Random\n    bytes = randomBytes(idLength);\n  }\n\n  // Convert bytes to alphanumeric characters\n  let suffix = \"\";\n  for (let i = 0; i < idLength; i++) {\n    const index = bytes[i] % chars.length;\n    suffix += chars[index];\n  }\n\n  return `${type}${suffix}`;\n}\n\n/**\n * Registry to track generated collection IDs and ensure uniqueness within a migration batch\n */\nexport class CollectionIdRegistry {\n  private ids: Set<string>;\n\n  constructor() {\n    this.ids = new Set<string>();\n  }\n\n  /**\n   * Generates a unique collection ID for a given collection name\n   * Retries up to 10 times if collision occurs (extremely rare)\n   * Special case: returns \"_pb_users_auth_\" for users collection\n   *\n   * @param collectionName - The name of the collection (optional)\n   * @returns A unique collection ID\n   * @throws Error if unable to generate unique ID after max attempts\n   */\n  generate(collectionName?: string): string {\n    // Special case: users collection always uses the constant\n    if (collectionName && collectionName.toLowerCase() === \"users\") {\n      const usersId = \"_pb_users_auth_\";\n      if (!this.has(usersId)) {\n        this.register(usersId);\n      }\n      return usersId;\n    }\n\n    const maxAttempts = 10;\n\n    for (let attempt = 0; attempt < maxAttempts; attempt++) {\n      const id = generateCollectionId();\n\n      if (!this.has(id)) {\n        this.register(id);\n        return id;\n      }\n    }\n\n    throw new Error(\"Failed to generate unique collection ID after maximum attempts\");\n  }\n\n  /**\n   * Checks if an ID has already been registered\n   *\n   * @param id - The collection ID to check\n   * @returns True if the ID exists in the registry\n   */\n  has(id: string): boolean {\n    return this.ids.has(id);\n  }\n\n  /**\n   * Registers a collection ID in the registry\n   *\n   * @param id - The collection ID to register\n   */\n  register(id: string): void {\n    this.ids.add(id);\n  }\n}\n","/**\n * Rule validator for PocketBase API rule expressions\n *\n * Validates permission rule expressions against PocketBase syntax rules,\n * including field references, @request references, and basic syntax validation.\n */\n\nimport type { APIRuleType, RuleExpression } from \"../utils/permissions\";\nimport type { FieldDefinition } from \"./types\";\nimport { generateFieldId } from \"./utils/collection-id-generator.js\";\n\n/**\n * PocketBase's back-relation path segment: `<collection>_via_<field>`\n *\n * Means \"the rows of `<collection>` whose `<field>` relation points at the\n * current record\". The referenced collection deliberately has no field by\n * that name, so a back-relation segment can never be resolved against a\n * field list — see `isBackRelationSegment`.\n */\nconst BACK_RELATION_SEGMENT = /^[a-zA-Z_][a-zA-Z0-9_]*_via_[a-zA-Z_][a-zA-Z0-9_]*$/;\n\n/**\n * Validation result for rule expressions\n */\nexport interface RuleValidationResult {\n  /** Whether the rule expression is valid */\n  valid: boolean;\n\n  /** List of validation errors */\n  errors: string[];\n\n  /** List of validation warnings */\n  warnings: string[];\n\n  /** List of field references found in the expression */\n  fieldReferences: string[];\n}\n\n/**\n * Rule expression validator\n *\n * Validates PocketBase API rule expressions for:\n * - Field reference existence and validity\n * - @request reference syntax\n * - Basic expression syntax (parentheses, operators)\n * - Auth collection specific rules (manageRule)\n *\n * Only the *root* of a field path is checked, because the validator sees one\n * collection at a time. Everything past the first hop — relation chains like\n * `User.email` and back-relations like `Members_via_WorkspaceRef.UserRef` —\n * is accepted unresolved and reported neither as an error nor a warning.\n * `@collection.*` references are likewise out of reach and are skipped.\n */\nexport class RuleValidator {\n  private fields: Map<string, FieldDefinition>;\n  private collectionName: string;\n  private isAuthCollection: boolean;\n\n  constructor(collectionName: string, fields: FieldDefinition[], isAuthCollection: boolean = false) {\n    this.collectionName = collectionName;\n    this.fields = new Map(fields.map((f) => [f.name, f]));\n    this.isAuthCollection = isAuthCollection;\n\n    // Add system fields that are always available in PocketBase\n    this.addSystemFields();\n  }\n\n  /**\n   * Add system fields that are always available in PocketBase collections\n   * These fields are automatically added by PocketBase and can be referenced in rules\n   */\n  private addSystemFields(): void {\n    // Base system fields available in all collections\n    const systemFields: FieldDefinition[] = [\n      { name: \"id\", id: generateFieldId(\"text\", \"id\"), type: \"text\", required: true, options: {} },\n      { name: \"created\", id: generateFieldId(\"date\", \"created\"), type: \"date\", required: true, options: {} },\n      { name: \"updated\", id: generateFieldId(\"date\", \"updated\"), type: \"date\", required: true, options: {} },\n      { name: \"collectionId\", id: generateFieldId(\"text\", \"collectionId\"), type: \"text\", required: true, options: {} },\n      { name: \"collectionName\", id: generateFieldId(\"text\", \"collectionName\"), type: \"text\", required: true, options: {} },\n    ];\n\n    // Auth collection specific system fields\n    if (this.isAuthCollection) {\n      systemFields.push(\n        { name: \"email\", id: generateFieldId(\"email\", \"email\"), type: \"email\", required: true, options: {} },\n        { name: \"emailVisibility\", id: generateFieldId(\"bool\", \"emailVisibility\"), type: \"bool\", required: false, options: {} },\n        { name: \"verified\", id: generateFieldId(\"bool\", \"verified\"), type: \"bool\", required: false, options: {} },\n        { name: \"tokenKey\", id: generateFieldId(\"text\", \"tokenKey\"), type: \"text\", required: true, options: {} },\n        { name: \"password\", id: generateFieldId(\"text\", \"password\"), type: \"text\", required: true, options: {} }\n      );\n    }\n\n    // Add system fields to the fields map (don't overwrite user-defined fields)\n    for (const field of systemFields) {\n      if (!this.fields.has(field.name)) {\n        this.fields.set(field.name, field);\n      }\n    }\n  }\n\n  /**\n   * Validate a rule expression\n   *\n   * @param ruleType - The type of rule being validated\n   * @param expression - The rule expression to validate\n   * @returns Validation result with errors, warnings, and field references\n   */\n  validate(ruleType: APIRuleType, expression: RuleExpression): RuleValidationResult {\n    const result: RuleValidationResult = {\n      valid: true,\n      errors: [],\n      warnings: [],\n      fieldReferences: [],\n    };\n\n    // Null means locked (superuser only) - always valid\n    if (expression === null) {\n      return result;\n    }\n\n    // Empty string means public - always valid but warn\n    if (expression === \"\") {\n      result.warnings.push(`${ruleType} is public - anyone can perform this operation`);\n      return result;\n    }\n\n    // Validate manageRule only for auth collections\n    if (ruleType === \"manageRule\" && !this.isAuthCollection) {\n      result.valid = false;\n      result.errors.push(\"manageRule is only valid for auth collections\");\n      return result;\n    }\n\n    // Extract and validate field references\n    const fieldRefs = this.extractFieldReferences(expression);\n    result.fieldReferences = fieldRefs;\n\n    for (const fieldRef of fieldRefs) {\n      this.validateFieldReference(fieldRef, result);\n    }\n\n    // Validate @request references\n    this.validateRequestReferences(expression, result);\n\n    // Validate syntax patterns\n    this.validateSyntax(expression, result);\n\n    return result;\n  }\n\n  /**\n   * Extract field references from expression\n   *\n   * Matches field names that are not @request or @collection references.\n   * Handles dot notation for relations: user.email, post.author.name\n   *\n   * @param expression - The rule expression\n   * @returns Array of unique field references\n   */\n  private extractFieldReferences(expression: string): string[] {\n    const refs: string[] = [];\n\n    // First, remove string literals and @-references to avoid matching them.\n    // @collection.<Name>.<path> addresses a *different* collection, so its\n    // segments are not fields of this one and must not be validated as such.\n    let cleaned = expression.replace(/\"[^\"]*\"/g, '\"\"').replace(/'[^']*'/g, \"''\");\n    cleaned = cleaned.replace(/@request\\.[a-zA-Z_][a-zA-Z0-9_.]*/g, \"\");\n    cleaned = cleaned.replace(/@collection\\.[a-zA-Z_][a-zA-Z0-9_.]*/g, \"\");\n\n    // Match field names (not starting with @)\n    // Handles dot notation for relations: user.email, post.author.name\n    const fieldPattern = /(?:^|[^@\\w])([a-zA-Z_][a-zA-Z0-9_]*(?:\\.[a-zA-Z_][a-zA-Z0-9_]*)*)(?=[^a-zA-Z0-9_.]|$)/g;\n\n    let match;\n    while ((match = fieldPattern.exec(cleaned)) !== null) {\n      const ref = match[1];\n      // Exclude PocketBase keywords and operators\n      if (!this.isKeyword(ref)) {\n        refs.push(ref);\n      }\n    }\n\n    return [...new Set(refs)]; // Remove duplicates\n  }\n\n  /**\n   * Check if a word is a PocketBase keyword\n   *\n   * @param word - The word to check\n   * @returns True if the word is a keyword\n   */\n  private isKeyword(word: string): boolean {\n    const keywords = [\"true\", \"false\", \"null\", \"AND\", \"OR\", \"NOT\", \"LIKE\", \"IN\"];\n    return keywords.includes(word.toUpperCase());\n  }\n\n  /**\n   * Check whether a path segment is a back-relation rather than a field\n   *\n   * A declared field wins: a collection may legitimately contain a field\n   * literally named `foo_via_bar`, and it should be validated as one.\n   *\n   * @param segment - A single dot-separated path segment\n   * @returns True if the segment should be treated as a back-relation\n   */\n  private isBackRelationSegment(segment: string): boolean {\n    return !this.fields.has(segment) && BACK_RELATION_SEGMENT.test(segment);\n  }\n\n  /**\n   * Validate a field reference exists in schema\n   *\n   * Only the root of the path is checked — the validator holds a single\n   * collection's fields, so anything past the first hop belongs to another\n   * collection and is accepted as-is. A root back-relation\n   * (`Members_via_WorkspaceRef.UserRef`) has no local field to check against\n   * either, so it is accepted too; PocketBase resolves it at runtime.\n   *\n   * @param fieldRef - The field reference to validate (e.g., \"user\" or \"user.email\")\n   * @param result - The validation result to update\n   */\n  private validateFieldReference(fieldRef: string, result: RuleValidationResult): void {\n    const parts = fieldRef.split(\".\");\n    const rootField = parts[0];\n\n    if (this.isBackRelationSegment(rootField)) {\n      return;\n    }\n\n    if (!this.fields.has(rootField)) {\n      result.errors.push(`Field '${rootField}' does not exist in collection '${this.collectionName}'`);\n      result.valid = false;\n      return;\n    }\n\n    // Traversing into a non-relation field is a local mistake we can catch.\n    // A back-relation only ever hangs off a relation hop, so this holds for\n    // `title.Foo_via_Bar` just as much as for `title.something`.\n    if (parts.length > 1) {\n      const field = this.fields.get(rootField)!;\n      if (field.type !== \"relation\") {\n        result.errors.push(`Field '${rootField}' is not a relation field, cannot access nested property '${parts[1]}'`);\n        result.valid = false;\n      }\n    }\n  }\n\n  /**\n   * Validate @request references\n   *\n   * Checks that @request references follow valid PocketBase patterns:\n   * - @request.auth.* - authenticated user data\n   * - @request.body.* - request body fields\n   * - @request.query.* - query parameters\n   * - @request.headers.* - request headers\n   * - @request.method - HTTP method\n   * - @request.context - execution context\n   *\n   * @param expression - The rule expression\n   * @param result - The validation result to update\n   */\n  private validateRequestReferences(expression: string, result: RuleValidationResult): void {\n    // Find all @request references\n    const requestRefs = expression.match(/@request\\.[a-zA-Z_][a-zA-Z0-9_.]*/g) || [];\n\n    for (const ref of requestRefs) {\n      // Check if the reference starts with a valid pattern\n      const isValid =\n        ref.startsWith(\"@request.auth.\") ||\n        ref === \"@request.method\" ||\n        ref === \"@request.context\" ||\n        ref.startsWith(\"@request.body.\") ||\n        ref.startsWith(\"@request.query.\") ||\n        ref.startsWith(\"@request.headers.\");\n\n      if (!isValid) {\n        result.errors.push(`Invalid @request reference: '${ref}'`);\n        result.valid = false;\n      }\n    }\n  }\n\n  /**\n   * Validate basic syntax patterns\n   *\n   * Checks for:\n   * - Balanced parentheses\n   * - Common operator mistakes (== instead of =)\n   *\n   * @param expression - The rule expression\n   * @param result - The validation result to update\n   */\n  private validateSyntax(expression: string, result: RuleValidationResult): void {\n    // Check for balanced parentheses\n    let parenCount = 0;\n    for (const char of expression) {\n      if (char === \"(\") parenCount++;\n      if (char === \")\") parenCount--;\n      if (parenCount < 0) {\n        result.errors.push(\"Unbalanced parentheses in expression\");\n        result.valid = false;\n        return;\n      }\n    }\n    if (parenCount !== 0) {\n      result.errors.push(\"Unbalanced parentheses in expression\");\n      result.valid = false;\n    }\n\n    // Warn about common mistakes\n    if (expression.includes(\"==\")) {\n      result.warnings.push(\"Use '=' instead of '==' for equality comparison in PocketBase rules\");\n    }\n  }\n}\n","/**\n * Permission analyzer for extracting and validating permissions from Zod schemas\n *\n * This module provides utilities to:\n * - Extract permission metadata from Zod schema descriptions\n * - Resolve template configurations to concrete permission schemas\n * - Validate permission rules against collection fields\n * - Merge permissions with default values\n */\n\nimport { resolveTemplate } from \"../utils/permission-templates\";\nimport type { APIRuleType, PermissionSchema, PermissionTemplateConfig } from \"../utils/permissions\";\nimport type { RuleValidationResult } from \"./rule-validator\";\nimport { RuleValidator } from \"./rule-validator\";\nimport type { FieldDefinition } from \"./types\";\n\n/**\n * Extract and analyze permissions from schema\n *\n * The PermissionAnalyzer class provides methods to work with permission\n * definitions attached to Zod schemas, including extraction, resolution,\n * validation, and normalization.\n */\nexport class PermissionAnalyzer {\n  /**\n   * Extract permission metadata from Zod schema description\n   *\n   * Zod schemas can have permission metadata attached via the describe() method.\n   * This method parses the description and extracts the permission configuration.\n   *\n   * @param schemaDescription - The Zod schema description string\n   * @returns Permission schema if found, null otherwise\n   *\n   * @example\n   * ```typescript\n   * const analyzer = new PermissionAnalyzer();\n   * const permissions = analyzer.extractPermissions(schema.description);\n   * ```\n   */\n  extractPermissions(schemaDescription: string | undefined): PermissionSchema | null {\n    if (!schemaDescription) {\n      return null;\n    }\n\n    try {\n      const metadata = JSON.parse(schemaDescription);\n      if (metadata.permissions) {\n        return metadata.permissions;\n      }\n    } catch {\n      // Not JSON or no permissions - this is expected for schemas without permissions\n      return null;\n    }\n\n    return null;\n  }\n\n  /**\n   * Resolve template configuration to concrete rules\n   *\n   * Takes either a template configuration or a direct permission schema\n   * and returns a fully resolved permission schema with all rules defined.\n   *\n   * If the input is already a permission schema (has rule properties),\n   * it's returned as-is. Otherwise, the template is resolved using the\n   * template resolver.\n   *\n   * @param config - Template configuration or direct permission schema\n   * @returns Resolved permission schema\n   *\n   * @example\n   * ```typescript\n   * const analyzer = new PermissionAnalyzer();\n   *\n   * // Resolve from template\n   * const permissions = analyzer.resolvePermissions({\n   *   template: 'owner-only',\n   *   ownerField: 'User'\n   * });\n   *\n   * // Or pass direct schema\n   * const permissions = analyzer.resolvePermissions({\n   *   listRule: '@request.auth.id != \"\"',\n   *   viewRule: '@request.auth.id != \"\"'\n   * });\n   * ```\n   */\n  resolvePermissions(config: PermissionTemplateConfig | PermissionSchema): PermissionSchema {\n    // If it's already a permission schema (has rule properties), return as-is\n    if (\n      \"listRule\" in config ||\n      \"viewRule\" in config ||\n      \"createRule\" in config ||\n      \"updateRule\" in config ||\n      \"deleteRule\" in config ||\n      \"manageRule\" in config\n    ) {\n      return config as PermissionSchema;\n    }\n\n    // Otherwise resolve template\n    return resolveTemplate(config as PermissionTemplateConfig);\n  }\n\n  /**\n   * Validate all rules in a permission schema\n   *\n   * Validates each rule in the permission schema against the collection's\n   * field definitions. Returns a map of validation results keyed by rule type.\n   *\n   * Only validates rules that are defined (not undefined). Undefined rules\n   * are treated as null (locked) by default.\n   *\n   * @param collectionName - Name of the collection being validated\n   * @param permissions - Permission schema to validate\n   * @param fields - Collection field definitions\n   * @param isAuthCollection - Whether this is an auth collection (allows manageRule)\n   * @returns Map of validation results by rule type\n   *\n   * @example\n   * ```typescript\n   * const analyzer = new PermissionAnalyzer();\n   * const results = analyzer.validatePermissions(\n   *   'posts',\n   *   { listRule: '@request.auth.id != \"\"', viewRule: 'author = @request.auth.id' },\n   *   fields,\n   *   false\n   * );\n   *\n   * for (const [ruleType, result] of results) {\n   *   if (!result.valid) {\n   *     console.error(`${ruleType} validation failed:`, result.errors);\n   *   }\n   * }\n   * ```\n   */\n  validatePermissions(\n    collectionName: string,\n    permissions: PermissionSchema,\n    fields: FieldDefinition[],\n    isAuthCollection: boolean = false\n  ): Map<APIRuleType, RuleValidationResult> {\n    const validator = new RuleValidator(collectionName, fields, isAuthCollection);\n    const results = new Map<APIRuleType, RuleValidationResult>();\n\n    // Define all possible rule types\n    const ruleTypes: APIRuleType[] = [\"listRule\", \"viewRule\", \"createRule\", \"updateRule\", \"deleteRule\"];\n\n    // Add manageRule for auth collections\n    if (isAuthCollection) {\n      ruleTypes.push(\"manageRule\");\n    }\n\n    // Validate each defined rule\n    for (const ruleType of ruleTypes) {\n      const expression = permissions[ruleType];\n      if (expression !== undefined) {\n        results.set(ruleType, validator.validate(ruleType, expression));\n      }\n    }\n\n    return results;\n  }\n\n  /**\n   * Merge permissions with defaults\n   *\n   * Ensures all rule types have a defined value. Undefined rules are set\n   * to null (locked to superusers only), which is the PocketBase default.\n   *\n   * This is useful when generating migrations to ensure all rules are\n   * explicitly set in the collection configuration.\n   *\n   * @param permissions - Permission schema (may have undefined rules)\n   * @returns Permission schema with all rules defined (null if not specified)\n   *\n   * @example\n   * ```typescript\n   * const analyzer = new PermissionAnalyzer();\n   * const merged = analyzer.mergeWithDefaults({\n   *   listRule: '@request.auth.id != \"\"'\n   *   // other rules undefined\n   * });\n   *\n   * // Result:\n   * // {\n   * //   listRule: '@request.auth.id != \"\"',\n   * //   viewRule: null,\n   * //   createRule: null,\n   * //   updateRule: null,\n   * //   deleteRule: null,\n   * //   manageRule: null\n   * // }\n   * ```\n   */\n  mergeWithDefaults(permissions: PermissionSchema): PermissionSchema {\n    return {\n      listRule: permissions.listRule ?? null,\n      viewRule: permissions.viewRule ?? null,\n      createRule: permissions.createRule ?? null,\n      updateRule: permissions.updateRule ?? null,\n      deleteRule: permissions.deleteRule ?? null,\n      manageRule: permissions.manageRule ?? null,\n    };\n  }\n}\n","/**\n * Zod to PocketBase type mapping utilities\n *\n * This module provides comprehensive mapping between Zod schema types\n * and PocketBase field types, including support for all PocketBase field types:\n * - text, email, url, editor\n * - number, bool\n * - date, autodate\n * - select (single/multiple)\n * - relation (single/multiple)\n * - file (single/multiple)\n * - json\n * - geoPoint\n */\n\nimport { z } from \"zod\";\nimport { extractFieldMetadata, type PocketBaseFieldType } from \"../../schema/fields\";\n\n/**\n * All supported PocketBase field types\n */\nexport const POCKETBASE_FIELD_TYPES: readonly PocketBaseFieldType[] = [\n  \"text\",\n  \"email\",\n  \"url\",\n  \"number\",\n  \"bool\",\n  \"date\",\n  \"select\",\n  \"relation\",\n  \"file\",\n  \"json\",\n  \"editor\",\n  \"geoPoint\",\n  \"autodate\",\n  \"password\",\n] as const;\n\n/**\n * Field type metadata for documentation and validation\n */\nexport interface FieldTypeInfo {\n  type: PocketBaseFieldType;\n  description: string;\n  zodTypes: string[];\n  supportsMultiple: boolean;\n}\n\n/**\n * Metadata about each PocketBase field type\n */\nexport const FIELD_TYPE_INFO: Record<PocketBaseFieldType, FieldTypeInfo> = {\n  text: {\n    type: \"text\",\n    description: \"Plain text field\",\n    zodTypes: [\"ZodString\"],\n    supportsMultiple: false,\n  },\n  password: {\n    type: \"password\",\n    description: \"Password field (system)\",\n    zodTypes: [\"ZodString\"],\n    supportsMultiple: false,\n  },\n  email: {\n    type: \"email\",\n    description: \"Email address field with validation\",\n    zodTypes: [\"ZodString with email()\"],\n    supportsMultiple: false,\n  },\n  url: {\n    type: \"url\",\n    description: \"URL field with validation\",\n    zodTypes: [\"ZodString with url()\"],\n    supportsMultiple: false,\n  },\n  editor: {\n    type: \"editor\",\n    description: \"Rich text editor field\",\n    zodTypes: [\"ZodString\"],\n    supportsMultiple: false,\n  },\n  number: {\n    type: \"number\",\n    description: \"Numeric field (integer or float)\",\n    zodTypes: [\"ZodNumber\"],\n    supportsMultiple: false,\n  },\n  bool: {\n    type: \"bool\",\n    description: \"Boolean field\",\n    zodTypes: [\"ZodBoolean\"],\n    supportsMultiple: false,\n  },\n  date: {\n    type: \"date\",\n    description: \"Date/datetime field\",\n    zodTypes: [\"ZodDate\", \"ZodString with datetime format\"],\n    supportsMultiple: false,\n  },\n  autodate: {\n    type: \"autodate\",\n    description: \"Auto-managed date field (created/updated)\",\n    zodTypes: [\"ZodString\"],\n    supportsMultiple: false,\n  },\n  select: {\n    type: \"select\",\n    description: \"Single or multiple select from predefined values\",\n    zodTypes: [\"ZodEnum\", \"ZodArray<ZodEnum>\"],\n    supportsMultiple: true,\n  },\n  relation: {\n    type: \"relation\",\n    description: \"Reference to another collection (explicit RelationField()/RelationsField() metadata only)\",\n    zodTypes: [\"RelationField()\", \"RelationsField()\"],\n    supportsMultiple: true,\n  },\n  file: {\n    type: \"file\",\n    description: \"File upload field\",\n    zodTypes: [\"File\", \"ZodArray<File>\"],\n    supportsMultiple: true,\n  },\n  json: {\n    type: \"json\",\n    description: \"JSON data field\",\n    zodTypes: [\"ZodRecord\", \"ZodObject\", \"ZodArray\", \"ZodArray<ZodString>\"],\n    supportsMultiple: false,\n  },\n  geoPoint: {\n    type: \"geoPoint\",\n    description: \"Geographic coordinates (lon, lat)\",\n    zodTypes: [\"ZodObject with lon/lat\"],\n    supportsMultiple: false,\n  },\n};\n\nfunction getChecks(zodType: z.ZodTypeAny): any[] {\n  const def = (zodType as any).def ?? (zodType as any)._def;\n  return (def?.checks ?? []) as any[];\n}\n\nfunction getJsonSchema(zodType: z.ZodTypeAny): any | null {\n  try {\n    const toJSONSchema = (zodType as any).toJSONSchema;\n    return typeof toJSONSchema === \"function\" ? toJSONSchema.call(zodType) : null;\n  } catch {\n    return null;\n  }\n}\n\n/**\n * Maps Zod string types to PocketBase field types\n */\nexport function mapZodStringType(zodType: z.ZodString): PocketBaseFieldType {\n  const checks = getChecks(zodType);\n\n  // Check for email validation\n  const hasEmail = checks.some((check: any) => check.kind === \"email\" || check.def?.format === \"email\");\n  if (hasEmail) {\n    return \"email\";\n  }\n\n  // Check for URL validation\n  const hasUrl = checks.some((check: any) => check.kind === \"url\" || check.def?.format === \"url\");\n  if (hasUrl) {\n    return \"url\";\n  }\n\n  // Check for datetime validation (could be date field)\n  const hasDatetime = checks.some(\n    (check: any) => check.kind === \"datetime\" || check.def?.format === \"datetime\" || check.def?.format === \"date-time\"\n  );\n  if (hasDatetime) {\n    return \"date\";\n  }\n\n  // Default to text\n  return \"text\";\n}\n\n/**\n * Maps Zod number types to PocketBase number type\n */\nexport function mapZodNumberType(_zodType: z.ZodNumber): PocketBaseFieldType {\n  return \"number\";\n}\n\n/**\n * Maps Zod boolean types to PocketBase bool type\n */\nexport function mapZodBooleanType(_zodType: z.ZodBoolean): PocketBaseFieldType {\n  return \"bool\";\n}\n\n/**\n * Maps Zod enum types to PocketBase select type\n */\nexport function mapZodEnumType(_zodType: z.ZodEnum<any>): PocketBaseFieldType {\n  return \"select\";\n}\n\n/**\n * Maps Zod array types to appropriate PocketBase types\n *\n * A bare array of strings maps to `json` — PocketBase has no plain\n * string-array type. Relations and multi-selects must be declared explicitly\n * with RelationsField() or SelectField(values, { maxSelect }).\n */\nexport function mapZodArrayType(zodType: z.ZodArray<any>): PocketBaseFieldType {\n  const elementType = zodType.element as z.ZodTypeAny;\n\n  if (elementType instanceof z.ZodFile) {\n    return \"file\";\n  }\n\n  // Default to JSON for all other array types (including arrays of strings)\n  return \"json\";\n}\n\n/**\n * Maps Zod date types to PocketBase date type\n */\nexport function mapZodDateType(_zodType: z.ZodDate): PocketBaseFieldType {\n  return \"date\";\n}\n\n/**\n * Maps Zod record/object types to PocketBase JSON type\n */\nexport function mapZodRecordType(_zodType: z.ZodRecord | z.ZodObject<any>): PocketBaseFieldType {\n  return \"json\";\n}\n\n/**\n * Main type mapping function that determines PocketBase field type from Zod type\n */\nexport function mapZodTypeToPocketBase(zodType: z.ZodTypeAny): PocketBaseFieldType {\n  const unwrappedType = unwrapZodType(zodType);\n\n  // Check for metadata first (explicit type overrides)\n  const metadata = extractFieldMetadata(unwrappedType.description);\n  if (metadata && metadata.type) {\n    return metadata.type;\n  }\n\n  if (unwrappedType instanceof z.ZodFile) {\n    return \"file\";\n  }\n\n  // Map based on Zod type\n  let type: PocketBaseFieldType = \"text\";\n\n  if (unwrappedType instanceof z.ZodString) {\n    type = mapZodStringType(unwrappedType);\n  } else if (unwrappedType instanceof z.ZodNumber) {\n    type = mapZodNumberType(unwrappedType);\n  } else if (unwrappedType instanceof z.ZodBoolean) {\n    type = mapZodBooleanType(unwrappedType);\n  } else if (unwrappedType instanceof z.ZodEnum) {\n    type = mapZodEnumType(unwrappedType);\n  } else if (unwrappedType instanceof z.ZodArray) {\n    type = mapZodArrayType(unwrappedType);\n  } else if (unwrappedType instanceof z.ZodDate) {\n    type = mapZodDateType(unwrappedType);\n  } else if (unwrappedType instanceof z.ZodRecord || unwrappedType instanceof z.ZodObject) {\n    type = mapZodRecordType(unwrappedType);\n  }\n\n  return type;\n}\n\n/**\n * Extracts field options from Zod type (min, max, pattern, etc.)\n */\nexport function extractFieldOptions(zodType: z.ZodTypeAny): Record<string, any> {\n  const options: Record<string, any> = {};\n\n  const unwrappedType = unwrapZodType(zodType);\n  const checks = getChecks(unwrappedType);\n\n  // Extract string constraints\n  if (unwrappedType instanceof z.ZodString) {\n    for (const check of checks) {\n      if (check.kind === \"min\") {\n        options.min = check.value;\n      }\n      if (check.kind === \"max\") {\n        options.max = check.value;\n      }\n      if (check.kind === \"regex\") {\n        options.pattern = check.regex.source;\n      }\n    }\n\n    if (options.min === undefined || options.max === undefined || options.pattern === undefined) {\n      const schema = getJsonSchema(unwrappedType);\n      if (schema) {\n        if (options.min === undefined && typeof schema.minLength === \"number\") {\n          options.min = schema.minLength;\n        }\n        if (options.max === undefined && typeof schema.maxLength === \"number\") {\n          options.max = schema.maxLength;\n        }\n        if (options.pattern === undefined && typeof schema.pattern === \"string\") {\n          options.pattern = schema.pattern;\n        }\n      }\n    }\n  }\n\n  // Extract number constraints\n  if (unwrappedType instanceof z.ZodNumber) {\n    for (const check of checks) {\n      if (check.kind === \"min\") {\n        options.min = check.value;\n      }\n      if (check.kind === \"max\") {\n        options.max = check.value;\n      }\n    }\n\n    const schema = getJsonSchema(unwrappedType);\n    if (schema) {\n      if (options.min === undefined && typeof schema.minimum === \"number\") {\n        options.min = schema.minimum;\n      }\n      if (options.max === undefined && typeof schema.maximum === \"number\") {\n        options.max = schema.maximum;\n      }\n    }\n\n    // `z.number().int()` is how an integer column is spelled in Zod; it maps\n    // onto PocketBase's onlyInt, which the generator writes from noDecimal\n    const isInteger =\n      schema?.type === \"integer\" ||\n      checks.some((check: any) => check.kind === \"int\" || String(check.def?.format ?? \"\").includes(\"int\"));\n    if (isInteger) {\n      options.noDecimal = true;\n    }\n  }\n\n  // Extract enum values\n  if (unwrappedType instanceof z.ZodEnum) {\n    options.values = unwrappedType.options.map(String);\n  }\n\n  // Extract array constraints\n  if (unwrappedType instanceof z.ZodArray) {\n    const arrayChecks = getChecks(unwrappedType);\n    for (const check of arrayChecks) {\n      if (check.kind === \"min\") {\n        options.minSelect = check.value;\n      }\n      if (check.kind === \"max\") {\n        options.maxSelect = check.value;\n      }\n    }\n\n    if (options.minSelect === undefined || options.maxSelect === undefined) {\n      const schema = getJsonSchema(unwrappedType);\n      if (schema) {\n        if (options.minSelect === undefined && typeof schema.minItems === \"number\") {\n          options.minSelect = schema.minItems;\n        }\n        if (options.maxSelect === undefined && typeof schema.maxItems === \"number\") {\n          options.maxSelect = schema.maxItems;\n        }\n      }\n    }\n  }\n\n  return options;\n}\n\n/**\n * Determines if a Zod field is required (not optional)\n */\nexport function isFieldRequired(zodType: z.ZodTypeAny): boolean {\n  // Check if it's optional\n  if (zodType instanceof z.ZodOptional) {\n    return false;\n  }\n\n  // Check if it has a default value (makes it optional)\n  if (zodType instanceof z.ZodDefault) {\n    return false;\n  }\n\n  // Check for nullable (in PocketBase context, nullable means optional)\n  if (zodType instanceof z.ZodNullable) {\n    return false;\n  }\n\n  return true;\n}\n\n/**\n * Unwraps a Zod type to get the inner type\n * Handles optional, nullable, and default wrappers\n */\nexport function unwrapZodType(zodType: z.ZodTypeAny): z.ZodTypeAny {\n  let unwrapped = zodType;\n  let previous = null;\n\n  while (unwrapped !== previous) {\n    previous = unwrapped;\n    if (unwrapped instanceof z.ZodOptional) {\n      unwrapped = unwrapped.unwrap() as z.ZodTypeAny;\n    } else if (unwrapped instanceof z.ZodNullable) {\n      unwrapped = unwrapped.unwrap() as z.ZodTypeAny;\n    } else if (unwrapped instanceof z.ZodDefault) {\n      unwrapped = unwrapped.unwrap() as z.ZodTypeAny;\n    }\n  }\n\n  return unwrapped;\n}\n\n/**\n * Gets the default value from a Zod type if it has one\n */\nexport function getDefaultValue(zodType: z.ZodTypeAny): any {\n  if (zodType instanceof z.ZodDefault) {\n    return zodType.def.defaultValue;\n  }\n  return undefined;\n}\n\n/**\n * Checks if a Zod type is an array type\n */\nexport function isArrayType(zodType: z.ZodTypeAny): boolean {\n  const unwrapped = unwrapZodType(zodType);\n  return unwrapped instanceof z.ZodArray;\n}\n\n/**\n * Gets the element type of an array Zod type\n */\nexport function getArrayElementType(zodType: z.ZodTypeAny): z.ZodTypeAny | null {\n  const unwrapped = unwrapZodType(zodType);\n  if (unwrapped instanceof z.ZodArray) {\n    return unwrapped.element as z.ZodTypeAny;\n  }\n  return null;\n}\n\n/**\n * Checks if a Zod type represents a geo point (object with lon/lat)\n */\nexport function isGeoPointType(zodType: z.ZodTypeAny): boolean {\n  const unwrapped = unwrapZodType(zodType);\n  if (!(unwrapped instanceof z.ZodObject)) {\n    return false;\n  }\n\n  const shape = unwrapped.shape;\n  const hasLon = \"lon\" in shape && shape.lon instanceof z.ZodNumber;\n  const hasLat = \"lat\" in shape && shape.lat instanceof z.ZodNumber;\n\n  return hasLon && hasLat;\n}\n\n/**\n * Complete field options extracted from a Zod type\n */\nexport interface ExtractedFieldOptions {\n  min?: number;\n  max?: number;\n  pattern?: string;\n  values?: string[];\n  minSelect?: number;\n  maxSelect?: number;\n  mimeTypes?: string[];\n  maxSize?: number;\n  thumbs?: string[];\n}\n\n/**\n * Extracts comprehensive field options from Zod type\n * Includes all constraints that can be mapped to PocketBase field options\n */\nexport function extractComprehensiveFieldOptions(zodType: z.ZodTypeAny): ExtractedFieldOptions {\n  const options: ExtractedFieldOptions = {};\n  const unwrapped = unwrapZodType(zodType);\n  const checks = getChecks(unwrapped);\n\n  // Extract string constraints\n  if (unwrapped instanceof z.ZodString) {\n    for (const check of checks) {\n      if (check.kind === \"min\") {\n        options.min = check.value;\n      }\n      if (check.kind === \"max\") {\n        options.max = check.value;\n      }\n      if (check.kind === \"regex\") {\n        options.pattern = check.regex.source;\n      }\n    }\n\n    if (options.min === undefined || options.max === undefined || options.pattern === undefined) {\n      const schema = getJsonSchema(unwrapped);\n      if (schema) {\n        if (options.min === undefined && typeof schema.minLength === \"number\") {\n          options.min = schema.minLength;\n        }\n        if (options.max === undefined && typeof schema.maxLength === \"number\") {\n          options.max = schema.maxLength;\n        }\n        if (options.pattern === undefined && typeof schema.pattern === \"string\") {\n          options.pattern = schema.pattern;\n        }\n      }\n    }\n  }\n\n  // Extract number constraints\n  if (unwrapped instanceof z.ZodNumber) {\n    for (const check of checks) {\n      if (check.kind === \"min\") {\n        options.min = check.value;\n      }\n      if (check.kind === \"max\") {\n        options.max = check.value;\n      }\n    }\n\n    if (options.min === undefined || options.max === undefined) {\n      const schema = getJsonSchema(unwrapped);\n      if (schema) {\n        if (options.min === undefined && typeof schema.minimum === \"number\") {\n          options.min = schema.minimum;\n        }\n        if (options.max === undefined && typeof schema.maximum === \"number\") {\n          options.max = schema.maximum;\n        }\n      }\n    }\n  }\n\n  // Extract enum values\n  if (unwrapped instanceof z.ZodEnum) {\n    options.values = unwrapped.options.map(String);\n  }\n\n  // Extract array constraints\n  if (unwrapped instanceof z.ZodArray) {\n    const arrayChecks = getChecks(unwrapped);\n    for (const check of arrayChecks) {\n      if (check.kind === \"min\") {\n        options.minSelect = check.value;\n      }\n      if (check.kind === \"max\") {\n        options.maxSelect = check.value;\n      }\n    }\n\n    if (options.minSelect === undefined || options.maxSelect === undefined) {\n      const schema = getJsonSchema(unwrapped);\n      if (schema) {\n        if (options.minSelect === undefined && typeof schema.minItems === \"number\") {\n          options.minSelect = schema.minItems;\n        }\n        if (options.maxSelect === undefined && typeof schema.maxItems === \"number\") {\n          options.maxSelect = schema.maxItems;\n        }\n      }\n    }\n\n    // Check for enum element type\n    const elementType = unwrapped.element as z.ZodTypeAny;\n    if (elementType instanceof z.ZodEnum) {\n      options.values = elementType.options.map(String);\n    }\n  }\n\n  return options;\n}\n\n\n\n/**\n * Options every PocketBase field carries, whatever its type\n */\nconst UNIVERSAL_FIELD_OPTIONS = [\"hidden\", \"presentable\", \"system\"] as const;\n\n/**\n * The options PocketBase actually stores per field type.\n *\n * Zod validators do not line up with PocketBase's option set: `z.string()\n * .email()` carries a regex that becomes `pattern`, but PocketBase's `email`\n * type has no `pattern` and drops it on save. Emitting one leaves the\n * migration file describing a collection the server never had — the file and\n * the database disagree from the moment it is applied.\n *\n * Keys are PocketBase's own, plus the internal aliases the generator\n * translates on the way out (`noDecimal` -> `onlyInt`).\n */\nconst SUPPORTED_FIELD_OPTIONS: Record<PocketBaseFieldType, readonly string[]> = {\n  text: [\"min\", \"max\", \"pattern\", \"autogeneratePattern\", \"primaryKey\"],\n  password: [\"min\", \"max\", \"pattern\", \"cost\"],\n  email: [\"exceptDomains\", \"onlyDomains\"],\n  url: [\"exceptDomains\", \"onlyDomains\"],\n  editor: [\"convertURLs\", \"maxSize\"],\n  number: [\"min\", \"max\", \"onlyInt\", \"noDecimal\"],\n  bool: [],\n  date: [\"min\", \"max\"],\n  autodate: [\"onCreate\", \"onUpdate\"],\n  select: [\"values\", \"maxSelect\"],\n  file: [\"mimeTypes\", \"thumbs\", \"maxSelect\", \"maxSize\", \"protected\"],\n  relation: [\"collectionId\", \"cascadeDelete\", \"minSelect\", \"maxSelect\"],\n  json: [\"maxSize\"],\n  geoPoint: [],\n};\n\n/**\n * The option keys a field of `fieldType` can carry — the same set the\n * generator is allowed to emit.\n *\n * The reader (`pocketbase-converter.extractFieldOptions`) uses this so that\n * every option the generator writes is read back on replay. A key that is\n * emitted but not read makes `compare()` see a modification on every run and\n * emit the same `updated_*` migration forever.\n *\n * @param fieldType - The PocketBase field type, if known\n * @returns The option keys readable for that type (every known key when the\n *   type is unrecognized)\n */\nexport function getSupportedFieldOptionKeys(fieldType?: string): string[] {\n  const typeSpecific =\n    fieldType && fieldType in SUPPORTED_FIELD_OPTIONS\n      ? SUPPORTED_FIELD_OPTIONS[fieldType as PocketBaseFieldType]\n      : Object.values(SUPPORTED_FIELD_OPTIONS).flat();\n\n  return [...new Set([...typeSpecific, ...UNIVERSAL_FIELD_OPTIONS])];\n}\n\n/**\n * Drops the options a PocketBase field type does not support.\n *\n * @param fieldType - The resolved PocketBase field type\n * @param options - Options collected from the Zod schema or field metadata\n * @returns The supported subset, or undefined when nothing is left\n */\nexport function filterSupportedFieldOptions(\n  fieldType: PocketBaseFieldType,\n  options: Record<string, any> | undefined\n): Record<string, any> | undefined {\n  if (!options) {\n    return options;\n  }\n\n  const supported = SUPPORTED_FIELD_OPTIONS[fieldType];\n  if (!supported) {\n    return options;\n  }\n\n  const allowed = new Set<string>([...supported, ...UNIVERSAL_FIELD_OPTIONS]);\n  const filtered: Record<string, any> = {};\n\n  for (const [key, value] of Object.entries(options)) {\n    if (allowed.has(key)) {\n      filtered[key] = value;\n    }\n  }\n\n  return Object.keys(filtered).length > 0 ? filtered : undefined;\n}\n\n/**\n * What PocketBase stores for an option that carries no constraint.\n *\n * Options live on a Go struct, so there is nothing to delete: dropping `max`\n * from a text field sets it back to `0`, dropping `pattern` sets it back to\n * `\"\"`. `min`/`max` are typed per field and handled in\n * {@link getFieldOptionUnsetValue}.\n */\nconst OPTION_UNSET_VALUES: Record<string, any> = {\n  pattern: \"\",\n  autogeneratePattern: \"\",\n  cost: 0,\n  maxSize: 0,\n  maxSelect: 0,\n  minSelect: 0,\n  primaryKey: false,\n  onlyInt: false,\n  noDecimal: false,\n  convertURLs: false,\n  protected: false,\n  hidden: false,\n  presentable: false,\n  system: false,\n  values: [],\n  mimeTypes: [],\n  thumbs: [],\n  exceptDomains: [],\n  onlyDomains: [],\n};\n\n/**\n * PocketBase's zero value for a field option — what the server holds once the\n * option no longer constrains anything.\n *\n * Removing an option has to be *written*, not omitted: the generator emits\n * `field.max = 0` rather than `field.max = null`, and the diff treats that zero\n * value as equivalent to a schema that never set the option. Emitting `null`\n * instead describes a state PocketBase cannot hold, and replay reads it back as\n * a removal still pending — a fresh `updated_*` migration on every run.\n *\n * @param fieldType - The PocketBase field type, if known\n * @param key - The option key\n * @returns The zero value PocketBase stores, or undefined for an unknown key\n */\nexport function getFieldOptionUnsetValue(fieldType: string | undefined, key: string): any {\n  // min/max are typed per field type: *float64 on number (nil when unset),\n  // types.DateTime on date (empty string), plain int everywhere else\n  if (key === \"min\" || key === \"max\") {\n    if (fieldType === \"number\") {\n      return null;\n    }\n    if (fieldType === \"date\") {\n      return \"\";\n    }\n    return 0;\n  }\n\n  return OPTION_UNSET_VALUES[key];\n}\n\n/**\n * Gets the PocketBase field type with additional context\n */\nexport interface FieldTypeResult {\n  type: PocketBaseFieldType;\n  isMultiple: boolean;\n  options: ExtractedFieldOptions;\n}\n\n/**\n * Comprehensive type mapping that returns full field information\n */\nexport function getFieldTypeInfo(zodType: z.ZodTypeAny): FieldTypeResult {\n  const type = mapZodTypeToPocketBase(zodType);\n  const isMultiple = isArrayType(zodType);\n  const options = extractComprehensiveFieldOptions(zodType);\n\n  return {\n    type,\n    isMultiple,\n    options,\n  };\n}\n","import { z } from \"zod\";\nimport type { RuleExpression } from \"../utils/permissions\";\nimport { defineCollection } from \"./base\";\n\n/**\n * Permission rules that apply to a view collection\n *\n * View collections are read-only: PocketBase rejects createRule, updateRule,\n * deleteRule and manageRule on them, so only the two read rules are accepted.\n */\nexport interface ViewPermissionSchema {\n  /** Controls who can list/query the view's rows */\n  listRule?: RuleExpression;\n\n  /** Controls who can view an individual row */\n  viewRule?: RuleExpression;\n}\n\n/**\n * Configuration options for defining a view collection\n */\nexport interface ViewCollectionConfig {\n  /**\n   * The name of the PocketBase collection\n   */\n  collectionName: string;\n\n  /**\n   * The Zod schema describing the shape of a row\n   *\n   * For views this is used for TypeScript type generation and application-side\n   * parsing only - PocketBase derives the collection's actual fields from the\n   * SQL query when the collection is saved.\n   */\n  schema: z.ZodObject<any>;\n\n  /**\n   * The SQL SELECT statement backing the view\n   *\n   * Use the `sql` tagged template for consistent formatting.\n   */\n  viewQuery: string;\n\n  /**\n   * Optional read permissions (listRule / viewRule)\n   */\n  permissions?: ViewPermissionSchema;\n}\n\n/**\n * Removes the common leading indentation from a multi-line string and trims\n * blank leading/trailing lines\n *\n * Keeps generated migrations stable when a query is re-indented in the source\n * file, since only the relative indentation is preserved. Also used when\n * reading a query back out of a migration file, where the generator has\n * indented it to fit the surrounding code.\n *\n * @param value - Raw multi-line string\n * @returns Dedented string\n */\nexport function dedentSql(value: string): string {\n  const lines = value.replace(/\\r\\n/g, \"\\n\").split(\"\\n\");\n\n  // Drop leading and trailing blank lines\n  while (lines.length > 0 && lines[0].trim() === \"\") {\n    lines.shift();\n  }\n  while (lines.length > 0 && lines[lines.length - 1].trim() === \"\") {\n    lines.pop();\n  }\n\n  if (lines.length === 0) {\n    return \"\";\n  }\n\n  // Find the smallest indentation across all non-blank lines\n  let minIndent = Infinity;\n  for (const line of lines) {\n    if (line.trim() === \"\") continue;\n    const indent = line.length - line.trimStart().length;\n    if (indent < minIndent) {\n      minIndent = indent;\n    }\n  }\n\n  if (!Number.isFinite(minIndent) || minIndent === 0) {\n    return lines.map((line) => line.trimEnd()).join(\"\\n\");\n  }\n\n  return lines.map((line) => line.slice(minIndent).trimEnd()).join(\"\\n\");\n}\n\n/**\n * Tagged template for SQL view queries\n *\n * Interpolates values, strips the common leading indentation and trims blank\n * leading/trailing lines. Returns a plain string, so a regular string literal\n * works anywhere `sql` does.\n *\n * @example\n * const query = sql`\n *   SELECT p.id AS id, p.title AS title\n *     FROM Projects p\n * `;\n * // \"SELECT p.id AS id, p.title AS title\\n  FROM Projects p\"\n */\nexport function sql(strings: TemplateStringsArray, ...values: Array<string | number>): string {\n  let result = \"\";\n\n  for (let i = 0; i < strings.length; i++) {\n    result += strings[i];\n    if (i < values.length) {\n      result += String(values[i]);\n    }\n  }\n\n  return dedentSql(result);\n}\n\n/**\n * Strips SQL comments and leading whitespace so the first real token can be checked\n *\n * @param query - The SQL query\n * @returns The query with leading comments and whitespace removed\n */\nfunction stripLeadingComments(query: string): string {\n  let remaining = query.trim();\n\n  // Repeatedly strip line comments (-- ...) and block comments (/* ... */)\n  while (remaining.length > 0) {\n    if (remaining.startsWith(\"--\")) {\n      const newline = remaining.indexOf(\"\\n\");\n      remaining = newline === -1 ? \"\" : remaining.slice(newline + 1).trim();\n      continue;\n    }\n\n    if (remaining.startsWith(\"/*\")) {\n      const end = remaining.indexOf(\"*/\");\n      remaining = end === -1 ? \"\" : remaining.slice(end + 2).trim();\n      continue;\n    }\n\n    break;\n  }\n\n  return remaining;\n}\n\n/**\n * Validates a view query, throwing with an actionable message when it can't work\n *\n * @param collectionName - Collection name, used in error messages\n * @param viewQuery - The SQL query to validate\n */\nexport function validateViewQuery(collectionName: string, viewQuery: unknown): asserts viewQuery is string {\n  if (typeof viewQuery !== \"string\" || viewQuery.trim() === \"\") {\n    throw new Error(\n      `View collection \"${collectionName}\" requires a non-empty viewQuery. ` +\n        `Provide the SQL SELECT statement backing the view.`\n    );\n  }\n\n  const body = stripLeadingComments(viewQuery);\n  if (!/^(select|with)\\b/i.test(body)) {\n    throw new Error(\n      `View collection \"${collectionName}\" has an invalid viewQuery: it must start with SELECT or WITH. ` +\n        `Received: ${body.slice(0, 40)}${body.length > 40 ? \"...\" : \"\"}`\n    );\n  }\n}\n\n/**\n * Defines a read-only PocketBase view collection backed by a SQL query\n *\n * PocketBase derives the collection's fields by running the query, so the Zod\n * schema only describes the shape for TypeScript types and application-side\n * parsing. Views cannot have indexes and only support listRule / viewRule.\n *\n * The generated migration creates the collection with `type: \"view\"` and the\n * query; changing the SQL later produces an in-place `viewQuery` update, which\n * keeps the collection id stable.\n *\n * @param config - View collection configuration\n * @returns The schema with view metadata attached\n *\n * @example\n * export default defineView({\n *   collectionName: \"ProjectStats\",\n *   schema: ProjectStatsSchema,\n *   viewQuery: sql`\n *     SELECT p.OwnerUser AS id,\n *            p.OwnerUser AS OwnerUser,\n *            COUNT(*)    AS projectCount\n *       FROM Projects p\n *      GROUP BY p.OwnerUser\n *   `,\n *   permissions: {\n *     listRule: \"OwnerUser = @request.auth.id\",\n *     viewRule: \"OwnerUser = @request.auth.id\",\n *   },\n * });\n *\n * @example\n * // Requirements PocketBase places on the query:\n * // - the outermost SELECT must expose an `id` column\n * // - a relation column must be selected bare (e.g. `p.OwnerUser AS OwnerUser`)\n * //   from the outer table for PocketBase to infer it as a relation field\n * // - no top-level UNION (wrap unions in a subquery)\n */\nexport function defineView(config: ViewCollectionConfig): z.ZodObject<any> {\n  const { collectionName, schema, viewQuery, permissions } = config;\n\n  validateViewQuery(collectionName, viewQuery);\n\n  return defineCollection({\n    collectionName,\n    schema,\n    type: \"view\",\n    viewQuery,\n    // Write rules are always locked for views - PocketBase rejects anything else\n    permissions: {\n      listRule: permissions?.listRule ?? null,\n      viewRule: permissions?.viewRule ?? null,\n      createRule: null,\n      updateRule: null,\n      deleteRule: null,\n    },\n  });\n}\n","import { z } from \"zod\";\n\n/**\n * Extracts the collection name from a Zod schema's metadata\n * Checks if the schema was created with defineCollection() which stores\n * the collection name in the schema description\n *\n * @param zodSchema - The Zod schema to extract collection name from\n * @returns The collection name if found in metadata, null otherwise\n */\nexport function extractCollectionNameFromSchema(zodSchema: z.ZodTypeAny): string | null {\n  if (!zodSchema.description) {\n    return null;\n  }\n\n  try {\n    const metadata = JSON.parse(zodSchema.description);\n    if (metadata.collectionName && typeof metadata.collectionName === \"string\") {\n      return metadata.collectionName;\n    }\n  } catch {\n    // Not JSON or no collectionName - this is expected for schemas without defineCollection\n  }\n\n  return null;\n}\n\n/**\n * Extracts the collection type from a Zod schema's metadata\n * Checks if the schema was created with defineCollection() which stores\n * the collection type in the schema description\n *\n * @param zodSchema - The Zod schema to extract collection type from\n * @returns The collection type (\"base\" | \"auth\" | \"view\") if found in metadata, null otherwise\n */\nexport function extractCollectionTypeFromSchema(zodSchema: z.ZodTypeAny): \"base\" | \"auth\" | \"view\" | null {\n  if (!zodSchema.description) {\n    return null;\n  }\n\n  try {\n    const metadata = JSON.parse(zodSchema.description);\n    if (metadata.type === \"base\" || metadata.type === \"auth\" || metadata.type === \"view\") {\n      return metadata.type;\n    }\n  } catch {\n    // Not JSON or no type - this is expected for schemas without explicit type\n  }\n\n  return null;\n}\n\n/**\n * Extracts the SQL query backing a view collection from a Zod schema's metadata\n * Set by defineView() (or defineCollection with type: \"view\")\n *\n * @param zodSchema - The Zod schema to extract the view query from\n * @returns The SQL query if found in metadata, null otherwise\n */\nexport function extractViewQueryFromSchema(zodSchema: z.ZodTypeAny): string | null {\n  if (!zodSchema.description) {\n    return null;\n  }\n\n  try {\n    const metadata = JSON.parse(zodSchema.description);\n    if (typeof metadata.viewQuery === \"string\") {\n      return metadata.viewQuery;\n    }\n  } catch {\n    // Not JSON or no viewQuery - expected for non-view collections\n  }\n\n  return null;\n}\n\n/**\n * A collection schema found in a module's exports\n */\nexport interface CollectionSchemaExport {\n  /** The Zod object schema carrying the collection metadata */\n  schema: z.ZodObject<any>;\n  /** The export the schema was found under (\"default\" or the named export) */\n  exportName: string;\n  /** The collection name declared in the metadata */\n  collectionName: string;\n}\n\n/**\n * Selects the collection schema from a module's exports.\n *\n * A Zod object export is a collection iff its description carries collection\n * metadata (a JSON `collectionName`), which is what defineCollection()/\n * defineView() produce. Export names carry no meaning; a default export is\n * reported as \"default\" but wins no precedence — candidates are deduplicated\n * by object reference, so `export default X; export { X }` counts once.\n *\n * @param module - The imported schema module\n * @returns The single collection export, or null when the module declares none\n * @throws Error when the module exports more than one distinct collection\n */\nexport function selectCollectionSchema(module: any): CollectionSchemaExport | null {\n  const seen = new Set<z.ZodObject<any>>();\n  const candidates: CollectionSchemaExport[] = [];\n\n  const consider = (exportName: string, value: unknown) => {\n    if (!(value instanceof z.ZodObject) || seen.has(value)) {\n      return;\n    }\n\n    const collectionName = extractCollectionNameFromSchema(value);\n    if (!collectionName) {\n      return;\n    }\n\n    seen.add(value);\n    candidates.push({ schema: value, exportName, collectionName });\n  };\n\n  consider(\"default\", module.default);\n  for (const [key, value] of Object.entries(module)) {\n    if (key !== \"default\") {\n      consider(key, value);\n    }\n  }\n\n  if (candidates.length === 0) {\n    return null;\n  }\n\n  if (candidates.length > 1) {\n    const names = candidates.map((c) => `${c.exportName} (${c.collectionName})`).join(\", \");\n    throw new Error(\n      `Multiple collection schemas exported from one file: ${names}. ` + `Define one collection per file.`\n    );\n  }\n\n  return candidates[0];\n}\n\n/**\n * Extracts field definitions from a Zod object schema\n * Filters out base schema fields (id, collectionId, created, updated, expand)\n *\n * @param zodSchema - The Zod object schema\n * @param excludeFields - Additional fields to exclude (default: base schema fields)\n * @returns Array of field names and their Zod types\n */\nexport function extractFieldDefinitions(\n  zodSchema: z.ZodObject<any>,\n  excludeFields?: string[]\n): Array<{ name: string; zodType: z.ZodTypeAny }> {\n  const shape = zodSchema.shape;\n  const fields: Array<{ name: string; zodType: z.ZodTypeAny }> = [];\n\n  // Base schema fields to exclude (these are system fields in PocketBase)\n  const baseFields = [\"id\", \"collectionId\", \"collectionName\", \"created\", \"updated\", \"expand\"];\n\n  // Combine all exclusions\n  const allExclusions = new Set([...baseFields, ...(excludeFields || [])]);\n\n  for (const [fieldName, zodType] of Object.entries(shape)) {\n    // Skip excluded fields\n    if (!allExclusions.has(fieldName)) {\n      fields.push({ name: fieldName, zodType: zodType as z.ZodTypeAny });\n    }\n  }\n\n  return fields;\n}\n\n/**\n * Extracts index definitions from a Zod schema\n * Parses the schema description metadata to find index definitions\n *\n * @param schema - Zod schema with index metadata\n * @returns Array of index SQL statements or undefined\n */\nexport function extractIndexes(schema: z.ZodTypeAny): string[] | undefined {\n  // Try to extract indexes from schema description\n  const schemaDescription = schema.description;\n\n  if (!schemaDescription) {\n    return undefined;\n  }\n\n  try {\n    const metadata = JSON.parse(schemaDescription);\n\n    // Check if indexes are present in metadata\n    if (metadata.indexes && Array.isArray(metadata.indexes)) {\n      return metadata.indexes;\n    }\n  } catch {\n    // If description is not valid JSON, return undefined\n  }\n\n  return undefined;\n}\n","import type { FieldDefinition } from \"../types\";\nimport type { MigrationGeneratorConfig } from \"./config\";\n\n/**\n * Generates a timestamp for migration filename\n * Format: Unix timestamp in seconds (e.g., 1687801090)\n *\n * @param config - Optional configuration with custom timestamp generator\n * @returns Timestamp string\n */\nexport function generateTimestamp(config?: MigrationGeneratorConfig): string {\n  if (config?.timestampGenerator) {\n    return config.timestampGenerator();\n  }\n  return Math.floor(Date.now() / 1000).toString();\n}\n\n/**\n * Increments a timestamp by 1 second\n * Ensures sequential ordering of migration files\n *\n * @param timestamp - Current timestamp string\n * @returns Incremented timestamp string\n */\nexport function incrementTimestamp(timestamp: string): string {\n  const currentTimestamp = parseInt(timestamp, 10);\n  return (currentTimestamp + 1).toString();\n}\n\n/**\n * Formats a value for JavaScript code generation\n * Handles strings, numbers, booleans, null, arrays, and objects\n *\n * @param value - Value to format\n * @returns Formatted string representation\n */\nexport function formatValue(value: any): string {\n  if (value === null || value === undefined) {\n    return \"null\";\n  }\n\n  if (typeof value === \"string\") {\n    // Use JSON.stringify to properly escape all special characters\n    return JSON.stringify(value);\n  }\n\n  if (typeof value === \"number\" || typeof value === \"boolean\") {\n    return String(value);\n  }\n\n  if (Array.isArray(value)) {\n    // Use JSON.stringify for arrays to properly handle all special characters\n    // Then format with spaces after commas to match expected test output\n    return JSON.stringify(value).replace(/\",\"/g, '\", \"');\n  }\n\n  if (typeof value === \"object\") {\n    const entries = Object.entries(value)\n      .filter(([_k, v]) => v !== undefined) // Omit undefined values\n      .map(([k, v]) => `${k}: ${formatValue(v)}`)\n      .join(\", \");\n    return `{ ${entries} }`;\n  }\n\n  return String(value);\n}\n\n/**\n * Formats a SQL view query as a JavaScript template literal\n *\n * Emitted as a backtick template (rather than a JSON string) so the SQL stays\n * readable in the generated migration. Backticks and `${` are escaped so the\n * query can never break out of the literal or be interpolated.\n *\n * @param query - The SQL query\n * @param indent - Indentation prefix applied to each line of SQL\n * @returns Template literal source, including the surrounding backticks\n */\nexport function formatSqlTemplate(query: string, indent: string = \"      \"): string {\n  const escaped = query.replace(/\\\\/g, \"\\\\\\\\\").replace(/`/g, \"\\\\`\").replace(/\\$\\{/g, \"\\\\${\");\n\n  const body = escaped\n    .split(\"\\n\")\n    .map((line) => (line.trim() === \"\" ? \"\" : `${indent}${line}`))\n    .join(\"\\n\");\n\n  return `\\`\\n${body}\\n${indent.slice(0, -2)}\\``;\n}\n\n/**\n * Gets the appropriate Field constructor name for a field type\n *\n * @param fieldType - PocketBase field type\n * @returns Field constructor name\n */\nexport function getFieldConstructorName(fieldType: string): string {\n  const constructorMap: Record<string, string> = {\n    text: \"TextField\",\n    email: \"EmailField\",\n    url: \"URLField\",\n    number: \"NumberField\",\n    bool: \"BoolField\",\n    date: \"DateField\",\n    select: \"SelectField\",\n    relation: \"RelationField\",\n    file: \"FileField\",\n    json: \"JSONField\",\n    editor: \"EditorField\",\n    autodate: \"AutodateField\",\n  };\n\n  return constructorMap[fieldType] || \"TextField\";\n}\n\n/**\n * Generates system fields that are required for all PocketBase collections\n * These fields (id, created, updated) must be explicitly included in migrations\n *\n * @returns Array of system field definitions\n */\nexport function getSystemFields(): FieldDefinition[] {\n  return [\n    // id field - primary key, auto-generated\n    {\n      name: \"id\",\n      id: \"text3208210256\",\n      type: \"text\",\n      required: true,\n      options: {\n        autogeneratePattern: \"[a-z0-9]{15}\",\n        hidden: false,\n        max: 15,\n        min: 15,\n        pattern: \"^[a-z0-9]+$\",\n        presentable: false,\n        primaryKey: true,\n        system: true,\n      },\n    },\n  ];\n}\n\n/**\n * Generates the autodate timestamp system fields (created, updated)\n * These appear at the end of every collection's field list, after user fields\n *\n * @returns Array of system timestamp field definitions\n */\nexport function getSystemTimestampFields(): FieldDefinition[] {\n  return [\n    {\n      name: \"created\",\n      id: \"autodate2990389176\",\n      type: \"autodate\",\n      required: false,\n      options: {\n        hidden: false,\n        onCreate: true,\n        onUpdate: false,\n        presentable: false,\n        system: true,\n      },\n    },\n    {\n      name: \"updated\",\n      id: \"autodate3332085495\",\n      type: \"autodate\",\n      required: false,\n      options: {\n        hidden: false,\n        onCreate: true,\n        onUpdate: true,\n        presentable: false,\n        system: true,\n      },\n    },\n  ];\n}\n\n/**\n * Generates auth-specific system fields\n *\n * @returns Array of auth system field definitions\n */\nexport function getAuthSystemFields(): FieldDefinition[] {\n  return [\n    {\n      name: \"password\",\n      id: \"password3208210256\",\n      // PocketBase stores the password as its own field type with an 8\n      // character minimum; emitting it as `text` makes PocketBase rewrite the\n      // field on apply, leaving the migration file describing a collection\n      // the server never had\n      type: \"password\",\n      required: true,\n      options: {\n        cost: 0,\n        hidden: true,\n        max: 0,\n        min: 8,\n        pattern: \"\",\n        presentable: false,\n        system: true,\n      },\n    },\n    {\n      name: \"tokenKey\",\n      id: \"tokenKey3208210256\",\n      type: \"text\",\n      required: true,\n      options: {\n        autogeneratePattern: \"[a-zA-Z0-9]{50}\",\n        hidden: true,\n        max: 60,\n        min: 30,\n        pattern: \"\",\n        presentable: false,\n        system: true,\n      },\n    },\n    {\n      name: \"email\",\n      id: \"email3208210256\",\n      type: \"email\",\n      required: true,\n      options: {\n        exceptDomains: null,\n        hidden: false,\n        onlyDomains: null,\n        presentable: false,\n        system: true,\n      },\n    },\n    {\n      name: \"emailVisibility\",\n      id: \"bool3208210256\",\n      type: \"bool\",\n      required: false,\n      options: {\n        hidden: false,\n        presentable: false,\n        system: true,\n      },\n    },\n    {\n      name: \"verified\",\n      id: \"bool1547992826\",\n      type: \"bool\",\n      required: false,\n      options: {\n        hidden: false,\n        presentable: false,\n        system: true,\n      },\n    },\n  ];\n}\n\n/**\n * Generates default system indexes for auth collections\n *\n * PocketBase names these after the collection they belong to\n * (`idx_tokenKey_<collectionId>`). SQLite index names are database-wide, so\n * the suffix has to vary per collection — a fixed one makes a second auth\n * collection fail to apply with \"index ... already exists\".\n *\n * @param collectionName - Name of the auth collection\n * @param collectionId - Id of the auth collection; falls back to its name\n * @returns Array of index SQL statements\n */\nexport function getAuthSystemIndexes(collectionName: string, collectionId?: string): string[] {\n  const suffix = collectionId || collectionName;\n\n  return [\n    `CREATE UNIQUE INDEX \\`idx_tokenKey_${suffix}\\` ON \\`${collectionName}\\` (\\`tokenKey\\`)`,\n    `CREATE UNIQUE INDEX \\`idx_email_${suffix}\\` ON \\`${collectionName}\\` (\\`email\\`) WHERE \\`email\\` != ''`,\n  ];\n}\n\n/**\n * Generates the code to find a collection by ID if available, otherwise by name\n *\n * @param name - Collection name\n * @param collectionIdMap - Map of collection names to IDs\n * @returns Code string like `app.findCollectionByNameOrId(\"id\") // name` or `app.findCollectionByNameOrId(\"name\")`\n */\nexport function generateFindCollectionCode(name: string, collectionIdMap?: Map<string, string>): string {\n  if (collectionIdMap && collectionIdMap.has(name)) {\n    const id = collectionIdMap.get(name);\n    return `app.findCollectionByNameOrId(\"${id}\") // ${name}`;\n  }\n  return `app.findCollectionByNameOrId(\"${name}\")`;\n}\n","import { z } from \"zod\";\nimport { extractRelationMetadata } from \"../../schema/base\";\nimport { extractFieldMetadata } from \"../../schema/fields\";\nimport type { PermissionSchema } from \"../../utils/permissions\";\nimport { PermissionAnalyzer } from \"../permission-analyzer\";\nimport type { PocketBaseFieldType } from \"../../schema/fields\";\nimport type { CollectionSchema, FieldDefinition } from \"../types\";\nimport {\n  extractFieldOptions,\n  filterSupportedFieldOptions,\n  isFieldRequired,\n  mapZodTypeToPocketBase,\n  POCKETBASE_FIELD_TYPES,\n  unwrapZodType,\n} from \"../utils/type-mapper\";\nimport { validateViewQuery } from \"../../schema/view\";\nimport {\n  extractCollectionTypeFromSchema,\n  extractFieldDefinitions,\n  extractIndexes,\n  extractViewQueryFromSchema,\n} from \"./extractors\";\nimport { generateFieldId } from \"../utils/collection-id-generator.js\";\nimport { getAuthSystemFields } from \"../generator/utils\";\n\n/**\n * Builds a field definition from a Zod type.\n *\n * Precedence: explicit `__pocketbase_field__` metadata (strong contract from\n * the field helpers), then `__pocketbase_relation__` metadata (RelationField/\n * RelationsField), then the loose structural mapping of plain Zod types.\n * Field names carry no meaning — there is no name-based inference.\n *\n * Field ids are never diffed: the diff matches fields by name and every\n * mutation the generator emits addresses fields by name (getByName /\n * removeByName). The id's type prefix is therefore purely cosmetic and hashes\n * the settled type.\n *\n * @param fieldName - The field name\n * @param zodType - The Zod type\n * @returns Field definition with constraints\n */\nexport function buildFieldDefinition(fieldName: string, zodType: z.ZodTypeAny): FieldDefinition {\n  // Check for explicit field metadata first (from field helper functions)\n  const unwrappedType = unwrapZodType(zodType);\n  const fieldMetadata = extractFieldMetadata(unwrappedType.description ?? zodType.description);\n\n  if (fieldMetadata) {\n    // A malformed strong contract is an error, not a fallthrough to guessing\n    if (!fieldMetadata.type || !POCKETBASE_FIELD_TYPES.includes(fieldMetadata.type as PocketBaseFieldType)) {\n      throw new Error(\n        `Field \"${fieldName}\" carries __pocketbase_field__ metadata with unknown type \"${fieldMetadata.type}\". ` +\n          `Use one of: ${POCKETBASE_FIELD_TYPES.join(\", \")}.`\n      );\n    }\n    // Use explicit metadata from field helpers\n    // For number fields, default to required: false unless explicitly set\n    // (because required: true in PocketBase means non-zero, which is often not desired)\n    let required: boolean;\n    if (fieldMetadata.type === \"number\") {\n      // Check if required is explicitly set in options\n      if (fieldMetadata.options?.required !== undefined) {\n        required = fieldMetadata.options.required;\n      } else {\n        // Default to false for number fields to allow zero values\n        // This allows zero values (e.g., progress: 0-100) unless explicitly set to required: true\n        required = false;\n      }\n    } else {\n      // For other field types, use standard logic\n      required = isFieldRequired(zodType);\n    }\n\n    // Remove 'required' from options if present (it's a top-level property, not an option)\n    const { required: _required, ...metadataOptions } = fieldMetadata.options || {};\n\n    // A validator chained onto a field helper (`TextField().max(60)`, or a\n    // shared rule reused with `.regex(...)`) states the same constraint as the\n    // helper's own options, so both are read. The helper wins where they\n    // overlap: its options are what the caller wrote for PocketBase.\n    const options = { ...extractChainedFieldOptions(fieldMetadata.type, unwrappedType), ...metadataOptions };\n\n    const fieldDef: FieldDefinition = {\n      name: fieldName,\n      id: generateFieldId(fieldMetadata.type, fieldName),\n      type: fieldMetadata.type,\n      required,\n      options: filterSupportedFieldOptions(fieldMetadata.type, Object.keys(options).length > 0 ? options : undefined),\n      zodType: zodType,\n    };\n\n    // If it's a relation type from metadata, we still need to extract relation config\n    if (fieldMetadata.type === \"relation\") {\n      const relationMetadata = extractRelationMetadata(unwrappedType.description ?? zodType.description);\n      if (relationMetadata) {\n        fieldDef.relation = {\n          collection: relationMetadata.collection,\n          maxSelect: relationMetadata.maxSelect,\n          minSelect: relationMetadata.minSelect,\n          cascadeDelete: relationMetadata.cascadeDelete,\n          displayFields: relationMetadata.displayFields,\n        };\n      }\n    }\n\n    return fieldDef;\n  }\n\n  // Explicit relation metadata (from RelationField()/RelationsField() helpers)\n  const relationMetadata = extractRelationMetadata(unwrappedType.description ?? zodType.description);\n\n  if (relationMetadata) {\n    return {\n      name: fieldName,\n      id: generateFieldId(\"relation\", fieldName),\n      type: \"relation\",\n      required: isFieldRequired(zodType),\n      // Zod validators on the field (array min/max etc.) are already captured\n      // in the relation metadata; the field itself carries no options\n      options: undefined,\n      zodType: zodType,\n      relation: {\n        collection: relationMetadata.collection,\n        maxSelect: relationMetadata.maxSelect,\n        minSelect: relationMetadata.minSelect,\n        cascadeDelete: relationMetadata.cascadeDelete,\n        displayFields: relationMetadata.displayFields,\n      },\n    };\n  }\n\n  // Loose structural contract: map plain Zod types by structure only\n  const fieldType = mapZodTypeToPocketBase(zodType);\n  const required = isFieldRequired(zodType);\n  const options = extractFieldOptions(zodType);\n\n  const fieldDef: FieldDefinition = {\n    name: fieldName,\n    id: generateFieldId(fieldType, fieldName),\n    type: fieldType,\n    required,\n    options,\n    zodType: zodType,\n  };\n\n  // Special handling for autodate fields\n  if (fieldDef.type === \"autodate\") {\n    // Autodate fields shouldn't have pattern or other string options\n    // and should have onCreate/onUpdate set by default\n    fieldDef.options = {\n      onCreate: true,\n      onUpdate: true,\n      ...(fieldDef.options || {}),\n    };\n    // Remove options that don't apply to autodate\n    delete fieldDef.options.pattern;\n    delete fieldDef.options.min;\n    delete fieldDef.options.max;\n  }\n\n  // Zod validators are richer than PocketBase's option set, so the\n  // unsupported leftovers are dropped last\n  fieldDef.options = filterSupportedFieldOptions(fieldDef.type, fieldDef.options);\n\n  return fieldDef;\n}\n\n/**\n * Field types whose PocketBase options mean the same thing as the Zod\n * validators they are read from.\n *\n * The rest are excluded because the same validator says something else there: a\n * `date` field is spelled as a Zod string, so `.min()` on it is a *length*, not\n * an earliest date, and `autodate`/`editor`/`json` carry no constraint\n * PocketBase would store. Reading those would invent options the schema never\n * declared.\n */\nconst TYPES_READING_CHAINED_VALIDATORS = new Set([\"text\", \"password\", \"number\", \"select\", \"file\"]);\n\n/**\n * Reads the options a field helper's Zod validators declare, for the field\n * types where the two line up.\n *\n * `TextField()` records what was passed to it, which leaves anything chained\n * afterwards (`TextField().max(60).regex(...)`, or a reusable rule the helper\n * wraps) visible only in the Zod schema.\n *\n * @param fieldType - The PocketBase field type from the helper's metadata\n * @param unwrappedType - The Zod type with optional/default/nullable removed\n * @returns The options the validators declare, empty when the type opts out\n */\nfunction extractChainedFieldOptions(fieldType: string, unwrappedType: z.ZodTypeAny): Record<string, any> {\n  if (!TYPES_READING_CHAINED_VALIDATORS.has(fieldType)) {\n    return {};\n  }\n\n  return extractFieldOptions(unwrappedType);\n}\n\n/**\n * Converts a Zod schema to a CollectionSchema interface\n *\n * @param collectionName - The name of the collection\n * @param zodSchema - The Zod object schema\n * @returns CollectionSchema definition\n */\nexport function convertZodSchemaToCollectionSchema(\n  collectionName: string,\n  zodSchema: z.ZodObject<any>\n): CollectionSchema {\n  // Extract field definitions from Zod schema\n  const rawFields = extractFieldDefinitions(zodSchema);\n\n  // Determine collection type: explicit metadata only, defaulting to \"base\".\n  // Auth collections must declare type: \"auth\" in defineCollection().\n  const explicitType = extractCollectionTypeFromSchema(zodSchema);\n  const collectionType = explicitType ?? \"base\";\n  const isView = collectionType === \"view\";\n\n  // View collections are backed by SQL - the query is required\n  const viewQuery = extractViewQueryFromSchema(zodSchema);\n  if (isView) {\n    validateViewQuery(collectionName, viewQuery);\n  } else if (viewQuery !== null) {\n    console.warn(\n      `[${collectionName}] viewQuery is only used by view collections and will be ignored. ` +\n        `Use defineView() or set type: \"view\" to define a view collection.`\n    );\n  }\n\n  // Build field definitions with constraints\n  const fields: FieldDefinition[] = rawFields\n    // Explicitly filter out system fields that might have slipped through\n    // This can happen if the schema was constructed manually without base schema\n    .filter((f) => ![\"created\", \"updated\"].includes(f.name))\n    .map(({ name, zodType }) => buildFieldDefinition(name, zodType));\n\n  // Ensure auth system fields exist for auth collections\n  if (collectionType === \"auth\") {\n    // These fields are required for auth collections and should match the\n    // native CLI output. The generator writes its own definitions for them\n    // (getAuthSystemFields), so taking the options from the same place keeps\n    // the analyzed schema equal to what replaying the generated migration\n    // reads back — otherwise every run re-emits the same field modifications\n    const authSystemFields = getAuthSystemFields();\n\n    // Add or update auth fields\n    for (const authField of authSystemFields) {\n      const existingFieldIndex = fields.findIndex((f) => f.name === authField.name);\n\n      if (existingFieldIndex !== -1) {\n        // Update existing field to ensure correct type and required status\n        const existingField = fields[existingFieldIndex];\n\n        // Merge options: defaults -> existing -> forced overrides (none currently)\n        // We want to ensure specific options like min/max match defaults if not set\n        const mergedOptions = { ...authField.options, ...existingField.options };\n\n        fields[existingFieldIndex] = {\n          ...existingField,\n          type: authField.type, // Force correct type (e.g. 'text' -> 'password')\n          required: authField.required, // Force correct required status\n          options: mergedOptions,\n        };\n      } else {\n        // Add missing field\n        fields.push({\n          name: authField.name,\n          id: generateFieldId(authField.type, authField.name),\n          type: authField.type,\n          required: authField.required,\n          options: authField.options,\n        });\n      }\n    }\n  }\n\n  // Extract indexes from schema\n  // View collections cannot have indexes - PocketBase rejects them\n  const indexes = extractIndexes(zodSchema) || [];\n  if (isView && indexes.length > 0) {\n    throw new Error(\n      `View collection \"${collectionName}\" cannot declare indexes. ` +\n        `PocketBase view collections are backed by a SQL query and do not support indexes.`\n    );\n  }\n\n  // Extract and validate permissions from schema\n  const permissionAnalyzer = new PermissionAnalyzer();\n  let permissions: PermissionSchema | undefined = undefined;\n\n  // Try to extract permissions from schema description\n  const schemaDescription = zodSchema.description;\n  const extractedPermissions = permissionAnalyzer.extractPermissions(schemaDescription);\n\n  if (extractedPermissions) {\n    // Resolve template configurations to concrete rules\n    const resolvedPermissions = permissionAnalyzer.resolvePermissions(extractedPermissions);\n\n    // View collections are read-only - warn and drop any write rules\n    if (isView) {\n      for (const ruleType of [\"createRule\", \"updateRule\", \"deleteRule\", \"manageRule\"] as const) {\n        if (resolvedPermissions[ruleType]) {\n          console.warn(\n            `[${collectionName}] ${ruleType} is not supported on view collections and will be set to null.`\n          );\n        }\n        resolvedPermissions[ruleType] = null;\n      }\n    }\n\n    // Validate permissions against collection fields\n    // Skipped for views: their real fields come from the SQL query, so field\n    // references in the rules can't be checked against the Zod shape\n    if (!isView) {\n      const validationResults = permissionAnalyzer.validatePermissions(\n        collectionName,\n        resolvedPermissions,\n        fields,\n        collectionType === \"auth\"\n      );\n\n      // Log validation errors and warnings\n      for (const [ruleType, result] of validationResults) {\n        if (!result.valid) {\n          console.error(`[${collectionName}] Permission validation failed for ${ruleType}:`);\n          result.errors.forEach((error) => console.error(`  - ${error}`));\n        }\n\n        if (result.warnings.length > 0) {\n          console.warn(`[${collectionName}] Permission warnings for ${ruleType}:`);\n          result.warnings.forEach((warning) => console.warn(`  - ${warning}`));\n        }\n      }\n    }\n\n    // Merge with defaults to ensure all rules are defined\n    permissions = permissionAnalyzer.mergeWithDefaults(resolvedPermissions);\n  }\n\n  // Build collection schema\n  // Use extracted permissions for rules, falling back to nulls\n  const collectionSchema: CollectionSchema = {\n    name: collectionName,\n    type: collectionType,\n    fields,\n    indexes,\n    rules: {\n      listRule: permissions?.listRule ?? null,\n      viewRule: permissions?.viewRule ?? null,\n      createRule: permissions?.createRule ?? null,\n      updateRule: permissions?.updateRule ?? null,\n      deleteRule: permissions?.deleteRule ?? null,\n      // Omit manageRule for base collections to match native CLI behavior\n      manageRule: collectionType === \"auth\" ? (permissions?.manageRule ?? null) : undefined,\n    },\n    permissions,\n  };\n\n  if (isView) {\n    collectionSchema.viewQuery = viewQuery as string;\n  }\n\n  return collectionSchema;\n}\n","import * as fs from \"fs\";\nimport * as path from \"path\";\nimport { FileSystemError, SchemaParsingError } from \"../errors\";\nimport { mergeConfig, resolveSchemaDir, type SchemaAnalyzerConfig } from \"./config\";\n\n// Register tsx loader for TypeScript file support\n// This allows dynamic imports of .ts files to work\nlet tsxLoaderRegistered = false;\nasync function ensureTsxLoader(): Promise<void> {\n  if (tsxLoaderRegistered) return;\n\n  try {\n    // Import tsx/esm to register the TypeScript loader hooks\n    // This enables dynamic imports of .ts files in Node.js ESM\n    await import(\"tsx/esm\");\n    tsxLoaderRegistered = true;\n  } catch {\n    // tsx is not available - will handle in importSchemaModule\n    tsxLoaderRegistered = false;\n  }\n}\n\n/**\n * Discovers schema files in the specified directory\n * Filters based on configuration patterns\n *\n * @param config - Schema analyzer configuration\n * @returns Array of schema file paths (without extension)\n */\nexport function discoverSchemaFiles(config: SchemaAnalyzerConfig): string[] {\n  const mergedConfig = mergeConfig(config);\n  const schemaDir = resolveSchemaDir(config);\n\n  try {\n    if (!fs.existsSync(schemaDir)) {\n      throw new FileSystemError(`Schema directory not found: ${schemaDir}`, schemaDir, \"access\", \"ENOENT\");\n    }\n\n    const files = fs.readdirSync(schemaDir);\n\n    // Pre-compile exclusion patterns to regexes for performance\n    const excludeMatchers = mergedConfig.excludePatterns.map((pattern) => {\n      if (pattern.includes(\"*\")) {\n        return new RegExp(\"^\" + pattern.replace(/\\*/g, \".*\") + \"$\");\n      }\n      return pattern; // For exact match\n    });\n\n    // Filter files based on configuration\n    const schemaFiles = files.filter((file) => {\n      // Check extension\n      const hasValidExtension = mergedConfig.includeExtensions.some((ext) => file.endsWith(ext));\n      if (!hasValidExtension) return false;\n\n      // Check exclusion patterns\n      const isExcluded = excludeMatchers.some((matcher) => {\n        if (typeof matcher === \"string\") {\n          return file === matcher;\n        }\n        return matcher.test(file); // It's a regex\n      });\n      if (isExcluded) return false;\n\n      return true;\n    });\n\n    // Create a single regex to remove any of the valid extensions, escaping special characters\n    const extensionRemovalRegex = new RegExp(\n      `(${mergedConfig.includeExtensions.map((ext) => ext.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")).join(\"|\")})$`\n    );\n\n    // Return full paths without extension (for dynamic import)\n    return schemaFiles.map((file) => {\n      return path.join(schemaDir, file.replace(extensionRemovalRegex, \"\"));\n    });\n  } catch (error) {\n    if (error instanceof FileSystemError) {\n      throw error;\n    }\n\n    const fsError = error as NodeJS.ErrnoException;\n    if (fsError.code === \"EACCES\" || fsError.code === \"EPERM\") {\n      throw new FileSystemError(\n        `Permission denied reading schema directory: ${schemaDir}`,\n        schemaDir,\n        \"read\",\n        fsError.code,\n        error as Error\n      );\n    }\n\n    throw new FileSystemError(\n      `Failed to read schema directory: ${schemaDir}`,\n      schemaDir,\n      \"read\",\n      fsError.code,\n      error as Error\n    );\n  }\n}\n\n/**\n * Dynamically imports a schema module\n * Supports both JavaScript and TypeScript files using tsx\n *\n * @param filePath - Path to the schema file (without extension)\n * @param config - Optional configuration for path transformation\n * @returns The imported module\n */\nexport async function importSchemaModule(filePath: string, config?: SchemaAnalyzerConfig): Promise<any> {\n  try {\n    let importPath = filePath;\n\n    // Apply path transformation if provided\n    if (config?.pathTransformer) {\n      importPath = config.pathTransformer(filePath);\n    }\n\n    // Determine the file extension to use\n    // Try .js first (for compiled files), then .ts (for source files)\n    let resolvedPath: string | null = null;\n    const jsPath = `${importPath}.js`;\n    const tsPath = `${importPath}.ts`;\n\n    if (fs.existsSync(jsPath)) {\n      resolvedPath = jsPath;\n    } else if (fs.existsSync(tsPath)) {\n      resolvedPath = tsPath;\n    } else {\n      // Default to .js extension for ESM import\n      resolvedPath = jsPath;\n    }\n\n    // If it's a TypeScript file, ensure tsx loader is registered\n    if (resolvedPath.endsWith(\".ts\")) {\n      await ensureTsxLoader();\n\n      // Check if tsx was successfully registered\n      if (!tsxLoaderRegistered) {\n        throw new SchemaParsingError(\n          `Failed to import TypeScript schema file. The 'tsx' package is required to load TypeScript files.\\n` +\n            `Please install tsx: npm install tsx (or yarn add tsx, or pnpm add tsx)\\n` +\n            `Alternatively, compile your schema files to JavaScript first.`,\n          filePath\n        );\n      }\n    }\n\n    // Convert to file URL for proper ESM import\n    const fileUrl = new URL(`file://${path.resolve(resolvedPath)}`);\n\n    // Use dynamic import to load the module\n    // tsx/esm will handle TypeScript files automatically if registered\n    const module = await import(fileUrl.href);\n    return module;\n  } catch (error) {\n    // Check if we're trying to import a TypeScript file\n    const tsPath = `${filePath}.ts`;\n    const isTypeScriptFile = fs.existsSync(tsPath);\n\n    if (isTypeScriptFile && error instanceof SchemaParsingError) {\n      // Re-throw SchemaParsingError as-is (already has helpful message)\n      throw error;\n    }\n\n    if (isTypeScriptFile) {\n      throw new SchemaParsingError(\n        `Failed to import TypeScript schema file. The 'tsx' package is required to load TypeScript files.\\n` +\n          `Please install tsx: npm install tsx (or yarn add tsx, or pnpm add tsx)\\n` +\n          `Alternatively, compile your schema files to JavaScript first.`,\n        filePath,\n        error as Error\n      );\n    }\n\n    throw new SchemaParsingError(\n      `Failed to import schema module. Make sure the schema files exist and are valid.`,\n      filePath,\n      error as Error\n    );\n  }\n}\n","/**\n * Schema Analyzer - Parses Zod schemas and extracts field definitions\n *\n * This module provides a standalone, configurable schema analyzer that can be used\n * by consumer projects to parse Zod schemas and convert them to PocketBase collection schemas.\n */\n\nimport * as fs from \"fs\";\nimport { SchemaParsingError } from \"../errors\";\nimport type { CollectionSchema, SchemaDefinition } from \"../types\";\nimport { mergeConfig, resolveSchemaDir, type SchemaAnalyzerConfig } from \"./config\";\nimport { convertZodSchemaToCollectionSchema } from \"./converter\";\nimport { selectCollectionSchema } from \"./extractors\";\nimport { discoverSchemaFiles, importSchemaModule } from \"./loader\";\n\n// Curated submodule surface — config internals (mergeConfig, DEFAULT_CONFIG,\n// resolveSchemaDir) stay module-private\nexport { type SchemaAnalyzerConfig } from \"./config\";\nexport { buildFieldDefinition, convertZodSchemaToCollectionSchema } from \"./converter\";\nexport {\n  extractCollectionNameFromSchema,\n  extractCollectionTypeFromSchema,\n  extractFieldDefinitions,\n  extractIndexes,\n  extractViewQueryFromSchema,\n  selectCollectionSchema,\n  type CollectionSchemaExport,\n} from \"./extractors\";\nexport { discoverSchemaFiles, importSchemaModule } from \"./loader\";\n\n/**\n * Parses schema files and returns a SchemaDefinition\n * Main entry point for the Schema Analyzer\n *\n * A file contributes a collection iff one of its exports is a Zod object\n * whose description carries collection metadata (what defineCollection()/\n * defineView() produce). Files without such an export are skipped with a\n * warning; a file with more than one, or two files declaring the same\n * collection name, are errors.\n *\n * @param config - Schema analyzer configuration\n * @returns Complete SchemaDefinition with all collections\n */\nexport async function parseSchemaFiles(config: SchemaAnalyzerConfig): Promise<SchemaDefinition> {\n  const mergedConfig = mergeConfig(config);\n  const collections = new Map<string, CollectionSchema>();\n  const collectionSources = new Map<string, string>();\n\n  // Discover schema files\n  const schemaFiles = discoverSchemaFiles(config);\n\n  if (schemaFiles.length === 0) {\n    const schemaDir = resolveSchemaDir(config);\n    throw new SchemaParsingError(\n      `No schema files found in ${schemaDir}. Make sure you have schema files in the directory.`,\n      schemaDir\n    );\n  }\n\n  // Process each schema file\n  for (const filePath of schemaFiles) {\n    try {\n      let importPath = filePath;\n\n      // Apply path transformation if provided (for monorepo setups)\n      if (config.pathTransformer) {\n        importPath = config.pathTransformer(filePath);\n      } else if (mergedConfig.useCompiledFiles) {\n        // Default transformation: convert /src/ to /dist/ for compiled files\n        // This is a common pattern but can be overridden with pathTransformer\n        const distPath = filePath.replace(/\\/src\\//, \"/dist/\");\n        // Only use dist path if it actually exists (i.e., files are compiled)\n        // Otherwise, fall back to source path for TypeScript files\n        if (fs.existsSync(`${distPath}.js`) || fs.existsSync(`${distPath}.mjs`)) {\n          importPath = distPath;\n        } else {\n          // Files aren't compiled, use source path\n          importPath = filePath;\n        }\n      }\n\n      // Import the module\n      const module = await importSchemaModule(importPath, config);\n\n      // Find the export carrying collection metadata\n      const collectionExport = selectCollectionSchema(module);\n\n      if (!collectionExport) {\n        console.warn(\n          `${filePath}: no export carries collection metadata (use defineCollection()/defineView()); skipping. ` +\n            `If this file previously produced a collection, the diff may now propose deleting it.`\n        );\n        continue;\n      }\n\n      const { collectionName, schema } = collectionExport;\n\n      // Two files declaring the same collection would silently overwrite each\n      // other in the map — surface it instead\n      const existingSource = collectionSources.get(collectionName);\n      if (existingSource) {\n        throw new SchemaParsingError(\n          `Collection \"${collectionName}\" is declared in both ${existingSource} and ${filePath}. ` +\n            `Collection names must be unique across schema files.`,\n          filePath\n        );\n      }\n\n      // Convert to CollectionSchema\n      const collectionSchema = convertZodSchemaToCollectionSchema(collectionName, schema);\n\n      // Add to collections map\n      collections.set(collectionName, collectionSchema);\n      collectionSources.set(collectionName, filePath);\n    } catch (error) {\n      // If it's already a SchemaParsingError, re-throw it\n      if (error instanceof SchemaParsingError) {\n        throw error;\n      }\n\n      // Otherwise, wrap it in a SchemaParsingError\n      throw new SchemaParsingError(\n        `Error processing schema file: ${error instanceof Error ? error.message : String(error)}`,\n        filePath,\n        error as Error\n      );\n    }\n  }\n\n  return { collections };\n}\n","/**\n * Runtime field constructors matching the PocketBase JSVM globals\n *\n * In the PocketBase JSVM, migrations construct fields via `new Field({...})`\n * or typed constructors like `new TextField({...})`. Instances are plain\n * mutable objects; migrations freely assign properties after construction\n * (e.g. `field.max = 500`).\n *\n * The constructors deliberately add no default properties beyond `type`:\n * the resulting state must match what the migration file literally declares,\n * the same data the literal declares, materialized as a real object.\n */\n\n/**\n * Generic field constructor: `new Field({type: \"number\", ...})`.\n * PocketBase's own generated migrations use this form with an explicit type.\n */\nexport class Field {\n  [key: string]: any;\n\n  constructor(data: Record<string, any> = {}) {\n    Object.assign(this, data);\n  }\n}\n\nfunction typedField(type: string): new (data?: Record<string, any>) => Field {\n  return class extends Field {\n    constructor(data: Record<string, any> = {}) {\n      super({ type, ...data });\n    }\n  };\n}\n\n// One constructor per PocketBase field type (see POCKETBASE_FIELD_TYPES)\nexport const TextField = typedField(\"text\");\nexport const EmailField = typedField(\"email\");\nexport const URLField = typedField(\"url\");\nexport const NumberField = typedField(\"number\");\nexport const BoolField = typedField(\"bool\");\nexport const DateField = typedField(\"date\");\nexport const SelectField = typedField(\"select\");\nexport const RelationField = typedField(\"relation\");\nexport const FileField = typedField(\"file\");\nexport const JSONField = typedField(\"json\");\nexport const EditorField = typedField(\"editor\");\nexport const GeoPointField = typedField(\"geoPoint\");\nexport const AutodateField = typedField(\"autodate\");\nexport const PasswordField = typedField(\"password\");\n\nexport const FIELD_CONSTRUCTORS: Record<string, new (data?: Record<string, any>) => Field> = {\n  Field,\n  TextField,\n  EmailField,\n  URLField,\n  NumberField,\n  BoolField,\n  DateField,\n  SelectField,\n  RelationField,\n  FileField,\n  JSONField,\n  EditorField,\n  GeoPointField,\n  AutodateField,\n  PasswordField,\n};\n\n/** crc32 (IEEE polynomial), lazily tabulated */\nlet crcTable: Uint32Array | null = null;\n\nfunction crc32(input: string): number {\n  if (!crcTable) {\n    crcTable = new Uint32Array(256);\n    for (let i = 0; i < 256; i++) {\n      let c = i;\n      for (let bit = 0; bit < 8; bit++) {\n        c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;\n      }\n      crcTable[i] = c >>> 0;\n    }\n  }\n\n  let crc = 0xffffffff;\n  for (const byte of new TextEncoder().encode(input)) {\n    crc = crcTable[(crc ^ byte) & 0xff] ^ (crc >>> 8);\n  }\n  return (crc ^ 0xffffffff) >>> 0;\n}\n\n/**\n * The id PocketBase gives a field that is added without one: its type\n * followed by crc32 of its name, as an unsigned decimal. Verified against the\n * ids PocketBase writes for the auth system fields — `password901924565`,\n * `text2504183744` (tokenKey), `email3885137012`, `bool1547992806`\n * (emailVisibility), `bool256245529` (verified), `text3208210256` (id).\n *\n * The formula has to match exactly, not just look plausible: `FieldsList.add()`\n * uses the derived id to decide whether an incoming field *replaces* an\n * existing one, so a random suffix silently turns a field rewrite into a\n * duplicate field.\n */\nexport function generateRuntimeFieldId(type: string, name: string): string {\n  return `${type || \"field\"}${crc32(name)}`;\n}\n","/**\n * FieldsList — runtime equivalent of a PocketBase collection's `fields`\n *\n * Mirrors the methods the JSVM exposes on `collection.fields`:\n * add / addAt / removeById / removeByName / getById / getByName, plus\n * read-side iteration. Field entries are live objects — mutations through\n * getByName() are visible when the collection is saved, exactly like the\n * generator's `const f = collection.fields.getByName(\"x\"); f.max = 500;`\n * output expects.\n */\n\nimport { Field, generateRuntimeFieldId } from \"./fields\";\n\nexport class FieldsList {\n  private items: Field[] = [];\n\n  constructor(fields?: any[]) {\n    if (Array.isArray(fields)) {\n      this.add(...fields);\n    }\n  }\n\n  get length(): number {\n    return this.items.length;\n  }\n\n  /**\n   * Appends fields; a field that matches an existing entry replaces it in\n   * place (position preserved), matching PocketBase upsert semantics.\n   */\n  add(...fields: any[]): void {\n    for (const raw of fields) {\n      const { field, existing } = this.resolveIncoming(raw);\n      if (existing >= 0) {\n        this.items[existing] = field;\n      } else {\n        this.items.push(field);\n      }\n    }\n  }\n\n  /**\n   * Inserts fields at a position. A field matching an already-present entry is\n   * moved: the old entry is removed first, then the field is inserted at\n   * the requested position.\n   */\n  addAt(position: number, ...fields: any[]): void {\n    let insertAt = Math.max(0, Math.min(position, this.items.length));\n    for (const raw of fields) {\n      const { field, existing } = this.resolveIncoming(raw);\n      if (existing >= 0) {\n        this.items.splice(existing, 1);\n        if (existing < insertAt) {\n          insertAt--;\n        }\n      }\n      insertAt = Math.max(0, Math.min(insertAt, this.items.length));\n      this.items.splice(insertAt, 0, field);\n      insertAt++;\n    }\n  }\n\n  /**\n   * Materializes an incoming field and locates the entry it replaces.\n   *\n   * PocketBase's rule (documented on `FieldsList.Add` in types.d.ts): match by\n   * id, \"or by their name if the new field doesn't have an explicit id\", and\n   * autogenerate a missing id from the name. Matching by id alone turns the\n   * idiomatic `fields.add(new TextField({name: \"title\", max: 500}))` — no id,\n   * meant to rewrite `title` — into a second field also called `title`, which\n   * PocketBase would reject on save but the engine used to accept, corrupting\n   * the reconstructed state.\n   *\n   * On a name match the *existing* id is kept rather than replaced with the\n   * derived one. For a collection PocketBase authored the two are identical\n   * (its auto-ids already are `<type><crc32(name)>`); they diverge only when\n   * the stored field carries a hand-assigned id, and there preserving it keeps\n   * a later `removeById`/`getById` in the same migration working.\n   */\n  private resolveIncoming(raw: any): { field: Field; existing: number } {\n    const field = raw instanceof Field ? raw : new Field(raw);\n    const hasExplicitId = typeof field.id === \"string\" && field.id !== \"\";\n\n    if (hasExplicitId) {\n      return { field, existing: this.indexOfId(field.id) };\n    }\n\n    const existing = this.items.findIndex((f) => f.name === field.name);\n    field.id =\n      existing >= 0\n        ? this.items[existing].id\n        : generateRuntimeFieldId(\n            typeof field.type === \"string\" ? field.type : \"\",\n            typeof field.name === \"string\" ? field.name : \"\"\n          );\n    return { field, existing };\n  }\n\n  removeById(id: string): void {\n    const index = this.indexOfId(id);\n    if (index >= 0) {\n      this.items.splice(index, 1);\n    }\n  }\n\n  removeByName(name: string): void {\n    const index = this.items.findIndex((f) => f.name === name);\n    if (index >= 0) {\n      this.items.splice(index, 1);\n    }\n  }\n\n  /**\n   * Null rather than undefined for a miss: these two return a Go `Field`\n   * interface, and goja surfaces a nil interface to JavaScript as `null`. A\n   * migration written as `if (collection.fields.getByName(\"x\") === null)` has\n   * to take the same branch here as it does in production.\n   */\n  getById(id: string): Field | null {\n    const index = this.indexOfId(id);\n    return index >= 0 ? this.items[index] : null;\n  }\n\n  getByName(name: string): Field | null {\n    return this.items.find((f) => f.name === name) ?? null;\n  }\n\n  at(index: number): Field | undefined {\n    return this.items.at(index);\n  }\n\n  find(predicate: (field: Field, index: number) => boolean): Field | undefined {\n    return this.items.find(predicate);\n  }\n\n  filter(predicate: (field: Field, index: number) => boolean): Field[] {\n    return this.items.filter(predicate);\n  }\n\n  map<T>(mapper: (field: Field, index: number) => T): T[] {\n    return this.items.map(mapper);\n  }\n\n  forEach(callback: (field: Field, index: number) => void): void {\n    this.items.forEach(callback);\n  }\n\n  [Symbol.iterator](): Iterator<Field> {\n    return this.items[Symbol.iterator]();\n  }\n\n  /** Replaces the whole list (used by unmarshal({fields: [...]}, collection)) */\n  replaceAll(fields: any[]): void {\n    this.items = [];\n    this.add(...fields);\n  }\n\n  /**\n   * Plain objects, in order — copied deeply, so option arrays like a select\n   * field's `values` are not shared with the live list. A shallow spread let a\n   * snapshot handed to the diff engine alias engine state, where an in-place\n   * sort or push downstream would silently rewrite the collection it came from.\n   */\n  serialize(): Record<string, any>[] {\n    return this.items.map((field) => copyPlainData({ ...field }) as Record<string, any>);\n  }\n\n  private indexOfId(id: unknown): number {\n    if (typeof id !== \"string\" || id === \"\") {\n      return -1;\n    }\n    return this.items.findIndex((f) => f.id === id);\n  }\n}\n\n/**\n * Deep copy of arrays and plain objects; anything else (including a function a\n * migration parked on a field) passes through by reference rather than\n * throwing, which is what structuredClone would do.\n */\nfunction copyPlainData(value: unknown): unknown {\n  if (Array.isArray(value)) {\n    return value.map(copyPlainData);\n  }\n  if (value !== null && typeof value === \"object\" && !(value instanceof Date)) {\n    const prototype = Object.getPrototypeOf(value);\n    if (prototype === Object.prototype || prototype === null) {\n      const copy: Record<string, unknown> = {};\n      for (const [key, entry] of Object.entries(value)) {\n        copy[key] = copyPlainData(entry);\n      }\n      return copy;\n    }\n  }\n  return value;\n}\n","/**\n * Runtime Collection class matching the PocketBase JSVM global\n *\n * `new Collection({...})` in a migration produces one of these. All data\n * properties are copied verbatim (auth options, templates, etc. survive a\n * snapshot import round-trip); `fields` becomes a live FieldsList and\n * `indexes` a real array so `push`/`findIndex`/`splice` work natively.\n *\n * No rule properties are defaulted: the serialized collection must contain\n * exactly what the migration declared, so engine output stays byte-parity\n * with static analysis of the same literals.\n */\n\nimport { FieldsList } from \"./fields-list\";\nimport type { RawCollection } from \"./types\";\n\n/**\n * Auth collections in real PocketBase always carry these system fields.\n * PocketBase injects the missing ones *when the collection is saved*\n * (`initDefaultFields`), not when the model is constructed — so this list is\n * applied by `ensureAuthSystemFields()` on the save path, never in the\n * constructor. Injecting on construction would also re-add them every time a\n * collection is rebuilt (`CollectionStore.clone()`), silently undoing a\n * migration that dropped one. Shapes and ids mirror what PocketBase\n * serializes into its own migration files.\n */\nconst AUTH_SYSTEM_FIELDS: RawCollection[] = [\n  {\n    autogeneratePattern: \"\",\n    hidden: true,\n    id: \"password901924565\",\n    max: 0,\n    min: 8,\n    name: \"password\",\n    pattern: \"\",\n    presentable: false,\n    required: true,\n    system: true,\n    type: \"password\",\n  },\n  {\n    autogeneratePattern: \"[a-zA-Z0-9]{50}\",\n    hidden: true,\n    id: \"text2504183744\",\n    max: 60,\n    min: 30,\n    name: \"tokenKey\",\n    pattern: \"\",\n    presentable: false,\n    primaryKey: false,\n    required: true,\n    system: true,\n    type: \"text\",\n  },\n  {\n    exceptDomains: null,\n    hidden: false,\n    id: \"email3885137012\",\n    name: \"email\",\n    onlyDomains: null,\n    presentable: false,\n    required: true,\n    system: true,\n    type: \"email\",\n  },\n  {\n    hidden: false,\n    id: \"bool1547992806\",\n    name: \"emailVisibility\",\n    presentable: false,\n    required: false,\n    system: true,\n    type: \"bool\",\n  },\n  {\n    hidden: false,\n    id: \"bool256245529\",\n    name: \"verified\",\n    presentable: false,\n    required: false,\n    system: true,\n    type: \"bool\",\n  },\n];\n\nexport function generateRuntimeCollectionId(): string {\n  let digits = \"\";\n  for (let i = 0; i < 10; i++) {\n    digits += Math.floor(Math.random() * 10).toString();\n  }\n  return `pbc_${digits}`;\n}\n\nexport class Collection {\n  [key: string]: any;\n\n  id: string;\n  name: string;\n  type: string;\n  system: boolean;\n  fields: FieldsList;\n  indexes: string[];\n\n  constructor(data: RawCollection = {}) {\n    const { fields, indexes, ...rest } = data;\n    Object.assign(this, rest);\n\n    this.id = typeof data.id === \"string\" && data.id !== \"\" ? data.id : generateRuntimeCollectionId();\n    this.name = typeof data.name === \"string\" ? data.name : \"\";\n    this.type = typeof data.type === \"string\" && data.type !== \"\" ? data.type : \"base\";\n    this.system = data.system === true;\n    this.fields = new FieldsList(Array.isArray(fields) ? fields : []);\n    this.indexes = Array.isArray(indexes) ? [...indexes] : [];\n  }\n\n  /** PocketBase-shaped plain object (what a snapshot array entry looks like) */\n  serialize(): RawCollection {\n    const raw: RawCollection = {};\n    for (const [key, value] of Object.entries(this)) {\n      if (key === \"fields\" || key === \"indexes\") {\n        continue;\n      }\n      raw[key] = value;\n    }\n    raw.fields = this.fields.serialize();\n    raw.indexes = [...this.indexes];\n    return raw;\n  }\n}\n\n/**\n * PocketBase's `initDefaultFields` for auth collections: on save, any missing\n * system field is put back. Call this from the save path only — the resulting\n * collection is then stable across serialize/rebuild cycles, so replaying the\n * next migration file sees exactly what the previous one committed.\n */\nexport function ensureAuthSystemFields(collection: Collection): void {\n  if (collection.type !== \"auth\") {\n    return;\n  }\n  for (const systemField of AUTH_SYSTEM_FIELDS) {\n    if (!collection.fields.getByName(systemField.name)) {\n      collection.fields.add({ ...systemField });\n    }\n  }\n}\n","/**\n * Condition expressions — one evaluator for PocketBase filters and SQL WHERE\n *\n * Data migrations select records two ways: PocketBase's filter syntax\n * (`status = \"draft\" && views > 10`) and raw SQL through `$dbx`/`app.db()`\n * (`WHERE status = {:status}`). The two dialects overlap almost completely —\n * the same comparison operators over the same field/literal operands — so the\n * simulation parses both with one grammar and evaluates the result against a\n * record.\n *\n * Deliberately small: comparisons, `LIKE`/`~`, `IN`, `IS NULL`, `AND`/`OR`/\n * `NOT`, parentheses, and `{:name}` bindings. Anything outside that raises\n * `ExpressionError`, which the caller reports as an unsupported query rather\n * than silently matching the wrong rows.\n */\n\nexport class ExpressionError extends Error {\n  constructor(message: string) {\n    super(message);\n    this.name = \"ExpressionError\";\n    Object.setPrototypeOf(this, ExpressionError.prototype);\n  }\n}\n\n/** Resolves a field reference to the value stored on the row being tested */\nexport interface EvaluationContext {\n  field: (name: string) => unknown;\n  params?: Record<string, unknown>;\n}\n\nexport type Condition =\n  | { kind: \"and\"; operands: Condition[] }\n  | { kind: \"or\"; operands: Condition[] }\n  | { kind: \"not\"; operand: Condition }\n  | { kind: \"compare\"; operator: CompareOperator; left: Operand; right: Operand }\n  | { kind: \"in\"; negated: boolean; left: Operand; values: Operand[] }\n  | { kind: \"like\"; negated: boolean; left: Operand; pattern: Operand; implicitWildcards: boolean }\n  | { kind: \"null\"; negated: boolean; operand: Operand }\n  | { kind: \"between\"; negated: boolean; operand: Operand; from: Operand; to: Operand }\n  | { kind: \"literal\"; value: boolean };\n\nexport type CompareOperator = \"=\" | \"!=\" | \">\" | \">=\" | \"<\" | \"<=\";\n\nexport type Operand =\n  | { kind: \"field\"; name: string }\n  | { kind: \"value\"; value: unknown }\n  | { kind: \"param\"; name: string };\n\n// ---------------------------------------------------------------------------\n// Tokenizer\n// ---------------------------------------------------------------------------\n\ntype TokenType = \"identifier\" | \"number\" | \"string\" | \"param\" | \"operator\" | \"punct\";\n\ninterface Token {\n  type: TokenType;\n  value: string;\n  position: number;\n}\n\nconst OPERATORS = [\"?!=\", \"!~\", \"?=\", \"?~\", \"!=\", \"<>\", \">=\", \"<=\", \"==\", \"&&\", \"||\", \"=\", \">\", \"<\", \"~\"];\n\nfunction tokenize(input: string): Token[] {\n  const tokens: Token[] = [];\n  let index = 0;\n\n  while (index < input.length) {\n    const char = input[index];\n\n    if (/\\s/.test(char)) {\n      index++;\n      continue;\n    }\n\n    // {:name} — dbx/PocketBase parameter binding\n    if (char === \"{\" && input[index + 1] === \":\") {\n      const end = input.indexOf(\"}\", index);\n      if (end === -1) {\n        throw new ExpressionError(`Unterminated parameter placeholder at position ${index}`);\n      }\n      tokens.push({ type: \"param\", value: input.slice(index + 2, end).trim(), position: index });\n      index = end + 1;\n      continue;\n    }\n\n    if (char === \"'\" || char === '\"') {\n      const { value, next } = readString(input, index);\n      tokens.push({ type: \"string\", value, position: index });\n      index = next;\n      continue;\n    }\n\n    if (/[0-9]/.test(char) || (char === \".\" && /[0-9]/.test(input[index + 1] ?? \"\"))) {\n      const match = /^[0-9]*\\.?[0-9]+(?:[eE][+-]?[0-9]+)?/.exec(input.slice(index));\n      if (!match) {\n        throw new ExpressionError(`Invalid number at position ${index}`);\n      }\n      tokens.push({ type: \"number\", value: match[0], position: index });\n      index += match[0].length;\n      continue;\n    }\n\n    // Identifiers may be qualified (table.column) or backtick/bracket quoted\n    if (/[A-Za-z_`[]/.test(char)) {\n      const { value, next } = readIdentifier(input, index);\n      tokens.push({ type: \"identifier\", value, position: index });\n      index = next;\n      continue;\n    }\n\n    const operator = OPERATORS.find((candidate) => input.startsWith(candidate, index));\n    if (operator) {\n      tokens.push({ type: \"operator\", value: operator, position: index });\n      index += operator.length;\n      continue;\n    }\n\n    if (char === \"(\" || char === \")\" || char === \",\") {\n      tokens.push({ type: \"punct\", value: char, position: index });\n      index++;\n      continue;\n    }\n\n    throw new ExpressionError(`Unexpected character ${JSON.stringify(char)} at position ${index}`);\n  }\n\n  return tokens;\n}\n\nfunction readString(input: string, start: number): { value: string; next: number } {\n  const quote = input[start];\n  let index = start + 1;\n  let value = \"\";\n\n  while (index < input.length) {\n    const char = input[index];\n    if (char === \"\\\\\" && index + 1 < input.length) {\n      value += unescapeChar(input[index + 1]);\n      index += 2;\n      continue;\n    }\n    // SQL doubles the quote to escape it: 'it''s'\n    if (char === quote && input[index + 1] === quote) {\n      value += quote;\n      index += 2;\n      continue;\n    }\n    if (char === quote) {\n      return { value, next: index + 1 };\n    }\n    value += char;\n    index++;\n  }\n\n  throw new ExpressionError(`Unterminated string starting at position ${start}`);\n}\n\nfunction unescapeChar(char: string): string {\n  switch (char) {\n    case \"n\":\n      return \"\\n\";\n    case \"t\":\n      return \"\\t\";\n    case \"r\":\n      return \"\\r\";\n    default:\n      return char;\n  }\n}\n\nfunction readIdentifier(input: string, start: number): { value: string; next: number } {\n  let index = start;\n  let value = \"\";\n\n  while (index < input.length) {\n    const char = input[index];\n    if (char === \"`\" || char === \"[\" || char === \"]\" || char === '\"') {\n      // Quoted identifier segment: `my table`.`col`\n      if (char === \"`\" || char === \"[\") {\n        const closing = char === \"`\" ? \"`\" : \"]\";\n        const end = input.indexOf(closing, index + 1);\n        if (end === -1) {\n          throw new ExpressionError(`Unterminated quoted identifier at position ${index}`);\n        }\n        value += input.slice(index + 1, end);\n        index = end + 1;\n        continue;\n      }\n      break;\n    }\n    if (/[A-Za-z0-9_.$]/.test(char)) {\n      value += char;\n      index++;\n      continue;\n    }\n    break;\n  }\n\n  if (value === \"\") {\n    throw new ExpressionError(`Invalid identifier at position ${start}`);\n  }\n  return { value, next: index };\n}\n\n// ---------------------------------------------------------------------------\n// Parser\n// ---------------------------------------------------------------------------\n\nconst KEYWORDS = new Set([\"and\", \"or\", \"not\", \"in\", \"is\", \"null\", \"like\", \"true\", \"false\", \"between\"]);\n\nclass Parser {\n  private index = 0;\n\n  constructor(private tokens: Token[]) {}\n\n  parse(): Condition {\n    if (this.tokens.length === 0) {\n      return { kind: \"literal\", value: true };\n    }\n    const condition = this.parseOr();\n    if (this.index < this.tokens.length) {\n      const token = this.tokens[this.index];\n      throw new ExpressionError(`Unexpected ${JSON.stringify(token.value)} at position ${token.position}`);\n    }\n    return condition;\n  }\n\n  private parseOr(): Condition {\n    const operands = [this.parseAnd()];\n    while (this.matchOperator(\"||\") || this.matchKeyword(\"or\")) {\n      operands.push(this.parseAnd());\n    }\n    return operands.length === 1 ? operands[0] : { kind: \"or\", operands };\n  }\n\n  private parseAnd(): Condition {\n    const operands = [this.parseNot()];\n    while (this.matchOperator(\"&&\") || this.matchKeyword(\"and\")) {\n      operands.push(this.parseNot());\n    }\n    return operands.length === 1 ? operands[0] : { kind: \"and\", operands };\n  }\n\n  private parseNot(): Condition {\n    if (this.matchKeyword(\"not\")) {\n      return { kind: \"not\", operand: this.parseNot() };\n    }\n    return this.parseComparison();\n  }\n\n  private parseComparison(): Condition {\n    if (this.peekPunct(\"(\")) {\n      // Only a parenthesized condition can start here; a parenthesized value\n      // list is consumed by IN below\n      this.index++;\n      const condition = this.parseOr();\n      this.expectPunct(\")\");\n      return condition;\n    }\n\n    const left = this.parseOperand();\n\n    if (this.matchKeyword(\"is\")) {\n      const negated = this.matchKeyword(\"not\");\n      this.expectKeyword(\"null\");\n      return { kind: \"null\", negated, operand: left };\n    }\n\n    // Postfix negation: `status NOT IN (...)`, `title NOT LIKE 'x'`,\n    // `n NOT BETWEEN 1 AND 5`. Nothing else may follow an operand.\n    const negated = this.matchKeyword(\"not\");\n\n    if (this.matchKeyword(\"in\")) {\n      return { kind: \"in\", negated, left, values: this.parseValueList() };\n    }\n\n    if (this.matchKeyword(\"like\")) {\n      return { kind: \"like\", negated, left, pattern: this.parseOperand(), implicitWildcards: false };\n    }\n\n    if (this.matchKeyword(\"between\")) {\n      const from = this.parseOperand();\n      this.expectKeyword(\"and\");\n      return { kind: \"between\", negated, operand: left, from, to: this.parseOperand() };\n    }\n\n    if (negated) {\n      const token = this.tokens[this.index];\n      throw new ExpressionError(\n        token\n          ? `Expected IN, LIKE or BETWEEN after NOT at position ${token.position}`\n          : \"Expected IN, LIKE or BETWEEN after NOT at end of expression\"\n      );\n    }\n\n    const operator = this.peekOperator();\n    if (!operator) {\n      const token = this.tokens[this.index];\n      throw new ExpressionError(\n        token\n          ? `Expected a comparison operator at position ${token.position}`\n          : \"Expected a comparison operator at end of expression\"\n      );\n    }\n    this.index++;\n\n    switch (operator) {\n      case \"~\":\n      case \"?~\":\n        return { kind: \"like\", negated: false, left, pattern: this.parseOperand(), implicitWildcards: true };\n      case \"!~\":\n        return { kind: \"like\", negated: true, left, pattern: this.parseOperand(), implicitWildcards: true };\n      default:\n        return { kind: \"compare\", operator: normalizeOperator(operator), left, right: this.parseOperand() };\n    }\n  }\n\n  private parseValueList(): Operand[] {\n    this.expectPunct(\"(\");\n    const values: Operand[] = [];\n    if (this.peekPunct(\")\")) {\n      this.index++;\n      return values;\n    }\n    values.push(this.parseOperand());\n    while (this.peekPunct(\",\")) {\n      this.index++;\n      values.push(this.parseOperand());\n    }\n    this.expectPunct(\")\");\n    return values;\n  }\n\n  parseOperand(): Operand {\n    const token = this.tokens[this.index];\n    if (!token) {\n      throw new ExpressionError(\"Unexpected end of expression\");\n    }\n    this.index++;\n\n    switch (token.type) {\n      case \"string\":\n        return { kind: \"value\", value: token.value };\n      case \"number\":\n        return { kind: \"value\", value: Number(token.value) };\n      case \"param\":\n        return { kind: \"param\", name: token.value };\n      case \"identifier\": {\n        const lowered = token.value.toLowerCase();\n        if (lowered === \"true\" || lowered === \"false\") {\n          return { kind: \"value\", value: lowered === \"true\" };\n        }\n        if (lowered === \"null\") {\n          return { kind: \"value\", value: null };\n        }\n        return { kind: \"field\", name: token.value };\n      }\n      default:\n        throw new ExpressionError(`Unexpected ${JSON.stringify(token.value)} at position ${token.position}`);\n    }\n  }\n\n  private peekOperator(): string | null {\n    const token = this.tokens[this.index];\n    return token?.type === \"operator\" ? token.value : null;\n  }\n\n  private matchOperator(value: string): boolean {\n    if (this.peekOperator() === value) {\n      this.index++;\n      return true;\n    }\n    return false;\n  }\n\n  private matchKeyword(keyword: string): boolean {\n    const token = this.tokens[this.index];\n    if (token?.type === \"identifier\" && token.value.toLowerCase() === keyword && KEYWORDS.has(keyword)) {\n      this.index++;\n      return true;\n    }\n    return false;\n  }\n\n  private expectKeyword(keyword: string): void {\n    if (!this.matchKeyword(keyword)) {\n      const token = this.tokens[this.index];\n      throw new ExpressionError(\n        `Expected ${keyword.toUpperCase()}${token ? ` at position ${token.position}` : \" at end of expression\"}`\n      );\n    }\n  }\n\n  private peekPunct(value: string): boolean {\n    const token = this.tokens[this.index];\n    return token?.type === \"punct\" && token.value === value;\n  }\n\n  private expectPunct(value: string): void {\n    if (!this.peekPunct(value)) {\n      const token = this.tokens[this.index];\n      throw new ExpressionError(\n        `Expected ${JSON.stringify(value)}${token ? ` at position ${token.position}` : \" at end of expression\"}`\n      );\n    }\n    this.index++;\n  }\n}\n\nfunction normalizeOperator(operator: string): CompareOperator {\n  switch (operator) {\n    case \"==\":\n    case \"=\":\n    case \"?=\":\n      return \"=\";\n    case \"!=\":\n    case \"<>\":\n    case \"?!=\":\n      return \"!=\";\n    default:\n      return operator as CompareOperator;\n  }\n}\n\n/** Parses a filter or SQL condition into an evaluable tree */\nexport function parseCondition(source: string): Condition {\n  return new Parser(tokenize(source)).parse();\n}\n\n/** Parses a standalone value (a SET assignment or a VALUES entry) */\nexport function parseValueOperand(source: string): Operand {\n  const tokens = tokenize(source);\n  if (tokens.length === 0) {\n    throw new ExpressionError(\"Expected a value\");\n  }\n  return new Parser(tokens).parseOperand();\n}\n\n// ---------------------------------------------------------------------------\n// Evaluation\n// ---------------------------------------------------------------------------\n\nexport function evaluateCondition(condition: Condition, context: EvaluationContext): boolean {\n  switch (condition.kind) {\n    case \"literal\":\n      return condition.value;\n    case \"and\":\n      return condition.operands.every((operand) => evaluateCondition(operand, context));\n    case \"or\":\n      return condition.operands.some((operand) => evaluateCondition(operand, context));\n    case \"not\":\n      return !evaluateCondition(condition.operand, context);\n    case \"null\": {\n      const value = resolveOperand(condition.operand, context);\n      const isNull = value === null || value === undefined;\n      return condition.negated ? !isNull : isNull;\n    }\n    case \"in\": {\n      const value = resolveOperand(condition.left, context);\n      const matches = condition.values.some((candidate) => looseEquals(value, resolveOperand(candidate, context)));\n      return condition.negated ? !matches : matches;\n    }\n    case \"like\": {\n      const value = resolveOperand(condition.left, context);\n      const pattern = resolveOperand(condition.pattern, context);\n      const matches = matchesLike(value, pattern, condition.implicitWildcards);\n      return condition.negated ? !matches : matches;\n    }\n    case \"between\": {\n      const value = resolveOperand(condition.operand, context);\n      const from = resolveOperand(condition.from, context);\n      const to = resolveOperand(condition.to, context);\n      const inRange = compareValues(value, from) >= 0 && compareValues(value, to) <= 0;\n      return condition.negated ? !inRange : inRange;\n    }\n    case \"compare\": {\n      const left = resolveOperand(condition.left, context);\n      const right = resolveOperand(condition.right, context);\n      switch (condition.operator) {\n        case \"=\":\n          return looseEquals(left, right);\n        case \"!=\":\n          return !looseEquals(left, right);\n        case \">\":\n          return compareValues(left, right) > 0;\n        case \">=\":\n          return compareValues(left, right) >= 0;\n        case \"<\":\n          return compareValues(left, right) < 0;\n        case \"<=\":\n          return compareValues(left, right) <= 0;\n      }\n    }\n  }\n}\n\nexport function resolveOperand(operand: Operand, context: EvaluationContext): unknown {\n  switch (operand.kind) {\n    case \"value\":\n      return operand.value;\n    case \"field\":\n      return context.field(operand.name);\n    case \"param\": {\n      const params = context.params ?? {};\n      if (!(operand.name in params)) {\n        throw new ExpressionError(`Missing bound parameter {:${operand.name}}`);\n      }\n      return params[operand.name];\n    }\n  }\n}\n\n/** Every field a condition reads, for callers that need to validate up front */\nexport function conditionFields(condition: Condition): string[] {\n  const names = new Set<string>();\n  const visitOperand = (operand: Operand) => {\n    if (operand.kind === \"field\") {\n      names.add(operand.name);\n    }\n  };\n\n  const visit = (node: Condition) => {\n    switch (node.kind) {\n      case \"and\":\n      case \"or\":\n        node.operands.forEach(visit);\n        break;\n      case \"not\":\n        visit(node.operand);\n        break;\n      case \"compare\":\n        visitOperand(node.left);\n        visitOperand(node.right);\n        break;\n      case \"in\":\n        visitOperand(node.left);\n        node.values.forEach(visitOperand);\n        break;\n      case \"like\":\n        visitOperand(node.left);\n        visitOperand(node.pattern);\n        break;\n      case \"between\":\n        visitOperand(node.operand);\n        visitOperand(node.from);\n        visitOperand(node.to);\n        break;\n      case \"null\":\n        visitOperand(node.operand);\n        break;\n      case \"literal\":\n        break;\n    }\n  };\n\n  visit(condition);\n  return [...names];\n}\n\n/**\n * SQLite comparison semantics, narrowed to what migrations rely on: numbers\n * compare numerically even when one side arrived as a string, everything else\n * compares as text.\n */\nexport function looseEquals(left: unknown, right: unknown): boolean {\n  if (left === null || left === undefined) {\n    return right === null || right === undefined;\n  }\n  if (right === null || right === undefined) {\n    return false;\n  }\n  if (typeof left === \"boolean\" || typeof right === \"boolean\") {\n    return toBoolean(left) === toBoolean(right);\n  }\n  if (typeof left === \"number\" || typeof right === \"number\") {\n    const leftNumber = Number(left);\n    const rightNumber = Number(right);\n    if (Number.isFinite(leftNumber) && Number.isFinite(rightNumber)) {\n      return leftNumber === rightNumber;\n    }\n  }\n  if (Array.isArray(left) || Array.isArray(right)) {\n    return JSON.stringify(left) === JSON.stringify(right);\n  }\n  return String(left) === String(right);\n}\n\nexport function compareValues(left: unknown, right: unknown): number {\n  if (left === null || left === undefined) {\n    return right === null || right === undefined ? 0 : -1;\n  }\n  if (right === null || right === undefined) {\n    return 1;\n  }\n  const leftNumber = Number(left);\n  const rightNumber = Number(right);\n  if (Number.isFinite(leftNumber) && Number.isFinite(rightNumber) && left !== \"\" && right !== \"\") {\n    return leftNumber === rightNumber ? 0 : leftNumber < rightNumber ? -1 : 1;\n  }\n  const leftText = String(left);\n  const rightText = String(right);\n  return leftText === rightText ? 0 : leftText < rightText ? -1 : 1;\n}\n\n/**\n * Ordering used by every sort surface (`sort: \"-views\"` and SQL `ORDER BY`),\n * so the two agree on the same rows: equality is the filter's `=`, and the\n * ordering below it is SQLite-ish — numeric when both sides are numbers.\n */\nexport function compareForSort(left: unknown, right: unknown): number {\n  if (looseEquals(left, right)) {\n    return 0;\n  }\n  return compareValues(left, right) < 0 ? -1 : 1;\n}\n\nfunction toBoolean(value: unknown): boolean {\n  if (typeof value === \"boolean\") {\n    return value;\n  }\n  if (typeof value === \"number\") {\n    return value !== 0;\n  }\n  if (typeof value === \"string\") {\n    return value !== \"\" && value !== \"0\" && value.toLowerCase() !== \"false\";\n  }\n  return Boolean(value);\n}\n\n/**\n * SQL LIKE. `implicitWildcards` is PocketBase's `~`, which wraps the term in\n * `%` unless the term already contains a wildcard.\n */\nfunction matchesLike(value: unknown, pattern: unknown, implicitWildcards: boolean): boolean {\n  if (value === null || value === undefined || pattern === null || pattern === undefined) {\n    return false;\n  }\n\n  let text = String(pattern);\n  if (implicitWildcards && !text.includes(\"%\") && !text.includes(\"_\")) {\n    text = `%${text}%`;\n  }\n\n  const regex = new RegExp(`^${likeToRegexSource(text)}$`, \"is\");\n  return regex.test(String(value));\n}\n\nfunction likeToRegexSource(pattern: string): string {\n  let source = \"\";\n  for (let index = 0; index < pattern.length; index++) {\n    const char = pattern[index];\n    if (char === \"\\\\\" && index + 1 < pattern.length) {\n      source += escapeRegex(pattern[++index]);\n      continue;\n    }\n    if (char === \"%\") {\n      source += \"[\\\\s\\\\S]*\";\n      continue;\n    }\n    if (char === \"_\") {\n      source += \"[\\\\s\\\\S]\";\n      continue;\n    }\n    source += escapeRegex(char);\n  }\n  return source;\n}\n\nfunction escapeRegex(char: string): string {\n  return char.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n","/**\n * `$dbx` and `app.db()` simulation\n *\n * PocketBase exposes two query surfaces to a migration: `$dbx` expression\n * builders passed to the record finders, and `app.db().newQuery(sql)` for raw\n * SQL. Both are simulated against the in-memory record store (`records.ts`).\n *\n * The SQL support is a deliberate subset — SELECT / INSERT / UPDATE / DELETE\n * against a single collection table, with the condition grammar from\n * `expression.ts`. Anything beyond it raises `UnsupportedQueryError`, which\n * the caller turns into a warning (lenient) or a throw (strict): reporting\n * \"this query is not simulated\" is useful, quietly matching the wrong rows is\n * not.\n */\n\nimport {\n  ExpressionError,\n  compareForSort,\n  evaluateCondition,\n  parseCondition,\n  parseValueOperand,\n  resolveOperand,\n  type Condition,\n  type Operand,\n} from \"./expression\";\nimport type { RecordModel } from \"./records\";\n\nexport class UnsupportedQueryError extends Error {\n  constructor(message: string) {\n    super(message);\n    this.name = \"UnsupportedQueryError\";\n    Object.setPrototypeOf(this, UnsupportedQueryError.prototype);\n  }\n}\n\n/** Marks the objects `$dbx.*` returns so the finders can recognize them */\nconst DBX_EXPRESSION = Symbol.for(\"pocketbase-zod-schema.dbxExpression\");\n\nexport interface DbxExpression {\n  [DBX_EXPRESSION]: true;\n  /** The SQL fragment, as `$dbx` would build it (for messages and debugging) */\n  build(): string;\n  matches(record: RecordModel): boolean;\n}\n\nexport function isDbxExpression(value: unknown): value is DbxExpression {\n  return typeof value === \"object\" && value !== null && (value as Record<symbol, unknown>)[DBX_EXPRESSION] === true;\n}\n\nfunction expression(sql: string, matches: (record: RecordModel) => boolean): DbxExpression {\n  return { [DBX_EXPRESSION]: true, build: () => sql, matches };\n}\n\n/** Evaluates a parsed condition against one record */\nexport function matchCondition(condition: Condition, record: RecordModel, params?: Record<string, unknown>): boolean {\n  return evaluateCondition(condition, { field: (name) => readField(record, name), params });\n}\n\n/**\n * Column references may be qualified (`posts.status`) or quoted; the record\n * only knows the bare name.\n */\nexport function readField(record: RecordModel, name: string): unknown {\n  const bare = name.includes(\".\") ? name.slice(name.lastIndexOf(\".\") + 1) : name;\n  return record.get(bare);\n}\n\nfunction quoteLiteral(value: unknown): string {\n  if (value === null || value === undefined) {\n    return \"NULL\";\n  }\n  if (typeof value === \"number\" || typeof value === \"boolean\") {\n    return String(value);\n  }\n  return `'${String(value).replace(/'/g, \"''\")}'`;\n}\n\n// ---------------------------------------------------------------------------\n// $dbx\n// ---------------------------------------------------------------------------\n\nexport function createDbx(): Record<string, unknown> {\n  const exp = (raw: string, params: Record<string, unknown> = {}): DbxExpression => {\n    const condition = parseCondition(raw);\n    return expression(raw, (record) => matchCondition(condition, record, params));\n  };\n\n  const hashExp = (pairs: Record<string, unknown>): DbxExpression => {\n    const entries = Object.entries(pairs ?? {});\n    const sql = entries.map(([key, value]) => `${key}=${quoteLiteral(value)}`).join(\" AND \") || \"1=1\";\n    return expression(sql, (record) => entries.every(([key, value]) => looseMatch(readField(record, key), value)));\n  };\n\n  const combine = (keyword: \"AND\" | \"OR\", operands: unknown[]): DbxExpression => {\n    const expressions = operands.filter(isDbxExpression);\n    const sql = expressions.map((operand) => `(${operand.build()})`).join(` ${keyword} `) || \"1=1\";\n    return expression(sql, (record) =>\n      keyword === \"AND\"\n        ? expressions.every((operand) => operand.matches(record))\n        : expressions.some((operand) => operand.matches(record))\n    );\n  };\n\n  const inList = (column: string, values: unknown[], negated: boolean): DbxExpression => {\n    const flat = values.flat();\n    const sql = `${column} ${negated ? \"NOT IN\" : \"IN\"} (${flat.map(quoteLiteral).join(\", \")})`;\n    return expression(sql, (record) => {\n      const matched = flat.some((value) => looseMatch(readField(record, column), value));\n      return negated ? !matched : matched;\n    });\n  };\n\n  const like = (column: string, values: unknown[], negated: boolean, anyOf: boolean): DbxExpression => {\n    const terms = values.flat().map((value) => String(value));\n    const keyword = negated ? \"NOT LIKE\" : \"LIKE\";\n    const sql = terms.map((term) => `${column} ${keyword} '%${term}%'`).join(anyOf ? \" OR \" : \" AND \") || \"1=1\";\n    return expression(sql, (record) => {\n      const text = String(readField(record, column) ?? \"\").toLowerCase();\n      const test = (term: string) => text.includes(term.toLowerCase());\n      const matched = anyOf ? terms.some(test) : terms.every(test);\n      return negated ? !matched : matched;\n    });\n  };\n\n  return {\n    exp,\n    hashExp,\n    and: (...operands: unknown[]) => combine(\"AND\", operands),\n    or: (...operands: unknown[]) => combine(\"OR\", operands),\n    not: (operand: unknown) => {\n      const inner = isDbxExpression(operand) ? operand : null;\n      return expression(inner ? `NOT (${inner.build()})` : \"1=0\", (record) => !inner || !inner.matches(record));\n    },\n    in: (column: string, ...values: unknown[]) => inList(column, values, false),\n    notIn: (column: string, ...values: unknown[]) => inList(column, values, true),\n    like: (column: string, ...values: unknown[]) => like(column, values, false, false),\n    notLike: (column: string, ...values: unknown[]) => like(column, values, true, false),\n    orLike: (column: string, ...values: unknown[]) => like(column, values, false, true),\n    between: (column: string, from: unknown, to: unknown) =>\n      expression(`${column} BETWEEN ${quoteLiteral(from)} AND ${quoteLiteral(to)}`, (record) => {\n        const value = readField(record, column);\n        return compare(value, from) >= 0 && compare(value, to) <= 0;\n      }),\n    notBetween: (column: string, from: unknown, to: unknown) =>\n      expression(`${column} NOT BETWEEN ${quoteLiteral(from)} AND ${quoteLiteral(to)}`, (record) => {\n        const value = readField(record, column);\n        return !(compare(value, from) >= 0 && compare(value, to) <= 0);\n      }),\n  };\n}\n\nfunction looseMatch(left: unknown, right: unknown): boolean {\n  return evaluateCondition(\n    { kind: \"compare\", operator: \"=\", left: { kind: \"value\", value: left }, right: { kind: \"value\", value: right } },\n    { field: () => undefined }\n  );\n}\n\nconst compare = compareForSort;\n\n// ---------------------------------------------------------------------------\n// SQL subset\n// ---------------------------------------------------------------------------\n\nexport type ParsedStatement =\n  | {\n      kind: \"select\";\n      table: string;\n      columns: string[];\n      where?: Condition;\n      order?: OrderTerm[];\n      limit?: number;\n      offset?: number;\n    }\n  | { kind: \"update\"; table: string; assignments: { column: string; value: Operand }[]; where?: Condition }\n  | { kind: \"delete\"; table: string; where?: Condition }\n  | { kind: \"insert\"; table: string; columns: string[]; values: Operand[] };\n\nexport interface OrderTerm {\n  column: string;\n  descending: boolean;\n}\n\nconst SELECT_PATTERN = /^SELECT\\s+(?<columns>[\\s\\S]+?)\\s+FROM\\s+(?<table>[`\"[\\]\\w.]+)(?<rest>[\\s\\S]*)$/i;\nconst UPDATE_PATTERN = /^UPDATE\\s+(?<table>[`\"[\\]\\w.]+)\\s+SET\\s+(?<rest>[\\s\\S]+)$/i;\nconst DELETE_PATTERN = /^DELETE\\s+FROM\\s+(?<table>[`\"[\\]\\w.]+)(?<rest>[\\s\\S]*)$/i;\nconst INSERT_PATTERN =\n  /^INSERT\\s+INTO\\s+(?<table>[`\"[\\]\\w.]+)\\s*\\((?<columns>[^)]*)\\)\\s*VALUES\\s*\\((?<values>[\\s\\S]*)\\)\\s*$/i;\n\n/**\n * Parses one statement of the supported subset.\n *\n * @throws UnsupportedQueryError for anything outside it\n */\nexport function parseStatement(sql: string): ParsedStatement {\n  const trimmed = sql.trim().replace(/;\\s*$/, \"\");\n\n  const insert = INSERT_PATTERN.exec(trimmed);\n  if (insert?.groups) {\n    const columns = splitTopLevel(insert.groups.columns).map(unquoteIdentifier);\n    const values = splitTopLevel(insert.groups.values).map((value) => parseOperandOrThrow(value, trimmed));\n    if (columns.length !== values.length) {\n      throw new UnsupportedQueryError(`INSERT column/value count mismatch: ${trimmed}`);\n    }\n    return { kind: \"insert\", table: unquoteIdentifier(insert.groups.table), columns, values };\n  }\n\n  const update = UPDATE_PATTERN.exec(trimmed);\n  if (update?.groups) {\n    const { clause, where } = splitWhere(update.groups.rest, trimmed);\n    const assignments = splitTopLevel(clause).map((assignment) => {\n      const separator = assignment.indexOf(\"=\");\n      if (separator === -1) {\n        throw new UnsupportedQueryError(`Unsupported SET assignment ${JSON.stringify(assignment)} in: ${trimmed}`);\n      }\n      return {\n        column: unquoteIdentifier(assignment.slice(0, separator)),\n        value: parseOperandOrThrow(assignment.slice(separator + 1), trimmed),\n      };\n    });\n    return { kind: \"update\", table: unquoteIdentifier(update.groups.table), assignments, where };\n  }\n\n  const remove = DELETE_PATTERN.exec(trimmed);\n  if (remove?.groups) {\n    const { clause, where } = splitWhere(remove.groups.rest, trimmed);\n    if (clause.trim() !== \"\") {\n      throw new UnsupportedQueryError(`Unsupported DELETE clause ${JSON.stringify(clause.trim())} in: ${trimmed}`);\n    }\n    return { kind: \"delete\", table: unquoteIdentifier(remove.groups.table), where };\n  }\n\n  const select = SELECT_PATTERN.exec(trimmed);\n  if (select?.groups) {\n    const { clause, where, order, limit, offset } = splitSelectTail(select.groups.rest, trimmed);\n    if (clause.trim() !== \"\") {\n      throw new UnsupportedQueryError(`Unsupported SELECT clause ${JSON.stringify(clause.trim())} in: ${trimmed}`);\n    }\n    return {\n      kind: \"select\",\n      table: unquoteIdentifier(select.groups.table),\n      columns: splitTopLevel(select.groups.columns).map((column) => unquoteIdentifier(stripAlias(column))),\n      where,\n      order,\n      limit,\n      offset,\n    };\n  }\n\n  throw new UnsupportedQueryError(`Only single-table SELECT/INSERT/UPDATE/DELETE are simulated. Got: ${trimmed}`);\n}\n\n/** Runs a parsed statement over a collection's rows */\nexport interface StatementTarget {\n  /** Records of the statement's table, in insertion order */\n  rows: () => RecordModel[];\n  insert: (values: Record<string, unknown>) => RecordModel;\n  remove: (record: RecordModel) => void;\n  persist: (record: RecordModel) => void;\n}\n\nexport interface StatementResult {\n  /** Rows a SELECT produced, as plain objects */\n  rows: Record<string, unknown>[];\n  /** Rows an INSERT/UPDATE/DELETE touched */\n  affected: number;\n}\n\nexport function executeStatement(\n  statement: ParsedStatement,\n  target: StatementTarget,\n  params: Record<string, unknown>\n): StatementResult {\n  const matching = (where?: Condition) =>\n    target.rows().filter((record) => (where ? matchCondition(where, record, params) : true));\n\n  switch (statement.kind) {\n    case \"select\": {\n      let rows = matching(statement.where);\n      const order = statement.order;\n      if (order?.length) {\n        rows = [...rows].sort((a, b) => {\n          for (const term of order) {\n            const result = compare(readField(a, term.column), readField(b, term.column));\n            if (result !== 0) {\n              return term.descending ? -result : result;\n            }\n          }\n          return 0;\n        });\n      }\n      if (statement.offset !== undefined) {\n        rows = rows.slice(statement.offset);\n      }\n      if (statement.limit !== undefined) {\n        rows = rows.slice(0, statement.limit);\n      }\n\n      const selectAll = statement.columns.length === 0 || statement.columns.includes(\"*\");\n      return {\n        rows: rows.map((record) => {\n          if (selectAll) {\n            return record.export();\n          }\n          const projected: Record<string, unknown> = {};\n          for (const column of statement.columns) {\n            projected[column] = readField(record, column);\n          }\n          return projected;\n        }),\n        affected: 0,\n      };\n    }\n\n    case \"update\": {\n      const rows = matching(statement.where);\n      for (const record of rows) {\n        for (const assignment of statement.assignments) {\n          record.set(\n            assignment.column,\n            resolveOperand(assignment.value, { field: (name) => readField(record, name), params })\n          );\n        }\n        target.persist(record);\n      }\n      return { rows: [], affected: rows.length };\n    }\n\n    case \"delete\": {\n      const rows = matching(statement.where);\n      for (const record of rows) {\n        target.remove(record);\n      }\n      return { rows: [], affected: rows.length };\n    }\n\n    case \"insert\": {\n      const values: Record<string, unknown> = {};\n      statement.columns.forEach((column, index) => {\n        values[column] = resolveOperand(statement.values[index], { field: () => undefined, params });\n      });\n      target.insert(values);\n      return { rows: [], affected: 1 };\n    }\n  }\n}\n\nfunction parseOperandOrThrow(source: string, sql: string): Operand {\n  try {\n    return parseValueOperand(source);\n  } catch (error) {\n    if (error instanceof ExpressionError) {\n      throw new UnsupportedQueryError(`Unsupported value ${JSON.stringify(source.trim())} in: ${sql}`);\n    }\n    throw error;\n  }\n}\n\nfunction parseConditionOrThrow(source: string, sql: string): Condition {\n  try {\n    return parseCondition(source);\n  } catch (error) {\n    if (error instanceof ExpressionError) {\n      throw new UnsupportedQueryError(`Unsupported WHERE clause in ${sql}: ${error.message}`);\n    }\n    throw error;\n  }\n}\n\nfunction splitWhere(rest: string, sql: string): { clause: string; where?: Condition } {\n  const index = indexOfKeyword(rest, \"WHERE\");\n  if (index === -1) {\n    return { clause: rest };\n  }\n  return {\n    clause: rest.slice(0, index),\n    where: parseConditionOrThrow(rest.slice(index + \"WHERE\".length), sql),\n  };\n}\n\nfunction splitSelectTail(\n  rest: string,\n  sql: string\n): { clause: string; where?: Condition; order?: OrderTerm[]; limit?: number; offset?: number } {\n  let remainder = rest;\n  let offset: number | undefined;\n  let limit: number | undefined;\n  let order: OrderTerm[] | undefined;\n\n  const offsetIndex = indexOfKeyword(remainder, \"OFFSET\");\n  if (offsetIndex !== -1) {\n    offset = parseCount(remainder.slice(offsetIndex + \"OFFSET\".length), sql);\n    remainder = remainder.slice(0, offsetIndex);\n  }\n\n  const limitIndex = indexOfKeyword(remainder, \"LIMIT\");\n  if (limitIndex !== -1) {\n    limit = parseCount(remainder.slice(limitIndex + \"LIMIT\".length), sql);\n    remainder = remainder.slice(0, limitIndex);\n  }\n\n  const orderIndex = indexOfKeyword(remainder, \"ORDER BY\");\n  if (orderIndex !== -1) {\n    order = splitTopLevel(remainder.slice(orderIndex + \"ORDER BY\".length)).map((term) => {\n      const parts = term.trim().split(/\\s+/);\n      return {\n        column: unquoteIdentifier(parts[0]),\n        descending: (parts[1] ?? \"\").toUpperCase() === \"DESC\",\n      };\n    });\n    remainder = remainder.slice(0, orderIndex);\n  }\n\n  const { clause, where } = splitWhere(remainder, sql);\n  return { clause, where, order, limit, offset };\n}\n\nfunction parseCount(source: string, sql: string): number {\n  const value = Number(source.trim());\n  if (!Number.isInteger(value) || value < 0) {\n    throw new UnsupportedQueryError(`Unsupported LIMIT/OFFSET ${JSON.stringify(source.trim())} in: ${sql}`);\n  }\n  return value;\n}\n\n/** Finds a keyword outside of quotes and parentheses */\nfunction indexOfKeyword(source: string, keyword: string): number {\n  const upper = source.toUpperCase();\n  const target = keyword.toUpperCase();\n  let depth = 0;\n  let quote: string | null = null;\n\n  for (let index = 0; index < source.length; index++) {\n    const char = source[index];\n    if (quote) {\n      if (char === \"\\\\\") {\n        index++;\n      } else if (char === quote) {\n        quote = null;\n      }\n      continue;\n    }\n    if (char === \"'\" || char === '\"' || char === \"`\") {\n      quote = char;\n      continue;\n    }\n    if (char === \"(\") {\n      depth++;\n      continue;\n    }\n    if (char === \")\") {\n      depth--;\n      continue;\n    }\n    if (depth !== 0) {\n      continue;\n    }\n    if (upper.startsWith(target, index) && isBoundary(source, index - 1) && isBoundary(source, index + target.length)) {\n      return index;\n    }\n  }\n\n  return -1;\n}\n\nfunction isBoundary(source: string, index: number): boolean {\n  if (index < 0 || index >= source.length) {\n    return true;\n  }\n  return !/[A-Za-z0-9_]/.test(source[index]);\n}\n\n/** Splits on commas that are not inside quotes or parentheses */\nfunction splitTopLevel(source: string): string[] {\n  const parts: string[] = [];\n  let current = \"\";\n  let depth = 0;\n  let quote: string | null = null;\n\n  for (let index = 0; index < source.length; index++) {\n    const char = source[index];\n    if (quote) {\n      current += char;\n      if (char === \"\\\\\" && index + 1 < source.length) {\n        current += source[++index];\n      } else if (char === quote) {\n        quote = null;\n      }\n      continue;\n    }\n    if (char === \"'\" || char === '\"' || char === \"`\") {\n      quote = char;\n      current += char;\n      continue;\n    }\n    if (char === \"(\") {\n      depth++;\n    } else if (char === \")\") {\n      depth--;\n    }\n    if (char === \",\" && depth === 0) {\n      parts.push(current);\n      current = \"\";\n      continue;\n    }\n    current += char;\n  }\n\n  if (current.trim() !== \"\") {\n    parts.push(current);\n  }\n  return parts.map((part) => part.trim()).filter((part) => part !== \"\");\n}\n\nfunction stripAlias(column: string): string {\n  return column.replace(/\\s+AS\\s+[\\s\\S]+$/i, \"\").trim();\n}\n\nfunction unquoteIdentifier(identifier: string): string {\n  const trimmed = identifier.trim();\n  const unquoted = trimmed.replace(/^[`\"[]/, \"\").replace(/[`\"\\]]$/, \"\");\n  // Qualified names (`posts.status`) reduce to the column\n  return unquoted.includes(\".\") ? unquoted.slice(unquoted.lastIndexOf(\".\") + 1) : unquoted;\n}\n","/**\n * Record simulation — an in-memory row store per collection\n *\n * Schema reconstruction never needs this: a migration that seeds or rewrites\n * data does not change the shape of a collection. It matters for the other\n * job the engine can do — running a hand-written data migration before it\n * touches production and seeing what it actually does.\n *\n * Enabled with `records: \"simulate\"`. Left off, `Record` and the data-layer\n * `app.*` methods stay the inert stubs they have always been, so schema-only\n * replay is unchanged.\n *\n * The store lives on `CollectionStore`, which means it inherits the runner's\n * transaction semantics for free: a migration that throws halfway through a\n * data rewrite leaves neither schema nor records behind.\n */\n\nimport type { Collection } from \"./collection\";\n\n/**\n * Fields PocketBase manages itself. `id` is generated on save; `created` and\n * `updated` are autodate columns the server stamps.\n */\nconst SYSTEM_RECORD_FIELDS = [\"id\", \"created\", \"updated\"];\n\n/** PocketBase record ids are 15 lowercase alphanumeric characters */\nexport function generateRecordId(): string {\n  const alphabet = \"abcdefghijklmnopqrstuvwxyz0123456789\";\n  let id = \"\";\n  for (let index = 0; index < 15; index++) {\n    id += alphabet[Math.floor(Math.random() * alphabet.length)];\n  }\n  return id;\n}\n\n/**\n * The `Record` global a migration sees. Mirrors `core.Record`'s JSVM surface:\n * `get`/`set` plus the typed getters, `load`, `publicExport`, `originalCopy`.\n *\n * Arbitrary property access (`record.title`) is deliberately *not* supported —\n * `core.Record` is a Go struct and does not support it either, so a migration\n * that relies on it would fail in PocketBase.\n */\nexport class RecordModel {\n  private data: Record<string, unknown> = {};\n  private original: Record<string, unknown> = {};\n  private readonly owner: Collection;\n  /** Set by setPassword(); PocketBase stores a hash, the simulation the value */\n  private password?: string;\n\n  constructor(collection: Collection, data: Record<string, unknown> = {}) {\n    if (!collection || typeof collection !== \"object\" || typeof (collection as Collection).name !== \"string\") {\n      throw new Error(\"[engine] new Record() expects a collection\");\n    }\n    this.owner = collection;\n    this.load(data);\n    this.original = { ...this.data };\n  }\n\n  get id(): string {\n    return typeof this.data.id === \"string\" ? this.data.id : \"\";\n  }\n\n  set id(value: string) {\n    this.data.id = value;\n  }\n\n  collection(): Collection {\n    return this.owner;\n  }\n\n  /** PocketBase names a collection's table after the collection */\n  tableName(): string {\n    return this.owner.name;\n  }\n\n  get(key: string): unknown {\n    return this.data[key];\n  }\n\n  set(key: string, value: unknown): void {\n    this.data[key] = value;\n  }\n\n  getString(key: string): string {\n    const value = this.get(key);\n    if (value === null || value === undefined) {\n      return \"\";\n    }\n    return typeof value === \"string\" ? value : String(value);\n  }\n\n  getBool(key: string): boolean {\n    const value = this.get(key);\n    if (typeof value === \"boolean\") {\n      return value;\n    }\n    if (typeof value === \"number\") {\n      return value !== 0;\n    }\n    if (typeof value === \"string\") {\n      return value !== \"\" && value !== \"0\" && value.toLowerCase() !== \"false\";\n    }\n    return Boolean(value);\n  }\n\n  getInt(key: string): number {\n    const value = Number(this.get(key));\n    return Number.isFinite(value) ? Math.trunc(value) : 0;\n  }\n\n  getFloat(key: string): number {\n    const value = Number(this.get(key));\n    return Number.isFinite(value) ? value : 0;\n  }\n\n  getDateTime(key: string): string {\n    return this.getString(key);\n  }\n\n  getStringSlice(key: string): string[] {\n    const value = this.get(key);\n    if (Array.isArray(value)) {\n      return value.map((entry) => (typeof entry === \"string\" ? entry : String(entry)));\n    }\n    if (typeof value === \"string\" && value !== \"\") {\n      return [value];\n    }\n    return [];\n  }\n\n  /** Bulk assignment, as `record.load({...})` does in the JSVM */\n  load(data: Record<string, unknown>): void {\n    if (!data || typeof data !== \"object\") {\n      return;\n    }\n    for (const [key, value] of Object.entries(data)) {\n      this.data[key] = value;\n    }\n  }\n\n  setPassword(password: string): void {\n    this.password = password;\n    this.data.password = password;\n  }\n\n  validatePassword(password: string): boolean {\n    return this.password !== undefined && this.password === password;\n  }\n\n  /** The record as it was last read from (or written to) the store */\n  originalCopy(): RecordModel {\n    return new RecordModel(this.owner, { ...this.original });\n  }\n\n  /**\n   * Deep, independent copy. `owner` rebinds the copy to another Collection\n   * instance (what a transaction clone needs); everything the getters cannot\n   * reach — the pre-modification `original` and the password `setPassword()`\n   * stored — is carried over, so a copy behaves like the record it came from.\n   */\n  clone(owner: Collection = this.owner): RecordModel {\n    const copy = new RecordModel(owner, structuredClone(this.data));\n    copy.original = structuredClone(this.original);\n    copy.password = this.password;\n    return copy;\n  }\n\n  /** Plain object, the shape `publicExport()` returns in the JSVM */\n  publicExport(): Record<string, unknown> {\n    return { ...this.data };\n  }\n\n  /** Every stored value, including system columns */\n  export(): Record<string, unknown> {\n    return { ...this.data };\n  }\n\n  /** Called by the store once a save has committed */\n  markPersisted(): void {\n    this.original = { ...this.data };\n  }\n\n  /** Fields the record carries that the collection does not declare */\n  undeclaredFields(): string[] {\n    const declared = new Set<string>(SYSTEM_RECORD_FIELDS);\n    for (const field of this.owner.fields) {\n      if (typeof field.name === \"string\") {\n        declared.add(field.name);\n      }\n    }\n    return Object.keys(this.data).filter((key) => !declared.has(key));\n  }\n}\n\n/**\n * Rows, keyed by collection id then record id. Insertion order is preserved\n * so unsorted queries come back the way they went in.\n */\nexport class RecordStore {\n  private byCollection = new Map<string, Map<string, RecordModel>>();\n\n  save(record: RecordModel): RecordModel {\n    if (record.id === \"\") {\n      record.id = generateRecordId();\n    }\n    const collection = record.collection();\n    const rows = this.rowsFor(collection.id);\n    rows.set(record.id, record);\n    record.markPersisted();\n    return record;\n  }\n\n  delete(record: RecordModel): boolean {\n    return this.rowsFor(record.collection().id).delete(record.id);\n  }\n\n  deleteById(collectionId: string, recordId: string): boolean {\n    return this.rowsFor(collectionId).delete(recordId);\n  }\n\n  getById(collectionId: string, recordId: string): RecordModel | undefined {\n    return this.rowsFor(collectionId).get(recordId);\n  }\n\n  list(collectionId: string): RecordModel[] {\n    return [...this.rowsFor(collectionId).values()];\n  }\n\n  count(collectionId: string): number {\n    return this.rowsFor(collectionId).size;\n  }\n\n  /** Drops every row of a collection (what deleting the collection does) */\n  dropCollection(collectionId: string): void {\n    this.byCollection.delete(collectionId);\n  }\n\n  /** Every collection id that currently holds at least one record */\n  collectionIds(): string[] {\n    return [...this.byCollection.keys()].filter((id) => this.byCollection.get(id)!.size > 0);\n  }\n\n  /**\n   * Deep copy. Records are rebound to the collections in `collections` so a\n   * cloned record's `collection()` points at the cloned schema, not the one\n   * the transaction started from.\n   */\n  clone(resolveCollection: (id: string) => Collection | undefined): RecordStore {\n    const copy = new RecordStore();\n    for (const [collectionId, rows] of this.byCollection.entries()) {\n      const collection = resolveCollection(collectionId);\n      if (!collection) {\n        // The collection was dropped in this transaction; its rows go with it\n        continue;\n      }\n      const copiedRows = new Map<string, RecordModel>();\n      for (const [recordId, record] of rows.entries()) {\n        copiedRows.set(recordId, record.clone(collection));\n      }\n      copy.byCollection.set(collectionId, copiedRows);\n    }\n    return copy;\n  }\n\n  /** Commit: adopt another store's rows */\n  replaceWith(other: RecordStore): void {\n    this.byCollection = new Map(other.byCollection);\n  }\n\n  private rowsFor(collectionId: string): Map<string, RecordModel> {\n    let rows = this.byCollection.get(collectionId);\n    if (!rows) {\n      rows = new Map();\n      this.byCollection.set(collectionId, rows);\n    }\n    return rows;\n  }\n}\n","/**\n * The data-layer half of `app` — record finders and `app.db()`\n *\n * Installed on the simulated app only when `records: \"simulate\"` is set.\n * Without it these names fall through to the inert stubs, which is what\n * schema-only replay wants: a data migration should not be able to fail a\n * `generate` run over rows nobody is tracking.\n *\n * Finder semantics follow PocketBase: \"by id\" and \"first by ...\" throw\n * `sql: no rows in result set` on a miss, list finders return an empty array.\n * A migration that guards with try/catch behaves the same here as in\n * production.\n */\n\nimport type { Collection } from \"./collection\";\nimport {\n  UnsupportedQueryError,\n  executeStatement,\n  isDbxExpression,\n  matchCondition,\n  parseStatement,\n  readField,\n  type DbxExpression,\n  type StatementResult,\n} from \"./dbx\";\nimport { compareForSort, ExpressionError, parseCondition } from \"./expression\";\nimport { RecordModel } from \"./records\";\nimport type { CollectionStore } from \"./store\";\nimport type { EngineOptions, EngineWarning } from \"./types\";\n\nexport interface WarningSink {\n  (warning: EngineWarning): void;\n}\n\n/** PocketBase's error text for a lookup that matched nothing */\nexport const NO_ROWS_ERROR = \"sql: no rows in result set\";\n\nexport interface DataApi {\n  /** Methods to install on the simulated app */\n  methods: Record<string, (...args: any[]) => unknown>;\n  /**\n   * Points `runInTransaction`'s callback argument at the app these methods\n   * are installed on. Called once the proxy exists.\n   */\n  bindApp: (app: unknown) => void;\n}\n\nexport function createDataApi(store: CollectionStore, options: EngineOptions, warn: WarningSink): DataApi {\n  const strict = options.strictness === \"strict\";\n\n  /**\n   * Accepts what PocketBase's finders accept: a name, an id, or a Collection.\n   * A Collection is re-resolved through the store so the rows come from the\n   * transaction's copy rather than whatever instance the caller held on to.\n   */\n  const resolveCollection = (target: unknown): Collection => {\n    if (typeof target === \"string\") {\n      const collection = store.getByNameOrId(target);\n      if (collection) {\n        return collection;\n      }\n      throw new Error(`${NO_ROWS_ERROR} (collection \"${target}\" not found)`);\n    }\n\n    if (target && typeof target === \"object\") {\n      const candidate = target as Collection;\n      const known =\n        (typeof candidate.id === \"string\" ? store.getById(candidate.id) : undefined) ??\n        (typeof candidate.name === \"string\" && candidate.name !== \"\" ? store.getByNameOrId(candidate.name) : undefined);\n      if (known) {\n        return known;\n      }\n      throw new Error(`${NO_ROWS_ERROR} (collection \"${candidate.name ?? candidate.id}\" not found)`);\n    }\n\n    throw new Error(\"[engine] expected a collection name, id, or Collection\");\n  };\n\n  const rowsOf = (target: unknown): RecordModel[] => store.records.list(resolveCollection(target).id);\n\n  const applyExpressions = (records: RecordModel[], expressions: unknown[]): RecordModel[] => {\n    const predicates = expressions.filter(isDbxExpression) as DbxExpression[];\n    const ignored = expressions.length - predicates.length;\n    if (ignored > 0) {\n      warn({\n        kind: \"unsupported-api\",\n        api: \"$dbx\",\n        message: `${ignored} query expression(s) were not built by $dbx and could not be evaluated; they were ignored`,\n      });\n    }\n    return records.filter((record) => predicates.every((predicate) => predicate.matches(record)));\n  };\n\n  /**\n   * PocketBase's `sort` string: comma-separated field names, `-` for\n   * descending. An unknown field simply compares as undefined, the way a\n   * missing column sorts in SQLite. Ordering is `compareForSort` — the same\n   * comparator SQL `ORDER BY` uses, so numbers sort numerically.\n   */\n  const applySort = (records: RecordModel[], sort: unknown): RecordModel[] => {\n    if (typeof sort !== \"string\" || sort.trim() === \"\") {\n      return records;\n    }\n    const terms = sort\n      .split(\",\")\n      .map((term) => term.trim())\n      .filter((term) => term !== \"\")\n      .map((term) => ({ field: term.replace(/^[-+]/, \"\"), descending: term.startsWith(\"-\") }));\n\n    return [...records].sort((a, b) => {\n      for (const term of terms) {\n        const result = compareForSort(readField(a, term.field), readField(b, term.field));\n        if (result !== 0) {\n          return term.descending ? -result : result;\n        }\n      }\n      return 0;\n    });\n  };\n\n  const filterRecords = (\n    target: unknown,\n    filter: unknown,\n    sort?: unknown,\n    limit?: unknown,\n    offset?: unknown,\n    params?: unknown\n  ): RecordModel[] => {\n    let records = rowsOf(target);\n\n    if (typeof filter === \"string\" && filter.trim() !== \"\") {\n      try {\n        const condition = parseCondition(filter);\n        const bound = (params && typeof params === \"object\" ? params : {}) as Record<string, unknown>;\n        records = records.filter((record) => matchCondition(condition, record, bound));\n      } catch (error) {\n        if (!(error instanceof ExpressionError)) {\n          throw error;\n        }\n        reportUnsupported(`filter ${JSON.stringify(filter)}: ${error.message}`);\n        return [];\n      }\n    }\n\n    records = applySort(records, sort);\n\n    const start = typeof offset === \"number\" && offset > 0 ? offset : 0;\n    const count = typeof limit === \"number\" && limit > 0 ? limit : undefined;\n    records = records.slice(start, count === undefined ? undefined : start + count);\n\n    return records;\n  };\n\n  function reportUnsupported(message: string): void {\n    if (strict) {\n      throw new UnsupportedQueryError(`[engine] ${message}`);\n    }\n    warn({ kind: \"unsupported-api\", api: \"app.db\", message: `${message}; the query was skipped` });\n  }\n\n  /** `app.db().newQuery(sql)` */\n  const createQuery = (sql: unknown) => {\n    let params: Record<string, unknown> = {};\n\n    const run = (): StatementResult => {\n      if (typeof sql !== \"string\") {\n        reportUnsupported(\"newQuery() expects a SQL string\");\n        return { rows: [], affected: 0 };\n      }\n      try {\n        const statement = parseStatement(sql);\n        const collection = resolveCollection(statement.table);\n        return executeStatement(\n          statement,\n          {\n            rows: () => store.records.list(collection.id),\n            insert: (values) => store.records.save(new RecordModel(collection, values)),\n            remove: (record) => store.records.delete(record),\n            persist: (record) => store.records.save(record),\n          },\n          params\n        );\n      } catch (error) {\n        if (error instanceof UnsupportedQueryError || error instanceof ExpressionError) {\n          reportUnsupported(error.message);\n          return { rows: [], affected: 0 };\n        }\n        throw error;\n      }\n    };\n\n    const assignTo = (target: unknown, value: unknown): unknown => {\n      if (target && typeof target === \"object\" && value && typeof value === \"object\") {\n        Object.assign(target as Record<string, unknown>, value as Record<string, unknown>);\n        return target;\n      }\n      return value;\n    };\n\n    const query = {\n      bind(values: Record<string, unknown>) {\n        params = { ...params, ...(values ?? {}) };\n        return query;\n      },\n      execute() {\n        const result = run();\n        return { rowsAffected: () => result.affected, lastInsertId: () => 0 };\n      },\n      all(target?: unknown) {\n        const rows = run().rows;\n        return target === undefined ? rows : assignTo(target, rows);\n      },\n      one(target?: unknown) {\n        const rows = run().rows;\n        if (rows.length === 0) {\n          throw new Error(NO_ROWS_ERROR);\n        }\n        return target === undefined ? rows[0] : assignTo(target, rows[0]);\n      },\n      row(target?: unknown) {\n        return query.one(target);\n      },\n    };\n\n    return query;\n  };\n\n  const methods: Record<string, (...args: any[]) => unknown> = {\n    findRecordById(target: unknown, id: unknown) {\n      const collection = resolveCollection(target);\n      const record = store.records.getById(collection.id, String(id));\n      if (!record) {\n        throw new Error(`${NO_ROWS_ERROR} (record \"${String(id)}\" in \"${collection.name}\")`);\n      }\n      return record;\n    },\n\n    findRecordsByIds(target: unknown, ids: unknown, ...expressions: unknown[]) {\n      const collection = resolveCollection(target);\n      const wanted = Array.isArray(ids) ? ids.map((id) => String(id)) : [String(ids)];\n      const found = wanted\n        .map((id) => store.records.getById(collection.id, id))\n        .filter((record): record is RecordModel => record !== undefined);\n      return applyExpressions(found, expressions);\n    },\n\n    findAllRecords(target: unknown, ...expressions: unknown[]) {\n      return applyExpressions(rowsOf(target), expressions);\n    },\n\n    findFirstRecordByData(target: unknown, key: unknown, value: unknown) {\n      const match = rowsOf(target).find((record) =>\n        matchCondition(\n          {\n            kind: \"compare\",\n            operator: \"=\",\n            left: { kind: \"field\", name: String(key) },\n            right: { kind: \"value\", value },\n          },\n          record\n        )\n      );\n      if (!match) {\n        throw new Error(`${NO_ROWS_ERROR} (${String(key)}=${String(value)})`);\n      }\n      return match;\n    },\n\n    findRecordsByFilter(\n      target: unknown,\n      filter: unknown,\n      sort?: unknown,\n      limit?: unknown,\n      offset?: unknown,\n      params?: unknown\n    ) {\n      return filterRecords(target, filter, sort, limit, offset, params);\n    },\n\n    findFirstRecordByFilter(target: unknown, filter: unknown, params?: unknown) {\n      const [first] = filterRecords(target, filter, undefined, 1, 0, params);\n      if (!first) {\n        throw new Error(`${NO_ROWS_ERROR} (${String(filter)})`);\n      }\n      return first;\n    },\n\n    findAuthRecordByEmail(target: unknown, email: unknown) {\n      return methods.findFirstRecordByData(target, \"email\", email);\n    },\n\n    countRecords(target: unknown, ...expressions: unknown[]) {\n      return applyExpressions(rowsOf(target), expressions).length;\n    },\n\n    db() {\n      return { newQuery: (sql: unknown) => createQuery(sql) };\n    },\n\n    /**\n     * PocketBase hands the callback a transactional app. Everything the\n     * runner executes is already inside one transaction, so the callback\n     * receives the same app; a throw still rolls the whole migration back.\n     */\n    runInTransaction(callback: unknown) {\n      if (typeof callback === \"function\") {\n        return (callback as (app: unknown) => unknown)(boundApp);\n      }\n      return undefined;\n    },\n  };\n\n  let boundApp: unknown;\n\n  return {\n    methods,\n    bindApp: (app: unknown) => {\n      boundApp = app;\n    },\n  };\n}\n","/**\n * SimulatedApp — the `app` handed to a migration's up() function\n *\n * Implements the schema-level surface of PocketBase's transactional app\n * (findCollectionByNameOrId / save / delete / importCollections). Everything\n * else — record and query APIs like findRecordById, db(), etc. — is handled\n * by a strictness-controlled Proxy: lenient mode records a warning and\n * returns an inert no-op value so schema-only replay of hand-written data\n * migrations still succeeds; strict mode throws.\n *\n * With `records: \"simulate\"` those data-layer methods are real instead\n * (see `data-api.ts`), backed by the in-memory record store.\n */\n\nimport { Collection, ensureAuthSystemFields } from \"./collection\";\nimport { createDataApi } from \"./data-api\";\nimport { generateRuntimeFieldId } from \"./fields\";\nimport { RecordModel } from \"./records\";\nimport type { CollectionStore } from \"./store\";\nimport type { EngineOptions, EngineWarning, RawCollection } from \"./types\";\n\nexport interface WarningSink {\n  (warning: EngineWarning): void;\n}\n\n/** Identifies the values `createInertStub` returns, which pretend to be anything */\nconst INERT_STUB = Symbol.for(\"pocketbase-zod-schema.inertStub\");\n\nexport function isInertStub(value: unknown): boolean {\n  if (value === null || (typeof value !== \"object\" && typeof value !== \"function\")) {\n    return false;\n  }\n  return (value as Record<symbol, unknown>)[INERT_STUB] === true;\n}\n\n/**\n * A callable, chainable, inert value returned by lenient stubs so chains\n * like `app.db().newQuery(\"...\").execute()` don't crash. Every call and\n * property access returns the stub itself; primitive coercion yields\n * neutral values.\n *\n * It also pretends to be an empty list: `length` is 0 and iterating it\n * yields nothing. Unsimulated list finders (`app.findRecordsByFilter`, …)\n * return this, and the usual `for (const r of found)` /\n * `while (found.length) {}` shapes in hand-written data migrations must\n * behave as \"nothing matched\" rather than crash or spin forever.\n */\nexport function createInertStub(name: string, options: EngineOptions, warn: WarningSink): any {\n  // Must be a full function (not an arrow) so the Proxy construct trap can\n  // service `new Record()`-style calls\n  const target = function inertStubTarget() {\n    return undefined;\n  };\n  const stub: any = new Proxy(target, {\n    get(_target, prop) {\n      if (prop === INERT_STUB) {\n        return true;\n      }\n      if (prop === Symbol.toPrimitive) {\n        return () => \"\";\n      }\n      if (prop === \"toString\") {\n        return () => \"\";\n      }\n      if (prop === \"valueOf\") {\n        return () => 0;\n      }\n      // Not a thenable — await/then chains must not treat this as a promise\n      if (prop === \"then\") {\n        return undefined;\n      }\n      // Empty-list behaviour: terminates `while (records.length)` loops and\n      // makes `for (const r of records)` / `[...records]` a no-op\n      if (prop === \"length\") {\n        return 0;\n      }\n      if (prop === Symbol.iterator) {\n        return function* emptyIterator() {\n          // nothing to yield — the call that produced this stub was not simulated\n        };\n      }\n      if (typeof prop === \"symbol\") {\n        return undefined;\n      }\n      return createInertStub(`${name}.${prop}`, options, warn);\n    },\n    apply() {\n      if (options.strictness === \"strict\") {\n        throw new Error(`[engine] ${name}() is not supported by the migration simulation engine (strict mode)`);\n      }\n      warn({\n        kind: \"unsupported-api\",\n        api: name,\n        message: `${name}() is not simulated; call was a no-op`,\n      });\n      return stub;\n    },\n    construct() {\n      if (options.strictness === \"strict\") {\n        throw new Error(`[engine] new ${name}() is not supported by the migration simulation engine (strict mode)`);\n      }\n      warn({\n        kind: \"unsupported-api\",\n        api: name,\n        message: `new ${name}() is not simulated; result is inert`,\n      });\n      return stub;\n    },\n  });\n  return stub;\n}\n\nclass SimulatedAppImpl {\n  constructor(\n    private store: CollectionStore,\n    private options: EngineOptions,\n    private warn: WarningSink\n  ) {}\n\n  findCollectionByNameOrId(nameOrId: string): Collection {\n    const collection = this.store.getByNameOrId(nameOrId);\n    if (!collection) {\n      // Matches the error PocketBase surfaces for a missing collection\n      throw new Error(`sql: no rows in result set (collection \"${nameOrId}\" not found)`);\n    }\n    return collection;\n  }\n\n  save(model: any): void {\n    // A record only reaches here with record simulation on; without it\n    // `new Record()` produced an inert stub, handled below\n    if (model instanceof RecordModel) {\n      this.store.records.save(model);\n      return;\n    }\n    if (this.skipInertModel(model, \"save\")) {\n      return;\n    }\n\n    const collection = this.toCollection(model);\n    if (!collection.name) {\n      throw new Error(\"[engine] cannot save a collection without a name\");\n    }\n    // PocketBase restores missing auth system fields as part of the save\n    ensureAuthSystemFields(collection);\n    // Safety net: FieldsList assigns ids on add, so this only fires for a\n    // field whose id a migration blanked out after the fact\n    for (const field of collection.fields) {\n      if (typeof field.id !== \"string\" || field.id === \"\") {\n        field.id = generateRuntimeFieldId(\n          typeof field.type === \"string\" ? field.type : \"\",\n          typeof field.name === \"string\" ? field.name : \"\"\n        );\n      }\n    }\n    this.store.upsert(collection);\n  }\n\n  delete(model: any): void {\n    if (model instanceof RecordModel) {\n      this.store.records.delete(model);\n      return;\n    }\n    if (this.skipInertModel(model, \"delete\")) {\n      return;\n    }\n    if (model instanceof Collection) {\n      this.store.removeById(model.id);\n      return;\n    }\n    if (typeof model === \"string\") {\n      const collection = this.store.getByNameOrId(model);\n      if (collection) {\n        this.store.removeById(collection.id);\n      }\n      return;\n    }\n    if (model && typeof model.id === \"string\") {\n      this.store.removeById(model.id);\n    }\n  }\n\n  /**\n   * `app.save(record)` in a data migration hands us whatever `new Record()`\n   * produced. Without record simulation that is an inert stub, and treating\n   * it as a collection would fail the whole replay over rows nobody is\n   * tracking — so the call is reported and skipped, like every other\n   * unsimulated data operation.\n   */\n  private skipInertModel(model: unknown, operation: string): boolean {\n    if (!isInertStub(model)) {\n      return false;\n    }\n    if (this.options.strictness === \"strict\") {\n      throw new Error(`[engine] app.${operation}() received an unsimulated model (strict mode)`);\n    }\n    this.warn({\n      kind: \"unsupported-api\",\n      api: `app.${operation}`,\n      message:\n        `app.${operation}() was called with an unsimulated model; the call was a no-op. ` +\n        `Set records: \"simulate\" to execute record operations.`,\n    });\n    return true;\n  }\n\n  /**\n   * What native snapshot migrations call:\n   * `return app.importCollections(snapshot, deleteMissing)`\n   */\n  importCollections(rawCollections: RawCollection[], deleteMissing = false): void {\n    if (!Array.isArray(rawCollections)) {\n      throw new Error(\"[engine] importCollections expects an array of collections\");\n    }\n    const imported = new Set<string>();\n    for (const raw of rawCollections) {\n      const collection = this.toCollection(raw);\n      ensureAuthSystemFields(collection);\n      this.store.upsert(collection);\n      imported.add(collection.id);\n    }\n    if (deleteMissing) {\n      for (const existing of this.store.list()) {\n        if (!imported.has(existing.id)) {\n          this.store.removeById(existing.id);\n        }\n      }\n    }\n  }\n\n  private toCollection(model: any): Collection {\n    if (model instanceof Collection) {\n      return model;\n    }\n    if (model && typeof model === \"object\") {\n      return new Collection(model);\n    }\n    throw new Error(\"[engine] expected a collection object\");\n  }\n}\n\nexport type SimulatedApp = SimulatedAppImpl;\n\n/**\n * The data-layer surface installed alongside the app when record simulation\n * is on, so the sandbox can expose the same `Record` and `$dbx` objects the\n * app's finders return.\n */\nexport interface SimulatedAppBundle {\n  app: SimulatedApp;\n  /** Null when records are not simulated */\n  data: ReturnType<typeof createDataApi> | null;\n}\n\nexport function createSimulatedAppBundle(\n  store: CollectionStore,\n  options: EngineOptions,\n  warn: WarningSink\n): SimulatedAppBundle {\n  const impl = new SimulatedAppImpl(store, options, warn);\n  const data = options.records === \"simulate\" ? createDataApi(store, options, warn) : null;\n\n  const app = new Proxy(impl, {\n    get(target, prop, receiver) {\n      if (prop in target || typeof prop === \"symbol\") {\n        return Reflect.get(target, prop, receiver);\n      }\n      const name = String(prop);\n      if (data && name in data.methods) {\n        return data.methods[name];\n      }\n      return createInertStub(`app.${name}`, options, warn);\n    },\n  }) as SimulatedApp;\n\n  data?.bindApp(app);\n\n  return { app, data };\n}\n\nexport function createSimulatedApp(store: CollectionStore, options: EngineOptions, warn: WarningSink): SimulatedApp {\n  return createSimulatedAppBundle(store, options, warn).app;\n}\n","/**\n * unmarshal(data, dst) — the PocketBase JSVM helper migrations use to merge\n * a JSON-shaped object into a collection (or any Go struct).\n *\n * Semantics follow Go's json.Unmarshal into an existing struct: plain\n * objects merge key by key, while arrays and scalars replace the target\n * value wholesale. `unmarshal({indexes: []}, collection)` therefore clears\n * the indexes list, which is exactly what PocketBase's generated down\n * migrations rely on.\n */\n\nimport { Collection } from \"./collection\";\nimport { FieldsList } from \"./fields-list\";\n\nfunction isPlainObject(value: unknown): value is Record<string, any> {\n  if (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n    return false;\n  }\n  // Cross-realm safe: vm-created literals have a foreign Object prototype\n  const proto = Object.getPrototypeOf(value);\n  return proto === null || Object.getPrototypeOf(proto) === null;\n}\n\nexport function unmarshal(data: unknown, dst: unknown): void {\n  if (!isPlainObject(data) || dst === null || typeof dst !== \"object\") {\n    return;\n  }\n\n  const target = dst as Record<string, any>;\n\n  for (const [key, value] of Object.entries(data)) {\n    if (key === \"fields\" && target instanceof Collection && Array.isArray(value)) {\n      target.fields.replaceAll(value);\n      continue;\n    }\n    if (key === \"fields\" && target.fields instanceof FieldsList && Array.isArray(value)) {\n      target.fields.replaceAll(value);\n      continue;\n    }\n\n    if (Array.isArray(value)) {\n      target[key] = [...value];\n    } else if (isPlainObject(value)) {\n      if (isPlainObject(target[key])) {\n        unmarshal(value, target[key]);\n      } else {\n        target[key] = {};\n        unmarshal(value, target[key]);\n      }\n    } else {\n      target[key] = value;\n    }\n  }\n}\n","/**\n * Sandbox globals for the migration execution context\n *\n * Recreates the PocketBase JSVM global surface a migration file sees:\n * migrate(), the Collection/Field constructors, unmarshal(), and the Go\n * binding globals ($app, $os, $dbx, ...). The sandbox contains NO Node\n * globals — no require, process, or fs — approximating goja, where none\n * of those exist either.\n */\n\nimport { Collection } from \"./collection\";\nimport { createInertStub, type SimulatedApp, type WarningSink } from \"./app\";\nimport { createDbx } from \"./dbx\";\nimport { FIELD_CONSTRUCTORS } from \"./fields\";\nimport { RecordModel } from \"./records\";\nimport { unmarshal } from \"./unmarshal\";\nimport type { EngineOptions } from \"./types\";\n\nexport interface MigrationRegistration {\n  up?: (app: SimulatedApp) => unknown;\n  down?: (app: SimulatedApp) => unknown;\n}\n\nexport interface SandboxHandles {\n  sandbox: Record<string, any>;\n  registrations: MigrationRegistration[];\n  /** The runner points this at the current transactional app during up() */\n  setCurrentApp: (app: SimulatedApp | null) => void;\n}\n\nconst STUBBED_GLOBALS = [\"$os\", \"$dbx\", \"$security\", \"$filesystem\", \"$http\", \"$mails\", \"$template\", \"Record\", \"DateTime\"];\n\nexport function buildSandbox(options: EngineOptions, warn: WarningSink): SandboxHandles {\n  const registrations: MigrationRegistration[] = [];\n  let currentApp: SimulatedApp | null = null;\n\n  const consoleMethod =\n    (level: string) =>\n    (...args: unknown[]) => {\n      warn({\n        kind: \"console\",\n        message: `console.${level}: ${args.map((arg) => stringifyArg(arg)).join(\" \")}`,\n      });\n    };\n\n  const sandbox: Record<string, any> = {\n    migrate(up?: MigrationRegistration[\"up\"], down?: MigrationRegistration[\"down\"]) {\n      registrations.push({ up, down });\n    },\n    Collection,\n    unmarshal,\n    ...FIELD_CONSTRUCTORS,\n    console: {\n      log: consoleMethod(\"log\"),\n      info: consoleMethod(\"info\"),\n      warn: consoleMethod(\"warn\"),\n      error: consoleMethod(\"error\"),\n      debug: consoleMethod(\"debug\"),\n    },\n  };\n\n  // Record and $dbx become real when record simulation is on; they hold no\n  // state of their own, so the sandbox can own them for the whole file while\n  // the store-bound half lives on the per-run app (see data-api.ts)\n  const simulatesRecords = options.records === \"simulate\";\n\n  for (const name of STUBBED_GLOBALS) {\n    if (simulatesRecords && (name === \"Record\" || name === \"$dbx\")) {\n      continue;\n    }\n    sandbox[name] = createInertStub(name, options, warn);\n  }\n\n  if (simulatesRecords) {\n    sandbox.Record = RecordModel;\n    sandbox.$dbx = createDbx();\n  }\n\n  // Some migrations use the global $app instead of the up() callback\n  // argument; bind it to the same transactional app while up() runs\n  Object.defineProperty(sandbox, \"$app\", {\n    enumerable: true,\n    get() {\n      return currentApp ?? createInertStub(\"$app\", options, warn);\n    },\n  });\n\n  return {\n    sandbox,\n    registrations,\n    setCurrentApp(app) {\n      currentApp = app;\n    },\n  };\n}\n\nfunction stringifyArg(arg: unknown): string {\n  if (typeof arg === \"string\") {\n    return arg;\n  }\n  try {\n    return JSON.stringify(arg) ?? String(arg);\n  } catch {\n    return String(arg);\n  }\n}\n","/**\n * Runner — executes one migration file against a CollectionStore\n *\n * Evaluation happens in a vm context built from the sandbox globals; the\n * file's migrate(up, down) call registers its closures. The requested\n * direction then runs transactionally: the store is cloned, the closure is\n * applied to the clone, and the clone replaces the store only on success.\n * The closure is invoked from inside the context (not host code) so the vm\n * timeout also bounds infinite loops within migration bodies.\n *\n * State reconstruction only ever runs `up`, which structurally rules out\n * replaying rollback statements as forward operations. `down` is executed on request (`executeMigrationDownSource`),\n * for rollback verification — see `verify.ts`. Downs run in reverse\n * registration order, mirroring how PocketBase rolls back.\n */\n\nimport * as fs from \"fs\";\nimport * as vm from \"vm\";\nimport { MigrationExecutionError } from \"../errors\";\nimport { createSimulatedApp } from \"./app\";\nimport { buildSandbox } from \"./globals\";\nimport type { CollectionStore } from \"./store\";\nimport type { EngineOptions, EngineWarning, MigrationDirection, MigrationExecutionResult } from \"./types\";\n\nconst DEFAULT_TIMEOUT_MS = 5000;\n\nexport function executeMigrationSource(\n  source: string,\n  store: CollectionStore,\n  options: EngineOptions & { filename?: string } = {}\n): MigrationExecutionResult {\n  return runMigrationSource(source, store, options, \"up\");\n}\n\nexport function executeMigrationFile(\n  filePath: string,\n  store: CollectionStore,\n  options: EngineOptions = {}\n): MigrationExecutionResult {\n  const source = fs.readFileSync(filePath, \"utf-8\");\n  return executeMigrationSource(source, store, { ...options, filename: filePath });\n}\n\n/**\n * Runs the file's `down()` closures against the store, newest registration\n * first. A file that registers no `down` leaves the store untouched and\n * reports `applied: false`.\n */\nexport function executeMigrationDownSource(\n  source: string,\n  store: CollectionStore,\n  options: EngineOptions & { filename?: string } = {}\n): MigrationExecutionResult {\n  return runMigrationSource(source, store, options, \"down\");\n}\n\nexport function executeMigrationDownFile(\n  filePath: string,\n  store: CollectionStore,\n  options: EngineOptions = {}\n): MigrationExecutionResult {\n  const source = fs.readFileSync(filePath, \"utf-8\");\n  return executeMigrationDownSource(source, store, { ...options, filename: filePath });\n}\n\nfunction runMigrationSource(\n  source: string,\n  store: CollectionStore,\n  options: EngineOptions & { filename?: string },\n  direction: MigrationDirection\n): MigrationExecutionResult {\n  const filename = options.filename ?? \"<migration>\";\n  const timeout = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n  const warnings: EngineWarning[] = [];\n  const warn = (warning: EngineWarning) => {\n    const withFile = { ...warning, file: warning.file ?? filename };\n    warnings.push(withFile);\n    options.onWarning?.(withFile);\n  };\n\n  const { sandbox, registrations, setCurrentApp } = buildSandbox(options, warn);\n  const context = vm.createContext(sandbox);\n\n  try {\n    new vm.Script(source, { filename }).runInContext(context, { timeout });\n  } catch (error) {\n    throw new MigrationExecutionError(\n      `Failed to evaluate migration file: ${error instanceof Error ? error.message : String(error)}`,\n      filename,\n      \"evaluate\",\n      error instanceof Error ? error : undefined\n    );\n  }\n\n  sandbox.__engineRegistrations__ = registrations;\n\n  // Rollback undoes the most recent registration first\n  const order = registrations.map((_, index) => index);\n  if (direction === \"down\") {\n    order.reverse();\n  }\n\n  let applied = false;\n  for (const index of order) {\n    const closure = registrations[index]?.[direction];\n    if (typeof closure !== \"function\") {\n      continue;\n    }\n\n    const tx = store.clone();\n    const app = createSimulatedApp(tx, options, warn);\n    sandbox.__engineApp__ = app;\n    setCurrentApp(app);\n\n    try {\n      vm.runInContext(`__engineRegistrations__[${index}].${direction}(__engineApp__)`, context, { timeout });\n    } catch (error) {\n      throw new MigrationExecutionError(\n        `Migration ${direction}() failed: ${error instanceof Error ? error.message : String(error)}`,\n        filename,\n        direction,\n        error instanceof Error ? error : undefined\n      );\n    } finally {\n      setCurrentApp(null);\n      delete sandbox.__engineApp__;\n    }\n\n    store.replaceWith(tx);\n    applied = true;\n  }\n\n  return { file: filename, direction, applied, warnings };\n}\n","/**\n * `_migrations` table awareness\n *\n * PocketBase records every migration it has run in an internal `_migrations`\n * table (`file` TEXT PRIMARY KEY, `applied` INTEGER). Replay that assumes\n * every file on disk is applied reconstructs a state the database may never\n * have been in: a file added but not yet run, or a file deleted from disk\n * after it ran, both produce silent drift.\n *\n * This module reads that table so replay can start from an actual checkpoint,\n * and so `status --verify` can name the difference between disk and database.\n *\n * The read is done with Node's built-in `node:sqlite` (Node >= 22.5), fetched\n * through `process.getBuiltinModule` so neither the ESM nor the CJS bundle\n * carries a hard dependency on it. `pb_data/data.db` is opened **read-only**;\n * a running PocketBase instance is never disturbed.\n */\n\nimport * as fs from \"fs\";\nimport * as path from \"path\";\n\n/** PocketBase's internal table of applied migrations */\nexport const APPLIED_MIGRATIONS_TABLE = \"_migrations\";\n\n/** PocketBase's SQLite database file inside a pb_data directory */\nexport const POCKETBASE_DATABASE_FILENAME = \"data.db\";\n\nexport interface AppliedMigration {\n  /** Filename as PocketBase recorded it, e.g. \"1712345678_created_Posts.js\" */\n  file: string;\n  /** Unix seconds from `_migrations.applied`, when the column has a value */\n  applied?: number;\n}\n\nexport interface AppliedMigrationsSource {\n  /** Where the list came from — a database path, or a caller-supplied label */\n  origin: string;\n  /** Every row, in application order */\n  entries: AppliedMigration[];\n  /**\n   * Entries PocketBase's own Go core migrations contributed (`*.go`). They\n   * never correspond to a file in a pb_migrations directory, so they are\n   * kept separate from `entries` rather than reported as missing.\n   */\n  coreEntries: AppliedMigration[];\n}\n\n/**\n * Raised when an applied-migrations list was requested but could not be read.\n * Callers that treat the list as optional should catch this and fall back to\n * \"assume everything on disk is applied\".\n */\nexport class AppliedMigrationsError extends Error {\n  public readonly source?: string;\n  public readonly originalError?: Error;\n\n  constructor(message: string, source?: string, originalError?: Error) {\n    super(message);\n    this.name = \"AppliedMigrationsError\";\n    this.source = source;\n    this.originalError = originalError;\n    Object.setPrototypeOf(this, AppliedMigrationsError.prototype);\n  }\n}\n\n/**\n * Builds a source from an explicit list of filenames (paths are reduced to\n * their basename, so a caller can pass either).\n */\nexport function appliedMigrationsFromList(files: string[], origin = \"<list>\"): AppliedMigrationsSource {\n  const entries: AppliedMigration[] = [];\n  const coreEntries: AppliedMigration[] = [];\n\n  for (const file of files) {\n    const entry: AppliedMigration = { file: path.basename(file) };\n    (isCoreMigration(entry.file) ? coreEntries : entries).push(entry);\n  }\n\n  return { origin, entries, coreEntries };\n}\n\n/**\n * The pb_data directory PocketBase uses alongside a pb_migrations directory.\n * Both live under the PocketBase working directory, so pb_data is a sibling.\n */\nexport function defaultDataDirectory(migrationsPath: string): string {\n  return path.resolve(path.dirname(path.resolve(migrationsPath)), \"pb_data\");\n}\n\n/**\n * Resolves a user-supplied pb_data path (directory or database file) to the\n * SQLite file to open. Returns null when nothing usable exists.\n */\nexport function resolveDatabasePath(dataPathOrFile: string): string | null {\n  const resolved = path.resolve(dataPathOrFile);\n  if (!fs.existsSync(resolved)) {\n    return null;\n  }\n  if (fs.statSync(resolved).isDirectory()) {\n    const candidate = path.join(resolved, POCKETBASE_DATABASE_FILENAME);\n    return fs.existsSync(candidate) ? candidate : null;\n  }\n  return resolved;\n}\n\n/**\n * Reads `_migrations` out of a PocketBase SQLite database.\n *\n * @param dataPathOrFile - A pb_data directory or a data.db file\n * @throws AppliedMigrationsError when the runtime, file, or table is unusable\n */\nexport function readAppliedMigrations(dataPathOrFile: string): AppliedMigrationsSource {\n  const databasePath = resolveDatabasePath(dataPathOrFile);\n  if (!databasePath) {\n    throw new AppliedMigrationsError(\n      `No PocketBase database found at ${path.resolve(dataPathOrFile)}. ` +\n        `Expected a data.db file, or a pb_data directory containing one.`,\n      dataPathOrFile\n    );\n  }\n\n  const sqlite = loadSqliteModule();\n  if (!sqlite) {\n    throw new AppliedMigrationsError(\n      `Reading the _migrations table requires Node's built-in node:sqlite module (Node >= 22.5). ` +\n        `This process runs ${process.version}. Pass the applied migrations explicitly instead.`,\n      databasePath\n    );\n  }\n\n  let database: { prepare: (sql: string) => { all: () => unknown[] }; close: () => void };\n  try {\n    database = withoutSqliteExperimentalWarning(() => new sqlite.DatabaseSync(databasePath, { readOnly: true }));\n  } catch (error) {\n    throw new AppliedMigrationsError(\n      `Failed to open ${databasePath}: ${errorMessage(error)}`,\n      databasePath,\n      error instanceof Error ? error : undefined\n    );\n  }\n\n  try {\n    const rows = database\n      .prepare(`SELECT file, applied FROM ${APPLIED_MIGRATIONS_TABLE} ORDER BY applied ASC, file ASC`)\n      .all() as { file?: unknown; applied?: unknown }[];\n\n    const entries: AppliedMigration[] = [];\n    const coreEntries: AppliedMigration[] = [];\n\n    for (const row of rows) {\n      if (typeof row?.file !== \"string\" || row.file === \"\") {\n        continue;\n      }\n      const entry: AppliedMigration = { file: row.file };\n      const applied = Number(row.applied);\n      if (Number.isFinite(applied) && applied > 0) {\n        entry.applied = applied;\n      }\n      (isCoreMigration(entry.file) ? coreEntries : entries).push(entry);\n    }\n\n    return { origin: databasePath, entries, coreEntries };\n  } catch (error) {\n    if (error instanceof AppliedMigrationsError) {\n      throw error;\n    }\n    throw new AppliedMigrationsError(\n      `Failed to read the ${APPLIED_MIGRATIONS_TABLE} table from ${databasePath}: ${errorMessage(error)}`,\n      databasePath,\n      error instanceof Error ? error : undefined\n    );\n  } finally {\n    try {\n      database.close();\n    } catch {\n      // A close failure cannot invalidate rows already read\n    }\n  }\n}\n\n/**\n * Best-effort read: returns null instead of throwing when there is simply no\n * database to read (the common case for a checkout that has never run\n * PocketBase). Genuine failures — an unreadable file, a missing table, a\n * runtime without node:sqlite — still throw, because silently assuming\n * \"everything is applied\" is the drift this module exists to catch.\n */\nexport function readAppliedMigrationsIfPresent(dataPathOrFile: string): AppliedMigrationsSource | null {\n  if (!resolveDatabasePath(dataPathOrFile)) {\n    return null;\n  }\n  return readAppliedMigrations(dataPathOrFile);\n}\n\n/**\n * PocketBase's own Go core migrations are recorded in `_migrations` alongside\n * JS ones. They have no counterpart on disk in a pb_migrations directory.\n */\nfunction isCoreMigration(file: string): boolean {\n  return !file.endsWith(\".js\");\n}\n\ninterface SqliteModule {\n  DatabaseSync: new (\n    path: string,\n    options?: { readOnly?: boolean }\n  ) => { prepare: (sql: string) => { all: () => unknown[] }; close: () => void };\n}\n\n/**\n * Loads node:sqlite without a static import, so the module keeps working on\n * runtimes that do not ship it (the rest of the engine does not need it).\n */\nfunction loadSqliteModule(): SqliteModule | null {\n  const getBuiltinModule = (process as NodeJS.Process & { getBuiltinModule?: (id: string) => unknown })\n    .getBuiltinModule;\n  if (typeof getBuiltinModule !== \"function\") {\n    return null;\n  }\n  try {\n    const module = withoutSqliteExperimentalWarning(() => getBuiltinModule(\"node:sqlite\") as SqliteModule | undefined);\n    return module && typeof module.DatabaseSync === \"function\" ? module : null;\n  } catch {\n    return null;\n  }\n}\n\n/**\n * node:sqlite emits an ExperimentalWarning on load and on open. Reading a\n * read-only table is a bounded, deliberate use of it, and a CLI that prints a\n * Node warning every time someone runs `status --verify` is just noise —\n * so the warning is dropped for the duration of the call, and only that one.\n */\nfunction withoutSqliteExperimentalWarning<T>(operation: () => T): T {\n  const original = process.emitWarning;\n\n  process.emitWarning = ((warning: unknown, ...rest: unknown[]) => {\n    const name = typeof warning === \"object\" && warning !== null ? (warning as Error).name : rest[0];\n    const message = typeof warning === \"string\" ? warning : ((warning as Error)?.message ?? \"\");\n    if (name === \"ExperimentalWarning\" && /sqlite/i.test(message)) {\n      return;\n    }\n    (original as (...args: unknown[]) => void).call(process, warning, ...rest);\n  }) as typeof process.emitWarning;\n\n  try {\n    return operation();\n  } finally {\n    process.emitWarning = original;\n  }\n}\n\nfunction errorMessage(error: unknown): string {\n  return error instanceof Error ? error.message : String(error);\n}\n","/**\n * Replay planning — which migration files reconstruct the current state\n *\n * Without knowledge of PocketBase's `_migrations` table, replay assumes every\n * file on disk has been applied. That is right for the common case and wrong\n * in exactly the situations that matter: a migration written but not yet run,\n * or a file removed from disk after it ran. Both produce a reconstructed state\n * the database was never in, and therefore a wrong diff.\n *\n * Given an applied-migrations list (see `applied-migrations.ts`), this module\n * turns a pb_migrations directory into a plan:\n *\n * - `filesToReplay` — the applied prefix, starting at the newest *applied*\n *   snapshot, which is the checkpoint replay should start from\n * - `pending` — on disk, never applied\n * - `missing` — applied, no longer on disk\n * - `outOfOrder` — pending files whose timestamp sits behind an already\n *   applied one, so they will be applied out of authoring order\n */\n\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport type { AppliedMigrationsSource } from \"./applied-migrations\";\nimport { appliedMigrationsFromList } from \"./applied-migrations\";\n\n/**\n * Extracts the timestamp prefix from a migration filename.\n * Migration files are named `[timestamp]_[description].js`.\n *\n * @param filename - Migration filename (basename, not a path)\n * @returns Timestamp as a number, or null when the name is not prefixed\n */\nexport function extractTimestampFromFilename(filename: string): number | null {\n  const match = filename.match(/^(\\d+)_/);\n  if (match) {\n    return parseInt(match[1], 10);\n  }\n  return null;\n}\n\n/** A migration file discovered on disk */\nexport interface DiscoveredMigration {\n  /** Absolute path */\n  path: string;\n  /** Basename, which is what `_migrations.file` stores */\n  name: string;\n  timestamp: number;\n  /** PocketBase's own `*_collections_snapshot.js` files */\n  isSnapshot: boolean;\n}\n\nexport interface MigrationPlan {\n  /** The snapshot the replay starts from, when the directory has one */\n  snapshotFile: string | null;\n  /** Absolute paths to execute, in timestamp order */\n  filesToReplay: string[];\n  /** Basenames present on disk but absent from `_migrations` */\n  pending: string[];\n  /** Basenames recorded in `_migrations` with no file on disk */\n  missing: string[];\n  /**\n   * Basenames from `pending` whose timestamp precedes an already-applied\n   * migration. PocketBase will still run them, but after migrations authored\n   * later — so the state they produce depends on apply order.\n   */\n  outOfOrder: string[];\n  /** False when no applied list was supplied: every file is assumed applied */\n  appliedKnown: boolean;\n  /** Where the applied list came from, when there was one */\n  appliedOrigin?: string;\n  /** Number of JS migrations recorded as applied */\n  appliedCount: number;\n  /** True when disk and `_migrations` agree exactly */\n  inSync: boolean;\n}\n\nexport interface PlanOptions {\n  /**\n   * The applied-migrations list. A plain array of filenames is accepted as a\n   * shorthand. Omit (or pass null) to assume every file on disk is applied.\n   */\n  applied?: AppliedMigrationsSource | string[] | null;\n}\n\n/**\n * Lists every timestamped `.js` migration in a directory, in timestamp order.\n * Returns an empty list when the directory does not exist.\n */\nexport function discoverMigrations(migrationsPath: string): DiscoveredMigration[] {\n  if (!fs.existsSync(migrationsPath) || !fs.statSync(migrationsPath).isDirectory()) {\n    return [];\n  }\n\n  const discovered: DiscoveredMigration[] = [];\n  for (const name of fs.readdirSync(migrationsPath)) {\n    if (!name.endsWith(\".js\")) {\n      continue;\n    }\n    const timestamp = extractTimestampFromFilename(name);\n    if (timestamp === null) {\n      continue;\n    }\n    discovered.push({\n      path: path.join(migrationsPath, name),\n      name,\n      timestamp,\n      isSnapshot: name.endsWith(\"_collections_snapshot.js\") || name.endsWith(\"_snapshot.js\"),\n    });\n  }\n\n  // Ties broken by name so the order is stable across filesystems\n  discovered.sort((a, b) => a.timestamp - b.timestamp || a.name.localeCompare(b.name));\n  return discovered;\n}\n\n/**\n * Builds the replay plan for a migrations directory.\n *\n * Without an applied list this reproduces the directory's default replay\n * window — newest snapshot plus everything after it — so the plan is a\n * drop-in for the previous file selection.\n */\nexport function planMigrationReplay(migrationsPath: string, options: PlanOptions = {}): MigrationPlan {\n  const discovered = discoverMigrations(migrationsPath);\n  const applied = normalizeApplied(options.applied);\n\n  if (!applied) {\n    const snapshot = lastSnapshot(discovered);\n    return {\n      snapshotFile: snapshot?.path ?? null,\n      filesToReplay: replayWindow(discovered, snapshot).map((migration) => migration.path),\n      pending: [],\n      missing: [],\n      outOfOrder: [],\n      appliedKnown: false,\n      appliedCount: 0,\n      inSync: true,\n    };\n  }\n\n  const appliedNames = new Set(applied.entries.map((entry) => entry.file));\n  const onDisk = new Set(discovered.map((migration) => migration.name));\n\n  // Start from the newest snapshot that was actually applied: a snapshot\n  // sitting on disk unapplied is not a checkpoint the database ever reached\n  const snapshot = lastSnapshot(discovered.filter((migration) => appliedNames.has(migration.name)));\n  const filesToReplay = replayWindow(discovered, snapshot)\n    .filter((migration) => appliedNames.has(migration.name))\n    .map((migration) => migration.path);\n\n  const pendingMigrations = discovered.filter((migration) => !appliedNames.has(migration.name));\n  const missing = applied.entries.filter((entry) => !onDisk.has(entry.file)).map((entry) => entry.file);\n\n  const newestAppliedTimestamp = discovered\n    .filter((migration) => appliedNames.has(migration.name))\n    .reduce((newest, migration) => Math.max(newest, migration.timestamp), 0);\n  const outOfOrder = pendingMigrations\n    .filter((migration) => migration.timestamp < newestAppliedTimestamp)\n    .map((migration) => migration.name);\n\n  const pending = pendingMigrations.map((migration) => migration.name);\n\n  return {\n    snapshotFile: snapshot?.path ?? null,\n    filesToReplay,\n    pending,\n    missing,\n    outOfOrder,\n    appliedKnown: true,\n    appliedOrigin: applied.origin,\n    appliedCount: applied.entries.length,\n    inSync: pending.length === 0 && missing.length === 0,\n  };\n}\n\n/**\n * The files a replay executes: the snapshot, then every non-snapshot\n * migration authored after it. Snapshots supersede everything before them,\n * so earlier files are never re-executed.\n */\nfunction replayWindow(discovered: DiscoveredMigration[], snapshot: DiscoveredMigration | null): DiscoveredMigration[] {\n  if (!snapshot) {\n    return discovered.filter((migration) => !migration.isSnapshot);\n  }\n  return [\n    snapshot,\n    ...discovered.filter((migration) => !migration.isSnapshot && migration.timestamp > snapshot.timestamp),\n  ];\n}\n\nfunction lastSnapshot(discovered: DiscoveredMigration[]): DiscoveredMigration | null {\n  let latest: DiscoveredMigration | null = null;\n  for (const migration of discovered) {\n    if (migration.isSnapshot) {\n      latest = migration;\n    }\n  }\n  return latest;\n}\n\nfunction normalizeApplied(applied: PlanOptions[\"applied\"]): AppliedMigrationsSource | null {\n  if (!applied) {\n    return null;\n  }\n  return Array.isArray(applied) ? appliedMigrationsFromList(applied) : applied;\n}\n","/**\n * PocketBase Format Converter\n * Converts PocketBase collection objects to our internal CollectionSchema format\n *\n * This module handles conversion between PocketBase's native collection format\n * (as found in migration files and snapshots) and our internal schema representation.\n */\n\nimport { dedentSql } from \"../schema/view\";\nimport type { CollectionSchema, FieldDefinition, SchemaSnapshot } from \"./types\";\nimport { getSupportedFieldOptionKeys } from \"./utils/type-mapper\";\n\nconst SNAPSHOT_VERSION = \"1.0.0\";\n\n/**\n * Resolves a collection ID to a collection name\n * Uses known constants and parses migration expressions to resolve IDs\n *\n * @param collectionId - The collection ID to resolve\n * @returns The collection name, or the original ID if it can't be resolved\n */\nexport function resolveCollectionIdToName(collectionId: string): string {\n  // Special case: _pb_users_auth_ is the constant for users collection\n  if (collectionId === \"_pb_users_auth_\") {\n    return \"users\";\n  }\n\n  // Try to extract collection name from expressions like app.findCollectionByNameOrId(\"Name\").id\n  const nameMatch = collectionId.match(/app\\.findCollectionByNameOrId\\s*\\(\\s*[\"']([^\"']+)[\"']\\s*\\)/);\n  if (nameMatch) {\n    return nameMatch[1];\n  }\n\n  // If we can't resolve it, return the original ID\n  // This will cause a comparison issue, but it's better than failing\n  return collectionId;\n}\n\n/**\n * Extracts field options from a PocketBase field object\n * Options can be placed directly on the field or in a nested options object\n * Direct properties take precedence over nested options\n *\n * @param pbField - PocketBase field object\n * @returns Merged options object\n */\nfunction extractFieldOptions(pbField: any): Record<string, any> {\n  const options: Record<string, any> = {};\n\n  // Start with nested options if present\n  if (pbField.options && typeof pbField.options === \"object\") {\n    Object.assign(options, pbField.options);\n  }\n\n  // Extract field options from direct properties\n  // These take precedence over nested options\n  //\n  // The key list is the generator's own whitelist: anything the generator can\n  // write has to be readable here, or replay loses it and every `db:generate`\n  // re-emits the same modification\n  const directOptionKeys = getSupportedFieldOptionKeys(pbField.type);\n\n  for (const key of directOptionKeys) {\n    if (pbField[key] !== undefined) {\n      options[key] = pbField[key];\n    }\n  }\n\n  return options;\n}\n\n/**\n * Converts a PocketBase field object to FieldDefinition format\n *\n * @param pbField - PocketBase field object\n * @returns FieldDefinition object\n */\nexport function convertPocketBaseField(pbField: any): FieldDefinition {\n  const field: any = {\n    name: pbField.name,\n    id: pbField.id,\n    type: pbField.type,\n    required: pbField.required || false,\n  };\n\n  // Extract options from both direct properties and nested options object\n  field.options = extractFieldOptions(pbField);\n\n  // Convert onlyInt to noDecimal for number fields (PocketBase uses onlyInt, but our schema uses noDecimal)\n  if (pbField.type === \"number\" && field.options.onlyInt !== undefined) {\n    field.options.noDecimal = field.options.onlyInt;\n    delete field.options.onlyInt;\n  }\n\n  // Handle relation fields\n  if (pbField.type === \"relation\") {\n    // Support both formats: collectionId directly on field or in options\n    const collectionId = pbField.collectionId || pbField.options?.collectionId || \"\";\n    // Resolve collectionId to collection name\n    // collectionId is a system field (like _pb_users_auth_), not the collection name\n    // We need to resolve it to the actual collection name for comparison\n    const collectionName = resolveCollectionIdToName(collectionId || \"\");\n    field.relation = {\n      collection: collectionName,\n      cascadeDelete: pbField.cascadeDelete ?? pbField.options?.cascadeDelete ?? false,\n      maxSelect: pbField.maxSelect ?? pbField.options?.maxSelect,\n      minSelect: pbField.minSelect ?? pbField.options?.minSelect,\n      displayFields: pbField.displayFields ?? pbField.options?.displayFields ?? null,\n    };\n\n    // Remove relation-specific properties from options\n    // These belong in the relation object, not options\n    delete field.options.collectionId;\n    delete field.options.maxSelect;\n    delete field.options.minSelect;\n    delete field.options.cascadeDelete;\n    delete field.options.displayFields;\n  }\n\n  // Clean up empty options object, but preserve values for select fields\n  // If options only contains values for a select field, keep it\n  const hasOnlyValues = Object.keys(field.options).length === 1 && field.options.values !== undefined;\n  if (Object.keys(field.options).length === 0) {\n    delete field.options;\n  } else if (pbField.type === \"select\" && hasOnlyValues) {\n    // Keep options object if it only contains values for a select field\n    // This ensures values are preserved for comparison\n  }\n\n  return field as FieldDefinition;\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 */\nexport function convertPocketBaseCollection(pbCollection: any): CollectionSchema {\n  const fields: any[] = [];\n  const isView = pbCollection.type === \"view\";\n\n  // System field names that should always be excluded\n  const systemFieldNames = [\"id\", \"created\", \"updated\", \"collectionId\", \"collectionName\", \"expand\"];\n\n  // View collections have no stored fields - PocketBase derives them from the\n  // view query, so anything present here is generated output, not schema\n  // Convert PocketBase fields to our FieldDefinition format\n  if (!isView && 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        // For auth collections, we want to keep the system fields (email, password, etc.)\n        // These are marked as system: true in PocketBase, but we need them in our schema\n        // to match the CLI behavior which includes them in the fields array\n        const isAuthSystemField =\n          pbCollection.type === \"auth\" &&\n          [\"email\", \"emailVisibility\", \"verified\", \"password\", \"tokenKey\"].includes(pbField.name);\n\n        if (!isAuthSystemField) {\n          continue;\n        }\n      }\n\n      const field = convertPocketBaseField(pbField);\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  // Preserve collection ID if present (needed for relation resolution)\n  if (pbCollection.id) {\n    schema.id = pbCollection.id;\n  }\n\n  // Preserve the SQL query backing a view collection\n  // Dedented so a query indented to fit the migration file compares equal to\n  // the one declared in the schema\n  if (typeof pbCollection.viewQuery === \"string\") {\n    schema.viewQuery = dedentSql(pbCollection.viewQuery);\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  // Check if any rule properties exist on the collection object\n  const hasAnyRule =\n    pbCollection.listRule !== undefined ||\n    pbCollection.viewRule !== undefined ||\n    pbCollection.createRule !== undefined ||\n    pbCollection.updateRule !== undefined ||\n    pbCollection.deleteRule !== undefined ||\n    pbCollection.manageRule !== undefined;\n\n  if (hasAnyRule) {\n    const rules: any = {};\n    // Include rules even if they're null (null is a valid value)\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    schema.rules = rules;\n    // Also set permissions to match rules (they're the same thing)\n    schema.permissions = { ...rules };\n  }\n\n  return schema;\n}\n\n/**\n * Converts an array of raw PocketBase-shaped collection objects (as found\n * in snapshot arrays or produced by the execution engine) to a SchemaSnapshot\n *\n * @param rawCollections - Raw PocketBase collection objects\n * @returns SchemaSnapshot with collections map\n */\nexport function rawCollectionsToSnapshot(rawCollections: any[]): SchemaSnapshot {\n  const collections = new Map<string, CollectionSchema>();\n\n  for (const pbCollection of rawCollections) {\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}\n","/**\n * CollectionStore — the in-memory database state migrations execute against\n *\n * Keyed by collection id (migrations reference collections by id, name, or\n * the `_pb_users_auth_` alias; renames must not orphan entries). Cloning\n * serializes to plain objects and rebuilds, giving transaction semantics:\n * the runner clones, applies a migration to the clone, and commits with\n * replaceWith() only on success.\n */\n\nimport { rawCollectionsToSnapshot } from \"../pocketbase-converter\";\nimport type { SchemaSnapshot } from \"../types\";\nimport { Collection } from \"./collection\";\nimport { RecordStore } from \"./records\";\nimport type { RawCollection } from \"./types\";\n\n/** PocketBase's fixed id for the default users auth collection */\nconst USERS_AUTH_ID = \"_pb_users_auth_\";\n\nexport class CollectionStore {\n  private byId = new Map<string, Collection>();\n\n  /**\n   * Rows, when record simulation is enabled. Always present so clone/commit\n   * carry data through the same transaction as the schema; empty and\n   * effectively free when only schema is being replayed.\n   */\n  readonly records = new RecordStore();\n\n  list(): Collection[] {\n    return [...this.byId.values()];\n  }\n\n  getById(id: string): Collection | undefined {\n    return this.byId.get(id);\n  }\n\n  getByNameOrId(nameOrId: string): Collection | undefined {\n    const byId = this.byId.get(nameOrId);\n    if (byId) {\n      return byId;\n    }\n    for (const collection of this.byId.values()) {\n      if (collection.name === nameOrId) {\n        return collection;\n      }\n    }\n    // The users auth collection is addressable by its fixed system id even\n    // when a snapshot stored it under a different id, and vice versa\n    if (nameOrId === USERS_AUTH_ID) {\n      return this.getByNameOrId(\"users\");\n    }\n    return undefined;\n  }\n\n  upsert(collection: Collection): void {\n    this.byId.set(collection.id, collection);\n  }\n\n  removeById(id: string): boolean {\n    // Dropping a collection drops its table with it\n    this.records.dropCollection(id);\n    return this.byId.delete(id);\n  }\n\n  /** Deep, independent copy (rebuilds Collection/FieldsList instances) */\n  clone(): CollectionStore {\n    const copy = new CollectionStore();\n    for (const collection of this.byId.values()) {\n      copy.upsert(new Collection(structuredClone(collection.serialize())));\n    }\n    // Rows are rebound to the copied collections, so a record's collection()\n    // sees the schema of the transaction it is running in\n    copy.records.replaceWith(this.records.clone((id) => copy.getById(id)));\n    return copy;\n  }\n\n  /** Commit: adopt another store's state */\n  replaceWith(other: CollectionStore): void {\n    this.byId = new Map(other.byId);\n    this.records.replaceWith(other.records);\n  }\n\n  serialize(): RawCollection[] {\n    return this.list().map((collection) => collection.serialize());\n  }\n\n  /** Convert to the internal schema model used by diff/compare */\n  toSnapshot(): SchemaSnapshot {\n    return rawCollectionsToSnapshot(this.serialize());\n  }\n}\n","/**\n * Replayer — folds an ordered list of migration files into a final state\n *\n * Mirrors what PocketBase does on `migrate up`: execute each unapplied file\n * in timestamp order. State reconstruction starts from an empty store; a\n * native snapshot migration (app.importCollections) is just the first file.\n *\n * Which files that is comes from `planMigrationReplay`: by default the newest\n * snapshot plus everything after it, or — when an applied-migrations list is\n * supplied — only the files PocketBase has actually run, starting from the\n * newest applied snapshot.\n */\n\nimport { executeMigrationFile } from \"./runner\";\nimport { planMigrationReplay, type MigrationPlan, type PlanOptions } from \"./migration-plan\";\nimport { CollectionStore } from \"./store\";\nimport type { EngineOptions, EngineWarning, ReplayResult } from \"./types\";\n\nexport function replayMigrations(\n  files: string[],\n  options: EngineOptions & { initialStore?: CollectionStore; plan?: MigrationPlan } = {}\n): ReplayResult {\n  const { initialStore, plan, ...engineOptions } = options;\n  const store = initialStore ?? new CollectionStore();\n  const warnings: EngineWarning[] = [];\n  const filesExecuted: string[] = [];\n\n  for (const file of files) {\n    const result = executeMigrationFile(file, store, engineOptions);\n    warnings.push(...result.warnings);\n    filesExecuted.push(file);\n  }\n\n  return {\n    snapshot: store.toSnapshot(),\n    store,\n    warnings,\n    filesExecuted,\n    plan: plan ?? null,\n  };\n}\n\n/**\n * Replays a pb_migrations directory: the snapshot the state starts from,\n * then every migration after it, in timestamp order.\n *\n * Pass `applied` (from `readAppliedMigrations`) to replay only what PocketBase\n * has actually run — otherwise every file on disk is assumed applied.\n *\n * Returns null when there is nothing to replay (an empty database).\n */\nexport function replayMigrationsDirectory(\n  migrationsPath: string,\n  options: EngineOptions & PlanOptions = {}\n): ReplayResult | null {\n  const { applied, ...engineOptions } = options;\n  const plan = planMigrationReplay(migrationsPath, { applied });\n\n  if (plan.filesToReplay.length === 0) {\n    return null;\n  }\n\n  return replayMigrations(plan.filesToReplay, { ...engineOptions, plan });\n}\n","/**\n * Snapshot loading\n *\n * The \"current database state\" is reconstructed by executing the generated\n * migration files in a simulated PocketBase JSVM (see migration/engine/).\n * There is no snapshot JSON file.\n */\n\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport type { AppliedMigrationsSource } from \"./engine/applied-migrations\";\nimport { replayMigrations, replayMigrationsDirectory } from \"./engine/replayer\";\nimport type { EngineOptions } from \"./engine/types\";\nimport { MigrationExecutionError, SnapshotError } from \"./errors\";\nimport type { SchemaSnapshot } from \"./types\";\n\n/**\n * Configuration for snapshot operations\n */\nexport interface SnapshotConfig {\n  /**\n   * Path to the migrations directory to replay\n   */\n  migrationsPath?: string;\n\n  /**\n   * Options forwarded to the execution engine, which reconstructs state by\n   * executing migration files in a simulated PocketBase JSVM.\n   */\n  engineOptions?: EngineOptions;\n\n  /**\n   * Migrations PocketBase has actually applied, read from its `_migrations`\n   * table (see `readAppliedMigrations`). When supplied, replay starts from\n   * the newest applied snapshot and stops at the applied set, so a migration\n   * written but not yet run does not leak into the reconstructed state.\n   */\n  appliedMigrations?: AppliedMigrationsSource | string[] | null;\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 * Reconstructs the current database state: executes the snapshot migration and\n * every migration after it in a simulated PocketBase JSVM.\n *\n * A migration that cannot be executed fails hard — continuing past it would\n * silently reconstruct the wrong state and cause the generator to emit\n * incorrect diffs.\n *\n * @param config - Snapshot configuration (must include migrationsPath)\n * @returns SchemaSnapshot representing the current state, or null when there is\n *   nothing to replay (an empty database)\n */\nexport function loadSnapshotWithMigrations(config: SnapshotConfig = {}): SchemaSnapshot | null {\n  const migrationsPath = config.migrationsPath;\n\n  if (!migrationsPath) {\n    return null;\n  }\n\n  try {\n    // File path instead of a directory (backward compatibility with tests):\n    // execute just that one file\n    if (fs.existsSync(migrationsPath) && fs.statSync(migrationsPath).isFile()) {\n      return replayMigrations([migrationsPath], config.engineOptions).snapshot;\n    }\n\n    const result = replayMigrationsDirectory(migrationsPath, {\n      ...config.engineOptions,\n      applied: config.appliedMigrations,\n    });\n    return result ? result.snapshot : null;\n  } catch (error) {\n    if (error instanceof MigrationExecutionError) {\n      throw new SnapshotError(\n        `Failed to execute migration ${error.filePath ?? \"<unknown>\"}: ${error.message}`,\n        error.filePath,\n        \"parse\",\n        error\n      );\n    }\n    throw error;\n  }\n}\n","/**\n * Configuration options for the diff engine\n */\nexport interface DiffEngineConfig {\n  /**\n   * Custom system collections to exclude from diff\n   * These collections will not be created or deleted\n   */\n  systemCollections?: string[];\n\n  /**\n   * Custom system fields to exclude from user collection diffs\n   * These fields will not be included in fieldsToAdd for the users collection\n   */\n  usersSystemFields?: string[];\n}\n\n/**\n * Default configuration values\n */\nexport const DEFAULT_CONFIG: Required<DiffEngineConfig> = {\n  systemCollections: [\"_mfas\", \"_otps\", \"_externalAuths\", \"_authOrigins\", \"_superusers\"],\n  usersSystemFields: [\"id\", \"password\", \"tokenKey\", \"email\", \"emailVisibility\", \"verified\", \"created\", \"updated\"],\n};\n\n/**\n * Merges user config with defaults\n */\nexport function mergeConfig(config?: DiffEngineConfig): Required<DiffEngineConfig> {\n  return {\n    ...DEFAULT_CONFIG,\n    ...config,\n  };\n}\n","import { getFieldOptionUnsetValue } from \"../utils/type-mapper\";\nimport { mergeConfig, type DiffEngineConfig } from \"./config\";\n\n/**\n * Checks if a collection is a PocketBase system collection\n * System collections are internal to PocketBase and should not be created or deleted\n *\n * @param collectionName - Name of the collection to check\n * @param config - Optional configuration with custom system collections\n * @returns True if the collection is a system collection\n */\nexport function isSystemCollection(collectionName: string, config?: DiffEngineConfig): boolean {\n  const mergedConfig = mergeConfig(config);\n  return mergedConfig.systemCollections.includes(collectionName);\n}\n\n/**\n * Returns the list of system field names for the users collection\n * These fields are automatically provided by PocketBase for auth collections\n * and should not be included when generating migrations for users collection extensions\n *\n * @param config - Optional configuration with custom system fields\n * @returns Set of system field names\n */\nexport function getUsersSystemFields(config?: DiffEngineConfig): Set<string> {\n  const mergedConfig = mergeConfig(config);\n  return new Set(mergedConfig.usersSystemFields);\n}\n\n/**\n * Compares two values for equality, handling deep object comparison\n *\n * @param a - First value\n * @param b - Second value\n * @returns True if values are equal\n */\nexport function areValuesEqual(a: any, b: any): boolean {\n  // Handle null/undefined\n  if (a === b) return true;\n  if (a == null || b == null) return false;\n\n  // Handle arrays\n  if (Array.isArray(a) && Array.isArray(b)) {\n    if (a.length !== b.length) return false;\n    return a.every((val, idx) => areValuesEqual(val, b[idx]));\n  }\n\n  // Handle objects\n  if (typeof a === \"object\" && typeof b === \"object\") {\n    const keysA = Object.keys(a);\n    const keysB = Object.keys(b);\n\n    if (keysA.length !== keysB.length) return false;\n\n    return keysA.every((key) => areValuesEqual(a[key], b[key]));\n  }\n\n  // Primitive comparison\n  return a === b;\n}\n\n/**\n * Normalizes a field option value to account for PocketBase defaults\n * Returns the normalized value, treating default values as equivalent to undefined\n *\n * @param key - Option key name\n * @param value - Option value\n * @param fieldType - Field type\n * @returns Normalized value (undefined if it's a default value)\n */\nexport function normalizeOptionValue(key: string, value: any, fieldType: string): any {\n  // PocketBase writes every option a field type has, at its zero value, into\n  // the migrations it authors itself. A schema that simply does not set the\n  // option means the same thing, so the zero value has to compare equal to a\n  // missing one — otherwise replaying a PocketBase-authored migration reports\n  // a modification the generator can never settle.\n  //\n  // `null` arrives from the same place: it is what PocketBase writes for its\n  // pointer-typed options (a number field's `min`/`max`), and what a migration\n  // clearing an option used to assign.\n  if (value === null || value === undefined) {\n    return undefined;\n  }\n\n  const unsetValue = getFieldOptionUnsetValue(fieldType, key);\n  if (unsetValue !== undefined && areValuesEqual(value, unsetValue)) {\n    return undefined;\n  }\n\n  // A select field's `values` is stored as an ordered list, but the order\n  // carries no data semantics — it only fixes the option order in the admin\n  // UI, and PocketBase appends options added there to the end. A schema\n  // listing the same options in a different order describes the same field,\n  // so compare them as a multiset (sorted copy, duplicates still count).\n  // A genuine add or remove is still reported, and the generator writes the\n  // whole array back in the schema's order, so the order re-syncs then.\n  if (key === \"values\" && fieldType === \"select\" && Array.isArray(value)) {\n    return [...value].sort();\n  }\n\n  // The remaining defaults are not zero values, so they need naming:\n  // maxSelect: 1 is what a single-value select or file field carries\n  if (key === \"maxSelect\" && value === 1 && (fieldType === \"select\" || fieldType === \"file\")) {\n    return undefined; // Treat as undefined to match missing default\n  }\n\n  // min: 1 can be a default for some PocketBase versions/number fields\n  if (key === \"min\" && value === 1 && fieldType === \"number\") {\n    return undefined;\n  }\n\n  // Autodate defaults\n  if (fieldType === \"autodate\") {\n    if (key === \"onCreate\" && value === true) {\n      return undefined;\n    }\n    if (key === \"onUpdate\" && value === false) {\n      return undefined;\n    }\n  }\n\n  return value;\n}\n","import type { FieldChange, FieldDefinition } from \"../types\";\nimport { areValuesEqual, normalizeOptionValue } from \"./utils\";\n\n/**\n * Identifies new fields in current collection that don't exist in previous\n *\n * @param currentFields - Current collection fields\n * @param previousFields - Previous collection fields\n * @returns Array of new fields\n */\nexport function findNewFields(currentFields: FieldDefinition[], previousFields: FieldDefinition[]): FieldDefinition[] {\n  const newFields: FieldDefinition[] = [];\n  const previousFieldNames = new Set(previousFields.map((f) => f.name));\n\n  for (const currentField of currentFields) {\n    if (!previousFieldNames.has(currentField.name)) {\n      newFields.push(currentField);\n    }\n  }\n\n  return newFields;\n}\n\n/**\n * Identifies fields removed from current collection (exist in previous but not in current)\n *\n * @param currentFields - Current collection fields\n * @param previousFields - Previous collection fields\n * @returns Array of removed fields\n */\nexport function findRemovedFields(\n  currentFields: FieldDefinition[],\n  previousFields: FieldDefinition[]\n): FieldDefinition[] {\n  const removedFields: FieldDefinition[] = [];\n  const currentFieldNames = new Set(currentFields.map((f) => f.name));\n\n  for (const previousField of previousFields) {\n    if (!currentFieldNames.has(previousField.name)) {\n      removedFields.push(previousField);\n    }\n  }\n\n  return removedFields;\n}\n\n/**\n * Matches fields by name between current and previous collections\n * Returns pairs of [current, previous] for fields that exist in both\n *\n * @param currentFields - Current collection fields\n * @param previousFields - Previous collection fields\n * @returns Array of matched field pairs\n */\nexport function matchFieldsByName(\n  currentFields: FieldDefinition[],\n  previousFields: FieldDefinition[]\n): Array<[FieldDefinition, FieldDefinition]> {\n  const matches: Array<[FieldDefinition, FieldDefinition]> = [];\n\n  // Create a map of previous fields by name for efficient lookup\n  const previousFieldMap = new Map<string, FieldDefinition>();\n  for (const previousField of previousFields) {\n    previousFieldMap.set(previousField.name, previousField);\n  }\n\n  // Find matching fields\n  for (const currentField of currentFields) {\n    const previousField = previousFieldMap.get(currentField.name);\n\n    if (previousField) {\n      matches.push([currentField, previousField]);\n    }\n  }\n\n  return matches;\n}\n\n/**\n * Compares field types between current and previous\n *\n * @param currentField - Current field definition\n * @param previousField - Previous field definition\n * @returns FieldChange if types differ, null otherwise\n */\nexport function compareFieldTypes(currentField: FieldDefinition, previousField: FieldDefinition): FieldChange | null {\n  if (currentField.type !== previousField.type) {\n    return {\n      property: \"type\",\n      oldValue: previousField.type,\n      newValue: currentField.type,\n    };\n  }\n\n  return null;\n}\n\n/**\n * Compares field constraints (required, unique) between current and previous\n *\n * @param currentField - Current field definition\n * @param previousField - Previous field definition\n * @returns Array of FieldChange for constraint differences\n */\nexport function compareFieldConstraints(currentField: FieldDefinition, previousField: FieldDefinition): FieldChange[] {\n  const changes: FieldChange[] = [];\n\n  // Compare required constraint\n  if (currentField.required !== previousField.required) {\n    changes.push({\n      property: \"required\",\n      oldValue: previousField.required,\n      newValue: currentField.required,\n    });\n  }\n\n  // Compare unique constraint\n  if (currentField.unique !== previousField.unique) {\n    changes.push({\n      property: \"unique\",\n      oldValue: previousField.unique,\n      newValue: currentField.unique,\n    });\n  }\n\n  return changes;\n}\n\n/**\n * Compares field options (min, max, pattern, etc.) between current and previous\n *\n * @param currentField - Current field definition\n * @param previousField - Previous field definition\n * @returns Array of FieldChange for option differences\n */\nexport function compareFieldOptions(currentField: FieldDefinition, previousField: FieldDefinition): FieldChange[] {\n  const changes: FieldChange[] = [];\n\n  const currentOptions = currentField.options || {};\n  const previousOptions = previousField.options || {};\n\n  // Get all unique option keys\n  const allKeys = new Set([...Object.keys(currentOptions), ...Object.keys(previousOptions)]);\n\n  // Compare each option\n  // Use currentField.type for normalization since types should match at this point\n  // (type changes are handled separately in compareFieldTypes)\n  const fieldType = currentField.type;\n\n  for (const key of allKeys) {\n    const currentValue = currentOptions[key];\n    const previousValue = previousOptions[key];\n\n    // Normalize values to account for default values\n    // This ensures that maxSelect: 1 (default) is treated the same as undefined (missing default)\n    const normalizedCurrent = normalizeOptionValue(key, currentValue, fieldType);\n    const normalizedPrevious = normalizeOptionValue(key, previousValue, fieldType);\n\n    // Handle undefined values - if both are undefined (or normalized to undefined), that's not a change\n    if (normalizedCurrent === undefined && normalizedPrevious === undefined) {\n      continue;\n    }\n\n    if (!areValuesEqual(normalizedCurrent, normalizedPrevious)) {\n      changes.push({\n        property: `options.${key}`,\n        oldValue: previousValue,\n        newValue: currentValue,\n      });\n    }\n  }\n\n  return changes;\n}\n\n/**\n * Compares relation configurations between current and previous\n *\n * @param currentField - Current field definition\n * @param previousField - Previous field definition\n * @returns Array of FieldChange for relation differences\n */\nexport function compareRelationConfigurations(\n  currentField: FieldDefinition,\n  previousField: FieldDefinition,\n  collectionIdToName?: Map<string, string>\n): FieldChange[] {\n  const changes: FieldChange[] = [];\n\n  const currentRelation = currentField.relation;\n  const previousRelation = previousField.relation;\n\n  // If one has relation and other doesn't, that's not a config change (handled elsewhere, likely type or structure)\n  // But here we assume types match (both relation) or structure implies relation\n  if (!currentRelation && !previousRelation) {\n    return changes;\n  }\n\n  if (!currentRelation || !previousRelation) {\n    // This shouldn't happen if types match and both are 'relation', but handle gracefully\n    return changes;\n  }\n\n  // Compare relation properties\n  // Note: collectionId should already be resolved to collection name during parsing\n  // This normalization is just a safety net for edge cases\n  const normalizeCollection = (collection: string): string => {\n    if (!collection) return collection;\n\n    // Resolve ID to name if possible\n    if (collectionIdToName && collectionIdToName.has(collection)) {\n      return collectionIdToName.get(collection)!;\n    }\n\n    // Handle expressions that might not have been parsed correctly\n    const nameMatch = collection.match(/app\\.findCollectionByNameOrId\\s*\\(\\s*[\"']([^\"']+)[\"']\\s*\\)/);\n    if (nameMatch) {\n      return nameMatch[1];\n    }\n    return collection;\n  };\n\n  const normalizedCurrent = normalizeCollection(currentRelation.collection);\n  // We resolve the ID from the previous relation (snapshot) to its name if available\n  const normalizedPrevious = normalizeCollection(previousRelation.collection);\n\n  // Only report a change if the normalized values differ\n  // Use case-insensitive comparison for collection names\n  if (normalizedCurrent.toLowerCase() !== normalizedPrevious.toLowerCase()) {\n    changes.push({\n      property: \"relation.collection\",\n      oldValue: previousRelation.collection,\n      newValue: currentRelation.collection,\n    });\n  }\n\n  if (currentRelation.cascadeDelete !== previousRelation.cascadeDelete) {\n    changes.push({\n      property: \"relation.cascadeDelete\",\n      oldValue: previousRelation.cascadeDelete,\n      newValue: currentRelation.cascadeDelete,\n    });\n  }\n\n  // Normalize maxSelect: 1 to undefined/null as it's often the default or treated as such\n  const normalizeMax = (val: number | null | undefined) => (val === 1 ? null : val);\n  const currentMax = normalizeMax(currentRelation.maxSelect);\n  const previousMax = normalizeMax(previousRelation.maxSelect);\n\n  // Use loose equality to handle null vs undefined\n  if (currentMax != previousMax) {\n    changes.push({\n      property: \"relation.maxSelect\",\n      oldValue: previousRelation.maxSelect,\n      newValue: currentRelation.maxSelect,\n    });\n  }\n\n  // Normalize minSelect: 0 to undefined/null\n  const normalizeMin = (val: number | null | undefined) => (val === 0 ? null : val);\n  const currentMin = normalizeMin(currentRelation.minSelect);\n  const previousMin = normalizeMin(previousRelation.minSelect);\n\n  if (currentMin != previousMin) {\n    changes.push({\n      property: \"relation.minSelect\",\n      oldValue: previousRelation.minSelect,\n      newValue: currentRelation.minSelect,\n    });\n  }\n\n  return changes;\n}\n\n/**\n * Detects all changes between two field definitions\n * Combines type, constraint, option, and relation changes\n *\n * @param currentField - Current field definition\n * @param previousField - Previous field definition\n * @returns Array of all detected changes\n */\nexport function detectFieldChanges(\n  currentField: FieldDefinition,\n  previousField: FieldDefinition,\n  collectionIdToName?: Map<string, string>\n): FieldChange[] {\n  const changes: FieldChange[] = [];\n\n  // Compare types\n  const typeChange = compareFieldTypes(currentField, previousField);\n  if (typeChange) {\n    changes.push(typeChange);\n  }\n\n  // Compare constraints\n  changes.push(...compareFieldConstraints(currentField, previousField));\n\n  // Compare options\n  changes.push(...compareFieldOptions(currentField, previousField));\n\n  // Compare relation configurations (if applicable)\n  if (currentField.type === \"relation\" && previousField.type === \"relation\") {\n    changes.push(...compareRelationConfigurations(currentField, previousField, collectionIdToName));\n  }\n\n  return changes;\n}\n","/**\n * Compares indexes between current and previous collections\n *\n * @param currentIndexes - Current collection indexes\n * @param previousIndexes - Previous collection indexes\n * @returns Object with indexes to add and remove\n */\nexport function compareIndexes(\n  currentIndexes: string[] = [],\n  previousIndexes: string[] = []\n): { indexesToAdd: string[]; indexesToRemove: string[] } {\n  const currentSet = new Set(currentIndexes);\n  const previousSet = new Set(previousIndexes);\n\n  const indexesToAdd = currentIndexes.filter((idx) => !previousSet.has(idx));\n  const indexesToRemove = previousIndexes.filter((idx) => !currentSet.has(idx));\n\n  return { indexesToAdd, indexesToRemove };\n}\n","import type { APIRuleType } from \"../../utils/permissions\";\nimport type { CollectionSchema, PermissionChange, RuleUpdate } from \"../types\";\n\n/**\n * Compares API rules between current and previous collections\n *\n * @param currentRules - Current collection rules\n * @param previousRules - Previous collection rules\n * @returns Array of rule updates\n */\nexport function compareRules(\n  currentRules: CollectionSchema[\"rules\"],\n  previousRules: CollectionSchema[\"rules\"],\n  currentPermissions?: CollectionSchema[\"permissions\"],\n  previousPermissions?: CollectionSchema[\"permissions\"]\n): RuleUpdate[] {\n  const updates: RuleUpdate[] = [];\n\n  const ruleTypes: Array<keyof NonNullable<CollectionSchema[\"rules\"]>> = [\n    \"listRule\",\n    \"viewRule\",\n    \"createRule\",\n    \"updateRule\",\n    \"deleteRule\",\n    \"manageRule\",\n  ];\n\n  for (const ruleType of ruleTypes) {\n    // Use rules if available, otherwise fall back to permissions (they're the same thing)\n    const currentValue = currentRules?.[ruleType] ?? currentPermissions?.[ruleType] ?? null;\n    const previousValue = previousRules?.[ruleType] ?? previousPermissions?.[ruleType] ?? null;\n\n    if (currentValue !== previousValue) {\n      updates.push({\n        ruleType: ruleType as RuleUpdate[\"ruleType\"],\n        oldValue: previousValue,\n        newValue: currentValue,\n      });\n    }\n  }\n\n  return updates;\n}\n\n/**\n * Compares permissions between current and previous collections\n * Detects changes in permission rules defined in schema\n *\n * @param currentPermissions - Current collection permissions\n * @param previousPermissions - Previous collection permissions\n * @returns Array of permission changes\n */\nexport function comparePermissions(\n  currentPermissions: CollectionSchema[\"permissions\"],\n  previousPermissions: CollectionSchema[\"permissions\"]\n): PermissionChange[] {\n  const changes: PermissionChange[] = [];\n\n  const ruleTypes: APIRuleType[] = [\"listRule\", \"viewRule\", \"createRule\", \"updateRule\", \"deleteRule\", \"manageRule\"];\n\n  for (const ruleType of ruleTypes) {\n    const currentValue = currentPermissions?.[ruleType] ?? null;\n    const previousValue = previousPermissions?.[ruleType] ?? null;\n\n    // Compare permission values\n    if (currentValue !== previousValue) {\n      changes.push({\n        ruleType,\n        oldValue: previousValue,\n        newValue: currentValue,\n      });\n    }\n  }\n\n  return changes;\n}\n","import type {\n  CollectionModification,\n  CollectionSchema,\n  FieldDefinition,\n  FieldModification,\n  SchemaDefinition,\n  SchemaSnapshot,\n  ViewQueryUpdate,\n} from \"../types\";\nimport { type DiffEngineConfig } from \"./config\";\nimport { detectFieldChanges, findNewFields, findRemovedFields, matchFieldsByName } from \"./fields\";\nimport { compareIndexes } from \"./indexes\";\nimport { comparePermissions, compareRules } from \"./rules\";\nimport { getUsersSystemFields, isSystemCollection } from \"./utils\";\n\n/**\n * Filters system collections from a schema definition\n * Returns a new SchemaDefinition with only custom (non-system) collections\n *\n * @param schema - Schema definition to filter\n * @param config - Optional configuration\n * @returns Filtered SchemaDefinition without system collections\n */\nexport function filterSystemCollections(schema: SchemaDefinition, config?: DiffEngineConfig): SchemaDefinition {\n  const filteredCollections = new Map<string, CollectionSchema>();\n\n  for (const [collectionName, collectionSchema] of schema.collections) {\n    if (!isSystemCollection(collectionName, config)) {\n      filteredCollections.set(collectionName, collectionSchema);\n    }\n  }\n\n  return {\n    collections: filteredCollections,\n  };\n}\n\n/**\n * Identifies new collections in schema that don't exist in snapshot\n *\n * @param currentSchema - Current schema definition\n * @param previousSnapshot - Previous schema snapshot\n * @returns Array of new collections\n */\nexport function findNewCollections(\n  currentSchema: SchemaDefinition,\n  previousSnapshot: SchemaSnapshot | null\n): CollectionSchema[] {\n  const newCollections: CollectionSchema[] = [];\n\n  // If no previous snapshot, all collections are new\n  if (!previousSnapshot) {\n    return Array.from(currentSchema.collections.values());\n  }\n\n  // Find collections in current schema that don't exist in snapshot\n  for (const [collectionName, collectionSchema] of currentSchema.collections) {\n    if (!previousSnapshot.collections.has(collectionName)) {\n      newCollections.push(collectionSchema);\n    }\n  }\n\n  return newCollections;\n}\n\n/**\n * Identifies collections removed from schema (exist in snapshot but not in current schema)\n *\n * @param currentSchema - Current schema definition\n * @param previousSnapshot - Previous schema snapshot\n * @returns Array of removed collections\n */\nexport function findRemovedCollections(\n  currentSchema: SchemaDefinition,\n  previousSnapshot: SchemaSnapshot | null\n): CollectionSchema[] {\n  const removedCollections: CollectionSchema[] = [];\n\n  // If no previous snapshot, nothing can be removed\n  if (!previousSnapshot) {\n    return removedCollections;\n  }\n\n  // Find collections in snapshot that don't exist in current schema\n  for (const [collectionName, collectionSchema] of previousSnapshot.collections) {\n    if (!currentSchema.collections.has(collectionName)) {\n      removedCollections.push(collectionSchema);\n    }\n  }\n\n  return removedCollections;\n}\n\n/**\n * Matches collections by name between current schema and snapshot\n * Returns pairs of [current, previous] for collections that exist in both\n *\n * @param currentSchema - Current schema definition\n * @param previousSnapshot - Previous schema snapshot\n * @returns Array of matched collection pairs\n */\nexport function matchCollectionsByName(\n  currentSchema: SchemaDefinition,\n  previousSnapshot: SchemaSnapshot | null\n): Array<[CollectionSchema, CollectionSchema]> {\n  const matches: Array<[CollectionSchema, CollectionSchema]> = [];\n\n  // If no previous snapshot, no matches possible\n  if (!previousSnapshot) {\n    return matches;\n  }\n\n  // Create a case-insensitive lookup map for previous collections\n  const previousCollectionsLower = new Map<string, [string, CollectionSchema]>();\n  for (const [name, collection] of previousSnapshot.collections) {\n    previousCollectionsLower.set(name.toLowerCase(), [name, collection]);\n  }\n\n  // Find collections that exist in both current and previous (case-insensitive)\n  for (const [collectionName, currentCollection] of currentSchema.collections) {\n    const previousEntry = previousCollectionsLower.get(collectionName.toLowerCase());\n\n    if (previousEntry) {\n      const [, previousCollection] = previousEntry;\n      matches.push([currentCollection, previousCollection]);\n    }\n  }\n\n  return matches;\n}\n\n/**\n * Compares fields between current and previous collections\n * Identifies new, removed, and modified fields\n * For the users collection, filters out system fields from fieldsToAdd\n *\n * @param currentCollection - Current collection schema\n * @param previousCollection - Previous collection schema\n * @param config - Optional configuration\n * @returns Object with field changes\n */\nfunction compareCollectionFields(\n  currentCollection: CollectionSchema,\n  previousCollection: CollectionSchema,\n  config?: DiffEngineConfig,\n  collectionIdToName?: Map<string, string>\n): {\n  fieldsToAdd: FieldDefinition[];\n  fieldsToRemove: FieldDefinition[];\n  fieldsToModify: FieldModification[];\n} {\n  let fieldsToAdd = findNewFields(currentCollection.fields, previousCollection.fields);\n  let fieldsToRemove = findRemovedFields(currentCollection.fields, previousCollection.fields);\n  const fieldsToModify: FieldModification[] = [];\n\n  // For users collection, filter out system fields from fieldsToAdd\n  // System fields are automatically provided by PocketBase and should not be in migrations\n  if (currentCollection.name === \"users\") {\n    const systemFields = getUsersSystemFields(config);\n    fieldsToAdd = fieldsToAdd.filter((field) => !systemFields.has(field.name));\n  }\n\n  // Check for modified fields\n  const matchedFields = matchFieldsByName(currentCollection.fields, previousCollection.fields);\n\n  for (const [currentField, previousField] of matchedFields) {\n    const changes = detectFieldChanges(currentField, previousField, collectionIdToName);\n\n    if (changes.length > 0) {\n      fieldsToModify.push({\n        fieldName: currentField.name,\n        currentDefinition: previousField,\n        newDefinition: currentField,\n        changes,\n      });\n    }\n  }\n\n  // Detect Renames (Heuristic)\n  // If we have single removed and added fields of the same type, consider it a rename\n  const processedAddIndices = new Set<number>();\n  const processedRemoveIndices = new Set<number>();\n\n  // Helper to resolve collection name from ID/expression\n  const resolveCollectionName = (val: string): string => {\n    if (!val) return val;\n    if (collectionIdToName && collectionIdToName.has(val)) return collectionIdToName.get(val)!;\n    const match = val.match(/app\\.findCollectionByNameOrId\\s*\\(\\s*[\"']([^\"']+)[\"']\\s*\\)/);\n    return match ? match[1] : val;\n  };\n\n  // Group fields by type\n  const addedByType = new Map<string, number[]>();\n  fieldsToAdd.forEach((field, index) => {\n    const type = field.type;\n    if (!addedByType.has(type)) addedByType.set(type, []);\n    addedByType.get(type)!.push(index);\n  });\n\n  const removedByType = new Map<string, number[]>();\n  fieldsToRemove.forEach((field, index) => {\n    const type = field.type;\n    if (!removedByType.has(type)) removedByType.set(type, []);\n    removedByType.get(type)!.push(index);\n  });\n\n  // Check each type for potential renames\n  for (const [type, removedIndices] of removedByType) {\n    const addedIndices = addedByType.get(type);\n\n    // Heuristic: Only rename if exactly one field of this type was removed and one added\n    if (addedIndices && addedIndices.length === 1 && removedIndices.length === 1) {\n      const addedIndex = addedIndices[0];\n      const removedIndex = removedIndices[0];\n      const addedField = fieldsToAdd[addedIndex];\n      const removedField = fieldsToRemove[removedIndex];\n\n      // For relations, ensure target collection matches\n      let isMatch = true;\n      if (type === \"relation\") {\n        const addedTarget = resolveCollectionName(addedField.relation?.collection || \"\");\n        const removedTarget = resolveCollectionName(removedField.relation?.collection || \"\");\n        if (addedTarget.toLowerCase() !== removedTarget.toLowerCase()) {\n          isMatch = false;\n        }\n      }\n\n      if (isMatch) {\n        // It's a rename!\n        processedAddIndices.add(addedIndex);\n        processedRemoveIndices.add(removedIndex);\n\n        // Calculate changes (including name change)\n        const changes = detectFieldChanges(addedField, removedField, collectionIdToName);\n        changes.push({\n          property: \"name\",\n          oldValue: removedField.name,\n          newValue: addedField.name,\n        });\n\n        fieldsToModify.push({\n          fieldName: removedField.name, // Use OLD name so generator can find it\n          currentDefinition: removedField, // OLD definition\n          newDefinition: addedField, // NEW definition\n          changes,\n        });\n      }\n    }\n  }\n\n  // Filter out processed fields\n  fieldsToAdd = fieldsToAdd.filter((_, index) => !processedAddIndices.has(index));\n  fieldsToRemove = fieldsToRemove.filter((_, index) => !processedRemoveIndices.has(index));\n\n  return { fieldsToAdd, fieldsToRemove, fieldsToModify };\n}\n\n/**\n * Normalizes a SQL view query for comparison\n * Collapses whitespace so re-indenting or re-wrapping a query does not produce\n * a migration\n *\n * @param query - The SQL query\n * @returns Normalized query text\n */\nexport function normalizeSql(query: string | null | undefined): string {\n  if (!query) {\n    return \"\";\n  }\n\n  return query\n    .split(\"\\n\")\n    .map((line) => line.trim())\n    .join(\" \")\n    .replace(/\\s+/g, \" \")\n    .trim();\n}\n\n/**\n * Compares the SQL query of two view collections\n *\n * @param currentCollection - Current collection schema\n * @param previousCollection - Previous collection schema\n * @returns A ViewQueryUpdate when the query changed, undefined otherwise\n */\nfunction compareViewQuery(\n  currentCollection: CollectionSchema,\n  previousCollection: CollectionSchema\n): ViewQueryUpdate | undefined {\n  const newValue = currentCollection.viewQuery;\n\n  if (typeof newValue !== \"string\") {\n    return undefined;\n  }\n\n  if (normalizeSql(newValue) === normalizeSql(previousCollection.viewQuery)) {\n    return undefined;\n  }\n\n  return {\n    oldValue: previousCollection.viewQuery ?? null,\n    newValue,\n  };\n}\n\n/**\n * Builds a CollectionModification for a matched collection pair\n *\n * @param currentCollection - Current collection schema\n * @param previousCollection - Previous collection schema\n * @param config - Optional configuration\n * @returns CollectionModification object\n */\nexport function buildCollectionModification(\n  currentCollection: CollectionSchema,\n  previousCollection: CollectionSchema,\n  config?: DiffEngineConfig,\n  collectionIdToName?: Map<string, string>\n): CollectionModification {\n  // View collections are defined entirely by their SQL query: PocketBase\n  // derives the fields from it and views cannot have indexes, so only the\n  // query and the read rules are diffed\n  const isView = currentCollection.type === \"view\" || previousCollection.type === \"view\";\n\n  if (isView) {\n    return {\n      collection: currentCollection.name,\n      fieldsToAdd: [],\n      fieldsToRemove: [],\n      fieldsToModify: [],\n      indexesToAdd: [],\n      indexesToRemove: [],\n      rulesToUpdate: compareRules(\n        currentCollection.rules,\n        previousCollection.rules,\n        currentCollection.permissions,\n        previousCollection.permissions\n      ),\n      permissionsToUpdate: comparePermissions(currentCollection.permissions, previousCollection.permissions),\n      viewQueryUpdate: compareViewQuery(currentCollection, previousCollection),\n    };\n  }\n\n  // Compare fields\n  const { fieldsToAdd, fieldsToRemove, fieldsToModify } = compareCollectionFields(\n    currentCollection,\n    previousCollection,\n    config,\n    collectionIdToName\n  );\n\n  // Compare indexes\n  const { indexesToAdd, indexesToRemove } = compareIndexes(currentCollection.indexes, previousCollection.indexes);\n\n  // Compare rules (also check permissions as fallback since they're the same thing)\n  const rulesToUpdate = compareRules(\n    currentCollection.rules,\n    previousCollection.rules,\n    currentCollection.permissions,\n    previousCollection.permissions\n  );\n\n  // Compare permissions\n  const permissionsToUpdate = comparePermissions(currentCollection.permissions, previousCollection.permissions);\n\n  return {\n    collection: currentCollection.name,\n    fieldsToAdd,\n    fieldsToRemove,\n    fieldsToModify,\n    indexesToAdd,\n    indexesToRemove,\n    rulesToUpdate,\n    permissionsToUpdate,\n  };\n}\n","import type { SchemaDiff, FieldModification } from \"../types\";\n\nexport interface FilterOptions {\n  patterns?: string[];\n  skipDestructive?: boolean;\n}\n\nfunction matchesPattern(text: string, patterns: string[]): boolean {\n  if (!patterns || patterns.length === 0) return true;\n  return patterns.some(pattern => {\n    try {\n        const regex = new RegExp(pattern);\n        return regex.test(text);\n    } catch {\n        return text.includes(pattern);\n    }\n  });\n}\n\nfunction isDestructiveFieldModification(mod: FieldModification): boolean {\n    const typeChange = mod.changes.find(c => c.property === \"type\");\n    const requiredChange = mod.changes.find(c => c.property === \"required\" && c.newValue === true);\n    return !!(typeChange || requiredChange);\n}\n\nexport function filterDiff(diff: SchemaDiff, options: FilterOptions): SchemaDiff {\n  const { patterns = [], skipDestructive = false } = options;\n\n  // 1. Filter Collections to Create\n  const collectionsToCreate = diff.collectionsToCreate.filter(col => {\n    return matchesPattern(col.name, patterns);\n  });\n\n  // 2. Filter Collections to Delete\n  // View collections are kept even when skipping destructive changes: they\n  // store no data, so dropping one loses nothing\n  let collectionsToDelete = diff.collectionsToDelete;\n  if (skipDestructive) {\n    collectionsToDelete = collectionsToDelete.filter(col => col.type === \"view\");\n  }\n  collectionsToDelete = collectionsToDelete.filter(col => {\n    return matchesPattern(col.name, patterns);\n  });\n\n  // 3. Filter Collections to Modify\n  const collectionsToModify = diff.collectionsToModify.map(mod => {\n    // Check if collection name itself matches\n    const collectionMatches = matchesPattern(mod.collection, patterns);\n\n    // Filter fields to add\n    const fieldsToAdd = mod.fieldsToAdd.filter(field => {\n      return collectionMatches || matchesPattern(`${mod.collection}.${field.name}`, patterns);\n    });\n\n    // Filter fields to remove\n    let fieldsToRemove = mod.fieldsToRemove;\n    if (skipDestructive) {\n      fieldsToRemove = [];\n    } else {\n      fieldsToRemove = fieldsToRemove.filter(field => {\n         return collectionMatches || matchesPattern(`${mod.collection}.${field.name}`, patterns);\n      });\n    }\n\n    // Filter fields to modify\n    let fieldsToModify = mod.fieldsToModify;\n    if (skipDestructive) {\n        fieldsToModify = fieldsToModify.filter(f => !isDestructiveFieldModification(f));\n    }\n    fieldsToModify = fieldsToModify.filter(f => {\n        return collectionMatches || matchesPattern(`${mod.collection}.${f.fieldName}`, patterns);\n    });\n\n    // Filter collection-level changes (indexes, rules, permissions)\n    // Only include them if the collection name itself matches the pattern.\n    // If user targets specific fields (e.g. \"User.name\"), collectionMatches is false, so these are skipped.\n    const indexesToAdd = collectionMatches ? mod.indexesToAdd : [];\n    const indexesToRemove = collectionMatches ? mod.indexesToRemove : [];\n    const rulesToUpdate = collectionMatches ? mod.rulesToUpdate : [];\n    const permissionsToUpdate = collectionMatches ? mod.permissionsToUpdate : [];\n    const viewQueryUpdate = collectionMatches ? mod.viewQueryUpdate : undefined;\n\n    return {\n      ...mod,\n      fieldsToAdd,\n      fieldsToRemove,\n      fieldsToModify,\n      indexesToAdd,\n      indexesToRemove,\n      rulesToUpdate,\n      permissionsToUpdate,\n      viewQueryUpdate\n    };\n  }).filter(mod => {\n     // Keep modification object only if there is something left to modify\n     return mod.fieldsToAdd.length > 0 ||\n            mod.fieldsToRemove.length > 0 ||\n            mod.fieldsToModify.length > 0 ||\n            mod.indexesToAdd.length > 0 ||\n            mod.indexesToRemove.length > 0 ||\n            mod.rulesToUpdate.length > 0 ||\n            mod.permissionsToUpdate.length > 0 ||\n            mod.viewQueryUpdate !== undefined;\n  });\n\n  return {\n    ...diff,\n    collectionsToCreate,\n    collectionsToDelete,\n    collectionsToModify\n  };\n}\n","import type { SchemaDiff } from \"../types\";\nimport { type DiffEngineConfig } from \"./config\";\n\n/**\n * Categorizes changes by severity\n * Returns object with destructive and non-destructive changes\n *\n * @param diff - Schema diff to categorize\n * @param config - Optional configuration\n * @returns Object with categorized changes\n */\nexport function categorizeChangesBySeverity(\n  diff: SchemaDiff,\n  _config?: DiffEngineConfig\n): {\n  destructive: string[];\n  nonDestructive: string[];\n} {\n  const destructive: string[] = [];\n  const nonDestructive: string[] = [];\n\n  // Collection deletions are destructive, except for views which hold no data\n  for (const collection of diff.collectionsToDelete) {\n    if (collection.type === \"view\") {\n      nonDestructive.push(`Delete view collection: ${collection.name}`);\n    } else {\n      destructive.push(`Delete collection: ${collection.name}`);\n    }\n  }\n\n  // Collection creations are non-destructive\n  for (const collection of diff.collectionsToCreate) {\n    nonDestructive.push(`Create collection: ${collection.name}`);\n  }\n\n  // Analyze modifications\n  for (const modification of diff.collectionsToModify) {\n    const collectionName = modification.collection;\n\n    // Field deletions are destructive\n    for (const field of modification.fieldsToRemove) {\n      destructive.push(`Delete field: ${collectionName}.${field.name}`);\n    }\n\n    // Field additions are non-destructive\n    for (const field of modification.fieldsToAdd) {\n      nonDestructive.push(`Add field: ${collectionName}.${field.name}`);\n    }\n\n    // Field modifications can be destructive or non-destructive\n    for (const fieldMod of modification.fieldsToModify) {\n      const hasTypeChange = fieldMod.changes.some((c) => c.property === \"type\");\n      const hasRequiredChange = fieldMod.changes.some((c) => c.property === \"required\" && c.newValue === true);\n\n      if (hasTypeChange) {\n        destructive.push(\n          `Change field type: ${collectionName}.${fieldMod.fieldName} (${fieldMod.changes.find((c) => c.property === \"type\")?.oldValue} → ${fieldMod.changes.find((c) => c.property === \"type\")?.newValue})`\n        );\n      } else if (hasRequiredChange) {\n        destructive.push(`Make field required: ${collectionName}.${fieldMod.fieldName}`);\n      } else {\n        nonDestructive.push(`Modify field: ${collectionName}.${fieldMod.fieldName}`);\n      }\n    }\n\n    // Index changes are generally non-destructive\n    for (const _index of modification.indexesToAdd) {\n      nonDestructive.push(`Add index: ${collectionName}`);\n    }\n\n    for (const _index of modification.indexesToRemove) {\n      nonDestructive.push(`Remove index: ${collectionName}`);\n    }\n\n    // Rule changes are non-destructive\n    for (const rule of modification.rulesToUpdate) {\n      nonDestructive.push(`Update rule: ${collectionName}.${rule.ruleType}`);\n    }\n\n    // View query changes are non-destructive - a view stores no data\n    if (modification.viewQueryUpdate) {\n      nonDestructive.push(`Update view query: ${collectionName}`);\n    }\n  }\n\n  return { destructive, nonDestructive };\n}\n","/**\n * Diff Engine component\n * Compares current schema with previous snapshot and identifies changes\n *\n * This module provides a standalone, configurable diff engine that can be used\n * by consumer projects to compare schema definitions and detect changes.\n */\n\nimport type { CollectionModification, SchemaDefinition, SchemaDiff, SchemaSnapshot } from \"../types\";\nimport { CollectionIdRegistry } from \"../utils/collection-id-generator\";\nimport {\n  buildCollectionModification,\n  findNewCollections,\n  findRemovedCollections,\n  matchCollectionsByName,\n} from \"./collections\";\nimport { type DiffEngineConfig } from \"./config\";\nimport { isSystemCollection } from \"./utils\";\n\n// Curated submodule surface — matching/aggregation internals (mergeConfig,\n// buildCollectionModification, find*/match* helpers, normalizeSql) stay\n// module-private\nexport { filterSystemCollections } from \"./collections\";\nexport { type DiffEngineConfig } from \"./config\";\nexport { compareFieldOptions } from \"./fields\";\nexport { filterDiff, type FilterOptions } from \"./filter\";\nexport { comparePermissions } from \"./rules\";\nexport { categorizeChangesBySeverity } from \"./summary\";\nexport { isSystemCollection } from \"./utils\";\n\n/**\n * Checks if a collection modification has any actual changes\n *\n * @param modification - Collection modification to check\n * @returns True if there are any changes\n */\nfunction hasChanges(modification: CollectionModification): boolean {\n  return (\n    modification.fieldsToAdd.length > 0 ||\n    modification.fieldsToRemove.length > 0 ||\n    modification.fieldsToModify.length > 0 ||\n    modification.indexesToAdd.length > 0 ||\n    modification.indexesToRemove.length > 0 ||\n    modification.rulesToUpdate.length > 0 ||\n    modification.permissionsToUpdate.length > 0 ||\n    modification.viewQueryUpdate !== undefined\n  );\n}\n\n/**\n * Main comparison function\n * Compares current schema with previous snapshot and returns complete diff\n *\n * @param currentSchema - Current schema definition\n * @param previousSnapshot - Previous schema snapshot (null for first run)\n * @param config - Optional configuration\n * @returns Complete SchemaDiff with all detected changes\n */\nexport function compare(\n  currentSchema: SchemaDefinition,\n  previousSnapshot: SchemaSnapshot | null,\n  config?: DiffEngineConfig\n): SchemaDiff {\n  // Build lookup map for ID -> Name from previous snapshot\n  // This helps resolve relations where snapshot uses ID but schema uses Name\n  const collectionIdToName = new Map<string, string>();\n  if (previousSnapshot) {\n    for (const [name, collection] of previousSnapshot.collections) {\n      if (collection.id) {\n        collectionIdToName.set(collection.id, name);\n      }\n    }\n  }\n\n  // Find new and removed collections\n  const collectionsToCreate = findNewCollections(currentSchema, previousSnapshot);\n  const collectionsToDelete = findRemovedCollections(currentSchema, previousSnapshot);\n\n  // Filter out system collections from create and delete operations\n  const filteredCollectionsToCreate = collectionsToCreate.filter(\n    (collection) => !isSystemCollection(collection.name, config)\n  );\n  const filteredCollectionsToDelete = collectionsToDelete.filter(\n    (collection) => !isSystemCollection(collection.name, config)\n  );\n\n  // Generate and assign collection IDs for new collections\n  const registry = new CollectionIdRegistry();\n  const collectionsWithIds = filteredCollectionsToCreate.map((collection) => {\n    // If the collection already has an ID, register it and use it\n    if (collection.id) {\n      registry.register(collection.id);\n      return collection;\n    }\n\n    // Generate a new ID for the collection (pass name for special handling)\n    const id = registry.generate(collection.name);\n    return {\n      ...collection,\n      id,\n    };\n  });\n\n  // Find modified collections\n  const collectionsToModify: CollectionModification[] = [];\n  const matchedCollections = matchCollectionsByName(currentSchema, previousSnapshot);\n\n  for (const [currentCollection, previousCollection] of matchedCollections) {\n    const modification = buildCollectionModification(currentCollection, previousCollection, config, collectionIdToName);\n\n    // Only include if there are actual changes\n    // Note: We allow modifications to the users collection (non-system)\n    if (hasChanges(modification)) {\n      collectionsToModify.push(modification);\n    }\n  }\n\n  // Build map of existing collection names to their IDs from the snapshot\n  // This is used by the generator to resolve relation field references\n  const existingCollectionIds = new Map<string, string>();\n  if (previousSnapshot) {\n    for (const [name, collection] of previousSnapshot.collections) {\n      if (collection.id) {\n        existingCollectionIds.set(name, collection.id);\n      }\n    }\n  }\n\n  return {\n    collectionsToCreate: collectionsWithIds,\n    collectionsToDelete: filteredCollectionsToDelete,\n    collectionsToModify,\n    existingCollectionIds,\n  };\n}\n","/**\n * Validation and warning utilities for migration tool\n * Detects destructive changes and provides warnings\n */\n\nimport type { SchemaDiff } from \"./types\";\n\n/**\n * Types of destructive changes\n */\nexport enum DestructiveChangeType {\n  COLLECTION_DELETION = \"collection_deletion\",\n  FIELD_DELETION = \"field_deletion\",\n  FIELD_TYPE_CHANGE = \"field_type_change\",\n  FIELD_REQUIRED_CHANGE = \"field_required_change\",\n}\n\n/**\n * Represents a destructive change with details\n */\nexport interface DestructiveChange {\n  type: DestructiveChangeType;\n  description: string;\n  collection: string;\n  field?: string;\n  details?: {\n    oldValue?: any;\n    newValue?: any;\n  };\n  severity: \"high\" | \"medium\" | \"low\";\n  warning: string;\n}\n\n/**\n * Detects collection deletions\n *\n * @param diff - Schema diff\n * @returns Array of destructive changes for collection deletions\n */\nfunction detectCollectionDeletions(diff: SchemaDiff): DestructiveChange[] {\n  const changes: DestructiveChange[] = [];\n\n  for (const collection of diff.collectionsToDelete) {\n    // View collections store no data, so dropping one is not destructive\n    if (collection.type === \"view\") {\n      continue;\n    }\n\n    changes.push({\n      type: DestructiveChangeType.COLLECTION_DELETION,\n      description: `Delete collection: ${collection.name}`,\n      collection: collection.name,\n      severity: \"high\",\n      warning: `All data in the \"${collection.name}\" collection will be permanently deleted.`,\n    });\n  }\n\n  return changes;\n}\n\n/**\n * Detects field deletions\n *\n * @param diff - Schema diff\n * @returns Array of destructive changes for field deletions\n */\nfunction detectFieldDeletions(diff: SchemaDiff): DestructiveChange[] {\n  const changes: DestructiveChange[] = [];\n\n  for (const modification of diff.collectionsToModify) {\n    for (const field of modification.fieldsToRemove) {\n      changes.push({\n        type: DestructiveChangeType.FIELD_DELETION,\n        description: `Delete field: ${modification.collection}.${field.name}`,\n        collection: modification.collection,\n        field: field.name,\n        severity: \"high\",\n        warning: `All data in the \"${field.name}\" field of \"${modification.collection}\" will be permanently deleted.`,\n      });\n    }\n  }\n\n  return changes;\n}\n\n/**\n * Detects field type changes\n *\n * @param diff - Schema diff\n * @returns Array of destructive changes for field type changes\n */\nfunction detectFieldTypeChanges(diff: SchemaDiff): DestructiveChange[] {\n  const changes: DestructiveChange[] = [];\n\n  for (const modification of diff.collectionsToModify) {\n    for (const fieldMod of modification.fieldsToModify) {\n      const typeChange = fieldMod.changes.find((c) => c.property === \"type\");\n\n      if (typeChange) {\n        changes.push({\n          type: DestructiveChangeType.FIELD_TYPE_CHANGE,\n          description: `Change field type: ${modification.collection}.${fieldMod.fieldName}`,\n          collection: modification.collection,\n          field: fieldMod.fieldName,\n          details: {\n            oldValue: typeChange.oldValue,\n            newValue: typeChange.newValue,\n          },\n          severity: \"high\",\n          warning: `Changing field type from \"${typeChange.oldValue}\" to \"${typeChange.newValue}\" may cause data loss or conversion errors.`,\n        });\n      }\n    }\n  }\n\n  return changes;\n}\n\n/**\n * Detects field required changes (making optional field required)\n *\n * @param diff - Schema diff\n * @returns Array of destructive changes for required field changes\n */\nfunction detectFieldRequiredChanges(diff: SchemaDiff): DestructiveChange[] {\n  const changes: DestructiveChange[] = [];\n\n  for (const modification of diff.collectionsToModify) {\n    for (const fieldMod of modification.fieldsToModify) {\n      const requiredChange = fieldMod.changes.find(\n        (c) => c.property === \"required\" && c.newValue === true && c.oldValue === false\n      );\n\n      if (requiredChange) {\n        changes.push({\n          type: DestructiveChangeType.FIELD_REQUIRED_CHANGE,\n          description: `Make field required: ${modification.collection}.${fieldMod.fieldName}`,\n          collection: modification.collection,\n          field: fieldMod.fieldName,\n          details: {\n            oldValue: false,\n            newValue: true,\n          },\n          severity: \"medium\",\n          warning: `Making \"${fieldMod.fieldName}\" required may cause issues with existing records that have null/empty values.`,\n        });\n      }\n    }\n  }\n\n  return changes;\n}\n\n/**\n * Detects all destructive changes in a schema diff\n *\n * @param diff - Schema diff to analyze\n * @returns Array of all destructive changes\n */\nexport function detectDestructiveChanges(diff: SchemaDiff): DestructiveChange[] {\n  const changes: DestructiveChange[] = [];\n\n  // Detect collection deletions\n  changes.push(...detectCollectionDeletions(diff));\n\n  // Detect field deletions\n  changes.push(...detectFieldDeletions(diff));\n\n  // Detect field type changes\n  changes.push(...detectFieldTypeChanges(diff));\n\n  // Detect field required changes\n  changes.push(...detectFieldRequiredChanges(diff));\n\n  return changes;\n}\n\n/**\n * Checks if a diff contains any destructive changes\n *\n * @param diff - Schema diff to check\n * @returns True if there are destructive changes\n */\nexport function hasDestructiveChanges(diff: SchemaDiff): boolean {\n  const changes = detectDestructiveChanges(diff);\n  return changes.length > 0;\n}\n\n/**\n * Formats destructive changes for display\n * Groups changes by severity and provides clear warnings\n *\n * @param changes - Array of destructive changes\n * @returns Formatted string for display\n */\nexport function formatDestructiveChanges(changes: DestructiveChange[]): string {\n  if (changes.length === 0) {\n    return \"No destructive changes detected.\";\n  }\n\n  const lines: string[] = [];\n\n  // Group by severity\n  const highSeverity = changes.filter((c) => c.severity === \"high\");\n  const mediumSeverity = changes.filter((c) => c.severity === \"medium\");\n  const lowSeverity = changes.filter((c) => c.severity === \"low\");\n\n  // Display high severity changes\n  if (highSeverity.length > 0) {\n    lines.push(\"🔴 HIGH SEVERITY CHANGES (Data Loss Risk):\");\n    lines.push(\"\");\n    for (const change of highSeverity) {\n      lines.push(`  • ${change.description}`);\n      lines.push(`    ⚠️  ${change.warning}`);\n      if (change.details) {\n        if (change.details.oldValue !== undefined && change.details.newValue !== undefined) {\n          lines.push(`    Old: ${change.details.oldValue} → New: ${change.details.newValue}`);\n        }\n      }\n      lines.push(\"\");\n    }\n  }\n\n  // Display medium severity changes\n  if (mediumSeverity.length > 0) {\n    lines.push(\"🟡 MEDIUM SEVERITY CHANGES (Potential Issues):\");\n    lines.push(\"\");\n    for (const change of mediumSeverity) {\n      lines.push(`  • ${change.description}`);\n      lines.push(`    ⚠️  ${change.warning}`);\n      if (change.details) {\n        if (change.details.oldValue !== undefined && change.details.newValue !== undefined) {\n          lines.push(`    Old: ${change.details.oldValue} → New: ${change.details.newValue}`);\n        }\n      }\n      lines.push(\"\");\n    }\n  }\n\n  // Display low severity changes\n  if (lowSeverity.length > 0) {\n    lines.push(\"🟢 LOW SEVERITY CHANGES:\");\n    lines.push(\"\");\n    for (const change of lowSeverity) {\n      lines.push(`  • ${change.description}`);\n      lines.push(`    ℹ️  ${change.warning}`);\n      lines.push(\"\");\n    }\n  }\n\n  return lines.join(\"\\n\");\n}\n\n/**\n * Generates a summary of destructive changes\n *\n * @param changes - Array of destructive changes\n * @returns Summary object with counts by severity\n */\nexport function summarizeDestructiveChanges(changes: DestructiveChange[]): {\n  total: number;\n  high: number;\n  medium: number;\n  low: number;\n} {\n  return {\n    total: changes.length,\n    high: changes.filter((c) => c.severity === \"high\").length,\n    medium: changes.filter((c) => c.severity === \"medium\").length,\n    low: changes.filter((c) => c.severity === \"low\").length,\n  };\n}\n\n/**\n * Checks if force flag is required for the given changes\n * Force is required if there are any high or medium severity changes\n *\n * @param changes - Array of destructive changes\n * @returns True if force flag should be required\n */\nexport function requiresForceFlag(changes: DestructiveChange[]): boolean {\n  return changes.some((c) => c.severity === \"high\" || c.severity === \"medium\");\n}\n","/**\n * Configuration options for the migration generator\n */\nexport interface MigrationGeneratorConfig {\n  /**\n   * Directory to write migration files\n   */\n  migrationDir: string;\n\n  /**\n   * Workspace root for resolving relative paths\n   * Defaults to process.cwd()\n   */\n  workspaceRoot?: string;\n\n  /**\n   * Custom timestamp generator function\n   * Defaults to Unix timestamp in seconds\n   */\n  timestampGenerator?: () => string;\n\n  /**\n   * Custom migration file template\n   * Use {{UP_CODE}} and {{DOWN_CODE}} placeholders\n   */\n  template?: string;\n\n  /**\n   * Whether to include type reference comment\n   * Defaults to true\n   */\n  includeTypeReference?: boolean;\n\n  /**\n   * Path to types.d.ts file for reference comment\n   * Defaults to '../pb_data/types.d.ts'\n   */\n  typesPath?: string;\n\n  /**\n   * Whether to force generation even if duplicate migration exists\n   * Defaults to false\n   */\n  force?: boolean;\n}\n\n/**\n * Default migration template\n */\nexport const DEFAULT_TEMPLATE = `/// <reference path=\"{{TYPES_PATH}}\" />\nmigrate((app) => {\n{{UP_CODE}}\n}, (app) => {\n{{DOWN_CODE}}\n});\n`;\n\n/**\n * Default configuration values\n */\nexport const DEFAULT_CONFIG: Omit<Required<MigrationGeneratorConfig>, \"migrationDir\" | \"force\"> = {\n  workspaceRoot: process.cwd(),\n  timestampGenerator: () => Math.floor(Date.now() / 1000).toString(),\n  template: DEFAULT_TEMPLATE,\n  includeTypeReference: true,\n  typesPath: \"../pb_data/types.d.ts\",\n};\n\n/**\n * Merges user config with defaults\n */\nexport function mergeConfig(config: MigrationGeneratorConfig): Required<MigrationGeneratorConfig> {\n  return {\n    ...DEFAULT_CONFIG,\n    force: false,\n    ...config,\n  };\n}\n","import * as fs from \"fs\";\nimport * as path from \"path\";\nimport { FileSystemError, MigrationGenerationError } from \"../errors\";\nimport { DEFAULT_CONFIG, mergeConfig, type MigrationGeneratorConfig } from \"./config\";\n\n/**\n * Resolves the migration directory path\n */\nexport function resolveMigrationDir(config: MigrationGeneratorConfig): string {\n  const workspaceRoot = config.workspaceRoot || process.cwd();\n\n  if (path.isAbsolute(config.migrationDir)) {\n    return config.migrationDir;\n  }\n\n  return path.join(workspaceRoot, config.migrationDir);\n}\n\n/**\n * Creates the migration file structure with up and down functions\n *\n * @param upCode - Code for the up migration\n * @param downCode - Code for the down migration\n * @param config - Optional configuration with custom template\n * @returns Complete migration file content\n */\nexport function createMigrationFileStructure(\n  upCode: string,\n  downCode: string,\n  config?: MigrationGeneratorConfig\n): string {\n  const mergedConfig = config ? mergeConfig(config) : DEFAULT_CONFIG;\n  let template = mergedConfig.template;\n\n  // Replace placeholders using functions to avoid special character expansion (like $')\n  template = template.replace(\"{{TYPES_PATH}}\", () => mergedConfig.typesPath);\n  template = template.replace(\"{{UP_CODE}}\", () => upCode);\n  template = template.replace(\"{{DOWN_CODE}}\", () => downCode);\n\n  // Remove type reference if disabled\n  if (!mergedConfig.includeTypeReference) {\n    template = template.replace(/\\/\\/\\/ <reference path=\"[^\"]*\" \\/>\\n?/, \"\");\n  }\n\n  return template;\n}\n\n/**\n * Writes migration file to the specified directory\n * Creates directory if it doesn't exist\n *\n * @param migrationDir - Directory to write migration file\n * @param filename - Migration filename\n * @param content - Migration file content\n * @returns Full path to the created migration file\n */\nexport function writeMigrationFile(migrationDir: string, filename: string, content: string): string {\n  try {\n    // Ensure migration directory exists\n    if (!fs.existsSync(migrationDir)) {\n      try {\n        fs.mkdirSync(migrationDir, { recursive: true });\n      } catch (error) {\n        const fsError = error as NodeJS.ErrnoException;\n        if (fsError.code === \"EACCES\" || fsError.code === \"EPERM\") {\n          throw new FileSystemError(\n            `Permission denied creating migration directory. Check directory permissions.`,\n            migrationDir,\n            \"create\",\n            fsError.code,\n            error as Error\n          );\n        }\n        throw new FileSystemError(\n          `Failed to create migration directory: ${fsError.message}`,\n          migrationDir,\n          \"create\",\n          fsError.code,\n          error as Error\n        );\n      }\n    }\n\n    // Full path to migration file\n    const filePath = path.join(migrationDir, filename);\n\n    // Write migration file\n    fs.writeFileSync(filePath, content, \"utf-8\");\n\n    return filePath;\n  } catch (error) {\n    // If it's already a FileSystemError, re-throw it\n    if (error instanceof FileSystemError) {\n      throw error;\n    }\n\n    const fsError = error as NodeJS.ErrnoException;\n    const filePath = path.join(migrationDir, filename);\n\n    if (fsError.code === \"EACCES\" || fsError.code === \"EPERM\") {\n      throw new FileSystemError(\n        `Permission denied writing migration file. Check file and directory permissions.`,\n        filePath,\n        \"write\",\n        fsError.code,\n        error as Error\n      );\n    } else if (fsError.code === \"ENOSPC\") {\n      throw new FileSystemError(\n        `No space left on device when writing migration file.`,\n        filePath,\n        \"write\",\n        fsError.code,\n        error as Error\n      );\n    }\n\n    throw new MigrationGenerationError(`Failed to write migration file: ${fsError.message}`, filePath, error as Error);\n  }\n}\n","import type { FieldDefinition, FieldModification } from \"../types\";\nimport { getFieldOptionUnsetValue } from \"../utils/type-mapper\";\nimport { formatValue, generateFindCollectionCode, getFieldConstructorName } from \"./utils\";\n\n/**\n * Generates field definition object for collection creation\n * Creates the field configuration object used in Collection constructor\n *\n * @param field - Field definition\n * @param collectionIdMap - Map of collection names to their pre-generated IDs\n * @returns Field definition object as string\n */\nexport function generateFieldDefinitionObject(field: FieldDefinition, collectionIdMap?: Map<string, string>): string {\n  const parts: string[] = [];\n\n  // Add field name\n  parts.push(`      \"name\": \"${field.name}\"`);\n\n  // Add field id\n  parts.push(`      \"id\": \"${field.id}\"`);\n\n  // Add field type\n  parts.push(`      \"type\": \"${field.type}\"`);\n\n  // Add required flag\n  parts.push(`      \"required\": ${field.required}`);\n\n  // Add unique flag if present\n  if (field.unique !== undefined) {\n    parts.push(`      \"unique\": ${field.unique}`);\n  }\n\n  // Add explicit defaults for select fields\n  if (field.type === \"select\") {\n    // Always include maxSelect (default: 1)\n    const maxSelect = field.options?.maxSelect ?? 1;\n    parts.push(`      \"maxSelect\": ${maxSelect}`);\n\n    // Always include values array (default: [])\n    const values = field.options?.values ?? [];\n    parts.push(`      \"values\": ${formatValue(values)}`);\n  }\n\n  // Add options if present (excluding select-specific options already handled)\n  if (field.options && Object.keys(field.options).length > 0) {\n    for (const [key, value] of Object.entries(field.options)) {\n      // Skip select-specific options as they're handled above\n      if (field.type === \"select\" && (key === \"maxSelect\" || key === \"values\")) {\n        continue;\n      }\n      // Skip id as it's already added explicitly above\n      if (key === \"id\") {\n        continue;\n      }\n      // Convert noDecimal to onlyInt for number fields (PocketBase uses onlyInt)\n      if (field.type === \"number\" && key === \"noDecimal\") {\n        parts.push(`      \"onlyInt\": ${formatValue(value)}`);\n      } else {\n        parts.push(`      \"${key}\": ${formatValue(value)}`);\n      }\n    }\n  }\n\n  // Add relation configuration if present\n  if (field.relation) {\n    // Use pre-generated collection ID from map if available\n    // Otherwise fall back to runtime lookup (for existing collections not in the current diff)\n    const isUsersCollection = field.relation.collection.toLowerCase() === \"users\";\n    let collectionIdValue: string;\n\n    if (isUsersCollection) {\n      // Special case: users collection always uses the constant\n      collectionIdValue = '\"_pb_users_auth_\"';\n    } else if (collectionIdMap && collectionIdMap.has(field.relation.collection)) {\n      // Use pre-generated ID from map\n      collectionIdValue = `\"${collectionIdMap.get(field.relation.collection)}\"`;\n    } else {\n      // Fall back to runtime lookup for existing collections\n      collectionIdValue = `app.findCollectionByNameOrId(\"${field.relation.collection}\").id`;\n    }\n\n    parts.push(`      \"collectionId\": ${collectionIdValue}`);\n\n    // Always include maxSelect (default: 1)\n    const maxSelect = field.relation.maxSelect ?? 1;\n    parts.push(`      \"maxSelect\": ${maxSelect}`);\n\n    // Always include minSelect (default: null)\n    const minSelect = field.relation.minSelect ?? null;\n    parts.push(`      \"minSelect\": ${minSelect}`);\n\n    // Always include cascadeDelete (default: false)\n    const cascadeDelete = field.relation.cascadeDelete ?? false;\n    parts.push(`      \"cascadeDelete\": ${cascadeDelete}`);\n\n    // `displayFields` is deliberately not emitted: PocketBase dropped it from\n    // the relation field in v0.23 and silently discards it on save, so writing\n    // it only makes the generated file diverge from what PocketBase stores\n  }\n\n  return `    {\\n${parts.join(\",\\n\")},\\n    }`;\n}\n\n/**\n * Generates fields array for collection creation\n *\n * @param fields - Array of field definitions\n * @param collectionIdMap - Map of collection names to their pre-generated IDs\n * @returns Fields array as string\n */\nexport function generateFieldsArray(fields: FieldDefinition[], collectionIdMap?: Map<string, string>): string {\n  if (fields.length === 0) {\n    return \"[]\";\n  }\n\n  const fieldObjects = fields.map((field) => generateFieldDefinitionObject(field, collectionIdMap));\n  return `[\\n${fieldObjects.join(\",\\n\")},\\n  ]`;\n}\n\n/**\n * Generates field constructor options object\n *\n * @param field - Field definition\n * @param collectionIdMap - Map of collection names to their pre-generated IDs\n * @returns Options object as string\n */\nexport function generateFieldConstructorOptions(field: FieldDefinition, collectionIdMap?: Map<string, string>): string {\n  const parts: string[] = [];\n\n  // Add field name\n  parts.push(`    \"name\": \"${field.name}\"`);\n\n  // Add field id\n  parts.push(`    \"id\": \"${field.id}\"`);\n\n  // Add required flag\n  parts.push(`    \"required\": ${field.required}`);\n\n  // Add unique flag if present\n  if (field.unique !== undefined) {\n    parts.push(`    \"unique\": ${field.unique}`);\n  }\n\n  // Add explicit defaults for select fields\n  if (field.type === \"select\") {\n    // Always include maxSelect (default: 1)\n    const maxSelect = field.options?.maxSelect ?? 1;\n    parts.push(`    \"maxSelect\": ${maxSelect}`);\n\n    // Always include values array (default: [])\n    const values = field.options?.values ?? [];\n    parts.push(`    \"values\": ${formatValue(values)}`);\n  }\n\n  // Add options if present (excluding select-specific options already handled)\n  if (field.options && Object.keys(field.options).length > 0) {\n    for (const [key, value] of Object.entries(field.options)) {\n      // Skip select-specific options as they're handled above\n      if (field.type === \"select\" && (key === \"maxSelect\" || key === \"values\")) {\n        continue;\n      }\n      // Skip id as it's already added explicitly above\n      if (key === \"id\") {\n        continue;\n      }\n      // Convert noDecimal to onlyInt for number fields (PocketBase uses onlyInt)\n      if (field.type === \"number\" && key === \"noDecimal\") {\n        parts.push(`    \"onlyInt\": ${formatValue(value)}`);\n      } else {\n        parts.push(`    \"${key}\": ${formatValue(value)}`);\n      }\n    }\n  }\n\n  // Add relation-specific options\n  if (field.relation && field.type === \"relation\") {\n    // Use pre-generated collection ID from map if available\n    // Otherwise fall back to runtime lookup (for existing collections not in the current diff)\n    const isUsersCollection = field.relation.collection.toLowerCase() === \"users\";\n    let collectionIdValue: string;\n\n    if (isUsersCollection) {\n      // Special case: users collection always uses the constant\n      collectionIdValue = '\"_pb_users_auth_\"';\n    } else if (collectionIdMap && collectionIdMap.has(field.relation.collection)) {\n      // Use pre-generated ID from map\n      collectionIdValue = `\"${collectionIdMap.get(field.relation.collection)}\"`;\n    } else {\n      // Fall back to runtime lookup for existing collections\n      collectionIdValue = `app.findCollectionByNameOrId(\"${field.relation.collection}\").id`;\n    }\n\n    parts.push(`    \"collectionId\": ${collectionIdValue}`);\n\n    // Always include maxSelect (default: 1)\n    const maxSelect = field.relation.maxSelect ?? 1;\n    parts.push(`    \"maxSelect\": ${maxSelect}`);\n\n    // Always include minSelect (default: null)\n    const minSelect = field.relation.minSelect ?? null;\n    parts.push(`    \"minSelect\": ${minSelect}`);\n\n    // Always include cascadeDelete (default: false)\n    const cascadeDelete = field.relation.cascadeDelete ?? false;\n    parts.push(`    \"cascadeDelete\": ${cascadeDelete}`);\n\n    // See generateFieldDefinitionObject: PocketBase has no displayFields\n    // option on relation fields since v0.23\n  }\n\n  return parts.join(\",\\n\");\n}\n\n/**\n * Generates code for adding a field to an existing collection\n * Uses the appropriate Field constructor based on field type\n *\n * @param collectionName - Name of the collection\n * @param field - Field definition to add\n * @param varName - Variable name to use for the collection (default: auto-generated)\n * @param isLast - Whether this is the last operation (will return the result)\n * @param collectionIdMap - Map of collection names to their pre-generated IDs\n * @returns JavaScript code for adding the field\n */\nexport function generateFieldAddition(\n  collectionName: string,\n  field: FieldDefinition,\n  varName?: string,\n  isLast: boolean = false,\n  collectionIdMap?: Map<string, string>\n): string {\n  const lines: string[] = [];\n  const constructorName = getFieldConstructorName(field.type);\n  const collectionVar = varName || `collection_${collectionName}_${field.name}`;\n\n  lines.push(`  const ${collectionVar} = ${generateFindCollectionCode(collectionName, collectionIdMap)};`);\n  lines.push(``);\n  lines.push(`  ${collectionVar}.fields.add(new ${constructorName}({`);\n  lines.push(generateFieldConstructorOptions(field, collectionIdMap));\n  lines.push(`  }));`);\n  lines.push(``);\n  lines.push(isLast ? `  return app.save(${collectionVar});` : `  app.save(${collectionVar});`);\n\n  return lines.join(\"\\n\");\n}\n\n/**\n * Generates code for modifying an existing field\n * Updates field properties based on detected changes\n *\n * @param collectionName - Name of the collection\n * @param modification - Field modification details\n * @param varName - Variable name to use for the collection (default: auto-generated)\n * @param isLast - Whether this is the last operation (will return the result)\n * @returns JavaScript code for modifying the field\n */\nexport function generateFieldModification(\n  collectionName: string,\n  modification: FieldModification,\n  varName?: string,\n  isLast: boolean = false,\n  collectionIdMap?: Map<string, string>\n): string {\n  const lines: string[] = [];\n  const collectionVar = varName || `collection_${collectionName}_${modification.fieldName}`;\n  const fieldVar = `${collectionVar}_field`;\n  const fieldType = modification.newDefinition?.type ?? modification.currentDefinition?.type;\n\n  lines.push(`  const ${collectionVar} = ${generateFindCollectionCode(collectionName, collectionIdMap)};`);\n  lines.push(`  const ${fieldVar} = ${collectionVar}.fields.getByName(\"${modification.fieldName}\");`);\n  lines.push(``);\n\n  // Apply each change\n  for (const change of modification.changes) {\n    if (change.property.startsWith(\"options.\")) {\n      // Handle nested options properties\n      const optionKey = change.property.replace(\"options.\", \"\");\n      // A schema that stops setting an option leaves no value to assign, but\n      // the option still exists on PocketBase's field struct, so it has to be\n      // written back to its zero value (`max = 0`, `pattern = \"\"`). Assigning\n      // `null` describes a state the server cannot hold, and replay reads it\n      // back as a removal still pending — the same migration, every run.\n      const newValue =\n        change.newValue === undefined ? getFieldOptionUnsetValue(fieldType, optionKey) : change.newValue;\n      // In PocketBase, field properties are set directly on the field, not in an options object\n      // (`noDecimal` is this project's name for what PocketBase stores as `onlyInt`)\n      const pbKey = fieldType === \"number\" && optionKey === \"noDecimal\" ? \"onlyInt\" : optionKey;\n      lines.push(`  ${fieldVar}.${pbKey} = ${formatValue(newValue)};`);\n    } else if (change.property.startsWith(\"relation.\")) {\n      // Handle nested relation properties\n      const relationKey = change.property.replace(\"relation.\", \"\");\n\n      if (relationKey === \"collection\") {\n        // Special handling for collection ID\n        // Use case-insensitive check for \"users\" to handle both explicit and implicit relation definitions\n        const isUsersCollection = String(change.newValue).toLowerCase() === \"users\";\n        let collectionIdValue: string;\n\n        if (isUsersCollection) {\n          collectionIdValue = '\"_pb_users_auth_\"';\n        } else if (collectionIdMap && collectionIdMap.has(String(change.newValue))) {\n          // Use pre-generated ID from map (for existing collections)\n          collectionIdValue = `\"${collectionIdMap.get(String(change.newValue))}\"`;\n        } else {\n          // Fall back to runtime lookup (should not happen if snapshot is properly loaded)\n          collectionIdValue = `app.findCollectionByNameOrId(\"${change.newValue}\").id`;\n        }\n        lines.push(`  ${fieldVar}.collectionId = ${collectionIdValue};`);\n      } else {\n        lines.push(`  ${fieldVar}.${relationKey} = ${formatValue(change.newValue)};`);\n      }\n    } else {\n      // Handle top-level properties\n      lines.push(`  ${fieldVar}.${change.property} = ${formatValue(change.newValue)};`);\n    }\n  }\n\n  lines.push(``);\n  lines.push(isLast ? `  return app.save(${collectionVar});` : `  app.save(${collectionVar});`);\n\n  return lines.join(\"\\n\");\n}\n\n/**\n * Generates code for deleting a field from a collection\n *\n * @param collectionName - Name of the collection\n * @param fieldName - Name of the field to delete\n * @param varName - Variable name to use for the collection (default: auto-generated)\n * @param isLast - Whether this is the last operation (will return the result)\n * @returns JavaScript code for deleting the field\n */\nexport function generateFieldDeletion(\n  collectionName: string,\n  fieldName: string,\n  varName?: string,\n  isLast: boolean = false,\n  collectionIdMap?: Map<string, string>\n): string {\n  const lines: string[] = [];\n  const collectionVar = varName || `collection_${collectionName}_${fieldName}`;\n\n  lines.push(`  const ${collectionVar} = ${generateFindCollectionCode(collectionName, collectionIdMap)};`);\n  lines.push(``);\n  lines.push(`  ${collectionVar}.fields.removeByName(\"${fieldName}\");`);\n  lines.push(``);\n  lines.push(isLast ? `  return app.save(${collectionVar});` : `  app.save(${collectionVar});`);\n\n  return lines.join(\"\\n\");\n}\n","import { generateFindCollectionCode } from \"./utils\";\n\n/**\n * Generates indexes array for collection creation\n *\n * @param indexes - Array of index definitions\n * @returns Indexes array as string\n */\nexport function generateIndexesArray(indexes?: string[]): string {\n  if (!indexes || indexes.length === 0) {\n    return \"[]\";\n  }\n\n  const indexStrings = indexes.map((idx) => JSON.stringify(idx));\n  return `[\\n    ${indexStrings.join(\",\\n    \")},\\n  ]`;\n}\n\n/**\n * Generates code for adding an index to a collection\n *\n * @param collectionName - Name of the collection\n * @param index - Index SQL statement\n * @param varName - Variable name to use for the collection (default: auto-generated)\n * @param isLast - Whether this is the last operation (will return the result)\n * @returns JavaScript code for adding the index\n */\nexport function generateIndexAddition(\n  collectionName: string,\n  index: string,\n  varName?: string,\n  isLast: boolean = false,\n  collectionIdMap?: Map<string, string>\n): string {\n  const lines: string[] = [];\n  const collectionVar = varName || `collection_${collectionName}_idx`;\n\n  lines.push(`  const ${collectionVar} = ${generateFindCollectionCode(collectionName, collectionIdMap)};`);\n  lines.push(`  ${collectionVar}.indexes.push(${JSON.stringify(index)});`);\n  lines.push(isLast ? `  return app.save(${collectionVar});` : `  app.save(${collectionVar});`);\n\n  return lines.join(\"\\n\");\n}\n\n/**\n * Generates code for removing an index from a collection\n *\n * @param collectionName - Name of the collection\n * @param index - Index SQL statement\n * @param varName - Variable name to use for the collection (default: auto-generated)\n * @param isLast - Whether this is the last operation (will return the result)\n * @returns JavaScript code for removing the index\n */\nexport function generateIndexRemoval(\n  collectionName: string,\n  index: string,\n  varName?: string,\n  isLast: boolean = false,\n  collectionIdMap?: Map<string, string>\n): string {\n  const lines: string[] = [];\n  const collectionVar = varName || `collection_${collectionName}_idx`;\n  const indexVar = `${collectionVar}_indexToRemove`;\n\n  lines.push(`  const ${collectionVar} = ${generateFindCollectionCode(collectionName, collectionIdMap)};`);\n  lines.push(`  const ${indexVar} = ${collectionVar}.indexes.findIndex(idx => idx === ${JSON.stringify(index)});`);\n  lines.push(`  if (${indexVar} !== -1) {`);\n  lines.push(`    ${collectionVar}.indexes.splice(${indexVar}, 1);`);\n  lines.push(`  }`);\n  lines.push(isLast ? `  return app.save(${collectionVar});` : `  app.save(${collectionVar});`);\n\n  return lines.join(\"\\n\");\n}\n","import type { CollectionSchema } from \"../types\";\nimport { formatSqlTemplate, formatValue, generateFindCollectionCode } from \"./utils\";\n\n/**\n * Generates collection rules object\n *\n * @param rules - Collection rules\n * @returns Rules configuration as string\n */\nexport function generateCollectionRules(rules?: CollectionSchema[\"rules\"], collectionType: string = \"base\"): string {\n  if (!rules) {\n    return \"\";\n  }\n\n  // View collections are read-only: the write rules are always null and\n  // manageRule is not applicable\n  if (collectionType === \"view\") {\n    return [\n      `\"listRule\": ${formatValue(rules.listRule ?? null)}`,\n      `\"viewRule\": ${formatValue(rules.viewRule ?? null)}`,\n      `\"createRule\": null`,\n      `\"updateRule\": null`,\n      `\"deleteRule\": null`,\n    ].join(\",\\n    \");\n  }\n\n  const parts: string[] = [];\n\n  if (rules.listRule !== undefined) {\n    parts.push(`\"listRule\": ${formatValue(rules.listRule)}`);\n  }\n\n  if (rules.viewRule !== undefined) {\n    parts.push(`\"viewRule\": ${formatValue(rules.viewRule)}`);\n  }\n\n  if (rules.createRule !== undefined) {\n    parts.push(`\"createRule\": ${formatValue(rules.createRule)}`);\n  }\n\n  if (rules.updateRule !== undefined) {\n    parts.push(`\"updateRule\": ${formatValue(rules.updateRule)}`);\n  }\n\n  if (rules.deleteRule !== undefined) {\n    parts.push(`\"deleteRule\": ${formatValue(rules.deleteRule)}`);\n  }\n\n  if (collectionType === \"auth\" && rules.manageRule !== undefined) {\n    parts.push(`\"manageRule\": ${formatValue(rules.manageRule)}`);\n  }\n\n  return parts.join(\",\\n    \");\n}\n\n/**\n * Generates collection permissions object\n * Permissions are the same as rules but extracted from schema metadata\n *\n * @param permissions - Collection permissions\n * @returns Permissions configuration as string\n */\nexport function generateCollectionPermissions(\n  permissions?: CollectionSchema[\"permissions\"],\n  collectionType: string = \"base\"\n): string {\n  if (!permissions) {\n    return \"\";\n  }\n\n  // View collections are read-only: the write rules are always null and\n  // manageRule is not applicable\n  if (collectionType === \"view\") {\n    return [\n      `\"listRule\": ${formatValue(permissions.listRule ?? null)}`,\n      `\"viewRule\": ${formatValue(permissions.viewRule ?? null)}`,\n      `\"createRule\": null`,\n      `\"updateRule\": null`,\n      `\"deleteRule\": null`,\n    ].join(\",\\n    \");\n  }\n\n  const parts: string[] = [];\n\n  if (permissions.listRule !== undefined) {\n    parts.push(`\"listRule\": ${formatValue(permissions.listRule)}`);\n  }\n\n  if (permissions.viewRule !== undefined) {\n    parts.push(`\"viewRule\": ${formatValue(permissions.viewRule)}`);\n  }\n\n  if (permissions.createRule !== undefined) {\n    parts.push(`\"createRule\": ${formatValue(permissions.createRule)}`);\n  }\n\n  if (permissions.updateRule !== undefined) {\n    parts.push(`\"updateRule\": ${formatValue(permissions.updateRule)}`);\n  }\n\n  if (permissions.deleteRule !== undefined) {\n    parts.push(`\"deleteRule\": ${formatValue(permissions.deleteRule)}`);\n  }\n\n  if (collectionType === \"auth\" && permissions.manageRule !== undefined) {\n    parts.push(`\"manageRule\": ${formatValue(permissions.manageRule)}`);\n  }\n\n  return parts.join(\",\\n    \");\n}\n\n/**\n * Generates code for updating collection rules\n *\n * @param collectionName - Name of the collection\n * @param ruleType - Type of rule to update\n * @param newValue - New rule value\n * @param varName - Variable name to use for the collection (default: auto-generated)\n * @param isLast - Whether this is the last operation (will return the result)\n * @returns JavaScript code for updating the rule\n */\nexport function generateRuleUpdate(\n  collectionName: string,\n  ruleType: string,\n  newValue: string | null,\n  varName?: string,\n  isLast: boolean = false,\n  collectionIdMap?: Map<string, string>\n): string {\n  const lines: string[] = [];\n  const collectionVar = varName || `collection_${collectionName}_${ruleType}`;\n\n  lines.push(`  const ${collectionVar} = ${generateFindCollectionCode(collectionName, collectionIdMap)};`);\n  lines.push(`  ${collectionVar}.${ruleType} = ${formatValue(newValue)};`);\n  lines.push(isLast ? `  return app.save(${collectionVar});` : `  app.save(${collectionVar});`);\n\n  return lines.join(\"\\n\");\n}\n\n/**\n * Generates code for updating collection permissions\n * Handles permission rule updates including manageRule for auth collections\n *\n * @param collectionName - Name of the collection\n * @param ruleType - Type of permission rule to update\n * @param newValue - New permission rule value\n * @param varName - Variable name to use for the collection (default: auto-generated)\n * @param isLast - Whether this is the last operation (will return the result)\n * @returns JavaScript code for updating the permission\n */\nexport function generatePermissionUpdate(\n  collectionName: string,\n  ruleType: string,\n  newValue: string | null,\n  varName?: string,\n  isLast: boolean = false,\n  collectionIdMap?: Map<string, string>\n): string {\n  const lines: string[] = [];\n  const collectionVar = varName || `collection_${collectionName}_${ruleType}`;\n\n  lines.push(`  const ${collectionVar} = ${generateFindCollectionCode(collectionName, collectionIdMap)};`);\n  lines.push(`  ${collectionVar}.${ruleType} = ${formatValue(newValue)};`);\n  lines.push(isLast ? `  return app.save(${collectionVar});` : `  app.save(${collectionVar});`);\n\n  return lines.join(\"\\n\");\n}\n\n/**\n * Generates code for updating a view collection's SQL query\n *\n * Applied in place so the collection ID stays stable - PocketBase re-derives\n * the view's fields when the collection is saved.\n *\n * Uses unmarshal() rather than a direct `collection.viewQuery = ...`\n * assignment: viewQuery lives on an embedded struct in PocketBase's Go model,\n * and a direct assignment from the migration JS runtime is silently dropped.\n *\n * @param collectionName - Name of the view collection\n * @param viewQuery - The SQL query to set\n * @param varName - Variable name to use for the collection (default: auto-generated)\n * @param isLast - Whether this is the last operation (will return the result)\n * @param collectionIdMap - Map of collection names to IDs\n * @returns JavaScript code for updating the view query\n */\nexport function generateViewQueryUpdate(\n  collectionName: string,\n  viewQuery: string,\n  varName?: string,\n  isLast: boolean = false,\n  collectionIdMap?: Map<string, string>\n): string {\n  const lines: string[] = [];\n  const collectionVar = varName || `collection_${collectionName}_viewQuery`;\n\n  lines.push(`  const ${collectionVar} = ${generateFindCollectionCode(collectionName, collectionIdMap)};`);\n  lines.push(`  unmarshal({`);\n  lines.push(`    \"viewQuery\": ${formatSqlTemplate(viewQuery, \"      \")},`);\n  lines.push(`  }, ${collectionVar})`);\n  lines.push(isLast ? `  return app.save(${collectionVar});` : `  app.save(${collectionVar});`);\n\n  return lines.join(\"\\n\");\n}\n\n/**\n * Generates a single unmarshal({...}, collection) block for multiple rule/permission changes.\n * Used when 2+ rules change at once to match PocketBase's native migration style.\n *\n * @param collectionName - Name of the collection\n * @param entries - Array of { ruleType, value } to include in the unmarshal object\n * @param varSuffix - Suffix for the variable name (e.g. \"rules\" or \"revert_rules\")\n * @param isLast - Whether this is the last operation (will use return app.save)\n * @param collectionIdMap - Map of collection names to IDs\n * @returns JavaScript code block\n */\nexport function generateGroupedRuleUpdates(\n  collectionName: string,\n  entries: Array<{ ruleType: string; value: string | null }>,\n  varSuffix: string,\n  isLast: boolean = false,\n  collectionIdMap?: Map<string, string>\n): string {\n  const collectionVar = `collection_${collectionName}_${varSuffix}`;\n  const lines: string[] = [];\n\n  lines.push(`  const ${collectionVar} = ${generateFindCollectionCode(collectionName, collectionIdMap)};`);\n  lines.push(`  unmarshal({`);\n  for (const entry of entries) {\n    lines.push(`    \"${entry.ruleType}\": ${formatValue(entry.value)},`);\n  }\n  lines.push(`  }, ${collectionVar})`);\n  lines.push(isLast ? `  return app.save(${collectionVar});` : `  app.save(${collectionVar});`);\n\n  return lines.join(\"\\n\");\n}\n","import type { CollectionSchema } from \"../types\";\nimport { generateFieldsArray } from \"./fields\";\nimport { generateIndexesArray } from \"./indexes\";\nimport { generateCollectionPermissions, generateCollectionRules } from \"./rules\";\nimport {\n  formatSqlTemplate,\n  formatValue,\n  generateFindCollectionCode,\n  getAuthSystemFields,\n  getAuthSystemIndexes,\n  getSystemFields,\n  getSystemTimestampFields,\n} from \"./utils\";\n\n/**\n * Generates Collection constructor call for creating a new collection\n *\n * @param collection - Collection schema\n * @param varName - Variable name to use for the collection (default: 'collection')\n * @returns JavaScript code for creating the collection\n */\nexport function generateCollectionCreation(\n  collection: CollectionSchema,\n  varName: string = \"collection\",\n  isLast: boolean = false,\n  collectionIdMap?: Map<string, string>\n): string {\n  const lines: string[] = [];\n\n  lines.push(`  const ${varName} = new Collection({`);\n  if (collection.id) {\n    lines.push(`    \"id\": ${formatValue(collection.id)},`);\n  }\n  lines.push(`    \"name\": \"${collection.name}\",`);\n  lines.push(`    \"type\": \"${collection.type}\",`);\n  lines.push(`    \"system\": false,`);\n\n  // Add permissions (preferred) or rules\n  // Permissions take precedence if both are defined\n  const permissionsCode = generateCollectionPermissions(collection.permissions, collection.type);\n  const rulesCode = generateCollectionRules(collection.rules, collection.type);\n\n  if (permissionsCode) {\n    lines.push(`    ${permissionsCode},`);\n  } else if (rulesCode) {\n    lines.push(`    ${rulesCode},`);\n  }\n\n  // View collections are defined by their SQL query: PocketBase derives the\n  // fields by running it, and views support neither fields nor indexes here\n  if (collection.type === \"view\") {\n    lines.push(`    \"viewQuery\": ${formatSqlTemplate(collection.viewQuery ?? \"\")},`);\n    lines.push(`  });`);\n    lines.push(``);\n    lines.push(isLast ? `  return app.save(${varName});` : `  app.save(${varName});`);\n\n    return lines.join(\"\\n\");\n  }\n\n  // Filter out system fields (they will be added back in correct order)\n  const systemFieldNames = [\"created\", \"updated\", \"id\"];\n  if (collection.type === \"auth\") {\n    systemFieldNames.push(...getAuthSystemFields().map((f) => f.name));\n  }\n  const userFields = collection.fields.filter((f) => !systemFieldNames.includes(f.name));\n\n  // Build field list in correct order: id, [auth fields], user fields, created, updated\n  const allFields = [...getSystemFields()];\n\n  if (collection.type === \"auth\") {\n    allFields.push(...getAuthSystemFields());\n  }\n\n  allFields.push(...userFields);\n  allFields.push(...getSystemTimestampFields());\n\n  // Add fields\n  lines.push(`    \"fields\": ${generateFieldsArray(allFields, collectionIdMap)},`);\n\n  // Add indexes\n  let allIndexes = [...(collection.indexes || [])];\n  if (collection.type === \"auth\") {\n    allIndexes = [...getAuthSystemIndexes(collection.name, collection.id), ...allIndexes];\n  }\n  lines.push(`    \"indexes\": ${generateIndexesArray(allIndexes)},`);\n\n  lines.push(`  });`);\n  lines.push(``);\n  lines.push(isLast ? `  return app.save(${varName});` : `  app.save(${varName});`);\n\n  return lines.join(\"\\n\");\n}\n\n/**\n * Generates code for deleting a collection\n *\n * @param collectionName - Name of the collection to delete\n * @param varName - Variable name to use for the collection (default: 'collection')\n * @param isLast - Whether this is the last operation (will return the result)\n * @returns JavaScript code for deleting the collection\n */\nexport function generateCollectionDeletion(\n  collectionName: string,\n  varName: string = \"collection\",\n  isLast: boolean = false,\n  collectionIdMap?: Map<string, string>\n): string {\n  const lines: string[] = [];\n\n  lines.push(`  const ${varName} = ${generateFindCollectionCode(collectionName, collectionIdMap)};`);\n  lines.push(isLast ? `  return app.delete(${varName});` : `  app.delete(${varName});`);\n\n  return lines.join(\"\\n\");\n}\n","import type { CollectionOperation, CollectionSchema, FieldModification, SchemaDiff } from \"../types\";\nimport { generateCollectionCreation, generateCollectionDeletion } from \"./collections\";\nimport { generateFieldAddition, generateFieldDeletion, generateFieldModification } from \"./fields\";\nimport { generateIndexAddition, generateIndexRemoval } from \"./indexes\";\nimport { generateGroupedRuleUpdates, generatePermissionUpdate, generateRuleUpdate, generateViewQueryUpdate } from \"./rules\";\n\n/**\n * Generates the up migration code for a single collection operation\n * Handles create, modify, and delete operations\n *\n * @param operation - Collection operation to generate migration for\n * @param collectionIdMap - Map of collection names to their pre-generated IDs\n * @returns JavaScript code for up migration\n */\nexport function generateOperationUpMigration(\n  operation: CollectionOperation,\n  collectionIdMap: Map<string, string>\n): string {\n  const lines: string[] = [];\n\n  if (operation.type === \"create\") {\n    // Handle collection creation\n    const collection = operation.collection as CollectionSchema;\n    const varName = \"collection\";\n    lines.push(generateCollectionCreation(collection, varName, true, collectionIdMap));\n  } else if (operation.type === \"modify\") {\n    // Handle collection modification\n    const modification = operation.modifications!;\n    const collectionName =\n      typeof operation.collection === \"string\"\n        ? operation.collection\n        : (operation.collection?.name ?? modification.collection);\n\n    let operationCount = 0;\n    const totalOperations =\n      modification.fieldsToAdd.length +\n      modification.fieldsToModify.length +\n      modification.fieldsToRemove.length +\n      modification.indexesToAdd.length +\n      modification.indexesToRemove.length +\n      (modification.viewQueryUpdate ? 1 : 0) +\n      (modification.permissionsToUpdate.length > 0 ? 1 : modification.rulesToUpdate.length > 0 ? 1 : 0);\n\n    // Update the view query (view collections only)\n    if (modification.viewQueryUpdate) {\n      operationCount++;\n      const isLast = operationCount === totalOperations;\n      lines.push(\n        generateViewQueryUpdate(\n          collectionName,\n          modification.viewQueryUpdate.newValue,\n          undefined,\n          isLast,\n          collectionIdMap\n        )\n      );\n      if (!isLast) lines.push(\"\");\n    }\n\n    // Add new fields\n    for (let i = 0; i < modification.fieldsToAdd.length; i++) {\n      const field = modification.fieldsToAdd[i];\n      operationCount++;\n      const varName = `collection_${collectionName}_add_${field.name}_${i}`;\n      const isLast = operationCount === totalOperations;\n      lines.push(generateFieldAddition(collectionName, field, varName, isLast, collectionIdMap));\n      if (!isLast) lines.push(\"\");\n    }\n\n    // Modify existing fields\n    for (const fieldMod of modification.fieldsToModify) {\n      operationCount++;\n      const varName = `collection_${collectionName}_modify_${fieldMod.fieldName}`;\n      const isLast = operationCount === totalOperations;\n      lines.push(generateFieldModification(collectionName, fieldMod, varName, isLast, collectionIdMap));\n      if (!isLast) lines.push(\"\");\n    }\n\n    // Remove fields\n    for (const field of modification.fieldsToRemove) {\n      operationCount++;\n      const varName = `collection_${collectionName}_remove_${field.name}`;\n      const isLast = operationCount === totalOperations;\n      lines.push(generateFieldDeletion(collectionName, field.name, varName, isLast, collectionIdMap));\n      if (!isLast) lines.push(\"\");\n    }\n\n    // Add indexes\n    for (let i = 0; i < modification.indexesToAdd.length; i++) {\n      operationCount++;\n      const index = modification.indexesToAdd[i];\n      const varName = `collection_${collectionName}_addidx_${i}`;\n      const isLast = operationCount === totalOperations;\n      lines.push(generateIndexAddition(collectionName, index, varName, isLast, collectionIdMap));\n      if (!isLast) lines.push(\"\");\n    }\n\n    // Remove indexes\n    for (let i = 0; i < modification.indexesToRemove.length; i++) {\n      operationCount++;\n      const index = modification.indexesToRemove[i];\n      const varName = `collection_${collectionName}_rmidx_${i}`;\n      const isLast = operationCount === totalOperations;\n      lines.push(generateIndexRemoval(collectionName, index, varName, isLast, collectionIdMap));\n      if (!isLast) lines.push(\"\");\n    }\n\n    // Update permissions (preferred) or rules (fallback)\n    if (modification.permissionsToUpdate && modification.permissionsToUpdate.length > 0) {\n      operationCount++;\n      const isLast = operationCount === totalOperations;\n      if (modification.permissionsToUpdate.length >= 2) {\n        const entries = modification.permissionsToUpdate.map((p) => ({ ruleType: p.ruleType, value: p.newValue }));\n        lines.push(generateGroupedRuleUpdates(collectionName, entries, \"rules\", isLast, collectionIdMap));\n      } else {\n        const permission = modification.permissionsToUpdate[0];\n        const varName = `collection_${collectionName}_perm_${permission.ruleType}`;\n        lines.push(generatePermissionUpdate(collectionName, permission.ruleType, permission.newValue, varName, isLast, collectionIdMap));\n      }\n      if (!isLast) lines.push(\"\");\n    } else if (modification.rulesToUpdate.length > 0) {\n      operationCount++;\n      const isLast = operationCount === totalOperations;\n      if (modification.rulesToUpdate.length >= 2) {\n        const entries = modification.rulesToUpdate.map((r) => ({ ruleType: r.ruleType, value: r.newValue }));\n        lines.push(generateGroupedRuleUpdates(collectionName, entries, \"rules\", isLast, collectionIdMap));\n      } else {\n        const rule = modification.rulesToUpdate[0];\n        const varName = `collection_${collectionName}_rule_${rule.ruleType}`;\n        lines.push(generateRuleUpdate(collectionName, rule.ruleType, rule.newValue, varName, isLast, collectionIdMap));\n      }\n      if (!isLast) lines.push(\"\");\n    }\n  } else if (operation.type === \"delete\") {\n    // Handle collection deletion\n    const collectionName = typeof operation.collection === \"string\" ? operation.collection : operation.collection.name;\n    const varName = \"collection\";\n    lines.push(generateCollectionDeletion(collectionName, varName, true, collectionIdMap));\n  }\n\n  let code = lines.join(\"\\n\");\n\n  // Check if there's already a return statement in the code\n  // If so, skip post-processing to avoid duplicate returns\n  const hasReturnStatement = /return\\s+app\\.(save|delete)\\(/m.test(code);\n\n  if (!hasReturnStatement) {\n    // Find the last app.save() or app.delete() call and make it return the result\n    // Match app.save(...) or app.delete(...) at the end of lines (not in comments or strings)\n    const savePattern = /^(\\s*)app\\.save\\((\\w+)\\);$/gm;\n    const deletePattern = /^(\\s*)app\\.delete\\((\\w+)\\);$/gm;\n\n    const saveMatches = [...code.matchAll(savePattern)];\n    const deleteMatches = [...code.matchAll(deletePattern)];\n\n    // Combine all matches and find the last one by position\n    const allMatches = [\n      ...saveMatches.map((m) => ({ match: m, type: \"save\", index: m.index! })),\n      ...deleteMatches.map((m) => ({ match: m, type: \"delete\", index: m.index! })),\n    ].sort((a, b) => b.index - a.index); // Sort descending to get last match first\n\n    if (allMatches.length > 0) {\n      const lastMatch = allMatches[0];\n      if (lastMatch.type === \"save\") {\n        code =\n          code.substring(0, lastMatch.match.index!) +\n          lastMatch.match[1] +\n          \"return app.save(\" +\n          lastMatch.match[2] +\n          \");\" +\n          code.substring(lastMatch.match.index! + lastMatch.match[0].length);\n      } else {\n        code =\n          code.substring(0, lastMatch.match.index!) +\n          lastMatch.match[1] +\n          \"return app.delete(\" +\n          lastMatch.match[2] +\n          \");\" +\n          code.substring(lastMatch.match.index! + lastMatch.match[0].length);\n      }\n    }\n  }\n\n  return code;\n}\n\n/**\n * Generates the down migration code for a single collection operation\n * Reverts the operation (inverse of up migration)\n *\n * @param operation - Collection operation to generate rollback for\n * @param collectionIdMap - Map of collection names to their pre-generated IDs\n * @returns JavaScript code for down migration\n */\nexport function generateOperationDownMigration(\n  operation: CollectionOperation,\n  collectionIdMap: Map<string, string>\n): string {\n  const lines: string[] = [];\n\n  if (operation.type === \"create\") {\n    // Rollback: delete the created collection\n    const collection = operation.collection as CollectionSchema;\n    const varName = \"collection\";\n    lines.push(generateCollectionDeletion(collection.name, varName, true, collectionIdMap));\n  } else if (operation.type === \"modify\") {\n    // Rollback: revert all modifications\n    const modification = operation.modifications!;\n    const collectionName =\n      typeof operation.collection === \"string\"\n        ? operation.collection\n        : (operation.collection?.name ?? modification.collection);\n\n    let operationCount = 0;\n    const totalOperations =\n      modification.fieldsToAdd.length +\n      modification.fieldsToModify.length +\n      modification.fieldsToRemove.length +\n      modification.indexesToAdd.length +\n      modification.indexesToRemove.length +\n      (modification.viewQueryUpdate ? 1 : 0) +\n      (modification.permissionsToUpdate.length > 0 ? 1 : modification.rulesToUpdate.length > 0 ? 1 : 0);\n\n    // Restore the previous view query (view collections only)\n    if (modification.viewQueryUpdate) {\n      operationCount++;\n      const isLast = operationCount === totalOperations;\n      lines.push(\n        generateViewQueryUpdate(\n          collectionName,\n          modification.viewQueryUpdate.oldValue ?? \"\",\n          `collection_${collectionName}_revert_viewQuery`,\n          isLast,\n          collectionIdMap\n        )\n      );\n      if (!isLast) lines.push(\"\");\n    }\n\n    // Revert permissions (preferred) or rules (fallback)\n    if (modification.permissionsToUpdate && modification.permissionsToUpdate.length > 0) {\n      operationCount++;\n      const isLast = operationCount === totalOperations;\n      if (modification.permissionsToUpdate.length >= 2) {\n        const entries = modification.permissionsToUpdate.map((p) => ({ ruleType: p.ruleType, value: p.oldValue }));\n        lines.push(generateGroupedRuleUpdates(collectionName, entries, \"revert_rules\", isLast, collectionIdMap));\n      } else {\n        const permission = modification.permissionsToUpdate[0];\n        const varName = `collection_${collectionName}_revert_perm_${permission.ruleType}`;\n        lines.push(generatePermissionUpdate(collectionName, permission.ruleType, permission.oldValue, varName, isLast, collectionIdMap));\n      }\n      if (!isLast) lines.push(\"\");\n    } else if (modification.rulesToUpdate.length > 0) {\n      operationCount++;\n      const isLast = operationCount === totalOperations;\n      if (modification.rulesToUpdate.length >= 2) {\n        const entries = modification.rulesToUpdate.map((r) => ({ ruleType: r.ruleType, value: r.oldValue }));\n        lines.push(generateGroupedRuleUpdates(collectionName, entries, \"revert_rules\", isLast, collectionIdMap));\n      } else {\n        const rule = modification.rulesToUpdate[0];\n        const varName = `collection_${collectionName}_revert_rule_${rule.ruleType}`;\n        lines.push(generateRuleUpdate(collectionName, rule.ruleType, rule.oldValue, varName, isLast, collectionIdMap));\n      }\n      if (!isLast) lines.push(\"\");\n    }\n\n    // Revert index removals (add them back)\n    for (let i = 0; i < modification.indexesToRemove.length; i++) {\n      operationCount++;\n      const index = modification.indexesToRemove[i];\n      const varName = `collection_${collectionName}_restore_idx_${i}`;\n      const isLast = operationCount === totalOperations;\n      lines.push(generateIndexAddition(collectionName, index, varName, isLast, collectionIdMap));\n      if (!isLast) lines.push(\"\");\n    }\n\n    // Revert index additions (remove them)\n    for (let i = 0; i < modification.indexesToAdd.length; i++) {\n      operationCount++;\n      const index = modification.indexesToAdd[i];\n      const varName = `collection_${collectionName}_revert_idx_${i}`;\n      const isLast = operationCount === totalOperations;\n      lines.push(generateIndexRemoval(collectionName, index, varName, isLast, collectionIdMap));\n      if (!isLast) lines.push(\"\");\n    }\n\n    // Revert field removals (add them back)\n    for (const field of modification.fieldsToRemove) {\n      operationCount++;\n      const varName = `collection_${collectionName}_restore_${field.name}`;\n      const isLast = operationCount === totalOperations;\n      lines.push(generateFieldAddition(collectionName, field, varName, isLast, collectionIdMap));\n      if (!isLast) lines.push(\"\");\n    }\n\n    // Revert field modifications\n    for (const fieldMod of modification.fieldsToModify) {\n      operationCount++;\n      // Create a reverse modification\n      const reverseChanges = fieldMod.changes.map((change) => ({\n        property: change.property,\n        oldValue: change.newValue,\n        newValue: change.oldValue,\n      }));\n\n      const reverseMod: FieldModification = {\n        fieldName: fieldMod.fieldName,\n        currentDefinition: fieldMod.newDefinition,\n        newDefinition: fieldMod.currentDefinition,\n        changes: reverseChanges,\n      };\n\n      const varName = `collection_${collectionName}_revert_${fieldMod.fieldName}`;\n      const isLast = operationCount === totalOperations;\n      lines.push(generateFieldModification(collectionName, reverseMod, varName, isLast, collectionIdMap));\n      if (!isLast) lines.push(\"\");\n    }\n\n    // Revert field additions (remove them)\n    for (const field of modification.fieldsToAdd) {\n      operationCount++;\n      const varName = `collection_${collectionName}_revert_add_${field.name}`;\n      const isLast = operationCount === totalOperations;\n      lines.push(generateFieldDeletion(collectionName, field.name, varName, isLast, collectionIdMap));\n      if (!isLast) lines.push(\"\");\n    }\n  } else if (operation.type === \"delete\") {\n    // Rollback: recreate the deleted collection\n    const collection = operation.collection;\n    if (typeof collection !== \"string\") {\n      const varName = \"collection\";\n      lines.push(generateCollectionCreation(collection, varName, true, collectionIdMap));\n    }\n  }\n\n  let code = lines.join(\"\\n\");\n\n  // Check if there's already a return statement in the code\n  // If so, skip post-processing to avoid duplicate returns\n  const hasReturnStatement = /return\\s+app\\.(save|delete)\\(/m.test(code);\n\n  if (!hasReturnStatement) {\n    // Find the last app.save() or app.delete() call and make it return the result\n    // Match app.save(...) or app.delete(...) at the end of lines (not in comments or strings)\n    const savePattern = /^(\\s*)app\\.save\\((\\w+)\\);$/gm;\n    const deletePattern = /^(\\s*)app\\.delete\\((\\w+)\\);$/gm;\n\n    const saveMatches = [...code.matchAll(savePattern)];\n    const deleteMatches = [...code.matchAll(deletePattern)];\n\n    // Combine all matches and find the last one by position\n    const allMatches = [\n      ...saveMatches.map((m) => ({ match: m, type: \"save\", index: m.index! })),\n      ...deleteMatches.map((m) => ({ match: m, type: \"delete\", index: m.index! })),\n    ].sort((a, b) => b.index - a.index); // Sort descending to get last match first\n\n    if (allMatches.length > 0) {\n      const lastMatch = allMatches[0];\n      if (lastMatch.type === \"save\") {\n        code =\n          code.substring(0, lastMatch.match.index!) +\n          lastMatch.match[1] +\n          \"return app.save(\" +\n          lastMatch.match[2] +\n          \");\" +\n          code.substring(lastMatch.match.index! + lastMatch.match[0].length);\n      } else {\n        code =\n          code.substring(0, lastMatch.match.index!) +\n          lastMatch.match[1] +\n          \"return app.delete(\" +\n          lastMatch.match[2] +\n          \");\" +\n          code.substring(lastMatch.match.index! + lastMatch.match[0].length);\n      }\n    }\n  }\n\n  return code;\n}\n\n/**\n * Generates the up migration function code\n * Applies all changes from the diff in the correct order\n *\n * @param diff - Schema diff containing all changes\n * @returns JavaScript code for up migration\n */\nexport function generateUpMigration(diff: SchemaDiff): string {\n  const lines: string[] = [];\n\n  // Add comment header\n  lines.push(`  // UP MIGRATION`);\n  lines.push(``);\n\n  // Build collection ID map from collections being created and existing collections\n  // This map will be used to resolve relation field references\n  const collectionIdMap = new Map<string, string>();\n  for (const collection of diff.collectionsToCreate) {\n    if (collection.id) {\n      collectionIdMap.set(collection.name, collection.id);\n    }\n  }\n  // Add existing collection IDs from snapshot (for relation fields referencing existing collections)\n  if (diff.existingCollectionIds) {\n    for (const [name, id] of diff.existingCollectionIds) {\n      collectionIdMap.set(name, id);\n    }\n  }\n\n  // 1. Create new collections\n  if (diff.collectionsToCreate.length > 0) {\n    lines.push(`  // Create new collections`);\n    for (let i = 0; i < diff.collectionsToCreate.length; i++) {\n      const collection = diff.collectionsToCreate[i];\n      const varName = `collection_${collection.name}_create`;\n      lines.push(generateCollectionCreation(collection, varName, false, collectionIdMap));\n      lines.push(``);\n    }\n  }\n\n  // 2. Modify existing collections\n  if (diff.collectionsToModify.length > 0) {\n    lines.push(`  // Modify existing collections`);\n    for (const modification of diff.collectionsToModify) {\n      const collectionName = modification.collection;\n\n      // Update the view query (view collections only)\n      if (modification.viewQueryUpdate) {\n        lines.push(`  // Update the view query of ${collectionName}`);\n        lines.push(\n          generateViewQueryUpdate(\n            collectionName,\n            modification.viewQueryUpdate.newValue,\n            undefined,\n            false,\n            collectionIdMap\n          )\n        );\n        lines.push(``);\n      }\n\n      // Add new fields\n      if (modification.fieldsToAdd.length > 0) {\n        lines.push(`  // Add fields to ${collectionName}`);\n        for (let i = 0; i < modification.fieldsToAdd.length; i++) {\n          const field = modification.fieldsToAdd[i];\n          const varName = `collection_${collectionName}_add_${field.name}_${i}`;\n          lines.push(generateFieldAddition(collectionName, field, varName, false, collectionIdMap));\n          lines.push(``);\n        }\n      }\n\n      // Modify existing fields\n      if (modification.fieldsToModify.length > 0) {\n        lines.push(`  // Modify fields in ${collectionName}`);\n        for (const fieldMod of modification.fieldsToModify) {\n          const varName = `collection_${collectionName}_modify_${fieldMod.fieldName}`;\n          lines.push(generateFieldModification(collectionName, fieldMod, varName, false, collectionIdMap));\n          lines.push(``);\n        }\n      }\n\n      // Remove fields\n      if (modification.fieldsToRemove.length > 0) {\n        lines.push(`  // Remove fields from ${collectionName}`);\n        for (const field of modification.fieldsToRemove) {\n          const varName = `collection_${collectionName}_remove_${field.name}`;\n          lines.push(generateFieldDeletion(collectionName, field.name, varName, false, collectionIdMap));\n          lines.push(``);\n        }\n      }\n\n      // Add indexes\n      if (modification.indexesToAdd.length > 0) {\n        lines.push(`  // Add indexes to ${collectionName}`);\n        for (let i = 0; i < modification.indexesToAdd.length; i++) {\n          const index = modification.indexesToAdd[i];\n          const varName = `collection_${collectionName}_addidx_${i}`;\n          lines.push(generateIndexAddition(collectionName, index, varName, false, collectionIdMap));\n          lines.push(``);\n        }\n      }\n\n      // Remove indexes\n      if (modification.indexesToRemove.length > 0) {\n        lines.push(`  // Remove indexes from ${collectionName}`);\n        for (let i = 0; i < modification.indexesToRemove.length; i++) {\n          const index = modification.indexesToRemove[i];\n          const varName = `collection_${collectionName}_rmidx_${i}`;\n          lines.push(generateIndexRemoval(collectionName, index, varName, false, collectionIdMap));\n          lines.push(``);\n        }\n      }\n\n      // Update permissions (preferred) or rules (fallback)\n      if (modification.permissionsToUpdate && modification.permissionsToUpdate.length > 0) {\n        lines.push(`  // Update permissions for ${collectionName}`);\n        if (modification.permissionsToUpdate.length >= 2) {\n          const entries = modification.permissionsToUpdate.map((p) => ({ ruleType: p.ruleType, value: p.newValue }));\n          lines.push(generateGroupedRuleUpdates(collectionName, entries, \"rules\", false, collectionIdMap));\n        } else {\n          const permission = modification.permissionsToUpdate[0];\n          const varName = `collection_${collectionName}_perm_${permission.ruleType}`;\n          lines.push(generatePermissionUpdate(collectionName, permission.ruleType, permission.newValue, varName, false, collectionIdMap));\n        }\n        lines.push(``);\n      } else if (modification.rulesToUpdate.length > 0) {\n        lines.push(`  // Update rules for ${collectionName}`);\n        if (modification.rulesToUpdate.length >= 2) {\n          const entries = modification.rulesToUpdate.map((r) => ({ ruleType: r.ruleType, value: r.newValue }));\n          lines.push(generateGroupedRuleUpdates(collectionName, entries, \"rules\", false, collectionIdMap));\n        } else {\n          const rule = modification.rulesToUpdate[0];\n          const varName = `collection_${collectionName}_rule_${rule.ruleType}`;\n          lines.push(generateRuleUpdate(collectionName, rule.ruleType, rule.newValue, varName, false, collectionIdMap));\n        }\n        lines.push(``);\n      }\n    }\n  }\n\n  // 3. Delete collections\n  if (diff.collectionsToDelete.length > 0) {\n    lines.push(`  // Delete collections`);\n    for (let i = 0; i < diff.collectionsToDelete.length; i++) {\n      const collection = diff.collectionsToDelete[i];\n      const varName = `collection_${collection.name}_delete`;\n      lines.push(generateCollectionDeletion(collection.name, varName, false, collectionIdMap));\n      lines.push(``);\n    }\n  }\n\n  // If no changes, add a comment\n  if (lines.length === 2) {\n    lines.push(`  // No changes detected`);\n    lines.push(``);\n  }\n\n  let code = lines.join(\"\\n\");\n\n  // Check if there's already a return statement in the code\n  // If so, skip post-processing to avoid duplicate returns\n  const hasReturnStatement = /return\\s+app\\.(save|delete)\\(/m.test(code);\n\n  if (!hasReturnStatement) {\n    // Find the last app.save() or app.delete() call and make it return the result\n    // Match app.save(...) or app.delete(...) at the end of lines (not in comments or strings)\n    const savePattern = /^(\\s*)app\\.save\\((\\w+)\\);$/gm;\n    const deletePattern = /^(\\s*)app\\.delete\\((\\w+)\\);$/gm;\n\n    const saveMatches = [...code.matchAll(savePattern)];\n    const deleteMatches = [...code.matchAll(deletePattern)];\n\n    // Combine all matches and find the last one by position\n    const allMatches = [\n      ...saveMatches.map((m) => ({ match: m, type: \"save\", index: m.index! })),\n      ...deleteMatches.map((m) => ({ match: m, type: \"delete\", index: m.index! })),\n    ].sort((a, b) => b.index - a.index); // Sort descending to get last match first\n\n    if (allMatches.length > 0) {\n      const lastMatch = allMatches[0];\n      if (lastMatch.type === \"save\") {\n        code =\n          code.substring(0, lastMatch.match.index!) +\n          lastMatch.match[1] +\n          \"return app.save(\" +\n          lastMatch.match[2] +\n          \");\" +\n          code.substring(lastMatch.match.index! + lastMatch.match[0].length);\n      } else {\n        code =\n          code.substring(0, lastMatch.match.index!) +\n          lastMatch.match[1] +\n          \"return app.delete(\" +\n          lastMatch.match[2] +\n          \");\" +\n          code.substring(lastMatch.match.index! + lastMatch.match[0].length);\n      }\n    }\n  }\n\n  return code;\n}\n\n/**\n * Generates the down migration function code\n * Reverts all changes from the diff in reverse order\n *\n * @param diff - Schema diff containing all changes\n * @returns JavaScript code for down migration\n */\nexport function generateDownMigration(diff: SchemaDiff): string {\n  const lines: string[] = [];\n\n  // Add comment header\n  lines.push(`  // DOWN MIGRATION (ROLLBACK)`);\n  lines.push(``);\n\n  // Build collection ID map from collections being created (for rollback)\n  // This map will be used to resolve relation field references\n  const collectionIdMap = new Map<string, string>();\n  for (const collection of diff.collectionsToCreate) {\n    if (collection.id) {\n      collectionIdMap.set(collection.name, collection.id);\n    }\n  }\n  // Also include deleted collections that might have IDs\n  for (const collection of diff.collectionsToDelete) {\n    if (collection.id) {\n      collectionIdMap.set(collection.name, collection.id);\n    }\n  }\n  // Add existing collection IDs from snapshot (for relation fields referencing existing collections)\n  if (diff.existingCollectionIds) {\n    for (const [name, id] of diff.existingCollectionIds) {\n      collectionIdMap.set(name, id);\n    }\n  }\n\n  // Reverse order: delete -> modify -> create\n\n  // 1. Recreate deleted collections\n  if (diff.collectionsToDelete.length > 0) {\n    lines.push(`  // Recreate deleted collections`);\n    for (let i = 0; i < diff.collectionsToDelete.length; i++) {\n      const collection = diff.collectionsToDelete[i];\n      const varName = `collection_${collection.name}_recreate`;\n      lines.push(generateCollectionCreation(collection, varName, false, collectionIdMap));\n      lines.push(``);\n    }\n  }\n\n  // 2. Revert modifications (in reverse order)\n  if (diff.collectionsToModify.length > 0) {\n    lines.push(`  // Revert modifications`);\n    for (const modification of diff.collectionsToModify) {\n      const collectionName = modification.collection;\n\n      // Restore the previous view query (view collections only)\n      if (modification.viewQueryUpdate) {\n        lines.push(`  // Restore the view query of ${collectionName}`);\n        lines.push(\n          generateViewQueryUpdate(\n            collectionName,\n            modification.viewQueryUpdate.oldValue ?? \"\",\n            `collection_${collectionName}_revert_viewQuery`,\n            false,\n            collectionIdMap\n          )\n        );\n        lines.push(``);\n      }\n\n      // Revert permissions (preferred) or rules (fallback)\n      if (modification.permissionsToUpdate && modification.permissionsToUpdate.length > 0) {\n        lines.push(`  // Revert permissions for ${collectionName}`);\n        if (modification.permissionsToUpdate.length >= 2) {\n          const entries = modification.permissionsToUpdate.map((p) => ({ ruleType: p.ruleType, value: p.oldValue }));\n          lines.push(generateGroupedRuleUpdates(collectionName, entries, \"revert_rules\", false, collectionIdMap));\n        } else {\n          const permission = modification.permissionsToUpdate[0];\n          const varName = `collection_${collectionName}_revert_perm_${permission.ruleType}`;\n          lines.push(generatePermissionUpdate(collectionName, permission.ruleType, permission.oldValue, varName, false, collectionIdMap));\n        }\n        lines.push(``);\n      } else if (modification.rulesToUpdate.length > 0) {\n        lines.push(`  // Revert rules for ${collectionName}`);\n        if (modification.rulesToUpdate.length >= 2) {\n          const entries = modification.rulesToUpdate.map((r) => ({ ruleType: r.ruleType, value: r.oldValue }));\n          lines.push(generateGroupedRuleUpdates(collectionName, entries, \"revert_rules\", false, collectionIdMap));\n        } else {\n          const rule = modification.rulesToUpdate[0];\n          const varName = `collection_${collectionName}_revert_rule_${rule.ruleType}`;\n          lines.push(generateRuleUpdate(collectionName, rule.ruleType, rule.oldValue, varName, false, collectionIdMap));\n        }\n        lines.push(``);\n      }\n\n      // Revert index removals (add them back)\n      if (modification.indexesToRemove.length > 0) {\n        lines.push(`  // Restore indexes to ${collectionName}`);\n        for (let i = 0; i < modification.indexesToRemove.length; i++) {\n          const index = modification.indexesToRemove[i];\n          const varName = `collection_${collectionName}_restore_idx_${i}`;\n            lines.push(generateIndexAddition(collectionName, index, varName, false, collectionIdMap));\n          lines.push(``);\n        }\n      }\n\n      // Revert index additions (remove them)\n      if (modification.indexesToAdd.length > 0) {\n        lines.push(`  // Remove indexes from ${collectionName}`);\n        for (let i = 0; i < modification.indexesToAdd.length; i++) {\n          const index = modification.indexesToAdd[i];\n          const varName = `collection_${collectionName}_revert_idx_${i}`;\n            lines.push(generateIndexRemoval(collectionName, index, varName, false, collectionIdMap));\n          lines.push(``);\n        }\n      }\n\n      // Revert field removals (add them back)\n      if (modification.fieldsToRemove.length > 0) {\n        lines.push(`  // Restore fields to ${collectionName}`);\n        for (const field of modification.fieldsToRemove) {\n          const varName = `collection_${collectionName}_restore_${field.name}`;\n          lines.push(generateFieldAddition(collectionName, field, varName, false, collectionIdMap));\n          lines.push(``);\n        }\n      }\n\n      // Revert field modifications\n      if (modification.fieldsToModify.length > 0) {\n        lines.push(`  // Revert field modifications in ${collectionName}`);\n        for (const fieldMod of modification.fieldsToModify) {\n          // Create a reverse modification\n          const reverseChanges = fieldMod.changes.map((change) => ({\n            property: change.property,\n            oldValue: change.newValue,\n            newValue: change.oldValue,\n          }));\n\n          const reverseMod: FieldModification = {\n            fieldName: fieldMod.fieldName,\n            currentDefinition: fieldMod.newDefinition,\n            newDefinition: fieldMod.currentDefinition,\n            changes: reverseChanges,\n          };\n\n          const varName = `collection_${collectionName}_revert_${fieldMod.fieldName}`;\n          lines.push(generateFieldModification(collectionName, reverseMod, varName, false, collectionIdMap));\n          lines.push(``);\n        }\n      }\n\n      // Revert field additions (remove them)\n      if (modification.fieldsToAdd.length > 0) {\n        lines.push(`  // Remove added fields from ${collectionName}`);\n        for (const field of modification.fieldsToAdd) {\n          const varName = `collection_${collectionName}_revert_add_${field.name}`;\n          lines.push(generateFieldDeletion(collectionName, field.name, varName, false, collectionIdMap));\n          lines.push(``);\n        }\n      }\n    }\n  }\n\n  // 3. Delete created collections\n  if (diff.collectionsToCreate.length > 0) {\n    lines.push(`  // Delete created collections`);\n    for (let i = 0; i < diff.collectionsToCreate.length; i++) {\n      const collection = diff.collectionsToCreate[i];\n      const varName = `collection_${collection.name}_rollback`;\n        lines.push(generateCollectionDeletion(collection.name, varName, false, collectionIdMap));\n      lines.push(``);\n    }\n  }\n\n  // If no changes, add a comment\n  if (lines.length === 2) {\n    lines.push(`  // No changes to revert`);\n    lines.push(``);\n  }\n\n  let code = lines.join(\"\\n\");\n\n  // Check if there's already a return statement in the code\n  // If so, skip post-processing to avoid duplicate returns\n  const hasReturnStatement = /return\\s+app\\.(save|delete)\\(/m.test(code);\n\n  if (!hasReturnStatement) {\n    // Find the last app.save() or app.delete() call and make it return the result\n    // Match app.save(...) or app.delete(...) at the end of lines (not in comments or strings)\n    const savePattern = /^(\\s*)app\\.save\\((\\w+)\\);$/gm;\n    const deletePattern = /^(\\s*)app\\.delete\\((\\w+)\\);$/gm;\n\n    const saveMatches = [...code.matchAll(savePattern)];\n    const deleteMatches = [...code.matchAll(deletePattern)];\n\n    // Combine all matches and find the last one by position\n    const allMatches = [\n      ...saveMatches.map((m) => ({ match: m, type: \"save\", index: m.index! })),\n      ...deleteMatches.map((m) => ({ match: m, type: \"delete\", index: m.index! })),\n    ].sort((a, b) => b.index - a.index); // Sort descending to get last match first\n\n    if (allMatches.length > 0) {\n      const lastMatch = allMatches[0];\n      if (lastMatch.type === \"save\") {\n        code =\n          code.substring(0, lastMatch.match.index!) +\n          lastMatch.match[1] +\n          \"return app.save(\" +\n          lastMatch.match[2] +\n          \");\" +\n          code.substring(lastMatch.match.index! + lastMatch.match[0].length);\n      } else {\n        code =\n          code.substring(0, lastMatch.match.index!) +\n          lastMatch.match[1] +\n          \"return app.delete(\" +\n          lastMatch.match[2] +\n          \");\" +\n          code.substring(lastMatch.match.index! + lastMatch.match[0].length);\n      }\n    }\n  }\n\n  return code;\n}\n","import type { CollectionSchema } from \"../types\";\n\n/**\n * Sorts collections based on their relationship dependencies.\n * Collections that are referenced by others should be created first.\n *\n * @param collections - List of collections to sort\n * @returns Sorted list of collections\n */\nexport function sortCollectionsByDependency(collections: CollectionSchema[]): CollectionSchema[] {\n  // Map collection names to schema objects for easy lookup\n  const collectionMap = new Map<string, CollectionSchema>();\n  collections.forEach((col) => collectionMap.set(col.name, col));\n\n  // Build dependency graph\n  // Adjacency list: dependency -> [dependents]\n  // In this graph, an edge A -> B means A must be created before B.\n  const adjList = new Map<string, string[]>();\n  // In-degree: number of dependencies a collection has that are also in the list\n  const inDegree = new Map<string, number>();\n\n  // Initialize graph\n  collections.forEach((col) => {\n    adjList.set(col.name, []);\n    inDegree.set(col.name, 0);\n  });\n\n  // Populate graph\n  collections.forEach((col) => {\n    col.fields.forEach((field) => {\n      // Check if field is a relation\n      if (field.relation) {\n        const targetName = field.relation.collection;\n\n        // We only care about dependencies on collections that are currently being created.\n        // If the target collection is not in the list, it's assumed to already exist.\n        if (collectionMap.has(targetName)) {\n          // If self-reference, ignore for topological sort (creation order doesn't matter strictly,\n          // but usually we want to avoid cycles if possible. Self-ref is cycle size 1).\n          if (targetName === col.name) {\n            return;\n          }\n\n          // Edge: Target -> Collection (Target comes before Collection)\n          adjList.get(targetName)?.push(col.name);\n          inDegree.set(col.name, (inDegree.get(col.name) || 0) + 1);\n        }\n      }\n    });\n  });\n\n  // Kahn's algorithm for topological sort\n  const queue: string[] = [];\n  const sortedResult: CollectionSchema[] = [];\n\n  // Add all nodes with in-degree 0 to queue\n  inDegree.forEach((degree, name) => {\n    if (degree === 0) {\n      queue.push(name);\n    }\n  });\n\n  // Process queue\n  while (queue.length > 0) {\n    const currentName = queue.shift()!;\n    const currentCollection = collectionMap.get(currentName);\n\n    if (currentCollection) {\n      sortedResult.push(currentCollection);\n    }\n\n    const neighbors = adjList.get(currentName) || [];\n    for (const neighbor of neighbors) {\n      inDegree.set(neighbor, (inDegree.get(neighbor) || 0) - 1);\n      if (inDegree.get(neighbor) === 0) {\n        queue.push(neighbor);\n      }\n    }\n  }\n\n  // Check for cycles\n  if (sortedResult.length !== collections.length) {\n    const remainingCount = collections.length - sortedResult.length;\n    console.warn(\n      `Warning: Circular dependencies detected involving ${remainingCount} collections. ` +\n      `Migrations may fail if strict foreign key checks are enabled. ` +\n      `Check your schema for circular relations.`\n    );\n\n    // Append remaining collections (those involved in cycles)\n    // We can't determine a perfect order, so we append them in their original order\n    // (excluding those already sorted)\n    const sortedNames = new Set(sortedResult.map((c) => c.name));\n    collections.forEach((col) => {\n      if (!sortedNames.has(col.name)) {\n        sortedResult.push(col);\n      }\n    });\n  }\n\n  return sortedResult;\n}\n","import type { CollectionOperation, SchemaDiff } from \"../types\";\nimport { sortCollectionsByDependency } from \"../utils/dependency-sorter\";\nimport { type MigrationGeneratorConfig } from \"./config\";\nimport { generateTimestamp } from \"./utils\";\n\n/**\n * Splits a SchemaDiff into individual collection operations\n * Each operation will generate a separate migration file\n *\n * @param diff - Schema diff containing all changes\n * @param baseTimestamp - Base timestamp for the first operation\n * @returns Array of collection operations\n */\nexport function splitDiffByCollection(diff: SchemaDiff, baseTimestamp: string): CollectionOperation[] {\n  const operations: CollectionOperation[] = [];\n  let currentTimestamp = parseInt(baseTimestamp, 10);\n\n  // Split collectionsToCreate into individual operations\n  // Sort collections by dependency to ensure collections are created in the correct order\n  const sortedCollections = sortCollectionsByDependency(diff.collectionsToCreate);\n  for (const collection of sortedCollections) {\n    operations.push({\n      type: \"create\",\n      collection: collection,\n      timestamp: currentTimestamp.toString(),\n    });\n    currentTimestamp += 1; // Increment by 1 second\n  }\n\n  // Split collectionsToModify into individual operations\n  for (const modification of diff.collectionsToModify) {\n    operations.push({\n      type: \"modify\",\n      collection: modification.collection,\n      modifications: modification,\n      timestamp: currentTimestamp.toString(),\n    });\n    currentTimestamp += 1; // Increment by 1 second\n  }\n\n  // Split collectionsToDelete into individual operations\n  for (const collection of diff.collectionsToDelete) {\n    operations.push({\n      type: \"delete\",\n      collection: collection, // Handle both object and string\n      timestamp: currentTimestamp.toString(),\n    });\n    currentTimestamp += 1; // Increment by 1 second\n  }\n\n  return operations;\n}\n\n/**\n * Generates migration filename for a collection operation\n * Format: {timestamp}_{operation}_{collection_name}.js\n *\n * @param operation - Collection operation\n * @returns Migration filename\n */\nexport function generateCollectionMigrationFilename(operation: CollectionOperation): string {\n  const timestamp = operation.timestamp;\n  const operationType = operation.type === \"modify\" ? \"updated\" : operation.type === \"create\" ? \"created\" : \"deleted\";\n\n  // Get collection name\n  let collectionName: string;\n  if (typeof operation.collection === \"string\") {\n    collectionName = operation.collection;\n  } else {\n    collectionName = operation.collection.name;\n  }\n\n  // Sanitize collection name for filename (replace spaces and special chars with underscores)\n  const sanitizedName = collectionName.replace(/[^a-zA-Z0-9_]/g, \"_\");\n\n  return `${timestamp}_${operationType}_${sanitizedName}.js`;\n}\n\n/**\n * Generates a human-readable description from the diff\n * Creates a concise summary of the main changes\n *\n * @param diff - Schema diff containing all changes\n * @returns Description string for filename\n */\nexport function generateMigrationDescription(diff: SchemaDiff): string {\n  const parts: string[] = [];\n\n  // Summarize collection changes\n  if (diff.collectionsToCreate.length > 0) {\n    if (diff.collectionsToCreate.length === 1) {\n      parts.push(`created_${diff.collectionsToCreate[0].name}`);\n    } else {\n      parts.push(`created_${diff.collectionsToCreate.length}_collections`);\n    }\n  }\n\n  if (diff.collectionsToDelete.length > 0) {\n    if (diff.collectionsToDelete.length === 1) {\n      parts.push(`deleted_${diff.collectionsToDelete[0].name}`);\n    } else {\n      parts.push(`deleted_${diff.collectionsToDelete.length}_collections`);\n    }\n  }\n\n  if (diff.collectionsToModify.length > 0) {\n    if (diff.collectionsToModify.length === 1) {\n      parts.push(`updated_${diff.collectionsToModify[0].collection}`);\n    } else {\n      parts.push(`updated_${diff.collectionsToModify.length}_collections`);\n    }\n  }\n\n  // Default description if no changes\n  if (parts.length === 0) {\n    return \"no_changes\";\n  }\n\n  // Join parts with underscores and limit length\n  let description = parts.join(\"_\");\n\n  // Truncate if too long (keep under 100 chars for filename)\n  if (description.length > 80) {\n    description = description.substring(0, 77) + \"...\";\n  }\n\n  return description;\n}\n\n/**\n * Generates the migration filename\n * Format: {timestamp}_{description}.js\n *\n * @param diff - Schema diff containing all changes\n * @param config - Optional configuration\n * @returns Migration filename\n */\nexport function generateMigrationFilename(diff: SchemaDiff, config?: MigrationGeneratorConfig): string {\n  const timestamp = generateTimestamp(config);\n  const description = generateMigrationDescription(diff);\n\n  return `${timestamp}_${description}.js`;\n}\n","/**\n * Migration Generator component\n * Creates PocketBase migration files based on detected differences\n *\n * This module provides a standalone, configurable migration generator that can be used\n * by consumer projects to generate PocketBase-compatible migration files.\n */\n\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport { FileSystemError, MigrationGenerationError } from \"../errors\";\nimport type { CollectionOperation, SchemaDiff } from \"../types\";\nimport { type MigrationGeneratorConfig } from \"./config\";\nimport { createMigrationFileStructure, resolveMigrationDir, writeMigrationFile } from \"./file-writer\";\nimport { generateOperationDownMigration, generateOperationUpMigration } from \"./migrator\";\nimport { generateCollectionMigrationFilename, splitDiffByCollection } from \"./operations\";\nimport { generateTimestamp } from \"./utils\";\n\n// Curated submodule surface — file-writer/config internals (mergeConfig,\n// DEFAULT_CONFIG, generateFindCollectionCode, ...) stay module-private\nexport { type MigrationGeneratorConfig } from \"./config\";\nexport { createMigrationFileStructure, writeMigrationFile } from \"./file-writer\";\nexport { generateFieldDefinitionObject } from \"./fields\";\nexport { generateOperationDownMigration, generateOperationUpMigration } from \"./migrator\";\nexport { generateCollectionMigrationFilename, splitDiffByCollection } from \"./operations\";\nexport { generateCollectionPermissions } from \"./rules\";\n\n/**\n * A migration file that has been generated but not yet written to disk\n */\nexport interface PlannedMigration {\n  /** Filename the migration will be written as */\n  filename: string;\n  /** Complete migration file content */\n  content: string;\n  /** The collection operation this file was generated from */\n  operation: CollectionOperation;\n}\n\n/**\n * Generates migration file contents from a schema diff without writing them\n *\n * Splitting planning from writing lets callers inspect or verify a migration\n * before it lands in the migrations directory — see the engine's\n * `verifyMigrationSources`, which the CLI's `generate --verify` runs over the\n * plan and aborts on.\n *\n * @param diff - Schema diff containing all changes\n * @param config - Migration generator configuration\n * @returns One planned migration per collection operation, in dependency order\n */\nexport function planMigrations(diff: SchemaDiff, config: MigrationGeneratorConfig | string): PlannedMigration[] {\n  // Support legacy string-only parameter (migration directory)\n  const normalizedConfig: MigrationGeneratorConfig = typeof config === \"string\" ? { migrationDir: config } : config;\n\n  try {\n    const migrationDir = resolveMigrationDir(normalizedConfig);\n\n    // Check if there are any changes\n    const hasChanges =\n      diff.collectionsToCreate.length > 0 || diff.collectionsToModify.length > 0 || diff.collectionsToDelete.length > 0;\n\n    // If no changes, return empty array\n    if (!hasChanges) {\n      return [];\n    }\n\n    // Build collection ID map from collections being created\n    const collectionIdMap = new Map<string, string>();\n    for (const collection of diff.collectionsToCreate) {\n      if (collection.id) {\n        collectionIdMap.set(collection.name, collection.id);\n      }\n    }\n    // Also include deleted collections that might have IDs (for rollback)\n    for (const collection of diff.collectionsToDelete) {\n      if (collection.id) {\n        collectionIdMap.set(collection.name, collection.id);\n      }\n    }\n    // Add existing collection IDs from snapshot (for relation fields referencing existing collections)\n    if (diff.existingCollectionIds) {\n      for (const [name, id] of diff.existingCollectionIds) {\n        collectionIdMap.set(name, id);\n      }\n    }\n\n    // Generate base timestamp\n    const baseTimestamp = generateTimestamp(normalizedConfig);\n\n    // Split diff into individual collection operations\n    const operations = splitDiffByCollection(diff, baseTimestamp);\n\n    // Generate migration file for each operation\n    const planned: PlannedMigration[] = [];\n\n    // Read existing files for duplicate check\n    let existingFiles: string[] = [];\n    if (!normalizedConfig.force && fs.existsSync(migrationDir)) {\n      existingFiles = fs\n        .readdirSync(migrationDir)\n        .filter((f) => f.endsWith(\".js\") || f.endsWith(\".ts\"))\n        .map((f) => fs.readFileSync(path.join(migrationDir, f), \"utf-8\"));\n    }\n\n    for (const operation of operations) {\n      // Generate up and down migration code for this operation\n      const upCode = generateOperationUpMigration(operation, collectionIdMap);\n      const downCode = generateOperationDownMigration(operation, collectionIdMap);\n\n      // Create migration file structure\n      const content = createMigrationFileStructure(upCode, downCode, normalizedConfig);\n\n      // Check for duplicates\n      if (!normalizedConfig.force && existingFiles.some((existingContent) => existingContent === content)) {\n        console.warn(\n          `Duplicate migration detected for ${operation.type} ${\n            typeof operation.collection === \"string\" ? operation.collection : operation.collection.name\n          }. Skipping...`\n        );\n        continue;\n      }\n\n      // Generate filename for this operation\n      const filename = generateCollectionMigrationFilename(operation);\n\n      planned.push({ filename, content, operation });\n    }\n\n    return planned;\n  } catch (error) {\n    // If it's already a MigrationGenerationError or FileSystemError, re-throw it\n    if (error instanceof MigrationGenerationError || error instanceof FileSystemError) {\n      throw error;\n    }\n\n    // Otherwise, wrap it in a MigrationGenerationError\n    throw new MigrationGenerationError(\n      `Failed to generate migration: ${error instanceof Error ? error.message : String(error)}`,\n      normalizedConfig.migrationDir,\n      error as Error\n    );\n  }\n}\n\n/**\n * Main generation function\n * Generates migration files from schema diff (one file per collection operation)\n *\n * @param diff - Schema diff containing all changes\n * @param config - Migration generator configuration\n * @returns Array of paths to the generated migration files\n */\nexport function generate(diff: SchemaDiff, config: MigrationGeneratorConfig | string): string[] {\n  const normalizedConfig: MigrationGeneratorConfig = typeof config === \"string\" ? { migrationDir: config } : config;\n  const planned = planMigrations(diff, normalizedConfig);\n\n  if (planned.length === 0) {\n    return [];\n  }\n\n  const migrationDir = resolveMigrationDir(normalizedConfig);\n  return writePlannedMigrations(planned, migrationDir);\n}\n\n/**\n * Writes planned migrations to disk, in order\n *\n * @param planned - Migrations produced by planMigrations()\n * @param migrationDir - Absolute path to the migrations directory\n * @returns Array of paths to the written files\n */\nexport function writePlannedMigrations(planned: PlannedMigration[], migrationDir: string): string[] {\n  return planned.map((migration) => writeMigrationFile(migrationDir, migration.filename, migration.content));\n}\n","/**\n * goja-compatibility lint\n *\n * The engine executes migrations with Node's JavaScript, a superset of the\n * goja dialect PocketBase actually runs. That gap is silent: a migration can\n * replay perfectly here, pass verification, and still fail the moment\n * `pocketbase migrate up` reaches it — because it referenced a Node global,\n * used class fields, or awaited a promise in a runtime with no event loop.\n *\n * This pass closes the gap statically. It parses the file with acorn and\n * reports:\n *\n * - `unknown-global` — a free identifier that is neither declared in the file\n *   nor part of the PocketBase JSVM surface (the sandbox globals) or the\n *   ECMAScript library goja implements. `require`, `process`, `Buffer`,\n *   `fetch`, `setTimeout` all land here.\n * - `unsupported-syntax` — constructs goja's parser rejects: class fields,\n *   private members, static blocks, BigInt literals, `import.meta`.\n * - `module-syntax` — `import`/`export`; migrations are scripts.\n * - `async` — `async`/`await`/`Promise`. goja runs migrations synchronously,\n *   so an awaited promise never settles.\n * - `unsupported-api` — folded in from execution warnings: a call that\n *   resolved to an inert stub did nothing here and will do something (or\n *   throw) in production.\n */\n\nimport * as acorn from \"acorn\";\nimport * as fs from \"fs\";\nimport { buildSandbox } from \"./globals\";\nimport type { EngineWarning } from \"./types\";\n\nexport type GojaLintRule =\n  | \"syntax\"\n  | \"unsupported-syntax\"\n  | \"module-syntax\"\n  | \"async\"\n  | \"unknown-global\"\n  | \"unsupported-api\";\n\nexport type GojaLintSeverity = \"error\" | \"warning\";\n\nexport interface GojaLintFinding {\n  rule: GojaLintRule;\n  severity: GojaLintSeverity;\n  message: string;\n  file?: string;\n  line?: number;\n  column?: number;\n}\n\nexport interface GojaLintResult {\n  file: string;\n  findings: GojaLintFinding[];\n  /** No error-severity findings */\n  ok: boolean;\n}\n\nexport interface GojaLintOptions {\n  /** Path or name used in messages */\n  file?: string;\n  /**\n   * Extra globals to treat as available — for a PocketBase build that\n   * registers its own JSVM bindings.\n   */\n  allowedGlobals?: string[];\n  /**\n   * Engine warnings from executing the same file. `unsupported-api` entries\n   * become findings, which is how a stubbed call gets surfaced prominently\n   * instead of being buried in replay output.\n   */\n  warnings?: EngineWarning[];\n}\n\n/**\n * The ECMAScript library goja implements. Deliberately excludes the ones it\n * does not: BigInt, WeakRef, FinalizationRegistry, Atomics,\n * SharedArrayBuffer, Intl.\n */\nconst ECMASCRIPT_GLOBALS = [\n  \"Array\",\n  \"ArrayBuffer\",\n  \"Boolean\",\n  \"DataView\",\n  \"Date\",\n  \"Error\",\n  \"EvalError\",\n  \"Float32Array\",\n  \"Float64Array\",\n  \"Function\",\n  \"Infinity\",\n  \"Int16Array\",\n  \"Int32Array\",\n  \"Int8Array\",\n  \"JSON\",\n  \"Map\",\n  \"Math\",\n  \"NaN\",\n  \"Number\",\n  \"Object\",\n  \"Proxy\",\n  \"RangeError\",\n  \"ReferenceError\",\n  \"Reflect\",\n  \"RegExp\",\n  \"Set\",\n  \"String\",\n  \"Symbol\",\n  \"SyntaxError\",\n  \"TypeError\",\n  \"URIError\",\n  \"Uint16Array\",\n  \"Uint32Array\",\n  \"Uint8Array\",\n  \"Uint8ClampedArray\",\n  \"WeakMap\",\n  \"WeakSet\",\n  \"decodeURI\",\n  \"decodeURIComponent\",\n  \"encodeURI\",\n  \"encodeURIComponent\",\n  \"escape\",\n  \"eval\",\n  \"globalThis\",\n  \"isFinite\",\n  \"isNaN\",\n  \"parseFloat\",\n  \"parseInt\",\n  \"undefined\",\n  \"unescape\",\n];\n\n/**\n * PocketBase JSVM bindings that exist at runtime but are not part of the\n * simulation's sandbox, so referencing them is valid even though the engine\n * would stub them.\n */\nconst POCKETBASE_GLOBALS = [\n  \"$apis\",\n  \"$tokens\",\n  \"__hooks\",\n  \"arrayOf\",\n  \"readerToString\",\n  \"sleep\",\n  \"toString\",\n  \"Cookie\",\n  \"DynamicModel\",\n  \"FieldsList\",\n  \"MailerMessage\",\n  \"RequestInfo\",\n  \"SubscriptionMessage\",\n  \"ValidationError\",\n];\n\n/**\n * `Promise` is real in goja but useless in a migration: nothing drains the\n * job queue, so a `.then` never runs. Reported by the async rule rather than\n * as an unknown global.\n */\nconst ASYNC_GLOBALS = new Set([\"Promise\"]);\n\n/** Node/browser globals absent from goja, named so the message can say why */\nconst KNOWN_FOREIGN_GLOBALS: Record<string, string> = {\n  Buffer: \"Node.js\",\n  TextDecoder: \"Node.js\",\n  TextEncoder: \"Node.js\",\n  URL: \"Node.js/browser\",\n  URLSearchParams: \"Node.js/browser\",\n  __dirname: \"Node.js (CommonJS)\",\n  __filename: \"Node.js (CommonJS)\",\n  atob: \"browser\",\n  btoa: \"browser\",\n  clearInterval: \"Node.js/browser\",\n  clearTimeout: \"Node.js/browser\",\n  document: \"browser\",\n  exports: \"Node.js (CommonJS)\",\n  fetch: \"Node.js/browser\",\n  global: \"Node.js\",\n  localStorage: \"browser\",\n  module: \"Node.js (CommonJS)\",\n  process: \"Node.js\",\n  queueMicrotask: \"Node.js/browser\",\n  require: \"Node.js (CommonJS)\",\n  setInterval: \"Node.js/browser\",\n  setTimeout: \"Node.js/browser\",\n  structuredClone: \"Node.js/browser\",\n  window: \"browser\",\n};\n\n/** The globals the simulation itself installs — the PocketBase JSVM surface */\nlet sandboxGlobalsCache: string[] | null = null;\n\nfunction sandboxGlobals(): string[] {\n  if (!sandboxGlobalsCache) {\n    const { sandbox } = buildSandbox({}, () => {});\n    sandboxGlobalsCache = Object.keys(sandbox);\n  }\n  return sandboxGlobalsCache;\n}\n\n/** The identifiers a migration may reference without declaring them */\nexport function availableGlobals(extra: string[] = []): Set<string> {\n  return new Set([...ECMASCRIPT_GLOBALS, ...POCKETBASE_GLOBALS, ...sandboxGlobals(), ...extra]);\n}\n\nexport function lintMigrationSource(source: string, options: GojaLintOptions = {}): GojaLintResult {\n  const file = options.file ?? \"<migration>\";\n  const findings: GojaLintFinding[] = [];\n  const at = (node: { loc?: acorn.SourceLocation | null }) => ({\n    file,\n    line: node.loc?.start.line,\n    column: node.loc?.start.column,\n  });\n\n  const parsed = parseForLint(source);\n  if (parsed.kind === \"failed\") {\n    findings.push({\n      rule: \"syntax\",\n      severity: \"error\",\n      message: `Not valid JavaScript: ${parsed.message}`,\n      file,\n      line: parsed.line,\n      column: parsed.column,\n    });\n    return finish(file, findings, options.warnings);\n  }\n\n  if (parsed.kind === \"module\") {\n    findings.push({\n      rule: \"module-syntax\",\n      severity: \"error\",\n      message:\n        \"import/export are not available in PocketBase migrations — they run as scripts in goja, not as ES modules\",\n      file,\n    });\n  }\n\n  if (parsed.kind === \"beyond-target\") {\n    findings.push({\n      rule: \"unsupported-syntax\",\n      severity: \"error\",\n      message: `Syntax beyond what goja parses: ${parsed.message}`,\n      file,\n      line: parsed.line,\n      column: parsed.column,\n    });\n  }\n\n  const program = parsed.program;\n  const declared = collectDeclaredNames(program);\n  const allowed = availableGlobals(options.allowedGlobals);\n\n  walk(program, (node, parent, key) => {\n    switch (node.type) {\n      case \"PropertyDefinition\":\n        findings.push({\n          rule: \"unsupported-syntax\",\n          severity: \"error\",\n          message: \"Class fields are not supported by goja\",\n          ...at(node),\n        });\n        break;\n      case \"PrivateIdentifier\":\n        findings.push({\n          rule: \"unsupported-syntax\",\n          severity: \"error\",\n          message: \"Private class members (#name) are not supported by goja\",\n          ...at(node),\n        });\n        break;\n      case \"StaticBlock\":\n        findings.push({\n          rule: \"unsupported-syntax\",\n          severity: \"error\",\n          message: \"Class static initialization blocks are not supported by goja\",\n          ...at(node),\n        });\n        break;\n      case \"ImportExpression\":\n        findings.push({\n          rule: \"module-syntax\",\n          severity: \"error\",\n          message: \"Dynamic import() is not available in PocketBase migrations\",\n          ...at(node),\n        });\n        break;\n      case \"MetaProperty\":\n        findings.push({\n          rule: \"unsupported-syntax\",\n          severity: \"error\",\n          message: \"import.meta is not available in PocketBase migrations\",\n          ...at(node),\n        });\n        break;\n      case \"AwaitExpression\":\n        findings.push({\n          rule: \"async\",\n          severity: \"error\",\n          message: \"await never settles in PocketBase migrations — goja runs them synchronously\",\n          ...at(node),\n        });\n        break;\n      case \"Literal\":\n        if (typeof (node as acorn.Literal & { bigint?: string }).bigint === \"string\") {\n          findings.push({\n            rule: \"unsupported-syntax\",\n            severity: \"error\",\n            message: \"BigInt literals are not supported by goja\",\n            ...at(node),\n          });\n        }\n        break;\n      case \"FunctionDeclaration\":\n      case \"FunctionExpression\":\n      case \"ArrowFunctionExpression\":\n        if ((node as acorn.Function).async) {\n          findings.push({\n            rule: \"async\",\n            severity: \"error\",\n            message: \"async functions do not work in PocketBase migrations — goja runs them synchronously\",\n            ...at(node),\n          });\n        }\n        break;\n      case \"ForOfStatement\":\n        if ((node as acorn.ForOfStatement).await) {\n          findings.push({\n            rule: \"async\",\n            severity: \"error\",\n            message: \"for await...of is not supported by goja\",\n            ...at(node),\n          });\n        }\n        break;\n      case \"Identifier\": {\n        if (!isReference(parent, key)) {\n          break;\n        }\n        const name = (node as acorn.Identifier).name;\n        if (declared.has(name) || allowed.has(name)) {\n          break;\n        }\n        if (ASYNC_GLOBALS.has(name)) {\n          findings.push({\n            rule: \"async\",\n            severity: \"error\",\n            message: `${name} is unusable in a PocketBase migration — nothing drains the job queue, so callbacks never run`,\n            ...at(node),\n          });\n          break;\n        }\n        const origin = KNOWN_FOREIGN_GLOBALS[name];\n        findings.push({\n          rule: \"unknown-global\",\n          severity: \"error\",\n          message: origin\n            ? `${name} is a ${origin} global and does not exist in PocketBase's JavaScript runtime`\n            : `${name} is not declared in this file and is not part of the PocketBase JSVM surface`,\n          ...at(node),\n        });\n        break;\n      }\n      default:\n        break;\n    }\n  });\n\n  return finish(file, dedupe(findings), options.warnings);\n}\n\nexport function lintMigrationFile(filePath: string, options: GojaLintOptions = {}): GojaLintResult {\n  return lintMigrationSource(fs.readFileSync(filePath, \"utf-8\"), { ...options, file: options.file ?? filePath });\n}\n\nexport function lintMigrationFiles(files: string[], options: GojaLintOptions = {}): GojaLintResult[] {\n  return files.map((file) => lintMigrationFile(file, { ...options, file }));\n}\n\n/** Turns engine execution warnings into findings */\nexport function gojaFindingsFromWarnings(warnings: EngineWarning[] = []): GojaLintFinding[] {\n  return warnings\n    .filter((warning) => warning.kind === \"unsupported-api\")\n    .map((warning) => ({\n      rule: \"unsupported-api\" as const,\n      // The call did nothing in the simulation; in production it does\n      // something the simulation did not model, which is worth reading but\n      // is not by itself a goja incompatibility\n      severity: \"warning\" as const,\n      message: warning.message,\n      file: warning.file,\n    }));\n}\n\nexport function formatGojaLintFinding(finding: GojaLintFinding): string {\n  const location = finding.line !== undefined ? `:${finding.line}:${(finding.column ?? 0) + 1}` : \"\";\n  return `${finding.file ?? \"<migration>\"}${location} [${finding.rule}] ${finding.message}`;\n}\n\n// ---------------------------------------------------------------------------\n// Parsing\n// ---------------------------------------------------------------------------\n\n/**\n * goja's parser tracks ES2022 minus the class-member additions, which the\n * walk reports individually — so parsing at that level yields an AST for\n * almost everything and leaves genuinely newer syntax to fail here.\n */\nconst GOJA_ECMA_VERSION = 2022;\n\ntype ParseOutcome =\n  | {\n      kind: \"script\" | \"module\" | \"beyond-target\";\n      program: acorn.Program;\n      message?: string;\n      line?: number;\n      column?: number;\n    }\n  | { kind: \"failed\"; message: string; line?: number; column?: number };\n\nfunction parseForLint(source: string): ParseOutcome {\n  const base: acorn.Options = { ecmaVersion: GOJA_ECMA_VERSION, locations: true, allowHashBang: true };\n\n  try {\n    return { kind: \"script\", program: acorn.parse(source, { ...base, sourceType: \"script\" }) };\n  } catch (scriptError) {\n    // import/export only parse as a module — reporting that specifically is\n    // far more useful than \"unexpected token\"\n    try {\n      return { kind: \"module\", program: acorn.parse(source, { ...base, sourceType: \"module\" }) };\n    } catch {\n      // Fall through: not a module problem\n    }\n\n    try {\n      const program = acorn.parse(source, { ecmaVersion: \"latest\", locations: true, sourceType: \"script\" });\n      return { kind: \"beyond-target\", program, ...describeParseError(scriptError) };\n    } catch (latestError) {\n      return { kind: \"failed\", ...describeParseError(latestError) };\n    }\n  }\n}\n\nfunction describeParseError(error: unknown): { message: string; line?: number; column?: number } {\n  const syntaxError = error as { message?: string; loc?: { line: number; column: number } };\n  return {\n    message: syntaxError?.message ?? String(error),\n    line: syntaxError?.loc?.line,\n    column: syntaxError?.loc?.column,\n  };\n}\n\n// ---------------------------------------------------------------------------\n// AST traversal\n// ---------------------------------------------------------------------------\n\ntype AnyNode = acorn.Node & Record<string, any>;\n\nfunction walk(node: AnyNode, visit: (node: AnyNode, parent: AnyNode | null, key: string | null) => void): void {\n  const stack: { node: AnyNode; parent: AnyNode | null; key: string | null }[] = [{ node, parent: null, key: null }];\n\n  while (stack.length > 0) {\n    const current = stack.pop()!;\n    visit(current.node, current.parent, current.key);\n\n    for (const [key, value] of Object.entries(current.node)) {\n      if (key === \"loc\" || key === \"range\" || value === null || typeof value !== \"object\") {\n        continue;\n      }\n      if (Array.isArray(value)) {\n        for (const entry of value) {\n          if (isNode(entry)) {\n            stack.push({ node: entry, parent: current.node, key });\n          }\n        }\n        continue;\n      }\n      if (isNode(value)) {\n        stack.push({ node: value, parent: current.node, key });\n      }\n    }\n  }\n}\n\nfunction isNode(value: unknown): value is AnyNode {\n  return typeof value === \"object\" && value !== null && typeof (value as AnyNode).type === \"string\";\n}\n\n/**\n * Whether an Identifier is a variable reference rather than a name in some\n * other position — a non-computed property, an object key, a label.\n */\nfunction isReference(parent: AnyNode | null, key: string | null): boolean {\n  if (!parent) {\n    return true;\n  }\n\n  switch (parent.type) {\n    case \"MemberExpression\":\n      return key !== \"property\" || parent.computed === true;\n    case \"Property\":\n      return key !== \"key\" || parent.computed === true;\n    case \"MethodDefinition\":\n    case \"PropertyDefinition\":\n      return key !== \"key\" || parent.computed === true;\n    case \"LabeledStatement\":\n    case \"BreakStatement\":\n    case \"ContinueStatement\":\n      return key !== \"label\";\n    case \"ExportSpecifier\":\n    case \"ImportSpecifier\":\n      return false;\n    default:\n      return true;\n  }\n}\n\n/**\n * Every name bound anywhere in the file.\n *\n * Scopes are deliberately collapsed: over-approximating what is declared\n * cannot produce a false \"unknown global\", and the alternative — a scope\n * chain — would only matter for a migration that shadows a global in one\n * function and expects the real one in another.\n */\nfunction collectDeclaredNames(program: acorn.Program): Set<string> {\n  const names = new Set<string>();\n\n  const bindPattern = (pattern: AnyNode | null | undefined): void => {\n    if (!pattern) {\n      return;\n    }\n    switch (pattern.type) {\n      case \"Identifier\":\n        names.add(pattern.name);\n        break;\n      case \"ObjectPattern\":\n        for (const property of pattern.properties ?? []) {\n          bindPattern(property.type === \"RestElement\" ? property.argument : property.value);\n        }\n        break;\n      case \"ArrayPattern\":\n        for (const element of pattern.elements ?? []) {\n          bindPattern(element);\n        }\n        break;\n      case \"AssignmentPattern\":\n        bindPattern(pattern.left);\n        break;\n      case \"RestElement\":\n        bindPattern(pattern.argument);\n        break;\n      default:\n        break;\n    }\n  };\n\n  walk(program as AnyNode, (node) => {\n    switch (node.type) {\n      case \"VariableDeclarator\":\n        bindPattern(node.id);\n        break;\n      case \"FunctionDeclaration\":\n      case \"FunctionExpression\":\n      case \"ArrowFunctionExpression\":\n        bindPattern(node.id);\n        for (const param of node.params ?? []) {\n          bindPattern(param);\n        }\n        break;\n      case \"ClassDeclaration\":\n      case \"ClassExpression\":\n        bindPattern(node.id);\n        break;\n      case \"CatchClause\":\n        bindPattern(node.param);\n        break;\n      case \"ImportDefaultSpecifier\":\n      case \"ImportNamespaceSpecifier\":\n      case \"ImportSpecifier\":\n        bindPattern(node.local);\n        break;\n      default:\n        break;\n    }\n  });\n\n  return names;\n}\n\n/**\n * One finding per issue. A missing global is usually referenced many times;\n * reporting it once, at its first use, is what a reader needs. Syntax\n * findings keep their location, because each occurrence is a separate edit.\n */\nfunction dedupe(findings: GojaLintFinding[]): GojaLintFinding[] {\n  const seen = new Set<string>();\n  const unique: GojaLintFinding[] = [];\n  const collapsedRules = new Set<GojaLintRule>([\"unknown-global\", \"async\"]);\n\n  // Sorted before collapsing so a rule reported once keeps its earliest use;\n  // the AST walk does not visit nodes in source order\n  const ordered = [...findings].sort((a, b) => (a.line ?? 0) - (b.line ?? 0) || (a.column ?? 0) - (b.column ?? 0));\n\n  for (const finding of ordered) {\n    const key = collapsedRules.has(finding.rule)\n      ? `${finding.rule}|${finding.message}`\n      : `${finding.rule}|${finding.message}|${finding.line ?? \"\"}|${finding.column ?? \"\"}`;\n    if (seen.has(key)) {\n      continue;\n    }\n    seen.add(key);\n    unique.push(finding);\n  }\n\n  return unique;\n}\n\nfunction finish(file: string, findings: GojaLintFinding[], warnings?: EngineWarning[]): GojaLintResult {\n  const all = [...findings, ...gojaFindingsFromWarnings(warnings)];\n  return { file, findings: all, ok: all.every((finding) => finding.severity !== \"error\") };\n}\n","/**\n * Structural comparison of two engine states\n *\n * Down-migration verification asks one question — \"is the state after\n * up() + down() the state we started from?\" — and needs an answer precise\n * enough to name what drifted. This compares the raw PocketBase-shaped\n * collections of two stores directly, rather than routing through the diff\n * engine, because a rollback that leaves the schema semantically equal but\n * structurally different (a restored field carrying a different id, an index\n * re-added in a different form) is exactly the kind of drift verification\n * exists to catch.\n *\n * Normalization is limited to differences PocketBase itself does not\n * distinguish:\n *\n * - An option a migration never declared and one set to its Go zero value\n *   (`\"\"`, `0`, `false`, `[]`, `null`) express the same constraint, so an\n *   absent key equals a zero-valued one. Two *declared* values are always\n *   compared (`min: 0` vs `min: 5` is a real difference).\n * - API rules are exempt from that rule: `null` (superuser only) and `\"\"`\n *   (public) are different permissions, so only absent ≡ `null` holds.\n * - Index order is not meaningful; index lists are compared as sets.\n * - Field order is not compared unless `strictFieldOrder` is set.\n */\n\nimport type { CollectionStore } from \"./store\";\nimport type { RawCollection } from \"./types\";\n\nexport interface StateDifference {\n  kind:\n    | \"collection-added\"\n    | \"collection-removed\"\n    | \"collection-property\"\n    | \"field-added\"\n    | \"field-removed\"\n    | \"field-property\"\n    | \"field-order\"\n    | \"indexes\";\n  /** Collection name (baseline name when the collection exists on both sides) */\n  collection: string;\n  field?: string;\n  property?: string;\n  expected?: unknown;\n  actual?: unknown;\n  /** Human-readable one-liner, suitable for CLI output */\n  message: string;\n}\n\nexport interface StateCompareOptions {\n  /**\n   * Collection and field properties to skip.\n   * Defaults to PocketBase's own bookkeeping timestamps.\n   */\n  ignoreKeys?: string[];\n  /** Also compare the position of each field within its collection */\n  strictFieldOrder?: boolean;\n  /** Labels used in messages; defaults to \"baseline\" / \"actual\" */\n  labels?: { expected: string; actual: string };\n}\n\nconst DEFAULT_IGNORED_KEYS = [\"created\", \"updated\"];\n\n/** Rules where absent means \"superuser only\" and \"\" means \"public\" */\nconst RULE_KEYS = new Set([\"listRule\", \"viewRule\", \"createRule\", \"updateRule\", \"deleteRule\", \"manageRule\", \"authRule\"]);\n\n/** Handled structurally rather than as plain properties */\nconst STRUCTURAL_KEYS = new Set([\"fields\", \"indexes\"]);\n\n/**\n * Compares two stores. An empty result means the two states are the same\n * schema; every entry names one concrete divergence.\n */\nexport function compareStores(\n  expected: CollectionStore,\n  actual: CollectionStore,\n  options: StateCompareOptions = {}\n): StateDifference[] {\n  return compareRawCollections(expected.serialize(), actual.serialize(), options);\n}\n\nexport function compareRawCollections(\n  expected: RawCollection[],\n  actual: RawCollection[],\n  options: StateCompareOptions = {}\n): StateDifference[] {\n  const ignored = new Set(options.ignoreKeys ?? DEFAULT_IGNORED_KEYS);\n  const labels = options.labels ?? { expected: \"baseline\", actual: \"actual\" };\n  const differences: StateDifference[] = [];\n\n  const remaining = [...actual];\n  const matched = new Map<RawCollection, RawCollection>();\n\n  for (const expectedCollection of expected) {\n    const index = findCollectionIndex(remaining, expectedCollection);\n    if (index === -1) {\n      differences.push({\n        kind: \"collection-removed\",\n        collection: collectionLabel(expectedCollection),\n        message: `collection \"${collectionLabel(expectedCollection)}\" is missing from ${labels.actual}`,\n      });\n      continue;\n    }\n    matched.set(expectedCollection, remaining[index]);\n    remaining.splice(index, 1);\n  }\n\n  for (const extra of remaining) {\n    differences.push({\n      kind: \"collection-added\",\n      collection: collectionLabel(extra),\n      message: `collection \"${collectionLabel(extra)}\" exists in ${labels.actual} but not in ${labels.expected}`,\n    });\n  }\n\n  for (const [expectedCollection, actualCollection] of matched) {\n    differences.push(...compareCollection(expectedCollection, actualCollection, ignored, options, labels));\n  }\n\n  return differences;\n}\n\n/** One line per difference, e.g. for CLI output */\nexport function describeStateDifferences(differences: StateDifference[]): string[] {\n  return differences.map((difference) => difference.message);\n}\n\nfunction compareCollection(\n  expected: RawCollection,\n  actual: RawCollection,\n  ignored: Set<string>,\n  options: StateCompareOptions,\n  labels: { expected: string; actual: string }\n): StateDifference[] {\n  const differences: StateDifference[] = [];\n  const name = collectionLabel(expected);\n\n  for (const key of unionKeys(expected, actual)) {\n    if (ignored.has(key) || STRUCTURAL_KEYS.has(key)) {\n      continue;\n    }\n    if (valuesAgree(key, expected[key], actual[key])) {\n      continue;\n    }\n    differences.push({\n      kind: \"collection-property\",\n      collection: name,\n      property: key,\n      expected: expected[key],\n      actual: actual[key],\n      message:\n        `[${name}] ${key} differs (${labels.expected}=${format(expected[key])}, ` +\n        `${labels.actual}=${format(actual[key])})`,\n    });\n  }\n\n  differences.push(...compareFields(name, expected, actual, ignored, options, labels));\n  differences.push(...compareIndexes(name, expected, actual, labels));\n\n  return differences;\n}\n\nfunction compareFields(\n  collection: string,\n  expected: RawCollection,\n  actual: RawCollection,\n  ignored: Set<string>,\n  options: StateCompareOptions,\n  labels: { expected: string; actual: string }\n): StateDifference[] {\n  const differences: StateDifference[] = [];\n  const expectedFields: RawCollection[] = Array.isArray(expected.fields) ? expected.fields : [];\n  const actualFields: RawCollection[] = Array.isArray(actual.fields) ? actual.fields : [];\n\n  const actualByName = new Map<string, RawCollection>();\n  for (const field of actualFields) {\n    actualByName.set(String(field?.name ?? \"\"), field);\n  }\n\n  for (const expectedField of expectedFields) {\n    const fieldName = String(expectedField?.name ?? \"\");\n    const actualField = actualByName.get(fieldName);\n\n    if (!actualField) {\n      differences.push({\n        kind: \"field-removed\",\n        collection,\n        field: fieldName,\n        message: `[${collection}] field \"${fieldName}\" is missing from ${labels.actual}`,\n      });\n      continue;\n    }\n\n    for (const key of unionKeys(expectedField, actualField)) {\n      if (ignored.has(key)) {\n        continue;\n      }\n      if (valuesAgree(key, expectedField[key], actualField[key])) {\n        continue;\n      }\n      differences.push({\n        kind: \"field-property\",\n        collection,\n        field: fieldName,\n        property: key,\n        expected: expectedField[key],\n        actual: actualField[key],\n        message:\n          `[${collection}] field \"${fieldName}\" ${key} differs ` +\n          `(${labels.expected}=${format(expectedField[key])}, ${labels.actual}=${format(actualField[key])})`,\n      });\n    }\n  }\n\n  const expectedNames = new Set(expectedFields.map((field) => String(field?.name ?? \"\")));\n  for (const actualField of actualFields) {\n    const fieldName = String(actualField?.name ?? \"\");\n    if (!expectedNames.has(fieldName)) {\n      differences.push({\n        kind: \"field-added\",\n        collection,\n        field: fieldName,\n        message: `[${collection}] field \"${fieldName}\" exists in ${labels.actual} but not in ${labels.expected}`,\n      });\n    }\n  }\n\n  if (options.strictFieldOrder) {\n    const expectedOrder = expectedFields.map((field) => String(field?.name ?? \"\"));\n    const actualOrder = actualFields.map((field) => String(field?.name ?? \"\"));\n    if (expectedOrder.length === actualOrder.length && !arraysEqual(expectedOrder, actualOrder)) {\n      differences.push({\n        kind: \"field-order\",\n        collection,\n        expected: expectedOrder,\n        actual: actualOrder,\n        message:\n          `[${collection}] field order differs (${labels.expected}=${expectedOrder.join(\", \")}, ` +\n          `${labels.actual}=${actualOrder.join(\", \")})`,\n      });\n    }\n  }\n\n  return differences;\n}\n\nfunction compareIndexes(\n  collection: string,\n  expected: RawCollection,\n  actual: RawCollection,\n  labels: { expected: string; actual: string }\n): StateDifference[] {\n  const expectedIndexes = normalizeIndexes(expected.indexes);\n  const actualIndexes = normalizeIndexes(actual.indexes);\n  const differences: StateDifference[] = [];\n\n  for (const index of expectedIndexes) {\n    if (!actualIndexes.includes(index)) {\n      differences.push({\n        kind: \"indexes\",\n        collection,\n        expected: index,\n        message: `[${collection}] index missing from ${labels.actual}: ${index}`,\n      });\n    }\n  }\n  for (const index of actualIndexes) {\n    if (!expectedIndexes.includes(index)) {\n      differences.push({\n        kind: \"indexes\",\n        collection,\n        actual: index,\n        message: `[${collection}] index only in ${labels.actual}: ${index}`,\n      });\n    }\n  }\n\n  return differences;\n}\n\nfunction findCollectionIndex(candidates: RawCollection[], target: RawCollection): number {\n  const byId = candidates.findIndex((candidate) => candidate.id && candidate.id === target.id);\n  if (byId !== -1) {\n    return byId;\n  }\n  return candidates.findIndex((candidate) => candidate.name && candidate.name === target.name);\n}\n\nfunction collectionLabel(collection: RawCollection): string {\n  return String(collection?.name || collection?.id || \"<unnamed>\");\n}\n\nfunction unionKeys(left: RawCollection, right: RawCollection): string[] {\n  return [...new Set([...Object.keys(left ?? {}), ...Object.keys(right ?? {})])];\n}\n\n/**\n * Whether two values for the same property describe the same thing —\n * see the normalization rules in the module comment.\n */\nfunction valuesAgree(key: string, expected: unknown, actual: unknown): boolean {\n  if (RULE_KEYS.has(key)) {\n    return deepEqual(expected ?? null, actual ?? null);\n  }\n  if (expected === undefined || actual === undefined) {\n    return isUnset(expected) && isUnset(actual);\n  }\n  return deepEqual(expected, actual);\n}\n\n/** Values that carry no constraint; an undeclared option means the same */\nfunction isUnset(value: unknown): boolean {\n  return (\n    value === undefined ||\n    value === null ||\n    value === \"\" ||\n    value === 0 ||\n    value === false ||\n    (Array.isArray(value) && value.length === 0)\n  );\n}\n\nfunction normalizeIndexes(indexes: unknown): string[] {\n  if (!Array.isArray(indexes)) {\n    return [];\n  }\n  return indexes.map((index) => String(index).replace(/\\s+/g, \" \").trim());\n}\n\nfunction arraysEqual(left: string[], right: string[]): boolean {\n  return left.length === right.length && left.every((value, index) => value === right[index]);\n}\n\nfunction deepEqual(left: unknown, right: unknown): boolean {\n  if (left === right) {\n    return true;\n  }\n  if (Array.isArray(left) && Array.isArray(right)) {\n    return left.length === right.length && left.every((value, index) => deepEqual(value, right[index]));\n  }\n  if (left && right && typeof left === \"object\" && typeof right === \"object\") {\n    const leftKeys = Object.keys(left as object);\n    const rightKeys = Object.keys(right as object);\n    if (leftKeys.length !== rightKeys.length) {\n      return false;\n    }\n    return leftKeys.every((key) =>\n      deepEqual((left as Record<string, unknown>)[key], (right as Record<string, unknown>)[key])\n    );\n  }\n  return false;\n}\n\nfunction format(value: unknown): string {\n  if (value === undefined) {\n    return \"unset\";\n  }\n  try {\n    return JSON.stringify(value) ?? String(value);\n  } catch {\n    return String(value);\n  }\n}\n","/**\n * Down-migration verification\n *\n * A generated `down()` is never exercised by state reconstruction — the\n * replayer only runs `up()` — so a rollback that does not actually roll back\n * stays invisible until someone runs `pocketbase migrate down` in anger.\n * This module closes that gap: for each migration it executes `up()` against\n * a baseline, then `down()` against the result, and asserts the state came\n * back to the baseline.\n *\n * `down()` runs from a fresh evaluation of the file, the way PocketBase runs\n * it — a separate invocation that cannot observe anything `up()` left in the\n * file's module scope.\n *\n * Failures are returned, not thrown: a verification pass reports on every\n * migration it was given, and the caller decides whether an unreversible\n * migration is fatal.\n */\n\nimport * as fs from \"fs\";\nimport { MigrationExecutionError } from \"../errors\";\nimport { executeMigrationDownSource, executeMigrationSource } from \"./runner\";\nimport { compareStores, type StateCompareOptions, type StateDifference } from \"./state-compare\";\nimport { CollectionStore } from \"./store\";\nimport type { EngineOptions, EngineWarning, MigrationDirection } from \"./types\";\n\nexport interface MigrationSourceRef {\n  source: string;\n  /** Path or name used in messages */\n  file?: string;\n}\n\nexport interface MigrationRoundTripResult {\n  file: string;\n  /** The file registered an up() closure and it committed */\n  upApplied: boolean;\n  /** The file registered a down() closure and it committed */\n  downApplied: boolean;\n  /** up() changed the state but the file has no down() to undo it */\n  missingDown: boolean;\n  /** up() followed by down() returned to the baseline */\n  reversible: boolean;\n  /** What the rollback failed to restore (empty when reversible) */\n  differences: StateDifference[];\n  warnings: EngineWarning[];\n  /** Set when a phase failed to execute at all */\n  error?: { phase: MigrationDirection | \"evaluate\"; message: string };\n  /** State after up() — what the next migration in a sequence starts from */\n  storeAfterUp: CollectionStore;\n}\n\nexport interface MigrationVerificationReport {\n  results: MigrationRoundTripResult[];\n  /** Every migration executed and reversed cleanly */\n  ok: boolean;\n  /** State after every up() — the state the migrations leave behind */\n  store: CollectionStore;\n  /** Only the results that failed, in input order */\n  failures: MigrationRoundTripResult[];\n}\n\nexport interface VerifyOptions extends EngineOptions {\n  /** State the first migration is applied to. Defaults to an empty store. */\n  initialStore?: CollectionStore;\n  /** Forwarded to the state comparison */\n  compare?: StateCompareOptions;\n}\n\n/**\n * Verifies one migration against a baseline. The baseline store is left\n * untouched; the state after up() is returned on the result.\n */\nexport function verifyMigrationRoundTrip(\n  migration: MigrationSourceRef,\n  baseline: CollectionStore = new CollectionStore(),\n  options: VerifyOptions = {}\n): MigrationRoundTripResult {\n  const { initialStore: _initialStore, compare: compareOptions, ...engineOptions } = options;\n  const file = migration.file ?? \"<migration>\";\n  const warnings: EngineWarning[] = [];\n\n  const afterUp = baseline.clone();\n  let upApplied = false;\n  try {\n    const upResult = executeMigrationSource(migration.source, afterUp, { ...engineOptions, filename: file });\n    upApplied = upResult.applied;\n    warnings.push(...upResult.warnings);\n  } catch (error) {\n    return {\n      file,\n      upApplied: false,\n      downApplied: false,\n      missingDown: false,\n      reversible: false,\n      differences: [],\n      warnings,\n      error: toPhaseError(error, \"up\"),\n      // up() is transactional: a failure leaves the baseline state intact\n      storeAfterUp: baseline.clone(),\n    };\n  }\n\n  const afterDown = afterUp.clone();\n  let downApplied = false;\n  try {\n    const downResult = executeMigrationDownSource(migration.source, afterDown, { ...engineOptions, filename: file });\n    downApplied = downResult.applied;\n    warnings.push(...downResult.warnings);\n  } catch (error) {\n    return {\n      file,\n      upApplied,\n      downApplied: false,\n      missingDown: false,\n      reversible: false,\n      differences: [],\n      warnings,\n      error: toPhaseError(error, \"down\"),\n      storeAfterUp: afterUp,\n    };\n  }\n\n  const differences = compareStores(baseline, afterDown, {\n    labels: { expected: \"pre-migration state\", actual: \"state after down()\" },\n    ...compareOptions,\n  });\n\n  return {\n    file,\n    upApplied,\n    downApplied,\n    // A file with no down() is only a problem if up() actually changed\n    // something — which the differences below will show\n    missingDown: upApplied && !downApplied,\n    reversible: differences.length === 0,\n    differences,\n    warnings,\n    storeAfterUp: afterUp,\n  };\n}\n\nexport function verifyMigrationFileRoundTrip(\n  filePath: string,\n  baseline: CollectionStore = new CollectionStore(),\n  options: VerifyOptions = {}\n): MigrationRoundTripResult {\n  return verifyMigrationRoundTrip({ source: fs.readFileSync(filePath, \"utf-8\"), file: filePath }, baseline, options);\n}\n\n/**\n * Verifies a sequence of migrations the way they will be applied: each one\n * is round-tripped against the state its predecessors leave behind, and its\n * up() is then committed before moving on.\n */\nexport function verifyMigrationSources(\n  migrations: MigrationSourceRef[],\n  options: VerifyOptions = {}\n): MigrationVerificationReport {\n  let store = options.initialStore ?? new CollectionStore();\n  const results: MigrationRoundTripResult[] = [];\n\n  for (const migration of migrations) {\n    const result = verifyMigrationRoundTrip(migration, store, options);\n    results.push(result);\n    store = result.storeAfterUp;\n\n    // Continuing past a migration that could not be applied would verify\n    // every later migration against a state that will never exist\n    if (result.error?.phase === \"up\" || result.error?.phase === \"evaluate\") {\n      break;\n    }\n  }\n\n  const failures = results.filter((result) => !result.reversible || result.error !== undefined);\n\n  return { results, ok: failures.length === 0, store, failures };\n}\n\nexport function verifyMigrationFiles(files: string[], options: VerifyOptions = {}): MigrationVerificationReport {\n  return verifyMigrationSources(\n    files.map((file) => ({ source: fs.readFileSync(file, \"utf-8\"), file })),\n    options\n  );\n}\n\nfunction toPhaseError(error: unknown, fallbackPhase: MigrationDirection): MigrationRoundTripResult[\"error\"] {\n  if (error instanceof MigrationExecutionError) {\n    return { phase: error.phase ?? fallbackPhase, message: error.message };\n  }\n  return { phase: fallbackPhase, message: error instanceof Error ? error.message : String(error) };\n}\n","/**\n * Configuration loader for migration tool\n * Handles loading and merging configuration from various sources\n */\n\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport { defaultDataDirectory } from \"../../migration/engine/applied-migrations.js\";\nimport { ConfigurationError } from \"../../migration/errors.js\";\n\n/**\n * Migration tool configuration\n */\nexport interface MigrationConfig {\n  schema: {\n    directory: string;\n    exclude: string[];\n  };\n  migrations: {\n    directory: string;\n    format: string;\n    /**\n     * Whether `generate` executes each new migration's up() and down() in the\n     * simulation before writing it, and refuses to write one that does not\n     * roll back cleanly. Off by default.\n     */\n    verify: boolean;\n    /**\n     * PocketBase's data directory (or a data.db file), used to read the\n     * `_migrations` table so replay can stop at what has actually been\n     * applied. Empty means \"the pb_data directory next to the migrations\n     * directory\".\n     */\n    dataDirectory: string;\n  };\n  diff: {\n    warnOnDelete: boolean;\n    requireForceForDestructive: boolean;\n  };\n  typeGen: {\n    outPath: string;\n  };\n}\n\n/**\n * Partial configuration for merging\n */\nexport type PartialMigrationConfig = {\n  schema?: Partial<MigrationConfig[\"schema\"]>;\n  migrations?: Partial<MigrationConfig[\"migrations\"]>;\n  diff?: Partial<MigrationConfig[\"diff\"]>;\n  typeGen?: Partial<MigrationConfig[\"typeGen\"]>;\n};\n\n/**\n * Configuration file names to search for\n */\nconst CONFIG_FILE_NAMES = [\n  \"pocketbase-migrate.config.js\",\n  \"pocketbase-migrate.config.mjs\",\n  \"pocketbase-migrate.config.json\",\n  \"migrate.config.js\",\n  \"migrate.config.mjs\",\n  \"migrate.config.json\",\n];\n\n/**\n * Default configuration values\n */\nconst DEFAULT_CONFIG: MigrationConfig = {\n  schema: {\n    directory: \"src/schema\",\n    exclude: [\"base.ts\", \"index.ts\", \"permissions.ts\", \"permission-templates.ts\"],\n  },\n  migrations: {\n    directory: \"pocketbase/pb_migrations\",\n    format: \"timestamp_description\",\n    verify: false,\n    dataDirectory: \"\",\n  },\n  diff: {\n    warnOnDelete: true,\n    requireForceForDestructive: true,\n  },\n  typeGen: {\n    outPath: \"pocketbase-types.ts\",\n  },\n};\n\n/**\n * Finds a configuration file in the given directory\n */\nfunction findConfigFile(directory: string): string | null {\n  for (const fileName of CONFIG_FILE_NAMES) {\n    const filePath = path.join(directory, fileName);\n    if (fs.existsSync(filePath)) {\n      return filePath;\n    }\n  }\n  return null;\n}\n\n/**\n * Loads configuration from a JSON file\n */\nfunction loadJsonConfig(configPath: string): PartialMigrationConfig {\n  try {\n    const content = fs.readFileSync(configPath, \"utf-8\");\n    return JSON.parse(content);\n  } catch (error) {\n    if (error instanceof SyntaxError) {\n      throw new ConfigurationError(\"Invalid JSON syntax in configuration file\", configPath, undefined, error);\n    }\n    throw new ConfigurationError(\n      \"Failed to read configuration file\",\n      configPath,\n      undefined,\n      error instanceof Error ? error : undefined\n    );\n  }\n}\n\n/**\n * Loads configuration from a JavaScript file\n */\nasync function loadJsConfig(configPath: string): Promise<PartialMigrationConfig> {\n  try {\n    const fileUrl = `file://${configPath}`;\n    const module = await import(fileUrl);\n    return module.default || module;\n  } catch (error) {\n    throw new ConfigurationError(\n      \"Failed to load JavaScript configuration file\",\n      configPath,\n      undefined,\n      error instanceof Error ? error : undefined\n    );\n  }\n}\n\n/**\n * Loads configuration from file if it exists\n */\nasync function loadConfigFile(configPath: string): Promise<PartialMigrationConfig | null> {\n  if (!fs.existsSync(configPath)) {\n    return null;\n  }\n\n  const ext = path.extname(configPath).toLowerCase();\n\n  if (ext === \".json\") {\n    return loadJsonConfig(configPath);\n  } else if (ext === \".js\" || ext === \".mjs\") {\n    return loadJsConfig(configPath);\n  } else {\n    throw new ConfigurationError(`Unsupported configuration file format: ${ext}`, configPath, undefined);\n  }\n}\n\n/**\n * Merges configuration objects with deep merge\n */\nfunction mergeConfig(base: MigrationConfig, override: PartialMigrationConfig): MigrationConfig {\n  return {\n    schema: { ...base.schema, ...override.schema },\n    migrations: { ...base.migrations, ...override.migrations },\n    diff: { ...base.diff, ...override.diff },\n    typeGen: { ...base.typeGen, ...override.typeGen },\n  };\n}\n\n/**\n * Loads configuration from environment variables\n */\nfunction loadConfigFromEnv(): PartialMigrationConfig {\n  const config: PartialMigrationConfig = {};\n\n  if (process.env.MIGRATION_SCHEMA_DIR) {\n    config.schema = { directory: process.env.MIGRATION_SCHEMA_DIR };\n  }\n\n  if (process.env.MIGRATION_SCHEMA_EXCLUDE) {\n    config.schema = {\n      ...config.schema,\n      exclude: process.env.MIGRATION_SCHEMA_EXCLUDE.split(\",\").map((s) => s.trim()),\n    };\n  }\n\n  if (process.env.MIGRATION_OUTPUT_DIR) {\n    config.migrations = { directory: process.env.MIGRATION_OUTPUT_DIR };\n  }\n\n  if (process.env.MIGRATION_VERIFY !== undefined) {\n    config.migrations = {\n      ...config.migrations,\n      verify: process.env.MIGRATION_VERIFY === \"true\",\n    };\n  }\n\n  if (process.env.MIGRATION_DATA_DIR) {\n    config.migrations = {\n      ...config.migrations,\n      dataDirectory: process.env.MIGRATION_DATA_DIR,\n    };\n  }\n\n  if (process.env.MIGRATION_REQUIRE_FORCE !== undefined) {\n    config.diff = { requireForceForDestructive: process.env.MIGRATION_REQUIRE_FORCE === \"true\" };\n  }\n\n  return config;\n}\n\n/**\n * Loads configuration from CLI arguments\n */\nexport function loadConfigFromArgs(options: any): PartialMigrationConfig {\n  const config: PartialMigrationConfig = {};\n\n  if (options.output) {\n    config.migrations = { directory: options.output };\n  }\n\n  if (options.schemaDir) {\n    config.schema = { directory: options.schemaDir };\n  }\n\n  if (options.pbData) {\n    config.migrations = { ...config.migrations, dataDirectory: options.pbData };\n  }\n\n  // Commander sets verify to false for --no-verify, so only an explicit\n  // boolean overrides the config file\n  if (typeof options.verify === \"boolean\") {\n    config.migrations = { ...config.migrations, verify: options.verify };\n  }\n\n  return config;\n}\n\n/**\n * Validates configuration values\n */\nfunction validateConfig(config: MigrationConfig, configPath?: string): void {\n  const invalidFields: string[] = [];\n\n  if (typeof config.schema.directory !== \"string\" || config.schema.directory.trim() === \"\") {\n    invalidFields.push(\"schema.directory (must be a non-empty string)\");\n  }\n\n  if (!Array.isArray(config.schema.exclude)) {\n    invalidFields.push(\"schema.exclude (must be an array of strings)\");\n  }\n\n  if (typeof config.migrations.directory !== \"string\" || config.migrations.directory.trim() === \"\") {\n    invalidFields.push(\"migrations.directory (must be a non-empty string)\");\n  }\n\n  if (typeof config.migrations.verify !== \"boolean\") {\n    invalidFields.push(\"migrations.verify (must be a boolean)\");\n  }\n\n  if (typeof config.migrations.dataDirectory !== \"string\") {\n    invalidFields.push(\"migrations.dataDirectory (must be a string)\");\n  }\n\n  if (typeof config.diff.warnOnDelete !== \"boolean\") {\n    invalidFields.push(\"diff.warnOnDelete (must be a boolean)\");\n  }\n\n  if (typeof config.diff.requireForceForDestructive !== \"boolean\") {\n    invalidFields.push(\"diff.requireForceForDestructive (must be a boolean)\");\n  }\n\n  if (typeof config.typeGen.outPath !== \"string\" || config.typeGen.outPath.trim() === \"\") {\n    invalidFields.push(\"typeGen.outPath (must be a non-empty string)\");\n  }\n\n  if (invalidFields.length > 0) {\n    throw new ConfigurationError(\"Invalid configuration values\", configPath, invalidFields);\n  }\n\n  // Validate schema directory exists - try multiple locations\n  const cwd = process.cwd();\n  const possiblePaths = [\n    path.resolve(cwd, config.schema.directory),\n    path.resolve(cwd, \"shared\", config.schema.directory),\n  ];\n\n  const schemaDir = possiblePaths.find((p) => fs.existsSync(p));\n\n  if (!schemaDir) {\n    throw new ConfigurationError(`Schema directory not found. Tried: ${possiblePaths.join(\", \")}`, configPath, [\n      \"schema.directory\",\n    ]);\n  }\n}\n\n/**\n * Loads and merges configuration from all sources\n * Priority: CLI args > Environment variables > Config file > Defaults\n */\nexport async function loadConfig(options: any = {}): Promise<MigrationConfig> {\n  let config: MigrationConfig = { ...DEFAULT_CONFIG };\n  let configFilePath: string | undefined;\n\n  const cwd = process.cwd();\n\n  // Check for explicit config path from CLI\n  if (options.config) {\n    const explicitPath = path.resolve(cwd, options.config);\n    if (!fs.existsSync(explicitPath)) {\n      throw new ConfigurationError(`Configuration file not found: ${explicitPath}`, explicitPath);\n    }\n    configFilePath = explicitPath;\n  } else {\n    // Search for config file in current directory and shared directory\n    const searchDirs = [cwd, path.join(cwd, \"shared\")];\n\n    for (const dir of searchDirs) {\n      if (fs.existsSync(dir)) {\n        const found = findConfigFile(dir);\n        if (found) {\n          configFilePath = found;\n          break;\n        }\n      }\n    }\n  }\n\n  // Load config file if found\n  if (configFilePath) {\n    const fileConfig = await loadConfigFile(configFilePath);\n    if (fileConfig) {\n      config = mergeConfig(config, fileConfig);\n    }\n  }\n\n  // Merge environment variables\n  const envConfig = loadConfigFromEnv();\n  if (Object.keys(envConfig).length > 0) {\n    config = mergeConfig(config, envConfig);\n  }\n\n  // Merge CLI arguments (highest priority)\n  const argsConfig = loadConfigFromArgs(options);\n  if (Object.keys(argsConfig).length > 0) {\n    config = mergeConfig(config, argsConfig);\n  }\n\n  // Validate final configuration\n  validateConfig(config, configFilePath);\n\n  return config;\n}\n\n/**\n * Gets the absolute path to the schema directory\n */\nexport function getSchemaDirectory(config: MigrationConfig): string {\n  const cwd = process.cwd();\n  const possiblePaths = [\n    path.resolve(cwd, config.schema.directory),\n    path.resolve(cwd, \"shared\", config.schema.directory),\n  ];\n\n  return possiblePaths.find((p) => fs.existsSync(p)) || possiblePaths[0];\n}\n\n/**\n * Gets the absolute path to the migrations directory\n */\nexport function getMigrationsDirectory(config: MigrationConfig): string {\n  const cwd = process.cwd();\n  const possiblePaths = [\n    path.resolve(cwd, config.migrations.directory),\n    path.resolve(cwd, \"shared\", config.migrations.directory),\n  ];\n\n  return possiblePaths.find((p) => fs.existsSync(p)) || possiblePaths[0];\n}\n\n/**\n * Gets the absolute path to PocketBase's data directory (or data.db file).\n *\n * Falls back to the pb_data directory next to the migrations directory, which\n * is where PocketBase puts it by default.\n */\nexport function getDataDirectory(config: MigrationConfig): string {\n  const configured = config.migrations.dataDirectory.trim();\n  if (configured !== \"\") {\n    return path.resolve(process.cwd(), configured);\n  }\n  return defaultDataDirectory(getMigrationsDirectory(config));\n}\n\n/**\n * Gets the default configuration\n */\nexport function getDefaultConfig(): MigrationConfig {\n  return { ...DEFAULT_CONFIG };\n}\n\n/**\n * Creates a sample configuration file content\n */\nexport function getSampleConfig(format: \"json\" | \"js\"): string {\n  if (format === \"json\") {\n    return JSON.stringify(DEFAULT_CONFIG, null, 2);\n  }\n\n  return `/**\n * PocketBase Zod Migration Configuration\n * @type {import('pocketbase-zod-schema/server').MigrationConfig}\n */\nexport default {\n  schema: {\n    directory: \"/src/schema\",\n    exclude: [\"base.ts\", \"index.ts\", \"permissions.ts\", \"permission-templates.ts\"],\n  },\n  migrations: {\n    directory: \"pocketbase/pb_migrations\",\n    format: \"timestamp_description\",\n    verify: false,\n    dataDirectory: \"\",\n  },\n  diff: {\n    warnOnDelete: true,\n    requireForceForDestructive: true,\n  },\n  typeGen: {\n    outPath: \"pocketbase-types.ts\",\n  },\n};\n`;\n}\n","/**\n * Logging utilities for CLI output\n * Provides colored console output and formatting helpers\n */\n\nimport chalk from \"chalk\";\nimport ora, { type Ora } from \"ora\";\nimport type { FieldChange, SchemaDiff } from \"../../migration/types.js\";\n\n/**\n * Verbosity levels for logging\n */\nexport type VerbosityLevel = \"quiet\" | \"normal\" | \"verbose\";\n\n/**\n * Current verbosity level\n */\nlet currentVerbosity: VerbosityLevel = \"normal\";\n\n/**\n * Sets the verbosity level for logging\n *\n * @param level - Verbosity level to set\n */\nexport function setVerbosity(level: VerbosityLevel): void {\n  currentVerbosity = level;\n}\n\n/**\n * Gets the current verbosity level\n *\n * @returns Current verbosity level\n */\nexport function getVerbosity(): VerbosityLevel {\n  return currentVerbosity;\n}\n\n/**\n * Checks if output should be shown based on verbosity\n *\n * @param requiredLevel - Minimum verbosity level required\n * @returns True if output should be shown\n */\nfunction shouldLog(requiredLevel: VerbosityLevel): boolean {\n  const levels: VerbosityLevel[] = [\"quiet\", \"normal\", \"verbose\"];\n  const currentIndex = levels.indexOf(currentVerbosity);\n  const requiredIndex = levels.indexOf(requiredLevel);\n  return currentIndex >= requiredIndex;\n}\n\n/**\n * Creates a spinner for long-running operations\n *\n * @param text - Initial spinner text\n * @returns Ora spinner instance\n */\nexport function createSpinner(text: string): Ora {\n  // In quiet mode, create a silent spinner\n  if (currentVerbosity === \"quiet\") {\n    return ora({ text, isSilent: true });\n  }\n  return ora(text);\n}\n\n/**\n * Logs a success message in green\n *\n * @param message - Message to log\n */\nexport function logSuccess(message: string): void {\n  if (shouldLog(\"normal\")) {\n    console.log(chalk.green(\"✓\"), message);\n  }\n}\n\n/**\n * Logs an error message in red\n * Always shown regardless of verbosity level\n *\n * @param message - Message to log\n */\nexport function logError(message: string): void {\n  console.error(chalk.red(\"✗\"), message);\n}\n\n/**\n * Logs a warning message in yellow\n *\n * @param message - Message to log\n */\nexport function logWarning(message: string): void {\n  if (shouldLog(\"normal\")) {\n    console.warn(chalk.yellow(\"⚠\"), message);\n  }\n}\n\n/**\n * Logs an info message in blue\n *\n * @param message - Message to log\n */\nexport function logInfo(message: string): void {\n  if (shouldLog(\"normal\")) {\n    console.log(chalk.blue(\"ℹ\"), message);\n  }\n}\n\n/**\n * Logs a debug message in gray\n * Only shown in verbose mode\n *\n * @param message - Message to log\n */\nexport function logDebug(message: string): void {\n  if (shouldLog(\"verbose\")) {\n    console.log(chalk.gray(\"⚙\"), chalk.gray(message));\n  }\n}\n\n/**\n * Logs a section header\n *\n * @param title - Section title\n */\nexport function logSection(title: string): void {\n  if (shouldLog(\"normal\")) {\n    console.log();\n    console.log(chalk.bold.cyan(title));\n    console.log(chalk.cyan(\"─\".repeat(title.length)));\n  }\n}\n\n/**\n * Formats a field change for display\n *\n * @param change - Field change object\n * @returns Formatted string\n */\nfunction formatFieldChange(change: FieldChange): string {\n  const oldValue = change.oldValue === null ? \"null\" : JSON.stringify(change.oldValue);\n  const newValue = change.newValue === null ? \"null\" : JSON.stringify(change.newValue);\n\n  return `${change.property}: ${chalk.red(oldValue)} → ${chalk.green(newValue)}`;\n}\n\n/**\n * Formats a change summary for display\n * Creates a formatted, colored summary of detected changes\n *\n * @param diff - Schema diff containing all changes\n * @returns Formatted summary string\n */\nexport function formatChangeSummary(diff: SchemaDiff): string {\n  const lines: string[] = [];\n\n  // Count total changes\n  const totalCollectionsToCreate = diff.collectionsToCreate.length;\n  const totalCollectionsToDelete = diff.collectionsToDelete.length;\n  const totalCollectionsToModify = diff.collectionsToModify.length;\n\n  const totalChanges = totalCollectionsToCreate + totalCollectionsToDelete + totalCollectionsToModify;\n\n  if (totalChanges === 0) {\n    return chalk.gray(\"No changes detected\");\n  }\n\n  lines.push(chalk.bold(`Found ${totalChanges} collection change(s):`));\n  lines.push(\"\");\n\n  // New collections\n  if (totalCollectionsToCreate > 0) {\n    lines.push(chalk.green.bold(`✓ ${totalCollectionsToCreate} collection(s) to create:`));\n    for (const collection of diff.collectionsToCreate) {\n      lines.push(chalk.green(`  + ${collection.name} (${collection.type})`));\n      if (collection.type === \"view\") {\n        // A view's fields are derived by PocketBase from its SQL query\n        lines.push(chalk.gray(`    fields derived from the view query`));\n      } else {\n        lines.push(chalk.gray(`    ${collection.fields.length} field(s)`));\n      }\n    }\n    lines.push(\"\");\n  }\n\n  // Deleted collections\n  if (totalCollectionsToDelete > 0) {\n    lines.push(chalk.red.bold(`✗ ${totalCollectionsToDelete} collection(s) to delete:`));\n    for (const collection of diff.collectionsToDelete) {\n      lines.push(chalk.red(`  - ${collection.name}`));\n    }\n    lines.push(\"\");\n  }\n\n  // Modified collections\n  if (totalCollectionsToModify > 0) {\n    lines.push(chalk.yellow.bold(`⚡ ${totalCollectionsToModify} collection(s) to modify:`));\n\n    for (const modification of diff.collectionsToModify) {\n      lines.push(chalk.yellow(`  ~ ${modification.collection}`));\n\n      // Fields to add\n      if (modification.fieldsToAdd.length > 0) {\n        lines.push(chalk.green(`    + ${modification.fieldsToAdd.length} field(s) to add:`));\n        for (const field of modification.fieldsToAdd) {\n          lines.push(chalk.green(`      + ${field.name} (${field.type})`));\n        }\n      }\n\n      // Fields to remove\n      if (modification.fieldsToRemove.length > 0) {\n        lines.push(chalk.red(`    - ${modification.fieldsToRemove.length} field(s) to remove:`));\n        for (const field of modification.fieldsToRemove) {\n          lines.push(chalk.red(`      - ${field.name}`));\n        }\n      }\n\n      // Fields to modify\n      if (modification.fieldsToModify.length > 0) {\n        lines.push(chalk.yellow(`    ~ ${modification.fieldsToModify.length} field(s) to modify:`));\n        for (const fieldMod of modification.fieldsToModify) {\n          lines.push(chalk.yellow(`      ~ ${fieldMod.fieldName}`));\n          for (const change of fieldMod.changes) {\n            lines.push(chalk.gray(`        ${formatFieldChange(change)}`));\n          }\n        }\n      }\n\n      // Indexes\n      if (modification.indexesToAdd.length > 0) {\n        lines.push(chalk.green(`    + ${modification.indexesToAdd.length} index(es) to add`));\n      }\n\n      if (modification.indexesToRemove.length > 0) {\n        lines.push(chalk.red(`    - ${modification.indexesToRemove.length} index(es) to remove`));\n      }\n\n      // Rules\n      if (modification.rulesToUpdate.length > 0) {\n        lines.push(chalk.yellow(`    ~ ${modification.rulesToUpdate.length} rule(s) to update`));\n      }\n\n      // View query\n      if (modification.viewQueryUpdate) {\n        lines.push(chalk.yellow(`    ~ view query to update`));\n      }\n\n      lines.push(\"\");\n    }\n  }\n\n  return lines.join(\"\\n\");\n}\n\n/**\n * Displays a progress indicator for a long operation\n *\n * @param message - Progress message\n * @param operation - Async operation to perform\n * @returns Result of the operation\n */\nexport async function withProgress<T>(message: string, operation: () => Promise<T>): Promise<T> {\n  const spinner = createSpinner(message).start();\n\n  try {\n    const result = await operation();\n    spinner.succeed();\n    return result;\n  } catch (error) {\n    spinner.fail();\n    throw error;\n  }\n}\n\n/**\n * Logs a step in a multi-step process\n *\n * @param step - Current step number\n * @param total - Total number of steps\n * @param message - Step description\n */\nexport function logStep(step: number, total: number, message: string): void {\n  if (shouldLog(\"normal\")) {\n    const progress = chalk.gray(`[${step}/${total}]`);\n    console.log(progress, message);\n  }\n}\n\n/**\n * Logs a list of items with bullet points\n *\n * @param items - Items to list\n * @param indent - Indentation level (default: 2)\n */\nexport function logList(items: string[], indent: number = 2): void {\n  if (shouldLog(\"normal\")) {\n    const padding = \" \".repeat(indent);\n    for (const item of items) {\n      console.log(`${padding}• ${item}`);\n    }\n  }\n}\n\n/**\n * Logs a key-value pair\n *\n * @param key - Key name\n * @param value - Value to display\n * @param indent - Indentation level (default: 2)\n */\nexport function logKeyValue(key: string, value: string, indent: number = 2): void {\n  if (shouldLog(\"normal\")) {\n    const padding = \" \".repeat(indent);\n    console.log(`${padding}${chalk.gray(key + \":\")} ${value}`);\n  }\n}\n\n/**\n * Logs a table of data\n *\n * @param headers - Column headers\n * @param rows - Data rows\n */\nexport function logTable(headers: string[], rows: string[][]): void {\n  if (!shouldLog(\"normal\")) return;\n\n  // Calculate column widths\n  const widths = headers.map((h, i) => {\n    const maxRowWidth = Math.max(...rows.map((r) => (r[i] || \"\").length));\n    return Math.max(h.length, maxRowWidth);\n  });\n\n  // Print header\n  const headerLine = headers.map((h, i) => h.padEnd(widths[i])).join(\"  \");\n  console.log(chalk.bold(headerLine));\n  console.log(chalk.gray(\"─\".repeat(headerLine.length)));\n\n  // Print rows\n  for (const row of rows) {\n    const rowLine = row.map((cell, i) => (cell || \"\").padEnd(widths[i])).join(\"  \");\n    console.log(rowLine);\n  }\n}\n\n/**\n * Logs a box with a title and content\n *\n * @param title - Box title\n * @param content - Box content (array of lines)\n */\nexport function logBox(title: string, content: string[]): void {\n  if (!shouldLog(\"normal\")) return;\n\n  const maxWidth = Math.max(title.length, ...content.map((c) => c.length));\n  const border = \"─\".repeat(maxWidth + 2);\n\n  console.log();\n  console.log(chalk.cyan(`┌${border}┐`));\n  console.log(chalk.cyan(\"│ \") + chalk.bold(title.padEnd(maxWidth)) + chalk.cyan(\" │\"));\n  console.log(chalk.cyan(`├${border}┤`));\n  for (const line of content) {\n    console.log(chalk.cyan(\"│ \") + line.padEnd(maxWidth) + chalk.cyan(\" │\"));\n  }\n  console.log(chalk.cyan(`└${border}┘`));\n}\n\n/**\n * Creates a progress bar string\n *\n * @param current - Current progress value\n * @param total - Total value\n * @param width - Bar width in characters (default: 20)\n * @returns Formatted progress bar string\n */\nexport function createProgressBar(current: number, total: number, width: number = 20): string {\n  const percentage = Math.min(100, Math.round((current / total) * 100));\n  const filled = Math.round((percentage / 100) * width);\n  const empty = width - filled;\n\n  const bar = chalk.green(\"█\".repeat(filled)) + chalk.gray(\"░\".repeat(empty));\n  return `${bar} ${percentage}%`;\n}\n\n/**\n * Logs a timestamp with a message\n *\n * @param message - Message to log\n */\nexport function logTimestamp(message: string): void {\n  if (shouldLog(\"verbose\")) {\n    const timestamp = new Date().toISOString();\n    console.log(chalk.gray(`[${timestamp}]`), message);\n  }\n}\n\n/**\n * Formats a duration in milliseconds to a human-readable string\n *\n * @param ms - Duration in milliseconds\n * @returns Formatted duration string\n */\nexport function formatDuration(ms: number): string {\n  if (ms < 1000) {\n    return `${ms}ms`;\n  } else if (ms < 60000) {\n    return `${(ms / 1000).toFixed(1)}s`;\n  } else {\n    const minutes = Math.floor(ms / 60000);\n    const seconds = Math.round((ms % 60000) / 1000);\n    return `${minutes}m ${seconds}s`;\n  }\n}\n\n/**\n * Logs a timed operation result\n *\n * @param message - Operation description\n * @param startTime - Start time from Date.now()\n */\nexport function logTimed(message: string, startTime: number): void {\n  if (shouldLog(\"normal\")) {\n    const duration = Date.now() - startTime;\n    console.log(chalk.green(\"✓\"), message, chalk.gray(`(${formatDuration(duration)})`));\n  }\n}\n\n/**\n * Status output interface for JSON output mode\n */\nexport interface StatusOutput {\n  status: \"up-to-date\" | \"changes-pending\" | \"first-time-setup\";\n  collections: {\n    current: number;\n    snapshot: number;\n  };\n  changes: {\n    create: number;\n    delete: number;\n    modify: number;\n  };\n  destructive: boolean;\n  /**\n   * Disk vs. PocketBase's `_migrations` table. Present only when an applied\n   * migrations list was read (`--verify` / `--pb-data`).\n   */\n  migrations?: {\n    source: string;\n    applied: number;\n    /** On disk, not yet applied */\n    pending: string[];\n    /** Applied, no longer on disk */\n    missing: string[];\n    /** Pending files that sit behind an already-applied migration */\n    outOfOrder: string[];\n    inSync: boolean;\n    /**\n     * What the database still lacks compared to the schema — the changes the\n     * pending files carry. Distinct from `changes`, which counts what has no\n     * migration file at all. Absent when disk and the database agree.\n     */\n    unapplied?: {\n      create: number;\n      delete: number;\n      modify: number;\n    };\n  };\n}\n\n/**\n * Formats status output as JSON\n *\n * @param output - Status output object\n * @returns JSON string\n */\nexport function formatStatusJson(output: StatusOutput): string {\n  return JSON.stringify(output, null, 2);\n}\n","/**\n * Generate command implementation\n * Generates migrations from schema changes\n */\n\nimport { Command } from \"commander\";\nimport * as path from \"path\";\nimport {\n  ConfigurationError,\n  FileSystemError,\n  MigrationExecutionError,\n  MigrationGenerationError,\n  SchemaParsingError,\n  SnapshotError,\n} from \"../../migration/errors.js\";\nimport {\n  CollectionStore,\n  compare,\n  detectDestructiveChanges,\n  filterDiff,\n  formatDestructiveChanges,\n  formatGojaLintFinding,\n  lintMigrationSource,\n  parseSchemaFiles,\n  planMigrations,\n  replayMigrationsDirectory,\n  requiresForceFlag,\n  summarizeDestructiveChanges,\n  verifyMigrationSources,\n  writePlannedMigrations,\n  type GojaLintResult,\n  type MigrationRoundTripResult,\n  type PlannedMigration,\n} from \"../../migration/index.js\";\nimport { loadSnapshotWithMigrations } from \"../../migration/snapshot.js\";\nimport type { SchemaDefinition } from \"../../migration/types.js\";\nimport { getMigrationsDirectory, getSchemaDirectory, loadConfig, type MigrationConfig } from \"../utils/config.js\";\nimport {\n  formatChangeSummary,\n  logDebug,\n  logError,\n  logInfo,\n  logSection,\n  logSuccess,\n  logWarning,\n  setVerbosity,\n  withProgress,\n} from \"../utils/logger.js\";\n\n/**\n * Checks if there are any changes in the diff\n *\n * @param diff - Schema diff to check\n * @returns True if there are changes\n */\nfunction hasChanges(diff: any): boolean {\n  return (\n    diff.collectionsToCreate.length > 0 || diff.collectionsToDelete.length > 0 || diff.collectionsToModify.length > 0\n  );\n}\n\n/**\n * Handles destructive changes with warnings and force flag\n *\n * @param diff - Schema diff containing changes\n * @param config - Migration configuration\n * @param force - Force flag from CLI\n * @returns True if should proceed, false otherwise\n */\nfunction handleDestructiveChanges(diff: any, config: MigrationConfig, force: boolean): boolean {\n  // Detect destructive changes\n  const destructiveChanges = detectDestructiveChanges(diff);\n\n  if (destructiveChanges.length === 0) {\n    return true; // No destructive changes, proceed\n  }\n\n  // Display destructive changes warning\n  logSection(\"⚠️  Destructive Changes Detected\");\n  console.log();\n\n  // Format and display destructive changes\n  console.log(formatDestructiveChanges(destructiveChanges));\n\n  // Display summary\n  const summary = summarizeDestructiveChanges(destructiveChanges);\n  console.log(\"Summary:\");\n  console.log(`  Total: ${summary.total} destructive change(s)`);\n  if (summary.high > 0) {\n    console.log(`  High Severity: ${summary.high}`);\n  }\n  if (summary.medium > 0) {\n    console.log(`  Medium Severity: ${summary.medium}`);\n  }\n  if (summary.low > 0) {\n    console.log(`  Low Severity: ${summary.low}`);\n  }\n  console.log();\n\n  // Check if force flag is required\n  const forceRequired = config.diff.requireForceForDestructive && requiresForceFlag(destructiveChanges);\n\n  if (forceRequired && !force) {\n    // This path should technically be unreachable if we filtered destructive changes when !force\n    // But keeping it as a safety net\n    logError(\"Destructive changes require the --force flag to proceed.\");\n    console.log();\n    logInfo(\"To proceed with these changes, run the command again with --force:\");\n    console.log(\"  yarn migrate:generate --force\");\n    console.log();\n    logWarning(\"⚠️  WARNING: Using --force will apply these changes and may result in data loss!\");\n    return false;\n  }\n\n  if (force) {\n    logWarning(\"Proceeding with destructive changes (--force flag provided)\");\n    console.log();\n  }\n\n  return true;\n}\n\n/**\n * Outcome of the pre-write verification pass\n */\ntype VerificationOutcome =\n  | { status: \"verified\"; count: number }\n  /** The existing migrations could not be executed, so there is no baseline */\n  | { status: \"baseline-unexecutable\"; error: MigrationExecutionError }\n  | { status: \"failed\"; failures: MigrationRoundTripResult[] }\n  /** The migration would not run in PocketBase's goja runtime */\n  | { status: \"incompatible\"; results: GojaLintResult[] };\n\n/**\n * Executes each planned migration's up() and down() in the simulated\n * PocketBase JSVM, starting from the state the existing migrations\n * reconstruct, and reports anything that does not roll back cleanly.\n *\n * @param planned - Migrations generated but not yet written\n * @param migrationsDir - Directory holding the existing migrations\n * @returns What the verification found (rendered by reportVerification)\n */\nfunction verifyPlannedMigrations(planned: PlannedMigration[], migrationsDir: string): VerificationOutcome {\n  // Executing in the engine proves nothing about goja, which is what will\n  // actually run the file — so check compatibility before round-tripping\n  const lintResults = planned.map((migration) => lintMigrationSource(migration.content, { file: migration.filename }));\n  const incompatible = lintResults.filter((result) => !result.ok);\n  if (incompatible.length > 0) {\n    return { status: \"incompatible\", results: incompatible };\n  }\n\n  let baseline: CollectionStore;\n  try {\n    baseline = replayMigrationsDirectory(migrationsDir)?.store ?? new CollectionStore();\n  } catch (error) {\n    if (error instanceof MigrationExecutionError) {\n      return { status: \"baseline-unexecutable\", error };\n    }\n    throw error;\n  }\n\n  const report = verifyMigrationSources(\n    planned.map((migration) => ({ file: migration.filename, source: migration.content })),\n    { initialStore: baseline }\n  );\n\n  return report.ok\n    ? { status: \"verified\", count: report.results.length }\n    : { status: \"failed\", failures: report.failures };\n}\n\n/**\n * Prints a verification outcome\n *\n * @returns True if generation should proceed\n */\nfunction reportVerification(outcome: VerificationOutcome): boolean {\n  if (outcome.status === \"verified\") {\n    logSuccess(`Verified ${outcome.count} migration(s): up and down both apply and the state round-trips`);\n    return true;\n  }\n\n  if (outcome.status === \"incompatible\") {\n    logError(\"Generated migration uses JavaScript PocketBase cannot run - no files were written.\");\n    console.log();\n    for (const result of outcome.results) {\n      for (const finding of result.findings.filter((entry) => entry.severity === \"error\")) {\n        console.log(`  ${formatGojaLintFinding(finding)}`);\n      }\n    }\n    console.log();\n    logInfo(\"This is a bug in the generator - please report it with the schema that produced it.\");\n    return false;\n  }\n\n  if (outcome.status === \"baseline-unexecutable\") {\n    logError(\"Cannot verify: an existing migration could not be executed.\");\n    console.error();\n    console.error(outcome.error.getDetailedMessage());\n    console.error();\n    logInfo(\"Fix the migration above, or run without --verify.\");\n    return false;\n  }\n\n  logError(\"Migration verification failed - no files were written.\");\n  console.log();\n\n  for (const failure of outcome.failures) {\n    if (failure.error) {\n      console.log(`  ${failure.file}: ${failure.error.phase}() failed`);\n      console.log(`    ${failure.error.message}`);\n      continue;\n    }\n\n    const reason = failure.missingDown ? \"no down() to undo it\" : \"down() did not restore the previous state\";\n    console.log(`  ${failure.file}: ${reason}`);\n    for (const difference of failure.differences) {\n      console.log(`    ${difference.message}`);\n    }\n  }\n\n  console.log();\n  logInfo(\"Suggestions:\");\n  console.log(\"  • Re-run with --no-verify to write the migration(s) anyway\");\n  console.log(\"  • Report the differences above if the migration was generated from a Zod schema\");\n  return false;\n}\n\n/**\n * Executes the generate command\n *\n * @param filters - Optional filters for collection/field names\n * @param options - Command options\n */\nexport async function executeGenerate(filters: string[], options: any): Promise<void> {\n  try {\n    // Set verbosity based on global options\n    const parentOpts = options.parent?.opts?.() || {};\n    if (parentOpts.verbose) {\n      setVerbosity(\"verbose\");\n    } else if (parentOpts.quiet) {\n      setVerbosity(\"quiet\");\n    }\n\n    logDebug(\"Starting migration generation...\");\n    logDebug(`Options: ${JSON.stringify(options, null, 2)}`);\n    if (filters && filters.length > 0) {\n      logDebug(`Filters: ${JSON.stringify(filters)}`);\n    }\n\n    // Load configuration\n    const config = await loadConfig(options);\n\n    // Get paths\n    const schemaDir = getSchemaDirectory(config);\n    const migrationsDir = getMigrationsDirectory(config);\n\n    logSection(\"🔍 Analyzing Schema\");\n\n    // Parse schema files with full config (including exclude patterns)\n    const analyzerConfig = {\n      schemaDir,\n      excludePatterns: config.schema.exclude,\n      useCompiledFiles: false, // Use source files since we're in development/testing\n    };\n    const currentSchema: SchemaDefinition = await withProgress(\"Parsing Zod schemas...\", () =>\n      parseSchemaFiles(analyzerConfig)\n    );\n\n    logSuccess(`Found ${currentSchema.collections.size} collection(s)`);\n\n    // Load previous snapshot from migrations directory and apply subsequent migrations\n    logInfo(\"Loading previous snapshot...\");\n    const previousSnapshot = loadSnapshotWithMigrations({\n      migrationsPath: migrationsDir,\n    });\n\n    if (!previousSnapshot) {\n      logInfo(\"No previous snapshot found - treating as empty database (first-time generation)\");\n    } else {\n      logSuccess(\"Loaded previous snapshot as base reference\");\n    }\n\n    // Compare schemas\n    logSection(\"📊 Comparing Schemas\");\n    let diff = compare(currentSchema, previousSnapshot);\n\n    // Apply filtering (patterns and destructive skipping)\n    const skipDestructive = !options.force;\n\n    // Check for destructive changes BEFORE filtering if we are going to skip them (for logging)\n    // Only if we are NOT forcing.\n    if (skipDestructive) {\n      const destructive = detectDestructiveChanges(diff);\n      if (destructive.length > 0) {\n        logInfo(`ℹ️  Omitting ${destructive.length} destructive change(s) because --force is not set.`);\n      }\n    }\n\n    // Apply filter\n    diff = filterDiff(diff, {\n      patterns: filters,\n      skipDestructive: skipDestructive,\n    });\n\n    // Check if there are any changes\n    if (!hasChanges(diff)) {\n      logInfo(\"No changes detected\");\n      console.log();\n      logSuccess(\"Schema is up to date!\");\n      return;\n    }\n\n    // Display change summary\n    console.log();\n    console.log(formatChangeSummary(diff));\n\n    // Handle destructive changes\n    // If skipDestructive was true, diff shouldn't have any destructive changes, so this will pass.\n    // If force was true, skipDestructive was false, diff might have destructive changes, this will warn and proceed.\n    if (!handleDestructiveChanges(diff, config, options.force)) {\n      process.exit(1);\n    }\n\n    // Generate migration\n    logSection(\"📝 Generating Migration\");\n\n    const planned = await withProgress(\"Creating migration file...\", () =>\n      Promise.resolve(planMigrations(diff, { migrationDir: migrationsDir, force: options.force }))\n    );\n\n    if (planned.length === 0) {\n      logWarning(\"No migration files were generated (no changes detected or duplicate migration).\");\n      return;\n    }\n\n    // Self-verify before writing: execute up() and down() in the simulated\n    // PocketBase JSVM and confirm the state round-trips\n    if (config.migrations.verify) {\n      logSection(\"🔁 Verifying Migration\");\n\n      const outcome = await withProgress(\"Executing up() and down()...\", () =>\n        Promise.resolve(verifyPlannedMigrations(planned, migrationsDir))\n      );\n\n      if (!reportVerification(outcome)) {\n        console.error();\n        process.exit(1);\n      }\n    }\n\n    const migrationPaths = writePlannedMigrations(planned, migrationsDir);\n\n    if (migrationPaths.length === 1) {\n      logSuccess(`Migration file created: ${path.basename(migrationPaths[0])}`);\n    } else {\n      logSuccess(`Created ${migrationPaths.length} migration files`);\n    }\n\n    // Note: Snapshot is embedded in the generated migration file\n    // No separate snapshot file needed\n\n    // Display next steps\n    logSection(\"✅ Next Steps\");\n    console.log();\n    console.log(\"  1. Review the generated migration file(s):\");\n    migrationPaths.forEach((migrationPath: string) => {\n      console.log(`     ${migrationPath}`);\n    });\n    console.log();\n    console.log(\"  2. Apply the migration by running PocketBase:\");\n    console.log(\"     yarn pb\");\n    console.log();\n    console.log(\"  Or apply migrations manually:\");\n    console.log(\"     cd pb && ./pocketbase migrate up\");\n    console.log();\n  } catch (error) {\n    // Handle specific error types with helpful messages\n    if (error instanceof SchemaParsingError) {\n      logError(\"Schema Parsing Error\");\n      console.error();\n      console.error(error.getDetailedMessage());\n      console.error();\n      logInfo(\"Suggestions:\");\n      console.log(\"  • Make sure your schema files are valid Zod schemas\");\n      console.log('  • Run \"yarn build\" in the shared workspace to compile TypeScript files');\n      console.log('  • Check that each schema file exports a defineCollection()/defineView() result (default export preferred)');\n    } else if (error instanceof SnapshotError) {\n      logError(\"Snapshot Error\");\n      console.error();\n      console.error(error.getDetailedMessage());\n      console.error();\n      logInfo(\"Suggestions:\");\n      console.log(\"  • Check that the snapshot file is not corrupted\");\n      console.log(\"  • Verify file permissions for the snapshot file\");\n      console.log(\"  • If this is the first run, this error should not occur\");\n    } else if (error instanceof MigrationGenerationError) {\n      logError(\"Migration Generation Error\");\n      console.error();\n      console.error(error.getDetailedMessage());\n      console.error();\n      logInfo(\"Suggestions:\");\n      console.log(\"  • Check that the migration directory exists and is writable\");\n      console.log(\"  • Verify you have sufficient disk space\");\n      console.log(\"  • Check file permissions for the migration directory\");\n    } else if (error instanceof FileSystemError) {\n      logError(\"File System Error\");\n      console.error();\n      console.error(error.getDetailedMessage());\n      console.error();\n      logInfo(\"Suggestions:\");\n      console.log(\"  • Check file and directory permissions\");\n      console.log(\"  • Verify you have sufficient disk space\");\n      console.log(\"  • Ensure the paths are correct and accessible\");\n    } else if (error instanceof ConfigurationError) {\n      logError(\"Configuration Error\");\n      console.error();\n      console.error(error.getDetailedMessage());\n      console.error();\n      logInfo(\"Suggestions:\");\n      console.log(\"  • Check your configuration file syntax\");\n      console.log(\"  • Verify all paths are correct and accessible\");\n      console.log(\"  • Run with --verbose flag for more details\");\n    } else {\n      // Generic error handling\n      logError(`Failed to generate migration: ${error}`);\n      if (error instanceof Error && error.stack) {\n        console.error();\n        console.error(error.stack);\n      }\n    }\n\n    console.error();\n    process.exit(1);\n  }\n}\n\n/**\n * Creates the generate command\n *\n * @returns Commander command instance\n */\nexport function createGenerateCommand(): Command {\n  return new Command(\"generate\")\n    .description(\"Generate a migration from schema changes\")\n    .argument(\"[filters...]\", \"Filter migrations by collection or field name (regex supported)\")\n    .option(\"-o, --output <directory>\", \"Output directory for migration files\")\n    .option(\"-f, --force\", \"Force generation even with destructive changes or duplicates\", false)\n    .option(\"--dry-run\", \"Show what would be generated without creating files\", false)\n    .option(\"--schema-dir <directory>\", \"Directory containing Zod schema files\")\n    .option(\"--verify\", \"Execute up() and down() before writing, and refuse migrations that do not roll back\")\n    .option(\"--no-verify\", \"Skip round-trip verification even when it is enabled in the configuration\")\n    .addHelpText(\n      \"after\",\n      `\nExamples:\n  $ pocketbase-migrate generate                    Generate migration from schema changes\n  $ pocketbase-migrate generate User               Generate migration only for User collection\n  $ pocketbase-migrate generate User.name          Generate migration only for User.name field\n  $ pocketbase-migrate generate --force            Force generation with destructive changes\n  $ pocketbase-migrate generate --dry-run          Preview changes without generating files\n  $ pocketbase-migrate generate --verify           Verify up() and down() round-trip before writing\n  $ pocketbase-migrate generate -o ./migrations    Specify output directory\n`\n    )\n    .action(executeGenerate);\n}\n","import { z, ZodIntersection, ZodTuple, ZodMap, ZodSet } from \"zod\";\nimport type { ZodTypeAny } from \"zod\";\n\nexport function zodToTs(schema: ZodTypeAny): string {\n  if (schema instanceof z.ZodString) {\n    return \"string\";\n  }\n  if (schema instanceof z.ZodNumber) {\n    return \"number\";\n  }\n  if (schema instanceof z.ZodBoolean) {\n    return \"boolean\";\n  }\n  if (schema instanceof z.ZodDate) {\n    return \"string\"; // PocketBase stores dates as strings\n  }\n  if (schema instanceof z.ZodAny || schema instanceof z.ZodUnknown) {\n    return \"any\";\n  }\n  if (schema instanceof z.ZodArray) {\n    const elemType = zodToTs(schema.element as ZodTypeAny);\n    // Wrap in parens if it looks like a union or complex type\n    if (elemType.includes(\"|\") || elemType.includes(\" \") || elemType.startsWith(\"{\")) {\n      return `(${elemType})[]`;\n    }\n    return `${elemType}[]`;\n  }\n  if (schema instanceof z.ZodObject) {\n    const shape = schema.shape;\n    const lines: string[] = [\"{\"];\n    for (const [key, value] of Object.entries(shape)) {\n      const isOptional = value instanceof z.ZodOptional;\n      const typeStr = zodToTs(value as ZodTypeAny);\n      lines.push(`  ${key}${isOptional ? \"?\" : \"\"}: ${typeStr};`);\n    }\n    lines.push(\"}\");\n    return lines.join(\"\\n\");\n  }\n  if (schema instanceof z.ZodOptional) {\n    const inner = zodToTs(schema.unwrap() as ZodTypeAny);\n    if (inner.includes('| undefined')) return inner;\n    return `${inner} | undefined`;\n  }\n  if (schema instanceof z.ZodNullable) {\n    const inner = zodToTs(schema.unwrap() as ZodTypeAny);\n    return `${inner} | null`;\n  }\n  if (schema instanceof z.ZodUnion) {\n    const options = schema.options as ZodTypeAny[];\n    return options.map((opt) => zodToTs(opt)).join(\" | \");\n  }\n\n  const isInstance = (target: any, typeName: string, fallbackClass?: any) => {\n    if (fallbackClass && target instanceof fallbackClass) return true;\n    if ((z as any)[typeName] && target instanceof (z as any)[typeName]) return true;\n    return false;\n  };\n\n  if (isInstance(schema, \"ZodIntersection\", ZodIntersection)) {\n    const def = schema._def as unknown as { left: ZodTypeAny; right: ZodTypeAny };\n    const left = zodToTs(def.left);\n    const right = zodToTs(def.right);\n    return `(${left} & ${right})`;\n  }\n\n  if (isInstance(schema, \"ZodTuple\", ZodTuple)) {\n    const items = (schema as { items?: ZodTypeAny[] }).items ?? (schema._def as { items?: ZodTypeAny[] }).items;\n    if (Array.isArray(items)) {\n      const itemTypes = items.map((item: ZodTypeAny) => zodToTs(item));\n      return `[${itemTypes.join(\", \")}]`;\n    }\n    return \"any[]\";\n  }\n\n  if (schema instanceof z.ZodEnum) {\n    const options = schema.options as unknown[];\n    return options.map((v) => (typeof v === \"string\" ? `\"${v}\"` : String(v))).join(\" | \");\n  }\n\n  if (isInstance(schema, \"ZodMap\", ZodMap)) {\n    const def = schema._def as unknown as { keyType: ZodTypeAny; valueType: ZodTypeAny };\n    const keyType = zodToTs(def.keyType);\n    const valueType = zodToTs(def.valueType);\n    return `Record<${keyType}, ${valueType}>`;\n  }\n\n  if (isInstance(schema, \"ZodSet\", ZodSet)) {\n    const def = schema._def as unknown as { valueType: ZodTypeAny };\n    const valueType = zodToTs(def.valueType);\n    return `${valueType}[]`;\n  }\n\n  if (schema instanceof z.ZodRecord) {\n    const valueType = zodToTs(schema.valueType as ZodTypeAny);\n    return `Record<string, ${valueType}>`;\n  }\n  if (schema instanceof z.ZodLiteral) {\n    const val = schema.value;\n    if (typeof val === \"string\") return `\"${val}\"`;\n    return String(val);\n  }\n\n  if (schema instanceof z.ZodPipe) {\n    return zodToTs((schema._def as unknown as { in: ZodTypeAny }).in);\n  }\n  if (schema instanceof z.ZodDefault) {\n    return zodToTs((schema._def as unknown as { innerType: ZodTypeAny }).innerType);\n  }\n  if (schema instanceof z.ZodLazy) {\n      return \"any /* z.lazy() */\";\n  }\n\n  return \"any\";\n}\n","import type { CollectionSchema, FieldDefinition, SchemaDefinition } from \"../migration/types\";\nimport { zodToTs } from \"./utils\";\n\nexport interface TypeGeneratorConfig {\n  outPath?: string;\n}\n\nconst PASCAL_CASE_REGEX = /(?:^\\w|[A-Z]|\\b\\w)/g;\nconst WORD_SEPARATOR_REGEX = /[\\s_-]+/g;\n\nexport class TypeGenerator {\n  private schema: SchemaDefinition;\n\n  constructor(schema: SchemaDefinition) {\n    this.schema = schema;\n  }\n\n  public generate(): string {\n    const lines: string[] = [];\n\n    // Add header\n    lines.push(`/**`);\n    lines.push(` * This file was auto-generated by pocketbase-zod-schema.`);\n    lines.push(` * Do not modify it manually.`);\n    lines.push(` */`);\n    lines.push(``);\n\n    // Check if RecordModel is needed (used as fallback for relations to collections not in schema)\n    const needsRecordModel = this.checkIfRecordModelNeeded();\n\n    lines.push(`import PocketBase from \"pocketbase\";`);\n    lines.push(`import type { RecordService } from \"pocketbase\";`);\n\n    if (needsRecordModel) {\n      lines.push(`import type { RecordModel } from \"pocketbase\";`);\n    }\n    lines.push(``);\n\n    // Generate types for each collection\n    const collectionNames = Array.from(this.schema.collections.keys());\n\n    for (const [_, collection] of this.schema.collections) {\n      lines.push(this.generateCollectionType(collection));\n      lines.push(``);\n    }\n\n    // Generate CollectionResponse map\n    lines.push(`export type CollectionResponses = {`);\n    for (const name of collectionNames) {\n      const typeName = this.toPascalCase(name);\n      lines.push(`  ${name}: ${typeName}Response;`);\n    }\n    lines.push(`};`);\n    lines.push(``);\n\n    // Generate TypedPocketBase interface\n    lines.push(`export interface TypedPocketBase extends PocketBase {`);\n    for (const name of collectionNames) {\n      const typeName = this.toPascalCase(name);\n      lines.push(`  collection(idOrName: \"${name}\"): RecordService<${typeName}Response>;`);\n    }\n    lines.push(`}`);\n    lines.push(``);\n\n    return lines.join(\"\\n\");\n  }\n\n  private generateCollectionType(collection: CollectionSchema): string {\n    const typeName = this.toPascalCase(collection.name);\n    const isView = collection.type === \"view\";\n    const lines: string[] = [];\n\n    // Generate Record Interface (base fields)\n    lines.push(`export interface ${typeName}Record {`);\n\n    // System fields\n    // Views only have the columns their query selects, so created/updated are\n    // not guaranteed to exist\n    lines.push(`  id: string;`);\n    if (!isView) {\n      lines.push(`  created: string;`);\n      lines.push(`  updated: string;`);\n    }\n    lines.push(`  collectionId: string;`);\n    lines.push(`  collectionName: \"${collection.name}\";`);\n\n    // User fields\n    for (const field of collection.fields) {\n      // Skip system fields if they are explicitly in the fields list (they shouldn't be, but just in case)\n      if (['id', 'created', 'updated'].includes(field.name)) continue;\n\n      const fieldType = this.getFieldType(field);\n      const optional = !field.required ? \"?\" : \"\";\n      lines.push(`  ${field.name}${optional}: ${fieldType};`);\n    }\n\n    lines.push(`}`);\n    lines.push(``);\n\n    // Calculate expand type\n    // Views don't support relation expansion, so they never get an expand block\n    const expandFields: string[] = [];\n    for (const field of isView ? [] : collection.fields) {\n      if (field.type === 'relation' && field.relation) {\n        const targetCollection = field.relation.collection;\n        // Check if target exists in schema or is system collection\n        let targetType = 'RecordModel'; // Fallback\n\n        if (targetCollection.toLowerCase() === 'users' && !this.schema.collections.has('users')) {\n            // If users collection is not in our schema but referenced, assume standard Auth collection\n            // Or if it IS in schema, we use it.\n            // Often 'users' is implicit. If we don't have it, we might want to generate a placeholder or use 'any'.\n            // For now, let's try to map to generated type if exists, else RecordModel\n        }\n\n        if (this.schema.collections.has(targetCollection)) {\n            targetType = `${this.toPascalCase(targetCollection)}Response`;\n        } else if (targetCollection === 'users') {\n            // Attempt to handle 'users' if it's not explicitly defined but referenced\n            // Check if we generated a 'UsersResponse'. If not, we might be in trouble.\n            // But usually 'users' is part of the schema if we are managing it.\n            // If not, we fall back to RecordModel or generic.\n            // Let's assume if it's missing, we use RecordModel\n             targetType = 'RecordModel';\n        }\n\n        const isMultiple = (field.relation.maxSelect ?? 1) > 1;\n        const expandType = isMultiple ? `${targetType}[]` : targetType;\n\n        // Relation field name in expand is same as field name\n        // However, it is optional in the response if not expanded\n        expandFields.push(`${field.name}?: ${expandType}`);\n      }\n    }\n\n    // Generate Response Interface (with expand)\n    if (expandFields.length > 0) {\n      lines.push(`export interface ${typeName}Response extends ${typeName}Record {`);\n      lines.push(`  expand?: {`);\n      for (const ef of expandFields) {\n        lines.push(`    ${ef};`);\n      }\n      lines.push(`  };`);\n      lines.push(`}`);\n    } else {\n      lines.push(`export type ${typeName}Response = ${typeName}Record;`);\n    }\n\n    return lines.join(\"\\n\");\n  }\n\n  private getFieldType(field: FieldDefinition): string {\n    switch (field.type) {\n      case 'text':\n      case 'email':\n      case 'url':\n      case 'editor':\n      case 'date':\n      case 'autodate':\n        return 'string';\n\n      case 'number':\n        return 'number';\n\n      case 'bool':\n        return 'boolean';\n\n      case 'json':\n        if (field.zodType) {\n          return zodToTs(field.zodType);\n        }\n        return 'any';\n\n      case 'file':\n        if (field.options?.maxSelect && field.options.maxSelect > 1) {\n          return 'string[]';\n        }\n        return 'string';\n\n      case 'select':\n        if (field.options?.values && Array.isArray(field.options.values) && field.options.values.length > 0) {\n          const union = field.options.values.map((v: string) => `\"${v}\"`).join(' | ');\n          if (field.options?.maxSelect && field.options.maxSelect > 1) {\n            return `(${union})[]`;\n          }\n          return union;\n        }\n        if (field.options?.maxSelect && field.options.maxSelect > 1) {\n          return 'string[]';\n        }\n        return 'string';\n\n      case 'relation':\n        if (field.relation?.maxSelect && field.relation.maxSelect > 1) {\n          return 'string[]';\n        }\n        return 'string';\n\n      default:\n        return 'any';\n    }\n  }\n\n  private toPascalCase(str: string): string {\n    return str\n      .replace(PASCAL_CASE_REGEX, (word) => {\n        return word.toUpperCase();\n      })\n      .replace(WORD_SEPARATOR_REGEX, '');\n  }\n\n  /**\n   * Checks if RecordModel is needed as a fallback type for relations\n   * to collections that don't exist in the schema\n   */\n  private checkIfRecordModelNeeded(): boolean {\n    for (const [_, collection] of this.schema.collections) {\n      for (const field of collection.fields) {\n        if (field.type === 'relation' && field.relation) {\n          const targetCollection = field.relation.collection;\n          // If target collection is not in schema, RecordModel will be used\n          if (!this.schema.collections.has(targetCollection)) {\n            return true;\n          }\n        }\n      }\n    }\n    return false;\n  }\n}\n","import { Command } from \"commander\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport { parseSchemaFiles } from \"../../migration/index.js\";\nimport type { SchemaDefinition } from \"../../migration/types.js\";\nimport { TypeGenerator } from \"../../type-gen/generator.js\";\nimport { getSchemaDirectory, loadConfig } from \"../utils/config.js\";\nimport { logDebug, logError, logSection, logSuccess, setVerbosity, withProgress } from \"../utils/logger.js\";\n\nexport async function executeGenerateTypes(options: any): Promise<void> {\n  try {\n    // Set verbosity based on global options\n    const parentOpts = options.parent?.opts?.() || {};\n    if (parentOpts.verbose) {\n      setVerbosity(\"verbose\");\n    } else if (parentOpts.quiet) {\n      setVerbosity(\"quiet\");\n    }\n\n    logDebug(\"Starting type generation...\");\n    logDebug(`Options: ${JSON.stringify(options, null, 2)}`);\n\n    // Load configuration\n    const config = await loadConfig(options);\n    const schemaDir = getSchemaDirectory(config);\n\n    logSection(\"🔍 Analyzing Schema\");\n\n    // Parse schema files\n    const analyzerConfig = {\n      schemaDir,\n      excludePatterns: config.schema.exclude,\n      useCompiledFiles: false,\n    };\n    const currentSchema: SchemaDefinition = await withProgress(\"Parsing Zod schemas...\", () => parseSchemaFiles(analyzerConfig));\n\n    logSuccess(`Found ${currentSchema.collections.size} collection(s)`);\n\n    // Generate types\n    logSection(\"📝 Generating Types\");\n    const generator = new TypeGenerator(currentSchema);\n    const output = await withProgress(\"Generating TypeScript definitions...\", () => Promise.resolve(generator.generate()));\n\n    // Write output file\n    const outputPath = options.output || config.typeGen.outPath;\n    const resolvedPath = path.resolve(process.cwd(), outputPath);\n\n    fs.writeFileSync(resolvedPath, output);\n\n    logSuccess(`Types generated successfully at: ${outputPath}`);\n\n    // Display next steps\n    logSection(\"✅ Next Steps\");\n    console.log();\n    console.log(\"  1. Import types in your application:\");\n    console.log(`     import { TypedPocketBase } from \"./${path.basename(outputPath).replace(/\\.ts$/, '')}\";`);\n    console.log();\n\n  } catch (error) {\n    logError(`Failed to generate types: ${error}`);\n    if (error instanceof Error && error.stack) {\n      console.error();\n      console.error(error.stack);\n    }\n    process.exit(1);\n  }\n}\n\nexport function createGenerateTypesCommand(): Command {\n  return new Command(\"generate-types\")\n    .description(\"Generate TypeScript definitions from Zod schemas\")\n    .option(\"-o, --output <path>\", \"Output file path\")\n    .option(\"--schema-dir <directory>\", \"Directory containing Zod schema files\")\n    .action(executeGenerateTypes);\n}\n","/**\n * Lint command implementation\n *\n * Checks migration files for constructs that work in the simulation engine\n * (and in Node) but not in the goja runtime PocketBase actually uses. A file\n * that replays cleanly here can still fail `pocketbase migrate up`; this is\n * the pass that says so before it happens.\n */\n\nimport chalk from \"chalk\";\nimport { Command } from \"commander\";\nimport * as path from \"path\";\nimport { ConfigurationError } from \"../../migration/errors.js\";\nimport {\n  CollectionStore,\n  discoverMigrations,\n  executeMigrationFile,\n  formatGojaLintFinding,\n  lintMigrationFile,\n  type EngineWarning,\n  type GojaLintResult,\n} from \"../../migration/index.js\";\nimport { getMigrationsDirectory, loadConfig } from \"../utils/config.js\";\nimport { logDebug, logError, logInfo, logSection, logSuccess, logWarning, setVerbosity } from \"../utils/logger.js\";\n\n/**\n * Executes each file so the APIs that resolve to inert stubs are recorded,\n * and folds those warnings into the lint findings.\n *\n * Failures are swallowed: a migration the engine cannot run is a separate\n * problem, reported by generate/status, and it must not stop the lint from\n * reporting what it did find.\n *\n * @param files - Migration files, in the order they would be applied\n * @returns Warnings per file path\n */\nfunction collectExecutionWarnings(files: string[]): Map<string, EngineWarning[]> {\n  const byFile = new Map<string, EngineWarning[]>();\n  const store = new CollectionStore();\n\n  for (const file of files) {\n    try {\n      const result = executeMigrationFile(file, store);\n      byFile.set(file, result.warnings);\n    } catch (error) {\n      logDebug(`Skipping execution of ${path.basename(file)}: ${error}`);\n      byFile.set(file, []);\n    }\n  }\n\n  return byFile;\n}\n\n/**\n * Prints one file's findings\n *\n * @returns True if the file has no error-severity findings\n */\nfunction reportResult(result: GojaLintResult): boolean {\n  const name = path.basename(result.file);\n\n  if (result.findings.length === 0) {\n    logDebug(`✓ ${name}`);\n    return true;\n  }\n\n  const errors = result.findings.filter((finding) => finding.severity === \"error\");\n  const warnings = result.findings.filter((finding) => finding.severity === \"warning\");\n\n  console.log(errors.length > 0 ? chalk.red(`  ✗ ${name}`) : chalk.yellow(`  ! ${name}`));\n  for (const finding of errors) {\n    console.log(chalk.red(`      ${formatGojaLintFinding({ ...finding, file: name })}`));\n  }\n  for (const finding of warnings) {\n    console.log(chalk.yellow(`      ${formatGojaLintFinding({ ...finding, file: name })}`));\n  }\n\n  return errors.length === 0;\n}\n\n/**\n * Executes the lint command\n *\n * @param files - Explicit files to lint; defaults to the migrations directory\n * @param options - Command options\n */\nexport async function executeLint(files: string[], options: any): Promise<void> {\n  try {\n    const parentOpts = options.parent?.opts?.() || {};\n    if (parentOpts.verbose) {\n      setVerbosity(\"verbose\");\n    } else if (parentOpts.quiet) {\n      setVerbosity(\"quiet\");\n    }\n\n    const config = await loadConfig(options);\n    const migrationsDir = getMigrationsDirectory(config);\n\n    const targets =\n      files.length > 0\n        ? files.map((file) => path.resolve(process.cwd(), file))\n        : discoverMigrations(migrationsDir).map((migration) => migration.path);\n\n    logSection(\"🔎 Checking goja Compatibility\");\n    console.log();\n\n    if (targets.length === 0) {\n      logInfo(`No migration files found in ${migrationsDir}`);\n      return;\n    }\n\n    // Stubbed-API warnings only exist once a file has run\n    const warningsByFile =\n      options.execute === false ? new Map<string, EngineWarning[]>() : collectExecutionWarnings(targets);\n\n    const results = targets.map((file) => lintMigrationFile(file, { warnings: warningsByFile.get(file) }));\n    const failed = results.filter((result) => !reportResult(result));\n    const warned = results.filter(\n      (result) => result.ok && result.findings.some((finding) => finding.severity === \"warning\")\n    );\n\n    console.log();\n\n    if (failed.length > 0) {\n      logError(\n        `${failed.length} of ${results.length} migration(s) use JavaScript PocketBase's runtime does not support`\n      );\n      console.log();\n      logInfo(\"Suggestions:\");\n      console.log(\"  • Replace Node-only globals with PocketBase JSVM bindings ($os, $http, $filesystem)\");\n      console.log(\"  • Rewrite async/await as synchronous code — goja migrations run to completion inline\");\n      console.log(\"  • Avoid class fields and private members; assign in the constructor instead\");\n      console.log();\n      process.exit(1);\n    }\n\n    if (warned.length > 0) {\n      logWarning(`${warned.length} migration(s) call APIs the simulation does not model (listed above)`);\n      console.log();\n    }\n\n    logSuccess(`${results.length} migration(s) are goja-compatible`);\n  } catch (error) {\n    if (error instanceof ConfigurationError) {\n      logError(\"Configuration Error\");\n      console.error();\n      console.error(error.getDetailedMessage());\n    } else {\n      logError(`Failed to lint migrations: ${error}`);\n      if (error instanceof Error && error.stack) {\n        console.error(error.stack);\n      }\n    }\n    process.exit(1);\n  }\n}\n\n/**\n * Creates the lint command\n *\n * @returns Commander command instance\n */\nexport function createLintCommand(): Command {\n  return new Command(\"lint\")\n    .description(\"Check migration files for JavaScript PocketBase's goja runtime cannot run\")\n    .argument(\"[files...]\", \"Migration files to lint (defaults to every file in the migrations directory)\")\n    .option(\"-o, --output <directory>\", \"Directory containing migration files\")\n    .option(\"--no-execute\", \"Skip executing the migrations, reporting only what static analysis finds\")\n    .addHelpText(\n      \"after\",\n      `\nExamples:\n  $ pocketbase-migrate lint                              Lint every migration\n  $ pocketbase-migrate lint pb_migrations/1712_seed.js   Lint one file\n  $ pocketbase-migrate lint --no-execute                 Static checks only\n`\n    )\n    .action(executeLint);\n}\n","/**\n * Status command implementation\n * Shows current migration status without generating files\n */\n\nimport chalk from \"chalk\";\nimport { Command } from \"commander\";\nimport {\n  AppliedMigrationsError,\n  categorizeChangesBySeverity,\n  compare,\n  parseSchemaFiles,\n  planMigrationReplay,\n  readAppliedMigrationsIfPresent,\n  type AppliedMigrationsSource,\n  type MigrationPlan,\n} from \"../../migration/index.js\";\nimport { ConfigurationError, SchemaParsingError, SnapshotError } from \"../../migration/errors.js\";\nimport { loadSnapshotWithMigrations } from \"../../migration/snapshot.js\";\nimport type { SchemaDefinition, SchemaDiff, SchemaSnapshot } from \"../../migration/types.js\";\nimport { getDataDirectory, getMigrationsDirectory, getSchemaDirectory, loadConfig } from \"../utils/config.js\";\nimport {\n  formatChangeSummary,\n  formatStatusJson,\n  logDebug,\n  logError,\n  logInfo,\n  logKeyValue,\n  logSection,\n  logSuccess,\n  logTable,\n  setVerbosity,\n  withProgress,\n  type StatusOutput,\n} from \"../utils/logger.js\";\n\n/**\n * Checks if there are any changes in the diff\n *\n * @param diff - Schema diff to check\n * @returns True if there are changes\n */\nfunction hasChanges(diff: SchemaDiff): boolean {\n  return (\n    diff.collectionsToCreate.length > 0 || diff.collectionsToDelete.length > 0 || diff.collectionsToModify.length > 0\n  );\n}\n\n/**\n * Checks if there are any destructive changes\n *\n * @param diff - Schema diff to check\n * @returns True if there are destructive changes\n */\nfunction hasDestructiveChanges(diff: SchemaDiff): boolean {\n  const { destructive } = categorizeChangesBySeverity(diff);\n  return destructive.length > 0;\n}\n\n/**\n * Creates a status output object for JSON mode\n *\n * @param status - Status type\n * @param currentCount - Current schema collection count\n * @param snapshotCount - Snapshot collection count\n * @param diff - Schema diff (optional)\n * @returns Status output object\n */\nfunction createStatusOutput(\n  status: StatusOutput[\"status\"],\n  currentCount: number,\n  snapshotCount: number,\n  diff?: SchemaDiff,\n  plan?: MigrationPlan | null,\n  appliedDiff?: SchemaDiff | null\n): StatusOutput {\n  return {\n    status,\n    collections: {\n      current: currentCount,\n      snapshot: snapshotCount,\n    },\n    changes: {\n      create: diff?.collectionsToCreate.length ?? 0,\n      delete: diff?.collectionsToDelete.length ?? 0,\n      modify: diff?.collectionsToModify.length ?? 0,\n    },\n    destructive: diff ? hasDestructiveChanges(diff) : false,\n    ...(plan?.appliedKnown\n      ? {\n          migrations: {\n            source: plan.appliedOrigin ?? \"\",\n            applied: plan.appliedCount,\n            pending: plan.pending,\n            missing: plan.missing,\n            outOfOrder: plan.outOfOrder,\n            inSync: plan.inSync,\n            ...(appliedDiff\n              ? {\n                  unapplied: {\n                    create: appliedDiff.collectionsToCreate.length,\n                    delete: appliedDiff.collectionsToDelete.length,\n                    modify: appliedDiff.collectionsToModify.length,\n                  },\n                }\n              : {}),\n          },\n        }\n      : {}),\n  };\n}\n\n/**\n * What the applied-migrations lookup produced. `unavailable` is not an error\n * by itself — most checkouts have never run PocketBase — but it does mean\n * `--verify` has nothing to compare against.\n */\ntype AppliedLookup =\n  | { status: \"found\"; applied: AppliedMigrationsSource; plan: MigrationPlan }\n  | { status: \"unavailable\"; dataPath: string }\n  | { status: \"failed\"; dataPath: string; message: string };\n\n/**\n * Reads PocketBase's `_migrations` table and plans the replay against it.\n *\n * @param migrationsDir - Directory holding the migration files\n * @param dataPath - pb_data directory or data.db file\n */\nfunction lookupAppliedMigrations(migrationsDir: string, dataPath: string): AppliedLookup {\n  try {\n    const applied = readAppliedMigrationsIfPresent(dataPath);\n    if (!applied) {\n      return { status: \"unavailable\", dataPath };\n    }\n    return { status: \"found\", applied, plan: planMigrationReplay(migrationsDir, { applied }) };\n  } catch (error) {\n    if (error instanceof AppliedMigrationsError) {\n      return { status: \"failed\", dataPath, message: error.message };\n    }\n    throw error;\n  }\n}\n\n/**\n * The two states `status` compares the schema against.\n */\nexport interface StatusBaselines {\n  /** What every migration file on disk describes — the baseline `generate` uses */\n  previousSnapshot: SchemaSnapshot | null;\n  /**\n   * The schema compared against the state PocketBase is actually in, i.e. the\n   * changes the pending files still owe the database. Null when no database\n   * was read or when disk and the database agree, in which case it would be\n   * identical to the schema comparison.\n   */\n  appliedDiff: SchemaDiff | null;\n}\n\n/**\n * Reconstructs both baselines.\n *\n * Two baselines, two questions, and mixing them up is what makes `status\n * --verify` contradict `generate`:\n *\n * - every file on disk answers \"does my schema still need a migration\n *   written?\". Diffing against the applied-only state instead reports\n *   collections that already have a migration file waiting, and then tells the\n *   user to run `generate` — which correctly writes nothing.\n * - the applied-only state answers \"is the database behind its files?\", which\n *   is reported next to the drift, not as a schema change.\n *\n * @param currentSchema - Schema parsed from the Zod files\n * @param migrationsDir - Directory holding the migration files\n * @param applied - Result of the `_migrations` lookup, if one was made\n */\nexport function loadStatusBaselines(\n  currentSchema: SchemaDefinition,\n  migrationsDir: string,\n  applied: AppliedLookup | null\n): StatusBaselines {\n  const previousSnapshot = loadSnapshotWithMigrations({\n    migrationsPath: migrationsDir,\n  });\n\n  if (applied?.status !== \"found\" || applied.plan.inSync) {\n    return { previousSnapshot, appliedDiff: null };\n  }\n\n  const appliedSnapshot = loadSnapshotWithMigrations({\n    migrationsPath: migrationsDir,\n    appliedMigrations: applied.applied,\n  });\n\n  return { previousSnapshot, appliedDiff: compare(currentSchema, appliedSnapshot) };\n}\n\n/**\n * Prints what the pending migration files will do to the database once\n * applied — the difference between the schema and the state PocketBase is\n * actually in.\n *\n * This is deliberately kept out of the Schema Comparison section: a collection\n * that already has a migration file waiting needs PocketBase to run, not\n * another `generate`.\n *\n * @param appliedDiff - Current schema compared against the applied-only state\n */\nfunction reportUnappliedChanges(appliedDiff: SchemaDiff): void {\n  if (!hasChanges(appliedDiff)) {\n    return;\n  }\n\n  console.log(chalk.gray(\"  The database is behind those files. Applying them will:\"));\n\n  for (const collection of appliedDiff.collectionsToCreate) {\n    console.log(chalk.gray(`    + create ${collection.name} (${collection.type})`));\n  }\n  for (const mod of appliedDiff.collectionsToModify) {\n    console.log(chalk.gray(`    ~ modify ${mod.collection}`));\n  }\n  for (const collection of appliedDiff.collectionsToDelete) {\n    console.log(chalk.gray(`    - delete ${collection.name}`));\n  }\n\n  console.log();\n  console.log(chalk.gray(\"    Start PocketBase to apply them; no new migration is needed.\"));\n  console.log();\n}\n\n/**\n * Prints the disk vs. `_migrations` comparison.\n *\n * @returns True when disk and database agree\n */\nfunction reportAppliedMigrations(plan: MigrationPlan): boolean {\n  logSection(\"🧾 Applied Migrations\");\n  console.log();\n  logKeyValue(\"Database\", plan.appliedOrigin ?? \"unknown\");\n  logKeyValue(\"Applied\", String(plan.appliedCount));\n  logKeyValue(\"Replaying\", String(plan.filesToReplay.length));\n  console.log();\n\n  if (plan.inSync) {\n    logSuccess(\"✓ Every migration file on disk is applied\");\n    return true;\n  }\n\n  if (plan.pending.length > 0) {\n    console.log(chalk.yellow(`  ${plan.pending.length} migration(s) on disk not applied to the database:`));\n    for (const file of plan.pending) {\n      console.log(chalk.yellow(`    + ${file}`));\n    }\n    console.log();\n  }\n\n  if (plan.missing.length > 0) {\n    console.log(chalk.red(`  ${plan.missing.length} applied migration(s) missing from disk:`));\n    for (const file of plan.missing) {\n      console.log(chalk.red(`    - ${file}`));\n    }\n    console.log();\n  }\n\n  if (plan.outOfOrder.length > 0) {\n    console.log(chalk.yellow(\"  Pending migrations authored before an already-applied one:\"));\n    for (const file of plan.outOfOrder) {\n      console.log(chalk.yellow(`    ! ${file}`));\n    }\n    console.log(chalk.gray(\"    They will be applied after migrations with later timestamps.\"));\n    console.log();\n  }\n\n  return false;\n}\n\n/**\n * Displays destructive changes summary\n *\n * @param diff - Schema diff containing changes\n */\nfunction displayDestructiveChangesSummary(diff: SchemaDiff): void {\n  const { destructive, nonDestructive } = categorizeChangesBySeverity(diff);\n\n  if (destructive.length > 0) {\n    logSection(\"⚠️  Destructive Changes\");\n    console.log();\n    for (const change of destructive) {\n      console.log(chalk.red(`  ${change}`));\n    }\n    console.log();\n  }\n\n  if (nonDestructive.length > 0) {\n    logSection(\"✓ Non-Destructive Changes\");\n    console.log();\n    for (const change of nonDestructive) {\n      console.log(chalk.green(`  ${change}`));\n    }\n    console.log();\n  }\n}\n\n/**\n * Displays a detailed change table\n *\n * @param diff - Schema diff containing changes\n */\nfunction displayChangeTable(diff: SchemaDiff): void {\n  const rows: string[][] = [];\n\n  // Add collections to create\n  for (const collection of diff.collectionsToCreate) {\n    rows.push([\n      chalk.green(\"+\"),\n      collection.name,\n      collection.type,\n      `${collection.fields.length} fields`,\n      chalk.green(\"Create\"),\n    ]);\n  }\n\n  // Add collections to delete\n  for (const collection of diff.collectionsToDelete) {\n    rows.push([chalk.red(\"-\"), collection.name, collection.type || \"base\", \"-\", chalk.red(\"Delete\")]);\n  }\n\n  // Add collections to modify\n  for (const mod of diff.collectionsToModify) {\n    const changes: string[] = [];\n    if (mod.fieldsToAdd.length > 0) changes.push(`+${mod.fieldsToAdd.length} fields`);\n    if (mod.fieldsToRemove.length > 0) changes.push(`-${mod.fieldsToRemove.length} fields`);\n    if (mod.fieldsToModify.length > 0) changes.push(`~${mod.fieldsToModify.length} fields`);\n    if (mod.indexesToAdd.length > 0) changes.push(`+${mod.indexesToAdd.length} indexes`);\n    if (mod.indexesToRemove.length > 0) changes.push(`-${mod.indexesToRemove.length} indexes`);\n    if (mod.rulesToUpdate.length > 0) changes.push(`~${mod.rulesToUpdate.length} rules`);\n\n    rows.push([chalk.yellow(\"~\"), mod.collection, \"-\", changes.join(\", \") || \"No changes\", chalk.yellow(\"Modify\")]);\n  }\n\n  if (rows.length > 0) {\n    logTable([\"\", \"Collection\", \"Type\", \"Changes\", \"Action\"], rows);\n  }\n}\n\n/**\n * Executes the status command\n *\n * @param options - Command options\n */\nexport async function executeStatus(options: any): Promise<void> {\n  const isJsonMode = options.json === true;\n\n  try {\n    // Set verbosity based on global options (quiet in JSON mode)\n    if (isJsonMode) {\n      setVerbosity(\"quiet\");\n    } else {\n      const parentOpts = options.parent?.opts?.() || {};\n      if (parentOpts.verbose) {\n        setVerbosity(\"verbose\");\n      } else if (parentOpts.quiet) {\n        setVerbosity(\"quiet\");\n      }\n    }\n\n    logDebug(\"Checking migration status...\");\n    logDebug(`Options: ${JSON.stringify(options, null, 2)}`);\n\n    // Load configuration\n    const config = await loadConfig(options);\n\n    // Get paths\n    const schemaDir = getSchemaDirectory(config);\n    const migrationsDir = getMigrationsDirectory(config);\n\n    logSection(\"🔍 Checking Migration Status\");\n\n    // Parse schema files with full config (including exclude patterns)\n    const analyzerConfig = {\n      schemaDir,\n      excludePatterns: config.schema.exclude,\n      useCompiledFiles: false, // Use source files since we're in development/testing\n    };\n    const currentSchema: SchemaDefinition = await withProgress(\"Parsing Zod schemas...\", () => parseSchemaFiles(analyzerConfig));\n\n    logSuccess(`Found ${currentSchema.collections.size} collection(s) in schema`);\n\n    // Reconstruct state from what PocketBase has actually applied, rather\n    // than from every file on disk, when a database is available to ask\n    const useAppliedMigrations = options.verify === true || typeof options.pbData === \"string\";\n    const applied: AppliedLookup | null = useAppliedMigrations\n      ? lookupAppliedMigrations(migrationsDir, getDataDirectory(config))\n      : null;\n\n    if (applied?.status === \"failed\") {\n      logError(`Could not read applied migrations: ${applied.message}`);\n      process.exit(1);\n    }\n\n    if (applied?.status === \"unavailable\") {\n      logError(`No PocketBase database found at ${applied.dataPath}`);\n      console.error();\n      logInfo(\"Suggestions:\");\n      console.log(\"  • Start PocketBase once so it creates pb_data/data.db\");\n      console.log(\"  • Point at another location with --pb-data <path>\");\n      process.exit(1);\n    }\n\n    logInfo(\"Loading previous snapshot...\");\n    const { previousSnapshot, appliedDiff } = loadStatusBaselines(currentSchema, migrationsDir, applied);\n\n    // Drift is reported before the schema comparison, and fails the command\n    // when it was explicitly asked for — but the rest of the status still\n    // prints, because knowing what else changed is the point of running it\n    if (applied?.status === \"found\" && !isJsonMode) {\n      const inSync = reportAppliedMigrations(applied.plan);\n      if (!inSync) {\n        if (appliedDiff) {\n          reportUnappliedChanges(appliedDiff);\n        }\n        if (options.verify === true) {\n          process.exitCode = 1;\n        }\n      }\n    } else if (applied?.status === \"found\" && !applied.plan.inSync && options.verify === true) {\n      process.exitCode = 1;\n    }\n\n    // Handle first-time setup\n    if (!previousSnapshot) {\n      if (isJsonMode) {\n        const output = createStatusOutput(\n          \"first-time-setup\",\n          currentSchema.collections.size,\n          0,\n          undefined,\n          applied?.status === \"found\" ? applied.plan : null,\n          appliedDiff\n        );\n        console.log(formatStatusJson(output));\n        return;\n      }\n\n      logSection(\"🆕 First-Time Setup Detected\");\n      console.log();\n      logInfo(\"No previous snapshot found. This appears to be a first-time setup.\");\n      console.log();\n      logKeyValue(\"Collections in schema\", String(currentSchema.collections.size));\n      console.log();\n      logInfo('Run \"pocketbase-migrate generate\" to create the initial migration.');\n      return;\n    }\n\n    logSuccess(`Loaded snapshot with ${previousSnapshot.collections.size} collection(s)`);\n\n    // Compare schemas against the migration files, not against the database:\n    // this section answers \"what still needs a migration written?\"\n    logSection(\"📊 Schema Comparison\");\n    if (appliedDiff && !isJsonMode) {\n      console.log(chalk.gray(\"  Compared against the migration files on disk, the same baseline generate uses.\"));\n    }\n    const diff = compare(currentSchema, previousSnapshot);\n\n    // Check if there are any changes\n    if (!hasChanges(diff)) {\n      if (isJsonMode) {\n        const output = createStatusOutput(\n          \"up-to-date\",\n          currentSchema.collections.size,\n          previousSnapshot.collections.size,\n          diff,\n          applied?.status === \"found\" ? applied.plan : null,\n          appliedDiff\n        );\n        console.log(formatStatusJson(output));\n        return;\n      }\n\n      console.log();\n      logSuccess(\"✓ Schema is in sync with the migration files\");\n      logInfo(\"No pending changes detected\");\n      console.log();\n      logKeyValue(\"Collections\", String(currentSchema.collections.size));\n\n      if (appliedDiff && hasChanges(appliedDiff)) {\n        console.log();\n        logInfo(\"The database is still behind those files — see Applied Migrations above.\");\n      }\n      return;\n    }\n\n    // Handle JSON output mode\n    if (isJsonMode) {\n      const output = createStatusOutput(\n        \"changes-pending\",\n        currentSchema.collections.size,\n        previousSnapshot.collections.size,\n        diff,\n        applied?.status === \"found\" ? applied.plan : null,\n        appliedDiff\n      );\n      console.log(formatStatusJson(output));\n      return;\n    }\n\n    // Display change summary\n    console.log();\n    console.log(formatChangeSummary(diff));\n\n    // Display change table in verbose mode\n    logDebug(\"Detailed change table:\");\n    displayChangeTable(diff);\n\n    // Display categorized changes\n    displayDestructiveChangesSummary(diff);\n\n    // Display next steps\n    logSection(\"📝 Next Steps\");\n    console.log();\n    console.log(\"  To generate a migration for these changes, run:\");\n    console.log(chalk.cyan(\"     pocketbase-migrate generate\"));\n    console.log();\n\n    const { destructive } = categorizeChangesBySeverity(diff);\n    if (destructive.length > 0) {\n      console.log(chalk.yellow(\"  ⚠️  Destructive changes detected. Use --force flag when generating:\"));\n      console.log(chalk.cyan(\"     pocketbase-migrate generate --force\"));\n      console.log();\n    }\n  } catch (error) {\n    // Handle specific error types with helpful messages\n    if (error instanceof SchemaParsingError) {\n      logError(\"Schema Parsing Error\");\n      console.error();\n      console.error(error.getDetailedMessage());\n      console.error();\n      logInfo(\"Suggestions:\");\n      console.log(\"  • Make sure your schema files are valid Zod schemas\");\n      console.log('  • Check that each schema file exports a defineCollection()/defineView() result (default export preferred)');\n    } else if (error instanceof SnapshotError) {\n      logError(\"Snapshot Error\");\n      console.error();\n      console.error(error.getDetailedMessage());\n      console.error();\n      logInfo(\"Suggestions:\");\n      console.log(\"  • Check that the snapshot file is not corrupted\");\n      console.log(\"  • Verify file permissions for the snapshot file\");\n    } else if (error instanceof ConfigurationError) {\n      logError(\"Configuration Error\");\n      console.error();\n      console.error(error.getDetailedMessage());\n      console.error();\n      logInfo(\"Suggestions:\");\n      console.log(\"  • Check your configuration file syntax\");\n      console.log(\"  • Verify all paths are correct and accessible\");\n    } else {\n      logError(`Failed to check status: ${error}`);\n      if (error instanceof Error && error.stack) {\n        console.error(error.stack);\n      }\n    }\n    process.exit(1);\n  }\n}\n\n/**\n * Creates the status command\n *\n * @returns Commander command instance\n */\nexport function createStatusCommand(): Command {\n  return new Command(\"status\")\n    .description(\"Show current migration status without generating files\")\n    .option(\"--schema-dir <directory>\", \"Directory containing Zod schema files\")\n    .option(\"--json\", \"Output status as JSON for programmatic use\", false)\n    .option(\n      \"--verify\",\n      \"Compare the migration files on disk against PocketBase's _migrations table and fail on any drift\"\n    )\n    .option(\"--pb-data <path>\", \"PocketBase data directory or data.db file (defaults to pb_data next to migrations)\")\n    .addHelpText(\n      \"after\",\n      `\nExamples:\n  $ pocketbase-migrate status              Check for pending schema changes\n  $ pocketbase-migrate status --json       Output status as JSON\n  $ pocketbase-migrate status --verbose    Show detailed status information\n  $ pocketbase-migrate status --verify     Fail if disk and the database disagree on applied migrations\n`\n    )\n    .action(executeStatus);\n}\n","#!/usr/bin/env node\n\n/**\n * CLI entry point for the migration tool\n * Schema-driven PocketBase migration generator\n */\n\n// Register tsx loader for TypeScript file support\n// This must be imported first to enable TypeScript file loading via dynamic imports\n// tsx/esm registers hooks that allow Node.js to handle .ts files in dynamic imports\nimport \"tsx/esm\";\n\nimport chalk from \"chalk\";\nimport { Command } from \"commander\";\nimport { readFileSync } from \"fs\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport { createGenerateCommand } from \"./commands/generate.js\";\nimport { createGenerateTypesCommand } from \"./commands/generate-types.js\";\nimport { createLintCommand } from \"./commands/lint.js\";\nimport { createStatusCommand } from \"./commands/status.js\";\n\n// Get package version from package.json\nfunction getVersion(): string {\n  try {\n    // Get the directory of the current file\n    const __filename = fileURLToPath(import.meta.url);\n    const __dirname = dirname(__filename);\n\n    // Resolve path to package.json (works from both src and dist)\n    // From dist/cli/migrate.js -> ../../package.json\n    // From src/cli/migrate.ts -> ../../package.json\n    const packageJsonPath = join(__dirname, \"../../package.json\");\n    const packageJson = JSON.parse(readFileSync(packageJsonPath, \"utf-8\"));\n    return packageJson.version || \"0.0.0\";\n  } catch {\n    // Fallback version if package.json cannot be read\n    console.warn(\"Warning: Could not read version from package.json\");\n    return \"0.0.0\";\n  }\n}\n\nconst VERSION = getVersion();\n\n/**\n * Display banner with tool name and version\n */\nfunction displayBanner(): void {\n  console.log();\n  console.log(chalk.cyan.bold(\"  PocketBase Zod Migration Tool\"));\n  console.log(chalk.gray(`  Version ${VERSION}`));\n  console.log();\n}\n\n/**\n * Main CLI program\n */\nconst program = new Command();\n\n// Configure main program\nprogram\n  .name(\"pocketbase-migrate\")\n  .description(\n    \"Schema-driven PocketBase migration tool\\n\\nGenerate type-safe migrations from Zod schemas for PocketBase applications.\"\n  )\n  .version(VERSION, \"-v, --version\", \"Output the current version\")\n  .option(\"-c, --config <path>\", \"Path to configuration file\")\n  .option(\"--verbose\", \"Enable verbose output\")\n  .option(\"--quiet\", \"Suppress non-essential output\")\n  .option(\"--no-color\", \"Disable colored output\")\n  .hook(\"preAction\", (thisCommand) => {\n    // Handle global options before any command runs\n    const opts = thisCommand.opts();\n\n    // Handle no-color option\n    if (opts.color === false) {\n      chalk.level = 0;\n    }\n\n    // Display banner unless quiet mode\n    if (!opts.quiet) {\n      displayBanner();\n    }\n  });\n\n// Add commands\nprogram.addCommand(createGenerateCommand());\nprogram.addCommand(createGenerateTypesCommand());\nprogram.addCommand(createStatusCommand());\nprogram.addCommand(createLintCommand());\n\n// Add examples to help output\nprogram.addHelpText(\n  \"after\",\n  `\n${chalk.bold(\"Examples:\")}\n  $ pocketbase-migrate status              Check for pending schema changes\n  $ pocketbase-migrate generate            Generate migration from schema changes\n  $ pocketbase-migrate generate-types      Generate TypeScript definitions\n  $ pocketbase-migrate generate --force    Generate migration with destructive changes\n  $ pocketbase-migrate lint                Check migrations against PocketBase's goja runtime\n  $ pocketbase-migrate --help              Show this help message\n\n${chalk.bold(\"Configuration:\")}\n  The tool looks for configuration in the following order:\n  1. CLI arguments (highest priority)\n  2. Environment variables (MIGRATION_SCHEMA_DIR, MIGRATION_OUTPUT_DIR, etc.)\n  3. Configuration file (migrate.config.js)\n  4. Default values\n\n${chalk.bold(\"Documentation:\")}\n  For more information, visit: https://github.com/dastron/pocketbase-zod-schema\n`\n);\n\n// Custom error handling\nprogram.exitOverride((err) => {\n  /**\n   * Commander throws on help/version when exitOverride is enabled.\n   * The error codes differ by commander version (e.g. \"commander.helpDisplayed\").\n   * Respect the exitCode whenever it is provided.\n   */\n  const anyErr = err as any;\n\n  // Common help/version codes across commander versions\n  if (anyErr?.code === \"commander.help\" || anyErr?.code === \"commander.helpDisplayed\") {\n    process.exit(0);\n  }\n  if (anyErr?.code === \"commander.version\") {\n    process.exit(0);\n  }\n\n  // Prefer commander-provided exitCode if present\n  if (typeof anyErr?.exitCode === \"number\") {\n    process.exit(anyErr.exitCode);\n  }\n\n  process.exit(1);\n});\n\n// Display help if no command provided\nif (process.argv.length === 2) {\n  displayBanner();\n  program.help();\n}\n\n// Parse command line arguments\nprogram.parse(process.argv);\n"]}