@opencrvs/toolkit 1.8.1-rc.a372970 → 1.8.1-rc.bbbfede
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 +6318 -5078
- package/dist/commons/conditionals/conditionals.d.ts +9 -13
- package/dist/commons/conditionals/validate.d.ts +17 -7
- package/dist/commons/events/ActionConfig.d.ts +119326 -1729
- package/dist/commons/events/ActionDocument.d.ts +5481 -1268
- package/dist/commons/events/ActionInput.d.ts +3745 -1025
- package/dist/commons/events/ActionType.d.ts +10 -1
- package/dist/commons/events/AdvancedSearchConfig.d.ts +1282 -22
- package/dist/commons/events/CompositeFieldValue.d.ts +40 -9
- package/dist/commons/events/Constants.d.ts +3 -0
- package/dist/commons/events/CountryConfigQueryInput.d.ts +4132 -0
- package/dist/commons/events/CreatedAtLocation.d.ts +2 -0
- package/dist/commons/events/Draft.d.ts +332 -97
- package/dist/commons/events/EventConfig.d.ts +54363 -1357
- package/dist/commons/events/EventDocument.d.ts +3136 -833
- package/dist/commons/events/EventIndex.d.ts +2234 -29
- package/dist/commons/events/EventMetadata.d.ts +353 -47
- package/dist/commons/events/FieldConfig.d.ts +6756 -1260
- package/dist/commons/events/FieldType.d.ts +8 -3
- package/dist/commons/events/FieldTypeMapping.d.ts +161 -73
- package/dist/commons/events/FieldValue.d.ts +91 -20
- package/dist/commons/events/FormConfig.d.ts +55770 -522
- package/dist/commons/events/PageConfig.d.ts +13825 -209
- package/dist/commons/events/SummaryConfig.d.ts +93 -42
- package/dist/commons/events/User.d.ts +34 -2
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +53 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +8116 -20
- package/dist/commons/events/defineConfig.d.ts +8529 -77
- package/dist/commons/events/event.d.ts +100 -0
- package/dist/commons/events/field.d.ts +94 -0
- package/dist/commons/events/index.d.ts +8 -0
- package/dist/commons/events/scopes.d.ts +45 -0
- package/dist/commons/events/serializer.d.ts +2 -0
- package/dist/commons/events/test.utils.d.ts +206 -90
- package/dist/commons/events/transactions.d.ts +1 -1
- package/dist/commons/events/utils.d.ts +15440 -88
- package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
- package/dist/conditionals/index.js +66 -56
- package/dist/events/index.js +4755 -1788
- package/dist/scopes/index.d.ts +184 -7
- package/dist/scopes/index.js +140 -40
- package/package.json +4 -3
package/dist/scopes/index.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { z } from 'zod';
|
2
|
+
import { SearchScopeAccessLevels } from './events';
|
2
3
|
export declare const SCOPES: {
|
3
4
|
readonly NATLSYSADMIN: "natlsysadmin";
|
4
5
|
readonly BYPASSRATELIMIT: "bypassratelimit";
|
@@ -19,6 +20,7 @@ export declare const SCOPES: {
|
|
19
20
|
* @TODO This is a temporary scope to be used for V2 Events custom events declaration
|
20
21
|
*/
|
21
22
|
readonly RECORD_DECLARE: "record.declare-birth";
|
23
|
+
readonly RECORD_IMPORT: "record.import";
|
22
24
|
readonly RECORD_DECLARE_BIRTH: "record.declare-birth";
|
23
25
|
readonly RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction";
|
24
26
|
readonly RECORD_DECLARE_DEATH: "record.declare-death";
|
@@ -84,8 +86,79 @@ export declare const SCOPES: {
|
|
84
86
|
readonly CONFIG_UPDATE_ALL: "config.update:all";
|
85
87
|
readonly USER_DATA_SEEDING: "user.data-seeding";
|
86
88
|
};
|
87
|
-
declare const
|
88
|
-
declare const
|
89
|
+
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
|
+
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 NotifyRecordScope: z.ZodObject<{
|
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<{
|
89
162
|
type: z.ZodLiteral<"user.create">;
|
90
163
|
options: z.ZodObject<{
|
91
164
|
role: z.ZodArray<z.ZodString, "many">;
|
@@ -123,20 +196,100 @@ declare const ConfigurableScopes: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
123
196
|
options: {
|
124
197
|
role: string[];
|
125
198
|
};
|
199
|
+
}>, z.ZodObject<{
|
200
|
+
type: z.ZodLiteral<"workqueue">;
|
201
|
+
options: z.ZodObject<{
|
202
|
+
id: z.ZodArray<z.ZodString, "many">;
|
203
|
+
}, "strip", z.ZodTypeAny, {
|
204
|
+
id: string[];
|
205
|
+
}, {
|
206
|
+
id: string[];
|
207
|
+
}>;
|
208
|
+
}, "strip", z.ZodTypeAny, {
|
209
|
+
type: "workqueue";
|
210
|
+
options: {
|
211
|
+
id: string[];
|
212
|
+
};
|
213
|
+
}, {
|
214
|
+
type: "workqueue";
|
215
|
+
options: {
|
216
|
+
id: string[];
|
217
|
+
};
|
218
|
+
}>, z.ZodObject<{
|
219
|
+
type: z.ZodLiteral<"record.notify">;
|
220
|
+
options: z.ZodObject<{
|
221
|
+
event: z.ZodArray<z.ZodString, "many">;
|
222
|
+
}, "strip", z.ZodTypeAny, {
|
223
|
+
event: string[];
|
224
|
+
}, {
|
225
|
+
event: string[];
|
226
|
+
}>;
|
227
|
+
}, "strip", z.ZodTypeAny, {
|
228
|
+
type: "record.notify";
|
229
|
+
options: {
|
230
|
+
event: string[];
|
231
|
+
};
|
232
|
+
}, {
|
233
|
+
type: "record.notify";
|
234
|
+
options: {
|
235
|
+
event: string[];
|
236
|
+
};
|
126
237
|
}>]>;
|
127
|
-
type
|
128
|
-
export
|
238
|
+
type ConfigurableRawScopes = z.infer<typeof ConfigurableRawScopes>;
|
239
|
+
export type ConfigurableScopeType = ConfigurableRawScopes['type'];
|
240
|
+
type FlattenedSearchScope = {
|
241
|
+
type: 'search';
|
242
|
+
options: Record<string, SearchScopeAccessLevels>;
|
243
|
+
};
|
244
|
+
export type ConfigurableScopes = Exclude<ConfigurableRawScopes, {
|
245
|
+
type: 'search';
|
246
|
+
}> | FlattenedSearchScope;
|
247
|
+
export declare function findScope<T extends ConfigurableScopeType>(scopes: string[], scopeType: T): Extract<{
|
129
248
|
type: "user.create";
|
130
249
|
options: {
|
131
250
|
role: string[];
|
132
251
|
};
|
133
|
-
}
|
252
|
+
}, {
|
253
|
+
type: T;
|
254
|
+
}> | Extract<{
|
134
255
|
type: "user.edit";
|
135
256
|
options: {
|
136
257
|
role: string[];
|
137
258
|
};
|
138
|
-
}
|
259
|
+
}, {
|
260
|
+
type: T;
|
261
|
+
}> | Extract<{
|
262
|
+
type: "workqueue";
|
263
|
+
options: {
|
264
|
+
id: string[];
|
265
|
+
};
|
266
|
+
}, {
|
267
|
+
type: T;
|
268
|
+
}> | Extract<{
|
269
|
+
type: "record.notify";
|
270
|
+
options: {
|
271
|
+
event: string[];
|
272
|
+
};
|
273
|
+
}, {
|
274
|
+
type: T;
|
275
|
+
}> | Extract<FlattenedSearchScope, {
|
276
|
+
type: T;
|
277
|
+
}> | undefined;
|
278
|
+
/**
|
279
|
+
* Parses a configurable scope string into a ConfigurableRawScopes object.
|
280
|
+
* @param {string} scope - The scope string to parse
|
281
|
+
* @returns {ConfigurableRawScopes | undefined} The parsed scope object if valid, undefined otherwise
|
282
|
+
* @example
|
283
|
+
* parseScope("user.create[role=field-agent|registration-agent]")
|
284
|
+
* // Returns: { type: "user.create", options: { role: ["field-agent", "registration-agent"] } }
|
285
|
+
*/
|
139
286
|
export declare function parseScope(scope: string): {
|
287
|
+
type: "search";
|
288
|
+
options: {
|
289
|
+
event: string[];
|
290
|
+
access: ("my-jurisdiction" | "all")[];
|
291
|
+
};
|
292
|
+
} | {
|
140
293
|
type: "user.create";
|
141
294
|
options: {
|
142
295
|
role: string[];
|
@@ -147,11 +300,35 @@ export declare function parseScope(scope: string): {
|
|
147
300
|
role: string[];
|
148
301
|
};
|
149
302
|
} | {
|
150
|
-
type: "
|
303
|
+
type: "workqueue";
|
304
|
+
options: {
|
305
|
+
id: string[];
|
306
|
+
};
|
307
|
+
} | {
|
308
|
+
type: "record.notify";
|
309
|
+
options: {
|
310
|
+
event: string[];
|
311
|
+
};
|
312
|
+
} | {
|
313
|
+
type: "natlsysadmin" | "bypassratelimit" | "declare" | "register" | "validate" | "demo" | "certify" | "performance" | "sysadmin" | "teams" | "config" | "webhook" | "nationalId" | "notification-api" | "recordsearch" | "record.declare-birth" | "record.import" | "record.declare-birth:my-jurisdiction" | "record.declare-death" | "record.declare-death:my-jurisdiction" | "record.declare-marriage" | "record.declare-marriage:my-jurisdiction" | "record.declaration-submit-incomplete" | "record.declaration-submit-for-review" | "record.unassign-others" | "record.declaration-submit-for-approval" | "record.declaration-submit-for-updates" | "record.declaration-edit" | "record.review-duplicates" | "record.declaration-archive" | "record.declaration-reinstate" | "record.register" | "record.export-records" | "record.declaration-print" | "record.declaration-print-supporting-documents" | "record.registration-print" | "record.registration-print&issue-certified-copies" | "record.registration-print-certified-copies" | "record.registration-bulk-print-certified-copies" | "record.registration-verify-certified-copies" | "record.registration-request-correction" | "record.registration-correct" | "record.registration-request-revocation" | "record.registration-revoke" | "record.registration-request-reinstatement" | "record.registration-reinstate" | "record.confirm-registration" | "record.reject-registration" | "search.birth:my-jurisdiction" | "search.birth" | "search.death:my-jurisdiction" | "search.death" | "search.marriage:my-jurisdiction" | "search.marriage" | "record.read" | "record.read-audit" | "record.read-comments" | "record.create-comments" | "profile.update" | "profile.electronic-signature" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "organisation.read-locations:all" | "organisation.read-locations:my-office" | "organisation.read-locations:my-jurisdiction" | "user.read:all" | "user.read:my-office" | "user.read:my-jurisdiction" | "user.read:only-my-audit" | "user.create:all" | "user.create:my-jurisdiction" | "user.update:all" | "user.update:my-jurisdiction" | "config.update:all" | "user.data-seeding";
|
151
314
|
} | undefined;
|
315
|
+
/**
|
316
|
+
* Stringifies a ConfigurableScopes object into a scope string.
|
317
|
+
* @param {ConfigurableScopes} scope - The scope object to stringify
|
318
|
+
* @returns {string} The stringified scope in format "type[key1=value1|value2,key2=value3|value4]"
|
319
|
+
* @example
|
320
|
+
* stringifyScope({
|
321
|
+
* type: "record.notify",
|
322
|
+
* options: { event: ["v2.birth", "tennis-club-membership"] }
|
323
|
+
* })
|
324
|
+
* // Returns: "record.notify[event=v2.birth|tennis-club-membership]"
|
325
|
+
*/
|
326
|
+
export declare function stringifyScope(scope: z.infer<typeof NotifyRecordScope>): string;
|
152
327
|
export declare const scopes: Scope[];
|
153
328
|
export type ParsedScopes = NonNullable<ReturnType<typeof parseScope>>;
|
154
329
|
export type RawScopes = z.infer<typeof LiteralScopes> | (string & {});
|
155
330
|
export type Scope = RawScopes;
|
331
|
+
export declare const ActionScopes: z.ZodUnion<[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">]>]>;
|
332
|
+
export type ActionScopes = z.infer<typeof ActionScopes>;
|
156
333
|
export {};
|
157
334
|
//# sourceMappingURL=scopes.d.ts.map
|
package/dist/scopes/index.js
CHANGED
@@ -20,10 +20,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
20
20
|
// src/scopes/index.ts
|
21
21
|
var scopes_exports = {};
|
22
22
|
__export(scopes_exports, {
|
23
|
+
ActionScopes: () => ActionScopes,
|
23
24
|
SCOPES: () => SCOPES,
|
25
|
+
SearchScopes: () => SearchScopes,
|
24
26
|
findScope: () => findScope,
|
25
27
|
parseScope: () => parseScope,
|
26
|
-
scopes: () => scopes
|
28
|
+
scopes: () => scopes,
|
29
|
+
stringifyScope: () => stringifyScope
|
27
30
|
});
|
28
31
|
module.exports = __toCommonJS(scopes_exports);
|
29
32
|
|
@@ -52,6 +55,8 @@ var SCOPES = {
|
|
52
55
|
*/
|
53
56
|
RECORD_DECLARE: "record.declare-birth",
|
54
57
|
// declare
|
58
|
+
RECORD_IMPORT: "record.import",
|
59
|
+
// declare
|
55
60
|
RECORD_DECLARE_BIRTH: "record.declare-birth",
|
56
61
|
RECORD_DECLARE_BIRTH_MY_JURISDICTION: "record.declare-birth:my-jurisdiction",
|
57
62
|
RECORD_DECLARE_DEATH: "record.declare-death",
|
@@ -139,7 +144,7 @@ var SCOPES = {
|
|
139
144
|
// data seeding
|
140
145
|
USER_DATA_SEEDING: "user.data-seeding"
|
141
146
|
};
|
142
|
-
var
|
147
|
+
var LegacyScopes = import_zod.z.union([
|
143
148
|
import_zod.z.literal(SCOPES.NATLSYSADMIN),
|
144
149
|
import_zod.z.literal(SCOPES.BYPASSRATELIMIT),
|
145
150
|
import_zod.z.literal(SCOPES.DECLARE),
|
@@ -150,11 +155,17 @@ var LiteralScopes = import_zod.z.union([
|
|
150
155
|
import_zod.z.literal(SCOPES.PERFORMANCE),
|
151
156
|
import_zod.z.literal(SCOPES.SYSADMIN),
|
152
157
|
import_zod.z.literal(SCOPES.TEAMS),
|
153
|
-
import_zod.z.literal(SCOPES.CONFIG)
|
158
|
+
import_zod.z.literal(SCOPES.CONFIG)
|
159
|
+
]);
|
160
|
+
var IntegrationScopes = import_zod.z.union([
|
154
161
|
import_zod.z.literal(SCOPES.WEBHOOK),
|
155
162
|
import_zod.z.literal(SCOPES.NATIONALID),
|
156
163
|
import_zod.z.literal(SCOPES.NOTIFICATION_API),
|
157
|
-
import_zod.z.literal(SCOPES.RECORDSEARCH)
|
164
|
+
import_zod.z.literal(SCOPES.RECORDSEARCH)
|
165
|
+
]);
|
166
|
+
var DeclareScopes = import_zod.z.union([
|
167
|
+
import_zod.z.literal(SCOPES.RECORD_DECLARE),
|
168
|
+
import_zod.z.literal(SCOPES.RECORD_IMPORT),
|
158
169
|
import_zod.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
|
159
170
|
import_zod.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
|
160
171
|
import_zod.z.literal(SCOPES.RECORD_DECLARE_DEATH),
|
@@ -162,15 +173,19 @@ var LiteralScopes = import_zod.z.union([
|
|
162
173
|
import_zod.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
|
163
174
|
import_zod.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
|
164
175
|
import_zod.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
|
165
|
-
import_zod.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW)
|
166
|
-
|
176
|
+
import_zod.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW)
|
177
|
+
]);
|
178
|
+
var UnassignScope = import_zod.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS);
|
179
|
+
var ValidateScopes = import_zod.z.union([
|
167
180
|
import_zod.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
|
168
181
|
import_zod.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
|
169
182
|
import_zod.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
|
170
183
|
import_zod.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
|
171
184
|
import_zod.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
|
172
|
-
import_zod.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE)
|
173
|
-
|
185
|
+
import_zod.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE)
|
186
|
+
]);
|
187
|
+
var RegisterScope = import_zod.z.literal(SCOPES.RECORD_REGISTER);
|
188
|
+
var CertifyScopes = import_zod.z.union([
|
174
189
|
import_zod.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
|
175
190
|
import_zod.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
|
176
191
|
import_zod.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
|
@@ -178,7 +193,9 @@ var LiteralScopes = import_zod.z.union([
|
|
178
193
|
import_zod.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
|
179
194
|
import_zod.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
|
180
195
|
import_zod.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
|
181
|
-
import_zod.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES)
|
196
|
+
import_zod.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES)
|
197
|
+
]);
|
198
|
+
var CorrectionScopes = import_zod.z.union([
|
182
199
|
import_zod.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
|
183
200
|
import_zod.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
|
184
201
|
import_zod.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
|
@@ -186,25 +203,37 @@ var LiteralScopes = import_zod.z.union([
|
|
186
203
|
import_zod.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
|
187
204
|
import_zod.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
|
188
205
|
import_zod.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
|
189
|
-
import_zod.z.literal(SCOPES.RECORD_REJECT_REGISTRATION)
|
206
|
+
import_zod.z.literal(SCOPES.RECORD_REJECT_REGISTRATION)
|
207
|
+
]);
|
208
|
+
var SearchScopes = import_zod.z.union([
|
190
209
|
import_zod.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
|
191
210
|
import_zod.z.literal(SCOPES.SEARCH_BIRTH),
|
192
211
|
import_zod.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
|
193
212
|
import_zod.z.literal(SCOPES.SEARCH_DEATH),
|
194
213
|
import_zod.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
|
195
|
-
import_zod.z.literal(SCOPES.SEARCH_MARRIAGE)
|
214
|
+
import_zod.z.literal(SCOPES.SEARCH_MARRIAGE)
|
215
|
+
]);
|
216
|
+
var AuditScopes = import_zod.z.union([
|
196
217
|
import_zod.z.literal(SCOPES.RECORD_READ),
|
197
218
|
import_zod.z.literal(SCOPES.RECORD_READ_AUDIT),
|
198
219
|
import_zod.z.literal(SCOPES.RECORD_READ_COMMENTS),
|
199
|
-
import_zod.z.literal(SCOPES.RECORD_CREATE_COMMENTS)
|
220
|
+
import_zod.z.literal(SCOPES.RECORD_CREATE_COMMENTS)
|
221
|
+
]);
|
222
|
+
var ProfileScopes = import_zod.z.union([
|
200
223
|
import_zod.z.literal(SCOPES.PROFILE_UPDATE),
|
201
|
-
import_zod.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE)
|
224
|
+
import_zod.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE)
|
225
|
+
]);
|
226
|
+
var PerformanceScopes = import_zod.z.union([
|
202
227
|
import_zod.z.literal(SCOPES.PERFORMANCE_READ),
|
203
228
|
import_zod.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
|
204
|
-
import_zod.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS)
|
229
|
+
import_zod.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS)
|
230
|
+
]);
|
231
|
+
var OrganisationScopes = import_zod.z.union([
|
205
232
|
import_zod.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
|
206
233
|
import_zod.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
|
207
|
-
import_zod.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION)
|
234
|
+
import_zod.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION)
|
235
|
+
]);
|
236
|
+
var UserScopes = import_zod.z.union([
|
208
237
|
import_zod.z.literal(SCOPES.USER_READ),
|
209
238
|
import_zod.z.literal(SCOPES.USER_READ_MY_OFFICE),
|
210
239
|
import_zod.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
|
@@ -212,11 +241,29 @@ var LiteralScopes = import_zod.z.union([
|
|
212
241
|
import_zod.z.literal(SCOPES.USER_CREATE),
|
213
242
|
import_zod.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
|
214
243
|
import_zod.z.literal(SCOPES.USER_UPDATE),
|
215
|
-
import_zod.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION)
|
216
|
-
|
217
|
-
|
244
|
+
import_zod.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION)
|
245
|
+
]);
|
246
|
+
var ConfigScope = import_zod.z.literal(SCOPES.CONFIG_UPDATE_ALL);
|
247
|
+
var DataSeedingScope = import_zod.z.literal(SCOPES.USER_DATA_SEEDING);
|
248
|
+
var LiteralScopes = import_zod.z.union([
|
249
|
+
LegacyScopes,
|
250
|
+
IntegrationScopes,
|
251
|
+
UnassignScope,
|
252
|
+
DeclareScopes,
|
253
|
+
ValidateScopes,
|
254
|
+
RegisterScope,
|
255
|
+
CertifyScopes,
|
256
|
+
CorrectionScopes,
|
257
|
+
SearchScopes,
|
258
|
+
AuditScopes,
|
259
|
+
ProfileScopes,
|
260
|
+
PerformanceScopes,
|
261
|
+
OrganisationScopes,
|
262
|
+
UserScopes,
|
263
|
+
ConfigScope,
|
264
|
+
DataSeedingScope
|
218
265
|
]);
|
219
|
-
var rawConfigurableScopeRegex = /^([a-zA-Z]
|
266
|
+
var rawConfigurableScopeRegex = /^([a-zA-Z\.]+)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
|
220
267
|
var rawConfigurableScope = import_zod.z.string().regex(rawConfigurableScopeRegex);
|
221
268
|
var CreateUserScope = import_zod.z.object({
|
222
269
|
type: import_zod.z.literal("user.create"),
|
@@ -230,15 +277,63 @@ var EditUserScope = import_zod.z.object({
|
|
230
277
|
role: import_zod.z.array(import_zod.z.string())
|
231
278
|
})
|
232
279
|
});
|
233
|
-
var
|
280
|
+
var WorkqueueScope = import_zod.z.object({
|
281
|
+
type: import_zod.z.literal("workqueue"),
|
282
|
+
options: import_zod.z.object({
|
283
|
+
id: import_zod.z.array(import_zod.z.string())
|
284
|
+
})
|
285
|
+
});
|
286
|
+
var NotifyRecordScope = import_zod.z.object({
|
287
|
+
type: import_zod.z.literal("record.notify"),
|
288
|
+
options: import_zod.z.object({
|
289
|
+
event: import_zod.z.array(import_zod.z.string())
|
290
|
+
})
|
291
|
+
});
|
292
|
+
var SearchScope = import_zod.z.object({
|
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,
|
234
301
|
CreateUserScope,
|
235
|
-
EditUserScope
|
302
|
+
EditUserScope,
|
303
|
+
WorkqueueScope,
|
304
|
+
NotifyRecordScope
|
236
305
|
]);
|
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
|
+
}
|
237
321
|
function findScope(scopes2, scopeType) {
|
238
|
-
|
239
|
-
|
322
|
+
const parsedScopes = scopes2.map((rawScope) => parseScope(rawScope));
|
323
|
+
const searchScopes = parsedScopes.filter((scope) => scope?.type === "search");
|
324
|
+
const otherScopes = parsedScopes.filter((scope) => scope?.type !== "search");
|
325
|
+
const mergedSearchScope = flattenAndMergeScopes(searchScopes);
|
326
|
+
return [...otherScopes, mergedSearchScope].find(
|
327
|
+
(scope) => scope?.type === scopeType
|
240
328
|
);
|
241
329
|
}
|
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
|
+
}
|
242
337
|
function parseScope(scope) {
|
243
338
|
const maybeLiteralScope = LiteralScopes.safeParse(scope);
|
244
339
|
if (maybeLiteralScope.success) {
|
@@ -247,23 +342,28 @@ function parseScope(scope) {
|
|
247
342
|
};
|
248
343
|
}
|
249
344
|
const maybeConfigurableScope = rawConfigurableScope.safeParse(scope);
|
250
|
-
if (maybeConfigurableScope.success) {
|
251
|
-
|
252
|
-
const [, type, rawOptions] = rawScope.match(rawConfigurableScopeRegex) ?? [];
|
253
|
-
const options = rawOptions.split(",").reduce((acc, option) => {
|
254
|
-
const [key, value] = option.split("=");
|
255
|
-
acc[key] = value.split("|");
|
256
|
-
return acc;
|
257
|
-
}, {});
|
258
|
-
const parsedScope = {
|
259
|
-
type,
|
260
|
-
options
|
261
|
-
};
|
262
|
-
const result = ConfigurableScopes.safeParse(parsedScope);
|
263
|
-
if (result.success) {
|
264
|
-
return result.data;
|
265
|
-
}
|
345
|
+
if (!maybeConfigurableScope.success) {
|
346
|
+
return;
|
266
347
|
}
|
267
|
-
|
348
|
+
const rawScope = maybeConfigurableScope.data;
|
349
|
+
const [, type, rawOptions] = rawScope.match(rawConfigurableScopeRegex) ?? [];
|
350
|
+
const options = getScopeOptions(rawOptions);
|
351
|
+
const parsedScope = {
|
352
|
+
type,
|
353
|
+
options
|
354
|
+
};
|
355
|
+
const result = ConfigurableRawScopes.safeParse(parsedScope);
|
356
|
+
return result.success ? result.data : void 0;
|
357
|
+
}
|
358
|
+
function stringifyScope(scope) {
|
359
|
+
const options = Object.entries(scope.options).map(([key, value]) => `${key}=${value.join("|")}`).join(",");
|
360
|
+
return `${scope.type}[${options}]`;
|
268
361
|
}
|
269
362
|
var scopes = Object.values(SCOPES);
|
363
|
+
var ActionScopes = import_zod.z.union([
|
364
|
+
DeclareScopes,
|
365
|
+
ValidateScopes,
|
366
|
+
RegisterScope,
|
367
|
+
CertifyScopes,
|
368
|
+
CorrectionScopes
|
369
|
+
]);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@opencrvs/toolkit",
|
3
|
-
"version": "1.8.1-rc.
|
3
|
+
"version": "1.8.1-rc.bbbfede",
|
4
4
|
"description": "OpenCRVS toolkit for building country configurations",
|
5
5
|
"license": "MPL-2.0",
|
6
6
|
"exports": {
|
@@ -19,8 +19,9 @@
|
|
19
19
|
"ajv": "^8.17.1",
|
20
20
|
"ajv-formats": "^3.0.1",
|
21
21
|
"superjson": "1.9.0-0",
|
22
|
-
"@trpc/client": "
|
23
|
-
"@trpc/server": "
|
22
|
+
"@trpc/client": "11.4.3",
|
23
|
+
"@trpc/server": "11.4.3",
|
24
|
+
"zod-openapi": "^4.2.4"
|
24
25
|
},
|
25
26
|
"devDependencies": {
|
26
27
|
"@types/uuid": "^9.0.3",
|