@kapeta/local-cluster-service 0.54.5 → 0.54.7

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,17 @@
1
+ ## [0.54.7](https://github.com/kapetacom/local-cluster-service/compare/v0.54.6...v0.54.7) (2024-06-21)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Forward errors to the UI ([#185](https://github.com/kapetacom/local-cluster-service/issues/185)) ([482a767](https://github.com/kapetacom/local-cluster-service/commit/482a76741315916ed696aea668a6061069eb3404))
7
+
8
+ ## [0.54.6](https://github.com/kapetacom/local-cluster-service/compare/v0.54.5...v0.54.6) (2024-06-21)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * dont run codegen after moving block to dest folder ([#186](https://github.com/kapetacom/local-cluster-service/issues/186)) ([f0f4a36](https://github.com/kapetacom/local-cluster-service/commit/f0f4a363c32c20074fbf9aa333f87ceada4a81a2))
14
+
1
15
  ## [0.54.5](https://github.com/kapetacom/local-cluster-service/compare/v0.54.4...v0.54.5) (2024-06-21)
2
16
 
3
17
 
@@ -17,6 +17,7 @@ export declare class StormCodegen {
17
17
  isAborted(): boolean;
18
18
  getStream(): StormStream;
19
19
  private handleTemplateFileOutput;
20
+ private handleError;
20
21
  private handleUiOutput;
21
22
  private handleFileEvents;
22
23
  private handleFileDoneOutput;
@@ -118,6 +118,9 @@ class StormCodegen {
118
118
  return this.out;
119
119
  }
120
120
  handleTemplateFileOutput(blockUri, aiName, data) {
121
+ if (this.handleError(data)) {
122
+ return;
123
+ }
121
124
  if (this.handleFileEvents(blockUri, aiName, data)) {
122
125
  return;
123
126
  }
@@ -126,9 +129,19 @@ class StormCodegen {
126
129
  return this.handleFileDoneOutput(blockUri, aiName, data);
127
130
  }
128
131
  }
132
+ handleError(data) {
133
+ if (data.type === 'ERROR_INTERNAL') {
134
+ this.out.emit('data', data);
135
+ return true;
136
+ }
137
+ return false;
138
+ }
129
139
  handleUiOutput(blockUri, blockName, data) {
130
140
  const blockRef = blockUri.toNormalizedString();
131
141
  const instanceId = event_parser_1.StormEventParser.toInstanceIdFromRef(blockRef);
142
+ if (this.handleError(data)) {
143
+ return;
144
+ }
132
145
  if (this.handleFileEvents(blockUri, blockName, data)) {
133
146
  return;
134
147
  }
@@ -149,7 +162,7 @@ class StormCodegen {
149
162
  case 'FILE_DONE':
150
163
  return this.handleFileDoneOutput(blockUri, blockName, data);
151
164
  default:
152
- console.warn('Unknown event type', data);
165
+ console.warn('Unknown UI event type', data);
153
166
  break;
154
167
  }
155
168
  }
@@ -712,11 +725,18 @@ class StormCodegen {
712
725
  for (const changedFile of changedFiles.flat()) {
713
726
  const find = allFiles.find((file) => file.filename === changedFile.payload.filename);
714
727
  if (find) {
715
- result.push({ type: find.type, filename: find.filename, mode: find.mode, permissions: find.permissions,
716
- content: changedFile.payload.content });
728
+ result.push({
729
+ type: find.type,
730
+ filename: find.filename,
731
+ mode: find.mode,
732
+ permissions: find.permissions,
733
+ content: changedFile.payload.content,
734
+ });
717
735
  }
718
736
  else {
719
- console.warn("processTemplates: AI changed a file that wasn't in the input [" + changedFile.payload.filename + "]");
737
+ console.warn("processTemplates: AI changed a file that wasn't in the input [" +
738
+ changedFile.payload.filename +
739
+ ']');
720
740
  }
721
741
  }
722
742
  return result;
@@ -117,7 +117,9 @@ router.post('/block/create', async (req, res) => {
117
117
  overwrite: true,
118
118
  });
119
119
  }
120
- const [asset] = await assetManager_1.assetManager.createAsset(ymlPath, createRequest.definition);
120
+ // Create asset without running codegen if the asset already exists
121
+ const shouldCodegen = !isExisting;
122
+ const [asset] = await assetManager_1.assetManager.createAsset(ymlPath, createRequest.definition, 'user', shouldCodegen);
121
123
  res.send(asset);
122
124
  }
