@event-driven-io/dumbo 0.13.0-beta.4 → 0.13.0-beta.41
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/dist/cloudflare.cjs +397 -0
- package/dist/cloudflare.cjs.map +1 -0
- package/dist/cloudflare.d.cts +99 -0
- package/dist/cloudflare.d.ts +99 -0
- package/dist/cloudflare.js +361 -0
- package/dist/cloudflare.js.map +1 -0
- package/dist/core-BMeDuqBQ.js +2265 -0
- package/dist/core-BMeDuqBQ.js.map +1 -0
- package/dist/core-BPNgo5b6.js +379 -0
- package/dist/core-BPNgo5b6.js.map +1 -0
- package/dist/core-CIVu4cNp.cjs +588 -0
- package/dist/core-CIVu4cNp.cjs.map +1 -0
- package/dist/core-D5W_5J8k.cjs +3246 -0
- package/dist/core-D5W_5J8k.cjs.map +1 -0
- package/dist/core-DqUjje4u.cjs +450 -0
- package/dist/core-DqUjje4u.cjs.map +1 -0
- package/dist/core-gu5fi784.js +451 -0
- package/dist/core-gu5fi784.js.map +1 -0
- package/dist/{index-C2z_XBn6.d.ts → index-B-q2er0S.d.cts} +122 -75
- package/dist/{index-C0h0c380.d.cts → index-B5qbt5nP.d.ts} +122 -75
- package/dist/index-BJJAkyuJ.d.ts +68 -0
- package/dist/index-CRbkvVjT.d.ts +1587 -0
- package/dist/index-Cmdlb0KP.d.cts +1587 -0
- package/dist/index-D7qxqMf9.d.cts +67 -0
- package/dist/index-DtRCGhFP.d.cts +68 -0
- package/dist/index-m5LDyNNF.d.ts +67 -0
- package/dist/index.cjs +219 -270
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -127
- package/dist/index.d.ts +3 -127
- package/dist/index.js +56 -269
- package/dist/index.js.map +1 -1
- package/dist/pg.cjs +373 -659
- package/dist/pg.cjs.map +1 -1
- package/dist/pg.d.cts +140 -153
- package/dist/pg.d.ts +140 -153
- package/dist/pg.js +326 -658
- package/dist/pg.js.map +1 -1
- package/dist/postgreSQLMetadata-Khf1e9CT.js +65 -0
- package/dist/postgreSQLMetadata-Khf1e9CT.js.map +1 -0
- package/dist/postgreSQLMetadata-Ri_p5u6i.cjs +118 -0
- package/dist/postgreSQLMetadata-Ri_p5u6i.cjs.map +1 -0
- package/dist/postgresql.cjs +25 -0
- package/dist/postgresql.d.cts +3 -0
- package/dist/postgresql.d.ts +3 -0
- package/dist/postgresql.js +4 -0
- package/dist/sqlite.cjs +30 -0
- package/dist/sqlite.d.cts +3 -0
- package/dist/sqlite.d.ts +3 -0
- package/dist/sqlite.js +4 -0
- package/dist/sqlite3.cjs +437 -273
- package/dist/sqlite3.cjs.map +1 -1
- package/dist/sqlite3.d.cts +92 -70
- package/dist/sqlite3.d.ts +92 -70
- package/dist/sqlite3.js +402 -272
- package/dist/sqlite3.js.map +1 -1
- package/dist/sqliteMetadata-CpmoZxqb.cjs +46 -0
- package/dist/sqliteMetadata-CpmoZxqb.cjs.map +1 -0
- package/dist/sqliteMetadata-viYmVwA5.js +29 -0
- package/dist/sqliteMetadata-viYmVwA5.js.map +1 -0
- package/package.json +60 -37
- package/dist/chunk-32AL3EAS.cjs +0 -47
- package/dist/chunk-32AL3EAS.cjs.map +0 -1
- package/dist/chunk-6IHCIJ7S.js +0 -47
- package/dist/chunk-6IHCIJ7S.js.map +0 -1
- package/dist/chunk-IYEHOE4S.cjs +0 -405
- package/dist/chunk-IYEHOE4S.cjs.map +0 -1
- package/dist/chunk-N7RWT46K.js +0 -2011
- package/dist/chunk-N7RWT46K.js.map +0 -1
- package/dist/chunk-OJ34O3Q2.cjs +0 -2011
- package/dist/chunk-OJ34O3Q2.cjs.map +0 -1
- package/dist/chunk-XVV3OOQX.js +0 -405
- package/dist/chunk-XVV3OOQX.js.map +0 -1
- package/dist/columnProcessors-BX-sH7ah.d.cts +0 -8
- package/dist/columnProcessors-DMPpTPqM.d.ts +0 -8
- package/dist/connectionString-B1wm0TFc.d.cts +0 -1271
- package/dist/connectionString-B1wm0TFc.d.ts +0 -1271
- package/dist/d1.cjs +0 -277
- package/dist/d1.cjs.map +0 -1
- package/dist/d1.d.cts +0 -72
- package/dist/d1.d.ts +0 -72
- package/dist/d1.js +0 -277
- package/dist/d1.js.map +0 -1
|
@@ -0,0 +1,1587 @@
|
|
|
1
|
+
//#region src/core/connections/client.d.ts
|
|
2
|
+
type DbClientSetup<DbClient = unknown> = {
|
|
3
|
+
connect: () => Promise<DbClient> | void;
|
|
4
|
+
close: (client: DbClient) => Promise<void> | void;
|
|
5
|
+
};
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/core/serializer/json/index.d.ts
|
|
8
|
+
interface JSONSerializer<SerializeOptions extends JSONSerializeOptions = JSONSerializeOptions, DeserializeOptions extends JSONDeserializeOptions = JSONDeserializeOptions> extends Serializer<string, SerializeOptions, DeserializeOptions> {
|
|
9
|
+
serialize<T>(object: T, options?: SerializeOptions): string;
|
|
10
|
+
deserialize<T>(payload: string, options?: DeserializeOptions): T;
|
|
11
|
+
}
|
|
12
|
+
type JSONSerializerOptions = {
|
|
13
|
+
parseDates?: boolean;
|
|
14
|
+
parseBigInts?: boolean;
|
|
15
|
+
failOnBigIntSerialization?: boolean;
|
|
16
|
+
useDefaultDateSerialization?: boolean;
|
|
17
|
+
};
|
|
18
|
+
type JSONSerializeOptions = {
|
|
19
|
+
replacer?: JSONReplacer;
|
|
20
|
+
} & JSONSerializerOptions;
|
|
21
|
+
type JSONDeserializeOptions = {
|
|
22
|
+
reviver?: JSONReviver;
|
|
23
|
+
} & JSONSerializerOptions;
|
|
24
|
+
interface JSONCodec<T, SerializeOptions extends JSONSerializeOptions = JSONSerializeOptions, DeserializeOptions extends JSONDeserializeOptions = JSONDeserializeOptions> extends SerializationCodec<T, string, SerializeOptions, DeserializeOptions> {
|
|
25
|
+
encode(object: T, options?: SerializeOptions): string;
|
|
26
|
+
decode(payload: string, options?: DeserializeOptions): T;
|
|
27
|
+
}
|
|
28
|
+
type JSONCodecSerializationOptions<SerializeOptions extends JSONSerializeOptions = JSONSerializeOptions, DeserializeOptions extends JSONDeserializeOptions = JSONDeserializeOptions> = {
|
|
29
|
+
serializer?: JSONSerializer<SerializeOptions, DeserializeOptions>;
|
|
30
|
+
serializerOptions?: never;
|
|
31
|
+
} | {
|
|
32
|
+
serializer?: never;
|
|
33
|
+
serializerOptions?: JSONSerializerOptions;
|
|
34
|
+
};
|
|
35
|
+
type JSONSerializationOptions<SerializeOptions extends JSONSerializeOptions = JSONSerializeOptions, DeserializeOptions extends JSONDeserializeOptions = JSONDeserializeOptions> = {
|
|
36
|
+
serialization?: {
|
|
37
|
+
serializer?: JSONSerializer<SerializeOptions, DeserializeOptions>;
|
|
38
|
+
options?: JSONSerializeOptions | JSONDeserializeOptions;
|
|
39
|
+
} | undefined;
|
|
40
|
+
};
|
|
41
|
+
type JSONCodecOptions<T, Payload = T, SerializeOptions extends JSONSerializeOptions = JSONSerializeOptions, DeserializeOptions extends JSONDeserializeOptions = JSONDeserializeOptions> = JSONCodecSerializationOptions<SerializeOptions, DeserializeOptions> & {
|
|
42
|
+
upcast?: (document: Payload) => T;
|
|
43
|
+
downcast?: (document: T) => Payload;
|
|
44
|
+
};
|
|
45
|
+
type JSONReplacer = (this: any, key: string, value: any) => any;
|
|
46
|
+
type JSONReviver = (this: any, key: string, value: any, context: JSONReviverContext) => any;
|
|
47
|
+
type JSONReviverContext = {
|
|
48
|
+
source: string;
|
|
49
|
+
};
|
|
50
|
+
declare const composeJSONReplacers: (...replacers: (JSONReplacer | undefined)[]) => JSONReplacer | undefined;
|
|
51
|
+
declare const composeJSONRevivers: (...revivers: (JSONReviver | undefined)[]) => JSONReviver | undefined;
|
|
52
|
+
declare const JSONReplacer: (opts?: JSONSerializeOptions) => JSONReplacer | undefined;
|
|
53
|
+
declare const JSONReviver: (opts?: JSONDeserializeOptions) => JSONReviver | undefined;
|
|
54
|
+
declare const JSONReplacers: {
|
|
55
|
+
bigInt: JSONReplacer;
|
|
56
|
+
date: JSONReplacer;
|
|
57
|
+
};
|
|
58
|
+
declare const JSONRevivers: {
|
|
59
|
+
bigInt: JSONReviver;
|
|
60
|
+
date: JSONReviver;
|
|
61
|
+
};
|
|
62
|
+
declare const jsonSerializer: (options?: JSONSerializerOptions & JSONDeserializeOptions & JSONSerializeOptions) => JSONSerializer;
|
|
63
|
+
declare const JSONSerializer: JSONSerializer & {
|
|
64
|
+
from: <SerializeOptions extends JSONSerializeOptions = JSONSerializeOptions, DeserializeOptions extends JSONDeserializeOptions = JSONDeserializeOptions>(options?: JSONSerializationOptions<SerializeOptions, DeserializeOptions>) => JSONSerializer<SerializeOptions, DeserializeOptions>;
|
|
65
|
+
};
|
|
66
|
+
declare const JSONCodec: <T, Payload = T, SerializeOptions extends JSONSerializeOptions = JSONSerializeOptions, DeserializeOptions extends JSONDeserializeOptions = JSONDeserializeOptions>(options: JSONCodecOptions<T, Payload, SerializeOptions, DeserializeOptions>) => JSONCodec<T, SerializeOptions, DeserializeOptions>;
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/core/serializer/index.d.ts
|
|
69
|
+
interface Serializer<Payload, SerializeOptions extends Record<string, unknown> = Record<string, unknown>, DeserializeOptions extends Record<string, unknown> = SerializeOptions> {
|
|
70
|
+
serialize<T>(object: T, options?: SerializeOptions): Payload;
|
|
71
|
+
deserialize<T>(payload: Payload, options?: DeserializeOptions): T;
|
|
72
|
+
}
|
|
73
|
+
interface SerializationCodec<T, Payload, SerializeOptions extends Record<string, unknown> = Record<string, unknown>, DeserializeOptions extends Record<string, unknown> = SerializeOptions> {
|
|
74
|
+
encode(object: T, options?: SerializeOptions): Payload;
|
|
75
|
+
decode(payload: Payload, options?: DeserializeOptions): T;
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/core/sql/parametrizedSQL/parametrizedSQL.d.ts
|
|
79
|
+
interface ParametrizedSQL {
|
|
80
|
+
query: string;
|
|
81
|
+
params: unknown[];
|
|
82
|
+
}
|
|
83
|
+
interface ParametrizedSQLBuilder {
|
|
84
|
+
addSQL: (str: string) => ParametrizedSQLBuilder;
|
|
85
|
+
addParam(value: unknown): ParametrizedSQLBuilder;
|
|
86
|
+
addParams(values: unknown[]): ParametrizedSQLBuilder;
|
|
87
|
+
build: () => ParametrizedSQL;
|
|
88
|
+
}
|
|
89
|
+
declare const ParametrizedSQLBuilder: ({
|
|
90
|
+
mapParamPlaceholder
|
|
91
|
+
}: {
|
|
92
|
+
mapParamPlaceholder: (index: number, value: unknown) => string;
|
|
93
|
+
}) => ParametrizedSQLBuilder;
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/core/sql/tokens/sqlToken.d.ts
|
|
96
|
+
type SQLToken<TSymbol extends string = string, TProps extends Omit<Record<string, unknown>, 'sqlTokenType'> | undefined = Omit<Record<string, unknown>, 'sqlTokenType'> | undefined> = {
|
|
97
|
+
sqlTokenType: TSymbol;
|
|
98
|
+
} & (TProps extends undefined ? void : Omit<TProps, 'sqlTokenType'>);
|
|
99
|
+
type ExtractSQLTokenType<T> = T extends ((...args: never[]) => infer R) ? R extends SQLToken ? R : never : T extends SQLToken ? T : never;
|
|
100
|
+
type AnySQLToken = SQLToken<string, any>;
|
|
101
|
+
declare const SQLToken: {
|
|
102
|
+
<SQLTokenType extends AnySQLToken, TInput = (Exclude<keyof SQLTokenType, "sqlTokenType"> extends never ? void : Omit<SQLTokenType, "sqlTokenType">)>(sqlTokenType: SQLTokenType["sqlTokenType"], map?: (input: TInput) => Omit<SQLTokenType, "sqlTokenType">): {
|
|
103
|
+
from: (input: TInput) => SQLTokenType;
|
|
104
|
+
check: (token: unknown) => token is SQLTokenType;
|
|
105
|
+
type: SQLTokenType["sqlTokenType"];
|
|
106
|
+
};
|
|
107
|
+
check<SQLTokenType extends AnySQLToken>(token: unknown): token is SQLTokenType;
|
|
108
|
+
};
|
|
109
|
+
type SQLIdentifier = SQLToken<'SQL_IDENTIFIER', {
|
|
110
|
+
value: string;
|
|
111
|
+
}>;
|
|
112
|
+
declare const SQLIdentifier: {
|
|
113
|
+
from: (input: string) => SQLIdentifier;
|
|
114
|
+
check: (token: unknown) => token is SQLIdentifier;
|
|
115
|
+
type: "SQL_IDENTIFIER";
|
|
116
|
+
};
|
|
117
|
+
type SQLPlain = SQLToken<'SQL_RAW', {
|
|
118
|
+
value: string;
|
|
119
|
+
}>;
|
|
120
|
+
declare const SQLPlain: {
|
|
121
|
+
from: (input: string) => SQLPlain;
|
|
122
|
+
check: (token: unknown) => token is SQLPlain;
|
|
123
|
+
type: "SQL_RAW";
|
|
124
|
+
};
|
|
125
|
+
type SQLLiteral = SQLToken<'SQL_LITERAL', {
|
|
126
|
+
value: unknown;
|
|
127
|
+
}>;
|
|
128
|
+
declare const SQLLiteral: {
|
|
129
|
+
from: (input: unknown) => SQLLiteral;
|
|
130
|
+
check: (token: unknown) => token is SQLLiteral;
|
|
131
|
+
type: "SQL_LITERAL";
|
|
132
|
+
};
|
|
133
|
+
type SQLArrayMode = 'params' | 'native';
|
|
134
|
+
type SQLArray = SQLToken<'SQL_ARRAY', {
|
|
135
|
+
value: unknown[];
|
|
136
|
+
mode?: SQLArrayMode;
|
|
137
|
+
}>;
|
|
138
|
+
declare const SQLArray: {
|
|
139
|
+
from: (input: unknown[] | {
|
|
140
|
+
value: unknown[];
|
|
141
|
+
mode?: SQLArrayMode;
|
|
142
|
+
}) => SQLArray;
|
|
143
|
+
check: (token: unknown) => token is SQLArray;
|
|
144
|
+
type: "SQL_ARRAY";
|
|
145
|
+
};
|
|
146
|
+
type SQLIn = SQLToken<'SQL_IN', {
|
|
147
|
+
column: SQLIdentifier;
|
|
148
|
+
values: SQLArray;
|
|
149
|
+
mode?: SQLArrayMode;
|
|
150
|
+
}>;
|
|
151
|
+
declare const SQLIn: {
|
|
152
|
+
from: (input: {
|
|
153
|
+
column: string;
|
|
154
|
+
values: unknown[];
|
|
155
|
+
mode?: SQLArrayMode;
|
|
156
|
+
}) => SQLIn;
|
|
157
|
+
check: (token: unknown) => token is SQLIn;
|
|
158
|
+
type: "SQL_IN";
|
|
159
|
+
};
|
|
160
|
+
type SQLDefaultTokens = SQLIdentifier | SQLPlain | SQLLiteral | SQLArray;
|
|
161
|
+
type SQLDefaultTokensTypes = SQLDefaultTokens['sqlTokenType'];
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/core/sql/tokens/columnTokens.d.ts
|
|
164
|
+
type JSONValueType = Record<string, unknown> | Array<unknown> | string | number | boolean | null;
|
|
165
|
+
type JSONValueTypeName = 'value_type:json:object' | 'value_type:json:array' | 'value_type:json:string' | 'value_type:json:number' | 'value_type:json:boolean' | 'value_type:json:null';
|
|
166
|
+
type JavaScriptValueType = Record<string, unknown> | Array<unknown> | string | number | boolean | null | undefined | Date | bigint;
|
|
167
|
+
type JavaScriptValueTypeName = 'value_type:js:object' | 'value_type:js:array' | 'value_type:js:string' | 'value_type:js:number' | 'value_type:js:boolean' | 'value_type:js:null' | 'value_type:js:undefined' | 'value_type:js:date' | 'value_type:js:bigint';
|
|
168
|
+
type JavaScriptValueTypeToNameMap = { [K in JavaScriptValueType as K extends Record<string, unknown> ? 'value_type:js:object' : K extends Array<unknown> ? 'value_type:js:array' : K extends string ? 'value_type:js:string' : K extends number ? 'value_type:js:number' : K extends boolean ? 'value_type:js:boolean' : K extends null ? 'value_type:js:null' : K extends undefined ? 'value_type:js:undefined' : K extends Date ? 'value_type:js:date' : K extends bigint ? 'value_type:js:bigint' : never]: K };
|
|
169
|
+
type ColumnTypeToken<JSValueTypeName extends JavaScriptValueTypeName = JavaScriptValueTypeName, ColumnTypeName extends string = string, TProps extends Omit<Record<string, unknown>, 'sqlTokenType'> | undefined = Omit<Record<string, unknown>, 'sqlTokenType'> | undefined, ValueType = undefined> = SQLToken<`SQL_COLUMN_${ColumnTypeName}`, TProps> & {
|
|
170
|
+
__brand: ValueType extends undefined ? JavaScriptValueTypeToNameMap[JSValueTypeName] : ValueType;
|
|
171
|
+
jsTypeName: JSValueTypeName;
|
|
172
|
+
};
|
|
173
|
+
declare const ColumnTypeToken: <SQLTokenType extends AnyColumnTypeToken, TInput = (keyof Omit<SQLTokenType, "sqlTokenType" | "__brand" | "jsTypeName"> extends never ? void : Omit<SQLTokenType, "sqlTokenType" | "__brand" | "jsTypeName">)>(sqlTokenType: SQLTokenType["sqlTokenType"], jsTypeName: SQLTokenType["jsTypeName"], map?: (input: TInput) => Omit<SQLTokenType, "sqlTokenType" | "__brand" | "jsTypeName">) => {
|
|
174
|
+
from: (input: TInput) => SQLTokenType;
|
|
175
|
+
check: (token: unknown) => token is SQLTokenType;
|
|
176
|
+
type: SQLTokenType["sqlTokenType"];
|
|
177
|
+
};
|
|
178
|
+
type AnyColumnTypeToken = ColumnTypeToken<any, string, any>;
|
|
179
|
+
type SerialToken = ColumnTypeToken<'value_type:js:number', 'SERIAL'>;
|
|
180
|
+
declare const SerialToken: {
|
|
181
|
+
from: (input: void) => SerialToken;
|
|
182
|
+
check: (token: unknown) => token is SerialToken;
|
|
183
|
+
type: "SQL_COLUMN_SERIAL";
|
|
184
|
+
};
|
|
185
|
+
type BigSerialToken = ColumnTypeToken<'value_type:js:bigint', 'BIGSERIAL'>;
|
|
186
|
+
declare const BigSerialToken: {
|
|
187
|
+
from: (input: void) => BigSerialToken;
|
|
188
|
+
check: (token: unknown) => token is BigSerialToken;
|
|
189
|
+
type: "SQL_COLUMN_BIGSERIAL";
|
|
190
|
+
};
|
|
191
|
+
type IntegerToken = ColumnTypeToken<'value_type:js:number', 'INTEGER'>;
|
|
192
|
+
declare const IntegerToken: {
|
|
193
|
+
from: (input: void) => IntegerToken;
|
|
194
|
+
check: (token: unknown) => token is IntegerToken;
|
|
195
|
+
type: "SQL_COLUMN_INTEGER";
|
|
196
|
+
};
|
|
197
|
+
type BigIntegerToken = ColumnTypeToken<'value_type:js:bigint', 'BIGINT'>;
|
|
198
|
+
declare const BigIntegerToken: {
|
|
199
|
+
from: (input: void) => BigIntegerToken;
|
|
200
|
+
check: (token: unknown) => token is BigIntegerToken;
|
|
201
|
+
type: "SQL_COLUMN_BIGINT";
|
|
202
|
+
};
|
|
203
|
+
type JSONBToken<ValueType extends Record<string, unknown> = Record<string, unknown>> = ColumnTypeToken<'value_type:js:object', 'JSONB', undefined, ValueType>;
|
|
204
|
+
declare const JSONBToken: {
|
|
205
|
+
type: string;
|
|
206
|
+
from: <ValueType extends Record<string, unknown> = Record<string, unknown>>() => JSONBToken<ValueType>;
|
|
207
|
+
check: <ValueType extends Record<string, unknown> = Record<string, unknown>>(token: unknown) => token is JSONBToken<ValueType>;
|
|
208
|
+
};
|
|
209
|
+
type TimestampToken = ColumnTypeToken<'value_type:js:date', 'TIMESTAMP'>;
|
|
210
|
+
declare const TimestampToken: {
|
|
211
|
+
from: (input: void) => TimestampToken;
|
|
212
|
+
check: (token: unknown) => token is TimestampToken;
|
|
213
|
+
type: "SQL_COLUMN_TIMESTAMP";
|
|
214
|
+
};
|
|
215
|
+
type TimestamptzToken = ColumnTypeToken<'value_type:js:date', 'TIMESTAMPTZ'>;
|
|
216
|
+
declare const TimestamptzToken: {
|
|
217
|
+
from: (input: void) => TimestamptzToken;
|
|
218
|
+
check: (token: unknown) => token is TimestamptzToken;
|
|
219
|
+
type: "SQL_COLUMN_TIMESTAMPTZ";
|
|
220
|
+
};
|
|
221
|
+
type VarcharToken = ColumnTypeToken<'value_type:js:string', 'VARCHAR', {
|
|
222
|
+
length: number | 'max';
|
|
223
|
+
}>;
|
|
224
|
+
declare const VarcharToken: {
|
|
225
|
+
from: (input: number | "max") => VarcharToken;
|
|
226
|
+
check: (token: unknown) => token is VarcharToken;
|
|
227
|
+
type: "SQL_COLUMN_VARCHAR";
|
|
228
|
+
};
|
|
229
|
+
type NotNullableSQLColumnTokenProps<ColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string> = {
|
|
230
|
+
name: string;
|
|
231
|
+
type: ColumnType;
|
|
232
|
+
notNull: true;
|
|
233
|
+
unique?: boolean;
|
|
234
|
+
primaryKey?: boolean;
|
|
235
|
+
default?: ColumnType | SQLToken;
|
|
236
|
+
} | {
|
|
237
|
+
name: string;
|
|
238
|
+
type: ColumnType;
|
|
239
|
+
notNull?: false;
|
|
240
|
+
unique?: boolean;
|
|
241
|
+
primaryKey: never;
|
|
242
|
+
default?: ColumnType | SQLToken;
|
|
243
|
+
};
|
|
244
|
+
type NullableSQLColumnTokenProps<ColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string> = {
|
|
245
|
+
name: string;
|
|
246
|
+
type: ColumnType;
|
|
247
|
+
notNull?: false;
|
|
248
|
+
unique?: boolean;
|
|
249
|
+
primaryKey?: false;
|
|
250
|
+
default?: ColumnType | SQLToken;
|
|
251
|
+
};
|
|
252
|
+
type SQLColumnToken<ColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string> = SQLToken<'SQL_COLUMN', NotNullableSQLColumnTokenProps<ColumnType> | NullableSQLColumnTokenProps<ColumnType>>;
|
|
253
|
+
type AutoIncrementSQLColumnToken = ColumnTypeToken<'value_type:js:bigint', 'AUTO_INCREMENT', {
|
|
254
|
+
primaryKey: boolean;
|
|
255
|
+
bigint?: boolean;
|
|
256
|
+
}, bigint>;
|
|
257
|
+
declare const AutoIncrementSQLColumnToken: {
|
|
258
|
+
from: (input: Omit<AutoIncrementSQLColumnToken, "sqlTokenType" | "__brand" | "jsTypeName">) => AutoIncrementSQLColumnToken;
|
|
259
|
+
check: (token: unknown) => token is AutoIncrementSQLColumnToken;
|
|
260
|
+
type: "SQL_COLUMN_AUTO_INCREMENT";
|
|
261
|
+
};
|
|
262
|
+
declare const SQLColumnTypeTokens: {
|
|
263
|
+
AutoIncrement: {
|
|
264
|
+
from: (input: Omit<AutoIncrementSQLColumnToken, "sqlTokenType" | "__brand" | "jsTypeName">) => AutoIncrementSQLColumnToken;
|
|
265
|
+
check: (token: unknown) => token is AutoIncrementSQLColumnToken;
|
|
266
|
+
type: "SQL_COLUMN_AUTO_INCREMENT";
|
|
267
|
+
};
|
|
268
|
+
BigInteger: {
|
|
269
|
+
from: (input: void) => BigIntegerToken;
|
|
270
|
+
check: (token: unknown) => token is BigIntegerToken;
|
|
271
|
+
type: "SQL_COLUMN_BIGINT";
|
|
272
|
+
};
|
|
273
|
+
BigSerial: {
|
|
274
|
+
from: (input: void) => BigSerialToken;
|
|
275
|
+
check: (token: unknown) => token is BigSerialToken;
|
|
276
|
+
type: "SQL_COLUMN_BIGSERIAL";
|
|
277
|
+
};
|
|
278
|
+
Integer: {
|
|
279
|
+
from: (input: void) => IntegerToken;
|
|
280
|
+
check: (token: unknown) => token is IntegerToken;
|
|
281
|
+
type: "SQL_COLUMN_INTEGER";
|
|
282
|
+
};
|
|
283
|
+
JSONB: {
|
|
284
|
+
type: string;
|
|
285
|
+
from: <ValueType extends Record<string, unknown> = Record<string, unknown>>() => JSONBToken<ValueType>;
|
|
286
|
+
check: <ValueType extends Record<string, unknown> = Record<string, unknown>>(token: unknown) => token is JSONBToken<ValueType>;
|
|
287
|
+
};
|
|
288
|
+
Serial: {
|
|
289
|
+
from: (input: void) => SerialToken;
|
|
290
|
+
check: (token: unknown) => token is SerialToken;
|
|
291
|
+
type: "SQL_COLUMN_SERIAL";
|
|
292
|
+
};
|
|
293
|
+
Timestamp: {
|
|
294
|
+
from: (input: void) => TimestampToken;
|
|
295
|
+
check: (token: unknown) => token is TimestampToken;
|
|
296
|
+
type: "SQL_COLUMN_TIMESTAMP";
|
|
297
|
+
};
|
|
298
|
+
Timestamptz: {
|
|
299
|
+
from: (input: void) => TimestamptzToken;
|
|
300
|
+
check: (token: unknown) => token is TimestamptzToken;
|
|
301
|
+
type: "SQL_COLUMN_TIMESTAMPTZ";
|
|
302
|
+
};
|
|
303
|
+
Varchar: {
|
|
304
|
+
from: (input: number | "max") => VarcharToken;
|
|
305
|
+
check: (token: unknown) => token is VarcharToken;
|
|
306
|
+
type: "SQL_COLUMN_VARCHAR";
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
type SQLColumnTypeTokens = {
|
|
310
|
+
AutoIncrement: AutoIncrementSQLColumnToken;
|
|
311
|
+
BigInteger: BigIntegerToken;
|
|
312
|
+
BigSerial: BigSerialToken;
|
|
313
|
+
Integer: IntegerToken;
|
|
314
|
+
JSONB: JSONBToken;
|
|
315
|
+
Serial: SerialToken;
|
|
316
|
+
Timestamp: TimestampToken;
|
|
317
|
+
Timestamptz: TimestamptzToken;
|
|
318
|
+
Varchar: VarcharToken;
|
|
319
|
+
};
|
|
320
|
+
declare const SQLColumnTypeTokensFactory: {
|
|
321
|
+
AutoIncrement: (input: Omit<AutoIncrementSQLColumnToken, "sqlTokenType" | "__brand" | "jsTypeName">) => AutoIncrementSQLColumnToken;
|
|
322
|
+
BigInteger: BigIntegerToken;
|
|
323
|
+
BigSerial: BigSerialToken;
|
|
324
|
+
Integer: IntegerToken;
|
|
325
|
+
JSONB: <ValueType extends Record<string, unknown> = Record<string, unknown>>() => JSONBToken<ValueType>;
|
|
326
|
+
Serial: SerialToken;
|
|
327
|
+
Timestamp: TimestampToken;
|
|
328
|
+
Timestamptz: TimestamptzToken;
|
|
329
|
+
Varchar: (input: number | "max") => VarcharToken;
|
|
330
|
+
};
|
|
331
|
+
type DefaultSQLColumnToken = AutoIncrementSQLColumnToken | SerialToken | BigSerialToken | IntegerToken | JSONBToken | BigIntegerToken | TimestampToken | TimestamptzToken | VarcharToken;
|
|
332
|
+
declare const SQLColumnToken: {
|
|
333
|
+
from: (input: Omit<SQLColumnToken<string | AnyColumnTypeToken>, "sqlTokenType">) => SQLColumnToken<string | AnyColumnTypeToken>;
|
|
334
|
+
check: (token: unknown) => token is SQLColumnToken<string | AnyColumnTypeToken>;
|
|
335
|
+
type: "SQL_COLUMN";
|
|
336
|
+
};
|
|
337
|
+
//#endregion
|
|
338
|
+
//#region src/core/sql/valueMappers/sqlValueMapper.d.ts
|
|
339
|
+
interface SQLValueMapper {
|
|
340
|
+
mapValue: MapSQLParamValue;
|
|
341
|
+
mapPlaceholder: (index: number, value: unknown) => string;
|
|
342
|
+
mapIdentifier: (value: string) => string;
|
|
343
|
+
}
|
|
344
|
+
type MapSQLParamValue = (value: unknown, serializer: JSONSerializer, options?: MapSQLParamValueOptions) => unknown;
|
|
345
|
+
interface MapSQLParamValueOptions {
|
|
346
|
+
mapBoolean?: (value: boolean) => unknown;
|
|
347
|
+
mapArray?: (array: unknown[], mapValue: MapSQLParamValue) => unknown[];
|
|
348
|
+
mapDate?: (value: Date) => unknown;
|
|
349
|
+
mapObject?: (value: object) => unknown;
|
|
350
|
+
mapBigInt?: (value: bigint) => unknown;
|
|
351
|
+
mapValue?: MapSQLParamValue;
|
|
352
|
+
mapPlaceholder?: (index: number, value: unknown) => string;
|
|
353
|
+
mapIdentifier?: (value: string) => string;
|
|
354
|
+
}
|
|
355
|
+
declare const ANSISQLParamPlaceholder = "?";
|
|
356
|
+
declare const ANSISQLIdentifierQuote = "\"";
|
|
357
|
+
declare const mapANSISQLParamPlaceholder: () => string;
|
|
358
|
+
declare const mapSQLIdentifier: (value: string, options?: {
|
|
359
|
+
reservedWords: {
|
|
360
|
+
[key: string]: boolean;
|
|
361
|
+
};
|
|
362
|
+
quote?: string;
|
|
363
|
+
}) => string;
|
|
364
|
+
declare const DefaultMapSQLParamValueOptions: {
|
|
365
|
+
mapPlaceholder: () => string;
|
|
366
|
+
mapIdentifier: (value: string, options?: {
|
|
367
|
+
reservedWords: {
|
|
368
|
+
[key: string]: boolean;
|
|
369
|
+
};
|
|
370
|
+
quote?: string;
|
|
371
|
+
}) => string;
|
|
372
|
+
};
|
|
373
|
+
declare const SQLValueMapper: (options?: MapSQLParamValueOptions) => SQLValueMapper;
|
|
374
|
+
declare function mapSQLParamValue(value: unknown, serializer: JSONSerializer, options?: MapSQLParamValueOptions): unknown;
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region src/core/sql/processors/sqlProcessor.d.ts
|
|
377
|
+
type SQLProcessorContext = {
|
|
378
|
+
mapper: SQLValueMapper;
|
|
379
|
+
builder: ParametrizedSQLBuilder;
|
|
380
|
+
processorsRegistry: SQLProcessorsReadonlyRegistry;
|
|
381
|
+
serializer: JSONSerializer;
|
|
382
|
+
};
|
|
383
|
+
type SQLProcessor<Token extends AnySQLToken = AnySQLToken> = {
|
|
384
|
+
canHandle: Token['sqlTokenType'];
|
|
385
|
+
handle: (value: Token, context: SQLProcessorContext) => void;
|
|
386
|
+
};
|
|
387
|
+
type AnySQLProcessor = SQLProcessor<any>;
|
|
388
|
+
type SQLProcessorOptions<Token extends AnySQLToken = AnySQLToken> = {
|
|
389
|
+
canHandle: Token['sqlTokenType'];
|
|
390
|
+
handle: (value: Token, context: SQLProcessorContext) => void;
|
|
391
|
+
};
|
|
392
|
+
declare const SQLProcessor: <Token extends AnySQLToken = AnySQLToken>(options: SQLProcessorOptions<Token>) => SQLProcessor<Token>;
|
|
393
|
+
//#endregion
|
|
394
|
+
//#region src/core/sql/processors/sqlProcessorRegistry.d.ts
|
|
395
|
+
interface SQLProcessorsReadonlyRegistry {
|
|
396
|
+
get<Token extends AnySQLToken = AnySQLToken>(tokenType: Token['sqlTokenType']): SQLProcessor<Token> | null;
|
|
397
|
+
all(): ReadonlyMap<string, AnySQLProcessor>;
|
|
398
|
+
}
|
|
399
|
+
interface SQLProcessorsRegistry extends SQLProcessorsReadonlyRegistry {
|
|
400
|
+
register(...processor: AnySQLProcessor[]): SQLProcessorsRegistry;
|
|
401
|
+
register(processor: Record<string, AnySQLProcessor>): SQLProcessorsRegistry;
|
|
402
|
+
}
|
|
403
|
+
declare const SQLProcessorsRegistry: (options?: {
|
|
404
|
+
from: SQLProcessorsRegistry;
|
|
405
|
+
}) => SQLProcessorsRegistry;
|
|
406
|
+
//#endregion
|
|
407
|
+
//#region src/core/sql/processors/columnProcessors.d.ts
|
|
408
|
+
type DefaultSQLColumnProcessors = { [key in keyof SQLColumnTypeTokens]: SQLProcessor<SQLColumnTypeTokens[key]> };
|
|
409
|
+
declare const mapDefaultSQLColumnProcessors: (mapColumnType: (token: DefaultSQLColumnToken, context: SQLProcessorContext) => void) => DefaultSQLColumnProcessors;
|
|
410
|
+
//#endregion
|
|
411
|
+
//#region src/core/sql/processors/defaultProcessors.d.ts
|
|
412
|
+
declare const ExpandArrayProcessor: SQLProcessor<SQLArray>;
|
|
413
|
+
declare const ExpandSQLInProcessor: SQLProcessor<SQLIn>;
|
|
414
|
+
declare const FormatIdentifierProcessor: SQLProcessor<SQLIdentifier>;
|
|
415
|
+
declare const MapLiteralProcessor: SQLProcessor<SQLLiteral>;
|
|
416
|
+
//#endregion
|
|
417
|
+
//#region src/core/sql/processors/index.d.ts
|
|
418
|
+
declare global {
|
|
419
|
+
var defaultProcessorsRegistry: ReturnType<typeof SQLProcessorsRegistry>;
|
|
420
|
+
}
|
|
421
|
+
declare const defaultProcessorsRegistry: SQLProcessorsRegistry;
|
|
422
|
+
//#endregion
|
|
423
|
+
//#region src/core/sql/sql.d.ts
|
|
424
|
+
type SQL = string & {
|
|
425
|
+
__brand: 'sql';
|
|
426
|
+
};
|
|
427
|
+
declare function SQL(strings: TemplateStringsArray, ...values: unknown[]): SQL;
|
|
428
|
+
declare namespace SQL {
|
|
429
|
+
export var EMPTY: SQL;
|
|
430
|
+
export var concat: (...sqls: SQL[]) => SQL;
|
|
431
|
+
export var merge: (sqls: SQL[], separator?: string) => SQL;
|
|
432
|
+
export var format: (sql: SQL | SQL[], formatter: SQLFormatter, options?: FormatSQLOptions) => ParametrizedSQL;
|
|
433
|
+
export var describe: (sql: SQL | SQL[], formatter: SQLFormatter, options?: FormatSQLOptions) => string;
|
|
434
|
+
var _a: (column: string, values: unknown[], options?: {
|
|
435
|
+
mode?: SQLArrayMode;
|
|
436
|
+
}) => SQLIn;
|
|
437
|
+
export var array: (values: unknown[], options?: {
|
|
438
|
+
mode?: SQLArrayMode;
|
|
439
|
+
}) => SQLArray;
|
|
440
|
+
export var identifier: (input: string) => SQLIdentifier;
|
|
441
|
+
export var plain: (input: string) => SQLPlain;
|
|
442
|
+
export var check: {
|
|
443
|
+
isSQL: (value: unknown) => value is SQL;
|
|
444
|
+
isTokenizedSQL: (value: unknown) => value is Readonly<{
|
|
445
|
+
__brand: "tokenized-sql";
|
|
446
|
+
sqlChunks: ReadonlyArray<string>;
|
|
447
|
+
sqlTokens: ReadonlyArray<AnySQLToken>;
|
|
448
|
+
}>;
|
|
449
|
+
isEmpty: (sql: SQL) => boolean;
|
|
450
|
+
isIdentifier: (token: unknown) => token is SQLIdentifier;
|
|
451
|
+
isPlain: (token: unknown) => token is SQLPlain;
|
|
452
|
+
isSQLIn: (token: unknown) => token is SQLIn;
|
|
453
|
+
};
|
|
454
|
+
export var column: ((input: Omit<SQLColumnToken<string | AnyColumnTypeToken>, "sqlTokenType">) => SQLColumnToken<string | AnyColumnTypeToken>) & {
|
|
455
|
+
type: typeof SQLColumnTypeTokensFactory;
|
|
456
|
+
};
|
|
457
|
+
export { _a as in };
|
|
458
|
+
}
|
|
459
|
+
declare function RawSQL(strings: TemplateStringsArray, ...values: unknown[]): SQL;
|
|
460
|
+
declare const isSQL: (value: unknown) => value is SQL;
|
|
461
|
+
//#endregion
|
|
462
|
+
//#region src/core/sql/formatters/sqlFormatter.d.ts
|
|
463
|
+
type FormatContext = Partial<SQLProcessorContext> & Pick<SQLProcessorContext, 'serializer'>;
|
|
464
|
+
interface SQLFormatter {
|
|
465
|
+
format: (sql: SQL | SQL[], context: FormatContext) => ParametrizedSQL;
|
|
466
|
+
describe: (sql: SQL | SQL[], context: FormatContext) => string;
|
|
467
|
+
valueMapper: SQLValueMapper;
|
|
468
|
+
}
|
|
469
|
+
type FormatSQLOptions = {
|
|
470
|
+
mapper?: MapSQLParamValueOptions;
|
|
471
|
+
processorsRegistry?: SQLProcessorsReadonlyRegistry;
|
|
472
|
+
serializer?: JSONSerializer;
|
|
473
|
+
};
|
|
474
|
+
type SQLFormatterOptions = Partial<Omit<SQLFormatter, 'valueMapper'>> & {
|
|
475
|
+
valueMapper?: MapSQLParamValueOptions;
|
|
476
|
+
processorsRegistry?: SQLProcessorsReadonlyRegistry;
|
|
477
|
+
};
|
|
478
|
+
declare const SQLFormatter: ({
|
|
479
|
+
format,
|
|
480
|
+
describe,
|
|
481
|
+
valueMapper: valueMapperOptions,
|
|
482
|
+
processorsRegistry
|
|
483
|
+
}: SQLFormatterOptions) => SQLFormatter;
|
|
484
|
+
declare global {
|
|
485
|
+
var dumboSQLFormatters: Record<string, SQLFormatter>;
|
|
486
|
+
}
|
|
487
|
+
declare const registerFormatter: (dialect: string, formatter: SQLFormatter) => void;
|
|
488
|
+
declare const getFormatter: (dialect: string) => SQLFormatter;
|
|
489
|
+
declare function formatSQL(sql: SQL | SQL[], formatter: SQLFormatter, serializer: JSONSerializer, context?: FormatSQLOptions): ParametrizedSQL;
|
|
490
|
+
declare const describeSQL: (sql: SQL | SQL[], formatter: SQLFormatter, serializer: JSONSerializer, options?: FormatSQLOptions) => string;
|
|
491
|
+
//#endregion
|
|
492
|
+
//#region src/core/schema/sqlMigration.d.ts
|
|
493
|
+
type MigrationStyle = 'None' | 'CreateOrUpdate';
|
|
494
|
+
type SQLMigration = {
|
|
495
|
+
name: string;
|
|
496
|
+
sqls: SQL[];
|
|
497
|
+
};
|
|
498
|
+
declare const sqlMigration: (name: string, sqls: SQL[]) => SQLMigration;
|
|
499
|
+
type MigrationRecord = {
|
|
500
|
+
id: number;
|
|
501
|
+
name: string;
|
|
502
|
+
application: string;
|
|
503
|
+
sqlHash: string;
|
|
504
|
+
timestamp: Date;
|
|
505
|
+
};
|
|
506
|
+
//#endregion
|
|
507
|
+
//#region src/core/schema/schemaComponent.d.ts
|
|
508
|
+
type SchemaComponent<ComponentKey extends string = string, AdditionalData extends Exclude<Record<string, unknown>, 'schemaComponentKey' | 'components' | 'migrations' | 'addComponent' | 'addMigration'> | undefined = undefined> = {
|
|
509
|
+
schemaComponentKey: ComponentKey;
|
|
510
|
+
components: ReadonlyMap<string, SchemaComponent>;
|
|
511
|
+
migrations: ReadonlyArray<SQLMigration>;
|
|
512
|
+
addComponent: <SchemaComponentType extends SchemaComponent<string, Record<string, any>> = SchemaComponent<string, Record<string, any>>>(component: SchemaComponentType) => SchemaComponentType;
|
|
513
|
+
addMigration: (migration: SQLMigration) => void;
|
|
514
|
+
} & Exclude<AdditionalData extends undefined ? {} : AdditionalData, 'schemaComponentKey' | 'components' | 'migrations' | 'addComponent' | 'addMigration'>;
|
|
515
|
+
type ExtractAdditionalData<T> = T extends SchemaComponent<infer _ComponentType, infer Data> ? Data : never;
|
|
516
|
+
type AnySchemaComponent = SchemaComponent<string, Record<string, any>>;
|
|
517
|
+
type AnySchemaComponentOfType<ComponentType extends string = string> = SchemaComponent<ComponentType, any>;
|
|
518
|
+
type SchemaComponentOptions<AdditionalOptions extends Record<string, unknown> = Record<string, unknown>> = {
|
|
519
|
+
migrations?: ReadonlyArray<SQLMigration>;
|
|
520
|
+
components?: ReadonlyArray<SchemaComponent>;
|
|
521
|
+
} & Omit<AdditionalOptions, 'migrations' | 'components'>;
|
|
522
|
+
type SchemaComponentType<Kind extends string = string> = `sc:${Kind}`;
|
|
523
|
+
type DumboSchemaComponentType<Kind extends string = string> = SchemaComponentType<`dumbo:${Kind}`>;
|
|
524
|
+
declare const schemaComponent: <const ComponentKey extends string = string>(key: ComponentKey, options: SchemaComponentOptions) => SchemaComponent<ComponentKey>;
|
|
525
|
+
declare const isSchemaComponentOfType: <SchemaComponentOfType extends AnySchemaComponent = AnySchemaComponent>(component: AnySchemaComponent, prefix: string) => component is SchemaComponentOfType;
|
|
526
|
+
declare const filterSchemaComponentsOfType: <T extends AnySchemaComponent>(components: ReadonlyMap<string, AnySchemaComponent>, prefix: string) => ReadonlyMap<string, T>;
|
|
527
|
+
declare const mapSchemaComponentsOfType: <T extends AnySchemaComponent>(components: ReadonlyMap<string, AnySchemaComponent>, prefix: string, keyMapper?: (component: T) => string) => ReadonlyMap<string, T>;
|
|
528
|
+
declare const findSchemaComponentsOfType: <T extends AnySchemaComponent>(root: AnySchemaComponent, prefix: string) => T[];
|
|
529
|
+
//#endregion
|
|
530
|
+
//#region src/core/schema/components/columnSchemaComponent.d.ts
|
|
531
|
+
type ColumnURNType = 'sc:dumbo:column';
|
|
532
|
+
type ColumnURN<ColumnName extends string = string> = `${ColumnURNType}:${ColumnName}`;
|
|
533
|
+
declare const ColumnURNType: ColumnURNType;
|
|
534
|
+
declare const ColumnURN: <ColumnName extends string = string>({
|
|
535
|
+
name
|
|
536
|
+
}: {
|
|
537
|
+
name: ColumnName;
|
|
538
|
+
}) => ColumnURN<ColumnName>;
|
|
539
|
+
type ColumnSchemaComponent<ColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string, ColumnName extends string = string> = SchemaComponent<ColumnURN<ColumnName>, Readonly<{
|
|
540
|
+
columnName: ColumnName;
|
|
541
|
+
}>> & SQLColumnToken<ColumnType>;
|
|
542
|
+
type AnyColumnSchemaComponent = ColumnSchemaComponent<any>;
|
|
543
|
+
type ColumnSchemaComponentOptions<ColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string> = Omit<SQLColumnToken<ColumnType>, 'name' | 'sqlTokenType'> & SchemaComponentOptions;
|
|
544
|
+
declare const columnSchemaComponent: <const ColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string, const TOptions extends ColumnSchemaComponentOptions<ColumnType> = ColumnSchemaComponentOptions<ColumnType>, const ColumnName extends string = string>(params: {
|
|
545
|
+
columnName: ColumnName;
|
|
546
|
+
} & TOptions) => ColumnSchemaComponent<ColumnType, ColumnName> & (TOptions extends {
|
|
547
|
+
notNull: true;
|
|
548
|
+
} | {
|
|
549
|
+
primaryKey: true;
|
|
550
|
+
} ? {
|
|
551
|
+
notNull: true;
|
|
552
|
+
} : {
|
|
553
|
+
notNull?: false;
|
|
554
|
+
});
|
|
555
|
+
//#endregion
|
|
556
|
+
//#region src/core/schema/components/indexSchemaComponent.d.ts
|
|
557
|
+
type IndexURNType = 'sc:dumbo:index';
|
|
558
|
+
type IndexURN = `${IndexURNType}:${string}`;
|
|
559
|
+
type IndexSchemaComponent = SchemaComponent<IndexURN, Readonly<{
|
|
560
|
+
indexName: string;
|
|
561
|
+
columnNames: ReadonlyArray<string>;
|
|
562
|
+
isUnique: boolean;
|
|
563
|
+
addColumn: (column: string | ColumnSchemaComponent) => void;
|
|
564
|
+
}>>;
|
|
565
|
+
declare const IndexURNType: IndexURNType;
|
|
566
|
+
declare const IndexURN: ({
|
|
567
|
+
name
|
|
568
|
+
}: {
|
|
569
|
+
name: string;
|
|
570
|
+
}) => IndexURN;
|
|
571
|
+
declare const indexSchemaComponent: ({
|
|
572
|
+
indexName,
|
|
573
|
+
columnNames,
|
|
574
|
+
isUnique,
|
|
575
|
+
...migrationsOrComponents
|
|
576
|
+
}: {
|
|
577
|
+
indexName: string;
|
|
578
|
+
columnNames: string[];
|
|
579
|
+
isUnique: boolean;
|
|
580
|
+
} & SchemaComponentOptions) => IndexSchemaComponent;
|
|
581
|
+
//#endregion
|
|
582
|
+
//#region src/core/typing/conditionals.d.ts
|
|
583
|
+
type IF<Condition extends boolean, Then, Else> = Condition extends true ? Then : Else;
|
|
584
|
+
type AND<A extends boolean, B extends boolean> = A extends true ? B extends true ? true : false : false;
|
|
585
|
+
type ALL<A extends boolean[]> = A extends [infer First, ...infer Rest] ? First extends true ? Rest extends boolean[] ? ALL<Rest> : true : false : true;
|
|
586
|
+
//#endregion
|
|
587
|
+
//#region src/core/typing/records.d.ts
|
|
588
|
+
type KeysOfString<T extends Record<string, unknown>> = Extract<keyof T, string>;
|
|
589
|
+
//#endregion
|
|
590
|
+
//#region src/core/typing/validation.d.ts
|
|
591
|
+
type TypeValidationResult<Valid extends boolean = boolean, Error = never> = Valid extends true ? {
|
|
592
|
+
valid: true;
|
|
593
|
+
} : {
|
|
594
|
+
valid: false;
|
|
595
|
+
error: Error;
|
|
596
|
+
};
|
|
597
|
+
type TypeValidationError<Error> = TypeValidationResult<false, Error>;
|
|
598
|
+
type TypeValidationSuccess = TypeValidationResult<true>;
|
|
599
|
+
type AnyTypeValidationError = TypeValidationError<any>;
|
|
600
|
+
type AnyTypeValidationResult = TypeValidationResult<boolean, any>;
|
|
601
|
+
type AnyTypeValidationFailed<Results = AnyTypeValidationResult[]> = Results extends readonly [infer First, ...infer Rest] ? First extends {
|
|
602
|
+
valid: false;
|
|
603
|
+
} ? true : Rest extends AnyTypeValidationResult[] ? AnyTypeValidationFailed<Rest> : false : false;
|
|
604
|
+
type UnwrapTypeValidationErrors<Results extends readonly AnyTypeValidationResult[]> = Results extends readonly [infer First, ...infer Rest] ? First extends TypeValidationResult<false, infer E> ? Rest extends readonly AnyTypeValidationResult[] ? [E, ...UnwrapTypeValidationErrors<Rest>] : [E] : Rest extends readonly AnyTypeValidationResult[] ? UnwrapTypeValidationErrors<Rest> : [] : [];
|
|
605
|
+
type FailOnFirstTypeValidationError<Validations extends readonly AnyTypeValidationResult[]> = Validations extends readonly [infer First, ...infer Rest] ? First extends AnyTypeValidationError ? First : Rest extends readonly AnyTypeValidationResult[] ? FailOnFirstTypeValidationError<Rest> : First : null;
|
|
606
|
+
//#endregion
|
|
607
|
+
//#region src/core/typing/tuples.d.ts
|
|
608
|
+
type GetTupleLength<T extends readonly unknown[]> = T['length'];
|
|
609
|
+
type NotEmptyTuple<T extends readonly unknown[]> = GetTupleLength<T> extends 0 ? never : T;
|
|
610
|
+
type HaveTuplesTheSameLength<T extends readonly unknown[], U extends readonly unknown[]> = GetTupleLength<T> extends GetTupleLength<U> ? true : false;
|
|
611
|
+
type IsEmptyTuple<T extends readonly unknown[]> = T extends [] ? true : false;
|
|
612
|
+
type IsNotEmptyTuple<T extends readonly unknown[]> = IsEmptyTuple<T> extends true ? false : true;
|
|
613
|
+
type FilterNotExistingInUnion<Tuple extends readonly string[], Union extends string> = Tuple extends readonly [infer First, ...infer Rest] ? First extends Union ? [...FilterNotExistingInUnion<Rest extends readonly string[] ? Rest : [], Union>] : [First, ...FilterNotExistingInUnion<Rest extends readonly string[] ? Rest : [], Union>] : [];
|
|
614
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
615
|
+
type LastOfUnion<T> = UnionToIntersection<T extends any ? () => T : never> extends (() => infer R) ? R : never;
|
|
616
|
+
type UnionToTuple<T, L = LastOfUnion<T>> = [T] extends [never] ? [] : [...UnionToTuple<Exclude<T, L>>, L];
|
|
617
|
+
type ZipTuplesCollectErrors<TupleA extends readonly unknown[], TupleB extends readonly unknown[], ValidateMap, Accumulated extends AnyTypeValidationError[] = []> = [TupleA, TupleB] extends [readonly [infer FirstA, ...infer RestA], readonly [infer FirstB, ...infer RestB]] ? FirstA extends keyof ValidateMap ? FirstB extends keyof ValidateMap[FirstA] ? ValidateMap[FirstA][FirstB] extends infer Result extends AnyTypeValidationError ? ZipTuplesCollectErrors<RestA, RestB, ValidateMap, [...Accumulated, Result]> : ZipTuplesCollectErrors<RestA, RestB, ValidateMap, Accumulated> : ZipTuplesCollectErrors<RestA, RestB, ValidateMap, Accumulated> : ZipTuplesCollectErrors<RestA, RestB, ValidateMap, Accumulated> : Accumulated;
|
|
618
|
+
type MapRecordCollectErrors<Record extends object, ValidateMap, Accumulated extends AnyTypeValidationError[] = [], Keys extends readonly unknown[] = UnionToTuple<keyof Record>> = Keys extends readonly [infer K, ...infer Rest] ? K extends keyof ValidateMap ? ValidateMap[K] extends infer Result extends AnyTypeValidationError ? MapRecordCollectErrors<Record, ValidateMap, [...Accumulated, Result], Rest> : MapRecordCollectErrors<Record, ValidateMap, Accumulated, Rest> : MapRecordCollectErrors<Record, ValidateMap, Accumulated, Rest> : Accumulated;
|
|
619
|
+
//#endregion
|
|
620
|
+
//#region src/core/schema/components/relationships/relationshipTypes.d.ts
|
|
621
|
+
type ExtractSchemaNames<DB> = DB extends DatabaseSchemaComponent<infer Schemas extends DatabaseSchemas> ? keyof Schemas : never;
|
|
622
|
+
type ExtractTableNames<Schema extends AnyDatabaseSchemaSchemaComponent> = Schema extends DatabaseSchemaSchemaComponent<infer Tables extends DatabaseSchemaTables> ? keyof Tables : never;
|
|
623
|
+
type ExtractColumnNames<Table extends AnyTableSchemaComponent> = Table extends TableSchemaComponent<infer Columns extends TableColumns> ? TableColumnNames<TableSchemaComponent<Columns>> : never;
|
|
624
|
+
type ExtractColumnTypeName<T> = T extends ColumnTypeToken<any, infer TypeName, any, any> ? Uppercase<TypeName> : never;
|
|
625
|
+
type AllColumnTypes<Schemas extends DatabaseSchemas> = { [SchemaName in keyof Schemas]: Schemas[SchemaName] extends DatabaseSchemaSchemaComponent<infer Tables> ? Writable<{ [TableName in keyof Tables]: Tables[TableName] extends TableSchemaComponent<infer Columns> ? Writable<{ [ColumnName in keyof Columns]: {
|
|
626
|
+
columnTypeName: ExtractColumnTypeName<Columns[ColumnName$1]['type']>;
|
|
627
|
+
} }> : never }> : never };
|
|
628
|
+
type AllColumnReferences<Schemas extends DatabaseSchemas> = { [SchemaName in keyof Schemas]: Schemas[SchemaName] extends DatabaseSchemaSchemaComponent<infer Tables> ? { [TableName in keyof Tables]: Tables[TableName] extends TableSchemaComponent<infer Columns> ? { [ColumnName in keyof Columns]: `${SchemaName & string}.${TableName & string}.${ColumnName$1 & string}` }[keyof Columns] : never }[keyof Tables] : never }[keyof Schemas];
|
|
629
|
+
type AllColumnTypesInSchema<Schema extends AnyDatabaseSchemaSchemaComponent> = Schema extends DatabaseSchemaSchemaComponent<infer Tables> ? { [TableName in keyof Tables]: Tables[TableName] extends TableSchemaComponent<infer Columns> ? { [ColumnName in keyof Columns]: {
|
|
630
|
+
columnTypeName: ExtractColumnTypeName<Columns[ColumnName$1]['type']>;
|
|
631
|
+
} } : never } : never;
|
|
632
|
+
type AllColumnReferencesInSchema<Schema extends AnyDatabaseSchemaSchemaComponent, SchemaName extends string> = Schema extends DatabaseSchemaSchemaComponent<infer Tables> ? { [TableName in keyof Tables]: Tables[TableName] extends TableSchemaComponent<infer Columns> ? { [ColumnName in keyof Columns]: `${SchemaName & string}.${TableName & string}.${ColumnName$1 & string}` }[keyof Columns] : never }[keyof Tables] : never;
|
|
633
|
+
type NormalizeReference<Path extends string, CurrentSchema extends string, CurrentTable extends string> = Path extends `${infer Schema}.${infer Table}.${infer Column}` ? `${Schema}.${Table}.${Column}` : Path extends `${infer Table}.${infer Column}` ? `${CurrentSchema}.${Table}.${Column}` : Path extends string ? `${CurrentSchema}.${CurrentTable}.${Path}` : never;
|
|
634
|
+
type NormalizeColumnPath<References extends readonly string[], SchemaName extends string, TableName extends string> = References extends readonly [infer First, ...infer Rest] ? First extends string ? Rest extends readonly string[] ? readonly [NormalizeReference<First, SchemaName, TableName>, ...NormalizeColumnPath<Rest, SchemaName, TableName>] : readonly [] : readonly [] : readonly [];
|
|
635
|
+
type ColumnName$1<ColName extends string = string> = `${ColName}`;
|
|
636
|
+
type TableColumnName<TableName extends string = string, ColName extends string = string> = `${TableName}.${ColName}`;
|
|
637
|
+
type SchemaColumnName<SchemaName extends string = string, TableName extends string = string, ColumnName extends string = string> = `${SchemaName}.${TableName}.${ColumnName}`;
|
|
638
|
+
type ColumnPath<SchemaName extends string = string, TableName extends string = string, ColName extends string = string> = SchemaColumnName<SchemaName, TableName, ColName> | TableColumnName<TableName, ColName> | ColumnName$1<ColName>;
|
|
639
|
+
type ColumnReference<SchemaName extends string = string, TableName extends string = string, ColumnName extends string = string> = {
|
|
640
|
+
schemaName: SchemaName;
|
|
641
|
+
tableName: TableName;
|
|
642
|
+
columnName: ColumnName;
|
|
643
|
+
};
|
|
644
|
+
type ColumnPathToReference<Reference extends ColumnPath = ColumnPath, CurrentSchema extends string = string, CurrentTable extends string = string> = NormalizeReference<Reference, CurrentSchema, CurrentTable> extends `${infer S}.${infer T}.${infer C}` ? {
|
|
645
|
+
schemaName: S;
|
|
646
|
+
tableName: T;
|
|
647
|
+
columnName: C;
|
|
648
|
+
} : never;
|
|
649
|
+
type ParseReferencePath<Path extends string> = Path extends `${infer Schema}.${infer Table}.${infer Column}` ? {
|
|
650
|
+
schema: Schema;
|
|
651
|
+
table: Table;
|
|
652
|
+
column: Column;
|
|
653
|
+
} : never;
|
|
654
|
+
type LookupColumnType<AllTypes, Path extends string> = ParseReferencePath<Path> extends {
|
|
655
|
+
schema: infer S;
|
|
656
|
+
table: infer T;
|
|
657
|
+
column: infer C;
|
|
658
|
+
} ? S extends keyof AllTypes ? T extends keyof AllTypes[S] ? C extends keyof AllTypes[S][T] ? AllTypes[S][T][C] extends {
|
|
659
|
+
columnTypeName: infer TypeName;
|
|
660
|
+
} ? TypeName : never : never : never : never : never;
|
|
661
|
+
type RelationshipType = 'one-to-one' | 'one-to-many' | 'many-to-one' | 'many-to-many';
|
|
662
|
+
type RelationshipDefinition<Columns extends string = string, Reference extends string = string, RelType extends RelationshipType = RelationshipType> = {
|
|
663
|
+
readonly columns: NotEmptyTuple<readonly Columns[]>;
|
|
664
|
+
readonly references: NotEmptyTuple<readonly Reference[]>;
|
|
665
|
+
readonly type: RelType;
|
|
666
|
+
};
|
|
667
|
+
type AnyTableRelationshipDefinition = RelationshipDefinition<any, any, any>;
|
|
668
|
+
type AnyTableRelationshipDefinitionWithColumns<Columns extends string = string> = RelationshipDefinition<Columns, any, any>;
|
|
669
|
+
type TableRelationships<Columns extends string = string> = Record<string, AnyTableRelationshipDefinitionWithColumns<Columns>>;
|
|
670
|
+
declare const relationship: <const Columns extends readonly string[], const References extends readonly string[], const RelType extends RelationshipType = RelationshipType>(columns: Columns, references: References, type: RelType) => {
|
|
671
|
+
readonly columns: Columns;
|
|
672
|
+
readonly references: References;
|
|
673
|
+
readonly type: RelType;
|
|
674
|
+
};
|
|
675
|
+
type AnyRelationshipDefinition = RelationshipDefinition<any, any, any>;
|
|
676
|
+
//#endregion
|
|
677
|
+
//#region src/core/schema/components/tableTypesInference.d.ts
|
|
678
|
+
type Writable<T> = { -readonly [P in keyof T]: T[P] };
|
|
679
|
+
type InferColumnType<ColumnType> = ColumnType extends ColumnTypeToken<infer _JSType, infer _ColumnTypeName, infer _TProps, infer ValueType> ? ValueType : ColumnType;
|
|
680
|
+
type TableColumnType<T extends AnyColumnSchemaComponent> = T extends ColumnSchemaComponent<infer ColumnType> ? T extends {
|
|
681
|
+
notNull: true;
|
|
682
|
+
} | {
|
|
683
|
+
primaryKey: true;
|
|
684
|
+
} ? InferColumnType<ColumnType> : InferColumnType<ColumnType> | null : unknown;
|
|
685
|
+
type TableColumnNames<T extends AnyTableSchemaComponent> = Exclude<keyof T['columns'], keyof ReadonlyMap<string, AnyColumnSchemaComponent>>;
|
|
686
|
+
type InferTableRow<Columns extends TableColumns> = Writable<{ [K in keyof Columns]: TableColumnType<Columns[K]> }>;
|
|
687
|
+
type TableRowType<T extends AnyTableSchemaComponent> = T extends TableSchemaComponent<infer Columns> ? InferTableRow<Columns> : never;
|
|
688
|
+
type InferSchemaTables<T extends AnyDatabaseSchemaSchemaComponent> = T extends DatabaseSchemaSchemaComponent<infer Tables> ? Tables : never;
|
|
689
|
+
type InferDatabaseSchemas<T extends AnyDatabaseSchemaComponent> = T extends DatabaseSchemaComponent<infer Schemas> ? Schemas : never;
|
|
690
|
+
//#endregion
|
|
691
|
+
//#region src/core/schema/components/tableSchemaComponent.d.ts
|
|
692
|
+
type TableURNType = 'sc:dumbo:table';
|
|
693
|
+
type TableURN = `${TableURNType}:${string}`;
|
|
694
|
+
declare const TableURNType: TableURNType;
|
|
695
|
+
declare const TableURN: ({
|
|
696
|
+
name
|
|
697
|
+
}: {
|
|
698
|
+
name: string;
|
|
699
|
+
}) => TableURN;
|
|
700
|
+
type TableColumns = Record<string, AnyColumnSchemaComponent>;
|
|
701
|
+
type TableSchemaComponent<Columns extends TableColumns = TableColumns, TableName extends string = string, Relationships extends TableRelationships<keyof Columns & string> = {} & TableRelationships<keyof Columns & string>> = SchemaComponent<TableURN, Readonly<{
|
|
702
|
+
tableName: TableName;
|
|
703
|
+
columns: ReadonlyMap<string, AnyColumnSchemaComponent> & Columns;
|
|
704
|
+
primaryKey: TableColumnNames<TableSchemaComponent<Columns, TableName, Relationships>>[];
|
|
705
|
+
relationships: Relationships;
|
|
706
|
+
indexes: ReadonlyMap<string, IndexSchemaComponent>;
|
|
707
|
+
addColumn: (column: AnyColumnSchemaComponent) => AnyColumnSchemaComponent;
|
|
708
|
+
addIndex: (index: IndexSchemaComponent) => IndexSchemaComponent;
|
|
709
|
+
}>>;
|
|
710
|
+
type InferTableSchemaComponentTypes<T extends AnyTableSchemaComponent> = T extends TableSchemaComponent<infer Columns, infer TableName, infer Relationships> ? [Columns, TableName, Relationships] : never;
|
|
711
|
+
type InferTableSchemaComponentColumns<T extends AnyTableSchemaComponent> = InferTableSchemaComponentTypes<T>[0];
|
|
712
|
+
type AnyTableSchemaComponent = TableSchemaComponent<any, any, any>;
|
|
713
|
+
declare const tableSchemaComponent: <const Columns extends TableColumns = TableColumns, const TableName extends string = string, const Relationships extends TableRelationships<keyof Columns & string> = {}>({
|
|
714
|
+
tableName,
|
|
715
|
+
columns,
|
|
716
|
+
primaryKey,
|
|
717
|
+
relationships,
|
|
718
|
+
...migrationsOrComponents
|
|
719
|
+
}: {
|
|
720
|
+
tableName: TableName;
|
|
721
|
+
columns?: Columns;
|
|
722
|
+
primaryKey?: TableColumnNames<TableSchemaComponent<Columns, TableName, Relationships>>[];
|
|
723
|
+
relationships?: Relationships;
|
|
724
|
+
} & SchemaComponentOptions) => TableSchemaComponent<Columns, TableName, Relationships> & {
|
|
725
|
+
relationships: Relationships;
|
|
726
|
+
};
|
|
727
|
+
//#endregion
|
|
728
|
+
//#region src/core/schema/components/databaseSchemaSchemaComponent.d.ts
|
|
729
|
+
type DatabaseSchemaURNType = 'sc:dumbo:database_schema';
|
|
730
|
+
type DatabaseSchemaURN<SchemaName extends string = string> = `${DatabaseSchemaURNType}:${SchemaName}`;
|
|
731
|
+
declare const DatabaseSchemaURNType: DatabaseSchemaURNType;
|
|
732
|
+
declare const DatabaseSchemaURN: <SchemaName extends string = string>({
|
|
733
|
+
name
|
|
734
|
+
}: {
|
|
735
|
+
name: SchemaName;
|
|
736
|
+
}) => DatabaseSchemaURN<SchemaName>;
|
|
737
|
+
type DatabaseSchemaTables<Tables extends AnyTableSchemaComponent = AnyTableSchemaComponent> = Record<string, Tables>;
|
|
738
|
+
type DatabaseSchemaSchemaComponent<Tables extends DatabaseSchemaTables = DatabaseSchemaTables, SchemaName extends string = string> = SchemaComponent<DatabaseSchemaURN<SchemaName>, Readonly<{
|
|
739
|
+
schemaName: SchemaName;
|
|
740
|
+
tables: ReadonlyMap<string, TableSchemaComponent> & Tables;
|
|
741
|
+
addTable: (table: string | TableSchemaComponent) => TableSchemaComponent;
|
|
742
|
+
}>>;
|
|
743
|
+
type AnyDatabaseSchemaSchemaComponent = DatabaseSchemaSchemaComponent<any, any>;
|
|
744
|
+
declare const databaseSchemaSchemaComponent: <const Tables extends DatabaseSchemaTables = DatabaseSchemaTables, const SchemaName extends string = string>({
|
|
745
|
+
schemaName,
|
|
746
|
+
tables,
|
|
747
|
+
...migrationsOrComponents
|
|
748
|
+
}: {
|
|
749
|
+
schemaName: SchemaName;
|
|
750
|
+
tables?: Tables;
|
|
751
|
+
} & SchemaComponentOptions) => DatabaseSchemaSchemaComponent<Tables, SchemaName>;
|
|
752
|
+
//#endregion
|
|
753
|
+
//#region src/core/schema/components/databaseSchemaComponent.d.ts
|
|
754
|
+
type DatabaseURNType = 'sc:dumbo:database';
|
|
755
|
+
type DatabaseURN = `${DatabaseURNType}:${string}`;
|
|
756
|
+
declare const DatabaseURNType: DatabaseURNType;
|
|
757
|
+
declare const DatabaseURN: ({
|
|
758
|
+
name
|
|
759
|
+
}: {
|
|
760
|
+
name: string;
|
|
761
|
+
}) => DatabaseURN;
|
|
762
|
+
type DatabaseSchemas<Schemas extends AnyDatabaseSchemaSchemaComponent = AnyDatabaseSchemaSchemaComponent> = Record<string, Schemas>;
|
|
763
|
+
type DatabaseSchemaComponent<Schemas extends DatabaseSchemas = DatabaseSchemas> = SchemaComponent<DatabaseURN, Readonly<{
|
|
764
|
+
databaseName: string;
|
|
765
|
+
schemas: ReadonlyMap<string, DatabaseSchemaSchemaComponent> & Schemas;
|
|
766
|
+
addSchema: (schema: string | DatabaseSchemaSchemaComponent) => DatabaseSchemaSchemaComponent;
|
|
767
|
+
}>>;
|
|
768
|
+
type AnyDatabaseSchemaComponent = DatabaseSchemaComponent<any>;
|
|
769
|
+
declare const databaseSchemaComponent: <Schemas extends DatabaseSchemas = DatabaseSchemas>({
|
|
770
|
+
databaseName,
|
|
771
|
+
schemas,
|
|
772
|
+
...migrationsOrComponents
|
|
773
|
+
}: {
|
|
774
|
+
databaseName: string;
|
|
775
|
+
schemas?: Schemas;
|
|
776
|
+
} & SchemaComponentOptions) => DatabaseSchemaComponent<Schemas>;
|
|
777
|
+
//#endregion
|
|
778
|
+
//#region src/core/schema/components/relationships/formatRelationshipErrors.d.ts
|
|
779
|
+
type Join<T extends readonly string[], Sep extends string> = T extends readonly [infer First extends string, ...infer Rest extends readonly string[]] ? Rest extends readonly [] ? First : `${First}${Sep}${Join<Rest, Sep>}` : '';
|
|
780
|
+
type IndentErrors<Messages extends readonly string[]> = Messages extends readonly [infer First extends string, ...infer Rest extends readonly string[]] ? [` - ${First}`, ...IndentErrors<Rest>] : [];
|
|
781
|
+
type ExtractSchemaFromReference<T extends string> = T extends `${infer Schema}.${string}.${string}` ? Schema : never;
|
|
782
|
+
type ExtractTableFromReference<T extends string> = T extends `${string}.${infer Table}.${string}` ? Table : never;
|
|
783
|
+
type ExtractColumnFromReference<T extends string> = T extends `${string}.${string}.${infer Column}` ? Column : never;
|
|
784
|
+
type TupleLength<T extends readonly unknown[]> = T extends {
|
|
785
|
+
length: infer L;
|
|
786
|
+
} ? L : never;
|
|
787
|
+
type FormatSingleError<E> = E extends {
|
|
788
|
+
errorCode: 'reference_columns_mismatch';
|
|
789
|
+
invalidColumns: infer InvalidCols extends readonly string[];
|
|
790
|
+
availableColumns: infer AvailableCols extends readonly string[];
|
|
791
|
+
} ? `Invalid columns: ${Join<InvalidCols, ', '>}. Available columns: ${Join<AvailableCols, ', '>}` : E extends {
|
|
792
|
+
errorCode: 'reference_length_mismatch';
|
|
793
|
+
columns: infer Cols extends readonly string[];
|
|
794
|
+
references: infer Refs extends readonly string[];
|
|
795
|
+
} ? `Column count mismatch: ${TupleLength<Cols>} columns ([${Join<Cols, ', '>}]) but ${TupleLength<Refs>} references ([${Join<Refs, ', '>}])` : E extends {
|
|
796
|
+
errorCode: 'missing_schema';
|
|
797
|
+
reference: infer Ref extends string;
|
|
798
|
+
} ? `Schema "${ExtractSchemaFromReference<Ref>}" does not exist (${Ref})` : E extends {
|
|
799
|
+
errorCode: 'missing_table';
|
|
800
|
+
reference: infer Ref extends string;
|
|
801
|
+
} ? `Table "${ExtractTableFromReference<Ref>}" does not exist in schema "${ExtractSchemaFromReference<Ref>}" (${Ref})` : E extends {
|
|
802
|
+
errorCode: 'missing_column';
|
|
803
|
+
reference: infer Ref extends string;
|
|
804
|
+
} ? `Column "${ExtractColumnFromReference<Ref>}" does not exist in table "${ExtractSchemaFromReference<Ref>}.${ExtractTableFromReference<Ref>}" (${Ref})` : E extends {
|
|
805
|
+
errorCode: 'type_mismatch';
|
|
806
|
+
reference: infer Ref extends string;
|
|
807
|
+
referenceType: infer RefType extends string;
|
|
808
|
+
columnTypeName: infer ColType extends string;
|
|
809
|
+
} ? `Type mismatch: column type "${ColType}" does not match referenced column type "${RefType}" (${Ref})` : never;
|
|
810
|
+
type FormatErrorMessages<Errors extends readonly unknown[]> = Errors extends readonly [infer First, ...infer Rest extends readonly unknown[]] ? [FormatSingleError<First>, ...FormatErrorMessages<Rest>] : [];
|
|
811
|
+
type FormatRelationshipBlock<E> = E extends {
|
|
812
|
+
relationship: infer RelName extends string;
|
|
813
|
+
errors: infer Errors extends readonly unknown[];
|
|
814
|
+
} ? Join<[`Relationship "${RelName}":`, ...IndentErrors<FormatErrorMessages<Errors>>], '\n'> : never;
|
|
815
|
+
type IndentLine<Line extends string> = ` ${Line}`;
|
|
816
|
+
type IndentRelationshipBlock<Block extends string> = Block extends `${infer FirstLine}\n${infer Rest}` ? `${IndentLine<FirstLine>}\n${IndentRelationshipBlock<Rest>}` : IndentLine<Block>;
|
|
817
|
+
type FormatRelationshipBlocks<RelErrors extends readonly unknown[]> = RelErrors extends readonly [infer First, ...infer Rest extends readonly unknown[]] ? Rest extends readonly [] ? IndentRelationshipBlock<FormatRelationshipBlock<First>> : `${IndentRelationshipBlock<FormatRelationshipBlock<First>>}\n${FormatRelationshipBlocks<Rest>}` : '';
|
|
818
|
+
type FormatTableLevel<E> = E extends {
|
|
819
|
+
table: infer TableName extends string;
|
|
820
|
+
errors: infer RelErrors extends readonly unknown[];
|
|
821
|
+
} ? `Table "${TableName}":\n${FormatRelationshipBlocks<RelErrors>}` : never;
|
|
822
|
+
type IndentTableBlock<Block extends string> = Block extends `${infer FirstLine}\n${infer Rest}` ? ` ${FirstLine}\n${IndentTableBlock<Rest>}` : ` ${Block}`;
|
|
823
|
+
type FormatTableBlocks<TableErrors extends readonly unknown[]> = TableErrors extends readonly [infer First, ...infer Rest extends readonly unknown[]] ? Rest extends readonly [] ? IndentTableBlock<FormatTableLevel<First>> : `${IndentTableBlock<FormatTableLevel<First>>}\n${FormatTableBlocks<Rest>}` : '';
|
|
824
|
+
type FormatSchemaLevel<E> = E extends {
|
|
825
|
+
schema: infer SchemaName extends string;
|
|
826
|
+
errors: infer TableErrors extends readonly unknown[];
|
|
827
|
+
} ? `Schema "${SchemaName}":\n${FormatTableBlocks<TableErrors>}` : never;
|
|
828
|
+
type FormatSchemaBlocks<SchemaErrors extends readonly unknown[]> = SchemaErrors extends readonly [infer First, ...infer Rest extends readonly unknown[]] ? Rest extends readonly [] ? FormatSchemaLevel<First> : `${FormatSchemaLevel<First>}\n${FormatSchemaBlocks<Rest>}` : '';
|
|
829
|
+
type FormatDatabaseValidationErrors<Errors extends readonly unknown[]> = FormatSchemaBlocks<Errors>;
|
|
830
|
+
type FormatValidationErrors<Result> = Result extends {
|
|
831
|
+
valid: false;
|
|
832
|
+
error: infer Errors extends readonly unknown[];
|
|
833
|
+
} ? `Relationship validation errors:\n\n${FormatDatabaseValidationErrors<Errors>}` : never;
|
|
834
|
+
//#endregion
|
|
835
|
+
//#region src/core/schema/components/relationships/relationshipValidation.d.ts
|
|
836
|
+
type RelationshipColumnsMismatchError<ColumnPath extends SchemaColumnName = SchemaColumnName> = {
|
|
837
|
+
valid: false;
|
|
838
|
+
error: {
|
|
839
|
+
errorCode: 'reference_columns_mismatch';
|
|
840
|
+
invalidColumns: ColumnPath[];
|
|
841
|
+
availableColumns: ColumnPath[];
|
|
842
|
+
};
|
|
843
|
+
};
|
|
844
|
+
type RelationshipReferencesLengthMismatchError<ColumnPath extends SchemaColumnName = SchemaColumnName> = {
|
|
845
|
+
valid: false;
|
|
846
|
+
error: {
|
|
847
|
+
errorCode: 'reference_length_mismatch';
|
|
848
|
+
columns: ColumnPath[];
|
|
849
|
+
references: ColumnPath[];
|
|
850
|
+
};
|
|
851
|
+
};
|
|
852
|
+
type ColumnReferenceExistanceError<ErrorCode extends 'missing_schema' | 'missing_table' | 'missing_column' = 'missing_schema' | 'missing_table' | 'missing_column', ColumnPath extends SchemaColumnName = SchemaColumnName> = {
|
|
853
|
+
valid: false;
|
|
854
|
+
error: {
|
|
855
|
+
errorCode: ErrorCode;
|
|
856
|
+
reference: ColumnPath;
|
|
857
|
+
};
|
|
858
|
+
};
|
|
859
|
+
type ColumnReferenceTypeMismatchError<Reference extends SchemaColumnName = SchemaColumnName, ReferenceTypeName extends string = string, ColumnTypeName extends string = string> = {
|
|
860
|
+
valid: false;
|
|
861
|
+
error: {
|
|
862
|
+
errorCode: 'type_mismatch';
|
|
863
|
+
reference: Reference;
|
|
864
|
+
referenceType: ReferenceTypeName;
|
|
865
|
+
columnTypeName: ColumnTypeName;
|
|
866
|
+
};
|
|
867
|
+
};
|
|
868
|
+
type NoError = TypeValidationSuccess;
|
|
869
|
+
type ColumnReferenceError = ColumnReferenceExistanceError | ColumnReferenceTypeMismatchError;
|
|
870
|
+
type RelationshipValidationError = RelationshipColumnsMismatchError | RelationshipReferencesLengthMismatchError | ColumnReferenceError;
|
|
871
|
+
type ValidateRelationshipLength<Rel extends AnyTableRelationshipDefinition> = IF<ALL<[HaveTuplesTheSameLength<Rel['columns'], Rel['references']>, IsNotEmptyTuple<Rel['columns']>, IsNotEmptyTuple<Rel['references']>]>, TypeValidationSuccess, TypeValidationResult<false, {
|
|
872
|
+
errorCode: 'reference_length_mismatch';
|
|
873
|
+
columns: Rel['columns'];
|
|
874
|
+
references: Rel['references'];
|
|
875
|
+
}>>;
|
|
876
|
+
type ValidateRelationshipColumns<Relationship extends AnyTableRelationshipDefinition, ValidColumns extends TableColumns> = FilterNotExistingInUnion<Relationship['columns'], KeysOfString<ValidColumns>> extends infer InvalidColumns extends NotEmptyTuple<string[]> ? IF<AND<IsEmptyTuple<InvalidColumns>, IsNotEmptyTuple<Relationship['columns']>>, TypeValidationSuccess, TypeValidationResult<false, {
|
|
877
|
+
errorCode: 'reference_columns_mismatch';
|
|
878
|
+
invalidColumns: InvalidColumns;
|
|
879
|
+
availableColumns: KeysOfString<ValidColumns>;
|
|
880
|
+
}>> : TypeValidationSuccess;
|
|
881
|
+
type ValidateColumnReference<ColReference extends SchemaColumnName, Schemas extends DatabaseSchemas> = ColReference extends SchemaColumnName<infer SchemaName, infer TableName, infer ColumnName> ? SchemaName extends keyof Schemas ? TableName extends keyof Schemas[SchemaName]['tables'] ? Schemas[SchemaName]['tables'][TableName] extends TableSchemaComponent<infer Columns, infer _TableName, infer _Relationships> ? ColumnName extends keyof Columns ? Columns[ColumnName] : ColumnReferenceExistanceError<'missing_column', `${SchemaName}.${TableName}.${ColumnName}`> : never : ColumnReferenceExistanceError<'missing_table', `${SchemaName}.${TableName}.${ColumnName}`> : ColumnReferenceExistanceError<'missing_schema', `${SchemaName}.${TableName}.${ColumnName}`> : never;
|
|
882
|
+
type ValidateColumnTypeMatch<RefColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string, ColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string, Reference extends SchemaColumnName = SchemaColumnName> = ColumnType extends ColumnTypeToken<infer _JsType, infer ColumnTypeName, infer _TProps> ? RefColumnType extends ColumnTypeToken<infer _JsType, infer RefColumnTypeName, infer _TProps> ? RefColumnTypeName extends ColumnTypeName ? TypeValidationSuccess : ColumnReferenceTypeMismatchError<Reference, RefColumnTypeName, ColumnTypeName> : RefColumnType extends ColumnTypeName ? TypeValidationSuccess : ColumnReferenceTypeMismatchError<Reference, Extract<RefColumnType, string>, ColumnTypeName> : RefColumnType extends ColumnTypeToken<infer _JsType, infer RefColumnTypeName, infer _TProps> ? RefColumnTypeName extends ColumnType ? TypeValidationSuccess : ColumnReferenceTypeMismatchError<Reference, RefColumnTypeName, Extract<ColumnType, string>> : RefColumnType extends ColumnType ? TypeValidationSuccess : ColumnReferenceTypeMismatchError<Reference, Extract<RefColumnType, string>, Extract<ColumnType, string>>;
|
|
883
|
+
type ValidateColumnsMatch<ReferenceColumn extends AnyColumnSchemaComponent, Column extends AnyColumnSchemaComponent, references extends SchemaColumnName = SchemaColumnName> = Column extends ColumnSchemaComponent<infer ColumnType> ? ReferenceColumn extends ColumnSchemaComponent<infer RefColumnType> ? ValidateColumnTypeMatch<RefColumnType, ColumnType, references> : never : never;
|
|
884
|
+
type ValidateReference<RefPath extends SchemaColumnName = SchemaColumnName, ColPath extends SchemaColumnName = SchemaColumnName, Schemas extends DatabaseSchemas = DatabaseSchemas> = ColPath extends SchemaColumnName<infer SchemaName, infer TableName, infer Column> ? ValidateColumnReference<RefPath, Schemas> extends infer RefColumn ? RefColumn extends AnyColumnSchemaComponent ? ValidateColumnsMatch<RefColumn, Schemas[SchemaName]['tables'][TableName]['columns'][Column], RefPath> : RefColumn extends {
|
|
885
|
+
valid: false;
|
|
886
|
+
error: infer E;
|
|
887
|
+
} ? TypeValidationError<E> : never : never : never;
|
|
888
|
+
type ValidateReferences<RefPath extends SchemaColumnName = SchemaColumnName, ColPath extends SchemaColumnName = SchemaColumnName, Schemas extends DatabaseSchemas = DatabaseSchemas> = ColPath extends SchemaColumnName<infer SchemaName, infer TableName, infer Column> ? ValidateColumnReference<RefPath, Schemas> extends infer RefColumn ? RefColumn extends AnyColumnSchemaComponent ? ValidateColumnsMatch<RefColumn, Schemas[SchemaName]['tables'][TableName]['columns'][Column], RefPath> : RefColumn extends {
|
|
889
|
+
valid: false;
|
|
890
|
+
error: infer E;
|
|
891
|
+
} ? TypeValidationError<E> : never : never : never;
|
|
892
|
+
type CollectReferencesErrors<Columns extends readonly SchemaColumnName[], References extends readonly SchemaColumnName[], _CurrentSchema extends string, _CurrentTable extends string, Schemas extends DatabaseSchemas = DatabaseSchemas, Errors extends AnyTypeValidationError[] = []> = ZipTuplesCollectErrors<References, Columns, { [R in References[number]]: { [C in Columns[number]]: ValidateReference<R, C, Schemas> } }, Errors>;
|
|
893
|
+
type SchemaTablesWithSingle<Table extends AnyTableSchemaComponent> = Table extends TableSchemaComponent<infer _Columns, infer TableName, infer _FKs> ? DatabaseSchemaSchemaComponent<{ [K in TableName]: Table }> : never;
|
|
894
|
+
type DatabaseSchemasWithSingle<Schema extends AnyDatabaseSchemaSchemaComponent> = Schema extends DatabaseSchemaSchemaComponent<infer _Tables, infer _SchemaName> ? { [K in _SchemaName]: Schema } : never;
|
|
895
|
+
type ValidateRelationship<Columns extends TableColumns, Relationship extends AnyTableRelationshipDefinitionWithColumns<Extract<keyof Columns, string>>, RelationshipName extends string, CurrentTableName extends string, Table extends AnyTableSchemaComponent = AnyTableSchemaComponent, Schema extends AnyDatabaseSchemaSchemaComponent = SchemaTablesWithSingle<Table>, Schemas extends DatabaseSchemas = DatabaseSchemasWithSingle<Schema>> = FailOnFirstTypeValidationError<[ValidateRelationshipLength<Relationship>, ValidateRelationshipColumns<Relationship, Columns>, CollectReferencesErrors<NormalizeColumnPath<Relationship['columns'], Schema['schemaName'], CurrentTableName>, NormalizeColumnPath<Relationship['references'], Schema['schemaName'], CurrentTableName>, Schema['schemaName'], CurrentTableName, Schemas> extends infer Results extends readonly AnyTypeValidationError[] ? IF<AnyTypeValidationFailed<Results>, TypeValidationError<UnwrapTypeValidationErrors<Results>>, TypeValidationSuccess> : TypeValidationSuccess]> extends infer Error extends AnyTypeValidationError ? TypeValidationError<{
|
|
896
|
+
relationship: RelationshipName;
|
|
897
|
+
errors: Error extends TypeValidationError<infer E> ? E extends readonly unknown[] ? E : [E] : never;
|
|
898
|
+
}> : TypeValidationSuccess;
|
|
899
|
+
type CollectRelationshipErrors<Columns extends TableColumns = TableColumns, Relationships extends TableRelationships<keyof Columns & string> = {} & TableRelationships<keyof Columns & string>, Table extends AnyTableSchemaComponent = AnyTableSchemaComponent, Schema extends AnyDatabaseSchemaSchemaComponent = SchemaTablesWithSingle<Table>, Schemas extends DatabaseSchemas = DatabaseSchemasWithSingle<Schema>, Errors extends AnyTypeValidationError[] = []> = MapRecordCollectErrors<Relationships, { [R in keyof Relationships]: ValidateRelationship<Columns, Relationships[R] extends AnyTableRelationshipDefinitionWithColumns<Extract<keyof Columns, string>> ? Relationships[R] : never, Extract<R, string>, Table['tableName'], Table, Schema, Schemas> }, Errors>;
|
|
900
|
+
type ValidateTableRelationships<Table extends AnyTableSchemaComponent, Schema extends AnyDatabaseSchemaSchemaComponent = SchemaTablesWithSingle<Table>, Schemas extends DatabaseSchemas = DatabaseSchemasWithSingle<Schema>> = Table extends TableSchemaComponent<infer Columns, infer TableName, infer Relationships> ? keyof Relationships extends Extract<keyof Relationships, string> ? CollectRelationshipErrors<Columns, Relationships, Table, Schema, Schemas> extends infer Results ? AnyTypeValidationFailed<Results> extends true ? TypeValidationError<{
|
|
901
|
+
table: TableName;
|
|
902
|
+
errors: UnwrapTypeValidationErrors<Results extends readonly AnyTypeValidationError[] ? Results : never>;
|
|
903
|
+
}> : Results : TypeValidationSuccess : TypeValidationSuccess : TypeValidationSuccess;
|
|
904
|
+
type ValidateTable<Table extends AnyTableSchemaComponent, Schema extends AnyDatabaseSchemaSchemaComponent = SchemaTablesWithSingle<Table>, Schemas extends DatabaseSchemas = DatabaseSchemasWithSingle<Schema>> = ValidateTableRelationships<Table, Schema, Schemas>;
|
|
905
|
+
type ValidateSchemaTables<Tables extends Record<string, AnyTableSchemaComponent>, SchemaName extends string, Schema extends AnyDatabaseSchemaSchemaComponent, Schemas extends DatabaseSchemas = DatabaseSchemasWithSingle<Schema>> = MapRecordCollectErrors<Tables, { [TableName in keyof Tables]: ValidateTable<Tables[TableName], Schema, Schemas> }> extends infer Results ? AnyTypeValidationFailed<Results> extends true ? TypeValidationError<{
|
|
906
|
+
schema: SchemaName;
|
|
907
|
+
errors: UnwrapTypeValidationErrors<Results extends readonly AnyTypeValidationError[] ? Results : never>;
|
|
908
|
+
}> : TypeValidationSuccess : TypeValidationSuccess;
|
|
909
|
+
type ValidateDatabaseSchema<Schema extends AnyDatabaseSchemaSchemaComponent, Schemas extends DatabaseSchemas = DatabaseSchemasWithSingle<Schema>> = Schema extends DatabaseSchemaSchemaComponent<infer Tables, infer SchemaName> ? ValidateSchemaTables<Tables, SchemaName, Schema, Schemas> : TypeValidationSuccess;
|
|
910
|
+
type ValidateDatabaseSchemas<Schemas extends DatabaseSchemas> = MapRecordCollectErrors<Schemas, { [SchemaName in keyof Schemas]: ValidateDatabaseSchema<Schemas[SchemaName], Schemas> }> extends infer Results ? AnyTypeValidationFailed<Results> extends true ? TypeValidationError<UnwrapTypeValidationErrors<Results extends readonly AnyTypeValidationError[] ? Results : never>> : TypeValidationSuccess : TypeValidationSuccess;
|
|
911
|
+
type ValidateDatabaseSchemasWithMessages<Schemas extends DatabaseSchemas> = FormatValidationErrors<ValidateDatabaseSchemas<Schemas>>;
|
|
912
|
+
//#endregion
|
|
913
|
+
//#region src/core/schema/components/index.d.ts
|
|
914
|
+
declare const schemaComponentURN: {
|
|
915
|
+
readonly database: ({
|
|
916
|
+
name
|
|
917
|
+
}: {
|
|
918
|
+
name: string;
|
|
919
|
+
}) => DatabaseURN;
|
|
920
|
+
readonly schema: <SchemaName extends string = string>({
|
|
921
|
+
name
|
|
922
|
+
}: {
|
|
923
|
+
name: SchemaName;
|
|
924
|
+
}) => DatabaseSchemaURN<SchemaName>;
|
|
925
|
+
readonly table: ({
|
|
926
|
+
name
|
|
927
|
+
}: {
|
|
928
|
+
name: string;
|
|
929
|
+
}) => TableURN;
|
|
930
|
+
readonly column: <ColumnName extends string = string>({
|
|
931
|
+
name
|
|
932
|
+
}: {
|
|
933
|
+
name: ColumnName;
|
|
934
|
+
}) => ColumnURN<ColumnName>;
|
|
935
|
+
readonly index: ({
|
|
936
|
+
name
|
|
937
|
+
}: {
|
|
938
|
+
name: string;
|
|
939
|
+
}) => IndexURN;
|
|
940
|
+
readonly extractName: (urn: string) => string;
|
|
941
|
+
};
|
|
942
|
+
//#endregion
|
|
943
|
+
//#region src/core/errors/index.d.ts
|
|
944
|
+
declare class DumboError extends Error {
|
|
945
|
+
static readonly ErrorCode: number;
|
|
946
|
+
static readonly ErrorType: string;
|
|
947
|
+
errorCode: number;
|
|
948
|
+
errorType: string;
|
|
949
|
+
innerError: Error | undefined;
|
|
950
|
+
constructor(options?: {
|
|
951
|
+
errorCode: number;
|
|
952
|
+
errorType?: string;
|
|
953
|
+
message?: string | undefined;
|
|
954
|
+
innerError?: Error | undefined;
|
|
955
|
+
} | string | number);
|
|
956
|
+
static isInstanceOf<ErrorType extends DumboError = DumboError>(error: unknown, options?: {
|
|
957
|
+
errorCode?: number;
|
|
958
|
+
errorType?: string;
|
|
959
|
+
}): error is ErrorType;
|
|
960
|
+
}
|
|
961
|
+
declare class ConcurrencyError extends DumboError {
|
|
962
|
+
static readonly ErrorCode: number;
|
|
963
|
+
static readonly ErrorType: string;
|
|
964
|
+
constructor(message?: string, innerError?: Error);
|
|
965
|
+
}
|
|
966
|
+
declare class TransientDatabaseError extends DumboError {
|
|
967
|
+
static readonly ErrorCode: number;
|
|
968
|
+
static readonly ErrorType: string;
|
|
969
|
+
constructor(message?: string, innerError?: Error);
|
|
970
|
+
}
|
|
971
|
+
declare class ConnectionError extends TransientDatabaseError {
|
|
972
|
+
static readonly ErrorCode: number;
|
|
973
|
+
static readonly ErrorType: string;
|
|
974
|
+
constructor(message?: string, innerError?: Error);
|
|
975
|
+
}
|
|
976
|
+
declare class SerializationError extends TransientDatabaseError {
|
|
977
|
+
static readonly ErrorCode: number;
|
|
978
|
+
static readonly ErrorType: string;
|
|
979
|
+
constructor(message?: string, innerError?: Error);
|
|
980
|
+
}
|
|
981
|
+
declare class DeadlockError extends TransientDatabaseError {
|
|
982
|
+
static readonly ErrorCode: number;
|
|
983
|
+
static readonly ErrorType: string;
|
|
984
|
+
constructor(message?: string, innerError?: Error);
|
|
985
|
+
}
|
|
986
|
+
declare class LockNotAvailableError extends TransientDatabaseError {
|
|
987
|
+
static readonly ErrorCode: number;
|
|
988
|
+
static readonly ErrorType: string;
|
|
989
|
+
constructor(message?: string, innerError?: Error);
|
|
990
|
+
}
|
|
991
|
+
declare class InsufficientResourcesError extends TransientDatabaseError {
|
|
992
|
+
static readonly ErrorCode: number;
|
|
993
|
+
static readonly ErrorType: string;
|
|
994
|
+
constructor(message?: string, innerError?: Error);
|
|
995
|
+
}
|
|
996
|
+
declare class SystemError extends TransientDatabaseError {
|
|
997
|
+
static readonly ErrorCode: number;
|
|
998
|
+
static readonly ErrorType: string;
|
|
999
|
+
constructor(message?: string, innerError?: Error);
|
|
1000
|
+
}
|
|
1001
|
+
declare class AdminShutdownError extends TransientDatabaseError {
|
|
1002
|
+
static readonly ErrorCode: number;
|
|
1003
|
+
static readonly ErrorType: string;
|
|
1004
|
+
constructor(message?: string, innerError?: Error);
|
|
1005
|
+
}
|
|
1006
|
+
declare class QueryCanceledError extends TransientDatabaseError {
|
|
1007
|
+
static readonly ErrorCode: number;
|
|
1008
|
+
static readonly ErrorType: string;
|
|
1009
|
+
constructor(message?: string, innerError?: Error);
|
|
1010
|
+
}
|
|
1011
|
+
declare class IntegrityConstraintViolationError extends DumboError {
|
|
1012
|
+
static readonly ErrorCode: number;
|
|
1013
|
+
static readonly ErrorType: string;
|
|
1014
|
+
constructor(message?: string, innerError?: Error);
|
|
1015
|
+
}
|
|
1016
|
+
declare class UniqueConstraintError extends IntegrityConstraintViolationError {
|
|
1017
|
+
static readonly ErrorCode: number;
|
|
1018
|
+
static readonly ErrorType: string;
|
|
1019
|
+
constructor(message?: string, innerError?: Error);
|
|
1020
|
+
}
|
|
1021
|
+
declare class ForeignKeyViolationError extends IntegrityConstraintViolationError {
|
|
1022
|
+
static readonly ErrorCode: number;
|
|
1023
|
+
static readonly ErrorType: string;
|
|
1024
|
+
constructor(message?: string, innerError?: Error);
|
|
1025
|
+
}
|
|
1026
|
+
declare class NotNullViolationError extends IntegrityConstraintViolationError {
|
|
1027
|
+
static readonly ErrorCode: number;
|
|
1028
|
+
static readonly ErrorType: string;
|
|
1029
|
+
constructor(message?: string, innerError?: Error);
|
|
1030
|
+
}
|
|
1031
|
+
declare class CheckViolationError extends IntegrityConstraintViolationError {
|
|
1032
|
+
static readonly ErrorCode: number;
|
|
1033
|
+
static readonly ErrorType: string;
|
|
1034
|
+
constructor(message?: string, innerError?: Error);
|
|
1035
|
+
}
|
|
1036
|
+
declare class ExclusionViolationError extends IntegrityConstraintViolationError {
|
|
1037
|
+
static readonly ErrorCode: number;
|
|
1038
|
+
static readonly ErrorType: string;
|
|
1039
|
+
constructor(message?: string, innerError?: Error);
|
|
1040
|
+
}
|
|
1041
|
+
declare class DataError extends DumboError {
|
|
1042
|
+
static readonly ErrorCode: number;
|
|
1043
|
+
static readonly ErrorType: string;
|
|
1044
|
+
constructor(message?: string, innerError?: Error);
|
|
1045
|
+
}
|
|
1046
|
+
declare class InvalidOperationError extends DumboError {
|
|
1047
|
+
static readonly ErrorCode: number;
|
|
1048
|
+
static readonly ErrorType: string;
|
|
1049
|
+
constructor(message?: string, innerError?: Error);
|
|
1050
|
+
}
|
|
1051
|
+
//#endregion
|
|
1052
|
+
//#region src/core/query/query.d.ts
|
|
1053
|
+
interface QueryResultRow {
|
|
1054
|
+
[column: string]: any;
|
|
1055
|
+
}
|
|
1056
|
+
type QueryResult<Result extends QueryResultRow = QueryResultRow> = {
|
|
1057
|
+
rowCount: number | null;
|
|
1058
|
+
rows: Result[];
|
|
1059
|
+
};
|
|
1060
|
+
//#endregion
|
|
1061
|
+
//#region src/core/execute/execute.d.ts
|
|
1062
|
+
declare const mapColumnToJSON: (column: string, serializer: JSONSerializer, options?: JSONDeserializeOptions) => {
|
|
1063
|
+
[x: string]: (value: unknown) => unknown;
|
|
1064
|
+
};
|
|
1065
|
+
declare const mapColumnToBigint: (column: string) => {
|
|
1066
|
+
[x: string]: (value: unknown) => unknown;
|
|
1067
|
+
};
|
|
1068
|
+
declare const mapColumnToDate: (column: string) => {
|
|
1069
|
+
[x: string]: (value: unknown) => unknown;
|
|
1070
|
+
};
|
|
1071
|
+
declare const mapSQLQueryResult: <T>(result: T, mapping: SQLQueryResultColumnMapping) => T;
|
|
1072
|
+
type SQLQueryResultColumnMapping = {
|
|
1073
|
+
[column: string]: (value: unknown) => unknown;
|
|
1074
|
+
};
|
|
1075
|
+
type SQLQueryOptions = {
|
|
1076
|
+
timeoutMs?: number | undefined;
|
|
1077
|
+
mapping?: SQLQueryResultColumnMapping;
|
|
1078
|
+
};
|
|
1079
|
+
type SQLCommandOptions = {
|
|
1080
|
+
timeoutMs?: number | undefined;
|
|
1081
|
+
mapping?: SQLQueryResultColumnMapping;
|
|
1082
|
+
};
|
|
1083
|
+
type BatchSQLCommandOptions = SQLCommandOptions & {
|
|
1084
|
+
assertChanges?: boolean;
|
|
1085
|
+
};
|
|
1086
|
+
declare class BatchCommandNoChangesError extends DumboError {
|
|
1087
|
+
static readonly ErrorCode: number;
|
|
1088
|
+
static readonly ErrorType: string;
|
|
1089
|
+
readonly statementIndex: number;
|
|
1090
|
+
constructor(statementIndex: number);
|
|
1091
|
+
}
|
|
1092
|
+
type DbSQLExecutorOptions = {
|
|
1093
|
+
serializer: JSONSerializer;
|
|
1094
|
+
};
|
|
1095
|
+
interface DbSQLExecutor<DriverType extends DatabaseDriverType = DatabaseDriverType, DbClient = unknown> {
|
|
1096
|
+
driverType: DriverType;
|
|
1097
|
+
query<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sql: SQL, options?: SQLQueryOptions): Promise<QueryResult<Result>>;
|
|
1098
|
+
batchQuery<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sqls: SQL[], options?: SQLQueryOptions): Promise<QueryResult<Result>[]>;
|
|
1099
|
+
command<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sql: SQL, options?: SQLCommandOptions): Promise<QueryResult<Result>>;
|
|
1100
|
+
batchCommand<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sqls: SQL[], options?: BatchSQLCommandOptions): Promise<QueryResult<Result>[]>;
|
|
1101
|
+
formatter: SQLFormatter;
|
|
1102
|
+
}
|
|
1103
|
+
interface SQLExecutor {
|
|
1104
|
+
query<Result extends QueryResultRow = QueryResultRow>(sql: SQL, options?: SQLQueryOptions): Promise<QueryResult<Result>>;
|
|
1105
|
+
batchQuery<Result extends QueryResultRow = QueryResultRow>(sqls: SQL[], options?: SQLQueryOptions): Promise<QueryResult<Result>[]>;
|
|
1106
|
+
command<Result extends QueryResultRow = QueryResultRow>(sql: SQL, options?: SQLCommandOptions): Promise<QueryResult<Result>>;
|
|
1107
|
+
batchCommand<Result extends QueryResultRow = QueryResultRow>(sqls: SQL[], options?: BatchSQLCommandOptions): Promise<QueryResult<Result>[]>;
|
|
1108
|
+
}
|
|
1109
|
+
interface WithSQLExecutor {
|
|
1110
|
+
execute: SQLExecutor;
|
|
1111
|
+
}
|
|
1112
|
+
declare const sqlExecutor: <DbClient = unknown, DbExecutor extends DbSQLExecutor = DbSQLExecutor>(sqlExecutor: DbExecutor, options: {
|
|
1113
|
+
connect: () => Promise<DbClient>;
|
|
1114
|
+
close?: (client: DbClient, error?: unknown) => Promise<void>;
|
|
1115
|
+
}) => SQLExecutor;
|
|
1116
|
+
declare const sqlExecutorInNewConnection: <ConnectionType extends Connection>(options: {
|
|
1117
|
+
driverType: ConnectionType["driverType"];
|
|
1118
|
+
connection: () => Promise<ConnectionType>;
|
|
1119
|
+
}) => SQLExecutor;
|
|
1120
|
+
declare const sqlExecutorInAmbientConnection: <ConnectionType extends Connection>(options: {
|
|
1121
|
+
driverType: ConnectionType["driverType"];
|
|
1122
|
+
connection: () => Promise<ConnectionType>;
|
|
1123
|
+
}) => SQLExecutor;
|
|
1124
|
+
declare const executeInNewDbClient: <DbClient = unknown, Result = unknown>(handle: (client: DbClient) => Promise<Result>, options: {
|
|
1125
|
+
connect: () => Promise<DbClient>;
|
|
1126
|
+
close?: (client: DbClient, error?: unknown) => Promise<void>;
|
|
1127
|
+
}) => Promise<Result>;
|
|
1128
|
+
declare const executeInNewConnection: <ConnectionType extends Connection, Result>(handle: (connection: ConnectionType) => Promise<Result>, options: {
|
|
1129
|
+
connection: () => Promise<ConnectionType>;
|
|
1130
|
+
}) => Promise<Result>;
|
|
1131
|
+
declare const executeInAmbientConnection: <ConnectionType extends Connection, Result>(handle: (connection: ConnectionType) => Promise<Result>, options: {
|
|
1132
|
+
connection: () => Promise<ConnectionType>;
|
|
1133
|
+
}) => Promise<Result>;
|
|
1134
|
+
//#endregion
|
|
1135
|
+
//#region src/core/schema/databaseMetadata/databaseMetadata.d.ts
|
|
1136
|
+
interface DatabaseCapabilities<SupportsMultipleDatabases extends boolean, SupportsSchemas extends boolean, SupportsFunctions extends boolean> {
|
|
1137
|
+
readonly supportsMultipleDatabases: SupportsMultipleDatabases;
|
|
1138
|
+
readonly supportsSchemas: SupportsSchemas;
|
|
1139
|
+
readonly supportsFunctions: SupportsFunctions;
|
|
1140
|
+
}
|
|
1141
|
+
type DatabaseMetadata<SupportsMultipleDatabases extends boolean = boolean, SupportsSchemas extends boolean = boolean, SupportsFunctions extends boolean = boolean> = {
|
|
1142
|
+
readonly databaseType: DatabaseType;
|
|
1143
|
+
readonly capabilities: DatabaseCapabilities<SupportsMultipleDatabases, SupportsSchemas, SupportsFunctions>;
|
|
1144
|
+
readonly tableExists: (pool: SQLExecutor, tableName: string) => Promise<boolean>;
|
|
1145
|
+
} & (SupportsMultipleDatabases extends true ? {
|
|
1146
|
+
readonly defaultDatabaseName: string;
|
|
1147
|
+
readonly parseDatabaseName: (connectionString?: string) => string | undefined;
|
|
1148
|
+
} : {
|
|
1149
|
+
readonly defaultDatabaseName?: never;
|
|
1150
|
+
readonly parseDatabaseName?: never;
|
|
1151
|
+
}) & (SupportsFunctions extends true ? {
|
|
1152
|
+
readonly functionExists: (pool: SQLExecutor, functionName: string) => Promise<boolean>;
|
|
1153
|
+
} : {
|
|
1154
|
+
readonly functionExists?: (pool: SQLExecutor, functionName: string) => Promise<boolean>;
|
|
1155
|
+
});
|
|
1156
|
+
declare const DumboDatabaseMetadataRegistry: () => {
|
|
1157
|
+
register: (databaseType: DatabaseType, info: DatabaseMetadata | (() => Promise<DatabaseMetadata>)) => void;
|
|
1158
|
+
tryResolve: (databaseType: DatabaseType) => Promise<DatabaseMetadata | null>;
|
|
1159
|
+
tryGet: (databaseType: DatabaseType) => DatabaseMetadata | null;
|
|
1160
|
+
has: (databaseType: DatabaseType) => boolean;
|
|
1161
|
+
readonly databaseTypes: DatabaseType[];
|
|
1162
|
+
};
|
|
1163
|
+
declare global {
|
|
1164
|
+
var dumboDatabaseMetadataRegistry: ReturnType<typeof DumboDatabaseMetadataRegistry>;
|
|
1165
|
+
}
|
|
1166
|
+
declare const dumboDatabaseMetadataRegistry: {
|
|
1167
|
+
register: (databaseType: DatabaseType, info: DatabaseMetadata | (() => Promise<DatabaseMetadata>)) => void;
|
|
1168
|
+
tryResolve: (databaseType: DatabaseType) => Promise<DatabaseMetadata | null>;
|
|
1169
|
+
tryGet: (databaseType: DatabaseType) => DatabaseMetadata | null;
|
|
1170
|
+
has: (databaseType: DatabaseType) => boolean;
|
|
1171
|
+
readonly databaseTypes: DatabaseType[];
|
|
1172
|
+
};
|
|
1173
|
+
declare const getDatabaseMetadata: (driverType: DatabaseDriverType) => DatabaseMetadata | null;
|
|
1174
|
+
declare const resolveDatabaseMetadata: (driverType: DatabaseDriverType, driverOverride?: DatabaseMetadata) => Promise<DatabaseMetadata | null>;
|
|
1175
|
+
declare const getDefaultDatabase: (driverType: DatabaseDriverType) => string | undefined;
|
|
1176
|
+
declare const getDefaultDatabaseAsync: (driverType: DatabaseDriverType) => Promise<string | undefined>;
|
|
1177
|
+
//#endregion
|
|
1178
|
+
//#region src/core/schema/dumboSchema/dumboSchema.d.ts
|
|
1179
|
+
declare const DEFAULT_DATABASE_SCHEMA_NAME = "__default_database_schema__";
|
|
1180
|
+
declare function dumboDatabaseSchema<const Tables extends DatabaseSchemaTables = DatabaseSchemaTables>(tables: Tables): DatabaseSchemaSchemaComponent<Tables, typeof DEFAULT_DATABASE_SCHEMA_NAME>;
|
|
1181
|
+
declare function dumboDatabaseSchema<const Tables extends DatabaseSchemaTables = DatabaseSchemaTables, const SchemaName extends string = string>(schemaName: SchemaName, tables: Tables, options?: SchemaComponentOptions): DatabaseSchemaSchemaComponent<Tables, SchemaName>;
|
|
1182
|
+
declare namespace dumboDatabaseSchema {
|
|
1183
|
+
var from: (schemaName: string | undefined, tableNames: string[]) => DatabaseSchemaSchemaComponent;
|
|
1184
|
+
var defaultName: string;
|
|
1185
|
+
}
|
|
1186
|
+
type ValidatedDatabaseSchemaComponent<Schemas extends DatabaseSchemas = DatabaseSchemas> = ValidateDatabaseSchemas<Schemas> extends {
|
|
1187
|
+
valid: true;
|
|
1188
|
+
} ? DatabaseSchemaComponent<Schemas> : ValidateDatabaseSchemas<Schemas> extends {
|
|
1189
|
+
valid: false;
|
|
1190
|
+
error: infer E;
|
|
1191
|
+
} ? {
|
|
1192
|
+
valid: false;
|
|
1193
|
+
error: E;
|
|
1194
|
+
} : DatabaseSchemaComponent<Schemas>;
|
|
1195
|
+
declare function dumboDatabase<Schemas extends DatabaseSchemas = DatabaseSchemas>(schemas: Schemas): ValidatedDatabaseSchemaComponent<Schemas>;
|
|
1196
|
+
declare function dumboDatabase<Schemas extends DatabaseSchemas = DatabaseSchemas>(schema: DatabaseSchemaSchemaComponent): ValidatedDatabaseSchemaComponent<Schemas>;
|
|
1197
|
+
declare function dumboDatabase<Schemas extends DatabaseSchemas = DatabaseSchemas>(databaseName: string, schemas: Schemas, options?: SchemaComponentOptions): ValidatedDatabaseSchemaComponent<Schemas>;
|
|
1198
|
+
declare function dumboDatabase<Schemas extends DatabaseSchemas = DatabaseSchemas>(databaseName: string, schema: AnyDatabaseSchemaSchemaComponent, options?: SchemaComponentOptions): ValidatedDatabaseSchemaComponent<Schemas>;
|
|
1199
|
+
declare namespace dumboDatabase {
|
|
1200
|
+
var from: <Schemas extends DatabaseSchemas = DatabaseSchemas>(databaseName: string | undefined, schemaNames: string[]) => ValidatedDatabaseSchemaComponent<Schemas>;
|
|
1201
|
+
var defaultName: string;
|
|
1202
|
+
}
|
|
1203
|
+
declare const dumboSchema: {
|
|
1204
|
+
database: typeof dumboDatabase;
|
|
1205
|
+
schema: typeof dumboDatabaseSchema;
|
|
1206
|
+
table: <const Columns extends TableColumns = TableColumns, const TableName extends string = string, const Relationships extends TableRelationships<keyof Columns & string> = TableRelationships<keyof Columns & string>>(name: TableName, definition: {
|
|
1207
|
+
columns?: Columns;
|
|
1208
|
+
primaryKey?: TableColumnNames<TableSchemaComponent<Columns, TableName, Relationships>>[];
|
|
1209
|
+
relationships?: Relationships;
|
|
1210
|
+
indexes?: Record<string, IndexSchemaComponent>;
|
|
1211
|
+
} & SchemaComponentOptions) => TableSchemaComponent<Columns, TableName, Relationships>;
|
|
1212
|
+
column: <const ColumnType extends AnyColumnTypeToken | string = string | AnyColumnTypeToken, const TOptions extends SchemaComponentOptions & Omit<SQLColumnToken<ColumnType>, "name" | "type" | "sqlTokenType"> = Omit<ColumnSchemaComponentOptions<ColumnType>, "type">, const ColumnName extends string = string>(name: ColumnName, type: ColumnType, options?: TOptions) => ({
|
|
1213
|
+
schemaComponentKey: `sc:dumbo:column:${ColumnName}`;
|
|
1214
|
+
components: ReadonlyMap<string, SchemaComponent>;
|
|
1215
|
+
migrations: ReadonlyArray<SQLMigration>;
|
|
1216
|
+
addComponent: <SchemaComponentType extends SchemaComponent<string, Record<string, any>> = SchemaComponent<string, Record<string, any>>>(component: SchemaComponentType) => SchemaComponentType;
|
|
1217
|
+
addMigration: (migration: SQLMigration) => void;
|
|
1218
|
+
} & Readonly<{
|
|
1219
|
+
columnName: ColumnName;
|
|
1220
|
+
}> & {
|
|
1221
|
+
sqlTokenType: "SQL_COLUMN";
|
|
1222
|
+
} & Omit<{
|
|
1223
|
+
name: string;
|
|
1224
|
+
type: ColumnType;
|
|
1225
|
+
notNull?: false;
|
|
1226
|
+
unique?: boolean;
|
|
1227
|
+
primaryKey: never;
|
|
1228
|
+
default?: ColumnType | SQLToken;
|
|
1229
|
+
}, "sqlTokenType"> & (TOptions & {
|
|
1230
|
+
type: ColumnType;
|
|
1231
|
+
} extends infer T ? T extends TOptions & {
|
|
1232
|
+
type: ColumnType;
|
|
1233
|
+
} ? T extends {
|
|
1234
|
+
notNull: true;
|
|
1235
|
+
} | {
|
|
1236
|
+
primaryKey: true;
|
|
1237
|
+
} ? {
|
|
1238
|
+
notNull: true;
|
|
1239
|
+
} : {
|
|
1240
|
+
notNull?: false;
|
|
1241
|
+
} : never : never)) | ({
|
|
1242
|
+
schemaComponentKey: `sc:dumbo:column:${ColumnName}`;
|
|
1243
|
+
components: ReadonlyMap<string, SchemaComponent>;
|
|
1244
|
+
migrations: ReadonlyArray<SQLMigration>;
|
|
1245
|
+
addComponent: <SchemaComponentType extends SchemaComponent<string, Record<string, any>> = SchemaComponent<string, Record<string, any>>>(component: SchemaComponentType) => SchemaComponentType;
|
|
1246
|
+
addMigration: (migration: SQLMigration) => void;
|
|
1247
|
+
} & Readonly<{
|
|
1248
|
+
columnName: ColumnName;
|
|
1249
|
+
}> & {
|
|
1250
|
+
sqlTokenType: "SQL_COLUMN";
|
|
1251
|
+
} & Omit<NullableSQLColumnTokenProps<ColumnType>, "sqlTokenType"> & (TOptions & {
|
|
1252
|
+
type: ColumnType;
|
|
1253
|
+
} extends infer T_1 ? T_1 extends TOptions & {
|
|
1254
|
+
type: ColumnType;
|
|
1255
|
+
} ? T_1 extends {
|
|
1256
|
+
notNull: true;
|
|
1257
|
+
} | {
|
|
1258
|
+
primaryKey: true;
|
|
1259
|
+
} ? {
|
|
1260
|
+
notNull: true;
|
|
1261
|
+
} : {
|
|
1262
|
+
notNull?: false;
|
|
1263
|
+
} : never : never));
|
|
1264
|
+
index: (name: string, columnNames: string[], options?: {
|
|
1265
|
+
unique?: boolean;
|
|
1266
|
+
} & SchemaComponentOptions) => IndexSchemaComponent;
|
|
1267
|
+
};
|
|
1268
|
+
//#endregion
|
|
1269
|
+
//#region src/core/locks/databaseLock.d.ts
|
|
1270
|
+
type DatabaseLockOptions = {
|
|
1271
|
+
lockId: number;
|
|
1272
|
+
timeoutMs?: number;
|
|
1273
|
+
};
|
|
1274
|
+
type AcquireDatabaseLockMode = 'Permanent' | 'Session';
|
|
1275
|
+
type AcquireDatabaseLockOptions = DatabaseLockOptions & {
|
|
1276
|
+
mode?: AcquireDatabaseLockMode;
|
|
1277
|
+
};
|
|
1278
|
+
type ReleaseDatabaseLockOptions = DatabaseLockOptions;
|
|
1279
|
+
declare const defaultDatabaseLockOptions: Required<Omit<DatabaseLockOptions, 'lockId'>>;
|
|
1280
|
+
type DatabaseLock = {
|
|
1281
|
+
acquire(execute: SQLExecutor, options: AcquireDatabaseLockOptions): Promise<void>;
|
|
1282
|
+
tryAcquire(execute: SQLExecutor, options: AcquireDatabaseLockOptions): Promise<boolean>;
|
|
1283
|
+
release(execute: SQLExecutor, options: ReleaseDatabaseLockOptions): Promise<boolean>;
|
|
1284
|
+
withAcquire: <Result = unknown>(execute: SQLExecutor, handle: () => Promise<Result>, options: AcquireDatabaseLockOptions) => Promise<Result>;
|
|
1285
|
+
};
|
|
1286
|
+
declare const NoDatabaseLock: DatabaseLock;
|
|
1287
|
+
//#endregion
|
|
1288
|
+
//#region src/core/schema/migrators/migrator.d.ts
|
|
1289
|
+
declare const MIGRATIONS_LOCK_ID = 999956789;
|
|
1290
|
+
declare global {
|
|
1291
|
+
var defaultMigratorOptions: Record<DatabaseType, MigratorOptions>;
|
|
1292
|
+
}
|
|
1293
|
+
declare const registerDefaultMigratorOptions: (databaseType: DatabaseType, options: MigratorOptions) => void;
|
|
1294
|
+
declare const getDefaultMigratorOptionsFromRegistry: (databaseType: DatabaseType) => MigratorOptions;
|
|
1295
|
+
type MigratorOptions = {
|
|
1296
|
+
schema?: {
|
|
1297
|
+
migrationTable?: SchemaComponent;
|
|
1298
|
+
};
|
|
1299
|
+
lock?: {
|
|
1300
|
+
databaseLock?: DatabaseLock;
|
|
1301
|
+
options?: Omit<DatabaseLockOptions, 'lockId'> & Partial<Pick<DatabaseLockOptions, 'lockId'>>;
|
|
1302
|
+
};
|
|
1303
|
+
dryRun?: boolean | undefined;
|
|
1304
|
+
ignoreMigrationHashMismatch?: boolean | undefined;
|
|
1305
|
+
migrationTimeoutMs?: number | undefined;
|
|
1306
|
+
};
|
|
1307
|
+
type RunSQLMigrationsResult = {
|
|
1308
|
+
applied: SQLMigration[];
|
|
1309
|
+
skipped: SQLMigration[];
|
|
1310
|
+
};
|
|
1311
|
+
declare const runSQLMigrations: (pool: Dumbo, migrations: ReadonlyArray<SQLMigration>, partialOptions?: Partial<MigratorOptions>) => Promise<RunSQLMigrationsResult>;
|
|
1312
|
+
declare const combineMigrations: (...migration: Pick<SQLMigration, "sqls">[]) => SQL[];
|
|
1313
|
+
//#endregion
|
|
1314
|
+
//#region src/core/schema/migrators/schemaComponentMigrator.d.ts
|
|
1315
|
+
declare const migrationTableSchemaComponent: {
|
|
1316
|
+
schemaComponentKey: "dumbo:schema-component:migrations-table";
|
|
1317
|
+
components: ReadonlyMap<string, SchemaComponent>;
|
|
1318
|
+
migrations: ReadonlyArray<SQLMigration>;
|
|
1319
|
+
addComponent: <SchemaComponentType extends SchemaComponent<string, Record<string, any>> = SchemaComponent<string, Record<string, any>>>(component: SchemaComponentType) => SchemaComponentType;
|
|
1320
|
+
addMigration: (migration: SQLMigration) => void;
|
|
1321
|
+
};
|
|
1322
|
+
type SchemaComponentMigrator = {
|
|
1323
|
+
component: SchemaComponent;
|
|
1324
|
+
run: (options?: Partial<MigratorOptions>) => Promise<void>;
|
|
1325
|
+
};
|
|
1326
|
+
declare const SchemaComponentMigrator: <DriverType extends DatabaseDriverType>(component: SchemaComponent, dumbo: Dumbo<DriverType>) => SchemaComponentMigrator;
|
|
1327
|
+
//#endregion
|
|
1328
|
+
//#region src/core/drivers/databaseDriver.d.ts
|
|
1329
|
+
interface DumboDatabaseDriver<ConnectionType extends AnyConnection = AnyConnection, DriverOptions extends unknown = unknown, DumboType extends Dumbo<ConnectionType['driverType'], ConnectionType> = Dumbo<ConnectionType['driverType'], ConnectionType>> {
|
|
1330
|
+
readonly driverType: ConnectionType['driverType'];
|
|
1331
|
+
readonly sqlFormatter: SQLFormatter;
|
|
1332
|
+
readonly defaultMigratorOptions: MigratorOptions;
|
|
1333
|
+
readonly databaseMetadata: DatabaseMetadata;
|
|
1334
|
+
createPool(options: DumboConnectionOptions<this>): DumboType;
|
|
1335
|
+
canHandle(options: DumboConnectionOptions<this>): boolean;
|
|
1336
|
+
}
|
|
1337
|
+
type AnyDumboDatabaseDriver = DumboDatabaseDriver<AnyConnection, any>;
|
|
1338
|
+
type ExtractDumboDatabaseDriverOptions<DatabaseDriver> = DatabaseDriver extends DumboDatabaseDriver<any, infer O, any> ? O : never;
|
|
1339
|
+
type ExtractDumboTypeFromDriver<DatabaseDriver> = DatabaseDriver extends DumboDatabaseDriver<any, any, infer D> ? D : never;
|
|
1340
|
+
declare const canHandleDriverWithConnectionString: <DatabaseDriver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver, ConnectionOptions extends DumboConnectionOptions<DatabaseDriver> = DumboConnectionOptions<DatabaseDriver>>(driver: DatabaseDriver["driverType"], tryParseConnectionString: (connectionString: string) => string | null) => (options: ConnectionOptions) => boolean;
|
|
1341
|
+
declare const DumboDatabaseDriverRegistry: () => {
|
|
1342
|
+
register: <Driver extends AnyDumboDatabaseDriver>(driverType: Driver["driverType"], plugin: Driver | (() => Promise<Driver>)) => void;
|
|
1343
|
+
tryResolve: <Driver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver, ConnectionOptions extends DumboConnectionOptions<Driver> = DumboConnectionOptions<Driver>>(options: ConnectionOptions) => Promise<Driver | null>;
|
|
1344
|
+
tryGet: <Driver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver, ConnectionOptions extends DumboConnectionOptions<Driver> = DumboConnectionOptions<Driver>>(options: ConnectionOptions) => Driver | null;
|
|
1345
|
+
has: (driverType: DatabaseDriverType) => boolean;
|
|
1346
|
+
readonly databaseDriverTypes: DatabaseDriverType[];
|
|
1347
|
+
};
|
|
1348
|
+
declare global {
|
|
1349
|
+
var dumboDatabaseDriverRegistry: ReturnType<typeof DumboDatabaseDriverRegistry>;
|
|
1350
|
+
}
|
|
1351
|
+
declare const dumboDatabaseDriverRegistry: {
|
|
1352
|
+
register: <Driver extends AnyDumboDatabaseDriver>(driverType: Driver["driverType"], plugin: Driver | (() => Promise<Driver>)) => void;
|
|
1353
|
+
tryResolve: <Driver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver, ConnectionOptions extends DumboConnectionOptions<Driver> = DumboConnectionOptions<Driver>>(options: ConnectionOptions) => Promise<Driver | null>;
|
|
1354
|
+
tryGet: <Driver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver, ConnectionOptions extends DumboConnectionOptions<Driver> = DumboConnectionOptions<Driver>>(options: ConnectionOptions) => Driver | null;
|
|
1355
|
+
has: (driverType: DatabaseDriverType) => boolean;
|
|
1356
|
+
readonly databaseDriverTypes: DatabaseDriverType[];
|
|
1357
|
+
};
|
|
1358
|
+
//#endregion
|
|
1359
|
+
//#region src/core/drivers/index.d.ts
|
|
1360
|
+
type DatabaseType = string;
|
|
1361
|
+
type DatabaseDriverName = string;
|
|
1362
|
+
type DatabaseDriverType<DatabaseTypeName extends DatabaseType = DatabaseType, DriverName extends DatabaseDriverName = DatabaseDriverName> = `${DatabaseTypeName}:${DriverName}`;
|
|
1363
|
+
type InferDriverDatabaseType<T extends string> = T extends `${infer DatabaseType}:${string}` ? DatabaseType : never;
|
|
1364
|
+
type DatabaseDriverTypeParts<T extends DatabaseType = DatabaseType> = {
|
|
1365
|
+
databaseType: T;
|
|
1366
|
+
driverName: string;
|
|
1367
|
+
};
|
|
1368
|
+
/**
|
|
1369
|
+
* Accepts a `databaseType` (e.g. PostgreSQL, SQLite) and a `driverName`
|
|
1370
|
+
* (the library name, e.g. pg, sqlite3) and combines them to a singular
|
|
1371
|
+
* `databaseDriverType` which can be used in database handling.
|
|
1372
|
+
*/
|
|
1373
|
+
declare function toDatabaseDriverType<T extends DatabaseType>(databaseType: T, driverName: string): DatabaseDriverType<T>;
|
|
1374
|
+
/**
|
|
1375
|
+
* Accepts a fully formatted `driverType` and returns the broken down
|
|
1376
|
+
* `databaseType` and `driverName`.
|
|
1377
|
+
*/
|
|
1378
|
+
declare function fromDatabaseDriverType<T extends DatabaseType>(databaseDriverType: DatabaseDriverType<T>): DatabaseDriverTypeParts<T>;
|
|
1379
|
+
/**
|
|
1380
|
+
* Accepts a fully formatted `databaseDriverType` and returns the `driverName`.
|
|
1381
|
+
*/
|
|
1382
|
+
declare function getDatabaseDriverName<T extends DatabaseType>(databaseDriverType: DatabaseDriverType<T>): DatabaseDriverName;
|
|
1383
|
+
/**
|
|
1384
|
+
* Accepts a fully formatted `databaseDriverType` and returns the `databaseType`.
|
|
1385
|
+
*/
|
|
1386
|
+
declare function getDatabaseType<T extends DatabaseType>(databaseDriverType: DatabaseDriverType<T>): DatabaseType;
|
|
1387
|
+
//#endregion
|
|
1388
|
+
//#region src/core/connections/transaction.d.ts
|
|
1389
|
+
interface DatabaseTransaction<ConnectionType extends AnyConnection = AnyConnection, TransactionOptionsType extends DatabaseTransactionOptions = DatabaseTransactionOptions> extends WithSQLExecutor {
|
|
1390
|
+
driverType: ConnectionType['driverType'];
|
|
1391
|
+
connection: ConnectionType;
|
|
1392
|
+
begin: () => Promise<void>;
|
|
1393
|
+
commit: () => Promise<void>;
|
|
1394
|
+
rollback: (error?: unknown) => Promise<void>;
|
|
1395
|
+
_transactionOptions: TransactionOptionsType;
|
|
1396
|
+
}
|
|
1397
|
+
type AnyDatabaseTransaction = DatabaseTransaction<any, any>;
|
|
1398
|
+
type DatabaseTransactionOptions = {
|
|
1399
|
+
allowNestedTransactions?: boolean;
|
|
1400
|
+
readonly?: boolean;
|
|
1401
|
+
};
|
|
1402
|
+
type InferTransactionOptionsFromTransaction<C extends AnyDatabaseTransaction> = C extends DatabaseTransaction<any, infer TO> ? TO : never;
|
|
1403
|
+
interface WithDatabaseTransactionFactory<ConnectionType extends AnyConnection = AnyConnection> {
|
|
1404
|
+
transaction: (options?: InferTransactionOptionsFromConnection<ConnectionType>) => InferTransactionFromConnection<ConnectionType>;
|
|
1405
|
+
withTransaction: <Result = never>(handle: (transaction: InferTransactionFromConnection<ConnectionType>) => Promise<TransactionResult<Result> | Result>, options?: InferTransactionOptionsFromConnection<ConnectionType>) => Promise<Result>;
|
|
1406
|
+
}
|
|
1407
|
+
type TransactionResult<Result> = {
|
|
1408
|
+
success: boolean;
|
|
1409
|
+
result: Result;
|
|
1410
|
+
};
|
|
1411
|
+
declare const executeInTransaction: <DatabaseTransactionType extends AnyDatabaseTransaction = AnyDatabaseTransaction, Result = void>(transaction: DatabaseTransactionType, handle: (transaction: DatabaseTransactionType) => Promise<TransactionResult<Result> | Result>) => Promise<Result>;
|
|
1412
|
+
declare const transactionFactoryWithDbClient: <ConnectionType extends AnyConnection = AnyConnection>(connect: () => Promise<InferDbClientFromConnection<ConnectionType>>, initTransaction: (client: Promise<InferDbClientFromConnection<ConnectionType>>, options?: InferTransactionOptionsFromConnection<ConnectionType> & {
|
|
1413
|
+
close: (client: InferDbClientFromConnection<ConnectionType>, error?: unknown) => Promise<void>;
|
|
1414
|
+
}) => InferTransactionFromConnection<ConnectionType>) => WithDatabaseTransactionFactory<ConnectionType>;
|
|
1415
|
+
declare const transactionFactoryWithNewConnection: <ConnectionType extends AnyConnection = AnyConnection>(connect: () => ConnectionType) => WithDatabaseTransactionFactory<ConnectionType>;
|
|
1416
|
+
declare const transactionFactoryWithAmbientConnection: <ConnectionType extends AnyConnection = AnyConnection>(connect: () => ConnectionType) => WithDatabaseTransactionFactory<ConnectionType>;
|
|
1417
|
+
declare const transactionFactoryWithAsyncAmbientConnection: <ConnectionType extends AnyConnection = AnyConnection>(driverType: ConnectionType["driverType"], connect: () => Promise<ConnectionType>, close?: (connection: ConnectionType) => void | Promise<void>) => WithDatabaseTransactionFactory<ConnectionType>;
|
|
1418
|
+
//#endregion
|
|
1419
|
+
//#region src/core/connections/connection.d.ts
|
|
1420
|
+
interface Connection<Self extends AnyConnection = AnyConnection, DriverType extends DatabaseDriverType = DatabaseDriverType, DbClient = unknown, TransactionType extends DatabaseTransaction<Self, any> = DatabaseTransaction<Self, any>> extends WithSQLExecutor, WithDatabaseTransactionFactory<Self> {
|
|
1421
|
+
driverType: DriverType;
|
|
1422
|
+
open: () => Promise<DbClient>;
|
|
1423
|
+
close: () => Promise<void>;
|
|
1424
|
+
_transactionType: TransactionType;
|
|
1425
|
+
}
|
|
1426
|
+
type AnyConnection = Connection<AnyConnection, DatabaseDriverType, unknown, AnyDatabaseTransaction>;
|
|
1427
|
+
type InferDriverTypeFromConnection<C extends AnyConnection> = C extends Connection<any, infer DT, any, any> ? DT : never;
|
|
1428
|
+
type InferDbClientFromConnection<C extends AnyConnection> = C extends Connection<any, any, infer DC, any> ? DC : never;
|
|
1429
|
+
type InferTransactionFromConnection<C extends AnyConnection> = C extends Connection<any, any, any, infer DT> ? DT : never;
|
|
1430
|
+
type InferTransactionOptionsFromConnection<C extends AnyConnection> = InferTransactionOptionsFromTransaction<InferTransactionFromConnection<C>>;
|
|
1431
|
+
type ConnectionOptions<ConnectionType extends AnyConnection = AnyConnection> = {
|
|
1432
|
+
driverType?: ConnectionType['driverType'];
|
|
1433
|
+
transactionOptions?: InferTransactionOptionsFromConnection<ConnectionType>;
|
|
1434
|
+
};
|
|
1435
|
+
type ConnectionFactory<ConnectionType extends AnyConnection = AnyConnection> = (options: ConnectionOptions<ConnectionType>) => ConnectionType;
|
|
1436
|
+
type WithConnectionOptions = {
|
|
1437
|
+
readonly?: boolean;
|
|
1438
|
+
};
|
|
1439
|
+
interface WithConnectionFactory<ConnectionType extends AnyConnection = AnyConnection> {
|
|
1440
|
+
connection: (options?: WithConnectionOptions) => Promise<ConnectionType>;
|
|
1441
|
+
withConnection: <Result = unknown>(handle: (connection: ConnectionType) => Promise<Result>, options?: WithConnectionOptions) => Promise<Result>;
|
|
1442
|
+
}
|
|
1443
|
+
type InitTransaction<ConnectionType extends AnyConnection = AnyConnection> = (connection: () => ConnectionType) => (client: Promise<InferDbClientFromConnection<ConnectionType>>, options?: InferTransactionOptionsFromConnection<ConnectionType> & {
|
|
1444
|
+
close: (client: InferDbClientFromConnection<ConnectionType>, error?: unknown) => Promise<void>;
|
|
1445
|
+
}) => InferTransactionFromConnection<ConnectionType>;
|
|
1446
|
+
type CreateConnectionOptions<ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor> = {
|
|
1447
|
+
driverType: InferDriverTypeFromConnection<ConnectionType>;
|
|
1448
|
+
connect: () => Promise<InferDbClientFromConnection<ConnectionType>>;
|
|
1449
|
+
close: (client: InferDbClientFromConnection<ConnectionType>) => Promise<void>;
|
|
1450
|
+
initTransaction: InitTransaction<ConnectionType>;
|
|
1451
|
+
serializer: JSONSerializer;
|
|
1452
|
+
executor: (options: DbSQLExecutorOptions) => Executor;
|
|
1453
|
+
};
|
|
1454
|
+
type CreateAmbientConnectionOptions<ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor> = {
|
|
1455
|
+
driverType: InferDriverTypeFromConnection<ConnectionType>;
|
|
1456
|
+
client: InferDbClientFromConnection<ConnectionType>;
|
|
1457
|
+
serializer: JSONSerializer;
|
|
1458
|
+
initTransaction: InitTransaction<ConnectionType>;
|
|
1459
|
+
executor: (options: DbSQLExecutorOptions) => Executor;
|
|
1460
|
+
};
|
|
1461
|
+
declare const createAmbientConnection: <ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor>(options: CreateAmbientConnectionOptions<ConnectionType, Executor>) => ConnectionType;
|
|
1462
|
+
type CreateSingletonConnectionOptions<ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor> = {
|
|
1463
|
+
driverType: InferDriverTypeFromConnection<ConnectionType>;
|
|
1464
|
+
connect: () => Promise<InferDbClientFromConnection<ConnectionType>>;
|
|
1465
|
+
close: (client: InferDbClientFromConnection<ConnectionType>) => Promise<void>;
|
|
1466
|
+
initTransaction: InitTransaction<ConnectionType>;
|
|
1467
|
+
serializer: JSONSerializer;
|
|
1468
|
+
executor: (options: DbSQLExecutorOptions) => Executor;
|
|
1469
|
+
};
|
|
1470
|
+
declare const createSingletonConnection: <ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor>(options: CreateSingletonConnectionOptions<ConnectionType, Executor>) => ConnectionType;
|
|
1471
|
+
type CreateTransientConnectionOptions<ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor> = {
|
|
1472
|
+
driverType: InferDriverTypeFromConnection<ConnectionType>;
|
|
1473
|
+
open: () => Promise<InferDbClientFromConnection<ConnectionType>>;
|
|
1474
|
+
close: () => Promise<void>;
|
|
1475
|
+
initTransaction: InitTransaction<ConnectionType>;
|
|
1476
|
+
serializer: JSONSerializer;
|
|
1477
|
+
executor: (options: DbSQLExecutorOptions) => Executor;
|
|
1478
|
+
};
|
|
1479
|
+
declare const createTransientConnection: <ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor>(options: CreateTransientConnectionOptions<ConnectionType, Executor>) => ConnectionType;
|
|
1480
|
+
declare const createConnection: <ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor>(options: CreateConnectionOptions<ConnectionType, Executor>) => ConnectionType;
|
|
1481
|
+
//#endregion
|
|
1482
|
+
//#region src/core/connections/pool.d.ts
|
|
1483
|
+
interface ConnectionPool<ConnectionType extends AnyConnection = AnyConnection> extends WithSQLExecutor, WithConnectionFactory<ConnectionType>, WithDatabaseTransactionFactory<ConnectionType> {
|
|
1484
|
+
driverType: ConnectionType['driverType'];
|
|
1485
|
+
close: () => Promise<void>;
|
|
1486
|
+
}
|
|
1487
|
+
type ConnectionPoolFactory<ConnectionPoolType extends ConnectionPool = ConnectionPool, ConnectionPoolOptions = unknown> = (options: ConnectionPoolOptions) => ConnectionPoolType;
|
|
1488
|
+
type AmbientConnectionPoolOptions<ConnectionType extends AnyConnection> = {
|
|
1489
|
+
driverType: ConnectionType['driverType'];
|
|
1490
|
+
connection: ConnectionType;
|
|
1491
|
+
};
|
|
1492
|
+
declare const createAmbientConnectionPool: <ConnectionType extends AnyConnection>(options: AmbientConnectionPoolOptions<ConnectionType>) => ConnectionPool<ConnectionType>;
|
|
1493
|
+
type SingletonConnectionPoolOptions<ConnectionType extends AnyConnection> = {
|
|
1494
|
+
driverType: ConnectionType['driverType'];
|
|
1495
|
+
getConnection: () => ConnectionType | Promise<ConnectionType>;
|
|
1496
|
+
closeConnection?: (connection: ConnectionType) => void | Promise<void>;
|
|
1497
|
+
connectionOptions?: never;
|
|
1498
|
+
};
|
|
1499
|
+
declare const createSingletonConnectionPool: <ConnectionType extends AnyConnection>(options: SingletonConnectionPoolOptions<ConnectionType>) => ConnectionPool<ConnectionType>;
|
|
1500
|
+
type CreateBoundedConnectionPoolOptions<ConnectionType extends AnyConnection> = {
|
|
1501
|
+
driverType: ConnectionType['driverType'];
|
|
1502
|
+
getConnection: () => ConnectionType | Promise<ConnectionType>;
|
|
1503
|
+
maxConnections: number;
|
|
1504
|
+
};
|
|
1505
|
+
declare const createBoundedConnectionPool: <ConnectionType extends AnyConnection>(options: CreateBoundedConnectionPoolOptions<ConnectionType>) => ConnectionPool<ConnectionType>;
|
|
1506
|
+
type SingletonClientConnectionPoolOptions<ConnectionType extends AnyConnection> = {
|
|
1507
|
+
driverType: ConnectionType['driverType'];
|
|
1508
|
+
dbClient: InferDbClientFromConnection<ConnectionType>;
|
|
1509
|
+
connectionFactory: (options: {
|
|
1510
|
+
dbClient: InferDbClientFromConnection<ConnectionType>;
|
|
1511
|
+
}) => ConnectionType;
|
|
1512
|
+
};
|
|
1513
|
+
declare const createSingletonClientConnectionPool: <ConnectionType extends AnyConnection>(options: SingletonClientConnectionPoolOptions<ConnectionType>) => ConnectionPool<ConnectionType>;
|
|
1514
|
+
type CreateAlwaysNewConnectionPoolOptions<ConnectionType extends AnyConnection, ConnectionOptions extends Record<string, unknown> | undefined = undefined> = ConnectionOptions extends undefined ? {
|
|
1515
|
+
driverType: ConnectionType['driverType'];
|
|
1516
|
+
getConnection: () => ConnectionType;
|
|
1517
|
+
connectionOptions?: never;
|
|
1518
|
+
} : {
|
|
1519
|
+
driverType: ConnectionType['driverType'];
|
|
1520
|
+
getConnection: (options: ConnectionOptions) => ConnectionType;
|
|
1521
|
+
connectionOptions: ConnectionOptions;
|
|
1522
|
+
};
|
|
1523
|
+
declare const createAlwaysNewConnectionPool: <ConnectionType extends AnyConnection, ConnectionOptions extends Record<string, unknown> | undefined = undefined>(options: CreateAlwaysNewConnectionPoolOptions<ConnectionType, ConnectionOptions>) => ConnectionPool<ConnectionType>;
|
|
1524
|
+
type CreateConnectionPoolOptions<ConnectionType extends AnyConnection> = Pick<ConnectionPool<ConnectionType>, 'driverType'> & Partial<ConnectionPool<ConnectionType>> & {
|
|
1525
|
+
getConnection: () => ConnectionType;
|
|
1526
|
+
};
|
|
1527
|
+
declare const createConnectionPool: <ConnectionType extends AnyConnection>(pool: CreateConnectionPoolOptions<ConnectionType>) => ConnectionPool<ConnectionType>;
|
|
1528
|
+
//#endregion
|
|
1529
|
+
//#region src/core/tracing/index.d.ts
|
|
1530
|
+
declare const tracer: {
|
|
1531
|
+
(): void;
|
|
1532
|
+
info(eventName: string, attributes?: Record<string, any>): void;
|
|
1533
|
+
warn(eventName: string, attributes?: Record<string, any>): void;
|
|
1534
|
+
log(eventName: string, attributes?: Record<string, any>): void;
|
|
1535
|
+
error(eventName: string, attributes?: Record<string, any>): void;
|
|
1536
|
+
};
|
|
1537
|
+
type LogLevel = 'DISABLED' | 'INFO' | 'LOG' | 'WARN' | 'ERROR';
|
|
1538
|
+
declare const LogLevel: {
|
|
1539
|
+
DISABLED: LogLevel;
|
|
1540
|
+
INFO: LogLevel;
|
|
1541
|
+
LOG: LogLevel;
|
|
1542
|
+
WARN: LogLevel;
|
|
1543
|
+
ERROR: LogLevel;
|
|
1544
|
+
};
|
|
1545
|
+
type LogType = 'CONSOLE';
|
|
1546
|
+
type LogStyle = 'RAW' | 'PRETTY';
|
|
1547
|
+
declare const LogStyle: {
|
|
1548
|
+
RAW: LogStyle;
|
|
1549
|
+
PRETTY: LogStyle;
|
|
1550
|
+
};
|
|
1551
|
+
//#endregion
|
|
1552
|
+
//#region src/core/index.d.ts
|
|
1553
|
+
type Dumbo<DriverType extends DatabaseDriverType = DatabaseDriverType, ConnectionType extends AnyConnection = AnyConnection> = ConnectionPool<ConnectionType>;
|
|
1554
|
+
type DumboConnectionOptions<DatabaseDriver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver> = ExtractDumboDatabaseDriverOptions<DatabaseDriver> extends infer Options ? Options extends unknown ? {
|
|
1555
|
+
driver?: DatabaseDriver;
|
|
1556
|
+
driverType?: DatabaseDriver['driverType'];
|
|
1557
|
+
} & Omit<Options, 'driver' | 'driverType' | 'connectionString'> : never : never;
|
|
1558
|
+
declare module './sql' {
|
|
1559
|
+
namespace SQL {
|
|
1560
|
+
const columnN: typeof dumboSchema.column & {
|
|
1561
|
+
type: typeof SQLColumnTypeTokensFactory;
|
|
1562
|
+
};
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
//#endregion
|
|
1566
|
+
//#region src/storage/all/connections/connectionString.d.ts
|
|
1567
|
+
type DatabaseConnectionString<DatabaseTypeName extends DatabaseType = DatabaseType, Format extends string = string> = Format & {
|
|
1568
|
+
_databaseType: DatabaseTypeName;
|
|
1569
|
+
};
|
|
1570
|
+
declare const parseConnectionString: (connectionString: DatabaseConnectionString | string) => DatabaseDriverTypeParts;
|
|
1571
|
+
//#endregion
|
|
1572
|
+
//#region src/storage/postgresql/core/schema/postgreSQLMetadata.d.ts
|
|
1573
|
+
declare const postgreSQLMetadata: DatabaseMetadata<true, true, true>;
|
|
1574
|
+
//#endregion
|
|
1575
|
+
//#region src/storage/sqlite/core/schema/sqliteMetadata.d.ts
|
|
1576
|
+
declare const sqliteMetadata: DatabaseMetadata<false, false, false>;
|
|
1577
|
+
//#endregion
|
|
1578
|
+
//#region src/storage/all/index.d.ts
|
|
1579
|
+
declare function dumbo<Driver extends AnyDumboDatabaseDriver>(options: ExtractDumboDatabaseDriverOptions<Driver> & {
|
|
1580
|
+
driver: Driver;
|
|
1581
|
+
} & JSONSerializationOptions): ExtractDumboTypeFromDriver<Driver>;
|
|
1582
|
+
declare function dumbo<DatabaseDriver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver, ConnectionOptions extends DumboConnectionOptions<DatabaseDriver> = DumboConnectionOptions<DatabaseDriver>>(options: ConnectionOptions & {
|
|
1583
|
+
driver?: never;
|
|
1584
|
+
}): ExtractDumboTypeFromDriver<DatabaseDriver>;
|
|
1585
|
+
//#endregion
|
|
1586
|
+
export { transactionFactoryWithAsyncAmbientConnection as $, JSONCodecOptions as $a, mapDefaultSQLColumnProcessors as $i, ValidateTable as $n, NormalizeColumnPath as $r, executeInNewConnection as $t, CreateAmbientConnectionOptions as A, SQLColumnToken as Aa, mapSchemaComponentsOfType as Ai, CollectReferencesErrors as An, InferDatabaseSchemas as Ar, DatabaseLockOptions as At, WithConnectionOptions as B, SQLArrayMode as Ba, describeSQL as Bi, SchemaTablesWithSingle as Bn, AllColumnTypesInSchema as Br, getDefaultDatabase as Bt, createConnectionPool as C, JSONValueType as Ca, ExtractAdditionalData as Ci, NotNullViolationError as Cn, InferTableSchemaComponentTypes as Cr, combineMigrations as Ct, Connection as D, JavaScriptValueTypeToNameMap as Da, filterSchemaComponentsOfType as Di, TransientDatabaseError as Dn, TableURNType as Dr, AcquireDatabaseLockMode as Dt, AnyConnection as E, JavaScriptValueTypeName as Ea, SchemaComponentType as Ei, SystemError as En, TableURN as Er, runSQLMigrations as Et, InferDriverTypeFromConnection as F, TimestamptzToken as Fa, sqlMigration as Fi, DatabaseSchemasWithSingle as Fn, TableRowType as Fr, DatabaseCapabilities as Ft, AnyDatabaseTransaction as G, SQLLiteral as Ga, SQL as Gi, ValidateDatabaseSchemas as Gn, ColumnPath as Gr, DbSQLExecutor as Gt, createConnection as H, SQLDefaultTokensTypes as Ha, getFormatter as Hi, ValidateColumnTypeMatch as Hn, AnyTableRelationshipDefinition as Hr, resolveDatabaseMetadata as Ht, InferTransactionFromConnection as I, VarcharToken as Ia, FormatContext as Ii, NoError as In, Writable as Ir, DatabaseMetadata as It, InferTransactionOptionsFromTransaction as J, ParametrizedSQL as Ja, ExpandArrayProcessor as Ji, ValidateReferences as Jn, ExtractColumnNames as Jr, SQLExecutor as Jt, DatabaseTransaction as K, SQLPlain as Ka, isSQL as Ki, ValidateDatabaseSchemasWithMessages as Kn, ColumnPathToReference as Kr, DbSQLExecutorOptions as Kt, InferTransactionOptionsFromConnection as L, AnySQLToken as La, FormatSQLOptions as Li, RelationshipColumnsMismatchError as Ln, AllColumnReferences as Lr, DumboDatabaseMetadataRegistry as Lt, CreateSingletonConnectionOptions as M, SQLColumnTypeTokensFactory as Ma, MigrationRecord as Mi, ColumnReferenceError as Mn, InferTableRow as Mr, ReleaseDatabaseLockOptions as Mt, CreateTransientConnectionOptions as N, SerialToken as Na, MigrationStyle as Ni, ColumnReferenceExistanceError as Nn, TableColumnNames as Nr, defaultDatabaseLockOptions as Nt, ConnectionFactory as O, NotNullableSQLColumnTokenProps as Oa, findSchemaComponentsOfType as Oi, UniqueConstraintError as On, tableSchemaComponent as Or, AcquireDatabaseLockOptions as Ot, InferDbClientFromConnection as P, TimestampToken as Pa, SQLMigration as Pi, ColumnReferenceTypeMismatchError as Pn, TableColumnType as Pr, dumboSchema as Pt, transactionFactoryWithAmbientConnection as Q, JSONCodec as Qa, DefaultSQLColumnProcessors as Qi, ValidateSchemaTables as Qn, LookupColumnType as Qr, executeInAmbientConnection as Qt, InitTransaction as R, ExtractSQLTokenType as Ra, SQLFormatter as Ri, RelationshipReferencesLengthMismatchError as Rn, AllColumnReferencesInSchema as Rr, dumboDatabaseMetadataRegistry as Rt, createBoundedConnectionPool as S, JSONBToken as Sa, DumboSchemaComponentType as Si, LockNotAvailableError as Sn, InferTableSchemaComponentColumns as Sr, RunSQLMigrationsResult as St, createSingletonConnectionPool as T, JavaScriptValueType as Ta, SchemaComponentOptions as Ti, SerializationError as Tn, TableSchemaComponent as Tr, registerDefaultMigratorOptions as Tt, createSingletonConnection as U, SQLIdentifier as Ua, registerFormatter as Ui, ValidateColumnsMatch as Un, AnyTableRelationshipDefinitionWithColumns as Ur, BatchCommandNoChangesError as Ut, createAmbientConnection as V, SQLDefaultTokens as Va, formatSQL as Vi, ValidateColumnReference as Vn, AnyRelationshipDefinition as Vr, getDefaultDatabaseAsync as Vt, createTransientConnection as W, SQLIn as Wa, RawSQL as Wi, ValidateDatabaseSchema as Wn, ColumnName$1 as Wr, BatchSQLCommandOptions as Wt, WithDatabaseTransactionFactory as X, SerializationCodec as Xa, FormatIdentifierProcessor as Xi, ValidateRelationshipColumns as Xn, ExtractSchemaNames as Xr, SQLQueryResultColumnMapping as Xt, TransactionResult as Y, ParametrizedSQLBuilder as Ya, ExpandSQLInProcessor as Yi, ValidateRelationship as Yn, ExtractColumnTypeName as Yr, SQLQueryOptions as Yt, executeInTransaction as Z, Serializer as Za, MapLiteralProcessor as Zi, ValidateRelationshipLength as Zn, ExtractTableNames as Zr, WithSQLExecutor as Zt, CreateConnectionPoolOptions as _, BigIntegerToken as _a, ColumnURN as _i, ExclusionViolationError as _n, DatabaseSchemaTables as _r, dumboDatabaseDriverRegistry as _t, parseConnectionString as a, SQLProcessorOptions as aa, TableColumnName as ai, sqlExecutor as an, JSONRevivers as ao, FormatTableLevel as ar, DatabaseType as at, createAlwaysNewConnectionPool as b, DefaultSQLColumnToken as ba, AnySchemaComponent as bi, IntegrityConstraintViolationError as bn, databaseSchemaSchemaComponent as br, MIGRATIONS_LOCK_ID as bt, LogLevel as c, DefaultMapSQLParamValueOptions as ca, AnyTypeValidationError as ci, QueryResult as cn, JSONSerializer as co, Join as cr, getDatabaseDriverName as ct, tracer as d, SQLValueMapper as da, IndexURN as di, CheckViolationError as dn, composeJSONRevivers as do, DatabaseSchemas as dr, AnyDumboDatabaseDriver as dt, SQLProcessorsReadonlyRegistry as ea, NormalizeReference as ei, executeInNewDbClient as en, JSONDeserializeOptions as eo, ValidateTableRelationships as er, transactionFactoryWithDbClient as et, AmbientConnectionPoolOptions as f, mapANSISQLParamPlaceholder as fa, IndexURNType as fi, ConcurrencyError as fn, jsonSerializer as fo, DatabaseURN as fr, DumboDatabaseDriver as ft, CreateBoundedConnectionPoolOptions as g, AutoIncrementSQLColumnToken as ga, ColumnSchemaComponentOptions as gi, DumboError as gn, DatabaseSchemaSchemaComponent as gr, canHandleDriverWithConnectionString as gt, CreateAlwaysNewConnectionPoolOptions as h, AnyColumnTypeToken as ha, ColumnSchemaComponent as hi, DeadlockError as hn, AnyDatabaseSchemaSchemaComponent as hr, ExtractDumboTypeFromDriver as ht, DatabaseConnectionString as i, SQLProcessorContext as ia, SchemaColumnName as ii, mapSQLQueryResult as in, JSONReviverContext as io, FormatSingleError as ir, DatabaseDriverTypeParts as it, CreateConnectionOptions as j, SQLColumnTypeTokens as ja, schemaComponent as ji, CollectRelationshipErrors as jn, InferSchemaTables as jr, NoDatabaseLock as jt, ConnectionOptions as k, NullableSQLColumnTokenProps as ka, isSchemaComponentOfType as ki, schemaComponentURN as kn, InferColumnType as kr, DatabaseLock as kt, LogStyle as l, MapSQLParamValue as la, TypeValidationSuccess as li, QueryResultRow as ln, JSONSerializerOptions as lo, AnyDatabaseSchemaComponent as lr, getDatabaseType as lt, ConnectionPoolFactory as m, mapSQLParamValue as ma, AnyColumnSchemaComponent as mi, DataError as mn, databaseSchemaComponent as mr, ExtractDumboDatabaseDriverOptions as mt, sqliteMetadata as n, AnySQLProcessor as na, RelationshipDefinition as ni, mapColumnToDate as nn, JSONReplacers as no, FormatRelationshipBlock as nr, DatabaseDriverName as nt, Dumbo as o, ANSISQLIdentifierQuote as oa, TableRelationships as oi, sqlExecutorInAmbientConnection as on, JSONSerializationOptions as oo, FormatValidationErrors as or, InferDriverDatabaseType as ot, ConnectionPool as p, mapSQLIdentifier as pa, indexSchemaComponent as pi, ConnectionError as pn, DbClientSetup as po, DatabaseURNType as pr, DumboDatabaseDriverRegistry as pt, DatabaseTransactionOptions as q, SQLToken as qa, defaultProcessorsRegistry as qi, ValidateReference as qn, ColumnReference as qr, SQLCommandOptions as qt, postgreSQLMetadata as r, SQLProcessor as ra, RelationshipType as ri, mapColumnToJSON as rn, JSONReviver as ro, FormatSchemaLevel as rr, DatabaseDriverType as rt, DumboConnectionOptions as s, ANSISQLParamPlaceholder as sa, relationship as si, sqlExecutorInNewConnection as sn, JSONSerializeOptions as so, IndentErrors as sr, fromDatabaseDriverType as st, dumbo as t, SQLProcessorsRegistry as ta, ParseReferencePath as ti, mapColumnToBigint as tn, JSONReplacer as to, FormatDatabaseValidationErrors as tr, transactionFactoryWithNewConnection as tt, LogType as u, MapSQLParamValueOptions as ua, IndexSchemaComponent as ui, AdminShutdownError as un, composeJSONReplacers as uo, DatabaseSchemaComponent as ur, toDatabaseDriverType as ut, SingletonClientConnectionPoolOptions as v, BigSerialToken as va, ColumnURNType as vi, ForeignKeyViolationError as vn, DatabaseSchemaURN as vr, SchemaComponentMigrator as vt, createSingletonClientConnectionPool as w, JSONValueTypeName as wa, SchemaComponent as wi, QueryCanceledError as wn, TableColumns as wr, getDefaultMigratorOptionsFromRegistry as wt, createAmbientConnectionPool as x, IntegerToken as xa, AnySchemaComponentOfType as xi, InvalidOperationError as xn, AnyTableSchemaComponent as xr, MigratorOptions as xt, SingletonConnectionPoolOptions as y, ColumnTypeToken as ya, columnSchemaComponent as yi, InsufficientResourcesError as yn, DatabaseSchemaURNType as yr, migrationTableSchemaComponent as yt, WithConnectionFactory as z, SQLArray as za, SQLFormatterOptions as zi, RelationshipValidationError as zn, AllColumnTypes as zr, getDatabaseMetadata as zt };
|
|
1587
|
+
//# sourceMappingURL=index-Cmdlb0KP.d.cts.map
|