@typespec/protobuf 0.47.0-dev.1 → 0.47.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.
@@ -1,3 +1,3 @@
1
1
  {
2
- "nonCachedDurationMs": 8603.385100000072
2
+ "nonCachedDurationMs": 9206.23629999999
3
3
  }
@@ -0,0 +1,48 @@
1
+ Invoking: c8 mocha --forbid-only
2
+
3
+
4
+ protobuf scenarios
5
+ √ addressbook (498ms)
6
+ √ anonymous-model (159ms)
7
+ √ anonymous-package (63ms)
8
+ √ array (112ms)
9
+ √ array-nested (65ms)
10
+ √ cross package references (50ms)
11
+ √ derived-scalar (58ms)
12
+ √ enum (59ms)
13
+ √ enum-nonintegral (56ms)
14
+ √ enum-nozero (51ms)
15
+ √ extern (53ms)
16
+ √ illegal field reservations (118ms)
17
+ √ inferred-message-names (79ms)
18
+ √ intrinsics (47ms)
19
+ √ map
20
+ √ model-no-package (93ms)
21
+ √ name-collision (60ms)
22
+ √ options (176ms)
23
+ √ options-invalid (153ms)
24
+ √ reserved field collisions (70ms)
25
+ √ reserved fields (65ms)
26
+ √ simple (45ms)
27
+ √ simple-error
28
+ √ simple-no-service (52ms)
29
+ √ streams
30
+ √ type-validation (76ms)
31
+ √ union (194ms)
32
+
33
+
34
+ 27 passing (3s)
35
+
36
+ ---------------|---------|----------|---------|---------|-------------------------------------------
37
+ File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
38
+ ---------------|---------|----------|---------|---------|-------------------------------------------
39
+ All files | 94.87 | 88.37 | 98.57 | 94.87 |
40
+ src | 99.12 | 96.22 | 97.29 | 99.12 |
41
+ ast.ts | 100 | 100 | 100 | 100 |
42
+ index.ts | 100 | 100 | 100 | 100 |
43
+ lib.ts | 100 | 100 | 100 | 100 |
44
+ proto.ts | 100 | 100 | 100 | 100 |
45
+ write.ts | 96.72 | 93.75 | 94.73 | 96.72 | 75-76,144-149
46
+ src/transform | 90.91 | 84.61 | 100 | 90.91 |
47
+ index.ts | 90.91 | 84.61 | 100 | 90.91 | ...96,948,950-953,955,970,973,975-978,980
48
+ ---------------|---------|----------|---------|---------|-------------------------------------------
@@ -0,0 +1,3 @@
1
+ {
2
+ "nonCachedDurationMs": 5457.190900000278
3
+ }
@@ -4,12 +4,12 @@
4
4
  "packages/protobuf/.eslintrc.cjs": "c0b2a9d1a75f440ffef72d32c607bb2cbe488eae",
5
5
  "packages/protobuf/.gitignore": "bea41e259d6405a4b1ac623184eaddabd0a7707f",
6
6
  "packages/protobuf/.mocharc.yaml": "2c757438b54590650819b87f0115efd0a4bd8b4c",
7
- "packages/protobuf/CHANGELOG.json": "ea1b676c0bfc365dc16a5d21370ffaa7a16d5921",
8
- "packages/protobuf/CHANGELOG.md": "3619b4df750735949ae74a84468f60fd84fdd1f7",
7
+ "packages/protobuf/CHANGELOG.json": "d9d15b50940ca9e0619443e8c2c9bb7420267285",
8
+ "packages/protobuf/CHANGELOG.md": "83c9a9cd0ae0630537b081da2401051362875709",
9
9
  "packages/protobuf/LICENSE": "21071075c24599ee98254f702bcfc504cdc275a6",
10
- "packages/protobuf/README.md": "5143cc0445ca5d50a5b1bda93ea2cc5370943bd9",
10
+ "packages/protobuf/README.md": "3c5287aedeb2860d1a52bbb8cb0de296f25c9844",
11
11
  "packages/protobuf/lib/proto.tsp": "fa892bfbd7ebc7b62331c520d9639cbe93527446",
