nucleus-core-ts 0.10.245 → 0.10.246
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/dist/.build-ok
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.10.
|
|
1
|
+
0.10.246
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nucleus-core-ts",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.246",
|
|
4
4
|
"description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
|
|
5
5
|
"author": "Hidayet Can Özcan <hidayetcan@gmail.com>",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -50,6 +50,7 @@ export function generateSchemaFile(tables: TableDef[]): string {
|
|
|
50
50
|
if (body.includes('PgTableExtraConfigValue')) imports.add('type PgTableExtraConfigValue')
|
|
51
51
|
if (body.includes('ExtraConfigColumn')) imports.add('type ExtraConfigColumn')
|
|
52
52
|
if (body.includes('AnyPgColumn')) imports.add('type AnyPgColumn')
|
|
53
|
+
if (body.includes('AnyPgTable')) imports.add('type AnyPgTable')
|
|
53
54
|
|
|
54
55
|
const usesEncrypted = body.includes('encryptedText(')
|
|
55
56
|
let code = `import { ${Array.from(imports).sort().join(', ')} } from 'drizzle-orm/pg-core';\n`
|
|
@@ -67,7 +68,7 @@ function generateCreateAllForSchemaFunction(tables: TableDef[], allTableNames: s
|
|
|
67
68
|
|
|
68
69
|
let code = `/** \`{ tenant: true }\` leaves out the main-only tables; the main schema is built without it. */\n`
|
|
69
70
|
code += `export function createAllTablesForSchema(\n\tschema: ReturnType<typeof pgSchema>,\n\toptions?: { tenant?: boolean }\n) {\n`
|
|
70
|
-
code += `\tconst tables: Record<string,
|
|
71
|
+
code += `\tconst tables: Record<string, AnyPgTable> = {};\n\n`
|
|
71
72
|
|
|
72
73
|
for (const table of sortedTables) {
|
|
73
74
|
const tableName = toCamelCase(table.table_name)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test'
|
|
2
|
+
import systemTables from '../../src/system.tables.json'
|
|
3
|
+
import { generateSchemaFile } from './schemaFile'
|
|
4
|
+
import type { TableDef } from './types'
|
|
5
|
+
|
|
6
|
+
describe('generated createAllTablesForSchema', () => {
|
|
7
|
+
it('collects tables in a typed map, never a map of unknown', () => {
|
|
8
|
+
const tables: TableDef[] = systemTables.tables
|
|
9
|
+
const code = generateSchemaFile(tables)
|
|
10
|
+
expect(code).toContain('const tables: Record<string, AnyPgTable> = {};')
|
|
11
|
+
expect(code).not.toContain('Record<string, unknown>')
|
|
12
|
+
expect(code).toMatch(/import \{[^}]*type AnyPgTable[^}]*\} from 'drizzle-orm\/pg-core'/)
|
|
13
|
+
})
|
|
14
|
+
})
|