@kapeta/local-cluster-service 0.47.1 → 0.47.2
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/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## [0.47.2](https://github.com/kapetacom/local-cluster-service/compare/v0.47.1...v0.47.2) (2024-05-30)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* Prettify kaplang from AI ([#151](https://github.com/kapetacom/local-cluster-service/issues/151)) ([c5afeac](https://github.com/kapetacom/local-cluster-service/commit/c5afeac7dbacdc689e53f5156a612d883f0662b1))
|
7
|
+
|
1
8
|
## [0.47.1](https://github.com/kapetacom/local-cluster-service/compare/v0.47.0...v0.47.1) (2024-05-30)
|
2
9
|
|
3
10
|
|
@@ -9,6 +9,26 @@ const nodejs_utils_1 = require("@kapeta/nodejs-utils");
|
|
9
9
|
const kaplang_core_1 = require("@kapeta/kaplang-core");
|
10
10
|
const uuid_1 = require("uuid");
|
11
11
|
const definitionsManager_1 = require("../definitionsManager");
|
12
|
+
function prettifyKaplang(source) {
|
13
|
+
if (!source || !source.trim()) {
|
14
|
+
return '';
|
15
|
+
}
|
16
|
+
try {
|
17
|
+
const ast = kaplang_core_1.DSLParser.parse(source, {
|
18
|
+
ignoreSemantics: true,
|
19
|
+
types: true,
|
20
|
+
methods: true,
|
21
|
+
rest: true,
|
22
|
+
extends: true,
|
23
|
+
generics: true,
|
24
|
+
});
|
25
|
+
return kaplang_core_1.KaplangWriter.write(ast.entities ?? []);
|
26
|
+
}
|
27
|
+
catch (e) {
|
28
|
+
console.warn('Failed to prettify source:\n%s', source);
|
29
|
+
return source;
|
30
|
+
}
|
31
|
+
}
|
12
32
|
async function resolveOptions() {
|
13
33
|
// Predefined types for now - TODO: Allow user to select / change
|
14
34
|
const blockTypeService = await definitionsManager_1.definitionsManager.getLatestDefinition('kapeta/block-type-service');
|
@@ -126,13 +146,13 @@ class StormEventParser {
|
|
126
146
|
this.error = evt.payload.error;
|
127
147
|
break;
|
128
148
|
case 'CREATE_API':
|
129
|
-
this.blocks[evt.payload.blockName].apis.push(evt.payload.content);
|
149
|
+
this.blocks[evt.payload.blockName].apis.push(prettifyKaplang(evt.payload.content));
|
130
150
|
break;
|
131
151
|
case 'CREATE_TYPE':
|
132
|
-
this.blocks[evt.payload.blockName].types.push(evt.payload.content);
|
152
|
+
this.blocks[evt.payload.blockName].types.push(prettifyKaplang(evt.payload.content));
|
133
153
|
break;
|
134
154
|
case 'CREATE_MODEL':
|
135
|
-
this.blocks[evt.payload.blockName].models.push(evt.payload.content);
|
155
|
+
this.blocks[evt.payload.blockName].models.push(prettifyKaplang(evt.payload.content));
|
136
156
|
break;
|
137
157
|
case 'CREATE_CONNECTION':
|
138
158
|
this.connections.push(evt.payload);
|
@@ -9,6 +9,26 @@ const nodejs_utils_1 = require("@kapeta/nodejs-utils");
|
|
9
9
|
const kaplang_core_1 = require("@kapeta/kaplang-core");
|
10
10
|
const uuid_1 = require("uuid");
|
11
11
|
const definitionsManager_1 = require("../definitionsManager");
|
12
|
+
function prettifyKaplang(source) {
|
13
|
+
if (!source || !source.trim()) {
|
14
|
+
return '';
|
15
|
+
}
|
16
|
+
try {
|
17
|
+
const ast = kaplang_core_1.DSLParser.parse(source, {
|
18
|
+
ignoreSemantics: true,
|
19
|
+
types: true,
|
20
|
+
methods: true,
|
21
|
+
rest: true,
|
22
|
+
extends: true,
|
23
|
+
generics: true,
|
24
|
+
});
|
25
|
+
return kaplang_core_1.KaplangWriter.write(ast.entities ?? []);
|
26
|
+
}
|
27
|
+
catch (e) {
|
28
|
+
console.warn('Failed to prettify source:\n%s', source);
|
29
|
+
return source;
|
30
|
+
}
|
31
|
+
}
|
12
32
|
async function resolveOptions() {
|
13
33
|
// Predefined types for now - TODO: Allow user to select / change
|
14
34
|
const blockTypeService = await definitionsManager_1.definitionsManager.getLatestDefinition('kapeta/block-type-service');
|
@@ -126,13 +146,13 @@ class StormEventParser {
|
|
126
146
|
this.error = evt.payload.error;
|
127
147
|
break;
|
128
148
|
case 'CREATE_API':
|
129
|
-
this.blocks[evt.payload.blockName].apis.push(evt.payload.content);
|
149
|
+
this.blocks[evt.payload.blockName].apis.push(prettifyKaplang(evt.payload.content));
|
130
150
|
break;
|
131
151
|
case 'CREATE_TYPE':
|
132
|
-
this.blocks[evt.payload.blockName].types.push(evt.payload.content);
|
152
|
+
this.blocks[evt.payload.blockName].types.push(prettifyKaplang(evt.payload.content));
|
133
153
|
break;
|
134
154
|
case 'CREATE_MODEL':
|
135
|
-
this.blocks[evt.payload.blockName].models.push(evt.payload.content);
|
155
|
+
this.blocks[evt.payload.blockName].models.push(prettifyKaplang(evt.payload.content));
|
136
156
|
break;
|
137
157
|
case 'CREATE_CONNECTION':
|
138
158
|
this.connections.push(evt.payload);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@kapeta/local-cluster-service",
|
3
|
-
"version": "0.47.
|
3
|
+
"version": "0.47.2",
|
4
4
|
"description": "Manages configuration, ports and service discovery for locally running Kapeta systems",
|
5
5
|
"type": "commonjs",
|
6
6
|
"exports": {
|
@@ -52,7 +52,7 @@
|
|
52
52
|
"dependencies": {
|
53
53
|
"@kapeta/codegen": "^1.4.0",
|
54
54
|
"@kapeta/config-mapper": "^1.2.1",
|
55
|
-
"@kapeta/kaplang-core": "^1.
|
55
|
+
"@kapeta/kaplang-core": "^1.17.1",
|
56
56
|
"@kapeta/local-cluster-config": "^0.4.2",
|
57
57
|
"@kapeta/nodejs-api-client": ">=0.2.0 <2",
|
58
58
|
"@kapeta/nodejs-process": "^1.2.0",
|
@@ -20,6 +20,7 @@ import {
|
|
20
20
|
DSLConverters,
|
21
21
|
DSLDataTypeParser,
|
22
22
|
DSLMethod,
|
23
|
+
DSLParser,
|
23
24
|
KAPLANG_ID,
|
24
25
|
KAPLANG_VERSION,
|
25
26
|
KaplangWriter,
|
@@ -64,6 +65,28 @@ export interface StormOptions {
|
|
64
65
|
gatewayKind: string;
|
65
66
|
}
|
66
67
|
|
68
|
+
function prettifyKaplang(source: string) {
|
69
|
+
if (!source || !source.trim()) {
|
70
|
+
return '';
|
71
|
+
}
|
72
|
+
|
73
|
+
try {
|
74
|
+
const ast = DSLParser.parse(source, {
|
75
|
+
ignoreSemantics: true,
|
76
|
+
types: true,
|
77
|
+
methods: true,
|
78
|
+
rest: true,
|
79
|
+
extends: true,
|
80
|
+
generics: true,
|
81
|
+
});
|
82
|
+
|
83
|
+
return KaplangWriter.write(ast.entities ?? []);
|
84
|
+
} catch (e) {
|
85
|
+
console.warn('Failed to prettify source:\n%s', source);
|
86
|
+
return source;
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
67
90
|
export async function resolveOptions(): Promise<StormOptions> {
|
68
91
|
// Predefined types for now - TODO: Allow user to select / change
|
69
92
|
|
@@ -222,13 +245,13 @@ export class StormEventParser {
|
|
222
245
|
this.error = evt.payload.error;
|
223
246
|
break;
|
224
247
|
case 'CREATE_API':
|
225
|
-
this.blocks[evt.payload.blockName].apis.push(evt.payload.content);
|
248
|
+
this.blocks[evt.payload.blockName].apis.push(prettifyKaplang(evt.payload.content));
|
226
249
|
break;
|
227
250
|
case 'CREATE_TYPE':
|
228
|
-
this.blocks[evt.payload.blockName].types.push(evt.payload.content);
|
251
|
+
this.blocks[evt.payload.blockName].types.push(prettifyKaplang(evt.payload.content));
|
229
252
|
break;
|
230
253
|
case 'CREATE_MODEL':
|
231
|
-
this.blocks[evt.payload.blockName].models.push(evt.payload.content);
|
254
|
+
this.blocks[evt.payload.blockName].models.push(prettifyKaplang(evt.payload.content));
|
232
255
|
break;
|
233
256
|
case 'CREATE_CONNECTION':
|
234
257
|
this.connections.push(evt.payload);
|