typespec-rust-emitter 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.
Files changed (43) hide show
  1. package/README.md +220 -0
  2. package/dist/src/emitter.d.ts +7 -0
  3. package/dist/src/emitter.js +490 -0
  4. package/dist/src/emitter.js.map +1 -0
  5. package/dist/src/index.d.ts +3 -0
  6. package/dist/src/index.js +4 -0
  7. package/dist/src/index.js.map +1 -0
  8. package/dist/src/lib.d.ts +12 -0
  9. package/dist/src/lib.js +7 -0
  10. package/dist/src/lib.js.map +1 -0
  11. package/dist/src/testing/index.d.ts +2 -0
  12. package/dist/src/testing/index.js +8 -0
  13. package/dist/src/testing/index.js.map +1 -0
  14. package/dist/test/hello.test.d.ts +1 -0
  15. package/dist/test/hello.test.js +140 -0
  16. package/dist/test/hello.test.js.map +1 -0
  17. package/dist/test/test-host.d.ts +4 -0
  18. package/dist/test/test-host.js +16 -0
  19. package/dist/test/test-host.js.map +1 -0
  20. package/eslint.config.js +20 -0
  21. package/example/lib/learning/models.tsp +189 -0
  22. package/example/lib/learning/operations.tsp +319 -0
  23. package/example/main.tsp +8 -0
  24. package/example/output-rust/Cargo.lock +1731 -0
  25. package/example/output-rust/Cargo.toml +12 -0
  26. package/example/output-rust/src/generated/mod.rs +1 -0
  27. package/example/output-rust/src/generated/types.rs +315 -0
  28. package/example/output-rust/src/main.rs +5 -0
  29. package/example/output-rust/src/mod.rs +1 -0
  30. package/example/package-lock.json +1495 -0
  31. package/example/package.json +15 -0
  32. package/example/tspconfig.yaml +10 -0
  33. package/justfile +15 -0
  34. package/package.json +64 -0
  35. package/prettierrc.yaml +8 -0
  36. package/src/emitter.ts +685 -0
  37. package/src/index.ts +3 -0
  38. package/src/lib.ts +8 -0
  39. package/src/lib.tsp +6 -0
  40. package/src/testing/index.ts +8 -0
  41. package/test/hello.test.ts +168 -0
  42. package/test/test-host.ts +20 -0
  43. package/tsconfig.json +18 -0
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "example",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "private": true,
6
+ "dependencies": {
7
+ "@typespec/compiler": "latest",
8
+ "@typespec/http": "latest",
9
+ "@typespec/rest": "latest",
10
+ "@typespec/openapi": "latest",
11
+ "@typespec/openapi3": "latest",
12
+ "typespec-rust-emitter": "file:.."
13
+ },
14
+ "packageManager": "npm@11.12.1+sha512.cdca14b85d647b3192028d02aadbe82d75f79a446aceea9874be98e6d768f20ebd3555770a48d0e9906106007877bbc690f715e9372f2e2dc644a3c3157fb14c"
15
+ }
@@ -0,0 +1,10 @@
1
+ emit:
2
+ - "@typespec/openapi3"
3
+ - "typespec-rust-emitter"
4
+ options:
5
+ "@typespec/openapi3":
6
+ emitter-output-dir: "{output-dir}/schema"
7
+ openapi-versions:
8
+ - 3.1.0
9
+ "typespec-rust-emitter":
10
+ emitter-output-dir: "{output-dir}/../output-rust/src/generated"
package/justfile ADDED
@@ -0,0 +1,15 @@
1
+ build:
2
+ npm run build
3
+
4
+ install:
5
+ npm install
6
+ cd example && npm install
7
+
8
+ compile: install
9
+ cd example && rm -rf output-rust/src/generated && mkdir -p output-rust/src/generated && tsp compile . && echo 'mod types;' > output-rust/src/generated/mod.rs
10
+
11
+ test:
12
+ npm test
13
+
14
+ check-rust:
15
+ cd example/output-rust && cargo check
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "typespec-rust-emitter",
3
+ "version": "0.1.0",
4
+ "description": "TypeSpec emitter that generates idiomatic Rust types and structs",
5
+ "keywords": [
6
+ "typespec",
7
+ "typespec-emitter",
8
+ "rust",
9
+ "codegen",
10
+ "openapi",
11
+ "api"
12
+ ],
13
+ "author": {
14
+ "name": "opencode",
15
+ "url": "https://opencode.ai"
16
+ },
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/cuikho210/typespec-rust-emitter"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/cuikho210/typespec-rust-emitter/issues"
24
+ },
25
+ "homepage": "https://github.com/cuikho210/typespec-rust-emitter#readme",
26
+ "type": "module",
27
+ "main": "dist/src/index.js",
28
+ "tspMain": "src/lib.tsp",
29
+ "exports": {
30
+ ".": {
31
+ "typespec": "./src/lib.tsp",
32
+ "types": "./dist/src/index.d.ts",
33
+ "default": "./dist/src/index.js"
34
+ },
35
+ "./testing": {
36
+ "types": "./dist/src/testing/index.d.ts",
37
+ "default": "./dist/src/testing/index.js"
38
+ }
39
+ },
40
+ "peerDependencies": {
41
+ "@typespec/compiler": ">=1.0.0",
42
+ "@typespec/emitter-framework": "^0.17.0"
43
+ },
44
+ "devDependencies": {
45
+ "@types/node": "latest",
46
+ "@typespec/compiler": "latest",
47
+ "eslint": "^9.15.0",
48
+ "prettier": "^3.3.3",
49
+ "typescript": "^5.3.3",
50
+ "typescript-eslint": "^8.49.0"
51
+ },
52
+ "scripts": {
53
+ "build": "tsc",
54
+ "watch": "tsc --watch",
55
+ "test": "tsc && node --test 'dist/test**/*.test.js'",
56
+ "lint": "eslint src/ test/ --report-unused-disable-directives --max-warnings=0",
57
+ "lint:fix": "eslint . --report-unused-disable-directives --fix",
58
+ "format": "prettier . --write",
59
+ "format:check": "prettier --check ."
60
+ },
61
+ "engines": {
62
+ "node": ">=18.0.0"
63
+ }
64
+ }
@@ -0,0 +1,8 @@
1
+ trailingComma: "all"
2
+ printWidth: 120
3
+ quoteProps: "consistent"
4
+ endOfLine: lf
5
+ arrowParens: always
6
+ plugins:
7
+ - "./node_modules/@typespec/prettier-plugin-typespec/dist/index.js"
8
+ overrides: [{ "files": "*.tsp", "options": { "parser": "typespec" } }]