@chain-registry/workflows 1.33.2 → 1.35.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/build.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { JSONStringifyOptions } from 'strfy-js';
2
+ import { JSONSchemaContent, Registry } from './registry';
3
+ import { JSONSchemaPatchOperation } from 'json-schema-patch';
4
+ export interface RegistryBuilderOptions {
5
+ assetList: JSONStringifyOptions;
6
+ chain: JSONStringifyOptions;
7
+ ibcData: JSONStringifyOptions;
8
+ ops: {
9
+ assetList: JSONSchemaPatchOperation[];
10
+ chain: JSONSchemaPatchOperation[];
11
+ ibcData: JSONSchemaPatchOperation[];
12
+ };
13
+ }
14
+ export declare class RegistryBuilder {
15
+ options: RegistryBuilderOptions;
16
+ private registry;
17
+ constructor(registry: Registry, options?: RegistryBuilderOptions);
18
+ writeFile(outDir: string, info: JSONSchemaContent<any>, options: JSONStringifyOptions): void;
19
+ writeSchema(outDir: string, info: JSONSchemaContent<any>, ops: JSONSchemaPatchOperation[]): void;
20
+ buildSchemas(outDir: string): void;
21
+ build(outDir: string): void;
22
+ }
package/build.js ADDED
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RegistryBuilder = void 0;
4
+ const fs_1 = require("fs");
5
+ const mkdirp_1 = require("mkdirp");
6
+ const path_1 = require("path");
7
+ const strfy_js_1 = require("strfy-js");
8
+ const json_schema_patch_1 = require("json-schema-patch");
9
+ class RegistryBuilder {
10
+ options;
11
+ registry;
12
+ constructor(registry, options) {
13
+ this.registry = registry;
14
+ this.options = options;
15
+ }
16
+ writeFile(outDir, info, options) {
17
+ const str = (0, strfy_js_1.jsonStringify)(info.content, options);
18
+ const file = (0, path_1.join)(outDir, info.path.replace(this.registry.basePath, ''));
19
+ (0, mkdirp_1.sync)((0, path_1.dirname)(file));
20
+ (0, fs_1.writeFileSync)(file, str);
21
+ }
22
+ writeSchema(outDir, info, ops) {
23
+ const patcher = new json_schema_patch_1.JSONSchemaPatch(info.content);
24
+ ops.forEach(patcher.prepareOperation.bind(patcher));
25
+ patcher.applyPatch();
26
+ const file = (0, path_1.join)(outDir, info.path.replace(this.registry.basePath, ''));
27
+ (0, mkdirp_1.sync)((0, path_1.dirname)(file));
28
+ (0, fs_1.writeFileSync)(file, JSON.stringify(patcher.schema, null, 2));
29
+ }
30
+ buildSchemas(outDir) {
31
+ this.writeSchema(outDir, this.registry.schemaMappings.AssetList, this.options.ops.assetList);
32
+ this.writeSchema(outDir, this.registry.schemaMappings.Chain, this.options.ops.chain);
33
+ this.writeSchema(outDir, this.registry.schemaMappings.IBCData, this.options.ops.ibcData);
34
+ }
35
+ build(outDir) {
36
+ this.registry.dataMappings.AssetList.forEach(info => {
37
+ this.writeFile(outDir, info, this.options.assetList);
38
+ });
39
+ this.registry.dataMappings.Chain.forEach(info => {
40
+ this.writeFile(outDir, info, this.options.chain);
41
+ });
42
+ this.registry.dataMappings.IBCData.forEach(info => {
43
+ this.writeFile(outDir, info, this.options.ibcData);
44
+ });
45
+ }
46
+ }
47
+ exports.RegistryBuilder = RegistryBuilder;
package/esm/build.js ADDED
@@ -0,0 +1,43 @@
1
+ import { writeFileSync } from 'fs';
2
+ import { sync as mkdirp } from 'mkdirp';
3
+ import { dirname, join } from 'path';
4
+ import { jsonStringify } from 'strfy-js';
5
+ import { JSONSchemaPatch } from 'json-schema-patch';
6
+ export class RegistryBuilder {
7
+ options;
8
+ registry;
9
+ constructor(registry, options) {
10
+ this.registry = registry;
11
+ this.options = options;
12
+ }
13
+ writeFile(outDir, info, options) {
14
+ const str = jsonStringify(info.content, options);
15
+ const file = join(outDir, info.path.replace(this.registry.basePath, ''));
16
+ mkdirp(dirname(file));
17
+ writeFileSync(file, str);
18
+ }
19
+ writeSchema(outDir, info, ops) {
20
+ const patcher = new JSONSchemaPatch(info.content);
21
+ ops.forEach(patcher.prepareOperation.bind(patcher));
22
+ patcher.applyPatch();
23
+ const file = join(outDir, info.path.replace(this.registry.basePath, ''));
24
+ mkdirp(dirname(file));
25
+ writeFileSync(file, JSON.stringify(patcher.schema, null, 2));
26
+ }
27
+ buildSchemas(outDir) {
28
+ this.writeSchema(outDir, this.registry.schemaMappings.AssetList, this.options.ops.assetList);
29
+ this.writeSchema(outDir, this.registry.schemaMappings.Chain, this.options.ops.chain);
30
+ this.writeSchema(outDir, this.registry.schemaMappings.IBCData, this.options.ops.ibcData);
31
+ }
32
+ build(outDir) {
33
+ this.registry.dataMappings.AssetList.forEach(info => {
34
+ this.writeFile(outDir, info, this.options.assetList);
35
+ });
36
+ this.registry.dataMappings.Chain.forEach(info => {
37
+ this.writeFile(outDir, info, this.options.chain);
38
+ });
39
+ this.registry.dataMappings.IBCData.forEach(info => {
40
+ this.writeFile(outDir, info, this.options.ibcData);
41
+ });
42
+ }
43
+ }
package/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './build';
1
2
  export * from './registry';
