@graphprotocol/graph-cli 0.64.0-alpha-20231213180901-055b47e → 0.64.0-alpha-20231213212340-cbd5345
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/CHANGELOG.md +20 -1
- package/dist/commands/build.js +1 -1
- package/dist/compiler/index.d.ts +0 -1
- package/dist/compiler/index.js +1 -43
- package/dist/subgraph.d.ts +1 -1
- package/dist/subgraph.js +3 -3
- package/dist/validation/schema.d.ts +1 -1
- package/dist/validation/schema.js +6 -34
- package/oclif.manifest.json +1 -1
- package/package.json +1 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @graphprotocol/graph-cli
|
|
2
2
|
|
|
3
|
-
## 0.64.0-alpha-
|
|
3
|
+
## 0.64.0-alpha-20231213212340-cbd5345
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -9,6 +9,25 @@
|
|
|
9
9
|
Thanks [@saihaj](https://github.com/saihaj)! - adding deprecation notices for commands we plan to
|
|
10
10
|
change in the next major. See https://github.com/graphprotocol/graph-tooling/issues/1487
|
|
11
11
|
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#1545](https://github.com/graphprotocol/graph-tooling/pull/1545)
|
|
15
|
+
[`b96a236`](https://github.com/graphprotocol/graph-tooling/commit/b96a2362bfeb32317d233f5949dcc29c433578c3)
|
|
16
|
+
Thanks [@saihaj](https://github.com/saihaj)! - dependencies updates:
|
|
17
|
+
|
|
18
|
+
- Removed dependency
|
|
19
|
+
[`@babel/core@^7.20.5` ↗︎](https://www.npmjs.com/package/@babel/core/v/7.20.5) (from
|
|
20
|
+
`dependencies`)
|
|
21
|
+
- Removed dependency
|
|
22
|
+
[`@babel/preset-typescript@^7.18.6` ↗︎](https://www.npmjs.com/package/@babel/preset-typescript/v/7.18.6)
|
|
23
|
+
(from `dependencies`)
|
|
24
|
+
- Removed dependency [`memoizee@^0.4.15` ↗︎](https://www.npmjs.com/package/memoizee/v/0.4.15)
|
|
25
|
+
(from `dependencies`)
|
|
26
|
+
|
|
27
|
+
- [#1545](https://github.com/graphprotocol/graph-tooling/pull/1545)
|
|
28
|
+
[`ae721d3`](https://github.com/graphprotocol/graph-tooling/commit/ae721d3fea9c5824283607777ccd59e96e4f36c7)
|
|
29
|
+
Thanks [@saihaj](https://github.com/saihaj)! - fix call handler validation
|
|
30
|
+
|
|
12
31
|
## 0.63.1
|
|
13
32
|
|
|
14
33
|
### Patch Changes
|
package/dist/commands/build.js
CHANGED
|
@@ -71,7 +71,7 @@ class BuildCommand extends core_1.Command {
|
|
|
71
71
|
await compiler.watchAndCompile();
|
|
72
72
|
}
|
|
73
73
|
else {
|
|
74
|
-
const result = await compiler.compile({ validate:
|
|
74
|
+
const result = await compiler.compile({ validate: true });
|
|
75
75
|
if (result === false) {
|
|
76
76
|
this.exit(1);
|
|
77
77
|
}
|
package/dist/compiler/index.d.ts
CHANGED
|
@@ -59,7 +59,6 @@ export default class Compiler {
|
|
|
59
59
|
_compileDataSourceMapping(protocol: Protocol, dataSource: immutable.Map<any, any>, mappingPath: string, compiledFiles: Map<any, any>, spinner: Spinner, validate?: boolean): any;
|
|
60
60
|
_compileTemplateMapping(template: immutable.Collection<any, any>, mappingPath: string, compiledFiles: Map<any, any>, spinner: Spinner): any;
|
|
61
61
|
_validateMappingContent(filePath: string): void;
|
|
62
|
-
_validateHandler(filePath: string, handlerName: string): void;
|
|
63
62
|
writeSubgraphToOutputDirectory(protocol: Protocol, subgraph: immutable.Map<any, any>): Promise<any>;
|
|
64
63
|
uploadSubgraphToIPFS(subgraph: immutable.Map<any, any>): Promise<any>;
|
|
65
64
|
_uploadFileToIPFS(maybeRelativeFile: string, uploadedFiles: Map<any, any>, spinner: Spinner): Promise<immutable.Collection<unknown, unknown>>;
|
package/dist/compiler/index.js
CHANGED
|
@@ -33,8 +33,6 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
|
33
33
|
const toolbox = __importStar(require("gluegun"));
|
|
34
34
|
const immutable_1 = __importDefault(require("immutable"));
|
|
35
35
|
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
36
|
-
const memoizee_1 = __importDefault(require("memoizee"));
|
|
37
|
-
const core_1 = require("@babel/core");
|
|
38
36
|
const spinner_1 = require("../command-helpers/spinner");
|
|
39
37
|
const debug_1 = __importDefault(require("../debug"));
|
|
40
38
|
const migrations_1 = require("../migrations");
|
|
@@ -42,16 +40,6 @@ const subgraph_1 = __importDefault(require("../subgraph"));
|
|
|
42
40
|
const watcher_1 = __importDefault(require("../watcher"));
|
|
43
41
|
const asc = __importStar(require("./asc"));
|
|
44
42
|
const compilerDebug = (0, debug_1.default)('graph-cli:compiler');
|
|
45
|
-
/** memoize the reading of the file so we don't have to read it every time */
|
|
46
|
-
const readFile = (0, memoizee_1.default)((filename) => fs_extra_1.default.readFileSync(filename, 'utf-8'));
|
|
47
|
-
/** Memoized parser for Babel, so we can simply just read from cache */
|
|
48
|
-
const babelAst = (0, memoizee_1.default)((filename) => {
|
|
49
|
-
const data = readFile(filename);
|
|
50
|
-
return (0, core_1.parseSync)(data, {
|
|
51
|
-
presets: ['@babel/preset-typescript'],
|
|
52
|
-
filename,
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
43
|
class Compiler {
|
|
56
44
|
constructor(options) {
|
|
57
45
|
this.options = options;
|
|
@@ -266,12 +254,6 @@ class Compiler {
|
|
|
266
254
|
const absoluteMappingPath = path_1.default.resolve(baseDir, mappingPath);
|
|
267
255
|
const inputFile = path_1.default.relative(baseDir, absoluteMappingPath);
|
|
268
256
|
this._validateMappingContent(absoluteMappingPath);
|
|
269
|
-
const eventHandlers = dataSource.getIn(['mapping', 'eventHandlers']);
|
|
270
|
-
// TODO: improve the types
|
|
271
|
-
for (const eventHandler of eventHandlers.toJS()) {
|
|
272
|
-
compilerDebug('Validating Event Handler %s', eventHandler.handler);
|
|
273
|
-
this._validateHandler(absoluteMappingPath, eventHandler.handler);
|
|
274
|
-
}
|
|
275
257
|
// If the file has already been compiled elsewhere, just use that output
|
|
276
258
|
// file and return early
|
|
277
259
|
const inputCacheKey = this.cacheKeyForFile(absoluteMappingPath);
|
|
@@ -322,12 +304,6 @@ class Compiler {
|
|
|
322
304
|
const absoluteMappingPath = path_1.default.resolve(baseDir, mappingPath);
|
|
323
305
|
const inputFile = path_1.default.relative(baseDir, absoluteMappingPath);
|
|
324
306
|
this._validateMappingContent(absoluteMappingPath);
|
|
325
|
-
const eventHandlers = template.getIn(['mapping', 'eventHandlers']);
|
|
326
|
-
// TODO: improve the types
|
|
327
|
-
for (const eventHandler of eventHandlers.toJS()) {
|
|
328
|
-
compilerDebug('Validating Template handler %s', eventHandler.handler);
|
|
329
|
-
this._validateHandler(absoluteMappingPath, eventHandler.handler);
|
|
330
|
-
}
|
|
331
307
|
// If the file has already been compiled elsewhere, just use that output
|
|
332
308
|
// file and return early
|
|
333
309
|
const inputCacheKey = this.cacheKeyForFile(absoluteMappingPath);
|
|
@@ -363,7 +339,7 @@ class Compiler {
|
|
|
363
339
|
}
|
|
364
340
|
}
|
|
365
341
|
_validateMappingContent(filePath) {
|
|
366
|
-
const data =
|
|
342
|
+
const data = fs_extra_1.default.readFileSync(filePath);
|
|
367
343
|
if (this.blockIpfsMethods && (data.includes('ipfs.cat') || data.includes('ipfs.map'))) {
|
|
368
344
|
throw Error(`
|
|
369
345
|
Subgraph Studio does not support mappings with ipfs methods.
|
|
@@ -372,24 +348,6 @@ class Compiler {
|
|
|
372
348
|
`);
|
|
373
349
|
}
|
|
374
350
|
}
|
|
375
|
-
_validateHandler(filePath, handlerName) {
|
|
376
|
-
const baselAst = babelAst(filePath);
|
|
377
|
-
const body = baselAst?.program.body;
|
|
378
|
-
if (!body) {
|
|
379
|
-
throw Error(`Could not parse ${filePath}`);
|
|
380
|
-
}
|
|
381
|
-
const exportedFunctionNames = body
|
|
382
|
-
.map(statement => {
|
|
383
|
-
if (statement.type === 'ExportNamedDeclaration' &&
|
|
384
|
-
statement?.declaration?.type === 'FunctionDeclaration') {
|
|
385
|
-
return statement.declaration.id?.name;
|
|
386
|
-
}
|
|
387
|
-
})
|
|
388
|
-
.filter(Boolean);
|
|
389
|
-
if (!exportedFunctionNames.includes(handlerName)) {
|
|
390
|
-
throw Error(`Could not find handler '${handlerName}' in ${filePath}`);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
351
|
async writeSubgraphToOutputDirectory(protocol, subgraph) {
|
|
394
352
|
const displayDir = `${this.displayPath(this.options.outputDir)}${toolbox.filesystem.separator}`;
|
|
395
353
|
// ensure that the output directory exists
|
package/dist/subgraph.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export default class Subgraph {
|
|
|
7
7
|
}): Promise<any>;
|
|
8
8
|
static validateSchema(manifest: any, { resolveFile }: {
|
|
9
9
|
resolveFile: ResolveFile;
|
|
10
|
-
}):
|
|
10
|
+
}): void;
|
|
11
11
|
static validateRepository(manifest: immutable.Collection<any, any>): immutable.List<unknown>;
|
|
12
12
|
static validateDescription(manifest: immutable.Collection<any, any>): immutable.List<unknown>;
|
|
13
13
|
static validateHandlers(manifest: immutable.Collection<any, any>, protocol: any, protocolSubgraph: ISubgraph): any;
|
package/dist/subgraph.js
CHANGED
|
@@ -73,11 +73,11 @@ class Subgraph {
|
|
|
73
73
|
resolveFile,
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
-
static
|
|
76
|
+
static validateSchema(manifest, { resolveFile }) {
|
|
77
77
|
subgraphDebug.extend('validate')('Validating schema in manifest');
|
|
78
78
|
const filename = resolveFile(manifest.getIn(['schema', 'file']));
|
|
79
79
|
subgraphDebug.extend('validate')('Loaded schema from %s', filename);
|
|
80
|
-
const validationErrors =
|
|
80
|
+
const validationErrors = validation.validateSchema(filename);
|
|
81
81
|
let errors;
|
|
82
82
|
if (validationErrors.size > 0) {
|
|
83
83
|
subgraphDebug.extend('validate')('Schema validation failed for %s', filename);
|
|
@@ -243,7 +243,7 @@ More than one template named '${name}', template names must be unique.`,
|
|
|
243
243
|
subgraphDebug.extend('manifest')('Loaded: %M', manifest);
|
|
244
244
|
// Validate the schema
|
|
245
245
|
subgraphDebug.extend('manifest')('Validating schema');
|
|
246
|
-
|
|
246
|
+
Subgraph.validateSchema(manifest, { resolveFile });
|
|
247
247
|
// Perform other validations
|
|
248
248
|
const protocolSubgraph = protocol.getSubgraph({
|
|
249
249
|
manifest,
|
|
@@ -4,4 +4,4 @@ import immutable from 'immutable';
|
|
|
4
4
|
* Returns `undefined` if no suggestion is available for the type.
|
|
5
5
|
*/
|
|
6
6
|
export declare const typeSuggestion: (typeName: string) => string | RegExp;
|
|
7
|
-
export declare const validateSchema: (filename: string) =>
|
|
7
|
+
export declare const validateSchema: (filename: string) => immutable.List<any>;
|
|
@@ -27,15 +27,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.validateSchema = exports.typeSuggestion = void 0;
|
|
30
|
-
const
|
|
30
|
+
const fs_1 = __importDefault(require("fs"));
|
|
31
31
|
const graphql = __importStar(require("graphql/language"));
|
|
32
32
|
const immutable_1 = __importDefault(require("immutable"));
|
|
33
|
-
const graphql_file_loader_1 = require("@graphql-tools/graphql-file-loader");
|
|
34
|
-
const load_1 = require("@graphql-tools/load");
|
|
35
|
-
const schema_1 = require("@graphql-tools/schema");
|
|
36
|
-
const url_loader_1 = require("@graphql-tools/url-loader");
|
|
37
33
|
const debug_1 = __importDefault(require("../debug"));
|
|
38
|
-
const fetch_1 = __importDefault(require("../fetch"));
|
|
39
34
|
const validateDebugger = (0, debug_1.default)('graph-cli:validation');
|
|
40
35
|
const List = immutable_1.default.List;
|
|
41
36
|
const Set = immutable_1.default.Set;
|
|
@@ -94,7 +89,7 @@ const typeSuggestion = (typeName) => TYPE_SUGGESTIONS.filter(([pattern, _]) => {
|
|
|
94
89
|
exports.typeSuggestion = typeSuggestion;
|
|
95
90
|
const loadSchema = (filename) => {
|
|
96
91
|
try {
|
|
97
|
-
return
|
|
92
|
+
return fs_1.default.readFileSync(filename, 'utf-8');
|
|
98
93
|
}
|
|
99
94
|
catch (e) {
|
|
100
95
|
throw new Error(`Failed to load GraphQL schema: ${e}`);
|
|
@@ -859,34 +854,11 @@ const validateNamingCollisions = (local, imported) => {
|
|
|
859
854
|
validateDebugger('Validating naming collisions');
|
|
860
855
|
return validateNamingCollisionsInTypes(local.concat(imported));
|
|
861
856
|
};
|
|
862
|
-
|
|
863
|
-
// const META_SCHEMA_GRAPH_NODE= "https://raw.githubusercontent.com/graphprotocol/graph-node/master/graph/src/schema/meta.graphql"
|
|
864
|
-
const META_SCHEMA_GRAPH_NODE = 'https://raw.githubusercontent.com/graphprotocol/graph-node/saihaj/fix-meta-schema/graph/src/schema/meta.graphql';
|
|
865
|
-
const validateSchema = async (filename) => {
|
|
857
|
+
const validateSchema = (filename) => {
|
|
866
858
|
validateDebugger('Validating schema: %s', filename);
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
loaders: [new graphql_file_loader_1.GraphQLFileLoader()],
|
|
871
|
-
assumeValid: true,
|
|
872
|
-
assumeValidSDL: true,
|
|
873
|
-
}),
|
|
874
|
-
(0, load_1.loadSchema)(META_SCHEMA_GRAPH_NODE, {
|
|
875
|
-
loaders: [new url_loader_1.UrlLoader()],
|
|
876
|
-
fetch: fetch_1.default,
|
|
877
|
-
}),
|
|
878
|
-
]);
|
|
879
|
-
console.log('doc', doc);
|
|
880
|
-
validateDebugger('Loaded schema: %s', filename);
|
|
881
|
-
const b = (0, schema_1.mergeSchemas)({
|
|
882
|
-
schemas: [metaSchema],
|
|
883
|
-
});
|
|
884
|
-
console.log(b);
|
|
885
|
-
}
|
|
886
|
-
catch (e) {
|
|
887
|
-
console.trace('Error', e);
|
|
888
|
-
}
|
|
889
|
-
const schema = parseSchema(loadSchema(filename));
|
|
859
|
+
const doc = loadSchema(filename);
|
|
860
|
+
validateDebugger('Loaded schema: %s', filename);
|
|
861
|
+
const schema = parseSchema(doc);
|
|
890
862
|
validateDebugger.extend('schema')('Parsed schema: %M', schema);
|
|
891
863
|
return List.of(...validateTypeDefinitions(schema.definitions), ...validateNamingCollisions(gatherLocalTypes(schema.definitions), gatherImportedTypes(schema.definitions)));
|
|
892
864
|
};
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphprotocol/graph-cli",
|
|
3
|
-
"version": "0.64.0-alpha-
|
|
3
|
+
"version": "0.64.0-alpha-20231213212340-cbd5345",
|
|
4
4
|
"description": "CLI for building for and deploying to The Graph",
|
|
5
5
|
"license": "(Apache-2.0 OR MIT)",
|
|
6
6
|
"engines": {
|
|
@@ -19,13 +19,7 @@
|
|
|
19
19
|
"!dist/*.tar.gz"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@babel/core": "^7.20.5",
|
|
23
|
-
"@babel/preset-typescript": "^7.18.6",
|
|
24
22
|
"@float-capital/float-subgraph-uncrashable": "^0.0.0-alpha.4",
|
|
25
|
-
"@graphql-tools/graphql-file-loader": "^8.0.0",
|
|
26
|
-
"@graphql-tools/load": "^8.0.1",
|
|
27
|
-
"@graphql-tools/schema": "^10.0.2",
|
|
28
|
-
"@graphql-tools/url-loader": "^8.0.1",
|
|
29
23
|
"@oclif/core": "2.8.6",
|
|
30
24
|
"@oclif/plugin-autocomplete": "^2.3.6",
|
|
31
25
|
"@oclif/plugin-not-found": "^2.4.0",
|
|
@@ -45,7 +39,6 @@
|
|
|
45
39
|
"ipfs-http-client": "55.0.0",
|
|
46
40
|
"jayson": "4.0.0",
|
|
47
41
|
"js-yaml": "3.14.1",
|
|
48
|
-
"memoizee": "^0.4.15",
|
|
49
42
|
"prettier": "1.19.1",
|
|
50
43
|
"request": "2.88.2",
|
|
51
44
|
"semver": "7.4.0",
|
|
@@ -56,12 +49,10 @@
|
|
|
56
49
|
"yaml": "1.10.2"
|
|
57
50
|
},
|
|
58
51
|
"devDependencies": {
|
|
59
|
-
"@types/babel__core": "^7.20.5",
|
|
60
52
|
"@types/debug": "^4.1.7",
|
|
61
53
|
"@types/fs-extra": "^9.0.13",
|
|
62
54
|
"@types/jest": "^29.0.0",
|
|
63
55
|
"@types/js-yaml": "^3.12.7",
|
|
64
|
-
"@types/memoizee": "^0.4.11",
|
|
65
56
|
"@types/semver": "^7.3.13",
|
|
66
57
|
"@types/which": "^2.0.1",
|
|
67
58
|
"copyfiles": "^2.4.1",
|