@opencrvs/toolkit 2.0.0-rc.f2d9566 → 2.0.0-rc.f38dc6b
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 +50 -20
- package/dist/commons/conditionals/conditionals.d.ts +6 -0
- package/dist/commons/events/index.d.ts +1 -0
- package/dist/commons/events/state/flags.d.ts +2 -0
- package/dist/conditionals/index.js +4 -0
- package/dist/events/index.js +7 -0
- package/opencrvs-toolkit-2.0.0-rc.f38dc6b.tgz +0 -0
- package/package.json +2 -2
- package/opencrvs-toolkit-2.0.0-rc.f2d9566.tgz +0 -0
|
@@ -15,7 +15,10 @@ const { execSync } = require('child_process')
|
|
|
15
15
|
const path = require('path')
|
|
16
16
|
const fs = require('fs')
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const COUNTRYCONFIG_REPO_URL =
|
|
19
|
+
'https://github.com/opencrvs/opencrvs-countryconfig.git'
|
|
20
|
+
const INFRASTRUCTURE_REPO_URL =
|
|
21
|
+
'https://github.com/opencrvs/infrastructure.git'
|
|
19
22
|
|
|
20
23
|
const projectName = process.argv[2]
|
|
21
24
|
|
|
@@ -26,48 +29,75 @@ if (!projectName) {
|
|
|
26
29
|
process.exit(1)
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
const
|
|
32
|
+
const countryconfigDirName = projectName + '-countryconfig'
|
|
33
|
+
const infrastructureDirName = projectName + '-infrastructure'
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
const countryconfigTargetDir = path.resolve(process.cwd(), countryconfigDirName)
|
|
36
|
+
const infrastructureTargetDir = path.resolve(process.cwd(), infrastructureDirName)
|
|
37
|
+
|
|
38
|
+
if (fs.existsSync(countryconfigTargetDir)) {
|
|
39
|
+
console.error('Error: Directory "' + countryconfigDirName + '" already exists.')
|
|
40
|
+
process.exit(1)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (fs.existsSync(infrastructureTargetDir)) {
|
|
44
|
+
console.error('Error: Directory "' + infrastructureDirName + '" already exists.')
|
|
33
45
|
process.exit(1)
|
|
34
46
|
}
|
|
35
47
|
|
|
36
|
-
console.log(
|
|
48
|
+
console.log('\nScaffolding OpenCRVS country config in ./' + countryconfigDirName + '...\n')
|
|
37
49
|
|
|
38
50
|
try {
|
|
39
|
-
execSync(
|
|
40
|
-
stdio: 'inherit'
|
|
41
|
-
})
|
|
51
|
+
execSync('git clone --depth 1 ' + COUNTRYCONFIG_REPO_URL + ' ' + countryconfigDirName, { stdio: 'inherit' })
|
|
42
52
|
} catch (err) {
|
|
43
|
-
console.error('Failed to clone the repository:', err.message)
|
|
53
|
+
console.error('Failed to clone the country config repository:', err.message)
|
|
44
54
|
process.exit(1)
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
try {
|
|
48
|
-
fs.rmSync(path.join(
|
|
58
|
+
fs.rmSync(path.join(countryconfigTargetDir, '.git'), { recursive: true, force: true })
|
|
49
59
|
} catch (err) {
|
|
50
|
-
console.error('Failed to remove .git directory:', err.message)
|
|
60
|
+
console.error('Failed to remove .git directory from country config:', err.message)
|
|
51
61
|
process.exit(1)
|
|
52
62
|
}
|
|
53
63
|
|
|
54
|
-
const pkgPath = path.join(
|
|
64
|
+
const pkgPath = path.join(countryconfigTargetDir, 'package.json')
|
|
55
65
|
if (fs.existsSync(pkgPath)) {
|
|
56
66
|
try {
|
|
57
67
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
|
|
58
|
-
pkg.name =
|
|
68
|
+
pkg.name = countryconfigDirName
|
|
59
69
|
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n')
|
|
60
70
|
} catch (err) {
|
|
61
71
|
console.error('Failed to update package.json:', err.message)
|
|
62
72
|
process.exit(1)
|
|
63
73
|
}
|
|
64
74
|
} else {
|
|
65
|
-
console.warn(
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
console.warn('Warning: No package.json found in the cloned country config repository. Project name was not updated.')
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
console.log('\nScaffolding OpenCRVS infrastructure in ./' + infrastructureDirName + '...\n')
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
execSync('git clone --depth 1 ' + INFRASTRUCTURE_REPO_URL + ' ' + infrastructureDirName, { stdio: 'inherit' })
|
|
82
|
+
} catch (err) {
|
|
83
|
+
console.error('Failed to clone the infrastructure repository:', err.message)
|
|
84
|
+
process.exit(1)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
try {
|
|
88
|
+
fs.rmSync(path.join(infrastructureTargetDir, '.git'), { recursive: true, force: true })
|
|
89
|
+
} catch (err) {
|
|
90
|
+
console.error('Failed to remove .git directory from infrastructure:', err.message)
|
|
91
|
+
process.exit(1)
|
|
68
92
|
}
|
|
69
93
|
|
|
70
|
-
console.log(
|
|
71
|
-
console.log(
|
|
72
|
-
console.log(
|
|
73
|
-
console.log(
|
|
94
|
+
console.log('\nDone! Your project has been set up in two directories:\n')
|
|
95
|
+
console.log(' ./' + countryconfigDirName + ' -- country configuration')
|
|
96
|
+
console.log(' ./' + infrastructureDirName + ' -- server infrastructure\n')
|
|
97
|
+
console.log('To get started with the country config:\n')
|
|
98
|
+
console.log(' cd ' + countryconfigDirName)
|
|
99
|
+
console.log(' git init')
|
|
100
|
+
console.log(' npm install\n')
|
|
101
|
+
console.log('To get started with the infrastructure:\n')
|
|
102
|
+
console.log(' cd ' + infrastructureDirName)
|
|
103
|
+
console.log(' git init\n')
|
|
@@ -67,6 +67,12 @@ export declare function not(condition: AjvJSONSchema): JSONSchema;
|
|
|
67
67
|
* @returns {JSONSchema} An schema object that always evaluates to false.
|
|
68
68
|
*/
|
|
69
69
|
export declare function never(): JSONSchema;
|
|
70
|
+
/**
|
|
71
|
+
* Returns an JSON Schema object, which is treated as always valid.
|
|
72
|
+
*
|
|
73
|
+
* @returns {JSONSchema} An schema object that always evaluates to true.
|
|
74
|
+
*/
|
|
75
|
+
export declare function always(): JSONSchema;
|
|
70
76
|
/**
|
|
71
77
|
* Generate conditional rules for current date
|
|
72
78
|
*/
|
|
@@ -22,6 +22,7 @@ export * from './FieldValue';
|
|
|
22
22
|
export * from './FormConfig';
|
|
23
23
|
export * from './CompositeFieldValue';
|
|
24
24
|
export * from './state';
|
|
25
|
+
export * from './state/flags';
|
|
25
26
|
export * from './utils';
|
|
26
27
|
export * from './defineConfig';
|
|
27
28
|
export * from './DeduplicationConfig';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { Action } from '../ActionDocument';
|
|
1
2
|
import { Flag, CustomFlag } from '../Flag';
|
|
2
3
|
import { EventConfig } from '../EventConfig';
|
|
3
4
|
import { EventDocument } from '../EventDocument';
|
|
5
|
+
export declare function isPotentialDuplicate(actions: Action[]): boolean;
|
|
4
6
|
/**
|
|
5
7
|
* This function resolves custom flags for an event based on its actions.
|
|
6
8
|
* Flags are not stored to the event state or any database directly, instead they are always computed/evaluated from the event actions.
|
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/conditionals/index.ts
|
|
31
31
|
var conditionals_exports = {};
|
|
32
32
|
__export(conditionals_exports, {
|
|
33
|
+
always: () => always,
|
|
33
34
|
alwaysTrue: () => alwaysTrue,
|
|
34
35
|
and: () => and,
|
|
35
36
|
createFieldConditionals: () => createFieldConditionals,
|
|
@@ -454,6 +455,9 @@ function not(condition) {
|
|
|
454
455
|
function never() {
|
|
455
456
|
return not(alwaysTrue());
|
|
456
457
|
}
|
|
458
|
+
function always() {
|
|
459
|
+
return defineConditional(alwaysTrue());
|
|
460
|
+
}
|
|
457
461
|
function jsonFieldPath(field) {
|
|
458
462
|
return [field.$$field, ...field.$$subfield].join("/");
|
|
459
463
|
}
|
package/dist/events/index.js
CHANGED
|
@@ -238,6 +238,7 @@ __export(events_exports, {
|
|
|
238
238
|
ageToDate: () => ageToDate,
|
|
239
239
|
aggregateActionAnnotations: () => aggregateActionAnnotations,
|
|
240
240
|
aggregateActionDeclarations: () => aggregateActionDeclarations,
|
|
241
|
+
always: () => always,
|
|
241
242
|
alwaysTrue: () => alwaysTrue,
|
|
242
243
|
and: () => and,
|
|
243
244
|
annotationActions: () => annotationActions,
|
|
@@ -322,6 +323,7 @@ __export(events_exports, {
|
|
|
322
323
|
getDeclarationFields: () => getDeclarationFields,
|
|
323
324
|
getDeclarationPages: () => getDeclarationPages,
|
|
324
325
|
getEventConfigById: () => getEventConfigById,
|
|
326
|
+
getEventFlags: () => getEventFlags,
|
|
325
327
|
getFilePathsFromEvent: () => getFilePathsFromEvent,
|
|
326
328
|
getLocationHierarchy: () => getLocationHierarchy,
|
|
327
329
|
getMixedPath: () => getMixedPath,
|
|
@@ -384,6 +386,7 @@ __export(events_exports, {
|
|
|
384
386
|
isPageVisible: () => isPageVisible,
|
|
385
387
|
isParagraphFieldType: () => isParagraphFieldType,
|
|
386
388
|
isPhoneFieldType: () => isPhoneFieldType,
|
|
389
|
+
isPotentialDuplicate: () => isPotentialDuplicate,
|
|
387
390
|
isPrintButtonFieldType: () => isPrintButtonFieldType,
|
|
388
391
|
isQrReaderFieldType: () => isQrReaderFieldType,
|
|
389
392
|
isQueryParamReaderFieldType: () => isQueryParamReaderFieldType,
|
|
@@ -417,6 +420,7 @@ __export(events_exports, {
|
|
|
417
420
|
plainDateToLocalDate: () => plainDateToLocalDate,
|
|
418
421
|
precompileActionSchemas: () => precompileActionSchemas,
|
|
419
422
|
resolveDateOfEvent: () => resolveDateOfEvent,
|
|
423
|
+
resolveEventCustomFlags: () => resolveEventCustomFlags,
|
|
420
424
|
resolvePlaceOfEvent: () => resolvePlaceOfEvent,
|
|
421
425
|
runFieldValidations: () => runFieldValidations,
|
|
422
426
|
runStructuralValidations: () => runStructuralValidations,
|
|
@@ -4854,6 +4858,9 @@ function not(condition) {
|
|
|
4854
4858
|
function never2() {
|
|
4855
4859
|
return not(alwaysTrue());
|
|
4856
4860
|
}
|
|
4861
|
+
function always() {
|
|
4862
|
+
return defineConditional(alwaysTrue());
|
|
4863
|
+
}
|
|
4857
4864
|
function jsonFieldPath(field3) {
|
|
4858
4865
|
return [field3.$$field, ...field3.$$subfield].join("/");
|
|
4859
4866
|
}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opencrvs/toolkit",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.f38dc6b",
|
|
4
4
|
"description": "OpenCRVS toolkit for building country configurations",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"bin": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"jwt-decode": "^3.0.0",
|
|
34
34
|
"lodash": "^4.17.10",
|
|
35
35
|
"object-hash": "^3.0.0",
|
|
36
|
-
"qs": "6.
|
|
36
|
+
"qs": "6.15.2",
|
|
37
37
|
"superjson": "1.9.0-0",
|
|
38
38
|
"ts-morph": "^27.0.2",
|
|
39
39
|
"uuid": "^9.0.0",
|
|
Binary file
|