keryx 0.10.7 → 0.11.1
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/api.ts +2 -1
- package/config/index.ts +29 -1
- package/index.ts +8 -0
- package/initializers/mcp.ts +0 -1
- package/package.json +1 -1
- package/templates/generate/action-middleware.ts.mustache +1 -1
- package/templates/generate/action.ts.mustache +1 -2
- package/templates/scaffold/hello-action.ts.mustache +1 -2
- package/templates/scaffold/keryx.ts.mustache +1 -1
- package/util/glob.ts +2 -20
- package/util/scaffold.ts +4 -4
package/api.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { API } from "./classes/API";
|
|
2
2
|
import type { Logger } from "./classes/Logger";
|
|
3
|
+
import type { KeryxConfig } from "./config";
|
|
3
4
|
import { config as Config } from "./config";
|
|
4
5
|
|
|
5
6
|
export {
|
|
@@ -30,7 +31,7 @@ export type {
|
|
|
30
31
|
declare namespace globalThis {
|
|
31
32
|
let api: API;
|
|
32
33
|
let logger: Logger;
|
|
33
|
-
let config:
|
|
34
|
+
let config: KeryxConfig;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
if (!globalThis.api) {
|
package/config/index.ts
CHANGED
|
@@ -26,4 +26,32 @@ export const config = {
|
|
|
26
26
|
tasks: configTasks,
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* The type of the merged configuration object. Applications can extend this
|
|
31
|
+
* via module augmentation to add custom config sections:
|
|
32
|
+
*
|
|
33
|
+
* ```typescript
|
|
34
|
+
* declare module "keryx" {
|
|
35
|
+
* interface KeryxConfig {
|
|
36
|
+
* audit: { retentionDays: number };
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export interface KeryxConfig {
|
|
42
|
+
actions: typeof configActions;
|
|
43
|
+
channels: typeof configChannels;
|
|
44
|
+
process: typeof configProcess;
|
|
45
|
+
logger: typeof configLogger;
|
|
46
|
+
database: typeof configDatabase;
|
|
47
|
+
observability: typeof configObservability;
|
|
48
|
+
redis: typeof configRedis;
|
|
49
|
+
rateLimit: typeof configRateLimit;
|
|
50
|
+
session: typeof configSession;
|
|
51
|
+
server: {
|
|
52
|
+
cli: typeof configServerCli;
|
|
53
|
+
web: typeof configServerWeb;
|
|
54
|
+
mcp: typeof configServerMcp;
|
|
55
|
+
};
|
|
56
|
+
tasks: typeof configTasks;
|
|
57
|
+
}
|
package/index.ts
CHANGED
|
@@ -18,9 +18,17 @@ import "./initializers/signals";
|
|
|
18
18
|
import "./initializers/swagger";
|
|
19
19
|
|
|
20
20
|
export * from "./api";
|
|
21
|
+
export { HTTP_METHOD } from "./classes/Action";
|
|
21
22
|
export type { ActionMiddleware } from "./classes/Action";
|
|
23
|
+
export { CHANNEL_NAME_PATTERN } from "./classes/Channel";
|
|
24
|
+
export type { ChannelMiddleware } from "./classes/Channel";
|
|
25
|
+
export { LogLevel } from "./classes/Logger";
|
|
22
26
|
export { ErrorStatusCodes, ErrorType, TypedError } from "./classes/TypedError";
|
|
23
27
|
export type { KeryxConfig } from "./config";
|
|
28
|
+
export type { SessionData } from "./initializers/session";
|
|
29
|
+
export { RateLimitMiddleware, checkRateLimit } from "./middleware/rateLimit";
|
|
30
|
+
export type { WebServer } from "./servers/web";
|
|
31
|
+
export { buildProgram } from "./util/cli";
|
|
24
32
|
export { deepMerge, loadFromEnvIfSet } from "./util/config";
|
|
25
33
|
export { globLoader } from "./util/glob";
|
|
26
34
|
export {
|
package/initializers/mcp.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { Action, type ActionParams } from "keryx";
|
|
3
|
-
import { HTTP_METHOD } from "keryx/classes/Action.ts";
|
|
2
|
+
import { Action, type ActionParams, HTTP_METHOD } from "keryx";
|
|
4
3
|
|
|
5
4
|
export class {{className}} implements Action {
|
|
6
5
|
name = "{{name}}";
|
package/util/glob.ts
CHANGED
|
@@ -25,26 +25,8 @@ export async function globLoader<T>(searchDir: string) {
|
|
|
25
25
|
const fullPath = path.join(dir, file);
|
|
26
26
|
const modules = (await import(fullPath)) as Record<string, unknown>;
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// per-key access so one TDZ export doesn't block the entire module.
|
|
31
|
-
let entries: [string, unknown][];
|
|
32
|
-
try {
|
|
33
|
-
entries = Object.entries(modules);
|
|
34
|
-
} catch {
|
|
35
|
-
const keys = Object.getOwnPropertyNames(modules);
|
|
36
|
-
entries = [];
|
|
37
|
-
for (const key of keys) {
|
|
38
|
-
try {
|
|
39
|
-
entries.push([key, modules[key]]);
|
|
40
|
-
} catch {
|
|
41
|
-
// Skip TDZ exports — they'll be loaded by their own initializer
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
for (const [name, klass] of entries) {
|
|
47
|
-
// Skip non-class exports (constants, functions, type remnants)
|
|
28
|
+
for (const [name, klass] of Object.entries(modules)) {
|
|
29
|
+
// Skip non-class exports (constants, enums, functions)
|
|
48
30
|
if (typeof klass !== "function" || klass.prototype === undefined) {
|
|
49
31
|
continue;
|
|
50
32
|
}
|
package/util/scaffold.ts
CHANGED
|
@@ -101,15 +101,15 @@ export async function generateConfigFileContents(): Promise<
|
|
|
101
101
|
);
|
|
102
102
|
content = content.replace(
|
|
103
103
|
/from ["']\.\.\/classes\/Logger["']/g,
|
|
104
|
-
'from "keryx
|
|
104
|
+
'from "keryx"',
|
|
105
105
|
);
|
|
106
106
|
|
|
107
107
|
// In index.ts, change `export const config` to `export default`
|
|
108
|
-
// and remove the KeryxConfig
|
|
108
|
+
// and remove the KeryxConfig interface export (it comes from the package)
|
|
109
109
|
if (file === "index.ts") {
|
|
110
110
|
content = content.replace("export const config =", "export default");
|
|
111
111
|
content = content.replace(
|
|
112
|
-
/\nexport
|
|
112
|
+
/\nexport interface KeryxConfig \{[\s\S]*?\}\n/,
|
|
113
113
|
"\n",
|
|
114
114
|
);
|
|
115
115
|
}
|
|
@@ -139,7 +139,7 @@ export async function generateBuiltinActionContents(): Promise<
|
|
|
139
139
|
content = content.replace(/from ["']\.\.\/api["']/g, 'from "keryx"');
|
|
140
140
|
content = content.replace(
|
|
141
141
|
/from ["']\.\.\/classes\/Action["']/g,
|
|
142
|
-
'from "keryx
|
|
142
|
+
'from "keryx"',
|
|
143
143
|
);
|
|
144
144
|
content = content.replace(
|
|
145
145
|
/from ["']\.\.\/package\.json["']/g,
|