kysely 0.19.7 → 0.19.10
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/README.md +16 -10
- package/dist/cjs/dialect/sqlite/sqlite-introspector.js +1 -1
- package/dist/cjs/operation-node/create-type-node.d.ts +17 -0
- package/dist/cjs/operation-node/create-type-node.js +27 -0
- package/dist/cjs/operation-node/drop-type-node.d.ts +16 -0
- package/dist/cjs/operation-node/drop-type-node.js +25 -0
- package/dist/cjs/operation-node/operation-node-transformer.d.ts +9 -2
- package/dist/cjs/operation-node/operation-node-transformer.js +147 -122
- package/dist/cjs/operation-node/operation-node-visitor.d.ts +6 -0
- package/dist/cjs/operation-node/operation-node-visitor.js +3 -0
- package/dist/cjs/operation-node/operation-node.d.ts +1 -1
- package/dist/cjs/operation-node/select-modifier-node.d.ts +16 -0
- package/dist/cjs/operation-node/select-modifier-node.js +24 -0
- package/dist/cjs/operation-node/select-query-node.d.ts +5 -5
- package/dist/cjs/operation-node/select-query-node.js +11 -9
- package/dist/cjs/plugin/with-schema/with-schema-transformer.d.ts +4 -0
- package/dist/cjs/plugin/with-schema/with-schema-transformer.js +6 -0
- package/dist/cjs/query-builder/select-query-builder.d.ts +50 -6
- package/dist/cjs/query-builder/select-query-builder.js +68 -13
- package/dist/cjs/query-compiler/default-query-compiler.d.ts +6 -0
- package/dist/cjs/query-compiler/default-query-compiler.js +29 -7
- package/dist/cjs/query-compiler/query-compiler.d.ts +3 -1
- package/dist/cjs/schema/create-type-builder.d.ts +19 -0
- package/dist/cjs/schema/create-type-builder.js +29 -0
- package/dist/cjs/schema/drop-type-builder.d.ts +19 -0
- package/dist/cjs/schema/drop-type-builder.js +31 -0
- package/dist/cjs/schema/schema.d.ts +32 -0
- package/dist/cjs/schema/schema.js +46 -0
- package/dist/cjs/util/require-all-props.d.ts +43 -0
- package/dist/cjs/util/require-all-props.js +40 -0
- package/dist/esm/dialect/sqlite/sqlite-introspector.js +1 -1
- package/dist/esm/operation-node/create-type-node.d.ts +17 -0
- package/dist/esm/operation-node/create-type-node.js +25 -0
- package/dist/esm/operation-node/drop-type-node.d.ts +16 -0
- package/dist/esm/operation-node/drop-type-node.js +23 -0
- package/dist/esm/operation-node/operation-node-transformer.d.ts +9 -2
- package/dist/esm/operation-node/operation-node-transformer.js +147 -122
- package/dist/esm/operation-node/operation-node-visitor.d.ts +6 -0
- package/dist/esm/operation-node/operation-node-visitor.js +3 -0
- package/dist/esm/operation-node/operation-node.d.ts +1 -1
- package/dist/esm/operation-node/select-modifier-node.d.ts +16 -0
- package/dist/esm/operation-node/select-modifier-node.js +22 -0
- package/dist/esm/operation-node/select-query-node.d.ts +5 -5
- package/dist/esm/operation-node/select-query-node.js +11 -9
- package/dist/esm/plugin/with-schema/with-schema-transformer.d.ts +4 -0
- package/dist/esm/plugin/with-schema/with-schema-transformer.js +6 -0
- package/dist/esm/query-builder/select-query-builder.d.ts +50 -6
- package/dist/esm/query-builder/select-query-builder.js +68 -13
- package/dist/esm/query-compiler/default-query-compiler.d.ts +6 -0
- package/dist/esm/query-compiler/default-query-compiler.js +29 -7
- package/dist/esm/query-compiler/query-compiler.d.ts +3 -1
- package/dist/esm/schema/create-type-builder.d.ts +19 -0
- package/dist/esm/schema/create-type-builder.js +26 -0
- package/dist/esm/schema/drop-type-builder.d.ts +19 -0
- package/dist/esm/schema/drop-type-builder.js +28 -0
- package/dist/esm/schema/schema.d.ts +32 -0
- package/dist/esm/schema/schema.js +46 -0
- package/dist/esm/util/require-all-props.d.ts +43 -0
- package/dist/esm/util/require-all-props.js +37 -0
- package/package.json +1 -1
|
@@ -20,6 +20,10 @@ import { CreateViewBuilder } from './create-view-builder.js';
|
|
|
20
20
|
import { CreateViewNode } from '../operation-node/create-view-node.js';
|
|
21
21
|
import { DropViewBuilder } from './drop-view-builder.js';
|
|
22
22
|
import { DropViewNode } from '../operation-node/drop-view-node.js';
|
|
23
|
+
import { CreateTypeBuilder } from './create-type-builder.js';
|
|
24
|
+
import { DropTypeBuilder } from './drop-type-builder.js';
|
|
25
|
+
import { CreateTypeNode } from '../operation-node/create-type-node.js';
|
|
26
|
+
import { DropTypeNode } from '../operation-node/drop-type-node.js';
|
|
23
27
|
/**
|
|
24
28
|
* Provides methods for building database schema.
|
|
25
29
|
*/
|
|
@@ -237,6 +241,48 @@ export class SchemaModule {
|
|
|
237
241
|
dropViewNode: DropViewNode.create(viewName),
|
|
238
242
|
});
|
|
239
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Create a new type.
|
|
246
|
+
*
|
|
247
|
+
* Only some dialects like PostgreSQL have user-defined types.
|
|
248
|
+
*
|
|
249
|
+
* ### Examples
|
|
250
|
+
*
|
|
251
|
+
* ```ts
|
|
252
|
+
* await db.schema
|
|
253
|
+
* .createType('species')
|
|
254
|
+
* .asEnum(['dog', 'cat', 'frog'])
|
|
255
|
+
* .execute()
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
createType(viewName) {
|
|
259
|
+
return new CreateTypeBuilder({
|
|
260
|
+
queryId: createQueryId(),
|
|
261
|
+
executor: this.#executor,
|
|
262
|
+
createTypeNode: CreateTypeNode.create(viewName),
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Drop a type.
|
|
267
|
+
*
|
|
268
|
+
* Only some dialects like PostgreSQL have user-defined types.
|
|
269
|
+
*
|
|
270
|
+
* ### Examples
|
|
271
|
+
*
|
|
272
|
+
* ```ts
|
|
273
|
+
* await db.schema
|
|
274
|
+
* .dropType('species')
|
|
275
|
+
* .ifExists()
|
|
276
|
+
* .execute()
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
dropType(viewName) {
|
|
280
|
+
return new DropTypeBuilder({
|
|
281
|
+
queryId: createQueryId(),
|
|
282
|
+
executor: this.#executor,
|
|
283
|
+
dropTypeNode: DropTypeNode.create(viewName),
|
|
284
|
+
});
|
|
285
|
+
}
|
|
240
286
|
/**
|
|
241
287
|
* Returns a copy of this schema module with the given plugin installed.
|
|
242
288
|
*/
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility type to force use of all properties of T.
|
|
3
|
+
*
|
|
4
|
+
* Similar to Required<T> build-in type, but allows `undefined` values.
|
|
5
|
+
*/
|
|
6
|
+
declare type AllProps<T> = T & {
|
|
7
|
+
[P in keyof T]-?: unknown;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Helper function to check listed properties according to given type. Check if all properties has been used when object is initialised.
|
|
11
|
+
*
|
|
12
|
+
* Example use:
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* type SomeType = { propA: string; propB?: number; }
|
|
16
|
+
*
|
|
17
|
+
* // propB has to be mentioned even it is optional. It still should be initialized with undefined.
|
|
18
|
+
* const a: SomeType = requireAllProps<SomeType>({ propA: "value A", propB: undefined });
|
|
19
|
+
*
|
|
20
|
+
* // checked type is implicit for variable.
|
|
21
|
+
* const b = requireAllProps<SomeType>({ propA: "value A", propB: undefined });
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Wrong use of this helper:
|
|
25
|
+
*
|
|
26
|
+
* 1. Omit checked type - all checked properties will be expect as of type never
|
|
27
|
+
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* const z: SomeType = requireAllProps({ propC: "no type will work" });
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* 2. Apply to spreaded object - there is no way how to check in compile time if spreaded object contains all properties
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* const y: SomeType = { propA: "" }; // valid object according to SomeType declaration
|
|
36
|
+
* const x = requireAllProps<SomeType>( { ... y } );
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @param obj object to check if all properties has been used
|
|
40
|
+
* @returns untouched obj parameter is returned
|
|
41
|
+
*/
|
|
42
|
+
export declare function requireAllProps<T>(obj: AllProps<T>): T;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/// <reference types="./require-all-props.d.ts" />
|
|
2
|
+
/**
|
|
3
|
+
* Helper function to check listed properties according to given type. Check if all properties has been used when object is initialised.
|
|
4
|
+
*
|
|
5
|
+
* Example use:
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* type SomeType = { propA: string; propB?: number; }
|
|
9
|
+
*
|
|
10
|
+
* // propB has to be mentioned even it is optional. It still should be initialized with undefined.
|
|
11
|
+
* const a: SomeType = requireAllProps<SomeType>({ propA: "value A", propB: undefined });
|
|
12
|
+
*
|
|
13
|
+
* // checked type is implicit for variable.
|
|
14
|
+
* const b = requireAllProps<SomeType>({ propA: "value A", propB: undefined });
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* Wrong use of this helper:
|
|
18
|
+
*
|
|
19
|
+
* 1. Omit checked type - all checked properties will be expect as of type never
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* const z: SomeType = requireAllProps({ propC: "no type will work" });
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* 2. Apply to spreaded object - there is no way how to check in compile time if spreaded object contains all properties
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* const y: SomeType = { propA: "" }; // valid object according to SomeType declaration
|
|
29
|
+
* const x = requireAllProps<SomeType>( { ... y } );
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @param obj object to check if all properties has been used
|
|
33
|
+
* @returns untouched obj parameter is returned
|
|
34
|
+
*/
|
|
35
|
+
export function requireAllProps(obj) {
|
|
36
|
+
return obj;
|
|
37
|
+
}
|