@event-driven-io/dumbo 0.13.0-beta.42 → 0.13.0-beta.43

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.
Files changed (63) hide show
  1. package/dist/cloudflare.cjs +2193 -86
  2. package/dist/cloudflare.cjs.map +1 -1
  3. package/dist/cloudflare.d.cts +1106 -3
  4. package/dist/cloudflare.d.ts +1106 -3
  5. package/dist/cloudflare.js +2082 -3
  6. package/dist/cloudflare.js.map +1 -1
  7. package/dist/index.cjs +2505 -160
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +1676 -2
  10. package/dist/index.d.ts +1676 -2
  11. package/dist/index.js +2321 -4
  12. package/dist/index.js.map +1 -1
  13. package/dist/pg.cjs +2051 -58
  14. package/dist/pg.cjs.map +1 -1
  15. package/dist/pg.d.cts +1040 -2
  16. package/dist/pg.d.ts +1040 -2
  17. package/dist/pg.js +1968 -3
  18. package/dist/pg.js.map +1 -1
  19. package/dist/postgresql.cjs +1845 -25
  20. package/dist/postgresql.cjs.map +1 -0
  21. package/dist/postgresql.d.cts +1034 -3
  22. package/dist/postgresql.d.ts +1034 -3
  23. package/dist/postgresql.js +1795 -3
  24. package/dist/postgresql.js.map +1 -0
  25. package/dist/sqlite.cjs +2124 -30
  26. package/dist/sqlite.cjs.map +1 -0
  27. package/dist/sqlite.d.cts +1107 -3
  28. package/dist/sqlite.d.ts +1107 -3
  29. package/dist/sqlite.js +2069 -3
  30. package/dist/sqlite.js.map +1 -0
  31. package/dist/sqlite3.cjs +2412 -61
  32. package/dist/sqlite3.cjs.map +1 -1
  33. package/dist/sqlite3.d.cts +1106 -4
  34. package/dist/sqlite3.d.ts +1106 -4
  35. package/dist/sqlite3.js +2326 -3
  36. package/dist/sqlite3.js.map +1 -1
  37. package/package.json +1 -1
  38. package/dist/core-BPSzA-lq.cjs +0 -3259
  39. package/dist/core-BPSzA-lq.cjs.map +0 -1
  40. package/dist/core-BuSVyamf.cjs +0 -480
  41. package/dist/core-BuSVyamf.cjs.map +0 -1
  42. package/dist/core-C3xoqqDs.js +0 -403
  43. package/dist/core-C3xoqqDs.js.map +0 -1
  44. package/dist/core-CHw8vO17.js +0 -456
  45. package/dist/core-CHw8vO17.js.map +0 -1
  46. package/dist/core-CUGYxOEQ.cjs +0 -599
  47. package/dist/core-CUGYxOEQ.cjs.map +0 -1
  48. package/dist/core-IV7or0Mj.js +0 -2278
  49. package/dist/core-IV7or0Mj.js.map +0 -1
  50. package/dist/index-BJC_v03L.d.ts +0 -192
  51. package/dist/index-CfH0u2y_.d.cts +0 -1682
  52. package/dist/index-DP9b7v4e.d.cts +0 -192
  53. package/dist/index-QWEAqtHF.d.ts +0 -1682
  54. package/dist/index-qxECrBHo.d.ts +0 -75
  55. package/dist/index-tS9lpLPz.d.cts +0 -75
  56. package/dist/postgreSQLMetadata-CCsCJ-eH.cjs +0 -118
  57. package/dist/postgreSQLMetadata-CCsCJ-eH.cjs.map +0 -1
  58. package/dist/postgreSQLMetadata-bCBDGz1f.js +0 -65
  59. package/dist/postgreSQLMetadata-bCBDGz1f.js.map +0 -1
  60. package/dist/sqliteMetadata-Cc7Z03lm.cjs +0 -46
  61. package/dist/sqliteMetadata-Cc7Z03lm.cjs.map +0 -1
  62. package/dist/sqliteMetadata-CvvEc1-v.js +0 -29
  63. package/dist/sqliteMetadata-CvvEc1-v.js.map +0 -1
