@axiom-lattice/gateway 3.0.2 → 3.0.4
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/index.js +37 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -6
- package/.eslintrc.json +0 -22
- package/.turbo/turbo-build.log +0 -46
- package/AGENTS.md +0 -112
- package/CHANGELOG.md +0 -1190
- package/LOGGER_CONFIG.md +0 -135
- package/RESUME_STREAM_CONTENT_BASED.md +0 -326
- package/RESUME_STREAM_README.md +0 -388
- package/jest.config.js +0 -72
- package/public/sdk/README.md +0 -695
- package/public/sdk/dashboard-engine-skill.md +0 -1122
- package/public/sdk/dashboard-single-file-spec.md +0 -357
- package/public/sdk/data-query-sdk-skill.md +0 -307
- package/public/sdk/data-query-sdk.d.ts +0 -252
- package/public/sdk/data-query-sdk.js +0 -970
- package/public/sdk/occupancy-dashboard.html +0 -363
- package/public/sdk/test-dashboard.html +0 -690
- package/scripts/seed-lark-installation.ts +0 -54
- package/src/__tests__/__mocks__/e2b.ts +0 -1
- package/src/__tests__/a2a.test.ts +0 -428
- package/src/__tests__/channel-installations.test.ts +0 -199
- package/src/__tests__/data-query.test.ts +0 -77
- package/src/__tests__/sandbox-provider-registration.test.ts +0 -74
- package/src/__tests__/setup.ts +0 -5
- package/src/__tests__/workspace.test.ts +0 -400
- package/src/channels/__tests__/routes.test.ts +0 -50
- package/src/channels/lark/LarkChannelAdapter.ts +0 -217
- package/src/channels/lark/README.md +0 -187
- package/src/channels/lark/__tests__/controller.test.ts +0 -136
- package/src/channels/lark/__tests__/mapping-service.test.ts +0 -118
- package/src/channels/lark/__tests__/parser.test.ts +0 -72
- package/src/channels/lark/__tests__/sender.test.ts +0 -37
- package/src/channels/lark/__tests__/verification.test.ts +0 -157
- package/src/channels/lark/controller.ts +0 -48
- package/src/channels/lark/mapping-service.ts +0 -138
- package/src/channels/lark/parser.ts +0 -68
- package/src/channels/lark/routes.ts +0 -22
- package/src/channels/lark/sender.ts +0 -58
- package/src/channels/lark/types.ts +0 -20
- package/src/channels/lark/verification.ts +0 -32
- package/src/channels/registry.ts +0 -20
- package/src/channels/routes.ts +0 -30
- package/src/channels/wechat/WechatChannelAdapter.ts +0 -294
- package/src/channels/wechat/__tests__/context-store.test.ts +0 -148
- package/src/channels/wechat/context-store.ts +0 -54
- package/src/channels/wechat/controller.ts +0 -59
- package/src/channels/wechat/routes.ts +0 -7
- package/src/channels/wechat/types.ts +0 -62
- package/src/channels/wechat/wechat-client.ts +0 -162
- package/src/config/local-a2a-templates.ts +0 -59
- package/src/config.ts +0 -124
- package/src/controllers/__tests__/assistant-local-a2a.test.ts +0 -147
- package/src/controllers/__tests__/local-a2a-templates.test.ts +0 -112
- package/src/controllers/__tests__/mime.test.ts +0 -74
- package/src/controllers/__tests__/resources.test.ts +0 -122
- package/src/controllers/__tests__/run.test.ts +0 -115
- package/src/controllers/__tests__/tasks.test.ts +0 -215
- package/src/controllers/__tests__/workflow-tracking.test.ts +0 -113
- package/src/controllers/agent_task.ts +0 -72
- package/src/controllers/assistant.ts +0 -490
- package/src/controllers/auth.ts +0 -524
- package/src/controllers/channel-bindings.ts +0 -135
- package/src/controllers/channel-installations.ts +0 -409
- package/src/controllers/collections.ts +0 -176
- package/src/controllers/config.ts +0 -126
- package/src/controllers/connections.ts +0 -181
- package/src/controllers/data-query.ts +0 -236
- package/src/controllers/database-configs.ts +0 -440
- package/src/controllers/embeddings.ts +0 -22
- package/src/controllers/entries.ts +0 -167
- package/src/controllers/eval.ts +0 -513
- package/src/controllers/export-import.ts +0 -166
- package/src/controllers/health.ts +0 -36
- package/src/controllers/local-a2a-templates.ts +0 -18
- package/src/controllers/local-a2a.ts +0 -149
- package/src/controllers/mcp-configs.ts +0 -673
- package/src/controllers/memory.ts +0 -257
- package/src/controllers/menu-items.ts +0 -114
- package/src/controllers/metrics-configs.ts +0 -1061
- package/src/controllers/middleware-types.ts +0 -15
- package/src/controllers/models.ts +0 -199
- package/src/controllers/personal-assistant.ts +0 -191
- package/src/controllers/resources.ts +0 -477
- package/src/controllers/run.ts +0 -338
- package/src/controllers/sandbox.ts +0 -255
- package/src/controllers/schedules.ts +0 -336
- package/src/controllers/skills.ts +0 -256
- package/src/controllers/tasks.ts +0 -213
- package/src/controllers/tenants.ts +0 -121
- package/src/controllers/thread_status.ts +0 -66
- package/src/controllers/threads.ts +0 -260
- package/src/controllers/tools.ts +0 -139
- package/src/controllers/users.ts +0 -135
- package/src/controllers/workflow-tracking.ts +0 -693
- package/src/controllers/workspace.ts +0 -879
- package/src/export_registrations/a2a-api-key.registration.ts +0 -89
- package/src/export_registrations/agent.registration.ts +0 -80
- package/src/export_registrations/binding.registration.ts +0 -106
- package/src/export_registrations/channel-installation.registration.ts +0 -88
- package/src/export_registrations/collection.registration.ts +0 -85
- package/src/export_registrations/connection.registration.ts +0 -97
- package/src/export_registrations/database-config.registration.ts +0 -94
- package/src/export_registrations/eval.registration.ts +0 -334
- package/src/export_registrations/index.ts +0 -31
- package/src/export_registrations/mcp-config.registration.ts +0 -97
- package/src/export_registrations/menu.registration.ts +0 -91
- package/src/export_registrations/metrics-config.registration.ts +0 -94
- package/src/export_registrations/skill.registration.ts +0 -88
- package/src/export_registrations/task.registration.ts +0 -99
- package/src/index.ts +0 -497
- package/src/logger/Logger.ts +0 -186
- package/src/router/MessageContext.ts +0 -14
- package/src/router/MessageRouter.ts +0 -490
- package/src/router/middlewares/auditLogger.ts +0 -34
- package/src/router/middlewares/deduplication.ts +0 -38
- package/src/router/middlewares/index.ts +0 -3
- package/src/router/middlewares/rateLimit.ts +0 -46
- package/src/routes/__tests__/a2a-test-connection.test.ts +0 -177
- package/src/routes/a2a-bridge.ts +0 -266
- package/src/routes/a2a-test-connection.ts +0 -126
- package/src/routes/a2a.ts +0 -851
- package/src/routes/channel-bindings.ts +0 -11
- package/src/routes/channel-installations.ts +0 -33
- package/src/routes/index.ts +0 -640
- package/src/routes/menu-items.ts +0 -10
- package/src/routes/resource-routes.ts +0 -35
- package/src/routes/stt.ts +0 -102
- package/src/schemas/data-query.ts +0 -69
- package/src/schemas/index.ts +0 -852
- package/src/services/ExportImportService.ts +0 -296
- package/src/services/__tests__/ExportImportService.test.ts +0 -130
- package/src/services/__tests__/eval-runner.test.ts +0 -131
- package/src/services/__tests__/local-a2a.test.ts +0 -124
- package/src/services/agent_task_consumer.ts +0 -348
- package/src/services/collection_service.ts +0 -258
- package/src/services/eval-runner.ts +0 -283
- package/src/services/local-a2a.ts +0 -354
- package/src/services/queue_service.ts +0 -104
- package/src/services/sandbox_service.ts +0 -223
- package/src/services/skill_service.ts +0 -97
- package/src/services/supabase.ts +0 -60
- package/src/swagger.ts +0 -77
- package/src/types/index.ts +0 -118
- package/src/types/koa.d.ts +0 -7
- package/src/utils/__tests__/local-a2a-runtime.test.ts +0 -77
- package/src/utils/__tests__/path-containment.test.ts +0 -35
- package/src/utils/a2a-url.ts +0 -20
- package/src/utils/local-a2a-runtime.ts +0 -107
- package/src/utils/mime.ts +0 -44
- package/src/utils/path-containment.ts +0 -38
- package/tsconfig.json +0 -26
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
import { FastifyRequest, FastifyReply } from "fastify";
|
|
2
|
-
import { agentInstanceManager } from "@axiom-lattice/core";
|
|
3
|
-
|
|
4
|
-
// 设置内存项
|
|
5
|
-
export const setMemoryItem = async (
|
|
6
|
-
request: FastifyRequest,
|
|
7
|
-
reply: FastifyReply
|
|
8
|
-
): Promise<void> => {
|
|
9
|
-
try {
|
|
10
|
-
const { assistantId, key } = request.params as {
|
|
11
|
-
assistantId: string;
|
|
12
|
-
key: string;
|
|
13
|
-
};
|
|
14
|
-
const value = request.body;
|
|
15
|
-
|
|
16
|
-
if (!assistantId || !key) {
|
|
17
|
-
reply.status(400).send({
|
|
18
|
-
success: false,
|
|
19
|
-
error: "助手ID和键是必需的",
|
|
20
|
-
});
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (value === undefined) {
|
|
25
|
-
reply.status(400).send({
|
|
26
|
-
success: false,
|
|
27
|
-
error: "值是必需的",
|
|
28
|
-
});
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
//const result = await memoryModel.setMemoryItem(assistantId, key, value);
|
|
33
|
-
|
|
34
|
-
// if (!result.success) {
|
|
35
|
-
reply.status(500).send();
|
|
36
|
-
return;
|
|
37
|
-
// }
|
|
38
|
-
|
|
39
|
-
//reply.send(result);
|
|
40
|
-
} catch (error: any) {
|
|
41
|
-
reply.status(500).send({
|
|
42
|
-
success: false,
|
|
43
|
-
error: `设置内存项时发生错误: ${error.message}`,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// 获取内存项
|
|
49
|
-
export const getMemoryItem = async (
|
|
50
|
-
request: FastifyRequest,
|
|
51
|
-
reply: FastifyReply
|
|
52
|
-
): Promise<void> => {
|
|
53
|
-
try {
|
|
54
|
-
const { assistantId, key } = request.params as {
|
|
55
|
-
assistantId: string;
|
|
56
|
-
key: string;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
if (!assistantId || !key) {
|
|
60
|
-
reply.status(400).send({
|
|
61
|
-
success: false,
|
|
62
|
-
error: "助手ID和键是必需的",
|
|
63
|
-
});
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
//const result = await memoryModel.getMemoryItem(assistantId, key);
|
|
68
|
-
|
|
69
|
-
// if (!result.success) {
|
|
70
|
-
reply.status(404).send();
|
|
71
|
-
return;
|
|
72
|
-
// }
|
|
73
|
-
|
|
74
|
-
//reply.send(result);
|
|
75
|
-
} catch (error: any) {
|
|
76
|
-
reply.status(500).send({
|
|
77
|
-
success: false,
|
|
78
|
-
error: `获取内存项时发生错误: ${error.message}`,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
// 获取所有内存项
|
|
84
|
-
export const getAllMemoryItems = async (
|
|
85
|
-
request: FastifyRequest,
|
|
86
|
-
reply: FastifyReply
|
|
87
|
-
): Promise<void> => {
|
|
88
|
-
try {
|
|
89
|
-
const { assistantId, thread_id } = request.params as {
|
|
90
|
-
assistantId: string;
|
|
91
|
-
thread_id: string;
|
|
92
|
-
};
|
|
93
|
-
const tenant_id = request.headers["x-tenant-id"] as string;
|
|
94
|
-
|
|
95
|
-
if (!thread_id) {
|
|
96
|
-
reply.status(400).send({
|
|
97
|
-
success: false,
|
|
98
|
-
error: "线程ID是必需的",
|
|
99
|
-
});
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (!assistantId) {
|
|
104
|
-
reply.status(400).send({
|
|
105
|
-
success: false,
|
|
106
|
-
error: "助手ID是必需的",
|
|
107
|
-
});
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const agent = agentInstanceManager.getAgent({ assistant_id: assistantId, tenant_id, thread_id: thread_id })
|
|
112
|
-
|
|
113
|
-
const result = await agent.getCurrentMessages();
|
|
114
|
-
|
|
115
|
-
if (!result) {
|
|
116
|
-
reply.status(500).send(result);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
reply.send(result);
|
|
121
|
-
} catch (error: any) {
|
|
122
|
-
reply.status(500).send({
|
|
123
|
-
success: false,
|
|
124
|
-
error: `获取所有内存项时发生错误: ${error.message}`,
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
// 获取助手状态
|
|
130
|
-
export const getAgentState = async (
|
|
131
|
-
request: FastifyRequest,
|
|
132
|
-
reply: FastifyReply
|
|
133
|
-
): Promise<void> => {
|
|
134
|
-
try {
|
|
135
|
-
const { assistantId, thread_id } = request.params as {
|
|
136
|
-
assistantId: string;
|
|
137
|
-
thread_id: string;
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
if (!thread_id) {
|
|
141
|
-
reply.status(400).send({
|
|
142
|
-
success: false,
|
|
143
|
-
error: "线程ID是必需的",
|
|
144
|
-
});
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (!assistantId) {
|
|
149
|
-
reply.status(400).send({
|
|
150
|
-
success: false,
|
|
151
|
-
error: "助手ID是必需的",
|
|
152
|
-
});
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const tenant_id = request.headers["x-tenant-id"] as string;
|
|
157
|
-
const agent = agentInstanceManager.getAgent({ assistant_id: assistantId, tenant_id, thread_id: thread_id })
|
|
158
|
-
|
|
159
|
-
// 1. 获取 LangGraph 状态(现有逻辑)
|
|
160
|
-
const result = await agent.getCurrentState();
|
|
161
|
-
const pendingMessages = await agent.getPendingMessages();
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
if (!result) {
|
|
165
|
-
reply.status(500).send(result);
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// 3. 合并返回
|
|
170
|
-
// Normalize pendingMessages content to string for consistent frontend format
|
|
171
|
-
const normalizedPendingMessages = pendingMessages.map(msg => ({
|
|
172
|
-
...msg,
|
|
173
|
-
content: typeof msg.content === 'object' && msg.content !== null
|
|
174
|
-
? ('message' in msg.content ? msg.content.message : JSON.stringify(msg.content))
|
|
175
|
-
: String(msg.content || '')
|
|
176
|
-
}));
|
|
177
|
-
|
|
178
|
-
const mergedResult = {
|
|
179
|
-
...result,
|
|
180
|
-
pendingMessages: normalizedPendingMessages
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
reply.send(mergedResult);
|
|
184
|
-
} catch (error: any) {
|
|
185
|
-
reply.status(500).send({
|
|
186
|
-
success: false,
|
|
187
|
-
error: `获取助手状态时发生错误: ${error.message}`,
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
// 删除内存项
|
|
193
|
-
export const deleteMemoryItem = async (
|
|
194
|
-
request: FastifyRequest,
|
|
195
|
-
reply: FastifyReply
|
|
196
|
-
): Promise<void> => {
|
|
197
|
-
try {
|
|
198
|
-
const { assistantId, key } = request.params as {
|
|
199
|
-
assistantId: string;
|
|
200
|
-
key: string;
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
if (!assistantId || !key) {
|
|
204
|
-
reply.status(400).send({
|
|
205
|
-
success: false,
|
|
206
|
-
error: "助手ID和键是必需的",
|
|
207
|
-
});
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
//const result = await memoryModel.deleteMemoryItem(assistantId, key);
|
|
212
|
-
|
|
213
|
-
// if (!result.success) {
|
|
214
|
-
reply.status(500).send();
|
|
215
|
-
return;
|
|
216
|
-
// }
|
|
217
|
-
|
|
218
|
-
reply.status(204).send();
|
|
219
|
-
} catch (error: any) {
|
|
220
|
-
reply.status(500).send({
|
|
221
|
-
success: false,
|
|
222
|
-
error: `删除内存项时发生错误: ${error.message}`,
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
// 清除内存
|
|
228
|
-
export const clearMemory = async (
|
|
229
|
-
request: FastifyRequest,
|
|
230
|
-
reply: FastifyReply
|
|
231
|
-
): Promise<void> => {
|
|
232
|
-
try {
|
|
233
|
-
const { assistantId } = request.params as { assistantId: string };
|
|
234
|
-
|
|
235
|
-
if (!assistantId) {
|
|
236
|
-
reply.status(400).send({
|
|
237
|
-
success: false,
|
|
238
|
-
error: "助手ID是必需的",
|
|
239
|
-
});
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
let result: any; //= await memoryModel.clearMemory(assistantId);
|
|
244
|
-
|
|
245
|
-
if (!result.success) {
|
|
246
|
-
reply.status(500).send(result);
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
reply.status(204).send();
|
|
251
|
-
} catch (error: any) {
|
|
252
|
-
reply.status(500).send({
|
|
253
|
-
success: false,
|
|
254
|
-
error: `清除内存时发生错误: ${error.message}`,
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
};
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import type { FastifyRequest, FastifyReply } from "fastify";
|
|
2
|
-
import type { CreateMenuItemInput } from "@axiom-lattice/protocols";
|
|
3
|
-
import { getMenuRegistry } from "@axiom-lattice/core";
|
|
4
|
-
|
|
5
|
-
function getTenantId(request: FastifyRequest): string {
|
|
6
|
-
const userTenantId = (request as any).user?.tenantId;
|
|
7
|
-
if (userTenantId) return userTenantId;
|
|
8
|
-
return (request.headers["x-tenant-id"] as string) || "default";
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function errorMessage(err: unknown): string {
|
|
12
|
-
return err instanceof Error ? err.message : "Unexpected error";
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export async function getMenuItemList(
|
|
16
|
-
request: FastifyRequest<{
|
|
17
|
-
Querystring: { menuTarget?: string };
|
|
18
|
-
}>,
|
|
19
|
-
_reply: FastifyReply,
|
|
20
|
-
) {
|
|
21
|
-
const tenantId = getTenantId(request);
|
|
22
|
-
try {
|
|
23
|
-
const registry = getMenuRegistry();
|
|
24
|
-
const items = await registry.list({ tenantId, menuTarget: request.query.menuTarget as "sidebar" | "workspace" | undefined });
|
|
25
|
-
return { success: true, message: "Menu items retrieved", data: { records: items, total: items.length } };
|
|
26
|
-
} catch (error) {
|
|
27
|
-
const msg = errorMessage(error);
|
|
28
|
-
console.error("Failed to get menu items:", msg);
|
|
29
|
-
return { success: false, message: msg, data: { records: [], total: 0 } };
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export async function getMenuItem(
|
|
34
|
-
request: FastifyRequest<{ Params: { id: string } }>,
|
|
35
|
-
reply: FastifyReply,
|
|
36
|
-
) {
|
|
37
|
-
const tenantId = getTenantId(request);
|
|
38
|
-
try {
|
|
39
|
-
const registry = getMenuRegistry();
|
|
40
|
-
const item = await registry.getById(request.params.id);
|
|
41
|
-
if (!item || item.tenantId !== tenantId) {
|
|
42
|
-
reply.status(404);
|
|
43
|
-
return { success: false, message: "Menu item not found" };
|
|
44
|
-
}
|
|
45
|
-
return { success: true, message: "Menu item retrieved", data: item };
|
|
46
|
-
} catch (error) {
|
|
47
|
-
const msg = errorMessage(error);
|
|
48
|
-
console.error("Failed to get menu item:", msg);
|
|
49
|
-
reply.status(500);
|
|
50
|
-
return { success: false, message: msg };
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export async function createMenuItem(
|
|
55
|
-
request: FastifyRequest<{ Body: CreateMenuItemInput }>,
|
|
56
|
-
reply: FastifyReply,
|
|
57
|
-
) {
|
|
58
|
-
const tenantId = getTenantId(request);
|
|
59
|
-
try {
|
|
60
|
-
const registry = getMenuRegistry();
|
|
61
|
-
const item = await registry.create({ ...request.body, tenantId });
|
|
62
|
-
reply.status(201);
|
|
63
|
-
return { success: true, message: "Menu item created", data: item };
|
|
64
|
-
} catch (error) {
|
|
65
|
-
const msg = errorMessage(error);
|
|
66
|
-
console.error("Failed to create menu item:", msg);
|
|
67
|
-
reply.status(500);
|
|
68
|
-
return { success: false, message: msg };
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export async function updateMenuItem(
|
|
73
|
-
request: FastifyRequest<{ Params: { id: string }; Body: Partial<CreateMenuItemInput & { enabled: boolean }> }>,
|
|
74
|
-
reply: FastifyReply,
|
|
75
|
-
) {
|
|
76
|
-
try {
|
|
77
|
-
const tenantId = getTenantId(request);
|
|
78
|
-
const registry = getMenuRegistry();
|
|
79
|
-
const existing = await registry.getById(request.params.id);
|
|
80
|
-
if (!existing || existing.tenantId !== tenantId) {
|
|
81
|
-
reply.status(404);
|
|
82
|
-
return { success: false, message: "Menu item not found" };
|
|
83
|
-
}
|
|
84
|
-
const item = await registry.update(request.params.id, request.body);
|
|
85
|
-
return { success: true, message: "Menu item updated", data: item };
|
|
86
|
-
} catch (error) {
|
|
87
|
-
const msg = errorMessage(error);
|
|
88
|
-
console.error("Failed to update menu item:", msg);
|
|
89
|
-
reply.status(500);
|
|
90
|
-
return { success: false, message: msg };
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export async function deleteMenuItem(
|
|
95
|
-
request: FastifyRequest<{ Params: { id: string } }>,
|
|
96
|
-
reply: FastifyReply,
|
|
97
|
-
) {
|
|
98
|
-
try {
|
|
99
|
-
const tenantId = getTenantId(request);
|
|
100
|
-
const registry = getMenuRegistry();
|
|
101
|
-
const existing = await registry.getById(request.params.id);
|
|
102
|
-
if (!existing || existing.tenantId !== tenantId) {
|
|
103
|
-
reply.status(404);
|
|
104
|
-
return { success: false, message: "Menu item not found" };
|
|
105
|
-
}
|
|
106
|
-
await registry.delete(request.params.id);
|
|
107
|
-
return { success: true, message: "Menu item deleted" };
|
|
108
|
-
} catch (error) {
|
|
109
|
-
const msg = errorMessage(error);
|
|
110
|
-
console.error("Failed to delete menu item:", msg);
|
|
111
|
-
reply.status(500);
|
|
112
|
-
return { success: false, message: msg };
|
|
113
|
-
}
|
|
114
|
-
}
|