@opencrvs/toolkit 2.0.0-rc.2314ee0 → 2.0.0-rc.2332d47

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.
@@ -67,6 +67,12 @@ export declare function not(condition: AjvJSONSchema): JSONSchema;
67
67
  * @returns {JSONSchema} An schema object that always evaluates to false.
68
68
  */
69
69
  export declare function never(): JSONSchema;
70
+ /**
71
+ * Returns an JSON Schema object, which is treated as always valid.
72
+ *
73
+ * @returns {JSONSchema} An schema object that always evaluates to true.
74
+ */
75
+ export declare function always(): JSONSchema;
70
76
  /**
71
77
  * Generate conditional rules for current date
72
78
  */
@@ -1,6 +1,8 @@
1
+ import { Action, RequestedCorrectionAction } from '../ActionDocument';
1
2
  import { Flag, CustomFlag } from '../Flag';
2
3
  import { EventConfig } from '../EventConfig';
3
4
  import { EventDocument } from '../EventDocument';
5
+ export declare function findPendingCorrectionAction(writeActions: Action[]): RequestedCorrectionAction | undefined;
4
6
  /**
5
7
  * This function resolves custom flags for an event based on its actions.
6
8
  * Flags are not stored to the event state or any database directly, instead they are always computed/evaluated from the event actions.
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/conditionals/index.ts
31
31
  var conditionals_exports = {};
32
32
  __export(conditionals_exports, {
33
+ always: () => always,
33
34
  alwaysTrue: () => alwaysTrue,
34
35
  and: () => and,
35
36
  createFieldConditionals: () => createFieldConditionals,
@@ -454,6 +455,9 @@ function not(condition) {
454
455
  function never() {
455
456
  return not(alwaysTrue());
456
457
  }
458
+ function always() {
459
+ return defineConditional(alwaysTrue());
460
+ }
457
461
  function jsonFieldPath(field) {
458
462
  return [field.$$field, ...field.$$subfield].join("/");
459
463
  }
@@ -238,6 +238,7 @@ __export(events_exports, {
238
238
  ageToDate: () => ageToDate,
239
239
  aggregateActionAnnotations: () => aggregateActionAnnotations,
240
240
  aggregateActionDeclarations: () => aggregateActionDeclarations,
241
+ always: () => always,
241
242
  alwaysTrue: () => alwaysTrue,
242
243
  and: () => and,
243
244
  annotationActions: () => annotationActions,
@@ -4854,6 +4855,9 @@ function not(condition) {
4854
4855
  function never2() {
4855
4856
  return not(alwaysTrue());
4856
4857
  }
4858
+ function always() {
4859
+ return defineConditional(alwaysTrue());
4860
+ }
4857
4861
  function jsonFieldPath(field3) {
4858
4862
  return [field3.$$field, ...field3.$$subfield].join("/");
4859
4863
  }
@@ -6384,19 +6388,22 @@ var import_date_fns3 = require("date-fns");
6384
6388
  function isEditInProgress(actions) {
6385
6389
  return actions.at(-1)?.type === ActionType.EDIT;
6386
6390
  }
6387
- function isCorrectionRequested(actions) {
6388
- return actions.reduce((prev, { type }) => {
6389
- if (type === ActionType.REQUEST_CORRECTION) {
6390
- return true;
6391
- }
6392
- if (type === ActionType.APPROVE_CORRECTION) {
6393
- return false;
6391
+ function findPendingCorrectionAction(writeActions2) {
6392
+ let correctionRequestAction;
6393
+ for (let i = writeActions2.length - 1; i >= 0; i--) {
6394
+ const action = writeActions2[i];
6395
+ if (action.type === ActionType.APPROVE_CORRECTION || action.type === ActionType.REJECT_CORRECTION) {
6396
+ break;
6394
6397
  }
6395
- if (type === ActionType.REJECT_CORRECTION) {
6396
- return false;
6398
+ if (action.type === ActionType.REQUEST_CORRECTION && action.status !== ActionStatus.Rejected) {
6399
+ correctionRequestAction = action;
6400
+ break;
6397
6401
  }
6398
- return prev;
6399
- }, false);
6402
+ }
6403
+ return correctionRequestAction;
6404
+ }
6405
+ function isCorrectionRequested(actions) {
6406
+ return findPendingCorrectionAction(actions) !== void 0;
6400
6407
  }
6401
6408
  function isDeclarationIncomplete(actions) {
6402
6409
  return getStatusFromActions(actions) === EventStatus.enum.NOTIFIED;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/toolkit",
3
- "version": "2.0.0-rc.2314ee0",
3
+ "version": "2.0.0-rc.2332d47",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "bin": {