@open-wa/api 5.0.0 → 5.1.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,466 @@
1
+ import { Hono } from 'hono';
2
+ import { cors } from 'hono/cors';
3
+ import { logger } from 'hono/logger';
4
+ import { createAdaptorServer, upgradeWebSocket } from '@hono/node-server';
5
+ import { createServer, type Server } from 'node:http';
6
+ import { WebSocketServer } from 'ws';
7
+ import { getHttpMethodDefinitions, type Config } from '@open-wa/schema';
8
+ import '@open-wa/schema';
9
+ import {
10
+ createScreencastRoute,
11
+ ScreencastManager,
12
+ } from '@open-wa/screencaster/server';
13
+ import { createApiMiddleware } from './createApiMiddleware';
14
+ import { createHonoMcpAdapter } from '@open-wa/mcp';
15
+ import { registerMetaRoutes } from './routes/meta';
16
+ import { registerDebugRoutes } from './routes/debug';
17
+ import { registerAgentDiscoveryRoutes } from './routes/agent-discovery';
18
+ import { type EventBridge } from './events/EventBridge';
19
+ import { HealthStore } from './health/HealthStore';
20
+ import { EventBroadcaster } from './events/EventBroadcaster';
21
+ import { ElasticEmitter } from './monitoring/elastic';
22
+ import {
23
+ setupViteDevServer,
24
+ mountDashboardProduction,
25
+ } from './dashboard/middleware';
26
+ import type { ApiServerOptions, ClientMethodMap } from './types';
27
+ import type { IScreencastPage } from '@open-wa/screencaster/server';
28
+ import type { PluginHost } from '@open-wa/core';
29
+
30
+ function parseCorsOrigin(corsConfig: string | string[]): string | string[] {
31
+ if (corsConfig === '*') {
32
+ return '*';
33
+ }
34
+
35
+ if (Array.isArray(corsConfig)) {
36
+ return corsConfig;
37
+ }
38
+
39
+ if (typeof corsConfig === 'string' && corsConfig.includes(',')) {
40
+ return corsConfig.split(',').map((origin) => origin.trim());
41
+ }
42
+
43
+ return corsConfig;
44
+ }
45
+
46
+ export class ApiServer {
47
+ private app: Hono;
48
+ private config: Config;
49
+ private client: ClientMethodMap | undefined;
50
+ private elasticEmitter?: ElasticEmitter;
51
+ private latestQR: string | null = null;
52
+ private screencastManager: ScreencastManager;
53
+ private server?: Server;
54
+ private isDashboardActive: boolean = false;
55
+ private pluginHost?: PluginHost;
56
+ private healthStore: HealthStore = new HealthStore();
57
+ private eventBroadcaster: EventBroadcaster;
58
+ private eventBridge?: EventBridge;
59
+ private eventBridgeListener?: (event: string, payload: any) => void;
60
+ private readinessProvider?: () =>
61
+ | {
62
+ state?: string;
63
+ status?: string;
64
+ ready: boolean;
65
+ exposureSafe?: boolean;
66
+ pending?: string[];
67
+ blockers?: string[];
68
+ }
69
+ | undefined;
70
+
71
+ constructor(options: ApiServerOptions) {
72
+ this.config = options.config;
73
+
74
+ // Validate MCP configuration
75
+ if (this.config.mcp?.enabled && !this.config.apiKey) {
76
+ throw new Error(
77
+ 'MCP requires Easy API apiKey. Refusing to start with MCP enabled and no apiKey configured.',
78
+ );
79
+ }
80
+
81
+ this.app = new Hono();
82
+ this.screencastManager = new ScreencastManager();
83
+ this.eventBroadcaster = new EventBroadcaster(this.config.sessionId);
84
+
85
+ if (this.config.elasticUrl) {
86
+ this.elasticEmitter = new ElasticEmitter({
87
+ url: this.config.elasticUrl,
88
+ username: this.config.elasticUsername,
89
+ password: this.config.elasticPassword,
90
+ bufferSize: this.config.elasticBufferSize,
91
+ pipeline: this.config.elasticPipeline,
92
+ indexPrefix: this.config.elasticIndexPrefix,
93
+ });
94
+ }
95
+
96
+ this.setupMiddleware();
97
+ this.registerRoutes();
98
+
99
+ // Register screencast WebSocket route
100
+ this.app.get(
101
+ '/screencast',
102
+ createScreencastRoute(upgradeWebSocket, this.screencastManager),
103
+ );
104
+ }
105
+
106
+ public setClient(client: ClientMethodMap | undefined) {
107
+ this.client = client;
108
+ }
109
+
110
+ public setEventBridge(bridge: EventBridge) {
111
+ if (this.eventBridge && this.eventBridgeListener) {
112
+ this.eventBridge.offAny(this.eventBridgeListener);
113
+ }
114
+
115
+ this.eventBridge = bridge;
116
+ this.eventBridgeListener = (event: string, payload: any) => {
117
+ this.healthStore.processEvent(event, payload);
118
+ this.eventBroadcaster.broadcast(event, payload);
119
+ };
120
+
121
+ // Also wire events into the HealthStore so /health returns accumulated data
122
+ bridge.onAny(this.eventBridgeListener);
123
+ }
124
+
125
+ public setReadinessProvider(
126
+ provider:
127
+ | (() =>
128
+ | {
129
+ state?: string;
130
+ status?: string;
131
+ ready: boolean;
132
+ exposureSafe?: boolean;
133
+ pending?: string[];
134
+ blockers?: string[];
135
+ }
136
+ | undefined)
137
+ | undefined,
138
+ ) {
139
+ this.readinessProvider = provider;
140
+ }
141
+
142
+ /**
143
+ * Bind a CDP-capable page for screencasting.
144
+ * Call this once the browser page is ready.
145
+ */
146
+ public async setPage(page: IScreencastPage): Promise<void> {
147
+ await this.screencastManager.setPage(page);
148
+ }
149
+
150
+ /**
151
+ * Unbind the screencaster page (session ended).
152
+ */
153
+ public async clearPage(): Promise<void> {
154
+ await this.screencastManager.clearPage();
155
+ }
156
+
157
+ public setQR(qr: string) {
158
+ this.latestQR = qr;
159
+ }
160
+
161
+ public getApp() {
162
+ return this.app;
163
+ }
164
+
165
+ public getEventBroadcaster() {
166
+ return this.eventBroadcaster;
167
+ }
168
+
169
+ /**
170
+ * Mount plugin routes and manifest endpoint.
171
+ * Call this after the PluginHost has all plugins registered.
172
+ */
173
+ public mountPlugins(pluginHost: PluginHost): void {
174
+ this.pluginHost = pluginHost;
175
+
176
+ // Mount each plugin's routes at /plugins/<name>/
177
+ for (const { name, router } of pluginHost.getRoutes()) {
178
+ this.app.route(`/plugins/${name}`, router);
179
+ }
180
+ }
181
+
182
+ public async start() {
183
+ let viteDevServer: any = null;
184
+ if (this.config.dashboard) {
185
+ viteDevServer = await setupViteDevServer();
186
+ if (!viteDevServer) {
187
+ this.isDashboardActive = await mountDashboardProduction(this.app);
188
+ } else {
189
+ this.isDashboardActive = true;
190
+ }
191
+ }
192
+
193
+ const server = createAdaptorServer({
194
+ fetch: this.app.fetch,
195
+ websocket: {
196
+ server: new WebSocketServer({ noServer: true }),
197
+ },
198
+ createServer: (options, honoListener) =>
199
+ createServer(options, (request, response) => {
200
+ if (viteDevServer && request.url?.startsWith('/dashboard')) {
201
+ viteDevServer.middlewares(request, response, () => {
202
+ void honoListener(request, response);
203
+ });
204
+ return;
205
+ }
206
+ void honoListener(request, response);
207
+ }),
208
+ });
209
+ this.server = server as Server;
210
+
211
+ await new Promise<void>((resolve, reject) => {
212
+ const onError = (error: Error) => {
213
+ server.off('error', onError);
214
+ reject(error);
215
+ };
216
+ server.once('error', onError);
217
+ server.listen(this.config.port, this.config.host, () => {
218
+ server.off('error', onError);
219
+ console.log(
220
+ `Server running on http://${this.config.host}:${this.config.port}`,
221
+ );
222
+ resolve();
223
+ });
224
+ });
225
+
226
+ if (this.elasticEmitter) {
227
+ await this.elasticEmitter.start();
228
+ }
229
+ }
230
+
231
+ public async stop() {
232
+ const server = this.server;
233
+ this.server = undefined;
234
+ if (server?.listening) {
235
+ await new Promise<void>((resolve, reject) => {
236
+ server.close((error) => (error ? reject(error) : resolve()));
237
+ });
238
+ }
239
+ await this.screencastManager.destroy();
240
+ if (this.elasticEmitter) {
241
+ await this.elasticEmitter.stop();
242
+ }
243
+ }
244
+
245
+ public isDashboardRunning() {
246
+ return this.isDashboardActive;
247
+ }
248
+
249
+ private isSessionConnected() {
250
+ const readiness = this.readinessProvider?.();
251
+ if (readiness) {
252
+ return readiness.ready;
253
+ }
254
+
255
+ if (!this.client) {
256
+ return false;
257
+ }
258
+
259
+ return typeof this.client.isConnected === 'function'
260
+ ? this.client.isConnected()
261
+ : false;
262
+ }
263
+
264
+ private setupMiddleware() {
265
+ this.app.use(
266
+ '/*',
267
+ cors({
268
+ origin: parseCorsOrigin(this.config.cors),
269
+ credentials: true,
270
+ }),
271
+ );
272
+
273
+ this.app.use('/*', async (c, next) => {
274
+ const path = new URL(c.req.url).pathname;
275
+ if (path === '/' || path.startsWith('/dashboard')) {
276
+ c.header(
277
+ 'Link',
278
+ [
279
+ `</.well-known/api-catalog>; rel="api-catalog"`,
280
+ `</.well-known/mcp/server-card.json>; rel="mcp"`,
281
+ `</.well-known/agent-card.json>; rel="describedby"`,
282
+ ].join(', '),
283
+ );
284
+ }
285
+
286
+ if (
287
+ path === '/' &&
288
+ (c.req.header('Accept') || '').includes('text/markdown')
289
+ ) {
290
+ const origin = new URL(c.req.url).origin;
291
+ c.header('Content-Type', 'text/markdown');
292
+ return c.text(
293
+ `# Open-WA Easy API\n\nThis is an Agent-Native API endpoint.\n\n## API Catalog\nExplore endpoints at \`${origin}/.well-known/api-catalog\` and docs at \`${origin}/api-docs\`.\n\n## MCP Endpoint\nAn MCP server is running for agents at \`${origin}/mcp\`.\n`,
294
+ );
295
+ }
296
+ await next();
297
+ });
298
+
299
+ if (this.config.logLevel !== 'silent') {
300
+ this.app.use('*', logger());
301
+ }
302
+ }
303
+
304
+ private registerRoutes() {
305
+ const methodDefinitions = getHttpMethodDefinitions();
306
+ registerAgentDiscoveryRoutes(this.app, {
307
+ config: this.config,
308
+ methodDefinitions,
309
+ });
310
+
311
+ this.app.get('/plugins/manifest', (c) =>
312
+ c.json(this.pluginHost?.getManifest() ?? { plugins: [] }),
313
+ );
314
+
315
+ this.app.get('/health', (c) => {
316
+ const healthSnapshot = this.healthStore.getSnapshot();
317
+ return c.json({
318
+ status: 'ok',
319
+ version: '5.0.0',
320
+ host: {
321
+ available: true,
322
+ api: true,
323
+ dashboard: {
324
+ enabled: this.config.dashboard,
325
+ running: this.isDashboardRunning(),
326
+ port: this.config.dashboardPort,
327
+ },
328
+ mcp: {
329
+ enabled: Boolean(this.config.mcp?.enabled),
330
+ available: Boolean(this.config.apiKey && this.config.mcp?.enabled),
331
+ path: this.config.mcp?.path || '/mcp',
332
+ },
333
+ },
334
+ capabilities: {
335
+ apiKeyConfigured: Boolean(this.config.apiKey),
336
+ mcpEnabled: Boolean(this.config.mcp?.enabled),
337
+ mcpAvailable: Boolean(this.config.apiKey && this.config.mcp?.enabled),
338
+ mcpPath: this.config.mcp?.path || '/mcp',
339
+ },
340
+ connected: this.isSessionConnected(),
341
+ session: this.readinessProvider?.() ?? {
342
+ ready: false,
343
+ status: this.client ? 'legacy' : 'unavailable',
344
+ state: this.client ? 'UNKNOWN' : 'DISCONNECTED',
345
+ pending: this.client
346
+ ? ['session_readiness_unavailable']
347
+ : ['client_not_bound'],
348
+ blockers: [],
349
+ exposureSafe: false,
350
+ },
351
+ // QR code for pre-launch scanning
352
+ qr: this.latestQR ?? null,
353
+ // Accumulated health data for the dashboard
354
+ launchTimeline: healthSnapshot.launchTimeline,
355
+ patches: healthSnapshot.patches,
356
+ license: healthSnapshot.license,
357
+ reconnections: healthSnapshot.reconnections,
358
+ startedAt: healthSnapshot.startedAt,
359
+ lastEventAt: healthSnapshot.lastEventAt,
360
+ });
361
+ });
362
+
363
+ this.app.get('/qr', (c) => {
364
+ if (!this.config.ezqr) {
365
+ return c.json({ error: 'QR endpoint disabled' }, 404);
366
+ }
367
+
368
+ if (!this.latestQR) {
369
+ return c.json(
370
+ {
371
+ error: 'QR code not available',
372
+ note: 'Session might be connected or generating QR',
373
+ },
374
+ 404,
375
+ );
376
+ }
377
+
378
+ return c.json({
379
+ qr: this.latestQR,
380
+ note: 'Scan this QR code in WhatsApp',
381
+ });
382
+ });
383
+
384
+ this.app.get('/api/events', (c) => {
385
+ // TODO: Unify this inline auth check with the shared apiKeyMiddleware used across Easy API.
386
+ // Note: This intentionally supports query params to preserve legacy Easy API behavior,
387
+ // unlike the MCP adapter which strictly enforces header-only auth (X-API-Key) for security.
388
+ if (this.config.apiKey) {
389
+ const apiKey =
390
+ c.req.header('X-API-Key') ||
391
+ c.req.query('api_key') ||
392
+ c.req.query('key');
393
+
394
+ if (!apiKey || apiKey !== this.config.apiKey) {
395
+ return c.json(
396
+ { error: 'Unauthorized', details: 'Invalid or missing API key' },
397
+ 401,
398
+ );
399
+ }
400
+ }
401
+
402
+ const topicsParam = c.req.query('topics');
403
+ const topics = topicsParam
404
+ ? topicsParam
405
+ .split(',')
406
+ .map((topic) => topic.trim())
407
+ .filter(Boolean)
408
+ : ['*'];
409
+
410
+ return new Response(
411
+ this.eventBroadcaster.createStream({
412
+ signal: c.req.raw.signal,
413
+ topics,
414
+ }),
415
+ {
416
+ headers: {
417
+ 'Cache-Control': 'no-cache, no-transform',
418
+ Connection: 'keep-alive',
419
+ 'Content-Type': 'text/event-stream',
420
+ 'X-Accel-Buffering': 'no',
421
+ },
422
+ },
423
+ );
424
+ });
425
+
426
+ registerMetaRoutes(this.app, {
427
+ config: this.config,
428
+ methodDefinitions,
429
+ });
430
+
431
+ registerDebugRoutes(this.app, {
432
+ config: this.config,
433
+ getConfig: () => this.config,
434
+ setIntegration: (id, data) => {
435
+ if (!this.config.integrations) {
436
+ this.config.integrations = {};
437
+ }
438
+ this.config.integrations[id] = data;
439
+ },
440
+ });
441
+ this.app.route(
442
+ '/api',
443
+ createApiMiddleware(() => this.client, {
444
+ config: this.config,
445
+ basePath: '/api',
446
+ elasticEmitter: this.elasticEmitter,
447
+ isSessionConnected: () => this.isSessionConnected(),
448
+ }),
449
+ );
450
+
451
+ if (this.config.mcp?.enabled) {
452
+ const mcpAdapter = createHonoMcpAdapter({
453
+ config: this.config,
454
+ clientSource: () => this.client,
455
+ elasticEmitter: this.elasticEmitter,
456
+ basePath: '/api',
457
+ isSessionConnected: () => this.isSessionConnected(),
458
+ });
459
+ mcpAdapter.mount(this.app, this.config.mcp.path || '/mcp');
460
+ }
461
+ }
462
+ }
463
+
464
+ export function createApiServer(config: Config) {
465
+ return new ApiServer({ config });
466
+ }
@@ -0,0 +1,94 @@
1
+ import { resolve, dirname } from 'path';
2
+ import { existsSync, readFileSync } from 'fs';
3
+ import type { Hono } from 'hono';
4
+ import { serveStatic } from '@hono/node-server/serve-static';
5
+ export function findDashboardDir(): string | null {
6
+ const monorepoCandidates = [
7
+ resolve(__dirname, '../../../apps/dashboard-neo'),
8
+ resolve(__dirname, '../../../../apps/dashboard-neo'),
9
+ ];
10
+
11
+ const monorepoPath = monorepoCandidates.find((candidate) => existsSync(resolve(candidate, 'package.json')));
12
+ if (monorepoPath) {
13
+ return monorepoPath;
14
+ }
15
+
16
+ const embeddedCandidates = [
17
+ resolve(__dirname, '../dashboard-neo'),
18
+ resolve(__dirname, 'dashboard-neo'),
19
+ ];
20
+ const embeddedPath = embeddedCandidates.find((candidate) => existsSync(resolve(candidate, 'dist/index.html')));
21
+ if (embeddedPath) {
22
+ return embeddedPath;
23
+ }
24
+
25
+ try {
26
+ const pkgPath = require.resolve('@open-wa/dashboard-neo/package.json');
27
+ return dirname(pkgPath);
28
+ } catch {
29
+ // Not installed
30
+ }
31
+
32
+ return null;
33
+ }
34
+
35
+
36
+ export async function setupViteDevServer(): Promise<any | null> {
37
+ const dashboardDir = findDashboardDir();
38
+ if (!dashboardDir) return null;
39
+
40
+ const isProd = process.env.NODE_ENV === 'production' || !existsSync(resolve(dashboardDir, 'vite.config.ts'));
41
+ if (isProd) return null;
42
+
43
+ try {
44
+ const vite = await import('vite');
45
+ const viteServer = await vite.createServer({
46
+ root: dashboardDir,
47
+ server: { middlewareMode: true },
48
+ appType: 'spa',
49
+ base: '/dashboard/',
50
+ });
51
+ console.log(`\n🚀 Dashboard mounted at /dashboard/ (Vite dev middleware)\n`);
52
+ return viteServer;
53
+ } catch (e: any) {
54
+ console.warn(`[dashboard] Failed to mount Vite middleware: ${e.message}`);
55
+ return null;
56
+ }
57
+ }
58
+
59
+ export async function mountDashboardProduction(app: Hono): Promise<boolean> {
60
+ const dashboardDir = findDashboardDir();
61
+ if (!dashboardDir) return false;
62
+ const distPath = resolve(dashboardDir, 'dist');
63
+ if (existsSync(distPath)) {
64
+ // Determine the root for serveStatic relative to process.cwd, or just use absolute?
65
+ // serveStatic usually looks at relative paths from process.cwd() unless configured.
66
+ // wait, @hono/node-server/serve-static `root` defaults to "./".
67
+ // It's safer to use a custom middleware to read the files, or pass absolute path directly if supported.
68
+ app.use('/dashboard/*', serveStatic({
69
+ root: distPath,
70
+ rewriteRequestPath: (path) => path.replace(/^\/dashboard/, '')
71
+ }));
72
+
73
+ // Fallback for SPA
74
+ app.get('/dashboard/*', (c) => {
75
+ const accept = c.req.header('Accept') || '';
76
+ if (accept.includes('text/markdown')) {
77
+ const origin = new URL(c.req.url).origin;
78
+ c.header('Content-Type', 'text/markdown');
79
+ return c.text(`# Open-WA Dashboard\n\nThe dashboard UI is a Single Page Application.\n\n## Developer API\nThe Easy API is available at \`${origin}/api\`.\nRefer to \`${origin}/api-docs\` for more details.\n\n## MCP Server\nThe local MCP server is running and discoverable. Check \`${origin}/.well-known/mcp/server-card.json\` for constraints.`);
80
+ }
81
+
82
+ const indexPath = resolve(distPath, 'index.html');
83
+ if (existsSync(indexPath)) {
84
+ return c.html(readFileSync(indexPath, 'utf-8'));
85
+ }
86
+ return c.notFound();
87
+ });
88
+
89
+ console.log(`\n🚀 Dashboard mounted at /dashboard/ (Production static)\n`);
90
+ return true;
91
+ }
92
+
93
+ return false;
94
+ }
@@ -0,0 +1,77 @@
1
+ import type { HttpMethodDefinition } from '@open-wa/schema';
2
+
3
+ function schemaToOpenApi(schema: { toJSONSchema?: (params?: unknown) => unknown }) {
4
+ if (typeof schema?.toJSONSchema === 'function') {
5
+ return schema.toJSONSchema({ target: 'openapi-3.0' });
6
+ }
7
+
8
+ return { type: 'object', additionalProperties: true };
9
+ }
10
+
11
+ function buildQueryParameters(def: HttpMethodDefinition) {
12
+ const inputSchema = schemaToOpenApi(def.inputSchema) as {
13
+ properties?: Record<string, Record<string, unknown>>;
14
+ required?: string[];
15
+ };
16
+ const properties = inputSchema.properties ?? {};
17
+ const required = new Set(inputSchema.required ?? []);
18
+
19
+ return def.parameterOrder.map((name) => ({
20
+ name,
21
+ in: 'query',
22
+ required: required.has(name),
23
+ description: properties[name]?.description || `Argument: ${name}`,
24
+ schema: properties[name] || { type: 'string' },
25
+ }));
26
+ }
27
+
28
+ export function createOpenApiDocument(
29
+ methodDefinitions: HttpMethodDefinition[],
30
+ options: { origin: string; basePath?: string; title?: string; version?: string }
31
+ ) {
32
+ const paths = Object.fromEntries(
33
+ methodDefinitions.map((def) => [
34
+ def.path,
35
+ {
36
+ [def.httpMethod.toLowerCase()]: {
37
+ summary: def.description,
38
+ operationId: def.functionName,
39
+ tags: [def.namespace],
40
+ ...(def.httpMethod === 'GET' || def.httpMethod === 'DELETE'
41
+ ? { parameters: buildQueryParameters(def) }
42
+ : {
43
+ requestBody: {
44
+ required: def.parameterOrder.length > 0,
45
+ content: {
46
+ 'application/json': {
47
+ schema: schemaToOpenApi(def.inputSchema),
48
+ },
49
+ },
50
+ },
51
+ }),
52
+ 'x-openwa-aliases': def.routeSignatures.filter((signature) => signature !== `${def.httpMethod} ${def.path}`),
53
+ responses: {
54
+ '200': {
55
+ description: 'Successful response',
56
+ content: {
57
+ 'application/json': {
58
+ schema: schemaToOpenApi(def.outputSchema),
59
+ },
60
+ },
61
+ },
62
+ },
63
+ },
64
+ },
65
+ ])
66
+ );
67
+
68
+ return {
69
+ openapi: '3.0.3',
70
+ info: {
71
+ title: options.title || 'open-wa Easy API',
72
+ version: options.version || '5.0.0',
73
+ },
74
+ servers: [{ url: options.origin }],
75
+ paths,
76
+ };
77
+ }
@@ -0,0 +1,42 @@
1
+ import type { HttpMethodDefinition } from '@open-wa/schema';
2
+
3
+ export function createPostmanCollection(
4
+ methodDefinitions: HttpMethodDefinition[],
5
+ options: { origin: string; basePath?: string; name?: string }
6
+ ) {
7
+ const basePath = options.basePath || '/api';
8
+
9
+ return {
10
+ info: {
11
+ name: options.name || 'open-wa Easy API',
12
+ schema: 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json',
13
+ },
14
+ variable: [
15
+ {
16
+ key: 'baseUrl',
17
+ value: `${options.origin}${basePath}`.replace(/\/api\/api$/, '/api'),
18
+ },
19
+ ],
20
+ item: methodDefinitions.map((def) => ({
21
+ name: def.functionName,
22
+ request: {
23
+ method: 'POST',
24
+ header: [{ key: 'Content-Type', value: 'application/json' }],
25
+ url: {
26
+ raw: `{{baseUrl}}/${def.functionName}`,
27
+ host: ['{{baseUrl}}'],
28
+ path: [def.functionName],
29
+ },
30
+ body: {
31
+ mode: 'raw',
32
+ raw: JSON.stringify(
33
+ Object.fromEntries(def.parameterOrder.map((name) => [name, `<${name}>`])),
34
+ null,
35
+ 2
36
+ ),
37
+ },
38
+ description: def.description,
39
+ },
40
+ })),
41
+ };
42
+ }
@@ -0,0 +1,4 @@
1
+ export interface EventBridge {
2
+ onAny(listener: (event: string, value: any) => void): void;
3
+ offAny(listener: (event: string, value: any) => void): void;
4
+ }