@event-driven-io/dumbo 0.13.0-beta.4 → 0.13.0-beta.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cloudflare.cjs +397 -0
- package/dist/cloudflare.cjs.map +1 -0
- package/dist/cloudflare.d.cts +99 -0
- package/dist/cloudflare.d.ts +99 -0
- package/dist/cloudflare.js +361 -0
- package/dist/cloudflare.js.map +1 -0
- package/dist/core-BG__WVn6.js +2262 -0
- package/dist/core-BG__WVn6.js.map +1 -0
- package/dist/core-BchvTX3G.js +379 -0
- package/dist/core-BchvTX3G.js.map +1 -0
- package/dist/core-CWZb0zOY.cjs +588 -0
- package/dist/core-CWZb0zOY.cjs.map +1 -0
- package/dist/core-D-smW7cm.cjs +3243 -0
- package/dist/core-D-smW7cm.cjs.map +1 -0
- package/dist/core-DXCRR5A9.cjs +450 -0
- package/dist/core-DXCRR5A9.cjs.map +1 -0
- package/dist/core-DlV8ua1P.js +451 -0
- package/dist/core-DlV8ua1P.js.map +1 -0
- package/dist/index-BDSQvDH2.d.cts +1585 -0
- package/dist/index-BdWFmDhJ.d.cts +68 -0
- package/dist/{index-C0h0c380.d.cts → index-BgFHGsuP.d.ts} +122 -75
- package/dist/index-DaP2fTEX.d.ts +67 -0
- package/dist/{index-C2z_XBn6.d.ts → index-N2ly5shv.d.cts} +122 -75
- package/dist/index-S_wp0Eaf.d.cts +67 -0
- package/dist/index-cxtbLiju.d.ts +68 -0
- package/dist/index-zkszkJqP.d.ts +1585 -0
- package/dist/index.cjs +219 -270
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -127
- package/dist/index.d.ts +3 -127
- package/dist/index.js +56 -269
- package/dist/index.js.map +1 -1
- package/dist/pg.cjs +373 -659
- package/dist/pg.cjs.map +1 -1
- package/dist/pg.d.cts +140 -153
- package/dist/pg.d.ts +140 -153
- package/dist/pg.js +326 -658
- package/dist/pg.js.map +1 -1
- package/dist/postgreSQLMetadata-BTz6vdwE.js +65 -0
- package/dist/postgreSQLMetadata-BTz6vdwE.js.map +1 -0
- package/dist/postgreSQLMetadata-WGXySO7a.cjs +118 -0
- package/dist/postgreSQLMetadata-WGXySO7a.cjs.map +1 -0
- package/dist/postgresql.cjs +25 -0
- package/dist/postgresql.d.cts +3 -0
- package/dist/postgresql.d.ts +3 -0
- package/dist/postgresql.js +4 -0
- package/dist/sqlite.cjs +30 -0
- package/dist/sqlite.d.cts +3 -0
- package/dist/sqlite.d.ts +3 -0
- package/dist/sqlite.js +4 -0
- package/dist/sqlite3.cjs +437 -273
- package/dist/sqlite3.cjs.map +1 -1
- package/dist/sqlite3.d.cts +92 -70
- package/dist/sqlite3.d.ts +92 -70
- package/dist/sqlite3.js +402 -272
- package/dist/sqlite3.js.map +1 -1
- package/dist/sqliteMetadata-7qBjsMBN.js +29 -0
- package/dist/sqliteMetadata-7qBjsMBN.js.map +1 -0
- package/dist/sqliteMetadata-PJTRPIZ1.cjs +46 -0
- package/dist/sqliteMetadata-PJTRPIZ1.cjs.map +1 -0
- package/package.json +60 -37
- package/dist/chunk-32AL3EAS.cjs +0 -47
- package/dist/chunk-32AL3EAS.cjs.map +0 -1
- package/dist/chunk-6IHCIJ7S.js +0 -47
- package/dist/chunk-6IHCIJ7S.js.map +0 -1
- package/dist/chunk-IYEHOE4S.cjs +0 -405
- package/dist/chunk-IYEHOE4S.cjs.map +0 -1
- package/dist/chunk-N7RWT46K.js +0 -2011
- package/dist/chunk-N7RWT46K.js.map +0 -1
- package/dist/chunk-OJ34O3Q2.cjs +0 -2011
- package/dist/chunk-OJ34O3Q2.cjs.map +0 -1
- package/dist/chunk-XVV3OOQX.js +0 -405
- package/dist/chunk-XVV3OOQX.js.map +0 -1
- package/dist/columnProcessors-BX-sH7ah.d.cts +0 -8
- package/dist/columnProcessors-DMPpTPqM.d.ts +0 -8
- package/dist/connectionString-B1wm0TFc.d.cts +0 -1271
- package/dist/connectionString-B1wm0TFc.d.ts +0 -1271
- package/dist/d1.cjs +0 -277
- package/dist/d1.cjs.map +0 -1
- package/dist/d1.d.cts +0 -72
- package/dist/d1.d.ts +0 -72
- package/dist/d1.js +0 -277
- package/dist/d1.js.map +0 -1
|
@@ -1,1271 +0,0 @@
|
|
|
1
|
-
interface ParametrizedSQL {
|
|
2
|
-
query: string;
|
|
3
|
-
params: unknown[];
|
|
4
|
-
}
|
|
5
|
-
interface ParametrizedSQLBuilder {
|
|
6
|
-
addSQL: (str: string) => ParametrizedSQLBuilder;
|
|
7
|
-
addParam(value: unknown): ParametrizedSQLBuilder;
|
|
8
|
-
addParams(values: unknown[]): ParametrizedSQLBuilder;
|
|
9
|
-
build: () => ParametrizedSQL;
|
|
10
|
-
}
|
|
11
|
-
declare const ParametrizedSQLBuilder: ({ mapParamPlaceholder, }: {
|
|
12
|
-
mapParamPlaceholder: (index: number, value: unknown) => string;
|
|
13
|
-
}) => ParametrizedSQLBuilder;
|
|
14
|
-
|
|
15
|
-
type ExtractSQLTokenType<T> = T extends (...args: never[]) => infer R ? R extends SQLToken ? R : never : T extends SQLToken ? T : never;
|
|
16
|
-
type AnySQLToken = SQLToken<string, any>;
|
|
17
|
-
type SQLToken<TSymbol extends string = string, TProps extends Omit<Record<string, unknown>, 'sqlTokenType'> | undefined = Omit<Record<string, unknown>, 'sqlTokenType'> | undefined> = {
|
|
18
|
-
sqlTokenType: TSymbol;
|
|
19
|
-
} & (TProps extends undefined ? void : Omit<TProps, 'sqlTokenType'>);
|
|
20
|
-
declare const SQLToken: {
|
|
21
|
-
<SQLTokenType extends AnySQLToken, TInput = Exclude<keyof SQLTokenType, "sqlTokenType"> extends never ? void : Omit<SQLTokenType, "sqlTokenType">>(sqlTokenType: SQLTokenType["sqlTokenType"], map?: (input: TInput) => Omit<SQLTokenType, "sqlTokenType">): {
|
|
22
|
-
from: (input: TInput) => SQLTokenType;
|
|
23
|
-
check: (token: unknown) => token is SQLTokenType;
|
|
24
|
-
type: SQLTokenType["sqlTokenType"];
|
|
25
|
-
};
|
|
26
|
-
check<SQLTokenType extends AnySQLToken>(token: unknown): token is SQLTokenType;
|
|
27
|
-
};
|
|
28
|
-
type SQLIdentifier = SQLToken<'SQL_IDENTIFIER', {
|
|
29
|
-
value: string;
|
|
30
|
-
}>;
|
|
31
|
-
declare const SQLIdentifier: {
|
|
32
|
-
from: (input: string) => SQLIdentifier;
|
|
33
|
-
check: (token: unknown) => token is SQLIdentifier;
|
|
34
|
-
type: "SQL_IDENTIFIER";
|
|
35
|
-
};
|
|
36
|
-
type SQLPlain = SQLToken<'SQL_RAW', {
|
|
37
|
-
value: string;
|
|
38
|
-
}>;
|
|
39
|
-
declare const SQLPlain: {
|
|
40
|
-
from: (input: string) => SQLPlain;
|
|
41
|
-
check: (token: unknown) => token is SQLPlain;
|
|
42
|
-
type: "SQL_RAW";
|
|
43
|
-
};
|
|
44
|
-
type SQLLiteral = SQLToken<'SQL_LITERAL', {
|
|
45
|
-
value: unknown;
|
|
46
|
-
}>;
|
|
47
|
-
declare const SQLLiteral: {
|
|
48
|
-
from: (input: unknown) => SQLLiteral;
|
|
49
|
-
check: (token: unknown) => token is SQLLiteral;
|
|
50
|
-
type: "SQL_LITERAL";
|
|
51
|
-
};
|
|
52
|
-
type SQLArray = SQLToken<'SQL_ARRAY', {
|
|
53
|
-
value: unknown[];
|
|
54
|
-
}>;
|
|
55
|
-
declare const SQLArray: {
|
|
56
|
-
from: (input: unknown[]) => SQLArray;
|
|
57
|
-
check: (token: unknown) => token is SQLArray;
|
|
58
|
-
type: "SQL_ARRAY";
|
|
59
|
-
};
|
|
60
|
-
type SQLIn = SQLToken<'SQL_IN', {
|
|
61
|
-
column: SQLIdentifier;
|
|
62
|
-
values: SQLArray;
|
|
63
|
-
}>;
|
|
64
|
-
declare const SQLIn: {
|
|
65
|
-
from: (input: {
|
|
66
|
-
column: string;
|
|
67
|
-
values: unknown[];
|
|
68
|
-
}) => SQLIn;
|
|
69
|
-
check: (token: unknown) => token is SQLIn;
|
|
70
|
-
type: "SQL_IN";
|
|
71
|
-
};
|
|
72
|
-
type SQLDefaultTokens = SQLIdentifier | SQLPlain | SQLLiteral | SQLArray;
|
|
73
|
-
type SQLDefaultTokensTypes = SQLDefaultTokens['sqlTokenType'];
|
|
74
|
-
|
|
75
|
-
type JSONValueType = Record<string, unknown> | Array<unknown> | string | number | boolean | null;
|
|
76
|
-
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';
|
|
77
|
-
type JavaScriptValueType = Record<string, unknown> | Array<unknown> | string | number | boolean | null | undefined | Date | bigint;
|
|
78
|
-
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';
|
|
79
|
-
type JavaScriptValueTypeToNameMap = {
|
|
80
|
-
[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;
|
|
81
|
-
};
|
|
82
|
-
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> & {
|
|
83
|
-
__brand: ValueType extends undefined ? JavaScriptValueTypeToNameMap[JSValueTypeName] : ValueType;
|
|
84
|
-
jsTypeName: JSValueTypeName;
|
|
85
|
-
};
|
|
86
|
-
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">) => {
|
|
87
|
-
from: (input: TInput) => SQLTokenType;
|
|
88
|
-
check: (token: unknown) => token is SQLTokenType;
|
|
89
|
-
type: SQLTokenType["sqlTokenType"];
|
|
90
|
-
};
|
|
91
|
-
type AnyColumnTypeToken = ColumnTypeToken<any, string, any>;
|
|
92
|
-
type SerialToken = ColumnTypeToken<'value_type:js:number', 'SERIAL'>;
|
|
93
|
-
declare const SerialToken: {
|
|
94
|
-
from: (input: void) => SerialToken;
|
|
95
|
-
check: (token: unknown) => token is SerialToken;
|
|
96
|
-
type: "SQL_COLUMN_SERIAL";
|
|
97
|
-
};
|
|
98
|
-
type BigSerialToken = ColumnTypeToken<'value_type:js:bigint', 'BIGSERIAL'>;
|
|
99
|
-
declare const BigSerialToken: {
|
|
100
|
-
from: (input: void) => BigSerialToken;
|
|
101
|
-
check: (token: unknown) => token is BigSerialToken;
|
|
102
|
-
type: "SQL_COLUMN_BIGSERIAL";
|
|
103
|
-
};
|
|
104
|
-
type IntegerToken = ColumnTypeToken<'value_type:js:number', 'INTEGER'>;
|
|
105
|
-
declare const IntegerToken: {
|
|
106
|
-
from: (input: void) => IntegerToken;
|
|
107
|
-
check: (token: unknown) => token is IntegerToken;
|
|
108
|
-
type: "SQL_COLUMN_INTEGER";
|
|
109
|
-
};
|
|
110
|
-
type BigIntegerToken = ColumnTypeToken<'value_type:js:bigint', 'BIGINT'>;
|
|
111
|
-
declare const BigIntegerToken: {
|
|
112
|
-
from: (input: void) => BigIntegerToken;
|
|
113
|
-
check: (token: unknown) => token is BigIntegerToken;
|
|
114
|
-
type: "SQL_COLUMN_BIGINT";
|
|
115
|
-
};
|
|
116
|
-
type JSONBToken<ValueType extends Record<string, unknown> = Record<string, unknown>> = ColumnTypeToken<'value_type:js:object', 'JSONB', undefined, ValueType>;
|
|
117
|
-
declare const JSONBToken: {
|
|
118
|
-
type: string;
|
|
119
|
-
from: <ValueType extends Record<string, unknown> = Record<string, unknown>>() => JSONBToken<ValueType>;
|
|
120
|
-
check: <ValueType extends Record<string, unknown> = Record<string, unknown>>(token: unknown) => token is JSONBToken<ValueType>;
|
|
121
|
-
};
|
|
122
|
-
type TimestampToken = ColumnTypeToken<'value_type:js:date', 'TIMESTAMP'>;
|
|
123
|
-
declare const TimestampToken: {
|
|
124
|
-
from: (input: void) => TimestampToken;
|
|
125
|
-
check: (token: unknown) => token is TimestampToken;
|
|
126
|
-
type: "SQL_COLUMN_TIMESTAMP";
|
|
127
|
-
};
|
|
128
|
-
type TimestamptzToken = ColumnTypeToken<'value_type:js:date', 'TIMESTAMPTZ'>;
|
|
129
|
-
declare const TimestamptzToken: {
|
|
130
|
-
from: (input: void) => TimestamptzToken;
|
|
131
|
-
check: (token: unknown) => token is TimestamptzToken;
|
|
132
|
-
type: "SQL_COLUMN_TIMESTAMPTZ";
|
|
133
|
-
};
|
|
134
|
-
type VarcharToken = ColumnTypeToken<'value_type:js:string', 'VARCHAR', {
|
|
135
|
-
length: number | 'max';
|
|
136
|
-
}>;
|
|
137
|
-
declare const VarcharToken: {
|
|
138
|
-
from: (input: number | "max") => VarcharToken;
|
|
139
|
-
check: (token: unknown) => token is VarcharToken;
|
|
140
|
-
type: "SQL_COLUMN_VARCHAR";
|
|
141
|
-
};
|
|
142
|
-
type NotNullableSQLColumnTokenProps<ColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string> = {
|
|
143
|
-
name: string;
|
|
144
|
-
type: ColumnType;
|
|
145
|
-
notNull: true;
|
|
146
|
-
unique?: boolean;
|
|
147
|
-
primaryKey?: boolean;
|
|
148
|
-
default?: ColumnType | SQLToken;
|
|
149
|
-
} | {
|
|
150
|
-
name: string;
|
|
151
|
-
type: ColumnType;
|
|
152
|
-
notNull?: false;
|
|
153
|
-
unique?: boolean;
|
|
154
|
-
primaryKey: never;
|
|
155
|
-
default?: ColumnType | SQLToken;
|
|
156
|
-
};
|
|
157
|
-
type NullableSQLColumnTokenProps<ColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string> = {
|
|
158
|
-
name: string;
|
|
159
|
-
type: ColumnType;
|
|
160
|
-
notNull?: false;
|
|
161
|
-
unique?: boolean;
|
|
162
|
-
primaryKey?: false;
|
|
163
|
-
default?: ColumnType | SQLToken;
|
|
164
|
-
};
|
|
165
|
-
type AutoIncrementSQLColumnToken = ColumnTypeToken<'value_type:js:bigint', 'AUTO_INCREMENT', {
|
|
166
|
-
primaryKey: boolean;
|
|
167
|
-
bigint?: boolean;
|
|
168
|
-
}, bigint>;
|
|
169
|
-
declare const AutoIncrementSQLColumnToken: {
|
|
170
|
-
from: (input: Omit<AutoIncrementSQLColumnToken, "sqlTokenType" | "__brand" | "jsTypeName">) => AutoIncrementSQLColumnToken;
|
|
171
|
-
check: (token: unknown) => token is AutoIncrementSQLColumnToken;
|
|
172
|
-
type: "SQL_COLUMN_AUTO_INCREMENT";
|
|
173
|
-
};
|
|
174
|
-
declare const SQLColumnTypeTokens: {
|
|
175
|
-
AutoIncrement: {
|
|
176
|
-
from: (input: Omit<AutoIncrementSQLColumnToken, "sqlTokenType" | "__brand" | "jsTypeName">) => AutoIncrementSQLColumnToken;
|
|
177
|
-
check: (token: unknown) => token is AutoIncrementSQLColumnToken;
|
|
178
|
-
type: "SQL_COLUMN_AUTO_INCREMENT";
|
|
179
|
-
};
|
|
180
|
-
BigInteger: {
|
|
181
|
-
from: (input: void) => BigIntegerToken;
|
|
182
|
-
check: (token: unknown) => token is BigIntegerToken;
|
|
183
|
-
type: "SQL_COLUMN_BIGINT";
|
|
184
|
-
};
|
|
185
|
-
BigSerial: {
|
|
186
|
-
from: (input: void) => BigSerialToken;
|
|
187
|
-
check: (token: unknown) => token is BigSerialToken;
|
|
188
|
-
type: "SQL_COLUMN_BIGSERIAL";
|
|
189
|
-
};
|
|
190
|
-
Integer: {
|
|
191
|
-
from: (input: void) => IntegerToken;
|
|
192
|
-
check: (token: unknown) => token is IntegerToken;
|
|
193
|
-
type: "SQL_COLUMN_INTEGER";
|
|
194
|
-
};
|
|
195
|
-
JSONB: {
|
|
196
|
-
type: string;
|
|
197
|
-
from: <ValueType extends Record<string, unknown> = Record<string, unknown>>() => JSONBToken<ValueType>;
|
|
198
|
-
check: <ValueType extends Record<string, unknown> = Record<string, unknown>>(token: unknown) => token is JSONBToken<ValueType>;
|
|
199
|
-
};
|
|
200
|
-
Serial: {
|
|
201
|
-
from: (input: void) => SerialToken;
|
|
202
|
-
check: (token: unknown) => token is SerialToken;
|
|
203
|
-
type: "SQL_COLUMN_SERIAL";
|
|
204
|
-
};
|
|
205
|
-
Timestamp: {
|
|
206
|
-
from: (input: void) => TimestampToken;
|
|
207
|
-
check: (token: unknown) => token is TimestampToken;
|
|
208
|
-
type: "SQL_COLUMN_TIMESTAMP";
|
|
209
|
-
};
|
|
210
|
-
Timestamptz: {
|
|
211
|
-
from: (input: void) => TimestamptzToken;
|
|
212
|
-
check: (token: unknown) => token is TimestamptzToken;
|
|
213
|
-
type: "SQL_COLUMN_TIMESTAMPTZ";
|
|
214
|
-
};
|
|
215
|
-
Varchar: {
|
|
216
|
-
from: (input: number | "max") => VarcharToken;
|
|
217
|
-
check: (token: unknown) => token is VarcharToken;
|
|
218
|
-
type: "SQL_COLUMN_VARCHAR";
|
|
219
|
-
};
|
|
220
|
-
};
|
|
221
|
-
type SQLColumnTypeTokens = {
|
|
222
|
-
AutoIncrement: AutoIncrementSQLColumnToken;
|
|
223
|
-
BigInteger: BigIntegerToken;
|
|
224
|
-
BigSerial: BigSerialToken;
|
|
225
|
-
Integer: IntegerToken;
|
|
226
|
-
JSONB: JSONBToken;
|
|
227
|
-
Serial: SerialToken;
|
|
228
|
-
Timestamp: TimestampToken;
|
|
229
|
-
Timestamptz: TimestamptzToken;
|
|
230
|
-
Varchar: VarcharToken;
|
|
231
|
-
};
|
|
232
|
-
declare const SQLColumnTypeTokensFactory: {
|
|
233
|
-
AutoIncrement: (input: Omit<AutoIncrementSQLColumnToken, "sqlTokenType" | "__brand" | "jsTypeName">) => AutoIncrementSQLColumnToken;
|
|
234
|
-
BigInteger: BigIntegerToken;
|
|
235
|
-
BigSerial: BigSerialToken;
|
|
236
|
-
Integer: IntegerToken;
|
|
237
|
-
JSONB: <ValueType extends Record<string, unknown> = Record<string, unknown>>() => JSONBToken<ValueType>;
|
|
238
|
-
Serial: SerialToken;
|
|
239
|
-
Timestamp: TimestampToken;
|
|
240
|
-
Timestamptz: TimestamptzToken;
|
|
241
|
-
Varchar: (input: number | "max") => VarcharToken;
|
|
242
|
-
};
|
|
243
|
-
type DefaultSQLColumnToken = AutoIncrementSQLColumnToken | SerialToken | BigSerialToken | IntegerToken | JSONBToken | BigIntegerToken | TimestampToken | TimestamptzToken | VarcharToken;
|
|
244
|
-
type SQLColumnToken<ColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string> = SQLToken<'SQL_COLUMN', NotNullableSQLColumnTokenProps<ColumnType> | NullableSQLColumnTokenProps<ColumnType>>;
|
|
245
|
-
declare const SQLColumnToken: {
|
|
246
|
-
from: (input: Omit<SQLColumnToken<string | AnyColumnTypeToken>, "sqlTokenType">) => SQLColumnToken<string | AnyColumnTypeToken>;
|
|
247
|
-
check: (token: unknown) => token is SQLColumnToken<string | AnyColumnTypeToken>;
|
|
248
|
-
type: "SQL_COLUMN";
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
type MapSQLParamValue = (value: unknown, options?: MapSQLParamValueOptions) => unknown;
|
|
252
|
-
interface MapSQLParamValueOptions {
|
|
253
|
-
mapBoolean?: (value: boolean) => unknown;
|
|
254
|
-
mapArray?: (array: unknown[], mapValue: MapSQLParamValue) => unknown[];
|
|
255
|
-
mapDate?: (value: Date) => unknown;
|
|
256
|
-
mapObject?: (value: object) => unknown;
|
|
257
|
-
mapBigInt?: (value: bigint) => unknown;
|
|
258
|
-
mapValue?: MapSQLParamValue;
|
|
259
|
-
mapPlaceholder?: (index: number, value: unknown) => string;
|
|
260
|
-
mapIdentifier?: (value: string) => string;
|
|
261
|
-
}
|
|
262
|
-
declare const ANSISQLParamPlaceholder = "?";
|
|
263
|
-
declare const ANSISQLIdentifierQuote = "\"";
|
|
264
|
-
declare const mapANSISQLParamPlaceholder: () => string;
|
|
265
|
-
declare const mapSQLIdentifier: (value: string, options?: {
|
|
266
|
-
reservedWords: {
|
|
267
|
-
[key: string]: boolean;
|
|
268
|
-
};
|
|
269
|
-
quote?: string;
|
|
270
|
-
}) => string;
|
|
271
|
-
declare const DefaultMapSQLParamValueOptions: {
|
|
272
|
-
mapPlaceholder: () => string;
|
|
273
|
-
mapIdentifier: (value: string, options?: {
|
|
274
|
-
reservedWords: {
|
|
275
|
-
[key: string]: boolean;
|
|
276
|
-
};
|
|
277
|
-
quote?: string;
|
|
278
|
-
}) => string;
|
|
279
|
-
};
|
|
280
|
-
interface SQLValueMapper {
|
|
281
|
-
mapValue: MapSQLParamValue;
|
|
282
|
-
mapPlaceholder: (index: number, value: unknown) => string;
|
|
283
|
-
mapIdentifier: (value: string) => string;
|
|
284
|
-
}
|
|
285
|
-
declare const SQLValueMapper: (options?: MapSQLParamValueOptions) => SQLValueMapper;
|
|
286
|
-
declare function mapSQLParamValue(value: unknown, options?: MapSQLParamValueOptions): unknown;
|
|
287
|
-
|
|
288
|
-
type SQLProcessorContext = {
|
|
289
|
-
mapper: SQLValueMapper;
|
|
290
|
-
builder: ParametrizedSQLBuilder;
|
|
291
|
-
processorsRegistry: SQLProcessorsReadonlyRegistry;
|
|
292
|
-
};
|
|
293
|
-
type AnySQLProcessor = SQLProcessor<any>;
|
|
294
|
-
type SQLProcessorOptions<Token extends AnySQLToken = AnySQLToken> = {
|
|
295
|
-
canHandle: Token['sqlTokenType'];
|
|
296
|
-
handle: (value: Token, context: SQLProcessorContext) => void;
|
|
297
|
-
};
|
|
298
|
-
type SQLProcessor<Token extends AnySQLToken = AnySQLToken> = {
|
|
299
|
-
canHandle: Token['sqlTokenType'];
|
|
300
|
-
handle: (value: Token, context: SQLProcessorContext) => void;
|
|
301
|
-
};
|
|
302
|
-
declare const SQLProcessor: <Token extends AnySQLToken = AnySQLToken>(options: SQLProcessorOptions<Token>) => SQLProcessor<Token>;
|
|
303
|
-
|
|
304
|
-
interface SQLProcessorsReadonlyRegistry {
|
|
305
|
-
get<Token extends AnySQLToken = AnySQLToken>(tokenType: Token['sqlTokenType']): SQLProcessor<Token> | null;
|
|
306
|
-
all(): ReadonlyMap<string, AnySQLProcessor>;
|
|
307
|
-
}
|
|
308
|
-
interface SQLProcessorsRegistry extends SQLProcessorsReadonlyRegistry {
|
|
309
|
-
register(...processor: AnySQLProcessor[]): SQLProcessorsRegistry;
|
|
310
|
-
register(processor: Record<string, AnySQLProcessor>): SQLProcessorsRegistry;
|
|
311
|
-
}
|
|
312
|
-
declare const SQLProcessorsRegistry: (options?: {
|
|
313
|
-
from: SQLProcessorsRegistry;
|
|
314
|
-
}) => SQLProcessorsRegistry;
|
|
315
|
-
|
|
316
|
-
declare global {
|
|
317
|
-
var defaultProcessorsRegistry: ReturnType<typeof SQLProcessorsRegistry>;
|
|
318
|
-
}
|
|
319
|
-
declare const defaultProcessorsRegistry: SQLProcessorsRegistry;
|
|
320
|
-
|
|
321
|
-
type SQL = string & {
|
|
322
|
-
__brand: 'sql';
|
|
323
|
-
};
|
|
324
|
-
declare function SQL(strings: TemplateStringsArray, ...values: unknown[]): SQL;
|
|
325
|
-
declare namespace SQL {
|
|
326
|
-
export var EMPTY: SQL;
|
|
327
|
-
export var concat: (...sqls: SQL[]) => SQL;
|
|
328
|
-
export var merge: (sqls: SQL[], separator?: string) => SQL;
|
|
329
|
-
export var format: (sql: SQL | SQL[], formatter: SQLFormatter, options?: FormatSQLOptions) => ParametrizedSQL;
|
|
330
|
-
export var describe: (sql: SQL | SQL[], formatter: SQLFormatter, options?: FormatSQLOptions) => string;
|
|
331
|
-
var _a: (column: string, values: unknown[]) => SQLIn;
|
|
332
|
-
export var identifier: (input: string) => SQLIdentifier;
|
|
333
|
-
export var plain: (input: string) => SQLPlain;
|
|
334
|
-
export var check: {
|
|
335
|
-
isSQL: (value: unknown) => value is SQL;
|
|
336
|
-
isTokenizedSQL: (value: unknown) => value is Readonly<{
|
|
337
|
-
__brand: "tokenized-sql";
|
|
338
|
-
sqlChunks: ReadonlyArray<string>;
|
|
339
|
-
sqlTokens: ReadonlyArray<AnySQLToken>;
|
|
340
|
-
}>;
|
|
341
|
-
isEmpty: (sql: SQL) => boolean;
|
|
342
|
-
isIdentifier: (token: unknown) => token is SQLIdentifier;
|
|
343
|
-
isPlain: (token: unknown) => token is SQLPlain;
|
|
344
|
-
isSQLIn: (token: unknown) => token is SQLIn;
|
|
345
|
-
};
|
|
346
|
-
export var column: ((input: Omit<SQLColumnToken<string | AnyColumnTypeToken>, "sqlTokenType">) => SQLColumnToken<string | AnyColumnTypeToken>) & {
|
|
347
|
-
type: typeof SQLColumnTypeTokensFactory;
|
|
348
|
-
};
|
|
349
|
-
export { _a as in };
|
|
350
|
-
}
|
|
351
|
-
declare const isSQL: (value: unknown) => value is SQL;
|
|
352
|
-
|
|
353
|
-
type FormatSQLOptions = {
|
|
354
|
-
mapper?: MapSQLParamValueOptions;
|
|
355
|
-
processorsRegistry?: SQLProcessorsReadonlyRegistry;
|
|
356
|
-
};
|
|
357
|
-
type SQLFormatterOptions = Partial<Omit<SQLFormatter, 'valueMapper'>> & {
|
|
358
|
-
valueMapper?: MapSQLParamValueOptions;
|
|
359
|
-
processorsRegistry?: SQLProcessorsReadonlyRegistry;
|
|
360
|
-
};
|
|
361
|
-
interface SQLFormatter {
|
|
362
|
-
format: (sql: SQL | SQL[], context?: SQLProcessorContext) => ParametrizedSQL;
|
|
363
|
-
describe: (sql: SQL | SQL[], context?: SQLProcessorContext) => string;
|
|
364
|
-
valueMapper: SQLValueMapper;
|
|
365
|
-
}
|
|
366
|
-
declare const SQLFormatter: ({ format, describe, valueMapper: valueMapperOptions, processorsRegistry, }: SQLFormatterOptions) => SQLFormatter;
|
|
367
|
-
declare global {
|
|
368
|
-
var dumboSQLFormatters: Record<string, SQLFormatter>;
|
|
369
|
-
}
|
|
370
|
-
declare const registerFormatter: (dialect: string, formatter: SQLFormatter) => void;
|
|
371
|
-
declare const getFormatter: (dialect: string) => SQLFormatter;
|
|
372
|
-
declare function formatSQL(sql: SQL | SQL[], formatter: SQLFormatter, context?: FormatSQLOptions): ParametrizedSQL;
|
|
373
|
-
declare const describeSQL: (sql: SQL | SQL[], formatter: SQLFormatter, options?: FormatSQLOptions) => string;
|
|
374
|
-
|
|
375
|
-
type MigrationStyle = 'None' | 'CreateOrUpdate';
|
|
376
|
-
type SQLMigration = {
|
|
377
|
-
name: string;
|
|
378
|
-
sqls: SQL[];
|
|
379
|
-
};
|
|
380
|
-
declare const sqlMigration: (name: string, sqls: SQL[]) => SQLMigration;
|
|
381
|
-
type MigrationRecord = {
|
|
382
|
-
id: number;
|
|
383
|
-
name: string;
|
|
384
|
-
application: string;
|
|
385
|
-
sqlHash: string;
|
|
386
|
-
timestamp: Date;
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
type SchemaComponent<ComponentKey extends string = string, AdditionalData extends Exclude<Record<string, unknown>, 'schemaComponentKey' | 'components' | 'migrations' | 'addComponent' | 'addMigration'> | undefined = undefined> = {
|
|
390
|
-
schemaComponentKey: ComponentKey;
|
|
391
|
-
components: ReadonlyMap<string, SchemaComponent>;
|
|
392
|
-
migrations: ReadonlyArray<SQLMigration>;
|
|
393
|
-
addComponent: <SchemaComponentType extends SchemaComponent<string, Record<string, any>> = SchemaComponent<string, Record<string, any>>>(component: SchemaComponentType) => SchemaComponentType;
|
|
394
|
-
addMigration: (migration: SQLMigration) => void;
|
|
395
|
-
} & Exclude<AdditionalData extends undefined ? {} : AdditionalData, 'schemaComponentKey' | 'components' | 'migrations' | 'addComponent' | 'addMigration'>;
|
|
396
|
-
type ExtractAdditionalData<T> = T extends SchemaComponent<infer _ComponentType, infer Data> ? Data : never;
|
|
397
|
-
type AnySchemaComponent = SchemaComponent<string, Record<string, any>>;
|
|
398
|
-
type AnySchemaComponentOfType<ComponentType extends string = string> = SchemaComponent<ComponentType, any>;
|
|
399
|
-
type SchemaComponentOptions<AdditionalOptions extends Record<string, unknown> = Record<string, unknown>> = {
|
|
400
|
-
migrations?: ReadonlyArray<SQLMigration>;
|
|
401
|
-
components?: ReadonlyArray<SchemaComponent>;
|
|
402
|
-
} & Omit<AdditionalOptions, 'migrations' | 'components'>;
|
|
403
|
-
type SchemaComponentType<Kind extends string = string> = `sc:${Kind}`;
|
|
404
|
-
type DumboSchemaComponentType<Kind extends string = string> = SchemaComponentType<`dumbo:${Kind}`>;
|
|
405
|
-
declare const schemaComponent: <const ComponentKey extends string = string>(key: ComponentKey, options: SchemaComponentOptions) => SchemaComponent<ComponentKey>;
|
|
406
|
-
declare const isSchemaComponentOfType: <SchemaComponentOfType extends AnySchemaComponent = AnySchemaComponent>(component: AnySchemaComponent, prefix: string) => component is SchemaComponentOfType;
|
|
407
|
-
declare const filterSchemaComponentsOfType: <T extends AnySchemaComponent>(components: ReadonlyMap<string, AnySchemaComponent>, prefix: string) => ReadonlyMap<string, T>;
|
|
408
|
-
declare const mapSchemaComponentsOfType: <T extends AnySchemaComponent>(components: ReadonlyMap<string, AnySchemaComponent>, prefix: string, keyMapper?: (component: T) => string) => ReadonlyMap<string, T>;
|
|
409
|
-
declare const findSchemaComponentsOfType: <T extends AnySchemaComponent>(root: AnySchemaComponent, prefix: string) => T[];
|
|
410
|
-
|
|
411
|
-
type ColumnURNType = 'sc:dumbo:column';
|
|
412
|
-
declare const ColumnURNType: ColumnURNType;
|
|
413
|
-
type ColumnURN<ColumnName extends string = string> = `${ColumnURNType}:${ColumnName}`;
|
|
414
|
-
declare const ColumnURN: <ColumnName extends string = string>({ name, }: {
|
|
415
|
-
name: ColumnName;
|
|
416
|
-
}) => ColumnURN<ColumnName>;
|
|
417
|
-
type ColumnSchemaComponent<ColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string, ColumnName extends string = string> = SchemaComponent<ColumnURN<ColumnName>, Readonly<{
|
|
418
|
-
columnName: ColumnName;
|
|
419
|
-
}>> & SQLColumnToken<ColumnType>;
|
|
420
|
-
type AnyColumnSchemaComponent = ColumnSchemaComponent<any>;
|
|
421
|
-
type ColumnSchemaComponentOptions<ColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string> = Omit<SQLColumnToken<ColumnType>, 'name' | 'sqlTokenType'> & SchemaComponentOptions;
|
|
422
|
-
declare const columnSchemaComponent: <const ColumnType extends AnyColumnTypeToken | string = AnyColumnTypeToken | string, const TOptions extends ColumnSchemaComponentOptions<ColumnType> = ColumnSchemaComponentOptions<ColumnType>, const ColumnName extends string = string>(params: {
|
|
423
|
-
columnName: ColumnName;
|
|
424
|
-
} & TOptions) => ColumnSchemaComponent<ColumnType, ColumnName> & (TOptions extends {
|
|
425
|
-
notNull: true;
|
|
426
|
-
} | {
|
|
427
|
-
primaryKey: true;
|
|
428
|
-
} ? {
|
|
429
|
-
notNull: true;
|
|
430
|
-
} : {
|
|
431
|
-
notNull?: false;
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
type IndexSchemaComponent = SchemaComponent<IndexURN, Readonly<{
|
|
435
|
-
indexName: string;
|
|
436
|
-
columnNames: ReadonlyArray<string>;
|
|
437
|
-
isUnique: boolean;
|
|
438
|
-
addColumn: (column: string | ColumnSchemaComponent) => void;
|
|
439
|
-
}>>;
|
|
440
|
-
type IndexURNType = 'sc:dumbo:index';
|
|
441
|
-
declare const IndexURNType: IndexURNType;
|
|
442
|
-
type IndexURN = `${IndexURNType}:${string}`;
|
|
443
|
-
declare const IndexURN: ({ name }: {
|
|
444
|
-
name: string;
|
|
445
|
-
}) => IndexURN;
|
|
446
|
-
declare const indexSchemaComponent: ({ indexName, columnNames, isUnique, ...migrationsOrComponents }: {
|
|
447
|
-
indexName: string;
|
|
448
|
-
columnNames: string[];
|
|
449
|
-
isUnique: boolean;
|
|
450
|
-
} & SchemaComponentOptions) => IndexSchemaComponent;
|
|
451
|
-
|
|
452
|
-
type IF<Condition extends boolean, Then, Else> = Condition extends true ? Then : Else;
|
|
453
|
-
type AND<A extends boolean, B extends boolean> = A extends true ? B extends true ? true : false : false;
|
|
454
|
-
type ALL<A extends boolean[]> = A extends [infer First, ...infer Rest] ? First extends true ? Rest extends boolean[] ? ALL<Rest> : true : false : true;
|
|
455
|
-
|
|
456
|
-
type KeysOfString<T extends Record<string, unknown>> = Extract<keyof T, string>;
|
|
457
|
-
|
|
458
|
-
type TypeValidationResult<Valid extends boolean = boolean, Error = never> = Valid extends true ? {
|
|
459
|
-
valid: true;
|
|
460
|
-
} : {
|
|
461
|
-
valid: false;
|
|
462
|
-
error: Error;
|
|
463
|
-
};
|
|
464
|
-
type TypeValidationError<Error> = TypeValidationResult<false, Error>;
|
|
465
|
-
type TypeValidationSuccess = TypeValidationResult<true>;
|
|
466
|
-
type AnyTypeValidationError = TypeValidationError<any>;
|
|
467
|
-
type AnyTypeValidationResult = TypeValidationResult<boolean, any>;
|
|
468
|
-
type AnyTypeValidationFailed<Results = AnyTypeValidationResult[]> = Results extends readonly [infer First, ...infer Rest] ? First extends {
|
|
469
|
-
valid: false;
|
|
470
|
-
} ? true : Rest extends AnyTypeValidationResult[] ? AnyTypeValidationFailed<Rest> : false : false;
|
|
471
|
-
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> : [] : [];
|
|
472
|
-
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;
|
|
473
|
-
|
|
474
|
-
type GetTupleLength<T extends readonly unknown[]> = T['length'];
|
|
475
|
-
type NotEmptyTuple<T extends readonly unknown[]> = GetTupleLength<T> extends 0 ? never : T;
|
|
476
|
-
type HaveTuplesTheSameLength<T extends readonly unknown[], U extends readonly unknown[]> = GetTupleLength<T> extends GetTupleLength<U> ? true : false;
|
|
477
|
-
type IsEmptyTuple<T extends readonly unknown[]> = T extends [] ? true : false;
|
|
478
|
-
type IsNotEmptyTuple<T extends readonly unknown[]> = IsEmptyTuple<T> extends true ? false : true;
|
|
479
|
-
type FilterNotExistingInUnion<Tuple extends readonly string[], Union extends string> = Tuple extends readonly [infer First, ...infer Rest] ? First extends Union ? [
|
|
480
|
-
...FilterNotExistingInUnion<Rest extends readonly string[] ? Rest : [], Union>
|
|
481
|
-
] : [
|
|
482
|
-
First,
|
|
483
|
-
...FilterNotExistingInUnion<Rest extends readonly string[] ? Rest : [], Union>
|
|
484
|
-
] : [];
|
|
485
|
-
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
486
|
-
type LastOfUnion<T> = UnionToIntersection<T extends any ? () => T : never> extends () => infer R ? R : never;
|
|
487
|
-
type UnionToTuple<T, L = LastOfUnion<T>> = [T] extends [never] ? [] : [...UnionToTuple<Exclude<T, L>>, L];
|
|
488
|
-
type ZipTuplesCollectErrors<TupleA extends readonly unknown[], TupleB extends readonly unknown[], ValidateMap, Accumulated extends AnyTypeValidationError[] = []> = [TupleA, TupleB] extends [
|
|
489
|
-
readonly [infer FirstA, ...infer RestA],
|
|
490
|
-
readonly [infer FirstB, ...infer RestB]
|
|
491
|
-
] ? FirstA extends keyof ValidateMap ? FirstB extends keyof ValidateMap[FirstA] ? ValidateMap[FirstA][FirstB] extends infer Result extends AnyTypeValidationError ? ZipTuplesCollectErrors<RestA, RestB, ValidateMap, [
|
|
492
|
-
...Accumulated,
|
|
493
|
-
Result
|
|
494
|
-
]> : ZipTuplesCollectErrors<RestA, RestB, ValidateMap, Accumulated> : ZipTuplesCollectErrors<RestA, RestB, ValidateMap, Accumulated> : ZipTuplesCollectErrors<RestA, RestB, ValidateMap, Accumulated> : Accumulated;
|
|
495
|
-
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, [
|
|
496
|
-
...Accumulated,
|
|
497
|
-
Result
|
|
498
|
-
], Rest> : MapRecordCollectErrors<Record, ValidateMap, Accumulated, Rest> : MapRecordCollectErrors<Record, ValidateMap, Accumulated, Rest> : Accumulated;
|
|
499
|
-
|
|
500
|
-
type ExtractSchemaNames<DB> = DB extends DatabaseSchemaComponent<infer Schemas extends DatabaseSchemas> ? keyof Schemas : never;
|
|
501
|
-
type ExtractTableNames<Schema extends AnyDatabaseSchemaSchemaComponent> = Schema extends DatabaseSchemaSchemaComponent<infer Tables extends DatabaseSchemaTables> ? keyof Tables : never;
|
|
502
|
-
type ExtractColumnNames<Table extends AnyTableSchemaComponent> = Table extends TableSchemaComponent<infer Columns extends TableColumns> ? TableColumnNames<TableSchemaComponent<Columns>> : never;
|
|
503
|
-
type ExtractColumnTypeName<T> = T extends ColumnTypeToken<any, infer TypeName, any, any> ? Uppercase<TypeName> : never;
|
|
504
|
-
type AllColumnTypes<Schemas extends DatabaseSchemas> = {
|
|
505
|
-
[SchemaName in keyof Schemas]: Schemas[SchemaName] extends DatabaseSchemaSchemaComponent<infer Tables> ? Writable<{
|
|
506
|
-
[TableName in keyof Tables]: Tables[TableName] extends TableSchemaComponent<infer Columns> ? Writable<{
|
|
507
|
-
[ColumnName in keyof Columns]: {
|
|
508
|
-
columnTypeName: ExtractColumnTypeName<Columns[ColumnName]['type']>;
|
|
509
|
-
};
|
|
510
|
-
}> : never;
|
|
511
|
-
}> : never;
|
|
512
|
-
};
|
|
513
|
-
type AllColumnReferences<Schemas extends DatabaseSchemas> = {
|
|
514
|
-
[SchemaName in keyof Schemas]: Schemas[SchemaName] extends DatabaseSchemaSchemaComponent<infer Tables> ? {
|
|
515
|
-
[TableName in keyof Tables]: Tables[TableName] extends TableSchemaComponent<infer Columns> ? {
|
|
516
|
-
[ColumnName in keyof Columns]: `${SchemaName & string}.${TableName & string}.${ColumnName & string}`;
|
|
517
|
-
}[keyof Columns] : never;
|
|
518
|
-
}[keyof Tables] : never;
|
|
519
|
-
}[keyof Schemas];
|
|
520
|
-
type AllColumnTypesInSchema<Schema extends AnyDatabaseSchemaSchemaComponent> = Schema extends DatabaseSchemaSchemaComponent<infer Tables> ? {
|
|
521
|
-
[TableName in keyof Tables]: Tables[TableName] extends TableSchemaComponent<infer Columns> ? {
|
|
522
|
-
[ColumnName in keyof Columns]: {
|
|
523
|
-
columnTypeName: ExtractColumnTypeName<Columns[ColumnName]['type']>;
|
|
524
|
-
};
|
|
525
|
-
} : never;
|
|
526
|
-
} : never;
|
|
527
|
-
type AllColumnReferencesInSchema<Schema extends AnyDatabaseSchemaSchemaComponent, SchemaName extends string> = Schema extends DatabaseSchemaSchemaComponent<infer Tables> ? {
|
|
528
|
-
[TableName in keyof Tables]: Tables[TableName] extends TableSchemaComponent<infer Columns> ? {
|
|
529
|
-
[ColumnName in keyof Columns]: `${SchemaName & string}.${TableName & string}.${ColumnName & string}`;
|
|
530
|
-
}[keyof Columns] : never;
|
|
531
|
-
}[keyof Tables] : never;
|
|
532
|
-
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;
|
|
533
|
-
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 [
|
|
534
|
-
NormalizeReference<First, SchemaName, TableName>,
|
|
535
|
-
...NormalizeColumnPath<Rest, SchemaName, TableName>
|
|
536
|
-
] : readonly [] : readonly [] : readonly [];
|
|
537
|
-
type ColumnName<ColName extends string = string> = `${ColName}`;
|
|
538
|
-
type TableColumnName<TableName extends string = string, ColName extends string = string> = `${TableName}.${ColName}`;
|
|
539
|
-
type SchemaColumnName<SchemaName extends string = string, TableName extends string = string, ColumnName extends string = string> = `${SchemaName}.${TableName}.${ColumnName}`;
|
|
540
|
-
type ColumnPath<SchemaName extends string = string, TableName extends string = string, ColName extends string = string> = SchemaColumnName<SchemaName, TableName, ColName> | TableColumnName<TableName, ColName> | ColumnName<ColName>;
|
|
541
|
-
type ColumnReference<SchemaName extends string = string, TableName extends string = string, ColumnName extends string = string> = {
|
|
542
|
-
schemaName: SchemaName;
|
|
543
|
-
tableName: TableName;
|
|
544
|
-
columnName: ColumnName;
|
|
545
|
-
};
|
|
546
|
-
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}` ? {
|
|
547
|
-
schemaName: S;
|
|
548
|
-
tableName: T;
|
|
549
|
-
columnName: C;
|
|
550
|
-
} : never;
|
|
551
|
-
type ParseReferencePath<Path extends string> = Path extends `${infer Schema}.${infer Table}.${infer Column}` ? {
|
|
552
|
-
schema: Schema;
|
|
553
|
-
table: Table;
|
|
554
|
-
column: Column;
|
|
555
|
-
} : never;
|
|
556
|
-
type LookupColumnType<AllTypes, Path extends string> = ParseReferencePath<Path> extends {
|
|
557
|
-
schema: infer S;
|
|
558
|
-
table: infer T;
|
|
559
|
-
column: infer C;
|
|
560
|
-
} ? S extends keyof AllTypes ? T extends keyof AllTypes[S] ? C extends keyof AllTypes[S][T] ? AllTypes[S][T][C] extends {
|
|
561
|
-
columnTypeName: infer TypeName;
|
|
562
|
-
} ? TypeName : never : never : never : never : never;
|
|
563
|
-
type RelationshipType = 'one-to-one' | 'one-to-many' | 'many-to-one' | 'many-to-many';
|
|
564
|
-
type RelationshipDefinition<Columns extends string = string, Reference extends string = string, RelType extends RelationshipType = RelationshipType> = {
|
|
565
|
-
readonly columns: NotEmptyTuple<readonly Columns[]>;
|
|
566
|
-
readonly references: NotEmptyTuple<readonly Reference[]>;
|
|
567
|
-
readonly type: RelType;
|
|
568
|
-
};
|
|
569
|
-
type AnyTableRelationshipDefinition = RelationshipDefinition<any, any, any>;
|
|
570
|
-
type AnyTableRelationshipDefinitionWithColumns<Columns extends string = string> = RelationshipDefinition<Columns, any, any>;
|
|
571
|
-
type TableRelationships<Columns extends string = string> = Record<string, AnyTableRelationshipDefinitionWithColumns<Columns>>;
|
|
572
|
-
declare const relationship: <const Columns extends readonly string[], const References extends readonly string[], const RelType extends RelationshipType = RelationshipType>(columns: Columns, references: References, type: RelType) => {
|
|
573
|
-
readonly columns: Columns;
|
|
574
|
-
readonly references: References;
|
|
575
|
-
readonly type: RelType;
|
|
576
|
-
};
|
|
577
|
-
type AnyRelationshipDefinition = RelationshipDefinition<any, any, any>;
|
|
578
|
-
|
|
579
|
-
type Writable<T> = {
|
|
580
|
-
-readonly [P in keyof T]: T[P];
|
|
581
|
-
};
|
|
582
|
-
type InferColumnType<ColumnType> = ColumnType extends ColumnTypeToken<infer _JSType, infer _ColumnTypeName, infer _TProps, infer ValueType> ? ValueType : ColumnType;
|
|
583
|
-
type TableColumnType<T extends AnyColumnSchemaComponent> = T extends ColumnSchemaComponent<infer ColumnType> ? T extends {
|
|
584
|
-
notNull: true;
|
|
585
|
-
} | {
|
|
586
|
-
primaryKey: true;
|
|
587
|
-
} ? InferColumnType<ColumnType> : InferColumnType<ColumnType> | null : unknown;
|
|
588
|
-
type TableColumnNames<T extends AnyTableSchemaComponent> = Exclude<keyof T['columns'], keyof ReadonlyMap<string, AnyColumnSchemaComponent>>;
|
|
589
|
-
type InferTableRow<Columns extends TableColumns> = Writable<{
|
|
590
|
-
[K in keyof Columns]: TableColumnType<Columns[K]>;
|
|
591
|
-
}>;
|
|
592
|
-
type TableRowType<T extends AnyTableSchemaComponent> = T extends TableSchemaComponent<infer Columns> ? InferTableRow<Columns> : never;
|
|
593
|
-
type InferSchemaTables<T extends AnyDatabaseSchemaSchemaComponent> = T extends DatabaseSchemaSchemaComponent<infer Tables> ? Tables : never;
|
|
594
|
-
type InferDatabaseSchemas<T extends AnyDatabaseSchemaComponent> = T extends DatabaseSchemaComponent<infer Schemas> ? Schemas : never;
|
|
595
|
-
|
|
596
|
-
type TableURNType = 'sc:dumbo:table';
|
|
597
|
-
declare const TableURNType: TableURNType;
|
|
598
|
-
type TableURN = `${TableURNType}:${string}`;
|
|
599
|
-
declare const TableURN: ({ name }: {
|
|
600
|
-
name: string;
|
|
601
|
-
}) => TableURN;
|
|
602
|
-
type TableColumns = Record<string, AnyColumnSchemaComponent>;
|
|
603
|
-
type TableSchemaComponent<Columns extends TableColumns = TableColumns, TableName extends string = string, Relationships extends TableRelationships<keyof Columns & string> = {} & TableRelationships<keyof Columns & string>> = SchemaComponent<TableURN, Readonly<{
|
|
604
|
-
tableName: TableName;
|
|
605
|
-
columns: ReadonlyMap<string, AnyColumnSchemaComponent> & Columns;
|
|
606
|
-
primaryKey: TableColumnNames<TableSchemaComponent<Columns, TableName, Relationships>>[];
|
|
607
|
-
relationships: Relationships;
|
|
608
|
-
indexes: ReadonlyMap<string, IndexSchemaComponent>;
|
|
609
|
-
addColumn: (column: AnyColumnSchemaComponent) => AnyColumnSchemaComponent;
|
|
610
|
-
addIndex: (index: IndexSchemaComponent) => IndexSchemaComponent;
|
|
611
|
-
}>>;
|
|
612
|
-
type InferTableSchemaComponentTypes<T extends AnyTableSchemaComponent> = T extends TableSchemaComponent<infer Columns, infer TableName, infer Relationships> ? [Columns, TableName, Relationships] : never;
|
|
613
|
-
type InferTableSchemaComponentColumns<T extends AnyTableSchemaComponent> = InferTableSchemaComponentTypes<T>[0];
|
|
614
|
-
type AnyTableSchemaComponent = TableSchemaComponent<any, any, any>;
|
|
615
|
-
declare const tableSchemaComponent: <const Columns extends TableColumns = TableColumns, const TableName extends string = string, const Relationships extends TableRelationships<keyof Columns & string> = {}>({ tableName, columns, primaryKey, relationships, ...migrationsOrComponents }: {
|
|
616
|
-
tableName: TableName;
|
|
617
|
-
columns?: Columns;
|
|
618
|
-
primaryKey?: TableColumnNames<TableSchemaComponent<Columns, TableName, Relationships>>[];
|
|
619
|
-
relationships?: Relationships;
|
|
620
|
-
} & SchemaComponentOptions) => TableSchemaComponent<Columns, TableName, Relationships> & {
|
|
621
|
-
relationships: Relationships;
|
|
622
|
-
};
|
|
623
|
-
|
|
624
|
-
type DatabaseSchemaURNType = 'sc:dumbo:database_schema';
|
|
625
|
-
declare const DatabaseSchemaURNType: DatabaseSchemaURNType;
|
|
626
|
-
type DatabaseSchemaURN<SchemaName extends string = string> = `${DatabaseSchemaURNType}:${SchemaName}`;
|
|
627
|
-
declare const DatabaseSchemaURN: <SchemaName extends string = string>({ name, }: {
|
|
628
|
-
name: SchemaName;
|
|
629
|
-
}) => DatabaseSchemaURN<SchemaName>;
|
|
630
|
-
type DatabaseSchemaTables<Tables extends AnyTableSchemaComponent = AnyTableSchemaComponent> = Record<string, Tables>;
|
|
631
|
-
type DatabaseSchemaSchemaComponent<Tables extends DatabaseSchemaTables = DatabaseSchemaTables, SchemaName extends string = string> = SchemaComponent<DatabaseSchemaURN<SchemaName>, Readonly<{
|
|
632
|
-
schemaName: SchemaName;
|
|
633
|
-
tables: ReadonlyMap<string, TableSchemaComponent> & Tables;
|
|
634
|
-
addTable: (table: string | TableSchemaComponent) => TableSchemaComponent;
|
|
635
|
-
}>>;
|
|
636
|
-
type AnyDatabaseSchemaSchemaComponent = DatabaseSchemaSchemaComponent<any, any>;
|
|
637
|
-
declare const databaseSchemaSchemaComponent: <const Tables extends DatabaseSchemaTables = DatabaseSchemaTables, const SchemaName extends string = string>({ schemaName, tables, ...migrationsOrComponents }: {
|
|
638
|
-
schemaName: SchemaName;
|
|
639
|
-
tables?: Tables;
|
|
640
|
-
} & SchemaComponentOptions) => DatabaseSchemaSchemaComponent<Tables, SchemaName>;
|
|
641
|
-
|
|
642
|
-
type DatabaseURNType = 'sc:dumbo:database';
|
|
643
|
-
declare const DatabaseURNType: DatabaseURNType;
|
|
644
|
-
type DatabaseURN = `${DatabaseURNType}:${string}`;
|
|
645
|
-
declare const DatabaseURN: ({ name }: {
|
|
646
|
-
name: string;
|
|
647
|
-
}) => DatabaseURN;
|
|
648
|
-
type DatabaseSchemas<Schemas extends AnyDatabaseSchemaSchemaComponent = AnyDatabaseSchemaSchemaComponent> = Record<string, Schemas>;
|
|
649
|
-
type DatabaseSchemaComponent<Schemas extends DatabaseSchemas = DatabaseSchemas> = SchemaComponent<DatabaseURN, Readonly<{
|
|
650
|
-
databaseName: string;
|
|
651
|
-
schemas: ReadonlyMap<string, DatabaseSchemaSchemaComponent> & Schemas;
|
|
652
|
-
addSchema: (schema: string | DatabaseSchemaSchemaComponent) => DatabaseSchemaSchemaComponent;
|
|
653
|
-
}>>;
|
|
654
|
-
type AnyDatabaseSchemaComponent = DatabaseSchemaComponent<any>;
|
|
655
|
-
declare const databaseSchemaComponent: <Schemas extends DatabaseSchemas = DatabaseSchemas>({ databaseName, schemas, ...migrationsOrComponents }: {
|
|
656
|
-
databaseName: string;
|
|
657
|
-
schemas?: Schemas;
|
|
658
|
-
} & SchemaComponentOptions) => DatabaseSchemaComponent<Schemas>;
|
|
659
|
-
|
|
660
|
-
type Join<T extends readonly string[], Sep extends string> = T extends readonly [
|
|
661
|
-
infer First extends string,
|
|
662
|
-
...infer Rest extends readonly string[]
|
|
663
|
-
] ? Rest extends readonly [] ? First : `${First}${Sep}${Join<Rest, Sep>}` : '';
|
|
664
|
-
type IndentErrors<Messages extends readonly string[]> = Messages extends readonly [
|
|
665
|
-
infer First extends string,
|
|
666
|
-
...infer Rest extends readonly string[]
|
|
667
|
-
] ? [` - ${First}`, ...IndentErrors<Rest>] : [];
|
|
668
|
-
type ExtractSchemaFromReference<T extends string> = T extends `${infer Schema}.${string}.${string}` ? Schema : never;
|
|
669
|
-
type ExtractTableFromReference<T extends string> = T extends `${string}.${infer Table}.${string}` ? Table : never;
|
|
670
|
-
type ExtractColumnFromReference<T extends string> = T extends `${string}.${string}.${infer Column}` ? Column : never;
|
|
671
|
-
type TupleLength<T extends readonly unknown[]> = T extends {
|
|
672
|
-
length: infer L;
|
|
673
|
-
} ? L : never;
|
|
674
|
-
type FormatSingleError<E> = E extends {
|
|
675
|
-
errorCode: 'reference_columns_mismatch';
|
|
676
|
-
invalidColumns: infer InvalidCols extends readonly string[];
|
|
677
|
-
availableColumns: infer AvailableCols extends readonly string[];
|
|
678
|
-
} ? `Invalid columns: ${Join<InvalidCols, ', '>}. Available columns: ${Join<AvailableCols, ', '>}` : E extends {
|
|
679
|
-
errorCode: 'reference_length_mismatch';
|
|
680
|
-
columns: infer Cols extends readonly string[];
|
|
681
|
-
references: infer Refs extends readonly string[];
|
|
682
|
-
} ? `Column count mismatch: ${TupleLength<Cols>} columns ([${Join<Cols, ', '>}]) but ${TupleLength<Refs>} references ([${Join<Refs, ', '>}])` : E extends {
|
|
683
|
-
errorCode: 'missing_schema';
|
|
684
|
-
reference: infer Ref extends string;
|
|
685
|
-
} ? `Schema "${ExtractSchemaFromReference<Ref>}" does not exist (${Ref})` : E extends {
|
|
686
|
-
errorCode: 'missing_table';
|
|
687
|
-
reference: infer Ref extends string;
|
|
688
|
-
} ? `Table "${ExtractTableFromReference<Ref>}" does not exist in schema "${ExtractSchemaFromReference<Ref>}" (${Ref})` : E extends {
|
|
689
|
-
errorCode: 'missing_column';
|
|
690
|
-
reference: infer Ref extends string;
|
|
691
|
-
} ? `Column "${ExtractColumnFromReference<Ref>}" does not exist in table "${ExtractSchemaFromReference<Ref>}.${ExtractTableFromReference<Ref>}" (${Ref})` : E extends {
|
|
692
|
-
errorCode: 'type_mismatch';
|
|
693
|
-
reference: infer Ref extends string;
|
|
694
|
-
referenceType: infer RefType extends string;
|
|
695
|
-
columnTypeName: infer ColType extends string;
|
|
696
|
-
} ? `Type mismatch: column type "${ColType}" does not match referenced column type "${RefType}" (${Ref})` : never;
|
|
697
|
-
type FormatErrorMessages<Errors extends readonly unknown[]> = Errors extends readonly [
|
|
698
|
-
infer First,
|
|
699
|
-
...infer Rest extends readonly unknown[]
|
|
700
|
-
] ? [FormatSingleError<First>, ...FormatErrorMessages<Rest>] : [];
|
|
701
|
-
type FormatRelationshipBlock<E> = E extends {
|
|
702
|
-
relationship: infer RelName extends string;
|
|
703
|
-
errors: infer Errors extends readonly unknown[];
|
|
704
|
-
} ? Join<[
|
|
705
|
-
`Relationship "${RelName}":`,
|
|
706
|
-
...IndentErrors<FormatErrorMessages<Errors>>
|
|
707
|
-
], '\n'> : never;
|
|
708
|
-
type IndentLine<Line extends string> = ` ${Line}`;
|
|
709
|
-
type IndentRelationshipBlock<Block extends string> = Block extends `${infer FirstLine}\n${infer Rest}` ? `${IndentLine<FirstLine>}\n${IndentRelationshipBlock<Rest>}` : IndentLine<Block>;
|
|
710
|
-
type FormatRelationshipBlocks<RelErrors extends readonly unknown[]> = RelErrors extends readonly [
|
|
711
|
-
infer First,
|
|
712
|
-
...infer Rest extends readonly unknown[]
|
|
713
|
-
] ? Rest extends readonly [] ? IndentRelationshipBlock<FormatRelationshipBlock<First>> : `${IndentRelationshipBlock<FormatRelationshipBlock<First>>}\n${FormatRelationshipBlocks<Rest>}` : '';
|
|
714
|
-
type FormatTableLevel<E> = E extends {
|
|
715
|
-
table: infer TableName extends string;
|
|
716
|
-
errors: infer RelErrors extends readonly unknown[];
|
|
717
|
-
} ? `Table "${TableName}":\n${FormatRelationshipBlocks<RelErrors>}` : never;
|
|
718
|
-
type IndentTableBlock<Block extends string> = Block extends `${infer FirstLine}\n${infer Rest}` ? ` ${FirstLine}\n${IndentTableBlock<Rest>}` : ` ${Block}`;
|
|
719
|
-
type FormatTableBlocks<TableErrors extends readonly unknown[]> = TableErrors extends readonly [
|
|
720
|
-
infer First,
|
|
721
|
-
...infer Rest extends readonly unknown[]
|
|
722
|
-
] ? Rest extends readonly [] ? IndentTableBlock<FormatTableLevel<First>> : `${IndentTableBlock<FormatTableLevel<First>>}\n${FormatTableBlocks<Rest>}` : '';
|
|
723
|
-
type FormatSchemaLevel<E> = E extends {
|
|
724
|
-
schema: infer SchemaName extends string;
|
|
725
|
-
errors: infer TableErrors extends readonly unknown[];
|
|
726
|
-
} ? `Schema "${SchemaName}":\n${FormatTableBlocks<TableErrors>}` : never;
|
|
727
|
-
type FormatSchemaBlocks<SchemaErrors extends readonly unknown[]> = SchemaErrors extends readonly [
|
|
728
|
-
infer First,
|
|
729
|
-
...infer Rest extends readonly unknown[]
|
|
730
|
-
] ? Rest extends readonly [] ? FormatSchemaLevel<First> : `${FormatSchemaLevel<First>}\n${FormatSchemaBlocks<Rest>}` : '';
|
|
731
|
-
type FormatDatabaseValidationErrors<Errors extends readonly unknown[]> = FormatSchemaBlocks<Errors>;
|
|
732
|
-
type FormatValidationErrors<Result> = Result extends {
|
|
733
|
-
valid: false;
|
|
734
|
-
error: infer Errors extends readonly unknown[];
|
|
735
|
-
} ? `Relationship validation errors:\n\n${FormatDatabaseValidationErrors<Errors>}` : never;
|
|
736
|
-
|
|
737
|
-
type RelationshipColumnsMismatchError<ColumnPath extends SchemaColumnName = SchemaColumnName> = {
|
|
738
|
-
valid: false;
|
|
739
|
-
error: {
|
|
740
|
-
errorCode: 'reference_columns_mismatch';
|
|
741
|
-
invalidColumns: ColumnPath[];
|
|
742
|
-
availableColumns: ColumnPath[];
|
|
743
|
-
};
|
|
744
|
-
};
|
|
745
|
-
type RelationshipReferencesLengthMismatchError<ColumnPath extends SchemaColumnName = SchemaColumnName> = {
|
|
746
|
-
valid: false;
|
|
747
|
-
error: {
|
|
748
|
-
errorCode: 'reference_length_mismatch';
|
|
749
|
-
columns: ColumnPath[];
|
|
750
|
-
references: ColumnPath[];
|
|
751
|
-
};
|
|
752
|
-
};
|
|
753
|
-
type ColumnReferenceExistanceError<ErrorCode extends 'missing_schema' | 'missing_table' | 'missing_column' = 'missing_schema' | 'missing_table' | 'missing_column', ColumnPath extends SchemaColumnName = SchemaColumnName> = {
|
|
754
|
-
valid: false;
|
|
755
|
-
error: {
|
|
756
|
-
errorCode: ErrorCode;
|
|
757
|
-
reference: ColumnPath;
|
|
758
|
-
};
|
|
759
|
-
};
|
|
760
|
-
type ColumnReferenceTypeMismatchError<Reference extends SchemaColumnName = SchemaColumnName, ReferenceTypeName extends string = string, ColumnTypeName extends string = string> = {
|
|
761
|
-
valid: false;
|
|
762
|
-
error: {
|
|
763
|
-
errorCode: 'type_mismatch';
|
|
764
|
-
reference: Reference;
|
|
765
|
-
referenceType: ReferenceTypeName;
|
|
766
|
-
columnTypeName: ColumnTypeName;
|
|
767
|
-
};
|
|
768
|
-
};
|
|
769
|
-
type NoError = TypeValidationSuccess;
|
|
770
|
-
type ColumnReferenceError = ColumnReferenceExistanceError | ColumnReferenceTypeMismatchError;
|
|
771
|
-
type RelationshipValidationError = RelationshipColumnsMismatchError | RelationshipReferencesLengthMismatchError | ColumnReferenceError;
|
|
772
|
-
type ValidateRelationshipLength<Rel extends AnyTableRelationshipDefinition> = IF<ALL<[
|
|
773
|
-
HaveTuplesTheSameLength<Rel['columns'], Rel['references']>,
|
|
774
|
-
IsNotEmptyTuple<Rel['columns']>,
|
|
775
|
-
IsNotEmptyTuple<Rel['references']>
|
|
776
|
-
]>, TypeValidationSuccess, TypeValidationResult<false, {
|
|
777
|
-
errorCode: 'reference_length_mismatch';
|
|
778
|
-
columns: Rel['columns'];
|
|
779
|
-
references: Rel['references'];
|
|
780
|
-
}>>;
|
|
781
|
-
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, {
|
|
782
|
-
errorCode: 'reference_columns_mismatch';
|
|
783
|
-
invalidColumns: InvalidColumns;
|
|
784
|
-
availableColumns: KeysOfString<ValidColumns>;
|
|
785
|
-
}>> : TypeValidationSuccess;
|
|
786
|
-
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;
|
|
787
|
-
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>>;
|
|
788
|
-
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;
|
|
789
|
-
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 {
|
|
790
|
-
valid: false;
|
|
791
|
-
error: infer E;
|
|
792
|
-
} ? TypeValidationError<E> : never : never : never;
|
|
793
|
-
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 {
|
|
794
|
-
valid: false;
|
|
795
|
-
error: infer E;
|
|
796
|
-
} ? TypeValidationError<E> : never : never : never;
|
|
797
|
-
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, {
|
|
798
|
-
[R in References[number]]: {
|
|
799
|
-
[C in Columns[number]]: ValidateReference<R, C, Schemas>;
|
|
800
|
-
};
|
|
801
|
-
}, Errors>;
|
|
802
|
-
type SchemaTablesWithSingle<Table extends AnyTableSchemaComponent> = Table extends TableSchemaComponent<infer _Columns, infer TableName, infer _FKs> ? DatabaseSchemaSchemaComponent<{
|
|
803
|
-
[K in TableName]: Table;
|
|
804
|
-
}> : never;
|
|
805
|
-
type DatabaseSchemasWithSingle<Schema extends AnyDatabaseSchemaSchemaComponent> = Schema extends DatabaseSchemaSchemaComponent<infer _Tables, infer _SchemaName> ? {
|
|
806
|
-
[K in _SchemaName]: Schema;
|
|
807
|
-
} : never;
|
|
808
|
-
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<[
|
|
809
|
-
ValidateRelationshipLength<Relationship>,
|
|
810
|
-
ValidateRelationshipColumns<Relationship, Columns>,
|
|
811
|
-
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
|
|
812
|
-
]> extends infer Error extends AnyTypeValidationError ? TypeValidationError<{
|
|
813
|
-
relationship: RelationshipName;
|
|
814
|
-
errors: Error extends TypeValidationError<infer E> ? E extends readonly unknown[] ? E : [E] : never;
|
|
815
|
-
}> : TypeValidationSuccess;
|
|
816
|
-
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, {
|
|
817
|
-
[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>;
|
|
818
|
-
}, Errors>;
|
|
819
|
-
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<{
|
|
820
|
-
table: TableName;
|
|
821
|
-
errors: UnwrapTypeValidationErrors<Results extends readonly AnyTypeValidationError[] ? Results : never>;
|
|
822
|
-
}> : Results : TypeValidationSuccess : TypeValidationSuccess : TypeValidationSuccess;
|
|
823
|
-
type ValidateTable<Table extends AnyTableSchemaComponent, Schema extends AnyDatabaseSchemaSchemaComponent = SchemaTablesWithSingle<Table>, Schemas extends DatabaseSchemas = DatabaseSchemasWithSingle<Schema>> = ValidateTableRelationships<Table, Schema, Schemas>;
|
|
824
|
-
type ValidateSchemaTables<Tables extends Record<string, AnyTableSchemaComponent>, SchemaName extends string, Schema extends AnyDatabaseSchemaSchemaComponent, Schemas extends DatabaseSchemas = DatabaseSchemasWithSingle<Schema>> = MapRecordCollectErrors<Tables, {
|
|
825
|
-
[TableName in keyof Tables]: ValidateTable<Tables[TableName], Schema, Schemas>;
|
|
826
|
-
}> extends infer Results ? AnyTypeValidationFailed<Results> extends true ? TypeValidationError<{
|
|
827
|
-
schema: SchemaName;
|
|
828
|
-
errors: UnwrapTypeValidationErrors<Results extends readonly AnyTypeValidationError[] ? Results : never>;
|
|
829
|
-
}> : TypeValidationSuccess : TypeValidationSuccess;
|
|
830
|
-
type ValidateDatabaseSchema<Schema extends AnyDatabaseSchemaSchemaComponent, Schemas extends DatabaseSchemas = DatabaseSchemasWithSingle<Schema>> = Schema extends DatabaseSchemaSchemaComponent<infer Tables, infer SchemaName> ? ValidateSchemaTables<Tables, SchemaName, Schema, Schemas> : TypeValidationSuccess;
|
|
831
|
-
type ValidateDatabaseSchemas<Schemas extends DatabaseSchemas> = MapRecordCollectErrors<Schemas, {
|
|
832
|
-
[SchemaName in keyof Schemas]: ValidateDatabaseSchema<Schemas[SchemaName], Schemas>;
|
|
833
|
-
}> extends infer Results ? AnyTypeValidationFailed<Results> extends true ? TypeValidationError<UnwrapTypeValidationErrors<Results extends readonly AnyTypeValidationError[] ? Results : never>> : TypeValidationSuccess : TypeValidationSuccess;
|
|
834
|
-
type ValidateDatabaseSchemasWithMessages<Schemas extends DatabaseSchemas> = FormatValidationErrors<ValidateDatabaseSchemas<Schemas>>;
|
|
835
|
-
|
|
836
|
-
declare const DEFAULT_DATABASE_SCHEMA_NAME = "__default_database_schema__";
|
|
837
|
-
declare function dumboDatabaseSchema<const Tables extends DatabaseSchemaTables = DatabaseSchemaTables>(tables: Tables): DatabaseSchemaSchemaComponent<Tables, typeof DEFAULT_DATABASE_SCHEMA_NAME>;
|
|
838
|
-
declare function dumboDatabaseSchema<const Tables extends DatabaseSchemaTables = DatabaseSchemaTables, const SchemaName extends string = string>(schemaName: SchemaName, tables: Tables, options?: SchemaComponentOptions): DatabaseSchemaSchemaComponent<Tables, SchemaName>;
|
|
839
|
-
declare namespace dumboDatabaseSchema {
|
|
840
|
-
var from: (schemaName: string | undefined, tableNames: string[]) => DatabaseSchemaSchemaComponent;
|
|
841
|
-
var defaultName: string;
|
|
842
|
-
}
|
|
843
|
-
type ValidatedDatabaseSchemaComponent<Schemas extends DatabaseSchemas = DatabaseSchemas> = ValidateDatabaseSchemas<Schemas> extends {
|
|
844
|
-
valid: true;
|
|
845
|
-
} ? DatabaseSchemaComponent<Schemas> : ValidateDatabaseSchemas<Schemas> extends {
|
|
846
|
-
valid: false;
|
|
847
|
-
error: infer E;
|
|
848
|
-
} ? {
|
|
849
|
-
valid: false;
|
|
850
|
-
error: E;
|
|
851
|
-
} : DatabaseSchemaComponent<Schemas>;
|
|
852
|
-
declare function dumboDatabase<Schemas extends DatabaseSchemas = DatabaseSchemas>(schemas: Schemas): ValidatedDatabaseSchemaComponent<Schemas>;
|
|
853
|
-
declare function dumboDatabase<Schemas extends DatabaseSchemas = DatabaseSchemas>(schema: DatabaseSchemaSchemaComponent): ValidatedDatabaseSchemaComponent<Schemas>;
|
|
854
|
-
declare function dumboDatabase<Schemas extends DatabaseSchemas = DatabaseSchemas>(databaseName: string, schemas: Schemas, options?: SchemaComponentOptions): ValidatedDatabaseSchemaComponent<Schemas>;
|
|
855
|
-
declare function dumboDatabase<Schemas extends DatabaseSchemas = DatabaseSchemas>(databaseName: string, schema: AnyDatabaseSchemaSchemaComponent, options?: SchemaComponentOptions): ValidatedDatabaseSchemaComponent<Schemas>;
|
|
856
|
-
declare namespace dumboDatabase {
|
|
857
|
-
var from: <Schemas extends DatabaseSchemas = DatabaseSchemas>(databaseName: string | undefined, schemaNames: string[]) => ValidatedDatabaseSchemaComponent<Schemas>;
|
|
858
|
-
var defaultName: string;
|
|
859
|
-
}
|
|
860
|
-
declare const dumboSchema: {
|
|
861
|
-
database: typeof dumboDatabase;
|
|
862
|
-
schema: typeof dumboDatabaseSchema;
|
|
863
|
-
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: {
|
|
864
|
-
columns?: Columns;
|
|
865
|
-
primaryKey?: TableColumnNames<TableSchemaComponent<Columns, TableName, Relationships>>[];
|
|
866
|
-
relationships?: Relationships;
|
|
867
|
-
indexes?: Record<string, IndexSchemaComponent>;
|
|
868
|
-
} & SchemaComponentOptions) => TableSchemaComponent<Columns, TableName, Relationships>;
|
|
869
|
-
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) => ({
|
|
870
|
-
schemaComponentKey: `sc:dumbo:column:${ColumnName}`;
|
|
871
|
-
components: ReadonlyMap<string, SchemaComponent>;
|
|
872
|
-
migrations: ReadonlyArray<SQLMigration>;
|
|
873
|
-
addComponent: <SchemaComponentType extends SchemaComponent<string, Record<string, any>> = SchemaComponent<string, Record<string, any>>>(component: SchemaComponentType) => SchemaComponentType;
|
|
874
|
-
addMigration: (migration: SQLMigration) => void;
|
|
875
|
-
} & Readonly<{
|
|
876
|
-
columnName: ColumnName;
|
|
877
|
-
}> & {
|
|
878
|
-
sqlTokenType: "SQL_COLUMN";
|
|
879
|
-
} & Omit<{
|
|
880
|
-
name: string;
|
|
881
|
-
type: ColumnType;
|
|
882
|
-
notNull?: false;
|
|
883
|
-
unique?: boolean;
|
|
884
|
-
primaryKey: never;
|
|
885
|
-
default?: SQLToken | ColumnType;
|
|
886
|
-
}, "sqlTokenType"> & (TOptions & {
|
|
887
|
-
type: ColumnType;
|
|
888
|
-
} extends infer T ? T extends TOptions & {
|
|
889
|
-
type: ColumnType;
|
|
890
|
-
} ? T extends {
|
|
891
|
-
notNull: true;
|
|
892
|
-
} | {
|
|
893
|
-
primaryKey: true;
|
|
894
|
-
} ? {
|
|
895
|
-
notNull: true;
|
|
896
|
-
} : {
|
|
897
|
-
notNull?: false;
|
|
898
|
-
} : never : never)) | ({
|
|
899
|
-
schemaComponentKey: `sc:dumbo:column:${ColumnName}`;
|
|
900
|
-
components: ReadonlyMap<string, SchemaComponent>;
|
|
901
|
-
migrations: ReadonlyArray<SQLMigration>;
|
|
902
|
-
addComponent: <SchemaComponentType extends SchemaComponent<string, Record<string, any>> = SchemaComponent<string, Record<string, any>>>(component: SchemaComponentType) => SchemaComponentType;
|
|
903
|
-
addMigration: (migration: SQLMigration) => void;
|
|
904
|
-
} & Readonly<{
|
|
905
|
-
columnName: ColumnName;
|
|
906
|
-
}> & {
|
|
907
|
-
sqlTokenType: "SQL_COLUMN";
|
|
908
|
-
} & Omit<NullableSQLColumnTokenProps<ColumnType>, "sqlTokenType"> & (TOptions & {
|
|
909
|
-
type: ColumnType;
|
|
910
|
-
} extends infer T_1 ? T_1 extends TOptions & {
|
|
911
|
-
type: ColumnType;
|
|
912
|
-
} ? T_1 extends {
|
|
913
|
-
notNull: true;
|
|
914
|
-
} | {
|
|
915
|
-
primaryKey: true;
|
|
916
|
-
} ? {
|
|
917
|
-
notNull: true;
|
|
918
|
-
} : {
|
|
919
|
-
notNull?: false;
|
|
920
|
-
} : never : never));
|
|
921
|
-
index: (name: string, columnNames: string[], options?: {
|
|
922
|
-
unique?: boolean;
|
|
923
|
-
} & SchemaComponentOptions) => IndexSchemaComponent;
|
|
924
|
-
};
|
|
925
|
-
|
|
926
|
-
type DatabaseLockOptions = {
|
|
927
|
-
lockId: number;
|
|
928
|
-
timeoutMs?: number;
|
|
929
|
-
};
|
|
930
|
-
type AcquireDatabaseLockMode = 'Permanent' | 'Session';
|
|
931
|
-
type AcquireDatabaseLockOptions = DatabaseLockOptions & {
|
|
932
|
-
mode?: AcquireDatabaseLockMode;
|
|
933
|
-
};
|
|
934
|
-
type ReleaseDatabaseLockOptions = DatabaseLockOptions;
|
|
935
|
-
declare const defaultDatabaseLockOptions: Required<Omit<DatabaseLockOptions, 'lockId'>>;
|
|
936
|
-
type DatabaseLock = {
|
|
937
|
-
acquire(execute: SQLExecutor, options: AcquireDatabaseLockOptions): Promise<void>;
|
|
938
|
-
tryAcquire(execute: SQLExecutor, options: AcquireDatabaseLockOptions): Promise<boolean>;
|
|
939
|
-
release(execute: SQLExecutor, options: ReleaseDatabaseLockOptions): Promise<boolean>;
|
|
940
|
-
withAcquire: <Result = unknown>(execute: SQLExecutor, handle: () => Promise<Result>, options: AcquireDatabaseLockOptions) => Promise<Result>;
|
|
941
|
-
};
|
|
942
|
-
declare const NoDatabaseLock: DatabaseLock;
|
|
943
|
-
|
|
944
|
-
declare const MIGRATIONS_LOCK_ID = 999956789;
|
|
945
|
-
declare global {
|
|
946
|
-
var defaultMigratorOptions: Record<DatabaseType, MigratorOptions>;
|
|
947
|
-
}
|
|
948
|
-
declare const registerDefaultMigratorOptions: (databaseType: DatabaseType, options: MigratorOptions) => void;
|
|
949
|
-
declare const getDefaultMigratorOptionsFromRegistry: (databaseType: DatabaseType) => MigratorOptions;
|
|
950
|
-
type MigratorOptions = {
|
|
951
|
-
schema?: {
|
|
952
|
-
migrationTable?: SchemaComponent;
|
|
953
|
-
};
|
|
954
|
-
lock?: {
|
|
955
|
-
databaseLock?: DatabaseLock;
|
|
956
|
-
options?: Omit<DatabaseLockOptions, 'lockId'> & Partial<Pick<DatabaseLockOptions, 'lockId'>>;
|
|
957
|
-
};
|
|
958
|
-
dryRun?: boolean | undefined;
|
|
959
|
-
};
|
|
960
|
-
declare const runSQLMigrations: (pool: Dumbo, migrations: ReadonlyArray<SQLMigration>, partialOptions?: Partial<MigratorOptions>) => Promise<void>;
|
|
961
|
-
declare const combineMigrations: (...migration: Pick<SQLMigration, "sqls">[]) => SQL[];
|
|
962
|
-
|
|
963
|
-
interface DumboDatabaseDriver<ConnectionType extends AnyConnection = AnyConnection, DriverOptions extends unknown = unknown, DumboType extends Dumbo<ConnectionType['driverType'], ConnectionType> = Dumbo<ConnectionType['driverType'], ConnectionType>> {
|
|
964
|
-
readonly driverType: ConnectionType['driverType'];
|
|
965
|
-
readonly sqlFormatter: SQLFormatter;
|
|
966
|
-
readonly defaultMigratorOptions: MigratorOptions;
|
|
967
|
-
getDatabaseNameOrDefault(connectionString: string): string;
|
|
968
|
-
createPool(options: DumboConnectionOptions<this>): DumboType;
|
|
969
|
-
canHandle(options: DumboConnectionOptions<this>): boolean;
|
|
970
|
-
}
|
|
971
|
-
type AnyDumboDatabaseDriver = DumboDatabaseDriver<AnyConnection, any>;
|
|
972
|
-
type ExtractDumboDatabaseDriverOptions<DatabaseDriver> = DatabaseDriver extends DumboDatabaseDriver<any, infer O, any> ? O : never;
|
|
973
|
-
type ExtractDumboTypeFromDriver<DatabaseDriver> = DatabaseDriver extends DumboDatabaseDriver<any, any, infer D> ? D : never;
|
|
974
|
-
declare const canHandleDriverWithConnectionString: <DatabaseDriver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver, ConnectionOptions extends DumboConnectionOptions<DatabaseDriver> = DumboConnectionOptions<DatabaseDriver>>(driver: DatabaseDriver["driverType"], tryParseConnectionString: (connectionString: string) => string | null) => (options: ConnectionOptions) => boolean;
|
|
975
|
-
declare const DumboDatabaseDriverRegistry: () => {
|
|
976
|
-
register: <Driver extends AnyDumboDatabaseDriver>(driverType: Driver["driverType"], plugin: Driver | (() => Promise<Driver>)) => void;
|
|
977
|
-
tryResolve: <Driver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver, ConnectionOptions extends DumboConnectionOptions<Driver> = DumboConnectionOptions<Driver>>(options: ConnectionOptions) => Promise<Driver | null>;
|
|
978
|
-
tryGet: <Driver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver, ConnectionOptions extends DumboConnectionOptions<Driver> = DumboConnectionOptions<Driver>>(options: ConnectionOptions) => Driver | null;
|
|
979
|
-
has: (driverType: DatabaseDriverType) => boolean;
|
|
980
|
-
readonly databaseDriverTypes: DatabaseDriverType[];
|
|
981
|
-
};
|
|
982
|
-
declare global {
|
|
983
|
-
var dumboDatabaseDriverRegistry: ReturnType<typeof DumboDatabaseDriverRegistry>;
|
|
984
|
-
}
|
|
985
|
-
declare const dumboDatabaseDriverRegistry: {
|
|
986
|
-
register: <Driver extends AnyDumboDatabaseDriver>(driverType: Driver["driverType"], plugin: Driver | (() => Promise<Driver>)) => void;
|
|
987
|
-
tryResolve: <Driver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver, ConnectionOptions extends DumboConnectionOptions<Driver> = DumboConnectionOptions<Driver>>(options: ConnectionOptions) => Promise<Driver | null>;
|
|
988
|
-
tryGet: <Driver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver, ConnectionOptions extends DumboConnectionOptions<Driver> = DumboConnectionOptions<Driver>>(options: ConnectionOptions) => Driver | null;
|
|
989
|
-
has: (driverType: DatabaseDriverType) => boolean;
|
|
990
|
-
readonly databaseDriverTypes: DatabaseDriverType[];
|
|
991
|
-
};
|
|
992
|
-
|
|
993
|
-
type DatabaseType = string;
|
|
994
|
-
type DatabaseDriverName = string;
|
|
995
|
-
type DatabaseDriverType<DatabaseTypeName extends DatabaseType = DatabaseType, DriverName extends DatabaseDriverName = DatabaseDriverName> = `${DatabaseTypeName}:${DriverName}`;
|
|
996
|
-
type InferDriverDatabaseType<T extends string> = T extends `${infer DatabaseType}:${string}` ? DatabaseType : never;
|
|
997
|
-
type DatabaseDriverTypeParts<T extends DatabaseType = DatabaseType> = {
|
|
998
|
-
databaseType: T;
|
|
999
|
-
driverName: string;
|
|
1000
|
-
};
|
|
1001
|
-
/**
|
|
1002
|
-
* Accepts a `databaseType` (e.g. PostgreSQL, SQLite) and a `driverName`
|
|
1003
|
-
* (the library name, e.g. pg, sqlite3) and combines them to a singular
|
|
1004
|
-
* `databaseDriverType` which can be used in database handling.
|
|
1005
|
-
*/
|
|
1006
|
-
declare function toDatabaseDriverType<T extends DatabaseType>(databaseType: T, driverName: string): DatabaseDriverType<T>;
|
|
1007
|
-
/**
|
|
1008
|
-
* Accepts a fully formatted `driverType` and returns the broken down
|
|
1009
|
-
* `databaseType` and `driverName`.
|
|
1010
|
-
*/
|
|
1011
|
-
declare function fromDatabaseDriverType<T extends DatabaseType>(databaseDriverType: DatabaseDriverType<T>): DatabaseDriverTypeParts<T>;
|
|
1012
|
-
/**
|
|
1013
|
-
* Accepts a fully formatted `databaseDriverType` and returns the `driverName`.
|
|
1014
|
-
*/
|
|
1015
|
-
declare function getDatabaseDriverName<T extends DatabaseType>(databaseDriverType: DatabaseDriverType<T>): DatabaseDriverName;
|
|
1016
|
-
/**
|
|
1017
|
-
* Accepts a fully formatted `databaseDriverType` and returns the `databaseType`.
|
|
1018
|
-
*/
|
|
1019
|
-
declare function getDatabaseType<T extends DatabaseType>(databaseDriverType: DatabaseDriverType<T>): DatabaseType;
|
|
1020
|
-
|
|
1021
|
-
interface QueryResultRow {
|
|
1022
|
-
[column: string]: any;
|
|
1023
|
-
}
|
|
1024
|
-
type QueryResult<Result extends QueryResultRow = QueryResultRow> = {
|
|
1025
|
-
rowCount: number | null;
|
|
1026
|
-
rows: Result[];
|
|
1027
|
-
};
|
|
1028
|
-
|
|
1029
|
-
type JSONSerializerOptions = {
|
|
1030
|
-
disableBigIntSerialization?: boolean;
|
|
1031
|
-
};
|
|
1032
|
-
type JSONSerializeOptions = {
|
|
1033
|
-
replacer?: JSONReplacer;
|
|
1034
|
-
} & JSONSerializerOptions;
|
|
1035
|
-
type JSONDeserializeOptions = {
|
|
1036
|
-
reviver?: JSONReviver;
|
|
1037
|
-
} & JSONSerializerOptions;
|
|
1038
|
-
type JSONObjectCodecOptions<SerializeOptions = JSONSerializeOptions, DeserializeOptions = JSONDeserializeOptions> = {
|
|
1039
|
-
serializer?: JSONSerializer<SerializeOptions, DeserializeOptions>;
|
|
1040
|
-
} | {
|
|
1041
|
-
serializerOptions?: JSONSerializerOptions;
|
|
1042
|
-
};
|
|
1043
|
-
declare const composeJSONReplacers: (...replacers: JSONReplacer[]) => JSONReplacer;
|
|
1044
|
-
declare const composeJSONRevivers: (...revivers: JSONReviver[]) => JSONReviver;
|
|
1045
|
-
type JSONReplacer = (this: any, key: string, value: any) => any;
|
|
1046
|
-
declare const JSONReplacer: (opts?: JSONSerializeOptions) => JSONReplacer | undefined;
|
|
1047
|
-
type JSONReviver = (this: any, key: string, value: any) => any;
|
|
1048
|
-
declare const JSONReviver: (opts?: JSONDeserializeOptions) => JSONReviver | undefined;
|
|
1049
|
-
declare const JSONReplacers: {
|
|
1050
|
-
bigInt: JSONReplacer;
|
|
1051
|
-
};
|
|
1052
|
-
declare const JSONRevivers: {
|
|
1053
|
-
bigInt: JSONReviver;
|
|
1054
|
-
};
|
|
1055
|
-
declare const jsonSerializer: (options?: JSONSerializerOptions) => JSONSerializer;
|
|
1056
|
-
interface JSONSerializer<SerializeOptions = JSONSerializeOptions, DeserializeOptions = JSONDeserializeOptions> extends Serializer<string, SerializeOptions, DeserializeOptions> {
|
|
1057
|
-
serialize<T>(object: T, options?: SerializeOptions): string;
|
|
1058
|
-
deserialize<T>(payload: string, options?: DeserializeOptions): T;
|
|
1059
|
-
}
|
|
1060
|
-
declare const JSONSerializer: JSONSerializer<JSONSerializeOptions, JSONDeserializeOptions>;
|
|
1061
|
-
declare const RawJSONSerializer: JSONSerializer<JSONSerializeOptions, JSONDeserializeOptions>;
|
|
1062
|
-
interface JSONObjectCodec<T, SerializeOptions = JSONSerializeOptions, DeserializeOptions = JSONDeserializeOptions> extends ObjectCodec<T, string> {
|
|
1063
|
-
encode(object: T, options?: SerializeOptions): string;
|
|
1064
|
-
decode(payload: string, options?: DeserializeOptions): T;
|
|
1065
|
-
}
|
|
1066
|
-
declare const JSONObjectCodec: <T, SerializeOptions = JSONSerializeOptions, DeserializeOptions = JSONDeserializeOptions>(options: JSONObjectCodecOptions<SerializeOptions, DeserializeOptions>) => JSONObjectCodec<T, SerializeOptions, DeserializeOptions>;
|
|
1067
|
-
|
|
1068
|
-
interface Serializer<Payload, SerializeOptions = never, DeserializeOptions = SerializeOptions> {
|
|
1069
|
-
serialize<T>(object: T, options?: SerializeOptions): Payload;
|
|
1070
|
-
deserialize<T>(payload: Payload, options?: DeserializeOptions): T;
|
|
1071
|
-
}
|
|
1072
|
-
interface ObjectCodec<T, Payload> {
|
|
1073
|
-
encode(object: T): Payload;
|
|
1074
|
-
decode(payload: Payload): T;
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
declare const mapColumnToJSON: (column: string, options?: JSONDeserializeOptions) => {
|
|
1078
|
-
[x: string]: (value: unknown) => unknown;
|
|
1079
|
-
};
|
|
1080
|
-
declare const mapColumnToBigint: (column: string) => {
|
|
1081
|
-
[x: string]: (value: unknown) => unknown;
|
|
1082
|
-
};
|
|
1083
|
-
declare const mapSQLQueryResult: <T>(result: T, mapping: SQLQueryResultColumnMapping) => T;
|
|
1084
|
-
type SQLQueryResultColumnMapping = {
|
|
1085
|
-
[column: string]: (value: unknown) => unknown;
|
|
1086
|
-
};
|
|
1087
|
-
type SQLQueryOptions = {
|
|
1088
|
-
timeoutMs?: number;
|
|
1089
|
-
mapping?: SQLQueryResultColumnMapping;
|
|
1090
|
-
};
|
|
1091
|
-
type SQLCommandOptions = {
|
|
1092
|
-
timeoutMs?: number;
|
|
1093
|
-
mapping?: SQLQueryResultColumnMapping;
|
|
1094
|
-
};
|
|
1095
|
-
interface DbSQLExecutor<DriverType extends DatabaseDriverType = DatabaseDriverType, DbClient = unknown> {
|
|
1096
|
-
driverType: DriverType;
|
|
1097
|
-
query<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sql: SQL, options?: SQLQueryOptions): Promise<QueryResult<Result>>;
|
|
1098
|
-
batchQuery<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sqls: SQL[], options?: SQLQueryOptions): Promise<QueryResult<Result>[]>;
|
|
1099
|
-
command<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sql: SQL, options?: SQLCommandOptions): Promise<QueryResult<Result>>;
|
|
1100
|
-
batchCommand<Result extends QueryResultRow = QueryResultRow>(client: DbClient, sqls: SQL[], options?: SQLCommandOptions): Promise<QueryResult<Result>[]>;
|
|
1101
|
-
formatter: SQLFormatter;
|
|
1102
|
-
}
|
|
1103
|
-
interface SQLExecutor {
|
|
1104
|
-
query<Result extends QueryResultRow = QueryResultRow>(sql: SQL, options?: SQLQueryOptions): Promise<QueryResult<Result>>;
|
|
1105
|
-
batchQuery<Result extends QueryResultRow = QueryResultRow>(sqls: SQL[], options?: SQLQueryOptions): Promise<QueryResult<Result>[]>;
|
|
1106
|
-
command<Result extends QueryResultRow = QueryResultRow>(sql: SQL, options?: SQLCommandOptions): Promise<QueryResult<Result>>;
|
|
1107
|
-
batchCommand<Result extends QueryResultRow = QueryResultRow>(sqls: SQL[], options?: SQLCommandOptions): Promise<QueryResult<Result>[]>;
|
|
1108
|
-
}
|
|
1109
|
-
interface WithSQLExecutor {
|
|
1110
|
-
execute: SQLExecutor;
|
|
1111
|
-
}
|
|
1112
|
-
declare const sqlExecutor: <DbClient = unknown, DbExecutor extends DbSQLExecutor = DbSQLExecutor>(sqlExecutor: DbExecutor, options: {
|
|
1113
|
-
connect: () => Promise<DbClient>;
|
|
1114
|
-
close?: (client: DbClient, error?: unknown) => Promise<void>;
|
|
1115
|
-
}) => SQLExecutor;
|
|
1116
|
-
declare const sqlExecutorInNewConnection: <ConnectionType extends Connection>(options: {
|
|
1117
|
-
driverType: ConnectionType["driverType"];
|
|
1118
|
-
connection: () => Promise<ConnectionType>;
|
|
1119
|
-
}) => SQLExecutor;
|
|
1120
|
-
declare const sqlExecutorInAmbientConnection: <ConnectionType extends Connection>(options: {
|
|
1121
|
-
driverType: ConnectionType["driverType"];
|
|
1122
|
-
connection: () => Promise<ConnectionType>;
|
|
1123
|
-
}) => SQLExecutor;
|
|
1124
|
-
declare const executeInNewDbClient: <DbClient = unknown, Result = unknown>(handle: (client: DbClient) => Promise<Result>, options: {
|
|
1125
|
-
connect: () => Promise<DbClient>;
|
|
1126
|
-
close?: (client: DbClient, error?: unknown) => Promise<void>;
|
|
1127
|
-
}) => Promise<Result>;
|
|
1128
|
-
declare const executeInNewConnection: <ConnectionType extends Connection, Result>(handle: (connection: ConnectionType) => Promise<Result>, options: {
|
|
1129
|
-
connection: () => Promise<ConnectionType>;
|
|
1130
|
-
}) => Promise<Result>;
|
|
1131
|
-
declare const executeInAmbientConnection: <ConnectionType extends Connection, Result>(handle: (connection: ConnectionType) => Promise<Result>, options: {
|
|
1132
|
-
connection: () => Promise<ConnectionType>;
|
|
1133
|
-
}) => Promise<Result>;
|
|
1134
|
-
|
|
1135
|
-
interface DatabaseTransaction<ConnectionType extends AnyConnection = AnyConnection> extends WithSQLExecutor {
|
|
1136
|
-
driverType: ConnectionType['driverType'];
|
|
1137
|
-
connection: ConnectionType;
|
|
1138
|
-
begin: () => Promise<void>;
|
|
1139
|
-
commit: () => Promise<void>;
|
|
1140
|
-
rollback: (error?: unknown) => Promise<void>;
|
|
1141
|
-
}
|
|
1142
|
-
type AnyDatabaseTransaction = DatabaseTransaction<any>;
|
|
1143
|
-
type DatabaseTransactionOptions = {
|
|
1144
|
-
allowNestedTransactions?: boolean;
|
|
1145
|
-
};
|
|
1146
|
-
interface WithDatabaseTransactionFactory<ConnectionType extends AnyConnection = AnyConnection, TransactionType extends DatabaseTransaction<ConnectionType> = DatabaseTransaction<ConnectionType>, TransactionOptionsType extends DatabaseTransactionOptions = DatabaseTransactionOptions> {
|
|
1147
|
-
transaction: (options?: TransactionOptionsType) => TransactionType;
|
|
1148
|
-
withTransaction: <Result = never>(handle: (transaction: TransactionType) => Promise<TransactionResult<Result> | Result>, options?: TransactionOptionsType) => Promise<Result>;
|
|
1149
|
-
}
|
|
1150
|
-
type TransactionResult<Result> = {
|
|
1151
|
-
success: boolean;
|
|
1152
|
-
result: Result;
|
|
1153
|
-
};
|
|
1154
|
-
declare const executeInTransaction: <DatabaseTransactionType extends AnyDatabaseTransaction = AnyDatabaseTransaction, Result = void>(transaction: DatabaseTransactionType, handle: (transaction: DatabaseTransactionType) => Promise<TransactionResult<Result> | Result>) => Promise<Result>;
|
|
1155
|
-
declare const transactionFactoryWithDbClient: <ConnectionType extends AnyConnection = AnyConnection, TransactionType extends DatabaseTransaction<ConnectionType> = DatabaseTransaction<ConnectionType>, TransactionOptionsType extends DatabaseTransactionOptions = DatabaseTransactionOptions>(connect: () => Promise<InferDbClientFromConnection<ConnectionType>>, initTransaction: (client: Promise<InferDbClientFromConnection<ConnectionType>>, options?: TransactionOptionsType & {
|
|
1156
|
-
close: (client: InferDbClientFromConnection<ConnectionType>, error?: unknown) => Promise<void>;
|
|
1157
|
-
}) => TransactionType) => WithDatabaseTransactionFactory<ConnectionType, TransactionType, TransactionOptionsType>;
|
|
1158
|
-
declare const transactionFactoryWithNewConnection: <ConnectionType extends AnyConnection = AnyConnection, TransactionType extends DatabaseTransaction<ConnectionType> = DatabaseTransaction<ConnectionType>, TransactionOptionsType extends DatabaseTransactionOptions = DatabaseTransactionOptions>(connect: () => ConnectionType) => WithDatabaseTransactionFactory<ConnectionType, TransactionType, TransactionOptionsType>;
|
|
1159
|
-
declare const transactionFactoryWithAmbientConnection: <ConnectionType extends AnyConnection = AnyConnection>(connect: () => ConnectionType) => WithDatabaseTransactionFactory<ConnectionType>;
|
|
1160
|
-
|
|
1161
|
-
interface Connection<Self extends AnyConnection = AnyConnection, DriverType extends DatabaseDriverType = DatabaseDriverType, DbClient = unknown, TransactionType extends DatabaseTransaction<Self> = DatabaseTransaction<Self>, TransactionOptionsType extends DatabaseTransactionOptions = DatabaseTransactionOptions> extends WithSQLExecutor, WithDatabaseTransactionFactory<Self, TransactionType, TransactionOptionsType> {
|
|
1162
|
-
driverType: DriverType;
|
|
1163
|
-
open: () => Promise<DbClient>;
|
|
1164
|
-
close: () => Promise<void>;
|
|
1165
|
-
}
|
|
1166
|
-
type AnyConnection = Connection<AnyConnection, DatabaseDriverType, unknown, AnyDatabaseTransaction, DatabaseTransactionOptions>;
|
|
1167
|
-
type InferDriverTypeFromConnection<C extends AnyConnection> = C extends Connection<any, infer DT, any, any, any> ? DT : never;
|
|
1168
|
-
type InferDbClientFromConnection<C extends AnyConnection> = C extends Connection<any, any, infer DC, any, any> ? DC : never;
|
|
1169
|
-
type InferTransactionFromConnection<C extends AnyConnection> = C extends Connection<any, any, any, infer DT, any> ? DT : never;
|
|
1170
|
-
type InferTransactionOptionsFromConnection<C extends AnyConnection> = C extends Connection<any, any, any, any, infer TO> ? TO : never;
|
|
1171
|
-
type ConnectionOptions<ConnectionType extends AnyConnection = AnyConnection> = {
|
|
1172
|
-
driverType?: ConnectionType['driverType'];
|
|
1173
|
-
transactionOptions?: InferTransactionOptionsFromConnection<ConnectionType>;
|
|
1174
|
-
};
|
|
1175
|
-
type ConnectionFactory<ConnectionType extends AnyConnection = AnyConnection> = (options: ConnectionOptions<ConnectionType>) => ConnectionType;
|
|
1176
|
-
interface WithConnectionFactory<ConnectionType extends AnyConnection = AnyConnection> {
|
|
1177
|
-
connection: () => Promise<ConnectionType>;
|
|
1178
|
-
withConnection: <Result = unknown>(handle: (connection: ConnectionType) => Promise<Result>) => Promise<Result>;
|
|
1179
|
-
}
|
|
1180
|
-
type InitTransaction<ConnectionType extends AnyConnection = AnyConnection, TreansactionType extends DatabaseTransaction<ConnectionType> = DatabaseTransaction<ConnectionType>, TransactionOptionsType extends DatabaseTransactionOptions = DatabaseTransactionOptions> = (connection: () => ConnectionType) => (client: Promise<InferDbClientFromConnection<ConnectionType>>, options?: TransactionOptionsType & {
|
|
1181
|
-
close: (client: InferDbClientFromConnection<ConnectionType>, error?: unknown) => Promise<void>;
|
|
1182
|
-
}) => TreansactionType;
|
|
1183
|
-
type CreateConnectionOptions<ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor, TransactionType extends DatabaseTransaction<ConnectionType> = DatabaseTransaction<ConnectionType>, TransactionOptionsType extends DatabaseTransactionOptions = DatabaseTransactionOptions> = {
|
|
1184
|
-
driverType: InferDriverTypeFromConnection<ConnectionType>;
|
|
1185
|
-
connect: () => Promise<InferDbClientFromConnection<ConnectionType>>;
|
|
1186
|
-
close: (client: InferDbClientFromConnection<ConnectionType>) => Promise<void>;
|
|
1187
|
-
initTransaction: InitTransaction<ConnectionType, TransactionType, TransactionOptionsType>;
|
|
1188
|
-
executor: () => Executor;
|
|
1189
|
-
};
|
|
1190
|
-
type CreateAmbientConnectionOptions<ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor, TransactionType extends DatabaseTransaction<ConnectionType> = DatabaseTransaction<ConnectionType>, TransactionOptionsType extends DatabaseTransactionOptions = DatabaseTransactionOptions> = {
|
|
1191
|
-
driverType: InferDriverTypeFromConnection<ConnectionType>;
|
|
1192
|
-
client: InferDbClientFromConnection<ConnectionType>;
|
|
1193
|
-
initTransaction: InitTransaction<ConnectionType, TransactionType, TransactionOptionsType>;
|
|
1194
|
-
executor: () => Executor;
|
|
1195
|
-
};
|
|
1196
|
-
declare const createAmbientConnection: <ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor, TransactionType extends DatabaseTransaction<ConnectionType> = DatabaseTransaction<ConnectionType>>(options: CreateAmbientConnectionOptions<ConnectionType, Executor, TransactionType>) => ConnectionType;
|
|
1197
|
-
type CreateSingletonConnectionOptions<ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor, TransactionType extends DatabaseTransaction<ConnectionType> = DatabaseTransaction<ConnectionType>, TransactionOptionsType extends DatabaseTransactionOptions = DatabaseTransactionOptions> = {
|
|
1198
|
-
driverType: InferDriverTypeFromConnection<ConnectionType>;
|
|
1199
|
-
connect: () => Promise<InferDbClientFromConnection<ConnectionType>>;
|
|
1200
|
-
close: (client: InferDbClientFromConnection<ConnectionType>) => Promise<void>;
|
|
1201
|
-
initTransaction: InitTransaction<ConnectionType, TransactionType, TransactionOptionsType>;
|
|
1202
|
-
executor: () => Executor;
|
|
1203
|
-
};
|
|
1204
|
-
declare const createSingletonConnection: <ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor, TransactionType extends DatabaseTransaction<ConnectionType> = DatabaseTransaction<ConnectionType>>(options: CreateSingletonConnectionOptions<ConnectionType, Executor, TransactionType>) => ConnectionType;
|
|
1205
|
-
type CreateTransientConnectionOptions<ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor, TransactionType extends DatabaseTransaction<ConnectionType> = DatabaseTransaction<ConnectionType>, TransactionOptionsType extends DatabaseTransactionOptions = DatabaseTransactionOptions> = {
|
|
1206
|
-
driverType: InferDriverTypeFromConnection<ConnectionType>;
|
|
1207
|
-
open: () => Promise<InferDbClientFromConnection<ConnectionType>>;
|
|
1208
|
-
close: () => Promise<void>;
|
|
1209
|
-
initTransaction: InitTransaction<ConnectionType, TransactionType, TransactionOptionsType>;
|
|
1210
|
-
executor: () => Executor;
|
|
1211
|
-
};
|
|
1212
|
-
declare const createTransientConnection: <ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor, TransactionType extends DatabaseTransaction<ConnectionType> = DatabaseTransaction<ConnectionType>>(options: CreateTransientConnectionOptions<ConnectionType, Executor, TransactionType>) => ConnectionType;
|
|
1213
|
-
declare const createConnection: <ConnectionType extends AnyConnection = AnyConnection, Executor extends DbSQLExecutor = DbSQLExecutor, TransactionType extends DatabaseTransaction<ConnectionType> = DatabaseTransaction<ConnectionType>>(options: CreateConnectionOptions<ConnectionType, Executor, TransactionType>) => ConnectionType;
|
|
1214
|
-
|
|
1215
|
-
interface ConnectionPool<ConnectionType extends AnyConnection = AnyConnection, TransactionType extends DatabaseTransaction<ConnectionType> = DatabaseTransaction<ConnectionType>, TransactionOptionsType extends DatabaseTransactionOptions = DatabaseTransactionOptions> extends WithSQLExecutor, WithConnectionFactory<ConnectionType>, WithDatabaseTransactionFactory<ConnectionType, TransactionType, TransactionOptionsType> {
|
|
1216
|
-
driverType: ConnectionType['driverType'];
|
|
1217
|
-
close: () => Promise<void>;
|
|
1218
|
-
}
|
|
1219
|
-
type ConnectionPoolFactory<ConnectionPoolType extends ConnectionPool = ConnectionPool, ConnectionPoolOptions = unknown> = (options: ConnectionPoolOptions) => ConnectionPoolType;
|
|
1220
|
-
declare const createAmbientConnectionPool: <ConnectionType extends AnyConnection>(options: {
|
|
1221
|
-
driverType: ConnectionType["driverType"];
|
|
1222
|
-
connection: ConnectionType;
|
|
1223
|
-
}) => ConnectionPool<ConnectionType>;
|
|
1224
|
-
type CreateSingletonConnectionPoolOptions<ConnectionType extends AnyConnection> = {
|
|
1225
|
-
driverType: ConnectionType['driverType'];
|
|
1226
|
-
getConnection: () => ConnectionType;
|
|
1227
|
-
connectionOptions?: never;
|
|
1228
|
-
};
|
|
1229
|
-
declare const createSingletonConnectionPool: <ConnectionType extends AnyConnection>(options: CreateSingletonConnectionPoolOptions<ConnectionType>) => ConnectionPool<ConnectionType>;
|
|
1230
|
-
type CreateSingletonClientPoolOptions<ConnectionType extends AnyConnection> = {
|
|
1231
|
-
driverType: ConnectionType['driverType'];
|
|
1232
|
-
dbClient: InferDbClientFromConnection<ConnectionType>;
|
|
1233
|
-
connectionFactory: (options: {
|
|
1234
|
-
dbClient: InferDbClientFromConnection<ConnectionType>;
|
|
1235
|
-
}) => ConnectionType;
|
|
1236
|
-
};
|
|
1237
|
-
declare const createSingletonClientPool: <ConnectionType extends AnyConnection>(options: CreateSingletonClientPoolOptions<ConnectionType>) => ConnectionPool<ConnectionType>;
|
|
1238
|
-
type CreateAlwaysNewConnectionPoolOptions<ConnectionType extends AnyConnection, ConnectionOptions extends Record<string, unknown> | undefined = undefined> = ConnectionOptions extends undefined ? {
|
|
1239
|
-
driverType: ConnectionType['driverType'];
|
|
1240
|
-
getConnection: () => ConnectionType;
|
|
1241
|
-
connectionOptions?: never;
|
|
1242
|
-
} : {
|
|
1243
|
-
driverType: ConnectionType['driverType'];
|
|
1244
|
-
getConnection: (options: ConnectionOptions) => ConnectionType;
|
|
1245
|
-
connectionOptions: ConnectionOptions;
|
|
1246
|
-
};
|
|
1247
|
-
declare const createAlwaysNewConnectionPool: <ConnectionType extends AnyConnection, ConnectionOptions extends Record<string, unknown> | undefined = undefined>(options: CreateAlwaysNewConnectionPoolOptions<ConnectionType, ConnectionOptions>) => ConnectionPool<ConnectionType>;
|
|
1248
|
-
type CreateConnectionPoolOptions<ConnectionType extends AnyConnection> = Pick<ConnectionPool<ConnectionType>, 'driverType'> & Partial<ConnectionPool<ConnectionType>> & {
|
|
1249
|
-
getConnection: () => ConnectionType;
|
|
1250
|
-
};
|
|
1251
|
-
declare const createConnectionPool: <ConnectionType extends AnyConnection>(pool: CreateConnectionPoolOptions<ConnectionType>) => ConnectionPool<ConnectionType>;
|
|
1252
|
-
|
|
1253
|
-
type Dumbo<DriverType extends DatabaseDriverType = DatabaseDriverType, ConnectionType extends AnyConnection = AnyConnection> = ConnectionPool<ConnectionType>;
|
|
1254
|
-
type DumboConnectionOptions<DatabaseDriver extends AnyDumboDatabaseDriver = AnyDumboDatabaseDriver> = ExtractDumboDatabaseDriverOptions<DatabaseDriver> extends infer Options ? Options extends unknown ? {
|
|
1255
|
-
driver?: DatabaseDriver;
|
|
1256
|
-
driverType?: DatabaseDriver['driverType'];
|
|
1257
|
-
} & Omit<Options, 'driver' | 'driverType' | 'connectionString'> : never : never;
|
|
1258
|
-
declare module './sql' {
|
|
1259
|
-
namespace SQL {
|
|
1260
|
-
const columnN: typeof dumboSchema.column & {
|
|
1261
|
-
type: typeof SQLColumnTypeTokensFactory;
|
|
1262
|
-
};
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
|
|
1266
|
-
type DatabaseConnectionString<DatabaseTypeName extends DatabaseType = DatabaseType, Format extends string = string> = Format & {
|
|
1267
|
-
_databaseType: DatabaseTypeName;
|
|
1268
|
-
};
|
|
1269
|
-
declare const parseConnectionString: (connectionString: DatabaseConnectionString | string) => DatabaseDriverTypeParts;
|
|
1270
|
-
|
|
1271
|
-
export { type CreateAlwaysNewConnectionPoolOptions as $, type AnySQLToken as A, type ConnectionOptions as B, type Connection as C, type DatabaseTransaction as D, type ExtractDumboTypeFromDriver as E, type ConnectionFactory as F, type InitTransaction as G, type CreateConnectionOptions as H, IndexURN as I, type CreateAmbientConnectionOptions as J, createAmbientConnection as K, type CreateSingletonConnectionOptions as L, type MigratorOptions as M, createSingletonConnection as N, type CreateTransientConnectionOptions as O, createTransientConnection as P, type QueryResultRow as Q, createConnection as R, SQLFormatter as S, TableURN as T, type ConnectionPoolFactory as U, createAmbientConnectionPool as V, type WithConnectionFactory as W, type CreateSingletonConnectionPoolOptions as X, createSingletonConnectionPool as Y, type CreateSingletonClientPoolOptions as Z, createSingletonClientPool as _, type DatabaseTransactionOptions as a, type ExtractColumnNames as a$, createAlwaysNewConnectionPool as a0, type CreateConnectionPoolOptions as a1, createConnectionPool as a2, type AnyDatabaseTransaction as a3, type WithDatabaseTransactionFactory as a4, type TransactionResult as a5, executeInTransaction as a6, transactionFactoryWithDbClient as a7, transactionFactoryWithNewConnection as a8, transactionFactoryWithAmbientConnection as a9, type DatabaseLockOptions as aA, type AcquireDatabaseLockMode as aB, type AcquireDatabaseLockOptions as aC, type ReleaseDatabaseLockOptions as aD, defaultDatabaseLockOptions as aE, type DatabaseLock as aF, NoDatabaseLock as aG, ColumnURNType as aH, type ColumnSchemaComponent as aI, type AnyColumnSchemaComponent as aJ, type ColumnSchemaComponentOptions as aK, columnSchemaComponent as aL, DatabaseURNType as aM, type DatabaseSchemas as aN, type DatabaseSchemaComponent as aO, type AnyDatabaseSchemaComponent as aP, databaseSchemaComponent as aQ, DatabaseSchemaURNType as aR, type DatabaseSchemaTables as aS, type DatabaseSchemaSchemaComponent as aT, type AnyDatabaseSchemaSchemaComponent as aU, databaseSchemaSchemaComponent as aV, IndexURNType as aW, type IndexSchemaComponent as aX, indexSchemaComponent as aY, type ExtractSchemaNames as aZ, type ExtractTableNames as a_, type DatabaseType as aa, type DatabaseDriverName as ab, type InferDriverDatabaseType as ac, type DatabaseDriverTypeParts as ad, toDatabaseDriverType as ae, fromDatabaseDriverType as af, getDatabaseDriverName as ag, getDatabaseType as ah, type ExtractDumboDatabaseDriverOptions as ai, canHandleDriverWithConnectionString as aj, DumboDatabaseDriverRegistry as ak, dumboDatabaseDriverRegistry as al, mapColumnToJSON as am, mapColumnToBigint as an, mapSQLQueryResult as ao, type SQLQueryResultColumnMapping as ap, type SQLQueryOptions as aq, type SQLCommandOptions as ar, type SQLExecutor as as, type WithSQLExecutor as at, sqlExecutor as au, sqlExecutorInNewConnection as av, sqlExecutorInAmbientConnection as aw, executeInNewDbClient as ax, executeInNewConnection as ay, executeInAmbientConnection as az, type ConnectionPool as b, type InferColumnType as b$, type ExtractColumnTypeName as b0, type AllColumnTypes as b1, type AllColumnReferences as b2, type AllColumnTypesInSchema as b3, type AllColumnReferencesInSchema as b4, type NormalizeReference as b5, type NormalizeColumnPath as b6, type ColumnName as b7, type TableColumnName as b8, type SchemaColumnName as b9, type CollectReferencesErrors as bA, type SchemaTablesWithSingle as bB, type DatabaseSchemasWithSingle as bC, type ValidateRelationship as bD, type CollectRelationshipErrors as bE, type ValidateTableRelationships as bF, type ValidateTable as bG, type ValidateSchemaTables as bH, type ValidateDatabaseSchema as bI, type ValidateDatabaseSchemas as bJ, type ValidateDatabaseSchemasWithMessages as bK, type Join as bL, type IndentErrors as bM, type FormatSingleError as bN, type FormatRelationshipBlock as bO, type FormatTableLevel as bP, type FormatSchemaLevel as bQ, type FormatDatabaseValidationErrors as bR, type FormatValidationErrors as bS, TableURNType as bT, type TableColumns as bU, type TableSchemaComponent as bV, type InferTableSchemaComponentTypes as bW, type InferTableSchemaComponentColumns as bX, type AnyTableSchemaComponent as bY, tableSchemaComponent as bZ, type Writable as b_, type ColumnPath as ba, type ColumnReference as bb, type ColumnPathToReference as bc, type ParseReferencePath as bd, type LookupColumnType as be, type RelationshipType as bf, type RelationshipDefinition as bg, type AnyTableRelationshipDefinition as bh, type AnyTableRelationshipDefinitionWithColumns as bi, type TableRelationships as bj, relationship as bk, type AnyRelationshipDefinition as bl, type RelationshipColumnsMismatchError as bm, type RelationshipReferencesLengthMismatchError as bn, type ColumnReferenceExistanceError as bo, type ColumnReferenceTypeMismatchError as bp, type NoError as bq, type ColumnReferenceError as br, type RelationshipValidationError as bs, type ValidateRelationshipLength as bt, type ValidateRelationshipColumns as bu, type ValidateColumnReference as bv, type ValidateColumnTypeMatch as bw, type ValidateColumnsMatch as bx, type ValidateReference as by, type ValidateReferences as bz, type DbSQLExecutor as c, ColumnTypeToken as c$, type TableColumnType as c0, type TableColumnNames as c1, type InferTableRow as c2, type TableRowType as c3, type InferSchemaTables as c4, type InferDatabaseSchemas as c5, dumboSchema as c6, MIGRATIONS_LOCK_ID as c7, registerDefaultMigratorOptions as c8, getDefaultMigratorOptionsFromRegistry as c9, RawJSONSerializer as cA, JSONObjectCodec as cB, type JSONObjectCodecOptions as cC, type JSONSerializerOptions as cD, type JSONSerializeOptions as cE, type JSONDeserializeOptions as cF, type FormatSQLOptions as cG, type SQLFormatterOptions as cH, registerFormatter as cI, getFormatter as cJ, formatSQL as cK, describeSQL as cL, type ParametrizedSQL as cM, ParametrizedSQLBuilder as cN, defaultProcessorsRegistry as cO, type SQLProcessorContext as cP, type AnySQLProcessor as cQ, type SQLProcessorOptions as cR, type SQLProcessorsReadonlyRegistry as cS, SQLProcessorsRegistry as cT, SQL as cU, isSQL as cV, type JSONValueType as cW, type JSONValueTypeName as cX, type JavaScriptValueType as cY, type JavaScriptValueTypeName as cZ, type JavaScriptValueTypeToNameMap as c_, runSQLMigrations as ca, combineMigrations as cb, type ExtractAdditionalData as cc, type AnySchemaComponent as cd, type AnySchemaComponentOfType as ce, type SchemaComponentOptions as cf, type SchemaComponentType as cg, type DumboSchemaComponentType as ch, schemaComponent as ci, isSchemaComponentOfType as cj, filterSchemaComponentsOfType as ck, mapSchemaComponentsOfType as cl, findSchemaComponentsOfType as cm, type MigrationStyle as cn, sqlMigration as co, type MigrationRecord as cp, type Serializer as cq, type ObjectCodec as cr, composeJSONReplacers as cs, composeJSONRevivers as ct, JSONReplacer as cu, JSONReplacers as cv, JSONReviver as cw, JSONRevivers as cx, JSONSerializer as cy, jsonSerializer as cz, type DumboDatabaseDriver as d, type AnyColumnTypeToken as d0, SerialToken as d1, BigSerialToken as d2, IntegerToken as d3, BigIntegerToken as d4, JSONBToken as d5, TimestampToken as d6, TimestamptzToken as d7, VarcharToken as d8, type NotNullableSQLColumnTokenProps as d9, type NullableSQLColumnTokenProps as da, SQLColumnToken as db, AutoIncrementSQLColumnToken as dc, SQLColumnTypeTokens as dd, SQLColumnTypeTokensFactory as de, type DefaultSQLColumnToken as df, SQLToken as dg, type ExtractSQLTokenType as dh, SQLPlain as di, type SQLDefaultTokens as dj, type SQLDefaultTokensTypes as dk, SQLValueMapper as dl, type MapSQLParamValue as dm, type MapSQLParamValueOptions as dn, ANSISQLParamPlaceholder as dp, ANSISQLIdentifierQuote as dq, mapANSISQLParamPlaceholder as dr, mapSQLIdentifier as ds, DefaultMapSQLParamValueOptions as dt, mapSQLParamValue as du, type DatabaseConnectionString as dv, parseConnectionString as dw, type Dumbo as e, type DumboConnectionOptions as f, SQLProcessor as g, SQLArray as h, SQLIn as i, SQLIdentifier as j, SQLLiteral as k, DatabaseURN as l, DatabaseSchemaURN as m, ColumnURN as n, type SchemaComponent as o, type SQLMigration as p, type DatabaseDriverType as q, type QueryResult as r, type AnyTypeValidationError as s, type TypeValidationSuccess as t, type AnyDumboDatabaseDriver as u, type AnyConnection as v, type InferDriverTypeFromConnection as w, type InferDbClientFromConnection as x, type InferTransactionFromConnection as y, type InferTransactionOptionsFromConnection as z };
|