@chain-registry/workflows 1.41.0 → 1.43.0
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/esm/registry.js +17 -11
- package/esm/validator.js +14 -8
- package/package.json +3 -3
- package/registry.js +17 -11
- package/validator.js +14 -8
package/esm/registry.js
CHANGED
|
@@ -103,17 +103,23 @@ export class Registry {
|
|
|
103
103
|
ignore: IGNORE_ROOT_DIRS.map(dir => `${this.basePath}/${dir}/**/*`)
|
|
104
104
|
})
|
|
105
105
|
.map(path => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
106
|
+
try {
|
|
107
|
+
const content = JSON.parse(readFileSync(path, 'utf-8'));
|
|
108
|
+
if (!this.isJsonSchema(content))
|
|
109
|
+
return;
|
|
110
|
+
// https://stackoverflow.com/questions/69133771/ajv-no-schema-with-key-or-ref-https-json-schema-org-draft-07-schema
|
|
111
|
+
content.$schema = content.$schema.replace(/https/, 'http');
|
|
112
|
+
types[basename(content.$schema)] = true;
|
|
113
|
+
return {
|
|
114
|
+
$schemaFile: basename(content.$schema),
|
|
115
|
+
path,
|
|
116
|
+
content
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
// Throw a custom error with a clear message including the file path
|
|
121
|
+
throw new Error(`Failed to parse JSON. The file at "${path}" is not valid JSON.`);
|
|
122
|
+
}
|
|
117
123
|
}).filter(Boolean);
|
|
118
124
|
// filter out schemas (e.g. draft-04/schema )
|
|
119
125
|
const schemas = this.definitions.filter(schema => this.isSchema(schema.content)).filter(Boolean);
|
package/esm/validator.js
CHANGED
|
@@ -18,15 +18,21 @@ export class SchemaValidator {
|
|
|
18
18
|
// Compile and validate each schema, then validate corresponding data
|
|
19
19
|
this.registry.forEachSchemas(([title, schema]) => {
|
|
20
20
|
schema.content.$schema = 'https://json-schema.org/draft/2019-09/schema';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
try {
|
|
22
|
+
const validate = this.ajv.compile(schema.content);
|
|
23
|
+
const dataMap = this.registry.dataMappings[title];
|
|
24
|
+
if (!dataMap) {
|
|
25
|
+
console.error(chalk.yellow(`⚠️ No data found for schema titled ${chalk.bold(title)}`));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
dataMap.forEach(data => {
|
|
29
|
+
this.validateJsonSchema(data, title, validate, verbose);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
console.error(chalk.red(`❌ Strict Validation errors for schema ${chalk.bold(title)} in file ${chalk.magenta(schema.path)}:`));
|
|
34
|
+
throw e;
|
|
26
35
|
}
|
|
27
|
-
dataMap.forEach(data => {
|
|
28
|
-
this.validateJsonSchema(data, title, validate, verbose);
|
|
29
|
-
});
|
|
30
36
|
});
|
|
31
37
|
}
|
|
32
38
|
validateJsonSchema(data, title, validate, verbose) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chain-registry/workflows",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.43.0",
|
|
4
4
|
"description": "Chain Registry Workflows",
|
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/cosmology-tech/chain-registry",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@types/sha.js": "^2.4.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@chain-registry/interfaces": "^0.
|
|
34
|
+
"@chain-registry/interfaces": "^0.42.0",
|
|
35
35
|
"ajv": "^8.12.0",
|
|
36
36
|
"ajv-formats": "^3.0.1",
|
|
37
37
|
"bignumber.js": "9.1.2",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"cosmos",
|
|
52
52
|
"interchain"
|
|
53
53
|
],
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "9aff67535f11998b742af7a345b00bd7bdda9332"
|
|
55
55
|
}
|
package/registry.js
CHANGED
|
@@ -106,17 +106,23 @@ class Registry {
|
|
|
106
106
|
ignore: IGNORE_ROOT_DIRS.map(dir => `${this.basePath}/${dir}/**/*`)
|
|
107
107
|
})
|
|
108
108
|
.map(path => {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
109
|
+
try {
|
|
110
|
+
const content = JSON.parse((0, fs_1.readFileSync)(path, 'utf-8'));
|
|
111
|
+
if (!this.isJsonSchema(content))
|
|
112
|
+
return;
|
|
113
|
+
// https://stackoverflow.com/questions/69133771/ajv-no-schema-with-key-or-ref-https-json-schema-org-draft-07-schema
|
|
114
|
+
content.$schema = content.$schema.replace(/https/, 'http');
|
|
115
|
+
types[(0, path_1.basename)(content.$schema)] = true;
|
|
116
|
+
return {
|
|
117
|
+
$schemaFile: (0, path_1.basename)(content.$schema),
|
|
118
|
+
path,
|
|
119
|
+
content
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
// Throw a custom error with a clear message including the file path
|
|
124
|
+
throw new Error(`Failed to parse JSON. The file at "${path}" is not valid JSON.`);
|
|
125
|
+
}
|
|
120
126
|
}).filter(Boolean);
|
|
121
127
|
// filter out schemas (e.g. draft-04/schema )
|
|
122
128
|
const schemas = this.definitions.filter(schema => this.isSchema(schema.content)).filter(Boolean);
|
package/validator.js
CHANGED
|
@@ -24,15 +24,21 @@ class SchemaValidator {
|
|
|
24
24
|
// Compile and validate each schema, then validate corresponding data
|
|
25
25
|
this.registry.forEachSchemas(([title, schema]) => {
|
|
26
26
|
schema.content.$schema = 'https://json-schema.org/draft/2019-09/schema';
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
try {
|
|
28
|
+
const validate = this.ajv.compile(schema.content);
|
|
29
|
+
const dataMap = this.registry.dataMappings[title];
|
|
30
|
+
if (!dataMap) {
|
|
31
|
+
console.error(chalk_1.default.yellow(`⚠️ No data found for schema titled ${chalk_1.default.bold(title)}`));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
dataMap.forEach(data => {
|
|
35
|
+
this.validateJsonSchema(data, title, validate, verbose);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
console.error(chalk_1.default.red(`❌ Strict Validation errors for schema ${chalk_1.default.bold(title)} in file ${chalk_1.default.magenta(schema.path)}:`));
|
|
40
|
+
throw e;
|
|
32
41
|
}
|
|
33
|
-
dataMap.forEach(data => {
|
|
34
|
-
this.validateJsonSchema(data, title, validate, verbose);
|
|
35
|
-
});
|
|
36
42
|
});
|
|
37
43
|
}
|
|
38
44
|
validateJsonSchema(data, title, validate, verbose) {
|