@dexto/server 1.6.20 → 1.6.22
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/a2a/jsonrpc/methods.cjs +1 -1
- package/dist/a2a/jsonrpc/methods.d.ts +14 -4
- package/dist/a2a/jsonrpc/methods.d.ts.map +1 -1
- package/dist/a2a/jsonrpc/methods.js +1 -1
- package/dist/approval/wire-approval-events.cjs +44 -0
- package/dist/approval/wire-approval-events.d.ts +4 -0
- package/dist/approval/wire-approval-events.d.ts.map +1 -0
- package/dist/approval/wire-approval-events.js +20 -0
- package/dist/events/session-sse-subscriber.cjs +167 -0
- package/dist/events/session-sse-subscriber.d.ts +13 -0
- package/dist/events/session-sse-subscriber.d.ts.map +1 -0
- package/dist/events/session-sse-subscriber.js +143 -0
- package/dist/hono/__tests__/test-fixtures.cjs +8 -0
- package/dist/hono/__tests__/test-fixtures.d.ts +1 -0
- package/dist/hono/__tests__/test-fixtures.d.ts.map +1 -1
- package/dist/hono/__tests__/test-fixtures.js +8 -0
- package/dist/hono/index.cjs +40 -8
- package/dist/hono/index.d.ts +45 -4531
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +43 -9
- package/dist/hono/node/index.cjs +51 -6
- package/dist/hono/node/index.d.ts.map +1 -1
- package/dist/hono/node/index.js +51 -6
- package/dist/hono/routes/a2a-jsonrpc.d.ts.map +1 -1
- package/dist/hono/routes/a2a-tasks.cjs +158 -32
- package/dist/hono/routes/a2a-tasks.d.ts +1 -502
- package/dist/hono/routes/a2a-tasks.d.ts.map +1 -1
- package/dist/hono/routes/a2a-tasks.js +162 -32
- package/dist/hono/routes/a2a.d.ts.map +1 -1
- package/dist/hono/routes/agents.cjs +410 -329
- package/dist/hono/routes/agents.d.ts +16043 -68
- package/dist/hono/routes/agents.d.ts.map +1 -1
- package/dist/hono/routes/agents.js +418 -330
- package/dist/hono/routes/approvals.cjs +102 -88
- package/dist/hono/routes/approvals.d.ts +2089 -142
- package/dist/hono/routes/approvals.d.ts.map +1 -1
- package/dist/hono/routes/approvals.js +108 -89
- package/dist/hono/routes/dexto-auth.cjs +40 -33
- package/dist/hono/routes/dexto-auth.d.ts +401 -2
- package/dist/hono/routes/dexto-auth.d.ts.map +1 -1
- package/dist/hono/routes/dexto-auth.js +40 -33
- package/dist/hono/routes/discovery.cjs +16 -14
- package/dist/hono/routes/discovery.d.ts +586 -1
- package/dist/hono/routes/discovery.d.ts.map +1 -1
- package/dist/hono/routes/discovery.js +16 -14
- package/dist/hono/routes/greeting.cjs +26 -22
- package/dist/hono/routes/greeting.d.ts +787 -3
- package/dist/hono/routes/greeting.d.ts.map +1 -1
- package/dist/hono/routes/greeting.js +26 -22
- package/dist/hono/routes/health.d.ts +1 -1
- package/dist/hono/routes/key.cjs +60 -52
- package/dist/hono/routes/key.d.ts +1597 -1
- package/dist/hono/routes/key.d.ts.map +1 -1
- package/dist/hono/routes/key.js +60 -52
- package/dist/hono/routes/llm.cjs +382 -349
- package/dist/hono/routes/llm.d.ts +12148 -98
- package/dist/hono/routes/llm.d.ts.map +1 -1
- package/dist/hono/routes/llm.js +386 -349
- package/dist/hono/routes/mcp.cjs +257 -226
- package/dist/hono/routes/mcp.d.ts +6605 -309
- package/dist/hono/routes/mcp.d.ts.map +1 -1
- package/dist/hono/routes/mcp.js +263 -225
- package/dist/hono/routes/memory.cjs +102 -89
- package/dist/hono/routes/memory.d.ts +5368 -4
- package/dist/hono/routes/memory.d.ts.map +1 -1
- package/dist/hono/routes/memory.js +108 -90
- package/dist/hono/routes/messages.cjs +189 -191
- package/dist/hono/routes/messages.d.ts +3900 -12
- package/dist/hono/routes/messages.d.ts.map +1 -1
- package/dist/hono/routes/messages.js +192 -191
- package/dist/hono/routes/models.cjs +106 -64
- package/dist/hono/routes/models.d.ts +2875 -2
- package/dist/hono/routes/models.d.ts.map +1 -1
- package/dist/hono/routes/models.js +108 -64
- package/dist/hono/routes/openrouter.cjs +79 -65
- package/dist/hono/routes/openrouter.d.ts +854 -1
- package/dist/hono/routes/openrouter.d.ts.map +1 -1
- package/dist/hono/routes/openrouter.js +79 -65
- package/dist/hono/routes/prompts.cjs +136 -109
- package/dist/hono/routes/prompts.d.ts +2818 -10
- package/dist/hono/routes/prompts.d.ts.map +1 -1
- package/dist/hono/routes/prompts.js +138 -109
- package/dist/hono/routes/queue.cjs +133 -120
- package/dist/hono/routes/queue.d.ts +5240 -11
- package/dist/hono/routes/queue.d.ts.map +1 -1
- package/dist/hono/routes/queue.js +136 -120
- package/dist/hono/routes/resources.cjs +65 -46
- package/dist/hono/routes/resources.d.ts +1983 -5
- package/dist/hono/routes/resources.d.ts.map +1 -1
- package/dist/hono/routes/resources.js +72 -47
- package/dist/hono/routes/schedules.cjs +233 -226
- package/dist/hono/routes/schedules.d.ts +4198 -22
- package/dist/hono/routes/schedules.d.ts.map +1 -1
- package/dist/hono/routes/schedules.js +233 -226
- package/dist/hono/routes/search.cjs +34 -30
- package/dist/hono/routes/search.d.ts +3094 -17
- package/dist/hono/routes/search.d.ts.map +1 -1
- package/dist/hono/routes/search.js +40 -31
- package/dist/hono/routes/sessions.cjs +491 -393
- package/dist/hono/routes/sessions.d.ts +18263 -65
- package/dist/hono/routes/sessions.d.ts.map +1 -1
- package/dist/hono/routes/sessions.js +497 -395
- package/dist/hono/routes/static.d.ts.map +1 -1
- package/dist/hono/routes/system-prompt.cjs +57 -61
- package/dist/hono/routes/system-prompt.d.ts +1228 -2
- package/dist/hono/routes/system-prompt.d.ts.map +1 -1
- package/dist/hono/routes/system-prompt.js +58 -62
- package/dist/hono/routes/tools.cjs +29 -34
- package/dist/hono/routes/tools.d.ts +1755 -6
- package/dist/hono/routes/tools.d.ts.map +1 -1
- package/dist/hono/routes/tools.js +33 -33
- package/dist/hono/routes/webhooks.cjs +115 -123
- package/dist/hono/routes/webhooks.d.ts +2501 -11
- package/dist/hono/routes/webhooks.d.ts.map +1 -1
- package/dist/hono/routes/webhooks.js +120 -124
- package/dist/hono/routes/workspaces.cjs +84 -79
- package/dist/hono/routes/workspaces.d.ts +2093 -2
- package/dist/hono/routes/workspaces.d.ts.map +1 -1
- package/dist/hono/routes/workspaces.js +89 -80
- package/dist/hono/schemas/responses.cjs +463 -260
- package/dist/hono/schemas/responses.d.ts +1893 -209
- package/dist/hono/schemas/responses.d.ts.map +1 -1
- package/dist/hono/schemas/responses.js +203 -14
- package/dist/hono/start-server.cjs +9 -0
- package/dist/hono/start-server.d.ts.map +1 -1
- package/dist/hono/start-server.js +9 -0
- package/dist/hono/types.d.ts +11 -0
- package/dist/hono/types.d.ts.map +1 -1
- package/dist/index.cjs +5 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/tools.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
const ToolInputSchema = z.object({
|
|
9
|
-
type: z.literal("object").optional().describe('Schema type, always "object" when present'),
|
|
10
|
-
properties: z.record(JsonSchemaProperty).optional().describe("Property definitions"),
|
|
11
|
-
required: z.array(z.string()).optional().describe("Required property names")
|
|
12
|
-
}).passthrough().describe("JSON Schema for tool input parameters");
|
|
2
|
+
import {
|
|
3
|
+
InternalErrorResponse,
|
|
4
|
+
JsonObjectSchema,
|
|
5
|
+
JsonValueSchema,
|
|
6
|
+
ToolInputSchema
|
|
7
|
+
} from "../schemas/responses.js";
|
|
13
8
|
const ToolInfoSchema = z.object({
|
|
14
9
|
id: z.string().describe("Tool identifier"),
|
|
15
10
|
name: z.string().describe("Tool name"),
|
|
@@ -17,7 +12,7 @@ const ToolInfoSchema = z.object({
|
|
|
17
12
|
source: z.enum(["local", "mcp"]).describe("Source of the tool (local or mcp)"),
|
|
18
13
|
serverName: z.string().optional().describe("MCP server name (if source is mcp)"),
|
|
19
14
|
inputSchema: ToolInputSchema.optional().describe("JSON Schema for tool input parameters"),
|
|
20
|
-
_meta: z.record(z.
|
|
15
|
+
_meta: z.record(z.string(), JsonValueSchema).optional().describe("Optional tool metadata (e.g., MCP Apps UI resource info)")
|
|
21
16
|
}).strict().describe("Tool information");
|
|
22
17
|
const AllToolsResponseSchema = z.object({
|
|
23
18
|
tools: z.array(ToolInfoSchema).describe("Array of all available tools"),
|
|
@@ -25,21 +20,22 @@ const AllToolsResponseSchema = z.object({
|
|
|
25
20
|
localCount: z.number().describe("Number of local tools"),
|
|
26
21
|
mcpCount: z.number().describe("Number of MCP tools")
|
|
27
22
|
}).strict().describe("All available tools from all sources");
|
|
23
|
+
const allToolsRoute = createRoute({
|
|
24
|
+
method: "get",
|
|
25
|
+
path: "/tools",
|
|
26
|
+
summary: "List All Tools",
|
|
27
|
+
description: "Retrieves all available tools from all sources (local and MCP)",
|
|
28
|
+
tags: ["tools"],
|
|
29
|
+
responses: {
|
|
30
|
+
200: {
|
|
31
|
+
description: "All tools",
|
|
32
|
+
content: { "application/json": { schema: AllToolsResponseSchema } }
|
|
33
|
+
},
|
|
34
|
+
500: InternalErrorResponse
|
|
35
|
+
}
|
|
36
|
+
});
|
|
28
37
|
function createToolsRouter(getAgent) {
|
|
29
38
|
const app = new OpenAPIHono();
|
|
30
|
-
const allToolsRoute = createRoute({
|
|
31
|
-
method: "get",
|
|
32
|
-
path: "/tools",
|
|
33
|
-
summary: "List All Tools",
|
|
34
|
-
description: "Retrieves all available tools from all sources (local and MCP)",
|
|
35
|
-
tags: ["tools"],
|
|
36
|
-
responses: {
|
|
37
|
-
200: {
|
|
38
|
-
description: "All tools",
|
|
39
|
-
content: { "application/json": { schema: AllToolsResponseSchema } }
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
39
|
return app.openapi(allToolsRoute, async (ctx) => {
|
|
44
40
|
const agent = await getAgent(ctx);
|
|
45
41
|
const allTools = await agent.getAllTools();
|
|
@@ -65,14 +61,15 @@ function createToolsRouter(getAgent) {
|
|
|
65
61
|
source = "local";
|
|
66
62
|
localCount++;
|
|
67
63
|
}
|
|
64
|
+
const metadataResult = JsonObjectSchema.safeParse(toolInfo._meta);
|
|
68
65
|
toolList.push({
|
|
69
66
|
id: toolName,
|
|
70
67
|
name: toolName,
|
|
71
68
|
description: toolInfo.description || "No description available",
|
|
72
69
|
source,
|
|
73
70
|
serverName,
|
|
74
|
-
inputSchema: toolInfo.parameters,
|
|
75
|
-
_meta:
|
|
71
|
+
inputSchema: toolInfo.parameters === void 0 ? void 0 : ToolInputSchema.parse(toolInfo.parameters),
|
|
72
|
+
_meta: metadataResult.success ? metadataResult.data : void 0
|
|
76
73
|
});
|
|
77
74
|
}
|
|
78
75
|
toolList.sort((a, b) => {
|
|
@@ -82,12 +79,15 @@ function createToolsRouter(getAgent) {
|
|
|
82
79
|
}
|
|
83
80
|
return a.name.localeCompare(b.name);
|
|
84
81
|
});
|
|
85
|
-
return ctx.json(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
82
|
+
return ctx.json(
|
|
83
|
+
{
|
|
84
|
+
tools: toolList,
|
|
85
|
+
totalCount: toolList.length,
|
|
86
|
+
localCount,
|
|
87
|
+
mcpCount
|
|
88
|
+
},
|
|
89
|
+
200
|
|
90
|
+
);
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
export {
|
|
@@ -28,7 +28,7 @@ const WebhookResponseSchema = import_zod_openapi.z.object({
|
|
|
28
28
|
id: import_zod_openapi.z.string().describe("Unique webhook identifier"),
|
|
29
29
|
url: import_zod_openapi.z.string().url().describe("Webhook URL"),
|
|
30
30
|
description: import_zod_openapi.z.string().optional().describe("Webhook description"),
|
|
31
|
-
createdAt: import_zod_openapi.z.
|
|
31
|
+
createdAt: import_zod_openapi.z.string().datetime().describe("Creation timestamp (ISO 8601)")
|
|
32
32
|
}).strict().describe("Webhook response object");
|
|
33
33
|
const WebhookTestResultSchema = import_zod_openapi.z.object({
|
|
34
34
|
success: import_zod_openapi.z.boolean().describe("Whether the webhook test succeeded"),
|
|
@@ -41,122 +41,129 @@ const WebhookBodySchema = import_zod_openapi.z.object({
|
|
|
41
41
|
secret: import_zod_openapi.z.string().optional().describe("A secret key for HMAC signature verification"),
|
|
42
42
|
description: import_zod_openapi.z.string().optional().describe("A description of the webhook for reference")
|
|
43
43
|
}).describe("Request body for registering a webhook");
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
webhook: WebhookResponseSchema.describe(
|
|
60
|
-
"Registered webhook details"
|
|
61
|
-
)
|
|
62
|
-
}).strict()
|
|
63
|
-
}
|
|
44
|
+
const registerRoute = (0, import_zod_openapi.createRoute)({
|
|
45
|
+
method: "post",
|
|
46
|
+
path: "/webhooks",
|
|
47
|
+
summary: "Register Webhook",
|
|
48
|
+
description: "Registers a new webhook endpoint to receive agent events",
|
|
49
|
+
tags: ["webhooks"],
|
|
50
|
+
request: { body: { content: { "application/json": { schema: WebhookBodySchema } } } },
|
|
51
|
+
responses: {
|
|
52
|
+
201: {
|
|
53
|
+
description: "Webhook registered",
|
|
54
|
+
content: {
|
|
55
|
+
"application/json": {
|
|
56
|
+
schema: import_zod_openapi.z.object({
|
|
57
|
+
webhook: WebhookResponseSchema.describe("Registered webhook details")
|
|
58
|
+
}).strict()
|
|
64
59
|
}
|
|
65
60
|
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
61
|
+
},
|
|
62
|
+
400: import_responses.BadRequestErrorResponse,
|
|
63
|
+
500: import_responses.InternalErrorResponse
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
const listRoute = (0, import_zod_openapi.createRoute)({
|
|
67
|
+
method: "get",
|
|
68
|
+
path: "/webhooks",
|
|
69
|
+
summary: "List Webhooks",
|
|
70
|
+
description: "Retrieves a list of all registered webhooks",
|
|
71
|
+
tags: ["webhooks"],
|
|
72
|
+
responses: {
|
|
73
|
+
200: {
|
|
74
|
+
description: "List webhooks",
|
|
75
|
+
content: {
|
|
76
|
+
"application/json": {
|
|
77
|
+
schema: import_zod_openapi.z.object({
|
|
78
|
+
webhooks: import_zod_openapi.z.array(WebhookResponseSchema).describe("Array of registered webhooks")
|
|
79
|
+
}).strict()
|
|
83
80
|
}
|
|
84
81
|
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
82
|
+
},
|
|
83
|
+
500: import_responses.InternalErrorResponse
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const getRoute = (0, import_zod_openapi.createRoute)({
|
|
87
|
+
method: "get",
|
|
88
|
+
path: "/webhooks/{webhookId}",
|
|
89
|
+
summary: "Get Webhook Details",
|
|
90
|
+
description: "Fetches details for a specific webhook",
|
|
91
|
+
tags: ["webhooks"],
|
|
92
|
+
request: { params: import_zod_openapi.z.object({ webhookId: import_zod_openapi.z.string().describe("The webhook identifier") }) },
|
|
93
|
+
responses: {
|
|
94
|
+
200: {
|
|
95
|
+
description: "Webhook",
|
|
96
|
+
content: {
|
|
97
|
+
"application/json": {
|
|
98
|
+
schema: import_zod_openapi.z.object({
|
|
99
|
+
webhook: WebhookResponseSchema.describe("Webhook details")
|
|
100
|
+
}).strict()
|
|
103
101
|
}
|
|
104
|
-
},
|
|
105
|
-
404: {
|
|
106
|
-
description: "Not found",
|
|
107
|
-
content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
|
|
108
102
|
}
|
|
103
|
+
},
|
|
104
|
+
404: {
|
|
105
|
+
description: "Not found",
|
|
106
|
+
content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
|
|
109
107
|
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
const deleteRoute = (0, import_zod_openapi.createRoute)({
|
|
111
|
+
method: "delete",
|
|
112
|
+
path: "/webhooks/{webhookId}",
|
|
113
|
+
summary: "Delete Webhook",
|
|
114
|
+
description: "Permanently removes a webhook endpoint. This action cannot be undone",
|
|
115
|
+
tags: ["webhooks"],
|
|
116
|
+
request: { params: import_zod_openapi.z.object({ webhookId: import_zod_openapi.z.string().describe("The webhook identifier") }) },
|
|
117
|
+
responses: {
|
|
118
|
+
200: {
|
|
119
|
+
description: "Removed",
|
|
120
|
+
content: {
|
|
121
|
+
"application/json": {
|
|
122
|
+
schema: import_zod_openapi.z.object({
|
|
123
|
+
status: import_zod_openapi.z.literal("removed").describe("Operation status indicating successful removal"),
|
|
124
|
+
webhookId: import_zod_openapi.z.string().describe("ID of the removed webhook")
|
|
125
|
+
}).strict()
|
|
128
126
|
}
|
|
129
|
-
},
|
|
130
|
-
404: {
|
|
131
|
-
description: "Not found",
|
|
132
|
-
content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
|
|
133
127
|
}
|
|
128
|
+
},
|
|
129
|
+
404: {
|
|
130
|
+
description: "Not found",
|
|
131
|
+
content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
|
|
134
132
|
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
const testRoute = (0, import_zod_openapi.createRoute)({
|
|
136
|
+
method: "post",
|
|
137
|
+
path: "/webhooks/{webhookId}/test",
|
|
138
|
+
summary: "Test Webhook",
|
|
139
|
+
description: "Sends a sample event to test webhook connectivity and configuration",
|
|
140
|
+
tags: ["webhooks"],
|
|
141
|
+
request: { params: import_zod_openapi.z.object({ webhookId: import_zod_openapi.z.string().describe("The webhook identifier") }) },
|
|
142
|
+
responses: {
|
|
143
|
+
200: {
|
|
144
|
+
description: "Test result",
|
|
145
|
+
content: {
|
|
146
|
+
"application/json": {
|
|
147
|
+
schema: import_zod_openapi.z.object({
|
|
148
|
+
test: import_zod_openapi.z.literal("completed").describe("Test status indicating completion"),
|
|
149
|
+
result: WebhookTestResultSchema.describe("Test execution results")
|
|
150
|
+
}).strict()
|
|
153
151
|
}
|
|
154
|
-
},
|
|
155
|
-
404: {
|
|
156
|
-
description: "Not found",
|
|
157
|
-
content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
|
|
158
152
|
}
|
|
153
|
+
},
|
|
154
|
+
404: {
|
|
155
|
+
description: "Not found",
|
|
156
|
+
content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
|
|
159
157
|
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
function createWebhooksRouter(getAgent, webhookSubscriber) {
|
|
161
|
+
const app = new import_zod_openapi.OpenAPIHono();
|
|
162
|
+
const serializeWebhook = (webhook) => ({
|
|
163
|
+
id: webhook.id,
|
|
164
|
+
url: webhook.url,
|
|
165
|
+
description: webhook.description,
|
|
166
|
+
createdAt: webhook.createdAt.toISOString()
|
|
160
167
|
});
|
|
161
168
|
return app.openapi(registerRoute, async (ctx) => {
|
|
162
169
|
const agent = await getAgent(ctx);
|
|
@@ -173,23 +180,13 @@ function createWebhooksRouter(getAgent, webhookSubscriber) {
|
|
|
173
180
|
agent.logger.info(`Webhook registered: ${webhookId} -> ${url}`);
|
|
174
181
|
return ctx.json(
|
|
175
182
|
{
|
|
176
|
-
webhook:
|
|
177
|
-
id: webhook.id,
|
|
178
|
-
url: webhook.url,
|
|
179
|
-
description: webhook.description,
|
|
180
|
-
createdAt: webhook.createdAt
|
|
181
|
-
}
|
|
183
|
+
webhook: serializeWebhook(webhook)
|
|
182
184
|
},
|
|
183
185
|
201
|
|
184
186
|
);
|
|
185
187
|
}).openapi(listRoute, async (ctx) => {
|
|
186
|
-
const webhooks = webhookSubscriber.getWebhooks().map(
|
|
187
|
-
|
|
188
|
-
url: webhook.url,
|
|
189
|
-
description: webhook.description,
|
|
190
|
-
createdAt: webhook.createdAt
|
|
191
|
-
}));
|
|
192
|
-
return ctx.json({ webhooks });
|
|
188
|
+
const webhooks = webhookSubscriber.getWebhooks().map(serializeWebhook);
|
|
189
|
+
return ctx.json({ webhooks }, 200);
|
|
193
190
|
}).openapi(getRoute, (ctx) => {
|
|
194
191
|
const { webhookId } = ctx.req.valid("param");
|
|
195
192
|
const webhook = webhookSubscriber.getWebhook(webhookId);
|
|
@@ -204,12 +201,7 @@ function createWebhooksRouter(getAgent, webhookSubscriber) {
|
|
|
204
201
|
}
|
|
205
202
|
return ctx.json(
|
|
206
203
|
{
|
|
207
|
-
webhook:
|
|
208
|
-
id: webhook.id,
|
|
209
|
-
url: webhook.url,
|
|
210
|
-
description: webhook.description,
|
|
211
|
-
createdAt: webhook.createdAt
|
|
212
|
-
}
|
|
204
|
+
webhook: serializeWebhook(webhook)
|
|
213
205
|
},
|
|
214
206
|
200
|
|
215
207
|
);
|