ormbridge 0.4.0 → 0.6.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/README.md +60 -7
- package/dist/cliRunner.js +13 -0
- package/dist/cliRunner.js.map +1 -1
- package/dist/config.d.ts +3 -0
- package/dist/config.js +9 -0
- package/dist/config.js.map +1 -1
- package/dist/emitters/jsonSchema.d.ts +13 -0
- package/dist/emitters/jsonSchema.js +78 -4
- package/dist/emitters/jsonSchema.js.map +1 -1
- package/dist/emitters/sqlalchemy.d.ts +30 -0
- package/dist/emitters/sqlalchemy.js +1725 -0
- package/dist/emitters/sqlalchemy.js.map +1 -0
- package/dist/formats.d.ts +7 -0
- package/dist/formats.js +22 -0
- package/dist/formats.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/io.js +27 -1
- package/dist/io.js.map +1 -1
- package/dist/parsers/jsonSchema.js +7 -0
- package/dist/parsers/jsonSchema.js.map +1 -1
- package/dist/parsers/pythonSyntax.d.ts +7 -1
- package/dist/parsers/pythonSyntax.js +47 -8
- package/dist/parsers/pythonSyntax.js.map +1 -1
- package/dist/parsers/sqlalchemy.d.ts +12 -0
- package/dist/parsers/sqlalchemy.js +3191 -0
- package/dist/parsers/sqlalchemy.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,10 +13,12 @@ Convert ORM models between frameworks and languages, so one data model can be sh
|
|
|
13
13
|
| Drizzle ORM (TypeScript) | ✔ | ✔ | `pgTable` / `mysqlTable` / `sqliteTable` plus `relations()` |
|
|
14
14
|
| JSON Schema / OpenAPI | ✔ | ✔ | Draft 2020-12, 2019-09 and 7, and OpenAPI `components.schemas` (JSON) |
|
|
15
15
|
| SQL DDL | ✔ | | `CREATE TABLE` and friends for PostgreSQL, MySQL, SQLite, SQL Server |
|
|
16
|
+
| SQLAlchemy / SQLModel | ✔ | | SQLAlchemy 2.0 declarative, `Column()` and `Table()` styles; SQLModel |
|
|
16
17
|
| TypeScript interfaces | | ✔ | Plain interfaces and enums for front ends |
|
|
17
18
|
| Graphene (graphene-django) | | ✔ | GraphQL types, queries and mutations that pair with Django |
|
|
18
19
|
| Zod schemas | | ✔ | Zod 4 schemas and inferred types for validation |
|
|
19
20
|
| SQL DDL | | ✔ | One `.sql` script for PostgreSQL, MySQL, SQLite or SQL Server |
|
|
21
|
+
| SQLAlchemy / SQLModel | | ✔ | SQLAlchemy 2.0 declarative models; `--style sqlmodel` for SQLModel |
|
|
20
22
|
|
|
21
23
|
See [What is converted](#what-is-converted) for the field-level mapping and [docs/CONVERSION_MATRIX.md](docs/CONVERSION_MATRIX.md) for exactly what survives a round trip between the readable formats.
|
|
22
24
|
|
|
@@ -72,6 +74,12 @@ ormbridge convert -i ./openapi.json --from json-schema --to prisma -o ./prisma/s
|
|
|
72
74
|
# SQL DDL (a pg_dump / mysqldump / sqlite .dump / SSMS script, or a folder of migrations) -> Prisma (every .sql file is read in name order; node_modules/, vendor/ and rollback scripts such as *.down.sql are skipped)
|
|
73
75
|
ormbridge convert -i ./schema.sql -o ./prisma/schema.prisma
|
|
74
76
|
ormbridge convert -i ./db/migrations --from sql --to django -o ./blog/models.py
|
|
77
|
+
|
|
78
|
+
# SQLAlchemy 2.0 or SQLModel models -> Prisma (.py belongs to Django, so pass --from sqlalchemy; every .py file is read; venvs, site-packages, migrations/, alembic/, __pycache__/ and test files are skipped)
|
|
79
|
+
ormbridge convert -i ./app/models --from sqlalchemy -o ./prisma/schema.prisma
|
|
80
|
+
# Prisma -> SQLAlchemy 2.0 models (".py" means Django, so pass --to sqlalchemy; --style sqlmodel writes SQLModel classes instead)
|
|
81
|
+
ormbridge convert -i ./prisma/schema.prisma --to sqlalchemy -o ./app/models.py
|
|
82
|
+
ormbridge convert -i ./prisma/schema.prisma --to sqlalchemy --style sqlmodel -o ./app/models.py
|
|
75
83
|
```
|
|
76
84
|
|
|
77
85
|
Formats are inferred from file extensions (`.py` = Django, `.prisma` = Prisma, `.ts` = TypeORM, `.sql` = SQL), or set explicitly with `--from` / `--to`. Passing a directory does not infer the format, so add `--from typeorm` (or `--from drizzle`, `--from json-schema`, `--from doctrine`, `--from laravel`, `--from gorm`) when reading a folder of entities (or `--from sql` for a folder of `.sql` files); `.php`, `.go` and `.json` are not inferred either, and `.ts` always means TypeORM, so Drizzle needs `--from drizzle`. Run `ormbridge formats` to list every supported format, its file extensions, and whether it can be read, written, or both. Without `-o`, the result is printed to stdout. Warnings go to stderr.
|
|
@@ -80,8 +88,8 @@ Formats are inferred from file extensions (`.py` = Django, `.prisma` = Prisma, `
|
|
|
80
88
|
| ------------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
81
89
|
| `-i, --input <paths...>` | required (or config) | Files or directories to read. Several files are merged into one schema, so abstract base classes can live in another file. |
|
|
82
90
|
| `-o, --output <path>` | stdout | File to write. Parent directories are created. |
|
|
83
|
-
| `-f, --from <format>` | inferred | `django`, `prisma`, `typeorm`, `drizzle`, `doctrine`, `laravel`, `gorm`, `json-schema` or `
|
|
84
|
-
| `-t, --to <format>` | inferred | `django`, `prisma`, `typeorm`, `drizzle`, `doctrine`, `laravel`, `gorm
|
|
91
|
+
| `-f, --from <format>` | inferred | `django`, `prisma`, `typeorm`, `drizzle`, `doctrine`, `laravel`, `gorm`, `json-schema`, `sql` or `sqlalchemy` |
|
|
92
|
+
| `-t, --to <format>` | inferred | `django`, `prisma`, `typeorm`, `drizzle`, `doctrine`, `laravel`, `gorm`, `json-schema`, `sql` or `sqlalchemy` (`drizzle`, `doctrine`, `laravel` and `gorm` write a directory), `typescript`, `zod` or `graphene` (output only) |
|
|
85
93
|
| `--naming <mode>` | `preserve` | `preserve` or `normalize` (see below) |
|
|
86
94
|
| `--provider <name>` | `postgresql` | Database: `postgresql`, `mysql`, `sqlite`, `sqlserver`, `mongodb`, `cockroachdb`. Controls Prisma native types such as `@db.VarChar`, the Drizzle and GORM dialect and the SQL dialect of `--to sql` (`postgresql`, `mysql`, `sqlite` or `sqlserver`). |
|
|
87
95
|
| `--no-header` | off | Omit the Prisma `generator` / `datasource` blocks (useful when pasting models into an existing schema). |
|
|
@@ -90,6 +98,7 @@ Formats are inferred from file extensions (`.py` = Django, `.prisma` = Prisma, `
|
|
|
90
98
|
| `--namespace <name>` | `App\Entity`, `App\Models` | PHP namespace of the Doctrine entities or Laravel models (`--to doctrine` / `--to laravel` only). Enums go in a sibling namespace. |
|
|
91
99
|
| `--go-package <name>` | `models` | Go package name of the GORM models, also the output sub-directory (`--to gorm` only). Must be a valid Go identifier. |
|
|
92
100
|
| `--prisma-version <6\|7>` | `6` | Prisma major version of the header (`--to prisma` only). `7` writes the `prisma-client` generator (with an `output`) and no datasource `url`. |
|
|
101
|
+
| `--style <name>` | `sqlalchemy` | Flavour of the SQLAlchemy output (`--to sqlalchemy` only): `sqlalchemy` (declarative `Mapped[...]` models) or `sqlmodel` (`SQLModel, table=True` classes). Anything else fails with the valid values. |
|
|
93
102
|
| `--dry-run` | off | Run the whole conversion and report what would be written, without touching the filesystem. |
|
|
94
103
|
| `--check` | off | Exit with code 3 if an output file is missing or differs from the conversion. Writes nothing. Needs an output path. |
|
|
95
104
|
| `--config <path>` | searched | Read settings from this JSON config file instead of searching for one. |
|
|
@@ -146,6 +155,7 @@ Instead of repeating flags, put them in `ormbridge.config.json` (or `.ormbridger
|
|
|
146
155
|
| `namespace` | string | `--namespace` (Doctrine or Laravel output) |
|
|
147
156
|
| `goPackage` | string | `--go-package` (GORM output) |
|
|
148
157
|
| `prismaVersion` | number | `--prisma-version` (`6` or `7`; Prisma output) |
|
|
158
|
+
| `style` | string | `--style` (`sqlalchemy` or `sqlmodel`; SQLAlchemy output) |
|
|
149
159
|
| `conversions` | list of objects | Several named conversions; each takes the keys above plus `name` |
|
|
150
160
|
|
|
151
161
|
Top-level keys are defaults for every entry in `conversions`. Flags override config values. With no `-i`, `ormbridge convert` runs every conversion in the list (and `-o` is rejected, since the conversions write to different paths); with `-i`, it runs a single conversion from the top-level settings. Unknown keys and bad values fail with a message naming the key, such as `"conversions[1].naming" must be "preserve" or "normalize" (got "weird")`.
|
|
@@ -395,7 +405,7 @@ Every object schema with properties under `$defs`, `definitions` or `components.
|
|
|
395
405
|
| `$ref` pointers (`#/$defs/X`, `#/definitions/X`, `#/components/schemas/X`, `#`), `$id`-relative references and relative file references between the input files | followed; a remote reference that is not an input file, a missing target, a named anchor or a reference cycle that never reaches an object keeps the property as a `json` column and warns |
|
|
396
406
|
| `allOf` composition | the properties of every member are merged into the model (inheritance is flattened, with a warning) |
|
|
397
407
|
|
|
398
|
-
A property that is not in `required` is nullable unless it has a `default` or is `readOnly` (the database fills it in). The conventions of ormbridge's own JSON Schema output are read back: a foreign key scalar (`author_id`) next to an optional `$ref` property (`author`) is one relation whose nullability is the scalar's, reverse sides are arrays that are matched with the foreign keys that point at the model (by `x-related-name`, otherwise by position when the counts agree, with a warning), `readOnly` columns are generated, and `bigInt` and `decimal` columns written as patterned strings (`^-?[0-9]+$`, `^-?[0-9]{1,6}(\.[0-9]{1,2})?$`) are read as `bigInt` and `decimal(8, 2)`. Table names, unique constraints, indexes, referential actions, enum labels and the exact owner of a many-to-many field are not JSON Schema keywords, so they only survive through the `x-` conventions above.
|
|
408
|
+
A property that is not in `required` is nullable unless it has a `default` or is `readOnly` (the database fills it in). The conventions of ormbridge's own JSON Schema output are read back: a foreign key scalar (`author_id`) next to an optional `$ref` property (`author`) is one relation whose nullability is the scalar's, reverse sides are arrays that are matched with the foreign keys that point at the model (by `x-related-name`, otherwise by position when the counts agree, with a warning), `readOnly` columns are generated, and `bigInt` and `decimal` columns written as patterned strings (`^-?[0-9]+$`, `^-?[0-9]{1,6}(\.[0-9]{1,2})?$`) are read as `bigInt` and `decimal(8, 2)`. Table names, unique constraints, indexes, composite keys, referential actions, related names, enum labels and the exact owner of a many-to-many field are not JSON Schema keywords, so they only survive through the `x-` conventions above, which the writer produces too (see below).
|
|
399
409
|
|
|
400
410
|
Losses, each reported as a warning naming the model and property: `description` / `title` (the IR has no comments), validation keywords (`minimum`, `pattern`, ...), `oneOf` / `anyOf` unions (a property becomes `json`; a `oneOf` of models is not a model), `patternProperties`, maps (`additionalProperties` with a schema), `if` / `then` / `else`, type unions, tuple arrays, nested inline objects (a `json` column; define them under `$defs` to make them models), arrays of models inside other arrays and non-string enums (the plain type is kept). An array of models with no counterpart on the other model gets a nullable foreign key on that model (JSON Schema cannot say who holds the key). The `x-` keywords above are ormbridge's own conventions and are ignored by other tools. [docs/CONVERSION_MATRIX.md](docs/CONVERSION_MATRIX.md) lists what the reader cannot express.
|
|
401
411
|
|
|
@@ -420,6 +430,31 @@ Losses, each reported as a warning naming the model and property: `description`
|
|
|
420
430
|
|
|
421
431
|
Everything else is skipped, and each kind is reported once as a warning with a count and the first line (`Skipped 3 CREATE VIEW statements (first at schema.sql:40)`): views, functions, procedures, triggers, sequences, domains, composite types, row data (`INSERT`, `COPY`), temporary tables, `CREATE TABLE ... AS SELECT`, `PARTITION OF`, and the `ALTER TABLE` changes that are not replayed (`DROP COLUMN`, `RENAME`, a changed column type). `COMMENT ON`, `SET`, `GRANT`, transactions and extensions are skipped without a warning. A `CHECK` that is not an enum, an `EXCLUDE` constraint, an expression index, a partial unique index (a full one would reject rows the source accepts), the `WHERE` of a partial index, `INHERITS` and partitioning, a MySQL `SET` column, a table without a primary key and a foreign key to a table that is not in the input each warn and name the table. MySQL creates an index for every foreign key, so an index over exactly the foreign-key columns is not kept as a separate index.
|
|
422
432
|
|
|
433
|
+
### SQLAlchemy and SQLModel (`--from sqlalchemy`)
|
|
434
|
+
|
|
435
|
+
`--from sqlalchemy` reads SQLAlchemy 2.0 declarative models, the classic `Column(...)` style, `Table(...)` objects and SQLModel classes (the `sqlalchemy` format also covers SQLModel). The Python is read with the same static tree-sitter grammar as Django, so **nothing is imported or run**: no Python, SQLAlchemy or database is needed. `.py` belongs to Django, so pass `--from sqlalchemy`; a directory is walked for `.py` files and skips virtual environments, `site-packages`, `migrations`, `alembic`, `__pycache__`, caches and test or tooling files (`test_*.py`, `*_test.py`, `conftest.py`, `setup.py`).
|
|
436
|
+
|
|
437
|
+
| SQLAlchemy / SQLModel | Read as |
|
|
438
|
+
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
439
|
+
| a class with `__tablename__` on `DeclarativeBase`, `declarative_base()`, `db.Model` or any imported base; a SQLModel class with `table=True`; `__table__` | a model named after the class; the table is `__tablename__` (a `@declared_attr` returning `cls.__name__.lower()` works too; SQLModel and Flask-SQLAlchemy default to the lower-cased and snake-cased class name) |
|
|
440
|
+
| `Mapped[T]`, `mapped_column(...)`, `Column(...)`, SQLModel `Field(...)` | a column; the attribute name is the field name and a name given to `mapped_column("name")` / `Column("name")` is the database column |
|
|
441
|
+
| `Mapped[Optional[T]]`, `Mapped[T \| None]`, `Union[T, None]`, `nullable=` | nullability (a plain `Column` is nullable unless it is a primary key or says `nullable=False`; `nullable=` always wins) |
|
|
442
|
+
| `Integer`, `SmallInteger`, `BigInteger`, `String(n)`, `Text`, `Boolean`, `Float`, `Numeric(p, s)`, `DateTime`, `Date`, `Time`, `Interval`, `LargeBinary` | `int`, `int`, `bigInt`, a string of that length, `text`, `boolean`, `float`, `decimal` with its digits and places, `dateTime`, `date`, `time`, `duration`, `bytes` |
|
|
443
|
+
| `JSON` / `JSONB`, `Uuid` / `UUID`, `ARRAY(T)`, `INET`, `HSTORE`, `INT4RANGE` and friends | `json`, `uuid`, an array of `T` (`dimensions=` adds levels), `ipAddress`, `hstore`, a range; any other type (`Geometry`) is an `unsupported` column with a warning |
|
|
444
|
+
| a bare Python type (`Mapped[int]`, `Mapped[datetime]`, `Mapped[Decimal]`, `Mapped[uuid.UUID]`, SQLModel `str`) | the matching column type; `Annotated[...]` aliases (`intpk = Annotated[int, mapped_column(primary_key=True)]`) and a literal `type_annotation_map` are followed, a `TypeDecorator` is read through its `impl` |
|
|
445
|
+
| `Enum(PyEnum)`, a `Mapped[PyEnum]`, `Enum("a", "b", name="x")`, `Mapped[Literal["a", "b"]]` | an enum; like SQLAlchemy it stores member names unless `values_callable=lambda e: [m.value for m in e]` is given; `name=` becomes the database name of the enum |
|
|
446
|
+
| `primary_key=True` on one or several columns, `PrimaryKeyConstraint(...)` | a primary key or a composite key; a lone integer key counts up (`autoincrement=False` turns that off), as do `Identity()` and `Sequence()` |
|
|
447
|
+
| `default=`, `server_default=`, `onupdate=`, `Computed(...)` | literals, enum members, `func.now()` / `datetime` callables (`now`), `uuid.uuid4`, `dict` / `list` and SQL text (`text("0")`, `text("CURRENT_TIMESTAMP")`); `server_default` marks a database default; `onupdate=func.now()` an auto-updated column; `Computed` a generated column |
|
|
448
|
+
| `ForeignKey("table.col", ondelete=, onupdate=, name=)`, `ForeignKey(Model.col)`, `ForeignKeyConstraint([...], [...])`, SQLModel `foreign_key=` | a foreign-key relation named after the `relationship()` that uses it, otherwise after the column without `_id`; a unique or primary-key foreign key is one-to-one; several columns make a composite foreign key |
|
|
449
|
+
| `relationship(back_populates=, backref=, foreign_keys=, remote_side=, uselist=False)`, SQLModel `Relationship(...)` | the other side of the foreign key becomes `related_name`; `uselist=False` (or a scalar annotation) on the reverse side makes the relation one-to-one; `backref` creates the reverse side; `viewonly` relationships are ignored |
|
|
450
|
+
| `relationship(secondary=Table(...))` (the table as a variable, a name or a `lambda`), SQLModel `link_model=` | one many-to-many on the side declared first (the other side is its related name); the association table is not a model |
|
|
451
|
+
| `Index(...)` in `__table_args__` or after the class, `index=True`, `unique=True`, `UniqueConstraint(...)`, `postgresql_using=` | indexes with their names, column order, descending columns and method; a single unique column becomes a unique field |
|
|
452
|
+
| mixins, `__abstract__ = True` bases, `MappedAsDataclass`, joined-table inheritance | the columns of mixins and abstract bases are copied into each subclass; a joined subclass has a one-to-one primary key to its parent |
|
|
453
|
+
| `Table(...)` that is not an association table | a model named after the class `map_imperatively` maps it to, otherwise after the table; a warning says so |
|
|
454
|
+
| `schema=` in `__table_args__`, `Table(...)` or `MetaData(schema=...)` | the model schema |
|
|
455
|
+
|
|
456
|
+
Not read, each with a warning naming the model and column: `CheckConstraint`, `ExcludeConstraint`, partial indexes (`postgresql_where` and friends), expression indexes (`func.lower(...)`, `text(...)`), single-table inheritance (a subclass without a table of its own), `column_property`, `composite`, `synonym`, `@declared_attr` members other than `__tablename__`, a `Table` reflected with `autoload_with`, a default that is a call the reader does not know, and a Python type with no column type (`dict`, `list[str]` without `JSON` / `ARRAY`). Hybrid properties, `association_proxy`, loader and cascade options and SQLModel's pydantic constraints (`ge`, `min_length`, validators) have no database meaning and are dropped without noise. A foreign key to a table that is not in the input gets a stub model with an auto-increment id and a warning. Hostile or very large input is limited (a file over 2 million characters is skipped, a table keeps its first 2000 columns, at most 500 warnings are printed) and never throws.
|
|
457
|
+
|
|
423
458
|
### Prisma constructs
|
|
424
459
|
|
|
425
460
|
The Prisma parser and emitter cover more than the Django mapping above. Constructs the shared model can carry survive a Prisma → Prisma round trip; the other formats get the closest equivalent and a warning naming the model and field.
|
|
@@ -464,7 +499,7 @@ Writes one JSON Schema (draft 2020-12) document describing the rows of every mod
|
|
|
464
499
|
- **Relations.** A foreign key keeps its scalar (`author_id`, typed from the referenced key) and gets an optional expanded property that is a `$ref` to the target (`anyOf` with null when nullable). Reverse sides and many-to-many relations are optional arrays of `$ref` (a one-to-one reverse side is nullable), exactly as in the TypeScript output.
|
|
465
500
|
- **Enums** are `{ "type": "string", "enum": [stored values] }`. The IR has no column comments, so `description` carries only enum labels (`draft: Draft`) and generated-column expressions.
|
|
466
501
|
- **OpenAPI.** An OpenAPI 3.1 document uses JSON Schema 2020-12, so the entries can be copied into `components.schemas`. References point at `#/$defs/<Name>` by default; pass `refPrefix: '#/components/schemas/'` to `emitJsonSchema` and copy the `$defs` entries over (or rewrite the prefix with a text replace). Generating an OpenAPI document itself (paths, `--to openapi`) is not part of this format.
|
|
467
|
-
- Warnings name the model and field for relations to unknown models, composite-key targets (the foreign key accepts any value), unknown enums or field types, duplicate enum values, and definition names that cannot be used in a `$ref` (they are renamed). Database constraints (unique, indexes,
|
|
502
|
+
- Warnings name the model and field for relations to unknown models, composite-key targets (the foreign key accepts any value), unknown enums or field types, duplicate enum values, and definition names that cannot be used in a `$ref` (they are renamed). Database constraints have no JSON Schema keyword, so they are written as ormbridge's own `x-` keywords, which the JSON Schema reader reads back: `x-table-name` (when the table is not named after the definition), `x-primary-key` (a key that is not called `id`, or a composite key as an array of property names), `x-unique` on a column, `x-indexes` (`{ fields, unique?, name? }` entries), and on a relation property `x-on-delete` (only when it differs from what the reader assumes: `restrict` for a required relation, `set-null` for an optional one) and `x-related-name` (the name of the reverse property). Other tools ignore these keywords, but **Ajv in strict mode rejects unknown keywords**: register them with `ajv.addVocabulary(JSON_SCHEMA_CONVENTION_KEYWORDS)` (exported by the package), or call `emitJsonSchema(schema, { camelFields: false, conventions: false })` for a document without them. Index methods, operator classes, sort orders, full-text kinds, `onUpdate` actions and constraint names have no convention and are not written.
|
|
468
503
|
- The tests check every canonical fixture's output structurally and, when Ajv is installed (`AJV_DIR`, see `test/README.md`), load it with the real draft 2020-12 validator and validate IR-generated sample rows.
|
|
469
504
|
|
|
470
505
|
### Zod schemas (`--to zod`)
|
|
@@ -498,6 +533,22 @@ Writes one `.sql` script of dialect-specific DDL, so the schema can be created i
|
|
|
498
533
|
|
|
499
534
|
[Back to Table of Contents](#table-of-contents)
|
|
500
535
|
|
|
536
|
+
### SQLAlchemy and SQLModel (`--to sqlalchemy`)
|
|
537
|
+
|
|
538
|
+
Writes [SQLAlchemy](https://www.sqlalchemy.org) 2.0 declarative models, or with `--style sqlmodel` [SQLModel](https://sqlmodel.tiangolo.com) classes. It is output only and writes **one `models.py`** (like Django, so `-o` is a file and the output can be printed to stdout); `.py` is inferred as Django, so pass `--to sqlalchemy`. The output needs Python 3.9 or newer and SQLAlchemy 2.0 or newer (SQLModel 0.0.21 or newer for `--style sqlmodel`). `--provider` is ignored: the models do not depend on the database.
|
|
539
|
+
|
|
540
|
+
- **SQLAlchemy style** (default): `class Base(DeclarativeBase)`, one class per model with `__tablename__`, typed `Mapped[...]` attributes built with `mapped_column`, and `relationship(back_populates=...)` on **both** sides of every relation (a forward `Mapped["User"]` / `Mapped[Optional["User"]]` and a reverse `Mapped[list["Post"]]`; the reverse side of a one-to-one is `Mapped[Optional["Profile"]]`). Python `enum.Enum` classes are bound with `Enum(Cls, name=..., values_callable=...)`, so the database stores the enum values, not the member names. Only the imports the module uses are written, forward references are strings, and classes follow the classes their foreign keys point at.
|
|
541
|
+
- **SQLModel style**: `class Post(SQLModel, table=True)` with `Field(...)` and `Relationship(back_populates=...)`. Types SQLModel infers from the annotation (`str`, `int`, `bool`, `date`, `uuid.UUID`, ...) are left to it, `max_length`, `max_digits` and `decimal_places` carry lengths and precision, and `sa_type`, `sa_column_kwargs`, `sa_relationship_kwargs` and (for a foreign key with `onupdate`, `NO ACTION` or a constraint name, which `Field` cannot say) `sa_column` appear only where needed. A column the database fills in is `Optional[...] = Field(default=None, nullable=False, ...)`.
|
|
542
|
+
- **Naming**: attributes are snake_case in both modes, with the database name as the first argument of `mapped_column` (or `sa_column_kwargs={"name": ...}`) when it differs. `preserve` keeps table, column, index and enum type names; `normalize` writes singular snake_case tables, UUID keys, snake_case columns and `created_at` / `updated_at`. An attribute that would shadow Python or SQLAlchemy (`class`, `metadata`, `text`, `datetime`, an enum or model name, and for SQLModel `json`, `copy`, `schema`, ...) gets a trailing underscore, a class that collides with an import gets a `Model` suffix, and enum members that are not identifiers are repaired; each repair is a warning. An unnamed reverse relation is named after the plural of the model (`posts`), a one-to-one after the model, and two relations from one model to the same target get `posts_author` / `posts_editor`.
|
|
543
|
+
- **Types**: `String(n)`, `Text`, `Integer`, `BigInteger`, `Float`, `Numeric(p, s)`, `Boolean`, `DateTime(timezone=True)`, `Date`, `Time`, `Interval`, `Uuid`, `JSON` (`JSON(none_as_null=True)` for a nullable column) and `LargeBinary`. Arrays (`ARRAY`, `dimensions=` for nested ones), `HSTORE`, range types and `INET` are PostgreSQL types; each is written with a `.with_variant(JSON(), "sqlite")` fallback (a `String(45)` for `INET`) so `create_all` also works in a SQLite test database, with a warning. A big auto-increment key is `BigInteger().with_variant(Integer, "sqlite")`.
|
|
544
|
+
- **Defaults**: literal, enum, boolean and `now` defaults are `server_default` (`func.now()`, `true()`, `text(...)`), UUID defaults are `default=uuid.uuid4`, an auto-updated column is `default=func.now(), onupdate=func.now()`, and a Prisma `dbgenerated(...)` expression is `server_default=text(...)`. Client-generated defaults (`cuid()`, `ulid()`) and Prisma default functions are dropped with a warning; a UUID version 7 default is written as `uuid4` with a warning.
|
|
545
|
+
- **Keys**: composite and named primary keys are a `PrimaryKeyConstraint`, composite foreign keys a `ForeignKeyConstraint` (with their relationship), unique and index entries `UniqueConstraint` / `Index` in `__table_args__` (generated names are `ix_<table>_<columns>` / `uq_...`; names the source gives are kept). `ForeignKey(..., ondelete=..., onupdate=...)` carries the referential actions, and the reverse side of a cascading or nulling key sets `passive_deletes=True`. A foreign key takes its column type from the key it references (`toField` targets and keys that are themselves relations are followed). `SET NULL` on a required relation is written as `RESTRICT` with a warning. Two foreign keys between the same tables, and self references, get `foreign_keys=` / `remote_side=`.
|
|
546
|
+
- **Many-to-many** relations are a `Table(...)` with the two foreign keys as a composite primary key (no surrogate `id`, unlike the table Django creates), named `<owner table>_<relation>` and used as `secondary=` on both relationships; a self reference adds `primaryjoin` / `secondaryjoin`. The table is defined before the classes.
|
|
547
|
+
- **Views** are a commented placeholder (SQLAlchemy has no declarative view; reflect it with `Table(..., autoload_with=engine)`) and a warning. A table without a primary key is mapped on its required columns with `__mapper_args__` (SQLModel needs a key, so its first column is marked) and a warning. Database schemas (`@@schema`), generated-column expressions (not SQL), index methods, operator classes, sort order and full-text kinds are dropped with a warning, and a relation to a view or to a model that is not in the input stays a plain column.
|
|
548
|
+
- The tests load the output with real SQLAlchemy 2 and SQLModel (`SQLALCHEMY_PYTHON`, see `test/README.md`): the models are imported, the mappers configured, the PostgreSQL DDL rendered, the tables created in SQLite, and the columns, keys, indexes and relationships compared with the schema; rows are inserted (defaults, enums, foreign keys, many-to-many through the relationships) and the referential actions exercised.
|
|
549
|
+
|
|
550
|
+
[Back to Table of Contents](#table-of-contents)
|
|
551
|
+
|
|
501
552
|
## Limitations and warnings
|
|
502
553
|
|
|
503
554
|
ormbridge never fails silently on something it cannot represent: each case produces a `warning:` on stderr naming the model and field. The main ones:
|
|
@@ -516,17 +567,19 @@ ormbridge never fails silently on something it cannot represent: each case produ
|
|
|
516
567
|
- Drizzle: only the TypeScript source is read and nothing is executed, so tables built in loops or by functions, column helpers that need run-time values and defaults computed at run time are not seen (each unresolvable table, column, spread, reference or default warns and names the file and table). Not represented, each with a warning: views, sequences, roles and policies, `check()` constraints, partial (`.where()`) indexes (a partial unique index is dropped because a full one would reject rows the source accepts; a partial plain index is read as a full one), expression indexes, index access methods Prisma does not have, `nullsNotDistinct`, `unsigned`, and relations v2 (`defineRelations`; the foreign keys are still read). SQLite `integer({ mode: 'timestamp' })` is read as a date-time column and warns that the database stores Unix time. A SQLite `integer().primaryKey()` is read as written: it is not auto-increment unless `{ autoIncrement: true }` is given, although SQLite assigns row ids anyway. Drizzle has no implicit many-to-many, so the explicit join table is a model and is written as one. Tables referenced but not found in the input get a stub with an auto-increment id. Drizzle can only be read for now; a writer is planned.
|
|
517
568
|
- JSON Schema: only JSON is read (no YAML), remote `$ref`s are never fetched and named anchors (`$anchor`, `$dynamicRef`) are not resolved. Relations are inferred from `$ref` properties and the `x-` conventions above, and a few guesses are warned about (a one-to-one pair with no required side, a lone array of models, a missing primary key). See "JSON Schema and OpenAPI" above and the conversion matrix for the full list of what is lost.
|
|
518
569
|
- SQL DDL: only the DDL text is read and nothing is run. The dialect is guessed per file, `UNSIGNED`, display widths, time zones and `jsonb` versus `json` are not kept, and names the database generated for constraints are not recorded. Relation names, reverse accessors, enum names and the many-to-many relation name are derived from table and column names, so they are guesses (the conversion matrix lists them). `ALTER TABLE` is replayed for added columns and constraints and a few column options only; renames, dropped columns and type changes are skipped with a warning, so a long migration history is best read from a schema dump. A composite foreign key that points at columns that are themselves single-column foreign keys cannot be expressed, and the Prisma writer reports it. Input is limited to 32 million characters; deeply nested or unterminated constructs are scanned in linear time and never overflow the stack.
|
|
570
|
+
- SQLAlchemy and SQLModel: the Python is read statically and nothing is imported, so models built in loops or functions, computed table names, `__table_args__` produced by a `@declared_attr` and column types chosen at run time are not seen. Not represented, each with a warning: check and exclude constraints, partial and expression indexes, single-table inheritance, `column_property` / `composite` / `synonym`, and Python types that need an explicit SQLAlchemy type (`dict`, `list`). Which side of a `relationship()` owns the foreign key is worked out from `foreign_keys`, `remote_side`, `primaryjoin` or the only key between the two tables; an ambiguous pair warns. A many-to-many keeps its two names but not the name or `ondelete` of its association table (see [docs/CONVERSION_MATRIX.md](docs/CONVERSION_MATRIX.md)).
|
|
571
|
+
- SQLAlchemy and SQLModel output: attributes are snake_case (the column name is passed explicitly), a reverse side that the source never named gets the plural of the model name, and the association table of a many-to-many relation has no surrogate `id` (Django's own does, so data needs migrating). Array, HSTORE, range and `INET` columns are PostgreSQL types with a JSON fallback for SQLite only, other databases are not covered, and a `String` without a length cannot be created on MySQL. Views, database schemas, generated-column expressions, index methods and operator classes are not expressed (each warns). SQLModel's `Field` cannot declare an `onupdate` or a named foreign key, so those columns use `sa_column`. The output is not run through Black or Ruff.
|
|
519
572
|
- Generated names for Django indexes are shortened to Django's 30-character limit.
|
|
520
573
|
|
|
521
574
|
Always review the output and run your own migrations/`prisma validate` before applying it to a real database.
|
|
522
575
|
|
|
523
576
|
### Verified against real tools
|
|
524
577
|
|
|
525
|
-
The emitters are not only compared with golden files. When the tools are installed, the tests also load the output with the real thing: Django (`manage.py check`, `makemigrations`, `sqlmigrate`, `migrate` and a comparison of the model metadata and the SQLite database with the schema), graphene-django (the generated schema is built, introspected and queried), TypeORM (`tsc` with decorator metadata, TypeORM's metadata validation for every provider and a `synchronize` into in-memory SQLite), Drizzle ORM (`tsc --strict`, `drizzle-kit generate` for PostgreSQL, MySQL and SQLite, `drizzle-kit push` into SQLite, Drizzle's relational configuration and a persistence run on the blog schema), Doctrine, Laravel, GORM and `prisma validate`. These checks are optional: each is skipped with a reason when its tool is missing, and `test/README.md` lists the environment variables (`DJANGO_PYTHON`, `TYPEORM_DIR`, `DRIZZLE_DIR`, `DOCTRINE_DIR`, `LARAVEL_DIR`, `PRISMA_BIN`) and `test/tools/setup-verification-tools.sh`, which installs the Django, TypeORM and Drizzle tools into a scratch directory. The Drizzle parser is checked the other way round: the fixtures are type-checked against `drizzle-orm` and compared with the snapshot `drizzle-kit generate` builds from them. The JSON Schema and OpenAPI fixtures are checked with the real Ajv validator, and the Zod schemas with real Zod 4 (`ZOD_DIR`): they are compiled with `tsc --strict` and parse generated rows (valid ones pass, invalid ones fail). The SQL DDL is executed in SQLite (always), PostgreSQL (`SQL_POSTGRES_URL`) and MySQL or MariaDB (`SQL_MYSQL_URL`), and the tables, columns, keys and indexes the database reports are compared with the schema, and the SQL parser reads the SQLite fixtures back and is compared with what the database reports.
|
|
578
|
+
The emitters are not only compared with golden files. When the tools are installed, the tests also load the output with the real thing: Django (`manage.py check`, `makemigrations`, `sqlmigrate`, `migrate` and a comparison of the model metadata and the SQLite database with the schema), graphene-django (the generated schema is built, introspected and queried), TypeORM (`tsc` with decorator metadata, TypeORM's metadata validation for every provider and a `synchronize` into in-memory SQLite), Drizzle ORM (`tsc --strict`, `drizzle-kit generate` for PostgreSQL, MySQL and SQLite, `drizzle-kit push` into SQLite, Drizzle's relational configuration and a persistence run on the blog schema), Doctrine, Laravel, GORM and `prisma validate`. These checks are optional: each is skipped with a reason when its tool is missing, and `test/README.md` lists the environment variables (`DJANGO_PYTHON`, `TYPEORM_DIR`, `DRIZZLE_DIR`, `SQLALCHEMY_PYTHON`, `DOCTRINE_DIR`, `LARAVEL_DIR`, `PRISMA_BIN`) and `test/tools/setup-verification-tools.sh`, which installs the Django, TypeORM and Drizzle tools into a scratch directory. The Drizzle parser is checked the other way round: the fixtures are type-checked against `drizzle-orm` and compared with the snapshot `drizzle-kit generate` builds from them. The JSON Schema and OpenAPI fixtures are checked with the real Ajv validator, and the Zod schemas with real Zod 4 (`ZOD_DIR`): they are compiled with `tsc --strict` and parse generated rows (valid ones pass, invalid ones fail). The SQLAlchemy and SQLModel output (`SQLALCHEMY_PYTHON`) is imported with the real libraries, its PostgreSQL DDL rendered, its tables created in SQLite and compared with the schema, and rows are inserted through the ORM (defaults, enums, foreign keys, many-to-many, referential actions). The SQL DDL is executed in SQLite (always), PostgreSQL (`SQL_POSTGRES_URL`) and MySQL or MariaDB (`SQL_MYSQL_URL`), and the tables, columns, keys and indexes the database reports are compared with the schema, and the SQL parser reads the SQLite fixtures back and is compared with what the database reports. The SQLAlchemy parser is checked the other way round: the fixtures are imported, the mappers configured, the tables created in SQLite and read back with the inspector, and one row per table is inserted to see that the defaults work.
|
|
526
579
|
|
|
527
580
|
### Conversion matrix
|
|
528
581
|
|
|
529
|
-
[docs/CONVERSION_MATRIX.md](./docs/CONVERSION_MATRIX.md) shows, for every pair of readable and writable formats (Django, Prisma, TypeORM, Doctrine, Laravel, GORM, Drizzle, JSON Schema, SQL), whether the schema survives a round trip and exactly what is lost when it does not (for example enum labels and column lengths, and Prisma's explicit join model for many-to-many fields). Write-only targets (GORM, Drizzle, JSON Schema and Zod) get a structural check of the written files instead of an IR comparison. It is generated from the test fixtures with `npm run docs:matrix`, and the tests fail if it is out of date.
|
|
582
|
+
[docs/CONVERSION_MATRIX.md](./docs/CONVERSION_MATRIX.md) shows, for every pair of readable and writable formats (Django, Prisma, TypeORM, Doctrine, Laravel, GORM, Drizzle, JSON Schema, SQL, SQLAlchemy), whether the schema survives a round trip and exactly what is lost when it does not (for example enum labels and column lengths, and Prisma's explicit join model for many-to-many fields). Write-only targets (GORM, Drizzle, JSON Schema and Zod) get a structural check of the written files instead of an IR comparison. It is generated from the test fixtures with `npm run docs:matrix`, and the tests fail if it is out of date.
|
|
530
583
|
|
|
531
584
|
Django models are read with a static [tree-sitter](https://tree-sitter.github.io/) parser, so **no Python, Django install, or database is needed**.
|
|
532
585
|
|
|
@@ -555,7 +608,7 @@ if (!result.ok) {
|
|
|
555
608
|
}
|
|
556
609
|
```
|
|
557
610
|
|
|
558
|
-
All functions return a `Result` (`{ ok: true, value } | { ok: false, error }`) instead of throwing, with a descriptive error code and message. Parsers and emitters are exported too (`parseDjango`, `parsePrisma`, `parseTypeorm`, `parseDrizzle`, `parseDoctrine`, `parseLaravel`, `parseGorm`, `parseJsonSchema`, `parseSqlDdl`, `emitPrisma`, `emitDjango`, `emitDoctrine`, `emitLaravel`, `emitGorm`, `emitDrizzle`, `emitJsonSchema`, `emitZod`, `emitSqlDdl`), all built on a shared intermediate representation, which is how new formats plug in.
|
|
611
|
+
All functions return a `Result` (`{ ok: true, value } | { ok: false, error }`) instead of throwing, with a descriptive error code and message. Parsers and emitters are exported too (`parseDjango`, `parsePrisma`, `parseTypeorm`, `parseDrizzle`, `parseDoctrine`, `parseLaravel`, `parseGorm`, `parseJsonSchema`, `parseSqlDdl`, `parseSqlAlchemy`, `emitPrisma`, `emitDjango`, `emitDoctrine`, `emitLaravel`, `emitGorm`, `emitDrizzle`, `emitJsonSchema`, `emitZod`, `emitSqlDdl`, `emitSqlAlchemy`), all built on a shared intermediate representation, which is how new formats plug in.
|
|
559
612
|
|
|
560
613
|
### Format registry
|
|
561
614
|
|
package/dist/cliRunner.js
CHANGED
|
@@ -3,6 +3,7 @@ import { extname, isAbsolute, relative, resolve } from 'node:path';
|
|
|
3
3
|
import { Command, CommanderError } from 'commander';
|
|
4
4
|
import { findConfigFile, loadConfigFile, } from './config.js';
|
|
5
5
|
import { PRISMA_PROVIDERS, } from './emitters/prisma.js';
|
|
6
|
+
import { isSqlAlchemyStyle, SQLALCHEMY_STYLES, } from './emitters/sqlalchemy.js';
|
|
6
7
|
import { describeFormats, getFormat, getFormatByExtension, listFormatNames, listFormats, } from './formats.js';
|
|
7
8
|
import { countLines, runConversion, } from './io.js';
|
|
8
9
|
/** Exit codes of the `ormbridge` command. */
|
|
@@ -61,6 +62,13 @@ function buildRunOptions(settings, mode) {
|
|
|
61
62
|
if (autoFieldValue !== 'int' && autoFieldValue !== 'bigint') {
|
|
62
63
|
return failure('INVALID_OPTION', `Invalid --auto-field value "${settings.autoField ?? ''}". Expected "int" or "bigint".`);
|
|
63
64
|
}
|
|
65
|
+
let style;
|
|
66
|
+
if (settings.style !== undefined) {
|
|
67
|
+
if (!isSqlAlchemyStyle(settings.style)) {
|
|
68
|
+
return failure('INVALID_OPTION', `Invalid --style value "${settings.style}". Expected one of: ${SQLALCHEMY_STYLES.join(', ')}.`);
|
|
69
|
+
}
|
|
70
|
+
style = settings.style;
|
|
71
|
+
}
|
|
64
72
|
let prismaVersion;
|
|
65
73
|
if (settings.prismaVersion !== undefined) {
|
|
66
74
|
const versionText = String(settings.prismaVersion).trim();
|
|
@@ -92,6 +100,7 @@ function buildRunOptions(settings, mode) {
|
|
|
92
100
|
? {}
|
|
93
101
|
: { goPackage: settings.goPackage }),
|
|
94
102
|
...(prismaVersion === undefined ? {} : { prismaVersion }),
|
|
103
|
+
...(style === undefined ? {} : { style }),
|
|
95
104
|
},
|
|
96
105
|
};
|
|
97
106
|
}
|
|
@@ -169,6 +178,9 @@ function planRuns(flags, headerFromFlag, config, env, mode) {
|
|
|
169
178
|
if (flags.prismaVersion !== undefined) {
|
|
170
179
|
settings.prismaVersion = flags.prismaVersion;
|
|
171
180
|
}
|
|
181
|
+
if (flags.style !== undefined) {
|
|
182
|
+
settings.style = flags.style;
|
|
183
|
+
}
|
|
172
184
|
const options = buildRunOptions(settings, mode);
|
|
173
185
|
if (!options.ok) {
|
|
174
186
|
const where = label === undefined ? '' : `conversion ${label}: `;
|
|
@@ -325,6 +337,7 @@ export async function runCli(argv, env) {
|
|
|
325
337
|
.option('--namespace <name>', 'PHP namespace of the Doctrine entities (default: App\\Entity) or Laravel models (default: App\\Models)')
|
|
326
338
|
.option('--go-package <name>', 'Go package name of the GORM models (default: models)')
|
|
327
339
|
.option('--prisma-version <version>', 'Prisma major version of the generator and datasource blocks (6 | 7) (default: 6; 7 writes the prisma-client generator and no datasource url)')
|
|
340
|
+
.option('--style <name>', `flavour of the SQLAlchemy output (${SQLALCHEMY_STYLES.join(' | ')}); sqlmodel writes SQLModel classes (--to sqlalchemy only) (default: sqlalchemy)`)
|
|
328
341
|
.option('--dry-run', 'run the conversion and report what would be written, without touching any file')
|
|
329
342
|
.option('--check', 'exit with code 3 if an output file is missing or differs from the conversion; writes nothing')
|
|
330
343
|
.option('--config <path>', 'read settings from this JSON config file instead of searching for ormbridge.config.json')
|
package/dist/cliRunner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cliRunner.js","sourceRoot":"","sources":["../src/cliRunner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EACL,cAAc,EACd,cAAc,GAGf,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,gBAAgB,GAGjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,eAAe,EACf,SAAS,EACT,oBAAoB,EACpB,eAAe,EACf,WAAW,GAGZ,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,UAAU,EACV,aAAa,GAId,MAAM,SAAS,CAAC;AAIjB,6CAA6C;AAC7C,MAAM,CAAC,MAAM,OAAO,GAAW,CAAC,CAAC;AACjC,6EAA6E;AAC7E,MAAM,CAAC,MAAM,qBAAqB,GAAW,CAAC,CAAC;AAC/C,sDAAsD;AACtD,MAAM,CAAC,MAAM,gBAA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AAO,MAAM,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC;QAC5D,CAAC;QACD,MAAM,MAAM,CAAC;IACf,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SqlAlchemyStyle } from './emitters/sqlalchemy.js';
|
|
1
2
|
import { type Result } from './result.js';
|
|
2
3
|
/** File names searched for in each directory, in priority order. */
|
|
3
4
|
export declare const CONFIG_FILE_NAMES: readonly string[];
|
|
@@ -22,6 +23,8 @@ export interface ConversionConfig {
|
|
|
22
23
|
goPackage?: string;
|
|
23
24
|
/** Prisma major version of the generated header (6 or 7). */
|
|
24
25
|
prismaVersion?: 6 | 7;
|
|
26
|
+
/** Flavour of the SQLAlchemy output: plain SQLAlchemy 2.0 or SQLModel. */
|
|
27
|
+
style?: SqlAlchemyStyle;
|
|
25
28
|
}
|
|
26
29
|
/** A parsed config file. Top-level settings are defaults shared by every entry in `conversions`. */
|
|
27
30
|
export interface ConfigFile {
|
package/dist/config.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFile, stat } from 'node:fs/promises';
|
|
2
2
|
import { dirname, join, resolve } from 'node:path';
|
|
3
3
|
import { PRISMA_PROVIDERS } from './emitters/prisma.js';
|
|
4
|
+
import { isSqlAlchemyStyle, SQLALCHEMY_STYLES, } from './emitters/sqlalchemy.js';
|
|
4
5
|
import { describeThrown, err, ok } from './result.js';
|
|
5
6
|
/** File names searched for in each directory, in priority order. */
|
|
6
7
|
export const CONFIG_FILE_NAMES = [
|
|
@@ -21,6 +22,7 @@ const CONVERSION_KEYS = [
|
|
|
21
22
|
'namespace',
|
|
22
23
|
'goPackage',
|
|
23
24
|
'prismaVersion',
|
|
25
|
+
'style',
|
|
24
26
|
];
|
|
25
27
|
/**
|
|
26
28
|
* Looks for a config file in `startDirectory` and each parent directory. The
|
|
@@ -200,6 +202,13 @@ function parseConversion(raw, prefix, baseDirectory) {
|
|
|
200
202
|
}
|
|
201
203
|
config.prismaVersion = prismaVersion;
|
|
202
204
|
}
|
|
205
|
+
const style = raw['style'];
|
|
206
|
+
if (style !== undefined) {
|
|
207
|
+
if (typeof style !== 'string' || !isSqlAlchemyStyle(style)) {
|
|
208
|
+
return fail('style', `must be one of ${SQLALCHEMY_STYLES.join(', ')} (got ${describeValue(style)}).`);
|
|
209
|
+
}
|
|
210
|
+
config.style = style;
|
|
211
|
+
}
|
|
203
212
|
const header = raw['header'];
|
|
204
213
|
if (header !== undefined) {
|
|
205
214
|
if (typeof header !== 'boolean') {
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,EAAE,EAAe,MAAM,aAAa,CAAC;AAEnE,oEAAoE;AACpE,MAAM,CAAC,MAAM,iBAAiB,GAAsB;IAClD,uBAAuB;IACvB,mBAAmB;CACpB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,GAElB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EA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CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QACtE,IAAI,OAAO,KAAK,KAAK,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;YAC9C,OAAO,IAAI,CACT,WAAW,EACX,kCAAkC,aAAa,CAAC,SAAS,CAAC,IAAI,CAC/D,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC;IAC7B,CAAC;IACD,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;AACpB,CAAC"}
|
|
@@ -6,6 +6,12 @@ export declare const JSON_SCHEMA_DIALECT: string;
|
|
|
6
6
|
export declare const JSON_SCHEMA_DEFAULT_ID: string;
|
|
7
7
|
/** Where `$ref` values point by default: the `$defs` of the document itself. */
|
|
8
8
|
export declare const JSON_SCHEMA_DEFAULT_REF_PREFIX: string;
|
|
9
|
+
/**
|
|
10
|
+
* The ormbridge-specific keywords the writer adds to carry what JSON Schema has no keyword for.
|
|
11
|
+
* Other tools ignore them, but Ajv in strict mode rejects unknown keywords: register them with
|
|
12
|
+
* `ajv.addVocabulary(JSON_SCHEMA_CONVENTION_KEYWORDS)` or turn them off with `conventions: false`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const JSON_SCHEMA_CONVENTION_KEYWORDS: readonly string[];
|
|
9
15
|
export interface JsonSchemaOptions {
|
|
10
16
|
/** Use camelCase property names (the `normalize` naming mode). */
|
|
11
17
|
camelFields: boolean;
|
|
@@ -16,5 +22,12 @@ export interface JsonSchemaOptions {
|
|
|
16
22
|
* `$defs` entries into an OpenAPI document's `components.schemas`.
|
|
17
23
|
*/
|
|
18
24
|
refPrefix?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Write the `x-table-name`, `x-primary-key`, `x-unique`, `x-indexes`, `x-on-delete` and
|
|
27
|
+
* `x-related-name` conventions that let the JSON Schema reader recover table names, keys,
|
|
28
|
+
* unique constraints, indexes and referential actions. Defaults to true; pass false for a
|
|
29
|
+
* document that strict validators such as Ajv can load without registering the keywords.
|
|
30
|
+
*/
|
|
31
|
+
conventions?: boolean;
|
|
19
32
|
}
|
|
20
33
|
export declare function emitJsonSchema(schema: IrSchema, options: JsonSchemaOptions): EmitOutput;
|
|
@@ -7,6 +7,19 @@ export const JSON_SCHEMA_DIALECT = 'https://json-schema.org/draft/2020-12/schema
|
|
|
7
7
|
export const JSON_SCHEMA_DEFAULT_ID = 'urn:ormbridge:schema';
|
|
8
8
|
/** Where `$ref` values point by default: the `$defs` of the document itself. */
|
|
9
9
|
export const JSON_SCHEMA_DEFAULT_REF_PREFIX = '#/$defs/';
|
|
10
|
+
/**
|
|
11
|
+
* The ormbridge-specific keywords the writer adds to carry what JSON Schema has no keyword for.
|
|
12
|
+
* Other tools ignore them, but Ajv in strict mode rejects unknown keywords: register them with
|
|
13
|
+
* `ajv.addVocabulary(JSON_SCHEMA_CONVENTION_KEYWORDS)` or turn them off with `conventions: false`.
|
|
14
|
+
*/
|
|
15
|
+
export const JSON_SCHEMA_CONVENTION_KEYWORDS = [
|
|
16
|
+
'x-table-name',
|
|
17
|
+
'x-primary-key',
|
|
18
|
+
'x-unique',
|
|
19
|
+
'x-indexes',
|
|
20
|
+
'x-on-delete',
|
|
21
|
+
'x-related-name',
|
|
22
|
+
];
|
|
10
23
|
const DEF_NAME_PATTERN = /^[A-Za-z0-9_.-]+$/;
|
|
11
24
|
const MAX_KEY_DEPTH = 5;
|
|
12
25
|
/** Value ranges of Prisma native integer types (the IR has no other integer sizes). */
|
|
@@ -29,6 +42,7 @@ export function emitJsonSchema(schema, options) {
|
|
|
29
42
|
schema,
|
|
30
43
|
refPrefix: options.refPrefix ?? JSON_SCHEMA_DEFAULT_REF_PREFIX,
|
|
31
44
|
camelFields: options.camelFields,
|
|
45
|
+
conventions: options.conventions ?? true,
|
|
32
46
|
warnings: prismaOnlyWarnings(schema),
|
|
33
47
|
names: new Map(),
|
|
34
48
|
inverseNames: new Map(),
|
|
@@ -50,7 +64,7 @@ export function emitJsonSchema(schema, options) {
|
|
|
50
64
|
...(forward.get(model.name) ?? []),
|
|
51
65
|
...(reverse.get(model.name) ?? []),
|
|
52
66
|
];
|
|
53
|
-
definitions[modelDefName(context, model)] = objectSchema(properties);
|
|
67
|
+
definitions[modelDefName(context, model)] = objectSchema(properties, modelConventions(context, model));
|
|
54
68
|
}
|
|
55
69
|
const document = {
|
|
56
70
|
$schema: JSON_SCHEMA_DIALECT,
|
|
@@ -415,12 +429,72 @@ function fieldProperty(context, model, field, name) {
|
|
|
415
429
|
if (generated) {
|
|
416
430
|
schema = { ...schema, readOnly: true };
|
|
417
431
|
}
|
|
432
|
+
if (context.conventions && field.isUnique) {
|
|
433
|
+
schema = { ...schema, 'x-unique': true };
|
|
434
|
+
}
|
|
435
|
+
// A key the reader would not find on its own (anything but "id") is marked. A composite key is
|
|
436
|
+
// written once on the model, by modelConventions().
|
|
437
|
+
if (context.conventions &&
|
|
438
|
+
field.isPrimaryKey &&
|
|
439
|
+
name !== 'id' &&
|
|
440
|
+
(model.compositePrimaryKey?.length ?? 0) < 2) {
|
|
441
|
+
schema = { ...schema, 'x-primary-key': true };
|
|
442
|
+
}
|
|
418
443
|
return {
|
|
419
444
|
name,
|
|
420
445
|
schema,
|
|
421
446
|
required: !field.isNullable && field.default === undefined && !generated,
|
|
422
447
|
};
|
|
423
448
|
}
|
|
449
|
+
/** What the reader assumes when a relation property carries no "x-on-delete". */
|
|
450
|
+
function readerOnDelete(relation) {
|
|
451
|
+
return relation.isNullable ? 'setNull' : 'restrict';
|
|
452
|
+
}
|
|
453
|
+
/** Adds the "x-related-name" and "x-on-delete" conventions to a relation property. */
|
|
454
|
+
function withRelationConventions(context, schema, relation, inverseProp) {
|
|
455
|
+
if (!context.conventions) {
|
|
456
|
+
return schema;
|
|
457
|
+
}
|
|
458
|
+
let result = schema;
|
|
459
|
+
if (relation.relatedName !== undefined) {
|
|
460
|
+
result = { ...result, 'x-related-name': inverseProp };
|
|
461
|
+
}
|
|
462
|
+
if (relation.onDelete !== readerOnDelete(relation)) {
|
|
463
|
+
result = { ...result, 'x-on-delete': relation.onDelete };
|
|
464
|
+
}
|
|
465
|
+
return result;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* The model-level conventions the reader understands: "x-table-name" when the table is not named
|
|
469
|
+
* after the definition, "x-primary-key" for a composite key and "x-indexes" for every index.
|
|
470
|
+
*/
|
|
471
|
+
function modelConventions(context, model) {
|
|
472
|
+
const names = namesOf(context, model);
|
|
473
|
+
const propertyOf = (irName) => names.relations.get(irName) ?? names.fields.get(irName) ?? irName;
|
|
474
|
+
const conventions = {};
|
|
475
|
+
if (!context.conventions) {
|
|
476
|
+
return conventions;
|
|
477
|
+
}
|
|
478
|
+
if (model.tableName !== modelDefName(context, model)) {
|
|
479
|
+
conventions['x-table-name'] = model.tableName;
|
|
480
|
+
}
|
|
481
|
+
if ((model.compositePrimaryKey?.length ?? 0) > 1) {
|
|
482
|
+
conventions['x-primary-key'] = (model.compositePrimaryKey ?? []).map(propertyOf);
|
|
483
|
+
}
|
|
484
|
+
if (model.indexes.length > 0) {
|
|
485
|
+
conventions['x-indexes'] = model.indexes.map((index) => {
|
|
486
|
+
const entry = { fields: index.fields.map(propertyOf) };
|
|
487
|
+
if (index.isUnique) {
|
|
488
|
+
entry.unique = true;
|
|
489
|
+
}
|
|
490
|
+
if (index.name !== undefined) {
|
|
491
|
+
entry.name = index.name;
|
|
492
|
+
}
|
|
493
|
+
return entry;
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
return conventions;
|
|
497
|
+
}
|
|
424
498
|
function buildForwardProperties(context, model, reverse) {
|
|
425
499
|
const properties = [];
|
|
426
500
|
const names = namesOf(context, model);
|
|
@@ -466,7 +540,7 @@ function buildForwardProperties(context, model, reverse) {
|
|
|
466
540
|
}
|
|
467
541
|
properties.push({
|
|
468
542
|
name: relationProp,
|
|
469
|
-
schema: relation.isNullable ? nullable(targetRef) : targetRef,
|
|
543
|
+
schema: withRelationConventions(context, relation.isNullable ? nullable(targetRef) : targetRef, relation, inverseProp),
|
|
470
544
|
required: false,
|
|
471
545
|
});
|
|
472
546
|
addReverse(reverse, target.name, {
|
|
@@ -484,7 +558,7 @@ function addReverse(reverse, targetName, property) {
|
|
|
484
558
|
existing.push(property);
|
|
485
559
|
reverse.set(targetName, existing);
|
|
486
560
|
}
|
|
487
|
-
function objectSchema(properties) {
|
|
561
|
+
function objectSchema(properties, conventions = {}) {
|
|
488
562
|
const members = {};
|
|
489
563
|
const required = [];
|
|
490
564
|
for (const property of properties) {
|
|
@@ -498,6 +572,6 @@ function objectSchema(properties) {
|
|
|
498
572
|
result.required = required;
|
|
499
573
|
}
|
|
500
574
|
result.additionalProperties = false;
|
|
501
|
-
return result;
|
|
575
|
+
return { ...result, ...conventions };
|
|
502
576
|
}
|
|
503
577
|
//# sourceMappingURL=jsonSchema.js.map
|