Add frontend, backend and CLI

This commit is contained in:
Maidul Islam
2022-11-17 17:54:35 -05:00
parent 8d00c5cdb7
commit bea0ff6e05
276 changed files with 50230 additions and 72 deletions
@@ -0,0 +1,24 @@
import SecurityClient from "../../../components/utilities/SecurityClient";
import { PATH } from "../../../const";
const changeHerokuConfigVars = ({ integrationId, key, secrets }) => {
return SecurityClient.fetchCall(PATH + "/api/v1/integration/" + integrationId + "/sync", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
key,
secrets,
})
})
.then(async res => {
if (res.status == 200) {
return res;
} else {
console.log('Failed to sync secrets to Heroku');
}
})
};
export default changeHerokuConfigVars;
@@ -0,0 +1,25 @@
import SecurityClient from "../../../components/utilities/SecurityClient";
import { PATH } from "../../../const";
/**
* This route deletes an integration from a certain project
* @param {*} integrationId
* @returns
*/
const deleteIntegration = ({ integrationId }) => {
return SecurityClient.fetchCall(PATH + "/api/v1/integration/" + integrationId, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
})
.then(async res => {
if (res.status == 200) {
return (await res.json()).workspace;
} else {
console.log('Failed to delete an integration');
}
})
};
export default deleteIntegration;
@@ -0,0 +1,25 @@
import SecurityClient from "../../../components/utilities/SecurityClient";
import { PATH } from "../../../const";
/**
* This route deletes an integration authorization from a certain project
* @param {*} integrationAuthId
* @returns
*/
const deleteIntegrationAuth = ({ integrationAuthId }) => {
return SecurityClient.fetchCall(PATH + "/api/v1/integration-auth/" + integrationAuthId, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
})
.then(async res => {
if (res.status == 200) {
return res;
} else {
console.log('Failed to delete an integration authorization');
}
})
};
export default deleteIntegrationAuth;
@@ -0,0 +1,20 @@
import SecurityClient from "../../../components/utilities/SecurityClient";
import { PATH } from "../../../const";
const getIntegrationApps = ({ integrationAuthId }) => {
return SecurityClient.fetchCall(PATH + "/api/v1/integration-auth/" + integrationAuthId + "/apps", {
method: "GET",
headers: {
"Content-Type": "application/json",
},
})
.then(async res => {
if (res.status == 200) {
return (await res.json()).apps;
} else {
console.log('Failed to get available apps for an integration');
}
})
};
export default getIntegrationApps;
@@ -0,0 +1,20 @@
import SecurityClient from "../../../components/utilities/SecurityClient";
import { PATH } from "../../../const";
const getIntegrations = () => {
return SecurityClient.fetchCall(PATH + "/api/v1/integration/integrations", {
method: "GET",
headers: {
"Content-Type": "application/json",
},
})
.then(async res => {
if (res.status == 200) {
return (await res.json()).integrations;
} else {
console.log('Failed to get project integrations');
}
})
};
export default getIntegrations;
@@ -0,0 +1,32 @@
import SecurityClient from "../../../components/utilities/SecurityClient";
import { PATH } from "../../../const";
/**
* This route starts the integration after teh default one if gonna set up.
* @param {*} integrationId
* @returns
*/
const startIntegration = ({ integrationId, appName, environment }) => {
return SecurityClient.fetchCall(PATH + "/api/v1/integration/" + integrationId, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
"update": {
app: appName,
environment,
isActive: true
}
})
})
.then(async res => {
if (res.status == 200) {
return res;
} else {
console.log('Failed to start an integration');
}
})
};
export default startIntegration;
@@ -0,0 +1,30 @@
import SecurityClient from "../../../components/utilities/SecurityClient";
import { PATH } from "../../../const";
/**
* This is the first step of the change password process (pake)
* @param {*} clientPublicKey
* @returns
*/
const AuthorizeIntegration = ({ workspaceId, code, integration }) => {
return SecurityClient.fetchCall(PATH + "/api/v1/integration-auth/oauth-token", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
workspaceId,
code,
integration
}),
})
.then(async res => {
if (res.status == 200) {
return res;
} else {
console.log('Failed to authorize the integration');
}
})
};
export default AuthorizeIntegration;
@@ -0,0 +1,25 @@
import SecurityClient from "../../../components/utilities/SecurityClient";
import { PATH } from "../../../const";
/**
* This route gets authorizations of a certain project (Heroku, etc.)
* @param {*} workspaceId
* @returns
*/
const getWorkspaceAuthorizations = ({ workspaceId }) => {
return SecurityClient.fetchCall(PATH + "/api/v1/workspace/" + workspaceId + "/authorizations", {
method: "GET",
headers: {
"Content-Type": "application/json",
},
})
.then(async res => {
if (res.status == 200) {
return (await res.json()).authorizations;
} else {
console.log('Failed to get project authorizations');
}
})
};
export default getWorkspaceAuthorizations;
@@ -0,0 +1,25 @@
import SecurityClient from "../../../components/utilities/SecurityClient";
import { PATH } from "../../../const";
/**
* This route gets integrations of a certain project (Heroku, etc.)
* @param {*} workspaceId
* @returns
*/
const getWorkspaceIntegrations = ({ workspaceId }) => {
return SecurityClient.fetchCall(PATH + "/api/v1/workspace/" + workspaceId + "/integrations", {
method: "GET",
headers: {
"Content-Type": "application/json",
},
})
.then(async res => {
if (res.status == 200) {
return (await res.json()).integrations;
} else {
console.log('Failed to get the project integrations');
}
})
};
export default getWorkspaceIntegrations;