@typra/emitter 0.2.1 → 0.2.3
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 +84 -0
- package/package.json +2 -1
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# @typra/emitter
|
|
2
|
+
|
|
3
|
+
`@typra/emitter` generates runtime model surfaces from TypeSpec. Use it when
|
|
4
|
+
you want TypeSpec to be the source of truth for shared model contracts and need
|
|
5
|
+
generated code, tests, JSON AST output, or documentation for one or more
|
|
6
|
+
runtimes.
|
|
7
|
+
|
|
8
|
+
Typra is emitter-only: it generates model/protocol surfaces, but it does not
|
|
9
|
+
ship runtime service implementations or product-specific contracts.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```powershell
|
|
14
|
+
npm install --save-dev @typra/emitter @typespec/compiler
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Configure TypeSpec
|
|
18
|
+
|
|
19
|
+
Add the emitter to `tspconfig.yaml`:
|
|
20
|
+
|
|
21
|
+
```yaml
|
|
22
|
+
emit:
|
|
23
|
+
- "@typra/emitter"
|
|
24
|
+
|
|
25
|
+
options:
|
|
26
|
+
"@typra/emitter":
|
|
27
|
+
emitter-output-dir: "{cwd}/generated"
|
|
28
|
+
root-object: "MyProject.ApiRoot"
|
|
29
|
+
root-namespace: "MyProject"
|
|
30
|
+
emit-targets:
|
|
31
|
+
- type: TypeScript
|
|
32
|
+
output-dir: "generated/typescript"
|
|
33
|
+
test-dir: "generated/typescript/tests"
|
|
34
|
+
import-path: "../index"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Import the emitter library from your TypeSpec entry point:
|
|
38
|
+
|
|
39
|
+
```typespec
|
|
40
|
+
import "@typra/emitter";
|
|
41
|
+
|
|
42
|
+
namespace MyProject;
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Compile with TypeSpec:
|
|
46
|
+
|
|
47
|
+
```powershell
|
|
48
|
+
npx tsp compile ./path/to/main.tsp --config ./tspconfig.yaml
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## CLI
|
|
52
|
+
|
|
53
|
+
The package includes the `typra-generate` command:
|
|
54
|
+
|
|
55
|
+
```powershell
|
|
56
|
+
npx typra-generate --help
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Supported output
|
|
60
|
+
|
|
61
|
+
Typra includes emitters for:
|
|
62
|
+
|
|
63
|
+
- TypeScript
|
|
64
|
+
- Python
|
|
65
|
+
- C#
|
|
66
|
+
- Go
|
|
67
|
+
- Rust
|
|
68
|
+
- Markdown documentation
|
|
69
|
+
- JSON AST
|
|
70
|
+
|
|
71
|
+
The first Typra fixture slice validates TypeScript and JSON AST generation from
|
|
72
|
+
synthetic TypeSpec shapes. Additional fixture coverage will expand as the
|
|
73
|
+
extracted emitter hardens.
|
|
74
|
+
|
|
75
|
+
## Generated files
|
|
76
|
+
|
|
77
|
+
Generated source files include Typra markers, and the emitter records a
|
|
78
|
+
generated-file manifest for each output root. Stale-file deletion is not enabled
|
|
79
|
+
yet, so Typra will not remove hand-authored runtime files.
|
|
80
|
+
|
|
81
|
+
## Links
|
|
82
|
+
|
|
83
|
+
- Repository: <https://github.com/sethjuarez/typra>
|
|
84
|
+
- Package: <https://www.npmjs.com/package/@typra/emitter>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typra/emitter",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Generic TypeSpec emitter for generating multi-runtime model surfaces",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
|
+
"README.md",
|
|
33
34
|
"dist/src/**/*.js",
|
|
34
35
|
"dist/src/**/*.d.ts",
|
|
35
36
|
"dist/src/**/*.json",
|