@opencrvs/toolkit 1.8.0-rc.fe7c504 → 1.8.0-rc.fe8c092
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/api/router.d.ts +10468 -1335
- package/dist/commons/events/ActionConfig.d.ts +0 -2600
- package/dist/commons/events/ActionDocument.d.ts +1087 -1081
- package/dist/commons/events/ActionInput.d.ts +726 -726
- package/dist/commons/events/ActionType.d.ts +2 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +18 -222
- package/dist/commons/events/CompositeFieldValue.d.ts +6 -6
- package/dist/commons/events/CountryConfigQueryInput.d.ts +572 -1234
- package/dist/commons/events/CreatedAtLocation.d.ts +2 -1
- package/dist/commons/events/Draft.d.ts +77 -77
- package/dist/commons/events/EventConfig.d.ts +0 -1458
- package/dist/commons/events/EventDocument.d.ts +711 -706
- package/dist/commons/events/EventIndex.d.ts +151 -135
- package/dist/commons/events/EventMetadata.d.ts +29 -38
- package/dist/commons/events/FieldConfig.d.ts +0 -178
- package/dist/commons/events/FieldTypeMapping.d.ts +16 -16
- package/dist/commons/events/FieldValue.d.ts +12 -12
- package/dist/commons/events/FormConfig.d.ts +0 -1092
- package/dist/commons/events/PageConfig.d.ts +0 -260
- package/dist/commons/events/User.d.ts +3 -6
- package/dist/commons/events/WorkqueueConfig.d.ts +1028 -2038
- package/dist/commons/events/defineConfig.d.ts +0 -294
- package/dist/commons/events/field.d.ts +0 -5
- package/dist/commons/events/test.utils.d.ts +19 -30
- package/dist/commons/events/transactions.d.ts +1 -1
- package/dist/commons/events/utils.d.ts +15 -440
- package/dist/conditionals/index.js +18 -22
- package/dist/events/index.js +185 -303
- package/dist/scopes/index.d.ts +6 -92
- package/dist/scopes/index.js +9 -38
- package/package.json +3 -3
package/dist/scopes/index.d.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import { z } from 'zod';
|
2
|
-
import { SearchScopeAccessLevels } from './events';
|
3
2
|
export declare const SCOPES: {
|
4
3
|
readonly NATLSYSADMIN: "natlsysadmin";
|
5
4
|
readonly BYPASSRATELIMIT: "bypassratelimit";
|
@@ -88,77 +87,7 @@ export declare const SCOPES: {
|
|
88
87
|
};
|
89
88
|
export declare const SearchScopes: z.ZodUnion<[z.ZodLiteral<"search.birth:my-jurisdiction">, z.ZodLiteral<"search.birth">, z.ZodLiteral<"search.death:my-jurisdiction">, z.ZodLiteral<"search.death">, z.ZodLiteral<"search.marriage:my-jurisdiction">, z.ZodLiteral<"search.marriage">]>;
|
90
89
|
declare const LiteralScopes: z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"natlsysadmin">, z.ZodLiteral<"bypassratelimit">, z.ZodLiteral<"declare">, z.ZodLiteral<"register">, z.ZodLiteral<"validate">, z.ZodLiteral<"demo">, z.ZodLiteral<"certify">, z.ZodLiteral<"performance">, z.ZodLiteral<"sysadmin">, z.ZodLiteral<"teams">, z.ZodLiteral<"config">]>, z.ZodUnion<[z.ZodLiteral<"webhook">, z.ZodLiteral<"nationalId">, z.ZodLiteral<"notification-api">, z.ZodLiteral<"recordsearch">]>, z.ZodLiteral<"record.unassign-others">, z.ZodUnion<[z.ZodLiteral<"record.declare-birth">, z.ZodLiteral<"record.import">, z.ZodLiteral<"record.declare-birth">, z.ZodLiteral<"record.declare-birth:my-jurisdiction">, z.ZodLiteral<"record.declare-death">, z.ZodLiteral<"record.declare-death:my-jurisdiction">, z.ZodLiteral<"record.declare-marriage">, z.ZodLiteral<"record.declare-marriage:my-jurisdiction">, z.ZodLiteral<"record.declaration-submit-incomplete">, z.ZodLiteral<"record.declaration-submit-for-review">]>, z.ZodUnion<[z.ZodLiteral<"record.declaration-submit-for-approval">, z.ZodLiteral<"record.declaration-submit-for-updates">, z.ZodLiteral<"record.declaration-edit">, z.ZodLiteral<"record.review-duplicates">, z.ZodLiteral<"record.declaration-archive">, z.ZodLiteral<"record.declaration-reinstate">]>, z.ZodLiteral<"record.register">, z.ZodUnion<[z.ZodLiteral<"record.export-records">, z.ZodLiteral<"record.declaration-print">, z.ZodLiteral<"record.declaration-print-supporting-documents">, z.ZodLiteral<"record.registration-print">, z.ZodLiteral<"record.registration-print&issue-certified-copies">, z.ZodLiteral<"record.registration-print-certified-copies">, z.ZodLiteral<"record.registration-bulk-print-certified-copies">, z.ZodLiteral<"record.registration-verify-certified-copies">]>, z.ZodUnion<[z.ZodLiteral<"record.registration-request-correction">, z.ZodLiteral<"record.registration-correct">, z.ZodLiteral<"record.registration-request-revocation">, z.ZodLiteral<"record.registration-revoke">, z.ZodLiteral<"record.registration-request-reinstatement">, z.ZodLiteral<"record.registration-reinstate">, z.ZodLiteral<"record.confirm-registration">, z.ZodLiteral<"record.reject-registration">]>, z.ZodUnion<[z.ZodLiteral<"search.birth:my-jurisdiction">, z.ZodLiteral<"search.birth">, z.ZodLiteral<"search.death:my-jurisdiction">, z.ZodLiteral<"search.death">, z.ZodLiteral<"search.marriage:my-jurisdiction">, z.ZodLiteral<"search.marriage">]>, z.ZodUnion<[z.ZodLiteral<"record.read">, z.ZodLiteral<"record.read-audit">, z.ZodLiteral<"record.read-comments">, z.ZodLiteral<"record.create-comments">]>, z.ZodUnion<[z.ZodLiteral<"profile.update">, z.ZodLiteral<"profile.electronic-signature">]>, z.ZodUnion<[z.ZodLiteral<"performance.read">, z.ZodLiteral<"performance.read-dashboards">, z.ZodLiteral<"performance.vital-statistics-export">]>, z.ZodUnion<[z.ZodLiteral<"organisation.read-locations:all">, z.ZodLiteral<"organisation.read-locations:my-office">, z.ZodLiteral<"organisation.read-locations:my-jurisdiction">]>, z.ZodUnion<[z.ZodLiteral<"user.read:all">, z.ZodLiteral<"user.read:my-office">, z.ZodLiteral<"user.read:my-jurisdiction">, z.ZodLiteral<"user.read:only-my-audit">, z.ZodLiteral<"user.create:all">, z.ZodLiteral<"user.create:my-jurisdiction">, z.ZodLiteral<"user.update:all">, z.ZodLiteral<"user.update:my-jurisdiction">]>, z.ZodLiteral<"config.update:all">, z.ZodLiteral<"user.data-seeding">]>;
|
91
|
-
declare const
|
92
|
-
type: z.ZodLiteral<"record.notify">;
|
93
|
-
options: z.ZodObject<{
|
94
|
-
event: z.ZodArray<z.ZodString, "many">;
|
95
|
-
}, "strip", z.ZodTypeAny, {
|
96
|
-
event: string[];
|
97
|
-
}, {
|
98
|
-
event: string[];
|
99
|
-
}>;
|
100
|
-
}, "strip", z.ZodTypeAny, {
|
101
|
-
type: "record.notify";
|
102
|
-
options: {
|
103
|
-
event: string[];
|
104
|
-
};
|
105
|
-
}, {
|
106
|
-
type: "record.notify";
|
107
|
-
options: {
|
108
|
-
event: string[];
|
109
|
-
};
|
110
|
-
}>;
|
111
|
-
declare const SearchScope: z.ZodObject<{
|
112
|
-
type: z.ZodLiteral<"search">;
|
113
|
-
options: z.ZodObject<{
|
114
|
-
event: z.ZodArray<z.ZodString, "many">;
|
115
|
-
access: z.ZodArray<z.ZodEnum<["my-jurisdiction", "all"]>, "many">;
|
116
|
-
}, "strip", z.ZodTypeAny, {
|
117
|
-
event: string[];
|
118
|
-
access: ("my-jurisdiction" | "all")[];
|
119
|
-
}, {
|
120
|
-
event: string[];
|
121
|
-
access: ("my-jurisdiction" | "all")[];
|
122
|
-
}>;
|
123
|
-
}, "strip", z.ZodTypeAny, {
|
124
|
-
type: "search";
|
125
|
-
options: {
|
126
|
-
event: string[];
|
127
|
-
access: ("my-jurisdiction" | "all")[];
|
128
|
-
};
|
129
|
-
}, {
|
130
|
-
type: "search";
|
131
|
-
options: {
|
132
|
-
event: string[];
|
133
|
-
access: ("my-jurisdiction" | "all")[];
|
134
|
-
};
|
135
|
-
}>;
|
136
|
-
export type SearchScope = z.infer<typeof SearchScope>;
|
137
|
-
declare const ConfigurableRawScopes: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
138
|
-
type: z.ZodLiteral<"search">;
|
139
|
-
options: z.ZodObject<{
|
140
|
-
event: z.ZodArray<z.ZodString, "many">;
|
141
|
-
access: z.ZodArray<z.ZodEnum<["my-jurisdiction", "all"]>, "many">;
|
142
|
-
}, "strip", z.ZodTypeAny, {
|
143
|
-
event: string[];
|
144
|
-
access: ("my-jurisdiction" | "all")[];
|
145
|
-
}, {
|
146
|
-
event: string[];
|
147
|
-
access: ("my-jurisdiction" | "all")[];
|
148
|
-
}>;
|
149
|
-
}, "strip", z.ZodTypeAny, {
|
150
|
-
type: "search";
|
151
|
-
options: {
|
152
|
-
event: string[];
|
153
|
-
access: ("my-jurisdiction" | "all")[];
|
154
|
-
};
|
155
|
-
}, {
|
156
|
-
type: "search";
|
157
|
-
options: {
|
158
|
-
event: string[];
|
159
|
-
access: ("my-jurisdiction" | "all")[];
|
160
|
-
};
|
161
|
-
}>, z.ZodObject<{
|
90
|
+
declare const ConfigurableScopes: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
162
91
|
type: z.ZodLiteral<"user.create">;
|
163
92
|
options: z.ZodObject<{
|
164
93
|
role: z.ZodArray<z.ZodString, "many">;
|
@@ -235,15 +164,8 @@ declare const ConfigurableRawScopes: z.ZodDiscriminatedUnion<"type", [z.ZodObjec
|
|
235
164
|
event: string[];
|
236
165
|
};
|
237
166
|
}>]>;
|
238
|
-
type
|
239
|
-
export type
|
240
|
-
type FlattenedSearchScope = {
|
241
|
-
type: 'search';
|
242
|
-
options: Record<string, SearchScopeAccessLevels>;
|
243
|
-
};
|
244
|
-
export type ConfigurableScopes = Exclude<ConfigurableRawScopes, {
|
245
|
-
type: 'search';
|
246
|
-
}> | FlattenedSearchScope;
|
167
|
+
export type ConfigurableScopeType = ConfigurableScopes['type'];
|
168
|
+
export type ConfigurableScopes = z.infer<typeof ConfigurableScopes>;
|
247
169
|
export declare function findScope<T extends ConfigurableScopeType>(scopes: string[], scopeType: T): Extract<{
|
248
170
|
type: "user.create";
|
249
171
|
options: {
|
@@ -272,24 +194,16 @@ export declare function findScope<T extends ConfigurableScopeType>(scopes: strin
|
|
272
194
|
};
|
273
195
|
}, {
|
274
196
|
type: T;
|
275
|
-
}> | Extract<FlattenedSearchScope, {
|
276
|
-
type: T;
|
277
197
|
}> | undefined;
|
278
198
|
/**
|
279
|
-
* Parses a configurable scope string into a
|
199
|
+
* Parses a configurable scope string into a ConfigurableScopes object.
|
280
200
|
* @param {string} scope - The scope string to parse
|
281
|
-
* @returns {
|
201
|
+
* @returns {ConfigurableScopes | undefined} The parsed scope object if valid, undefined otherwise
|
282
202
|
* @example
|
283
203
|
* parseScope("user.create[role=field-agent|registration-agent]")
|
284
204
|
* // Returns: { type: "user.create", options: { role: ["field-agent", "registration-agent"] } }
|
285
205
|
*/
|
286
206
|
export declare function parseScope(scope: string): {
|
287
|
-
type: "search";
|
288
|
-
options: {
|
289
|
-
event: string[];
|
290
|
-
access: ("my-jurisdiction" | "all")[];
|
291
|
-
};
|
292
|
-
} | {
|
293
207
|
type: "user.create";
|
294
208
|
options: {
|
295
209
|
role: string[];
|
@@ -323,7 +237,7 @@ export declare function parseScope(scope: string): {
|
|
323
237
|
* })
|
324
238
|
* // Returns: "record.notify[event=v2.birth|tennis-club-membership]"
|
325
239
|
*/
|
326
|
-
export declare function stringifyScope(scope:
|
240
|
+
export declare function stringifyScope(scope: ConfigurableScopes): string;
|
327
241
|
export declare const scopes: Scope[];
|
328
242
|
export type ParsedScopes = NonNullable<ReturnType<typeof parseScope>>;
|
329
243
|
export type RawScopes = z.infer<typeof LiteralScopes> | (string & {});
|
package/dist/scopes/index.js
CHANGED
@@ -289,51 +289,18 @@ var NotifyRecordScope = import_zod.z.object({
|
|
289
289
|
event: import_zod.z.array(import_zod.z.string())
|
290
290
|
})
|
291
291
|
});
|
292
|
-
var
|
293
|
-
type: import_zod.z.literal("search"),
|
294
|
-
options: import_zod.z.object({
|
295
|
-
event: import_zod.z.array(import_zod.z.string()).length(1),
|
296
|
-
access: import_zod.z.array(import_zod.z.enum(["my-jurisdiction", "all"])).length(1)
|
297
|
-
})
|
298
|
-
});
|
299
|
-
var ConfigurableRawScopes = import_zod.z.discriminatedUnion("type", [
|
300
|
-
SearchScope,
|
292
|
+
var ConfigurableScopes = import_zod.z.discriminatedUnion("type", [
|
301
293
|
CreateUserScope,
|
302
294
|
EditUserScope,
|
303
295
|
WorkqueueScope,
|
304
296
|
NotifyRecordScope
|
305
297
|
]);
|
306
|
-
function flattenAndMergeScopes(scopes2) {
|
307
|
-
if (scopes2.length === 0) return null;
|
308
|
-
const type = scopes2[0].type;
|
309
|
-
const mergedOptions = {};
|
310
|
-
for (const scope of scopes2) {
|
311
|
-
const entries = Object.entries(scope.options);
|
312
|
-
if (entries.length < 2) continue;
|
313
|
-
const sourceValues = entries[0][1];
|
314
|
-
const targetValues = entries[1][1];
|
315
|
-
for (let i = 0; i < sourceValues.length; i++) {
|
316
|
-
mergedOptions[sourceValues[i]] = targetValues[i];
|
317
|
-
}
|
318
|
-
}
|
319
|
-
return { type, options: mergedOptions };
|
320
|
-
}
|
321
298
|
function findScope(scopes2, scopeType) {
|
322
299
|
const parsedScopes = scopes2.map((rawScope) => parseScope(rawScope));
|
323
|
-
|
324
|
-
|
325
|
-
const mergedSearchScope = flattenAndMergeScopes(searchScopes);
|
326
|
-
return [...otherScopes, mergedSearchScope].find(
|
327
|
-
(scope) => scope?.type === scopeType
|
300
|
+
return parsedScopes.find(
|
301
|
+
(parsedScope) => parsedScope?.type === scopeType
|
328
302
|
);
|
329
303
|
}
|
330
|
-
function getScopeOptions(rawOptions) {
|
331
|
-
return rawOptions.split(",").reduce((acc, option) => {
|
332
|
-
const [key, value] = option.split("=");
|
333
|
-
acc[key] = value.split("|");
|
334
|
-
return acc;
|
335
|
-
}, {});
|
336
|
-
}
|
337
304
|
function parseScope(scope) {
|
338
305
|
const maybeLiteralScope = LiteralScopes.safeParse(scope);
|
339
306
|
if (maybeLiteralScope.success) {
|
@@ -347,12 +314,16 @@ function parseScope(scope) {
|
|
347
314
|
}
|
348
315
|
const rawScope = maybeConfigurableScope.data;
|
349
316
|
const [, type, rawOptions] = rawScope.match(rawConfigurableScopeRegex) ?? [];
|
350
|
-
const options =
|
317
|
+
const options = rawOptions.split(",").reduce((acc, option) => {
|
318
|
+
const [key, value] = option.split("=");
|
319
|
+
acc[key] = value.split("|");
|
320
|
+
return acc;
|
321
|
+
}, {});
|
351
322
|
const parsedScope = {
|
352
323
|
type,
|
353
324
|
options
|
354
325
|
};
|
355
|
-
const result =
|
326
|
+
const result = ConfigurableScopes.safeParse(parsedScope);
|
356
327
|
return result.success ? result.data : void 0;
|
357
328
|
}
|
358
329
|
function stringifyScope(scope) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@opencrvs/toolkit",
|
3
|
-
"version": "1.8.0-rc.
|
3
|
+
"version": "1.8.0-rc.fe8c092",
|
4
4
|
"description": "OpenCRVS toolkit for building country configurations",
|
5
5
|
"license": "MPL-2.0",
|
6
6
|
"exports": {
|
@@ -19,8 +19,8 @@
|
|
19
19
|
"ajv": "^8.17.1",
|
20
20
|
"ajv-formats": "^3.0.1",
|
21
21
|
"superjson": "1.9.0-0",
|
22
|
-
"@trpc/client": "11.
|
23
|
-
"@trpc/server": "11.
|
22
|
+
"@trpc/client": "^11.0.0-rc.648",
|
23
|
+
"@trpc/server": "^11.0.0-rc.532",
|
24
24
|
"zod-openapi": "^4.2.4"
|
25
25
|
},
|
26
26
|
"devDependencies": {
|