@ecrvs/opencrvs-toolkit 1.8.1-rc.a7ee8fb
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/README.md +70 -0
- package/build.sh +56 -0
- package/dist/api/index.d.ts +11 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +52 -0
- package/dist/commons/api/router.d.ts +14568 -0
- package/dist/commons/conditionals/conditionals.d.ts +194 -0
- package/dist/commons/conditionals/index.d.ts +2 -0
- package/dist/commons/conditionals/validate.d.ts +129 -0
- package/dist/commons/events/ActionConfig.d.ts +2034 -0
- package/dist/commons/events/ActionDocument.d.ts +14400 -0
- package/dist/commons/events/ActionInput.d.ts +11157 -0
- package/dist/commons/events/ActionType.d.ts +52 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +1175 -0
- package/dist/commons/events/CompositeFieldValue.d.ts +181 -0
- package/dist/commons/events/Conditional.d.ts +55 -0
- package/dist/commons/events/Constants.d.ts +3 -0
- package/dist/commons/events/CountryConfigQueryInput.d.ts +4494 -0
- package/dist/commons/events/CreatedAtLocation.d.ts +2 -0
- package/dist/commons/events/DeduplicationConfig.d.ts +209 -0
- package/dist/commons/events/Draft.d.ts +814 -0
- package/dist/commons/events/EventConfig.d.ts +2237 -0
- package/dist/commons/events/EventConfigInput.d.ts +10 -0
- package/dist/commons/events/EventDocument.d.ts +8505 -0
- package/dist/commons/events/EventIndex.d.ts +3858 -0
- package/dist/commons/events/EventInput.d.ts +13 -0
- package/dist/commons/events/EventMetadata.d.ts +408 -0
- package/dist/commons/events/FieldConfig.d.ts +7125 -0
- package/dist/commons/events/FieldType.d.ts +46 -0
- package/dist/commons/events/FieldTypeMapping.d.ts +537 -0
- package/dist/commons/events/FieldValue.d.ts +250 -0
- package/dist/commons/events/FileUtils.d.ts +4 -0
- package/dist/commons/events/FormConfig.d.ts +725 -0
- package/dist/commons/events/PageConfig.d.ts +336 -0
- package/dist/commons/events/SummaryConfig.d.ts +170 -0
- package/dist/commons/events/TemplateConfig.d.ts +38 -0
- package/dist/commons/events/TranslationConfig.d.ts +15 -0
- package/dist/commons/events/User.d.ts +45 -0
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +53 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +8997 -0
- package/dist/commons/events/deduplication.d.ts +32 -0
- package/dist/commons/events/defineConfig.d.ts +309 -0
- package/dist/commons/events/event.d.ts +109 -0
- package/dist/commons/events/field.d.ts +151 -0
- package/dist/commons/events/index.d.ts +46 -0
- package/dist/commons/events/locations.d.ts +24 -0
- package/dist/commons/events/scopes.d.ts +55 -0
- package/dist/commons/events/serializer.d.ts +2 -0
- package/dist/commons/events/state/availableActions.d.ts +6 -0
- package/dist/commons/events/state/flags.d.ts +4 -0
- package/dist/commons/events/state/index.d.ts +146 -0
- package/dist/commons/events/state/utils.d.ts +1263 -0
- package/dist/commons/events/test.utils.d.ts +473 -0
- package/dist/commons/events/transactions.d.ts +2 -0
- package/dist/commons/events/utils.d.ts +501 -0
- package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
- package/dist/commons/notification/UserNotifications.d.ts +632 -0
- package/dist/commons/notification/index.d.ts +2 -0
- package/dist/conditionals/index.d.ts +2 -0
- package/dist/conditionals/index.d.ts.map +1 -0
- package/dist/conditionals/index.js +491 -0
- package/dist/events/deduplication.d.ts +32 -0
- package/dist/events/deduplication.d.ts.map +1 -0
- package/dist/events/deduplication.js +67 -0
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +8383 -0
- package/dist/notification/index.d.ts +2 -0
- package/dist/notification/index.d.ts.map +1 -0
- package/dist/notification/index.js +5928 -0
- package/dist/scopes/index.d.ts +335 -0
- package/dist/scopes/index.d.ts.map +1 -0
- package/dist/scopes/index.js +379 -0
- package/package.json +40 -0
- package/tsconfig.json +27 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/conditionals/index.ts
|
|
31
|
+
var conditionals_exports = {};
|
|
32
|
+
__export(conditionals_exports, {
|
|
33
|
+
alwaysTrue: () => alwaysTrue,
|
|
34
|
+
and: () => and,
|
|
35
|
+
createFieldConditionals: () => createFieldConditionals,
|
|
36
|
+
defineConditional: () => defineConditional,
|
|
37
|
+
defineFormConditional: () => defineFormConditional,
|
|
38
|
+
never: () => never,
|
|
39
|
+
not: () => not,
|
|
40
|
+
or: () => or,
|
|
41
|
+
user: () => user
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(conditionals_exports);
|
|
44
|
+
|
|
45
|
+
// ../commons/src/conditionals/conditionals.ts
|
|
46
|
+
var objectHash = __toESM(require("object-hash"));
|
|
47
|
+
|
|
48
|
+
// ../commons/src/events/serializers/user/serializer.ts
|
|
49
|
+
var import_zod = require("zod");
|
|
50
|
+
var SerializedUserField = import_zod.z.object({
|
|
51
|
+
$userField: import_zod.z.enum([
|
|
52
|
+
"id",
|
|
53
|
+
"name",
|
|
54
|
+
"role",
|
|
55
|
+
"signature",
|
|
56
|
+
"avatar",
|
|
57
|
+
"primaryOfficeId"
|
|
58
|
+
]),
|
|
59
|
+
$location: import_zod.z.string().optional()
|
|
60
|
+
});
|
|
61
|
+
function userSerializer(userField) {
|
|
62
|
+
return {
|
|
63
|
+
$userField: userField,
|
|
64
|
+
locationLevel(adminLevelId) {
|
|
65
|
+
return {
|
|
66
|
+
$userField: this.$userField,
|
|
67
|
+
$location: adminLevelId
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
toJSON() {
|
|
71
|
+
return {
|
|
72
|
+
$userField: userField
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// ../commons/src/utils.ts
|
|
79
|
+
var z2 = __toESM(require("zod"));
|
|
80
|
+
var FullNameV1 = z2.array(
|
|
81
|
+
z2.object({
|
|
82
|
+
use: z2.string(),
|
|
83
|
+
family: z2.string(),
|
|
84
|
+
given: z2.array(z2.string())
|
|
85
|
+
})
|
|
86
|
+
);
|
|
87
|
+
function omitKeyDeep(obj, keyToRemove) {
|
|
88
|
+
if (Array.isArray(obj)) {
|
|
89
|
+
return obj.map((item) => omitKeyDeep(item, keyToRemove));
|
|
90
|
+
}
|
|
91
|
+
if (obj === null || typeof obj !== "object") {
|
|
92
|
+
return obj;
|
|
93
|
+
}
|
|
94
|
+
const newObj = {};
|
|
95
|
+
for (const key of Object.keys(obj)) {
|
|
96
|
+
if (key !== keyToRemove) {
|
|
97
|
+
newObj[key] = omitKeyDeep(obj[key], keyToRemove);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return newObj;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// ../commons/src/conditionals/conditionals.ts
|
|
104
|
+
function defineConditional(schema) {
|
|
105
|
+
const schemaWithooutIDRef = omitKeyDeep(schema, "$id");
|
|
106
|
+
return {
|
|
107
|
+
$id: `https://opencrvs.org/conditionals/${objectHash.sha1(schemaWithooutIDRef)}`,
|
|
108
|
+
...schemaWithooutIDRef
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function defineFormConditional(schema) {
|
|
112
|
+
const schemaWithForm = {
|
|
113
|
+
type: "object",
|
|
114
|
+
properties: {
|
|
115
|
+
$form: schema
|
|
116
|
+
},
|
|
117
|
+
required: ["$form"]
|
|
118
|
+
};
|
|
119
|
+
return defineConditional(schemaWithForm);
|
|
120
|
+
}
|
|
121
|
+
function alwaysTrue() {
|
|
122
|
+
return {};
|
|
123
|
+
}
|
|
124
|
+
function and(...conditions) {
|
|
125
|
+
return defineConditional({
|
|
126
|
+
type: "object",
|
|
127
|
+
allOf: conditions,
|
|
128
|
+
required: []
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function or(...conditions) {
|
|
132
|
+
return defineConditional({
|
|
133
|
+
type: "object",
|
|
134
|
+
anyOf: conditions,
|
|
135
|
+
required: []
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function not(condition) {
|
|
139
|
+
return defineConditional({
|
|
140
|
+
type: "object",
|
|
141
|
+
not: condition,
|
|
142
|
+
required: []
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function never() {
|
|
146
|
+
return not(alwaysTrue());
|
|
147
|
+
}
|
|
148
|
+
function wrapToPath(condition, path) {
|
|
149
|
+
if (path.length === 0) {
|
|
150
|
+
return condition;
|
|
151
|
+
}
|
|
152
|
+
return path.reduceRight((conditionNow, part) => {
|
|
153
|
+
return {
|
|
154
|
+
type: "object",
|
|
155
|
+
properties: {
|
|
156
|
+
[part]: conditionNow
|
|
157
|
+
},
|
|
158
|
+
required: [part]
|
|
159
|
+
};
|
|
160
|
+
}, condition);
|
|
161
|
+
}
|
|
162
|
+
var user = Object.assign(userSerializer, {
|
|
163
|
+
hasScope: (scope) => defineConditional({
|
|
164
|
+
type: "object",
|
|
165
|
+
properties: {
|
|
166
|
+
$user: {
|
|
167
|
+
type: "object",
|
|
168
|
+
required: ["scope"],
|
|
169
|
+
properties: {
|
|
170
|
+
scope: {
|
|
171
|
+
type: "array",
|
|
172
|
+
contains: {
|
|
173
|
+
type: "string",
|
|
174
|
+
const: scope
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
required: ["$user"]
|
|
181
|
+
}),
|
|
182
|
+
isOnline: () => defineConditional({
|
|
183
|
+
type: "object",
|
|
184
|
+
properties: {
|
|
185
|
+
$online: {
|
|
186
|
+
type: "boolean",
|
|
187
|
+
const: true
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
required: ["$online"]
|
|
191
|
+
}),
|
|
192
|
+
locationLevel: (adminLevelId) => ({
|
|
193
|
+
$user: {
|
|
194
|
+
$location: adminLevelId
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
});
|
|
198
|
+
function getDateRangeToFieldReference(fieldId, comparedFieldId, clause) {
|
|
199
|
+
return {
|
|
200
|
+
type: "object",
|
|
201
|
+
properties: {
|
|
202
|
+
[fieldId]: {
|
|
203
|
+
type: "string",
|
|
204
|
+
format: "date",
|
|
205
|
+
[clause]: { $data: `1/${comparedFieldId}` }
|
|
206
|
+
},
|
|
207
|
+
[comparedFieldId]: { type: "string", format: "date" }
|
|
208
|
+
},
|
|
209
|
+
required: [fieldId]
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
function isFieldReference(value) {
|
|
213
|
+
return typeof value === "object" && value !== null && "$$field" in value;
|
|
214
|
+
}
|
|
215
|
+
function defineComparison(fieldId, value, keyword) {
|
|
216
|
+
if (isFieldReference(value)) {
|
|
217
|
+
const comparedFieldId = value.$$field;
|
|
218
|
+
return defineFormConditional({
|
|
219
|
+
type: "object",
|
|
220
|
+
properties: {
|
|
221
|
+
[fieldId]: {
|
|
222
|
+
type: ["number"],
|
|
223
|
+
[keyword]: { $data: `1/${comparedFieldId}` }
|
|
224
|
+
},
|
|
225
|
+
[comparedFieldId]: {
|
|
226
|
+
type: "number"
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
required: [fieldId, comparedFieldId]
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
return defineFormConditional({
|
|
233
|
+
type: "object",
|
|
234
|
+
properties: {
|
|
235
|
+
[fieldId]: {
|
|
236
|
+
type: "number",
|
|
237
|
+
[keyword]: value
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
required: [fieldId]
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
function createFieldConditionals(fieldId) {
|
|
244
|
+
const getDayRange = (days, clause) => ({
|
|
245
|
+
type: "object",
|
|
246
|
+
properties: {
|
|
247
|
+
[fieldId]: {
|
|
248
|
+
type: "string",
|
|
249
|
+
format: "date",
|
|
250
|
+
daysFromNow: {
|
|
251
|
+
days,
|
|
252
|
+
clause
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
required: [fieldId]
|
|
257
|
+
});
|
|
258
|
+
const getDateRange = (date, clause) => ({
|
|
259
|
+
type: "object",
|
|
260
|
+
properties: {
|
|
261
|
+
[fieldId]: {
|
|
262
|
+
type: "string",
|
|
263
|
+
format: "date",
|
|
264
|
+
[clause]: date
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
required: [fieldId]
|
|
268
|
+
});
|
|
269
|
+
return {
|
|
270
|
+
/**
|
|
271
|
+
* @private Internal property used for field reference tracking.
|
|
272
|
+
*/
|
|
273
|
+
$$field: fieldId,
|
|
274
|
+
/**
|
|
275
|
+
* @private Internal property used for solving a object path within field's value
|
|
276
|
+
*/
|
|
277
|
+
$$subfield: [],
|
|
278
|
+
get(fieldPath) {
|
|
279
|
+
return {
|
|
280
|
+
...this,
|
|
281
|
+
$$subfield: fieldPath.split(".")
|
|
282
|
+
};
|
|
283
|
+
},
|
|
284
|
+
isAfter: () => ({
|
|
285
|
+
days: (days) => ({
|
|
286
|
+
inPast: () => defineFormConditional(getDayRange(-days, "after")),
|
|
287
|
+
inFuture: () => defineFormConditional(getDayRange(days, "after"))
|
|
288
|
+
}),
|
|
289
|
+
date: (date) => {
|
|
290
|
+
if (isFieldReference(date)) {
|
|
291
|
+
const comparedFieldId = date.$$field;
|
|
292
|
+
return defineFormConditional(
|
|
293
|
+
getDateRangeToFieldReference(
|
|
294
|
+
fieldId,
|
|
295
|
+
comparedFieldId,
|
|
296
|
+
"formatMinimum"
|
|
297
|
+
)
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
return defineFormConditional(getDateRange(date, "formatMinimum"));
|
|
301
|
+
},
|
|
302
|
+
now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMinimum"))
|
|
303
|
+
}),
|
|
304
|
+
isBefore: () => ({
|
|
305
|
+
days: (days) => ({
|
|
306
|
+
inPast: () => defineFormConditional(getDayRange(days, "before")),
|
|
307
|
+
inFuture: () => defineFormConditional(getDayRange(-days, "before"))
|
|
308
|
+
}),
|
|
309
|
+
date: (date) => {
|
|
310
|
+
if (isFieldReference(date)) {
|
|
311
|
+
const comparedFieldId = date.$$field;
|
|
312
|
+
return defineFormConditional(
|
|
313
|
+
getDateRangeToFieldReference(
|
|
314
|
+
fieldId,
|
|
315
|
+
comparedFieldId,
|
|
316
|
+
"formatMaximum"
|
|
317
|
+
)
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
return defineFormConditional(getDateRange(date, "formatMaximum"));
|
|
321
|
+
},
|
|
322
|
+
now: () => defineFormConditional(getDateRange({ $data: "/$now" }, "formatMaximum"))
|
|
323
|
+
}),
|
|
324
|
+
isGreaterThan: (value) => defineComparison(fieldId, value, "exclusiveMinimum"),
|
|
325
|
+
isLessThan: (value) => defineComparison(fieldId, value, "exclusiveMaximum"),
|
|
326
|
+
isEqualTo(value) {
|
|
327
|
+
if (isFieldReference(value)) {
|
|
328
|
+
const comparedFieldId = value.$$field;
|
|
329
|
+
return defineFormConditional({
|
|
330
|
+
type: "object",
|
|
331
|
+
properties: {
|
|
332
|
+
[fieldId]: {
|
|
333
|
+
type: ["string", "boolean"],
|
|
334
|
+
const: { $data: `/$form/${comparedFieldId}` }
|
|
335
|
+
},
|
|
336
|
+
[comparedFieldId]: { type: ["string", "boolean"] }
|
|
337
|
+
},
|
|
338
|
+
required: [fieldId, comparedFieldId]
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
return defineFormConditional({
|
|
342
|
+
type: "object",
|
|
343
|
+
properties: {
|
|
344
|
+
[fieldId]: wrapToPath(
|
|
345
|
+
{
|
|
346
|
+
oneOf: [
|
|
347
|
+
{ type: "string", const: value },
|
|
348
|
+
{ type: "boolean", const: value }
|
|
349
|
+
],
|
|
350
|
+
const: value
|
|
351
|
+
},
|
|
352
|
+
this.$$subfield
|
|
353
|
+
)
|
|
354
|
+
},
|
|
355
|
+
required: [fieldId]
|
|
356
|
+
});
|
|
357
|
+
},
|
|
358
|
+
/**
|
|
359
|
+
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
|
360
|
+
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
|
361
|
+
* @returns whether the field is falsy (undefined, false, null, empty string)
|
|
362
|
+
*
|
|
363
|
+
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
|
364
|
+
*
|
|
365
|
+
*/
|
|
366
|
+
isFalsy() {
|
|
367
|
+
return defineFormConditional({
|
|
368
|
+
type: "object",
|
|
369
|
+
properties: {
|
|
370
|
+
[fieldId]: wrapToPath(
|
|
371
|
+
{
|
|
372
|
+
anyOf: [
|
|
373
|
+
{ const: "undefined" },
|
|
374
|
+
{ const: false },
|
|
375
|
+
{ const: null },
|
|
376
|
+
{ const: "" }
|
|
377
|
+
]
|
|
378
|
+
},
|
|
379
|
+
this.$$subfield
|
|
380
|
+
)
|
|
381
|
+
},
|
|
382
|
+
anyOf: [
|
|
383
|
+
{
|
|
384
|
+
required: [fieldId]
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
not: {
|
|
388
|
+
required: [fieldId]
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
]
|
|
392
|
+
});
|
|
393
|
+
},
|
|
394
|
+
isUndefined() {
|
|
395
|
+
return defineFormConditional({
|
|
396
|
+
type: "object",
|
|
397
|
+
properties: {
|
|
398
|
+
[fieldId]: wrapToPath(
|
|
399
|
+
{
|
|
400
|
+
type: "string",
|
|
401
|
+
enum: ["undefined"]
|
|
402
|
+
},
|
|
403
|
+
this.$$subfield
|
|
404
|
+
)
|
|
405
|
+
},
|
|
406
|
+
not: {
|
|
407
|
+
required: [fieldId]
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
},
|
|
411
|
+
inArray: (values) => defineFormConditional({
|
|
412
|
+
type: "object",
|
|
413
|
+
properties: {
|
|
414
|
+
[fieldId]: {
|
|
415
|
+
type: "string",
|
|
416
|
+
enum: values
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
required: [fieldId]
|
|
420
|
+
}),
|
|
421
|
+
isValidEnglishName: () => defineFormConditional({
|
|
422
|
+
type: "object",
|
|
423
|
+
properties: {
|
|
424
|
+
[fieldId]: {
|
|
425
|
+
type: "string",
|
|
426
|
+
minLength: 1,
|
|
427
|
+
pattern: "^[\\p{Script=Latin}0-9'.-]*(\\([\\p{Script=Latin}0-9'.-]+\\))?[\\p{Script=Latin}0-9'.-]*( [\\p{Script=Latin}0-9'.-]*(\\([\\p{Script=Latin}0-9'.-]+\\))?[\\p{Script=Latin}0-9'.-]*)*$",
|
|
428
|
+
description: "Name must contain only letters, numbers, and allowed special characters ('.-). No double spaces."
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}),
|
|
432
|
+
isValidAdministrativeLeafLevel: () => defineFormConditional({
|
|
433
|
+
type: "object",
|
|
434
|
+
properties: {
|
|
435
|
+
[fieldId]: {
|
|
436
|
+
type: "object",
|
|
437
|
+
properties: {
|
|
438
|
+
administrativeArea: {
|
|
439
|
+
type: "string",
|
|
440
|
+
isLeafLevelLocation: true
|
|
441
|
+
}
|
|
442
|
+
},
|
|
443
|
+
description: "The provided administrative value should have a value corresponding to the required lowest administrative level"
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}),
|
|
447
|
+
/**
|
|
448
|
+
* Checks if the field value matches a given regular expression pattern.
|
|
449
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
|
450
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
|
451
|
+
*/
|
|
452
|
+
matches: (pattern) => defineFormConditional({
|
|
453
|
+
type: "object",
|
|
454
|
+
properties: {
|
|
455
|
+
[fieldId]: {
|
|
456
|
+
type: "string",
|
|
457
|
+
pattern
|
|
458
|
+
}
|
|
459
|
+
},
|
|
460
|
+
required: [fieldId]
|
|
461
|
+
}),
|
|
462
|
+
isBetween: (min, max) => defineFormConditional({
|
|
463
|
+
type: "object",
|
|
464
|
+
properties: {
|
|
465
|
+
[fieldId]: {
|
|
466
|
+
type: "number",
|
|
467
|
+
minimum: min,
|
|
468
|
+
maximum: max
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
required: [fieldId]
|
|
472
|
+
}),
|
|
473
|
+
getId: () => ({ fieldId }),
|
|
474
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
475
|
+
object: (options) => defineFormConditional({
|
|
476
|
+
type: "object",
|
|
477
|
+
properties: {
|
|
478
|
+
[fieldId]: {
|
|
479
|
+
type: "object",
|
|
480
|
+
properties: Object.fromEntries(
|
|
481
|
+
Object.entries(options).map(([key, value]) => {
|
|
482
|
+
return [key, value.properties.$form.properties[key]];
|
|
483
|
+
})
|
|
484
|
+
),
|
|
485
|
+
required: Object.keys(options)
|
|
486
|
+
}
|
|
487
|
+
},
|
|
488
|
+
required: [fieldId]
|
|
489
|
+
})
|
|
490
|
+
};
|
|
491
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
fuzziness?: string | number | undefined;
|
|
12
|
+
} | undefined;
|
|
13
|
+
};
|
|
14
|
+
strictMatches: (options?: StrictMatcherOptions) => {
|
|
15
|
+
fieldId: string;
|
|
16
|
+
type: "strict";
|
|
17
|
+
options: {
|
|
18
|
+
value?: string | undefined;
|
|
19
|
+
boost?: number | undefined;
|
|
20
|
+
} | undefined;
|
|
21
|
+
};
|
|
22
|
+
dateRangeMatches: (options: DateRangeMatcherOptions) => {
|
|
23
|
+
fieldId: string;
|
|
24
|
+
type: "dateRange";
|
|
25
|
+
options: {
|
|
26
|
+
days: number;
|
|
27
|
+
boost?: number | undefined;
|
|
28
|
+
pivot?: number | undefined;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=deduplication.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deduplication.d.ts","sourceRoot":"","sources":["../../src/events/deduplication.ts"],"names":[],"mappings":"AAUA,cAAc,wCAAwC,CAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/events/deduplication.ts
|
|
21
|
+
var deduplication_exports = {};
|
|
22
|
+
__export(deduplication_exports, {
|
|
23
|
+
and: () => and,
|
|
24
|
+
field: () => field,
|
|
25
|
+
not: () => not,
|
|
26
|
+
or: () => or
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(deduplication_exports);
|
|
29
|
+
|
|
30
|
+
// ../commons/src/events/deduplication.ts
|
|
31
|
+
function not(clause) {
|
|
32
|
+
return {
|
|
33
|
+
type: "not",
|
|
34
|
+
clause
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function and(...clauses) {
|
|
38
|
+
return {
|
|
39
|
+
type: "and",
|
|
40
|
+
clauses
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function or(...clauses) {
|
|
44
|
+
return {
|
|
45
|
+
type: "or",
|
|
46
|
+
clauses
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function field(fieldId) {
|
|
50
|
+
return {
|
|
51
|
+
fuzzyMatches: (options) => ({
|
|
52
|
+
fieldId,
|
|
53
|
+
type: "fuzzy",
|
|
54
|
+
options
|
|
55
|
+
}),
|
|
56
|
+
strictMatches: (options) => ({
|
|
57
|
+
fieldId,
|
|
58
|
+
type: "strict",
|
|
59
|
+
options
|
|
60
|
+
}),
|
|
61
|
+
dateRangeMatches: (options) => ({
|
|
62
|
+
fieldId,
|
|
63
|
+
type: "dateRange",
|
|
64
|
+
options
|
|
65
|
+
})
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAUA,cAAc,0BAA0B,CAAA"}
|