@opencrvs/toolkit 2.0.0-rc.358aed8 → 2.0.0-rc.3598fb7

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 (94) hide show
  1. package/README.md +15 -0
  2. package/build.sh +3 -2
  3. package/dist/api/index.js +3 -3
  4. package/dist/application-config/index.js +26 -9
  5. package/dist/cli.js +3253 -47
  6. package/dist/commons/api/router.d.ts +21 -2
  7. package/dist/commons/conditionals/conditionals.d.ts +3 -3
  8. package/dist/commons/events/ActionConfig.d.ts +35 -2
  9. package/dist/commons/events/AdvancedSearchConfig.d.ts +12 -0
  10. package/dist/commons/events/CountryConfigQueryInput.d.ts +42 -0
  11. package/dist/commons/events/EventConfig.d.ts +2 -0
  12. package/dist/commons/events/EventIndex.d.ts +25 -0
  13. package/dist/commons/events/EventMetadata.d.ts +26 -0
  14. package/dist/commons/events/FieldConfig.d.ts +11 -0
  15. package/dist/commons/events/FieldType.d.ts +1 -0
  16. package/dist/commons/events/FieldTypeMapping.d.ts +1 -1
  17. package/dist/commons/events/WorkqueueConfig.d.ts +39 -0
  18. package/dist/commons/events/locations.d.ts +1 -0
  19. package/dist/commons/events/state/index.d.ts +8 -0
  20. package/dist/commons/events/state/utils.d.ts +9 -0
  21. package/dist/commons/events/utils.d.ts +8 -0
  22. package/dist/conditionals/index.js +13 -8
  23. package/dist/environment/custom-types.d.ts +33 -0
  24. package/dist/environment/custom-types.d.ts.map +1 -0
  25. package/dist/environment/custom-types.js +12 -0
  26. package/dist/environment/derived-variables.d.ts +134 -0
  27. package/dist/environment/derived-variables.d.ts.map +1 -0
  28. package/dist/environment/derived-variables.js +169 -0
  29. package/dist/environment/editor-questions.d.ts +4 -0
  30. package/dist/environment/editor-questions.d.ts.map +1 -0
  31. package/dist/environment/editor-questions.js +67 -0
  32. package/dist/environment/git.d.ts +5 -0
  33. package/dist/environment/git.d.ts.map +1 -0
  34. package/dist/environment/git.js +38 -0
  35. package/dist/environment/github.d.ts +26 -0
  36. package/dist/environment/github.d.ts.map +1 -0
  37. package/dist/environment/github.js +247 -0
  38. package/dist/environment/index.d.ts +5 -0
  39. package/dist/environment/index.d.ts.map +1 -0
  40. package/dist/environment/index.js +71 -0
  41. package/dist/environment/logger.d.ts +15 -0
  42. package/dist/environment/logger.d.ts.map +1 -0
  43. package/dist/environment/logger.js +25 -0
  44. package/dist/environment/manage-users.d.ts +11 -0
  45. package/dist/environment/manage-users.d.ts.map +1 -0
  46. package/dist/environment/manage-users.js +497 -0
  47. package/dist/environment/questions-helper.d.ts +15 -0
  48. package/dist/environment/questions-helper.d.ts.map +1 -0
  49. package/dist/environment/questions-helper.js +70 -0
  50. package/dist/environment/questions.d.ts +199 -0
  51. package/dist/environment/questions.d.ts.map +1 -0
  52. package/dist/environment/questions.js +412 -0
  53. package/dist/environment/setup-environment.d.ts +2 -0
  54. package/dist/environment/setup-environment.d.ts.map +1 -0
  55. package/dist/environment/setup-environment.js +794 -0
  56. package/dist/environment/ssh-keygen.d.ts +5 -0
  57. package/dist/environment/ssh-keygen.d.ts.map +1 -0
  58. package/dist/environment/ssh-keygen.js +21 -0
  59. package/dist/environment/swarm-to-k8s.d.ts +2 -0
  60. package/dist/environment/swarm-to-k8s.d.ts.map +1 -0
  61. package/dist/environment/swarm-to-k8s.js +173 -0
  62. package/dist/environment/templates.d.ts +27 -0
  63. package/dist/environment/templates.d.ts.map +1 -0
  64. package/dist/environment/templates.js +163 -0
  65. package/dist/environment/update-workflows.d.ts +2 -0
  66. package/dist/environment/update-workflows.d.ts.map +1 -0
  67. package/dist/environment/update-workflows.js +169 -0
  68. package/dist/environment/users.d.ts +2 -0
  69. package/dist/environment/users.d.ts.map +1 -0
  70. package/dist/environment/users.js +112 -0
  71. package/dist/environment/utils.d.ts +18 -0
  72. package/dist/environment/utils.d.ts.map +1 -0
  73. package/dist/environment/utils.js +100 -0
  74. package/dist/events/index.js +222 -80
  75. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +1 -1
  76. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  77. package/dist/migrations/v2.0/checkout-upstream-files.js +1 -1
  78. package/dist/migrations/v2.0/index.js +14 -9
  79. package/dist/notification/index.js +128 -20
  80. package/dist/scopes/index.d.ts +89 -1
  81. package/dist/scopes/index.js +13 -8
  82. package/dist/templates/charts-values/dependencies/values.override.yaml +4 -0
  83. package/dist/templates/charts-values/dependencies/values.yaml +83 -0
  84. package/dist/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
  85. package/dist/templates/charts-values/opencrvs-services/values.yaml +81 -0
  86. package/dist/templates/charts-values/traefik/values.override.yaml +4 -0
  87. package/dist/templates/charts-values/traefik/values.yaml +115 -0
  88. package/dist/templates/inventory/inventory.template.yml +100 -0
  89. package/dist/templates/inventory/production.example.yml +77 -0
  90. package/dist/templates/inventory/qa.example.yml +48 -0
  91. package/opencrvs-toolkit-2.0.0-rc.3598fb7.tgz +0 -0
  92. package/package.json +16 -2
  93. package/tsconfig.tsbuildinfo +1 -1
  94. package/opencrvs-toolkit-2.0.0-rc.358aed8.tgz +0 -0
