protons 2.0.2 → 3.0.1

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.
Files changed (59) hide show
  1. package/LICENSE +3 -20
  2. package/README.md +30 -122
  3. package/dist/bin/protons.js +34 -0
  4. package/dist/src/index.d.ts +2 -0
  5. package/dist/src/index.d.ts.map +1 -0
  6. package/dist/src/index.js +206 -0
  7. package/dist/src/index.js.map +1 -0
  8. package/package.json +148 -70
  9. package/src/index.ts +282 -0
  10. package/.aegir.js +0 -11
  11. package/.github/ISSUE_TEMPLATE/config.yml +0 -8
  12. package/.github/ISSUE_TEMPLATE/open_an_issue.md +0 -19
  13. package/.github/config.yml +0 -68
  14. package/.travis.yml +0 -42
  15. package/CHANGELOG.md +0 -88
  16. package/bench/bench.proto.js +0 -30
  17. package/bench/index.js +0 -57
  18. package/example.js +0 -19
  19. package/example.proto +0 -4
  20. package/src/compile/decode.js +0 -330
  21. package/src/compile/encode.js +0 -133
  22. package/src/compile/encoding-length.js +0 -102
  23. package/src/compile/encodings/bool.js +0 -21
  24. package/src/compile/encodings/bytes.js +0 -42
  25. package/src/compile/encodings/double.js +0 -21
  26. package/src/compile/encodings/encoder.js +0 -14
  27. package/src/compile/encodings/fixed32.js +0 -21
  28. package/src/compile/encodings/fixed64.js +0 -25
  29. package/src/compile/encodings/float.js +0 -21
  30. package/src/compile/encodings/index.js +0 -22
  31. package/src/compile/encodings/int32.js +0 -22
  32. package/src/compile/encodings/int64.js +0 -49
  33. package/src/compile/encodings/sfixed32.js +0 -21
  34. package/src/compile/encodings/sint64.js +0 -19
  35. package/src/compile/encodings/string.js +0 -41
  36. package/src/compile/encodings/varint.js +0 -19
  37. package/src/compile/index.js +0 -165
  38. package/src/compile/utils.js +0 -5
  39. package/src/index.js +0 -39
  40. package/test/basic.spec.js +0 -109
  41. package/test/booleans.spec.js +0 -37
  42. package/test/bytes.spec.js +0 -36
  43. package/test/corrupted.spec.js +0 -50
  44. package/test/custom-types.spec.js +0 -55
  45. package/test/defaults.spec.js +0 -44
  46. package/test/enums.spec.js +0 -21
  47. package/test/float.spec.js +0 -28
  48. package/test/integers.spec.js +0 -72
  49. package/test/map.spec.js +0 -35
  50. package/test/nan.spec.js +0 -28
  51. package/test/nested.spec.js +0 -70
  52. package/test/notpacked.spec.js +0 -33
  53. package/test/oneof.spec.js +0 -59
  54. package/test/optional.spec.js +0 -65
  55. package/test/packed.spec.js +0 -61
  56. package/test/repeated.spec.js +0 -74
  57. package/test/strings.spec.js +0 -45
  58. package/test/test.proto.js +0 -134
  59. package/test/utf-8.spec.js +0 -21
package/LICENSE CHANGED
@@ -1,21 +1,4 @@
1
- The MIT License (MIT)
1
+ This project is dual licensed under MIT and Apache-2.0.
2
2
 
3
- Copyright (c) 2014 Mathias Buus
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
13
- all 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
21
- THE SOFTWARE.
3
+ MIT: https://www.opensource.org/licenses/mit
4
+ Apache-2.0: https://www.apache.org/licenses/license-2.0
package/README.md CHANGED
@@ -1,155 +1,63 @@
1
- ⛔️ DEPRECATED: This module is no longer maintained <!-- omit in toc -->
2
-
3
1
  # protons <!-- omit in toc -->
4
2
 
