@majkapp/plugin-kit 3.7.0 → 3.7.2
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.
- package/dist/generator/cli.js +0 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/majk-interface-types.d.ts +463 -0
- package/dist/majk-interface-types.d.ts.map +1 -1
- package/dist/plugin-kit.d.ts +90 -1
- package/dist/plugin-kit.d.ts.map +1 -1
- package/dist/plugin-kit.js +62 -0
- package/dist/types.d.ts +94 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/transports.d.ts +0 -59
- package/dist/transports.d.ts.map +0 -1
- package/dist/transports.js +0 -171
package/package.json
CHANGED
package/dist/transports.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { Transport, TransportMetadata, FunctionRegistry, PluginContext, RequestLike, ResponseLike } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* HTTP Transport configuration
|
|
4
|
-
*/
|
|
5
|
-
export interface HttpTransportConfig {
|
|
6
|
-
basePath?: string;
|
|
7
|
-
cors?: boolean;
|
|
8
|
-
validation?: {
|
|
9
|
-
request?: boolean;
|
|
10
|
-
response?: boolean;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* HTTP Transport implementation
|
|
15
|
-
*/
|
|
16
|
-
export declare class HttpTransport implements Transport {
|
|
17
|
-
name: string;
|
|
18
|
-
private registry?;
|
|
19
|
-
private context?;
|
|
20
|
-
private config;
|
|
21
|
-
constructor(config?: HttpTransportConfig);
|
|
22
|
-
initialize(registry: FunctionRegistry, context: PluginContext): Promise<void>;
|
|
23
|
-
start(): Promise<void>;
|
|
24
|
-
stop(): Promise<void>;
|
|
25
|
-
getMetadata(): TransportMetadata;
|
|
26
|
-
/**
|
|
27
|
-
* Handle a function call via HTTP
|
|
28
|
-
*/
|
|
29
|
-
handleFunctionCall(functionName: string, req: RequestLike, res: ResponseLike, ctx: any): Promise<void>;
|
|
30
|
-
/**
|
|
31
|
-
* Get discovery information
|
|
32
|
-
*/
|
|
33
|
-
getDiscovery(): any;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* WebSocket Transport (placeholder for future implementation)
|
|
37
|
-
*/
|
|
38
|
-
export declare class WebSocketTransport implements Transport {
|
|
39
|
-
name: string;
|
|
40
|
-
private config;
|
|
41
|
-
constructor(config?: any);
|
|
42
|
-
initialize(registry: FunctionRegistry, context: PluginContext): Promise<void>;
|
|
43
|
-
start(): Promise<void>;
|
|
44
|
-
stop(): Promise<void>;
|
|
45
|
-
getMetadata(): TransportMetadata;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* MCP Transport (placeholder for future implementation)
|
|
49
|
-
*/
|
|
50
|
-
export declare class MCPTransport implements Transport {
|
|
51
|
-
name: string;
|
|
52
|
-
private config;
|
|
53
|
-
constructor(config?: any);
|
|
54
|
-
initialize(registry: FunctionRegistry, context: PluginContext): Promise<void>;
|
|
55
|
-
start(): Promise<void>;
|
|
56
|
-
stop(): Promise<void>;
|
|
57
|
-
getMetadata(): TransportMetadata;
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=transports.d.ts.map
|
package/dist/transports.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transports.d.ts","sourceRoot":"","sources":["../src/transports.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE;QACX,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;C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C;IAI3B,WAAW,IAAI,iBAAiB;CAMjC"}
|
package/dist/transports.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MCPTransport = exports.WebSocketTransport = exports.HttpTransport = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* HTTP Transport implementation
|
|
6
|
-
*/
|
|
7
|
-
class HttpTransport {
|
|
8
|
-
constructor(config = {}) {
|
|
9
|
-
this.name = 'http';
|
|
10
|
-
this.config = {
|
|
11
|
-
basePath: config.basePath || '/api',
|
|
12
|
-
cors: config.cors !== false,
|
|
13
|
-
validation: {
|
|
14
|
-
request: config.validation?.request !== false,
|
|
15
|
-
response: config.validation?.response !== false
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
async initialize(registry, context) {
|
|
20
|
-
this.registry = registry;
|
|
21
|
-
this.context = context;
|
|
22
|
-
context.logger.info(`HTTP Transport initialized with base path ${this.config.basePath}`);
|
|
23
|
-
}
|
|
24
|
-
async start() {
|
|
25
|
-
// HTTP server is managed by the BuiltPlugin
|
|
26
|
-
// This transport just provides the route handlers
|
|
27
|
-
}
|
|
28
|
-
async stop() {
|
|
29
|
-
// Cleanup if needed
|
|
30
|
-
}
|
|
31
|
-
getMetadata() {
|
|
32
|
-
// Use the baseUrl from context if available, otherwise construct from context.http
|
|
33
|
-
const baseUrl = this.context?.http?.baseUrl || '';
|
|
34
|
-
return {
|
|
35
|
-
type: 'http',
|
|
36
|
-
endpoint: `${baseUrl}${this.config.basePath}`,
|
|
37
|
-
discovery: `${baseUrl}${this.config.basePath}/discovery`
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Handle a function call via HTTP
|
|
42
|
-
*/
|
|
43
|
-
async handleFunctionCall(functionName, req, res, ctx) {
|
|
44
|
-
if (!this.registry) {
|
|
45
|
-
res.status(500);
|
|
46
|
-
res.json({ success: false, error: 'Transport not initialized' });
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const func = this.registry.functions.get(functionName);
|
|
50
|
-
if (!func) {
|
|
51
|
-
res.status(404);
|
|
52
|
-
res.json({ success: false, error: `Function "${functionName}" not found` });
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
try {
|
|
56
|
-
// Get input from request body
|
|
57
|
-
const input = req.body || {};
|
|
58
|
-
// Validate input if configured
|
|
59
|
-
if (this.config.validation?.request) {
|
|
60
|
-
// TODO: Add actual JSON Schema validation here
|
|
61
|
-
// For now, just check basic structure
|
|
62
|
-
if (func.input.type === 'object' && typeof input !== 'object') {
|
|
63
|
-
res.status(400);
|
|
64
|
-
res.json({
|
|
65
|
-
success: false,
|
|
66
|
-
error: 'Invalid input',
|
|
67
|
-
details: ['Input must be an object']
|
|
68
|
-
});
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
// Call the function handler
|
|
73
|
-
const output = await func.handler(input, this.context);
|
|
74
|
-
// Return success response
|
|
75
|
-
res.json({ success: true, data: output });
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
this.context?.logger.error(`Function "${functionName}" error: ${error.message}`);
|
|
79
|
-
res.status(500);
|
|
80
|
-
res.json({
|
|
81
|
-
success: false,
|
|
82
|
-
error: error.message || 'Internal server error'
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Get discovery information
|
|
88
|
-
*/
|
|
89
|
-
getDiscovery() {
|
|
90
|
-
if (!this.registry) {
|
|
91
|
-
return { error: 'Transport not initialized' };
|
|
92
|
-
}
|
|
93
|
-
const functions = [];
|
|
94
|
-
for (const [name, func] of this.registry.functions) {
|
|
95
|
-
functions.push({
|
|
96
|
-
name,
|
|
97
|
-
description: func.description,
|
|
98
|
-
input: func.input,
|
|
99
|
-
output: func.output,
|
|
100
|
-
tags: func.tags,
|
|
101
|
-
deprecated: func.deprecated
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
const subscriptions = [];
|
|
105
|
-
for (const [name, sub] of this.registry.subscriptions) {
|
|
106
|
-
subscriptions.push({
|
|
107
|
-
name,
|
|
108
|
-
description: sub.description,
|
|
109
|
-
input: sub.input,
|
|
110
|
-
output: sub.output
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
plugin: this.registry.plugin,
|
|
115
|
-
functions,
|
|
116
|
-
subscriptions,
|
|
117
|
-
transports: [this.getMetadata()]
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
exports.HttpTransport = HttpTransport;
|
|
122
|
-
/**
|
|
123
|
-
* WebSocket Transport (placeholder for future implementation)
|
|
124
|
-
*/
|
|
125
|
-
class WebSocketTransport {
|
|
126
|
-
constructor(config = {}) {
|
|
127
|
-
this.name = 'websocket';
|
|
128
|
-
this.config = config;
|
|
129
|
-
}
|
|
130
|
-
async initialize(registry, context) {
|
|
131
|
-
context.logger.info('WebSocket Transport initialized (not yet implemented)');
|
|
132
|
-
}
|
|
133
|
-
async start() {
|
|
134
|
-
// TODO: Implement WebSocket server
|
|
135
|
-
}
|
|
136
|
-
async stop() {
|
|
137
|
-
// TODO: Stop WebSocket server
|
|
138
|
-
}
|
|
139
|
-
getMetadata() {
|
|
140
|
-
return {
|
|
141
|
-
type: 'websocket',
|
|
142
|
-
endpoint: `ws://localhost:${this.config.port || 3001}${this.config.path || '/ws'}`
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
exports.WebSocketTransport = WebSocketTransport;
|
|
147
|
-
/**
|
|
148
|
-
* MCP Transport (placeholder for future implementation)
|
|
149
|
-
*/
|
|
150
|
-
class MCPTransport {
|
|
151
|
-
constructor(config = {}) {
|
|
152
|
-
this.name = 'mcp';
|
|
153
|
-
this.config = config;
|
|
154
|
-
}
|
|
155
|
-
async initialize(registry, context) {
|
|
156
|
-
context.logger.info('MCP Transport initialized (not yet implemented)');
|
|
157
|
-
}
|
|
158
|
-
async start() {
|
|
159
|
-
// TODO: Register functions as MCP tools
|
|
160
|
-
}
|
|
161
|
-
async stop() {
|
|
162
|
-
// TODO: Cleanup MCP registration
|
|
163
|
-
}
|
|
164
|
-
getMetadata() {
|
|
165
|
-
return {
|
|
166
|
-
type: 'mcp',
|
|
167
|
-
name: this.config.name || 'plugin-mcp-server'
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
exports.MCPTransport = MCPTransport;
|