vona-module-a-orm 5.1.4 → 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 +3 -3
- 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 +1 -0
- 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/config/config.d.ts +3 -0
- package/dist/config/config.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 +59 -28
- 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 +50 -15
- 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 +48 -16
- 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 +63 -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/config/config.ts +3 -0
- 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
|
@@ -17,12 +17,14 @@ export class ServiceColumnsCache extends BeanBase {
|
|
|
17
17
|
/** real client name */
|
|
18
18
|
protected __init__(clientName: keyof IDatabaseClientRecord) {
|
|
19
19
|
this.clientName = clientName;
|
|
20
|
-
this._onColumnsClearCancel = this.scope.event.columnsClear.on(
|
|
21
|
-
|
|
22
|
-
this.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
this._onColumnsClearCancel = this.scope.event.columnsClear.on(
|
|
21
|
+
({ clientName, tableName }, next) => {
|
|
22
|
+
if (clientName === this.clientName) {
|
|
23
|
+
this.columnsClear(tableName);
|
|
24
|
+
}
|
|
25
|
+
next();
|
|
26
|
+
},
|
|
27
|
+
);
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
protected async __dispose__() {
|
package/src/service/database.ts
CHANGED
|
@@ -4,7 +4,11 @@ import { Service } from 'vona-module-a-bean';
|
|
|
4
4
|
|
|
5
5
|
import type { BeanDatabaseDialectBase } from '../bean/bean.databaseDialectBase.ts';
|
|
6
6
|
import type { ConfigDatabaseClient } from '../types/config.ts';
|
|
7
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
IDatabaseClientDialectRecord,
|
|
9
|
+
IDatabaseClientRecord,
|
|
10
|
+
IDbInfo,
|
|
11
|
+
} from '../types/database.ts';
|
|
8
12
|
|
|
9
13
|
import { ServiceDatabaseClient } from './databaseClient_.ts';
|
|
10
14
|
|
|
@@ -14,7 +18,11 @@ export class ServiceDatabase extends BeanBase {
|
|
|
14
18
|
return this.app.config.database;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
|
-
getClientConfig(
|
|
21
|
+
getClientConfig(
|
|
22
|
+
clientName: keyof IDatabaseClientRecord,
|
|
23
|
+
clientConfig?: ConfigDatabaseClient,
|
|
24
|
+
original?: boolean,
|
|
25
|
+
): ConfigDatabaseClient {
|
|
18
26
|
// clientConfig
|
|
19
27
|
if (!clientConfig) {
|
|
20
28
|
clientConfig = this.configDatabase.clients[clientName];
|
|
@@ -51,7 +59,10 @@ export class ServiceDatabase extends BeanBase {
|
|
|
51
59
|
return { level, clientName };
|
|
52
60
|
}
|
|
53
61
|
|
|
54
|
-
prepareClientNameSelector(
|
|
62
|
+
prepareClientNameSelector(
|
|
63
|
+
dbInfo: IDbInfo,
|
|
64
|
+
dialect: BeanDatabaseDialectBase | keyof IDatabaseClientDialectRecord,
|
|
65
|
+
) {
|
|
55
66
|
const dialect2 = typeof dialect === 'string' ? this.bean.database.getDialect(dialect) : dialect;
|
|
56
67
|
if (!dialect2.capabilities.level) return dbInfo.clientName;
|
|
57
68
|
// combine
|
|
@@ -80,7 +91,8 @@ export class ServiceDatabase extends BeanBase {
|
|
|
80
91
|
// check instance
|
|
81
92
|
const instanceName = this.ctx.instanceName;
|
|
82
93
|
if (!isNil(instanceName)) {
|
|
83
|
-
const configInstanceBase =
|
|
94
|
+
const configInstanceBase =
|
|
95
|
+
this.$scope.instance.service.instance.getConfigInstanceBase(instanceName);
|
|
84
96
|
if (configInstanceBase?.isolate) {
|
|
85
97
|
return configInstanceBase.isolateClient!;
|
|
86
98
|
}
|
|
@@ -89,9 +101,12 @@ export class ServiceDatabase extends BeanBase {
|
|
|
89
101
|
}
|
|
90
102
|
|
|
91
103
|
prepareClientNameReal(clientName?: keyof IDatabaseClientRecord): keyof IDatabaseClientRecord {
|
|
92
|
-
return this.scope.event.clientNameReal.emitSync(
|
|
93
|
-
|
|
94
|
-
|
|
104
|
+
return this.scope.event.clientNameReal.emitSync(
|
|
105
|
+
this.prepareClientName(clientName),
|
|
106
|
+
clientName => {
|
|
107
|
+
return clientName;
|
|
108
|
+
},
|
|
109
|
+
);
|
|
95
110
|
}
|
|
96
111
|
|
|
97
112
|
columnsClear(clientName?: keyof IDatabaseClientRecord, tableName?: string) {
|
|
@@ -100,16 +115,25 @@ export class ServiceDatabase extends BeanBase {
|
|
|
100
115
|
}
|
|
101
116
|
|
|
102
117
|
private columnsClearWorker(clientName?: keyof IDatabaseClientRecord, tableName?: string) {
|
|
103
|
-
this.scope.event.columnsClear.emitSync({
|
|
118
|
+
this.scope.event.columnsClear.emitSync({
|
|
119
|
+
clientName: this.prepareClientNameReal(clientName),
|
|
120
|
+
tableName,
|
|
121
|
+
});
|
|
104
122
|
}
|
|
105
123
|
|
|
106
|
-
async reloadClients(
|
|
124
|
+
async reloadClients(
|
|
125
|
+
clientName?: keyof IDatabaseClientRecord,
|
|
126
|
+
clientConfig?: ConfigDatabaseClient,
|
|
127
|
+
) {
|
|
107
128
|
clientName = this.prepareClientName(clientName);
|
|
108
129
|
await this.bean.mutate.reloadInstances(ServiceDatabaseClient, { clientName, clientConfig });
|
|
109
130
|
this.columnsClear(clientName);
|
|
110
131
|
}
|
|
111
132
|
|
|
112
|
-
async reloadClientsWorker(
|
|
133
|
+
async reloadClientsWorker(
|
|
134
|
+
clientName?: keyof IDatabaseClientRecord,
|
|
135
|
+
clientConfig?: ConfigDatabaseClient,
|
|
136
|
+
) {
|
|
113
137
|
clientName = this.prepareClientName(clientName);
|
|
114
138
|
await this.bean.mutate.reloadInstancesWorker({
|
|
115
139
|
beanFullName: appResource.getBeanFullName(ServiceDatabaseClient) as any,
|
|
@@ -85,7 +85,10 @@ export class ServiceDatabaseClient extends BeanMutateBase {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
async reload(clientConfig?: ConfigDatabaseClient) {
|
|
88
|
-
const clientConfigReal = this.scope.service.database.getClientConfig(
|
|
88
|
+
const clientConfigReal = this.scope.service.database.getClientConfig(
|
|
89
|
+
this.clientName,
|
|
90
|
+
clientConfig,
|
|
91
|
+
);
|
|
89
92
|
this.$mutate([this.clientNameSelector, clientConfigReal]);
|
|
90
93
|
await this.__close();
|
|
91
94
|
this.__load(this.clientNameSelector, clientConfigReal);
|
|
@@ -69,12 +69,21 @@ export class ServiceRelations extends BeanBase {
|
|
|
69
69
|
const relations = this.handleRelationsCollection(includeWrapper);
|
|
70
70
|
if (!relations) return entitiesResult;
|
|
71
71
|
for (const relation of relations) {
|
|
72
|
-
entitiesResult = await this.__handleRelationMutate(
|
|
72
|
+
entitiesResult = await this.__handleRelationMutate(
|
|
73
|
+
entitiesResult,
|
|
74
|
+
entities,
|
|
75
|
+
relation,
|
|
76
|
+
methodOptions,
|
|
77
|
+
);
|
|
73
78
|
}
|
|
74
79
|
return entitiesResult;
|
|
75
80
|
}
|
|
76
81
|
|
|
77
|
-
public async handleRelationsDelete(
|
|
82
|
+
public async handleRelationsDelete(
|
|
83
|
+
ids: TableIdentity[],
|
|
84
|
+
includeWrapper?: IModelRelationIncludeWrapper,
|
|
85
|
+
methodOptions?: IModelMethodOptions,
|
|
86
|
+
) {
|
|
78
87
|
if (ids.length === 0) return;
|
|
79
88
|
// relations
|
|
80
89
|
const relations = this.handleRelationsCollection(includeWrapper);
|
|
@@ -84,7 +93,11 @@ export class ServiceRelations extends BeanBase {
|
|
|
84
93
|
}
|
|
85
94
|
}
|
|
86
95
|
|
|
87
|
-
private async __handleRelationOne<TRecord extends {}>(
|
|
96
|
+
private async __handleRelationOne<TRecord extends {}>(
|
|
97
|
+
entity: TRecord,
|
|
98
|
+
relation: IRelationItem,
|
|
99
|
+
methodOptions?: IModelMethodOptions,
|
|
100
|
+
) {
|
|
88
101
|
const [relationName, relationReal, includeReal, withReal] = relation;
|
|
89
102
|
const { type, modelMiddle, model, keyFrom, keyTo, key, options } = relationReal;
|
|
90
103
|
const modelTarget = this.__getModelTarget(model, options?.meta) as BeanModelCache;
|
|
@@ -125,12 +138,18 @@ export class ServiceRelations extends BeanBase {
|
|
|
125
138
|
}
|
|
126
139
|
}
|
|
127
140
|
} else if (type === 'belongsToMany') {
|
|
128
|
-
const modelTargetMiddle = this.__getModelTarget(
|
|
141
|
+
const modelTargetMiddle = this.__getModelTarget(
|
|
142
|
+
modelMiddle,
|
|
143
|
+
options?.meta?.middle,
|
|
144
|
+
) as BeanModelCrud;
|
|
129
145
|
const idFrom = cast(entity).id;
|
|
130
146
|
if (isNil(idFrom)) {
|
|
131
147
|
entity[relationName] = optionsReal.groups ? [] : optionsReal.aggrs ? undefined : [];
|
|
132
148
|
} else {
|
|
133
|
-
const itemsMiddle = await modelTargetMiddle.select(
|
|
149
|
+
const itemsMiddle = await modelTargetMiddle.select(
|
|
150
|
+
{ where: { [keyFrom]: idFrom } },
|
|
151
|
+
methodOptionsReal,
|
|
152
|
+
);
|
|
134
153
|
const idsTo = itemsMiddle.map(item => item[keyTo]);
|
|
135
154
|
if (optionsReal.groups) {
|
|
136
155
|
const options2 = deepExtend({}, optionsReal, { where: { id: idsTo } });
|
|
@@ -146,7 +165,11 @@ export class ServiceRelations extends BeanBase {
|
|
|
146
165
|
}
|
|
147
166
|
}
|
|
148
167
|
|
|
149
|
-
private async __handleRelationMany<TRecord extends {}>(
|
|
168
|
+
private async __handleRelationMany<TRecord extends {}>(
|
|
169
|
+
entities: TRecord[],
|
|
170
|
+
relation: IRelationItem,
|
|
171
|
+
methodOptions?: IModelMethodOptions,
|
|
172
|
+
) {
|
|
150
173
|
const [relationName, relationReal, includeReal, withReal] = relation;
|
|
151
174
|
const { type, modelMiddle, model, keyFrom, keyTo, key, options } = relationReal;
|
|
152
175
|
const modelTarget = this.__getModelTarget(model, options?.meta) as BeanModelCache;
|
|
@@ -218,23 +241,36 @@ export class ServiceRelations extends BeanBase {
|
|
|
218
241
|
}
|
|
219
242
|
}
|
|
220
243
|
} else if (type === 'belongsToMany') {
|
|
221
|
-
const modelTargetMiddle = this.__getModelTarget(
|
|
244
|
+
const modelTargetMiddle = this.__getModelTarget(
|
|
245
|
+
modelMiddle,
|
|
246
|
+
options?.meta?.middle,
|
|
247
|
+
) as BeanModelCrud;
|
|
222
248
|
const idsFrom = entities.map(item => cast(item).id).filter(id => !isNil(id));
|
|
223
249
|
let itemsMiddle;
|
|
224
250
|
if (idsFrom.length === 0) {
|
|
225
251
|
itemsMiddle = [];
|
|
226
252
|
} else {
|
|
227
|
-
itemsMiddle = await modelTargetMiddle.select(
|
|
253
|
+
itemsMiddle = await modelTargetMiddle.select(
|
|
254
|
+
{ where: { [keyFrom]: idsFrom } },
|
|
255
|
+
methodOptionsReal,
|
|
256
|
+
);
|
|
228
257
|
}
|
|
229
258
|
if (optionsReal.groups) {
|
|
230
259
|
for (const entity of entities) {
|
|
231
|
-
const idsTo = itemsMiddle
|
|
232
|
-
|
|
260
|
+
const idsTo = itemsMiddle
|
|
261
|
+
.filter(item => item[keyFrom] === cast(entity).id)
|
|
262
|
+
.map(item => item[keyTo]);
|
|
263
|
+
const options2 = deepExtend({}, optionsReal, {
|
|
264
|
+
groups: optionsReal.groups,
|
|
265
|
+
where: { id: idsTo },
|
|
266
|
+
});
|
|
233
267
|
entity[relationName] = await modelTarget.group(options2, methodOptionsReal);
|
|
234
268
|
}
|
|
235
269
|
} else if (optionsReal.aggrs) {
|
|
236
270
|
for (const entity of entities) {
|
|
237
|
-
const idsTo = itemsMiddle
|
|
271
|
+
const idsTo = itemsMiddle
|
|
272
|
+
.filter(item => item[keyFrom] === cast(entity).id)
|
|
273
|
+
.map(item => item[keyTo]);
|
|
238
274
|
const options2 = deepExtend({}, optionsReal, { where: { id: idsTo } });
|
|
239
275
|
entity[relationName] = await modelTarget.aggregate(options2, methodOptionsReal);
|
|
240
276
|
}
|
|
@@ -246,7 +282,9 @@ export class ServiceRelations extends BeanBase {
|
|
|
246
282
|
entity[relationName] = [];
|
|
247
283
|
for (const itemMiddle of itemsMiddle) {
|
|
248
284
|
if (itemMiddle[keyFrom] === cast(entity).id) {
|
|
249
|
-
entity[relationName].push(
|
|
285
|
+
entity[relationName].push(
|
|
286
|
+
items.find(item => cast(item).id === cast(itemMiddle)[keyTo]),
|
|
287
|
+
);
|
|
250
288
|
}
|
|
251
289
|
}
|
|
252
290
|
}
|
|
@@ -263,7 +301,10 @@ export class ServiceRelations extends BeanBase {
|
|
|
263
301
|
const [relationName, relationReal, includeReal, withReal] = relation;
|
|
264
302
|
const { type, modelMiddle, model, keyFrom, keyTo, key, options } = relationReal;
|
|
265
303
|
const modelTarget = this.__getModelTarget(model, options?.meta) as BeanModelCache;
|
|
266
|
-
const methodOptionsReal = Object.assign({}, methodOptions, {
|
|
304
|
+
const methodOptionsReal = Object.assign({}, methodOptions, {
|
|
305
|
+
include: includeReal,
|
|
306
|
+
with: withReal,
|
|
307
|
+
});
|
|
267
308
|
if (type === 'hasOne') {
|
|
268
309
|
let children: any[] = [];
|
|
269
310
|
for (let index = 0; index < entities.length; index++) {
|
|
@@ -271,7 +312,11 @@ export class ServiceRelations extends BeanBase {
|
|
|
271
312
|
if (entity[relationName]) {
|
|
272
313
|
// donot check if has id of entity[relationName], for safety
|
|
273
314
|
const item: any = await modelTarget.get({ [key]: cast(entity).id });
|
|
274
|
-
if (
|
|
315
|
+
if (
|
|
316
|
+
!isNil(item?.id) &&
|
|
317
|
+
!isNil(entity[relationName].id) &&
|
|
318
|
+
String(item?.id) !== String(entity[relationName].id)
|
|
319
|
+
) {
|
|
275
320
|
throw new Error(`invalid id: ${entity[relationName].id}`);
|
|
276
321
|
}
|
|
277
322
|
const dataNew: any = { [key]: cast(entity).id };
|
|
@@ -287,7 +332,9 @@ export class ServiceRelations extends BeanBase {
|
|
|
287
332
|
const entityResult = result[index];
|
|
288
333
|
const entity = entities[index];
|
|
289
334
|
if (entity[relationName]) {
|
|
290
|
-
entityResult[relationName] = children.find(
|
|
335
|
+
entityResult[relationName] = children.find(
|
|
336
|
+
item => String(item[key]) === String(cast(entity).id),
|
|
337
|
+
);
|
|
291
338
|
}
|
|
292
339
|
}
|
|
293
340
|
return result;
|
|
@@ -305,7 +352,11 @@ export class ServiceRelations extends BeanBase {
|
|
|
305
352
|
if (idsTo.length === 0) {
|
|
306
353
|
idsTarget = [];
|
|
307
354
|
} else {
|
|
308
|
-
const itemsTarget = await cast(modelTarget).__select_raw(
|
|
355
|
+
const itemsTarget = await cast(modelTarget).__select_raw(
|
|
356
|
+
undefined,
|
|
357
|
+
{ where: { [key]: entityId, id: idsTo } },
|
|
358
|
+
methodOptionsReal,
|
|
359
|
+
);
|
|
309
360
|
idsTarget = itemsTarget.map(item => item.id);
|
|
310
361
|
}
|
|
311
362
|
for (const child of entity[relationName]) {
|
|
@@ -332,7 +383,10 @@ export class ServiceRelations extends BeanBase {
|
|
|
332
383
|
}
|
|
333
384
|
return result;
|
|
334
385
|
} else if (type === 'belongsToMany') {
|
|
335
|
-
const modelTargetMiddle = this.__getModelTarget(
|
|
386
|
+
const modelTargetMiddle = this.__getModelTarget(
|
|
387
|
+
modelMiddle,
|
|
388
|
+
options?.meta?.middle,
|
|
389
|
+
) as BeanModelCache;
|
|
336
390
|
let children: any[] = [];
|
|
337
391
|
for (let index = 0; index < entities.length; index++) {
|
|
338
392
|
const entity = entities[index];
|
|
@@ -384,20 +438,38 @@ export class ServiceRelations extends BeanBase {
|
|
|
384
438
|
return entitiesResult;
|
|
385
439
|
}
|
|
386
440
|
|
|
387
|
-
private async __handleRelationDelete(
|
|
441
|
+
private async __handleRelationDelete(
|
|
442
|
+
ids: TableIdentity[],
|
|
443
|
+
relation: IRelationItem,
|
|
444
|
+
methodOptions?: IModelMethodOptions,
|
|
445
|
+
) {
|
|
388
446
|
const [_relationName, relationReal, includeReal, withReal] = relation;
|
|
389
447
|
const { type, modelMiddle, model, keyFrom, key, options } = relationReal;
|
|
390
448
|
const modelTarget = this.__getModelTarget(model, options?.meta) as BeanModelCache;
|
|
391
|
-
const methodOptionsReal = Object.assign({}, methodOptions, {
|
|
449
|
+
const methodOptionsReal = Object.assign({}, methodOptions, {
|
|
450
|
+
include: includeReal,
|
|
451
|
+
with: withReal,
|
|
452
|
+
});
|
|
392
453
|
if (type === 'hasOne' || type === 'hasMany') {
|
|
393
|
-
const children = await cast(modelTarget).__select_raw(
|
|
454
|
+
const children = await cast(modelTarget).__select_raw(
|
|
455
|
+
undefined,
|
|
456
|
+
{ columns: 'id', where: { [key]: ids } },
|
|
457
|
+
methodOptionsReal,
|
|
458
|
+
);
|
|
394
459
|
const idsTo = children.map(item => item.id);
|
|
395
460
|
await modelTarget.deleteBulk(idsTo, methodOptionsReal);
|
|
396
461
|
} else if (type === 'belongsTo') {
|
|
397
462
|
// do nothing
|
|
398
463
|
} else if (type === 'belongsToMany') {
|
|
399
|
-
const modelTargetMiddle = this.__getModelTarget(
|
|
400
|
-
|
|
464
|
+
const modelTargetMiddle = this.__getModelTarget(
|
|
465
|
+
modelMiddle,
|
|
466
|
+
options?.meta?.middle,
|
|
467
|
+
) as BeanModelCache;
|
|
468
|
+
const itemsMiddle = await cast(modelTargetMiddle).__select_raw(
|
|
469
|
+
undefined,
|
|
470
|
+
{ columns: 'id', where: { [keyFrom]: ids } },
|
|
471
|
+
methodOptionsReal,
|
|
472
|
+
);
|
|
401
473
|
const idsMiddle = itemsMiddle.map(item => item.id);
|
|
402
474
|
await modelTargetMiddle.deleteBulk(idsMiddle, methodOptionsReal);
|
|
403
475
|
}
|
|
@@ -411,7 +483,10 @@ export class ServiceRelations extends BeanBase {
|
|
|
411
483
|
return [columns, false];
|
|
412
484
|
}
|
|
413
485
|
|
|
414
|
-
public prepareColumnsByRelations<T extends { columns?: any }>(
|
|
486
|
+
public prepareColumnsByRelations<T extends { columns?: any }>(
|
|
487
|
+
relations: IRelationItem[],
|
|
488
|
+
options?: T,
|
|
489
|
+
): [T | undefined, string[] | undefined] {
|
|
415
490
|
if (!options || !options.columns) return [options, undefined];
|
|
416
491
|
const columns = Array.isArray(options.columns) ? options.columns : [options.columns];
|
|
417
492
|
if (columns.includes('*')) return [options, undefined];
|
|
@@ -5,7 +5,10 @@ import type { FunctionAny, FunctionAsync } from 'vona';
|
|
|
5
5
|
import { BeanBase } from 'vona';
|
|
6
6
|
import { Service } from 'vona-module-a-bean';
|
|
7
7
|
|
|
8
|
-
import type {
|
|
8
|
+
import type {
|
|
9
|
+
ITransactionConsistencyCommitOptions,
|
|
10
|
+
ITransactionOptions,
|
|
11
|
+
} from '../types/transaction.ts';
|
|
9
12
|
import type { ServiceDb } from './db_.ts';
|
|
10
13
|
import type { ServiceTransactionFiber } from './transactionFiber_.ts';
|
|
11
14
|
|
|
@@ -103,13 +106,18 @@ export class ServiceTransaction extends BeanBase {
|
|
|
103
106
|
throw new Error('transaction error: unknown propagation');
|
|
104
107
|
}
|
|
105
108
|
|
|
106
|
-
private async _isolationLevelRequired<RESULT>(
|
|
109
|
+
private async _isolationLevelRequired<RESULT>(
|
|
110
|
+
fn: FunctionAsync<RESULT>,
|
|
111
|
+
options?: ITransactionOptions,
|
|
112
|
+
): Promise<RESULT> {
|
|
107
113
|
let res: RESULT;
|
|
108
114
|
// begin
|
|
109
115
|
let fiber: ServiceTransactionFiber | undefined;
|
|
110
116
|
if (!this.inTransaction) {
|
|
111
117
|
const connection = this._db.client.connection;
|
|
112
|
-
const transactionConnection = await connection.transaction(
|
|
118
|
+
const transactionConnection = await connection.transaction(
|
|
119
|
+
_translateTransactionOptions(options),
|
|
120
|
+
);
|
|
113
121
|
fiber = this.transactionState.add(this._db, transactionConnection);
|
|
114
122
|
}
|
|
115
123
|
// fn
|
|
@@ -138,7 +146,9 @@ export class ServiceTransaction extends BeanBase {
|
|
|
138
146
|
}
|
|
139
147
|
}
|
|
140
148
|
|
|
141
|
-
function _translateTransactionOptions(
|
|
149
|
+
function _translateTransactionOptions(
|
|
150
|
+
options?: ITransactionOptions,
|
|
151
|
+
): Knex.TransactionConfig | undefined {
|
|
142
152
|
if (!options) return undefined;
|
|
143
153
|
return {
|
|
144
154
|
isolationLevel: TransactionIsolationLevelsMap[options.isolationLevel ?? 'DEFAULT'] as any,
|
package/src/types/dto/dtoGet.ts
CHANGED
|
@@ -2,12 +2,17 @@ import type { BeanModelMeta } from '../../bean/bean.model/bean.model_meta.ts';
|
|
|
2
2
|
import type { IModelRelationIncludeWrapper } from '../model.ts';
|
|
3
3
|
import type { TypeModelColumns } from '../modelWhere.ts';
|
|
4
4
|
import type { IModelClassRecord } from '../onion/model.ts';
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
TypeModelOfModelLike,
|
|
7
|
+
TypeModelRelationResult,
|
|
8
|
+
TypeSymbolKeyEntity,
|
|
9
|
+
} from '../relations.ts';
|
|
6
10
|
|
|
7
|
-
export type IDtoGetParams<ModelLike extends BeanModelMeta | keyof IModelClassRecord> =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
export type IDtoGetParams<ModelLike extends BeanModelMeta | keyof IModelClassRecord> =
|
|
12
|
+
IBuildDtoGetParams<
|
|
13
|
+
TypeModelOfModelLike<ModelLike>[TypeSymbolKeyEntity],
|
|
14
|
+
TypeModelOfModelLike<ModelLike>
|
|
15
|
+
>;
|
|
11
16
|
|
|
12
17
|
export interface IBuildDtoGetParams<TRecord, Model extends BeanModelMeta>
|
|
13
18
|
extends IModelRelationIncludeWrapper<Model>, IBuildDtoGetParamsBasic<TRecord> {}
|
|
@@ -16,7 +21,10 @@ export interface IBuildDtoGetParamsBasic<TRecord> {
|
|
|
16
21
|
columns?: TypeModelColumns<TRecord>;
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
export type TypeDtoGetResult<
|
|
24
|
+
export type TypeDtoGetResult<
|
|
25
|
+
ModelLike extends BeanModelMeta | keyof IModelClassRecord,
|
|
26
|
+
TOptionsRelation,
|
|
27
|
+
> = TypeModelRelationResult<
|
|
20
28
|
TypeModelOfModelLike<ModelLike>[TypeSymbolKeyEntity],
|
|
21
29
|
TypeModelOfModelLike<ModelLike>,
|
|
22
30
|
TOptionsRelation
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { TypeModelGroupRelationResultGroups } from '../relationsGroup.ts';
|
|
2
2
|
|
|
3
|
-
export type TypeDtoGroupResult<TRecord, Aggrs, Groups, Columns> =
|
|
3
|
+
export type TypeDtoGroupResult<TRecord, Aggrs, Groups, Columns> =
|
|
4
|
+
TypeModelGroupRelationResultGroups<TRecord, Aggrs, Groups, Columns>;
|
|
@@ -27,10 +27,11 @@ import type {
|
|
|
27
27
|
|
|
28
28
|
export type TypeDtoMutateType = 'create' | 'update' | 'mutate';
|
|
29
29
|
|
|
30
|
-
export type IDtoMutateParams<ModelLike extends BeanModelMeta | keyof IModelClassRecord> =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
export type IDtoMutateParams<ModelLike extends BeanModelMeta | keyof IModelClassRecord> =
|
|
31
|
+
IBuildDtoMutateParams<
|
|
32
|
+
TypeModelOfModelLike<ModelLike>[TypeSymbolKeyEntity],
|
|
33
|
+
TypeModelOfModelLike<ModelLike>
|
|
34
|
+
>;
|
|
34
35
|
|
|
35
36
|
export interface IBuildDtoMutateParams<TRecord, Model extends BeanModelMeta>
|
|
36
37
|
extends IModelRelationIncludeWrapper<Model>, IBuildDtoMutateParamsBasic<TRecord> {}
|
|
@@ -73,9 +74,18 @@ export type TypeDtoMutateRelationResult<
|
|
|
73
74
|
> &
|
|
74
75
|
(TModel extends BeanModelMeta
|
|
75
76
|
? OmitNever<
|
|
76
|
-
TypeDtoMutateRelationResultMergeInclude<
|
|
77
|
+
TypeDtoMutateRelationResultMergeInclude<
|
|
78
|
+
TMutateTypeTopLevel,
|
|
79
|
+
TypeUtilGetModelOptions<TModel>,
|
|
80
|
+
TypeUtilGetParamsInlcude<TOptionsRelation>
|
|
81
|
+
>
|
|
77
82
|
> &
|
|
78
|
-
OmitNever<
|
|
83
|
+
OmitNever<
|
|
84
|
+
TypeDtoMutateModelRelationResultMergeWith<
|
|
85
|
+
TMutateTypeTopLevel,
|
|
86
|
+
TypeUtilGetParamsWith<TOptionsRelation>
|
|
87
|
+
>
|
|
88
|
+
>
|
|
79
89
|
: {});
|
|
80
90
|
|
|
81
91
|
type TypeDtoMutateRelationResultMergeInclude<
|
|
@@ -85,15 +95,32 @@ type TypeDtoMutateRelationResultMergeInclude<
|
|
|
85
95
|
> = {
|
|
86
96
|
[RelationName in keyof TModelOptions['relations']]: TInclude extends {}
|
|
87
97
|
? TInclude[RelationName] extends {} | boolean
|
|
88
|
-
? TypeDtoMutateRelationResultMergeIncludeWrapper<
|
|
89
|
-
|
|
90
|
-
|
|
98
|
+
? TypeDtoMutateRelationResultMergeIncludeWrapper<
|
|
99
|
+
TMutateTypeTopLevel,
|
|
100
|
+
TModelOptions['relations'][RelationName],
|
|
101
|
+
TInclude[RelationName]
|
|
102
|
+
>
|
|
103
|
+
: TypeDtoMutateRelationResultMergeAutoload<
|
|
104
|
+
TMutateTypeTopLevel,
|
|
105
|
+
TModelOptions['relations'][RelationName]
|
|
106
|
+
>
|
|
107
|
+
: TypeDtoMutateRelationResultMergeAutoload<
|
|
108
|
+
TMutateTypeTopLevel,
|
|
109
|
+
TModelOptions['relations'][RelationName]
|
|
110
|
+
>;
|
|
91
111
|
};
|
|
92
112
|
|
|
93
113
|
type TypeDtoMutateModelRelationResultMergeWith<
|
|
94
114
|
TMutateTypeTopLevel extends TypeDtoMutateType,
|
|
95
115
|
TWith extends {} | undefined | unknown,
|
|
96
|
-
> = TWith extends {}
|
|
116
|
+
> = TWith extends {}
|
|
117
|
+
? {
|
|
118
|
+
[RelationName in keyof TWith]: TypeDtoMutateRelationResultMergeWithRelation<
|
|
119
|
+
TMutateTypeTopLevel,
|
|
120
|
+
TWith[RelationName]
|
|
121
|
+
>;
|
|
122
|
+
}
|
|
123
|
+
: {};
|
|
97
124
|
|
|
98
125
|
type TypeDtoMutateRelationResultMergeIncludeWrapper<
|
|
99
126
|
TMutateTypeTopLevel extends TypeDtoMutateType,
|
|
@@ -107,17 +134,27 @@ type TypeDtoMutateRelationResultMergeIncludeWrapper<
|
|
|
107
134
|
? TypeUtilGetDtoMutateRelationEntityByType<TMutateTypeTopLevel, Relation, IncludeWrapper>
|
|
108
135
|
: never;
|
|
109
136
|
|
|
110
|
-
type TypeDtoMutateRelationResultMergeAutoload<
|
|
137
|
+
type TypeDtoMutateRelationResultMergeAutoload<
|
|
138
|
+
TMutateTypeTopLevel extends TypeDtoMutateType,
|
|
139
|
+
Relation,
|
|
140
|
+
> =
|
|
111
141
|
TypeUtilGetRelationOptionsAutoload<Relation> extends true
|
|
112
142
|
? TypeUtilGetDtoMutateRelationEntityByType<TMutateTypeTopLevel, Relation, undefined>
|
|
113
143
|
: never;
|
|
114
144
|
|
|
115
|
-
type TypeDtoMutateRelationResultMergeWithRelation<
|
|
145
|
+
type TypeDtoMutateRelationResultMergeWithRelation<
|
|
146
|
+
TMutateTypeTopLevel extends TypeDtoMutateType,
|
|
147
|
+
WithRelation,
|
|
148
|
+
> = WithRelation extends false
|
|
116
149
|
? never
|
|
117
150
|
: WithRelation extends true
|
|
118
151
|
? never
|
|
119
152
|
: WithRelation extends {}
|
|
120
|
-
? TypeUtilGetDtoMutateRelationEntityByType<
|
|
153
|
+
? TypeUtilGetDtoMutateRelationEntityByType<
|
|
154
|
+
TMutateTypeTopLevel,
|
|
155
|
+
WithRelation,
|
|
156
|
+
TypeUtilGetRelationOptions<WithRelation>
|
|
157
|
+
>
|
|
121
158
|
: never;
|
|
122
159
|
|
|
123
160
|
type TypeUtilGetDtoMutateRelationEntityByType<
|
|
@@ -146,8 +183,32 @@ type TypeUtilGetDtoMutateEntityByType<
|
|
|
146
183
|
: TYPE extends 'belongsToMany'
|
|
147
184
|
? Array<{ id: TableIdentity; deleted?: boolean }> | undefined
|
|
148
185
|
: TYPE extends 'hasMany'
|
|
149
|
-
?
|
|
150
|
-
|
|
186
|
+
?
|
|
187
|
+
| Array<
|
|
188
|
+
TypeDtoMutateRelationResult<
|
|
189
|
+
TRecord,
|
|
190
|
+
TModel,
|
|
191
|
+
IncludeWrapper,
|
|
192
|
+
TMutateTypeTopLevel,
|
|
193
|
+
undefined,
|
|
194
|
+
false,
|
|
195
|
+
Columns,
|
|
196
|
+
REFKEY
|
|
197
|
+
>
|
|
198
|
+
>
|
|
199
|
+
| undefined
|
|
200
|
+
:
|
|
201
|
+
| TypeDtoMutateRelationResult<
|
|
202
|
+
TRecord,
|
|
203
|
+
TModel,
|
|
204
|
+
IncludeWrapper,
|
|
205
|
+
TMutateTypeTopLevel,
|
|
206
|
+
undefined,
|
|
207
|
+
false,
|
|
208
|
+
Columns,
|
|
209
|
+
REFKEY
|
|
210
|
+
>
|
|
211
|
+
| undefined;
|
|
151
212
|
|
|
152
213
|
type TypeDtoMutateRelationResultEntity<
|
|
153
214
|
TRecord,
|
|
@@ -157,7 +218,13 @@ type TypeDtoMutateRelationResultEntity<
|
|
|
157
218
|
TTopLevel extends boolean | undefined = undefined,
|
|
158
219
|
REFKEY = undefined,
|
|
159
220
|
> = TypeDtoMutateRelationResultPatch<
|
|
160
|
-
TypeDtoMutateRelationResultEntityInner<
|
|
221
|
+
TypeDtoMutateRelationResultEntityInner<
|
|
222
|
+
TRecord,
|
|
223
|
+
Columns,
|
|
224
|
+
TMutateTypeTopLevel,
|
|
225
|
+
TColumnsOmitDefault,
|
|
226
|
+
TTopLevel
|
|
227
|
+
>,
|
|
161
228
|
TMutateTypeTopLevel,
|
|
162
229
|
TTopLevel,
|
|
163
230
|
REFKEY
|
|
@@ -169,7 +236,10 @@ type TypeDtoMutateRelationResultPatch<
|
|
|
169
236
|
TTopLevel extends boolean | undefined = undefined,
|
|
170
237
|
REFKEY = undefined,
|
|
171
238
|
> = TTopLevel extends false
|
|
172
|
-
? TypeUtilEntityOmit<
|
|
239
|
+
? TypeUtilEntityOmit<
|
|
240
|
+
TypeDtoMutateRelationResultPatch2<TRecordResult, TMutateTypeTopLevel, TTopLevel>,
|
|
241
|
+
REFKEY
|
|
242
|
+
>
|
|
173
243
|
: TypeDtoMutateRelationResultPatch2<TRecordResult, TMutateTypeTopLevel, TTopLevel>;
|
|
174
244
|
|
|
175
245
|
type TypeDtoMutateRelationResultPatch2<
|
|
@@ -190,7 +260,11 @@ type TypeDtoMutateRelationResultEntityInner<
|
|
|
190
260
|
TTopLevel extends boolean | undefined = undefined,
|
|
191
261
|
> = [Columns] extends [string | string[]]
|
|
192
262
|
? TypeDtoMutateRelationResultEntityFromColumns<TRecord, Columns, TMutateTypeTopLevel, TTopLevel>
|
|
193
|
-
: TypeDtoMutateRelationResultEntityFromColumnsOmitDefault<
|
|
263
|
+
: TypeDtoMutateRelationResultEntityFromColumnsOmitDefault<
|
|
264
|
+
TRecord,
|
|
265
|
+
TMutateTypeTopLevel,
|
|
266
|
+
TColumnsOmitDefault
|
|
267
|
+
>;
|
|
194
268
|
|
|
195
269
|
type TypeDtoMutateRelationResultEntityFromColumns<
|
|
196
270
|
TRecord,
|
|
@@ -199,7 +273,13 @@ type TypeDtoMutateRelationResultEntityFromColumns<
|
|
|
199
273
|
TTopLevel extends boolean | undefined = undefined,
|
|
200
274
|
> = TypeUtilEntitySelector<
|
|
201
275
|
TRecord,
|
|
202
|
-
TypeUtilPrepareColumns<
|
|
276
|
+
TypeUtilPrepareColumns<
|
|
277
|
+
TypeDtoMutateRelationResultPrepareColumns<
|
|
278
|
+
TypeUtilPrepareColumns<Columns>,
|
|
279
|
+
TMutateTypeTopLevel,
|
|
280
|
+
TTopLevel
|
|
281
|
+
>
|
|
282
|
+
>
|
|
203
283
|
>;
|
|
204
284
|
|
|
205
285
|
type TypeDtoMutateRelationResultEntityFromColumnsOmitDefault<
|
|
@@ -208,7 +288,9 @@ type TypeDtoMutateRelationResultEntityFromColumnsOmitDefault<
|
|
|
208
288
|
TColumnsOmitDefault extends string | string[] | undefined = undefined,
|
|
209
289
|
> = TypeUtilEntityOmit<
|
|
210
290
|
TRecord,
|
|
211
|
-
TypeUtilPrepareColumns<
|
|
291
|
+
TypeUtilPrepareColumns<
|
|
292
|
+
TypeDtoMutateRelationResultPrepareColumnsOmitDefault<TMutateTypeTopLevel, TColumnsOmitDefault>
|
|
293
|
+
>
|
|
212
294
|
>;
|
|
213
295
|
|
|
214
296
|
type TypeDtoMutateRelationResultPrepareColumns<
|
|
@@ -13,6 +13,10 @@ export class DtoQueryBase {
|
|
|
13
13
|
@Api.field(v.optional(), z.looseObject({}))
|
|
14
14
|
where?: object;
|
|
15
15
|
|
|
16
|
-
@Api.field(
|
|
16
|
+
@Api.field(
|
|
17
|
+
v.default(ordersDefault),
|
|
18
|
+
v.optional(),
|
|
19
|
+
z.union([z.string(), z.array(z.array(z.string()))]),
|
|
20
|
+
)
|
|
17
21
|
orders?: string | string[][];
|
|
18
22
|
}
|