law-common 10.21.1-beta.1 → 10.21.1-beta.2

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.
@@ -14,9 +14,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.ConvertToCommonEntity = ConvertToCommonEntity;
15
15
  exports.ConvertApiToEntity = ConvertApiToEntity;
16
16
  function ConvertToCommonEntity(obj) {
17
- var _a, _b;
18
17
  const { createdOn: _, updatedOn: __ } = obj, objectToAssign = __rest(obj, ["createdOn", "updatedOn"]);
19
- return Object.assign({ createdOn: (_a = obj.createdOn) === null || _a === void 0 ? void 0 : _a.toISOString(), updatedOn: (_b = obj.updatedOn) === null || _b === void 0 ? void 0 : _b.toISOString() }, objectToAssign);
18
+ const dateTransformerObj = {};
19
+ if (obj.createdOn) {
20
+ dateTransformerObj["createdOn"] = obj.createdOn.toISOString();
21
+ }
22
+ if (obj.updatedOn) {
23
+ dateTransformerObj["updatedOn"] = obj.updatedOn.toISOString();
24
+ }
25
+ return Object.assign(Object.assign({}, dateTransformerObj), objectToAssign);
20
26
  }
21
27
  function ConvertApiToEntity(obj) {
22
28
  const { createdOn: _, updatedOn: __ } = obj, objectToAssign = __rest(obj, ["createdOn", "updatedOn"]);
@@ -11,3 +11,8 @@ export declare const entityEnumToEntityModel: {
11
11
  export declare function entityMapToModels(entityMap: EntityMap): void;
12
12
  export declare function parseEntities<T extends EnumEntityType<EntityEnum | VirtualEntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum | VirtualEntityEnum, entityMap: EntityMap): EntityMap;
13
13
  export declare function entityMapToEntityIndexMap(entityMap: EntityMap, entityRelationsFor: EntityEnum[]): EntityIndexMap;
14
+ export declare function parseEntitiesWithoutModels<T extends EnumEntityType<EntityEnum | VirtualEntityEnum>>(json: IBaseEntityApiResponse<T>, baseEntity: EntityEnum | VirtualEntityEnum, entityMap?: {
15
+ [E in EntityEnum | VirtualEntityEnum]?: IApiEntity<EnumEntityType<E>>[];
16
+ }): {
17
+ [E in EntityEnum | VirtualEntityEnum]?: IApiEntity<EnumEntityType<E>>[];
18
+ };
@@ -7,6 +7,7 @@ exports.populateRelationsFor = populateRelationsFor;
7
7
  exports.entityMapToModels = entityMapToModels;
8
8
  exports.parseEntities = parseEntities;
9
9
  exports.entityMapToEntityIndexMap = entityMapToEntityIndexMap;
10
+ exports.parseEntitiesWithoutModels = parseEntitiesWithoutModels;
10
11
  const entity_utils_interface_1 = require("../interface/entity.utils.interface");
11
12
  const bank_entity_model_1 = require("./bank.entity.model");
12
13
  const base_entity_model_1 = require("./base.entity.model");
@@ -103,3 +104,19 @@ function entityMapToEntityIndexMap(entityMap, entityRelationsFor) {
103
104
  populateRelationsFor(entityIndexMap, entityRelationsFor);
104
105
  return entityIndexMap;
105
106
  }
107
+ function parseEntitiesWithoutModels(json, baseEntity, entityMap = {}) {
108
+ var _a;
109
+ if (!(baseEntity in exports.entityEnumToEntityModel)) {
110
+ throw new Error(`Unknown entity: ${baseEntity}`);
111
+ }
112
+ entityMap[baseEntity] = ((_a = json["baseEntities"]) !== null && _a !== void 0 ? _a : []);
113
+ if (json["relatedEntities"]) {
114
+ const relatedEntities = json["relatedEntities"];
115
+ for (const entityName in relatedEntities) {
116
+ parseEntitiesWithoutModels(
117
+ // @ts-ignore
118
+ relatedEntities[entityName], entityName, entityMap);
119
+ }
120
+ }
121
+ return entityMap;
122
+ }
@@ -22,7 +22,9 @@ export declare function getPermittedActions<T extends LeaveStatusActionPair, E>(
22
22
  };
23
23
  };
24
24
  };
25
- }, currentStatus: T['status'] | null, userPermissions: string[], combineActions?: T['action'][], data?: (a: E) => {
25
+ }, currentStatus: T['status'] | null, userPermissions: string[], combineActions?: T['action'][], actionLabels?: {
26
+ [key in T['action']]?: string;
27
+ }, data?: (a: E) => {
26
28
  [key: string]: () => boolean;
27
29
  }): {
28
30
  label: string;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPermittedActions = getPermittedActions;
4
- const entities_1 = require("../entities");
5
4
  /**
6
5
  * Gets available actions for a leave based on current status and user permissions
7
6
  * @param entityFlowConfig - The flow configuration for the entity
@@ -12,7 +11,7 @@ const entities_1 = require("../entities");
12
11
  * @returns Array of available actions with labels and values
13
12
  * @throws Error if user has multiple permissions for a single action
14
13
  */
15
- function getPermittedActions(entityFlowConfig, currentStatus, userPermissions, combineActions = [], data = (_) => ({})) {
14
+ function getPermittedActions(entityFlowConfig, currentStatus, userPermissions, combineActions = [], actionLabels = {}, data = (_) => ({})) {
16
15
  var _a;
17
16
  // Handle invalid inputs
18
17
  if (!currentStatus || !entityFlowConfig[currentStatus]) {
@@ -32,7 +31,7 @@ function getPermittedActions(entityFlowConfig, currentStatus, userPermissions, c
32
31
  return matchingPermissions.length > 0 && (!data || !data({})[matchingPermissions[0]] || data({})[matchingPermissions[0]]());
33
32
  })
34
33
  .map(([actionKey, _]) => ({
35
- label: entities_1.LeaveActionEnum.getLabel(actionKey) || '',
34
+ label: actionLabels[actionKey] || actionKey,
36
35
  value: actionKey,
37
36
  }));
38
37
  // // Combine specified actions if all are present and combineActions is not empty
@@ -42,9 +41,7 @@ function getPermittedActions(entityFlowConfig, currentStatus, userPermissions, c
42
41
  return [
43
42
  ...permittedActions.filter((action) => !combineActions.includes(action.value)),
44
43
  {
45
- label: combineActions
46
- .map((a) => entities_1.LeaveActionEnum.getLabel(a) || '')
47
- .join('/'),
44
+ label: actionLabels[combineActions.join('_')] || combineActions.join('_'),
48
45
  value: combineActions.join('_'),
49
46
  },
50
47
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "law-common",
3
- "version": "10.21.1-beta.1",
3
+ "version": "10.21.1-beta.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [