@opencrvs/toolkit 1.8.0-rc.ffe8c17 → 1.8.1-rc.a372970

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.
Files changed (33) hide show
  1. package/README.md +1 -1
  2. package/dist/commons/api/router.d.ts +6644 -9555
  3. package/dist/commons/conditionals/conditionals.d.ts +26 -3
  4. package/dist/commons/conditionals/validate-address.test.d.ts +2 -0
  5. package/dist/commons/conditionals/validate.d.ts +14 -17
  6. package/dist/commons/events/ActionConfig.d.ts +1008 -3209
  7. package/dist/commons/events/ActionDocument.d.ts +9488 -312
  8. package/dist/commons/events/ActionInput.d.ts +5329 -472
  9. package/dist/commons/events/ActionType.d.ts +26 -11
  10. package/dist/commons/events/CompositeFieldValue.d.ts +152 -2
  11. package/dist/commons/events/Conditional.d.ts +21 -5
  12. package/dist/commons/events/Draft.d.ts +351 -48
  13. package/dist/commons/events/EventConfig.d.ts +639 -2862
  14. package/dist/commons/events/EventConfigInput.d.ts +6 -3
  15. package/dist/commons/events/EventDocument.d.ts +3340 -424
  16. package/dist/commons/events/EventIndex.d.ts +6 -3
  17. package/dist/commons/events/EventMetadata.d.ts +3 -0
  18. package/dist/commons/events/FieldConfig.d.ts +383 -104
  19. package/dist/commons/events/FieldTypeMapping.d.ts +104 -207
  20. package/dist/commons/events/FieldValue.d.ts +71 -76
  21. package/dist/commons/events/FormConfig.d.ts +527 -279
  22. package/dist/commons/events/PageConfig.d.ts +335 -0
  23. package/dist/commons/events/TemplateConfig.d.ts +5 -5
  24. package/dist/commons/events/defineConfig.d.ts +40 -417
  25. package/dist/commons/events/index.d.ts +2 -1
  26. package/dist/commons/events/test.utils.d.ts +140 -213
  27. package/dist/commons/events/utils.d.ts +126 -156
  28. package/dist/commons/events/utils.test.d.ts +2 -0
  29. package/dist/conditionals/index.js +166 -81
  30. package/dist/events/index.js +1287 -795
  31. package/dist/scopes/index.d.ts +70 -1
  32. package/dist/scopes/index.js +130 -0
  33. package/package.json +1 -1
