Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
action.fileName
);
} else if (possibleDeps.length === 1) {
// We found a single matching target, and fully-qualify it if it's a normal dependency,
// or add all of its dependencies to ours if it's an 'inline' table.
const protoDep = possibleDeps[0].proto;
if (protoDep instanceof dataform.Table && protoDep.type === "inline") {
protoDep.dependencyTargets.forEach(inlineDep =>
action.dependencyTargets.push(inlineDep)
);
} else {
fullyQualifiedDependencies[protoDep.name] = protoDep.target;
}
} else {
// Too many targets matched the dependency.
this.compileError(new Error(utils.ambiguousActionNameMsg(dependency, possibleDeps)));
}
}
action.dependencies = Object.keys(fullyQualifiedDependencies);
action.dependencyTargets = Object.values(fullyQualifiedDependencies);
});
}
public resolve(ref: Resolvable): string {
const allResolved = this.findActions(ref);
if (allResolved.length > 1) {
this.compileError(new Error(utils.ambiguousActionNameMsg(ref, allResolved)));
}
const resolved = allResolved.length > 0 ? allResolved[0] : undefined;
if (resolved && resolved instanceof table.Table && resolved.proto.type === "inline") {
// TODO: Pretty sure this is broken as the proto.query value may not
// be set yet as it happens during compilation. We should evalute the query here.
return `(${resolved.proto.query})`;
}
if (resolved && resolved instanceof Operation && !resolved.proto.hasOutput) {
this.compileError(
new Error("Actions cannot resolve operations which do not produce output.")
);
}
if (resolved) {
if (resolved instanceof Declaration) {
public resolve(ref: Resolvable): string {
const allResolved = this.findActions(utils.resolvableAsTarget(ref));
if (allResolved.length > 1) {
this.compileError(new Error(utils.ambiguousActionNameMsg(ref, allResolved)));
}
const resolved = allResolved.length > 0 ? allResolved[0] : undefined;
if (resolved && resolved instanceof table.Table && resolved.proto.type === "inline") {
// TODO: Pretty sure this is broken as the proto.query value may not
// be set yet as it happens during compilation. We should evalute the query here.
return `(${resolved.proto.query})`;
}
if (resolved && resolved instanceof Operation && !resolved.proto.hasOutput) {
this.compileError(
new Error("Actions cannot resolve operations which do not produce output.")
);
}
if (resolved) {
if (resolved instanceof Declaration) {
action.dependencies = (action.dependencies || []).map(dependencyName => {
if (!!allActionsByName[dependencyName]) {
// Dependency is already fully-qualified.
return dependencyName;
}
const possibleDeps = this.findActions(dependencyName);
if (possibleDeps.length === 1) {
return possibleDeps[0].proto.name;
}
if (possibleDeps.length >= 1) {
this.compileError(new Error(utils.ambiguousActionNameMsg(dependencyName, possibleDeps)));
} else {
this.compileError(
new Error(
`Missing dependency detected: Action "${action.name}" depends on "${dependencyName}" which does not exist.`
),
action.fileName
);
}
return dependencyName;
});
});