tspace-mysql 1.9.0 → 1.9.1
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 +4357 -133
- package/dist/lib/config/index.d.ts +2 -2
- package/dist/lib/config/index.js +24 -16
- package/dist/lib/config/index.js.map +1 -1
- package/dist/lib/constants/index.d.ts +10 -1
- package/dist/lib/constants/index.js +11 -2
- package/dist/lib/constants/index.js.map +1 -1
- package/dist/lib/core/Abstracts/AbstractBuilder.d.ts +11 -7
- package/dist/lib/core/Abstracts/AbstractBuilder.js +11 -13
- package/dist/lib/core/Abstracts/AbstractBuilder.js.map +1 -1
- package/dist/lib/core/Abstracts/AbstractDB.d.ts +4 -1
- package/dist/lib/core/Abstracts/AbstractDB.js.map +1 -1
- package/dist/lib/core/Abstracts/AbstractView.js.map +1 -1
- package/dist/lib/core/Blueprint.d.ts +30 -10
- package/dist/lib/core/Blueprint.js +39 -14
- package/dist/lib/core/Blueprint.js.map +1 -1
- package/dist/lib/core/Builder.d.ts +263 -9
- package/dist/lib/core/Builder.js +610 -347
- package/dist/lib/core/Builder.js.map +1 -1
- package/dist/lib/core/Cache/DBCache.js +19 -20
- package/dist/lib/core/Cache/DBCache.js.map +1 -1
- package/dist/lib/core/Cache/MemoryCache.js +3 -3
- package/dist/lib/core/Cache/MemoryCache.js.map +1 -1
- package/dist/lib/core/Cache/RedisCache.js +27 -17
- package/dist/lib/core/Cache/RedisCache.js.map +1 -1
- package/dist/lib/core/Cache/index.js +5 -4
- package/dist/lib/core/Cache/index.js.map +1 -1
- package/dist/lib/core/Contracts/AlterTable.d.ts +152 -0
- package/dist/lib/core/Contracts/AlterTable.js +243 -0
- package/dist/lib/core/Contracts/AlterTable.js.map +1 -0
- package/dist/lib/core/Contracts/Audit.js +2 -5
- package/dist/lib/core/Contracts/Audit.js.map +1 -1
- package/dist/lib/core/DB.d.ts +101 -9
- package/dist/lib/core/DB.js +168 -29
- package/dist/lib/core/DB.js.map +1 -1
- package/dist/lib/core/Decorator.d.ts +144 -16
- package/dist/lib/core/Decorator.js +156 -14
- package/dist/lib/core/Decorator.js.map +1 -1
- package/dist/lib/core/Driver/index.d.ts +43 -9
- package/dist/lib/core/Driver/index.js +9 -7
- package/dist/lib/core/Driver/index.js.map +1 -1
- package/dist/lib/core/Driver/mariadb/MariadbDriver.js +74 -27
- package/dist/lib/core/Driver/mariadb/MariadbDriver.js.map +1 -1
- package/dist/lib/core/Driver/mariadb/MariadbQueryBuilder.d.ts +45 -9
- package/dist/lib/core/Driver/mariadb/MariadbQueryBuilder.js +165 -21
- package/dist/lib/core/Driver/mariadb/MariadbQueryBuilder.js.map +1 -1
- package/dist/lib/core/Driver/mongodb/MongodbDriver.d.ts +24 -0
- package/dist/lib/core/Driver/mongodb/MongodbDriver.js +255 -0
- package/dist/lib/core/Driver/mongodb/MongodbDriver.js.map +1 -0
- package/dist/lib/core/Driver/mongodb/MongodbQueryBuilder.d.ts +141 -0
- package/dist/lib/core/Driver/mongodb/MongodbQueryBuilder.js +563 -0
- package/dist/lib/core/Driver/mongodb/MongodbQueryBuilder.js.map +1 -0
- package/dist/lib/core/Driver/mysql/MysqlDriver.js +105 -95
- package/dist/lib/core/Driver/mysql/MysqlDriver.js.map +1 -1
- package/dist/lib/core/Driver/mysql/MysqlQueryBuilder.d.ts +45 -9
- package/dist/lib/core/Driver/mysql/MysqlQueryBuilder.js +165 -21
- package/dist/lib/core/Driver/mysql/MysqlQueryBuilder.js.map +1 -1
- package/dist/lib/core/Driver/postgres/PostgresDriver.js +97 -72
- package/dist/lib/core/Driver/postgres/PostgresDriver.js.map +1 -1
- package/dist/lib/core/Driver/postgres/PostgresQueryBuilder.d.ts +50 -9
- package/dist/lib/core/Driver/postgres/PostgresQueryBuilder.js +296 -41
- package/dist/lib/core/Driver/postgres/PostgresQueryBuilder.js.map +1 -1
- package/dist/lib/core/Driver/sqlite/SqliteDriver.d.ts +20 -0
- package/dist/lib/core/Driver/sqlite/SqliteDriver.js +192 -0
- package/dist/lib/core/Driver/sqlite/SqliteDriver.js.map +1 -0
- package/dist/lib/core/Driver/sqlite/SqliteQueryBuilder.d.ts +144 -0
- package/dist/lib/core/Driver/sqlite/SqliteQueryBuilder.js +689 -0
- package/dist/lib/core/Driver/sqlite/SqliteQueryBuilder.js.map +1 -0
- package/dist/lib/core/JoinModel.js +2 -2
- package/dist/lib/core/JoinModel.js.map +1 -1
- package/dist/lib/core/Meta.d.ts +17 -11
- package/dist/lib/core/Meta.js +25 -19
- package/dist/lib/core/Meta.js.map +1 -1
- package/dist/lib/core/Model.d.ts +450 -108
- package/dist/lib/core/Model.js +1031 -587
- package/dist/lib/core/Model.js.map +1 -1
- package/dist/lib/{tools/index.d.ts → core/Package.d.ts} +11 -3
- package/dist/lib/{tools/index.js → core/Package.js} +20 -7
- package/dist/lib/core/Package.js.map +1 -0
- package/dist/lib/core/Pool.js +42 -30
- package/dist/lib/core/Pool.js.map +1 -1
- package/dist/lib/core/Queue.d.ts +240 -0
- package/dist/lib/core/Queue.js +686 -0
- package/dist/lib/core/Queue.js.map +1 -0
- package/dist/lib/core/RelationManager.js +27 -25
- package/dist/lib/core/RelationManager.js.map +1 -1
- package/dist/lib/core/Repository.d.ts +73 -207
- package/dist/lib/core/Repository.js +120 -235
- package/dist/lib/core/Repository.js.map +1 -1
- package/dist/lib/core/Schema.d.ts +218 -0
- package/dist/lib/core/Schema.js +370 -65
- package/dist/lib/core/Schema.js.map +1 -1
- package/dist/lib/core/StateManager.d.ts +25 -12
- package/dist/lib/core/StateManager.js +10 -5
- package/dist/lib/core/StateManager.js.map +1 -1
- package/dist/lib/core/UtilityTypes.d.ts +85 -56
- package/dist/lib/core/UtilityTypes.js.map +1 -1
- package/dist/lib/core/index.d.ts +4 -0
- package/dist/lib/core/index.js +6 -2
- package/dist/lib/core/index.js.map +1 -1
- package/dist/lib/types/decorator/index.d.ts +1 -1
- package/dist/lib/types/index.d.ts +69 -22
- package/dist/lib/types/repository/index.d.ts +68 -37
- package/dist/lib/utils/index.d.ts +11 -1
- package/dist/lib/utils/index.js +58 -2
- package/dist/lib/utils/index.js.map +1 -1
- package/package.json +14 -6
- package/dist/lib/tools/index.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Blueprint } from "./Blueprint";
|
|
2
|
-
import type { TPattern, TSave, TValidateSchema } from "../types";
|
|
2
|
+
import type { TPattern, TRelationOptions, TSave, TStateWhereCondition, TValidateSchema } from "../types";
|
|
3
3
|
declare const STATE_DEFAULT: {
|
|
4
4
|
readonly PRIMARY_KEY: string;
|
|
5
5
|
readonly VOID: boolean;
|
|
@@ -17,7 +17,7 @@ declare const STATE_DEFAULT: {
|
|
|
17
17
|
readonly EXCEPTS: string[];
|
|
18
18
|
readonly FROM: string[];
|
|
19
19
|
readonly JOIN: string[];
|
|
20
|
-
readonly WHERE:
|
|
20
|
+
readonly WHERE: TStateWhereCondition[];
|
|
21
21
|
readonly GROUP_BY: string[];
|
|
22
22
|
readonly ORDER_BY: string[];
|
|
23
23
|
readonly LIMIT: number | null;
|
|
@@ -27,14 +27,18 @@ declare const STATE_DEFAULT: {
|
|
|
27
27
|
readonly HIDDEN: string[];
|
|
28
28
|
readonly DEBUG: boolean;
|
|
29
29
|
readonly CTE: string[];
|
|
30
|
-
readonly PAGE: number;
|
|
30
|
+
readonly PAGE: number | null;
|
|
31
31
|
readonly AFTER_SAVE: number;
|
|
32
32
|
readonly HOOKS: Function[];
|
|
33
33
|
readonly ALIAS: string | null;
|
|
34
34
|
readonly RAW_ALIAS: string | null;
|
|
35
35
|
readonly UNION: string[];
|
|
36
36
|
readonly UNION_ALL: string[];
|
|
37
|
-
readonly ROW_LEVEL_LOCK:
|
|
37
|
+
readonly ROW_LEVEL_LOCK: {
|
|
38
|
+
readonly mode: "FOR_UPDATE" | "FOR_SHARE" | null;
|
|
39
|
+
readonly skipLocked: boolean | null;
|
|
40
|
+
readonly nowait: boolean | null;
|
|
41
|
+
};
|
|
38
42
|
};
|
|
39
43
|
declare const STATE_DB: {
|
|
40
44
|
readonly PRIMARY_KEY: string;
|
|
@@ -53,7 +57,7 @@ declare const STATE_DB: {
|
|
|
53
57
|
readonly EXCEPTS: string[];
|
|
54
58
|
readonly FROM: string[];
|
|
55
59
|
readonly JOIN: string[];
|
|
56
|
-
readonly WHERE:
|
|
60
|
+
readonly WHERE: TStateWhereCondition[];
|
|
57
61
|
readonly GROUP_BY: string[];
|
|
58
62
|
readonly ORDER_BY: string[];
|
|
59
63
|
readonly LIMIT: number | null;
|
|
@@ -63,14 +67,18 @@ declare const STATE_DB: {
|
|
|
63
67
|
readonly HIDDEN: string[];
|
|
64
68
|
readonly DEBUG: boolean;
|
|
65
69
|
readonly CTE: string[];
|
|
66
|
-
readonly PAGE: number;
|
|
70
|
+
readonly PAGE: number | null;
|
|
67
71
|
readonly AFTER_SAVE: number;
|
|
68
72
|
readonly HOOKS: Function[];
|
|
69
73
|
readonly ALIAS: string | null;
|
|
70
74
|
readonly RAW_ALIAS: string | null;
|
|
71
75
|
readonly UNION: string[];
|
|
72
76
|
readonly UNION_ALL: string[];
|
|
73
|
-
readonly ROW_LEVEL_LOCK:
|
|
77
|
+
readonly ROW_LEVEL_LOCK: {
|
|
78
|
+
readonly mode: "FOR_UPDATE" | "FOR_SHARE" | null;
|
|
79
|
+
readonly skipLocked: boolean | null;
|
|
80
|
+
readonly nowait: boolean | null;
|
|
81
|
+
};
|
|
74
82
|
};
|
|
75
83
|
declare const STATE_MODEL: {
|
|
76
84
|
readonly AUDIT: number | null;
|
|
@@ -83,8 +91,8 @@ declare const STATE_MODEL: {
|
|
|
83
91
|
readonly SOFT_DELETE_RELATIONS: boolean;
|
|
84
92
|
readonly REGISTRY: Record<string, string>;
|
|
85
93
|
readonly PATTERN: TPattern;
|
|
86
|
-
readonly
|
|
87
|
-
readonly RELATIONS:
|
|
94
|
+
readonly APPLY_RELATIONS: TRelationOptions[];
|
|
95
|
+
readonly RELATIONS: TRelationOptions[];
|
|
88
96
|
readonly RELATIONS_TRASHED: boolean;
|
|
89
97
|
readonly RELATIONS_EXISTS: boolean;
|
|
90
98
|
readonly TIMESTAMP: boolean;
|
|
@@ -101,6 +109,7 @@ declare const STATE_MODEL: {
|
|
|
101
109
|
} | null;
|
|
102
110
|
readonly TABLE_LOGGER: string;
|
|
103
111
|
readonly TABLE_AUDIT: string;
|
|
112
|
+
readonly TABLE_JOB: string;
|
|
104
113
|
readonly VALIDATE_SCHEMA: boolean;
|
|
105
114
|
readonly VALIDATE_SCHEMA_DEFINED: TValidateSchema | null;
|
|
106
115
|
readonly FUNCTION_RELATION: boolean;
|
|
@@ -145,7 +154,7 @@ declare const STATE_MODEL: {
|
|
|
145
154
|
readonly EXCEPTS: string[];
|
|
146
155
|
readonly FROM: string[];
|
|
147
156
|
readonly JOIN: string[];
|
|
148
|
-
readonly WHERE:
|
|
157
|
+
readonly WHERE: TStateWhereCondition[];
|
|
149
158
|
readonly GROUP_BY: string[];
|
|
150
159
|
readonly ORDER_BY: string[];
|
|
151
160
|
readonly LIMIT: number | null;
|
|
@@ -155,14 +164,18 @@ declare const STATE_MODEL: {
|
|
|
155
164
|
readonly HIDDEN: string[];
|
|
156
165
|
readonly DEBUG: boolean;
|
|
157
166
|
readonly CTE: string[];
|
|
158
|
-
readonly PAGE: number;
|
|
167
|
+
readonly PAGE: number | null;
|
|
159
168
|
readonly AFTER_SAVE: number;
|
|
160
169
|
readonly HOOKS: Function[];
|
|
161
170
|
readonly ALIAS: string | null;
|
|
162
171
|
readonly RAW_ALIAS: string | null;
|
|
163
172
|
readonly UNION: string[];
|
|
164
173
|
readonly UNION_ALL: string[];
|
|
165
|
-
readonly ROW_LEVEL_LOCK:
|
|
174
|
+
readonly ROW_LEVEL_LOCK: {
|
|
175
|
+
readonly mode: "FOR_UPDATE" | "FOR_SHARE" | null;
|
|
176
|
+
readonly skipLocked: boolean | null;
|
|
177
|
+
readonly nowait: boolean | null;
|
|
178
|
+
};
|
|
166
179
|
};
|
|
167
180
|
type State = typeof STATE_MODEL & typeof STATE_DB & typeof STATE_DEFAULT;
|
|
168
181
|
declare class StateManager {
|
|
@@ -25,14 +25,18 @@ const STATE_DEFAULT = {
|
|
|
25
25
|
HIDDEN: [],
|
|
26
26
|
DEBUG: false,
|
|
27
27
|
CTE: [],
|
|
28
|
-
PAGE:
|
|
28
|
+
PAGE: null,
|
|
29
29
|
AFTER_SAVE: 100,
|
|
30
30
|
HOOKS: [],
|
|
31
31
|
ALIAS: null,
|
|
32
32
|
RAW_ALIAS: null,
|
|
33
33
|
UNION: [],
|
|
34
34
|
UNION_ALL: [],
|
|
35
|
-
ROW_LEVEL_LOCK:
|
|
35
|
+
ROW_LEVEL_LOCK: {
|
|
36
|
+
mode: null,
|
|
37
|
+
skipLocked: false,
|
|
38
|
+
nowait: false
|
|
39
|
+
}
|
|
36
40
|
};
|
|
37
41
|
const STATE_DB = {
|
|
38
42
|
...STATE_DEFAULT,
|
|
@@ -49,7 +53,7 @@ const STATE_MODEL = {
|
|
|
49
53
|
SOFT_DELETE_RELATIONS: false,
|
|
50
54
|
REGISTRY: {},
|
|
51
55
|
PATTERN: 'default',
|
|
52
|
-
|
|
56
|
+
APPLY_RELATIONS: [],
|
|
53
57
|
RELATIONS: [],
|
|
54
58
|
RELATIONS_TRASHED: false,
|
|
55
59
|
RELATIONS_EXISTS: false,
|
|
@@ -60,8 +64,9 @@ const STATE_MODEL = {
|
|
|
60
64
|
},
|
|
61
65
|
LOGGER: false,
|
|
62
66
|
LOGGER_OPTIONS: null,
|
|
63
|
-
TABLE_LOGGER: '
|
|
64
|
-
TABLE_AUDIT: '
|
|
67
|
+
TABLE_LOGGER: 'tspace_loggers',
|
|
68
|
+
TABLE_AUDIT: 'tspace_audits',
|
|
69
|
+
TABLE_JOB: 'tspace_jobs',
|
|
65
70
|
VALIDATE_SCHEMA: false,
|
|
66
71
|
VALIDATE_SCHEMA_DEFINED: null,
|
|
67
72
|
FUNCTION_RELATION: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateManager.js","sourceRoot":"","sources":["../../../src/lib/core/StateManager.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"StateManager.js","sourceRoot":"","sources":["../../../src/lib/core/StateManager.ts"],"names":[],"mappings":";;;AAUA,MAAM,aAAa,GAAG;IACpB,WAAW,EAAE,IAAc;IAC3B,IAAI,EAAE,KAAgB;IACtB,QAAQ,EAAE,KAAgB;IAC1B,IAAI,EAAE,IAAoB;IAC1B,MAAM,EAAE,KAAuB;IAC/B,MAAM,EAAE,IAAuB;IAC/B,MAAM,EAAE,IAAuD;IAC/D,MAAM,EAAE,EAAc;IACtB,UAAU,EAAE,EAAc;IAC1B,IAAI,EAAE,EAAc;IACpB,OAAO,EAAE,EAAc;IACvB,IAAI,EAAE,EAAc;IACpB,IAAI,EAAE,EAAc;IACpB,KAAK,EAAE,EAA4B;IACnC,QAAQ,EAAE,EAAc;IACxB,QAAQ,EAAE,EAAc;IACxB,KAAK,EAAE,IAAqB;IAC5B,MAAM,EAAE,IAAqB;IAC7B,MAAM,EAAE,IAAqB;IAC7B,UAAU,EAAE,IAAqB;IACjC,MAAM,EAAE,EAAc;IACtB,KAAK,EAAE,KAAgB;IACvB,GAAG,EAAE,EAAc;IACnB,IAAI,EAAE,IAAqB;IAC3B,UAAU,EAAE,GAAa;IACzB,KAAK,EAAE,EAAgB;IACvB,KAAK,EAAE,IAAqB;IAC5B,SAAS,EAAE,IAAqB;IAChC,KAAK,EAAE,EAAc;IACrB,SAAS,EAAE,EAAc;IACzB,cAAc,EAAG;QACf,IAAI,EAAG,IAAyC;QAChD,UAAU,EAAG,KAAuB;QACpC,MAAM,EAAG,KAAuB;KACjC;CACO,CAAA;AAEV,MAAM,QAAQ,GAAG;IACf,GAAG,aAAa;CACR,CAAA;AAEV,MAAM,WAAW,GAAG;IAChB,GAAG,aAAa;IAChB,KAAK,EAAG,IAAqB;IAC7B,cAAc,EAAG,IAAiC;IAClD,UAAU,EAAE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AAI,CAAC,CAAA;QAC1C,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAC,IAAI,CAAC,CAAA;QACxC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAC,KAAK,CAAC,CAAA;IAC7C,CAAC;IAEO,YAAY,CAAC,YAA+B,IAAI,EAAG,UAAmB,OAAO;QAEjF,IAAG,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,CAAA;QAC9B,CAAC;QAED,IAAG,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;QAEtC,OAAM;IACV,CAAC;CACJ;AAEQ,oCAAY;AACrB,kBAAe,YAAY,CAAA"}
|
|
@@ -1,38 +1,10 @@
|
|
|
1
1
|
import { Blueprint } from "./Blueprint";
|
|
2
2
|
import { Model } from "./Model";
|
|
3
3
|
import { Repository } from "./Repository";
|
|
4
|
-
import type { TDeepExpand,
|
|
4
|
+
import type { TDeepExpand, TResultResolved, TFreezeStringQuery, TIsEnum, TOperatorQuery, TPagination, TRawStringQuery, TRelationKeys, TRelationResults, TSelectionMerger, TDeepOmit, TConflictKeys } from "../types";
|
|
5
5
|
import type { TColumnsDecorator, TRelationsDecorator } from "../types/decorator";
|
|
6
|
-
import type { TRepositoryCreate, TRepositoryCreateMultiple, TRepositoryCreateOrThings, TRepositoryDelete, TRepositoryExcept, TRepositoryGroupBy, TRepositoryOrderBy, TRepositoryRelation, TRepositoryRequest, TRepositorySelect, TRepositoryUpdate, TRepositoryUpdateMultiple, TRepositoryWhere } from "../types/repository";
|
|
7
|
-
|
|
8
|
-
* The 'TSchemaStrict' type is used to specify the type of the schema.
|
|
9
|
-
*
|
|
10
|
-
* @param {type} T typeof the schema
|
|
11
|
-
* @param {type} S override type in the schema
|
|
12
|
-
* @example
|
|
13
|
-
* import { Blueprint, TSchema, Model, Schema } from 'tspace-mysql';
|
|
14
|
-
* const schemaUser = {
|
|
15
|
-
* id :new Blueprint().int().notNull().primary().autoIncrement(),
|
|
16
|
-
* uuid :new Blueprint().varchar(50).null(),
|
|
17
|
-
* email :new Blueprint().varchar(50).null(),
|
|
18
|
-
* name :new Blueprint().varchar(255).null(),
|
|
19
|
-
* username : new Blueprint().varchar(255).null(),
|
|
20
|
-
* password : new Blueprint().varchar(255).null(),
|
|
21
|
-
* createdAt :new Blueprint().timestamp().null(),
|
|
22
|
-
* updatedAt :new Blueprint().timestamp().null()
|
|
23
|
-
* }
|
|
24
|
-
*
|
|
25
|
-
* type TSchemaUser = TSchemaStrict<typeof schemaUser , {
|
|
26
|
-
* id : number,
|
|
27
|
-
* uuid : string,
|
|
28
|
-
* ........
|
|
29
|
-
* }>
|
|
30
|
-
*
|
|
31
|
-
* class User<TSchemaUser> {}
|
|
32
|
-
*/
|
|
33
|
-
export type TSchemaStrict<T, S = {}> = {
|
|
34
|
-
[K in keyof T]: K extends keyof S ? S[K] : T[K] extends Blueprint<infer U> ? U : any;
|
|
35
|
-
};
|
|
6
|
+
import type { TRepositoryCreate, TRepositoryCreateMultiple, TRepositoryCreateOrThings, TRepositoryDelete, TRepositoryExcept, TRepositoryExtendType, TRepositoryGroupBy, TRepositoryOrderBy, TRepositoryPrimitiveExtendType, TRepositoryRelation, TRepositoryRequest, TRepositorySelect, TRepositoryUpdate, TRepositoryUpdateMultiple, TRepositoryWhere } from "../types/repository";
|
|
7
|
+
import { z } from "zod";
|
|
36
8
|
/**
|
|
37
9
|
* The 'TSchema' type is used to specify the type of the schema.
|
|
38
10
|
*
|
|
@@ -63,8 +35,6 @@ export type TSchemaStrict<T, S = {}> = {
|
|
|
63
35
|
*/
|
|
64
36
|
export type TSchema<T, S = {}> = {
|
|
65
37
|
[K in keyof T]: K extends keyof S ? S[K] : T[K] extends Blueprint<infer U> ? U : any;
|
|
66
|
-
} & {
|
|
67
|
-
[key: string]: any;
|
|
68
38
|
};
|
|
69
39
|
/**
|
|
70
40
|
* The 'TRelation' type is used to specify the type of the relation.
|
|
@@ -156,37 +126,95 @@ export type TSchemaKeyOf<M extends Model, T = TSchemaModel<M>> = keyof {
|
|
|
156
126
|
[K in keyof T as string extends K ? never : K]: T[K];
|
|
157
127
|
};
|
|
158
128
|
export declare namespace T {
|
|
159
|
-
type Schema<T, S = {}> = TSchema<T, S>;
|
|
160
|
-
type SchemaStrict<T, S = {}> = TSchemaStrict<T, S>;
|
|
129
|
+
type Schema<T, S = {}> = T extends Model ? TSchemaModel<T> : TSchema<T, S>;
|
|
161
130
|
type Relation<R> = TRelation<R>;
|
|
162
131
|
type SchemaModel<M extends Model> = keyof TColumnsDecorator<M> extends never ? TDeepExpand<TSchemaModel<M>> : TDeepExpand<TColumnsDecorator<M>>;
|
|
163
132
|
type RelationModel<M extends Model> = keyof TColumnsDecorator<M> extends never ? TDeepExpand<TRelationModel<M>> : TDeepExpand<TRelationsDecorator<M>>;
|
|
164
133
|
type Repository<M extends Model> = ReturnType<typeof Repository<M>>;
|
|
165
|
-
type
|
|
166
|
-
type ResultFiltered<M extends Model, K = {}, S = undefined, // selected by columns
|
|
134
|
+
type ResultFiltered<M extends Model, S = undefined, // selected by columns
|
|
167
135
|
SR = undefined, // selected by relations
|
|
168
|
-
E = undefined
|
|
136
|
+
E = undefined, // excepted by omit columns
|
|
137
|
+
SRS = undefined, // selected by raw select
|
|
138
|
+
G = {}> = ([
|
|
169
139
|
S,
|
|
170
140
|
SR
|
|
171
|
-
] extends [undefined, undefined] ? T.Columns<M> :
|
|
141
|
+
] extends [undefined, undefined] ? SRS extends undefined ? E extends undefined ? T.Columns<M> & TRepositoryPrimitiveExtendType<G> : T.Result<M> & TRepositoryPrimitiveExtendType<G> : E extends undefined ? T.Columns<M> & {
|
|
142
|
+
[K in keyof SRS]: any;
|
|
143
|
+
} & TRepositoryPrimitiveExtendType<G> : T.Result<M> & {
|
|
144
|
+
[K in keyof SRS]: any;
|
|
145
|
+
} & TRepositoryPrimitiveExtendType<G> : TDeepExpand<TSelectionMerger<SRS extends undefined ? T.Result<M> : T.Result<M> & {
|
|
146
|
+
[K in keyof SRS]: any;
|
|
147
|
+
}, S extends undefined ? SRS extends undefined ? {
|
|
172
148
|
[K in keyof T.Columns<M>]: true;
|
|
173
|
-
} :
|
|
174
|
-
[K in keyof
|
|
175
|
-
}
|
|
176
|
-
|
|
149
|
+
} : {
|
|
150
|
+
[K in keyof T.Columns<M>]: true;
|
|
151
|
+
} & {
|
|
152
|
+
[K in keyof SRS]: true;
|
|
153
|
+
} : SRS extends undefined ? S : S & {
|
|
154
|
+
[K in keyof SRS]: true;
|
|
155
|
+
}, SR>> & TRepositoryPrimitiveExtendType<G>) extends infer $Resolved ? S extends undefined ? E extends undefined ? TDeepExpand<$Resolved> : TDeepExpand<TDeepOmit<$Resolved, E>> : TDeepExpand<$Resolved> : never;
|
|
156
|
+
type PaginateResultFiltered<M extends Model, K = {}, S = undefined, SR = undefined, E = undefined, SRS = undefined> = TDeepExpand<TPagination<ResultFiltered<M, K, S, SR, E, SRS>>>;
|
|
157
|
+
type Result<M extends Model, K = {}> = TDeepExpand<TResultResolved<M> & K> & {
|
|
158
|
+
[customKey: string]: unknown;
|
|
159
|
+
};
|
|
177
160
|
type PaginateResult<M extends Model, K = {}> = TDeepExpand<TPagination<Result<M, K>>>;
|
|
178
|
-
type InsertResult<M extends Model
|
|
179
|
-
type InsertManyResult<M extends Model
|
|
180
|
-
type InsertNotExistsResult<M extends Model
|
|
181
|
-
type UpdateResult<M extends Model
|
|
182
|
-
type UpdateManyResult<M extends Model
|
|
161
|
+
type InsertResult<M extends Model> = TDeepExpand<TResultResolved<M>>;
|
|
162
|
+
type InsertManyResult<M extends Model> = TDeepExpand<TResultResolved<M>>[];
|
|
163
|
+
type InsertNotExistsResult<M extends Model> = TDeepExpand<TResultResolved<M>> | null;
|
|
164
|
+
type UpdateResult<M extends Model> = TDeepExpand<TResultResolved<M>> | null;
|
|
165
|
+
type UpdateManyResult<M extends Model> = TDeepExpand<TResultResolved<M>>[];
|
|
183
166
|
type DeleteResult = boolean;
|
|
167
|
+
type InsertInput<K, C> = {
|
|
168
|
+
[P in Exclude<K & keyof C, "id" | "_id" | "uuid"> as null extends C[P] ? never : P]: C[P] extends Date ? any : C[P] extends Record<string, unknown> ? string : C[P];
|
|
169
|
+
} & {
|
|
170
|
+
[P in Exclude<K & keyof C, "id" | "_id" | "uuid"> as null extends C[P] ? P : never]?: C[P] extends Date ? any : C[P] extends Record<string, unknown> ? string : C[P];
|
|
171
|
+
} & {
|
|
172
|
+
[P in Extract<K & keyof C, "id" | "_id" | "uuid">]?: C[P] extends Date ? any : C[P] extends Record<string, unknown> ? string : C[P];
|
|
173
|
+
};
|
|
174
|
+
type UpdateInput<K, C> = {
|
|
175
|
+
[P in Exclude<K & keyof C, "id" | "_id">]: {
|
|
176
|
+
[Q in P]-?: Q extends "uuid" ? string : C[Q] extends Date ? any : C[Q] extends Record<string, unknown> ? string : C[Q];
|
|
177
|
+
} & {
|
|
178
|
+
[Q in Exclude<K & keyof C, "id" | "_id" | P>]?: Q extends "uuid" ? string : C[Q] extends Date ? any : C[Q] extends Record<string, unknown> ? string : C[Q];
|
|
179
|
+
};
|
|
180
|
+
}[Exclude<K & keyof C, "id" | "_id">];
|
|
181
|
+
type NoConflict<R extends readonly PropertyKey[], O extends readonly PropertyKey[]> = TConflictKeys<R, O> extends never ? {} : {
|
|
182
|
+
ERROR_DUPLICATE_KEYS: TConflictKeys<R, O>;
|
|
183
|
+
};
|
|
184
|
+
type ZodShapeCreate<M extends Model, O extends T.ColumnKeys<M, {
|
|
185
|
+
OnlyColumn: true;
|
|
186
|
+
}>[] = [], Opt extends T.ColumnKeys<M, {
|
|
187
|
+
OnlyColumn: true;
|
|
188
|
+
}>[] = []> = {
|
|
189
|
+
[K in Extract<T.ColumnKeys<M, {
|
|
190
|
+
OnlyColumn: true;
|
|
191
|
+
}>, keyof Columns<M>> as K extends O[number] ? K extends Opt[number] ? K : never : K]: K extends Opt[number] ? z.ZodOptional<BlueprintToZod<Columns<M>[K]>> : BlueprintToZod<Columns<M>[K]>;
|
|
192
|
+
};
|
|
193
|
+
type ZodShapeUpdate<M extends Model, R extends T.ColumnKeys<M, {
|
|
194
|
+
OnlyColumn: true;
|
|
195
|
+
}>[] = [], O extends T.ColumnKeys<M, {
|
|
196
|
+
OnlyColumn: true;
|
|
197
|
+
}>[] = []> = {
|
|
198
|
+
[K in Extract<T.ColumnKeys<M, {
|
|
199
|
+
OnlyColumn: true;
|
|
200
|
+
}>, keyof Columns<M>> as K extends O[number] ? never : K]: K extends R[number] ? BlueprintToZod<Columns<M>[K]> : z.ZodOptional<BlueprintToZod<Columns<M>[K]>>;
|
|
201
|
+
};
|
|
202
|
+
type BlueprintToZod<T> = T extends number ? z.ZodNumber : T extends string ? z.ZodString : T extends Date ? z.ZodDate : T extends null ? z.ZodNull : z.ZodTypeAny;
|
|
203
|
+
type ColumnBlueprints<M extends Model> = {
|
|
204
|
+
[K in keyof Columns<M, {
|
|
205
|
+
InputQuery: true;
|
|
206
|
+
}>]: Blueprint<Columns<M, {
|
|
207
|
+
InputQuery: true;
|
|
208
|
+
}>[K]>;
|
|
209
|
+
};
|
|
184
210
|
type Columns<M extends Model, Options extends {
|
|
185
211
|
InputQuery?: boolean;
|
|
186
212
|
} = {}> = TDeepExpand<keyof TColumnsDecorator<M> extends never ? {
|
|
187
213
|
[K in keyof TSchemaModel<M>]: Options['InputQuery'] extends true ? TSchemaModel<M>[K] | TOperatorQuery | TRawStringQuery | TFreezeStringQuery : TSchemaModel<M>[K];
|
|
188
214
|
} : TColumnsDecorator<M, Options>>;
|
|
189
|
-
type ColumnKeys<M extends Model
|
|
215
|
+
type ColumnKeys<M extends Model, Options extends {
|
|
216
|
+
OnlyColumn?: boolean;
|
|
217
|
+
} = {}> = (keyof TColumnsDecorator<M> extends never ? TSchemaKeyOf<M> : keyof TColumnsDecorator<M>) | (Options["OnlyColumn"] extends true ? never : `${string}.${string}` | TRawStringQuery | TFreezeStringQuery);
|
|
190
218
|
type ColumnEnumMap<M extends Model> = keyof TColumnsDecorator<M> extends never ? {
|
|
191
219
|
[K in keyof TSchemaModel<M> as TIsEnum<NonNullable<TSchemaModel<M>[K]>> extends true ? K : never]: TSchemaModel<M>[K];
|
|
192
220
|
} : {
|
|
@@ -204,15 +232,16 @@ export declare namespace T {
|
|
|
204
232
|
}>;
|
|
205
233
|
type WhereOptions<M extends Model> = TRepositoryWhere<TSchemaModel<M>, TRelationModel<M>, M>;
|
|
206
234
|
type SelectOptions<M extends Model> = TRepositorySelect<TSchemaModel<M>, TRelationModel<M>, M>;
|
|
207
|
-
type ExceptOptions<M extends Model> = TRepositoryExcept<TSchemaModel<M>, M>;
|
|
235
|
+
type ExceptOptions<M extends Model> = TRepositoryExcept<TSchemaModel<M>, TRelationModel<M>, M>;
|
|
208
236
|
type OrderByOptions<M extends Model> = TRepositoryOrderBy<TSchemaModel<M>, TRelationModel<M>, M>;
|
|
209
237
|
type GroupByOptions<M extends Model> = TRepositoryGroupBy<TSchemaModel<M>, TRelationModel<M>, M>;
|
|
210
238
|
type RelationOptions<M extends Model> = TRepositoryRelation<TRelationModel<M>, M>;
|
|
211
|
-
type RepositoryOptions<M extends Model, S = undefined, SR = undefined, E = undefined> = TRepositoryRequest<TSchemaModel<M>, TRelationModel<M>, M, S, SR, E>;
|
|
212
|
-
type RepositoryCreate<M extends Model> = TRepositoryCreate<M>;
|
|
213
|
-
type RepositoryCreateMultiple<M extends Model> = TRepositoryCreateMultiple<M>;
|
|
214
|
-
type RepositoryUpdate<M extends Model> = TRepositoryUpdate<M>;
|
|
215
|
-
type RepositoryUpdateMultiple<M extends Model> = TRepositoryUpdateMultiple<M>;
|
|
216
|
-
type RepositoryCreateOrThings<M extends Model> = TRepositoryCreateOrThings<M>;
|
|
239
|
+
type RepositoryOptions<M extends Model, S = undefined, SR = undefined, E = undefined, SRS = undefined, G = undefined> = TRepositoryRequest<TSchemaModel<M>, TRelationModel<M>, M, S, SR, E, SRS, G>;
|
|
240
|
+
type RepositoryCreate<M extends Model, NR extends boolean | undefined = false> = TRepositoryCreate<M, NR>;
|
|
241
|
+
type RepositoryCreateMultiple<M extends Model, NR extends boolean | undefined = false> = TRepositoryCreateMultiple<M, NR>;
|
|
242
|
+
type RepositoryUpdate<M extends Model, NR extends boolean | undefined = false> = TRepositoryUpdate<M, NR>;
|
|
243
|
+
type RepositoryUpdateMultiple<M extends Model, NR extends boolean | undefined = false> = TRepositoryUpdateMultiple<M, NR>;
|
|
244
|
+
type RepositoryCreateOrThings<M extends Model, NR extends boolean | undefined = false> = TRepositoryCreateOrThings<M, NR>;
|
|
217
245
|
type RepositoryDelete<M extends Model> = TRepositoryDelete<M>;
|
|
246
|
+
type RepositoryGenericTypeOptions = TRepositoryExtendType;
|
|
218
247
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UtilityTypes.js","sourceRoot":"","sources":["../../../src/lib/core/UtilityTypes.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"UtilityTypes.js","sourceRoot":"","sources":["../../../src/lib/core/UtilityTypes.ts"],"names":[],"mappings":";;AAmeC,CAAC"}
|
package/dist/lib/core/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import Pool from "./Pool";
|
|
|
6
6
|
import sql from "./SqlLike";
|
|
7
7
|
import Meta from "./Meta";
|
|
8
8
|
import View from './View';
|
|
9
|
+
import Queue from "./Queue";
|
|
9
10
|
export { View };
|
|
10
11
|
export { Meta };
|
|
11
12
|
export { sql };
|
|
@@ -13,6 +14,7 @@ export { DB };
|
|
|
13
14
|
export { Model };
|
|
14
15
|
export { Blueprint };
|
|
15
16
|
export { Pool };
|
|
17
|
+
export { Queue };
|
|
16
18
|
export * from "./Decorator";
|
|
17
19
|
export * from "./Schema";
|
|
18
20
|
export * from "./UtilityTypes";
|
|
@@ -20,11 +22,13 @@ export * from "./Repository";
|
|
|
20
22
|
export * from "./Operator";
|
|
21
23
|
export * from "./Nest";
|
|
22
24
|
export * from './StoredProcedure';
|
|
25
|
+
export * from "./Queue";
|
|
23
26
|
declare const _default: {
|
|
24
27
|
DB: typeof DB;
|
|
25
28
|
Model: typeof Model;
|
|
26
29
|
Schema: typeof Schema;
|
|
27
30
|
Blueprint: typeof Blueprint;
|
|
28
31
|
Pool: import("./Pool").PoolConnection;
|
|
32
|
+
Queue: typeof Queue;
|
|
29
33
|
};
|
|
30
34
|
export default _default;
|
package/dist/lib/core/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.Pool = exports.Blueprint = exports.Model = exports.DB = exports.sql = exports.Meta = exports.View = void 0;
|
|
20
|
+
exports.Queue = exports.Pool = exports.Blueprint = exports.Model = exports.DB = exports.sql = exports.Meta = exports.View = void 0;
|
|
21
21
|
const DB_1 = __importDefault(require("./DB"));
|
|
22
22
|
exports.DB = DB_1.default;
|
|
23
23
|
const Model_1 = __importDefault(require("./Model"));
|
|
@@ -33,6 +33,8 @@ const Meta_1 = __importDefault(require("./Meta"));
|
|
|
33
33
|
exports.Meta = Meta_1.default;
|
|
34
34
|
const View_1 = __importDefault(require("./View"));
|
|
35
35
|
exports.View = View_1.default;
|
|
36
|
+
const Queue_1 = __importDefault(require("./Queue"));
|
|
37
|
+
exports.Queue = Queue_1.default;
|
|
36
38
|
__exportStar(require("./Decorator"), exports);
|
|
37
39
|
__exportStar(require("./Schema"), exports);
|
|
38
40
|
__exportStar(require("./UtilityTypes"), exports);
|
|
@@ -40,11 +42,13 @@ __exportStar(require("./Repository"), exports);
|
|
|
40
42
|
__exportStar(require("./Operator"), exports);
|
|
41
43
|
__exportStar(require("./Nest"), exports);
|
|
42
44
|
__exportStar(require("./StoredProcedure"), exports);
|
|
45
|
+
__exportStar(require("./Queue"), exports);
|
|
43
46
|
exports.default = {
|
|
44
47
|
DB: DB_1.default,
|
|
45
48
|
Model: Model_1.default,
|
|
46
49
|
Schema: Schema_1.default,
|
|
47
50
|
Blueprint: Blueprint_1.default,
|
|
48
|
-
Pool: Pool_1.default
|
|
51
|
+
Pool: Pool_1.default,
|
|
52
|
+
Queue: Queue_1.default
|
|
49
53
|
};
|
|
50
54
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,8CAA8B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,8CAA8B;AAarB,aAbF,YAAE,CAaE;AAZX,oDAAiC;AAaxB,gBAbF,eAAK,CAaE;AAZd,sDAAkC;AAClC,4DAAqC;AAY5B,oBAZF,mBAAS,CAYE;AAXlB,kDAAgC;AAYvB,eAZF,cAAI,CAYE;AAXb,wDAAmC;AAO1B,cAPF,iBAAG,CAOE;AANZ,kDAAgC;AAKvB,eALF,cAAI,CAKE;AAJb,kDAAgC;AAGvB,eAHF,cAAI,CAGE;AAFb,oDAAiC;AASxB,gBATF,eAAK,CASE;AACd,8CAA4B;AAC5B,2CAAyB;AACzB,iDAA+B;AAC/B,+CAA6B;AAC7B,6CAA2B;AAC3B,yCAAuB;AACvB,oDAAiC;AACjC,0CAAuB;AAEvB,kBAAe;IACb,EAAE,EAAF,YAAE;IACF,KAAK,EAAL,eAAK;IACL,MAAM,EAAN,gBAAM;IACN,SAAS,EAAT,mBAAS;IACT,IAAI,EAAJ,cAAI;IACJ,KAAK,EAAL,eAAK;CACN,CAAC"}
|
|
@@ -20,7 +20,7 @@ export type TRelationOptionsDecorator<K = any> = {
|
|
|
20
20
|
export type TColumnsDecorator<T, Options extends {
|
|
21
21
|
InputQuery?: boolean;
|
|
22
22
|
} = {}> = {
|
|
23
|
-
[K in keyof T as T[K] extends string | number | null | boolean | Date ? K : never]: Options['InputQuery'] extends true ? T[K] | TOperatorQuery | TRawStringQuery | TFreezeStringQuery : T[K];
|
|
23
|
+
[K in keyof T as T[K] extends string | number | null | boolean | Date | Record<string, unknown> ? K : never]: Options['InputQuery'] extends true ? T[K] | TOperatorQuery | TRawStringQuery | TFreezeStringQuery : T[K];
|
|
24
24
|
};
|
|
25
25
|
export type TRelationsDecorator<T> = Pick<T, {
|
|
26
26
|
[K in keyof T]: T[K] extends Model | Model[] ? K : never;
|
|
@@ -6,6 +6,24 @@ import { QueryBuilder } from "../core/Driver";
|
|
|
6
6
|
import { TResult } from "../core";
|
|
7
7
|
import { TResultDecorator } from "./decorator";
|
|
8
8
|
export type TCache = Cache;
|
|
9
|
+
export type TCacheModel = {
|
|
10
|
+
provider: () => string;
|
|
11
|
+
driver: (driver: "db" | "memory" | "redis") => any;
|
|
12
|
+
all: () => Promise<any[]>;
|
|
13
|
+
clear: () => Promise<void>;
|
|
14
|
+
get: (key: string, options?: {
|
|
15
|
+
namespace?: boolean;
|
|
16
|
+
}) => Promise<any>;
|
|
17
|
+
exists: (key: string, options?: {
|
|
18
|
+
namespace?: boolean;
|
|
19
|
+
}) => Promise<boolean>;
|
|
20
|
+
set: (key: string, value: unknown, ms: number, options?: {
|
|
21
|
+
namespace?: boolean;
|
|
22
|
+
}) => Promise<void>;
|
|
23
|
+
delete: (key: string, options?: {
|
|
24
|
+
namespace?: boolean;
|
|
25
|
+
}) => Promise<void>;
|
|
26
|
+
};
|
|
9
27
|
export type TConstant = typeof CONSTANTS;
|
|
10
28
|
export type TRelationOptions<K = any> = {
|
|
11
29
|
name: K;
|
|
@@ -17,7 +35,7 @@ export type TRelationOptions<K = any> = {
|
|
|
17
35
|
pivot?: string;
|
|
18
36
|
query?: any;
|
|
19
37
|
queryPivot?: any;
|
|
20
|
-
relation?:
|
|
38
|
+
relation?: string;
|
|
21
39
|
exists?: boolean;
|
|
22
40
|
notExists?: boolean;
|
|
23
41
|
all?: boolean;
|
|
@@ -58,10 +76,12 @@ export type TPagination<K = any> = {
|
|
|
58
76
|
last_page: number;
|
|
59
77
|
next_page: number;
|
|
60
78
|
prev_page: number;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
79
|
+
page: {
|
|
80
|
+
prev: number;
|
|
81
|
+
next: number;
|
|
82
|
+
current: number;
|
|
83
|
+
last: number;
|
|
84
|
+
};
|
|
65
85
|
};
|
|
66
86
|
data: K[];
|
|
67
87
|
};
|
|
@@ -113,7 +133,6 @@ export type TPoolCallback = {
|
|
|
113
133
|
release: () => void;
|
|
114
134
|
};
|
|
115
135
|
export type TConnectionTransaction = {
|
|
116
|
-
on: (event: TPoolEvent, data: any) => void;
|
|
117
136
|
query: (sql: string) => Promise<any[]>;
|
|
118
137
|
/**
|
|
119
138
|
* The 'startTransaction' method is used when need to started the transaction
|
|
@@ -135,6 +154,11 @@ export type TConnectionTransaction = {
|
|
|
135
154
|
* @returns {Promise<void>}
|
|
136
155
|
*/
|
|
137
156
|
end: () => Promise<void>;
|
|
157
|
+
/**
|
|
158
|
+
* The 'release' method is used to release connection
|
|
159
|
+
* @returns {Promise<void>}
|
|
160
|
+
*/
|
|
161
|
+
release: () => Promise<void>;
|
|
138
162
|
};
|
|
139
163
|
export type TConnection = {
|
|
140
164
|
on: (event: TPoolEvent, data: any) => void;
|
|
@@ -144,6 +168,7 @@ export type TConnection = {
|
|
|
144
168
|
commit: () => Promise<void>;
|
|
145
169
|
rollback: () => Promise<void>;
|
|
146
170
|
end: () => Promise<void>;
|
|
171
|
+
release: () => Promise<void>;
|
|
147
172
|
};
|
|
148
173
|
export type TPoolConnected = {
|
|
149
174
|
database: () => string;
|
|
@@ -291,7 +316,7 @@ export type TLiteralStringKeys<T> = {
|
|
|
291
316
|
[K in keyof T]: T[K] extends string ? (string extends T[K] ? never : K) : never;
|
|
292
317
|
}[keyof T];
|
|
293
318
|
export type TLiteralEnumKeys<T> = TLiteralStringKeys<TRemoveIndexSignature<T>>;
|
|
294
|
-
export type TDriver = 'pg' | 'postgres' | 'mysql' | 'mysql2' | 'mariadb' | 'mssql' | '
|
|
319
|
+
export type TDriver = 'pg' | 'postgres' | 'mysql' | 'mysql2' | 'mariadb' | 'mssql' | 'sqlite' | 'mongodb';
|
|
295
320
|
export type TPoolCusterOptions = {
|
|
296
321
|
writer: {
|
|
297
322
|
host: string;
|
|
@@ -330,23 +355,45 @@ export type TIsEnum<T> = string extends T ? false : number extends T ? false : b
|
|
|
330
355
|
T
|
|
331
356
|
] extends [string | number] ? true : false;
|
|
332
357
|
export type TLifecycle = "beforeInsert" | "afterInsert" | "beforeUpdate" | "afterUpdate" | "beforeRemove" | "afterRemove";
|
|
358
|
+
export type TDeepOmit<T, Filter> = T extends infer ObjectType ? {
|
|
359
|
+
[K in keyof ObjectType as K extends keyof Filter ? Filter[K] extends true ? never : K : NonNullable<ObjectType[K]> extends object ? (NonNullable<ObjectType[K]> extends Date ? K : never) : K]: K extends keyof Filter ? Filter[K] extends object ? TDeepOmit<NonNullable<ObjectType[K]>, Filter[K]> : ObjectType[K] : ObjectType[K];
|
|
360
|
+
} : never;
|
|
333
361
|
export type TDeepExpand<T> = T extends Date ? T : T extends Function ? T : T extends Model ? T : T extends (infer U)[] ? TDeepExpand<U>[] : T extends object ? {
|
|
334
362
|
[K in keyof T]: TDeepExpand<T[K]>;
|
|
335
363
|
} : T;
|
|
336
|
-
export type TResultResolved<M extends Model
|
|
337
|
-
export type
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
364
|
+
export type TResultResolved<M extends Model> = (unknown extends TResult<M> ? unknown extends TResultDecorator<M> ? Record<string, any> : {} extends TResultDecorator<M> ? Record<string, any> : TResultDecorator<M> : TResult<M>);
|
|
365
|
+
export type TConflictKeys<R extends readonly PropertyKey[], O extends readonly PropertyKey[]> = Extract<R[number], O[number]>;
|
|
366
|
+
type Normalize<T> = T extends object ? ((T extends {
|
|
367
|
+
select: infer S;
|
|
368
|
+
} ? S : {}) & (T extends {
|
|
369
|
+
relations: infer R;
|
|
370
|
+
} ? R : {}) & (T extends {
|
|
371
|
+
except: infer E;
|
|
372
|
+
} ? {
|
|
373
|
+
_except: E;
|
|
374
|
+
} : {}) & Omit<T, 'select' | 'relations' | 'except'>) : {};
|
|
375
|
+
type IsStrict<T> = T extends true ? false : T extends object ? (T extends {
|
|
376
|
+
select: any;
|
|
377
|
+
} ? true : T extends {
|
|
378
|
+
except: any;
|
|
379
|
+
} ? false : (keyof Omit<T, 'relations' | 'except'> extends never ? false : true)) : false;
|
|
380
|
+
type RemoveUndefined<T> = T extends undefined ? never : T;
|
|
381
|
+
type NonObjectKeys<T> = {
|
|
382
|
+
[K in keyof T]: RemoveUndefined<T[K]> extends Date ? K : RemoveUndefined<T[K]> extends object ? never : K;
|
|
383
|
+
}[keyof T];
|
|
384
|
+
type GetExceptKeys<T> = T extends {
|
|
385
|
+
_except: infer E;
|
|
386
|
+
} ? keyof E : never;
|
|
387
|
+
export type TSelectionMerger<IncomingResult, S1, S2> = IncomingResult extends Date | Function ? IncomingResult : IncomingResult extends (infer U)[] ? TSelectionMerger<U, S1, S2>[] : IncomingResult extends object ? (Normalize<S1> extends infer F1 ? Normalize<S2> extends infer F2 ? (F1 & F2) extends infer Merged ? {
|
|
388
|
+
[K in keyof Omit<Merged, '_except'> & keyof IncomingResult]-?: TSelectionMerger<RemoveUndefined<IncomingResult[K]>, K extends keyof F1 ? F1[K] : unknown, K extends keyof F2 ? F2[K] : unknown>;
|
|
389
|
+
} & ((IsStrict<S1> extends true ? true : IsStrict<S2> extends true ? true : false) extends true ? {} : {
|
|
390
|
+
[K in Exclude<NonObjectKeys<IncomingResult>, GetExceptKeys<F1> | GetExceptKeys<F2>>]-?: IncomingResult[K];
|
|
391
|
+
}) : never : never : never) : IncomingResult;
|
|
392
|
+
export type TStateWhereCondition = {
|
|
393
|
+
column?: string;
|
|
394
|
+
operator?: string;
|
|
395
|
+
value?: any;
|
|
396
|
+
condition?: 'AND' | 'OR';
|
|
397
|
+
nested?: TStateWhereCondition[];
|
|
351
398
|
};
|
|
352
399
|
export {};
|