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