@zeniai/client-epic-state 5.0.90-betaAR3 → 5.0.90-betaAR4

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.
@@ -91,15 +91,20 @@ export const toApprovalChangableInfoPayload = (approverViewUpdateData) => {
91
91
  return payload;
92
92
  };
93
93
  /**
94
- * V1 wire mapper — used when `approval_rule_v3_config` resolves to OFF
95
- * for the current tenant. Translates the form-side amount criteria into
96
- * the legacy `{rangeType, rangeEntity, range: {min, max}}` shape. The
97
- * V1 backend does not understand vendor / department criteria or the
98
- * rule-level 3.0 fields, so those are dropped on the wire.
94
+ * V1 wire mapper — used when 'approval_rule_v3_config' resolves to OFF
95
+ * for the current tenant. Emits the legacy snake_case array shape that
96
+ * '/approval-rules' historically consumed (see the V1 fixture in
97
+ * 'entity/entityApprovalStatus/__mocks__/json/entityApprovalStatusPayload.json'):
98
+ * criteria: [{type: 'range', range_entity: 'currency', min, max,
99
+ * currency_code, currency_symbol}]
99
100
  *
100
- * The form-side amount slot is always read as a `range`-style criteria
101
- * here: V1 schemas only supported ranges, so an absent `min` or `max`
102
- * falls back to `0` / `Number.MAX_SAFE_INTEGER`.
101
+ * Open-ended semantics are preserved on the wire: an absent 'min' or
102
+ * 'max' is sent as 'null' rather than synthesised to '0' or
103
+ * 'MAX_SAFE_INTEGER', so a 'greater_than' / 'less_than' rule stays
104
+ * one-sided after rollback rather than collapsing into a closed range.
105
+ *
106
+ * The V1 backend does not understand vendor / department criteria or
107
+ * the rule-level 3.0 fields, so those are dropped on the wire.
103
108
  */
104
109
  export const toApprovalChangableInfoPayloadV1 = (approverViewUpdateData) => {
105
110
  const amount = approverViewUpdateData.criteria?.amount;
@@ -125,25 +130,18 @@ export const toApprovalChangableInfoPayloadV1 = (approverViewUpdateData) => {
125
130
  };
126
131
  });
127
132
  const isUpdate = approverViewUpdateData.approvalRuleId != null;
133
+ const criteriaEntry = {
134
+ type: 'range',
135
+ range_entity: 'currency',
136
+ min: minAmount?.amount ?? null,
137
+ max: maxAmount?.amount ?? null,
138
+ currency_code: currencyCode,
139
+ currency_symbol: currencySymbol,
140
+ };
128
141
  const payload = {
129
142
  steps,
130
143
  is_applicable_on_pending_approval_entity: approverViewUpdateData.isApplicableOnPendingApprovalEntity ?? true,
131
- criteria: {
132
- rangeType: 'range',
133
- rangeEntity: 'currency',
134
- range: {
135
- min: {
136
- amount: minAmount?.amount ?? 0,
137
- currencyCode,
138
- currencySymbol,
139
- },
140
- max: {
141
- amount: maxAmount?.amount ?? Number.MAX_SAFE_INTEGER,
142
- currencyCode,
143
- currencySymbol,
144
- },
145
- },
146
- },
144
+ criteria: [criteriaEntry],
147
145
  };
