@happyvertical/smrt-core 0.51.39 → 0.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +9 -0
- package/README.md +8 -2
- package/agents/model-moves.md +114 -0
- package/agents/object-runtime.md +3 -1
- package/agents/run-once.md +16 -7
- package/agents/schema-paths.md +79 -0
- package/dist/cascade.d.ts.map +1 -1
- package/dist/cascade.js +6 -3
- package/dist/cascade.js.map +1 -1
- package/dist/collection.d.ts +10 -1
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +14 -4
- package/dist/collection.js.map +1 -1
- package/dist/errors.d.ts +18 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +21 -0
- package/dist/errors.js.map +1 -1
- package/dist/generators/preflight-route.d.ts.map +1 -1
- package/dist/generators/preflight-route.js +1 -1
- package/dist/generators/preflight-route.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/knowledge.d.ts.map +1 -1
- package/dist/knowledge.js +3 -0
- package/dist/knowledge.js.map +1 -1
- package/dist/manifest/static-manifest.d.ts.map +1 -1
- package/dist/manifest/static-manifest.js +9 -1
- package/dist/manifest/static-manifest.js.map +1 -1
- package/dist/manifest/store.js +1 -1
- package/dist/manifest/store.js.map +1 -1
- package/dist/manifest.json +9 -1
- package/dist/migrations/differ.d.ts +56 -0
- package/dist/migrations/differ.d.ts.map +1 -1
- package/dist/migrations/differ.js +152 -27
- package/dist/migrations/differ.js.map +1 -1
- package/dist/migrations/index.d.ts +1 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +2 -1
- package/dist/migrations/null-equal-indexes.js +1 -1
- package/dist/migrations/orchestrate.d.ts +7 -0
- package/dist/migrations/orchestrate.d.ts.map +1 -1
- package/dist/migrations/orchestrate.js +4 -2
- package/dist/migrations/orchestrate.js.map +1 -1
- package/dist/migrations/qualified-name-aliases.d.ts +134 -0
- package/dist/migrations/qualified-name-aliases.d.ts.map +1 -0
- package/dist/migrations/qualified-name-aliases.js +294 -0
- package/dist/migrations/qualified-name-aliases.js.map +1 -0
- package/dist/migrations/tracker.d.ts +29 -1
- package/dist/migrations/tracker.d.ts.map +1 -1
- package/dist/migrations/tracker.js +92 -7
- package/dist/migrations/tracker.js.map +1 -1
- package/dist/migrations.js +2 -1
- package/dist/object.d.ts +128 -0
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +333 -44
- package/dist/object.js.map +1 -1
- package/dist/polymorphic-association.d.ts +18 -0
- package/dist/polymorphic-association.d.ts.map +1 -1
- package/dist/polymorphic-association.js +27 -2
- package/dist/polymorphic-association.js.map +1 -1
- package/dist/registry/class-registration.d.ts.map +1 -1
- package/dist/registry/class-registration.js +27 -4
- package/dist/registry/class-registration.js.map +1 -1
- package/dist/registry/name-resolver.d.ts +8 -2
- package/dist/registry/name-resolver.d.ts.map +1 -1
- package/dist/registry/name-resolver.js +17 -8
- package/dist/registry/name-resolver.js.map +1 -1
- package/dist/registry/qualified-name-aliases.d.ts +109 -0
- package/dist/registry/qualified-name-aliases.d.ts.map +1 -0
- package/dist/registry/qualified-name-aliases.js +286 -0
- package/dist/registry/qualified-name-aliases.js.map +1 -0
- package/dist/registry/relationship-graph.d.ts.map +1 -1
- package/dist/registry/relationship-graph.js +1 -1
- package/dist/registry/relationship-graph.js.map +1 -1
- package/dist/registry/schema-builder.d.ts.map +1 -1
- package/dist/registry/schema-builder.js +7 -5
- package/dist/registry/schema-builder.js.map +1 -1
- package/dist/registry/types.d.ts +26 -0
- package/dist/registry/types.d.ts.map +1 -1
- package/dist/registry.d.ts +127 -6
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +234 -14
- package/dist/registry.js.map +1 -1
- package/dist/scanner/index.d.ts +1 -1
- package/dist/scanner/index.d.ts.map +1 -1
- package/dist/scanner/manifest-generator.d.ts +14 -2
- package/dist/scanner/manifest-generator.d.ts.map +1 -1
- package/dist/scanner/manifest-generator.js +48 -9
- package/dist/scanner/manifest-generator.js.map +1 -1
- package/dist/scanner/types.d.ts +21 -0
- package/dist/scanner/types.d.ts.map +1 -1
- package/dist/scanner/types.js.map +1 -1
- package/dist/schema/conflict-target.d.ts +68 -11
- package/dist/schema/conflict-target.d.ts.map +1 -1
- package/dist/schema/conflict-target.js +75 -12
- package/dist/schema/conflict-target.js.map +1 -1
- package/dist/schema/foreign-key-ddl.d.ts +17 -1
- package/dist/schema/foreign-key-ddl.d.ts.map +1 -1
- package/dist/schema/foreign-key-ddl.js +29 -3
- package/dist/schema/foreign-key-ddl.js.map +1 -1
- package/dist/schema/foreign-key-policy.d.ts +8 -0
- package/dist/schema/foreign-key-policy.d.ts.map +1 -1
- package/dist/schema/foreign-key-policy.js +2 -1
- package/dist/schema/foreign-key-policy.js.map +1 -1
- package/dist/schema/generator.d.ts +7 -0
- package/dist/schema/generator.d.ts.map +1 -1
- package/dist/schema/generator.js +18 -10
- package/dist/schema/generator.js.map +1 -1
- package/dist/schema/text-cast-probe.d.ts +50 -1
- package/dist/schema/text-cast-probe.d.ts.map +1 -1
- package/dist/schema/text-cast-probe.js +46 -11
- package/dist/schema/text-cast-probe.js.map +1 -1
- package/dist/schema/types.d.ts +6 -0
- package/dist/schema/types.d.ts.map +1 -1
- package/dist/scripts/browser-plain-json-regression.mjs +4 -1
- package/dist/smrt-knowledge.json +22 -11
- package/dist/utils/qualified-names.d.ts +11 -0
- package/dist/utils/qualified-names.d.ts.map +1 -1
- package/dist/utils/qualified-names.js +21 -1
- package/dist/utils/qualified-names.js.map +1 -1
- package/package.json +11 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qualified-name-aliases.js","names":[],"sources":["../../src/registry/qualified-name-aliases.ts"],"sourcesContent":["/**\n * Deprecated qualified-name aliases (#3338).\n *\n * A class that moves package (or is renamed) changes its qualified name, and\n * every persisted or declared reference to the old name — a polymorphic\n * `metaType`, a `@crossPackageRef` target, a playbook `model:` — would stop\n * resolving silently. `@smrt({ previousQualifiedNames })` declares the old\n * names; this module turns them into lookup bridges.\n *\n * An alias is never a registry key. The `classes` map — and so\n * `getAllClasses()`, schema/DDL, MCP, CLI and REST generation, and every other\n * iteration — still holds exactly one entry per class. Qualified-name lookups\n * consult the derived alias index only after a direct miss, so a live class\n * always wins and an alias can never shadow one; registration refuses the\n * collisions that would make that ambiguous.\n *\n * Like the simple-name index in `name-resolver.ts`, the alias index is\n * derived, not maintained: it is rebuilt from `classes` once per registry\n * generation (#3047).\n */\n\nimport { createLogger } from '@happyvertical/logger';\nimport { ConfigurationError } from '../errors';\nimport {\n getLocalTestManifestCache,\n getManifestCache,\n getStaticManifestCache,\n getTestManifestCache,\n} from '../manifest/store.js';\nimport type { SmartObjectManifest } from '../scanner/types.js';\nimport {\n isQualifiedNameAliasFormat,\n readPreviousQualifiedNames,\n} from '../utils/qualified-names.js';\nimport { recordRegistryDiagnostic } from './diagnostics';\nimport { getRegistryGeneration } from './generation';\nimport { getClasses } from './shared-state';\nimport type { RegisteredClass } from './types';\n\nexport {\n isQualifiedNameAliasFormat,\n readPreviousQualifiedNames,\n} from '../utils/qualified-names.js';\n\n/** Error code for an alias that collides with a live class or another alias. */\nexport const QUALIFIED_NAME_ALIAS_COLLISION =\n 'CONFIG_QUALIFIED_NAME_ALIAS_COLLISION';\n\n/** Error code for a malformed `previousQualifiedNames` declaration. */\nexport const QUALIFIED_NAME_ALIAS_INVALID =\n 'CONFIG_QUALIFIED_NAME_ALIAS_INVALID';\n\n/** Diagnostic code recorded (once per alias) when a lookup uses an old name. */\nexport const QUALIFIED_NAME_ALIAS_DEPRECATED =\n 'QUALIFIED_NAME_ALIAS_DEPRECATED';\n\nconst logger = createLogger({ level: 'info' });\n\ndeclare global {\n // eslint-disable-next-line no-var\n var __smrtRegistryWarnedQualifiedNameAliases: Set<string> | undefined;\n}\n\nfunction getWarnedAliases(): Set<string> {\n if (!globalThis.__smrtRegistryWarnedQualifiedNameAliases) {\n globalThis.__smrtRegistryWarnedQualifiedNameAliases = new Set();\n }\n return globalThis.__smrtRegistryWarnedQualifiedNameAliases;\n}\n\n/** Forget which aliases already warned (`ObjectRegistry.clear()`, tests). */\nexport function resetQualifiedNameAliasWarnings(): void {\n getWarnedAliases().clear();\n}\n\n/**\n * Two registrations describe the same class: one object, one constructor, or\n * one qualified name (a manifest stub later replaced by its real class, or\n * an HMR reload).\n */\nfunction sameClass(left: RegisteredClass, right: RegisteredClass): boolean {\n return (\n left === right ||\n left.constructor === right.constructor ||\n (!!left.qualifiedName && left.qualifiedName === right.qualifiedName)\n );\n}\n\nfunction ownName(entry: RegisteredClass, registrationKey?: string): string {\n return entry.qualifiedName ?? registrationKey ?? entry.name;\n}\n\nlet aliasIndex:\n | {\n generation: number;\n classes: Map<string, RegisteredClass>;\n byAlias: Map<string, RegisteredClass>;\n }\n | undefined;\n\n/** Alias → registered class, rebuilt once per registry generation. */\nfunction getAliasIndex(): Map<string, RegisteredClass> {\n const classes = getClasses();\n const generation = getRegistryGeneration();\n if (\n aliasIndex &&\n aliasIndex.generation === generation &&\n aliasIndex.classes === classes\n ) {\n return aliasIndex.byAlias;\n }\n\n const byAlias = new Map<string, RegisteredClass>();\n for (const [key, entry] of classes) {\n for (const alias of readPreviousQualifiedNames(entry.config)) {\n // A live class always wins over an alias (registration refuses the\n // collision; this guards registries assembled before that check ran).\n if (classes.has(alias)) continue;\n const existing = byAlias.get(alias);\n // The same class can sit under a transitional simple key and its\n // qualified key; prefer the qualified registration.\n if (!existing || (sameClass(existing, entry) && key.includes(':'))) {\n byAlias.set(alias, entry);\n }\n }\n }\n aliasIndex = { generation, classes, byAlias };\n return byAlias;\n}\n\n/**\n * The class a deprecated qualified name now resolves to, WITHOUT warning.\n * Returns `undefined` for live names and unknown names alike.\n */\nexport function lookupQualifiedNameAlias(\n name: string,\n): RegisteredClass | undefined {\n if (!name.includes(':')) return undefined;\n return getAliasIndex().get(name);\n}\n\n/**\n * Resolve a deprecated qualified name to its current class, logging the\n * one-time deprecation warning. `source` names the resolution site for that\n * warning (e.g. `SmrtPolymorphicAssociation.hydrate`).\n */\nexport function resolveQualifiedNameAlias(\n name: string,\n source = 'ObjectRegistry qualified-name lookup',\n): RegisteredClass | undefined {\n const registered = lookupQualifiedNameAlias(name);\n if (registered) {\n warnDeprecatedQualifiedName(\n name,\n registered.qualifiedName ?? registered.name,\n source,\n );\n }\n return registered;\n}\n\n/**\n * Warn — once per old name per process — that a lookup used a deprecated\n * qualified name. Also recorded as a `warn` registry diagnostic so apps and\n * tests can inspect it through `ObjectRegistry.getDiagnostics()`.\n */\nexport function warnDeprecatedQualifiedName(\n alias: string,\n current: string,\n source: string,\n): void {\n const warned = getWarnedAliases();\n if (warned.has(alias)) return;\n warned.add(alias);\n const message =\n `Qualified name \"${alias}\" is deprecated; it now resolves to \"${current}\" ` +\n `(resolved from ${source}). Store and declare \"${current}\" instead — ` +\n 'the alias will be removed in a later breaking release. ' +\n '`smrt doctor --db` counts stored references that still use it.';\n const context = { alias, current, source };\n recordRegistryDiagnostic('warn', QUALIFIED_NAME_ALIAS_DEPRECATED, message, {\n ...context,\n });\n logger.warn(`[smrt:${QUALIFIED_NAME_ALIAS_DEPRECATED}] ${message}`, context);\n}\n\n/** Every declared alias → its class's current qualified name, sorted. */\nexport function getQualifiedNameAliasMap(): Map<string, string> {\n const entries = [...getAliasIndex()].map(\n ([alias, registered]) =>\n [alias, registered.qualifiedName ?? registered.name] as const,\n );\n entries.sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0));\n return new Map(entries);\n}\n\n/**\n * Refuse a registration whose aliases would make a qualified name resolve to\n * two classes. Called before a class is stored in `classes` — and, for an\n * update of a live entry, with the PROPOSED entry and `replacing` set to the\n * live one, before anything is mutated, so a refused update changes nothing.\n *\n * - every alias is a scoped `@scope/package:ClassName` string, distinct from the\n * class's own name, and declared once;\n * - no alias is the key of a different live class;\n * - no alias is also declared by a different class;\n * - the class's own name is not another class's alias.\n *\n * @throws {ConfigurationError} `CONFIG_QUALIFIED_NAME_ALIAS_INVALID` or\n * `CONFIG_QUALIFIED_NAME_ALIAS_COLLISION`.\n */\nexport function assertQualifiedNameAliasesAvailable(\n registrationKey: string,\n entry: RegisteredClass,\n replacing?: RegisteredClass,\n): void {\n const self = ownName(entry, registrationKey);\n const declared = (entry.config as { previousQualifiedNames?: unknown })\n ?.previousQualifiedNames;\n if (declared !== undefined && !Array.isArray(declared)) {\n throw new ConfigurationError(\n `${self}: previousQualifiedNames must be an array of qualified names (\"@package/name:ClassName\").`,\n QUALIFIED_NAME_ALIAS_INVALID,\n { className: self, previousQualifiedNames: declared },\n );\n }\n const aliases = (declared as unknown[] | undefined) ?? [];\n const seen = new Set<string>();\n for (const alias of aliases) {\n if (!isQualifiedNameAliasFormat(alias)) {\n throw new ConfigurationError(\n `${self}: previousQualifiedNames entry ${JSON.stringify(alias)} is not a qualified name (\"@package/name:ClassName\").`,\n QUALIFIED_NAME_ALIAS_INVALID,\n { className: self, alias },\n );\n }\n if (alias === self) {\n throw new ConfigurationError(\n `${self}: previousQualifiedNames lists the class's own current name \"${alias}\".`,\n QUALIFIED_NAME_ALIAS_INVALID,\n { className: self, alias },\n );\n }\n if (alias === registrationKey) {\n // Another package's manifest entry under the old name is being merged\n // into, or keyed onto, this class: the old name is still live.\n throw collision(\n `${self} declares previousQualifiedNames \"${alias}\", but a class is being registered under \"${alias}\". ` +\n 'An alias may only name a class that no longer exists; remove the alias or the stale class/manifest.',\n { className: self, alias },\n );\n }\n if (seen.has(alias)) {\n throw new ConfigurationError(\n `${self}: previousQualifiedNames lists \"${alias}\" more than once.`,\n QUALIFIED_NAME_ALIAS_INVALID,\n { className: self, alias },\n );\n }\n seen.add(alias);\n }\n\n const classes = getClasses();\n // Identities a registration answers to: its qualified name, its key, and\n // `<packageName>:<name>` (a source registration can sit under a simple key\n // before its qualified promotion).\n const identities = (other: RegisteredClass, key: string): string[] => [\n ownName(other, key),\n key,\n ...(other.packageName ? [`${other.packageName}:${other.name}`] : []),\n ];\n const selfIdentities = new Set(identities(entry, registrationKey));\n\n for (const [key, other] of classes) {\n if (other === replacing || sameClass(other, entry)) continue;\n const otherName = ownName(other, key);\n for (const identity of identities(other, key)) {\n if (seen.has(identity)) {\n throw collision(\n `${self} declares previousQualifiedNames \"${identity}\", but \"${identity}\" is a live registered class. ` +\n 'An alias may only name a class that no longer exists; remove the alias or the stale class/manifest.',\n { className: self, alias: identity, liveClass: otherName },\n );\n }\n }\n const otherAliases = readPreviousQualifiedNames(other.config);\n if (otherAliases.length === 0) continue;\n for (const alias of otherAliases) {\n if (seen.has(alias)) {\n throw collision(\n `previousQualifiedNames \"${alias}\" is declared by both ${self} and ${otherName}; ` +\n 'an old name can resolve to only one class.',\n { className: self, alias, otherClass: otherName },\n );\n }\n if (selfIdentities.has(alias)) {\n throw collision(\n `${otherName} declares previousQualifiedNames \"${alias}\", but ${self} is registered under that name. ` +\n 'An alias may only name a class that no longer exists; remove the alias or the stale class/manifest.',\n { className: self, alias, otherClass: otherName },\n );\n }\n }\n }\n\n // A competing claim in any manifest this process has loaded — an\n // installed package not registered yet — is the same collision (#3338).\n if (seen.size > 0) {\n assertNoCompetingManifestClaims(\n seen,\n collectManifestAliasInventory(loadedManifests()),\n entry.qualifiedName ?? self,\n );\n }\n}\n\nfunction collision(\n message: string,\n details: Record<string, unknown>,\n): ConfigurationError {\n return new ConfigurationError(\n message,\n QUALIFIED_NAME_ALIAS_COLLISION,\n details,\n );\n}\n\n/** The current qualified name a manifest object registers under. */\nfunction manifestObjectQualifiedName(\n manifest: SmartObjectManifest,\n key: string,\n objectDef: SmartObjectManifest['objects'][string],\n): string | undefined {\n if (objectDef.qualifiedName) return objectDef.qualifiedName;\n if (key.includes(':')) return key;\n const packageName = objectDef.packageName ?? manifest.packageName;\n return packageName ? `${packageName}:${objectDef.className}` : undefined;\n}\n\n/**\n * What a set of manifests says about qualified names (#3338): which classes\n * claim each old name, and which qualified names the manifests DEFINE as\n * classes of their own (installed but possibly unregistered).\n */\nexport interface ManifestAliasInventory {\n /** Old name → distinct current names claiming it. */\n claims: Map<string, Set<string>>;\n /** Every qualified name a manifest defines as a class. */\n defined: Set<string>;\n}\n\n/**\n * Index `manifests` (one manifest may appear twice, e.g. cached and static;\n * the same class claiming twice is one claim). A re-exported constructor is\n * not a definition: manifests list only classes a package declares.\n */\nexport function collectManifestAliasInventory(\n manifests: Iterable<SmartObjectManifest | null | undefined>,\n): ManifestAliasInventory {\n const claims = new Map<string, Set<string>>();\n const defined = new Set<string>();\n for (const manifest of manifests) {\n if (!manifest?.objects) continue;\n for (const [key, objectDef] of Object.entries(manifest.objects)) {\n const current = manifestObjectQualifiedName(manifest, key, objectDef);\n if (!current) continue;\n defined.add(current);\n for (const alias of readPreviousQualifiedNames(\n objectDef?.decoratorConfig,\n )) {\n const owners = claims.get(alias) ?? new Set<string>();\n owners.add(current);\n claims.set(alias, owners);\n }\n }\n }\n return { claims, defined };\n}\n\n/**\n * THE manifest rule for old names (#3338). Throws when any of `aliases`:\n *\n * - is defined as a class by a manifest in `inventory` — an installed\n * (possibly stale) package still ships the old class, so the old name is\n * live, not deprecated;\n * - is claimed by a class other than `owner` (or, with no `owner`, by more\n * than one class).\n *\n * @throws {ConfigurationError} `CONFIG_QUALIFIED_NAME_ALIAS_COLLISION`\n */\nexport function assertNoCompetingManifestClaims(\n aliases: Iterable<string>,\n inventory: ManifestAliasInventory,\n owner?: string,\n): void {\n for (const alias of aliases) {\n if (inventory.defined.has(alias)) {\n const claimants = [...(inventory.claims.get(alias) ?? [])];\n if (owner && !claimants.includes(owner)) claimants.push(owner);\n throw collision(\n `previousQualifiedNames \"${alias}\" is still defined as a class by an installed manifest (claimed by ${claimants.sort().join(', ') || 'no class'}). ` +\n 'An alias may only name a class that no longer exists; remove the stale package/manifest or the alias.',\n { alias, claimants: claimants.sort(), definedByManifest: true },\n );\n }\n const owners = new Set(inventory.claims.get(alias) ?? []);\n if (owner) owners.add(owner);\n if (owners.size > 1) {\n const sorted = [...owners].sort();\n throw collision(\n `previousQualifiedNames \"${alias}\" is declared by more than one class across installed manifests (${sorted.join(', ')}); ` +\n 'an old name can resolve to only one class.',\n { alias, claimants: sorted },\n );\n }\n }\n}\n\n/** Every manifest this process has loaded (package, static, test caches). */\nfunction loadedManifests(): Array<SmartObjectManifest | null | undefined> {\n return [\n ...getManifestCache().values(),\n getStaticManifestCache(),\n getTestManifestCache(),\n getLocalTestManifestCache(),\n ];\n}\n\n/**\n * The single current owner of `alias` in an inventory, or `undefined` —\n * also when a manifest defines `alias` as a class of its own.\n * Two distinct claimants are refused rather than resolved first-match: an\n * old name can resolve to only one class, on the lazy path as on the eager\n * one.\n *\n * @throws {ConfigurationError} `CONFIG_QUALIFIED_NAME_ALIAS_COLLISION`\n */\nexport function resolveManifestQualifiedNameAlias(\n inventory: ManifestAliasInventory,\n alias: string,\n): string | undefined {\n // A name some manifest defines as a class is not an alias to follow.\n if (inventory.defined.has(alias)) return undefined;\n assertNoCompetingManifestClaims([alias], inventory);\n return [...(inventory.claims.get(alias) ?? [])][0];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,IAAa,iCACX;;AAGF,IAAa,+BACX;;AAGF,IAAa,kCACX;AAEF,IAAM,SAAS,aAAa,EAAE,OAAO,OAAO,CAAC;AAO7C,SAAS,mBAAgC;CACvC,IAAI,CAAC,WAAW,0CACd,WAAW,2DAA2C,IAAI,IAAI;CAEhE,OAAO,WAAW;AACpB;;AAGA,SAAgB,kCAAwC;CACtD,iBAAiB,CAAC,CAAC,MAAM;AAC3B;;;;;;AAOA,SAAS,UAAU,MAAuB,OAAiC;CACzE,OACE,SAAS,SACT,KAAK,gBAAgB,MAAM,eAC1B,CAAC,CAAC,KAAK,iBAAiB,KAAK,kBAAkB,MAAM;AAE1D;AAEA,SAAS,QAAQ,OAAwB,iBAAkC;CACzE,OAAO,MAAM,iBAAiB,mBAAmB,MAAM;AACzD;AAEA,IAAI;;AASJ,SA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AiB,CAAC,CAAC,OAAO;EAC7B,uBAAuB;EACvB,qBAAqB;EACrB,0BAA0B;CAC5B;AACF;;;;;;;;;;AAWA,SAAgB,kCACd,WACA,OACoB;CAEpB,IAAI,UAAU,QAAQ,IAAI,KAAK,GAAG,OAAO,KAAA;CACzC,gCAAgC,CAAC,KAAK,GAAG,SAAS;CAClD,OAAO,CAAC,GAAI,UAAU,OAAO,IAAI,KAAK,KAAK,CAAC,CAAE,CAAC,CAAC;AAClD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relationship-graph.d.ts","sourceRoot":"","sources":["../../src/registry/relationship-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAGV,oBAAoB,EACrB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"relationship-graph.d.ts","sourceRoot":"","sources":["../../src/registry/relationship-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAGV,oBAAoB,EACrB,MAAM,SAAS,CAAC;AAyCjB,mFAAmF;AACnF,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,IAAI,GAAG,SAAS,CAe3B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAgC1D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,GAAG,CAAC,MAAM,EAAE,oBAAoB,EAAE,CAAC,CA6FxE"}
|
|
@@ -20,7 +20,7 @@ function resolveTarget(registered, field) {
|
|
|
20
20
|
}
|
|
21
21
|
const related = field.related;
|
|
22
22
|
if (!related) return null;
|
|
23
|
-
if (related.includes(":")) return findClass(related)?.qualifiedName ?? related;
|
|
23
|
+
if (related.includes(":")) return findClass(related, `relationship target declared on ${registered.qualifiedName ?? registered.name}`)?.qualifiedName ?? related;
|
|
24
24
|
const local = classes.get(`${registered.packageName}:${related}`);
|
|
25
25
|
if (local) return local.qualifiedName ?? `${registered.packageName}:${related}`;
|
|
26
26
|
const matches = Array.from(classes).filter(([, entry]) => entry.name === related);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relationship-graph.js","names":[],"sources":["../../src/registry/relationship-graph.ts"],"sourcesContent":["/**\n * Relationship graph and dependency resolution module for the SMRT ObjectRegistry.\n *\n * Builds relationship maps and dependency graphs from registered class fields.\n *\n * Extracted from registry.ts as part of issue #1006.\n * @see https://github.com/happyvertical/smrt/issues/1006\n */\n\nimport { getInheritanceChain } from './inheritance-resolver';\nimport { findClass } from './name-resolver';\nimport { getClasses } from './shared-state';\nimport type {\n RegisteredClass,\n RegisteredField,\n RelationshipMetadata,\n} from './types';\n\n/** Resolve lazily: the target may register after the decorated child. */\nfunction resolveTarget(\n registered: RegisteredClass,\n field: RegisteredField,\n): string | null | undefined {\n const classes = getClasses();\n const ctor = field._meta?.relatedConstructor;\n if (typeof ctor === 'function') {\n const match = Array.from(classes).find(\n ([, entry]) => entry.constructor === ctor,\n );\n return match ? (match[1].qualifiedName ?? match[0]) : null;\n }\n const related = field.related;\n if (!related) return null;\n if (related.includes(':'))\n return findClass(related)?.qualifiedName ?? related;\n const local = classes.get(`${registered.packageName}:${related}`);\n if (local)\n return local.qualifiedName ?? `${registered.packageName}:${related}`;\n const matches = Array.from(classes).filter(\n ([, entry]) => entry.name === related,\n );\n const distinct = [\n ...new Map(matches.map((match) => [match[1], match])).values(),\n ];\n if (distinct.length === 0) return undefined;\n if (distinct.length !== 1) return null;\n const match = matches.find(([key]) => key.includes(':')) ?? distinct[0];\n return match[1].qualifiedName ?? match[0];\n}\n\n/** Canonical target of the field's declaring class, including inherited fields. */\nexport function resolveRelationshipTarget(\n className: string,\n fieldName: string,\n): string | null | undefined {\n for (const name of [\n className,\n ...[...getInheritanceChain(className)].reverse(),\n ]) {\n const registered = findClass(name);\n const field = registered?.fields.get(fieldName);\n if (registered && field) {\n return resolveTarget(registered, {\n ...field,\n related: field.related?.split('.')[0],\n });\n }\n }\n return undefined;\n}\n\n/**\n * Build dependency graph from foreignKey relationships.\n *\n * Returns a map where keys are class names and values are arrays\n * of class names that the key depends on (via foreignKey fields).\n */\nexport function getDependencyGraph(): Map<string, string[]> {\n const classes = getClasses();\n const graph = new Map<string, string[]>();\n\n // Initialize graph with all registered classes\n for (const [_key, entry] of classes) {\n graph.set(entry.name || _key, []);\n }\n\n // Scan all fields for foreignKey relationships\n for (const [_key, registered] of classes) {\n const simpleName = registered.name || _key;\n const dependencies: string[] = [];\n\n for (const [_fieldName, field] of registered.fields) {\n if (field.type === 'foreignKey' && field.related) {\n const relatedClass = field.related;\n // Skip self-references (table can reference itself after creation)\n // Only add if the related class is registered and not self\n if (\n relatedClass !== simpleName &&\n findClass(relatedClass) !== undefined\n ) {\n dependencies.push(relatedClass);\n }\n }\n }\n\n graph.set(simpleName, dependencies);\n }\n\n return graph;\n}\n\n/**\n * Build comprehensive relationship map from all field types.\n *\n * Returns a map containing all relationships (foreignKey, oneToMany, manyToMany)\n * discovered in registered classes.\n */\nexport function getRelationshipMap(): Map<string, RelationshipMetadata[]> {\n const classes = getClasses();\n const relationshipMap = new Map<string, RelationshipMetadata[]>();\n const simpleNameEntries = new Map<string, Set<RegisteredClass>>();\n\n // Initialize map with all registered classes\n for (const [key, entry] of classes) {\n // The registry is qualified-name keyed. Keep relationship buckets on that\n // canonical identity as well: classes in separate packages may share a\n // simple name, and a later empty declaration must not overwrite an earlier\n // class's relationships.\n relationshipMap.set(entry.qualifiedName || key, []);\n const simpleName = entry.name || key;\n const entries = simpleNameEntries.get(simpleName) ?? new Set();\n entries.add(entry);\n simpleNameEntries.set(simpleName, entries);\n }\n\n // Scan all fields for relationship types\n for (const [key, registered] of classes) {\n const simpleName = registered.name || key;\n const sourceQualifiedClass = registered.qualifiedName || key;\n const relationships: RelationshipMetadata[] = [];\n\n for (const [fieldName, field] of registered.fields) {\n // Check for foreignKey relationships\n if (field.type === 'foreignKey' && field.related) {\n relationships.push({\n sourceClass: simpleName,\n sourceQualifiedClass,\n fieldName,\n targetClass: field.related,\n targetQualifiedClass: resolveTarget(registered, field),\n type: 'foreignKey',\n options: field._meta,\n });\n }\n\n // Check for crossPackageRef relationships (cross-package, no DDL FK)\n if (field.type === 'crossPackageRef' && field.related) {\n relationships.push({\n sourceClass: simpleName,\n sourceQualifiedClass,\n fieldName,\n targetClass: field.related,\n targetQualifiedClass: resolveTarget(registered, field),\n type: 'crossPackageRef',\n options: field._meta,\n });\n }\n\n // Check for oneToMany relationships\n if (field.type === 'oneToMany' && field.related) {\n relationships.push({\n sourceClass: simpleName,\n sourceQualifiedClass,\n fieldName,\n targetClass: field.related,\n targetQualifiedClass: resolveTarget(registered, field),\n type: 'oneToMany',\n options: field._meta,\n });\n }\n\n // Check for manyToMany relationships\n if (field.type === 'manyToMany' && field.related) {\n relationships.push({\n sourceClass: simpleName,\n sourceQualifiedClass,\n fieldName,\n targetClass: field.related,\n targetQualifiedClass: resolveTarget(registered, field),\n type: 'manyToMany',\n options: field._meta,\n });\n }\n }\n\n relationshipMap.set(registered.qualifiedName || key, relationships);\n }\n\n // Preserve the public simple-name map contract where that name identifies\n // exactly one registered class. Colliding names intentionally have no alias:\n // callers with a constructor must use the qualified bucket above.\n for (const [key, registered] of classes) {\n const simpleName = registered.name || key;\n if (simpleNameEntries.get(simpleName)?.size !== 1) continue;\n const qualifiedName = registered.qualifiedName || key;\n const relationships = relationshipMap.get(qualifiedName);\n if (relationships) relationshipMap.set(simpleName, relationships);\n }\n\n return relationshipMap;\n}\n"],"mappings":";;;;;;;;;;;;;AAmBA,SAAS,cACP,YACA,OAC2B;CAC3B,MAAM,UAAU,WAAW;CAC3B,MAAM,OAAO,MAAM,OAAO;CAC1B,IAAI,OAAO,SAAS,YAAY;EAC9B,MAAM,QAAQ,MAAM,KAAK,OAAO,CAAC,CAAC,MAC/B,GAAG,WAAW,MAAM,gBAAgB,IACvC;E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,SAAS,MAAM;GACjB,CAAC;GAIH,IAAI,MAAM,SAAS,eAAe,MAAM,SACtC,cAAc,KAAK;IACjB,aAAa;IACb;IACA;IACA,aAAa,MAAM;IACnB,sBAAsB,cAAc,YAAY,KAAK;IACrD,MAAM;IACN,SAAS,MAAM;GACjB,CAAC;GAIH,IAAI,MAAM,SAAS,gBAAgB,MAAM,SACvC,cAAc,KAAK;IACjB,aAAa;IACb;IACA;IACA,aAAa,MAAM;IACnB,sBAAsB,cAAc,YAAY,KAAK;IACrD,MAAM;IACN,SAAS,MAAM;GACjB,CAAC;EAEL;EAEA,gBAAgB,IAAI,WAAW,iBAAiB,KAAK,aAAa;CACpE;CAKA,KAAK,MAAM,CAAC,KAAK,eAAe,SAAS;EACvC,MAAM,aAAa,WAAW,QAAQ;EACtC,IAAI,kBAAkB,IAAI,UAAU,CAAC,EAAE,SAAS,GAAG;EACnD,MAAM,gBAAgB,WAAW,iBAAiB;EAClD,MAAM,gBAAgB,gBAAgB,IAAI,aAAa;EACvD,IAAI,eAAe,gBAAgB,IAAI,YAAY,aAAa;CAClE;CAEA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"relationship-graph.js","names":[],"sources":["../../src/registry/relationship-graph.ts"],"sourcesContent":["/**\n * Relationship graph and dependency resolution module for the SMRT ObjectRegistry.\n *\n * Builds relationship maps and dependency graphs from registered class fields.\n *\n * Extracted from registry.ts as part of issue #1006.\n * @see https://github.com/happyvertical/smrt/issues/1006\n */\n\nimport { getInheritanceChain } from './inheritance-resolver';\nimport { findClass } from './name-resolver';\nimport { getClasses } from './shared-state';\nimport type {\n RegisteredClass,\n RegisteredField,\n RelationshipMetadata,\n} from './types';\n\n/** Resolve lazily: the target may register after the decorated child. */\nfunction resolveTarget(\n registered: RegisteredClass,\n field: RegisteredField,\n): string | null | undefined {\n const classes = getClasses();\n const ctor = field._meta?.relatedConstructor;\n if (typeof ctor === 'function') {\n const match = Array.from(classes).find(\n ([, entry]) => entry.constructor === ctor,\n );\n return match ? (match[1].qualifiedName ?? match[0]) : null;\n }\n const related = field.related;\n if (!related) return null;\n // A deprecated qualified target (#3338) resolves to the class's current\n // name, so relationship loads, inverses and delete planning all key on it.\n if (related.includes(':'))\n return (\n findClass(\n related,\n `relationship target declared on ${registered.qualifiedName ?? registered.name}`,\n )?.qualifiedName ?? related\n );\n const local = classes.get(`${registered.packageName}:${related}`);\n if (local)\n return local.qualifiedName ?? `${registered.packageName}:${related}`;\n const matches = Array.from(classes).filter(\n ([, entry]) => entry.name === related,\n );\n const distinct = [\n ...new Map(matches.map((match) => [match[1], match])).values(),\n ];\n if (distinct.length === 0) return undefined;\n if (distinct.length !== 1) return null;\n const match = matches.find(([key]) => key.includes(':')) ?? distinct[0];\n return match[1].qualifiedName ?? match[0];\n}\n\n/** Canonical target of the field's declaring class, including inherited fields. */\nexport function resolveRelationshipTarget(\n className: string,\n fieldName: string,\n): string | null | undefined {\n for (const name of [\n className,\n ...[...getInheritanceChain(className)].reverse(),\n ]) {\n const registered = findClass(name);\n const field = registered?.fields.get(fieldName);\n if (registered && field) {\n return resolveTarget(registered, {\n ...field,\n related: field.related?.split('.')[0],\n });\n }\n }\n return undefined;\n}\n\n/**\n * Build dependency graph from foreignKey relationships.\n *\n * Returns a map where keys are class names and values are arrays\n * of class names that the key depends on (via foreignKey fields).\n */\nexport function getDependencyGraph(): Map<string, string[]> {\n const classes = getClasses();\n const graph = new Map<string, string[]>();\n\n // Initialize graph with all registered classes\n for (const [_key, entry] of classes) {\n graph.set(entry.name || _key, []);\n }\n\n // Scan all fields for foreignKey relationships\n for (const [_key, registered] of classes) {\n const simpleName = registered.name || _key;\n const dependencies: string[] = [];\n\n for (const [_fieldName, field] of registered.fields) {\n if (field.type === 'foreignKey' && field.related) {\n const relatedClass = field.related;\n // Skip self-references (table can reference itself after creation)\n // Only add if the related class is registered and not self\n if (\n relatedClass !== simpleName &&\n findClass(relatedClass) !== undefined\n ) {\n dependencies.push(relatedClass);\n }\n }\n }\n\n graph.set(simpleName, dependencies);\n }\n\n return graph;\n}\n\n/**\n * Build comprehensive relationship map from all field types.\n *\n * Returns a map containing all relationships (foreignKey, oneToMany, manyToMany)\n * discovered in registered classes.\n */\nexport function getRelationshipMap(): Map<string, RelationshipMetadata[]> {\n const classes = getClasses();\n const relationshipMap = new Map<string, RelationshipMetadata[]>();\n const simpleNameEntries = new Map<string, Set<RegisteredClass>>();\n\n // Initialize map with all registered classes\n for (const [key, entry] of classes) {\n // The registry is qualified-name keyed. Keep relationship buckets on that\n // canonical identity as well: classes in separate packages may share a\n // simple name, and a later empty declaration must not overwrite an earlier\n // class's relationships.\n relationshipMap.set(entry.qualifiedName || key, []);\n const simpleName = entry.name || key;\n const entries = simpleNameEntries.get(simpleName) ?? new Set();\n entries.add(entry);\n simpleNameEntries.set(simpleName, entries);\n }\n\n // Scan all fields for relationship types\n for (const [key, registered] of classes) {\n const simpleName = registered.name || key;\n const sourceQualifiedClass = registered.qualifiedName || key;\n const relationships: RelationshipMetadata[] = [];\n\n for (const [fieldName, field] of registered.fields) {\n // Check for foreignKey relationships\n if (field.type === 'foreignKey' && field.related) {\n relationships.push({\n sourceClass: simpleName,\n sourceQualifiedClass,\n fieldName,\n targetClass: field.related,\n targetQualifiedClass: resolveTarget(registered, field),\n type: 'foreignKey',\n options: field._meta,\n });\n }\n\n // Check for crossPackageRef relationships (cross-package, no DDL FK)\n if (field.type === 'crossPackageRef' && field.related) {\n relationships.push({\n sourceClass: simpleName,\n sourceQualifiedClass,\n fieldName,\n targetClass: field.related,\n targetQualifiedClass: resolveTarget(registered, field),\n type: 'crossPackageRef',\n options: field._meta,\n });\n }\n\n // Check for oneToMany relationships\n if (field.type === 'oneToMany' && field.related) {\n relationships.push({\n sourceClass: simpleName,\n sourceQualifiedClass,\n fieldName,\n targetClass: field.related,\n targetQualifiedClass: resolveTarget(registered, field),\n type: 'oneToMany',\n options: field._meta,\n });\n }\n\n // Check for manyToMany relationships\n if (field.type === 'manyToMany' && field.related) {\n relationships.push({\n sourceClass: simpleName,\n sourceQualifiedClass,\n fieldName,\n targetClass: field.related,\n targetQualifiedClass: resolveTarget(registered, field),\n type: 'manyToMany',\n options: field._meta,\n });\n }\n }\n\n relationshipMap.set(registered.qualifiedName || key, relationships);\n }\n\n // Preserve the public simple-name map contract where that name identifies\n // exactly one registered class. Colliding names intentionally have no alias:\n // callers with a constructor must use the qualified bucket above.\n for (const [key, registered] of classes) {\n const simpleName = registered.name || key;\n if (simpleNameEntries.get(simpleName)?.size !== 1) continue;\n const qualifiedName = registered.qualifiedName || key;\n const relationships = relationshipMap.get(qualifiedName);\n if (relationships) relationshipMap.set(simpleName, relationships);\n }\n\n return relationshipMap;\n}\n"],"mappings":";;;;;;;;;;;;;AAmBA,SAAS,cACP,YACA,OAC2B;CAC3B,MAAM,UAAU,WAAW;CAC3B,MAAM,OAAO,MAAM,OAAO;CAC1B,IAAI,OAAO,SAAS,YAAY;EAC9B,MAAM,QAAQ,MAAM,KAAK,OAAO,CAAC,CAAC,MAC/B,GAAG,WAAW,MAAM,gBAAgB,IACvC;EACA,OAAO,QAAS,MAAM,EAAE,CAAC,iBAAiB,MAAM,KAAM;CACxD;CACA,MAAM,UAAU,MAAM;CACtB,IAAI,CAAC,SAAS,OAAO;CAGrB,IAAI,QAAQ,SAAS,GAAG,GACtB,OACE,UACE,SACA,mCAAmC,WAAW,iBAAiB,WAAW,MAC5E,CAAC,EAAE,iBAAiB;CAExB,MAAM,QAAQ,QAAQ,IAAI,GAAG,WAAW,YAAY,GAAG,SAAS;CAChE,IAAI,OACF,OAAO,MAAM,iBAAiB,GAAG,WAAW,YAAY,GAAG;CAC7D,MAAM,UAAU,MAAM,KAAK,OAAO,CAAC,CAAC,QACjC,GAAG,WAAW,MAAM,SAAS,OAChC;CACA,MAAM,WAAW,CACf,GAAG,IAAI,IAAI,QAAQ,KAAK,UAAU,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAC/D;CACA,IAAI,SAAS,WAA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S,GAAG;EACnD,MAAM,gBAAgB,WAAW,iBAAiB;EAClD,MAAM,gBAAgB,gBAAgB,IAAI,aAAa;EACvD,IAAI,eAAe,gBAAgB,IAAI,YAAY,aAAa;CAClE;CAEA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-builder.d.ts","sourceRoot":"","sources":["../../src/registry/schema-builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAO3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAc7D,OAAO,KAAK,EACV,gBAAgB,EAEhB,gBAAgB,EAChB,WAAW,EACZ,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"schema-builder.d.ts","sourceRoot":"","sources":["../../src/registry/schema-builder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAO3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAc7D,OAAO,KAAK,EACV,gBAAgB,EAEhB,gBAAgB,EAChB,WAAW,EACZ,MAAM,oBAAoB,CAAC;AA6L5B;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAIpE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,cAAc,GACtB,MAAM,GAAG,SAAS,CAWpB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAkB7D;AA6dD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAC3B,MAAM,CAAC,EAAE,cAAc,GACtB,MAAM,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAuFxE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CA4C7E;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,EACzC,KAAK,UAAQ,EACb,MAAM,CAAC,EAAE,cAAc,GACtB,MAAM,CA2DR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,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,CAuHlC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,eAAe,CAAC,MAAM,CAAC,GACjC,WAAW,CAqBb"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ConfigurationError } from "../errors.js";
|
|
2
|
+
import { conflictIndexName, nullableConflictIdentity } from "../schema/conflict-target.js";
|
|
2
3
|
import { requireForeignKeyAction, resolveForeignKeyDeleteAction } from "../schema/foreign-key-policy.js";
|
|
3
4
|
import { classnameToTablename, toSnakeCase } from "../utils/naming.js";
|
|
4
5
|
import { formatDefaultValue as formatDefaultValue$1, quoteIdentifier } from "../schema/sql-identifiers.js";
|
|
@@ -7,7 +8,6 @@ import { renderForeignKeyConstraint, schemaForeignKeys } from "../schema/foreign
|
|
|
7
8
|
import { getDDLStrategy } from "../schema/ddl/index.js";
|
|
8
9
|
import { isQualifiedName, parseQualifiedName } from "../utils/qualified-names.js";
|
|
9
10
|
import { getClasses, getCollectionTableNames } from "./shared-state.js";
|
|
10
|
-
import { conflictIndexName, nullableConflictIdentity } from "../schema/conflict-target.js";
|
|
11
11
|
import { normalizeBackfill } from "../schema/backfill.js";
|
|
12
12
|
import { findClass } from "./name-resolver.js";
|
|
13
13
|
import "../utils.js";
|
|
@@ -71,8 +71,8 @@ function getReferenceKind(fieldDef) {
|
|
|
71
71
|
if (fieldDef.type === "foreignKey") return "foreignKey";
|
|
72
72
|
if (fieldDef.type === "crossPackageRef") return "crossPackageRef";
|
|
73
73
|
}
|
|
74
|
-
function shouldEmitDefault(
|
|
75
|
-
return !(
|
|
74
|
+
function shouldEmitDefault(_fieldDef, sqlType, defaultValue) {
|
|
75
|
+
return !(sqlType === "UUID" && defaultValue === "");
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
78
|
* Fallback base columns for a table whose contributing class carries no
|
|
@@ -238,7 +238,8 @@ function applyContributorForeignKeys(tableSchema, contributor) {
|
|
|
238
238
|
const { action } = resolveForeignKeyDeleteAction({
|
|
239
239
|
declared: field._meta?.onDelete,
|
|
240
240
|
isConflictColumn: conflictColumns.has(columnName),
|
|
241
|
-
isTenantIdField: false
|
|
241
|
+
isTenantIdField: false,
|
|
242
|
+
columnName
|
|
242
243
|
});
|
|
243
244
|
column.foreignKey = {
|
|
244
245
|
table: targetTable,
|
|
@@ -615,7 +616,8 @@ function fieldsToColumns(fields, options) {
|
|
|
615
616
|
onDelete: resolveForeignKeyDeleteAction({
|
|
616
617
|
declared: fieldMeta?.onDelete,
|
|
617
618
|
isConflictColumn: conflictColumns.has(toSnakeCase(fieldName)),
|
|
618
|
-
isTenantIdField: false
|
|
619
|
+
isTenantIdField: false,
|
|
620
|
+
columnName: toSnakeCase(fieldName)
|
|
619
621
|
}).action,
|
|
620
622
|
onUpdate: fieldMeta?.onUpdate === void 0 ? "CASCADE" : requireForeignKeyAction(fieldMeta.onUpdate, `${fieldName} ON UPDATE`),
|
|
621
623
|
...typeof fieldDef._meta?.constraint === "object" ? { engines: [...fieldDef._meta.constraint.engines] } : {}
|
|
@@ -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 { 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/D,IAAI,CAAC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AO,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
|
+
{"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\n// A uuid column never defaults to '' (same rule as the manifest generator,\n// 9832f70fa): PostgreSQL stores `(''::text)::uuid` unevaluated and every\n// INSERT that omits the column fails with 22P02. This covers a plain\n// `@field({ sqlType: 'UUID' }) tenantId = ''` (TenantKey) as well as\n// tenant references.\nfunction shouldEmitDefault(\n _fieldDef: FieldDefinition,\n sqlType: SQLDataType,\n defaultValue: unknown,\n) {\n return !(sqlType === 'UUID' && defaultValue === '');\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 // for a DECLARED tenant column. Only the declared column names the index:\n // an inferred ownership column (an undeclared `tenant_id`) gets the\n // custom-key name, so its tenant-led unique is built BESIDE the legacy\n // global one (expand, then contract) and old code's\n // `ON CONFLICT (slug, context)` keeps binding during a rolling deploy.\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 columnName,\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 columnName: toSnakeCase(fieldName),\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 'J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8BAA8B;KACtC,UAAU,WAAW;KACrB,kBAAkB,gBAAgB,IAAI,YAAY,SAAS,CAAC;KAC5D,iBAAiB;KACjB,YAAY,YAAY,SAAS;IACnC,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"}
|
package/dist/registry/types.d.ts
CHANGED
|
@@ -245,6 +245,32 @@ export interface SmartObjectConfig {
|
|
|
245
245
|
* stack/package.json discovery, which can fail in bundled deployments.
|
|
246
246
|
*/
|
|
247
247
|
packageName?: string;
|
|
248
|
+
/**
|
|
249
|
+
* Deprecated qualified names (`@package/name:ClassName`) this class was
|
|
250
|
+
* registered under before it moved package or was renamed (#3338).
|
|
251
|
+
*
|
|
252
|
+
* Each entry is a lookup bridge, never a second class: qualified lookups,
|
|
253
|
+
* `SmrtPolymorphicAssociation.hydrate()`, `@crossPackageRef` and
|
|
254
|
+
* relationship targets, and playbook `model:` names that still use an old
|
|
255
|
+
* name resolve to this class, logging a one-time deprecation warning per
|
|
256
|
+
* name. The alias never owns a table, route, tool, or `getAllClasses()`
|
|
257
|
+
* entry, and new writes store the current qualified name. An alias that
|
|
258
|
+
* equals a live class's qualified name, or that two classes both declare,
|
|
259
|
+
* is a `CONFIG_QUALIFIED_NAME_ALIAS_COLLISION` error.
|
|
260
|
+
*
|
|
261
|
+
* Removing an entry is a breaking change: ship it only once
|
|
262
|
+
* `smrt doctor --db` reports no stored references to that name. See
|
|
263
|
+
* `packages/core/agents/model-moves.md`.
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* ```typescript
|
|
267
|
+
* @smrt({
|
|
268
|
+
* previousQualifiedNames: ['@happyvertical/smrt-projects:ServiceTimeEntry'],
|
|
269
|
+
* })
|
|
270
|
+
* export class ServiceTimeEntry extends SmrtObject {}
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
previousQualifiedNames?: string[];
|
|
248
274
|
/**
|
|
249
275
|
* Custom table name for database storage (defaults to pluralized snake_case class name)
|
|
250
276
|
* Explicitly setting this ensures the table name survives code minification
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/registry/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EACV,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,uBAAuB,EACvB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAE5B;;;GAGG;AAEH,MAAM,MAAM,qBAAqB,GAAG,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,UAAU,CAAC;AAEvE,MAAM,MAAM,aAAa,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