@codenotch/codenotch.cli 1.0.33 → 1.0.34

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 (97) hide show
  1. package/dist/commands/index.js +2 -0
  2. package/dist/commands/index.js.map +1 -1
  3. package/dist/commands/validation/ValidationUtils.d.ts +28 -0
  4. package/dist/commands/validation/ValidationUtils.js +182 -0
  5. package/dist/commands/validation/ValidationUtils.js.map +1 -0
  6. package/dist/commands/validation/files/AppManifestValidator.d.ts +6 -0
  7. package/dist/commands/validation/files/AppManifestValidator.js +93 -0
  8. package/dist/commands/validation/files/AppManifestValidator.js.map +1 -0
  9. package/dist/commands/validation/files/BpmnValidator.d.ts +5 -0
  10. package/dist/commands/validation/files/BpmnValidator.js +32 -0
  11. package/dist/commands/validation/files/BpmnValidator.js.map +1 -0
  12. package/dist/commands/validation/files/DbSchemaValidator.d.ts +5 -0
  13. package/dist/commands/validation/files/DbSchemaValidator.js +16 -0
  14. package/dist/commands/validation/files/DbSchemaValidator.js.map +1 -0
  15. package/dist/commands/validation/files/DocumentValidator.d.ts +5 -0
  16. package/dist/commands/validation/files/DocumentValidator.js +12 -0
  17. package/dist/commands/validation/files/DocumentValidator.js.map +1 -0
  18. package/dist/commands/validation/files/I18nValidator.d.ts +5 -0
  19. package/dist/commands/validation/files/I18nValidator.js +13 -0
  20. package/dist/commands/validation/files/I18nValidator.js.map +1 -0
  21. package/dist/commands/validation/files/JsonValidator.d.ts +5 -0
  22. package/dist/commands/validation/files/JsonValidator.js +13 -0
  23. package/dist/commands/validation/files/JsonValidator.js.map +1 -0
  24. package/dist/commands/validation/files/ManifestCacheValidator.d.ts +5 -0
  25. package/dist/commands/validation/files/ManifestCacheValidator.js +121 -0
  26. package/dist/commands/validation/files/ManifestCacheValidator.js.map +1 -0
  27. package/dist/commands/validation/files/ManifestValidator.d.ts +5 -0
  28. package/dist/commands/validation/files/ManifestValidator.js +14 -0
  29. package/dist/commands/validation/files/ManifestValidator.js.map +1 -0
  30. package/dist/commands/validation/files/ScriptValidator.d.ts +12 -0
  31. package/dist/commands/validation/files/ScriptValidator.js +128 -0
  32. package/dist/commands/validation/files/ScriptValidator.js.map +1 -0
  33. package/dist/commands/validation/files/TableValidator.d.ts +5 -0
  34. package/dist/commands/validation/files/TableValidator.js +19 -0
  35. package/dist/commands/validation/files/TableValidator.js.map +1 -0
  36. package/dist/commands/validation/validate.d.ts +2 -0
  37. package/dist/commands/validation/validate.js +245 -0
  38. package/dist/commands/validation/validate.js.map +1 -0
  39. package/dist/utils/BuildUtils.d.ts +22 -4
  40. package/dist/utils/BuildUtils.js +45 -16
  41. package/dist/utils/BuildUtils.js.map +1 -1
  42. package/dist/utils/FileUtils.d.ts +13 -0
  43. package/dist/utils/FileUtils.js +30 -0
  44. package/dist/utils/FileUtils.js.map +1 -1
  45. package/dist/utils/I18nUtils.js +0 -2
  46. package/dist/utils/I18nUtils.js.map +1 -1
  47. package/package.json +14 -6
  48. package/.github/copilot-instructions.md +0 -3
  49. package/bin/cli.js +0 -3
  50. package/docs/ARCHITECTURE.md +0 -179
  51. package/docs/TODO.md +0 -18
  52. package/src/bin/cli.ts +0 -4
  53. package/src/commands/index.ts +0 -13
  54. package/src/commands/project/compile.ts +0 -20
  55. package/src/commands/project/deploy.ts +0 -11
  56. package/src/commands/project/index.ts +0 -28
  57. package/src/commands/project/inspect.ts +0 -12
  58. package/src/commands/project/new.ts +0 -11
  59. package/src/commands/project/open.ts +0 -21
  60. package/src/commands/project/package.ts +0 -20
  61. package/src/commands/project/refresh.ts +0 -13
  62. package/src/commands/project/remove.ts +0 -12
  63. package/src/commands/project/shared.ts +0 -9
  64. package/src/commands/project/start.ts +0 -24
  65. package/src/commands/project/test.ts +0 -15
  66. package/src/commands/react/build.ts +0 -12
  67. package/src/commands/react/index.ts +0 -12
  68. package/src/commands/react/serve.ts +0 -13
  69. package/src/commands/runtime/clear.ts +0 -11
  70. package/src/commands/runtime/index.ts +0 -24
  71. package/src/commands/runtime/info.ts +0 -47
  72. package/src/commands/runtime/latest.ts +0 -18
  73. package/src/commands/runtime/portal.ts +0 -20
  74. package/src/commands/runtime/start.ts +0 -16
  75. package/src/commands/runtime/stop.ts +0 -13
  76. package/src/commands/runtime/update.ts +0 -12
  77. package/src/commands/system/index.ts +0 -9
  78. package/src/commands/system/info.ts +0 -23
  79. package/src/commands/system/read.ts +0 -25
  80. package/src/index.ts +0 -22
  81. package/src/models/Codenotch.ts +0 -361
  82. package/src/models/DbModels.ts +0 -428
  83. package/src/models/OpenApiModels.ts +0 -145
  84. package/src/utils/BuildUtils.ts +0 -739
  85. package/src/utils/ConsoleUtils.ts +0 -22
  86. package/src/utils/FileUtils.ts +0 -266
  87. package/src/utils/GitHubAuthUtils.ts +0 -83
  88. package/src/utils/I18nUtils.ts +0 -58
  89. package/src/utils/OpenAPIUtils.ts +0 -285
  90. package/src/utils/OsUtils.ts +0 -32
  91. package/src/utils/ProjectCompilationUtils.ts +0 -1002
  92. package/src/utils/ProjectUtils.ts +0 -151
  93. package/src/utils/RuntimeUtils.ts +0 -743
  94. package/src/utils/ServeUtils.ts +0 -175
  95. package/src/utils/ShellUtils.ts +0 -26
  96. package/src/utils/StringUtils.ts +0 -80
  97. package/tsconfig.json +0 -35
