@opencrvs/toolkit 2.0.0-rc.c2c75ca → 2.0.0-rc.c618db4
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/application-config/index.js +39 -11
- package/dist/cli.js +35 -7
- package/dist/commons/api/router.d.ts +54 -52
- package/dist/commons/application-config/index.d.ts +16 -4
- package/dist/commons/conditionals/conditionals.d.ts +3 -3
- package/dist/commons/events/FieldConfig.d.ts +5 -0
- package/dist/commons/events/locations.d.ts +38 -1
- package/dist/commons/events/mocks.test.utils.d.ts +19 -0
- package/dist/commons/events/scopes.d.ts +24 -1
- package/dist/conditionals/index.js +35 -7
- package/dist/events/index.js +128 -7
- package/dist/migrations/v2.0/index.js +35 -7
- package/dist/notification/index.js +35 -7
- package/dist/scopes/index.d.ts +82 -10
- package/dist/scopes/index.js +41 -8
- package/opencrvs-toolkit-2.0.0-rc.c618db4.tgz +0 -0
- package/package.json +1 -1
- package/opencrvs-toolkit-2.0.0-rc.c2c75ca.tgz +0 -0
package/dist/scopes/index.js
CHANGED
|
@@ -42,6 +42,7 @@ __export(scopes_exports, {
|
|
|
42
42
|
ScopesWithFullOptions: () => ScopesWithFullOptions,
|
|
43
43
|
ScopesWithPlaceEventOptions: () => ScopesWithPlaceEventOptions,
|
|
44
44
|
UserFilter: () => UserFilter,
|
|
45
|
+
UserScopeV2: () => UserScopeV2,
|
|
45
46
|
canUserCreateEvent: () => canUserCreateEvent,
|
|
46
47
|
decodeScope: () => decodeScope,
|
|
47
48
|
defineRoles: () => defineRoles,
|
|
@@ -54,7 +55,8 @@ __export(scopes_exports, {
|
|
|
54
55
|
isCustomActionScope: () => isCustomActionScope,
|
|
55
56
|
scopeUsesDeclaredOptions: () => scopeUsesDeclaredOptions,
|
|
56
57
|
scopeUsesFullOptions: () => scopeUsesFullOptions,
|
|
57
|
-
scopeUsesPrintCertifiedCopiesOptions: () => scopeUsesPrintCertifiedCopiesOptions
|
|
58
|
+
scopeUsesPrintCertifiedCopiesOptions: () => scopeUsesPrintCertifiedCopiesOptions,
|
|
59
|
+
scopeUsesRoleOptions: () => scopeUsesRoleOptions
|
|
58
60
|
});
|
|
59
61
|
module.exports = __toCommonJS(scopes_exports);
|
|
60
62
|
var z4 = __toESM(require("zod/v4"));
|
|
@@ -139,6 +141,10 @@ var scopeByEvent = z3.preprocess(
|
|
|
139
141
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
140
142
|
z3.array(z3.string()).optional()
|
|
141
143
|
).describe("Event type, e.g. birth, death");
|
|
144
|
+
var userRole = z3.preprocess(
|
|
145
|
+
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
146
|
+
z3.array(z3.string()).optional()
|
|
147
|
+
).describe("User role, e.g. admin, field agent");
|
|
142
148
|
var scopeOptionsPlaceEvent = z3.object({
|
|
143
149
|
event: scopeByEvent,
|
|
144
150
|
placeOfEvent: JurisdictionFilter.optional()
|
|
@@ -162,6 +168,9 @@ var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
|
162
168
|
var AccessLevelOptions = z3.object({
|
|
163
169
|
accessLevel: JurisdictionFilter.optional()
|
|
164
170
|
});
|
|
171
|
+
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
172
|
+
role: userRole.optional()
|
|
173
|
+
});
|
|
165
174
|
var WorkqueueOrDashboardOptions = z3.object({
|
|
166
175
|
ids: z3.preprocess(
|
|
167
176
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
@@ -171,6 +180,7 @@ var WorkqueueOrDashboardOptions = z3.object({
|
|
|
171
180
|
var AllScopeOptions = z3.object({
|
|
172
181
|
...AllRecordScopeOptions.shape,
|
|
173
182
|
...AccessLevelOptions.shape,
|
|
183
|
+
...AllUserScopeOptions.shape,
|
|
174
184
|
...WorkqueueOrDashboardOptions.shape
|
|
175
185
|
});
|
|
176
186
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
@@ -243,6 +253,31 @@ var RecordScopeV2 = z3.discriminatedUnion("type", [
|
|
|
243
253
|
]).describe(
|
|
244
254
|
"Scopes used to check user's permission to perform actions on a record."
|
|
245
255
|
);
|
|
256
|
+
var SystemScopeType = z3.enum([
|
|
257
|
+
"organisation.read-locations",
|
|
258
|
+
"user.read",
|
|
259
|
+
"user.create",
|
|
260
|
+
"user.edit"
|
|
261
|
+
]);
|
|
262
|
+
var UserScopeType = SystemScopeType.extract([
|
|
263
|
+
"user.read",
|
|
264
|
+
"user.create",
|
|
265
|
+
"user.edit"
|
|
266
|
+
]);
|
|
267
|
+
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
268
|
+
var UserScopeV2 = z3.discriminatedUnion("type", [
|
|
269
|
+
z3.object({
|
|
270
|
+
type: ScopesWithRoleOption,
|
|
271
|
+
options: AllUserScopeOptions.optional()
|
|
272
|
+
}),
|
|
273
|
+
z3.object({
|
|
274
|
+
type: UserScopeType.extract(["user.read"]),
|
|
275
|
+
options: AccessLevelOptions.optional()
|
|
276
|
+
})
|
|
277
|
+
]);
|
|
278
|
+
function scopeUsesRoleOptions(scope) {
|
|
279
|
+
return ScopesWithRoleOption?.options.some((opt) => opt === scope.type);
|
|
280
|
+
}
|
|
246
281
|
function scopeUsesDeclaredOptions(scope) {
|
|
247
282
|
return !ScopesWithPlaceEventOptions.options.some((opt) => opt === scope.type);
|
|
248
283
|
}
|
|
@@ -275,16 +310,14 @@ var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
|
|
|
275
310
|
}).optional()
|
|
276
311
|
})
|
|
277
312
|
]).describe("Resolved scope with location/user IDs instead of filters.");
|
|
278
|
-
var SystemScopeType = z3.enum([
|
|
279
|
-
"organisation.read-locations",
|
|
280
|
-
"user.read",
|
|
281
|
-
"user.create",
|
|
282
|
-
"user.edit"
|
|
283
|
-
]);
|
|
284
313
|
var Scope2 = z3.discriminatedUnion("type", [
|
|
285
314
|
z3.object({ type: PlainScopeType }),
|
|
286
315
|
...RecordScopeV2.options,
|
|
287
|
-
|
|
316
|
+
...UserScopeV2.options,
|
|
317
|
+
z3.object({
|
|
318
|
+
type: z3.literal("organisation.read-locations"),
|
|
319
|
+
options: AccessLevelOptions.optional()
|
|
320
|
+
}),
|
|
288
321
|
z3.object({
|
|
289
322
|
type: z3.literal("workqueue"),
|
|
290
323
|
options: WorkqueueOrDashboardOptions
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|