@opencrvs/toolkit 2.0.0-rc.b2d066a → 2.0.0-rc.b414697

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 (42) hide show
  1. package/create-countryconfig/index.js +73 -0
  2. package/create-countryconfig/package.json +11 -0
  3. package/dist/application-config/index.js +17 -23
  4. package/dist/cli.js +410 -165
  5. package/dist/commons/api/router.d.ts +2901 -163
  6. package/dist/commons/conditionals/conditionals.d.ts +3 -3
  7. package/dist/commons/conditionals/validate.d.ts +1 -0
  8. package/dist/commons/events/ActionInput.d.ts +108 -0
  9. package/dist/commons/events/Draft.d.ts +3 -0
  10. package/dist/commons/events/FieldConfig.d.ts +5 -0
  11. package/dist/commons/events/locations.d.ts +21 -0
  12. package/dist/commons/events/mocks.test.utils.d.ts +19 -0
  13. package/dist/commons/events/scopes.d.ts +24 -1
  14. package/dist/commons/events/utils.d.ts +1 -1
  15. package/dist/conditionals/index.js +5 -3
  16. package/dist/events/index.js +88 -37
  17. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -1
  18. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +60 -35
  19. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +1 -1
  20. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  21. package/dist/migrations/v2.0/checkout-upstream-files.js +1 -2
  22. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +9 -1
  23. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -1
  24. package/dist/migrations/v2.0/delete-infrastructure-directory.js +66 -20
  25. package/dist/migrations/v2.0/index.d.ts +5 -3
  26. package/dist/migrations/v2.0/index.d.ts.map +1 -1
  27. package/dist/migrations/v2.0/index.js +410 -165
  28. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -1
  29. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +90 -1
  30. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +11 -1
  31. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -1
  32. package/dist/migrations/v2.0/merge-infrastructure-directory.js +17 -16
  33. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
  34. package/dist/migrations/v2.0/migrate-scopes.js +54 -30
  35. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
  36. package/dist/migrations/v2.0/migrate-workqueue-configs.js +140 -59
  37. package/dist/notification/index.js +20 -23
  38. package/dist/scopes/index.d.ts +6 -1
  39. package/dist/scopes/index.js +5 -3
  40. package/opencrvs-toolkit-2.0.0-rc.b414697.tgz +0 -0
  41. package/package.json +1 -1
  42. package/opencrvs-toolkit-2.0.0-rc.b2d066a.tgz +0 -0
@@ -226,12 +226,14 @@ var SystemScopeType = z2.enum([
226
226
  "organisation.read-locations",
227
227
  "user.read",
228
228
  "user.create",
229
- "user.edit"
229
+ "user.edit",
230
+ "user.search"
230
231
  ]);
231
232
  var UserScopeType = SystemScopeType.extract([
232
233
  "user.read",
233
234
  "user.create",
234
- "user.edit"
235
+ "user.edit",
236
+ "user.search"
235
237
  ]);
236
238
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
237
239
  var UserScopeV2 = z2.discriminatedUnion("type", [
@@ -240,7 +242,7 @@ var UserScopeV2 = z2.discriminatedUnion("type", [
240
242
  options: AllUserScopeOptions.optional()
241
243
  }),
242
244
  z2.object({
243
- type: UserScopeType.extract(["user.read"]),
245
+ type: UserScopeType.extract(["user.read", "user.search"]),
244
246
  options: AccessLevelOptions.optional()
245
247
  })
246
248
  ]);
@@ -978,28 +980,20 @@ function schemaPriority(schema) {
978
980
  return idx === -1 ? 9999 : idx;
979
981
  }
