ormbridge 0.7.0 → 0.9.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.
Files changed (93) hide show
  1. package/README.md +2 -0
  2. package/dist/cliRunner.js +9 -7
  3. package/dist/cliRunner.js.map +1 -1
  4. package/dist/config.d.ts +8 -4
  5. package/dist/config.js +3 -3
  6. package/dist/config.js.map +1 -1
  7. package/dist/emitters/efcore.d.ts +40 -0
  8. package/dist/emitters/efcore.js +686 -0
  9. package/dist/emitters/efcore.js.map +1 -0
  10. package/dist/emitters/efcoreColumns.d.ts +75 -0
  11. package/dist/emitters/efcoreColumns.js +492 -0
  12. package/dist/emitters/efcoreColumns.js.map +1 -0
  13. package/dist/emitters/efcoreNames.d.ts +30 -0
  14. package/dist/emitters/efcoreNames.js +268 -0
  15. package/dist/emitters/efcoreNames.js.map +1 -0
  16. package/dist/emitters/efcoreRender.d.ts +2 -0
  17. package/dist/emitters/efcoreRender.js +570 -0
  18. package/dist/emitters/efcoreRender.js.map +1 -0
  19. package/dist/emitters/efcoreTypes.d.ts +114 -0
  20. package/dist/emitters/efcoreTypes.js +2 -0
  21. package/dist/emitters/efcoreTypes.js.map +1 -0
  22. package/dist/emitters/sequelize.d.ts +35 -0
  23. package/dist/emitters/sequelize.js +1276 -0
  24. package/dist/emitters/sequelize.js.map +1 -0
  25. package/dist/formats.d.ts +12 -8
  26. package/dist/formats.js +72 -4
  27. package/dist/formats.js.map +1 -1
  28. package/dist/index.d.ts +10 -0
  29. package/dist/index.js +5 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/io.js +53 -1
  32. package/dist/io.js.map +1 -1
  33. package/dist/parsers/csharpChains.d.ts +36 -0
  34. package/dist/parsers/csharpChains.js +157 -0
  35. package/dist/parsers/csharpChains.js.map +1 -0
  36. package/dist/parsers/csharpDeclarations.d.ts +3 -0
  37. package/dist/parsers/csharpDeclarations.js +293 -0
  38. package/dist/parsers/csharpDeclarations.js.map +1 -0
  39. package/dist/parsers/csharpSyntax.d.ts +130 -0
  40. package/dist/parsers/csharpSyntax.js +339 -0
  41. package/dist/parsers/csharpSyntax.js.map +1 -0
  42. package/dist/parsers/efcore.d.ts +17 -0
  43. package/dist/parsers/efcore.js +265 -0
  44. package/dist/parsers/efcore.js.map +1 -0
  45. package/dist/parsers/efcoreAnnotations.d.ts +19 -0
  46. package/dist/parsers/efcoreAnnotations.js +293 -0
  47. package/dist/parsers/efcoreAnnotations.js.map +1 -0
  48. package/dist/parsers/efcoreBuild.d.ts +13 -0
  49. package/dist/parsers/efcoreBuild.js +523 -0
  50. package/dist/parsers/efcoreBuild.js.map +1 -0
  51. package/dist/parsers/efcoreEntities.d.ts +13 -0
  52. package/dist/parsers/efcoreEntities.js +468 -0
  53. package/dist/parsers/efcoreEntities.js.map +1 -0
  54. package/dist/parsers/efcoreFields.d.ts +22 -0
  55. package/dist/parsers/efcoreFields.js +285 -0
  56. package/dist/parsers/efcoreFields.js.map +1 -0
  57. package/dist/parsers/efcoreFluent.d.ts +47 -0
  58. package/dist/parsers/efcoreFluent.js +375 -0
  59. package/dist/parsers/efcoreFluent.js.map +1 -0
  60. package/dist/parsers/efcoreModel.d.ts +209 -0
  61. package/dist/parsers/efcoreModel.js +2 -0
  62. package/dist/parsers/efcoreModel.js.map +1 -0
  63. package/dist/parsers/efcoreRelations.d.ts +46 -0
  64. package/dist/parsers/efcoreRelations.js +317 -0
  65. package/dist/parsers/efcoreRelations.js.map +1 -0
  66. package/dist/parsers/efcoreSteps.d.ts +89 -0
  67. package/dist/parsers/efcoreSteps.js +793 -0
  68. package/dist/parsers/efcoreSteps.js.map +1 -0
  69. package/dist/parsers/efcoreTypes.d.ts +35 -0
  70. package/dist/parsers/efcoreTypes.js +404 -0
  71. package/dist/parsers/efcoreTypes.js.map +1 -0
  72. package/dist/parsers/sequelize.d.ts +15 -0
  73. package/dist/parsers/sequelize.js +906 -0
  74. package/dist/parsers/sequelize.js.map +1 -0
  75. package/dist/parsers/sequelizeAssociations.d.ts +45 -0
  76. package/dist/parsers/sequelizeAssociations.js +449 -0
  77. package/dist/parsers/sequelizeAssociations.js.map +1 -0
  78. package/dist/parsers/sequelizeCollect.d.ts +33 -0
  79. package/dist/parsers/sequelizeCollect.js +1298 -0
  80. package/dist/parsers/sequelizeCollect.js.map +1 -0
  81. package/dist/parsers/sequelizeInflection.d.ts +14 -0
  82. package/dist/parsers/sequelizeInflection.js +451 -0
  83. package/dist/parsers/sequelizeInflection.js.map +1 -0
  84. package/dist/parsers/sequelizeModel.d.ts +185 -0
  85. package/dist/parsers/sequelizeModel.js +2 -0
  86. package/dist/parsers/sequelizeModel.js.map +1 -0
  87. package/dist/parsers/sequelizeTypes.d.ts +24 -0
  88. package/dist/parsers/sequelizeTypes.js +248 -0
  89. package/dist/parsers/sequelizeTypes.js.map +1 -0
  90. package/dist/styles.d.ts +18 -0
  91. package/dist/styles.js +43 -0
  92. package/dist/styles.js.map +1 -0
  93. package/package.json +4 -1
