@kumori/aurora-backend-handler 1.0.100 → 1.0.111

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
+ errors,
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
  );
@@ -964,7 +939,7 @@ const linkPendingServices = async (service: Service, token: string) => {
964
939
 
965
940
  const notification: Notification = {
966
941
  type: "success",
967
- subtype: "service-linked",
942
+ subtype: errors.service.linked.subtype,
968
943
  date: Date.now().toString(),
969
944
  status: "unread",
970
945
  callToAction: false,
@@ -979,7 +954,7 @@ 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: errors.service.linkError.subtype,
983
958
  date: Date.now().toString(),
984
959
  info_content: {
985
960
  code: (linkErr as any).error.code,
@@ -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 { errors, Notification, Resource } from "@kumori/aurora-interfaces";
2
2
  import { eventHelper } from "../backend-handler";
3
3
 
4
4
  import {
@@ -50,7 +50,7 @@ export const createDomain = async (
50
50
  // eventHelper.resource.publish.created(domain);
51
51
  const resourceNotification: Notification = {
52
52
  type: "success",
53
- subtype: "resource-created",
53
+ subtype: errors.resource.created.subtype,
54
54
  date: Date.now().toString(),
55
55
  status: "unread",
56
56
  callToAction: false,
@@ -87,7 +87,7 @@ export const createDomain = async (
87
87
  }
88
88
  const resourceErrorNotification: Notification = {
89
89
  type: "error",
90
- subtype: "resource-creation-error",
90
+ subtype: errors.resource.creationError.subtype,
91
91
  info_content: {
92
92
  code: contentMessage,
93
93
  message: errorContent,
@@ -130,7 +130,7 @@ export const createPort = async (
130
130
  eventHelper.resource.publish.created(port);
131
131
  const resourceNotification: Notification = {
132
132
  type: "success",
133
- subtype: "resource-created",
133
+ subtype: errors.resource.created.subtype,
134
134
  date: Date.now().toString(),
135
135
  status: "unread",
136
136
  callToAction: false,
@@ -167,7 +167,7 @@ export const createPort = async (
167
167
  }
168
168
  const resourceErrorNotification: Notification = {
169
169
  type: "error",
170
- subtype: "resource-creation-error",
170
+ subtype: errors.resource.creationError.subtype,
171
171
  info_content: {
172
172
  code: contentMessage,
173
173
  message: errorContent,
@@ -210,7 +210,7 @@ export const createCA = async (
210
210
  eventHelper.resource.publish.created(ca);
211
211
  const resourceNotification: Notification = {
212
212
  type: "success",
213
- subtype: "resource-created",
213
+ subtype: errors.resource.created.subtype,
214
214
  date: Date.now().toString(),
215
215
  status: "unread",
216
216
  callToAction: false,
@@ -247,7 +247,7 @@ export const createCA = async (
247
247
  }
248
248
  const resourceErrorNotification: Notification = {
249
249
  type: "error",
250
- subtype: "resource-creation-error",
250
+ subtype: errors.resource.creationError.subtype,
251
251
  info_content: {
252
252
  code: contentMessage,
253
253
  message: errorContent,
@@ -303,7 +303,7 @@ export const createCertificate = async (
303
303
  eventHelper.resource.publish.created(certificate);
304
304
  const resourceNotification: Notification = {
305
305
  type: "success",
306
- subtype: "resource-created",
306
+ subtype: errors.resource.created.subtype,
307
307
  date: Date.now().toString(),
308
308
  status: "unread",
309
309
  callToAction: false,
@@ -340,7 +340,7 @@ export const createCertificate = async (
340
340
  }
341
341
  const resourceErrorNotification: Notification = {
342
342
  type: "error",
343
- subtype: "resource-creation-error",
343
+ subtype: errors.resource.creationError.subtype,
344
344
  info_content: {
345
345
  code: contentMessage,
346
346
  message: errorContent,
@@ -383,7 +383,7 @@ export const createSecret = async (
383
383
  eventHelper.resource.publish.created(secret);
384
384
  const resourceNotification: Notification = {
385
385
  type: "success",
386
- subtype: "resource-created",
386
+ subtype: errors.resource.created.subtype,
387
387
  date: Date.now().toString(),
388
388
  status: "unread",
389
389
  callToAction: false,
@@ -420,7 +420,7 @@ export const createSecret = async (
420
420
  }
421
421
  const resourceErrorNotification: Notification = {
422
422
  type: "error",
423
- subtype: "resource-creation-error",
423
+ subtype: errors.resource.creationError.subtype,
424
424
  info_content: {
425
425
  code: contentMessage,
426
426
  message: errorContent,
@@ -483,7 +483,7 @@ export const createVolume = async (
483
483
  eventHelper.resource.publish.created(volume);
484
484
  const resourceNotification: Notification = {
485
485
  type: "success",
486
- subtype: "resource-created",
486
+ subtype: errors.resource.created.subtype,
487
487
  date: Date.now().toString(),
488
488
  status: "unread",
489
489
  callToAction: false,
@@ -520,7 +520,7 @@ export const createVolume = async (
520
520
  }
521
521
  const resourceErrorNotification: Notification = {
522
522
  type: "error",
523
- subtype: "resource-creation-error",
523
+ subtype: errors.resource.creationError.subtype,
524
524
  info_content: {
525
525
  code: contentMessage,
526
526
  message: errorContent,
@@ -587,13 +587,13 @@ 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
- subtype: "resource-deleting",
596
+ subtype: errors.resource.deleting.subtype,
597
597
  date: Date.now().toString(),
598
598
  status: "unread",
599
599
  callToAction: false,
@@ -626,7 +626,7 @@ const deleteResourceBase = async (
626
626
  }
627
627
  const resourceErrorNotification: Notification = {
628
628
  type: "error",
629
- subtype: "resource-deletion-error",
629
+ subtype: errors.resource.deletionError.subtype,
630
630
  info_content: {
631
631
  code: contentMessage,
632
632
  message: errorContent,
@@ -688,7 +688,7 @@ const updateResourceBase = async (
688
688
  // eventHelper.resource.publish.updated(resource);
689
689
  const resourceNotification: Notification = {
690
690
  type: "success",
691
- subtype: "resource-updated",
691
+ subtype: errors.resource.updated.subtype,
692
692
  date: Date.now().toString(),
693
693
  status: "unread",
694
694
  callToAction: false,
@@ -721,7 +721,7 @@ const updateResourceBase = async (
721
721
  }
722
722
  const resourceErrorNotification: Notification = {
723
723
  type: "error",
724
- subtype: "resource-update-error",
724
+ subtype: errors.resource.updateError.subtype,
725
725
  info_content: {
726
726
  code: contentMessage,
727
727
  message: errorContent,
@@ -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 { errors, 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) {
@@ -346,7 +349,7 @@ export const linkPendingServices = async (service: Service, token: string) => {
346
349
 
347
350
  const notification: Notification = {
348
351
  type: "success",
349
- subtype: "service-linked",
352
+ subtype: errors.service.linked.subtype,
350
353
  date: Date.now().toString(),
351
354
  status: "unread",
352
355
  callToAction: false,
@@ -361,7 +364,7 @@ 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: errors.service.linkError.subtype,
365
368
  date: Date.now().toString(),
366
369
  info_content: {
367
370
  code: (linkErr as any).error.code,
@@ -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}`);
@@ -608,7 +612,7 @@ export const updateService = async (
608
612
 
609
613
  const updateNotification: Notification = {
610
614
  type: "success",
611
- subtype: "service-updated",
615
+ subtype: errors.service.updated.subtype,
612
616
  date: Date.now().toString(),
613
617
  status: "unread",
614
618
  callToAction: false,
@@ -625,7 +629,7 @@ 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: errors.service.updateError.subtype,
629
633
  date: Date.now().toString(),
630
634
  info_content: {
631
635
  code: (err as any).error.code,
@@ -666,7 +670,7 @@ export const unlinkServices = async (service: Service, token: string) => {
666
670
 
667
671
  const unlinkNotification: Notification = {
668
672
  type: "success",
669
- subtype: "service-unlinking",
673
+ subtype: errors.service.unlinking.subtype,
670
674
  date: Date.now().toString(),
671
675
  status: "unread",
672
676
  callToAction: false,
@@ -682,7 +686,7 @@ 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: errors.service.unlinkError.subtype,
686
690
  date: Date.now().toString(),
687
691
  info_content: {
688
692
  code: (unlinkErr as any).error.code,
@@ -744,7 +748,7 @@ 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: errors.service.unlinkError.subtype,
748
752
  date: Date.now().toString(),
749
753
  info_content: {
750
754
  code: (unlinkErr as any).error.code,
@@ -775,7 +779,7 @@ export const updateServiceLinks = async (link: Link, token: string) => {
775
779
 
776
780
  const notification: Notification = {
777
781
  type: "success",
778
- subtype: "service-linked",
782
+ subtype: errors.service.linked.subtype,
779
783
  date: Date.now().toString(),
780
784
  status: "unread",
781
785
  callToAction: false,
@@ -790,7 +794,7 @@ 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: errors.service.linkError.subtype,
794
798
  date: Date.now().toString(),
795
799
  info_content: {
796
800
  code: (linkErr as any).error.code,
@@ -831,7 +835,7 @@ export const changeRevision = async (data: Service, token: string) => {
831
835
  );
832
836
  const notification: Notification = {
833
837
  type: "success",
834
- subtype: "revision-updated",
838
+ subtype: errors.deployment.revisionUpdated.subtype,
835
839
  date: Date.now().toString(),
836
840
  status: "unread",
837
841
  callToAction: false,
@@ -844,7 +848,7 @@ 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: errors.deployment.revisionUpdateError.subtype,
848
852
  date: Date.now().toString(),
849
853
  info_content: {
850
854
  code: (error as any).error.code,
@@ -890,7 +894,7 @@ export async function restartInstance(
890
894
  );
891
895
  const notification: Notification = {
892
896
  type: "success",
893
- subtype: "instance-restarted",
897
+ subtype: errors.deployment.instanceRestarted.subtype,
894
898
  date: Date.now().toString(),
895
899
  status: "unread",
896
900
  callToAction: false,
@@ -903,7 +907,7 @@ export async function restartInstance(
903
907
  } catch (error) {
904
908
  const notification: Notification = {
905
909
  type: "error",
906
- subtype: "error-instance-update",
910
+ subtype: errors.deployment.instanceUpdateError.subtype,
907
911
  date: Date.now().toString(),
908
912
  info_content: {
909
913
  code: (error as any).error.code,