@kumori/aurora-backend-handler 1.0.100 → 1.0.112

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.
@@ -1,4 +1,5 @@
1
1
  import {
2
+ getWuiErrorCode,
2
3
  Link,
3
4
  MarketplaceItem,
4
5
  MarketplaceService,
@@ -59,10 +60,7 @@ type DeploymentResource =
59
60
  | Port<DeploymentResourceSpec>
60
61
  | Certificate<DeploymentResourceSpec>;
61
62
  let pendingLinks = new Map<string, Link[]>();
62
- /**
63
- * Function to deploy a marketplace item
64
- * @param item A MarketplaceService object containing the item to deploy
65
- */
63
+
66
64
  export const deployMarketplaceItem = async (item: MarketplaceService) => {
67
65
  const complexDeployment = item.deploymentData.serverChannels.find(
68
66
  (channel) => channel.isPublic,
@@ -79,10 +77,10 @@ export const deployMarketplaceItem = async (item: MarketplaceService) => {
79
77
  url.searchParams.append("wait", "30000");
80
78
  url.searchParams.append("validate", "true");
81
79
  url.searchParams.append("dsl", "true");
82
-
83
80
  const response = await fetch(url.toString(), {
84
81
  method: "POST",
85
82
  body: formData,
83
+ credentials: "include",
86
84
  });
87
85
 
88
86
  if (!response.ok) {
@@ -294,24 +292,14 @@ export const deployMarketplaceItem = async (item: MarketplaceService) => {
294
292
 
295
293
  const scale =
296
294
  item.type === "component" || item.serviceName === ""
297
- ? { hsize: 1 }
295
+ ? { hsize: item.deploymentData.role[0].hsize || 0 }
298
296
  : item.schema?.name === "builtins/inbound"
299
297
  ? { detail: {} }
300
298
  : item.type === "service" && item.roles && Array.isArray(item.roles)
301
299
  ? {
302
300
  detail: {},
303
301
  }
304
- : // ? {
305
- // detail: item.roles.reduce(
306
- // (acc, role) => ({
307
- // ...acc,
308
- // [role]: { hsize: 1 },
309
- // }),
310
- // {},
311
- // ),
312
- // }
313
- { detail: {} };
314
- // : { detail: { [`${item.artifactName}`]: { hsize: 1 } } };
302
+ : { detail: {} };
315
303
 
316
304
  const scaling: {
317
305
  simple: {
@@ -380,6 +368,7 @@ export const deployMarketplaceItem = async (item: MarketplaceService) => {
380
368
  "Content-Type": "application/json",
381
369
  },
382
370
  body: JSON.stringify(itemBody),
371
+ credentials: "include",
383
372
  });
384
373
 
385
374
  if (!response.ok) {
@@ -462,23 +451,9 @@ export const getMarketplaceItems = async (
462
451
  domain: (value as any).domain,
463
452
  type: (value as any).artifactTypes[0],
464
453
  artifact: (value as any).artifact,
454
+ schema: undefined,
465
455
  };
466
456
 
467
- try {
468
- const schemaData = await getMarketplaceSchema(
469
- tenant,
470
- item,
471
- security,
472
- );
473
- item.schema = schemaData;
474
- } catch (schemaError) {
475
- console.error(
476
- `Error cargando schema para ${item.name}:`,
477
- schemaError,
478
- );
479
- item.schema = undefined;
480
- }
481
-
482
457
  return item;
483
458
  },
484
459
  );
@@ -967,7 +942,7 @@ const linkPendingServices = async (service: Service, token: string) => {
967
942
  subtype: "service-linked",
968
943
  date: Date.now().toString(),
969
944
  status: "unread",
970
- callToAction: false,
945
+ notificationType: "regular",
971
946
  data: {
972
947
  service: service.name,
973
948
  tenant: service.tenant,
@@ -979,14 +954,14 @@ const linkPendingServices = async (service: Service, token: string) => {
979
954
  } catch (linkErr) {
980
955
  const notification: Notification = {
981
956
  type: "error",
982
- subtype: "error-service-link",
957
+ subtype: getWuiErrorCode("service", "linkService", (linkErr as any).error.code) ?? "error-service-link",
983
958
  date: Date.now().toString(),
984
959
  info_content: {
985
960
  code: (linkErr as any).error.code,
986
961
  message: (linkErr as any).error.content,
987
962
  },
988
963
  status: "unread",
989
- callToAction: false,
964
+ notificationType: "regular",
990
965
  data: {
991
966
  service: service.name,
992
967
  tenant: service.tenant,
@@ -998,11 +973,7 @@ const linkPendingServices = async (service: Service, token: string) => {
998
973
  );
999
974
  }
1000
975
  };
1001
- /**
1002
- * Function to load marketplace items for a specific tenant
1003
- * @param tenant Tenant ID
1004
- * @param security Authorization token
1005
- */
976
+
1006
977
  export const loadMarketplaceItemsForTenant = async (
1007
978
  tenant: string,
1008
979
  security: string,
@@ -1022,47 +993,27 @@ export const loadMarketplaceItemsForTenant = async (
1022
993
  return [];
1023
994
  }
1024
995
 
1025
- const itemPromises = items.map(async (item: any) => {
1026
- const marketplaceItem: MarketplaceItem = {
1027
- tenant: tenant,
1028
- name: item.module,
1029
- logo: item.icon,
1030
- description: item.description,
1031
- version: item.version,
1032
- requirements: {
1033
- cpu: item.requirements?.cpu || 0,
1034
- memory: item.requirements?.memory || 0,
1035
- },
1036
- status: "",
1037
- instances: [],
1038
- links: [],
1039
- resources: [],
1040
- domain: item.domain,
1041
- type: item.artifactTypes?.[0],
1042
- artifact: item.artifact,
1043
- package: item.package,
1044
- categories: item.categories || [],
1045
- };
1046
-
1047
- try {
1048
- const schemaData = await getMarketplaceSchema(
1049
- tenant,
1050
- marketplaceItem,
1051
- security,
1052
- );
1053
- marketplaceItem.schema = schemaData;
1054
- } catch (schemaError) {
1055
- console.error(
1056
- `Error loading schema for ${marketplaceItem.name}:`,
1057
- schemaError,
1058
- );
1059
- marketplaceItem.schema = undefined;
1060
- }
1061
-
1062
- return marketplaceItem;
1063
- });
1064
-
1065
- return await Promise.all(itemPromises);
996
+ return items.map((item: any): MarketplaceItem => ({
997
+ tenant,
998
+ name: item.module,
999
+ logo: item.icon,
1000
+ description: item.description,
1001
+ version: item.version,
1002
+ requirements: {
1003
+ cpu: item.requirements?.cpu || 0,
1004
+ memory: item.requirements?.memory || 0,
1005
+ },
1006
+ status: "",
1007
+ instances: [],
1008
+ links: [],
1009
+ resources: [],
1010
+ domain: item.domain,
1011
+ type: item.artifactTypes?.[0],
1012
+ artifact: item.artifact,
1013
+ package: item.package,
1014
+ categories: item.categories || [],
1015
+ schema: undefined,
1016
+ }));
1066
1017
  } catch (error) {
1067
1018
  console.error(
1068
1019
  `Error loading marketplace items for tenant ${tenant}:`,
@@ -1,4 +1,4 @@
1
- import { Notification, Resource } from "@kumori/aurora-interfaces";
1
+ import { getWuiErrorCode, Notification, Resource } from "@kumori/aurora-interfaces";
2
2
  import { eventHelper } from "../backend-handler";
3
3
 
4
4
  import {
@@ -53,7 +53,7 @@ export const createDomain = async (
53
53
  subtype: "resource-created",
54
54
  date: Date.now().toString(),
55
55
  status: "unread",
56
- callToAction: false,
56
+ notificationType: "regular",
57
57
  data: {
58
58
  resource: domain.name,
59
59
  tenant: tenant
@@ -87,14 +87,14 @@ export const createDomain = async (
87
87
  }
88
88
  const resourceErrorNotification: Notification = {
89
89
  type: "error",
90
- subtype: "resource-creation-error",
90
+ subtype: getWuiErrorCode("resource", "createResource", contentMessage) ?? "resource-creation-error",
91
91
  info_content: {
92
92
  code: contentMessage,
93
93
  message: errorContent,
94
94
  },
95
95
  date: Date.now().toString(),
96
96
  status: "unread",
97
- callToAction: false,
97
+ notificationType: "regular",
98
98
  data: {
99
99
  resource: domain.name,
100
100
  tenant: tenant
@@ -133,7 +133,7 @@ export const createPort = async (
133
133
  subtype: "resource-created",
134
134
  date: Date.now().toString(),
135
135
  status: "unread",
136
- callToAction: false,
136
+ notificationType: "regular",
137
137
  data: {
138
138
  resource: port.name,
139
139
  tenant: tenant
@@ -167,14 +167,14 @@ export const createPort = async (
167
167
  }
168
168
  const resourceErrorNotification: Notification = {
169
169
  type: "error",
170
- subtype: "resource-creation-error",
170
+ subtype: getWuiErrorCode("resource", "createResource", contentMessage) ?? "resource-creation-error",
171
171
  info_content: {
172
172
  code: contentMessage,
173
173
  message: errorContent,
174
174
  },
175
175
  date: Date.now().toString(),
176
176
  status: "unread",
177
- callToAction: false,
177
+ notificationType: "regular",
178
178
  data: {
179
179
  resource: port.name,
180
180
  tenant: tenant
@@ -213,7 +213,7 @@ export const createCA = async (
213
213
  subtype: "resource-created",
214
214
  date: Date.now().toString(),
215
215
  status: "unread",
216
- callToAction: false,
216
+ notificationType: "regular",
217
217
  data: {
218
218
  resource: ca.name,
219
219
  tenant: tenant
@@ -247,14 +247,14 @@ export const createCA = async (
247
247
  }
248
248
  const resourceErrorNotification: Notification = {
249
249
  type: "error",
250
- subtype: "resource-creation-error",
250
+ subtype: getWuiErrorCode("resource", "createResource", contentMessage) ?? "resource-creation-error",
251
251
  info_content: {
252
252
  code: contentMessage,
253
253
  message: errorContent,
254
254
  },
255
255
  date: Date.now().toString(),
256
256
  status: "unread",
257
- callToAction: false,
257
+ notificationType: "regular",
258
258
  data: {
259
259
  resource: ca.name,
260
260
  tenant: tenant
@@ -306,7 +306,7 @@ export const createCertificate = async (
306
306
  subtype: "resource-created",
307
307
  date: Date.now().toString(),
308
308
  status: "unread",
309
- callToAction: false,
309
+ notificationType: "regular",
310
310
  data: {
311
311
  resource: certificate.name,
312
312
  tenant: tenant
@@ -340,14 +340,14 @@ export const createCertificate = async (
340
340
  }
341
341
  const resourceErrorNotification: Notification = {
342
342
  type: "error",
343
- subtype: "resource-creation-error",
343
+ subtype: getWuiErrorCode("resource", "createResource", contentMessage) ?? "resource-creation-error",
344
344
  info_content: {
345
345
  code: contentMessage,
346
346
  message: errorContent,
347
347
  },
348
348
  date: Date.now().toString(),
349
349
  status: "unread",
350
- callToAction: false,
350
+ notificationType: "regular",
351
351
  data: {
352
352
  resource: certificate.name,
353
353
  tenant: tenant
@@ -386,7 +386,7 @@ export const createSecret = async (
386
386
  subtype: "resource-created",
387
387
  date: Date.now().toString(),
388
388
  status: "unread",
389
- callToAction: false,
389
+ notificationType: "regular",
390
390
  data: {
391
391
  resource: secret.name,
392
392
  tenant: tenant
@@ -420,14 +420,14 @@ export const createSecret = async (
420
420
  }
421
421
  const resourceErrorNotification: Notification = {
422
422
  type: "error",
423
- subtype: "resource-creation-error",
423
+ subtype: getWuiErrorCode("resource", "createResource", contentMessage) ?? "resource-creation-error",
424
424
  info_content: {
425
425
  code: contentMessage,
426
426
  message: errorContent,
427
427
  },
428
428
  date: Date.now().toString(),
429
429
  status: "unread",
430
- callToAction: false,
430
+ notificationType: "regular",
431
431
  data: {
432
432
  resource: secret.name,
433
433
  tenant: tenant
@@ -486,7 +486,7 @@ export const createVolume = async (
486
486
  subtype: "resource-created",
487
487
  date: Date.now().toString(),
488
488
  status: "unread",
489
- callToAction: false,
489
+ notificationType: "regular",
490
490
  data: {
491
491
  resource: volume.name,
492
492
  tenant: tenant
@@ -520,14 +520,14 @@ export const createVolume = async (
520
520
  }
521
521
  const resourceErrorNotification: Notification = {
522
522
  type: "error",
523
- subtype: "resource-creation-error",
523
+ subtype: getWuiErrorCode("resource", "createResource", contentMessage) ?? "resource-creation-error",
524
524
  info_content: {
525
525
  code: contentMessage,
526
526
  message: errorContent,
527
527
  },
528
528
  date: Date.now().toString(),
529
529
  status: "unread",
530
- callToAction: false,
530
+ notificationType: "regular",
531
531
  data: {
532
532
  resource: volume.name,
533
533
  tenant: tenant
@@ -587,16 +587,16 @@ const deleteResourceBase = async (
587
587
  body,
588
588
  30000,
589
589
  "DELETE",
590
- resource.name
590
+ resource.name,
591
+ "resource"
591
592
  );
592
-
593
593
  //eventHelper.resource.publish.deleted(resource);
594
594
  const resourceNotification: Notification = {
595
595
  type: "success",
596
596
  subtype: "resource-deleting",
597
597
  date: Date.now().toString(),
598
598
  status: "unread",
599
- callToAction: false,
599
+ notificationType: "regular",
600
600
  data: {
601
601
  resource: resource.name,
602
602
  type: resource.type,
@@ -626,14 +626,14 @@ const deleteResourceBase = async (
626
626
  }
627
627
  const resourceErrorNotification: Notification = {
628
628
  type: "error",
629
- subtype: "resource-deletion-error",
629
+ subtype: getWuiErrorCode("resource", "deleteResource", contentMessage) ?? "resource-deletion-error",
630
630
  info_content: {
631
631
  code: contentMessage,
632
632
  message: errorContent,
633
633
  },
634
634
  date: Date.now().toString(),
635
635
  status: "unread",
636
- callToAction: false,
636
+ notificationType: "regular",
637
637
  data: {
638
638
  resource: resource.name,
639
639
  type: resource.type,
@@ -691,7 +691,7 @@ const updateResourceBase = async (
691
691
  subtype: "resource-updated",
692
692
  date: Date.now().toString(),
693
693
  status: "unread",
694
- callToAction: false,
694
+ notificationType: "regular",
695
695
  data: {
696
696
  resource: resource.name,
697
697
  type: resource.type,
@@ -721,14 +721,14 @@ const updateResourceBase = async (
721
721
  }
722
722
  const resourceErrorNotification: Notification = {
723
723
  type: "error",
724
- subtype: "resource-update-error",
724
+ subtype: getWuiErrorCode("resource", "updateResource", contentMessage) ?? "resource-update-error",
725
725
  info_content: {
726
726
  code: contentMessage,
727
727
  message: errorContent,
728
728
  },
729
729
  date: Date.now().toString(),
730
730
  status: "unread",
731
- callToAction: false,
731
+ notificationType: "regular",
732
732
  data: {
733
733
  resource: resource.name,
734
734
  type: resource.type,
@@ -830,4 +830,4 @@ export const updateResource = async (
830
830
  default:
831
831
  throw new Error(`Unsupported resource type: ${resource.type}`);
832
832
  }
833
- };
833
+ };
@@ -6,7 +6,7 @@ import {
6
6
  getWebSocketStatus,
7
7
  makeGlobalWebSocketRequest,
8
8
  } from "../websocket-manager";
9
- import { Link, Notification, Service } from "@kumori/aurora-interfaces";
9
+ import { getWuiErrorCode, Link, Notification, Service } from "@kumori/aurora-interfaces";
10
10
  import { Revision } from "@kumori/aurora-interfaces/interfaces/revision-interface";
11
11
  let pendingLinks = new Map<string, Link[]>();
12
12
  /**
@@ -40,6 +40,7 @@ export const deployService = async (data: Service, token: string) => {
40
40
  const response = await fetch(url.toString(), {
41
41
  method: "POST",
42
42
  body: formData,
43
+ credentials: "include",
43
44
  });
44
45
  if (!response.ok) {
45
46
  throw new Error(`HTTP error! status: ${response.status}`);
@@ -66,6 +67,7 @@ export const deployService = async (data: Service, token: string) => {
66
67
  const response = await fetch(url.toString(), {
67
68
  method: "POST",
68
69
  body: formData,
70
+ credentials: "include",
69
71
  });
70
72
  if (!response.ok) {
71
73
  const jsonResponse = await response.json();
@@ -121,6 +123,7 @@ export const redeployService = async (data: Service) => {
121
123
  const response = await fetch(url.toString(), {
122
124
  method: "POST",
123
125
  body: formData,
126
+ credentials: "include",
124
127
  });
125
128
 
126
129
  if (!response.ok) {
@@ -349,7 +352,7 @@ export const linkPendingServices = async (service: Service, token: string) => {
349
352
  subtype: "service-linked",
350
353
  date: Date.now().toString(),
351
354
  status: "unread",
352
- callToAction: false,
355
+ notificationType: "regular",
353
356
  data: {
354
357
  service: service.name,
355
358
  tenant: service.tenant,
@@ -361,14 +364,14 @@ export const linkPendingServices = async (service: Service, token: string) => {
361
364
  } catch (linkErr) {
362
365
  const notification: Notification = {
363
366
  type: "error",
364
- subtype: "error-service-link",
367
+ subtype: getWuiErrorCode("service", "linkService", (linkErr as any).error.code) ?? "error-service-link",
365
368
  date: Date.now().toString(),
366
369
  info_content: {
367
370
  code: (linkErr as any).error.code,
368
371
  message: (linkErr as any).error.content,
369
372
  },
370
373
  status: "unread",
371
- callToAction: false,
374
+ notificationType: "regular",
372
375
  data: {
373
376
  service: service.name,
374
377
  tenant: service.tenant,
@@ -447,6 +450,7 @@ export const updateService = async (
447
450
  const response = await fetch(url.toString(), {
448
451
  method: "POST",
449
452
  body: formData,
453
+ credentials: "include",
450
454
  });
451
455
  if (!response.ok) {
452
456
  throw new Error(`HTTP error! status: ${response.status}`);
@@ -611,7 +615,7 @@ export const updateService = async (
611
615
  subtype: "service-updated",
612
616
  date: Date.now().toString(),
613
617
  status: "unread",
614
- callToAction: false,
618
+ notificationType: "regular",
615
619
  data: {
616
620
  service: data.name,
617
621
  tenant: data.tenant,
@@ -625,14 +629,14 @@ export const updateService = async (
625
629
  console.error("Error updating service configuration via WebSocket:", err);
626
630
  const notification: Notification = {
627
631
  type: "error",
628
- subtype: "service-update-error",
632
+ subtype: getWuiErrorCode("service", "updateRevision", (err as any).error.code) ?? "service-update-error",
629
633
  date: Date.now().toString(),
630
634
  info_content: {
631
635
  code: (err as any).error.code,
632
636
  message: (err as any).error.content,
633
637
  },
634
638
  status: "unread",
635
- callToAction: false,
639
+ notificationType: "regular",
636
640
  data: {
637
641
  service: data.name,
638
642
  tenant: data.tenant,
@@ -669,7 +673,7 @@ export const unlinkServices = async (service: Service, token: string) => {
669
673
  subtype: "service-unlinking",
670
674
  date: Date.now().toString(),
671
675
  status: "unread",
672
- callToAction: false,
676
+ notificationType: "regular",
673
677
  data: {
674
678
  service: service.name,
675
679
  tenant: service.tenant,
@@ -682,14 +686,14 @@ export const unlinkServices = async (service: Service, token: string) => {
682
686
 
683
687
  const notification: Notification = {
684
688
  type: "error",
685
- subtype: "service-unlink-error",
689
+ subtype: getWuiErrorCode("service", "unlinkService", (unlinkErr as any).error.code) ?? "service-unlink-error",
686
690
  date: Date.now().toString(),
687
691
  info_content: {
688
692
  code: (unlinkErr as any).error.code,
689
693
  message: (unlinkErr as any).error.content,
690
694
  },
691
695
  status: "unread",
692
- callToAction: false,
696
+ notificationType: "regular",
693
697
  data: {
694
698
  service: service.name,
695
699
  tenant: service.tenant,
@@ -731,7 +735,7 @@ export const updateServiceLinks = async (link: Link, token: string) => {
731
735
  // subtype: "service-unlinked",
732
736
  // date: Date.now().toString(),
733
737
  // status: "unread",
734
- // callToAction: false,
738
+ // notificationType: "regular",
735
739
  // data: {
736
740
  // service: link.origin,
737
741
  // tenant: link.tenant,
@@ -744,14 +748,14 @@ export const updateServiceLinks = async (link: Link, token: string) => {
744
748
 
745
749
  const notification: Notification = {
746
750
  type: "error",
747
- subtype: "service-unlink-error",
751
+ subtype: getWuiErrorCode("service", "unlinkService", (unlinkErr as any).error.code) ?? "service-unlink-error",
748
752
  date: Date.now().toString(),
749
753
  info_content: {
750
754
  code: (unlinkErr as any).error.code,
751
755
  message: (unlinkErr as any).error.content,
752
756
  },
753
757
  status: "unread",
754
- callToAction: false,
758
+ notificationType: "regular",
755
759
  data: {
756
760
  service: link.origin,
757
761
  tenant: link.tenant,
@@ -778,7 +782,7 @@ export const updateServiceLinks = async (link: Link, token: string) => {
778
782
  subtype: "service-linked",
779
783
  date: Date.now().toString(),
780
784
  status: "unread",
781
- callToAction: false,
785
+ notificationType: "regular",
782
786
  data: {
783
787
  service: link.origin,
784
788
  tenant: link.tenant,
@@ -790,14 +794,14 @@ export const updateServiceLinks = async (link: Link, token: string) => {
790
794
  } catch (linkErr) {
791
795
  const notification: Notification = {
792
796
  type: "error",
793
- subtype: "error-service-link",
797
+ subtype: getWuiErrorCode("service", "linkService", (linkErr as any).error.code) ?? "error-service-link",
794
798
  date: Date.now().toString(),
795
799
  info_content: {
796
800
  code: (linkErr as any).error.code,
797
801
  message: (linkErr as any).error.content,
798
802
  },
799
803
  status: "unread",
800
- callToAction: false,
804
+ notificationType: "regular",
801
805
  data: {
802
806
  service: link.origin,
803
807
  tenant: link.tenant,
@@ -834,7 +838,7 @@ export const changeRevision = async (data: Service, token: string) => {
834
838
  subtype: "revision-updated",
835
839
  date: Date.now().toString(),
836
840
  status: "unread",
837
- callToAction: false,
841
+ notificationType: "regular",
838
842
  data: {
839
843
  service: data,
840
844
  },
@@ -844,14 +848,14 @@ export const changeRevision = async (data: Service, token: string) => {
844
848
  } catch (error) {
845
849
  const notification: Notification = {
846
850
  type: "error",
847
- subtype: "error-revision-update",
851
+ subtype: getWuiErrorCode("service", "updateRevision", (error as any).error.code) ?? "error-revision-update",
848
852
  date: Date.now().toString(),
849
853
  info_content: {
850
854
  code: (error as any).error.code,
851
855
  message: (error as any).error.content,
852
856
  },
853
857
  status: "unread",
854
- callToAction: false,
858
+ notificationType: "regular",
855
859
  data: {
856
860
  service: data,
857
861
  },
@@ -893,7 +897,7 @@ export async function restartInstance(
893
897
  subtype: "instance-restarted",
894
898
  date: Date.now().toString(),
895
899
  status: "unread",
896
- callToAction: false,
900
+ notificationType: "regular",
897
901
  data: {
898
902
  service: service,
899
903
  },
@@ -903,14 +907,14 @@ export async function restartInstance(
903
907
  } catch (error) {
904
908
  const notification: Notification = {
905
909
  type: "error",
906
- subtype: "error-instance-update",
910
+ subtype: getWuiErrorCode("service", "restart", (error as any).error.code) ?? "error-instance-update",
907
911
  date: Date.now().toString(),
908
912
  info_content: {
909
913
  code: (error as any).error.code,
910
914
  message: (error as any).error.content,
911
915
  },
912
916
  status: "unread",
913
- callToAction: false,
917
+ notificationType: "regular",
914
918
  data: {
915
919
  service: service,
916
920
  },