12
- "packages/protobuf/package.json": "2b99af296d616de404fcdaac271cfd392cafa8a1",
12
+ "packages/protobuf/package.json": "c144eb51c67ef3c9e2809bdee03e13e73331fefe",
13
13
  "packages/protobuf/src/ast.ts": "c43456893db4c92d309a159d245ac57da1be0d1d",
14
14
  "packages/protobuf/src/index.ts": "0dd36fbcc216cc478f19af2bb5d04d970eb8bfc1",
15
15
  "packages/protobuf/src/lib.ts": "53f0ac77e39822248a6267691d7b4de01e29f6d4",
@@ -76,7 +76,7 @@
76
76
  "packages/protobuf/test/scenarios/union/diagnostics.txt": "d63834c5727e7b621a2ddbd72f94da4eb8e6611d",
77
77
  "packages/protobuf/test/scenarios/union/input/main.tsp": "76ac3fdd8f79d7603074dc4c24a644531e971bc4",
78
78
  "packages/protobuf/tsconfig.json": "3723ffd27d082799c5ea0776020c838be131cbc3",
79
- "packages/protobuf/.rush/temp/shrinkwrap-deps.json": "c872104fd090bc92582b2a0b81a44c1c6f8a021b"
79
+ "packages/protobuf/.rush/temp/shrinkwrap-deps.json": "d49c324647a341d8e7009f3abb1294772819a65f"
80
80
  },
81
81
  "arguments": "tsc -p . "
82
82
  }
