@opencrvs/toolkit 1.9.2-rc.f1d7235 → 1.9.2-rc.f5e3efd
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/commons/api/router.d.ts +220 -482
- package/dist/commons/events/ActionConfig.d.ts +13 -390
- package/dist/commons/events/ActionDocument.d.ts +44 -0
- package/dist/commons/events/ActionInput.d.ts +20 -0
- package/dist/commons/events/ActionType.d.ts +7 -1
- package/dist/commons/events/AdvancedSearchConfig.d.ts +0 -6
- package/dist/commons/events/CountryConfigQueryInput.d.ts +12 -0
- package/dist/commons/events/Draft.d.ts +2 -0
- package/dist/commons/events/EventConfig.d.ts +8 -318
- package/dist/commons/events/EventDocument.d.ts +22 -0
- package/dist/commons/events/EventIndex.d.ts +5 -1
- package/dist/commons/events/EventMetadata.d.ts +2 -3
- package/dist/commons/events/FieldConfig.d.ts +0 -80
- package/dist/commons/events/FieldType.d.ts +1 -2
- package/dist/commons/events/FieldTypeMapping.d.ts +1 -8
- package/dist/commons/events/FieldValue.d.ts +1 -2
- package/dist/commons/events/Flag.d.ts +3 -0
- package/dist/commons/events/FormConfig.d.ts +0 -234
- package/dist/commons/events/PageConfig.d.ts +0 -156
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +2 -5
- package/dist/commons/events/WorkqueueConfig.d.ts +19 -7
- package/dist/commons/events/defineConfig.d.ts +2 -446
- package/dist/commons/events/scopes.d.ts +1 -0
- package/dist/commons/events/state/index.d.ts +0 -6
- package/dist/commons/events/state/utils.d.ts +15 -1
- package/dist/commons/events/test.utils.d.ts +9 -1
- package/dist/commons/events/utils.d.ts +17 -887
- package/dist/events/index.js +73 -115
- package/dist/notification/index.js +27 -35
- package/dist/scopes/index.d.ts +6 -2
- package/dist/scopes/index.js +1 -0
- package/package.json +1 -1
package/dist/events/index.js
CHANGED
|
@@ -77,7 +77,6 @@ __export(events_exports, {
|
|
|
77
77
|
CustomActionInput: () => CustomActionInput,
|
|
78
78
|
CustomFlag: () => CustomFlag,
|
|
79
79
|
DEFAULT_DATE_OF_EVENT_PROPERTY: () => DEFAULT_DATE_OF_EVENT_PROPERTY,
|
|
80
|
-
DEFAULT_PLACE_OF_EVENT_PROPERTY: () => DEFAULT_PLACE_OF_EVENT_PROPERTY,
|
|
81
80
|
DataEntry: () => DataEntry,
|
|
82
81
|
DataFieldValue: () => DataFieldValue,
|
|
83
82
|
DateCondition: () => DateCondition,
|
|
@@ -100,6 +99,7 @@ __export(events_exports, {
|
|
|
100
99
|
DraftInput: () => DraftInput,
|
|
101
100
|
DuplicateDetectedAction: () => DuplicateDetectedAction,
|
|
102
101
|
DuplicateDetectedActionInput: () => DuplicateDetectedActionInput,
|
|
102
|
+
EditActionInput: () => EditActionInput,
|
|
103
103
|
EmailField: () => EmailField,
|
|
104
104
|
EmailValue: () => EmailValue,
|
|
105
105
|
EnableConditional: () => EnableConditional,
|
|
@@ -138,7 +138,6 @@ __export(events_exports, {
|
|
|
138
138
|
FormPageConfig: () => FormPageConfig,
|
|
139
139
|
Fuzzy: () => Fuzzy,
|
|
140
140
|
GeographicalArea: () => GeographicalArea,
|
|
141
|
-
HiddenFieldValue: () => HiddenFieldValue,
|
|
142
141
|
HttpFieldUpdateValue: () => HttpFieldUpdateValue,
|
|
143
142
|
HttpFieldValue: () => HttpFieldValue,
|
|
144
143
|
IdReaderFieldValue: () => IdReaderFieldValue,
|
|
@@ -334,7 +333,6 @@ __export(events_exports, {
|
|
|
334
333
|
isFieldVisible: () => isFieldVisible,
|
|
335
334
|
isFileFieldType: () => isFileFieldType,
|
|
336
335
|
isFileFieldWithOptionType: () => isFileFieldWithOptionType,
|
|
337
|
-
isHiddenFieldType: () => isHiddenFieldType,
|
|
338
336
|
isHttpFieldType: () => isHttpFieldType,
|
|
339
337
|
isIdFieldType: () => isIdFieldType,
|
|
340
338
|
isIdReaderFieldType: () => isIdReaderFieldType,
|
|
@@ -379,7 +377,6 @@ __export(events_exports, {
|
|
|
379
377
|
or: () => or,
|
|
380
378
|
pickRandom: () => pickRandom,
|
|
381
379
|
resolveDateOfEvent: () => resolveDateOfEvent,
|
|
382
|
-
resolvePlaceOfEvent: () => resolvePlaceOfEvent,
|
|
383
380
|
runFieldValidations: () => runFieldValidations,
|
|
384
381
|
runStructuralValidations: () => runStructuralValidations,
|
|
385
382
|
safeUnion: () => safeUnion,
|
|
@@ -428,6 +425,7 @@ var ActionType = {
|
|
|
428
425
|
DECLARE: "DECLARE",
|
|
429
426
|
VALIDATE: "VALIDATE",
|
|
430
427
|
REGISTER: "REGISTER",
|
|
428
|
+
EDIT: "EDIT",
|
|
431
429
|
// Declaration system actions. Non-configurable.
|
|
432
430
|
DUPLICATE_DETECTED: "DUPLICATE_DETECTED",
|
|
433
431
|
REJECT: "REJECT",
|
|
@@ -450,6 +448,7 @@ var ActionType = {
|
|
|
450
448
|
var ConfirmableActions = [
|
|
451
449
|
ActionType.NOTIFY,
|
|
452
450
|
ActionType.DECLARE,
|
|
451
|
+
ActionType.EDIT,
|
|
453
452
|
ActionType.VALIDATE,
|
|
454
453
|
ActionType.REGISTER,
|
|
455
454
|
ActionType.REJECT,
|
|
@@ -465,6 +464,7 @@ var ActionTypes = z2.enum([
|
|
|
465
464
|
"CREATE",
|
|
466
465
|
"NOTIFY",
|
|
467
466
|
"DECLARE",
|
|
467
|
+
"EDIT",
|
|
468
468
|
"VALIDATE",
|
|
469
469
|
"REGISTER",
|
|
470
470
|
"DUPLICATE_DETECTED",
|
|
@@ -486,6 +486,7 @@ var ClientSpecificAction = {
|
|
|
486
486
|
};
|
|
487
487
|
var declarationActionValues = [
|
|
488
488
|
ActionTypes.enum.DECLARE,
|
|
489
|
+
ActionTypes.enum.EDIT,
|
|
489
490
|
ActionTypes.enum.VALIDATE,
|
|
490
491
|
ActionTypes.enum.REGISTER,
|
|
491
492
|
ActionTypes.enum.NOTIFY,
|
|
@@ -618,8 +619,7 @@ var FieldType = {
|
|
|
618
619
|
QUERY_PARAM_READER: "QUERY_PARAM_READER",
|
|
619
620
|
QR_READER: "QR_READER",
|
|
620
621
|
ID_READER: "ID_READER",
|
|
621
|
-
LOADER: "LOADER"
|
|
622
|
-
HIDDEN: "HIDDEN"
|
|
622
|
+
LOADER: "LOADER"
|
|
623
623
|
};
|
|
624
624
|
var FileFieldType = z4.enum([
|
|
625
625
|
FieldType.FILE,
|
|
@@ -753,7 +753,6 @@ var IdReaderFieldValue = ReadDataValue;
|
|
|
753
753
|
|
|
754
754
|
// ../commons/src/events/FieldValue.ts
|
|
755
755
|
var TextValue = z7.string();
|
|
756
|
-
var HiddenFieldValue = z7.string();
|
|
757
756
|
var NonEmptyTextValue = TextValue.min(1);
|
|
758
757
|
var DateValue = z7.iso.date().describe("Date in the format YYYY-MM-DD");
|
|
759
758
|
var AgeValue = z7.object({
|
|
@@ -879,8 +878,7 @@ var FieldUpdateValue = safeUnion([
|
|
|
879
878
|
DataFieldValue.describe("DataFieldValue"),
|
|
880
879
|
NameFieldUpdateValue.describe("NameFieldUpdateValue"),
|
|
881
880
|
HttpFieldUpdateValue.describe("HttpFieldUpdateValue"),
|
|
882
|
-
QueryParamReaderFieldUpdateValue.describe("QueryParamReaderFieldUpdateValue")
|
|
883
|
-
HiddenFieldValue.describe("HiddenFieldValue")
|
|
881
|
+
QueryParamReaderFieldUpdateValue.describe("QueryParamReaderFieldUpdateValue")
|
|
884
882
|
]);
|
|
885
883
|
|
|
886
884
|
// ../commons/src/uuid.ts
|
|
@@ -1141,6 +1139,7 @@ var RecordScopeType = z10.enum([
|
|
|
1141
1139
|
"record.read",
|
|
1142
1140
|
"record.declare",
|
|
1143
1141
|
"record.notify",
|
|
1142
|
+
"record.declared.edit",
|
|
1144
1143
|
"record.declared.validate",
|
|
1145
1144
|
"record.declared.reject",
|
|
1146
1145
|
"record.declared.archive",
|
|
@@ -1498,6 +1497,11 @@ var NotifiedAction = ActionBase.extend(
|
|
|
1498
1497
|
type: z12.literal(ActionType.NOTIFY)
|
|
1499
1498
|
}).shape
|
|
1500
1499
|
);
|
|
1500
|
+
var EditAction = ActionBase.extend(
|
|
1501
|
+
z12.object({
|
|
1502
|
+
type: z12.literal(ActionType.EDIT)
|
|
1503
|
+
}).shape
|
|
1504
|
+
);
|
|
1501
1505
|
var PrintContent = z12.object({
|
|
1502
1506
|
templateId: z12.string().optional()
|
|
1503
1507
|
});
|
|
@@ -1556,6 +1560,7 @@ var ActionDocument = z12.discriminatedUnion("type", [
|
|
|
1556
1560
|
UnassignedAction.meta({ id: "UnassignedAction" }),
|
|
1557
1561
|
PrintCertificateAction.meta({ id: "PrintCertificateAction" }),
|
|
1558
1562
|
ReadAction.meta({ id: "ReadAction" }),
|
|
1563
|
+
EditAction.meta({ id: "EditAction" }),
|
|
1559
1564
|
CustomAction.meta({ id: "CustomAction" })
|
|
1560
1565
|
]).meta({
|
|
1561
1566
|
id: "ActionDocument"
|
|
@@ -1578,7 +1583,8 @@ var InherentFlags = {
|
|
|
1578
1583
|
INCOMPLETE: "incomplete",
|
|
1579
1584
|
REJECTED: "rejected",
|
|
1580
1585
|
CORRECTION_REQUESTED: "correction-requested",
|
|
1581
|
-
POTENTIAL_DUPLICATE: "potential-duplicate"
|
|
1586
|
+
POTENTIAL_DUPLICATE: "potential-duplicate",
|
|
1587
|
+
EDIT_IN_PROGRESS: "edit-in-progress"
|
|
1582
1588
|
};
|
|
1583
1589
|
var ActionFlag = z13.string().regex(
|
|
1584
1590
|
new RegExp(
|
|
@@ -1649,7 +1655,6 @@ var EventMetadata = z14.object({
|
|
|
1649
1655
|
),
|
|
1650
1656
|
createdAt: z14.iso.datetime().describe("The timestamp when the event was first created and saved."),
|
|
1651
1657
|
dateOfEvent: ZodDate.nullish(),
|
|
1652
|
-
placeOfEvent: CreatedAtLocation,
|
|
1653
1658
|
createdBy: z14.string().describe("ID of the user who created the event."),
|
|
1654
1659
|
createdByUserType: z14.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
|
|
1655
1660
|
updatedByUserRole: z14.string().describe("Role of the user who last changed the status."),
|
|
@@ -1679,7 +1684,6 @@ var EventMetadataKeysArray = [
|
|
|
1679
1684
|
"status",
|
|
1680
1685
|
"createdAt",
|
|
1681
1686
|
"dateOfEvent",
|
|
1682
|
-
"placeOfEvent",
|
|
1683
1687
|
"createdBy",
|
|
1684
1688
|
"createdByUserType",
|
|
1685
1689
|
"updatedByUserRole",
|
|
@@ -1714,11 +1718,6 @@ var eventMetadataLabelMap = {
|
|
|
1714
1718
|
defaultMessage: "Date of Event",
|
|
1715
1719
|
description: "Date of Event"
|
|
1716
1720
|
},
|
|
1717
|
-
"event.placeOfEvent": {
|
|
1718
|
-
id: "event.placeOfEvent.label",
|
|
1719
|
-
defaultMessage: "Place of Event",
|
|
1720
|
-
description: "Place of Event"
|
|
1721
|
-
},
|
|
1722
1721
|
"event.createdAtLocation": {
|
|
1723
1722
|
id: "event.createdAtLocation.label",
|
|
1724
1723
|
defaultMessage: "Location",
|
|
@@ -2459,13 +2458,6 @@ var LoaderField = BaseField.extend({
|
|
|
2459
2458
|
}).describe(
|
|
2460
2459
|
"A non-interactive field that indicates an in progress operation in form"
|
|
2461
2460
|
);
|
|
2462
|
-
var HiddenField = BaseField.extend({
|
|
2463
|
-
type: z16.literal(FieldType.HIDDEN),
|
|
2464
|
-
required: z16.literal(false).optional()
|
|
2465
|
-
// Hidden fields cannot be required
|
|
2466
|
-
}).describe(
|
|
2467
|
-
"A non-interactive, hidden field that only hold a value in the form"
|
|
2468
|
-
);
|
|
2469
2461
|
var FieldConfig = z16.discriminatedUnion("type", [
|
|
2470
2462
|
Address,
|
|
2471
2463
|
TextField,
|
|
@@ -2505,8 +2497,7 @@ var FieldConfig = z16.discriminatedUnion("type", [
|
|
|
2505
2497
|
IdReaderField,
|
|
2506
2498
|
QueryParamReaderField,
|
|
2507
2499
|
LoaderField,
|
|
2508
|
-
SearchField
|
|
2509
|
-
HiddenField
|
|
2500
|
+
SearchField
|
|
2510
2501
|
]).meta({
|
|
2511
2502
|
description: "Form field configuration",
|
|
2512
2503
|
id: "FieldConfig"
|
|
@@ -3138,7 +3129,6 @@ function mapFieldTypeToZod(field3, actionType) {
|
|
|
3138
3129
|
case FieldType.VERIFICATION_STATUS:
|
|
3139
3130
|
case FieldType.ID:
|
|
3140
3131
|
case FieldType.LOADER:
|
|
3141
|
-
case FieldType.HIDDEN:
|
|
3142
3132
|
schema = field3.required ? NonEmptyTextValue : TextValue;
|
|
3143
3133
|
break;
|
|
3144
3134
|
case FieldType.NUMBER:
|
|
@@ -3222,7 +3212,6 @@ function mapFieldTypeToEmptyValue(field3) {
|
|
|
3222
3212
|
case FieldType.QR_READER:
|
|
3223
3213
|
case FieldType.ID_READER:
|
|
3224
3214
|
case FieldType.LOADER:
|
|
3225
|
-
case FieldType.HIDDEN:
|
|
3226
3215
|
return null;
|
|
3227
3216
|
case FieldType.ADDRESS:
|
|
3228
3217
|
return {
|
|
@@ -3359,9 +3348,6 @@ var isIdReaderFieldType = (field3) => {
|
|
|
3359
3348
|
var isLoaderFieldType = (field3) => {
|
|
3360
3349
|
return field3.config.type === FieldType.LOADER;
|
|
3361
3350
|
};
|
|
3362
|
-
var isHiddenFieldType = (field3) => {
|
|
3363
|
-
return field3.config.type === FieldType.HIDDEN;
|
|
3364
|
-
};
|
|
3365
3351
|
var isNonInteractiveFieldType = (field3) => {
|
|
3366
3352
|
return field3.type === FieldType.DIVIDER || field3.type === FieldType.PAGE_HEADER || field3.type === FieldType.PARAGRAPH || 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;
|
|
3367
3353
|
};
|
|
@@ -3806,7 +3792,7 @@ function getActionConfig({
|
|
|
3806
3792
|
if (a.type === ActionType.CUSTOM && customActionType) {
|
|
3807
3793
|
return a.customActionType === customActionType;
|
|
3808
3794
|
}
|
|
3809
|
-
if (actionType === ActionType.NOTIFY) {
|
|
3795
|
+
if (actionType === ActionType.NOTIFY || actionType === ActionType.EDIT) {
|
|
3810
3796
|
return a.type === ActionType.DECLARE;
|
|
3811
3797
|
}
|
|
3812
3798
|
if (actionType === ActionType.APPROVE_CORRECTION || actionType === ActionType.REJECT_CORRECTION) {
|
|
@@ -3868,9 +3854,13 @@ var findRecordActionPages = (config, actionType) => {
|
|
|
3868
3854
|
return [];
|
|
3869
3855
|
};
|
|
3870
3856
|
function getActionReview(configuration, actionType) {
|
|
3871
|
-
const
|
|
3872
|
-
|
|
3873
|
-
|
|
3857
|
+
const actionConfig = getActionConfig({
|
|
3858
|
+
eventConfiguration: configuration,
|
|
3859
|
+
actionType
|
|
3860
|
+
});
|
|
3861
|
+
if (!actionConfig) {
|
|
3862
|
+
throw "Tried to get action review for an action that is not a declaration action";
|
|
3863
|
+
}
|
|
3874
3864
|
if ("review" in actionConfig) {
|
|
3875
3865
|
return actionConfig.review;
|
|
3876
3866
|
}
|
|
@@ -4150,9 +4140,6 @@ var EventConfig = z29.object({
|
|
|
4150
4140
|
dateOfEvent: FieldReference.optional().describe(
|
|
4151
4141
|
"Reference to the field capturing the date of the event (e.g. date of birth). Defaults to the event creation date if unspecified."
|
|
4152
4142
|
),
|
|
4153
|
-
placeOfEvent: FieldReference.optional().describe(
|
|
4154
|
-
"Reference to the field capturing the place of the event (e.g. place of birth). Defaults to the meta.createdAtLocation if unspecified."
|
|
4155
|
-
),
|
|
4156
4143
|
title: TranslationConfig.describe(
|
|
4157
4144
|
'Title template for the singular event, supporting variables (e.g. "{applicant.name.firstname} {applicant.name.surname}").'
|
|
4158
4145
|
),
|
|
@@ -4227,19 +4214,6 @@ var EventConfig = z29.object({
|
|
|
4227
4214
|
});
|
|
4228
4215
|
}
|
|
4229
4216
|
}
|
|
4230
|
-
if (event2.placeOfEvent) {
|
|
4231
|
-
const eventPlaceFieldId = getDeclarationFields(event2).find(
|
|
4232
|
-
({ id }) => id === event2.placeOfEvent?.$$field
|
|
4233
|
-
);
|
|
4234
|
-
if (!eventPlaceFieldId) {
|
|
4235
|
-
ctx.addIssue({
|
|
4236
|
-
code: "custom",
|
|
4237
|
-
message: `Place of event field id must match a field id in the event.declaration fields.
|
|
4238
|
-
Invalid place of event field ID for event ${event2.id}: ${event2.placeOfEvent.$$field}`,
|
|
4239
|
-
path: ["placeOfEvent"]
|
|
4240
|
-
});
|
|
4241
|
-
}
|
|
4242
|
-
}
|
|
4243
4217
|
const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
|
|
4244
4218
|
const configuredFlagIds = event2.flags.map((flag2) => flag2.id);
|
|
4245
4219
|
const actionFlagIds = event2.actions.flatMap(
|
|
@@ -5203,6 +5177,11 @@ var DeclareActionInput = BaseActionInput.extend(
|
|
|
5203
5177
|
type: z33.literal(ActionType.DECLARE).default(ActionType.DECLARE)
|
|
5204
5178
|
}).shape
|
|
5205
5179
|
);
|
|
5180
|
+
var EditActionInput = BaseActionInput.extend(
|
|
5181
|
+
z33.object({
|
|
5182
|
+
type: z33.literal(ActionType.EDIT).default(ActionType.EDIT)
|
|
5183
|
+
}).shape
|
|
5184
|
+
);
|
|
5206
5185
|
var PrintCertificateActionInput = BaseActionInput.extend(
|
|
5207
5186
|
z33.object({
|
|
5208
5187
|
type: z33.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
|
|
@@ -5314,7 +5293,8 @@ var ActionInput = z33.discriminatedUnion("type", [
|
|
|
5314
5293
|
id: "ApproveCorrectionActionInput"
|
|
5315
5294
|
}),
|
|
5316
5295
|
ReadActionInput.meta({ id: "ReadActionInput" }),
|
|
5317
|
-
CustomActionInput.meta({ id: "CustomActionInput" })
|
|
5296
|
+
CustomActionInput.meta({ id: "CustomActionInput" }),
|
|
5297
|
+
EditActionInput.meta({ id: "EditActionInput" })
|
|
5318
5298
|
]).meta({
|
|
5319
5299
|
id: "ActionInput"
|
|
5320
5300
|
});
|
|
@@ -5457,6 +5437,9 @@ function getLegalStatuses(actions) {
|
|
|
5457
5437
|
// ../commons/src/events/state/flags.ts
|
|
5458
5438
|
var import_lodash3 = require("lodash");
|
|
5459
5439
|
var import_date_fns3 = require("date-fns");
|
|
5440
|
+
function isEditInProgress(actions) {
|
|
5441
|
+
return actions.at(-1)?.type === ActionType.EDIT;
|
|
5442
|
+
}
|
|
5460
5443
|
function isPendingCertification(actions) {
|
|
5461
5444
|
if (getStatusFromActions(actions) !== EventStatus.enum.REGISTERED) {
|
|
5462
5445
|
return false;
|
|
@@ -5519,8 +5502,14 @@ function isFlagConditionMet(conditional, form, action) {
|
|
|
5519
5502
|
});
|
|
5520
5503
|
}
|
|
5521
5504
|
function resolveEventCustomFlags(event2, eventConfiguration) {
|
|
5522
|
-
const
|
|
5523
|
-
const
|
|
5505
|
+
const sortedActions = getAcceptedActions(event2).filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
5506
|
+
const declareIndexes = sortedActions.map((a, i) => a.type === ActionType.DECLARE ? i : -1).filter((i) => i !== -1);
|
|
5507
|
+
let actions = sortedActions;
|
|
5508
|
+
if (declareIndexes.length >= 2) {
|
|
5509
|
+
const secondLast = declareIndexes[declareIndexes.length - 2];
|
|
5510
|
+
const last = declareIndexes[declareIndexes.length - 1];
|
|
5511
|
+
actions = sortedActions.filter((_, idx) => idx < secondLast || idx >= last);
|
|
5512
|
+
}
|
|
5524
5513
|
return actions.reduce((acc, action, idx) => {
|
|
5525
5514
|
let actionConfig;
|
|
5526
5515
|
if (isActionConfigType(action.type)) {
|
|
@@ -5582,6 +5571,9 @@ function getEventFlags(event2, config) {
|
|
|
5582
5571
|
if (isPotentialDuplicate(sortedActions)) {
|
|
5583
5572
|
flags.push(InherentFlags.POTENTIAL_DUPLICATE);
|
|
5584
5573
|
}
|
|
5574
|
+
if (isEditInProgress(sortedActions)) {
|
|
5575
|
+
flags.push(InherentFlags.EDIT_IN_PROGRESS);
|
|
5576
|
+
}
|
|
5585
5577
|
return [...flags, ...resolveEventCustomFlags(event2, config)];
|
|
5586
5578
|
}
|
|
5587
5579
|
|
|
@@ -5611,8 +5603,8 @@ function getStatusFromActions(actions) {
|
|
|
5611
5603
|
case ActionType.MARK_AS_DUPLICATE:
|
|
5612
5604
|
case ActionType.REJECT_CORRECTION:
|
|
5613
5605
|
case ActionType.READ:
|
|
5614
|
-
case ActionType.CUSTOM:
|
|
5615
5606
|
case ActionType.VALIDATE:
|
|
5607
|
+
case ActionType.EDIT:
|
|
5616
5608
|
default:
|
|
5617
5609
|
return status2;
|
|
5618
5610
|
}
|
|
@@ -5667,33 +5659,6 @@ function resolveDateOfEvent(eventMetadata, declaration, config) {
|
|
|
5667
5659
|
const parsedDate = ZodDate.safeParse(declaration[config.dateOfEvent.$$field]);
|
|
5668
5660
|
return parsedDate.success ? parsedDate.data : void 0;
|
|
5669
5661
|
}
|
|
5670
|
-
var DEFAULT_PLACE_OF_EVENT_PROPERTY = "createdAtLocation";
|
|
5671
|
-
function getParsedUUID(value, oldValue) {
|
|
5672
|
-
const parsed = UUID.safeParse(value);
|
|
5673
|
-
return parsed.success ? parsed.data : oldValue;
|
|
5674
|
-
}
|
|
5675
|
-
function resolvePlaceOfEvent(eventMetadata, declaration, config) {
|
|
5676
|
-
let placeOfEvent = getParsedUUID(
|
|
5677
|
-
eventMetadata[DEFAULT_PLACE_OF_EVENT_PROPERTY]
|
|
5678
|
-
);
|
|
5679
|
-
if (config.placeOfEvent) {
|
|
5680
|
-
const addressFieldValue = AddressFieldValue.safeParse(
|
|
5681
|
-
declaration[config.placeOfEvent.$$field]
|
|
5682
|
-
);
|
|
5683
|
-
if (addressFieldValue.success && addressFieldValue.data.addressType === AddressType.DOMESTIC && addressFieldValue.data.administrativeArea) {
|
|
5684
|
-
placeOfEvent = getParsedUUID(
|
|
5685
|
-
addressFieldValue.data.administrativeArea,
|
|
5686
|
-
placeOfEvent
|
|
5687
|
-
);
|
|
5688
|
-
} else {
|
|
5689
|
-
placeOfEvent = getParsedUUID(
|
|
5690
|
-
declaration[config.placeOfEvent.$$field],
|
|
5691
|
-
placeOfEvent
|
|
5692
|
-
);
|
|
5693
|
-
}
|
|
5694
|
-
}
|
|
5695
|
-
return placeOfEvent;
|
|
5696
|
-
}
|
|
5697
5662
|
function extractPotentialDuplicatesFromActions(actions) {
|
|
5698
5663
|
return actions.reduce((duplicates, action) => {
|
|
5699
5664
|
if (action.type === ActionType.DUPLICATE_DETECTED) {
|
|
@@ -5738,11 +5703,6 @@ function getCurrentEventState(event2, config) {
|
|
|
5738
5703
|
trackingId: event2.trackingId,
|
|
5739
5704
|
updatedByUserRole: requestActionMetadata.createdByRole,
|
|
5740
5705
|
dateOfEvent: resolveDateOfEvent(event2, declaration, config),
|
|
5741
|
-
placeOfEvent: resolvePlaceOfEvent(
|
|
5742
|
-
{ createdAtLocation: creationAction.createdAtLocation },
|
|
5743
|
-
declaration,
|
|
5744
|
-
config
|
|
5745
|
-
),
|
|
5746
5706
|
potentialDuplicates: extractPotentialDuplicatesFromActions(sortedActions),
|
|
5747
5707
|
flags: getEventFlags(event2, config)
|
|
5748
5708
|
});
|
|
@@ -5787,11 +5747,6 @@ function applyDeclarationToEventIndex(eventIndex, declaration, eventConfiguratio
|
|
|
5787
5747
|
updatedDeclaration,
|
|
5788
5748
|
eventConfiguration
|
|
5789
5749
|
),
|
|
5790
|
-
placeOfEvent: resolvePlaceOfEvent(
|
|
5791
|
-
eventIndex,
|
|
5792
|
-
updatedDeclaration,
|
|
5793
|
-
eventConfiguration
|
|
5794
|
-
),
|
|
5795
5750
|
declaration: updatedDeclaration
|
|
5796
5751
|
};
|
|
5797
5752
|
}
|
|
@@ -8099,7 +8054,6 @@ function mapFieldTypeToMockValue(field3, i, rng) {
|
|
|
8099
8054
|
case FieldType.OFFICE:
|
|
8100
8055
|
case FieldType.LINK_BUTTON:
|
|
8101
8056
|
case FieldType.LOADER:
|
|
8102
|
-
case FieldType.HIDDEN:
|
|
8103
8057
|
return `${field3.id}-${field3.type}-${i}`;
|
|
8104
8058
|
case FieldType.VERIFICATION_STATUS:
|
|
8105
8059
|
return "verified";
|
|
@@ -8326,6 +8280,14 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
|
|
|
8326
8280
|
keepAssignment: input.keepAssignment
|
|
8327
8281
|
};
|
|
8328
8282
|
},
|
|
8283
|
+
edit: (eventId, input = {}) => ({
|
|
8284
|
+
type: ActionType.EDIT,
|
|
8285
|
+
transactionId: input.transactionId ?? getUUID(),
|
|
8286
|
+
declaration: input.declaration ?? generateActionDeclarationInput(configuration, ActionType.EDIT, rng),
|
|
8287
|
+
annotation: input.annotation ?? generateActionAnnotationInput(configuration, ActionType.EDIT, rng),
|
|
8288
|
+
eventId,
|
|
8289
|
+
...input
|
|
8290
|
+
}),
|
|
8329
8291
|
validate: (eventId, input = {}) => ({
|
|
8330
8292
|
type: ActionType.VALIDATE,
|
|
8331
8293
|
transactionId: input.transactionId ?? getUUID(),
|
|
@@ -8517,22 +8479,25 @@ function generateActionDocument({
|
|
|
8517
8479
|
...defaults
|
|
8518
8480
|
};
|
|
8519
8481
|
switch (action) {
|
|
8482
|
+
case ActionType.READ:
|
|
8483
|
+
case ActionType.MARK_AS_NOT_DUPLICATE:
|
|
8484
|
+
case ActionType.DECLARE:
|
|
8485
|
+
case ActionType.UNASSIGN:
|
|
8486
|
+
case ActionType.CREATE:
|
|
8487
|
+
case ActionType.NOTIFY:
|
|
8488
|
+
case ActionType.VALIDATE:
|
|
8489
|
+
case ActionType.REGISTER:
|
|
8490
|
+
case ActionType.REQUEST_CORRECTION:
|
|
8491
|
+
case ActionType.EDIT:
|
|
8492
|
+
return { ...actionBase, type: action };
|
|
8520
8493
|
case ActionType.CUSTOM:
|
|
8521
8494
|
return {
|
|
8522
8495
|
...actionBase,
|
|
8523
8496
|
type: action,
|
|
8524
8497
|
customActionType: "CUSTOM_ACTION_TYPE"
|
|
8525
8498
|
};
|
|
8526
|
-
case ActionType.READ:
|
|
8527
|
-
return { ...actionBase, type: action };
|
|
8528
|
-
case ActionType.MARK_AS_NOT_DUPLICATE:
|
|
8529
|
-
return { ...actionBase, type: action };
|
|
8530
8499
|
case ActionType.MARK_AS_DUPLICATE:
|
|
8531
8500
|
return { ...actionBase, type: action, content: void 0 };
|
|
8532
|
-
case ActionType.DECLARE:
|
|
8533
|
-
return { ...actionBase, type: action };
|
|
8534
|
-
case ActionType.UNASSIGN:
|
|
8535
|
-
return { ...actionBase, type: action };
|
|
8536
8501
|
case ActionType.ASSIGN: {
|
|
8537
8502
|
const assignActionDefaults = defaults;
|
|
8538
8503
|
return {
|
|
@@ -8541,16 +8506,10 @@ function generateActionDocument({
|
|
|
8541
8506
|
type: action
|
|
8542
8507
|
};
|
|
8543
8508
|
}
|
|
8544
|
-
case ActionType.VALIDATE:
|
|
8545
|
-
return { ...actionBase, type: action };
|
|
8546
8509
|
case ActionType.ARCHIVE:
|
|
8547
8510
|
return { ...actionBase, type: action, content: { reason: "Archive" } };
|
|
8548
8511
|
case ActionType.REJECT:
|
|
8549
8512
|
return { ...actionBase, type: action, content: { reason: "Reject" } };
|
|
8550
|
-
case ActionType.CREATE:
|
|
8551
|
-
return { ...actionBase, type: action };
|
|
8552
|
-
case ActionType.NOTIFY:
|
|
8553
|
-
return { ...actionBase, type: action };
|
|
8554
8513
|
case ActionType.PRINT_CERTIFICATE: {
|
|
8555
8514
|
const printActionDefaults = defaults;
|
|
8556
8515
|
return {
|
|
@@ -8559,8 +8518,6 @@ function generateActionDocument({
|
|
|
8559
8518
|
content: printActionDefaults?.content
|
|
8560
8519
|
};
|
|
8561
8520
|
}
|
|
8562
|
-
case ActionType.REQUEST_CORRECTION:
|
|
8563
|
-
return { ...actionBase, type: action };
|
|
8564
8521
|
case ActionType.APPROVE_CORRECTION:
|
|
8565
8522
|
return { ...actionBase, requestId: getUUID(), type: action };
|
|
8566
8523
|
case ActionType.REJECT_CORRECTION:
|
|
@@ -8570,11 +8527,6 @@ function generateActionDocument({
|
|
|
8570
8527
|
type: action,
|
|
8571
8528
|
content: { reason: "Correction rejection" }
|
|
8572
8529
|
};
|
|
8573
|
-
case ActionType.REGISTER:
|
|
8574
|
-
return {
|
|
8575
|
-
...actionBase,
|
|
8576
|
-
type: action
|
|
8577
|
-
};
|
|
8578
8530
|
case ActionType.DUPLICATE_DETECTED: {
|
|
8579
8531
|
const duplicateActionDefaults = defaults;
|
|
8580
8532
|
return {
|
|
@@ -8800,6 +8752,7 @@ var ACTION_SCOPE_MAP = {
|
|
|
8800
8752
|
"record.declared.validate",
|
|
8801
8753
|
"record.register"
|
|
8802
8754
|
],
|
|
8755
|
+
[ActionType.EDIT]: ["record.declared.edit"],
|
|
8803
8756
|
[ActionType.DELETE]: ["record.declare"],
|
|
8804
8757
|
[ActionType.VALIDATE]: ["record.declared.validate", "record.register"],
|
|
8805
8758
|
[ActionType.REGISTER]: ["record.register"],
|
|
@@ -8940,7 +8893,8 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
|
|
|
8940
8893
|
ActionType.MARK_AS_DUPLICATE,
|
|
8941
8894
|
ActionType.ARCHIVE,
|
|
8942
8895
|
ActionType.REJECT,
|
|
8943
|
-
ActionType.CUSTOM
|
|
8896
|
+
ActionType.CUSTOM,
|
|
8897
|
+
ActionType.EDIT
|
|
8944
8898
|
],
|
|
8945
8899
|
[EventStatus.enum.REGISTERED]: [
|
|
8946
8900
|
ActionType.READ,
|
|
@@ -8966,6 +8920,7 @@ var ACTION_FILTERS = {
|
|
|
8966
8920
|
[ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
8967
8921
|
[ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
8968
8922
|
[ActionType.VALIDATE]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
8923
|
+
[ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
8969
8924
|
[ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
8970
8925
|
[ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
|
|
8971
8926
|
[ActionType.ARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested"))
|
|
@@ -8994,6 +8949,9 @@ function getAvailableActionsWithoutFlagFilters(status2, flags) {
|
|
|
8994
8949
|
flags.filter((flag2) => flag2 !== InherentFlags.REJECTED)
|
|
8995
8950
|
).filter((action) => action !== ActionType.DELETE).concat(ActionType.ARCHIVE);
|
|
8996
8951
|
}
|
|
8952
|
+
if (flags.includes(InherentFlags.EDIT_IN_PROGRESS)) {
|
|
8953
|
+
return [ActionType.DECLARE, ActionType.REGISTER];
|
|
8954
|
+
}
|
|
8997
8955
|
return AVAILABLE_ACTIONS_BY_EVENT_STATUS[status2];
|
|
8998
8956
|
}
|
|
8999
8957
|
case EventStatus.enum.REGISTERED: {
|