vona-module-a-orm 5.1.5 → 5.1.6
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/cli/entity/metadata/generate.ts +13 -3
- package/cli/model/metadata/generate.ts +6 -3
- package/cli/model/metadata/magic.ts +6 -1
- package/dist/.metadata/locales.d.ts.map +1 -1
- package/dist/bean/aopMethod.transaction.d.ts.map +1 -1
- package/dist/bean/bean.database.d.ts.map +1 -1
- package/dist/bean/bean.databaseDialectBase.d.ts.map +1 -1
- package/dist/bean/bean.model/bean.model_cache.d.ts.map +1 -1
- package/dist/bean/bean.model/bean.model_crud.d.ts.map +1 -1
- package/dist/bean/bean.model/bean.model_crud_inner.d.ts.map +1 -1
- package/dist/bean/bean.model/bean.model_crud_table.d.ts.map +1 -1
- package/dist/bean/bean.model/bean.model_knex.d.ts.map +1 -1
- package/dist/bean/bean.model/bean.model_meta.d.ts.map +1 -1
- package/dist/bean/bean.model/bean.model_utils.d.ts.map +1 -1
- package/dist/bean/bean.model/bean.model_view.d.ts.map +1 -1
- package/dist/bean/event.clientNameReal.d.ts.map +1 -1
- package/dist/bean/event.columnsClear.d.ts.map +1 -1
- package/dist/bean/queue.doubleDelete.d.ts.map +1 -1
- package/dist/bean/schedule.softDeletionPrune.d.ts.map +1 -1
- package/dist/common/buildWhere.d.ts.map +1 -1
- package/dist/common/utils.d.ts.map +1 -1
- package/dist/extend/schemaBuilder.d.ts.map +1 -1
- package/dist/extend/tableBuilder.d.ts.map +1 -1
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/lib/const.d.ts.map +1 -1
- package/dist/lib/databaseDialect.d.ts.map +1 -1
- package/dist/lib/dto/dtoAggregate.d.ts.map +1 -1
- package/dist/lib/dto/dtoCreate.d.ts.map +1 -1
- package/dist/lib/dto/dtoGet.d.ts.map +1 -1
- package/dist/lib/dto/dtoGroup.d.ts.map +1 -1
- package/dist/lib/dto/dtoListAndCount.d.ts.map +1 -1
- package/dist/lib/dto/dtoMutate.d.ts.map +1 -1
- package/dist/lib/dto/dtoQueryPage.d.ts.map +1 -1
- package/dist/lib/dto/dtoSelectAndCount.d.ts.map +1 -1
- package/dist/lib/dto/dtoUpdate.d.ts.map +1 -1
- package/dist/lib/entity.d.ts.map +1 -1
- package/dist/lib/modelCacheBase.d.ts.map +1 -1
- package/dist/lib/relations.d.ts.map +1 -1
- package/dist/lib/relationsDynamic.d.ts.map +1 -1
- package/dist/lib/relationsMutate.d.ts.map +1 -1
- package/dist/lib/relationsStatic.d.ts.map +1 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/service/columnsCache_.d.ts.map +1 -1
- package/dist/service/database.d.ts.map +1 -1
- package/dist/service/databaseClient_.d.ts.map +1 -1
- package/dist/service/relations_.d.ts.map +1 -1
- package/dist/service/transaction_.d.ts.map +1 -1
- package/dist/types/dto/dtoGet.d.ts.map +1 -1
- package/dist/types/dto/dtoGroup.d.ts.map +1 -1
- package/dist/types/dto/dtoMutate.d.ts.map +1 -1
- package/dist/types/dto/dtoQueryBase.d.ts.map +1 -1
- package/dist/types/dto/dtoSelectAndCount.d.ts.map +1 -1
- package/dist/types/entity.d.ts.map +1 -1
- package/dist/types/model.d.ts +5 -1
- package/dist/types/model.d.ts.map +1 -1
- package/dist/types/modelAggr.d.ts.map +1 -1
- package/dist/types/modelCount.d.ts.map +1 -1
- package/dist/types/modelGeneral.d.ts.map +1 -1
- package/dist/types/modelGroup.d.ts.map +1 -1
- package/dist/types/modelIncrement.d.ts.map +1 -1
- package/dist/types/modelWhere.d.ts.map +1 -1
- package/dist/types/onion/entity.d.ts +2 -2
- package/dist/types/onion/entity.d.ts.map +1 -1
- package/dist/types/onion/model.d.ts.map +1 -1
- package/dist/types/relations.d.ts.map +1 -1
- package/dist/types/relationsAggr.d.ts +1 -1
- package/dist/types/relationsAggr.d.ts.map +1 -1
- package/dist/types/relationsColumns.d.ts.map +1 -1
- package/dist/types/relationsDef.d.ts.map +1 -1
- package/dist/types/relationsDefDynamic.d.ts.map +1 -1
- package/dist/types/relationsDefMutate.d.ts.map +1 -1
- package/dist/types/relationsGroup.d.ts.map +1 -1
- package/dist/types/relationsMutate.d.ts.map +1 -1
- package/dist/types/relationsTables.d.ts.map +1 -1
- package/dist/types/transaction.d.ts.map +1 -1
- package/dist-cli/entity/metadata/generate.js +4 -1
- package/dist-cli/model/metadata/generate.js +4 -2
- package/package.json +1 -1
- package/src/.metadata/locales.ts +6 -1
- package/src/bean/aopMethod.transaction.ts +9 -2
- package/src/bean/bean.database.ts +33 -8
- package/src/bean/bean.databaseDialectBase.ts +42 -9
- package/src/bean/bean.model/bean.model_cache.ts +130 -46
- package/src/bean/bean.model/bean.model_crud.ts +28 -7
- package/src/bean/bean.model/bean.model_crud_inner.ts +17 -4
- package/src/bean/bean.model/bean.model_crud_table.ts +25 -5
- package/src/bean/bean.model/bean.model_knex.ts +18 -5
- package/src/bean/bean.model/bean.model_meta.ts +23 -5
- package/src/bean/bean.model/bean.model_utils.ts +55 -12
- package/src/bean/bean.model/bean.model_view.ts +20 -5
- package/src/bean/event.clientNameReal.ts +4 -1
- package/src/bean/event.columnsClear.ts +4 -1
- package/src/bean/queue.doubleDelete.ts +9 -2
- package/src/bean/schedule.softDeletionPrune.ts +3 -1
- package/src/common/buildWhere.ts +30 -5
- package/src/common/utils.ts +6 -2
- package/src/extend/schemaBuilder.ts +2 -1
- package/src/extend/tableBuilder.ts +32 -19
- package/src/lib/const.ts +3 -1
- package/src/lib/databaseDialect.ts +3 -1
- package/src/lib/dto/dtoAggregate.ts +18 -6
- package/src/lib/dto/dtoCreate.ts +24 -4
- package/src/lib/dto/dtoGet.ts +82 -17
- package/src/lib/dto/dtoGroup.ts +24 -8
- package/src/lib/dto/dtoListAndCount.ts +3 -1
- package/src/lib/dto/dtoMutate.ts +26 -7
- package/src/lib/dto/dtoQueryPage.ts +4 -1
- package/src/lib/dto/dtoSelectAndCount.ts +3 -1
- package/src/lib/dto/dtoUpdate.ts +24 -4
- package/src/lib/entity.ts +10 -4
- package/src/lib/modelCacheBase.ts +9 -3
- package/src/lib/relations.ts +22 -4
- package/src/lib/relationsDynamic.ts +29 -7
- package/src/lib/relationsMutate.ts +28 -5
- package/src/lib/relationsStatic.ts +4 -1
- package/src/lib/utils.ts +11 -2
- package/src/main.ts +10 -2
- package/src/service/columnsCache_.ts +8 -6
- package/src/service/database.ts +34 -10
- package/src/service/databaseClient_.ts +4 -1
- package/src/service/relations_.ts +98 -23
- package/src/service/transaction_.ts +14 -4
- package/src/types/dto/dtoGet.ts +14 -6
- package/src/types/dto/dtoGroup.ts +2 -1
- package/src/types/dto/dtoMutate.ts +102 -20
- package/src/types/dto/dtoQueryBase.ts +5 -1
- package/src/types/dto/dtoSelectAndCount.ts +4 -1
- package/src/types/entity.ts +3 -1
- package/src/types/entityBase.ts +1 -1
- package/src/types/entityBaseInner.ts +4 -4
- package/src/types/entityBaseSimple.ts +1 -1
- package/src/types/model.ts +73 -16
- package/src/types/modelAggr.ts +18 -6
- package/src/types/modelCount.ts +4 -1
- package/src/types/modelGeneral.ts +26 -5
- package/src/types/modelGroup.ts +8 -2
- package/src/types/modelIncrement.ts +4 -1
- package/src/types/modelWhere.ts +12 -3
- package/src/types/onion/entity.ts +2 -2
- package/src/types/onion/model.ts +20 -4
- package/src/types/relations.ts +151 -47
- package/src/types/relationsAggr.ts +35 -11
- package/src/types/relationsColumns.ts +80 -57
- package/src/types/relationsDef.ts +82 -29
- package/src/types/relationsDefDynamic.ts +59 -13
- package/src/types/relationsDefMutate.ts +3 -1
- package/src/types/relationsGroup.ts +32 -10
- package/src/types/relationsMutate.ts +60 -19
- package/src/types/relationsTables.ts +16 -14
- package/src/types/transaction.ts +14 -2
package/src/types/relations.ts
CHANGED
|
@@ -3,8 +3,14 @@ import type { Constructable, OmitNever } from 'vona';
|
|
|
3
3
|
import type { BeanModelMeta } from '../bean/bean.model/bean.model_meta.ts';
|
|
4
4
|
import type { TypeDepthPrev, TypeDepthPrevMax } from './depth.ts';
|
|
5
5
|
import type { IDecoratorModelOptions, IModelClassRecord } from './onion/model.ts';
|
|
6
|
-
import type {
|
|
7
|
-
|
|
6
|
+
import type {
|
|
7
|
+
TypeModelAggrRelationResultAggrs,
|
|
8
|
+
TypeUtilGetAggrsFromRelationAndIncludeWrapper,
|
|
9
|
+
} from './relationsAggr.ts';
|
|
10
|
+
import type {
|
|
11
|
+
TypeModelGroupRelationResultGroups,
|
|
12
|
+
TypeUtilGetGroupsFromRelationAndIncludeWrapper,
|
|
13
|
+
} from './relationsGroup.ts';
|
|
8
14
|
|
|
9
15
|
export const SymbolKeyEntity = Symbol('$entity');
|
|
10
16
|
export const SymbolKeyEntityMeta = Symbol('$entityMeta');
|
|
@@ -30,9 +36,8 @@ export type TypeModelOfModelLike<
|
|
|
30
36
|
? MODEL
|
|
31
37
|
: ModelLike;
|
|
32
38
|
|
|
33
|
-
export type TypeModelClassLike<MODEL extends BeanModelMeta | keyof IModelClassRecord> =
|
|
34
|
-
? (() => Constructable<MODEL>) | Constructable<MODEL>
|
|
35
|
-
: MODEL;
|
|
39
|
+
export type TypeModelClassLike<MODEL extends BeanModelMeta | keyof IModelClassRecord> =
|
|
40
|
+
MODEL extends BeanModelMeta ? (() => Constructable<MODEL>) | Constructable<MODEL> : MODEL;
|
|
36
41
|
|
|
37
42
|
export type TypeModelClassLikeGeneral<MODEL extends BeanModelMeta = BeanModelMeta> =
|
|
38
43
|
| (() => Constructable<MODEL>)
|
|
@@ -45,14 +50,18 @@ export type TypeModelsClassLikeGeneral<MODEL extends BeanModelMeta = BeanModelMe
|
|
|
45
50
|
| TypeModelClassLikeGeneral<MODEL>
|
|
46
51
|
| Array<TypeModelClassLikeGeneral<MODEL>>;
|
|
47
52
|
|
|
48
|
-
export type TypeModelParamsInclude<MODEL extends BeanModelMeta | undefined> =
|
|
53
|
+
export type TypeModelParamsInclude<MODEL extends BeanModelMeta | undefined> =
|
|
54
|
+
TypeModelParamsIncludeByModelOptions<TypeUtilGetModelOptions<MODEL>>;
|
|
49
55
|
|
|
50
|
-
export type TypeModelParamsIncludeByModelOptions<
|
|
51
|
-
ModelOptions extends IDecoratorModelOptions
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
export type TypeModelParamsIncludeByModelOptions<
|
|
57
|
+
ModelOptions extends IDecoratorModelOptions | undefined,
|
|
58
|
+
> = ModelOptions extends IDecoratorModelOptions
|
|
59
|
+
? {
|
|
60
|
+
[relationName in keyof ModelOptions['relations']]?: TypeModelParamsRelationOptions<
|
|
61
|
+
ModelOptions['relations'][relationName]
|
|
62
|
+
>;
|
|
63
|
+
}
|
|
64
|
+
: never;
|
|
56
65
|
|
|
57
66
|
export type TypeModelParamsRelationOptions<Relation> =
|
|
58
67
|
| boolean
|
|
@@ -61,13 +70,21 @@ export type TypeModelParamsRelationOptions<Relation> =
|
|
|
61
70
|
with?: Record<string, unknown>;
|
|
62
71
|
});
|
|
63
72
|
|
|
64
|
-
export type TypeUtilGetRelationType<Relation> = Relation extends { type?: infer TYPE }
|
|
65
|
-
|
|
73
|
+
export type TypeUtilGetRelationType<Relation> = Relation extends { type?: infer TYPE }
|
|
74
|
+
? TYPE
|
|
75
|
+
: undefined;
|
|
76
|
+
export type TypeUtilGetRelationKey<Relation> = Relation extends { key?: infer KEY }
|
|
77
|
+
? KEY
|
|
78
|
+
: undefined;
|
|
66
79
|
export type TypeUtilGetRelationModel<Relation> = Relation extends {
|
|
67
|
-
model?:
|
|
80
|
+
model?:
|
|
81
|
+
| (() => Constructable<infer MODEL extends BeanModelMeta>)
|
|
82
|
+
| Constructable<infer MODEL extends BeanModelMeta>;
|
|
68
83
|
}
|
|
69
84
|
? MODEL
|
|
70
|
-
: Relation extends {
|
|
85
|
+
: Relation extends {
|
|
86
|
+
model?: (() => infer MODEL extends BeanModelMeta) | (infer MODEL extends BeanModelMeta);
|
|
87
|
+
}
|
|
71
88
|
? MODEL
|
|
72
89
|
: Relation extends { model?: () => Constructable<infer MODEL extends BeanModelMeta> }
|
|
73
90
|
? MODEL
|
|
@@ -81,22 +98,46 @@ export type TypeUtilGetRelationModel<Relation> = Relation extends {
|
|
|
81
98
|
? IModelClassRecord[MODELNAME]
|
|
82
99
|
: undefined;
|
|
83
100
|
|
|
84
|
-
export type TypeUtilGetRelationModelOptions<Relation> = TypeUtilGetModelOptions<
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
export type
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
export type
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
101
|
+
export type TypeUtilGetRelationModelOptions<Relation> = TypeUtilGetModelOptions<
|
|
102
|
+
TypeUtilGetRelationModel<Relation>
|
|
103
|
+
>;
|
|
104
|
+
export type TypeUtilGetRelationEntity<Relation> = TypeUtilGetModelEntity<
|
|
105
|
+
TypeUtilGetRelationModel<Relation>
|
|
106
|
+
>;
|
|
107
|
+
export type TypeUtilGetRelationEntityMeta<Relation> = TypeUtilGetModelEntityMeta<
|
|
108
|
+
TypeUtilGetRelationModel<Relation>
|
|
109
|
+
>;
|
|
110
|
+
export type TypeUtilGetRelationOptions<Relation> = Relation extends { options?: infer OPTIONS }
|
|
111
|
+
? OPTIONS
|
|
112
|
+
: undefined;
|
|
113
|
+
export type TypeUtilGetRelationOptionsAutoload<Relation> = Relation extends {
|
|
114
|
+
options?: { autoload?: infer AUTOLOAD };
|
|
115
|
+
}
|
|
116
|
+
? AUTOLOAD
|
|
94
117
|
: undefined;
|
|
95
|
-
export type
|
|
96
|
-
|
|
97
|
-
|
|
118
|
+
export type TypeUtilGetRelationOptionsColumns<Relation> = Relation extends {
|
|
119
|
+
options?: { columns?: infer COLUMNS };
|
|
120
|
+
}
|
|
121
|
+
? COLUMNS
|
|
98
122
|
: undefined;
|
|
99
|
-
export type
|
|
123
|
+
export type TypeUtilGetRelationOptionsAggrs<Relation> = Relation extends {
|
|
124
|
+
options?: { aggrs?: infer Aggrs };
|
|
125
|
+
}
|
|
126
|
+
? Aggrs
|
|
127
|
+
: undefined;
|
|
128
|
+
export type TypeUtilGetRelationOptionsGroups<Relation> = Relation extends {
|
|
129
|
+
options?: { groups?: infer Groups };
|
|
130
|
+
}
|
|
131
|
+
? Groups
|
|
132
|
+
: undefined;
|
|
133
|
+
export type TypeUtilGetModelOptions<Model extends BeanModelMeta | undefined> =
|
|
134
|
+
Model extends BeanModelMeta ? Model[TypeSymbolKeyModelOptions] : undefined;
|
|
135
|
+
export type TypeUtilGetModelEntity<Model extends BeanModelMeta | undefined> =
|
|
136
|
+
Model extends BeanModelMeta ? Model[TypeSymbolKeyEntity] : undefined;
|
|
137
|
+
export type TypeUtilGetModelEntityMeta<Model extends BeanModelMeta | undefined> =
|
|
138
|
+
Model extends BeanModelMeta ? Model[TypeSymbolKeyEntityMeta] : undefined;
|
|
139
|
+
export type TypeUtilGetModelOnionName<Model extends BeanModelMeta | undefined> =
|
|
140
|
+
Model extends BeanModelMeta ? Model['$onionName'] : undefined;
|
|
100
141
|
|
|
101
142
|
export type TypeUtilGetRelationEntityByType<
|
|
102
143
|
Relation,
|
|
@@ -130,13 +171,33 @@ export type TypeUtilGetEntityByType<
|
|
|
130
171
|
: Array<TypeModelRelationResult<TRecord, TModel, IncludeWrapper, Columns>>
|
|
131
172
|
: [Depth] extends [never]
|
|
132
173
|
? undefined
|
|
133
|
-
:
|
|
174
|
+
:
|
|
175
|
+
| TypeModelRelationResult<
|
|
176
|
+
TRecord,
|
|
177
|
+
TModel,
|
|
178
|
+
IncludeWrapper,
|
|
179
|
+
Columns,
|
|
180
|
+
undefined,
|
|
181
|
+
undefined,
|
|
182
|
+
TypeDepthPrev[Depth]
|
|
183
|
+
>
|
|
184
|
+
| undefined;
|
|
134
185
|
|
|
135
|
-
export type TypeUtilGetParamsAggrs<TParams> = TParams extends { aggrs?: infer Aggrs }
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
export type
|
|
139
|
-
|
|
186
|
+
export type TypeUtilGetParamsAggrs<TParams> = TParams extends { aggrs?: infer Aggrs }
|
|
187
|
+
? Aggrs
|
|
188
|
+
: undefined;
|
|
189
|
+
export type TypeUtilGetParamsGroups<TParams> = TParams extends { groups?: infer Groups }
|
|
190
|
+
? Groups
|
|
191
|
+
: undefined; // not use Groups extends string |string[]
|
|
192
|
+
export type TypeUtilGetParamsInlcude<TParams> = TParams extends { include?: infer INCLUDE }
|
|
193
|
+
? INCLUDE
|
|
194
|
+
: undefined;
|
|
195
|
+
export type TypeUtilGetParamsWith<TParams> = TParams extends { with?: infer WITH }
|
|
196
|
+
? WITH
|
|
197
|
+
: undefined;
|
|
198
|
+
export type TypeUtilGetParamsColumns<TParams> = TParams extends { columns?: infer COLUMNS }
|
|
199
|
+
? COLUMNS
|
|
200
|
+
: undefined;
|
|
140
201
|
export type TypeUtilPrepareColumns<TColumns> = TColumns extends '*' | ['*']
|
|
141
202
|
? undefined
|
|
142
203
|
: TColumns extends string[]
|
|
@@ -144,12 +205,19 @@ export type TypeUtilPrepareColumns<TColumns> = TColumns extends '*' | ['*']
|
|
|
144
205
|
: TColumns extends string
|
|
145
206
|
? TColumns
|
|
146
207
|
: undefined;
|
|
147
|
-
export type TypeUtilEntitySelector<TRecord, TColumns> = [TColumns] extends [keyof TRecord]
|
|
148
|
-
|
|
208
|
+
export type TypeUtilEntitySelector<TRecord, TColumns> = [TColumns] extends [keyof TRecord]
|
|
209
|
+
? Pick<TRecord, TColumns>
|
|
210
|
+
: TRecord;
|
|
211
|
+
export type TypeUtilEntityOmit<TRecord, TColumns> = [TColumns] extends [keyof TRecord]
|
|
212
|
+
? Omit<TRecord, TColumns>
|
|
213
|
+
: TRecord;
|
|
149
214
|
export type TypeUtilEntityPartial<TRecord, TColumns> = [TColumns] extends [keyof TRecord]
|
|
150
215
|
? Partial<Pick<TRecord, TColumns>> & Omit<TRecord, TColumns>
|
|
151
216
|
: TRecord;
|
|
152
|
-
export type TypeUtilGetColumnsFromRelationAndIncludeWrapper<
|
|
217
|
+
export type TypeUtilGetColumnsFromRelationAndIncludeWrapper<
|
|
218
|
+
Relation,
|
|
219
|
+
IncludeWrapper extends {} | undefined | unknown,
|
|
220
|
+
> =
|
|
153
221
|
TypeUtilGetParamsColumns<IncludeWrapper> extends string | string[]
|
|
154
222
|
? TypeUtilGetParamsColumns<IncludeWrapper>
|
|
155
223
|
: TypeUtilGetRelationOptionsColumns<Relation>;
|
|
@@ -163,7 +231,15 @@ export interface TypeModelSelectAndCount<
|
|
|
163
231
|
Groups = undefined,
|
|
164
232
|
Depth extends TypeDepthPrev[number] = TypeDepthPrevMax,
|
|
165
233
|
> {
|
|
166
|
-
list: TypeModelRelationResult<
|
|
234
|
+
list: TypeModelRelationResult<
|
|
235
|
+
TRecord,
|
|
236
|
+
TModel,
|
|
237
|
+
TOptionsRelation,
|
|
238
|
+
TColumns,
|
|
239
|
+
Aggrs,
|
|
240
|
+
Groups,
|
|
241
|
+
Depth
|
|
242
|
+
>[];
|
|
167
243
|
total: string;
|
|
168
244
|
pageCount: number;
|
|
169
245
|
pageSize: number;
|
|
@@ -192,10 +268,18 @@ export type TypeModelRelationResult_Normal<
|
|
|
192
268
|
Depth extends TypeDepthPrev[number] = TypeDepthPrevMax,
|
|
193
269
|
> = TypeUtilEntitySelector<
|
|
194
270
|
TRecord,
|
|
195
|
-
TypeUtilPrepareColumns<
|
|
271
|
+
TypeUtilPrepareColumns<
|
|
272
|
+
TColumns extends string | string[] ? TColumns : TypeUtilGetParamsColumns<TOptionsRelation>
|
|
273
|
+
>
|
|
196
274
|
> &
|
|
197
275
|
(TModel extends BeanModelMeta
|
|
198
|
-
? OmitNever<
|
|
276
|
+
? OmitNever<
|
|
277
|
+
TypeModelRelationResultMergeInclude<
|
|
278
|
+
TypeUtilGetModelOptions<TModel>,
|
|
279
|
+
TypeUtilGetParamsInlcude<TOptionsRelation>,
|
|
280
|
+
Depth
|
|
281
|
+
>
|
|
282
|
+
> &
|
|
199
283
|
OmitNever<TypeModelRelationResultMergeWith<TypeUtilGetParamsWith<TOptionsRelation>, Depth>>
|
|
200
284
|
: {});
|
|
201
285
|
|
|
@@ -206,7 +290,11 @@ export type TypeModelRelationResultMergeInclude<
|
|
|
206
290
|
> = {
|
|
207
291
|
[RelationName in keyof TModelOptions['relations']]: TInclude extends {}
|
|
208
292
|
? TInclude[RelationName] extends {} | boolean
|
|
209
|
-
? TypeModelRelationResultMergeIncludeWrapper<
|
|
293
|
+
? TypeModelRelationResultMergeIncludeWrapper<
|
|
294
|
+
TModelOptions['relations'][RelationName],
|
|
295
|
+
TInclude[RelationName],
|
|
296
|
+
Depth
|
|
297
|
+
>
|
|
210
298
|
: TypeModelRelationResultMergeAutoload<TModelOptions['relations'][RelationName], Depth>
|
|
211
299
|
: TypeModelRelationResultMergeAutoload<TModelOptions['relations'][RelationName], Depth>;
|
|
212
300
|
};
|
|
@@ -214,10 +302,22 @@ export type TypeModelRelationResultMergeInclude<
|
|
|
214
302
|
export type TypeModelRelationResultMergeWith<
|
|
215
303
|
TWith extends {} | undefined | unknown,
|
|
216
304
|
Depth extends TypeDepthPrev[number] = TypeDepthPrevMax,
|
|
217
|
-
> = TWith extends {}
|
|
305
|
+
> = TWith extends {}
|
|
306
|
+
? {
|
|
307
|
+
[RelationName in keyof TWith]: TypeModelRelationResultMergeWithRelation<
|
|
308
|
+
TWith[RelationName],
|
|
309
|
+
Depth
|
|
310
|
+
>;
|
|
311
|
+
}
|
|
312
|
+
: {};
|
|
218
313
|
|
|
219
|
-
export type TypeModelRelationResultMergeAutoload<
|
|
220
|
-
|
|
314
|
+
export type TypeModelRelationResultMergeAutoload<
|
|
315
|
+
Relation,
|
|
316
|
+
Depth extends TypeDepthPrev[number] = TypeDepthPrevMax,
|
|
317
|
+
> =
|
|
318
|
+
TypeUtilGetRelationOptionsAutoload<Relation> extends true
|
|
319
|
+
? TypeUtilGetRelationEntityByType<Relation, undefined, Depth>
|
|
320
|
+
: never;
|
|
221
321
|
|
|
222
322
|
export type TypeModelRelationResultMergeIncludeWrapper<
|
|
223
323
|
Relation,
|
|
@@ -239,5 +339,9 @@ export type TypeModelRelationResultMergeWithRelation<
|
|
|
239
339
|
: WithRelation extends true
|
|
240
340
|
? never
|
|
241
341
|
: WithRelation extends {}
|
|
242
|
-
? TypeUtilGetRelationEntityByType<
|
|
342
|
+
? TypeUtilGetRelationEntityByType<
|
|
343
|
+
WithRelation,
|
|
344
|
+
TypeUtilGetRelationOptions<WithRelation>,
|
|
345
|
+
Depth
|
|
346
|
+
>
|
|
243
347
|
: never;
|
|
@@ -1,31 +1,55 @@
|
|
|
1
1
|
import type { TypeUtilGetParamsAggrs, TypeUtilGetRelationOptionsAggrs } from './relations.ts';
|
|
2
2
|
|
|
3
3
|
export type TypeModelAggrRelationResult<TOptions> =
|
|
4
|
-
TypeUtilGetParamsAggrs<TOptions> extends {}
|
|
4
|
+
TypeUtilGetParamsAggrs<TOptions> extends {}
|
|
5
|
+
? TypeModelAggrRelationResultAggrs<TypeUtilGetParamsAggrs<TOptions>>
|
|
6
|
+
: {}; // not use undefined
|
|
5
7
|
|
|
6
8
|
export type TypeModelAggrRelationResultAggrs<Aggrs> = Aggrs extends {}
|
|
7
9
|
? TypeRecordAggrsValuesToObject<
|
|
8
10
|
TypeRecordAggrsValues<{
|
|
9
|
-
[K in keyof Aggrs]: K extends string
|
|
11
|
+
[K in keyof Aggrs]: K extends string
|
|
12
|
+
? TypeModelAggrRelationResultAggr<K, TypeUtilAggrPrepareColumns<Aggrs[K]>>
|
|
13
|
+
: never;
|
|
10
14
|
}>
|
|
11
15
|
>
|
|
12
16
|
: {};
|
|
13
17
|
|
|
14
|
-
export type TypeModelAggrRelationResultAggr<
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
export type TypeModelAggrRelationResultAggr<
|
|
19
|
+
Aggr extends string,
|
|
20
|
+
Columns extends string | number | symbol | undefined,
|
|
21
|
+
> = Columns extends string ? `${Aggr}_${Columns extends '*' ? 'all' : Columns}` : never;
|
|
17
22
|
|
|
18
|
-
export type TypeUtilAggrPrepareColumns<TColumns> = TColumns extends string[]
|
|
23
|
+
export type TypeUtilAggrPrepareColumns<TColumns> = TColumns extends string[]
|
|
24
|
+
? TColumns[number]
|
|
25
|
+
: TColumns extends string
|
|
26
|
+
? TColumns
|
|
27
|
+
: undefined;
|
|
19
28
|
export type TypeRecordAggrsValues<TRecord extends Record<string, any>> = TRecord[keyof TRecord];
|
|
20
|
-
export type TypeRecordAggrsValuesToObject<AggrValues extends string> = {
|
|
29
|
+
export type TypeRecordAggrsValuesToObject<AggrValues extends string> = {
|
|
30
|
+
[K in AggrValues]: string | undefined;
|
|
31
|
+
};
|
|
21
32
|
|
|
22
|
-
export type TypeUtilGetAggrsFromRelationAndIncludeWrapper<
|
|
33
|
+
export type TypeUtilGetAggrsFromRelationAndIncludeWrapper<
|
|
34
|
+
Relation,
|
|
35
|
+
IncludeWrapper extends {} | undefined | unknown,
|
|
36
|
+
> =
|
|
23
37
|
TypeUtilGetRelationOptionsAggrs<Relation> extends {}
|
|
24
38
|
? TypeUtilGetParamsAggrs<IncludeWrapper> extends {}
|
|
25
|
-
? TypeUtilGetAggrsFromRelationAndIncludeWrapper_Mixed<
|
|
39
|
+
? TypeUtilGetAggrsFromRelationAndIncludeWrapper_Mixed<
|
|
40
|
+
TypeUtilGetRelationOptionsAggrs<Relation>,
|
|
41
|
+
TypeUtilGetParamsAggrs<IncludeWrapper>
|
|
42
|
+
>
|
|
26
43
|
: TypeUtilGetRelationOptionsAggrs<Relation>
|
|
27
44
|
: undefined;
|
|
28
45
|
|
|
29
|
-
export type TypeUtilGetAggrsFromRelationAndIncludeWrapper_Mixed<
|
|
30
|
-
|
|
46
|
+
export type TypeUtilGetAggrsFromRelationAndIncludeWrapper_Mixed<
|
|
47
|
+
RelationAggrs extends {},
|
|
48
|
+
IncludeWrapperAggrs extends {},
|
|
49
|
+
> = {
|
|
50
|
+
[K in keyof RelationAggrs]: K extends string
|
|
51
|
+
? K extends keyof IncludeWrapperAggrs
|
|
52
|
+
? IncludeWrapperAggrs[K]
|
|
53
|
+
: RelationAggrs[K]
|
|
54
|
+
: undefined;
|
|
31
55
|
};
|
|
@@ -13,96 +13,119 @@ import type {
|
|
|
13
13
|
TypeUtilGetRelationModel,
|
|
14
14
|
} from './relations.ts';
|
|
15
15
|
|
|
16
|
-
export type TypeEntityTableColumnNames<EntityMeta extends { $table: string } | undefined> =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
export type TypeEntityTableColumnNames<EntityMeta extends { $table: string } | undefined> =
|
|
17
|
+
EntityMeta extends { $table: string }
|
|
18
|
+
? keyof {
|
|
19
|
+
[K in keyof EntityMeta as K extends '$table' | '$comment' | '$default'
|
|
20
|
+
? never
|
|
21
|
+
: K extends string
|
|
22
|
+
? `${EntityMeta['$table']}.${K}`
|
|
23
|
+
: never]: EntityMeta[K];
|
|
24
|
+
}
|
|
25
|
+
: never;
|
|
25
26
|
export type TypeEntityTableColumnNamesShort<Entity> = keyof Entity;
|
|
26
27
|
|
|
27
|
-
export type TypeEntityTableColumns<
|
|
28
|
+
export type TypeEntityTableColumns<
|
|
29
|
+
Entity extends {} | undefined,
|
|
30
|
+
EntityMeta extends { $table: string } | undefined,
|
|
31
|
+
> = Entity extends {}
|
|
28
32
|
? EntityMeta extends { $table: string }
|
|
29
|
-
? {
|
|
33
|
+
? {
|
|
34
|
+
[K in keyof Entity as K extends string ? `${EntityMeta['$table']}.${K}` : never]: Entity[K];
|
|
35
|
+
}
|
|
30
36
|
: {}
|
|
31
37
|
: {};
|
|
32
38
|
export type TypeEntityTableColumnsShort<Entity> = Entity;
|
|
33
39
|
|
|
34
|
-
export type TypeEntityTableColumnsOfModelDirect<TModel extends BeanModelMeta | undefined> =
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
export type TypeEntityTableColumnsOfModelDirect<TModel extends BeanModelMeta | undefined> =
|
|
41
|
+
TModel extends BeanModelMeta
|
|
42
|
+
? TypeEntityTableColumns<TModel[TypeSymbolKeyEntity], TModel[TypeSymbolKeyEntityMeta]>
|
|
43
|
+
: {};
|
|
37
44
|
|
|
38
|
-
export type TypeEntityTableColumnNamesOfModels<A extends BeanModelMeta[]> =
|
|
45
|
+
export type TypeEntityTableColumnNamesOfModels<A extends BeanModelMeta[]> =
|
|
46
|
+
TypeEntityTableColumnNames<A[number][TypeSymbolKeyEntityMeta]>;
|
|
39
47
|
|
|
40
48
|
// export type TypeEntityTableColumnNamesOfModelOptions<TModelOptions extends IDecoratorModelOptions> = TypeEntityTableColumnNames<TypeRecordValues<{
|
|
41
49
|
// [RelationName in keyof TModelOptions['relations']]: TypeUtilGetRelationEntityMeta<TModelOptions['relations'][RelationName]>;
|
|
42
50
|
// }>>;
|
|
43
|
-
export type TypeEntityTableColumnNamesOfModelOptions<TModelOptions extends IDecoratorModelOptions> =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
: never;
|
|
50
|
-
|
|
51
|
-
export type TypeEntityTableColumnsOfModelOptions<TModelOptions extends IDecoratorModelOptions> = TModelOptions['relations'] extends {}
|
|
52
|
-
? TypeEntityTableColumnsOfModelDirect<
|
|
53
|
-
TypeRecordModelValues<{
|
|
54
|
-
[RelationName in keyof TModelOptions['relations']]: TypeUtilGetRelationModel<TModelOptions['relations'][RelationName]>;
|
|
51
|
+
export type TypeEntityTableColumnNamesOfModelOptions<TModelOptions extends IDecoratorModelOptions> =
|
|
52
|
+
TModelOptions['relations'] extends {}
|
|
53
|
+
? TypeRecordValues<{
|
|
54
|
+
[RelationName in keyof TModelOptions['relations']]: TypeEntityTableColumnNames<
|
|
55
|
+
TypeUtilGetRelationEntityMeta<TModelOptions['relations'][RelationName]>
|
|
56
|
+
>;
|
|
55
57
|
}>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
: never;
|
|
59
|
+
|
|
60
|
+
export type TypeEntityTableColumnsOfModelOptions<TModelOptions extends IDecoratorModelOptions> =
|
|
61
|
+
TModelOptions['relations'] extends {}
|
|
62
|
+
? TypeEntityTableColumnsOfModelDirect<
|
|
63
|
+
TypeRecordModelValues<{
|
|
64
|
+
[RelationName in keyof TModelOptions['relations']]: TypeUtilGetRelationModel<
|
|
65
|
+
TModelOptions['relations'][RelationName]
|
|
66
|
+
>;
|
|
67
|
+
}>
|
|
68
|
+
>
|
|
69
|
+
: {};
|
|
70
|
+
|
|
71
|
+
export type TypeModelsOfModelOptions<TModelOptions extends IDecoratorModelOptions> =
|
|
72
|
+
TModelOptions['relations'] extends {}
|
|
73
|
+
? TypeRecordModelValues<{
|
|
74
|
+
[RelationName in keyof TModelOptions['relations']]: TypeUtilGetRelationModel<
|
|
75
|
+
TModelOptions['relations'][RelationName]
|
|
76
|
+
>;
|
|
77
|
+
}>
|
|
78
|
+
: never;
|
|
79
|
+
|
|
80
|
+
export type TypeModelOnionNamesOfModelOptions<TModelOptions extends IDecoratorModelOptions> =
|
|
81
|
+
TModelOptions['relations'] extends {}
|
|
82
|
+
? TypeRecordValues<{
|
|
83
|
+
[RelationName in keyof TModelOptions['relations']]: TypeUtilGetModelOnionName<
|
|
84
|
+
TypeUtilGetRelationModel<TModelOptions['relations'][RelationName]>
|
|
85
|
+
>;
|
|
86
|
+
}>
|
|
87
|
+
: undefined; // not use never
|
|
58
88
|
|
|
59
|
-
export type
|
|
60
|
-
|
|
61
|
-
[RelationName in keyof TModelOptions['relations']]: TypeUtilGetRelationModel<TModelOptions['relations'][RelationName]>;
|
|
62
|
-
}>
|
|
63
|
-
: never;
|
|
89
|
+
export type TypeRecordModelValues<TRecord extends Record<string, BeanModelMeta | undefined>> =
|
|
90
|
+
TRecord[keyof TRecord];
|
|
64
91
|
|
|
65
|
-
export type
|
|
66
|
-
|
|
67
|
-
[RelationName in keyof TModelOptions['relations']]: TypeUtilGetModelOnionName<
|
|
68
|
-
TypeUtilGetRelationModel<TModelOptions['relations'][RelationName]>
|
|
69
|
-
>;
|
|
70
|
-
}>
|
|
71
|
-
: undefined; // not use never
|
|
92
|
+
export type TypeEntityTableColumnNamesOfModelClass<TModel extends BeanModelMeta> =
|
|
93
|
+
TypeEntityTableColumnNamesOfModelOptions<TypeUtilGetModelOptions<TModel>>;
|
|
72
94
|
|
|
73
|
-
export type
|
|
95
|
+
export type TypeEntityTableColumnsOfModelClass<TModel extends BeanModelMeta> =
|
|
96
|
+
TypeEntityTableColumnsOfModelOptions<TypeUtilGetModelOptions<TModel>>;
|
|
74
97
|
|
|
75
|
-
export type
|
|
98
|
+
export type TypeModelsOfModelClass<TModel extends BeanModelMeta> = TypeModelsOfModelOptions<
|
|
76
99
|
TypeUtilGetModelOptions<TModel>
|
|
77
100
|
>;
|
|
78
101
|
|
|
79
|
-
export type
|
|
102
|
+
export type TypeModelOnionNamesOfModelClass<TModel extends BeanModelMeta> =
|
|
103
|
+
TypeModelOnionNamesOfModelOptions<TypeUtilGetModelOptions<TModel>>;
|
|
80
104
|
|
|
81
|
-
export type
|
|
105
|
+
export type TypeEntityTableColumnNamesOfModelJoins<TModelJoins extends TypeModelsClassLikeGeneral> =
|
|
106
|
+
TypeEntityTableColumnNames<
|
|
107
|
+
TypeModelOfModelLike<TypeConfirmArray<TModelJoins>[number]>[TypeSymbolKeyEntityMeta]
|
|
108
|
+
>;
|
|
82
109
|
|
|
83
|
-
export type
|
|
84
|
-
|
|
85
|
-
export type TypeEntityTableColumnNamesOfModelJoins<TModelJoins extends TypeModelsClassLikeGeneral> = TypeEntityTableColumnNames<
|
|
86
|
-
TypeModelOfModelLike<TypeConfirmArray<TModelJoins>[number]>[TypeSymbolKeyEntityMeta]
|
|
87
|
-
>;
|
|
88
|
-
|
|
89
|
-
export type TypeEntityTableColumnsOfModelJoins<TModelJoins extends TypeModelsClassLikeGeneral> = TypeEntityTableColumnsOfModelDirect<
|
|
90
|
-
TypeModelOfModelLike<TypeConfirmArray<TModelJoins>[number]>
|
|
91
|
-
>;
|
|
110
|
+
export type TypeEntityTableColumnsOfModelJoins<TModelJoins extends TypeModelsClassLikeGeneral> =
|
|
111
|
+
TypeEntityTableColumnsOfModelDirect<TypeModelOfModelLike<TypeConfirmArray<TModelJoins>[number]>>;
|
|
92
112
|
|
|
93
113
|
export type TypeEntityTableColumnNamesOfModelSelf<TModel extends BeanModelMeta> =
|
|
94
114
|
| TypeEntityTableColumnNames<TModel[TypeSymbolKeyEntityMeta]>
|
|
95
115
|
| TypeEntityTableColumnNamesShort<TModel[TypeSymbolKeyEntity]>;
|
|
96
116
|
|
|
97
|
-
export type TypeEntityTableColumnsOfModelSelf<TModel extends BeanModelMeta> =
|
|
98
|
-
|
|
117
|
+
export type TypeEntityTableColumnsOfModelSelf<TModel extends BeanModelMeta> =
|
|
118
|
+
TypeEntityTableColumnsOfModelDirect<TModel> &
|
|
119
|
+
TypeEntityTableColumnsShort<TModel[TypeSymbolKeyEntity]>;
|
|
99
120
|
|
|
100
121
|
export type TypeEntityTableColumnNamesOfGeneral<
|
|
101
122
|
TModelJoins extends TypeModelsClassLikeGeneral | undefined,
|
|
102
123
|
TModel extends BeanModelMeta | undefined,
|
|
103
124
|
> = TModel extends BeanModelMeta
|
|
104
125
|
? TModelJoins extends TypeModelsClassLikeGeneral
|
|
105
|
-
?
|
|
126
|
+
?
|
|
127
|
+
| TypeEntityTableColumnNamesOfModelJoins<TModelJoins>
|
|
128
|
+
| TypeEntityTableColumnNamesOfModelSelf<TModel>
|
|
106
129
|
: TypeEntityTableColumnNamesOfModelClass<TModel> | TypeEntityTableColumnNamesOfModelSelf<TModel>
|
|
107
130
|
: undefined;
|
|
108
131
|
|