@ruiapp/rapid-core 0.7.6 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bootstrapApplicationConfig.d.ts +40 -16
- package/dist/index.js +42 -4
- package/dist/types.d.ts +16 -0
- package/package.json +1 -1
- package/src/bootstrapApplicationConfig.ts +32 -0
- package/src/dataAccess/entityManager.ts +9 -3
- package/src/plugins/cronJob/CronJobPlugin.ts +1 -1
- package/src/types.ts +22 -0
|
@@ -18,10 +18,10 @@ declare const _default: {
|
|
|
18
18
|
required: true;
|
|
19
19
|
autoIncrement: true;
|
|
20
20
|
description?: undefined;
|
|
21
|
+
defaultValue?: undefined;
|
|
21
22
|
relation?: undefined;
|
|
22
23
|
targetSingularCode?: undefined;
|
|
23
24
|
selfIdColumnName?: undefined;
|
|
24
|
-
defaultValue?: undefined;
|
|
25
25
|
} | {
|
|
26
26
|
name: string;
|
|
27
27
|
code: string;
|
|
@@ -30,10 +30,10 @@ declare const _default: {
|
|
|
30
30
|
required: true;
|
|
31
31
|
autoIncrement?: undefined;
|
|
32
32
|
description?: undefined;
|
|
33
|
+
defaultValue?: undefined;
|
|
33
34
|
relation?: undefined;
|
|
34
35
|
targetSingularCode?: undefined;
|
|
35
36
|
selfIdColumnName?: undefined;
|
|
36
|
-
defaultValue?: undefined;
|
|
37
37
|
} | {
|
|
38
38
|
name: string;
|
|
39
39
|
code: string;
|
|
@@ -42,10 +42,10 @@ declare const _default: {
|
|
|
42
42
|
required: false;
|
|
43
43
|
autoIncrement?: undefined;
|
|
44
44
|
description?: undefined;
|
|
45
|
+
defaultValue?: undefined;
|
|
45
46
|
relation?: undefined;
|
|
46
47
|
targetSingularCode?: undefined;
|
|
47
48
|
selfIdColumnName?: undefined;
|
|
48
|
-
defaultValue?: undefined;
|
|
49
49
|
} | {
|
|
50
50
|
name: string;
|
|
51
51
|
description: string;
|
|
@@ -54,10 +54,22 @@ declare const _default: {
|
|
|
54
54
|
type: "json";
|
|
55
55
|
required: false;
|
|
56
56
|
autoIncrement?: undefined;
|
|
57
|
+
defaultValue?: undefined;
|
|
58
|
+
relation?: undefined;
|
|
59
|
+
targetSingularCode?: undefined;
|
|
60
|
+
selfIdColumnName?: undefined;
|
|
61
|
+
} | {
|
|
62
|
+
name: string;
|
|
63
|
+
code: string;
|
|
64
|
+
columnName: string;
|
|
65
|
+
type: "boolean";
|
|
66
|
+
required: true;
|
|
67
|
+
defaultValue: string;
|
|
68
|
+
autoIncrement?: undefined;
|
|
69
|
+
description?: undefined;
|
|
57
70
|
relation?: undefined;
|
|
58
71
|
targetSingularCode?: undefined;
|
|
59
72
|
selfIdColumnName?: undefined;
|
|
60
|
-
defaultValue?: undefined;
|
|
61
73
|
} | {
|
|
62
74
|
name: string;
|
|
63
75
|
code: string;
|
|
@@ -78,19 +90,7 @@ declare const _default: {
|
|
|
78
90
|
required: false;
|
|
79
91
|
autoIncrement?: undefined;
|
|
80
92
|
description?: undefined;
|
|
81
|
-
relation?: undefined;
|
|
82
|
-
targetSingularCode?: undefined;
|
|
83
|
-
selfIdColumnName?: undefined;
|
|
84
93
|
defaultValue?: undefined;
|
|
85
|
-
} | {
|
|
86
|
-
name: string;
|
|
87
|
-
code: string;
|
|
88
|
-
columnName: string;
|
|
89
|
-
type: "boolean";
|
|
90
|
-
required: true;
|
|
91
|
-
defaultValue: string;
|
|
92
|
-
autoIncrement?: undefined;
|
|
93
|
-
description?: undefined;
|
|
94
94
|
relation?: undefined;
|
|
95
95
|
targetSingularCode?: undefined;
|
|
96
96
|
selfIdColumnName?: undefined;
|
|
@@ -314,6 +314,18 @@ declare const _default: {
|
|
|
314
314
|
relation?: undefined;
|
|
315
315
|
targetSingularCode?: undefined;
|
|
316
316
|
selfIdColumnName?: undefined;
|
|
317
|
+
} | {
|
|
318
|
+
name: string;
|
|
319
|
+
code: string;
|
|
320
|
+
columnName: string;
|
|
321
|
+
type: "boolean";
|
|
322
|
+
required: true;
|
|
323
|
+
defaultValue: string;
|
|
324
|
+
autoIncrement?: undefined;
|
|
325
|
+
relation?: undefined;
|
|
326
|
+
targetSingularCode?: undefined;
|
|
327
|
+
selfIdColumnName?: undefined;
|
|
328
|
+
description?: undefined;
|
|
317
329
|
})[];
|
|
318
330
|
indexes?: undefined;
|
|
319
331
|
} | {
|
|
@@ -409,6 +421,18 @@ declare const _default: {
|
|
|
409
421
|
targetSingularCode?: undefined;
|
|
410
422
|
targetIdColumnName?: undefined;
|
|
411
423
|
defaultValue?: undefined;
|
|
424
|
+
} | {
|
|
425
|
+
name: string;
|
|
426
|
+
code: string;
|
|
427
|
+
columnName: string;
|
|
428
|
+
type: "boolean";
|
|
429
|
+
required: true;
|
|
430
|
+
defaultValue: string;
|
|
431
|
+
autoIncrement?: undefined;
|
|
432
|
+
relation?: undefined;
|
|
433
|
+
targetSingularCode?: undefined;
|
|
434
|
+
targetIdColumnName?: undefined;
|
|
435
|
+
description?: undefined;
|
|
412
436
|
})[];
|
|
413
437
|
indexes?: undefined;
|
|
414
438
|
})[];
|
package/dist/index.js
CHANGED
|
@@ -1734,6 +1734,14 @@ var bootstrapApplicationConfig = {
|
|
|
1734
1734
|
type: "text",
|
|
1735
1735
|
required: false,
|
|
1736
1736
|
},
|
|
1737
|
+
{
|
|
1738
|
+
name: "deprecated",
|
|
1739
|
+
code: "deprecated",
|
|
1740
|
+
columnName: "deprecated",
|
|
1741
|
+
type: "boolean",
|
|
1742
|
+
required: true,
|
|
1743
|
+
defaultValue: "false",
|
|
1744
|
+
},
|
|
1737
1745
|
{
|
|
1738
1746
|
name: "properties",
|
|
1739
1747
|
code: "properties",
|
|
@@ -1866,6 +1874,14 @@ var bootstrapApplicationConfig = {
|
|
|
1866
1874
|
type: "text",
|
|
1867
1875
|
required: true,
|
|
1868
1876
|
},
|
|
1877
|
+
{
|
|
1878
|
+
name: "deprecated",
|
|
1879
|
+
code: "deprecated",
|
|
1880
|
+
columnName: "deprecated",
|
|
1881
|
+
type: "boolean",
|
|
1882
|
+
required: true,
|
|
1883
|
+
defaultValue: "false",
|
|
1884
|
+
},
|
|
1869
1885
|
{
|
|
1870
1886
|
name: "required",
|
|
1871
1887
|
code: "required",
|
|
@@ -2096,6 +2112,14 @@ var bootstrapApplicationConfig = {
|
|
|
2096
2112
|
type: "json",
|
|
2097
2113
|
required: false,
|
|
2098
2114
|
},
|
|
2115
|
+
{
|
|
2116
|
+
name: "deprecated",
|
|
2117
|
+
code: "deprecated",
|
|
2118
|
+
columnName: "deprecated",
|
|
2119
|
+
type: "boolean",
|
|
2120
|
+
required: true,
|
|
2121
|
+
defaultValue: "false",
|
|
2122
|
+
},
|
|
2099
2123
|
],
|
|
2100
2124
|
},
|
|
2101
2125
|
{
|
|
@@ -2190,6 +2214,14 @@ var bootstrapApplicationConfig = {
|
|
|
2190
2214
|
type: "json",
|
|
2191
2215
|
required: false,
|
|
2192
2216
|
},
|
|
2217
|
+
{
|
|
2218
|
+
name: "deprecated",
|
|
2219
|
+
code: "deprecated",
|
|
2220
|
+
columnName: "deprecated",
|
|
2221
|
+
type: "boolean",
|
|
2222
|
+
required: true,
|
|
2223
|
+
defaultValue: "false",
|
|
2224
|
+
},
|
|
2193
2225
|
],
|
|
2194
2226
|
},
|
|
2195
2227
|
{
|
|
@@ -3429,7 +3461,10 @@ async function createEntity(server, dataAccessor, options, plugin) {
|
|
|
3429
3461
|
const targetDataAccessor = server.getDataAccessor({
|
|
3430
3462
|
singularCode: property.targetSingularCode,
|
|
3431
3463
|
});
|
|
3432
|
-
|
|
3464
|
+
let relatedEntitiesToBeSaved = entity[property.code];
|
|
3465
|
+
if (relatedEntitiesToBeSaved === null) {
|
|
3466
|
+
relatedEntitiesToBeSaved = [];
|
|
3467
|
+
}
|
|
3433
3468
|
if (!lodash.isArray(relatedEntitiesToBeSaved)) {
|
|
3434
3469
|
throw new Error(`Value of field '${property.code}' should be an array.`);
|
|
3435
3470
|
}
|
|
@@ -3743,7 +3778,10 @@ async function updateEntityById(server, dataAccessor, options, plugin) {
|
|
|
3743
3778
|
const targetDataAccessor = server.getDataAccessor({
|
|
3744
3779
|
singularCode: property.targetSingularCode,
|
|
3745
3780
|
});
|
|
3746
|
-
|
|
3781
|
+
let relatedEntitiesToBeSaved = changes[property.code];
|
|
3782
|
+
if (relatedEntitiesToBeSaved === null) {
|
|
3783
|
+
relatedEntitiesToBeSaved = [];
|
|
3784
|
+
}
|
|
3747
3785
|
if (!lodash.isArray(relatedEntitiesToBeSaved)) {
|
|
3748
3786
|
throw new Error(`Value of field '${property.code}' should be an array.`);
|
|
3749
3787
|
}
|
|
@@ -3790,7 +3828,7 @@ async function updateEntityById(server, dataAccessor, options, plugin) {
|
|
|
3790
3828
|
relationRemoveMode = "delete";
|
|
3791
3829
|
}
|
|
3792
3830
|
else {
|
|
3793
|
-
relationRemoveMode = updateRelationPropertiesOptions
|
|
3831
|
+
relationRemoveMode = updateRelationPropertiesOptions?.relationRemoveMode || "delete";
|
|
3794
3832
|
}
|
|
3795
3833
|
const relationModel = server.getModel({
|
|
3796
3834
|
singularCode: property.targetSingularCode,
|
|
@@ -8554,7 +8592,7 @@ class CronJobPlugin {
|
|
|
8554
8592
|
}
|
|
8555
8593
|
}
|
|
8556
8594
|
catch (ex) {
|
|
8557
|
-
logger.error(
|
|
8595
|
+
logger.error('Cron job "%s" execution error: %s', job.code, ex.message, { cronJobCode: job.code });
|
|
8558
8596
|
}
|
|
8559
8597
|
}
|
|
8560
8598
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -184,6 +184,10 @@ export interface RpdDataModel {
|
|
|
184
184
|
* Configure the property code to save derived type for base entity.
|
|
185
185
|
*/
|
|
186
186
|
derivedTypePropertyCode?: string;
|
|
187
|
+
/**
|
|
188
|
+
* Indicates whether the entity is deprecated.
|
|
189
|
+
*/
|
|
190
|
+
deprecated?: boolean;
|
|
187
191
|
/**
|
|
188
192
|
* Configure the property code used to display the entity.
|
|
189
193
|
*/
|
|
@@ -252,6 +256,10 @@ export interface RpdDataModelProperty {
|
|
|
252
256
|
* 字段类型。
|
|
253
257
|
*/
|
|
254
258
|
type: RpdDataPropertyTypes;
|
|
259
|
+
/**
|
|
260
|
+
* Indicates whether the property is deprecated.
|
|
261
|
+
*/
|
|
262
|
+
deprecated?: boolean;
|
|
255
263
|
/**
|
|
256
264
|
* 是否必须有值。默认为 false。
|
|
257
265
|
*/
|
|
@@ -368,6 +376,10 @@ export type RpdDataDictionary = {
|
|
|
368
376
|
* 本地化资源
|
|
369
377
|
*/
|
|
370
378
|
locales?: Record<string, RpdDataDictionaryLocale>;
|
|
379
|
+
/**
|
|
380
|
+
* Indicates whether the data dictionary is deprecated.
|
|
381
|
+
*/
|
|
382
|
+
deprecated?: boolean;
|
|
371
383
|
};
|
|
372
384
|
export type RpdDataDictionaryLocale = {
|
|
373
385
|
name: string;
|
|
@@ -413,6 +425,10 @@ export type RpdDataDictionaryEntry = {
|
|
|
413
425
|
* 本地化资源
|
|
414
426
|
*/
|
|
415
427
|
locales?: Record<string, RpdDataDictionaryEntryLocale>;
|
|
428
|
+
/**
|
|
429
|
+
* Indicates whether the data dictionary entry is deprecated.
|
|
430
|
+
*/
|
|
431
|
+
deprecated?: boolean;
|
|
416
432
|
};
|
|
417
433
|
/**
|
|
418
434
|
* 数据字典项本地化资源配置
|
package/package.json
CHANGED
|
@@ -122,6 +122,14 @@ export default {
|
|
|
122
122
|
type: "text",
|
|
123
123
|
required: false,
|
|
124
124
|
},
|
|
125
|
+
{
|
|
126
|
+
name: "deprecated",
|
|
127
|
+
code: "deprecated",
|
|
128
|
+
columnName: "deprecated",
|
|
129
|
+
type: "boolean",
|
|
130
|
+
required: true,
|
|
131
|
+
defaultValue: "false",
|
|
132
|
+
},
|
|
125
133
|
{
|
|
126
134
|
name: "properties",
|
|
127
135
|
code: "properties",
|
|
@@ -254,6 +262,14 @@ export default {
|
|
|
254
262
|
type: "text",
|
|
255
263
|
required: true,
|
|
256
264
|
},
|
|
265
|
+
{
|
|
266
|
+
name: "deprecated",
|
|
267
|
+
code: "deprecated",
|
|
268
|
+
columnName: "deprecated",
|
|
269
|
+
type: "boolean",
|
|
270
|
+
required: true,
|
|
271
|
+
defaultValue: "false",
|
|
272
|
+
},
|
|
257
273
|
{
|
|
258
274
|
name: "required",
|
|
259
275
|
code: "required",
|
|
@@ -484,6 +500,14 @@ export default {
|
|
|
484
500
|
type: "json",
|
|
485
501
|
required: false,
|
|
486
502
|
},
|
|
503
|
+
{
|
|
504
|
+
name: "deprecated",
|
|
505
|
+
code: "deprecated",
|
|
506
|
+
columnName: "deprecated",
|
|
507
|
+
type: "boolean",
|
|
508
|
+
required: true,
|
|
509
|
+
defaultValue: "false",
|
|
510
|
+
},
|
|
487
511
|
],
|
|
488
512
|
},
|
|
489
513
|
{
|
|
@@ -578,6 +602,14 @@ export default {
|
|
|
578
602
|
type: "json",
|
|
579
603
|
required: false,
|
|
580
604
|
},
|
|
605
|
+
{
|
|
606
|
+
name: "deprecated",
|
|
607
|
+
code: "deprecated",
|
|
608
|
+
columnName: "deprecated",
|
|
609
|
+
type: "boolean",
|
|
610
|
+
required: true,
|
|
611
|
+
defaultValue: "false",
|
|
612
|
+
},
|
|
581
613
|
],
|
|
582
614
|
},
|
|
583
615
|
{
|
|
@@ -951,7 +951,10 @@ async function createEntity(server: IRpdServer, dataAccessor: IRpdDataAccessor,
|
|
|
951
951
|
singularCode: property.targetSingularCode!,
|
|
952
952
|
});
|
|
953
953
|
|
|
954
|
-
|
|
954
|
+
let relatedEntitiesToBeSaved = entity[property.code];
|
|
955
|
+
if (relatedEntitiesToBeSaved === null) {
|
|
956
|
+
relatedEntitiesToBeSaved = [];
|
|
957
|
+
}
|
|
955
958
|
if (!isArray(relatedEntitiesToBeSaved)) {
|
|
956
959
|
throw new Error(`Value of field '${property.code}' should be an array.`);
|
|
957
960
|
}
|
|
@@ -1292,7 +1295,10 @@ async function updateEntityById(server: IRpdServer, dataAccessor: IRpdDataAccess
|
|
|
1292
1295
|
singularCode: property.targetSingularCode!,
|
|
1293
1296
|
});
|
|
1294
1297
|
|
|
1295
|
-
|
|
1298
|
+
let relatedEntitiesToBeSaved = changes[property.code];
|
|
1299
|
+
if (relatedEntitiesToBeSaved === null) {
|
|
1300
|
+
relatedEntitiesToBeSaved = [];
|
|
1301
|
+
}
|
|
1296
1302
|
if (!isArray(relatedEntitiesToBeSaved)) {
|
|
1297
1303
|
throw new Error(`Value of field '${property.code}' should be an array.`);
|
|
1298
1304
|
}
|
|
@@ -1353,7 +1359,7 @@ async function updateEntityById(server: IRpdServer, dataAccessor: IRpdDataAccess
|
|
|
1353
1359
|
if (updateRelationPropertiesOptions === true) {
|
|
1354
1360
|
relationRemoveMode = "delete";
|
|
1355
1361
|
} else {
|
|
1356
|
-
relationRemoveMode = updateRelationPropertiesOptions
|
|
1362
|
+
relationRemoveMode = updateRelationPropertiesOptions?.relationRemoveMode || "delete";
|
|
1357
1363
|
}
|
|
1358
1364
|
const relationModel = server.getModel({
|
|
1359
1365
|
singularCode: property.targetSingularCode,
|
|
@@ -109,7 +109,7 @@ class CronJobPlugin implements RapidPlugin {
|
|
|
109
109
|
await job.handler(handlerContext, job.handleOptions);
|
|
110
110
|
}
|
|
111
111
|
} catch (ex) {
|
|
112
|
-
logger.error(
|
|
112
|
+
logger.error('Cron job "%s" execution error: %s', job.code, ex.message, { cronJobCode: job.code });
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
}
|
package/src/types.ts
CHANGED
|
@@ -211,6 +211,12 @@ export interface RpdDataModel {
|
|
|
211
211
|
* Configure the property code to save derived type for base entity.
|
|
212
212
|
*/
|
|
213
213
|
derivedTypePropertyCode?: string;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Indicates whether the entity is deprecated.
|
|
217
|
+
*/
|
|
218
|
+
deprecated?: boolean;
|
|
219
|
+
|
|
214
220
|
/**
|
|
215
221
|
* Configure the property code used to display the entity.
|
|
216
222
|
*/
|
|
@@ -285,6 +291,12 @@ export interface RpdDataModelProperty {
|
|
|
285
291
|
* 字段类型。
|
|
286
292
|
*/
|
|
287
293
|
type: RpdDataPropertyTypes;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Indicates whether the property is deprecated.
|
|
297
|
+
*/
|
|
298
|
+
deprecated?: boolean;
|
|
299
|
+
|
|
288
300
|
/**
|
|
289
301
|
* 是否必须有值。默认为 false。
|
|
290
302
|
*/
|
|
@@ -437,6 +449,11 @@ export type RpdDataDictionary = {
|
|
|
437
449
|
* 本地化资源
|
|
438
450
|
*/
|
|
439
451
|
locales?: Record<string, RpdDataDictionaryLocale>;
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Indicates whether the data dictionary is deprecated.
|
|
455
|
+
*/
|
|
456
|
+
deprecated?: boolean;
|
|
440
457
|
};
|
|
441
458
|
|
|
442
459
|
export type RpdDataDictionaryLocale = {
|
|
@@ -492,6 +509,11 @@ export type RpdDataDictionaryEntry = {
|
|
|
492
509
|
* 本地化资源
|
|
493
510
|
*/
|
|
494
511
|
locales?: Record<string, RpdDataDictionaryEntryLocale>;
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Indicates whether the data dictionary entry is deprecated.
|
|
515
|
+
*/
|
|
516
|
+
deprecated?: boolean;
|
|
495
517
|
};
|
|
496
518
|
|
|
497
519
|
/**
|