diff --git a/packages/backend/src/apps/twitter2/triggers/my-tweets/index.ts b/packages/backend/src/apps/twitter2/triggers/my-tweets/index.ts index 55cc9dbc..33ad3c4f 100644 --- a/packages/backend/src/apps/twitter2/triggers/my-tweets/index.ts +++ b/packages/backend/src/apps/twitter2/triggers/my-tweets/index.ts @@ -1,4 +1,4 @@ -import { IGlobalVariableForConnection } from '@automatisch/types'; +import { IGlobalVariable } from '@automatisch/types'; import getCurrentUser from '../../common/get-current-user'; import getUserByUsername from '../../common/get-user-by-username'; import getUserTweets from '../../common/get-user-tweets'; @@ -19,15 +19,15 @@ export default { }, ], - async run($: IGlobalVariableForConnection) { + async run($: IGlobalVariable) { return this.getTweets($, await $.db.flow.lastInternalId()); }, - async testRun($: IGlobalVariableForConnection) { + async testRun($: IGlobalVariable) { return this.getTweets($); }, - async getTweets($: IGlobalVariableForConnection, lastInternalId?: string) { + async getTweets($: IGlobalVariable, lastInternalId?: string) { const { username } = await getCurrentUser($); const user = await getUserByUsername($, username); diff --git a/packages/backend/src/graphql/mutations/create-auth-data.ts b/packages/backend/src/graphql/mutations/create-auth-data.ts index 2ce1aa65..6d0972ad 100644 --- a/packages/backend/src/graphql/mutations/create-auth-data.ts +++ b/packages/backend/src/graphql/mutations/create-auth-data.ts @@ -1,6 +1,6 @@ import Context from '../../types/express/context'; import axios from 'axios'; -import prepareGlobalVariableForConnection from '../../helpers/global-variable/connection'; +import globalVariable from '../../helpers/global-variable'; import App from '../../models/app'; type Params = { @@ -29,7 +29,7 @@ const createAuthData = async ( .default; const app = App.findOneByKey(connection.key); - const $ = prepareGlobalVariableForConnection(connection, app); + const $ = globalVariable(connection, app); await authInstance.createAuthData($); try { diff --git a/packages/backend/src/graphql/mutations/update-step.ts b/packages/backend/src/graphql/mutations/update-step.ts index 45fd1295..0c5adbed 100644 --- a/packages/backend/src/graphql/mutations/update-step.ts +++ b/packages/backend/src/graphql/mutations/update-step.ts @@ -1,3 +1,4 @@ +import { IJSONObject } from '@automatisch/types'; import Step from '../../models/step'; import Context from '../../types/express/context'; @@ -6,7 +7,7 @@ type Params = { id: string; key: string; appKey: string; - parameters: Record; + parameters: IJSONObject; flow: { id: string; }; diff --git a/packages/backend/src/graphql/mutations/verify-connection.ts b/packages/backend/src/graphql/mutations/verify-connection.ts index a73c6cc9..358afd3e 100644 --- a/packages/backend/src/graphql/mutations/verify-connection.ts +++ b/packages/backend/src/graphql/mutations/verify-connection.ts @@ -1,6 +1,6 @@ import Context from '../../types/express/context'; import App from '../../models/app'; -import prepareGlobalVariableForConnection from '../../helpers/global-variable/connection'; +import globalVariable from '../../helpers/global-variable'; type Params = { input: { @@ -24,7 +24,7 @@ const verifyConnection = async ( const authInstance = (await import(`../../apps/${connection.key}2/auth`)) .default; - const $ = prepareGlobalVariableForConnection(connection, app); + const $ = globalVariable(connection, app); await authInstance.verifyCredentials($); connection = await connection.$query().patchAndFetch({ diff --git a/packages/backend/src/helpers/global-variable/connection.ts b/packages/backend/src/helpers/global-variable.ts similarity index 56% rename from packages/backend/src/helpers/global-variable/connection.ts rename to packages/backend/src/helpers/global-variable.ts index 6913592d..54ea59c7 100644 --- a/packages/backend/src/helpers/global-variable/connection.ts +++ b/packages/backend/src/helpers/global-variable.ts @@ -1,17 +1,13 @@ -import createHttpClient from '../http-client'; -import Connection from '../../models/connection'; -import Flow from '../../models/flow'; -import { - IJSONObject, - IApp, - IGlobalVariableForConnection, -} from '@automatisch/types'; +import createHttpClient from './http-client'; +import Connection from '../models/connection'; +import Flow from '../models/flow'; +import { IJSONObject, IApp, IGlobalVariable } from '@automatisch/types'; -const prepareGlobalVariableForConnection = ( +const globalVariable = ( connection: Connection, appData: IApp, flow?: Flow -): IGlobalVariableForConnection => { +): IGlobalVariable => { return { auth: { set: async (args: IJSONObject) => { @@ -32,4 +28,4 @@ const prepareGlobalVariableForConnection = ( }; }; -export default prepareGlobalVariableForConnection; +export default globalVariable; diff --git a/packages/backend/src/models/step.ts b/packages/backend/src/models/step.ts index dcd9d58d..70662981 100644 --- a/packages/backend/src/models/step.ts +++ b/packages/backend/src/models/step.ts @@ -4,7 +4,7 @@ import App from './app'; import Flow from './flow'; import Connection from './connection'; import ExecutionStep from './execution-step'; -import type { IStep } from '@automatisch/types'; +import type { IJSONObject, IStep } from '@automatisch/types'; import Telemetry from '../helpers/telemetry'; import appConfig from '../config/app'; @@ -17,7 +17,7 @@ class Step extends Base { connectionId?: string; status = 'incomplete'; position!: number; - parameters: Record; + parameters: IJSONObject; connection?: Connection; flow: Flow; executionSteps: ExecutionStep[]; diff --git a/packages/types/index.d.ts b/packages/types/index.d.ts index b9cb17ba..495b244e 100644 --- a/packages/types/index.d.ts +++ b/packages/types/index.d.ts @@ -56,7 +56,7 @@ export interface IStep { connectionId?: string; status: string; position: number; - parameters: Record; + parameters: IJSONObject; connection?: Partial; flow: IFlow; executionSteps: IExecutionStep[]; @@ -195,7 +195,7 @@ export type IHttpClientParams = { baseURL?: string; }; -export type IGlobalVariableForConnection = { +export type IGlobalVariable = { auth: { set: (args: IJSONObject) => Promise; data: IJSONObject;