2
3
  export * from './schema-typescript';
3
4
  export * from './validator';
@@ -35,6 +35,11 @@ export class SchemaTypeGenerator {
35
35
  }
36
36
  generateTypes() {
37
37
  this.registry.schemas.forEach(fileInfo => {
38
+ // WTF! TOOD
39
+ if (!fileInfo) {
40
+ console.warn('Warning: generateTypes() registry has empty value for schema');
41
+ return;
42
+ }
38
43
  const schemaFile = fileInfo.path;
39
44
  if (this.isSchemaSupported(schemaFile)) {
40
45
  try {
package/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './build';
1
2
  export * from './registry';
2
3
  export * from './schema-typescript';
3
4
  export * from './validator';
package/index.js CHANGED
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./build"), exports);
17
18
  __exportStar(require("./registry"), exports);
18
19
  __exportStar(require("./schema-typescript"), exports);
19
20
  __exportStar(require("./validator"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chain-registry/workflows",
3
- "version": "1.33.2",
3
+ "version": "1.35.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,13 +31,14 @@
31
31
  "@types/sha.js": "^2.4.0"
32
32
  },
33
33
  "dependencies": {
34
- "@chain-registry/interfaces": "^0.32.2",
34
+ "@chain-registry/interfaces": "^0.34.0",
35
35
  "ajv": "^8.12.0",
36
36
  "ajv-formats": "^3.0.1",
37
- "bignumber.js": "9.1.1",
37
+ "bignumber.js": "9.1.2",
38
38
  "chalk": "^4.1.0",
39
39
  "file-ts": "^0.7.15",
40
40
  "glob": "^7.1.4",
41
+ "json-schema-patch": "0.5.0",
41
42
  "minimatch": "^9.0.4",
42
43
  "mkdirp": "3.0.1",
43
44
  "schema-typescript": "^0.5.0",
@@ -49,5 +50,5 @@
49
50
  "cosmos",
50
51
  "interchain"
51
52
  ],
52
- "gitHead": "524048e52fe52d7d4da30d3a221772d643cee836"
53
+ "gitHead": "9617e82b460cb30e74e30300b28e979297641b4f"
53
54
  }
@@ -61,6 +61,11 @@ class SchemaTypeGenerator {
61
61
  }
62
62
  generateTypes() {
63
63
  this.registry.schemas.forEach(fileInfo => {
64
+ // WTF! TOOD
65
+ if (!fileInfo) {
66
+ console.warn('Warning: generateTypes() registry has empty value for schema');
67
+ return;
68
+ }
64
69
  const schemaFile = fileInfo.path;
65
70
  if (this.isSchemaSupported(schemaFile)) {
66
71
  try {