@kumori/aurora-backend-handler 1.0.99 → 1.1.0
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/api/deploy-service-helper.ts +12 -35
- package/api/tenant-api-service.ts +18 -2
- package/backend-handler.ts +2 -2
- package/event-helper.ts +4 -3
- package/helpers/user-helper.ts +4 -5
- package/package.json +1 -1
- package/websocket-manager.ts +21 -0
|
@@ -436,7 +436,6 @@ export function handleParametersToGenerateData(
|
|
|
436
436
|
* @returns A ServiceSpecForm object with the data of the service.
|
|
437
437
|
*/
|
|
438
438
|
export function transformServiceToForm(service: Service): ServiceSpecForm {
|
|
439
|
-
console.log('--- TRANSFORM SERVICE TO FORM ---', service.name);
|
|
440
439
|
return {
|
|
441
440
|
tenantId: service.tenant,
|
|
442
441
|
accountId: service.account,
|
|
@@ -513,15 +512,12 @@ export async function generateServiceSpec(
|
|
|
513
512
|
resources: componentResources,
|
|
514
513
|
} = handleParametersToGenerateData(formParams, formResources);
|
|
515
514
|
|
|
516
|
-
console.log('--- GENERATE SERVICE SPEC ---', form.serviceId);
|
|
517
|
-
console.log('Channels from Form:', JSON.stringify(form.channels));
|
|
518
|
-
|
|
519
515
|
const serverConfigDomainResources: ArtifactConfigResource[] = form.channels
|
|
520
516
|
.filter((channel) => channel.protocol === "HTTPS" && channel.isPublic)
|
|
521
517
|
.map((channel) => ({ domain: { name: `${channel.channelName}_domain` } }));
|
|
522
518
|
|
|
523
519
|
const hasDefaultCertChannel = form.channels.some(
|
|
524
|
-
(ch) => ch.protocol === "HTTPS" && ch.isPublic && !ch.certificateResource
|
|
520
|
+
(ch) => ch.protocol === "HTTPS" && ch.isPublic && !ch.certificateResource,
|
|
525
521
|
);
|
|
526
522
|
if (hasDefaultCertChannel) {
|
|
527
523
|
serverConfigDomainResources.push({
|
|
@@ -531,23 +527,17 @@ export async function generateServiceSpec(
|
|
|
531
527
|
|
|
532
528
|
const customCertResources: ArtifactConfigResource[] = form.channels
|
|
533
529
|
.filter(
|
|
534
|
-
(ch) => ch.protocol === "HTTPS" && ch.isPublic && ch.certificateResource
|
|
530
|
+
(ch) => ch.protocol === "HTTPS" && ch.isPublic && ch.certificateResource,
|
|
535
531
|
)
|
|
536
532
|
.map((ch) => ({ certificate: { name: `${ch.channelName}_cert` } }));
|
|
537
533
|
|
|
538
534
|
const customCaResources: ArtifactConfigResource[] = form.channels
|
|
539
535
|
.filter(
|
|
540
536
|
(ch) =>
|
|
541
|
-
ch.protocol === "HTTPS" && ch.isPublic && ch.withMtls && ch.caResource
|
|
537
|
+
ch.protocol === "HTTPS" && ch.isPublic && ch.withMtls && ch.caResource,
|
|
542
538
|
)
|
|
543
539
|
.map((ch) => ({ ca: { name: `${ch.channelName}_ca` } }));
|
|
544
540
|
|
|
545
|
-
console.log('Generated Resources Spec:', {
|
|
546
|
-
serverConfigDomainResources,
|
|
547
|
-
customCertResources,
|
|
548
|
-
customCaResources
|
|
549
|
-
});
|
|
550
|
-
|
|
551
541
|
const serviceConfigPortResources: ArtifactConfigResource[] = form.channels
|
|
552
542
|
.filter((channel) => channel.protocol === "TCP" && channel.isPublic)
|
|
553
543
|
.map((channel) => ({ port: { name: `${channel.channelName}_port` } }));
|
|
@@ -891,7 +881,7 @@ export async function generateServiceSpec(
|
|
|
891
881
|
}));
|
|
892
882
|
|
|
893
883
|
const hasDefaultCertChannelDeployment = form.channels.some(
|
|
894
|
-
(ch) => ch.protocol === "HTTPS" && ch.isPublic && !ch.certificateResource
|
|
884
|
+
(ch) => ch.protocol === "HTTPS" && ch.isPublic && !ch.certificateResource,
|
|
895
885
|
);
|
|
896
886
|
if (hasDefaultCertChannelDeployment) {
|
|
897
887
|
deploymentConfigDomain.push({
|
|
@@ -904,7 +894,7 @@ export async function generateServiceSpec(
|
|
|
904
894
|
|
|
905
895
|
const customCertDeploymentResources: DeploymentResource[] = form.channels
|
|
906
896
|
.filter(
|
|
907
|
-
(ch) => ch.protocol === "HTTPS" && ch.isPublic && ch.certificateResource
|
|
897
|
+
(ch) => ch.protocol === "HTTPS" && ch.isPublic && ch.certificateResource,
|
|
908
898
|
)
|
|
909
899
|
.map((ch) => ({
|
|
910
900
|
certificate: {
|
|
@@ -916,7 +906,7 @@ export async function generateServiceSpec(
|
|
|
916
906
|
const customCaDeploymentResources: DeploymentResource[] = form.channels
|
|
917
907
|
.filter(
|
|
918
908
|
(ch) =>
|
|
919
|
-
ch.protocol === "HTTPS" && ch.isPublic && ch.withMtls && ch.caResource
|
|
909
|
+
ch.protocol === "HTTPS" && ch.isPublic && ch.withMtls && ch.caResource,
|
|
920
910
|
)
|
|
921
911
|
.map((ch) => ({
|
|
922
912
|
ca: {
|
|
@@ -1145,7 +1135,7 @@ async function generateServiceSpecDSL(
|
|
|
1145
1135
|
.map((channel) => ({ domain: { name: `${channel.channelName}_domain` } }));
|
|
1146
1136
|
|
|
1147
1137
|
const hasDefaultCertChannel = form.channels.some(
|
|
1148
|
-
(ch) => ch.protocol === "HTTPS" && ch.isPublic && !ch.certificateResource
|
|
1138
|
+
(ch) => ch.protocol === "HTTPS" && ch.isPublic && !ch.certificateResource,
|
|
1149
1139
|
);
|
|
1150
1140
|
if (hasDefaultCertChannel) {
|
|
1151
1141
|
serverConfigDomainResources.push({
|
|
@@ -1155,23 +1145,17 @@ async function generateServiceSpecDSL(
|
|
|
1155
1145
|
|
|
1156
1146
|
const customCertResources: ArtifactConfigResource[] = form.channels
|
|
1157
1147
|
.filter(
|
|
1158
|
-
(ch) => ch.protocol === "HTTPS" && ch.isPublic && ch.certificateResource
|
|
1148
|
+
(ch) => ch.protocol === "HTTPS" && ch.isPublic && ch.certificateResource,
|
|
1159
1149
|
)
|
|
1160
1150
|
.map((ch) => ({ certificate: { name: `${ch.channelName}_cert` } }));
|
|
1161
1151
|
|
|
1162
1152
|
const customCaResources: ArtifactConfigResource[] = form.channels
|
|
1163
1153
|
.filter(
|
|
1164
1154
|
(ch) =>
|
|
1165
|
-
ch.protocol === "HTTPS" && ch.isPublic && ch.withMtls && ch.caResource
|
|
1155
|
+
ch.protocol === "HTTPS" && ch.isPublic && ch.withMtls && ch.caResource,
|
|
1166
1156
|
)
|
|
1167
1157
|
.map((ch) => ({ ca: { name: `${ch.channelName}_ca` } }));
|
|
1168
1158
|
|
|
1169
|
-
console.log('Generated Resources Config:', {
|
|
1170
|
-
serverConfigDomainResources,
|
|
1171
|
-
customCertResources,
|
|
1172
|
-
customCaResources
|
|
1173
|
-
});
|
|
1174
|
-
|
|
1175
1159
|
const serviceConfigPortResources: ArtifactConfigResource[] = form.channels
|
|
1176
1160
|
.filter((channel) => channel.protocol === "TCP" && channel.isPublic)
|
|
1177
1161
|
.map((channel) => ({ port: { name: `${channel.channelName}_port` } }));
|
|
@@ -1458,7 +1442,7 @@ async function generateServiceSpecDSL(
|
|
|
1458
1442
|
}));
|
|
1459
1443
|
|
|
1460
1444
|
const hasDefaultCertChannelDeployment = form.channels.some(
|
|
1461
|
-
(ch) => ch.protocol === "HTTPS" && ch.isPublic && !ch.certificateResource
|
|
1445
|
+
(ch) => ch.protocol === "HTTPS" && ch.isPublic && !ch.certificateResource,
|
|
1462
1446
|
);
|
|
1463
1447
|
if (hasDefaultCertChannelDeployment) {
|
|
1464
1448
|
deploymentConfigDomain.push({
|
|
@@ -1471,7 +1455,7 @@ async function generateServiceSpecDSL(
|
|
|
1471
1455
|
|
|
1472
1456
|
const customCertDeploymentResources: DeploymentResource[] = form.channels
|
|
1473
1457
|
.filter(
|
|
1474
|
-
(ch) => ch.protocol === "HTTPS" && ch.isPublic && ch.certificateResource
|
|
1458
|
+
(ch) => ch.protocol === "HTTPS" && ch.isPublic && ch.certificateResource,
|
|
1475
1459
|
)
|
|
1476
1460
|
.map((ch) => ({
|
|
1477
1461
|
certificate: {
|
|
@@ -1483,7 +1467,7 @@ async function generateServiceSpecDSL(
|
|
|
1483
1467
|
const customCaDeploymentResources: DeploymentResource[] = form.channels
|
|
1484
1468
|
.filter(
|
|
1485
1469
|
(ch) =>
|
|
1486
|
-
ch.protocol === "HTTPS" && ch.isPublic && ch.withMtls && ch.caResource
|
|
1470
|
+
ch.protocol === "HTTPS" && ch.isPublic && ch.withMtls && ch.caResource,
|
|
1487
1471
|
)
|
|
1488
1472
|
.map((ch) => ({
|
|
1489
1473
|
ca: {
|
|
@@ -1492,12 +1476,6 @@ async function generateServiceSpecDSL(
|
|
|
1492
1476
|
},
|
|
1493
1477
|
}));
|
|
1494
1478
|
|
|
1495
|
-
console.log('Generated Deployment Resources:', {
|
|
1496
|
-
deploymentConfigDomain,
|
|
1497
|
-
customCertDeploymentResources,
|
|
1498
|
-
customCaDeploymentResources
|
|
1499
|
-
});
|
|
1500
|
-
|
|
1501
1479
|
const deploymentConfigPort: DeploymentResource[] = form.channels
|
|
1502
1480
|
.filter((channel) => channel.protocol === "TCP" && channel.isPublic)
|
|
1503
1481
|
.map((channel) => ({
|
|
@@ -1718,7 +1696,6 @@ export async function deployServiceHelper(
|
|
|
1718
1696
|
serviceForm,
|
|
1719
1697
|
marketplaceItem,
|
|
1720
1698
|
);
|
|
1721
|
-
console.log('Final generated ServiceSpecDSL:', JSON.stringify(serviceSpecDSL, null, 2));
|
|
1722
1699
|
CUEBundle = buildServiceDeploymentModule(serviceSpecDSL);
|
|
1723
1700
|
|
|
1724
1701
|
// if (marketplaceItem?.package) {
|
|
@@ -1120,7 +1120,7 @@ export const acceptInvite = async (tenant: string, security: string) => {
|
|
|
1120
1120
|
}
|
|
1121
1121
|
};
|
|
1122
1122
|
|
|
1123
|
-
export const rejectInvite = async (tenant: string, security: string) => {
|
|
1123
|
+
export const rejectInvite = async (tenant: string, security: string, leave: boolean) => {
|
|
1124
1124
|
try {
|
|
1125
1125
|
await initializeGlobalWebSocketClient(security);
|
|
1126
1126
|
const queryParams = { tenant: tenant };
|
|
@@ -1131,7 +1131,21 @@ export const rejectInvite = async (tenant: string, security: string) => {
|
|
|
1131
1131
|
"DELETE",
|
|
1132
1132
|
`${tenant}/reject`
|
|
1133
1133
|
);
|
|
1134
|
-
|
|
1134
|
+
if(leave){
|
|
1135
|
+
const tenantInviteRejectedNotification: Notification = {
|
|
1136
|
+
type: "success",
|
|
1137
|
+
subtype: "tenant-leave",
|
|
1138
|
+
date: Date.now().toString(),
|
|
1139
|
+
status: "unread",
|
|
1140
|
+
callToAction: false,
|
|
1141
|
+
data: {
|
|
1142
|
+
tenant: tenant,
|
|
1143
|
+
},
|
|
1144
|
+
};
|
|
1145
|
+
eventHelper.notification.publish.creation(tenantInviteRejectedNotification);
|
|
1146
|
+
}
|
|
1147
|
+
else{
|
|
1148
|
+
const tenantInviteRejectedNotification: Notification = {
|
|
1135
1149
|
type: "success",
|
|
1136
1150
|
subtype: "tenant-invite-rejected",
|
|
1137
1151
|
date: Date.now().toString(),
|
|
@@ -1142,6 +1156,8 @@ export const rejectInvite = async (tenant: string, security: string) => {
|
|
|
1142
1156
|
},
|
|
1143
1157
|
};
|
|
1144
1158
|
eventHelper.notification.publish.creation(tenantInviteRejectedNotification);
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1145
1161
|
return response;
|
|
1146
1162
|
} catch (error) {
|
|
1147
1163
|
console.error("Error rejecting tenant invite:", {
|
package/backend-handler.ts
CHANGED
|
@@ -352,8 +352,8 @@ export class BackendHandler {
|
|
|
352
352
|
this.unsubscribeFunctions.push(() =>
|
|
353
353
|
eventHelper.tenant.unsubscribe.acceptInviteError(inviteAcceptErrorCb)
|
|
354
354
|
);
|
|
355
|
-
const rejectInviteCb = (payload: { tenant: string }) => {
|
|
356
|
-
rejectInvite(payload.tenant, token);
|
|
355
|
+
const rejectInviteCb = (payload: { tenant: string, leave: boolean }) => {
|
|
356
|
+
rejectInvite(payload.tenant, token, payload.leave);
|
|
357
357
|
}
|
|
358
358
|
eventHelper.tenant.subscribe.rejectInvite(rejectInviteCb);
|
|
359
359
|
this.unsubscribeFunctions.push(() =>
|
package/event-helper.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { loadUser } from './api/user-api-service';
|
|
1
2
|
import { Account, Environment, Link, MarketplaceItem, MarketplaceService, Organization, PlanProvider, Registry, Tenant, tenantRole, User, Service, Notification, Resource } from "@kumori/aurora-interfaces";
|
|
2
3
|
import { EventNames } from "./event-names";
|
|
3
4
|
export interface RegistryUpdatePayload {
|
|
@@ -63,7 +64,7 @@ export class EventHelper {
|
|
|
63
64
|
updateInvite: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.UpdateInvite).publish,
|
|
64
65
|
inviteUpdated: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.InviteUpdated).publish,
|
|
65
66
|
inviteUpdateError: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.InviteUpdateError).publish,
|
|
66
|
-
rejectInvite: this.createEvent<{ tenant: string; }>(EventNames.RejectInvite).publish,
|
|
67
|
+
rejectInvite: this.createEvent<{ tenant: string; leave: boolean }>(EventNames.RejectInvite).publish,
|
|
67
68
|
inviteRejected: this.createEvent<{ user: string; tenant: string; }>(EventNames.InviteRejected).publish,
|
|
68
69
|
inviteRejectError: this.createEvent<{ tenant: string; }>(EventNames.InviteRejectError).publish,
|
|
69
70
|
createToken: this.createEvent<{ tenant: string; expiration: string; description: string }>(EventNames.CreateToken).publish,
|
|
@@ -104,7 +105,7 @@ export class EventHelper {
|
|
|
104
105
|
updateInvite: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.UpdateInvite).subscribe,
|
|
105
106
|
inviteUpdated: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.InviteUpdated).subscribe,
|
|
106
107
|
inviteUpdateError: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.InviteUpdateError).subscribe,
|
|
107
|
-
rejectInvite: this.createEvent<{ tenant: string; }>(EventNames.RejectInvite).subscribe,
|
|
108
|
+
rejectInvite: this.createEvent<{ tenant: string; leave: boolean }>(EventNames.RejectInvite).subscribe,
|
|
108
109
|
inviteRejected: this.createEvent<{ user: string; tenant: string; }>(EventNames.InviteRejected).subscribe,
|
|
109
110
|
inviteRejectError: this.createEvent<{ tenant: string; }>(EventNames.InviteRejectError).subscribe,
|
|
110
111
|
createToken: this.createEvent<{ tenant: string; expiration: string; description: string }>(EventNames.CreateToken).subscribe,
|
|
@@ -145,7 +146,7 @@ export class EventHelper {
|
|
|
145
146
|
updateInvite: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.UpdateInvite).unsubscribe,
|
|
146
147
|
inviteUpdated: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.InviteUpdated).unsubscribe,
|
|
147
148
|
inviteUpdateError: this.createEvent<{ tenant: string; user: string; role: tenantRole; }>(EventNames.InviteUpdateError).unsubscribe,
|
|
148
|
-
rejectInvite: this.createEvent<{ tenant: string; }>(EventNames.RejectInvite).unsubscribe,
|
|
149
|
+
rejectInvite: this.createEvent<{ tenant: string; leave: boolean }>(EventNames.RejectInvite).unsubscribe,
|
|
149
150
|
inviteRejected: this.createEvent<{ user: string; tenant: string; }>(EventNames.InviteRejected).unsubscribe,
|
|
150
151
|
inviteRejectError: this.createEvent<{ tenant: string; }>(EventNames.InviteRejectError).unsubscribe,
|
|
151
152
|
createToken: this.createEvent<{ tenant: string; expiration: string; description: string }>(EventNames.CreateToken).unsubscribe,
|
package/helpers/user-helper.ts
CHANGED
|
@@ -38,10 +38,9 @@ export const handleUserEvent = ({
|
|
|
38
38
|
if (!userTenants.includes(key)) {
|
|
39
39
|
const tenantToDelete = tenantsMap.get(key);
|
|
40
40
|
if (tenantToDelete) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
subtype: "tenant-deleted",
|
|
41
|
+
const userRemovedNotification: Notification = {
|
|
42
|
+
type: "info",
|
|
43
|
+
subtype: "user-removed-from-tenant",
|
|
45
44
|
date: Date.now().toString(),
|
|
46
45
|
callToAction: false,
|
|
47
46
|
status: "unread",
|
|
@@ -49,7 +48,7 @@ export const handleUserEvent = ({
|
|
|
49
48
|
tenant: tenantToDelete.name,
|
|
50
49
|
},
|
|
51
50
|
};
|
|
52
|
-
eventHelper.notification.publish.creation(
|
|
51
|
+
eventHelper.notification.publish.creation(userRemovedNotification);
|
|
53
52
|
deletedTenantKeys.push(key);
|
|
54
53
|
}
|
|
55
54
|
}
|
package/package.json
CHANGED
package/websocket-manager.ts
CHANGED
|
@@ -804,6 +804,27 @@ const handleEvent = async (message: WSMessage) => {
|
|
|
804
804
|
eventData,
|
|
805
805
|
userData,
|
|
806
806
|
);
|
|
807
|
+
|
|
808
|
+
if (
|
|
809
|
+
existingTenant &&
|
|
810
|
+
existingTenant.role &&
|
|
811
|
+
newTenant.role &&
|
|
812
|
+
existingTenant.role !== newTenant.role
|
|
813
|
+
) {
|
|
814
|
+
const roleNotification: Notification = {
|
|
815
|
+
type: "info",
|
|
816
|
+
subtype: "tenant-role-changed",
|
|
817
|
+
date: Date.now().toString(),
|
|
818
|
+
status: "unread",
|
|
819
|
+
callToAction: false,
|
|
820
|
+
data: {
|
|
821
|
+
tenant: newTenant.name,
|
|
822
|
+
oldRole: existingTenant.role,
|
|
823
|
+
newRole: newTenant.role,
|
|
824
|
+
},
|
|
825
|
+
};
|
|
826
|
+
eventHelper.notification.publish.creation(roleNotification);
|
|
827
|
+
}
|
|
807
828
|
if (existingTenant) {
|
|
808
829
|
if (
|
|
809
830
|
!newTenant.resources?.length &&
|