@opencrvs/toolkit 2.0.0-rc.ca280e0 → 2.0.0-rc.cb67c16

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.
@@ -989,8 +989,9 @@ var RequestedCorrectionAction = ActionBase.extend(
989
989
  var ApprovedCorrectionAction = ActionBase.extend(
990
990
  z13.object({
991
991
  type: z13.literal(ActionType.APPROVE_CORRECTION),
992
- requestId: z13.string()
992
+ requestId: z13.string(),
993
993
  // TODO move into 'content' property
994
+ content: z13.object({ immediateCorrection: z13.boolean().optional() }).optional()
994
995
  }).shape
995
996
  );
996
997
  var RejectedCorrectionAction = ActionBase.extend(
@@ -313,6 +313,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
313
313
  createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
314
314
  annotation?: Record<string, import("../commons").FieldUpdateValue> | null | undefined;
315
315
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
316
+ content?: {
317
+ immediateCorrection?: boolean | undefined;
318
+ } | undefined;
316
319
  } | {
317
320
  id: string & import("zod").$brand<"UUID">;
318
321
  transactionId: string;
@@ -622,6 +625,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
622
625
  createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
623
626
  annotation?: Record<string, import("../commons").FieldUpdateValue> | null | undefined;
624
627
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
628
+ content?: {
629
+ immediateCorrection?: boolean | undefined;
630
+ } | undefined;
625
631
  } | {
626
632
  id: string & import("zod").$brand<"UUID">;
627
633
  transactionId: string;
@@ -930,6 +936,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
930
936
  createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
931
937
  annotation?: Record<string, import("../commons").FieldUpdateValue> | null | undefined;
932
938
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
939
+ content?: {
940
+ immediateCorrection?: boolean | undefined;
941
+ } | undefined;
933
942
  } | {
934
943
  id: string & import("zod").$brand<"UUID">;
935
944
  transactionId: string;
@@ -1388,6 +1397,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
1388
1397
  waitFor?: boolean | undefined;
1389
1398
  createdAtLocation?: string | null | undefined;
1390
1399
  type?: "APPROVE_CORRECTION" | undefined;
1400
+ content?: {
1401
+ immediateCorrection?: boolean | undefined;
1402
+ } | undefined;
1391
1403
  }, "keepAssignmentIfAccepted" | "keepAssignmentIfRejected"> | Omit<{
1392
1404
  eventId: string;
1393
1405
  transactionId: string;
@@ -1672,6 +1684,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
1672
1684
  createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
1673
1685
  annotation?: Record<string, import("../commons").FieldUpdateValue> | null | undefined;
1674
1686
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
1687
+ content?: {
1688
+ immediateCorrection?: boolean | undefined;
1689
+ } | undefined;
1675
1690
  } | {
1676
1691
  id: string & import("zod").$brand<"UUID">;
1677
1692
  transactionId: string;
@@ -2012,6 +2027,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
2012
2027
  createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
2013
2028
  annotation?: Record<string, import("../commons").FieldUpdateValue> | null | undefined;
2014
2029
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
2030
+ content?: {
2031
+ immediateCorrection?: boolean | undefined;
2032
+ } | undefined;
2015
2033
  } | {
2016
2034
  id: string & import("zod").$brand<"UUID">;
2017
2035
  transactionId: string;
@@ -2331,6 +2349,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
2331
2349
  waitFor?: boolean | undefined;
2332
2350
  createdAtLocation?: string | null | undefined;
2333
2351
  type?: "APPROVE_CORRECTION" | undefined;
2352
+ content?: {
2353
+ immediateCorrection?: boolean | undefined;
2354
+ } | undefined;
2334
2355
  }, "keepAssignmentIfAccepted" | "keepAssignmentIfRejected"> | Omit<{
2335
2356
  eventId: string;
2336
2357
  transactionId: string;
@@ -2623,6 +2644,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
2623
2644
  waitFor?: boolean | undefined;
2624
2645
  createdAtLocation?: string | null | undefined;
2625
2646
  type?: "APPROVE_CORRECTION" | undefined;
2647
+ content?: {
2648
+ immediateCorrection?: boolean | undefined;
2649
+ } | undefined;
2626
2650
  }, "keepAssignmentIfAccepted" | "keepAssignmentIfRejected"> | Omit<{
2627
2651
  eventId: string;
2628
2652
  transactionId: string;
@@ -2915,6 +2939,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
2915
2939
  waitFor?: boolean | undefined;
2916
2940
  createdAtLocation?: string | null | undefined;
2917
2941
  type?: "APPROVE_CORRECTION" | undefined;
2942
+ content?: {
2943
+ immediateCorrection?: boolean | undefined;
2944
+ } | undefined;
2918
2945
  }, "keepAssignmentIfAccepted" | "keepAssignmentIfRejected"> | Omit<{
2919
2946
  eventId: string;
2920
2947
  transactionId: string;
@@ -3207,6 +3234,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
3207
3234
  waitFor?: boolean | undefined;
3208
3235
  createdAtLocation?: string | null | undefined;
3209
3236
  type?: "APPROVE_CORRECTION" | undefined;
3237
+ content?: {
3238
+ immediateCorrection?: boolean | undefined;
3239
+ } | undefined;
3210
3240
  }, "keepAssignmentIfAccepted" | "keepAssignmentIfRejected"> | Omit<{
3211
3241
  eventId: string;
3212
3242
  transactionId: string;
@@ -3499,6 +3529,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
3499
3529
  waitFor?: boolean | undefined;
3500
3530
  createdAtLocation?: string | null | undefined;
3501
3531
  type?: "APPROVE_CORRECTION" | undefined;
3532
+ content?: {
3533
+ immediateCorrection?: boolean | undefined;
3534
+ } | undefined;
3502
3535
  }, "keepAssignmentIfAccepted" | "keepAssignmentIfRejected"> | Omit<{
3503
3536
  eventId: string;
3504
3537
  transactionId: string;
@@ -3791,6 +3824,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
3791
3824
  waitFor?: boolean | undefined;
3792
3825
  createdAtLocation?: string | null | undefined;
3793
3826
  type?: "APPROVE_CORRECTION" | undefined;
3827
+ content?: {
3828
+ immediateCorrection?: boolean | undefined;
3829
+ } | undefined;
3794
3830
  }, "keepAssignmentIfAccepted" | "keepAssignmentIfRejected"> | Omit<{
3795
3831
  eventId: string;
3796
3832
  transactionId: string;
@@ -4077,6 +4113,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
4077
4113
  createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
4078
4114
  annotation?: Record<string, import("../commons").FieldUpdateValue> | null | undefined;
4079
4115
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
4116
+ content?: {
4117
+ immediateCorrection?: boolean | undefined;
4118
+ } | undefined;
4080
4119
  } | {
4081
4120
  id: string & import("zod").$brand<"UUID">;
4082
4121
  transactionId: string;
@@ -4396,6 +4435,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
4396
4435
  waitFor?: boolean | undefined;
4397
4436
  createdAtLocation?: string | null | undefined;
4398
4437
  type?: "APPROVE_CORRECTION" | undefined;
4438
+ content?: {
4439
+ immediateCorrection?: boolean | undefined;
4440
+ } | undefined;
4399
4441
  }, "keepAssignmentIfAccepted" | "keepAssignmentIfRejected"> | Omit<{
4400
4442
  eventId: string;
4401
4443
  transactionId: string;
@@ -4682,6 +4724,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
4682
4724
  createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
4683
4725
  annotation?: Record<string, import("../commons").FieldUpdateValue> | null | undefined;
4684
4726
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
4727
+ content?: {
4728
+ immediateCorrection?: boolean | undefined;
4729
+ } | undefined;
4685
4730
  } | {
4686
4731
  id: string & import("zod").$brand<"UUID">;
4687
4732
  transactionId: string;
@@ -5000,6 +5045,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
5000
5045
  createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
5001
5046
  annotation?: Record<string, import("../commons").FieldUpdateValue> | null | undefined;
5002
5047
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
5048
+ content?: {
5049
+ immediateCorrection?: boolean | undefined;
5050
+ } | undefined;
5003
5051
  } | {
5004
5052
  id: string & import("zod").$brand<"UUID">;
5005
5053
  transactionId: string;
@@ -5369,6 +5417,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
5369
5417
  waitFor?: boolean | undefined;
5370
5418
  createdAtLocation?: string | null | undefined;
5371
5419
  type?: "APPROVE_CORRECTION" | undefined;
5420
+ content?: {
5421
+ immediateCorrection?: boolean | undefined;
5422
+ } | undefined;
5372
5423
  }, "keepAssignmentIfAccepted" | "keepAssignmentIfRejected"> | Omit<{
5373
5424
  eventId: string;
5374
5425
  transactionId: string;
@@ -5661,6 +5712,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
5661
5712
  waitFor?: boolean | undefined;
5662
5713
  createdAtLocation?: string | null | undefined;
5663
5714
  type?: "APPROVE_CORRECTION" | undefined;
5715
+ content?: {
5716
+ immediateCorrection?: boolean | undefined;
5717
+ } | undefined;
5664
5718
  }, "keepAssignmentIfAccepted" | "keepAssignmentIfRejected"> | Omit<{
5665
5719
  eventId: string;
5666
5720
  transactionId: string;
@@ -5953,6 +6007,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
5953
6007
  waitFor?: boolean | undefined;
5954
6008
  createdAtLocation?: string | null | undefined;
5955
6009
  type?: "APPROVE_CORRECTION" | undefined;
6010
+ content?: {
6011
+ immediateCorrection?: boolean | undefined;
6012
+ } | undefined;
5956
6013
  }, "keepAssignmentIfAccepted" | "keepAssignmentIfRejected"> | Omit<{
5957
6014
  eventId: string;
5958
6015
  transactionId: string;
@@ -6242,6 +6299,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
6242
6299
  createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
6243
6300
  annotation?: Record<string, import("../commons").FieldUpdateValue> | null | undefined;
6244
6301
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
6302
+ content?: {
6303
+ immediateCorrection?: boolean | undefined;
6304
+ } | undefined;
6245
6305
  } | {
6246
6306
  id: string & import("zod").$brand<"UUID">;
6247
6307
  transactionId: string;
@@ -6559,6 +6619,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
6559
6619
  createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
6560
6620
  annotation?: Record<string, import("../commons").FieldUpdateValue> | null | undefined;
6561
6621
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
6622
+ content?: {
6623
+ immediateCorrection?: boolean | undefined;
6624
+ } | undefined;
6562
6625
  } | {
6563
6626
  id: string & import("zod").$brand<"UUID">;
6564
6627
  transactionId: string;
@@ -6919,6 +6982,9 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
6919
6982
  createdAtLocation?: string | null | undefined;
6920
6983
  annotation?: Record<string, unknown> | null | undefined;
6921
6984
  originalActionId?: string | null | undefined;
6985
+ content?: {
6986
+ immediateCorrection?: boolean | undefined;
6987
+ } | undefined;
6922
6988
  } | {
6923
6989
  id: string;
6924
6990
  transactionId: string;
@@ -517,6 +517,9 @@ export declare const ActionDocument: z.ZodDiscriminatedUnion<[z.ZodObject<{
517
517
  originalActionId: z.ZodNullable<z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
518
518
  type: z.ZodLiteral<"APPROVE_CORRECTION">;
519
519
  requestId: z.ZodString;
520
+ content: z.ZodOptional<z.ZodObject<{
521
+ immediateCorrection: z.ZodOptional<z.ZodBoolean>;
522
+ }, z.core.$strip>>;
520
523
  }, z.core.$strip>, z.ZodObject<{
521
524
  id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
522
525
  transactionId: z.ZodString;
@@ -955,6 +958,9 @@ export declare const Action: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.Zod
955
958
  originalActionId: z.ZodNullable<z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
956
959
  type: z.ZodLiteral<"APPROVE_CORRECTION">;
957
960
  requestId: z.ZodString;
961
+ content: z.ZodOptional<z.ZodObject<{
962
+ immediateCorrection: z.ZodOptional<z.ZodBoolean>;
963
+ }, z.core.$strip>>;
958
964
  }, z.core.$strip>, z.ZodObject<{
959
965
  id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
960
966
  transactionId: z.ZodString;
@@ -246,6 +246,9 @@ export declare const ApproveCorrectionActionInput: z.ZodObject<{
246
246
  createdAtLocation: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
247
247
  requestId: z.ZodString;
248
248
  type: z.ZodDefault<z.ZodLiteral<"APPROVE_CORRECTION">>;
249
+ content: z.ZodOptional<z.ZodObject<{
250
+ immediateCorrection: z.ZodOptional<z.ZodBoolean>;
251
+ }, z.core.$strip>>;
249
252
  }, z.core.$strip>;
250
253
  export type ApproveCorrectionActionInput = z.infer<typeof ApproveCorrectionActionInput>;
251
254
  export declare const ReadActionInput: z.ZodObject<{
@@ -495,6 +498,9 @@ export declare const ActionInput: z.ZodDiscriminatedUnion<[z.ZodObject<{
495
498
  createdAtLocation: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
496
499
  requestId: z.ZodString;
497
500
  type: z.ZodDefault<z.ZodLiteral<"APPROVE_CORRECTION">>;
501
+ content: z.ZodOptional<z.ZodObject<{
502
+ immediateCorrection: z.ZodOptional<z.ZodBoolean>;
503
+ }, z.core.$strip>>;
498
504
  }, z.core.$strip>, z.ZodObject<{
499
505
  eventId: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
500
506
  transactionId: z.ZodString;
@@ -274,6 +274,9 @@ export declare const EventDocument: z.ZodObject<{
274
274
  originalActionId: z.ZodNullable<z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
275
275
  type: z.ZodLiteral<"APPROVE_CORRECTION">;
276
276
  requestId: z.ZodString;
277
+ content: z.ZodOptional<z.ZodObject<{
278
+ immediateCorrection: z.ZodOptional<z.ZodBoolean>;
279
+ }, z.core.$strip>>;
277
280
  }, z.core.$strip>, z.ZodObject<{
278
281
  id: z.core.$ZodBranded<z.ZodUUID, "UUID", "out">;
279
282
  transactionId: z.ZodString;
@@ -22,6 +22,7 @@ export * from './FieldValue';
22
22
  export * from './FormConfig';
23
23
  export * from './CompositeFieldValue';
24
24
  export * from './state';
25
+ export * from './state/flags';
25
26
  export * from './utils';
26
27
  export * from './defineConfig';
27
28
  export * from './DeduplicationConfig';
@@ -1,6 +1,9 @@
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;
6
+ export declare function isPotentialDuplicate(actions: Action[]): boolean;
4
7
  /**
5
8
  * This function resolves custom flags for an event based on its actions.
6
9
  * Flags are not stored to the event state or any database directly, instead they are always computed/evaluated from the event actions.
@@ -18,5 +21,18 @@ import { EventDocument } from '../EventDocument';
18
21
  * // Returns: ['flag-1', 'flag-3']
19
22
  */
20
23
  export declare function resolveEventCustomFlags(event: EventDocument, eventConfiguration: EventConfig): CustomFlag[];
24
+ /**
25
+ * Computes all flags (inherent, action status, and custom) that should be attached to the given event,
26
+ * based on its actions and event-specific configuration.
27
+ *
28
+ * Flags are determined by combining:
29
+ * - Action status flags (format 'ActionType:ActionStatus')
30
+ * - Inherent flags (e.g. incomplete, rejected, correction requested, potential duplicate, edit in progress)
31
+ * - Event type-specific custom flags defined in the event configuration
32
+ *
33
+ * @param event - The EventDocument containing the action history and payload
34
+ * @param config - The EventConfig providing rules for custom flag evaluation
35
+ * @returns An array of flags currently relevant/applicable to the event
36
+ */
21
37
  export declare function getEventFlags(event: EventDocument, config: EventConfig): Flag[];
22
38
  //# sourceMappingURL=flags.d.ts.map
@@ -241,6 +241,9 @@ export declare function getActionUpdateMetadata(actions: Action[]): Partial<{
241
241
  createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
242
242
  annotation?: Record<string, import("..").FieldUpdateValue> | null | undefined;
243
243
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
244
+ content?: {
245
+ immediateCorrection?: boolean | undefined;
246
+ } | undefined;
244
247
  } | {
245
248
  id: string & import("zod").$brand<"UUID">;
246
249
  transactionId: string;
@@ -386,6 +386,9 @@ export declare function findLastAssignmentAction(actions: Action[]): {
386
386
  createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
387
387
  annotation?: Record<string, import("./FieldValue").FieldUpdateValue> | null | undefined;
388
388
  originalActionId?: (string & import("zod").$brand<"UUID">) | null | undefined;
389
+ content?: {
390
+ immediateCorrection?: boolean | undefined;
391
+ } | undefined;
389
392
  } | {
390
393
  id: string & import("zod").$brand<"UUID">;
391
394
  transactionId: string;
@@ -560,6 +563,14 @@ export declare function timePeriodToDateRange(value: SelectDateRangeValue): {
560
563
  export declare function mergeDrafts(currentDraft: Draft, incomingDraft: Draft): Draft;
561
564
  export declare function getPendingAction(actions: Action[]): ActionDocument;
562
565
  export declare function getCompleteActionAnnotation(annotation: ActionUpdate, event: EventDocument, action: ActionDocument): ActionUpdate;
566
+ /**
567
+ * Resolves the complete content for an action, inheriting from its original
568
+ * Requested action when the Accepted action carries no content of its own.
569
+ *
570
+ * Mirrors the same "originalActionId → merge from Requested" pattern used by
571
+ * getCompleteActionAnnotation and getCompleteActionDeclaration.
572
+ */
573
+ export declare function getCompleteActionContent(event: EventDocument, action: ActionDocument): Record<string, unknown> | null | undefined;
563
574
  export declare function getCompleteActionDeclaration<T extends EventState | ActionUpdate>(declaration: T, event: EventDocument, action: ActionDocument): T;
564
575
  export declare function getAcceptedActions(event: EventDocument): ActionDocument[];
565
576
  export declare function aggregateActionDeclarations(event: EventDocument): EventState;
@@ -282,6 +282,7 @@ __export(events_exports, {
282
282
  findActiveDraftForEvent: () => findActiveDraftForEvent,
283
283
  findAllFields: () => findAllFields,
284
284
  findLastAssignmentAction: () => findLastAssignmentAction,
285
+ findPendingCorrectionAction: () => findPendingCorrectionAction,
285
286
  findRecordActionPages: () => findRecordActionPages,
286
287
  flag: () => flag,
287
288
  flattenFieldReference: () => flattenFieldReference,
@@ -315,6 +316,7 @@ __export(events_exports, {
315
316
  getAvailableActionsForEvent: () => getAvailableActionsForEvent,
316
317
  getAvailableRolesForUserUpdatePayload: () => getAvailableRolesForUserUpdatePayload,
317
318
  getCompleteActionAnnotation: () => getCompleteActionAnnotation,
319
+ getCompleteActionContent: () => getCompleteActionContent,
318
320
  getCompleteActionDeclaration: () => getCompleteActionDeclaration,
319
321
  getCurrentEventState: () => getCurrentEventState,
320
322
  getCustomActionFields: () => getCustomActionFields,
@@ -323,6 +325,7 @@ __export(events_exports, {
323
325
  getDeclarationFields: () => getDeclarationFields,
324
326
  getDeclarationPages: () => getDeclarationPages,
325
327
  getEventConfigById: () => getEventConfigById,
328
+ getEventFlags: () => getEventFlags,
326
329
  getFilePathsFromEvent: () => getFilePathsFromEvent,
327
330
  getLocationHierarchy: () => getLocationHierarchy,
328
331
  getMixedPath: () => getMixedPath,
@@ -385,6 +388,7 @@ __export(events_exports, {
385
388
  isPageVisible: () => isPageVisible,
386
389
  isParagraphFieldType: () => isParagraphFieldType,
387
390
  isPhoneFieldType: () => isPhoneFieldType,
391
+ isPotentialDuplicate: () => isPotentialDuplicate,
388
392
  isPrintButtonFieldType: () => isPrintButtonFieldType,
389
393
  isQrReaderFieldType: () => isQrReaderFieldType,
390
394
  isQueryParamReaderFieldType: () => isQueryParamReaderFieldType,
@@ -418,6 +422,7 @@ __export(events_exports, {
418
422
  plainDateToLocalDate: () => plainDateToLocalDate,
419
423
  precompileActionSchemas: () => precompileActionSchemas,
420
424
  resolveDateOfEvent: () => resolveDateOfEvent,
425
+ resolveEventCustomFlags: () => resolveEventCustomFlags,
421
426
  resolvePlaceOfEvent: () => resolvePlaceOfEvent,
422
427
  runFieldValidations: () => runFieldValidations,
423
428
  runStructuralValidations: () => runStructuralValidations,
@@ -1653,8 +1658,9 @@ var RequestedCorrectionAction = ActionBase.extend(
1653
1658
  var ApprovedCorrectionAction = ActionBase.extend(
1654
1659
  z14.object({
1655
1660
  type: z14.literal(ActionType.APPROVE_CORRECTION),
1656
- requestId: z14.string()
1661
+ requestId: z14.string(),
1657
1662
  // TODO move into 'content' property
1663
+ content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
1658
1664
  }).shape
1659
1665
  );
1660
1666
  var RejectedCorrectionAction = ActionBase.extend(
@@ -3520,9 +3526,11 @@ var z30 = __toESM(require("zod/v4"));
3520
3526
  var z29 = __toESM(require("zod/v4"));
3521
3527
  function getDynamicNameValue(field3) {
3522
3528
  const nameConfiguration = field3.configuration?.name;
3529
+ const firstnameRequired = nameConfiguration?.firstname?.required ?? field3.required;
3530
+ const surnameRequired = nameConfiguration?.surname?.required ?? field3.required;
3523
3531
  return z29.object({
3524
- firstname: nameConfiguration?.firstname?.required ? NonEmptyTextValue : TextValue,
3525
- surname: nameConfiguration?.surname?.required ? NonEmptyTextValue : TextValue,
3532
+ firstname: firstnameRequired ? NonEmptyTextValue : TextValue,
3533
+ surname: surnameRequired ? NonEmptyTextValue : TextValue,
3526
3534
  middlename: nameConfiguration?.middlename?.required ? NonEmptyTextValue : TextValue.optional()
3527
3535
  });
3528
3536
  }
@@ -4749,6 +4757,22 @@ function getCompleteActionAnnotation(annotation, event2, action) {
4749
4757
  }
4750
4758
  return deepMerge(annotation, action.annotation ?? {});
4751
4759
  }
4760
+ function getCompleteActionContent(event2, action) {
4761
+ const currentContent = "content" in action ? action.content : void 0;
4762
+ if (!action.originalActionId) {
4763
+ return currentContent;
4764
+ }
4765
+ const originalAction = event2.actions.find(
4766
+ ({ id }) => id === action.originalActionId
4767
+ );
4768
+ if (originalAction && "content" in originalAction && originalAction.content) {
4769
+ return {
4770
+ ...originalAction.content,
4771
+ ...currentContent ?? {}
4772
+ };
4773
+ }
4774
+ return currentContent;
4775
+ }
4752
4776
  function getCompleteActionDeclaration(declaration, event2, action) {
4753
4777
  if (action.originalActionId) {
4754
4778
  const originalAction = event2.actions.find(
@@ -6195,7 +6219,8 @@ var RejectCorrectionActionInput = BaseActionInput.extend(
6195
6219
  var ApproveCorrectionActionInput = BaseActionInput.extend(
6196
6220
  z38.object({
6197
6221
  requestId: z38.string(),
6198
- type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
6222
+ type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION),
6223
+ content: z38.object({ immediateCorrection: z38.boolean().optional() }).optional()
6199
6224
  }).shape
6200
6225
  );
6201
6226
  var ReadActionInput = BaseActionInput.extend(
@@ -6388,26 +6413,43 @@ var import_date_fns3 = require("date-fns");
6388
6413
  function isEditInProgress(actions) {
6389
6414
  return actions.at(-1)?.type === ActionType.EDIT;
6390
6415
  }
6416
+ function findPendingCorrectionAction(writeActions2) {
6417
+ let correctionRequestAction;
6418
+ for (let i = writeActions2.length - 1; i >= 0; i--) {
6419
+ const action = writeActions2[i];
6420
+ if (action.type === ActionType.APPROVE_CORRECTION || action.type === ActionType.REJECT_CORRECTION) {
6421
+ break;
6422
+ }
6423
+ if (action.type === ActionType.REQUEST_CORRECTION) {
6424
+ correctionRequestAction = action;
6425
+ break;
6426
+ }
6427
+ }
6428
+ return correctionRequestAction;
6429
+ }
6391
6430
  function isCorrectionRequested(actions) {
6431
+ return findPendingCorrectionAction(actions) !== void 0;
6432
+ }
6433
+ function isDeclarationIncomplete(actions) {
6434
+ return getStatusFromActions(actions) === EventStatus.enum.NOTIFIED;
6435
+ }
6436
+ function isRejected(actions) {
6437
+ const resettingActionTypes = [
6438
+ ActionType.NOTIFY,
6439
+ ActionType.DECLARE,
6440
+ ActionType.EDIT,
6441
+ ActionType.REGISTER
6442
+ ];
6392
6443
  return actions.reduce((prev, { type }) => {
6393
- if (type === ActionType.REQUEST_CORRECTION) {
6444
+ if (type === ActionType.REJECT) {
6394
6445
  return true;
6395
6446
  }
6396
- if (type === ActionType.APPROVE_CORRECTION) {
6397
- return false;
6398
- }
6399
- if (type === ActionType.REJECT_CORRECTION) {
6447
+ if (resettingActionTypes.includes(type)) {
6400
6448
  return false;
6401
6449
  }
6402
6450
  return prev;
6403
6451
  }, false);
6404
6452
  }
6405
- function isDeclarationIncomplete(actions) {
6406
- return getStatusFromActions(actions) === EventStatus.enum.NOTIFIED;
6407
- }
6408
- function isRejected(actions) {
6409
- return actions.at(-1)?.type === ActionType.REJECT;
6410
- }
6411
6453
  function isPotentialDuplicate(actions) {
6412
6454
  return actions.reduce((prev, { type }) => {
6413
6455
  if (type === ActionType.DUPLICATE_DETECTED) {
@@ -6470,8 +6512,7 @@ function resolveEventCustomFlags(event2, eventConfiguration) {
6470
6512
  return (0, import_lodash3.uniq)(flags);
6471
6513
  }, []);
6472
6514
  }
6473
- function getEventFlags(event2, config) {
6474
- const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
6515
+ function getActionStatusFlags(sortedActions) {
6475
6516
  const actionStatus = sortedActions.reduce(
6476
6517
  (actionStatuses, { type, status: status2 }) => ({
6477
6518
  ...actionStatuses,
@@ -6479,26 +6520,40 @@ function getEventFlags(event2, config) {
6479
6520
  }),
6480
6521
  {}
6481
6522
  );
6482
- const flags = Object.entries(actionStatus).filter(([, status2]) => status2 !== ActionStatus.Accepted).map(([type, status2]) => {
6523
+ return Object.entries(actionStatus).filter(([, status2]) => status2 !== ActionStatus.Accepted).map(([type, status2]) => {
6483
6524
  const flag2 = joinValues([type, status2], ":").toLowerCase();
6484
6525
  return flag2;
6485
6526
  });
6486
- if (isCorrectionRequested(sortedActions)) {
6487
- flags.push(InherentFlags.CORRECTION_REQUESTED);
6527
+ }
6528
+ function getInherentFlags(sortedActions) {
6529
+ const acceptedActions = sortedActions.filter(
6530
+ ({ status: status2 }) => status2 === ActionStatus.Accepted
6531
+ );
6532
+ const inherentFlags = [];
6533
+ if (isCorrectionRequested(acceptedActions)) {
6534
+ inherentFlags.push(InherentFlags.CORRECTION_REQUESTED);
6488
6535
  }
6489
- if (isDeclarationIncomplete(sortedActions)) {
6490
- flags.push(InherentFlags.INCOMPLETE);
6536
+ if (isDeclarationIncomplete(acceptedActions)) {
6537
+ inherentFlags.push(InherentFlags.INCOMPLETE);
6491
6538
  }
6492
- if (isRejected(sortedActions)) {
6493
- flags.push(InherentFlags.REJECTED);
6539
+ if (isRejected(acceptedActions)) {
6540
+ inherentFlags.push(InherentFlags.REJECTED);
6494
6541
  }
6495
- if (isPotentialDuplicate(sortedActions)) {
6496
- flags.push(InherentFlags.POTENTIAL_DUPLICATE);
6542
+ if (isPotentialDuplicate(acceptedActions)) {
6543
+ inherentFlags.push(InherentFlags.POTENTIAL_DUPLICATE);
6497
6544
  }
6498
- if (isEditInProgress(sortedActions)) {
6499
- flags.push(InherentFlags.EDIT_IN_PROGRESS);
6545
+ if (isEditInProgress(acceptedActions)) {
6546
+ inherentFlags.push(InherentFlags.EDIT_IN_PROGRESS);
6500
6547
  }
6501
- return [...flags, ...resolveEventCustomFlags(event2, config)];
6548
+ return inherentFlags;
6549
+ }
6550
+ function getEventFlags(event2, config) {
6551
+ const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
6552
+ return [
6553
+ ...getActionStatusFlags(sortedActions),
6554
+ ...getInherentFlags(sortedActions),
6555
+ ...resolveEventCustomFlags(event2, config)
6556
+ ];
6502
6557
  }
6503
6558
 
6504
6559
  // ../commons/src/events/state/index.ts
@@ -1215,8 +1215,9 @@ var RequestedCorrectionAction = ActionBase.extend(
1215
1215
  var ApprovedCorrectionAction = ActionBase.extend(
1216
1216
  z14.object({
1217
1217
  type: z14.literal(ActionType.APPROVE_CORRECTION),
1218
- requestId: z14.string()
1218
+ requestId: z14.string(),
1219
1219
  // TODO move into 'content' property
1220
+ content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
1220
1221
  }).shape
1221
1222
  );
1222
1223
  var RejectedCorrectionAction = ActionBase.extend(
@@ -4469,7 +4470,8 @@ var RejectCorrectionActionInput = BaseActionInput.extend(
4469
4470
  var ApproveCorrectionActionInput = BaseActionInput.extend(
4470
4471
  z38.object({
4471
4472
  requestId: z38.string(),
4472
- type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
4473
+ type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION),
4474
+ content: z38.object({ immediateCorrection: z38.boolean().optional() }).optional()
4473
4475
  }).shape
4474
4476
  );
4475
4477
  var ReadActionInput = BaseActionInput.extend(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/toolkit",
3
- "version": "2.0.0-rc.ca280e0",
3
+ "version": "2.0.0-rc.cb67c16",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "bin": {