|
|
|
@@ -28,10 +28,21 @@ export const loginAction = loginStatePart.createAction<{ username: string; passw
|
|
|
|
|
...statePartArg.getState(),
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return {
|
|
|
|
|
const newState = {
|
|
|
|
|
...currentState,
|
|
|
|
|
...(response.identity ? { identity: response.identity } : {}),
|
|
|
|
|
};
|
|
|
|
|
try {
|
|
|
|
|
// Keep shared API client in sync and establish WS for modules using sockets
|
|
|
|
|
apiClient.identity = (response as any)?.identity || null;
|
|
|
|
|
if (apiClient.identity) {
|
|
|
|
|
if (!apiClient['typedsocketClient']) {
|
|
|
|
|
await apiClient.start();
|
|
|
|
|
}
|
|
|
|
|
try { apiClient.typedsocketClient.addTag('identity', apiClient.identity); } catch {}
|
|
|
|
|
}
|
|
|
|
|
} catch {}
|
|
|
|
|
return newState;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
@@ -84,6 +95,12 @@ export const dataState = await appstate.getStatePart<IDataState>(
|
|
|
|
|
'soft'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Shared API client instance (used by UI actions)
|
|
|
|
|
export const apiClient = new plugins.servezoneApi.CloudlyApiClient({
|
|
|
|
|
registerAs: 'api',
|
|
|
|
|
cloudlyUrl: (typeof window !== 'undefined' && window.location?.origin) ? window.location.origin : undefined,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Getting data
|
|
|
|
|
export const getAllDataAction = dataState.createAction(async (statePartArg) => {
|
|
|
|
|
let currentState = statePartArg.getState();
|
|
|
|
@@ -144,19 +161,13 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => {
|
|
|
|
|
clusters: responseClusters.clusters,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// External Registries
|
|
|
|
|
const trGetExternalRegistries =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.externalRegistry.IReq_GetRegistries>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'getExternalRegistries'
|
|
|
|
|
);
|
|
|
|
|
// External Registries via shared API client
|
|
|
|
|
try {
|
|
|
|
|
const responseExternalRegistries = await trGetExternalRegistries.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
const registries = await apiClient.externalRegistry.getRegistries();
|
|
|
|
|
currentState = {
|
|
|
|
|
...currentState,
|
|
|
|
|
externalRegistries: responseExternalRegistries?.registries || [],
|
|
|
|
|
externalRegistries: registries as any,
|
|
|
|
|
};
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Failed to fetch external registries:', error);
|
|
|
|
@@ -210,16 +221,10 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Domains
|
|
|
|
|
const trGetDomains =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.domain.IRequest_Any_Cloudly_GetDomains>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'getDomains'
|
|
|
|
|
);
|
|
|
|
|
// Domains via API client
|
|
|
|
|
try {
|
|
|
|
|
const responseDomains = await trGetDomains.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
const responseDomains = await apiClient.domains.getDomains();
|
|
|
|
|
currentState = {
|
|
|
|
|
...currentState,
|
|
|
|
|
domains: responseDomains?.domains || [],
|
|
|
|
@@ -232,16 +237,10 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => {
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DNS Entries
|
|
|
|
|
const trGetDnsEntries =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.dns.IRequest_Any_Cloudly_GetDnsEntries>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'getDnsEntries'
|
|
|
|
|
);
|
|
|
|
|
// DNS Entries via API client
|
|
|
|
|
try {
|
|
|
|
|
const responseDnsEntries = await trGetDnsEntries.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
const responseDnsEntries = await apiClient.dns.getDnsEntries();
|
|
|
|
|
currentState = {
|
|
|
|
|
...currentState,
|
|
|
|
|
dnsEntries: responseDnsEntries?.dnsEntries || [],
|
|
|
|
@@ -261,15 +260,8 @@ export const getAllDataAction = dataState.createAction(async (statePartArg) => {
|
|
|
|
|
export const createServiceAction = dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { serviceData: plugins.interfaces.data.IService['data'] }) => {
|
|
|
|
|
let currentState = statePartArg.getState();
|
|
|
|
|
const trCreateService =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.service.IRequest_Any_Cloudly_CreateService>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'createService'
|
|
|
|
|
);
|
|
|
|
|
const response = await trCreateService.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
serviceData: payloadArg.serviceData,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
await apiClient.services.createService(payloadArg.serviceData);
|
|
|
|
|
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
@@ -278,16 +270,8 @@ export const createServiceAction = dataState.createAction(
|
|
|
|
|
export const updateServiceAction = dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { serviceId: string; serviceData: plugins.interfaces.data.IService['data'] }) => {
|
|
|
|
|
let currentState = statePartArg.getState();
|
|
|
|
|
const trUpdateService =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.service.IRequest_Any_Cloudly_UpdateService>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'updateService'
|
|
|
|
|
);
|
|
|
|
|
const response = await trUpdateService.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
serviceId: payloadArg.serviceId,
|
|
|
|
|
serviceData: payloadArg.serviceData,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
await apiClient.services.updateService(payloadArg.serviceId, payloadArg.serviceData);
|
|
|
|
|
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
@@ -296,15 +280,8 @@ export const updateServiceAction = dataState.createAction(
|
|
|
|
|
export const deleteServiceAction = dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { serviceId: string }) => {
|
|
|
|
|
let currentState = statePartArg.getState();
|
|
|
|
|
const trDeleteService =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.service.IRequest_Any_Cloudly_DeleteServiceById>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'deleteServiceById'
|
|
|
|
|
);
|
|
|
|
|
const response = await trDeleteService.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
serviceId: payloadArg.serviceId,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
await apiClient.services.deleteService(payloadArg.serviceId);
|
|
|
|
|
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
@@ -368,22 +345,9 @@ export const deleteSecretBundleAction = dataState.createAction(
|
|
|
|
|
export const createImageAction = dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { imageName: string, description: string }) => {
|
|
|
|
|
let currentState = statePartArg.getState();
|
|
|
|
|
const trCreateImage =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.image.IRequest_CreateImage>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'createImage'
|
|
|
|
|
);
|
|
|
|
|
const response = await trCreateImage.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
name: payloadArg.imageName,
|
|
|
|
|
description: payloadArg.description,
|
|
|
|
|
});
|
|
|
|
|
currentState = {
|
|
|
|
|
...currentState,
|
|
|
|
|
...{
|
|
|
|
|
images: [...currentState.images, response.image],
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
await apiClient.image.createImage({ name: payloadArg.imageName, description: payloadArg.description } as any);
|
|
|
|
|
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
@@ -391,21 +355,9 @@ export const createImageAction = dataState.createAction(
|
|
|
|
|
export const deleteImageAction = dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { imageId: string }) => {
|
|
|
|
|
let currentState = statePartArg.getState();
|
|
|
|
|
const trDeleteImage =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.image.IRequest_DeleteImage>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'deleteImage'
|
|
|
|
|
);
|
|
|
|
|
const response = await trDeleteImage.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
imageId: payloadArg.imageId,
|
|
|
|
|
});
|
|
|
|
|
currentState = {
|
|
|
|
|
...currentState,
|
|
|
|
|
...{
|
|
|
|
|
images: currentState.images.filter((image) => image.id !== payloadArg.imageId),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
await apiClient.image.deleteImage(payloadArg.imageId);
|
|
|
|
|
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
@@ -414,15 +366,8 @@ export const deleteImageAction = dataState.createAction(
|
|
|
|
|
export const createDeploymentAction = dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { deploymentData: Partial<plugins.interfaces.data.IDeployment> }) => {
|
|
|
|
|
let currentState = statePartArg.getState();
|
|
|
|
|
const trCreateDeployment =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.deployment.IReq_Any_Cloudly_CreateDeployment>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'createDeployment'
|
|
|
|
|
);
|
|
|
|
|
const response = await trCreateDeployment.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
deploymentData: payloadArg.deploymentData,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
await apiClient.deployments.createDeployment(payloadArg.deploymentData);
|
|
|
|
|
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
@@ -431,16 +376,8 @@ export const createDeploymentAction = dataState.createAction(
|
|
|
|
|
export const updateDeploymentAction = dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { deploymentId: string; deploymentData: Partial<plugins.interfaces.data.IDeployment> }) => {
|
|
|
|
|
let currentState = statePartArg.getState();
|
|
|
|
|
const trUpdateDeployment =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.deployment.IReq_Any_Cloudly_UpdateDeployment>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'updateDeployment'
|
|
|
|
|
);
|
|
|
|
|
const response = await trUpdateDeployment.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
deploymentId: payloadArg.deploymentId,
|
|
|
|
|
deploymentData: payloadArg.deploymentData,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
await apiClient.deployments.updateDeployment(payloadArg.deploymentId, payloadArg.deploymentData);
|
|
|
|
|
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
@@ -449,15 +386,8 @@ export const updateDeploymentAction = dataState.createAction(
|
|
|
|
|
export const deleteDeploymentAction = dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { deploymentId: string }) => {
|
|
|
|
|
let currentState = statePartArg.getState();
|
|
|
|
|
const trDeleteDeployment =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.deployment.IReq_Any_Cloudly_DeleteDeploymentById>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'deleteDeploymentById'
|
|
|
|
|
);
|
|
|
|
|
const response = await trDeleteDeployment.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
deploymentId: payloadArg.deploymentId,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
await apiClient.deployments.deleteDeployment(payloadArg.deploymentId);
|
|
|
|
|
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
@@ -467,15 +397,8 @@ export const deleteDeploymentAction = dataState.createAction(
|
|
|
|
|
export const createDnsEntryAction = dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { dnsEntryData: plugins.interfaces.data.IDnsEntry['data'] }) => {
|
|
|
|
|
let currentState = statePartArg.getState();
|
|
|
|
|
const trCreateDnsEntry =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.dns.IRequest_Any_Cloudly_CreateDnsEntry>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'createDnsEntry'
|
|
|
|
|
);
|
|
|
|
|
const response = await trCreateDnsEntry.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
dnsEntryData: payloadArg.dnsEntryData,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
await apiClient.dns.createDnsEntry(payloadArg.dnsEntryData);
|
|
|
|
|
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
@@ -484,16 +407,8 @@ export const createDnsEntryAction = dataState.createAction(
|
|
|
|
|
export const updateDnsEntryAction = dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { dnsEntryId: string; dnsEntryData: plugins.interfaces.data.IDnsEntry['data'] }) => {
|
|
|
|
|
let currentState = statePartArg.getState();
|
|
|
|
|
const trUpdateDnsEntry =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.dns.IRequest_Any_Cloudly_UpdateDnsEntry>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'updateDnsEntry'
|
|
|
|
|
);
|
|
|
|
|
const response = await trUpdateDnsEntry.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
dnsEntryId: payloadArg.dnsEntryId,
|
|
|
|
|
dnsEntryData: payloadArg.dnsEntryData,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
await apiClient.dns.updateDnsEntry(payloadArg.dnsEntryId, payloadArg.dnsEntryData);
|
|
|
|
|
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
@@ -502,15 +417,8 @@ export const updateDnsEntryAction = dataState.createAction(
|
|
|
|
|
export const deleteDnsEntryAction = dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { dnsEntryId: string }) => {
|
|
|
|
|
let currentState = statePartArg.getState();
|
|
|
|
|
const trDeleteDnsEntry =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.dns.IRequest_Any_Cloudly_DeleteDnsEntry>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'deleteDnsEntry'
|
|
|
|
|
);
|
|
|
|
|
const response = await trDeleteDnsEntry.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
dnsEntryId: payloadArg.dnsEntryId,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
await apiClient.dns.deleteDnsEntry(payloadArg.dnsEntryId);
|
|
|
|
|
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
@@ -520,15 +428,8 @@ export const deleteDnsEntryAction = dataState.createAction(
|
|
|
|
|
export const createDomainAction = dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { domainData: plugins.interfaces.data.IDomain['data'] }) => {
|
|
|
|
|
let currentState = statePartArg.getState();
|
|
|
|
|
const trCreateDomain =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.domain.IRequest_Any_Cloudly_CreateDomain>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'createDomain'
|
|
|
|
|
);
|
|
|
|
|
const response = await trCreateDomain.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
domainData: payloadArg.domainData,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
await apiClient.domains.createDomain(payloadArg.domainData);
|
|
|
|
|
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
@@ -537,16 +438,8 @@ export const createDomainAction = dataState.createAction(
|
|
|
|
|
export const updateDomainAction = dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { domainId: string; domainData: plugins.interfaces.data.IDomain['data'] }) => {
|
|
|
|
|
let currentState = statePartArg.getState();
|
|
|
|
|
const trUpdateDomain =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.domain.IRequest_Any_Cloudly_UpdateDomain>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'updateDomain'
|
|
|
|
|
);
|
|
|
|
|
const response = await trUpdateDomain.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
domainId: payloadArg.domainId,
|
|
|
|
|
domainData: payloadArg.domainData,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
await apiClient.domains.updateDomain(payloadArg.domainId, payloadArg.domainData);
|
|
|
|
|
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
@@ -555,15 +448,8 @@ export const updateDomainAction = dataState.createAction(
|
|
|
|
|
export const deleteDomainAction = dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { domainId: string }) => {
|
|
|
|
|
let currentState = statePartArg.getState();
|
|
|
|
|
const trDeleteDomain =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.domain.IRequest_Any_Cloudly_DeleteDomain>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'deleteDomain'
|
|
|
|
|
);
|
|
|
|
|
const response = await trDeleteDomain.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
domainId: payloadArg.domainId,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
await apiClient.domains.deleteDomain(payloadArg.domainId);
|
|
|
|
|
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
@@ -572,16 +458,8 @@ export const deleteDomainAction = dataState.createAction(
|
|
|
|
|
export const verifyDomainAction = dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { domainId: string; verificationMethod?: 'dns' | 'http' | 'email' | 'manual' }) => {
|
|
|
|
|
let currentState = statePartArg.getState();
|
|
|
|
|
const trVerifyDomain =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.domain.IRequest_Any_Cloudly_VerifyDomain>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'verifyDomain'
|
|
|
|
|
);
|
|
|
|
|
const response = await trVerifyDomain.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
domainId: payloadArg.domainId,
|
|
|
|
|
verificationMethod: payloadArg.verificationMethod,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
await apiClient.domains.verifyDomain(payloadArg.domainId, payloadArg.verificationMethod);
|
|
|
|
|
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
@@ -591,15 +469,8 @@ export const verifyDomainAction = dataState.createAction(
|
|
|
|
|
export const createExternalRegistryAction = dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { registryData: plugins.interfaces.data.IExternalRegistry['data'] }) => {
|
|
|
|
|
let currentState = statePartArg.getState();
|
|
|
|
|
const trCreateRegistry =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.externalRegistry.IReq_CreateRegistry>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'createExternalRegistry'
|
|
|
|
|
);
|
|
|
|
|
const response = await trCreateRegistry.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
registryData: payloadArg.registryData,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
await apiClient.externalRegistry.createRegistry(payloadArg.registryData);
|
|
|
|
|
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
@@ -608,17 +479,17 @@ export const createExternalRegistryAction = dataState.createAction(
|
|
|
|
|
export const updateExternalRegistryAction = dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { registryId: string; registryData: plugins.interfaces.data.IExternalRegistry['data'] }) => {
|
|
|
|
|
let currentState = statePartArg.getState();
|
|
|
|
|
const trUpdateRegistry =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.externalRegistry.IReq_UpdateRegistry>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'updateExternalRegistry'
|
|
|
|
|
);
|
|
|
|
|
const response = await trUpdateRegistry.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
registryId: payloadArg.registryId,
|
|
|
|
|
registryData: payloadArg.registryData,
|
|
|
|
|
});
|
|
|
|
|
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
|
|
|
|
try {
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
const reg = (currentState.externalRegistries as any[])?.find(r => r.id === payloadArg.registryId);
|
|
|
|
|
if (reg) {
|
|
|
|
|
reg.data = payloadArg.registryData;
|
|
|
|
|
await reg.update();
|
|
|
|
|
}
|
|
|
|
|
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error('Failed to update external registry:', err);
|
|
|
|
|
}
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
@@ -626,16 +497,16 @@ export const updateExternalRegistryAction = dataState.createAction(
|
|
|
|
|
export const deleteExternalRegistryAction = dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { registryId: string }) => {
|
|
|
|
|
let currentState = statePartArg.getState();
|
|
|
|
|
const trDeleteRegistry =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.externalRegistry.IReq_DeleteRegistryById>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'deleteExternalRegistryById'
|
|
|
|
|
);
|
|
|
|
|
const response = await trDeleteRegistry.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
registryId: payloadArg.registryId,
|
|
|
|
|
});
|
|
|
|
|
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
|
|
|
|
try {
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
const reg = (currentState.externalRegistries as any[])?.find(r => r.id === payloadArg.registryId);
|
|
|
|
|
if (reg) {
|
|
|
|
|
await reg.delete(apiClient as any, reg.id);
|
|
|
|
|
}
|
|
|
|
|
currentState = await dataState.dispatchAction(getAllDataAction, null);
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error('Failed to delete external registry:', err);
|
|
|
|
|
}
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
@@ -643,26 +514,27 @@ export const deleteExternalRegistryAction = dataState.createAction(
|
|
|
|
|
export const verifyExternalRegistryAction = dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { registryId: string }) => {
|
|
|
|
|
let currentState = statePartArg.getState();
|
|
|
|
|
const trVerifyRegistry =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.externalRegistry.IReq_VerifyRegistry>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'verifyExternalRegistry'
|
|
|
|
|
);
|
|
|
|
|
const response = await trVerifyRegistry.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
registryId: payloadArg.registryId,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (response.success && response.registry) {
|
|
|
|
|
// Update the registry in the state with the verified status
|
|
|
|
|
currentState = {
|
|
|
|
|
...currentState,
|
|
|
|
|
externalRegistries: currentState.externalRegistries?.map(reg =>
|
|
|
|
|
reg.id === payloadArg.registryId ? response.registry : reg
|
|
|
|
|
) || [],
|
|
|
|
|
};
|
|
|
|
|
try {
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
const result = await apiClient.externalRegistry.verifyRegistry(payloadArg.registryId);
|
|
|
|
|
if (result.success && result.registry) {
|
|
|
|
|
const regs = (currentState.externalRegistries || []).slice();
|
|
|
|
|
const idx = regs.findIndex(r => r.id === payloadArg.registryId);
|
|
|
|
|
if (idx >= 0) {
|
|
|
|
|
// Preserve instance; update its data + shallow props
|
|
|
|
|
const instance: any = regs[idx];
|
|
|
|
|
instance.data = result.registry.data;
|
|
|
|
|
instance.id = result.registry.id;
|
|
|
|
|
regs[idx] = instance;
|
|
|
|
|
}
|
|
|
|
|
currentState = {
|
|
|
|
|
...currentState,
|
|
|
|
|
externalRegistries: regs,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error('Failed to verify external registry:', err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
@@ -672,14 +544,8 @@ export const taskActions = {
|
|
|
|
|
getTasks: dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: {}) => {
|
|
|
|
|
const currentState = statePartArg.getState();
|
|
|
|
|
const trGetTasks =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.task.IRequest_Any_Cloudly_GetTasks>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'getTasks'
|
|
|
|
|
);
|
|
|
|
|
const response = await trGetTasks.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
const response = await apiClient.tasks.getTasks();
|
|
|
|
|
return {
|
|
|
|
|
...currentState,
|
|
|
|
|
tasks: response.tasks,
|
|
|
|
@@ -690,15 +556,8 @@ export const taskActions = {
|
|
|
|
|
getTaskExecutions: dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { filter?: any }) => {
|
|
|
|
|
const currentState = statePartArg.getState();
|
|
|
|
|
const trGetTaskExecutions =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.task.IRequest_Any_Cloudly_GetTaskExecutions>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'getTaskExecutions'
|
|
|
|
|
);
|
|
|
|
|
const response = await trGetTaskExecutions.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
filter: payloadArg.filter,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
const response = await apiClient.tasks.getTaskExecutions(payloadArg.filter);
|
|
|
|
|
return {
|
|
|
|
|
...currentState,
|
|
|
|
|
taskExecutions: response.executions,
|
|
|
|
@@ -709,15 +568,8 @@ export const taskActions = {
|
|
|
|
|
getTaskExecutionById: dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { executionId: string }) => {
|
|
|
|
|
const currentState = statePartArg.getState();
|
|
|
|
|
const trGetTaskExecutionById =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.task.IRequest_Any_Cloudly_GetTaskExecutionById>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'getTaskExecutionById'
|
|
|
|
|
);
|
|
|
|
|
const response = await trGetTaskExecutionById.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
executionId: payloadArg.executionId,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
await apiClient.tasks.getTaskExecutionById(payloadArg.executionId);
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
|
),
|
|
|
|
@@ -725,16 +577,8 @@ export const taskActions = {
|
|
|
|
|
triggerTask: dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { taskName: string; userId?: string }) => {
|
|
|
|
|
const currentState = statePartArg.getState();
|
|
|
|
|
const trTriggerTask =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.task.IRequest_Any_Cloudly_TriggerTask>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'triggerTask'
|
|
|
|
|
);
|
|
|
|
|
const response = await trTriggerTask.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
taskName: payloadArg.taskName,
|
|
|
|
|
userId: payloadArg.userId,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
await apiClient.tasks.triggerTask(payloadArg.taskName, payloadArg.userId);
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
|
),
|
|
|
|
@@ -742,15 +586,8 @@ export const taskActions = {
|
|
|
|
|
cancelTask: dataState.createAction(
|
|
|
|
|
async (statePartArg, payloadArg: { executionId: string }) => {
|
|
|
|
|
const currentState = statePartArg.getState();
|
|
|
|
|
const trCancelTask =
|
|
|
|
|
new domtools.plugins.typedrequest.TypedRequest<plugins.interfaces.requests.task.IRequest_Any_Cloudly_CancelTask>(
|
|
|
|
|
'/typedrequest',
|
|
|
|
|
'cancelTask'
|
|
|
|
|
);
|
|
|
|
|
const response = await trCancelTask.fire({
|
|
|
|
|
identity: loginStatePart.getState().identity,
|
|
|
|
|
executionId: payloadArg.executionId,
|
|
|
|
|
});
|
|
|
|
|
apiClient.identity = loginStatePart.getState().identity;
|
|
|
|
|
await apiClient.tasks.cancelTask(payloadArg.executionId);
|
|
|
|
|
return currentState;
|
|
|
|
|
}
|
|
|
|
|
),
|
|
|
|
|