uql-orm 0.96.1 → 0.98.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/dist/dialect/abstractSqlDialect.d.ts +1 -7
- package/dist/dialect/abstractSqlDialect.js +1 -9
- package/dist/dialect/mysqlLikeSqlDialect.d.ts +2 -0
- package/dist/dialect/mysqlLikeSqlDialect.js +4 -1
- package/dist/dialect/pgLikeSqlDialect.js +0 -1
- package/dist/migrate/acquireQuerierForMigrations.d.ts +4 -8
- package/dist/migrate/acquireQuerierForMigrations.js +10 -18
- package/dist/migrate/builder/columnBuilder.d.ts +1 -2
- package/dist/migrate/builder/columnBuilder.js +3 -10
- package/dist/migrate/builder/migrationBuilder.d.ts +6 -26
- package/dist/migrate/builder/migrationBuilder.js +21 -78
- package/dist/migrate/builder/tableBuilder.js +2 -3
- package/dist/migrate/builder/types.d.ts +59 -120
- package/dist/migrate/cli-config.d.ts +1 -0
- package/dist/migrate/cli-config.js +11 -26
- package/dist/migrate/cli.d.ts +0 -13
- package/dist/migrate/cli.js +55 -118
- package/dist/migrate/codegen/entityCodeGenerator.d.ts +7 -61
- package/dist/migrate/codegen/entityCodeGenerator.js +53 -174
- package/dist/migrate/codegen/fieldOptionsSource.d.ts +1 -3
- package/dist/migrate/codegen/fieldOptionsSource.js +3 -11
- package/dist/migrate/codegen/index.d.ts +2 -7
- package/dist/migrate/codegen/index.js +2 -8
- package/dist/migrate/codegen/migrationFile.d.ts +1 -8
- package/dist/migrate/codegen/migrationFile.js +9 -13
- package/dist/migrate/ddl/defaultSql.d.ts +2 -1
- package/dist/migrate/ddl/defaultSql.js +1 -3
- package/dist/migrate/ddl/indexCapabilities.d.ts +18 -0
- package/dist/migrate/ddl/indexCapabilities.js +60 -0
- package/dist/migrate/ddl/indexDdl.d.ts +11 -24
- package/dist/migrate/ddl/indexDdl.js +22 -28
- package/dist/migrate/ddl/mssqlIndexDdl.d.ts +1 -7
- package/dist/migrate/ddl/mssqlIndexDdl.js +1 -7
- package/dist/migrate/ddl/mssqlTableDdl.d.ts +6 -9
- package/dist/migrate/ddl/mssqlTableDdl.js +14 -17
- package/dist/migrate/ddl/mysqlIndexDdl.d.ts +0 -21
- package/dist/migrate/ddl/mysqlIndexDdl.js +4 -48
- package/dist/migrate/ddl/mysqlTableDdl.d.ts +6 -5
- package/dist/migrate/ddl/mysqlTableDdl.js +15 -10
- package/dist/migrate/ddl/pgIndexDdl.d.ts +0 -10
- package/dist/migrate/ddl/pgIndexDdl.js +5 -44
- package/dist/migrate/ddl/pgTableDdl.d.ts +6 -2
- package/dist/migrate/ddl/pgTableDdl.js +17 -1
- package/dist/migrate/ddl/sqliteIndexDdl.js +2 -7
- package/dist/migrate/ddl/tableDdl.d.ts +43 -24
- package/dist/migrate/ddl/tableDdl.js +56 -37
- package/dist/migrate/ddl/tableRebuild.d.ts +2 -1
- package/dist/migrate/drift/driftDetector.d.ts +29 -32
- package/dist/migrate/drift/driftDetector.js +155 -205
- package/dist/migrate/drift/index.d.ts +1 -6
- package/dist/migrate/drift/index.js +1 -6
- package/dist/migrate/generator/definitionToNode.d.ts +2 -2
- package/dist/migrate/generator/definitionToNode.js +6 -5
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.d.ts +56 -77
- package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js +75 -98
- package/dist/migrate/introspection/mssqlIntrospector.d.ts +10 -43
- package/dist/migrate/introspection/mssqlIntrospector.js +52 -77
- package/dist/migrate/introspection/mysqlIntrospector.d.ts +21 -37
- package/dist/migrate/introspection/mysqlIntrospector.js +75 -56
- package/dist/migrate/introspection/postgresIntrospector.d.ts +15 -60
- package/dist/migrate/introspection/postgresIntrospector.js +74 -77
- package/dist/migrate/introspection/sqliteIntrospector.d.ts +19 -53
- package/dist/migrate/introspection/sqliteIntrospector.js +73 -119
- package/dist/migrate/introspection/tableSchemaAST.d.ts +13 -0
- package/dist/migrate/introspection/tableSchemaAST.js +85 -0
- package/dist/migrate/migrationTarget.js +10 -2
- package/dist/migrate/migrator.d.ts +9 -44
- package/dist/migrate/migrator.js +72 -150
- package/dist/migrate/schemaChange.d.ts +8 -5
- package/dist/migrate/schemaChange.js +25 -8
- package/dist/migrate/schemaGenerator.d.ts +35 -109
- package/dist/migrate/schemaGenerator.js +179 -353
- package/dist/migrate/storage/databaseStorage.d.ts +2 -1
- package/dist/migrate/storage/databaseStorage.js +3 -2
- package/dist/migrate/storage/jsonStorage.d.ts +1 -2
- package/dist/migrate/storage/jsonStorage.js +11 -20
- package/dist/migrate/triggerSql.d.ts +7 -9
- package/dist/migrate/triggerSql.js +17 -18
- package/dist/mongo/index.d.ts +0 -1
- package/dist/mongo/index.js +0 -1
- package/dist/mongo/mongoDialect.js +0 -1
- package/dist/mongo/mongoIntrospector.d.ts +1 -6
- package/dist/mongo/mongoIntrospector.js +7 -18
- package/dist/mongo/mongoSchemaGenerator.d.ts +7 -26
- package/dist/mongo/mongoSchemaGenerator.js +51 -75
- package/dist/mssql/mssqlDialect.js +0 -1
- package/dist/schema/canonicalType.d.ts +15 -19
- package/dist/schema/canonicalType.js +20 -43
- package/dist/schema/dependencyGraph.d.ts +2 -3
- package/dist/schema/dependencyGraph.js +0 -4
- package/dist/schema/indexDifferences.js +2 -2
- package/dist/schema/schemaAST.d.ts +1 -1
- package/dist/schema/schemaAST.js +5 -12
- package/dist/schema/schemaASTBuilder.d.ts +5 -6
- package/dist/schema/schemaASTBuilder.js +17 -18
- package/dist/schema/schemaASTDiffer.d.ts +4 -5
- package/dist/schema/schemaASTDiffer.js +40 -73
- package/dist/schema/types.d.ts +24 -54
- package/dist/sqlite/localSqliteQuerierPool.d.ts +16 -2
- package/dist/sqlite/localSqliteQuerierPool.js +20 -4
- package/dist/sqlite/nodeSqliteQuerierPool.js +2 -2
- package/dist/sqlite/sqliteDialect.js +0 -1
- package/dist/sqlite/sqliteQuerierPool.js +3 -3
- package/dist/type/dialect.d.ts +0 -2
- package/dist/type/migration.d.ts +13 -73
- package/dist/util/ddlExpression.util.d.ts +13 -2
- package/dist/util/ddlExpression.util.js +27 -4
- package/dist/util/sql.util.d.ts +2 -12
- package/dist/util/sql.util.js +9 -18
- package/package.json +1 -1
- package/skills/uql-orm/SKILL.md +1 -1
- package/dist/migrate/introspection/baseSqlIntrospector.d.ts +0 -36
- package/dist/migrate/introspection/baseSqlIntrospector.js +0 -133
- package/dist/schema/index.d.ts +0 -2
- package/dist/schema/index.js +0 -1
- package/dist/sqlite/sqlitePragmas.d.ts +0 -3
- package/dist/sqlite/sqlitePragmas.js +0 -15
package/dist/migrate/cli.d.ts
CHANGED
|
@@ -2,17 +2,4 @@
|
|
|
2
2
|
import type { Config } from '../type/index.js';
|
|
3
3
|
import { Migrator } from './migrator.js';
|
|
4
4
|
export declare function main(args?: string[]): Promise<void>;
|
|
5
|
-
export declare function runUp(migrator: Migrator, args: string[]): Promise<void>;
|
|
6
|
-
export declare function runDown(migrator: Migrator, args: string[]): Promise<void>;
|
|
7
|
-
export declare function runStatus(migrator: Migrator): Promise<void>;
|
|
8
|
-
export declare function runPending(migrator: Migrator): Promise<void>;
|
|
9
|
-
export declare function runGenerate(migrator: Migrator, args: string[]): Promise<void>;
|
|
10
|
-
export declare function runGenerateFromEntities(migrator: Migrator, args: string[]): Promise<void>;
|
|
11
|
-
/**
|
|
12
|
-
* Writes a `.d.ts` for the registered entities. The point is a schema defined at runtime: the same
|
|
13
|
-
* registration that made the tables is what the compiler then checks queries against.
|
|
14
|
-
*/
|
|
15
|
-
export declare function runTypes(migrator: Migrator, args: string[]): void;
|
|
16
|
-
export declare function runSync(migrator: Migrator, args: string[], config: Partial<Config>): Promise<void>;
|
|
17
|
-
export declare function runGenerateFromDb(migrator: Migrator, args: string[]): Promise<void>;
|
|
18
5
|
export declare function runDriftCheck(migrator: Migrator, config: Partial<Config>): Promise<void>;
|
package/dist/migrate/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ import * as path from 'node:path';
|
|
|
4
4
|
import { UqlUsageError } from '../util/uqlError.js';
|
|
5
5
|
import { assertCliConfig } from './assertCliConfig.js';
|
|
6
6
|
import { loadConfig } from './cli-config.js';
|
|
7
|
-
import {
|
|
7
|
+
import { EntityCodeGenerator } from './codegen/entityCodeGenerator.js';
|
|
8
8
|
import { entityTypesSource } from './codegen/entityTypes.js';
|
|
9
9
|
import { detectDrift } from './drift/driftDetector.js';
|
|
10
10
|
import { Migrator } from './migrator.js';
|
|
@@ -28,45 +28,53 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
28
28
|
try {
|
|
29
29
|
const config = await loadConfig(customPath);
|
|
30
30
|
assertCliConfig(config);
|
|
31
|
-
const
|
|
32
|
-
migrationsPath: config.migrationsPath
|
|
31
|
+
const migrator = new Migrator(config.pool, {
|
|
32
|
+
migrationsPath: config.migrationsPath,
|
|
33
33
|
tableName: config.tableName,
|
|
34
34
|
// A dry run's stdout is the SQL alone, so what the migrator notes on the way goes to stderr.
|
|
35
35
|
logger: filteredArgs.includes('--dry-run') ? console.error : console.log,
|
|
36
36
|
entities: config.entities,
|
|
37
37
|
defaultForeignKeyAction: config.defaultForeignKeyAction,
|
|
38
|
-
};
|
|
39
|
-
const
|
|
38
|
+
});
|
|
39
|
+
const rest = filteredArgs.slice(1);
|
|
40
40
|
switch (command) {
|
|
41
41
|
case 'up':
|
|
42
|
-
await
|
|
42
|
+
reportRun(await migrator.up({ to: readFlag(rest, '--to'), step: readStep(rest) }), 'Migrations', 'No pending migrations.');
|
|
43
43
|
break;
|
|
44
|
-
case 'down':
|
|
45
|
-
|
|
44
|
+
case 'down': {
|
|
45
|
+
const to = readFlag(rest, '--to');
|
|
46
|
+
const step = to || rest.includes('--all') ? readStep(rest) : (readStep(rest) ?? 1);
|
|
47
|
+
reportRun(await migrator.down({ to, step }), 'Rollback', 'No migrations to rollback.');
|
|
46
48
|
break;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
}
|
|
50
|
+
case 'status': {
|
|
51
|
+
const { executed, pending } = await migrator.status();
|
|
52
|
+
print('\n=== Migration Status ===\n', 'Executed migrations:', ...listed(executed, '✓'), '\nPending migrations:', ...listed(pending, '○'), '');
|
|
49
53
|
break;
|
|
54
|
+
}
|
|
55
|
+
case 'pending': {
|
|
56
|
+
const pending = (await migrator.pending()).map((migration) => migration.name);
|
|
57
|
+
print(...(pending.length ? ['Pending migrations:', ...listed(pending, '○')] : ['No pending migrations.']));
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
// The migrator logs the file it created.
|
|
50
61
|
case 'generate':
|
|
51
62
|
case 'create':
|
|
52
|
-
await
|
|
63
|
+
await migrator.generate(rest.join('_') || 'migration');
|
|
53
64
|
break;
|
|
54
65
|
case 'generate:entities':
|
|
55
66
|
case 'generate-entities':
|
|
56
|
-
await
|
|
67
|
+
await migrator.generateFromEntities(rest.join('_') || 'schema');
|
|
57
68
|
break;
|
|
58
69
|
case 'generate:from-db':
|
|
59
70
|
case 'generate-from-db':
|
|
60
|
-
await runGenerateFromDb(migrator,
|
|
71
|
+
await runGenerateFromDb(migrator, rest);
|
|
61
72
|
break;
|
|
62
73
|
case 'sync':
|
|
63
|
-
await runSync(migrator,
|
|
74
|
+
await runSync(migrator, rest);
|
|
64
75
|
break;
|
|
65
76
|
case 'types':
|
|
66
|
-
runTypes(migrator,
|
|
67
|
-
break;
|
|
68
|
-
case 'pending':
|
|
69
|
-
await runPending(migrator);
|
|
77
|
+
runTypes(migrator, rest);
|
|
70
78
|
break;
|
|
71
79
|
case 'drift:check':
|
|
72
80
|
case 'drift-check':
|
|
@@ -84,114 +92,48 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
84
92
|
process.exit(1);
|
|
85
93
|
}
|
|
86
94
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
options.to = args[++i];
|
|
92
|
-
}
|
|
93
|
-
else if (args[i] === '--step' && args[i + 1]) {
|
|
94
|
-
options.step = Number.parseInt(args[++i], 10);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
const results = await migrator.up(options);
|
|
98
|
-
if (results.length === 0) {
|
|
99
|
-
console.log('No pending migrations.');
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const successful = results.filter((r) => r.success).length;
|
|
103
|
-
const failed = results.filter((r) => !r.success).length;
|
|
104
|
-
console.log(`\nMigrations complete: ${successful} successful, ${failed} failed`);
|
|
105
|
-
if (failed > 0) {
|
|
106
|
-
process.exit(1);
|
|
107
|
-
}
|
|
95
|
+
/** The value after the first of `names` the arguments hold. */
|
|
96
|
+
function readFlag(args, ...names) {
|
|
97
|
+
const at = args.findIndex((arg) => names.includes(arg));
|
|
98
|
+
return at === -1 ? undefined : args[at + 1];
|
|
108
99
|
}
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
options.step = Number.parseInt(args[++i], 10);
|
|
118
|
-
}
|
|
119
|
-
else if (args[i] === '--all') {
|
|
120
|
-
delete options.step;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
const results = await migrator.down(options);
|
|
124
|
-
if (results.length === 0) {
|
|
125
|
-
console.log('No migrations to rollback.');
|
|
100
|
+
function readStep(args) {
|
|
101
|
+
const step = readFlag(args, '--step');
|
|
102
|
+
return step === undefined ? undefined : Number.parseInt(step, 10);
|
|
103
|
+
}
|
|
104
|
+
/** How a run of migrations went, failing the process on any failure. */
|
|
105
|
+
function reportRun(results, title, none) {
|
|
106
|
+
if (!results.length) {
|
|
107
|
+
console.log(none);
|
|
126
108
|
return;
|
|
127
109
|
}
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (failed > 0) {
|
|
110
|
+
const failed = results.filter((result) => !result.success).length;
|
|
111
|
+
console.log(`\n${title} complete: ${results.length - failed} successful, ${failed} failed`);
|
|
112
|
+
if (failed) {
|
|
132
113
|
process.exit(1);
|
|
133
114
|
}
|
|
134
115
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
console.log('Executed migrations:');
|
|
139
|
-
if (status.executed.length === 0) {
|
|
140
|
-
console.log(' (none)');
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
for (const name of status.executed) {
|
|
144
|
-
console.log(` ✓ ${name}`);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
console.log('\nPending migrations:');
|
|
148
|
-
if (status.pending.length === 0) {
|
|
149
|
-
console.log(' (none)');
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
for (const name of status.pending) {
|
|
153
|
-
console.log(` ○ ${name}`);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
console.log('');
|
|
116
|
+
/** Migration names, one a line, or `(none)`. */
|
|
117
|
+
function listed(names, icon) {
|
|
118
|
+
return names.length ? names.map((name) => ` ${icon} ${name}`) : [' (none)'];
|
|
157
119
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
console.log(
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
console.log('Pending migrations:');
|
|
165
|
-
for (const migration of pending) {
|
|
166
|
-
console.log(` ○ ${migration.name}`);
|
|
120
|
+
/** Each line its own `console.log`. */
|
|
121
|
+
function print(...lines) {
|
|
122
|
+
for (const line of lines) {
|
|
123
|
+
console.log(line);
|
|
167
124
|
}
|
|
168
125
|
}
|
|
169
|
-
export async function runGenerate(migrator, args) {
|
|
170
|
-
const name = args.join('_') || 'migration';
|
|
171
|
-
const filePath = await migrator.generate(name);
|
|
172
|
-
console.log(`\nCreated migration: ${filePath}`);
|
|
173
|
-
}
|
|
174
|
-
export async function runGenerateFromEntities(migrator, args) {
|
|
175
|
-
const name = args.join('_') || 'schema';
|
|
176
|
-
const filePath = await migrator.generateFromEntities(name);
|
|
177
|
-
console.log(`\nCreated migration from entities: ${filePath}`);
|
|
178
|
-
}
|
|
179
126
|
/**
|
|
180
127
|
* Writes a `.d.ts` for the registered entities. The point is a schema defined at runtime: the same
|
|
181
128
|
* registration that made the tables is what the compiler then checks queries against.
|
|
182
129
|
*/
|
|
183
|
-
|
|
184
|
-
const output =
|
|
130
|
+
function runTypes(migrator, args) {
|
|
131
|
+
const output = readFlag(args, '--output', '-o') ?? './uql-entities.d.ts';
|
|
185
132
|
fs.mkdirSync(path.dirname(output), { recursive: true });
|
|
186
133
|
fs.writeFileSync(output, entityTypesSource(migrator.entities), 'utf-8');
|
|
187
134
|
console.log(`Wrote ${migrator.entities.length} entities to ${output}`);
|
|
188
135
|
}
|
|
189
|
-
|
|
190
|
-
function readOutput(args) {
|
|
191
|
-
const at = args.findIndex((arg) => arg === '--output' || arg === '-o');
|
|
192
|
-
return at === -1 ? undefined : args[at + 1];
|
|
193
|
-
}
|
|
194
|
-
export async function runSync(migrator, args, config) {
|
|
136
|
+
async function runSync(migrator, args) {
|
|
195
137
|
// Pulling the database into entity files is what `generate:from-db` does; one implementation.
|
|
196
138
|
if (args.includes('--pull')) {
|
|
197
139
|
return runGenerateFromDb(migrator, args);
|
|
@@ -218,19 +160,14 @@ export async function runSync(migrator, args, config) {
|
|
|
218
160
|
await migrator.sync({ ...options, logging: true });
|
|
219
161
|
console.log('\nSchema sync completed.');
|
|
220
162
|
}
|
|
221
|
-
|
|
222
|
-
const outputDir =
|
|
163
|
+
async function runGenerateFromDb(migrator, args) {
|
|
164
|
+
const outputDir = readFlag(args, '--output', '-o') ?? './src/entities';
|
|
223
165
|
console.log('\nAnalyzing database schema...');
|
|
224
166
|
const ast = await migrator.schemaIntrospector.introspect();
|
|
225
167
|
const tableCount = ast.tables.size;
|
|
226
168
|
console.log(`Found ${tableCount} table(s): ${Array.from(ast.tables.keys()).join(', ')}`);
|
|
227
169
|
console.log('\nGenerating entities...');
|
|
228
|
-
const
|
|
229
|
-
addSyncComments: true,
|
|
230
|
-
includeRelations: true,
|
|
231
|
-
includeIndexes: true,
|
|
232
|
-
});
|
|
233
|
-
const entities = generator.generateAll();
|
|
170
|
+
const entities = new EntityCodeGenerator(ast).generateAll();
|
|
234
171
|
fs.mkdirSync(outputDir, { recursive: true });
|
|
235
172
|
for (const entity of entities) {
|
|
236
173
|
const filePath = path.join(outputDir, entity.fileName);
|
|
@@ -257,8 +194,8 @@ export async function runDriftCheck(migrator, config) {
|
|
|
257
194
|
// The dialect renders canonical types as SQL: without it no type drift is reported, silently
|
|
258
195
|
// passing a mismatched column as in sync.
|
|
259
196
|
const report = detectDrift(expectedAST, actualAST, {
|
|
197
|
+
...generator.diffOptions?.(),
|
|
260
198
|
dialect: config.pool?.dialect,
|
|
261
|
-
defaultsEqual: generator.defaultsEqual,
|
|
262
199
|
excludeTables: [config.tableName ?? DEFAULT_MIGRATIONS_TABLE],
|
|
263
200
|
});
|
|
264
201
|
printDriftReport(report);
|
|
@@ -38,55 +38,31 @@ export declare class EntityCodeGenerator {
|
|
|
38
38
|
private readonly ast;
|
|
39
39
|
private readonly options;
|
|
40
40
|
constructor(ast: SchemaAST, options?: EntityCodeGeneratorOptions);
|
|
41
|
-
/**
|
|
42
|
-
* Generate entities for all tables in the AST.
|
|
43
|
-
*/
|
|
41
|
+
/** An entity for each table of the AST. */
|
|
44
42
|
generateAll(): GeneratedEntity[];
|
|
45
|
-
/**
|
|
46
|
-
* Generate entity for a specific table.
|
|
47
|
-
*/
|
|
43
|
+
/** The entity for the table named, if the AST has it. */
|
|
48
44
|
generateForTable(tableName: string): GeneratedEntity | undefined;
|
|
49
|
-
/**
|
|
50
|
-
* Generate entity code for a table.
|
|
51
|
-
*/
|
|
52
45
|
private generateEntity;
|
|
53
|
-
/**
|
|
54
|
-
* Build import statements.
|
|
55
|
-
*/
|
|
56
46
|
private buildImports;
|
|
57
|
-
/**
|
|
58
|
-
* Build entity decorators.
|
|
59
|
-
*/
|
|
60
47
|
private buildEntityDecorators;
|
|
61
|
-
/**
|
|
62
|
-
* Build field definitions.
|
|
63
|
-
*/
|
|
64
48
|
private buildFields;
|
|
49
|
+
/** The `@sync-added` JSDoc a generated member opens with, saying `what` it is, where asked for. */
|
|
50
|
+
private syncDoc;
|
|
65
51
|
/**
|
|
66
52
|
* The `idKey` brand naming the key, which the type level cannot see otherwise: needed unless the key is
|
|
67
53
|
* one column holding the conventional name the entity would be read by, the first of `_id`, `id`, `uuid`.
|
|
68
54
|
*/
|
|
69
55
|
private idKeyBrand;
|
|
70
|
-
/**
|
|
71
|
-
* Build a single field definition.
|
|
72
|
-
*/
|
|
73
56
|
private buildField;
|
|
74
|
-
/**
|
|
75
|
-
* Build Field decorator options.
|
|
76
|
-
*/
|
|
77
57
|
private buildFieldOptions;
|
|
78
58
|
/**
|
|
79
59
|
* The indexes this table needs an `@Index` for, which is every one a `@Field({ index })` cannot
|
|
80
60
|
* carry on its own.
|
|
81
61
|
*/
|
|
82
62
|
private declaredIndexes;
|
|
83
|
-
/**
|
|
84
|
-
* Build relation definitions.
|
|
85
|
-
*/
|
|
63
|
+
/** The relations on both sides: where this table holds the foreign key, then where another points here. */
|
|
86
64
|
private buildRelations;
|
|
87
|
-
/**
|
|
88
|
-
* Build outgoing relation (ManyToOne or OneToOne where this table has FK).
|
|
89
|
-
*/
|
|
65
|
+
/** The side holding the foreign key; `onDelete`/`onUpdate` only where the database states an action of its own. */
|
|
90
66
|
private buildOutgoingRelation;
|
|
91
67
|
/**
|
|
92
68
|
* The property of the side holding the foreign key: its column's name less an `_id` or `Id` suffix
|
|
@@ -103,36 +79,6 @@ export declare class EntityCodeGenerator {
|
|
|
103
79
|
* key, column pairs otherwise, and nothing when the columns do not pair up.
|
|
104
80
|
*/
|
|
105
81
|
private referencesSource;
|
|
106
|
-
/**
|
|
107
|
-
* Build incoming relation (OneToMany where other tables have FK to this).
|
|
108
|
-
*/
|
|
82
|
+
/** The inverse side, mapped by the related class's property that points back at this one. */
|
|
109
83
|
private buildIncomingRelation;
|
|
110
|
-
/**
|
|
111
|
-
* Format type for description.
|
|
112
|
-
*/
|
|
113
|
-
private formatTypeDescription;
|
|
114
|
-
/**
|
|
115
|
-
* Default class name transformer: table_name -> TableName (PascalCase, singular).
|
|
116
|
-
*/
|
|
117
|
-
private defaultClassNameTransformer;
|
|
118
|
-
/**
|
|
119
|
-
* Default property name transformer: column_name -> columnName (camelCase).
|
|
120
|
-
*/
|
|
121
|
-
private defaultPropertyNameTransformer;
|
|
122
|
-
/**
|
|
123
|
-
* Convert to PascalCase (delegates to shared utility).
|
|
124
|
-
*/
|
|
125
|
-
private toPascalCase;
|
|
126
|
-
/**
|
|
127
|
-
* Convert to camelCase (delegates to shared utility).
|
|
128
|
-
*/
|
|
129
|
-
private toCamelCase;
|
|
130
|
-
/**
|
|
131
|
-
* Default singularize function (delegates to shared utility).
|
|
132
|
-
*/
|
|
133
|
-
private defaultSingularize;
|
|
134
84
|
}
|
|
135
|
-
/**
|
|
136
|
-
* Create an EntityCodeGenerator from SchemaAST.
|
|
137
|
-
*/
|
|
138
|
-
export declare function createEntityCodeGenerator(ast: SchemaAST, options?: EntityCodeGeneratorOptions): EntityCodeGenerator;
|