@@ -1,3 +1,4 @@
1
+ import { z } from 'zod';
1
2
  export declare const SCOPES: {
2
3
  readonly NATLSYSADMIN: "natlsysadmin";
3
4
  readonly BYPASSRATELIMIT: "bypassratelimit";
@@ -83,6 +84,74 @@ export declare const SCOPES: {
83
84
  readonly CONFIG_UPDATE_ALL: "config.update:all";
84
85
  readonly USER_DATA_SEEDING: "user.data-seeding";
85
86
  };
86
- export type Scope = (typeof SCOPES)[keyof typeof SCOPES];
87
+ declare const LiteralScopes: 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.ZodLiteral<"webhook">, z.ZodLiteral<"nationalId">, z.ZodLiteral<"notification-api">, z.ZodLiteral<"recordsearch">, 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.ZodLiteral<"record.unassign-others">, 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.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.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.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.ZodLiteral<"record.read">, z.ZodLiteral<"record.read-audit">, z.ZodLiteral<"record.read-comments">, z.ZodLiteral<"record.create-comments">, z.ZodLiteral<"profile.update">, z.ZodLiteral<"profile.electronic-signature">, z.ZodLiteral<"performance.read">, z.ZodLiteral<"performance.read-dashboards">, z.ZodLiteral<"performance.vital-statistics-export">, z.ZodLiteral<"organisation.read-locations:all">, z.ZodLiteral<"organisation.read-locations:my-office">, z.ZodLiteral<"organisation.read-locations:my-jurisdiction">, 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">]>;
88
+ declare const ConfigurableScopes: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
89
+ type: z.ZodLiteral<"user.create">;
90
+ options: z.ZodObject<{
91
+ role: z.ZodArray<z.ZodString, "many">;
92
+ }, "strip", z.ZodTypeAny, {
93
+ role: string[];
94
+ }, {
95
+ role: string[];
96
+ }>;
97
+ }, "strip", z.ZodTypeAny, {
98
+ type: "user.create";
99
+ options: {
100
+ role: string[];
101
+ };
102
+ }, {
103
+ type: "user.create";
104
+ options: {
105
+ role: string[];
106
+ };
107
+ }>, z.ZodObject<{
108
+ type: z.ZodLiteral<"user.edit">;
109
+ options: z.ZodObject<{
110
+ role: z.ZodArray<z.ZodString, "many">;
111
+ }, "strip", z.ZodTypeAny, {
112
+ role: string[];
113
+ }, {
114
+ role: string[];
115
+ }>;
116
+ }, "strip", z.ZodTypeAny, {
117
+ type: "user.edit";
118
+ options: {
119
+ role: string[];
120
+ };
121
+ }, {
122
+ type: "user.edit";
123
+ options: {
124
+ role: string[];
125
+ };
126
+ }>]>;
127
+ type ConfigurableScopes = z.infer<typeof ConfigurableScopes>;
128
+ export declare function findScope(scopes: string[], scopeType: ConfigurableScopes['type']): {
129
+ type: "user.create";
130
+ options: {
131
+ role: string[];
132
+ };
133
+ } | {
134
+ type: "user.edit";
135
+ options: {
136
+ role: string[];
137
+ };
138
+ } | undefined;
139
+ export declare function parseScope(scope: string): {
140
+ type: "user.create";
141
+ options: {
142
+ role: string[];
143
+ };
144
+ } | {
145
+ type: "user.edit";
146
+ options: {
147
+ role: string[];
148
+ };
149
+ } | {
150
+ type: "natlsysadmin" | "bypassratelimit" | "declare" | "register" | "validate" | "demo" | "certify" | "performance" | "sysadmin" | "teams" | "config" | "webhook" | "nationalId" | "notification-api" | "recordsearch" | "record.declare-birth" | "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
+ } | undefined;
87
152
  export declare const scopes: Scope[];
153
+ export type ParsedScopes = NonNullable<ReturnType<typeof parseScope>>;
154
+ export type RawScopes = z.infer<typeof LiteralScopes> | (string & {});
155
+ export type Scope = RawScopes;
156
+ export {};
88
157
  //# sourceMappingURL=scopes.d.ts.map
@@ -21,11 +21,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var scopes_exports = {};
22
22
  __export(scopes_exports, {
23
23
  SCOPES: () => SCOPES,
24
+ findScope: () => findScope,
25
+ parseScope: () => parseScope,
24
26
  scopes: () => scopes
25
27
  });
26
28
  module.exports = __toCommonJS(scopes_exports);
27
29
 
28
30
  // ../commons/src/scopes.ts
