@ruiapp/rapid-core 0.1.53 → 0.1.54
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/index.js +7 -0
- package/dist/types.d.ts +17 -0
- package/package.json +1 -1
- package/src/dataAccess/entityManager.ts +3 -0
- package/src/plugins/dataManage/actionHandlers/addEntityRelations.ts +3 -2
- package/src/plugins/dataManage/actionHandlers/createCollectionEntitiesBatch.ts +1 -0
- package/src/plugins/dataManage/actionHandlers/createCollectionEntity.ts +1 -0
- package/src/plugins/dataManage/actionHandlers/findCollectionEntities.ts +1 -0
- package/src/types.ts +17 -0
package/dist/index.js
CHANGED
|
@@ -2113,6 +2113,7 @@ async function findEntities(server, dataAccessor, options) {
|
|
|
2113
2113
|
}
|
|
2114
2114
|
const entities = rows.map((item) => mapDbRowToEntity(server, model, item, options.keepNonPropertyFields));
|
|
2115
2115
|
await server.emitEvent("entity.beforeResponse", {
|
|
2116
|
+
routerContext: options.routerContext,
|
|
2116
2117
|
namespace: model.namespace,
|
|
2117
2118
|
modelSingularCode: model.singularCode,
|
|
2118
2119
|
baseModelSingularCode: model.base,
|
|
@@ -2407,6 +2408,7 @@ async function createEntity(server, dataAccessor, options, plugin) {
|
|
|
2407
2408
|
const { entity } = options;
|
|
2408
2409
|
await server.beforeCreateEntity(model, options);
|
|
2409
2410
|
await server.emitEvent("entity.beforeCreate", {
|
|
2411
|
+
routerContext: options.routerContext,
|
|
2410
2412
|
namespace: model.namespace,
|
|
2411
2413
|
modelSingularCode: model.singularCode,
|
|
2412
2414
|
baseModelSingularCode: model.base,
|
|
@@ -2547,6 +2549,7 @@ async function createEntity(server, dataAccessor, options, plugin) {
|
|
|
2547
2549
|
}
|
|
2548
2550
|
}
|
|
2549
2551
|
await server.emitEvent("entity.create", {
|
|
2552
|
+
routerContext: options.routerContext,
|
|
2550
2553
|
namespace: model.namespace,
|
|
2551
2554
|
modelSingularCode: model.singularCode,
|
|
2552
2555
|
baseModelSingularCode: model.base,
|
|
@@ -3759,6 +3762,7 @@ const code$m = "findCollectionEntities";
|
|
|
3759
3762
|
async function handler$m(plugin, ctx, options) {
|
|
3760
3763
|
await runCollectionEntityActionHandler(ctx, options, code$m, async (entityManager, input) => {
|
|
3761
3764
|
input.filters = removeFiltersWithNullValue(input.filters);
|
|
3765
|
+
input.routerContext = ctx.routerContext;
|
|
3762
3766
|
const entities = await entityManager.findEntities(input);
|
|
3763
3767
|
const result = { list: entities };
|
|
3764
3768
|
if (input.pagination && !input.pagination.withoutTotal) {
|
|
@@ -3822,6 +3826,7 @@ async function handler$j(plugin, ctx, options) {
|
|
|
3822
3826
|
const entityManager = server.getEntityManager(options.singularCode);
|
|
3823
3827
|
const output = await entityManager.createEntity({
|
|
3824
3828
|
entity: input,
|
|
3829
|
+
routerContext: ctx.routerContext,
|
|
3825
3830
|
}, plugin);
|
|
3826
3831
|
ctx.output = output;
|
|
3827
3832
|
}
|
|
@@ -3851,6 +3856,7 @@ async function handler$i(plugin, ctx, options) {
|
|
|
3851
3856
|
const entityManager = server.getEntityManager(options.singularCode);
|
|
3852
3857
|
const newEntity = await entityManager.createEntity({
|
|
3853
3858
|
entity: mergedEntity,
|
|
3859
|
+
routerContext: ctx.routerContext,
|
|
3854
3860
|
}, plugin);
|
|
3855
3861
|
output.push(newEntity);
|
|
3856
3862
|
}
|
|
@@ -3911,6 +3917,7 @@ async function handler$f(plugin, ctx, options) {
|
|
|
3911
3917
|
const mergedInput = mergeInput(defaultInput, input, fixedInput);
|
|
3912
3918
|
logger.debug(`Running ${code$f} handler...`, { defaultInput, fixedInput, mergedInput });
|
|
3913
3919
|
const entityManager = server.getEntityManager(options.singularCode);
|
|
3920
|
+
mergedInput.routerContext = ctx.routerContext;
|
|
3914
3921
|
await entityManager.addRelations(mergedInput, plugin);
|
|
3915
3922
|
ctx.output = {};
|
|
3916
3923
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RouteContext } from "./core/routeContext";
|
|
1
2
|
import { IRpdServer, RapidPlugin } from "./core/server";
|
|
2
3
|
import { CountRowOptions, FindRowOptions } from "./dataAccess/dataAccessTypes";
|
|
3
4
|
export type RapidServerConfig = {
|
|
@@ -66,18 +67,21 @@ export type RpdServerEventTypes = {
|
|
|
66
67
|
"entity.beforeResponse": [RapidPlugin, RpdEntityBeforeResponseEventPayload];
|
|
67
68
|
};
|
|
68
69
|
export interface RpdEntityBeforeCreateEventPayload {
|
|
70
|
+
routerContext?: RouteContext;
|
|
69
71
|
namespace: string;
|
|
70
72
|
modelSingularCode: string;
|
|
71
73
|
baseModelSingularCode?: string;
|
|
72
74
|
before: any;
|
|
73
75
|
}
|
|
74
76
|
export interface RpdEntityCreateEventPayload {
|
|
77
|
+
routerContext?: RouteContext;
|
|
75
78
|
namespace: string;
|
|
76
79
|
modelSingularCode: string;
|
|
77
80
|
baseModelSingularCode?: string;
|
|
78
81
|
after: any;
|
|
79
82
|
}
|
|
80
83
|
export interface RpdEntityBeforeUpdateEventPayload {
|
|
84
|
+
routerContext?: RouteContext;
|
|
81
85
|
namespace: string;
|
|
82
86
|
modelSingularCode: string;
|
|
83
87
|
baseModelSingularCode?: string;
|
|
@@ -85,6 +89,7 @@ export interface RpdEntityBeforeUpdateEventPayload {
|
|
|
85
89
|
changes: any;
|
|
86
90
|
}
|
|
87
91
|
export interface RpdEntityUpdateEventPayload {
|
|
92
|
+
routerContext?: RouteContext;
|
|
88
93
|
namespace: string;
|
|
89
94
|
modelSingularCode: string;
|
|
90
95
|
baseModelSingularCode?: string;
|
|
@@ -93,18 +98,21 @@ export interface RpdEntityUpdateEventPayload {
|
|
|
93
98
|
changes: any;
|
|
94
99
|
}
|
|
95
100
|
export interface RpdEntityBeforeDeleteEventPayload {
|
|
101
|
+
routerContext?: RouteContext;
|
|
96
102
|
namespace: string;
|
|
97
103
|
modelSingularCode: string;
|
|
98
104
|
baseModelSingularCode?: string;
|
|
99
105
|
before: any;
|
|
100
106
|
}
|
|
101
107
|
export interface RpdEntityDeleteEventPayload {
|
|
108
|
+
routerContext?: RouteContext;
|
|
102
109
|
namespace: string;
|
|
103
110
|
modelSingularCode: string;
|
|
104
111
|
baseModelSingularCode?: string;
|
|
105
112
|
before: any;
|
|
106
113
|
}
|
|
107
114
|
export interface RpdEntityAddRelationsEventPayload {
|
|
115
|
+
routerContext?: RouteContext;
|
|
108
116
|
namespace: string;
|
|
109
117
|
modelSingularCode: string;
|
|
110
118
|
baseModelSingularCode?: string;
|
|
@@ -113,6 +121,7 @@ export interface RpdEntityAddRelationsEventPayload {
|
|
|
113
121
|
relations: any[];
|
|
114
122
|
}
|
|
115
123
|
export interface RpdEntityRemoveRelationsEventPayload {
|
|
124
|
+
routerContext?: RouteContext;
|
|
116
125
|
namespace: string;
|
|
117
126
|
modelSingularCode: string;
|
|
118
127
|
baseModelSingularCode?: string;
|
|
@@ -121,6 +130,7 @@ export interface RpdEntityRemoveRelationsEventPayload {
|
|
|
121
130
|
relations: any[];
|
|
122
131
|
}
|
|
123
132
|
export interface RpdEntityBeforeResponseEventPayload {
|
|
133
|
+
routerContext?: RouteContext;
|
|
124
134
|
namespace: string;
|
|
125
135
|
modelSingularCode: string;
|
|
126
136
|
baseModelSingularCode?: string;
|
|
@@ -335,6 +345,7 @@ export type EntityFilterOperators = EntityFilterRelationalOperators | EntityFilt
|
|
|
335
345
|
export type EntityFilterOptions = FindEntityRelationalFilterOptions | FindEntitySetFilterOptions | FindEntityLogicalFilterOptions | FindEntityUnaryFilterOptions | FindEntityExistenceFilterOptions;
|
|
336
346
|
export type EntityNonRelationPropertyFilterOptions = FindEntityRelationalFilterOptions | FindEntitySetFilterOptions | FindEntityUnaryFilterOptions;
|
|
337
347
|
export interface FindEntityOptions {
|
|
348
|
+
routerContext?: RouteContext;
|
|
338
349
|
filters?: EntityFilterOptions[];
|
|
339
350
|
orderBy?: FindEntityOrderByOptions[];
|
|
340
351
|
pagination?: FindEntityPaginationOptions;
|
|
@@ -381,22 +392,27 @@ export interface CountEntityResult {
|
|
|
381
392
|
count: number;
|
|
382
393
|
}
|
|
383
394
|
export interface CreateEntityOptions {
|
|
395
|
+
routerContext?: RouteContext;
|
|
384
396
|
entity: any;
|
|
385
397
|
}
|
|
386
398
|
export interface UpdateEntityOptions {
|
|
399
|
+
routerContext?: RouteContext;
|
|
387
400
|
filters?: EntityFilterOptions[];
|
|
388
401
|
entity: any;
|
|
389
402
|
}
|
|
390
403
|
export interface UpdateEntityByIdOptions {
|
|
404
|
+
routerContext?: RouteContext;
|
|
391
405
|
id: any;
|
|
392
406
|
entityToSave: any;
|
|
393
407
|
operation?: any;
|
|
394
408
|
stateProperties?: string[];
|
|
395
409
|
}
|
|
396
410
|
export interface DeleteEntityOptions {
|
|
411
|
+
routerContext?: RouteContext;
|
|
397
412
|
filters?: EntityFilterOptions[];
|
|
398
413
|
}
|
|
399
414
|
export interface AddEntityRelationsOptions {
|
|
415
|
+
routerContext?: RouteContext;
|
|
400
416
|
id: number;
|
|
401
417
|
property: string;
|
|
402
418
|
relations: {
|
|
@@ -405,6 +421,7 @@ export interface AddEntityRelationsOptions {
|
|
|
405
421
|
}[];
|
|
406
422
|
}
|
|
407
423
|
export interface RemoveEntityRelationsOptions {
|
|
424
|
+
routerContext?: RouteContext;
|
|
408
425
|
id: number;
|
|
409
426
|
property: string;
|
|
410
427
|
relations: {
|
package/package.json
CHANGED
|
@@ -196,6 +196,7 @@ async function findEntities(server: IRpdServer, dataAccessor: IRpdDataAccessor,
|
|
|
196
196
|
await server.emitEvent(
|
|
197
197
|
"entity.beforeResponse",
|
|
198
198
|
{
|
|
199
|
+
routerContext: options.routerContext,
|
|
199
200
|
namespace: model.namespace,
|
|
200
201
|
modelSingularCode: model.singularCode,
|
|
201
202
|
baseModelSingularCode: model.base,
|
|
@@ -512,6 +513,7 @@ async function createEntity(server: IRpdServer, dataAccessor: IRpdDataAccessor,
|
|
|
512
513
|
await server.emitEvent(
|
|
513
514
|
"entity.beforeCreate",
|
|
514
515
|
{
|
|
516
|
+
routerContext: options.routerContext,
|
|
515
517
|
namespace: model.namespace,
|
|
516
518
|
modelSingularCode: model.singularCode,
|
|
517
519
|
baseModelSingularCode: model.base,
|
|
@@ -665,6 +667,7 @@ async function createEntity(server: IRpdServer, dataAccessor: IRpdDataAccessor,
|
|
|
665
667
|
await server.emitEvent(
|
|
666
668
|
"entity.create",
|
|
667
669
|
{
|
|
670
|
+
routerContext: options.routerContext,
|
|
668
671
|
namespace: model.namespace,
|
|
669
672
|
modelSingularCode: model.singularCode,
|
|
670
673
|
baseModelSingularCode: model.base,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RunEntityActionHandlerOptions } from "~/types";
|
|
1
|
+
import { AddEntityRelationsOptions, RunEntityActionHandlerOptions } from "~/types";
|
|
2
2
|
import { mergeInput } from "~/helpers/inputHelper";
|
|
3
3
|
import { ActionHandlerContext } from "~/core/actionHandler";
|
|
4
4
|
import { RapidPlugin } from "~/core/server";
|
|
@@ -9,10 +9,11 @@ export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, op
|
|
|
9
9
|
const { logger, server, input } = ctx;
|
|
10
10
|
|
|
11
11
|
const { defaultInput, fixedInput } = options;
|
|
12
|
-
const mergedInput = mergeInput(defaultInput, input, fixedInput);
|
|
12
|
+
const mergedInput: AddEntityRelationsOptions = mergeInput(defaultInput, input, fixedInput);
|
|
13
13
|
logger.debug(`Running ${code} handler...`, { defaultInput, fixedInput, mergedInput });
|
|
14
14
|
|
|
15
15
|
const entityManager = server.getEntityManager(options.singularCode);
|
|
16
|
+
mergedInput.routerContext = ctx.routerContext;
|
|
16
17
|
await entityManager.addRelations(mergedInput, plugin);
|
|
17
18
|
|
|
18
19
|
ctx.output = {};
|
|
@@ -9,6 +9,7 @@ export const code = "findCollectionEntities";
|
|
|
9
9
|
export async function handler(plugin: RapidPlugin, ctx: ActionHandlerContext, options: RunEntityActionHandlerOptions) {
|
|
10
10
|
await runCollectionEntityActionHandler(ctx, options, code, async (entityManager, input: FindEntityOptions) => {
|
|
11
11
|
input.filters = removeFiltersWithNullValue(input.filters);
|
|
12
|
+
input.routerContext = ctx.routerContext;
|
|
12
13
|
const entities = await entityManager.findEntities(input);
|
|
13
14
|
const result: {
|
|
14
15
|
list: any;
|
package/src/types.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RouteContext } from "./core/routeContext";
|
|
1
2
|
import { IRpdServer, RapidPlugin } from "./core/server";
|
|
2
3
|
import { CountRowOptions, FindRowOptions } from "./dataAccess/dataAccessTypes";
|
|
3
4
|
|
|
@@ -79,6 +80,7 @@ export type RpdServerEventTypes = {
|
|
|
79
80
|
};
|
|
80
81
|
|
|
81
82
|
export interface RpdEntityBeforeCreateEventPayload {
|
|
83
|
+
routerContext?: RouteContext;
|
|
82
84
|
namespace: string;
|
|
83
85
|
modelSingularCode: string;
|
|
84
86
|
baseModelSingularCode?: string;
|
|
@@ -86,6 +88,7 @@ export interface RpdEntityBeforeCreateEventPayload {
|
|
|
86
88
|
}
|
|
87
89
|
|
|
88
90
|
export interface RpdEntityCreateEventPayload {
|
|
91
|
+
routerContext?: RouteContext;
|
|
89
92
|
namespace: string;
|
|
90
93
|
modelSingularCode: string;
|
|
91
94
|
baseModelSingularCode?: string;
|
|
@@ -93,6 +96,7 @@ export interface RpdEntityCreateEventPayload {
|
|
|
93
96
|
}
|
|
94
97
|
|
|
95
98
|
export interface RpdEntityBeforeUpdateEventPayload {
|
|
99
|
+
routerContext?: RouteContext;
|
|
96
100
|
namespace: string;
|
|
97
101
|
modelSingularCode: string;
|
|
98
102
|
baseModelSingularCode?: string;
|
|
@@ -101,6 +105,7 @@ export interface RpdEntityBeforeUpdateEventPayload {
|
|
|
101
105
|
}
|
|
102
106
|
|
|
103
107
|
export interface RpdEntityUpdateEventPayload {
|
|
108
|
+
routerContext?: RouteContext;
|
|
104
109
|
namespace: string;
|
|
105
110
|
modelSingularCode: string;
|
|
106
111
|
baseModelSingularCode?: string;
|
|
@@ -110,6 +115,7 @@ export interface RpdEntityUpdateEventPayload {
|
|
|
110
115
|
}
|
|
111
116
|
|
|
112
117
|
export interface RpdEntityBeforeDeleteEventPayload {
|
|
118
|
+
routerContext?: RouteContext;
|
|
113
119
|
namespace: string;
|
|
114
120
|
modelSingularCode: string;
|
|
115
121
|
baseModelSingularCode?: string;
|
|
@@ -117,6 +123,7 @@ export interface RpdEntityBeforeDeleteEventPayload {
|
|
|
117
123
|
}
|
|
118
124
|
|
|
119
125
|
export interface RpdEntityDeleteEventPayload {
|
|
126
|
+
routerContext?: RouteContext;
|
|
120
127
|
namespace: string;
|
|
121
128
|
modelSingularCode: string;
|
|
122
129
|
baseModelSingularCode?: string;
|
|
@@ -124,6 +131,7 @@ export interface RpdEntityDeleteEventPayload {
|
|
|
124
131
|
}
|
|
125
132
|
|
|
126
133
|
export interface RpdEntityAddRelationsEventPayload {
|
|
134
|
+
routerContext?: RouteContext;
|
|
127
135
|
namespace: string;
|
|
128
136
|
modelSingularCode: string;
|
|
129
137
|
baseModelSingularCode?: string;
|
|
@@ -133,6 +141,7 @@ export interface RpdEntityAddRelationsEventPayload {
|
|
|
133
141
|
}
|
|
134
142
|
|
|
135
143
|
export interface RpdEntityRemoveRelationsEventPayload {
|
|
144
|
+
routerContext?: RouteContext;
|
|
136
145
|
namespace: string;
|
|
137
146
|
modelSingularCode: string;
|
|
138
147
|
baseModelSingularCode?: string;
|
|
@@ -142,6 +151,7 @@ export interface RpdEntityRemoveRelationsEventPayload {
|
|
|
142
151
|
}
|
|
143
152
|
|
|
144
153
|
export interface RpdEntityBeforeResponseEventPayload {
|
|
154
|
+
routerContext?: RouteContext;
|
|
145
155
|
namespace: string;
|
|
146
156
|
modelSingularCode: string;
|
|
147
157
|
baseModelSingularCode?: string;
|
|
@@ -389,6 +399,7 @@ export type EntityFilterOptions = FindEntityRelationalFilterOptions | FindEntity
|
|
|
389
399
|
export type EntityNonRelationPropertyFilterOptions = FindEntityRelationalFilterOptions | FindEntitySetFilterOptions | FindEntityUnaryFilterOptions;
|
|
390
400
|
|
|
391
401
|
export interface FindEntityOptions {
|
|
402
|
+
routerContext?: RouteContext;
|
|
392
403
|
filters?: EntityFilterOptions[];
|
|
393
404
|
orderBy?: FindEntityOrderByOptions[];
|
|
394
405
|
pagination?: FindEntityPaginationOptions;
|
|
@@ -445,15 +456,18 @@ export interface CountEntityResult {
|
|
|
445
456
|
}
|
|
446
457
|
|
|
447
458
|
export interface CreateEntityOptions {
|
|
459
|
+
routerContext?: RouteContext;
|
|
448
460
|
entity: any;
|
|
449
461
|
}
|
|
450
462
|
|
|
451
463
|
export interface UpdateEntityOptions {
|
|
464
|
+
routerContext?: RouteContext;
|
|
452
465
|
filters?: EntityFilterOptions[];
|
|
453
466
|
entity: any;
|
|
454
467
|
}
|
|
455
468
|
|
|
456
469
|
export interface UpdateEntityByIdOptions {
|
|
470
|
+
routerContext?: RouteContext;
|
|
457
471
|
id: any;
|
|
458
472
|
entityToSave: any;
|
|
459
473
|
operation?: any;
|
|
@@ -461,16 +475,19 @@ export interface UpdateEntityByIdOptions {
|
|
|
461
475
|
}
|
|
462
476
|
|
|
463
477
|
export interface DeleteEntityOptions {
|
|
478
|
+
routerContext?: RouteContext;
|
|
464
479
|
filters?: EntityFilterOptions[];
|
|
465
480
|
}
|
|
466
481
|
|
|
467
482
|
export interface AddEntityRelationsOptions {
|
|
483
|
+
routerContext?: RouteContext;
|
|
468
484
|
id: number;
|
|
469
485
|
property: string;
|
|
470
486
|
relations: { id?: number; [k: string]: any }[];
|
|
471
487
|
}
|
|
472
488
|
|
|
473
489
|
export interface RemoveEntityRelationsOptions {
|
|
490
|
+
routerContext?: RouteContext;
|
|
474
491
|
id: number;
|
|
475
492
|
property: string;
|
|
476
493
|
relations: { id?: number; [k: string]: any }[];
|