@chain-registry/workflows 1.40.0 → 1.41.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 CHANGED
@@ -133,6 +133,20 @@ export class Registry {
133
133
  this.loadData(schema);
134
134
  });
135
135
  }
136
+ mapSchemas(mapper) {
137
+ return Object.entries(this.schemaMappings).map(([title, schema]) => {
138
+ if (schema)
139
+ return [title, schema];
140
+ }).filter(Boolean)
141
+ .map(mapper);
142
+ }
143
+ forEachSchemas(mapper) {
144
+ return Object.entries(this.schemaMappings).map(([title, schema]) => {
145
+ if (schema)
146
+ return [title, schema];
147
+ }).filter(Boolean)
148
+ .forEach(mapper);
149
+ }
136
150
  get chains() {
137
151
  return this.dataMappings.Chain.map(c => c.content);
138
152
  }
@@ -149,7 +163,7 @@ export class Registry {
149
163
  return this.dataMappings.Versions.map(c => c.content);
150
164
  }
151
165
  get schemas() {
152
- return Object.entries(this.schemaMappings).map(([_str, obj]) => {
166
+ return this.mapSchemas(([_str, obj]) => {
153
167
  return obj;
154
168
  });
155
169
  }
package/esm/validator.js CHANGED
@@ -16,7 +16,7 @@ export class SchemaValidator {
16
16
  }
17
17
  validateAllData(verbose = false) {
18
18
  // Compile and validate each schema, then validate corresponding data
19
- Object.entries(this.registry.schemaMappings).forEach(([title, schema]) => {
19
+ this.registry.forEachSchemas(([title, schema]) => {
20
20
  schema.content.$schema = 'https://json-schema.org/draft/2019-09/schema';
21
21
  const validate = this.ajv.compile(schema.content);
22
22
  const dataMap = this.registry.dataMappings[title];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chain-registry/workflows",
3
- "version": "1.40.0",
3
+ "version": "1.41.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.39.0",
34
+ "@chain-registry/interfaces": "^0.40.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": "4951764c7bd7a6364f5f6d4d267da3c70e986628"
54
+ "gitHead": "dbadb4695ee1308638cd4b37685ecdcb00c7d694"
55
55
  }
package/registry.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { AssetList, Chain, IBCData, MemoKeys, Versions } from '@chain-registry/interfaces';
2
2
  import { JSONSchema } from "schema-typescript";
3
+ export type SchemaMapper = ([title, schema]: [string, JSONSchemaContent<any>]) => any;
3
4
  export interface JSONSchemaContent<T> {
4
5
  $schemaFile: string;
5
6
  path: string;
@@ -33,6 +34,8 @@ export declare class Registry {
33
34
  private loadData;
34
35
  private initStoreForSchema;
35
36
  private initializeData;
37
+ mapSchemas(mapper: SchemaMapper): any;
38
+ forEachSchemas(mapper: SchemaMapper): any;
36
39
  get chains(): Chain[];
37
40
  get assetLists(): AssetList[];
38
41
  get ibcData(): IBCData[];
package/registry.js CHANGED
@@ -136,6 +136,20 @@ class Registry {
136
136
  this.loadData(schema);
137
137
  });
138
138
  }
139
+ mapSchemas(mapper) {
140
+ return Object.entries(this.schemaMappings).map(([title, schema]) => {
141
+ if (schema)
142
+ return [title, schema];
143
+ }).filter(Boolean)
144
+ .map(mapper);
145
+ }
146
+ forEachSchemas(mapper) {
147
+ return Object.entries(this.schemaMappings).map(([title, schema]) => {
148
+ if (schema)
149
+ return [title, schema];
150
+ }).filter(Boolean)
151
+ .forEach(mapper);
152
+ }
139
153
  get chains() {
140
154
  return this.dataMappings.Chain.map(c => c.content);
141
155
  }
@@ -152,7 +166,7 @@ class Registry {
152
166
  return this.dataMappings.Versions.map(c => c.content);
153
167
  }
154
168
  get schemas() {
155
- return Object.entries(this.schemaMappings).map(([_str, obj]) => {
169
+ return this.mapSchemas(([_str, obj]) => {
156
170
  return obj;
157
171
  });
158
172
  }
package/validator.js CHANGED
@@ -22,7 +22,7 @@ class SchemaValidator {
22
22
  }
23
23
  validateAllData(verbose = false) {
24
24
  // Compile and validate each schema, then validate corresponding data
25
- Object.entries(this.registry.schemaMappings).forEach(([title, schema]) => {
25
+ this.registry.forEachSchemas(([title, schema]) => {
26
26
  schema.content.$schema = 'https://json-schema.org/draft/2019-09/schema';
27
27
  const validate = this.ajv.compile(schema.content);
28
28
  const dataMap = this.registry.dataMappings[title];