@opencrvs/toolkit 2.0.0-rc.61bee9f → 2.0.0-rc.660de90

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.
@@ -1723,7 +1723,6 @@ declare const AdministrativeAreaField: z.ZodObject<{
1723
1723
  "user.read": "user.read";
1724
1724
  "user.create": "user.create";
1725
1725
  "user.edit": "user.edit";
1726
- "user.search": "user.search";
1727
1726
  workqueue: "workqueue";
1728
1727
  "dashboard.view": "dashboard.view";
1729
1728
  }>;
@@ -1843,7 +1842,6 @@ declare const LocationInput: z.ZodObject<{
1843
1842
  "user.read": "user.read";
1844
1843
  "user.create": "user.create";
1845
1844
  "user.edit": "user.edit";
1846
- "user.search": "user.search";
1847
1845
  workqueue: "workqueue";
1848
1846
  "dashboard.view": "dashboard.view";
1849
1847
  }>;
@@ -2028,7 +2026,6 @@ declare const Facility: z.ZodObject<{
2028
2026
  "user.read": "user.read";
2029
2027
  "user.create": "user.create";
2030
2028
  "user.edit": "user.edit";
2031
- "user.search": "user.search";
2032
2029
  workqueue: "workqueue";
2033
2030
  "dashboard.view": "dashboard.view";
2034
2031
  }>;
@@ -2134,7 +2131,6 @@ declare const Office: z.ZodObject<{
2134
2131
  "user.read": "user.read";
2135
2132
  "user.create": "user.create";
2136
2133
  "user.edit": "user.edit";
2137
- "user.search": "user.search";
2138
2134
  workqueue: "workqueue";
2139
2135
  "dashboard.view": "dashboard.view";
2140
2136
  }>;
@@ -2327,7 +2323,6 @@ declare const Address: z.ZodObject<{
2327
2323
  "user.read": "user.read";
2328
2324
  "user.create": "user.create";
2329
2325
  "user.edit": "user.edit";
2330
- "user.search": "user.search";
2331
2326
  workqueue: "workqueue";
2332
2327
  "dashboard.view": "dashboard.view";
2333
2328
  }>;
@@ -298,14 +298,12 @@ var SystemScopeType = z6.enum([
298
298
  "organisation.read-locations",
299
299
  "user.read",
300
300
  "user.create",
301
- "user.edit",
302
- "user.search"
301
+ "user.edit"
303
302
  ]);
304
303
  var UserScopeType = SystemScopeType.extract([
305
304
  "user.read",
306
305
  "user.create",
307
- "user.edit",
308
- "user.search"
306
+ "user.edit"
309
307
  ]);
310
308
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
311
309
  var UserScopeV2 = z6.discriminatedUnion("type", [
@@ -314,7 +312,7 @@ var UserScopeV2 = z6.discriminatedUnion("type", [
314
312
  options: AllUserScopeOptions.optional()
315
313
  }),
316
314
  z6.object({
317
- type: UserScopeType.extract(["user.read", "user.search"]),
315
+ type: UserScopeType.extract(["user.read"]),
318
316
  options: AccessLevelOptions.optional()
319
317
  })
320
318
  ]);
@@ -607,14 +607,12 @@ var SystemScopeType = z2.enum([
607
607
  "organisation.read-locations",
608
608
  "user.read",
609
609
  "user.create",
610
- "user.edit",
611
- "user.search"
610
+ "user.edit"
612
611
  ]);
613
612
  var UserScopeType = SystemScopeType.extract([
614
613
  "user.read",
615
614
  "user.create",
616
- "user.edit",
617
- "user.search"
615
+ "user.edit"
618
616
  ]);
