@happyvertical/smrt-core 0.51.24 → 0.51.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/AGENTS.md +8 -0
  2. package/dist/index.js +1 -1
  3. package/dist/manifest/manifest-loader.d.ts +0 -25
  4. package/dist/manifest/manifest-loader.d.ts.map +1 -1
  5. package/dist/manifest/manifest-loader.js +21 -8
  6. package/dist/manifest/manifest-loader.js.map +1 -1
  7. package/dist/manifest/static-manifest.js +1 -1
  8. package/dist/manifest/static-manifest.js.map +1 -1
  9. package/dist/manifest/store.d.ts.map +1 -1
  10. package/dist/manifest/store.js +7 -2
  11. package/dist/manifest/store.js.map +1 -1
  12. package/dist/manifest.json +1 -1
  13. package/dist/object.d.ts.map +1 -1
  14. package/dist/object.js +26 -26
  15. package/dist/object.js.map +1 -1
  16. package/dist/registry/class-registration.d.ts.map +1 -1
  17. package/dist/registry/class-registration.js +31 -11
  18. package/dist/registry/class-registration.js.map +1 -1
  19. package/dist/registry/inheritance-resolver.js +1 -1
  20. package/dist/registry/name-resolver.d.ts.map +1 -1
  21. package/dist/registry/name-resolver.js +11 -0
  22. package/dist/registry/name-resolver.js.map +1 -1
  23. package/dist/registry/schema-builder.d.ts.map +1 -1
  24. package/dist/registry/schema-builder.js +71 -31
  25. package/dist/registry/schema-builder.js.map +1 -1
  26. package/dist/registry/shared-state.js +1 -1
  27. package/dist/registry.d.ts.map +1 -1
  28. package/dist/registry.js +11 -7
  29. package/dist/registry.js.map +1 -1
  30. package/dist/scanner/manifest-generator.js +1 -1
  31. package/dist/smrt-knowledge.json +5 -5
  32. package/dist/testing/database.js +1 -1
  33. package/dist/utils/stack-frames.d.ts +7 -0
  34. package/dist/utils/stack-frames.d.ts.map +1 -1
  35. package/dist/utils/stack-frames.js +21 -2
  36. package/dist/utils/stack-frames.js.map +1 -1
  37. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"name-resolver.js","names":[],"sources":["../../src/registry/name-resolver.ts"],"sourcesContent":["/**\n * Name resolution module for the SMRT ObjectRegistry.\n *\n * Handles class lookup, disambiguation, and qualified name resolution.\n * All functions operate on the shared globalThis state.\n *\n * Release B (#1133): classNameMap is gone — the eagerly-maintained\n * lowercase-simple-name → qualified-key[] index was removed in favor of\n * on-demand iteration over the `classes` Map. Production SMRT apps carry\n * a few hundred classes at most, so the linear scan is negligible and\n * removes an entire class of cache-sync bugs (#584, #847, #951).\n *\n * #3047: hydration resolves names per row, so the scan now runs once per\n * registry generation into a derived (never hand-maintained) index; see\n * `getSimpleNameIndex()` and `registry/generation.ts`.\n *\n * Extracted from registry.ts as part of issue #1006.\n * @see https://github.com/happyvertical/smrt/issues/1006\n * @see https://github.com/happyvertical/smrt/issues/1133\n */\n\nimport { ConfigurationError } from '../errors';\nimport type { QualifiedClassName, SmrtVisibility } from '../scanner/types.js';\nimport {\n createQualifiedName,\n isQualifiedName,\n parseQualifiedName,\n} from '../utils/qualified-names.js';\nimport { getRegistryGeneration } from './generation';\nimport { getClasses, getConstructorIndex, verboseLog } from './shared-state';\nimport type { RegisteredClass, SmrtObjectConstructor } from './types';\n\n// ── Simple-name iteration (replaces classNameMap reads) ─────────────\n\n/**\n * Return every registry key whose registered class has the given simple\n * name (case-insensitive). Replaces the old eagerly-maintained\n * `__smrtRegistryClassNameMap` lookup: we iterate `classes` instead.\n *\n * Cost is O(n) over the classes map; production SMRT apps hold low-\n * hundreds of entries so this is trivially fast. Returned keys preserve\n * insertion order, which makes the \"first match wins\" behavior of the old\n * map-based lookup deterministic in the same way.\n *\n * De-duplicates by RegisteredClass object identity so a class registered\n * under both a simple key and a promoted qualified key (a transitional\n * state during manifest merge) counts as a single entry — matching the\n * old classNameMap's behavior of storing each canonical qualified key once.\n * When that happens, the qualified key wins over the simple one.\n */\nfunction registryKeysBySimpleName(simpleName: string): string[] {\n const keys = getSimpleNameIndex().get(simpleName.toLowerCase());\n return keys ? [...keys] : [];\n}\n\n/**\n * Lower-cased simple name → registry keys, rebuilt once per registry\n * generation (#3047).\n *\n * #1133 removed an eagerly-maintained name index because every writer had to\n * keep it in sync. This one is derived, not maintained: it is rebuilt from\n * the `classes` map whenever the registry generation moves, and every\n * registry mutation bumps the generation (the map itself is\n * generation-tracked; in-place identity changes bump explicitly). Hydration\n * resolves names several times per row, so the O(registered classes) scan\n * per lookup dominated large result sets.\n */\nlet simpleNameIndex:\n | {\n generation: number;\n classes: Map<string, RegisteredClass>;\n keysByName: Map<string, string[]>;\n }\n | undefined;\n\nfunction getSimpleNameIndex(): Map<string, string[]> {\n const classes = getClasses();\n const generation = getRegistryGeneration();\n if (\n simpleNameIndex &&\n simpleNameIndex.generation === generation &&\n simpleNameIndex.classes === classes\n ) {\n return simpleNameIndex.keysByName;\n }\n\n const byName = new Map<string, Map<RegisteredClass, string>>();\n for (const [key, value] of classes.entries()) {\n const lower = value.name?.toLowerCase();\n if (!lower) continue;\n\n let seen = byName.get(lower);\n if (!seen) {\n seen = new Map<RegisteredClass, string>();\n byName.set(lower, seen);\n }\n\n const existing = seen.get(value);\n if (!existing) {\n seen.set(value, key);\n continue;\n }\n\n // Two keys for the same object: prefer the qualified form.\n if (key.includes(':') && !existing.includes(':')) {\n seen.set(value, key);\n }\n }\n\n const keysByName = new Map<string, string[]>();\n for (const [lower, seen] of byName) {\n keysByName.set(lower, [...seen.values()]);\n }\n simpleNameIndex = { generation, classes, keysByName };\n return keysByName;\n}\n\n// ── Lookup functions ────────────────────────────────────────\n\n/**\n * Check if a class is already registered (case-insensitive).\n * Returns the canonical name if found, undefined otherwise. Returns\n * undefined if the simple name is ambiguous across multiple packages.\n */\nexport function getCanonicalClassName(name: string): string | undefined {\n const keys = registryKeysBySimpleName(name);\n if (keys.length === 1) return keys[0];\n // Zero matches, or ambiguous with >1 entries\n return undefined;\n}\n\n/**\n * Check if a class exists by name (case-insensitive).\n */\nexport function hasClassCaseInsensitive(name: string): boolean {\n return getSimpleNameIndex().has(name.toLowerCase());\n}\n\n/**\n * Helper for class lookup with qualified name support.\n *\n * Lookup priority:\n * 1. Direct hit on classes map (works for qualified names as keys)\n * 2. If input contains ':', prefer direct qualified lookup, then fall back\n * to an exact/simple registration when runtime source imports registered\n * the class before package-qualified promotion happened\n * 3. Simple-name iteration by lowercase\n * - Unambiguous (1 match) → return it\n * - Ambiguous (>1 matches) → log warning, return first\n */\nexport function findClass(name: string): RegisteredClass | undefined {\n const classes = getClasses();\n\n // 1. Direct hit on classes map (fast path, works for qualified keys)\n const registered = classes.get(name);\n if (registered) {\n return registered;\n }\n\n // 2. Qualified lookup fallback for source-registered classes.\n // In workspace/dev mode a package can be imported from source before a\n // manifest-promoted qualified key exists. If we already have exactly the\n // requested package or a single unqualified registration for this class\n // name, treat it as the same class instead of forcing node_modules manifest\n // discovery.\n if (isQualifiedName(name)) {\n const { packageName, className } = parseQualifiedName(name);\n const keys = registryKeysBySimpleName(className);\n\n if (keys.length > 0) {\n const exactPackageMatch = keys\n .map((key) => classes.get(key))\n .find((candidate) => candidate?.packageName === packageName);\n\n if (exactPackageMatch) {\n return exactPackageMatch;\n }\n\n if (keys.length === 1) {\n const fallback = classes.get(keys[0]);\n if (fallback && !fallback.packageName) {\n return fallback;\n }\n }\n }\n\n return undefined;\n }\n\n // 3. Simple-name lookup\n const keys = registryKeysBySimpleName(name);\n if (keys.length > 0) {\n if (keys.length === 1) {\n return classes.get(keys[0]);\n }\n // Ambiguous — multiple packages define this class name\n // Return first match but log a warning (use resolveType() for strict behavior)\n verboseLog(\n `[registry] findClass(\"${name}\") is ambiguous — ${keys.length} matches. ` +\n `Use qualified name (e.g., ${keys[0]}) for precision.`,\n );\n return classes.get(keys[0]);\n }\n\n return undefined;\n}\n\n/**\n * Strict class lookup with package-aware disambiguation.\n *\n * Unlike `findClass()` which silently returns the first match when a simple\n * name is ambiguous, this method throws a `ConfigurationError` — making it\n * safe for inheritance-critical paths.\n *\n * @throws {ConfigurationError} When simple name is ambiguous and no package context resolves it\n * @see https://github.com/happyvertical/smrt/issues/1005\n */\nexport function findClassStrict(\n name: string,\n fromPackage?: string,\n): RegisteredClass | undefined {\n const classes = getClasses();\n\n // 1. Direct hit on classes map (fast path, works for qualified keys)\n const registered = classes.get(name);\n if (registered) {\n return registered;\n }\n\n // 2. If input is a qualified name, no fallback — it's not found\n if (isQualifiedName(name)) {\n return undefined;\n }\n\n // 3. If fromPackage provided, try constructing qualified name for direct lookup\n if (fromPackage) {\n const qualifiedAttempt = createQualifiedName(fromPackage, name);\n const byQualified = classes.get(qualifiedAttempt);\n if (byQualified) {\n return byQualified;\n }\n }\n\n // 4. Simple-name lookup\n const keys = registryKeysBySimpleName(name);\n if (keys.length > 0) {\n if (keys.length === 1) {\n return classes.get(keys[0]);\n }\n // Ambiguous — multiple packages define this class name\n // In strict mode, throw instead of silently returning first match\n throw new ConfigurationError(\n `Ambiguous class name \"${name}\" — found in ${keys.length} packages: ` +\n `${keys.join(', ')}. ` +\n `Use a qualified name (e.g., ${keys[0]}) to disambiguate.`,\n 'CONFIG_AMBIGUOUS_CLASS',\n { className: name, candidates: keys },\n );\n }\n\n return undefined;\n}\n\n/**\n * Qualify an `extends` value with the parent class's package name.\n *\n * @see https://github.com/happyvertical/smrt/issues/1004\n */\nexport function qualifyExtendsName(\n extendsValue: string,\n currentPackage: string,\n): string {\n const classes = getClasses();\n\n // Already qualified → pass through\n if (isQualifiedName(extendsValue)) {\n return extendsValue;\n }\n\n // Skip framework base classes (never registered with qualified names)\n if (\n extendsValue === 'SmrtObject' ||\n extendsValue === 'SmrtClass' ||\n extendsValue === 'SmrtCollection'\n ) {\n return extendsValue;\n }\n\n // Try same-package first (common case: child and parent in same package)\n const samePackageQualified = createQualifiedName(\n currentPackage,\n extendsValue,\n );\n if (classes.has(samePackageQualified)) {\n return samePackageQualified;\n }\n\n // Try to find the parent in any registered package\n const keys = registryKeysBySimpleName(extendsValue);\n if (keys.length === 1) {\n return keys[0];\n }\n\n // Fallback: return unmodified (backward compat)\n return extendsValue;\n}\n\n// ── Public lookup functions ─────────────────────────────────\n\n/**\n * Get a registered class by name (case-insensitive).\n */\nexport function getClass(name: string): RegisteredClass | undefined {\n return findClass(name);\n}\n\n/**\n * Get a registered class by its constructor reference (O(1) WeakMap lookup).\n */\nexport function getClassByConstructor(\n ctor: SmrtObjectConstructor,\n): RegisteredClass | undefined {\n const registeredName = getConstructorIndex().get(ctor);\n if (registeredName) {\n return getClasses().get(registeredName);\n }\n return undefined;\n}\n\n/**\n * Get a registered class by its qualified name (O(1) direct lookup).\n */\nexport function getClassByQualifiedName(\n qualifiedName: string,\n): RegisteredClass | undefined {\n return getClasses().get(qualifiedName);\n}\n\n/**\n * Get a registered class by package name and class name.\n */\nexport function getClassInPackage(\n packageName: string,\n className: string,\n): RegisteredClass | undefined {\n const qualifiedName = createQualifiedName(packageName, className);\n return getClasses().get(qualifiedName);\n}\n\n/**\n * Find all registered classes with a given simple class name.\n */\nexport function findClassesByName(className: string): RegisteredClass[] {\n // A source registration can retain its simple key while manifest hydration\n // adds its canonical qualified key. Both aliases designate one class, so\n // ambiguity means distinct RegisteredClass identities — which is what the\n // index's per-name keys already are (one key per identity).\n const classes = getClasses();\n const matches: RegisteredClass[] = [];\n for (const key of getSimpleNameIndex().get(className.toLowerCase()) ?? []) {\n const registered = classes.get(key);\n if (registered) {\n matches.push(registered);\n }\n }\n return matches;\n}\n\n/**\n * Resolve a short class name to its qualified name.\n * @throws {Error} If no class or ambiguous classes registered\n */\nexport function resolveType(shortName: string): QualifiedClassName {\n // If already qualified, validate and return\n if (shortName.includes(':') && shortName.startsWith('@')) {\n const registered = getClassByQualifiedName(shortName as QualifiedClassName);\n if (!registered) {\n throw new Error(\n `Class \"${shortName}\" is not registered. ` +\n `Make sure the package is installed and the class is decorated with @smrt().`,\n );\n }\n return shortName as QualifiedClassName;\n }\n\n // Find all classes with this short name\n const matches = findClassesByName(shortName);\n\n if (matches.length === 0) {\n throw new Error(\n `Class \"${shortName}\" is not registered. ` +\n `Make sure the package is installed and the class is decorated with @smrt().`,\n );\n }\n\n if (matches.length > 1) {\n const packageList = matches.map((m) => ` - ${m.qualifiedName}`).join('\\n');\n throw new Error(\n `\"${shortName}\" is ambiguous. Found in multiple packages:\\n${packageList}\\n` +\n `Use the fully qualified name instead.`,\n );\n }\n\n return matches[0].qualifiedName as QualifiedClassName;\n}\n\n/**\n * Get all registered classes from a specific package.\n */\nexport function getClassesByPackage(\n packageName: string,\n): Map<string, RegisteredClass> {\n const result = new Map<string, RegisteredClass>();\n\n for (const [name, registered] of getClasses().entries()) {\n if (registered.packageName === packageName) {\n result.set(name, registered);\n }\n }\n\n return result;\n}\n\n/**\n * Get all registered classes with a specific visibility level.\n */\nexport function getClassesByVisibility(\n visibility: SmrtVisibility,\n): Map<string, RegisteredClass> {\n const result = new Map<string, RegisteredClass>();\n\n for (const [name, registered] of getClasses().entries()) {\n const classVisibility = registered.visibility || 'public';\n if (classVisibility === visibility) {\n result.set(name, registered);\n }\n }\n\n return result;\n}\n\n/**\n * Get all public registered classes.\n */\nexport function getPublicClasses(): Map<string, RegisteredClass> {\n return getClassesByVisibility('public');\n}\n\n/**\n * Get all registered classes.\n */\nexport function getAllClasses(): Map<string, RegisteredClass> {\n return new Map(getClasses());\n}\n\n/**\n * Get class names (simple names, deduplicated).\n */\nexport function getClassNames(): string[] {\n const names = Array.from(getClasses().values()).map((entry) => entry.name);\n return Array.from(new Set(names));\n}\n\n/**\n * Get lookup names for every registered class without collapsing\n * cross-package simple-name collisions.\n *\n * Prefer each registration's qualified name when available, fall back to the\n * registry key, then to the simple class name for package-less registrations.\n * De-duplicates aliases that point to the same RegisteredClass object while\n * preserving distinct packages that intentionally share a simple class name.\n */\nexport function getQualifiedClassNames(): string[] {\n const names: string[] = [];\n const seenRegistrations = new Set<RegisteredClass>();\n const seenNames = new Set<string>();\n\n for (const [key, entry] of getClasses().entries()) {\n if (seenRegistrations.has(entry)) {\n continue;\n }\n seenRegistrations.add(entry);\n\n const lookupName = entry.qualifiedName || key || entry.name;\n if (seenNames.has(lookupName)) {\n continue;\n }\n\n seenNames.add(lookupName);\n names.push(lookupName);\n }\n\n return names;\n}\n\n/**\n * Check if a class is registered (case-insensitive).\n */\nexport function hasClass(name: string): boolean {\n return findClass(name) !== undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAS,yBAAyB,YAA8B;CAC9D,MAAM,OAAO,mBAAmB,CAAC,CAAC,IAAI,WAAW,YAAY,CAAC;CAC9D,OAAO,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC;AAC7B;;;;;;;;;;;;;AAcA,IAAI;AAQJ,SAAS,qBAA4C;CACnD,MAAM,UAAU,WAAW;CAC3B,MAAM,aAAa,sBAAsB;CACzC,IACE,mBACA,gBAAgB,eAAe,cAC/B,gBAAgB,YAAY,SAE5B,OAAO,gBAAgB;CAGzB,MAAM,yBAAS,IAAI,IAA0C;CAC7D,KAAK,MAAM,CAAC,KAAK,UAAU,QAAQ,QAAQ,GAAG;EAC5C,MAAM,QAAQ,MAAM,MAAM,YAAY;EACtC,IAAI,CAAC,OAAO;EAEZ,IAAI,OAAO,OAAO,IAAI,KAAK;EAC3B,IAAI,CAAC,MAAM;GACT,uBAAO,IAAI,IAA6B;GACxC,OAAO,IAAI,OAAO,IAAI;EACxB;EAEA,MAAM,WAAW,KAAK,IAAI,KAAK;EAC/B,IAAI,CAAC,UAAU;GACb,KAAK,IAAI,OAAO,GAAG;GACnB;EACF;EAGA,IAAI,IAAI,SAAS,GAAG,KAAK,CAAC,SAAS,SAAS,GAAG,GAC7C,KAAK,IAAI,OAAO,GAAG;CAEvB;CAEA,MAAM,6BAAa,IAAI,IAAsB;CAC7C,KAAK,MAAM,CAAC,OAAO,SAAS,QAC1B,WAAW,IAAI,OAAO,CAAC,GAAG,KAAK,OAAO,CAAC,CAAC;CAE1C,kBAAkB;EAAE;EAAY;EAAS;CAAW;CACpD,OAAO;AACT;;;;;;AASA,SAAgB,sB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AAC,CAAC,CAAC,KAAK,UAAU,MAAM,IAAI;CACzE,OAAO,MAAM,KAAK,IAAI,IAAI,KAAK,CAAC;AAClC;;;;;;;;;;AAWA,SAAgB,yBAAmC;CACjD,MAAM,QAAkB,CAAC;CACzB,MAAM,oCAAoB,IAAI,IAAqB;CACnD,MAAM,4BAAY,IAAI,IAAY;CAElC,KAAK,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,CAAC,QAAQ,GAAG;EACjD,IAAI,kBAAkB,IAAI,KAAK,GAC7B;EAEF,kBAAkB,IAAI,KAAK;EAE3B,MAAM,aAAa,MAAM,iBAAiB,OAAO,MAAM;EACvD,IAAI,UAAU,IAAI,UAAU,GAC1B;EAGF,UAAU,IAAI,UAAU;EACxB,MAAM,KAAK,UAAU;CACvB;CAEA,OAAO;AACT;;;;AAKA,SAAgB,SAAS,MAAuB;CAC9C,OAAO,UAAU,IAAI,MAAM,KAAA;AAC7B"}