@@ -0,0 +1,114 @@
1
+ import type { IrCompositeForeignKey, IrField, IrModel, IrRelation, IrSchema } from '../ir.js';
2
+ import type { ColumnSpec, EnumPlan } from './efcoreColumns.js';
3
+ import type { PrismaProvider } from './prisma.js';
4
+ /** The shapes the planning and rendering steps of the EF Core emitter share. */
5
+ export type EfcoreStyle = 'annotations' | 'fluent';
6
+ /** One property that is a database column: a field, or the foreign key column of a relation. */
7
+ export interface ColumnMember {
8
+ property: string;
9
+ spec: ColumnSpec;
10
+ /** True when the column is part of the primary key. */
11
+ isKey: boolean;
12
+ /** The IR field, for a field. */
13
+ fieldName?: string;
14
+ /** The IR relation, for a foreign key column. */
15
+ relationName?: string;
16
+ }
17
+ /** One navigation property. */
18
+ export interface NavMember {
19
+ property: string;
20
+ /** The class the navigation points at. */
21
+ typeName: string;
22
+ collection: boolean;
23
+ /** True when a reference may be null. */
24
+ nullable: boolean;
25
+ /** Foreign key properties, for the reference navigation of the dependent side. */
26
+ foreignKeys?: string[];
27
+ /** The navigation on the other side, for `[InverseProperty]`. */
28
+ inverseOf?: {
29
+ className: string;
30
+ property: string;
31
+ };
32
+ }
33
+ export interface ConfigIndex {
34
+ properties: string[];
35
+ unique: boolean;
36
+ name?: string;
37
+ /** Sort order by position; empty when every column is ascending. */
38
+ descending: boolean[];
39
+ /** Access method (`gin`); only the fluent API can say it. */
40
+ method?: string;
41
+ }
42
+ /** A one-to-many or one-to-one relationship, seen from the entity that holds the foreign key. */
43
+ export interface Link {
44
+ owner: ModelPlan;
45
+ target: ModelPlan;
46
+ relationName: string;
47
+ relation?: IrRelation;
48
+ composite?: IrCompositeForeignKey;
49
+ /** The reference navigation on the owner. */
50
+ nav: string;
51
+ /** The navigation on the target, when the relation has a related name. */
52
+ inverse?: string;
53
+ oneToOne: boolean;
54
+ /** Foreign key properties on the owner. */
55
+ foreignKeys: string[];
56
+ /** Referenced properties on the target when they are not its primary key. */
57
+ principalKeys?: string[];
58
+ /** The `DeleteBehavior` to write; undefined when EF Core's default is the wanted one. */
59
+ behavior?: string;
60
+ required: boolean;
61
+ constraintName?: string;
62
+ /** The key field the foreign key column copies its type from. */
63
+ keyField?: IrField;
64
+ }
65
+ export interface ManyToManyLink {
66
+ owner: ModelPlan;
67
+ target: ModelPlan;
68
+ relationName: string;
69
+ nav: string;
70
+ inverse?: string;
71
+ joinTable: string;
72
+ ownerColumn: string;
73
+ targetColumn: string;
74
+ }
75
+ export interface ModelPlan {
76
+ model: IrModel;
77
+ className: string;
78
+ /** The `DbSet` property name on the context. */
79
+ dbSet: string;
80
+ tableName: string;
81
+ /** True when the table name is not the `DbSet` name, so the class needs `[Table]` / `ToTable`. */
82
+ needsTable: boolean;
83
+ schema: string | undefined;
84
+ /** Member names in use on the class. */
85
+ used: Set<string>;
86
+ /** IR field name -> property. */
87
+ fieldProps: Map<string, string>;
88
+ /** IR relation name -> foreign key property. */
89
+ relationFks: Map<string, string>;
90
+ /** IR relation name -> navigation property. */
91
+ relationNavs: Map<string, string>;
92
+ columns: ColumnMember[];
93
+ navs: NavMember[];
94
+ /** Primary key properties, in key order. */
95
+ keyProps: string[];
96
+ keyless: boolean;
97
+ isView: boolean;
98
+ keyName: string | undefined;
99
+ alternateKeys: string[][];
100
+ indexes: ConfigIndex[];
101
+ links: Link[];
102
+ manyToMany: ManyToManyLink[];
103
+ /** Properties that are refreshed on every save. */
104
+ autoUpdated: string[];
105
+ }
106
+ export interface Plan {
107
+ schema: IrSchema;
108
+ style: EfcoreStyle;
109
+ namespace: string;
110
+ header: boolean;
111
+ provider: PrismaProvider;
112
+ models: ModelPlan[];
113
+ enums: EnumPlan[];
114
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=efcoreTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"efcoreTypes.js","sourceRoot":"","sources":["../../src/emitters/efcoreTypes.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ import type { MultiFileEmitOutput } from '../formats.js';
2
+ import type { IrSchema } from '../ir.js';
3
+ import { type NamingMode } from '../transforms.js';
4
+ import type { PrismaProvider } from './prisma.js';
5
+ /**
6
+ * Writes Sequelize 6 models. Both styles write one file per model plus an `index` file:
7
+ *
8
+ * - `init` (the default) is TypeScript: `class User extends Model<InferAttributes<User>, ...>` with `declare`
9
+ * fields and a static `initModel(sequelize)` that calls `User.init({ ... }, { sequelize, modelName, tableName })`.
10
+ * `index.ts` exports the models and an `initModels(sequelize)` function that runs every `initModel` and then
11
+ * the associations (`belongsTo`, `hasMany`, `hasOne`, `belongsToMany`).
12
+ * - `define` is the CommonJS layout `sequelize-cli` generates: `module.exports = (sequelize, DataTypes) => ...`
13
+ * with `sequelize.define(...)` and an `associate(models)` function, and an `index.js` that wires them together.
14
+ *
15
+ * Every table, column and association is written explicitly (`tableName`, `field`, `as`, `foreignKey`,
16
+ * `onDelete`), so the models create the schema of the IR and the Sequelize reader reads the output back.
17
+ */
18
+ export type SequelizeStyle = 'init' | 'define';
19
+ export declare const SEQUELIZE_STYLES: readonly SequelizeStyle[];
20
+ /** True when a value is one of the Sequelize `--style` values. */
21
+ export declare function isSequelizeStyle(value: string): value is SequelizeStyle;
22
+ export interface SequelizeEmitOptions {
23
+ /** Database provider; picks the data types (JSONB vs JSON, ARRAY, INET, ...). */
24
+ provider: PrismaProvider;
25
+ /**
26
+ * "preserve" keeps the database names of the source: the attribute names stay as written and every
27
+ * `tableName` and `field` is explicit. "normalize" applies the fresh-schema style of the other emitters
28
+ * (singular snake_case tables, UUID keys, `created_at` / `updated_at`) with camelCase attributes over
29
+ * snake_case columns (`underscored: true`).
30
+ */
31
+ naming: NamingMode;
32
+ /** Output layout; defaults to `init`. */
33
+ style?: SequelizeStyle;
34
+ }
35
+ export declare function emitSequelize(schema: IrSchema, options: SequelizeEmitOptions): MultiFileEmitOutput;