@ruiapp/rapid-core 0.1.17 → 0.1.19

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 CHANGED
@@ -1643,8 +1643,13 @@ function mapDbRowToEntity(model, row, keepNonPropertyFields) {
1643
1643
  }
1644
1644
  }
1645
1645
  if (isRelationProp) {
1646
- if (row[propertyName] && !result[propertyName]) {
1647
- result[propertyName] = row[propertyName];
1646
+ if (row[propertyName]) {
1647
+ if (!result[propertyName]) {
1648
+ result[propertyName] = row[propertyName];
1649
+ }
1650
+ }
1651
+ else if (keepNonPropertyFields) {
1652
+ result[columnName] = row[columnName];
1648
1653
  }
1649
1654
  }
1650
1655
  else {
@@ -1,6 +1,7 @@
1
1
  import { IRpdServer } from "../../core/server";
2
2
  import { RpdServerEventTypes } from "../../types";
3
- export interface EntityWatcher<TEventName extends keyof RpdServerEventTypes> {
3
+ export type EntityWatcherType = EntityWatcher<"entity.create"> | EntityWatcher<"entity.update"> | EntityWatcher<"entity.delete"> | EntityWatcher<"entity.addRelations"> | EntityWatcher<"entity.removeRelations"> | EntityWatcher<any>;
4
+ export interface EntityWatcher<TEventName extends keyof RpdServerEventTypes = any> {
4
5
  eventName: TEventName;
5
6
  modelSingularCode: string;
6
7
  handler: EntityWatchHandler<TEventName>;
@@ -11,5 +12,5 @@ export type EntityWatchHandlerContext<TEventName extends keyof RpdServerEventTyp
11
12
  payload: RpdServerEventTypes[TEventName][1];
12
13
  };
13
14
  export interface EntityWatchPluginInitOptions {
14
- watchers: EntityWatcher<keyof RpdServerEventTypes>[];
15
+ watchers: EntityWatcherType[];
15
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruiapp/rapid-core",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "keywords": [],
@@ -31,8 +31,12 @@ export function mapDbRowToEntity(model: RpdDataModel, row: any, keepNonPropertyF
31
31
  }
32
32
 
33
33
  if (isRelationProp) {
34
- if (row[propertyName] && !result[propertyName]) {
35
- result[propertyName] = row[propertyName];
34
+ if (row[propertyName]) {
35
+ if (!result[propertyName]) {
36
+ result[propertyName] = row[propertyName];
37
+ }
38
+ } else if (keepNonPropertyFields) {
39
+ result[columnName] = row[columnName];
36
40
  }
37
41
  } else {
38
42
  if (!result[propertyName]) {
@@ -1,7 +1,6 @@
1
1
  import type { RpdEntityCreateEventPayload, RpdServerEventTypes } from "~/types";
2
-
3
2
  import { IRpdServer, RapidPlugin, RpdConfigurationItemOptions, RpdServerPluginConfigurableTargetOptions, RpdServerPluginExtendingAbilities } from "~/core/server";
4
- import { EntityWatchHandlerContext, EntityWatchPluginInitOptions, EntityWatcher } from "./EntityWatchPluginTypes";
3
+ import { EntityWatchHandlerContext, EntityWatchPluginInitOptions } from "./EntityWatchPluginTypes";
5
4
  import EventManager from "~/core/eventManager";
6
5
 
7
6
  class EntityWatchPlugin implements RapidPlugin {
@@ -1,7 +1,16 @@
1
1
  import { IRpdServer } from "~/core/server";
2
2
  import { RpdServerEventTypes } from "~/types";
3
3
 
4
- export interface EntityWatcher<TEventName extends keyof RpdServerEventTypes> {
4
+ export type EntityWatcherType =
5
+ | EntityWatcher<"entity.create">
6
+ | EntityWatcher<"entity.update">
7
+ | EntityWatcher<"entity.delete">
8
+ | EntityWatcher<"entity.addRelations">
9
+ | EntityWatcher<"entity.removeRelations">
10
+ | EntityWatcher<any>
11
+ ;
12
+
13
+ export interface EntityWatcher<TEventName extends keyof RpdServerEventTypes = any> {
5
14
  eventName: TEventName;
6
15
  modelSingularCode: string;
7
16
  handler: EntityWatchHandler<TEventName>;
@@ -15,5 +24,5 @@ export type EntityWatchHandlerContext<TEventName extends keyof RpdServerEventTyp
15
24
  }
16
25
 
17
26
  export interface EntityWatchPluginInitOptions {
18
- watchers: EntityWatcher<keyof RpdServerEventTypes>[];
27
+ watchers: EntityWatcherType[];
19
28
  }