5
- [![Dependency Status](https://david-dm.org/ipfs/protons.svg?style=flat-square)](https://david-dm.org/ipfs/protons)
6
- [![Travis CI](https://travis-ci.org/ipfs/protons.svg?branch=master)](https://travis-ci.org/ipfs/protons)
7
-
8
- > [Protocol Buffers](https://developers.google.com/protocol-buffers/) for Node.js and the browser without compilation.
9
- >
10
- > Forked from [protocol-buffers](https://github.com/mafintosh/protocol-buffers).
11
-
12
- ## Lead Maintainer <!-- omit in toc -->
3
+ > Generate typescript from .proto files
13
4
 
14
- [Alex Potsides](https://github.com/achingbrain)
15
-
16
- ## Table of Contents <!-- omit in toc -->
5
+ ## Table of contents <!-- omit in toc -->
17
6
 
18
7
  - [Install](#install)
19
8
  - [Usage](#usage)
20
- - [Properties](#properties)
21
- - [Performance](#performance)
22
- - [Leveldb encoding compatibility](#leveldb-encoding-compatibility)
9
+ - [Contribute](#contribute)
23
10
  - [License](#license)
24
11
 
25
12
  ## Install
26
13
 
27
- ```sh
28
- > npm install protons
29
- ```
14
+ To use this project, add `protons` as a development dependency and `protons-runtime` as a runtime dependency.
30
15
 
31
- ## Usage
32
-
33
- Assuming the following `test.proto` file exists
34
-
35
- ```proto
36
- enum FOO {
37
- BAR = 1;
38
- }
16
+ `protons` contains the code to compile `.proto` files to `.ts` files and `protons-runtime` contains the code to do serialization/deserialization to `Uint8Array`s during application execution.
39
17
 
40
- message Test {
41
- required float num = 1;
42
- required string payload = 2;
43
- }
44
-
45
- message AnotherOne {
46
- repeated FOO list = 1;
47
- }
48
-
49
- message WithOptional {
50
- optional string payload = 1;
51
- }
18
+ ```console
19
+ $ npm install --save-dev protons
20
+ $ npm install --save protons-runtime
52
21
  ```
53
22
 
54
- Use the above proto file to encode/decode messages by doing
55
-
56
- ``` js
57
- const protons = require('protons')
58
-
59
- // pass a proto file as a buffer/string or pass a parsed protobuf-schema object
60
- const messages = protons(fs.readFileSync('test.proto'))
61
-
62
- const buf = messages.Test.encode({
63
- num: 42,
64
- payload: 'hello world'
65
- })
66
-
67
- console.log(buf) // should print a buffer
68
- ```
69
-
70
- To decode a message use `Test.decode`
71
-
72
- ``` js
73
- const obj = messages.Test.decode(buf)
74
- console.log(obj) // should print an object similar to above
75
- ```
76
-
77
- Enums are accessed in the same way as messages
78
-
79
- ``` js
80
- const buf = messages.AnotherOne.encode({
81
- list: [
82
- messages.FOO.BAR
83
- ]
84
- })
85
- ```
23
+ ## Usage
86
24
 
87
- Nested emums are accessed as properties on the corresponding message
25
+ First generate your `.ts` files:
88
26
 
89
- ``` js
90
- const buf = message.SomeMessage.encode({
91
- list: [
92
- messages.SomeMessage.NESTED_ENUM.VALUE
93
- ]
94
- })
27
+ ```console
28
+ $ protons ./path/to/foo.proto ./path/to/output.ts
95
29
  ```
96
30
 
97
- See the [Google Protocol Buffers docs](https://developers.google.com/protocol-buffers/) for more information about the
98
- available types etc.
99
-
100
- ## Properties
101
-
102
- Decoded object properties can be interacted with using accessor methods:
103
-
104
- ```javascript
105
- const obj = messages.WithOptional.decode(messages.WithOptional.encode({}))
31
+ Then run tsc over them as normal:
106
32
 
107
- obj.hasPayload() // false
108
- obj.getPayload() // ''
109
- obj.setPayload('hello world')
110
- obj.getPayload() // 'hello world'
111
- obj.clearPayload()
112
- obj.getPayload() // undefined
33
+ ```console
34
+ $ tsc
113
35
  ```
114
36
 
115
- ## Performance
37
+ In your code import the generated classes and use them to transform to/from bytes:
116
38
 
117
- This module is pretty fast.
39
+ ```js
40
+ import { Foo } from './foo.js'
118
41
 
119
- You can run the benchmarks yourself by doing `npm run bench`.
42
+ const foo = {
43
+ message: 'hello world'
44
+ }
120
45
 
121
- On my Macbook Pro it gives the following results
46
+ const encoded = Foo.encode(foo)
47
+ const decoded = Foo.decode(encoded)
122
48
 
123
- ```
124
- JSON (encode) x 703,160 ops/sec ±2.06% (91 runs sampled)
125
- JSON (decode) x 619,564 ops/sec ±1.60% (94 runs sampled)
126
- JSON (encode + decode) x 308,635 ops/sec ±1.74% (92 runs sampled)
127
- protocol-buffers@4.1.0 (encode) x 693,570 ops/sec ±1.55% (92 runs sampled)
128
- protocol-buffers@4.1.0 (decode) x 1,894,031 ops/sec ±1.61% (93 runs sampled)
129
- protocol-buffers@4.1.0 (encode + decode) x 444,229 ops/sec ±1.50% (93 runs sampled)
130
- protons@1.0.1 (encode) x 435,058 ops/sec ±1.46% (91 runs sampled)
131
- protons@1.0.1 (decode) x 29,548 ops/sec ±3.29% (78 runs sampled)
132
- protons@1.0.1 (encode + decode) x 27,042 ops/sec ±4.41% (80 runs sampled)
49
+ console.info(decoded.message)
50
+ // 'hello world'
133
51
  ```
134
52
 
135
- Note that JSON parsing/serialization in node is a native function that is *really* fast.
53
+ ## Contribute
136
54
 
137
- ## Leveldb encoding compatibility
55
+ Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/protons/issues)!
138
56
 
139
- Compiled protocol buffers messages are valid levelup encodings.
140
- This means you can pass them as `valueEncoding` and `keyEncoding`.
57
+ This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
141
58
 
142
- ``` js
143
- const level = require('level')
144
- const db = level('db')
145
-
146
- db.put('hello', {payload:'world'}, {valueEncoding:messages.Test}, (err) => {
147
- db.get('hello', {valueEncoding:messages.Test}, (err, message) => {
148
- console.log(message)
149
- })
150
- })
151
- ```
59
+ [![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/contributing.md)
152
60
 
153
61
  ## License
154
62
 
155
- MIT
63
+ [Apache-2.0](LICENSE-APACHE) or [MIT](LICENSE-MIT) © Protocol Labs
@@ -0,0 +1,34 @@
1
+ #! /usr/bin/env node
2
+ import meow from 'meow';
3
+ import { generate } from '../src/index.js';
4
+ async function main() {
5
+ const cli = meow(`
6
+ Usage
7
+ $ protons source
8
+
9
+ Options
10
+ --output, -o Path to a directory to write transpiled typescript files into
11
+
12
+ Examples
13
+ $ protons ./path/to/file.proto
14
+ `, {
15
+ importMeta: import.meta,
16
+ flags: {
17
+ output: {
18
+ type: 'string',
19
+ alias: 'o'
20
+ }
21
+ }
22
+ });
23
+ if (cli.input.length === 0) {
24
+ throw new Error('source must be specified');
25
+ }
26
+ for (const source of cli.input) {
27
+ await generate(source, cli.flags);
28
+ }
29
+ }
30
+ main().catch(err => {
31
+ console.error(err); // eslint-disable-line no-console
32
+ process.exit(1);
33
+ });
34
+ //# sourceMappingURL=protons.js.map
@@ -0,0 +1,2 @@
1
+ export declare function generate(source: string, flags: any): Promise<void>;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAoQA,wBAAsB,QAAQ,CAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,iBAqBzD"}
@@ -0,0 +1,206 @@
1
+ import { main as pbjs } from 'protobufjs/cli/pbjs.js';
2
+ import path from 'path';
3
+ import { promisify } from 'util';
4
+ import fs from 'fs/promises';
5
+ function pathWithExtension(input, extension) {
6
+ return path.join(path.dirname(input), path.basename(input).split('.').slice(0, -1).join('.') + extension);
7
+ }
8
+ const types = {
9
+ double: 'number',
10
+ float: 'number',
11
+ int32: 'number',
12
+ int64: 'bigint',
13
+ uint32: 'number',
14
+ uint64: 'bigint',
15
+ sint32: 'number',
16
+ sint64: 'bigint',
17
+ fixed32: 'number',
18
+ fixed64: 'bigint',
19
+ sfixed32: 'number',
20
+ sfixed64: 'bigint',
21
+ bool: 'boolean',
22
+ string: 'string',
23
+ bytes: 'Uint8Array'
24
+ };
25
+ function findTypeName(typeName, classDef, moduleDef) {
26
+ if (types[typeName] != null) {
27
+ return types[typeName];
28
+ }
29
+ if (isEnumDef(classDef)) {
30
+ throw new Error('Could not find type in enum');
31
+ }
32
+ if (classDef.nested?.[typeName] != null) {
33
+ return `${classDef.fullName}.${typeName}`;
34
+ }
35
+ if (classDef.parent != null) {
36
+ return findTypeName(typeName, classDef.parent, moduleDef);
37
+ }
38
+ if (moduleDef.globals[typeName] != null) {
39
+ return typeName;
40
+ }
41
+ throw new Error(`Could not resolve type name "${typeName}"`);
42
+ }
43
+ function findDef(typeName, classDef, moduleDef) {
44
+ if (isEnumDef(classDef)) {
45
+ throw new Error('Could not find type in enum');
46
+ }
47
+ if (classDef.nested?.[typeName] != null) {
48
+ return classDef.nested?.[typeName];
49
+ }
50
+ if (classDef.parent != null) {
51
+ return findDef(typeName, classDef.parent, moduleDef);
52
+ }
53
+ if (moduleDef.globals[typeName] != null) {
54
+ return moduleDef.globals[typeName];
55
+ }
56
+ throw new Error(`Could not resolve type name "${typeName}"`);
57
+ }
58
+ const encoders = {
59
+ bool: 'bool',
60
+ double: 'double',
61
+ bytes: 'bytes',
62
+ fixed32: 'fixed32',
63
+ fixed64: 'fixed64',
64
+ float: 'float',
65
+ int32: 'int32',
66
+ int64: 'int64',
67
+ sint32: 'sint32',
68
+ sint64: 'sint64',
69
+ string: 'string',
70
+ uint32: 'uint32',
71
+ uint64: 'uint64',
72
+ sfixed32: 'sfixed32',
73
+ sfixed64: 'sfixed64'
74
+ };
75
+ function isEnumDef(obj) {
76
+ return obj.values != null;
77
+ }
78
+ function defineFields(fields, messageDef, moduleDef) {
79
+ return Object.entries(fields).map(([fieldName, fieldDef]) => {
80
+ const isArray = fieldDef.rule === 'repeated';
81
+ const isOptional = !isArray && fieldDef.options?.proto3_optional === true;
82
+ return `${fieldName}${isOptional ? '?' : ''}: ${findTypeName(fieldDef.type, messageDef, moduleDef)}${isArray ? '[]' : ''}`;
83
+ });
84
+ }
85
+ function compileMessage(messageDef, moduleDef) {
86
+ if (isEnumDef(messageDef)) {
87
+ moduleDef.imports.add('enumeration');
88
+ return `
89
+ export enum ${messageDef.name} {
90
+ ${Object.entries(messageDef.values).map(([enumValueName, enumValue]) => {
91
+ return `${enumValueName} = '${enumValueName}'`;
92
+ }).join(',\n ').trim()}
93
+ }
94
+
95
+ export namespace ${messageDef.name} {
96
+ export const codec = enumeration<typeof ${messageDef.name}>(${messageDef.name})
97
+ }
98
+ `;
99
+ }
100
+ let nested = '';
101
+ if (messageDef.nested != null) {
102
+ nested = '\n';
103
+ nested += Object.values(messageDef.nested)
104
+ .map(def => compileMessage(def, moduleDef).trim())
105
+ .join('\n')
106
+ .split('\n')
107
+ .map(line => line.trim() === '' ? '' : ` ${line}`)
108
+ .join('\n');
109
+ nested += '\n';
110
+ }
111
+ const fields = messageDef.fields ?? {};
112
+ // import relevant modules
113
+ moduleDef.imports.add('encodeMessage');
114
+ moduleDef.imports.add('decodeMessage');
115
+ moduleDef.imports.add('message');
116
+ return `
117
+ export interface ${messageDef.name} {
118
+ ${defineFields(fields, messageDef, moduleDef)
119
+ .join('\n ')
120
+ .trim()}
121
+ }
122
+
123
+ export namespace ${messageDef.name} {${nested}
124
+ export const codec = message<${messageDef.name}>({
125
+ ${Object.entries(fields)
126
+ .map(([name, fieldDef]) => {
127
+ let codec = encoders[fieldDef.type];
128
+ if (codec == null) {
129
+ const def = findDef(fieldDef.type, messageDef, moduleDef);
130
+ if (isEnumDef(def)) {
131
+ moduleDef.imports.add('enumeration');
132
+ }
133
+ else {
134
+ moduleDef.imports.add('message');
135
+ }
136
+ const typeName = findTypeName(fieldDef.type, messageDef, moduleDef);
137
+ codec = `${typeName}.codec`;
138
+ }
139
+ else {
140
+ moduleDef.imports.add(codec);
141
+ }
142
+ return `${fieldDef.id}: { name: '${name}', codec: ${codec}${fieldDef.options?.proto3_optional === true ? ', optional: true' : ''}${fieldDef.rule === 'repeated' ? ', repeats: true' : ''} }`;
143
+ }).join(',\n ')}
144
+ })
145
+
146
+ export const encode = (obj: ${messageDef.name}): Uint8Array => {
147
+ return encodeMessage(obj, ${messageDef.name}.codec)
148
+ }
149
+
150
+ export const decode = (buf: Uint8Array): ${messageDef.name} => {
151
+ return decodeMessage(buf, ${messageDef.name}.codec)
152
+ }
153
+ }
154
+ `;
155
+ }
156
+ function defineModule(def) {
157
+ const moduleDef = {
158
+ imports: new Set(),
159
+ types: new Set(),
160
+ compiled: [],
161
+ globals: {}
162
+ };
163
+ const defs = def.nested;
164
+ if (defs == null) {
165
+ throw new Error('No top-level messages found in protobuf');
166
+ }
167
+ function defineMessage(defs, parent) {
168
+ for (const className of Object.keys(defs)) {
169
+ const classDef = defs[className];
170
+ classDef.name = className;
171
+ classDef.parent = parent;
172
+ classDef.fullName = parent == null ? className : `${parent.fullName}.${className}`;
173
+ if (classDef.nested != null) {
174
+ defineMessage(classDef.nested, classDef);
175
+ }
176
+ if (parent == null) {
177
+ moduleDef.globals[className] = classDef;
178
+ }
179
+ }
180
+ }
181
+ defineMessage(defs);
182
+ for (const className of Object.keys(defs)) {
183
+ const classDef = defs[className];
184
+ moduleDef.compiled.push(compileMessage(classDef, moduleDef));
185
+ }
186
+ return moduleDef;
187
+ }
188
+ export async function generate(source, flags) {
189
+ // convert .protobuf to .json
190
+ const json = await promisify(pbjs)(['-t', 'json', source]);
191
+ if (json == null) {
192
+ throw new Error(`Could not convert ${source} to intermediate JSON format`);
193
+ }
194
+ const def = JSON.parse(json);
195
+ const moduleDef = defineModule(def);
196
+ const content = `
197
+ /* eslint-disable import/export */
198
+ /* eslint-disable @typescript-eslint/no-namespace */
199
+
200
+ import { ${Array.from(moduleDef.imports).join(', ')} } from 'protons-runtime'
201
+
202
+ ${moduleDef.compiled.map(str => str.trim()).join('\n\n').trim()}
203
+ `.trim();
204
+ await fs.writeFile(pathWithExtension(source, '.ts'), content + '\n');
205
+ }
206
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,IAAI,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,SAAS,E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