@tabnas/proto 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 jsonicjs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # @tabnas/proto
2
+
3
+ Parse Protocol Buffers `.proto` IDL — **proto2, proto3, and editions 2023
4
+ / 2024** — into [FileDescriptorProto][fdp]-shaped JSON, using the
5
+ [Tabnas](https://github.com/tabnas/parser) parser driven by an
6
+ [ABNF](https://github.com/tabnas/abnf) grammar.
7
+
8
+ ```js
9
+ const { parse } = require('@tabnas/proto')
10
+
11
+ const fdp = parse(`
12
+ syntax = "proto3";
13
+ package example;
14
+ message Person {
15
+ string name = 1;
16
+ repeated string emails = 2;
17
+ }
18
+ `)
19
+
20
+ fdp.syntax // => 'proto3'
21
+ fdp.package // => 'example'
22
+ fdp.messageType[0].name // => 'Person'
23
+ fdp.messageType[0].field[1].label // => 'LABEL_REPEATED'
24
+ fdp.messageType[0].field[0].type // => 'TYPE_STRING'
25
+ ```
26
+
27
+ ## Versions
28
+
29
+ The version is auto-detected from the file's `syntax` / `edition`
30
+ declaration, and/or set explicitly with the `version` option:
31
+
32
+ ```js
33
+ const { parse } = require('@tabnas/proto')
34
+
35
+ parse('edition = "2023";').edition // => 'EDITION_2023'
36
+ parse('message M {}', { version: 'proto3' }).syntax // => 'proto3'
37
+ ```
38
+
39
+ When both an explicit `version` and a declaration are present they must
40
+ agree (`reconcile: true`, the default) or `parse` throws; set
41
+ `reconcile: false` to let the declaration win.
42
+
43
+ ## API
44
+
45
+ - `parse(src, options?) => FileDescriptorProto` — parse a `.proto` string.
46
+ - `Proto` — the Tabnas plugin; `new Tabnas().use(Proto)` installs the
47
+ grammar so `tn.parse(src)` returns the raw `{rule, src, kids}` CST.
48
+ - `toDescriptor(cst, options?)` — turn a parsed CST into a
49
+ FileDescriptorProto.
50
+
51
+ Options: `{ version?: 'proto2'|'proto3'|'2023'|'2024' | null,
52
+ reconcile?: boolean }`.
53
+
54
+ ## What it produces
55
+
56
+ A `FileDescriptorProto`-shaped object (the `descriptor.proto` JSON shape):
57
+ `package`, `dependency` (+ `publicDependency` / `weakDependency`),
58
+ `messageType` (recursive `DescriptorProto` with `field`, `nestedType`,
59
+ `enumType`, `oneofDecl`, `extensionRange`, `reservedRange`), `enumType`,
60
+ `service`, `extension`, `options`, and `syntax` / `edition`. `map<K,V>`
61
+ fields are expanded to a repeated message field plus a synthesised
62
+ `…Entry` nested message with `options.mapEntry = true`, exactly as `protoc`
63
+ does. Type names are stored as written; cross-file resolution is a separate
64
+ concern.
65
+
66
+ See [doc/tutorial.md](doc/tutorial.md), [doc/guide.md](doc/guide.md),
67
+ [doc/reference.md](doc/reference.md), and [doc/concepts.md](doc/concepts.md).
68
+
69
+ [fdp]: https://protobuf.dev/reference/protobuf/google.protobuf/#file-descriptor-proto
@@ -0,0 +1,9 @@
1
+ import { FileDescriptorProto } from './descriptor';
2
+ import { ProtoVersion } from './detect-version';
3
+ type Node = {
4
+ rule?: string;
5
+ src: string;
6
+ kids?: Node[];
7
+ };
8
+ export declare function buildFile(proto: Node, version: ProtoVersion): FileDescriptorProto;
9
+ export {};
@@ -0,0 +1,385 @@
1
+ "use strict";
2
+ /* Copyright (c) 2026 Richard Rodger and other contributors, MIT License */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.buildFile = buildFile;
5
+ // Walk the `{rule, src, kids}` CST produced by the proto ABNF grammar and
6
+ // assemble a FileDescriptorProto-shaped object. Lexical atoms arrive as
7
+ // whole-word tokens, and abnf's leading-ref inlining means the specific
8
+ // statement rule (message / field / enum …) is folded into the enclosing
9
+ // `topLevelDef` / `messageElement` dispatch node; we recover the statement
10
+ // kind from the keyword that precedes the node's first child (`kw`).
11
+ const descriptor_1 = require("./descriptor");
12
+ const detect_version_1 = require("./detect-version");
13
+ // Children that are real rule nodes (terminals fold into `src`).
14
+ function R(n) {
15
+ return (n.kids || []).filter((k) => k && k.rule);
16
+ }
17
+ // The keyword(s) consumed before this node's first child — the part of
18
+ // `src` ahead of the first child's `src`. For `message Foo {…}` the first
19
+ // child is `Foo`, so `kw` is `message`; for an unlabelled field it is ``.
20
+ function kw(n) {
21
+ const k = R(n);
22
+ if (0 === k.length)
23
+ return n.src;
24
+ const i = n.src.indexOf(k[0].src);
25
+ return i <= 0 ? '' : n.src.slice(0, i);
26
+ }
27
+ function child(n, rule) {
28
+ return R(n).find((k) => k.rule === rule);
29
+ }
30
+ function unquote(s) {
31
+ const m = s.match(/^["']([\s\S]*)["']$/);
32
+ return m ? m[1] : s;
33
+ }
34
+ // ---- constants / option values -------------------------------------------
35
+ function constantValue(n) {
36
+ const s = n.src;
37
+ if ('true' === s)
38
+ return true;
39
+ if ('false' === s)
40
+ return false;
41
+ if (/^["']/.test(s))
42
+ return unquote(s);
43
+ if (/^[-+]?(?:\d|\.\d|0x|0o|0b)/i.test(s)) {
44
+ const num = Number(s.replace(/^\+/, ''));
45
+ if (!Number.isNaN(num))
46
+ return num;
47
+ }
48
+ return s; // identifier (enum value name, inf, nan, …) kept verbatim
49
+ }
50
+ // The option name in an `optionName "=" constant` statement. Because the
51
+ // name's leading `optionNamePart` is inlined and the parts are split across
52
+ // the node's `src` and later children, read it as everything before the
53
+ // `constant`, with the trailing `=` removed.
54
+ function optionNameOf(stmt, valueNode) {
55
+ if (!valueNode)
56
+ return '';
57
+ const i = stmt.src.indexOf(valueNode.src);
58
+ return (i <= 0 ? '' : stmt.src.slice(0, i)).replace(/=$/, '');
59
+ }
60
+ // fieldOptions = "[" fieldOption *( "," fieldOption ) "]"
61
+ // fieldOption = optionName "=" constant
62
+ function readFieldOptions(opts) {
63
+ if (!opts)
64
+ return undefined;
65
+ const out = {};
66
+ for (const fo of R(opts)) {
67
+ const cst = child(fo, 'constant');
68
+ const name = optionNameOf(fo, cst);
69
+ if (cst && name)
70
+ out[name] = constantValue(cst);
71
+ }
72
+ return Object.keys(out).length ? out : undefined;
73
+ }
74
+ // ---- fields --------------------------------------------------------------
75
+ function fieldLabel(labelNode, version) {
76
+ const lab = labelNode?.src;
77
+ if ('required' === lab)
78
+ return { label: 'LABEL_REQUIRED' };
79
+ if ('repeated' === lab)
80
+ return { label: 'LABEL_REPEATED' };
81
+ if ('optional' === lab) {
82
+ return 'proto3' === version
83
+ ? { label: 'LABEL_OPTIONAL', proto3Optional: true }
84
+ : { label: 'LABEL_OPTIONAL' };
85
+ }
86
+ // Implicit label.
87
+ return { label: 'LABEL_OPTIONAL' };
88
+ }
89
+ function fieldTypeName(typeText) {
90
+ const bare = typeText.replace(/^\./, '');
91
+ const scalar = descriptor_1.SCALAR_TYPES[bare];
92
+ if (scalar)
93
+ return { type: scalar };
94
+ // Message or enum reference; resolution deferred, store as written.
95
+ return { type: 'TYPE_MESSAGE', typeName: typeText };
96
+ }
97
+ // A normal field: [label] fieldType ident "=" fieldNumber [fieldOptions].
98
+ // The surrounding dispatch node (`messageElement` / `oneofElement`) has these
99
+ // inlined as its children.
100
+ // The field type. Normally a `fieldType` child; but when `fieldType` is a
101
+ // leading ref (an unlabelled oneof member `string x = 1;`) abnf inlines it,
102
+ // so the type surfaces as a bare `fullIdent` / `messageType` child instead.
103
+ function typeNodeOf(n) {
104
+ return child(n, 'fieldType') ?? child(n, 'messageType') ?? child(n, 'fullIdent');
105
+ }
106
+ function buildField(n, version) {
107
+ const label = child(n, 'label');
108
+ const type = typeNodeOf(n);
109
+ const name = child(n, 'ident');
110
+ const number = child(n, 'fieldNumber');
111
+ const opts = child(n, 'fieldOptions');
112
+ const f = {
113
+ name: name ? name.src : '',
114
+ number: number ? Number(number.src) : 0,
115
+ ...fieldLabel(label, version),
116
+ ...fieldTypeName(type ? type.src : ''),
117
+ };
118
+ const fo = readFieldOptions(opts);
119
+ if (fo)
120
+ f.options = fo;
121
+ return f;
122
+ }
123
+ // map<K,V> name = N; -> a repeated message field whose type is a
124
+ // synthesised nested `<Name>Entry` message with mapEntry=true.
125
+ function buildMapField(n, version, into) {
126
+ const types = R(n).filter((k) => k.rule === 'fieldType');
127
+ const name = child(n, 'ident');
128
+ const number = child(n, 'fieldNumber');
129
+ const keyText = types[0] ? types[0].src : '';
130
+ const valText = types[1] ? types[1].src : '';
131
+ const fname = name ? name.src : '';
132
+ const entryName = fname.replace(/(^|_)([a-z])/g, (_, a, b) => a + b.toUpperCase())
133
+ + 'Entry';
134
+ const entry = {
135
+ name: entryName,
136
+ field: [
137
+ { name: 'key', number: 1, label: 'LABEL_OPTIONAL', ...fieldTypeName(keyText) },
138
+ { name: 'value', number: 2, label: 'LABEL_OPTIONAL', ...fieldTypeName(valText) },
139
+ ],
140
+ nestedType: [], enumType: [], oneofDecl: [], extension: [],
141
+ options: { mapEntry: true },
142
+ };
143
+ into.nestedType.push(entry);
144
+ const f = {
145
+ name: fname,
146
+ number: number ? Number(number.src) : 0,
147
+ label: 'LABEL_REPEATED',
148
+ type: 'TYPE_MESSAGE',
149
+ typeName: entryName,
150
+ };
151
+ const fo = readFieldOptions(child(n, 'fieldOptions'));
152
+ if (fo)
153
+ f.options = fo;
154
+ return f;
155
+ }
156
+ // ---- enums ---------------------------------------------------------------
157
+ function buildEnum(n) {
158
+ const e = { name: child(n, 'ident')?.src ?? '', value: [] };
159
+ for (const el of R(n).filter((k) => k.rule === 'enumElement')) {
160
+ const k = kw(el);
161
+ if (k.startsWith('reserved')) {
162
+ addReserved(el, e);
163
+ continue;
164
+ }
165
+ if (k.startsWith('option')) {
166
+ continue; // enum-level option; folded into options below if needed
167
+ }
168
+ // enumField: ident "=" ["-"] fieldNumber -> name is the kw before "="
169
+ const name = kw(el).replace(/=.*$/, '');
170
+ const num = child(el, 'fieldNumber');
171
+ if (name && num) {
172
+ const neg = /=-/.test(el.src.replace(/\s+/g, ''));
173
+ e.value.push({ name, number: (neg ? -1 : 1) * Number(num.src) });
174
+ }
175
+ }
176
+ return e;
177
+ }
178
+ // ---- reserved / extensions ranges ----------------------------------------
179
+ // `ranges = range *( "," range )`. The leading `range` is inlined into
180
+ // `ranges.src`, so parse the (whitespace-stripped) text rather than kids.
181
+ function ranges(rangesNode) {
182
+ if (!rangesNode)
183
+ return [];
184
+ const out = [];
185
+ for (const part of rangesNode.src.replace(/\s+/g, '').split(',')) {
186
+ const m = part.match(/^(-?\d+)(?:to(-?\d+|max))?$/);
187
+ if (!m)
188
+ continue;
189
+ const start = Number(m[1]);
190
+ const end = !m[2] ? start : (m[2] === 'max' ? 536870911 : Number(m[2]));
191
+ out.push({ start, end });
192
+ }
193
+ return out;
194
+ }
195
+ function addReserved(n, target) {
196
+ const rn = child(n, 'ranges');
197
+ if (rn) {
198
+ (target.reservedRange = target.reservedRange || []).push(...ranges(rn));
199
+ return;
200
+ }
201
+ const names = child(n, 'fieldNames');
202
+ if (names) {
203
+ const list = R(names).filter((k) => k.rule === 'strLit').map((k) => unquote(k.src));
204
+ (target.reservedName = target.reservedName || []).push(...list);
205
+ }
206
+ }
207
+ // ---- messages ------------------------------------------------------------
208
+ function buildMessage(n, version) {
209
+ // `n` is a dispatch node whose `message` alt was inlined: kids are
210
+ // [ident, messageBody-children…] or [ident] then messageBody.
211
+ const msg = {
212
+ name: child(n, 'ident')?.src ?? '',
213
+ field: [], nestedType: [], enumType: [], oneofDecl: [], extension: [],
214
+ };
215
+ const body = child(n, 'messageBody');
216
+ const elements = body ? R(body).filter((k) => k.rule === 'messageElement') : [];
217
+ for (const el of elements)
218
+ addMessageElement(el, version, msg);
219
+ return msg;
220
+ }
221
+ function addMessageElement(el, version, msg) {
222
+ const k = kw(el);
223
+ const first = R(el)[0];
224
+ if (k.startsWith('map<')) {
225
+ msg.field.push(buildMapField(el, version, msg));
226
+ return;
227
+ }
228
+ if (k.startsWith('oneof')) {
229
+ addOneof(el, version, msg);
230
+ return;
231
+ }
232
+ if (k.startsWith('export') || k.startsWith('local')) {
233
+ // edition 2024 symbol visibility wraps the message/enum as a child node.
234
+ const m = child(el, 'message');
235
+ const e = child(el, 'enumDef');
236
+ if (m)
237
+ msg.nestedType.push(buildMessage(m, version));
238
+ else if (e)
239
+ msg.enumType.push(buildEnum(e));
240
+ return;
241
+ }
242
+ if (k.startsWith('message')) {
243
+ msg.nestedType.push(buildMessage(el, version));
244
+ return;
245
+ }
246
+ if (k.startsWith('enum')) {
247
+ msg.enumType.push(buildEnum(el));
248
+ return;
249
+ }
250
+ if (k.startsWith('reserved')) {
251
+ addReserved(el, msg);
252
+ return;
253
+ }
254
+ if (k.startsWith('extensions')) {
255
+ (msg.extensionRange = msg.extensionRange || []).push(...ranges(child(el, 'ranges')));
256
+ return;
257
+ }
258
+ if (k.startsWith('extend')) {
259
+ addExtend(el, version, msg.extension);
260
+ return;
261
+ }
262
+ if (k.startsWith('option')) {
263
+ msg.options = { ...(msg.options || {}), ...optionFrom(el) };
264
+ return;
265
+ }
266
+ if (';' === el.src)
267
+ return; // emptyStmt
268
+ // No keyword and a fieldType/label lead => a field.
269
+ if (first && (first.rule === 'fieldType' || first.rule === 'label')) {
270
+ msg.field.push(buildField(el, version));
271
+ }
272
+ }
273
+ function addOneof(el, version, msg) {
274
+ const name = child(el, 'ident')?.src ?? '';
275
+ const index = msg.oneofDecl.length;
276
+ msg.oneofDecl.push({ name });
277
+ for (const of of R(el).filter((k) => k.rule === 'oneofElement')) {
278
+ if (kw(of).startsWith('option'))
279
+ continue;
280
+ if (';' === of.src)
281
+ continue;
282
+ const f = buildField(of, version);
283
+ f.oneofIndex = index;
284
+ delete f.proto3Optional; // explicit oneof members aren't proto3-optional
285
+ msg.field.push(f);
286
+ }
287
+ }
288
+ function addExtend(el, version, into) {
289
+ // extend messageType "{" *field "}" — fields inline as messageElement-like.
290
+ for (const f of R(el).filter((k) => k.rule === 'field' || k.rule === 'messageElement')) {
291
+ into.push(buildField(f, version));
292
+ }
293
+ }
294
+ // ---- options -------------------------------------------------------------
295
+ // optionStmt = "option" optionName "=" constant ";"
296
+ function optionFrom(el) {
297
+ const cst = child(el, 'constant');
298
+ if (!cst)
299
+ return {};
300
+ const name = optionNameOf(el, cst).replace(/^option/, '');
301
+ return { [name]: constantValue(cst) };
302
+ }
303
+ // ---- services ------------------------------------------------------------
304
+ function buildService(n) {
305
+ const svc = { name: child(n, 'ident')?.src ?? '', method: [] };
306
+ for (const el of R(n).filter((k) => k.rule === 'serviceElement')) {
307
+ if (kw(el).startsWith('rpc'))
308
+ svc.method.push(buildRpc(el));
309
+ }
310
+ return svc;
311
+ }
312
+ // rpc ident "(" ["stream"] messageType ")" "returns" "(" ["stream"] messageType ")"
313
+ function buildRpc(el) {
314
+ const ids = R(el).filter((k) => k.rule === 'ident');
315
+ const types = R(el).filter((k) => k.rule === 'messageType');
316
+ const flat = el.src.replace(/\s+/g, '');
317
+ const m = {
318
+ name: ids[0] ? ids[0].src : '',
319
+ inputType: types[0] ? types[0].src : '',
320
+ outputType: types[1] ? types[1].src : '',
321
+ };
322
+ // Split request vs response on the `returns` keyword so a `(stream …)`
323
+ // is attributed to the right side even when in/out types are identical.
324
+ const ri = flat.indexOf('returns(');
325
+ const request = ri >= 0 ? flat.slice(0, ri) : flat;
326
+ const response = ri >= 0 ? flat.slice(ri) : '';
327
+ if (/\(stream/.test(request))
328
+ m.clientStreaming = true;
329
+ if (/\(stream/.test(response))
330
+ m.serverStreaming = true;
331
+ return m;
332
+ }
333
+ // ---- file ----------------------------------------------------------------
334
+ function buildFile(proto, version) {
335
+ const file = {
336
+ dependency: [], publicDependency: [], weakDependency: [],
337
+ messageType: [], enumType: [], service: [], extension: [],
338
+ };
339
+ if ((0, detect_version_1.isEdition)(version))
340
+ file.edition = 'EDITION_' + version;
341
+ else
342
+ file.syntax = version;
343
+ for (const def of R(proto).filter((k) => k.rule === 'topLevelDef')) {
344
+ const k = kw(def);
345
+ if (k.startsWith('package')) {
346
+ file.package = child(def, 'fullIdent')?.src;
347
+ }
348
+ else if (k.startsWith('import')) {
349
+ const s = child(def, 'strLit');
350
+ if (s) {
351
+ const idx = file.dependency.length;
352
+ file.dependency.push(unquote(s.src));
353
+ if (k.includes('public'))
354
+ file.publicDependency.push(idx);
355
+ if (k.includes('weak'))
356
+ file.weakDependency.push(idx);
357
+ }
358
+ }
359
+ else if (k.startsWith('option')) {
360
+ file.options = { ...(file.options || {}), ...optionFrom(def) };
361
+ }
362
+ else if (k.startsWith('export') || k.startsWith('local')) {
363
+ const m = child(def, 'message');
364
+ const e = child(def, 'enumDef');
365
+ if (m)
366
+ file.messageType.push(buildMessage(m, version));
367
+ else if (e)
368
+ file.enumType.push(buildEnum(e));
369
+ }
370
+ else if (k.startsWith('message')) {
371
+ file.messageType.push(buildMessage(def, version));
372
+ }
373
+ else if (k.startsWith('enum')) {
374
+ file.enumType.push(buildEnum(def));
375
+ }
376
+ else if (k.startsWith('service')) {
377
+ file.service.push(buildService(def));
378
+ }
379
+ else if (k.startsWith('extend')) {
380
+ addExtend(def, version, file.extension);
381
+ }
382
+ }
383
+ return file;
384
+ }
385
+ //# sourceMappingURL=build-descriptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-descriptor.js","sourceRoot":"","sources":["../src/build-descriptor.ts"],"names":[],"mappings":";AAAA,2EAA2E;;AA4U3E,8BAqCC;AA/WD,0EAA0E;AAC1E,wEAAwE;AACxE,wEAAwE;AACxE,yEAAyE;AACzE,2EAA2E;AAC3E,qEAAqE;AAErE,6CAIqB;AACrB,qDAA0D;AAI1D,iEAAiE;AACjE,SAAS,CAAC,CAAC,CAAO;IAChB,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAA;AAClD,CAAC;AAED,uEAAuE;AACvE,0EAA0E;AAC1E,0EAA0E;AAC1E,SAAS,EAAE,CAAC,CAAO;IACjB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACd,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,CAAC,CAAC,GAAG,CAAA;IAChC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;IACjC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AACxC,CAAC;AAED,SAAS,KAAK,CAAC,CAAO,EAAE,IAAY;IAClC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAA;AAC1C,CAAC;AAED,SAAS,OAAO,CAAC,CAAS;IACxB,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAA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,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YAChC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA;QACpC,CAAC;aAAM,IAAI,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YACnC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAA;QACtC,CAAC;aAAM,IAAI,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAClC,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;QACzC,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,80 @@
1
+ export type FieldLabel = 'LABEL_OPTIONAL' | 'LABEL_REQUIRED' | 'LABEL_REPEATED';
2
+ export type FieldType = 'TYPE_DOUBLE' | 'TYPE_FLOAT' | 'TYPE_INT64' | 'TYPE_UINT64' | 'TYPE_INT32' | 'TYPE_FIXED64' | 'TYPE_FIXED32' | 'TYPE_BOOL' | 'TYPE_STRING' | 'TYPE_GROUP' | 'TYPE_MESSAGE' | 'TYPE_BYTES' | 'TYPE_UINT32' | 'TYPE_ENUM' | 'TYPE_SFIXED32' | 'TYPE_SFIXED64' | 'TYPE_SINT32' | 'TYPE_SINT64';
3
+ export type OptionValue = string | number | boolean | {
4
+ [k: string]: OptionValue;
5
+ };
6
+ export interface FieldDescriptorProto {
7
+ name: string;
8
+ number: number;
9
+ label?: FieldLabel;
10
+ type?: FieldType;
11
+ typeName?: string;
12
+ proto3Optional?: boolean;
13
+ oneofIndex?: number;
14
+ options?: Record<string, OptionValue>;
15
+ }
16
+ export interface EnumValueDescriptorProto {
17
+ name: string;
18
+ number: number;
19
+ options?: Record<string, OptionValue>;
20
+ }
21
+ export interface EnumDescriptorProto {
22
+ name: string;
23
+ value: EnumValueDescriptorProto[];
24
+ reservedRange?: {
25
+ start: number;
26
+ end: number;
27
+ }[];
28
+ reservedName?: string[];
29
+ options?: Record<string, OptionValue>;
30
+ }
31
+ export interface OneofDescriptorProto {
32
+ name: string;
33
+ options?: Record<string, OptionValue>;
34
+ }
35
+ export interface DescriptorProto {
36
+ name: string;
37
+ field: FieldDescriptorProto[];
38
+ nestedType: DescriptorProto[];
39
+ enumType: EnumDescriptorProto[];
40
+ oneofDecl: OneofDescriptorProto[];
41
+ extension: FieldDescriptorProto[];
42
+ extensionRange?: {
43
+ start: number;
44
+ end: number;
45
+ }[];
46
+ reservedRange?: {
47
+ start: number;
48
+ end: number;
49
+ }[];
50
+ reservedName?: string[];
51
+ options?: Record<string, OptionValue>;
52
+ }
53
+ export interface MethodDescriptorProto {
54
+ name: string;
55
+ inputType: string;
56
+ outputType: string;
57
+ clientStreaming?: boolean;
58
+ serverStreaming?: boolean;
59
+ options?: Record<string, OptionValue>;
60
+ }
61
+ export interface ServiceDescriptorProto {
62
+ name: string;
63
+ method: MethodDescriptorProto[];
64
+ options?: Record<string, OptionValue>;
65
+ }
66
+ export interface FileDescriptorProto {
67
+ name?: string;
68
+ package?: string;
69
+ dependency: string[];
70
+ publicDependency: number[];
71
+ weakDependency: number[];
72
+ messageType: DescriptorProto[];
73
+ enumType: EnumDescriptorProto[];
74
+ service: ServiceDescriptorProto[];
75
+ extension: FieldDescriptorProto[];
76
+ options?: Record<string, OptionValue>;
77
+ syntax?: string;
78
+ edition?: string;
79
+ }
80
+ export declare const SCALAR_TYPES: Record<string, FieldType>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /* Copyright (c) 2026 Richard Rodger and other contributors, MIT License */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.SCALAR_TYPES = void 0;
5
+ // Scalar protobuf types -> FieldDescriptorProto.type. A field whose type
6
+ // is not in this table is a message/enum/group reference (resolution
7
+ // deferred) and gets a `typeName` instead.
8
+ exports.SCALAR_TYPES = {
9
+ double: 'TYPE_DOUBLE',
10
+ float: 'TYPE_FLOAT',
11
+ int32: 'TYPE_INT32',
12
+ int64: 'TYPE_INT64',
13
+ uint32: 'TYPE_UINT32',
14
+ uint64: 'TYPE_UINT64',
15
+ sint32: 'TYPE_SINT32',
16
+ sint64: 'TYPE_SINT64',
17
+ fixed32: 'TYPE_FIXED32',
18
+ fixed64: 'TYPE_FIXED64',
19
+ sfixed32: 'TYPE_SFIXED32',
20
+ sfixed64: 'TYPE_SFIXED64',
21
+ bool: 'TYPE_BOOL',
22
+ string: 'TYPE_STRING',
23
+ bytes: 'TYPE_BYTES',
24
+ };
25
+ //# sourceMappingURL=descriptor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"descriptor.js","sourceRoot":"","sources":["../src/descriptor.ts"],"names":[],"mappings":";AAAA,2EAA2E;;;AAqG3E,yEAAyE;AACzE,qEAAqE;AACrE,2CAA2C;AAC9B,QAAA,YAAY,GAA8B;IACrD,MAAM,EAAE,aAAa;IACrB,KAAK,EAAE,YAAY;IACnB,KAAK,EAAE,YAAY;IACnB,KAAK,EAAE,YAAY;IACnB,MAAM,EAAE,aAAa;IACrB,MAAM,EAAE,aAAa;IACrB,MAAM,EAAE,aAAa;IACrB,MAAM,EAAE,aAAa;IACrB,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,cAAc;IACvB,QAAQ,EAAE,eAAe;IACzB,QAAQ,EAAE,eAAe;IACzB,IAAI,EAAE,WAAW;IACjB,MAAM,EAAE,aAAa;IACrB,KAAK,EAAE,YAAY;CACpB,CAAA"}
@@ -0,0 +1,5 @@
1
+ export type ProtoVersion = 'proto2' | 'proto3' | '2023' | '2024';
2
+ export declare function declaredVersion(syntaxNode: any): ProtoVersion | null;
3
+ export declare function resolveVersion(declared: ProtoVersion | null, option: ProtoVersion | null, reconcile: boolean): ProtoVersion;
4
+ export declare function isEdition(v: ProtoVersion): boolean;
5
+ export declare function editionEnum(v: ProtoVersion): string;