@@ -28,8 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
30
  // src/events/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
31
+ var events_exports = {};
32
+ __export(events_exports, {
33
33
  ACTION_SCOPE_MAP: () => ACTION_SCOPE_MAP,
34
34
  Action: () => Action,
35
35
  ActionBase: () => ActionBase,
@@ -151,6 +151,7 @@ __export(index_exports, {
151
151
  FormPageConfig: () => FormPageConfig,
152
152
  Fuzzy: () => Fuzzy,
153
153
  GeographicalArea: () => GeographicalArea,
154
+ HiddenFieldTypes: () => HiddenFieldTypes,
154
155
  HiddenFieldValue: () => HiddenFieldValue,
155
156
  HttpFieldUpdateValue: () => HttpFieldUpdateValue,
156
157
  HttpFieldValue: () => HttpFieldValue,
@@ -311,6 +312,7 @@ __export(index_exports, {
311
312
  getActionAnnotation: () => getActionAnnotation,
312
313
  getActionAnnotationFields: () => getActionAnnotationFields,
313
314
  getActionConfig: () => getActionConfig,
315
+ getActionFormFields: () => getActionFormFields,
314
316
  getActionReview: () => getActionReview,
315
317
  getActionReviewFields: () => getActionReviewFields,
316
318
  getAdministrativeAreaHierarchy: () => getAdministrativeAreaHierarchy,
@@ -445,7 +447,7 @@ __export(index_exports, {
445
447
  window: () => window2,
446
448
  writeActions: () => writeActions
447
449
  });
448
- module.exports = __toCommonJS(index_exports);
450
+ module.exports = __toCommonJS(events_exports);
449
451
 
450
452
  // ../commons/src/events/AuditLog.ts
451
453
  var z5 = __toESM(require("zod/v4"));
@@ -519,11 +521,13 @@ var scopeOptionsPlaceEvent = z2.object({
519
521
  event: scopeByEvent,
520
522
  placeOfEvent: JurisdictionFilter.optional()
521
523
  }).describe("Options applicable to all record scopes.");
522
- var scopeOptionsDeclared = scopeOptionsPlaceEvent.extend({
524
+ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
525
+ notifiedIn: JurisdictionFilter.optional(),
526
+ notifiedBy: UserFilter.optional(),
523
527
  declaredIn: JurisdictionFilter.optional(),
524
528
  declaredBy: UserFilter.optional()
525
529
  }).describe("Options applicable to actions that may take place after DECLARE");
526
- var AllRecordScopeOptions = scopeOptionsDeclared.extend({
530
+ var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
527
531
  registeredIn: JurisdictionFilter.optional(),
528
532
  registeredBy: UserFilter.optional()
529
533
  }).describe(
@@ -561,6 +565,8 @@ var ResolvedScopeOptionsPlaceEvent = z2.object({
561
565
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
562
566
  );
563
567
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
568
+ notifiedIn: UUID.nullish(),
569
+ notifiedBy: z2.string().optional(),
564
570
  declaredIn: UUID.nullish(),
565
571
  declaredBy: z2.string().optional()
566
572
  }).describe(
@@ -606,7 +612,7 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
606
612
  }),
607
613
  z2.object({
608
614
  type: ScopesWithDeclaredOptions,
609
- options: scopeOptionsDeclared.optional()
615
+ options: scopeOptionsDeclaredOrNotified.optional()
610
616
  }),
611
617
  z2.object({
612
618
  type: ScopesWithFullOptions,
@@ -729,8 +735,9 @@ var decodeScope = (encodedScope) => {
729
735
  var DEFAULT_SCOPE_OPTIONS = {
730
736
  placeOfEvent: JurisdictionFilter.enum.all,
731
737
  accessLevel: JurisdictionFilter.enum.all,
732
- registeredIn: JurisdictionFilter.enum.all,
733
- declaredIn: JurisdictionFilter.enum.all
738
+ notifiedIn: JurisdictionFilter.enum.all,
739
+ declaredIn: JurisdictionFilter.enum.all,
740
+ registeredIn: JurisdictionFilter.enum.all
734
741
  };
735
742
  function getAcceptedScopesByType({
736
743
  acceptedScopes,
@@ -1219,6 +1226,11 @@ var FieldTypesToHideInReview = [
1219
1226
  FieldType.ALPHA_PRINT_BUTTON,
1220
1227
  FieldType.ALPHA_HIDDEN
1221
1228
  ];
1229
+ var HiddenFieldTypes = [
1230
+ FieldType.HTTP,
1231
+ FieldType.QUERY_PARAM_READER,
1232
+ FieldType.ALPHA_HIDDEN
1233
+ ];
1222
1234
 
1223
1235
  // ../commons/src/events/FieldValue.ts
1224
1236
  var z12 = __toESM(require("zod/v4"));
@@ -1809,6 +1821,7 @@ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
1809
1821
  )
1810
1822
  });
1811
1823
  var LegalStatuses = z16.object({
1824
+ [EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
1812
1825
  [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
1813
1826
  [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
1814
1827
  });
@@ -1950,6 +1963,8 @@ var eventMetadataLabelMap = {
1950
1963
  var EventMetadataDateFieldIdInput = z16.enum([
1951
1964
  "createdAt",
1952
1965
  "updatedAt",
1966
+ "legalStatuses.NOTIFIED.createdAt",
1967
+ "legalStatuses.NOTIFIED.acceptedAt",
1953
1968
  "legalStatuses.DECLARED.createdAt",
1954
1969
  "legalStatuses.DECLARED.acceptedAt",
1955
1970
  "legalStatuses.REGISTERED.createdAt",
@@ -1958,6 +1973,8 @@ var EventMetadataDateFieldIdInput = z16.enum([
1958
1973
  var EventMetadataDateFieldId = z16.enum([
1959
1974
  "event.createdAt",
1960
1975
  "event.updatedAt",
1976
+ "event.legalStatuses.NOTIFIED.createdAt",
1977
+ "event.legalStatuses.NOTIFIED.acceptedAt",
1961
1978
  "event.legalStatuses.DECLARED.createdAt",
1962
1979
  "event.legalStatuses.DECLARED.acceptedAt",
1963
1980
  "event.legalStatuses.REGISTERED.createdAt",
@@ -2017,7 +2034,8 @@ var Range = import_v4.z.object({
2017
2034
  });
2018
2035
  var ContainsFlags = import_v4.z.object({
2019
2036
  anyOf: import_v4.z.array(Flag).optional(),
2020
- noneOf: import_v4.z.array(Flag).optional()
2037
+ noneOf: import_v4.z.array(Flag).optional(),
2038
+ allOf: import_v4.z.array(Flag).optional()
2021
2039
  }).meta({
2022
2040
  id: "ContainsFlags"
2023
2041
  });
@@ -2292,6 +2310,7 @@ var NumberField = BaseField.extend({
2292
2310
  configuration: import_v43.default.object({
2293
2311
  min: import_v43.default.number().optional().describe("Minimum value"),
2294
2312
  max: import_v43.default.number().optional().describe("Maximum value"),
2313
+ integer: import_v43.default.boolean().optional().describe("When true, only whole numbers are allowed"),
2295
2314
  prefix: TranslationConfig.optional(),
2296
2315
  postfix: TranslationConfig.optional()
2297
2316
  }).optional()
@@ -3206,6 +3225,9 @@ var ActionConfigBase = z24.object({
3206
3225
  var DeclarationActionBase = ActionConfigBase.extend({
3207
3226
  deduplication: DeduplicationConfig.optional()
3208
3227
  });
3228
+ var actionConfirmationForm = z24.array(FieldConfig).optional().describe(
3229
+ "Fields rendered on the action confirmation dialog. Submitted values are stored in the action annotation and shown in the audit history."
3230
+ );
3209
3231
  var ReadActionConfig = ActionConfigBase.extend(
3210
3232
  z24.object({
3211
3233
  type: z24.literal(ActionType.READ),
@@ -3215,12 +3237,19 @@ var ReadActionConfig = ActionConfigBase.extend(
3215
3237
  conditionals: z24.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
3216
3238
  }).shape
3217
3239
  );
3240
+ var NotifyConfig = ActionConfigBase.extend(
3241
+ z24.object({
3242
+ type: z24.literal(ActionType.NOTIFY),
3243
+ form: actionConfirmationForm
3244
+ }).shape
3245
+ );
3218
3246
  var DeclareConfig = DeclarationActionBase.extend(
3219
3247
  z24.object({
3220
3248
  type: z24.literal(ActionType.DECLARE),
3221
3249
  review: DeclarationReviewConfig.describe(
3222
3250
  "Configuration of the review page fields."
3223
3251
  ),
3252
+ form: actionConfirmationForm,
3224
3253
  dialogCopy: z24.object({
3225
3254
  notify: TranslationConfig.describe(
3226
3255
  "Confirmation text for the notify action"
@@ -3236,7 +3265,8 @@ var DeclareConfig = DeclarationActionBase.extend(
3236
3265
  );
3237
3266
  var ArchiveConfig = ActionConfigBase.extend(
3238
3267
  z24.object({
3239
- type: z24.literal(ActionType.ARCHIVE)
3268
+ type: z24.literal(ActionType.ARCHIVE),
3269
+ form: actionConfirmationForm
3240
3270
  }).shape
3241
3271
  );
3242
3272
  var EditActionConfig = ActionConfigBase.extend(
@@ -3257,12 +3287,14 @@ var EditActionConfig = ActionConfigBase.extend(
3257
3287
  );
3258
3288
  var RejectConfig = ActionConfigBase.extend(
3259
3289
  z24.object({
3260
- type: z24.literal(ActionType.REJECT)
3290
+ type: z24.literal(ActionType.REJECT),
3291
+ form: actionConfirmationForm
3261
3292
  }).shape
3262
3293
  );
3263
3294
  var RegisterConfig = DeclarationActionBase.extend(
3264
3295
  z24.object({
3265
- type: z24.literal(ActionType.REGISTER)
3296
+ type: z24.literal(ActionType.REGISTER),
3297
+ form: actionConfirmationForm
3266
3298
  }).shape
3267
3299
  );
3268
3300
  var PrintCertificateActionConfig = ActionConfigBase.extend(
@@ -3299,9 +3331,13 @@ var ActionConfig = z24.discriminatedUnion("type", [
3299
3331
  id: "ReadActionConfig",
3300
3332
  description: "Configuration for the read action \u2014 defines the record-tab content displayed on the event overview page."
3301
3333
  }),
3334
+ NotifyConfig.meta({
3335
+ id: "NotifyActionConfig",
3336
+ description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
3337
+ }),
3302
3338
  DeclareConfig.meta({
3303
3339
  id: "DeclareActionConfig",
3304
- description: "Configuration for the declare action. Includes review-page fields. Shared with the notify action (ActionType.NOTIFY)."
3340
+ description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
3305
3341
  }),
3306
3342
  RejectConfig.meta({
3307
3343
  id: "RejectActionConfig",
@@ -3908,7 +3944,7 @@ var isHiddenFieldType = (field3) => {
3908
3944
  return field3.config.type === FieldType.ALPHA_HIDDEN;
3909
3945
  };
3910
3946
  var isNonInteractiveFieldType = (field3) => {
3911
- return field3.type === FieldType.DIVIDER || field3.type === FieldType.PAGE_HEADER || field3.type === FieldType.PARAGRAPH || field3.type === FieldType.HEADING || field3.type === FieldType.BULLET_LIST || field3.type === FieldType.DATA || field3.type === FieldType.ALPHA_PRINT_BUTTON || field3.type === FieldType.HTTP || field3.type === FieldType.LINK_BUTTON || field3.type === FieldType.QUERY_PARAM_READER || field3.type === FieldType.LOADER;
3947
+ return field3.type === FieldType.DIVIDER || field3.type === FieldType.PAGE_HEADER || field3.type === FieldType.PARAGRAPH || field3.type === FieldType.HEADING || field3.type === FieldType.BULLET_LIST || field3.type === FieldType.DATA || field3.type === FieldType.ALPHA_PRINT_BUTTON || field3.type === FieldType.LINK_BUTTON || field3.type === FieldType.LOADER;
3912
3948
  };
3913
3949
 
3914
3950
  // ../commons/src/conditionals/validate.ts
@@ -4470,13 +4506,13 @@ function getActionConfig({
4470
4506
  actionType,
4471
4507
  customActionType
4472
4508
  }) {
4509
+ if (actionType === ActionType.NOTIFY) {
4510
+ return eventConfiguration.actions.find((a) => a.type === ActionType.NOTIFY) ?? eventConfiguration.actions.find((a) => a.type === ActionType.DECLARE);
4511
+ }
4473
4512
  return eventConfiguration.actions.find((a) => {
4474
4513
  if (a.type === ActionType.CUSTOM && customActionType) {
4475
4514
  return a.customActionType === customActionType;
4476
4515
  }
4477
- if (actionType === ActionType.NOTIFY) {
4478
- return a.type === ActionType.DECLARE;
4479
- }
4480
4516
  if (actionType === ActionType.APPROVE_CORRECTION || actionType === ActionType.REJECT_CORRECTION) {
4481
4517
  return a.type === ActionType.REQUEST_CORRECTION;
4482
4518
  }
@@ -4489,7 +4525,19 @@ function getCustomActionFields(eventConfiguration, customActionType) {
4489
4525
  customActionType,
4490
4526
  actionType: ActionType.CUSTOM
4491
4527
  });
4492
- if (!actionConfig || !("form" in actionConfig)) {
4528
+ if (!actionConfig || actionConfig.type !== ActionType.CUSTOM) {
4529
+ return [];
4530
+ }
4531
+ return actionConfig.form;
4532
+ }
4533
+ function getActionFormFields(eventConfiguration, actionType, customActionType) {
4534
+ const actionConfig = eventConfiguration.actions.find((a) => {
4535
+ if (a.type === ActionType.CUSTOM && customActionType) {
4536
+ return a.customActionType === customActionType;
4537
+ }
4538
+ return a.type === actionType;
4539
+ });
4540
+ if (!actionConfig || !("form" in actionConfig) || actionConfig.form == null) {
4493
4541
  return [];
4494
4542
  }
4495
4543
  return actionConfig.form;
@@ -4510,13 +4558,9 @@ var getActionAnnotationFields = (actionConfig) => {
4510
4558
  if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
4511
4559
  return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
4512
4560
  }
4513
- if (actionConfig.type === ActionType.CUSTOM) {
4514
- return actionConfig.form;
4515
- }
4516
- if ("review" in actionConfig) {
4517
- return actionConfig.review.fields;
4518
- }
4519
- return [];
4561
+ const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
4562
+ const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
4563
+ return [...reviewFields, ...formFields];
4520
4564
  };
4521
4565
  function getAllAnnotationFields(config) {
4522
4566
  return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
@@ -6485,6 +6529,8 @@ var updateActions = ActionTypes.extract([
6485
6529
  ActionType.ARCHIVE,
6486
6530
  ActionType.PRINT_CERTIFICATE,
6487
6531
  ActionType.REQUEST_CORRECTION,
6532
+ ActionType.APPROVE_CORRECTION,
6533
+ ActionType.REJECT_CORRECTION,
6488
6534
  ActionType.CUSTOM
6489
6535
  ]);
6490
6536
  function getActionUpdateMetadata(actions) {
@@ -6512,6 +6558,10 @@ function getActionUpdateMetadata(actions) {
6512
6558
  }
6513
6559
  function getLegalStatuses(actions) {
6514
6560
  return {
6561
+ [EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
6562
+ ActionType.NOTIFY,
6563
+ actions
6564
+ ),
6515
6565
  [EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
6516
6566
  ActionType.DECLARE,
6517
6567
  actions
@@ -6526,9 +6576,6 @@ function getLegalStatuses(actions) {
6526
6576
  // ../commons/src/events/state/flags.ts
6527
6577
  var import_lodash3 = require("lodash");
6528
6578
  var import_date_fns3 = require("date-fns");
6529
- function isEditInProgress(actions) {
6530
- return actions.at(-1)?.type === ActionType.EDIT;
6531
- }
6532
6579
  function findPendingCorrectionAction(writeActions2) {
6533
6580
  let correctionRequestAction;
6534
6581
  for (let i = writeActions2.length - 1; i >= 0; i--) {
@@ -6543,29 +6590,6 @@ function findPendingCorrectionAction(writeActions2) {
6543
6590
  }
6544
6591
  return correctionRequestAction;
6545
6592
  }
6546
- function isCorrectionRequested(actions) {
6547
- return findPendingCorrectionAction(actions) !== void 0;
6548
- }
6549
- function isDeclarationIncomplete(actions) {
6550
- return getStatusFromActions(actions) === EventStatus.enum.NOTIFIED;
6551
- }
6552
- function isRejected(actions) {
6553
- const resettingActionTypes = [
6554
- ActionType.NOTIFY,
6555
- ActionType.DECLARE,
6556
- ActionType.EDIT,
6557
- ActionType.REGISTER
6558
- ];
6559
- return actions.reduce((prev, { type }) => {
6560
- if (type === ActionType.REJECT) {
6561
- return true;
6562
- }
6563
- if (resettingActionTypes.includes(type)) {
6564
- return false;
6565
- }
6566
- return prev;
6567
- }, false);
6568
- }
6569
6593
  function isPotentialDuplicate(actions) {
6570
6594
  return actions.reduce((prev, { type }) => {
6571
6595
  if (type === ActionType.DUPLICATE_DETECTED) {
@@ -6593,6 +6617,88 @@ function isFlagConditionMet(conditional, form, action) {
6593
6617
  }
6594
6618
  });
6595
6619
  }
6620
+ function actionConfigRemovesFlag(action, flagId, actionsUpToAndIncluding, event2, eventConfiguration) {
6621
+ if (!isActionConfigType(action.type)) {
6622
+ return false;
6623
+ }
6624
+ const actionConfig = getActionConfig({
6625
+ eventConfiguration,
6626
+ actionType: action.type,
6627
+ customActionType: "customActionType" in action ? action.customActionType : void 0
6628
+ });
6629
+ const removeOperations = (actionConfig?.flags ?? []).filter(
6630
+ ({ id, operation }) => id === flagId && operation === "remove"
6631
+ );
6632
+ if (removeOperations.length === 0) {
6633
+ return false;
6634
+ }
6635
+ const eventUpToThisAction = { ...event2, actions: actionsUpToAndIncluding };
6636
+ const declaration = aggregateActionDeclarations(eventUpToThisAction);
6637
+ const annotation = aggregateActionAnnotations(eventUpToThisAction);
6638
+ const form = { ...declaration, ...annotation };
6639
+ return removeOperations.some(
6640
+ ({ conditional }) => conditional ? isFlagConditionMet(conditional, form, action) : true
6641
+ );
6642
+ }
6643
+ var INHERENT_FLAG_RULES = [
6644
+ {
6645
+ flag: InherentFlags.CORRECTION_REQUESTED,
6646
+ setOn: [ActionType.REQUEST_CORRECTION],
6647
+ resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
6648
+ },
6649
+ {
6650
+ // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
6651
+ // other status-changing action (see getStatusFromActions).
6652
+ flag: InherentFlags.INCOMPLETE,
6653
+ setOn: [ActionType.NOTIFY],
6654
+ resetOn: [
6655
+ ActionType.CREATE,
6656
+ ActionType.DECLARE,
6657
+ ActionType.REGISTER,
6658
+ ActionType.ARCHIVE
6659
+ ]
6660
+ },
6661
+ {
6662
+ flag: InherentFlags.REJECTED,
6663
+ setOn: [ActionType.REJECT],
6664
+ resetOn: [
6665
+ ActionType.NOTIFY,
6666
+ ActionType.DECLARE,
6667
+ ActionType.EDIT,
6668
+ ActionType.REGISTER
6669
+ ]
6670
+ },
6671
+ {
6672
+ flag: InherentFlags.POTENTIAL_DUPLICATE,
6673
+ setOn: [ActionType.DUPLICATE_DETECTED],
6674
+ resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
6675
+ },
6676
+ {
6677
+ flag: InherentFlags.EDIT_IN_PROGRESS,
6678
+ setOn: [ActionType.EDIT],
6679
+ resetOnAnyOtherAction: true
6680
+ }
6681
+ ];
6682
+ function resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration) {
6683
+ return acceptedActions.reduce((present, action, idx) => {
6684
+ if (rule.setOn.includes(action.type)) {
6685
+ return true;
6686
+ }
6687
+ if (rule.resetOnAnyOtherAction || (rule.resetOn ?? []).includes(action.type)) {
6688
+ return false;
6689
+ }
6690
+ if (actionConfigRemovesFlag(
6691
+ action,
6692
+ rule.flag,
6693
+ acceptedActions.slice(0, idx + 1),
6694
+ event2,
6695
+ eventConfiguration
6696
+ )) {
6697
+ return false;
6698
+ }
6699
+ return present;
6700
+ }, false);
6701
+ }
6596
6702
  function resolveEventCustomFlags(event2, eventConfiguration) {
6597
6703
  const actions = getAcceptedActions(event2).filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
6598
6704
  return actions.reduce((acc, action, idx) => {
@@ -6641,33 +6747,19 @@ function getActionStatusFlags(sortedActions) {
6641
6747
  return flag2;
6642
6748
  });
6643
6749
  }
6644
- function getInherentFlags(sortedActions) {
6750
+ function getInherentFlags(sortedActions, event2, eventConfiguration) {
6645
6751
  const acceptedActions = sortedActions.filter(
6646
6752
  ({ status: status2 }) => status2 === ActionStatus.Accepted
6647
6753
  );
6648
- const inherentFlags = [];
6649
- if (isCorrectionRequested(acceptedActions)) {
6650
- inherentFlags.push(InherentFlags.CORRECTION_REQUESTED);
6651
- }
6652
- if (isDeclarationIncomplete(acceptedActions)) {
6653
- inherentFlags.push(InherentFlags.INCOMPLETE);
6654
- }
6655
- if (isRejected(acceptedActions)) {
6656
- inherentFlags.push(InherentFlags.REJECTED);
6657
- }
6658
- if (isPotentialDuplicate(acceptedActions)) {
6659
- inherentFlags.push(InherentFlags.POTENTIAL_DUPLICATE);
6660
- }
6661
- if (isEditInProgress(acceptedActions)) {
6662
- inherentFlags.push(InherentFlags.EDIT_IN_PROGRESS);
6663
- }
6664
- return inherentFlags;
6754
+ return INHERENT_FLAG_RULES.filter(
6755
+ (rule) => resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration)
6756
+ ).map(({ flag: flag2 }) => flag2);
6665
6757
  }
6666
6758
  function getEventFlags(event2, config) {
6667
6759
  const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
6668
6760
  return [
6669
6761
  ...getActionStatusFlags(sortedActions),
6670
- ...getInherentFlags(sortedActions),
6762
+ ...getInherentFlags(sortedActions, event2, config),
6671
6763
  ...resolveEventCustomFlags(event2, config)
6672
6764
  ];
6673
6765
  }
@@ -7672,6 +7764,11 @@ var TENNIS_CLUB_DECLARATION_REVIEW = {
7672
7764
  id: "signature.upload.modal.title",
7673
7765
  defaultMessage: "Draw signature",
7674
7766
  description: "Title for the modal to draw signature"
7767
+ },
7768
+ // Zod applies the schema default at parse time, but this fixture bypasses
7769
+ // parsing — GeneratedInputField accesses configuration.maxFileSize directly.
7770
+ configuration: {
7771
+ maxFileSize: 5 * 1024 * 1024
7675
7772
  }
7676
7773
  }
7677
7774
  ]
@@ -8228,6 +8325,20 @@ var tennisClubMembershipEvent = defineConfig({
8228
8325
  },
8229
8326
  review: TENNIS_CLUB_DECLARATION_REVIEW
8230
8327
  },
8328
+ {
8329
+ type: ActionType.NOTIFY,
8330
+ label: {
8331
+ defaultMessage: "Notify health worker",
8332
+ description: "This is shown as the action name anywhere the user can trigger the action from",
8333
+ id: "event.tennis-club-membership.action.notify.label"
8334
+ },
8335
+ flags: [
8336
+ {
8337
+ id: "health-worker-notified",
8338
+ operation: "add"
8339
+ }
8340
+ ]
8341
+ },
8231
8342
  {
8232
8343
  type: ActionType.REJECT,
8233
8344
  label: {
@@ -8470,6 +8581,17 @@ var tennisClubMembershipEvent = defineConfig({
8470
8581
  }
8471
8582
  }
8472
8583
  ],
8584
+ flags: [
8585
+ {
8586
+ id: "health-worker-notified",
8587
+ requiresAction: false,
8588
+ label: {
8589
+ id: "event.tennis-club-membership.flag.health-worker-notified.label",
8590
+ defaultMessage: "Health worker notified",
8591
+ description: "Label for the health-worker-notified flag"
8592
+ }
8593
+ }
8594
+ ],
8473
8595
  advancedSearch: [
8474
8596
  {
8475
8597
  title: {
@@ -10228,7 +10350,7 @@ function matchesJurisdictionFilter(locationIds, filter, user2) {
10228
10350
  return locationIds.some((id) => id === user2.primaryOfficeId);
10229
10351
  }
10230
10352
  if (filter === JurisdictionFilter.enum.administrativeArea) {
10231
- return user2.administrativeAreaId === null || locationIds.some((id) => id === user2.administrativeAreaId);
10353
+ return !user2.administrativeAreaId || locationIds.some((id) => id === user2.administrativeAreaId);
10232
10354
  }
10233
10355
  return true;
10234
10356
  }
@@ -10255,6 +10377,25 @@ function canAccessEventWithScope(event2, scope, user2, customActionType) {
10255
10377
  }
10256
10378
  if (scopeUsesDeclaredOptions(scope)) {
10257
10379
  const { options } = scope;
10380
+ if (options?.notifiedBy === UserFilter.enum.user) {
10381
+ if (event2.legalStatuses?.NOTIFIED?.createdBy !== user2.id) {
10382
+ return false;
10383
+ }
10384
+ }
10385
+ if (options?.notifiedIn === JurisdictionFilter.enum.location && !matchesJurisdictionFilter(
10386
+ event2.legalStatuses?.NOTIFIED?.createdAtLocation,
10387
+ JurisdictionFilter.enum.location,
10388
+ user2
10389
+ )) {
10390
+ return false;
10391
+ }
10392
+ if (options?.notifiedIn === JurisdictionFilter.enum.administrativeArea && !matchesJurisdictionFilter(
10393
+ event2.legalStatuses?.NOTIFIED?.createdAtLocation,
10394
+ JurisdictionFilter.enum.administrativeArea,
10395
+ user2
10396
+ )) {
10397
+ return false;
10398
+ }
10258
10399
  if (options?.declaredBy === UserFilter.enum.user) {
10259
10400
  if (event2.legalStatuses?.DECLARED?.createdBy !== user2.id) {
10260
10401
  return false;
@@ -10317,7 +10458,7 @@ function canAccessUserWithScope({
10317
10458
  }
10318
10459
  const hasAdministrativeAreaInHierarchy = userToAccess.administrativeHierarchy.some(
10319
10460
  (id) => user2.administrativeAreaId === id
10320
- ) || user2.administrativeAreaId === null;
10461
+ ) || !user2.administrativeAreaId;
10321
10462
  if (opts?.accessLevel === JurisdictionFilter.enum.administrativeArea && !hasAdministrativeAreaInHierarchy) {
10322
10463
  return false;
10323
10464
  }
@@ -10623,18 +10764,19 @@ var ACTION_FILTERS = {
10623
10764
  function filterActionsByFlags(actions, flags) {
10624
10765
  return actions.filter((action) => ACTION_FILTERS[action]?.(flags) ?? true);
10625
10766
  }
10767
+ var REJECTED_ACTIONS = [
10768
+ ActionType.READ,
10769
+ ActionType.NOTIFY,
10770
+ ActionType.CUSTOM,
10771
+ ActionType.EDIT,
10772
+ ActionType.ARCHIVE
10773
+ ];
10626
10774
  function getAvailableActionsWithoutFlagFilters(status2, flags) {
10627
10775
  if (flags.includes(InherentFlags.EDIT_IN_PROGRESS)) {
10628
10776
  return [ActionType.NOTIFY, ActionType.DECLARE, ActionType.REGISTER];
10629
10777
  }
10630
- if (flags.includes(InherentFlags.REJECTED)) {
10631
- return [
10632
- ActionType.READ,
10633
- ActionType.NOTIFY,
10634
- ActionType.CUSTOM,
10635
- ActionType.EDIT,
10636
- ActionType.ARCHIVE
10637
- ];
10778
+ if (flags.includes(InherentFlags.REJECTED) && status2 !== EventStatus.enum.ARCHIVED) {
10779
+ return REJECTED_ACTIONS;
10638
10780
  }
10639
10781
  return AVAILABLE_ACTIONS_BY_EVENT_STATUS[status2];
10640
10782
  }
@@ -1,5 +1,5 @@
1
1
  export declare const UPSTREAM_URL = "https://github.com/opencrvs/opencrvs-countryconfig.git";
2
- export declare const UPSTREAM_BRANCH = "release-v2.0.0";
2
+ export declare const UPSTREAM_BRANCH = "release/2.0.0";
3
3
  /**
4
4
  * Runs a git command in the country config working directory.
5
5
  *
@@ -1 +1 @@
1
- {"version":3,"file":"checkout-upstream-files.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/checkout-upstream-files.ts"],"names":[],"mappings":"AA8CA,eAAO,MAAM,YAAY,2DACiC,CAAA;AAE1D,eAAO,MAAM,eAAe,mBAAmB,CAAA;AAc/C;;;;;;GAMG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,MAAc,EAAE,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC5C,MAAM,CAMR;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAO9C;AAED,wBAAgB,eAAe,IAAI,IAAI,CAMtC;AAID,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAuDnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"checkout-upstream-files.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/checkout-upstream-files.ts"],"names":[],"mappings":"AA8CA,eAAO,MAAM,YAAY,2DACiC,CAAA;AAE1D,eAAO,MAAM,eAAe,kBAAkB,CAAA;AAc9C;;;;;;GAMG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,MAAc,EAAE,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC5C,MAAM,CAMR;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAO9C;AAED,wBAAgB,eAAe,IAAI,IAAI,CAMtC;AAID,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAuDnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -59,7 +59,7 @@ exports.main = main;
59
59
  */
60
60
  const child_process_1 = require("child_process");
61
61
  exports.UPSTREAM_URL = 'https://github.com/opencrvs/opencrvs-countryconfig.git';
62
- exports.UPSTREAM_BRANCH = 'release-v2.0.0';
62
+ exports.UPSTREAM_BRANCH = 'release/2.0.0';
63
63
  // Remote name used only for the duration of this codemod. Prefixed to avoid
64
64
  // clashing with remotes the user may have (origin, upstream, etc.).
65
65
  const TEMP_REMOTE = 'opencrvs-upgrade-v19-v20-codemod';
@@ -29,11 +29,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
30
 
31
31
  // src/migrations/v2.0/index.ts
32
- var index_exports = {};
33
- __export(index_exports, {
32
+ var v2_exports = {};
33
+ __export(v2_exports, {
34
34
  runUpgrade: () => runUpgrade
35
35
  });
36
- module.exports = __toCommonJS(index_exports);
36
+ module.exports = __toCommonJS(v2_exports);
37
37
 
38
38
  // src/migrations/v2.0/remove-review-from-register-action.ts
39
39
  var import_ts_morph = require("ts-morph");
@@ -2204,11 +2204,13 @@ var scopeOptionsPlaceEvent = z3.object({
2204
2204
  event: scopeByEvent,
2205
2205
  placeOfEvent: JurisdictionFilter.optional()
2206
2206
  }).describe("Options applicable to all record scopes.");
2207
- var scopeOptionsDeclared = scopeOptionsPlaceEvent.extend({
2207
+ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
2208
+ notifiedIn: JurisdictionFilter.optional(),
2209
+ notifiedBy: UserFilter.optional(),
2208
2210
  declaredIn: JurisdictionFilter.optional(),
2209
2211
  declaredBy: UserFilter.optional()
2210
2212
  }).describe("Options applicable to actions that may take place after DECLARE");
2211
- var AllRecordScopeOptions = scopeOptionsDeclared.extend({
2213
+ var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
2212
2214
  registeredIn: JurisdictionFilter.optional(),
2213
2215
  registeredBy: UserFilter.optional()
2214
2216
  }).describe(
@@ -2246,6 +2248,8 @@ var ResolvedScopeOptionsPlaceEvent = z3.object({
2246
2248
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
2247
2249
  );
2248
2250
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
2251
+ notifiedIn: UUID.nullish(),
2252
+ notifiedBy: z3.string().optional(),
2249
2253
  declaredIn: UUID.nullish(),
2250
2254
  declaredBy: z3.string().optional()
2251
2255
  }).describe(
@@ -2291,7 +2295,7 @@ var RecordScopeV2 = z3.discriminatedUnion("type", [
2291
2295
  }),
2292
2296
  z3.object({
2293
2297
  type: ScopesWithDeclaredOptions,
2294
- options: scopeOptionsDeclared.optional()
2298
+ options: scopeOptionsDeclaredOrNotified.optional()
2295
2299
  }),
2296
2300
  z3.object({
2297
2301
  type: ScopesWithFullOptions,
@@ -2412,8 +2416,9 @@ var decodeScope = (encodedScope) => {
2412
2416
  var DEFAULT_SCOPE_OPTIONS = {
2413
2417
  placeOfEvent: JurisdictionFilter.enum.all,
2414
2418
  accessLevel: JurisdictionFilter.enum.all,
2415
- registeredIn: JurisdictionFilter.enum.all,
2416
- declaredIn: JurisdictionFilter.enum.all
2419
+ notifiedIn: JurisdictionFilter.enum.all,
2420
+ declaredIn: JurisdictionFilter.enum.all,
2421
+ registeredIn: JurisdictionFilter.enum.all
2417
2422
  };
2418
2423
 
2419
2424
  // ../commons/src/scopes.deprecated.do-not-use.ts
@@ -4312,7 +4317,7 @@ Saved ${handlerRelPath}.`);
4312
4317
  // src/migrations/v2.0/checkout-upstream-files.ts
4313
4318
  var import_child_process = require("child_process");
4314
4319
  var UPSTREAM_URL = "https://github.com/opencrvs/opencrvs-countryconfig.git";
4315
- var UPSTREAM_BRANCH = "release-v2.0.0";
4320
+ var UPSTREAM_BRANCH = "release/2.0.0";
4316
4321
  var TEMP_REMOTE = "opencrvs-upgrade-v19-v20-codemod";
4317
4322
  var FILES_TO_CHECKOUT = [
4318
4323
  "src/analytics/analytics.ts",