How to use the @dataform/core.indexFileGenerator 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 / api / vm / query.ts View on Github external
let compiledQuery = query;
  if (projectDir) {
    const vm = new NodeVM({
      wrapper: "none",
      require: {
        context: "sandbox",
        root: projectDir,
        external: true
      },
      sourceExtensions: ["js", "sql"],
      compiler: (code, path) => compiler(code, path)
    });
    // This use of genIndex needs some rethinking. It uses the version built into
    // @dataform/api instead of @dataform/core, which would be more correct, as done in compile.ts.
    // Possibly query compilation as a whole needs a redesign.
    const indexScript = indexFileGenerator(
      createGenIndexConfig(
        { projectDir },
        `(function() {
        require("@dataform/core");
        const ref = global.session.resolve.bind(session);
        const resolve = global.session.resolve.bind(session);
        const noop = () => "";
        const config = noop;
        const type = noop;
        const postOps = noop;
        const preOps = noop;
        const self = noop;
        const dependencies = noop;
        const where = noop;
        const descriptor = noop;
        const describe = field => field;