Socket
Socket
Sign inDemoInstall

ts-proto

Package Overview
Dependencies
Maintainers
1
Versions
352
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-proto - npm Package Compare versions

Comparing version 1.178.0 to 1.179.0

6

build/enums.js

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

function generateEnum(ctx, fullName, enumDesc, sourceInfo) {
var _a;
const { options } = ctx;
const chunks = [];
let unrecognizedEnum = { present: false };
(0, utils_1.maybeAddComment)(options, sourceInfo, chunks, (_a = enumDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
(0, utils_1.maybeAddComment)(options, sourceInfo, chunks, enumDesc.options?.deprecated);
if (options.enumsAsLiterals) {

@@ -24,3 +23,2 @@ chunks.push((0, ts_poet_1.code) `export const ${(0, ts_poet_1.def)(fullName)} = {`);

enumDesc.value.forEach((valueDesc, index) => {
var _a;
const info = sourceInfo.lookup(sourceInfo_1.Fields.enum.value, index);

@@ -32,3 +30,3 @@ const valueName = getValueName(ctx, fullName, valueDesc);

}
(0, utils_1.maybeAddComment)(options, info, chunks, (_a = valueDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated, `${memberName} - `);
(0, utils_1.maybeAddComment)(options, info, chunks, valueDesc.options?.deprecated, `${memberName} - `);
chunks.push((0, ts_poet_1.code) `${memberName} ${delimiter} ${options.stringEnums ? `"${valueName}"` : valueDesc.number.toString()},`);

@@ -35,0 +33,0 @@ });

@@ -14,5 +14,4 @@ "use strict";

function generateGenericServiceDefinition(ctx, fileDesc, sourceInfo, serviceDesc) {
var _a, _b, _c;
const chunks = [];
(0, utils_1.maybeAddComment)(ctx.options, sourceInfo, chunks, (_a = serviceDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
(0, utils_1.maybeAddComment)(ctx.options, sourceInfo, chunks, serviceDesc.options?.deprecated);
// Service definition type

@@ -27,3 +26,3 @@ const name = (0, ts_poet_1.def)(`${serviceDesc.name}Definition`);

`);
(_b = serviceDesc.options) === null || _b === void 0 ? void 0 : _b.uninterpretedOption;
serviceDesc.options?.uninterpretedOption;
chunks.push((0, ts_poet_1.code) `

@@ -36,3 +35,3 @@ name: '${serviceDesc.name}',

const info = sourceInfo.lookup(sourceInfo_1.Fields.service.method, index);
(0, utils_1.maybeAddComment)(ctx.options, info, chunks, (_c = methodDesc.options) === null || _c === void 0 ? void 0 : _c.deprecated);
(0, utils_1.maybeAddComment)(ctx.options, info, chunks, methodDesc.options?.deprecated);
chunks.push((0, ts_poet_1.code) `

@@ -39,0 +38,0 @@ ${(0, case_1.uncapitalize)(methodDesc.name)}: ${generateMethodDefinition(ctx, methodDesc)},

@@ -42,5 +42,4 @@ "use strict";

function generateServiceDefinition(ctx, fileDesc, sourceInfo, serviceDesc) {
var _a, _b;
const chunks = [];
(0, utils_1.maybeAddComment)(ctx.options, sourceInfo, chunks, (_a = serviceDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
(0, utils_1.maybeAddComment)(ctx.options, sourceInfo, chunks, serviceDesc.options?.deprecated);
// Service definition type

@@ -60,3 +59,3 @@ const name = (0, ts_poet_1.def)(`${serviceDesc.name}Service`);

const info = sourceInfo.lookup(sourceInfo_1.Fields.service.method, index);
(0, utils_1.maybeAddComment)(ctx.options, info, chunks, (_b = methodDesc.options) === null || _b === void 0 ? void 0 : _b.deprecated);
(0, utils_1.maybeAddComment)(ctx.options, info, chunks, methodDesc.options?.deprecated);
const inputEncoder = (0, encode_1.generateEncoder)(ctx, methodDesc.inputType);

@@ -84,3 +83,2 @@ const outputEncoder = (0, encode_1.generateEncoder)(ctx, methodDesc.outputType);

function generateServerStub(ctx, sourceInfo, serviceDesc) {
var _a;
const chunks = [];

@@ -93,3 +91,3 @@ chunks.push((0, ts_poet_1.code) `export interface ${(0, ts_poet_1.def)(`${serviceDesc.name}Server`)} extends ${UntypedServiceImplementation} {`);

const info = sourceInfo.lookup(sourceInfo_1.Fields.service.method, index);
(0, utils_1.maybeAddComment)(ctx.options, info, chunks, (_a = methodDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
(0, utils_1.maybeAddComment)(ctx.options, info, chunks, methodDesc.options?.deprecated);
const callType = methodDesc.clientStreaming

@@ -110,3 +108,2 @@ ? methodDesc.serverStreaming

function generateClientStub(ctx, sourceInfo, serviceDesc) {
var _a;
const chunks = [];

@@ -119,3 +116,3 @@ chunks.push((0, ts_poet_1.code) `export interface ${(0, ts_poet_1.def)(`${serviceDesc.name}Client`)} extends ${Client} {`);

const info = sourceInfo.lookup(sourceInfo_1.Fields.service.method, index);
(0, utils_1.maybeAddComment)(ctx.options, info, chunks, (_a = methodDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
(0, utils_1.maybeAddComment)(ctx.options, info, chunks, methodDesc.options?.deprecated);
const responseCallback = (0, ts_poet_1.code) `(error: ${ServiceError} | null, response: ${outputType}) => void`;

@@ -122,0 +119,0 @@ if (methodDesc.clientStreaming) {

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

function generateNestjsServiceController(ctx, fileDesc, sourceInfo, serviceDesc) {
var _a;
const { options } = ctx;
const chunks = [];
const Metadata = (0, ts_poet_1.imp)("Metadata@@grpc/grpc-js");
(0, utils_1.maybeAddComment)(options, sourceInfo, chunks, (_a = serviceDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
(0, utils_1.maybeAddComment)(options, sourceInfo, chunks, serviceDesc.options?.deprecated);
const t = options.context ? `<${main_1.contextTypeVar}>` : "";

@@ -21,6 +20,5 @@ chunks.push((0, ts_poet_1.code) `

serviceDesc.method.forEach((methodDesc, index) => {
var _a;
(0, utils_1.assertInstanceOf)(methodDesc, utils_1.FormattedMethodDescriptor);
const info = sourceInfo.lookup(sourceInfo_1.Fields.service.method, index);
(0, utils_1.maybeAddComment)(options, info, chunks, (_a = serviceDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
(0, utils_1.maybeAddComment)(options, info, chunks, serviceDesc.options?.deprecated);
const params = [];

@@ -85,3 +83,2 @@ if (options.context) {

serviceDesc.method.forEach((methodDesc, index) => {
var _a;
(0, utils_1.assertInstanceOf)(methodDesc, utils_1.FormattedMethodDescriptor);

@@ -104,3 +101,3 @@ const params = [];

const info = sourceInfo.lookup(sourceInfo_1.Fields.service.method, index);
(0, utils_1.maybeAddComment)(options, info, chunks, (_a = methodDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
(0, utils_1.maybeAddComment)(options, info, chunks, methodDesc.options?.deprecated);
chunks.push((0, ts_poet_1.code) `

@@ -107,0 +104,0 @@ ${methodDesc.formattedName}(

@@ -22,3 +22,2 @@ "use strict";

function generateServerStub(ctx, sourceInfo, serviceDesc) {
var _a;
const chunks = [];

@@ -36,3 +35,3 @@ const maybeSuffix = serviceDesc.name.endsWith("Service") ? "" : "Service";

const info = sourceInfo.lookup(sourceInfo_1.Fields.service.method, index);
(0, utils_1.maybeAddComment)(ctx.options, info, chunks, (_a = methodDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
(0, utils_1.maybeAddComment)(ctx.options, info, chunks, methodDesc.options?.deprecated);
if (methodDesc.clientStreaming) {

@@ -83,3 +82,2 @@ if (methodDesc.serverStreaming) {

function generateClientStub(ctx, sourceInfo, serviceDesc) {
var _a;
const chunks = [];

@@ -95,3 +93,3 @@ chunks.push((0, ts_poet_1.code) `export interface ${(0, ts_poet_1.def)(`${serviceDesc.name}Client`)}<CallOptionsExt = {}> {`);

const info = sourceInfo.lookup(sourceInfo_1.Fields.service.method, index);
(0, utils_1.maybeAddComment)(ctx.options, info, chunks, (_a = methodDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
(0, utils_1.maybeAddComment)(ctx.options, info, chunks, methodDesc.options?.deprecated);
if (methodDesc.clientStreaming) {

@@ -98,0 +96,0 @@ if (methodDesc.serverStreaming) {

@@ -20,13 +20,11 @@ "use strict";

function generateService(ctx, fileDesc, sourceInfo, serviceDesc) {
var _a;
const { options } = ctx;
const chunks = [];
(0, utils_1.maybeAddComment)(options, sourceInfo, chunks, (_a = serviceDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
(0, utils_1.maybeAddComment)(options, sourceInfo, chunks, serviceDesc.options?.deprecated);
const maybeTypeVar = options.context ? `<${main_1.contextTypeVar}>` : "";
chunks.push((0, ts_poet_1.code) `export interface ${(0, ts_poet_1.def)(serviceDesc.name)}${maybeTypeVar} {`);
serviceDesc.method.forEach((methodDesc, index) => {
var _a;
(0, utils_1.assertInstanceOf)(methodDesc, utils_1.FormattedMethodDescriptor);
const info = sourceInfo.lookup(sourceInfo_1.Fields.service.method, index);
(0, utils_1.maybeAddComment)(options, info, chunks, (_a = methodDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
(0, utils_1.maybeAddComment)(options, info, chunks, methodDesc.options?.deprecated);
const params = [];

@@ -33,0 +31,0 @@ if (options.context) {

@@ -100,2 +100,3 @@ import { ToStringOpts } from "ts-poet/build/Code";

noDefaultsForOptionals: boolean;
bigIntLiteral: boolean;
};

@@ -102,0 +103,0 @@ export declare function defaultOptions(): Options;

@@ -107,2 +107,3 @@ "use strict";

noDefaultsForOptionals: false,
bigIntLiteral: true,
};

@@ -109,0 +110,0 @@ }

@@ -13,3 +13,2 @@ "use strict";

function generateSchema(ctx, fileDesc, sourceInfo) {
var _a;
const { options } = ctx;

@@ -77,3 +76,3 @@ const chunks = [];

descriptor.sourceCodeInfo = {
location: ((_a = descriptor.sourceCodeInfo) === null || _a === void 0 ? void 0 : _a.location.filter((loc) => loc["leadingComments"] || loc["trailingComments"])) || [],
location: descriptor.sourceCodeInfo?.location.filter((loc) => loc["leadingComments"] || loc["trailingComments"]) || [],
};

@@ -80,0 +79,0 @@ let fileOptions;

@@ -64,5 +64,4 @@ "use strict";

function basicTypeName(ctx, field, typeOptions = {}) {
var _a, _b;
const { options } = ctx;
const fieldType = (_a = getFieldOptionsJsType(field, ctx.options)) !== null && _a !== void 0 ? _a : field.type;
const fieldType = getFieldOptionsJsType(field, ctx.options) ?? field.type;
switch (fieldType) {

@@ -83,3 +82,3 @@ case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_DOUBLE:

return isJsTypeFieldOption(options, field)
? (_b = jsTypeName(field)) !== null && _b !== void 0 ? _b : longTypeName(ctx)
? jsTypeName(field) ?? longTypeName(ctx)
: // this handles 2^53, Long is only needed for 2^64; this is effectively pbjs's forceNumber

@@ -175,4 +174,3 @@ longTypeName(ctx);

function getFieldOptionsJsType(field, options) {
var _a;
if (!options.useJsTypeOverride || ((_a = field.options) === null || _a === void 0 ? void 0 : _a.jstype) === undefined) {
if (!options.useJsTypeOverride || field.options?.jstype === undefined) {
return;

@@ -248,3 +246,3 @@ }

else if (options.forceLong === options_1.LongOption.BIGINT) {
return `BigInt("${numericDefaultVal}")`;
return options.bigIntLiteral ? (0, ts_poet_1.code) `${numericDefaultVal}n` : (0, ts_poet_1.code) `BigInt("${numericDefaultVal}")`;
}

@@ -382,3 +380,3 @@ else {

return ((optionalMessages && isMessage(field) && !isRepeated(field)) ||
((optionalAll || deprecatedOnly) && !(messageOptions === null || messageOptions === void 0 ? void 0 : messageOptions.mapEntry)) ||
((optionalAll || deprecatedOnly) && !messageOptions?.mapEntry) ||
(options.noDefaultsForOptionals && !isRepeated(field) && (isScalar(field) || isEnum(field))) ||

@@ -388,3 +386,3 @@ // file is proto2, we have enabled proto2 optionals, and the field itself is optional

field.label === ts_proto_descriptors_1.FieldDescriptorProto_Label.LABEL_OPTIONAL &&
!(messageOptions === null || messageOptions === void 0 ? void 0 : messageOptions.mapEntry) &&
!messageOptions?.mapEntry &&
!options.disableProto2Optionals) ||

@@ -582,7 +580,6 @@ // don't bother verifying that oneof is not union. union oneofs generate their own properties.

function jsTypeName(field) {
var _a, _b;
if (((_a = field.options) === null || _a === void 0 ? void 0 : _a.jstype) === ts_proto_descriptors_1.FieldOptions_JSType.JS_STRING) {
if (field.options?.jstype === ts_proto_descriptors_1.FieldOptions_JSType.JS_STRING) {
return (0, ts_poet_1.code) `string`;
}
else if (((_b = field.options) === null || _b === void 0 ? void 0 : _b.jstype) === ts_proto_descriptors_1.FieldOptions_JSType.JS_NUMBER) {
else if (field.options?.jstype === ts_proto_descriptors_1.FieldOptions_JSType.JS_NUMBER) {
return (0, ts_poet_1.code) `number`;

@@ -593,3 +590,2 @@ }

function messageToTypeName(ctx, protoType, typeOptions = {}) {
var _a;
const { options, typeMap } = ctx;

@@ -602,3 +598,3 @@ // Watch for the wrapper types `.google.protobuf.*Value`. If we're mapping

if (!typeOptions.keepValueType && valueType) {
if ((_a = typeOptions.repeated) !== null && _a !== void 0 ? _a : false) {
if (typeOptions.repeated ?? false) {
return valueType;

@@ -636,3 +632,2 @@ }

function toTypeName(ctx, messageDesc, field, ensureOptional = false) {
var _a;
function finalize(type, isOptional) {

@@ -644,3 +639,3 @@ if (isOptional) {

}
const fieldType = (_a = getFieldOptionsJsType(field, ctx.options)) !== null && _a !== void 0 ? _a : field.type;
const fieldType = getFieldOptionsJsType(field, ctx.options) ?? field.type;
const type = basicTypeName(ctx, { ...field, type: fieldType }, { keepValueType: false });

@@ -711,3 +706,2 @@ if (isRepeated(field)) {

function detectMapType(ctx, messageDesc, fieldDesc) {
var _a;
const { typeMap } = ctx;

@@ -717,3 +711,3 @@ if (fieldDesc.label === ts_proto_descriptors_1.FieldDescriptorProto_Label.LABEL_REPEATED &&

const mapType = typeMap.get(fieldDesc.typeName)[2];
if (!((_a = mapType.options) === null || _a === void 0 ? void 0 : _a.mapEntry))
if (!mapType.options?.mapEntry)
return undefined;

@@ -815,6 +809,5 @@ const [keyField, valueField] = mapType.field;

function isJsTypeFieldOption(options, field) {
var _a, _b;
return (options.useJsTypeOverride &&
(((_a = field.options) === null || _a === void 0 ? void 0 : _a.jstype) === ts_proto_descriptors_1.FieldOptions_JSType.JS_NUMBER || ((_b = field.options) === null || _b === void 0 ? void 0 : _b.jstype) === ts_proto_descriptors_1.FieldOptions_JSType.JS_STRING));
(field.options?.jstype === ts_proto_descriptors_1.FieldOptions_JSType.JS_NUMBER || field.options?.jstype === ts_proto_descriptors_1.FieldOptions_JSType.JS_STRING));
}
exports.isJsTypeFieldOption = isJsTypeFieldOption;

@@ -286,3 +286,2 @@ "use strict";

async function getVersions(request) {
var _a;
let protocVersion = "unknown";

@@ -295,3 +294,3 @@ if (request.compilerVersion) {

const packageJson = await Promise.resolve(`${path}`).then(s => require(s));
const tsProtoVersion = `v${(_a = packageJson === null || packageJson === void 0 ? void 0 : packageJson.version) !== null && _a !== void 0 ? _a : "unknown"}`;
const tsProtoVersion = `v${packageJson?.version ?? "unknown"}`;
return {

@@ -298,0 +297,0 @@ protocVersion,

{
"name": "ts-proto",
"version": "1.178.0",
"version": "1.179.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "build/plugin.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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