ts-proto 1.110.4 → 1.111.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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
# [1.111.0](https://github.com/stephenh/ts-proto/compare/v1.110.4...v1.111.0) (2022-05-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* include service and definition types with implementations ([#552](https://github.com/stephenh/ts-proto/issues/552)) ([6b896f4](https://github.com/stephenh/ts-proto/commit/6b896f4b7f4ba0f0d97730767421786171646aea))
|
|
7
|
+
|
|
8
|
+
## [next](https://github.com/stephenh/ts-proto/compare/v1.110.4...main) (????-??-??)
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* When outputing service and service definition implementations, include types. Eg, before:
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
export const TestDefinition = {
|
|
16
|
+
name: 'Test',
|
|
17
|
+
fullName: 'simple.Test',
|
|
18
|
+
methods: {
|
|
19
|
+
…
|
|
20
|
+
},
|
|
21
|
+
} as const;
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Now:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
export type TestDefinition = typeof TestDefinition;
|
|
28
|
+
export const TestDefinition = {
|
|
29
|
+
name: 'Test',
|
|
30
|
+
fullName: 'simple.Test',
|
|
31
|
+
methods: {
|
|
32
|
+
…
|
|
33
|
+
},
|
|
34
|
+
} as const;
|
|
35
|
+
```
|
|
36
|
+
|
|
1
37
|
## [1.110.4](https://github.com/stephenh/ts-proto/compare/v1.110.3...v1.110.4) (2022-04-08)
|
|
2
38
|
|
|
3
39
|
|
package/README.markdown
CHANGED
|
@@ -473,7 +473,7 @@ If you need ts-proto customizations or priority support for your company, you ca
|
|
|
473
473
|
|
|
474
474
|
**Setup**
|
|
475
475
|
|
|
476
|
-
The commands below assume you have **Docker** installed. To use a **local** copy of `protoc` without docker, use commands suffixed with `:local`
|
|
476
|
+
The commands below assume you have **Docker** installed. To use a **local** copy of `protoc` without docker, use commands suffixed with `:local`. If you are using OS X, install **coreutils**, `brew install coreutils`.
|
|
477
477
|
|
|
478
478
|
- Check out the [repository]() for the latest code.
|
|
479
479
|
- Run `yarn install` to install the dependencies.
|
|
@@ -784,4 +784,4 @@ Where (\*) indicates they might throw an error at runtime.
|
|
|
784
784
|
- Required primitives: use as-is, i.e. `string name = 1`.
|
|
785
785
|
- Optional primitives: use wrapper types, i.e. `StringValue name = 1`.
|
|
786
786
|
- Required messages: not available
|
|
787
|
-
- Optional
|
|
787
|
+
- Optional messages: use as-is, i.e. `SubMessage message = 1`.
|
|
@@ -14,9 +14,14 @@ function generateGenericServiceDefinition(ctx, fileDesc, sourceInfo, serviceDesc
|
|
|
14
14
|
var _a, _b, _c;
|
|
15
15
|
const chunks = [];
|
|
16
16
|
utils_1.maybeAddComment(sourceInfo, chunks, (_a = serviceDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
|
|
17
|
+
// Service definition type
|
|
18
|
+
const name = ts_poet_1.def(`${serviceDesc.name}Definition`);
|
|
19
|
+
chunks.push(ts_poet_1.code `
|
|
20
|
+
export type ${name} = typeof ${name};
|
|
21
|
+
`);
|
|
17
22
|
// Service definition
|
|
18
23
|
chunks.push(ts_poet_1.code `
|
|
19
|
-
export const ${
|
|
24
|
+
export const ${name} = {
|
|
20
25
|
`);
|
|
21
26
|
(_b = serviceDesc.options) === null || _b === void 0 ? void 0 : _b.uninterpretedOption;
|
|
22
27
|
chunks.push(ts_poet_1.code `
|
|
@@ -42,9 +42,14 @@ function generateServiceDefinition(ctx, fileDesc, sourceInfo, serviceDesc) {
|
|
|
42
42
|
var _a, _b;
|
|
43
43
|
const chunks = [];
|
|
44
44
|
utils_1.maybeAddComment(sourceInfo, chunks, (_a = serviceDesc.options) === null || _a === void 0 ? void 0 : _a.deprecated);
|
|
45
|
+
// Service definition type
|
|
46
|
+
const name = ts_poet_1.def(`${serviceDesc.name}Service`);
|
|
47
|
+
chunks.push(ts_poet_1.code `
|
|
48
|
+
export type ${name} = typeof ${name};
|
|
49
|
+
`);
|
|
45
50
|
// Service definition
|
|
46
51
|
chunks.push(ts_poet_1.code `
|
|
47
|
-
export const ${
|
|
52
|
+
export const ${name} = {
|
|
48
53
|
`);
|
|
49
54
|
for (const [index, methodDesc] of serviceDesc.method.entries()) {
|
|
50
55
|
utils_1.assertInstanceOf(methodDesc, utils_1.FormattedMethodDescriptor);
|