619
617
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
620
618
  var UserScopeV2 = z2.discriminatedUnion("type", [
@@ -623,7 +621,7 @@ var UserScopeV2 = z2.discriminatedUnion("type", [
623
621
  options: AllUserScopeOptions.optional()
624
622
  }),
625
623
  z2.object({
626
- type: UserScopeType.extract(["user.read", "user.search"]),
624
+ type: UserScopeType.extract(["user.read"]),
627
625
  options: AccessLevelOptions.optional()
628
626
  })
629
627
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"add-birth-certificate-issuance-flag.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/add-birth-certificate-issuance-flag.ts"],"names":[],"mappings":"AAycA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"add-birth-certificate-issuance-flag.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/add-birth-certificate-issuance-flag.ts"],"names":[],"mappings":"AA2aA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -24,17 +24,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.main = main;
26
26
  /**
27
- * Codemod: Add `pending-first-certificate-issuance` flag to event configs and workqueues.
27
+ * Codemod: Add `pending-first-certificate-issuance` flag to birth event configs and workqueues.
28
28
  *
29
29
  * Usage:
30
30
  * ts-node -r tsconfig-paths/register src/migrations/v2.0/add-birth-certificate-issuance-flag.ts
31
31
  *
32
32
  * What it does:
33
- * defineConfig (every event type — birth, death, marriage, custom, etc.):
33
+ * defineConfig (birth type only):
34
34
  * - Ensures the top-level `flags` array contains the `pending-first-certificate-issuance`
35
- * flag definition. The flag's i18n `label.id` is event-specific, e.g.
36
- * `event.birth.flag.pending-first-certificate-issuance`,
37
- * `event.death.flag.pending-first-certificate-issuance`.
35
+ * flag definition
38
36
  * - Ensures every `REGISTER` action has
39
37
  * `flags: [{ id: 'pending-first-certificate-issuance', operation: 'add' }]`
40
38
  * - Ensures every `PRINT_CERTIFICATE` action has
@@ -57,27 +55,20 @@ const ACTION_PROPERTY_NAME = 'action';
57
55
  const FLAGS_PROPERTY_NAME = 'flags';
58
56
  const QUERY_PROPERTY_NAME = 'query';
59
57
  const TYPE_PROPERTY_NAME = 'type';
60
- const ID_PROPERTY_NAME = 'id';
61
58
  const CLAUSES_PROPERTY_NAME = 'clauses';
62
59
  const ANY_OF_PROPERTY_NAME = 'anyOf';
63
60
  const FLAG_ID = 'pending-first-certificate-issuance';
64
61
  const REGISTER_TYPE = 'REGISTER';
65
62
  const PRINT_CERTIFICATE_TYPE = 'PRINT_CERTIFICATE';
66
- /**
67
- * Builds the flag-definition object literal for a given event type so the i18n
68
- * `label.id` is namespaced per event (e.g. `event.death.flag.…`).
69
- */
70
- function flagDefinitionInitializer(eventType) {
71
- return `{
63
+ const FLAG_DEFINITION_INITIALIZER = `{
72
64
  id: '${FLAG_ID}',
73
65
  label: {
74
- id: 'event.${eventType}.flag.${FLAG_ID}',
66
+ id: 'event.birth.flag.${FLAG_ID}',
75
67
  defaultMessage: 'Pending first certificate issuance',
76
68
  description: 'Flag label for first certificate issuance'
77
69
  },
78
70
  requiresAction: true
79
71
  }`;
80
- }
81
72
  // ─── Generic helpers ──────────────────────────────────────────────────────────
82
73
  /**
83
74
  * Returns true if the object's `type` property matches the given type name.
@@ -99,36 +90,23 @@ function isActionOfType(obj, typeName) {
99
90
  return false;
100
91
  }
101
92
  /**
102
- * Extracts the event type from a `defineConfig` root config object, using the
103
- * (lower-cased) value of either the `type` or `id` property. Property name has
104
- * shifted across core/country-config versions, so both are tried.
105
- *
106
- * Handles all known shapes:
107
- * - `type: 'birth'` / `id: 'birth'`
108
- * - `type: EventType.BIRTH` / `id: Event.Birth`
109
- *
110
- * For `PropertyAccessExpression` (enum access), the *member name* is returned
111
- * lower-cased — this works for the conventional `EventType.BIRTH = 'birth'` and
112
- * `Event.Birth = 'birth'` mappings used in core and country configs.
113
- *
114
- * Returns null when no event type can be determined.
93
+ * Returns true when the `defineConfig` root config object describes a birth event.
94
+ * Handles both `'birth'` string literal and `EventType.BIRTH` enum access.
115
95
  */
116
- function getEventType(configArg) {
117
- for (const propName of [TYPE_PROPERTY_NAME, ID_PROPERTY_NAME]) {
118
- const prop = configArg.getProperty(propName);
119
- if (!prop || !ts_morph_1.Node.isPropertyAssignment(prop))
120
- continue;
121
- const initializer = prop.getInitializer();
122
- if (!initializer)
123
- continue;
124
- if (ts_morph_1.Node.isStringLiteral(initializer)) {
125
- return initializer.getLiteralValue().toLowerCase();
126
- }
127
- if (ts_morph_1.Node.isPropertyAccessExpression(initializer)) {
128
- return initializer.getName().toLowerCase();
129
- }
96
+ function isBirthConfig(configArg) {
97
+ const typeProperty = configArg.getProperty(TYPE_PROPERTY_NAME);
98
+ if (!typeProperty || !ts_morph_1.Node.isPropertyAssignment(typeProperty))
99
+ return false;
100
+ const initializer = typeProperty.getInitializer();
101
+ if (!initializer)
102
+ return false;
103
+ if (ts_morph_1.Node.isStringLiteral(initializer)) {
104
+ return initializer.getLiteralValue().toLowerCase() === 'birth';
105
+ }
106
+ if (ts_morph_1.Node.isPropertyAccessExpression(initializer)) {
107
+ return initializer.getName().toLowerCase() === 'birth';
130
108
  }
131
- return null;
109
+ return false;
132
110
  }
133
111
  /**
134
112
  * Returns true if an array literal contains an object literal with `id: <id>`.
@@ -151,19 +129,17 @@ function hasElementWithId(array, id) {
151
129
  }
152
130
  // ─── defineConfig helpers ─────────────────────────────────────────────────────
153
131
  /**
154
- * Ensures the top-level `flags` array in a `defineConfig` contains the
155
- * `pending-first-certificate-issuance` flag definition. The flag's i18n
156
- * `label.id` is namespaced per event type (e.g. `event.death.flag.…`).
132
+ * Ensures the top-level `flags` array in a birth `defineConfig` contains the
133
+ * `pending-first-certificate-issuance` flag definition.
157
134
  */
158
- function ensureTopLevelFlagDefinition(configArg, eventType) {
159
- const initializer = flagDefinitionInitializer(eventType);
135
+ function ensureTopLevelFlagDefinition(configArg) {
160
136
  const flagsProp = configArg.getProperty(FLAGS_PROPERTY_NAME);
161
137
  if (flagsProp && ts_morph_1.Node.isPropertyAssignment(flagsProp)) {
162
138
  const flagsInit = flagsProp.getInitializer();
163
139
  if (flagsInit && ts_morph_1.Node.isArrayLiteralExpression(flagsInit)) {
164
140
  if (hasElementWithId(flagsInit, FLAG_ID))
165
141
  return false;
166
- flagsInit.addElement(initializer);
142
+ flagsInit.addElement(FLAG_DEFINITION_INITIALIZER);
167
143
  return true;
168
144
  }
169
145
  return false;
@@ -171,7 +147,7 @@ function ensureTopLevelFlagDefinition(configArg, eventType) {
171
147
  // No `flags` property at all — create it
172
148
  configArg.addPropertyAssignment({
173
149
  name: FLAGS_PROPERTY_NAME,
174
- initializer: `[\n ${initializer}\n]`
150
+ initializer: `[\n ${FLAG_DEFINITION_INITIALIZER}\n]`
175
151
  });
176
152
  return true;
177
153
  }
@@ -198,15 +174,15 @@ function ensureActionOperationFlag(action, operation) {
198
174
  return true;
199
175
  }
200
176
  /**
201
- * Processes a `defineConfig` object: ensures top-level flag definition,
177
+ * Processes a birth defineConfig object: ensures top-level flag definition,
202
178
  * REGISTER action flags, and PRINT_CERTIFICATE action flags.
203
179
  * Returns the number of changes made.
204
180
  */
205
- function processConfig(configArg, eventType, relPath) {
181
+ function processBirthConfig(configArg, relPath) {
206
182
  let changes = 0;
207
- if (ensureTopLevelFlagDefinition(configArg, eventType)) {
183
+ if (ensureTopLevelFlagDefinition(configArg)) {
208
184
  changes++;
209
- console.log(` [${relPath}] (${eventType}) Added '${FLAG_ID}' to top-level flags`);
185
+ console.log(` [${relPath}] Added '${FLAG_ID}' to top-level flags`);
210
186
  }
211
187
  const actionsProp = configArg.getProperty(ACTIONS_PROPERTY_NAME);
212
188
  if (!actionsProp || !ts_morph_1.Node.isPropertyAssignment(actionsProp))
@@ -221,13 +197,13 @@ function processConfig(configArg, eventType, relPath) {
221
197
  if (isActionOfType(element, REGISTER_TYPE)) {
222
198
  if (ensureActionOperationFlag(element, 'add')) {
223
199
  changes++;
224
- console.log(` [${relPath}] (${eventType}) Added '${FLAG_ID}' add-flag to REGISTER action`);
200
+ console.log(` [${relPath}] Added '${FLAG_ID}' add-flag to REGISTER action`);
225
201
  }
226
202
  }
227
203
  if (isActionOfType(element, PRINT_CERTIFICATE_TYPE)) {
228
204
  if (ensureActionOperationFlag(element, 'remove')) {
229
205
  changes++;
230
- console.log(` [${relPath}] (${eventType}) Added '${FLAG_ID}' remove-flag to PRINT_CERTIFICATE action`);
206
+ console.log(` [${relPath}] Added '${FLAG_ID}' remove-flag to PRINT_CERTIFICATE action`);
231
207
  }
232
208
  }
233
209
  }
@@ -356,10 +332,9 @@ function processFile(filePath, project) {
356
332
  const configArg = args[0];
357
333
  if (!ts_morph_1.Node.isObjectLiteralExpression(configArg))
358
334
  continue;
359
- const eventType = getEventType(configArg);
360
- if (!eventType)
335
+ if (!isBirthConfig(configArg))
361
336
  continue;
362
- totalChanges += processConfig(configArg, eventType, relPath);
337
+ totalChanges += processBirthConfig(configArg, relPath);
363
338
  }
364
339
  // ── defineWorkqueues ──────────────────────────────────────────────────────
365
340
  if (calleeName === DEFINE_WORKQUEUES_NAME) {
@@ -394,7 +369,7 @@ function processFile(filePath, project) {
394
369
  function main() {
395
370
  return __awaiter(this, void 0, void 0, function* () {
396
371
  const srcDir = path_1.default.join(process.cwd(), 'src');
397
- console.log(`Scanning for defineConfig and PRINT_CERTIFICATE workqueues in: ${srcDir}\n`);
372
+ console.log(`Scanning for birth defineConfig and PRINT_CERTIFICATE workqueues in: ${srcDir}\n`);
398
373
  const project = new ts_morph_1.Project({
399
374
  tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
400
375
  skipAddingFilesFromTsConfig: false
@@ -415,7 +390,7 @@ function main() {
415
390
  }
416
391
  }
417
392
  if (modifiedFiles.length === 0) {
418
- console.log('No event configs or PRINT_CERTIFICATE workqueues found. Nothing to do.');
393
+ console.log('No birth configs or PRINT_CERTIFICATE workqueues found. Nothing to do.');
419
394
  return;
420
395
  }
421
396
  console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
@@ -190,8 +190,6 @@ function ensureImports(sourceFile) {
190
190
  var DEFINE_CONFIG_NAME2 = "defineConfig";
191
191
  var ACTIONS_PROPERTY_NAME2 = "actions";
192
192
  var TYPE_PROPERTY_NAME2 = "type";
193
- var ID_PROPERTY_NAME = "id";
194
- var FLAGS_PROPERTY_NAME = "flags";
195
193
  var CUSTOM_ACTION_TYPE_PROPERTY_NAME = "customActionType";
196
194
  var AUDIT_HISTORY_LABEL_PROPERTY_NAME = "auditHistoryLabel";
197
195
  var DEDUPLICATION_PROPERTY_NAME = "deduplication";
@@ -201,12 +199,9 @@ var FORM_PROPERTY_NAME = "form";
201
199
  var ACTION_TYPE_ENUM_NAME = "ActionType";
202
200
  var VALIDATE_MEMBER_NAME = "VALIDATE";
203
201
  var CUSTOM_MEMBER_NAME = "CUSTOM";
204
- var REGISTER_MEMBER_NAME2 = "REGISTER";
205
202
  var VALIDATE_STRING_LITERAL = "VALIDATE";
206
203
  var CUSTOM_STRING_LITERAL = "CUSTOM";
207
- var REGISTER_STRING_LITERAL2 = "REGISTER";
208
204
  var VALIDATE_DECLARATION_VALUE = "VALIDATE_DECLARATION";
209
- var VALIDATED_FLAG_VALUE = "validated";
210
205
  function isValidateType(typeInitializer) {
211
206
  if (typeInitializer.getKind() === import_ts_morph2.SyntaxKind.PropertyAccessExpression) {
212
207
  const propAccess = typeInitializer.asKindOrThrow(
@@ -330,50 +325,6 @@ function transformValidateActionToCustom(obj, eventType) {
330
325
  }
331
326
  return true;
332
327
  }
333
- function isRegisterAction(action) {
334
- const typeProperty = action.getProperty(TYPE_PROPERTY_NAME2);
335
- if (!typeProperty || !import_ts_morph2.Node.isPropertyAssignment(typeProperty)) return false;
336
- const typeInit = typeProperty.getInitializer();
337
- if (!typeInit) return false;
338
- if (import_ts_morph2.Node.isPropertyAccessExpression(typeInit)) {
339
- const enumExpr = typeInit.getExpression();
340
- return import_ts_morph2.Node.isIdentifier(enumExpr) && enumExpr.getText() === ACTION_TYPE_ENUM_NAME && typeInit.getName() === REGISTER_MEMBER_NAME2;
341
- }
342
- if (import_ts_morph2.Node.isStringLiteral(typeInit)) {
343
- return typeInit.getLiteralValue() === REGISTER_STRING_LITERAL2;
344
- }
345
- return false;
346
- }
347
- function arrayHasElementWithId(array3, id) {
348
- for (const el of array3.getElements()) {
349
- if (!import_ts_morph2.Node.isObjectLiteralExpression(el)) continue;
350
- const idProp = el.getProperty(ID_PROPERTY_NAME);
351
- if (!idProp || !import_ts_morph2.Node.isPropertyAssignment(idProp)) continue;
352
- const idInit = idProp.getInitializer();
353
- if (idInit && import_ts_morph2.Node.isStringLiteral(idInit) && idInit.getLiteralValue() === id) {
354
- return true;
355
- }
356
- }
357
- return false;
358
- }
359
- function ensureRegisterRemovesValidatedFlag(action) {
360
- const entry = `{ id: '${VALIDATED_FLAG_VALUE}', operation: 'remove' }`;
361
- const flagsProp = action.getProperty(FLAGS_PROPERTY_NAME);
362
- if (flagsProp && import_ts_morph2.Node.isPropertyAssignment(flagsProp)) {
363
- const flagsInit = flagsProp.getInitializer();
364
- if (flagsInit && import_ts_morph2.Node.isArrayLiteralExpression(flagsInit)) {
365
- if (arrayHasElementWithId(flagsInit, VALIDATED_FLAG_VALUE)) return false;
366
- flagsInit.addElement(entry);
367
- return true;
368
- }
369
- return false;
370
- }
371
- action.addPropertyAssignment({
372
- name: FLAGS_PROPERTY_NAME,
373
- initializer: `[${entry}]`
374
- });
375
- return true;
376
- }
377
328
  function processFile2(filePath, project) {
378
329
  const sourceFile = project.getSourceFile(filePath);
379
330
  if (!sourceFile) return 0;
@@ -439,18 +390,6 @@ function processFile2(filePath, project) {
439
390
  ` [${import_path2.default.relative(process.cwd(), filePath)}] Added top-level 'flags' array to defineConfig`
440
391
  );
441
392
  }
442
- if (configHadValidateAction) {
443
- for (const element of actionsInitializer.getElements()) {
444
- if (!import_ts_morph2.Node.isObjectLiteralExpression(element)) continue;
445
- if (!isRegisterAction(element)) continue;
446
- if (ensureRegisterRemovesValidatedFlag(element)) {
447
- transformedCount++;
448
- console.log(
449
- ` [${import_path2.default.relative(process.cwd(), filePath)}] Added '${VALIDATED_FLAG_VALUE}' remove-flag to REGISTER action`
450
- );
451
- }
452
- }
453
- }
454
393
  if (fileNeedsImports) {
455
394
  ensureImports(sourceFile);
456
395
  }
@@ -497,7 +436,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
497
436
  }
498
437
  console.log(
499
438
  `
500
- Done. Applied ${totalTransformed} change(s): VALIDATE \u2192 CUSTOM (${VALIDATE_DECLARATION_VALUE}) and '${VALIDATED_FLAG_VALUE}' remove-flag on matching REGISTER actions.`
439
+ Done. Transformed ${totalTransformed} VALIDATE action(s) to CUSTOM with customActionType: '${VALIDATE_DECLARATION_VALUE}'.`
501
440
  );
502
441
  }
