@zeniai/client-epic-state 5.0.77-betaAR1 → 5.0.77-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 (37) hide show
  1. package/lib/entity/approvalRule/approvalRulePayload.d.ts +27 -5
  2. package/lib/entity/approvalRule/approvalRulePayload.js +131 -10
  3. package/lib/entity/approvalRule/approvalRuleSelector.d.ts +25 -1
  4. package/lib/entity/approvalRule/approvalRuleSelector.js +40 -0
  5. package/lib/entity/approvalRule/approvalRuleState.d.ts +48 -7
  6. package/lib/esm/entity/approvalRule/approvalRulePayload.js +131 -10
  7. package/lib/esm/entity/approvalRule/approvalRuleSelector.js +35 -0
  8. package/lib/esm/index.js +2 -1
  9. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/backgroundRefetchReviewTabEpic.js +1 -14
  10. package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +1 -12
  11. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/deleteBillPayApprovalRuleEpic.js +3 -1
  12. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/fetchBillPaySetupApproverViewEpic.js +3 -1
  13. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/initializeBillPaySetupApproverViewUpdateDataEpic.js +11 -7
  14. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/epic/saveBillPaySetupApproverViewUpdatesEpic.js +3 -1
  15. package/lib/esm/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +61 -16
  16. package/lib/esm/view/spendManagement/billPay/editBillView/editBillViewSelector.js +7 -2
  17. package/lib/esm/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +11 -7
  18. package/lib/index.d.ts +3 -2
  19. package/lib/index.js +22 -16
  20. package/lib/view/companyTaskManagerView/companyTaskManagerViewReducer.d.ts +2 -2
  21. package/lib/view/companyView/types/cockpitTypes.d.ts +1 -1
  22. package/lib/view/expenseAutomationView/epics/transactionCategorization/backgroundRefetchReviewTabEpic.js +1 -14
  23. package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +1 -12
  24. package/lib/view/expenseAutomationView/payload/transactionCategorizationPayload.d.ts +0 -10
  25. package/lib/view/people/peopleTypes.d.ts +1 -1
  26. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/deleteBillPayApprovalRuleEpic.js +3 -1
  27. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/fetchBillPaySetupApproverViewEpic.js +3 -1
  28. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/initializeBillPaySetupApproverViewUpdateDataEpic.js +10 -6
  29. package/lib/view/spendManagement/billPay/billPaySetupApproverView/epic/saveBillPaySetupApproverViewUpdatesEpic.js +3 -1
  30. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.d.ts +9 -1
  31. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonPayload.js +61 -16
  32. package/lib/view/spendManagement/billPay/billPaySetupApproverView/types/commonState.d.ts +31 -5
  33. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +7 -2
  34. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -1
  35. package/lib/view/spendManagement/reimbursement/remiSetupApproverView/epic/initializeRemiSetupApproverViewUpdateDataEpic.js +10 -6
  36. package/lib/view/taskManager/taskListView/taskList.d.ts +3 -3
  37. package/package.json +1 -1
@@ -14,9 +14,17 @@ interface ApproverViewStepPayload extends Omit<StepPayload, 'actors'> {
14
14
  }
15
15
  interface ApprovalUpdatableInfoPayload {
16
16
  approval_rule_id: ID;
17
- criteria: CriteriaPayload[];
17
+ criteria: CriteriaPayload;
18
18
  is_applicable_on_pending_approval_entity: boolean;
19
19
  steps: ApproverViewStepPayload[];
20
+ description?: string;
21
+ is_fallback?: boolean;
22
+ /**
23
+ * Approval Rules 3.0 — rule-level wire fields. The backend accepts these
24
+ * as optional today; once 3.0 ships they become first-class.
25
+ */
26
+ name?: string;
27
+ separation_of_duties?: boolean;
20
28
  }
21
29
  export declare const toApprovalChangableInfoPayload: (approverViewUpdateData: ApprovalRuleUpdateData | ApprovalRuleCreateData) => Partial<ApprovalUpdatableInfoPayload>;
22
30
  export {};
@@ -2,22 +2,50 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  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,10 +66,27 @@ 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.separation_of_duties = approverViewUpdateData.separationOfDuties;
86
+ }
87
+ if (approverViewUpdateData.isFallback != null) {
88
+ payload.is_fallback = approverViewUpdateData.isFallback;
89
+ }
45
90
  if (isUpdate) {
46
91
  payload.approval_rule_id = approverViewUpdateData.approvalRuleId;
47
92
  }
@@ -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";
@@ -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
  }
@@ -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.77-betaAR1",
3
+ "version": "5.0.77-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",