@opencrvs/toolkit 2.0.0-rc.dd19028 → 2.0.0-rc.ddf354d

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 (52) 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 +36 -35
  4. package/dist/cli.js +507 -171
  5. package/dist/commons/api/router.d.ts +3334 -271
  6. package/dist/commons/application-config/index.d.ts +16 -4
  7. package/dist/commons/conditionals/conditionals.d.ts +3 -3
  8. package/dist/commons/conditionals/validate.d.ts +1 -0
  9. package/dist/commons/events/ActionInput.d.ts +108 -0
  10. package/dist/commons/events/Draft.d.ts +3 -0
  11. package/dist/commons/events/EventIndex.d.ts +0 -3
  12. package/dist/commons/events/EventMetadata.d.ts +0 -7
  13. package/dist/commons/events/FieldConfig.d.ts +5 -0
  14. package/dist/commons/events/WorkqueueConfig.d.ts +146 -146
  15. package/dist/commons/events/locations.d.ts +21 -0
  16. package/dist/commons/events/mocks.test.utils.d.ts +19 -0
  17. package/dist/commons/events/scopes.d.ts +24 -1
  18. package/dist/commons/events/state/index.d.ts +0 -4
  19. package/dist/commons/events/state/utils.d.ts +0 -2
  20. package/dist/commons/events/utils.d.ts +1 -1
  21. package/dist/conditionals/index.js +8 -4
  22. package/dist/events/index.js +114 -79
  23. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -1
  24. package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +60 -35
  25. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +1 -1
  26. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  27. package/dist/migrations/v2.0/checkout-upstream-files.js +1 -2
  28. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +9 -1
  29. package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -1
  30. package/dist/migrations/v2.0/delete-infrastructure-directory.js +66 -20
  31. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts +3 -0
  32. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts.map +1 -0
  33. package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.js +110 -0
  34. package/dist/migrations/v2.0/index.d.ts +5 -3
  35. package/dist/migrations/v2.0/index.d.ts.map +1 -1
  36. package/dist/migrations/v2.0/index.js +505 -169
  37. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -1
  38. package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +90 -1
  39. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +11 -1
  40. package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -1
  41. package/dist/migrations/v2.0/merge-infrastructure-directory.js +17 -16
  42. package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
  43. package/dist/migrations/v2.0/migrate-scopes.js +54 -30
  44. package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
  45. package/dist/migrations/v2.0/migrate-workqueue-configs.js +140 -59
  46. package/dist/notification/index.js +46 -49
  47. package/dist/scopes/index.d.ts +6 -1
  48. package/dist/scopes/index.js +8 -4
  49. package/opencrvs-toolkit-2.0.0-rc.ddf354d.tgz +0 -0
  50. package/package.json +1 -1
  51. package/tsconfig.tsbuildinfo +1 -1
  52. package/opencrvs-toolkit-2.0.0-rc.dd19028.tgz +0 -0
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env node
2
+
3
+ /*
4
+ * This Source Code Form is subject to the terms of the Mozilla Public
5
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
6
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7
+ *
8
+ * OpenCRVS is also distributed under the terms of the Civil Registration
9
+ * & Healthcare Disclaimer located at http://opencrvs.org/license.
10
+ *
11
+ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
12
+ */
13
+
14
+ const { execSync } = require('child_process')
15
+ const path = require('path')
16
+ const fs = require('fs')
17
+
18
+ const REPO_URL = 'https://github.com/opencrvs/opencrvs-countryconfig.git'
19
+
20
+ const projectName = process.argv[2]
21
+
22
+ if (!projectName) {
23
+ console.error(
24
+ 'Please specify a project name:\n\n npm create @opencrvs/countryconfig <project-name>\n'
25
+ )
26
+ process.exit(1)
27
+ }
28
+
29
+ const targetDir = path.resolve(process.cwd(), projectName)
30
+
31
+ if (fs.existsSync(targetDir)) {
32
+ console.error(`Error: Directory "${projectName}" already exists.`)
33
+ process.exit(1)
34
+ }
35
+
36
+ console.log(`\nScaffolding OpenCRVS country config in ./${projectName}...\n`)
37
+
38
+ try {
39
+ execSync(`git clone --depth 1 ${REPO_URL} ${projectName}`, {
40
+ stdio: 'inherit'
41
+ })
42
+ } catch (err) {
43
+ console.error('Failed to clone the repository:', err.message)
44
+ process.exit(1)
45
+ }
46
+
47
+ try {
48
+ fs.rmSync(path.join(targetDir, '.git'), { recursive: true, force: true })
49
+ } catch (err) {
50
+ console.error('Failed to remove .git directory:', err.message)
51
+ process.exit(1)
52
+ }
53
+
54
+ const pkgPath = path.join(targetDir, 'package.json')
55
+ if (fs.existsSync(pkgPath)) {
56
+ try {
57
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
58
+ pkg.name = projectName
59
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n')
60
+ } catch (err) {
61
+ console.error('Failed to update package.json:', err.message)
62
+ process.exit(1)
63
+ }
64
+ } else {
65
+ console.warn(
66
+ `Warning: No package.json found in the cloned repository. Project name was not updated.`
67
+ )
68
+ }
69
+
70
+ console.log(`\nDone! To get started:\n`)
71
+ console.log(` cd ${projectName}`)
72
+ console.log(` git init`)
73
+ console.log(` npm install\n`)
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "@opencrvs/create-countryconfig",
3
+ "version": "1.0.0",
4
+ "description": "Scaffold a new OpenCRVS country configuration",
5
+ "bin": {
6
+ "create-countryconfig": "./index.js"
7
+ },
8
+ "files": ["index.js"],
9
+ "keywords": ["opencrvs", "countryconfig", "create"],
10
+ "license": "MPL-2.0"
11
+ }
@@ -75,7 +75,10 @@ var ActionConditional = z.discriminatedUnion("type", [
75
75
  ShowConditional,
76
76
  // Action can be shown to the user in the list but as disabled
77
77
  EnableConditional
78
- ]);
78
+ ]).meta({
79
+ description: "Action conditional configuration",
80
+ id: "ActionConditional"
81
+ });
79
82
  var DisplayOnReviewConditional = z.object({
80
83
  type: z.literal(ConditionalType.DISPLAY_ON_REVIEW),
81
84
  conditional: Conditional
@@ -418,28 +421,20 @@ function schemaPriority(schema) {
418
421
  return idx === -1 ? 9999 : idx;
419
422
  }
420
423
  function safeUnion(schemas) {
424
+ const sortedSchemas = [...schemas].sort(
425
+ (a, b) => schemaPriority(a) - schemaPriority(b)
426
+ );
421
427
  return z7.any().superRefine((val, ctx) => {
422
- const successful = schemas.filter((s) => s.safeParse(val).success);
423
- if (successful.length === 1) {
424
- return;
425
- }
426
- if (successful.length === 0) {
427
- ctx.addIssue({
428
- code: "invalid_type",
429
- expected: "custom",
430
- message: "Value does not match any schema"
431
- });
432
- return;
433
- }
434
- successful.sort((a, b) => schemaPriority(a) - schemaPriority(b));
435
- const best = successful[0];
436
- if (!best.safeParse(val).success) {
437
- ctx.addIssue({
438
- expected: "custom",
439
- code: "invalid_type",
440
- message: "Value did not match the best schema"
441
- });
428
+ for (const schema of sortedSchemas) {
429
+ if (schema.safeParse(val).success) {
430
+ return;
431
+ }
442
432
  }
433
+ ctx.addIssue({
434
+ code: "invalid_type",
435
+ expected: "custom",
436
+ message: "Value does not match any schema"
437
+ });
443
438
  }).meta({
444
439
  description: "Value that matches exactly one of the possible schema types (TextValue, DateValue, DateRangeFieldValue). The best matching schema is chosen by priority."
445
440
  });
@@ -772,12 +767,14 @@ var SystemScopeType = z11.enum([
772
767
  "organisation.read-locations",
773
768
  "user.read",
774
769
  "user.create",
775
- "user.edit"
770
+ "user.edit",
771
+ "user.search"
776
772
  ]);
777
773
  var UserScopeType = SystemScopeType.extract([
778
774
  "user.read",
779
775
  "user.create",
780
- "user.edit"
776
+ "user.edit",
777
+ "user.search"
781
778
  ]);
782
779
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
783
780
  var UserScopeV2 = z11.discriminatedUnion("type", [
@@ -786,7 +783,7 @@ var UserScopeV2 = z11.discriminatedUnion("type", [
786
783
  options: AllUserScopeOptions.optional()
787
784
  }),
788
785
  z11.object({
789
- type: UserScopeType.extract(["user.read"]),
786
+ type: UserScopeType.extract(["user.read", "user.search"]),
790
787
  options: AccessLevelOptions.optional()
791
788
  })
792
789
  ]);
@@ -837,7 +834,9 @@ var ScopeType = z11.enum([
837
834
  var EncodedScope = z11.string().brand("EncodedScope");
838
835
  var DEFAULT_SCOPE_OPTIONS = {
839
836
  placeOfEvent: JurisdictionFilter.enum.all,
840
- accessLevel: JurisdictionFilter.enum.all
837
+ accessLevel: JurisdictionFilter.enum.all,
838
+ registeredIn: JurisdictionFilter.enum.all,
839
+ declaredIn: JurisdictionFilter.enum.all
841
840
  };
842
841
 
843
842
  // ../commons/src/authentication.ts
@@ -1083,6 +1082,9 @@ var FlagConfig = z14.object({
1083
1082
  "Indicates if this flag expects an action to be performed to be cleared."
1084
1083
  ),
1085
1084
  label: TranslationConfig.describe("Human readable label of the flag.")
1085
+ }).meta({
1086
+ description: "Flag configuration",
1087
+ id: "FlagConfig"
1086
1088
  });
1087
1089
  var ActionFlagConfig = z14.object({
1088
1090
  id: Flag,
@@ -1090,6 +1092,9 @@ var ActionFlagConfig = z14.object({
1090
1092
  conditional: Conditional.optional().describe(
1091
1093
  "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
1092
1094
  )
1095
+ }).meta({
1096
+ description: "Action flag configuration",
1097
+ id: "ActionFlagConfig"
1093
1098
  });
1094
1099
 
1095
1100
  // ../commons/src/events/EventMetadata.ts
@@ -1111,8 +1116,7 @@ var ActionCreationMetadata = z15.object({
1111
1116
  ),
1112
1117
  createdByUserType: z15.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1113
1118
  acceptedAt: z15.iso.datetime().describe("Timestamp when the action request was accepted."),
1114
- createdByRole: z15.string().optional().describe("Role of the user at the time of action request creation."),
1115
- createdBySignature: z15.string().nullish().describe("Signature of the user who created the action request.")
1119
+ createdByRole: z15.string().optional().describe("Role of the user at the time of action request creation.")
1116
1120
  });
1117
1121
  var RegistrationCreationMetadata = ActionCreationMetadata.extend({
1118
1122
  registrationNumber: z15.string().describe(
@@ -1140,9 +1144,6 @@ var EventMetadata = z15.object({
1140
1144
  createdAtLocation: UUID.nullish().describe(
1141
1145
  "Location of the user who created the event."
1142
1146
  ),
1143
- createdBySignature: DocumentPath.nullish().describe(
1144
- "Signature of the user who created the event."
1145
- ),
1146
1147
  updatedAtLocation: UUID.nullish().describe(
1147
1148
  "Location of the user who last changed the status."
1148
1149
  ),
@@ -1406,7 +1407,7 @@ var FieldId = import_v43.default.string().superRefine((val, ctx) => {
1406
1407
  }
1407
1408
  }).describe("Unique identifier for the field");
1408
1409
  var FieldReference = import_v43.default.object({
1409
- $$field: FieldId,
1410
+ $$field: FieldId.describe("Id of the field to reference"),
1410
1411
  $$subfield: import_v43.default.array(import_v43.default.string()).optional().default([]).describe(
1411
1412
  'If the FieldValue is an object, subfield can be used to refer to e.g. `["foo", "bar"]` in `{ foo: { bar: 3 } }`'
1412
1413
  )
@@ -2106,8 +2107,8 @@ var ApplicationConfig = z20.object({
2106
2107
  })
2107
2108
  ),
2108
2109
  PHONE_NUMBER_PATTERN: z20.string().or(z20.instanceof(RegExp)),
2109
- USER_NOTIFICATION_DELIVERY_METHOD: z20.string(),
2110
- INFORMANT_NOTIFICATION_DELIVERY_METHOD: z20.string(),
2110
+ USER_NOTIFICATION_DELIVERY_METHOD: z20.enum(["email", "sms"]),
2111
+ INFORMANT_NOTIFICATION_DELIVERY_METHOD: z20.enum(["email", "sms"]),
2111
2112
  SEARCH_DEFAULT_CRITERIA: SearchCriteria.optional().default("TRACKING_ID"),
2112
2113
  ADDITIONAL_USER_FIELDS: z20.array(FieldConfig).optional().default([])
2113
2114
  });
@@ -2125,8 +2126,8 @@ var BackgroundConfig = z20.object({
2125
2126
  var LoginConfig = z20.object({
2126
2127
  COUNTRY: z20.string(),
2127
2128
  LANGUAGES: z20.array(z20.string()),
2128
- USER_NOTIFICATION_DELIVERY_METHOD: z20.string(),
2129
- INFORMANT_NOTIFICATION_DELIVERY_METHOD: z20.string(),
2129
+ USER_NOTIFICATION_DELIVERY_METHOD: z20.enum(["email", "sms"]),
2130
+ INFORMANT_NOTIFICATION_DELIVERY_METHOD: z20.enum(["email", "sms"]),
2130
2131
  PHONE_NUMBER_PATTERN: z20.string().or(z20.instanceof(RegExp)),
2131
2132
  LOGIN_BACKGROUND: BackgroundConfig,
2132
2133
  SENTRY: z20.string().optional()