fix: Type problems regarding global variable
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { IGlobalVariableForConnection } from '@automatisch/types';
|
import { IGlobalVariable } from '@automatisch/types';
|
||||||
import getCurrentUser from '../../common/get-current-user';
|
import getCurrentUser from '../../common/get-current-user';
|
||||||
import getUserByUsername from '../../common/get-user-by-username';
|
import getUserByUsername from '../../common/get-user-by-username';
|
||||||
import getUserTweets from '../../common/get-user-tweets';
|
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());
|
return this.getTweets($, await $.db.flow.lastInternalId());
|
||||||
},
|
},
|
||||||
|
|
||||||
async testRun($: IGlobalVariableForConnection) {
|
async testRun($: IGlobalVariable) {
|
||||||
return this.getTweets($);
|
return this.getTweets($);
|
||||||
},
|
},
|
||||||
|
|
||||||
async getTweets($: IGlobalVariableForConnection, lastInternalId?: string) {
|
async getTweets($: IGlobalVariable, lastInternalId?: string) {
|
||||||
const { username } = await getCurrentUser($);
|
const { username } = await getCurrentUser($);
|
||||||
const user = await getUserByUsername($, username);
|
const user = await getUserByUsername($, username);
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import Context from '../../types/express/context';
|
import Context from '../../types/express/context';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import prepareGlobalVariableForConnection from '../../helpers/global-variable/connection';
|
import globalVariable from '../../helpers/global-variable';
|
||||||
import App from '../../models/app';
|
import App from '../../models/app';
|
||||||
|
|
||||||
type Params = {
|
type Params = {
|
||||||
@@ -29,7 +29,7 @@ const createAuthData = async (
|
|||||||
.default;
|
.default;
|
||||||
const app = App.findOneByKey(connection.key);
|
const app = App.findOneByKey(connection.key);
|
||||||
|
|
||||||
const $ = prepareGlobalVariableForConnection(connection, app);
|
const $ = globalVariable(connection, app);
|
||||||
await authInstance.createAuthData($);
|
await authInstance.createAuthData($);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
import { IJSONObject } from '@automatisch/types';
|
||||||
import Step from '../../models/step';
|
import Step from '../../models/step';
|
||||||
import Context from '../../types/express/context';
|
import Context from '../../types/express/context';
|
||||||
|
|
||||||
@@ -6,7 +7,7 @@ type Params = {
|
|||||||
id: string;
|
id: string;
|
||||||
key: string;
|
key: string;
|
||||||
appKey: string;
|
appKey: string;
|
||||||
parameters: Record<string, unknown>;
|
parameters: IJSONObject;
|
||||||
flow: {
|
flow: {
|
||||||
id: string;
|
id: string;
|
||||||
};
|
};
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import Context from '../../types/express/context';
|
import Context from '../../types/express/context';
|
||||||
import App from '../../models/app';
|
import App from '../../models/app';
|
||||||
import prepareGlobalVariableForConnection from '../../helpers/global-variable/connection';
|
import globalVariable from '../../helpers/global-variable';
|
||||||
|
|
||||||
type Params = {
|
type Params = {
|
||||||
input: {
|
input: {
|
||||||
@@ -24,7 +24,7 @@ const verifyConnection = async (
|
|||||||
const authInstance = (await import(`../../apps/${connection.key}2/auth`))
|
const authInstance = (await import(`../../apps/${connection.key}2/auth`))
|
||||||
.default;
|
.default;
|
||||||
|
|
||||||
const $ = prepareGlobalVariableForConnection(connection, app);
|
const $ = globalVariable(connection, app);
|
||||||
await authInstance.verifyCredentials($);
|
await authInstance.verifyCredentials($);
|
||||||
|
|
||||||
connection = await connection.$query().patchAndFetch({
|
connection = await connection.$query().patchAndFetch({
|
||||||
|
@@ -1,17 +1,13 @@
|
|||||||
import createHttpClient from '../http-client';
|
import createHttpClient from './http-client';
|
||||||
import Connection from '../../models/connection';
|
import Connection from '../models/connection';
|
||||||
import Flow from '../../models/flow';
|
import Flow from '../models/flow';
|
||||||
import {
|
import { IJSONObject, IApp, IGlobalVariable } from '@automatisch/types';
|
||||||
IJSONObject,
|
|
||||||
IApp,
|
|
||||||
IGlobalVariableForConnection,
|
|
||||||
} from '@automatisch/types';
|
|
||||||
|
|
||||||
const prepareGlobalVariableForConnection = (
|
const globalVariable = (
|
||||||
connection: Connection,
|
connection: Connection,
|
||||||
appData: IApp,
|
appData: IApp,
|
||||||
flow?: Flow
|
flow?: Flow
|
||||||
): IGlobalVariableForConnection => {
|
): IGlobalVariable => {
|
||||||
return {
|
return {
|
||||||
auth: {
|
auth: {
|
||||||
set: async (args: IJSONObject) => {
|
set: async (args: IJSONObject) => {
|
||||||
@@ -32,4 +28,4 @@ const prepareGlobalVariableForConnection = (
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default prepareGlobalVariableForConnection;
|
export default globalVariable;
|
@@ -4,7 +4,7 @@ import App from './app';
|
|||||||
import Flow from './flow';
|
import Flow from './flow';
|
||||||
import Connection from './connection';
|
import Connection from './connection';
|
||||||
import ExecutionStep from './execution-step';
|
import ExecutionStep from './execution-step';
|
||||||
import type { IStep } from '@automatisch/types';
|
import type { IJSONObject, IStep } from '@automatisch/types';
|
||||||
import Telemetry from '../helpers/telemetry';
|
import Telemetry from '../helpers/telemetry';
|
||||||
import appConfig from '../config/app';
|
import appConfig from '../config/app';
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ class Step extends Base {
|
|||||||
connectionId?: string;
|
connectionId?: string;
|
||||||
status = 'incomplete';
|
status = 'incomplete';
|
||||||
position!: number;
|
position!: number;
|
||||||
parameters: Record<string, unknown>;
|
parameters: IJSONObject;
|
||||||
connection?: Connection;
|
connection?: Connection;
|
||||||
flow: Flow;
|
flow: Flow;
|
||||||
executionSteps: ExecutionStep[];
|
executionSteps: ExecutionStep[];
|
||||||
|
4
packages/types/index.d.ts
vendored
4
packages/types/index.d.ts
vendored
@@ -56,7 +56,7 @@ export interface IStep {
|
|||||||
connectionId?: string;
|
connectionId?: string;
|
||||||
status: string;
|
status: string;
|
||||||
position: number;
|
position: number;
|
||||||
parameters: Record<string, unknown>;
|
parameters: IJSONObject;
|
||||||
connection?: Partial<IConnection>;
|
connection?: Partial<IConnection>;
|
||||||
flow: IFlow;
|
flow: IFlow;
|
||||||
executionSteps: IExecutionStep[];
|
executionSteps: IExecutionStep[];
|
||||||
@@ -195,7 +195,7 @@ export type IHttpClientParams = {
|
|||||||
baseURL?: string;
|
baseURL?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type IGlobalVariableForConnection = {
|
export type IGlobalVariable = {
|
||||||
auth: {
|
auth: {
|
||||||
set: (args: IJSONObject) => Promise<IConnection>;
|
set: (args: IJSONObject) => Promise<IConnection>;
|
||||||
data: IJSONObject;
|
data: IJSONObject;
|
||||||
|
Reference in New Issue
Block a user