@opencrvs/toolkit 2.0.0-rc.5b9f149 → 2.0.0-rc.5bc1dd8

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.
@@ -6535,9 +6535,6 @@ function getLegalStatuses(actions) {
6535
6535
  // ../commons/src/events/state/flags.ts
6536
6536
  var import_lodash3 = require("lodash");
6537
6537
  var import_date_fns3 = require("date-fns");
6538
- function isEditInProgress(actions) {
6539
- return actions.at(-1)?.type === ActionType.EDIT;
6540
- }
6541
6538
  function findPendingCorrectionAction(writeActions2) {
6542
6539
  let correctionRequestAction;
6543
6540
  for (let i = writeActions2.length - 1; i >= 0; i--) {
@@ -6552,29 +6549,6 @@ function findPendingCorrectionAction(writeActions2) {
6552
6549
  }
6553
6550
  return correctionRequestAction;
6554
6551
  }
6555
- function isCorrectionRequested(actions) {
6556
- return findPendingCorrectionAction(actions) !== void 0;
6557
- }
6558
- function isDeclarationIncomplete(actions) {
6559
- return getStatusFromActions(actions) === EventStatus.enum.NOTIFIED;
6560
- }
6561
- function isRejected(actions) {
6562
- const resettingActionTypes = [
6563
- ActionType.NOTIFY,
6564
- ActionType.DECLARE,
6565
- ActionType.EDIT,
6566
- ActionType.REGISTER
6567
- ];
6568
- return actions.reduce((prev, { type }) => {
6569
- if (type === ActionType.REJECT) {
6570
- return true;
6571
- }
6572
- if (resettingActionTypes.includes(type)) {
6573
- return false;
6574
- }
6575
- return prev;
6576
- }, false);
6577
- }
6578
6552
  function isPotentialDuplicate(actions) {
6579
6553
  return actions.reduce((prev, { type }) => {
6580
6554
  if (type === ActionType.DUPLICATE_DETECTED) {
@@ -6602,6 +6576,88 @@ function isFlagConditionMet(conditional, form, action) {
6602
6576
  }
6603
6577
  });
6604
6578
  }
6579
+ function actionConfigRemovesFlag(action, flagId, actionsUpToAndIncluding, event2, eventConfiguration) {
6580
+ if (!isActionConfigType(action.type)) {
6581
+ return false;
6582
+ }
6583
+ const actionConfig = getActionConfig({
6584
+ eventConfiguration,
6585
+ actionType: action.type,
6586
+ customActionType: "customActionType" in action ? action.customActionType : void 0
6587
+ });
6588
+ const removeOperations = (actionConfig?.flags ?? []).filter(
6589
+ ({ id, operation }) => id === flagId && operation === "remove"
6590
+ );
6591
+ if (removeOperations.length === 0) {
6592
+ return false;
6593
+ }
6594
+ const eventUpToThisAction = { ...event2, actions: actionsUpToAndIncluding };
6595
+ const declaration = aggregateActionDeclarations(eventUpToThisAction);
6596
+ const annotation = aggregateActionAnnotations(eventUpToThisAction);
6597
+ const form = { ...declaration, ...annotation };
6598
+ return removeOperations.some(
6599
+ ({ conditional }) => conditional ? isFlagConditionMet(conditional, form, action) : true
6600
+ );
6601
+ }
6602
+ var INHERENT_FLAG_RULES = [
6603
+ {
6604
+ flag: InherentFlags.CORRECTION_REQUESTED,
6605
+ setOn: [ActionType.REQUEST_CORRECTION],
6606
+ resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
6607
+ },
6608
+ {
6609
+ // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
6610
+ // other status-changing action (see getStatusFromActions).
6611
+ flag: InherentFlags.INCOMPLETE,
6612
+ setOn: [ActionType.NOTIFY],
6613
+ resetOn: [
6614
+ ActionType.CREATE,
6615
+ ActionType.DECLARE,
6616
+ ActionType.REGISTER,
6617
+ ActionType.ARCHIVE
6618
+ ]
6619
+ },
6620
+ {
6621
+ flag: InherentFlags.REJECTED,
6622
+ setOn: [ActionType.REJECT],
6623
+ resetOn: [
6624
+ ActionType.NOTIFY,
6625
+ ActionType.DECLARE,
6626
+ ActionType.EDIT,
6627
+ ActionType.REGISTER
6628
+ ]
6629
+ },
6630
+ {
6631
+ flag: InherentFlags.POTENTIAL_DUPLICATE,
6632
+ setOn: [ActionType.DUPLICATE_DETECTED],
6633
+ resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
6634
+ },
6635
+ {
6636
+ flag: InherentFlags.EDIT_IN_PROGRESS,
6637
+ setOn: [ActionType.EDIT],
6638
+ resetOnAnyOtherAction: true
6639
+ }
6640
+ ];
6641
+ function resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration) {
6642
+ return acceptedActions.reduce((present, action, idx) => {
6643
+ if (rule.setOn.includes(action.type)) {
6644
+ return true;
6645
+ }
6646
+ if (rule.resetOnAnyOtherAction || (rule.resetOn ?? []).includes(action.type)) {
6647
+ return false;
6648
+ }
6649
+ if (actionConfigRemovesFlag(
6650
+ action,
6651
+ rule.flag,
6652
+ acceptedActions.slice(0, idx + 1),
6653
+ event2,
6654
+ eventConfiguration
6655
+ )) {
6656
+ return false;
6657
+ }
6658
+ return present;
6659
+ }, false);
6660
+ }
6605
6661
  function resolveEventCustomFlags(event2, eventConfiguration) {
6606
6662
  const actions = getAcceptedActions(event2).filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
6607
6663
  return actions.reduce((acc, action, idx) => {
@@ -6650,33 +6706,19 @@ function getActionStatusFlags(sortedActions) {
6650
6706
  return flag2;
6651
6707
  });
6652
6708
  }
6653
- function getInherentFlags(sortedActions) {
6709
+ function getInherentFlags(sortedActions, event2, eventConfiguration) {
6654
6710
  const acceptedActions = sortedActions.filter(
6655
6711
  ({ status: status2 }) => status2 === ActionStatus.Accepted
6656
6712
  );
6657
- const inherentFlags = [];
6658
- if (isCorrectionRequested(acceptedActions)) {
6659
- inherentFlags.push(InherentFlags.CORRECTION_REQUESTED);
6660
- }
6661
- if (isDeclarationIncomplete(acceptedActions)) {
6662
- inherentFlags.push(InherentFlags.INCOMPLETE);
6663
- }
6664
- if (isRejected(acceptedActions)) {
6665
- inherentFlags.push(InherentFlags.REJECTED);
6666
- }
6667
- if (isPotentialDuplicate(acceptedActions)) {
6668
- inherentFlags.push(InherentFlags.POTENTIAL_DUPLICATE);
6669
- }
6670
- if (isEditInProgress(acceptedActions)) {
6671
- inherentFlags.push(InherentFlags.EDIT_IN_PROGRESS);
6672
- }
6673
- return inherentFlags;
6713
+ return INHERENT_FLAG_RULES.filter(
6714
+ (rule) => resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration)
6715
+ ).map(({ flag: flag2 }) => flag2);
6674
6716
  }
6675
6717
  function getEventFlags(event2, config) {
6676
6718
  const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
6677
6719
  return [
6678
6720
  ...getActionStatusFlags(sortedActions),
6679
- ...getInherentFlags(sortedActions),
6721
+ ...getInherentFlags(sortedActions, event2, config),
6680
6722
  ...resolveEventCustomFlags(event2, config)
6681
6723
  ];
6682
6724
  }
@@ -7681,6 +7723,11 @@ var TENNIS_CLUB_DECLARATION_REVIEW = {
7681
7723
  id: "signature.upload.modal.title",
7682
7724
  defaultMessage: "Draw signature",
7683
7725
  description: "Title for the modal to draw signature"
7726
+ },
7727
+ // Zod applies the schema default at parse time, but this fixture bypasses
7728
+ // parsing — GeneratedInputField accesses configuration.maxFileSize directly.
7729
+ configuration: {
7730
+ maxFileSize: 5 * 1024 * 1024
7684
7731
  }
7685
7732
  }
7686
7733
  ]
@@ -4711,6 +4711,45 @@ var updateActions = ActionTypes.extract([
4711
4711
  // ../commons/src/events/state/flags.ts
4712
4712
  var import_lodash3 = require("lodash");
4713
4713
  var import_date_fns3 = require("date-fns");
4714
+ var INHERENT_FLAG_RULES = [
4715
+ {
4716
+ flag: InherentFlags.CORRECTION_REQUESTED,
4717
+ setOn: [ActionType.REQUEST_CORRECTION],
4718
+ resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
4719
+ },
4720
+ {
4721
+ // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
4722
+ // other status-changing action (see getStatusFromActions).
4723
+ flag: InherentFlags.INCOMPLETE,
4724
+ setOn: [ActionType.NOTIFY],
4725
+ resetOn: [
4726
+ ActionType.CREATE,
4727
+ ActionType.DECLARE,
4728
+ ActionType.REGISTER,
4729
+ ActionType.ARCHIVE
4730
+ ]
4731
+ },
4732
+ {
4733
+ flag: InherentFlags.REJECTED,
4734
+ setOn: [ActionType.REJECT],
4735
+ resetOn: [
4736
+ ActionType.NOTIFY,
4737
+ ActionType.DECLARE,
4738
+ ActionType.EDIT,
4739
+ ActionType.REGISTER
4740
+ ]
4741
+ },
4742
+ {
4743
+ flag: InherentFlags.POTENTIAL_DUPLICATE,
4744
+ setOn: [ActionType.DUPLICATE_DETECTED],
4745
+ resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
4746
+ },
4747
+ {
4748
+ flag: InherentFlags.EDIT_IN_PROGRESS,
4749
+ setOn: [ActionType.EDIT],
4750
+ resetOnAnyOtherAction: true
4751
+ }
4752
+ ];
4714
4753
 
4715
4754
  // ../commons/src/events/defineConfig.ts
4716
4755
  var IGNORED_EVENT_TYPES = [
@@ -5456,6 +5495,11 @@ var TENNIS_CLUB_DECLARATION_REVIEW = {
5456
5495
  id: "signature.upload.modal.title",
5457
5496
  defaultMessage: "Draw signature",
5458
5497
  description: "Title for the modal to draw signature"
5498
+ },
5499
+ // Zod applies the schema default at parse time, but this fixture bypasses
5500
+ // parsing — GeneratedInputField accesses configuration.maxFileSize directly.
5501
+ configuration: {
5502
+ maxFileSize: 5 * 1024 * 1024
5459
5503
  }
5460
5504
  }
5461
5505
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/toolkit",
3
- "version": "2.0.0-rc.5b9f149",
3
+ "version": "2.0.0-rc.5bc1dd8",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "bin": {