@opencrvs/toolkit 2.0.0-rc.e12df15 → 2.0.0-rc.e4ffdc6
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.
- package/create-countryconfig/index.js +73 -0
- package/create-countryconfig/package.json +11 -0
- package/dist/application-config/index.js +9 -7
- package/dist/cli.js +115 -43
- package/dist/commons/api/router.d.ts +368 -20
- package/dist/commons/application-config/index.d.ts +16 -4
- package/dist/commons/conditionals/conditionals.d.ts +3 -3
- package/dist/commons/events/FieldConfig.d.ts +5 -0
- package/dist/commons/events/locations.d.ts +21 -0
- package/dist/commons/events/mocks.test.utils.d.ts +19 -0
- package/dist/commons/events/scopes.d.ts +24 -1
- package/dist/conditionals/index.js +5 -3
- package/dist/events/index.js +60 -3
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -1
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +60 -35
- package/dist/migrations/v2.0/index.js +115 -43
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -1
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +90 -1
- package/dist/notification/index.js +5 -3
- package/dist/scopes/index.d.ts +6 -1
- package/dist/scopes/index.js +5 -3
- package/opencrvs-toolkit-2.0.0-rc.e4ffdc6.tgz +0 -0
- package/package.json +1 -1
- package/opencrvs-toolkit-2.0.0-rc.e12df15.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
|
+
}
|
|
@@ -772,12 +772,14 @@ var SystemScopeType = z11.enum([
|
|
|
772
772
|
"organisation.read-locations",
|
|
773
773
|
"user.read",
|
|
774
774
|
"user.create",
|
|
775
|
-
"user.edit"
|
|
775
|
+
"user.edit",
|
|
776
|
+
"user.search"
|
|
776
777
|
]);
|
|
777
778
|
var UserScopeType = SystemScopeType.extract([
|
|
778
779
|
"user.read",
|
|
779
780
|
"user.create",
|
|
780
|
-
"user.edit"
|
|
781
|
+
"user.edit",
|
|
782
|
+
"user.search"
|
|
781
783
|
]);
|
|
782
784
|
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
783
785
|
var UserScopeV2 = z11.discriminatedUnion("type", [
|
|
@@ -786,7 +788,7 @@ var UserScopeV2 = z11.discriminatedUnion("type", [
|
|
|
786
788
|
options: AllUserScopeOptions.optional()
|
|
787
789
|
}),
|
|
788
790
|
z11.object({
|
|
789
|
-
type: UserScopeType.extract(["user.read"]),
|
|
791
|
+
type: UserScopeType.extract(["user.read", "user.search"]),
|
|
790
792
|
options: AccessLevelOptions.optional()
|
|
791
793
|
})
|
|
792
794
|
]);
|
|
@@ -2106,8 +2108,8 @@ var ApplicationConfig = z20.object({
|
|
|
2106
2108
|
})
|
|
2107
2109
|
),
|
|
2108
2110
|
PHONE_NUMBER_PATTERN: z20.string().or(z20.instanceof(RegExp)),
|
|
2109
|
-
USER_NOTIFICATION_DELIVERY_METHOD: z20.
|
|
2110
|
-
INFORMANT_NOTIFICATION_DELIVERY_METHOD: z20.
|
|
2111
|
+
USER_NOTIFICATION_DELIVERY_METHOD: z20.enum(["email", "sms"]),
|
|
2112
|
+
INFORMANT_NOTIFICATION_DELIVERY_METHOD: z20.enum(["email", "sms"]),
|
|
2111
2113
|
SEARCH_DEFAULT_CRITERIA: SearchCriteria.optional().default("TRACKING_ID"),
|
|
2112
2114
|
ADDITIONAL_USER_FIELDS: z20.array(FieldConfig).optional().default([])
|
|
2113
2115
|
});
|
|
@@ -2125,8 +2127,8 @@ var BackgroundConfig = z20.object({
|
|
|
2125
2127
|
var LoginConfig = z20.object({
|
|
2126
2128
|
COUNTRY: z20.string(),
|
|
2127
2129
|
LANGUAGES: z20.array(z20.string()),
|
|
2128
|
-
USER_NOTIFICATION_DELIVERY_METHOD: z20.
|
|
2129
|
-
INFORMANT_NOTIFICATION_DELIVERY_METHOD: z20.
|
|
2130
|
+
USER_NOTIFICATION_DELIVERY_METHOD: z20.enum(["email", "sms"]),
|
|
2131
|
+
INFORMANT_NOTIFICATION_DELIVERY_METHOD: z20.enum(["email", "sms"]),
|
|
2130
2132
|
PHONE_NUMBER_PATTERN: z20.string().or(z20.instanceof(RegExp)),
|
|
2131
2133
|
LOGIN_BACKGROUND: BackgroundConfig,
|
|
2132
2134
|
SENTRY: z20.string().optional()
|
package/dist/cli.js
CHANGED
|
@@ -178,6 +178,8 @@ function ensureImports(sourceFile) {
|
|
|
178
178
|
var DEFINE_CONFIG_NAME2 = "defineConfig";
|
|
179
179
|
var ACTIONS_PROPERTY_NAME2 = "actions";
|
|
180
180
|
var TYPE_PROPERTY_NAME2 = "type";
|
|
181
|
+
var ID_PROPERTY_NAME = "id";
|
|
182
|
+
var FLAGS_PROPERTY_NAME = "flags";
|
|
181
183
|
var CUSTOM_ACTION_TYPE_PROPERTY_NAME = "customActionType";
|
|
182
184
|
var AUDIT_HISTORY_LABEL_PROPERTY_NAME = "auditHistoryLabel";
|
|
183
185
|
var DEDUPLICATION_PROPERTY_NAME = "deduplication";
|
|
@@ -187,9 +189,12 @@ var FORM_PROPERTY_NAME = "form";
|
|
|
187
189
|
var ACTION_TYPE_ENUM_NAME = "ActionType";
|
|
188
190
|
var VALIDATE_MEMBER_NAME = "VALIDATE";
|
|
189
191
|
var CUSTOM_MEMBER_NAME = "CUSTOM";
|
|
192
|
+
var REGISTER_MEMBER_NAME2 = "REGISTER";
|
|
190
193
|
var VALIDATE_STRING_LITERAL = "VALIDATE";
|
|
191
194
|
var CUSTOM_STRING_LITERAL = "CUSTOM";
|
|
195
|
+
var REGISTER_STRING_LITERAL2 = "REGISTER";
|
|
192
196
|
var VALIDATE_DECLARATION_VALUE = "VALIDATE_DECLARATION";
|
|
197
|
+
var VALIDATED_FLAG_VALUE = "validated";
|
|
193
198
|
function isValidateType(typeInitializer) {
|
|
194
199
|
if (typeInitializer.getKind() === import_ts_morph2.SyntaxKind.PropertyAccessExpression) {
|
|
195
200
|
const propAccess = typeInitializer.asKindOrThrow(
|
|
@@ -313,6 +318,50 @@ function transformValidateActionToCustom(obj, eventType) {
|
|
|
313
318
|
}
|
|
314
319
|
return true;
|
|
315
320
|
}
|
|
321
|
+
function isRegisterAction(action) {
|
|
322
|
+
const typeProperty = action.getProperty(TYPE_PROPERTY_NAME2);
|
|
323
|
+
if (!typeProperty || !import_ts_morph2.Node.isPropertyAssignment(typeProperty)) return false;
|
|
324
|
+
const typeInit = typeProperty.getInitializer();
|
|
325
|
+
if (!typeInit) return false;
|
|
326
|
+
if (import_ts_morph2.Node.isPropertyAccessExpression(typeInit)) {
|
|
327
|
+
const enumExpr = typeInit.getExpression();
|
|
328
|
+
return import_ts_morph2.Node.isIdentifier(enumExpr) && enumExpr.getText() === ACTION_TYPE_ENUM_NAME && typeInit.getName() === REGISTER_MEMBER_NAME2;
|
|
329
|
+
}
|
|
330
|
+
if (import_ts_morph2.Node.isStringLiteral(typeInit)) {
|
|
331
|
+
return typeInit.getLiteralValue() === REGISTER_STRING_LITERAL2;
|
|
332
|
+
}
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
function arrayHasElementWithId(array3, id) {
|
|
336
|
+
for (const el of array3.getElements()) {
|
|
337
|
+
if (!import_ts_morph2.Node.isObjectLiteralExpression(el)) continue;
|
|
338
|
+
const idProp = el.getProperty(ID_PROPERTY_NAME);
|
|
339
|
+
if (!idProp || !import_ts_morph2.Node.isPropertyAssignment(idProp)) continue;
|
|
340
|
+
const idInit = idProp.getInitializer();
|
|
341
|
+
if (idInit && import_ts_morph2.Node.isStringLiteral(idInit) && idInit.getLiteralValue() === id) {
|
|
342
|
+
return true;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
347
|
+
function ensureRegisterRemovesValidatedFlag(action) {
|
|
348
|
+
const entry = `{ id: '${VALIDATED_FLAG_VALUE}', operation: 'remove' }`;
|
|
349
|
+
const flagsProp = action.getProperty(FLAGS_PROPERTY_NAME);
|
|
350
|
+
if (flagsProp && import_ts_morph2.Node.isPropertyAssignment(flagsProp)) {
|
|
351
|
+
const flagsInit = flagsProp.getInitializer();
|
|
352
|
+
if (flagsInit && import_ts_morph2.Node.isArrayLiteralExpression(flagsInit)) {
|
|
353
|
+
if (arrayHasElementWithId(flagsInit, VALIDATED_FLAG_VALUE)) return false;
|
|
354
|
+
flagsInit.addElement(entry);
|
|
355
|
+
return true;
|
|
356
|
+
}
|
|
357
|
+
return false;
|
|
358
|
+
}
|
|
359
|
+
action.addPropertyAssignment({
|
|
360
|
+
name: FLAGS_PROPERTY_NAME,
|
|
361
|
+
initializer: `[${entry}]`
|
|
362
|
+
});
|
|
363
|
+
return true;
|
|
364
|
+
}
|
|
316
365
|
function processFile2(filePath, project) {
|
|
317
366
|
const sourceFile = project.getSourceFile(filePath);
|
|
318
367
|
if (!sourceFile) return 0;
|
|
@@ -378,6 +427,18 @@ function processFile2(filePath, project) {
|
|
|
378
427
|
` [${import_path2.default.relative(process.cwd(), filePath)}] Added top-level 'flags' array to defineConfig`
|
|
379
428
|
);
|
|
380
429
|
}
|
|
430
|
+
if (configHadValidateAction) {
|
|
431
|
+
for (const element of actionsInitializer.getElements()) {
|
|
432
|
+
if (!import_ts_morph2.Node.isObjectLiteralExpression(element)) continue;
|
|
433
|
+
if (!isRegisterAction(element)) continue;
|
|
434
|
+
if (ensureRegisterRemovesValidatedFlag(element)) {
|
|
435
|
+
transformedCount++;
|
|
436
|
+
console.log(
|
|
437
|
+
` [${import_path2.default.relative(process.cwd(), filePath)}] Added '${VALIDATED_FLAG_VALUE}' remove-flag to REGISTER action`
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
381
442
|
if (fileNeedsImports) {
|
|
382
443
|
ensureImports(sourceFile);
|
|
383
444
|
}
|
|
@@ -424,7 +485,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
|
|
|
424
485
|
}
|
|
425
486
|
console.log(
|
|
426
487
|
`
|
|
427
|
-
Done.
|
|
488
|
+
Done. Applied ${totalTransformed} change(s): VALIDATE \u2192 CUSTOM (${VALIDATE_DECLARATION_VALUE}) and '${VALIDATED_FLAG_VALUE}' remove-flag on matching REGISTER actions.`
|
|
428
489
|
);
|
|
429
490
|
}
|
|
430
491
|
|
|
@@ -667,14 +728,14 @@ var QUERY_PROPERTY_NAME = "query";
|
|
|
667
728
|
var TYPE_PROPERTY_NAME5 = "type";
|
|
668
729
|
var CLAUSES_PROPERTY_NAME = "clauses";
|
|
669
730
|
var STATUS_PROPERTY_NAME = "status";
|
|
670
|
-
var
|
|
731
|
+
var FLAGS_PROPERTY_NAME2 = "flags";
|
|
671
732
|
var TERMS_PROPERTY_NAME = "terms";
|
|
672
733
|
var TERM_PROPERTY_NAME = "term";
|
|
673
734
|
var ANY_OF_PROPERTY_NAME = "anyOf";
|
|
674
735
|
var VALIDATED_STATUS_VALUE = "VALIDATED";
|
|
675
|
-
var
|
|
736
|
+
var VALIDATED_FLAG_VALUE2 = "validated";
|
|
676
737
|
function addValidatedFlag(clause) {
|
|
677
|
-
const flagsProperty = clause.getProperty(
|
|
738
|
+
const flagsProperty = clause.getProperty(FLAGS_PROPERTY_NAME2);
|
|
678
739
|
if (flagsProperty && import_ts_morph5.Node.isPropertyAssignment(flagsProperty)) {
|
|
679
740
|
const flagsInit = flagsProperty.getInitializer();
|
|
680
741
|
if (flagsInit && import_ts_morph5.Node.isObjectLiteralExpression(flagsInit)) {
|
|
@@ -682,19 +743,19 @@ function addValidatedFlag(clause) {
|
|
|
682
743
|
if (anyOfProperty && import_ts_morph5.Node.isPropertyAssignment(anyOfProperty)) {
|
|
683
744
|
const anyOfInit = anyOfProperty.getInitializer();
|
|
684
745
|
if (anyOfInit && import_ts_morph5.Node.isArrayLiteralExpression(anyOfInit)) {
|
|
685
|
-
anyOfInit.addElement(`'${
|
|
746
|
+
anyOfInit.addElement(`'${VALIDATED_FLAG_VALUE2}'`);
|
|
686
747
|
}
|
|
687
748
|
} else {
|
|
688
749
|
flagsInit.addPropertyAssignment({
|
|
689
750
|
name: ANY_OF_PROPERTY_NAME,
|
|
690
|
-
initializer: `['${
|
|
751
|
+
initializer: `['${VALIDATED_FLAG_VALUE2}']`
|
|
691
752
|
});
|
|
692
753
|
}
|
|
693
754
|
}
|
|
694
755
|
} else {
|
|
695
756
|
clause.addPropertyAssignment({
|
|
696
|
-
name:
|
|
697
|
-
initializer: `{ ${ANY_OF_PROPERTY_NAME}: ['${
|
|
757
|
+
name: FLAGS_PROPERTY_NAME2,
|
|
758
|
+
initializer: `{ ${ANY_OF_PROPERTY_NAME}: ['${VALIDATED_FLAG_VALUE2}'] }`
|
|
698
759
|
});
|
|
699
760
|
}
|
|
700
761
|
}
|
|
@@ -860,23 +921,26 @@ var DEFINE_CONFIG_NAME4 = "defineConfig";
|
|
|
860
921
|
var DEFINE_WORKQUEUES_NAME2 = "defineWorkqueues";
|
|
861
922
|
var ACTIONS_PROPERTY_NAME4 = "actions";
|
|
862
923
|
var ACTION_PROPERTY_NAME = "action";
|
|
863
|
-
var
|
|
924
|
+
var FLAGS_PROPERTY_NAME3 = "flags";
|
|
864
925
|
var QUERY_PROPERTY_NAME2 = "query";
|
|
865
926
|
var TYPE_PROPERTY_NAME6 = "type";
|
|
927
|
+
var ID_PROPERTY_NAME2 = "id";
|
|
866
928
|
var CLAUSES_PROPERTY_NAME2 = "clauses";
|
|
867
929
|
var ANY_OF_PROPERTY_NAME2 = "anyOf";
|
|
868
930
|
var FLAG_ID = "pending-first-certificate-issuance";
|
|
869
931
|
var REGISTER_TYPE = "REGISTER";
|
|
870
932
|
var PRINT_CERTIFICATE_TYPE = "PRINT_CERTIFICATE";
|
|
871
|
-
|
|
933
|
+
function flagDefinitionInitializer(eventType) {
|
|
934
|
+
return `{
|
|
872
935
|
id: '${FLAG_ID}',
|
|
873
936
|
label: {
|
|
874
|
-
id: 'event.
|
|
937
|
+
id: 'event.${eventType}.flag.${FLAG_ID}',
|
|
875
938
|
defaultMessage: 'Pending first certificate issuance',
|
|
876
939
|
description: 'Flag label for first certificate issuance'
|
|
877
940
|
},
|
|
878
941
|
requiresAction: true
|
|
879
942
|
}`;
|
|
943
|
+
}
|
|
880
944
|
function isActionOfType(obj, typeName) {
|
|
881
945
|
const typeProperty = obj.getProperty(TYPE_PROPERTY_NAME6);
|
|
882
946
|
if (!typeProperty || !import_ts_morph6.Node.isPropertyAssignment(typeProperty)) return false;
|
|
@@ -890,18 +954,20 @@ function isActionOfType(obj, typeName) {
|
|
|
890
954
|
}
|
|
891
955
|
return false;
|
|
892
956
|
}
|
|
893
|
-
function
|
|
894
|
-
const
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
957
|
+
function getEventType(configArg) {
|
|
958
|
+
for (const propName of [TYPE_PROPERTY_NAME6, ID_PROPERTY_NAME2]) {
|
|
959
|
+
const prop = configArg.getProperty(propName);
|
|
960
|
+
if (!prop || !import_ts_morph6.Node.isPropertyAssignment(prop)) continue;
|
|
961
|
+
const initializer = prop.getInitializer();
|
|
962
|
+
if (!initializer) continue;
|
|
963
|
+
if (import_ts_morph6.Node.isStringLiteral(initializer)) {
|
|
964
|
+
return initializer.getLiteralValue().toLowerCase();
|
|
965
|
+
}
|
|
966
|
+
if (import_ts_morph6.Node.isPropertyAccessExpression(initializer)) {
|
|
967
|
+
return initializer.getName().toLowerCase();
|
|
968
|
+
}
|
|
903
969
|
}
|
|
904
|
-
return
|
|
970
|
+
return null;
|
|
905
971
|
}
|
|
906
972
|
function hasElementWithId(array3, id) {
|
|
907
973
|
for (const el of array3.getElements()) {
|
|
@@ -915,27 +981,28 @@ function hasElementWithId(array3, id) {
|
|
|
915
981
|
}
|
|
916
982
|
return false;
|
|
917
983
|
}
|
|
918
|
-
function ensureTopLevelFlagDefinition(configArg) {
|
|
919
|
-
const
|
|
984
|
+
function ensureTopLevelFlagDefinition(configArg, eventType) {
|
|
985
|
+
const initializer = flagDefinitionInitializer(eventType);
|
|
986
|
+
const flagsProp = configArg.getProperty(FLAGS_PROPERTY_NAME3);
|
|
920
987
|
if (flagsProp && import_ts_morph6.Node.isPropertyAssignment(flagsProp)) {
|
|
921
988
|
const flagsInit = flagsProp.getInitializer();
|
|
922
989
|
if (flagsInit && import_ts_morph6.Node.isArrayLiteralExpression(flagsInit)) {
|
|
923
990
|
if (hasElementWithId(flagsInit, FLAG_ID)) return false;
|
|
924
|
-
flagsInit.addElement(
|
|
991
|
+
flagsInit.addElement(initializer);
|
|
925
992
|
return true;
|
|
926
993
|
}
|
|
927
994
|
return false;
|
|
928
995
|
}
|
|
929
996
|
configArg.addPropertyAssignment({
|
|
930
|
-
name:
|
|
997
|
+
name: FLAGS_PROPERTY_NAME3,
|
|
931
998
|
initializer: `[
|
|
932
|
-
${
|
|
999
|
+
${initializer}
|
|
933
1000
|
]`
|
|
934
1001
|
});
|
|
935
1002
|
return true;
|
|
936
1003
|
}
|
|
937
1004
|
function ensureActionOperationFlag(action, operation) {
|
|
938
|
-
const flagsProp = action.getProperty(
|
|
1005
|
+
const flagsProp = action.getProperty(FLAGS_PROPERTY_NAME3);
|
|
939
1006
|
const entry = `{ id: '${FLAG_ID}', operation: '${operation}' }`;
|
|
940
1007
|
if (flagsProp && import_ts_morph6.Node.isPropertyAssignment(flagsProp)) {
|
|
941
1008
|
const flagsInit = flagsProp.getInitializer();
|
|
@@ -947,16 +1014,18 @@ function ensureActionOperationFlag(action, operation) {
|
|
|
947
1014
|
return false;
|
|
948
1015
|
}
|
|
949
1016
|
action.addPropertyAssignment({
|
|
950
|
-
name:
|
|
1017
|
+
name: FLAGS_PROPERTY_NAME3,
|
|
951
1018
|
initializer: `[${entry}]`
|
|
952
1019
|
});
|
|
953
1020
|
return true;
|
|
954
1021
|
}
|
|
955
|
-
function
|
|
1022
|
+
function processConfig(configArg, eventType, relPath) {
|
|
956
1023
|
let changes = 0;
|
|
957
|
-
if (ensureTopLevelFlagDefinition(configArg)) {
|
|
1024
|
+
if (ensureTopLevelFlagDefinition(configArg, eventType)) {
|
|
958
1025
|
changes++;
|
|
959
|
-
console.log(
|
|
1026
|
+
console.log(
|
|
1027
|
+
` [${relPath}] (${eventType}) Added '${FLAG_ID}' to top-level flags`
|
|
1028
|
+
);
|
|
960
1029
|
}
|
|
961
1030
|
const actionsProp = configArg.getProperty(ACTIONS_PROPERTY_NAME4);
|
|
962
1031
|
if (!actionsProp || !import_ts_morph6.Node.isPropertyAssignment(actionsProp)) return changes;
|
|
@@ -970,7 +1039,7 @@ function processBirthConfig(configArg, relPath) {
|
|
|
970
1039
|
if (ensureActionOperationFlag(element, "add")) {
|
|
971
1040
|
changes++;
|
|
972
1041
|
console.log(
|
|
973
|
-
` [${relPath}] Added '${FLAG_ID}' add-flag to REGISTER action`
|
|
1042
|
+
` [${relPath}] (${eventType}) Added '${FLAG_ID}' add-flag to REGISTER action`
|
|
974
1043
|
);
|
|
975
1044
|
}
|
|
976
1045
|
}
|
|
@@ -978,7 +1047,7 @@ function processBirthConfig(configArg, relPath) {
|
|
|
978
1047
|
if (ensureActionOperationFlag(element, "remove")) {
|
|
979
1048
|
changes++;
|
|
980
1049
|
console.log(
|
|
981
|
-
` [${relPath}] Added '${FLAG_ID}' remove-flag to PRINT_CERTIFICATE action`
|
|
1050
|
+
` [${relPath}] (${eventType}) Added '${FLAG_ID}' remove-flag to PRINT_CERTIFICATE action`
|
|
982
1051
|
);
|
|
983
1052
|
}
|
|
984
1053
|
}
|
|
@@ -1007,7 +1076,7 @@ function hasPrintCertificateAction(workqueue) {
|
|
|
1007
1076
|
return false;
|
|
1008
1077
|
}
|
|
1009
1078
|
function addFlagToQueryClause(clause) {
|
|
1010
|
-
const flagsProp = clause.getProperty(
|
|
1079
|
+
const flagsProp = clause.getProperty(FLAGS_PROPERTY_NAME3);
|
|
1011
1080
|
if (flagsProp && import_ts_morph6.Node.isPropertyAssignment(flagsProp)) {
|
|
1012
1081
|
const flagsInit = flagsProp.getInitializer();
|
|
1013
1082
|
if (flagsInit && import_ts_morph6.Node.isObjectLiteralExpression(flagsInit)) {
|
|
@@ -1032,7 +1101,7 @@ function addFlagToQueryClause(clause) {
|
|
|
1032
1101
|
}
|
|
1033
1102
|
} else {
|
|
1034
1103
|
clause.addPropertyAssignment({
|
|
1035
|
-
name:
|
|
1104
|
+
name: FLAGS_PROPERTY_NAME3,
|
|
1036
1105
|
initializer: `{ ${ANY_OF_PROPERTY_NAME2}: ['${FLAG_ID}'] }`
|
|
1037
1106
|
});
|
|
1038
1107
|
return true;
|
|
@@ -1076,8 +1145,9 @@ function processFile6(filePath, project) {
|
|
|
1076
1145
|
if (args2.length === 0) continue;
|
|
1077
1146
|
const configArg = args2[0];
|
|
1078
1147
|
if (!import_ts_morph6.Node.isObjectLiteralExpression(configArg)) continue;
|
|
1079
|
-
|
|
1080
|
-
|
|
1148
|
+
const eventType = getEventType(configArg);
|
|
1149
|
+
if (!eventType) continue;
|
|
1150
|
+
totalChanges += processConfig(configArg, eventType, relPath);
|
|
1081
1151
|
}
|
|
1082
1152
|
if (calleeName === DEFINE_WORKQUEUES_NAME2) {
|
|
1083
1153
|
const args2 = call.getArguments();
|
|
@@ -1106,7 +1176,7 @@ function processFile6(filePath, project) {
|
|
|
1106
1176
|
async function main6() {
|
|
1107
1177
|
const srcDir = import_path6.default.join(process.cwd(), "src");
|
|
1108
1178
|
console.log(
|
|
1109
|
-
`Scanning for
|
|
1179
|
+
`Scanning for defineConfig and PRINT_CERTIFICATE workqueues in: ${srcDir}
|
|
1110
1180
|
`
|
|
1111
1181
|
);
|
|
1112
1182
|
const project = new import_ts_morph6.Project({
|
|
@@ -1131,7 +1201,7 @@ async function main6() {
|
|
|
1131
1201
|
}
|
|
1132
1202
|
if (modifiedFiles.length === 0) {
|
|
1133
1203
|
console.log(
|
|
1134
|
-
"No
|
|
1204
|
+
"No event configs or PRINT_CERTIFICATE workqueues found. Nothing to do."
|
|
1135
1205
|
);
|
|
1136
1206
|
return;
|
|
1137
1207
|
}
|
|
@@ -2226,12 +2296,14 @@ var SystemScopeType = z3.enum([
|
|
|
2226
2296
|
"organisation.read-locations",
|
|
2227
2297
|
"user.read",
|
|
2228
2298
|
"user.create",
|
|
2229
|
-
"user.edit"
|
|
2299
|
+
"user.edit",
|
|
2300
|
+
"user.search"
|
|
2230
2301
|
]);
|
|
2231
2302
|
var UserScopeType = SystemScopeType.extract([
|
|
2232
2303
|
"user.read",
|
|
2233
2304
|
"user.create",
|
|
2234
|
-
"user.edit"
|
|
2305
|
+
"user.edit",
|
|
2306
|
+
"user.search"
|
|
2235
2307
|
]);
|
|
2236
2308
|
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
2237
2309
|
var UserScopeV2 = z3.discriminatedUnion("type", [
|
|
@@ -2240,7 +2312,7 @@ var UserScopeV2 = z3.discriminatedUnion("type", [
|
|
|
2240
2312
|
options: AllUserScopeOptions.optional()
|
|
2241
2313
|
}),
|
|
2242
2314
|
z3.object({
|
|
2243
|
-
type: UserScopeType.extract(["user.read"]),
|
|
2315
|
+
type: UserScopeType.extract(["user.read", "user.search"]),
|
|
2244
2316
|
options: AccessLevelOptions.optional()
|
|
2245
2317
|
})
|
|
2246
2318
|
]);
|