From a9453806b8cc7aa35a65f4fda303b919a6a7519c Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Mon, 22 Jul 2019 20:29:06 +0200 Subject: [PATCH] :sparkles: Add support for PostgresDB and save date as Date --- packages/cli/README.md | 38 ++++++++++++- packages/cli/config/index.ts | 34 +++++++++++- packages/cli/package.json | 1 + packages/cli/src/Db.ts | 11 ++++ packages/cli/src/Interfaces.ts | 34 +++++++----- packages/cli/src/Server.ts | 10 ++-- packages/cli/src/databases/index.ts | 2 + .../databases/mongodb/CredentialsEntity.ts | 8 +-- .../src/databases/mongodb/ExecutionEntity.ts | 8 +-- .../src/databases/mongodb/WorkflowEntity.ts | 8 +-- .../databases/postgresdb/CredentialsEntity.ts | 44 +++++++++++++++ .../databases/postgresdb/ExecutionEntity.ts | 51 +++++++++++++++++ .../databases/postgresdb/WorkflowEntity.ts | 55 +++++++++++++++++++ .../cli/src/databases/postgresdb/index.ts | 3 + .../src/databases/sqlite/CredentialsEntity.ts | 4 +- .../src/databases/sqlite/ExecutionEntity.ts | 4 +- .../src/databases/sqlite/WorkflowEntity.ts | 4 +- packages/core/src/ActiveExecutions.ts | 2 +- packages/core/src/Interfaces.ts | 4 +- packages/core/src/LoadNodeParameterOptions.ts | 4 +- packages/core/src/WorkflowExecute.ts | 8 +-- packages/core/test/Credentials.test.ts | 2 +- packages/editor-ui/src/Interface.ts | 24 ++++---- .../src/components/ExecutionsList.vue | 8 +-- .../src/components/mixins/restApi.ts | 2 +- .../src/components/mixins/workflowRun.ts | 4 +- packages/workflow/src/Interfaces.ts | 6 +- 27 files changed, 310 insertions(+), 73 deletions(-) create mode 100644 packages/cli/src/databases/postgresdb/CredentialsEntity.ts create mode 100644 packages/cli/src/databases/postgresdb/ExecutionEntity.ts create mode 100644 packages/cli/src/databases/postgresdb/WorkflowEntity.ts create mode 100644 packages/cli/src/databases/postgresdb/index.ts diff --git a/packages/cli/README.md b/packages/cli/README.md index a9851e0963..c2c9cf95a1 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -68,11 +68,19 @@ n8n start --tunnel ``` -### Start with MongoDB as Database +### Start with other Database By default n8n uses SQLite to save credentials, past executions and workflows. -To use MongoDB instead you can provide the environment varialbles `DB_TYPE` and -`DB_MONGODB_CONNECTION_URL` like in the example bellow. +n8n however also supports MongoDB and PostgresDB. To use them simply a few +environment variables have to be set. + + +#### Start with MongoDB as Database + +To use MongoDB as database you can provide the following environment variables like +in the example bellow: + - `DB_TYPE=mongodb` + - `DB_MONGODB_CONNECTION_URL=` Replace the following placeholders with the actual data: - MONGO_DATABASE @@ -88,6 +96,30 @@ n8n start ``` +#### Start with PostgresDB as Database + +To use PostgresDB as database you can provide the following environment variables + - `DB_TYPE=postgresdb` + - `DB_POSTGRESDB_DATABASE` (default: 'n8n') + - `DB_POSTGRESDB_HOST` (default: 'localhost') + - `DB_POSTGRESDB_PORT` (default: 5432) + - `DB_POSTGRESDB_USER` (default: 'root') + - `DB_POSTGRESDB_PASSWORD` (default: empty) + + + +```bash +export DB_TYPE=postgresdb +export DB_POSTGRESDB_DATABASE=n8n +export DB_POSTGRESDB_HOST=postgresdb +export DB_POSTGRESDB_PORT=5432 +export DB_POSTGRESDB_USER=n8n +export DB_POSTGRESDB_PASSWORD=n8n + +n8n start +``` + + ## Execute Workflow from CLI Workflows can not just be started by triggers, webhooks or manually via the diff --git a/packages/cli/config/index.ts b/packages/cli/config/index.ts index 7f01b1ef36..64daf41455 100644 --- a/packages/cli/config/index.ts +++ b/packages/cli/config/index.ts @@ -8,7 +8,7 @@ const config = convict({ database: { type: { doc: 'Type of database to use', - format: ['sqlite', 'mongodb'], + format: ['sqlite', 'mongodb', 'postgresdb'], default: 'sqlite', env: 'DB_TYPE' }, @@ -20,6 +20,38 @@ const config = convict({ env: 'DB_MONGODB_CONNECTION_URL' } }, + postgresdb: { + database: { + doc: 'PostgresDB Database', + format: String, + default: 'n8n', + env: 'DB_POSTGRESDB_DATABASE' + }, + host: { + doc: 'PostgresDB Host', + format: String, + default: 'localhost', + env: 'DB_POSTGRESDB_HOST' + }, + password: { + doc: 'PostgresDB Password', + format: String, + default: '', + env: 'DB_POSTGRESDB_PASSWORD' + }, + port: { + doc: 'PostgresDB Port', + format: Number, + default: 5432, + env: 'DB_POSTGRESDB_PORT' + }, + user: { + doc: 'PostgresDB User', + format: String, + default: 'root', + env: 'DB_POSTGRESDB_USER' + }, + }, }, executions: { diff --git a/packages/cli/package.json b/packages/cli/package.json index 695fbe323b..7603430bc2 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -73,6 +73,7 @@ "n8n-nodes-base": "^0.7.0", "n8n-workflow": "^0.6.0", "open": "^6.1.0", + "pg": "^7.11.0", "request-promise-native": "^1.0.7", "sqlite3": "^4.0.6", "sse-channel": "^3.1.1", diff --git a/packages/cli/src/Db.ts b/packages/cli/src/Db.ts index 29f99a7f53..a51a92b675 100644 --- a/packages/cli/src/Db.ts +++ b/packages/cli/src/Db.ts @@ -18,6 +18,7 @@ import * as config from './../config'; import { MongoDb, + PostgresDb, SQLite, } from './databases'; @@ -43,6 +44,16 @@ export async function init(): Promise { url: config.get('database.mongodb.connectionUrl') as string, useNewUrlParser: true, }; + } else if (dbType === 'postgresdb') { + entities = PostgresDb; + connectionOptions = { + type: 'postgres', + database: config.get('database.postgresdb.database'), + host: config.get('database.postgresdb.host'), + password: config.get('database.postgresdb.password'), + port: config.get('database.postgresdb.port'), + username: config.get('database.postgresdb.user'), + }; } else if (dbType === 'sqlite') { entities = SQLite; connectionOptions = { diff --git a/packages/cli/src/Interfaces.ts b/packages/cli/src/Interfaces.ts index 239c684df7..7e2b25708c 100644 --- a/packages/cli/src/Interfaces.ts +++ b/packages/cli/src/Interfaces.ts @@ -41,8 +41,8 @@ export interface IWorkflowBase { id?: number | string | ObjectID; name: string; active: boolean; - createdAt: number | string; - updatedAt: number | string; + createdAt: Date; + updatedAt: Date; nodes: INode[]; connections: IConnections; settings?: IWorkflowSettings; @@ -63,13 +63,13 @@ export interface IWorkflowShortResponse { id: string; name: string; active: boolean; - createdAt: number | string; - updatedAt: number | string; + createdAt: Date; + updatedAt: Date; } export interface ICredentialsBase { - createdAt: number | string; - updatedAt: number | string; + createdAt: Date; + updatedAt: Date; } export interface ICredentialsDb extends ICredentialsBase, ICredentialsEncrypted{ @@ -88,14 +88,14 @@ export interface ICredentialsDecryptedResponse extends ICredentialsDecryptedDb { id: string; } -export type DatabaseType = 'mongodb' | 'sqlite'; +export type DatabaseType = 'mongodb' | 'postgresdb' | 'sqlite'; export type SaveExecutionDataType = 'all' | 'none'; export interface IExecutionBase { id?: number | string | ObjectID; mode: WorkflowExecuteMode; - startedAt: number; - stoppedAt: number; + startedAt: Date; + stoppedAt: Date; workflowId?: string; // To be able to filter executions easily // finished: boolean; retryOf?: number | string | ObjectID; // If it is a retry, the id of the execution it is a retry of. @@ -148,8 +148,8 @@ export interface IExecutionsListResponse { export interface IExecutionsStopData { finished?: boolean; mode: WorkflowExecuteMode; - startedAt: number | string; - stoppedAt: number | string; + startedAt: Date; + stoppedAt: Date; } export interface IExecutionsSummary { @@ -158,14 +158,14 @@ export interface IExecutionsSummary { finished?: boolean; retryOf?: string; retrySuccessId?: string; - startedAt: number | string; - stoppedAt?: number | string; + startedAt: Date; + stoppedAt?: Date; workflowId: string; workflowName?: string; } export interface IExecutionDeleteFilter { - deleteBefore?: number; + deleteBefore?: Date; filters?: IDataObject; ids?: string[]; } @@ -186,6 +186,12 @@ export interface IN8nConfigDatabase { mongodb: { connectionUrl: string; }; + postgresdb: { + host: string; + password: string; + port: number; + user: string; + }; } export interface IN8nConfigEndpoints { diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 40c7b0df90..12932dab1d 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -105,8 +105,8 @@ class App { * @returns {number} * @memberof App */ - getCurrentDate(): number { - return Math.floor(new Date().getTime()); + getCurrentDate(): Date { + return new Date(); } @@ -851,7 +851,7 @@ class App { id: data.id.toString(), workflowId: data.workflowId, mode:data.mode, - startedAt: data.startedAt, + startedAt: new Date(data.startedAt), } ); } @@ -873,8 +873,8 @@ class App { const returnData: IExecutionsStopData = { mode: result.mode, - startedAt: result.startedAt, - stoppedAt: result.stoppedAt, + startedAt: new Date(result.startedAt), + stoppedAt: new Date(result.stoppedAt), finished: result.finished, }; diff --git a/packages/cli/src/databases/index.ts b/packages/cli/src/databases/index.ts index f38130f797..9263d9230f 100644 --- a/packages/cli/src/databases/index.ts +++ b/packages/cli/src/databases/index.ts @@ -1,7 +1,9 @@ import * as MongoDb from './mongodb'; +import * as PostgresDb from './postgresdb'; import * as SQLite from './sqlite'; export { MongoDb, + PostgresDb, SQLite, }; diff --git a/packages/cli/src/databases/mongodb/CredentialsEntity.ts b/packages/cli/src/databases/mongodb/CredentialsEntity.ts index f02e778792..9910d2bb2f 100644 --- a/packages/cli/src/databases/mongodb/CredentialsEntity.ts +++ b/packages/cli/src/databases/mongodb/CredentialsEntity.ts @@ -33,9 +33,9 @@ export class CredentialsEntity implements ICredentialsDb { @Column('json') nodesAccess: ICredentialNodeAccess[]; - @Column() - createdAt: number; + @Column('Date') + createdAt: Date; - @Column() - updatedAt: number; + @Column('Date') + updatedAt: Date; } diff --git a/packages/cli/src/databases/mongodb/ExecutionEntity.ts b/packages/cli/src/databases/mongodb/ExecutionEntity.ts index 7dc89927de..3336374327 100644 --- a/packages/cli/src/databases/mongodb/ExecutionEntity.ts +++ b/packages/cli/src/databases/mongodb/ExecutionEntity.ts @@ -36,11 +36,11 @@ export class ExecutionEntity implements IExecutionFlattedDb { @Column() retrySuccessId: string; - @Column() - startedAt: number; + @Column('Date') + startedAt: Date; - @Column() - stoppedAt: number; + @Column('Date') + stoppedAt: Date; @Column('json') workflowData: IWorkflowDb; diff --git a/packages/cli/src/databases/mongodb/WorkflowEntity.ts b/packages/cli/src/databases/mongodb/WorkflowEntity.ts index dce1c4cbe4..aebe1054f0 100644 --- a/packages/cli/src/databases/mongodb/WorkflowEntity.ts +++ b/packages/cli/src/databases/mongodb/WorkflowEntity.ts @@ -34,11 +34,11 @@ export class WorkflowEntity implements IWorkflowDb { @Column('json') connections: IConnections; - @Column() - createdAt: number; + @Column('Date') + createdAt: Date; - @Column() - updatedAt: number; + @Column('Date') + updatedAt: Date; @Column('json') settings?: IWorkflowSettings; diff --git a/packages/cli/src/databases/postgresdb/CredentialsEntity.ts b/packages/cli/src/databases/postgresdb/CredentialsEntity.ts new file mode 100644 index 0000000000..f2a173bf8a --- /dev/null +++ b/packages/cli/src/databases/postgresdb/CredentialsEntity.ts @@ -0,0 +1,44 @@ +import { + ICredentialNodeAccess, +} from 'n8n-workflow'; + +import { + ICredentialsDb, +} from '../../'; + +import { + Column, + Entity, + Index, + PrimaryGeneratedColumn, +} from "typeorm"; + +@Entity() +export class CredentialsEntity implements ICredentialsDb { + + @PrimaryGeneratedColumn() + id: number; + + @Column({ + length: 128 + }) + name: string; + + @Column('text') + data: string; + + @Index() + @Column({ + length: 32 + }) + type: string; + + @Column('json') + nodesAccess: ICredentialNodeAccess[]; + + @Column('timestamp') + createdAt: Date; + + @Column('timestamp') + updatedAt: Date; +} diff --git a/packages/cli/src/databases/postgresdb/ExecutionEntity.ts b/packages/cli/src/databases/postgresdb/ExecutionEntity.ts new file mode 100644 index 0000000000..7167843b0a --- /dev/null +++ b/packages/cli/src/databases/postgresdb/ExecutionEntity.ts @@ -0,0 +1,51 @@ +import { + WorkflowExecuteMode, +} from 'n8n-workflow'; + +import { + IExecutionFlattedDb, + IWorkflowDb, +} from '../../'; + +import { + Column, + Entity, + Index, + PrimaryGeneratedColumn, + } from "typeorm"; + + +@Entity() +export class ExecutionEntity implements IExecutionFlattedDb { + + @PrimaryGeneratedColumn() + id: number; + + @Column('text') + data: string; + + @Column() + finished: boolean; + + @Column() + mode: WorkflowExecuteMode; + + @Column({ nullable: true }) + retryOf: string; + + @Column({ nullable: true }) + retrySuccessId: string; + + @Column('timestamp') + startedAt: Date; + + @Column('timestamp') + stoppedAt: Date; + + @Column('json') + workflowData: IWorkflowDb; + + @Index() + @Column({ nullable: true }) + workflowId: string; +} diff --git a/packages/cli/src/databases/postgresdb/WorkflowEntity.ts b/packages/cli/src/databases/postgresdb/WorkflowEntity.ts new file mode 100644 index 0000000000..bdb1778274 --- /dev/null +++ b/packages/cli/src/databases/postgresdb/WorkflowEntity.ts @@ -0,0 +1,55 @@ +import { + IConnections, + IDataObject, + INode, + IWorkflowSettings, +} from 'n8n-workflow'; + +import { + IWorkflowDb, +} from '../../'; + +import { + Column, + Entity, + PrimaryGeneratedColumn, +} from "typeorm"; + +@Entity() +export class WorkflowEntity implements IWorkflowDb { + + @PrimaryGeneratedColumn() + id: number; + + @Column({ + length: 128 + }) + name: string; + + @Column() + active: boolean; + + @Column('json') + nodes: INode[]; + + @Column('json') + connections: IConnections; + + @Column('timestamp') + createdAt: Date; + + @Column('timestamp') + updatedAt: Date; + + @Column({ + type: 'json', + nullable: true, + }) + settings?: IWorkflowSettings; + + @Column({ + type: 'json', + nullable: true, + }) + staticData?: IDataObject; +} diff --git a/packages/cli/src/databases/postgresdb/index.ts b/packages/cli/src/databases/postgresdb/index.ts new file mode 100644 index 0000000000..164d67fd0c --- /dev/null +++ b/packages/cli/src/databases/postgresdb/index.ts @@ -0,0 +1,3 @@ +export * from './CredentialsEntity'; +export * from './ExecutionEntity'; +export * from './WorkflowEntity'; diff --git a/packages/cli/src/databases/sqlite/CredentialsEntity.ts b/packages/cli/src/databases/sqlite/CredentialsEntity.ts index 557562bf30..c683c99ee1 100644 --- a/packages/cli/src/databases/sqlite/CredentialsEntity.ts +++ b/packages/cli/src/databases/sqlite/CredentialsEntity.ts @@ -37,8 +37,8 @@ export class CredentialsEntity implements ICredentialsDb { nodesAccess: ICredentialNodeAccess[]; @Column() - createdAt: number; + createdAt: Date; @Column() - updatedAt: number; + updatedAt: Date; } diff --git a/packages/cli/src/databases/sqlite/ExecutionEntity.ts b/packages/cli/src/databases/sqlite/ExecutionEntity.ts index c4e755db21..a38c89ef99 100644 --- a/packages/cli/src/databases/sqlite/ExecutionEntity.ts +++ b/packages/cli/src/databases/sqlite/ExecutionEntity.ts @@ -39,10 +39,10 @@ export class ExecutionEntity implements IExecutionFlattedDb { retrySuccessId: string; @Column() - startedAt: number; + startedAt: Date; @Column() - stoppedAt: number; + stoppedAt: Date; @Column('simple-json') workflowData: IWorkflowDb; diff --git a/packages/cli/src/databases/sqlite/WorkflowEntity.ts b/packages/cli/src/databases/sqlite/WorkflowEntity.ts index 4e8b330af0..2c68c2bae8 100644 --- a/packages/cli/src/databases/sqlite/WorkflowEntity.ts +++ b/packages/cli/src/databases/sqlite/WorkflowEntity.ts @@ -36,10 +36,10 @@ export class WorkflowEntity implements IWorkflowDb { connections: IConnections; @Column() - createdAt: number; + createdAt: Date; @Column() - updatedAt: number; + updatedAt: Date; @Column({ type: 'simple-json', diff --git a/packages/core/src/ActiveExecutions.ts b/packages/core/src/ActiveExecutions.ts index 1e840d7d72..124978d9d3 100644 --- a/packages/core/src/ActiveExecutions.ts +++ b/packages/core/src/ActiveExecutions.ts @@ -35,7 +35,7 @@ export class ActiveExecutions { this.activeExecutions[executionId] = { runExecutionData, - startedAt: new Date().getTime(), + startedAt: new Date(), mode, workflow, postExecutePromises: [], diff --git a/packages/core/src/Interfaces.ts b/packages/core/src/Interfaces.ts index 7cced88dfe..fead342e48 100644 --- a/packages/core/src/Interfaces.ts +++ b/packages/core/src/Interfaces.ts @@ -47,7 +47,7 @@ export interface IExecuteSingleFunctions extends IExecuteSingleFunctionsBase { export interface IExecutingWorkflowData { runExecutionData: IRunExecutionData; - startedAt: number; + startedAt: Date; mode: WorkflowExecuteMode; workflow: Workflow; postExecutePromises: Array>; @@ -55,7 +55,7 @@ export interface IExecutingWorkflowData { export interface IExecutionsCurrentSummary { id: string; - startedAt: number; + startedAt: Date; mode: WorkflowExecuteMode; workflowId: string; } diff --git a/packages/core/src/LoadNodeParameterOptions.ts b/packages/core/src/LoadNodeParameterOptions.ts index 9bce351444..8ff78e41cd 100644 --- a/packages/core/src/LoadNodeParameterOptions.ts +++ b/packages/core/src/LoadNodeParameterOptions.ts @@ -66,8 +66,8 @@ export class LoadNodeParameterOptions { active: false, connections: {}, nodes: Object.values(this.workflow.nodes), - createdAt: 0, - updatedAt: 0, + createdAt: new Date(), + updatedAt: new Date(), }; } diff --git a/packages/core/src/WorkflowExecute.ts b/packages/core/src/WorkflowExecute.ts index 8bcad84cd3..1b4d159cc9 100644 --- a/packages/core/src/WorkflowExecute.ts +++ b/packages/core/src/WorkflowExecute.ts @@ -623,8 +623,8 @@ export class WorkflowExecute { const fullRunData: IRun = { data: runExecutionData, mode: this.mode, - startedAt, - stoppedAt: new Date().getTime(), + startedAt: new Date(startedAt), + stoppedAt: new Date(), }; if (executionError !== undefined) { @@ -643,8 +643,8 @@ export class WorkflowExecute { const fullRunData: IRun = { data: runExecutionData, mode: this.mode, - startedAt, - stoppedAt: new Date().getTime(), + startedAt: new Date(startedAt), + stoppedAt: new Date(), }; fullRunData.data.resultData.error = { diff --git a/packages/core/test/Credentials.test.ts b/packages/core/test/Credentials.test.ts index 57c9057c9a..dc8e151b86 100644 --- a/packages/core/test/Credentials.test.ts +++ b/packages/core/test/Credentials.test.ts @@ -50,7 +50,7 @@ describe('Credentials', () => { { nodeType: 'base.noOp', user: 'userName', - date: 1234, + date: new Date(), } ]; diff --git a/packages/editor-ui/src/Interface.ts b/packages/editor-ui/src/Interface.ts index 87a7691bda..30be24a83e 100644 --- a/packages/editor-ui/src/Interface.ts +++ b/packages/editor-ui/src/Interface.ts @@ -116,7 +116,7 @@ export interface IRestApi { getActiveWorkflows(): Promise; getActivationError(id: string): Promise; getCurrentExecutions(filter: object): Promise; - getPastExecutions(filter: object, limit: number, lastStartedAt?: number): Promise; + getPastExecutions(filter: object, limit: number, lastStartedAt?: Date): Promise; stopCurrentExecution(executionId: string): Promise; makeRestApiRequest(method: string, endpoint: string, data?: any): Promise; // tslint:disable-line:no-any getSettings(): Promise; @@ -250,8 +250,8 @@ export interface IExecutionBase { mode: WorkflowExecuteMode; retryOf?: string; retrySuccessId?: string; - startedAt: number; - stoppedAt: number; + startedAt: Date; + stoppedAt?: Date; workflowId?: string; // To be able to filter executions easily // } @@ -283,8 +283,8 @@ export interface IExecutionShortResponse { }; mode: WorkflowExecuteMode; finished: boolean; - startedAt: number | string; - stoppedAt: number | string; + startedAt: Date; + stoppedAt: Date; executionTime?: number; } @@ -297,8 +297,8 @@ export interface IExecutionsCurrentSummaryExtended { id: string; finished?: boolean; mode: WorkflowExecuteMode; - startedAt: number | string; - stoppedAt?: number | string; + startedAt: Date; + stoppedAt?: Date; workflowId: string; workflowName?: string; } @@ -306,8 +306,8 @@ export interface IExecutionsCurrentSummaryExtended { export interface IExecutionsStopData { finished?: boolean; mode: WorkflowExecuteMode; - startedAt: number | string; - stoppedAt: number | string; + startedAt: Date; + stoppedAt: Date; } export interface IExecutionsSummary { @@ -316,14 +316,14 @@ export interface IExecutionsSummary { finished?: boolean; retryOf?: string; retrySuccessId?: string; - startedAt: number | string; - stoppedAt?: number | string; + startedAt: Date; + stoppedAt?: Date; workflowId: string; workflowName?: string; } export interface IExecutionDeleteFilter { - deleteBefore?: number; + deleteBefore?: Date; filters?: IDataObject; ids?: string[]; } diff --git a/packages/editor-ui/src/components/ExecutionsList.vue b/packages/editor-ui/src/components/ExecutionsList.vue index 05b54a43d6..08a10ddcf3 100644 --- a/packages/editor-ui/src/components/ExecutionsList.vue +++ b/packages/editor-ui/src/components/ExecutionsList.vue @@ -110,7 +110,7 @@ {{(new Date().getTime() - new Date(scope.row.startedAt).getTime())/1000}} sec. - {{(scope.row.stoppedAt - scope.row.startedAt) / 1000}} sec. + {{(new Date(scope.row.stoppedAt).getTime() - new Date(scope.row.startedAt).getTime()) / 1000}} sec. @@ -323,7 +323,7 @@ export default mixins( const sendData: IExecutionDeleteFilter = {}; if (this.checkAll === true) { - sendData.deleteBefore = this.finishedExecutions[0].startedAt as number; + sendData.deleteBefore = this.finishedExecutions[0].startedAt as Date; } else { sendData.ids = Object.keys(this.selectedItems); } @@ -387,11 +387,11 @@ export default mixins( this.isDataLoading = true; const filter = this.workflowFilter; - let lastStartedAt: number | undefined; + let lastStartedAt: Date | undefined; if (this.finishedExecutions.length !== 0) { const lastItem = this.finishedExecutions.slice(-1)[0]; - lastStartedAt = lastItem.startedAt as number; + lastStartedAt = lastItem.startedAt as Date; } let data: IExecutionsListResponse; diff --git a/packages/editor-ui/src/components/mixins/restApi.ts b/packages/editor-ui/src/components/mixins/restApi.ts index c7dbf54b5b..3702e950ed 100644 --- a/packages/editor-ui/src/components/mixins/restApi.ts +++ b/packages/editor-ui/src/components/mixins/restApi.ts @@ -269,7 +269,7 @@ export const restApi = Vue.extend({ // Returns all saved executions // TODO: For sure needs some kind of default filter like last day, with max 10 results, ... - getPastExecutions: (filter: object, limit: number, lastStartedAt?: number): Promise => { + getPastExecutions: (filter: object, limit: number, lastStartedAt?: Date): Promise => { let sendData = {}; if (filter) { sendData = { diff --git a/packages/editor-ui/src/components/mixins/workflowRun.ts b/packages/editor-ui/src/components/mixins/workflowRun.ts index 722e1d0964..a32814f5bb 100644 --- a/packages/editor-ui/src/components/mixins/workflowRun.ts +++ b/packages/editor-ui/src/components/mixins/workflowRun.ts @@ -144,8 +144,8 @@ export const workflowRun = mixins( id: '__IN_PROGRESS__', finished: false, mode: 'manual', - startedAt: new Date().getTime(), - stoppedAt: 0, + startedAt: new Date(), + stoppedAt: undefined, workflowId: workflow.id, data: { resultData: { diff --git a/packages/workflow/src/Interfaces.ts b/packages/workflow/src/Interfaces.ts index 264a930a66..e8a155cfdd 100644 --- a/packages/workflow/src/Interfaces.ts +++ b/packages/workflow/src/Interfaces.ts @@ -37,7 +37,7 @@ export interface IGetCredentials { export interface ICredentialNodeAccess { nodeType: string; user?: string; - date?: number; + date?: Date; } export interface ICredentialsDecrypted { @@ -466,8 +466,8 @@ export interface IRun { data: IRunExecutionData; finished?: boolean; mode: WorkflowExecuteMode; - startedAt: number; - stoppedAt: number; + startedAt: Date; + stoppedAt: Date; }