@open-wa/api 5.0.0 → 5.2.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.
- package/dashboard-neo/dist/assets/{AgentScalarDrawer.vue-BGBDvSQB.js → AgentScalarDrawer.vue-Cly13x9l.js} +3 -3
- package/dashboard-neo/dist/assets/index-CP58_PDI.css +1 -0
- package/dashboard-neo/dist/assets/index-Dl0sJuu6.js +2162 -0
- package/dashboard-neo/dist/assets/{modal-CKSoZwLD.js → modal-BTlJ4pQT.js} +1 -1
- package/dashboard-neo/dist/index.html +2 -2
- package/dist/index.cjs +167 -8
- package/dist/index.d.cts +1 -0
- package/dist/index.d.cts.map +1 -1
- package/package.json +5 -4
- package/src/auth/api-key.ts +28 -0
- package/src/compat/args.ts +1 -0
- package/src/compat/deprecation.ts +35 -0
- package/src/compat/session-path.ts +19 -0
- package/src/createApiMiddleware.ts +184 -0
- package/src/createApiServer.ts +472 -0
- package/src/dashboard/middleware.ts +94 -0
- package/src/diagnostics/DiagnosticStore.ts +99 -0
- package/src/docs/openapi.ts +132 -0
- package/src/docs/postman.ts +42 -0
- package/src/events/EventBridge.ts +4 -0
- package/src/events/EventBroadcaster.ts +126 -0
- package/src/execution/kernel.ts +1 -0
- package/src/health/HealthStore.ts +252 -0
- package/src/index.ts +9 -0
- package/src/invoke-client-method.ts +1 -0
- package/src/middleware/rate-limit.ts +30 -0
- package/src/monitoring/elastic.ts +104 -0
- package/src/routes/agent-discovery.ts +150 -0
- package/src/routes/debug.ts +114 -0
- package/src/routes/meta.ts +512 -0
- package/src/types.ts +31 -0
- package/src/version.ts +4 -0
- package/dashboard-neo/dist/assets/index-DM5k7cbF.css +0 -1
- package/dashboard-neo/dist/assets/index-rjufqWkX.js +0 -2149
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
import type { Config, HttpMethodDefinition } from '@open-wa/schema';
|
|
2
|
+
import { eventRegistry } from '@open-wa/schema';
|
|
3
|
+
import { getMcpToolDefinitions } from '@open-wa/mcp';
|
|
4
|
+
import { deprecatedJson, applyDeprecationHeaders } from '../compat/deprecation';
|
|
5
|
+
import { createOpenApiDocument } from '../docs/openapi';
|
|
6
|
+
import { createPostmanCollection } from '../docs/postman';
|
|
7
|
+
|
|
8
|
+
function joinPath(...parts: string[]) {
|
|
9
|
+
const normalized = parts
|
|
10
|
+
.filter(Boolean)
|
|
11
|
+
.map((part, index) => {
|
|
12
|
+
if (index === 0) {
|
|
13
|
+
return part.replace(/\/+$/, '');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return part.replace(/^\/+/, '').replace(/\/+$/, '');
|
|
17
|
+
})
|
|
18
|
+
.filter(Boolean)
|
|
19
|
+
.join('/');
|
|
20
|
+
|
|
21
|
+
return normalized.startsWith('/') ? normalized : `/${normalized}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function getExternalBase(c: any) {
|
|
25
|
+
return c.req.header('x-openwa-external-base') || '';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function renderExplorerHtml(config: Config, methodDefinitions: HttpMethodDefinition[], origin: string, externalBase: string) {
|
|
29
|
+
const commandRows = methodDefinitions
|
|
30
|
+
.map(
|
|
31
|
+
(def) => `
|
|
32
|
+
<tr>
|
|
33
|
+
<td><code>${def.functionName}</code></td>
|
|
34
|
+
<td><span class="ns-badge">${def.namespace}</span></td>
|
|
35
|
+
<td>${def.description}</td>
|
|
36
|
+
</tr>`
|
|
37
|
+
)
|
|
38
|
+
.join('');
|
|
39
|
+
|
|
40
|
+
const listenerRows = eventRegistry
|
|
41
|
+
.getAll()
|
|
42
|
+
.map(
|
|
43
|
+
(def) => `
|
|
44
|
+
<tr>
|
|
45
|
+
<td><code>${def.meta.eventName}</code></td>
|
|
46
|
+
<td><code class="legacy">${def.meta.legacyName}</code></td>
|
|
47
|
+
<td><span class="ns-badge">${def.meta.namespace || 'core'}</span></td>
|
|
48
|
+
<td>${def.meta.description || def.meta.eventName}</td>
|
|
49
|
+
</tr>`
|
|
50
|
+
)
|
|
51
|
+
.join('');
|
|
52
|
+
|
|
53
|
+
const swaggerPath = joinPath(externalBase, 'meta/swagger.json');
|
|
54
|
+
const postmanPath = joinPath(externalBase, 'meta/postman.json');
|
|
55
|
+
const commandsPath = joinPath(externalBase, 'meta/basic/commands');
|
|
56
|
+
const listenersPath = joinPath(externalBase, 'meta/basic/listeners');
|
|
57
|
+
const apiBasePath = joinPath(externalBase, 'api');
|
|
58
|
+
|
|
59
|
+
return `<!doctype html>
|
|
60
|
+
<html lang="en">
|
|
61
|
+
<head>
|
|
62
|
+
<meta charset="utf-8" />
|
|
63
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
64
|
+
<title>open-wa API Explorer — ${config.sessionId}</title>
|
|
65
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
66
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
67
|
+
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet" />
|
|
68
|
+
<style>
|
|
69
|
+
:root {
|
|
70
|
+
--bg: #faf6f0;
|
|
71
|
+
--fg: #3e2723;
|
|
72
|
+
--card: #ffffff;
|
|
73
|
+
--muted: #efebe9;
|
|
74
|
+
--muted-fg: #5d4037;
|
|
75
|
+
--primary: #8d6e63;
|
|
76
|
+
--border: #d7ccc8;
|
|
77
|
+
--code-bg: #2d221e;
|
|
78
|
+
--code-fg: #f5ebe6;
|
|
79
|
+
}
|
|
80
|
+
@media (prefers-color-scheme: dark) {
|
|
81
|
+
:root {
|
|
82
|
+
--bg: #2d221e;
|
|
83
|
+
--fg: #f5ebe6;
|
|
84
|
+
--card: #3e2f2a;
|
|
85
|
+
--muted: #4e3b33;
|
|
86
|
+
--muted-fg: #bcaaa4;
|
|
87
|
+
--primary: #bcaaa4;
|
|
88
|
+
--border: #4e3b33;
|
|
89
|
+
--code-bg: #1e1614;
|
|
90
|
+
--code-fg: #f5ebe6;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
95
|
+
|
|
96
|
+
body {
|
|
97
|
+
font-family: 'Inter', -apple-system, sans-serif;
|
|
98
|
+
background: var(--bg);
|
|
99
|
+
color: var(--fg);
|
|
100
|
+
line-height: 1.6;
|
|
101
|
+
min-height: 100vh;
|
|
102
|
+
position: relative;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* Dither texture overlay on body */
|
|
106
|
+
body::before {
|
|
107
|
+
content: '';
|
|
108
|
+
position: fixed;
|
|
109
|
+
inset: 0;
|
|
110
|
+
background-image: radial-gradient(var(--border) 20%, transparent 20%),
|
|
111
|
+
radial-gradient(var(--border) 20%, transparent 20%);
|
|
112
|
+
background-size: 6px 6px;
|
|
113
|
+
background-position: 0 0, 3px 3px;
|
|
114
|
+
opacity: 0.08;
|
|
115
|
+
pointer-events: none;
|
|
116
|
+
z-index: 0;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.container {
|
|
120
|
+
max-width: 1100px;
|
|
121
|
+
margin: 0 auto;
|
|
122
|
+
padding: 2rem 1.5rem 4rem;
|
|
123
|
+
position: relative;
|
|
124
|
+
z-index: 1;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/* Header card */
|
|
128
|
+
.header-card {
|
|
129
|
+
border: 2px solid var(--fg);
|
|
130
|
+
border-radius: 1rem;
|
|
131
|
+
background: var(--card);
|
|
132
|
+
padding: 1.5rem 2rem;
|
|
133
|
+
box-shadow: 4px 4px 0px 0px var(--fg);
|
|
134
|
+
margin-bottom: 2rem;
|
|
135
|
+
position: relative;
|
|
136
|
+
overflow: hidden;
|
|
137
|
+
}
|
|
138
|
+
.header-card::before {
|
|
139
|
+
content: '';
|
|
140
|
+
position: absolute;
|
|
141
|
+
inset: 0;
|
|
142
|
+
background-image: radial-gradient(var(--border) 20%, transparent 20%),
|
|
143
|
+
radial-gradient(var(--border) 20%, transparent 20%);
|
|
144
|
+
background-size: 6px 6px;
|
|
145
|
+
background-position: 0 0, 3px 3px;
|
|
146
|
+
opacity: 0.06;
|
|
147
|
+
pointer-events: none;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
h1 {
|
|
151
|
+
font-family: 'Space Grotesk', sans-serif;
|
|
152
|
+
font-weight: 700;
|
|
153
|
+
font-size: 1.75rem;
|
|
154
|
+
letter-spacing: -0.02em;
|
|
155
|
+
position: relative;
|
|
156
|
+
}
|
|
157
|
+
h1 .emoji { font-size: 1.5rem; margin-right: 0.5rem; }
|
|
158
|
+
|
|
159
|
+
.session-info {
|
|
160
|
+
margin-top: 0.75rem;
|
|
161
|
+
font-size: 0.875rem;
|
|
162
|
+
color: var(--muted-fg);
|
|
163
|
+
position: relative;
|
|
164
|
+
}
|
|
165
|
+
.session-info strong { color: var(--fg); font-weight: 600; }
|
|
166
|
+
.session-info code {
|
|
167
|
+
font-family: 'JetBrains Mono', monospace;
|
|
168
|
+
font-size: 0.8rem;
|
|
169
|
+
background: var(--code-bg);
|
|
170
|
+
color: var(--code-fg);
|
|
171
|
+
padding: 0.15rem 0.5rem;
|
|
172
|
+
border-radius: 0.5rem;
|
|
173
|
+
border: 1px solid var(--border);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/* Quick links */
|
|
177
|
+
.quick-links {
|
|
178
|
+
display: flex;
|
|
179
|
+
flex-wrap: wrap;
|
|
180
|
+
gap: 0.5rem;
|
|
181
|
+
margin-top: 1rem;
|
|
182
|
+
position: relative;
|
|
183
|
+
}
|
|
184
|
+
.quick-links a {
|
|
185
|
+
display: inline-flex;
|
|
186
|
+
align-items: center;
|
|
187
|
+
gap: 0.35rem;
|
|
188
|
+
font-family: 'Space Grotesk', sans-serif;
|
|
189
|
+
font-weight: 500;
|
|
190
|
+
font-size: 0.8rem;
|
|
191
|
+
text-decoration: none;
|
|
192
|
+
color: var(--fg);
|
|
193
|
+
background: var(--muted);
|
|
194
|
+
border: 2px solid var(--fg);
|
|
195
|
+
border-radius: 0.5rem;
|
|
196
|
+
padding: 0.35rem 0.75rem;
|
|
197
|
+
box-shadow: 2px 2px 0px 0px var(--fg);
|
|
198
|
+
transition: all 0.15s ease;
|
|
199
|
+
}
|
|
200
|
+
.quick-links a:hover {
|
|
201
|
+
transform: translate(-1px, -1px);
|
|
202
|
+
box-shadow: 3px 3px 0px 0px var(--fg);
|
|
203
|
+
background: var(--primary);
|
|
204
|
+
color: var(--bg);
|
|
205
|
+
}
|
|
206
|
+
.quick-links a:active {
|
|
207
|
+
transform: translate(1px, 1px);
|
|
208
|
+
box-shadow: 1px 1px 0px 0px var(--fg);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/* Section headers */
|
|
212
|
+
h2 {
|
|
213
|
+
font-family: 'Space Grotesk', sans-serif;
|
|
214
|
+
font-weight: 700;
|
|
215
|
+
font-size: 1.25rem;
|
|
216
|
+
margin: 2rem 0 0.75rem;
|
|
217
|
+
display: flex;
|
|
218
|
+
align-items: center;
|
|
219
|
+
gap: 0.5rem;
|
|
220
|
+
}
|
|
221
|
+
h2 .count {
|
|
222
|
+
font-family: 'JetBrains Mono', monospace;
|
|
223
|
+
font-size: 0.7rem;
|
|
224
|
+
font-weight: 500;
|
|
225
|
+
background: var(--muted);
|
|
226
|
+
color: var(--muted-fg);
|
|
227
|
+
border: 1.5px solid var(--fg);
|
|
228
|
+
border-radius: 2rem;
|
|
229
|
+
padding: 0.1rem 0.5rem;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/* Table card */
|
|
233
|
+
.table-card {
|
|
234
|
+
border: 2px solid var(--fg);
|
|
235
|
+
border-radius: 1rem;
|
|
236
|
+
background: var(--card);
|
|
237
|
+
box-shadow: 4px 4px 0px 0px var(--fg);
|
|
238
|
+
overflow: hidden;
|
|
239
|
+
margin-bottom: 1.5rem;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
table { border-collapse: collapse; width: 100%; }
|
|
243
|
+
|
|
244
|
+
thead {
|
|
245
|
+
background: var(--muted);
|
|
246
|
+
border-bottom: 2px solid var(--fg);
|
|
247
|
+
}
|
|
248
|
+
th {
|
|
249
|
+
font-family: 'Space Grotesk', sans-serif;
|
|
250
|
+
font-weight: 700;
|
|
251
|
+
font-size: 0.7rem;
|
|
252
|
+
text-transform: uppercase;
|
|
253
|
+
letter-spacing: 0.1em;
|
|
254
|
+
padding: 0.75rem 1rem;
|
|
255
|
+
text-align: left;
|
|
256
|
+
color: var(--fg);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
td {
|
|
260
|
+
padding: 0.625rem 1rem;
|
|
261
|
+
font-size: 0.85rem;
|
|
262
|
+
color: var(--muted-fg);
|
|
263
|
+
border-bottom: 1px solid var(--border);
|
|
264
|
+
vertical-align: top;
|
|
265
|
+
}
|
|
266
|
+
tr:last-child td { border-bottom: none; }
|
|
267
|
+
tr:hover { background: color-mix(in srgb, var(--muted) 40%, transparent); }
|
|
268
|
+
|
|
269
|
+
code {
|
|
270
|
+
font-family: 'JetBrains Mono', monospace;
|
|
271
|
+
font-size: 0.8rem;
|
|
272
|
+
background: var(--code-bg);
|
|
273
|
+
color: var(--code-fg);
|
|
274
|
+
padding: 0.1rem 0.4rem;
|
|
275
|
+
border-radius: 0.35rem;
|
|
276
|
+
border: 1px solid var(--border);
|
|
277
|
+
}
|
|
278
|
+
code.legacy {
|
|
279
|
+
opacity: 0.6;
|
|
280
|
+
font-size: 0.75rem;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.ns-badge {
|
|
284
|
+
display: inline-block;
|
|
285
|
+
font-family: 'Space Grotesk', sans-serif;
|
|
286
|
+
font-size: 0.7rem;
|
|
287
|
+
font-weight: 600;
|
|
288
|
+
background: var(--primary);
|
|
289
|
+
color: var(--bg);
|
|
290
|
+
border-radius: 0.35rem;
|
|
291
|
+
padding: 0.1rem 0.5rem;
|
|
292
|
+
text-transform: lowercase;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/* Search/filter input */
|
|
296
|
+
.filter-bar {
|
|
297
|
+
margin-bottom: 1rem;
|
|
298
|
+
}
|
|
299
|
+
.filter-bar input {
|
|
300
|
+
width: 100%;
|
|
301
|
+
max-width: 400px;
|
|
302
|
+
font-family: 'JetBrains Mono', monospace;
|
|
303
|
+
font-size: 0.85rem;
|
|
304
|
+
padding: 0.5rem 0.75rem;
|
|
305
|
+
border: 2px solid var(--fg);
|
|
306
|
+
border-radius: 0.75rem;
|
|
307
|
+
background: var(--card);
|
|
308
|
+
color: var(--fg);
|
|
309
|
+
box-shadow: 2px 2px 0px 0px var(--fg);
|
|
310
|
+
outline: none;
|
|
311
|
+
transition: box-shadow 0.15s ease, transform 0.15s ease;
|
|
312
|
+
}
|
|
313
|
+
.filter-bar input:focus {
|
|
314
|
+
transform: translate(-1px, -1px);
|
|
315
|
+
box-shadow: 3px 3px 0px 0px var(--fg);
|
|
316
|
+
}
|
|
317
|
+
.filter-bar input::placeholder { color: var(--muted-fg); opacity: 0.5; }
|
|
318
|
+
|
|
319
|
+
@media (max-width: 640px) {
|
|
320
|
+
.container { padding: 1rem; }
|
|
321
|
+
.header-card { padding: 1rem 1.25rem; }
|
|
322
|
+
h1 { font-size: 1.25rem; }
|
|
323
|
+
.quick-links { flex-direction: column; }
|
|
324
|
+
.quick-links a { justify-content: center; }
|
|
325
|
+
}
|
|
326
|
+
</style>
|
|
327
|
+
</head>
|
|
328
|
+
<body>
|
|
329
|
+
<div class="container">
|
|
330
|
+
<div class="header-card">
|
|
331
|
+
<h1><span class="emoji">🧰</span> open-wa API Explorer</h1>
|
|
332
|
+
<div class="session-info">
|
|
333
|
+
Session: <strong>${config.sessionId}</strong> ·
|
|
334
|
+
Base URL: <code>${origin}${apiBasePath}</code>
|
|
335
|
+
</div>
|
|
336
|
+
<div class="quick-links">
|
|
337
|
+
<a href="${swaggerPath}">📋 Swagger JSON</a>
|
|
338
|
+
<a href="${postmanPath}">📮 Postman Collection</a>
|
|
339
|
+
<a href="${commandsPath}">⚡ Commands JSON</a>
|
|
340
|
+
<a href="${listenersPath}">📡 Listeners JSON</a>
|
|
341
|
+
</div>
|
|
342
|
+
</div>
|
|
343
|
+
|
|
344
|
+
<h2>⚡ Commands <span class="count">${methodDefinitions.length}</span></h2>
|
|
345
|
+
<div class="filter-bar">
|
|
346
|
+
<input type="text" id="cmd-filter" placeholder="Filter commands..." oninput="filterTable('cmd-table', this.value)" />
|
|
347
|
+
</div>
|
|
348
|
+
<div class="table-card">
|
|
349
|
+
<table id="cmd-table">
|
|
350
|
+
<thead><tr><th>Method</th><th>Namespace</th><th>Description</th></tr></thead>
|
|
351
|
+
<tbody>${commandRows}</tbody>
|
|
352
|
+
</table>
|
|
353
|
+
</div>
|
|
354
|
+
|
|
355
|
+
<h2>📡 Listeners <span class="count">${eventRegistry.getAll().length}</span></h2>
|
|
356
|
+
<div class="filter-bar">
|
|
357
|
+
<input type="text" id="evt-filter" placeholder="Filter listeners..." oninput="filterTable('evt-table', this.value)" />
|
|
358
|
+
</div>
|
|
359
|
+
<div class="table-card">
|
|
360
|
+
<table id="evt-table">
|
|
361
|
+
<thead><tr><th>Event</th><th>Legacy Alias</th><th>Namespace</th><th>Description</th></tr></thead>
|
|
362
|
+
<tbody>${listenerRows}</tbody>
|
|
363
|
+
</table>
|
|
364
|
+
</div>
|
|
365
|
+
</div>
|
|
366
|
+
<script>
|
|
367
|
+
function filterTable(tableId, query) {
|
|
368
|
+
var table = document.getElementById(tableId);
|
|
369
|
+
var rows = table.querySelectorAll('tbody tr');
|
|
370
|
+
var q = query.toLowerCase();
|
|
371
|
+
rows.forEach(function(row) {
|
|
372
|
+
row.style.display = row.textContent.toLowerCase().includes(q) ? '' : 'none';
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
</script>
|
|
376
|
+
</body>
|
|
377
|
+
</html>`;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export function registerMetaRoutes(
|
|
381
|
+
app: any,
|
|
382
|
+
options: { config: Config; methodDefinitions: HttpMethodDefinition[] }
|
|
383
|
+
) {
|
|
384
|
+
app.get('/', (c: any) => c.redirect('/api-docs/'));
|
|
385
|
+
app.get('/api-docs', (c: any) => c.redirect('/api-docs/'));
|
|
386
|
+
app.get('/api-docs/', (c: any) => {
|
|
387
|
+
const origin = new URL(c.req.url).origin;
|
|
388
|
+
const externalBase = getExternalBase(c);
|
|
389
|
+
return c.html(renderExplorerHtml(options.config, options.methodDefinitions, origin, externalBase));
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
app.get('/meta/swagger.json', (c: any) => {
|
|
393
|
+
const origin = new URL(c.req.url).origin;
|
|
394
|
+
const basePath = joinPath(getExternalBase(c), 'api');
|
|
395
|
+
return c.json(createOpenApiDocument(options.methodDefinitions, { origin, basePath }));
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
app.get('/meta/postman.json', (c: any) => {
|
|
399
|
+
const origin = new URL(c.req.url).origin;
|
|
400
|
+
const basePath = joinPath(getExternalBase(c), 'api');
|
|
401
|
+
return c.json(createPostmanCollection(options.methodDefinitions, { origin, basePath }));
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
app.get('/meta/basic/commands', (c: any) => {
|
|
405
|
+
return c.json(
|
|
406
|
+
options.methodDefinitions.map((def) => ({
|
|
407
|
+
method: def.functionName,
|
|
408
|
+
namespacedName: def.namespacedName,
|
|
409
|
+
namespace: def.namespace,
|
|
410
|
+
description: def.description,
|
|
411
|
+
path: def.path,
|
|
412
|
+
parameterOrder: def.parameterOrder,
|
|
413
|
+
aliases: def.aliases,
|
|
414
|
+
aliasRoutes: def.aliasRoutes,
|
|
415
|
+
routeSignatures: def.routeSignatures,
|
|
416
|
+
}))
|
|
417
|
+
);
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
app.get('/meta/basic/listeners', (c: any) => {
|
|
421
|
+
return c.json(
|
|
422
|
+
eventRegistry.getAll().map((def) => ({
|
|
423
|
+
eventName: def.meta.eventName,
|
|
424
|
+
legacyName: def.meta.legacyName,
|
|
425
|
+
namespace: def.meta.namespace,
|
|
426
|
+
description: def.meta.description,
|
|
427
|
+
status: def.meta.status,
|
|
428
|
+
}))
|
|
429
|
+
);
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
if (options.config.mcp?.exposeToolsMeta) {
|
|
433
|
+
app.get('/meta/mcp-tools.json', (c: any) => {
|
|
434
|
+
return c.json({
|
|
435
|
+
endpoint: options.config.mcp?.path || '/mcp',
|
|
436
|
+
requiresApiKey: true,
|
|
437
|
+
tools: getMcpToolDefinitions(),
|
|
438
|
+
});
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
app.get('/swagger-stats', (c: any) => {
|
|
443
|
+
applyDeprecationHeaders(c, {
|
|
444
|
+
route: '/swagger-stats',
|
|
445
|
+
message: 'swagger-stats is not carried forward in v5.',
|
|
446
|
+
replacement: '/api-docs/',
|
|
447
|
+
});
|
|
448
|
+
return c.redirect('/api-docs/');
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
app.get('/swagger-stats/', (c: any) => {
|
|
452
|
+
applyDeprecationHeaders(c, {
|
|
453
|
+
route: '/swagger-stats/',
|
|
454
|
+
message: 'swagger-stats is not carried forward in v5.',
|
|
455
|
+
replacement: '/api-docs/',
|
|
456
|
+
});
|
|
457
|
+
return c.redirect('/api-docs/');
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
app.post('/meta/codegen/:language', (c: any) => {
|
|
461
|
+
const language = c.req.param('language');
|
|
462
|
+
return deprecatedJson(
|
|
463
|
+
c,
|
|
464
|
+
{
|
|
465
|
+
route: '/meta/codegen/:language',
|
|
466
|
+
message: 'Runtime codegen is no longer generated inline by the Easy API server.',
|
|
467
|
+
replacement: '/meta/swagger.json or /meta/postman.json',
|
|
468
|
+
},
|
|
469
|
+
410,
|
|
470
|
+
{
|
|
471
|
+
language,
|
|
472
|
+
availableArtifacts: ['/meta/swagger.json', '/meta/postman.json'],
|
|
473
|
+
}
|
|
474
|
+
);
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
app.post('/meta/process/exit', (c: any) =>
|
|
478
|
+
deprecatedJson(
|
|
479
|
+
c,
|
|
480
|
+
{
|
|
481
|
+
route: '/meta/process/exit',
|
|
482
|
+
message: 'Process-control endpoints are not exposed by the shared v5 API runtime.',
|
|
483
|
+
replacement: 'external process manager controls',
|
|
484
|
+
},
|
|
485
|
+
410
|
|
486
|
+
)
|
|
487
|
+
);
|
|
488
|
+
|
|
489
|
+
app.post('/meta/process/restart', (c: any) =>
|
|
490
|
+
deprecatedJson(
|
|
491
|
+
c,
|
|
492
|
+
{
|
|
493
|
+
route: '/meta/process/restart',
|
|
494
|
+
message: 'Process-control endpoints are not exposed by the shared v5 API runtime.',
|
|
495
|
+
replacement: 'external process manager controls',
|
|
496
|
+
},
|
|
497
|
+
410
|
|
498
|
+
)
|
|
499
|
+
);
|
|
500
|
+
|
|
501
|
+
app.post('/disengage', (c: any) =>
|
|
502
|
+
deprecatedJson(
|
|
503
|
+
c,
|
|
504
|
+
{
|
|
505
|
+
route: '/disengage',
|
|
506
|
+
message: 'The disengage route is deprecated in the shared v5 API runtime.',
|
|
507
|
+
replacement: '/meta/process/restart or external orchestration controls',
|
|
508
|
+
},
|
|
509
|
+
410
|
|
510
|
+
)
|
|
511
|
+
);
|
|
512
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Config, HttpMethodDefinition } from '@open-wa/schema';
|
|
2
|
+
import type { Hono } from 'hono';
|
|
3
|
+
import type { ElasticEmitter } from './monitoring/elastic';
|
|
4
|
+
import type { EventBroadcaster } from './events/EventBroadcaster';
|
|
5
|
+
|
|
6
|
+
export type ClientMethodMap = Record<string, (...args: any[]) => Promise<any> | any>;
|
|
7
|
+
export type ClientSource = ClientMethodMap | undefined | (() => ClientMethodMap | undefined);
|
|
8
|
+
|
|
9
|
+
export interface ApiMiddlewareOptions {
|
|
10
|
+
config: Config;
|
|
11
|
+
basePath?: string;
|
|
12
|
+
useSessionIdInPath?: boolean;
|
|
13
|
+
methodDefinitions?: HttpMethodDefinition[];
|
|
14
|
+
elasticEmitter?: ElasticEmitter;
|
|
15
|
+
isSessionConnected?: () => boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface RuntimeExplorerOptions {
|
|
19
|
+
config: Config;
|
|
20
|
+
methodDefinitions: HttpMethodDefinition[];
|
|
21
|
+
origin: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ApiServerOptions {
|
|
25
|
+
config: Config;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ApiServerLike {
|
|
29
|
+
getApp(): Hono;
|
|
30
|
+
getEventBroadcaster(): EventBroadcaster;
|
|
31
|
+
}
|
package/src/version.ts
ADDED