keryx 0.16.2 → 0.16.3
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/classes/Action.ts +8 -8
- package/classes/Logger.ts +8 -8
- package/classes/TypedError.ts +23 -23
- package/index.ts +3 -3
- package/initializers/actionts.ts +1 -1
- package/initializers/connections.ts +1 -1
- package/initializers/db.ts +2 -2
- package/initializers/resque.ts +4 -4
- package/package.json +4 -7
- package/servers/web.ts +1 -1
- package/templates/oauth-success.html +1 -1
- package/util/cli.ts +3 -3
- package/util/scaffold.ts +34 -3
package/classes/Action.ts
CHANGED
|
@@ -3,17 +3,17 @@ import type { Connection } from "./Connection";
|
|
|
3
3
|
import type { TypedError } from "./TypedError";
|
|
4
4
|
|
|
5
5
|
export enum MCP_RESPONSE_FORMAT {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
JSON = "json",
|
|
7
|
+
MARKDOWN = "markdown",
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export enum HTTP_METHOD {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
GET = "GET",
|
|
12
|
+
POST = "POST",
|
|
13
|
+
PUT = "PUT",
|
|
14
|
+
DELETE = "DELETE",
|
|
15
|
+
PATCH = "PATCH",
|
|
16
|
+
OPTIONS = "OPTIONS",
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export const DEFAULT_QUEUE = "default";
|
package/classes/Logger.ts
CHANGED
|
@@ -3,17 +3,17 @@ import colors from "colors";
|
|
|
3
3
|
import type { configLogger } from "../config/logger";
|
|
4
4
|
|
|
5
5
|
export enum LogLevel {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
trace = "trace",
|
|
7
|
+
debug = "debug",
|
|
8
|
+
info = "info",
|
|
9
|
+
warn = "warn",
|
|
10
|
+
error = "error",
|
|
11
|
+
fatal = "fatal",
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export enum LogFormat {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
text = "text",
|
|
16
|
+
json = "json",
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
package/classes/TypedError.ts
CHANGED
|
@@ -4,37 +4,37 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export enum ErrorType {
|
|
6
6
|
// general
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
SERVER_INITIALIZATION = "SERVER_INITIALIZATION",
|
|
8
|
+
SERVER_START = "SERVER_START",
|
|
9
|
+
SERVER_STOP = "SERVER_STOP",
|
|
10
10
|
|
|
11
11
|
// init
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
CONFIG_ERROR = "CONFIG_ERROR",
|
|
13
|
+
INITIALIZER_VALIDATION = "INITIALIZER_VALIDATION",
|
|
14
|
+
ACTION_VALIDATION = "ACTION_VALIDATION",
|
|
15
|
+
TASK_VALIDATION = "TASK_VALIDATION",
|
|
16
|
+
SERVER_VALIDATION = "SERVER_VALIDATION",
|
|
17
17
|
|
|
18
18
|
// session
|
|
19
|
-
|
|
19
|
+
CONNECTION_SESSION_NOT_FOUND = "CONNECTION_SESSION_NOT_FOUND",
|
|
20
20
|
|
|
21
21
|
// actions
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
CONNECTION_SERVER_ERROR = "CONNECTION_SERVER_ERROR",
|
|
23
|
+
CONNECTION_ACTION_NOT_FOUND = "CONNECTION_ACTION_NOT_FOUND",
|
|
24
|
+
CONNECTION_ACTION_PARAM_REQUIRED = "CONNECTION_ACTION_PARAM_REQUIRED",
|
|
25
|
+
CONNECTION_ACTION_PARAM_DEFAULT = "CONNECTION_ACTION_PARAM_DEFAULT",
|
|
26
|
+
CONNECTION_ACTION_PARAM_VALIDATION = "CONNECTION_ACTION_PARAM_VALIDATION",
|
|
27
|
+
CONNECTION_ACTION_PARAM_FORMATTING = "CONNECTION_ACTION_PARAM_FORMATTING",
|
|
28
|
+
CONNECTION_ACTION_RUN = "CONNECTION_ACTION_RUN",
|
|
29
|
+
CONNECTION_TYPE_NOT_FOUND = "CONNECTION_TYPE_NOT_FOUND",
|
|
30
|
+
CONNECTION_NOT_SUBSCRIBED = "CONNECTION_NOT_SUBSCRIBED",
|
|
31
|
+
CONNECTION_CHANNEL_AUTHORIZATION = "CONNECTION_CHANNEL_AUTHORIZATION",
|
|
32
|
+
CONNECTION_CHANNEL_VALIDATION = "CONNECTION_CHANNEL_VALIDATION",
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
CONNECTION_ACTION_TIMEOUT = "CONNECTION_ACTION_TIMEOUT",
|
|
35
|
+
CONNECTION_RATE_LIMITED = "CONNECTION_RATE_LIMITED",
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
CONNECTION_TASK_DEFINITION = "CONNECTION_TASK_DEFINITION",
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/** Maps each `ErrorType` to the HTTP status code returned to the client. */
|
package/index.ts
CHANGED
|
@@ -18,16 +18,16 @@ import "./initializers/signals";
|
|
|
18
18
|
import "./initializers/swagger";
|
|
19
19
|
|
|
20
20
|
export * from "./api";
|
|
21
|
-
export { HTTP_METHOD, MCP_RESPONSE_FORMAT } from "./classes/Action";
|
|
22
21
|
export type { ActionMiddleware } from "./classes/Action";
|
|
23
|
-
export {
|
|
22
|
+
export { HTTP_METHOD, MCP_RESPONSE_FORMAT } from "./classes/Action";
|
|
24
23
|
export type { ChannelMiddleware } from "./classes/Channel";
|
|
24
|
+
export { CHANNEL_NAME_PATTERN } from "./classes/Channel";
|
|
25
25
|
export { Connection } from "./classes/Connection";
|
|
26
26
|
export { LogLevel } from "./classes/Logger";
|
|
27
27
|
export { ErrorStatusCodes, ErrorType, TypedError } from "./classes/TypedError";
|
|
28
28
|
export type { KeryxConfig } from "./config";
|
|
29
29
|
export type { SessionData } from "./initializers/session";
|
|
30
|
-
export {
|
|
30
|
+
export { checkRateLimit, RateLimitMiddleware } from "./middleware/rateLimit";
|
|
31
31
|
export type { WebServer } from "./servers/web";
|
|
32
32
|
export { buildProgram } from "./util/cli";
|
|
33
33
|
export { deepMerge, loadFromEnvIfSet } from "./util/config";
|
package/initializers/actionts.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { randomUUID } from "crypto";
|
|
|
2
2
|
import type { ErrorPayload } from "node-resque";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { api, logger } from "../api";
|
|
5
|
-
import {
|
|
5
|
+
import { type Action, DEFAULT_QUEUE } from "../classes/Action";
|
|
6
6
|
import { Initializer } from "../classes/Initializer";
|
|
7
7
|
import { ErrorType, TypedError } from "../classes/TypedError";
|
|
8
8
|
import { config } from "../config";
|
package/initializers/db.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { unlink } from "node:fs/promises";
|
|
1
3
|
import { $ } from "bun";
|
|
2
4
|
import { type Config as DrizzleMigrateConfig } from "drizzle-kit";
|
|
3
5
|
import { DefaultLogger, type LogWriter, sql } from "drizzle-orm";
|
|
4
6
|
import { drizzle } from "drizzle-orm/node-postgres";
|
|
5
7
|
import { migrate } from "drizzle-orm/node-postgres/migrator";
|
|
6
|
-
import fs from "node:fs";
|
|
7
|
-
import { unlink } from "node:fs/promises";
|
|
8
8
|
import path from "path";
|
|
9
9
|
import { Pool } from "pg";
|
|
10
10
|
import { api, logger } from "../api";
|
package/initializers/resque.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
+
type Job,
|
|
3
|
+
type ParsedJob,
|
|
2
4
|
Queue,
|
|
3
5
|
Scheduler,
|
|
4
6
|
Worker,
|
|
5
|
-
type Job,
|
|
6
|
-
type ParsedJob,
|
|
7
7
|
} from "node-resque";
|
|
8
8
|
import {
|
|
9
9
|
Action,
|
|
10
|
+
type ActionParams,
|
|
10
11
|
api,
|
|
11
|
-
config,
|
|
12
12
|
Connection,
|
|
13
|
+
config,
|
|
13
14
|
logger,
|
|
14
15
|
RUN_MODE,
|
|
15
|
-
type ActionParams,
|
|
16
16
|
} from "../api";
|
|
17
17
|
import { Initializer } from "../classes/Initializer";
|
|
18
18
|
import { LogFormat } from "../classes/Logger";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keryx",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.3",
|
|
4
4
|
"module": "index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"migrations": "bun run migrations.ts",
|
|
73
73
|
"test": "tsc && bun test",
|
|
74
74
|
"compile": "bun build keryx.ts --compile --outfile keryx",
|
|
75
|
-
"lint": "tsc &&
|
|
76
|
-
"format": "tsc &&
|
|
75
|
+
"lint": "tsc && biome check .",
|
|
76
|
+
"format": "tsc && biome check --write .",
|
|
77
77
|
"prepublishOnly": "cp ../../README.md ."
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
@@ -99,12 +99,9 @@
|
|
|
99
99
|
"zod": "^4.3.6"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
|
-
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
|
|
103
102
|
"@types/bun": "latest",
|
|
104
103
|
"@types/formidable": "^3.4.6",
|
|
105
104
|
"drizzle-kit": "^0.31.9",
|
|
106
|
-
"drizzle-zod": "^0.8.3"
|
|
107
|
-
"prettier": "^3.8.1",
|
|
108
|
-
"prettier-plugin-organize-imports": "^4.3.0"
|
|
105
|
+
"drizzle-zod": "^0.8.3"
|
|
109
106
|
}
|
|
110
107
|
}
|
package/servers/web.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { parse } from "node:url";
|
|
1
2
|
import type { ServerWebSocket } from "bun";
|
|
2
3
|
import colors from "colors";
|
|
3
4
|
import cookie from "cookie";
|
|
4
5
|
import { randomUUID } from "crypto";
|
|
5
|
-
import { parse } from "node:url";
|
|
6
6
|
import { api, logger } from "../api";
|
|
7
7
|
import { type HTTP_METHOD } from "../classes/Action";
|
|
8
8
|
import { Connection } from "../classes/Connection";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<meta name="redirect-url" content="{{
|
|
6
|
+
<meta name="redirect-url" content="{{redirectUrl}}" />
|
|
7
7
|
<title>Authorization Successful</title>
|
|
8
8
|
<style>
|
|
9
9
|
{{> commonCss}}
|
package/util/cli.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
1
|
import os from "node:os";
|
|
2
|
+
import { Command } from "commander";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { Action, api, Connection, RUN_MODE } from "../api";
|
|
5
|
-
import { config } from "../config";
|
|
6
5
|
import { ExitCode } from "./../classes/ExitCode";
|
|
7
6
|
import { TypedError } from "./../classes/TypedError";
|
|
7
|
+
import { config } from "../config";
|
|
8
8
|
import { generateComponent } from "./generate";
|
|
9
9
|
import { globLoader } from "./glob";
|
|
10
10
|
import {
|
|
11
11
|
interactiveScaffold,
|
|
12
|
-
scaffoldProject,
|
|
13
12
|
type ScaffoldOptions,
|
|
13
|
+
scaffoldProject,
|
|
14
14
|
} from "./scaffold";
|
|
15
15
|
import { upgradeProject } from "./upgrade";
|
|
16
16
|
|
package/util/scaffold.ts
CHANGED
|
@@ -298,8 +298,8 @@ export async function scaffoldProject(
|
|
|
298
298
|
start: "bun keryx.ts start",
|
|
299
299
|
dev: "bun --watch keryx.ts start",
|
|
300
300
|
...(options.includeDb ? { migrations: "bun run migrations.ts" } : {}),
|
|
301
|
-
lint: "tsc &&
|
|
302
|
-
format: "tsc &&
|
|
301
|
+
lint: "tsc && biome check .",
|
|
302
|
+
format: "tsc && biome check --write .",
|
|
303
303
|
},
|
|
304
304
|
dependencies: {
|
|
305
305
|
keryx: `^${keryxVersion}`,
|
|
@@ -312,8 +312,8 @@ export async function scaffoldProject(
|
|
|
312
312
|
: {}),
|
|
313
313
|
},
|
|
314
314
|
devDependencies: {
|
|
315
|
+
"@biomejs/biome": "^2.4.8",
|
|
315
316
|
"@types/bun": "latest",
|
|
316
|
-
prettier: "^3.8.1",
|
|
317
317
|
...(options.includeDb ? { "drizzle-kit": "^0.20.18" } : {}),
|
|
318
318
|
},
|
|
319
319
|
},
|
|
@@ -323,6 +323,37 @@ export async function scaffoldProject(
|
|
|
323
323
|
);
|
|
324
324
|
|
|
325
325
|
await write("tsconfig.json", generateTsconfigContents());
|
|
326
|
+
await write(
|
|
327
|
+
"biome.json",
|
|
328
|
+
JSON.stringify(
|
|
329
|
+
{
|
|
330
|
+
$schema: "https://biomejs.dev/schemas/2.4.8/schema.json",
|
|
331
|
+
assist: { actions: { source: { organizeImports: "on" } } },
|
|
332
|
+
formatter: {
|
|
333
|
+
enabled: true,
|
|
334
|
+
indentStyle: "space",
|
|
335
|
+
indentWidth: 2,
|
|
336
|
+
lineWidth: 80,
|
|
337
|
+
},
|
|
338
|
+
linter: { enabled: false },
|
|
339
|
+
javascript: {
|
|
340
|
+
formatter: { quoteStyle: "double", trailingCommas: "all" },
|
|
341
|
+
},
|
|
342
|
+
files: {
|
|
343
|
+
includes: [
|
|
344
|
+
"**",
|
|
345
|
+
"!**/node_modules",
|
|
346
|
+
"!**/types/",
|
|
347
|
+
"!**/.cache/",
|
|
348
|
+
"!**/bun.lockb",
|
|
349
|
+
"!**/templates/**",
|
|
350
|
+
],
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
null,
|
|
354
|
+
2,
|
|
355
|
+
) + "\n",
|
|
356
|
+
);
|
|
326
357
|
|
|
327
358
|
await writeTemplate("index.ts", "index.ts.mustache");
|
|
328
359
|
await write("keryx.ts", await generateKeryxTsContents());
|