123
125
  catch (err) {
@@ -17,6 +17,7 @@ export declare class StormCodegen {
17
17
  isAborted(): boolean;
18
18
  getStream(): StormStream;
19
19
  private handleTemplateFileOutput;
20
+ private handleError;
20
21
  private handleUiOutput;
21
22
  private handleFileEvents;
22
23
  private handleFileDoneOutput;
@@ -118,6 +118,9 @@ class StormCodegen {
118
118
  return this.out;
119
119
  }
120
120
  handleTemplateFileOutput(blockUri, aiName, data) {
121
+ if (this.handleError(data)) {
122
+ return;
123
+ }
121
124
  if (this.handleFileEvents(blockUri, aiName, data)) {
122
125
  return;
123
126
  }
@@ -126,9 +129,19 @@ class StormCodegen {
126
129
  return this.handleFileDoneOutput(blockUri, aiName, data);
127
130
  }
128
131
  }
132
+ handleError(data) {
133
+ if (data.type === 'ERROR_INTERNAL') {
134
+ this.out.emit('data', data);
135
+ return true;
136
+ }
137
+ return false;
138
+ }
129
139
  handleUiOutput(blockUri, blockName, data) {
130
140
  const blockRef = blockUri.toNormalizedString();
131
141
  const instanceId = event_parser_1.StormEventParser.toInstanceIdFromRef(blockRef);
142
+ if (this.handleError(data)) {
143
+ return;
144
+ }
132
145
  if (this.handleFileEvents(blockUri, blockName, data)) {
133
146
  return;
134
147
  }
@@ -149,7 +162,7 @@ class StormCodegen {
149
162
  case 'FILE_DONE':
150
163
  return this.handleFileDoneOutput(blockUri, blockName, data);
151
164
  default:
152
- console.warn('Unknown event type', data);
165
+ console.warn('Unknown UI event type', data);
153
166
  break;
154
167
  }
155
168
  }
@@ -712,11 +725,18 @@ class StormCodegen {
712
725
  for (const changedFile of changedFiles.flat()) {
713
726
  const find = allFiles.find((file) => file.filename === changedFile.payload.filename);
714
727
  if (find) {
715
- result.push({ type: find.type, filename: find.filename, mode: find.mode, permissions: find.permissions,
716
- content: changedFile.payload.content });
728
+ result.push({
729
+ type: find.type,
730
+ filename: find.filename,
731
+ mode: find.mode,
732
+ permissions: find.permissions,
733
+ content: changedFile.payload.content,
734
+ });
717
735
  }
718
736
  else {
719
- console.warn("processTemplates: AI changed a file that wasn't in the input [" + changedFile.payload.filename + "]");
737
+ console.warn("processTemplates: AI changed a file that wasn't in the input [" +
738
+ changedFile.payload.filename +
739
+ ']');
720
740
  }
721
741
  }
722
742
  return result;
@@ -117,7 +117,9 @@ router.post('/block/create', async (req, res) => {
117
117
  overwrite: true,
118
118
  });
119
119
  }
120
- const [asset] = await assetManager_1.assetManager.createAsset(ymlPath, createRequest.definition);
120
+ // Create asset without running codegen if the asset already exists
121
+ const shouldCodegen = !isExisting;
122
+ const [asset] = await assetManager_1.assetManager.createAsset(ymlPath, createRequest.definition, 'user', shouldCodegen);
121
123
  res.send(asset);
122
124
  }
123
125
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kapeta/local-cluster-service",
3
- "version": "0.54.5",
3
+ "version": "0.54.7",
4
4
  "description": "Manages configuration, ports and service discovery for locally running Kapeta systems",
5
5
  "type": "commonjs",
6
6
  "exports": {
@@ -135,6 +135,10 @@ export class StormCodegen {
135
135
  aiName: string,
136
136
  data: StormEvent
137
137
  ): StormEventFileDone | undefined {
138
+ if (this.handleError(data)) {
139
+ return;
140
+ }
141
+
138
142
  if (this.handleFileEvents(blockUri, aiName, data)) {
139
143
  return;
140
144
  }
@@ -145,10 +149,23 @@ export class StormCodegen {
145
149
  }
146
150
  }
147
151
 
152
+ private handleError(data: StormEvent): boolean {
153
+ if (data.type === 'ERROR_INTERNAL') {
154
+ this.out.emit('data', data);
155
+ return true;
156
+ }
157
+
158
+ return false;
159
+ }
160
+
148
161
  private handleUiOutput(blockUri: KapetaURI, blockName: string, data: StormEvent): StormEventFileDone | undefined {
149
162
  const blockRef = blockUri.toNormalizedString();
150
163
  const instanceId = StormEventParser.toInstanceIdFromRef(blockRef);
151
164
 
165
+ if (this.handleError(data)) {
166
+ return;
167
+ }
168
+
152
169
  if (this.handleFileEvents(blockUri, blockName, data)) {
153
170
  return;
154
171
  }
@@ -169,8 +186,9 @@ export class StormCodegen {
169
186
  break;
170
187
  case 'FILE_DONE':
171
188
  return this.handleFileDoneOutput(blockUri, blockName, data);
189
+
172
190
  default:
173
- console.warn('Unknown event type', data);
191
+ console.warn('Unknown UI event type', data);
174
192
  break;
175
193
  }
176
194
  }
@@ -233,7 +251,11 @@ export class StormCodegen {
233
251
  return false;
234
252
  }
235
253
 
236
- private handleFileDoneOutput(blockUri: KapetaURI, aiName: string, data: StormEvent): StormEventFileDone | undefined {
254
+ private handleFileDoneOutput(
255
+ blockUri: KapetaURI,
256
+ aiName: string,
257
+ data: StormEvent
258
+ ): StormEventFileDone | undefined {
237
259
  switch (data.type) {
238
260
  case 'FILE_DONE':
239
261
  const ref = blockUri.toNormalizedString();
@@ -906,10 +928,19 @@ export class StormCodegen {
906
928
  for (const changedFile of changedFiles.flat()) {
907
929
  const find = allFiles.find((file) => file.filename === changedFile.payload.filename);
908
930
  if (find) {
909
- result.push({ type: find.type, filename: find.filename, mode: find.mode, permissions: find.permissions,
910
- content: changedFile.payload.content });
931
+ result.push({
932
+ type: find.type,
933
+ filename: find.filename,
934
+ mode: find.mode,
935
+ permissions: find.permissions,
936
+ content: changedFile.payload.content,
937
+ });
911
938
  } else {
912
- console.warn("processTemplates: AI changed a file that wasn't in the input [" + changedFile.payload.filename + "]");
939
+ console.warn(
940
+ "processTemplates: AI changed a file that wasn't in the input [" +
941
+ changedFile.payload.filename +
942
+ ']'
943
+ );
913
944
  }
914
945
  }
915
946
  return result;
@@ -153,7 +153,9 @@ router.post('/block/create', async (req: KapetaBodyRequest, res: Response) => {
153
153
  overwrite: true,
154
154
  });
155
155
  }
156
- const [asset] = await assetManager.createAsset(ymlPath, createRequest.definition);
156
+ // Create asset without running codegen if the asset already exists
157
+ const shouldCodegen = !isExisting;
158
+ const [asset] = await assetManager.createAsset(ymlPath, createRequest.definition, 'user', shouldCodegen);
157
159
  res.send(asset);
158
160
  } catch (err: any) {
159
161
  res.status(500).send({ error: err.message });