law-common 14.1.2-beta.1 → 14.1.2-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.
@@ -1,15 +1,8 @@
1
1
  import { PermissionGroupEnum } from "../../enums/permission_group_enum";
2
2
  /**
3
- * Registry of per-entity action maps used by {@link FlowConfigUtils}.
4
- *
5
- * Every entry maps an {@link EntityEnum} member to the `ACTION_MAP` declared by that entity's
6
- * flow config file. To register another entity: add `export` to its `ACTION_MAP` (only
7
- * expense_type and work_from_home export it today) and add one line here. The typing below
8
- * follows automatically:
9
- * the entity parameter and the action parameter of `getPermissionGroupByAction` both derive
10
- * from this object, so a new entity's actions are accepted only with that entity, and rejected
11
- * for every other entity — including actions from a different enum that share the same string
12
- * value (string enums are nominal across types).
3
+ * Registry of per-entity action maps; each value is the whole ACTION_MAP that entity's flow config exports
4
+ * (register one by exporting its ACTION_MAP and adding a line here). Entity and action params derive from it.
5
+ * Example: enumToActionMap[EntityEnum.WORK_FROM_HOME] → { CREATE, UPDATE, DELETE, APPROVE, REJECT, RECALL: ActionMapEntry }
13
6
  */
14
7
  export declare const enumToActionMap: {
15
8
  expense_type: {
@@ -79,32 +72,18 @@ export declare const enumToActionMap: {
79
72
  };
80
73
  export type EnumToActionMap = typeof enumToActionMap;
81
74
  /**
82
- * The action enum registered for entity `E`, derived from {@link enumToActionMap}.
83
- *
84
- * Written as a mapped-union lookup rather than `EnumToActionMap[E]`'s `keyof`: both forms are
85
- * strict at the call site, but only this form also lets the method body index the erased map
86
- * below without a cast (TS cannot resolve `EnumToActionMap[E][keyof EnumToActionMap[E]]` —
87
- * property access on that deferred generic indexed access is a compile error). Intersected
88
- * with `string` because a bare `keyof` constraint includes `symbol`, which forbids template
89
- * interpolation of the parameter (TS2731); map keys are always string enum members, so the
90
- * intersection loses nothing.
75
+ * Action enum values registered for entity `E`, via a mapped-union lookup (bare keyof would include symbol,
76
+ * breaking template interpolation — TS2731).
77
+ * Example: RegisteredActions<EntityEnum.WORK_FROM_HOME> → "CREATE" | "UPDATE" | "DELETE" | "APPROVE" | "REJECT" | "RECALL"
91
78
  */
92
79
  export type RegisteredActions<E extends keyof EnumToActionMap> = {
93
80
  [K in keyof EnumToActionMap]: keyof EnumToActionMap[K] & string;
94
81
  }[E];
95
82
  export declare class FlowConfigUtils {
96
83
  /**
97
- * Resolves the permission group an entity's action is authorised under, from the entity's
98
- * flat `ACTION_MAP`. Needs only the entity and the action — deliberately no status and no
99
- * existing entity — so callers building search filters can use it before any entity data
100
- * has been fetched.
101
- *
102
- * @param entity Registered entity; entities missing from `enumToActionMap` are compile errors.
103
- * @param action That entity's action enum member. A member of another entity's action enum
104
- * is a compile error even when its string value coincides.
105
- * @throws AppBadRequestException (400) when the registry, the action, or the action's
106
- * `group` annotation is missing. Never falls back to a default group: defaulting
107
- * would authorise the action under another action's permissions.
84
+ * Resolves the permission group an action is authorised under, from the entity's flat ACTION_MAP.
85
+ * Needs only entity + action (no status, no existing entity)
86
+ * Example: getPermissionGroupByAction(EntityEnum.WORK_FROM_HOME, WorkFromHomeActionEnum.APPROVE) → PermissionGroupEnum.APPROVAL_FLOW.
108
87
  */
109
88
  static getPermissionGroupByAction<E extends keyof EnumToActionMap>(entity: E, action: RegisteredActions<E>): PermissionGroupEnum;
110
89
  }
@@ -7,16 +7,9 @@ const entity_utils_interface_1 = require("../../interface/entity.utils.interface
7
7
  const expense_type_flow_config_1 = require("../expense_type_flow.config");
8
8
  const work_from_home_flow_config_1 = require("../work_from_home_flow.config");
9
9
  /**
10
- * Registry of per-entity action maps used by {@link FlowConfigUtils}.
11
- *
12
- * Every entry maps an {@link EntityEnum} member to the `ACTION_MAP` declared by that entity's
13
- * flow config file. To register another entity: add `export` to its `ACTION_MAP` (only
14
- * expense_type and work_from_home export it today) and add one line here. The typing below
15
- * follows automatically:
16
- * the entity parameter and the action parameter of `getPermissionGroupByAction` both derive
17
- * from this object, so a new entity's actions are accepted only with that entity, and rejected
18
- * for every other entity — including actions from a different enum that share the same string
19
- * value (string enums are nominal across types).
10
+ * Registry of per-entity action maps; each value is the whole ACTION_MAP that entity's flow config exports
11
+ * (register one by exporting its ACTION_MAP and adding a line here). Entity and action params derive from it.
12
+ * Example: enumToActionMap[EntityEnum.WORK_FROM_HOME] → { CREATE, UPDATE, DELETE, APPROVE, REJECT, RECALL: ActionMapEntry }
20
13
  */
21
14
  exports.enumToActionMap = {
22
15
  [entity_utils_interface_1.EntityEnum.EXPENSE_TYPE]: expense_type_flow_config_1.ACTION_MAP,
@@ -24,17 +17,9 @@ exports.enumToActionMap = {
24
17
  };
25
18
  class FlowConfigUtils {
26
19
  /**
27
- * Resolves the permission group an entity's action is authorised under, from the entity's
28
- * flat `ACTION_MAP`. Needs only the entity and the action — deliberately no status and no
29
- * existing entity — so callers building search filters can use it before any entity data
30
- * has been fetched.
31
- *
32
- * @param entity Registered entity; entities missing from `enumToActionMap` are compile errors.
33
- * @param action That entity's action enum member. A member of another entity's action enum
34
- * is a compile error even when its string value coincides.
35
- * @throws AppBadRequestException (400) when the registry, the action, or the action's
36
- * `group` annotation is missing. Never falls back to a default group: defaulting
37
- * would authorise the action under another action's permissions.
20
+ * Resolves the permission group an action is authorised under, from the entity's flat ACTION_MAP.
21
+ * Needs only entity + action (no status, no existing entity)
22
+ * Example: getPermissionGroupByAction(EntityEnum.WORK_FROM_HOME, WorkFromHomeActionEnum.APPROVE) → PermissionGroupEnum.APPROVAL_FLOW.
38
23
  */
39
24
  static getPermissionGroupByAction(entity, action) {
40
25
  const actionMap = exports.enumToActionMap[entity];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "law-common",
3
- "version": "14.1.2-beta.1",
3
+ "version": "14.1.2-beta.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [