Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public test(name: string): test.Test {
const newTest = new test.Test();
newTest.session = this;
newTest.proto.name = name;
newTest.proto.fileName = utils.getCallerFile(this.rootDir);
// Add it to global index.
this.tests[name] = newTest;
return newTest;
}
public test(name: string): test.Test {
const newTest = new test.Test();
newTest.session = this;
newTest.proto.name = name;
newTest.proto.fileName = utils.getCallerFile(this.rootDir);
// Add it to global index.
this.tests[name] = newTest;
return newTest;
}
public declare(dataset: dataform.ITarget): Declaration {
const declaration = new Declaration();
declaration.session = this;
utils.setNameAndTarget(this, declaration.proto, dataset.name, dataset.schema, dataset.database);
declaration.proto.fileName = utils.getCallerFile(this.rootDir);
this.actions.push(declaration);
return declaration;
}
public declare(dataset: FullyQualifiedName): Declaration {
const declaration = new Declaration();
declaration.session = this;
this.setNameAndTarget(declaration.proto, dataset.name, dataset.schema);
declaration.proto.fileName = utils.getCallerFile(this.rootDir);
this.actions.push(declaration);
return declaration;
}
public compileError(err: Error | string, path?: string) {
const fileName = path || utils.getCallerFile(this.rootDir) || __filename;
const compileError = dataform.CompilationError.create({
fileName
});
if (typeof err === "string") {
compileError.message = err;
} else {
compileError.message = err.message;
compileError.stack = err.stack;
}
this.graphErrors.compilationErrors.push(compileError);
}
public compileError(err: Error | string, path?: string) {
const fileName = path || utils.getCallerFile(this.rootDir) || __filename;
const compileError = dataform.CompilationError.create({
fileName
});
if (typeof err === "string") {
compileError.message = err;
} else {
compileError.message = err.message;
compileError.stack = err.stack;
}
this.graphErrors.compilationErrors.push(compileError);
}
public publish(
name: string,
queryOrConfig?: table.TContextable | table.TConfig
): table.Table {
const newTable = new table.Table();
newTable.session = this;
utils.setNameAndTarget(this, newTable.proto, name);
if (!!queryOrConfig) {
if (typeof queryOrConfig === "object") {
newTable.config(queryOrConfig);
} else {
newTable.query(queryOrConfig);
}
}
newTable.proto.fileName = utils.getCallerFile(this.rootDir);
this.actions.push(newTable);
return newTable;
}
public assert(name: string, query?: AContextable): Assertion {
const assertion = new Assertion();
assertion.session = this;
utils.setNameAndTarget(this, assertion.proto, name, this.config.assertionSchema);
if (query) {
assertion.query(query);
}
assertion.proto.fileName = utils.getCallerFile(this.rootDir);
this.actions.push(assertion);
return assertion;
}
public assert(name: string, query?: AContextable): Assertion {
const assertion = new Assertion();
assertion.session = this;
this.setNameAndTarget(assertion.proto, name, this.config.assertionSchema);
if (query) {
assertion.query(query);
}
assertion.proto.fileName = utils.getCallerFile(this.rootDir);
this.actions.push(assertion);
return assertion;
}