@absolutejs/dbml 0.0.0-stage → 0.1.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,121 @@
1
+ import { SQL } from 'drizzle-orm';
2
+ /** The column properties this package reads; Drizzle columns carry more,
3
+ * and each dialect only some of these. */
4
+ export type DrizzleColumn = {
5
+ autoIncrement?: boolean;
6
+ columnType: string;
7
+ default?: unknown;
8
+ defaultFn?: unknown;
9
+ dimensions?: number;
10
+ enum?: {
11
+ enumName: string;
12
+ schema?: string | undefined;
13
+ };
14
+ enumValues?: readonly string[] | undefined;
15
+ generated?: {
16
+ as: unknown;
17
+ mode?: string;
18
+ type?: string;
19
+ } | undefined;
20
+ generatedIdentity?: {
21
+ type?: string;
22
+ } | undefined;
23
+ getSQLType: () => string;
24
+ hasOnUpdateNow?: boolean;
25
+ identity?: unknown;
26
+ isUnique: boolean;
27
+ name: string;
28
+ notNull: boolean;
29
+ onUpdateFn?: unknown;
30
+ primary: boolean;
31
+ uniqueType?: string | undefined;
32
+ };
33
+ export type IndexConfig = {
34
+ algorithm?: string | undefined;
35
+ columns: readonly unknown[];
36
+ concurrently?: boolean | undefined;
37
+ lock?: string | undefined;
38
+ method?: string | undefined;
39
+ name?: string | undefined;
40
+ unique?: boolean | undefined;
41
+ using?: string | SQL | undefined;
42
+ where?: SQL | undefined;
43
+ with?: Record<string, unknown> | undefined;
44
+ };
45
+ export type PolicyConfig = {
46
+ as?: string | undefined;
47
+ for?: string | undefined;
48
+ name: string;
49
+ to?: unknown;
50
+ using?: SQL | undefined;
51
+ withCheck?: SQL | undefined;
52
+ };
53
+ type ForeignKeyConfig = {
54
+ onDelete?: string | undefined;
55
+ onUpdate?: string | undefined;
56
+ reference: () => {
57
+ columns: readonly DrizzleColumn[];
58
+ foreignColumns: readonly DrizzleColumn[];
59
+ foreignTable: object;
60
+ name?: string | undefined;
61
+ };
62
+ };
63
+ export type TableConfig = {
64
+ checks: readonly {
65
+ name: string;
66
+ value: SQL;
67
+ }[];
68
+ columns: readonly DrizzleColumn[];
69
+ enableRLS?: boolean;
70
+ foreignKeys: readonly ForeignKeyConfig[];
71
+ indexes: readonly {
72
+ config: IndexConfig;
73
+ }[];
74
+ name: string;
75
+ policies?: readonly PolicyConfig[];
76
+ primaryKeys: readonly {
77
+ columns: readonly DrizzleColumn[];
78
+ name?: string | undefined;
79
+ }[];
80
+ schema?: string | undefined;
81
+ uniqueConstraints: readonly {
82
+ columns: readonly DrizzleColumn[];
83
+ name?: string | undefined;
84
+ nullsNotDistinct?: boolean;
85
+ }[];
86
+ };
87
+ export type ViewConfig = {
88
+ isExisting: boolean;
89
+ name: string;
90
+ query?: SQL | undefined;
91
+ schema?: string | undefined;
92
+ selectedFields: Record<string, unknown>;
93
+ };
94
+ export type EnumConfig = {
95
+ enumName: string;
96
+ enumValues: readonly string[];
97
+ schema?: string | undefined;
98
+ };
99
+ export type SequenceConfig = {
100
+ schema?: string | undefined;
101
+ seqName?: string | undefined;
102
+ seqOptions?: object | undefined;
103
+ };
104
+ export type Dialect = {
105
+ databaseType: string;
106
+ enumOf: (value: unknown) => EnumConfig | undefined;
107
+ materializedViewOf: (value: unknown) => ViewConfig | undefined;
108
+ sequenceOf: (value: unknown) => SequenceConfig | undefined;
109
+ tableOf: (value: unknown) => TableConfig | undefined;
110
+ viewOf: (value: unknown) => ViewConfig | undefined;
111
+ };
112
+ export declare const DIALECTS: Dialect[];
113
+ /** A Drizzle SQL fragment as text, its columns by bare name (`"email"`,
114
+ * not `"users"."email"`) and its values written in. The fragment itself
115
+ * is left as it was. */
116
+ export declare const sqlText: (fragment: SQL) => string;
117
+ /** The same, with columns named by their table (`"users"."email"`), for
118
+ * a query that reads several tables. */
119
+ export declare const sqlTextQualified: (fragment: SQL) => string;
120
+ export declare const isSql: (value: unknown) => value is SQL;
121
+ export {};
@@ -0,0 +1,21 @@
1
+ import { type DbmlModel } from '../model';
2
+ type TablePlace = {
3
+ name: string;
4
+ schema?: string;
5
+ };
6
+ export type FromDrizzleOptions = {
7
+ /**
8
+ * Table groups: `'schema'` groups tables by their schema, or a function
9
+ * names the group a table belongs in (undefined for none).
10
+ */
11
+ groups?: 'schema' | ((table: TablePlace) => string | undefined);
12
+ project?: {
13
+ name?: string;
14
+ note?: string;
15
+ };
16
+ /** The `defineRelations(...)` result, when it isn't one of the exports. */
17
+ relations?: unknown;
18
+ };
19
+ /** The schema's exports as a DBML model. */
20
+ export declare const fromDrizzle: (schema: Record<string, unknown> | unknown[], options?: FromDrizzleOptions) => DbmlModel;
21
+ export {};