@opencrvs/toolkit 2.2.0-rc.045257f → 2.2.0-rc.1a111f2
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.
- package/dist/cli.js +925 -356
- package/dist/commons/api/router.d.ts +4 -4
- package/dist/commons/events/ActionType.d.ts +2 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +3 -0
- package/dist/commons/events/Draft.d.ts +34 -1
- package/dist/commons/events/EventConfig.d.ts +385 -0
- package/dist/commons/events/defineConfig.d.ts +7 -2
- package/dist/commons/events/event.d.ts +4 -1
- package/dist/commons/events/field.d.ts +5 -0
- package/dist/commons/events/scopes.d.ts +1 -0
- package/dist/commons/events/test.utils.d.ts +57 -5
- package/dist/commons/events/utils.d.ts +13 -0
- package/dist/environment/custom-types.d.ts +1 -0
- package/dist/environment/custom-types.d.ts.map +1 -1
- package/dist/environment/derived-variables.d.ts +8 -0
- package/dist/environment/derived-variables.d.ts.map +1 -1
- package/dist/environment/derived-variables.js +9 -0
- package/dist/environment/questions.d.ts +42 -9
- package/dist/environment/questions.d.ts.map +1 -1
- package/dist/environment/questions.js +70 -47
- package/dist/environment/registry.d.ts +15 -0
- package/dist/environment/registry.d.ts.map +1 -0
- package/dist/environment/registry.js +112 -0
- package/dist/environment/setup-environment.d.ts.map +1 -1
- package/dist/environment/setup-environment.js +98 -23
- package/dist/events/index.js +462 -99
- package/dist/migrations/add-notify-config.d.ts +40 -0
- package/dist/migrations/add-notify-config.d.ts.map +1 -0
- package/dist/migrations/add-notify-config.js +249 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +602 -143
- package/dist/migrations/move-declaration-to-declare-action.d.ts.map +1 -1
- package/dist/migrations/move-declaration-to-declare-action.js +27 -144
- package/dist/migrations/read-declaration-through-helper.d.ts.map +1 -1
- package/dist/migrations/read-declaration-through-helper.js +3 -61
- package/dist/migrations/resolve-versioned-event-config.d.ts +56 -0
- package/dist/migrations/resolve-versioned-event-config.d.ts.map +1 -0
- package/dist/migrations/resolve-versioned-event-config.js +353 -0
- package/dist/migrations/utils.d.ts +61 -0
- package/dist/migrations/utils.d.ts.map +1 -0
- package/dist/migrations/utils.js +218 -0
- package/dist/notification/index.js +510 -36
- package/dist/templates/charts-values/dependencies/values.yaml +2 -1
- package/dist/templates/charts-values/opencrvs-services/values.yaml +2 -2
- package/dist/verify/endpoints.d.ts +11 -0
- package/dist/verify/endpoints.d.ts.map +1 -1
- package/dist/verify/endpoints.js +21 -27
- package/opencrvs-toolkit-2.2.0-rc.1a111f2.tgz +0 -0
- package/package.json +2 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/environment/dockerhub.d.ts +0 -15
- package/dist/environment/dockerhub.d.ts.map +0 -1
- package/dist/environment/dockerhub.js +0 -104
- package/opencrvs-toolkit-2.2.0-rc.045257f.tgz +0 -0
package/dist/events/index.js
CHANGED
|
@@ -88,6 +88,8 @@ __export(events_exports, {
|
|
|
88
88
|
CustomFieldValue: () => CustomFieldValue,
|
|
89
89
|
CustomFlag: () => CustomFlag,
|
|
90
90
|
DEFAULT_DATE_OF_EVENT_PROPERTY: () => DEFAULT_DATE_OF_EVENT_PROPERTY,
|
|
91
|
+
DEFAULT_EFFECTIVE_FROM: () => DEFAULT_EFFECTIVE_FROM,
|
|
92
|
+
DEFAULT_EVENT_CONFIG_VERSION_ID: () => DEFAULT_EVENT_CONFIG_VERSION_ID,
|
|
91
93
|
DEFAULT_PLACE_OF_EVENT_PROPERTY: () => DEFAULT_PLACE_OF_EVENT_PROPERTY,
|
|
92
94
|
DOCUMENT_DELETE_SCOPES: () => DOCUMENT_DELETE_SCOPES,
|
|
93
95
|
DataEntry: () => DataEntry,
|
|
@@ -208,6 +210,7 @@ __export(events_exports, {
|
|
|
208
210
|
RejectCorrectionActionInput: () => RejectCorrectionActionInput,
|
|
209
211
|
RejectDeclarationActionInput: () => RejectDeclarationActionInput,
|
|
210
212
|
RejectedCorrectionAction: () => RejectedCorrectionAction,
|
|
213
|
+
RemoteDraft: () => RemoteDraft,
|
|
211
214
|
RequestCorrectionActionInput: () => RequestCorrectionActionInput,
|
|
212
215
|
RevokeRegistrationActionInput: () => RevokeRegistrationActionInput,
|
|
213
216
|
SearchQuery: () => SearchQuery,
|
|
@@ -247,6 +250,7 @@ __export(events_exports, {
|
|
|
247
250
|
VerificationActionConfig: () => VerificationActionConfig,
|
|
248
251
|
VerificationPageConfig: () => VerificationPageConfig,
|
|
249
252
|
VerificationStatusValue: () => VerificationStatusValue,
|
|
253
|
+
VersionedEventConfig: () => VersionedEventConfig,
|
|
250
254
|
WithdrawAdministrativeAreaVersionPayload: () => WithdrawAdministrativeAreaVersionPayload,
|
|
251
255
|
WithdrawLocationVersionPayload: () => WithdrawLocationVersionPayload,
|
|
252
256
|
Within: () => Within,
|
|
@@ -321,6 +325,7 @@ __export(events_exports, {
|
|
|
321
325
|
flattenFormState: () => flattenFormState,
|
|
322
326
|
generateActionDeclarationInput: () => generateActionDeclarationInput,
|
|
323
327
|
generateActionDocument: () => generateActionDocument,
|
|
328
|
+
generateActionDocuments: () => generateActionDocuments,
|
|
324
329
|
generateActionDuplicateDeclarationInput: () => generateActionDuplicateDeclarationInput,
|
|
325
330
|
generateEventConfig: () => generateEventConfig,
|
|
326
331
|
generateEventDocument: () => generateEventDocument,
|
|
@@ -362,8 +367,10 @@ __export(events_exports, {
|
|
|
362
367
|
getDeclarationPages: () => getDeclarationPages,
|
|
363
368
|
getDeclarationWithPendingAction: () => getDeclarationWithPendingAction,
|
|
364
369
|
getEventConfigById: () => getEventConfigById,
|
|
370
|
+
getEventConfigOfVersion: () => getEventConfigOfVersion,
|
|
365
371
|
getEventFlags: () => getEventFlags,
|
|
366
372
|
getEventValidatorContext: () => getEventValidatorContext,
|
|
373
|
+
getEventWithCompleteAcceptedActions: () => getEventWithCompleteAcceptedActions,
|
|
367
374
|
getFilePathsFromEvent: () => getFilePathsFromEvent,
|
|
368
375
|
getLeafAdministrativeAreaIds: () => getLeafAdministrativeAreaIds,
|
|
369
376
|
getLocationHierarchy: () => getLocationHierarchy,
|
|
@@ -474,6 +481,7 @@ __export(events_exports, {
|
|
|
474
481
|
plainDateToLocalDate: () => plainDateToLocalDate,
|
|
475
482
|
precompileActionSchemas: () => precompileActionSchemas,
|
|
476
483
|
resolveDateOfEvent: () => resolveDateOfEvent,
|
|
484
|
+
resolveEventConfig: () => resolveEventConfig,
|
|
477
485
|
resolveEventCustomFlags: () => resolveEventCustomFlags,
|
|
478
486
|
resolvePath: () => resolvePath,
|
|
479
487
|
resolvePlaceOfEvent: () => resolvePlaceOfEvent,
|
|
@@ -489,10 +497,13 @@ __export(events_exports, {
|
|
|
489
497
|
toNotificationForm: () => toNotificationForm,
|
|
490
498
|
toNotificationReview: () => toNotificationReview,
|
|
491
499
|
toPlainDate: () => toPlainDate,
|
|
500
|
+
toVersionedEventConfig: () => toVersionedEventConfig,
|
|
492
501
|
todayISO: () => todayISO,
|
|
493
502
|
user: () => user,
|
|
494
503
|
userCanAccessEventWithScopes: () => userCanAccessEventWithScopes,
|
|
495
504
|
validate: () => validate,
|
|
505
|
+
validateEachVersion: () => validateEachVersion,
|
|
506
|
+
validateEventConfig: () => validateEventConfig,
|
|
496
507
|
validateFieldInput: () => validateFieldInput,
|
|
497
508
|
validateValue: () => validateValue,
|
|
498
509
|
window: () => window2,
|
|
@@ -603,7 +614,9 @@ var ActionTypes = z2.enum([
|
|
|
603
614
|
"CUSTOM"
|
|
604
615
|
]);
|
|
605
616
|
var ClientSpecificAction = {
|
|
606
|
-
REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST"
|
|
617
|
+
REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST",
|
|
618
|
+
/** Opens the user's declare or notify draft of the event in its own flow */
|
|
619
|
+
CONTINUE_DRAFT: "CONTINUE_DRAFT"
|
|
607
620
|
};
|
|
608
621
|
var declarationActionValues = [
|
|
609
622
|
ActionTypes.enum.DECLARE,
|
|
@@ -4099,7 +4112,10 @@ var SearchQueryParams = z30.object({
|
|
|
4099
4112
|
}).catchall(FieldValue);
|
|
4100
4113
|
var FieldConfigSchema = BaseField3.extend({
|
|
4101
4114
|
fieldId: z30.string(),
|
|
4102
|
-
fieldType: z30.literal("field")
|
|
4115
|
+
fieldType: z30.literal("field"),
|
|
4116
|
+
defaultValue: z30.union([z30.boolean(), z30.string(), z30.number()]).optional().describe(
|
|
4117
|
+
`Value the field opens with in advanced search. Omitted or true uses the declaration form's defaultValue, false opens the field empty, and any other value opens it with that value. Only text, number and date fields take a value; every other field type, and date fields searched as a range, only accept true or false.`
|
|
4118
|
+
)
|
|
4103
4119
|
});
|
|
4104
4120
|
var EventFieldIdInput = z30.enum([
|
|
4105
4121
|
"trackingId",
|
|
@@ -5800,7 +5816,9 @@ function buildClientFunctionContext(input) {
|
|
|
5800
5816
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
5801
5817
|
$online: isOnline(),
|
|
5802
5818
|
$user: input.validatorContext?.user,
|
|
5803
|
-
$event: input.validatorContext?.event?.document
|
|
5819
|
+
$event: input.validatorContext?.event?.document ? getEventWithCompleteAcceptedActions(
|
|
5820
|
+
input.validatorContext.event.document
|
|
5821
|
+
) : void 0,
|
|
5804
5822
|
$leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
|
|
5805
5823
|
user: input.systemVariables?.user,
|
|
5806
5824
|
$window: input.systemVariables?.$window,
|
|
@@ -6321,14 +6339,14 @@ function getDeclarationPages(configuration) {
|
|
|
6321
6339
|
function getDeclarationFields(configuration) {
|
|
6322
6340
|
return getDeclarationPages(configuration).flatMap(({ fields }) => fields);
|
|
6323
6341
|
}
|
|
6324
|
-
function
|
|
6342
|
+
function findNotificationForm(configuration) {
|
|
6325
6343
|
const notifyAction = configuration.actions.find(
|
|
6326
6344
|
(action) => action.type === ActionType.NOTIFY
|
|
6327
6345
|
);
|
|
6328
6346
|
return notifyAction?.type === ActionType.NOTIFY ? notifyAction.notificationForm : void 0;
|
|
6329
6347
|
}
|
|
6330
6348
|
function getNotificationForm(configuration) {
|
|
6331
|
-
const notificationForm =
|
|
6349
|
+
const notificationForm = findNotificationForm(configuration);
|
|
6332
6350
|
if (!notificationForm) {
|
|
6333
6351
|
throw new Error(
|
|
6334
6352
|
`Event '${configuration.id}' has no ${ActionType.NOTIFY} action.`
|
|
@@ -6604,9 +6622,7 @@ function isWriteAction(actionType) {
|
|
|
6604
6622
|
var findAllFields = (config) => {
|
|
6605
6623
|
return (0, import_lodash4.flattenDeep)([
|
|
6606
6624
|
...getDeclarationFields(config),
|
|
6607
|
-
...
|
|
6608
|
-
({ fields }) => fields
|
|
6609
|
-
) ?? [],
|
|
6625
|
+
...findNotificationForm(config)?.pages.flatMap(({ fields }) => fields) ?? [],
|
|
6610
6626
|
...getAllAnnotationFields(config)
|
|
6611
6627
|
]);
|
|
6612
6628
|
};
|
|
@@ -6742,12 +6758,41 @@ function getCompleteActionDeclaration(declaration, event2, action) {
|
|
|
6742
6758
|
}
|
|
6743
6759
|
return deepMerge(declaration, action.declaration);
|
|
6744
6760
|
}
|
|
6745
|
-
function
|
|
6746
|
-
return
|
|
6761
|
+
function completeAcceptedAction(event2, action) {
|
|
6762
|
+
return {
|
|
6747
6763
|
...action,
|
|
6748
6764
|
declaration: getCompleteActionDeclaration({}, event2, action),
|
|
6749
6765
|
annotation: getCompleteActionAnnotation(event2, action)
|
|
6750
|
-
}
|
|
6766
|
+
};
|
|
6767
|
+
}
|
|
6768
|
+
function getAcceptedActions(event2) {
|
|
6769
|
+
return event2.actions.filter(isAcceptedAction).map((action) => completeAcceptedAction(event2, action));
|
|
6770
|
+
}
|
|
6771
|
+
function getEventWithCompleteAcceptedActions(event2) {
|
|
6772
|
+
return {
|
|
6773
|
+
...event2,
|
|
6774
|
+
actions: event2.actions.map((action) => {
|
|
6775
|
+
if (!isAcceptedAction(action) || !action.originalActionId) {
|
|
6776
|
+
return action;
|
|
6777
|
+
}
|
|
6778
|
+
const requestedAction = event2.actions.find(
|
|
6779
|
+
({ id }) => id === action.originalActionId
|
|
6780
|
+
);
|
|
6781
|
+
if (requestedAction?.status !== ActionStatus.Requested) {
|
|
6782
|
+
return action;
|
|
6783
|
+
}
|
|
6784
|
+
const content = getCompleteActionContent(event2, action);
|
|
6785
|
+
return {
|
|
6786
|
+
...completeAcceptedAction(event2, action),
|
|
6787
|
+
// Who requested the action, as getActionUpdateMetadata resolves it.
|
|
6788
|
+
createdBy: requestedAction.createdBy,
|
|
6789
|
+
createdByRole: requestedAction.createdByRole,
|
|
6790
|
+
createdByUserType: requestedAction.createdByUserType,
|
|
6791
|
+
createdAtLocation: requestedAction.createdAtLocation,
|
|
6792
|
+
...content ? { content } : {}
|
|
6793
|
+
};
|
|
6794
|
+
})
|
|
6795
|
+
};
|
|
6751
6796
|
}
|
|
6752
6797
|
var EXCLUDED_ACTIONS = [
|
|
6753
6798
|
ActionType.REQUEST_CORRECTION,
|
|
@@ -6846,6 +6891,20 @@ function dropSecuredDeclarationFields(eventConfig, eventIndex, validatorContext)
|
|
|
6846
6891
|
}
|
|
6847
6892
|
|
|
6848
6893
|
// ../commons/src/events/eventConfigValidation.ts
|
|
6894
|
+
var SEARCH_DEFAULT_VALUE_FIELD_TYPES = [
|
|
6895
|
+
FieldType.TEXT,
|
|
6896
|
+
FieldType.TEXTAREA,
|
|
6897
|
+
FieldType.EMAIL,
|
|
6898
|
+
FieldType.PHONE,
|
|
6899
|
+
FieldType.ID,
|
|
6900
|
+
FieldType.SELECT,
|
|
6901
|
+
FieldType.RADIO_GROUP,
|
|
6902
|
+
FieldType.COUNTRY,
|
|
6903
|
+
FieldType.LOCATION,
|
|
6904
|
+
FieldType.ADMINISTRATIVE_AREA,
|
|
6905
|
+
FieldType.NUMBER,
|
|
6906
|
+
FieldType.DATE
|
|
6907
|
+
];
|
|
6849
6908
|
function validateAdvancedSearchConfig(event2, ctx) {
|
|
6850
6909
|
const allFields = findAllFields(event2);
|
|
6851
6910
|
const fieldIds = allFields.map((field3) => field3.id);
|
|
@@ -6877,6 +6936,56 @@ function validateAdvancedSearchConfig(event2, ctx) {
|
|
|
6877
6936
|
path: ["advancedSearch"]
|
|
6878
6937
|
});
|
|
6879
6938
|
}
|
|
6939
|
+
event2.advancedSearch.forEach((section, sectionIndex) => {
|
|
6940
|
+
section.fields.forEach((searchField, fieldIndex) => {
|
|
6941
|
+
if (searchField.fieldType !== "field" || searchField.defaultValue === void 0) {
|
|
6942
|
+
return;
|
|
6943
|
+
}
|
|
6944
|
+
const path = [
|
|
6945
|
+
"advancedSearch",
|
|
6946
|
+
sectionIndex,
|
|
6947
|
+
"fields",
|
|
6948
|
+
fieldIndex,
|
|
6949
|
+
"defaultValue"
|
|
6950
|
+
];
|
|
6951
|
+
if (searchField.config.searchFields && searchField.config.searchFields.length > 0) {
|
|
6952
|
+
ctx.addIssue({
|
|
6953
|
+
code: "custom",
|
|
6954
|
+
message: `Advanced search field ${searchField.fieldId} searches across several form fields, so it does not support a defaultValue.`,
|
|
6955
|
+
path
|
|
6956
|
+
});
|
|
6957
|
+
return;
|
|
6958
|
+
}
|
|
6959
|
+
if (typeof searchField.defaultValue === "boolean") {
|
|
6960
|
+
return;
|
|
6961
|
+
}
|
|
6962
|
+
const formField = allFields.find(({ id }) => id === searchField.fieldId);
|
|
6963
|
+
if (!formField) {
|
|
6964
|
+
return;
|
|
6965
|
+
}
|
|
6966
|
+
if (!SEARCH_DEFAULT_VALUE_FIELD_TYPES.some(
|
|
6967
|
+
(type) => type === formField.type
|
|
6968
|
+
)) {
|
|
6969
|
+
ctx.addIssue({
|
|
6970
|
+
code: "custom",
|
|
6971
|
+
message: `Advanced search field ${searchField.fieldId} is a ${formField.type} field, which does not support a defaultValue value, only true or false. Field types that support a defaultValue value: ${SEARCH_DEFAULT_VALUE_FIELD_TYPES.join(", ")}.`,
|
|
6972
|
+
path
|
|
6973
|
+
});
|
|
6974
|
+
} else if (formField.type === FieldType.DATE && searchField.config.type === "range") {
|
|
6975
|
+
ctx.addIssue({
|
|
6976
|
+
code: "custom",
|
|
6977
|
+
message: `Advanced search field ${searchField.fieldId} is searched as a date range, so its defaultValue can only be true or false.`,
|
|
6978
|
+
path
|
|
6979
|
+
});
|
|
6980
|
+
} else if (!mapFieldTypeToZod(formField).safeParse(searchField.defaultValue).success) {
|
|
6981
|
+
ctx.addIssue({
|
|
6982
|
+
code: "custom",
|
|
6983
|
+
message: `Advanced search field ${searchField.fieldId} has defaultValue "${searchField.defaultValue}", which is not a valid ${formField.type} value.`,
|
|
6984
|
+
path
|
|
6985
|
+
});
|
|
6986
|
+
}
|
|
6987
|
+
});
|
|
6988
|
+
});
|
|
6880
6989
|
}
|
|
6881
6990
|
function validateDateOfEvent(event2, ctx) {
|
|
6882
6991
|
if (event2.dateOfEvent && isFieldReference(event2.dateOfEvent)) {
|
|
@@ -7049,10 +7158,16 @@ function validateNotificationForm(event2, ctx) {
|
|
|
7049
7158
|
var EventFieldReference = z35.object({ $$event: EventMetadataDateFieldIdInput }).describe(
|
|
7050
7159
|
"Reference to a field defined in the event metadata, using the field id."
|
|
7051
7160
|
);
|
|
7052
|
-
var
|
|
7161
|
+
var eventLevelFields = {
|
|
7053
7162
|
id: z35.string().describe(
|
|
7054
7163
|
'Machine-readable identifier of the event (e.g. "birth", "death").'
|
|
7055
7164
|
),
|
|
7165
|
+
label: TranslationConfig.describe("Human-readable label for the event type."),
|
|
7166
|
+
advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
|
|
7167
|
+
"Configuration of fields available in the advanced search feature."
|
|
7168
|
+
)
|
|
7169
|
+
};
|
|
7170
|
+
var versionFields = {
|
|
7056
7171
|
dateOfEvent: FieldReference.or(EventFieldReference).optional().describe(
|
|
7057
7172
|
"Reference to the field capturing the date of the event (e.g. date of birth). Defaults to the event creation date if unspecified."
|
|
7058
7173
|
),
|
|
@@ -7068,18 +7183,12 @@ var _EventConfigBase = z35.object({
|
|
|
7068
7183
|
summary: SummaryConfig.describe(
|
|
7069
7184
|
"Summary information displayed in the event overview."
|
|
7070
7185
|
),
|
|
7071
|
-
label: TranslationConfig.describe(
|
|
7072
|
-
"Human-readable label for the event type."
|
|
7073
|
-
),
|
|
7074
7186
|
actions: z35.array(ActionConfig).describe(
|
|
7075
7187
|
"Configuration of core and custom actions associated with the event."
|
|
7076
7188
|
),
|
|
7077
7189
|
actionOrder: z35.array(z35.string()).optional().describe(
|
|
7078
7190
|
"Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
|
|
7079
7191
|
),
|
|
7080
|
-
advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
|
|
7081
|
-
"Configuration of fields available in the advanced search feature."
|
|
7082
|
-
),
|
|
7083
7192
|
flags: z35.array(FlagConfig).optional().default([]).describe(
|
|
7084
7193
|
"Configuration of custom flags associated with the actions of this event type."
|
|
7085
7194
|
),
|
|
@@ -7089,8 +7198,9 @@ var _EventConfigBase = z35.object({
|
|
|
7089
7198
|
icon: z35.partialRecord(AvailableIcons, Conditional).optional().describe(
|
|
7090
7199
|
'Maps an icon name to a conditional. The icon of the first entry (in definition order) whose conditional matches the event is used when rendering it (e.g. in the "iconWithName"/"iconWithNameEvent" workqueue columns). Falls back to the default status-based icon when unset or when no conditional matches.'
|
|
7091
7200
|
)
|
|
7092
|
-
}
|
|
7093
|
-
var
|
|
7201
|
+
};
|
|
7202
|
+
var _EventConfigBase = z35.object({ ...eventLevelFields, ...versionFields });
|
|
7203
|
+
function validateEventConfig(event2, ctx) {
|
|
7094
7204
|
if (!validateExactlyOneDeclareAction(event2, ctx)) {
|
|
7095
7205
|
return;
|
|
7096
7206
|
}
|
|
@@ -7100,10 +7210,116 @@ var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
|
|
|
7100
7210
|
validatePlaceOfEvent(event2, ctx);
|
|
7101
7211
|
validateActionFlags(event2, ctx);
|
|
7102
7212
|
validateActionOrder(event2, ctx);
|
|
7103
|
-
}
|
|
7213
|
+
}
|
|
7214
|
+
var EventConfig = _EventConfigBase.superRefine(validateEventConfig).meta({
|
|
7104
7215
|
id: "EventConfig",
|
|
7105
7216
|
description: "Configuration defining an event type registered in OpenCRVS (for example birth or death)."
|
|
7106
7217
|
});
|
|
7218
|
+
var DEFAULT_EVENT_CONFIG_VERSION_ID = "default";
|
|
7219
|
+
var DEFAULT_EFFECTIVE_FROM = "0001-01-01";
|
|
7220
|
+
var _EventConfigVersion = z35.object({
|
|
7221
|
+
id: z35.string().describe(
|
|
7222
|
+
'Identifier of the version, unique within the event (e.g. "birth-v2").'
|
|
7223
|
+
),
|
|
7224
|
+
effectiveFrom: z35.iso.date().default(DEFAULT_EFFECTIVE_FROM).describe(
|
|
7225
|
+
`Date (YYYY-MM-DD) from which this version is effective. A version without one is effective from the beginning of time ('${DEFAULT_EFFECTIVE_FROM}').`
|
|
7226
|
+
),
|
|
7227
|
+
...versionFields
|
|
7228
|
+
});
|
|
7229
|
+
var resolvedConfigs = /* @__PURE__ */ new WeakMap();
|
|
7230
|
+
function getEventConfigOfVersion(config, version) {
|
|
7231
|
+
let resolvedVersions = resolvedConfigs.get(config);
|
|
7232
|
+
if (!resolvedVersions) {
|
|
7233
|
+
resolvedVersions = /* @__PURE__ */ new WeakMap();
|
|
7234
|
+
resolvedConfigs.set(config, resolvedVersions);
|
|
7235
|
+
}
|
|
7236
|
+
const cached = resolvedVersions.get(version);
|
|
7237
|
+
if (cached) {
|
|
7238
|
+
return cached;
|
|
7239
|
+
}
|
|
7240
|
+
const { id: _id, effectiveFrom: _effectiveFrom, ...fields } = version;
|
|
7241
|
+
const resolved = {
|
|
7242
|
+
...fields,
|
|
7243
|
+
id: config.id,
|
|
7244
|
+
label: config.label,
|
|
7245
|
+
advancedSearch: config.advancedSearch
|
|
7246
|
+
};
|
|
7247
|
+
resolvedVersions.set(version, resolved);
|
|
7248
|
+
return resolved;
|
|
7249
|
+
}
|
|
7250
|
+
function resolveEventConfig(config) {
|
|
7251
|
+
return getEventConfigOfVersion(config, config.versions[0]);
|
|
7252
|
+
}
|
|
7253
|
+
function validateVersionList(config, ctx) {
|
|
7254
|
+
const ids = /* @__PURE__ */ new Set();
|
|
7255
|
+
const versionIdByEffectiveFrom = /* @__PURE__ */ new Map();
|
|
7256
|
+
config.versions.forEach((version, index) => {
|
|
7257
|
+
if (ids.has(version.id)) {
|
|
7258
|
+
ctx.addIssue({
|
|
7259
|
+
code: "custom",
|
|
7260
|
+
message: `Event '${config.id}' has more than one version with id '${version.id}'. Each version must have a different id.`,
|
|
7261
|
+
path: ["versions", index, "id"]
|
|
7262
|
+
});
|
|
7263
|
+
}
|
|
7264
|
+
ids.add(version.id);
|
|
7265
|
+
const sameEffectiveFromId = versionIdByEffectiveFrom.get(
|
|
7266
|
+
version.effectiveFrom
|
|
7267
|
+
);
|
|
7268
|
+
if (sameEffectiveFromId !== void 0) {
|
|
7269
|
+
const versionIds = `'${sameEffectiveFromId}', '${version.id}'`;
|
|
7270
|
+
ctx.addIssue({
|
|
7271
|
+
code: "custom",
|
|
7272
|
+
message: version.effectiveFrom !== DEFAULT_EFFECTIVE_FROM ? `Event '${config.id}' has more than one version with \`effectiveFrom\` '${version.effectiveFrom}' (${versionIds}). Each version must have a different \`effectiveFrom\`.` : `Event '${config.id}' has more than one version without \`effectiveFrom\` (${versionIds}). At most one version may omit it.`,
|
|
7273
|
+
path: ["versions", index, "effectiveFrom"]
|
|
7274
|
+
});
|
|
7275
|
+
} else {
|
|
7276
|
+
versionIdByEffectiveFrom.set(version.effectiveFrom, version.id);
|
|
7277
|
+
}
|
|
7278
|
+
});
|
|
7279
|
+
}
|
|
7280
|
+
function validateEachVersion(ctx, events, validate2) {
|
|
7281
|
+
const reported = /* @__PURE__ */ new Set();
|
|
7282
|
+
events.forEach((event2, index) => {
|
|
7283
|
+
const addIssue = (issue) => {
|
|
7284
|
+
if (typeof issue === "string") {
|
|
7285
|
+
ctx.addIssue({
|
|
7286
|
+
code: "custom",
|
|
7287
|
+
message: issue,
|
|
7288
|
+
path: ["versions", index]
|
|
7289
|
+
});
|
|
7290
|
+
return;
|
|
7291
|
+
}
|
|
7292
|
+
const [field3] = issue.path ?? [];
|
|
7293
|
+
const isEventLevel = typeof field3 === "string" && field3 in eventLevelFields;
|
|
7294
|
+
const path = isEventLevel ? issue.path ?? [] : ["versions", index, ...issue.path ?? []];
|
|
7295
|
+
const key = JSON.stringify([path, issue.message]);
|
|
7296
|
+
if (reported.has(key)) {
|
|
7297
|
+
return;
|
|
7298
|
+
}
|
|
7299
|
+
reported.add(key);
|
|
7300
|
+
ctx.addIssue({ ...issue, path });
|
|
7301
|
+
};
|
|
7302
|
+
validate2(event2, { value: event2, addIssue });
|
|
7303
|
+
});
|
|
7304
|
+
}
|
|
7305
|
+
var VersionedEventConfig = z35.object({
|
|
7306
|
+
...eventLevelFields,
|
|
7307
|
+
versions: z35.array(_EventConfigVersion).min(1).describe(
|
|
7308
|
+
`Versions of the event configuration, each effective from its \`effectiveFrom\`. An event configured without versions has a single version, with id '${DEFAULT_EVENT_CONFIG_VERSION_ID}' and \`effectiveFrom\` '${DEFAULT_EFFECTIVE_FROM}'.`
|
|
7309
|
+
)
|
|
7310
|
+
}).superRefine((config, ctx) => {
|
|
7311
|
+
validateVersionList(config, ctx);
|
|
7312
|
+
validateEachVersion(
|
|
7313
|
+
ctx,
|
|
7314
|
+
config.versions.map(
|
|
7315
|
+
(version) => getEventConfigOfVersion(config, version)
|
|
7316
|
+
),
|
|
7317
|
+
validateEventConfig
|
|
7318
|
+
);
|
|
7319
|
+
}).meta({
|
|
7320
|
+
id: "VersionedEventConfig",
|
|
7321
|
+
description: "Configuration of an event type registered in OpenCRVS (for example birth or death), with every version of it."
|
|
7322
|
+
});
|
|
7107
7323
|
|
|
7108
7324
|
// ../commons/src/events/EventConfigInput.ts
|
|
7109
7325
|
var defineDeclarationForm = (form) => DeclarationFormConfig.parse(form);
|
|
@@ -7203,7 +7419,10 @@ function eventFn(fieldId) {
|
|
|
7203
7419
|
}
|
|
7204
7420
|
var event = Object.assign(eventFn, {
|
|
7205
7421
|
/**
|
|
7206
|
-
* Checks if the event contains a specific action type.
|
|
7422
|
+
* Checks if the event contains a specific accepted action type.
|
|
7423
|
+
* Only Accepted actions are matched: a confirmable action is stored as a
|
|
7424
|
+
* Requested and an Accepted action, and a pending or rejected request must
|
|
7425
|
+
* not count as the action having happened.
|
|
7207
7426
|
* Can be used directly as a conditional or chained with additional methods.
|
|
7208
7427
|
* @param action - The action type to check for.
|
|
7209
7428
|
*/
|
|
@@ -7221,9 +7440,12 @@ var event = Object.assign(eventFn, {
|
|
|
7221
7440
|
properties: {
|
|
7222
7441
|
type: {
|
|
7223
7442
|
const: action
|
|
7443
|
+
},
|
|
7444
|
+
status: {
|
|
7445
|
+
const: ActionStatus.Accepted
|
|
7224
7446
|
}
|
|
7225
7447
|
},
|
|
7226
|
-
required: ["type"]
|
|
7448
|
+
required: ["type", "status"]
|
|
7227
7449
|
}
|
|
7228
7450
|
}
|
|
7229
7451
|
},
|
|
@@ -7234,9 +7456,10 @@ var event = Object.assign(eventFn, {
|
|
|
7234
7456
|
});
|
|
7235
7457
|
const buildActionConstraints = (additionalFields) => {
|
|
7236
7458
|
const actionProperties = {
|
|
7237
|
-
type: { const: action }
|
|
7459
|
+
type: { const: action },
|
|
7460
|
+
status: { const: ActionStatus.Accepted }
|
|
7238
7461
|
};
|
|
7239
|
-
const requiredFields = ["type"];
|
|
7462
|
+
const requiredFields = ["type", "status"];
|
|
7240
7463
|
if (additionalFields) {
|
|
7241
7464
|
Object.entries(additionalFields).forEach(([key, value]) => {
|
|
7242
7465
|
actionProperties[key] = { const: value };
|
|
@@ -7717,17 +7940,19 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
|
|
|
7717
7940
|
/*
|
|
7718
7941
|
* A draft can name a file that no action references. Such a file stays until
|
|
7719
7942
|
* the record is deleted or the record's next action sweeps its prefix.
|
|
7720
|
-
*
|
|
7721
|
-
*
|
|
7722
|
-
* which is about to be declared or registered.
|
|
7943
|
+
* Drafts are therefore saved only on a created record, which can still be deleted.
|
|
7944
|
+
* The server refuses them on any other record.
|
|
7723
7945
|
*/
|
|
7724
|
-
type: z40.
|
|
7946
|
+
type: z40.enum([ActionTypes.enum.DECLARE, ActionTypes.enum.NOTIFY]),
|
|
7725
7947
|
status: z40.enum([
|
|
7726
7948
|
ActionStatus.Requested,
|
|
7727
7949
|
ActionStatus.Accepted,
|
|
7728
7950
|
ActionStatus.Rejected
|
|
7729
7951
|
])
|
|
7730
7952
|
});
|
|
7953
|
+
var RemoteDraft = Draft.extend({
|
|
7954
|
+
action: Draft.shape.action.extend({ type: DraftInput.shape.type })
|
|
7955
|
+
});
|
|
7731
7956
|
|
|
7732
7957
|
// ../commons/src/events/EventInput.ts
|
|
7733
7958
|
var z41 = __toESM(require("zod/v4"));
|
|
@@ -7771,16 +7996,55 @@ function moveDeclarationToDeclareAction({
|
|
|
7771
7996
|
}
|
|
7772
7997
|
return {
|
|
7773
7998
|
...config,
|
|
7774
|
-
actions: config.actions.map(
|
|
7775
|
-
(action
|
|
7776
|
-
|
|
7999
|
+
actions: config.actions.map((action) => {
|
|
8000
|
+
if (action.type !== ActionType.DECLARE) {
|
|
8001
|
+
return action;
|
|
8002
|
+
}
|
|
8003
|
+
const declarationOfAction = action.declaration ?? declaration;
|
|
8004
|
+
if (!declarationOfAction) {
|
|
8005
|
+
throw new Error(`Event '${config.id}' does not define \`declaration\`.`);
|
|
8006
|
+
}
|
|
8007
|
+
return { ...action, declaration: declarationOfAction };
|
|
8008
|
+
})
|
|
8009
|
+
};
|
|
8010
|
+
}
|
|
8011
|
+
var VERSIONED_EVENT_FIELDS = [
|
|
8012
|
+
"id",
|
|
8013
|
+
"label",
|
|
8014
|
+
"advancedSearch",
|
|
8015
|
+
"versions"
|
|
8016
|
+
];
|
|
8017
|
+
function validateNoVersionFieldsAtTopLevel(config, ctx) {
|
|
8018
|
+
Object.keys(config).filter((key) => !VERSIONED_EVENT_FIELDS.includes(key)).forEach((key) => {
|
|
8019
|
+
ctx.addIssue({
|
|
8020
|
+
code: "custom",
|
|
8021
|
+
message: `Event '${config.id}' defines \`versions\`, so \`${key}\` must be defined on each version, not at the top level.`,
|
|
8022
|
+
path: [key]
|
|
8023
|
+
});
|
|
8024
|
+
});
|
|
8025
|
+
}
|
|
8026
|
+
function toVersionedInput(config) {
|
|
8027
|
+
if ("versions" in config) {
|
|
8028
|
+
return config;
|
|
8029
|
+
}
|
|
8030
|
+
const { id, label, advancedSearch, ...version } = moveDeclarationToDeclareAction(config);
|
|
8031
|
+
return {
|
|
8032
|
+
id,
|
|
8033
|
+
label,
|
|
8034
|
+
advancedSearch,
|
|
8035
|
+
versions: [{ ...version, id: DEFAULT_EVENT_CONFIG_VERSION_ID }]
|
|
7777
8036
|
};
|
|
7778
8037
|
}
|
|
7779
8038
|
var EventConfigDefinition = z43.custom().superRefine((config, ctx) => {
|
|
7780
|
-
if (
|
|
7781
|
-
|
|
8039
|
+
if ("versions" in config) {
|
|
8040
|
+
validateNoVersionFieldsAtTopLevel(config, ctx);
|
|
8041
|
+
return;
|
|
8042
|
+
}
|
|
8043
|
+
const eventCtx = { ...ctx, value: config };
|
|
8044
|
+
if (validateExactlyOneDeclareAction(config, eventCtx)) {
|
|
8045
|
+
validateDeclarationGivenExactlyOnce(config, eventCtx);
|
|
7782
8046
|
}
|
|
7783
|
-
}).transform(
|
|
8047
|
+
}).transform(toVersionedInput).pipe(VersionedEventConfig);
|
|
7784
8048
|
var defineConfig = (config) => EventConfigDefinition.parse(config);
|
|
7785
8049
|
|
|
7786
8050
|
// ../commons/src/events/toNotificationForm.ts
|
|
@@ -9071,7 +9335,7 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
|
9071
9335
|
});
|
|
9072
9336
|
|
|
9073
9337
|
// ../commons/src/fixtures/tennis-club-membership-event.ts
|
|
9074
|
-
var
|
|
9338
|
+
var versionedTennisClubMembershipEvent = defineConfig({
|
|
9075
9339
|
id: TENNIS_CLUB_MEMBERSHIP,
|
|
9076
9340
|
declaration: TENNIS_CLUB_DECLARATION_FORM,
|
|
9077
9341
|
label: {
|
|
@@ -9428,9 +9692,12 @@ var tennisClubMembershipEvent = defineConfig({
|
|
|
9428
9692
|
}
|
|
9429
9693
|
]
|
|
9430
9694
|
});
|
|
9695
|
+
var tennisClubMembershipEvent = resolveEventConfig(
|
|
9696
|
+
versionedTennisClubMembershipEvent
|
|
9697
|
+
);
|
|
9431
9698
|
|
|
9432
9699
|
// ../commons/src/fixtures/football-club-membership-event.ts
|
|
9433
|
-
var
|
|
9700
|
+
var versionedFootballClubMembershipEvent = defineConfig({
|
|
9434
9701
|
id: "FOOTBALL_CLUB_MEMBERSHIP",
|
|
9435
9702
|
label: {
|
|
9436
9703
|
defaultMessage: "Football club membership application",
|
|
@@ -9753,6 +10020,9 @@ var footballClubMembershipEvent = defineConfig({
|
|
|
9753
10020
|
],
|
|
9754
10021
|
declaration: TENNIS_CLUB_DECLARATION_FORM
|
|
9755
10022
|
});
|
|
10023
|
+
var footballClubMembershipEvent = resolveEventConfig(
|
|
10024
|
+
versionedFootballClubMembershipEvent
|
|
10025
|
+
);
|
|
9756
10026
|
|
|
9757
10027
|
// ../commons/src/fixtures/library-membership-event.ts
|
|
9758
10028
|
var libraryMembershipForm = defineDeclarationForm({
|
|
@@ -9796,7 +10066,7 @@ var libraryMembershipForm = defineDeclarationForm({
|
|
|
9796
10066
|
}
|
|
9797
10067
|
]
|
|
9798
10068
|
});
|
|
9799
|
-
var
|
|
10069
|
+
var versionedLibraryMembershipEvent = defineConfig({
|
|
9800
10070
|
id: "library-membership",
|
|
9801
10071
|
label: {
|
|
9802
10072
|
defaultMessage: "Library membership application",
|
|
@@ -9829,6 +10099,9 @@ var libraryMembershipEvent = defineConfig({
|
|
|
9829
10099
|
],
|
|
9830
10100
|
declaration: libraryMembershipForm
|
|
9831
10101
|
});
|
|
10102
|
+
var libraryMembershipEvent = resolveEventConfig(
|
|
10103
|
+
versionedLibraryMembershipEvent
|
|
10104
|
+
);
|
|
9832
10105
|
|
|
9833
10106
|
// ../commons/src/fixtures/child-onboarding-event.ts
|
|
9834
10107
|
function generateTranslationConfig(message) {
|
|
@@ -10042,7 +10315,7 @@ var CHILD_ONBOARDING_DECLARATION_FORM = defineDeclarationForm({
|
|
|
10042
10315
|
label: generateTranslationConfig("Birth decalration form"),
|
|
10043
10316
|
pages: [child, mother]
|
|
10044
10317
|
});
|
|
10045
|
-
var
|
|
10318
|
+
var versionedChildOnboardingEvent = defineConfig({
|
|
10046
10319
|
id: CHILD_ONBOARDING_EVENT,
|
|
10047
10320
|
title: generateTranslationConfig(
|
|
10048
10321
|
"{child.name.firstname} {child.name.surname}"
|
|
@@ -10070,6 +10343,9 @@ var ChildOnboardingEvent = defineConfig({
|
|
|
10070
10343
|
],
|
|
10071
10344
|
advancedSearch: []
|
|
10072
10345
|
});
|
|
10346
|
+
var ChildOnboardingEvent = resolveEventConfig(
|
|
10347
|
+
versionedChildOnboardingEvent
|
|
10348
|
+
);
|
|
10073
10349
|
|
|
10074
10350
|
// ../commons/src/fixtures/digital-identity-issuance-event.ts
|
|
10075
10351
|
var PRINT_DIGITAL_ID_CERTIFICATE_FORM = defineActionForm({
|
|
@@ -10258,7 +10534,7 @@ var digitalIdentityForm = defineDeclarationForm({
|
|
|
10258
10534
|
}
|
|
10259
10535
|
]
|
|
10260
10536
|
});
|
|
10261
|
-
var
|
|
10537
|
+
var versionedDigitalIdentityEvent = defineConfig({
|
|
10262
10538
|
id: "digital-identity",
|
|
10263
10539
|
label: {
|
|
10264
10540
|
defaultMessage: "Digital identity issuance",
|
|
@@ -10300,6 +10576,9 @@ var digitalIdentityEvent = defineConfig({
|
|
|
10300
10576
|
],
|
|
10301
10577
|
declaration: digitalIdentityForm
|
|
10302
10578
|
});
|
|
10579
|
+
var digitalIdentityEvent = resolveEventConfig(
|
|
10580
|
+
versionedDigitalIdentityEvent
|
|
10581
|
+
);
|
|
10303
10582
|
|
|
10304
10583
|
// ../commons/src/events/test.utils.ts
|
|
10305
10584
|
var z45 = __toESM(require("zod/v4"));
|
|
@@ -11583,9 +11862,9 @@ function generateActionDocument({
|
|
|
11583
11862
|
return { ...actionBase, type: action };
|
|
11584
11863
|
case ActionType.EDIT:
|
|
11585
11864
|
return {
|
|
11865
|
+
content: { comment: "Test comment" },
|
|
11586
11866
|
...actionBase,
|
|
11587
|
-
type: action
|
|
11588
|
-
content: { comment: "Test comment" }
|
|
11867
|
+
type: action
|
|
11589
11868
|
};
|
|
11590
11869
|
case ActionType.CUSTOM:
|
|
11591
11870
|
return {
|
|
@@ -11604,9 +11883,9 @@ function generateActionDocument({
|
|
|
11604
11883
|
};
|
|
11605
11884
|
}
|
|
11606
11885
|
case ActionType.ARCHIVE:
|
|
11607
|
-
return {
|
|
11886
|
+
return { content: { reason: "Archive" }, ...actionBase, type: action };
|
|
11608
11887
|
case ActionType.REJECT:
|
|
11609
|
-
return {
|
|
11888
|
+
return { content: { reason: "Reject" }, ...actionBase, type: action };
|
|
11610
11889
|
case ActionType.PRINT_CERTIFICATE: {
|
|
11611
11890
|
const printActionDefaults = defaults;
|
|
11612
11891
|
return {
|
|
@@ -11616,13 +11895,13 @@ function generateActionDocument({
|
|
|
11616
11895
|
};
|
|
11617
11896
|
}
|
|
11618
11897
|
case ActionType.APPROVE_CORRECTION:
|
|
11619
|
-
return {
|
|
11898
|
+
return { requestId: getUUID(), ...actionBase, type: action };
|
|
11620
11899
|
case ActionType.REJECT_CORRECTION:
|
|
11621
11900
|
return {
|
|
11622
|
-
...actionBase,
|
|
11623
11901
|
requestId: getUUID(),
|
|
11624
|
-
|
|
11625
|
-
|
|
11902
|
+
content: { reason: "Correction rejection" },
|
|
11903
|
+
...actionBase,
|
|
11904
|
+
type: action
|
|
11626
11905
|
};
|
|
11627
11906
|
case ActionType.DUPLICATE_DETECTED: {
|
|
11628
11907
|
const duplicateActionDefaults = defaults;
|
|
@@ -11639,6 +11918,65 @@ function generateActionDocument({
|
|
|
11639
11918
|
throw new Error(`Unsupported action type: ${action}`);
|
|
11640
11919
|
}
|
|
11641
11920
|
}
|
|
11921
|
+
function isConfirmableAction(type) {
|
|
11922
|
+
return ConfirmableActions.some((confirmable) => confirmable === type);
|
|
11923
|
+
}
|
|
11924
|
+
function generateActionDocuments({
|
|
11925
|
+
confirmation,
|
|
11926
|
+
...args
|
|
11927
|
+
}) {
|
|
11928
|
+
const actionDocument = generateActionDocument(args);
|
|
11929
|
+
if (!isConfirmableAction(actionDocument.type)) {
|
|
11930
|
+
return [actionDocument];
|
|
11931
|
+
}
|
|
11932
|
+
if (args.defaults?.status !== void 0) {
|
|
11933
|
+
throw new Error(
|
|
11934
|
+
`generateActionDocuments: set the status of ${actionDocument.type} with confirmation.status, not defaults.status`
|
|
11935
|
+
);
|
|
11936
|
+
}
|
|
11937
|
+
const status2 = confirmation?.status ?? ActionStatus.Accepted;
|
|
11938
|
+
if (status2 === ActionStatus.Requested) {
|
|
11939
|
+
if (confirmation?.defaults) {
|
|
11940
|
+
throw new Error(
|
|
11941
|
+
"generateActionDocuments: confirmation.defaults have no confirming action to apply to while the request is pending"
|
|
11942
|
+
);
|
|
11943
|
+
}
|
|
11944
|
+
return [{ ...actionDocument, status: ActionStatus.Requested }];
|
|
11945
|
+
}
|
|
11946
|
+
const requestedAction = {
|
|
11947
|
+
...actionDocument,
|
|
11948
|
+
id: getUUID(),
|
|
11949
|
+
status: ActionStatus.Requested
|
|
11950
|
+
};
|
|
11951
|
+
const confirmingAction = {
|
|
11952
|
+
...actionDocument,
|
|
11953
|
+
originalActionId: requestedAction.id,
|
|
11954
|
+
createdAt: new Date(
|
|
11955
|
+
new Date(actionDocument.createdAt).getTime() + 1
|
|
11956
|
+
).toISOString(),
|
|
11957
|
+
...confirmation?.defaults
|
|
11958
|
+
};
|
|
11959
|
+
if (status2 === ActionStatus.Rejected) {
|
|
11960
|
+
const { declaration, annotation, ...rejectedAction } = confirmingAction;
|
|
11961
|
+
return [
|
|
11962
|
+
requestedAction,
|
|
11963
|
+
{
|
|
11964
|
+
...rejectedAction,
|
|
11965
|
+
type: actionDocument.type,
|
|
11966
|
+
status: ActionStatus.Rejected
|
|
11967
|
+
}
|
|
11968
|
+
];
|
|
11969
|
+
}
|
|
11970
|
+
return [
|
|
11971
|
+
requestedAction,
|
|
11972
|
+
{
|
|
11973
|
+
...confirmingAction,
|
|
11974
|
+
status: ActionStatus.Accepted,
|
|
11975
|
+
declaration: {},
|
|
11976
|
+
annotation: {}
|
|
11977
|
+
}
|
|
11978
|
+
];
|
|
11979
|
+
}
|
|
11642
11980
|
function generateRandomDatetime(rng, start, end) {
|
|
11643
11981
|
const range = end.getTime() - start.getTime();
|
|
11644
11982
|
const offset = Math.floor(rng() * range);
|
|
@@ -11658,8 +11996,18 @@ function generateEventDocument({
|
|
|
11658
11996
|
return {
|
|
11659
11997
|
trackingId: generateTrackingId(rng),
|
|
11660
11998
|
type: configuration.id,
|
|
11661
|
-
actions: actions.
|
|
11662
|
-
(
|
|
11999
|
+
actions: actions.flatMap((action, i) => {
|
|
12000
|
+
const createdAt = (0, import_date_fns4.addDays)(
|
|
12001
|
+
new Date(
|
|
12002
|
+
generateRandomDatetime(
|
|
12003
|
+
rng,
|
|
12004
|
+
new Date(2025, 0, 1),
|
|
12005
|
+
new Date(2025, 11, 31)
|
|
12006
|
+
)
|
|
12007
|
+
),
|
|
12008
|
+
i
|
|
12009
|
+
);
|
|
12010
|
+
return generateActionDocuments({
|
|
11663
12011
|
configuration,
|
|
11664
12012
|
action: action.type,
|
|
11665
12013
|
defaults: {
|
|
@@ -11667,20 +12015,11 @@ function generateEventDocument({
|
|
|
11667
12015
|
createdAtLocation: action.user?.primaryOfficeId,
|
|
11668
12016
|
assignedTo: action.user?.assignedTo,
|
|
11669
12017
|
createdByRole: action.user?.role,
|
|
11670
|
-
createdAt: (
|
|
11671
|
-
new Date(
|
|
11672
|
-
generateRandomDatetime(
|
|
11673
|
-
rng,
|
|
11674
|
-
new Date(2025, 0, 1),
|
|
11675
|
-
new Date(2025, 11, 31)
|
|
11676
|
-
)
|
|
11677
|
-
),
|
|
11678
|
-
i
|
|
11679
|
-
).toISOString()
|
|
12018
|
+
createdAt: createdAt.toISOString()
|
|
11680
12019
|
},
|
|
11681
12020
|
declarationOverrides: action.declarationOverrides
|
|
11682
|
-
})
|
|
11683
|
-
),
|
|
12021
|
+
});
|
|
12022
|
+
}),
|
|
11684
12023
|
// Offset is needed so the createdAt timestamps for events, actions and drafts make logical sense in storybook tests.
|
|
11685
12024
|
// @TODO: This should be fixed in the future.
|
|
11686
12025
|
createdAt: new Date(Date.now() - 1e3).toISOString(),
|
|
@@ -11707,6 +12046,7 @@ function generateEventDraftDocument({
|
|
|
11707
12046
|
transactionId: getUUID(),
|
|
11708
12047
|
action: {
|
|
11709
12048
|
...action,
|
|
12049
|
+
type: actionType,
|
|
11710
12050
|
declaration: {
|
|
11711
12051
|
...action.declaration,
|
|
11712
12052
|
...declaration
|
|
@@ -11794,45 +12134,47 @@ var generateEventConfig = ({
|
|
|
11794
12134
|
dateOfEventId,
|
|
11795
12135
|
actions = []
|
|
11796
12136
|
}) => {
|
|
11797
|
-
return
|
|
11798
|
-
|
|
11799
|
-
|
|
11800
|
-
|
|
11801
|
-
|
|
11802
|
-
|
|
11803
|
-
|
|
11804
|
-
placeOfEvent: placeOfEventId ? { $$field: placeOfEventId } : void 0,
|
|
11805
|
-
dateOfEvent: dateOfEventId ? { $$field: dateOfEventId } : void 0,
|
|
11806
|
-
declaration: {
|
|
11807
|
-
label: generateTranslationConfig2(`${id} Declaration`),
|
|
11808
|
-
pages: [
|
|
11809
|
-
{
|
|
11810
|
-
id: "page1",
|
|
11811
|
-
title: generateTranslationConfig2("Page 1"),
|
|
11812
|
-
fields
|
|
11813
|
-
}
|
|
11814
|
-
]
|
|
11815
|
-
},
|
|
11816
|
-
actions: [
|
|
11817
|
-
{
|
|
11818
|
-
type: ActionType.READ,
|
|
11819
|
-
label: generateTranslationConfig2("Read"),
|
|
11820
|
-
review: {
|
|
11821
|
-
title: generateTranslationConfig2("Review Read Action"),
|
|
11822
|
-
fields: []
|
|
11823
|
-
}
|
|
12137
|
+
return resolveEventConfig(
|
|
12138
|
+
defineConfig({
|
|
12139
|
+
id,
|
|
12140
|
+
label: generateTranslationConfig2(id),
|
|
12141
|
+
title: generateTranslationConfig2(`${id} Event`),
|
|
12142
|
+
summary: {
|
|
12143
|
+
fields: []
|
|
11824
12144
|
},
|
|
11825
|
-
{
|
|
11826
|
-
|
|
11827
|
-
|
|
11828
|
-
|
|
11829
|
-
|
|
11830
|
-
|
|
11831
|
-
|
|
12145
|
+
placeOfEvent: placeOfEventId ? { $$field: placeOfEventId } : void 0,
|
|
12146
|
+
dateOfEvent: dateOfEventId ? { $$field: dateOfEventId } : void 0,
|
|
12147
|
+
declaration: {
|
|
12148
|
+
label: generateTranslationConfig2(`${id} Declaration`),
|
|
12149
|
+
pages: [
|
|
12150
|
+
{
|
|
12151
|
+
id: "page1",
|
|
12152
|
+
title: generateTranslationConfig2("Page 1"),
|
|
12153
|
+
fields
|
|
12154
|
+
}
|
|
12155
|
+
]
|
|
11832
12156
|
},
|
|
11833
|
-
|
|
11834
|
-
|
|
11835
|
-
|
|
12157
|
+
actions: [
|
|
12158
|
+
{
|
|
12159
|
+
type: ActionType.READ,
|
|
12160
|
+
label: generateTranslationConfig2("Read"),
|
|
12161
|
+
review: {
|
|
12162
|
+
title: generateTranslationConfig2("Review Read Action"),
|
|
12163
|
+
fields: []
|
|
12164
|
+
}
|
|
12165
|
+
},
|
|
12166
|
+
{
|
|
12167
|
+
type: ActionType.DECLARE,
|
|
12168
|
+
label: generateTranslationConfig2("Declare"),
|
|
12169
|
+
review: {
|
|
12170
|
+
title: generateTranslationConfig2("Review Declare Action"),
|
|
12171
|
+
fields: []
|
|
12172
|
+
}
|
|
12173
|
+
},
|
|
12174
|
+
...actions
|
|
12175
|
+
]
|
|
12176
|
+
})
|
|
12177
|
+
);
|
|
11836
12178
|
};
|
|
11837
12179
|
function withDeclaration(configuration, declaration) {
|
|
11838
12180
|
return {
|
|
@@ -11896,6 +12238,25 @@ function generateTestValidatorContext(userRole2, eventWithConfig) {
|
|
|
11896
12238
|
event: getEventValidatorContext(event2, eventConfig)
|
|
11897
12239
|
};
|
|
11898
12240
|
}
|
|
12241
|
+
function toVersionedEventConfig({
|
|
12242
|
+
id,
|
|
12243
|
+
label,
|
|
12244
|
+
advancedSearch,
|
|
12245
|
+
...version
|
|
12246
|
+
}) {
|
|
12247
|
+
return {
|
|
12248
|
+
id,
|
|
12249
|
+
label,
|
|
12250
|
+
advancedSearch,
|
|
12251
|
+
versions: [
|
|
12252
|
+
{
|
|
12253
|
+
...version,
|
|
12254
|
+
id: DEFAULT_EVENT_CONFIG_VERSION_ID,
|
|
12255
|
+
effectiveFrom: DEFAULT_EFFECTIVE_FROM
|
|
12256
|
+
}
|
|
12257
|
+
]
|
|
12258
|
+
};
|
|
12259
|
+
}
|
|
11899
12260
|
|
|
11900
12261
|
// ../commons/src/events/TemplateConfig.ts
|
|
11901
12262
|
var window2 = () => ({
|
|
@@ -11952,6 +12313,8 @@ var ACTION_SCOPE_MAP = {
|
|
|
11952
12313
|
"record.correct"
|
|
11953
12314
|
],
|
|
11954
12315
|
[ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: ["record.correct"],
|
|
12316
|
+
// Not granted by a scope: the client checks the draft's own action instead
|
|
12317
|
+
[ClientSpecificAction.CONTINUE_DRAFT]: [],
|
|
11955
12318
|
[ActionType.REJECT_CORRECTION]: ["record.correct"],
|
|
11956
12319
|
[ActionType.APPROVE_CORRECTION]: ["record.correct"],
|
|
11957
12320
|
[ActionType.REVOKE_REGISTRATION]: ["record.revoke-registration"],
|