ormbridge 0.2.0 → 0.3.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.
@@ -0,0 +1,38 @@
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
+ * GORM emitter (Go structs with `gorm:"..."` tags). Writes one file per model
7
+ * (`models/post.go`) and one per enum (`models/post_status.go`), so it returns
8
+ * the multi-file form of the emit contract. Column and table names that match
9
+ * GORM's naming conventions are left implicit; everything else is written out.
10
+ */
11
+ export interface GormEmitOptions {
12
+ /** Database provider; chooses column types such as `uuid` vs `char(36)` and the UUID default. */
13
+ provider: PrismaProvider;
14
+ /** "normalize" applies GORM's conventions (plural snake_case tables, timestamps) before writing. */
15
+ naming: NamingMode;
16
+ /** Go package name of the generated files (default `models`); also the output directory. */
17
+ goPackage?: string;
18
+ }
19
+ export declare const DEFAULT_GO_PACKAGE: string;
20
+ /** True when `value` can be used as a Go package name: an identifier that is not `_` or a keyword. */
21
+ export declare function isValidGoPackageName(value: string): boolean;
22
+ export declare function emitGorm(schema: IrSchema, options: GormEmitOptions): MultiFileEmitOutput;
23
+ /**
24
+ * The column name GORM derives from a Go field name (`schema.NamingStrategy.ColumnName`,
25
+ * gorm v1.31): `PublicID` becomes `public_id`, `HTTPServer` becomes `http_server`.
26
+ */
27
+ export declare function gormColumnName(goName: string): string;
28
+ /** Pluralizes a lower-case snake_case name the way GORM does for table names. */
29
+ export declare function gormPluralize(snake: string): string;
30
+ /** The table name GORM derives from a Go struct name: `BlogPost` becomes `blog_posts`. */
31
+ export declare function gormTableName(goTypeName: string): string;
32
+ /**
33
+ * Applies GORM's conventions to a schema: plural snake_case table names (join
34
+ * tables keep theirs), snake_case columns, and `created_at` / `updated_at`
35
+ * where a model has none (GORM fills both in by name). Primary keys keep their
36
+ * type.
37
+ */
38
+ export declare function normalizeGormSchema(schema: IrSchema): IrSchema;