grpc-dc 0.32.12 → 0.32.13
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/package.json +1 -1
- package/plugin/gen/generators.js +84 -8
package/package.json
CHANGED
package/plugin/gen/generators.js
CHANGED
|
@@ -3628,6 +3628,12 @@ function javaClientStreamClass(m, svc) {
|
|
|
3628
3628
|
+ ' public ' + m.output + ' recv() throws Exception {\n'
|
|
3629
3629
|
+ ' ' + m.output + ' resp = new ' + m.output + '();\n'
|
|
3630
3630
|
+ ' stream.recv(resp);\n return resp;\n }\n\n'
|
|
3631
|
+
+ ' /** Initial metadata (response headers); null until they arrive. */\n'
|
|
3632
|
+
+ ' public Map<String, String> headers() {\n'
|
|
3633
|
+
+ ' return stream.headers() == null ? null : stream.headers().metadata;\n }\n\n'
|
|
3634
|
+
+ ' /** Trailing metadata of the terminal status; null until it arrives. */\n'
|
|
3635
|
+
+ ' public Map<String, String> trailers() {\n'
|
|
3636
|
+
+ ' return stream.trailers();\n }\n\n'
|
|
3631
3637
|
+ ' /** Abort this stream (sends RST, wakes a pending recv). */\n'
|
|
3632
3638
|
+ ' public void cancel() {\n'
|
|
3633
3639
|
+ ' stream.cancel();\n }\n\n'
|
|
@@ -4463,6 +4469,10 @@ function csClientStreamClass(m, svc) {
|
|
|
4463
4469
|
+ ' public ' + m.output + ' Recv()\n {\n'
|
|
4464
4470
|
+ ' var resp = new ' + m.output + '();\n'
|
|
4465
4471
|
+ ' _stream.Recv(resp);\n return resp;\n }\n\n'
|
|
4472
|
+
+ ' /// <summary>Initial metadata (response headers); null until they arrive.</summary>\n'
|
|
4473
|
+
+ ' public Dictionary<string, string> Headers => _stream.Headers?.Metadata;\n\n'
|
|
4474
|
+
+ ' /// <summary>Trailing metadata of the terminal status; null until it arrives.</summary>\n'
|
|
4475
|
+
+ ' public Dictionary<string, string> Trailers => _stream.Trailers;\n\n'
|
|
4466
4476
|
+ ' /// <summary>Abort this stream (sends RST, wakes a pending Recv).</summary>\n'
|
|
4467
4477
|
+ ' public void Cancel() => _stream.Cancel();\n\n'
|
|
4468
4478
|
+ ' /// <summary>Abandon the call if still live (RST); no-op once terminated.</summary>\n'
|
|
@@ -4692,10 +4702,26 @@ function cspFindOwner(model, f) {
|
|
|
4692
4702
|
function cspFieldName(model, f) {
|
|
4693
4703
|
const n = cspPascal(f.name);
|
|
4694
4704
|
const owner = cspFindOwner(model, f);
|
|
4695
|
-
if (owner && (owner.nested.some((m) => m.name === n) || owner.enums.some((e) => e.name === n))) return n + '_';
|
|
4705
|
+
if (owner && (owner.name === n || owner.nested.some((m) => m.name === n) || owner.enums.some((e) => e.name === n))) return n + '_';
|
|
4696
4706
|
return n;
|
|
4697
4707
|
}
|
|
4698
4708
|
|
|
4709
|
+
function csQualifyType(pkg, simple, full) {
|
|
4710
|
+
if (!full || !pkg || full.startsWith(pkg + '.')) return simple;
|
|
4711
|
+
return full[0].toUpperCase() + full.slice(1);
|
|
4712
|
+
}
|
|
4713
|
+
|
|
4714
|
+
function csQualifyServices(pkg, services) {
|
|
4715
|
+
return services.map((svc) => ({
|
|
4716
|
+
...svc,
|
|
4717
|
+
methods: svc.methods.map((m) => ({
|
|
4718
|
+
...m,
|
|
4719
|
+
input: csQualifyType(pkg, m.input, m.inputFull),
|
|
4720
|
+
output: csQualifyType(pkg, m.output, m.outputFull),
|
|
4721
|
+
})),
|
|
4722
|
+
}));
|
|
4723
|
+
}
|
|
4724
|
+
|
|
4699
4725
|
function cspResolve(model, typeName) {
|
|
4700
4726
|
const entry = model.types.get(typeName);
|
|
4701
4727
|
if (!entry) throw new Error('unresolved type ' + typeName);
|
|
@@ -5175,7 +5201,7 @@ function emitCsharpFile(model, params) {
|
|
|
5175
5201
|
+ 'namespace ' + ns + ';\n\n'
|
|
5176
5202
|
+ '/// <summary>Generated gRPC-over-DataChannels stubs for ' + model.name + '.</summary>\n'
|
|
5177
5203
|
+ 'public static class ' + className + '\n{\n'
|
|
5178
|
-
+ model.services.map(csService).join('')
|
|
5204
|
+
+ csQualifyServices(model.package, model.services).map(csService).join('')
|
|
5179
5205
|
+ '}\n',
|
|
5180
5206
|
};
|
|
5181
5207
|
const pbFiles = emitCsharpPbFiles(model);
|
|
@@ -6821,6 +6847,10 @@ function kotlinClientStreamClass(m, svc) {
|
|
|
6821
6847
|
+ ' fun recv(): ' + m.output + ' {\n'
|
|
6822
6848
|
+ ' val resp = ' + m.output + '()\n'
|
|
6823
6849
|
+ ' stream.recv(resp)\n return resp\n }\n\n'
|
|
6850
|
+
+ ' /** Initial metadata (response headers); null until they arrive. */\n'
|
|
6851
|
+
+ ' fun headers(): Map<String, String>? = stream.headers?.metadata\n\n'
|
|
6852
|
+
+ ' /** Trailing metadata of the terminal status; null until it arrives. */\n'
|
|
6853
|
+
+ ' fun trailers(): Map<String, String>? = stream.trailers\n\n'
|
|
6824
6854
|
+ ' /** Abort this stream (sends RST, wakes a pending recv). */\n'
|
|
6825
6855
|
+ ' fun cancel() = stream.cancel()\n\n'
|
|
6826
6856
|
+ ' /** Abandon the call if still live (RST); no-op once terminated. */\n'
|
|
@@ -7030,9 +7060,9 @@ function kotlinService(svc) {
|
|
|
7030
7060
|
+ ' // Adapters are retained for the process lifetime: registration is\n'
|
|
7031
7061
|
+ ' // once-per-process and bounded by service count.\n'
|
|
7032
7062
|
+ ' val adapter = ' + sname + 'ServerAsyncAdapter(impl)\n'
|
|
7033
|
-
+ '
|
|
7063
|
+
+ ' ' + lowerFirst(sname) + 'Adapters.add(adapter)\n'
|
|
7034
7064
|
+ ' register' + sname + 'Server(server, adapter)\n }\n\n'
|
|
7035
|
-
+ ' private val
|
|
7065
|
+
+ ' private val ' + lowerFirst(sname) + 'Adapters = ArrayList<' + sname + 'ServerAsyncAdapter>()\n');
|
|
7036
7066
|
}
|
|
7037
7067
|
|
|
7038
7068
|
|
|
@@ -7510,6 +7540,22 @@ function emitKotlinPbFile(model) {
|
|
|
7510
7540
|
return { name: pascalName(base) + 'Messages.kt', content };
|
|
7511
7541
|
}
|
|
7512
7542
|
|
|
7543
|
+
function kotlinQualifyType(pkg, simple, full) {
|
|
7544
|
+
if (!full || !pkg || full.startsWith(pkg + '.')) return simple;
|
|
7545
|
+
return full;
|
|
7546
|
+
}
|
|
7547
|
+
|
|
7548
|
+
function kotlinQualifyServices(pkg, services) {
|
|
7549
|
+
return services.map((svc) => ({
|
|
7550
|
+
...svc,
|
|
7551
|
+
methods: svc.methods.map((m) => ({
|
|
7552
|
+
...m,
|
|
7553
|
+
input: kotlinQualifyType(pkg, m.input, m.inputFull),
|
|
7554
|
+
output: kotlinQualifyType(pkg, m.output, m.outputFull),
|
|
7555
|
+
})),
|
|
7556
|
+
}));
|
|
7557
|
+
}
|
|
7558
|
+
|
|
7513
7559
|
function emitKotlinFile(model, params) {
|
|
7514
7560
|
const base = baseName(model.name);
|
|
7515
7561
|
const objectName = pascalName(base) + 'GrpcDc';
|
|
@@ -7523,7 +7569,7 @@ function emitKotlinFile(model, params) {
|
|
|
7523
7569
|
+ 'import java.io.EOFException\nimport java.util.concurrent.CompletableFuture\n\n'
|
|
7524
7570
|
+ '/** Generated gRPC-over-DataChannels stubs for ' + model.name + '. */\n'
|
|
7525
7571
|
+ 'object ' + objectName + ' {\n'
|
|
7526
|
-
+ model.services.map(kotlinService).join('')
|
|
7572
|
+
+ kotlinQualifyServices(model.package, model.services).map(kotlinService).join('')
|
|
7527
7573
|
+ '}\n',
|
|
7528
7574
|
};
|
|
7529
7575
|
const pbFile = emitKotlinPbFile(model);
|
|
@@ -11076,7 +11122,11 @@ function scalaService(svc) {
|
|
|
11076
11122
|
+ ' out\n'
|
|
11077
11123
|
+ ' }\n'
|
|
11078
11124
|
+ ' def cancel(): Unit = stream.cancel()\n'
|
|
11079
|
-
+ ' def close(): Unit = stream.close()\n
|
|
11125
|
+
+ ' def close(): Unit = stream.close()\n'
|
|
11126
|
+
+ ' /** Initial metadata (response headers); null until they arrive. */\n'
|
|
11127
|
+
+ ' def headers: Map[String, String] = if (stream.headers == null) null else stream.headers.metadata\n'
|
|
11128
|
+
+ ' /** Trailing metadata of the terminal status; null until it arrives. */\n'
|
|
11129
|
+
+ ' def trailers: Map[String, String] = stream.trailers\n }\n\n';
|
|
11080
11130
|
return ' /** Client for ' + svc.fullName + '. */\n'
|
|
11081
11131
|
+ ' class ' + sname + 'Client(private val channel: grpcdc.Channel) {\n'
|
|
11082
11132
|
+ classOutputs('server-streaming').map((out) => streamClass('server-streaming', out)).join('')
|
|
@@ -11140,8 +11190,18 @@ function scpCamel(s) {
|
|
|
11140
11190
|
return parts[0] + parts.slice(1).map((p) => (p ? p[0].toUpperCase() + p.slice(1) : '')).join('');
|
|
11141
11191
|
}
|
|
11142
11192
|
|
|
11193
|
+
const SCP_KEYWORDS = new Set([
|
|
11194
|
+
'abstract', 'case', 'catch', 'class', 'def', 'do', 'else', 'extends',
|
|
11195
|
+
'false', 'final', 'finally', 'for', 'forSome', 'if', 'implicit',
|
|
11196
|
+
'import', 'lazy', 'match', 'new', 'null', 'object', 'override',
|
|
11197
|
+
'package', 'private', 'protected', 'return', 'sealed', 'super',
|
|
11198
|
+
'this', 'throw', 'trait', 'try', 'true', 'type', 'val', 'var',
|
|
11199
|
+
'while', 'with', 'yield',
|
|
11200
|
+
]);
|
|
11201
|
+
|
|
11143
11202
|
function scpFieldName(f) {
|
|
11144
|
-
|
|
11203
|
+
const n = f.jsonName ? f.jsonName : scpCamel(f.name);
|
|
11204
|
+
return SCP_KEYWORDS.has(n) ? '`' + n + '`' : n;
|
|
11145
11205
|
}
|
|
11146
11206
|
|
|
11147
11207
|
function scpFlat(pkg, full) {
|
|
@@ -11524,6 +11584,22 @@ function emitScalaPbFile(model) {
|
|
|
11524
11584
|
return { name: pascalName(base) + 'Messages.scala', content };
|
|
11525
11585
|
}
|
|
11526
11586
|
|
|
11587
|
+
function scalaQualifyType(pkg, simple, full) {
|
|
11588
|
+
if (!full || !pkg || full.startsWith(pkg + '.')) return simple;
|
|
11589
|
+
return full;
|
|
11590
|
+
}
|
|
11591
|
+
|
|
11592
|
+
function scalaQualifyServices(pkg, services) {
|
|
11593
|
+
return services.map((svc) => ({
|
|
11594
|
+
...svc,
|
|
11595
|
+
methods: svc.methods.map((m) => ({
|
|
11596
|
+
...m,
|
|
11597
|
+
input: scalaQualifyType(pkg, m.input, m.inputFull),
|
|
11598
|
+
output: scalaQualifyType(pkg, m.output, m.outputFull),
|
|
11599
|
+
})),
|
|
11600
|
+
}));
|
|
11601
|
+
}
|
|
11602
|
+
|
|
11527
11603
|
function emitScalaFile(model, params) {
|
|
11528
11604
|
const base = baseName(model.name);
|
|
11529
11605
|
const objName = camelName(base) + 'GrpcDc';
|
|
@@ -11534,7 +11610,7 @@ function emitScalaFile(model, params) {
|
|
|
11534
11610
|
+ 'package ' + model.package + '\n\n'
|
|
11535
11611
|
+ '/** Generated gRPC-over-DataChannels stubs. */\n'
|
|
11536
11612
|
+ 'object ' + objName + ' {\n'
|
|
11537
|
-
+ model.services.map(scalaService).join('')
|
|
11613
|
+
+ scalaQualifyServices(model.package, model.services).map(scalaService).join('')
|
|
11538
11614
|
+ '}\n',
|
|
11539
11615
|
};
|
|
11540
11616
|
const pbFile = emitScalaPbFile(model);
|