@opencrvs/toolkit 2.0.0-rc.6b5f496 → 2.0.0-rc.6bedc29

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.
@@ -520,13 +520,11 @@ var scopeOptionsPlaceEvent = z2.object({
520
520
  event: scopeByEvent,
521
521
  placeOfEvent: JurisdictionFilter.optional()
522
522
  }).describe("Options applicable to all record scopes.");
523
- var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
524
- notifiedIn: JurisdictionFilter.optional(),
525
- notifiedBy: UserFilter.optional(),
523
+ var scopeOptionsDeclared = scopeOptionsPlaceEvent.extend({
526
524
  declaredIn: JurisdictionFilter.optional(),
527
525
  declaredBy: UserFilter.optional()
528
526
  }).describe("Options applicable to actions that may take place after DECLARE");
529
- var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
527
+ var AllRecordScopeOptions = scopeOptionsDeclared.extend({
530
528
  registeredIn: JurisdictionFilter.optional(),
531
529
  registeredBy: UserFilter.optional()
532
530
  }).describe(
@@ -564,8 +562,6 @@ var ResolvedScopeOptionsPlaceEvent = z2.object({
564
562
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
565
563
  );
566
564
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
567
- notifiedIn: UUID.nullish(),
568
- notifiedBy: z2.string().optional(),
569
565
  declaredIn: UUID.nullish(),
570
566
  declaredBy: z2.string().optional()
571
567
  }).describe(
@@ -611,7 +607,7 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
611
607
  }),
612
608
  z2.object({
613
609
  type: ScopesWithDeclaredOptions,
614
- options: scopeOptionsDeclaredOrNotified.optional()
610
+ options: scopeOptionsDeclared.optional()
615
611
  }),
