@celljs/grpc 0.0.0-stage → 4.3.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/README.md +123 -2
- package/cell.yml +12 -0
- package/esm/node/call/async-queue.d.ts +31 -0
- package/esm/node/call/async-queue.js +80 -0
- package/esm/node/call/async-queue.js.map +1 -0
- package/esm/node/call/grpc-status.d.ts +33 -0
- package/esm/node/call/grpc-status.js +48 -0
- package/esm/node/call/grpc-status.js.map +1 -0
- package/esm/node/call/message-framer.d.ts +24 -0
- package/esm/node/call/message-framer.js +105 -0
- package/esm/node/call/message-framer.js.map +1 -0
- package/esm/node/call/metadata.d.ts +15 -0
- package/esm/node/call/metadata.js +81 -0
- package/esm/node/call/metadata.js.map +1 -0
- package/esm/node/client/grpc-channel.d.ts +64 -0
- package/esm/node/client/grpc-channel.js +285 -0
- package/esm/node/client/grpc-channel.js.map +1 -0
- package/esm/node/codec/proto-reader.d.ts +26 -0
- package/esm/node/codec/proto-reader.js +153 -0
- package/esm/node/codec/proto-reader.js.map +1 -0
- package/esm/node/codec/proto-writer.d.ts +29 -0
- package/esm/node/codec/proto-writer.js +150 -0
- package/esm/node/codec/proto-writer.js.map +1 -0
- package/esm/node/index.d.ts +15 -0
- package/esm/node/index.js +16 -0
- package/esm/node/index.js.map +1 -0
- package/esm/node/module.d.ts +3 -0
- package/esm/node/module.js +4 -0
- package/esm/node/module.js.map +1 -0
- package/esm/node/proto/proto-ast.d.ts +46 -0
- package/esm/node/proto/proto-ast.js +2 -0
- package/esm/node/proto/proto-ast.js.map +1 -0
- package/esm/node/proto/proto-parser.d.ts +45 -0
- package/esm/node/proto/proto-parser.js +451 -0
- package/esm/node/proto/proto-parser.js.map +1 -0
- package/esm/node/proto/proto-types.d.ts +76 -0
- package/esm/node/proto/proto-types.js +444 -0
- package/esm/node/proto/proto-types.js.map +1 -0
- package/esm/node/proto/proto.d.ts +57 -0
- package/esm/node/proto/proto.js +174 -0
- package/esm/node/proto/proto.js.map +1 -0
- package/esm/node/proto/well-known.d.ts +5 -0
- package/esm/node/proto/well-known.js +41 -0
- package/esm/node/proto/well-known.js.map +1 -0
- package/esm/node/server/grpc-server-lifecycle.d.ts +21 -0
- package/esm/node/server/grpc-server-lifecycle.js +65 -0
- package/esm/node/server/grpc-server-lifecycle.js.map +1 -0
- package/esm/node/server/grpc-server.d.ts +60 -0
- package/esm/node/server/grpc-server.js +312 -0
- package/esm/node/server/grpc-server.js.map +1 -0
- package/esm/node/server/grpc-service.d.ts +24 -0
- package/esm/node/server/grpc-service.js +38 -0
- package/esm/node/server/grpc-service.js.map +1 -0
- package/esm/node/test/proto-loader.d.ts +2 -0
- package/esm/node/test/proto-loader.js +13 -0
- package/esm/node/test/proto-loader.js.map +1 -0
- package/esm/node/test/test-protos.d.ts +28 -0
- package/esm/node/test/test-protos.js +145 -0
- package/esm/node/test/test-protos.js.map +1 -0
- package/esm/package.json +3 -0
- package/lib/node/call/async-queue.d.ts +32 -0
- package/lib/node/call/async-queue.d.ts.map +1 -0
- package/lib/node/call/async-queue.js +84 -0
- package/lib/node/call/async-queue.js.map +1 -0
- package/lib/node/call/grpc-status.d.ts +34 -0
- package/lib/node/call/grpc-status.d.ts.map +1 -0
- package/lib/node/call/grpc-status.js +52 -0
- package/lib/node/call/grpc-status.js.map +1 -0
- package/lib/node/call/message-framer.d.ts +25 -0
- package/lib/node/call/message-framer.d.ts.map +1 -0
- package/lib/node/call/message-framer.js +109 -0
- package/lib/node/call/message-framer.js.map +1 -0
- package/lib/node/call/metadata.d.ts +16 -0
- package/lib/node/call/metadata.d.ts.map +1 -0
- package/lib/node/call/metadata.js +84 -0
- package/lib/node/call/metadata.js.map +1 -0
- package/lib/node/client/grpc-channel.d.ts +65 -0
- package/lib/node/client/grpc-channel.d.ts.map +1 -0
- package/lib/node/client/grpc-channel.js +289 -0
- package/lib/node/client/grpc-channel.js.map +1 -0
- package/lib/node/codec/proto-reader.d.ts +27 -0
- package/lib/node/codec/proto-reader.d.ts.map +1 -0
- package/lib/node/codec/proto-reader.js +157 -0
- package/lib/node/codec/proto-reader.js.map +1 -0
- package/lib/node/codec/proto-writer.d.ts +30 -0
- package/lib/node/codec/proto-writer.d.ts.map +1 -0
- package/lib/node/codec/proto-writer.js +154 -0
- package/lib/node/codec/proto-writer.js.map +1 -0
- package/lib/node/grpc.spec.d.ts +2 -0
- package/lib/node/grpc.spec.d.ts.map +1 -0
- package/lib/node/grpc.spec.js +148 -0
- package/lib/node/grpc.spec.js.map +1 -0
- package/lib/node/index.d.ts +16 -0
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +32 -0
- package/lib/node/index.js.map +1 -0
- package/lib/node/interop.spec.d.ts +2 -0
- package/lib/node/interop.spec.d.ts.map +1 -0
- package/lib/node/interop.spec.js +194 -0
- package/lib/node/interop.spec.js.map +1 -0
- package/lib/node/module.d.ts +4 -0
- package/lib/node/module.d.ts.map +1 -0
- package/lib/node/module.js +6 -0
- package/lib/node/module.js.map +1 -0
- package/lib/node/proto/proto-ast.d.ts +47 -0
- package/lib/node/proto/proto-ast.d.ts.map +1 -0
- package/lib/node/proto/proto-ast.js +3 -0
- package/lib/node/proto/proto-ast.js.map +1 -0
- package/lib/node/proto/proto-parser.d.ts +46 -0
- package/lib/node/proto/proto-parser.d.ts.map +1 -0
- package/lib/node/proto/proto-parser.js +455 -0
- package/lib/node/proto/proto-parser.js.map +1 -0
- package/lib/node/proto/proto-parser.spec.d.ts +2 -0
- package/lib/node/proto/proto-parser.spec.d.ts.map +1 -0
- package/lib/node/proto/proto-parser.spec.js +95 -0
- package/lib/node/proto/proto-parser.spec.js.map +1 -0
- package/lib/node/proto/proto-types.d.ts +77 -0
- package/lib/node/proto/proto-types.d.ts.map +1 -0
- package/lib/node/proto/proto-types.js +449 -0
- package/lib/node/proto/proto-types.js.map +1 -0
- package/lib/node/proto/proto-types.spec.d.ts +2 -0
- package/lib/node/proto/proto-types.spec.d.ts.map +1 -0
- package/lib/node/proto/proto-types.spec.js +120 -0
- package/lib/node/proto/proto-types.spec.js.map +1 -0
- package/lib/node/proto/proto.d.ts +58 -0
- package/lib/node/proto/proto.d.ts.map +1 -0
- package/lib/node/proto/proto.js +178 -0
- package/lib/node/proto/proto.js.map +1 -0
- package/lib/node/proto/well-known.d.ts +6 -0
- package/lib/node/proto/well-known.d.ts.map +1 -0
- package/lib/node/proto/well-known.js +44 -0
- package/lib/node/proto/well-known.js.map +1 -0
- package/lib/node/server/grpc-server-lifecycle.d.ts +22 -0
- package/lib/node/server/grpc-server-lifecycle.d.ts.map +1 -0
- package/lib/node/server/grpc-server-lifecycle.js +68 -0
- package/lib/node/server/grpc-server-lifecycle.js.map +1 -0
- package/lib/node/server/grpc-server-lifecycle.spec.d.ts +2 -0
- package/lib/node/server/grpc-server-lifecycle.spec.d.ts.map +1 -0
- package/lib/node/server/grpc-server-lifecycle.spec.js +100 -0
- package/lib/node/server/grpc-server-lifecycle.spec.js.map +1 -0
- package/lib/node/server/grpc-server.d.ts +61 -0
- package/lib/node/server/grpc-server.d.ts.map +1 -0
- package/lib/node/server/grpc-server.js +316 -0
- package/lib/node/server/grpc-server.js.map +1 -0
- package/lib/node/server/grpc-service.d.ts +25 -0
- package/lib/node/server/grpc-service.d.ts.map +1 -0
- package/lib/node/server/grpc-service.js +42 -0
- package/lib/node/server/grpc-service.js.map +1 -0
- package/lib/node/test/proto-loader.d.ts +3 -0
- package/lib/node/test/proto-loader.d.ts.map +1 -0
- package/lib/node/test/proto-loader.js +16 -0
- package/lib/node/test/proto-loader.js.map +1 -0
- package/lib/node/test/test-protos.d.ts +29 -0
- package/lib/node/test/test-protos.d.ts.map +1 -0
- package/lib/node/test/test-protos.js +150 -0
- package/lib/node/test/test-protos.js.map +1 -0
- package/lib/package.spec.d.ts +2 -0
- package/lib/package.spec.d.ts.map +1 -0
- package/lib/package.spec.js +7 -0
- package/lib/package.spec.js.map +1 -0
- package/package.json +69 -4
- package/src/node/call/async-queue.ts +79 -0
- package/src/node/call/grpc-status.ts +49 -0
- package/src/node/call/message-framer.ts +109 -0
- package/src/node/call/metadata.ts +85 -0
- package/src/node/client/grpc-channel.ts +327 -0
- package/src/node/codec/proto-reader.ts +172 -0
- package/src/node/codec/proto-writer.ts +170 -0
- package/src/node/grpc.spec.ts +160 -0
- package/src/node/index.ts +15 -0
- package/src/node/interop.spec.ts +174 -0
- package/src/node/module.ts +4 -0
- package/src/node/proto/proto-ast.ts +48 -0
- package/src/node/proto/proto-parser.spec.ts +104 -0
- package/src/node/proto/proto-parser.ts +477 -0
- package/src/node/proto/proto-types.spec.ts +128 -0
- package/src/node/proto/proto-types.ts +497 -0
- package/src/node/proto/proto.ts +218 -0
- package/src/node/proto/well-known.ts +40 -0
- package/src/node/server/grpc-server-lifecycle.spec.ts +88 -0
- package/src/node/server/grpc-server-lifecycle.ts +56 -0
- package/src/node/server/grpc-server.ts +368 -0
- package/src/node/server/grpc-service.ts +40 -0
- package/src/node/test/proto-loader.ts +13 -0
- package/src/node/test/test-protos.ts +159 -0
- package/src/package.spec.ts +5 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
const encoder = new TextEncoder();
|
|
2
|
+
/** Writes the protobuf binary format into a growing buffer. */
|
|
3
|
+
export class ProtoWriter {
|
|
4
|
+
constructor(initialSize = 64) {
|
|
5
|
+
this.pos = 0;
|
|
6
|
+
this.buf = new Uint8Array(initialSize);
|
|
7
|
+
this.view = new DataView(this.buf.buffer);
|
|
8
|
+
}
|
|
9
|
+
tag(fieldNumber, wireType) {
|
|
10
|
+
this.uint32(((fieldNumber << 3) | wireType) >>> 0);
|
|
11
|
+
}
|
|
12
|
+
uint32(value) {
|
|
13
|
+
this.ensure(5);
|
|
14
|
+
const buf = this.buf;
|
|
15
|
+
let v = value >>> 0;
|
|
16
|
+
while (v > 127) {
|
|
17
|
+
buf[this.pos++] = (v & 127) | 128;
|
|
18
|
+
v >>>= 7;
|
|
19
|
+
}
|
|
20
|
+
buf[this.pos++] = v;
|
|
21
|
+
}
|
|
22
|
+
int32(value) {
|
|
23
|
+
if (value >= 0) {
|
|
24
|
+
this.uint32(value);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
// Negative int32 values are sign-extended to 64 bits: always 10 bytes.
|
|
28
|
+
this.ensure(10);
|
|
29
|
+
const buf = this.buf;
|
|
30
|
+
let v = value >>> 0;
|
|
31
|
+
for (let i = 0; i < 4; i++) {
|
|
32
|
+
buf[this.pos++] = (v & 127) | 128;
|
|
33
|
+
v >>>= 7;
|
|
34
|
+
}
|
|
35
|
+
buf[this.pos++] = (v & 15) | 0xf0;
|
|
36
|
+
for (let i = 0; i < 4; i++) {
|
|
37
|
+
buf[this.pos++] = 0xff;
|
|
38
|
+
}
|
|
39
|
+
buf[this.pos++] = 1;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
sint32(value) {
|
|
43
|
+
this.uint32((value << 1) ^ (value >> 31));
|
|
44
|
+
}
|
|
45
|
+
bool(value) {
|
|
46
|
+
this.ensure(1);
|
|
47
|
+
this.buf[this.pos++] = value ? 1 : 0;
|
|
48
|
+
}
|
|
49
|
+
/** An unsigned 64-bit varint; `value` must be in [0, 2^64). */
|
|
50
|
+
varint64(value) {
|
|
51
|
+
if (value < 0x80000000) {
|
|
52
|
+
this.uint32(Number(value));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this.ensure(10);
|
|
56
|
+
let v = value;
|
|
57
|
+
while (v > 127) {
|
|
58
|
+
this.buf[this.pos++] = Number(v & BigInt(127)) | 128;
|
|
59
|
+
v >>= BigInt(7);
|
|
60
|
+
}
|
|
61
|
+
this.buf[this.pos++] = Number(v);
|
|
62
|
+
}
|
|
63
|
+
fixed32(value) {
|
|
64
|
+
this.ensure(4);
|
|
65
|
+
this.view.setUint32(this.pos, value >>> 0, true);
|
|
66
|
+
this.pos += 4;
|
|
67
|
+
}
|
|
68
|
+
sfixed32(value) {
|
|
69
|
+
this.ensure(4);
|
|
70
|
+
this.view.setInt32(this.pos, value | 0, true);
|
|
71
|
+
this.pos += 4;
|
|
72
|
+
}
|
|
73
|
+
float(value) {
|
|
74
|
+
this.ensure(4);
|
|
75
|
+
this.view.setFloat32(this.pos, value, true);
|
|
76
|
+
this.pos += 4;
|
|
77
|
+
}
|
|
78
|
+
double(value) {
|
|
79
|
+
this.ensure(8);
|
|
80
|
+
this.view.setFloat64(this.pos, value, true);
|
|
81
|
+
this.pos += 8;
|
|
82
|
+
}
|
|
83
|
+
fixed64(value) {
|
|
84
|
+
this.ensure(8);
|
|
85
|
+
this.view.setBigUint64(this.pos, value, true);
|
|
86
|
+
this.pos += 8;
|
|
87
|
+
}
|
|
88
|
+
sfixed64(value) {
|
|
89
|
+
this.ensure(8);
|
|
90
|
+
this.view.setBigInt64(this.pos, value, true);
|
|
91
|
+
this.pos += 8;
|
|
92
|
+
}
|
|
93
|
+
bytes(value) {
|
|
94
|
+
this.uint32(value.length);
|
|
95
|
+
this.ensure(value.length);
|
|
96
|
+
this.buf.set(value, this.pos);
|
|
97
|
+
this.pos += value.length;
|
|
98
|
+
}
|
|
99
|
+
string(value) {
|
|
100
|
+
var _a;
|
|
101
|
+
const start = this.fork();
|
|
102
|
+
this.ensure(value.length * 3);
|
|
103
|
+
this.pos += (_a = encoder.encodeInto(value, this.buf.subarray(this.pos)).written) !== null && _a !== void 0 ? _a : 0;
|
|
104
|
+
this.ldelim(start);
|
|
105
|
+
}
|
|
106
|
+
/** Starts a length-delimited value; finish it with {@link ldelim}. */
|
|
107
|
+
fork() {
|
|
108
|
+
this.ensure(1);
|
|
109
|
+
return this.pos++;
|
|
110
|
+
}
|
|
111
|
+
/** Writes the length of the value started at `start` by {@link fork}, moving the value when the length needs more than one byte. */
|
|
112
|
+
ldelim(start) {
|
|
113
|
+
const length = this.pos - start - 1;
|
|
114
|
+
if (length < 128) {
|
|
115
|
+
this.buf[start] = length;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
let size = 1;
|
|
119
|
+
for (let v = length >>> 7; v > 0; v >>>= 7) {
|
|
120
|
+
size++;
|
|
121
|
+
}
|
|
122
|
+
this.ensure(size - 1);
|
|
123
|
+
const buf = this.buf;
|
|
124
|
+
buf.copyWithin(start + size, start + 1, this.pos);
|
|
125
|
+
this.pos += size - 1;
|
|
126
|
+
let p = start;
|
|
127
|
+
let v = length;
|
|
128
|
+
while (v > 127) {
|
|
129
|
+
buf[p++] = (v & 127) | 128;
|
|
130
|
+
v >>>= 7;
|
|
131
|
+
}
|
|
132
|
+
buf[p] = v;
|
|
133
|
+
}
|
|
134
|
+
skip(count) {
|
|
135
|
+
this.ensure(count);
|
|
136
|
+
this.pos += count;
|
|
137
|
+
}
|
|
138
|
+
finish() {
|
|
139
|
+
return this.buf.subarray(0, this.pos);
|
|
140
|
+
}
|
|
141
|
+
ensure(count) {
|
|
142
|
+
if (this.pos + count > this.buf.length) {
|
|
143
|
+
const buf = new Uint8Array(Math.max(this.buf.length * 2, this.pos + count));
|
|
144
|
+
buf.set(this.buf.subarray(0, this.pos));
|
|
145
|
+
this.buf = buf;
|
|
146
|
+
this.view = new DataView(buf.buffer);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=proto-writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proto-writer.js","sourceRoot":"","sources":["../../../src/node/codec/proto-writer.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,+DAA+D;AAC/D,MAAM,OAAO,WAAW;IAKpB,YAAY,WAAW,GAAG,EAAE;QAF5B,QAAG,GAAG,CAAC,CAAC;QAGJ,IAAI,CAAC,GAAG,GAAG,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IAED,GAAG,CAAC,WAAmB,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AAC,CAAC;YACxC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;YACf,IAAI,CAAC,IAAI,GAAG,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACzC,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './call/async-queue.js';
|
|
2
|
+
export * from './call/grpc-status.js';
|
|
3
|
+
export * from './call/message-framer.js';
|
|
4
|
+
export * from './call/metadata.js';
|
|
5
|
+
export * from './client/grpc-channel.js';
|
|
6
|
+
export * from './codec/proto-reader.js';
|
|
7
|
+
export * from './codec/proto-writer.js';
|
|
8
|
+
export * from './proto/proto.js';
|
|
9
|
+
export * from './proto/proto-ast.js';
|
|
10
|
+
export * from './proto/proto-parser.js';
|
|
11
|
+
export * from './proto/proto-types.js';
|
|
12
|
+
export * from './proto/well-known.js';
|
|
13
|
+
export * from './server/grpc-server.js';
|
|
14
|
+
export * from './server/grpc-server-lifecycle.js';
|
|
15
|
+
export * from './server/grpc-service.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './call/async-queue.js';
|
|
2
|
+
export * from './call/grpc-status.js';
|
|
3
|
+
export * from './call/message-framer.js';
|
|
4
|
+
export * from './call/metadata.js';
|
|
5
|
+
export * from './client/grpc-channel.js';
|
|
6
|
+
export * from './codec/proto-reader.js';
|
|
7
|
+
export * from './codec/proto-writer.js';
|
|
8
|
+
export * from './proto/proto.js';
|
|
9
|
+
export * from './proto/proto-ast.js';
|
|
10
|
+
export * from './proto/proto-parser.js';
|
|
11
|
+
export * from './proto/proto-types.js';
|
|
12
|
+
export * from './proto/well-known.js';
|
|
13
|
+
export * from './server/grpc-server.js';
|
|
14
|
+
export * from './server/grpc-server-lifecycle.js';
|
|
15
|
+
export * from './server/grpc-service.js';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/node/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,SAAS,CAAC;AAEjB,eAAe,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** What {@link ProtoParser} reads from one .proto file, before type references are resolved. */
|
|
2
|
+
export interface ProtoFileAst {
|
|
3
|
+
syntax: 'proto2' | 'proto3';
|
|
4
|
+
package: string;
|
|
5
|
+
imports: string[];
|
|
6
|
+
messages: MessageAst[];
|
|
7
|
+
enums: EnumAst[];
|
|
8
|
+
services: ServiceAst[];
|
|
9
|
+
}
|
|
10
|
+
export interface MessageAst {
|
|
11
|
+
name: string;
|
|
12
|
+
fields: FieldAst[];
|
|
13
|
+
oneofs: string[];
|
|
14
|
+
messages: MessageAst[];
|
|
15
|
+
enums: EnumAst[];
|
|
16
|
+
}
|
|
17
|
+
export interface FieldAst {
|
|
18
|
+
name: string;
|
|
19
|
+
number: number;
|
|
20
|
+
/** A scalar type name (`int32`, `string`...) or a message / enum reference as written. */
|
|
21
|
+
type: string;
|
|
22
|
+
rule?: 'repeated' | 'optional' | 'required';
|
|
23
|
+
/** Key type of a `map<K, V>` field; `type` is then the value type. */
|
|
24
|
+
keyType?: string;
|
|
25
|
+
oneof?: string;
|
|
26
|
+
/** `[packed = ...]`, when given. */
|
|
27
|
+
packed?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface EnumAst {
|
|
30
|
+
name: string;
|
|
31
|
+
values: {
|
|
32
|
+
name: string;
|
|
33
|
+
number: number;
|
|
34
|
+
}[];
|
|
35
|
+
}
|
|
36
|
+
export interface ServiceAst {
|
|
37
|
+
name: string;
|
|
38
|
+
methods: MethodAst[];
|
|
39
|
+
}
|
|
40
|
+
export interface MethodAst {
|
|
41
|
+
name: string;
|
|
42
|
+
requestType: string;
|
|
43
|
+
requestStream: boolean;
|
|
44
|
+
responseType: string;
|
|
45
|
+
responseStream: boolean;
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proto-ast.js","sourceRoot":"","sources":["../../../src/node/proto/proto-ast.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { EnumAst, FieldAst, MessageAst, MethodAst, ProtoFileAst, ServiceAst } from './proto-ast.js';
|
|
2
|
+
interface Token {
|
|
3
|
+
kind: 'ident' | 'number' | 'string' | 'symbol';
|
|
4
|
+
value: string;
|
|
5
|
+
line: number;
|
|
6
|
+
column: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Parses the text of a .proto file (proto2 or proto3) into a {@link ProtoFileAst}: messages (nested,
|
|
10
|
+
* `oneof`, `map<K, V>`), enums and services. Options, `reserved`, `extensions` and `extend` blocks are
|
|
11
|
+
* read and skipped; groups and editions are rejected.
|
|
12
|
+
*/
|
|
13
|
+
export declare class ProtoParser {
|
|
14
|
+
protected readonly source: string;
|
|
15
|
+
protected readonly fileName: string;
|
|
16
|
+
protected readonly tokens: Token[];
|
|
17
|
+
protected pos: number;
|
|
18
|
+
constructor(source: string, fileName?: string);
|
|
19
|
+
static parse(source: string, fileName?: string): ProtoFileAst;
|
|
20
|
+
parseFile(): ProtoFileAst;
|
|
21
|
+
protected parseMessage(): MessageAst;
|
|
22
|
+
protected parseField(): FieldAst;
|
|
23
|
+
protected parseEnum(): EnumAst;
|
|
24
|
+
protected parseService(): ServiceAst;
|
|
25
|
+
protected parseMethod(): MethodAst;
|
|
26
|
+
protected methodType(): [boolean, string];
|
|
27
|
+
protected optionName(): string;
|
|
28
|
+
protected optionValue(): string;
|
|
29
|
+
/** Skips the rest of an `option`, `reserved` or `extensions` statement, aggregate values included. */
|
|
30
|
+
protected skipStatement(): void;
|
|
31
|
+
/** Skips a `{ ... }` block, nested blocks included. */
|
|
32
|
+
protected skipBlock(): void;
|
|
33
|
+
protected skipUntil(symbol: string): void;
|
|
34
|
+
protected ident(): string;
|
|
35
|
+
protected string(): string;
|
|
36
|
+
protected integer(): number;
|
|
37
|
+
protected accept(value: string): boolean;
|
|
38
|
+
protected expect(symbol: string): void;
|
|
39
|
+
protected peek(offset?: number): Token;
|
|
40
|
+
protected next(): Token;
|
|
41
|
+
protected endToken(): Token;
|
|
42
|
+
protected fail(message: string, token: Token): never;
|
|
43
|
+
protected tokenize(): Token[];
|
|
44
|
+
}
|
|
45
|
+
export {};
|