@opencrvs/toolkit 2.1.0-rc.f29a266 → 2.1.0-rc.f5ea803
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/build.sh +9 -1
- package/create-countryconfig/index.js +176 -2
- package/dist/application-config/index.js +211 -201
- package/dist/authentication/index.d.ts +67 -0
- package/dist/authentication/index.d.ts.map +1 -0
- package/dist/authentication/index.js +750 -0
- package/dist/cli.js +1587 -69
- package/dist/commons/api/router.d.ts +4 -4
- package/dist/commons/conditionals/conditionals.d.ts +3 -3
- package/dist/commons/events/AdvancedSearchConfig.d.ts +6 -0
- package/dist/commons/events/EventDocument.d.ts +468 -0
- package/dist/commons/events/EventMetadata.d.ts +1 -11
- package/dist/commons/events/EventStatus.d.ts +19 -0
- package/dist/commons/events/FieldConfig.d.ts +5 -0
- package/dist/commons/events/FieldTypeMapping.d.ts +15 -15
- package/dist/commons/events/locations.d.ts +2 -2
- package/dist/commons/notification/UserNotifications.d.ts +0 -13
- package/dist/commons/notification/dispatch.d.ts +10 -0
- package/dist/commons/notification/index.d.ts +1 -0
- package/dist/conditionals/index.js +74 -57
- package/dist/csv.d.ts +25 -0
- package/dist/csv.d.ts.map +1 -0
- package/dist/csv.js +120 -0
- package/dist/events/index.js +760 -743
- package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
- package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
- package/dist/migrations/v2.1/add-recovery-link-notifications.js +511 -0
- package/dist/migrations/v2.1/add-translations.d.ts +9 -0
- package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
- package/dist/migrations/v2.1/add-translations.js +213 -0
- package/dist/migrations/v2.1/enable-telemetry.d.ts +3 -0
- package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
- package/dist/migrations/v2.1/enable-telemetry.js +438 -0
- package/dist/migrations/v2.1/index.d.ts.map +1 -1
- package/dist/migrations/v2.1/index.js +1058 -0
- package/dist/notification/index.js +855 -815
- package/dist/scopes/index.d.ts +74 -6
- package/dist/scopes/index.js +74 -57
- package/dist/telemetry/index.d.ts +45 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +39 -0
- package/dist/translations/check.d.ts +19 -0
- package/dist/translations/check.d.ts.map +1 -0
- package/dist/translations/check.js +127 -0
- package/dist/verify/endpoints.d.ts +2 -0
- package/dist/verify/endpoints.d.ts.map +1 -0
- package/dist/verify/endpoints.js +345 -0
- package/opencrvs-toolkit-2.1.0-rc.f5ea803.tgz +0 -0
- package/package.json +8 -3
- package/tsconfig.build.json +11 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +3 -0
- package/opencrvs-toolkit-2.1.0-rc.f29a266.tgz +0 -0
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1931,6 +1931,7 @@ declare const AdministrativeAreaField: z.ZodObject<{
|
|
|
1931
1931
|
registeredBy: "registeredBy";
|
|
1932
1932
|
registeredIn: "registeredIn";
|
|
1933
1933
|
role: "role";
|
|
1934
|
+
status: "status";
|
|
1934
1935
|
}>;
|
|
1935
1936
|
}, z.core.$strip>]>;
|
|
1936
1937
|
}, z.core.$strip>>;
|
|
@@ -2066,6 +2067,7 @@ declare const LocationInput: z.ZodObject<{
|
|
|
2066
2067
|
registeredBy: "registeredBy";
|
|
2067
2068
|
registeredIn: "registeredIn";
|
|
2068
2069
|
role: "role";
|
|
2070
|
+
status: "status";
|
|
2069
2071
|
}>;
|
|
2070
2072
|
}, z.core.$strip>]>;
|
|
2071
2073
|
}, z.core.$strip>>;
|
|
@@ -2272,6 +2274,7 @@ declare const Facility: z.ZodObject<{
|
|
|
2272
2274
|
registeredBy: "registeredBy";
|
|
2273
2275
|
registeredIn: "registeredIn";
|
|
2274
2276
|
role: "role";
|
|
2277
|
+
status: "status";
|
|
2275
2278
|
}>;
|
|
2276
2279
|
}, z.core.$strip>]>;
|
|
2277
2280
|
}, z.core.$strip>>;
|
|
@@ -2393,6 +2396,7 @@ declare const Office: z.ZodObject<{
|
|
|
2393
2396
|
registeredBy: "registeredBy";
|
|
2394
2397
|
registeredIn: "registeredIn";
|
|
2395
2398
|
role: "role";
|
|
2399
|
+
status: "status";
|
|
2396
2400
|
}>;
|
|
2397
2401
|
}, z.core.$strip>]>;
|
|
2398
2402
|
}, z.core.$strip>>;
|
|
@@ -2600,6 +2604,7 @@ declare const Address: z.ZodObject<{
|
|
|
2600
2604
|
registeredBy: "registeredBy";
|
|
2601
2605
|
registeredIn: "registeredIn";
|
|
2602
2606
|
role: "role";
|
|
2607
|
+
status: "status";
|
|
2603
2608
|
}>;
|
|
2604
2609
|
}, z.core.$strip>]>;
|
|
2605
2610
|
}, z.core.$strip>>;
|
|
@@ -29,15 +29,11 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
|
|
|
29
29
|
}> | z.ZodNumber | z.ZodObject<Readonly<{
|
|
30
30
|
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
31
31
|
}>, z.core.$strip> | z.ZodObject<{
|
|
32
|
-
age: z.ZodNumber;
|
|
33
|
-
asOfDateRef: z.ZodString;
|
|
34
|
-
}, z.core.$strip> | z.ZodObject<{
|
|
35
|
-
label: z.ZodString;
|
|
36
|
-
value: z.ZodString;
|
|
37
|
-
}, z.core.$strip> | z.ZodObject<{
|
|
38
32
|
path: z.core.$ZodBranded<z.ZodString, "DocumentPath", "out">;
|
|
39
33
|
originalFilename: z.ZodString;
|
|
40
34
|
type: z.ZodString;
|
|
35
|
+
}, z.core.$strip> | z.ZodObject<{
|
|
36
|
+
data: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
41
37
|
}, z.core.$strip> | z.ZodObject<{
|
|
42
38
|
data: z.ZodAny;
|
|
43
39
|
}, z.core.$strip> | z.ZodObject<{
|
|
@@ -47,7 +43,11 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
|
|
|
47
43
|
numericValue: z.ZodOptional<z.ZodNumber>;
|
|
48
44
|
unit: z.ZodOptional<z.ZodString>;
|
|
49
45
|
}, z.core.$strip> | z.ZodObject<{
|
|
50
|
-
|
|
46
|
+
age: z.ZodNumber;
|
|
47
|
+
asOfDateRef: z.ZodString;
|
|
48
|
+
}, z.core.$strip> | z.ZodObject<{
|
|
49
|
+
label: z.ZodString;
|
|
50
|
+
value: z.ZodString;
|
|
51
51
|
}, z.core.$strip> | z.ZodObject<{
|
|
52
52
|
firstname: z.ZodString;
|
|
53
53
|
surname: z.ZodString;
|
|
@@ -65,15 +65,11 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
|
|
|
65
65
|
}>>> | z.ZodOptional<z.ZodNullable<z.ZodNumber>> | z.ZodOptional<z.ZodNullable<z.ZodObject<Readonly<{
|
|
66
66
|
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
67
67
|
}>, z.core.$strip>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
68
|
-
age: z.ZodNumber;
|
|
69
|
-
asOfDateRef: z.ZodString;
|
|
70
|
-
}, z.core.$strip>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
71
|
-
label: z.ZodString;
|
|
72
|
-
value: z.ZodString;
|
|
73
|
-
}, z.core.$strip>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
74
68
|
path: z.core.$ZodBranded<z.ZodString, "DocumentPath", "out">;
|
|
75
69
|
originalFilename: z.ZodString;
|
|
76
70
|
type: z.ZodString;
|
|
71
|
+
}, z.core.$strip>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
72
|
+
data: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
77
73
|
}, z.core.$strip>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
78
74
|
data: z.ZodAny;
|
|
79
75
|
}, z.core.$strip>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
@@ -82,6 +78,12 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
|
|
|
82
78
|
}, z.core.$strip>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
83
79
|
numericValue: z.ZodOptional<z.ZodNumber>;
|
|
84
80
|
unit: z.ZodOptional<z.ZodString>;
|
|
81
|
+
}, z.core.$strip>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
82
|
+
age: z.ZodNumber;
|
|
83
|
+
asOfDateRef: z.ZodString;
|
|
84
|
+
}, z.core.$strip>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
85
|
+
label: z.ZodString;
|
|
86
|
+
value: z.ZodString;
|
|
85
87
|
}, z.core.$strip>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
86
88
|
data: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
87
89
|
country: z.ZodString;
|
|
@@ -152,8 +154,6 @@ export declare function mapFieldTypeToZod(field: FieldConfig, actionType?: Actio
|
|
|
152
154
|
label: z.ZodString;
|
|
153
155
|
value: z.ZodString;
|
|
154
156
|
}, z.core.$strip>>>]>>;
|
|
155
|
-
}, z.core.$strip>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
156
|
-
data: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
157
157
|
}, z.core.$strip>>> | z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
158
158
|
firstname: z.ZodString;
|
|
159
159
|
surname: z.ZodString;
|
|
@@ -247,7 +247,7 @@ export type EventIndexWithAdministrativeHierarchy = Omit<ToArrayFields<EventInde
|
|
|
247
247
|
* Return false early to break out of checks as soon as possible - if any option is not satisfied, the scope does not allow access to the event, so no need to check further options.
|
|
248
248
|
*
|
|
249
249
|
*/
|
|
250
|
-
export declare function canAccessEventWithScope(event:
|
|
250
|
+
export declare function canAccessEventWithScope(event: EventIndexWithAdministrativeHierarchy, scope: RecordScopeV2, user: UserContext | SystemContext, customActionType?: string): boolean;
|
|
251
251
|
export type UserWithResolvedHierarchy = {
|
|
252
252
|
role: string;
|
|
253
253
|
administrativeHierarchy: UUID[];
|
|
@@ -268,7 +268,7 @@ export declare function canAccessOtherUserWithScopes({ scopes, userToAccess, use
|
|
|
268
268
|
*
|
|
269
269
|
* One of the scopes must allow access for the event to be accessible.
|
|
270
270
|
*/
|
|
271
|
-
export declare function userCanAccessEventWithScopes(event:
|
|
271
|
+
export declare function userCanAccessEventWithScopes(event: EventIndexWithAdministrativeHierarchy, scopes: RecordScopeV2[], user: UserContext | SystemContext, customActionType?: string): boolean;
|
|
272
272
|
export declare function getAdministrativeAreaHierarchy<A extends {
|
|
273
273
|
id: UUID;
|
|
274
274
|
parentId: UUID | null;
|
|
@@ -212,18 +212,5 @@ export declare const TriggerPayload: {
|
|
|
212
212
|
export type TriggerPayload = {
|
|
213
213
|
[K in TriggerEvent]: z.infer<(typeof TriggerPayload)[K]>;
|
|
214
214
|
};
|
|
215
|
-
export declare function triggerUserEventNotification(args: {
|
|
216
|
-
event: typeof TriggerEvent.ALL_USER_NOTIFICATION;
|
|
217
|
-
payload: TriggerPayload[typeof TriggerEvent.ALL_USER_NOTIFICATION];
|
|
218
|
-
countryConfigUrl: string;
|
|
219
|
-
}): Promise<Response>;
|
|
220
|
-
export declare function triggerUserEventNotification<T extends Exclude<TriggerEvent, typeof TriggerEvent.ALL_USER_NOTIFICATION>>(args: {
|
|
221
|
-
event: T;
|
|
222
|
-
payload: TriggerPayload[T];
|
|
223
|
-
countryConfigUrl: string;
|
|
224
|
-
authHeader: {
|
|
225
|
-
Authorization: string;
|
|
226
|
-
};
|
|
227
|
-
}): Promise<Response>;
|
|
228
215
|
export declare function parseUserEventTrigger<T extends TriggerEvent>(event: T, body: unknown): TriggerPayload[T];
|
|
229
216
|
//# sourceMappingURL=UserNotifications.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TriggerEvent, TriggerPayload } from './UserNotifications';
|
|
2
|
+
export declare function triggerUserEventNotification<T extends TriggerEvent>({ event, payload, countryConfigUrl, authHeader }: {
|
|
3
|
+
event: T;
|
|
4
|
+
payload: TriggerPayload[T];
|
|
5
|
+
countryConfigUrl: string;
|
|
6
|
+
authHeader: {
|
|
7
|
+
Authorization: string;
|
|
8
|
+
};
|
|
9
|
+
}): Promise<Response>;
|
|
10
|
+
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -47,7 +47,7 @@ __export(conditionals_exports, {
|
|
|
47
47
|
user: () => user
|
|
48
48
|
});
|
|
49
49
|
module.exports = __toCommonJS(conditionals_exports);
|
|
50
|
-
var
|
|
50
|
+
var z13 = __toESM(require("zod/v4"));
|
|
51
51
|
|
|
52
52
|
// ../commons/src/conditionals/conditionals.ts
|
|
53
53
|
var objectHash = __toESM(require("object-hash"));
|
|
@@ -124,7 +124,7 @@ function todayDateTimeValueSerializer() {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
// ../commons/src/scopes.ts
|
|
127
|
-
var
|
|
127
|
+
var z11 = __toESM(require("zod/v4"));
|
|
128
128
|
var qs = __toESM(require("qs"));
|
|
129
129
|
|
|
130
130
|
// ../commons/src/uuid.ts
|
|
@@ -383,12 +383,22 @@ var ActionFlagConfig = z9.object({
|
|
|
383
383
|
description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
|
|
384
384
|
});
|
|
385
385
|
|
|
386
|
+
// ../commons/src/events/EventStatus.ts
|
|
387
|
+
var z10 = __toESM(require("zod/v4"));
|
|
388
|
+
var EventStatus = z10.enum([
|
|
389
|
+
"CREATED",
|
|
390
|
+
"NOTIFIED",
|
|
391
|
+
"DECLARED",
|
|
392
|
+
"REGISTERED",
|
|
393
|
+
"ARCHIVED"
|
|
394
|
+
]);
|
|
395
|
+
|
|
386
396
|
// ../commons/src/scopes.ts
|
|
387
|
-
var JurisdictionFilter =
|
|
397
|
+
var JurisdictionFilter = z11.enum(["administrativeArea", "location", "all"]).describe(
|
|
388
398
|
"Filters based on user jurisdiction relative to their office location in hierarchy."
|
|
389
399
|
);
|
|
390
|
-
var UserFilter =
|
|
391
|
-
var RecordScopeTypeV2 =
|
|
400
|
+
var UserFilter = z11.enum(["user"]).describe("Filters based on the user. Limits to self.");
|
|
401
|
+
var RecordScopeTypeV2 = z11.enum([
|
|
392
402
|
"record.search",
|
|
393
403
|
"record.create",
|
|
394
404
|
"record.read",
|
|
@@ -406,7 +416,7 @@ var RecordScopeTypeV2 = z10.enum([
|
|
|
406
416
|
"record.unassign-others",
|
|
407
417
|
"record.custom-action"
|
|
408
418
|
]);
|
|
409
|
-
var PlainScopeType =
|
|
419
|
+
var PlainScopeType = z11.enum([
|
|
410
420
|
// Misc. system scopes
|
|
411
421
|
"bypassratelimit",
|
|
412
422
|
"record.reindex",
|
|
@@ -431,15 +441,21 @@ var PlainScopeType = z10.enum([
|
|
|
431
441
|
"record.confirm-registration",
|
|
432
442
|
"record.reject-registration"
|
|
433
443
|
]);
|
|
434
|
-
var scopeByEvent =
|
|
444
|
+
var scopeByEvent = z11.preprocess(
|
|
435
445
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
436
|
-
|
|
446
|
+
z11.array(z11.string()).optional()
|
|
437
447
|
).describe("Event type, e.g. birth, death");
|
|
438
|
-
var
|
|
448
|
+
var scopeByStatus = z11.preprocess(
|
|
439
449
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
440
|
-
|
|
450
|
+
z11.array(EventStatus).optional()
|
|
451
|
+
).describe(
|
|
452
|
+
"Restricts the scope to records currently in one of these statuses."
|
|
453
|
+
);
|
|
454
|
+
var userRole = z11.preprocess(
|
|
455
|
+
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
456
|
+
z11.array(z11.string()).optional()
|
|
441
457
|
).describe("User role, e.g. admin, field agent");
|
|
442
|
-
var scopeOptionsPlaceEvent =
|
|
458
|
+
var scopeOptionsPlaceEvent = z11.object({
|
|
443
459
|
event: scopeByEvent,
|
|
444
460
|
placeOfEvent: JurisdictionFilter.optional()
|
|
445
461
|
}).describe("Options applicable to all record scopes.");
|
|
@@ -447,7 +463,8 @@ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
|
|
|
447
463
|
notifiedIn: JurisdictionFilter.optional(),
|
|
448
464
|
notifiedBy: UserFilter.optional(),
|
|
449
465
|
declaredIn: JurisdictionFilter.optional(),
|
|
450
|
-
declaredBy: UserFilter.optional()
|
|
466
|
+
declaredBy: UserFilter.optional(),
|
|
467
|
+
status: scopeByStatus
|
|
451
468
|
}).describe("Options applicable to actions that may take place after DECLARE");
|
|
452
469
|
var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
|
|
453
470
|
registeredIn: JurisdictionFilter.optional(),
|
|
@@ -457,31 +474,31 @@ var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
|
|
|
457
474
|
"Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
|
|
458
475
|
);
|
|
459
476
|
var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
460
|
-
customActionTypes:
|
|
477
|
+
customActionTypes: z11.preprocess(
|
|
461
478
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
462
|
-
|
|
479
|
+
z11.array(z11.string()).optional()
|
|
463
480
|
).describe("Allowed custom action types")
|
|
464
481
|
});
|
|
465
|
-
var AccessLevelOptions =
|
|
482
|
+
var AccessLevelOptions = z11.object({
|
|
466
483
|
accessLevel: JurisdictionFilter.optional()
|
|
467
484
|
});
|
|
468
485
|
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
469
486
|
role: userRole.optional()
|
|
470
487
|
});
|
|
471
|
-
var WorkqueueOrDashboardOptions =
|
|
472
|
-
ids:
|
|
488
|
+
var WorkqueueOrDashboardOptions = z11.object({
|
|
489
|
+
ids: z11.preprocess(
|
|
473
490
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
474
|
-
|
|
491
|
+
z11.array(z11.string())
|
|
475
492
|
).describe("Must contain a list of workqueue or dashboard ids.")
|
|
476
493
|
});
|
|
477
|
-
var AllScopeOptions =
|
|
494
|
+
var AllScopeOptions = z11.object({
|
|
478
495
|
...AllRecordScopeOptions.shape,
|
|
479
496
|
...AccessLevelOptions.shape,
|
|
480
497
|
...AllUserScopeOptions.shape,
|
|
481
498
|
...WorkqueueOrDashboardOptions.shape
|
|
482
499
|
});
|
|
483
500
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
484
|
-
var ResolvedScopeOptionsPlaceEvent =
|
|
501
|
+
var ResolvedScopeOptionsPlaceEvent = z11.object({
|
|
485
502
|
event: scopeByEvent,
|
|
486
503
|
placeOfEvent: UUID.nullish()
|
|
487
504
|
}).describe(
|
|
@@ -489,15 +506,15 @@ var ResolvedScopeOptionsPlaceEvent = z10.object({
|
|
|
489
506
|
);
|
|
490
507
|
var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
|
|
491
508
|
notifiedIn: UUID.nullish(),
|
|
492
|
-
notifiedBy:
|
|
509
|
+
notifiedBy: z11.string().optional(),
|
|
493
510
|
declaredIn: UUID.nullish(),
|
|
494
|
-
declaredBy:
|
|
511
|
+
declaredBy: z11.string().optional()
|
|
495
512
|
}).describe(
|
|
496
513
|
"Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
|
|
497
514
|
);
|
|
498
515
|
var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
|
|
499
516
|
registeredIn: UUID.nullish(),
|
|
500
|
-
registeredBy:
|
|
517
|
+
registeredBy: z11.string().optional(),
|
|
501
518
|
flags: ContainsFlags.optional()
|
|
502
519
|
}).describe(
|
|
503
520
|
"Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
|
|
@@ -512,7 +529,6 @@ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
|
|
|
512
529
|
"record.reject",
|
|
513
530
|
"record.archive",
|
|
514
531
|
"record.unarchive",
|
|
515
|
-
"record.review-duplicates",
|
|
516
532
|
"record.register"
|
|
517
533
|
]);
|
|
518
534
|
var ScopesWithFullOptions = RecordScopeTypeV2.extract([
|
|
@@ -520,41 +536,42 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
|
|
|
520
536
|
"record.read",
|
|
521
537
|
"record.request-correction",
|
|
522
538
|
"record.correct",
|
|
523
|
-
"record.unassign-others"
|
|
539
|
+
"record.unassign-others",
|
|
540
|
+
"record.review-duplicates"
|
|
524
541
|
]);
|
|
525
542
|
var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
|
|
526
|
-
templates:
|
|
543
|
+
templates: z11.preprocess(
|
|
527
544
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
528
|
-
|
|
545
|
+
z11.array(z11.string()).optional()
|
|
529
546
|
).describe(
|
|
530
547
|
"Template IDs for certified copies. Controls which certificate templates are returned to the client via the config service. Certificate printing is a client-side operation \u2014 this option is not validated when the printCertificate action is submitted."
|
|
531
548
|
)
|
|
532
549
|
});
|
|
533
|
-
var RecordScopeV2 =
|
|
534
|
-
|
|
550
|
+
var RecordScopeV2 = z11.discriminatedUnion("type", [
|
|
551
|
+
z11.object({
|
|
535
552
|
type: ScopesWithPlaceEventOptions,
|
|
536
553
|
options: scopeOptionsPlaceEvent.optional()
|
|
537
554
|
}),
|
|
538
|
-
|
|
555
|
+
z11.object({
|
|
539
556
|
type: ScopesWithDeclaredOptions,
|
|
540
557
|
options: scopeOptionsDeclaredOrNotified.optional()
|
|
541
558
|
}),
|
|
542
|
-
|
|
559
|
+
z11.object({
|
|
543
560
|
type: ScopesWithFullOptions,
|
|
544
561
|
options: AllRecordScopeOptions.optional()
|
|
545
562
|
}),
|
|
546
|
-
|
|
547
|
-
type:
|
|
563
|
+
z11.object({
|
|
564
|
+
type: z11.literal("record.custom-action"),
|
|
548
565
|
options: CustomActionScopeOptions.optional()
|
|
549
566
|
}),
|
|
550
|
-
|
|
551
|
-
type:
|
|
567
|
+
z11.object({
|
|
568
|
+
type: z11.literal("record.print-certified-copies"),
|
|
552
569
|
options: ScopeOptionsPrintCertifiedCopies.optional()
|
|
553
570
|
})
|
|
554
571
|
]).describe(
|
|
555
572
|
"Scopes used to check user's permission to perform actions on a record."
|
|
556
573
|
);
|
|
557
|
-
var SystemScopeType =
|
|
574
|
+
var SystemScopeType = z11.enum([
|
|
558
575
|
"organisation.read-locations",
|
|
559
576
|
"user.read",
|
|
560
577
|
"user.create",
|
|
@@ -568,61 +585,61 @@ var UserScopeType = SystemScopeType.extract([
|
|
|
568
585
|
"user.search"
|
|
569
586
|
]);
|
|
570
587
|
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
571
|
-
var UserScopeV2 =
|
|
572
|
-
|
|
588
|
+
var UserScopeV2 = z11.discriminatedUnion("type", [
|
|
589
|
+
z11.object({
|
|
573
590
|
type: ScopesWithRoleOption,
|
|
574
591
|
options: AllUserScopeOptions.optional()
|
|
575
592
|
}),
|
|
576
|
-
|
|
593
|
+
z11.object({
|
|
577
594
|
type: UserScopeType.extract(["user.read", "user.search"]),
|
|
578
595
|
options: AccessLevelOptions.optional()
|
|
579
596
|
})
|
|
580
597
|
]);
|
|
581
|
-
var ResolvedRecordScopeV2 =
|
|
582
|
-
|
|
598
|
+
var ResolvedRecordScopeV2 = z11.discriminatedUnion("type", [
|
|
599
|
+
z11.object({
|
|
583
600
|
type: ScopesWithPlaceEventOptions,
|
|
584
601
|
options: ResolvedScopeOptionsPlaceEvent.optional()
|
|
585
602
|
}),
|
|
586
|
-
|
|
603
|
+
z11.object({
|
|
587
604
|
type: ScopesWithDeclaredOptions,
|
|
588
605
|
options: ResolvedScopeOptionsDeclared.optional()
|
|
589
606
|
}),
|
|
590
|
-
|
|
607
|
+
z11.object({
|
|
591
608
|
type: ScopesWithFullOptions,
|
|
592
609
|
options: ResolvedScopeOptionsFull.optional()
|
|
593
610
|
}),
|
|
594
|
-
|
|
595
|
-
type:
|
|
611
|
+
z11.object({
|
|
612
|
+
type: z11.literal("record.print-certified-copies"),
|
|
596
613
|
options: ResolvedScopeOptionsFull.extend({
|
|
597
|
-
templates:
|
|
614
|
+
templates: z11.array(z11.string()).optional()
|
|
598
615
|
}).optional()
|
|
599
616
|
})
|
|
600
617
|
]).describe("Resolved scope with location/user IDs instead of filters.");
|
|
601
|
-
var Scope2 =
|
|
602
|
-
|
|
618
|
+
var Scope2 = z11.discriminatedUnion("type", [
|
|
619
|
+
z11.object({ type: PlainScopeType }),
|
|
603
620
|
...RecordScopeV2.options,
|
|
604
621
|
...UserScopeV2.options,
|
|
605
|
-
|
|
606
|
-
type:
|
|
622
|
+
z11.object({
|
|
623
|
+
type: z11.literal("organisation.read-locations"),
|
|
607
624
|
options: AccessLevelOptions.optional()
|
|
608
625
|
}),
|
|
609
|
-
|
|
610
|
-
type:
|
|
626
|
+
z11.object({
|
|
627
|
+
type: z11.literal("workqueue"),
|
|
611
628
|
options: WorkqueueOrDashboardOptions
|
|
612
629
|
}),
|
|
613
|
-
|
|
614
|
-
type:
|
|
630
|
+
z11.object({
|
|
631
|
+
type: z11.literal("dashboard.view"),
|
|
615
632
|
options: WorkqueueOrDashboardOptions
|
|
616
633
|
})
|
|
617
634
|
]);
|
|
618
|
-
var ScopeType2 =
|
|
635
|
+
var ScopeType2 = z11.enum([
|
|
619
636
|
...SystemScopeType.options,
|
|
620
637
|
...RecordScopeTypeV2.options,
|
|
621
638
|
...PlainScopeType.options,
|
|
622
639
|
"workqueue",
|
|
623
640
|
"dashboard.view"
|
|
624
641
|
]);
|
|
625
|
-
var EncodedScope2 =
|
|
642
|
+
var EncodedScope2 = z11.string().brand("EncodedScope");
|
|
626
643
|
var DEFAULT_SCOPE_OPTIONS = {
|
|
627
644
|
placeOfEvent: JurisdictionFilter.enum.all,
|
|
628
645
|
accessLevel: JurisdictionFilter.enum.all,
|
|
@@ -1317,4 +1334,4 @@ function createFieldConditionals(fieldId) {
|
|
|
1317
1334
|
}
|
|
1318
1335
|
|
|
1319
1336
|
// src/conditionals/index.ts
|
|
1320
|
-
|
|
1337
|
+
z13.globalRegistry.clear();
|
package/dist/csv.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type CsvFile = {
|
|
2
|
+
header: string;
|
|
3
|
+
body: string[];
|
|
4
|
+
/** Preserved so a file written on Windows stays written on Windows. */
|
|
5
|
+
newline: string;
|
|
6
|
+
trailingNewline: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function parseCsvLine(line: string): string[];
|
|
9
|
+
export declare function toCsvLine(values: string[]): string;
|
|
10
|
+
/**
|
|
11
|
+
* The id of a row, which is its first column. Translation ids never contain a
|
|
12
|
+
* comma or a quote, so this does not need the parser.
|
|
13
|
+
*/
|
|
14
|
+
export declare function idOf(line: string): string;
|
|
15
|
+
export declare function readCsvFile(path: string): CsvFile | undefined;
|
|
16
|
+
export declare function writeCsvFile(path: string, file: CsvFile): void;
|
|
17
|
+
/**
|
|
18
|
+
* Adds the rows the file does not already have an id for, in place. Rows go in
|
|
19
|
+
* sorted position when the file is sorted by id, and at the end when it is not,
|
|
20
|
+
* so a country config that keeps its own order keeps it.
|
|
21
|
+
*
|
|
22
|
+
* Returns the ids that were added.
|
|
23
|
+
*/
|
|
24
|
+
export declare function addRows(file: CsvFile, rows: string[]): string[];
|
|
25
|
+
//# sourceMappingURL=csv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csv.d.ts","sourceRoot":"","sources":["../src/csv.ts"],"names":[],"mappings":"AAuBA,MAAM,MAAM,OAAO,GAAG;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,EAAE,OAAO,CAAA;CACzB,CAAA;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAiCnD;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAMlD;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKzC;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAe7D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,CAM9D;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CA4B/D"}
|
package/dist/csv.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
6
|
+
*
|
|
7
|
+
* OpenCRVS is also distributed under the terms of the Civil Registration
|
|
8
|
+
* & Healthcare Disclaimer located at http://opencrvs.org/license.
|
|
9
|
+
*
|
|
10
|
+
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.parseCsvLine = parseCsvLine;
|
|
14
|
+
exports.toCsvLine = toCsvLine;
|
|
15
|
+
exports.idOf = idOf;
|
|
16
|
+
exports.readCsvFile = readCsvFile;
|
|
17
|
+
exports.writeCsvFile = writeCsvFile;
|
|
18
|
+
exports.addRows = addRows;
|
|
19
|
+
/**
|
|
20
|
+
* Just enough CSV for the translation files codemods edit. They are read and
|
|
21
|
+
* written a line at a time rather than through a parser, so that adding two
|
|
22
|
+
* rows to a file of sixteen hundred produces a diff of two lines instead of a
|
|
23
|
+
* re-quoted rewrite of the whole thing.
|
|
24
|
+
*
|
|
25
|
+
* Rows spanning multiple lines are not supported, and none of the translation
|
|
26
|
+
* files contain any.
|
|
27
|
+
*/
|
|
28
|
+
const fs_1 = require("fs");
|
|
29
|
+
function parseCsvLine(line) {
|
|
30
|
+
const values = [];
|
|
31
|
+
let value = '';
|
|
32
|
+
let quoted = false;
|
|
33
|
+
for (let index = 0; index < line.length; index++) {
|
|
34
|
+
const character = line[index];
|
|
35
|
+
if (quoted) {
|
|
36
|
+
if (character !== '"') {
|
|
37
|
+
value += character;
|
|
38
|
+
}
|
|
39
|
+
else if (line[index + 1] === '"') {
|
|
40
|
+
value += '"';
|
|
41
|
+
index++;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
quoted = false;
|
|
45
|
+
}
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (character === '"') {
|
|
49
|
+
quoted = true;
|
|
50
|
+
}
|
|
51
|
+
else if (character === ',') {
|
|
52
|
+
values.push(value);
|
|
53
|
+
value = '';
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
value += character;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
values.push(value);
|
|
60
|
+
return values;
|
|
61
|
+
}
|
|
62
|
+
function toCsvLine(values) {
|
|
63
|
+
return values
|
|
64
|
+
.map((value) => /["\n,]/.test(value) ? `"${value.replace(/"/g, '""')}"` : value)
|
|
65
|
+
.join(',');
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The id of a row, which is its first column. Translation ids never contain a
|
|
69
|
+
* comma or a quote, so this does not need the parser.
|
|
70
|
+
*/
|
|
71
|
+
function idOf(line) {
|
|
72
|
+
const comma = line.indexOf(',');
|
|
73
|
+
// No comma: `slice(0, -1)` would eat the last character.
|
|
74
|
+
return comma === -1 ? line : line.slice(0, comma);
|
|
75
|
+
}
|
|
76
|
+
function readCsvFile(path) {
|
|
77
|
+
if (!(0, fs_1.existsSync)(path)) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
const contents = (0, fs_1.readFileSync)(path, 'utf8');
|
|
81
|
+
const newline = contents.includes('\r\n') ? '\r\n' : '\n';
|
|
82
|
+
const trailingNewline = /\r?\n$/.test(contents);
|
|
83
|
+
const lines = contents.replace(/\r?\n$/, '').split(/\r?\n/);
|
|
84
|
+
// Trailing blank line leaves an empty entry. It sorts before every id, so
|
|
85
|
+
// the file reads as unsorted.
|
|
86
|
+
const body = lines.slice(1).filter((line) => line !== '');
|
|
87
|
+
return { header: lines[0], body, newline, trailingNewline };
|
|
88
|
+
}
|
|
89
|
+
function writeCsvFile(path, file) {
|
|
90
|
+
(0, fs_1.writeFileSync)(path, [file.header, ...file.body].join(file.newline) +
|
|
91
|
+
(file.trailingNewline ? file.newline : ''));
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Adds the rows the file does not already have an id for, in place. Rows go in
|
|
95
|
+
* sorted position when the file is sorted by id, and at the end when it is not,
|
|
96
|
+
* so a country config that keeps its own order keeps it.
|
|
97
|
+
*
|
|
98
|
+
* Returns the ids that were added.
|
|
99
|
+
*/
|
|
100
|
+
function addRows(file, rows) {
|
|
101
|
+
const isSorted = file.body.every((line, index) => index === 0 || idOf(file.body[index - 1]) <= idOf(line));
|
|
102
|
+
const added = [];
|
|
103
|
+
for (const row of rows) {
|
|
104
|
+
const id = idOf(row);
|
|
105
|
+
if (file.body.some((line) => idOf(line) === id)) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const insertAt = isSorted
|
|
109
|
+
? file.body.findIndex((line) => idOf(line) > id)
|
|
110
|
+
: -1;
|
|
111
|
+
if (insertAt === -1) {
|
|
112
|
+
file.body.push(row);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
file.body.splice(insertAt, 0, row);
|
|
116
|
+
}
|
|
117
|
+
added.push(id);
|
|
118
|
+
}
|
|
119
|
+
return added;
|
|
120
|
+
}
|