@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.
- package/dist/cloudflare.cjs +2193 -86
- package/dist/cloudflare.cjs.map +1 -1
- package/dist/cloudflare.d.cts +1106 -3
- package/dist/cloudflare.d.ts +1106 -3
- package/dist/cloudflare.js +2082 -3
- package/dist/cloudflare.js.map +1 -1
- package/dist/index.cjs +2505 -160
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1676 -2
- package/dist/index.d.ts +1676 -2
- package/dist/index.js +2321 -4
- package/dist/index.js.map +1 -1
- package/dist/pg.cjs +2051 -58
- package/dist/pg.cjs.map +1 -1
- package/dist/pg.d.cts +1040 -2
- package/dist/pg.d.ts +1040 -2
- package/dist/pg.js +1968 -3
- package/dist/pg.js.map +1 -1
- package/dist/postgresql.cjs +1845 -25
- package/dist/postgresql.cjs.map +1 -0
- package/dist/postgresql.d.cts +1034 -3
- package/dist/postgresql.d.ts +1034 -3
- package/dist/postgresql.js +1795 -3
- package/dist/postgresql.js.map +1 -0
- package/dist/sqlite.cjs +2124 -30
- package/dist/sqlite.cjs.map +1 -0
- package/dist/sqlite.d.cts +1107 -3
- package/dist/sqlite.d.ts +1107 -3
- package/dist/sqlite.js +2069 -3
- package/dist/sqlite.js.map +1 -0
- package/dist/sqlite3.cjs +2412 -61
- package/dist/sqlite3.cjs.map +1 -1
- package/dist/sqlite3.d.cts +1106 -4
- package/dist/sqlite3.d.ts +1106 -4
- package/dist/sqlite3.js +2326 -3
- package/dist/sqlite3.js.map +1 -1
- package/package.json +1 -1
- package/dist/core-BPSzA-lq.cjs +0 -3259
- package/dist/core-BPSzA-lq.cjs.map +0 -1
- package/dist/core-BuSVyamf.cjs +0 -480
- package/dist/core-BuSVyamf.cjs.map +0 -1
- package/dist/core-C3xoqqDs.js +0 -403
- package/dist/core-C3xoqqDs.js.map +0 -1
- package/dist/core-CHw8vO17.js +0 -456
- package/dist/core-CHw8vO17.js.map +0 -1
- package/dist/core-CUGYxOEQ.cjs +0 -599
- package/dist/core-CUGYxOEQ.cjs.map +0 -1
- package/dist/core-IV7or0Mj.js +0 -2278
- package/dist/core-IV7or0Mj.js.map +0 -1
- package/dist/index-BJC_v03L.d.ts +0 -192
- package/dist/index-CfH0u2y_.d.cts +0 -1682
- package/dist/index-DP9b7v4e.d.cts +0 -192
- package/dist/index-QWEAqtHF.d.ts +0 -1682
- package/dist/index-qxECrBHo.d.ts +0 -75
- package/dist/index-tS9lpLPz.d.cts +0 -75
- package/dist/postgreSQLMetadata-CCsCJ-eH.cjs +0 -118
- package/dist/postgreSQLMetadata-CCsCJ-eH.cjs.map +0 -1
- package/dist/postgreSQLMetadata-bCBDGz1f.js +0 -65
- package/dist/postgreSQLMetadata-bCBDGz1f.js.map +0 -1
- package/dist/sqliteMetadata-Cc7Z03lm.cjs +0 -46
- package/dist/sqliteMetadata-Cc7Z03lm.cjs.map +0 -1
- package/dist/sqliteMetadata-CvvEc1-v.js +0 -29
- package/dist/sqliteMetadata-CvvEc1-v.js.map +0 -1
package/dist/sqlite.d.ts
CHANGED
|
@@ -1,3 +1,1107 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/core/serializer/json/index.d.ts
|
|
2
|
+
interface JSONSerializer<SerializeOptions extends JSONSerializeOptions = JSONSerializeOptions, DeserializeOptions extends JSONDeserializeOptions = JSONDeserializeOptions> extends Serializer<string, SerializeOptions, DeserializeOptions> {
|
|
3
|
+
serialize<T>(object: T, options?: SerializeOptions): string;
|
|
4
|
+
deserialize<T>(payload: string, options?: DeserializeOptions): T;
|
|
5
|
+
}
|
|
6
|
+
type JSONSerializerOptions = {
|
|
7
|
+
parseDates?: boolean;
|
|
8
|
+
parseBigInts?: boolean;
|
|
9
|
+
failOnBigIntSerialization?: boolean;
|
|
10
|
+
useDefaultDateSerialization?: boolean;
|
|
11
|
+
};
|
|
12
|
+
type JSONSerializeOptions = {
|
|
13
|
+
replacer?: JSONReplacer;
|
|
14
|
+
} & JSONSerializerOptions;
|
|
15
|
+
type JSONDeserializeOptions = {
|
|
16
|
+
reviver?: JSONReviver;
|
|
17
|
+
} & JSONSerializerOptions;
|
|
18
|
+
type JSONSerializationOptions<SerializeOptions extends JSONSerializeOptions = JSONSerializeOptions, DeserializeOptions extends JSONDeserializeOptions = JSONDeserializeOptions> = {
|
|
19
|
+
serialization?: {
|
|
20
|
+
serializer?: JSONSerializer<SerializeOptions, DeserializeOptions>;
|
|
21
|
+
options?: JSONSerializeOptions | JSONDeserializeOptions;
|
|
22
|
+
} | undefined;
|
|
23
|
+
};
|
|
24
|
+
type JSONReplacer = (this: any, key: string, value: any) => any;
|
|
25
|
+
type JSONReviver = (this: any, key: string, value: any, context: JSONReviverContext) => any;
|
|
26
|
+
type JSONReviverContext = {
|
|
27
|
+
source: string;
|
|
28
|
+
};
|
|
29
|
+
declare const JSONReplacer: (opts?: JSONSerializeOptions) => JSONReplacer | undefined;
|
|
30
|
+
declare const JSONReviver: (opts?: JSONDeserializeOptions) => JSONReviver | undefined;
|
|
31
|
+
declare const JSONSerializer: JSONSerializer & {
|
|
32
|
+
from: <SerializeOptions extends JSONSerializeOptions = JSONSerializeOptions, DeserializeOptions extends JSONDeserializeOptions = JSONDeserializeOptions>(options?: JSONSerializationOptions<SerializeOptions, DeserializeOptions>) => JSONSerializer<SerializeOptions, DeserializeOptions>;
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/core/serializer/index.d.ts
|
|
36
|
+
interface Serializer<Payload, SerializeOptions extends Record<string, unknown> = Record<string, unknown>, DeserializeOptions extends Record<string, unknown> = SerializeOptions> {
|
|
37
|
+
serialize<T>(object: T, options?: SerializeOptions): Payload;
|
|
38
|
+
deserialize<T>(payload: Payload, options?: DeserializeOptions): T;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/core/sql/parametrizedSQL/parametrizedSQL.d.ts
|
|
42
|
+
interface ParametrizedSQL {
|
|
43
|
+
query: string;
|
|
44
|
+
params: unknown[];
|
|
45
|
+
}
|
|
46
|
+
interface ParametrizedSQLBuilder {
|
|
47
|
+
addSQL: (str: string) => ParametrizedSQLBuilder;
|
|
48
|
+
addParam(value: unknown): ParametrizedSQLBuilder;
|
|
49
|
+
addParams(values: unknown[]): ParametrizedSQLBuilder;
|
|
50
|
+
build: () => ParametrizedSQL;
|
|
51
|
+
}
|
|
52
|
+
declare const ParametrizedSQLBuilder: ({
|
|
53
|
+
mapParamPlaceholder
|
|
54
|
+
}: {
|
|
55
|
+
mapParamPlaceholder: (index: number, value: unknown) => string;
|
|
56
|
+
}) => ParametrizedSQLBuilder;
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/core/sql/tokens/sqlToken.d.ts
|
|
59
|
+
type SQLToken<TSymbol extends string = string, TProps extends Omit<Record<string, unknown>, 'sqlTokenType'> | undefined = Omit<Record<string, unknown>, 'sqlTokenType'> | undefined> = {
|
|
60
|
+
sqlTokenType: TSymbol;
|
|
61
|
+
} & (TProps extends undefined ? void : Omit<TProps, 'sqlTokenType'>);
|
|
62
|
+
type AnySQLToken = SQLToken<string, any>;
|
|
63
|
+
declare const SQLToken: {
|
|
64
|
+
<SQLTokenType extends AnySQLToken, TInput = (Exclude<keyof SQLTokenType, "sqlTokenType"> extends never ? void : Omit<SQLTokenType, "sqlTokenType">)>(sqlTokenType: SQLTokenType["sqlTokenType"], map?: (input: TInput) => Omit<SQLTokenType, "sqlTokenType">): {
|
|
65
|
+
from: (input: TInput) => SQLTokenType;
|
|
66
|
+
check: (token: unknown) => token is SQLTokenType;
|
|
67
|
+
type: SQLTokenType["sqlTokenType"];
|
|
68
|
+
};
|
|
69
|
+
check<SQLTokenType extends AnySQLToken>(token: unknown): token is SQLTokenType;
|
|
70
|
+
};
|
|
71
|
+
type SQLIdentifier = SQLToken<'SQL_IDENTIFIER', {
|
|
72
|
+
value: string;
|
|
73
|
+
}>;
|
|
74
|
+
declare const SQLIdentifier: {
|
|
75
|
+
from: (input: string) => SQLIdentifier;
|
|
76
|
+
check: (token: unknown) => token is SQLIdentifier;
|
|
77
|
+
type: "SQL_IDENTIFIER";
|
|
78
|
+
};
|
|
79
|
+
type SQLPlain = SQLToken<'SQL_RAW', {
|
|
80
|
+
value: string;
|
|
81
|
+
}>;
|
|
82
|
+
declare const SQLPlain: {
|
|
83
|
+
from: (input: string) => SQLPlain;
|
|
84
|
+
check: (token: unknown) => token is SQLPlain;
|
|
85
|
+
type: "SQL_RAW";
|
|
86
|
+
};
|
|
87
|
+
type SQLArrayMode = 'params' | 'native';
|
|
88
|
+
type SQLArray = SQLToken<'SQL_ARRAY', {
|
|
89
|
+
value: unknown[];
|
|
90
|
+
mode?: SQLArrayMode;
|
|
91
|
+
}>;
|
|
92
|
+
declare const SQLArray: {
|
|
93
|
+
from: (input: unknown[] | {
|
|
94
|
+
value: unknown[];
|
|
95
|
+
mode?: SQLArrayMode;
|
|
96
|
+
}) => SQLArray;
|
|
97
|
+
check: (token: unknown) => token is SQLArray;
|
|
98
|
+
type: "SQL_ARRAY";
|
|
99
|
+
};
|
|
100
|
+
type SQLIn = SQLToken<'SQL_IN', {
|
|
101
|
+
column: SQLIdentifier;
|
|
102
|
+
values: SQLArray;
|
|
103
|
+
mode?: SQLArrayMode;
|
|
104
|
+
}>;
|
|
105
|
+
declare const SQLIn: {
|
|
106
|
+
from: (input: {
|
|
107
|
+
column: string;
|
|
108
|
+
values: unknown[];
|
|
109
|
+
mode?: SQLArrayMode;
|
|
110
|
+
}) => SQLIn;
|
|
111
|
+
check: (token: unknown) => token is SQLIn;
|
|
112
|
+
type: "SQL_IN";
|
|
113
|
+
};
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region src/core/sql/tokens/columnTokens.d.ts
|
|
116
|
+
type JavaScriptValueType = Record<string, unknown> | Array<unknown> | string | number | boolean | null | undefined | Date | bigint;
|
|
117
|
+
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';
|
|
118
|
+
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 };
|
|
119
|
+
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> & {
|
|
120
|
+
__brand: ValueType extends undefined ? JavaScriptValueTypeToNameMap[JSValueTypeName] : ValueType;
|
|
121
|
+
jsTypeName: JSValueTypeName;
|
|
122
|
+
};
|
|
123
|
+
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">) => {
|
|
124
|
+
from: (input: TInput) => SQLTokenType;
|
|
125
|
+
check: (token: unknown) => token is SQLTokenType;
|
|
126
|
+
type: SQLTokenType["sqlTokenType"];
|
|
127
|
+
};
|
|
128
|
+
type AnyColumnTypeToken = ColumnTypeToken<any, string, any>;
|
|
129
|
+
type SerialToken = ColumnTypeToken<'value_type:js:number', 'SERIAL'>;
|
|
130
|
+
declare const SerialToken: {
|
|
131
|
+
from: (input: void) => SerialToken;
|
|
132
|
+
check: (token: unknown) => token is SerialToken;
|
|
133
|
+
type: "SQL_COLUMN_SERIAL";
|
|
134
|
+
};
|
|
135
|
+
type BigSerialToken = ColumnTypeToken<'value_type:js:bigint', 'BIGSERIAL'>;
|
|
136
|
+
declare const BigSerialToken: {
|
|
137
|
+
from: (input: void) => BigSerialToken;
|
|
138
|
+
check: (token: unknown) => token is BigSerialToken;
|
|
139
|
+
type: "SQL_COLUMN_BIGSERIAL";
|
|
140
|
+
};
|
|
141
|
+
type IntegerToken = ColumnTypeToken<'value_type:js:number', 'INTEGER'>;
|
|
142
|
+
declare const IntegerToken: {
|
|
143
|
+
from: (input: void) => IntegerToken;
|
|
144
|
+
check: (token: unknown) => token is IntegerToken;
|
|
145
|
+
type: "SQL_COLUMN_INTEGER";
|
|
146
|
+
};
|
|
147
|
+
type BigIntegerToken = ColumnTypeToken<'value_type:js:bigint', 'BIGINT'>;
|
|
148
|
+
declare const BigIntegerToken: {
|
|
149
|
+
from: (input: void) => BigIntegerToken;
|
|
150
|
+
check: (token: unknown) => token is BigIntegerToken;
|
|
151
|
+
type: "SQL_COLUMN_BIGINT";
|
|
152
|
+
};
|
|
153
|
+
type JSONBToken<ValueType extends Record<string, unknown> = Record<string, unknown>> = ColumnTypeToken<'value_type:js:object', 'JSONB', undefined, ValueType>;
|
|
154
|
+
declare const JSONBToken: {
|
|
155
|
+
type: string;
|
|
156
|
+
from: <ValueType extends Record<string, unknown> = Record<string, unknown>>() => JSONBToken<ValueType>;
|
|
157
|
+
check: <ValueType extends Record<string, unknown> = Record<string, unknown>>(token: unknown) => token is JSONBToken<ValueType>;
|
|
158
|
+
};
|
|
159
|
+
type TimestampToken = ColumnTypeToken<'value_type:js:date', 'TIMESTAMP'>;
|
|
160
|
+
declare const TimestampToken: {
|
|
161
|
+
from: (input: void) => TimestampToken;
|
|
162
|
+
check: (token: unknown) => token is TimestampToken;
|
|
163
|
+
type: "SQL_COLUMN_TIMESTAMP";
|
|
164
|
+
};
|
|
165
|
+
type TimestamptzToken = ColumnTypeToken<'value_type:js:date', 'TIMESTAMPTZ'>;
|
|
166
|
+
declare const TimestamptzToken: {
|
|
167
|
+
from: (input: void) => TimestamptzToken;
|
|
168
|
+
check: (token: unknown) => token is TimestamptzToken;
|
|
169
|
+
type: "SQL_COLUMN_TIMESTAMPTZ";
|
|
170
|
+
};
|
|
171
|
+
type VarcharToken = ColumnTypeToken<'value_type:js:string', 'VARCHAR', {
|
|
172
|
+
length: number | 'max';
|
|
173
|
+
}>;
|
|
174
|
+
declare const VarcharToken: {
|
|
175
|
+
from: (input: number | "max") => VarcharToken;
|
|
176
|
+
check: (token: unknown) => token is VarcharToken;
|
|
177
|
+
type: "SQL_COLUMN_VARCHAR";
|
|
178
|
+
};
|
|
179
|
+
type NotNullableSQLColumnTokenProps<ColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string> = {
|
|
180
|
+
name: string;
|
|
181
|
+
type: ColumnType;
|
|
182
|
+
notNull: true;
|
|
183
|
+
unique?: boolean;
|
|
184
|
+
primaryKey?: boolean;
|
|
185
|
+
default?: ColumnType | SQLToken;
|
|
186
|
+
} | {
|
|
187
|
+
name: string;
|
|
188
|
+
type: ColumnType;
|
|
189
|
+
notNull?: false;
|
|
190
|
+
unique?: boolean;
|
|
191
|
+
primaryKey: never;
|
|
192
|
+
default?: ColumnType | SQLToken;
|
|
193
|
+
};
|
|
194
|
+
type NullableSQLColumnTokenProps<ColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string> = {
|
|
195
|
+
name: string;
|
|
196
|
+
type: ColumnType;
|
|
197
|
+
notNull?: false;
|
|
198
|
+
unique?: boolean;
|
|
199
|
+
primaryKey?: false;
|
|
200
|
+
default?: ColumnType | SQLToken;
|
|
201
|
+
};
|
|
202
|
+
type SQLColumnToken<ColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string> = SQLToken<'SQL_COLUMN', NotNullableSQLColumnTokenProps<ColumnType> | NullableSQLColumnTokenProps<ColumnType>>;
|
|
203
|
+
type AutoIncrementSQLColumnToken = ColumnTypeToken<'value_type:js:bigint', 'AUTO_INCREMENT', {
|
|
204
|
+
primaryKey: boolean;
|
|
205
|
+
bigint?: boolean;
|
|
206
|
+
}, bigint>;
|
|
207
|
+
declare const AutoIncrementSQLColumnToken: {
|
|
208
|
+
from: (input: Omit<AutoIncrementSQLColumnToken, "sqlTokenType" | "__brand" | "jsTypeName">) => AutoIncrementSQLColumnToken;
|
|
209
|
+
check: (token: unknown) => token is AutoIncrementSQLColumnToken;
|
|
210
|
+
type: "SQL_COLUMN_AUTO_INCREMENT";
|
|
211
|
+
};
|
|
212
|
+
declare const SQLColumnTypeTokensFactory: {
|
|
213
|
+
AutoIncrement: (input: Omit<AutoIncrementSQLColumnToken, "sqlTokenType" | "__brand" | "jsTypeName">) => AutoIncrementSQLColumnToken;
|
|
214
|
+
BigInteger: BigIntegerToken;
|
|
215
|
+
BigSerial: BigSerialToken;
|
|
216
|
+
Integer: IntegerToken;
|
|
217
|
+
JSONB: <ValueType extends Record<string, unknown> = Record<string, unknown>>() => JSONBToken<ValueType>;
|
|
218
|
+
Serial: SerialToken;
|
|
219
|
+
Timestamp: TimestampToken;
|
|
220
|
+
Timestamptz: TimestamptzToken;
|
|
221
|
+
Varchar: (input: number | "max") => VarcharToken;
|
|
222
|
+
};
|
|
223
|
+
declare const SQLColumnToken: {
|
|
224
|
+
from: (input: Omit<SQLColumnToken<string | AnyColumnTypeToken>, "sqlTokenType">) => SQLColumnToken<string | AnyColumnTypeToken>;
|
|
225
|
+
check: (token: unknown) => token is SQLColumnToken<string | AnyColumnTypeToken>;
|
|
226
|
+
type: "SQL_COLUMN";
|
|
227
|
+
};
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/core/sql/valueMappers/sqlValueMapper.d.ts
|
|
230
|
+
interface SQLValueMapper {
|
|
231
|
+
mapValue: MapSQLParamValue;
|
|
232
|
+
mapPlaceholder: (index: number, value: unknown) => string;
|
|
233
|
+
mapIdentifier: (value: string) => string;
|
|
234
|
+
}
|
|
235
|
+
type MapSQLParamValue = (value: unknown, serializer: JSONSerializer, options?: MapSQLParamValueOptions) => unknown;
|
|
236
|
+
interface MapSQLParamValueOptions {
|
|
237
|
+
mapBoolean?: (value: boolean) => unknown;
|
|
238
|
+
mapArray?: (array: unknown[], mapValue: MapSQLParamValue) => unknown[];
|
|
239
|
+
mapDate?: (value: Date) => unknown;
|
|
240
|
+
mapObject?: (value: object) => unknown;
|
|
241
|
+
mapBigInt?: (value: bigint) => unknown;
|
|
242
|
+
mapValue?: MapSQLParamValue;
|
|
243
|
+
mapPlaceholder?: (index: number, value: unknown) => string;
|
|
244
|
+
mapIdentifier?: (value: string) => string;
|
|
245
|
+
}
|
|
246
|
+
declare const SQLValueMapper: (options?: MapSQLParamValueOptions) => SQLValueMapper;
|
|
247
|
+
//#endregion
|
|
248
|
+
//#region src/core/sql/processors/sqlProcessor.d.ts
|
|
249
|
+
type SQLProcessorContext = {
|
|
250
|
+
mapper: SQLValueMapper;
|
|
251
|
+
builder: ParametrizedSQLBuilder;
|
|
252
|
+
processorsRegistry: SQLProcessorsReadonlyRegistry;
|
|
253
|
+
serializer: JSONSerializer;
|
|
254
|
+
};
|
|
255
|
+
type SQLProcessor<Token extends AnySQLToken = AnySQLToken> = {
|
|
256
|
+
canHandle: Token['sqlTokenType'];
|
|
257
|
+
handle: (value: Token, context: SQLProcessorContext) => void;
|
|
258
|
+
};
|
|
259
|
+
type AnySQLProcessor = SQLProcessor<any>;
|
|
260
|
+
type SQLProcessorOptions<Token extends AnySQLToken = AnySQLToken> = {
|
|
261
|
+
canHandle: Token['sqlTokenType'];
|
|
262
|
+
handle: (value: Token, context: SQLProcessorContext) => void;
|
|
263
|
+
};
|
|
264
|
+
declare const SQLProcessor: <Token extends AnySQLToken = AnySQLToken>(options: SQLProcessorOptions<Token>) => SQLProcessor<Token>;
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region src/core/sql/processors/sqlProcessorRegistry.d.ts
|
|
267
|
+
interface SQLProcessorsReadonlyRegistry {
|
|
268
|
+
get<Token extends AnySQLToken = AnySQLToken>(tokenType: Token['sqlTokenType']): SQLProcessor<Token> | null;
|
|
269
|
+
all(): ReadonlyMap<string, AnySQLProcessor>;
|
|
270
|
+
}
|
|
271
|
+
interface SQLProcessorsRegistry extends SQLProcessorsReadonlyRegistry {
|
|
272
|
+
register(...processor: AnySQLProcessor[]): SQLProcessorsRegistry;
|
|
273
|
+
register(processor: Record<string, AnySQLProcessor>): SQLProcessorsRegistry;
|
|
274
|
+
}
|
|
275
|
+
declare const SQLProcessorsRegistry: (options?: {
|
|
276
|
+
from: SQLProcessorsRegistry;
|
|
277
|
+
}) => SQLProcessorsRegistry;
|
|
278
|
+
//#endregion
|
|
279
|
+
//#region src/core/sql/processors/index.d.ts
|
|
280
|
+
declare global {
|
|
281
|
+
var defaultProcessorsRegistry: ReturnType<typeof SQLProcessorsRegistry>;
|
|
282
|
+
}
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region src/core/schema/sqlMigration.d.ts
|
|
285
|
+
type SQLMigration = {
|
|
286
|
+
name: string;
|
|
287
|
+
sqls: SQL[];
|
|
288
|
+
};
|
|
289
|
+
//#endregion
|
|
290
|
+
//#region src/core/schema/schemaComponent.d.ts
|
|
291
|
+
type SchemaComponent<ComponentKey extends string = string, AdditionalData extends Exclude<Record<string, unknown>, 'schemaComponentKey' | 'components' | 'migrations' | 'addComponent' | 'addMigration'> | undefined = undefined> = {
|
|
292
|
+
schemaComponentKey: ComponentKey;
|
|
293
|
+
components: ReadonlyMap<string, SchemaComponent>;
|
|
294
|
+
migrations: ReadonlyArray<SQLMigration>;
|
|
295
|
+
addComponent: <SchemaComponentType extends SchemaComponent<string, Record<string, any>> = SchemaComponent<string, Record<string, any>>>(component: SchemaComponentType) => SchemaComponentType;
|
|
296
|
+
addMigration: (migration: SQLMigration) => void;
|
|
297
|
+
} & Exclude<AdditionalData extends undefined ? {} : AdditionalData, 'schemaComponentKey' | 'components' | 'migrations' | 'addComponent' | 'addMigration'>;
|
|
298
|
+
type SchemaComponentOptions<AdditionalOptions extends Record<string, unknown> = Record<string, unknown>> = {
|
|
299
|
+
migrations?: ReadonlyArray<SQLMigration>;
|
|
300
|
+
components?: ReadonlyArray<SchemaComponent>;
|
|
301
|
+
} & Omit<AdditionalOptions, 'migrations' | 'components'>;
|
|
302
|
+
//#endregion
|
|
303
|
+
//#region src/core/schema/dumboSchema/dumboSchema.d.ts
|
|
304
|
+
declare const DEFAULT_DATABASE_SCHEMA_NAME = "__default_database_schema__";
|
|
305
|
+
declare function dumboDatabaseSchema<const Tables extends DatabaseSchemaTables = DatabaseSchemaTables>(tables: Tables): DatabaseSchemaSchemaComponent<Tables, typeof DEFAULT_DATABASE_SCHEMA_NAME>;
|
|
306
|
+
declare function dumboDatabaseSchema<const Tables extends DatabaseSchemaTables = DatabaseSchemaTables, const SchemaName extends string = string>(schemaName: SchemaName, tables: Tables, options?: SchemaComponentOptions): DatabaseSchemaSchemaComponent<Tables, SchemaName>;
|
|
307
|
+
declare namespace dumboDatabaseSchema {
|
|
308
|
+
var from: (schemaName: string | undefined, tableNames: string[]) => DatabaseSchemaSchemaComponent;
|
|
309
|
+
var defaultName: string;
|
|
310
|
+
}
|
|
311
|
+
type ValidatedDatabaseSchemaComponent<Schemas extends DatabaseSchemas = DatabaseSchemas> = ValidateDatabaseSchemas<Schemas> extends {
|
|
312
|
+
valid: true;
|
|
313
|
+
} ? DatabaseSchemaComponent<Schemas> : ValidateDatabaseSchemas<Schemas> extends {
|
|
314
|
+
valid: false;
|
|
315
|
+
error: infer E;
|
|
316
|
+
} ? {
|
|
317
|
+
valid: false;
|
|
318
|
+
error: E;
|
|
319
|
+
} : DatabaseSchemaComponent<Schemas>;
|
|
320
|
+
declare function dumboDatabase<Schemas extends DatabaseSchemas = DatabaseSchemas>(schemas: Schemas): ValidatedDatabaseSchemaComponent<Schemas>;
|
|
321
|
+
declare function dumboDatabase<Schemas extends DatabaseSchemas = DatabaseSchemas>(schema: DatabaseSchemaSchemaComponent): ValidatedDatabaseSchemaComponent<Schemas>;
|
|
322
|
+
declare function dumboDatabase<Schemas extends DatabaseSchemas = DatabaseSchemas>(databaseName: string, schemas: Schemas, options?: SchemaComponentOptions): ValidatedDatabaseSchemaComponent<Schemas>;
|
|
323
|
+
declare function dumboDatabase<Schemas extends DatabaseSchemas = DatabaseSchemas>(databaseName: string, schema: AnyDatabaseSchemaSchemaComponent, options?: SchemaComponentOptions): ValidatedDatabaseSchemaComponent<Schemas>;
|
|
324
|
+
declare namespace dumboDatabase {
|
|
325
|
+
var from: <Schemas extends DatabaseSchemas = DatabaseSchemas>(databaseName: string | undefined, schemaNames: string[]) => ValidatedDatabaseSchemaComponent<Schemas>;
|
|
326
|
+
var defaultName: string;
|
|
327
|
+
}
|
|
328
|
+
declare const dumboSchema: {
|
|
329
|
+
database: typeof dumboDatabase;
|
|
330
|
+
schema: typeof dumboDatabaseSchema;
|
|
331
|
+
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: {
|
|
332
|
+
columns?: Columns;
|
|
333
|
+
primaryKey?: TableColumnNames<TableSchemaComponent<Columns, TableName, Relationships>>[];
|
|
334
|
+
relationships?: Relationships;
|
|
335
|
+
indexes?: Record<string, IndexSchemaComponent>;
|
|
336
|
+
} & SchemaComponentOptions) => TableSchemaComponent<Columns, TableName, Relationships>;
|
|
337
|
+
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) => ({
|
|
338
|
+
schemaComponentKey: `sc:dumbo:column:${ColumnName}`;
|
|
339
|
+
components: ReadonlyMap<string, SchemaComponent>;
|
|
340
|
+
migrations: ReadonlyArray<SQLMigration>;
|
|
341
|
+
addComponent: <SchemaComponentType extends SchemaComponent<string, Record<string, any>> = SchemaComponent<string, Record<string, any>>>(component: SchemaComponentType) => SchemaComponentType;
|
|
342
|
+
addMigration: (migration: SQLMigration) => void;
|
|
343
|
+
} & Readonly<{
|
|
344
|
+
columnName: ColumnName;
|
|
345
|
+
}> & {
|
|
346
|
+
sqlTokenType: "SQL_COLUMN";
|
|
347
|
+
} & Omit<{
|
|
348
|
+
name: string;
|
|
349
|
+
type: ColumnType;
|
|
350
|
+
notNull?: false;
|
|
351
|
+
unique?: boolean;
|
|
352
|
+
primaryKey: never;
|
|
353
|
+
default?: ColumnType | SQLToken;
|
|
354
|
+
}, "sqlTokenType"> & (TOptions & {
|
|
355
|
+
type: ColumnType;
|
|
356
|
+
} extends infer T ? T extends TOptions & {
|
|
357
|
+
type: ColumnType;
|
|
358
|
+
} ? T extends {
|
|
359
|
+
notNull: true;
|
|
360
|
+
} | {
|
|
361
|
+
primaryKey: true;
|
|
362
|
+
} ? {
|
|
363
|
+
notNull: true;
|
|
364
|
+
} : {
|
|
365
|
+
notNull?: false;
|
|
366
|
+
} : never : never)) | ({
|
|
367
|
+
schemaComponentKey: `sc:dumbo:column:${ColumnName}`;
|
|
368
|
+
components: ReadonlyMap<string, SchemaComponent>;
|
|
369
|
+
migrations: ReadonlyArray<SQLMigration>;
|
|
370
|
+
addComponent: <SchemaComponentType extends SchemaComponent<string, Record<string, any>> = SchemaComponent<string, Record<string, any>>>(component: SchemaComponentType) => SchemaComponentType;
|
|
371
|
+
addMigration: (migration: SQLMigration) => void;
|
|
372
|
+
} & Readonly<{
|
|
373
|
+
columnName: ColumnName;
|
|
374
|
+
}> & {
|
|
375
|
+
sqlTokenType: "SQL_COLUMN";
|
|
376
|
+
} & Omit<NullableSQLColumnTokenProps<ColumnType>, "sqlTokenType"> & (TOptions & {
|
|
377
|
+
type: ColumnType;
|
|
378
|
+
} extends infer T_1 ? T_1 extends TOptions & {
|
|
379
|
+
type: ColumnType;
|
|
380
|
+
} ? T_1 extends {
|
|
381
|
+
notNull: true;
|
|
382
|
+
} | {
|
|
383
|
+
primaryKey: true;
|
|
384
|
+
} ? {
|
|
385
|
+
notNull: true;
|
|
386
|
+
} : {
|
|
387
|
+
notNull?: false;
|
|
388
|
+
} : never : never));
|
|
389
|
+
index: (name: string, columnNames: string[], options?: {
|
|
390
|
+
unique?: boolean;
|
|
391
|
+
} & SchemaComponentOptions) => IndexSchemaComponent;
|
|
392
|
+
};
|
|
393
|
+
//#endregion
|
|
394
|
+
//#region src/core/sql/tokenizedSQL/tokenizedSQL.d.ts
|
|
395
|
+
type TokenizedSQL = Readonly<{
|
|
396
|
+
__brand: 'tokenized-sql';
|
|
397
|
+
sqlChunks: ReadonlyArray<string>;
|
|
398
|
+
sqlTokens: ReadonlyArray<AnySQLToken>;
|
|
399
|
+
}>;
|
|
400
|
+
declare const TokenizedSQL: {
|
|
401
|
+
(strings: ReadonlyArray<string>, values: unknown[]): TokenizedSQL;
|
|
402
|
+
paramPlaceholder: string;
|
|
403
|
+
empty: {
|
|
404
|
+
__brand: "tokenized-sql";
|
|
405
|
+
sqlChunks: string[];
|
|
406
|
+
sqlTokens: never[];
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
//#endregion
|
|
410
|
+
//#region src/core/sql/sql.d.ts
|
|
411
|
+
/** A tokenized SQL statement created with the {@link SQL} template tag. */
|
|
412
|
+
type SQL = string & {
|
|
413
|
+
__brand: 'sql';
|
|
414
|
+
};
|
|
415
|
+
type SQLTag = {
|
|
416
|
+
/**
|
|
417
|
+
* Creates a tokenized SQL statement.
|
|
418
|
+
*
|
|
419
|
+
* Interpolated values are treated as bound parameters by default. Use the
|
|
420
|
+
* helper methods on `SQL` for SQL syntax that cannot be represented as a bound
|
|
421
|
+
* parameter, such as identifiers or trusted raw fragments.
|
|
422
|
+
*/
|
|
423
|
+
(strings: TemplateStringsArray, ...values: unknown[]): SQL; /** Empty SQL statement used when optional query fragments are absent. */
|
|
424
|
+
EMPTY: SQL; /** Concatenates SQL fragments without adding a separator. */
|
|
425
|
+
concat: (...sqls: SQL[]) => SQL;
|
|
426
|
+
/**
|
|
427
|
+
* Merges SQL fragments, skipping empty fragments and inserting a separator
|
|
428
|
+
* between non-empty fragments.
|
|
429
|
+
*/
|
|
430
|
+
merge: (sqls: SQL[], separator?: string) => SQL; /** Formats SQL into a parametrized query and params using the selected formatter. */
|
|
431
|
+
format: (sql: SQL | SQL[], formatter: SQLFormatter, options?: FormatSQLOptions) => ParametrizedSQL; /** Formats SQL into a readable SQL string for diagnostics and migrations. */
|
|
432
|
+
describe: (sql: SQL | SQL[], formatter: SQLFormatter, options?: FormatSQLOptions) => string; /** Creates a SQL `IN`/native-array token for the provided column and values. */
|
|
433
|
+
in: (column: string, values: unknown[], options?: {
|
|
434
|
+
mode?: SQLArrayMode;
|
|
435
|
+
}) => SQLIn; /** Creates an array token that formatters can render as native or expanded params. */
|
|
436
|
+
array: (values: unknown[], options?: {
|
|
437
|
+
mode?: SQLArrayMode;
|
|
438
|
+
}) => SQLArray; /** Creates a SQL identifier token, quoting it when required by SQL rules. */
|
|
439
|
+
identifier: typeof SQLIdentifier.from;
|
|
440
|
+
/**
|
|
441
|
+
* Creates a trusted raw SQL fragment.
|
|
442
|
+
*
|
|
443
|
+
* This does not quote, escape, or bind the value. Prefer bound parameters for
|
|
444
|
+
* data values, `SQL.identifier` for identifiers, and `SQL.literal` only when
|
|
445
|
+
* SQL syntax requires an inline value literal.
|
|
446
|
+
*/
|
|
447
|
+
plain: typeof SQLPlain.from;
|
|
448
|
+
/**
|
|
449
|
+
* Creates an inline SQL value literal.
|
|
450
|
+
*
|
|
451
|
+
* Use this for SQL syntax positions that cannot use bound parameters. Data
|
|
452
|
+
* values in ordinary queries should stay as template interpolations.
|
|
453
|
+
*/
|
|
454
|
+
literal: (value: string) => SQLPlain; /** Type guards and helpers for SQL tokens. */
|
|
455
|
+
check: {
|
|
456
|
+
isSQL: (value: unknown) => value is SQL;
|
|
457
|
+
isTokenizedSQL: (value: unknown) => value is TokenizedSQL;
|
|
458
|
+
isEmpty: (sql: SQL) => boolean;
|
|
459
|
+
isIdentifier: typeof SQLIdentifier.check;
|
|
460
|
+
isPlain: typeof SQLPlain.check;
|
|
461
|
+
isSQLIn: typeof SQLIn.check;
|
|
462
|
+
}; /** Creates a schema column token for SQL generation. */
|
|
463
|
+
column: typeof SQLColumnToken.from & {
|
|
464
|
+
/** Column type token factory. */type: typeof SQLColumnTypeTokensFactory;
|
|
465
|
+
}; /** Creates a schema column token using Dumbo schema metadata. */
|
|
466
|
+
columnN: typeof dumboSchema.column & {
|
|
467
|
+
/** Column type token factory. */type: typeof SQLColumnTypeTokensFactory;
|
|
468
|
+
};
|
|
469
|
+
};
|
|
470
|
+
declare const SQL: SQLTag;
|
|
471
|
+
//#endregion
|
|
472
|
+
//#region src/core/sql/formatters/sqlFormatter.d.ts
|
|
473
|
+
type FormatContext = Partial<SQLProcessorContext> & Pick<SQLProcessorContext, 'serializer'>;
|
|
474
|
+
interface SQLFormatter {
|
|
475
|
+
format: (sql: SQL | SQL[], context: FormatContext) => ParametrizedSQL;
|
|
476
|
+
describe: (sql: SQL | SQL[], context: FormatContext) => string;
|
|
477
|
+
valueMapper: SQLValueMapper;
|
|
478
|
+
}
|
|
479
|
+
type FormatSQLOptions = {
|
|
480
|
+
mapper?: MapSQLParamValueOptions;
|
|
481
|
+
processorsRegistry?: SQLProcessorsReadonlyRegistry;
|
|
482
|
+
serializer?: JSONSerializer;
|
|
483
|
+
};
|
|
484
|
+
type SQLFormatterOptions = Partial<Omit<SQLFormatter, 'valueMapper'>> & {
|
|
485
|
+
valueMapper?: MapSQLParamValueOptions;
|
|
486
|
+
processorsRegistry?: SQLProcessorsReadonlyRegistry;
|
|
487
|
+
};
|
|
488
|
+
declare const SQLFormatter: ({
|
|
489
|
+
format,
|
|
490
|
+
describe,
|
|
491
|
+
valueMapper: valueMapperOptions,
|
|
492
|
+
processorsRegistry
|
|
493
|
+
}: SQLFormatterOptions) => SQLFormatter;
|
|
494
|
+
declare global {
|
|
495
|
+
var dumboSQLFormatters: Record<string, SQLFormatter>;
|
|
496
|
+
}
|
|
497
|
+
//#endregion
|
|
498
|
+
//#region src/core/schema/components/columnSchemaComponent.d.ts
|
|
499
|
+
type ColumnURNType = 'sc:dumbo:column';
|
|
500
|
+
type ColumnURN<ColumnName extends string = string> = `${ColumnURNType}:${ColumnName}`;
|
|
501
|
+
declare const ColumnURNType: ColumnURNType;
|
|
502
|
+
declare const ColumnURN: <ColumnName extends string = string>({
|
|
503
|
+
name
|
|
504
|
+
}: {
|
|
505
|
+
name: ColumnName;
|
|
506
|
+
}) => ColumnURN<ColumnName>;
|
|
507
|
+
type ColumnSchemaComponent<ColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string, ColumnName extends string = string> = SchemaComponent<ColumnURN<ColumnName>, Readonly<{
|
|
508
|
+
columnName: ColumnName;
|
|
509
|
+
}>> & SQLColumnToken<ColumnType>;
|
|
510
|
+
type AnyColumnSchemaComponent = ColumnSchemaComponent<any>;
|
|
511
|
+
type ColumnSchemaComponentOptions<ColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string> = Omit<SQLColumnToken<ColumnType>, 'name' | 'sqlTokenType'> & SchemaComponentOptions;
|
|
512
|
+
//#endregion
|
|
513
|
+
//#region src/core/schema/components/indexSchemaComponent.d.ts
|
|
514
|
+
type IndexURNType = 'sc:dumbo:index';
|
|
515
|
+
type IndexURN = `${IndexURNType}:${string}`;
|
|
516
|
+
type IndexSchemaComponent = SchemaComponent<IndexURN, Readonly<{
|
|
517
|
+
indexName: string;
|
|
518
|
+
columnNames: ReadonlyArray<string>;
|
|
519
|
+
isUnique: boolean;
|
|
520
|
+
addColumn: (column: string | ColumnSchemaComponent) => void;
|
|
521
|
+
}>>;
|
|
522
|
+
declare const IndexURNType: IndexURNType;
|
|
523
|
+
declare const IndexURN: ({
|
|
524
|
+
name
|
|
525
|
+
}: {
|
|
526
|
+
name: string;
|
|
527
|
+
}) => IndexURN;
|
|
528
|
+
//#endregion
|
|
529
|
+
//#region src/core/typing/conditionals.d.ts
|
|
530
|
+
type IF<Condition extends boolean, Then, Else> = Condition extends true ? Then : Else;
|
|
531
|
+
type AND<A extends boolean, B extends boolean> = A extends true ? B extends true ? true : false : false;
|
|
532
|
+
type ALL<A extends boolean[]> = A extends [infer First, ...infer Rest] ? First extends true ? Rest extends boolean[] ? ALL<Rest> : true : false : true;
|
|
533
|
+
//#endregion
|
|
534
|
+
//#region src/core/typing/records.d.ts
|
|
535
|
+
type KeysOfString<T extends Record<string, unknown>> = Extract<keyof T, string>;
|
|
536
|
+
//#endregion
|
|
537
|
+
//#region src/core/typing/validation.d.ts
|
|
538
|
+
type TypeValidationResult<Valid extends boolean = boolean, Error = never> = Valid extends true ? {
|
|
539
|
+
valid: true;
|
|
540
|
+
} : {
|
|
541
|
+
valid: false;
|
|
542
|
+
error: Error;
|
|
543
|
+
};
|
|
544
|
+
type TypeValidationError<Error> = TypeValidationResult<false, Error>;
|
|
545
|
+
type TypeValidationSuccess = TypeValidationResult<true>;
|
|
546
|
+
type AnyTypeValidationError = TypeValidationError<any>;
|
|
547
|
+
type AnyTypeValidationResult = TypeValidationResult<boolean, any>;
|
|
548
|
+
type AnyTypeValidationFailed<Results = AnyTypeValidationResult[]> = Results extends readonly [infer First, ...infer Rest] ? First extends {
|
|
549
|
+
valid: false;
|
|
550
|
+
} ? true : Rest extends AnyTypeValidationResult[] ? AnyTypeValidationFailed<Rest> : false : false;
|
|
551
|
+
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> : [] : [];
|
|
552
|
+
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;
|
|
553
|
+
//#endregion
|
|
554
|
+
//#region src/core/typing/tuples.d.ts
|
|
555
|
+
type GetTupleLength<T extends readonly unknown[]> = T['length'];
|
|
556
|
+
type NotEmptyTuple<T extends readonly unknown[]> = GetTupleLength<T> extends 0 ? never : T;
|
|
557
|
+
type HaveTuplesTheSameLength<T extends readonly unknown[], U extends readonly unknown[]> = GetTupleLength<T> extends GetTupleLength<U> ? true : false;
|
|
558
|
+
type IsEmptyTuple<T extends readonly unknown[]> = T extends [] ? true : false;
|
|
559
|
+
type IsNotEmptyTuple<T extends readonly unknown[]> = IsEmptyTuple<T> extends true ? false : true;
|
|
560
|
+
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>] : [];
|
|
561
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
562
|
+
type LastOfUnion<T> = UnionToIntersection<T extends any ? () => T : never> extends (() => infer R) ? R : never;
|
|
563
|
+
type UnionToTuple<T, L = LastOfUnion<T>> = [T] extends [never] ? [] : [...UnionToTuple<Exclude<T, L>>, L];
|
|
564
|
+
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;
|
|
565
|
+
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;
|
|
566
|
+
//#endregion
|
|
567
|
+
//#region src/core/schema/components/relationships/relationshipTypes.d.ts
|
|
568
|
+
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;
|
|
569
|
+
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 [];
|
|
570
|
+
type SchemaColumnName<SchemaName extends string = string, TableName extends string = string, ColumnName extends string = string> = `${SchemaName}.${TableName}.${ColumnName}`;
|
|
571
|
+
type RelationshipType = 'one-to-one' | 'one-to-many' | 'many-to-one' | 'many-to-many';
|
|
572
|
+
type RelationshipDefinition<Columns extends string = string, Reference extends string = string, RelType extends RelationshipType = RelationshipType> = {
|
|
573
|
+
readonly columns: NotEmptyTuple<readonly Columns[]>;
|
|
574
|
+
readonly references: NotEmptyTuple<readonly Reference[]>;
|
|
575
|
+
readonly type: RelType;
|
|
576
|
+
};
|
|
577
|
+
type AnyTableRelationshipDefinition = RelationshipDefinition<any, any, any>;
|
|
578
|
+
type AnyTableRelationshipDefinitionWithColumns<Columns extends string = string> = RelationshipDefinition<Columns, any, any>;
|
|
579
|
+
type TableRelationships<Columns extends string = string> = Record<string, AnyTableRelationshipDefinitionWithColumns<Columns>>;
|
|
580
|
+
//#endregion
|
|
581
|
+
//#region src/core/schema/components/tableTypesInference.d.ts
|
|
582
|
+
type TableColumnNames<T extends AnyTableSchemaComponent> = Exclude<keyof T['columns'], keyof ReadonlyMap<string, AnyColumnSchemaComponent>>;
|
|
583
|
+
//#endregion
|
|
584
|
+
//#region src/core/schema/components/tableSchemaComponent.d.ts
|
|
585
|
+
type TableURNType = 'sc:dumbo:table';
|
|
586
|
+
type TableURN = `${TableURNType}:${string}`;
|
|
587
|
+
declare const TableURNType: TableURNType;
|
|
588
|
+
declare const TableURN: ({
|
|
589
|
+
name
|
|
590
|
+
}: {
|
|
591
|
+
name: string;
|
|
592
|
+
}) => TableURN;
|
|
593
|
+
type TableColumns = Record<string, AnyColumnSchemaComponent>;
|
|
594
|
+
type TableSchemaComponent<Columns extends TableColumns = TableColumns, TableName extends string = string, Relationships extends TableRelationships<keyof Columns & string> = {} & TableRelationships<keyof Columns & string>> = SchemaComponent<TableURN, Readonly<{
|
|
595
|
+
tableName: TableName;
|
|
596
|
+
columns: ReadonlyMap<string, AnyColumnSchemaComponent> & Columns;
|
|
597
|
+
primaryKey: TableColumnNames<TableSchemaComponent<Columns, TableName, Relationships>>[];
|
|
598
|
+
relationships: Relationships;
|
|
599
|
+
indexes: ReadonlyMap<string, IndexSchemaComponent>;
|
|
600
|
+
addColumn: (column: AnyColumnSchemaComponent) => AnyColumnSchemaComponent;
|
|
601
|
+
addIndex: (index: IndexSchemaComponent) => IndexSchemaComponent;
|
|
602
|
+
}>>;
|
|
603
|
+
type AnyTableSchemaComponent = TableSchemaComponent<any, any, any>;
|
|
604
|
+
//#endregion
|
|
605
|
+
//#region src/core/schema/components/databaseSchemaSchemaComponent.d.ts
|
|
606
|
+
type DatabaseSchemaURNType = 'sc:dumbo:database_schema';
|
|
607
|
+
type DatabaseSchemaURN<SchemaName extends string = string> = `${DatabaseSchemaURNType}:${SchemaName}`;
|
|
608
|
+
declare const DatabaseSchemaURNType: DatabaseSchemaURNType;
|
|
609
|
+
declare const DatabaseSchemaURN: <SchemaName extends string = string>({
|
|
610
|
+
name
|
|
611
|
+
}: {
|
|
612
|
+
name: SchemaName;
|
|
613
|
+
}) => DatabaseSchemaURN<SchemaName>;
|
|
614
|
+
type DatabaseSchemaTables<Tables extends AnyTableSchemaComponent = AnyTableSchemaComponent> = Record<string, Tables>;
|
|
615
|
+
type DatabaseSchemaSchemaComponent<Tables extends DatabaseSchemaTables = DatabaseSchemaTables, SchemaName extends string = string> = SchemaComponent<DatabaseSchemaURN<SchemaName>, Readonly<{
|
|
616
|
+
schemaName: SchemaName;
|
|
617
|
+
tables: ReadonlyMap<string, TableSchemaComponent> & Tables;
|
|
618
|
+
addTable: (table: string | TableSchemaComponent) => TableSchemaComponent;
|
|
619
|
+
}>>;
|
|
620
|
+
type AnyDatabaseSchemaSchemaComponent = DatabaseSchemaSchemaComponent<any, any>;
|
|
621
|
+
//#endregion
|
|
622
|
+
//#region src/core/schema/components/databaseSchemaComponent.d.ts
|
|
623
|
+
type DatabaseURNType = 'sc:dumbo:database';
|
|
624
|
+
type DatabaseURN = `${DatabaseURNType}:${string}`;
|
|
625
|
+
declare const DatabaseURNType: DatabaseURNType;
|
|
626
|
+
declare const DatabaseURN: ({
|
|
627
|
+
name
|
|
628
|
+
}: {
|
|
629
|
+
name: string;
|
|
630
|
+
}) => DatabaseURN;
|
|
631
|
+
type DatabaseSchemas<Schemas extends AnyDatabaseSchemaSchemaComponent = AnyDatabaseSchemaSchemaComponent> = Record<string, Schemas>;
|
|
632
|
+
type DatabaseSchemaComponent<Schemas extends DatabaseSchemas = DatabaseSchemas> = SchemaComponent<DatabaseURN, Readonly<{
|
|
633
|
+
databaseName: string;
|
|
634
|
+
schemas: ReadonlyMap<string, DatabaseSchemaSchemaComponent> & Schemas;
|
|
635
|
+
addSchema: (schema: string | DatabaseSchemaSchemaComponent) => DatabaseSchemaSchemaComponent;
|
|
636
|
+
}>>;
|
|
637
|
+
//#endregion
|
|
638
|
+
//#region src/core/schema/components/relationships/relationshipValidation.d.ts
|
|
639
|
+
type ColumnReferenceExistanceError<ErrorCode extends 'missing_schema' | 'missing_table' | 'missing_column' = 'missing_schema' | 'missing_table' | 'missing_column', ColumnPath extends SchemaColumnName = SchemaColumnName> = {
|
|
640
|
+
valid: false;
|
|
641
|
+
error: {
|
|
642
|
+
errorCode: ErrorCode;
|
|
643
|
+
reference: ColumnPath;
|
|
644
|
+
};
|
|
645
|
+
};
|
|
646
|
+
type ColumnReferenceTypeMismatchError<Reference extends SchemaColumnName = SchemaColumnName, ReferenceTypeName extends string = string, ColumnTypeName extends string = string> = {
|
|
647
|
+
valid: false;
|
|
648
|
+
error: {
|
|
649
|
+
errorCode: 'type_mismatch';
|
|
650
|
+
reference: Reference;
|
|
651
|
+
referenceType: ReferenceTypeName;
|
|
652
|
+
columnTypeName: ColumnTypeName;
|
|
653
|
+
};
|
|
654
|
+
};
|
|
655
|
+
type ValidateRelationshipLength<Rel extends AnyTableRelationshipDefinition> = IF<ALL<[HaveTuplesTheSameLength<Rel['columns'], Rel['references']>, IsNotEmptyTuple<Rel['columns']>, IsNotEmptyTuple<Rel['references']>]>, TypeValidationSuccess, TypeValidationResult<false, {
|
|
656
|
+
errorCode: 'reference_length_mismatch';
|
|
657
|
+
columns: Rel['columns'];
|
|
658
|
+
references: Rel['references'];
|
|
659
|
+
}>>;
|
|
660
|
+
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, {
|
|
661
|
+
errorCode: 'reference_columns_mismatch';
|
|
662
|
+
invalidColumns: InvalidColumns;
|
|
663
|
+
availableColumns: KeysOfString<ValidColumns>;
|
|
664
|
+
}>> : TypeValidationSuccess;
|
|
665
|
+
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;
|
|
666
|
+
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>>;
|
|
667
|
+
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;
|
|
668
|
+
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 {
|
|
669
|
+
valid: false;
|
|
670
|
+
error: infer E;
|
|
671
|
+
} ? TypeValidationError<E> : never : never : never;
|
|
672
|
+
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>;
|
|
673
|
+
type SchemaTablesWithSingle<Table extends AnyTableSchemaComponent> = Table extends TableSchemaComponent<infer _Columns, infer TableName, infer _FKs> ? DatabaseSchemaSchemaComponent<{ [K in TableName]: Table }> : never;
|
|
674
|
+
type DatabaseSchemasWithSingle<Schema extends AnyDatabaseSchemaSchemaComponent> = Schema extends DatabaseSchemaSchemaComponent<infer _Tables, infer _SchemaName> ? { [K in _SchemaName]: Schema } : never;
|
|
675
|
+
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<{
|
|
676
|
+
relationship: RelationshipName;
|
|
677
|
+
errors: Error extends TypeValidationError<infer E> ? E extends readonly unknown[] ? E : [E] : never;
|
|
678
|
+
}> : TypeValidationSuccess;
|
|
679
|
+
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>;
|
|
680
|
+
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<{
|
|
681
|
+
table: TableName;
|
|
682
|
+
errors: UnwrapTypeValidationErrors<Results extends readonly AnyTypeValidationError[] ? Results : never>;
|
|
683
|
+
}> : Results : TypeValidationSuccess : TypeValidationSuccess : TypeValidationSuccess;
|
|
684
|
+
type ValidateTable<Table extends AnyTableSchemaComponent, Schema extends AnyDatabaseSchemaSchemaComponent = SchemaTablesWithSingle<Table>, Schemas extends DatabaseSchemas = DatabaseSchemasWithSingle<Schema>> = ValidateTableRelationships<Table, Schema, Schemas>;
|
|
685
|
+
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<{
|
|
686
|
+
schema: SchemaName;
|
|
687
|
+
errors: UnwrapTypeValidationErrors<Results extends readonly AnyTypeValidationError[] ? Results : never>;
|
|
688
|
+
}> : TypeValidationSuccess : TypeValidationSuccess;
|
|
689
|
+
type ValidateDatabaseSchema<Schema extends AnyDatabaseSchemaSchemaComponent, Schemas extends DatabaseSchemas = DatabaseSchemasWithSingle<Schema>> = Schema extends DatabaseSchemaSchemaComponent<infer Tables, infer SchemaName> ? ValidateSchemaTables<Tables, SchemaName, Schema, Schemas> : TypeValidationSuccess;
|
|
690
|
+
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;
|
|
691
|
+
//#endregion
|
|
692
|
+
//#region src/core/errors/index.d.ts
|
|
693
|
+
declare class DumboError extends Error {
|
|
694
|
+
static readonly ErrorCode: number;
|
|
695
|
+
static readonly ErrorType: string;
|
|
696
|
+
errorCode: number;
|
|
697
|
+
errorType: string;
|
|
698
|
+
innerError: Error | undefined;
|
|
699
|
+
constructor(options?: {
|
|
700
|
+
errorCode: number;
|
|
701
|
+
errorType?: string;
|
|
702
|
+
message?: string | undefined;
|
|
703
|
+
innerError?: Error | undefined;
|
|
704
|
+
} | string | number);
|
|
705
|
+
static isInstanceOf<ErrorType extends DumboError = DumboError>(error: unknown, options?: {
|
|
706
|
+
errorCode?: number;
|
|
707
|
+
errorType?: string;
|
|
708
|
+
}): error is ErrorType;
|
|
709
|
+
}
|
|
710
|
+
//#endregion
|
|
711
|
+
//#region src/core/query/query.d.ts
|
|
712
|
+
interface QueryResultRow {
|
|
713
|
+
[column: string]: any;
|
|
714
|
+
}
|
|
715
|
+
type QueryResult<Result extends QueryResultRow = QueryResultRow> = {
|
|
716
|
+
rowCount: number | null;
|
|
717
|
+
rows: Result[];
|
|
718
|
+
};
|
|
719
|
+
//#endregion
|
|
720
|
+
//#region src/core/execute/execute.d.ts
|
|
721
|
+
type SQLQueryResultColumnMapping = {
|
|
722
|
+
[column: string]: (value: unknown) => unknown;
|
|
723
|
+
};
|
|
724
|
+
type SQLQueryOptions = {
|
|
725
|
+
timeoutMs?: number | undefined;
|
|
726
|
+
mapping?: SQLQueryResultColumnMapping;
|
|
727
|
+
};
|
|
728
|
+
type SQLCommandOptions = {
|
|
729
|
+
timeoutMs?: number | undefined;
|
|
730
|
+
mapping?: SQLQueryResultColumnMapping;
|
|
731
|
+
};
|
|
732
|
+
type BatchSQLCommandOptions = SQLCommandOptions & {
|
|
733
|
+
assertChanges?: boolean;
|
|
734
|
+
};
|
|
735
|
+
interface DbSQLExecutor<DriverType extends DatabaseDriverType = DatabaseDriverType, DbClient = unknown> {
|
|
736
|
+
driverType: DriverType;
|
|
737
|
+
query<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sql: SQL, options?: SQLQueryOptions): Promise<QueryResult<Result>>;
|
|
738
|
+
batchQuery<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sqls: SQL[], options?: SQLQueryOptions): Promise<QueryResult<Result>[]>;
|
|
739
|
+
command<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sql: SQL, options?: SQLCommandOptions): Promise<QueryResult<Result>>;
|
|
740
|
+
batchCommand<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sqls: SQL[], options?: BatchSQLCommandOptions): Promise<QueryResult<Result>[]>;
|
|
741
|
+
formatter: SQLFormatter;
|
|
742
|
+
}
|
|
743
|
+
interface SQLExecutor {
|
|
744
|
+
query<Result extends QueryResultRow = QueryResultRow>(sql: SQL, options?: SQLQueryOptions): Promise<QueryResult<Result>>;
|
|
745
|
+
batchQuery<Result extends QueryResultRow = QueryResultRow>(sqls: SQL[], options?: SQLQueryOptions): Promise<QueryResult<Result>[]>;
|
|
746
|
+
command<Result extends QueryResultRow = QueryResultRow>(sql: SQL, options?: SQLCommandOptions): Promise<QueryResult<Result>>;
|
|
747
|
+
batchCommand<Result extends QueryResultRow = QueryResultRow>(sqls: SQL[], options?: BatchSQLCommandOptions): Promise<QueryResult<Result>[]>;
|
|
748
|
+
}
|
|
749
|
+
interface WithSQLExecutor {
|
|
750
|
+
execute: SQLExecutor;
|
|
751
|
+
}
|
|
752
|
+
//#endregion
|
|
753
|
+
//#region src/core/schema/databaseMetadata/databaseMetadata.d.ts
|
|
754
|
+
interface DatabaseCapabilities<SupportsMultipleDatabases extends boolean, SupportsSchemas extends boolean, SupportsFunctions extends boolean> {
|
|
755
|
+
readonly supportsMultipleDatabases: SupportsMultipleDatabases;
|
|
756
|
+
readonly supportsSchemas: SupportsSchemas;
|
|
757
|
+
readonly supportsFunctions: SupportsFunctions;
|
|
758
|
+
}
|
|
759
|
+
type DatabaseMetadata<SupportsMultipleDatabases extends boolean = boolean, SupportsSchemas extends boolean = boolean, SupportsFunctions extends boolean = boolean> = {
|
|
760
|
+
readonly databaseType: DatabaseType;
|
|
761
|
+
readonly capabilities: DatabaseCapabilities<SupportsMultipleDatabases, SupportsSchemas, SupportsFunctions>;
|
|
762
|
+
readonly tableExists: (pool: SQLExecutor, tableName: string) => Promise<boolean>;
|
|
763
|
+
} & (SupportsMultipleDatabases extends true ? {
|
|
764
|
+
readonly defaultDatabaseName: string;
|
|
765
|
+
readonly parseDatabaseName: (connectionString?: string) => string | undefined;
|
|
766
|
+
} : {
|
|
767
|
+
readonly defaultDatabaseName?: never;
|
|
768
|
+
readonly parseDatabaseName?: never;
|
|
769
|
+
}) & (SupportsFunctions extends true ? {
|
|
770
|
+
readonly functionExists: (pool: SQLExecutor, functionName: string) => Promise<boolean>;
|
|
771
|
+
} : {
|
|
772
|
+
readonly functionExists?: (pool: SQLExecutor, functionName: string) => Promise<boolean>;
|
|
773
|
+
});
|
|
774
|
+
declare const DumboDatabaseMetadataRegistry: () => {
|
|
775
|
+
register: (databaseType: DatabaseType, info: DatabaseMetadata | (() => Promise<DatabaseMetadata>)) => void;
|
|
776
|
+
tryResolve: (databaseType: DatabaseType) => Promise<DatabaseMetadata | null>;
|
|
777
|
+
tryGet: (databaseType: DatabaseType) => DatabaseMetadata | null;
|
|
778
|
+
has: (databaseType: DatabaseType) => boolean;
|
|
779
|
+
readonly databaseTypes: DatabaseType[];
|
|
780
|
+
};
|
|
781
|
+
declare global {
|
|
782
|
+
var dumboDatabaseMetadataRegistry: ReturnType<typeof DumboDatabaseMetadataRegistry>;
|
|
783
|
+
}
|
|
784
|
+
//#endregion
|
|
785
|
+
//#region src/core/locks/databaseLock.d.ts
|
|
786
|
+
type DatabaseLockOptions = {
|
|
787
|
+
lockId: number;
|
|
788
|
+
timeoutMs?: number;
|
|
789
|
+
};
|
|
790
|
+
type AcquireDatabaseLockMode = 'Permanent' | 'Session';
|
|
791
|
+
type AcquireDatabaseLockOptions = DatabaseLockOptions & {
|
|
792
|
+
mode?: AcquireDatabaseLockMode;
|
|
793
|
+
};
|
|
794
|
+
type ReleaseDatabaseLockOptions = DatabaseLockOptions;
|
|
795
|
+
type DatabaseLock = {
|
|
796
|
+
acquire(execute: SQLExecutor, options: AcquireDatabaseLockOptions): Promise<void>;
|
|
797
|
+
tryAcquire(execute: SQLExecutor, options: AcquireDatabaseLockOptions): Promise<boolean>;
|
|
798
|
+
release(execute: SQLExecutor, options: ReleaseDatabaseLockOptions): Promise<boolean>;
|
|
799
|
+
withAcquire: <Result = unknown>(execute: SQLExecutor, handle: () => Promise<Result>, options: AcquireDatabaseLockOptions) => Promise<Result>;
|
|
800
|
+
};
|
|
801
|
+
//#endregion
|
|
802
|
+
//#region src/core/schema/migrators/migrator.d.ts
|
|
803
|
+
declare global {
|
|
804
|
+
var defaultMigratorOptions: Record<DatabaseType, MigratorOptions>;
|
|
805
|
+
}
|
|
806
|
+
type MigratorOptions = {
|
|
807
|
+
schema?: {
|
|
808
|
+
migrationTable?: SchemaComponent;
|
|
809
|
+
};
|
|
810
|
+
lock?: {
|
|
811
|
+
databaseLock?: DatabaseLock;
|
|
812
|
+
options?: Omit<DatabaseLockOptions, 'lockId'> & Partial<Pick<DatabaseLockOptions, 'lockId'>>;
|
|
813
|
+
};
|
|
814
|
+
dryRun?: boolean | undefined;
|
|
815
|
+
ignoreMigrationHashMismatch?: boolean | undefined;
|
|
816
|
+
migrationTimeoutMs?: number | undefined;
|
|
817
|
+
};
|
|
818
|
+
//#endregion
|
|
819
|
+
//#region src/core/drivers/databaseDriver.d.ts
|
|
820
|
+
interface DumboDatabaseDriver<ConnectionType extends AnyConnection = AnyConnection, DriverOptions extends unknown = unknown, DumboType extends Dumbo<ConnectionType['driverType'], ConnectionType> = Dumbo<ConnectionType['driverType'], ConnectionType>> {
|
|
821
|
+
readonly driverType: ConnectionType['driverType'];
|
|
822
|
+
readonly sqlFormatter: SQLFormatter;
|
|
823
|
+
readonly defaultMigratorOptions: MigratorOptions;
|
|
824
|
+
readonly databaseMetadata: DatabaseMetadata;
|
|
825
|
+
createPool(options: DumboConnectionOptions<this>): DumboType;
|
|
826
|
+
canHandle(options: DumboConnectionOptions<this>): boolean;
|
|
827
|
+
}
|
|
828
|
+
type AnyDumboDatabaseDriver = DumboDatabaseDriver<AnyConnection, any>;
|
|
829
|
+
type ExtractDumboDatabaseDriverOptions<DatabaseDriver> = DatabaseDriver extends DumboDatabaseDriver<any, infer O, any> ? O : never;
|
|
830
|
+
declare const DumboDatabaseDriverRegistry: () => {
|
|
831
|
+
register: <Driver extends AnyDumboDatabaseDriver>(driverType: Driver["driverType"], plugin: Driver | (() => Promise<Driver>)) => void;
|
|
832
|
+
tryResolve: <Driver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver, ConnectionOptions extends DumboConnectionOptions<Driver> = DumboConnectionOptions<Driver>>(options: ConnectionOptions) => Promise<Driver | null>;
|
|
833
|
+
tryGet: <Driver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver, ConnectionOptions extends DumboConnectionOptions<Driver> = DumboConnectionOptions<Driver>>(options: ConnectionOptions) => Driver | null;
|
|
834
|
+
has: (driverType: DatabaseDriverType) => boolean;
|
|
835
|
+
readonly databaseDriverTypes: DatabaseDriverType[];
|
|
836
|
+
};
|
|
837
|
+
declare global {
|
|
838
|
+
var dumboDatabaseDriverRegistry: ReturnType<typeof DumboDatabaseDriverRegistry>;
|
|
839
|
+
}
|
|
840
|
+
//#endregion
|
|
841
|
+
//#region src/core/drivers/index.d.ts
|
|
842
|
+
type DatabaseType = string;
|
|
843
|
+
type DatabaseDriverName = string;
|
|
844
|
+
type DatabaseDriverType<DatabaseTypeName extends DatabaseType = DatabaseType, DriverName extends DatabaseDriverName = DatabaseDriverName> = `${DatabaseTypeName}:${DriverName}`;
|
|
845
|
+
//#endregion
|
|
846
|
+
//#region src/core/connections/transaction.d.ts
|
|
847
|
+
interface DatabaseTransaction<ConnectionType extends AnyConnection = AnyConnection, TransactionOptionsType extends DatabaseTransactionOptions = DatabaseTransactionOptions> extends WithSQLExecutor {
|
|
848
|
+
driverType: ConnectionType['driverType'];
|
|
849
|
+
connection: ConnectionType;
|
|
850
|
+
begin: () => Promise<void>;
|
|
851
|
+
commit: () => Promise<void>;
|
|
852
|
+
rollback: (error?: unknown) => Promise<void>;
|
|
853
|
+
_transactionOptions: TransactionOptionsType;
|
|
854
|
+
}
|
|
855
|
+
type AnyDatabaseTransaction = DatabaseTransaction<any, any>;
|
|
856
|
+
type DatabaseTransactionOptions = {
|
|
857
|
+
allowNestedTransactions?: boolean;
|
|
858
|
+
readonly?: boolean;
|
|
859
|
+
};
|
|
860
|
+
type InferTransactionOptionsFromTransaction<C extends AnyDatabaseTransaction> = C extends DatabaseTransaction<any, infer TO> ? TO : never;
|
|
861
|
+
interface WithDatabaseTransactionFactory<ConnectionType extends AnyConnection = AnyConnection> {
|
|
862
|
+
transaction: (options?: InferTransactionOptionsFromConnection<ConnectionType>) => InferTransactionFromConnection<ConnectionType>;
|
|
863
|
+
withTransaction: <Result = never>(handle: (transaction: InferTransactionFromConnection<ConnectionType>) => Promise<TransactionResult<Result> | Result>, options?: InferTransactionOptionsFromConnection<ConnectionType>) => Promise<Result>;
|
|
864
|
+
}
|
|
865
|
+
type TransactionResult<Result> = {
|
|
866
|
+
success: boolean;
|
|
867
|
+
result: Result;
|
|
868
|
+
};
|
|
869
|
+
//#endregion
|
|
870
|
+
//#region src/core/connections/connection.d.ts
|
|
871
|
+
interface Connection<Self extends AnyConnection = AnyConnection, DriverType extends DatabaseDriverType = DatabaseDriverType, DbClient = unknown, TransactionType extends DatabaseTransaction<Self, any> = DatabaseTransaction<Self, any>> extends WithSQLExecutor, WithDatabaseTransactionFactory<Self> {
|
|
872
|
+
driverType: DriverType;
|
|
873
|
+
open: () => Promise<DbClient>;
|
|
874
|
+
close: () => Promise<void>;
|
|
875
|
+
_transactionType: TransactionType;
|
|
876
|
+
}
|
|
877
|
+
type AnyConnection = Connection<AnyConnection, DatabaseDriverType, unknown, AnyDatabaseTransaction>;
|
|
878
|
+
type InferDriverTypeFromConnection<C extends AnyConnection> = C extends Connection<any, infer DT, any, any> ? DT : never;
|
|
879
|
+
type InferDbClientFromConnection<C extends AnyConnection> = C extends Connection<any, any, infer DC, any> ? DC : never;
|
|
880
|
+
type InferTransactionFromConnection<C extends AnyConnection> = C extends Connection<any, any, any, infer DT> ? DT : never;
|
|
881
|
+
type InferTransactionOptionsFromConnection<C extends AnyConnection> = InferTransactionOptionsFromTransaction<InferTransactionFromConnection<C>>;
|
|
882
|
+
type ConnectionOptions<ConnectionType extends AnyConnection = AnyConnection> = {
|
|
883
|
+
driverType?: ConnectionType['driverType'];
|
|
884
|
+
transactionOptions?: InferTransactionOptionsFromConnection<ConnectionType>;
|
|
885
|
+
};
|
|
886
|
+
type WithConnectionOptions = {
|
|
887
|
+
readonly?: boolean;
|
|
888
|
+
};
|
|
889
|
+
interface WithConnectionFactory<ConnectionType extends AnyConnection = AnyConnection> {
|
|
890
|
+
connection: (options?: WithConnectionOptions) => Promise<ConnectionType>;
|
|
891
|
+
withConnection: <Result = unknown>(handle: (connection: ConnectionType) => Promise<Result>, options?: WithConnectionOptions) => Promise<Result>;
|
|
892
|
+
}
|
|
893
|
+
type InitTransaction<ConnectionType extends AnyConnection = AnyConnection> = (connection: () => ConnectionType) => (client: Promise<InferDbClientFromConnection<ConnectionType>>, options?: InferTransactionOptionsFromConnection<ConnectionType> & {
|
|
894
|
+
close: (client: InferDbClientFromConnection<ConnectionType>, error?: unknown) => Promise<void>;
|
|
895
|
+
}) => InferTransactionFromConnection<ConnectionType>;
|
|
896
|
+
//#endregion
|
|
897
|
+
//#region src/core/connections/pool.d.ts
|
|
898
|
+
interface ConnectionPool<ConnectionType extends AnyConnection = AnyConnection> extends WithSQLExecutor, WithConnectionFactory<ConnectionType>, WithDatabaseTransactionFactory<ConnectionType> {
|
|
899
|
+
driverType: ConnectionType['driverType'];
|
|
900
|
+
close: () => Promise<void>;
|
|
901
|
+
}
|
|
902
|
+
//#endregion
|
|
903
|
+
//#region src/core/index.d.ts
|
|
904
|
+
type Dumbo<DriverType extends DatabaseDriverType = DatabaseDriverType, ConnectionType extends AnyConnection = AnyConnection> = ConnectionPool<ConnectionType>;
|
|
905
|
+
type DumboConnectionOptions<DatabaseDriver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver> = ExtractDumboDatabaseDriverOptions<DatabaseDriver> extends infer Options ? Options extends unknown ? {
|
|
906
|
+
driver?: DatabaseDriver;
|
|
907
|
+
driverType?: DatabaseDriver['driverType'];
|
|
908
|
+
} & Omit<Options, 'driver' | 'driverType' | 'connectionString'> : never : never;
|
|
909
|
+
//#endregion
|
|
910
|
+
//#region src/storage/all/connections/connectionString.d.ts
|
|
911
|
+
type DatabaseConnectionString<DatabaseTypeName extends DatabaseType = DatabaseType, Format extends string = string> = Format & {
|
|
912
|
+
_databaseType: DatabaseTypeName;
|
|
913
|
+
};
|
|
914
|
+
//#endregion
|
|
915
|
+
//#region src/storage/sqlite/core/schema/sqliteMetadata.d.ts
|
|
916
|
+
declare const sqliteMetadata: DatabaseMetadata<false, false, false>;
|
|
917
|
+
//#endregion
|
|
918
|
+
//#region src/storage/sqlite/core/execute/execute.d.ts
|
|
919
|
+
type SQLiteErrorMapper = (error: unknown) => DumboError;
|
|
920
|
+
declare const sqliteExecute: <Result = void>(database: SQLiteClient, handle: (client: SQLiteClient) => Promise<Result>) => Promise<Result>;
|
|
921
|
+
type SQLiteSQLExecutor<DriverType extends SQLiteDriverType = SQLiteDriverType> = DbSQLExecutor<DriverType, SQLiteClient>;
|
|
922
|
+
declare const sqliteSQLExecutor: <DriverType extends SQLiteDriverType = SQLiteDriverType>(driverType: DriverType, serializer: JSONSerializer, formatter?: SQLFormatter, errorMapper?: SQLiteErrorMapper) => SQLiteSQLExecutor<DriverType>;
|
|
923
|
+
//#endregion
|
|
924
|
+
//#region src/storage/sqlite/core/transactions/index.d.ts
|
|
925
|
+
type SQLiteTransaction<ConnectionType extends AnySQLiteConnection = AnySQLiteConnection, TransactionOptions extends SQLiteTransactionOptions = SQLiteTransactionOptions> = DatabaseTransaction<ConnectionType, TransactionOptions>;
|
|
926
|
+
type SQLiteTransactionMode = 'DEFERRED' | 'IMMEDIATE' | 'EXCLUSIVE';
|
|
927
|
+
type SQLiteTransactionOptions = DatabaseTransactionOptions & {
|
|
928
|
+
mode?: SQLiteTransactionMode;
|
|
929
|
+
useSavepoints?: boolean;
|
|
930
|
+
};
|
|
931
|
+
declare const sqliteTransaction: <ConnectionType extends AnySQLiteConnection = AnySQLiteConnection>(driverType: ConnectionType["driverType"], connection: () => ConnectionType, allowNestedTransactions: boolean, serializer: JSONSerializer, defaultTransactionMode?: "IMMEDIATE" | "DEFERRED" | "EXCLUSIVE") => (getClient: Promise<InferDbClientFromConnection<ConnectionType>>, options?: {
|
|
932
|
+
close: (client: InferDbClientFromConnection<ConnectionType>, error?: unknown) => Promise<void>;
|
|
933
|
+
} & SQLiteTransactionOptions) => InferTransactionFromConnection<ConnectionType>;
|
|
934
|
+
//#endregion
|
|
935
|
+
//#region src/storage/sqlite/core/connections/connectionString.d.ts
|
|
936
|
+
type SQLitePragmaOptions = {
|
|
937
|
+
journal_mode?: 'DELETE' | 'TRUNCATE' | 'PERSIST' | 'MEMORY' | 'WAL' | 'OFF';
|
|
938
|
+
synchronous?: 'OFF' | 'NORMAL' | 'FULL' | 'EXTRA';
|
|
939
|
+
cache_size?: number;
|
|
940
|
+
foreign_keys?: boolean;
|
|
941
|
+
temp_store?: 'DEFAULT' | 'FILE' | 'MEMORY';
|
|
942
|
+
busy_timeout?: number;
|
|
943
|
+
mmap_size?: number;
|
|
944
|
+
};
|
|
945
|
+
type SQLiteConnectionString = DatabaseConnectionString<'SQLite', `file:${string}` | `:memory:` | `/${string}` | `./${string}`>;
|
|
946
|
+
declare const SQLiteConnectionString: (connectionString: string) => SQLiteConnectionString;
|
|
947
|
+
declare const parsePragmasFromConnectionString: (connectionString: string | SQLiteConnectionString) => Partial<SQLitePragmaOptions>;
|
|
948
|
+
//#endregion
|
|
949
|
+
//#region src/storage/sqlite/core/connections/index.d.ts
|
|
950
|
+
type SQLiteCommandOptions = SQLCommandOptions & {
|
|
951
|
+
ignoreChangesCount?: boolean;
|
|
952
|
+
};
|
|
953
|
+
type BatchSQLiteCommandOptions = SQLiteCommandOptions & BatchSQLCommandOptions;
|
|
954
|
+
type SQLiteParameters = object | string | bigint | number | boolean | null;
|
|
955
|
+
type SQLiteClient = {
|
|
956
|
+
connect: () => Promise<void>;
|
|
957
|
+
close: () => Promise<void>;
|
|
958
|
+
} & SQLExecutor;
|
|
959
|
+
type SQLitePoolClient = {
|
|
960
|
+
release: () => void;
|
|
961
|
+
} & SQLExecutor;
|
|
962
|
+
type SQLiteClientFactory<SQLiteClientType extends SQLiteClient = SQLiteClient, ClientOptions = SQLiteClientOptions> = (options: ClientOptions) => SQLiteClientType;
|
|
963
|
+
type SQLiteClientOrPoolClient = SQLitePoolClient | SQLiteClient;
|
|
964
|
+
interface SQLiteError extends Error {
|
|
965
|
+
errno: number;
|
|
966
|
+
}
|
|
967
|
+
declare const isSQLiteError: (error: unknown) => error is SQLiteError;
|
|
968
|
+
type SQLiteClientConnection<Self extends AnyConnection = AnyConnection, DriverType extends SQLiteDriverType = SQLiteDriverType, SQLiteClientType extends SQLiteClient = SQLiteClient, TransactionType extends DatabaseTransaction<Self> = DatabaseTransaction<Self>> = Connection<Self, DriverType, SQLiteClientType, TransactionType>;
|
|
969
|
+
type SQLitePoolClientConnection<Self extends AnyConnection = AnyConnection, DriverType extends SQLiteDriverType = SQLiteDriverType, SQLitePoolClientType extends SQLitePoolClient = SQLitePoolClient, TransactionType extends DatabaseTransaction<Self> = DatabaseTransaction<Self>> = Connection<Self, DriverType, SQLitePoolClientType, TransactionType>;
|
|
970
|
+
type SQLiteConnection<Self extends AnyConnection = AnyConnection, DriverType extends SQLiteDriverType = SQLiteDriverType, SQLiteClientType extends SQLiteClientOrPoolClient = SQLiteClient | SQLitePoolClient, TransactionType extends DatabaseTransaction<Self> = DatabaseTransaction<Self>> = (SQLiteClientType extends SQLiteClient ? SQLiteClientConnection<Self, DriverType, SQLiteClientType, TransactionType> : never) | (SQLiteClientType extends SQLitePoolClient ? SQLitePoolClientConnection<Self, DriverType, SQLiteClientType, TransactionType> : never);
|
|
971
|
+
type AnySQLiteClientConnection = SQLiteClientConnection<any, any>;
|
|
972
|
+
type AnySQLitePoolClientConnection = SQLitePoolClientConnection<any, any, any, any>;
|
|
973
|
+
type AnySQLiteConnection = SQLiteConnection<any, any, any, any>;
|
|
974
|
+
type SQLiteConnectionOptions<ConnectionType extends AnySQLiteConnection = AnySQLiteConnection> = ConnectionOptions<ConnectionType> & SQLiteClientOptions;
|
|
975
|
+
type SQLiteClientConnectionDefinitionOptions<SQLiteConnectionType extends AnySQLiteClientConnection = AnySQLiteClientConnection, ConnectionOptions = SQLiteConnectionOptions> = {
|
|
976
|
+
driverType: InferDriverTypeFromConnection<SQLiteConnectionType>;
|
|
977
|
+
type: 'Client';
|
|
978
|
+
sqliteClientFactory: SQLiteClientFactory<InferDbClientFromConnection<SQLiteConnectionType>, ConnectionOptions>;
|
|
979
|
+
connectionOptions: SQLiteConnectionOptions<SQLiteConnectionType>;
|
|
980
|
+
serializer: JSONSerializer;
|
|
981
|
+
};
|
|
982
|
+
type SQLitePoolConnectionDefinitionOptions<SQLiteConnectionType extends AnySQLitePoolClientConnection = AnySQLitePoolClientConnection, ConnectionOptions = SQLiteConnectionOptions> = {
|
|
983
|
+
driverType: InferDriverTypeFromConnection<SQLiteConnectionType>;
|
|
984
|
+
type: 'PoolClient';
|
|
985
|
+
sqliteClientFactory: SQLiteClientFactory<InferDbClientFromConnection<SQLiteConnectionType>, ConnectionOptions>;
|
|
986
|
+
connectionOptions: SQLiteConnectionOptions<SQLiteConnectionType>;
|
|
987
|
+
serializer: JSONSerializer;
|
|
988
|
+
};
|
|
989
|
+
type SQLiteConnectionDefinitionOptions<SQLiteConnectionType extends AnySQLitePoolClientConnection = AnySQLitePoolClientConnection, ClientOptions = SQLiteClientOptions> = SQLiteClientConnectionDefinitionOptions<SQLiteConnectionType, ClientOptions> | SQLitePoolConnectionDefinitionOptions<SQLiteConnectionType, ClientOptions>;
|
|
990
|
+
type SQLiteConnectionFactory<SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection, ConnectionOptions extends SQLiteConnectionOptions = SQLiteConnectionOptions> = (options: ConnectionOptions) => SQLiteConnectionType;
|
|
991
|
+
type TransactionNestingCounter = {
|
|
992
|
+
increment: () => void;
|
|
993
|
+
decrement: () => void;
|
|
994
|
+
reset: () => void;
|
|
995
|
+
level: number;
|
|
996
|
+
};
|
|
997
|
+
declare const transactionNestingCounter: () => TransactionNestingCounter;
|
|
998
|
+
type SqliteAmbientClientConnectionOptions<SQLiteConnectionType extends AnySQLiteClientConnection = AnySQLiteClientConnection> = {
|
|
999
|
+
driverType: SQLiteConnectionType['driverType'];
|
|
1000
|
+
client: InferDbClientFromConnection<SQLiteConnectionType>;
|
|
1001
|
+
initTransaction?: InitTransaction<SQLiteConnectionType>;
|
|
1002
|
+
allowNestedTransactions?: boolean;
|
|
1003
|
+
defaultTransactionMode?: SQLiteTransactionMode;
|
|
1004
|
+
serializer: JSONSerializer;
|
|
1005
|
+
errorMapper?: SQLiteErrorMapper;
|
|
1006
|
+
};
|
|
1007
|
+
declare const sqliteAmbientClientConnection: <SQLiteConnectionType extends AnySQLiteClientConnection = AnySQLiteClientConnection>(options: SqliteAmbientClientConnectionOptions<SQLiteConnectionType>) => SQLiteConnectionType;
|
|
1008
|
+
declare const sqliteClientConnection: <SQLiteConnectionType extends AnySQLiteClientConnection = AnySQLiteClientConnection, ClientOptions = SQLiteClientOptions>(options: SQLiteClientConnectionDefinitionOptions<SQLiteConnectionType, ClientOptions>) => SQLiteConnectionType;
|
|
1009
|
+
declare const sqlitePoolClientConnection: <SQLiteConnectionType extends AnySQLiteClientConnection = AnySQLiteClientConnection, ClientOptions = SQLiteClientOptions>(options: SQLitePoolConnectionDefinitionOptions<SQLiteConnectionType, ClientOptions>) => SQLiteConnectionType;
|
|
1010
|
+
declare function sqliteConnection<SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection, ClientOptions = SQLiteClientOptions>(options: SQLiteConnectionDefinitionOptions<SQLiteConnectionType, ClientOptions>): SQLiteConnectionType;
|
|
1011
|
+
type InMemorySQLiteDatabase = ':memory:';
|
|
1012
|
+
declare const InMemorySQLiteDatabase: SQLiteConnectionString;
|
|
1013
|
+
declare const DEFAULT_SQLITE_PRAGMA_OPTIONS: SQLitePragmaOptions;
|
|
1014
|
+
type SQLiteClientOptions = {
|
|
1015
|
+
pragmaOptions?: Partial<SQLitePragmaOptions>;
|
|
1016
|
+
defaultTransactionMode?: SQLiteTransactionMode;
|
|
1017
|
+
skipDatabasePragmas?: boolean;
|
|
1018
|
+
readonly?: boolean;
|
|
1019
|
+
};
|
|
1020
|
+
//#endregion
|
|
1021
|
+
//#region src/storage/sqlite/core/errors/errorMapper.d.ts
|
|
1022
|
+
/**
|
|
1023
|
+
* Maps a SQLite error (from the `sqlite3` / node-sqlite3 driver) to a typed
|
|
1024
|
+
* DumboError based on the SQLite result code.
|
|
1025
|
+
*
|
|
1026
|
+
* Result code reference: https://www.sqlite.org/rescode.html
|
|
1027
|
+
*
|
|
1028
|
+
* Falls back to a generic DumboError (500) if the error is not a recognized SQLite error.
|
|
1029
|
+
*/
|
|
1030
|
+
declare const mapSqliteError: (error: unknown) => DumboError;
|
|
1031
|
+
//#endregion
|
|
1032
|
+
//#region src/storage/sqlite/core/pool/pool.d.ts
|
|
1033
|
+
type SQLiteFileNameOrConnectionString = {
|
|
1034
|
+
fileName: string | SQLiteConnectionString;
|
|
1035
|
+
connectionString?: never;
|
|
1036
|
+
} | {
|
|
1037
|
+
connectionString: string | SQLiteConnectionString;
|
|
1038
|
+
fileName?: never;
|
|
1039
|
+
};
|
|
1040
|
+
declare const isInMemoryDatabase: (options: Record<string, unknown>) => boolean;
|
|
1041
|
+
type SQLiteAmbientConnectionPool<SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection> = ConnectionPool<SQLiteConnectionType>;
|
|
1042
|
+
type SQLiteAmbientConnectionPoolOptions<SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection> = {
|
|
1043
|
+
singleton?: true;
|
|
1044
|
+
pooled?: false;
|
|
1045
|
+
sqliteConnectionFactory?: never;
|
|
1046
|
+
connection: SQLiteConnectionType;
|
|
1047
|
+
connectionOptions?: never;
|
|
1048
|
+
};
|
|
1049
|
+
declare const sqliteAmbientConnectionPool: <SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection>(options: {
|
|
1050
|
+
driverType: SQLiteConnectionType["driverType"];
|
|
1051
|
+
} & SQLiteAmbientConnectionPoolOptions<SQLiteConnectionType["driverType"]>) => SQLiteAmbientConnectionPool<SQLiteConnectionType["driverType"]>;
|
|
1052
|
+
type SQLiteSingletonConnectionPoolOptions<SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection, ConnectionOptions extends SQLiteConnectionOptions = SQLiteConnectionOptions> = {
|
|
1053
|
+
singleton: true;
|
|
1054
|
+
pooled?: true;
|
|
1055
|
+
sqliteConnectionFactory: SQLiteConnectionFactory<SQLiteConnectionType, ConnectionOptions>;
|
|
1056
|
+
connection?: never;
|
|
1057
|
+
connectionOptions: ConnectionOptions;
|
|
1058
|
+
};
|
|
1059
|
+
type SQLiteSingletonConnectionPool<SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection> = ConnectionPool<SQLiteConnectionType>;
|
|
1060
|
+
declare const sqliteSingletonConnectionPool: <SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection, ConnectionOptions extends SQLiteConnectionOptions & Record<string, unknown> = SQLiteConnectionOptions & Record<string, unknown>>(options: {
|
|
1061
|
+
driverType: SQLiteConnectionType["driverType"];
|
|
1062
|
+
} & SQLiteSingletonConnectionPoolOptions<SQLiteConnectionType, ConnectionOptions>) => SQLiteSingletonConnectionPool<SQLiteConnectionType>;
|
|
1063
|
+
type SQLiteAlwaysNewPoolOptions<SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection, ConnectionOptions extends SQLiteConnectionOptions = SQLiteConnectionOptions> = {
|
|
1064
|
+
singleton?: false;
|
|
1065
|
+
pooled?: true;
|
|
1066
|
+
sqliteConnectionFactory: SQLiteConnectionFactory<SQLiteConnectionType, ConnectionOptions>;
|
|
1067
|
+
connection?: never;
|
|
1068
|
+
connectionOptions: ConnectionOptions;
|
|
1069
|
+
};
|
|
1070
|
+
type SQLiteAlwaysNewConnectionPool<SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection> = ConnectionPool<SQLiteConnectionType>;
|
|
1071
|
+
declare const sqliteAlwaysNewConnectionPool: <SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection, ConnectionOptions extends SQLiteConnectionOptions & Record<string, unknown> = SQLiteConnectionOptions & Record<string, unknown>>(options: {
|
|
1072
|
+
driverType: SQLiteConnectionType["driverType"];
|
|
1073
|
+
} & SQLiteAlwaysNewPoolOptions<SQLiteConnectionType, ConnectionOptions>) => SQLiteAlwaysNewConnectionPool<SQLiteConnectionType>;
|
|
1074
|
+
type SQLitePoolOptions<SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection, ConnectionOptions extends SQLiteConnectionOptions = SQLiteConnectionOptions> = (SQLiteAlwaysNewPoolOptions<SQLiteConnectionType, ConnectionOptions> | SQLiteSingletonConnectionPoolOptions<SQLiteConnectionType, ConnectionOptions> | SQLiteAmbientConnectionPoolOptions<SQLiteConnectionType>) & {
|
|
1075
|
+
driverType: SQLiteConnectionType['driverType'];
|
|
1076
|
+
serializer?: JSONSerializer;
|
|
1077
|
+
};
|
|
1078
|
+
type SQLitePool<SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection> = SQLiteAmbientConnectionPool<SQLiteConnectionType> | SQLiteSingletonConnectionPool<SQLiteConnectionType> | SQLiteAlwaysNewConnectionPool<SQLiteConnectionType>;
|
|
1079
|
+
type SQLitePoolFactoryOptions<SQLiteConnectionType extends AnySQLiteConnection, ConnectionOptions extends SQLiteConnectionOptions> = Omit<SQLitePoolOptions<SQLiteConnectionType, ConnectionOptions>, 'singleton'> & {
|
|
1080
|
+
singleton?: boolean;
|
|
1081
|
+
};
|
|
1082
|
+
declare const toSqlitePoolOptions: <SQLiteConnectionType extends AnySQLiteConnection, ConnectionOptions extends SQLiteConnectionOptions>(options: SQLitePoolFactoryOptions<SQLiteConnectionType, ConnectionOptions>) => SQLitePoolOptions<SQLiteConnectionType, ConnectionOptions>;
|
|
1083
|
+
declare function sqlitePool<SQLiteConnectionType extends AnySQLiteConnection = AnySQLiteConnection, ConnectionOptions extends SQLiteConnectionOptions = SQLiteConnectionOptions>(options: SQLitePoolOptions<SQLiteConnectionType, ConnectionOptions>): SQLitePool<SQLiteConnectionType>;
|
|
1084
|
+
//#endregion
|
|
1085
|
+
//#region src/storage/sqlite/core/schema/migrations.d.ts
|
|
1086
|
+
declare const DefaultSQLiteMigratorOptions: MigratorOptions;
|
|
1087
|
+
//#endregion
|
|
1088
|
+
//#region src/storage/sqlite/core/schema/schema.d.ts
|
|
1089
|
+
declare const defaultSQLiteDatabase = ":memory:";
|
|
1090
|
+
declare const tableExists: (execute: SQLExecutor, tableName: string) => Promise<boolean>;
|
|
1091
|
+
//#endregion
|
|
1092
|
+
//#region src/storage/sqlite/core/sql/formatter/index.d.ts
|
|
1093
|
+
declare const sqliteFormatter: SQLFormatter;
|
|
1094
|
+
//#endregion
|
|
1095
|
+
//#region src/storage/sqlite/core/sql/json.d.ts
|
|
1096
|
+
declare const SQLiteJSON: {
|
|
1097
|
+
readonly path: (path: string) => SQLPlain;
|
|
1098
|
+
};
|
|
1099
|
+
//#endregion
|
|
1100
|
+
//#region src/storage/sqlite/core/index.d.ts
|
|
1101
|
+
type SQLiteDatabaseName = 'SQLite';
|
|
1102
|
+
declare const SQLiteDatabaseName = "SQLite";
|
|
1103
|
+
type SQLiteDriverType<DriverName extends string = string> = DatabaseDriverType<SQLiteDatabaseName, DriverName>;
|
|
1104
|
+
type SQLiteDatabaseType = 'SQLite';
|
|
1105
|
+
//#endregion
|
|
1106
|
+
export { AnySQLiteClientConnection, AnySQLiteConnection, AnySQLitePoolClientConnection, BatchSQLiteCommandOptions, DEFAULT_SQLITE_PRAGMA_OPTIONS, DefaultSQLiteMigratorOptions, InMemorySQLiteDatabase, SQLiteAlwaysNewConnectionPool, SQLiteAmbientConnectionPool, SQLiteClient, SQLiteClientConnection, SQLiteClientConnectionDefinitionOptions, SQLiteClientFactory, SQLiteClientOptions, SQLiteClientOrPoolClient, SQLiteCommandOptions, SQLiteConnection, SQLiteConnectionDefinitionOptions, SQLiteConnectionFactory, SQLiteConnectionOptions, SQLiteConnectionString, SQLiteDatabaseName, SQLiteDatabaseType, SQLiteDriverType, SQLiteError, SQLiteErrorMapper, SQLiteFileNameOrConnectionString, SQLiteJSON, SQLiteParameters, SQLitePool, SQLitePoolClient, SQLitePoolClientConnection, SQLitePoolConnectionDefinitionOptions, SQLitePoolFactoryOptions, SQLitePoolOptions, type SQLitePragmaOptions, SQLiteSQLExecutor, SQLiteSingletonConnectionPool, SQLiteTransaction, SQLiteTransactionMode, SQLiteTransactionOptions, SqliteAmbientClientConnectionOptions, TransactionNestingCounter, defaultSQLiteDatabase, isInMemoryDatabase, isSQLiteError, mapSqliteError, parsePragmasFromConnectionString, sqliteAlwaysNewConnectionPool, sqliteAmbientClientConnection, sqliteAmbientConnectionPool, sqliteClientConnection, sqliteConnection, sqliteExecute, sqliteFormatter, sqliteMetadata, sqlitePool, sqlitePoolClientConnection, sqliteSQLExecutor, sqliteSingletonConnectionPool, sqliteTransaction, tableExists, toSqlitePoolOptions, transactionNestingCounter };
|
|
1107
|
+
//# sourceMappingURL=sqlite.d.ts.map
|