@nodetool-ai/websocket 0.7.0-rc.11
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/agent/agent-runtime.d.ts +47 -0
- package/dist/agent/agent-runtime.d.ts.map +1 -0
- package/dist/agent/agent-runtime.js +577 -0
- package/dist/agent/agent-runtime.js.map +1 -0
- package/dist/agent/codex-agent.d.ts +41 -0
- package/dist/agent/codex-agent.d.ts.map +1 -0
- package/dist/agent/codex-agent.js +334 -0
- package/dist/agent/codex-agent.js.map +1 -0
- package/dist/agent/index.d.ts +6 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +4 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/llm-agent.d.ts +51 -0
- package/dist/agent/llm-agent.d.ts.map +1 -0
- package/dist/agent/llm-agent.js +526 -0
- package/dist/agent/llm-agent.js.map +1 -0
- package/dist/agent/mcp-tool-server.d.ts +33 -0
- package/dist/agent/mcp-tool-server.d.ts.map +1 -0
- package/dist/agent/mcp-tool-server.js +292 -0
- package/dist/agent/mcp-tool-server.js.map +1 -0
- package/dist/agent/opencode-agent.d.ts +32 -0
- package/dist/agent/opencode-agent.d.ts.map +1 -0
- package/dist/agent/opencode-agent.js +332 -0
- package/dist/agent/opencode-agent.js.map +1 -0
- package/dist/agent/pi-agent.d.ts +42 -0
- package/dist/agent/pi-agent.d.ts.map +1 -0
- package/dist/agent/pi-agent.js +429 -0
- package/dist/agent/pi-agent.js.map +1 -0
- package/dist/agent/sdk-provider.d.ts +46 -0
- package/dist/agent/sdk-provider.d.ts.map +1 -0
- package/dist/agent/sdk-provider.js +50 -0
- package/dist/agent/sdk-provider.js.map +1 -0
- package/dist/agent/socket-route.d.ts +11 -0
- package/dist/agent/socket-route.d.ts.map +1 -0
- package/dist/agent/socket-route.js +262 -0
- package/dist/agent/socket-route.js.map +1 -0
- package/dist/agent/transport.d.ts +39 -0
- package/dist/agent/transport.d.ts.map +1 -0
- package/dist/agent/transport.js +17 -0
- package/dist/agent/transport.js.map +1 -0
- package/dist/agent/types.d.ts +11 -0
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent/types.js +10 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/collection-api.d.ts +14 -0
- package/dist/collection-api.d.ts.map +1 -0
- package/dist/collection-api.js +75 -0
- package/dist/collection-api.js.map +1 -0
- package/dist/error-codes.d.ts +3 -0
- package/dist/error-codes.d.ts.map +1 -0
- package/dist/error-codes.js +2 -0
- package/dist/error-codes.js.map +1 -0
- package/dist/file-api.d.ts +12 -0
- package/dist/file-api.d.ts.map +1 -0
- package/dist/file-api.js +76 -0
- package/dist/file-api.js.map +1 -0
- package/dist/http-api.d.ts +94 -0
- package/dist/http-api.d.ts.map +1 -0
- package/dist/http-api.js +1472 -0
- package/dist/http-api.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/asset-paths.d.ts +10 -0
- package/dist/lib/asset-paths.d.ts.map +1 -0
- package/dist/lib/asset-paths.js +45 -0
- package/dist/lib/asset-paths.js.map +1 -0
- package/dist/lib/bridge.d.ts +8 -0
- package/dist/lib/bridge.d.ts.map +1 -0
- package/dist/lib/bridge.js +70 -0
- package/dist/lib/bridge.js.map +1 -0
- package/dist/mcp-server.d.ts +32 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +842 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/models-api.d.ts +12 -0
- package/dist/models-api.d.ts.map +1 -0
- package/dist/models-api.js +730 -0
- package/dist/models-api.js.map +1 -0
- package/dist/oauth-api.d.ts +28 -0
- package/dist/oauth-api.d.ts.map +1 -0
- package/dist/oauth-api.js +681 -0
- package/dist/oauth-api.js.map +1 -0
- package/dist/openai-api.d.ts +63 -0
- package/dist/openai-api.d.ts.map +1 -0
- package/dist/openai-api.js +359 -0
- package/dist/openai-api.js.map +1 -0
- package/dist/plugins/websocket.d.ts +14 -0
- package/dist/plugins/websocket.d.ts.map +1 -0
- package/dist/plugins/websocket.js +431 -0
- package/dist/plugins/websocket.js.map +1 -0
- package/dist/resolve-media-urls.d.ts +19 -0
- package/dist/resolve-media-urls.d.ts.map +1 -0
- package/dist/resolve-media-urls.js +109 -0
- package/dist/resolve-media-urls.js.map +1 -0
- package/dist/routes/assets.d.ts +22 -0
- package/dist/routes/assets.d.ts.map +1 -0
- package/dist/routes/assets.js +168 -0
- package/dist/routes/assets.js.map +1 -0
- package/dist/routes/collections.d.ts +16 -0
- package/dist/routes/collections.d.ts.map +1 -0
- package/dist/routes/collections.js +32 -0
- package/dist/routes/collections.js.map +1 -0
- package/dist/routes/files.d.ts +12 -0
- package/dist/routes/files.d.ts.map +1 -0
- package/dist/routes/files.js +11 -0
- package/dist/routes/files.js.map +1 -0
- package/dist/routes/health.d.ts +4 -0
- package/dist/routes/health.d.ts.map +1 -0
- package/dist/routes/health.js +41 -0
- package/dist/routes/health.js.map +1 -0
- package/dist/routes/jobs.d.ts +16 -0
- package/dist/routes/jobs.d.ts.map +1 -0
- package/dist/routes/jobs.js +25 -0
- package/dist/routes/jobs.js.map +1 -0
- package/dist/routes/nodes.d.ts +8 -0
- package/dist/routes/nodes.d.ts.map +1 -0
- package/dist/routes/nodes.js +124 -0
- package/dist/routes/nodes.js.map +1 -0
- package/dist/routes/oauth.d.ts +8 -0
- package/dist/routes/oauth.d.ts.map +1 -0
- package/dist/routes/oauth.js +19 -0
- package/dist/routes/oauth.js.map +1 -0
- package/dist/routes/openai.d.ts +8 -0
- package/dist/routes/openai.d.ts.map +1 -0
- package/dist/routes/openai.js +20 -0
- package/dist/routes/openai.js.map +1 -0
- package/dist/routes/storage.d.ts +12 -0
- package/dist/routes/storage.d.ts.map +1 -0
- package/dist/routes/storage.js +13 -0
- package/dist/routes/storage.js.map +1 -0
- package/dist/routes/workflows.d.ts +18 -0
- package/dist/routes/workflows.d.ts.map +1 -0
- package/dist/routes/workflows.js +25 -0
- package/dist/routes/workflows.js.map +1 -0
- package/dist/routes/workspace.d.ts +15 -0
- package/dist/routes/workspace.d.ts.map +1 -0
- package/dist/routes/workspace.js +24 -0
- package/dist/routes/workspace.js.map +1 -0
- package/dist/screenshot-server.d.ts +21 -0
- package/dist/screenshot-server.d.ts.map +1 -0
- package/dist/screenshot-server.js +222 -0
- package/dist/screenshot-server.js.map +1 -0
- package/dist/server.d.ts +10 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +783 -0
- package/dist/server.js.map +1 -0
- package/dist/settings-registry.d.ts +29 -0
- package/dist/settings-registry.d.ts.map +1 -0
- package/dist/settings-registry.js +117 -0
- package/dist/settings-registry.js.map +1 -0
- package/dist/storage-api.d.ts +5 -0
- package/dist/storage-api.d.ts.map +1 -0
- package/dist/storage-api.js +221 -0
- package/dist/storage-api.js.map +1 -0
- package/dist/test-ui-server.d.ts +19 -0
- package/dist/test-ui-server.d.ts.map +1 -0
- package/dist/test-ui-server.js +1256 -0
- package/dist/test-ui-server.js.map +1 -0
- package/dist/trpc/context.d.ts +21 -0
- package/dist/trpc/context.d.ts.map +1 -0
- package/dist/trpc/context.js +10 -0
- package/dist/trpc/context.js.map +1 -0
- package/dist/trpc/error-formatter.d.ts +18 -0
- package/dist/trpc/error-formatter.d.ts.map +1 -0
- package/dist/trpc/error-formatter.js +41 -0
- package/dist/trpc/error-formatter.js.map +1 -0
- package/dist/trpc/index.d.ts +18 -0
- package/dist/trpc/index.d.ts.map +1 -0
- package/dist/trpc/index.js +13 -0
- package/dist/trpc/index.js.map +1 -0
- package/dist/trpc/middleware.d.ts +8 -0
- package/dist/trpc/middleware.d.ts.map +1 -0
- package/dist/trpc/middleware.js +12 -0
- package/dist/trpc/middleware.js.map +1 -0
- package/dist/trpc/router.d.ts +2543 -0
- package/dist/trpc/router.d.ts.map +1 -0
- package/dist/trpc/router.js +43 -0
- package/dist/trpc/router.js.map +1 -0
- package/dist/trpc/routers/assets.d.ts +229 -0
- package/dist/trpc/routers/assets.d.ts.map +1 -0
- package/dist/trpc/routers/assets.js +263 -0
- package/dist/trpc/routers/assets.js.map +1 -0
- package/dist/trpc/routers/collections.d.ts +88 -0
- package/dist/trpc/routers/collections.d.ts.map +1 -0
- package/dist/trpc/routers/collections.js +166 -0
- package/dist/trpc/routers/collections.js.map +1 -0
- package/dist/trpc/routers/costs.d.ts +129 -0
- package/dist/trpc/routers/costs.d.ts.map +1 -0
- package/dist/trpc/routers/costs.js +95 -0
- package/dist/trpc/routers/costs.js.map +1 -0
- package/dist/trpc/routers/files.d.ts +34 -0
- package/dist/trpc/routers/files.d.ts.map +1 -0
- package/dist/trpc/routers/files.js +92 -0
- package/dist/trpc/routers/files.js.map +1 -0
- package/dist/trpc/routers/jobs.d.ts +92 -0
- package/dist/trpc/routers/jobs.d.ts.map +1 -0
- package/dist/trpc/routers/jobs.js +100 -0
- package/dist/trpc/routers/jobs.js.map +1 -0
- package/dist/trpc/routers/mcp-config.d.ts +69 -0
- package/dist/trpc/routers/mcp-config.d.ts.map +1 -0
- package/dist/trpc/routers/mcp-config.js +290 -0
- package/dist/trpc/routers/mcp-config.js.map +1 -0
- package/dist/trpc/routers/messages.d.ts +121 -0
- package/dist/trpc/routers/messages.d.ts.map +1 -0
- package/dist/trpc/routers/messages.js +113 -0
- package/dist/trpc/routers/messages.js.map +1 -0
- package/dist/trpc/routers/models.d.ts +748 -0
- package/dist/trpc/routers/models.d.ts.map +1 -0
- package/dist/trpc/routers/models.js +1107 -0
- package/dist/trpc/routers/models.js.map +1 -0
- package/dist/trpc/routers/nodes.d.ts +48 -0
- package/dist/trpc/routers/nodes.d.ts.map +1 -0
- package/dist/trpc/routers/nodes.js +57 -0
- package/dist/trpc/routers/nodes.js.map +1 -0
- package/dist/trpc/routers/sandboxes.d.ts +64 -0
- package/dist/trpc/routers/sandboxes.d.ts.map +1 -0
- package/dist/trpc/routers/sandboxes.js +327 -0
- package/dist/trpc/routers/sandboxes.js.map +1 -0
- package/dist/trpc/routers/settings.d.ts +113 -0
- package/dist/trpc/routers/settings.d.ts.map +1 -0
- package/dist/trpc/routers/settings.js +193 -0
- package/dist/trpc/routers/settings.js.map +1 -0
- package/dist/trpc/routers/skills.d.ts +41 -0
- package/dist/trpc/routers/skills.d.ts.map +1 -0
- package/dist/trpc/routers/skills.js +194 -0
- package/dist/trpc/routers/skills.js.map +1 -0
- package/dist/trpc/routers/storage.d.ts +44 -0
- package/dist/trpc/routers/storage.d.ts.map +1 -0
- package/dist/trpc/routers/storage.js +153 -0
- package/dist/trpc/routers/storage.js.map +1 -0
- package/dist/trpc/routers/threads.d.ts +95 -0
- package/dist/trpc/routers/threads.d.ts.map +1 -0
- package/dist/trpc/routers/threads.js +150 -0
- package/dist/trpc/routers/threads.js.map +1 -0
- package/dist/trpc/routers/users.d.ts +79 -0
- package/dist/trpc/routers/users.d.ts.map +1 -0
- package/dist/trpc/routers/users.js +125 -0
- package/dist/trpc/routers/users.js.map +1 -0
- package/dist/trpc/routers/workflows.d.ts +681 -0
- package/dist/trpc/routers/workflows.d.ts.map +1 -0
- package/dist/trpc/routers/workflows.js +725 -0
- package/dist/trpc/routers/workflows.js.map +1 -0
- package/dist/trpc/routers/workspace.d.ts +127 -0
- package/dist/trpc/routers/workspace.d.ts.map +1 -0
- package/dist/trpc/routers/workspace.js +203 -0
- package/dist/trpc/routers/workspace.js.map +1 -0
- package/dist/unified-websocket-runner.d.ts +280 -0
- package/dist/unified-websocket-runner.d.ts.map +1 -0
- package/dist/unified-websocket-runner.js +3840 -0
- package/dist/unified-websocket-runner.js.map +1 -0
- package/dist/workspace-api.d.ts +14 -0
- package/dist/workspace-api.d.ts.map +1 -0
- package/dist/workspace-api.js +104 -0
- package/dist/workspace-api.js.map +1 -0
- package/dist/ws-adapter.d.ts +25 -0
- package/dist/ws-adapter.d.ts.map +1 -0
- package/dist/ws-adapter.js +63 -0
- package/dist/ws-adapter.js.map +1 -0
- package/package.json +92 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tRPC router for the storage domain — JSON ops only.
|
|
3
|
+
* Binary PUT/GET stay as REST (/api/storage/*).
|
|
4
|
+
*/
|
|
5
|
+
import { stat, unlink, readdir } from "node:fs/promises";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { extname } from "node:path";
|
|
8
|
+
import { getDefaultAssetsPath } from "@nodetool-ai/config";
|
|
9
|
+
import { router } from "../index.js";
|
|
10
|
+
import { protectedProcedure } from "../middleware.js";
|
|
11
|
+
import { throwApiError } from "../error-formatter.js";
|
|
12
|
+
import { listStorageInput, listStorageOutput, storageMetadataInput, storageMetadataOutput, storageDeleteInput, storageDeleteOutput } from "@nodetool-ai/protocol/api-schemas/storage.js";
|
|
13
|
+
import { ApiErrorCode } from "@nodetool-ai/protocol/api-schemas/api-error-code.js";
|
|
14
|
+
// ── MIME types (mirrors storage-api.ts) ──────────────────────────────────────
|
|
15
|
+
const MIME_TYPES = {
|
|
16
|
+
".jpg": "image/jpeg",
|
|
17
|
+
".jpeg": "image/jpeg",
|
|
18
|
+
".png": "image/png",
|
|
19
|
+
".gif": "image/gif",
|
|
20
|
+
".webp": "image/webp",
|
|
21
|
+
".mp4": "video/mp4",
|
|
22
|
+
".mp3": "audio/mpeg",
|
|
23
|
+
".wav": "audio/wav",
|
|
24
|
+
".json": "application/json",
|
|
25
|
+
".txt": "text/plain",
|
|
26
|
+
".pdf": "application/pdf"
|
|
27
|
+
};
|
|
28
|
+
function getMimeType(filePath) {
|
|
29
|
+
return (MIME_TYPES[extname(filePath).toLowerCase()] ?? "application/octet-stream");
|
|
30
|
+
}
|
|
31
|
+
// ── Key validation (mirrors storage-api.ts) ──────────────────────────────────
|
|
32
|
+
function validateStorageKey(key) {
|
|
33
|
+
if (!key)
|
|
34
|
+
return "Key is required";
|
|
35
|
+
if (key.startsWith("/"))
|
|
36
|
+
return "Key must not be absolute path";
|
|
37
|
+
const parts = key
|
|
38
|
+
.replace(/\\/g, "/")
|
|
39
|
+
.split("/")
|
|
40
|
+
.filter((p) => p && p !== ".");
|
|
41
|
+
if (parts.some((p) => p === ".."))
|
|
42
|
+
return "Key must not contain path traversal";
|
|
43
|
+
return null; // valid
|
|
44
|
+
}
|
|
45
|
+
function resolveStoragePath(rootDir, key) {
|
|
46
|
+
const normalized = key
|
|
47
|
+
.replace(/\\/g, "/")
|
|
48
|
+
.split("/")
|
|
49
|
+
.filter((p) => p && p !== ".")
|
|
50
|
+
.join("/");
|
|
51
|
+
return path.join(rootDir, normalized);
|
|
52
|
+
}
|
|
53
|
+
function keyFromPath(rootDir, filePath) {
|
|
54
|
+
return path
|
|
55
|
+
.relative(rootDir, filePath)
|
|
56
|
+
.replace(/\\/g, "/");
|
|
57
|
+
}
|
|
58
|
+
// ── Router ────────────────────────────────────────────────────────────────────
|
|
59
|
+
export const storageRouter = router({
|
|
60
|
+
list: protectedProcedure
|
|
61
|
+
.input(listStorageInput)
|
|
62
|
+
.output(listStorageOutput)
|
|
63
|
+
.query(async ({ input }) => {
|
|
64
|
+
const rootDir = getDefaultAssetsPath();
|
|
65
|
+
const prefix = input.prefix ?? "";
|
|
66
|
+
// Validate prefix if provided
|
|
67
|
+
if (prefix) {
|
|
68
|
+
const err = validateStorageKey(prefix);
|
|
69
|
+
if (err) {
|
|
70
|
+
throwApiError(ApiErrorCode.INVALID_INPUT, err);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const baseDir = prefix
|
|
74
|
+
? resolveStoragePath(rootDir, prefix)
|
|
75
|
+
: rootDir;
|
|
76
|
+
// Recursively collect all file entries
|
|
77
|
+
const entries = [];
|
|
78
|
+
async function walk(dir) {
|
|
79
|
+
let dirents;
|
|
80
|
+
try {
|
|
81
|
+
dirents = await readdir(dir, { withFileTypes: true });
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return; // directory may not exist yet
|
|
85
|
+
}
|
|
86
|
+
for (const dirent of dirents) {
|
|
87
|
+
const fullPath = path.join(dir, dirent.name);
|
|
88
|
+
if (dirent.isDirectory()) {
|
|
89
|
+
await walk(fullPath);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
try {
|
|
93
|
+
const fileStat = await stat(fullPath);
|
|
94
|
+
entries.push({
|
|
95
|
+
key: keyFromPath(rootDir, fullPath),
|
|
96
|
+
size: fileStat.size,
|
|
97
|
+
content_type: getMimeType(fullPath),
|
|
98
|
+
last_modified: fileStat.mtime.toISOString()
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
// skip files we can't stat
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
await walk(baseDir);
|
|
108
|
+
return { entries, count: entries.length };
|
|
109
|
+
}),
|
|
110
|
+
metadata: protectedProcedure
|
|
111
|
+
.input(storageMetadataInput)
|
|
112
|
+
.output(storageMetadataOutput)
|
|
113
|
+
.query(async ({ input }) => {
|
|
114
|
+
const validationError = validateStorageKey(input.key);
|
|
115
|
+
if (validationError) {
|
|
116
|
+
throwApiError(ApiErrorCode.INVALID_INPUT, validationError);
|
|
117
|
+
}
|
|
118
|
+
const rootDir = getDefaultAssetsPath();
|
|
119
|
+
const filePath = resolveStoragePath(rootDir, input.key);
|
|
120
|
+
try {
|
|
121
|
+
const fileStat = await stat(filePath);
|
|
122
|
+
return {
|
|
123
|
+
key: input.key,
|
|
124
|
+
size: fileStat.size,
|
|
125
|
+
content_type: getMimeType(filePath),
|
|
126
|
+
last_modified: fileStat.mtime.toISOString()
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
throwApiError(ApiErrorCode.NOT_FOUND, "Object not found");
|
|
131
|
+
}
|
|
132
|
+
}),
|
|
133
|
+
delete: protectedProcedure
|
|
134
|
+
.input(storageDeleteInput)
|
|
135
|
+
.output(storageDeleteOutput)
|
|
136
|
+
.mutation(async ({ input }) => {
|
|
137
|
+
const validationError = validateStorageKey(input.key);
|
|
138
|
+
if (validationError) {
|
|
139
|
+
throwApiError(ApiErrorCode.INVALID_INPUT, validationError);
|
|
140
|
+
}
|
|
141
|
+
const rootDir = getDefaultAssetsPath();
|
|
142
|
+
const filePath = resolveStoragePath(rootDir, input.key);
|
|
143
|
+
try {
|
|
144
|
+
await stat(filePath);
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
throwApiError(ApiErrorCode.NOT_FOUND, "Object not found");
|
|
148
|
+
}
|
|
149
|
+
await unlink(filePath);
|
|
150
|
+
return { ok: true };
|
|
151
|
+
})
|
|
152
|
+
});
|
|
153
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/trpc/routers/storage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,qDAAqD,CAAC;AAEnF,gFAAgF;AAEhF,MAAM,UAAU,GAA2B;IACzC,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,WAAW;IACnB,MAAM,EAAE,WAAW;IACnB,OAAO,EAAE,YAAY;IACrB,MA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AAQ,CAAC,IAAI;gBACnB,YAAY,EAAE,WAAW,CAAC,QAAQ,CAAC;gBACnC,aAAa,EAAE,QAAQ,CAAC,KAAK,CAAC,WAAW,EAAE;aAC5C,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,aAAa,CAAC,YAAY,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC,CAAC;IAEJ,MAAM,EAAE,kBAAkB;SACvB,KAAK,CAAC,kBAAkB,CAAC;SACzB,MAAM,CAAC,mBAAmB,CAAC;SAC3B,QAAQ,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;QAC5B,MAAM,eAAe,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACtD,IAAI,eAAe,EAAE,CAAC;YACpB,aAAa,CAAC,YAAY,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;QAC7D,CAAC;QAED,MAAM,OAAO,GAAG,oBAAoB,EAAE,CAAC;QACvC,MAAM,QAAQ,GAAG,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QAExD,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvB,CAAC;QAAC,MAAM,CAAC;YACP,aAAa,CAAC,YAAY,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;QAC5D,CAAC;QAED,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;QACvB,OAAO,EAAE,EAAE,EAAE,IAAa,EAAE,CAAC;IAC/B,CAAC,CAAC;CACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Threads router — migrated from REST `/api/threads*`.
|
|
3
|
+
*
|
|
4
|
+
* Handlers previously lived inline in http-api.ts (`handleThreadsRoot`,
|
|
5
|
+
* `handleThreadById`, `handleThreadSummarize`). The delete path cascades
|
|
6
|
+
* to Message.delete() in batches of 100, mirroring the legacy behavior.
|
|
7
|
+
*/
|
|
8
|
+
export declare const threadsRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
9
|
+
ctx: import("../context.js").Context;
|
|
10
|
+
meta: object;
|
|
11
|
+
errorShape: import("../error-formatter.js").ApiErrorShape;
|
|
12
|
+
transformer: true;
|
|
13
|
+
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
14
|
+
list: import("@trpc/server").TRPCQueryProcedure<{
|
|
15
|
+
input: {
|
|
16
|
+
limit?: number | undefined;
|
|
17
|
+
cursor?: string | undefined;
|
|
18
|
+
reverse?: boolean | undefined;
|
|
19
|
+
};
|
|
20
|
+
output: {
|
|
21
|
+
threads: {
|
|
22
|
+
id: string;
|
|
23
|
+
user_id: string;
|
|
24
|
+
title: string;
|
|
25
|
+
created_at: string;
|
|
26
|
+
updated_at: string;
|
|
27
|
+
etag: string;
|
|
28
|
+
}[];
|
|
29
|
+
next: string | null;
|
|
30
|
+
};
|
|
31
|
+
meta: object;
|
|
32
|
+
}>;
|
|
33
|
+
get: import("@trpc/server").TRPCQueryProcedure<{
|
|
34
|
+
input: {
|
|
35
|
+
id: string;
|
|
36
|
+
};
|
|
37
|
+
output: {
|
|
38
|
+
id: string;
|
|
39
|
+
user_id: string;
|
|
40
|
+
title: string;
|
|
41
|
+
created_at: string;
|
|
42
|
+
updated_at: string;
|
|
43
|
+
etag: string;
|
|
44
|
+
};
|
|
45
|
+
meta: object;
|
|
46
|
+
}>;
|
|
47
|
+
create: import("@trpc/server").TRPCMutationProcedure<{
|
|
48
|
+
input: {
|
|
49
|
+
title?: string | undefined;
|
|
50
|
+
};
|
|
51
|
+
output: {
|
|
52
|
+
id: string;
|
|
53
|
+
user_id: string;
|
|
54
|
+
title: string;
|
|
55
|
+
created_at: string;
|
|
56
|
+
updated_at: string;
|
|
57
|
+
etag: string;
|
|
58
|
+
};
|
|
59
|
+
meta: object;
|
|
60
|
+
}>;
|
|
61
|
+
update: import("@trpc/server").TRPCMutationProcedure<{
|
|
62
|
+
input: {
|
|
63
|
+
id: string;
|
|
64
|
+
title: string;
|
|
65
|
+
};
|
|
66
|
+
output: {
|
|
67
|
+
id: string;
|
|
68
|
+
user_id: string;
|
|
69
|
+
title: string;
|
|
70
|
+
created_at: string;
|
|
71
|
+
updated_at: string;
|
|
72
|
+
etag: string;
|
|
73
|
+
};
|
|
74
|
+
meta: object;
|
|
75
|
+
}>;
|
|
76
|
+
delete: import("@trpc/server").TRPCMutationProcedure<{
|
|
77
|
+
input: {
|
|
78
|
+
id: string;
|
|
79
|
+
};
|
|
80
|
+
output: {
|
|
81
|
+
ok: true;
|
|
82
|
+
};
|
|
83
|
+
meta: object;
|
|
84
|
+
}>;
|
|
85
|
+
summarize: import("@trpc/server").TRPCMutationProcedure<{
|
|
86
|
+
input: {
|
|
87
|
+
id: string;
|
|
88
|
+
};
|
|
89
|
+
output: {
|
|
90
|
+
title: string;
|
|
91
|
+
};
|
|
92
|
+
meta: object;
|
|
93
|
+
}>;
|
|
94
|
+
}>>;
|
|
95
|
+
//# sourceMappingURL=threads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"threads.d.ts","sourceRoot":"","sources":["../../../src/trpc/routers/threads.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA+EH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsFxB,CAAC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Threads router — migrated from REST `/api/threads*`.
|
|
3
|
+
*
|
|
4
|
+
* Handlers previously lived inline in http-api.ts (`handleThreadsRoot`,
|
|
5
|
+
* `handleThreadById`, `handleThreadSummarize`). The delete path cascades
|
|
6
|
+
* to Message.delete() in batches of 100, mirroring the legacy behavior.
|
|
7
|
+
*/
|
|
8
|
+
import { Thread, Message } from "@nodetool-ai/models";
|
|
9
|
+
import { ApiErrorCode } from "../../error-codes.js";
|
|
10
|
+
import { router } from "../index.js";
|
|
11
|
+
import { protectedProcedure } from "../middleware.js";
|
|
12
|
+
import { throwApiError } from "../error-formatter.js";
|
|
13
|
+
import { listInput, listOutput, getInput, threadResponse, createInput, updateInput, deleteInput, deleteOutput, summarizeInput, summarizeOutput } from "@nodetool-ai/protocol/api-schemas/threads.js";
|
|
14
|
+
/** Maximum length of a derived thread title before truncation. */
|
|
15
|
+
const THREAD_TITLE_MAX_LEN = 60;
|
|
16
|
+
/** Length of visible text when a title is truncated (max - "...".length). */
|
|
17
|
+
const THREAD_TITLE_TRUNC_LEN = THREAD_TITLE_MAX_LEN - 3;
|
|
18
|
+
function toThreadResponse(thread) {
|
|
19
|
+
return {
|
|
20
|
+
id: thread.id,
|
|
21
|
+
user_id: thread.user_id,
|
|
22
|
+
title: thread.title,
|
|
23
|
+
created_at: thread.created_at,
|
|
24
|
+
updated_at: thread.updated_at,
|
|
25
|
+
etag: thread.getEtag()
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Derive a short title from a thread's messages. Port of the legacy
|
|
30
|
+
* `deriveThreadTitle` — scans up to 10 messages, pulls the first non-empty
|
|
31
|
+
* user-visible text, truncates to THREAD_TITLE_MAX_LEN with "..." suffix,
|
|
32
|
+
* falls back to "New Thread".
|
|
33
|
+
*/
|
|
34
|
+
async function deriveThreadTitle(threadId) {
|
|
35
|
+
const [messages] = await Message.paginate(threadId, { limit: 10 });
|
|
36
|
+
for (const msg of messages) {
|
|
37
|
+
const content = msg.content;
|
|
38
|
+
if (typeof content === "string" && content.trim().length > 0) {
|
|
39
|
+
const text = content.trim().replace(/\s+/g, " ");
|
|
40
|
+
return text.length > THREAD_TITLE_MAX_LEN
|
|
41
|
+
? text.slice(0, THREAD_TITLE_TRUNC_LEN) + "..."
|
|
42
|
+
: text;
|
|
43
|
+
}
|
|
44
|
+
if (Array.isArray(content)) {
|
|
45
|
+
for (const part of content) {
|
|
46
|
+
if (part !== null &&
|
|
47
|
+
typeof part === "object" &&
|
|
48
|
+
"type" in part &&
|
|
49
|
+
part.type === "text" &&
|
|
50
|
+
"text" in part &&
|
|
51
|
+
typeof part.text === "string") {
|
|
52
|
+
const text = part.text
|
|
53
|
+
.trim()
|
|
54
|
+
.replace(/\s+/g, " ");
|
|
55
|
+
if (text.length > 0) {
|
|
56
|
+
return text.length > THREAD_TITLE_MAX_LEN
|
|
57
|
+
? text.slice(0, THREAD_TITLE_TRUNC_LEN) + "..."
|
|
58
|
+
: text;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return "New Thread";
|
|
65
|
+
}
|
|
66
|
+
export const threadsRouter = router({
|
|
67
|
+
list: protectedProcedure
|
|
68
|
+
.input(listInput)
|
|
69
|
+
.output(listOutput)
|
|
70
|
+
.query(async ({ ctx, input }) => {
|
|
71
|
+
const [threads, cursor] = await Thread.paginate(ctx.userId, {
|
|
72
|
+
limit: input.limit,
|
|
73
|
+
startKey: input.cursor,
|
|
74
|
+
reverse: input.reverse
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
threads: threads.map((t) => toThreadResponse(t)),
|
|
78
|
+
next: cursor || null
|
|
79
|
+
};
|
|
80
|
+
}),
|
|
81
|
+
get: protectedProcedure
|
|
82
|
+
.input(getInput)
|
|
83
|
+
.output(threadResponse)
|
|
84
|
+
.query(async ({ ctx, input }) => {
|
|
85
|
+
const thread = await Thread.find(ctx.userId, input.id);
|
|
86
|
+
if (!thread) {
|
|
87
|
+
throwApiError(ApiErrorCode.NOT_FOUND, "Thread not found");
|
|
88
|
+
}
|
|
89
|
+
return toThreadResponse(thread);
|
|
90
|
+
}),
|
|
91
|
+
create: protectedProcedure
|
|
92
|
+
.input(createInput)
|
|
93
|
+
.output(threadResponse)
|
|
94
|
+
.mutation(async ({ ctx, input }) => {
|
|
95
|
+
const title = input.title ?? "New Thread";
|
|
96
|
+
const thread = (await Thread.create({
|
|
97
|
+
user_id: ctx.userId,
|
|
98
|
+
title
|
|
99
|
+
}));
|
|
100
|
+
return toThreadResponse(thread);
|
|
101
|
+
}),
|
|
102
|
+
update: protectedProcedure
|
|
103
|
+
.input(updateInput)
|
|
104
|
+
.output(threadResponse)
|
|
105
|
+
.mutation(async ({ ctx, input }) => {
|
|
106
|
+
const thread = await Thread.find(ctx.userId, input.id);
|
|
107
|
+
if (!thread) {
|
|
108
|
+
throwApiError(ApiErrorCode.NOT_FOUND, "Thread not found");
|
|
109
|
+
}
|
|
110
|
+
thread.title = input.title;
|
|
111
|
+
await thread.save();
|
|
112
|
+
return toThreadResponse(thread);
|
|
113
|
+
}),
|
|
114
|
+
delete: protectedProcedure
|
|
115
|
+
.input(deleteInput)
|
|
116
|
+
.output(deleteOutput)
|
|
117
|
+
.mutation(async ({ ctx, input }) => {
|
|
118
|
+
const thread = await Thread.find(ctx.userId, input.id);
|
|
119
|
+
if (!thread) {
|
|
120
|
+
throwApiError(ApiErrorCode.NOT_FOUND, "Thread not found");
|
|
121
|
+
}
|
|
122
|
+
// Delete all messages in the thread, batched.
|
|
123
|
+
while (true) {
|
|
124
|
+
const [msgs] = await Message.paginate(input.id, { limit: 100 });
|
|
125
|
+
if (!msgs.length)
|
|
126
|
+
break;
|
|
127
|
+
for (const msg of msgs) {
|
|
128
|
+
await msg.delete();
|
|
129
|
+
}
|
|
130
|
+
if (msgs.length < 100)
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
await thread.delete();
|
|
134
|
+
return { ok: true };
|
|
135
|
+
}),
|
|
136
|
+
summarize: protectedProcedure
|
|
137
|
+
.input(summarizeInput)
|
|
138
|
+
.output(summarizeOutput)
|
|
139
|
+
.mutation(async ({ ctx, input }) => {
|
|
140
|
+
const thread = await Thread.find(ctx.userId, input.id);
|
|
141
|
+
if (!thread) {
|
|
142
|
+
throwApiError(ApiErrorCode.NOT_FOUND, "Thread not found");
|
|
143
|
+
}
|
|
144
|
+
const title = await deriveThreadTitle(input.id);
|
|
145
|
+
thread.title = title;
|
|
146
|
+
await thread.save();
|
|
147
|
+
return { title };
|
|
148
|
+
})
|
|
149
|
+
});
|
|
150
|
+
//# sourceMappingURL=threads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"threads.js","sourceRoot":"","sources":["../../../src/trpc/routers/threads.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EACL,SAAS,EACT,UAAU,EACV,QAAQ,EACR,cAAc,EACd,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,EACZ,cAAc,EACd,eAAe,EAEhB,MAAM,8CAA8C,CAAC;AAEtD,kEAAkE;AAClE,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,6EAA6E;AAC7E,MAAM,sBAAsB,GAAG,oBAAoB,GAAG,CAAC,CAAC;AAExD,SAAS,gBAAgB,CAAC,MAAmB;IAC3C,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE;KACvB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,iBAAiB,CAAC,QAAgB;IAC/C,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,O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admin (userId === "1" in dev,
|
|
5
|
+
* or listed in the comma-separated `ADMIN_USER_IDS` env var in production).
|
|
6
|
+
* The response shapes differ by operation:
|
|
7
|
+
* • list / get return `token_hash` (masked).
|
|
8
|
+
* • create / resetToken return plaintext `token` (shown once on creation).
|
|
9
|
+
*/
|
|
10
|
+
export declare const usersRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
11
|
+
ctx: import("../context.js").Context;
|
|
12
|
+
meta: object;
|
|
13
|
+
errorShape: import("../error-formatter.js").ApiErrorShape;
|
|
14
|
+
transformer: true;
|
|
15
|
+
}, import("@trpc/server").TRPCDecorateCreateRouterOptions<{
|
|
16
|
+
list: import("@trpc/server").TRPCQueryProcedure<{
|
|
17
|
+
input: void;
|
|
18
|
+
output: {
|
|
19
|
+
users: {
|
|
20
|
+
username: string;
|
|
21
|
+
user_id: string;
|
|
22
|
+
role: string;
|
|
23
|
+
token_hash: string;
|
|
24
|
+
created_at: string;
|
|
25
|
+
}[];
|
|
26
|
+
};
|
|
27
|
+
meta: object;
|
|
28
|
+
}>;
|
|
29
|
+
get: import("@trpc/server").TRPCQueryProcedure<{
|
|
30
|
+
input: {
|
|
31
|
+
username: string;
|
|
32
|
+
};
|
|
33
|
+
output: {
|
|
34
|
+
username: string;
|
|
35
|
+
user_id: string;
|
|
36
|
+
role: string;
|
|
37
|
+
token_hash: string;
|
|
38
|
+
created_at: string;
|
|
39
|
+
};
|
|
40
|
+
meta: object;
|
|
41
|
+
}>;
|
|
42
|
+
create: import("@trpc/server").TRPCMutationProcedure<{
|
|
43
|
+
input: {
|
|
44
|
+
username: string;
|
|
45
|
+
role?: string | undefined;
|
|
46
|
+
};
|
|
47
|
+
output: {
|
|
48
|
+
username: string;
|
|
49
|
+
user_id: string;
|
|
50
|
+
role: string;
|
|
51
|
+
token: string;
|
|
52
|
+
created_at: string;
|
|
53
|
+
};
|
|
54
|
+
meta: object;
|
|
55
|
+
}>;
|
|
56
|
+
remove: import("@trpc/server").TRPCMutationProcedure<{
|
|
57
|
+
input: {
|
|
58
|
+
username: string;
|
|
59
|
+
};
|
|
60
|
+
output: {
|
|
61
|
+
message: string;
|
|
62
|
+
};
|
|
63
|
+
meta: object;
|
|
64
|
+
}>;
|
|
65
|
+
resetToken: import("@trpc/server").TRPCMutationProcedure<{
|
|
66
|
+
input: {
|
|
67
|
+
username: string;
|
|
68
|
+
};
|
|
69
|
+
output: {
|
|
70
|
+
username: string;
|
|
71
|
+
user_id: string;
|
|
72
|
+
role: string;
|
|
73
|
+
token: string;
|
|
74
|
+
created_at: string;
|
|
75
|
+
};
|
|
76
|
+
meta: object;
|
|
77
|
+
}>;
|
|
78
|
+
}>>;
|
|
79
|
+
//# sourceMappingURL=users.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../../src/trpc/routers/users.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA4DH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EtB,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Users router — migrated from REST `/api/users*`.
|
|
3
|
+
*
|
|
4
|
+
* All procedures require the caller to be an admin (userId === "1" in dev,
|
|
5
|
+
* or listed in the comma-separated `ADMIN_USER_IDS` env var in production).
|
|
6
|
+
* The response shapes differ by operation:
|
|
7
|
+
* • list / get return `token_hash` (masked).
|
|
8
|
+
* • create / resetToken return plaintext `token` (shown once on creation).
|
|
9
|
+
*/
|
|
10
|
+
import { FileUserManager } from "@nodetool-ai/auth";
|
|
11
|
+
import { ApiErrorCode } from "../../error-codes.js";
|
|
12
|
+
import { router } from "../index.js";
|
|
13
|
+
import { protectedProcedure } from "../middleware.js";
|
|
14
|
+
import { throwApiError } from "../error-formatter.js";
|
|
15
|
+
import { listOutput, getInput, userListItem, createInput, userCreateResponse, removeInput, removeOutput, resetTokenInput } from "@nodetool-ai/protocol/api-schemas/users.js";
|
|
16
|
+
/**
|
|
17
|
+
* Check if a user ID has admin privileges. Mirrors `isAdmin` from the
|
|
18
|
+
* legacy users-api.ts: user "1" is always admin in dev, and
|
|
19
|
+
* `ADMIN_USER_IDS` (comma-separated) grants admin in production.
|
|
20
|
+
*/
|
|
21
|
+
function isAdmin(userId) {
|
|
22
|
+
if (userId === "1")
|
|
23
|
+
return true;
|
|
24
|
+
const adminIds = process.env.ADMIN_USER_IDS;
|
|
25
|
+
if (adminIds) {
|
|
26
|
+
return adminIds
|
|
27
|
+
.split(",")
|
|
28
|
+
.map((s) => s.trim())
|
|
29
|
+
.includes(userId);
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
/** Guard: throws FORBIDDEN if caller is not an admin. */
|
|
34
|
+
function requireAdmin(userId) {
|
|
35
|
+
if (!isAdmin(userId)) {
|
|
36
|
+
throwApiError(ApiErrorCode.FORBIDDEN, "Admin access required");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** Manager singleton — matches legacy behaviour (module-scoped instance). */
|
|
40
|
+
const manager = new FileUserManager();
|
|
41
|
+
/** Build a list-item response from a FileUserManager UserRecord. */
|
|
42
|
+
function toUserListItem(username, record) {
|
|
43
|
+
return {
|
|
44
|
+
username,
|
|
45
|
+
user_id: record.id,
|
|
46
|
+
role: record.role,
|
|
47
|
+
token_hash: record.tokenHash.slice(0, 16) + "...",
|
|
48
|
+
created_at: record.createdAt
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export const usersRouter = router({
|
|
52
|
+
list: protectedProcedure.output(listOutput).query(async ({ ctx }) => {
|
|
53
|
+
requireAdmin(ctx.userId);
|
|
54
|
+
const users = await manager.listUsers();
|
|
55
|
+
return {
|
|
56
|
+
users: Object.entries(users).map(([username, rec]) => toUserListItem(username, rec))
|
|
57
|
+
};
|
|
58
|
+
}),
|
|
59
|
+
get: protectedProcedure
|
|
60
|
+
.input(getInput)
|
|
61
|
+
.output(userListItem)
|
|
62
|
+
.query(async ({ ctx, input }) => {
|
|
63
|
+
requireAdmin(ctx.userId);
|
|
64
|
+
const user = await manager.getUser(input.username);
|
|
65
|
+
if (!user) {
|
|
66
|
+
throwApiError(ApiErrorCode.NOT_FOUND, `User '${input.username}' not found`);
|
|
67
|
+
}
|
|
68
|
+
return toUserListItem(input.username, user);
|
|
69
|
+
}),
|
|
70
|
+
create: protectedProcedure
|
|
71
|
+
.input(createInput)
|
|
72
|
+
.output(userCreateResponse)
|
|
73
|
+
.mutation(async ({ ctx, input }) => {
|
|
74
|
+
requireAdmin(ctx.userId);
|
|
75
|
+
try {
|
|
76
|
+
const result = await manager.addUser(input.username, input.role);
|
|
77
|
+
return {
|
|
78
|
+
username: result.username,
|
|
79
|
+
user_id: result.userId,
|
|
80
|
+
role: result.role,
|
|
81
|
+
token: result.token,
|
|
82
|
+
created_at: result.createdAt
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
const msg = err instanceof Error ? err.message : "Bad request";
|
|
87
|
+
throwApiError(ApiErrorCode.INVALID_INPUT, msg);
|
|
88
|
+
}
|
|
89
|
+
}),
|
|
90
|
+
remove: protectedProcedure
|
|
91
|
+
.input(removeInput)
|
|
92
|
+
.output(removeOutput)
|
|
93
|
+
.mutation(async ({ ctx, input }) => {
|
|
94
|
+
requireAdmin(ctx.userId);
|
|
95
|
+
try {
|
|
96
|
+
await manager.removeUser(input.username);
|
|
97
|
+
return { message: `User '${input.username}' removed successfully` };
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
const msg = err instanceof Error ? err.message : "Not found";
|
|
101
|
+
throwApiError(ApiErrorCode.NOT_FOUND, msg);
|
|
102
|
+
}
|
|
103
|
+
}),
|
|
104
|
+
resetToken: protectedProcedure
|
|
105
|
+
.input(resetTokenInput)
|
|
106
|
+
.output(userCreateResponse)
|
|
107
|
+
.mutation(async ({ ctx, input }) => {
|
|
108
|
+
requireAdmin(ctx.userId);
|
|
109
|
+
try {
|
|
110
|
+
const result = await manager.resetToken(input.username);
|
|
111
|
+
return {
|
|
112
|
+
username: result.username,
|
|
113
|
+
user_id: result.userId,
|
|
114
|
+
role: result.role,
|
|
115
|
+
token: result.token,
|
|
116
|
+
created_at: result.createdAt
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
const msg = err instanceof Error ? err.message : "Not found";
|
|
121
|
+
throwApiError(ApiErrorCode.NOT_FOUND, msg);
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
});
|
|
125
|
+
//# sourceMappingURL=users.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.js","sourceRoot":"","sources":["../../../src/trpc/routers/users.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EACL,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,eAAe,EAEhB,MAAM,4CAA4C,CAAC;AAEpD;;;;GAIG;AACH,SAAS,OAAO,CAAC,MAAc;IAC7B,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC;IAChC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;IAC5C,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,QAAQ;aACZ,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,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