503
442
 
@@ -740,14 +679,14 @@ var QUERY_PROPERTY_NAME = "query";
740
679
  var TYPE_PROPERTY_NAME5 = "type";
741
680
  var CLAUSES_PROPERTY_NAME = "clauses";
742
681
  var STATUS_PROPERTY_NAME = "status";
743
- var FLAGS_PROPERTY_NAME2 = "flags";
682
+ var FLAGS_PROPERTY_NAME = "flags";
744
683
  var TERMS_PROPERTY_NAME = "terms";
745
684
  var TERM_PROPERTY_NAME = "term";
746
685
  var ANY_OF_PROPERTY_NAME = "anyOf";
747
686
  var VALIDATED_STATUS_VALUE = "VALIDATED";
748
- var VALIDATED_FLAG_VALUE2 = "validated";
687
+ var VALIDATED_FLAG_VALUE = "validated";
749
688
  function addValidatedFlag(clause) {
750
- const flagsProperty = clause.getProperty(FLAGS_PROPERTY_NAME2);
689
+ const flagsProperty = clause.getProperty(FLAGS_PROPERTY_NAME);
751
690
  if (flagsProperty && import_ts_morph5.Node.isPropertyAssignment(flagsProperty)) {
752
691
  const flagsInit = flagsProperty.getInitializer();
753
692
  if (flagsInit && import_ts_morph5.Node.isObjectLiteralExpression(flagsInit)) {
@@ -755,19 +694,19 @@ function addValidatedFlag(clause) {
755
694
  if (anyOfProperty && import_ts_morph5.Node.isPropertyAssignment(anyOfProperty)) {
756
695
  const anyOfInit = anyOfProperty.getInitializer();
757
696
  if (anyOfInit && import_ts_morph5.Node.isArrayLiteralExpression(anyOfInit)) {
758
- anyOfInit.addElement(`'${VALIDATED_FLAG_VALUE2}'`);
697
+ anyOfInit.addElement(`'${VALIDATED_FLAG_VALUE}'`);
759
698
  }
760
699
  } else {
761
700
  flagsInit.addPropertyAssignment({
762
701
  name: ANY_OF_PROPERTY_NAME,
763
- initializer: `['${VALIDATED_FLAG_VALUE2}']`
702
+ initializer: `['${VALIDATED_FLAG_VALUE}']`
764
703
  });
765
704
  }
766
705
  }
767
706
  } else {
768
707
  clause.addPropertyAssignment({
769
- name: FLAGS_PROPERTY_NAME2,
770
- initializer: `{ ${ANY_OF_PROPERTY_NAME}: ['${VALIDATED_FLAG_VALUE2}'] }`
708
+ name: FLAGS_PROPERTY_NAME,
709
+ initializer: `{ ${ANY_OF_PROPERTY_NAME}: ['${VALIDATED_FLAG_VALUE}'] }`
771
710
  });
772
711
  }
773
712
  }
@@ -933,26 +872,23 @@ var DEFINE_CONFIG_NAME4 = "defineConfig";
933
872
  var DEFINE_WORKQUEUES_NAME2 = "defineWorkqueues";
934
873
  var ACTIONS_PROPERTY_NAME4 = "actions";
935
874
  var ACTION_PROPERTY_NAME = "action";
936
- var FLAGS_PROPERTY_NAME3 = "flags";
875
+ var FLAGS_PROPERTY_NAME2 = "flags";
937
876
  var QUERY_PROPERTY_NAME2 = "query";
938
877
  var TYPE_PROPERTY_NAME6 = "type";
939
- var ID_PROPERTY_NAME2 = "id";
940
878
  var CLAUSES_PROPERTY_NAME2 = "clauses";
941
879
  var ANY_OF_PROPERTY_NAME2 = "anyOf";
942
880
  var FLAG_ID = "pending-first-certificate-issuance";
943
881
  var REGISTER_TYPE = "REGISTER";
944
882
  var PRINT_CERTIFICATE_TYPE = "PRINT_CERTIFICATE";
945
- function flagDefinitionInitializer(eventType) {
946
- return `{
883
+ var FLAG_DEFINITION_INITIALIZER = `{
947
884
  id: '${FLAG_ID}',
948
885
  label: {
949
- id: 'event.${eventType}.flag.${FLAG_ID}',
886
+ id: 'event.birth.flag.${FLAG_ID}',
950
887
  defaultMessage: 'Pending first certificate issuance',
951
888
  description: 'Flag label for first certificate issuance'
952
889
  },
953
890
  requiresAction: true
954
891
  }`;
955
- }
956
892
  function isActionOfType(obj, typeName) {
957
893
  const typeProperty = obj.getProperty(TYPE_PROPERTY_NAME6);
958
894
  if (!typeProperty || !import_ts_morph6.Node.isPropertyAssignment(typeProperty)) return false;
@@ -966,20 +902,18 @@ function isActionOfType(obj, typeName) {
966
902
  }
967
903
  return false;
968
904
  }
969
- function getEventType(configArg) {
970
- for (const propName of [TYPE_PROPERTY_NAME6, ID_PROPERTY_NAME2]) {
971
- const prop = configArg.getProperty(propName);
972
- if (!prop || !import_ts_morph6.Node.isPropertyAssignment(prop)) continue;
973
- const initializer = prop.getInitializer();
974
- if (!initializer) continue;
975
- if (import_ts_morph6.Node.isStringLiteral(initializer)) {
976
- return initializer.getLiteralValue().toLowerCase();
977
- }
978
- if (import_ts_morph6.Node.isPropertyAccessExpression(initializer)) {
979
- return initializer.getName().toLowerCase();
980
- }
905
+ function isBirthConfig(configArg) {
906
+ const typeProperty = configArg.getProperty(TYPE_PROPERTY_NAME6);
907
+ if (!typeProperty || !import_ts_morph6.Node.isPropertyAssignment(typeProperty)) return false;
908
+ const initializer = typeProperty.getInitializer();
909
+ if (!initializer) return false;
910
+ if (import_ts_morph6.Node.isStringLiteral(initializer)) {
911
+ return initializer.getLiteralValue().toLowerCase() === "birth";
981
912
  }
982
- return null;
913
+ if (import_ts_morph6.Node.isPropertyAccessExpression(initializer)) {
914
+ return initializer.getName().toLowerCase() === "birth";
915
+ }
916
+ return false;
983
917
  }
984
918
  function hasElementWithId(array3, id) {
985
919
  for (const el of array3.getElements()) {
@@ -993,28 +927,27 @@ function hasElementWithId(array3, id) {
993
927
  }
994
928
  return false;
995
929
  }
996
- function ensureTopLevelFlagDefinition(configArg, eventType) {
997
- const initializer = flagDefinitionInitializer(eventType);
998
- const flagsProp = configArg.getProperty(FLAGS_PROPERTY_NAME3);
930
+ function ensureTopLevelFlagDefinition(configArg) {
931
+ const flagsProp = configArg.getProperty(FLAGS_PROPERTY_NAME2);
999
932
  if (flagsProp && import_ts_morph6.Node.isPropertyAssignment(flagsProp)) {
1000
933
  const flagsInit = flagsProp.getInitializer();
1001
934
  if (flagsInit && import_ts_morph6.Node.isArrayLiteralExpression(flagsInit)) {
1002
935
  if (hasElementWithId(flagsInit, FLAG_ID)) return false;
1003
- flagsInit.addElement(initializer);
936
+ flagsInit.addElement(FLAG_DEFINITION_INITIALIZER);
1004
937
  return true;
1005
938
  }
1006
939
  return false;
1007
940
  }
1008
941
  configArg.addPropertyAssignment({
1009
- name: FLAGS_PROPERTY_NAME3,
942
+ name: FLAGS_PROPERTY_NAME2,
1010
943
  initializer: `[
1011
- ${initializer}
944
+ ${FLAG_DEFINITION_INITIALIZER}
1012
945
  ]`
1013
946
  });
1014
947
  return true;
1015
948
  }
1016
949
  function ensureActionOperationFlag(action, operation) {
1017
- const flagsProp = action.getProperty(FLAGS_PROPERTY_NAME3);
950
+ const flagsProp = action.getProperty(FLAGS_PROPERTY_NAME2);
1018
951
  const entry = `{ id: '${FLAG_ID}', operation: '${operation}' }`;
1019
952
  if (flagsProp && import_ts_morph6.Node.isPropertyAssignment(flagsProp)) {
1020
953
  const flagsInit = flagsProp.getInitializer();
@@ -1026,18 +959,16 @@ function ensureActionOperationFlag(action, operation) {
1026
959
  return false;
1027
960
  }
1028
961
  action.addPropertyAssignment({
1029
- name: FLAGS_PROPERTY_NAME3,
962
+ name: FLAGS_PROPERTY_NAME2,
1030
963
  initializer: `[${entry}]`
1031
964
  });
1032
965
  return true;
1033
966
  }
1034
- function processConfig(configArg, eventType, relPath) {
967
+ function processBirthConfig(configArg, relPath) {
1035
968
  let changes = 0;
1036
- if (ensureTopLevelFlagDefinition(configArg, eventType)) {
969
+ if (ensureTopLevelFlagDefinition(configArg)) {
1037
970
  changes++;
1038
- console.log(
1039
- ` [${relPath}] (${eventType}) Added '${FLAG_ID}' to top-level flags`
1040
- );
971
+ console.log(` [${relPath}] Added '${FLAG_ID}' to top-level flags`);
1041
972
  }
1042
973
  const actionsProp = configArg.getProperty(ACTIONS_PROPERTY_NAME4);
1043
974
  if (!actionsProp || !import_ts_morph6.Node.isPropertyAssignment(actionsProp)) return changes;
@@ -1051,7 +982,7 @@ function processConfig(configArg, eventType, relPath) {
1051
982
  if (ensureActionOperationFlag(element, "add")) {
1052
983
  changes++;
1053
984
  console.log(
1054
- ` [${relPath}] (${eventType}) Added '${FLAG_ID}' add-flag to REGISTER action`
985
+ ` [${relPath}] Added '${FLAG_ID}' add-flag to REGISTER action`
1055
986
  );
1056
987
  }
1057
988
  }
@@ -1059,7 +990,7 @@ function processConfig(configArg, eventType, relPath) {
1059
990
  if (ensureActionOperationFlag(element, "remove")) {
1060
991
  changes++;
1061
992
  console.log(
1062
- ` [${relPath}] (${eventType}) Added '${FLAG_ID}' remove-flag to PRINT_CERTIFICATE action`
993
+ ` [${relPath}] Added '${FLAG_ID}' remove-flag to PRINT_CERTIFICATE action`
1063
994
  );
1064
995
  }
1065
996
  }
@@ -1088,7 +1019,7 @@ function hasPrintCertificateAction(workqueue) {
1088
1019
  return false;
1089
1020
  }
1090
1021
  function addFlagToQueryClause(clause) {
1091
- const flagsProp = clause.getProperty(FLAGS_PROPERTY_NAME3);
1022
+ const flagsProp = clause.getProperty(FLAGS_PROPERTY_NAME2);
1092
1023
  if (flagsProp && import_ts_morph6.Node.isPropertyAssignment(flagsProp)) {
1093
1024
  const flagsInit = flagsProp.getInitializer();
1094
1025
  if (flagsInit && import_ts_morph6.Node.isObjectLiteralExpression(flagsInit)) {
@@ -1113,7 +1044,7 @@ function addFlagToQueryClause(clause) {
1113
1044
  }
1114
1045
  } else {
1115
1046
  clause.addPropertyAssignment({
1116
- name: FLAGS_PROPERTY_NAME3,
1047
+ name: FLAGS_PROPERTY_NAME2,
1117
1048
  initializer: `{ ${ANY_OF_PROPERTY_NAME2}: ['${FLAG_ID}'] }`
1118
1049
  });
1119
1050
  return true;
@@ -1157,9 +1088,8 @@ function processFile6(filePath, project) {
1157
1088
  if (args.length === 0) continue;
1158
1089
  const configArg = args[0];
1159
1090
  if (!import_ts_morph6.Node.isObjectLiteralExpression(configArg)) continue;
1160
- const eventType = getEventType(configArg);
1161
- if (!eventType) continue;
1162
- totalChanges += processConfig(configArg, eventType, relPath);
1091
+ if (!isBirthConfig(configArg)) continue;
1092
+ totalChanges += processBirthConfig(configArg, relPath);
1163
1093
  }
1164
1094
  if (calleeName === DEFINE_WORKQUEUES_NAME2) {
1165
1095
  const args = call.getArguments();
@@ -1188,7 +1118,7 @@ function processFile6(filePath, project) {
1188
1118
  async function main6() {
1189
1119
  const srcDir = import_path6.default.join(process.cwd(), "src");
1190
1120
  console.log(
1191
- `Scanning for defineConfig and PRINT_CERTIFICATE workqueues in: ${srcDir}
1121
+ `Scanning for birth defineConfig and PRINT_CERTIFICATE workqueues in: ${srcDir}
1192
1122
  `
1193
1123
  );
1194
1124
  const project = new import_ts_morph6.Project({
@@ -1213,7 +1143,7 @@ async function main6() {
1213
1143
  }
1214
1144
  if (modifiedFiles.length === 0) {
1215
1145
  console.log(
1216
- "No event configs or PRINT_CERTIFICATE workqueues found. Nothing to do."
1146
+ "No birth configs or PRINT_CERTIFICATE workqueues found. Nothing to do."
1217
1147
  );
1218
1148
  return;
1219
1149
  }
@@ -2308,14 +2238,12 @@ var SystemScopeType = z3.enum([
2308
2238
  "organisation.read-locations",
2309
2239
  "user.read",
2310
2240
  "user.create",
2311
- "user.edit",
2312
- "user.search"
2241
+ "user.edit"
2313
2242
  ]);
2314
2243
  var UserScopeType = SystemScopeType.extract([
2315
2244
  "user.read",
2316
2245
  "user.create",
2317
- "user.edit",
2318
- "user.search"
2246
+ "user.edit"
2319
2247
  ]);
2320
2248
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
2321
2249
  var UserScopeV2 = z3.discriminatedUnion("type", [
@@ -2324,7 +2252,7 @@ var UserScopeV2 = z3.discriminatedUnion("type", [
2324
2252
  options: AllUserScopeOptions.optional()
2325
2253
  }),
2326
2254
  z3.object({
2327
- type: UserScopeType.extract(["user.read", "user.search"]),
2255
+ type: UserScopeType.extract(["user.read"]),
2328
2256
  options: AccessLevelOptions.optional()
2329
2257
  })
2330
2258
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"make-built-in-validate-actions-custom.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/make-built-in-validate-actions-custom.ts"],"names":[],"mappings":"AAodA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"make-built-in-validate-actions-custom.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/make-built-in-validate-actions-custom.ts"],"names":[],"mappings":"AA2WA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}