feat: Add @n8n/extension-sdk package (no-changelog) (#14291)

This commit is contained in:
Alex Grozav
2025-03-31 16:13:42 +03:00
committed by GitHub
parent a00cd4b2ac
commit d6331195b8
18 changed files with 244 additions and 1 deletions

24
packages/@n8n/extension-sdk/.gitignore vendored Normal file
View File

@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

View File

@@ -0,0 +1 @@
See LICENSE.md in the root of this repository for more information.

View File

@@ -0,0 +1 @@
# @n8n/plugin-sdk

View File

@@ -0,0 +1,46 @@
{
"name": "@n8n/extension-sdk",
"version": "0.1.0",
"type": "module",
"files": [
"dist",
"LICENSE",
"README.md"
],
"exports": {
"./backend": {
"types": "./dist/backend/index.d.ts",
"import": "./dist/backend/index.js",
"require": "./dist/backend/index.cjs"
},
"./frontend": {
"types": "./dist/frontend/index.d.ts",
"import": "./dist/frontend/index.js",
"require": "./dist/frontend/index.cjs"
},
"./*": "./*"
},
"scripts": {
"clean": "rimraf dist",
"dev": "tsup --watch",
"typecheck:frontend": "vue-tsc --noEmit --project tsconfig.frontend.json",
"typecheck:backend": "tsc --noEmit --project tsconfig.backend.json",
"build": "pnpm \"/^typecheck:.+/\" && pnpm clean && tsup",
"preview": "vite preview"
},
"peerDependencies": {
"vue": "catalog:frontend",
"vue-router": "catalog:frontend"
},
"devDependencies": {
"@n8n/typescript-config": "workspace:*",
"@vitejs/plugin-vue": "catalog:frontend",
"@vue/tsconfig": "catalog:frontend",
"rimraf": "catalog:",
"vite": "catalog:frontend",
"vue": "catalog:frontend",
"vue-router": "catalog:frontend",
"vue-tsc": "catalog:frontend"
},
"license": "https://docs.n8n.io/sustainable-use-license/"
}

View File

@@ -0,0 +1,5 @@
import type { BackendModule } from './types.ts';
export function defineBackendModule(module: BackendModule): BackendModule {
return module;
}

View File

@@ -0,0 +1,2 @@
export * from './define';
export * from './types';

View File

@@ -0,0 +1,7 @@
export type BackendModuleContext = {};
export type BackendModuleSetupFn = (context: BackendModule) => void;
export type BackendModule = {
setup: BackendModuleSetupFn;
};

View File

@@ -0,0 +1,5 @@
import type { FrontendModule } from './types.ts';
export function defineFrontendModule(module: FrontendModule): FrontendModule {
return module;
}

View File

@@ -0,0 +1,2 @@
export * from './define';
export * from './types';

View File

@@ -0,0 +1,13 @@
import type { RouteRecordRaw } from 'vue-router';
import type { App } from 'vue';
export type FrontendModuleContext = {
app: App;
defineRoutes: (routes: RouteRecordRaw[]) => void;
};
export type FrontendModuleSetupFn = (context: FrontendModuleContext) => void;
export type FrontendModule = {
setup: FrontendModuleSetupFn;
};

View File

View File

@@ -0,0 +1 @@
/// <reference types="vite/client" />

View File

@@ -0,0 +1,7 @@
{
"extends": "@n8n/typescript-config/tsconfig.common.json",
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.backend.tsbuildinfo"
},
"include": ["src/backend/**/*.ts"]
}

View File

@@ -0,0 +1,7 @@
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.frontend.tsbuildinfo"
},
"include": ["src/frontend/**/*.ts", "src/frontend/**/*.vue"]
}

View File

@@ -0,0 +1,4 @@
{
"files": ["./src/index.ts"],
"references": [{ "path": "./tsconfig.backend.json" }, { "path": "./tsconfig.frontend.json" }]
}

View File

@@ -0,0 +1,32 @@
import { defineConfig } from 'tsup';
export default defineConfig([
{
clean: true,
entry: [
'src/backend/**/*.ts',
'!src/backend/**/*.test.ts',
'!src/backend/**/*.d.ts',
'!src/backend/__tests__**/*',
],
outDir: 'dist/backend',
format: ['cjs', 'esm'],
dts: true,
sourcemap: true,
tsconfig: 'tsconfig.backend.json',
},
{
clean: true,
entry: [
'src/frontend/**/*.ts',
'!src/frontend/**/*.test.ts',
'!src/frontend/**/*.d.ts',
'!src/frontend/__tests__**/*',
],
outDir: 'dist/frontend',
format: ['cjs', 'esm'],
dts: true,
sourcemap: true,
tsconfig: 'tsconfig.frontend.json',
},
]);