31
+ var import_zod = require("zod");
29
32
  var SCOPES = {
30
33
  // TODO v1.8 legacy scopes
31
34
  NATLSYSADMIN: "natlsysadmin",
@@ -136,4 +139,131 @@ var SCOPES = {
136
139
  // data seeding
137
140
  USER_DATA_SEEDING: "user.data-seeding"
138
141
  };
142
+ var LiteralScopes = import_zod.z.union([
143
+ import_zod.z.literal(SCOPES.NATLSYSADMIN),
144
+ import_zod.z.literal(SCOPES.BYPASSRATELIMIT),
145
+ import_zod.z.literal(SCOPES.DECLARE),
146
+ import_zod.z.literal(SCOPES.REGISTER),
147
+ import_zod.z.literal(SCOPES.VALIDATE),
148
+ import_zod.z.literal(SCOPES.DEMO),
149
+ import_zod.z.literal(SCOPES.CERTIFY),
150
+ import_zod.z.literal(SCOPES.PERFORMANCE),
151
+ import_zod.z.literal(SCOPES.SYSADMIN),
152
+ import_zod.z.literal(SCOPES.TEAMS),
153
+ import_zod.z.literal(SCOPES.CONFIG),
154
+ import_zod.z.literal(SCOPES.WEBHOOK),
155
+ import_zod.z.literal(SCOPES.NATIONALID),
156
+ import_zod.z.literal(SCOPES.NOTIFICATION_API),
157
+ import_zod.z.literal(SCOPES.RECORDSEARCH),
158
+ import_zod.z.literal(SCOPES.RECORD_DECLARE_BIRTH),
159
+ import_zod.z.literal(SCOPES.RECORD_DECLARE_BIRTH_MY_JURISDICTION),
160
+ import_zod.z.literal(SCOPES.RECORD_DECLARE_DEATH),
161
+ import_zod.z.literal(SCOPES.RECORD_DECLARE_DEATH_MY_JURISDICTION),
162
+ import_zod.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE),
163
+ import_zod.z.literal(SCOPES.RECORD_DECLARE_MARRIAGE_MY_JURISDICTION),
164
+ import_zod.z.literal(SCOPES.RECORD_SUBMIT_INCOMPLETE),
165
+ import_zod.z.literal(SCOPES.RECORD_SUBMIT_FOR_REVIEW),
166
+ import_zod.z.literal(SCOPES.RECORD_UNASSIGN_OTHERS),
167
+ import_zod.z.literal(SCOPES.RECORD_SUBMIT_FOR_APPROVAL),
168
+ import_zod.z.literal(SCOPES.RECORD_SUBMIT_FOR_UPDATES),
169
+ import_zod.z.literal(SCOPES.RECORD_DECLARATION_EDIT),
170
+ import_zod.z.literal(SCOPES.RECORD_REVIEW_DUPLICATES),
171
+ import_zod.z.literal(SCOPES.RECORD_DECLARATION_ARCHIVE),
172
+ import_zod.z.literal(SCOPES.RECORD_DECLARATION_REINSTATE),
173
+ import_zod.z.literal(SCOPES.RECORD_REGISTER),
174
+ import_zod.z.literal(SCOPES.RECORD_EXPORT_RECORDS),
175
+ import_zod.z.literal(SCOPES.RECORD_DECLARATION_PRINT),
176
+ import_zod.z.literal(SCOPES.RECORD_PRINT_RECORDS_SUPPORTING_DOCUMENTS),
177
+ import_zod.z.literal(SCOPES.RECORD_REGISTRATION_PRINT),
178
+ import_zod.z.literal(SCOPES.RECORD_PRINT_ISSUE_CERTIFIED_COPIES),
179
+ import_zod.z.literal(SCOPES.RECORD_PRINT_CERTIFIED_COPIES),
180
+ import_zod.z.literal(SCOPES.RECORD_BULK_PRINT_CERTIFIED_COPIES),
181
+ import_zod.z.literal(SCOPES.RECORD_REGISTRATION_VERIFY_CERTIFIED_COPIES),
182
+ import_zod.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_CORRECTION),
183
+ import_zod.z.literal(SCOPES.RECORD_REGISTRATION_CORRECT),
184
+ import_zod.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REVOCATION),
185
+ import_zod.z.literal(SCOPES.RECORD_REGISTRATION_REVOKE),
186
+ import_zod.z.literal(SCOPES.RECORD_REGISTRATION_REQUEST_REINSTATEMENT),
187
+ import_zod.z.literal(SCOPES.RECORD_REGISTRATION_REINSTATE),
188
+ import_zod.z.literal(SCOPES.RECORD_CONFIRM_REGISTRATION),
189
+ import_zod.z.literal(SCOPES.RECORD_REJECT_REGISTRATION),
190
+ import_zod.z.literal(SCOPES.SEARCH_BIRTH_MY_JURISDICTION),
191
+ import_zod.z.literal(SCOPES.SEARCH_BIRTH),
192
+ import_zod.z.literal(SCOPES.SEARCH_DEATH_MY_JURISDICTION),
193
+ import_zod.z.literal(SCOPES.SEARCH_DEATH),
194
+ import_zod.z.literal(SCOPES.SEARCH_MARRIAGE_MY_JURISDICTION),
195
+ import_zod.z.literal(SCOPES.SEARCH_MARRIAGE),
196
+ import_zod.z.literal(SCOPES.RECORD_READ),
197
+ import_zod.z.literal(SCOPES.RECORD_READ_AUDIT),
198
+ import_zod.z.literal(SCOPES.RECORD_READ_COMMENTS),
199
+ import_zod.z.literal(SCOPES.RECORD_CREATE_COMMENTS),
200
+ import_zod.z.literal(SCOPES.PROFILE_UPDATE),
201
+ import_zod.z.literal(SCOPES.PROFILE_ELECTRONIC_SIGNATURE),
202
+ import_zod.z.literal(SCOPES.PERFORMANCE_READ),
203
+ import_zod.z.literal(SCOPES.PERFORMANCE_READ_DASHBOARDS),
204
+ import_zod.z.literal(SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS),
205
+ import_zod.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS),
206
+ import_zod.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE),
207
+ import_zod.z.literal(SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION),
208
+ import_zod.z.literal(SCOPES.USER_READ),
209
+ import_zod.z.literal(SCOPES.USER_READ_MY_OFFICE),
210
+ import_zod.z.literal(SCOPES.USER_READ_MY_JURISDICTION),
211
+ import_zod.z.literal(SCOPES.USER_READ_ONLY_MY_AUDIT),
212
+ import_zod.z.literal(SCOPES.USER_CREATE),
213
+ import_zod.z.literal(SCOPES.USER_CREATE_MY_JURISDICTION),
214
+ import_zod.z.literal(SCOPES.USER_UPDATE),
215
+ import_zod.z.literal(SCOPES.USER_UPDATE_MY_JURISDICTION),
216
+ import_zod.z.literal(SCOPES.CONFIG_UPDATE_ALL),
217
+ import_zod.z.literal(SCOPES.USER_DATA_SEEDING)
218
+ ]);
219
+ var rawConfigurableScopeRegex = /^([a-zA-Z]+\.[a-zA-Z]+)\[((?:\w+=\w+(?:\|\w+)*)(:?,\w+=\w+(?:\|\w+)*)*)\]$/;
220
+ var rawConfigurableScope = import_zod.z.string().regex(rawConfigurableScopeRegex);
221
+ var CreateUserScope = import_zod.z.object({
222
+ type: import_zod.z.literal("user.create"),
223
+ options: import_zod.z.object({
224
+ role: import_zod.z.array(import_zod.z.string())
225
+ })
226
+ });
227
+ var EditUserScope = import_zod.z.object({
228
+ type: import_zod.z.literal("user.edit"),
229
+ options: import_zod.z.object({
230
+ role: import_zod.z.array(import_zod.z.string())
231
+ })
232
+ });
233
+ var ConfigurableScopes = import_zod.z.discriminatedUnion("type", [
234
+ CreateUserScope,
235
+ EditUserScope
236
+ ]);
237
+ function findScope(scopes2, scopeType) {
238
+ return scopes2.map((rawScope) => parseScope(rawScope)).find(
239
+ (parsedScope) => parsedScope?.type === scopeType
240
+ );
241
+ }
242
+ function parseScope(scope) {
243
+ const maybeLiteralScope = LiteralScopes.safeParse(scope);
244
+ if (maybeLiteralScope.success) {
245
+ return {
246
+ type: maybeLiteralScope.data
247
+ };
248
+ }
249
+ const maybeConfigurableScope = rawConfigurableScope.safeParse(scope);
250
+ if (maybeConfigurableScope.success) {
251
+ const rawScope = maybeConfigurableScope.data;
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
+ }
266
+ }
267
+ return void 0;
268
+ }
139
269
  var scopes = Object.values(SCOPES);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/toolkit",
3
- "version": "1.8.0-rc.ffe8c17",
3
+ "version": "1.8.1-rc.a372970",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "exports": {