@opencrvs/toolkit 1.9.6-rc.e1907dc → 1.9.6-rc.e1e4717
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/events/DeduplicationConfig.d.ts +24 -0
- package/dist/commons/events/FieldConfig.d.ts +12 -31
- package/dist/commons/events/FieldTypeMapping.d.ts +18 -0
- package/dist/commons/events/FieldValue.d.ts +1 -0
- package/dist/commons/events/TemplateConfig.d.ts +0 -2
- package/dist/commons/events/deduplication.d.ts +44 -0
- package/dist/conditionals/index.js +2 -6
- package/dist/events/deduplication.d.ts +44 -0
- package/dist/events/deduplication.js +41 -0
- package/dist/events/index.js +42 -20
- package/dist/notification/index.js +39 -16
- package/package.json +1 -1
|
@@ -10,10 +10,13 @@ declare const FuzzyMatcher: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
10
10
|
fieldId: z.ZodString;
|
|
11
11
|
options: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
12
12
|
boost: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
matchAgainst: z.ZodOptional<z.ZodString>;
|
|
13
14
|
}, "strip", z.ZodTypeAny, {
|
|
14
15
|
boost?: number | undefined;
|
|
16
|
+
matchAgainst?: string | undefined;
|
|
15
17
|
}, {
|
|
16
18
|
boost?: number | undefined;
|
|
19
|
+
matchAgainst?: string | undefined;
|
|
17
20
|
}>>>;
|
|
18
21
|
}, {
|
|
19
22
|
type: z.ZodLiteral<"fuzzy">;
|
|
@@ -25,11 +28,14 @@ declare const FuzzyMatcher: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
25
28
|
*/
|
|
26
29
|
fuzziness: z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>>;
|
|
27
30
|
boost: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
31
|
+
matchAgainst: z.ZodOptional<z.ZodString>;
|
|
28
32
|
}, "strip", z.ZodTypeAny, {
|
|
29
33
|
boost: number;
|
|
30
34
|
fuzziness: string | number;
|
|
35
|
+
matchAgainst?: string | undefined;
|
|
31
36
|
}, {
|
|
32
37
|
boost?: number | undefined;
|
|
38
|
+
matchAgainst?: string | undefined;
|
|
33
39
|
fuzziness?: string | number | undefined;
|
|
34
40
|
}>>>;
|
|
35
41
|
}>, "strip", z.ZodTypeAny, {
|
|
@@ -37,6 +43,7 @@ declare const FuzzyMatcher: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
37
43
|
options: {
|
|
38
44
|
boost: number;
|
|
39
45
|
fuzziness: string | number;
|
|
46
|
+
matchAgainst?: string | undefined;
|
|
40
47
|
};
|
|
41
48
|
fieldId: string;
|
|
42
49
|
}, {
|
|
@@ -44,6 +51,7 @@ declare const FuzzyMatcher: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
44
51
|
fieldId: string;
|
|
45
52
|
options?: {
|
|
46
53
|
boost?: number | undefined;
|
|
54
|
+
matchAgainst?: string | undefined;
|
|
47
55
|
fuzziness?: string | number | undefined;
|
|
48
56
|
} | undefined;
|
|
49
57
|
}>;
|
|
@@ -58,10 +66,13 @@ declare const StrictMatcher: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
58
66
|
fieldId: z.ZodString;
|
|
59
67
|
options: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
60
68
|
boost: z.ZodOptional<z.ZodNumber>;
|
|
69
|
+
matchAgainst: z.ZodOptional<z.ZodString>;
|
|
61
70
|
}, "strip", z.ZodTypeAny, {
|
|
62
71
|
boost?: number | undefined;
|
|
72
|
+
matchAgainst?: string | undefined;
|
|
63
73
|
}, {
|
|
64
74
|
boost?: number | undefined;
|
|
75
|
+
matchAgainst?: string | undefined;
|
|
65
76
|
}>>>;
|
|
66
77
|
}, {
|
|
67
78
|
type: z.ZodLiteral<"strict">;
|
|
@@ -71,18 +82,22 @@ declare const StrictMatcher: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
71
82
|
* The constant value to be present in the field for both records
|
|
72
83
|
*/
|
|
73
84
|
value: z.ZodOptional<z.ZodString>;
|
|
85
|
+
matchAgainst: z.ZodOptional<z.ZodString>;
|
|
74
86
|
}, "strip", z.ZodTypeAny, {
|
|
75
87
|
boost: number;
|
|
76
88
|
value?: string | undefined;
|
|
89
|
+
matchAgainst?: string | undefined;
|
|
77
90
|
}, {
|
|
78
91
|
value?: string | undefined;
|
|
79
92
|
boost?: number | undefined;
|
|
93
|
+
matchAgainst?: string | undefined;
|
|
80
94
|
}>>>;
|
|
81
95
|
}>, "strip", z.ZodTypeAny, {
|
|
82
96
|
type: "strict";
|
|
83
97
|
options: {
|
|
84
98
|
boost: number;
|
|
85
99
|
value?: string | undefined;
|
|
100
|
+
matchAgainst?: string | undefined;
|
|
86
101
|
};
|
|
87
102
|
fieldId: string;
|
|
88
103
|
}, {
|
|
@@ -91,6 +106,7 @@ declare const StrictMatcher: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
91
106
|
options?: {
|
|
92
107
|
value?: string | undefined;
|
|
93
108
|
boost?: number | undefined;
|
|
109
|
+
matchAgainst?: string | undefined;
|
|
94
110
|
} | undefined;
|
|
95
111
|
}>;
|
|
96
112
|
export type StrictMatcherOptions = z.input<typeof StrictMatcher>['options'];
|
|
@@ -104,10 +120,13 @@ declare const DateRangeMatcher: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
104
120
|
fieldId: z.ZodString;
|
|
105
121
|
options: z.ZodDefault<z.ZodOptional<z.ZodObject<{
|
|
106
122
|
boost: z.ZodOptional<z.ZodNumber>;
|
|
123
|
+
matchAgainst: z.ZodOptional<z.ZodString>;
|
|
107
124
|
}, "strip", z.ZodTypeAny, {
|
|
108
125
|
boost?: number | undefined;
|
|
126
|
+
matchAgainst?: string | undefined;
|
|
109
127
|
}, {
|
|
110
128
|
boost?: number | undefined;
|
|
129
|
+
matchAgainst?: string | undefined;
|
|
111
130
|
}>>>;
|
|
112
131
|
}, {
|
|
113
132
|
type: z.ZodLiteral<"dateRange">;
|
|
@@ -119,13 +138,16 @@ declare const DateRangeMatcher: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
119
138
|
pivot: z.ZodOptional<z.ZodNumber>;
|
|
120
139
|
days: z.ZodNumber;
|
|
121
140
|
boost: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
141
|
+
matchAgainst: z.ZodOptional<z.ZodString>;
|
|
122
142
|
}, "strip", z.ZodTypeAny, {
|
|
123
143
|
boost: number;
|
|
124
144
|
days: number;
|
|
145
|
+
matchAgainst?: string | undefined;
|
|
125
146
|
pivot?: number | undefined;
|
|
126
147
|
}, {
|
|
127
148
|
days: number;
|
|
128
149
|
boost?: number | undefined;
|
|
150
|
+
matchAgainst?: string | undefined;
|
|
129
151
|
pivot?: number | undefined;
|
|
130
152
|
}>;
|
|
131
153
|
}>, "strip", z.ZodTypeAny, {
|
|
@@ -133,6 +155,7 @@ declare const DateRangeMatcher: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
133
155
|
options: {
|
|
134
156
|
boost: number;
|
|
135
157
|
days: number;
|
|
158
|
+
matchAgainst?: string | undefined;
|
|
136
159
|
pivot?: number | undefined;
|
|
137
160
|
};
|
|
138
161
|
fieldId: string;
|
|
@@ -141,6 +164,7 @@ declare const DateRangeMatcher: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
141
164
|
options: {
|
|
142
165
|
days: number;
|
|
143
166
|
boost?: number | undefined;
|
|
167
|
+
matchAgainst?: string | undefined;
|
|
144
168
|
pivot?: number | undefined;
|
|
145
169
|
};
|
|
146
170
|
fieldId: string;
|
|
@@ -1768,20 +1768,12 @@ declare const DateField: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
1768
1768
|
analytics: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
1769
1769
|
}, {
|
|
1770
1770
|
type: z.ZodLiteral<"DATE">;
|
|
1771
|
-
defaultValue: z.ZodOptional<z.ZodUnion<[z.
|
|
1772
|
-
$$
|
|
1773
|
-
$$time: z.ZodOptional<z.ZodLiteral<"now">>;
|
|
1771
|
+
defaultValue: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
1772
|
+
$$now: z.ZodLiteral<true>;
|
|
1774
1773
|
}, "strip", z.ZodTypeAny, {
|
|
1775
|
-
$$
|
|
1776
|
-
$$time?: "now" | undefined;
|
|
1777
|
-
}, {
|
|
1778
|
-
$$date?: "now" | undefined;
|
|
1779
|
-
$$time?: "now" | undefined;
|
|
1780
|
-
}>, {
|
|
1781
|
-
$$date: "now";
|
|
1774
|
+
$$now: true;
|
|
1782
1775
|
}, {
|
|
1783
|
-
$$
|
|
1784
|
-
$$time?: "now" | undefined;
|
|
1776
|
+
$$now: true;
|
|
1785
1777
|
}>, z.ZodString]>>;
|
|
1786
1778
|
configuration: z.ZodOptional<z.ZodObject<{
|
|
1787
1779
|
notice: z.ZodOptional<z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
|
|
@@ -1840,7 +1832,7 @@ declare const DateField: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
1840
1832
|
uncorrectable?: boolean | undefined;
|
|
1841
1833
|
analytics?: boolean | undefined;
|
|
1842
1834
|
defaultValue?: string | {
|
|
1843
|
-
$$
|
|
1835
|
+
$$now: true;
|
|
1844
1836
|
} | undefined;
|
|
1845
1837
|
configuration?: {
|
|
1846
1838
|
notice?: TranslationConfig | undefined;
|
|
@@ -1907,8 +1899,7 @@ declare const DateField: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
1907
1899
|
uncorrectable?: boolean | undefined;
|
|
1908
1900
|
analytics?: boolean | undefined;
|
|
1909
1901
|
defaultValue?: string | {
|
|
1910
|
-
$$
|
|
1911
|
-
$$time?: "now" | undefined;
|
|
1902
|
+
$$now: true;
|
|
1912
1903
|
} | undefined;
|
|
1913
1904
|
configuration?: {
|
|
1914
1905
|
notice?: {
|
|
@@ -2284,20 +2275,12 @@ declare const TimeField: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
2284
2275
|
analytics: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
2285
2276
|
}, {
|
|
2286
2277
|
type: z.ZodLiteral<"TIME">;
|
|
2287
|
-
defaultValue: z.ZodOptional<z.ZodUnion<[z.
|
|
2288
|
-
$$
|
|
2289
|
-
$$time: z.ZodOptional<z.ZodLiteral<"now">>;
|
|
2278
|
+
defaultValue: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
2279
|
+
$$now: z.ZodLiteral<true>;
|
|
2290
2280
|
}, "strip", z.ZodTypeAny, {
|
|
2291
|
-
$$
|
|
2292
|
-
$$time?: "now" | undefined;
|
|
2293
|
-
}, {
|
|
2294
|
-
$$date?: "now" | undefined;
|
|
2295
|
-
$$time?: "now" | undefined;
|
|
2296
|
-
}>, {
|
|
2297
|
-
$$time: "now";
|
|
2281
|
+
$$now: true;
|
|
2298
2282
|
}, {
|
|
2299
|
-
$$
|
|
2300
|
-
$$time?: "now" | undefined;
|
|
2283
|
+
$$now: true;
|
|
2301
2284
|
}>, z.ZodString]>>;
|
|
2302
2285
|
configuration: z.ZodOptional<z.ZodObject<{
|
|
2303
2286
|
use12HourFormat: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -2359,7 +2342,7 @@ declare const TimeField: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
2359
2342
|
uncorrectable?: boolean | undefined;
|
|
2360
2343
|
analytics?: boolean | undefined;
|
|
2361
2344
|
defaultValue?: string | {
|
|
2362
|
-
$$
|
|
2345
|
+
$$now: true;
|
|
2363
2346
|
} | undefined;
|
|
2364
2347
|
configuration?: {
|
|
2365
2348
|
notice?: TranslationConfig | undefined;
|
|
@@ -2427,8 +2410,7 @@ declare const TimeField: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
2427
2410
|
uncorrectable?: boolean | undefined;
|
|
2428
2411
|
analytics?: boolean | undefined;
|
|
2429
2412
|
defaultValue?: string | {
|
|
2430
|
-
$$
|
|
2431
|
-
$$time?: "now" | undefined;
|
|
2413
|
+
$$now: true;
|
|
2432
2414
|
} | undefined;
|
|
2433
2415
|
configuration?: {
|
|
2434
2416
|
notice?: {
|
|
@@ -2440,7 +2422,6 @@ declare const TimeField: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
2440
2422
|
} | undefined;
|
|
2441
2423
|
}>;
|
|
2442
2424
|
export type TimeField = z.infer<typeof TimeField>;
|
|
2443
|
-
export type TimeField2 = z.input<typeof TimeField>;
|
|
2444
2425
|
declare const DateRangeField: z.ZodObject<z.objectUtil.extendShape<{
|
|
2445
2426
|
id: z.ZodEffects<z.ZodString, string, string>;
|
|
2446
2427
|
label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, {
|
|
@@ -230,6 +230,15 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
|
|
|
230
230
|
}, {
|
|
231
231
|
data?: any;
|
|
232
232
|
}>>> | z.ZodObject<{
|
|
233
|
+
numericValue: z.ZodNumber;
|
|
234
|
+
unit: z.ZodString;
|
|
235
|
+
}, "strip", z.ZodTypeAny, {
|
|
236
|
+
numericValue: number;
|
|
237
|
+
unit: string;
|
|
238
|
+
}, {
|
|
239
|
+
numericValue: number;
|
|
240
|
+
unit: string;
|
|
241
|
+
}> | z.ZodObject<{
|
|
233
242
|
numericValue: z.ZodOptional<z.ZodNumber>;
|
|
234
243
|
unit: z.ZodOptional<z.ZodString>;
|
|
235
244
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -239,6 +248,15 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
|
|
|
239
248
|
numericValue?: number | undefined;
|
|
240
249
|
unit?: string | undefined;
|
|
241
250
|
}> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
251
|
+
numericValue: z.ZodNumber;
|
|
252
|
+
unit: z.ZodString;
|
|
253
|
+
}, "strip", z.ZodTypeAny, {
|
|
254
|
+
numericValue: number;
|
|
255
|
+
unit: string;
|
|
256
|
+
}, {
|
|
257
|
+
numericValue: number;
|
|
258
|
+
unit: string;
|
|
259
|
+
}>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
242
260
|
numericValue: z.ZodOptional<z.ZodNumber>;
|
|
243
261
|
unit: z.ZodOptional<z.ZodString>;
|
|
244
262
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -38,6 +38,7 @@ export declare const AgeUpdateValue: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
|
38
38
|
asOfDateRef: string;
|
|
39
39
|
}>>>;
|
|
40
40
|
export declare const TimeValue: z.ZodString;
|
|
41
|
+
export type TimeValue = z.infer<typeof TimeValue>;
|
|
41
42
|
export declare const DatetimeValue: z.ZodString;
|
|
42
43
|
export declare const SelectDateRangeValue: z.ZodEnum<["last7Days", "last30Days", "last90Days", "last365Days"]>;
|
|
43
44
|
export declare const DateRangeFieldValue: z.ZodUnion<[z.ZodObject<{
|
|
@@ -8,6 +8,7 @@ export declare function field(fieldId: string): {
|
|
|
8
8
|
type: "fuzzy";
|
|
9
9
|
options: {
|
|
10
10
|
boost?: number | undefined;
|
|
11
|
+
matchAgainst?: string | undefined;
|
|
11
12
|
fuzziness?: string | number | undefined;
|
|
12
13
|
} | undefined;
|
|
13
14
|
};
|
|
@@ -17,14 +18,57 @@ export declare function field(fieldId: string): {
|
|
|
17
18
|
options: {
|
|
18
19
|
value?: string | undefined;
|
|
19
20
|
boost?: number | undefined;
|
|
21
|
+
matchAgainst?: string | undefined;
|
|
20
22
|
} | undefined;
|
|
21
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Creates a date range matcher that finds records where date fields 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 across multiple fields 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 fields to match against. When provided,
|
|
35
|
+
* the query matches if any of these fields fall within the date range. The default field is always excluded in the search in that case.
|
|
36
|
+
* If you want to add the default field, you have to explicitly add that field in `matchAgainst` option
|
|
37
|
+
*
|
|
38
|
+
* @returns A clause that matches records where at least one of the specified date fields is within the range
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* // Matches only against mother.dob (±365 days)
|
|
42
|
+
* field('mother.dob').dateRangeMatches({ days: 365 })
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // Matches against mother.age OR spouse.dob, not mother.dob
|
|
46
|
+
* field('mother.dob').dateRangeMatches({
|
|
47
|
+
* days: 365,
|
|
48
|
+
* matchAgainst: [$field('mother.age'), $field('spouse.dob')]
|
|
49
|
+
* })
|
|
50
|
+
*
|
|
51
|
+
* If you want to add mother.dob, then
|
|
52
|
+
* field('mother.dob').dateRangeMatches({
|
|
53
|
+
* days: 365,
|
|
54
|
+
* matchAgainst: [$field('mother.age'), $field('spouse.dob'), $field('mother.dob')]
|
|
55
|
+
* })
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* // With custom pivot and boost
|
|
59
|
+
* field('mother.dob').dateRangeMatches({
|
|
60
|
+
* days: 730,
|
|
61
|
+
* pivot: 365,
|
|
62
|
+
* boost: 2
|
|
63
|
+
* })
|
|
64
|
+
*/
|
|
22
65
|
dateRangeMatches: (options: DateRangeMatcherOptions) => {
|
|
23
66
|
fieldId: string;
|
|
24
67
|
type: "dateRange";
|
|
25
68
|
options: {
|
|
26
69
|
days: number;
|
|
27
70
|
boost?: number | undefined;
|
|
71
|
+
matchAgainst?: string | undefined;
|
|
28
72
|
pivot?: number | undefined;
|
|
29
73
|
};
|
|
30
74
|
};
|
|
@@ -110,14 +110,10 @@ function omitKeyDeep(obj, keyToRemove) {
|
|
|
110
110
|
// ../commons/src/events/serializers/date/serializer.ts
|
|
111
111
|
var import_zod2 = require("zod");
|
|
112
112
|
var SerializedNowDateTime = import_zod2.z.object({
|
|
113
|
-
$$
|
|
114
|
-
$$time: import_zod2.z.literal("now").optional()
|
|
113
|
+
$$now: import_zod2.z.literal(true)
|
|
115
114
|
});
|
|
116
115
|
function todayDateTimeValueSerializer() {
|
|
117
|
-
return {
|
|
118
|
-
$$date: "now",
|
|
119
|
-
$$time: "now"
|
|
120
|
-
};
|
|
116
|
+
return { $$now: true };
|
|
121
117
|
}
|
|
122
118
|
|
|
123
119
|
// ../commons/src/conditionals/conditionals.ts
|
|
@@ -8,6 +8,7 @@ export declare function field(fieldId: string): {
|
|
|
8
8
|
type: "fuzzy";
|
|
9
9
|
options: {
|
|
10
10
|
boost?: number | undefined;
|
|
11
|
+
matchAgainst?: string | undefined;
|
|
11
12
|
fuzziness?: string | number | undefined;
|
|
12
13
|
} | undefined;
|
|
13
14
|
};
|
|
@@ -17,14 +18,57 @@ export declare function field(fieldId: string): {
|
|
|
17
18
|
options: {
|
|
18
19
|
value?: string | undefined;
|
|
19
20
|
boost?: number | undefined;
|
|
21
|
+
matchAgainst?: string | undefined;
|
|
20
22
|
} | undefined;
|
|
21
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Creates a date range matcher that finds records where date fields 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 across multiple fields 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 fields to match against. When provided,
|
|
35
|
+
* the query matches if any of these fields fall within the date range. The default field is always excluded in the search in that case.
|
|
36
|
+
* If you want to add the default field, you have to explicitly add that field in `matchAgainst` option
|
|
37
|
+
*
|
|
38
|
+
* @returns A clause that matches records where at least one of the specified date fields is within the range
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* // Matches only against mother.dob (±365 days)
|
|
42
|
+
* field('mother.dob').dateRangeMatches({ days: 365 })
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // Matches against mother.age OR spouse.dob, not mother.dob
|
|
46
|
+
* field('mother.dob').dateRangeMatches({
|
|
47
|
+
* days: 365,
|
|
48
|
+
* matchAgainst: [$field('mother.age'), $field('spouse.dob')]
|
|
49
|
+
* })
|
|
50
|
+
*
|
|
51
|
+
* If you want to add mother.dob, then
|
|
52
|
+
* field('mother.dob').dateRangeMatches({
|
|
53
|
+
* days: 365,
|
|
54
|
+
* matchAgainst: [$field('mother.age'), $field('spouse.dob'), $field('mother.dob')]
|
|
55
|
+
* })
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* // With custom pivot and boost
|
|
59
|
+
* field('mother.dob').dateRangeMatches({
|
|
60
|
+
* days: 730,
|
|
61
|
+
* pivot: 365,
|
|
62
|
+
* boost: 2
|
|
63
|
+
* })
|
|
64
|
+
*/
|
|
22
65
|
dateRangeMatches: (options: DateRangeMatcherOptions) => {
|
|
23
66
|
fieldId: string;
|
|
24
67
|
type: "dateRange";
|
|
25
68
|
options: {
|
|
26
69
|
days: number;
|
|
27
70
|
boost?: number | undefined;
|
|
71
|
+
matchAgainst?: string | undefined;
|
|
28
72
|
pivot?: number | undefined;
|
|
29
73
|
};
|
|
30
74
|
};
|
|
@@ -58,6 +58,47 @@ function field(fieldId) {
|
|
|
58
58
|
type: "strict",
|
|
59
59
|
options
|
|
60
60
|
}),
|
|
61
|
+
/**
|
|
62
|
+
* Creates a date range matcher that finds records where date fields fall within a specified range.
|
|
63
|
+
*
|
|
64
|
+
* By default, matches against the field specified in `field()` (e.g., 'mother.dob').
|
|
65
|
+
* When `matchAgainst` is provided, it overwrites the default field and searches across multiple fields with OR logic .
|
|
66
|
+
*
|
|
67
|
+
* @param options - Configuration for the date range matching
|
|
68
|
+
* @param options.days - Number of days before and after the target date to search (creates a ±days range)
|
|
69
|
+
* @param options.pivot - Optional. Distance in days where relevance scoring drops by 50%. Defaults to ⌊(days * 2) / 3⌋
|
|
70
|
+
* @param options.boost - Optional. Scoring boost multiplier for matching results. Defaults to 1
|
|
71
|
+
* @param options.matchAgainst - Optional. Additional fields to match against. When provided,
|
|
72
|
+
* the query matches if any of these fields fall within the date range. The default field is always excluded in the search in that case.
|
|
73
|
+
* If you want to add the default field, you have to explicitly add that field in `matchAgainst` option
|
|
74
|
+
*
|
|
75
|
+
* @returns A clause that matches records where at least one of the specified date fields is within the range
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* // Matches only against mother.dob (±365 days)
|
|
79
|
+
* field('mother.dob').dateRangeMatches({ days: 365 })
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* // Matches against mother.age OR spouse.dob, not mother.dob
|
|
83
|
+
* field('mother.dob').dateRangeMatches({
|
|
84
|
+
* days: 365,
|
|
85
|
+
* matchAgainst: [$field('mother.age'), $field('spouse.dob')]
|
|
86
|
+
* })
|
|
87
|
+
*
|
|
88
|
+
* If you want to add mother.dob, then
|
|
89
|
+
* field('mother.dob').dateRangeMatches({
|
|
90
|
+
* days: 365,
|
|
91
|
+
* matchAgainst: [$field('mother.age'), $field('spouse.dob'), $field('mother.dob')]
|
|
92
|
+
* })
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* // With custom pivot and boost
|
|
96
|
+
* field('mother.dob').dateRangeMatches({
|
|
97
|
+
* days: 730,
|
|
98
|
+
* pivot: 365,
|
|
99
|
+
* boost: 2
|
|
100
|
+
* })
|
|
101
|
+
*/
|
|
61
102
|
dateRangeMatches: (options) => ({
|
|
62
103
|
fieldId,
|
|
63
104
|
type: "dateRange",
|
package/dist/events/index.js
CHANGED
|
@@ -1909,14 +1909,10 @@ var SearchScopeAccessLevels = {
|
|
|
1909
1909
|
// ../commons/src/events/serializers/date/serializer.ts
|
|
1910
1910
|
var import_zod15 = require("zod");
|
|
1911
1911
|
var SerializedNowDateTime = import_zod15.z.object({
|
|
1912
|
-
$$
|
|
1913
|
-
$$time: import_zod15.z.literal("now").optional()
|
|
1912
|
+
$$now: import_zod15.z.literal(true)
|
|
1914
1913
|
});
|
|
1915
1914
|
function todayDateTimeValueSerializer() {
|
|
1916
|
-
return {
|
|
1917
|
-
$$date: "now",
|
|
1918
|
-
$$time: "now"
|
|
1919
|
-
};
|
|
1915
|
+
return { $$now: true };
|
|
1920
1916
|
}
|
|
1921
1917
|
|
|
1922
1918
|
// ../commons/src/events/FieldConfig.ts
|
|
@@ -2052,9 +2048,7 @@ var EmailField = BaseField.extend({
|
|
|
2052
2048
|
});
|
|
2053
2049
|
var DateField = BaseField.extend({
|
|
2054
2050
|
type: import_zod16.z.literal(FieldType.DATE),
|
|
2055
|
-
defaultValue: SerializedNowDateTime.
|
|
2056
|
-
$$date: "now"
|
|
2057
|
-
})).or(DateValue).optional().openapi({ effectType: "input", type: "object" }).describe("Default date value(yyyy-MM-dd)"),
|
|
2051
|
+
defaultValue: SerializedNowDateTime.or(DateValue).optional().openapi({ effectType: "input", type: "string" }).describe("Default date value(yyyy-MM-dd)"),
|
|
2058
2052
|
configuration: import_zod16.z.object({
|
|
2059
2053
|
notice: TranslationConfig.describe(
|
|
2060
2054
|
"Text to display above the date input"
|
|
@@ -2072,9 +2066,7 @@ var AgeField = BaseField.extend({
|
|
|
2072
2066
|
}).describe("An age input field which uses the current date as the asOfDate");
|
|
2073
2067
|
var TimeField = BaseField.extend({
|
|
2074
2068
|
type: import_zod16.z.literal(FieldType.TIME),
|
|
2075
|
-
defaultValue: SerializedNowDateTime.
|
|
2076
|
-
$$time: "now"
|
|
2077
|
-
})).or(TimeValue).optional().openapi({ effectType: "input", type: "object" }).describe("Default time value (HH-mm)"),
|
|
2069
|
+
defaultValue: SerializedNowDateTime.or(TimeValue).optional().openapi({ effectType: "input", type: "object" }).describe("Default time value (HH-mm)"),
|
|
2078
2070
|
configuration: import_zod16.z.object({
|
|
2079
2071
|
use12HourFormat: import_zod16.z.boolean().optional().describe("Whether to use 12-hour format"),
|
|
2080
2072
|
notice: TranslationConfig.describe(
|
|
@@ -2565,7 +2557,8 @@ var Matcher = import_zod19.z.object({
|
|
|
2565
2557
|
*/
|
|
2566
2558
|
fieldId: FieldReference2,
|
|
2567
2559
|
options: import_zod19.z.object({
|
|
2568
|
-
boost: import_zod19.z.number().optional()
|
|
2560
|
+
boost: import_zod19.z.number().optional(),
|
|
2561
|
+
matchAgainst: FieldReference2.optional()
|
|
2569
2562
|
}).optional().default({
|
|
2570
2563
|
boost: 1
|
|
2571
2564
|
})
|
|
@@ -2579,7 +2572,8 @@ var FuzzyMatcher = Matcher.extend({
|
|
|
2579
2572
|
* Names of length >7 characters = 2 edits allowed
|
|
2580
2573
|
*/
|
|
2581
2574
|
fuzziness: import_zod19.z.union([import_zod19.z.string(), import_zod19.z.number()]).optional().default("AUTO:4,7"),
|
|
2582
|
-
boost: import_zod19.z.number().optional().default(1)
|
|
2575
|
+
boost: import_zod19.z.number().optional().default(1),
|
|
2576
|
+
matchAgainst: FieldReference2.optional()
|
|
2583
2577
|
}).optional().default({
|
|
2584
2578
|
fuzziness: "AUTO:4,7",
|
|
2585
2579
|
boost: 1
|
|
@@ -2592,7 +2586,8 @@ var StrictMatcher = Matcher.extend({
|
|
|
2592
2586
|
/**
|
|
2593
2587
|
* The constant value to be present in the field for both records
|
|
2594
2588
|
*/
|
|
2595
|
-
value: import_zod19.z.string().optional()
|
|
2589
|
+
value: import_zod19.z.string().optional(),
|
|
2590
|
+
matchAgainst: FieldReference2.optional()
|
|
2596
2591
|
}).optional().default({
|
|
2597
2592
|
boost: 1
|
|
2598
2593
|
})
|
|
@@ -2606,7 +2601,8 @@ var DateRangeMatcher = Matcher.extend({
|
|
|
2606
2601
|
*/
|
|
2607
2602
|
pivot: import_zod19.z.number().optional(),
|
|
2608
2603
|
days: import_zod19.z.number(),
|
|
2609
|
-
boost: import_zod19.z.number().optional().default(1)
|
|
2604
|
+
boost: import_zod19.z.number().optional().default(1),
|
|
2605
|
+
matchAgainst: FieldReference2.optional()
|
|
2610
2606
|
})
|
|
2611
2607
|
});
|
|
2612
2608
|
var Not = import_zod19.z.object({
|
|
@@ -3017,7 +3013,7 @@ function mapFieldTypeToZod(field3, actionType) {
|
|
|
3017
3013
|
schema = NumberFieldValue;
|
|
3018
3014
|
break;
|
|
3019
3015
|
case FieldType.NUMBER_WITH_UNIT:
|
|
3020
|
-
schema = NumberWithUnitFieldUpdateValue;
|
|
3016
|
+
schema = field3.required ? NumberWithUnitFieldValue : NumberWithUnitFieldUpdateValue;
|
|
3021
3017
|
break;
|
|
3022
3018
|
case FieldType.CHECKBOX:
|
|
3023
3019
|
schema = CheckboxFieldValue;
|
|
@@ -3408,7 +3404,7 @@ function isFieldVisible(field3, form, context) {
|
|
|
3408
3404
|
}
|
|
3409
3405
|
function isFieldEmptyAndNotRequired(field3, form) {
|
|
3410
3406
|
const fieldValue = form[field3.id];
|
|
3411
|
-
return !field3.required && (fieldValue === void 0 || fieldValue === "");
|
|
3407
|
+
return !field3.required && (fieldValue === void 0 || fieldValue === "" || fieldValue && typeof fieldValue === "object" && Object.values(fieldValue).every((v) => v === void 0 || v === ""));
|
|
3412
3408
|
}
|
|
3413
3409
|
function isFieldEnabled(field3, form, context) {
|
|
3414
3410
|
return isFieldConditionMet(field3, form, ConditionalType.ENABLE, context);
|
|
@@ -7821,8 +7817,35 @@ var mother = defineFormPage({
|
|
|
7821
7817
|
secured: true,
|
|
7822
7818
|
validation: [],
|
|
7823
7819
|
label: generateTranslationConfig("Date of birth"),
|
|
7820
|
+
conditionals: [
|
|
7821
|
+
{
|
|
7822
|
+
type: "SHOW",
|
|
7823
|
+
conditional: not(field("mother.dobUnknown").isEqualTo(true))
|
|
7824
|
+
}
|
|
7825
|
+
]
|
|
7826
|
+
},
|
|
7827
|
+
{
|
|
7828
|
+
id: "mother.dobUnknown",
|
|
7829
|
+
type: "CHECKBOX",
|
|
7830
|
+
label: generateTranslationConfig("Exact date of birth unknown"),
|
|
7824
7831
|
conditionals: []
|
|
7825
7832
|
},
|
|
7833
|
+
{
|
|
7834
|
+
id: "mother.age",
|
|
7835
|
+
type: FieldType.AGE,
|
|
7836
|
+
required: true,
|
|
7837
|
+
analytics: true,
|
|
7838
|
+
label: generateTranslationConfig("Age of mother"),
|
|
7839
|
+
configuration: {
|
|
7840
|
+
asOfDate: field("child.dob")
|
|
7841
|
+
},
|
|
7842
|
+
conditionals: [
|
|
7843
|
+
{
|
|
7844
|
+
type: "SHOW",
|
|
7845
|
+
conditional: field("mother.dobUnknown").isEqualTo(true)
|
|
7846
|
+
}
|
|
7847
|
+
]
|
|
7848
|
+
},
|
|
7826
7849
|
{
|
|
7827
7850
|
id: "mother.idType",
|
|
7828
7851
|
type: FieldType.SELECT,
|
|
@@ -8907,8 +8930,7 @@ function isFieldValueWithoutTemplates(value) {
|
|
|
8907
8930
|
if (isTemplateVariable(value)) {
|
|
8908
8931
|
return false;
|
|
8909
8932
|
}
|
|
8910
|
-
if (typeof value === "object" && value !== null &&
|
|
8911
|
-
(Object.values(value).some((val) => isTemplateVariable(val)) || Object.keys(value).some((val) => isTemplateVariable(val)))) {
|
|
8933
|
+
if (typeof value === "object" && value !== null && Object.values(value).some((val) => isTemplateVariable(val))) {
|
|
8912
8934
|
return false;
|
|
8913
8935
|
}
|
|
8914
8936
|
return true;
|
|
@@ -1431,14 +1431,10 @@ var SearchQuery = import_zod14.z.object({
|
|
|
1431
1431
|
// ../commons/src/events/serializers/date/serializer.ts
|
|
1432
1432
|
var import_zod15 = require("zod");
|
|
1433
1433
|
var SerializedNowDateTime = import_zod15.z.object({
|
|
1434
|
-
$$
|
|
1435
|
-
$$time: import_zod15.z.literal("now").optional()
|
|
1434
|
+
$$now: import_zod15.z.literal(true)
|
|
1436
1435
|
});
|
|
1437
1436
|
function todayDateTimeValueSerializer() {
|
|
1438
|
-
return {
|
|
1439
|
-
$$date: "now",
|
|
1440
|
-
$$time: "now"
|
|
1441
|
-
};
|
|
1437
|
+
return { $$now: true };
|
|
1442
1438
|
}
|
|
1443
1439
|
|
|
1444
1440
|
// ../commons/src/events/FieldConfig.ts
|
|
@@ -1574,9 +1570,7 @@ var EmailField = BaseField.extend({
|
|
|
1574
1570
|
});
|
|
1575
1571
|
var DateField = BaseField.extend({
|
|
1576
1572
|
type: import_zod16.z.literal(FieldType.DATE),
|
|
1577
|
-
defaultValue: SerializedNowDateTime.
|
|
1578
|
-
$$date: "now"
|
|
1579
|
-
})).or(DateValue).optional().openapi({ effectType: "input", type: "object" }).describe("Default date value(yyyy-MM-dd)"),
|
|
1573
|
+
defaultValue: SerializedNowDateTime.or(DateValue).optional().openapi({ effectType: "input", type: "string" }).describe("Default date value(yyyy-MM-dd)"),
|
|
1580
1574
|
configuration: import_zod16.z.object({
|
|
1581
1575
|
notice: TranslationConfig.describe(
|
|
1582
1576
|
"Text to display above the date input"
|
|
@@ -1594,9 +1588,7 @@ var AgeField = BaseField.extend({
|
|
|
1594
1588
|
}).describe("An age input field which uses the current date as the asOfDate");
|
|
1595
1589
|
var TimeField = BaseField.extend({
|
|
1596
1590
|
type: import_zod16.z.literal(FieldType.TIME),
|
|
1597
|
-
defaultValue: SerializedNowDateTime.
|
|
1598
|
-
$$time: "now"
|
|
1599
|
-
})).or(TimeValue).optional().openapi({ effectType: "input", type: "object" }).describe("Default time value (HH-mm)"),
|
|
1591
|
+
defaultValue: SerializedNowDateTime.or(TimeValue).optional().openapi({ effectType: "input", type: "object" }).describe("Default time value (HH-mm)"),
|
|
1600
1592
|
configuration: import_zod16.z.object({
|
|
1601
1593
|
use12HourFormat: import_zod16.z.boolean().optional().describe("Whether to use 12-hour format"),
|
|
1602
1594
|
notice: TranslationConfig.describe(
|
|
@@ -2087,7 +2079,8 @@ var Matcher = import_zod19.z.object({
|
|
|
2087
2079
|
*/
|
|
2088
2080
|
fieldId: FieldReference2,
|
|
2089
2081
|
options: import_zod19.z.object({
|
|
2090
|
-
boost: import_zod19.z.number().optional()
|
|
2082
|
+
boost: import_zod19.z.number().optional(),
|
|
2083
|
+
matchAgainst: FieldReference2.optional()
|
|
2091
2084
|
}).optional().default({
|
|
2092
2085
|
boost: 1
|
|
2093
2086
|
})
|
|
@@ -2101,7 +2094,8 @@ var FuzzyMatcher = Matcher.extend({
|
|
|
2101
2094
|
* Names of length >7 characters = 2 edits allowed
|
|
2102
2095
|
*/
|
|
2103
2096
|
fuzziness: import_zod19.z.union([import_zod19.z.string(), import_zod19.z.number()]).optional().default("AUTO:4,7"),
|
|
2104
|
-
boost: import_zod19.z.number().optional().default(1)
|
|
2097
|
+
boost: import_zod19.z.number().optional().default(1),
|
|
2098
|
+
matchAgainst: FieldReference2.optional()
|
|
2105
2099
|
}).optional().default({
|
|
2106
2100
|
fuzziness: "AUTO:4,7",
|
|
2107
2101
|
boost: 1
|
|
@@ -2114,7 +2108,8 @@ var StrictMatcher = Matcher.extend({
|
|
|
2114
2108
|
/**
|
|
2115
2109
|
* The constant value to be present in the field for both records
|
|
2116
2110
|
*/
|
|
2117
|
-
value: import_zod19.z.string().optional()
|
|
2111
|
+
value: import_zod19.z.string().optional(),
|
|
2112
|
+
matchAgainst: FieldReference2.optional()
|
|
2118
2113
|
}).optional().default({
|
|
2119
2114
|
boost: 1
|
|
2120
2115
|
})
|
|
@@ -2128,7 +2123,8 @@ var DateRangeMatcher = Matcher.extend({
|
|
|
2128
2123
|
*/
|
|
2129
2124
|
pivot: import_zod19.z.number().optional(),
|
|
2130
2125
|
days: import_zod19.z.number(),
|
|
2131
|
-
boost: import_zod19.z.number().optional().default(1)
|
|
2126
|
+
boost: import_zod19.z.number().optional().default(1),
|
|
2127
|
+
matchAgainst: FieldReference2.optional()
|
|
2132
2128
|
})
|
|
2133
2129
|
});
|
|
2134
2130
|
var Not = import_zod19.z.object({
|
|
@@ -6074,8 +6070,35 @@ var mother = defineFormPage({
|
|
|
6074
6070
|
secured: true,
|
|
6075
6071
|
validation: [],
|
|
6076
6072
|
label: generateTranslationConfig("Date of birth"),
|
|
6073
|
+
conditionals: [
|
|
6074
|
+
{
|
|
6075
|
+
type: "SHOW",
|
|
6076
|
+
conditional: not(field("mother.dobUnknown").isEqualTo(true))
|
|
6077
|
+
}
|
|
6078
|
+
]
|
|
6079
|
+
},
|
|
6080
|
+
{
|
|
6081
|
+
id: "mother.dobUnknown",
|
|
6082
|
+
type: "CHECKBOX",
|
|
6083
|
+
label: generateTranslationConfig("Exact date of birth unknown"),
|
|
6077
6084
|
conditionals: []
|
|
6078
6085
|
},
|
|
6086
|
+
{
|
|
6087
|
+
id: "mother.age",
|
|
6088
|
+
type: FieldType.AGE,
|
|
6089
|
+
required: true,
|
|
6090
|
+
analytics: true,
|
|
6091
|
+
label: generateTranslationConfig("Age of mother"),
|
|
6092
|
+
configuration: {
|
|
6093
|
+
asOfDate: field("child.dob")
|
|
6094
|
+
},
|
|
6095
|
+
conditionals: [
|
|
6096
|
+
{
|
|
6097
|
+
type: "SHOW",
|
|
6098
|
+
conditional: field("mother.dobUnknown").isEqualTo(true)
|
|
6099
|
+
}
|
|
6100
|
+
]
|
|
6101
|
+
},
|
|
6079
6102
|
{
|
|
6080
6103
|
id: "mother.idType",
|
|
6081
6104
|
type: FieldType.SELECT,
|