@polytric/openws-sdkgen 0.0.4 → 0.0.6

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 (30) hide show
  1. package/README.md +2 -2
  2. package/dist/main.cjs +53 -5
  3. package/dist/main.js +53 -5
  4. package/dist/plans/dotnet.cjs +3 -3
  5. package/dist/plans/dotnet.d.cts +2 -143
  6. package/dist/plans/dotnet.d.ts +2 -143
  7. package/dist/plans/dotnet.js +2 -2
  8. package/dist/plans/typescript.cjs +569 -0
  9. package/dist/plans/typescript.d.cts +6 -0
  10. package/dist/plans/typescript.d.ts +6 -0
  11. package/dist/plans/typescript.js +532 -0
  12. package/dist/templates/dotnet/HostRole.cs.ejs +23 -8
  13. package/dist/templates/dotnet/Model.cs.ejs +1 -1
  14. package/dist/templates/dotnet/RemoteRole.cs.ejs +7 -2
  15. package/dist/templates/dotnet/UserHostRole.cs.ejs +26 -4
  16. package/dist/templates/typescript/package.json.ejs +41 -0
  17. package/dist/templates/typescript/src/core/index.ts.ejs +6 -0
  18. package/dist/templates/typescript/src/core/models/index.ts.ejs +3 -0
  19. package/dist/templates/typescript/src/core/models/model.ts.ejs +41 -0
  20. package/dist/templates/typescript/src/core/network.ts.ejs +517 -0
  21. package/dist/templates/typescript/src/core/roles/index.ts.ejs +3 -0
  22. package/dist/templates/typescript/src/core/roles/role.ts.ejs +104 -0
  23. package/dist/templates/typescript/src/index.ts.ejs +4 -0
  24. package/dist/templates/typescript/src/sdk/index.ts.ejs +3 -0
  25. package/dist/templates/typescript/src/sdk/role.ts.ejs +372 -0
  26. package/dist/templates/typescript/tsconfig.json.ejs +14 -0
  27. package/dist/templates/typescript/tsup.config.ts.ejs +10 -0
  28. package/dist/types-BdZPs123.d.cts +115 -0
  29. package/dist/types-BdZPs123.d.ts +115 -0
  30. package/package.json +13 -4
@@ -0,0 +1,115 @@
1
+ import { Spec, Endpoint } from '@polytric/openws-spec/types';
2
+
3
+ interface PipelineContext {
4
+ argv: string[];
5
+ rawInput?: RawInput;
6
+ request?: BuildRequest;
7
+ spec?: Spec;
8
+ ir?: IR;
9
+ plan?: PlanStep[];
10
+ }
11
+ interface RawInput {
12
+ spec: string;
13
+ out: string;
14
+ project: string;
15
+ hostRole: string[];
16
+ language: 'csharp' | 'javascript' | 'typescript';
17
+ environment: 'unity' | 'node' | 'browser';
18
+ frameworks?: string[];
19
+ }
20
+ interface BuildRequest {
21
+ specPath: string;
22
+ outputPath: string;
23
+ project: string;
24
+ hostRoles: string[];
25
+ target: {
26
+ csharp?: {
27
+ environment: 'unity';
28
+ frameworks?: string[];
29
+ };
30
+ javascript?: {
31
+ environment: 'node' | 'browser';
32
+ frameworks?: string[];
33
+ };
34
+ typescript?: {
35
+ environment: 'node' | 'browser';
36
+ frameworks?: string[];
37
+ };
38
+ };
39
+ }
40
+ interface IR {
41
+ package: IRPackage;
42
+ networks: IRNetwork[];
43
+ assemblyName?: string;
44
+ }
45
+ interface IRPackage {
46
+ project: string;
47
+ service: string;
48
+ description?: string;
49
+ version?: string;
50
+ }
51
+ interface IRNetwork {
52
+ name: string;
53
+ description?: string;
54
+ version?: string;
55
+ roles: IRRole[];
56
+ handlers: IRHandler[];
57
+ messages: IRMessage[];
58
+ models: IRModel[];
59
+ }
60
+ interface IRRole {
61
+ name: string;
62
+ description?: string;
63
+ isHost: boolean;
64
+ endpoints: Endpoint[];
65
+ }
66
+ interface IRHandler {
67
+ roleName: string;
68
+ handlerName: string;
69
+ description?: string;
70
+ modelClassName?: string;
71
+ messageName?: string;
72
+ methodName?: string;
73
+ }
74
+ interface IRMessage {
75
+ roleName: string;
76
+ handlerName: string;
77
+ description?: string;
78
+ modelClassName?: string;
79
+ messageName?: string;
80
+ methodName?: string;
81
+ }
82
+ interface IRModel {
83
+ scopeName: string;
84
+ modelName: string;
85
+ type: string;
86
+ description?: string;
87
+ properties?: IRProperty[];
88
+ namespace?: string;
89
+ className?: string;
90
+ }
91
+ interface IRProperty {
92
+ type: string;
93
+ scopeName: string;
94
+ modelName: string;
95
+ description?: string;
96
+ required?: boolean;
97
+ items?: {
98
+ type: string;
99
+ scopeName: string;
100
+ modelName: string;
101
+ description?: string;
102
+ };
103
+ propertyName?: string;
104
+ typeName?: string;
105
+ }
106
+ interface PlanStep {
107
+ name: string;
108
+ command: 'copy' | 'render';
109
+ input?: string;
110
+ output: string;
111
+ template?: string;
112
+ getData?: () => unknown;
113
+ }
114
+
115
+ export type { PipelineContext as P };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polytric/openws-sdkgen",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "OpenWS SDK generator CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -34,20 +34,29 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@pocketgems/schema": "^0.1.3",
37
+ "ajv": "^8.17.1",
37
38
  "ejs": "^3.1.10",
38
- "yargs": "^18.0.0"
39
+ "yargs": "^18.0.0",
40
+ "@polytric/openws-spec": "0.0.4"
39
41
  },
40
42
  "devDependencies": {
41
43
  "@types/ejs": "^3.1.5",
42
44
  "@types/node": "^22.15.29",
45
+ "@types/ws": "^8.18.1",
43
46
  "@types/yargs": "^17.0.33",
47
+ "fastify": "^5.6.2",
44
48
  "tsup": "^8.5.1",
45
49
  "tsx": "^4.21.0",
46
- "typescript": "^5.9.3"
50
+ "typescript": "^5.9.3",
51
+ "ws": "^8.18.3",
52
+ "@polytric/openws": "0.0.4"
47
53
  },
48
54
  "scripts": {
49
55
  "build": "tsup",
50
56
  "typecheck": "tsc --noEmit",
51
- "test:csharp:unity": "node dist/main.cjs --spec ./test/spec.json --out ./generated/dotnet/unity --project Example --hostRole client --language csharp --environment unity"
57
+ "test:csharp:unity": "node dist/main.cjs --spec ./test/spec.json --out ./generated/dotnet/unity --project Example --hostRole client --language csharp --environment unity",
58
+ "test:typescript:node": "node dist/main.cjs --spec ./test/spec.json --out ./generated/typescript/node --project Example --hostRole client --language typescript --environment node",
59
+ "test:typescript:server": "tsx ./test/typescript/server.ts",
60
+ "test:typescript:client": "tsx ./test/typescript/client.ts"
52
61
  }
53
62
  }