@opencrvs/toolkit 2.0.0-rc.cb6a4d5 → 2.0.0-rc.cc79560

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.
@@ -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
@@ -831,7 +834,9 @@ var ScopeType = z11.enum([
831
834
  var EncodedScope = z11.string().brand("EncodedScope");
832
835
  var DEFAULT_SCOPE_OPTIONS = {
833
836
  placeOfEvent: JurisdictionFilter.enum.all,
834
- accessLevel: JurisdictionFilter.enum.all
837
+ accessLevel: JurisdictionFilter.enum.all,
838
+ registeredIn: JurisdictionFilter.enum.all,
839
+ declaredIn: JurisdictionFilter.enum.all
835
840
  };
836
841
 
837
842
  // ../commons/src/authentication.ts
@@ -1077,6 +1082,9 @@ var FlagConfig = z14.object({
1077
1082
  "Indicates if this flag expects an action to be performed to be cleared."
1078
1083
  ),
1079
1084
  label: TranslationConfig.describe("Human readable label of the flag.")
1085
+ }).meta({
1086
+ description: "Flag configuration",
1087
+ id: "FlagConfig"
1080
1088
  });
1081
1089
  var ActionFlagConfig = z14.object({
1082
1090
  id: Flag,
@@ -1084,6 +1092,9 @@ var ActionFlagConfig = z14.object({
1084
1092
  conditional: Conditional.optional().describe(
1085
1093
  "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
1086
1094
  )
1095
+ }).meta({
1096
+ description: "Action flag configuration",
1097
+ id: "ActionFlagConfig"
1087
1098
  });
1088
1099
 
1089
1100
  // ../commons/src/events/EventMetadata.ts
@@ -1105,8 +1116,7 @@ var ActionCreationMetadata = z15.object({
1105
1116
  ),
1106
1117
  createdByUserType: z15.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1107
1118
  acceptedAt: z15.iso.datetime().describe("Timestamp when the action request was accepted."),
1108
- createdByRole: z15.string().optional().describe("Role of the user at the time of action request creation."),
1109
- 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.")
1110
1120
  });
1111
1121
  var RegistrationCreationMetadata = ActionCreationMetadata.extend({
1112
1122
  registrationNumber: z15.string().describe(
@@ -1134,9 +1144,6 @@ var EventMetadata = z15.object({
1134
1144
  createdAtLocation: UUID.nullish().describe(
1135
1145
  "Location of the user who created the event."
1136
1146
  ),
1137
- createdBySignature: DocumentPath.nullish().describe(
1138
- "Signature of the user who created the event."
1139
- ),
1140
1147
  updatedAtLocation: UUID.nullish().describe(
1141
1148
  "Location of the user who last changed the status."
1142
1149
  ),
@@ -1400,7 +1407,7 @@ var FieldId = import_v43.default.string().superRefine((val, ctx) => {
1400
1407
  }
1401
1408
  }).describe("Unique identifier for the field");
1402
1409
  var FieldReference = import_v43.default.object({
1403
- $$field: FieldId,
1410
+ $$field: FieldId.describe("Id of the field to reference"),
1404
1411
  $$subfield: import_v43.default.array(import_v43.default.string()).optional().default([]).describe(
1405
1412
  'If the FieldValue is an object, subfield can be used to refer to e.g. `["foo", "bar"]` in `{ foo: { bar: 3 } }`'
1406
1413
  )
package/dist/cli.js CHANGED
@@ -1883,9 +1883,9 @@ function updateRouteHandlers(sourceFiles, group, srcDir, relCwd) {
1883
1883
  }
1884
1884
  return replacedCount;
1885
1885
  }
1886
- function resolveConfigChain(configObj, path23) {
1886
+ function resolveConfigChain(configObj, path24) {
1887
1887
  let current = configObj;
1888
- for (const key of path23) {
1888
+ for (const key of path24) {
1889
1889
  if (!import_ts_morph10.Node.isObjectLiteralExpression(current)) return null;
1890
1890
  const prop = current.getProperty(key);
1891
1891
  if (!prop || !import_ts_morph10.Node.isPropertyAssignment(prop)) return null;
@@ -2393,7 +2393,9 @@ var decodeScope = (query) => {
2393
2393
  };
2394
2394
  var DEFAULT_SCOPE_OPTIONS = {
2395
2395
  placeOfEvent: JurisdictionFilter.enum.all,
2396
- accessLevel: JurisdictionFilter.enum.all
2396
+ accessLevel: JurisdictionFilter.enum.all,
2397
+ registeredIn: JurisdictionFilter.enum.all,
2398
+ declaredIn: JurisdictionFilter.enum.all
2397
2399
  };
2398
2400
 
2399
2401
  // ../commons/src/scopes.deprecated.do-not-use.ts
@@ -4831,9 +4833,9 @@ var import_path24 = require("path");
4831
4833
  var TEMP_REMOTE2 = "opencrvs-upgrade-v19-v20-codemod-merge-infra";
4832
4834
  var INFRASTRUCTURE_DIR = "infrastructure";
4833
4835
  var BASE_BRANCH = "release-v1.9";
4834
- function gitShowBytes(ref, path23) {
4836
+ function gitShowBytes(ref, path24) {
4835
4837
  try {
4836
- const buf = (0, import_child_process2.execFileSync)("git", ["show", `${ref}:${path23}`], {
4838
+ const buf = (0, import_child_process2.execFileSync)("git", ["show", `${ref}:${path24}`], {
4837
4839
  cwd: process.cwd(),
4838
4840
  stdio: ["ignore", "pipe", "pipe"]
4839
4841
  });
@@ -5009,6 +5011,94 @@ async function main26({
5009
5011
  );
5010
5012
  }
5011
5013
 
5014
+ // src/migrations/v2.0/fix-accept-requested-registration-function-type.ts
5015
+ var import_ts_morph22 = require("ts-morph");
5016
+ var import_path26 = __toESM(require("path"));
5017
+ var TARGET_FUNCTION_NAME = "acceptRequestedRegistration";
5018
+ var ACTION_PARAMETER_NAME = "action";
5019
+ var OLD_TYPE = "ActionInput";
5020
+ var NEW_TYPE = "Extract<ActionInput, { type?: 'REGISTER' }>";
5021
+ function isAcceptRequestedRegistrationParameter(parameter) {
5022
+ const functionDeclaration = parameter.getFirstAncestorByKind(
5023
+ import_ts_morph22.SyntaxKind.FunctionDeclaration
5024
+ );
5025
+ if (functionDeclaration?.getName() === TARGET_FUNCTION_NAME) {
5026
+ return true;
5027
+ }
5028
+ const arrowFunction = parameter.getFirstAncestorByKind(
5029
+ import_ts_morph22.SyntaxKind.ArrowFunction
5030
+ );
5031
+ const variableDeclaration = arrowFunction?.getFirstAncestorByKind(
5032
+ import_ts_morph22.SyntaxKind.VariableDeclaration
5033
+ );
5034
+ return variableDeclaration?.getName() === TARGET_FUNCTION_NAME;
5035
+ }
5036
+ function processFile14(filePath, project) {
5037
+ const sourceFile = project.getSourceFile(filePath);
5038
+ if (!sourceFile) return 0;
5039
+ let updatedCount = 0;
5040
+ for (const parameter of sourceFile.getDescendantsOfKind(
5041
+ import_ts_morph22.SyntaxKind.Parameter
5042
+ )) {
5043
+ if (parameter.getName() !== ACTION_PARAMETER_NAME) {
5044
+ continue;
5045
+ }
5046
+ if (!isAcceptRequestedRegistrationParameter(parameter)) {
5047
+ continue;
5048
+ }
5049
+ const typeNode = parameter.getTypeNode();
5050
+ if (!typeNode || typeNode.getText() !== OLD_TYPE) {
5051
+ continue;
5052
+ }
5053
+ parameter.setType(NEW_TYPE);
5054
+ updatedCount++;
5055
+ console.log(
5056
+ ` [${import_path26.default.relative(process.cwd(), filePath)}] Updated '${ACTION_PARAMETER_NAME}' in ${TARGET_FUNCTION_NAME} to ${NEW_TYPE}`
5057
+ );
5058
+ }
5059
+ return updatedCount;
5060
+ }
5061
+ async function main27() {
5062
+ const srcDir = import_path26.default.join(process.cwd(), "src");
5063
+ console.log(`Scanning for ${TARGET_FUNCTION_NAME} in: ${srcDir}
5064
+ `);
5065
+ const project = new import_ts_morph22.Project({
5066
+ tsConfigFilePath: import_path26.default.resolve(srcDir, "../tsconfig.json"),
5067
+ skipAddingFilesFromTsConfig: false
5068
+ });
5069
+ const sourceFiles = project.getSourceFiles().filter((sf) => {
5070
+ const filePath = sf.getFilePath();
5071
+ return filePath.includes("/src/") && !filePath.includes("/node_modules/");
5072
+ });
5073
+ let totalUpdated = 0;
5074
+ const modifiedFiles = [];
5075
+ for (const sourceFile of sourceFiles) {
5076
+ const filePath = sourceFile.getFilePath();
5077
+ const updated = processFile14(filePath, project);
5078
+ if (updated > 0) {
5079
+ totalUpdated += updated;
5080
+ modifiedFiles.push(filePath);
5081
+ }
5082
+ }
5083
+ if (modifiedFiles.length === 0) {
5084
+ console.log(
5085
+ `No '${ACTION_PARAMETER_NAME}: ${OLD_TYPE}' parameter in ${TARGET_FUNCTION_NAME} found. Nothing to do.`
5086
+ );
5087
+ return;
5088
+ }
5089
+ console.log(`
5090
+ Saving ${modifiedFiles.length} modified file(s)...`);
5091
+ for (const filePath of modifiedFiles) {
5092
+ const sourceFile = project.getSourceFileOrThrow(filePath);
5093
+ await sourceFile.save();
5094
+ console.log(` Saved: ${import_path26.default.relative(process.cwd(), filePath)}`);
5095
+ }
5096
+ console.log(
5097
+ `
5098
+ Done. Updated ${totalUpdated} parameter type annotation(s) in ${TARGET_FUNCTION_NAME}.`
5099
+ );
5100
+ }
5101
+
5012
5102
  // src/migrations/v2.0/index.ts
5013
5103
  var NON_SWARM_INFRA_SUBDIRS = ["postgres", "metabase"];
5014
5104
  async function runUpgrade(dockerSwarm) {
@@ -5035,6 +5125,7 @@ async function runUpgrade(dockerSwarm) {
5035
5125
  await main22();
5036
5126
  await main23();
5037
5127
  await main24();
5128
+ await main27();
5038
5129
  await main17();
5039
5130
  if (dockerSwarm) {
5040
5131
  await main25();
@@ -5069,7 +5160,7 @@ Options:
5069
5160
  'infrastructure/' directory is deleted (default).
5070
5161
  -h, --help Show this message.
5071
5162
  `.trim();
5072
- function main27() {
5163
+ function main28() {
5073
5164
  const command = args[0];
5074
5165
  if (!command || command === "--help" || command === "-h") {
5075
5166
  console.log(USAGE);
@@ -5144,4 +5235,4 @@ function handleCheckTranslations() {
5144
5235
  console.warn("This command is not implemented yet!");
5145
5236
  process.exit(1);
5146
5237
  }
5147
- main27();
5238
+ main28();
@@ -6682,7 +6682,6 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
6682
6682
  createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
6683
6683
  createdByUserType?: "system" | "user" | null | undefined;
6684
6684
  createdByRole?: string | undefined;
6685
- createdBySignature?: string | null | undefined;
6686
6685
  } | null | undefined;
6687
6686
  REGISTERED?: {
6688
6687
  createdAt: string;
@@ -6692,7 +6691,6 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
6692
6691
  createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
6693
6692
  createdByUserType?: "system" | "user" | null | undefined;
6694
6693
  createdByRole?: string | undefined;
6695
- createdBySignature?: string | null | undefined;
6696
6694
  } | null | undefined;
6697
6695
  };
6698
6696
  createdAt: string;
@@ -6710,7 +6708,6 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
6710
6708
  createdByUserType?: "system" | "user" | null | undefined;
6711
6709
  updatedByUserRole?: string | null | undefined;
6712
6710
  createdAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
6713
- createdBySignature?: (string & import("zod").$brand<"DocumentPath">) | null | undefined;
6714
6711
  updatedAtLocation?: (string & import("zod").$brand<"UUID">) | null | undefined;
6715
6712
  assignedTo?: string | null | undefined;
6716
6713
  updatedBy?: string | null | undefined;
@@ -7169,33 +7166,22 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
7169
7166
  input: string[];
7170
7167
  output: ({
7171
7168
  id: string & import("zod").$brand<"UUID">;
7169
+ type: "user";
7172
7170
  name: {
7173
7171
  firstname: string;
7174
7172
  surname: string;
7175
7173
  };
7176
7174
  role: string;
7177
7175
  primaryOfficeId: string & import("zod").$brand<"UUID">;
7178
- type: "user";
7179
- status: "active" | "pending" | "deactivated";
7176
+ fullHonorificName?: string | undefined;
7180
7177
  avatar?: (string & import("zod").$brand<"DocumentPath">) | undefined;
7181
- signature?: (string & import("zod").$brand<"DocumentPath">) | null | undefined;
7182
7178
  administrativeAreaId?: (string & import("zod").$brand<"UUID">) | null | undefined;
7183
- device?: string | undefined;
7184
- fullHonorificName?: string | undefined;
7185
- mobile?: string | undefined;
7186
- email?: string | undefined;
7187
- data?: Record<string, import("../commons").FieldValue> | undefined;
7188
7179
  } | {
7189
7180
  id: string & import("zod").$brand<"UUID">;
7190
- name: string;
7191
7181
  type: "system";
7182
+ name: string;
7192
7183
  primaryOfficeId?: (string & import("zod").$brand<"UUID">) | undefined;
7193
7184
  administrativeAreaId?: (string & import("zod").$brand<"UUID">) | undefined;
7194
- signature?: undefined;
7195
- avatar?: undefined;
7196
- fullHonorificName?: string | undefined;
7197
- legacyId?: string | undefined;
7198
- status?: undefined;
7199
7185
  })[];
7200
7186
  meta: import("trpc-to-openapi").OpenApiMeta;
7201
7187
  }>;
@@ -7213,33 +7199,24 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
7213
7199
  };
7214
7200
  output: ({
7215
7201
  id: string & import("zod").$brand<"UUID">;
7202
+ type: "user";
7216
7203
  name: {
7217
7204
  firstname: string;
7218
7205
  surname: string;
7219
7206
  };
7220
7207
  role: string;
7221
7208
  primaryOfficeId: string & import("zod").$brand<"UUID">;
7222
- type: "user";
7223
7209
  status: "active" | "pending" | "deactivated";
7210
+ fullHonorificName?: string | undefined;
7224
7211
  avatar?: (string & import("zod").$brand<"DocumentPath">) | undefined;
7225
- signature?: (string & import("zod").$brand<"DocumentPath">) | null | undefined;
7226
7212
  administrativeAreaId?: (string & import("zod").$brand<"UUID">) | null | undefined;
7227
- device?: string | undefined;
7228
- fullHonorificName?: string | undefined;
7229
- mobile?: string | undefined;
7230
- email?: string | undefined;
7231
- data?: Record<string, import("../commons").FieldValue> | undefined;
7232
7213
  } | {
7233
7214
  id: string & import("zod").$brand<"UUID">;
7234
- name: string;
7235
7215
  type: "system";
7216
+ name: string;
7236
7217
  primaryOfficeId?: (string & import("zod").$brand<"UUID">) | undefined;
7237
7218
  administrativeAreaId?: (string & import("zod").$brand<"UUID">) | undefined;
7238
- signature?: undefined;
7239
- avatar?: undefined;
7240
- fullHonorificName?: string | undefined;
7241
- legacyId?: string | undefined;
7242
- status?: undefined;
7219
+ status?: "active" | "pending" | "deactivated" | undefined;
7243
7220
  })[];
7244
7221
  meta: object;
7245
7222
  }>;
@@ -20,7 +20,6 @@ export declare const EventIndex: z.ZodObject<{
20
20
  }>>>;
21
21
  acceptedAt: z.ZodISODateTime;
22
22
  createdByRole: z.ZodOptional<z.ZodString>;
23
- createdBySignature: z.ZodOptional<z.ZodNullable<z.ZodString>>;
24
23
  }, z.core.$strip>>>;
25
24
  REGISTERED: z.ZodOptional<z.ZodNullable<z.ZodObject<{
26
25
  createdAt: z.ZodISODateTime;
@@ -32,7 +31,6 @@ export declare const EventIndex: z.ZodObject<{
32
31
  }>>>;
33
32
  acceptedAt: z.ZodISODateTime;
34
33
  createdByRole: z.ZodOptional<z.ZodString>;
35
- createdBySignature: z.ZodOptional<z.ZodNullable<z.ZodString>>;
36
34
  registrationNumber: z.ZodString;
37
35
  }, z.core.$strip>>>;
38
36
  }, z.core.$strip>;
@@ -46,7 +44,6 @@ export declare const EventIndex: z.ZodObject<{
46
44
  }>>>;
47
45
  updatedByUserRole: z.ZodOptional<z.ZodNullable<z.ZodString>>;
48
46
  createdAtLocation: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
49
- createdBySignature: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodString, "DocumentPath", "out">>>;
50
47
  updatedAtLocation: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
51
48
  updatedAt: z.ZodISODateTime;
52
49
  assignedTo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -23,7 +23,6 @@ export declare const ActionCreationMetadata: z.ZodObject<{
23
23
  }>>>;
24
24
  acceptedAt: z.ZodISODateTime;
25
25
  createdByRole: z.ZodOptional<z.ZodString>;
26
- createdBySignature: z.ZodOptional<z.ZodNullable<z.ZodString>>;
27
26
  }, z.core.$strip>;
28
27
  export type ActionCreationMetadata = z.infer<typeof ActionCreationMetadata>;
29
28
  export declare const RegistrationCreationMetadata: z.ZodObject<{
@@ -36,7 +35,6 @@ export declare const RegistrationCreationMetadata: z.ZodObject<{
36
35
  }>>>;
37
36
  acceptedAt: z.ZodISODateTime;
38
37
  createdByRole: z.ZodOptional<z.ZodString>;
39
- createdBySignature: z.ZodOptional<z.ZodNullable<z.ZodString>>;
40
38
  registrationNumber: z.ZodString;
41
39
  }, z.core.$strip>;
42
40
  export type RegistrationCreationMetadata = z.infer<typeof RegistrationCreationMetadata>;
@@ -51,7 +49,6 @@ export declare const LegalStatuses: z.ZodObject<{
51
49
  }>>>;
52
50
  acceptedAt: z.ZodISODateTime;
53
51
  createdByRole: z.ZodOptional<z.ZodString>;
54
- createdBySignature: z.ZodOptional<z.ZodNullable<z.ZodString>>;
55
52
  }, z.core.$strip>>>;
56
53
  REGISTERED: z.ZodOptional<z.ZodNullable<z.ZodObject<{
57
54
  createdAt: z.ZodISODateTime;
@@ -63,7 +60,6 @@ export declare const LegalStatuses: z.ZodObject<{
63
60
  }>>>;
64
61
  acceptedAt: z.ZodISODateTime;
65
62
  createdByRole: z.ZodOptional<z.ZodString>;
66
- createdBySignature: z.ZodOptional<z.ZodNullable<z.ZodString>>;
67
63
  registrationNumber: z.ZodString;
68
64
  }, z.core.$strip>>>;
69
65
  }, z.core.$strip>;
@@ -93,7 +89,6 @@ export declare const EventMetadata: z.ZodObject<{
93
89
  }>>>;
94
90
  acceptedAt: z.ZodISODateTime;
95
91
  createdByRole: z.ZodOptional<z.ZodString>;
96
- createdBySignature: z.ZodOptional<z.ZodNullable<z.ZodString>>;
97
92
  }, z.core.$strip>>>;
98
93
  REGISTERED: z.ZodOptional<z.ZodNullable<z.ZodObject<{
99
94
  createdAt: z.ZodISODateTime;
@@ -105,7 +100,6 @@ export declare const EventMetadata: z.ZodObject<{
105
100
  }>>>;
106
101
  acceptedAt: z.ZodISODateTime;
107
102
  createdByRole: z.ZodOptional<z.ZodString>;
108
- createdBySignature: z.ZodOptional<z.ZodNullable<z.ZodString>>;
109
103
  registrationNumber: z.ZodString;
110
104
  }, z.core.$strip>>>;
111
105
  }, z.core.$strip>;
@@ -119,7 +113,6 @@ export declare const EventMetadata: z.ZodObject<{
119
113
  }>>>;
120
114
  updatedByUserRole: z.ZodOptional<z.ZodNullable<z.ZodString>>;
121
115
  createdAtLocation: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
122
- createdBySignature: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodString, "DocumentPath", "out">>>;
123
116
  updatedAtLocation: z.ZodOptional<z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "UUID", "out">>>;
124
117
  updatedAt: z.ZodISODateTime;
125
118
  assignedTo: z.ZodOptional<z.ZodNullable<z.ZodString>>;