style: auto format whole project

This commit is contained in:
Ali BARIN
2022-11-05 23:57:33 +01:00
parent e338770e57
commit 475f24f661
199 changed files with 2421 additions and 1839 deletions

View File

@@ -7,7 +7,10 @@ enum AuthenticationSteps {
OpenWithPopup = 'openWithPopup',
}
const processMutation = async (step: IAuthenticationStep, variables: IJSONObject) => {
const processMutation = async (
step: IAuthenticationStep,
variables: IJSONObject
) => {
const mutation = MUTATIONS[step.name];
const mutationResponse = await apolloClient.mutate({
mutation,
@@ -37,12 +40,20 @@ function getObjectOfEntries(iterator: any) {
return result;
}
const processOpenWithPopup = (step: IAuthenticationStep, variables: IJSONObject) => {
const processOpenWithPopup = (
step: IAuthenticationStep,
variables: IJSONObject
) => {
return new Promise((resolve, reject) => {
const windowFeatures = 'toolbar=no, titlebar=no, menubar=no, width=500, height=700, top=100, left=100';
const windowFeatures =
'toolbar=no, titlebar=no, menubar=no, width=500, height=700, top=100, left=100';
const url = variables.url;
const popup = window.open(url as string, '_blank', windowFeatures) as WindowProxy;
const popup = window.open(
url as string,
'_blank',
windowFeatures
) as WindowProxy;
popup?.focus();
const closeCheckIntervalId = setInterval(() => {
@@ -50,7 +61,7 @@ const processOpenWithPopup = (step: IAuthenticationStep, variables: IJSONObject)
clearInterval(closeCheckIntervalId);
reject({ message: 'Error occured while verifying credentials!' });
}
}, 1000)
}, 1000);
const messageHandler = async (event: MessageEvent) => {
if (event.data.source !== 'automatisch') {
@@ -68,7 +79,10 @@ const processOpenWithPopup = (step: IAuthenticationStep, variables: IJSONObject)
});
};
export const processStep = async (step: IAuthenticationStep, variables: IJSONObject): Promise<any> => {
export const processStep = async (
step: IAuthenticationStep,
variables: IJSONObject
): Promise<any> => {
if (step.type === AuthenticationSteps.Mutation) {
return processMutation(step, variables);
} else if (step.type === AuthenticationSteps.OpenWithPopup) {

View File

@@ -4,23 +4,32 @@ import type { IAuthenticationStepField, IJSONObject } from '@automatisch/types';
const interpolate = /{([\s\S]+?)}/g;
type Variables = {
[key: string]: any
}
[key: string]: any;
};
type IVariable = Omit<IAuthenticationStepField, "properties"> & Partial<Pick<IAuthenticationStepField, "properties">>;
type IVariable = Omit<IAuthenticationStepField, 'properties'> &
Partial<Pick<IAuthenticationStepField, 'properties'>>;
const computeAuthStepVariables = (variableSchema: IVariable[], aggregatedData: IJSONObject): IJSONObject => {
const computeAuthStepVariables = (
variableSchema: IVariable[],
aggregatedData: IJSONObject
): IJSONObject => {
const variables: Variables = {};
for (const variable of variableSchema) {
if (variable.properties) {
variables[variable.name] = computeAuthStepVariables(variable.properties, aggregatedData);
variables[variable.name] = computeAuthStepVariables(
variable.properties,
aggregatedData
);
continue;
}
if (variable.value) {
const computedVariable = template(variable.value, { interpolate })(aggregatedData);
const computedVariable = template(variable.value, { interpolate })(
aggregatedData
);
variables[variable.name] = computedVariable;
}

View File

@@ -4,23 +4,32 @@ import type { IAuthenticationStepField, IJSONObject } from '@automatisch/types';
const interpolate = /{([\s\S]+?)}/g;
type Variables = {
[key: string]: any
}
[key: string]: any;
};
type IVariable = Omit<IAuthenticationStepField, "properties"> & Partial<Pick<IAuthenticationStepField, "properties">>;
type IVariable = Omit<IAuthenticationStepField, 'properties'> &
Partial<Pick<IAuthenticationStepField, 'properties'>>;
const computeAuthStepVariables = (variableSchema: IVariable[], aggregatedData: IJSONObject): IJSONObject => {
const computeAuthStepVariables = (
variableSchema: IVariable[],
aggregatedData: IJSONObject
): IJSONObject => {
const variables: Variables = {};
for (const variable of variableSchema) {
if (variable.properties) {
variables[variable.name] = computeAuthStepVariables(variable.properties, aggregatedData);
variables[variable.name] = computeAuthStepVariables(
variable.properties,
aggregatedData
);
continue;
}
if (variable.value) {
const computedVariable = template(variable.value, { interpolate })(aggregatedData);
const computedVariable = template(variable.value, { interpolate })(
aggregatedData
);
variables[variable.name] = computedVariable;
}

View File

@@ -2,4 +2,4 @@ import copy from 'clipboard-copy';
export default function copyInputValue(element: HTMLInputElement): void {
copy(element.value);
};
}

View File

@@ -7,4 +7,4 @@ export const setItem = (key: string, value: string) => {
export const getItem = (key: string) => {
return localStorage.getItem(makeKey(key));
}
};