616
612
  z2.object({
617
613
  type: ScopesWithFullOptions,
@@ -734,9 +730,8 @@ var decodeScope = (encodedScope) => {
734
730
  var DEFAULT_SCOPE_OPTIONS = {
735
731
  placeOfEvent: JurisdictionFilter.enum.all,
736
732
  accessLevel: JurisdictionFilter.enum.all,
737
- notifiedIn: JurisdictionFilter.enum.all,
738
- declaredIn: JurisdictionFilter.enum.all,
739
- registeredIn: JurisdictionFilter.enum.all
733
+ registeredIn: JurisdictionFilter.enum.all,
734
+ declaredIn: JurisdictionFilter.enum.all
740
735
  };
741
736
  function getAcceptedScopesByType({
742
737
  acceptedScopes,
@@ -1820,7 +1815,6 @@ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
1820
1815
  )
1821
1816
  });
1822
1817
  var LegalStatuses = z16.object({
1823
- [EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
1824
1818
  [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
1825
1819
  [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
1826
1820
  });
@@ -1962,8 +1956,6 @@ var eventMetadataLabelMap = {
1962
1956
  var EventMetadataDateFieldIdInput = z16.enum([
1963
1957
  "createdAt",
1964
1958
  "updatedAt",
1965
- "legalStatuses.NOTIFIED.createdAt",
1966
- "legalStatuses.NOTIFIED.acceptedAt",
1967
1959
  "legalStatuses.DECLARED.createdAt",
1968
1960
  "legalStatuses.DECLARED.acceptedAt",
1969
1961
  "legalStatuses.REGISTERED.createdAt",
@@ -1972,8 +1964,6 @@ var EventMetadataDateFieldIdInput = z16.enum([
1972
1964
  var EventMetadataDateFieldId = z16.enum([
1973
1965
  "event.createdAt",
1974
1966
  "event.updatedAt",
1975
- "event.legalStatuses.NOTIFIED.createdAt",
1976
- "event.legalStatuses.NOTIFIED.acceptedAt",
1977
1967
  "event.legalStatuses.DECLARED.createdAt",
1978
1968
  "event.legalStatuses.DECLARED.acceptedAt",
1979
1969
  "event.legalStatuses.REGISTERED.createdAt",
@@ -3238,52 +3228,6 @@ var NotifyConfig = ActionConfigBase.extend(
3238
3228
  type: z24.literal(ActionType.NOTIFY)
3239
3229
  }).shape
3240
3230
  );
3241
- var DuplicateDetectedConfig = ActionConfigBase.extend(
3242
- z24.object({
3243
- type: z24.literal(ActionType.DUPLICATE_DETECTED),
3244
- label: z24.never().optional().describe(
3245
- "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no label."
3246
- ),
3247
- supportingCopy: z24.never().optional(),
3248
- icon: z24.never().optional().describe(
3249
- "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no icon."
3250
- ),
3251
- conditionals: z24.never().optional().describe(
3252
- "DUPLICATE_DETECTED is system-generated and never shown as a button, so it cannot be disabled or hidden with conditionals."
3253
- )
3254
- }).shape
3255
- );
3256
- var MarkAsDuplicateConfig = ActionConfigBase.extend(
3257
- z24.object({
3258
- type: z24.literal(ActionType.MARK_AS_DUPLICATE)
3259
- }).shape
3260
- );
3261
- var MarkAsNotDuplicateConfig = ActionConfigBase.extend(
3262
- z24.object({
3263
- type: z24.literal(ActionType.MARK_AS_NOT_DUPLICATE)
3264
- }).shape
3265
- );
3266
- var AssignConfig = ActionConfigBase.extend(
3267
- z24.object({
3268
- type: z24.literal(ActionType.ASSIGN),
3269
- flags: z24.never().optional().describe(
3270
- "ASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
3271
- )
3272
- }).shape
3273
- );
3274
- var UnassignConfig = ActionConfigBase.extend(
3275
- z24.object({
3276
- type: z24.literal(ActionType.UNASSIGN),
3277
- flags: z24.never().optional().describe(
3278
- "UNASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
3279
- )
3280
- }).shape
3281
- );
3282
- var DeleteConfig = ActionConfigBase.extend(
3283
- z24.object({
3284
- type: z24.literal(ActionType.DELETE)
3285
- }).shape
3286
- );
3287
3231
  var DeclareConfig = DeclarationActionBase.extend(
3288
3232
  z24.object({
3289
3233
  type: z24.literal(ActionType.DECLARE),
@@ -3346,17 +3290,7 @@ var RequestCorrectionConfig = ActionConfigBase.extend(
3346
3290
  correctionForm: ActionFormConfig
3347
3291
  }).shape
3348
3292
  );
3349
- var ApproveCorrectionConfig = ActionConfigBase.extend(
3350
- z24.object({
3351
- type: z24.literal(ActionType.APPROVE_CORRECTION)
3352
- }).shape
3353
- );
3354
- var RejectCorrectionConfig = ActionConfigBase.extend(
3355
- z24.object({
3356
- type: z24.literal(ActionType.REJECT_CORRECTION)
3357
- }).shape
3358
- );
3359
- var CustomActionConfig = ActionConfigBase.extend(
3293
+ var CustomActionConfig = ActionConfigBase.merge(
3360
3294
  z24.object({
3361
3295
  type: z24.literal(ActionType.CUSTOM),
3362
3296
  customActionType: z24.string().describe("Type identifier of the custom action."),
@@ -3367,7 +3301,7 @@ var CustomActionConfig = ActionConfigBase.extend(
3367
3301
  auditHistoryLabel: TranslationConfig.describe(
3368
3302
  'The label to show in audit history for this action. For example "Approved".'
3369
3303
  )
3370
- }).shape
3304
+ })
3371
3305
  );
3372
3306
  var ActionConfig = z24.discriminatedUnion("type", [
3373
3307
  /*
@@ -3378,18 +3312,6 @@ var ActionConfig = z24.discriminatedUnion("type", [
3378
3312
  id: "ReadActionConfig",
3379
3313
  description: "Configuration for the read action \u2014 defines the record-tab content displayed on the event overview page."
3380
3314
  }),
3381
- AssignConfig.meta({
3382
- id: "AssignActionConfig",
3383
- description: "Configuration for assigning a record to the current user."
3384
- }),
3385
- UnassignConfig.meta({
3386
- id: "UnassignActionConfig",
3387
- description: "Configuration for unassigning a record from its current assignee."
3388
- }),
3389
- DeleteConfig.meta({
3390
- id: "DeleteActionConfig",
3391
- description: "Configuration for deleting a draft record."
3392
- }),
3393
3315
  NotifyConfig.meta({
3394
3316
  id: "NotifyActionConfig",
3395
3317
  description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
@@ -3398,18 +3320,6 @@ var ActionConfig = z24.discriminatedUnion("type", [
3398
3320
  id: "DeclareActionConfig",
3399
3321
  description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
3400
3322
  }),
3401
- DuplicateDetectedConfig.meta({
3402
- id: "DuplicateDetectedActionConfig",
3403
- description: "Configuration for the system-generated duplicate-detection action. Never shown as a button, so it only supports flags \u2014 not label, icon, or conditionals."
3404
- }),
3405
- MarkAsDuplicateConfig.meta({
3406
- id: "MarkAsDuplicateActionConfig",
3407
- description: "Configuration for marking a record as a duplicate."
3408
- }),
3409
- MarkAsNotDuplicateConfig.meta({
3410
- id: "MarkAsNotDuplicateActionConfig",
3411
- description: "Configuration for marking a record as not a duplicate, after it was previously flagged as one."
3412
- }),
3413
3323
  RejectConfig.meta({
3414
3324
  id: "RejectActionConfig",
3415
3325
  description: "Configuration for rejecting a record before registration."
@@ -3426,14 +3336,6 @@ var ActionConfig = z24.discriminatedUnion("type", [
3426
3336
  id: "RequestCorrectionActionConfig",
3427
3337
  description: "Configuration for requesting a correction on a registered record."
3428
3338
  }),
3429
- ApproveCorrectionConfig.meta({
3430
- id: "ApproveCorrectionActionConfig",
3431
- description: "Configuration for approving a requested correction."
3432
- }),
3433
- RejectCorrectionConfig.meta({
3434
- id: "RejectCorrectionActionConfig",
3435
- description: "Configuration for rejecting a requested correction."
3436
- }),
3437
3339
  EditActionConfig.meta({
3438
3340
  id: "EditActionConfig",
3439
3341
  description: "Configuration for editing a record before registration."
@@ -4592,6 +4494,9 @@ function getActionConfig({
4592
4494
  if (a.type === ActionType.CUSTOM && customActionType) {
4593
4495
  return a.customActionType === customActionType;
4594
4496
  }
4497
+ if (actionType === ActionType.APPROVE_CORRECTION || actionType === ActionType.REJECT_CORRECTION) {
4498
+ return a.type === ActionType.REQUEST_CORRECTION;
4499
+ }
4595
4500
  return a.type === actionType;
4596
4501
  });
4597
4502
  }
@@ -5745,7 +5650,7 @@ function validateActionFlags(event2, ctx) {
5745
5650
  const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
5746
5651
  const configuredFlagIds = event2.flags.map((flag2) => flag2.id);
5747
5652
  const actionFlagIds = event2.actions.flatMap(
5748
- (action) => (action.flags ?? []).map((flag2) => flag2.id)
5653
+ (action) => action.flags.map((flag2) => flag2.id)
5749
5654
  );
5750
5655
  for (const actionFlagId of actionFlagIds) {
5751
5656
  const isConfigured = configuredFlagIds.includes(actionFlagId);
@@ -6626,10 +6531,6 @@ function getActionUpdateMetadata(actions) {
6626
6531
  }
6627
6532
  function getLegalStatuses(actions) {
6628
6533
  return {
6629
- [EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
6630
- ActionType.NOTIFY,
6631
- actions
6632
- ),
6633
6534
  [EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
6634
6535
  ActionType.DECLARE,
6635
6536
  actions
@@ -6788,7 +6689,7 @@ function resolveEventCustomFlags(event2, eventConfiguration) {
6788
6689
  const declaration = aggregateActionDeclarations(eventUpToThisAction);
6789
6690
  const annotation = aggregateActionAnnotations(eventUpToThisAction);
6790
6691
  const form = { ...declaration, ...annotation };
6791
- const flagsWithMetConditions = (actionConfig.flags ?? []).filter(
6692
+ const flagsWithMetConditions = actionConfig.flags.filter(
6792
6693
  ({ conditional }) => (
6793
6694
  // If conditional is not provided, the flag is resolved
6794
6695
  conditional ? isFlagConditionMet(conditional, form, action) : true
@@ -10445,25 +10346,6 @@ function canAccessEventWithScope(event2, scope, user2, customActionType) {
10445
10346
  }
10446
10347
  if (scopeUsesDeclaredOptions(scope)) {
10447
10348
  const { options } = scope;
10448
- if (options?.notifiedBy === UserFilter.enum.user) {
10449
- if (event2.legalStatuses?.NOTIFIED?.createdBy !== user2.id) {
10450
- return false;
10451
- }
10452
- }
10453
- if (options?.notifiedIn === JurisdictionFilter.enum.location && !matchesJurisdictionFilter(
10454
- event2.legalStatuses?.NOTIFIED?.createdAtLocation,
10455
- JurisdictionFilter.enum.location,
10456
- user2
10457
- )) {
10458
- return false;
10459
- }
10460
- if (options?.notifiedIn === JurisdictionFilter.enum.administrativeArea && !matchesJurisdictionFilter(
10461
- event2.legalStatuses?.NOTIFIED?.createdAtLocation,
10462
- JurisdictionFilter.enum.administrativeArea,
10463
- user2
10464
- )) {
10465
- return false;
10466
- }
10467
10349
  if (options?.declaredBy === UserFilter.enum.user) {
10468
10350
  if (event2.legalStatuses?.DECLARED?.createdBy !== user2.id) {
10469
10351
  return false;