How to use the @dataform/core/utils.ambiguousActionNameMsg function in @dataform/core

To help you get started, we’ve selected a few @dataform/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dataform-co / dataform / core / session.ts View on Github external
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);
    });
  }
github dataform-co / dataform / core / session.ts View on Github external
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) {
github dataform-co / dataform / core / session.ts View on Github external
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) {
github dataform-co / dataform / core / session.ts View on Github external
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;
      });
    });