@@ -0,0 +1,82 @@
1
+ {
2
+ "files": {
3
+ "packages/protobuf/.c8rc.json": "df1397419db4181073b8e496d18f636dfca6a610",
4
+ "packages/protobuf/.eslintrc.cjs": "c0b2a9d1a75f440ffef72d32c607bb2cbe488eae",
5
+ "packages/protobuf/.gitignore": "bea41e259d6405a4b1ac623184eaddabd0a7707f",
6
+ "packages/protobuf/.mocharc.yaml": "2c757438b54590650819b87f0115efd0a4bd8b4c",
7
+ "packages/protobuf/CHANGELOG.json": "d9d15b50940ca9e0619443e8c2c9bb7420267285",
8
+ "packages/protobuf/CHANGELOG.md": "83c9a9cd0ae0630537b081da2401051362875709",
9
+ "packages/protobuf/LICENSE": "21071075c24599ee98254f702bcfc504cdc275a6",
10
+ "packages/protobuf/README.md": "3c5287aedeb2860d1a52bbb8cb0de296f25c9844",
11
+ "packages/protobuf/lib/proto.tsp": "fa892bfbd7ebc7b62331c520d9639cbe93527446",
12
+ "packages/protobuf/package.json": "c144eb51c67ef3c9e2809bdee03e13e73331fefe",
13
+ "packages/protobuf/src/ast.ts": "c43456893db4c92d309a159d245ac57da1be0d1d",
14
+ "packages/protobuf/src/index.ts": "0dd36fbcc216cc478f19af2bb5d04d970eb8bfc1",
15
+ "packages/protobuf/src/lib.ts": "53f0ac77e39822248a6267691d7b4de01e29f6d4",
16
+ "packages/protobuf/src/proto.ts": "249a89f1c1e04ba5df5cda86106fe4ff2203193e",
17
+ "packages/protobuf/src/transform/index.ts": "25d9bbd7aab7d54ca65cd92b96dad6e61a152807",
18
+ "packages/protobuf/src/write.ts": "5826d5d4048ccf39cb57c59566dd05de6c0fc657",
19
+ "packages/protobuf/test/include/foo/bar.proto": "ac62127a60f6e94bb43ca42f93567cf0a87e0031",
20
+ "packages/protobuf/test/scenarios.test.ts": "828e32d8fa03b74b78cb28a117d447ef0b1671cb",
21
+ "packages/protobuf/test/scenarios/addressbook/input/addressbook.tsp": "d0fdd62b034460b6a5d7f9fd4036179f8bc15ad1",
22
+ "packages/protobuf/test/scenarios/addressbook/input/main.tsp": "4153b8ec33c51477b669d0f416dc0d092d4059f4",
23
+ "packages/protobuf/test/scenarios/addressbook/output/@typespec/protobuf/addressbook.proto": "2fdbab6edee88a268eb102ea5021cb45a856cf23",
24
+ "packages/protobuf/test/scenarios/addressbook/output/@typespec/protobuf/main.proto": "dde2c147648c20ca1f577925d4c9a0576246c4ae",
25
+ "packages/protobuf/test/scenarios/anonymous-model/diagnostics.txt": "63249e042038962d228c8a34078b9221443d97e3",
26
+ "packages/protobuf/test/scenarios/anonymous-model/input/main.tsp": "ef50660d20680733da474e2d8e0acc8858ead2ef",
27
+ "packages/protobuf/test/scenarios/anonymous-package/input/main.tsp": "4c07fd10d79d9fbfad2e0461fe87afcd3d22b428",
28
+ "packages/protobuf/test/scenarios/anonymous-package/output/@typespec/protobuf/main.proto": "b990bd3bf456f2998b3f2e49ab56e0fc45aa9037",
29
+ "packages/protobuf/test/scenarios/array-nested/diagnostics.txt": "7c873a7afeae5413eaea0b4d416bdd37f3eaa8a5",
30
+ "packages/protobuf/test/scenarios/array-nested/input/main.tsp": "64ad31180c3bd805ac900c37038c12b6dfa90dd6",
31
+ "packages/protobuf/test/scenarios/array/input/main.tsp": "4fb4ba7ddbffe83c809c473a1c5efc3985f4b4e6",
32
+ "packages/protobuf/test/scenarios/array/output/@typespec/protobuf/com/azure/test.proto": "c3bd262fb2390ec052db0c439d7e605effebf3c8",
33
+ "packages/protobuf/test/scenarios/cross package references/input/main.tsp": "81470b434e1b2c8b861d637fb6ac8d26dd4db093",
34
+ "packages/protobuf/test/scenarios/cross package references/output/@typespec/protobuf/A.proto": "0eae330f106a32900a7f5709d896e01d60c553d8",
35
+ "packages/protobuf/test/scenarios/cross package references/output/@typespec/protobuf/B.proto": "bcaece25e2ff4440f1cc9151d6af43655d482f02",
36
+ "packages/protobuf/test/scenarios/derived-scalar/input/main.tsp": "f02f998755fac51c602c27b43624c00b4d6c9af1",
37
+ "packages/protobuf/test/scenarios/derived-scalar/output/@typespec/protobuf/com/azure/Test.proto": "32114a3b14a34fae397d6d03925afa14b5c456d5",
38
+ "packages/protobuf/test/scenarios/enum-nonintegral/diagnostics.txt": "327989959cde66511b02ec3f8e15d4a9cbe021e1",
39
+ "packages/protobuf/test/scenarios/enum-nonintegral/input/main.tsp": "231edf79ea384e1c5ed932586e52a88234106257",
40
+ "packages/protobuf/test/scenarios/enum-nozero/diagnostics.txt": "e4f6b67f2b384cfc84fd011bd7804f9a3451f058",
41
+ "packages/protobuf/test/scenarios/enum-nozero/input/main.tsp": "12b298f1b0f35e6df48de88f7d5e738416e4cc09",
42
+ "packages/protobuf/test/scenarios/enum/input/main.tsp": "e40d8df990f6aa1f53c88b415fafa29daa7e51a6",
43
+ "packages/protobuf/test/scenarios/enum/output/@typespec/protobuf/main.proto": "9d8ae850a0b3e2267dd1ebfa41f0721132f7fa13",
44
+ "packages/protobuf/test/scenarios/extern/input/main.tsp": "2d61b90d8ff094d464cec8d64f056701ff9077b0",
45
+ "packages/protobuf/test/scenarios/extern/output/@typespec/protobuf/main.proto": "119d0339a8614e2e86b141a3279a87d12570b785",
46
+ "packages/protobuf/test/scenarios/illegal field reservations/diagnostics.txt": "794e8483e6e16e90989ba829d6511dfa9ec55051",
47
+ "packages/protobuf/test/scenarios/illegal field reservations/input/main.tsp": "c57f720991d6e38b69d949d360aa0094f561a81b",
48
+ "packages/protobuf/test/scenarios/inferred-message-names/input/main.tsp": "c91c1e9048a608b161ef76f9c122ac03dbf7abb9",
49
+ "packages/protobuf/test/scenarios/inferred-message-names/output/@typespec/protobuf/com/azure/test.proto": "6337433b26d1e1522b47d87f3db71416231c35f6",
50
+ "packages/protobuf/test/scenarios/intrinsics/input/main.tsp": "3fcc60752e42601de6f48a40550eace24c096287",
51
+ "packages/protobuf/test/scenarios/intrinsics/output/@typespec/protobuf/com/azure/Test.proto": "292c1a06207995cc9ab3bd2fc7e8eb3515af2465",
52
+ "packages/protobuf/test/scenarios/map/input/main.tsp": "b09d77d9ccb1975d2555c54ac1b89880e8dd2137",
53
+ "packages/protobuf/test/scenarios/map/output/@typespec/protobuf/main.proto": "6907839def44a3e343fe382e5ef0a0cb2eba8127",
54
+ "packages/protobuf/test/scenarios/model-no-package/diagnostics.txt": "308c890579a56ebe8778d093766c08419d1b2959",
55
+ "packages/protobuf/test/scenarios/model-no-package/input/main.tsp": "4cd41b90f770c35267aebb34522a366833c1e914",
56
+ "packages/protobuf/test/scenarios/name-collision/input/main.tsp": "e8ae67325e708985137c20f05b5f494601053ac2",
57
+ "packages/protobuf/test/scenarios/name-collision/output/@typespec/protobuf/main.proto": "bd7a640d097be42434625aeb41a68ca96582b275",
58
+ "packages/protobuf/test/scenarios/options-invalid/diagnostics.txt": "904a5d524dd7c06aa03e82c5b54303355758d824",
59
+ "packages/protobuf/test/scenarios/options-invalid/input/main.tsp": "26f01df0b86e440632fe8a19f1c93c5ee67541ae",
60
+ "packages/protobuf/test/scenarios/options/input/main.tsp": "427312d83245e2832daa9c73aa8a896203614b5b",
61
+ "packages/protobuf/test/scenarios/options/output/@typespec/protobuf/com/azure/Test.proto": "f5457833f28994a21b4c29eeb57222353072d708",
62
+ "packages/protobuf/test/scenarios/reserved field collisions/diagnostics.txt": "c609a427259a32cdc7187c700ea69d691c389e79",
63
+ "packages/protobuf/test/scenarios/reserved field collisions/input/main.tsp": "4046c2b39f56feeb16095bbe6d392155fed60987",
64
+ "packages/protobuf/test/scenarios/reserved fields/input/main.tsp": "2bfbc9e169d971ca0e83c9ef010cbf069845efb4",
65
+ "packages/protobuf/test/scenarios/reserved fields/output/@typespec/protobuf/main.proto": "478af2f97cc7d1c792f78dc2f0ab5e3bda991a0c",
66
+ "packages/protobuf/test/scenarios/simple-error/diagnostics.txt": "82fb428dd13d08f89d2c3945beaa97f8825a76e4",
67
+ "packages/protobuf/test/scenarios/simple-error/input/main.tsp": "9f013ef3b9d7f32ff121ff3618586902368c9617",
68
+ "packages/protobuf/test/scenarios/simple-no-service/input/main.tsp": "c70c2060d1309413558127805c08e066911ce478",
69
+ "packages/protobuf/test/scenarios/simple-no-service/output/@typespec/protobuf/com/azure/Test.proto": "2aeda7b5782b6deb105172c9f84474181c3b359f",
70
+ "packages/protobuf/test/scenarios/simple/input/main.tsp": "d8c0c0053674b7734319d699a4cac949524a8bd3",
71
+ "packages/protobuf/test/scenarios/simple/output/@typespec/protobuf/com/azure/Test.proto": "32114a3b14a34fae397d6d03925afa14b5c456d5",
72
+ "packages/protobuf/test/scenarios/streams/input/main.tsp": "4ce0b3191d631feb6236472a1a73564623287fe0",
73
+ "packages/protobuf/test/scenarios/streams/output/@typespec/protobuf/main.proto": "31181e2591d4ec599c484fd7c7545d720faf5733",
74
+ "packages/protobuf/test/scenarios/type-validation/diagnostics.txt": "03dbc58ab1ff922efb279cdfcd7a8ceacd42a339",
75
+ "packages/protobuf/test/scenarios/type-validation/input/main.tsp": "cb6a5aeb8c2084b38b2432fa0a0b63d71276a342",
76
+ "packages/protobuf/test/scenarios/union/diagnostics.txt": "d63834c5727e7b621a2ddbd72f94da4eb8e6611d",
77
+ "packages/protobuf/test/scenarios/union/input/main.tsp": "76ac3fdd8f79d7603074dc4c24a644531e971bc4",
78
+ "packages/protobuf/tsconfig.json": "3723ffd27d082799c5ea0776020c838be131cbc3",
79
+ "packages/protobuf/.rush/temp/shrinkwrap-deps.json": "d49c324647a341d8e7009f3abb1294772819a65f"
80
+ },
81
+ "arguments": "c8 mocha --forbid-only "
82
+ }
@@ -1,5 +1,5 @@
1
1
  {
2
- "../../packages/protobuf": "../../packages/protobuf:z14TZ8lLeAPWlbSxL1IWc18YqrJnV9q78fCk6LxSILU=:",
2
+ "../../packages/protobuf": "../../packages/protobuf:LWUXE5ILZg5pyanTv5uDBMzfw+yLOQ8AQKSyv2uH7dk=:",
3
3
  "/@bcoe/v8-coverage@0.2.3": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==",
4
4
  "/@eslint-community/eslint-utils@4.4.0(eslint@8.42.0)": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==",
5
5
  "/@eslint-community/regexpp@4.5.1": "sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ==",
@@ -172,7 +172,7 @@
172
172
  "/to-regex-range@5.0.1": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
173
173
  "/type-check@0.4.0": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==",
174
174
  "/type-fest@0.20.2": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==",
175
- "/typescript@5.1.3": "sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw==",
175
+ "/typescript@5.1.5": "sha512-FOH+WN/DQjUvN6WgW+c4Ml3yi0PH+a/8q+kNIfRehv1wLhWONedw85iu+vQ39Wp49IzTJEsZ2lyLXpBF7mkF1g==",
176
176
  "/uri-js@4.4.1": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
177
177
  "/v8-to-istanbul@9.1.0": "sha512-6z3GW9x8G1gd+JIIgQQQxXuiJtCXeAjp6RaPEPLv62mH3iPHPxV6W3robxtCzNErRo6ZwTmzWhsbNvjyEBKzKA==",
178
178
  "/which@2.0.2": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
package/CHANGELOG.json CHANGED
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "name": "@typespec/protobuf",
3
3
  "entries": [
4
+ {
5
+ "version": "0.47.0",
6
+ "tag": "@typespec/protobuf_v0.47.0",
7
+ "date": "Tue, 08 Aug 2023 22:32:10 GMT",
8
+ "comments": {}
9
+ },
4
10
  {
5
11
  "version": "0.46.0",
6
12
  "tag": "@typespec/protobuf_v0.46.0",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Change Log - @typespec/protobuf
2
2
 
3
- This log was last generated on Tue, 11 Jul 2023 22:06:00 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 08 Aug 2023 22:32:10 GMT and should not be manually modified.
4
+
5
+ ## 0.47.0
6
+ Tue, 08 Aug 2023 22:32:10 GMT
7
+
8
+ _Version update only_
4
9
 
5
10
  ## 0.46.0
6
11
  Tue, 11 Jul 2023 22:06:00 GMT
package/README.md CHANGED
@@ -1,30 +1,213 @@
1
- # TypeSpec Protobuf library and emitter
1
+ # @typespec/protobuf
2
2
 
3
- **Warning** :warning:: This pre-release emitter is in active development and may change. Your feedback is highly appreciated.
4
-
5
- This package provides support for defining and emitting Protobuf specifications in [TypeSpec](https://github.com/microsoft/typespec) and an emitter that generates Protobuf output files from TypeSpec sources.
3
+ TypeSpec library and emitter for Protobuf (gRPC)
6
4
 
7
5
  ## Install
8
6
 
9
- In your project root:
10
-
11
7
  ```bash
12
8
  npm install @typespec/protobuf
13
9
  ```
14
10
 
15
- ## Using the Protobuf emitter
11
+ ## Emitter
12
+
13
+ ### Usage
16
14
 
17
- 1. Using the TypeSpec CLI (`tsp`):
15
+ 1. Via the command line
18
16
 
19
17
  ```bash
20
- tsp compile . --emit @typespec/protobuf
18
+ tsp compile . --emit=@typespec/protobuf
21
19
  ```
22
20
 
23
- 2. Using the TypeSpec project configuration file:
24
-
25
- Add the following to your `tspproject.yaml` file.
21
+ 2. Via the config
26
22
 
27
23
  ```yaml
28
24
  emit:
29
25
  - "@typespec/protobuf"
30
26
  ```
27
+
28
+ ### Emitter options
29
+
30
+ #### `noEmit`
31
+
32
+ **Type:** `boolean`
33
+
34
+ ## Decorators
35
+
36
+ ### TypeSpec.Protobuf
37
+
38
+ - [`@field`](#@field)
39
+ - [`@message`](#@message)
40
+ - [`@package`](#@package)
41
+ - [`@reserve`](#@reserve)
42
+ - [`@service`](#@service)
43
+ - [`@stream`](#@stream)
44
+
45
+ #### `@field`
46
+
47
+ Defines the field index of a model property for conversion to a Protobuf
48
+ message.
49
+
50
+ The field index of a Protobuf message must:
51
+
52
+ - fall between 1 and 2<sup>29</sup> - 1, inclusive.
53
+ - not fall within the implementation reserved range of 19000 to 19999, inclusive.
54
+ - not fall within any range that was [marked reserved](#
55
+
56
+ ```typespec
57
+ @TypeSpec.Protobuf.field(index: valueof uint32)
58
+ ```
59
+
60
+ ##### Target
61
+
62
+ `ModelProperty`
63
+
64
+ ##### Parameters
65
+
66
+ | Name | Type | Description |
67
+ | ----- | ----------------------- | ------------------------------------ |
68
+ | index | `valueof scalar uint32` | The whole-number index of the field. |
69
+
70
+ ##### Examples
71
+
72
+ ```typespec
73
+ model ExampleMessage {
74
+ @field(1)
75
+ test: string;
76
+ }
77
+ ```
78
+
79
+ #### `@message`
80
+
81
+ Declares that a model is a Protobuf message.
82
+
83
+ Messages can be detected automatically if either of the following two conditions are met:
84
+
85
+ - The model has a `@field` annotation on all of its properties.
86
+ - The model is referenced by any service operation.
87
+
88
+ This decorator will force the emitter to check and emit a model.
89
+
90
+ ```typespec
91
+ @TypeSpec.Protobuf.message
92
+ ```
93
+
94
+ ##### Target
95
+
96
+ `model {}`
97
+
98
+ ##### Parameters
99
+
100
+ None
101
+
102
+ #### `@package`
103
+
104
+ Declares that a TypeSpec namespace constitutes a Protobuf package. The contents of the namespace will be emitted to a
105
+ single Protobuf file.
106
+
107
+ ```typespec
108
+ @TypeSpec.Protobuf.package(details?: TypeSpec.Protobuf.PackageDetails)
109
+ ```
110
+
111
+ ##### Target
112
+
113
+ `Namespace`
114
+
115
+ ##### Parameters
116
+
117
+ | Name | Type | Description |
118
+ | ------- | ---------------------------------------- | ----------------------------------- |
119
+ | details | `model TypeSpec.Protobuf.PackageDetails` | the optional details of the package |
120
+
121
+ #### `@reserve`
122
+
123
+ Reserve a field index, range, or name. If a field definition collides with a reservation, the emitter will produce
124
+ an error.
125
+
126
+ This decorator accepts multiple reservations. Each reservation is one of the following:
127
+
128
+ - a `string`, in which case the reservation refers to a field name.
129
+ - a `uint32`, in which case the reservation refers to a field index.
130
+ - a tuple `[uint32, uint32]`, in which case the reservation refers to a field range that is _inclusive_ of both ends.
131
+
132
+ Unlike in Protobuf, where field name and index reservations must be separated, you can mix string and numeric field
133
+ reservations in a single `@reserve` call in TypeSpec.
134
+
135
+ #### API Compatibility Note
136
+
137
+ Field reservations prevent users of your Protobuf specification from using the given field names or indices. This can
138
+ be useful if a field is removed, as it will further prevent adding a new, incompatible field and will prevent users
139
+ from utilizing the field index at runtime in a way that may break compatibility with users of older specifications.
140
+
141
+ See _[Protobuf Language Guide - Reserved Fields](https://protobuf.dev/programming-guides/proto3/#reserved)_ for more
142
+ information.
143
+
144
+ ```typespec
145
+ @TypeSpec.Protobuf.reserve(...reservations: valueof string | [uint32, uint32] | uint32[])
146
+ ```
147
+
148
+ ##### Target
149
+
150
+ `model {}`
151
+
152
+ ##### Parameters
153
+
154
+ | Name | Type | Description |
155
+ | ------------ | ------------------------------------------------------ | ---------------------------- |
156
+ | reservations | `valueof model string \| [uint32, uint32] \| uint32[]` | a list of field reservations |
157
+
158
+ ##### Examples
159
+
160
+ ```typespec
161
+ // Reserve the fields 8-15 inclusive, 100, and the field name "test" within a model.
162
+ @reserve([8, 15], 100, "test")
163
+ model Example {
164
+ // ...
165
+ }
166
+ ```
167
+
168
+ #### `@service`
169
+
170
+ Declares that a TypeSpec interface constitutes a Protobuf service. The contents of the interface will be converted to
171
+ a `service` declaration in the resulting Protobuf file.
172
+
173
+ ```typespec
174
+ @TypeSpec.Protobuf.service
175
+ ```
176
+
177
+ ##### Target
178
+
179
+ `Interface`
180
+
181
+ ##### Parameters
182
+
183
+ None
184
+
185
+ #### `@stream`
186
+
187
+ Set the streaming mode of an operation. See [StreamMode](./data-types#TypeSpec.Protobuf.StreamMode) for more information.
188
+
189
+ ```typespec
190
+ @TypeSpec.Protobuf.stream(mode: TypeSpec.Protobuf.StreamMode)
191
+ ```
192
+
193
+ ##### Target
194
+
195
+ `Operation`
196
+
197
+ ##### Parameters
198
+
199
+ | Name | Type | Description |
200
+ | ---- | ----------------------------------- | ---------------------------------------------- |
201
+ | mode | `enum TypeSpec.Protobuf.StreamMode` | The streaming mode to apply to this operation. |
202
+
203
+ ##### Examples
204
+
205
+ ```typespec
206
+ @stream(StreamMode.Out)
207
+ op logs(...LogsRequest): LogEvent;
208
+ ```
209
+
210
+ ```typespec
211
+ @stream(StreamMode.Duplex)
212
+ op connectToMessageService(...Message): Message;
213
+ ```