@dexto/server 1.6.19 → 1.6.21
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/hono/index.cjs +39 -8
- package/dist/hono/index.d.ts +43 -4503
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +42 -9
- package/dist/hono/routes/a2a-jsonrpc.d.ts.map +1 -1
- package/dist/hono/routes/a2a-tasks.cjs +173 -34
- package/dist/hono/routes/a2a-tasks.d.ts +1 -498
- package/dist/hono/routes/a2a-tasks.d.ts.map +1 -1
- package/dist/hono/routes/a2a-tasks.js +177 -34
- 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 +16048 -73
- package/dist/hono/routes/agents.d.ts.map +1 -1
- package/dist/hono/routes/agents.js +418 -330
- package/dist/hono/routes/approvals.cjs +103 -78
- package/dist/hono/routes/approvals.d.ts +2090 -112
- package/dist/hono/routes/approvals.d.ts.map +1 -1
- package/dist/hono/routes/approvals.js +108 -78
- 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 +381 -348
- package/dist/hono/routes/llm.d.ts +12137 -87
- package/dist/hono/routes/llm.d.ts.map +1 -1
- package/dist/hono/routes/llm.js +385 -348
- package/dist/hono/routes/mcp.cjs +273 -212
- package/dist/hono/routes/mcp.d.ts +6605 -316
- package/dist/hono/routes/mcp.d.ts.map +1 -1
- package/dist/hono/routes/mcp.js +287 -213
- 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 +171 -164
- package/dist/hono/routes/messages.d.ts +3899 -10
- package/dist/hono/routes/messages.d.ts.map +1 -1
- package/dist/hono/routes/messages.js +181 -165
- package/dist/hono/routes/models.cjs +106 -64
- package/dist/hono/routes/models.d.ts +2874 -1
- 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 +137 -104
- package/dist/hono/routes/prompts.d.ts +2820 -12
- package/dist/hono/routes/prompts.d.ts.map +1 -1
- package/dist/hono/routes/prompts.js +144 -105
- package/dist/hono/routes/queue.cjs +158 -132
- package/dist/hono/routes/queue.d.ts +5148 -13
- package/dist/hono/routes/queue.d.ts.map +1 -1
- package/dist/hono/routes/queue.js +168 -133
- 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 +4202 -26
- 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 +2837 -14
- package/dist/hono/routes/search.d.ts.map +1 -1
- package/dist/hono/routes/search.js +40 -31
- package/dist/hono/routes/sessions.cjs +404 -392
- package/dist/hono/routes/sessions.d.ts +16585 -30
- package/dist/hono/routes/sessions.d.ts.map +1 -1
- package/dist/hono/routes/sessions.js +408 -393
- 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 +1756 -7
- package/dist/hono/routes/tools.d.ts.map +1 -1
- package/dist/hono/routes/tools.js +33 -33
- package/dist/hono/routes/webhooks.cjs +159 -132
- package/dist/hono/routes/webhooks.d.ts +2504 -14
- package/dist/hono/routes/webhooks.d.ts.map +1 -1
- package/dist/hono/routes/webhooks.js +163 -132
- 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 +492 -235
- package/dist/hono/schemas/responses.d.ts +1461 -146
- package/dist/hono/schemas/responses.d.ts.map +1 -1
- package/dist/hono/schemas/responses.js +247 -9
- package/dist/hono/types.d.ts +11 -0
- package/dist/hono/types.d.ts.map +1 -1
- 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":["../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H,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA4ErD;AAED,KAAK,mBAAmB,GAAG,kBAAkB,CAAC,OAAO,aAAa,EAAE,EAAE,CAAC,CAAC;AAExE,MAAM,MAAM,iBAAiB,GAAG,mBAAmB,CAAC"}
|
|
@@ -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 {
|
|
@@ -22,11 +22,13 @@ __export(webhooks_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(webhooks_exports);
|
|
24
24
|
var import_zod_openapi = require("@hono/zod-openapi");
|
|
25
|
+
var import_core = require("@dexto/core");
|
|
26
|
+
var import_responses = require("../schemas/responses.js");
|
|
25
27
|
const WebhookResponseSchema = import_zod_openapi.z.object({
|
|
26
28
|
id: import_zod_openapi.z.string().describe("Unique webhook identifier"),
|
|
27
29
|
url: import_zod_openapi.z.string().url().describe("Webhook URL"),
|
|
28
30
|
description: import_zod_openapi.z.string().optional().describe("Webhook description"),
|
|
29
|
-
createdAt: import_zod_openapi.z.
|
|
31
|
+
createdAt: import_zod_openapi.z.string().datetime().describe("Creation timestamp (ISO 8601)")
|
|
30
32
|
}).strict().describe("Webhook response object");
|
|
31
33
|
const WebhookTestResultSchema = import_zod_openapi.z.object({
|
|
32
34
|
success: import_zod_openapi.z.boolean().describe("Whether the webhook test succeeded"),
|
|
@@ -39,113 +41,129 @@ const WebhookBodySchema = import_zod_openapi.z.object({
|
|
|
39
41
|
secret: import_zod_openapi.z.string().optional().describe("A secret key for HMAC signature verification"),
|
|
40
42
|
description: import_zod_openapi.z.string().optional().describe("A description of the webhook for reference")
|
|
41
43
|
}).describe("Request body for registering a webhook");
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
webhook: WebhookResponseSchema.describe(
|
|
58
|
-
"Registered webhook details"
|
|
59
|
-
)
|
|
60
|
-
}).strict()
|
|
61
|
-
}
|
|
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()
|
|
62
59
|
}
|
|
63
60
|
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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()
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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()
|
|
101
101
|
}
|
|
102
|
-
}
|
|
103
|
-
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
404: {
|
|
105
|
+
description: "Not found",
|
|
106
|
+
content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
|
|
104
107
|
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
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()
|
|
123
126
|
}
|
|
124
|
-
}
|
|
125
|
-
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
404: {
|
|
130
|
+
description: "Not found",
|
|
131
|
+
content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
|
|
126
132
|
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
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()
|
|
145
151
|
}
|
|
146
|
-
}
|
|
147
|
-
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
404: {
|
|
155
|
+
description: "Not found",
|
|
156
|
+
content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
|
|
148
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()
|
|
149
167
|
});
|
|
150
168
|
return app.openapi(registerRoute, async (ctx) => {
|
|
151
169
|
const agent = await getAgent(ctx);
|
|
@@ -162,64 +180,73 @@ function createWebhooksRouter(getAgent, webhookSubscriber) {
|
|
|
162
180
|
agent.logger.info(`Webhook registered: ${webhookId} -> ${url}`);
|
|
163
181
|
return ctx.json(
|
|
164
182
|
{
|
|
165
|
-
webhook:
|
|
166
|
-
id: webhook.id,
|
|
167
|
-
url: webhook.url,
|
|
168
|
-
description: webhook.description,
|
|
169
|
-
createdAt: webhook.createdAt
|
|
170
|
-
}
|
|
183
|
+
webhook: serializeWebhook(webhook)
|
|
171
184
|
},
|
|
172
185
|
201
|
|
173
186
|
);
|
|
174
187
|
}).openapi(listRoute, async (ctx) => {
|
|
175
|
-
const webhooks = webhookSubscriber.getWebhooks().map(
|
|
176
|
-
|
|
177
|
-
url: webhook.url,
|
|
178
|
-
description: webhook.description,
|
|
179
|
-
createdAt: webhook.createdAt
|
|
180
|
-
}));
|
|
181
|
-
return ctx.json({ webhooks });
|
|
188
|
+
const webhooks = webhookSubscriber.getWebhooks().map(serializeWebhook);
|
|
189
|
+
return ctx.json({ webhooks }, 200);
|
|
182
190
|
}).openapi(getRoute, (ctx) => {
|
|
183
191
|
const { webhookId } = ctx.req.valid("param");
|
|
184
192
|
const webhook = webhookSubscriber.getWebhook(webhookId);
|
|
185
193
|
if (!webhook) {
|
|
186
|
-
|
|
194
|
+
throw new import_core.DextoRuntimeError(
|
|
195
|
+
"webhook_not_found",
|
|
196
|
+
"webhook",
|
|
197
|
+
import_core.ErrorType.NOT_FOUND,
|
|
198
|
+
"Webhook not found",
|
|
199
|
+
{ webhookId }
|
|
200
|
+
);
|
|
187
201
|
}
|
|
188
|
-
return ctx.json(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
});
|
|
202
|
+
return ctx.json(
|
|
203
|
+
{
|
|
204
|
+
webhook: serializeWebhook(webhook)
|
|
205
|
+
},
|
|
206
|
+
200
|
|
207
|
+
);
|
|
196
208
|
}).openapi(deleteRoute, async (ctx) => {
|
|
197
209
|
const agent = await getAgent(ctx);
|
|
198
210
|
const { webhookId } = ctx.req.valid("param");
|
|
199
211
|
const removed = webhookSubscriber.removeWebhook(webhookId);
|
|
200
212
|
if (!removed) {
|
|
201
|
-
|
|
213
|
+
throw new import_core.DextoRuntimeError(
|
|
214
|
+
"webhook_not_found",
|
|
215
|
+
"webhook",
|
|
216
|
+
import_core.ErrorType.NOT_FOUND,
|
|
217
|
+
"Webhook not found",
|
|
218
|
+
{ webhookId }
|
|
219
|
+
);
|
|
202
220
|
}
|
|
203
221
|
agent.logger.info(`Webhook removed: ${webhookId}`);
|
|
204
|
-
return ctx.json({ status: "removed", webhookId });
|
|
222
|
+
return ctx.json({ status: "removed", webhookId }, 200);
|
|
205
223
|
}).openapi(testRoute, async (ctx) => {
|
|
206
224
|
const agent = await getAgent(ctx);
|
|
207
225
|
const { webhookId } = ctx.req.valid("param");
|
|
208
226
|
const webhook = webhookSubscriber.getWebhook(webhookId);
|
|
209
227
|
if (!webhook) {
|
|
210
|
-
|
|
228
|
+
throw new import_core.DextoRuntimeError(
|
|
229
|
+
"webhook_not_found",
|
|
230
|
+
"webhook",
|
|
231
|
+
import_core.ErrorType.NOT_FOUND,
|
|
232
|
+
"Webhook not found",
|
|
233
|
+
{ webhookId }
|
|
234
|
+
);
|
|
211
235
|
}
|
|
212
236
|
agent.logger.info(`Testing webhook: ${webhookId}`);
|
|
213
237
|
const result = await webhookSubscriber.testWebhook(webhookId);
|
|
214
|
-
return ctx.json(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
238
|
+
return ctx.json(
|
|
239
|
+
{
|
|
240
|
+
test: "completed",
|
|
241
|
+
result: {
|
|
242
|
+
success: result.success,
|
|
243
|
+
statusCode: result.statusCode,
|
|
244
|
+
responseTime: result.responseTime,
|
|
245
|
+
error: result.error
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
200
|
|
249
|
+
);
|
|
223
250
|
});
|
|
224
251
|
}
|
|
225
252
|
// Annotate the CommonJS export names for ESM import in node:
|