refactor(core): Move push message types to a new shared package (no-changelog) (#10742)
This commit is contained in:
committed by
GitHub
parent
7f1c131b72
commit
2f8c8448d3
7
packages/@n8n/api-types/.eslintrc.js
Normal file
7
packages/@n8n/api-types/.eslintrc.js
Normal file
@@ -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),
|
||||
};
|
||||
3
packages/@n8n/api-types/README.md
Normal file
3
packages/@n8n/api-types/README.md
Normal file
@@ -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.
|
||||
2
packages/@n8n/api-types/jest.config.js
Normal file
2
packages/@n8n/api-types/jest.config.js
Normal file
@@ -0,0 +1,2 @@
|
||||
/** @type {import('jest').Config} */
|
||||
module.exports = require('../../../jest.config');
|
||||
24
packages/@n8n/api-types/package.json
Normal file
24
packages/@n8n/api-types/package.json
Normal file
@@ -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:*"
|
||||
}
|
||||
}
|
||||
2
packages/@n8n/api-types/src/datetime.ts
Normal file
2
packages/@n8n/api-types/src/datetime.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
/** Date time in the ISO 8601 format, e.g. 2024-10-31T00:00:00.123Z */
|
||||
export type Iso8601DateTimeString = string;
|
||||
7
packages/@n8n/api-types/src/index.ts
Normal file
7
packages/@n8n/api-types/src/index.ts
Normal file
@@ -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';
|
||||
17
packages/@n8n/api-types/src/push/collaboration.ts
Normal file
17
packages/@n8n/api-types/src/push/collaboration.ts
Normal file
@@ -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;
|
||||
9
packages/@n8n/api-types/src/push/debug.ts
Normal file
9
packages/@n8n/api-types/src/push/debug.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
type SendConsoleMessage = {
|
||||
type: 'sendConsoleMessage';
|
||||
data: {
|
||||
source: string;
|
||||
messages: unknown[];
|
||||
};
|
||||
};
|
||||
|
||||
export type DebugPushMessage = SendConsoleMessage;
|
||||
53
packages/@n8n/api-types/src/push/execution.ts
Normal file
53
packages/@n8n/api-types/src/push/execution.ts
Normal file
@@ -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;
|
||||
21
packages/@n8n/api-types/src/push/hot-reload.ts
Normal file
21
packages/@n8n/api-types/src/push/hot-reload.ts
Normal file
@@ -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;
|
||||
20
packages/@n8n/api-types/src/push/index.ts
Normal file
20
packages/@n8n/api-types/src/push/index.ts
Normal file
@@ -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'];
|
||||
17
packages/@n8n/api-types/src/push/webhook.ts
Normal file
17
packages/@n8n/api-types/src/push/webhook.ts
Normal file
@@ -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;
|
||||
11
packages/@n8n/api-types/src/push/worker.ts
Normal file
11
packages/@n8n/api-types/src/push/worker.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import type { WorkerStatus } from '../scaling';
|
||||
|
||||
export type SendWorkerStatusMessage = {
|
||||
type: 'sendWorkerStatusMessage';
|
||||
data: {
|
||||
workerId: string;
|
||||
status: WorkerStatus;
|
||||
};
|
||||
};
|
||||
|
||||
export type WorkerPushMessage = SendWorkerStatusMessage;
|
||||
26
packages/@n8n/api-types/src/push/workflow.ts
Normal file
26
packages/@n8n/api-types/src/push/workflow.ts
Normal file
@@ -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;
|
||||
30
packages/@n8n/api-types/src/scaling.ts
Normal file
30
packages/@n8n/api-types/src/scaling.ts
Normal file
@@ -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;
|
||||
};
|
||||
6
packages/@n8n/api-types/src/user.ts
Normal file
6
packages/@n8n/api-types/src/user.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export type MinimalUser = {
|
||||
id: string;
|
||||
email: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
};
|
||||
11
packages/@n8n/api-types/tsconfig.build.json
Normal file
11
packages/@n8n/api-types/tsconfig.build.json
Normal file
@@ -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__/**"]
|
||||
}
|
||||
10
packages/@n8n/api-types/tsconfig.json
Normal file
10
packages/@n8n/api-types/tsconfig.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "../../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": ".",
|
||||
"types": ["node", "jest"],
|
||||
"baseUrl": "src",
|
||||
"tsBuildInfoFile": "dist/typecheck.tsbuildinfo"
|
||||
},
|
||||
"include": ["src/**/*.ts", "test/**/*.ts"]
|
||||
}
|
||||
Reference in New Issue
Block a user