@zeniai/client-epic-state 5.0.82-betaAN1 → 5.0.82-betaAR2

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.
Files changed (48) hide show
  1. package/lib/entity/aiCfo/aiCfoPayload.d.ts +0 -1
  2. package/lib/entity/aiCfo/aiCfoReducer.js +1 -3
  3. package/lib/entity/aiCfo/aiCfoState.d.ts +0 -1
  4. package/lib/entity/approvalRule/approvalRulePayload.d.ts +34 -5
  5. package/lib/entity/approvalRule/approvalRulePayload.js +130 -10
  6. package/lib/entity/approvalRule/approvalRuleSelector.d.ts +25 -1
  7. package/lib/entity/approvalRule/approvalRuleSelector.js +40 -0
  8. package/lib/entity/approvalRule/approvalRuleState.d.ts +59 -7
  9. package/lib/esm/entity/aiCfo/aiCfoReducer.js +1 -3
  10. package/lib/esm/entity/approvalRule/approvalRulePayload.js +130 -10
  11. package/lib/esm/entity/approvalRule/approvalRuleSelector.js +35 -0
  12. package/lib/esm/index.js +2 -1
  13. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.js +29 -11
  14. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/deleteBillPayApprovalRuleEpic.js +11 -2
  15. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/fetchBillPaySetupApproverViewEpic.js +9 -4
  16. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/initializeBillPaySetupApproverViewUpdateDataEpic.js +11 -7
  17. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/saveBillPaySetupApproverViewUpdatesEpic.js +14 -4
  18. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +122 -16
  19. package/lib/esm/view/spendManagement/billPay/editBillView/editBillViewSelector.js +7 -2
  20. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/deleteRemiApprovalRuleEpic.js +11 -2
  21. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/fetchRemiSetupApproverViewEpic.js +9 -2
  22. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +11 -7
  23. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/saveRemiSetupApproverViewUpdatesEpic.js +14 -4
  24. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +28 -10
  25. package/lib/index.d.ts +3 -2
  26. package/lib/index.js +22 -16
  27. package/lib/view/companyTaskManagerView/companyTaskManagerViewReducer.d.ts +2 -2
  28. package/lib/view/companyView/types/cockpitTypes.d.ts +1 -1
  29. package/lib/view/people/peopleTypes.d.ts +1 -1
  30. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.d.ts +7 -3
  31. package/lib/view/spendManagement/billPay/billPaySetupApproverView/billPaySetupApproverViewReducer.js +29 -11
  32. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/deleteBillPayApprovalRuleEpic.js +11 -2
  33. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/fetchBillPaySetupApproverViewEpic.js +9 -4
  34. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/initializeBillPaySetupApproverViewUpdateDataEpic.js +10 -6
  35. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/saveBillPaySetupApproverViewUpdatesEpic.js +13 -3
  36. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.d.ts +50 -1
  37. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +124 -17
  38. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonState.d.ts +31 -5
  39. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +7 -2
  40. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
  41. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/deleteRemiApprovalRuleEpic.js +11 -2
  42. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/fetchRemiSetupApproverViewEpic.js +9 -2
  43. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +10 -6
  44. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/saveRemiSetupApproverViewUpdatesEpic.js +13 -3
  45. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.d.ts +7 -3
  46. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/remiSetupApproverViewReducer.js +28 -10
  47. package/lib/view/taskManager/taskListView/taskList.d.ts +3 -3
  48. package/package.json +1 -1
