Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bufbuild/protoplugin

Package Overview
Dependencies
Maintainers
6
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bufbuild/protoplugin - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

dist/cjs/ecmascript/custom-options.js

94

dist/cjs/create-es-plugin.js

@@ -18,3 +18,3 @@ "use strict";

const schema_js_1 = require("./ecmascript/schema.js");
const protobuf_1 = require("@bufbuild/protobuf");
const transpile_js_1 = require("./ecmascript/transpile.js");
const error_js_1 = require("./error.js");

@@ -26,3 +26,5 @@ /**

*/
function createEcmaScriptPlugin(init, generateFn) {
function createEcmaScriptPlugin(init) {
let transpileJs = false;
let transpileDts = false;
return {

@@ -32,8 +34,66 @@ name: init.name,

run(req) {
const { targets, tsNocheck, bootstrapWkt, rewriteImports } = parseParameter(req.parameter, init.parseOption);
const { schema, toResponse } = (0, schema_js_1.createSchema)(req, targets, init.name, init.version, tsNocheck, bootstrapWkt, rewriteImports);
generateFn(schema);
const res = new protobuf_1.CodeGeneratorResponse();
toResponse(res);
return res;
var _a;
const { targets, tsNocheck, bootstrapWkt, rewriteImports, keepEmptyFiles, } = parseParameter(req.parameter, init.parseOption);
const { schema, getFileInfo } = (0, schema_js_1.createSchema)(req, targets, init.name, init.version, tsNocheck, bootstrapWkt, rewriteImports, keepEmptyFiles);
const targetTs = schema.targets.includes("ts");
const targetJs = schema.targets.includes("js");
const targetDts = schema.targets.includes("dts");
// Generate TS files under the following conditions:
// - if they are explicitly specified as a target.
// - if js is specified as a target but no js generator is provided.
// - if dts is specified as a target, but no dts generator is provided.
// In the latter two cases, it is because we need the generated TS files
// to use for transpiling js and/or dts.
let tsFiles = [];
if (targetTs ||
(targetJs && !init.generateJs) ||
(targetDts && !init.generateDts)) {
init.generateTs(schema, "ts");
// Save off the generated TypeScript files so that we can pass these
// to the transpilation process if necessary. We do not want to pass
// JavaScript files for a few reasons:
// 1. Our usage of allowJs in the compiler options will cause issues
// with attempting to transpile .ts and .js files to the same location.
// 2. There should be no reason to transpile JS because generateTs
// functions are required, so users would never be able to only specify
// a generateJs function and expect to transpile declarations.
// 3. Transpiling is somewhat expensive and situations with an
// extremely large amount of files could have performance impacts.
tsFiles = getFileInfo();
}
if (targetJs) {
if (init.generateJs) {
init.generateJs(schema, "js");
}
else {
transpileJs = true;
}
}
if (targetDts) {
if (init.generateDts) {
init.generateDts(schema, "dts");
}
else {
transpileDts = true;
}
}
// Get generated files. If ts was specified as a target, then we want
// all generated files. If ts was not specified, we still may have
// generated TypeScript files to assist in transpilation. If they were
// generated but not specified in the target out, we shouldn't produce
// these files in the CodeGeneratorResponse.
let files = getFileInfo();
if (!targetTs && tsFiles.length > 0) {
files = files.filter((file) => !tsFiles.some((tsFile) => tsFile.name === file.name));
}
// If either boolean is true, it means it was specified in the target out
// but no generate function was provided. This also means that we will
// have generated .ts files above.
if (transpileJs || transpileDts) {
const transpileFn = (_a = init.transpile) !== null && _a !== void 0 ? _a : transpile_js_1.transpile;
// Transpile the TypeScript files and add to the master list of files
const transpiledFiles = transpileFn(tsFiles, transpileJs, transpileDts);
files.push(...transpiledFiles);
}
return (0, schema_js_1.toResponse)(files);
},

@@ -47,2 +107,3 @@ };

let bootstrapWkt = false;
let keepEmptyFiles = false;
const rewriteImports = [];

@@ -105,2 +166,17 @@ for (const { key, value } of splitParameter(parameter)) {

}
case "keep_empty_files": {
switch (value) {
case "true":
case "1":
keepEmptyFiles = true;
break;
case "false":
case "0":
keepEmptyFiles = false;
break;
default:
throw new error_js_1.PluginOptionError(`${key}=${value}`);
}
break;
}
default:

@@ -119,3 +195,3 @@ if (parseOption === undefined) {

}
return { targets, tsNocheck, bootstrapWkt, rewriteImports };
return { targets, tsNocheck, bootstrapWkt, rewriteImports, keepEmptyFiles };
}

@@ -122,0 +198,0 @@ function splitParameter(parameter) {

29

dist/cjs/ecmascript/gencommon.js

@@ -106,6 +106,3 @@ "use strict";

break;
case "scalar_field":
case "enum_field":
case "message_field":
case "map_field":
case "field":
text += `@generated from field: ${desc.declarationString()};`;

@@ -143,8 +140,8 @@ break;

let optional = false;
switch (field.kind) {
case "scalar_field":
switch (field.fieldKind) {
case "scalar":
typing.push(scalarTypeScriptType(field.scalar));
optional = field.optional;
break;
case "message_field": {
case "message": {
const baseType = getUnwrappedFieldType(field);

@@ -160,7 +157,7 @@ if (baseType !== undefined) {

}
case "enum_field":
case "enum":
typing.push(file.import(field.enum).toTypeOnly());
optional = field.optional;
break;
case "map_field": {
case "map": {
let keyType;

@@ -237,4 +234,4 @@ switch (field.mapKey) {

function getFieldExplicitDefaultValue(field, protoInt64Symbol) {
switch (field.kind) {
case "enum_field": {
switch (field.fieldKind) {
case "enum": {
const value = field.enum.values.find((v) => v.number === field.getDefaultValue());

@@ -246,3 +243,3 @@ if (value !== undefined) {

}
case "scalar_field": {
case "scalar": {
const defaultValue = field.getDefaultValue();

@@ -301,3 +298,3 @@ if (defaultValue === undefined) {

}
if (field.kind == "map_field") {
if (field.fieldKind == "map") {
return {

@@ -311,4 +308,4 @@ defaultValue: "{}",

if (field.parent.file.syntax == "proto3") {
switch (field.kind) {
case "enum_field": {
switch (field.fieldKind) {
case "enum": {
if (!field.optional) {

@@ -324,3 +321,3 @@ const zeroValue = field.enum.values.find((v) => v.number === 0);

}
case "scalar_field":
case "scalar":
if (!field.optional) {

@@ -327,0 +324,0 @@ typingInferrable = true;

@@ -17,7 +17,6 @@ "use strict";

exports.createGeneratedFile = void 0;
const protobuf_1 = require("@bufbuild/protobuf");
const import_symbol_js_1 = require("./import-symbol.js");
const gencommon_js_1 = require("./gencommon.js");
const import_path_js_1 = require("./import-path.js");
function createGeneratedFile(name, importPath, createTypeImport, runtimeImports, preambleSettings) {
function createGeneratedFile(name, importPath, createTypeImport, runtimeImports, preambleSettings, keepEmpty) {
let preamble;

@@ -39,18 +38,16 @@ const el = [];

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return (0, import_symbol_js_1.createImportSymbol)(name, from);
return (0, import_symbol_js_1.createImportSymbol)(typeOrName, from);
}
return createTypeImport(typeOrName);
},
toResponse(res) {
let content = elToContent(el, importPath);
if (content.length === 0) {
getFileInfo() {
const content = elToContent(el, importPath);
if (!keepEmpty && content.length === 0) {
return;
}
if (preamble !== undefined) {
content = preamble + "\n" + content;
}
res.file.push(new protobuf_1.CodeGeneratorResponse_File({
name: name,
return {
name,
content,
}));
preamble,
};
},

@@ -57,0 +54,0 @@ };

@@ -16,3 +16,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.literalString = exports.makeJsDoc = exports.getFieldTyping = exports.getFieldIntrinsicDefaultValue = exports.getFieldExplicitDefaultValue = exports.createJsDocBlock = exports.localName = void 0;
exports.findCustomEnumOption = exports.findCustomMessageOption = exports.findCustomScalarOption = exports.literalString = exports.makeJsDoc = exports.getFieldTyping = exports.getFieldIntrinsicDefaultValue = exports.getFieldExplicitDefaultValue = exports.createJsDocBlock = exports.localName = void 0;
const protobuf_1 = require("@bufbuild/protobuf");

@@ -32,1 +32,5 @@ var target_js_1 = require("./target.js");

Object.defineProperty(exports, "literalString", { enumerable: true, get: function () { return gencommon_js_1.literalString; } });
var custom_options_js_1 = require("./custom-options.js");
Object.defineProperty(exports, "findCustomScalarOption", { enumerable: true, get: function () { return custom_options_js_1.findCustomScalarOption; } });
Object.defineProperty(exports, "findCustomMessageOption", { enumerable: true, get: function () { return custom_options_js_1.findCustomMessageOption; } });
Object.defineProperty(exports, "findCustomEnumOption", { enumerable: true, get: function () { return custom_options_js_1.findCustomEnumOption; } });

@@ -16,3 +16,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.createSchema = void 0;
exports.toResponse = exports.createSchema = void 0;
const protobuf_1 = require("@bufbuild/protobuf");

@@ -23,3 +23,3 @@ const generated_file_js_1 = require("./generated-file.js");

const import_path_js_1 = require("./import-path.js");
function createSchema(request, targets, pluginName, pluginVersion, tsNocheck, bootstrapWkt, rewriteImports) {
function createSchema(request, targets, pluginName, pluginVersion, tsNocheck, bootstrapWkt, rewriteImports, keepEmptyFiles) {
const descriptorSet = (0, protobuf_1.createDescriptorSet)(request.protoFile);

@@ -47,3 +47,3 @@ const filesToGenerate = findFilesToGenerate(descriptorSet, request);

tsNocheck,
});
}, keepEmptyFiles);
generatedFiles.push(genFile);

@@ -55,7 +55,11 @@ return genFile;

schema,
toResponse(res) {
res.supportedFeatures = protobuf_1.protoInt64.parse(protobuf_1.CodeGeneratorResponse_Feature.PROTO3_OPTIONAL);
for (const genFile of generatedFiles) {
genFile.toResponse(res);
}
getFileInfo() {
return generatedFiles.flatMap((file) => {
const fileInfo = file.getFileInfo();
// undefined is returned if the file has no content
if (!fileInfo) {
return [];
}
return [fileInfo];
});
},

@@ -65,2 +69,14 @@ };

exports.createSchema = createSchema;
function toResponse(files) {
return new protobuf_1.CodeGeneratorResponse({
supportedFeatures: protobuf_1.protoInt64.parse(protobuf_1.CodeGeneratorResponse_Feature.PROTO3_OPTIONAL),
file: files.map((f) => {
if (f.preamble !== undefined) {
f.content = f.preamble + "\n" + f.content;
}
return f;
}),
});
}
exports.toResponse = toResponse;
function findFilesToGenerate(descriptorSet, request) {

@@ -67,0 +83,0 @@ const missing = request.fileToGenerate.filter((fileToGenerate) => descriptorSet.files.every((file) => fileToGenerate !== file.name + ".proto"));

@@ -14,4 +14,4 @@ // Copyright 2021-2022 Buf Technologies, Inc.

// limitations under the License.
import { createSchema } from "./ecmascript/schema.js";
import { CodeGeneratorResponse } from "@bufbuild/protobuf";
import { createSchema, toResponse } from "./ecmascript/schema.js";
import { transpile } from "./ecmascript/transpile.js";
import { PluginOptionError } from "./error.js";

@@ -23,3 +23,5 @@ /**

*/
export function createEcmaScriptPlugin(init, generateFn) {
export function createEcmaScriptPlugin(init) {
let transpileJs = false;
let transpileDts = false;
return {

@@ -29,8 +31,66 @@ name: init.name,

run(req) {
const { targets, tsNocheck, bootstrapWkt, rewriteImports } = parseParameter(req.parameter, init.parseOption);
const { schema, toResponse } = createSchema(req, targets, init.name, init.version, tsNocheck, bootstrapWkt, rewriteImports);
generateFn(schema);
const res = new CodeGeneratorResponse();
toResponse(res);
return res;
var _a;
const { targets, tsNocheck, bootstrapWkt, rewriteImports, keepEmptyFiles, } = parseParameter(req.parameter, init.parseOption);
const { schema, getFileInfo } = createSchema(req, targets, init.name, init.version, tsNocheck, bootstrapWkt, rewriteImports, keepEmptyFiles);
const targetTs = schema.targets.includes("ts");
const targetJs = schema.targets.includes("js");
const targetDts = schema.targets.includes("dts");
// Generate TS files under the following conditions:
// - if they are explicitly specified as a target.
// - if js is specified as a target but no js generator is provided.
// - if dts is specified as a target, but no dts generator is provided.
// In the latter two cases, it is because we need the generated TS files
// to use for transpiling js and/or dts.
let tsFiles = [];
if (targetTs ||
(targetJs && !init.generateJs) ||
(targetDts && !init.generateDts)) {
init.generateTs(schema, "ts");
// Save off the generated TypeScript files so that we can pass these
// to the transpilation process if necessary. We do not want to pass
// JavaScript files for a few reasons:
// 1. Our usage of allowJs in the compiler options will cause issues
// with attempting to transpile .ts and .js files to the same location.
// 2. There should be no reason to transpile JS because generateTs
// functions are required, so users would never be able to only specify
// a generateJs function and expect to transpile declarations.
// 3. Transpiling is somewhat expensive and situations with an
// extremely large amount of files could have performance impacts.
tsFiles = getFileInfo();
}
if (targetJs) {
if (init.generateJs) {
init.generateJs(schema, "js");
}
else {
transpileJs = true;
}
}
if (targetDts) {
if (init.generateDts) {
init.generateDts(schema, "dts");
}
else {
transpileDts = true;
}
}
// Get generated files. If ts was specified as a target, then we want
// all generated files. If ts was not specified, we still may have
// generated TypeScript files to assist in transpilation. If they were
// generated but not specified in the target out, we shouldn't produce
// these files in the CodeGeneratorResponse.
let files = getFileInfo();
if (!targetTs && tsFiles.length > 0) {
files = files.filter((file) => !tsFiles.some((tsFile) => tsFile.name === file.name));
}
// If either boolean is true, it means it was specified in the target out
// but no generate function was provided. This also means that we will
// have generated .ts files above.
if (transpileJs || transpileDts) {
const transpileFn = (_a = init.transpile) !== null && _a !== void 0 ? _a : transpile;
// Transpile the TypeScript files and add to the master list of files
const transpiledFiles = transpileFn(tsFiles, transpileJs, transpileDts);
files.push(...transpiledFiles);
}
return toResponse(files);
},

@@ -43,2 +103,3 @@ };

let bootstrapWkt = false;
let keepEmptyFiles = false;
const rewriteImports = [];

@@ -101,2 +162,17 @@ for (const { key, value } of splitParameter(parameter)) {

}
case "keep_empty_files": {
switch (value) {
case "true":
case "1":
keepEmptyFiles = true;
break;
case "false":
case "0":
keepEmptyFiles = false;
break;
default:
throw new PluginOptionError(`${key}=${value}`);
}
break;
}
default:

@@ -115,3 +191,3 @@ if (parseOption === undefined) {

}
return { targets, tsNocheck, bootstrapWkt, rewriteImports };
return { targets, tsNocheck, bootstrapWkt, rewriteImports, keepEmptyFiles };
}

@@ -118,0 +194,0 @@ function splitParameter(parameter) {

@@ -101,6 +101,3 @@ // Copyright 2021-2022 Buf Technologies, Inc.

break;
case "scalar_field":
case "enum_field":
case "message_field":
case "map_field":
case "field":
text += `@generated from field: ${desc.declarationString()};`;

@@ -137,8 +134,8 @@ break;

let optional = false;
switch (field.kind) {
case "scalar_field":
switch (field.fieldKind) {
case "scalar":
typing.push(scalarTypeScriptType(field.scalar));
optional = field.optional;
break;
case "message_field": {
case "message": {
const baseType = getUnwrappedFieldType(field);

@@ -154,7 +151,7 @@ if (baseType !== undefined) {

}
case "enum_field":
case "enum":
typing.push(file.import(field.enum).toTypeOnly());
optional = field.optional;
break;
case "map_field": {
case "map": {
let keyType;

@@ -228,4 +225,4 @@ switch (field.mapKey) {

export function getFieldExplicitDefaultValue(field, protoInt64Symbol) {
switch (field.kind) {
case "enum_field": {
switch (field.fieldKind) {
case "enum": {
const value = field.enum.values.find((v) => v.number === field.getDefaultValue());

@@ -237,3 +234,3 @@ if (value !== undefined) {

}
case "scalar_field": {
case "scalar": {
const defaultValue = field.getDefaultValue();

@@ -291,3 +288,3 @@ if (defaultValue === undefined) {

}
if (field.kind == "map_field") {
if (field.fieldKind == "map") {
return {

@@ -301,4 +298,4 @@ defaultValue: "{}",

if (field.parent.file.syntax == "proto3") {
switch (field.kind) {
case "enum_field": {
switch (field.fieldKind) {
case "enum": {
if (!field.optional) {

@@ -314,3 +311,3 @@ const zeroValue = field.enum.values.find((v) => v.number === 0);

}
case "scalar_field":
case "scalar":
if (!field.optional) {

@@ -317,0 +314,0 @@ typingInferrable = true;

@@ -14,7 +14,6 @@ // Copyright 2021-2022 Buf Technologies, Inc.

// limitations under the License.
import { CodeGeneratorResponse_File, } from "@bufbuild/protobuf";
import { createImportSymbol } from "./import-symbol.js";
import { literalString, makeFilePreamble } from "./gencommon.js";
import { makeImportPathRelative } from "./import-path.js";
export function createGeneratedFile(name, importPath, createTypeImport, runtimeImports, preambleSettings) {
export function createGeneratedFile(name, importPath, createTypeImport, runtimeImports, preambleSettings, keepEmpty) {
let preamble;

@@ -36,18 +35,16 @@ const el = [];

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return createImportSymbol(name, from);
return createImportSymbol(typeOrName, from);
}
return createTypeImport(typeOrName);
},
toResponse(res) {
let content = elToContent(el, importPath);
if (content.length === 0) {
getFileInfo() {
const content = elToContent(el, importPath);
if (!keepEmpty && content.length === 0) {
return;
}
if (preamble !== undefined) {
content = preamble + "\n" + content;
}
res.file.push(new CodeGeneratorResponse_File({
name: name,
return {
name,
content,
}));
preamble,
};
},

@@ -54,0 +51,0 @@ };

@@ -22,1 +22,2 @@ // Copyright 2021-2022 Buf Technologies, Inc.

export { createJsDocBlock, getFieldExplicitDefaultValue, getFieldIntrinsicDefaultValue, getFieldTyping, makeJsDoc, literalString, } from "./gencommon.js";
export { findCustomScalarOption, findCustomMessageOption, findCustomEnumOption, } from "./custom-options.js";

@@ -14,3 +14,3 @@ // Copyright 2021-2022 Buf Technologies, Inc.

// limitations under the License.
import { codegenInfo, CodeGeneratorResponse_Feature, createDescriptorSet, protoInt64, } from "@bufbuild/protobuf";
import { codegenInfo, CodeGeneratorResponse, CodeGeneratorResponse_Feature, createDescriptorSet, protoInt64, } from "@bufbuild/protobuf";
import { createGeneratedFile } from "./generated-file.js";

@@ -20,3 +20,3 @@ import { createRuntimeImports } from "./runtime-imports.js";

import { deriveImportPath, makeImportPath, rewriteImportPath, } from "./import-path.js";
export function createSchema(request, targets, pluginName, pluginVersion, tsNocheck, bootstrapWkt, rewriteImports) {
export function createSchema(request, targets, pluginName, pluginVersion, tsNocheck, bootstrapWkt, rewriteImports, keepEmptyFiles) {
const descriptorSet = createDescriptorSet(request.protoFile);

@@ -44,3 +44,3 @@ const filesToGenerate = findFilesToGenerate(descriptorSet, request);

tsNocheck,
});
}, keepEmptyFiles);
generatedFiles.push(genFile);

@@ -52,10 +52,25 @@ return genFile;

schema,
toResponse(res) {
res.supportedFeatures = protoInt64.parse(CodeGeneratorResponse_Feature.PROTO3_OPTIONAL);
for (const genFile of generatedFiles) {
genFile.toResponse(res);
}
getFileInfo() {
return generatedFiles.flatMap((file) => {
const fileInfo = file.getFileInfo();
// undefined is returned if the file has no content
if (!fileInfo) {
return [];
}
return [fileInfo];
});
},
};
}
export function toResponse(files) {
return new CodeGeneratorResponse({
supportedFeatures: protoInt64.parse(CodeGeneratorResponse_Feature.PROTO3_OPTIONAL),
file: files.map((f) => {
if (f.preamble !== undefined) {
f.content = f.preamble + "\n" + f.content;
}
return f;
}),
});
}
function findFilesToGenerate(descriptorSet, request) {

@@ -62,0 +77,0 @@ const missing = request.fileToGenerate.filter((fileToGenerate) => descriptorSet.files.every((file) => fileToGenerate !== file.name + ".proto"));

@@ -1,2 +0,3 @@

import type { Schema } from "./ecmascript";
import { Schema } from "./ecmascript/schema.js";
import type { FileInfo } from "./ecmascript/generated-file.js";
import type { Plugin } from "./plugin.js";

@@ -12,3 +13,45 @@ interface PluginInit {

version: string;
/**
* A optional parsing function which can be used to customize parameter
* parsing of the plugin.
*/
parseOption?: PluginOptionParseFn;
/**
* A function which will generate TypeScript files based on proto input.
* This function will be invoked by the plugin framework when the plugin runs.
*
* Note that this is required to be provided for plugin initialization.
*/
generateTs: (schema: Schema, target: "ts") => void;
/**
* A optional function which will generate JavaScript files based on proto
* input. This function will be invoked by the plugin framework when the
* plugin runs.
*
* If this function is not provided, the plugin framework will then check if
* a transpile function is provided. If so, it will be invoked to transpile
* JavaScript files. If not, the plugin framework will transpile the files
* itself.
*/
generateJs?: (schema: Schema, target: "js") => void;
/**
* A optional function which will generate TypeScript declaration files
* based on proto input. This function will be invoked by the plugin
* framework when the plugin runs.
*
* If this function is not provided, the plugin framework will then check if
* a transpile function is provided. If so, it will be invoked to transpile
* declaration files. If not, the plugin framework will transpile the files
* itself.
*/
generateDts?: (schema: Schema, target: "dts") => void;
/**
* A optional function which will transpile a given set of files.
*
* This funcion is meant to be used in place of either generateJs,
* generateDts, or both. However, those functions will take precedence.
* This means that if generateJs, generateDts, and this transpile function
* are all provided, this transpile function will be ignored.
*/
transpile?: (files: FileInfo[], transpileJs: boolean, transpileDts: boolean) => FileInfo[];
}

@@ -21,3 +64,3 @@ declare type PluginOptionParseFn = (key: string, value: string | undefined) => void;

*/
export declare function createEcmaScriptPlugin(init: PluginInit, generateFn: (schema: Schema) => void): Plugin;
export declare function createEcmaScriptPlugin(init: PluginInit): Plugin;
export {};
import { DescEnum, DescEnumValue, DescField, DescFile, DescMessage, DescMethod, DescOneof, DescService, ScalarType } from "@bufbuild/protobuf";
import type { GeneratedFile } from "./generated-file.js";
import type { GeneratedFile, Printable } from "./generated-file.js";
import type { ImportSymbol } from "./import-symbol.js";
declare type Printable = Parameters<GeneratedFile["print"]>[number];
export declare function makeFilePreamble(file: DescFile, pluginName: string, pluginVersion: string, parameter: string | undefined, tsNoCheck: boolean): string;

@@ -23,2 +22,1 @@ export declare function createJsDocBlock(text: string, indentation?: string): Printable;

};
export {};
import type { DescEnum, DescFile, DescMessage } from "@bufbuild/protobuf";
import { CodeGeneratorResponse } from "@bufbuild/protobuf";
import type { ImportSymbol } from "./import-symbol.js";

@@ -8,4 +7,12 @@ import type { RuntimeImports } from "./runtime-imports.js";

*/
declare type Printable = string | number | boolean | bigint | Uint8Array | ImportSymbol | DescMessage | DescEnum | Printable[];
export declare type Printable = string | number | boolean | bigint | Uint8Array | ImportSymbol | DescMessage | DescEnum | Printable[];
/**
* FileInfo represents an intermediate type using for transpiling TypeScript internally.
*/
export interface FileInfo {
name: string;
content: string;
preamble?: string | undefined;
}
/**
* Represents a JavaScript, TypeScript, or TypeScript declaration file.

@@ -54,4 +61,4 @@ */

}
export interface GenerateFileToResponse {
toResponse(res: CodeGeneratorResponse): void;
export interface GenerateFileToFileInfo {
getFileInfo(): FileInfo | undefined;
}

@@ -64,3 +71,3 @@ declare type CreateTypeImportFn = (desc: DescMessage | DescEnum) => ImportSymbol;

tsNocheck: boolean;
}): GeneratedFile & GenerateFileToResponse;
}, keepEmpty: boolean): GeneratedFile & GenerateFileToFileInfo;
export {};
export { Target } from "./target.js";
export { Schema } from "./schema.js";
export { RuntimeImports } from "./runtime-imports.js";
export { GeneratedFile } from "./generated-file.js";
export { GeneratedFile, FileInfo, Printable } from "./generated-file.js";
export { ImportSymbol } from "./import-symbol.js";
export declare const localName: typeof import("@bufbuild/protobuf/dist/types/private/names.js").localName;
export { createJsDocBlock, getFieldExplicitDefaultValue, getFieldIntrinsicDefaultValue, getFieldTyping, makeJsDoc, literalString, } from "./gencommon.js";
export { findCustomScalarOption, findCustomMessageOption, findCustomEnumOption, } from "./custom-options.js";
import type { CodeGeneratorRequest, DescFile } from "@bufbuild/protobuf";
import { CodeGeneratorResponse } from "@bufbuild/protobuf";
import type { GeneratedFile } from "./generated-file.js";
import type { GeneratedFile, FileInfo } from "./generated-file.js";
import { RuntimeImports } from "./runtime-imports.js";

@@ -39,5 +39,6 @@ import type { Target } from "./target.js";

schema: Schema;
toResponse: (res: CodeGeneratorResponse) => void;
getFileInfo: () => FileInfo[];
}
export declare function createSchema(request: CodeGeneratorRequest, targets: Target[], pluginName: string, pluginVersion: string, tsNocheck: boolean, bootstrapWkt: boolean, rewriteImports: RewriteImports): SchemaController;
export declare function createSchema(request: CodeGeneratorRequest, targets: Target[], pluginName: string, pluginVersion: string, tsNocheck: boolean, bootstrapWkt: boolean, rewriteImports: RewriteImports, keepEmptyFiles: boolean): SchemaController;
export declare function toResponse(files: FileInfo[]): CodeGeneratorResponse;
export {};
{
"name": "@bufbuild/protoplugin",
"version": "0.1.1",
"version": "0.2.0",
"license": "(Apache-2.0 AND BSD-3-Clause)",

@@ -38,10 +38,12 @@ "description": "Helps to create your own Protocol Buffers code generators.",

"dependencies": {
"@bufbuild/protobuf": "0.1.1"
"@bufbuild/protobuf": "0.2.0",
"@typescript/vfs": "^1.4.0",
"typescript": "4.5.2"
},
"devDependencies": {
"typescript": "^4.8.2"
},
"files": [
"dist/**/"
]
],
"devDependencies": {
"@types/lz-string": "^1.3.34"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc