metal-orm 1.0.14 → 1.0.15

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 (115) hide show
  1. package/README.md +40 -45
  2. package/dist/decorators/index.cjs +1600 -27
  3. package/dist/decorators/index.cjs.map +1 -1
  4. package/dist/decorators/index.d.cts +6 -2
  5. package/dist/decorators/index.d.ts +6 -2
  6. package/dist/decorators/index.js +1599 -27
  7. package/dist/decorators/index.js.map +1 -1
  8. package/dist/index.cjs +4608 -3429
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +511 -159
  11. package/dist/index.d.ts +511 -159
  12. package/dist/index.js +4526 -3415
  13. package/dist/index.js.map +1 -1
  14. package/dist/{select-CCp1oz9p.d.cts → select-Bkv8g8u_.d.cts} +193 -67
  15. package/dist/{select-CCp1oz9p.d.ts → select-Bkv8g8u_.d.ts} +193 -67
  16. package/package.json +1 -1
  17. package/src/codegen/typescript.ts +38 -35
  18. package/src/core/ast/adapters.ts +21 -0
  19. package/src/core/ast/aggregate-functions.ts +13 -13
  20. package/src/core/ast/builders.ts +56 -43
  21. package/src/core/ast/expression-builders.ts +34 -34
  22. package/src/core/ast/expression-nodes.ts +18 -16
  23. package/src/core/ast/expression-visitor.ts +122 -69
  24. package/src/core/ast/expression.ts +6 -4
  25. package/src/core/ast/join-metadata.ts +15 -0
  26. package/src/core/ast/join-node.ts +22 -20
  27. package/src/core/ast/join.ts +5 -5
  28. package/src/core/ast/query.ts +52 -88
  29. package/src/core/ast/types.ts +20 -0
  30. package/src/core/ast/window-functions.ts +55 -55
  31. package/src/core/ddl/dialects/base-schema-dialect.ts +20 -6
  32. package/src/core/ddl/dialects/mssql-schema-dialect.ts +32 -8
  33. package/src/core/ddl/dialects/mysql-schema-dialect.ts +21 -10
  34. package/src/core/ddl/dialects/postgres-schema-dialect.ts +52 -7
  35. package/src/core/ddl/dialects/sqlite-schema-dialect.ts +23 -9
  36. package/src/core/ddl/introspect/catalogs/index.ts +1 -0
  37. package/src/core/ddl/introspect/catalogs/postgres.ts +143 -0
  38. package/src/core/ddl/introspect/context.ts +9 -0
  39. package/src/core/ddl/introspect/functions/postgres.ts +26 -0
  40. package/src/core/ddl/introspect/mssql.ts +149 -149
  41. package/src/core/ddl/introspect/mysql.ts +99 -99
  42. package/src/core/ddl/introspect/postgres.ts +245 -154
  43. package/src/core/ddl/introspect/registry.ts +26 -0
  44. package/src/core/ddl/introspect/run-select.ts +25 -0
  45. package/src/core/ddl/introspect/sqlite.ts +7 -7
  46. package/src/core/ddl/introspect/types.ts +23 -19
  47. package/src/core/ddl/introspect/utils.ts +1 -1
  48. package/src/core/ddl/naming-strategy.ts +10 -0
  49. package/src/core/ddl/schema-dialect.ts +41 -0
  50. package/src/core/ddl/schema-diff.ts +211 -179
  51. package/src/core/ddl/schema-generator.ts +16 -90
  52. package/src/core/ddl/schema-introspect.ts +25 -32
  53. package/src/core/ddl/schema-plan-executor.ts +17 -0
  54. package/src/core/ddl/schema-types.ts +46 -39
  55. package/src/core/ddl/sql-writing.ts +170 -0
  56. package/src/core/dialect/abstract.ts +144 -126
  57. package/src/core/dialect/base/cte-compiler.ts +33 -0
  58. package/src/core/dialect/base/function-table-formatter.ts +132 -0
  59. package/src/core/dialect/base/groupby-compiler.ts +21 -0
  60. package/src/core/dialect/base/join-compiler.ts +26 -0
  61. package/src/core/dialect/base/orderby-compiler.ts +21 -0
  62. package/src/core/dialect/base/pagination-strategy.ts +32 -0
  63. package/src/core/dialect/base/returning-strategy.ts +56 -0
  64. package/src/core/dialect/base/sql-dialect.ts +181 -204
  65. package/src/core/dialect/dialect-factory.ts +91 -0
  66. package/src/core/dialect/mssql/functions.ts +101 -0
  67. package/src/core/dialect/mssql/index.ts +128 -126
  68. package/src/core/dialect/mysql/functions.ts +101 -0
  69. package/src/core/dialect/mysql/index.ts +20 -18
  70. package/src/core/dialect/postgres/functions.ts +95 -0
  71. package/src/core/dialect/postgres/index.ts +30 -28
  72. package/src/core/dialect/sqlite/functions.ts +115 -0
  73. package/src/core/dialect/sqlite/index.ts +30 -28
  74. package/src/core/driver/database-driver.ts +11 -0
  75. package/src/core/driver/mssql-driver.ts +20 -0
  76. package/src/core/driver/mysql-driver.ts +20 -0
  77. package/src/core/driver/postgres-driver.ts +20 -0
  78. package/src/core/driver/sqlite-driver.ts +20 -0
  79. package/src/core/execution/db-executor.ts +63 -0
  80. package/src/core/execution/executors/mssql-executor.ts +39 -0
  81. package/src/core/execution/executors/mysql-executor.ts +47 -0
  82. package/src/core/execution/executors/postgres-executor.ts +32 -0
  83. package/src/core/execution/executors/sqlite-executor.ts +31 -0
  84. package/src/core/functions/datetime.ts +132 -0
  85. package/src/core/functions/numeric.ts +179 -0
  86. package/src/core/functions/standard-strategy.ts +47 -0
  87. package/src/core/functions/text.ts +147 -0
  88. package/src/core/functions/types.ts +18 -0
  89. package/src/core/hydration/types.ts +57 -0
  90. package/src/decorators/bootstrap.ts +10 -0
  91. package/src/decorators/relations.ts +15 -0
  92. package/src/index.ts +30 -19
  93. package/src/orm/entity-metadata.ts +7 -0
  94. package/src/orm/entity.ts +58 -27
  95. package/src/orm/hydration.ts +25 -17
  96. package/src/orm/lazy-batch.ts +46 -2
  97. package/src/orm/orm-context.ts +60 -60
  98. package/src/orm/query-logger.ts +1 -1
  99. package/src/orm/relation-change-processor.ts +43 -2
  100. package/src/orm/relations/has-one.ts +139 -0
  101. package/src/orm/transaction-runner.ts +1 -1
  102. package/src/orm/unit-of-work.ts +60 -60
  103. package/src/query-builder/delete.ts +22 -5
  104. package/src/query-builder/hydration-manager.ts +2 -1
  105. package/src/query-builder/hydration-planner.ts +8 -7
  106. package/src/query-builder/insert.ts +22 -5
  107. package/src/query-builder/relation-conditions.ts +9 -8
  108. package/src/query-builder/relation-service.ts +3 -2
  109. package/src/query-builder/select.ts +66 -61
  110. package/src/query-builder/update.ts +22 -5
  111. package/src/schema/column.ts +246 -246
  112. package/src/schema/relation.ts +35 -1
  113. package/src/schema/table.ts +28 -28
  114. package/src/schema/types.ts +41 -31
  115. package/src/orm/db-executor.ts +0 -11