1
+ {"version":3,"file":"name-resolver.js","names":[],"sources":["../../src/registry/name-resolver.ts"],"sourcesContent":["/**\n * Name resolution module for the SMRT ObjectRegistry.\n *\n * Handles class lookup, disambiguation, and qualified name resolution.\n * All functions operate on the shared globalThis state.\n *\n * Release B (#1133): classNameMap is gone — the eagerly-maintained\n * lowercase-simple-name → qualified-key[] index was removed in favor of\n * on-demand iteration over the `classes` Map. Production SMRT apps carry\n * a few hundred classes at most, so the linear scan is negligible and\n * removes an entire class of cache-sync bugs (#584, #847, #951).\n *\n * #3047: hydration resolves names per row, so the scan now runs once per\n * registry generation into a derived (never hand-maintained) index; see\n * `getSimpleNameIndex()` and `registry/generation.ts`.\n *\n * Extracted from registry.ts as part of issue #1006.\n * @see https://github.com/happyvertical/smrt/issues/1006\n * @see https://github.com/happyvertical/smrt/issues/1133\n */\n\nimport { ConfigurationError } from '../errors';\nimport {\n getLocalTestManifestCache,\n getManifestCache,\n getTestManifestCache,\n} from '../manifest/store.js';\nimport type { QualifiedClassName, SmrtVisibility } from '../scanner/types.js';\nimport {\n createQualifiedName,\n isQualifiedName,\n parseQualifiedName,\n} from '../utils/qualified-names.js';\nimport { getRegistryGeneration } from './generation';\nimport { getClasses, getConstructorIndex, verboseLog } from './shared-state';\nimport type { RegisteredClass, SmrtObjectConstructor } from './types';\n\n// ── Simple-name iteration (replaces classNameMap reads) ─────────────\n\n/**\n * Return every registry key whose registered class has the given simple\n * name (case-insensitive). Replaces the old eagerly-maintained\n * `__smrtRegistryClassNameMap` lookup: we iterate `classes` instead.\n *\n * Cost is O(n) over the classes map; production SMRT apps hold low-\n * hundreds of entries so this is trivially fast. Returned keys preserve\n * insertion order, which makes the \"first match wins\" behavior of the old\n * map-based lookup deterministic in the same way.\n *\n * De-duplicates by RegisteredClass object identity so a class registered\n * under both a simple key and a promoted qualified key (a transitional\n * state during manifest merge) counts as a single entry — matching the\n * old classNameMap's behavior of storing each canonical qualified key once.\n * When that happens, the qualified key wins over the simple one.\n */\nfunction registryKeysBySimpleName(simpleName: string): string[] {\n const keys = getSimpleNameIndex().get(simpleName.toLowerCase());\n return keys ? [...keys] : [];\n}\n\n/**\n * Lower-cased simple name → registry keys, rebuilt once per registry\n * generation (#3047).\n *\n * #1133 removed an eagerly-maintained name index because every writer had to\n * keep it in sync. This one is derived, not maintained: it is rebuilt from\n * the `classes` map whenever the registry generation moves, and every\n * registry mutation bumps the generation (the map itself is\n * generation-tracked; in-place identity changes bump explicitly). Hydration\n * resolves names several times per row, so the O(registered classes) scan\n * per lookup dominated large result sets.\n */\nlet simpleNameIndex:\n | {\n generation: number;\n classes: Map<string, RegisteredClass>;\n keysByName: Map<string, string[]>;\n }\n | undefined;\n\nfunction getSimpleNameIndex(): Map<string, string[]> {\n const classes = getClasses();\n const generation = getRegistryGeneration();\n if (\n simpleNameIndex &&\n simpleNameIndex.generation === generation &&\n simpleNameIndex.classes === classes\n ) {\n return simpleNameIndex.keysByName;\n }\n\n const byName = new Map<string, Map<RegisteredClass, string>>();\n for (const [key, value] of classes.entries()) {\n const lower = value.name?.toLowerCase();\n if (!lower) continue;\n\n let seen = byName.get(lower);\n if (!seen) {\n seen = new Map<RegisteredClass, string>();\n byName.set(lower, seen);\n }\n\n const existing = seen.get(value);\n if (!existing) {\n seen.set(value, key);\n continue;\n }\n\n // Two keys for the same object: prefer the qualified form.\n if (key.includes(':') && !existing.includes(':')) {\n seen.set(value, key);\n }\n }\n\n const keysByName = new Map<string, string[]>();\n for (const [lower, seen] of byName) {\n keysByName.set(lower, [...seen.values()]);\n }\n simpleNameIndex = { generation, classes, keysByName };\n return keysByName;\n}\n\n// ── Lookup functions ────────────────────────────────────────\n\n/**\n * Check if a class is already registered (case-insensitive).\n * Returns the canonical name if found, undefined otherwise. Returns\n * undefined if the simple name is ambiguous across multiple packages.\n */\nexport function getCanonicalClassName(name: string): string | undefined {\n const keys = registryKeysBySimpleName(name);\n if (keys.length === 1) return keys[0];\n // Zero matches, or ambiguous with >1 entries\n return undefined;\n}\n\n/**\n * Check if a class exists by name (case-insensitive).\n */\nexport function hasClassCaseInsensitive(name: string): boolean {\n return getSimpleNameIndex().has(name.toLowerCase());\n}\n\n/**\n * Helper for class lookup with qualified name support.\n *\n * Lookup priority:\n * 1. Direct hit on classes map (works for qualified names as keys)\n * 2. If input contains ':', prefer direct qualified lookup, then fall back\n * to an exact/simple registration when runtime source imports registered\n * the class before package-qualified promotion happened\n * 3. Simple-name iteration by lowercase\n * - Unambiguous (1 match) → return it\n * - Ambiguous (>1 matches) → log warning, return first\n */\nexport function findClass(name: string): RegisteredClass | undefined {\n const classes = getClasses();\n\n // 1. Direct hit on classes map (fast path, works for qualified keys)\n const registered = classes.get(name);\n if (registered) {\n return registered;\n }\n\n // 2. Qualified lookup fallback for source-registered classes.\n // In workspace/dev mode a package can be imported from source before a\n // manifest-promoted qualified key exists. If we already have exactly the\n // requested package or a single unqualified registration for this class\n // name, treat it as the same class instead of forcing node_modules manifest\n // discovery.\n if (isQualifiedName(name)) {\n const { packageName, className } = parseQualifiedName(name);\n const keys = registryKeysBySimpleName(className);\n\n if (keys.length > 0) {\n const exactPackageMatch = keys\n .map((key) => classes.get(key))\n .find((candidate) => candidate?.packageName === packageName);\n\n if (exactPackageMatch) {\n return exactPackageMatch;\n }\n\n if (keys.length === 1) {\n const fallback = classes.get(keys[0]);\n if (fallback && !fallback.packageName) {\n return fallback;\n }\n }\n }\n\n return undefined;\n }\n\n // 3. Simple-name lookup\n const keys = registryKeysBySimpleName(name);\n if (keys.length > 0) {\n if (keys.length === 1) {\n return classes.get(keys[0]);\n }\n // Ambiguous — multiple packages define this class name\n // Return first match but log a warning (use resolveType() for strict behavior)\n verboseLog(\n `[registry] findClass(\"${name}\") is ambiguous — ${keys.length} matches. ` +\n `Use qualified name (e.g., ${keys[0]}) for precision.`,\n );\n return classes.get(keys[0]);\n }\n\n return undefined;\n}\n\n/**\n * Strict class lookup with package-aware disambiguation.\n *\n * Unlike `findClass()` which silently returns the first match when a simple\n * name is ambiguous, this method throws a `ConfigurationError` — making it\n * safe for inheritance-critical paths.\n *\n * @throws {ConfigurationError} When simple name is ambiguous and no package context resolves it\n * @see https://github.com/happyvertical/smrt/issues/1005\n */\nexport function findClassStrict(\n name: string,\n fromPackage?: string,\n): RegisteredClass | undefined {\n const classes = getClasses();\n\n // 1. Direct hit on classes map (fast path, works for qualified keys)\n const registered = classes.get(name);\n if (registered) {\n return registered;\n }\n\n // 2. If input is a qualified name, no fallback — it's not found\n if (isQualifiedName(name)) {\n return undefined;\n }\n\n // 3. If fromPackage provided, try constructing qualified name for direct lookup\n if (fromPackage) {\n const qualifiedAttempt = createQualifiedName(fromPackage, name);\n const byQualified = classes.get(qualifiedAttempt);\n if (byQualified) {\n return byQualified;\n }\n }\n\n // 4. Simple-name lookup\n const keys = registryKeysBySimpleName(name);\n if (keys.length > 0) {\n if (keys.length === 1) {\n return classes.get(keys[0]);\n }\n // Ambiguous — multiple packages define this class name\n // In strict mode, throw instead of silently returning first match\n throw new ConfigurationError(\n `Ambiguous class name \"${name}\" — found in ${keys.length} packages: ` +\n `${keys.join(', ')}. ` +\n `Use a qualified name (e.g., ${keys[0]}) to disambiguate.`,\n 'CONFIG_AMBIGUOUS_CLASS',\n { className: name, candidates: keys },\n );\n }\n\n return undefined;\n}\n\n/**\n * Qualify an `extends` value with the parent class's package name.\n *\n * @see https://github.com/happyvertical/smrt/issues/1004\n */\nexport function qualifyExtendsName(\n extendsValue: string,\n currentPackage: string,\n): string {\n const classes = getClasses();\n\n // Already qualified → pass through\n if (isQualifiedName(extendsValue)) {\n return extendsValue;\n }\n\n // Skip framework base classes (never registered with qualified names)\n if (\n extendsValue === 'SmrtObject' ||\n extendsValue === 'SmrtClass' ||\n extendsValue === 'SmrtCollection'\n ) {\n return extendsValue;\n }\n\n // Try same-package first (common case: child and parent in same package)\n const samePackageQualified = createQualifiedName(\n currentPackage,\n extendsValue,\n );\n if (classes.has(samePackageQualified)) {\n return samePackageQualified;\n }\n\n // The package's own manifest declares the parent but it is not registered\n // yet (manifest entries register in file order, so a subclass can precede\n // its base). It is still this package's class: another package's\n // same-named registration must not become the parent (#3098).\n const ownManifests = [\n getManifestCache().get(currentPackage),\n getLocalTestManifestCache(),\n getTestManifestCache(),\n ];\n if (\n ownManifests.some((manifest) => {\n if (manifest?.packageName !== currentPackage) return false;\n const entry = manifest.objects?.[samePackageQualified];\n // An entry that itself extends this simple name is the subclass being\n // registered (a same-named child of another package's base, e.g.\n // support's ServiceTimeEntry), not a base of its own package.\n const entryParent = entry?.extends?.split(':').pop();\n return !!entry && entryParent !== extendsValue;\n })\n ) {\n return samePackageQualified;\n }\n\n // Try to find the parent in any registered package\n const keys = registryKeysBySimpleName(extendsValue);\n if (keys.length === 1) {\n return keys[0];\n }\n\n // Fallback: return unmodified (backward compat)\n return extendsValue;\n}\n\n// ── Public lookup functions ─────────────────────────────────\n\n/**\n * Get a registered class by name (case-insensitive).\n */\nexport function getClass(name: string): RegisteredClass | undefined {\n return findClass(name);\n}\n\n/**\n * Get a registered class by its constructor reference (O(1) WeakMap lookup).\n */\nexport function getClassByConstructor(\n ctor: SmrtObjectConstructor,\n): RegisteredClass | undefined {\n const registeredName = getConstructorIndex().get(ctor);\n if (registeredName) {\n return getClasses().get(registeredName);\n }\n return undefined;\n}\n\n/**\n * Get a registered class by its qualified name (O(1) direct lookup).\n */\nexport function getClassByQualifiedName(\n qualifiedName: string,\n): RegisteredClass | undefined {\n return getClasses().get(qualifiedName);\n}\n\n/**\n * Get a registered class by package name and class name.\n */\nexport function getClassInPackage(\n packageName: string,\n className: string,\n): RegisteredClass | undefined {\n const qualifiedName = createQualifiedName(packageName, className);\n return getClasses().get(qualifiedName);\n}\n\n/**\n * Find all registered classes with a given simple class name.\n */\nexport function findClassesByName(className: string): RegisteredClass[] {\n // A source registration can retain its simple key while manifest hydration\n // adds its canonical qualified key. Both aliases designate one class, so\n // ambiguity means distinct RegisteredClass identities — which is what the\n // index's per-name keys already are (one key per identity).\n const classes = getClasses();\n const matches: RegisteredClass[] = [];\n for (const key of getSimpleNameIndex().get(className.toLowerCase()) ?? []) {\n const registered = classes.get(key);\n if (registered) {\n matches.push(registered);\n }\n }\n return matches;\n}\n\n/**\n * Resolve a short class name to its qualified name.\n * @throws {Error} If no class or ambiguous classes registered\n */\nexport function resolveType(shortName: string): QualifiedClassName {\n // If already qualified, validate and return\n if (shortName.includes(':') && shortName.startsWith('@')) {\n const registered = getClassByQualifiedName(shortName as QualifiedClassName);\n if (!registered) {\n throw new Error(\n `Class \"${shortName}\" is not registered. ` +\n `Make sure the package is installed and the class is decorated with @smrt().`,\n );\n }\n return shortName as QualifiedClassName;\n }\n\n // Find all classes with this short name\n const matches = findClassesByName(shortName);\n\n if (matches.length === 0) {\n throw new Error(\n `Class \"${shortName}\" is not registered. ` +\n `Make sure the package is installed and the class is decorated with @smrt().`,\n );\n }\n\n if (matches.length > 1) {\n const packageList = matches.map((m) => ` - ${m.qualifiedName}`).join('\\n');\n throw new Error(\n `\"${shortName}\" is ambiguous. Found in multiple packages:\\n${packageList}\\n` +\n `Use the fully qualified name instead.`,\n );\n }\n\n return matches[0].qualifiedName as QualifiedClassName;\n}\n\n/**\n * Get all registered classes from a specific package.\n */\nexport function getClassesByPackage(\n packageName: string,\n): Map<string, RegisteredClass> {\n const result = new Map<string, RegisteredClass>();\n\n for (const [name, registered] of getClasses().entries()) {\n if (registered.packageName === packageName) {\n result.set(name, registered);\n }\n }\n\n return result;\n}\n\n/**\n * Get all registered classes with a specific visibility level.\n */\nexport function getClassesByVisibility(\n visibility: SmrtVisibility,\n): Map<string, RegisteredClass> {\n const result = new Map<string, RegisteredClass>();\n\n for (const [name, registered] of getClasses().entries()) {\n const classVisibility = registered.visibility || 'public';\n if (classVisibility === visibility) {\n result.set(name, registered);\n }\n }\n\n return result;\n}\n\n/**\n * Get all public registered classes.\n */\nexport function getPublicClasses(): Map<string, RegisteredClass> {\n return getClassesByVisibility('public');\n}\n\n/**\n * Get all registered classes.\n */\nexport function getAllClasses(): Map<string, RegisteredClass> {\n return new Map(getClasses());\n}\n\n/**\n * Get class names (simple names, deduplicated).\n */\nexport function getClassNames(): string[] {\n const names = Array.from(getClasses().values()).map((entry) => entry.name);\n return Array.from(new Set(names));\n}\n\n/**\n * Get lookup names for every registered class without collapsing\n * cross-package simple-name collisions.\n *\n * Prefer each registration's qualified name when available, fall back to the\n * registry key, then to the simple class name for package-less registrations.\n * De-duplicates aliases that point to the same RegisteredClass object while\n * preserving distinct packages that intentionally share a simple class name.\n */\nexport function getQualifiedClassNames(): string[] {\n const names: string[] = [];\n const seenRegistrations = new Set<RegisteredClass>();\n const seenNames = new Set<string>();\n\n for (const [key, entry] of getClasses().entries()) {\n if (seenRegistrations.has(entry)) {\n continue;\n }\n seenRegistrations.add(entry);\n\n const lookupName = entry.qualifiedName || key || entry.name;\n if (seenNames.has(lookupName)) {\n continue;\n }\n\n seenNames.add(lookupName);\n names.push(lookupName);\n }\n\n return names;\n}\n\n/**\n * Check if a class is registered (case-insensitive).\n */\nexport function hasClass(name: string): boolean {\n return findClass(name)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EAAE,MAAM,GAAG,MAAM,CAEvE;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,EACpC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAsHlC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,eAAe,CAAC,MAAM,CAAC,GACjC,WAAW,CAqBb"}
@@ -1,13 +1,15 @@
1
+ import { ConfigurationError } from "../errors.js";
1
2
  import { requireForeignKeyAction, resolveForeignKeyDeleteAction } from "../schema/foreign-key-policy.js";
2
3
  import { classnameToTablename, toSnakeCase } from "../utils/naming.js";
3
4
  import { formatDefaultValue as formatDefaultValue$1, quoteIdentifier } from "../schema/sql-identifiers.js";
4
5
  import { shortenIdentifier } from "../schema/index-utils.js";
5
6
  import { renderForeignKeyConstraint, schemaForeignKeys } from "../schema/foreign-key-ddl.js";
6
7
  import { getDDLStrategy } from "../schema/ddl/index.js";
8
+ import { isQualifiedName, parseQualifiedName } from "../utils/qualified-names.js";
7
9
  import { getClasses, getCollectionTableNames } from "./shared-state.js";
8
- import { findClass } from "./name-resolver.js";
9
10
  import { conflictIndexName, nullableConflictIdentity } from "../schema/conflict-target.js";
10
11
  import { normalizeBackfill } from "../schema/backfill.js";
12
+ import { findClass } from "./name-resolver.js";
11
13
  import "../utils.js";
12
14
  import { isFrameworkBaseClass } from "./framework-base-classes.js";
13
15
  import { readFieldAttribute } from "./manifest-field-merge.js";
@@ -311,6 +313,41 @@ function resolveContributorTable(registered, fallbackName) {
311
313
  };
312
314
  }
