ts-proto 1.117.0 → 1.119.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ # [1.119.0](https://github.com/stephenh/ts-proto/compare/v1.118.0...v1.119.0) (2022-07-21)
2
+
3
+
4
+ ### Features
5
+
6
+ * support grpc-web client straming ([#617](https://github.com/stephenh/ts-proto/issues/617)) ([d3e7f1f](https://github.com/stephenh/ts-proto/commit/d3e7f1f4aac12db87c54d6357e557a351c96a2ca))
7
+
8
+ # [1.118.0](https://github.com/stephenh/ts-proto/compare/v1.117.1...v1.118.0) (2022-07-19)
9
+
10
+
11
+ ### Features
12
+
13
+ * add dynamic upStreamCodes option ([#618](https://github.com/stephenh/ts-proto/issues/618)) ([3091023](https://github.com/stephenh/ts-proto/commit/309102313273e09aef3a8480f4b46360ad82adaa))
14
+
15
+ ## [1.117.1](https://github.com/stephenh/ts-proto/compare/v1.117.0...v1.117.1) (2022-07-16)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * import protobufjs/minimal with importSuffix ([#616](https://github.com/stephenh/ts-proto/issues/616)) ([b86291c](https://github.com/stephenh/ts-proto/commit/b86291c58b1cb9d4064944a6371e928b564aef7f))
21
+
1
22
  # [1.117.0](https://github.com/stephenh/ts-proto/compare/v1.116.1...v1.117.0) (2022-07-05)
2
23
 
3
24
 
package/README.markdown CHANGED
@@ -99,6 +99,13 @@ plugins:
99
99
  path: ../node_modules/ts-proto/protoc-gen-ts_proto
100
100
  ```
101
101
 
102
+ To prevent `buf push` from reading irrelevent `.proto` files, configure `buf.yaml` like so:
103
+
104
+ ```yaml
105
+ build:
106
+ excludes: [node_modules]
107
+ ```
108
+
102
109
  You can also use the official plugin published to the Buf Registry.
103
110
 
104
111
  ```yaml
@@ -110,6 +117,8 @@ plugins:
110
117
 
111
118
  # Goals
112
119
 
120
+ In terms of the code that `ts-proto` generates, the general goals are:
121
+
113
122
  - Idiomatic TypeScript/ES6 types
114
123
  - `ts-proto` is a clean break from either the built-in Google/Java-esque JS code of `protoc` or the "make `.d.ts` files the `*.js` comments" approach of `protobufjs`
115
124
  - (Techically the `protobufjs/minimal` package is used for actually reading/writing bytes.)
@@ -118,6 +127,17 @@ plugins:
118
127
  - As much as possible, types are just interfaces, so you can work with messages just like regular hashes/data structures.
119
128
  - Only supports codegen `*.proto`-to-`*.ts` workflow, currently no runtime reflection/loading of dynamic `.proto` files
120
129
 
130
+ ## Non-Goals
131
+
132
+ Note that ts-proto is not an out-of-the-box RPC framework; instead it's more of a swiss-army knife (as witnessed by its many config options), that lets you build _exactly_ the RPC framework you'd like on top of it (i.e. that best integrates with your company's protobuf ecosystem; for better or worse, protobuf RPC is still a somewhat fragmented ecosystem).
133
+
134
+ If you'd like an out-of-the-box RPC framework built on top of ts-proto, there are a few examples:
135
+
136
+ - [nice-grpc](https://github.com/deeplay-io/nice-grpc)
137
+ - [starpc](https://github.com/aperturerobotics/starpc)
138
+
139
+ (Note for potential contributors, if you develop other frameworks/mini-frameworks, or even blog posts/tutorials, on using `ts-proto`, we're happy to link to them.)
140
+
121
141
  # Example Types
122
142
 
123
143
  The generated types are "just data", i.e.:
@@ -483,6 +503,8 @@ If you need ts-proto customizations or priority support for your company, you ca
483
503
 
484
504
  # Development
485
505
 
506
+ This section describes how to contribute directly to ts-proto, i.e. it's not required for running `ts-proto` in `protoc` or using the generated TypeScript.
507
+
486
508
  **Requirements**
487
509
 
488
510
  - [Docker](https://www.docker.com) or [protoc](https://github.com/protocolbuffers/protobuf/releases) v3.19.1
@@ -18,7 +18,7 @@ function generateGrpcClientImpl(ctx, _fileDesc, serviceDesc) {
18
18
  // Create the constructor(rpc: Rpc)
19
19
  chunks.push((0, ts_poet_1.code) `
20
20
  private readonly rpc: Rpc;
21
-
21
+
22
22
  constructor(rpc: Rpc) {
23
23
  `);
24
24
  chunks.push((0, ts_poet_1.code) `this.rpc = rpc;`);
@@ -46,9 +46,11 @@ function generateRpcMethod(ctx, serviceDesc, methodDesc) {
46
46
  return (0, ts_poet_1.code) `
47
47
  ${methodDesc.formattedName}(
48
48
  request: ${inputType},
49
- metadata?: grpc.Metadata,
50
- ): ${returns} {
51
- throw new Error('ts-proto does not yet support client streaming!');
49
+ options?: {
50
+ metadata?: grpc.Metadata,
51
+ rpcOptions?: grpc.RpcOptions,
52
+ }): ${returns} {
53
+ return this.rpc.stream(${methodDescName(serviceDesc, methodDesc)}, request, options?.metadata, options?.rpcOptions)
52
54
  }
53
55
  `;
54
56
  }
@@ -83,7 +85,7 @@ exports.generateGrpcServiceDesc = generateGrpcServiceDesc;
83
85
  * implementation.
84
86
  */
85
87
  function generateGrpcMethodDesc(ctx, serviceDesc, methodDesc) {
86
- const inputType = (0, types_1.requestType)(ctx, methodDesc);
88
+ const inputType = (0, types_1.rawRequestType)(ctx, methodDesc);
87
89
  const outputType = (0, types_1.responseType)(ctx, methodDesc);
88
90
  // grpc-web expects this to be a class, but the ts-proto messages are just interfaces.
89
91
  //
@@ -109,13 +111,15 @@ function generateGrpcMethodDesc(ctx, serviceDesc, methodDesc) {
109
111
  deserializeBinary(data: Uint8Array) {
110
112
  return { ...${outputType}.decode(data), toObject() { return this; } };
111
113
  }
112
- }`;
114
+ }`;
115
+ const streaming = methodDesc.clientStreaming || methodDesc.serverStreaming;
116
+ const methodDef = streaming ? 'MethodDefinitionish' : 'UnaryMethodDefinitionish';
113
117
  return (0, ts_poet_1.code) `
114
- export const ${methodDescName(serviceDesc, methodDesc)}: UnaryMethodDefinitionish = {
118
+ export const ${methodDescName(serviceDesc, methodDesc)}: ${methodDef} = {
115
119
  methodName: "${methodDesc.name}",
116
120
  service: ${serviceDesc.name}Desc,
117
- requestStream: false,
118
- responseStream: ${methodDesc.serverStreaming ? 'true' : 'false'},
121
+ requestStream: ${methodDesc.clientStreaming ? true : false},
122
+ responseStream: ${methodDesc.serverStreaming ? true : false},
119
123
  requestType: ${requestFn} as any,
120
124
  responseType: ${responseFn} as any,
121
125
  };
@@ -133,6 +137,10 @@ function addGrpcWebMisc(ctx, hasStreamingMethods) {
133
137
  interface UnaryMethodDefinitionishR extends ${grpc}.UnaryMethodDefinition<any, any> { requestStream: any; responseStream: any; }
134
138
  `);
135
139
  chunks.push((0, ts_poet_1.code) `type UnaryMethodDefinitionish = UnaryMethodDefinitionishR;`);
140
+ chunks.push((0, ts_poet_1.code) `
141
+ interface MethodDefinitionishR extends ${grpc}.MethodDefinition<any, any> { requestStream: any; responseStream: any; }
142
+ `);
143
+ chunks.push((0, ts_poet_1.code) `type MethodDefinitionish = MethodDefinitionishR;`);
136
144
  chunks.push(generateGrpcWebRpcType(ctx, options.returnObservable, hasStreamingMethods));
137
145
  chunks.push(generateGrpcWebImpl(ctx, options.returnObservable, hasStreamingMethods));
138
146
  return (0, ts_poet_1.joinCode)(chunks, { on: '\n\n' });
@@ -156,8 +164,14 @@ function generateGrpcWebRpcType(ctx, returnObservable, hasStreamingMethods) {
156
164
  methodDesc: T,
157
165
  request: any,
158
166
  metadata: grpc.Metadata | undefined,
159
- ): ${(0, types_1.observableType)(ctx)}<any>;
160
- `);
167
+ ): ${(0, types_1.observableType)(ctx)}<any>;`);
168
+ chunks.push((0, ts_poet_1.code) `
169
+ stream<T extends MethodDefinitionish>(
170
+ methodDesc: T,
171
+ request: ${(0, types_1.observableType)(ctx)}<any>,
172
+ metadata: grpc.Metadata | undefined,
173
+ rpcOptions: grpc.RpcOptions | undefined
174
+ ): ${(0, types_1.observableType)(ctx)}<any>;`);
161
175
  }
162
176
  chunks.push((0, ts_poet_1.code) `}`);
163
177
  return (0, ts_poet_1.joinCode)(chunks, { on: '\n' });
@@ -170,6 +184,7 @@ function generateGrpcWebImpl(ctx, returnObservable, hasStreamingMethods) {
170
184
  ${hasStreamingMethods ? 'streamingTransport?: grpc.TransportFactory,' : ``}
171
185
  debug?: boolean,
172
186
  metadata?: grpc.Metadata,
187
+ upStreamRetryCodes?: number[],
173
188
  }
174
189
  `;
175
190
  const chunks = [];
@@ -177,7 +192,7 @@ function generateGrpcWebImpl(ctx, returnObservable, hasStreamingMethods) {
177
192
  export class GrpcWebImpl {
178
193
  private host: string;
179
194
  private options: ${options};
180
-
195
+
181
196
  constructor(host: string, options: ${options}) {
182
197
  this.host = host;
183
198
  this.options = options;
@@ -191,6 +206,7 @@ function generateGrpcWebImpl(ctx, returnObservable, hasStreamingMethods) {
191
206
  }
192
207
  if (hasStreamingMethods) {
193
208
  chunks.push(createInvokeMethod(ctx));
209
+ chunks.push(createStreamMethod(ctx));
194
210
  }
195
211
  chunks.push((0, ts_poet_1.code) `}`);
196
212
  return (0, ts_poet_1.joinCode)(chunks, { trim: false });
@@ -258,7 +274,7 @@ function createObservableUnaryMethod(ctx) {
258
274
  },
259
275
  });
260
276
  }).pipe(${take}(1));
261
- }
277
+ }
262
278
  `;
263
279
  }
264
280
  function createInvokeMethod(ctx) {
@@ -268,8 +284,7 @@ function createInvokeMethod(ctx) {
268
284
  _request: any,
269
285
  metadata: grpc.Metadata | undefined
270
286
  ): ${(0, types_1.observableType)(ctx)}<any> {
271
- // Status Response Codes (https://developers.google.com/maps-booking/reference/grpc-api/status_codes)
272
- const upStreamCodes = [2, 4, 8, 9, 10, 13, 14, 15];
287
+ const upStreamCodes = this.options.upStreamRetryCodes || [];
273
288
  const DEFAULT_TIMEOUT_TIME: number = 3_000;
274
289
  const request = { ..._request, ...methodDesc.requestType };
275
290
  const maybeCombinedMetadata =
@@ -302,3 +317,50 @@ function createInvokeMethod(ctx) {
302
317
  }
303
318
  `;
304
319
  }
320
+ function createStreamMethod(ctx) {
321
+ return (0, ts_poet_1.code) `
322
+ stream<T extends MethodDefinitionish>(
323
+ methodDesc: T,
324
+ _request: ${(0, types_1.observableType)(ctx)}<any>,
325
+ metadata: ${grpc}.Metadata | undefined,
326
+ rpcOptions: ${grpc}.RpcOptions | undefined
327
+ ): ${(0, types_1.observableType)(ctx)}<any> {
328
+ const defaultOptions = {
329
+ host: this.host,
330
+ debug: rpcOptions?.debug || this.options.debug,
331
+ transport: rpcOptions?.transport || this.options.streamingTransport || this.options.transport,
332
+ }
333
+
334
+ let started = false;
335
+ const client = ${grpc}.client(methodDesc, defaultOptions);
336
+
337
+ const subscription = _request.subscribe((_req: any) => {
338
+ const request = { ..._req, ...methodDesc.requestType };
339
+ if (!started) {
340
+ client.start(metadata);
341
+ started = true;
342
+ }
343
+ client.send(request);
344
+ })
345
+
346
+ subscription.add(() => {
347
+ client.finishSend();
348
+ })
349
+
350
+ return new Observable((observer) => {
351
+ client.onEnd((code: ${grpc}.Code, message: string, trailers: ${grpc}.Metadata) => {
352
+ subscription.unsubscribe();
353
+ if (code === 0) {
354
+ observer.complete();
355
+ } else {
356
+ observer.error(new Error(\`Error \${code} \${message}\`));
357
+ }
358
+ })
359
+ client.onMessage((res: any) => {
360
+ observer.next(res);
361
+ })
362
+ observer.add(() => client.close())
363
+ }).pipe(share());
364
+ }
365
+ `;
366
+ }
@@ -8,7 +8,6 @@ const sourceInfo_1 = require("./sourceInfo");
8
8
  const main_1 = require("./main");
9
9
  const hash = (0, ts_poet_1.imp)('hash*object-hash');
10
10
  const dataloader = (0, ts_poet_1.imp)('DataLoader*dataloader');
11
- const Reader = (0, ts_poet_1.imp)('Reader@protobufjs/minimal');
12
11
  /**
13
12
  * Generates an interface for `serviceDesc`.
14
13
  *
@@ -43,7 +42,14 @@ function generateService(ctx, fileDesc, sourceInfo, serviceDesc) {
43
42
  // Use metadata as last argument for interface only configuration
44
43
  if (options.outputClientImpl === 'grpc-web') {
45
44
  // We have to use grpc.Metadata where grpc will come from @improbable-eng
46
- params.push((0, ts_poet_1.code) `metadata?: grpc.Metadata`);
45
+ if (methodDesc.clientStreaming) {
46
+ params.push((0, ts_poet_1.code) `options?: {
47
+ metadata?: grpc.Metadata,
48
+ rpcOptions?: grpc.RpcOptions}`);
49
+ }
50
+ else {
51
+ params.push((0, ts_poet_1.code) `metadata?: grpc.Metadata`);
52
+ }
47
53
  }
48
54
  else if (options.addGrpcMetadata) {
49
55
  const Metadata = (0, ts_poet_1.imp)('Metadata@@grpc/grpc-js');
@@ -76,7 +82,7 @@ exports.generateService = generateService;
76
82
  function generateRegularRpcMethod(ctx, fileDesc, serviceDesc, methodDesc) {
77
83
  (0, utils_1.assertInstanceOf)(methodDesc, utils_1.FormattedMethodDescriptor);
78
84
  const { options, utils } = ctx;
79
- const Reader = (0, ts_poet_1.imp)('Reader@protobufjs/minimal');
85
+ const Reader = (0, utils_1.impFile)(ctx.options, 'Reader@protobufjs/minimal');
80
86
  const rawInputType = (0, types_1.rawRequestType)(ctx, methodDesc);
81
87
  const inputType = (0, types_1.requestType)(ctx, methodDesc);
82
88
  const outputType = (0, types_1.responseType)(ctx, methodDesc);
@@ -223,6 +229,7 @@ function generateCachingRpcMethod(ctx, fileDesc, serviceDesc, methodDesc) {
223
229
  const inputType = (0, types_1.requestType)(ctx, methodDesc);
224
230
  const outputType = (0, types_1.responseType)(ctx, methodDesc);
225
231
  const uniqueIdentifier = `${(0, utils_1.maybePrefixPackage)(fileDesc, serviceDesc.name)}.${methodDesc.name}`;
232
+ const Reader = (0, utils_1.impFile)(ctx.options, 'Reader@protobufjs/minimal');
226
233
  const lambda = (0, ts_poet_1.code) `
227
234
  (requests) => {
228
235
  const responses = requests.map(async request => {
@@ -2,8 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateTypeRegistry = void 0;
4
4
  const ts_poet_1 = require("ts-poet");
5
- const Writer = (0, ts_poet_1.imp)('Writer@protobufjs/minimal');
6
- const Reader = (0, ts_poet_1.imp)('Reader@protobufjs/minimal');
5
+ const utils_1 = require("./utils");
7
6
  function generateTypeRegistry(ctx) {
8
7
  const chunks = [];
9
8
  chunks.push(generateMessageType(ctx));
@@ -22,6 +21,8 @@ function generateMessageType(ctx) {
22
21
  chunks.push((0, ts_poet_1.code) `export interface MessageType<Message extends UnknownMessage = UnknownMessage> {`);
23
22
  chunks.push((0, ts_poet_1.code) `$type: Message['$type'];`);
24
23
  if (ctx.options.outputEncodeMethods) {
24
+ const Writer = (0, utils_1.impFile)(ctx.options, 'Writer@protobufjs/minimal');
25
+ const Reader = (0, utils_1.impFile)(ctx.options, 'Reader@protobufjs/minimal');
25
26
  chunks.push((0, ts_poet_1.code) `encode(message: Message, writer?: ${Writer}): ${Writer};`);
26
27
  chunks.push((0, ts_poet_1.code) `decode(input: ${Reader} | Uint8Array, length?: number): Message;`);
27
28
  }
package/build/main.js CHANGED
@@ -108,14 +108,13 @@ function generateFile(ctx, fileDesc) {
108
108
  };
109
109
  `);
110
110
  if (options.outputTypeRegistry) {
111
- const messageTypeRegistry = (0, ts_poet_1.imp)('messageTypeRegistry@./typeRegistry');
111
+ const messageTypeRegistry = (0, utils_1.impFile)(options, 'messageTypeRegistry@./typeRegistry');
112
112
  chunks.push((0, ts_poet_1.code) `
113
113
  ${messageTypeRegistry}.set(${fullName}.$type, ${fullName});
114
114
  `);
115
115
  }
116
116
  }, options);
117
117
  }
118
- let hasServerStreamingMethods = false;
119
118
  let hasStreamingMethods = false;
120
119
  (0, visit_1.visitServices)(fileDesc, sourceInfo, (serviceDesc, sInfo) => {
121
120
  if (options.nestJs) {
@@ -155,12 +154,7 @@ function generateFile(ctx, fileDesc) {
155
154
  chunks.push((0, generate_grpc_web_1.generateGrpcClientImpl)(ctx, fileDesc, serviceDesc));
156
155
  chunks.push((0, generate_grpc_web_1.generateGrpcServiceDesc)(fileDesc, serviceDesc));
157
156
  serviceDesc.method.forEach((method) => {
158
- if (!method.clientStreaming) {
159
- chunks.push((0, generate_grpc_web_1.generateGrpcMethodDesc)(ctx, serviceDesc, method));
160
- }
161
- if (method.serverStreaming) {
162
- hasServerStreamingMethods = true;
163
- }
157
+ chunks.push((0, generate_grpc_web_1.generateGrpcMethodDesc)(ctx, serviceDesc, method));
164
158
  });
165
159
  }
166
160
  }
@@ -179,7 +173,7 @@ function generateFile(ctx, fileDesc) {
179
173
  chunks.push((0, generate_services_1.generateRpcType)(ctx, hasStreamingMethods));
180
174
  }
181
175
  else if (options.outputClientImpl === 'grpc-web') {
182
- chunks.push((0, generate_grpc_web_1.addGrpcWebMisc)(ctx, hasServerStreamingMethods));
176
+ chunks.push((0, generate_grpc_web_1.addGrpcWebMisc)(ctx, hasStreamingMethods));
183
177
  }
184
178
  }
185
179
  if (options.context) {
@@ -227,8 +221,8 @@ exports.makeUtils = makeUtils;
227
221
  function makeLongUtils(options, bytes) {
228
222
  // Regardless of which `forceLong` config option we're using, we always use
229
223
  // the `long` library to either represent or at least sanity-check 64-bit values
230
- const util = (0, ts_poet_1.imp)('util@protobufjs/minimal');
231
- const configure = (0, ts_poet_1.imp)('configure@protobufjs/minimal');
224
+ const util = (0, utils_1.impFile)(options, 'util@protobufjs/minimal');
225
+ const configure = (0, utils_1.impFile)(options, 'configure@protobufjs/minimal');
232
226
  // Before esModuleInterop, we had to use 'import * as Long from long` b/c long is
233
227
  // an `export =` module and exports only the Long constructor (which is callable).
234
228
  // See https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require.
@@ -572,6 +566,7 @@ function generateDecode(ctx, fullName, messageDesc) {
572
566
  if (options.usePrototypeForDefaults) {
573
567
  createBase = (0, ts_poet_1.code) `Object.create(${createBase}) as ${fullName}`;
574
568
  }
569
+ const Reader = (0, utils_1.impFile)(ctx.options, 'Reader@protobufjs/minimal');
575
570
  // create the basic function declaration
576
571
  chunks.push((0, ts_poet_1.code) `
577
572
  decode(
@@ -712,12 +707,11 @@ function generateDecode(ctx, fullName, messageDesc) {
712
707
  chunks.push((0, ts_poet_1.code) `}`);
713
708
  return (0, ts_poet_1.joinCode)(chunks, { on: '\n' });
714
709
  }
715
- const Writer = (0, ts_poet_1.imp)('Writer@protobufjs/minimal');
716
- const Reader = (0, ts_poet_1.imp)('Reader@protobufjs/minimal');
717
710
  /** Creates a function to encode a message by loop overing the tags. */
718
711
  function generateEncode(ctx, fullName, messageDesc) {
719
712
  const { options, utils, typeMap } = ctx;
720
713
  const chunks = [];
714
+ const Writer = (0, utils_1.impFile)(ctx.options, 'Writer@protobufjs/minimal');
721
715
  // create the basic function declaration
722
716
  chunks.push((0, ts_poet_1.code) `
723
717
  encode(
package/build/options.js CHANGED
@@ -165,6 +165,7 @@ function parseParameter(parameter) {
165
165
  return options;
166
166
  }
167
167
  function getTsPoetOpts(_options) {
168
- return { forceModuleImport: ['protobufjs/minimal'] };
168
+ const imports = ['protobufjs/minimal' + _options.importSuffix];
169
+ return _options.esModuleInterop ? { forceDefaultImport: imports } : { forceModuleImport: imports };
169
170
  }
170
171
  exports.getTsPoetOpts = getTsPoetOpts;
package/build/schema.js CHANGED
@@ -68,7 +68,7 @@ function generateSchema(ctx, fileDesc, sourceInfo) {
68
68
  }
69
69
  });
70
70
  const dependencies = fileDesc.dependency.map((dep) => {
71
- return (0, ts_poet_1.code) `${(0, ts_poet_1.imp)(`protoMetadata@./${dep.replace('.proto', '')}`)}`;
71
+ return (0, ts_poet_1.code) `${(0, utils_1.impFile)(options, `protoMetadata@./${dep.replace('.proto', '')}`)}`;
72
72
  });
73
73
  // Use toObject so that we get enums as numbers (instead of the default toJSON behavior)
74
74
  const descriptor = ts_proto_descriptors_1.FileDescriptorProto.fromPartial(fileDesc);
package/build/types.js CHANGED
@@ -641,7 +641,7 @@ function responseObservable(ctx, methodDesc) {
641
641
  exports.responseObservable = responseObservable;
642
642
  function responsePromiseOrObservable(ctx, methodDesc) {
643
643
  const { options } = ctx;
644
- if (options.returnObservable || methodDesc.serverStreaming) {
644
+ if (options.returnObservable || methodDesc.serverStreaming || methodDesc.clientStreaming) {
645
645
  return responseObservable(ctx, methodDesc);
646
646
  }
647
647
  return responsePromise(ctx, methodDesc);
package/build/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.impProto = 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;
3
+ 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;
4
4
  const ts_poet_1 = require("ts-poet");
5
5
  const options_1 = require("./options");
6
6
  const case_1 = require("./case");
@@ -169,6 +169,10 @@ function getPropertyAccessor(objectName, propertyName, optional = false) {
169
169
  : `${objectName}${optional ? '?.' : ''}[${JSON.stringify(propertyName)}]`;
170
170
  }
171
171
  exports.getPropertyAccessor = getPropertyAccessor;
172
+ function impFile(options, spec) {
173
+ return (0, ts_poet_1.imp)(`${spec}${options.importSuffix}`);
174
+ }
175
+ exports.impFile = impFile;
172
176
  function impProto(options, module, type) {
173
177
  const importString = `${type}@./${module}${options.fileSuffix}${options.importSuffix}`;
174
178
  if (options.onlyTypes) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-proto",
3
- "version": "1.117.0",
3
+ "version": "1.119.0",
4
4
  "description": "",
5
5
  "main": "build/plugin.js",
6
6
  "repository": "github:stephenh/ts-proto",