ts-proto 1.115.3 → 1.116.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.
@@ -4,47 +4,46 @@ exports.addGrpcWebMisc = exports.generateGrpcMethodDesc = exports.generateGrpcSe
4
4
  const types_1 = require("./types");
5
5
  const ts_poet_1 = require("ts-poet");
6
6
  const utils_1 = require("./utils");
7
- const grpc = ts_poet_1.imp('grpc@@improbable-eng/grpc-web');
8
- const share = ts_poet_1.imp('share@rxjs/operators');
9
- const take = ts_poet_1.imp('take@rxjs/operators');
10
- const BrowserHeaders = ts_poet_1.imp('BrowserHeaders@browser-headers');
11
- const Observable = ts_poet_1.imp('Observable@rxjs');
7
+ const grpc = (0, ts_poet_1.imp)('grpc@@improbable-eng/grpc-web');
8
+ const share = (0, ts_poet_1.imp)('share@rxjs/operators');
9
+ const take = (0, ts_poet_1.imp)('take@rxjs/operators');
10
+ const BrowserHeaders = (0, ts_poet_1.imp)('BrowserHeaders@browser-headers');
12
11
  /** Generates a client that uses the `@improbable-web/grpc-web` library. */
13
- function generateGrpcClientImpl(ctx, fileDesc, serviceDesc) {
12
+ function generateGrpcClientImpl(ctx, _fileDesc, serviceDesc) {
14
13
  const chunks = [];
15
14
  // Define the FooServiceImpl class
16
- chunks.push(ts_poet_1.code `
15
+ chunks.push((0, ts_poet_1.code) `
17
16
  export class ${serviceDesc.name}ClientImpl implements ${serviceDesc.name} {
18
17
  `);
19
18
  // Create the constructor(rpc: Rpc)
20
- chunks.push(ts_poet_1.code `
19
+ chunks.push((0, ts_poet_1.code) `
21
20
  private readonly rpc: Rpc;
22
21
 
23
22
  constructor(rpc: Rpc) {
24
23
  `);
25
- chunks.push(ts_poet_1.code `this.rpc = rpc;`);
24
+ chunks.push((0, ts_poet_1.code) `this.rpc = rpc;`);
26
25
  // Bind each FooService method to the FooServiceImpl class
27
26
  for (const methodDesc of serviceDesc.method) {
28
- utils_1.assertInstanceOf(methodDesc, utils_1.FormattedMethodDescriptor);
29
- chunks.push(ts_poet_1.code `this.${methodDesc.formattedName} = this.${methodDesc.formattedName}.bind(this);`);
27
+ (0, utils_1.assertInstanceOf)(methodDesc, utils_1.FormattedMethodDescriptor);
28
+ chunks.push((0, ts_poet_1.code) `this.${methodDesc.formattedName} = this.${methodDesc.formattedName}.bind(this);`);
30
29
  }
31
- chunks.push(ts_poet_1.code `}`);
30
+ chunks.push((0, ts_poet_1.code) `}`);
32
31
  // Create a method for each FooService method
33
32
  for (const methodDesc of serviceDesc.method) {
34
33
  chunks.push(generateRpcMethod(ctx, serviceDesc, methodDesc));
35
34
  }
36
- chunks.push(ts_poet_1.code `}`);
37
- return ts_poet_1.joinCode(chunks, { trim: false, on: '\n' });
35
+ chunks.push((0, ts_poet_1.code) `}`);
36
+ return (0, ts_poet_1.joinCode)(chunks, { trim: false, on: '\n' });
38
37
  }
39
38
  exports.generateGrpcClientImpl = generateGrpcClientImpl;
40
39
  /** Creates the RPC methods that client code actually calls. */
41
40
  function generateRpcMethod(ctx, serviceDesc, methodDesc) {
42
- utils_1.assertInstanceOf(methodDesc, utils_1.FormattedMethodDescriptor);
43
- const requestMessage = types_1.rawRequestType(ctx, methodDesc);
44
- const inputType = types_1.requestType(ctx, methodDesc, true);
45
- const returns = types_1.responsePromiseOrObservable(ctx, methodDesc);
41
+ (0, utils_1.assertInstanceOf)(methodDesc, utils_1.FormattedMethodDescriptor);
42
+ const requestMessage = (0, types_1.rawRequestType)(ctx, methodDesc);
43
+ const inputType = (0, types_1.requestType)(ctx, methodDesc, true);
44
+ const returns = (0, types_1.responsePromiseOrObservable)(ctx, methodDesc);
46
45
  if (methodDesc.clientStreaming) {
47
- return ts_poet_1.code `
46
+ return (0, ts_poet_1.code) `
48
47
  ${methodDesc.formattedName}(
49
48
  request: ${inputType},
50
49
  metadata?: grpc.Metadata,
@@ -54,7 +53,7 @@ function generateRpcMethod(ctx, serviceDesc, methodDesc) {
54
53
  `;
55
54
  }
56
55
  const method = methodDesc.serverStreaming ? 'invoke' : 'unary';
57
- return ts_poet_1.code `
56
+ return (0, ts_poet_1.code) `
58
57
  ${methodDesc.formattedName}(
59
58
  request: ${inputType},
60
59
  metadata?: grpc.Metadata,
@@ -69,9 +68,9 @@ function generateRpcMethod(ctx, serviceDesc, methodDesc) {
69
68
  }
70
69
  /** Creates the service descriptor that grpc-web needs at runtime. */
71
70
  function generateGrpcServiceDesc(fileDesc, serviceDesc) {
72
- return ts_poet_1.code `
71
+ return (0, ts_poet_1.code) `
73
72
  export const ${serviceDesc.name}Desc = {
74
- serviceName: "${utils_1.maybePrefixPackage(fileDesc, serviceDesc.name)}",
73
+ serviceName: "${(0, utils_1.maybePrefixPackage)(fileDesc, serviceDesc.name)}",
75
74
  };
76
75
  `;
77
76
  }
@@ -84,8 +83,8 @@ exports.generateGrpcServiceDesc = generateGrpcServiceDesc;
84
83
  * implementation.
85
84
  */
86
85
  function generateGrpcMethodDesc(ctx, serviceDesc, methodDesc) {
87
- const inputType = types_1.requestType(ctx, methodDesc);
88
- const outputType = types_1.responseType(ctx, methodDesc);
86
+ const inputType = (0, types_1.requestType)(ctx, methodDesc);
87
+ const outputType = (0, types_1.responseType)(ctx, methodDesc);
89
88
  // grpc-web expects this to be a class, but the ts-proto messages are just interfaces.
90
89
  //
91
90
  // That said, grpc-web's runtime doesn't really use this (at least so far for what ts-proto
@@ -97,7 +96,7 @@ function generateGrpcMethodDesc(ctx, serviceDesc, methodDesc) {
97
96
  // message's `serializeBinary` method into the data before handing it off to grpc-web.
98
97
  //
99
98
  // This makes our data look enough like an object/class that grpc-web works just fine.
100
- const requestFn = ts_poet_1.code `{
99
+ const requestFn = (0, ts_poet_1.code) `{
101
100
  serializeBinary() {
102
101
  return ${inputType}.encode(this).finish();
103
102
  },
@@ -106,12 +105,12 @@ function generateGrpcMethodDesc(ctx, serviceDesc, methodDesc) {
106
105
  // create new instances of messages. We again don't have an actual class constructor/symbol
107
106
  // to pass to it, but we can make up a lambda that has a `deserializeBinary` that does what
108
107
  // we want/what grpc-web's runtime needs.
109
- const responseFn = ts_poet_1.code `{
108
+ const responseFn = (0, ts_poet_1.code) `{
110
109
  deserializeBinary(data: Uint8Array) {
111
110
  return { ...${outputType}.decode(data), toObject() { return this; } };
112
111
  }
113
112
  }`;
114
- return ts_poet_1.code `
113
+ return (0, ts_poet_1.code) `
115
114
  export const ${methodDescName(serviceDesc, methodDesc)}: UnaryMethodDefinitionish = {
116
115
  methodName: "${methodDesc.name}",
117
116
  service: ${serviceDesc.name}Desc,
@@ -130,21 +129,21 @@ function methodDescName(serviceDesc, methodDesc) {
130
129
  function addGrpcWebMisc(ctx, hasStreamingMethods) {
131
130
  const { options } = ctx;
132
131
  const chunks = [];
133
- chunks.push(ts_poet_1.code `
132
+ chunks.push((0, ts_poet_1.code) `
134
133
  interface UnaryMethodDefinitionishR extends ${grpc}.UnaryMethodDefinition<any, any> { requestStream: any; responseStream: any; }
135
134
  `);
136
- chunks.push(ts_poet_1.code `type UnaryMethodDefinitionish = UnaryMethodDefinitionishR;`);
137
- chunks.push(generateGrpcWebRpcType(options.returnObservable, hasStreamingMethods));
138
- chunks.push(generateGrpcWebImpl(options.returnObservable, hasStreamingMethods));
139
- return ts_poet_1.joinCode(chunks, { on: '\n\n' });
135
+ chunks.push((0, ts_poet_1.code) `type UnaryMethodDefinitionish = UnaryMethodDefinitionishR;`);
136
+ chunks.push(generateGrpcWebRpcType(ctx, options.returnObservable, hasStreamingMethods));
137
+ chunks.push(generateGrpcWebImpl(ctx, options.returnObservable, hasStreamingMethods));
138
+ return (0, ts_poet_1.joinCode)(chunks, { on: '\n\n' });
140
139
  }
141
140
  exports.addGrpcWebMisc = addGrpcWebMisc;
142
141
  /** Makes an `Rpc` interface to decouple from the low-level grpc-web `grpc.invoke and grpc.unary`/etc. methods. */
143
- function generateGrpcWebRpcType(returnObservable, hasStreamingMethods) {
142
+ function generateGrpcWebRpcType(ctx, returnObservable, hasStreamingMethods) {
144
143
  const chunks = [];
145
- chunks.push(ts_poet_1.code `interface Rpc {`);
146
- const wrapper = returnObservable ? Observable : 'Promise';
147
- chunks.push(ts_poet_1.code `
144
+ chunks.push((0, ts_poet_1.code) `interface Rpc {`);
145
+ const wrapper = returnObservable ? (0, types_1.observableType)(ctx) : 'Promise';
146
+ chunks.push((0, ts_poet_1.code) `
148
147
  unary<T extends UnaryMethodDefinitionish>(
149
148
  methodDesc: T,
150
149
  request: any,
@@ -152,20 +151,20 @@ function generateGrpcWebRpcType(returnObservable, hasStreamingMethods) {
152
151
  ): ${wrapper}<any>;
153
152
  `);
154
153
  if (hasStreamingMethods) {
155
- chunks.push(ts_poet_1.code `
154
+ chunks.push((0, ts_poet_1.code) `
156
155
  invoke<T extends UnaryMethodDefinitionish>(
157
156
  methodDesc: T,
158
157
  request: any,
159
158
  metadata: grpc.Metadata | undefined,
160
- ): ${Observable}<any>;
159
+ ): ${(0, types_1.observableType)(ctx)}<any>;
161
160
  `);
162
161
  }
163
- chunks.push(ts_poet_1.code `}`);
164
- return ts_poet_1.joinCode(chunks, { on: '\n' });
162
+ chunks.push((0, ts_poet_1.code) `}`);
163
+ return (0, ts_poet_1.joinCode)(chunks, { on: '\n' });
165
164
  }
166
165
  /** Implements the `Rpc` interface by making calls using the `grpc.unary` method. */
167
- function generateGrpcWebImpl(returnObservable, hasStreamingMethods) {
168
- const options = ts_poet_1.code `
166
+ function generateGrpcWebImpl(ctx, returnObservable, hasStreamingMethods) {
167
+ const options = (0, ts_poet_1.code) `
169
168
  {
170
169
  transport?: grpc.TransportFactory,
171
170
  ${hasStreamingMethods ? 'streamingTransport?: grpc.TransportFactory,' : ``}
@@ -174,7 +173,7 @@ function generateGrpcWebImpl(returnObservable, hasStreamingMethods) {
174
173
  }
175
174
  `;
176
175
  const chunks = [];
177
- chunks.push(ts_poet_1.code `
176
+ chunks.push((0, ts_poet_1.code) `
178
177
  export class GrpcWebImpl {
179
178
  private host: string;
180
179
  private options: ${options};
@@ -185,19 +184,19 @@ function generateGrpcWebImpl(returnObservable, hasStreamingMethods) {
185
184
  }
186
185
  `);
187
186
  if (returnObservable) {
188
- chunks.push(createObservableUnaryMethod());
187
+ chunks.push(createObservableUnaryMethod(ctx));
189
188
  }
190
189
  else {
191
190
  chunks.push(createPromiseUnaryMethod());
192
191
  }
193
192
  if (hasStreamingMethods) {
194
- chunks.push(createInvokeMethod());
193
+ chunks.push(createInvokeMethod(ctx));
195
194
  }
196
- chunks.push(ts_poet_1.code `}`);
197
- return ts_poet_1.joinCode(chunks, { trim: false });
195
+ chunks.push((0, ts_poet_1.code) `}`);
196
+ return (0, ts_poet_1.joinCode)(chunks, { trim: false });
198
197
  }
199
198
  function createPromiseUnaryMethod() {
200
- return ts_poet_1.code `
199
+ return (0, ts_poet_1.code) `
201
200
  unary<T extends UnaryMethodDefinitionish>(
202
201
  methodDesc: T,
203
202
  _request: any,
@@ -230,13 +229,13 @@ function createPromiseUnaryMethod() {
230
229
  }
231
230
  `;
232
231
  }
233
- function createObservableUnaryMethod() {
234
- return ts_poet_1.code `
232
+ function createObservableUnaryMethod(ctx) {
233
+ return (0, ts_poet_1.code) `
235
234
  unary<T extends UnaryMethodDefinitionish>(
236
235
  methodDesc: T,
237
236
  _request: any,
238
237
  metadata: grpc.Metadata | undefined
239
- ): ${Observable}<any> {
238
+ ): ${(0, types_1.observableType)(ctx)}<any> {
240
239
  const request = { ..._request, ...methodDesc.requestType };
241
240
  const maybeCombinedMetadata =
242
241
  metadata && this.options.metadata
@@ -262,13 +261,13 @@ function createObservableUnaryMethod() {
262
261
  }
263
262
  `;
264
263
  }
265
- function createInvokeMethod() {
266
- return ts_poet_1.code `
264
+ function createInvokeMethod(ctx) {
265
+ return (0, ts_poet_1.code) `
267
266
  invoke<T extends UnaryMethodDefinitionish>(
268
267
  methodDesc: T,
269
268
  _request: any,
270
269
  metadata: grpc.Metadata | undefined
271
- ): ${Observable}<any> {
270
+ ): ${(0, types_1.observableType)(ctx)}<any> {
272
271
  // Status Response Codes (https://developers.google.com/maps-booking/reference/grpc-api/status_codes)
273
272
  const upStreamCodes = [2, 4, 8, 9, 10, 13, 14, 15];
274
273
  const DEFAULT_TIMEOUT_TIME: number = 3_000;
@@ -10,136 +10,136 @@ function generateNestjsServiceController(ctx, fileDesc, sourceInfo, serviceDesc)
10
10
  var _a;
11
11
  const { options } = ctx;
12
12
  const chunks = [];
13
- const Metadata = ts_poet_1.imp('Metadata@@grpc/grpc-js');
14
- utils_1.maybeAddComment(sourceInfo, chunks, (_a = serviceDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
13
+ const Metadata = (0, ts_poet_1.imp)('Metadata@@grpc/grpc-js');
14
+ (0, utils_1.maybeAddComment)(sourceInfo, chunks, (_a = serviceDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
15
15
  const t = options.context ? `<${main_1.contextTypeVar}>` : '';
16
- chunks.push(ts_poet_1.code `
16
+ chunks.push((0, ts_poet_1.code) `
17
17
  export interface ${serviceDesc.name}Controller${t} {
18
18
  `);
19
19
  serviceDesc.method.forEach((methodDesc, index) => {
20
20
  var _a;
21
- utils_1.assertInstanceOf(methodDesc, utils_1.FormattedMethodDescriptor);
21
+ (0, utils_1.assertInstanceOf)(methodDesc, utils_1.FormattedMethodDescriptor);
22
22
  const info = sourceInfo.lookup(sourceInfo_1.Fields.service.method, index);
23
- utils_1.maybeAddComment(info, chunks, (_a = serviceDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
23
+ (0, utils_1.maybeAddComment)(info, chunks, (_a = serviceDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
24
24
  const params = [];
25
25
  if (options.context) {
26
- params.push(ts_poet_1.code `ctx: Context`);
26
+ params.push((0, ts_poet_1.code) `ctx: Context`);
27
27
  }
28
- params.push(ts_poet_1.code `request: ${types_1.requestType(ctx, methodDesc)}`);
28
+ params.push((0, ts_poet_1.code) `request: ${(0, types_1.requestType)(ctx, methodDesc)}`);
29
29
  // Use metadata as last argument for interface only configuration
30
30
  if (options.addGrpcMetadata) {
31
31
  const q = options.addNestjsRestParameter ? '' : '?';
32
- params.push(ts_poet_1.code `metadata${q}: ${Metadata}`);
32
+ params.push((0, ts_poet_1.code) `metadata${q}: ${Metadata}`);
33
33
  }
34
34
  if (options.addNestjsRestParameter) {
35
- params.push(ts_poet_1.code `...rest: any`);
35
+ params.push((0, ts_poet_1.code) `...rest: any`);
36
36
  }
37
37
  // Return observable for interface only configuration, passing returnObservable=true and methodDesc.serverStreaming=true
38
38
  let returns;
39
- if (types_1.isEmptyType(methodDesc.outputType)) {
40
- returns = ts_poet_1.code `void`;
39
+ if ((0, types_1.isEmptyType)(methodDesc.outputType)) {
40
+ returns = (0, ts_poet_1.code) `void`;
41
41
  }
42
42
  else if (options.returnObservable || methodDesc.serverStreaming) {
43
- returns = ts_poet_1.code `${types_1.responseObservable(ctx, methodDesc)}`;
43
+ returns = (0, ts_poet_1.code) `${(0, types_1.responseObservable)(ctx, methodDesc)}`;
44
44
  }
45
45
  else {
46
46
  // generate nestjs union type
47
- returns = ts_poet_1.code `
48
- ${types_1.responsePromise(ctx, methodDesc)}
49
- | ${types_1.responseObservable(ctx, methodDesc)}
50
- | ${types_1.responseType(ctx, methodDesc)}
47
+ returns = (0, ts_poet_1.code) `
48
+ ${(0, types_1.responsePromise)(ctx, methodDesc)}
49
+ | ${(0, types_1.responseObservable)(ctx, methodDesc)}
50
+ | ${(0, types_1.responseType)(ctx, methodDesc)}
51
51
  `;
52
52
  }
53
- chunks.push(ts_poet_1.code `
54
- ${methodDesc.formattedName}(${ts_poet_1.joinCode(params, { on: ', ' })}): ${returns};
53
+ chunks.push((0, ts_poet_1.code) `
54
+ ${methodDesc.formattedName}(${(0, ts_poet_1.joinCode)(params, { on: ', ' })}): ${returns};
55
55
  `);
56
56
  if (options.context) {
57
- const batchMethod = types_1.detectBatchMethod(ctx, fileDesc, serviceDesc, methodDesc);
57
+ const batchMethod = (0, types_1.detectBatchMethod)(ctx, fileDesc, serviceDesc, methodDesc);
58
58
  if (batchMethod) {
59
59
  const maybeCtx = options.context ? 'ctx: Context,' : '';
60
- chunks.push(ts_poet_1.code `
60
+ chunks.push((0, ts_poet_1.code) `
61
61
  ${batchMethod.singleMethodName}(
62
62
  ${maybeCtx}
63
- ${utils_1.singular(batchMethod.inputFieldName)}: ${batchMethod.inputType},
63
+ ${(0, utils_1.singular)(batchMethod.inputFieldName)}: ${batchMethod.inputType},
64
64
  ): Promise<${batchMethod.outputType}>;
65
65
  `);
66
66
  }
67
67
  }
68
68
  });
69
- chunks.push(ts_poet_1.code `}`);
70
- return ts_poet_1.joinCode(chunks, { on: '\n\n' });
69
+ chunks.push((0, ts_poet_1.code) `}`);
70
+ return (0, ts_poet_1.joinCode)(chunks, { on: '\n\n' });
71
71
  }
72
72
  exports.generateNestjsServiceController = generateNestjsServiceController;
73
73
  function generateNestjsServiceClient(ctx, fileDesc, sourceInfo, serviceDesc) {
74
74
  const { options } = ctx;
75
75
  const chunks = [];
76
- const Metadata = ts_poet_1.imp('Metadata@@grpc/grpc-js');
77
- utils_1.maybeAddComment(sourceInfo, chunks);
76
+ const Metadata = (0, ts_poet_1.imp)('Metadata@@grpc/grpc-js');
77
+ (0, utils_1.maybeAddComment)(sourceInfo, chunks);
78
78
  const t = options.context ? `<${main_1.contextTypeVar}>` : ``;
79
- chunks.push(ts_poet_1.code `
79
+ chunks.push((0, ts_poet_1.code) `
80
80
  export interface ${serviceDesc.name}Client${t} {
81
81
  `);
82
82
  serviceDesc.method.forEach((methodDesc, index) => {
83
83
  var _a;
84
- utils_1.assertInstanceOf(methodDesc, utils_1.FormattedMethodDescriptor);
84
+ (0, utils_1.assertInstanceOf)(methodDesc, utils_1.FormattedMethodDescriptor);
85
85
  const params = [];
86
86
  if (options.context) {
87
- params.push(ts_poet_1.code `ctx: Context`);
87
+ params.push((0, ts_poet_1.code) `ctx: Context`);
88
88
  }
89
- params.push(ts_poet_1.code `request: ${types_1.requestType(ctx, methodDesc)}`);
89
+ params.push((0, ts_poet_1.code) `request: ${(0, types_1.requestType)(ctx, methodDesc)}`);
90
90
  // Use metadata as last argument for interface only configuration
91
91
  if (options.addGrpcMetadata) {
92
92
  const q = options.addNestjsRestParameter ? '' : '?';
93
- params.push(ts_poet_1.code `metadata${q}: ${Metadata}`);
93
+ params.push((0, ts_poet_1.code) `metadata${q}: ${Metadata}`);
94
94
  }
95
95
  if (options.addNestjsRestParameter) {
96
- params.push(ts_poet_1.code `...rest: any`);
96
+ params.push((0, ts_poet_1.code) `...rest: any`);
97
97
  }
98
98
  // Return observable since nestjs client always returns an Observable
99
- const returns = types_1.responseObservable(ctx, methodDesc);
99
+ const returns = (0, types_1.responseObservable)(ctx, methodDesc);
100
100
  const info = sourceInfo.lookup(sourceInfo_1.Fields.service.method, index);
101
- utils_1.maybeAddComment(info, chunks, (_a = methodDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
102
- chunks.push(ts_poet_1.code `
101
+ (0, utils_1.maybeAddComment)(info, chunks, (_a = methodDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
102
+ chunks.push((0, ts_poet_1.code) `
103
103
  ${methodDesc.formattedName}(
104
- ${ts_poet_1.joinCode(params, { on: ',' })}
104
+ ${(0, ts_poet_1.joinCode)(params, { on: ',' })}
105
105
  ): ${returns};
106
106
  `);
107
107
  if (options.context) {
108
- const batchMethod = types_1.detectBatchMethod(ctx, fileDesc, serviceDesc, methodDesc);
108
+ const batchMethod = (0, types_1.detectBatchMethod)(ctx, fileDesc, serviceDesc, methodDesc);
109
109
  if (batchMethod) {
110
110
  const maybeContext = options.context ? `ctx: Context,` : '';
111
- chunks.push(ts_poet_1.code `
111
+ chunks.push((0, ts_poet_1.code) `
112
112
  ${batchMethod.singleMethodName}(
113
113
  ${maybeContext}
114
- ${utils_1.singular(batchMethod.inputFieldName)}
114
+ ${(0, utils_1.singular)(batchMethod.inputFieldName)}
115
115
  ): Promise<${batchMethod.inputType}>;
116
116
  `);
117
117
  }
118
118
  }
119
119
  });
120
- chunks.push(ts_poet_1.code `}`);
121
- return ts_poet_1.joinCode(chunks, { on: '\n\n' });
120
+ chunks.push((0, ts_poet_1.code) `}`);
121
+ return (0, ts_poet_1.joinCode)(chunks, { on: '\n\n' });
122
122
  }
123
123
  exports.generateNestjsServiceClient = generateNestjsServiceClient;
124
124
  function generateNestjsGrpcServiceMethodsDecorator(ctx, serviceDesc) {
125
125
  const { options } = ctx;
126
- const GrpcMethod = ts_poet_1.imp('GrpcMethod@@nestjs/microservices');
127
- const GrpcStreamMethod = ts_poet_1.imp('GrpcStreamMethod@@nestjs/microservices');
126
+ const GrpcMethod = (0, ts_poet_1.imp)('GrpcMethod@@nestjs/microservices');
127
+ const GrpcStreamMethod = (0, ts_poet_1.imp)('GrpcStreamMethod@@nestjs/microservices');
128
128
  const grpcMethods = serviceDesc.method
129
129
  .filter((m) => !m.clientStreaming)
130
130
  .map((m) => {
131
- utils_1.assertInstanceOf(m, utils_1.FormattedMethodDescriptor);
131
+ (0, utils_1.assertInstanceOf)(m, utils_1.FormattedMethodDescriptor);
132
132
  return m.formattedName;
133
133
  })
134
134
  .map((n) => `"${n}"`);
135
135
  const grpcStreamMethods = serviceDesc.method
136
136
  .filter((m) => m.clientStreaming)
137
137
  .map((m) => {
138
- utils_1.assertInstanceOf(m, utils_1.FormattedMethodDescriptor);
138
+ (0, utils_1.assertInstanceOf)(m, utils_1.FormattedMethodDescriptor);
139
139
  return m.formattedName;
140
140
  })
141
141
  .map((n) => `"${n}"`);
142
- return ts_poet_1.code `
142
+ return (0, ts_poet_1.code) `
143
143
  export function ${serviceDesc.name}ControllerMethods() {
144
144
  return function(constructor: Function) {
145
145
  const grpcMethods: string[] = [${grpcMethods.join(', ')}];
@@ -6,8 +6,8 @@ const case_1 = require("./case");
6
6
  const sourceInfo_1 = require("./sourceInfo");
7
7
  const types_1 = require("./types");
8
8
  const utils_1 = require("./utils");
9
- const CallOptions = ts_poet_1.imp('CallOptions@nice-grpc-common');
10
- const CallContext = ts_poet_1.imp('CallContext@nice-grpc-common');
9
+ const CallOptions = (0, ts_poet_1.imp)('CallOptions@nice-grpc-common');
10
+ const CallContext = (0, ts_poet_1.imp)('CallContext@nice-grpc-common');
11
11
  /**
12
12
  * Generates server / client stubs for `nice-grpc` library.
13
13
  */
@@ -15,28 +15,28 @@ function generateNiceGrpcService(ctx, fileDesc, sourceInfo, serviceDesc) {
15
15
  const chunks = [];
16
16
  chunks.push(generateServerStub(ctx, sourceInfo, serviceDesc));
17
17
  chunks.push(generateClientStub(ctx, sourceInfo, serviceDesc));
18
- return ts_poet_1.joinCode(chunks, { on: '\n\n' });
18
+ return (0, ts_poet_1.joinCode)(chunks, { on: '\n\n' });
19
19
  }
20
20
  exports.generateNiceGrpcService = generateNiceGrpcService;
21
21
  function generateServerStub(ctx, sourceInfo, serviceDesc) {
22
22
  var _a;
23
23
  const chunks = [];
24
- chunks.push(ts_poet_1.code `export interface ${ts_poet_1.def(`${serviceDesc.name}ServiceImplementation`)}<CallContextExt = {}> {`);
24
+ chunks.push((0, ts_poet_1.code) `export interface ${(0, ts_poet_1.def)(`${serviceDesc.name}ServiceImplementation`)}<CallContextExt = {}> {`);
25
25
  for (const [index, methodDesc] of serviceDesc.method.entries()) {
26
- utils_1.assertInstanceOf(methodDesc, utils_1.FormattedMethodDescriptor);
27
- const inputType = types_1.messageToTypeName(ctx, methodDesc.inputType, { keepValueType: true });
28
- let outputType = types_1.messageToTypeName(ctx, methodDesc.outputType, { keepValueType: true });
26
+ (0, utils_1.assertInstanceOf)(methodDesc, utils_1.FormattedMethodDescriptor);
27
+ const inputType = (0, types_1.messageToTypeName)(ctx, methodDesc.inputType, { keepValueType: true });
28
+ let outputType = (0, types_1.messageToTypeName)(ctx, methodDesc.outputType, { keepValueType: true });
29
29
  if (ctx.options.outputPartialMethods) {
30
- outputType = ts_poet_1.code `${ctx.utils.DeepPartial}<${outputType}>`;
30
+ outputType = (0, ts_poet_1.code) `${ctx.utils.DeepPartial}<${outputType}>`;
31
31
  }
32
32
  const ServerStreamingMethodResult = ctx.utils.NiceGrpcServerStreamingMethodResult;
33
33
  const info = sourceInfo.lookup(sourceInfo_1.Fields.service.method, index);
34
- utils_1.maybeAddComment(info, chunks, (_a = methodDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
34
+ (0, utils_1.maybeAddComment)(info, chunks, (_a = methodDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
35
35
  if (methodDesc.clientStreaming) {
36
36
  if (methodDesc.serverStreaming) {
37
37
  // bidi streaming
38
- chunks.push(ts_poet_1.code `
39
- ${case_1.camelCase(methodDesc.name)}(
38
+ chunks.push((0, ts_poet_1.code) `
39
+ ${(0, case_1.camelCase)(methodDesc.name)}(
40
40
  request: AsyncIterable<${inputType}>,
41
41
  context: ${CallContext} & CallContextExt,
42
42
  ): ${ServerStreamingMethodResult}<${outputType}>;
@@ -44,8 +44,8 @@ function generateServerStub(ctx, sourceInfo, serviceDesc) {
44
44
  }
45
45
  else {
46
46
  // client streaming
47
- chunks.push(ts_poet_1.code `
48
- ${case_1.camelCase(methodDesc.name)}(
47
+ chunks.push((0, ts_poet_1.code) `
48
+ ${(0, case_1.camelCase)(methodDesc.name)}(
49
49
  request: AsyncIterable<${inputType}>,
50
50
  context: ${CallContext} & CallContextExt,
51
51
  ): Promise<${outputType}>;
@@ -55,8 +55,8 @@ function generateServerStub(ctx, sourceInfo, serviceDesc) {
55
55
  else {
56
56
  if (methodDesc.serverStreaming) {
57
57
  // server streaming
58
- chunks.push(ts_poet_1.code `
59
- ${case_1.camelCase(methodDesc.name)}(
58
+ chunks.push((0, ts_poet_1.code) `
59
+ ${(0, case_1.camelCase)(methodDesc.name)}(
60
60
  request: ${inputType},
61
61
  context: ${CallContext} & CallContextExt,
62
62
  ): ${ServerStreamingMethodResult}<${outputType}>;
@@ -64,8 +64,8 @@ function generateServerStub(ctx, sourceInfo, serviceDesc) {
64
64
  }
65
65
  else {
66
66
  // unary
67
- chunks.push(ts_poet_1.code `
68
- ${case_1.camelCase(methodDesc.name)}(
67
+ chunks.push((0, ts_poet_1.code) `
68
+ ${(0, case_1.camelCase)(methodDesc.name)}(
69
69
  request: ${inputType},
70
70
  context: ${CallContext} & CallContextExt,
71
71
  ): Promise<${outputType}>;
@@ -73,27 +73,27 @@ function generateServerStub(ctx, sourceInfo, serviceDesc) {
73
73
  }
74
74
  }
75
75
  }
76
- chunks.push(ts_poet_1.code `}`);
77
- return ts_poet_1.joinCode(chunks, { on: '\n' });
76
+ chunks.push((0, ts_poet_1.code) `}`);
77
+ return (0, ts_poet_1.joinCode)(chunks, { on: '\n' });
78
78
  }
79
79
  function generateClientStub(ctx, sourceInfo, serviceDesc) {
80
80
  var _a;
81
81
  const chunks = [];
82
- chunks.push(ts_poet_1.code `export interface ${ts_poet_1.def(`${serviceDesc.name}Client`)}<CallOptionsExt = {}> {`);
82
+ chunks.push((0, ts_poet_1.code) `export interface ${(0, ts_poet_1.def)(`${serviceDesc.name}Client`)}<CallOptionsExt = {}> {`);
83
83
  for (const [index, methodDesc] of serviceDesc.method.entries()) {
84
- utils_1.assertInstanceOf(methodDesc, utils_1.FormattedMethodDescriptor);
85
- let inputType = types_1.messageToTypeName(ctx, methodDesc.inputType, { keepValueType: true });
84
+ (0, utils_1.assertInstanceOf)(methodDesc, utils_1.FormattedMethodDescriptor);
85
+ let inputType = (0, types_1.messageToTypeName)(ctx, methodDesc.inputType, { keepValueType: true });
86
86
  if (ctx.options.outputPartialMethods) {
87
- inputType = ts_poet_1.code `${ctx.utils.DeepPartial}<${inputType}>`;
87
+ inputType = (0, ts_poet_1.code) `${ctx.utils.DeepPartial}<${inputType}>`;
88
88
  }
89
- const outputType = types_1.messageToTypeName(ctx, methodDesc.outputType, { keepValueType: true });
89
+ const outputType = (0, types_1.messageToTypeName)(ctx, methodDesc.outputType, { keepValueType: true });
90
90
  const info = sourceInfo.lookup(sourceInfo_1.Fields.service.method, index);
91
- utils_1.maybeAddComment(info, chunks, (_a = methodDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
91
+ (0, utils_1.maybeAddComment)(info, chunks, (_a = methodDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
92
92
  if (methodDesc.clientStreaming) {
93
93
  if (methodDesc.serverStreaming) {
94
94
  // bidi streaming
95
- chunks.push(ts_poet_1.code `
96
- ${case_1.camelCase(methodDesc.name)}(
95
+ chunks.push((0, ts_poet_1.code) `
96
+ ${(0, case_1.camelCase)(methodDesc.name)}(
97
97
  request: AsyncIterable<${inputType}>,
98
98
  options?: ${CallOptions} & CallOptionsExt,
99
99
  ): AsyncIterable<${outputType}>;
@@ -101,8 +101,8 @@ function generateClientStub(ctx, sourceInfo, serviceDesc) {
101
101
  }
102
102
  else {
103
103
  // client streaming
104
- chunks.push(ts_poet_1.code `
105
- ${case_1.camelCase(methodDesc.name)}(
104
+ chunks.push((0, ts_poet_1.code) `
105
+ ${(0, case_1.camelCase)(methodDesc.name)}(
106
106
  request: AsyncIterable<${inputType}>,
107
107
  options?: ${CallOptions} & CallOptionsExt,
108
108
  ): Promise<${outputType}>;
@@ -112,8 +112,8 @@ function generateClientStub(ctx, sourceInfo, serviceDesc) {
112
112
  else {
113
113
  if (methodDesc.serverStreaming) {
114
114
  // server streaming
115
- chunks.push(ts_poet_1.code `
116
- ${case_1.camelCase(methodDesc.name)}(
115
+ chunks.push((0, ts_poet_1.code) `
116
+ ${(0, case_1.camelCase)(methodDesc.name)}(
117
117
  request: ${inputType},
118
118
  options?: ${CallOptions} & CallOptionsExt,
119
119
  ): AsyncIterable<${outputType}>;
@@ -121,8 +121,8 @@ function generateClientStub(ctx, sourceInfo, serviceDesc) {
121
121
  }
122
122
  else {
123
123
  // unary
124
- chunks.push(ts_poet_1.code `
125
- ${case_1.camelCase(methodDesc.name)}(
124
+ chunks.push((0, ts_poet_1.code) `
125
+ ${(0, case_1.camelCase)(methodDesc.name)}(
126
126
  request: ${inputType},
127
127
  options?: ${CallOptions} & CallOptionsExt,
128
128
  ): Promise<${outputType}>;
@@ -130,6 +130,6 @@ function generateClientStub(ctx, sourceInfo, serviceDesc) {
130
130
  }
131
131
  }
132
132
  }
133
- chunks.push(ts_poet_1.code `}`);
134
- return ts_poet_1.joinCode(chunks, { on: '\n' });
133
+ chunks.push((0, ts_poet_1.code) `}`);
134
+ return (0, ts_poet_1.joinCode)(chunks, { on: '\n' });
135
135
  }