@kapeta/local-cluster-service 0.55.0 → 0.55.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 +15 -0
- package/dist/cjs/src/storm/archetype.js +4 -4
- package/dist/cjs/src/storm/event-parser.js +6 -3
- package/dist/cjs/test/storm/codegen.test.js +4 -2
- package/dist/esm/src/storm/archetype.js +4 -4
- package/dist/esm/src/storm/event-parser.js +6 -3
- package/dist/esm/test/storm/codegen.test.js +4 -2
- package/package.json +1 -1
- package/src/storm/archetype.ts +4 -4
- package/src/storm/event-parser.ts +18 -14
- package/test/storm/codegen.test.ts +5 -3
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
## [0.55.2](https://github.com/kapetacom/local-cluster-service/compare/v0.55.1...v0.55.2) (2024-07-12)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* recurring create-block events will not overwrite types, apis or models ([f07b2da](https://github.com/kapetacom/local-cluster-service/commit/f07b2da0e0fc286e3eb06af2efcd1746808f2ba9))
|
7
|
+
|
8
|
+
## [0.55.1](https://github.com/kapetacom/local-cluster-service/compare/v0.55.0...v0.55.1) (2024-07-12)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* include full path for files in cloned predefined source ([dba3151](https://github.com/kapetacom/local-cluster-service/commit/dba3151ab365281396ee8b3c9e0dd1f44f88b3f6))
|
14
|
+
* more tests ([6c61030](https://github.com/kapetacom/local-cluster-service/commit/6c61030c243dc2d23da257b587ab4dfe2e2966f4))
|
15
|
+
|
1
16
|
# [0.55.0](https://github.com/kapetacom/local-cluster-service/compare/v0.54.12...v0.55.0) (2024-07-11)
|
2
17
|
|
3
18
|
|
@@ -57,7 +57,7 @@ class Archetype {
|
|
57
57
|
}
|
58
58
|
async convertToGeneratedResult(basePath) {
|
59
59
|
const generatedFiles = [];
|
60
|
-
async function traverse(currentPath) {
|
60
|
+
async function traverse(currentPath, basePath) {
|
61
61
|
const files = await fs.promises.readdir(currentPath, { withFileTypes: true });
|
62
62
|
for (const file of files) {
|
63
63
|
const fullPath = path_1.default.join(currentPath, file.name);
|
@@ -67,7 +67,7 @@ class Archetype {
|
|
67
67
|
const permissions = stats.mode.toString(8).slice(-3);
|
68
68
|
const content = await fs.promises.readFile(fullPath);
|
69
69
|
const generatedFile = {
|
70
|
-
filename:
|
70
|
+
filename: fullPath.replace(basePath + '/', ''),
|
71
71
|
content: content.toString(),
|
72
72
|
mode: mode,
|
73
73
|
permissions: permissions,
|
@@ -75,11 +75,11 @@ class Archetype {
|
|
75
75
|
generatedFiles.push(generatedFile);
|
76
76
|
}
|
77
77
|
else if (file.isDirectory()) {
|
78
|
-
await traverse(fullPath);
|
78
|
+
await traverse(fullPath, basePath);
|
79
79
|
}
|
80
80
|
}
|
81
81
|
}
|
82
|
-
await traverse(basePath);
|
82
|
+
await traverse(basePath, basePath);
|
83
83
|
return { files: generatedFiles };
|
84
84
|
}
|
85
85
|
downloadRepo(url, dest) {
|
@@ -170,11 +170,14 @@ class StormEventParser {
|
|
170
170
|
this.planDescription = evt.payload.description;
|
171
171
|
break;
|
172
172
|
case 'CREATE_BLOCK':
|
173
|
+
const apis = this.blocks[evt.payload.name]?.apis;
|
174
|
+
const models = this.blocks[evt.payload.name]?.models;
|
175
|
+
const types = this.blocks[evt.payload.name]?.types;
|
173
176
|
this.blocks[evt.payload.name] = {
|
174
177
|
...evt.payload,
|
175
|
-
apis: [],
|
176
|
-
models: [],
|
177
|
-
types: [],
|
178
|
+
apis: apis ?? [],
|
179
|
+
models: models ?? [],
|
180
|
+
types: types ?? [],
|
178
181
|
};
|
179
182
|
evt.payload.blockRef = StormEventParser.toRef(handle, evt.payload.name).toNormalizedString();
|
180
183
|
evt.payload.instanceId = StormEventParser.toInstanceIdFromRef(evt.payload.blockRef);
|
@@ -25,8 +25,10 @@ describe('codegen', () => {
|
|
25
25
|
let codegenPromise = consumeStream(codegen.getStream());
|
26
26
|
await codegen.process();
|
27
27
|
const stormEvents = await codegenPromise;
|
28
|
-
expect(stormEvents
|
29
|
-
expect(stormEvents
|
28
|
+
expect(stormEvents.filter((event) => event.type === 'FILE_DONE').length).toBeGreaterThan(1);
|
29
|
+
expect(stormEvents.filter((event) => event.type === 'FILE_DONE' && event.payload.filename.endsWith('UserDTO.java')).length)
|
30
|
+
.toBe(1);
|
31
|
+
expect(stormEvents.at(-1).type).toBe('BLOCK_READY');
|
30
32
|
});
|
31
33
|
});
|
32
34
|
async function consumeStream(stream) {
|
@@ -57,7 +57,7 @@ class Archetype {
|
|
57
57
|
}
|
58
58
|
async convertToGeneratedResult(basePath) {
|
59
59
|
const generatedFiles = [];
|
60
|
-
async function traverse(currentPath) {
|
60
|
+
async function traverse(currentPath, basePath) {
|
61
61
|
const files = await fs.promises.readdir(currentPath, { withFileTypes: true });
|
62
62
|
for (const file of files) {
|
63
63
|
const fullPath = path_1.default.join(currentPath, file.name);
|
@@ -67,7 +67,7 @@ class Archetype {
|
|
67
67
|
const permissions = stats.mode.toString(8).slice(-3);
|
68
68
|
const content = await fs.promises.readFile(fullPath);
|
69
69
|
const generatedFile = {
|
70
|
-
filename:
|
70
|
+
filename: fullPath.replace(basePath + '/', ''),
|
71
71
|
content: content.toString(),
|
72
72
|
mode: mode,
|
73
73
|
permissions: permissions,
|
@@ -75,11 +75,11 @@ class Archetype {
|
|
75
75
|
generatedFiles.push(generatedFile);
|
76
76
|
}
|
77
77
|
else if (file.isDirectory()) {
|
78
|
-
await traverse(fullPath);
|
78
|
+
await traverse(fullPath, basePath);
|
79
79
|
}
|
80
80
|
}
|
81
81
|
}
|
82
|
-
await traverse(basePath);
|
82
|
+
await traverse(basePath, basePath);
|
83
83
|
return { files: generatedFiles };
|
84
84
|
}
|
85
85
|
downloadRepo(url, dest) {
|
@@ -170,11 +170,14 @@ class StormEventParser {
|
|
170
170
|
this.planDescription = evt.payload.description;
|
171
171
|
break;
|
172
172
|
case 'CREATE_BLOCK':
|
173
|
+
const apis = this.blocks[evt.payload.name]?.apis;
|
174
|
+
const models = this.blocks[evt.payload.name]?.models;
|
175
|
+
const types = this.blocks[evt.payload.name]?.types;
|
173
176
|
this.blocks[evt.payload.name] = {
|
174
177
|
...evt.payload,
|
175
|
-
apis: [],
|
176
|
-
models: [],
|
177
|
-
types: [],
|
178
|
+
apis: apis ?? [],
|
179
|
+
models: models ?? [],
|
180
|
+
types: types ?? [],
|
178
181
|
};
|
179
182
|
evt.payload.blockRef = StormEventParser.toRef(handle, evt.payload.name).toNormalizedString();
|
180
183
|
evt.payload.instanceId = StormEventParser.toInstanceIdFromRef(evt.payload.blockRef);
|
@@ -25,8 +25,10 @@ describe('codegen', () => {
|
|
25
25
|
let codegenPromise = consumeStream(codegen.getStream());
|
26
26
|
await codegen.process();
|
27
27
|
const stormEvents = await codegenPromise;
|
28
|
-
expect(stormEvents
|
29
|
-
expect(stormEvents
|
28
|
+
expect(stormEvents.filter((event) => event.type === 'FILE_DONE').length).toBeGreaterThan(1);
|
29
|
+
expect(stormEvents.filter((event) => event.type === 'FILE_DONE' && event.payload.filename.endsWith('UserDTO.java')).length)
|
30
|
+
.toBe(1);
|
31
|
+
expect(stormEvents.at(-1).type).toBe('BLOCK_READY');
|
30
32
|
});
|
31
33
|
});
|
32
34
|
async function consumeStream(stream) {
|
package/package.json
CHANGED
package/src/storm/archetype.ts
CHANGED
@@ -43,7 +43,7 @@ export class Archetype {
|
|
43
43
|
private async convertToGeneratedResult(basePath: string): Promise<GeneratedResult> {
|
44
44
|
const generatedFiles: GeneratedFile[] = [];
|
45
45
|
|
46
|
-
async function traverse(currentPath: string): Promise<void> {
|
46
|
+
async function traverse(currentPath: string, basePath: string): Promise<void> {
|
47
47
|
const files = await fs.promises.readdir(currentPath, { withFileTypes: true });
|
48
48
|
|
49
49
|
for (const file of files) {
|
@@ -55,19 +55,19 @@ export class Archetype {
|
|
55
55
|
const permissions = stats.mode.toString(8).slice(-3);
|
56
56
|
const content = await fs.promises.readFile(fullPath);
|
57
57
|
const generatedFile: GeneratedFile = {
|
58
|
-
filename:
|
58
|
+
filename: fullPath.replace(basePath + '/', ''),
|
59
59
|
content: content.toString(),
|
60
60
|
mode: mode,
|
61
61
|
permissions: permissions,
|
62
62
|
};
|
63
63
|
generatedFiles.push(generatedFile);
|
64
64
|
} else if (file.isDirectory()) {
|
65
|
-
await traverse(fullPath);
|
65
|
+
await traverse(fullPath, basePath);
|
66
66
|
}
|
67
67
|
}
|
68
68
|
}
|
69
69
|
|
70
|
-
await traverse(basePath);
|
70
|
+
await traverse(basePath, basePath);
|
71
71
|
return { files: generatedFiles } as GeneratedResult;
|
72
72
|
}
|
73
73
|
|
@@ -281,11 +281,15 @@ export class StormEventParser {
|
|
281
281
|
this.planDescription = evt.payload.description;
|
282
282
|
break;
|
283
283
|
case 'CREATE_BLOCK':
|
284
|
+
const apis = this.blocks[evt.payload.name]?.apis;
|
285
|
+
const models = this.blocks[evt.payload.name]?.models;
|
286
|
+
const types = this.blocks[evt.payload.name]?.types;
|
287
|
+
|
284
288
|
this.blocks[evt.payload.name] = {
|
285
289
|
...evt.payload,
|
286
|
-
apis: [],
|
287
|
-
models: [],
|
288
|
-
types: [],
|
290
|
+
apis: apis ?? [],
|
291
|
+
models: models ??[],
|
292
|
+
types: types ?? [],
|
289
293
|
};
|
290
294
|
evt.payload.blockRef = StormEventParser.toRef(handle, evt.payload.name).toNormalizedString();
|
291
295
|
evt.payload.instanceId = StormEventParser.toInstanceIdFromRef(evt.payload.blockRef);
|
@@ -685,18 +689,18 @@ export class StormEventParser {
|
|
685
689
|
}
|
686
690
|
}
|
687
691
|
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
}
|
692
|
+
if (!exactMatch) {
|
693
|
+
// if we couldn't place the given api on the exact resource we just park it on the first
|
694
|
+
// available rest resource
|
695
|
+
const firstKey = Object.keys(apiResources)[0];
|
696
|
+
const firstEntry = apiResources[firstKey];
|
697
|
+
if (firstEntry) {
|
698
|
+
firstEntry.spec.source.value += api + '\n\n';
|
699
|
+
} else {
|
700
|
+
console.warn('Unable to find resource for API', api);
|
698
701
|
}
|
699
|
-
}
|
702
|
+
}
|
703
|
+
});
|
700
704
|
|
701
705
|
blockInfo.types.forEach((type) => {
|
702
706
|
blockSpec.entities!.source!.value += type + '\n';
|
@@ -24,12 +24,14 @@ describe('codegen', () => {
|
|
24
24
|
const conversationId = uuid.v4().toString();
|
25
25
|
|
26
26
|
let codegen = new StormCodegen(conversationId, '', result.blocks, parser.getEvents());
|
27
|
-
let codegenPromise = consumeStream(codegen.getStream());
|
27
|
+
let codegenPromise: Promise<StormEvent[]> = consumeStream(codegen.getStream());
|
28
28
|
await codegen.process();
|
29
29
|
|
30
30
|
const stormEvents = await codegenPromise;
|
31
|
-
expect(stormEvents
|
32
|
-
expect(stormEvents
|
31
|
+
expect(stormEvents.filter((event) => event.type === 'FILE_DONE').length).toBeGreaterThan(1);
|
32
|
+
expect(stormEvents.filter((event) => event.type === 'FILE_DONE' && event.payload.filename.endsWith('UserDTO.java')).length)
|
33
|
+
.toBe(1);
|
34
|
+
expect(stormEvents.at(-1)!.type).toBe('BLOCK_READY');
|
33
35
|
});
|
34
36
|
});
|
35
37
|
|