@@ -1,285 +0,0 @@
1
- import OpenAPISpec, { APIController, APIParameter, APIResponse, SchemaType } from "../models/OpenApiModels";
2
- import ProjectCompilationUtils, { CompilationContext } from "./ProjectCompilationUtils";
3
- import { IVariable, VariableType } from "@codenotch/codenotch.core";
4
- import { IFlow, IProcess, IWorkflowApiEventDefinition, IWorkflowBoundary, IWorkflowCallbackEventDefinition, IWorkflowEvent, IWorkflowItem, IWorkflowItemWithPosition, IWorkflowTask, WorkflowItemType } from "@codenotch/codenotch.core.workflow";
5
-
6
- export abstract class OpenApiUtils {
7
-
8
- static async generateOpenApi(context: CompilationContext): Promise<OpenAPISpec | undefined> {
9
- let openApi = new OpenAPISpec();
10
- let apiCount = 0;
11
-
12
- for(let processId in context.processes) {
13
- if(!context.processes[processId]) {
14
- continue;
15
- }
16
-
17
- try {
18
- if (this.AddBPMN(openApi, context.processes[processId]!)) {
19
- apiCount++;
20
- }
21
- }
22
- catch (e) {
23
- context.errors.push(`Failed to add process ${processId} to OpenAPI spec: ${e instanceof Error ? e.message : String(e)}`);
24
- }
25
- }
26
-
27
- if (apiCount === 0) {
28
- return undefined;
29
- }
30
-
31
- return openApi;
32
- }
33
-
34
-
35
- /**
36
- * Convert codevariable object to openapi json standard
37
- * @param codevariable Code variable object
38
- * @returns the converted object
39
- */
40
- static CodeVariableToOpenAPISchema(codevariable: IVariable): SchemaType {
41
- let result = new SchemaType();
42
- result.properties = {};
43
- result.type = "object";
44
-
45
- codevariable.objectType?.forEach(child => {
46
- if (child.type === VariableType.object) {
47
- result.properties![child.name] = this.CodeVariableToOpenAPISchema(child);
48
- }
49
- else if (child.type === VariableType.array) {
50
- result.properties![child.name] = new SchemaType();
51
- result.properties![child.name].type = ProjectCompilationUtils.ProcessVariableTypeToJsonSchemaTypeName(child.type);
52
-
53
- if (child.arrayType) {
54
- if (child.arrayType.type === VariableType.object)
55
- result.properties![child.name].items = this.CodeVariableToOpenAPISchema(child.arrayType)
56
- else {
57
- result.properties![child.name].items = {
58
- type: ProjectCompilationUtils.ProcessVariableTypeToJsonSchemaTypeName(child.arrayType.type)
59
- }
60
- }
61
- }
62
- } else {
63
- result.properties![child.name] = new SchemaType();
64
- result.properties![child.name].type = ProjectCompilationUtils.ProcessVariableTypeToJsonSchemaTypeName(child.type);
65
- }
66
- });
67
-
68
- return result;
69
- }
70
-
71
- /**
72
- * Return parameters from codevariables
73
- * @param codevariable the codevariable source
74
- * @param intype
75
- * @param required
76
- * @returns
77
- */
78
- static CodevariableToParameters(codevariable: IVariable, intype: string, required: boolean): APIParameter[] {
79
- let result: APIParameter[] = [];
80
-
81
- codevariable?.objectType?.forEach(child => {
82
- let parameter = new APIParameter();
83
- parameter.name = child.name;
84
- parameter.in = intype;
85
- parameter.required = required;
86
- parameter.schema = new SchemaType();
87
- parameter.schema.type = ProjectCompilationUtils.ProcessVariableTypeToJsonSchemaTypeName(child.type);
88
- result.push(parameter);
89
- });
90
-
91
- return result;
92
- }
93
-
94
- /**
95
- * Browse the graph recursivly to find api error or api end event
96
- * @param item the start node
97
- * @param model the entire bpmn model
98
- * @returns the list of node to convert into openapi
99
- */
100
- static BrowseResponses(item: IWorkflowItem, model: IProcess): IWorkflowItem[] | null {
101
-
102
- let result: IWorkflowItem[];
103
-
104
- if (item.type === WorkflowItemType.ErrorEndEvent
105
- || item.type === WorkflowItemType.CallbackEndEvent
106
- || item.type === WorkflowItemType.ThrowCallbackIntermediateEvent) {
107
- result = [item as IWorkflowEvent];
108
-
109
- } else if ((item as IWorkflowTask)?.errors?.length! > 0) {
110
- result = [item as IWorkflowTask];
111
- } else {
112
- result = [];
113
- }
114
-
115
- let flows: IFlow[] = model.items.filter(c => (c as IFlow).sourceId === item.id) as IFlow[];
116
-
117
- flows?.forEach(flow => {
118
- let targetNode: IWorkflowItem = model.items.find(c => c.id === flow.targetId) as IWorkflowItem;
119
- if (targetNode) {
120
- let targetResponses = this.BrowseResponses(targetNode, model);
121
- if (targetResponses) {
122
- result = result.concat(targetResponses);
123
- }
124
- }
125
- });
126
-
127
- let boundaries: IWorkflowBoundary[] = model.items.filter(c => (c as IWorkflowBoundary).nodeId === item.id) as IWorkflowBoundary[];
128
- boundaries?.forEach(boundary => {
129
- let targetResponses = this.BrowseResponses(boundary, model);
130
- if (targetResponses) {
131
- result = result.concat(targetResponses);
132
- }
133
- });
134
-
135
- return result;
136
- }
137
-
138
- /**
139
- * Add bpmn model into open api spec
140
- * @param model Bpmn definition model
141
- */
142
- static AddBPMN(spec: OpenAPISpec, model: IProcess): boolean {
143
- //get api start
144
- let hasApi = false;
145
- let startEvents = model.items.filter(c => c.type === WorkflowItemType.ApiStartEvent);
146
- startEvents.forEach(node => {
147
- //reterieve eventnode model
148
-
149
- let startEvent = node as IWorkflowEvent;
150
-
151
- let parameters = (startEvent as IWorkflowEvent).outputs[0].outputVariables;
152
-
153
- //get definition
154
- let definition: IWorkflowApiEventDefinition = startEvent.eventDefinitions.find(c => c ) as IWorkflowApiEventDefinition;
155
- if (definition) {
156
- let apicontroller = new APIController();
157
-
158
- apicontroller.description = startEvent.desc || "";
159
-
160
- let body = parameters.find(c => c.name === "body");
161
-
162
- if (body) {
163
- apicontroller.requestBody = {
164
- "content": {
165
- "application/json": {
166
- "schema": this.CodeVariableToOpenAPISchema(body as any)
167
- }
168
- }
169
- };
170
- }
171
-
172
- let header = parameters.find(c => c.name === "header");
173
-
174
- if (header) {
175
- let parameters = this.CodevariableToParameters(header as any, "header", true);
176
- if (!apicontroller.parameters)
177
- apicontroller.parameters = parameters;
178
- else
179
- apicontroller.parameters = apicontroller.parameters.concat(parameters);
180
- }
181
-
182
- let query = parameters.find(c => c.name === "query");
183
- if (query) {
184
- let parameters = this.CodevariableToParameters(query as any, "query", true);
185
- if (!apicontroller.parameters)
186
- apicontroller.parameters = parameters;
187
- else
188
- apicontroller.parameters = apicontroller.parameters.concat(parameters);
189
- }
190
-
191
- let path = parameters.find(c => c.name === "path");
192
- if (path) {
193
- let parameters = this.CodevariableToParameters(path as any, "path", true);
194
- if (!apicontroller.parameters)
195
- apicontroller.parameters = parameters;
196
- else
197
- apicontroller.parameters = apicontroller.parameters.concat(parameters);
198
- }
199
-
200
-
201
- let responses = this.BrowseResponses(startEvent, model);
202
-
203
- responses?.forEach(response => {
204
-
205
- let eventDefinitions = (node as IWorkflowEvent).eventDefinitions;
206
- let errors = (node as IWorkflowTask).errors;
207
- if (eventDefinitions) {
208
- let callbackeventdefinition: IWorkflowCallbackEventDefinition = eventDefinitions[0] as IWorkflowCallbackEventDefinition;
209
-
210
- let evtParameters = (response as IWorkflowEvent).outputs[0].outputVariables;
211
-
212
- if (callbackeventdefinition) {
213
- let apiresponse: APIResponse = new APIResponse();
214
- apiresponse.description = response.desc || "";
215
-
216
- let responsecode = evtParameters.find(c => c.name === "code");
217
- let code: string = responsecode ? responsecode.value! : "200";
218
- let responseshema = evtParameters.find(c => c.name === "response");
219
-
220
- let i = (code + "").indexOf('{');
221
- let codeisValid: boolean = i < 0;
222
- if (responseshema && codeisValid) {
223
- apiresponse.content = {
224
- "application/json": {
225
- "schema": this.CodeVariableToOpenAPISchema(responseshema as any)
226
- }
227
- }
228
- apicontroller.responses[code] = apiresponse;
229
- }
230
- }
231
- } else if (errors) {
232
- errors.forEach(error => {
233
-
234
- if ((error.code + "").indexOf('{') < 0) {
235
- let apiresponse: APIResponse = new APIResponse();
236
- apiresponse.description = error.description;
237
-
238
- apiresponse.content = {
239
- "application/json": {
240
- "schema": {
241
- "type": "object",
242
- "properties": {
243
- "code": { "type": "string", example: error.code },
244
- "message": { "type": "string", example: error.description }
245
- }
246
- }
247
- }
248
- }
249
- apicontroller.responses[error.code] = apiresponse;
250
- }
251
-
252
- })
253
- }
254
-
255
- //add default error
256
- let apiresponse: APIResponse = new APIResponse();
257
- apiresponse.description = "Server error";
258
-
259
- apiresponse.content = {
260
- "application/json": {
261
- "schema": {
262
- "type": "object",
263
- "properties": {
264
- "code": { "type": "string", example: "500" },
265
- "message": { "type": "string", example: "Server error" }
266
- }
267
- }
268
- }
269
- }
270
- apicontroller.responses["500"] = apiresponse;
271
-
272
- });
273
-
274
- if (!spec.paths[definition.route])
275
- spec.paths[definition.route] = {};
276
- spec.paths[definition.route][definition.method] = apicontroller;
277
-
278
- hasApi = true;
279
- }
280
-
281
- });
282
-
283
- return hasApi;
284
- }
285
- }
@@ -1,32 +0,0 @@
1
- import { exec } from 'child_process';
2
-
3
- export class OsUtils {
4
-
5
- /**
6
- * Opens a URL in the default browser.
7
- * Supports Windows, macOS and Linux.
8
- * @param url The URL to open.
9
- */
10
- static openInBrowser(url: string): void {
11
- let command: string;
12
-
13
- switch (process.platform) {
14
- case 'win32':
15
- command = `start "" "${url}"`;
16
- break;
17
- case 'darwin':
18
- command = `open "${url}"`;
19
- break;
20
- default:
21
- // Linux and other Unix-like systems
22
- command = `xdg-open "${url}"`;
23
- break;
24
- }
25
-
26
- exec(command, (error) => {
27
- if (error) {
28
- console.error(`Failed to open browser: ${error.message}`);
29
- }
30
- });
31
- }
32
- }