@@ -1,1682 +0,0 @@
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/reservedSqlWords.d.ts
339
- declare const ansiSqlReservedMap: {
340
- [key: string]: boolean;
341
- };
342
- //#endregion
343
- //#region src/core/sql/valueMappers/sqlValueMapper.d.ts
344
- interface SQLValueMapper {
345
- mapValue: MapSQLParamValue;
346
- mapPlaceholder: (index: number, value: unknown) => string;
347
- mapIdentifier: (value: string) => string;
348
- }
349
- type MapSQLParamValue = (value: unknown, serializer: JSONSerializer, options?: MapSQLParamValueOptions) => unknown;
350
- interface MapSQLParamValueOptions {
351
- mapBoolean?: (value: boolean) => unknown;
352
- mapArray?: (array: unknown[], mapValue: MapSQLParamValue) => unknown[];
353
- mapDate?: (value: Date) => unknown;
354
- mapObject?: (value: object) => unknown;
355
- mapBigInt?: (value: bigint) => unknown;
356
- mapValue?: MapSQLParamValue;
357
- mapPlaceholder?: (index: number, value: unknown) => string;
358
- mapIdentifier?: (value: string) => string;
359
- }
360
- declare const ANSISQLParamPlaceholder = "?";
361
- declare const ANSISQLIdentifierQuote = "\"";
362
- declare const mapANSISQLParamPlaceholder: () => string;
363
- declare const mapSQLIdentifier: (value: string, options?: {
364
- reservedWords: {
365
- [key: string]: boolean;
366
- };
367
- quote?: string;
368
- }) => string;
369
- declare const DefaultMapSQLParamValueOptions: {
370
- mapPlaceholder: () => string;
371
- mapIdentifier: (value: string, options?: {
372
- reservedWords: {
373
- [key: string]: boolean;
374
- };
375
- quote?: string;
376
- }) => string;
377
- };
378
- declare const SQLValueMapper: (options?: MapSQLParamValueOptions) => SQLValueMapper;
379
- declare function mapSQLParamValue(value: unknown, serializer: JSONSerializer, options?: MapSQLParamValueOptions): unknown;
380
- //#endregion
381
- //#region src/core/sql/processors/sqlProcessor.d.ts
382
- type SQLProcessorContext = {
383
- mapper: SQLValueMapper;
384
- builder: ParametrizedSQLBuilder;
385
- processorsRegistry: SQLProcessorsReadonlyRegistry;
386
- serializer: JSONSerializer;
387
- };
388
- type SQLProcessor<Token extends AnySQLToken = AnySQLToken> = {
389
- canHandle: Token['sqlTokenType'];
390
- handle: (value: Token, context: SQLProcessorContext) => void;
391
- };
392
- type AnySQLProcessor = SQLProcessor<any>;
393
- type SQLProcessorOptions<Token extends AnySQLToken = AnySQLToken> = {
394
- canHandle: Token['sqlTokenType'];
395
- handle: (value: Token, context: SQLProcessorContext) => void;
396
- };
397
- declare const SQLProcessor: <Token extends AnySQLToken = AnySQLToken>(options: SQLProcessorOptions<Token>) => SQLProcessor<Token>;
398
- //#endregion
399
- //#region src/core/sql/processors/sqlProcessorRegistry.d.ts
400
- interface SQLProcessorsReadonlyRegistry {
401
- get<Token extends AnySQLToken = AnySQLToken>(tokenType: Token['sqlTokenType']): SQLProcessor<Token> | null;
402
- all(): ReadonlyMap<string, AnySQLProcessor>;
403
- }
404
- interface SQLProcessorsRegistry extends SQLProcessorsReadonlyRegistry {
405
- register(...processor: AnySQLProcessor[]): SQLProcessorsRegistry;
406
- register(processor: Record<string, AnySQLProcessor>): SQLProcessorsRegistry;
407
- }
408
- declare const SQLProcessorsRegistry: (options?: {
409
- from: SQLProcessorsRegistry;
410
- }) => SQLProcessorsRegistry;
411
- //#endregion
412
- //#region src/core/sql/processors/columnProcessors.d.ts
413
- type DefaultSQLColumnProcessors = { [key in keyof SQLColumnTypeTokens]: SQLProcessor<SQLColumnTypeTokens[key]> };
414
- declare const mapDefaultSQLColumnProcessors: (mapColumnType: (token: DefaultSQLColumnToken, context: SQLProcessorContext) => void) => DefaultSQLColumnProcessors;
415
- //#endregion
416
- //#region src/core/sql/processors/defaultProcessors.d.ts
417
- declare const ExpandArrayProcessor: SQLProcessor<SQLArray>;
418
- declare const ExpandSQLInProcessor: SQLProcessor<SQLIn>;
419
- declare const FormatIdentifierProcessor: SQLProcessor<SQLIdentifier>;
420
- declare const MapLiteralProcessor: SQLProcessor<SQLLiteral>;
421
- //#endregion
422
- //#region src/core/sql/processors/index.d.ts
423
- declare global {
424
- var defaultProcessorsRegistry: ReturnType<typeof SQLProcessorsRegistry>;
425
- }
426
- declare const defaultProcessorsRegistry: SQLProcessorsRegistry;
427
- //#endregion
428
- //#region src/core/schema/sqlMigration.d.ts
429
- type MigrationStyle = 'None' | 'CreateOrUpdate';
430
- type SQLMigration = {
431
- name: string;
432
- sqls: SQL[];
433
- };
434
- declare const sqlMigration: (name: string, sqls: SQL[]) => SQLMigration;
435
- type MigrationRecord = {
436
- id: number;
437
- name: string;
438
- application: string;
439
- sqlHash: string;
440
- timestamp: Date;
441
- };
442
- //#endregion
443
- //#region src/core/schema/schemaComponent.d.ts
444
- type SchemaComponent<ComponentKey extends string = string, AdditionalData extends Exclude<Record<string, unknown>, 'schemaComponentKey' | 'components' | 'migrations' | 'addComponent' | 'addMigration'> | undefined = undefined> = {
445
- schemaComponentKey: ComponentKey;
446
- components: ReadonlyMap<string, SchemaComponent>;
447
- migrations: ReadonlyArray<SQLMigration>;
448
- addComponent: <SchemaComponentType extends SchemaComponent<string, Record<string, any>> = SchemaComponent<string, Record<string, any>>>(component: SchemaComponentType) => SchemaComponentType;
449
- addMigration: (migration: SQLMigration) => void;
450
- } & Exclude<AdditionalData extends undefined ? {} : AdditionalData, 'schemaComponentKey' | 'components' | 'migrations' | 'addComponent' | 'addMigration'>;
451
- type ExtractAdditionalData<T> = T extends SchemaComponent<infer _ComponentType, infer Data> ? Data : never;
452
- type AnySchemaComponent = SchemaComponent<string, Record<string, any>>;
453
- type AnySchemaComponentOfType<ComponentType extends string = string> = SchemaComponent<ComponentType, any>;
454
- type SchemaComponentOptions<AdditionalOptions extends Record<string, unknown> = Record<string, unknown>> = {
455
- migrations?: ReadonlyArray<SQLMigration>;
456
- components?: ReadonlyArray<SchemaComponent>;
457
- } & Omit<AdditionalOptions, 'migrations' | 'components'>;
458
- type SchemaComponentType<Kind extends string = string> = `sc:${Kind}`;
459
- type DumboSchemaComponentType<Kind extends string = string> = SchemaComponentType<`dumbo:${Kind}`>;
460
- declare const schemaComponent: <const ComponentKey extends string = string>(key: ComponentKey, options: SchemaComponentOptions) => SchemaComponent<ComponentKey>;
461
- declare const isSchemaComponentOfType: <SchemaComponentOfType extends AnySchemaComponent = AnySchemaComponent>(component: AnySchemaComponent, prefix: string) => component is SchemaComponentOfType;
462
- declare const filterSchemaComponentsOfType: <T extends AnySchemaComponent>(components: ReadonlyMap<string, AnySchemaComponent>, prefix: string) => ReadonlyMap<string, T>;
463
- declare const mapSchemaComponentsOfType: <T extends AnySchemaComponent>(components: ReadonlyMap<string, AnySchemaComponent>, prefix: string, keyMapper?: (component: T) => string) => ReadonlyMap<string, T>;
464
- declare const findSchemaComponentsOfType: <T extends AnySchemaComponent>(root: AnySchemaComponent, prefix: string) => T[];
465
- //#endregion
466
- //#region src/core/schema/dumboSchema/dumboSchema.d.ts
467
- declare const DEFAULT_DATABASE_SCHEMA_NAME = "__default_database_schema__";
468
- declare function dumboDatabaseSchema<const Tables extends DatabaseSchemaTables = DatabaseSchemaTables>(tables: Tables): DatabaseSchemaSchemaComponent<Tables, typeof DEFAULT_DATABASE_SCHEMA_NAME>;
469
- declare function dumboDatabaseSchema<const Tables extends DatabaseSchemaTables = DatabaseSchemaTables, const SchemaName extends string = string>(schemaName: SchemaName, tables: Tables, options?: SchemaComponentOptions): DatabaseSchemaSchemaComponent<Tables, SchemaName>;
470
- declare namespace dumboDatabaseSchema {
471
- var from: (schemaName: string | undefined, tableNames: string[]) => DatabaseSchemaSchemaComponent;
472
- var defaultName: string;
473
- }
474
- type ValidatedDatabaseSchemaComponent<Schemas extends DatabaseSchemas = DatabaseSchemas> = ValidateDatabaseSchemas<Schemas> extends {
475
- valid: true;
476
- } ? DatabaseSchemaComponent<Schemas> : ValidateDatabaseSchemas<Schemas> extends {
477
- valid: false;
478
- error: infer E;
479
- } ? {
480
- valid: false;
481
- error: E;
482
- } : DatabaseSchemaComponent<Schemas>;
483
- declare function dumboDatabase<Schemas extends DatabaseSchemas = DatabaseSchemas>(schemas: Schemas): ValidatedDatabaseSchemaComponent<Schemas>;
484
- declare function dumboDatabase<Schemas extends DatabaseSchemas = DatabaseSchemas>(schema: DatabaseSchemaSchemaComponent): ValidatedDatabaseSchemaComponent<Schemas>;
485
- declare function dumboDatabase<Schemas extends DatabaseSchemas = DatabaseSchemas>(databaseName: string, schemas: Schemas, options?: SchemaComponentOptions): ValidatedDatabaseSchemaComponent<Schemas>;
486
- declare function dumboDatabase<Schemas extends DatabaseSchemas = DatabaseSchemas>(databaseName: string, schema: AnyDatabaseSchemaSchemaComponent, options?: SchemaComponentOptions): ValidatedDatabaseSchemaComponent<Schemas>;
487
- declare namespace dumboDatabase {
488
- var from: <Schemas extends DatabaseSchemas = DatabaseSchemas>(databaseName: string | undefined, schemaNames: string[]) => ValidatedDatabaseSchemaComponent<Schemas>;
489
- var defaultName: string;
490
- }
491
- declare const dumboSchema: {
492
- database: typeof dumboDatabase;
493
- schema: typeof dumboDatabaseSchema;
494
- 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: {
495
- columns?: Columns;
496
- primaryKey?: TableColumnNames<TableSchemaComponent<Columns, TableName, Relationships>>[];
497
- relationships?: Relationships;
498
- indexes?: Record<string, IndexSchemaComponent>;
499
- } & SchemaComponentOptions) => TableSchemaComponent<Columns, TableName, Relationships>;
500
- 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) => ({
501
- schemaComponentKey: `sc:dumbo:column:${ColumnName}`;
502
- components: ReadonlyMap<string, SchemaComponent>;
503
- migrations: ReadonlyArray<SQLMigration>;
504
- addComponent: <SchemaComponentType extends SchemaComponent<string, Record<string, any>> = SchemaComponent<string, Record<string, any>>>(component: SchemaComponentType) => SchemaComponentType;
505
- addMigration: (migration: SQLMigration) => void;
506
- } & Readonly<{
507
- columnName: ColumnName;
508
- }> & {
509
- sqlTokenType: "SQL_COLUMN";
510
- } & Omit<{
511
- name: string;
512
- type: ColumnType;
513
- notNull?: false;
514
- unique?: boolean;
515
- primaryKey: never;
516
- default?: ColumnType | SQLToken;
517
- }, "sqlTokenType"> & (TOptions & {
518
- type: ColumnType;
519
- } extends infer T ? T extends TOptions & {
520
- type: ColumnType;
521
- } ? T extends {
522
- notNull: true;
523
- } | {
524
- primaryKey: true;
525
- } ? {
526
- notNull: true;
527
- } : {
528
- notNull?: false;
529
- } : never : never)) | ({
530
- schemaComponentKey: `sc:dumbo:column:${ColumnName}`;
531
- components: ReadonlyMap<string, SchemaComponent>;
532
- migrations: ReadonlyArray<SQLMigration>;
533
- addComponent: <SchemaComponentType extends SchemaComponent<string, Record<string, any>> = SchemaComponent<string, Record<string, any>>>(component: SchemaComponentType) => SchemaComponentType;
534
- addMigration: (migration: SQLMigration) => void;
535
- } & Readonly<{
536
- columnName: ColumnName;
537
- }> & {
538
- sqlTokenType: "SQL_COLUMN";
539
- } & Omit<NullableSQLColumnTokenProps<ColumnType>, "sqlTokenType"> & (TOptions & {
540
- type: ColumnType;
541
- } extends infer T_1 ? T_1 extends TOptions & {
542
- type: ColumnType;
543
- } ? T_1 extends {
544
- notNull: true;
545
- } | {
546
- primaryKey: true;
547
- } ? {
548
- notNull: true;
549
- } : {
550
- notNull?: false;
551
- } : never : never));
552
- index: (name: string, columnNames: string[], options?: {
553
- unique?: boolean;
554
- } & SchemaComponentOptions) => IndexSchemaComponent;
555
- };
556
- //#endregion
557
- //#region src/core/sql/tokenizedSQL/tokenizedSQL.d.ts
558
- type TokenizedSQL = Readonly<{
559
- __brand: 'tokenized-sql';
560
- sqlChunks: ReadonlyArray<string>;
561
- sqlTokens: ReadonlyArray<AnySQLToken>;
562
- }>;
563
- declare const TokenizedSQL: {
564
- (strings: ReadonlyArray<string>, values: unknown[]): TokenizedSQL;
565
- paramPlaceholder: string;
566
- empty: {
567
- __brand: "tokenized-sql";
568
- sqlChunks: string[];
569
- sqlTokens: never[];
570
- };
571
- };
572
- declare const isTokenizedSQL: (value: unknown) => value is TokenizedSQL;
573
- //#endregion
574
- //#region src/core/sql/sql.d.ts
575
- /** A tokenized SQL statement created with the {@link SQL} template tag. */
576
- type SQL = string & {
577
- __brand: 'sql';
578
- };
579
- type SQLTag = {
580
- /**
581
- * Creates a tokenized SQL statement.
582
- *
583
- * Interpolated values are treated as bound parameters by default. Use the
584
- * helper methods on `SQL` for SQL syntax that cannot be represented as a bound
585
- * parameter, such as identifiers or trusted raw fragments.
586
- */
587
- (strings: TemplateStringsArray, ...values: unknown[]): SQL; /** Empty SQL statement used when optional query fragments are absent. */
588
- EMPTY: SQL; /** Concatenates SQL fragments without adding a separator. */
589
- concat: (...sqls: SQL[]) => SQL;
590
- /**
591
- * Merges SQL fragments, skipping empty fragments and inserting a separator
592
- * between non-empty fragments.
593
- */
594
- merge: (sqls: SQL[], separator?: string) => SQL; /** Formats SQL into a parametrized query and params using the selected formatter. */
595
- format: (sql: SQL | SQL[], formatter: SQLFormatter, options?: FormatSQLOptions) => ParametrizedSQL; /** Formats SQL into a readable SQL string for diagnostics and migrations. */
596
- describe: (sql: SQL | SQL[], formatter: SQLFormatter, options?: FormatSQLOptions) => string; /** Creates a SQL `IN`/native-array token for the provided column and values. */
597
- in: (column: string, values: unknown[], options?: {
598
- mode?: SQLArrayMode;
599
- }) => SQLIn; /** Creates an array token that formatters can render as native or expanded params. */
600
- array: (values: unknown[], options?: {
601
- mode?: SQLArrayMode;
602
- }) => SQLArray; /** Creates a SQL identifier token, quoting it when required by SQL rules. */
603
- identifier: typeof SQLIdentifier.from;
604
- /**
605
- * Creates a trusted raw SQL fragment.
606
- *
607
- * This does not quote, escape, or bind the value. Prefer bound parameters for
608
- * data values, `SQL.identifier` for identifiers, and `SQL.literal` only when
609
- * SQL syntax requires an inline value literal.
610
- */
611
- plain: typeof SQLPlain.from;
612
- /**
613
- * Creates an inline SQL value literal.
614
- *
615
- * Use this for SQL syntax positions that cannot use bound parameters. Data
616
- * values in ordinary queries should stay as template interpolations.
617
- */
618
- literal: (value: string) => SQLPlain; /** Type guards and helpers for SQL tokens. */
619
- check: {
620
- isSQL: (value: unknown) => value is SQL;
621
- isTokenizedSQL: (value: unknown) => value is TokenizedSQL;
622
- isEmpty: (sql: SQL) => boolean;
623
- isIdentifier: typeof SQLIdentifier.check;
624
- isPlain: typeof SQLPlain.check;
625
- isSQLIn: typeof SQLIn.check;
626
- }; /** Creates a schema column token for SQL generation. */
627
- column: typeof SQLColumnToken.from & {
628
- /** Column type token factory. */type: typeof SQLColumnTypeTokensFactory;
629
- }; /** Creates a schema column token using Dumbo schema metadata. */
630
- columnN: typeof dumboSchema.column & {
631
- /** Column type token factory. */type: typeof SQLColumnTypeTokensFactory;
632
- };
633
- };
634
- /**
635
- * Creates SQL by interpolating values directly into the statement.
636
- *
637
- * Prefer {@link SQL} for query execution. `RawSQL` is for trusted SQL text that
638
- * is already safe to inline.
639
- */
640
- declare function RawSQL(strings: TemplateStringsArray, ...values: unknown[]): SQL;
641
- /** Returns true when the value is a tokenized SQL statement. */
642
- declare const isSQL: (value: unknown) => value is SQL;
643
- declare const SQL: SQLTag;
644
- //#endregion
645
- //#region src/core/sql/formatters/sqlFormatter.d.ts
646
- type FormatContext = Partial<SQLProcessorContext> & Pick<SQLProcessorContext, 'serializer'>;
647
- interface SQLFormatter {
648
- format: (sql: SQL | SQL[], context: FormatContext) => ParametrizedSQL;
649
- describe: (sql: SQL | SQL[], context: FormatContext) => string;
650
- valueMapper: SQLValueMapper;
651
- }
652
- type FormatSQLOptions = {
653
- mapper?: MapSQLParamValueOptions;
654
- processorsRegistry?: SQLProcessorsReadonlyRegistry;
655
- serializer?: JSONSerializer;
656
- };
657
- type SQLFormatterOptions = Partial<Omit<SQLFormatter, 'valueMapper'>> & {
658
- valueMapper?: MapSQLParamValueOptions;
659
- processorsRegistry?: SQLProcessorsReadonlyRegistry;
660
- };
661
- declare const SQLFormatter: ({
662
- format,
663
- describe,
664
- valueMapper: valueMapperOptions,
665
- processorsRegistry
666
- }: SQLFormatterOptions) => SQLFormatter;
667
- declare global {
668
- var dumboSQLFormatters: Record<string, SQLFormatter>;
669
- }
670
- declare const registerFormatter: (dialect: string, formatter: SQLFormatter) => void;
671
- declare const getFormatter: (dialect: string) => SQLFormatter;
672
- declare function formatSQL(sql: SQL | SQL[], formatter: SQLFormatter, serializer: JSONSerializer, context?: FormatSQLOptions): ParametrizedSQL;
673
- declare const describeSQL: (sql: SQL | SQL[], formatter: SQLFormatter, serializer: JSONSerializer, options?: FormatSQLOptions) => string;
674
- //#endregion
675
- //#region src/core/sql/parameters/jsonParam.d.ts
676
- declare const JSONParam: {
677
- readonly arrayContaining: (jsonValue: unknown, serializer: JSONSerializer) => string;
678
- readonly document: (document: unknown, serializer: JSONSerializer) => string;
679
- readonly value: (jsonValue: unknown, serializer: JSONSerializer) => string;
680
- };
681
- //#endregion
682
- //#region src/core/schema/components/columnSchemaComponent.d.ts
683
- type ColumnURNType = 'sc:dumbo:column';
684
- type ColumnURN<ColumnName extends string = string> = `${ColumnURNType}:${ColumnName}`;
685
- declare const ColumnURNType: ColumnURNType;
686
- declare const ColumnURN: <ColumnName extends string = string>({
687
- name
688
- }: {
689
- name: ColumnName;
690
- }) => ColumnURN<ColumnName>;
691
- type ColumnSchemaComponent<ColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string, ColumnName extends string = string> = SchemaComponent<ColumnURN<ColumnName>, Readonly<{
692
- columnName: ColumnName;
693
- }>> & SQLColumnToken<ColumnType>;
694
- type AnyColumnSchemaComponent = ColumnSchemaComponent<any>;
695
- type ColumnSchemaComponentOptions<ColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string> = Omit<SQLColumnToken<ColumnType>, 'name' | 'sqlTokenType'> & SchemaComponentOptions;
696
- declare const columnSchemaComponent: <const ColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string, const TOptions extends ColumnSchemaComponentOptions<ColumnType> = ColumnSchemaComponentOptions<ColumnType>, const ColumnName extends string = string>(params: {
697
- columnName: ColumnName;
698
- } & TOptions) => ColumnSchemaComponent<ColumnType, ColumnName> & (TOptions extends {
699
- notNull: true;
700
- } | {
701
- primaryKey: true;
702
- } ? {
703
- notNull: true;
704
- } : {
705
- notNull?: false;
706
- });
707
- //#endregion
708
- //#region src/core/schema/components/indexSchemaComponent.d.ts
709
- type IndexURNType = 'sc:dumbo:index';
710
- type IndexURN = `${IndexURNType}:${string}`;
711
- type IndexSchemaComponent = SchemaComponent<IndexURN, Readonly<{
712
- indexName: string;
713
- columnNames: ReadonlyArray<string>;
714
- isUnique: boolean;
715
- addColumn: (column: string | ColumnSchemaComponent) => void;
716
- }>>;
717
- declare const IndexURNType: IndexURNType;
718
- declare const IndexURN: ({
719
- name
720
- }: {
721
- name: string;
722
- }) => IndexURN;
723
- declare const indexSchemaComponent: ({
724
- indexName,
725
- columnNames,
726
- isUnique,
727
- ...migrationsOrComponents
728
- }: {
729
- indexName: string;
730
- columnNames: string[];
731
- isUnique: boolean;
732
- } & SchemaComponentOptions) => IndexSchemaComponent;
733
- //#endregion
734
- //#region src/core/typing/conditionals.d.ts
735
- type IF<Condition extends boolean, Then, Else> = Condition extends true ? Then : Else;
736
- type AND<A extends boolean, B extends boolean> = A extends true ? B extends true ? true : false : false;
737
- type ALL<A extends boolean[]> = A extends [infer First, ...infer Rest] ? First extends true ? Rest extends boolean[] ? ALL<Rest> : true : false : true;
738
- //#endregion
739
- //#region src/core/typing/records.d.ts
740
- type KeysOfString<T extends Record<string, unknown>> = Extract<keyof T, string>;
741
- //#endregion
742
- //#region src/core/typing/validation.d.ts
743
- type TypeValidationResult<Valid extends boolean = boolean, Error = never> = Valid extends true ? {
744
- valid: true;
745
- } : {
746
- valid: false;
747
- error: Error;
748
- };
749
- type TypeValidationError<Error> = TypeValidationResult<false, Error>;
750
- type TypeValidationSuccess = TypeValidationResult<true>;
751
- type AnyTypeValidationError = TypeValidationError<any>;
752
- type AnyTypeValidationResult = TypeValidationResult<boolean, any>;
753
- type AnyTypeValidationFailed<Results = AnyTypeValidationResult[]> = Results extends readonly [infer First, ...infer Rest] ? First extends {
754
- valid: false;
755
- } ? true : Rest extends AnyTypeValidationResult[] ? AnyTypeValidationFailed<Rest> : false : false;
756
- 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> : [] : [];
757
- 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;
758
- //#endregion
759
- //#region src/core/typing/tuples.d.ts
760
- type GetTupleLength<T extends readonly unknown[]> = T['length'];
761
- type NotEmptyTuple<T extends readonly unknown[]> = GetTupleLength<T> extends 0 ? never : T;
762
- type HaveTuplesTheSameLength<T extends readonly unknown[], U extends readonly unknown[]> = GetTupleLength<T> extends GetTupleLength<U> ? true : false;
763
- type IsEmptyTuple<T extends readonly unknown[]> = T extends [] ? true : false;
764
- type IsNotEmptyTuple<T extends readonly unknown[]> = IsEmptyTuple<T> extends true ? false : true;
765
- 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>] : [];
766
- type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
767
- type LastOfUnion<T> = UnionToIntersection<T extends any ? () => T : never> extends (() => infer R) ? R : never;
768
- type UnionToTuple<T, L = LastOfUnion<T>> = [T] extends [never] ? [] : [...UnionToTuple<Exclude<T, L>>, L];
769
- 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;
770
- 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;
771
- //#endregion
772
- //#region src/core/schema/components/relationships/relationshipTypes.d.ts
773
- type ExtractSchemaNames<DB> = DB extends DatabaseSchemaComponent<infer Schemas extends DatabaseSchemas> ? keyof Schemas : never;
774
- type ExtractTableNames<Schema extends AnyDatabaseSchemaSchemaComponent> = Schema extends DatabaseSchemaSchemaComponent<infer Tables extends DatabaseSchemaTables> ? keyof Tables : never;
775
- type ExtractColumnNames<Table extends AnyTableSchemaComponent> = Table extends TableSchemaComponent<infer Columns extends TableColumns> ? TableColumnNames<TableSchemaComponent<Columns>> : never;
776
- type ExtractColumnTypeName<T> = T extends ColumnTypeToken<any, infer TypeName, any, any> ? Uppercase<TypeName> : never;
777
- 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]: {
778
- columnTypeName: ExtractColumnTypeName<Columns[ColumnName$1]['type']>;
779
- } }> : never }> : never };
780
- 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];
781
- type AllColumnTypesInSchema<Schema extends AnyDatabaseSchemaSchemaComponent> = Schema extends DatabaseSchemaSchemaComponent<infer Tables> ? { [TableName in keyof Tables]: Tables[TableName] extends TableSchemaComponent<infer Columns> ? { [ColumnName in keyof Columns]: {
782
- columnTypeName: ExtractColumnTypeName<Columns[ColumnName$1]['type']>;
783
- } } : never } : never;
784
- 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;
785
- 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;
786
- 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 [];
787
- type ColumnName$1<ColName extends string = string> = `${ColName}`;
788
- type TableColumnName<TableName extends string = string, ColName extends string = string> = `${TableName}.${ColName}`;
789
- type SchemaColumnName<SchemaName extends string = string, TableName extends string = string, ColumnName extends string = string> = `${SchemaName}.${TableName}.${ColumnName}`;
790
- type ColumnPath<SchemaName extends string = string, TableName extends string = string, ColName extends string = string> = SchemaColumnName<SchemaName, TableName, ColName> | TableColumnName<TableName, ColName> | ColumnName$1<ColName>;
791
- type ColumnReference<SchemaName extends string = string, TableName extends string = string, ColumnName extends string = string> = {
792
- schemaName: SchemaName;
793
- tableName: TableName;
794
- columnName: ColumnName;
795
- };
796
- 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}` ? {
797
- schemaName: S;
798
- tableName: T;
799
- columnName: C;
800
- } : never;
801
- type ParseReferencePath<Path extends string> = Path extends `${infer Schema}.${infer Table}.${infer Column}` ? {
802
- schema: Schema;
803
- table: Table;
804
- column: Column;
805
- } : never;
806
- type LookupColumnType<AllTypes, Path extends string> = ParseReferencePath<Path> extends {
807
- schema: infer S;
808
- table: infer T;
809
- column: infer C;
810
- } ? S extends keyof AllTypes ? T extends keyof AllTypes[S] ? C extends keyof AllTypes[S][T] ? AllTypes[S][T][C] extends {
811
- columnTypeName: infer TypeName;
812
- } ? TypeName : never : never : never : never : never;
813
- type RelationshipType = 'one-to-one' | 'one-to-many' | 'many-to-one' | 'many-to-many';
814
- type RelationshipDefinition<Columns extends string = string, Reference extends string = string, RelType extends RelationshipType = RelationshipType> = {
815
- readonly columns: NotEmptyTuple<readonly Columns[]>;
816
- readonly references: NotEmptyTuple<readonly Reference[]>;
817
- readonly type: RelType;
818
- };
819
- type AnyTableRelationshipDefinition = RelationshipDefinition<any, any, any>;
820
- type AnyTableRelationshipDefinitionWithColumns<Columns extends string = string> = RelationshipDefinition<Columns, any, any>;
821
- type TableRelationships<Columns extends string = string> = Record<string, AnyTableRelationshipDefinitionWithColumns<Columns>>;
822
- declare const relationship: <const Columns extends readonly string[], const References extends readonly string[], const RelType extends RelationshipType = RelationshipType>(columns: Columns, references: References, type: RelType) => {
823
- readonly columns: Columns;
824
- readonly references: References;
825
- readonly type: RelType;
826
- };
827
- type AnyRelationshipDefinition = RelationshipDefinition<any, any, any>;
828
- //#endregion
829
- //#region src/core/schema/components/tableTypesInference.d.ts
830
- type Writable<T> = { -readonly [P in keyof T]: T[P] };
831
- type InferColumnType<ColumnType> = ColumnType extends ColumnTypeToken<infer _JSType, infer _ColumnTypeName, infer _TProps, infer ValueType> ? ValueType : ColumnType;
832
- type TableColumnType<T extends AnyColumnSchemaComponent> = T extends ColumnSchemaComponent<infer ColumnType> ? T extends {
833
- notNull: true;
834
- } | {
835
- primaryKey: true;
836
- } ? InferColumnType<ColumnType> : InferColumnType<ColumnType> | null : unknown;
837
- type TableColumnNames<T extends AnyTableSchemaComponent> = Exclude<keyof T['columns'], keyof ReadonlyMap<string, AnyColumnSchemaComponent>>;
838
- type InferTableRow<Columns extends TableColumns> = Writable<{ [K in keyof Columns]: TableColumnType<Columns[K]> }>;
839
- type TableRowType<T extends AnyTableSchemaComponent> = T extends TableSchemaComponent<infer Columns> ? InferTableRow<Columns> : never;
840
- type InferSchemaTables<T extends AnyDatabaseSchemaSchemaComponent> = T extends DatabaseSchemaSchemaComponent<infer Tables> ? Tables : never;
841
- type InferDatabaseSchemas<T extends AnyDatabaseSchemaComponent> = T extends DatabaseSchemaComponent<infer Schemas> ? Schemas : never;
842
- //#endregion
843
- //#region src/core/schema/components/tableSchemaComponent.d.ts
844
- type TableURNType = 'sc:dumbo:table';
845
- type TableURN = `${TableURNType}:${string}`;
846
- declare const TableURNType: TableURNType;
847
- declare const TableURN: ({
848
- name
849
- }: {
850
- name: string;
851
- }) => TableURN;
852
- type TableColumns = Record<string, AnyColumnSchemaComponent>;
853
- type TableSchemaComponent<Columns extends TableColumns = TableColumns, TableName extends string = string, Relationships extends TableRelationships<keyof Columns & string> = {} & TableRelationships<keyof Columns & string>> = SchemaComponent<TableURN, Readonly<{
854
- tableName: TableName;
855
- columns: ReadonlyMap<string, AnyColumnSchemaComponent> & Columns;
856
- primaryKey: TableColumnNames<TableSchemaComponent<Columns, TableName, Relationships>>[];
857
- relationships: Relationships;
858
- indexes: ReadonlyMap<string, IndexSchemaComponent>;
859
- addColumn: (column: AnyColumnSchemaComponent) => AnyColumnSchemaComponent;
860
- addIndex: (index: IndexSchemaComponent) => IndexSchemaComponent;
861
- }>>;
862
- type InferTableSchemaComponentTypes<T extends AnyTableSchemaComponent> = T extends TableSchemaComponent<infer Columns, infer TableName, infer Relationships> ? [Columns, TableName, Relationships] : never;
863
- type InferTableSchemaComponentColumns<T extends AnyTableSchemaComponent> = InferTableSchemaComponentTypes<T>[0];
864
- type AnyTableSchemaComponent = TableSchemaComponent<any, any, any>;
865
- declare const tableSchemaComponent: <const Columns extends TableColumns = TableColumns, const TableName extends string = string, const Relationships extends TableRelationships<keyof Columns & string> = {}>({
866
- tableName,
867
- columns,
868
- primaryKey,
869
- relationships,
870
- ...migrationsOrComponents
871
- }: {
872
- tableName: TableName;
873
- columns?: Columns;
874
- primaryKey?: TableColumnNames<TableSchemaComponent<Columns, TableName, Relationships>>[];
875
- relationships?: Relationships;
876
- } & SchemaComponentOptions) => TableSchemaComponent<Columns, TableName, Relationships> & {
877
- relationships: Relationships;
878
- };
879
- //#endregion
880
- //#region src/core/schema/components/databaseSchemaSchemaComponent.d.ts
881
- type DatabaseSchemaURNType = 'sc:dumbo:database_schema';
882
- type DatabaseSchemaURN<SchemaName extends string = string> = `${DatabaseSchemaURNType}:${SchemaName}`;
883
- declare const DatabaseSchemaURNType: DatabaseSchemaURNType;
884
- declare const DatabaseSchemaURN: <SchemaName extends string = string>({
885
- name
886
- }: {
887
- name: SchemaName;
888
- }) => DatabaseSchemaURN<SchemaName>;
889
- type DatabaseSchemaTables<Tables extends AnyTableSchemaComponent = AnyTableSchemaComponent> = Record<string, Tables>;
890
- type DatabaseSchemaSchemaComponent<Tables extends DatabaseSchemaTables = DatabaseSchemaTables, SchemaName extends string = string> = SchemaComponent<DatabaseSchemaURN<SchemaName>, Readonly<{
891
- schemaName: SchemaName;
892
- tables: ReadonlyMap<string, TableSchemaComponent> & Tables;
893
- addTable: (table: string | TableSchemaComponent) => TableSchemaComponent;
894
- }>>;
895
- type AnyDatabaseSchemaSchemaComponent = DatabaseSchemaSchemaComponent<any, any>;
896
- declare const databaseSchemaSchemaComponent: <const Tables extends DatabaseSchemaTables = DatabaseSchemaTables, const SchemaName extends string = string>({
897
- schemaName,
898
- tables,
899
- ...migrationsOrComponents
900
- }: {
901
- schemaName: SchemaName;
902
- tables?: Tables;
903
- } & SchemaComponentOptions) => DatabaseSchemaSchemaComponent<Tables, SchemaName>;
904
- //#endregion
905
- //#region src/core/schema/components/databaseSchemaComponent.d.ts
906
- type DatabaseURNType = 'sc:dumbo:database';
907
- type DatabaseURN = `${DatabaseURNType}:${string}`;
908
- declare const DatabaseURNType: DatabaseURNType;
909
- declare const DatabaseURN: ({
910
- name
911
- }: {
912
- name: string;
913
- }) => DatabaseURN;
914
- type DatabaseSchemas<Schemas extends AnyDatabaseSchemaSchemaComponent = AnyDatabaseSchemaSchemaComponent> = Record<string, Schemas>;
915
- type DatabaseSchemaComponent<Schemas extends DatabaseSchemas = DatabaseSchemas> = SchemaComponent<DatabaseURN, Readonly<{
916
- databaseName: string;
917
- schemas: ReadonlyMap<string, DatabaseSchemaSchemaComponent> & Schemas;
918
- addSchema: (schema: string | DatabaseSchemaSchemaComponent) => DatabaseSchemaSchemaComponent;
919
- }>>;
920
- type AnyDatabaseSchemaComponent = DatabaseSchemaComponent<any>;
921
- declare const databaseSchemaComponent: <Schemas extends DatabaseSchemas = DatabaseSchemas>({
922
- databaseName,
923
- schemas,
924
- ...migrationsOrComponents
925
- }: {
926
- databaseName: string;
927
- schemas?: Schemas;
928
- } & SchemaComponentOptions) => DatabaseSchemaComponent<Schemas>;
929
- //#endregion
930
- //#region src/core/schema/components/relationships/formatRelationshipErrors.d.ts
931
- 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>}` : '';
932
- type IndentErrors<Messages extends readonly string[]> = Messages extends readonly [infer First extends string, ...infer Rest extends readonly string[]] ? [` - ${First}`, ...IndentErrors<Rest>] : [];
933
- type ExtractSchemaFromReference<T extends string> = T extends `${infer Schema}.${string}.${string}` ? Schema : never;
934
- type ExtractTableFromReference<T extends string> = T extends `${string}.${infer Table}.${string}` ? Table : never;
935
- type ExtractColumnFromReference<T extends string> = T extends `${string}.${string}.${infer Column}` ? Column : never;
936
- type TupleLength<T extends readonly unknown[]> = T extends {
937
- length: infer L;
938
- } ? L : never;
939
- type FormatSingleError<E> = E extends {
940
- errorCode: 'reference_columns_mismatch';
941
- invalidColumns: infer InvalidCols extends readonly string[];
942
- availableColumns: infer AvailableCols extends readonly string[];
943
- } ? `Invalid columns: ${Join<InvalidCols, ', '>}. Available columns: ${Join<AvailableCols, ', '>}` : E extends {
944
- errorCode: 'reference_length_mismatch';
945
- columns: infer Cols extends readonly string[];
946
- references: infer Refs extends readonly string[];
947
- } ? `Column count mismatch: ${TupleLength<Cols>} columns ([${Join<Cols, ', '>}]) but ${TupleLength<Refs>} references ([${Join<Refs, ', '>}])` : E extends {
948
- errorCode: 'missing_schema';
949
- reference: infer Ref extends string;
950
- } ? `Schema "${ExtractSchemaFromReference<Ref>}" does not exist (${Ref})` : E extends {
951
- errorCode: 'missing_table';
952
- reference: infer Ref extends string;
953
- } ? `Table "${ExtractTableFromReference<Ref>}" does not exist in schema "${ExtractSchemaFromReference<Ref>}" (${Ref})` : E extends {
954
- errorCode: 'missing_column';
955
- reference: infer Ref extends string;
956
- } ? `Column "${ExtractColumnFromReference<Ref>}" does not exist in table "${ExtractSchemaFromReference<Ref>}.${ExtractTableFromReference<Ref>}" (${Ref})` : E extends {
957
- errorCode: 'type_mismatch';
958
- reference: infer Ref extends string;
959
- referenceType: infer RefType extends string;
960
- columnTypeName: infer ColType extends string;
961
- } ? `Type mismatch: column type "${ColType}" does not match referenced column type "${RefType}" (${Ref})` : never;
962
- type FormatErrorMessages<Errors extends readonly unknown[]> = Errors extends readonly [infer First, ...infer Rest extends readonly unknown[]] ? [FormatSingleError<First>, ...FormatErrorMessages<Rest>] : [];
963
- type FormatRelationshipBlock<E> = E extends {
964
- relationship: infer RelName extends string;
965
- errors: infer Errors extends readonly unknown[];
966
- } ? Join<[`Relationship "${RelName}":`, ...IndentErrors<FormatErrorMessages<Errors>>], '\n'> : never;
967
- type IndentLine<Line extends string> = ` ${Line}`;
968
- type IndentRelationshipBlock<Block extends string> = Block extends `${infer FirstLine}\n${infer Rest}` ? `${IndentLine<FirstLine>}\n${IndentRelationshipBlock<Rest>}` : IndentLine<Block>;
969
- 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>}` : '';
970
- type FormatTableLevel<E> = E extends {
971
- table: infer TableName extends string;
972
- errors: infer RelErrors extends readonly unknown[];
973
- } ? `Table "${TableName}":\n${FormatRelationshipBlocks<RelErrors>}` : never;
974
- type IndentTableBlock<Block extends string> = Block extends `${infer FirstLine}\n${infer Rest}` ? ` ${FirstLine}\n${IndentTableBlock<Rest>}` : ` ${Block}`;
975
- 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>}` : '';
976
- type FormatSchemaLevel<E> = E extends {
977
- schema: infer SchemaName extends string;
978
- errors: infer TableErrors extends readonly unknown[];
979
- } ? `Schema "${SchemaName}":\n${FormatTableBlocks<TableErrors>}` : never;
980
- 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>}` : '';
981
- type FormatDatabaseValidationErrors<Errors extends readonly unknown[]> = FormatSchemaBlocks<Errors>;
982
- type FormatValidationErrors<Result> = Result extends {
983
- valid: false;
984
- error: infer Errors extends readonly unknown[];
985
- } ? `Relationship validation errors:\n\n${FormatDatabaseValidationErrors<Errors>}` : never;
986
- //#endregion
987
- //#region src/core/schema/components/relationships/relationshipValidation.d.ts
988
- type RelationshipColumnsMismatchError<ColumnPath extends SchemaColumnName = SchemaColumnName> = {
989
- valid: false;
990
- error: {
991
- errorCode: 'reference_columns_mismatch';
992
- invalidColumns: ColumnPath[];
993
- availableColumns: ColumnPath[];
994
- };
995
- };
996
- type RelationshipReferencesLengthMismatchError<ColumnPath extends SchemaColumnName = SchemaColumnName> = {
997
- valid: false;
998
- error: {
999
- errorCode: 'reference_length_mismatch';
1000
- columns: ColumnPath[];
1001
- references: ColumnPath[];
1002
- };
1003
- };
1004
- type ColumnReferenceExistanceError<ErrorCode extends 'missing_schema' | 'missing_table' | 'missing_column' = 'missing_schema' | 'missing_table' | 'missing_column', ColumnPath extends SchemaColumnName = SchemaColumnName> = {
1005
- valid: false;
1006
- error: {
1007
- errorCode: ErrorCode;
1008
- reference: ColumnPath;
1009
- };
1010
- };
1011
- type ColumnReferenceTypeMismatchError<Reference extends SchemaColumnName = SchemaColumnName, ReferenceTypeName extends string = string, ColumnTypeName extends string = string> = {
1012
- valid: false;
1013
- error: {
1014
- errorCode: 'type_mismatch';
1015
- reference: Reference;
1016
- referenceType: ReferenceTypeName;
1017
- columnTypeName: ColumnTypeName;
1018
- };
1019
- };
1020
- type NoError = TypeValidationSuccess;
1021
- type ColumnReferenceError = ColumnReferenceExistanceError | ColumnReferenceTypeMismatchError;
1022
- type RelationshipValidationError = RelationshipColumnsMismatchError | RelationshipReferencesLengthMismatchError | ColumnReferenceError;
1023
- type ValidateRelationshipLength<Rel extends AnyTableRelationshipDefinition> = IF<ALL<[HaveTuplesTheSameLength<Rel['columns'], Rel['references']>, IsNotEmptyTuple<Rel['columns']>, IsNotEmptyTuple<Rel['references']>]>, TypeValidationSuccess, TypeValidationResult<false, {
1024
- errorCode: 'reference_length_mismatch';
1025
- columns: Rel['columns'];
1026
- references: Rel['references'];
1027
- }>>;
1028
- 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, {
1029
- errorCode: 'reference_columns_mismatch';
1030
- invalidColumns: InvalidColumns;
1031
- availableColumns: KeysOfString<ValidColumns>;
1032
- }>> : TypeValidationSuccess;
1033
- 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;
1034
- 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>>;
1035
- 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;
1036
- 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 {
1037
- valid: false;
1038
- error: infer E;
1039
- } ? TypeValidationError<E> : never : never : never;
1040
- 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 {
1041
- valid: false;
1042
- error: infer E;
1043
- } ? TypeValidationError<E> : never : never : never;
1044
- 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>;
1045
- type SchemaTablesWithSingle<Table extends AnyTableSchemaComponent> = Table extends TableSchemaComponent<infer _Columns, infer TableName, infer _FKs> ? DatabaseSchemaSchemaComponent<{ [K in TableName]: Table }> : never;
1046
- type DatabaseSchemasWithSingle<Schema extends AnyDatabaseSchemaSchemaComponent> = Schema extends DatabaseSchemaSchemaComponent<infer _Tables, infer _SchemaName> ? { [K in _SchemaName]: Schema } : never;
1047
- 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<{
1048
- relationship: RelationshipName;
1049
- errors: Error extends TypeValidationError<infer E> ? E extends readonly unknown[] ? E : [E] : never;
1050
- }> : TypeValidationSuccess;
1051
- 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>;
1052
- 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<{
1053
- table: TableName;
1054
- errors: UnwrapTypeValidationErrors<Results extends readonly AnyTypeValidationError[] ? Results : never>;
1055
- }> : Results : TypeValidationSuccess : TypeValidationSuccess : TypeValidationSuccess;
1056
- type ValidateTable<Table extends AnyTableSchemaComponent, Schema extends AnyDatabaseSchemaSchemaComponent = SchemaTablesWithSingle<Table>, Schemas extends DatabaseSchemas = DatabaseSchemasWithSingle<Schema>> = ValidateTableRelationships<Table, Schema, Schemas>;
1057
- 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<{
1058
- schema: SchemaName;
1059
- errors: UnwrapTypeValidationErrors<Results extends readonly AnyTypeValidationError[] ? Results : never>;
1060
- }> : TypeValidationSuccess : TypeValidationSuccess;
1061
- type ValidateDatabaseSchema<Schema extends AnyDatabaseSchemaSchemaComponent, Schemas extends DatabaseSchemas = DatabaseSchemasWithSingle<Schema>> = Schema extends DatabaseSchemaSchemaComponent<infer Tables, infer SchemaName> ? ValidateSchemaTables<Tables, SchemaName, Schema, Schemas> : TypeValidationSuccess;
1062
- 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;
1063
- type ValidateDatabaseSchemasWithMessages<Schemas extends DatabaseSchemas> = FormatValidationErrors<ValidateDatabaseSchemas<Schemas>>;
1064
- //#endregion
1065
- //#region src/core/schema/components/index.d.ts
1066
- declare const schemaComponentURN: {
1067
- readonly database: ({
1068
- name
1069
- }: {
1070
- name: string;
1071
- }) => DatabaseURN;
1072
- readonly schema: <SchemaName extends string = string>({
1073
- name
1074
- }: {
1075
- name: SchemaName;
1076
- }) => DatabaseSchemaURN<SchemaName>;
1077
- readonly table: ({
1078
- name
1079
- }: {
1080
- name: string;
1081
- }) => TableURN;
1082
- readonly column: <ColumnName extends string = string>({
1083
- name
1084
- }: {
1085
- name: ColumnName;
1086
- }) => ColumnURN<ColumnName>;
1087
- readonly index: ({
1088
- name
1089
- }: {
1090
- name: string;
1091
- }) => IndexURN;
1092
- readonly extractName: (urn: string) => string;
1093
- };
1094
- //#endregion
1095
- //#region src/core/errors/index.d.ts
1096
- declare class DumboError extends Error {
1097
- static readonly ErrorCode: number;
1098
- static readonly ErrorType: string;
1099
- errorCode: number;
1100
- errorType: string;
1101
- innerError: Error | undefined;
1102
- constructor(options?: {
1103
- errorCode: number;
1104
- errorType?: string;
1105
- message?: string | undefined;
1106
- innerError?: Error | undefined;
1107
- } | string | number);
1108
- static isInstanceOf<ErrorType extends DumboError = DumboError>(error: unknown, options?: {
1109
- errorCode?: number;
1110
- errorType?: string;
1111
- }): error is ErrorType;
1112
- }
1113
- declare class ConcurrencyError extends DumboError {
1114
- static readonly ErrorCode: number;
1115
- static readonly ErrorType: string;
1116
- constructor(message?: string, innerError?: Error);
1117
- }
1118
- declare class TransientDatabaseError extends DumboError {
1119
- static readonly ErrorCode: number;
1120
- static readonly ErrorType: string;
1121
- constructor(message?: string, innerError?: Error);
1122
- }
1123
- declare class ConnectionError extends TransientDatabaseError {
1124
- static readonly ErrorCode: number;
1125
- static readonly ErrorType: string;
1126
- constructor(message?: string, innerError?: Error);
1127
- }
1128
- declare class SerializationError extends TransientDatabaseError {
1129
- static readonly ErrorCode: number;
1130
- static readonly ErrorType: string;
1131
- constructor(message?: string, innerError?: Error);
1132
- }
1133
- declare class DeadlockError extends TransientDatabaseError {
1134
- static readonly ErrorCode: number;
1135
- static readonly ErrorType: string;
1136
- constructor(message?: string, innerError?: Error);
1137
- }
1138
- declare class LockNotAvailableError extends TransientDatabaseError {
1139
- static readonly ErrorCode: number;
1140
- static readonly ErrorType: string;
1141
- constructor(message?: string, innerError?: Error);
1142
- }
1143
- declare class InsufficientResourcesError extends TransientDatabaseError {
1144
- static readonly ErrorCode: number;
1145
- static readonly ErrorType: string;
1146
- constructor(message?: string, innerError?: Error);
1147
- }
1148
- declare class SystemError extends TransientDatabaseError {
1149
- static readonly ErrorCode: number;
1150
- static readonly ErrorType: string;
1151
- constructor(message?: string, innerError?: Error);
1152
- }
1153
- declare class AdminShutdownError extends TransientDatabaseError {
1154
- static readonly ErrorCode: number;
1155
- static readonly ErrorType: string;
1156
- constructor(message?: string, innerError?: Error);
1157
- }
1158
- declare class QueryCanceledError extends TransientDatabaseError {
1159
- static readonly ErrorCode: number;
1160
- static readonly ErrorType: string;
1161
- constructor(message?: string, innerError?: Error);
1162
- }
1163
- declare class IntegrityConstraintViolationError extends DumboError {
1164
- static readonly ErrorCode: number;
1165
- static readonly ErrorType: string;
1166
- constructor(message?: string, innerError?: Error);
1167
- }
1168
- declare class UniqueConstraintError extends IntegrityConstraintViolationError {
1169
- static readonly ErrorCode: number;
1170
- static readonly ErrorType: string;
1171
- constructor(message?: string, innerError?: Error);
1172
- }
1173
- declare class ForeignKeyViolationError extends IntegrityConstraintViolationError {
1174
- static readonly ErrorCode: number;
1175
- static readonly ErrorType: string;
1176
- constructor(message?: string, innerError?: Error);
1177
- }
1178
- declare class NotNullViolationError extends IntegrityConstraintViolationError {
1179
- static readonly ErrorCode: number;
1180
- static readonly ErrorType: string;
1181
- constructor(message?: string, innerError?: Error);
1182
- }
1183
- declare class CheckViolationError extends IntegrityConstraintViolationError {
1184
- static readonly ErrorCode: number;
1185
- static readonly ErrorType: string;
1186
- constructor(message?: string, innerError?: Error);
1187
- }
1188
- declare class ExclusionViolationError extends IntegrityConstraintViolationError {
1189
- static readonly ErrorCode: number;
1190
- static readonly ErrorType: string;
1191
- constructor(message?: string, innerError?: Error);
1192
- }
1193
- declare class DataError extends DumboError {
1194
- static readonly ErrorCode: number;
1195
- static readonly ErrorType: string;
1196
- constructor(message?: string, innerError?: Error);
1197
- }
1198
- declare class InvalidOperationError extends DumboError {
1199
- static readonly ErrorCode: number;
1200
- static readonly ErrorType: string;
1201
- constructor(message?: string, innerError?: Error);
1202
- }
1203
- //#endregion
1204
- //#region src/core/query/query.d.ts
1205
- interface QueryResultRow {
1206
- [column: string]: any;
1207
- }
1208
- type QueryResult<Result extends QueryResultRow = QueryResultRow> = {
1209
- rowCount: number | null;
1210
- rows: Result[];
1211
- };
1212
- //#endregion
1213
- //#region src/core/query/mappers.d.ts
1214
- declare const mapRows: <Result extends QueryResultRow = QueryResultRow, Mapped = unknown>(getResult: Promise<QueryResult<Result>>, map: (row: Result) => Mapped) => Promise<Mapped[]>;
1215
- declare const toCamelCase: (snakeStr: string) => string;
1216
- declare const mapToCamelCase: <T extends Record<string, unknown>>(obj: Record<string, unknown>) => T;
1217
- //#endregion
1218
- //#region src/core/query/selectors.d.ts
1219
- declare const firstOrNull: <Result extends QueryResultRow = QueryResultRow>(getResult: Promise<QueryResult<Result>>) => Promise<Result | null>;
1220
- declare const first: <Result extends QueryResultRow = QueryResultRow>(getResult: Promise<QueryResult<Result>>) => Promise<Result>;
1221
- declare const singleOrNull: <Result extends QueryResultRow = QueryResultRow>(getResult: Promise<QueryResult<Result>>) => Promise<Result | null>;
1222
- declare const single: <Result extends QueryResultRow = QueryResultRow>(getResult: Promise<QueryResult<Result>>) => Promise<Result>;
1223
- type CountSQLQueryResult = {
1224
- count: number;
1225
- };
1226
- declare const count: (getResult: Promise<QueryResult<CountSQLQueryResult>>) => Promise<number>;
1227
- type ExistsSQLQueryResult = {
1228
- exists: boolean | 1 | 0;
1229
- };
1230
- declare const exists: (getResult: Promise<QueryResult<ExistsSQLQueryResult>>) => Promise<boolean>;
1231
- //#endregion
1232
- //#region src/core/execute/execute.d.ts
1233
- declare const mapColumnToJSON: (column: string, serializer: JSONSerializer, options?: JSONDeserializeOptions) => {
1234
- [x: string]: (value: unknown) => unknown;
1235
- };
1236
- declare const mapColumnToBigint: (column: string) => {
1237
- [x: string]: (value: unknown) => unknown;
1238
- };
1239
- declare const mapColumnToDate: (column: string) => {
1240
- [x: string]: (value: unknown) => unknown;
1241
- };
1242
- declare const mapSQLQueryResult: <T>(result: T, mapping: SQLQueryResultColumnMapping) => T;
1243
- type SQLQueryResultColumnMapping = {
1244
- [column: string]: (value: unknown) => unknown;
1245
- };
1246
- type SQLQueryOptions = {
1247
- timeoutMs?: number | undefined;
1248
- mapping?: SQLQueryResultColumnMapping;
1249
- };
1250
- type SQLCommandOptions = {
1251
- timeoutMs?: number | undefined;
1252
- mapping?: SQLQueryResultColumnMapping;
1253
- };
1254
- type BatchSQLCommandOptions = SQLCommandOptions & {
1255
- assertChanges?: boolean;
1256
- };
1257
- declare class BatchCommandNoChangesError extends DumboError {
1258
- static readonly ErrorCode: number;
1259
- static readonly ErrorType: string;
1260
- readonly statementIndex: number;
1261
- constructor(statementIndex: number);
1262
- }
1263
- type DbSQLExecutorOptions = {
1264
- serializer: JSONSerializer;
1265
- };
1266
- interface DbSQLExecutor<DriverType extends DatabaseDriverType = DatabaseDriverType, DbClient = unknown> {
1267
- driverType: DriverType;
1268
- query<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sql: SQL, options?: SQLQueryOptions): Promise<QueryResult<Result>>;
1269
- batchQuery<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sqls: SQL[], options?: SQLQueryOptions): Promise<QueryResult<Result>[]>;
1270
- command<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sql: SQL, options?: SQLCommandOptions): Promise<QueryResult<Result>>;
1271
- batchCommand<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sqls: SQL[], options?: BatchSQLCommandOptions): Promise<QueryResult<Result>[]>;
1272
- formatter: SQLFormatter;
1273
- }
1274
- interface SQLExecutor {
1275
- query<Result extends QueryResultRow = QueryResultRow>(sql: SQL, options?: SQLQueryOptions): Promise<QueryResult<Result>>;
1276
- batchQuery<Result extends QueryResultRow = QueryResultRow>(sqls: SQL[], options?: SQLQueryOptions): Promise<QueryResult<Result>[]>;
1277
- command<Result extends QueryResultRow = QueryResultRow>(sql: SQL, options?: SQLCommandOptions): Promise<QueryResult<Result>>;
1278
- batchCommand<Result extends QueryResultRow = QueryResultRow>(sqls: SQL[], options?: BatchSQLCommandOptions): Promise<QueryResult<Result>[]>;
1279
- }
1280
- interface WithSQLExecutor {
1281
- execute: SQLExecutor;
1282
- }
1283
- declare const sqlExecutor: <DbClient = unknown, DbExecutor extends DbSQLExecutor = DbSQLExecutor>(sqlExecutor: DbExecutor, options: {
1284
- connect: () => Promise<DbClient>;
1285
- close?: (client: DbClient, error?: unknown) => Promise<void>;
1286
- }) => SQLExecutor;
1287
- declare const sqlExecutorInNewConnection: <ConnectionType extends Connection>(options: {
1288
- driverType: ConnectionType["driverType"];
1289
- connection: () => Promise<ConnectionType>;
1290
- }) => SQLExecutor;
1291
- declare const sqlExecutorInAmbientConnection: <ConnectionType extends Connection>(options: {
1292
- driverType: ConnectionType["driverType"];
1293
- connection: () => Promise<ConnectionType>;
1294
- }) => SQLExecutor;
1295
- declare const executeInNewDbClient: <DbClient = unknown, Result = unknown>(handle: (client: DbClient) => Promise<Result>, options: {
1296
- connect: () => Promise<DbClient>;
1297
- close?: (client: DbClient, error?: unknown) => Promise<void>;
1298
- }) => Promise<Result>;
1299
- declare const executeInNewConnection: <ConnectionType extends Connection, Result>(handle: (connection: ConnectionType) => Promise<Result>, options: {
1300
- connection: () => Promise<ConnectionType>;
1301
- }) => Promise<Result>;
1302
- declare const executeInAmbientConnection: <ConnectionType extends Connection, Result>(handle: (connection: ConnectionType) => Promise<Result>, options: {
1303
- connection: () => Promise<ConnectionType>;
1304
- }) => Promise<Result>;
1305
- //#endregion
1306
- //#region src/core/schema/databaseMetadata/databaseMetadata.d.ts
1307
- interface DatabaseCapabilities<SupportsMultipleDatabases extends boolean, SupportsSchemas extends boolean, SupportsFunctions extends boolean> {
1308
- readonly supportsMultipleDatabases: SupportsMultipleDatabases;
1309
- readonly supportsSchemas: SupportsSchemas;
1310
- readonly supportsFunctions: SupportsFunctions;
1311
- }
1312
- type DatabaseMetadata<SupportsMultipleDatabases extends boolean = boolean, SupportsSchemas extends boolean = boolean, SupportsFunctions extends boolean = boolean> = {
1313
- readonly databaseType: DatabaseType;
1314
- readonly capabilities: DatabaseCapabilities<SupportsMultipleDatabases, SupportsSchemas, SupportsFunctions>;
1315
- readonly tableExists: (pool: SQLExecutor, tableName: string) => Promise<boolean>;
1316
- } & (SupportsMultipleDatabases extends true ? {
1317
- readonly defaultDatabaseName: string;
1318
- readonly parseDatabaseName: (connectionString?: string) => string | undefined;
1319
- } : {
1320
- readonly defaultDatabaseName?: never;
1321
- readonly parseDatabaseName?: never;
1322
- }) & (SupportsFunctions extends true ? {
1323
- readonly functionExists: (pool: SQLExecutor, functionName: string) => Promise<boolean>;
1324
- } : {
1325
- readonly functionExists?: (pool: SQLExecutor, functionName: string) => Promise<boolean>;
1326
- });
1327
- declare const DumboDatabaseMetadataRegistry: () => {
1328
- register: (databaseType: DatabaseType, info: DatabaseMetadata | (() => Promise<DatabaseMetadata>)) => void;
1329
- tryResolve: (databaseType: DatabaseType) => Promise<DatabaseMetadata | null>;
1330
- tryGet: (databaseType: DatabaseType) => DatabaseMetadata | null;
1331
- has: (databaseType: DatabaseType) => boolean;
1332
- readonly databaseTypes: DatabaseType[];
1333
- };
1334
- declare global {
1335
- var dumboDatabaseMetadataRegistry: ReturnType<typeof DumboDatabaseMetadataRegistry>;
1336
- }
1337
- declare const dumboDatabaseMetadataRegistry: {
1338
- register: (databaseType: DatabaseType, info: DatabaseMetadata | (() => Promise<DatabaseMetadata>)) => void;
1339
- tryResolve: (databaseType: DatabaseType) => Promise<DatabaseMetadata | null>;
1340
- tryGet: (databaseType: DatabaseType) => DatabaseMetadata | null;
1341
- has: (databaseType: DatabaseType) => boolean;
1342
- readonly databaseTypes: DatabaseType[];
1343
- };
1344
- declare const getDatabaseMetadata: (driverType: DatabaseDriverType) => DatabaseMetadata | null;
1345
- declare const resolveDatabaseMetadata: (driverType: DatabaseDriverType, driverOverride?: DatabaseMetadata) => Promise<DatabaseMetadata | null>;
1346
- declare const getDefaultDatabase: (driverType: DatabaseDriverType) => string | undefined;
1347
- declare const getDefaultDatabaseAsync: (driverType: DatabaseDriverType) => Promise<string | undefined>;
1348
- //#endregion
1349
- //#region src/core/locks/databaseLock.d.ts
1350
- type DatabaseLockOptions = {
1351
- lockId: number;
1352
- timeoutMs?: number;
1353
- };
1354
- type AcquireDatabaseLockMode = 'Permanent' | 'Session';
1355
- type AcquireDatabaseLockOptions = DatabaseLockOptions & {
1356
- mode?: AcquireDatabaseLockMode;
1357
- };
1358
- type ReleaseDatabaseLockOptions = DatabaseLockOptions;
1359
- declare const defaultDatabaseLockOptions: Required<Omit<DatabaseLockOptions, 'lockId'>>;
1360
- type DatabaseLock = {
1361
- acquire(execute: SQLExecutor, options: AcquireDatabaseLockOptions): Promise<void>;
1362
- tryAcquire(execute: SQLExecutor, options: AcquireDatabaseLockOptions): Promise<boolean>;
1363
- release(execute: SQLExecutor, options: ReleaseDatabaseLockOptions): Promise<boolean>;
1364
- withAcquire: <Result = unknown>(execute: SQLExecutor, handle: () => Promise<Result>, options: AcquireDatabaseLockOptions) => Promise<Result>;
1365
- };
1366
- declare const NoDatabaseLock: DatabaseLock;
1367
- //#endregion
1368
- //#region src/core/schema/migrators/migrator.d.ts
1369
- declare const MIGRATIONS_LOCK_ID = 999956789;
1370
- declare global {
1371
- var defaultMigratorOptions: Record<DatabaseType, MigratorOptions>;
1372
- }
1373
- declare const registerDefaultMigratorOptions: (databaseType: DatabaseType, options: MigratorOptions) => void;
1374
- declare const getDefaultMigratorOptionsFromRegistry: (databaseType: DatabaseType) => MigratorOptions;
1375
- type MigratorOptions = {
1376
- schema?: {
1377
- migrationTable?: SchemaComponent;
1378
- };
1379
- lock?: {
1380
- databaseLock?: DatabaseLock;
1381
- options?: Omit<DatabaseLockOptions, 'lockId'> & Partial<Pick<DatabaseLockOptions, 'lockId'>>;
1382
- };
1383
- dryRun?: boolean | undefined;
1384
- ignoreMigrationHashMismatch?: boolean | undefined;
1385
- migrationTimeoutMs?: number | undefined;
1386
- };
1387
- type RunSQLMigrationsResult = {
1388
- applied: SQLMigration[];
1389
- skipped: SQLMigration[];
1390
- };
1391
- declare const runSQLMigrations: (pool: Dumbo, migrations: ReadonlyArray<SQLMigration>, partialOptions?: Partial<MigratorOptions>) => Promise<RunSQLMigrationsResult>;
1392
- declare const combineMigrations: (...migration: Pick<SQLMigration, "sqls">[]) => SQL[];
1393
- //#endregion
1394
- //#region src/core/schema/migrators/schemaComponentMigrator.d.ts
1395
- declare const migrationTableSchemaComponent: {
1396
- schemaComponentKey: "dumbo:schema-component:migrations-table";
1397
- components: ReadonlyMap<string, SchemaComponent>;
1398
- migrations: ReadonlyArray<SQLMigration>;
1399
- addComponent: <SchemaComponentType extends SchemaComponent<string, Record<string, any>> = SchemaComponent<string, Record<string, any>>>(component: SchemaComponentType) => SchemaComponentType;
1400
- addMigration: (migration: SQLMigration) => void;
1401
- };
1402
- type SchemaComponentMigrator = {
1403
- component: SchemaComponent;
1404
- run: (options?: Partial<MigratorOptions>) => Promise<void>;
1405
- };
1406
- declare const SchemaComponentMigrator: <DriverType extends DatabaseDriverType>(component: SchemaComponent, dumbo: Dumbo<DriverType>) => SchemaComponentMigrator;
1407
- //#endregion
1408
- //#region src/core/drivers/databaseDriver.d.ts
1409
- interface DumboDatabaseDriver<ConnectionType extends AnyConnection = AnyConnection, DriverOptions extends unknown = unknown, DumboType extends Dumbo<ConnectionType['driverType'], ConnectionType> = Dumbo<ConnectionType['driverType'], ConnectionType>> {
1410
- readonly driverType: ConnectionType['driverType'];
1411
- readonly sqlFormatter: SQLFormatter;
1412
- readonly defaultMigratorOptions: MigratorOptions;
1413
- readonly databaseMetadata: DatabaseMetadata;
1414
- createPool(options: DumboConnectionOptions<this>): DumboType;
1415
- canHandle(options: DumboConnectionOptions<this>): boolean;
1416
- }
1417
- type AnyDumboDatabaseDriver = DumboDatabaseDriver<AnyConnection, any>;
1418
- type ExtractDumboDatabaseDriverOptions<DatabaseDriver> = DatabaseDriver extends DumboDatabaseDriver<any, infer O, any> ? O : never;
1419
- type ExtractDumboTypeFromDriver<DatabaseDriver> = DatabaseDriver extends DumboDatabaseDriver<any, any, infer D> ? D : never;
1420
- declare const canHandleDriverWithConnectionString: <DatabaseDriver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver, ConnectionOptions extends DumboConnectionOptions<DatabaseDriver> = DumboConnectionOptions<DatabaseDriver>>(driver: DatabaseDriver["driverType"], tryParseConnectionString: (connectionString: string) => string | null) => (options: ConnectionOptions) => boolean;
1421
- declare const DumboDatabaseDriverRegistry: () => {
1422
- register: <Driver extends AnyDumboDatabaseDriver>(driverType: Driver["driverType"], plugin: Driver | (() => Promise<Driver>)) => void;
1423
- tryResolve: <Driver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver, ConnectionOptions extends DumboConnectionOptions<Driver> = DumboConnectionOptions<Driver>>(options: ConnectionOptions) => Promise<Driver | null>;
1424
- tryGet: <Driver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver, ConnectionOptions extends DumboConnectionOptions<Driver> = DumboConnectionOptions<Driver>>(options: ConnectionOptions) => Driver | null;
1425
- has: (driverType: DatabaseDriverType) => boolean;
1426
- readonly databaseDriverTypes: DatabaseDriverType[];
1427
- };
1428
- declare global {
1429
- var dumboDatabaseDriverRegistry: ReturnType<typeof DumboDatabaseDriverRegistry>;
1430
- }
1431
- declare const dumboDatabaseDriverRegistry: {
1432
- register: <Driver extends AnyDumboDatabaseDriver>(driverType: Driver["driverType"], plugin: Driver | (() => Promise<Driver>)) => void;
1433
- tryResolve: <Driver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver, ConnectionOptions extends DumboConnectionOptions<Driver> = DumboConnectionOptions<Driver>>(options: ConnectionOptions) => Promise<Driver | null>;
1434
- tryGet: <Driver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver, ConnectionOptions extends DumboConnectionOptions<Driver> = DumboConnectionOptions<Driver>>(options: ConnectionOptions) => Driver | null;
1435
- has: (driverType: DatabaseDriverType) => boolean;
1436
- readonly databaseDriverTypes: DatabaseDriverType[];
1437
- };
1438
- //#endregion
1439
- //#region src/core/drivers/index.d.ts
1440
- type DatabaseType = string;
1441
- type DatabaseDriverName = string;
1442
- type DatabaseDriverType<DatabaseTypeName extends DatabaseType = DatabaseType, DriverName extends DatabaseDriverName = DatabaseDriverName> = `${DatabaseTypeName}:${DriverName}`;
1443
- type InferDriverDatabaseType<T extends string> = T extends `${infer DatabaseType}:${string}` ? DatabaseType : never;
1444
- type DatabaseDriverTypeParts<T extends DatabaseType = DatabaseType> = {
1445
- databaseType: T;
1446
- driverName: string;
1447
- };
1448
- /**
1449
- * Accepts a `databaseType` (e.g. PostgreSQL, SQLite) and a `driverName`
1450
- * (the library name, e.g. pg, sqlite3) and combines them to a singular
1451
- * `databaseDriverType` which can be used in database handling.
1452
- */
1453
- declare function toDatabaseDriverType<T extends DatabaseType>(databaseType: T, driverName: string): DatabaseDriverType<T>;
1454
- /**
1455
- * Accepts a fully formatted `driverType` and returns the broken down
1456
- * `databaseType` and `driverName`.
1457
- */
1458
- declare function fromDatabaseDriverType<T extends DatabaseType>(databaseDriverType: DatabaseDriverType<T>): DatabaseDriverTypeParts<T>;
1459
- /**
1460
- * Accepts a fully formatted `databaseDriverType` and returns the `driverName`.
1461
- */
1462
- declare function getDatabaseDriverName<T extends DatabaseType>(databaseDriverType: DatabaseDriverType<T>): DatabaseDriverName;
1463
- /**
1464
- * Accepts a fully formatted `databaseDriverType` and returns the `databaseType`.
1465
- */
1466
- declare function getDatabaseType<T extends DatabaseType>(databaseDriverType: DatabaseDriverType<T>): DatabaseType;
1467
- //#endregion
1468
- //#region src/core/connections/transaction.d.ts
1469
- interface DatabaseTransaction<ConnectionType extends AnyConnection = AnyConnection, TransactionOptionsType extends DatabaseTransactionOptions = DatabaseTransactionOptions> extends WithSQLExecutor {
1470
- driverType: ConnectionType['driverType'];
1471
- connection: ConnectionType;
1472
- begin: () => Promise<void>;
1473
- commit: () => Promise<void>;
1474
- rollback: (error?: unknown) => Promise<void>;
1475
- _transactionOptions: TransactionOptionsType;
1476
- }
1477
- type AnyDatabaseTransaction = DatabaseTransaction<any, any>;
1478
- type DatabaseTransactionOptions = {
1479
- allowNestedTransactions?: boolean;
1480
- readonly?: boolean;
1481
- };
1482
- type InferTransactionOptionsFromTransaction<C extends AnyDatabaseTransaction> = C extends DatabaseTransaction<any, infer TO> ? TO : never;
1483
- interface WithDatabaseTransactionFactory<ConnectionType extends AnyConnection = AnyConnection> {
1484
- transaction: (options?: InferTransactionOptionsFromConnection<ConnectionType>) => InferTransactionFromConnection<ConnectionType>;
1485
- withTransaction: <Result = never>(handle: (transaction: InferTransactionFromConnection<ConnectionType>) => Promise<TransactionResult<Result> | Result>, options?: InferTransactionOptionsFromConnection<ConnectionType>) => Promise<Result>;
1486
- }
1487
- type TransactionResult<Result> = {
1488
- success: boolean;
1489
- result: Result;
1490
- };
1491
- declare const executeInTransaction: <DatabaseTransactionType extends AnyDatabaseTransaction = AnyDatabaseTransaction, Result = void>(transaction: DatabaseTransactionType, handle: (transaction: DatabaseTransactionType) => Promise<TransactionResult<Result> | Result>) => Promise<Result>;
1492
- declare const transactionFactoryWithDbClient: <ConnectionType extends AnyConnection = AnyConnection>(connect: () => Promise<InferDbClientFromConnection<ConnectionType>>, initTransaction: (client: Promise<InferDbClientFromConnection<ConnectionType>>, options?: InferTransactionOptionsFromConnection<ConnectionType> & {
1493
- close: (client: InferDbClientFromConnection<ConnectionType>, error?: unknown) => Promise<void>;
1494
- }) => InferTransactionFromConnection<ConnectionType>) => WithDatabaseTransactionFactory<ConnectionType>;
1495
- declare const transactionFactoryWithNewConnection: <ConnectionType extends AnyConnection = AnyConnection>(connect: () => ConnectionType) => WithDatabaseTransactionFactory<ConnectionType>;
1496
- declare const transactionFactoryWithAmbientConnection: <ConnectionType extends AnyConnection = AnyConnection>(connect: () => ConnectionType) => WithDatabaseTransactionFactory<ConnectionType>;
1497
- declare const transactionFactoryWithAsyncAmbientConnection: <ConnectionType extends AnyConnection = AnyConnection>(driverType: ConnectionType["driverType"], connect: () => Promise<ConnectionType>, close?: (connection: ConnectionType) => void | Promise<void>) => WithDatabaseTransactionFactory<ConnectionType>;
1498
- //#endregion
1499
- //#region src/core/connections/connection.d.ts
1500
- interface Connection<Self extends AnyConnection = AnyConnection, DriverType extends DatabaseDriverType = DatabaseDriverType, DbClient = unknown, TransactionType extends DatabaseTransaction<Self, any> = DatabaseTransaction<Self, any>> extends WithSQLExecutor, WithDatabaseTransactionFactory<Self> {
1501
- driverType: DriverType;
1502
- open: () => Promise<DbClient>;
1503
- close: () => Promise<void>;
1504
- _transactionType: TransactionType;
1505
- }
1506
- type AnyConnection = Connection<AnyConnection, DatabaseDriverType, unknown, AnyDatabaseTransaction>;
1507
- type InferDriverTypeFromConnection<C extends AnyConnection> = C extends Connection<any, infer DT, any, any> ? DT : never;
1508
- type InferDbClientFromConnection<C extends AnyConnection> = C extends Connection<any, any, infer DC, any> ? DC : never;
1509
- type InferTransactionFromConnection<C extends AnyConnection> = C extends Connection<any, any, any, infer DT> ? DT : never;
1510
- type InferTransactionOptionsFromConnection<C extends AnyConnection> = InferTransactionOptionsFromTransaction<InferTransactionFromConnection<C>>;
1511
- type ConnectionOptions<ConnectionType extends AnyConnection = AnyConnection> = {
1512
- driverType?: ConnectionType['driverType'];
1513
- transactionOptions?: InferTransactionOptionsFromConnection<ConnectionType>;
1514
- };
1515
- type ConnectionFactory<ConnectionType extends AnyConnection = AnyConnection> = (options: ConnectionOptions<ConnectionType>) => ConnectionType;
1516
- type WithConnectionOptions = {
1517
- readonly?: boolean;
1518
- };
1519
- interface WithConnectionFactory<ConnectionType extends AnyConnection = AnyConnection> {
1520
- connection: (options?: WithConnectionOptions) => Promise<ConnectionType>;
1521
- withConnection: <Result = unknown>(handle: (connection: ConnectionType) => Promise<Result>, options?: WithConnectionOptions) => Promise<Result>;
1522
- }
1523
- type InitTransaction<ConnectionType extends AnyConnection = AnyConnection> = (connection: () => ConnectionType) => (client: Promise<InferDbClientFromConnection<ConnectionType>>, options?: InferTransactionOptionsFromConnection<ConnectionType> & {
1524
- close: (client: InferDbClientFromConnection<ConnectionType>, error?: unknown) => Promise<void>;
1525
- }) => InferTransactionFromConnection<ConnectionType>;
1526
- type CreateConnectionOptions<ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor> = {
1527
- driverType: InferDriverTypeFromConnection<ConnectionType>;
1528
- connect: () => Promise<InferDbClientFromConnection<ConnectionType>>;
1529
- close: (client: InferDbClientFromConnection<ConnectionType>) => Promise<void>;
1530
- initTransaction: InitTransaction<ConnectionType>;
1531
- serializer: JSONSerializer;
1532
- executor: (options: DbSQLExecutorOptions) => Executor;
1533
- };
1534
- type CreateAmbientConnectionOptions<ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor> = {
1535
- driverType: InferDriverTypeFromConnection<ConnectionType>;
1536
- client: InferDbClientFromConnection<ConnectionType>;
1537
- serializer: JSONSerializer;
1538
- initTransaction: InitTransaction<ConnectionType>;
1539
- executor: (options: DbSQLExecutorOptions) => Executor;
1540
- };
1541
- declare const createAmbientConnection: <ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor>(options: CreateAmbientConnectionOptions<ConnectionType, Executor>) => ConnectionType;
1542
- type CreateSingletonConnectionOptions<ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor> = {
1543
- driverType: InferDriverTypeFromConnection<ConnectionType>;
1544
- connect: () => Promise<InferDbClientFromConnection<ConnectionType>>;
1545
- close: (client: InferDbClientFromConnection<ConnectionType>) => Promise<void>;
1546
- initTransaction: InitTransaction<ConnectionType>;
1547
- serializer: JSONSerializer;
1548
- executor: (options: DbSQLExecutorOptions) => Executor;
1549
- };
1550
- declare const createSingletonConnection: <ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor>(options: CreateSingletonConnectionOptions<ConnectionType, Executor>) => ConnectionType;
1551
- type CreateTransientConnectionOptions<ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor> = {
1552
- driverType: InferDriverTypeFromConnection<ConnectionType>;
1553
- open: () => Promise<InferDbClientFromConnection<ConnectionType>>;
1554
- close: () => Promise<void>;
1555
- initTransaction: InitTransaction<ConnectionType>;
1556
- serializer: JSONSerializer;
1557
- executor: (options: DbSQLExecutorOptions) => Executor;
1558
- };
1559
- declare const createTransientConnection: <ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor>(options: CreateTransientConnectionOptions<ConnectionType, Executor>) => ConnectionType;
1560
- declare const createConnection: <ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor>(options: CreateConnectionOptions<ConnectionType, Executor>) => ConnectionType;
1561
- //#endregion
1562
- //#region src/core/connections/pool.d.ts
1563
- interface ConnectionPool<ConnectionType extends AnyConnection = AnyConnection> extends WithSQLExecutor, WithConnectionFactory<ConnectionType>, WithDatabaseTransactionFactory<ConnectionType> {
1564
- driverType: ConnectionType['driverType'];
1565
- close: () => Promise<void>;
1566
- }
1567
- type ConnectionPoolFactory<ConnectionPoolType extends ConnectionPool = ConnectionPool, ConnectionPoolOptions = unknown> = (options: ConnectionPoolOptions) => ConnectionPoolType;
1568
- type AmbientConnectionPoolOptions<ConnectionType extends AnyConnection> = {
1569
- driverType: ConnectionType['driverType'];
1570
- connection: ConnectionType;
1571
- };
1572
- declare const createAmbientConnectionPool: <ConnectionType extends AnyConnection>(options: AmbientConnectionPoolOptions<ConnectionType>) => ConnectionPool<ConnectionType>;
1573
- type SingletonConnectionPoolOptions<ConnectionType extends AnyConnection> = {
1574
- driverType: ConnectionType['driverType'];
1575
- getConnection: () => ConnectionType | Promise<ConnectionType>;
1576
- closeConnection?: (connection: ConnectionType) => void | Promise<void>;
1577
- connectionOptions?: never;
1578
- };
1579
- declare const createSingletonConnectionPool: <ConnectionType extends AnyConnection>(options: SingletonConnectionPoolOptions<ConnectionType>) => ConnectionPool<ConnectionType>;
1580
- type CreateBoundedConnectionPoolOptions<ConnectionType extends AnyConnection> = {
1581
- driverType: ConnectionType['driverType'];
1582
- getConnection: () => ConnectionType | Promise<ConnectionType>;
1583
- maxConnections: number;
1584
- };
1585
- declare const createBoundedConnectionPool: <ConnectionType extends AnyConnection>(options: CreateBoundedConnectionPoolOptions<ConnectionType>) => ConnectionPool<ConnectionType>;
1586
- type SingletonClientConnectionPoolOptions<ConnectionType extends AnyConnection> = {
1587
- driverType: ConnectionType['driverType'];
1588
- dbClient: InferDbClientFromConnection<ConnectionType>;
1589
- connectionFactory: (options: {
1590
- dbClient: InferDbClientFromConnection<ConnectionType>;
1591
- }) => ConnectionType;
1592
- };
1593
- declare const createSingletonClientConnectionPool: <ConnectionType extends AnyConnection>(options: SingletonClientConnectionPoolOptions<ConnectionType>) => ConnectionPool<ConnectionType>;
1594
- type CreateAlwaysNewConnectionPoolOptions<ConnectionType extends AnyConnection, ConnectionOptions extends Record<string, unknown> | undefined = undefined> = ConnectionOptions extends undefined ? {
1595
- driverType: ConnectionType['driverType'];
1596
- getConnection: () => ConnectionType;
1597
- connectionOptions?: never;
1598
- } : {
1599
- driverType: ConnectionType['driverType'];
1600
- getConnection: (options: ConnectionOptions) => ConnectionType;
1601
- connectionOptions: ConnectionOptions;
1602
- };
1603
- declare const createAlwaysNewConnectionPool: <ConnectionType extends AnyConnection, ConnectionOptions extends Record<string, unknown> | undefined = undefined>(options: CreateAlwaysNewConnectionPoolOptions<ConnectionType, ConnectionOptions>) => ConnectionPool<ConnectionType>;
1604
- type CreateConnectionPoolOptions<ConnectionType extends AnyConnection> = Pick<ConnectionPool<ConnectionType>, 'driverType'> & Partial<ConnectionPool<ConnectionType>> & {
1605
- getConnection: () => ConnectionType;
1606
- };
1607
- declare const createConnectionPool: <ConnectionType extends AnyConnection>(pool: CreateConnectionPoolOptions<ConnectionType>) => ConnectionPool<ConnectionType>;
1608
- //#endregion
1609
- //#region src/core/testing/typesTesting.d.ts
1610
- type Expect<T extends true> = T;
1611
- type Equals<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
1612
- type IsError<T> = T extends AnyTypeValidationError ? true : false;
1613
- type IsOK<T> = T extends TypeValidationSuccess ? true : false;
1614
- //#endregion
1615
- //#region src/core/tracing/printing/color.d.ts
1616
- declare const color: {
1617
- level: 0 | 1;
1618
- hex: (value: string) => (text: string) => string;
1619
- red: (value: string) => string;
1620
- green: (value: string) => string;
1621
- blue: (value: string) => string;
1622
- cyan: (value: string) => string;
1623
- yellow: (value: string) => string;
1624
- };
1625
- //#endregion
1626
- //#region src/core/tracing/printing/pretty.d.ts
1627
- declare const prettyJson: (obj: unknown, options?: {
1628
- handleMultiline?: boolean;
1629
- }) => string;
1630
- //#endregion
1631
- //#region src/core/tracing/index.d.ts
1632
- declare const tracer: {
1633
- (): void;
1634
- info(eventName: string, attributes?: Record<string, any>): void;
1635
- warn(eventName: string, attributes?: Record<string, any>): void;
1636
- log(eventName: string, attributes?: Record<string, any>): void;
1637
- error(eventName: string, attributes?: Record<string, any>): void;
1638
- };
1639
- type LogLevel = 'DISABLED' | 'INFO' | 'LOG' | 'WARN' | 'ERROR';
1640
- declare const LogLevel: {
1641
- DISABLED: LogLevel;
1642
- INFO: LogLevel;
1643
- LOG: LogLevel;
1644
- WARN: LogLevel;
1645
- ERROR: LogLevel;
1646
- };
1647
- type LogType = 'CONSOLE';
1648
- type LogStyle = 'RAW' | 'PRETTY';
1649
- declare const LogStyle: {
1650
- RAW: LogStyle;
1651
- PRETTY: LogStyle;
1652
- };
1653
- //#endregion
1654
- //#region src/core/index.d.ts
1655
- type Dumbo<DriverType extends DatabaseDriverType = DatabaseDriverType, ConnectionType extends AnyConnection = AnyConnection> = ConnectionPool<ConnectionType>;
1656
- type DumboConnectionOptions<DatabaseDriver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver> = ExtractDumboDatabaseDriverOptions<DatabaseDriver> extends infer Options ? Options extends unknown ? {
1657
- driver?: DatabaseDriver;
1658
- driverType?: DatabaseDriver['driverType'];
1659
- } & Omit<Options, 'driver' | 'driverType' | 'connectionString'> : never : never;
1660
- //#endregion
1661
- //#region src/storage/all/connections/connectionString.d.ts
1662
- type DatabaseConnectionString<DatabaseTypeName extends DatabaseType = DatabaseType, Format extends string = string> = Format & {
1663
- _databaseType: DatabaseTypeName;
1664
- };
1665
- declare const parseConnectionString: (connectionString: DatabaseConnectionString | string) => DatabaseDriverTypeParts;
1666
- //#endregion
1667
- //#region src/storage/postgresql/core/schema/postgreSQLMetadata.d.ts
1668
- declare const postgreSQLMetadata: DatabaseMetadata<true, true, true>;
1669
- //#endregion
1670
- //#region src/storage/sqlite/core/schema/sqliteMetadata.d.ts
1671
- declare const sqliteMetadata: DatabaseMetadata<false, false, false>;
1672
- //#endregion
1673
- //#region src/storage/all/index.d.ts
1674
- declare function dumbo<Driver extends AnyDumboDatabaseDriver>(options: ExtractDumboDatabaseDriverOptions<Driver> & {
1675
- driver: Driver;
1676
- } & JSONSerializationOptions): ExtractDumboTypeFromDriver<Driver>;
1677
- declare function dumbo<DatabaseDriver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver, ConnectionOptions extends DumboConnectionOptions<DatabaseDriver> = DumboConnectionOptions<DatabaseDriver>>(options: ConnectionOptions & {
1678
- driver?: never;
1679
- }): ExtractDumboTypeFromDriver<DatabaseDriver>;
1680
- //#endregion
1681
- export { DatabaseTransactionOptions as $, SerialToken as $a, ExtractAdditionalData as $i, RelationshipColumnsMismatchError as $n, AllColumnReferences as $r, SQLExecutor as $t, createSingletonClientConnectionPool as A, SQLValueMapper as Aa, ColumnSchemaComponentOptions as Ai, DataError as An, composeJSONReplacers as Ao, databaseSchemaComponent as Ar, getDefaultMigratorOptionsFromRegistry as At, InferDbClientFromConnection as B, DefaultSQLColumnToken as Ba, formatSQL as Bi, QueryCanceledError as Bn, TableColumns as Br, DatabaseCapabilities as Bt, CreateConnectionPoolOptions as C, SQLProcessorContext as Ca, relationship as Ci, toCamelCase as Cn, JSONReviver as Co, IndentErrors as Cr, dumboDatabaseDriverRegistry as Ct, createAmbientConnectionPool as D, DefaultMapSQLParamValueOptions as Da, indexSchemaComponent as Di, CheckViolationError as Dn, JSONSerializeOptions as Do, DatabaseSchemas as Dr, MigratorOptions as Dt, createAlwaysNewConnectionPool as E, ANSISQLParamPlaceholder as Ea, IndexURNType as Ei, AdminShutdownError as En, JSONSerializationOptions as Eo, DatabaseSchemaComponent as Er, MIGRATIONS_LOCK_ID as Et, ConnectionOptions as F, AnyColumnTypeToken as Fa, FormatContext as Fi, InsufficientResourcesError as Fn, DatabaseSchemaURNType as Fr, DatabaseLock as Ft, WithConnectionFactory as G, JavaScriptValueType as Ga, SQLTag as Gi, schemaComponentURN as Gn, InferColumnType as Gr, getDefaultDatabase as Gt, InferTransactionFromConnection as H, JSONBToken as Ha, registerFormatter as Hi, SystemError as Hn, TableURN as Hr, DumboDatabaseMetadataRegistry as Ht, CreateAmbientConnectionOptions as I, AutoIncrementSQLColumnToken as Ia, FormatSQLOptions as Ii, IntegrityConstraintViolationError as In, databaseSchemaSchemaComponent as Ir, DatabaseLockOptions as It, createConnection as J, NotNullableSQLColumnTokenProps as Ja, isTokenizedSQL as Ji, ColumnReferenceError as Jn, InferTableRow as Jr, BatchCommandNoChangesError as Jt, WithConnectionOptions as K, JavaScriptValueTypeName as Ka, isSQL as Ki, CollectReferencesErrors as Kn, InferDatabaseSchemas as Kr, getDefaultDatabaseAsync as Kt, CreateConnectionOptions as L, BigIntegerToken as La, SQLFormatter as Li, InvalidOperationError as Ln, AnyTableSchemaComponent as Lr, NoDatabaseLock as Lt, AnyConnection as M, mapSQLIdentifier as Ma, ColumnURNType as Mi, DumboError as Mn, jsonSerializer as Mo, DatabaseSchemaSchemaComponent as Mr, runSQLMigrations as Mt, Connection as N, mapSQLParamValue as Na, columnSchemaComponent as Ni, ExclusionViolationError as Nn, DbClientSetup as No, DatabaseSchemaTables as Nr, AcquireDatabaseLockMode as Nt, createBoundedConnectionPool as O, MapSQLParamValue as Oa, AnyColumnSchemaComponent as Oi, ConcurrencyError as On, JSONSerializer as Oo, DatabaseURN as Or, RunSQLMigrationsResult as Ot, ConnectionFactory as P, ansiSqlReservedMap as Pa, JSONParam as Pi, ForeignKeyViolationError as Pn, DatabaseSchemaURN as Pr, AcquireDatabaseLockOptions as Pt, DatabaseTransaction as Q, SQLColumnTypeTokensFactory as Qa, DumboSchemaComponentType as Qi, NoError as Qn, Writable as Qr, SQLCommandOptions as Qt, CreateSingletonConnectionOptions as R, BigSerialToken as Ra, SQLFormatterOptions as Ri, LockNotAvailableError as Rn, InferTableSchemaComponentColumns as Rr, ReleaseDatabaseLockOptions as Rt, CreateBoundedConnectionPoolOptions as S, SQLProcessor as Sa, TableRelationships as Si, mapToCamelCase as Sn, JSONReplacers as So, FormatValidationErrors as Sr, canHandleDriverWithConnectionString as St, SingletonConnectionPoolOptions as T, ANSISQLIdentifierQuote as Ta, IndexURN as Ti, QueryResultRow as Tn, JSONRevivers as To, AnyDatabaseSchemaComponent as Tr, migrationTableSchemaComponent as Tt, InferTransactionOptionsFromConnection as U, JSONValueType as Ua, RawSQL as Ui, TransientDatabaseError as Un, TableURNType as Ur, dumboDatabaseMetadataRegistry as Ut, InferDriverTypeFromConnection as V, IntegerToken as Va, getFormatter as Vi, SerializationError as Vn, TableSchemaComponent as Vr, DatabaseMetadata as Vt, InitTransaction as W, JSONValueTypeName as Wa, SQL as Wi, UniqueConstraintError as Wn, tableSchemaComponent as Wr, getDatabaseMetadata as Wt, createTransientConnection as X, SQLColumnToken as Xa, AnySchemaComponent as Xi, ColumnReferenceTypeMismatchError as Xn, TableColumnType as Xr, DbSQLExecutor as Xt, createSingletonConnection as Y, NullableSQLColumnTokenProps as Ya, dumboSchema as Yi, ColumnReferenceExistanceError as Yn, TableColumnNames as Yr, BatchSQLCommandOptions as Yt, AnyDatabaseTransaction as Z, SQLColumnTypeTokens as Za, AnySchemaComponentOfType as Zi, DatabaseSchemasWithSingle as Zn, TableRowType as Zr, DbSQLExecutorOptions as Zt, IsOK as _, DefaultSQLColumnProcessors as _a, ParseReferencePath as _i, first as _n, Serializer as _o, FormatDatabaseValidationErrors as _r, AnyDumboDatabaseDriver as _t, parseConnectionString as a, isSchemaComponentOfType as aa, AnyTableRelationshipDefinitionWithColumns as ai, executeInNewDbClient as an, SQLArray as ao, ValidateColumnsMatch as ar, transactionFactoryWithAsyncAmbientConnection as at, ConnectionPoolFactory as b, SQLProcessorsRegistry as ba, SchemaColumnName as bi, singleOrNull as bn, JSONDeserializeOptions as bo, FormatSingleError as br, ExtractDumboDatabaseDriverOptions as bt, LogLevel as c, MigrationRecord as ca, ColumnPathToReference as ci, mapColumnToJSON as cn, SQLDefaultTokensTypes as co, ValidateDatabaseSchemasWithMessages as cr, DatabaseDriverName as ct, tracer as d, sqlMigration as da, ExtractColumnTypeName as di, sqlExecutorInAmbientConnection as dn, SQLLiteral as do, ValidateRelationship as dr, DatabaseType as dt, SchemaComponent as ea, AllColumnReferencesInSchema as ei, SQLQueryOptions as en, TimestampToken as eo, RelationshipReferencesLengthMismatchError as er, InferTransactionOptionsFromTransaction as et, prettyJson as f, defaultProcessorsRegistry as fa, ExtractSchemaNames as fi, sqlExecutorInNewConnection as fn, SQLPlain as fo, ValidateRelationshipColumns as fr, InferDriverDatabaseType as ft, IsError as g, MapLiteralProcessor as ga, NormalizeReference as gi, exists as gn, SerializationCodec as go, ValidateTableRelationships as gr, toDatabaseDriverType as gt, Expect as h, FormatIdentifierProcessor as ha, NormalizeColumnPath as hi, count as hn, ParametrizedSQLBuilder as ho, ValidateTable as hr, getDatabaseType as ht, DatabaseConnectionString as i, findSchemaComponentsOfType as ia, AnyTableRelationshipDefinition as ii, executeInNewConnection as in, ExtractSQLTokenType as io, ValidateColumnTypeMatch as ir, transactionFactoryWithAmbientConnection as it, createSingletonConnectionPool as j, mapANSISQLParamPlaceholder as ja, ColumnURN as ji, DeadlockError as jn, composeJSONRevivers as jo, AnyDatabaseSchemaSchemaComponent as jr, registerDefaultMigratorOptions as jt, createConnectionPool as k, MapSQLParamValueOptions as ka, ColumnSchemaComponent as ki, ConnectionError as kn, JSONSerializerOptions as ko, DatabaseURNType as kr, combineMigrations as kt, LogStyle as l, MigrationStyle as la, ColumnReference as li, mapSQLQueryResult as ln, SQLIdentifier as lo, ValidateReference as lr, DatabaseDriverType as lt, Equals as m, ExpandSQLInProcessor as ma, LookupColumnType as mi, ExistsSQLQueryResult as mn, ParametrizedSQL as mo, ValidateSchemaTables as mr, getDatabaseDriverName as mt, sqliteMetadata as n, SchemaComponentType as na, AllColumnTypesInSchema as ni, WithSQLExecutor as nn, VarcharToken as no, SchemaTablesWithSingle as nr, WithDatabaseTransactionFactory as nt, Dumbo as o, mapSchemaComponentsOfType as oa, ColumnName$1 as oi, mapColumnToBigint as on, SQLArrayMode as oo, ValidateDatabaseSchema as or, transactionFactoryWithDbClient as ot, color as p, ExpandArrayProcessor as pa, ExtractTableNames as pi, CountSQLQueryResult as pn, SQLToken as po, ValidateRelationshipLength as pr, fromDatabaseDriverType as pt, createAmbientConnection as q, JavaScriptValueTypeToNameMap as qa, TokenizedSQL as qi, CollectRelationshipErrors as qn, InferSchemaTables as qr, resolveDatabaseMetadata as qt, postgreSQLMetadata as r, filterSchemaComponentsOfType as ra, AnyRelationshipDefinition as ri, executeInAmbientConnection as rn, AnySQLToken as ro, ValidateColumnReference as rr, executeInTransaction as rt, DumboConnectionOptions as s, schemaComponent as sa, ColumnPath as si, mapColumnToDate as sn, SQLDefaultTokens as so, ValidateDatabaseSchemas as sr, transactionFactoryWithNewConnection as st, dumbo as t, SchemaComponentOptions as ta, AllColumnTypes as ti, SQLQueryResultColumnMapping as tn, TimestamptzToken as to, RelationshipValidationError as tr, TransactionResult as tt, LogType as u, SQLMigration as ua, ExtractColumnNames as ui, sqlExecutor as un, SQLIn as uo, ValidateReferences as ur, DatabaseDriverTypeParts as ut, AmbientConnectionPoolOptions as v, mapDefaultSQLColumnProcessors as va, RelationshipDefinition as vi, firstOrNull as vn, JSONCodec as vo, FormatRelationshipBlock as vr, DumboDatabaseDriver as vt, SingletonClientConnectionPoolOptions as w, SQLProcessorOptions as wa, IndexSchemaComponent as wi, QueryResult as wn, JSONReviverContext as wo, Join as wr, SchemaComponentMigrator as wt, CreateAlwaysNewConnectionPoolOptions as x, AnySQLProcessor as xa, TableColumnName as xi, mapRows as xn, JSONReplacer as xo, FormatTableLevel as xr, ExtractDumboTypeFromDriver as xt, ConnectionPool as y, SQLProcessorsReadonlyRegistry as ya, RelationshipType as yi, single as yn, JSONCodecOptions as yo, FormatSchemaLevel as yr, DumboDatabaseDriverRegistry as yt, CreateTransientConnectionOptions as z, ColumnTypeToken as za, describeSQL as zi, NotNullViolationError as zn, InferTableSchemaComponentTypes as zr, defaultDatabaseLockOptions as zt };
1682
- //# sourceMappingURL=index-QWEAqtHF.d.ts.map