@@ -1,4 +1,4 @@
1
- import { K as TableHooks, Q as ColumnType, C as ColumnDef, T as TableDef, a0 as CascadeMode, z as SelectQueryBuilder } from '../select-CCp1oz9p.cjs';
1
+ import { X as TableHooks, Z as ColumnType, h as ColumnDef, i as TableDef, a4 as CascadeMode, P as SelectQueryBuilder } from '../select-Bkv8g8u_.cjs';
2
2
 
3
3
  interface EntityOptions {
4
4
  tableName?: string;
@@ -28,6 +28,9 @@ interface BaseRelationOptions {
28
28
  interface HasManyOptions extends BaseRelationOptions {
29
29
  foreignKey: string;
30
30
  }
31
+ interface HasOneOptions extends BaseRelationOptions {
32
+ foreignKey: string;
33
+ }
31
34
  interface BelongsToOptions extends BaseRelationOptions {
32
35
  foreignKey: string;
33
36
  }
@@ -43,6 +46,7 @@ interface BelongsToManyOptions {
43
46
  cascade?: CascadeMode;
44
47
  }
45
48
  declare function HasMany(options: HasManyOptions): PropertyDecorator;
49
+ declare function HasOne(options: HasOneOptions): PropertyDecorator;
46
50
  declare function BelongsTo(options: BelongsToOptions): PropertyDecorator;
47
51
  declare function BelongsToMany(options: BelongsToManyOptions): PropertyDecorator;
48
52
 
@@ -50,4 +54,4 @@ declare const bootstrapEntities: () => TableDef[];
50
54
  declare const getTableDefFromEntity: (ctor: EntityConstructor) => TableDef | undefined;
51
55
  declare const selectFromEntity: <TTable extends TableDef>(ctor: EntityConstructor) => SelectQueryBuilder<any, TTable>;
52
56
 
53
- export { BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToOptions, Column, type ColumnInput, type ColumnOptions, Entity, type EntityOptions, HasMany, type HasManyOptions, PrimaryKey, bootstrapEntities, getTableDefFromEntity, selectFromEntity };
57
+ export { BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToOptions, Column, type ColumnInput, type ColumnOptions, Entity, type EntityOptions, HasMany, type HasManyOptions, HasOne, type HasOneOptions, PrimaryKey, bootstrapEntities, getTableDefFromEntity, selectFromEntity };
@@ -1,4 +1,4 @@
1
- import { K as TableHooks, Q as ColumnType, C as ColumnDef, T as TableDef, a0 as CascadeMode, z as SelectQueryBuilder } from '../select-CCp1oz9p.js';
1
+ import { X as TableHooks, Z as ColumnType, h as ColumnDef, i as TableDef, a4 as CascadeMode, P as SelectQueryBuilder } from '../select-Bkv8g8u_.js';
2
2
 
3
3
  interface EntityOptions {
4
4
  tableName?: string;
@@ -28,6 +28,9 @@ interface BaseRelationOptions {
28
28
  interface HasManyOptions extends BaseRelationOptions {
29
29
  foreignKey: string;
30
30
  }
31
+ interface HasOneOptions extends BaseRelationOptions {
32
+ foreignKey: string;
33
+ }
31
34
  interface BelongsToOptions extends BaseRelationOptions {
32
35
  foreignKey: string;
33
36
  }
@@ -43,6 +46,7 @@ interface BelongsToManyOptions {
43
46
  cascade?: CascadeMode;
44
47
  }
45
48
  declare function HasMany(options: HasManyOptions): PropertyDecorator;
49
+ declare function HasOne(options: HasOneOptions): PropertyDecorator;
46
50
  declare function BelongsTo(options: BelongsToOptions): PropertyDecorator;
47
51
  declare function BelongsToMany(options: BelongsToManyOptions): PropertyDecorator;
48
52
 
@@ -50,4 +54,4 @@ declare const bootstrapEntities: () => TableDef[];
50
54
  declare const getTableDefFromEntity: (ctor: EntityConstructor) => TableDef | undefined;
51
55
  declare const selectFromEntity: <TTable extends TableDef>(ctor: EntityConstructor) => SelectQueryBuilder<any, TTable>;
52
56
 
53
- export { BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToOptions, Column, type ColumnInput, type ColumnOptions, Entity, type EntityOptions, HasMany, type HasManyOptions, PrimaryKey, bootstrapEntities, getTableDefFromEntity, selectFromEntity };
57
+ export { BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToOptions, Column, type ColumnInput, type ColumnOptions, Entity, type EntityOptions, HasMany, type HasManyOptions, HasOne, type HasOneOptions, PrimaryKey, bootstrapEntities, getTableDefFromEntity, selectFromEntity };