@ruiapp/rapid-core 0.8.6 → 0.8.7

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.
@@ -28,8 +28,8 @@ export default class EntityManager<TEntity = any> {
28
28
  constructor(server: IRpdServer, dataAccessor: IRpdDataAccessor);
29
29
  getModel(): RpdDataModel;
30
30
  findEntities(options: FindEntityOptions): Promise<TEntity[]>;
31
- findEntity(options: FindEntityOptions): Promise<TEntity | null>;
32
- findById(options: FindEntityByIdOptions | string | number): Promise<TEntity | null>;
31
+ findEntity(options: FindEntityOptions): Promise<TEntity | undefined>;
32
+ findById(options: FindEntityByIdOptions | string | number): Promise<TEntity | undefined>;
33
33
  createEntity(options: CreateEntityOptions, plugin?: RapidPlugin): Promise<TEntity>;
34
34
  updateEntityById(options: UpdateEntityByIdOptions, plugin?: RapidPlugin): Promise<TEntity>;
35
35
  count(options: CountEntityOptions): Promise<number>;
@@ -1,3 +1,3 @@
1
1
  import { IRpdServer } from "../core/server";
2
2
  import { RpdDataModel } from "../types";
3
- export declare function getEntityPartChanges(server: IRpdServer, model: RpdDataModel, before: any, after: any): Record<string, any> | null;
3
+ export declare function detectChangedFieldsOfEntity(server: IRpdServer, model: RpdDataModel, before: any, after: any): Record<string, any> | null;
package/dist/index.d.ts CHANGED
@@ -15,6 +15,7 @@ export * from "./utilities/accessControlUtility";
15
15
  export * from "./utilities/entityUtility";
16
16
  export * from "./utilities/jwtUtility";
17
17
  export * from "./utilities/timeUtility";
18
+ export * from "./helpers/entityHelpers";
18
19
  export * from "./helpers/licenseHelper";
19
20
  export * from "./deno-std/http/cookie";
20
21
  export { mapDbRowToEntity } from "./dataAccess/entityMapper";
package/dist/index.js CHANGED
@@ -2591,7 +2591,7 @@ function mapPropertyNameToColumnName(server, model, propertyName) {
2591
2591
  return property.columnName || property.code;
2592
2592
  }
2593
2593
 
2594
- function getEntityPartChanges(server, model, before, after) {
2594
+ function detectChangedFieldsOfEntity(server, model, before, after) {
2595
2595
  if (!before) {
2596
2596
  throw new Error("Argument 'before' can not be null.");
2597
2597
  }
@@ -3586,7 +3586,7 @@ async function updateEntityById(server, dataAccessor, options, plugin) {
3586
3586
  if (!entity) {
3587
3587
  throw new Error(`${model.namespace}.${model.singularCode} with id "${id}" was not found.`);
3588
3588
  }
3589
- let changes = getEntityPartChanges(server, model, entity, entityToSave);
3589
+ let changes = detectChangedFieldsOfEntity(server, model, entity, entityToSave);
3590
3590
  if (!changes && !options.operation) {
3591
3591
  return entity;
3592
3592
  }
@@ -3616,7 +3616,7 @@ async function updateEntityById(server, dataAccessor, options, plugin) {
3616
3616
  sender: plugin,
3617
3617
  routeContext: options.routeContext,
3618
3618
  });
3619
- changes = getEntityPartChanges(server, model, entity, entityToSave);
3619
+ changes = detectChangedFieldsOfEntity(server, model, entity, entityToSave);
3620
3620
  // check readonly properties
3621
3621
  Object.keys(changes).forEach((propertyName) => {
3622
3622
  let isReadonlyProperty = false;
@@ -9095,6 +9095,7 @@ exports.bootstrapApplicationConfig = bootstrapApplicationConfig$1;
9095
9095
  exports.createJwt = createJwt;
9096
9096
  exports.decodeJwt = decodeJwt;
9097
9097
  exports.deleteCookie = deleteCookie;
9098
+ exports.detectChangedFieldsOfEntity = detectChangedFieldsOfEntity;
9098
9099
  exports.generateJwtSecretKey = generateJwtSecretKey;
9099
9100
  exports.getCookies = getCookies;
9100
9101
  exports.getDateString = getDateString;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruiapp/rapid-core",
3
- "version": "0.8.6",
3
+ "version": "0.8.7",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -23,7 +23,7 @@ import { isNullOrUndefined } from "~/utilities/typeUtility";
23
23
  import { mapDbRowToEntity, mapEntityToDbRow } from "./entityMapper";
24
24
  import { mapPropertyNameToColumnName } from "./propertyMapper";
25
25
  import { IRpdServer, RapidPlugin } from "~/core/server";
26
- import { getEntityPartChanges } from "~/helpers/entityHelpers";
26
+ import { detectChangedFieldsOfEntity } from "~/helpers/entityHelpers";
27
27
  import {
28
28
  cloneDeep,
29
29
  concat,
@@ -1066,7 +1066,7 @@ async function updateEntityById(server: IRpdServer, dataAccessor: IRpdDataAccess
1066
1066
  throw new Error(`${model.namespace}.${model.singularCode} with id "${id}" was not found.`);
1067
1067
  }
1068
1068
 
1069
- let changes = getEntityPartChanges(server, model, entity, entityToSave);
1069
+ let changes = detectChangedFieldsOfEntity(server, model, entity, entityToSave);
1070
1070
  if (!changes && !options.operation) {
1071
1071
  return entity;
1072
1072
  }
@@ -1101,7 +1101,7 @@ async function updateEntityById(server: IRpdServer, dataAccessor: IRpdDataAccess
1101
1101
  routeContext: options.routeContext,
1102
1102
  });
1103
1103
 
1104
- changes = getEntityPartChanges(server, model, entity, entityToSave);
1104
+ changes = detectChangedFieldsOfEntity(server, model, entity, entityToSave);
1105
1105
 
1106
1106
  // check readonly properties
1107
1107
  Object.keys(changes).forEach((propertyName) => {
@@ -1792,11 +1792,11 @@ export default class EntityManager<TEntity = any> {
1792
1792
  return await findEntities(this.#server, this.#dataAccessor, options);
1793
1793
  }
1794
1794
 
1795
- async findEntity(options: FindEntityOptions): Promise<TEntity | null> {
1795
+ async findEntity(options: FindEntityOptions): Promise<TEntity | undefined> {
1796
1796
  return await findEntity(this.#server, this.#dataAccessor, options);
1797
1797
  }
1798
1798
 
1799
- async findById(options: FindEntityByIdOptions | string | number): Promise<TEntity | null> {
1799
+ async findById(options: FindEntityByIdOptions | string | number): Promise<TEntity | undefined> {
1800
1800
  // options is id
1801
1801
  if (!isObject(options)) {
1802
1802
  options = {
@@ -3,7 +3,7 @@ import { IRpdServer } from "~/core/server";
3
3
  import { getEntityPropertyByCode, isOneRelationProperty } from "~/helpers/metaHelper";
4
4
  import { RpdDataModel } from "~/types";
5
5
 
6
- export function getEntityPartChanges(server: IRpdServer, model: RpdDataModel, before: any, after: any): Record<string, any> | null {
6
+ export function detectChangedFieldsOfEntity(server: IRpdServer, model: RpdDataModel, before: any, after: any): Record<string, any> | null {
7
7
  if (!before) {
8
8
  throw new Error("Argument 'before' can not be null.");
9
9
  }
package/src/index.ts CHANGED
@@ -23,6 +23,7 @@ export * from "./utilities/entityUtility";
23
23
  export * from "./utilities/jwtUtility";
24
24
  export * from "./utilities/timeUtility";
25
25
 
26
+ export * from "./helpers/entityHelpers";
26
27
  export * from "./helpers/licenseHelper";
27
28
 
28
29
  export * from "./deno-std/http/cookie";