@nira-opencrvs/toolkit 1.9.11-rc.39d8d68

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.
Files changed (77) hide show
  1. package/README.md +70 -0
  2. package/build.sh +56 -0
  3. package/dist/api/index.d.ts +11 -0
  4. package/dist/api/index.d.ts.map +1 -0
  5. package/dist/api/index.js +52 -0
  6. package/dist/commons/api/router.d.ts +4125 -0
  7. package/dist/commons/conditionals/conditionals.d.ts +824 -0
  8. package/dist/commons/conditionals/index.d.ts +2 -0
  9. package/dist/commons/conditionals/validate.d.ts +101 -0
  10. package/dist/commons/events/ActionConfig.d.ts +1609 -0
  11. package/dist/commons/events/ActionDocument.d.ts +2180 -0
  12. package/dist/commons/events/ActionInput.d.ts +1229 -0
  13. package/dist/commons/events/ActionType.d.ts +52 -0
  14. package/dist/commons/events/AdvancedSearchConfig.d.ts +1538 -0
  15. package/dist/commons/events/CompositeFieldValue.d.ts +280 -0
  16. package/dist/commons/events/Conditional.d.ts +55 -0
  17. package/dist/commons/events/Constants.d.ts +3 -0
  18. package/dist/commons/events/CountryConfigQueryInput.d.ts +4784 -0
  19. package/dist/commons/events/CreatedAtLocation.d.ts +2 -0
  20. package/dist/commons/events/DeduplicationConfig.d.ts +233 -0
  21. package/dist/commons/events/Draft.d.ts +118 -0
  22. package/dist/commons/events/DynamicFieldValue.d.ts +139 -0
  23. package/dist/commons/events/EventConfig.d.ts +2255 -0
  24. package/dist/commons/events/EventConfigInput.d.ts +10 -0
  25. package/dist/commons/events/EventDocument.d.ts +1457 -0
  26. package/dist/commons/events/EventIndex.d.ts +1134 -0
  27. package/dist/commons/events/EventInput.d.ts +13 -0
  28. package/dist/commons/events/EventMetadata.d.ts +413 -0
  29. package/dist/commons/events/FieldConfig.d.ts +12935 -0
  30. package/dist/commons/events/FieldType.d.ts +55 -0
  31. package/dist/commons/events/FieldTypeMapping.d.ts +1289 -0
  32. package/dist/commons/events/FieldValue.d.ts +512 -0
  33. package/dist/commons/events/FileUtils.d.ts +4 -0
  34. package/dist/commons/events/FormConfig.d.ts +755 -0
  35. package/dist/commons/events/PageConfig.d.ts +342 -0
  36. package/dist/commons/events/PlainDate.d.ts +19 -0
  37. package/dist/commons/events/SummaryConfig.d.ts +170 -0
  38. package/dist/commons/events/TemplateConfig.d.ts +66 -0
  39. package/dist/commons/events/TranslationConfig.d.ts +15 -0
  40. package/dist/commons/events/WorkqueueColumnConfig.d.ts +53 -0
  41. package/dist/commons/events/WorkqueueConfig.d.ts +7957 -0
  42. package/dist/commons/events/deduplication.d.ts +69 -0
  43. package/dist/commons/events/defineConfig.d.ts +234 -0
  44. package/dist/commons/events/event.d.ts +80 -0
  45. package/dist/commons/events/field.d.ts +514 -0
  46. package/dist/commons/events/index.d.ts +45 -0
  47. package/dist/commons/events/locations.d.ts +24 -0
  48. package/dist/commons/events/scopes.d.ts +55 -0
  49. package/dist/commons/events/serializer.d.ts +2 -0
  50. package/dist/commons/events/state/availableActions.d.ts +6 -0
  51. package/dist/commons/events/state/flags.d.ts +4 -0
  52. package/dist/commons/events/state/index.d.ts +119 -0
  53. package/dist/commons/events/state/utils.d.ts +311 -0
  54. package/dist/commons/events/test.utils.d.ts +248 -0
  55. package/dist/commons/events/transactions.d.ts +2 -0
  56. package/dist/commons/events/utils.d.ts +486 -0
  57. package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
  58. package/dist/commons/notification/UserNotifications.d.ts +762 -0
  59. package/dist/commons/notification/index.d.ts +2 -0
  60. package/dist/conditionals/index.d.ts +2 -0
  61. package/dist/conditionals/index.d.ts.map +1 -0
  62. package/dist/conditionals/index.js +689 -0
  63. package/dist/events/deduplication.d.ts +69 -0
  64. package/dist/events/deduplication.d.ts.map +1 -0
  65. package/dist/events/deduplication.js +101 -0
  66. package/dist/events/index.d.ts +2 -0
  67. package/dist/events/index.d.ts.map +1 -0
  68. package/dist/events/index.js +9327 -0
  69. package/dist/notification/index.d.ts +2 -0
  70. package/dist/notification/index.d.ts.map +1 -0
  71. package/dist/notification/index.js +6674 -0
  72. package/dist/scopes/index.d.ts +385 -0
  73. package/dist/scopes/index.d.ts.map +1 -0
  74. package/dist/scopes/index.js +349 -0
  75. package/package.json +40 -0
  76. package/tsconfig.json +27 -0
  77. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,69 @@
