-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core): Move push message types to a new shared package (no-c…
…hangelog) (#10742)
- Loading branch information
Showing
56 changed files
with
480 additions
and
663 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const sharedOptions = require('@n8n_io/eslint-config/shared'); | ||
|
||
/** @type {import('@types/eslint').ESLint.ConfigData} */ | ||
module.exports = { | ||
extends: ['@n8n_io/eslint-config/base'], | ||
...sharedOptions(__dirname), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## @n8n/api-types | ||
|
||
This package contains types and schema definitions for the n8n internal API, so that these can be shared between the backend and the frontend code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/** @type {import('jest').Config} */ | ||
module.exports = require('../../../jest.config'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "@n8n/api-types", | ||
"version": "0.1.0", | ||
"scripts": { | ||
"clean": "rimraf dist .turbo", | ||
"dev": "pnpm watch", | ||
"typecheck": "tsc --noEmit", | ||
"build": "tsc -p tsconfig.build.json", | ||
"format": "prettier --write . --ignore-path ../../../.prettierignore", | ||
"lint": "eslint .", | ||
"lintfix": "eslint . --fix", | ||
"watch": "tsc -p tsconfig.build.json --watch", | ||
"test": "echo \"No tests yet\" && exit 0" | ||
}, | ||
"main": "dist/index.js", | ||
"module": "src/index.ts", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist/**/*" | ||
], | ||
"devDependencies": { | ||
"n8n-workflow": "workspace:*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/** Date time in the ISO 8601 format, e.g. 2024-10-31T00:00:00.123Z */ | ||
export type Iso8601DateTimeString = string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export type * from './push'; | ||
export type * from './scaling'; | ||
export type * from './datetime'; | ||
export type * from './user'; | ||
|
||
export type { Collaborator } from './push/collaboration'; | ||
export type { SendWorkerStatusMessage } from './push/worker'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { Iso8601DateTimeString } from '../datetime'; | ||
import type { MinimalUser } from '../user'; | ||
|
||
export type Collaborator = { | ||
user: MinimalUser; | ||
lastSeen: Iso8601DateTimeString; | ||
}; | ||
|
||
type CollaboratorsChanged = { | ||
type: 'collaboratorsChanged'; | ||
data: { | ||
workflowId: string; | ||
collaborators: Collaborator[]; | ||
}; | ||
}; | ||
|
||
export type CollaborationPushMessage = CollaboratorsChanged; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
type SendConsoleMessage = { | ||
type: 'sendConsoleMessage'; | ||
data: { | ||
source: string; | ||
messages: unknown[]; | ||
}; | ||
}; | ||
|
||
export type DebugPushMessage = SendConsoleMessage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import type { IRun, ITaskData, WorkflowExecuteMode } from 'n8n-workflow'; | ||
|
||
type ExecutionStarted = { | ||
type: 'executionStarted'; | ||
data: { | ||
executionId: string; | ||
mode: WorkflowExecuteMode; | ||
startedAt: Date; | ||
workflowId: string; | ||
workflowName?: string; | ||
retryOf?: string; | ||
}; | ||
}; | ||
|
||
type ExecutionFinished = { | ||
type: 'executionFinished'; | ||
data: { | ||
executionId: string; | ||
data: IRun; | ||
retryOf?: string; | ||
}; | ||
}; | ||
|
||
type ExecutionRecovered = { | ||
type: 'executionRecovered'; | ||
data: { | ||
executionId: string; | ||
}; | ||
}; | ||
|
||
type NodeExecuteBefore = { | ||
type: 'nodeExecuteBefore'; | ||
data: { | ||
executionId: string; | ||
nodeName: string; | ||
}; | ||
}; | ||
|
||
type NodeExecuteAfter = { | ||
type: 'nodeExecuteAfter'; | ||
data: { | ||
executionId: string; | ||
nodeName: string; | ||
data: ITaskData; | ||
}; | ||
}; | ||
|
||
export type ExecutionPushMessage = | ||
| ExecutionStarted | ||
| ExecutionFinished | ||
| ExecutionRecovered | ||
| NodeExecuteBefore | ||
| NodeExecuteAfter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
type NodeTypeData = { | ||
name: string; | ||
version: number; | ||
}; | ||
|
||
type ReloadNodeType = { | ||
type: 'reloadNodeType'; | ||
data: NodeTypeData; | ||
}; | ||
|
||
type RemoveNodeType = { | ||
type: 'removeNodeType'; | ||
data: NodeTypeData; | ||
}; | ||
|
||
type NodeDescriptionUpdated = { | ||
type: 'nodeDescriptionUpdated'; | ||
data: {}; | ||
}; | ||
|
||
export type HotReloadPushMessage = ReloadNodeType | RemoveNodeType | NodeDescriptionUpdated; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { ExecutionPushMessage } from './execution'; | ||
import type { WorkflowPushMessage } from './workflow'; | ||
import type { HotReloadPushMessage } from './hot-reload'; | ||
import type { WorkerPushMessage } from './worker'; | ||
import type { WebhookPushMessage } from './webhook'; | ||
import type { CollaborationPushMessage } from './collaboration'; | ||
import type { DebugPushMessage } from './debug'; | ||
|
||
export type PushMessage = | ||
| ExecutionPushMessage | ||
| WorkflowPushMessage | ||
| HotReloadPushMessage | ||
| WebhookPushMessage | ||
| WorkerPushMessage | ||
| CollaborationPushMessage | ||
| DebugPushMessage; | ||
|
||
export type PushType = PushMessage['type']; | ||
|
||
export type PushPayload<T extends PushType> = Extract<PushMessage, { type: T }>['data']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
type TestWebhookDeleted = { | ||
type: 'testWebhookDeleted'; | ||
data: { | ||
executionId?: string; | ||
workflowId: string; | ||
}; | ||
}; | ||
|
||
type TestWebhookReceived = { | ||
type: 'testWebhookReceived'; | ||
data: { | ||
executionId: string; | ||
workflowId: string; | ||
}; | ||
}; | ||
|
||
export type WebhookPushMessage = TestWebhookDeleted | TestWebhookReceived; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { WorkerStatus } from '../scaling'; | ||
|
||
export type SendWorkerStatusMessage = { | ||
type: 'sendWorkerStatusMessage'; | ||
data: { | ||
workerId: string; | ||
status: WorkerStatus; | ||
}; | ||
}; | ||
|
||
export type WorkerPushMessage = SendWorkerStatusMessage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
type WorkflowActivated = { | ||
type: 'workflowActivated'; | ||
data: { | ||
workflowId: string; | ||
}; | ||
}; | ||
|
||
type WorkflowFailedToActivate = { | ||
type: 'workflowFailedToActivate'; | ||
data: { | ||
workflowId: string; | ||
errorMessage: string; | ||
}; | ||
}; | ||
|
||
type WorkflowDeactivated = { | ||
type: 'workflowDeactivated'; | ||
data: { | ||
workflowId: string; | ||
}; | ||
}; | ||
|
||
export type WorkflowPushMessage = | ||
| WorkflowActivated | ||
| WorkflowFailedToActivate | ||
| WorkflowDeactivated; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { ExecutionStatus, WorkflowExecuteMode } from 'n8n-workflow'; | ||
|
||
export type RunningJobSummary = { | ||
executionId: string; | ||
workflowId: string; | ||
workflowName: string; | ||
mode: WorkflowExecuteMode; | ||
startedAt: Date; | ||
retryOf: string; | ||
status: ExecutionStatus; | ||
}; | ||
|
||
export type WorkerStatus = { | ||
workerId: string; | ||
runningJobsSummary: RunningJobSummary[]; | ||
freeMem: number; | ||
totalMem: number; | ||
uptime: number; | ||
loadAvg: number[]; | ||
cpus: string; | ||
arch: string; | ||
platform: NodeJS.Platform; | ||
hostname: string; | ||
interfaces: Array<{ | ||
family: 'IPv4' | 'IPv6'; | ||
address: string; | ||
internal: boolean; | ||
}>; | ||
version: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export type MinimalUser = { | ||
id: string; | ||
email: string; | ||
firstName: string; | ||
lastName: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": ["./tsconfig.json", "../../../tsconfig.build.json"], | ||
"compilerOptions": { | ||
"composite": true, | ||
"rootDir": "src", | ||
"outDir": "dist", | ||
"tsBuildInfoFile": "dist/build.tsbuildinfo" | ||
}, | ||
"include": ["src/**/*.ts"], | ||
"exclude": ["test/**", "src/**/__tests__/**"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "../../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": ".", | ||
"types": ["node", "jest"], | ||
"baseUrl": "src", | ||
"tsBuildInfoFile": "dist/typecheck.tsbuildinfo" | ||
}, | ||
"include": ["src/**/*.ts", "test/**/*.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.