How to use the protobufjs.util.base64 function in protobufjs

To help you get started, we’ve selected a few protobufjs 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 / gen_index_config.ts View on Github external
}
  });
  // Support projects that don't use the new project structure.
  glob.sync("models/**/*.{js,sql,sqlx}", { cwd: compileConfig.projectDir }).forEach(path => {
    if (definitionPaths.indexOf(path) < 0) {
      definitionPaths.push(path);
    }
  });
  const encodedConfigBytes = dataform.GenerateIndexConfig.encode({
    compileConfig,
    includePaths,
    definitionPaths,
    // For backwards compatibility with old versions of @dataform/core.
    returnOverride: compileConfig.returnOverride
  }).finish();
  return util.base64.encode(encodedConfigBytes, 0, encodedConfigBytes.length);
}
github dataform-co / dataform / api / commands / compile.ts View on Github external
}

  try {
    // check dataformJson is valid before we try to compile
    const dataformJson = fs.readFileSync(`${compileConfig.projectDir}/dataform.json`, "utf8");
    const projectConfig = JSON.parse(dataformJson);
    checkDataformJsonValidity({
      ...projectConfig,
      ...compileConfig.projectConfigOverride
    });
  } catch (e) {
    throw new Error(`Compile Error: ProjectConfig ('dataform.json') is invalid. ${e}`);
  }

  const encodedGraphInBase64 = await CompileChildProcess.forkProcess().compile(compileConfig);
  const encodedGraphBytes = new Uint8Array(util.base64.length(encodedGraphInBase64));
  util.base64.decode(encodedGraphInBase64, encodedGraphBytes, 0);
  const compiledGraph = dataform.CompiledGraph.decode(encodedGraphBytes);
  return dataform.CompiledGraph.create({
    ...compiledGraph,
    graphErrors: validate(compiledGraph)
  });
}
github dataform-co / dataform / core / gen_index.ts View on Github external
export function genIndex(base64EncodedConfig: string): string {
  const encodedGraphBytes = new Uint8Array(util.base64.length(base64EncodedConfig));
  util.base64.decode(base64EncodedConfig, encodedGraphBytes, 0);
  const config = dataform.GenerateIndexConfig.decode(encodedGraphBytes);

  const includeRequires = config.includePaths
    .map(path => {
      return `
      try { global.${utils.baseFilename(path)} = require("./${path}"); } catch (e) {
        if (global.session.compileError) {
          global.session.compileError(e, "${path}");
        } else {
          console.error('Error:', e.message, 'Path: "${path}"');
        }
      }`;
    })
    .join("\n");
  const definitionRequires = config.definitionPaths
github dataform-co / dataform / core / gen_index.ts View on Github external
export function genIndex(base64EncodedConfig: string): string {
  const encodedGraphBytes = new Uint8Array(util.base64.length(base64EncodedConfig));
  util.base64.decode(base64EncodedConfig, encodedGraphBytes, 0);
  const config = dataform.GenerateIndexConfig.decode(encodedGraphBytes);

  const includeRequires = config.includePaths
    .map(path => {
      return `
      try { global.${utils.baseFilename(path)} = require("./${path}"); } catch (e) {
        if (global.session.compileError) {
          global.session.compileError(e, "${path}");
        } else {
          console.error('Error:', e.message, 'Path: "${path}"');
        }
      }`;
    })
    .join("\n");
  const definitionRequires = config.definitionPaths
    .map(path => {
github dataform-co / dataform / api / vm / legacy_gen_index.ts View on Github external
export function legacyGenIndex(base64EncodedConfig: string): string {
  const encodedGraphBytes = new Uint8Array(util.base64.length(base64EncodedConfig));
  util.base64.decode(base64EncodedConfig, encodedGraphBytes, 0);
  const config = dataform.GenerateIndexConfig.decode(encodedGraphBytes);

  const includeRequires = config.includePaths
    .map(path => {
      return `
      try { global.${utils.baseFilename(path)} = require("./${path}"); } catch (e) {
        if (global.session.compileError) {
          global.session.compileError(e, "${path}");
        } else {
          console.error('Error:', e.message, 'Path: "${path}"');
        }
      }`;
    })
    .join("\n");
  const definitionRequires = config.definitionPaths
github cockroachdb / cockroach-gen / pkg / ui / cluster-ui / src / sessions / sessionsPage.fixture.ts View on Github external
const toUuid = function(s: string): Uint8Array {
  const buf = util.newBuffer(util.base64.length(s));
  util.base64.decode(s, buf, 0);
  return buf;
};
github cockroachdb / cockroach-gen / pkg / ui / src / views / sessions / sessionsPage.fixture.ts View on Github external
const toUuid = function (s: string): Uint8Array {
  const buf = util.newBuffer(util.base64.length(s));
  base64.decode(s, buf, 0);
  return buf;
};
github dataform-co / dataform / core / session.ts View on Github external
public compileToBase64() {
    const encodedGraphBytes = dataform.CompiledGraph.encode(this.compile()).finish();
    return util.base64.encode(encodedGraphBytes, 0, encodedGraphBytes.length);
  }