feat: add defineTrigger and defineAction
This commit is contained in:
@@ -9,10 +9,14 @@ const appInfoConverter = (rawAppData: IApp) => {
|
||||
|
||||
if (rawAppData.auth?.fields) {
|
||||
rawAppData.auth.fields = rawAppData.auth.fields.map((field) => {
|
||||
return {
|
||||
...field,
|
||||
value: field.value?.replace('{WEB_APP_URL}', appConfig.webAppUrl),
|
||||
};
|
||||
if (typeof field.value === 'string') {
|
||||
return {
|
||||
...field,
|
||||
value: field.value.replace('{WEB_APP_URL}', appConfig.webAppUrl),
|
||||
};
|
||||
}
|
||||
|
||||
return field
|
||||
});
|
||||
}
|
||||
|
||||
|
5
packages/backend/src/helpers/define-action.ts
Normal file
5
packages/backend/src/helpers/define-action.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { IAction } from '@automatisch/types';
|
||||
|
||||
export default function defineAction(actionDefinition: IAction): IAction {
|
||||
return actionDefinition;
|
||||
}
|
5
packages/backend/src/helpers/define-trigger.ts
Normal file
5
packages/backend/src/helpers/define-trigger.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { ITrigger } from '@automatisch/types';
|
||||
|
||||
export default function defineTrigger(triggerDefinition: ITrigger): ITrigger {
|
||||
return triggerDefinition;
|
||||
}
|
@@ -16,17 +16,13 @@ async function getFileContent<C>(
|
||||
path: string,
|
||||
stripFuncs: boolean
|
||||
): Promise<C> {
|
||||
try {
|
||||
const fileContent = await getDefaultExport(path);
|
||||
const fileContent = await getDefaultExport(path);
|
||||
|
||||
if (stripFuncs) {
|
||||
return stripFunctions(fileContent);
|
||||
}
|
||||
|
||||
return fileContent;
|
||||
} catch (err) {
|
||||
return null;
|
||||
if (stripFuncs) {
|
||||
return stripFunctions(fileContent);
|
||||
}
|
||||
|
||||
return fileContent;
|
||||
}
|
||||
|
||||
async function getChildrenContentInDirectory<C>(
|
||||
@@ -55,10 +51,12 @@ async function getChildrenContentInDirectory<C>(
|
||||
const getApp = async (appKey: string, stripFuncs = true) => {
|
||||
const appData: IApp = await getDefaultExport(`../apps/${appKey}`);
|
||||
|
||||
appData.auth = await getFileContent<IAuth>(
|
||||
`../apps/${appKey}/auth`,
|
||||
stripFuncs
|
||||
);
|
||||
if (appData.supportsConnections) {
|
||||
appData.auth = await getFileContent<IAuth>(
|
||||
`../apps/${appKey}/auth`,
|
||||
stripFuncs
|
||||
);
|
||||
}
|
||||
appData.triggers = await getChildrenContentInDirectory<ITrigger>(
|
||||
`${appKey}/triggers`,
|
||||
stripFuncs
|
||||
|
Reference in New Issue
Block a user