148
146
  if (isUpdate) {
149
147
  payload.approval_rule_id = approverViewUpdateData.approvalRuleId;
@@ -30,42 +30,51 @@ interface ApprovalUpdatableInfoPayload {
30
30
  }
31
31
  /**
32
32
  * V1 / pre-3.0 wire shape. Kept so the rollback flag (gated by
33
- * `approval_rule_v3_config` dynamic config) can target the original
34
- * `/approval-rules` endpoint with the legacy `{rangeType, rangeEntity, range}`
35
- * criteria. None of the 3.0 rule-level fields are sent.
33
+ * 'approval_rule_v3_config' dynamic config) can target the original
34
+ * '/approval-rules' endpoint with the legacy snake_case array of
35
+ * range entries. None of the 3.0 rule-level fields are sent.
36
+ *
37
+ * Reference: 'entityApprovalStatusPayload.json' fixture, which carries
38
+ * a real V1 approval rule from the legacy backend:
39
+ * criteria: [{type: 'range', range_entity: 'currency',
40
+ * min, max, currency_code, currency_symbol}]
41
+ * with 'min' / 'max' as scalar numbers and 'null' representing an
42
+ * absent bound for one-sided rules. The read-side mapper in
43
+ * 'approvalRulePayload.ts' (see 'LegacyAmountRangeCriterionPayload')
44
+ * decodes the same shape — write-side has to match.
36
45
  */
46
+ interface ApprovalUpdatableInfoPayloadV1CriterionEntry {
47
+ currency_code: string;
48
+ currency_symbol: string;
49
+ /** Upper bound. 'null' for a 'greater_than' (open-upper) rule. */
50
+ max: number | null;
51
+ /** Lower bound. 'null' for a 'less_than' (open-lower) rule. */
52
+ min: number | null;
53
+ range_entity: 'currency';
54
+ type: 'range';
55
+ }
37
56
  interface ApprovalUpdatableInfoPayloadV1 {
38
- criteria: {
39
- range: {
40
- max: {
41
- amount: number;
42
- currencyCode: string;
43
- currencySymbol: string;
44
- };
45
- min: {
46
- amount: number;
47
- currencyCode: string;
48
- currencySymbol: string;
49
- };
50
- };
51
- rangeEntity: 'currency';
52
- rangeType: 'range';
53
- };
57
+ criteria: ApprovalUpdatableInfoPayloadV1CriterionEntry[];
54
58
  is_applicable_on_pending_approval_entity: boolean;
55
59
  steps: ApproverViewStepPayload[];
56
60
  approval_rule_id?: ID;
57
61
  }
58
62
  export declare const toApprovalChangableInfoPayload: (approverViewUpdateData: ApprovalRuleUpdateData | ApprovalRuleCreateData) => Partial<ApprovalUpdatableInfoPayload>;
59
63
  /**
60
- * V1 wire mapper — used when `approval_rule_v3_config` resolves to OFF
61
- * for the current tenant. Translates the form-side amount criteria into
62
- * the legacy `{rangeType, rangeEntity, range: {min, max}}` shape. The
63
- * V1 backend does not understand vendor / department criteria or the
64
- * rule-level 3.0 fields, so those are dropped on the wire.
64
+ * V1 wire mapper — used when 'approval_rule_v3_config' resolves to OFF
65
+ * for the current tenant. Emits the legacy snake_case array shape that
66
+ * '/approval-rules' historically consumed (see the V1 fixture in
67
+ * 'entity/entityApprovalStatus/__mocks__/json/entityApprovalStatusPayload.json'):
68
+ * criteria: [{type: 'range', range_entity: 'currency', min, max,
69
+ * currency_code, currency_symbol}]
70
+ *
71
+ * Open-ended semantics are preserved on the wire: an absent 'min' or
72
+ * 'max' is sent as 'null' rather than synthesised to '0' or
73
+ * 'MAX_SAFE_INTEGER', so a 'greater_than' / 'less_than' rule stays
74
+ * one-sided after rollback rather than collapsing into a closed range.
65
75
  *
66
- * The form-side amount slot is always read as a `range`-style criteria
67
- * here: V1 schemas only supported ranges, so an absent `min` or `max`
68
- * falls back to `0` / `Number.MAX_SAFE_INTEGER`.
76
+ * The V1 backend does not understand vendor / department criteria or
77
+ * the rule-level 3.0 fields, so those are dropped on the wire.
69
78
  */
70
79
  export declare const toApprovalChangableInfoPayloadV1: (approverViewUpdateData: ApprovalRuleUpdateData | ApprovalRuleCreateData) => Partial<ApprovalUpdatableInfoPayloadV1>;
71
80
  export {};
@@ -95,15 +95,20 @@ const toApprovalChangableInfoPayload = (approverViewUpdateData) => {
95
95
  };
96
96
  exports.toApprovalChangableInfoPayload = toApprovalChangableInfoPayload;
97
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.
98
+ * V1 wire mapper — used when 'approval_rule_v3_config' resolves to OFF
99
+ * for the current tenant. Emits the legacy snake_case array shape that
100
+ * '/approval-rules' historically consumed (see the V1 fixture in
101
+ * 'entity/entityApprovalStatus/__mocks__/json/entityApprovalStatusPayload.json'):
102
+ * criteria: [{type: 'range', range_entity: 'currency', min, max,
103
+ * currency_code, currency_symbol}]
103
104
  *
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`.
105
+ * Open-ended semantics are preserved on the wire: an absent 'min' or
106
+ * 'max' is sent as 'null' rather than synthesised to '0' or
107
+ * 'MAX_SAFE_INTEGER', so a 'greater_than' / 'less_than' rule stays
108
+ * one-sided after rollback rather than collapsing into a closed range.
109
+ *
110
+ * The V1 backend does not understand vendor / department criteria or
111
+ * the rule-level 3.0 fields, so those are dropped on the wire.
107
112
  */
108
113
  const toApprovalChangableInfoPayloadV1 = (approverViewUpdateData) => {
109
114
  const amount = approverViewUpdateData.criteria?.amount;
@@ -129,25 +134,18 @@ const toApprovalChangableInfoPayloadV1 = (approverViewUpdateData) => {
129
134
  };
130
135
  });
131
136
  const isUpdate = approverViewUpdateData.approvalRuleId != null;
137
+ const criteriaEntry = {
138
+ type: 'range',
139
+ range_entity: 'currency',
140
+ min: minAmount?.amount ?? null,
141
+ max: maxAmount?.amount ?? null,
142
+ currency_code: currencyCode,
143
+ currency_symbol: currencySymbol,
144
+ };
132
145
  const payload = {
133
146
  steps,
134
147
  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
- },
148
+ criteria: [criteriaEntry],
151
149
  };
152
150
  if (isUpdate) {
153
151
  payload.approval_rule_id = approverViewUpdateData.approvalRuleId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.90-betaAR3",
3
+ "version": "5.0.90-betaAR4",
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",