@graphprotocol/graph-cli
Version:
CLI for building for and deploying to The Graph
71 lines (70 loc) • 3.05 kB
TypeScript
import immutable from 'immutable';
import { Spinner } from '../command-helpers/spinner.js';
import Protocol from '../protocols/index.js';
interface CompilerOptions {
ipfs: any;
subgraphManifest: string;
outputDir: string;
outputFormat: string;
skipMigrations: boolean;
blockIpfsMethods?: RegExpMatchArray;
protocol: Protocol;
}
export default class Compiler {
private options;
private ipfs;
private sourceDir;
private blockIpfsMethods?;
private libsDirs;
/**
* Path to the global.ts file in the graph-ts package.
*
* @note if you are using substreams as a protocol, this will be undefined.
*/
private globalsFile?;
private protocol;
private ABI;
constructor(options: CompilerOptions);
subgraphDir(parent: string, subgraph: immutable.Map<any, any>): string;
displayPath(p: string): string;
cacheKeyForFile(filename: string): string;
compile({ validate, }: {
/**
* Whether to validate the compiled artifacts.
*/
validate: boolean;
}): Promise<any>;
completed(ipfsHashOrPath: string): void;
loadSubgraph({ quiet }?: {
quiet: boolean;
}): Promise<any>;
getFilesToWatch(): Promise<string[]>;
watchAndCompile(onCompiled?: (ipfsHash: string) => void): Promise<void>;
_writeSubgraphFile(maybeRelativeFile: string, data: string | Buffer, sourceDir: string, targetDir: string, spinner: Spinner): string;
compileSubgraph(subgraph: any, validate?: boolean): Promise<any>;
/**
* Validate that the compiled WASM has all the handlers that are defined in the subgraph manifest
*
* @returns a list of handlers that are missing from the compiled WASM
*
* This is a temporary solution to validate that the compiled WASM has all the event handlers.
* A better way would be if we can do this even before compiling
* but requires a larger refactor so we are running additional validations before compilation
*/
_validateHandlersInWasm({ pathToWasm, dataSource, }: {
pathToWasm: string;
dataSource: immutable.Map<any, any>;
}): any[];
_compileDataSourceMapping(protocol: Protocol, dataSource: immutable.Map<any, any>, mappingPath: string, compiledFiles: Map<any, any>, spinner: Spinner, validate?: boolean): any;
_compileTemplateMapping(template: immutable.Collection<any, any>, mappingPath: string, compiledFiles: Map<any, any>, spinner: Spinner): any;
_validateMappingContent(filePath: string): void;
writeSubgraphToOutputDirectory(protocol: Protocol, subgraph: immutable.Map<any, any>): Promise<any>;
uploadSubgraphToIPFS(subgraph: immutable.Map<any, any>): Promise<any>;
_uploadFileToIPFS(maybeRelativeFile: string, uploadedFiles: Map<any, any>, spinner: Spinner): Promise<immutable.Map<"/", string>>;
_uploadSubgraphDefinitionToIPFS(subgraph: immutable.Map<any, any>): Promise<string>;
_uploadToIPFS(file: {
path: string;
content: Buffer;
}): Promise<string>;
}
export {};