313
315
  /**
316
+ * Reject a table claimed by two unrelated classes (#3098).
317
+ *
318
+ * Classes share a physical table only as one single-table-inheritance family,
319
+ * identified by its STI base. Anything else — two packages that both declare
320
+ * `Account` and both derive `accounts`, or an explicit `tableName` reused by an
321
+ * unrelated class — would be merged into one union table whose rows each
322
+ * package's unscoped queries then return as its own. An unqualified (source)
323
+ * registration and a package-qualified one of the same class are the same
324
+ * family, not a conflict.
325
+ */
326
+ function assertSingleTableFamily(tableName, contributors) {
327
+ const families = /* @__PURE__ */ new Map();
328
+ for (const contributor of contributors) {
329
+ const familyKey = contributor.conflictKey;
330
+ if (families.has(familyKey)) continue;
331
+ families.set(familyKey, isQualifiedName(familyKey) ? (() => {
332
+ const parsed = parseQualifiedName(familyKey);
333
+ return {
334
+ className: parsed.className,
335
+ pkg: parsed.packageName
336
+ };
337
+ })() : { className: familyKey });
338
+ }
339
+ const distinct = [...families.entries()];
340
+ for (let i = 0; i < distinct.length; i++) for (let j = i + 1; j < distinct.length; j++) {
341
+ const [leftKey, left] = distinct[i];
342
+ const [rightKey, right] = distinct[j];
343
+ if (left.className === right.className && (!left.pkg || !right.pkg || left.pkg === right.pkg)) continue;
344
+ throw new ConfigurationError(`Table '${tableName}' is claimed by unrelated classes ${leftKey} and ${rightKey}. Classes share a table only as one single-table-inheritance family; give one of them its own @smrt({ tableName }).`, "CONFIG_TABLE_NAME_COLLISION", {
345
+ tableName,
346
+ classes: [leftKey, rightKey]
347
+ });
348
+ }
349
+ }
350
+ /**
314
351
  * Order the classes that share one table deterministically.
315
352
  *
316
353
  * The first contributor seeds the table: it supplies the base columns, the
@@ -349,37 +386,40 @@ function buildMergedTableSchemas() {
349
386
  else contributorsByTable.set(resolved.tableName, [resolved.contributor]);
350
387
  }
351
388
  const tableSchemas = {};
352
- for (const [tableName, contributors] of contributorsByTable) for (const contributor of sortTableContributors(contributors)) {
353
- const { registered, simpleName, isSTI } = contributor;
354
- const conflictColumns = ObjectRegistry.getConflictColumns(contributor.conflictKey);
355
- const columnsToUse = mergeRuntimeFieldColumns(simpleName, registered.schema?.columns, registered.fields, {
356
- stiUnionColumns: isSTI,
357
- conflictColumns
358
- });
359
- let tableSchema = tableSchemas[tableName];
360
- if (!tableSchema) {
361
- tableSchema = {
362
- tableName,
363
- columns: {
364
- ...createBaseColumns(registered, isSTI),
365
- ...columnsToUse
366
- },
367
- indexes: [],
368
- ddl: registered.schema?.ddl || "",
369
- isSTI,
389
+ for (const [tableName, contributors] of contributorsByTable) {
390
+ assertSingleTableFamily(tableName, contributors);
391
+ for (const contributor of sortTableContributors(contributors)) {
392
+ const { registered, simpleName, isSTI } = contributor;
393
+ const conflictColumns = ObjectRegistry.getConflictColumns(contributor.conflictKey);
394
+ const columnsToUse = mergeRuntimeFieldColumns(simpleName, registered.schema?.columns, registered.fields, {
395
+ stiUnionColumns: isSTI,
370
396
  conflictColumns
371
- };
372
- tableSchemas[tableName] = tableSchema;
373
- } else for (const [colName, colDef] of Object.entries(columnsToUse)) if (!tableSchema.columns[colName]) tableSchema.columns[colName] = colDef;
374
- applyContributorForeignKeys(tableSchema, contributor);
375
- const schemaIndexes = registered.schema?.indexes;
376
- if (schemaIndexes && schemaIndexes.length > 0) {
377
- const existingNames = new Set(tableSchema.indexes.map((index) => index.name));
378
- for (const index of schemaIndexes) {
379
- if (typeof index === "string") continue;
380
- if (!existingNames.has(index.name)) {
381
- tableSchema.indexes.push(index);
382
- existingNames.add(index.name);
397
+ });
398
+ let tableSchema = tableSchemas[tableName];
399
+ if (!tableSchema) {
400
+ tableSchema = {
401
+ tableName,
402
+ columns: {
403
+ ...createBaseColumns(registered, isSTI),
404
+ ...columnsToUse
405
+ },
406
+ indexes: [],
407
+ ddl: registered.schema?.ddl || "",
408
+ isSTI,
409
+ conflictColumns
410
+ };
411
+ tableSchemas[tableName] = tableSchema;
412
+ } else for (const [colName, colDef] of Object.entries(columnsToUse)) if (!tableSchema.columns[colName]) tableSchema.columns[colName] = colDef;
413
+ applyContributorForeignKeys(tableSchema, contributor);
414
+ const schemaIndexes = registered.schema?.indexes;
415
+ if (schemaIndexes && schemaIndexes.length > 0) {
416
+ const existingNames = new Set(tableSchema.indexes.map((index) => index.name));
417
+ for (const index of schemaIndexes) {
418
+ if (typeof index === "string") continue;
419
+ if (!existingNames.has(index.name)) {
420
+ tableSchema.indexes.push(index);
421
+ existingNames.add(index.name);
422
+ }
383
423
  }
384
424
  }
385
425
  }
@@ -1 +1 @@
1
- {"version":3,"file":"schema-builder.js","names":[],"sources":["../../src/registry/schema-builder.ts"],"sourcesContent":["/**\n * Schema building logic for the SMRT ObjectRegistry.\n *\n * Extracted from registry.ts as part of issue #1006.\n */\n\nimport { ObjectRegistry } from '../registry';\nimport type { FieldDefinition } from '../scanner/types.js';\nimport { normalizeBackfill } from '../schema/backfill.js';\nimport {\n conflictIndexName,\n nullableConflictIdentity,\n} from '../schema/conflict-target.js';\nimport { getDDLStrategy } from '../schema/ddl/index.js';\nimport type { DatabaseEngine } from '../schema/ddl/types.js';\nimport {\n renderForeignKeyConstraint,\n schemaForeignKeys,\n} from '../schema/foreign-key-ddl.js';\nimport {\n requireForeignKeyAction,\n resolveForeignKeyDeleteAction,\n} from '../schema/foreign-key-policy.js';\nimport { shortenIdentifier } from '../schema/index-utils.js';\nimport {\n formatDefaultValue as formatDefaultValueShared,\n quoteIdentifier,\n} from '../schema/sql-identifiers.js';\nimport type {\n ColumnDefinition,\n IndexDefinition,\n SchemaDefinition,\n SQLDataType,\n} from '../schema/types.js';\nimport { classnameToTablename, toSnakeCase } from '../utils';\nimport {\n type CollectionRegistrationLookup,\n isCollectionRegistration,\n} from './collection-resolution';\nimport { isFrameworkBaseClass } from './framework-base-classes';\nimport { readFieldAttribute } from './manifest-field-merge';\nimport { findClass } from './name-resolver';\nimport { getClasses, getCollectionTableNames } from './shared-state';\nimport type { RegisteredClass } from './types';\n\ntype ForeignKeyAction = NonNullable<\n NonNullable<ColumnDefinition['foreignKey']>['onDelete']\n>;\n\nconst collectionRegistrationLookup: CollectionRegistrationLookup = {\n findClass,\n findClassInPackage: (packageName, className) =>\n ObjectRegistry.getClassInPackage(packageName, className),\n getInheritanceChain: (className) =>\n ObjectRegistry.getInheritanceChain(className),\n};\n\nfunction applyDecoratorSqlTypeOverrides(\n className: string,\n columns: Record<string, ColumnDefinition>,\n): Record<string, ColumnDefinition> {\n const decorators = ObjectRegistry.getFieldDecorators(className);\n if (!decorators.size) {\n return columns;\n }\n\n for (const [fieldName, options] of decorators) {\n if (!options?.sqlType) {\n continue;\n }\n\n const columnName = toSnakeCase(fieldName);\n const existing = columns[columnName];\n if (!existing) {\n continue;\n }\n\n const referenceKind = getReferenceKind(options as FieldDefinition);\n columns[columnName] = {\n ...existing,\n type: String(options.sqlType).toUpperCase() as SQLDataType,\n ...(referenceKind ? { referenceKind } : {}),\n };\n }\n\n return columns;\n}\n\nfunction mergeRuntimeFieldColumns(\n className: string,\n schemaColumns: Record<string, ColumnDefinition> | undefined,\n fields: Map<string, FieldDefinition>,\n options?: FieldsToColumnsOptions,\n): Record<string, ColumnDefinition> {\n const columnsToUse = { ...(schemaColumns || {}) };\n\n if (fields.size > 0) {\n const fieldColumns = fieldsToColumns(fields, options);\n for (const [columnName, columnDef] of Object.entries(fieldColumns)) {\n if (!columnsToUse[columnName]) {\n columnsToUse[columnName] = columnDef;\n }\n }\n\n for (const [fieldName, fieldDef] of fields) {\n const columnName = toSnakeCase(fieldName);\n const existing = columnsToUse[columnName];\n if (!existing) {\n continue;\n }\n\n const sqlType =\n fieldDef._meta?.sqlType ||\n (fieldDef as unknown as { sqlType?: string }).sqlType;\n const referenceKind = getReferenceKind(fieldDef);\n // #3008: the per-row backfill lives in field metadata only; overlay it\n // onto manifest-sourced columns too so db:migrate always sees it.\n const backfill = normalizeBackfill(fieldDef._meta?.backfill);\n columnsToUse[columnName] = {\n ...existing,\n ...(sqlType\n ? { type: String(sqlType).toUpperCase() as SQLDataType }\n : {}),\n ...(referenceKind ? { referenceKind } : {}),\n ...(backfill !== undefined ? { backfill } : {}),\n };\n }\n }\n\n applyDecoratorSqlTypeOverrides(className, columnsToUse);\n return columnsToUse;\n}\n\nfunction getReferenceKind(\n fieldDef: FieldDefinition,\n): ColumnDefinition['referenceKind'] | undefined {\n if (\n (\n fieldDef as unknown as {\n __tenancy?: { isTenantIdField?: boolean };\n }\n ).__tenancy?.isTenantIdField ||\n fieldDef._meta?.__tenancy?.isTenantIdField\n ) {\n return 'tenantId';\n }\n\n if (fieldDef.type === 'foreignKey') {\n return 'foreignKey';\n }\n\n if (fieldDef.type === 'crossPackageRef') {\n return 'crossPackageRef';\n }\n\n return undefined;\n}\n\nfunction shouldEmitDefault(\n fieldDef: FieldDefinition,\n sqlType: SQLDataType,\n defaultValue: unknown,\n) {\n return !(\n getReferenceKind(fieldDef) === 'tenantId' &&\n sqlType === 'UUID' &&\n defaultValue === ''\n );\n}\n\n/**\n * Fallback base columns for a table whose contributing class carries no\n * manifest columns.\n *\n * These mirror what the manifest schema generators emit for the same table\n * (`generateSchemaFromManifest` / `generateSTISchemaFromManifest`), so a table\n * assembled from runtime field metadata alone has the same NOT NULL and\n * DEFAULT shape as one assembled from a manifest. Divergence here is what made\n * the merged table shape depend on which class registered first (#2372).\n */\nfunction createBaseColumns(\n registered: {\n config?: { idType?: 'uuid' | 'text' };\n },\n isSTI: boolean,\n): Record<string, ColumnDefinition> {\n const baseColumns: Record<string, ColumnDefinition> = {\n id: {\n type: registered.config?.idType === 'text' ? 'TEXT' : 'UUID',\n primaryKey: true,\n notNull: true,\n referenceKind: 'id',\n },\n slug: { type: 'TEXT', notNull: true },\n context: { type: 'TEXT', notNull: true, defaultValue: '' },\n created_at: {\n type: 'TIMESTAMP',\n notNull: true,\n defaultValue: 'current_timestamp',\n },\n updated_at: {\n type: 'TIMESTAMP',\n notNull: true,\n defaultValue: 'current_timestamp',\n },\n };\n\n // STI tables also carry the discriminator and the meta payload column\n // (issue #690: db:diff needs them to detect schema changes).\n if (isSTI) {\n baseColumns._meta_type = { type: 'TEXT', notNull: true };\n baseColumns._meta_data = { type: 'JSON', notNull: false };\n }\n\n return baseColumns;\n}\n\n/**\n * Get cached schema definition for a registered class\n *\n * @param name - Name of the registered class\n * @returns Schema definition or undefined if not found\n * @example\n * ```typescript\n * const schema = getSchema('Product');\n * console.log(schema.tableName); // 'products'\n * console.log(schema.ddl); // 'CREATE TABLE...'\n * ```\n */\nexport function getSchema(name: string): SchemaDefinition | undefined {\n // Issue #951: Use findClass for multi-strategy lookup\n const registered = findClass(name);\n return registered?.schema;\n}\n\n/**\n * Get SQL DDL statement for a registered class\n *\n * @param name - Name of the registered class\n * Cached manifest DDL contains abstract types and is not safe to execute on\n * PostgreSQL. New executable paths must pass a target engine. Omitting it is\n * retained for backward compatibility with consumers that only inspect the\n * legacy engine-neutral manifest string.\n *\n * @param engine - Database engine that will execute the DDL\n * @returns Engine-specific SQL DDL, or the legacy cached DDL when omitted\n * @example\n * ```typescript\n * const ddl = ObjectRegistry.getSchemaDDL('Product', 'postgres');\n * await db.query(ddl);\n * ```\n */\nexport function getSchemaDDL(\n name: string,\n engine?: DatabaseEngine,\n): string | undefined {\n const schema = getSchema(name);\n if (!schema) return undefined;\n if (engine && Object.keys(schema.columns).length === 0) {\n throw new Error(\n `Cannot materialize schema '${name}' for ${engine}: the manifest has no structured columns`,\n );\n }\n return engine\n ? getDDLStrategy(engine).generateCreateTable(schema)\n : schema.ddl;\n}\n\n/**\n * Get table name for a registered class\n *\n * @param name - Name of the registered class\n * @returns Table name or undefined if not found\n * @example\n * ```typescript\n * const tableName = getTableName('Product');\n * console.log(tableName); // 'products'\n * ```\n */\nexport function getTableName(name: string): string | undefined {\n // Check if this is a collection class - collections have their own tableName mapping\n const collectionTableName = getCollectionTableNames().get(name);\n if (collectionTableName) {\n return collectionTableName;\n }\n\n // For STI classes, return the STI base class's table name.\n // R5-canon: `getSTIBase` returns the qualified name; resolve `name`\n // (which may be simple) to its registration's qualified form for the\n // comparison.\n const stiBase = ObjectRegistry.getSTIBase(name);\n const registered = ObjectRegistry.getClass(name);\n const qualifiedName = registered?.qualifiedName ?? registered?.name ?? name;\n if (stiBase && stiBase !== qualifiedName) {\n return getSchema(stiBase)?.tableName;\n }\n return getSchema(name)?.tableName;\n}\n\nfunction withConflictIndex(\n tableName: string,\n columns: Record<string, ColumnDefinition>,\n indexes: IndexDefinition[],\n conflictColumns: string[],\n): IndexDefinition[] {\n if (\n conflictColumns.length === 0 ||\n !conflictColumns.every((column) => columns[column])\n ) {\n return indexes;\n }\n\n // `ON CONFLICT (id)` binds to the primary-key constraint itself; a second\n // unique index over the primary key column set adds nothing (#2359, A5).\n // Kept in step with SchemaGenerator.conflictColumnsArePrimaryKey().\n const primaryKeyColumns = Object.entries(columns)\n .filter(([, column]) => column.primaryKey === true)\n .map(([name]) => name);\n if (\n primaryKeyColumns.length > 0 &&\n primaryKeyColumns.length === conflictColumns.length &&\n primaryKeyColumns.every((column) => conflictColumns.includes(column))\n ) {\n return indexes;\n }\n\n // Same stable naming as SchemaGenerator (`schema/conflict-target.ts`), so\n // a manifest built before the runtime learned the tenant-aware default\n // (#2360) has its stale `<table>_slug_context_idx` REPLACED in place here\n // — the differ then swaps the live index by name — instead of a second,\n // suffixed unique index being appended beside the old global one.\n const tenantColumn = Object.entries(columns).find(\n ([, column]) => column.referenceKind === 'tenantId',\n )?.[0];\n // The composed name can exceed PostgreSQL's 63-byte limit on a long table.\n // Shortening here (rather than inside conflictIndexName) keeps the generator\n // paths, which run enforceIdentifierLimits() over their whole index list,\n // and this migrate leg agreeing on the final name (#2374).\n const name = shortenIdentifier(\n conflictIndexName(tableName, conflictColumns, tenantColumn),\n );\n const canonical = indexes.find((index) => index.name === name);\n if (\n !canonical &&\n indexes.some(\n (index) =>\n index.unique === true &&\n !index.where &&\n !index.jsonPath &&\n index.columns.length === conflictColumns.length &&\n index.columns.every((column) => conflictColumns.includes(column)),\n )\n ) {\n // A user-owned equivalent unique index is not permission to change its NULL semantics.\n return indexes;\n }\n const conflictIndex: IndexDefinition = {\n name,\n columns: conflictColumns,\n unique: true,\n ...(nullableConflictIdentity(conflictColumns, columns)\n ? { nullsNotDistinct: true }\n : {}),\n };\n if (indexes.some((index) => index.name === name)) {\n return indexes.map((index) =>\n index.name === name ? conflictIndex : index,\n );\n }\n return [...indexes, conflictIndex];\n}\n\n/**\n * A registered class that contributes columns to one physical table.\n *\n * For a single-table-inheritance hierarchy every class in the hierarchy is a\n * contributor to the same table.\n */\ninterface TableContributor {\n registered: RegisteredClass;\n simpleName: string;\n qualifiedName: string;\n isSTI: boolean;\n /** True when this class is the STI base that owns the table. */\n isSTIBase: boolean;\n /** Inheritance depth; ancestors sort before descendants. */\n depth: number;\n /** Conflict-column lookup key (the STI base for STI members). */\n conflictKey: string;\n}\n\n/**\n * A merged physical table assembled from every class that contributes to it.\n */\ninterface MergedTableSchema {\n tableName: string;\n columns: Record<string, ColumnDefinition>;\n indexes: IndexDefinition[];\n ddl: string;\n isSTI: boolean;\n conflictColumns: string[];\n}\n\nfunction applyContributorForeignKeys(\n tableSchema: MergedTableSchema,\n contributor: TableContributor,\n): void {\n const conflictColumns = new Set(tableSchema.conflictColumns);\n for (const [fieldName, field] of contributor.registered.fields) {\n if (field.type !== 'foreignKey' || !field.related) continue;\n const columnName = toSnakeCase(fieldName);\n const column = tableSchema.columns[columnName];\n if (!column) continue;\n if (\n field._meta?.__tenancy?.isTenantIdField === true ||\n (\n field as FieldDefinition & {\n __tenancy?: { isTenantIdField?: boolean };\n }\n ).__tenancy?.isTenantIdField === true\n ) {\n column.foreignKey = undefined;\n continue;\n }\n const [legacyTargetName, declaredTargetColumn] = field.related.split('.');\n const resolvedTarget = ObjectRegistry.resolveRelationshipTarget(\n contributor.qualifiedName,\n fieldName,\n );\n if (resolvedTarget === null) {\n throw new Error(\n `Cannot resolve foreign key ${contributor.qualifiedName}.${fieldName}: target constructor is unregistered or the target name is ambiguous`,\n );\n }\n const targetName = resolvedTarget ?? legacyTargetName;\n const targetBase = ObjectRegistry.getSTIBase(targetName) || targetName;\n const registeredTarget = ObjectRegistry.getClass(targetBase);\n const targetColumn =\n declaredTargetColumn ||\n Array.from(ObjectRegistry.getFields(targetBase).entries()).find(\n ([, targetField]) => targetField._meta?.primaryKey === true,\n )?.[0] ||\n 'id';\n if (registeredTarget && !field._meta?.sqlType) {\n const targetColumnName = toSnakeCase(targetColumn);\n const targetColumnType =\n registeredTarget.schema?.columns?.[targetColumnName]?.type ||\n (targetColumnName === 'id'\n ? registeredTarget.config.idType === 'text'\n ? 'TEXT'\n : 'UUID'\n : undefined);\n if (targetColumnType) {\n column.type = targetColumnType;\n }\n }\n if (field._meta?.constraint === false) {\n column.foreignKey = undefined;\n continue;\n }\n // A manifest may carry explicit actions that predate or differ from the\n // runtime decorator defaults. Merging runtime fields must not erase them.\n // The fallback produced from runtime fields, however, must be replaced so\n // conflict columns receive the same default CASCADE as app-side cleanup.\n const manifestForeignKey =\n contributor.registered.schema?.columns?.[columnName]?.foreignKey;\n if (manifestForeignKey) {\n column.foreignKey = manifestForeignKey;\n continue;\n }\n // A decorator-only runtime field has no authoritative physical target\n // until that target is registered. Scanner-produced manifests clear this\n // shape too; only an explicit manifest FK above may survive unloaded\n // runtime classes (the manifest-authority contract from #1120).\n if (!registeredTarget) {\n column.foreignKey = undefined;\n continue;\n }\n const targetTable =\n ObjectRegistry.getTableName(targetBase) ||\n classnameToTablename(targetBase);\n const { action } = resolveForeignKeyDeleteAction({\n declared: field._meta?.onDelete,\n isConflictColumn: conflictColumns.has(columnName),\n isTenantIdField: false,\n });\n column.foreignKey = {\n table: targetTable,\n column: toSnakeCase(targetColumn),\n onDelete: action,\n onUpdate: 'CASCADE',\n ...(typeof field._meta?.constraint === 'object'\n ? { engines: [...field._meta.constraint.engines] }\n : {}),\n };\n }\n}\n\n/**\n * Resolve the physical table a registered class writes to.\n *\n * STI subclasses are folded onto their base's table. Returns `undefined` when\n * the class has no table (for example an unresolvable manifest stub).\n *\n * R5-canon: STI lookups use the qualified key so a colliding simple name in\n * another package cannot yield the wrong table strategy or STI base and move\n * this class's columns under that other package's table.\n */\nfunction resolveContributorTable(\n registered: RegisteredClass,\n fallbackName: string,\n): { tableName: string; contributor: TableContributor } | undefined {\n const simpleName = registered.name || fallbackName;\n const qualifiedName = registered.qualifiedName ?? simpleName;\n\n // STI subclasses loaded from external manifests can arrive with a null\n // tableName; registerFromManifest() then derives one from the class name.\n // Adopt the STI base's tableName instead so the subclass lands on the\n // shared table (issue #703).\n if (!registered.schema?.tableName && registered.extends) {\n if (ObjectRegistry.getTableStrategy(qualifiedName) === 'sti') {\n const stiBaseName = ObjectRegistry.getSTIBase(qualifiedName);\n if (stiBaseName && stiBaseName !== qualifiedName) {\n const stiBaseClass = findClass(stiBaseName);\n if (stiBaseClass?.schema?.tableName) {\n if (!registered.schema) {\n registered.schema = {\n tableName: '',\n ddl: '',\n columns: {},\n indexes: [],\n triggers: [],\n foreignKeys: [],\n dependencies: [],\n version: '',\n };\n }\n registered.schema.tableName = stiBaseClass.schema.tableName;\n }\n }\n }\n }\n\n if (!registered.schema?.tableName) {\n return undefined;\n }\n\n let tableName = registered.schema.tableName;\n const tableStrategy = ObjectRegistry.getTableStrategy(qualifiedName);\n const isSTI = tableStrategy === 'sti';\n let isSTIBase = isSTI;\n let conflictKey = qualifiedName;\n\n if (isSTI) {\n const stiBaseName = ObjectRegistry.getSTIBase(qualifiedName);\n if (stiBaseName) {\n conflictKey = stiBaseName;\n if (stiBaseName !== qualifiedName) {\n isSTIBase = false;\n // STI subclasses serialize to the base class's table even when they\n // carry a tableName of their own (issue #693).\n const stiBaseClass = findClass(stiBaseName);\n if (stiBaseClass?.schema?.tableName) {\n tableName = stiBaseClass.schema.tableName;\n }\n }\n }\n }\n\n return {\n tableName,\n contributor: {\n registered,\n simpleName,\n qualifiedName,\n isSTI,\n isSTIBase,\n depth: ObjectRegistry.getInheritanceChain(qualifiedName).length,\n conflictKey,\n },\n };\n}\n\n/**\n * Order the classes that share one table deterministically.\n *\n * The first contributor seeds the table: it supplies the base columns, the\n * `idType`, the conflict columns and the cached DDL, and its columns win every\n * merge conflict. Registration order must not decide that, or the same\n * hierarchy yields a different table shape depending on which class a manifest\n * happens to list first — child-first dropped NOT NULL and DEFAULT from the\n * base columns (#2372).\n *\n * Order: the STI base first, then ancestors before descendants, then by\n * qualified name so the result is a total order.\n */\nfunction sortTableContributors(contributors: TableContributor[]) {\n return [...contributors].sort((a, b) => {\n if (a.isSTIBase !== b.isSTIBase) {\n return a.isSTIBase ? -1 : 1;\n }\n if (a.depth !== b.depth) {\n return a.depth - b.depth;\n }\n return a.qualifiedName.localeCompare(b.qualifiedName);\n });\n}\n\n/**\n * Assemble every physical table from the classes that contribute to it.\n *\n * Shared by {@link getAllSchemas} and {@link getAllSchemasAsDefinitions} so\n * both produce the same merged shape. The result depends only on what is\n * registered, never on the order it was registered in.\n */\nfunction buildMergedTableSchemas(): Record<string, MergedTableSchema> {\n // Pass 1: group contributing classes by physical table.\n const contributorsByTable = new Map<string, TableContributor[]>();\n\n for (const [className, registered] of getClasses()) {\n // Collection classes have no table of their own; their schemas carry\n // collection properties (loaded, options, ...) rather than columns.\n if (\n isCollectionRegistration(\n className,\n registered,\n collectionRegistrationLookup,\n )\n ) {\n continue;\n }\n\n // Framework abstract base classes (SmrtObject, SmrtClass, ...) are\n // scaffolding, not resources — they produce no table (#2642).\n if (isFrameworkBaseClass(registered.name, registered.packageName)) {\n continue;\n }\n\n const resolved = resolveContributorTable(registered, className);\n if (!resolved) {\n continue;\n }\n\n const existing = contributorsByTable.get(resolved.tableName);\n if (existing) {\n existing.push(resolved.contributor);\n } else {\n contributorsByTable.set(resolved.tableName, [resolved.contributor]);\n }\n }\n\n // Pass 2: merge each table's contributors in deterministic order.\n const tableSchemas: Record<string, MergedTableSchema> = {};\n\n for (const [tableName, contributors] of contributorsByTable) {\n for (const contributor of sortTableContributors(contributors)) {\n const { registered, simpleName, isSTI } = contributor;\n const conflictColumns = ObjectRegistry.getConflictColumns(\n contributor.conflictKey,\n );\n\n // The manifest schema stays authoritative for the columns it defines.\n // Runtime field metadata backfills columns the manifest never had (for\n // example tenantScoped injections) and applies explicit sqlType\n // overrides, without erasing richer manifest metadata.\n const columnsToUse = mergeRuntimeFieldColumns(\n simpleName,\n registered.schema?.columns,\n registered.fields,\n { stiUnionColumns: isSTI, conflictColumns },\n );\n\n let tableSchema = tableSchemas[tableName];\n if (!tableSchema) {\n tableSchema = {\n tableName,\n columns: {\n ...createBaseColumns(registered, isSTI),\n ...columnsToUse,\n },\n indexes: [],\n ddl: registered.schema?.ddl || '',\n isSTI,\n conflictColumns,\n };\n tableSchemas[tableName] = tableSchema;\n } else {\n // Another class sharing this table (STI): add only columns the\n // seeding contributor did not already define.\n for (const [colName, colDef] of Object.entries(columnsToUse)) {\n if (!tableSchema.columns[colName]) {\n tableSchema.columns[colName] = colDef;\n }\n }\n }\n\n applyContributorForeignKeys(tableSchema, contributor);\n\n // Merge indexes, keeping the first definition of each name.\n const schemaIndexes = registered.schema?.indexes;\n if (schemaIndexes && schemaIndexes.length > 0) {\n const existingNames = new Set(\n tableSchema.indexes.map((index) => index.name),\n );\n for (const index of schemaIndexes) {\n // Legacy string-format indexes carry no columns and cannot be merged.\n if (typeof index === 'string') {\n continue;\n }\n if (!existingNames.has(index.name)) {\n tableSchema.indexes.push(index);\n existingNames.add(index.name);\n }\n }\n }\n }\n }\n\n return tableSchemas;\n}\n\n/**\n * Get all pre-generated schemas for explicit adapter bootstrap paths.\n *\n * Returns schemas in SDK SchemaProvider format for all registered classes.\n * Tooling and test helpers can pass these to `getDatabase()` when they want\n * to bootstrap schema before runtime. Core runtime no longer does this\n * implicitly.\n *\n * @returns Record of table names to schema definitions\n * @example\n * ```typescript\n * const schemas = ObjectRegistry.getAllSchemas('json');\n * const db = await getDatabase({ type: 'json', url: './data', schemas });\n * ```\n */\nexport function getAllSchemas(\n engine?: DatabaseEngine,\n): Record<string, { tableName: string; ddl: string; indexes?: string[] }> {\n // Step 1: Assemble every table from its contributing classes. The merge is\n // deterministic, so the shape does not depend on registration order (#2372).\n const tableSchemas = buildMergedTableSchemas();\n\n // Step 2: Convert to output format, regenerating DDL for merged schemas\n const schemas: Record<\n string,\n { tableName: string; ddl: string; indexes?: string[] }\n > = {};\n\n for (const [tableName, tableSchema] of Object.entries(tableSchemas)) {\n const engineIndexes = engine\n ? withConflictIndex(\n tableName,\n tableSchema.columns,\n tableSchema.indexes,\n tableSchema.conflictColumns,\n )\n : tableSchema.indexes;\n const mergedSchema: SchemaDefinition = {\n tableName,\n ddl: tableSchema.ddl,\n columns: tableSchema.columns,\n indexes: engineIndexes,\n triggers: [],\n foreignKeys: [],\n version: '',\n dependencies: [],\n };\n mergedSchema.foreignKeys = schemaForeignKeys(mergedSchema);\n mergedSchema.dependencies = mergedSchema.foreignKeys\n .map((foreignKey) => foreignKey.referencesTable)\n .filter((dependency) => dependency !== tableName);\n\n // Generate DDL from merged columns (or use original DDL if columns are empty)\n let ddl: string;\n if (Object.keys(tableSchema.columns).length === 0 && tableSchema.ddl) {\n if (engine) {\n throw new Error(\n `Cannot materialize schema '${tableName}' for ${engine}: the manifest has no structured columns`,\n );\n }\n // Preserve legacy inspection of cached engine-neutral DDL. Executable\n // target-engine paths fail above rather than returning unsafe SQL.\n ddl = tableSchema.ddl;\n } else if (Object.keys(tableSchema.columns).length === 0) {\n // Skip schemas with no columns and no original DDL\n continue;\n } else if (engine) {\n // Target-engine materialization must route the complete structured\n // schema through its strategy. In particular, DuckDB/JSON require\n // UNIQUE constraints inline for ON CONFLICT, and every strategy owns\n // CHECK/default/index-expression rendering.\n ddl = getDDLStrategy(engine).generateCreateTable(mergedSchema);\n } else {\n ddl = generateDDLFromColumns(\n tableName,\n tableSchema.columns,\n tableSchema.isSTI,\n );\n }\n\n // Convert index definitions to SQL strings for SDK compatibility\n let indexSQL: string[] | undefined;\n if (engineIndexes.length > 0) {\n indexSQL = engine\n ? getDDLStrategy(engine).generateIndexes(mergedSchema)\n : engineIndexes.map((idx) => {\n const indexType = idx.unique ? 'UNIQUE INDEX' : 'INDEX';\n const columnList = idx.columns\n .map((col) => quoteIdentifier(col))\n .join(', ');\n return `CREATE ${indexType} IF NOT EXISTS ${quoteIdentifier(\n idx.name,\n )} ON ${quoteIdentifier(tableName)} (${columnList});`;\n });\n }\n\n schemas[tableName] = {\n tableName,\n ddl,\n indexes: indexSQL,\n };\n }\n\n return schemas;\n}\n\n/**\n * Get all registered schemas as SchemaDefinition objects\n *\n * Similar to getAllSchemas(), but returns SchemaDefinition format suitable\n * for use with SchemaComparer (migrations/differ.ts).\n *\n * Key difference: Indexes are kept as IndexDefinition objects instead of\n * being converted to SQL strings.\n *\n * @returns Map of tableName to SchemaDefinition\n */\nexport function getAllSchemasAsDefinitions(): Record<string, SchemaDefinition> {\n // Step 1: Assemble every table from its contributing classes. The merge is\n // deterministic, so the shape does not depend on registration order (#2372).\n const tableSchemas = buildMergedTableSchemas();\n\n // Step 2: Convert to SchemaDefinition format\n const schemas: Record<string, SchemaDefinition> = {};\n\n for (const [tableName, tableSchema] of Object.entries(tableSchemas)) {\n if (Object.keys(tableSchema.columns).length === 0) {\n continue;\n }\n\n // Generate DDL from columns\n const ddl = generateDDLFromColumns(\n tableName,\n tableSchema.columns,\n tableSchema.isSTI,\n );\n const foreignKeys = schemaForeignKeys({\n columns: tableSchema.columns,\n foreignKeys: [],\n });\n\n schemas[tableName] = {\n tableName,\n ddl,\n columns: tableSchema.columns,\n indexes: withConflictIndex(\n tableName,\n tableSchema.columns,\n tableSchema.indexes,\n tableSchema.conflictColumns,\n ),\n triggers: [],\n foreignKeys,\n version: '',\n dependencies: foreignKeys\n .map((foreignKey) => foreignKey.referencesTable)\n .filter((dependency) => dependency !== tableName),\n };\n }\n\n return schemas;\n}\n\n/**\n * Generate DDL CREATE TABLE statement from columns\n *\n * Used internally by getAllSchemas() to regenerate DDL after merging\n * columns from multiple STI subtypes that share the same table.\n *\n * @param tableName - Name of the table\n * @param columns - Column definitions\n * @returns DDL CREATE TABLE statement\n */\nexport function generateDDLFromColumns(\n tableName: string,\n columns: Record<string, ColumnDefinition>,\n isSTI = false,\n engine?: DatabaseEngine,\n): string {\n let sql = `CREATE TABLE IF NOT EXISTS ${quoteIdentifier(tableName)} (\\n`;\n\n const columnLines: string[] = [];\n for (const [columnName, columnDef] of Object.entries(columns)) {\n const parts: string[] = [];\n\n // Column name and type\n const strategy = engine ? getDDLStrategy(engine) : undefined;\n const columnType = strategy\n ? strategy.mapType(columnDef.type)\n : columnDef.type;\n parts.push(` ${quoteIdentifier(columnName)} ${columnType}`);\n\n // Primary key\n if (columnDef.primaryKey) {\n parts.push('PRIMARY KEY');\n }\n\n // Not null constraint\n if (columnDef.notNull) {\n parts.push('NOT NULL');\n }\n\n // Unique constraint (skip if primary key already implies uniqueness)\n if (columnDef.unique && !columnDef.primaryKey) {\n parts.push('UNIQUE');\n }\n\n // Default value\n if (columnDef.defaultValue !== undefined) {\n const defaultSQL = strategy\n ? strategy.formatDefaultValue(columnDef.defaultValue, columnDef.type)\n : formatDefaultValue(columnDef.defaultValue, columnDef.type);\n parts.push(`DEFAULT ${defaultSQL}`);\n }\n\n columnLines.push(parts.join(' '));\n }\n for (const foreignKey of schemaForeignKeys({ columns, foreignKeys: [] })) {\n columnLines.push(` ${renderForeignKeyConstraint(tableName, foreignKey)}`);\n }\n\n sql += columnLines.join(',\\n');\n\n // Add UNIQUE constraint for UPSERT operations\n // For STI tables: UNIQUE(slug, context, _meta_type) - different types can have same slug+context\n // For non-STI tables: UNIQUE(slug, context)\n if (columns.slug && columns.context) {\n if (isSTI && columns._meta_type) {\n sql += ',\\n UNIQUE(slug, context, _meta_type)';\n } else {\n sql += ',\\n UNIQUE(slug, context)';\n }\n }\n\n sql += '\\n);';\n\n return sql;\n}\n\n/**\n * Format default value for SQL DDL.\n *\n * Thin wrapper over the shared, injection-safe formatter\n * (`schema/sql-identifiers.ts`) so the registry schema-builder uses the same\n * rules as the DDL strategies and schema generator: an allowlist of SQL\n * keyword/function defaults (not \"contains `(`\"), type-driven literal quoting,\n * and no folding of a literal string `\"null\"` into the SQL NULL keyword.\n *\n * @param value - Default value\n * @param type - Column SQL type\n * @returns Formatted SQL default value\n */\nexport function formatDefaultValue(value: unknown, type: string): string {\n return formatDefaultValueShared(value, type);\n}\n\n/**\n * Options for {@link fieldsToColumns}.\n */\nexport interface FieldsToColumnsOptions {\n /**\n * Shape the columns for a single-table-inheritance table.\n *\n * An STI table holds the union of every subtype's fields, so a column that\n * only one subtype declares must stay nullable — rows of sibling subtypes\n * never populate it. This matches `generateSTISchemaFromManifest`, which\n * emits `notNull: false` for every non-system column on an STI table.\n * Declared defaults are still emitted.\n */\n stiUnionColumns?: boolean;\n /**\n * Physical column names that form the table's natural conflict key.\n * Undeclared delete actions on foreign-key members use the shared CASCADE\n * default, matching app-side relationship cleanup.\n */\n conflictColumns?: readonly string[];\n}\n\n/**\n * Convert a Map of field definitions to column definitions\n *\n * Used by getAllSchemas() to generate columns from fields when a class\n * has no pre-generated schema (e.g., STI subclasses registered from manifest).\n *\n * `required`, `default`, and `description` are read from either the top level\n * or `_meta`: registry-sourced fields normalize them into `_meta`, so reading\n * only the top level dropped NOT NULL and DEFAULT for every such field\n * (#2372).\n *\n * @param fields - Map of field name to field definition\n * @param options - Table-shape options (see {@link FieldsToColumnsOptions})\n * @returns Record of column name to column definition\n * @private\n */\nexport function fieldsToColumns(\n fields: Map<string, FieldDefinition>,\n options?: FieldsToColumnsOptions,\n): Record<string, ColumnDefinition> {\n const columns: Record<string, ColumnDefinition> = {};\n const conflictColumns = new Set(\n (options?.conflictColumns ?? []).map((column) => toSnakeCase(column)),\n );\n\n for (const [fieldName, fieldDef] of fields) {\n // Skip id, timestamps - they're on the base table\n if (\n fieldName === 'id' ||\n fieldName === 'created_at' ||\n fieldName === 'updated_at' ||\n fieldName === 'slug' ||\n fieldName === 'context'\n ) {\n continue;\n }\n\n // Skip transient fields (non-persisted)\n if (fieldDef.transient || fieldDef._meta?.transient) {\n continue;\n }\n\n // Skip relationship fields that don't create columns\n // oneToMany and manyToMany are relationship metadata, not actual database columns\n if (fieldDef.type === 'oneToMany' || fieldDef.type === 'manyToMany') {\n continue;\n }\n\n // Skip meta fields - they're stored in _meta_data JSONB column\n if (fieldDef.type === 'meta') {\n continue;\n }\n\n // Map field type to SQL type\n const sqlType =\n fieldDef._meta?.sqlType ||\n (fieldDef.type === 'crossPackageRef' &&\n (fieldDef._meta?.idType === 'text' ||\n (fieldDef as unknown as { idType?: string }).idType === 'text')\n ? 'TEXT'\n : mapFieldTypeToSQL(fieldDef.type));\n const normalizedSqlType = String(sqlType).toUpperCase() as SQLDataType;\n const referenceKind = getReferenceKind(fieldDef);\n\n const required = readFieldAttribute(fieldDef, 'required');\n const defaultValue = readFieldAttribute(fieldDef, 'default');\n const description = readFieldAttribute(fieldDef, 'description');\n\n const column: ColumnDefinition = {\n type: normalizedSqlType,\n referenceKind,\n notNull: options?.stiUnionColumns\n ? false\n : fieldDef._meta?.nullable\n ? false\n : Boolean(required),\n unique: fieldDef._meta?.unique || false,\n description: description as string | undefined,\n };\n\n // Handle default values\n if (\n defaultValue !== undefined &&\n shouldEmitDefault(fieldDef, normalizedSqlType, defaultValue)\n ) {\n column.defaultValue = defaultValue;\n }\n const backfill = normalizeBackfill(fieldDef._meta?.backfill);\n if (backfill !== undefined) {\n column.backfill = backfill;\n }\n\n // Handle foreign keys\n if (\n fieldDef.type === 'foreignKey' &&\n fieldDef.related &&\n fieldDef._meta?.constraint !== false &&\n fieldDef._meta?.__tenancy?.isTenantIdField !== true &&\n !(\n fieldDef as FieldDefinition & {\n __tenancy?: { isTenantIdField?: boolean };\n }\n ).__tenancy?.isTenantIdField\n ) {\n const [table, columnName = 'id'] = fieldDef.related.split('.');\n const fieldMeta = fieldDef._meta as\n | {\n onDelete?: ForeignKeyAction;\n onUpdate?: ForeignKeyAction;\n }\n | undefined;\n column.foreignKey = {\n table: classnameToTablename(table),\n column: columnName,\n onDelete: resolveForeignKeyDeleteAction({\n declared: fieldMeta?.onDelete,\n isConflictColumn: conflictColumns.has(toSnakeCase(fieldName)),\n isTenantIdField: false,\n }).action,\n onUpdate:\n fieldMeta?.onUpdate === undefined\n ? 'CASCADE'\n : requireForeignKeyAction(\n fieldMeta.onUpdate,\n `${fieldName} ON UPDATE`,\n ),\n ...(typeof fieldDef._meta?.constraint === 'object'\n ? { engines: [...fieldDef._meta.constraint.engines] }\n : {}),\n };\n }\n\n // Use snake_case for column names\n columns[toSnakeCase(fieldName)] = column;\n }\n\n return columns;\n}\n\n/**\n * Map field type to SQL data type\n * @private\n */\nexport function mapFieldTypeToSQL(\n fieldType: FieldDefinition['type'],\n): SQLDataType {\n switch (fieldType) {\n case 'text':\n return 'TEXT';\n case 'integer':\n return 'INTEGER';\n case 'decimal':\n return 'REAL';\n case 'boolean':\n return 'BOOLEAN';\n case 'datetime':\n return 'TIMESTAMP';\n case 'json':\n return 'JSON';\n case 'foreignKey':\n return 'UUID';\n case 'crossPackageRef':\n return 'UUID';\n default:\n return 'TEXT';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAiDA,IAAM,+BAA6D;CACjE;CACA,qBAAqB,aAAa,cAChC,eAAe,kBAAkB,aAAa,SAAS;CACzD,sBAAsB,cACpB,eAAe,oBAAoB,SAAS;AAChD;AAEA,SAAS,+BACP,WACA,SACkC;CAClC,MAAM,aAAa,eAAe,mBAAmB,SAAS;CAC9D,IAAI,CAAC,WAAW,MACd,OAAO;CAGT,KAAK,MAAM,CAAC,WAAW,YAAY,YAAY;EAC7C,IAAI,CAAC,SAAS,SACZ;EAGF,MAAM,aAAa,YAAY,SAAS;EACxC,MAAM,WAAW,QAAQ;EACzB,IAAI,CAAC,UACH;EAGF,MAAM,gBAAgB,iBAAiB,OAA0B;EACjE,QAAQ,cAAc;GACpB,GAAG;GACH,MAAM,OAAO,QAAQ,OAAO,CAAC,CAAC,YAAY;GAC1C,GAAI,gBAAgB,EAAE,cAAc,IAAI,CAAC;EAC3C;CACF;CAEA,OAAO;AACT;AAEA,SAAS,y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AGA,QAAQ,YAAY,SAAS,KAAK;CACpC;CAEA,OAAO;AACT;;;;;AAMA,SAAgB,kBACd,WACa;CACb,QAAQ,WAAR;EACE,KAAK,QACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,KAAK,cACH,OAAO;EACT,KAAK,mBACH,OAAO;EACT,SACE,OAAO;CACX;AACF"}
1
+ {"version":3,"file":"schema-builder.js","names":[],"sources":["../../src/registry/schema-builder.ts"],"sourcesContent":["/**\n * Schema building logic for the SMRT ObjectRegistry.\n *\n * Extracted from registry.ts as part of issue #1006.\n */\n\nimport { ConfigurationError } from '../errors';\nimport { ObjectRegistry } from '../registry';\nimport type { FieldDefinition } from '../scanner/types.js';\nimport { normalizeBackfill } from '../schema/backfill.js';\nimport {\n conflictIndexName,\n nullableConflictIdentity,\n} from '../schema/conflict-target.js';\nimport { getDDLStrategy } from '../schema/ddl/index.js';\nimport type { DatabaseEngine } from '../schema/ddl/types.js';\nimport {\n renderForeignKeyConstraint,\n schemaForeignKeys,\n} from '../schema/foreign-key-ddl.js';\nimport {\n requireForeignKeyAction,\n resolveForeignKeyDeleteAction,\n} from '../schema/foreign-key-policy.js';\nimport { shortenIdentifier } from '../schema/index-utils.js';\nimport {\n formatDefaultValue as formatDefaultValueShared,\n quoteIdentifier,\n} from '../schema/sql-identifiers.js';\nimport type {\n ColumnDefinition,\n IndexDefinition,\n SchemaDefinition,\n SQLDataType,\n} from '../schema/types.js';\nimport { classnameToTablename, toSnakeCase } from '../utils';\nimport {\n isQualifiedName,\n parseQualifiedName,\n} from '../utils/qualified-names.js';\nimport {\n type CollectionRegistrationLookup,\n isCollectionRegistration,\n} from './collection-resolution';\nimport { isFrameworkBaseClass } from './framework-base-classes';\nimport { readFieldAttribute } from './manifest-field-merge';\nimport { findClass } from './name-resolver';\nimport { getClasses, getCollectionTableNames } from './shared-state';\nimport type { RegisteredClass } from './types';\n\ntype ForeignKeyAction = NonNullable<\n NonNullable<ColumnDefinition['foreignKey']>['onDelete']\n>;\n\nconst collectionRegistrationLookup: CollectionRegistrationLookup = {\n findClass,\n findClassInPackage: (packageName, className) =>\n ObjectRegistry.getClassInPackage(packageName, className),\n getInheritanceChain: (className) =>\n ObjectRegistry.getInheritanceChain(className),\n};\n\nfunction applyDecoratorSqlTypeOverrides(\n className: string,\n columns: Record<string, ColumnDefinition>,\n): Record<string, ColumnDefinition> {\n const decorators = ObjectRegistry.getFieldDecorators(className);\n if (!decorators.size) {\n return columns;\n }\n\n for (const [fieldName, options] of decorators) {\n if (!options?.sqlType) {\n continue;\n }\n\n const columnName = toSnakeCase(fieldName);\n const existing = columns[columnName];\n if (!existing) {\n continue;\n }\n\n const referenceKind = getReferenceKind(options as FieldDefinition);\n columns[columnName] = {\n ...existing,\n type: String(options.sqlType).toUpperCase() as SQLDataType,\n ...(referenceKind ? { referenceKind } : {}),\n };\n }\n\n return columns;\n}\n\nfunction mergeRuntimeFieldColumns(\n className: string,\n schemaColumns: Record<string, ColumnDefinition> | undefined,\n fields: Map<string, FieldDefinition>,\n options?: FieldsToColumnsOptions,\n): Record<string, ColumnDefinition> {\n const columnsToUse = { ...(schemaColumns || {}) };\n\n if (fields.size > 0) {\n const fieldColumns = fieldsToColumns(fields, options);\n for (const [columnName, columnDef] of Object.entries(fieldColumns)) {\n if (!columnsToUse[columnName]) {\n columnsToUse[columnName] = columnDef;\n }\n }\n\n for (const [fieldName, fieldDef] of fields) {\n const columnName = toSnakeCase(fieldName);\n const existing = columnsToUse[columnName];\n if (!existing) {\n continue;\n }\n\n const sqlType =\n fieldDef._meta?.sqlType ||\n (fieldDef as unknown as { sqlType?: string }).sqlType;\n const referenceKind = getReferenceKind(fieldDef);\n // #3008: the per-row backfill lives in field metadata only; overlay it\n // onto manifest-sourced columns too so db:migrate always sees it.\n const backfill = normalizeBackfill(fieldDef._meta?.backfill);\n columnsToUse[columnName] = {\n ...existing,\n ...(sqlType\n ? { type: String(sqlType).toUpperCase() as SQLDataType }\n : {}),\n ...(referenceKind ? { referenceKind } : {}),\n ...(backfill !== undefined ? { backfill } : {}),\n };\n }\n }\n\n applyDecoratorSqlTypeOverrides(className, columnsToUse);\n return columnsToUse;\n}\n\nfunction getReferenceKind(\n fieldDef: FieldDefinition,\n): ColumnDefinition['referenceKind'] | undefined {\n if (\n (\n fieldDef as unknown as {\n __tenancy?: { isTenantIdField?: boolean };\n }\n ).__tenancy?.isTenantIdField ||\n fieldDef._meta?.__tenancy?.isTenantIdField\n ) {\n return 'tenantId';\n }\n\n if (fieldDef.type === 'foreignKey') {\n return 'foreignKey';\n }\n\n if (fieldDef.type === 'crossPackageRef') {\n return 'crossPackageRef';\n }\n\n return undefined;\n}\n\nfunction shouldEmitDefault(\n fieldDef: FieldDefinition,\n sqlType: SQLDataType,\n defaultValue: unknown,\n) {\n return !(\n getReferenceKind(fieldDef) === 'tenantId' &&\n sqlType === 'UUID' &&\n defaultValue === ''\n );\n}\n\n/**\n * Fallback base columns for a table whose contributing class carries no\n * manifest columns.\n *\n * These mirror what the manifest schema generators emit for the same table\n * (`generateSchemaFromManifest` / `generateSTISchemaFromManifest`), so a table\n * assembled from runtime field metadata alone has the same NOT NULL and\n * DEFAULT shape as one assembled from a manifest. Divergence here is what made\n * the merged table shape depend on which class registered first (#2372).\n */\nfunction createBaseColumns(\n registered: {\n config?: { idType?: 'uuid' | 'text' };\n },\n isSTI: boolean,\n): Record<string, ColumnDefinition> {\n const baseColumns: Record<string, ColumnDefinition> = {\n id: {\n type: registered.config?.idType === 'text' ? 'TEXT' : 'UUID',\n primaryKey: true,\n notNull: true,\n referenceKind: 'id',\n },\n slug: { type: 'TEXT', notNull: true },\n context: { type: 'TEXT', notNull: true, defaultValue: '' },\n created_at: {\n type: 'TIMESTAMP',\n notNull: true,\n defaultValue: 'current_timestamp',\n },\n updated_at: {\n type: 'TIMESTAMP',\n notNull: true,\n defaultValue: 'current_timestamp',\n },\n };\n\n // STI tables also carry the discriminator and the meta payload column\n // (issue #690: db:diff needs them to detect schema changes).\n if (isSTI) {\n baseColumns._meta_type = { type: 'TEXT', notNull: true };\n baseColumns._meta_data = { type: 'JSON', notNull: false };\n }\n\n return baseColumns;\n}\n\n/**\n * Get cached schema definition for a registered class\n *\n * @param name - Name of the registered class\n * @returns Schema definition or undefined if not found\n * @example\n * ```typescript\n * const schema = getSchema('Product');\n * console.log(schema.tableName); // 'products'\n * console.log(schema.ddl); // 'CREATE TABLE...'\n * ```\n */\nexport function getSchema(name: string): SchemaDefinition | undefined {\n // Issue #951: Use findClass for multi-strategy lookup\n const registered = findClass(name);\n return registered?.schema;\n}\n\n/**\n * Get SQL DDL statement for a registered class\n *\n * @param name - Name of the registered class\n * Cached manifest DDL contains abstract types and is not safe to execute on\n * PostgreSQL. New executable paths must pass a target engine. Omitting it is\n * retained for backward compatibility with consumers that only inspect the\n * legacy engine-neutral manifest string.\n *\n * @param engine - Database engine that will execute the DDL\n * @returns Engine-specific SQL DDL, or the legacy cached DDL when omitted\n * @example\n * ```typescript\n * const ddl = ObjectRegistry.getSchemaDDL('Product', 'postgres');\n * await db.query(ddl);\n * ```\n */\nexport function getSchemaDDL(\n name: string,\n engine?: DatabaseEngine,\n): string | undefined {\n const schema = getSchema(name);\n if (!schema) return undefined;\n if (engine && Object.keys(schema.columns).length === 0) {\n throw new Error(\n `Cannot materialize schema '${name}' for ${engine}: the manifest has no structured columns`,\n );\n }\n return engine\n ? getDDLStrategy(engine).generateCreateTable(schema)\n : schema.ddl;\n}\n\n/**\n * Get table name for a registered class\n *\n * @param name - Name of the registered class\n * @returns Table name or undefined if not found\n * @example\n * ```typescript\n * const tableName = getTableName('Product');\n * console.log(tableName); // 'products'\n * ```\n */\nexport function getTableName(name: string): string | undefined {\n // Check if this is a collection class - collections have their own tableName mapping\n const collectionTableName = getCollectionTableNames().get(name);\n if (collectionTableName) {\n return collectionTableName;\n }\n\n // For STI classes, return the STI base class's table name.\n // R5-canon: `getSTIBase` returns the qualified name; resolve `name`\n // (which may be simple) to its registration's qualified form for the\n // comparison.\n const stiBase = ObjectRegistry.getSTIBase(name);\n const registered = ObjectRegistry.getClass(name);\n const qualifiedName = registered?.qualifiedName ?? registered?.name ?? name;\n if (stiBase && stiBase !== qualifiedName) {\n return getSchema(stiBase)?.tableName;\n }\n return getSchema(name)?.tableName;\n}\n\nfunction withConflictIndex(\n tableName: string,\n columns: Record<string, ColumnDefinition>,\n indexes: IndexDefinition[],\n conflictColumns: string[],\n): IndexDefinition[] {\n if (\n conflictColumns.length === 0 ||\n !conflictColumns.every((column) => columns[column])\n ) {\n return indexes;\n }\n\n // `ON CONFLICT (id)` binds to the primary-key constraint itself; a second\n // unique index over the primary key column set adds nothing (#2359, A5).\n // Kept in step with SchemaGenerator.conflictColumnsArePrimaryKey().\n const primaryKeyColumns = Object.entries(columns)\n .filter(([, column]) => column.primaryKey === true)\n .map(([name]) => name);\n if (\n primaryKeyColumns.length > 0 &&\n primaryKeyColumns.length === conflictColumns.length &&\n primaryKeyColumns.every((column) => conflictColumns.includes(column))\n ) {\n return indexes;\n }\n\n // Same stable naming as SchemaGenerator (`schema/conflict-target.ts`), so\n // a manifest built before the runtime learned the tenant-aware default\n // (#2360) has its stale `<table>_slug_context_idx` REPLACED in place here\n // — the differ then swaps the live index by name — instead of a second,\n // suffixed unique index being appended beside the old global one.\n const tenantColumn = Object.entries(columns).find(\n ([, column]) => column.referenceKind === 'tenantId',\n )?.[0];\n // The composed name can exceed PostgreSQL's 63-byte limit on a long table.\n // Shortening here (rather than inside conflictIndexName) keeps the generator\n // paths, which run enforceIdentifierLimits() over their whole index list,\n // and this migrate leg agreeing on the final name (#2374).\n const name = shortenIdentifier(\n conflictIndexName(tableName, conflictColumns, tenantColumn),\n );\n const canonical = indexes.find((index) => index.name === name);\n if (\n !canonical &&\n indexes.some(\n (index) =>\n index.unique === true &&\n !index.where &&\n !index.jsonPath &&\n index.columns.length === conflictColumns.length &&\n index.columns.every((column) => conflictColumns.includes(column)),\n )\n ) {\n // A user-owned equivalent unique index is not permission to change its NULL semantics.\n return indexes;\n }\n const conflictIndex: IndexDefinition = {\n name,\n columns: conflictColumns,\n unique: true,\n ...(nullableConflictIdentity(conflictColumns, columns)\n ? { nullsNotDistinct: true }\n : {}),\n };\n if (indexes.some((index) => index.name === name)) {\n return indexes.map((index) =>\n index.name === name ? conflictIndex : index,\n );\n }\n return [...indexes, conflictIndex];\n}\n\n/**\n * A registered class that contributes columns to one physical table.\n *\n * For a single-table-inheritance hierarchy every class in the hierarchy is a\n * contributor to the same table.\n */\ninterface TableContributor {\n registered: RegisteredClass;\n simpleName: string;\n qualifiedName: string;\n isSTI: boolean;\n /** True when this class is the STI base that owns the table. */\n isSTIBase: boolean;\n /** Inheritance depth; ancestors sort before descendants. */\n depth: number;\n /** Conflict-column lookup key (the STI base for STI members). */\n conflictKey: string;\n}\n\n/**\n * A merged physical table assembled from every class that contributes to it.\n */\ninterface MergedTableSchema {\n tableName: string;\n columns: Record<string, ColumnDefinition>;\n indexes: IndexDefinition[];\n ddl: string;\n isSTI: boolean;\n conflictColumns: string[];\n}\n\nfunction applyContributorForeignKeys(\n tableSchema: MergedTableSchema,\n contributor: TableContributor,\n): void {\n const conflictColumns = new Set(tableSchema.conflictColumns);\n for (const [fieldName, field] of contributor.registered.fields) {\n if (field.type !== 'foreignKey' || !field.related) continue;\n const columnName = toSnakeCase(fieldName);\n const column = tableSchema.columns[columnName];\n if (!column) continue;\n if (\n field._meta?.__tenancy?.isTenantIdField === true ||\n (\n field as FieldDefinition & {\n __tenancy?: { isTenantIdField?: boolean };\n }\n ).__tenancy?.isTenantIdField === true\n ) {\n column.foreignKey = undefined;\n continue;\n }\n const [legacyTargetName, declaredTargetColumn] = field.related.split('.');\n const resolvedTarget = ObjectRegistry.resolveRelationshipTarget(\n contributor.qualifiedName,\n fieldName,\n );\n if (resolvedTarget === null) {\n throw new Error(\n `Cannot resolve foreign key ${contributor.qualifiedName}.${fieldName}: target constructor is unregistered or the target name is ambiguous`,\n );\n }\n const targetName = resolvedTarget ?? legacyTargetName;\n const targetBase = ObjectRegistry.getSTIBase(targetName) || targetName;\n const registeredTarget = ObjectRegistry.getClass(targetBase);\n const targetColumn =\n declaredTargetColumn ||\n Array.from(ObjectRegistry.getFields(targetBase).entries()).find(\n ([, targetField]) => targetField._meta?.primaryKey === true,\n )?.[0] ||\n 'id';\n if (registeredTarget && !field._meta?.sqlType) {\n const targetColumnName = toSnakeCase(targetColumn);\n const targetColumnType =\n registeredTarget.schema?.columns?.[targetColumnName]?.type ||\n (targetColumnName === 'id'\n ? registeredTarget.config.idType === 'text'\n ? 'TEXT'\n : 'UUID'\n : undefined);\n if (targetColumnType) {\n column.type = targetColumnType;\n }\n }\n if (field._meta?.constraint === false) {\n column.foreignKey = undefined;\n continue;\n }\n // A manifest may carry explicit actions that predate or differ from the\n // runtime decorator defaults. Merging runtime fields must not erase them.\n // The fallback produced from runtime fields, however, must be replaced so\n // conflict columns receive the same default CASCADE as app-side cleanup.\n const manifestForeignKey =\n contributor.registered.schema?.columns?.[columnName]?.foreignKey;\n if (manifestForeignKey) {\n column.foreignKey = manifestForeignKey;\n continue;\n }\n // A decorator-only runtime field has no authoritative physical target\n // until that target is registered. Scanner-produced manifests clear this\n // shape too; only an explicit manifest FK above may survive unloaded\n // runtime classes (the manifest-authority contract from #1120).\n if (!registeredTarget) {\n column.foreignKey = undefined;\n continue;\n }\n const targetTable =\n ObjectRegistry.getTableName(targetBase) ||\n classnameToTablename(targetBase);\n const { action } = resolveForeignKeyDeleteAction({\n declared: field._meta?.onDelete,\n isConflictColumn: conflictColumns.has(columnName),\n isTenantIdField: false,\n });\n column.foreignKey = {\n table: targetTable,\n column: toSnakeCase(targetColumn),\n onDelete: action,\n onUpdate: 'CASCADE',\n ...(typeof field._meta?.constraint === 'object'\n ? { engines: [...field._meta.constraint.engines] }\n : {}),\n };\n }\n}\n\n/**\n * Resolve the physical table a registered class writes to.\n *\n * STI subclasses are folded onto their base's table. Returns `undefined` when\n * the class has no table (for example an unresolvable manifest stub).\n *\n * R5-canon: STI lookups use the qualified key so a colliding simple name in\n * another package cannot yield the wrong table strategy or STI base and move\n * this class's columns under that other package's table.\n */\nfunction resolveContributorTable(\n registered: RegisteredClass,\n fallbackName: string,\n): { tableName: string; contributor: TableContributor } | undefined {\n const simpleName = registered.name || fallbackName;\n const qualifiedName = registered.qualifiedName ?? simpleName;\n\n // STI subclasses loaded from external manifests can arrive with a null\n // tableName; registerFromManifest() then derives one from the class name.\n // Adopt the STI base's tableName instead so the subclass lands on the\n // shared table (issue #703).\n if (!registered.schema?.tableName && registered.extends) {\n if (ObjectRegistry.getTableStrategy(qualifiedName) === 'sti') {\n const stiBaseName = ObjectRegistry.getSTIBase(qualifiedName);\n if (stiBaseName && stiBaseName !== qualifiedName) {\n const stiBaseClass = findClass(stiBaseName);\n if (stiBaseClass?.schema?.tableName) {\n if (!registered.schema) {\n registered.schema = {\n tableName: '',\n ddl: '',\n columns: {},\n indexes: [],\n triggers: [],\n foreignKeys: [],\n dependencies: [],\n version: '',\n };\n }\n registered.schema.tableName = stiBaseClass.schema.tableName;\n }\n }\n }\n }\n\n if (!registered.schema?.tableName) {\n return undefined;\n }\n\n let tableName = registered.schema.tableName;\n const tableStrategy = ObjectRegistry.getTableStrategy(qualifiedName);\n const isSTI = tableStrategy === 'sti';\n let isSTIBase = isSTI;\n let conflictKey = qualifiedName;\n\n if (isSTI) {\n const stiBaseName = ObjectRegistry.getSTIBase(qualifiedName);\n if (stiBaseName) {\n conflictKey = stiBaseName;\n if (stiBaseName !== qualifiedName) {\n isSTIBase = false;\n // STI subclasses serialize to the base class's table even when they\n // carry a tableName of their own (issue #693).\n const stiBaseClass = findClass(stiBaseName);\n if (stiBaseClass?.schema?.tableName) {\n tableName = stiBaseClass.schema.tableName;\n }\n }\n }\n }\n\n return {\n tableName,\n contributor: {\n registered,\n simpleName,\n qualifiedName,\n isSTI,\n isSTIBase,\n depth: ObjectRegistry.getInheritanceChain(qualifiedName).length,\n conflictKey,\n },\n };\n}\n\n/**\n * Reject a table claimed by two unrelated classes (#3098).\n *\n * Classes share a physical table only as one single-table-inheritance family,\n * identified by its STI base. Anything else — two packages that both declare\n * `Account` and both derive `accounts`, or an explicit `tableName` reused by an\n * unrelated class — would be merged into one union table whose rows each\n * package's unscoped queries then return as its own. An unqualified (source)\n * registration and a package-qualified one of the same class are the same\n * family, not a conflict.\n */\nfunction assertSingleTableFamily(\n tableName: string,\n contributors: TableContributor[],\n): void {\n const families = new Map<string, { className: string; pkg?: string }>();\n for (const contributor of contributors) {\n const familyKey = contributor.conflictKey;\n if (families.has(familyKey)) continue;\n families.set(\n familyKey,\n isQualifiedName(familyKey)\n ? (() => {\n const parsed = parseQualifiedName(familyKey);\n return { className: parsed.className, pkg: parsed.packageName };\n })()\n : { className: familyKey },\n );\n }\n const distinct = [...families.entries()];\n for (let i = 0; i < distinct.length; i++) {\n for (let j = i + 1; j < distinct.length; j++) {\n const [leftKey, left] = distinct[i];\n const [rightKey, right] = distinct[j];\n const sameClass =\n left.className === right.className &&\n (!left.pkg || !right.pkg || left.pkg === right.pkg);\n if (sameClass) continue;\n throw new ConfigurationError(\n `Table '${tableName}' is claimed by unrelated classes ${leftKey} and ${rightKey}. ` +\n 'Classes share a table only as one single-table-inheritance family; give one of them its own @smrt({ tableName }).',\n 'CONFIG_TABLE_NAME_COLLISION',\n { tableName, classes: [leftKey, rightKey] },\n );\n }\n }\n}\n\n/**\n * Order the classes that share one table deterministically.\n *\n * The first contributor seeds the table: it supplies the base columns, the\n * `idType`, the conflict columns and the cached DDL, and its columns win every\n * merge conflict. Registration order must not decide that, or the same\n * hierarchy yields a different table shape depending on which class a manifest\n * happens to list first — child-first dropped NOT NULL and DEFAULT from the\n * base columns (#2372).\n *\n * Order: the STI base first, then ancestors before descendants, then by\n * qualified name so the result is a total order.\n */\nfunction sortTableContributors(contributors: TableContributor[]) {\n return [...contributors].sort((a, b) => {\n if (a.isSTIBase !== b.isSTIBase) {\n return a.isSTIBase ? -1 : 1;\n }\n if (a.depth !== b.depth) {\n return a.depth - b.depth;\n }\n return a.qualifiedName.localeCompare(b.qualifiedName);\n });\n}\n\n/**\n * Assemble every physical table from the classes that contribute to it.\n *\n * Shared by {@link getAllSchemas} and {@link getAllSchemasAsDefinitions} so\n * both produce the same merged shape. The result depends only on what is\n * registered, never on the order it was registered in.\n */\nfunction buildMergedTableSchemas(): Record<string, MergedTableSchema> {\n // Pass 1: group contributing classes by physical table.\n const contributorsByTable = new Map<string, TableContributor[]>();\n\n for (const [className, registered] of getClasses()) {\n // Collection classes have no table of their own; their schemas carry\n // collection properties (loaded, options, ...) rather than columns.\n if (\n isCollectionRegistration(\n className,\n registered,\n collectionRegistrationLookup,\n )\n ) {\n continue;\n }\n\n // Framework abstract base classes (SmrtObject, SmrtClass, ...) are\n // scaffolding, not resources — they produce no table (#2642).\n if (isFrameworkBaseClass(registered.name, registered.packageName)) {\n continue;\n }\n\n const resolved = resolveContributorTable(registered, className);\n if (!resolved) {\n continue;\n }\n\n const existing = contributorsByTable.get(resolved.tableName);\n if (existing) {\n existing.push(resolved.contributor);\n } else {\n contributorsByTable.set(resolved.tableName, [resolved.contributor]);\n }\n }\n\n // Pass 2: merge each table's contributors in deterministic order.\n const tableSchemas: Record<string, MergedTableSchema> = {};\n\n for (const [tableName, contributors] of contributorsByTable) {\n assertSingleTableFamily(tableName, contributors);\n for (const contributor of sortTableContributors(contributors)) {\n const { registered, simpleName, isSTI } = contributor;\n const conflictColumns = ObjectRegistry.getConflictColumns(\n contributor.conflictKey,\n );\n\n // The manifest schema stays authoritative for the columns it defines.\n // Runtime field metadata backfills columns the manifest never had (for\n // example tenantScoped injections) and applies explicit sqlType\n // overrides, without erasing richer manifest metadata.\n const columnsToUse = mergeRuntimeFieldColumns(\n simpleName,\n registered.schema?.columns,\n registered.fields,\n { stiUnionColumns: isSTI, conflictColumns },\n );\n\n let tableSchema = tableSchemas[tableName];\n if (!tableSchema) {\n tableSchema = {\n tableName,\n columns: {\n ...createBaseColumns(registered, isSTI),\n ...columnsToUse,\n },\n indexes: [],\n ddl: registered.schema?.ddl || '',\n isSTI,\n conflictColumns,\n };\n tableSchemas[tableName] = tableSchema;\n } else {\n // Another class sharing this table (STI): add only columns the\n // seeding contributor did not already define.\n for (const [colName, colDef] of Object.entries(columnsToUse)) {\n if (!tableSchema.columns[colName]) {\n tableSchema.columns[colName] = colDef;\n }\n }\n }\n\n applyContributorForeignKeys(tableSchema, contributor);\n\n // Merge indexes, keeping the first definition of each name.\n const schemaIndexes = registered.schema?.indexes;\n if (schemaIndexes && schemaIndexes.length > 0) {\n const existingNames = new Set(\n tableSchema.indexes.map((index) => index.name),\n );\n for (const index of schemaIndexes) {\n // Legacy string-format indexes carry no columns and cannot be merged.\n if (typeof index === 'string') {\n continue;\n }\n if (!existingNames.has(index.name)) {\n tableSchema.indexes.push(index);\n existingNames.add(index.name);\n }\n }\n }\n }\n }\n\n return tableSchemas;\n}\n\n/**\n * Get all pre-generated schemas for explicit adapter bootstrap paths.\n *\n * Returns schemas in SDK SchemaProvider format for all registered classes.\n * Tooling and test helpers can pass these to `getDatabase()` when they want\n * to bootstrap schema before runtime. Core runtime no longer does this\n * implicitly.\n *\n * @returns Record of table names to schema definitions\n * @example\n * ```typescript\n * const schemas = ObjectRegistry.getAllSchemas('json');\n * const db = await getDatabase({ type: 'json', url: './data', schemas });\n * ```\n */\nexport function getAllSchemas(\n engine?: DatabaseEngine,\n): Record<string, { tableName: string; ddl: string; indexes?: string[] }> {\n // Step 1: Assemble every table from its contributing classes. The merge is\n // deterministic, so the shape does not depend on registration order (#2372).\n const tableSchemas = buildMergedTableSchemas();\n\n // Step 2: Convert to output format, regenerating DDL for merged schemas\n const schemas: Record<\n string,\n { tableName: string; ddl: string; indexes?: string[] }\n > = {};\n\n for (const [tableName, tableSchema] of Object.entries(tableSchemas)) {\n const engineIndexes = engine\n ? withConflictIndex(\n tableName,\n tableSchema.columns,\n tableSchema.indexes,\n tableSchema.conflictColumns,\n )\n : tableSchema.indexes;\n const mergedSchema: SchemaDefinition = {\n tableName,\n ddl: tableSchema.ddl,\n columns: tableSchema.columns,\n indexes: engineIndexes,\n triggers: [],\n foreignKeys: [],\n version: '',\n dependencies: [],\n };\n mergedSchema.foreignKeys = schemaForeignKeys(mergedSchema);\n mergedSchema.dependencies = mergedSchema.foreignKeys\n .map((foreignKey) => foreignKey.referencesTable)\n .filter((dependency) => dependency !== tableName);\n\n // Generate DDL from merged columns (or use original DDL if columns are empty)\n let ddl: string;\n if (Object.keys(tableSchema.columns).length === 0 && tableSchema.ddl) {\n if (engine) {\n throw new Error(\n `Cannot materialize schema '${tableName}' for ${engine}: the manifest has no structured columns`,\n );\n }\n // Preserve legacy inspection of cached engine-neutral DDL. Executable\n // target-engine paths fail above rather than returning unsafe SQL.\n ddl = tableSchema.ddl;\n } else if (Object.keys(tableSchema.columns).length === 0) {\n // Skip schemas with no columns and no original DDL\n continue;\n } else if (engine) {\n // Target-engine materialization must route the complete structured\n // schema through its strategy. In particular, DuckDB/JSON require\n // UNIQUE constraints inline for ON CONFLICT, and every strategy owns\n // CHECK/default/index-expression rendering.\n ddl = getDDLStrategy(engine).generateCreateTable(mergedSchema);\n } else {\n ddl = generateDDLFromColumns(\n tableName,\n tableSchema.columns,\n tableSchema.isSTI,\n );\n }\n\n // Convert index definitions to SQL strings for SDK compatibility\n let indexSQL: string[] | undefined;\n if (engineIndexes.length > 0) {\n indexSQL = engine\n ? getDDLStrategy(engine).generateIndexes(mergedSchema)\n : engineIndexes.map((idx) => {\n const indexType = idx.unique ? 'UNIQUE INDEX' : 'INDEX';\n const columnList = idx.columns\n .map((col) => quoteIdentifier(col))\n .join(', ');\n return `CREATE ${indexType} IF NOT EXISTS ${quoteIdentifier(\n idx.name,\n )} ON ${quoteIdentifier(tableName)} (${columnList});`;\n });\n }\n\n schemas[tableName] = {\n tableName,\n ddl,\n indexes: indexSQL,\n };\n }\n\n return schemas;\n}\n\n/**\n * Get all registered schemas as SchemaDefinition objects\n *\n * Similar to getAllSchemas(), but returns SchemaDefinition format suitable\n * for use with SchemaComparer (migrations/differ.ts).\n *\n * Key difference: Indexes are kept as IndexDefinition objects instead of\n * being converted to SQL strings.\n *\n * @returns Map of tableName to SchemaDefinition\n */\nexport function getAllSchemasAsDefinitions(): Record<string, SchemaDefinition> {\n // Step 1: Assemble every table from its contributing classes. The merge is\n // deterministic, so the shape does not depend on registration order (#2372).\n const tableSchemas = buildMergedTableSchemas();\n\n // Step 2: Convert to SchemaDefinition format\n const schemas: Record<string, SchemaDefinition> = {};\n\n for (const [tableName, tableSchema] of Object.entries(tableSchemas)) {\n if (Object.keys(tableSchema.columns).length === 0) {\n continue;\n }\n\n // Generate DDL from columns\n const ddl = generateDDLFromColumns(\n tableName,\n tableSchema.columns,\n tableSchema.isSTI,\n );\n const foreignKeys = schemaForeignKeys({\n columns: tableSchema.columns,\n foreignKeys: [],\n });\n\n schemas[tableName] = {\n tableName,\n ddl,\n columns: tableSchema.columns,\n indexes: withConflictIndex(\n tableName,\n tableSchema.columns,\n tableSchema.indexes,\n tableSchema.conflictColumns,\n ),\n triggers: [],\n foreignKeys,\n version: '',\n dependencies: foreignKeys\n .map((foreignKey) => foreignKey.referencesTable)\n .filter((dependency) => dependency !== tableName),\n };\n }\n\n return schemas;\n}\n\n/**\n * Generate DDL CREATE TABLE statement from columns\n *\n * Used internally by getAllSchemas() to regenerate DDL after merging\n * columns from multiple STI subtypes that share the same table.\n *\n * @param tableName - Name of the table\n * @param columns - Column definitions\n * @returns DDL CREATE TABLE statement\n */\nexport function generateDDLFromColumns(\n tableName: string,\n columns: Record<string, ColumnDefinition>,\n isSTI = false,\n engine?: DatabaseEngine,\n): string {\n let sql = `CREATE TABLE IF NOT EXISTS ${quoteIdentifier(tableName)} (\\n`;\n\n const columnLines: string[] = [];\n for (const [columnName, columnDef] of Object.entries(columns)) {\n const parts: string[] = [];\n\n // Column name and type\n const strategy = engine ? getDDLStrategy(engine) : undefined;\n const columnType = strategy\n ? strategy.mapType(columnDef.type)\n : columnDef.type;\n parts.push(` ${quoteIdentifier(columnName)} ${columnType}`);\n\n // Primary key\n if (columnDef.primaryKey) {\n parts.push('PRIMARY KEY');\n }\n\n // Not null constraint\n if (columnDef.notNull) {\n parts.push('NOT NULL');\n }\n\n // Unique constraint (skip if primary key already implies uniqueness)\n if (columnDef.unique && !columnDef.primaryKey) {\n parts.push('UNIQUE');\n }\n\n // Default value\n if (columnDef.defaultValue !== undefined) {\n const defaultSQL = strategy\n ? strategy.formatDefaultValue(columnDef.defaultValue, columnDef.type)\n : formatDefaultValue(columnDef.defaultValue, columnDef.type);\n parts.push(`DEFAULT ${defaultSQL}`);\n }\n\n columnLines.push(parts.join(' '));\n }\n for (const foreignKey of schemaForeignKeys({ columns, foreignKeys: [] })) {\n columnLines.push(` ${renderForeignKeyConstraint(tableName, foreignKey)}`);\n }\n\n sql += columnLines.join(',\\n');\n\n // Add UNIQUE constraint for UPSERT operations\n // For STI tables: UNIQUE(slug, context, _meta_type) - different types can have same slug+context\n // For non-STI tables: UNIQUE(slug, context)\n if (columns.slug && columns.context) {\n if (isSTI && columns._meta_type) {\n sql += ',\\n UNIQUE(slug, context, _meta_type)';\n } else {\n sql += ',\\n UNIQUE(slug, context)';\n }\n }\n\n sql += '\\n);';\n\n return sql;\n}\n\n/**\n * Format default value for SQL DDL.\n *\n * Thin wrapper over the shared, injection-safe formatter\n * (`schema/sql-identifiers.ts`) so the registry schema-builder uses the same\n * rules as the DDL strategies and schema generator: an allowlist of SQL\n * keyword/function defaults (not \"contains `(`\"), type-driven literal quoting,\n * and no folding of a literal string `\"null\"` into the SQL NULL keyword.\n *\n * @param value - Default value\n * @param type - Column SQL type\n * @returns Formatted SQL default value\n */\nexport function formatDefaultValue(value: unknown, type: string): string {\n return formatDefaultValueShared(value, type);\n}\n\n/**\n * Options for {@link fieldsToColumns}.\n */\nexport interface FieldsToColumnsOptions {\n /**\n * Shape the columns for a single-table-inheritance table.\n *\n * An STI table holds the union of every subtype's fields, so a column that\n * only one subtype declares must stay nullable — rows of sibling subtypes\n * never populate it. This matches `generateSTISchemaFromManifest`, which\n * emits `notNull: false` for every non-system column on an STI table.\n * Declared defaults are still emitted.\n */\n stiUnionColumns?: boolean;\n /**\n * Physical column names that form the table's natural conflict key.\n * Undeclared delete actions on foreign-key members use the shared CASCADE\n * default, matching app-side relationship cleanup.\n */\n conflictColumns?: readonly string[];\n}\n\n/**\n * Convert a Map of field definitions to column definitions\n *\n * Used by getAllSchemas() to generate columns from fields when a class\n * has no pre-generated schema (e.g., STI subclasses registered from manifest).\n *\n * `required`, `default`, and `description` are read from either the top level\n * or `_meta`: registry-sourced fields normalize them into `_meta`, so reading\n * only the top level dropped NOT NULL and DEFAULT for every such field\n * (#2372).\n *\n * @param fields - Map of field name to field definition\n * @param options - Table-shape options (see {@link FieldsToColumnsOptions})\n * @returns Record of column name to column definition\n * @private\n */\nexport function fieldsToColumns(\n fields: Map<string, FieldDefinition>,\n options?: FieldsToColumnsOptions,\n): Record<string, ColumnDefinition> {\n const columns: Record<string, ColumnDefinition> = {};\n const conflictColumns = new Set(\n (options?.conflictColumns ?? []).map((column) => toSnakeCase(column)),\n );\n\n for (const [fieldName, fieldDef] of fields) {\n // Skip id, timestamps - they're on the base table\n if (\n fieldName === 'id' ||\n fieldName === 'created_at' ||\n fieldName === 'updated_at' ||\n fieldName === 'slug' ||\n fieldName === 'context'\n ) {\n continue;\n }\n\n // Skip transient fields (non-persisted)\n if (fieldDef.transient || fieldDef._meta?.transient) {\n continue;\n }\n\n // Skip relationship fields that don't create columns\n // oneToMany and manyToMany are relationship metadata, not actual database columns\n if (fieldDef.type === 'oneToMany' || fieldDef.type === 'manyToMany') {\n continue;\n }\n\n // Skip meta fields - they're stored in _meta_data JSONB column\n if (fieldDef.type === 'meta') {\n continue;\n }\n\n // Map field type to SQL type\n const sqlType =\n fieldDef._meta?.sqlType ||\n (fieldDef.type === 'crossPackageRef' &&\n (fieldDef._meta?.idType === 'text' ||\n (fieldDef as unknown as { idType?: string }).idType === 'text')\n ? 'TEXT'\n : mapFieldTypeToSQL(fieldDef.type));\n const normalizedSqlType = String(sqlType).toUpperCase() as SQLDataType;\n const referenceKind = getReferenceKind(fieldDef);\n\n const required = readFieldAttribute(fieldDef, 'required');\n const defaultValue = readFieldAttribute(fieldDef, 'default');\n const description = readFieldAttribute(fieldDef, 'description');\n\n const column: ColumnDefinition = {\n type: normalizedSqlType,\n referenceKind,\n notNull: options?.stiUnionColumns\n ? false\n : fieldDef._meta?.nullable\n ? false\n : Boolean(required),\n unique: fieldDef._meta?.unique || false,\n description: description as string | undefined,\n };\n\n // Handle default values\n if (\n defaultValue !== undefined &&\n shouldEmitDefault(fieldDef, normalizedSqlType, defaultValue)\n ) {\n column.defaultValue = defaultValue;\n }\n const backfill = normalizeBackfill(fieldDef._meta?.backfill);\n if (backfill !== undefined) {\n column.backfill = backfill;\n }\n\n // Handle foreign keys\n if (\n fieldDef.type === 'foreignKey' &&\n fieldDef.related &&\n fieldDef._meta?.constraint !== false &&\n fieldDef._meta?.__tenancy?.isTenantIdField !== true &&\n !(\n fieldDef as FieldDefinition & {\n __tenancy?: { isTenantIdField?: boolean };\n }\n ).__tenancy?.isTenantIdField\n ) {\n const [table, columnName = 'id'] = fieldDef.related.split('.');\n const fieldMeta = fieldDef._meta as\n | {\n onDelete?: ForeignKeyAction;\n onUpdate?: ForeignKeyAction;\n }\n | undefined;\n column.foreignKey = {\n table: classnameToTablename(table),\n column: columnName,\n onDelete: resolveForeignKeyDeleteAction({\n declared: fieldMeta?.onDelete,\n isConflictColumn: conflictColumns.has(toSnakeCase(fieldName)),\n isTenantIdField: false,\n }).action,\n onUpdate:\n fieldMeta?.onUpdate === undefined\n ? 'CASCADE'\n : requireForeignKeyAction(\n fieldMeta.onUpdate,\n `${fieldName} ON UPDATE`,\n ),\n ...(typeof fieldDef._meta?.constraint === 'object'\n ? { engines: [...fieldDef._meta.constraint.engines] }\n : {}),\n };\n }\n\n // Use snake_case for column names\n columns[toSnakeCase(fieldName)] = column;\n }\n\n return columns;\n}\n\n/**\n * Map field type to SQL data type\n * @private\n */\nexport function mapFieldTypeToSQL(\n fieldType: FieldDefinition['type'],\n): SQLDataType {\n switch (fieldType) {\n case 'text':\n return 'TEXT';\n case 'integer':\n return 'INTEGER';\n case 'decimal':\n return 'REAL';\n case 'boolean':\n return 'BOOLEAN';\n case 'datetime':\n return 'TIMESTAMP';\n case 'json':\n return 'JSON';\n case 'foreignKey':\n return 'UUID';\n case 'crossPackageRef':\n return 'UUID';\n default:\n return 'TEXT';\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsDA,IAAM,+BAA6D;CACjE;CACA,qBAAqB,aAAa,cAChC,eAAe,kBAAkB,aAAa,SAAS;CACzD,sBAAsB,cACpB,eAAe,oBAAoB,SAAS;AAChD;AAEA,SAAS,+BACP,WACA,SACkC;CAClC,MAAM,aAAa,eAAe,mBAAmB,SAAS;CAC9D,IAAI,CAAC,WAAW,MACd,OAAO;CAGT,KAAK,MAAM,CAAC,WAAW,YAAY,YAAY;EAC7C,IAAI,CAAC,SAAS,SACZ;EAGF,MAAM,aAAa,YAAY,SAAS;EACxC,MAAM,WAAW,QAAQ;EACzB,IAAI,CAAC,UACH;EAGF,MAAM,gBAAgB,iBAAiB,OAA0B;EACjE,QAAQ,cAAc;GACpB,GAAG;GACH,MAAM,OAAO,QAAQ,OAAO,CAAC,CAAC,YAAY;GAC1C,GAAI,gBAAgB,EAAE,cAAc,IAAI,CAAC;EAC3C;CACF;CAEA,OAAO;AACT;AAEA,SAAS,yBACP,WACA,eACA,QACA,SACkC;CAClC,MAAM,eAAe,EAAE,GAAI,iBAAiB,CAAC,EAAG;CAEhD,IAAI,OAAO,OAAO,GAAG;EACnB,MAAM,eAAe,gBAAgB,QAAQ,OAAO;EACpD,KAAK,MAAM,CAAC,YAAY,cAAc,OAAO,QAAQ,YAAY,GAC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AAkB,SAAS,OAAO,QAAQ;EAC3D,IAAI,aAAa,KAAA,GACf,OAAO,WAAW;EAIpB,IACE,SAAS,SAAS,gBAClB,SAAS,WACT,SAAS,OAAO,eAAe,SAC/B,SAAS,OAAO,WAAW,oBAAoB,QAC/C,CACE,SAGA,WAAW,iBACb;GACA,MAAM,CAAC,OAAO,aAAa,QAAQ,SAAS,QAAQ,MAAM,GAAG;GAC7D,MAAM,YAAY,SAAS;GAM3B,OAAO,aAAa;IAClB,OAAO,qBAAqB,KAAK;IACjC,QAAQ;IACR,UAAU,8BAA8B;KACtC,UAAU,WAAW;KACrB,kBAAkB,gBAAgB,IAAI,YAAY,SAAS,CAAC;KAC5D,iBAAiB;IACnB,CAAC,CAAC,CAAC;IACH,UACE,WAAW,aAAa,KAAA,IACpB,YACA,wBACE,UAAU,UACV,GAAG,UAAU,WACf;IACN,GAAI,OAAO,SAAS,OAAO,eAAe,WACtC,EAAE,SAAS,CAAC,GAAG,SAAS,MAAM,WAAW,OAAO,EAAE,IAClD,CAAC;GACP;EACF;EAGA,QAAQ,YAAY,SAAS,KAAK;CACpC;CAEA,OAAO;AACT;;;;;AAMA,SAAgB,kBACd,WACa;CACb,QAAQ,WAAR;EACE,KAAK,QACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,KAAK,cACH,OAAO;EACT,KAAK,mBACH,OAAO;EACT,SACE,OAAO;CACX;AACF"}
@@ -1,7 +1,7 @@
1
1
  import { createGenerationTrackedMap, isGenerationTrackedMap } from "./generation.js";
2
+ import { isDecoratorRuntimeFramePath } from "../utils/stack-frames.js";
2
3
  import { getSmrtModuleConfig } from "../config/global-config.js";
3
4
  import { LRUCache } from "../utils/lru-cache.js";
4
- import { isDecoratorRuntimeFramePath } from "../utils/stack-frames.js";
5
5
  import { createLogger } from "@happyvertical/logger";
6
6
  //#region src/registry/shared-state.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