@kapeta/local-cluster-service 0.55.2 → 0.55.3

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.55.3](https://github.com/kapetacom/local-cluster-service/compare/v0.55.2...v0.55.3) (2024-07-12)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * ensure versions on predefined blocks are the latest ([0a841bc](https://github.com/kapetacom/local-cluster-service/commit/0a841bc221cfac09cac41992a06385be1da24197))
7
+
1
8
  ## [0.55.2](https://github.com/kapetacom/local-cluster-service/compare/v0.55.1...v0.55.2) (2024-07-12)
2
9
 
3
10
 
package/definitions.d.ts CHANGED
@@ -47,4 +47,4 @@ declare module 'download-git-repo' {
47
47
  ): void;
48
48
 
49
49
  export = download;
50
- }
50
+ }
@@ -39,6 +39,7 @@ export interface StormOptions {
39
39
  desktopKind: string;
40
40
  desktopLanguage: string;
41
41
  gatewayKind: string;
42
+ [key: string]: string;
42
43
  }
43
44
  export declare function createPhaseStartEvent(type: StormEventPhaseType): StormEventPhases;
44
45
  export declare function createPhaseEndEvent(type: StormEventPhaseType): StormEventPhases;
@@ -66,7 +67,7 @@ export declare class StormEventParser {
66
67
  getEvents(): StormEvent[];
67
68
  isValid(): boolean;
68
69
  getError(): string;
69
- toResult(handle: string): Promise<StormDefinitions>;
70
+ toResult(handle: string, warn?: boolean): Promise<StormDefinitions>;
70
71
  toBlockDefinitions(handle: string): Promise<{
71
72
  [key: string]: BlockDefinitionInfo;
72
73
  }>;
@@ -244,7 +244,7 @@ class StormEventParser {
244
244
  getError() {
245
245
  return this.error;
246
246
  }
247
- async toResult(handle) {
247
+ async toResult(handle, warn = false) {
248
248
  const planRef = StormEventParser.toRef(handle, this.planName || 'undefined');
249
249
  const blockDefinitions = await this.toBlockDefinitions(handle);
250
250
  const refIdMap = {};
@@ -284,7 +284,9 @@ class StormEventParser {
284
284
  }
285
285
  const apiResource = apiProviderBlock.content.spec.providers?.find((p) => p.kind === this.options.apiKind && p.metadata.name === apiConnection.fromResource);
286
286
  if (!apiResource) {
287
- console.warn('API resource not found: %s on %s', apiConnection.fromResource, apiProviderRef.toNormalizedString(), apiConnection);
287
+ if (warn) {
288
+ console.warn('API resource not found: %s on %s', apiConnection.fromResource, apiProviderRef.toNormalizedString(), apiConnection);
289
+ }
288
290
  return;
289
291
  }
290
292
  const clientResource = clientConsumerBlock.content.spec.consumers?.find((clientResource) => {
@@ -295,7 +297,9 @@ class StormEventParser {
295
297
  return clientResource.metadata.name === apiConnection.toResource;
296
298
  });
297
299
  if (!clientResource) {
298
- console.warn('Client resource not found: %s on %s', apiConnection.toResource, clientConsumerRef.toNormalizedString(), apiConnection);
300
+ if (warn) {
301
+ console.warn('Client resource not found: %s on %s', apiConnection.toResource, clientConsumerRef.toNormalizedString(), apiConnection);
302
+ }
299
303
  return;
300
304
  }
301
305
  if (apiProviderBlock.content.spec.entities?.source?.value) {
@@ -340,7 +344,7 @@ class StormEventParser {
340
344
  blockId: refIdMap[fromRef.toNormalizedString()],
341
345
  resourceName: connection.fromResource,
342
346
  },
343
- mapping: this.toConnectionMapping(handle, connection, blockDefinitions),
347
+ mapping: this.toConnectionMapping(handle, connection, blockDefinitions, warn),
344
348
  };
345
349
  });
346
350
  const plan = {
@@ -368,7 +372,7 @@ class StormEventParser {
368
372
  const blockRef = StormEventParser.toRef(handle, blockInfo.name);
369
373
  let blockDefinitionInfo;
370
374
  if (blockInfo.archetype) {
371
- blockDefinitionInfo = await this.resolveArchetypeBlockDefinition(blockRef, blockInfo);
375
+ blockDefinitionInfo = await this.resolveArchetypeBlockDefinition(blockRef, blockInfo, handle);
372
376
  }
373
377
  else {
374
378
  blockDefinitionInfo = this.createBlockDefinitionInfo(blockRef, blockInfo, handle);
@@ -533,7 +537,7 @@ class StormEventParser {
533
537
  firstEntry.spec.source.value += api + '\n\n';
534
538
  }
535
539
  else {
536
- console.warn('Unable to find resource for API', api);
540
+ // this might be ok as we might receive api and types before resources from the ai-service
537
541
  }
538
542
  }
539
543
  });
@@ -596,7 +600,7 @@ class StormEventParser {
596
600
  }
597
601
  return '';
598
602
  }
599
- toConnectionMapping(handle, connection, blockDefinitions) {
603
+ toConnectionMapping(handle, connection, blockDefinitions, warn) {
600
604
  if (connection.fromResourceType !== 'API') {
601
605
  return;
602
606
  }
@@ -608,7 +612,9 @@ class StormEventParser {
608
612
  }
609
613
  const apiResource = apiProviderBlock.content.spec.providers?.find((p) => p.kind === this.options.apiKind && p.metadata.name === connection.fromResource);
610
614
  if (!apiResource) {
611
- console.warn('API resource not found: %s on %s', connection.fromResource, fromRef.toNormalizedString(), connection);
615
+ if (warn) {
616
+ console.warn('API resource not found: %s on %s', connection.fromResource, fromRef.toNormalizedString(), connection);
617
+ }
612
618
  return;
613
619
  }
614
620
  const apiMethods = kaplang_core_1.DSLConverters.toSchemaMethods(kaplang_core_1.DSLAPIParser.parse(apiResource.spec?.source?.value ?? '', {
@@ -681,14 +687,36 @@ class StormEventParser {
681
687
  }
682
688
  return undefined;
683
689
  }
684
- async resolveArchetypeBlockDefinition(blockRef, blockInfo) {
690
+ async resolveArchetypeBlockDefinition(blockRef, blockInfo, handle) {
685
691
  const predefinedBlock = predefined_1.PREDEFINED_BLOCKS.get(blockInfo.archetype);
686
692
  if (!predefinedBlock) {
687
693
  throw new Error('Predefined block not found for archetype [' + blockInfo.archetype + ']');
688
694
  }
695
+ const target = this.toBlockTarget(handle, blockInfo.type);
689
696
  const blockDefinition = await predefinedBlock.getBlockDefinition();
690
697
  lodash_1.default.set(blockDefinition, ['metadata', 'name'], blockRef.fullName);
691
698
  lodash_1.default.set(blockDefinition, ['metadata', 'title'], blockRef.name);
699
+ lodash_1.default.set(blockDefinition, ['spec', 'target', 'options'], target?.options);
700
+ const options = this.options;
701
+ function getKind(kind) {
702
+ for (const prop in options) {
703
+ if (options.hasOwnProperty(prop)) {
704
+ const value = options[prop];
705
+ if (value.startsWith(kind)) {
706
+ return value;
707
+ }
708
+ }
709
+ }
710
+ }
711
+ blockDefinition.kind = getKind((0, nodejs_utils_1.parseKapetaUri)(blockDefinition.kind).fullName) ?? blockDefinition.kind;
712
+ for (const provider of blockDefinition.spec.providers ?? []) {
713
+ provider.kind = getKind((0, nodejs_utils_1.parseKapetaUri)(provider.kind).fullName) ?? provider.kind;
714
+ }
715
+ for (const consumer of blockDefinition.spec.consumers ?? []) {
716
+ consumer.kind = getKind((0, nodejs_utils_1.parseKapetaUri)(consumer.kind).fullName) ?? consumer.kind;
717
+ }
718
+ blockDefinition.spec.target.kind =
719
+ getKind((0, nodejs_utils_1.parseKapetaUri)(blockDefinition.spec.target.kind).fullName) ?? blockDefinition.spec.target.kind;
692
720
  return {
693
721
  uri: blockRef.toNormalizedString(),
694
722
  aiName: blockInfo.name,
@@ -82,7 +82,7 @@ router.post('/:handle/all', async (req, res) => {
82
82
  res.end();
83
83
  return;
84
84
  }
85
- const result = await eventParser.toResult(handle);
85
+ const result = await eventParser.toResult(handle, true);
86
86
  if (metaStream.isAborted()) {
87
87
  return;
88
88
  }