@superinterface/server 1.0.18 → 1.0.19
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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +2 -2
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/eslint/.cache_btwyo7 +1 -1
- package/.next/fallback-build-manifest.json +2 -2
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/api/files/[fileId]/contents/route.js +1 -1
- package/.next/server/app/api/files/[fileId]/contents/route.js.nft.json +1 -1
- package/.next/server/app/api/files/route.js +1 -1
- package/.next/server/app/api/files/route.js.nft.json +1 -1
- package/.next/server/app/api/messages/route.js +3 -3
- package/.next/server/app/api/messages/route.js.nft.json +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +1 -1
- package/.next/server/chunks/[root-of-the-server]__0c1bc5ed._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0c1bc5ed._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__13c6bd62._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__13c6bd62._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__25ee13bc._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__25ee13bc._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__27aadac9._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__27aadac9._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__2945c9e9._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__2945c9e9._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__29635e8e._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__29635e8e._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__29b43490._.js +2 -2
- package/.next/server/chunks/[root-of-the-server]__29b43490._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__315f084a._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__315f084a._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__441cee00._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__441cee00._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__464a4377._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__464a4377._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__4e536bc0._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__4e536bc0._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__51977f30._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__51977f30._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__583a7f1c._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__583a7f1c._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__5abf1160._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__5abf1160._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__5d09614a._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__5d09614a._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__62d958e7._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__62d958e7._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__7f9ca1e3._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__7f9ca1e3._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__83461316._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__83461316._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__9a611d42._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__9a611d42._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__a135e388._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__a135e388._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__b10ec83e._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__b10ec83e._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__b9a334c3._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__b9a334c3._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__c1629392._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__c1629392._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__dd176cb5._.js +2 -2
- package/.next/server/chunks/[root-of-the-server]__dd176cb5._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__eb816e13._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__eb816e13._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__ed6cf593._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__ed6cf593._.js.map +1 -1
- package/.next/server/chunks/{[root-of-the-server]__30845206._.js → [root-of-the-server]__ff90af03._.js} +3 -3
- package/.next/server/chunks/{[root-of-the-server]__30845206._.js.map → [root-of-the-server]__ff90af03._.js.map} +1 -1
- package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_cb746cf4.js +1 -1
- package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_cb746cf4.js.map +1 -1
- package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_f952d9ab.js +1 -1
- package/.next/server/chunks/c4f00_next_dist_esm_build_templates_app-route_f952d9ab.js.map +1 -1
- package/.next/server/chunks/supercorp_superinterface_bebd2c96._.js +2 -2
- package/.next/server/chunks/supercorp_superinterface_bebd2c96._.js.map +1 -1
- package/.next/server/functions-config-manifest.json +2 -2
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/trace +1 -1
- package/bin/index.cjs +2 -0
- package/dist/app/api/api-keys/[apiKeyId]/route.d.ts +55 -0
- package/dist/app/api/api-keys/[apiKeyId]/route.d.ts.map +1 -1
- package/dist/app/api/api-keys/[apiKeyId]/route.js +10 -4
- package/dist/app/api/api-keys/route.d.ts +29 -0
- package/dist/app/api/api-keys/route.d.ts.map +1 -1
- package/dist/app/api/api-keys/route.js +8 -3
- package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.d.ts +172 -0
- package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/functions/[functionId]/route.js +11 -4
- package/dist/app/api/assistants/[assistantId]/functions/route.d.ts +113 -0
- package/dist/app/api/assistants/[assistantId]/functions/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/functions/route.js +8 -3
- package/dist/app/api/assistants/[assistantId]/initial-messages/route.d.ts +39 -0
- package/dist/app/api/assistants/[assistantId]/initial-messages/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/initial-messages/route.js +8 -3
- package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.d.ts +94 -0
- package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/mcp-servers/[mcpServerId]/route.js +10 -4
- package/dist/app/api/assistants/[assistantId]/mcp-servers/route.d.ts +61 -0
- package/dist/app/api/assistants/[assistantId]/mcp-servers/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/mcp-servers/route.js +7 -3
- package/dist/app/api/assistants/[assistantId]/route.d.ts +123 -0
- package/dist/app/api/assistants/[assistantId]/route.d.ts.map +1 -1
- package/dist/app/api/assistants/[assistantId]/route.js +15 -6
- package/dist/app/api/assistants/route.d.ts +59 -0
- package/dist/app/api/assistants/route.d.ts.map +1 -1
- package/dist/app/api/assistants/route.js +8 -4
- package/dist/app/api/files/[fileId]/contents/route.d.ts +3 -2
- package/dist/app/api/files/[fileId]/contents/route.d.ts.map +1 -1
- package/dist/app/api/files/[fileId]/contents/route.js +6 -3
- package/dist/app/api/files/route.d.ts +10 -0
- package/dist/app/api/files/route.d.ts.map +1 -1
- package/dist/app/api/files/route.js +7 -3
- package/dist/app/api/messages/route.d.ts +24 -1
- package/dist/app/api/messages/route.d.ts.map +1 -1
- package/dist/app/api/messages/route.js +27 -6
- package/dist/app/api/providers/[modelProviderId]/assistants/route.d.ts +19 -0
- package/dist/app/api/providers/[modelProviderId]/assistants/route.d.ts.map +1 -1
- package/dist/app/api/providers/[modelProviderId]/assistants/route.js +4 -2
- package/dist/app/api/providers/[modelProviderId]/models/route.d.ts +14 -0
- package/dist/app/api/providers/[modelProviderId]/models/route.d.ts.map +1 -1
- package/dist/app/api/providers/[modelProviderId]/models/route.js +4 -2
- package/dist/app/api/providers/[modelProviderId]/route.d.ts +64 -0
- package/dist/app/api/providers/[modelProviderId]/route.d.ts.map +1 -1
- package/dist/app/api/providers/[modelProviderId]/route.js +12 -6
- package/dist/app/api/providers/route.d.ts +35 -0
- package/dist/app/api/providers/route.d.ts.map +1 -1
- package/dist/app/api/providers/route.js +9 -5
- package/dist/app/api/tasks/[taskId]/route.d.ts +61 -0
- package/dist/app/api/tasks/[taskId]/route.d.ts.map +1 -1
- package/dist/app/api/tasks/[taskId]/route.js +11 -5
- package/dist/app/api/tasks/callback/route.d.ts.map +1 -1
- package/dist/app/api/tasks/callback/route.js +14 -6
- package/dist/app/api/tasks/route.d.ts +33 -0
- package/dist/app/api/tasks/route.d.ts.map +1 -1
- package/dist/app/api/tasks/route.js +8 -4
- package/dist/app/api/threads/runs/submit-client-tool-outputs/route.d.ts +9 -1
- package/dist/app/api/threads/runs/submit-client-tool-outputs/route.d.ts.map +1 -1
- package/dist/app/api/threads/runs/submit-client-tool-outputs/route.js +5 -3
- package/dist/app/api/workspaces/[workspaceId]/route.d.ts +33 -0
- package/dist/app/api/workspaces/[workspaceId]/route.d.ts.map +1 -1
- package/dist/app/api/workspaces/[workspaceId]/route.js +7 -3
- package/dist/app/api/workspaces/route.d.ts +17 -3
- package/dist/app/api/workspaces/route.d.ts.map +1 -1
- package/dist/app/api/workspaces/route.js +8 -4
- package/dist/lib/apiKeys/getApiKey.d.ts +3 -2
- package/dist/lib/apiKeys/getApiKey.d.ts.map +1 -1
- package/dist/lib/apiKeys/getApiKey.js +1 -2
- package/dist/lib/apiKeys/workspaceAccessWhere.d.ts +3 -1
- package/dist/lib/apiKeys/workspaceAccessWhere.d.ts.map +1 -1
- package/dist/lib/apiKeys/workspaceAccessWhere.js +2 -1
- package/dist/lib/assistants/assistantClientAdapter/buildGetOpenaiAssistant.d.ts +3 -2
- package/dist/lib/assistants/assistantClientAdapter/buildGetOpenaiAssistant.d.ts.map +1 -1
- package/dist/lib/assistants/assistantClientAdapter/buildGetOpenaiAssistant.js +3 -3
- package/dist/lib/assistants/assistantClientAdapter/index.d.ts.map +1 -1
- package/dist/lib/assistants/assistantClientAdapter/index.js +7 -2
- package/dist/lib/computerCalls/handleComputerCall/index.d.ts +3 -2
- package/dist/lib/computerCalls/handleComputerCall/index.d.ts.map +1 -1
- package/dist/lib/computerCalls/handleComputerCall/index.js +5 -1
- package/dist/lib/functions/createFunction.d.ts +2 -1
- package/dist/lib/functions/createFunction.d.ts.map +1 -1
- package/dist/lib/functions/createFunction.js +2 -2
- package/dist/lib/functions/handleFunction/handleAssistant.d.ts +3 -2
- package/dist/lib/functions/handleFunction/handleAssistant.d.ts.map +1 -1
- package/dist/lib/functions/handleFunction/handleAssistant.js +12 -2
- package/dist/lib/functions/handleFunction/handleClientTool.d.ts +3 -2
- package/dist/lib/functions/handleFunction/handleClientTool.d.ts.map +1 -1
- package/dist/lib/functions/handleFunction/handleClientTool.js +2 -1
- package/dist/lib/functions/handleFunction/handleFirecrawl.d.ts +3 -2
- package/dist/lib/functions/handleFunction/handleFirecrawl.d.ts.map +1 -1
- package/dist/lib/functions/handleFunction/handleFirecrawl.js +7 -1
- package/dist/lib/functions/handleFunction/handleReplicate.d.ts +3 -2
- package/dist/lib/functions/handleFunction/handleReplicate.d.ts.map +1 -1
- package/dist/lib/functions/handleFunction/handleReplicate.js +4 -1
- package/dist/lib/functions/handleFunction/handleRequest.d.ts +3 -2
- package/dist/lib/functions/handleFunction/handleRequest.d.ts.map +1 -1
- package/dist/lib/functions/handleFunction/handleRequest.js +6 -1
- package/dist/lib/functions/handleFunction/index.d.ts +3 -2
- package/dist/lib/functions/handleFunction/index.d.ts.map +1 -1
- package/dist/lib/functions/handleFunction/index.js +25 -1
- package/dist/lib/functions/handleFunction/tasks/handleCreateTask.d.ts +3 -2
- package/dist/lib/functions/handleFunction/tasks/handleCreateTask.d.ts.map +1 -1
- package/dist/lib/functions/handleFunction/tasks/handleCreateTask.js +4 -4
- package/dist/lib/functions/handleFunction/tasks/handleDeleteTask.d.ts +3 -2
- package/dist/lib/functions/handleFunction/tasks/handleDeleteTask.d.ts.map +1 -1
- package/dist/lib/functions/handleFunction/tasks/handleDeleteTask.js +3 -3
- package/dist/lib/functions/handleFunction/tasks/handleListTasks.d.ts +3 -2
- package/dist/lib/functions/handleFunction/tasks/handleListTasks.d.ts.map +1 -1
- package/dist/lib/functions/handleFunction/tasks/handleListTasks.js +3 -3
- package/dist/lib/functions/handleFunction/tasks/handleUpdateTask.d.ts +3 -2
- package/dist/lib/functions/handleFunction/tasks/handleUpdateTask.d.ts.map +1 -1
- package/dist/lib/functions/handleFunction/tasks/handleUpdateTask.js +4 -4
- package/dist/lib/functions/updateFunction.d.ts +2 -1
- package/dist/lib/functions/updateFunction.d.ts.map +1 -1
- package/dist/lib/functions/updateFunction.js +2 -2
- package/dist/lib/handlers/handlerPrismaInput.d.ts +3 -1
- package/dist/lib/handlers/handlerPrismaInput.d.ts.map +1 -1
- package/dist/lib/handlers/handlerPrismaInput.jsx +1 -2
- package/dist/lib/initialMessages/updateInitialMessages.d.ts +3 -2
- package/dist/lib/initialMessages/updateInitialMessages.d.ts.map +1 -1
- package/dist/lib/initialMessages/updateInitialMessages.js +1 -2
- package/dist/lib/logs/createLog.d.ts +3 -2
- package/dist/lib/logs/createLog.d.ts.map +1 -1
- package/dist/lib/logs/createLog.js +1 -2
- package/dist/lib/mcpServers/connectMcpServer.d.ts +6 -4
- package/dist/lib/mcpServers/connectMcpServer.d.ts.map +1 -1
- package/dist/lib/mcpServers/connectMcpServer.js +7 -5
- package/dist/lib/mcpServers/getToolCallMcpServer.d.ts +3 -2
- package/dist/lib/mcpServers/getToolCallMcpServer.d.ts.map +1 -1
- package/dist/lib/mcpServers/getToolCallMcpServer.js +2 -1
- package/dist/lib/mcpServers/headers.d.ts +3 -2
- package/dist/lib/mcpServers/headers.d.ts.map +1 -1
- package/dist/lib/mcpServers/headers.js +2 -1
- package/dist/lib/mcpServers/url.d.ts +3 -2
- package/dist/lib/mcpServers/url.d.ts.map +1 -1
- package/dist/lib/mcpServers/url.js +2 -1
- package/dist/lib/metadata/serializeMetadata.d.ts +3 -1
- package/dist/lib/metadata/serializeMetadata.d.ts.map +1 -1
- package/dist/lib/metadata/serializeMetadata.js +3 -2
- package/dist/lib/organizationApiKeys/getOrganizationApiKey.d.ts +3 -2
- package/dist/lib/organizationApiKeys/getOrganizationApiKey.d.ts.map +1 -1
- package/dist/lib/organizationApiKeys/getOrganizationApiKey.js +1 -2
- package/dist/lib/runs/createRunOpts.d.ts +3 -2
- package/dist/lib/runs/createRunOpts.d.ts.map +1 -1
- package/dist/lib/runs/createRunOpts.js +2 -2
- package/dist/lib/tasks/getTaskToolKey.d.ts +3 -2
- package/dist/lib/tasks/getTaskToolKey.d.ts.map +1 -1
- package/dist/lib/tasks/getTaskToolKey.js +2 -1
- package/dist/lib/tasks/parseTaskToolArgs.d.ts +3 -2
- package/dist/lib/tasks/parseTaskToolArgs.d.ts.map +1 -1
- package/dist/lib/tasks/parseTaskToolArgs.js +4 -1
- package/dist/lib/tasks/scheduleTask.d.ts +3 -2
- package/dist/lib/tasks/scheduleTask.d.ts.map +1 -1
- package/dist/lib/tasks/scheduleTask.js +1 -2
- package/dist/lib/threads/createThread/index.d.ts +3 -3
- package/dist/lib/threads/createThread/index.d.ts.map +1 -1
- package/dist/lib/threads/createThread/index.js +1 -0
- package/dist/lib/threads/managedOpenaiThreadId.d.ts +3 -2
- package/dist/lib/threads/managedOpenaiThreadId.d.ts.map +1 -1
- package/dist/lib/threads/managedOpenaiThreadId.js +1 -2
- package/dist/lib/toolCalls/handleToolCall.d.ts +3 -2
- package/dist/lib/toolCalls/handleToolCall.d.ts.map +1 -1
- package/dist/lib/toolCalls/handleToolCall.js +5 -1
- package/dist/lib/tools/tools/index.d.ts +3 -2
- package/dist/lib/tools/tools/index.d.ts.map +1 -1
- package/dist/lib/tools/tools/index.js +9 -6
- package/package.json +1 -1
- package/scripts/utils/loadPrisma.ts +1 -2
- /package/.next/static/{s_BjB5fnRbk2L3A0fMr5L → rEvucoSBXJWMKfLWTgPF2}/_buildManifest.js +0 -0
- /package/.next/static/{s_BjB5fnRbk2L3A0fMr5L → rEvucoSBXJWMKfLWTgPF2}/_clientMiddlewareManifest.json +0 -0
- /package/.next/static/{s_BjB5fnRbk2L3A0fMr5L → rEvucoSBXJWMKfLWTgPF2}/_ssgManifest.js +0 -0
|
@@ -1,4 +1,25 @@
|
|
|
1
|
+
import { type PrismaClient } from '@prisma/client';
|
|
1
2
|
import { NextResponse, type NextRequest } from 'next/server';
|
|
3
|
+
export declare const buildGET: ({ prisma }?: {
|
|
4
|
+
prisma?: PrismaClient;
|
|
5
|
+
}) => (_request: NextRequest, props: {
|
|
6
|
+
params: Promise<{
|
|
7
|
+
taskId: string;
|
|
8
|
+
}>;
|
|
9
|
+
}) => Promise<NextResponse<{
|
|
10
|
+
error: string;
|
|
11
|
+
}> | NextResponse<{
|
|
12
|
+
task: {
|
|
13
|
+
id: string;
|
|
14
|
+
title: string;
|
|
15
|
+
message: string;
|
|
16
|
+
schedule: PrismaJson.TaskSchedule;
|
|
17
|
+
threadId: string;
|
|
18
|
+
key: string;
|
|
19
|
+
createdAt: string;
|
|
20
|
+
updatedAt: string;
|
|
21
|
+
};
|
|
22
|
+
}>>;
|
|
2
23
|
export declare const GET: (_request: NextRequest, props: {
|
|
3
24
|
params: Promise<{
|
|
4
25
|
taskId: string;
|
|
@@ -17,6 +38,26 @@ export declare const GET: (_request: NextRequest, props: {
|
|
|
17
38
|
updatedAt: string;
|
|
18
39
|
};
|
|
19
40
|
}>>;
|
|
41
|
+
export declare const buildPATCH: ({ prisma }?: {
|
|
42
|
+
prisma?: PrismaClient;
|
|
43
|
+
}) => (request: NextRequest, props: {
|
|
44
|
+
params: Promise<{
|
|
45
|
+
taskId: string;
|
|
46
|
+
}>;
|
|
47
|
+
}) => Promise<NextResponse<{
|
|
48
|
+
error: string;
|
|
49
|
+
}> | NextResponse<{
|
|
50
|
+
task: {
|
|
51
|
+
id: string;
|
|
52
|
+
title: string;
|
|
53
|
+
message: string;
|
|
54
|
+
schedule: PrismaJson.TaskSchedule;
|
|
55
|
+
threadId: string;
|
|
56
|
+
key: string;
|
|
57
|
+
createdAt: string;
|
|
58
|
+
updatedAt: string;
|
|
59
|
+
};
|
|
60
|
+
}>>;
|
|
20
61
|
export declare const PATCH: (request: NextRequest, props: {
|
|
21
62
|
params: Promise<{
|
|
22
63
|
taskId: string;
|
|
@@ -35,6 +76,26 @@ export declare const PATCH: (request: NextRequest, props: {
|
|
|
35
76
|
updatedAt: string;
|
|
36
77
|
};
|
|
37
78
|
}>>;
|
|
79
|
+
export declare const buildDELETE: ({ prisma }?: {
|
|
80
|
+
prisma?: PrismaClient;
|
|
81
|
+
}) => (_request: NextRequest, props: {
|
|
82
|
+
params: Promise<{
|
|
83
|
+
taskId: string;
|
|
84
|
+
}>;
|
|
85
|
+
}) => Promise<NextResponse<{
|
|
86
|
+
error: string;
|
|
87
|
+
}> | NextResponse<{
|
|
88
|
+
task: {
|
|
89
|
+
id: string;
|
|
90
|
+
title: string;
|
|
91
|
+
message: string;
|
|
92
|
+
schedule: PrismaJson.TaskSchedule;
|
|
93
|
+
threadId: string;
|
|
94
|
+
key: string;
|
|
95
|
+
createdAt: string;
|
|
96
|
+
updatedAt: string;
|
|
97
|
+
};
|
|
98
|
+
}>>;
|
|
38
99
|
export declare const DELETE: (_request: NextRequest, props: {
|
|
39
100
|
params: Promise<{
|
|
40
101
|
taskId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/tasks/[taskId]/route.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/tasks/[taskId]/route.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAkB5D,eAAO,MAAM,QAAQ,GAClB,aAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,UAAU,WAAW,EACrB,OAAO;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;;;;;GA8C/C,CAAA;AAEH,eAAO,MAAM,GAAG,aAjDF,WAAW,SACd;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;;;;;GAgDrB,CAAA;AAE7B,eAAO,MAAM,UAAU,GACpB,aAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,SAAS,WAAW,EACpB,OAAO;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;;;;;GAiF/C,CAAA;AAEH,eAAO,MAAM,KAAK,YApFL,WAAW,SACb;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;;;;;GAmFjB,CAAA;AAEjC,eAAO,MAAM,WAAW,GACrB,aAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,UAAU,WAAW,EACrB,OAAO;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;;;;;GAkD/C,CAAA;AAEH,eAAO,MAAM,MAAM,aArDL,WAAW,SACd;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;;;;;GAoDf,CAAA;AAEnC,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
|
|
@@ -4,7 +4,7 @@ import { NextResponse } from 'next/server';
|
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { validate } from 'uuid';
|
|
6
6
|
import { cacheHeaders } from '../../../../lib/cache/cacheHeaders';
|
|
7
|
-
import { prisma } from '../../../../lib/prisma';
|
|
7
|
+
import { prisma as defaultPrisma } from '../../../../lib/prisma';
|
|
8
8
|
import { serializeTask } from '../../../../lib/tasks/serializeTask';
|
|
9
9
|
import { validateSchedule } from '../../../../lib/tasks/validateSchedule';
|
|
10
10
|
import { getApiKey } from '../../../../lib/apiKeys/getApiKey';
|
|
@@ -16,7 +16,7 @@ const updateTaskSchema = z.object({
|
|
|
16
16
|
schedule: z.any().optional(),
|
|
17
17
|
key: z.string().optional(),
|
|
18
18
|
});
|
|
19
|
-
export const
|
|
19
|
+
export const buildGET = ({ prisma = defaultPrisma } = {}) => async (_request, props) => {
|
|
20
20
|
const { taskId } = await props.params;
|
|
21
21
|
const headersList = await headers();
|
|
22
22
|
const authorization = headersList.get('authorization');
|
|
@@ -26,6 +26,7 @@ export const GET = async (_request, props) => {
|
|
|
26
26
|
const privateApiKey = await getApiKey({
|
|
27
27
|
authorization,
|
|
28
28
|
type: ApiKeyType.PRIVATE,
|
|
29
|
+
prisma,
|
|
29
30
|
});
|
|
30
31
|
if (!privateApiKey) {
|
|
31
32
|
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
@@ -47,7 +48,8 @@ export const GET = async (_request, props) => {
|
|
|
47
48
|
}
|
|
48
49
|
return NextResponse.json({ task: serializeTask({ task }) }, { headers: cacheHeaders });
|
|
49
50
|
};
|
|
50
|
-
export const
|
|
51
|
+
export const GET = buildGET();
|
|
52
|
+
export const buildPATCH = ({ prisma = defaultPrisma } = {}) => async (request, props) => {
|
|
51
53
|
const { taskId } = await props.params;
|
|
52
54
|
const headersList = await headers();
|
|
53
55
|
const authorization = headersList.get('authorization');
|
|
@@ -57,6 +59,7 @@ export const PATCH = async (request, props) => {
|
|
|
57
59
|
const privateApiKey = await getApiKey({
|
|
58
60
|
authorization,
|
|
59
61
|
type: ApiKeyType.PRIVATE,
|
|
62
|
+
prisma,
|
|
60
63
|
});
|
|
61
64
|
if (!privateApiKey) {
|
|
62
65
|
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
@@ -94,10 +97,11 @@ export const PATCH = async (request, props) => {
|
|
|
94
97
|
where: { id: existingTask.id },
|
|
95
98
|
data: updateData,
|
|
96
99
|
});
|
|
97
|
-
await scheduleTask({ task });
|
|
100
|
+
await scheduleTask({ task, prisma });
|
|
98
101
|
return NextResponse.json({ task: serializeTask({ task }) }, { headers: cacheHeaders });
|
|
99
102
|
};
|
|
100
|
-
export const
|
|
103
|
+
export const PATCH = buildPATCH();
|
|
104
|
+
export const buildDELETE = ({ prisma = defaultPrisma } = {}) => async (_request, props) => {
|
|
101
105
|
const { taskId } = await props.params;
|
|
102
106
|
const headersList = await headers();
|
|
103
107
|
const authorization = headersList.get('authorization');
|
|
@@ -107,6 +111,7 @@ export const DELETE = async (_request, props) => {
|
|
|
107
111
|
const privateApiKey = await getApiKey({
|
|
108
112
|
authorization,
|
|
109
113
|
type: ApiKeyType.PRIVATE,
|
|
114
|
+
prisma,
|
|
110
115
|
});
|
|
111
116
|
if (!privateApiKey) {
|
|
112
117
|
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
@@ -130,6 +135,7 @@ export const DELETE = async (_request, props) => {
|
|
|
130
135
|
const task = await prisma.task.delete({ where: { id: existingTask.id } });
|
|
131
136
|
return NextResponse.json({ task: serializeTask({ task }) }, { headers: cacheHeaders });
|
|
132
137
|
};
|
|
138
|
+
export const DELETE = buildDELETE();
|
|
133
139
|
export const OPTIONS = () => NextResponse.json({}, {
|
|
134
140
|
headers: cacheHeaders,
|
|
135
141
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/tasks/callback/route.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/tasks/callback/route.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,WAAW,MAAM,CAAA;AA8Q9B,eAAO,MAAM,IAAI,2FAG0B,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server';
|
|
2
2
|
import { verifySignatureAppRouter } from '@upstash/qstash/nextjs';
|
|
3
3
|
import { createMessageResponse } from '@superinterface/react/server';
|
|
4
|
-
import { LogRequestMethod, LogRequestRoute, LogLevel } from '@prisma/client';
|
|
5
|
-
import { prisma } from '../../../../lib/prisma';
|
|
4
|
+
import { LogRequestMethod, LogRequestRoute, LogLevel, } from '@prisma/client';
|
|
5
|
+
import { prisma as defaultPrisma } from '../../../../lib/prisma';
|
|
6
6
|
import { assistantClientAdapter } from '../../../../lib/assistants/assistantClientAdapter';
|
|
7
7
|
import { createRunOpts } from '../../../../lib/runs/createRunOpts';
|
|
8
8
|
import { scheduleTask } from '../../../../lib/tasks/scheduleTask';
|
|
@@ -15,7 +15,7 @@ import { isOpenaiAssistantsStorageProvider } from '../../../../lib/storageProvid
|
|
|
15
15
|
import { managedOpenaiThreadId } from '../../../../lib/threads/managedOpenaiThreadId';
|
|
16
16
|
import { serializeMetadata } from '../../../../lib/metadata/serializeMetadata';
|
|
17
17
|
export const maxDuration = 800;
|
|
18
|
-
const
|
|
18
|
+
const buildPostHandler = ({ prisma = defaultPrisma } = {}) => async (request) => {
|
|
19
19
|
var _a, _b;
|
|
20
20
|
const { taskId } = await request.json();
|
|
21
21
|
const task = await prisma.task.findUnique({
|
|
@@ -101,6 +101,7 @@ const postHandler = async (request) => {
|
|
|
101
101
|
assistantId: assistant.id,
|
|
102
102
|
threadId: thread.id,
|
|
103
103
|
},
|
|
104
|
+
prisma,
|
|
104
105
|
});
|
|
105
106
|
return NextResponse.json({ error: 'Failed to get storage thread id.' }, { status: 500 });
|
|
106
107
|
}
|
|
@@ -112,6 +113,7 @@ const postHandler = async (request) => {
|
|
|
112
113
|
storageThreadId = await managedOpenaiThreadId({
|
|
113
114
|
assistant,
|
|
114
115
|
threadId: thread.id,
|
|
116
|
+
prisma,
|
|
115
117
|
});
|
|
116
118
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
117
119
|
}
|
|
@@ -127,6 +129,7 @@ const postHandler = async (request) => {
|
|
|
127
129
|
assistantId: assistant.id,
|
|
128
130
|
threadId: thread.id,
|
|
129
131
|
},
|
|
132
|
+
prisma,
|
|
130
133
|
});
|
|
131
134
|
return NextResponse.json({ error: 'Failed to get managed openai thread id.' }, { status: 500 });
|
|
132
135
|
}
|
|
@@ -143,6 +146,7 @@ const postHandler = async (request) => {
|
|
|
143
146
|
assistantId: assistant.id,
|
|
144
147
|
threadId: thread.id,
|
|
145
148
|
},
|
|
149
|
+
prisma,
|
|
146
150
|
});
|
|
147
151
|
return NextResponse.json({ error: 'Invalid thread configuration.' }, { status: 500 });
|
|
148
152
|
}
|
|
@@ -156,6 +160,7 @@ const postHandler = async (request) => {
|
|
|
156
160
|
superinterfaceCreatedById: task.id,
|
|
157
161
|
},
|
|
158
162
|
workspaceId: assistant.workspaceId,
|
|
163
|
+
prisma,
|
|
159
164
|
}),
|
|
160
165
|
});
|
|
161
166
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -173,12 +178,13 @@ const postHandler = async (request) => {
|
|
|
173
178
|
assistantId: assistant.id,
|
|
174
179
|
threadId: thread.id,
|
|
175
180
|
},
|
|
181
|
+
prisma,
|
|
176
182
|
});
|
|
177
183
|
return NextResponse.json({ error: 'Failed to create message' }, { status: 500 });
|
|
178
184
|
}
|
|
179
185
|
let createRunStream;
|
|
180
186
|
try {
|
|
181
|
-
createRunStream = await client.beta.threads.runs.create(storageThreadId, await createRunOpts({ assistant, thread }));
|
|
187
|
+
createRunStream = await client.beta.threads.runs.create(storageThreadId, await createRunOpts({ assistant, thread, prisma }));
|
|
182
188
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
183
189
|
}
|
|
184
190
|
catch (error) {
|
|
@@ -194,13 +200,14 @@ const postHandler = async (request) => {
|
|
|
194
200
|
assistantId: assistant.id,
|
|
195
201
|
threadId: thread.id,
|
|
196
202
|
},
|
|
203
|
+
prisma,
|
|
197
204
|
});
|
|
198
205
|
return NextResponse.json({ error: 'Failed to create run stream' }, { status: 500 });
|
|
199
206
|
}
|
|
200
207
|
const messageResponse = createMessageResponse({
|
|
201
208
|
client,
|
|
202
209
|
createRunStream,
|
|
203
|
-
handleToolCall: handleToolCall({ assistant, thread }),
|
|
210
|
+
handleToolCall: handleToolCall({ assistant, thread, prisma }),
|
|
204
211
|
});
|
|
205
212
|
const decoder = new TextDecoder();
|
|
206
213
|
const reader = messageResponse.getReader();
|
|
@@ -228,9 +235,10 @@ const postHandler = async (request) => {
|
|
|
228
235
|
});
|
|
229
236
|
}
|
|
230
237
|
}
|
|
231
|
-
await scheduleTask({ task });
|
|
238
|
+
await scheduleTask({ task, prisma });
|
|
232
239
|
return NextResponse.json({ ok: true });
|
|
233
240
|
};
|
|
241
|
+
const postHandler = buildPostHandler();
|
|
234
242
|
export const POST = process.env.NODE_ENV === 'test' || !process.env.QSTASH_CURRENT_SIGNING_KEY
|
|
235
243
|
? postHandler
|
|
236
244
|
: verifySignatureAppRouter(postHandler);
|
|
@@ -1,4 +1,21 @@
|
|
|
1
|
+
import { type PrismaClient } from '@prisma/client';
|
|
1
2
|
import { NextResponse, type NextRequest } from 'next/server';
|
|
3
|
+
export declare const buildGET: ({ prisma }?: {
|
|
4
|
+
prisma?: PrismaClient;
|
|
5
|
+
}) => (request: NextRequest) => Promise<NextResponse<{
|
|
6
|
+
error: string;
|
|
7
|
+
}> | NextResponse<{
|
|
8
|
+
tasks: {
|
|
9
|
+
id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
message: string;
|
|
12
|
+
schedule: PrismaJson.TaskSchedule;
|
|
13
|
+
threadId: string;
|
|
14
|
+
key: string;
|
|
15
|
+
createdAt: string;
|
|
16
|
+
updatedAt: string;
|
|
17
|
+
}[];
|
|
18
|
+
}>>;
|
|
2
19
|
export declare const GET: (request: NextRequest) => Promise<NextResponse<{
|
|
3
20
|
error: string;
|
|
4
21
|
}> | NextResponse<{
|
|
@@ -13,6 +30,22 @@ export declare const GET: (request: NextRequest) => Promise<NextResponse<{
|
|
|
13
30
|
updatedAt: string;
|
|
14
31
|
}[];
|
|
15
32
|
}>>;
|
|
33
|
+
export declare const buildPOST: ({ prisma }?: {
|
|
34
|
+
prisma?: PrismaClient;
|
|
35
|
+
}) => (request: NextRequest) => Promise<NextResponse<{
|
|
36
|
+
error: string;
|
|
37
|
+
}> | NextResponse<{
|
|
38
|
+
task: {
|
|
39
|
+
id: string;
|
|
40
|
+
title: string;
|
|
41
|
+
message: string;
|
|
42
|
+
schedule: PrismaJson.TaskSchedule;
|
|
43
|
+
threadId: string;
|
|
44
|
+
key: string;
|
|
45
|
+
createdAt: string;
|
|
46
|
+
updatedAt: string;
|
|
47
|
+
};
|
|
48
|
+
}>>;
|
|
16
49
|
export declare const POST: (request: NextRequest) => Promise<NextResponse<{
|
|
17
50
|
error: string;
|
|
18
51
|
}> | NextResponse<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/app/api/tasks/route.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/app/api/tasks/route.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAS5D,eAAO,MAAM,QAAQ,GAClB,aAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MACpD,SAAS,WAAW;;;;;;;;;;;;;GAoC1B,CAAA;AAEH,eAAO,MAAM,GAAG,YAtCE,WAAW;;;;;;;;;;;;;GAsCA,CAAA;AAE7B,eAAO,MAAM,SAAS,GACnB,aAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MACpD,SAAS,WAAW;;;;;;;;;;;;;GAiE1B,CAAA;AAEH,eAAO,MAAM,IAAI,YAnEC,WAAW;;;;;;;;;;;;;GAmEE,CAAA;AAE/B,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
|
|
@@ -3,12 +3,12 @@ import { ApiKeyType } from '@prisma/client';
|
|
|
3
3
|
import { NextResponse } from 'next/server';
|
|
4
4
|
import { createTaskSchema } from '../../../lib/tasks/schemas';
|
|
5
5
|
import { cacheHeaders } from '../../../lib/cache/cacheHeaders';
|
|
6
|
-
import { prisma } from '../../../lib/prisma';
|
|
6
|
+
import { prisma as defaultPrisma } from '../../../lib/prisma';
|
|
7
7
|
import { serializeTask } from '../../../lib/tasks/serializeTask';
|
|
8
8
|
import { validateSchedule } from '../../../lib/tasks/validateSchedule';
|
|
9
9
|
import { getApiKey } from '../../../lib/apiKeys/getApiKey';
|
|
10
10
|
import { scheduleTask } from '../../../lib/tasks/scheduleTask';
|
|
11
|
-
export const
|
|
11
|
+
export const buildGET = ({ prisma = defaultPrisma } = {}) => async (request) => {
|
|
12
12
|
const headersList = await headers();
|
|
13
13
|
const authorization = headersList.get('authorization');
|
|
14
14
|
if (!authorization) {
|
|
@@ -17,6 +17,7 @@ export const GET = async (request) => {
|
|
|
17
17
|
const privateApiKey = await getApiKey({
|
|
18
18
|
authorization,
|
|
19
19
|
type: ApiKeyType.PRIVATE,
|
|
20
|
+
prisma,
|
|
20
21
|
});
|
|
21
22
|
if (!privateApiKey) {
|
|
22
23
|
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
@@ -30,7 +31,8 @@ export const GET = async (request) => {
|
|
|
30
31
|
tasks: tasks.map((t) => serializeTask({ task: t })),
|
|
31
32
|
}, { headers: cacheHeaders });
|
|
32
33
|
};
|
|
33
|
-
export const
|
|
34
|
+
export const GET = buildGET();
|
|
35
|
+
export const buildPOST = ({ prisma = defaultPrisma } = {}) => async (request) => {
|
|
34
36
|
var _a;
|
|
35
37
|
const headersList = await headers();
|
|
36
38
|
const authorization = headersList.get('authorization');
|
|
@@ -40,6 +42,7 @@ export const POST = async (request) => {
|
|
|
40
42
|
const privateApiKey = await getApiKey({
|
|
41
43
|
authorization,
|
|
42
44
|
type: ApiKeyType.PRIVATE,
|
|
45
|
+
prisma,
|
|
43
46
|
});
|
|
44
47
|
if (!privateApiKey) {
|
|
45
48
|
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
@@ -74,11 +77,12 @@ export const POST = async (request) => {
|
|
|
74
77
|
key: (_a = parsed.data.key) !== null && _a !== void 0 ? _a : '',
|
|
75
78
|
},
|
|
76
79
|
});
|
|
77
|
-
await scheduleTask({ task });
|
|
80
|
+
await scheduleTask({ task, prisma });
|
|
78
81
|
return NextResponse.json({
|
|
79
82
|
task: serializeTask({ task }),
|
|
80
83
|
}, { headers: cacheHeaders });
|
|
81
84
|
};
|
|
85
|
+
export const POST = buildPOST();
|
|
82
86
|
export const OPTIONS = () => NextResponse.json({}, {
|
|
83
87
|
headers: cacheHeaders,
|
|
84
88
|
});
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
-
|
|
2
|
+
import { type PrismaClient } from '@prisma/client';
|
|
3
|
+
export declare const buildPOST: ({ prisma }?: {
|
|
4
|
+
prisma?: PrismaClient;
|
|
5
|
+
}) => (request: NextRequest) => Promise<NextResponse<{
|
|
6
|
+
error: string;
|
|
7
|
+
}> | NextResponse<{
|
|
8
|
+
status: string;
|
|
9
|
+
}>>;
|
|
10
|
+
export declare const POST: (request: NextRequest) => Promise<NextResponse<{
|
|
3
11
|
error: string;
|
|
4
12
|
}> | NextResponse<{
|
|
5
13
|
status: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/threads/runs/submit-client-tool-outputs/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../src/app/api/threads/runs/submit-client-tool-outputs/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAIvD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAGlD,eAAO,MAAM,SAAS,GACnB,aAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MACpD,SAAS,WAAW;;;;GAgD1B,CAAA;AAEH,eAAO,MAAM,IAAI,YAlDC,WAAW;;;;GAkDE,CAAA"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server';
|
|
2
2
|
import { map } from 'p-iteration';
|
|
3
3
|
import { redis } from '../../../../../lib/redis';
|
|
4
|
-
import { prisma } from '../../../../../lib/prisma';
|
|
4
|
+
import { prisma as defaultPrisma } from '../../../../../lib/prisma';
|
|
5
5
|
import { workspaceAccessWhere as getWorkspaceAccessWhere } from '../../../../../lib/apiKeys/workspaceAccessWhere';
|
|
6
|
-
export
|
|
6
|
+
export const buildPOST = ({ prisma = defaultPrisma } = {}) => async (request) => {
|
|
7
7
|
const body = await request.json();
|
|
8
8
|
const { assistantId, publicApiKey, toolOutputs } = body;
|
|
9
9
|
const workspaceAccessWhere = await getWorkspaceAccessWhere({
|
|
10
10
|
publicApiKey,
|
|
11
|
+
prisma,
|
|
11
12
|
});
|
|
12
13
|
if (!workspaceAccessWhere) {
|
|
13
14
|
return NextResponse.json({ error: 'Invalid api key' }, { status: 400 });
|
|
@@ -32,4 +33,5 @@ export async function POST(request) {
|
|
|
32
33
|
}
|
|
33
34
|
});
|
|
34
35
|
return NextResponse.json({ status: 'success' });
|
|
35
|
-
}
|
|
36
|
+
};
|
|
37
|
+
export const POST = buildPOST();
|
|
@@ -1,4 +1,21 @@
|
|
|
1
|
+
import { type PrismaClient } from '@prisma/client';
|
|
1
2
|
import { NextResponse, type NextRequest } from 'next/server';
|
|
3
|
+
export declare const buildGET: ({ prisma }?: {
|
|
4
|
+
prisma?: PrismaClient;
|
|
5
|
+
}) => (_request: NextRequest, props: {
|
|
6
|
+
params: Promise<{
|
|
7
|
+
workspaceId: string;
|
|
8
|
+
}>;
|
|
9
|
+
}) => Promise<NextResponse<{
|
|
10
|
+
error: string;
|
|
11
|
+
}> | NextResponse<{
|
|
12
|
+
workspace: {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
createdAt: string;
|
|
16
|
+
updatedAt: string;
|
|
17
|
+
};
|
|
18
|
+
}>>;
|
|
2
19
|
export declare const GET: (_request: NextRequest, props: {
|
|
3
20
|
params: Promise<{
|
|
4
21
|
workspaceId: string;
|
|
@@ -13,6 +30,22 @@ export declare const GET: (_request: NextRequest, props: {
|
|
|
13
30
|
updatedAt: string;
|
|
14
31
|
};
|
|
15
32
|
}>>;
|
|
33
|
+
export declare const buildPATCH: ({ prisma }?: {
|
|
34
|
+
prisma?: PrismaClient;
|
|
35
|
+
}) => (request: NextRequest, props: {
|
|
36
|
+
params: Promise<{
|
|
37
|
+
workspaceId: string;
|
|
38
|
+
}>;
|
|
39
|
+
}) => Promise<NextResponse<{
|
|
40
|
+
error: string;
|
|
41
|
+
}> | NextResponse<{
|
|
42
|
+
workspace: {
|
|
43
|
+
id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
createdAt: string;
|
|
46
|
+
updatedAt: string;
|
|
47
|
+
};
|
|
48
|
+
}>>;
|
|
16
49
|
export declare const PATCH: (request: NextRequest, props: {
|
|
17
50
|
params: Promise<{
|
|
18
51
|
workspaceId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/workspaces/[workspaceId]/route.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../src/app/api/workspaces/[workspaceId]/route.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAQ5D,eAAO,MAAM,QAAQ,GAClB,aAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,UAAU,WAAW,EACrB,OAAO;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;GAkDpD,CAAA;AAEH,eAAO,MAAM,GAAG,aArDF,WAAW,SACd;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;GAoD1B,CAAA;AAE7B,eAAO,MAAM,UAAU,GACpB,aAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO,MAEzD,SAAS,WAAW,EACpB,OAAO;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;GAsEpD,CAAA;AAEH,eAAO,MAAM,KAAK,YAzEL,WAAW,SACb;IAAE,MAAM,EAAE,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE;;;;;;;;;GAwEtB,CAAA;AAEjC,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
|
|
@@ -2,11 +2,11 @@ import { headers } from 'next/headers';
|
|
|
2
2
|
import { NextResponse } from 'next/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { cacheHeaders } from '../../../../lib/cache/cacheHeaders';
|
|
5
|
-
import { prisma } from '../../../../lib/prisma';
|
|
5
|
+
import { prisma as defaultPrisma } from '../../../../lib/prisma';
|
|
6
6
|
import { validate } from 'uuid';
|
|
7
7
|
import { getOrganizationApiKey } from '../../../../lib/organizationApiKeys/getOrganizationApiKey';
|
|
8
8
|
import { serializeApiWorkspace } from '../../../../lib/workspaces/serializeApiWorkspace';
|
|
9
|
-
export const
|
|
9
|
+
export const buildGET = ({ prisma = defaultPrisma } = {}) => async (_request, props) => {
|
|
10
10
|
const { workspaceId } = await props.params;
|
|
11
11
|
const headersList = await headers();
|
|
12
12
|
const authorization = headersList.get('authorization');
|
|
@@ -15,6 +15,7 @@ export const GET = async (_request, props) => {
|
|
|
15
15
|
}
|
|
16
16
|
const organizationApiKey = await getOrganizationApiKey({
|
|
17
17
|
authorization,
|
|
18
|
+
prisma,
|
|
18
19
|
});
|
|
19
20
|
if (!organizationApiKey) {
|
|
20
21
|
return NextResponse.json({ error: 'Invalid organization api key' }, { status: 400 });
|
|
@@ -35,7 +36,8 @@ export const GET = async (_request, props) => {
|
|
|
35
36
|
workspace: serializeApiWorkspace({ workspace }),
|
|
36
37
|
}, { headers: cacheHeaders });
|
|
37
38
|
};
|
|
38
|
-
export const
|
|
39
|
+
export const GET = buildGET();
|
|
40
|
+
export const buildPATCH = ({ prisma = defaultPrisma } = {}) => async (request, props) => {
|
|
39
41
|
const { workspaceId } = await props.params;
|
|
40
42
|
const headersList = await headers();
|
|
41
43
|
const authorization = headersList.get('authorization');
|
|
@@ -44,6 +46,7 @@ export const PATCH = async (request, props) => {
|
|
|
44
46
|
}
|
|
45
47
|
const organizationApiKey = await getOrganizationApiKey({
|
|
46
48
|
authorization,
|
|
49
|
+
prisma,
|
|
47
50
|
});
|
|
48
51
|
if (!organizationApiKey) {
|
|
49
52
|
return NextResponse.json({ error: 'Invalid organization api key' }, { status: 400 });
|
|
@@ -78,6 +81,7 @@ export const PATCH = async (request, props) => {
|
|
|
78
81
|
workspace: serializeApiWorkspace({ workspace }),
|
|
79
82
|
}, { headers: cacheHeaders });
|
|
80
83
|
};
|
|
84
|
+
export const PATCH = buildPATCH();
|
|
81
85
|
export const OPTIONS = () => NextResponse.json({}, {
|
|
82
86
|
headers: cacheHeaders,
|
|
83
87
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Organization, Workspace } from '@prisma/client';
|
|
1
|
+
import type { Organization, Workspace, PrismaClient } from '@prisma/client';
|
|
2
2
|
import { NextResponse, type NextRequest } from 'next/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
declare const createWorkspaceSchema: z.ZodObject<{
|
|
@@ -8,6 +8,18 @@ declare const createWorkspaceSchema: z.ZodObject<{
|
|
|
8
8
|
}, {
|
|
9
9
|
name?: string | undefined;
|
|
10
10
|
}>;
|
|
11
|
+
export declare const buildGET: ({ prisma }?: {
|
|
12
|
+
prisma?: PrismaClient;
|
|
13
|
+
}) => () => Promise<NextResponse<{
|
|
14
|
+
error: string;
|
|
15
|
+
}> | NextResponse<{
|
|
16
|
+
workspaces: {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
createdAt: string;
|
|
20
|
+
updatedAt: string;
|
|
21
|
+
}[];
|
|
22
|
+
}>>;
|
|
11
23
|
export declare const GET: () => Promise<NextResponse<{
|
|
12
24
|
error: string;
|
|
13
25
|
}> | NextResponse<{
|
|
@@ -18,10 +30,12 @@ export declare const GET: () => Promise<NextResponse<{
|
|
|
18
30
|
updatedAt: string;
|
|
19
31
|
}[];
|
|
20
32
|
}>>;
|
|
21
|
-
export declare const buildPOST: ({ createWorkspace, }
|
|
22
|
-
|
|
33
|
+
export declare const buildPOST: ({ prisma, createWorkspace, }?: {
|
|
34
|
+
prisma?: PrismaClient;
|
|
35
|
+
createWorkspace?: ({ parsedData, organization, prisma, }: {
|
|
23
36
|
parsedData: z.infer<typeof createWorkspaceSchema>;
|
|
24
37
|
organization: Organization;
|
|
38
|
+
prisma: PrismaClient;
|
|
25
39
|
}) => Promise<Workspace>;
|
|
26
40
|
}) => (request: NextRequest) => Promise<NextResponse<{
|
|
27
41
|
error: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/app/api/workspaces/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/app/api/workspaces/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE3E,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,QAAA,MAAM,qBAAqB;;;;;;EAEzB,CAAA;AAEF,eAAO,MAAM,QAAQ,GAClB,aAA4B;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAO;;;;;;;;;GAsC1D,CAAA;AAEH,eAAO,MAAM,GAAG;;;;;;;;;GAAa,CAAA;AAE7B,eAAO,MAAM,SAAS,GACnB,+BAiBE;IACD,MAAM,CAAC,EAAE,YAAY,CAAA;IACrB,eAAe,CAAC,EAAE,CAAC,EACjB,UAAU,EACV,YAAY,EACZ,MAAM,GACP,EAAE;QACD,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;QACjD,YAAY,EAAE,YAAY,CAAA;QAC1B,MAAM,EAAE,YAAY,CAAA;KACrB,KAAK,OAAO,CAAC,SAAS,CAAC,CAAA;CACpB,MACC,SAAS,WAAW;;;;;;;;;GAuD1B,CAAA;AAEH,eAAO,MAAM,IAAI,YAzDC,WAAW;;;;;;;;;GAyDI,CAAA;AAEjC,eAAO,MAAM,OAAO,wBAMjB,CAAA"}
|
|
@@ -2,13 +2,13 @@ import { headers } from 'next/headers';
|
|
|
2
2
|
import { NextResponse } from 'next/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { cacheHeaders } from '../../../lib/cache/cacheHeaders';
|
|
5
|
-
import { prisma } from '../../../lib/prisma';
|
|
5
|
+
import { prisma as defaultPrisma } from '../../../lib/prisma';
|
|
6
6
|
import { serializeApiWorkspace } from '../../../lib/workspaces/serializeApiWorkspace';
|
|
7
7
|
import { getOrganizationApiKey } from '../../../lib/organizationApiKeys/getOrganizationApiKey';
|
|
8
8
|
const createWorkspaceSchema = z.object({
|
|
9
9
|
name: z.string().optional(),
|
|
10
10
|
});
|
|
11
|
-
export const
|
|
11
|
+
export const buildGET = ({ prisma = defaultPrisma } = {}) => async () => {
|
|
12
12
|
const headersList = await headers();
|
|
13
13
|
const authorization = headersList.get('authorization');
|
|
14
14
|
if (!authorization) {
|
|
@@ -16,6 +16,7 @@ export const GET = async () => {
|
|
|
16
16
|
}
|
|
17
17
|
const organizationApiKey = await getOrganizationApiKey({
|
|
18
18
|
authorization,
|
|
19
|
+
prisma,
|
|
19
20
|
});
|
|
20
21
|
if (!organizationApiKey) {
|
|
21
22
|
return NextResponse.json({ error: 'Invalid organization api key' }, { status: 400 });
|
|
@@ -29,7 +30,8 @@ export const GET = async () => {
|
|
|
29
30
|
workspaces: workspaces.map((workspace) => serializeApiWorkspace({ workspace })),
|
|
30
31
|
}, { headers: cacheHeaders });
|
|
31
32
|
};
|
|
32
|
-
export const
|
|
33
|
+
export const GET = buildGET();
|
|
34
|
+
export const buildPOST = ({ prisma = defaultPrisma, createWorkspace = ({ parsedData, organization, prisma, }) => {
|
|
33
35
|
var _a;
|
|
34
36
|
return prisma.workspace.create({
|
|
35
37
|
data: {
|
|
@@ -37,7 +39,7 @@ export const buildPOST = ({ createWorkspace = ({ parsedData, organization, }) =>
|
|
|
37
39
|
organizationId: organization.id,
|
|
38
40
|
},
|
|
39
41
|
});
|
|
40
|
-
}, }) => async (request) => {
|
|
42
|
+
}, } = {}) => async (request) => {
|
|
41
43
|
const headersList = await headers();
|
|
42
44
|
const authorization = headersList.get('authorization');
|
|
43
45
|
if (!authorization) {
|
|
@@ -45,6 +47,7 @@ export const buildPOST = ({ createWorkspace = ({ parsedData, organization, }) =>
|
|
|
45
47
|
}
|
|
46
48
|
const organizationApiKey = await getOrganizationApiKey({
|
|
47
49
|
authorization,
|
|
50
|
+
prisma,
|
|
48
51
|
});
|
|
49
52
|
if (!organizationApiKey) {
|
|
50
53
|
return NextResponse.json({ error: 'Invalid organization api key' }, { status: 400 });
|
|
@@ -65,6 +68,7 @@ export const buildPOST = ({ createWorkspace = ({ parsedData, organization, }) =>
|
|
|
65
68
|
const workspace = await createWorkspace({
|
|
66
69
|
parsedData: parsed.data,
|
|
67
70
|
organization,
|
|
71
|
+
prisma,
|
|
68
72
|
});
|
|
69
73
|
return NextResponse.json({
|
|
70
74
|
workspace: serializeApiWorkspace({ workspace }),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ApiKeyType, ApiKey } from '@prisma/client';
|
|
2
|
-
export declare const getApiKey: ({ authorization, type, }: {
|
|
1
|
+
import { ApiKeyType, ApiKey, type PrismaClient } from '@prisma/client';
|
|
2
|
+
export declare const getApiKey: ({ authorization, type, prisma, }: {
|
|
3
3
|
authorization: string | null;
|
|
4
4
|
type: ApiKeyType;
|
|
5
|
+
prisma: PrismaClient;
|
|
5
6
|
}) => Promise<ApiKey | null>;
|
|
6
7
|
//# sourceMappingURL=getApiKey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getApiKey.d.ts","sourceRoot":"","sources":["../../../src/lib/apiKeys/getApiKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"getApiKey.d.ts","sourceRoot":"","sources":["../../../src/lib/apiKeys/getApiKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAGtE,eAAO,MAAM,SAAS,GAAU,kCAI7B;IACD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,IAAI,EAAE,UAAU,CAAA;IAChB,MAAM,EAAE,YAAY,CAAA;CACrB,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAcxB,CAAA"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { type PrismaClient } from '@prisma/client';
|
|
2
|
+
export declare const workspaceAccessWhere: ({ publicApiKey, prisma, }: {
|
|
2
3
|
publicApiKey: string | null;
|
|
4
|
+
prisma: PrismaClient;
|
|
3
5
|
}) => Promise<{
|
|
4
6
|
apiKeys: {
|
|
5
7
|
some: {
|