@vibeorm/dsl 2.0.0-alpha.7 → 2.0.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 +24 -4
- package/dist/column.d.ts +13 -3
- package/dist/column.d.ts.map +1 -1
- package/dist/enum.d.ts +7 -0
- package/dist/enum.d.ts.map +1 -1
- package/dist/generator/prisma.d.ts.map +1 -1
- package/dist/index.d.ts +13 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +955 -709
- package/dist/index.js.map +12 -12
- package/dist/model.d.ts.map +1 -1
- package/dist/relation-plan.d.ts +1 -0
- package/dist/relation-plan.d.ts.map +1 -1
- package/dist/relations.d.ts +4 -4
- package/dist/relations.d.ts.map +1 -1
- package/dist/schema.d.ts +5 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/to-ir.d.ts +13 -4
- package/dist/to-ir.d.ts.map +1 -1
- package/dist/types.d.ts +137 -15
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
The code-first schema input: models and relations written in TypeScript, compiled straight to the canonical `SchemaIR`. It is the peer of the `.prisma` parser, and it also emits `.prisma` text for interop.
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
bun add @vibeorm/dsl
|
|
8
|
+
bun add @vibeorm/dsl
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
> **
|
|
11
|
+
> **Stable.** `2.0.0`, published under the `latest` dist-tag. The v1 line stays installable as `vibeorm@1`.
|
|
12
12
|
|
|
13
13
|
Most users never install this directly — it ships as a dependency of [`vibeorm`](https://www.npmjs.com/package/vibeorm). Reach for it when you are building tooling on the IR or SQL layer.
|
|
14
14
|
|
|
@@ -71,16 +71,36 @@ On every column: `.optional()`, `.unique()`, `.index()`, `.array()`, `.default(v
|
|
|
71
71
|
|
|
72
72
|
Kind-specific: `.maxLength(n)` and `.text()` on strings, `.precision(p, s)` on decimals, `.defaultNow()`, `.updatedAt()` and `.tz()` on datetimes.
|
|
73
73
|
|
|
74
|
+
### Database defaults
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
arrival: dsl.bigint().autoincrement(),
|
|
78
|
+
settings: dsl.json().default({ notifications: true, channels: [] }),
|
|
79
|
+
tags: dsl.string().array().default([]),
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`dsl.int()` also supports `.autoincrement()`. The config form is `{ autoincrement: true }`. Neither form implies a primary key or uniqueness. PostgreSQL/PGlite allow non-primary counters; SQLite requires the single integer primary key; MySQL requires a leading index and permits only one counter per table. Existing serial columns compare equal to the declaration without replacing their sequences. Adding auto-increment to an existing ordinary column remains an explicit migration operation, not a sequence reset.
|
|
83
|
+
|
|
84
|
+
JSON objects, arrays, booleans, numbers and JSON `null` become database defaults. String arguments retain the Prisma-compatible serialized-JSON convention, for example `.default('"hello"')`. Cycles, undefined members, non-finite numbers and class instances are refused. Scalar-list defaults are supported on PostgreSQL/PGlite, including empty lists and exact BigInt elements. Other dialects cannot store scalar-list columns. Defaults are database-owned, so inserts may omit these fields. A literal default cannot be combined with `.dbgenerated()` or `.autoincrement()`.
|
|
85
|
+
|
|
86
|
+
Physical index names use `map`, separately from a compound unique's client-selector `name`:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
indexes: (i) => [i.on(["arrival"], { map: "arrival_lookup" })],
|
|
90
|
+
```
|
|
91
|
+
|
|
74
92
|
## Relations
|
|
75
93
|
|
|
76
94
|
Relations are declared separately from columns, in `dsl.defineRelations(models, (r) => ...)`, which keeps column references typed on both ends.
|
|
77
95
|
|
|
78
|
-
- One side: `r.one.X({ from, to, optional?, alias?, onDelete?, onUpdate? })`.
|
|
96
|
+
- One side: `r.one.X({ from, to, optional?, alias?, ownsForeignKey?, onDelete?, onUpdate? })`.
|
|
79
97
|
- Many side: `r.many.X({ from, to })`.
|
|
80
|
-
- Implicit many-to-many: both sides `r.many
|
|
98
|
+
- Implicit many-to-many: both sides `r.many`, between two DIFFERENT models. A many-to-many from a model to itself is refused (`VIBE_SCHEMA_INVALID`, rule `implicit-self-many-to-many`) because both sides would own the same join-table column; use an explicit junction model with one foreign key per direction.
|
|
81
99
|
- Explicit many-to-many, through a junction model: `r.many.Group({ from: r.User.id.through(r.UserGroup.userId), to: r.Group.id.through(r.UserGroup.groupId) })`.
|
|
82
100
|
- Self-relations, and several relations between the same pair of models, disambiguate with `alias`.
|
|
83
101
|
|
|
102
|
+
For a shared-primary-key one-to-one, set `ownsForeignKey: true` on the side whose table carries the foreign key. Ambiguous pairs now fail instead of deriving ownership from declaration order. `ownsForeignKey: false` marks the inverse side; conflicting declarations fail. Conversion emits ownership explicitly.
|
|
103
|
+
|
|
84
104
|
Large schemas can split relations across files with `dsl.defineRelationsPart` and recombine them with `dsl.mergeRelations`; `dsl.domain({ name, models })` groups models.
|
|
85
105
|
|
|
86
106
|
## Templates
|
package/dist/column.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* dsl.int().default(42)
|
|
9
9
|
* dsl.string({ optional: true })
|
|
10
10
|
*/
|
|
11
|
+
import type { EnumStorage } from "@vibeorm/schema";
|
|
11
12
|
import type { BaseColumnConfig, BigIntColumnConfig, BooleanColumnConfig, BytesColumnConfig, ColumnDef, ColumnType, DatetimeColumnConfig, DecimalColumnConfig, ExtensionTypeConfig, FloatColumnConfig, IdColumnConfig, IdGeneratorType, InlineEnumConfig, IntColumnConfig, JsonColumnConfig, StringColumnConfig } from "./types.ts";
|
|
12
13
|
/**
|
|
13
14
|
* Shallow-clones a column definition with a fresh `__config`, so columns
|
|
@@ -24,6 +25,7 @@ export declare class ChainableColumn<T extends ColumnType = ColumnType> implemen
|
|
|
24
25
|
__name?: string;
|
|
25
26
|
__enumValues?: readonly string[];
|
|
26
27
|
__enumName?: string;
|
|
28
|
+
__enumStorage?: EnumStorage;
|
|
27
29
|
constructor(columnType: T, config?: BaseColumnConfig);
|
|
28
30
|
/** Marks the column nullable (`Type?`). */
|
|
29
31
|
optional(): this;
|
|
@@ -49,6 +51,8 @@ export declare class ChainableStringColumn extends ChainableColumn<"string"> {
|
|
|
49
51
|
maxLength(n: number): this;
|
|
50
52
|
/** `@db.Text` */
|
|
51
53
|
text(): this;
|
|
54
|
+
/** `@collation("...")` — explicit column collation (mysql-rendered; inert on postgres/sqlite). */
|
|
55
|
+
collation(name: string): this;
|
|
52
56
|
}
|
|
53
57
|
/** Decimal column carrying precision/scale. */
|
|
54
58
|
export declare class ChainableDecimalColumn extends ChainableColumn<"decimal"> {
|
|
@@ -78,9 +82,10 @@ export declare class ChainableEnumColumn<T extends readonly string[] = readonly
|
|
|
78
82
|
options: T;
|
|
79
83
|
config?: BaseColumnConfig;
|
|
80
84
|
enumName?: string;
|
|
85
|
+
storage?: EnumStorage;
|
|
81
86
|
});
|
|
82
87
|
/** Sets the default to one of the declared options. */
|
|
83
|
-
default(value: T[number]): this;
|
|
88
|
+
default(value: T[number] | readonly T[number][]): this;
|
|
84
89
|
}
|
|
85
90
|
/**
|
|
86
91
|
* String column.
|
|
@@ -91,8 +96,13 @@ export declare class ChainableEnumColumn<T extends readonly string[] = readonly
|
|
|
91
96
|
* dsl.string().unique().index() // String @unique + @@index
|
|
92
97
|
*/
|
|
93
98
|
export declare function string(config?: StringColumnConfig): ChainableStringColumn;
|
|
99
|
+
/** Integer column with database-generated values independent of primary-key membership. */
|
|
100
|
+
export declare class ChainableIntegerColumn<T extends "int" | "bigint"> extends ChainableColumn<T> {
|
|
101
|
+
/** Assign values from the database sequence; does not imply a key or uniqueness. */
|
|
102
|
+
autoincrement(): this;
|
|
103
|
+
}
|
|
94
104
|
/** Int column. */
|
|
95
|
-
export declare function int(config?: IntColumnConfig):
|
|
105
|
+
export declare function int(config?: IntColumnConfig): ChainableIntegerColumn<"int">;
|
|
96
106
|
/** Float column. */
|
|
97
107
|
export declare function float(config?: FloatColumnConfig): ChainableColumn<"float">;
|
|
98
108
|
/** Decimal column. */
|
|
@@ -136,7 +146,7 @@ export declare function id(config?: IdColumnConfig): ChainableIdColumn;
|
|
|
136
146
|
/** Bytes column. */
|
|
137
147
|
export declare function bytes(config?: BytesColumnConfig): ChainableColumn<"bytes">;
|
|
138
148
|
/** BigInt column, for values beyond 32-bit ints. */
|
|
139
|
-
export declare function bigint(config?: BigIntColumnConfig):
|
|
149
|
+
export declare function bigint(config?: BigIntColumnConfig): ChainableIntegerColumn<"bigint">;
|
|
140
150
|
/**
|
|
141
151
|
* Column with a database-native type Prisma cannot model.
|
|
142
152
|
*
|
package/dist/column.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column.d.ts","sourceRoot":"","sources":["../src/column.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAEnB,MAAM,YAAY,CAAC;AAIpB;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"column.d.ts","sourceRoot":"","sources":["../src/column.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAEnB,MAAM,YAAY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,CAAC,CAExF;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,CAAC,aAAa,CAAC,CAG1E;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,eAAe,CAAC,aAAa,CAAC,CAQzF;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,KAAK,CAAC,CAAC,SAAS,SAAS,MAAM,EAAE,EACvD,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAC1B,mBAAmB,CAAC,CAAC,CAAC,CAQxB"}
|
package/dist/enum.d.ts
CHANGED
|
@@ -9,11 +9,18 @@
|
|
|
9
9
|
* schema: { id: dsl.id(), status: Status.field().default("active") },
|
|
10
10
|
* });
|
|
11
11
|
*/
|
|
12
|
+
import type { EnumStorage } from "@vibeorm/schema";
|
|
12
13
|
import type { EnumDef } from "./types.ts";
|
|
13
14
|
/** Config for a standalone enum — a `name` is what makes it standalone. */
|
|
14
15
|
export type StandaloneEnumConfig<T extends readonly string[] = readonly string[]> = {
|
|
15
16
|
name: string;
|
|
16
17
|
options: T;
|
|
18
|
+
/**
|
|
19
|
+
* Physical storage. `"database"` (default) keeps the native projection
|
|
20
|
+
* (PostgreSQL enum type, MySQL ENUM, SQLite CHECK); `"string"` stores an
|
|
21
|
+
* ordinary String column and lets VibeORM enforce membership.
|
|
22
|
+
*/
|
|
23
|
+
storage?: EnumStorage;
|
|
17
24
|
};
|
|
18
25
|
/**
|
|
19
26
|
* Creates a reusable enum. Its `field()` yields a chainable enum column that
|
package/dist/enum.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../src/enum.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"enum.d.ts","sourceRoot":"","sources":["../src/enum.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,KAAK,EAAE,OAAO,EAA+B,MAAM,YAAY,CAAC;AAIvE,2EAA2E;AAC3E,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,SAAS,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,IAAI;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,CAAC;IACX;;;;OAIG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB,CAAC;AAUF;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,SAAS,MAAM,EAAE,EAC1D,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC9B,OAAO,CAAC,CAAC,CAAC,CAYZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prisma.d.ts","sourceRoot":"","sources":["../../src/generator/prisma.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAIV,qBAAqB,EACrB,SAAS,EAEV,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"prisma.d.ts","sourceRoot":"","sources":["../../src/generator/prisma.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAIV,qBAAqB,EACrB,SAAS,EAEV,MAAM,aAAa,CAAC;AAqQrB;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,GAAE,qBAA0B,GAAG,MAAM,CAwC7F"}
|
package/dist/index.d.ts
CHANGED
|
@@ -33,20 +33,22 @@
|
|
|
33
33
|
* const prisma = dsl.generate.prisma(schema); // .prisma text
|
|
34
34
|
*/
|
|
35
35
|
import type { ExtensionRegistry, Provider, SchemaIR } from "@vibeorm/schema";
|
|
36
|
-
import type { ChainableColumn, ChainableDatetimeColumn, ChainableDecimalColumn, ChainableEnumColumn, ChainableIdColumn, ChainableStringColumn } from "./column.ts";
|
|
36
|
+
import type { ChainableColumn, ChainableDatetimeColumn, ChainableDecimalColumn, ChainableEnumColumn, ChainableIdColumn, ChainableIntegerColumn, ChainableStringColumn } from "./column.ts";
|
|
37
37
|
import type { StandaloneEnumConfig } from "./enum.ts";
|
|
38
|
+
import { defineRelations, defineRelationsPart, mergeRelations } from "./relations.ts";
|
|
39
|
+
import { defineRls } from "./schema.ts";
|
|
38
40
|
import type { SchemaOptions } from "./schema.ts";
|
|
39
41
|
import type { TemplatesApi } from "./templates.ts";
|
|
40
42
|
import type { ValidationError } from "./validate.ts";
|
|
41
|
-
import type { BigIntColumnConfig, BooleanColumnConfig, BytesColumnConfig, CreateModelConfig, DatetimeColumnConfig, DecimalColumnConfig, EnumDef, ExtensionTypeConfig, FloatColumnConfig, GeneratorOutput, IdColumnConfig, InlineEnumConfig, IntColumnConfig, JsonColumnConfig, ModelDef, PrismaGeneratorConfig,
|
|
42
|
-
export { ChainableColumn, ChainableDatetimeColumn, ChainableDecimalColumn, ChainableEnumColumn, ChainableIdColumn, ChainableStringColumn, cloneColumnDef, } from "./column.ts";
|
|
43
|
+
import type { BigIntColumnConfig, BooleanColumnConfig, BytesColumnConfig, CreateModelConfig, DatetimeColumnConfig, DecimalColumnConfig, EnumDef, ExtensionTypeConfig, FloatColumnConfig, GeneratorOutput, IdColumnConfig, InlineEnumConfig, IntColumnConfig, JsonColumnConfig, ModelDef, PrismaGeneratorConfig, SchemaDef, SchemaDefinition, SchemaInput, StringColumnConfig } from "./types.ts";
|
|
44
|
+
export { ChainableColumn, ChainableDatetimeColumn, ChainableDecimalColumn, ChainableEnumColumn, ChainableIdColumn, ChainableIntegerColumn, ChainableStringColumn, cloneColumnDef, } from "./column.ts";
|
|
43
45
|
export { createEnum } from "./enum.ts";
|
|
44
46
|
export { generatePrisma } from "./generator/prisma.ts";
|
|
45
47
|
export { create, createIndexBuilder, evaluateIndexes, getColumnNames } from "./model.ts";
|
|
46
48
|
export { children, createChildrenBuilder } from "./relation.ts";
|
|
47
49
|
export { detectOneToOnePairs, planSchema, resolveRelationType } from "./relation-plan.ts";
|
|
48
50
|
export { defineRelations, defineRelationsPart, mergeRelations } from "./relations.ts";
|
|
49
|
-
export { domain, schema } from "./schema.ts";
|
|
51
|
+
export { defineRls, domain, schema } from "./schema.ts";
|
|
50
52
|
export { base, baseWithWorkspace, fields, templates, withActive, withAudit, withExternalId, withMetadata, withNameDescription, } from "./templates.ts";
|
|
51
53
|
export { toIR } from "./to-ir.ts";
|
|
52
54
|
export { validateSchema } from "./validate.ts";
|
|
@@ -55,7 +57,7 @@ export type { MergedOneToOneSide, PlannedIndex, PlannedRelation, PlannedRelation
|
|
|
55
57
|
export type { SchemaOptions } from "./schema.ts";
|
|
56
58
|
export type { ActiveTemplate, AuditTemplate, BaseTemplate, BaseWithWorkspaceTemplate, ExternalIdTemplate, FieldsTemplate, MetadataTemplate, NameDescriptionTemplate, TemplatesApi, } from "./templates.ts";
|
|
57
59
|
export type { ValidationError } from "./validate.ts";
|
|
58
|
-
export type { BaseColumnConfig, BigIntColumnConfig, BooleanColumnConfig, BytesColumnConfig, CascadeAction, ChildrenBuilder, ChildrenDef, ChildrenRelationConfig, ChildrenSchemaCallback, ColumnDef, ColumnKeys, ColumnRef, ColumnType, CreateModelConfig, DatetimeColumnConfig, DecimalColumnConfig, EnumDef, EnumFieldConfig, ExtensionAttributeUse, ExtensionTypeConfig, FloatColumnConfig, GeneratorOutput, IdColumnConfig, IdGeneratorType, IndexBuilder, IndexCallback, IndexDef, IndexOptions, ModelCheckConfig, UniqueIndexOptions, IndexType, InlineEnumConfig, IntColumnConfig, JsonColumnConfig, ManyRelationDefConfig, ModelColumnRefs, ModelDef, OneRelationDefConfig, PrismaGeneratorConfig, RelationsBuilder, RelationsMap, RelationsOutput, SchemaColumnNames, SchemaDef, SchemaDefinition, SchemaInput, StoredRelationDef, StringColumnConfig, ThroughRef, UnsupportedColumnConfig, } from "./types.ts";
|
|
60
|
+
export type { DefineRlsOptions, MergedRelations, RlsColumnKind, RlsContextRef, RlsContextRefs, RlsDef, RlsPolicies, BaseColumnConfig, BigIntColumnConfig, BooleanColumnConfig, BytesColumnConfig, CascadeAction, ChildrenBuilder, ChildrenDef, ChildrenRelationConfig, ChildrenSchemaCallback, ColumnDef, ColumnKeys, ColumnRef, ColumnType, CreateModelConfig, DatetimeColumnConfig, DecimalColumnConfig, EnumDef, EnumFieldConfig, EnumStorage, EnumValues, ExtensionAttributeUse, ExtensionTypeConfig, FloatColumnConfig, GeneratorOutput, IdColumnConfig, IdGeneratorType, IndexBuilder, IndexCallback, IndexDef, IndexOptions, ModelCheckConfig, ModelPolicyConfig, UniqueIndexOptions, IndexType, InlineEnumConfig, IntColumnConfig, JsonColumnConfig, ManyRelationDefConfig, ModelColumnRefs, ModelDef, OneRelationDefConfig, PrismaGeneratorConfig, RelationsBuilder, RelationsMap, RelationsOutput, SchemaColumnNames, SchemaDef, SchemaDefinition, SchemaInput, StoredRelationDef, StringColumnConfig, ThroughRef, UnsupportedColumnConfig, } from "./types.ts";
|
|
59
61
|
/**
|
|
60
62
|
* Creates an enum: standalone (reusable, has a `name`) or inline (one-off).
|
|
61
63
|
*
|
|
@@ -78,8 +80,8 @@ export type GenerateApi = {
|
|
|
78
80
|
*/
|
|
79
81
|
export type DslApi = {
|
|
80
82
|
readonly string: (config?: StringColumnConfig) => ChainableStringColumn;
|
|
81
|
-
readonly int: (config?: IntColumnConfig) =>
|
|
82
|
-
readonly bigint: (config?: BigIntColumnConfig) =>
|
|
83
|
+
readonly int: (config?: IntColumnConfig) => ChainableIntegerColumn<"int">;
|
|
84
|
+
readonly bigint: (config?: BigIntColumnConfig) => ChainableIntegerColumn<"bigint">;
|
|
83
85
|
readonly float: (config?: FloatColumnConfig) => ChainableColumn<"float">;
|
|
84
86
|
readonly decimal: (config?: DecimalColumnConfig) => ChainableDecimalColumn;
|
|
85
87
|
readonly boolean: (config?: BooleanColumnConfig) => ChainableColumn<"boolean">;
|
|
@@ -91,9 +93,10 @@ export type DslApi = {
|
|
|
91
93
|
readonly extensionType: (config: ExtensionTypeConfig) => ChainableColumn<"unsupported">;
|
|
92
94
|
readonly enum: EnumFactory;
|
|
93
95
|
readonly create: <const TSchema extends SchemaDefinition>(config: CreateModelConfig<TSchema>) => ModelDef<TSchema>;
|
|
94
|
-
readonly defineRelations:
|
|
95
|
-
readonly defineRelationsPart:
|
|
96
|
-
readonly mergeRelations:
|
|
96
|
+
readonly defineRelations: typeof defineRelations;
|
|
97
|
+
readonly defineRelationsPart: typeof defineRelationsPart;
|
|
98
|
+
readonly mergeRelations: typeof mergeRelations;
|
|
99
|
+
readonly defineRls: typeof defineRls;
|
|
97
100
|
readonly schema: (input: SchemaInput, options?: SchemaOptions) => SchemaDef;
|
|
98
101
|
readonly domain: (params: {
|
|
99
102
|
name: string;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAiB7E,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAiB7E,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EACvB,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