@happyvertical/smrt-core 0.40.70 → 0.41.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 +2 -2
- package/agents/change-feed.md +1 -1
- package/agents/schema-paths.md +487 -29
- package/dist/browser.js +5 -4
- package/dist/cascade.d.ts +120 -0
- package/dist/cascade.d.ts.map +1 -0
- package/dist/cascade.js +430 -0
- package/dist/cascade.js.map +1 -0
- package/dist/change-feed.d.ts +34 -2
- package/dist/change-feed.d.ts.map +1 -1
- package/dist/change-feed.js +52 -11
- package/dist/change-feed.js.map +1 -1
- package/dist/class.d.ts +36 -3
- package/dist/class.d.ts.map +1 -1
- package/dist/class.js +59 -5
- package/dist/class.js.map +1 -1
- package/dist/collection-cache.js +0 -0
- package/dist/collection-cache.js.map +1 -1
- package/dist/collection.d.ts +29 -0
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +66 -14
- package/dist/collection.js.map +1 -1
- package/dist/config.d.ts +10 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/decorators/index.d.ts +63 -5
- package/dist/decorators/index.d.ts.map +1 -1
- package/dist/decorators/index.js +37 -5
- package/dist/decorators/index.js.map +1 -1
- package/dist/dispatch/collections/Dispatches.d.ts.map +1 -1
- package/dist/dispatch/collections/Dispatches.js +19 -4
- package/dist/dispatch/collections/Dispatches.js.map +1 -1
- package/dist/dispatch/types.d.ts +5 -0
- package/dist/dispatch/types.d.ts.map +1 -1
- package/dist/embedded-write-queue.d.ts +46 -0
- package/dist/embedded-write-queue.d.ts.map +1 -0
- package/dist/embedded-write-queue.js +66 -0
- package/dist/embedded-write-queue.js.map +1 -0
- package/dist/embeddings/storage.d.ts +7 -0
- package/dist/embeddings/storage.d.ts.map +1 -1
- package/dist/embeddings/storage.js +29 -12
- package/dist/embeddings/storage.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/hierarchical.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -6
- package/dist/interceptors.d.ts +21 -0
- package/dist/interceptors.d.ts.map +1 -1
- package/dist/interceptors.js +27 -1
- package/dist/interceptors.js.map +1 -1
- package/dist/manifest/generator.d.ts.map +1 -1
- package/dist/manifest/generator.js +4 -7
- package/dist/manifest/generator.js.map +1 -1
- package/dist/manifest/static-manifest.js +10 -10
- 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 +19 -19
- package/dist/migrations/differ.d.ts +9 -1
- package/dist/migrations/differ.d.ts.map +1 -1
- package/dist/migrations/differ.js +10 -5
- 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/minor-units.d.ts +162 -0
- package/dist/migrations/minor-units.d.ts.map +1 -0
- package/dist/migrations/minor-units.js +381 -0
- package/dist/migrations/minor-units.js.map +1 -0
- package/dist/migrations.js +2 -1
- package/dist/object.d.ts +98 -5
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +138 -30
- package/dist/object.js.map +1 -1
- package/dist/query-bounds.d.ts +5 -1
- package/dist/query-bounds.d.ts.map +1 -1
- package/dist/query-bounds.js +5 -1
- package/dist/query-bounds.js.map +1 -1
- package/dist/registry/class-registration.d.ts.map +1 -1
- package/dist/registry/class-registration.js +3 -1
- package/dist/registry/class-registration.js.map +1 -1
- package/dist/registry/manifest-field-merge.d.ts +12 -0
- package/dist/registry/manifest-field-merge.d.ts.map +1 -1
- package/dist/registry/manifest-field-merge.js +14 -2
- package/dist/registry/manifest-field-merge.js.map +1 -1
- package/dist/registry/schema-builder.d.ts +22 -1
- package/dist/registry/schema-builder.d.ts.map +1 -1
- package/dist/registry/schema-builder.js +205 -165
- package/dist/registry/schema-builder.js.map +1 -1
- package/dist/registry/types.d.ts +3 -2
- package/dist/registry/types.d.ts.map +1 -1
- package/dist/registry.d.ts +41 -46
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +61 -83
- package/dist/registry.js.map +1 -1
- package/dist/scanner/manifest-generator.d.ts +45 -0
- package/dist/scanner/manifest-generator.d.ts.map +1 -1
- package/dist/scanner/manifest-generator.js +92 -28
- package/dist/scanner/manifest-generator.js.map +1 -1
- package/dist/schema/conflict-target.d.ts +104 -0
- package/dist/schema/conflict-target.d.ts.map +1 -0
- package/dist/schema/conflict-target.js +129 -0
- package/dist/schema/conflict-target.js.map +1 -0
- package/dist/schema/ddl/duckdb-strategy.d.ts.map +1 -1
- package/dist/schema/ddl/duckdb-strategy.js +2 -1
- package/dist/schema/ddl/duckdb-strategy.js.map +1 -1
- package/dist/schema/ddl/postgres-strategy.d.ts.map +1 -1
- package/dist/schema/ddl/postgres-strategy.js +12 -1
- package/dist/schema/ddl/postgres-strategy.js.map +1 -1
- package/dist/schema/generator.d.ts +252 -16
- package/dist/schema/generator.d.ts.map +1 -1
- package/dist/schema/generator.js +411 -106
- package/dist/schema/generator.js.map +1 -1
- package/dist/schema/index-utils.d.ts +120 -0
- package/dist/schema/index-utils.d.ts.map +1 -1
- package/dist/schema/index-utils.js +242 -1
- package/dist/schema/index-utils.js.map +1 -1
- package/dist/schema/index.d.ts +1 -1
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +2 -2
- package/dist/schema/live-parity.d.ts.map +1 -1
- package/dist/schema/live-parity.js +4 -2
- package/dist/schema/live-parity.js.map +1 -1
- package/dist/schema/system-table-shapes.d.ts +13 -0
- package/dist/schema/system-table-shapes.d.ts.map +1 -1
- package/dist/schema/system-table-shapes.js +14 -1
- package/dist/schema/system-table-shapes.js.map +1 -1
- package/dist/schema/utils.d.ts +1 -1
- package/dist/schema/utils.d.ts.map +1 -1
- package/dist/schema/utils.js +3 -3
- package/dist/schema/utils.js.map +1 -1
- package/dist/schema.js +2 -2
- package/dist/smrt-knowledge.json +9 -9
- package/dist/system/compatibility.d.ts +42 -0
- package/dist/system/compatibility.d.ts.map +1 -1
- package/dist/system/compatibility.js +182 -9
- package/dist/system/compatibility.js.map +1 -1
- package/dist/system/index.d.ts +1 -0
- package/dist/system/index.d.ts.map +1 -1
- package/dist/system/index.js +3 -2
- package/dist/system/retention.d.ts +237 -0
- package/dist/system/retention.d.ts.map +1 -0
- package/dist/system/retention.js +497 -0
- package/dist/system/retention.js.map +1 -0
- package/dist/system/schema.d.ts +100 -15
- package/dist/system/schema.d.ts.map +1 -1
- package/dist/system/schema.js +81 -45
- package/dist/system/schema.js.map +1 -1
- package/dist/system/types.d.ts +0 -2
- package/dist/system/types.d.ts.map +1 -1
- package/dist/testing/database.d.ts.map +1 -1
- package/dist/testing/database.js.map +1 -1
- package/dist/vite-plugin/index.d.ts.map +1 -1
- package/dist/vite-plugin/index.js +4 -9
- package/dist/vite-plugin/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-builder.js","names":[],"sources":["../../src/registry/schema-builder.ts"],"sourcesContent":["/**\n * Schema building logic for the SMRT ObjectRegistry.\n *\n * Extracted from registry.ts as part of issue #1006.\n */\n\nimport { ObjectRegistry } from '../registry';\nimport type { FieldDefinition } from '../scanner/types.js';\nimport { getDDLStrategy } from '../schema/ddl/index.js';\nimport type { DatabaseEngine } from '../schema/ddl/types.js';\nimport {\n formatDefaultValue as formatDefaultValueShared,\n quoteIdentifier,\n} from '../schema/sql-identifiers.js';\nimport type {\n ColumnDefinition,\n IndexDefinition,\n SchemaDefinition,\n SQLDataType,\n} from '../schema/types.js';\nimport { classnameToTablename, toSnakeCase } from '../utils';\nimport {\n type CollectionRegistrationLookup,\n isCollectionRegistration,\n} from './collection-resolution';\nimport { findClass } from './name-resolver';\nimport { getClasses, getCollectionTableNames } from './shared-state';\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): Record<string, ColumnDefinition> {\n const columnsToUse = { ...(schemaColumns || {}) };\n\n if (fields.size > 0) {\n const fieldColumns = fieldsToColumns(fields);\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 columnsToUse[columnName] = {\n ...existing,\n ...(sqlType\n ? { type: String(sqlType).toUpperCase() as SQLDataType }\n : {}),\n ...(referenceKind ? { referenceKind } : {}),\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(fieldDef: FieldDefinition, sqlType: SQLDataType) {\n return !(\n getReferenceKind(fieldDef) === 'tenantId' &&\n sqlType === 'UUID' &&\n fieldDef.default === ''\n );\n}\n\nfunction createBaseColumns(registered: {\n config?: { idType?: 'uuid' | 'text' };\n}): Record<string, ColumnDefinition> {\n return {\n id: {\n type: registered.config?.idType === 'text' ? 'TEXT' : 'UUID',\n primaryKey: true,\n referenceKind: 'id',\n },\n slug: { type: 'TEXT', notNull: true },\n context: { type: 'TEXT' },\n created_at: { type: 'TIMESTAMP' },\n updated_at: { type: 'TIMESTAMP' },\n };\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 const hasConflictIndex = 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 if (hasConflictIndex) return indexes;\n\n const nameColumns =\n conflictColumns.length > 2 ? conflictColumns.slice(0, 2) : conflictColumns;\n const preferredName = `${tableName}_${nameColumns.join('_')}_idx`;\n const name = indexes.some((index) => index.name === preferredName)\n ? `${preferredName}_unique`\n : preferredName;\n return [\n ...indexes,\n {\n name,\n columns: conflictColumns,\n unique: true,\n },\n ];\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: Collect all schemas grouped by tableName\n // For STI, multiple classes may share the same table\n const tableSchemas: Record<\n string,\n {\n tableName: string;\n columns: Record<string, ColumnDefinition>;\n indexes: IndexDefinition[];\n ddl: string;\n isSTI: boolean;\n conflictColumns: string[];\n }\n > = {};\n\n for (const [_className, registered] of getClasses()) {\n // Skip collection classes - they don't have their own tables\n // Their schemas incorrectly contain collection properties (loaded, options, etc.)\n if (\n isCollectionRegistration(\n _className,\n registered,\n collectionRegistrationLookup,\n )\n ) {\n continue;\n }\n\n // Issue #951: Use simple name for STI comparisons (map key may be qualified)\n const simpleName = registered.name || _className;\n\n // Issue #703: Handle STI subclasses with null tableName from external manifests\n // When loaded from external manifests, tableName may be null, causing\n // registerFromManifest() to derive a tableName from class name.\n // For STI subclasses, we need to use the STI base's tableName instead.\n if (!registered.schema?.tableName && registered.extends) {\n // R5-canon: use the qualified key for STI lookups so colliding\n // simple names don't resolve to the wrong package's class.\n // `getTableStrategy` / `getSTIBase` both accept qualified names\n // via `findClass`'s multi-strategy lookup.\n const qualifiedName = registered.qualifiedName ?? simpleName;\n const lookupKey = qualifiedName;\n const tableStrategy = ObjectRegistry.getTableStrategy(lookupKey);\n if (tableStrategy === 'sti') {\n const stiBaseName = ObjectRegistry.getSTIBase(lookupKey);\n if (stiBaseName && stiBaseName !== qualifiedName) {\n const stiBaseClass = findClass(stiBaseName);\n if (stiBaseClass?.schema?.tableName) {\n // Ensure we have a schema object to modify\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 // Set tableName from STI base so the following block processes this class\n registered.schema.tableName = stiBaseClass.schema.tableName;\n }\n }\n }\n }\n\n if (registered.schema?.tableName) {\n // For STI subclasses, use the STI base class's tableName\n // This ensures all STI subclass columns are merged into the parent table\n // (Issue #693: STI subclasses with separate tableName still serialize to parent table)\n let tableName = registered.schema.tableName;\n // R5-canon: same qualified-key strategy as the block above.\n const qualifiedName = registered.qualifiedName ?? simpleName;\n const lookupKey = qualifiedName;\n const tableStrategy = ObjectRegistry.getTableStrategy(lookupKey);\n if (tableStrategy === 'sti') {\n const stiBaseName = ObjectRegistry.getSTIBase(lookupKey);\n if (stiBaseName && stiBaseName !== qualifiedName) {\n // This is an STI subclass - use the base class's tableName\n const stiBaseClass = findClass(stiBaseName);\n if (stiBaseClass?.schema?.tableName) {\n tableName = stiBaseClass.schema.tableName;\n }\n }\n }\n\n // Start with manifest columns, then backfill any columns that only exist\n // in runtime field metadata (for example tenantScoped injections). We do\n // not replace existing manifest column metadata here, because the manifest\n // is authoritative for foreign keys, defaults, and other schema details.\n // Explicit decorator sqlType overrides are patched onto the merged column.\n const columnsToUse = mergeRuntimeFieldColumns(\n simpleName,\n registered.schema.columns,\n registered.fields,\n );\n\n if (!tableSchemas[tableName]) {\n // First class for this table - initialize with base columns\n // These are required for all tables but are skipped by fieldsToColumns()\n const baseColumns = createBaseColumns(registered);\n\n // For STI tables, add discriminator and data columns\n // (Issue #690: db:diff needs these columns to detect schema changes)\n const isSTI = tableStrategy === 'sti';\n if (isSTI) {\n baseColumns._meta_type = {\n type: 'TEXT',\n notNull: true,\n defaultValue: '',\n };\n baseColumns._meta_data = { type: 'JSON' };\n }\n\n tableSchemas[tableName] = {\n tableName,\n columns: { ...baseColumns, ...columnsToUse },\n indexes: [],\n ddl: registered.schema.ddl || '',\n isSTI,\n conflictColumns: ObjectRegistry.getConflictColumns(\n isSTI\n ? ObjectRegistry.getSTIBase(lookupKey) || lookupKey\n : lookupKey,\n ),\n };\n } else {\n // Additional class sharing this table (STI scenario)\n // Merge columns from this class into the existing schema\n for (const [colName, colDef] of Object.entries(columnsToUse)) {\n if (!tableSchemas[tableName].columns[colName]) {\n // New column from this subtype - add it\n tableSchemas[tableName].columns[colName] = colDef;\n }\n }\n }\n\n // Merge indexes (avoid duplicates by name)\n if (registered.schema.indexes && registered.schema.indexes.length > 0) {\n const existingNames = new Set(\n tableSchemas[tableName].indexes.map((idx) =>\n typeof idx === 'string' ? idx : idx.name,\n ),\n );\n for (const idx of registered.schema.indexes) {\n const indexName = typeof idx === 'string' ? idx : idx.name;\n if (!existingNames.has(indexName)) {\n if (typeof idx === 'string') {\n // Legacy string format - skip, can't merge properly\n } else {\n tableSchemas[tableName].indexes.push(idx);\n existingNames.add(idx.name);\n }\n }\n }\n }\n }\n }\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\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: Collect all schemas grouped by tableName\n // For STI, multiple classes may share the same table\n const tableSchemas: Record<\n string,\n {\n tableName: string;\n columns: Record<string, ColumnDefinition>;\n indexes: IndexDefinition[];\n isSTI: boolean;\n conflictColumns: string[];\n }\n > = {};\n\n for (const [_className, registered] of getClasses()) {\n // Skip collection classes - they don't have their own tables\n if (\n isCollectionRegistration(\n _className,\n registered,\n collectionRegistrationLookup,\n )\n ) {\n continue;\n }\n\n // Issue #951: Use simple name for STI comparisons (map key may be qualified)\n const simpleName = registered.name || _className;\n\n // Handle STI subclasses with null tableName from external manifests\n if (!registered.schema?.tableName && registered.extends) {\n // R5-canon: use the qualified key for STI lookups so colliding\n // simple names don't resolve to the wrong package's class.\n // `getTableStrategy` / `getSTIBase` both accept qualified names\n // via `findClass`'s multi-strategy lookup.\n const qualifiedName = registered.qualifiedName ?? simpleName;\n const lookupKey = qualifiedName;\n const tableStrategy = ObjectRegistry.getTableStrategy(lookupKey);\n if (tableStrategy === 'sti') {\n const stiBaseName = ObjectRegistry.getSTIBase(lookupKey);\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 // For STI subclasses, use the STI base class's tableName.\n // R5-canon: qualified-key lookup so a colliding simple name in\n // another package can't yield the wrong tableStrategy / STI base\n // and move this class's columns under that other package's table.\n let tableName = registered.schema.tableName;\n const qualifiedName = registered.qualifiedName ?? simpleName;\n const lookupKey = qualifiedName;\n const tableStrategy = ObjectRegistry.getTableStrategy(lookupKey);\n if (tableStrategy === 'sti') {\n const stiBaseName = ObjectRegistry.getSTIBase(lookupKey);\n if (stiBaseName && stiBaseName !== qualifiedName) {\n const stiBaseClass = findClass(stiBaseName);\n if (stiBaseClass?.schema?.tableName) {\n tableName = stiBaseClass.schema.tableName;\n }\n }\n }\n\n // Manifest schema remains authoritative for existing columns. Runtime\n // field metadata can backfill missing columns and apply explicit sqlType\n // overrides without erasing richer manifest metadata.\n const columnsToUse = mergeRuntimeFieldColumns(\n simpleName,\n registered.schema.columns,\n registered.fields,\n );\n\n if (!tableSchemas[tableName]) {\n // First class for this table - initialize with base columns\n const baseColumns = createBaseColumns(registered);\n\n const isSTI = tableStrategy === 'sti';\n if (isSTI) {\n baseColumns._meta_type = {\n type: 'TEXT',\n notNull: true,\n defaultValue: '',\n };\n baseColumns._meta_data = { type: 'JSON' };\n }\n\n tableSchemas[tableName] = {\n tableName,\n columns: { ...baseColumns, ...columnsToUse },\n indexes: [],\n isSTI,\n conflictColumns: ObjectRegistry.getConflictColumns(\n isSTI\n ? ObjectRegistry.getSTIBase(lookupKey) || lookupKey\n : lookupKey,\n ),\n };\n } else {\n // Additional class sharing this table (STI scenario) - merge columns\n for (const [colName, colDef] of Object.entries(columnsToUse)) {\n if (!tableSchemas[tableName].columns[colName]) {\n tableSchemas[tableName].columns[colName] = colDef;\n }\n }\n }\n\n // Merge indexes (avoid duplicates by name)\n if (registered.schema.indexes && registered.schema.indexes.length > 0) {\n const existingNames = new Set(\n tableSchemas[tableName].indexes.map((idx) => idx.name),\n );\n for (const idx of registered.schema.indexes) {\n if (!existingNames.has(idx.name)) {\n tableSchemas[tableName].indexes.push(idx);\n existingNames.add(idx.name);\n }\n }\n }\n }\n }\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\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: [],\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\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 * 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 * @param fields - Map of field name to field definition\n * @returns Record of column name to column definition\n * @private\n */\nexport function fieldsToColumns(\n fields: Map<string, FieldDefinition>,\n): Record<string, ColumnDefinition> {\n const columns: Record<string, ColumnDefinition> = {};\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 column: ColumnDefinition = {\n type: normalizedSqlType,\n referenceKind,\n notNull: fieldDef._meta?.nullable ? false : fieldDef.required || false,\n unique: fieldDef._meta?.unique || false,\n description: fieldDef.description,\n };\n\n // Handle default values\n if (\n fieldDef.default !== undefined &&\n shouldEmitDefault(fieldDef, normalizedSqlType)\n ) {\n column.defaultValue = fieldDef.default;\n }\n\n // Handle foreign keys\n if (fieldDef.type === 'foreignKey' && fieldDef.related) {\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: fieldMeta?.onDelete ?? 'CASCADE',\n onUpdate: fieldMeta?.onUpdate ?? 'CASCADE',\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":";;;;;;;;;;;;;;AAgCA,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,QACkC;CAClC,MAAM,eAAe,EAAE,GAAI,iBAAiB,CAAC,EAAG;CA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AAY;IACjC,UAAU,WAAW,YAAY;GACnC;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 { ObjectRegistry } from '../registry';\nimport type { FieldDefinition } from '../scanner/types.js';\nimport { conflictIndexName } from '../schema/conflict-target.js';\nimport { getDDLStrategy } from '../schema/ddl/index.js';\nimport type { DatabaseEngine } from '../schema/ddl/types.js';\nimport { shortenIdentifier } from '../schema/index-utils.js';\nimport {\n formatDefaultValue as formatDefaultValueShared,\n quoteIdentifier,\n} from '../schema/sql-identifiers.js';\nimport type {\n ColumnDefinition,\n IndexDefinition,\n SchemaDefinition,\n SQLDataType,\n} from '../schema/types.js';\nimport { classnameToTablename, toSnakeCase } from '../utils';\nimport {\n type CollectionRegistrationLookup,\n isCollectionRegistration,\n} from './collection-resolution';\nimport { 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 columnsToUse[columnName] = {\n ...existing,\n ...(sqlType\n ? { type: String(sqlType).toUpperCase() as SQLDataType }\n : {}),\n ...(referenceKind ? { referenceKind } : {}),\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 const hasConflictIndex = 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 if (hasConflictIndex) return indexes;\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 conflictIndex: IndexDefinition = {\n name,\n columns: conflictColumns,\n unique: true,\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\n/**\n * Resolve the physical table a registered class writes to.\n *\n * STI subclasses are folded onto their base's table. Returns `undefined` when\n * the class has no table (for example an unresolvable manifest stub).\n *\n * R5-canon: STI lookups use the qualified key so a colliding simple name in\n * another package cannot yield the wrong table strategy or STI base and move\n * this class's columns under that other package's table.\n */\nfunction resolveContributorTable(\n registered: RegisteredClass,\n fallbackName: string,\n): { tableName: string; contributor: TableContributor } | undefined {\n const simpleName = registered.name || fallbackName;\n const qualifiedName = registered.qualifiedName ?? simpleName;\n\n // STI subclasses loaded from external manifests can arrive with a null\n // tableName; registerFromManifest() then derives one from the class name.\n // Adopt the STI base's tableName instead so the subclass lands on the\n // shared table (issue #703).\n if (!registered.schema?.tableName && registered.extends) {\n if (ObjectRegistry.getTableStrategy(qualifiedName) === 'sti') {\n const stiBaseName = ObjectRegistry.getSTIBase(qualifiedName);\n if (stiBaseName && stiBaseName !== qualifiedName) {\n const stiBaseClass = findClass(stiBaseName);\n if (stiBaseClass?.schema?.tableName) {\n if (!registered.schema) {\n registered.schema = {\n tableName: '',\n ddl: '',\n columns: {},\n indexes: [],\n triggers: [],\n foreignKeys: [],\n dependencies: [],\n version: '',\n };\n }\n registered.schema.tableName = stiBaseClass.schema.tableName;\n }\n }\n }\n }\n\n if (!registered.schema?.tableName) {\n return undefined;\n }\n\n let tableName = registered.schema.tableName;\n const tableStrategy = ObjectRegistry.getTableStrategy(qualifiedName);\n const isSTI = tableStrategy === 'sti';\n let isSTIBase = isSTI;\n let conflictKey = qualifiedName;\n\n if (isSTI) {\n const stiBaseName = ObjectRegistry.getSTIBase(qualifiedName);\n if (stiBaseName) {\n conflictKey = stiBaseName;\n if (stiBaseName !== qualifiedName) {\n isSTIBase = false;\n // STI subclasses serialize to the base class's table even when they\n // carry a tableName of their own (issue #693).\n const stiBaseClass = findClass(stiBaseName);\n if (stiBaseClass?.schema?.tableName) {\n tableName = stiBaseClass.schema.tableName;\n }\n }\n }\n }\n\n return {\n tableName,\n contributor: {\n registered,\n simpleName,\n qualifiedName,\n isSTI,\n isSTIBase,\n depth: ObjectRegistry.getInheritanceChain(qualifiedName).length,\n conflictKey,\n },\n };\n}\n\n/**\n * Order the classes that share one table deterministically.\n *\n * The first contributor seeds the table: it supplies the base columns, the\n * `idType`, the conflict columns and the cached DDL, and its columns win every\n * merge conflict. Registration order must not decide that, or the same\n * hierarchy yields a different table shape depending on which class a manifest\n * happens to list first — child-first dropped NOT NULL and DEFAULT from the\n * base columns (#2372).\n *\n * Order: the STI base first, then ancestors before descendants, then by\n * qualified name so the result is a total order.\n */\nfunction sortTableContributors(contributors: TableContributor[]) {\n return [...contributors].sort((a, b) => {\n if (a.isSTIBase !== b.isSTIBase) {\n return a.isSTIBase ? -1 : 1;\n }\n if (a.depth !== b.depth) {\n return a.depth - b.depth;\n }\n return a.qualifiedName.localeCompare(b.qualifiedName);\n });\n}\n\n/**\n * Assemble every physical table from the classes that contribute to it.\n *\n * Shared by {@link getAllSchemas} and {@link getAllSchemasAsDefinitions} so\n * both produce the same merged shape. The result depends only on what is\n * registered, never on the order it was registered in.\n */\nfunction buildMergedTableSchemas(): Record<string, MergedTableSchema> {\n // Pass 1: group contributing classes by physical table.\n const contributorsByTable = new Map<string, TableContributor[]>();\n\n for (const [className, registered] of getClasses()) {\n // Collection classes have no table of their own; their schemas carry\n // collection properties (loaded, options, ...) rather than columns.\n if (\n isCollectionRegistration(\n className,\n registered,\n collectionRegistrationLookup,\n )\n ) {\n continue;\n }\n\n const resolved = resolveContributorTable(registered, className);\n if (!resolved) {\n continue;\n }\n\n const existing = contributorsByTable.get(resolved.tableName);\n if (existing) {\n existing.push(resolved.contributor);\n } else {\n contributorsByTable.set(resolved.tableName, [resolved.contributor]);\n }\n }\n\n // Pass 2: merge each table's contributors in deterministic order.\n const tableSchemas: Record<string, MergedTableSchema> = {};\n\n for (const [tableName, contributors] of contributorsByTable) {\n for (const contributor of sortTableContributors(contributors)) {\n const { registered, simpleName, isSTI } = contributor;\n\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 },\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: ObjectRegistry.getConflictColumns(\n contributor.conflictKey,\n ),\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 // 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\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\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: [],\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\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\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\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\n // Handle foreign keys\n if (fieldDef.type === 'foreignKey' && fieldDef.related) {\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: fieldMeta?.onDelete ?? 'CASCADE',\n onUpdate: fieldMeta?.onUpdate ?? 'CASCADE',\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":";;;;;;;;;;;;;;;;;AAoCA,IAAM,+BAA6D;CACjE;CACA,qBAAqB,aAAa,cAChC,eAAe,kBAAkB,aAA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AAa;IAClB,OAAO,qBAAqB,KAAK;IACjC,QAAQ;IACR,UAAU,WAAW,YAAY;IACjC,UAAU,WAAW,YAAY;GACnC;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
|
@@ -715,8 +715,9 @@ export interface RelationshipMetadata {
|
|
|
715
715
|
* objects by folding decorator options into the AST-scanned field, which
|
|
716
716
|
* attaches a few extra runtime-only members beyond the scanner contract:
|
|
717
717
|
*
|
|
718
|
-
* - `options`: legacy mirror of the decorator option bag
|
|
719
|
-
* `_smrt_registry` snapshot row
|
|
718
|
+
* - `options`: legacy mirror of the decorator option bag. It used to be
|
|
719
|
+
* persisted into the retired `_smrt_registry` snapshot row and is now only
|
|
720
|
+
* read in-process (issue #2376).
|
|
720
721
|
* - `validate`: optional cross-package-ref validation hint read off either the
|
|
721
722
|
* field or its `_meta` bag (`object.ts` `validateCrossPackageRefs`).
|
|
722
723
|
* - `__report`: report-aggregate marker mirrored at the top level for the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/registry/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACvE,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,C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KAChC,CAAC;IACF;;;;;OAKG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B"}
|
package/dist/registry.d.ts
CHANGED
|
@@ -1071,16 +1071,29 @@ export declare class ObjectRegistry {
|
|
|
1071
1071
|
/**
|
|
1072
1072
|
* Get the conflict columns for UPSERT operations on a class
|
|
1073
1073
|
*
|
|
1074
|
-
*
|
|
1075
|
-
* table
|
|
1076
|
-
*
|
|
1077
|
-
*
|
|
1074
|
+
* The conflict target is a property of the TABLE, resolved from its
|
|
1075
|
+
* schema-owning class — the STI root for a single-table hierarchy, the
|
|
1076
|
+
* class itself otherwise — so every class sharing a table upserts on the
|
|
1077
|
+
* same key the schema indexes. In order:
|
|
1078
|
+
*
|
|
1079
|
+
* 1. explicit `@smrt({ conflictColumns })` on the schema owner;
|
|
1080
|
+
* 2. `@report` classes: `[tenant column, ...group/bucket columns]`, or
|
|
1081
|
+
* `['id']` when the report declares no grouping;
|
|
1082
|
+
* 3. a custom primary key (`@field({ primaryKey: true })`): the declared
|
|
1083
|
+
* primary-key column(s) — the only unique key such a table has;
|
|
1084
|
+
* 4. the strategy default — CTI `['slug', 'context']`, STI
|
|
1085
|
+
* `['slug', 'context', '_meta_type']` — led by the tenant column when
|
|
1086
|
+
* the schema owner is tenant-scoped (#2360): tenant-scoped rows are
|
|
1087
|
+
* unique per tenant, and without the tenant column a second tenant's
|
|
1088
|
+
* `save()` of the same natural key updated the first tenant's row
|
|
1089
|
+
* through `DO UPDATE SET`.
|
|
1078
1090
|
*
|
|
1079
1091
|
* STI subclasses share a table, so the discriminator participates in
|
|
1080
1092
|
* identity — two subtypes can coexist with the same (slug, context). The
|
|
1081
|
-
* matching unique
|
|
1082
|
-
*
|
|
1083
|
-
*
|
|
1093
|
+
* matching unique index must exist in the live schema; if a deployment
|
|
1094
|
+
* carries a stale shape, `smrt db:migrate` swaps it in place (issue #1165,
|
|
1095
|
+
* #2360). NULL-tenant rows dedup through the SDK's null-aware upsert
|
|
1096
|
+
* (`IS NOT DISTINCT FROM`), see `schema/conflict-target.ts`.
|
|
1084
1097
|
*
|
|
1085
1098
|
* @param className - Name of the class to get conflict columns for
|
|
1086
1099
|
* @returns Array of column names to use for conflict detection
|
|
@@ -1093,9 +1106,30 @@ export declare class ObjectRegistry {
|
|
|
1093
1106
|
*
|
|
1094
1107
|
* ObjectRegistry.getConflictColumns('EventParticipant');
|
|
1095
1108
|
* // Returns: ['event_id', 'profile_id']
|
|
1109
|
+
*
|
|
1110
|
+
* @smrt({ tenantScoped: true })
|
|
1111
|
+
* class Document extends SmrtObject {}
|
|
1112
|
+
*
|
|
1113
|
+
* ObjectRegistry.getConflictColumns('Document');
|
|
1114
|
+
* // Returns: ['tenant_id', 'slug', 'context']
|
|
1096
1115
|
* ```
|
|
1097
1116
|
*/
|
|
1098
1117
|
static getConflictColumns(className: string): string[];
|
|
1118
|
+
/**
|
|
1119
|
+
* The tenant column of the table a class writes to, or `undefined` when its
|
|
1120
|
+
* schema owner (the STI root for a single-table hierarchy, the class itself
|
|
1121
|
+
* otherwise) is not tenant-scoped (#2360).
|
|
1122
|
+
*
|
|
1123
|
+
* Resolved from the owner's normalized `tenantScoped` configuration
|
|
1124
|
+
* (`@smrt({ tenantScoped })`, or `@TenantScoped()` carried by the
|
|
1125
|
+
* manifest), never from the standalone tenancy registry: the schema
|
|
1126
|
+
* generator and `getConflictColumns()` must agree before any interceptor
|
|
1127
|
+
* is enabled.
|
|
1128
|
+
*
|
|
1129
|
+
* @param className - Name of the class (simple or qualified)
|
|
1130
|
+
* @returns The snake_case tenant column name, e.g. `tenant_id`
|
|
1131
|
+
*/
|
|
1132
|
+
static getTenantColumn(className: string): string | undefined;
|
|
1099
1133
|
/**
|
|
1100
1134
|
* Get the tenant scoping configuration for a class (Issue #688)
|
|
1101
1135
|
*
|
|
@@ -1191,45 +1225,6 @@ export declare class ObjectRegistry {
|
|
|
1191
1225
|
* ```
|
|
1192
1226
|
*/
|
|
1193
1227
|
static getDescendants(className: string): string[];
|
|
1194
|
-
/**
|
|
1195
|
-
* Persist registry state to system tables
|
|
1196
|
-
*
|
|
1197
|
-
* Saves all registered class metadata to the _smrt_registry system table
|
|
1198
|
-
* for runtime introspection and debugging. This enables applications to
|
|
1199
|
-
* query what SMRT objects exist and their configurations.
|
|
1200
|
-
*
|
|
1201
|
-
* @param db - Database interface to persist to
|
|
1202
|
-
* @returns Promise that resolves when persistence is complete
|
|
1203
|
-
* @example
|
|
1204
|
-
* ```typescript
|
|
1205
|
-
* // After registering all classes
|
|
1206
|
-
* await ObjectRegistry.persistToDatabase(db);
|
|
1207
|
-
*
|
|
1208
|
-
* // Later, query the system table
|
|
1209
|
-
* const rows = await db.all('SELECT * FROM _smrt_registry');
|
|
1210
|
-
* console.log('Registered classes:', rows.map(r => r.class_name));
|
|
1211
|
-
* ```
|
|
1212
|
-
*/
|
|
1213
|
-
static persistToDatabase(db: import('@happyvertical/sql').DatabaseInterface): Promise<void>;
|
|
1214
|
-
/**
|
|
1215
|
-
* Load registry metadata from system tables
|
|
1216
|
-
*
|
|
1217
|
-
* Reads the _smrt_registry system table to inspect what classes
|
|
1218
|
-
* have been registered. This is primarily for introspection and
|
|
1219
|
-
* debugging - actual class registration happens via @smrt() decorator.
|
|
1220
|
-
*
|
|
1221
|
-
* @param db - Database interface to load from
|
|
1222
|
-
* @returns Promise resolving to array of class metadata
|
|
1223
|
-
* @example
|
|
1224
|
-
* ```typescript
|
|
1225
|
-
* const metadata = await ObjectRegistry.loadFromDatabase(db);
|
|
1226
|
-
* for (const meta of metadata) {
|
|
1227
|
-
* console.log(`Class: ${meta.class_name}`);
|
|
1228
|
-
* console.log(`Table: ${JSON.parse(meta.manifest).tableName}`);
|
|
1229
|
-
* }
|
|
1230
|
-
* ```
|
|
1231
|
-
*/
|
|
1232
|
-
static loadFromDatabase(db: import('@happyvertical/sql').DatabaseInterface): Promise<Record<string, unknown>[]>;
|
|
1233
1228
|
/**
|
|
1234
1229
|
* Get embedding configuration for a class
|
|
1235
1230
|
*
|
package/dist/registry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,OAAO,EACL,cAAc,EAEd,KAAK,qBAAqB,EAC3B,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAUhD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAS3C,OAAO,EAIL,KAAK,kBAAkB,EAExB,MAAM,wBAAwB,CAAC;AA8DhC,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACf,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,OAAO,EACL,cAAc,EAEd,KAAK,qBAAqB,EAC3B,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB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AAE,MAAM,GAAG,MAAM,GAAG,IAAI;IA4CnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;IA0ClD;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,MAAM,CAAC,kBAAkB,CACvB,SAAS,EAAE,MAAM,GAChB,oBAAoB,GAAG,SAAS;IAInC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAIhD;;;;;;;;;OASG;IACH,MAAM,CAAC,mBAAmB,IAAI,MAAM,EAAE;IAItC;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,yBAAyB,IAAI,sBAAsB;IAI1D;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,MAAM,CAAC,sBAAsB,CAC3B,SAAS,EAAE,MAAM,GAChB,uBAAuB,GAAG,SAAS;IAItC;;;;;;;;OAQG;IACH,MAAM,CAAC,4BAA4B,CACjC,SAAS,EAAE,MAAM,GAChB,qBAAqB,GAAG,SAAS;CAGrC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,wBAAgB,IAAI,CAAC,MAAM,GAAE,iBAAsB,IAMzC,CAAC,SAAS,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,EACvD,MAAM,CAAC,EACP,mBAAmB,qBAAqB,CAAC,CAAC,CAAC,KAC1C,CAAC,CAmML"}
|
package/dist/registry.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { applyOneToManyChildAccessors } from "./child-accessors.js";
|
|
2
1
|
import { ConfigurationError } from "./errors.js";
|
|
2
|
+
import { classnameToTablename, toSnakeCase } from "./utils/naming.js";
|
|
3
|
+
import { applyOneToManyChildAccessors } from "./child-accessors.js";
|
|
3
4
|
import { applyPendingDecoratorRegistrations } from "./decorators/compatibility.js";
|
|
4
5
|
import { clearRegistryDiagnostics, flushRegistryDiagnostics, getRegistryDiagnostics, recordRegistryDiagnostic } from "./registry/diagnostics.js";
|
|
5
6
|
import { createQualifiedName, isQualifiedName, parseQualifiedName } from "./utils/qualified-names.js";
|
|
@@ -11,7 +12,7 @@ import { getClasses, getCollectionCache, getCollectionTableNames, getCollections
|
|
|
11
12
|
import { findClass, findClassesByName, getAllClasses, getCanonicalClassName, getClass, getClassByConstructor, getClassByQualifiedName, getClassInPackage, getClassNames, getClassesByPackage, getClassesByVisibility, getPublicClasses, getQualifiedClassNames, hasClass, hasClassCaseInsensitive, resolveType } from "./registry/name-resolver.js";
|
|
12
13
|
import { getAllFields, getAllMethods, getInheritanceChain, mergeFieldConfigs } from "./registry/inheritance-resolver.js";
|
|
13
14
|
import { resolveCollectionCacheConfig } from "./registry/cache-config.js";
|
|
14
|
-
import {
|
|
15
|
+
import { defaultConflictColumns, resolveTenantColumn } from "./schema/conflict-target.js";
|
|
15
16
|
import "./utils.js";
|
|
16
17
|
import { createFieldFromManifest, manifestFieldDiffers, mergeManifestField } from "./registry/manifest-field-merge.js";
|
|
17
18
|
import { compileValidators } from "./registry/validator.js";
|
|
@@ -1664,16 +1665,29 @@ var ObjectRegistry = class ObjectRegistry {
|
|
|
1664
1665
|
/**
|
|
1665
1666
|
* Get the conflict columns for UPSERT operations on a class
|
|
1666
1667
|
*
|
|
1667
|
-
*
|
|
1668
|
-
* table
|
|
1669
|
-
*
|
|
1670
|
-
*
|
|
1668
|
+
* The conflict target is a property of the TABLE, resolved from its
|
|
1669
|
+
* schema-owning class — the STI root for a single-table hierarchy, the
|
|
1670
|
+
* class itself otherwise — so every class sharing a table upserts on the
|
|
1671
|
+
* same key the schema indexes. In order:
|
|
1672
|
+
*
|
|
1673
|
+
* 1. explicit `@smrt({ conflictColumns })` on the schema owner;
|
|
1674
|
+
* 2. `@report` classes: `[tenant column, ...group/bucket columns]`, or
|
|
1675
|
+
* `['id']` when the report declares no grouping;
|
|
1676
|
+
* 3. a custom primary key (`@field({ primaryKey: true })`): the declared
|
|
1677
|
+
* primary-key column(s) — the only unique key such a table has;
|
|
1678
|
+
* 4. the strategy default — CTI `['slug', 'context']`, STI
|
|
1679
|
+
* `['slug', 'context', '_meta_type']` — led by the tenant column when
|
|
1680
|
+
* the schema owner is tenant-scoped (#2360): tenant-scoped rows are
|
|
1681
|
+
* unique per tenant, and without the tenant column a second tenant's
|
|
1682
|
+
* `save()` of the same natural key updated the first tenant's row
|
|
1683
|
+
* through `DO UPDATE SET`.
|
|
1671
1684
|
*
|
|
1672
1685
|
* STI subclasses share a table, so the discriminator participates in
|
|
1673
1686
|
* identity — two subtypes can coexist with the same (slug, context). The
|
|
1674
|
-
* matching unique
|
|
1675
|
-
*
|
|
1676
|
-
*
|
|
1687
|
+
* matching unique index must exist in the live schema; if a deployment
|
|
1688
|
+
* carries a stale shape, `smrt db:migrate` swaps it in place (issue #1165,
|
|
1689
|
+
* #2360). NULL-tenant rows dedup through the SDK's null-aware upsert
|
|
1690
|
+
* (`IS NOT DISTINCT FROM`), see `schema/conflict-target.ts`.
|
|
1677
1691
|
*
|
|
1678
1692
|
* @param className - Name of the class to get conflict columns for
|
|
1679
1693
|
* @returns Array of column names to use for conflict detection
|
|
@@ -1686,26 +1700,53 @@ var ObjectRegistry = class ObjectRegistry {
|
|
|
1686
1700
|
*
|
|
1687
1701
|
* ObjectRegistry.getConflictColumns('EventParticipant');
|
|
1688
1702
|
* // Returns: ['event_id', 'profile_id']
|
|
1703
|
+
*
|
|
1704
|
+
* @smrt({ tenantScoped: true })
|
|
1705
|
+
* class Document extends SmrtObject {}
|
|
1706
|
+
*
|
|
1707
|
+
* ObjectRegistry.getConflictColumns('Document');
|
|
1708
|
+
* // Returns: ['tenant_id', 'slug', 'context']
|
|
1689
1709
|
* ```
|
|
1690
1710
|
*/
|
|
1691
1711
|
static getConflictColumns(className) {
|
|
1692
1712
|
const registered = ObjectRegistry.findClass(className);
|
|
1693
|
-
if (!registered) return
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1713
|
+
if (!registered) return defaultConflictColumns("cti");
|
|
1714
|
+
const tableStrategy = ObjectRegistry.getTableStrategy(className);
|
|
1715
|
+
const ownerName = tableStrategy === "sti" ? ObjectRegistry.getSTIBase(className) : null;
|
|
1716
|
+
const owner = ownerName && ownerName !== className ? ObjectRegistry.findClass(ownerName) ?? registered : registered;
|
|
1717
|
+
if (owner.config?.conflictColumns) return owner.config.conflictColumns;
|
|
1718
|
+
if (owner.config?.report) {
|
|
1719
|
+
const reportConflictColumns = Array.from(owner.fields.entries()).filter(([, field]) => {
|
|
1699
1720
|
const kind = field?._meta?.__report?.kind ?? field?.__report?.kind;
|
|
1700
1721
|
return kind === "group" || kind === "bucket";
|
|
1701
1722
|
}).map(([fieldName]) => toSnakeCase(fieldName));
|
|
1723
|
+
const tenantColumn = ObjectRegistry.getTenantColumn(className);
|
|
1702
1724
|
return reportConflictColumns.length > 0 ? [...tenantColumn ? [tenantColumn] : [], ...reportConflictColumns] : ["id"];
|
|
1703
1725
|
}
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1726
|
+
const primaryKeyColumns = Array.from(owner.fields.entries()).filter(([, field]) => field?._meta?.primaryKey === true).map(([fieldName]) => toSnakeCase(fieldName));
|
|
1727
|
+
if (primaryKeyColumns.length > 0) return primaryKeyColumns;
|
|
1728
|
+
return defaultConflictColumns(tableStrategy, ObjectRegistry.getTenantColumn(className));
|
|
1729
|
+
}
|
|
1730
|
+
/**
|
|
1731
|
+
* The tenant column of the table a class writes to, or `undefined` when its
|
|
1732
|
+
* schema owner (the STI root for a single-table hierarchy, the class itself
|
|
1733
|
+
* otherwise) is not tenant-scoped (#2360).
|
|
1734
|
+
*
|
|
1735
|
+
* Resolved from the owner's normalized `tenantScoped` configuration
|
|
1736
|
+
* (`@smrt({ tenantScoped })`, or `@TenantScoped()` carried by the
|
|
1737
|
+
* manifest), never from the standalone tenancy registry: the schema
|
|
1738
|
+
* generator and `getConflictColumns()` must agree before any interceptor
|
|
1739
|
+
* is enabled.
|
|
1740
|
+
*
|
|
1741
|
+
* @param className - Name of the class (simple or qualified)
|
|
1742
|
+
* @returns The snake_case tenant column name, e.g. `tenant_id`
|
|
1743
|
+
*/
|
|
1744
|
+
static getTenantColumn(className) {
|
|
1745
|
+
const registered = ObjectRegistry.findClass(className);
|
|
1746
|
+
if (!registered) return void 0;
|
|
1747
|
+
const ownerName = ObjectRegistry.getTableStrategy(className) === "sti" ? ObjectRegistry.getSTIBase(className) : null;
|
|
1748
|
+
const owner = ownerName && ownerName !== className ? ObjectRegistry.findClass(ownerName) ?? registered : registered;
|
|
1749
|
+
return resolveTenantColumn(owner.tenantScopedConfig?.field, (fieldName) => owner.fields.has(fieldName), toSnakeCase);
|
|
1709
1750
|
}
|
|
1710
1751
|
/**
|
|
1711
1752
|
* Get the tenant scoping configuration for a class (Issue #688)
|
|
@@ -1830,69 +1871,6 @@ var ObjectRegistry = class ObjectRegistry {
|
|
|
1830
1871
|
return descendants;
|
|
1831
1872
|
}
|
|
1832
1873
|
/**
|
|
1833
|
-
* Persist registry state to system tables
|
|
1834
|
-
*
|
|
1835
|
-
* Saves all registered class metadata to the _smrt_registry system table
|
|
1836
|
-
* for runtime introspection and debugging. This enables applications to
|
|
1837
|
-
* query what SMRT objects exist and their configurations.
|
|
1838
|
-
*
|
|
1839
|
-
* @param db - Database interface to persist to
|
|
1840
|
-
* @returns Promise that resolves when persistence is complete
|
|
1841
|
-
* @example
|
|
1842
|
-
* ```typescript
|
|
1843
|
-
* // After registering all classes
|
|
1844
|
-
* await ObjectRegistry.persistToDatabase(db);
|
|
1845
|
-
*
|
|
1846
|
-
* // Later, query the system table
|
|
1847
|
-
* const rows = await db.all('SELECT * FROM _smrt_registry');
|
|
1848
|
-
* console.log('Registered classes:', rows.map(r => r.class_name));
|
|
1849
|
-
* ```
|
|
1850
|
-
*/
|
|
1851
|
-
static async persistToDatabase(db) {
|
|
1852
|
-
for (const [className, registered] of ObjectRegistry.classes.entries()) {
|
|
1853
|
-
const fieldsData = {};
|
|
1854
|
-
for (const [key, value] of registered.fields) fieldsData[key] = {
|
|
1855
|
-
type: value.type,
|
|
1856
|
-
options: value.options
|
|
1857
|
-
};
|
|
1858
|
-
await db.upsert("_smrt_registry", ["class_name"], {
|
|
1859
|
-
class_name: className,
|
|
1860
|
-
schema_version: "1.0.0",
|
|
1861
|
-
fields: JSON.stringify(fieldsData),
|
|
1862
|
-
relationships: JSON.stringify(ObjectRegistry.getRelationships(className)),
|
|
1863
|
-
config: JSON.stringify(registered.config),
|
|
1864
|
-
manifest: JSON.stringify({
|
|
1865
|
-
name: registered.name,
|
|
1866
|
-
tableName: registered.schema?.tableName,
|
|
1867
|
-
tools: registered.tools
|
|
1868
|
-
}),
|
|
1869
|
-
last_updated: /* @__PURE__ */ new Date()
|
|
1870
|
-
});
|
|
1871
|
-
}
|
|
1872
|
-
}
|
|
1873
|
-
/**
|
|
1874
|
-
* Load registry metadata from system tables
|
|
1875
|
-
*
|
|
1876
|
-
* Reads the _smrt_registry system table to inspect what classes
|
|
1877
|
-
* have been registered. This is primarily for introspection and
|
|
1878
|
-
* debugging - actual class registration happens via @smrt() decorator.
|
|
1879
|
-
*
|
|
1880
|
-
* @param db - Database interface to load from
|
|
1881
|
-
* @returns Promise resolving to array of class metadata
|
|
1882
|
-
* @example
|
|
1883
|
-
* ```typescript
|
|
1884
|
-
* const metadata = await ObjectRegistry.loadFromDatabase(db);
|
|
1885
|
-
* for (const meta of metadata) {
|
|
1886
|
-
* console.log(`Class: ${meta.class_name}`);
|
|
1887
|
-
* console.log(`Table: ${JSON.parse(meta.manifest).tableName}`);
|
|
1888
|
-
* }
|
|
1889
|
-
* ```
|
|
1890
|
-
*/
|
|
1891
|
-
static async loadFromDatabase(db) {
|
|
1892
|
-
const { rows } = await db.query("SELECT * FROM _smrt_registry ORDER BY class_name");
|
|
1893
|
-
return rows;
|
|
1894
|
-
}
|
|
1895
|
-
/**
|
|
1896
1874
|
* Get embedding configuration for a class
|
|
1897
1875
|
*
|
|
1898
1876
|
* Returns the class-specific embedding config if embeddings are enabled.
|