1
+ import { ClauseInput, DateRangeMatcherOptions, FuzzyMatcherOptions, StrictMatcherOptions } from '.';
2
+ export declare function not(clause: ClauseInput): ClauseInput;
3
+ export declare function and(...clauses: ClauseInput[]): ClauseInput;
4
+ export declare function or(...clauses: ClauseInput[]): ClauseInput;
5
+ export declare function field(fieldId: string): {
6
+ fuzzyMatches: (options?: FuzzyMatcherOptions) => {
7
+ fieldId: string;
8
+ type: "fuzzy";
9
+ options: {
10
+ boost?: number | undefined;
11
+ matchAgainst?: string | undefined;
12
+ fuzziness?: string | number | undefined;
13
+ } | undefined;
14
+ };
15
+ strictMatches: (options?: StrictMatcherOptions) => {
16
+ fieldId: string;
17
+ type: "strict";
18
+ options: {
19
+ value?: string | undefined;
20
+ boost?: number | undefined;
21
+ matchAgainst?: string | undefined;
22
+ } | undefined;
23
+ };
24
+ /**
25
+ * Creates a date range matcher that finds records where date field fall within a specified range.
26
+ *
27
+ * By default, matches against the field specified in `field()` (e.g., 'mother.dob').
28
+ * When `matchAgainst` is provided, it overwrites the default field and searches against that field with OR logic .
29
+ *
30
+ * @param options - Configuration for the date range matching
31
+ * @param options.days - Number of days before and after the target date to search (creates a ±days range)
32
+ * @param options.pivot - Optional. Distance in days where relevance scoring drops by 50%. Defaults to ⌊(days * 2) / 3⌋
33
+ * @param options.boost - Optional. Scoring boost multiplier for matching results. Defaults to 1
34
+ * @param options.matchAgainst - Optional. Additional field to match against. When provided,
35
+ * the query matches if the field fall within the date range. The default field is always excluded in the search in that case.
36
+ *
37
+ * @returns A clause that matches records where at least one of the specified date field is within the range
38
+ *
39
+ * @example
40
+ * // Matches only against mother.dob (±365 days)
41
+ * field('mother.dob').dateRangeMatches({ days: 365 })
42
+ *
43
+ * @example
44
+ * // Matches against mother.age OR spouse.dob, not mother.dob
45
+ * field('mother.dob').dateRangeMatches({
46
+ * days: 365,
47
+ * matchAgainst: $field('mother.age')
48
+ * })
49
+ *
50
+ * @example
51
+ * // With custom pivot and boost
52
+ * field('mother.dob').dateRangeMatches({
53
+ * days: 730,
54
+ * pivot: 365,
55
+ * boost: 2
56
+ * })
57
+ */
58
+ dateRangeMatches: (options: DateRangeMatcherOptions) => {
59
+ fieldId: string;
60
+ type: "dateRange";
61
+ options: {
62
+ days: number;
63
+ boost?: number | undefined;
64
+ matchAgainst?: string | undefined;
65
+ pivot?: number | undefined;
66
+ };
67
+ };
68
+ };
69
+ //# sourceMappingURL=deduplication.d.ts.map
@@ -0,0 +1,234 @@
1
+ import { EventConfigInput } from './EventConfigInput';
2
+ /**
3
+ * Builds a validated configuration for an event
4
+ * @param config - Event specific configuration
5
+ */
6
+ export declare const defineConfig: (config: EventConfigInput) => {
7
+ id: string;
8
+ title: import("./TranslationConfig").TranslationConfig;
9
+ declaration: {
10
+ label: import("./TranslationConfig").TranslationConfig;
11
+ pages: {
12
+ type: "FORM";
13
+ id: string;
14
+ title: import("./TranslationConfig").TranslationConfig;
15
+ fields: import("./FieldConfig").FieldConfig[];
16
+ requireCompletionToContinue: boolean;
17
+ conditional?: import(".").JSONSchema | undefined;
18
+ }[];
19
+ };
20
+ actions: ({
21
+ type: "READ";
22
+ label: import("./TranslationConfig").TranslationConfig;
23
+ review: {
24
+ title: import("./TranslationConfig").TranslationConfig;
25
+ fields: import("./FieldConfig").FieldConfig[];
26
+ };
27
+ } | {
28
+ type: "DECLARE";
29
+ label: import("./TranslationConfig").TranslationConfig;
30
+ review: {
31
+ title: import("./TranslationConfig").TranslationConfig;
32
+ fields: import("./FieldConfig").FieldConfig[];
33
+ };
34
+ deduplication?: {
35
+ id: string;
36
+ query: import("./DeduplicationConfig").ClauseOutput;
37
+ label: import("./TranslationConfig").TranslationConfig;
38
+ } | undefined;
39
+ } | {
40
+ type: "VALIDATE";
41
+ label: import("./TranslationConfig").TranslationConfig;
42
+ review: {
43
+ title: import("./TranslationConfig").TranslationConfig;
44
+ fields: import("./FieldConfig").FieldConfig[];
45
+ };
46
+ deduplication?: {
47
+ id: string;
48
+ query: import("./DeduplicationConfig").ClauseOutput;
49
+ label: import("./TranslationConfig").TranslationConfig;
50
+ } | undefined;
51
+ } | {
52
+ type: "REJECT";
53
+ label: import("./TranslationConfig").TranslationConfig;
54
+ } | {
55
+ type: "ARCHIVE";
56
+ label: import("./TranslationConfig").TranslationConfig;
57
+ } | {
58
+ type: "REGISTER";
59
+ label: import("./TranslationConfig").TranslationConfig;
60
+ review: {
61
+ title: import("./TranslationConfig").TranslationConfig;
62
+ fields: import("./FieldConfig").FieldConfig[];
63
+ };
64
+ deduplication?: {
65
+ id: string;
66
+ query: import("./DeduplicationConfig").ClauseOutput;
67
+ label: import("./TranslationConfig").TranslationConfig;
68
+ } | undefined;
69
+ } | {
70
+ type: "DELETE";
71
+ label: import("./TranslationConfig").TranslationConfig;
72
+ } | {
73
+ type: "PRINT_CERTIFICATE";
74
+ label: import("./TranslationConfig").TranslationConfig;
75
+ printForm: {
76
+ label: import("./TranslationConfig").TranslationConfig;
77
+ pages: ({
78
+ type: "FORM";
79
+ id: string;
80
+ title: import("./TranslationConfig").TranslationConfig;
81
+ fields: import("./FieldConfig").FieldConfig[];
82
+ requireCompletionToContinue: boolean;
83
+ conditional?: import(".").JSONSchema | undefined;
84
+ } | {
85
+ type: "VERIFICATION";
86
+ id: string;
87
+ title: import("./TranslationConfig").TranslationConfig;
88
+ actions: {
89
+ cancel: {
90
+ label: import("./TranslationConfig").TranslationConfig;
91
+ confirmation: {
92
+ title: import("./TranslationConfig").TranslationConfig;
93
+ body: import("./TranslationConfig").TranslationConfig;
94
+ };
95
+ };
96
+ verify: {
97
+ label: import("./TranslationConfig").TranslationConfig;
98
+ };
99
+ };
100
+ fields: import("./FieldConfig").FieldConfig[];
101
+ requireCompletionToContinue: boolean;
102
+ conditional?: import(".").JSONSchema | undefined;
103
+ })[];
104
+ };
105
+ } | {
106
+ type: "REQUEST_CORRECTION";
107
+ label: import("./TranslationConfig").TranslationConfig;
108
+ correctionForm: {
109
+ label: import("./TranslationConfig").TranslationConfig;
110
+ pages: ({
111
+ type: "FORM";
112
+ id: string;
113
+ title: import("./TranslationConfig").TranslationConfig;
114
+ fields: import("./FieldConfig").FieldConfig[];
115
+ requireCompletionToContinue: boolean;
116
+ conditional?: import(".").JSONSchema | undefined;
117
+ } | {
118
+ type: "VERIFICATION";
119
+ id: string;
120
+ title: import("./TranslationConfig").TranslationConfig;
121
+ actions: {
122
+ cancel: {
123
+ label: import("./TranslationConfig").TranslationConfig;
124
+ confirmation: {
125
+ title: import("./TranslationConfig").TranslationConfig;
126
+ body: import("./TranslationConfig").TranslationConfig;
127
+ };
128
+ };
129
+ verify: {
130
+ label: import("./TranslationConfig").TranslationConfig;
131
+ };
132
+ };
133
+ fields: import("./FieldConfig").FieldConfig[];
134
+ requireCompletionToContinue: boolean;
135
+ conditional?: import(".").JSONSchema | undefined;
136
+ })[];
137
+ };
138
+ } | {
139
+ type: "REJECT_CORRECTION";
140
+ label: import("./TranslationConfig").TranslationConfig;
141
+ } | {
142
+ type: "APPROVE_CORRECTION";
143
+ label: import("./TranslationConfig").TranslationConfig;
144
+ })[];
145
+ label: import("./TranslationConfig").TranslationConfig;
146
+ summary: {
147
+ fields: ({
148
+ fieldId: string;
149
+ label?: import("./TranslationConfig").TranslationConfig | undefined;
150
+ conditionals?: {
151
+ type: "SHOW";
152
+ conditional: import(".").JSONSchema;
153
+ }[] | undefined;
154
+ emptyValueMessage?: import("./TranslationConfig").TranslationConfig | undefined;
155
+ } | {
156
+ id: string;
157
+ value: import("./TranslationConfig").TranslationConfig;
158
+ label: import("./TranslationConfig").TranslationConfig;
159
+ conditionals?: {
160
+ type: "SHOW";
161
+ conditional: import(".").JSONSchema;
162
+ }[] | undefined;
163
+ emptyValueMessage?: import("./TranslationConfig").TranslationConfig | undefined;
164
+ })[];
165
+ };
166
+ advancedSearch: {
167
+ title: import("./TranslationConfig").TranslationConfig;
168
+ fields: ({
169
+ config: {
170
+ type: "exact" | "fuzzy" | "range" | "within";
171
+ searchFields?: string[] | undefined;
172
+ };
173
+ fieldId: string;
174
+ fieldType: "field";
175
+ type?: "NAME" | "PHONE" | "ID" | "ADDRESS" | "TEXT" | "NUMBER" | "NUMBER_WITH_UNIT" | "TEXTAREA" | "EMAIL" | "DATE" | "AGE" | "DATE_RANGE" | "SELECT_DATE_RANGE" | "TIME" | "PARAGRAPH" | "PAGE_HEADER" | "RADIO_GROUP" | "FILE" | "FILE_WITH_OPTIONS" | "BULLET_LIST" | "CHECKBOX" | "SELECT" | "COUNTRY" | "LOCATION" | "DIVIDER" | "ADMINISTRATIVE_AREA" | "FACILITY" | "OFFICE" | "SIGNATURE" | "DATA" | "BUTTON" | "SEARCH" | "ALPHA_PRINT_BUTTON" | "HTTP" | "LINK_BUTTON" | "VERIFICATION_STATUS" | "QUERY_PARAM_READER" | "QR_READER" | "ID_READER" | "LOADER" | undefined;
176
+ options?: {
177
+ value: string;
178
+ label: string | import("./TranslationConfig").TranslationConfig;
179
+ }[] | undefined;
180
+ label?: import("./TranslationConfig").TranslationConfig | undefined;
181
+ conditionals?: ({
182
+ type: "SHOW";
183
+ conditional: import(".").JSONSchema;
184
+ } | {
185
+ type: "ENABLE";
186
+ conditional: import(".").JSONSchema;
187
+ } | {
188
+ type: "DISPLAY_ON_REVIEW";
189
+ conditional: import(".").JSONSchema;
190
+ })[] | undefined;
191
+ searchCriteriaLabelPrefix?: import("./TranslationConfig").TranslationConfig | undefined;
192
+ validations?: {
193
+ message: import("./TranslationConfig").TranslationConfig;
194
+ validator: import(".").JSONSchema;
195
+ }[] | undefined;
196
+ } | {
197
+ config: {
198
+ type: "exact" | "fuzzy" | "range" | "within";
199
+ searchFields?: string[] | undefined;
200
+ };
201
+ fieldId: "event.status" | "event.trackingId" | "event.updatedAt" | "event.legalStatuses.REGISTERED.acceptedAt" | "event.legalStatuses.REGISTERED.createdAtLocation" | "event.legalStatuses.REGISTERED.registrationNumber";
202
+ fieldType: "event";
203
+ type?: "NAME" | "PHONE" | "ID" | "ADDRESS" | "TEXT" | "NUMBER" | "NUMBER_WITH_UNIT" | "TEXTAREA" | "EMAIL" | "DATE" | "AGE" | "DATE_RANGE" | "SELECT_DATE_RANGE" | "TIME" | "PARAGRAPH" | "PAGE_HEADER" | "RADIO_GROUP" | "FILE" | "FILE_WITH_OPTIONS" | "BULLET_LIST" | "CHECKBOX" | "SELECT" | "COUNTRY" | "LOCATION" | "DIVIDER" | "ADMINISTRATIVE_AREA" | "FACILITY" | "OFFICE" | "SIGNATURE" | "DATA" | "BUTTON" | "SEARCH" | "ALPHA_PRINT_BUTTON" | "HTTP" | "LINK_BUTTON" | "VERIFICATION_STATUS" | "QUERY_PARAM_READER" | "QR_READER" | "ID_READER" | "LOADER" | undefined;
204
+ options?: {
205
+ value: string;
206
+ label: string | import("./TranslationConfig").TranslationConfig;
207
+ }[] | undefined;
208
+ label?: import("./TranslationConfig").TranslationConfig | undefined;
209
+ conditionals?: ({
210
+ type: "SHOW";
211
+ conditional: import(".").JSONSchema;
212
+ } | {
213
+ type: "ENABLE";
214
+ conditional: import(".").JSONSchema;
215
+ } | {
216
+ type: "DISPLAY_ON_REVIEW";
217
+ conditional: import(".").JSONSchema;
218
+ })[] | undefined;
219
+ searchCriteriaLabelPrefix?: import("./TranslationConfig").TranslationConfig | undefined;
220
+ validations?: {
221
+ message: import("./TranslationConfig").TranslationConfig;
222
+ validator: import(".").JSONSchema;
223
+ }[] | undefined;
224
+ })[];
225
+ }[];
226
+ dateOfEvent?: {
227
+ $$field: string;
228
+ $$subfield: string[];
229
+ } | {
230
+ $$event: "createdAt" | "updatedAt" | "legalStatuses.DECLARED.createdAt" | "legalStatuses.DECLARED.acceptedAt" | "legalStatuses.REGISTERED.createdAt" | "legalStatuses.REGISTERED.acceptedAt";
231
+ } | undefined;
232
+ fallbackTitle?: import("./TranslationConfig").TranslationConfig | undefined;
233
+ };
234
+ //# sourceMappingURL=defineConfig.d.ts.map
@@ -0,0 +1,80 @@
1
+ import { NonSearchableEventMetadataTimeFieldIdInput, AdvancedSearchConfig } from '../event-config/event-configuration';
2
+ import { ActionType } from './ActionType';
3
+ import { EventFieldIdInput } from './AdvancedSearchConfig';
4
+ import { WorkqueueColumnKeys, WorkqueueColumnValue } from './WorkqueueColumnConfig';
5
+ /**
6
+ * Creates a function that acts like a callable + static method container.
7
+ *
8
+ * @example
9
+ * event('status') // → returns search config
10
+ * event.hasAction('CLICKED') // → returns conditional
11
+ */
12
+ declare function eventFn(fieldId: EventFieldIdInput): AdvancedSearchConfig;
13
+ declare function eventFn(fieldId: NonSearchableEventMetadataTimeFieldIdInput): {
14
+ $$event: NonSearchableEventMetadataTimeFieldIdInput;
15
+ };
16
+ declare const event: typeof eventFn & {
17
+ /**
18
+ * Checks if the event contains a specific action type.
19
+ * Can be used directly as a conditional or chained with additional methods.
20
+ * @param action - The action type to check for.
21
+ */
22
+ hasAction: (action: ActionType) => {
23
+ /**
24
+ * Creates a conditional that checks if the event contains a specific action type
25
+ * with a minimum count of occurrences.
26
+ *
27
+ * @param minCount - The minimum number of actions required.
28
+ */
29
+ minCount: (minCount: number) => import("../conditionals/conditionals").JSONSchema;
30
+ /**
31
+ * Builds a conditional that sets a maximum count for the number of actions.
32
+ * This is useful for limiting the number of actions of a specific type in a single event.
33
+ */
34
+ maxCount: (maxCount: number) => import("../conditionals/conditionals").JSONSchema;
35
+ /**
36
+ * Adds additional field constraints to the action matching.
37
+ *
38
+ * @param fields - Object containing additional fields to match on the action.
39
+ */
40
+ withFields: (fields: Record<string, unknown>) => {
41
+ /**
42
+ * Creates a conditional that checks if the event contains a specific action type
43
+ * with a minimum count of occurrences.
44
+ *
45
+ * @param minCount - The minimum number of actions required.
46
+ */
47
+ minCount: (minCount: number) => import("../conditionals/conditionals").JSONSchema;
48
+ /**
49
+ * Builds a conditional that sets a maximum count for the number of actions.
50
+ * This is useful for limiting the number of actions of a specific type in a single event.
51
+ */
52
+ maxCount: (maxCount: number) => import("../conditionals/conditionals").JSONSchema;
53
+ };
54
+ /**
55
+ * Adds template ID constraint to the action matching.
56
+ * This is a convenience method that adds content.templateId to the fields.
57
+ *
58
+ * @param id - The template ID to match against.
59
+ */
60
+ withTemplate: (id: string) => {
61
+ /**
62
+ * Creates a conditional that checks if the event contains a specific action type
63
+ * with a minimum count of occurrences.
64
+ *
65
+ * @param minCount - The minimum number of actions required.
66
+ */
67
+ minCount: (minCount: number) => import("../conditionals/conditionals").JSONSchema;
68
+ /**
69
+ * Builds a conditional that sets a maximum count for the number of actions.
70
+ * This is useful for limiting the number of actions of a specific type in a single event.
71
+ */
72
+ maxCount: (maxCount: number) => import("../conditionals/conditionals").JSONSchema;
73
+ };
74
+ $id: string;
75
+ __nominal__type: "JSONSchema";
76
+ };
77
+ field(field: WorkqueueColumnKeys): WorkqueueColumnValue;
78
+ };
79
+ export { event };
80
+ //# sourceMappingURL=event.d.ts.map