Comparing version
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.camelCase = exports.capitalize = exports.camelToSnake = exports.snakeToCamel = exports.maybeSnakeToCamel = void 0; | ||
exports.camelCaseGrpc = exports.uncapitalize = exports.capitalize = exports.camelToSnake = exports.snakeToCamel = exports.maybeSnakeToCamel = void 0; | ||
const case_anything_1 = require("case-anything"); | ||
/** Converts `key` to TS/JS camel-case idiom, unless overridden not to. */ | ||
@@ -34,5 +35,14 @@ function maybeSnakeToCamel(key, options) { | ||
exports.capitalize = capitalize; | ||
function camelCase(s) { | ||
function uncapitalize(s) { | ||
return s.substring(0, 1).toLowerCase() + s.substring(1); | ||
} | ||
exports.camelCase = camelCase; | ||
exports.uncapitalize = uncapitalize; | ||
/* This function uses the exact same semantics found inside the grpc | ||
* nodejs library. Camel case splitting must be done by word i.e | ||
* GetAPIValue must become getApiValue (notice the API becomes Api). | ||
* This needs to be followed otherwise it will not succeed in the grpc nodejs module. | ||
*/ | ||
function camelCaseGrpc(s) { | ||
return (0, case_anything_1.camelCase)(s); | ||
} | ||
exports.camelCaseGrpc = camelCaseGrpc; |
@@ -15,3 +15,7 @@ "use strict"; | ||
const TimestampValue = (0, utils_1.impProto)(ctx.options, "google/protobuf/timestamp", name); | ||
return (0, ts_poet_1.code) `${TimestampValue}.encode(${ctx.utils.toTimestamp}(value)).finish()`; | ||
let value = (0, ts_poet_1.code) `value`; | ||
if (ctx.options.useDate === options_1.DateOption.DATE || ctx.options.useDate === options_1.DateOption.STRING) { | ||
value = (0, ts_poet_1.code) `${ctx.utils.toTimestamp}(${value})`; | ||
} | ||
return (0, ts_poet_1.code) `${TimestampValue}.encode(${value}).finish()`; | ||
} | ||
@@ -44,3 +48,3 @@ if (name == "Struct") { | ||
case "BytesValue": | ||
return (0, ts_poet_1.code) `${TypeValue}.encode({value: value ?? new Uint8Array()}).finish()`; | ||
return (0, ts_poet_1.code) `${TypeValue}.encode({value: value ?? new Uint8Array(0)}).finish()`; | ||
} | ||
@@ -59,3 +63,7 @@ throw new Error(`unknown wrapper type: ${name}`); | ||
TypeValue = (0, utils_1.impProto)(ctx.options, "google/protobuf/timestamp", name); | ||
return (0, ts_poet_1.code) `${TypeValue}.decode(value)`; | ||
const decoder = (0, ts_poet_1.code) `${TypeValue}.decode(value)`; | ||
if (ctx.options.useDate === options_1.DateOption.DATE || ctx.options.useDate === options_1.DateOption.STRING) { | ||
return (0, ts_poet_1.code) `${ctx.utils.fromTimestamp}(${decoder})`; | ||
} | ||
return decoder; | ||
} | ||
@@ -62,0 +70,0 @@ if (name == "Struct" || name == "ListValue") { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generateEnumToNumber = exports.generateEnumToJson = exports.generateEnumFromJson = exports.generateEnum = void 0; | ||
exports.getMemberName = exports.generateEnumToNumber = exports.generateEnumToJson = exports.generateEnumFromJson = exports.generateEnum = void 0; | ||
const ts_poet_1 = require("ts-poet"); | ||
@@ -26,4 +26,6 @@ const utils_1 = require("./utils"); | ||
const info = sourceInfo.lookup(sourceInfo_1.Fields.enum.value, index); | ||
(0, utils_1.maybeAddComment)(info, chunks, (_a = valueDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated, `${valueDesc.name} - `); | ||
chunks.push((0, ts_poet_1.code) `${valueDesc.name} ${delimiter} ${options.stringEnums ? `"${valueDesc.name}"` : valueDesc.number.toString()},`); | ||
const valueName = getValueName(ctx, fullName, valueDesc); | ||
const memberName = getMemberName(ctx, enumDesc, valueDesc); | ||
(0, utils_1.maybeAddComment)(info, chunks, (_a = valueDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated, `${memberName} - `); | ||
chunks.push((0, ts_poet_1.code) `${memberName} ${delimiter} ${options.stringEnums ? `"${valueName}"` : valueDesc.number.toString()},`); | ||
}); | ||
@@ -60,10 +62,12 @@ if (options.unrecognizedEnum) | ||
const chunks = []; | ||
const functionName = (0, case_1.camelCase)(fullName) + "FromJSON"; | ||
const functionName = (0, case_1.uncapitalize)(fullName) + "FromJSON"; | ||
chunks.push((0, ts_poet_1.code) `export function ${(0, ts_poet_1.def)(functionName)}(object: any): ${fullName} {`); | ||
chunks.push((0, ts_poet_1.code) `switch (object) {`); | ||
for (const valueDesc of enumDesc.value) { | ||
const memberName = getMemberName(ctx, enumDesc, valueDesc); | ||
const valueName = getValueName(ctx, fullName, valueDesc); | ||
chunks.push((0, ts_poet_1.code) ` | ||
case ${valueDesc.number}: | ||
case "${valueDesc.name}": | ||
return ${fullName}.${valueDesc.name}; | ||
case "${valueName}": | ||
return ${fullName}.${memberName}; | ||
`); | ||
@@ -95,3 +99,3 @@ } | ||
const chunks = []; | ||
const functionName = (0, case_1.camelCase)(fullName) + "ToJSON"; | ||
const functionName = (0, case_1.uncapitalize)(fullName) + "ToJSON"; | ||
chunks.push((0, ts_poet_1.code) `export function ${(0, ts_poet_1.def)(functionName)}(object: ${fullName}): ${ctx.options.useNumericEnumForJson ? "number" : "string"} {`); | ||
@@ -101,6 +105,9 @@ chunks.push((0, ts_poet_1.code) `switch (object) {`); | ||
if (ctx.options.useNumericEnumForJson) { | ||
chunks.push((0, ts_poet_1.code) `case ${fullName}.${valueDesc.name}: return ${valueDesc.number};`); | ||
const memberName = getMemberName(ctx, enumDesc, valueDesc); | ||
chunks.push((0, ts_poet_1.code) `case ${fullName}.${memberName}: return ${valueDesc.number};`); | ||
} | ||
else { | ||
chunks.push((0, ts_poet_1.code) `case ${fullName}.${valueDesc.name}: return "${valueDesc.name}";`); | ||
const memberName = getMemberName(ctx, enumDesc, valueDesc); | ||
const valueName = getValueName(ctx, fullName, valueDesc); | ||
chunks.push((0, ts_poet_1.code) `case ${fullName}.${memberName}: return "${valueName}";`); | ||
} | ||
@@ -140,7 +147,7 @@ } | ||
const chunks = []; | ||
const functionName = (0, case_1.camelCase)(fullName) + "ToNumber"; | ||
const functionName = (0, case_1.uncapitalize)(fullName) + "ToNumber"; | ||
chunks.push((0, ts_poet_1.code) `export function ${(0, ts_poet_1.def)(functionName)}(object: ${fullName}): number {`); | ||
chunks.push((0, ts_poet_1.code) `switch (object) {`); | ||
for (const valueDesc of enumDesc.value) { | ||
chunks.push((0, ts_poet_1.code) `case ${fullName}.${valueDesc.name}: return ${valueDesc.number};`); | ||
chunks.push((0, ts_poet_1.code) `case ${fullName}.${getMemberName(ctx, enumDesc, valueDesc)}: return ${valueDesc.number};`); | ||
} | ||
@@ -166,1 +173,11 @@ if (options.unrecognizedEnum) { | ||
exports.generateEnumToNumber = generateEnumToNumber; | ||
function getMemberName(ctx, enumDesc, valueDesc) { | ||
if (ctx.options.removeEnumPrefix) { | ||
return valueDesc.name.replace(`${(0, case_1.camelToSnake)(enumDesc.name)}_`, ""); | ||
} | ||
return valueDesc.name; | ||
} | ||
exports.getMemberName = getMemberName; | ||
function getValueName(ctx, fullName, valueDesc) { | ||
return valueDesc.name; | ||
} |
@@ -36,3 +36,3 @@ "use strict"; | ||
chunks.push((0, ts_poet_1.code) ` | ||
${(0, case_1.camelCase)(methodDesc.name)}: ${generateMethodDefinition(ctx, methodDesc)}, | ||
${(0, case_1.uncapitalize)(methodDesc.name)}: ${generateMethodDefinition(ctx, methodDesc)}, | ||
`); | ||
@@ -57,7 +57,7 @@ } | ||
responseStream: ${methodDesc.serverStreaming}, | ||
options: ${generateMethodOptions(methodDesc.options)} | ||
options: ${generateMethodOptions(ctx, methodDesc.options)} | ||
} | ||
`; | ||
} | ||
function generateMethodOptions(options) { | ||
function generateMethodOptions(ctx, options) { | ||
const chunks = []; | ||
@@ -72,2 +72,16 @@ chunks.push((0, ts_poet_1.code) `{`); | ||
} | ||
if (options._unknownFields !== undefined) { | ||
const unknownFieldsChunks = []; | ||
unknownFieldsChunks.push((0, ts_poet_1.code) `{`); | ||
for (const key in options._unknownFields) { | ||
const values = options._unknownFields[key]; | ||
const valuesChunks = []; | ||
for (const value of values) { | ||
valuesChunks.push((0, ts_poet_1.code) `${ctx.options.env == "node" ? "Buffer.from" : "new Uint8Array"}([${value.join(", ")}])`); | ||
} | ||
unknownFieldsChunks.push((0, ts_poet_1.code) `${key}: [\n${(0, ts_poet_1.joinCode)(valuesChunks, { on: "," })}\n],`); | ||
} | ||
unknownFieldsChunks.push((0, ts_poet_1.code) `}`); | ||
chunks.push((0, ts_poet_1.code) `_unknownFields: ${(0, ts_poet_1.joinCode)(unknownFieldsChunks, { on: "\n" })}`); | ||
} | ||
} | ||
@@ -74,0 +88,0 @@ chunks.push((0, ts_poet_1.code) `}`); |
@@ -11,3 +11,3 @@ "use strict"; | ||
const ChannelCredentials = (0, ts_poet_1.imp)("ChannelCredentials@@grpc/grpc-js"); | ||
const ChannelOptions = (0, ts_poet_1.imp)("ChannelOptions@@grpc/grpc-js"); | ||
const ClientOptions = (0, ts_poet_1.imp)("ClientOptions@@grpc/grpc-js"); | ||
const Client = (0, ts_poet_1.imp)("Client@@grpc/grpc-js"); | ||
@@ -202,3 +202,3 @@ const ClientDuplexStream = (0, ts_poet_1.imp)("ClientDuplexStream@@grpc/grpc-js"); | ||
credentials: ${ChannelCredentials}, | ||
options?: Partial<${ChannelOptions}>, | ||
options?: Partial<${ClientOptions}>, | ||
): ${serviceDesc.name}Client; | ||
@@ -205,0 +205,0 @@ service: typeof ${serviceDesc.name}Service; |
@@ -21,3 +21,3 @@ "use strict"; | ||
private readonly rpc: Rpc; | ||
constructor(rpc: Rpc) { | ||
@@ -43,2 +43,4 @@ `); | ||
(0, utils_1.assertInstanceOf)(methodDesc, utils_1.FormattedMethodDescriptor); | ||
const { options } = ctx; | ||
const { useAbortSignal } = options; | ||
const requestMessage = (0, types_1.rawRequestType)(ctx, methodDesc); | ||
@@ -52,2 +54,3 @@ const inputType = (0, types_1.requestType)(ctx, methodDesc, true); | ||
metadata?: grpc.Metadata, | ||
${useAbortSignal ? "abortSignal?: AbortSignal," : ""} | ||
): ${returns} { | ||
@@ -63,2 +66,3 @@ throw new Error('ts-proto does not yet support client streaming!'); | ||
metadata?: grpc.Metadata, | ||
${useAbortSignal ? "abortSignal?: AbortSignal," : ""} | ||
): ${returns} { | ||
@@ -69,2 +73,3 @@ return this.rpc.${method}( | ||
metadata, | ||
${useAbortSignal ? "abortSignal," : ""} | ||
); | ||
@@ -115,3 +120,7 @@ } | ||
deserializeBinary(data: Uint8Array) { | ||
return { ...${outputType}.decode(data), toObject() { return this; } }; | ||
const value = ${outputType}.decode(data); | ||
return { | ||
...value, | ||
toObject() { return value; }, | ||
}; | ||
} | ||
@@ -150,2 +159,4 @@ }`; | ||
const chunks = []; | ||
const { options } = ctx; | ||
const { useAbortSignal } = options; | ||
chunks.push((0, ts_poet_1.code) `interface Rpc {`); | ||
@@ -158,2 +169,3 @@ const wrapper = returnObservable ? (0, types_1.observableType)(ctx) : "Promise"; | ||
metadata: grpc.Metadata | undefined, | ||
${useAbortSignal ? "abortSignal?: AbortSignal," : ""} | ||
): ${wrapper}<any>; | ||
@@ -167,2 +179,3 @@ `); | ||
metadata: grpc.Metadata | undefined, | ||
${useAbortSignal ? "abortSignal?: AbortSignal," : ""} | ||
): ${(0, types_1.observableType)(ctx)}<any>; | ||
@@ -209,2 +222,11 @@ `); | ||
function createPromiseUnaryMethod(ctx) { | ||
const { options } = ctx; | ||
const { useAbortSignal } = options; | ||
const maybeAbortSignal = useAbortSignal | ||
? ` | ||
if (abortSignal) abortSignal.addEventListener("abort", () => { | ||
client.close(); | ||
reject(abortSignal.reason); | ||
});` | ||
: ""; | ||
return (0, ts_poet_1.code) ` | ||
@@ -214,19 +236,19 @@ unary<T extends UnaryMethodDefinitionish>( | ||
_request: any, | ||
metadata: grpc.Metadata | undefined | ||
metadata: grpc.Metadata | undefined, | ||
${useAbortSignal ? "abortSignal?: AbortSignal," : ""} | ||
): Promise<any> { | ||
const request = { ..._request, ...methodDesc.requestType }; | ||
const maybeCombinedMetadata = | ||
metadata && this.options.metadata | ||
? new ${BrowserHeaders}({ ...this.options?.metadata.headersMap, ...metadata?.headersMap }) | ||
: metadata || this.options.metadata; | ||
const maybeCombinedMetadata = metadata && this.options.metadata | ||
? new ${BrowserHeaders}({ ...this.options?.metadata.headersMap, ...metadata?.headersMap }) | ||
: metadata ?? this.options.metadata; | ||
return new Promise((resolve, reject) => { | ||
${grpc}.unary(methodDesc, { | ||
${useAbortSignal ? `const client =` : ""} ${grpc}.unary(methodDesc, { | ||
request, | ||
host: this.host, | ||
metadata: maybeCombinedMetadata, | ||
transport: this.options.transport, | ||
debug: this.options.debug, | ||
metadata: maybeCombinedMetadata ?? {}, | ||
...(this.options.transport !== undefined ? {transport: this.options.transport} : {}), | ||
debug: this.options.debug ?? false, | ||
onEnd: function (response) { | ||
if (response.status === grpc.Code.OK) { | ||
resolve(response.message); | ||
resolve(response.message!.toObject()); | ||
} else { | ||
@@ -238,2 +260,4 @@ const err = new ${ctx.utils.GrpcWebError}(response.statusMessage, response.status, response.trailers); | ||
}); | ||
${maybeAbortSignal} | ||
}); | ||
@@ -244,2 +268,11 @@ } | ||
function createObservableUnaryMethod(ctx) { | ||
const { options } = ctx; | ||
const { useAbortSignal } = options; | ||
const maybeAbortSignal = useAbortSignal | ||
? ` | ||
if (abortSignal) abortSignal.addEventListener("abort", () => { | ||
observer.error(abortSignal.reason); | ||
client.close(); | ||
});` | ||
: ""; | ||
return (0, ts_poet_1.code) ` | ||
@@ -249,16 +282,16 @@ unary<T extends UnaryMethodDefinitionish>( | ||
_request: any, | ||
metadata: grpc.Metadata | undefined | ||
metadata: grpc.Metadata | undefined, | ||
${useAbortSignal ? "abortSignal?: AbortSignal," : ""} | ||
): ${(0, types_1.observableType)(ctx)}<any> { | ||
const request = { ..._request, ...methodDesc.requestType }; | ||
const maybeCombinedMetadata = | ||
metadata && this.options.metadata | ||
? new ${BrowserHeaders}({ ...this.options?.metadata.headersMap, ...metadata?.headersMap }) | ||
: metadata || this.options.metadata; | ||
const maybeCombinedMetadata = metadata && this.options.metadata | ||
? new ${BrowserHeaders}({ ...this.options?.metadata.headersMap, ...metadata?.headersMap }) | ||
: metadata ?? this.options.metadata; | ||
return new Observable(observer => { | ||
${grpc}.unary(methodDesc, { | ||
${useAbortSignal ? `const client =` : ""} ${grpc}.unary(methodDesc, { | ||
request, | ||
host: this.host, | ||
metadata: maybeCombinedMetadata, | ||
transport: this.options.transport, | ||
debug: this.options.debug, | ||
metadata: maybeCombinedMetadata ?? {}, | ||
...(this.options.transport !== undefined ? {transport: this.options.transport} : {}), | ||
debug: this.options.debug ?? false, | ||
onEnd: (next) => { | ||
@@ -274,2 +307,6 @@ if (next.status !== 0) { | ||
}); | ||
${maybeAbortSignal} | ||
}).pipe(${take}(1)); | ||
@@ -280,2 +317,11 @@ } | ||
function createInvokeMethod(ctx) { | ||
const { options } = ctx; | ||
const { useAbortSignal } = options; | ||
const maybeAbortSignal = useAbortSignal | ||
? ` | ||
if (abortSignal) abortSignal.addEventListener("abort", () => { | ||
observer.error(abortSignal.reason); | ||
client.close(); | ||
});` | ||
: ""; | ||
return (0, ts_poet_1.code) ` | ||
@@ -285,11 +331,12 @@ invoke<T extends UnaryMethodDefinitionish>( | ||
_request: any, | ||
metadata: grpc.Metadata | undefined | ||
metadata: grpc.Metadata | undefined, | ||
${useAbortSignal ? "abortSignal?: AbortSignal," : ""} | ||
): ${(0, types_1.observableType)(ctx)}<any> { | ||
const upStreamCodes = this.options.upStreamRetryCodes || []; | ||
const upStreamCodes = this.options.upStreamRetryCodes ?? []; | ||
const DEFAULT_TIMEOUT_TIME: number = 3_000; | ||
const request = { ..._request, ...methodDesc.requestType }; | ||
const maybeCombinedMetadata = | ||
metadata && this.options.metadata | ||
const transport = this.options.streamingTransport ?? this.options.transport; | ||
const maybeCombinedMetadata = metadata && this.options.metadata | ||
? new ${BrowserHeaders}({ ...this.options?.metadata.headersMap, ...metadata?.headersMap }) | ||
: metadata || this.options.metadata; | ||
: metadata ?? this.options.metadata; | ||
return new Observable(observer => { | ||
@@ -300,5 +347,5 @@ const upStream = (() => { | ||
request, | ||
transport: this.options.streamingTransport || this.options.transport, | ||
metadata: maybeCombinedMetadata, | ||
debug: this.options.debug, | ||
...(transport !== undefined ? {transport} : {}), | ||
metadata: maybeCombinedMetadata ?? {}, | ||
debug: this.options.debug ?? false, | ||
onMessage: (next) => observer.next(next), | ||
@@ -318,3 +365,10 @@ onEnd: (code: ${grpc}.Code, message: string, trailers: ${grpc}.Metadata) => { | ||
}); | ||
observer.add(() => client.close()); | ||
observer.add(() => { | ||
${!useAbortSignal | ||
? `return client.close();` | ||
: `if (!abortSignal || !abortSignal.aborted) | ||
return client.close();`} | ||
}); | ||
${maybeAbortSignal} | ||
}); | ||
@@ -321,0 +375,0 @@ upStream(); |
@@ -9,4 +9,4 @@ "use strict"; | ||
const utils_1 = require("./utils"); | ||
const CallOptions = (0, ts_poet_1.imp)("CallOptions@nice-grpc-common"); | ||
const CallContext = (0, ts_poet_1.imp)("CallContext@nice-grpc-common"); | ||
const CallOptions = (0, ts_poet_1.imp)("t:CallOptions@nice-grpc-common"); | ||
const CallContext = (0, ts_poet_1.imp)("t:CallContext@nice-grpc-common"); | ||
/** | ||
@@ -25,3 +25,4 @@ * Generates server / client stubs for `nice-grpc` library. | ||
const chunks = []; | ||
chunks.push((0, ts_poet_1.code) `export interface ${(0, ts_poet_1.def)(`${serviceDesc.name}ServiceImplementation`)}<CallContextExt = {}> {`); | ||
const maybeSuffix = serviceDesc.name.endsWith("Service") ? "" : "Service"; | ||
chunks.push((0, ts_poet_1.code) `export interface ${(0, ts_poet_1.def)(`${serviceDesc.name}${maybeSuffix}Implementation`)}<CallContextExt = {}> {`); | ||
for (const [index, methodDesc] of serviceDesc.method.entries()) { | ||
@@ -41,3 +42,3 @@ (0, utils_1.assertInstanceOf)(methodDesc, utils_1.FormattedMethodDescriptor); | ||
chunks.push((0, ts_poet_1.code) ` | ||
${(0, case_1.camelCase)(methodDesc.name)}( | ||
${(0, case_1.uncapitalize)(methodDesc.name)}( | ||
request: AsyncIterable<${inputType}>, | ||
@@ -51,3 +52,3 @@ context: ${CallContext} & CallContextExt, | ||
chunks.push((0, ts_poet_1.code) ` | ||
${(0, case_1.camelCase)(methodDesc.name)}( | ||
${(0, case_1.uncapitalize)(methodDesc.name)}( | ||
request: AsyncIterable<${inputType}>, | ||
@@ -63,3 +64,3 @@ context: ${CallContext} & CallContextExt, | ||
chunks.push((0, ts_poet_1.code) ` | ||
${(0, case_1.camelCase)(methodDesc.name)}( | ||
${(0, case_1.uncapitalize)(methodDesc.name)}( | ||
request: ${inputType}, | ||
@@ -73,3 +74,3 @@ context: ${CallContext} & CallContextExt, | ||
chunks.push((0, ts_poet_1.code) ` | ||
${(0, case_1.camelCase)(methodDesc.name)}( | ||
${(0, case_1.uncapitalize)(methodDesc.name)}( | ||
request: ${inputType}, | ||
@@ -102,3 +103,3 @@ context: ${CallContext} & CallContextExt, | ||
chunks.push((0, ts_poet_1.code) ` | ||
${(0, case_1.camelCase)(methodDesc.name)}( | ||
${(0, case_1.uncapitalize)(methodDesc.name)}( | ||
request: AsyncIterable<${inputType}>, | ||
@@ -112,3 +113,3 @@ options?: ${CallOptions} & CallOptionsExt, | ||
chunks.push((0, ts_poet_1.code) ` | ||
${(0, case_1.camelCase)(methodDesc.name)}( | ||
${(0, case_1.uncapitalize)(methodDesc.name)}( | ||
request: AsyncIterable<${inputType}>, | ||
@@ -124,3 +125,3 @@ options?: ${CallOptions} & CallOptionsExt, | ||
chunks.push((0, ts_poet_1.code) ` | ||
${(0, case_1.camelCase)(methodDesc.name)}( | ||
${(0, case_1.uncapitalize)(methodDesc.name)}( | ||
request: ${inputType}, | ||
@@ -134,3 +135,3 @@ options?: ${CallOptions} & CallOptionsExt, | ||
chunks.push((0, ts_poet_1.code) ` | ||
${(0, case_1.camelCase)(methodDesc.name)}( | ||
${(0, case_1.uncapitalize)(methodDesc.name)}( | ||
request: ${inputType}, | ||
@@ -137,0 +138,0 @@ options?: ${CallOptions} & CallOptionsExt, |
@@ -9,4 +9,2 @@ "use strict"; | ||
const main_1 = require("./main"); | ||
const hash = (0, ts_poet_1.imp)("hash*object-hash"); | ||
const dataloader = (0, ts_poet_1.imp)("DataLoader*dataloader"); | ||
/** | ||
@@ -57,2 +55,5 @@ * Generates an interface for `serviceDesc`. | ||
} | ||
if (options.useAbortSignal) { | ||
params.push((0, ts_poet_1.code) `abortSignal?: AbortSignal`); | ||
} | ||
if (options.addNestjsRestParameter) { | ||
@@ -77,17 +78,21 @@ params.push((0, ts_poet_1.code) `...rest: any`); | ||
exports.generateService = generateService; | ||
function generateRegularRpcMethod(ctx, fileDesc, serviceDesc, methodDesc) { | ||
function generateRegularRpcMethod(ctx, methodDesc) { | ||
(0, utils_1.assertInstanceOf)(methodDesc, utils_1.FormattedMethodDescriptor); | ||
const { options, utils } = ctx; | ||
const { options } = ctx; | ||
const Reader = (0, utils_1.impFile)(ctx.options, "Reader@protobufjs/minimal"); | ||
const rawInputType = (0, types_1.rawRequestType)(ctx, methodDesc); | ||
const rawInputType = (0, types_1.rawRequestType)(ctx, methodDesc, { keepValueType: true }); | ||
const inputType = (0, types_1.requestType)(ctx, methodDesc); | ||
const outputType = (0, types_1.responseType)(ctx, methodDesc); | ||
const rawOutputType = (0, types_1.responseType)(ctx, methodDesc, { keepValueType: true }); | ||
const params = [...(options.context ? [(0, ts_poet_1.code) `ctx: Context`] : []), (0, ts_poet_1.code) `request: ${inputType}`]; | ||
const params = [ | ||
...(options.context ? [(0, ts_poet_1.code) `ctx: Context`] : []), | ||
(0, ts_poet_1.code) `request: ${inputType}`, | ||
...(options.useAbortSignal ? [(0, ts_poet_1.code) `abortSignal?: AbortSignal`] : []), | ||
]; | ||
const maybeCtx = options.context ? "ctx," : ""; | ||
const maybeAbortSignal = options.useAbortSignal ? "abortSignal || undefined," : ""; | ||
let encode = (0, ts_poet_1.code) `${rawInputType}.encode(request).finish()`; | ||
let decode = (0, ts_poet_1.code) `data => ${outputType}.decode(new ${Reader}(data))`; | ||
if (options.useDate && rawOutputType.toString().includes("Timestamp")) { | ||
decode = (0, ts_poet_1.code) `data => ${utils.fromTimestamp}(${rawOutputType}.decode(new ${Reader}(data)))`; | ||
} | ||
let decode = (0, ts_poet_1.code) `data => ${rawOutputType}.decode(${Reader}.create(data))`; | ||
// if (options.useDate && rawOutputType.toString().includes("Timestamp")) { | ||
// decode = code`data => ${utils.fromTimestamp}(${rawOutputType}.decode(${Reader}.create(data)))`; | ||
// } | ||
if (methodDesc.clientStreaming) { | ||
@@ -135,5 +140,6 @@ if (options.useAsyncIterable) { | ||
${maybeCtx} | ||
"${(0, utils_1.maybePrefixPackage)(fileDesc, serviceDesc.name)}", | ||
this.service, | ||
"${methodDesc.name}", | ||
data | ||
data, | ||
${maybeAbortSignal} | ||
); | ||
@@ -147,4 +153,9 @@ return ${decode}; | ||
const chunks = []; | ||
// Determine information about the service. | ||
const { name } = serviceDesc; | ||
const serviceName = (0, utils_1.maybePrefixPackage)(fileDesc, serviceDesc.name); | ||
// Define the service name constant. | ||
const serviceNameConst = `${name}ServiceName`; | ||
chunks.push((0, ts_poet_1.code) `export const ${serviceNameConst} = "${serviceName}";`); | ||
// Define the FooServiceImpl class | ||
const { name } = serviceDesc; | ||
const i = options.context ? `${name}<Context>` : name; | ||
@@ -156,3 +167,5 @@ const t = options.context ? `<${main_1.contextTypeVar}>` : ""; | ||
chunks.push((0, ts_poet_1.code) `private readonly rpc: ${rpcType};`); | ||
chunks.push((0, ts_poet_1.code) `constructor(rpc: ${rpcType}) {`); | ||
chunks.push((0, ts_poet_1.code) `private readonly service: string;`); | ||
chunks.push((0, ts_poet_1.code) `constructor(rpc: ${rpcType}, opts?: {service?: string}) {`); | ||
chunks.push((0, ts_poet_1.code) `this.service = opts?.service || ${serviceNameConst};`); | ||
chunks.push((0, ts_poet_1.code) `this.rpc = rpc;`); | ||
@@ -178,3 +191,3 @@ // Bind each FooService method to the FooServiceImpl class | ||
else { | ||
chunks.push(generateRegularRpcMethod(ctx, fileDesc, serviceDesc, methodDesc)); | ||
chunks.push(generateRegularRpcMethod(ctx, methodDesc)); | ||
} | ||
@@ -187,5 +200,8 @@ } | ||
/** We've found a BatchXxx method, create a synthetic GetXxx method that calls it. */ | ||
function generateBatchingRpcMethod(_ctx, batchMethod) { | ||
function generateBatchingRpcMethod(ctx, batchMethod) { | ||
const { methodDesc, singleMethodName, inputFieldName, inputType, outputFieldName, outputType, mapType, uniqueIdentifier, } = batchMethod; | ||
(0, utils_1.assertInstanceOf)(methodDesc, utils_1.FormattedMethodDescriptor); | ||
const { options } = ctx; | ||
const hash = options.esModuleInterop ? (0, ts_poet_1.imp)("hash=object-hash") : (0, ts_poet_1.imp)("hash*object-hash"); | ||
const dataloader = options.esModuleInterop ? (0, ts_poet_1.imp)("DataLoader=dataloader") : (0, ts_poet_1.imp)("DataLoader*dataloader"); | ||
// Create the `(keys) => ...` lambda we'll pass to the DataLoader constructor | ||
@@ -200,4 +216,4 @@ const lambda = []; | ||
lambda.push((0, ts_poet_1.code) ` | ||
return this.${methodDesc.formattedName}(ctx, request).then(res => { | ||
return ${inputFieldName}.map(key => res.${outputFieldName}[key]) | ||
return this.${methodDesc.formattedName}(ctx, request as any).then(res => { | ||
return ${inputFieldName}.map(key => res.${outputFieldName}[key] ?? ${ctx.utils.fail}()) | ||
}); | ||
@@ -209,3 +225,3 @@ `); | ||
lambda.push((0, ts_poet_1.code) ` | ||
return this.${methodDesc.formattedName}(ctx, request).then(res => res.${outputFieldName}) | ||
return this.${methodDesc.formattedName}(ctx, request as any).then(res => res.${outputFieldName}) | ||
`); | ||
@@ -220,3 +236,3 @@ } | ||
const dl = ctx.getDataLoader("${uniqueIdentifier}", () => { | ||
return new ${dataloader}<${inputType}, ${outputType}>( | ||
return new ${dataloader}<${inputType}, ${outputType}, string>( | ||
${(0, ts_poet_1.joinCode)(lambda)}, | ||
@@ -233,2 +249,5 @@ { cacheKeyFn: ${hash}, ...ctx.rpcDataLoaderOptions } | ||
(0, utils_1.assertInstanceOf)(methodDesc, utils_1.FormattedMethodDescriptor); | ||
const { options } = ctx; | ||
const hash = options.esModuleInterop ? (0, ts_poet_1.imp)("hash=object-hash") : (0, ts_poet_1.imp)("hash*object-hash"); | ||
const dataloader = options.esModuleInterop ? (0, ts_poet_1.imp)("DataLoader=dataloader") : (0, ts_poet_1.imp)("DataLoader*dataloader"); | ||
const inputType = (0, types_1.requestType)(ctx, methodDesc); | ||
@@ -243,3 +262,3 @@ const outputType = (0, types_1.responseType)(ctx, methodDesc); | ||
const response = await this.rpc.request(ctx, "${(0, utils_1.maybePrefixPackage)(fileDesc, serviceDesc.name)}", "${methodDesc.name}", data); | ||
return ${outputType}.decode(new ${Reader}(response)); | ||
return ${outputType}.decode(${Reader}.create(response)); | ||
}); | ||
@@ -255,3 +274,3 @@ return Promise.all(responses); | ||
const dl = ctx.getDataLoader("${uniqueIdentifier}", () => { | ||
return new ${dataloader}<${inputType}, ${outputType}>( | ||
return new ${dataloader}<${inputType}, ${outputType}, string>( | ||
${lambda}, | ||
@@ -281,5 +300,6 @@ { cacheKeyFn: ${hash}, ...ctx.rpcDataLoaderOptions }, | ||
const maybeContextParam = options.context ? "ctx: Context," : ""; | ||
const maybeAbortSignalParam = options.useAbortSignal ? "abortSignal?: AbortSignal," : ""; | ||
const methods = [[(0, ts_poet_1.code) `request`, (0, ts_poet_1.code) `Uint8Array`, (0, ts_poet_1.code) `Promise<Uint8Array>`]]; | ||
if (hasStreamingMethods) { | ||
const observable = (0, types_1.observableType)(ctx); | ||
const observable = (0, types_1.observableType)(ctx, true); | ||
methods.push([(0, ts_poet_1.code) `clientStreamingRequest`, (0, ts_poet_1.code) `${observable}<Uint8Array>`, (0, ts_poet_1.code) `Promise<Uint8Array>`]); | ||
@@ -301,3 +321,4 @@ methods.push([(0, ts_poet_1.code) `serverStreamingRequest`, (0, ts_poet_1.code) `Uint8Array`, (0, ts_poet_1.code) `${observable}<Uint8Array>`]); | ||
method: string, | ||
data: ${method[1]} | ||
data: ${method[1]}, | ||
${maybeAbortSignalParam} | ||
): ${method[2]};`); | ||
@@ -304,0 +325,0 @@ }); |
@@ -6,8 +6,16 @@ "use strict"; | ||
const utils_1 = require("./utils"); | ||
const options_1 = require("./options"); | ||
function generateTypeRegistry(ctx) { | ||
const chunks = []; | ||
chunks.push(generateMessageType(ctx)); | ||
chunks.push((0, ts_poet_1.code) ` | ||
if ((0, options_1.addTypeToMessages)(ctx.options)) { | ||
chunks.push((0, ts_poet_1.code) ` | ||
export type UnknownMessage = {$type: string}; | ||
`); | ||
} | ||
else { | ||
chunks.push((0, ts_poet_1.code) ` | ||
export type UnknownMessage = unknown; | ||
`); | ||
} | ||
chunks.push((0, ts_poet_1.code) ` | ||
@@ -23,3 +31,8 @@ export const messageTypeRegistry = new Map<string, MessageType>(); | ||
chunks.push((0, ts_poet_1.code) `export interface MessageType<Message extends UnknownMessage = UnknownMessage> {`); | ||
chunks.push((0, ts_poet_1.code) `$type: Message['$type'];`); | ||
if ((0, options_1.addTypeToMessages)(ctx.options)) { | ||
chunks.push((0, ts_poet_1.code) `$type: Message['$type'];`); | ||
} | ||
else { | ||
chunks.push((0, ts_poet_1.code) `$type: string;`); | ||
} | ||
if (ctx.options.outputEncodeMethods) { | ||
@@ -26,0 +39,0 @@ const Writer = (0, utils_1.impFile)(ctx.options, "Writer@protobufjs/minimal"); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getTsPoetOpts = exports.optionsFromParameter = exports.defaultOptions = exports.ServiceOption = exports.OneofOption = exports.EnvOption = exports.DateOption = exports.LongOption = void 0; | ||
exports.addTypeToMessages = exports.getTsPoetOpts = exports.optionsFromParameter = exports.defaultOptions = exports.ServiceOption = exports.OneofOption = exports.EnvOption = exports.DateOption = exports.LongOption = void 0; | ||
var LongOption; | ||
@@ -9,3 +9,4 @@ (function (LongOption) { | ||
LongOption["STRING"] = "string"; | ||
})(LongOption = exports.LongOption || (exports.LongOption = {})); | ||
LongOption["BIGINT"] = "bigint"; | ||
})(LongOption || (exports.LongOption = LongOption = {})); | ||
var DateOption; | ||
@@ -16,3 +17,3 @@ (function (DateOption) { | ||
DateOption["TIMESTAMP"] = "timestamp"; | ||
})(DateOption = exports.DateOption || (exports.DateOption = {})); | ||
})(DateOption || (exports.DateOption = DateOption = {})); | ||
var EnvOption; | ||
@@ -23,3 +24,3 @@ (function (EnvOption) { | ||
EnvOption["BOTH"] = "both"; | ||
})(EnvOption = exports.EnvOption || (exports.EnvOption = {})); | ||
})(EnvOption || (exports.EnvOption = EnvOption = {})); | ||
var OneofOption; | ||
@@ -29,3 +30,3 @@ (function (OneofOption) { | ||
OneofOption["UNIONS"] = "unions"; | ||
})(OneofOption = exports.OneofOption || (exports.OneofOption = {})); | ||
})(OneofOption || (exports.OneofOption = OneofOption = {})); | ||
var ServiceOption; | ||
@@ -38,3 +39,3 @@ (function (ServiceOption) { | ||
ServiceOption["NONE"] = "none"; | ||
})(ServiceOption = exports.ServiceOption || (exports.ServiceOption = {})); | ||
})(ServiceOption || (exports.ServiceOption = ServiceOption = {})); | ||
function defaultOptions() { | ||
@@ -56,5 +57,7 @@ return { | ||
outputPartialMethods: true, | ||
outputTypeAnnotations: false, | ||
outputTypeRegistry: false, | ||
stringEnums: false, | ||
constEnums: false, | ||
removeEnumPrefix: false, | ||
enumsAsLiterals: false, | ||
@@ -75,2 +78,3 @@ outputClientImpl: true, | ||
useExactTypes: true, | ||
useAbortSignal: false, | ||
useAsyncIterable: false, | ||
@@ -82,2 +86,8 @@ unknownFields: false, | ||
initializeFieldsAsUndefined: true, | ||
useMapType: false, | ||
useReadonlyTypes: false, | ||
useSnakeTypeName: true, | ||
outputExtensions: false, | ||
outputIndex: false, | ||
M: {}, | ||
}; | ||
@@ -162,2 +172,5 @@ } | ||
} | ||
if (options.outputIndex) { | ||
options.exportCommonSymbols = false; | ||
} | ||
return options; | ||
@@ -168,7 +181,24 @@ } | ||
function parseParameter(parameter) { | ||
const options = {}; | ||
const pairs = parameter.split(",").map((s) => s.split("=")); | ||
pairs.forEach(([key, _value]) => { | ||
const value = _value === "true" ? true : _value === "false" ? false : _value; | ||
if (options[key]) { | ||
const options = { M: {} }; | ||
parameter.split(",").forEach((param) => { | ||
// same as protoc-gen-go https://github.com/protocolbuffers/protobuf-go/blob/bf9455640daabb98c93b5b5e71628f3f813d57bb/compiler/protogen/protogen.go#L168-L171 | ||
const optionSeparatorPos = param.indexOf("="); | ||
const key = param.substring(0, optionSeparatorPos); | ||
const value = parseParamValue(param.substring(optionSeparatorPos + 1)); | ||
if (key.charAt(0) === "M") { | ||
if (typeof value !== "string") { | ||
console.warn(`ignoring invalid M option: '${param}'`); | ||
} | ||
else { | ||
const mKey = key.substring(1); | ||
if (options.M[mKey]) { | ||
console.warn(`received conflicting M options: '${param}' will override 'M${mKey}=${options.M[mKey]}'`); | ||
} | ||
if (param.endsWith(".ts")) { | ||
console.warn(`received M option '${param}' ending in '.ts' this is usually a mistake`); | ||
} | ||
options.M[mKey] = value; | ||
} | ||
} | ||
else if (options[key]) { | ||
options[key] = [options[key], value]; | ||
@@ -182,10 +212,20 @@ } | ||
} | ||
function getTsPoetOpts(_options) { | ||
const imports = ["protobufjs/minimal" + _options.importSuffix]; | ||
function parseParamValue(value) { | ||
return value === "true" ? true : value === "false" ? false : value; | ||
} | ||
function getTsPoetOpts(options) { | ||
const { importSuffix, esModuleInterop } = options; | ||
const pbjs = "protobufjs/minimal" + importSuffix; | ||
return { | ||
prefix: `/* eslint-disable */`, | ||
dprintOptions: { preferSingleLine: true, lineWidth: 120 }, | ||
...(_options.esModuleInterop ? { forceDefaultImport: imports } : { forceModuleImport: imports }), | ||
forceRequireImport: esModuleInterop ? [] : ["long"], | ||
forceDefaultImport: esModuleInterop ? [pbjs] : [], | ||
forceModuleImport: esModuleInterop ? [] : [pbjs], | ||
}; | ||
} | ||
exports.getTsPoetOpts = getTsPoetOpts; | ||
function addTypeToMessages(options) { | ||
return ((options.outputTypeAnnotations || options.outputTypeRegistry) && options.outputTypeAnnotations !== "static-only"); | ||
} | ||
exports.addTypeToMessages = addTypeToMessages; |
@@ -20,3 +20,24 @@ "use strict"; | ||
const ctx = { typeMap, options, utils }; | ||
const filesToGenerate = options.emitImportedFiles ? request.protoFile : (0, utils_1.protoFilesToGenerate)(request); | ||
let filesToGenerate; | ||
if (options.emitImportedFiles) { | ||
const fileSet = new Set(); | ||
function addFilesUnlessAliased(filenames) { | ||
filenames | ||
.filter((name) => !options.M[name]) | ||
.forEach((name) => { | ||
if (fileSet.has(name)) | ||
return; | ||
fileSet.add(name); | ||
const file = request.protoFile.find((file) => file.name === name); | ||
if (file && file.dependency.length > 0) { | ||
addFilesUnlessAliased(file.dependency); | ||
} | ||
}); | ||
} | ||
addFilesUnlessAliased(request.fileToGenerate); | ||
filesToGenerate = request.protoFile.filter((file) => fileSet.has(file.name)); | ||
} | ||
else { | ||
filesToGenerate = (0, utils_1.protoFilesToGenerate)(request).filter((file) => !options.M[file.name]); | ||
} | ||
const files = await Promise.all(filesToGenerate.map(async (file) => { | ||
@@ -35,2 +56,8 @@ const [path, code] = (0, main_1.generateFile)(ctx, file); | ||
} | ||
if (options.outputIndex) { | ||
for (const [path, code] of (0, utils_1.generateIndexFiles)(filesToGenerate, options)) { | ||
const content = code.toString({ ...(0, options_1.getTsPoetOpts)(options), path }); | ||
files.push({ name: path, content }); | ||
} | ||
} | ||
const response = ts_proto_descriptors_1.CodeGeneratorResponse.fromPartial({ | ||
@@ -37,0 +64,0 @@ file: files, |
@@ -81,4 +81,4 @@ "use strict"; | ||
if (fileDesc.options) { | ||
fileOptions = encodedOptionsToOptions(ctx, ".google.protobuf.FileOptions", fileDesc.options["_unknownFields"]); | ||
delete fileDesc.options["_unknownFields"]; | ||
fileOptions = encodedOptionsToOptions(ctx, ".google.protobuf.FileOptions", fileDesc.options._unknownFields); | ||
delete fileDesc.options._unknownFields; | ||
} | ||
@@ -97,4 +97,4 @@ const messagesOptions = []; | ||
if (method.options) { | ||
const methodOptions = encodedOptionsToOptions(ctx, ".google.protobuf.MethodOptions", method.options["_unknownFields"]); | ||
delete method.options["_unknownFields"]; | ||
const methodOptions = encodedOptionsToOptions(ctx, ".google.protobuf.MethodOptions", method.options._unknownFields); | ||
delete method.options._unknownFields; | ||
if (methodOptions) { | ||
@@ -107,4 +107,4 @@ methodsOptions.push((0, ts_poet_1.code) `'${method.name}': ${methodOptions}`); | ||
if (service.options) { | ||
serviceOptions = encodedOptionsToOptions(ctx, ".google.protobuf.ServiceOptions", service.options["_unknownFields"]); | ||
delete service.options["_unknownFields"]; | ||
serviceOptions = encodedOptionsToOptions(ctx, ".google.protobuf.ServiceOptions", service.options._unknownFields); | ||
delete service.options._unknownFields; | ||
} | ||
@@ -125,4 +125,4 @@ if (methodsOptions.length > 0 || serviceOptions) { | ||
if (value.options) { | ||
const valueOptions = encodedOptionsToOptions(ctx, ".google.protobuf.EnumValueOptions", value.options["_unknownFields"]); | ||
delete value.options["_unknownFields"]; | ||
const valueOptions = encodedOptionsToOptions(ctx, ".google.protobuf.EnumValueOptions", value.options._unknownFields); | ||
delete value.options._unknownFields; | ||
if (valueOptions) { | ||
@@ -135,4 +135,4 @@ valuesOptions.push((0, ts_poet_1.code) `'${value.name}': ${valueOptions}`); | ||
if (Enum.options) { | ||
enumOptions = encodedOptionsToOptions(ctx, ".google.protobuf.EnumOptions", Enum.options["_unknownFields"]); | ||
delete Enum.options["_unknownFields"]; | ||
enumOptions = encodedOptionsToOptions(ctx, ".google.protobuf.EnumOptions", Enum.options._unknownFields); | ||
delete Enum.options._unknownFields; | ||
} | ||
@@ -193,3 +193,4 @@ if (valuesOptions.length > 0 || enumOptions) { | ||
const resultOptions = []; | ||
for (const [key, value] of Object.entries(encodedOptions)) { | ||
for (const key in encodedOptions) { | ||
const value = encodedOptions[key]; | ||
const extension = extensionCache[extendee][parseInt(key, 10) >>> 3]; | ||
@@ -207,4 +208,4 @@ resultOptions.push(getExtensionValue(ctx, extension, value)); | ||
if (field.options) { | ||
const fieldOptions = encodedOptionsToOptions(ctx, ".google.protobuf.FieldOptions", field.options["_unknownFields"]); | ||
delete field.options["_unknownFields"]; | ||
const fieldOptions = encodedOptionsToOptions(ctx, ".google.protobuf.FieldOptions", field.options._unknownFields); | ||
delete field.options._unknownFields; | ||
if (fieldOptions) { | ||
@@ -218,4 +219,4 @@ fieldsOptions.push((0, ts_poet_1.code) `'${field.name}': ${fieldOptions}`); | ||
if (oneOf.options) { | ||
const oneOfOptions = encodedOptionsToOptions(ctx, ".google.protobuf.OneofOptions", oneOf.options["_unknownFields"]); | ||
delete oneOf.options["_unknownFields"]; | ||
const oneOfOptions = encodedOptionsToOptions(ctx, ".google.protobuf.OneofOptions", oneOf.options._unknownFields); | ||
delete oneOf.options._unknownFields; | ||
if (oneOfOptions) { | ||
@@ -237,4 +238,4 @@ oneOfsOptions.push((0, ts_poet_1.code) `'${oneOf.name}': ${oneOfOptions}`); | ||
if (message.options) { | ||
messageOptions = encodedOptionsToOptions(ctx, ".google.protobuf.MessageOptions", message.options["_unknownFields"]); | ||
delete message.options["_unknownFields"]; | ||
messageOptions = encodedOptionsToOptions(ctx, ".google.protobuf.MessageOptions", message.options._unknownFields); | ||
delete message.options._unknownFields; | ||
} | ||
@@ -241,0 +242,0 @@ if (fieldsOptions.length > 0 || oneOfsOptions.length > 0 || nestedOptions.length > 0 || messageOptions) { |
@@ -48,7 +48,2 @@ "use strict"; | ||
class SourceInfo { | ||
// Private | ||
constructor(sourceCode, selfDescription) { | ||
this.sourceCode = sourceCode; | ||
this.selfDescription = selfDescription; | ||
} | ||
/** Returns an empty SourceInfo */ | ||
@@ -72,2 +67,7 @@ static empty() { | ||
} | ||
// Private | ||
constructor(sourceCode, selfDescription) { | ||
this.sourceCode = sourceCode; | ||
this.selfDescription = selfDescription; | ||
} | ||
/** Returns the code span [start line, start column, end line] */ | ||
@@ -74,0 +74,0 @@ get span() { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.detectBatchMethod = exports.responsePromiseOrObservable = exports.responseObservable = exports.responsePromise = exports.responseType = exports.requestType = exports.observableType = exports.rawRequestType = exports.detectMapType = exports.toTypeName = exports.getEnumMethod = exports.messageToTypeName = exports.wrapperTypeName = exports.valueTypeName = exports.isEmptyType = exports.isLongValueType = exports.isStructTypeName = exports.isStructType = exports.isListValueTypeName = exports.isListValueType = exports.isFieldMaskTypeName = exports.isFieldMaskType = exports.isBytesValueType = exports.isAnyValueTypeName = exports.isAnyValueType = exports.isValueType = exports.isTimestamp = exports.isObjectId = exports.isMapType = exports.isWholeNumber = exports.isLong = exports.isRepeated = exports.isWithinOneOfThatShouldBeUnion = exports.isWithinOneOf = exports.isEnum = exports.isMessage = exports.isBytes = exports.isPrimitive = exports.isOptionalProperty = exports.isScalar = exports.createTypeMap = exports.notDefaultCheck = exports.defaultValue = exports.packedType = exports.toReaderCall = exports.basicTypeName = exports.basicLongWireType = exports.basicWireType = void 0; | ||
exports.detectBatchMethod = exports.responsePromiseOrObservable = exports.responseObservable = exports.responsePromise = exports.responseType = exports.requestType = exports.observableType = exports.rawRequestType = exports.detectMapType = exports.shouldGenerateJSMapType = exports.toTypeName = exports.getEnumMethod = exports.messageToTypeName = exports.wrapperTypeName = exports.valueTypeName = exports.isEmptyType = exports.isLongValueType = exports.isStructTypeName = exports.isStructType = exports.isListValueTypeName = exports.isListValueType = exports.isFieldMaskTypeName = exports.isFieldMaskType = exports.isBytesValueType = exports.isAnyValueTypeName = exports.isAnyValueType = exports.isValueType = exports.isTimestamp = exports.isObjectId = exports.isMapType = exports.isWholeNumber = exports.isLong = exports.isRepeated = exports.isWithinOneOfThatShouldBeUnion = exports.isWithinOneOf = exports.isEnum = exports.isMessage = exports.isBytes = exports.isPrimitive = exports.isOptionalProperty = exports.isScalar = exports.createTypeMap = exports.notDefaultCheck = exports.defaultValue = exports.packedType = exports.toReaderCall = exports.basicTypeName = exports.basicLongWireType = exports.basicWireType = void 0; | ||
const ts_proto_descriptors_1 = require("ts-proto-descriptors"); | ||
@@ -11,2 +11,3 @@ const ts_poet_1 = require("ts-poet"); | ||
const case_1 = require("./case"); | ||
const enums_1 = require("./enums"); | ||
/** Based on https://github.com/dcodeIO/protobuf.js/blob/master/src/types.js#L37. */ | ||
@@ -38,3 +39,6 @@ function basicWireType(type) { | ||
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_BYTES: | ||
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_MESSAGE: | ||
return 2; | ||
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_GROUP: | ||
return 3; | ||
default: | ||
@@ -90,2 +94,3 @@ throw new Error("Invalid type " + type); | ||
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_MESSAGE: | ||
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_GROUP: | ||
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_ENUM: | ||
@@ -181,7 +186,8 @@ return messageToTypeName(ctx, field.typeName, { ...typeOptions, repeated: isRepeated(field) }); | ||
// and I believe the semantics of those in the proto2 world are generally undefined. | ||
const enumProto = typeMap.get(field.typeName)[2]; | ||
const typeInfo = typeMap.get(field.typeName); | ||
const enumProto = typeInfo[2]; | ||
const zerothValue = enumProto.value.find((v) => v.number === 0) || enumProto.value[0]; | ||
if (options.stringEnums) { | ||
const enumType = messageToTypeName(ctx, field.typeName); | ||
return (0, ts_poet_1.code) `${enumType}.${zerothValue.name}`; | ||
return (0, ts_poet_1.code) `${enumType}.${(0, enums_1.getMemberName)(ctx, enumProto, zerothValue)}`; | ||
} | ||
@@ -199,2 +205,5 @@ else { | ||
} | ||
else if (options.forceLong === options_1.LongOption.BIGINT) { | ||
return 'BigInt("0")'; | ||
} | ||
else { | ||
@@ -212,2 +221,5 @@ return 0; | ||
} | ||
else if (options.forceLong === options_1.LongOption.BIGINT) { | ||
return 'BigInt("0")'; | ||
} | ||
else { | ||
@@ -225,5 +237,6 @@ return 0; | ||
else { | ||
return "new Uint8Array()"; | ||
return "new Uint8Array(0)"; | ||
} | ||
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_MESSAGE: | ||
case ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_GROUP: | ||
default: | ||
@@ -253,7 +266,9 @@ return "undefined"; | ||
// and I believe the semantics of those in the proto2 world are generally undefined. | ||
const enumProto = typeMap.get(field.typeName)[2]; | ||
const typeInfo = typeMap.get(field.typeName); | ||
const enumProto = typeInfo[2]; | ||
const zerothValue = enumProto.value.find((v) => v.number === 0) || enumProto.value[0]; | ||
if (options.stringEnums) { | ||
const enumType = messageToTypeName(ctx, field.typeName); | ||
return (0, ts_poet_1.code) `${maybeNotUndefinedAnd} ${place} !== ${enumType}.${zerothValue.name}`; | ||
const enumValue = (0, enums_1.getMemberName)(ctx, enumProto, zerothValue); | ||
return (0, ts_poet_1.code) `${maybeNotUndefinedAnd} ${place} !== ${enumType}.${enumValue}`; | ||
} | ||
@@ -274,2 +289,5 @@ else { | ||
} | ||
else if (options.forceLong === options_1.LongOption.BIGINT) { | ||
return (0, ts_poet_1.code) `${maybeNotUndefinedAnd} ${place} !== BigInt("0")`; | ||
} | ||
else { | ||
@@ -332,2 +350,3 @@ return (0, ts_poet_1.code) `${maybeNotUndefinedAnd} ${place} !== 0`; | ||
// always be present. | ||
// OneOf fields are always optional, whenever oneof=unions option not in use. | ||
function isOptionalProperty(field, messageOptions, options) { | ||
@@ -338,2 +357,4 @@ const optionalMessages = options.useOptionals === true || options.useOptionals === "messages" || options.useOptionals === "all"; | ||
(optionalAll && !(messageOptions === null || messageOptions === void 0 ? void 0 : messageOptions.mapEntry)) || | ||
// don't bother verifying that oneof is not union. union oneofs generate their own properties. | ||
isWithinOneOf(field) || | ||
field.proto3Optional); | ||
@@ -352,3 +373,3 @@ } | ||
function isMessage(field) { | ||
return field.type === ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_MESSAGE; | ||
return field.type === ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_MESSAGE || field.type === ts_proto_descriptors_1.FieldDescriptorProto_Type.TYPE_GROUP; | ||
} | ||
@@ -472,9 +493,13 @@ exports.isMessage = isMessage; | ||
case ".google.protobuf.ListValue": | ||
return (0, ts_poet_1.code) `Array<any>`; | ||
return ctx.options.useReadonlyTypes ? (0, ts_poet_1.code) `ReadonlyArray<any>` : (0, ts_poet_1.code) `Array<any>`; | ||
case ".google.protobuf.Value": | ||
return (0, ts_poet_1.code) `any`; | ||
case ".google.protobuf.Struct": | ||
return (0, ts_poet_1.code) `{[key: string]: any}`; | ||
return ctx.options.useReadonlyTypes ? (0, ts_poet_1.code) `{readonly [key: string]: any}` : (0, ts_poet_1.code) `{[key: string]: any}`; | ||
case ".google.protobuf.FieldMask": | ||
return ctx.options.useJsonWireFormat ? (0, ts_poet_1.code) `string` : (0, ts_poet_1.code) `string[]`; | ||
return ctx.options.useJsonWireFormat | ||
? (0, ts_poet_1.code) `string` | ||
: ctx.options.useReadonlyTypes | ||
? (0, ts_poet_1.code) `readonly string[]` | ||
: (0, ts_poet_1.code) `string[]`; | ||
case ".google.protobuf.Duration": | ||
@@ -517,2 +542,5 @@ return ctx.options.useJsonWireFormat ? (0, ts_poet_1.code) `string` : undefined; | ||
} | ||
else if (options.forceLong === options_1.LongOption.BIGINT) { | ||
return (0, ts_poet_1.code) `bigint`; | ||
} | ||
else { | ||
@@ -524,2 +552,3 @@ return (0, ts_poet_1.code) `number`; | ||
function messageToTypeName(ctx, protoType, typeOptions = {}) { | ||
var _a; | ||
const { options, typeMap } = ctx; | ||
@@ -530,10 +559,5 @@ // Watch for the wrapper types `.google.protobuf.*Value`. If we're mapping | ||
// - If the field is repeated, values cannot be undefined. | ||
// - If useOptionals='messages' or useOptionals='all', all non-scalar types | ||
// are already optional properties, so there's no need for that union. | ||
let valueType = valueTypeName(ctx, protoType); | ||
if (!typeOptions.keepValueType && valueType) { | ||
if (!!typeOptions.repeated || | ||
options.useOptionals === true || | ||
options.useOptionals === "messages" || | ||
options.useOptionals === "all") { | ||
if ((_a = typeOptions.repeated) !== null && _a !== void 0 ? _a : false) { | ||
return valueType; | ||
@@ -566,15 +590,27 @@ } | ||
const [module, type] = toModuleAndType(ctx.typeMap, enumProtoType); | ||
return (0, utils_1.impProto)(ctx.options, module, `${(0, case_1.camelCase)(type)}${methodSuffix}`); | ||
return (0, utils_1.impProto)(ctx.options, module, `${(0, case_1.uncapitalize)(type)}${methodSuffix}`); | ||
} | ||
exports.getEnumMethod = getEnumMethod; | ||
/** Return the TypeName for any field (primitive/message/etc.) as exposed in the interface. */ | ||
function toTypeName(ctx, messageDesc, field) { | ||
function toTypeName(ctx, messageDesc, field, ensureOptional = false) { | ||
function finalize(type, isOptional) { | ||
if (isOptional) { | ||
return (0, ts_poet_1.code) `${type} | undefined`; | ||
} | ||
return type; | ||
} | ||
let type = basicTypeName(ctx, field, { keepValueType: false }); | ||
if (isRepeated(field)) { | ||
const mapType = detectMapType(ctx, messageDesc, field); | ||
const mapType = messageDesc ? detectMapType(ctx, messageDesc, field) : false; | ||
if (mapType) { | ||
const { keyType, valueType } = mapType; | ||
return (0, ts_poet_1.code) `{ [key: ${keyType} ]: ${valueType} }`; | ||
if (shouldGenerateJSMapType(ctx, messageDesc, field)) { | ||
return finalize((0, ts_poet_1.code) `Map<${keyType}, ${valueType}>`, ensureOptional); | ||
} | ||
return finalize((0, ts_poet_1.code) `{ [key: ${keyType} ]: ${valueType} }`, ensureOptional); | ||
} | ||
return (0, ts_poet_1.code) `${type}[]`; | ||
if (ctx.options.useReadonlyTypes) { | ||
return finalize((0, ts_poet_1.code) `readonly ${type}[]`, ensureOptional); | ||
} | ||
return finalize((0, ts_poet_1.code) `${type}[]`, ensureOptional); | ||
} | ||
@@ -584,3 +620,3 @@ if (isValueType(ctx, field)) { | ||
// in messageToTypeName, so no need to consider them for that here. | ||
return type; | ||
return finalize(type, false); | ||
} | ||
@@ -599,12 +635,33 @@ // By default (useOptionals='none', oneof=properties), non-scalar fields | ||
const { options } = ctx; | ||
if ((!isWithinOneOf(field) && | ||
return finalize(type, (!isWithinOneOf(field) && | ||
isMessage(field) && | ||
(options.useOptionals === false || options.useOptionals === "none")) || | ||
(isWithinOneOf(field) && options.oneof === options_1.OneofOption.PROPERTIES) || | ||
(isWithinOneOf(field) && field.proto3Optional)) { | ||
return (0, ts_poet_1.code) `${type} | undefined`; | ||
(isWithinOneOf(field) && field.proto3Optional) || | ||
ensureOptional); | ||
} | ||
exports.toTypeName = toTypeName; | ||
/** | ||
* For a protobuf map field, if the generated code should use the javascript Map type. | ||
* | ||
* If the type of a protobuf map key corresponds to the Long type, we always use the Map type. This avoids generating | ||
* invalid code such as below (using Long as key of a javascript object): | ||
* | ||
* export interface Foo { | ||
* bar: { [key: Long]: Long } | ||
* } | ||
* | ||
* See https://github.com/stephenh/ts-proto/issues/708 for more details. | ||
*/ | ||
function shouldGenerateJSMapType(ctx, message, field) { | ||
if (ctx.options.useMapType) { | ||
return true; | ||
} | ||
return type; | ||
const mapType = detectMapType(ctx, message, field); | ||
if (!mapType) { | ||
return false; | ||
} | ||
return isLong(mapType.keyField) && ctx.options.forceLong === options_1.LongOption.LONG; | ||
} | ||
exports.toTypeName = toTypeName; | ||
exports.shouldGenerateJSMapType = shouldGenerateJSMapType; | ||
function detectMapType(ctx, messageDesc, fieldDesc) { | ||
@@ -627,15 +684,20 @@ var _a; | ||
exports.detectMapType = detectMapType; | ||
function rawRequestType(ctx, methodDesc) { | ||
return messageToTypeName(ctx, methodDesc.inputType); | ||
function rawRequestType(ctx, methodDesc, typeOptions = {}) { | ||
return messageToTypeName(ctx, methodDesc.inputType, typeOptions); | ||
} | ||
exports.rawRequestType = rawRequestType; | ||
function observableType(ctx) { | ||
function observableType(ctx, asType = false) { | ||
if (ctx.options.useAsyncIterable) { | ||
return (0, ts_poet_1.code) `AsyncIterable`; | ||
} | ||
return (0, ts_poet_1.code) `${(0, ts_poet_1.imp)("Observable@rxjs")}`; | ||
else if (asType) { | ||
return (0, ts_poet_1.code) `${(0, ts_poet_1.imp)("t:Observable@rxjs")}`; | ||
} | ||
else { | ||
return (0, ts_poet_1.code) `${(0, ts_poet_1.imp)("Observable@rxjs")}`; | ||
} | ||
} | ||
exports.observableType = observableType; | ||
function requestType(ctx, methodDesc, partial = false) { | ||
let typeName = rawRequestType(ctx, methodDesc); | ||
let typeName = rawRequestType(ctx, methodDesc, { keepValueType: true }); | ||
if (partial) { | ||
@@ -651,11 +713,11 @@ typeName = (0, ts_poet_1.code) `${ctx.utils.DeepPartial}<${typeName}>`; | ||
function responseType(ctx, methodDesc, typeOptions = {}) { | ||
return messageToTypeName(ctx, methodDesc.outputType, typeOptions); | ||
return messageToTypeName(ctx, methodDesc.outputType, { keepValueType: true }); | ||
} | ||
exports.responseType = responseType; | ||
function responsePromise(ctx, methodDesc) { | ||
return (0, ts_poet_1.code) `Promise<${responseType(ctx, methodDesc)}>`; | ||
return (0, ts_poet_1.code) `Promise<${responseType(ctx, methodDesc, { keepValueType: true })}>`; | ||
} | ||
exports.responsePromise = responsePromise; | ||
function responseObservable(ctx, methodDesc) { | ||
return (0, ts_poet_1.code) `${observableType(ctx)}<${responseType(ctx, methodDesc)}>`; | ||
return (0, ts_poet_1.code) `${observableType(ctx)}<${responseType(ctx, methodDesc, { keepValueType: true })}>`; | ||
} | ||
@@ -662,0 +724,0 @@ exports.responseObservable = responseObservable; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.impProto = exports.impFile = exports.getPropertyAccessor = exports.getFieldJsonName = exports.FormattedMethodDescriptor = exports.assertInstanceOf = exports.maybePrefixPackage = exports.prefixDisableLinter = exports.maybeAddComment = exports.upperFirst = exports.lowerFirst = exports.singular = exports.fail = exports.readToBuffer = exports.protoFilesToGenerate = void 0; | ||
exports.impProto = exports.impFile = exports.getPropertyAccessor = exports.getFieldJsonName = exports.FormattedMethodDescriptor = exports.assertInstanceOf = exports.maybePrefixPackage = exports.prefixDisableLinter = exports.maybeAddComment = exports.upperFirst = exports.lowerFirst = exports.singular = exports.fail = exports.readToBuffer = exports.generateIndexFiles = exports.protoFilesToGenerate = void 0; | ||
const path = require("path"); | ||
const ts_poet_1 = require("ts-poet"); | ||
@@ -11,2 +12,36 @@ const options_1 = require("./options"); | ||
exports.protoFilesToGenerate = protoFilesToGenerate; | ||
function generateIndexFiles(files, options) { | ||
const packageTree = { | ||
index: "index.ts", | ||
leaves: {}, | ||
chunks: [], | ||
}; | ||
for (const { name, package: pkg } of files) { | ||
const moduleName = name.replace(".proto", options.fileSuffix); | ||
const pkgParts = pkg.length > 0 ? pkg.split(".") : []; | ||
const branch = pkgParts.reduce((branch, part, i) => { | ||
if (!(part in branch.leaves)) { | ||
const prePkgParts = pkgParts.slice(0, i + 1); | ||
const index = `index.${prePkgParts.join(".")}.ts`; | ||
branch.chunks.push((0, ts_poet_1.code) `export * as ${part} from "./${path.basename(index, ".ts")}";`); | ||
branch.leaves[part] = { | ||
index, | ||
leaves: {}, | ||
chunks: [], | ||
}; | ||
} | ||
return branch.leaves[part]; | ||
}, packageTree); | ||
branch.chunks.push((0, ts_poet_1.code) `export * from "./${moduleName}";`); | ||
} | ||
const indexFiles = []; | ||
let branches = [packageTree]; | ||
let currentBranch; | ||
while ((currentBranch = branches.pop())) { | ||
indexFiles.push([currentBranch.index, (0, ts_poet_1.joinCode)(currentBranch.chunks)]); | ||
branches.push(...Object.values(currentBranch.leaves)); | ||
} | ||
return indexFiles; | ||
} | ||
exports.generateIndexFiles = generateIndexFiles; | ||
function readToBuffer(stream) { | ||
@@ -109,2 +144,9 @@ return new Promise((resolve) => { | ||
class FormattedMethodDescriptor { | ||
/** | ||
* The name of this method with formatting applied according to the `Options` object passed to the constructor. | ||
* Automatically updates to any changes to the `Options` or `name` of this object | ||
*/ | ||
get formattedName() { | ||
return FormattedMethodDescriptor.formatName(this.name, this.ctxOptions); | ||
} | ||
constructor(src, options) { | ||
@@ -121,9 +163,2 @@ this.ctxOptions = options; | ||
/** | ||
* The name of this method with formatting applied according to the `Options` object passed to the constructor. | ||
* Automatically updates to any changes to the `Options` or `name` of this object | ||
*/ | ||
get formattedName() { | ||
return FormattedMethodDescriptor.formatName(this.name, this.ctxOptions); | ||
} | ||
/** | ||
* Retrieve the source `MethodDescriptorProto` used to construct this object | ||
@@ -144,3 +179,4 @@ * @returns The source `MethodDescriptorProto` used to construct this object | ||
if (options.lowerCaseServiceMethods || options.outputServices.includes(options_1.ServiceOption.GRPC)) { | ||
result = (0, case_1.camelCase)(result); | ||
if (options.snakeToCamel) | ||
result = (0, case_1.camelCaseGrpc)(result); | ||
} | ||
@@ -185,10 +221,9 @@ return result; | ||
function impProto(options, module, type) { | ||
const importString = `${type}@./${module}${options.fileSuffix}${options.importSuffix}`; | ||
if (options.onlyTypes) { | ||
return (0, ts_poet_1.imp)("t:" + importString); | ||
const prefix = options.onlyTypes ? "t:" : ""; | ||
const protoFile = `${module}.proto`; | ||
if (options.M[protoFile]) { | ||
return (0, ts_poet_1.imp)(`${prefix}${type}@${options.M[protoFile]}`); | ||
} | ||
else { | ||
return (0, ts_poet_1.imp)(importString); | ||
} | ||
return (0, ts_poet_1.imp)(`${prefix}${type}@./${module}${options.fileSuffix}${options.importSuffix}`); | ||
} | ||
exports.impProto = impProto; |
@@ -26,3 +26,4 @@ "use strict"; | ||
messageFn(tsFullName, message, nestedSourceInfo, protoFullName); | ||
visit(message, nestedSourceInfo, messageFn, options, enumFn, tsFullName + "_", protoFullName + "."); | ||
const delim = options.useSnakeTypeName ? "_" : ""; | ||
visit(message, nestedSourceInfo, messageFn, options, enumFn, tsFullName + delim, protoFullName + "."); | ||
}); | ||
@@ -29,0 +30,0 @@ } |
{ | ||
"name": "ts-proto", | ||
"version": "1.125.0", | ||
"version": "1.156.7", | ||
"description": "", | ||
@@ -13,3 +13,2 @@ "main": "build/plugin.js", | ||
"build:test": "yarn proto2bin && yarn proto2pbjs && yarn bin2ts", | ||
"build:test:local": "yarn proto2bin:local && yarn proto2pbjs:local && yarn bin2ts:local", | ||
"prepare": "yarn build", | ||
@@ -20,6 +19,4 @@ "proto2bin": "docker compose run --rm protoc update-bins.sh", | ||
"bin2ts": "docker compose run --rm protoc codegen.sh", | ||
"proto2bin:local": "integration/update-bins.sh", | ||
"proto2pbjs:local": "integration/pbjs.sh", | ||
"bin2ts:local": "integration/codegen.sh", | ||
"test": "yarn jest -c jest.config.js --maxWorkers=2", | ||
"tsc:check": "./tsc-check.sh tsconfig.json tests/tsconfig.json integration/tsconfig.json integration/tsconfig.proto.json protos/tsconfig.json", | ||
"format": "prettier --write {src,tests}/**/*.ts integration/*.ts", | ||
@@ -37,40 +34,44 @@ "format:check": "prettier --list-different {src,tests}/**/*.ts", | ||
"devDependencies": { | ||
"@grpc/grpc-js": "^1.2.12", | ||
"@grpc/proto-loader": "^0.5.6", | ||
"@improbable-eng/grpc-web": "^0.14.0", | ||
"@improbable-eng/grpc-web-node-http-transport": "^0.14.0", | ||
"@nestjs/common": "^8.2.2", | ||
"@nestjs/core": "^8.2.2", | ||
"@nestjs/microservices": "^8.2.2", | ||
"@semantic-release/changelog": "^5.0.1", | ||
"@semantic-release/commit-analyzer": "^8.0.1", | ||
"@grpc/grpc-js": "^1.8.17", | ||
"@grpc/proto-loader": "^0.7.8", | ||
"@improbable-eng/grpc-web": "^0.14.1", | ||
"@improbable-eng/grpc-web-node-http-transport": "^0.14.1", | ||
"@nestjs/common": "^9.4.3", | ||
"@nestjs/core": "^9.4.3", | ||
"@nestjs/microservices": "^9.4.3", | ||
"@semantic-release/changelog": "^6.0.3", | ||
"@semantic-release/commit-analyzer": "^10.0.1", | ||
"@semantic-release/exec": "^6.0.3", | ||
"@semantic-release/git": "^9.0.0", | ||
"@semantic-release/github": "^7.2.0", | ||
"@semantic-release/npm": "^7.1.0", | ||
"@semantic-release/release-notes-generator": "^9.0.2", | ||
"@types/jest": "^26.0.22", | ||
"@types/node": "^14.14.37", | ||
"chokidar": "^3.5.2", | ||
"jest": "^28.1.2", | ||
"@semantic-release/git": "^10.0.1", | ||
"@semantic-release/github": "^9.0.3", | ||
"@semantic-release/npm": "^10.0.4", | ||
"@semantic-release/release-notes-generator": "^11.0.4", | ||
"@tsconfig/strictest": "^2.0.1", | ||
"@types/jest": "^29.5.3", | ||
"@types/node": "^16.18.38", | ||
"@types/object-hash": "^3.0.2", | ||
"chokidar": "^3.5.3", | ||
"dataloader": "^2.2.2", | ||
"jest": "^29.6.1", | ||
"jest-ts-webcompat-resolver": "^1.0.0", | ||
"mongodb": "^4.3.0", | ||
"nice-grpc": "^1.1.1", | ||
"prettier": "^2.7.1", | ||
"mongodb": "^5.7.0", | ||
"nice-grpc": "^2.1.4", | ||
"object-hash": "^3.0.0", | ||
"prettier": "^2.8.8", | ||
"protobufjs-cli": "^1.1.1", | ||
"reflect-metadata": "^0.1.13", | ||
"rxjs": "^7.4.0", | ||
"semantic-release": "^19.0.3", | ||
"ts-jest": "^28.0.5", | ||
"tsx": "^3.8.2", | ||
"typescript": "^4.7.4", | ||
"uglify-js": "^3.16.1" | ||
"rxjs": "^7.8.1", | ||
"semantic-release": "^21.0.7", | ||
"ts-jest": "^29.1.1", | ||
"tsx": "^3.12.7", | ||
"typescript": "^5.1.6", | ||
"uglify-js": "^3.17.4" | ||
}, | ||
"dependencies": { | ||
"@types/object-hash": "^1.3.0", | ||
"dataloader": "^1.4.0", | ||
"object-hash": "^1.3.1", | ||
"protobufjs": "^6.11.3", | ||
"ts-poet": "^6.1.0", | ||
"ts-proto-descriptors": "1.7.1" | ||
} | ||
"case-anything": "^2.1.13", | ||
"protobufjs": "^7.2.4", | ||
"ts-poet": "^6.5.0", | ||
"ts-proto-descriptors": "1.15.0" | ||
}, | ||
"packageManager": "yarn@3.6.0" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
324683
1.99%4
-33.33%5658
22.47%912
8.19%34
17.24%+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated