@the-portland-company/devnotes 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +91 -0
- package/bin/setup.js +100 -0
- package/dist/index.d.mts +261 -0
- package/dist/index.d.ts +261 -0
- package/dist/index.js +4514 -0
- package/dist/index.mjs +4521 -0
- package/dist/router-Bt8qbFfY.d.ts +49 -0
- package/dist/router-CPtxoMg5.d.mts +49 -0
- package/dist/server/express.d.mts +6 -0
- package/dist/server/express.d.ts +6 -0
- package/dist/server/express.js +130 -0
- package/dist/server/express.mjs +103 -0
- package/dist/server/next.d.mts +10 -0
- package/dist/server/next.d.ts +10 -0
- package/dist/server/next.js +138 -0
- package/dist/server/next.mjs +111 -0
- package/dist/styles.css +1 -0
- package/dist/types-xqGNcAbZ.d.mts +185 -0
- package/dist/types-xqGNcAbZ.d.ts +185 -0
- package/package.json +84 -0
- package/templates/DevNotesWrapper.tsx +47 -0
- package/templates/ExpressDevNotesProxy.ts +71 -0
- package/templates/NextDevNotesRoute.ts +76 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { e as DevNotesCapabilities, f as DevNotesAppLinkStatus, n as DevNotesLinkAppInput, B as BugReport, l as BugReportCreateData, c as BugReportType, T as TaskList, m as BugReportMessage, d as BugReportCreator, k as AiConversationMessage, i as BugCaptureContext, j as AiAssistResult } from './types-xqGNcAbZ.js';
|
|
2
|
+
|
|
3
|
+
type DevNotesProxyRequest = {
|
|
4
|
+
method: string;
|
|
5
|
+
slug: string[];
|
|
6
|
+
request: Request;
|
|
7
|
+
authToken: string | null;
|
|
8
|
+
query: URLSearchParams;
|
|
9
|
+
body: any;
|
|
10
|
+
};
|
|
11
|
+
interface DevNotesProxyBackend {
|
|
12
|
+
getCapabilities(req: DevNotesProxyRequest): Promise<DevNotesCapabilities>;
|
|
13
|
+
getAppLinkStatus(req: DevNotesProxyRequest): Promise<DevNotesAppLinkStatus>;
|
|
14
|
+
linkApp(input: DevNotesLinkAppInput, req: DevNotesProxyRequest): Promise<DevNotesAppLinkStatus>;
|
|
15
|
+
unlinkApp(req: DevNotesProxyRequest): Promise<void>;
|
|
16
|
+
listReports(req: DevNotesProxyRequest): Promise<BugReport[]>;
|
|
17
|
+
createReport(data: BugReportCreateData, req: DevNotesProxyRequest): Promise<BugReport>;
|
|
18
|
+
updateReport(id: string, data: Partial<BugReport>, req: DevNotesProxyRequest): Promise<BugReport>;
|
|
19
|
+
deleteReport(id: string, req: DevNotesProxyRequest): Promise<void>;
|
|
20
|
+
listReportTypes(req: DevNotesProxyRequest): Promise<BugReportType[]>;
|
|
21
|
+
createReportType(name: string, req: DevNotesProxyRequest): Promise<BugReportType>;
|
|
22
|
+
deleteReportType(id: string, req: DevNotesProxyRequest): Promise<void>;
|
|
23
|
+
listTaskLists(req: DevNotesProxyRequest): Promise<TaskList[]>;
|
|
24
|
+
createTaskList(name: string, req: DevNotesProxyRequest): Promise<TaskList>;
|
|
25
|
+
listMessages(reportId: string, req: DevNotesProxyRequest): Promise<BugReportMessage[]>;
|
|
26
|
+
createMessage(reportId: string, body: string, req: DevNotesProxyRequest): Promise<BugReportMessage>;
|
|
27
|
+
updateMessage(id: string, body: string, req: DevNotesProxyRequest): Promise<BugReportMessage>;
|
|
28
|
+
deleteMessage(id: string, req: DevNotesProxyRequest): Promise<void>;
|
|
29
|
+
getUnreadCounts(req: DevNotesProxyRequest): Promise<Record<string, number>>;
|
|
30
|
+
markMessagesRead(messageIds: string[], req: DevNotesProxyRequest): Promise<void>;
|
|
31
|
+
listCollaborators(ids: string[] | null, req: DevNotesProxyRequest): Promise<BugReportCreator[]>;
|
|
32
|
+
refineDescription?: (input: {
|
|
33
|
+
description: string;
|
|
34
|
+
conversationHistory: AiConversationMessage[];
|
|
35
|
+
context: {
|
|
36
|
+
title?: string;
|
|
37
|
+
page_url?: string;
|
|
38
|
+
route_label?: string;
|
|
39
|
+
severity?: string;
|
|
40
|
+
types?: string[];
|
|
41
|
+
target_selector?: string;
|
|
42
|
+
expected_behavior?: string;
|
|
43
|
+
actual_behavior?: string;
|
|
44
|
+
capture_context?: BugCaptureContext;
|
|
45
|
+
};
|
|
46
|
+
}, req: DevNotesProxyRequest) => Promise<AiAssistResult>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type { DevNotesProxyBackend as D };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { e as DevNotesCapabilities, f as DevNotesAppLinkStatus, n as DevNotesLinkAppInput, B as BugReport, l as BugReportCreateData, c as BugReportType, T as TaskList, m as BugReportMessage, d as BugReportCreator, k as AiConversationMessage, i as BugCaptureContext, j as AiAssistResult } from './types-xqGNcAbZ.mjs';
|
|
2
|
+
|
|
3
|
+
type DevNotesProxyRequest = {
|
|
4
|
+
method: string;
|
|
5
|
+
slug: string[];
|
|
6
|
+
request: Request;
|
|
7
|
+
authToken: string | null;
|
|
8
|
+
query: URLSearchParams;
|
|
9
|
+
body: any;
|
|
10
|
+
};
|
|
11
|
+
interface DevNotesProxyBackend {
|
|
12
|
+
getCapabilities(req: DevNotesProxyRequest): Promise<DevNotesCapabilities>;
|
|
13
|
+
getAppLinkStatus(req: DevNotesProxyRequest): Promise<DevNotesAppLinkStatus>;
|
|
14
|
+
linkApp(input: DevNotesLinkAppInput, req: DevNotesProxyRequest): Promise<DevNotesAppLinkStatus>;
|
|
15
|
+
unlinkApp(req: DevNotesProxyRequest): Promise<void>;
|
|
16
|
+
listReports(req: DevNotesProxyRequest): Promise<BugReport[]>;
|
|
17
|
+
createReport(data: BugReportCreateData, req: DevNotesProxyRequest): Promise<BugReport>;
|
|
18
|
+
updateReport(id: string, data: Partial<BugReport>, req: DevNotesProxyRequest): Promise<BugReport>;
|
|
19
|
+
deleteReport(id: string, req: DevNotesProxyRequest): Promise<void>;
|
|
20
|
+
listReportTypes(req: DevNotesProxyRequest): Promise<BugReportType[]>;
|
|
21
|
+
createReportType(name: string, req: DevNotesProxyRequest): Promise<BugReportType>;
|
|
22
|
+
deleteReportType(id: string, req: DevNotesProxyRequest): Promise<void>;
|
|
23
|
+
listTaskLists(req: DevNotesProxyRequest): Promise<TaskList[]>;
|
|
24
|
+
createTaskList(name: string, req: DevNotesProxyRequest): Promise<TaskList>;
|
|
25
|
+
listMessages(reportId: string, req: DevNotesProxyRequest): Promise<BugReportMessage[]>;
|
|
26
|
+
createMessage(reportId: string, body: string, req: DevNotesProxyRequest): Promise<BugReportMessage>;
|
|
27
|
+
updateMessage(id: string, body: string, req: DevNotesProxyRequest): Promise<BugReportMessage>;
|
|
28
|
+
deleteMessage(id: string, req: DevNotesProxyRequest): Promise<void>;
|
|
29
|
+
getUnreadCounts(req: DevNotesProxyRequest): Promise<Record<string, number>>;
|
|
30
|
+
markMessagesRead(messageIds: string[], req: DevNotesProxyRequest): Promise<void>;
|
|
31
|
+
listCollaborators(ids: string[] | null, req: DevNotesProxyRequest): Promise<BugReportCreator[]>;
|
|
32
|
+
refineDescription?: (input: {
|
|
33
|
+
description: string;
|
|
34
|
+
conversationHistory: AiConversationMessage[];
|
|
35
|
+
context: {
|
|
36
|
+
title?: string;
|
|
37
|
+
page_url?: string;
|
|
38
|
+
route_label?: string;
|
|
39
|
+
severity?: string;
|
|
40
|
+
types?: string[];
|
|
41
|
+
target_selector?: string;
|
|
42
|
+
expected_behavior?: string;
|
|
43
|
+
actual_behavior?: string;
|
|
44
|
+
capture_context?: BugCaptureContext;
|
|
45
|
+
};
|
|
46
|
+
}, req: DevNotesProxyRequest) => Promise<AiAssistResult>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type { DevNotesProxyBackend as D };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/server/express.ts
|
|
21
|
+
var express_exports = {};
|
|
22
|
+
__export(express_exports, {
|
|
23
|
+
createExpressDevNotesProxy: () => createExpressDevNotesProxy
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(express_exports);
|
|
26
|
+
|
|
27
|
+
// src/server/router.ts
|
|
28
|
+
var json = (body, status = 200) => ({ status, body });
|
|
29
|
+
var getId = (slug, index) => decodeURIComponent(slug[index] || "");
|
|
30
|
+
async function routeDevNotesProxy(backend, req) {
|
|
31
|
+
const [resource, resourceId, nested] = req.slug;
|
|
32
|
+
const method = req.method.toUpperCase();
|
|
33
|
+
if (resource === "capabilities" && method === "GET") {
|
|
34
|
+
return json(await backend.getCapabilities(req));
|
|
35
|
+
}
|
|
36
|
+
if (resource === "app-link") {
|
|
37
|
+
if (method === "GET") return json(await backend.getAppLinkStatus(req));
|
|
38
|
+
if (method === "POST") return json(await backend.linkApp(req.body, req));
|
|
39
|
+
if (method === "DELETE") {
|
|
40
|
+
await backend.unlinkApp(req);
|
|
41
|
+
return json({ success: true });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (resource === "reports" && method === "GET" && !resourceId) {
|
|
45
|
+
return json(await backend.listReports(req));
|
|
46
|
+
}
|
|
47
|
+
if (resource === "reports" && method === "POST" && !resourceId) {
|
|
48
|
+
return json(await backend.createReport(req.body, req));
|
|
49
|
+
}
|
|
50
|
+
if (resource === "reports" && method === "PATCH" && resourceId && !nested) {
|
|
51
|
+
return json(await backend.updateReport(getId(req.slug, 1), req.body, req));
|
|
52
|
+
}
|
|
53
|
+
if (resource === "reports" && method === "DELETE" && resourceId && !nested) {
|
|
54
|
+
await backend.deleteReport(getId(req.slug, 1), req);
|
|
55
|
+
return json({ success: true });
|
|
56
|
+
}
|
|
57
|
+
if (resource === "reports" && resourceId && nested === "messages") {
|
|
58
|
+
if (method === "GET") return json(await backend.listMessages(getId(req.slug, 1), req));
|
|
59
|
+
if (method === "POST") {
|
|
60
|
+
return json(await backend.createMessage(getId(req.slug, 1), String(req.body?.body || ""), req));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (resource === "report-types") {
|
|
64
|
+
if (method === "GET" && !resourceId) return json(await backend.listReportTypes(req));
|
|
65
|
+
if (method === "POST" && !resourceId) {
|
|
66
|
+
return json(await backend.createReportType(String(req.body?.name || ""), req));
|
|
67
|
+
}
|
|
68
|
+
if (method === "DELETE" && resourceId) {
|
|
69
|
+
await backend.deleteReportType(getId(req.slug, 1), req);
|
|
70
|
+
return json({ success: true });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (resource === "task-lists") {
|
|
74
|
+
if (method === "GET" && !resourceId) return json(await backend.listTaskLists(req));
|
|
75
|
+
if (method === "POST" && !resourceId) {
|
|
76
|
+
return json(await backend.createTaskList(String(req.body?.name || ""), req));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (resource === "messages" && resourceId && method === "PATCH") {
|
|
80
|
+
return json(await backend.updateMessage(getId(req.slug, 1), String(req.body?.body || ""), req));
|
|
81
|
+
}
|
|
82
|
+
if (resource === "messages" && resourceId && method === "DELETE") {
|
|
83
|
+
await backend.deleteMessage(getId(req.slug, 1), req);
|
|
84
|
+
return json({ success: true });
|
|
85
|
+
}
|
|
86
|
+
if (resource === "messages" && resourceId === "read" && method === "POST") {
|
|
87
|
+
await backend.markMessagesRead(Array.isArray(req.body?.messageIds) ? req.body.messageIds : [], req);
|
|
88
|
+
return json({ success: true });
|
|
89
|
+
}
|
|
90
|
+
if (resource === "unread-counts" && method === "GET") {
|
|
91
|
+
return json(await backend.getUnreadCounts(req));
|
|
92
|
+
}
|
|
93
|
+
if (resource === "collaborators" && method === "GET") {
|
|
94
|
+
const ids = req.query.get("ids");
|
|
95
|
+
return json(await backend.listCollaborators(ids ? ids.split(",").filter(Boolean) : null, req));
|
|
96
|
+
}
|
|
97
|
+
if (resource === "ai" && resourceId === "refine-description" && method === "POST") {
|
|
98
|
+
if (!backend.refineDescription) {
|
|
99
|
+
return json({ error: "AI refinement is not configured." }, 404);
|
|
100
|
+
}
|
|
101
|
+
return json(await backend.refineDescription(req.body, req));
|
|
102
|
+
}
|
|
103
|
+
return json({ error: "Not found" }, 404);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// src/server/express.ts
|
|
107
|
+
function createExpressDevNotesProxy(backend) {
|
|
108
|
+
return async function devNotesProxy(req, res) {
|
|
109
|
+
const slug = Array.isArray(req.params?.[0]) ? req.params[0] : String(req.params?.[0] || "").split("/").filter(Boolean);
|
|
110
|
+
const request = new Request(`http://localhost${req.originalUrl || req.url}`, {
|
|
111
|
+
method: req.method,
|
|
112
|
+
headers: req.headers,
|
|
113
|
+
body: req.method === "GET" || req.method === "HEAD" ? void 0 : JSON.stringify(req.body || {})
|
|
114
|
+
});
|
|
115
|
+
const proxyRequest = {
|
|
116
|
+
method: req.method,
|
|
117
|
+
slug,
|
|
118
|
+
request,
|
|
119
|
+
authToken: req.headers?.authorization || null,
|
|
120
|
+
query: new URL(request.url).searchParams,
|
|
121
|
+
body: req.body || null
|
|
122
|
+
};
|
|
123
|
+
const result = await routeDevNotesProxy(backend, proxyRequest);
|
|
124
|
+
res.status(result.status ?? 200).json(result.body ?? null);
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
128
|
+
0 && (module.exports = {
|
|
129
|
+
createExpressDevNotesProxy
|
|
130
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// src/server/router.ts
|
|
2
|
+
var json = (body, status = 200) => ({ status, body });
|
|
3
|
+
var getId = (slug, index) => decodeURIComponent(slug[index] || "");
|
|
4
|
+
async function routeDevNotesProxy(backend, req) {
|
|
5
|
+
const [resource, resourceId, nested] = req.slug;
|
|
6
|
+
const method = req.method.toUpperCase();
|
|
7
|
+
if (resource === "capabilities" && method === "GET") {
|
|
8
|
+
return json(await backend.getCapabilities(req));
|
|
9
|
+
}
|
|
10
|
+
if (resource === "app-link") {
|
|
11
|
+
if (method === "GET") return json(await backend.getAppLinkStatus(req));
|
|
12
|
+
if (method === "POST") return json(await backend.linkApp(req.body, req));
|
|
13
|
+
if (method === "DELETE") {
|
|
14
|
+
await backend.unlinkApp(req);
|
|
15
|
+
return json({ success: true });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (resource === "reports" && method === "GET" && !resourceId) {
|
|
19
|
+
return json(await backend.listReports(req));
|
|
20
|
+
}
|
|
21
|
+
if (resource === "reports" && method === "POST" && !resourceId) {
|
|
22
|
+
return json(await backend.createReport(req.body, req));
|
|
23
|
+
}
|
|
24
|
+
if (resource === "reports" && method === "PATCH" && resourceId && !nested) {
|
|
25
|
+
return json(await backend.updateReport(getId(req.slug, 1), req.body, req));
|
|
26
|
+
}
|
|
27
|
+
if (resource === "reports" && method === "DELETE" && resourceId && !nested) {
|
|
28
|
+
await backend.deleteReport(getId(req.slug, 1), req);
|
|
29
|
+
return json({ success: true });
|
|
30
|
+
}
|
|
31
|
+
if (resource === "reports" && resourceId && nested === "messages") {
|
|
32
|
+
if (method === "GET") return json(await backend.listMessages(getId(req.slug, 1), req));
|
|
33
|
+
if (method === "POST") {
|
|
34
|
+
return json(await backend.createMessage(getId(req.slug, 1), String(req.body?.body || ""), req));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (resource === "report-types") {
|
|
38
|
+
if (method === "GET" && !resourceId) return json(await backend.listReportTypes(req));
|
|
39
|
+
if (method === "POST" && !resourceId) {
|
|
40
|
+
return json(await backend.createReportType(String(req.body?.name || ""), req));
|
|
41
|
+
}
|
|
42
|
+
if (method === "DELETE" && resourceId) {
|
|
43
|
+
await backend.deleteReportType(getId(req.slug, 1), req);
|
|
44
|
+
return json({ success: true });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (resource === "task-lists") {
|
|
48
|
+
if (method === "GET" && !resourceId) return json(await backend.listTaskLists(req));
|
|
49
|
+
if (method === "POST" && !resourceId) {
|
|
50
|
+
return json(await backend.createTaskList(String(req.body?.name || ""), req));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (resource === "messages" && resourceId && method === "PATCH") {
|
|
54
|
+
return json(await backend.updateMessage(getId(req.slug, 1), String(req.body?.body || ""), req));
|
|
55
|
+
}
|
|
56
|
+
if (resource === "messages" && resourceId && method === "DELETE") {
|
|
57
|
+
await backend.deleteMessage(getId(req.slug, 1), req);
|
|
58
|
+
return json({ success: true });
|
|
59
|
+
}
|
|
60
|
+
if (resource === "messages" && resourceId === "read" && method === "POST") {
|
|
61
|
+
await backend.markMessagesRead(Array.isArray(req.body?.messageIds) ? req.body.messageIds : [], req);
|
|
62
|
+
return json({ success: true });
|
|
63
|
+
}
|
|
64
|
+
if (resource === "unread-counts" && method === "GET") {
|
|
65
|
+
return json(await backend.getUnreadCounts(req));
|
|
66
|
+
}
|
|
67
|
+
if (resource === "collaborators" && method === "GET") {
|
|
68
|
+
const ids = req.query.get("ids");
|
|
69
|
+
return json(await backend.listCollaborators(ids ? ids.split(",").filter(Boolean) : null, req));
|
|
70
|
+
}
|
|
71
|
+
if (resource === "ai" && resourceId === "refine-description" && method === "POST") {
|
|
72
|
+
if (!backend.refineDescription) {
|
|
73
|
+
return json({ error: "AI refinement is not configured." }, 404);
|
|
74
|
+
}
|
|
75
|
+
return json(await backend.refineDescription(req.body, req));
|
|
76
|
+
}
|
|
77
|
+
return json({ error: "Not found" }, 404);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// src/server/express.ts
|
|
81
|
+
function createExpressDevNotesProxy(backend) {
|
|
82
|
+
return async function devNotesProxy(req, res) {
|
|
83
|
+
const slug = Array.isArray(req.params?.[0]) ? req.params[0] : String(req.params?.[0] || "").split("/").filter(Boolean);
|
|
84
|
+
const request = new Request(`http://localhost${req.originalUrl || req.url}`, {
|
|
85
|
+
method: req.method,
|
|
86
|
+
headers: req.headers,
|
|
87
|
+
body: req.method === "GET" || req.method === "HEAD" ? void 0 : JSON.stringify(req.body || {})
|
|
88
|
+
});
|
|
89
|
+
const proxyRequest = {
|
|
90
|
+
method: req.method,
|
|
91
|
+
slug,
|
|
92
|
+
request,
|
|
93
|
+
authToken: req.headers?.authorization || null,
|
|
94
|
+
query: new URL(request.url).searchParams,
|
|
95
|
+
body: req.body || null
|
|
96
|
+
};
|
|
97
|
+
const result = await routeDevNotesProxy(backend, proxyRequest);
|
|
98
|
+
res.status(result.status ?? 200).json(result.body ?? null);
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
createExpressDevNotesProxy
|
|
103
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { D as DevNotesProxyBackend } from '../router-CPtxoMg5.mjs';
|
|
2
|
+
import '../types-xqGNcAbZ.mjs';
|
|
3
|
+
|
|
4
|
+
declare function createNextDevNotesProxy(backend: DevNotesProxyBackend): (request: Request, context?: {
|
|
5
|
+
params?: {
|
|
6
|
+
slug?: string[];
|
|
7
|
+
};
|
|
8
|
+
}) => Promise<Response>;
|
|
9
|
+
|
|
10
|
+
export { createNextDevNotesProxy };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { D as DevNotesProxyBackend } from '../router-Bt8qbFfY.js';
|
|
2
|
+
import '../types-xqGNcAbZ.js';
|
|
3
|
+
|
|
4
|
+
declare function createNextDevNotesProxy(backend: DevNotesProxyBackend): (request: Request, context?: {
|
|
5
|
+
params?: {
|
|
6
|
+
slug?: string[];
|
|
7
|
+
};
|
|
8
|
+
}) => Promise<Response>;
|
|
9
|
+
|
|
10
|
+
export { createNextDevNotesProxy };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/server/next.ts
|
|
21
|
+
var next_exports = {};
|
|
22
|
+
__export(next_exports, {
|
|
23
|
+
createNextDevNotesProxy: () => createNextDevNotesProxy
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(next_exports);
|
|
26
|
+
|
|
27
|
+
// src/server/router.ts
|
|
28
|
+
var json = (body, status = 200) => ({ status, body });
|
|
29
|
+
var getId = (slug, index) => decodeURIComponent(slug[index] || "");
|
|
30
|
+
async function routeDevNotesProxy(backend, req) {
|
|
31
|
+
const [resource, resourceId, nested] = req.slug;
|
|
32
|
+
const method = req.method.toUpperCase();
|
|
33
|
+
if (resource === "capabilities" && method === "GET") {
|
|
34
|
+
return json(await backend.getCapabilities(req));
|
|
35
|
+
}
|
|
36
|
+
if (resource === "app-link") {
|
|
37
|
+
if (method === "GET") return json(await backend.getAppLinkStatus(req));
|
|
38
|
+
if (method === "POST") return json(await backend.linkApp(req.body, req));
|
|
39
|
+
if (method === "DELETE") {
|
|
40
|
+
await backend.unlinkApp(req);
|
|
41
|
+
return json({ success: true });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (resource === "reports" && method === "GET" && !resourceId) {
|
|
45
|
+
return json(await backend.listReports(req));
|
|
46
|
+
}
|
|
47
|
+
if (resource === "reports" && method === "POST" && !resourceId) {
|
|
48
|
+
return json(await backend.createReport(req.body, req));
|
|
49
|
+
}
|
|
50
|
+
if (resource === "reports" && method === "PATCH" && resourceId && !nested) {
|
|
51
|
+
return json(await backend.updateReport(getId(req.slug, 1), req.body, req));
|
|
52
|
+
}
|
|
53
|
+
if (resource === "reports" && method === "DELETE" && resourceId && !nested) {
|
|
54
|
+
await backend.deleteReport(getId(req.slug, 1), req);
|
|
55
|
+
return json({ success: true });
|
|
56
|
+
}
|
|
57
|
+
if (resource === "reports" && resourceId && nested === "messages") {
|
|
58
|
+
if (method === "GET") return json(await backend.listMessages(getId(req.slug, 1), req));
|
|
59
|
+
if (method === "POST") {
|
|
60
|
+
return json(await backend.createMessage(getId(req.slug, 1), String(req.body?.body || ""), req));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (resource === "report-types") {
|
|
64
|
+
if (method === "GET" && !resourceId) return json(await backend.listReportTypes(req));
|
|
65
|
+
if (method === "POST" && !resourceId) {
|
|
66
|
+
return json(await backend.createReportType(String(req.body?.name || ""), req));
|
|
67
|
+
}
|
|
68
|
+
if (method === "DELETE" && resourceId) {
|
|
69
|
+
await backend.deleteReportType(getId(req.slug, 1), req);
|
|
70
|
+
return json({ success: true });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (resource === "task-lists") {
|
|
74
|
+
if (method === "GET" && !resourceId) return json(await backend.listTaskLists(req));
|
|
75
|
+
if (method === "POST" && !resourceId) {
|
|
76
|
+
return json(await backend.createTaskList(String(req.body?.name || ""), req));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (resource === "messages" && resourceId && method === "PATCH") {
|
|
80
|
+
return json(await backend.updateMessage(getId(req.slug, 1), String(req.body?.body || ""), req));
|
|
81
|
+
}
|
|
82
|
+
if (resource === "messages" && resourceId && method === "DELETE") {
|
|
83
|
+
await backend.deleteMessage(getId(req.slug, 1), req);
|
|
84
|
+
return json({ success: true });
|
|
85
|
+
}
|
|
86
|
+
if (resource === "messages" && resourceId === "read" && method === "POST") {
|
|
87
|
+
await backend.markMessagesRead(Array.isArray(req.body?.messageIds) ? req.body.messageIds : [], req);
|
|
88
|
+
return json({ success: true });
|
|
89
|
+
}
|
|
90
|
+
if (resource === "unread-counts" && method === "GET") {
|
|
91
|
+
return json(await backend.getUnreadCounts(req));
|
|
92
|
+
}
|
|
93
|
+
if (resource === "collaborators" && method === "GET") {
|
|
94
|
+
const ids = req.query.get("ids");
|
|
95
|
+
return json(await backend.listCollaborators(ids ? ids.split(",").filter(Boolean) : null, req));
|
|
96
|
+
}
|
|
97
|
+
if (resource === "ai" && resourceId === "refine-description" && method === "POST") {
|
|
98
|
+
if (!backend.refineDescription) {
|
|
99
|
+
return json({ error: "AI refinement is not configured." }, 404);
|
|
100
|
+
}
|
|
101
|
+
return json(await backend.refineDescription(req.body, req));
|
|
102
|
+
}
|
|
103
|
+
return json({ error: "Not found" }, 404);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// src/server/next.ts
|
|
107
|
+
async function readBody(request) {
|
|
108
|
+
if (request.method === "GET" || request.method === "HEAD") return null;
|
|
109
|
+
const text = await request.text();
|
|
110
|
+
if (!text) return null;
|
|
111
|
+
try {
|
|
112
|
+
return JSON.parse(text);
|
|
113
|
+
} catch {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function createNextDevNotesProxy(backend) {
|
|
118
|
+
return async function handler(request, context = {}) {
|
|
119
|
+
const url = new URL(request.url);
|
|
120
|
+
const proxyRequest = {
|
|
121
|
+
method: request.method,
|
|
122
|
+
slug: context.params?.slug || [],
|
|
123
|
+
request,
|
|
124
|
+
authToken: request.headers.get("authorization"),
|
|
125
|
+
query: url.searchParams,
|
|
126
|
+
body: await readBody(request)
|
|
127
|
+
};
|
|
128
|
+
const result = await routeDevNotesProxy(backend, proxyRequest);
|
|
129
|
+
return new Response(JSON.stringify(result.body ?? null), {
|
|
130
|
+
status: result.status ?? 200,
|
|
131
|
+
headers: { "Content-Type": "application/json" }
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
136
|
+
0 && (module.exports = {
|
|
137
|
+
createNextDevNotesProxy
|
|
138
|
+
});
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// src/server/router.ts
|
|
2
|
+
var json = (body, status = 200) => ({ status, body });
|
|
3
|
+
var getId = (slug, index) => decodeURIComponent(slug[index] || "");
|
|
4
|
+
async function routeDevNotesProxy(backend, req) {
|
|
5
|
+
const [resource, resourceId, nested] = req.slug;
|
|
6
|
+
const method = req.method.toUpperCase();
|
|
7
|
+
if (resource === "capabilities" && method === "GET") {
|
|
8
|
+
return json(await backend.getCapabilities(req));
|
|
9
|
+
}
|
|
10
|
+
if (resource === "app-link") {
|
|
11
|
+
if (method === "GET") return json(await backend.getAppLinkStatus(req));
|
|
12
|
+
if (method === "POST") return json(await backend.linkApp(req.body, req));
|
|
13
|
+
if (method === "DELETE") {
|
|
14
|
+
await backend.unlinkApp(req);
|
|
15
|
+
return json({ success: true });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (resource === "reports" && method === "GET" && !resourceId) {
|
|
19
|
+
return json(await backend.listReports(req));
|
|
20
|
+
}
|
|
21
|
+
if (resource === "reports" && method === "POST" && !resourceId) {
|
|
22
|
+
return json(await backend.createReport(req.body, req));
|
|
23
|
+
}
|
|
24
|
+
if (resource === "reports" && method === "PATCH" && resourceId && !nested) {
|
|
25
|
+
return json(await backend.updateReport(getId(req.slug, 1), req.body, req));
|
|
26
|
+
}
|
|
27
|
+
if (resource === "reports" && method === "DELETE" && resourceId && !nested) {
|
|
28
|
+
await backend.deleteReport(getId(req.slug, 1), req);
|
|
29
|
+
return json({ success: true });
|
|
30
|
+
}
|
|
31
|
+
if (resource === "reports" && resourceId && nested === "messages") {
|
|
32
|
+
if (method === "GET") return json(await backend.listMessages(getId(req.slug, 1), req));
|
|
33
|
+
if (method === "POST") {
|
|
34
|
+
return json(await backend.createMessage(getId(req.slug, 1), String(req.body?.body || ""), req));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (resource === "report-types") {
|
|
38
|
+
if (method === "GET" && !resourceId) return json(await backend.listReportTypes(req));
|
|
39
|
+
if (method === "POST" && !resourceId) {
|
|
40
|
+
return json(await backend.createReportType(String(req.body?.name || ""), req));
|
|
41
|
+
}
|
|
42
|
+
if (method === "DELETE" && resourceId) {
|
|
43
|
+
await backend.deleteReportType(getId(req.slug, 1), req);
|
|
44
|
+
return json({ success: true });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (resource === "task-lists") {
|
|
48
|
+
if (method === "GET" && !resourceId) return json(await backend.listTaskLists(req));
|
|
49
|
+
if (method === "POST" && !resourceId) {
|
|
50
|
+
return json(await backend.createTaskList(String(req.body?.name || ""), req));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (resource === "messages" && resourceId && method === "PATCH") {
|
|
54
|
+
return json(await backend.updateMessage(getId(req.slug, 1), String(req.body?.body || ""), req));
|
|
55
|
+
}
|
|
56
|
+
if (resource === "messages" && resourceId && method === "DELETE") {
|
|
57
|
+
await backend.deleteMessage(getId(req.slug, 1), req);
|
|
58
|
+
return json({ success: true });
|
|
59
|
+
}
|
|
60
|
+
if (resource === "messages" && resourceId === "read" && method === "POST") {
|
|
61
|
+
await backend.markMessagesRead(Array.isArray(req.body?.messageIds) ? req.body.messageIds : [], req);
|
|
62
|
+
return json({ success: true });
|
|
63
|
+
}
|
|
64
|
+
if (resource === "unread-counts" && method === "GET") {
|
|
65
|
+
return json(await backend.getUnreadCounts(req));
|
|
66
|
+
}
|
|
67
|
+
if (resource === "collaborators" && method === "GET") {
|
|
68
|
+
const ids = req.query.get("ids");
|
|
69
|
+
return json(await backend.listCollaborators(ids ? ids.split(",").filter(Boolean) : null, req));
|
|
70
|
+
}
|
|
71
|
+
if (resource === "ai" && resourceId === "refine-description" && method === "POST") {
|
|
72
|
+
if (!backend.refineDescription) {
|
|
73
|
+
return json({ error: "AI refinement is not configured." }, 404);
|
|
74
|
+
}
|
|
75
|
+
return json(await backend.refineDescription(req.body, req));
|
|
76
|
+
}
|
|
77
|
+
return json({ error: "Not found" }, 404);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// src/server/next.ts
|
|
81
|
+
async function readBody(request) {
|
|
82
|
+
if (request.method === "GET" || request.method === "HEAD") return null;
|
|
83
|
+
const text = await request.text();
|
|
84
|
+
if (!text) return null;
|
|
85
|
+
try {
|
|
86
|
+
return JSON.parse(text);
|
|
87
|
+
} catch {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function createNextDevNotesProxy(backend) {
|
|
92
|
+
return async function handler(request, context = {}) {
|
|
93
|
+
const url = new URL(request.url);
|
|
94
|
+
const proxyRequest = {
|
|
95
|
+
method: request.method,
|
|
96
|
+
slug: context.params?.slug || [],
|
|
97
|
+
request,
|
|
98
|
+
authToken: request.headers.get("authorization"),
|
|
99
|
+
query: url.searchParams,
|
|
100
|
+
body: await readBody(request)
|
|
101
|
+
};
|
|
102
|
+
const result = await routeDevNotesProxy(backend, proxyRequest);
|
|
103
|
+
return new Response(JSON.stringify(result.body ?? null), {
|
|
104
|
+
status: result.status ?? 200,
|
|
105
|
+
headers: { "Content-Type": "application/json" }
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
createNextDevNotesProxy
|
|
111
|
+
};
|