@an5/orm 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +167 -175
  2. package/dist/an5Metadata.js +64 -0
  3. package/dist/an5Orm.d.ts +92 -3
  4. package/dist/an5Orm.js +697 -206
  5. package/dist/errors.d.ts +1 -1
  6. package/dist/errors.js +1 -1
  7. package/dist/generator/src/code-generator.d.ts +14 -13
  8. package/dist/generator/src/code-generator.js +249 -225
  9. package/dist/generator/src/dotnet-generator.d.ts +13 -11
  10. package/dist/generator/src/dotnet-generator.js +872 -546
  11. package/dist/generator/src/index.d.ts +1 -1
  12. package/dist/generator/src/index.js +104 -88
  13. package/dist/generator/src/metadata-generator.d.ts +11 -8
  14. package/dist/generator/src/metadata-generator.js +104 -90
  15. package/dist/generator/src/parser.d.ts +11 -11
  16. package/dist/generator/src/parser.js +206 -206
  17. package/dist/generator/src/python-generator.d.ts +19 -9
  18. package/dist/generator/src/python-generator.js +345 -105
  19. package/dist/generator/src/types.d.ts +27 -27
  20. package/dist/generator/src/types.js +2 -2
  21. package/dist/index.d.ts +3 -2
  22. package/dist/index.js +19 -8
  23. package/dist/logger.js +1 -1
  24. package/dist/migration-core.d.ts +87 -0
  25. package/dist/migration-core.js +692 -0
  26. package/dist/scripts/release-cli.d.ts +2 -2
  27. package/dist/scripts/release-cli.js +115 -115
  28. package/dist/sql-utils.d.ts +3 -1
  29. package/dist/sql-utils.js +94 -24
  30. package/generator/src/code-generator.ts +259 -230
  31. package/generator/src/dotnet-generator.ts +882 -544
  32. package/generator/src/golang-generator.ts +1242 -0
  33. package/generator/src/index.ts +111 -116
  34. package/generator/src/metadata-generator.ts +116 -101
  35. package/generator/src/parser.ts +202 -202
  36. package/generator/src/python-generator.ts +424 -114
  37. package/generator/src/types.ts +29 -29
  38. package/package.json +12 -6
@@ -0,0 +1,87 @@
1
+ export interface SchemaField {
2
+ name: string;
3
+ sqlType: string;
4
+ isOptional: boolean;
5
+ isId: boolean;
6
+ isUnique: boolean;
7
+ uniqueName?: string | undefined;
8
+ defaultValue?: string | undefined;
9
+ }
10
+ export interface SchemaIndexDefinition {
11
+ fields: string[];
12
+ name?: string;
13
+ includeFields?: string[];
14
+ filter?: string;
15
+ options?: string;
16
+ }
17
+ export interface SchemaModel {
18
+ name: string;
19
+ tableName: string;
20
+ fields: SchemaField[];
21
+ compoundUniques: Array<string[] | SchemaIndexDefinition>;
22
+ indexes: Array<string[] | SchemaIndexDefinition>;
23
+ }
24
+ export interface DbColumn {
25
+ columnName: string;
26
+ dataType: string;
27
+ maxLength?: number;
28
+ precision?: number;
29
+ scale?: number;
30
+ isNullable: boolean;
31
+ isPrimaryKey: boolean;
32
+ isIdentity: boolean;
33
+ defaultValue?: string;
34
+ }
35
+ export interface MigrationOp {
36
+ type: 'CREATE_TABLE' | 'ADD_COLUMN' | 'DROP_COLUMN' | 'ALTER_COLUMN' | 'ADD_INDEX' | 'ADD_UNIQUE' | 'DROP_INDEX' | 'DROP_UNIQUE' | 'DROP_TABLE';
37
+ table: string;
38
+ column?: string;
39
+ details?: string;
40
+ sql?: string;
41
+ previousSqlType?: string;
42
+ previousNullable?: boolean;
43
+ riskWarnings?: string[];
44
+ preflightSql?: string[];
45
+ }
46
+ export interface TableArtifacts {
47
+ indexes?: string[];
48
+ uniqueConstraints?: string[];
49
+ }
50
+ export interface MigrationSections {
51
+ preflight: string;
52
+ up: string;
53
+ down: string;
54
+ hasDown: boolean;
55
+ }
56
+ export interface AppliedMigrationRef {
57
+ id: string;
58
+ }
59
+ export interface MigrationCommandOptions {
60
+ dryRun: boolean;
61
+ rest: string[];
62
+ }
63
+ export declare function parseSqlType(raw: string): string;
64
+ export declare function formatDbColumnSqlType(column: DbColumn): string;
65
+ export declare function mapDefault(val: string): string;
66
+ export declare function safeIdentifierName(raw: string): string;
67
+ export declare function quoteTableName(raw: string): string;
68
+ export declare function tableIdentityName(raw: string): string;
69
+ export declare function buildAlterColumnWarnings(previousSqlType: string, nextSqlType: string, previousNullable: boolean, nextNullable: boolean): string[];
70
+ export declare function buildAlterColumnPreflightSql(tableName: string, columnName: string, previousSqlType: string, nextSqlType: string, previousNullable: boolean, nextNullable: boolean): string[];
71
+ export declare function buildAddColumnPreflightSql(tableName: string, field: SchemaField): string[];
72
+ export declare function buildUniqueConstraintPreflightSql(tableName: string, fields: string[]): string[];
73
+ export declare function parseSchemaText(text: string): SchemaModel[];
74
+ export declare function buildCreateTableSql(model: SchemaModel): string;
75
+ export declare function buildIndexDiff(model: SchemaModel, artifacts: TableArtifacts, ops: MigrationOp[]): void;
76
+ export declare function generateColumnDiff(model: SchemaModel, dbColumns: DbColumn[], ops: MigrationOp[]): void;
77
+ export declare function generateDiff(schemaModels: SchemaModel[], dbTables: string[], introspectTable: (tableName: string) => Promise<DbColumn[]>, introspectArtifacts?: (tableName: string) => Promise<TableArtifacts>): Promise<MigrationOp[]>;
78
+ export declare function buildMigrationFile(timestamp: string, ops: MigrationOp[]): string;
79
+ export declare function buildDownMigrationSql(ops: MigrationOp[]): string;
80
+ export declare function parseMigrationSections(sql: string): MigrationSections;
81
+ export declare function splitSqlBatches(sql: string): string[];
82
+ export declare function parseRollbackSelection(args: string[], applied: AppliedMigrationRef[]): {
83
+ count: number;
84
+ label: string;
85
+ };
86
+ export declare function parseMigrationCommandOptions(args: string[]): MigrationCommandOptions;
87
+ //# sourceMappingURL=migration-core.d.ts.map