980
982
  function safeUnion(schemas) {
983
+ const sortedSchemas = [...schemas].sort(
984
+ (a, b) => schemaPriority(a) - schemaPriority(b)
985
+ );
981
986
  return z12.any().superRefine((val, ctx) => {
982
- const successful = schemas.filter((s) => s.safeParse(val).success);
983
- if (successful.length === 1) {
984
- return;
985
- }
986
- if (successful.length === 0) {
987
- ctx.addIssue({
988
- code: "invalid_type",
989
- expected: "custom",
990
- message: "Value does not match any schema"
991
- });
992
- return;
993
- }
994
- successful.sort((a, b) => schemaPriority(a) - schemaPriority(b));
995
- const best = successful[0];
996
- if (!best.safeParse(val).success) {
997
- ctx.addIssue({
998
- expected: "custom",
999
- code: "invalid_type",
1000
- message: "Value did not match the best schema"
1001
- });
987
+ for (const schema of sortedSchemas) {
988
+ if (schema.safeParse(val).success) {
989
+ return;
990
+ }
1002
991
  }
992
+ ctx.addIssue({
993
+ code: "invalid_type",
994
+ expected: "custom",
995
+ message: "Value does not match any schema"
996
+ });
1003
997
  }).meta({
1004
998
  description: "Value that matches exactly one of the possible schema types (TextValue, DateValue, DateRangeFieldValue). The best matching schema is chosen by priority."
1005
999
  });
@@ -4178,6 +4172,9 @@ var BaseActionInput = z38.object({
4178
4172
  originalActionId: UUID.optional(),
4179
4173
  // should not be part of base action.
4180
4174
  keepAssignment: z38.boolean().optional(),
4175
+ keepAssignmentIfAccepted: z38.boolean().optional(),
4176
+ keepAssignmentIfRejected: z38.boolean().optional(),
4177
+ waitFor: z38.boolean().optional(),
4181
4178
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
4182
4179
  // @TODO: createdAtLocation should be limited to actions that system users can perform. For normal users, it should not be part of the base action.
4183
4180
  createdAtLocation: UUID.nullish().describe(
@@ -227,12 +227,14 @@ declare const SystemScopeType: z.ZodEnum<{
227
227
  "user.read": "user.read";
228
228
  "user.create": "user.create";
229
229
  "user.edit": "user.edit";
230
+ "user.search": "user.search";
230
231
  }>;
231
232
  export type SystemScopeType = z.infer<typeof SystemScopeType>;
232
233
  declare const UserScopeType: z.ZodEnum<{
233
234
  "user.read": "user.read";
234
235
  "user.create": "user.create";
235
236
  "user.edit": "user.edit";
237
+ "user.search": "user.search";
236
238
  }>;
237
239
  export type UserScopeType = z.infer<typeof UserScopeType>;
238
240
  declare const ScopesWithRoleOption: z.ZodEnum<{
@@ -256,6 +258,7 @@ export declare const UserScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
256
258
  }, z.core.$strip>, z.ZodObject<{
257
259
  type: z.ZodEnum<{
258
260
  "user.read": "user.read";
261
+ "user.search": "user.search";
259
262
  }>;
260
263
  options: z.ZodOptional<z.ZodObject<{
261
264
  accessLevel: z.ZodOptional<z.ZodEnum<{
@@ -493,6 +496,7 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
493
496
  }, z.core.$strip>, z.ZodObject<{
494
497
  type: z.ZodEnum<{
495
498
  "user.read": "user.read";
499
+ "user.search": "user.search";
496
500
  }>;
497
501
  options: z.ZodOptional<z.ZodObject<{
498
502
  accessLevel: z.ZodOptional<z.ZodEnum<{
@@ -556,6 +560,7 @@ export declare const ScopeType: z.ZodEnum<{
556
560
  "user.read": "user.read";
557
561
  "user.create": "user.create";
558
562
  "user.edit": "user.edit";
563
+ "user.search": "user.search";
559
564
  workqueue: "workqueue";
560
565
  "dashboard.view": "dashboard.view";
561
566
  }>;
@@ -635,7 +640,7 @@ export declare const decodeScope: (query: EncodedScope) => {
635
640
  role?: string[] | undefined;
636
641
  } | undefined;
637
642
  } | {
638
- type: "user.read";
643
+ type: "user.read" | "user.search";
639
644
  options?: {
640
645
  accessLevel?: "administrativeArea" | "location" | "all" | undefined;
641
646
  } | undefined;
@@ -257,12 +257,14 @@ var SystemScopeType = z3.enum([
257
257
  "organisation.read-locations",
258
258
  "user.read",
259
259
  "user.create",
260
- "user.edit"
260
+ "user.edit",
261
+ "user.search"
261
262
  ]);
262
263
  var UserScopeType = SystemScopeType.extract([
263
264
  "user.read",
264
265
  "user.create",
265
- "user.edit"
266
+ "user.edit",
267
+ "user.search"
266
268
  ]);
267
269
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
268
270
  var UserScopeV2 = z3.discriminatedUnion("type", [
@@ -271,7 +273,7 @@ var UserScopeV2 = z3.discriminatedUnion("type", [
271
273
  options: AllUserScopeOptions.optional()
272
274
  }),
273
275
  z3.object({
274
- type: UserScopeType.extract(["user.read"]),
276
+ type: UserScopeType.extract(["user.read", "user.search"]),
275
277
  options: AccessLevelOptions.optional()
276
278
  })
277
279
  ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/toolkit",
3
- "version": "2.0.0-rc.b2d066a",
3
+ "version": "2.0.0-rc.b414697",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "bin": {