@opencrvs/toolkit 1.8.0-rc.fb0e687 → 1.8.0-rc.fb2e700
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 +13 -0
- package/dist/commons/conditionals/validate.d.ts +2 -6
- package/dist/commons/events/ActionDocument.d.ts +6 -0
- package/dist/commons/events/ActionInput.d.ts +90 -0
- package/dist/commons/events/ActionType.d.ts +2 -0
- package/dist/commons/events/Draft.d.ts +3 -0
- package/dist/commons/events/EventDocument.d.ts +5 -0
- package/dist/commons/events/TemplateConfig.d.ts +4 -4
- package/dist/commons/events/test.utils.d.ts +2 -2
- package/dist/commons/events/utils.d.ts +49 -41
- package/dist/commons/events/utils.test.d.ts +2 -0
- package/dist/events/index.js +128 -58
- package/dist/scopes/index.d.ts +70 -1
- package/dist/scopes/index.js +130 -0
- package/package.json +1 -1
@@ -34,4 +34,6 @@ export type DeclarationUpdateActionType = z.infer<typeof DeclarationUpdateAction
|
|
34
34
|
/** Actions which update annotation or status of an event. */
|
35
35
|
export declare const annotationActions: z.ZodEnum<["DELETE", "CREATE", "NOTIFY", "DETECT_DUPLICATE", "REJECT", "MARKED_AS_DUPLICATE", "ARCHIVE", "PRINT_CERTIFICATE", "REQUEST_CORRECTION", "REJECT_CORRECTION", "APPROVE_CORRECTION", "READ", "ASSIGN", "UNASSIGN"]>;
|
36
36
|
export type AnnotationActionType = z.infer<typeof annotationActions>;
|
37
|
+
/** Actions which requires the user to be assigned */
|
38
|
+
export declare const writeActions: z.ZodEnum<["DELETE", "NOTIFY", "DECLARE", "VALIDATE", "REGISTER", "DETECT_DUPLICATE", "REJECT", "MARKED_AS_DUPLICATE", "ARCHIVE", "PRINT_CERTIFICATE", "REQUEST_CORRECTION", "REJECT_CORRECTION", "APPROVE_CORRECTION"]>;
|
37
39
|
//# sourceMappingURL=ActionType.d.ts.map
|
@@ -819,6 +819,7 @@ export declare const DraftInput: z.ZodObject<z.objectUtil.extendShape<{
|
|
819
819
|
postcodeOrZip?: string | null | undefined;
|
820
820
|
}>]>>>;
|
821
821
|
originalActionId: z.ZodOptional<z.ZodString>;
|
822
|
+
keepAssignment: z.ZodOptional<z.ZodBoolean>;
|
822
823
|
}, {
|
823
824
|
type: z.ZodEnum<["DELETE", "CREATE", "NOTIFY", "DECLARE", "VALIDATE", "REGISTER", "DETECT_DUPLICATE", "REJECT", "MARKED_AS_DUPLICATE", "ARCHIVE", "PRINT_CERTIFICATE", "REQUEST_CORRECTION", "REJECT_CORRECTION", "APPROVE_CORRECTION", "READ", "ASSIGN", "UNASSIGN"]>;
|
824
825
|
}>, "strip", z.ZodTypeAny, {
|
@@ -902,6 +903,7 @@ export declare const DraftInput: z.ZodObject<z.objectUtil.extendShape<{
|
|
902
903
|
originalFilename: string;
|
903
904
|
}[] | undefined> | undefined;
|
904
905
|
originalActionId?: string | undefined;
|
906
|
+
keepAssignment?: boolean | undefined;
|
905
907
|
}, {
|
906
908
|
type: "DECLARE" | "REGISTER" | "VALIDATE" | "DELETE" | "CREATE" | "NOTIFY" | "DETECT_DUPLICATE" | "REJECT" | "MARKED_AS_DUPLICATE" | "ARCHIVE" | "PRINT_CERTIFICATE" | "REQUEST_CORRECTION" | "REJECT_CORRECTION" | "APPROVE_CORRECTION" | "READ" | "ASSIGN" | "UNASSIGN";
|
907
909
|
eventId: string;
|
@@ -983,6 +985,7 @@ export declare const DraftInput: z.ZodObject<z.objectUtil.extendShape<{
|
|
983
985
|
originalFilename: string;
|
984
986
|
}[] | undefined> | undefined;
|
985
987
|
originalActionId?: string | undefined;
|
988
|
+
keepAssignment?: boolean | undefined;
|
986
989
|
}>;
|
987
990
|
export type Draft = z.infer<typeof Draft>;
|
988
991
|
export type DraftInput = z.infer<typeof DraftInput>;
|
@@ -5113,6 +5113,7 @@ export declare const EventDocument: z.ZodObject<{
|
|
5113
5113
|
originalActionId: z.ZodOptional<z.ZodString>;
|
5114
5114
|
}, {
|
5115
5115
|
type: z.ZodLiteral<"UNASSIGN">;
|
5116
|
+
assignedTo: z.ZodDefault<z.ZodLiteral<null>>;
|
5116
5117
|
}>, "strip", z.ZodTypeAny, {
|
5117
5118
|
type: "UNASSIGN";
|
5118
5119
|
id: string;
|
@@ -5158,6 +5159,7 @@ export declare const EventDocument: z.ZodObject<{
|
|
5158
5159
|
originalFilename: string;
|
5159
5160
|
}[] | undefined>;
|
5160
5161
|
createdAtLocation: string;
|
5162
|
+
assignedTo: null;
|
5161
5163
|
annotation?: Record<string, string | number | boolean | {
|
5162
5164
|
type: string;
|
5163
5165
|
filename: string;
|
@@ -5281,6 +5283,7 @@ export declare const EventDocument: z.ZodObject<{
|
|
5281
5283
|
originalFilename: string;
|
5282
5284
|
}[] | undefined> | undefined;
|
5283
5285
|
originalActionId?: string | undefined;
|
5286
|
+
assignedTo?: null | undefined;
|
5284
5287
|
}>, z.ZodObject<z.objectUtil.extendShape<{
|
5285
5288
|
id: z.ZodString;
|
5286
5289
|
createdAt: z.ZodString;
|
@@ -6478,6 +6481,7 @@ export declare const EventDocument: z.ZodObject<{
|
|
6478
6481
|
originalFilename: string;
|
6479
6482
|
}[] | undefined>;
|
6480
6483
|
createdAtLocation: string;
|
6484
|
+
assignedTo: null;
|
6481
6485
|
annotation?: Record<string, string | number | boolean | {
|
6482
6486
|
type: string;
|
6483
6487
|
filename: string;
|
@@ -7794,6 +7798,7 @@ export declare const EventDocument: z.ZodObject<{
|
|
7794
7798
|
originalFilename: string;
|
7795
7799
|
}[] | undefined> | undefined;
|
7796
7800
|
originalActionId?: string | undefined;
|
7801
|
+
assignedTo?: null | undefined;
|
7797
7802
|
} | {
|
7798
7803
|
type: "REGISTER";
|
7799
7804
|
id: string;
|
@@ -6,7 +6,7 @@ import { FieldValue } from './FieldValue';
|
|
6
6
|
/**
|
7
7
|
* Available system variables for configuration.
|
8
8
|
*/
|
9
|
-
export type
|
9
|
+
export type SystemVariables = {
|
10
10
|
$user: {
|
11
11
|
province: string;
|
12
12
|
district: string;
|
@@ -21,12 +21,12 @@ export type MetaFields = {
|
|
21
21
|
type FlattenedKeyStrings<T, Prefix extends string = ''> = {
|
22
22
|
[K in keyof T]: T[K] extends Record<string, any> ? FlattenedKeyStrings<T[K], `${Prefix}${K & string}.`> : `${Prefix}${K & string}`;
|
23
23
|
}[keyof T];
|
24
|
-
export type
|
24
|
+
export type FlattenenedSystemVariables = FlattenedKeyStrings<SystemVariables>;
|
25
25
|
/**
|
26
26
|
* Default value for a field when configuring a form.
|
27
27
|
*/
|
28
|
-
export type FieldConfigDefaultValue = FieldValue |
|
29
|
-
export declare function isTemplateVariable(value: FieldConfigDefaultValue): value is
|
28
|
+
export type FieldConfigDefaultValue = FieldValue | FlattenenedSystemVariables | Record<string, FlattenenedSystemVariables | FieldValue>;
|
29
|
+
export declare function isTemplateVariable(value: FieldConfigDefaultValue): value is FlattenenedSystemVariables;
|
30
30
|
export declare function isFieldValue(value: FieldConfigDefaultValue): value is FieldValue;
|
31
31
|
/**
|
32
32
|
* Checks if given value is valid for a field, and known template variables are already resolved.
|
@@ -8,7 +8,7 @@ import { EventIndex } from './EventIndex';
|
|
8
8
|
import { EventInput } from './EventInput';
|
9
9
|
import { FieldValue } from './FieldValue';
|
10
10
|
import { TranslationConfig } from './TranslationConfig';
|
11
|
-
export declare function
|
11
|
+
export declare function generateActionDeclarationInput(configuration: EventConfig, action: ActionType): import("lodash").Dictionary<string | number | boolean | {
|
12
12
|
type: string;
|
13
13
|
filename: string;
|
14
14
|
originalFilename: string;
|
@@ -46,7 +46,7 @@ export declare function generateActionInput(configuration: EventConfig, action:
|
|
46
46
|
filename: string;
|
47
47
|
originalFilename: string;
|
48
48
|
}[] | undefined>;
|
49
|
-
export declare function
|
49
|
+
export declare function generateActionAnnotationInput(configuration: EventConfig, action: ActionType): {};
|
50
50
|
export declare const eventPayloadGenerator: {
|
51
51
|
create: (input?: Partial<EventInput>) => {
|
52
52
|
transactionId: string;
|
@@ -2,7 +2,7 @@ import { ActionType, DeclarationActionType } from './ActionType';
|
|
2
2
|
import { EventConfig } from './EventConfig';
|
3
3
|
import { FieldConfig } from './FieldConfig';
|
4
4
|
import { WorkqueueConfig } from './WorkqueueConfig';
|
5
|
-
import { ActionUpdate, EventState } from './ActionDocument';
|
5
|
+
import { Action, ActionUpdate, EventState } from './ActionDocument';
|
6
6
|
import { PageConfig, VerificationPageConfig } from './PageConfig';
|
7
7
|
import { Draft } from './Draft';
|
8
8
|
import { EventDocument } from './EventDocument';
|
@@ -43,8 +43,45 @@ export declare function getActionReview(configuration: EventConfig, actionType:
|
|
43
43
|
export declare function getActionReviewFields(configuration: EventConfig, actionType: DeclarationActionType): import("./FieldConfig").Inferred[];
|
44
44
|
export declare function validateWorkqueueConfig(workqueueConfigs: WorkqueueConfig[]): void;
|
45
45
|
export declare function isPageVisible(page: PageConfig, formValues: ActionUpdate): boolean;
|
46
|
-
export declare
|
47
|
-
|
46
|
+
export declare function omitHiddenFields(fields: FieldConfig[], values: EventState): import("lodash").Dictionary<string | number | boolean | {
|
47
|
+
type: string;
|
48
|
+
filename: string;
|
49
|
+
originalFilename: string;
|
50
|
+
} | {
|
51
|
+
country: string;
|
52
|
+
district: string;
|
53
|
+
addressType: "DOMESTIC";
|
54
|
+
province: string;
|
55
|
+
urbanOrRural: "URBAN";
|
56
|
+
number?: string | undefined;
|
57
|
+
town?: string | undefined;
|
58
|
+
residentialArea?: string | undefined;
|
59
|
+
street?: string | undefined;
|
60
|
+
zipCode?: string | undefined;
|
61
|
+
} | {
|
62
|
+
country: string;
|
63
|
+
district: string;
|
64
|
+
addressType: "DOMESTIC";
|
65
|
+
province: string;
|
66
|
+
urbanOrRural: "RURAL";
|
67
|
+
village?: string | undefined;
|
68
|
+
} | {
|
69
|
+
country: string;
|
70
|
+
state: string;
|
71
|
+
addressType: "INTERNATIONAL";
|
72
|
+
district2: string;
|
73
|
+
cityOrTown?: string | undefined;
|
74
|
+
addressLine1?: string | undefined;
|
75
|
+
addressLine2?: string | undefined;
|
76
|
+
addressLine3?: string | undefined;
|
77
|
+
postcodeOrZip?: string | undefined;
|
78
|
+
} | {
|
79
|
+
type: string;
|
80
|
+
option: string;
|
81
|
+
filename: string;
|
82
|
+
originalFilename: string;
|
83
|
+
}[] | undefined>;
|
84
|
+
export declare function omitHiddenPaginatedFields(formConfig: FormConfig, declaration: EventState): import("lodash").Dictionary<string | number | boolean | {
|
48
85
|
type: string;
|
49
86
|
filename: string;
|
50
87
|
originalFilename: string;
|
@@ -187,42 +224,13 @@ export declare function createEmptyDraft(eventId: string, draftId: string, actio
|
|
187
224
|
};
|
188
225
|
};
|
189
226
|
export declare function isVerificationPage(page: PageConfig): page is VerificationPageConfig;
|
190
|
-
export declare function deepMerge(currentDocument:
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
urbanOrRural: "URBAN";
|
200
|
-
number?: string | null | undefined;
|
201
|
-
town?: string | null | undefined;
|
202
|
-
residentialArea?: string | null | undefined;
|
203
|
-
street?: string | null | undefined;
|
204
|
-
zipCode?: string | null | undefined;
|
205
|
-
} | {
|
206
|
-
country: string;
|
207
|
-
district: string;
|
208
|
-
addressType: "DOMESTIC";
|
209
|
-
province: string;
|
210
|
-
urbanOrRural: "RURAL";
|
211
|
-
village?: string | null | undefined;
|
212
|
-
} | {
|
213
|
-
country: string;
|
214
|
-
state: string;
|
215
|
-
addressType: "INTERNATIONAL";
|
216
|
-
district2: string;
|
217
|
-
cityOrTown?: string | null | undefined;
|
218
|
-
addressLine1?: string | null | undefined;
|
219
|
-
addressLine2?: string | null | undefined;
|
220
|
-
addressLine3?: string | null | undefined;
|
221
|
-
postcodeOrZip?: string | null | undefined;
|
222
|
-
} | {
|
223
|
-
type: string;
|
224
|
-
option: string;
|
225
|
-
filename: string;
|
226
|
-
originalFilename: string;
|
227
|
-
}[] | undefined>;
|
227
|
+
export declare function deepMerge<T extends Record<string, unknown>>(currentDocument: T, actionDocument: T): T;
|
228
|
+
export declare function findLastAssignmentAction(actions: Action[]): Action | undefined;
|
229
|
+
/** Tell compiler that accessing record with arbitrary key might result to undefined
|
230
|
+
* Use when you **cannot guarantee** that key exists in the record
|
231
|
+
*/
|
232
|
+
export type IndexMap<T> = {
|
233
|
+
[id: string]: T | undefined;
|
234
|
+
};
|
235
|
+
export declare function isWriteAction(actionType: ActionType): boolean;
|
228
236
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/events/index.js
CHANGED
@@ -152,10 +152,11 @@ __export(events_exports, {
|
|
152
152
|
fieldTypes: () => fieldTypes,
|
153
153
|
findActiveDrafts: () => findActiveDrafts,
|
154
154
|
findAllFields: () => findAllFields,
|
155
|
+
findLastAssignmentAction: () => findLastAssignmentAction,
|
155
156
|
findRecordActionPages: () => findRecordActionPages,
|
157
|
+
generateActionAnnotationInput: () => generateActionAnnotationInput,
|
158
|
+
generateActionDeclarationInput: () => generateActionDeclarationInput,
|
156
159
|
generateActionDocument: () => generateActionDocument,
|
157
|
-
generateActionInput: () => generateActionInput,
|
158
|
-
generateActionMetadataInput: () => generateActionMetadataInput,
|
159
160
|
generateEventDocument: () => generateEventDocument,
|
160
161
|
generateEventDraftDocument: () => generateEventDraftDocument,
|
161
162
|
generateTransactionId: () => generateTransactionId,
|
@@ -173,7 +174,6 @@ __export(events_exports, {
|
|
173
174
|
getDeclarationFields: () => getDeclarationFields,
|
174
175
|
getDeclarationPages: () => getDeclarationPages,
|
175
176
|
getFieldValidationErrors: () => getFieldValidationErrors,
|
176
|
-
getVisiblePagesFormFields: () => getVisiblePagesFormFields,
|
177
177
|
isAddressFieldType: () => isAddressFieldType,
|
178
178
|
isAdministrativeAreaFieldType: () => isAdministrativeAreaFieldType,
|
179
179
|
isBulletListFieldType: () => isBulletListFieldType,
|
@@ -206,17 +206,20 @@ __export(events_exports, {
|
|
206
206
|
isTextFieldType: () => isTextFieldType,
|
207
207
|
isUndeclaredDraft: () => isUndeclaredDraft,
|
208
208
|
isVerificationPage: () => isVerificationPage,
|
209
|
+
isWriteAction: () => isWriteAction,
|
209
210
|
mapFieldTypeToEmptyValue: () => mapFieldTypeToEmptyValue,
|
210
211
|
mapFieldTypeToMockValue: () => mapFieldTypeToMockValue,
|
211
212
|
mapFieldTypeToZod: () => mapFieldTypeToZod,
|
212
213
|
never: () => never,
|
213
214
|
not: () => not,
|
215
|
+
omitHiddenFields: () => omitHiddenFields,
|
216
|
+
omitHiddenPaginatedFields: () => omitHiddenPaginatedFields,
|
214
217
|
or: () => or,
|
215
|
-
stripHiddenFields: () => stripHiddenFields,
|
216
218
|
user: () => user,
|
217
219
|
validate: () => validate,
|
218
220
|
validateFieldInput: () => validateFieldInput,
|
219
|
-
validateWorkqueueConfig: () => validateWorkqueueConfig
|
221
|
+
validateWorkqueueConfig: () => validateWorkqueueConfig,
|
222
|
+
writeActions: () => writeActions
|
220
223
|
});
|
221
224
|
module.exports = __toCommonJS(events_exports);
|
222
225
|
|
@@ -797,6 +800,12 @@ var DeclarationUpdateActions = ActionTypes.extract(
|
|
797
800
|
declarationUpdateActionValues
|
798
801
|
);
|
799
802
|
var annotationActions = ActionTypes.exclude(declarationActionValues);
|
803
|
+
var writeActions = ActionTypes.exclude([
|
804
|
+
ActionType.CREATE,
|
805
|
+
ActionType.READ,
|
806
|
+
ActionType.ASSIGN,
|
807
|
+
ActionType.UNASSIGN
|
808
|
+
]);
|
800
809
|
|
801
810
|
// ../commons/src/events/FormConfig.ts
|
802
811
|
var import_zod8 = require("zod");
|
@@ -1632,7 +1641,7 @@ function validateFieldInput({
|
|
1632
1641
|
);
|
1633
1642
|
return rawError.error?.issues.map((issue) => issue.message) ?? [];
|
1634
1643
|
}
|
1635
|
-
function
|
1644
|
+
function runFieldValidations({
|
1636
1645
|
field: field2,
|
1637
1646
|
values
|
1638
1647
|
}) {
|
@@ -1640,6 +1649,23 @@ function getFieldValidationErrors({
|
|
1640
1649
|
$form: values,
|
1641
1650
|
$now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1642
1651
|
};
|
1652
|
+
const fieldValidationResult = validateFieldInput({
|
1653
|
+
field: field2,
|
1654
|
+
value: values[field2.id]
|
1655
|
+
});
|
1656
|
+
const customValidationResults = runCustomFieldValidations({
|
1657
|
+
field: field2,
|
1658
|
+
conditionalParameters
|
1659
|
+
});
|
1660
|
+
return {
|
1661
|
+
// Assumes that custom validation errors are based on the field type, and extend the validation.
|
1662
|
+
errors: [...fieldValidationResult, ...customValidationResults]
|
1663
|
+
};
|
1664
|
+
}
|
1665
|
+
function getFieldValidationErrors({
|
1666
|
+
field: field2,
|
1667
|
+
values
|
1668
|
+
}) {
|
1643
1669
|
if (!isFieldVisible(field2, values) || !isFieldEnabled(field2, values)) {
|
1644
1670
|
if (values[field2.id]) {
|
1645
1671
|
return {
|
@@ -1654,18 +1680,10 @@ function getFieldValidationErrors({
|
|
1654
1680
|
errors: []
|
1655
1681
|
};
|
1656
1682
|
}
|
1657
|
-
|
1658
|
-
field: field2,
|
1659
|
-
value: values[field2.id]
|
1660
|
-
});
|
1661
|
-
const customValidationResults = runCustomFieldValidations({
|
1683
|
+
return runFieldValidations({
|
1662
1684
|
field: field2,
|
1663
|
-
|
1685
|
+
values
|
1664
1686
|
});
|
1665
|
-
return {
|
1666
|
-
// Assumes that custom validation errors are based on the field type, and extend the validation.
|
1667
|
-
errors: [...fieldValidationResult, ...customValidationResults]
|
1668
|
-
};
|
1669
1687
|
}
|
1670
1688
|
|
1671
1689
|
// ../commons/src/uuid.ts
|
@@ -1765,27 +1783,19 @@ function isPageVisible(page, formValues) {
|
|
1765
1783
|
$now: (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" })
|
1766
1784
|
});
|
1767
1785
|
}
|
1768
|
-
|
1769
|
-
return
|
1770
|
-
};
|
1771
|
-
function isOptionalUncheckedCheckbox(field2, form) {
|
1772
|
-
if (field2.type !== FieldType.CHECKBOX || field2.required) {
|
1773
|
-
return false;
|
1774
|
-
}
|
1775
|
-
return !form[field2.id];
|
1776
|
-
}
|
1777
|
-
function stripHiddenFields(fields, declaration) {
|
1778
|
-
return (0, import_lodash.omitBy)(declaration, (_, fieldId) => {
|
1786
|
+
function omitHiddenFields(fields, values) {
|
1787
|
+
return (0, import_lodash.omitBy)(values, (_, fieldId) => {
|
1779
1788
|
const field2 = fields.find((f) => f.id === fieldId);
|
1780
1789
|
if (!field2) {
|
1781
1790
|
return true;
|
1782
1791
|
}
|
1783
|
-
|
1784
|
-
return true;
|
1785
|
-
}
|
1786
|
-
return !isFieldVisible(field2, declaration);
|
1792
|
+
return !isFieldVisible(field2, values);
|
1787
1793
|
});
|
1788
1794
|
}
|
1795
|
+
function omitHiddenPaginatedFields(formConfig, declaration) {
|
1796
|
+
const visiblePagesFormFields = formConfig.pages.filter((p) => isPageVisible(p, declaration)).flatMap((p) => p.fields);
|
1797
|
+
return omitHiddenFields(visiblePagesFormFields, declaration);
|
1798
|
+
}
|
1789
1799
|
function findActiveDrafts(event2, drafts) {
|
1790
1800
|
const actions = event2.actions.slice().filter(({ type }) => type !== ActionType.READ).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
1791
1801
|
const lastAction = actions[actions.length - 1];
|
@@ -1828,6 +1838,14 @@ function deepMerge(currentDocument, actionDocument) {
|
|
1828
1838
|
}
|
1829
1839
|
);
|
1830
1840
|
}
|
1841
|
+
function findLastAssignmentAction(actions) {
|
1842
|
+
return actions.filter(
|
1843
|
+
({ type }) => type === ActionType.ASSIGN || type === ActionType.UNASSIGN
|
1844
|
+
).reduce((latestAction, action) => !latestAction || action.createdAt > latestAction.createdAt ? action : latestAction, void 0);
|
1845
|
+
}
|
1846
|
+
function isWriteAction(actionType) {
|
1847
|
+
return writeActions.safeParse(actionType).success;
|
1848
|
+
}
|
1831
1849
|
|
1832
1850
|
// ../commons/src/events/EventConfig.ts
|
1833
1851
|
var EventConfig = import_zod20.z.object({
|
@@ -1908,7 +1926,8 @@ var AssignedAction = ActionBase.merge(
|
|
1908
1926
|
);
|
1909
1927
|
var UnassignedAction = ActionBase.merge(
|
1910
1928
|
import_zod21.z.object({
|
1911
|
-
type: import_zod21.z.literal(ActionType.UNASSIGN)
|
1929
|
+
type: import_zod21.z.literal(ActionType.UNASSIGN),
|
1930
|
+
assignedTo: import_zod21.z.literal(null).default(null)
|
1912
1931
|
})
|
1913
1932
|
);
|
1914
1933
|
var RegisterAction = ActionBase.merge(
|
@@ -2027,7 +2046,8 @@ var BaseActionInput = import_zod22.z.object({
|
|
2027
2046
|
transactionId: import_zod22.z.string(),
|
2028
2047
|
declaration: ActionUpdate.default({}),
|
2029
2048
|
annotation: ActionUpdate.optional(),
|
2030
|
-
originalActionId: import_zod22.z.string().optional()
|
2049
|
+
originalActionId: import_zod22.z.string().optional(),
|
2050
|
+
keepAssignment: import_zod22.z.boolean().optional()
|
2031
2051
|
});
|
2032
2052
|
var CreateActionInput = BaseActionInput.merge(
|
2033
2053
|
import_zod22.z.object({
|
@@ -2238,7 +2258,7 @@ function aggregateActionDeclarations(actions) {
|
|
2238
2258
|
}
|
2239
2259
|
function deepDropNulls(obj) {
|
2240
2260
|
if (Array.isArray(obj)) {
|
2241
|
-
return obj;
|
2261
|
+
return obj.map(deepDropNulls);
|
2242
2262
|
}
|
2243
2263
|
if (obj !== null && typeof obj === "object") {
|
2244
2264
|
return Object.entries(obj).reduce((acc, [key, value]) => {
|
@@ -3398,9 +3418,8 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
3398
3418
|
},
|
3399
3419
|
{
|
3400
3420
|
id: "applicant.dob",
|
3401
|
-
type:
|
3421
|
+
type: FieldType.DATE,
|
3402
3422
|
required: true,
|
3403
|
-
conditionals: [],
|
3404
3423
|
validation: [
|
3405
3424
|
{
|
3406
3425
|
message: {
|
@@ -3411,12 +3430,50 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
|
|
3411
3430
|
validator: field("applicant.dob").isBefore().now()
|
3412
3431
|
}
|
3413
3432
|
],
|
3433
|
+
conditionals: [
|
3434
|
+
{
|
3435
|
+
type: ConditionalType.SHOW,
|
3436
|
+
conditional: field("applicant.dobUnknown").isFalsy()
|
3437
|
+
}
|
3438
|
+
],
|
3414
3439
|
label: {
|
3415
3440
|
defaultMessage: "Applicant's date of birth",
|
3416
3441
|
description: "This is the label for the field",
|
3417
3442
|
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dob.label"
|
3418
3443
|
}
|
3419
3444
|
},
|
3445
|
+
{
|
3446
|
+
id: "applicant.dobUnknown",
|
3447
|
+
type: FieldType.CHECKBOX,
|
3448
|
+
required: false,
|
3449
|
+
label: {
|
3450
|
+
defaultMessage: "Exact date of birth unknown",
|
3451
|
+
description: "This is the label for the field",
|
3452
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.dobUnknown.label"
|
3453
|
+
},
|
3454
|
+
conditionals: [
|
3455
|
+
{
|
3456
|
+
type: ConditionalType.DISPLAY_ON_REVIEW,
|
3457
|
+
conditional: never()
|
3458
|
+
}
|
3459
|
+
]
|
3460
|
+
},
|
3461
|
+
{
|
3462
|
+
id: "applicant.age",
|
3463
|
+
type: FieldType.NUMBER,
|
3464
|
+
required: true,
|
3465
|
+
label: {
|
3466
|
+
defaultMessage: "Age of tennis-member",
|
3467
|
+
description: "This is the label for the field",
|
3468
|
+
id: "v2.event.tennis-club-membership.action.declare.form.section.who.field.age.label"
|
3469
|
+
},
|
3470
|
+
conditionals: [
|
3471
|
+
{
|
3472
|
+
type: ConditionalType.SHOW,
|
3473
|
+
conditional: field("applicant.dobUnknown").isEqualTo(true)
|
3474
|
+
}
|
3475
|
+
]
|
3476
|
+
},
|
3420
3477
|
{
|
3421
3478
|
id: "applicant.image",
|
3422
3479
|
type: FieldType.FILE,
|
@@ -3932,7 +3989,7 @@ var tennisClubMembershipEvent = defineConfig({
|
|
3932
3989
|
});
|
3933
3990
|
|
3934
3991
|
// ../commons/src/events/test.utils.ts
|
3935
|
-
function
|
3992
|
+
function fieldConfigsToActionPayload(fields) {
|
3936
3993
|
return fields.reduce(
|
3937
3994
|
(acc, field2, i) => ({
|
3938
3995
|
...acc,
|
@@ -3941,22 +3998,23 @@ function fieldConfigsToActionAnnotation(fields) {
|
|
3941
3998
|
{}
|
3942
3999
|
);
|
3943
4000
|
}
|
3944
|
-
function
|
4001
|
+
function generateActionDeclarationInput(configuration, action) {
|
3945
4002
|
const parsed = DeclarationUpdateActions.safeParse(action);
|
3946
4003
|
if (parsed.success) {
|
3947
4004
|
const fields = getDeclarationFields(configuration);
|
3948
|
-
const
|
3949
|
-
|
4005
|
+
const declarationConfig = getDeclaration(configuration);
|
4006
|
+
const declaration = fieldConfigsToActionPayload(fields);
|
4007
|
+
return omitHiddenPaginatedFields(declarationConfig, declaration);
|
3950
4008
|
}
|
3951
4009
|
console.warn(`${action} is not a declaration action. Setting data as {}.`);
|
3952
4010
|
return {};
|
3953
4011
|
}
|
3954
|
-
function
|
4012
|
+
function generateActionAnnotationInput(configuration, action) {
|
3955
4013
|
const actionConfig = configuration.actions.find(
|
3956
4014
|
(ac) => ac.type === action
|
3957
4015
|
);
|
3958
4016
|
const annotationFields = actionConfig ? getActionAnnotationFields(actionConfig) : [];
|
3959
|
-
const annotation =
|
4017
|
+
const annotation = fieldConfigsToActionPayload(annotationFields);
|
3960
4018
|
const visibleVerificationPageIds = findRecordActionPages(
|
3961
4019
|
configuration,
|
3962
4020
|
action
|
@@ -3968,7 +4026,7 @@ function generateActionMetadataInput(configuration, action) {
|
|
3968
4026
|
}),
|
3969
4027
|
{}
|
3970
4028
|
);
|
3971
|
-
const fieldBasedPayload =
|
4029
|
+
const fieldBasedPayload = omitHiddenFields(annotationFields, annotation);
|
3972
4030
|
return {
|
3973
4031
|
...fieldBasedPayload,
|
3974
4032
|
...visiblePageVerificationMap
|
@@ -4014,8 +4072,11 @@ var eventPayloadGenerator = {
|
|
4014
4072
|
declare: (eventId, input = {}) => ({
|
4015
4073
|
type: ActionType.DECLARE,
|
4016
4074
|
transactionId: input.transactionId ?? getUUID(),
|
4017
|
-
declaration: input.declaration ??
|
4018
|
-
|
4075
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4076
|
+
tennisClubMembershipEvent,
|
4077
|
+
ActionType.DECLARE
|
4078
|
+
),
|
4079
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4019
4080
|
tennisClubMembershipEvent,
|
4020
4081
|
ActionType.DECLARE
|
4021
4082
|
),
|
@@ -4028,7 +4089,10 @@ var eventPayloadGenerator = {
|
|
4028
4089
|
let declaration = input.declaration;
|
4029
4090
|
if (!declaration) {
|
4030
4091
|
const partialDeclaration = (0, import_lodash2.omitBy)(
|
4031
|
-
|
4092
|
+
generateActionDeclarationInput(
|
4093
|
+
tennisClubMembershipEvent,
|
4094
|
+
ActionType.DECLARE
|
4095
|
+
),
|
4032
4096
|
import_lodash2.isString
|
4033
4097
|
);
|
4034
4098
|
declaration = partialDeclaration;
|
@@ -4043,8 +4107,11 @@ var eventPayloadGenerator = {
|
|
4043
4107
|
validate: (eventId, input = {}) => ({
|
4044
4108
|
type: ActionType.VALIDATE,
|
4045
4109
|
transactionId: input.transactionId ?? getUUID(),
|
4046
|
-
declaration: input.declaration ??
|
4047
|
-
|
4110
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4111
|
+
tennisClubMembershipEvent,
|
4112
|
+
ActionType.VALIDATE
|
4113
|
+
),
|
4114
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4048
4115
|
tennisClubMembershipEvent,
|
4049
4116
|
ActionType.VALIDATE
|
4050
4117
|
),
|
@@ -4078,7 +4145,7 @@ var eventPayloadGenerator = {
|
|
4078
4145
|
type: ActionType.REJECT,
|
4079
4146
|
transactionId: input.transactionId ?? getUUID(),
|
4080
4147
|
declaration: {},
|
4081
|
-
annotation: input.annotation ??
|
4148
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4082
4149
|
tennisClubMembershipEvent,
|
4083
4150
|
ActionType.REJECT
|
4084
4151
|
),
|
@@ -4088,8 +4155,11 @@ var eventPayloadGenerator = {
|
|
4088
4155
|
register: (eventId, input = {}) => ({
|
4089
4156
|
type: ActionType.REGISTER,
|
4090
4157
|
transactionId: input.transactionId ?? getUUID(),
|
4091
|
-
declaration: input.declaration ??
|
4092
|
-
|
4158
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4159
|
+
tennisClubMembershipEvent,
|
4160
|
+
ActionType.REGISTER
|
4161
|
+
),
|
4162
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4093
4163
|
tennisClubMembershipEvent,
|
4094
4164
|
ActionType.REGISTER
|
4095
4165
|
),
|
@@ -4099,7 +4169,7 @@ var eventPayloadGenerator = {
|
|
4099
4169
|
type: ActionType.PRINT_CERTIFICATE,
|
4100
4170
|
transactionId: input.transactionId ?? getUUID(),
|
4101
4171
|
declaration: {},
|
4102
|
-
annotation: input.annotation ??
|
4172
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4103
4173
|
tennisClubMembershipEvent,
|
4104
4174
|
ActionType.PRINT_CERTIFICATE
|
4105
4175
|
),
|
@@ -4109,11 +4179,11 @@ var eventPayloadGenerator = {
|
|
4109
4179
|
request: (eventId, input = {}) => ({
|
4110
4180
|
type: ActionType.REQUEST_CORRECTION,
|
4111
4181
|
transactionId: input.transactionId ?? getUUID(),
|
4112
|
-
declaration: input.declaration ??
|
4182
|
+
declaration: input.declaration ?? generateActionDeclarationInput(
|
4113
4183
|
tennisClubMembershipEvent,
|
4114
4184
|
ActionType.REQUEST_CORRECTION
|
4115
4185
|
),
|
4116
|
-
annotation: input.annotation ??
|
4186
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4117
4187
|
tennisClubMembershipEvent,
|
4118
4188
|
ActionType.REQUEST_CORRECTION
|
4119
4189
|
),
|
@@ -4123,7 +4193,7 @@ var eventPayloadGenerator = {
|
|
4123
4193
|
type: ActionType.APPROVE_CORRECTION,
|
4124
4194
|
transactionId: input.transactionId ?? getUUID(),
|
4125
4195
|
declaration: {},
|
4126
|
-
annotation: input.annotation ??
|
4196
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4127
4197
|
tennisClubMembershipEvent,
|
4128
4198
|
ActionType.APPROVE_CORRECTION
|
4129
4199
|
),
|
@@ -4134,7 +4204,7 @@ var eventPayloadGenerator = {
|
|
4134
4204
|
type: ActionType.REJECT_CORRECTION,
|
4135
4205
|
transactionId: input.transactionId ?? getUUID(),
|
4136
4206
|
declaration: {},
|
4137
|
-
annotation: input.annotation ??
|
4207
|
+
annotation: input.annotation ?? generateActionAnnotationInput(
|
4138
4208
|
tennisClubMembershipEvent,
|
4139
4209
|
ActionType.REJECT_CORRECTION
|
4140
4210
|
),
|
@@ -4156,7 +4226,7 @@ function generateActionDocument({
|
|
4156
4226
|
createdBy: getUUID(),
|
4157
4227
|
id: getUUID(),
|
4158
4228
|
createdAtLocation: "TODO",
|
4159
|
-
declaration:
|
4229
|
+
declaration: generateActionDeclarationInput(configuration, action),
|
4160
4230
|
annotation: {},
|
4161
4231
|
...defaults,
|
4162
4232
|
status: ActionStatus.Accepted
|
@@ -4169,7 +4239,7 @@ function generateActionDocument({
|
|
4169
4239
|
case ActionType.DECLARE:
|
4170
4240
|
return { ...actionBase, type: action };
|
4171
4241
|
case ActionType.UNASSIGN:
|
4172
|
-
return { ...actionBase, type: action };
|
4242
|
+
return { ...actionBase, type: action, assignedTo: null };
|
4173
4243
|
case ActionType.ASSIGN:
|
4174
4244
|
return { ...actionBase, assignedTo: getUUID(), type: action };
|
4175
4245
|
case ActionType.VALIDATE:
|