@lark-apaas/nestjs-capability 0.0.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/services/template-engine.service.ts","../src/services/plugin-loader.service.ts","../src/services/capability.service.ts","../src/controllers/debug.controller.ts","../src/controllers/webhook.controller.ts","../src/capability.module.ts"],"sourcesContent":["export * from './interfaces';\nexport * from './services';\nexport * from './controllers';\nexport * from './capability.module';\n","import { Injectable } from '@nestjs/common';\n\n@Injectable()\nexport class TemplateEngineService {\n private readonly TEMPLATE_REGEX = /^\\{\\{input\\.(.+)\\}\\}$/;\n\n resolve(template: unknown, input: Record<string, unknown>): unknown {\n if (typeof template === 'string') {\n return this.resolveString(template, input);\n }\n\n if (Array.isArray(template)) {\n return template.map(item => this.resolve(item, input));\n }\n\n if (template !== null && typeof template === 'object') {\n return this.resolveObject(template as Record<string, unknown>, input);\n }\n\n return template;\n }\n\n private resolveString(template: string, input: Record<string, unknown>): unknown {\n const match = template.match(this.TEMPLATE_REGEX);\n if (!match) {\n return template;\n }\n\n const path = match[1];\n return this.getValueByPath(input, path);\n }\n\n private resolveObject(\n template: Record<string, unknown>,\n input: Record<string, unknown>,\n ): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(template)) {\n result[key] = this.resolve(value, input);\n }\n\n return result;\n }\n\n private getValueByPath(obj: Record<string, unknown>, path: string): unknown {\n const keys = path.split('.');\n let current: unknown = obj;\n\n for (const key of keys) {\n if (current === null || current === undefined) {\n return undefined;\n }\n current = (current as Record<string, unknown>)[key];\n }\n\n return current;\n }\n}\n","import { Injectable, Logger } from '@nestjs/common';\nimport type { PluginInstance, PluginPackage } from '../interfaces';\n\nexport class PluginNotFoundError extends Error {\n constructor(pluginID: string) {\n super(`Plugin not found: ${pluginID}`);\n this.name = 'PluginNotFoundError';\n }\n}\n\nexport class PluginLoadError extends Error {\n constructor(pluginID: string, reason: string) {\n super(`Failed to load plugin ${pluginID}: ${reason}`);\n this.name = 'PluginLoadError';\n }\n}\n\n@Injectable()\nexport class PluginLoaderService {\n private readonly logger = new Logger(PluginLoaderService.name);\n private readonly pluginInstances = new Map<string, PluginInstance>();\n\n loadPlugin(pluginID: string): PluginInstance {\n const cached = this.pluginInstances.get(pluginID);\n if (cached) {\n this.logger.debug(`Using cached plugin instance: ${pluginID}`);\n return cached;\n }\n\n this.logger.log(`Loading plugin: ${pluginID}`);\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const pluginPackage = require(pluginID) as PluginPackage;\n\n if (typeof pluginPackage.create !== 'function') {\n throw new PluginLoadError(pluginID, 'Plugin does not export create() function');\n }\n\n const instance = pluginPackage.create();\n this.pluginInstances.set(pluginID, instance);\n\n this.logger.log(`Plugin loaded successfully: ${pluginID}`);\n return instance;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'MODULE_NOT_FOUND') {\n throw new PluginNotFoundError(pluginID);\n }\n throw new PluginLoadError(\n pluginID,\n error instanceof Error ? error.message : String(error),\n );\n }\n }\n\n isPluginInstalled(pluginID: string): boolean {\n try {\n require.resolve(pluginID);\n return true;\n } catch {\n return false;\n }\n }\n\n clearCache(pluginID?: string): void {\n if (pluginID) {\n this.pluginInstances.delete(pluginID);\n this.logger.log(`Cleared cache for plugin: ${pluginID}`);\n } else {\n this.pluginInstances.clear();\n this.logger.log('Cleared all plugin caches');\n }\n }\n}\n","import { Injectable, Logger, Inject, OnModuleInit } from '@nestjs/common';\nimport {\n RequestContextService,\n PLATFORM_HTTP_CLIENT,\n type PlatformHttpClient,\n} from '@lark-apaas/nestjs-common';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport type { CapabilityConfig, PluginActionContext, UserContext } from '../interfaces';\nimport { PluginLoaderService } from './plugin-loader.service';\nimport { TemplateEngineService } from './template-engine.service';\n\nexport class CapabilityNotFoundError extends Error {\n constructor(capabilityId: string) {\n super(`Capability not found: ${capabilityId}`);\n this.name = 'CapabilityNotFoundError';\n }\n}\n\nexport class ActionNotFoundError extends Error {\n constructor(pluginID: string, actionName: string) {\n super(`Action '${actionName}' not found in plugin ${pluginID}`);\n this.name = 'ActionNotFoundError';\n }\n}\n\nexport interface CapabilityExecutor {\n call(actionName: string, input: unknown, context?: Partial<PluginActionContext>): Promise<unknown>;\n}\n\nexport interface CapabilityModuleOptions {\n capabilitiesDir?: string;\n}\n\n@Injectable()\nexport class CapabilityService implements OnModuleInit {\n private readonly logger = new Logger(CapabilityService.name);\n private readonly capabilities = new Map<string, CapabilityConfig>();\n private capabilitiesDir: string;\n\n constructor(\n private readonly requestContextService: RequestContextService,\n @Inject(PLATFORM_HTTP_CLIENT) private readonly httpClient: PlatformHttpClient,\n private readonly pluginLoaderService: PluginLoaderService,\n private readonly templateEngineService: TemplateEngineService,\n ) {\n this.capabilitiesDir = path.join(process.cwd(), 'server/capabilities');\n }\n\n setCapabilitiesDir(dir: string): void {\n this.capabilitiesDir = dir;\n }\n\n async onModuleInit(): Promise<void> {\n await this.loadCapabilities();\n }\n\n private async loadCapabilities(): Promise<void> {\n this.logger.log(`Loading capabilities from ${this.capabilitiesDir}`);\n\n if (!fs.existsSync(this.capabilitiesDir)) {\n this.logger.warn(`Capabilities directory not found: ${this.capabilitiesDir}`);\n return;\n }\n\n const files = fs.readdirSync(this.capabilitiesDir).filter(f => f.endsWith('.json'));\n\n for (const file of files) {\n try {\n const filePath = path.join(this.capabilitiesDir, file);\n const content = fs.readFileSync(filePath, 'utf-8');\n const config = JSON.parse(content) as CapabilityConfig;\n\n if (!config.id) {\n this.logger.warn(`Skipping capability without id: ${file}`);\n continue;\n }\n\n this.capabilities.set(config.id, config);\n this.logger.log(`Loaded capability: ${config.id} (${config.name})`);\n } catch (error) {\n this.logger.error(`Failed to load capability from ${file}:`, error);\n }\n }\n\n this.logger.log(`Loaded ${this.capabilities.size} capabilities`);\n }\n\n listCapabilities(): CapabilityConfig[] {\n return Array.from(this.capabilities.values());\n }\n\n getCapability(capabilityId: string): CapabilityConfig | null {\n return this.capabilities.get(capabilityId) ?? null;\n }\n\n load(capabilityId: string): CapabilityExecutor {\n const config = this.capabilities.get(capabilityId);\n if (!config) {\n throw new CapabilityNotFoundError(capabilityId);\n }\n\n return {\n call: async (\n actionName: string,\n input: unknown,\n contextOverride?: Partial<PluginActionContext>,\n ) => {\n return this.execute(config, actionName, input, contextOverride);\n },\n };\n }\n\n private async execute(\n config: CapabilityConfig,\n actionName: string,\n input: unknown,\n contextOverride?: Partial<PluginActionContext>,\n ): Promise<unknown> {\n const startTime = Date.now();\n\n try {\n const pluginInstance = this.pluginLoaderService.loadPlugin(config.pluginID);\n\n if (!pluginInstance.hasAction(actionName)) {\n throw new ActionNotFoundError(config.pluginID, actionName);\n }\n\n const resolvedParams = this.templateEngineService.resolve(\n config.formValue,\n input as Record<string, unknown>,\n );\n\n const context = this.buildActionContext(contextOverride);\n\n this.logger.log({\n message: 'Executing capability',\n capabilityId: config.id,\n action: actionName,\n pluginID: config.pluginID,\n });\n\n const result = await pluginInstance.run(actionName, context, resolvedParams);\n\n this.logger.log({\n message: 'Capability executed successfully',\n capabilityId: config.id,\n action: actionName,\n duration: Date.now() - startTime,\n });\n\n return result;\n } catch (error) {\n this.logger.error({\n message: 'Capability execution failed',\n capabilityId: config.id,\n action: actionName,\n error: error instanceof Error ? error.message : String(error),\n duration: Date.now() - startTime,\n });\n throw error;\n }\n }\n\n private buildActionContext(override?: Partial<PluginActionContext>): PluginActionContext {\n return {\n logger: this.logger,\n httpClient: this.httpClient,\n userContext: override?.userContext ?? this.getUserContext(),\n };\n }\n\n private getUserContext(): UserContext {\n const ctx = this.requestContextService.getContext();\n return {\n userId: ctx?.userId ?? '',\n tenantId: ctx?.tenantId ?? '',\n };\n }\n}\n","import {\n Controller,\n Post,\n Get,\n Param,\n Body,\n HttpException,\n HttpStatus,\n} from '@nestjs/common';\nimport {\n CapabilityService,\n CapabilityNotFoundError,\n ActionNotFoundError,\n} from '../services/capability.service';\nimport { PluginNotFoundError } from '../services/plugin-loader.service';\nimport { TemplateEngineService } from '../services/template-engine.service';\n\ninterface ExecuteRequestBody {\n action: string;\n params: Record<string, unknown>;\n}\n\ninterface DebugResponse {\n code: number;\n message: string;\n data: unknown;\n debug?: {\n capabilityConfig: unknown;\n resolvedParams: unknown;\n duration: number;\n pluginID: string;\n };\n}\n\ninterface ListResponse {\n code: number;\n message: string;\n data: Array<{\n id: string;\n name: string;\n pluginID: string;\n pluginVersion: string;\n }>;\n}\n\n@Controller('__innerapi__/capability')\nexport class DebugController {\n constructor(\n private readonly capabilityService: CapabilityService,\n private readonly templateEngineService: TemplateEngineService,\n ) {}\n\n @Get('list')\n list(): ListResponse {\n const capabilities = this.capabilityService.listCapabilities();\n\n return {\n code: 0,\n message: 'success',\n data: capabilities.map(c => ({\n id: c.id,\n name: c.name,\n pluginID: c.pluginID,\n pluginVersion: c.pluginVersion,\n })),\n };\n }\n\n @Post('debug/:capability_id')\n async debug(\n @Param('capability_id') capabilityId: string,\n @Body() body: ExecuteRequestBody,\n ): Promise<DebugResponse> {\n const startTime = Date.now();\n\n const config = this.capabilityService.getCapability(capabilityId);\n if (!config) {\n throw new HttpException(\n {\n code: 1,\n message: `Capability not found: ${capabilityId}`,\n error: 'CAPABILITY_NOT_FOUND',\n },\n HttpStatus.NOT_FOUND,\n );\n }\n\n const resolvedParams = this.templateEngineService.resolve(\n config.formValue,\n body.params,\n );\n\n try {\n const result = await this.capabilityService\n .load(capabilityId)\n .call(body.action, body.params);\n\n return {\n code: 0,\n message: 'success',\n data: result,\n debug: {\n capabilityConfig: config,\n resolvedParams,\n duration: Date.now() - startTime,\n pluginID: config.pluginID,\n },\n };\n } catch (error) {\n const duration = Date.now() - startTime;\n\n if (error instanceof CapabilityNotFoundError) {\n throw new HttpException(\n {\n code: 1,\n message: error.message,\n error: 'CAPABILITY_NOT_FOUND',\n debug: { duration },\n },\n HttpStatus.NOT_FOUND,\n );\n }\n\n if (error instanceof PluginNotFoundError) {\n throw new HttpException(\n {\n code: 1,\n message: error.message,\n error: 'PLUGIN_NOT_FOUND',\n debug: { duration, pluginID: config.pluginID },\n },\n HttpStatus.INTERNAL_SERVER_ERROR,\n );\n }\n\n if (error instanceof ActionNotFoundError) {\n throw new HttpException(\n {\n code: 1,\n message: error.message,\n error: 'ACTION_NOT_FOUND',\n debug: { duration, pluginID: config.pluginID },\n },\n HttpStatus.BAD_REQUEST,\n );\n }\n\n throw new HttpException(\n {\n code: 1,\n message: error instanceof Error ? error.message : String(error),\n error: 'EXECUTION_ERROR',\n debug: {\n duration,\n pluginID: config.pluginID,\n resolvedParams,\n },\n },\n HttpStatus.INTERNAL_SERVER_ERROR,\n );\n }\n }\n}\n","import {\n Controller,\n Post,\n Param,\n Body,\n HttpException,\n HttpStatus,\n} from '@nestjs/common';\nimport {\n CapabilityService,\n CapabilityNotFoundError,\n ActionNotFoundError,\n} from '../services/capability.service';\nimport { PluginNotFoundError } from '../services/plugin-loader.service';\n\ninterface ExecuteRequestBody {\n action: string;\n params: Record<string, unknown>;\n}\n\ninterface ExecuteResponse {\n code: number;\n message: string;\n data: unknown;\n}\n\n@Controller('api/capability')\nexport class WebhookController {\n constructor(private readonly capabilityService: CapabilityService) {}\n\n @Post(':capability_id')\n async execute(\n @Param('capability_id') capabilityId: string,\n @Body() body: ExecuteRequestBody,\n ): Promise<ExecuteResponse> {\n try {\n const result = await this.capabilityService\n .load(capabilityId)\n .call(body.action, body.params);\n\n return {\n code: 0,\n message: 'success',\n data: result,\n };\n } catch (error) {\n if (error instanceof CapabilityNotFoundError) {\n throw new HttpException(\n {\n code: 1,\n message: error.message,\n error: 'CAPABILITY_NOT_FOUND',\n },\n HttpStatus.NOT_FOUND,\n );\n }\n\n if (error instanceof PluginNotFoundError) {\n throw new HttpException(\n {\n code: 1,\n message: error.message,\n error: 'PLUGIN_NOT_FOUND',\n },\n HttpStatus.INTERNAL_SERVER_ERROR,\n );\n }\n\n if (error instanceof ActionNotFoundError) {\n throw new HttpException(\n {\n code: 1,\n message: error.message,\n error: 'ACTION_NOT_FOUND',\n },\n HttpStatus.BAD_REQUEST,\n );\n }\n\n throw new HttpException(\n {\n code: 1,\n message: error instanceof Error ? error.message : String(error),\n error: 'EXECUTION_ERROR',\n },\n HttpStatus.INTERNAL_SERVER_ERROR,\n );\n }\n }\n}\n","import { Module, DynamicModule, Type } from '@nestjs/common';\nimport {\n RequestContextService,\n PLATFORM_HTTP_CLIENT,\n} from '@lark-apaas/nestjs-common';\nimport { DebugController, WebhookController } from './controllers';\nimport {\n CapabilityService,\n PluginLoaderService,\n TemplateEngineService,\n type CapabilityModuleOptions,\n} from './services';\n\nconst CAPABILITY_OPTIONS = Symbol('CAPABILITY_OPTIONS');\n\nconst isDevelopment = process.env.NODE_ENV === 'development';\n\nfunction getControllers(): Type[] {\n const controllers: Type[] = [WebhookController];\n if (isDevelopment) {\n controllers.push(DebugController);\n }\n return controllers;\n}\n\n@Module({\n controllers: getControllers(),\n providers: [CapabilityService, PluginLoaderService, TemplateEngineService],\n exports: [CapabilityService],\n})\nexport class CapabilityModule {\n static forRoot(options?: CapabilityModuleOptions): DynamicModule {\n return {\n module: CapabilityModule,\n controllers: getControllers(),\n providers: [\n {\n provide: CAPABILITY_OPTIONS,\n useValue: options ?? {},\n },\n {\n provide: CapabilityService,\n useFactory: (\n requestContextService: RequestContextService,\n httpClient: any,\n pluginLoader: PluginLoaderService,\n templateEngine: TemplateEngineService,\n moduleOptions: CapabilityModuleOptions,\n ) => {\n const service = new CapabilityService(\n requestContextService,\n httpClient,\n pluginLoader,\n templateEngine,\n );\n if (moduleOptions?.capabilitiesDir) {\n service.setCapabilitiesDir(moduleOptions.capabilitiesDir);\n }\n return service;\n },\n inject: [\n RequestContextService,\n PLATFORM_HTTP_CLIENT,\n PluginLoaderService,\n TemplateEngineService,\n CAPABILITY_OPTIONS,\n ],\n },\n PluginLoaderService,\n TemplateEngineService,\n ],\n exports: [Capab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UAAUY,OAAOV,KAAAA;QACzDA,OAAO;MACT,GACAG,0BAAWG,qBAAqB;IAEpC;EACF;AACF;;;;;;;;;;;;;;;;;;;;;ACzFA,IAAAK,iBAA4C;AAC5C,IAAAC,wBAGO;;;;;;;;AASP,IAAMC,qBAAqBC,uBAAO,oBAAA;AAElC,IAAMC,gBAAgBC,QAAQC,IAAIC,aAAa;AAE/C,SAASC,iBAAAA;AACP,QAAMC,cAAsB;IAACC;;AAC7B,MAAIN,eAAe;AACjBK,gBAAYE,KAAKC,eAAAA;EACnB;AACA,SAAOH;AACT;AANSD;AAaF,IAAMK,mBAAN,MAAMA,kBAAAA;SAAAA;;;EACX,OAAOC,QAAQC,SAAkD;AAC/D,WAAO;MACLC,QAAQH;MACRJ,aAAaD,eAAAA;MACbS,WAAW;QACT;UACEC,SAAShB;UACTiB,UAAUJ,WAAW,CAAC;QACxB;QACA;UACEG,SAASE;UACTC,YAAY,wBACVC,uBACAC,YACAC,cACAC,gBACAC,kBAAAA;AAEA,kBAAMC,UAAU,IAAIP,kBAClBE,uBACAC,YACAC,cACAC,cAAAA;AAEF,gBAAIC,eAAeE,iBAAiB;AAClCD,sBAAQE,mBAAmBH,cAAcE,eAAe;YAC1D;AACA,mBAAOD;UACT,GAjBY;UAkBZG,QAAQ;YACNC;YACAC;YACAC;YACAC;YACAhC;;QAEJ;QACA+B;QACAC;;MAEFC,SAAS;QAACf;;IACZ;EACF;AACF;;;IAhDEX,aAAaD,eAAAA;IACbS,WAAW;MAACG;MAAmBa;MAAqBC;;IACpDC,SAAS;MAACf;;;;","names":["TemplateEngineService","TEMPLATE_REGEX","resolve","template","input","resolveString","Array","isArray","map","item","resolveObject","match","path","getValueByPath","result","key","value","Object","entries","obj","keys","split","current","undefined","import_common","PluginNotFoundError","Error","pluginID","name","PluginLoadError","reason","PluginLoaderService","logger","Logger","pluginInstances","Map","loadPlugin","cached","get","debug","log","pluginPackage","require","create","instance","set","error","code","message","String","isPluginInstalled","resolve","clearCache","delete","clear","import_common","CapabilityNotFoundError","Error","capabilityId","name","ActionNotFoundError","pluginID","actionName","CapabilityService","logger","Logger","capabilities","Map","capabilitiesDir","requestContextService","httpClient","pluginLoaderService","templateEngineService","join","process","cwd","setCapabilitiesDir","dir","onModuleInit","loadCapabilities","log","existsSync","warn","files","readdirSync","filter","f","endsWith","file","filePath","content","readFileSync","config","JSON","parse","id","set","error","size","listCapabilities","Array","from","values","getCapability","get","load","call","input","contextOverride","execute","startTime","Date","now","pluginInstance","loadPlugin","hasAction","resolvedParams","resolve","formValue","context","buildActionContext","message","action","result","run","duration","String","override","userContext","getUserContext","ctx","getContext","userId","tenantId","import_common","DebugController","capabilityService","templateEngineService","list","capabilities","listCapabilities","code","message","data","map","c","id","name","pluginID","pluginVersion","debug","capabilityId","body","startTime","Date","now","config","getCapability","HttpException","error","HttpStatus","NOT_FOUND","resolvedParams","resolve","formValue","params","result","load","call","action","capabilityConfig","duration","CapabilityNotFoundError","PluginNotFoundError","INTERNAL_SERVER_ERROR","ActionNotFoundError","BAD_REQUEST","Error","String","import_common","WebhookController","capabilityService","execute","capabilityId","body","result","load","call","action","params","code","message","data","error","CapabilityNotFoundError","HttpException","HttpStatus","NOT_FOUND","PluginNotFoundError","INTERNAL_SERVER_ERROR","ActionNotFoundError","BAD_REQUEST","Error","String","import_common","import_nestjs_common","CAPABILITY_OPTIONS","Symbol","isDevelopment","process","env","NODE_ENV","getControllers","controllers","WebhookController","push","DebugController","CapabilityModule","forRoot","options","module","providers","provide","useValue","CapabilityService","useFactory","requestContextService","httpClient","pluginLoader","templateEngine","moduleOptions","service","capabilitiesDir","setCapabilitiesDir","inject","RequestContextService","PLATFORM_HTTP_CLIENT","PluginLoaderService","TemplateEngineService","exports"]}
@@ -0,0 +1,156 @@
1
+ import { Logger, OnModuleInit, DynamicModule } from '@nestjs/common';
2
+ import { PlatformHttpClient, RequestContextService } from '@lark-apaas/nestjs-common';
3
+ import { ZodSchema } from 'zod';
4
+
5
+ interface UserContext {
6
+ userId: string;
7
+ tenantId: string;
8
+ }
9
+ interface PluginActionContext {
10
+ logger: Logger;
11
+ httpClient: PlatformHttpClient;
12
+ userContext: UserContext;
13
+ }
14
+
15
+ interface ActionSchema {
16
+ input: ZodSchema | ((config: unknown) => ZodSchema);
17
+ output?: ZodSchema | ((input: unknown, config: unknown) => ZodSchema);
18
+ }
19
+ interface PluginInstance {
20
+ run(actionName: string, context: PluginActionContext, input: unknown): Promise<unknown>;
21
+ hasAction(actionName: string): boolean;
22
+ getActionSchema(actionName: string): ActionSchema | null;
23
+ getInputSchema(actionName: string, config?: unknown): ZodSchema | undefined;
24
+ getOutputSchema(actionName: string, input: unknown, config?: unknown): ZodSchema | undefined;
25
+ listActions(): string[];
26
+ }
27
+ interface PluginPackage {
28
+ create(): PluginInstance;
29
+ }
30
+
31
+ interface JSONSchema {
32
+ type?: string;
33
+ properties?: Record<string, JSONSchema>;
34
+ required?: string[];
35
+ items?: JSONSchema;
36
+ [key: string]: unknown;
37
+ }
38
+ interface CapabilityConfig {
39
+ id: string;
40
+ pluginID: string;
41
+ pluginVersion: string;
42
+ name: string;
43
+ description: string;
44
+ paramsSchema: JSONSchema;
45
+ formValue: Record<string, unknown>;
46
+ createdAt: number;
47
+ updatedAt: number;
48
+ }
49
+
50
+ declare class TemplateEngineService {
51
+ private readonly TEMPLATE_REGEX;
52
+ resolve(template: unknown, input: Record<string, unknown>): unknown;
53
+ private resolveString;
54
+ private resolveObject;
55
+ private getValueByPath;
56
+ }
57
+
58
+ declare class PluginNotFoundError extends Error {
59
+ constructor(pluginID: string);
60
+ }
61
+ declare class PluginLoadError extends Error {
62
+ constructor(pluginID: string, reason: string);
63
+ }
64
+ declare class PluginLoaderService {
65
+ private readonly logger;
66
+ private readonly pluginInstances;
67
+ loadPlugin(pluginID: string): PluginInstance;
68
+ isPluginInstalled(pluginID: string): boolean;
69
+ clearCache(pluginID?: string): void;
70
+ }
71
+
72
+ declare class CapabilityNotFoundError extends Error {
73
+ constructor(capabilityId: string);
74
+ }
75
+ declare class ActionNotFoundError extends Error {
76
+ constructor(pluginID: string, actionName: string);
77
+ }
78
+ interface CapabilityExecutor {
79
+ call(actionName: string, input: unknown, context?: Partial<PluginActionContext>): Promise<unknown>;
80
+ }
81
+ interface CapabilityModuleOptions {
82
+ capabilitiesDir?: string;
83
+ }
84
+ declare class CapabilityService implements OnModuleInit {
85
+ private readonly requestContextService;
86
+ private readonly httpClient;
87
+ private readonly pluginLoaderService;
88
+ private readonly templateEngineService;
89
+ private readonly logger;
90
+ private readonly capabilities;
91
+ private capabilitiesDir;
92
+ constructor(requestContextService: RequestContextService, httpClient: PlatformHttpClient, pluginLoaderService: PluginLoaderService, templateEngineService: TemplateEngineService);
93
+ setCapabilitiesDir(dir: string): void;
94
+ onModuleInit(): Promise<void>;
95
+ private loadCapabilities;
96
+ listCapabilities(): CapabilityConfig[];
97
+ getCapability(capabilityId: string): CapabilityConfig | null;
98
+ load(capabilityId: string): CapabilityExecutor;
99
+ private execute;
100
+ private buildActionContext;
101
+ private getUserContext;
102
+ }
103
+
104
+ interface ExecuteRequestBody$1 {
105
+ action: string;
106
+ params: Record<string, unknown>;
107
+ }
108
+ interface DebugResponse {
109
+ code: number;
110
+ message: string;
111
+ data: unknown;
112
+ debug?: {
113
+ capabilityConfig: unknown;
114
+ resolvedParams: unknown;
115
+ duration: number;
116
+ pluginID: string;
117
+ };
118
+ }
119
+ interface ListResponse {
120
+ code: number;
121
+ message: string;
122
+ data: Array<{
123
+ id: string;
124
+ name: string;
125
+ pluginID: string;
126
+ pluginVersion: string;
127
+ }>;
128
+ }
129
+ declare class DebugController {
130
+ private readonly capabilityService;
131
+ private readonly templateEngineService;
132
+ constructor(capabilityService: CapabilityService, templateEngineService: TemplateEngineService);
133
+ list(): ListResponse;
134
+ debug(capabilityId: string, body: ExecuteRequestBody$1): Promise<DebugResponse>;
135
+ }
136
+
137
+ interface ExecuteRequestBody {
138
+ action: string;
139
+ params: Record<string, unknown>;
140
+ }
141
+ interface ExecuteResponse {
142
+ code: number;
143
+ message: string;
144
+ data: unknown;
145
+ }
146
+ declare class WebhookController {
147
+ private readonly capabilityService;
148
+ constructor(capabilityService: CapabilityService);
149
+ execute(capabilityId: string, body: ExecuteRequestBody): Promise<ExecuteResponse>;
150
+ }
151
+
152
+ declare class CapabilityModule {
153
+ static forRoot(options?: CapabilityModuleOptions): DynamicModule;
154
+ }
155
+
156
+ export { ActionNotFoundError, type ActionSchema, type CapabilityConfig, type CapabilityExecutor, CapabilityModule, type CapabilityModuleOptions, CapabilityNotFoundError, CapabilityService, DebugController, type JSONSchema, type PluginActionContext, type PluginInstance, PluginLoadError, PluginLoaderService, PluginNotFoundError, type PluginPackage, TemplateEngineService, type UserContext, WebhookController };
@@ -0,0 +1,156 @@
1
+ import { Logger, OnModuleInit, DynamicModule } from '@nestjs/common';
2
+ import { PlatformHttpClient, RequestContextService } from '@lark-apaas/nestjs-common';
3
+ import { ZodSchema } from 'zod';
4
+
5
+ interface UserContext {
6
+ userId: string;
7
+ tenantId: string;
8
+ }
9
+ interface PluginActionContext {
10
+ logger: Logger;
11
+ httpClient: PlatformHttpClient;
12
+ userContext: UserContext;
13
+ }
14
+
15
+ interface ActionSchema {
16
+ input: ZodSchema | ((config: unknown) => ZodSchema);
17
+ output?: ZodSchema | ((input: unknown, config: unknown) => ZodSchema);
18
+ }
19
+ interface PluginInstance {
20
+ run(actionName: string, context: PluginActionContext, input: unknown): Promise<unknown>;
21
+ hasAction(actionName: string): boolean;
22
+ getActionSchema(actionName: string): ActionSchema | null;
23
+ getInputSchema(actionName: string, config?: unknown): ZodSchema | undefined;
24
+ getOutputSchema(actionName: string, input: unknown, config?: unknown): ZodSchema | undefined;
25
+ listActions(): string[];
26
+ }
27
+ interface PluginPackage {
28
+ create(): PluginInstance;
29
+ }
30
+
31
+ interface JSONSchema {
32
+ type?: string;
33
+ properties?: Record<string, JSONSchema>;
34
+ required?: string[];
35
+ items?: JSONSchema;
36
+ [key: string]: unknown;
37
+ }
38
+ interface CapabilityConfig {
39
+ id: string;
40
+ pluginID: string;
41
+ pluginVersion: string;
42
+ name: string;
43
+ description: string;
44
+ paramsSchema: JSONSchema;
45
+ formValue: Record<string, unknown>;
46
+ createdAt: number;
47
+ updatedAt: number;
48
+ }
49
+
50
+ declare class TemplateEngineService {
51
+ private readonly TEMPLATE_REGEX;
52
+ resolve(template: unknown, input: Record<string, unknown>): unknown;
53
+ private resolveString;
54
+ private resolveObject;
55
+ private getValueByPath;
56
+ }
57
+
58
+ declare class PluginNotFoundError extends Error {
59
+ constructor(pluginID: string);
60
+ }
61
+ declare class PluginLoadError extends Error {
62
+ constructor(pluginID: string, reason: string);
63
+ }
64
+ declare class PluginLoaderService {
65
+ private readonly logger;
66
+ private readonly pluginInstances;
67
+ loadPlugin(pluginID: string): PluginInstance;
68
+ isPluginInstalled(pluginID: string): boolean;
69
+ clearCache(pluginID?: string): void;
70
+ }
71
+
72
+ declare class CapabilityNotFoundError extends Error {
73
+ constructor(capabilityId: string);
74
+ }
75
+ declare class ActionNotFoundError extends Error {
76
+ constructor(pluginID: string, actionName: string);
77
+ }
78
+ interface CapabilityExecutor {
79
+ call(actionName: string, input: unknown, context?: Partial<PluginActionContext>): Promise<unknown>;
80
+ }
81
+ interface CapabilityModuleOptions {
82
+ capabilitiesDir?: string;
83
+ }
84
+ declare class CapabilityService implements OnModuleInit {
85
+ private readonly requestContextService;
86
+ private readonly httpClient;
87
+ private readonly pluginLoaderService;
88
+ private readonly templateEngineService;
89
+ private readonly logger;
90
+ private readonly capabilities;
91
+ private capabilitiesDir;
92
+ constructor(requestContextService: RequestContextService, httpClient: PlatformHttpClient, pluginLoaderService: PluginLoaderService, templateEngineService: TemplateEngineService);
93
+ setCapabilitiesDir(dir: string): void;
94
+ onModuleInit(): Promise<void>;
95
+ private loadCapabilities;
96
+ listCapabilities(): CapabilityConfig[];
97
+ getCapability(capabilityId: string): CapabilityConfig | null;
98
+ load(capabilityId: string): CapabilityExecutor;
99
+ private execute;
100
+ private buildActionContext;
101
+ private getUserContext;
102
+ }
103
+
104
+ interface ExecuteRequestBody$1 {
105
+ action: string;
106
+ params: Record<string, unknown>;
107
+ }
108
+ interface DebugResponse {
109
+ code: number;
110
+ message: string;
111
+ data: unknown;
112
+ debug?: {
113
+ capabilityConfig: unknown;
114
+ resolvedParams: unknown;
115
+ duration: number;
116
+ pluginID: string;
117
+ };
118
+ }
119
+ interface ListResponse {
120
+ code: number;
121
+ message: string;
122
+ data: Array<{
123
+ id: string;
124
+ name: string;
125
+ pluginID: string;
126
+ pluginVersion: string;
127
+ }>;
128
+ }
129
+ declare class DebugController {
130
+ private readonly capabilityService;
131
+ private readonly templateEngineService;
132
+ constructor(capabilityService: CapabilityService, templateEngineService: TemplateEngineService);
133
+ list(): ListResponse;
134
+ debug(capabilityId: string, body: ExecuteRequestBody$1): Promise<DebugResponse>;
135
+ }
136
+
137
+ interface ExecuteRequestBody {
138
+ action: string;
139
+ params: Record<string, unknown>;
140
+ }
141
+ interface ExecuteResponse {
142
+ code: number;
143
+ message: string;
144
+ data: unknown;
145
+ }
146
+ declare class WebhookController {
147
+ private readonly capabilityService;
148
+ constructor(capabilityService: CapabilityService);
149
+ execute(capabilityId: string, body: ExecuteRequestBody): Promise<ExecuteResponse>;
150
+ }
151
+
152
+ declare class CapabilityModule {
153
+ static forRoot(options?: CapabilityModuleOptions): DynamicModule;
154
+ }
155
+
156
+ export { ActionNotFoundError, type ActionSchema, type CapabilityConfig, type CapabilityExecutor, CapabilityModule, type CapabilityModuleOptions, CapabilityNotFoundError, CapabilityService, DebugController, type JSONSchema, type PluginActionContext, type PluginInstance, PluginLoadError, PluginLoaderService, PluginNotFoundError, type PluginPackage, TemplateEngineService, type UserContext, WebhookController };