@@ -1,23 +1,51 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toApprovalChangableInfoPayload = void 0;
3
+ exports.toApprovalChangableInfoPayloadV1 = exports.toApprovalChangableInfoPayload = void 0;
4
4
  const toApprovalChangableInfoPayload = (approverViewUpdateData) => {
5
- let criteriaPayload = [];
5
+ // Form-side criteria is a structured object with optional slots for
6
+ // amount / vendor / department; flatten it into the wire format's
7
+ // `conditions[]` array.
8
+ let criteriaPayload;
6
9
  if (approverViewUpdateData.criteria != null) {
7
- const criteria = approverViewUpdateData.criteria;
8
- const { rangeType, rangeEntity, range } = criteria;
9
- const { min, max } = range;
10
- const { currencyCode, currencySymbol } = min;
11
- criteriaPayload = [
12
- {
13
- type: rangeType,
14
- range_entity: rangeEntity,
15
- min: min.amount,
16
- max: max?.amount ?? null,
17
- currency_code: currencyCode,
18
- currency_symbol: currencySymbol,
19
- },
20
- ];
10
+ const { amount, vendor, department } = approverViewUpdateData.criteria;
11
+ const conditions = [];
12
+ if (amount?.min != null) {
13
+ conditions.push({
14
+ field: 'amount',
15
+ type: 'gte',
16
+ value: amount.min.amount,
17
+ });
18
+ }
19
+ if (amount?.max != null) {
20
+ conditions.push({
21
+ field: 'amount',
22
+ type: 'lte',
23
+ value: amount.max.amount,
24
+ });
25
+ }
26
+ if (vendor != null && vendor.vendorIds.length > 0) {
27
+ conditions.push({
28
+ field: 'vendor_id',
29
+ type: vendor.operator === 'is_not' ? 'not_in' : 'in',
30
+ value: vendor.vendorIds,
31
+ });
32
+ }
33
+ if (department != null && department.departmentIds.length > 0) {
34
+ conditions.push({
35
+ field: 'department_id',
36
+ type: department.operator === 'is_not' ? 'not_in' : 'in',
37
+ value: department.departmentIds,
38
+ });
39
+ }
40
+ if (conditions.length > 0) {
41
+ const currency = amount?.min ?? amount?.max ?? null;
42
+ criteriaPayload = {
43
+ conditions,
44
+ criteria_operator: 'and',
45
+ currency_code: currency?.currencyCode ?? 'USD',
46
+ currency_symbol: currency?.currencySymbol ?? '$',
47
+ };
48
+ }
21
49
  }
22
50
  const steps = approverViewUpdateData.steps.map((step) => {
23
51
  return {
@@ -38,13 +66,92 @@ const toApprovalChangableInfoPayload = (approverViewUpdateData) => {
38
66
  });
39
67
  const isUpdate = approverViewUpdateData.approvalRuleId != null;
40
68
  const payload = {
41
- criteria: criteriaPayload,
42
69
  steps,
43
70
  is_applicable_on_pending_approval_entity: approverViewUpdateData.isApplicableOnPendingApprovalEntity ?? true,
44
71
  };
72
+ if (criteriaPayload != null) {
73
+ payload.criteria = criteriaPayload;
74
+ }
75
+ // Approval Rules 3.0 — surface rule-level fields when the form set them.
76
+ // Send only what the user actually entered: an undefined value means
77
+ // "no opinion" and stays off the wire.
78
+ if (approverViewUpdateData.name != null) {
79
+ payload.name = approverViewUpdateData.name;
80
+ }
81
+ if (approverViewUpdateData.description != null) {
82
+ payload.description = approverViewUpdateData.description;
83
+ }
84
+ if (approverViewUpdateData.separationOfDuties != null) {
85
+ payload.is_separation_of_duty_enabled =
86
+ approverViewUpdateData.separationOfDuties;
87
+ }
88
+ if (approverViewUpdateData.isFallback != null) {
89
+ payload.is_fallback = approverViewUpdateData.isFallback;
90
+ }
45
91
  if (isUpdate) {
46
92
  payload.approval_rule_id = approverViewUpdateData.approvalRuleId;
47
93
  }
48
94
  return payload;
49
95
  };
50
96
  exports.toApprovalChangableInfoPayload = toApprovalChangableInfoPayload;
97
+ /**
98
+ * V1 wire mapper — used when `approval_rule_v3_config` resolves to OFF
99
+ * for the current tenant. Translates the form-side amount criteria into
100
+ * the legacy `{rangeType, rangeEntity, range: {min, max}}` shape. The
101
+ * V1 backend does not understand vendor / department criteria or the
102
+ * rule-level 3.0 fields, so those are dropped on the wire.
103
+ *
104
+ * The form-side amount slot is always read as a `range`-style criteria
105
+ * here: V1 schemas only supported ranges, so an absent `min` or `max`
106
+ * falls back to `0` / `Number.MAX_SAFE_INTEGER`.
107
+ */
108
+ const toApprovalChangableInfoPayloadV1 = (approverViewUpdateData) => {
109
+ const amount = approverViewUpdateData.criteria?.amount;
110
+ const minAmount = amount?.min;
111
+ const maxAmount = amount?.max;
112
+ const currencyCode = minAmount?.currencyCode ?? maxAmount?.currencyCode ?? 'USD';
113
+ const currencySymbol = minAmount?.currencySymbol ?? maxAmount?.currencySymbol ?? '$';
114
+ const steps = approverViewUpdateData.steps.map((step) => {
115
+ return {
116
+ action: step.action,
117
+ operator: step.operator,
118
+ actors: step.actors
119
+ .filter((actor) => actor.subType !== 'admin')
120
+ .map((actor) => {
121
+ return {
122
+ type: actor.type,
123
+ id: actor.userId ?? null,
124
+ sub_type: actor.subType ?? null,
125
+ id_type: actor.idType ?? null,
126
+ is_implicit_actor: actor.isImplicitActor ?? false,
127
+ };
128
+ }),
129
+ };
130
+ });
131
+ const isUpdate = approverViewUpdateData.approvalRuleId != null;
132
+ const payload = {
133
+ steps,
134
+ is_applicable_on_pending_approval_entity: approverViewUpdateData.isApplicableOnPendingApprovalEntity ?? true,
135
+ criteria: {
136
+ rangeType: 'range',
137
+ rangeEntity: 'currency',
138
+ range: {
139
+ min: {
140
+ amount: minAmount?.amount ?? 0,
141
+ currencyCode,
142
+ currencySymbol,
143
+ },
144
+ max: {
145
+ amount: maxAmount?.amount ?? Number.MAX_SAFE_INTEGER,
146
+ currencyCode,
147
+ currencySymbol,
148
+ },
149
+ },
150
+ },
151
+ };
152
+ if (isUpdate) {
153
+ payload.approval_rule_id = approverViewUpdateData.approvalRuleId;
154
+ }
155
+ return payload;
156
+ };
157
+ exports.toApprovalChangableInfoPayloadV1 = toApprovalChangableInfoPayloadV1;
@@ -1,19 +1,45 @@
1
1
  import { FetchStateAndError, ID } from '../../../../../commonStateTypes/common';
2
- import { Criteria, Step } from '../../../../../entity/approvalRule/approvalRuleState';
2
+ import { AmountCriteria, DepartmentCriteria, Step, VendorCriteria } from '../../../../../entity/approvalRule/approvalRuleState';
3
3
  export type ApprovalUpdateActionType = 'approval_create' | 'approval_update';
4
4
  export interface ApproverViewUpdateData {
5
5
  type: ApprovalUpdateActionType;
6
6
  updateStatus: FetchStateAndError;
7
7
  data?: ApprovalRuleUpdateData | ApprovalRuleCreateData;
8
8
  }
9
- export interface ApprovalRuleUpdateData {
9
+ /**
10
+ * Form-side criteria shape used by the rule create/edit form.
11
+ *
12
+ * Each condition kind gets its own optional slot, mirroring how the UI
13
+ * edits them as distinct rows. At most one of each kind is present; this
14
+ * matches the design constraint that each condition type can be added once.
15
+ */
16
+ export interface ApprovalRuleFormCriteria {
17
+ amount?: AmountCriteria;
18
+ department?: DepartmentCriteria;
19
+ vendor?: VendorCriteria;
20
+ }
21
+ /**
22
+ * Rule-level fields shared by both create and update flows.
23
+ *
24
+ * These come from the 3.0 design: the form now owns a name, an optional
25
+ * description, an optional Separation-of-Duties toggle, and a flag that
26
+ * marks the rule as the org-wide fallback rule. They live alongside
27
+ * criteria/steps but are not part of either.
28
+ */
29
+ export interface ApprovalRuleFormBase {
30
+ description?: string;
31
+ isFallback?: boolean;
32
+ name?: string;
33
+ separationOfDuties?: boolean;
34
+ }
35
+ export interface ApprovalRuleUpdateData extends ApprovalRuleFormBase {
10
36
  approvalRuleId: ID;
11
- criteria: Criteria;
37
+ criteria: ApprovalRuleFormCriteria;
12
38
  steps: Step[];
13
39
  isApplicableOnPendingApprovalEntity?: boolean;
14
40
  }
15
- export interface ApprovalRuleCreateData {
16
- criteria: Criteria;
41
+ export interface ApprovalRuleCreateData extends ApprovalRuleFormBase {
42
+ criteria: ApprovalRuleFormCriteria;
17
43
  steps: Step[];
18
44
  isApplicableOnPendingApprovalEntity?: boolean;
19
45
  }
@@ -9,6 +9,7 @@ exports.getPaymentSection = getPaymentSection;
9
9
  exports.toPaymentToOption = toPaymentToOption;
10
10
  const get_1 = __importDefault(require("lodash/get"));
11
11
  const has_1 = __importDefault(require("lodash/has"));
12
+ const approvalRuleSelector_1 = require("../../../../entity/approvalRule/approvalRuleSelector");
12
13
  const reduceFetchState_1 = require("../../../../commonStateTypes/reduceFetchState");
13
14
  const bankAccountSelector_1 = require("../../../../entity/bankAccount/bankAccountSelector");
14
15
  const contactSelector_1 = require("../../../../entity/billPay/contact/contactSelector");
@@ -698,9 +699,13 @@ exports.getDefaultWithdrawFromAccount = getDefaultWithdrawFromAccount;
698
699
  const checkIfCreatorIsApprover = (billAmount, approvalRules, signedInUser) => {
699
700
  let isCreatorAlsoApprover = false;
700
701
  const approvalRule = approvalRules.find((rule) => {
701
- const { max, min } = rule.criteria[0].range;
702
+ const amountCriteria = (0, approvalRuleSelector_1.getAmountCriteria)(rule.criteria);
703
+ if (amountCriteria?.min == null) {
704
+ return false;
705
+ }
706
+ const { min, max } = amountCriteria;
702
707
  return (billAmount > min.amount &&
703
- (max?.amount != null ? billAmount <= max?.amount : true));
708
+ (max?.amount != null ? billAmount <= max.amount : true));
704
709
  });
705
710
  if (approvalRule != null) {
706
711
  const requireApprovalSteps = approvalRule.steps.filter((step) => step.action === 'require_approval');
@@ -61,7 +61,7 @@ export declare const initialCreditAcc: CreditAccount;
61
61
  export declare const initialDebitCardSummaries: DebitCardSummaries;
62
62
  export declare const initialResendRevokeCardInvite: ResendRevokeCardInvite;
63
63
  export declare const initialCreditAccountRepayment: CreditAccountRepayment;
64
- export declare const toChargeCardSortKeyType: (v: string) => "status" | "accountType" | "owner" | "cardName" | "limit" | "department" | "cardType" | "utilisation";
64
+ export declare const toChargeCardSortKeyType: (v: string) => "status" | "department" | "accountType" | "owner" | "cardName" | "limit" | "cardType" | "utilisation";
65
65
  export declare type ChargeCardViewSortKey = ReturnType<typeof toChargeCardSortKeyType>;
66
66
  export declare const ALL_CASHBACK_SORT_KEYS: readonly ["month", "cashback"];
67
67
  export declare const toCashbackSortKeyType: (v: string) => "month" | "cashback";
@@ -9,9 +9,18 @@ const userReducer_1 = require("../../../../../entity/user/userReducer");
9
9
  const responsePayload_1 = require("../../../../../responsePayload");
10
10
  const remiSetupApproverViewReducer_1 = require("../remiSetupApproverViewReducer");
11
11
  const deleteRemiApprovalRuleEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(remiSetupApproverViewReducer_1.deleteRemiApprovalRule.match), (0, operators_1.switchMap)((action) => {
12
- const { approvalRuleId } = action.payload;
12
+ const { approvalRuleId, useV3 } = action.payload;
13
+ // Approval Rules 3.0 — flag-gated endpoint selection.
14
+ // Explicit `=== true` keeps `strict-boolean-expressions` happy
15
+ // when RTK's payload type widens to `any` in some configs.
16
+ const endpoint = useV3 === true
17
+ ? // ? `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules-v2`
18
+ `https://dev.api.zeni.ai/version/approval/tarun/1.0/reimbursements/approval-rules-v2`
19
+ : `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules`;
13
20
  return zeniAPI
14
- .deleteAndGetJSON(`${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules`, { approval_rule_id: approvalRuleId })
21
+ .deleteAndGetJSON(endpoint, {
22
+ approval_rule_id: approvalRuleId,
23
+ })
15
24
  .pipe((0, operators_1.mergeMap)((response) => {
16
25
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
17
26
  const approvalRuleIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
@@ -9,7 +9,7 @@ const userReducer_1 = require("../../../../../entity/user/userReducer");
9
9
  const responsePayload_1 = require("../../../../../responsePayload");
10
10
  const remiSetupApproverViewReducer_1 = require("../remiSetupApproverViewReducer");
11
11
  const fetchRemiSetupApproverViewEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(remiSetupApproverViewReducer_1.fetchRemiSetupApproverView.match), (0, operators_1.switchMap)((action) => {
12
- const { cacheOverride, resolveAttributeToUser, includeImplicitActors } = action.payload;
12
+ const { cacheOverride, resolveAttributeToUser, includeImplicitActors, useV3, } = action.payload;
13
13
  const { remiSetupApproverViewState, approvalRuleState } = state$.value;
14
14
  const approvalRules = (0, approvalRuleSelector_1.getApprovalRulesByIds)(approvalRuleState, remiSetupApproverViewState.approvalRuleIds);
15
15
  if (cacheOverride === true ||
@@ -17,8 +17,15 @@ const fetchRemiSetupApproverViewEpic = (actions$, state$, zeniAPI) => actions$.p
17
17
  remiSetupApproverViewState.approvalRuleIds.length ||
18
18
  (remiSetupApproverViewState.hasValidState() === false &&
19
19
  remiSetupApproverViewState.fetchState !== 'In-Progress')) {
20
+ // Approval Rules 3.0 — flag-gated endpoint selection.
21
+ // Explicit `=== true` keeps `strict-boolean-expressions` happy
22
+ // when RTK's payload type widens to `any` in some configs.
23
+ const basePath = useV3 === true
24
+ ? // ? `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules-v2`
25
+ `https://dev.api.zeni.ai/version/approval/tarun/1.0/reimbursements/approval-rules-v2`
26
+ : `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules`;
20
27
  return zeniAPI
21
- .getJSON(`${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules?query={"is_include_implicit_actors": ${includeImplicitActors}, "is_resolve_attribute_to_user":${resolveAttributeToUser}}`)
28
+ .getJSON(`${basePath}?query={"is_include_implicit_actors": ${includeImplicitActors}, "is_resolve_attribute_to_user":${resolveAttributeToUser}}`)
22
29
  .pipe((0, operators_1.mergeMap)((response) => {
23
30
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
24
31
  const approvalRuleIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
@@ -11,16 +11,20 @@ const initializeRemiSetupApproverViewUpdateDataEpic = (actions$, state$) => acti
11
11
  if (approvalRuleId != null) {
12
12
  const approvalRule = (0, approvalRuleSelector_1.getApprovalRuleById)(state$.value.approvalRuleState, approvalRuleId);
13
13
  if (approvalRule != null) {
14
- const criteria = approvalRule.criteria[0];
15
- const range = criteria?.range;
16
14
  const remiSetupApproverViewUpdateData = {
17
15
  approvalRuleId,
18
16
  steps: approvalRule.steps,
19
17
  criteria: {
20
- rangeType: criteria?.rangeType,
21
- rangeEntity: criteria?.rangeEntity,
22
- range,
18
+ amount: (0, approvalRuleSelector_1.getAmountCriteria)(approvalRule.criteria),
19
+ vendor: (0, approvalRuleSelector_1.getVendorCriteria)(approvalRule.criteria),
20
+ department: (0, approvalRuleSelector_1.getDepartmentCriteria)(approvalRule.criteria),
23
21
  },
22
+ // Approval Rules 3.0 — seed rule-level fields so the form can
23
+ // round-trip them on edit. Each may be undefined on legacy rules.
24
+ name: approvalRule.name,
25
+ description: approvalRule.description,
26
+ separationOfDuties: approvalRule.separationOfDuties,
27
+ isFallback: approvalRule.isFallback,
24
28
  };
25
29
  fetchActions.push((0, remiSetupApproverViewReducer_1.clearRemiSetupApproverViewUpdateData)(), (0, remiSetupApproverViewReducer_1.saveRemiSetupApproverViewUpdateData)(remiSetupApproverViewUpdateData));
26
30
  }
@@ -28,7 +32,7 @@ const initializeRemiSetupApproverViewUpdateDataEpic = (actions$, state$) => acti
28
32
  else {
29
33
  const remiSetupApproverViewCreateData = {
30
34
  steps: [],
31
- criteria: undefined,
35
+ criteria: {},
32
36
  };
33
37
  fetchActions.push((0, remiSetupApproverViewReducer_1.clearRemiSetupApproverViewUpdateData)(), (0, remiSetupApproverViewReducer_1.saveRemiSetupApproverViewUpdateData)(remiSetupApproverViewCreateData));
34
38
  }
@@ -9,14 +9,24 @@ const userReducer_1 = require("../../../../../entity/user/userReducer");
9
9
  const responsePayload_1 = require("../../../../../responsePayload");
10
10
  const commonPayload_1 = require("../../../billPay/billPaySetupApproverView/types/commonPayload");
11
11
  const remiSetupApproverViewReducer_1 = require("../remiSetupApproverViewReducer");
12
- const saveRemiSetupApproverViewUpdatesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(remiSetupApproverViewReducer_1.saveRemiSetupApproverViewUpdates.match), (0, operators_1.switchMap)(() => {
12
+ const saveRemiSetupApproverViewUpdatesEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(remiSetupApproverViewReducer_1.saveRemiSetupApproverViewUpdates.match), (0, operators_1.switchMap)((action) => {
13
13
  const { remiSetupApproverViewState } = state$.value;
14
14
  const remiSetupApproverViewUpdateData = remiSetupApproverViewState.remiSetupApproverViewUpdateData;
15
15
  if (remiSetupApproverViewUpdateData != null &&
16
16
  remiSetupApproverViewUpdateData.data != null) {
17
- const payload = (0, commonPayload_1.toApprovalChangableInfoPayload)(remiSetupApproverViewUpdateData.data);
17
+ // Approval Rules 3.0 — gate URL + write-side payload mapper on
18
+ // the `approval_rule_v3_config` dynamic config. `useV3` arrives
19
+ // on the action payload from the screen connector.
20
+ const { useV3 } = action.payload;
21
+ const payload = useV3
22
+ ? (0, commonPayload_1.toApprovalChangableInfoPayload)(remiSetupApproverViewUpdateData.data)
23
+ : (0, commonPayload_1.toApprovalChangableInfoPayloadV1)(remiSetupApproverViewUpdateData.data);
24
+ const endpoint = useV3
25
+ ? // ? `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules-v2`
26
+ `https://dev.api.zeni.ai/version/approval/tarun/1.0/reimbursements/approval-rules-v2`
27
+ : `${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules`;
18
28
  return zeniAPI
19
- .postAndGetJSON(`${zeniAPI.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules`, payload)
29
+ .postAndGetJSON(endpoint, payload)
20
30
  .pipe((0, operators_1.mergeMap)((response) => {
21
31
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
22
32
  const approvalRuleIds = response.data.approval_rules.map((approvalRule) => approvalRule.approval_rule_id);
@@ -2,10 +2,11 @@ import { ZeniAPIStatus } from '../../../../responsePayload';
2
2
  import { ApprovalRuleCreateData, ApprovalRuleUpdateData } from '../../billPay/billPaySetupApproverView/types/commonState';
3
3
  import { RemiSetupApproverViewState } from './remiSetupApproverViewState';
4
4
  export declare const initialState: RemiSetupApproverViewState;
5
- export declare const fetchRemiSetupApproverView: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[cacheOverride?: any, resolveAttributeToUser?: any, includeImplicitActors?: any], {
5
+ export declare const fetchRemiSetupApproverView: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[cacheOverride?: any, resolveAttributeToUser?: any, includeImplicitActors?: any, useV3?: any], {
6
6
  cacheOverride: any;
7
7
  resolveAttributeToUser: any;
8
8
  includeImplicitActors: any;
9
+ useV3: any;
9
10
  }, "remiSetupApproverView/fetchRemiSetupApproverView", never, never>, fetchRemiSetupApproverViewSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[approvalRuleIds: string[]], {
10
11
  approvalRuleIds: string[];
11
12
  }, "remiSetupApproverView/fetchRemiSetupApproverViewSuccess", never, never>, fetchRemiSetupApproverViewFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[status: ZeniAPIStatus<Record<string, unknown>>], ZeniAPIStatus<Record<string, unknown>>, "remiSetupApproverView/fetchRemiSetupApproverViewFailure", never, never>, fetchRemiApproversDetails: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[cacheOverride?: any, includeUserRoles?: any, includeAttributesUserIds?: any, lastUpdatedByUserId?: any], {
@@ -24,15 +25,18 @@ export declare const fetchRemiSetupApproverView: import("@reduxjs/toolkit").Acti
24
25
  attributeSubTypeToUserIdMapping: Record<"manager" | "vendor_owner" | "manager_of_manager", string> | undefined;
25
26
  }, "remiSetupApproverView/fetchRemiApproversListSuccess", never, never>, fetchRemiApproversListFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[status: ZeniAPIStatus<Record<string, unknown>>], {
26
27
  status: ZeniAPIStatus<Record<string, unknown>>;
27
- }, "remiSetupApproverView/fetchRemiApproversListFailure", never, never>, deleteRemiApprovalRule: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[approvalRuleId: string], {
28
+ }, "remiSetupApproverView/fetchRemiApproversListFailure", never, never>, deleteRemiApprovalRule: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[approvalRuleId: string, useV3?: any], {
28
29
  approvalRuleId: string;
30
+ useV3: any;
29
31
  }, "remiSetupApproverView/deleteRemiApprovalRule", never, never>, deleteRemiApprovalRuleSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[deletedApprovalRuleId: string, approvalRuleIds: string[]], {
30
32
  deletedApprovalRuleId: string;
31
33
  approvalRuleIds: string[];
32
34
  }, "remiSetupApproverView/deleteRemiApprovalRuleSuccess", never, never>, deleteRemiApprovalRuleFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[approvalRuleId: string, status: ZeniAPIStatus<Record<string, unknown>>], {
33
35
  approvalRuleId: string;
34
36
  status: ZeniAPIStatus<Record<string, unknown>>;
35
- }, "remiSetupApproverView/deleteRemiApprovalRuleFailure", never, never>, saveRemiSetupApproverViewUpdates: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"remiSetupApproverView/saveRemiSetupApproverViewUpdates">, saveRemiSetupApproverViewUpdatesSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[approvalRuleIds: string[], affectedEntityIds?: string[] | undefined, newApprovalRuleId?: string | undefined], {
37
+ }, "remiSetupApproverView/deleteRemiApprovalRuleFailure", never, never>, saveRemiSetupApproverViewUpdates: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[useV3: boolean], {
38
+ useV3: boolean;
39
+ }, "remiSetupApproverView/saveRemiSetupApproverViewUpdates", never, never>, saveRemiSetupApproverViewUpdatesSuccess: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[approvalRuleIds: string[], affectedEntityIds?: string[] | undefined, newApprovalRuleId?: string | undefined], {
36
40
  approvalRuleIds: string[];
37
41
  affectedEntityIds: string[] | undefined;
38
42
  newApprovalRuleId: string | undefined;
@@ -30,12 +30,16 @@ const remiSetupApproverView = (0, toolkit_1.createSlice)({
30
30
  draft.fetchState = 'In-Progress';
31
31
  draft.error = undefined;
32
32
  },
33
- prepare(cacheOverride = false, resolveAttributeToUser = false, includeImplicitActors = false) {
33
+ // Approval Rules 3.0 `useV3` arrives from the screen connector
34
+ // (`approval_rule_v3_config` dynamic config) and picks v1 vs v2
35
+ // endpoint in the fetch epic.
36
+ prepare(cacheOverride = false, resolveAttributeToUser = false, includeImplicitActors = false, useV3 = false) {
34
37
  return {
35
38
  payload: {
36
39
  cacheOverride,
37
40
  resolveAttributeToUser,
38
41
  includeImplicitActors,
42
+ useV3,
39
43
  },
40
44
  };
41
45
  },
@@ -138,8 +142,11 @@ const remiSetupApproverView = (0, toolkit_1.createSlice)({
138
142
  error: undefined,
139
143
  };
140
144
  },
141
- prepare(approvalRuleId) {
142
- return { payload: { approvalRuleId } };
145
+ // Approval Rules 3.0 — `useV3` flows from the screen connector
146
+ // (`approval_rule_v3_config` dynamic config) so the delete epic
147
+ // can pick the v1 vs v2 endpoint.
148
+ prepare(approvalRuleId, useV3 = false) {
149
+ return { payload: { approvalRuleId, useV3 } };
143
150
  },
144
151
  },
145
152
  deleteRemiApprovalRuleSuccess: {
@@ -171,13 +178,24 @@ const remiSetupApproverView = (0, toolkit_1.createSlice)({
171
178
  };
172
179
  },
173
180
  },
174
- saveRemiSetupApproverViewUpdates(draft) {
175
- if (draft.remiSetupApproverViewUpdateData != null) {
176
- draft.remiSetupApproverViewUpdateData.updateStatus = {
177
- fetchState: 'In-Progress',
178
- error: undefined,
179
- };
180
- }
181
+ saveRemiSetupApproverViewUpdates: {
182
+ // Approval Rules 3.0 `useV3` sourced from
183
+ // `approval_rule_v3_config` dynamic config in the screen
184
+ // connector; epic uses it to pick v1 vs v2 URL + mapper. The
185
+ // reducer doesn't read the action but the parameter must be
186
+ // declared so the action payload type carries downstream.
187
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
188
+ reducer(draft, _action) {
189
+ if (draft.remiSetupApproverViewUpdateData != null) {
190
+ draft.remiSetupApproverViewUpdateData.updateStatus = {
191
+ fetchState: 'In-Progress',
192
+ error: undefined,
193
+ };
194
+ }
195
+ },
196
+ prepare(useV3) {
197
+ return { payload: { useV3 } };
198
+ },
181
199
  },
182
200
  saveRemiSetupApproverViewUpdatesSuccess: {
183
201
  reducer(draft, action) {
@@ -50,15 +50,15 @@ export interface TaskFilterCategory {
50
50
  }
51
51
  export type TaskListFilterCategoryField = 'status' | 'dueDate' | 'assignee' | 'creationDate' | 'priority' | 'tag';
52
52
  export declare const TASK_LIST_GROUP_BY_KEYS: readonly ["groupName", "status", "dueDate", "assignee", "priority", "tag"];
53
- export declare const toTaskListGroupByKeyType: (v: string) => "status" | "dueDate" | "groupName" | "tag" | "priority" | "assignee";
54
- export declare const toTaskListGroupByKeyTypeStrict: (v: string) => "status" | "dueDate" | "groupName" | "tag" | "priority" | "assignee" | undefined;
53
+ export declare const toTaskListGroupByKeyType: (v: string) => "status" | "priority" | "dueDate" | "groupName" | "tag" | "assignee";
54
+ export declare const toTaskListGroupByKeyTypeStrict: (v: string) => "status" | "priority" | "dueDate" | "groupName" | "tag" | "assignee" | undefined;
55
55
  export declare type TaskGroupKey = ReturnType<typeof toTaskListGroupByKeyType>;
56
56
  export interface TaskListUIState extends SpendManagementUIState {
57
57
  groupByKey: TaskGroupKey;
58
58
  searchText: string;
59
59
  sortKey: TaskListViewSortKey;
60
60
  }
61
- declare const toTaskListSortKeyType: (v: string) => "status" | "name" | "dueDate" | "tag" | "priority" | "timeSpent" | "assignee" | "creationDate" | "visibility";
61
+ declare const toTaskListSortKeyType: (v: string) => "status" | "name" | "priority" | "dueDate" | "tag" | "timeSpent" | "assignee" | "creationDate" | "visibility";
62
62
  export declare type TaskListViewSortKey = ReturnType<typeof toTaskListSortKeyType>;
63
63
  export declare const TASK_LIST_FILTER_CATEGORIES: TaskListFilterCategoryOption[];
64
64
  interface TaskListFilterCategoryOption {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.82-betaAN1",
3
+ "version": "5.0.82-betaAR2",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",