weifuwu 0.24.0 → 0.24.2
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 +970 -756
- package/cli/template/app.ts +5 -1
- package/cli/template/index.ts +4 -1
- package/cli/template/locales/en.json +6 -1
- package/cli/template/locales/zh-CN.json +6 -1
- package/cli/template/locales/zh-TW.json +6 -1
- package/cli/template/locales/zh.json +6 -1
- package/cli/template/ui/app/globals.css +1 -1
- package/cli/template/ui/app/page.tsx +55 -16
- package/cli.ts +148 -104
- package/dist/agent/rest.d.ts +1 -1
- package/dist/agent/run.d.ts +2 -2
- package/dist/agent/types.d.ts +2 -1
- package/dist/ai/workflow.d.ts +1 -1
- package/dist/ai-sdk.d.ts +1 -1
- package/dist/analytics.d.ts +2 -2
- package/dist/cache.d.ts +4 -4
- package/dist/cli.js +135 -97
- package/dist/cookie.d.ts +24 -0
- package/dist/cors.d.ts +2 -2
- package/dist/deploy/types.d.ts +2 -2
- package/dist/fts.d.ts +5 -5
- package/dist/helmet.d.ts +2 -2
- package/dist/hub.d.ts +2 -1
- package/dist/iii/index.d.ts +1 -1
- package/dist/iii/register-worker.d.ts +1 -1
- package/dist/iii/types.d.ts +4 -4
- package/dist/index.d.ts +5 -5
- package/dist/index.js +905 -442
- package/dist/kb/types.d.ts +8 -0
- package/dist/live.d.ts +2 -3
- package/dist/logdb/rest.d.ts +1 -1
- package/dist/logdb/types.d.ts +2 -1
- package/dist/mailer.d.ts +3 -2
- package/dist/messager/agent.d.ts +2 -2
- package/dist/messager/rest.d.ts +3 -3
- package/dist/messager/types.d.ts +2 -1
- package/dist/messager/ws.d.ts +3 -3
- package/dist/opencode/index.d.ts +1 -1
- package/dist/opencode/permissions.d.ts +1 -1
- package/dist/opencode/run.d.ts +1 -1
- package/dist/opencode/session.d.ts +9 -9
- package/dist/opencode/tools/web.d.ts +1 -1
- package/dist/opencode/types.d.ts +2 -1
- package/dist/opencode/ws.d.ts +1 -2
- package/dist/permissions.d.ts +4 -4
- package/dist/postgres/module.d.ts +5 -4
- package/dist/postgres/schema/index.d.ts +1 -1
- package/dist/postgres/schema/table.d.ts +22 -20
- package/dist/postgres/types.d.ts +6 -6
- package/dist/queue/types.d.ts +3 -3
- package/dist/rate-limit.d.ts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +141 -96
- package/dist/redis/types.d.ts +2 -2
- package/dist/router.d.ts +10 -10
- package/dist/seo.d.ts +2 -2
- package/dist/serve.d.ts +1 -1
- package/dist/session.d.ts +8 -5
- package/dist/tailwind.d.ts +9 -0
- package/dist/tenant/graphql.d.ts +2 -2
- package/dist/tenant/index.d.ts +1 -1
- package/dist/tenant/rest.d.ts +2 -2
- package/dist/tenant/types.d.ts +3 -3
- package/dist/test-utils.d.ts +3 -3
- package/dist/types.d.ts +8 -0
- package/dist/upload.d.ts +4 -2
- package/dist/user/index.d.ts +1 -1
- package/dist/user/oauth-login.d.ts +2 -2
- package/dist/user/types.d.ts +2 -2
- package/dist/vendor.d.ts +4 -0
- package/opencode/ui/app/globals.css +1 -1
- package/opencode/ui/app/layout.tsx +2 -3
- package/opencode/ui/app/page.tsx +302 -73
- package/package.json +33 -10
- package/cli/template/.weifuwu/ssr/2e3a7e60.js +0 -112
package/dist/kb/types.d.ts
CHANGED
|
@@ -41,6 +41,14 @@ export interface KBListEntry {
|
|
|
41
41
|
title: string;
|
|
42
42
|
chunks: number;
|
|
43
43
|
}
|
|
44
|
+
export interface KBInjected {
|
|
45
|
+
search(query: string, searchOptions?: KBSearchOptions): Promise<KBSearchResult[]>;
|
|
46
|
+
}
|
|
47
|
+
declare module '../types.ts' {
|
|
48
|
+
interface Context {
|
|
49
|
+
kb?: KBInjected;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
44
52
|
export interface KBModule {
|
|
45
53
|
/**
|
|
46
54
|
* Ingest a document: chunk → embed → store.
|
package/dist/live.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { Router } from './router.ts';
|
|
2
|
-
import type { WebSocketHandler } from './router.ts';
|
|
1
|
+
import { Router, type WebSocketHandler } from './router.ts';
|
|
3
2
|
export declare function broadcastReload(): void;
|
|
4
3
|
export declare function liveWs(): WebSocketHandler;
|
|
5
|
-
export declare function liveRouter(
|
|
4
|
+
export declare function liveRouter(_dir: string): Router;
|
|
6
5
|
export declare function liveWatcher(dir: string): {
|
|
7
6
|
close: () => void;
|
|
8
7
|
};
|
package/dist/logdb/rest.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type BoundTable } from '../postgres/schema/index.ts';
|
|
2
2
|
import type { Context } from '../types.ts';
|
|
3
3
|
export declare function createHandler(entries: BoundTable<any>): (req: Request, ctx: Context) => Promise<Response>;
|
|
4
4
|
export declare function listHandler(entries: BoundTable<any>): (req: Request) => Promise<Response>;
|
package/dist/logdb/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PostgresClient } from '../postgres/types.ts';
|
|
2
2
|
import type { Router } from '../router.ts';
|
|
3
|
+
import type { Closeable } from '../types.ts';
|
|
3
4
|
export interface LogdbOptions {
|
|
4
5
|
pg: PostgresClient;
|
|
5
6
|
table?: string;
|
|
@@ -18,7 +19,7 @@ export interface LogEntryInput {
|
|
|
18
19
|
message: string;
|
|
19
20
|
metadata?: Record<string, unknown>;
|
|
20
21
|
}
|
|
21
|
-
export interface LogdbModule extends Router {
|
|
22
|
+
export interface LogdbModule extends Router, Closeable {
|
|
22
23
|
log(input: LogEntryInput): Promise<LogEntry>;
|
|
23
24
|
migrate(): Promise<void>;
|
|
24
25
|
clean(retentionMonths: number): Promise<number>;
|
package/dist/mailer.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Transporter } from 'nodemailer';
|
|
2
|
+
import type { Closeable } from './types.ts';
|
|
2
3
|
/** Options for sending an email. */
|
|
3
4
|
export interface MailOptions {
|
|
4
5
|
/** Recipient address(es). */
|
|
@@ -26,7 +27,7 @@ export interface MailerOptions {
|
|
|
26
27
|
send?: (opts: MailOptions) => Promise<void>;
|
|
27
28
|
}
|
|
28
29
|
/** Mailer instance returned by {@link mailer}. */
|
|
29
|
-
export interface Mailer {
|
|
30
|
+
export interface Mailer extends Closeable {
|
|
30
31
|
/** Send an email. */
|
|
31
32
|
send: (opts: MailOptions) => Promise<void>;
|
|
32
33
|
/** Close the nodemailer transport. */
|
package/dist/messager/agent.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SqlClient } from '../vendor.ts';
|
|
2
2
|
import type { AgentModule } from '../agent/types.ts';
|
|
3
3
|
import type { Hub } from '../hub.ts';
|
|
4
4
|
/**
|
|
@@ -6,6 +6,6 @@ import type { Hub } from '../hub.ts';
|
|
|
6
6
|
* - Streaming: broadcasts SSE text tokens in real-time
|
|
7
7
|
* - Multi-round: passes recent channel history as conversation context
|
|
8
8
|
*/
|
|
9
|
-
export declare function runAgentRouting(sql:
|
|
9
|
+
export declare function runAgentRouting(sql: SqlClient, messages: {
|
|
10
10
|
insert: (data: any) => Promise<any>;
|
|
11
11
|
}, agents: AgentModule | undefined, hub: Hub, channelId: number, content: string, stream?: boolean, contextMessages?: number): Promise<void>;
|
package/dist/messager/rest.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SqlClient } from '../vendor.ts';
|
|
2
2
|
import { Router } from '../router.ts';
|
|
3
3
|
import type { AgentModule } from '../agent/types.ts';
|
|
4
4
|
import type { Hub } from '../hub.ts';
|
|
5
|
-
import type
|
|
5
|
+
import { type BoundTable } from '../postgres/schema/index.ts';
|
|
6
6
|
interface RestDeps {
|
|
7
|
-
sql:
|
|
7
|
+
sql: SqlClient;
|
|
8
8
|
channels: BoundTable<any>;
|
|
9
9
|
members: BoundTable<any>;
|
|
10
10
|
messages: BoundTable<any>;
|
package/dist/messager/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Router } from '../router.ts';
|
|
|
2
2
|
import type { AgentModule } from '../agent/types.ts';
|
|
3
3
|
import type { PostgresClient } from '../postgres/types.ts';
|
|
4
4
|
import type { Redis } from '../vendor.ts';
|
|
5
|
+
import type { Closeable } from '../types.ts';
|
|
5
6
|
export interface MessagerOptions {
|
|
6
7
|
pg: PostgresClient;
|
|
7
8
|
agents?: AgentModule;
|
|
@@ -37,7 +38,7 @@ export interface Message {
|
|
|
37
38
|
mime_type: string | null;
|
|
38
39
|
created_at: string;
|
|
39
40
|
}
|
|
40
|
-
export interface MessagerModule extends Router {
|
|
41
|
+
export interface MessagerModule extends Router, Closeable {
|
|
41
42
|
migrate: () => Promise<void>;
|
|
42
43
|
wsHandler: () => any;
|
|
43
44
|
send: (channelId: number, content: string, opts?: {
|
package/dist/messager/ws.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SqlClient } from '../vendor.ts';
|
|
2
2
|
import type { AgentModule } from '../agent/types.ts';
|
|
3
|
-
import type
|
|
3
|
+
import { type Hub } from '../hub.ts';
|
|
4
4
|
interface WSDeps {
|
|
5
|
-
sql:
|
|
5
|
+
sql: SqlClient;
|
|
6
6
|
agents?: AgentModule;
|
|
7
7
|
redis?: import('../vendor.ts').Redis;
|
|
8
8
|
}
|
package/dist/opencode/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { opencode } from './client.ts';
|
|
2
|
-
export type { OpencodeOptions, OpencodeModule, SkillDef, SkillRegistry, OpencodePermissions, Session } from './types.ts';
|
|
2
|
+
export type { OpencodeOptions, OpencodeModule, SkillDef, SkillRegistry, OpencodePermissions, Session, } from './types.ts';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OpencodePermissions } from './types.ts';
|
|
2
2
|
export declare function isCommandAllowed(command: string): boolean;
|
|
3
|
-
export declare function isPathAllowed(resolvedPath: string, workspace: string,
|
|
3
|
+
export declare function isPathAllowed(resolvedPath: string, workspace: string, _perms?: OpencodePermissions): boolean;
|
|
4
4
|
export declare function isToolEnabled(name: string, perms?: OpencodePermissions): boolean;
|
|
5
5
|
export declare function isSkillAllowed(name: string, perms?: OpencodePermissions): boolean;
|
package/dist/opencode/run.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SqlClient } from '../vendor.ts';
|
|
2
2
|
import type { Session, Message } from './types.ts';
|
|
3
|
-
export declare function createSession(sql:
|
|
3
|
+
export declare function createSession(sql: SqlClient, opts: {
|
|
4
4
|
userId?: number;
|
|
5
5
|
title?: string;
|
|
6
6
|
model?: string;
|
|
7
7
|
systemPrompt?: string;
|
|
8
8
|
}, cwd: string, mountPath: string): Promise<Session>;
|
|
9
|
-
export declare function getSession(sql:
|
|
10
|
-
export declare function listSessions(sql:
|
|
11
|
-
export declare function deleteSession(sql:
|
|
12
|
-
export declare function getHistory(sql:
|
|
9
|
+
export declare function getSession(sql: SqlClient, id: string): Promise<Session | null>;
|
|
10
|
+
export declare function listSessions(sql: SqlClient, userId?: number): Promise<Session[]>;
|
|
11
|
+
export declare function deleteSession(sql: SqlClient, id: string): Promise<void>;
|
|
12
|
+
export declare function getHistory(sql: SqlClient, sessionId: string, limit?: number): Promise<SessionMessage[]>;
|
|
13
13
|
export interface SessionMessage {
|
|
14
14
|
id: number;
|
|
15
15
|
session_id: string;
|
|
@@ -21,6 +21,6 @@ export interface SessionMessage {
|
|
|
21
21
|
tokens_out: number;
|
|
22
22
|
created_at: string;
|
|
23
23
|
}
|
|
24
|
-
export declare function addTextMessage(sql:
|
|
25
|
-
export declare function addToolMessages(sql:
|
|
26
|
-
export declare function updateSessionTitle(sql:
|
|
24
|
+
export declare function addTextMessage(sql: SqlClient, sessionId: string, role: 'user' | 'assistant', content: string, tokensIn?: number, tokensOut?: number): Promise<Message>;
|
|
25
|
+
export declare function addToolMessages(sql: SqlClient, sessionId: string, toolCalls: unknown[], toolResults: unknown[]): Promise<Message>;
|
|
26
|
+
export declare function updateSessionTitle(sql: SqlClient, id: string, title: string): Promise<void>;
|
package/dist/opencode/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Router } from '../router.ts';
|
|
2
2
|
import type { PostgresClient } from '../postgres/types.ts';
|
|
3
|
+
import type { Closeable } from '../types.ts';
|
|
3
4
|
export interface Session {
|
|
4
5
|
id: string;
|
|
5
6
|
tenant_id: string | null;
|
|
@@ -74,7 +75,7 @@ export interface OpencodeOptions {
|
|
|
74
75
|
skills?: SkillDef[];
|
|
75
76
|
permissions?: OpencodePermissions;
|
|
76
77
|
}
|
|
77
|
-
export interface OpencodeModule extends Router {
|
|
78
|
+
export interface OpencodeModule extends Router, Closeable {
|
|
78
79
|
migrate: () => Promise<void>;
|
|
79
80
|
wsHandler: () => any;
|
|
80
81
|
close: () => Promise<void>;
|
package/dist/opencode/ws.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { WebSocket } from '../vendor.ts';
|
|
2
2
|
import type { LanguageModel } from 'ai';
|
|
3
3
|
import type { Context } from '../types.ts';
|
|
4
|
-
import type { PendingQuestion, SkillDef, SkillRegistry } from './types.ts';
|
|
5
|
-
import type { OpencodePermissions } from './types.ts';
|
|
4
|
+
import type { PendingQuestion, SkillDef, SkillRegistry, OpencodePermissions } from './types.ts';
|
|
6
5
|
interface WsDeps {
|
|
7
6
|
sql: any;
|
|
8
7
|
model: LanguageModel;
|
package/dist/permissions.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SqlClient } from './vendor.ts';
|
|
2
2
|
import type { Middleware, Context, Handler } from './types.ts';
|
|
3
3
|
declare module './types.ts' {
|
|
4
4
|
interface Context {
|
|
@@ -11,7 +11,7 @@ declare module './types.ts' {
|
|
|
11
11
|
export interface PermissionsOptions {
|
|
12
12
|
/** PostgreSQL client. */
|
|
13
13
|
pg: {
|
|
14
|
-
sql:
|
|
14
|
+
sql: SqlClient;
|
|
15
15
|
};
|
|
16
16
|
/** Table prefix (default: '' → _roles, _user_roles, _role_permissions). */
|
|
17
17
|
prefix?: string;
|
|
@@ -39,12 +39,12 @@ export interface PermissionsModule extends Middleware {
|
|
|
39
39
|
* Middleware that rejects the request if the user does not have any of the specified roles.
|
|
40
40
|
* Must be placed after `permissions()` middleware (which injects ctx.permissions.roles).
|
|
41
41
|
*/
|
|
42
|
-
requireRole(...roles: string[]): Middleware
|
|
42
|
+
requireRole(...roles: string[]): Middleware<Context, Context>;
|
|
43
43
|
/**
|
|
44
44
|
* Middleware that rejects the request if the user does not have all specified permissions.
|
|
45
45
|
* Must be placed after `permissions()` middleware (which injects ctx.permissions.permissions).
|
|
46
46
|
*/
|
|
47
|
-
requirePermission(...permissions: string[]): Middleware
|
|
47
|
+
requirePermission(...permissions: string[]): Middleware<Context, Context>;
|
|
48
48
|
/** Create the underlying tables. Safe to call multiple times. */
|
|
49
49
|
migrate(): Promise<void>;
|
|
50
50
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { PostgresClient } from './types.ts';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SqlClient } from '../vendor.ts';
|
|
3
3
|
import type { ColumnBuilder, BoundTable, Table } from './schema/index.ts';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import type { Closeable } from '../types.ts';
|
|
5
|
+
export declare class PgModule implements Closeable {
|
|
6
|
+
protected sql: SqlClient;
|
|
6
7
|
protected pg: PostgresClient;
|
|
7
8
|
constructor(pg: PostgresClient);
|
|
8
9
|
table<R extends Record<string, unknown>>(tableOrSchema: string | Table<R>, builders?: {
|
|
9
10
|
[K in keyof R]: ColumnBuilder<R[K]>;
|
|
10
11
|
}): BoundTable<R>;
|
|
11
|
-
transaction<T>(fn: (sql:
|
|
12
|
+
transaction<T>(fn: (sql: SqlClient) => Promise<T>, retryOpts?: {
|
|
12
13
|
maxRetries?: number;
|
|
13
14
|
}): Promise<T>;
|
|
14
15
|
migrate(): Promise<void>;
|
|
@@ -3,4 +3,4 @@ export { ColumnBuilder, serial, uuid, text, integer, boolean as boolean, boolean
|
|
|
3
3
|
export type { PartitionByDef } from './columns.ts';
|
|
4
4
|
export { pgTable, Table, BoundTable } from './table.ts';
|
|
5
5
|
export type { IndexOptions, FindOptions, CreateOptions } from './table.ts';
|
|
6
|
-
export { eq, ne, gt, gte, lt, lte, isNull, isNotNull, like, contains, in_, and, or, not } from './where.ts';
|
|
6
|
+
export { eq, ne, gt, gte, lt, lte, isNull, isNotNull, like, contains, in_, and, or, not, } from './where.ts';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SqlClient } from '../../vendor.ts';
|
|
2
2
|
import { ColumnBuilder, type PartitionByDef } from './columns.ts';
|
|
3
3
|
import { SQL } from './sql.ts';
|
|
4
4
|
/** Options for table index creation. */
|
|
@@ -64,39 +64,41 @@ export declare class Table<R extends Record<string, unknown>> {
|
|
|
64
64
|
* Bind this table schema to a SQL connection, returning a `BoundTable`
|
|
65
65
|
* that can run queries without passing `sql` to every call.
|
|
66
66
|
*/
|
|
67
|
-
bind(sql:
|
|
67
|
+
bind(sql: SqlClient): BoundTable<R>;
|
|
68
68
|
/** Returns the primary key column name (DB name), or 'id' as fallback. */
|
|
69
69
|
private get pkColumn();
|
|
70
70
|
/** Adds `deleted_at IS NULL` condition if the table has soft delete and not explicitly excluded. */
|
|
71
71
|
private _softDeleteFilter;
|
|
72
|
-
create(sql:
|
|
73
|
-
drop(sql:
|
|
72
|
+
create(sql: SqlClient, opts?: CreateOptions): Promise<void>;
|
|
73
|
+
drop(sql: SqlClient, opts?: {
|
|
74
74
|
cascade?: boolean;
|
|
75
75
|
}): Promise<void>;
|
|
76
|
-
createIndex(sql:
|
|
77
|
-
createUniqueIndex(sql:
|
|
76
|
+
createIndex(sql: SqlClient, columns: string | string[], opts?: IndexOptions): Promise<void>;
|
|
77
|
+
createUniqueIndex(sql: SqlClient, columns: string | string[]): Promise<void>;
|
|
78
78
|
private _buildConditions;
|
|
79
79
|
private _buildSET;
|
|
80
|
-
insert(sql:
|
|
81
|
-
insertMany(sql:
|
|
82
|
-
read(sql:
|
|
83
|
-
readMany(sql:
|
|
80
|
+
insert(sql: SqlClient, data: Partial<R>): Promise<R>;
|
|
81
|
+
insertMany(sql: SqlClient, data: Partial<R>[]): Promise<R[]>;
|
|
82
|
+
read(sql: SqlClient, id: string | number, opts?: Pick<FindOptions, 'select' | 'withDeleted'>): Promise<R | undefined>;
|
|
83
|
+
readMany(sql: SqlClient, where?: Partial<R> | SQL | SQL[], opts?: FindOptions): Promise<{
|
|
84
84
|
count: number;
|
|
85
85
|
data: R[];
|
|
86
86
|
}>;
|
|
87
|
-
update(sql:
|
|
88
|
-
updateMany(sql:
|
|
89
|
-
delete(sql:
|
|
90
|
-
hardDelete(sql:
|
|
91
|
-
deleteMany(sql:
|
|
92
|
-
hardDeleteMany(sql:
|
|
93
|
-
upsert(sql:
|
|
94
|
-
count(sql:
|
|
87
|
+
update(sql: SqlClient, id: string | number, data: Partial<R>): Promise<R | undefined>;
|
|
88
|
+
updateMany(sql: SqlClient, where: Partial<R> | SQL | SQL[], data: Partial<R>): Promise<number>;
|
|
89
|
+
delete(sql: SqlClient, id: string | number): Promise<R | undefined>;
|
|
90
|
+
hardDelete(sql: SqlClient, id: string | number): Promise<R | undefined>;
|
|
91
|
+
deleteMany(sql: SqlClient, where: Partial<R> | SQL | SQL[]): Promise<number>;
|
|
92
|
+
hardDeleteMany(sql: SqlClient, where: Partial<R> | SQL | SQL[]): Promise<number>;
|
|
93
|
+
upsert(sql: SqlClient, data: Partial<R>, conflict: string | string[]): Promise<R>;
|
|
94
|
+
count(sql: SqlClient, where?: Partial<R> | SQL | SQL[]): Promise<number>;
|
|
95
95
|
}
|
|
96
96
|
export declare class BoundTable<R extends Record<string, unknown>> {
|
|
97
97
|
private inner;
|
|
98
98
|
private sql;
|
|
99
|
-
|
|
99
|
+
/** The underlying table name. */
|
|
100
|
+
get tableName(): string;
|
|
101
|
+
constructor(sql: SqlClient, tableName: string, builders: Record<string, ColumnBuilder<unknown>>);
|
|
100
102
|
create(opts?: CreateOptions): Promise<void>;
|
|
101
103
|
drop(opts?: {
|
|
102
104
|
cascade?: boolean;
|
|
@@ -118,7 +120,7 @@ export declare class BoundTable<R extends Record<string, unknown>> {
|
|
|
118
120
|
hardDeleteMany(where: Partial<R> | SQL | SQL[]): Promise<number>;
|
|
119
121
|
upsert(data: Partial<R>, conflict: string | string[]): Promise<R>;
|
|
120
122
|
count(where?: Partial<R> | SQL | SQL[]): Promise<number>;
|
|
121
|
-
withSql(sql:
|
|
123
|
+
withSql(sql: SqlClient): BoundTable<R>;
|
|
122
124
|
}
|
|
123
125
|
/**
|
|
124
126
|
* Define a type-safe table schema.
|
package/dist/postgres/types.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Context, Middleware } from '../types.ts';
|
|
1
|
+
import type { SqlClient } from '../vendor.ts';
|
|
2
|
+
import type { Context, Middleware, Closeable } from '../types.ts';
|
|
3
3
|
import type { ColumnBuilder, BoundTable, Table } from './schema/index.ts';
|
|
4
4
|
declare module '../types.ts' {
|
|
5
5
|
interface Context {
|
|
6
|
-
sql:
|
|
6
|
+
sql: SqlClient;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
export interface PostgresInjected {
|
|
10
|
-
sql:
|
|
10
|
+
sql: SqlClient;
|
|
11
11
|
}
|
|
12
12
|
export interface PostgresOptions {
|
|
13
13
|
connection?: string | Record<string, unknown>;
|
|
@@ -22,8 +22,8 @@ export interface PostgresOptions {
|
|
|
22
22
|
/** Called after every query completes. Receives query text, duration in ms, and row count. */
|
|
23
23
|
onQuery?: (query: string, durationMs: number, rowCount: number) => void;
|
|
24
24
|
}
|
|
25
|
-
export interface PostgresClient extends Middleware<Context, Context & PostgresInjected
|
|
26
|
-
sql:
|
|
25
|
+
export interface PostgresClient extends Middleware<Context, Context & PostgresInjected>, Closeable {
|
|
26
|
+
sql: SqlClient;
|
|
27
27
|
/** Creates the migration tracking table (_weifuwu_migrations). Called once at startup. */
|
|
28
28
|
migrate: () => Promise<void>;
|
|
29
29
|
/** Record that a module's migration has been applied (idempotent). */
|
package/dist/queue/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Redis } from '../vendor.ts';
|
|
2
|
-
import type { Context, Middleware } from '../types.ts';
|
|
2
|
+
import type { Context, Middleware, Closeable } from '../types.ts';
|
|
3
3
|
declare module '../types.ts' {
|
|
4
4
|
interface Context {
|
|
5
5
|
queue: Queue;
|
|
@@ -22,7 +22,7 @@ export interface QueueOptions {
|
|
|
22
22
|
pollInterval?: number;
|
|
23
23
|
/** PostgreSQL client (required when store: 'pg'). */
|
|
24
24
|
pg?: {
|
|
25
|
-
sql: import('../vendor.ts').
|
|
25
|
+
sql: import('../vendor.ts').SqlClient;
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
export interface QueueInjected {
|
|
@@ -32,7 +32,7 @@ export interface QueueJobWithError<T = unknown> extends QueueJob<T> {
|
|
|
32
32
|
error: string;
|
|
33
33
|
failedAt: number;
|
|
34
34
|
}
|
|
35
|
-
export interface Queue extends Middleware<Context, Context & QueueInjected
|
|
35
|
+
export interface Queue extends Middleware<Context, Context & QueueInjected>, Closeable {
|
|
36
36
|
/** Register a cron job. Uses queue's backend (memory/pg/redis) for execution. */
|
|
37
37
|
cron(pattern: string, handler: () => void | Promise<void>): {
|
|
38
38
|
stop: () => void;
|
package/dist/rate-limit.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export interface RateLimitOptions {
|
|
|
34
34
|
* app.use(rateLimit({ store: 'redis', redis: new Redis(), max: 100 }))
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
export declare function rateLimit(options?: RateLimitOptions): Middleware & {
|
|
37
|
+
export declare function rateLimit(options?: RateLimitOptions): Middleware<Context, Context> & {
|
|
38
38
|
close: () => void;
|
|
39
39
|
stop?: () => void;
|
|
40
40
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -11,4 +11,4 @@ export { useLocale } from './client-locale.ts';
|
|
|
11
11
|
export { useTheme, applyTheme } from './client-theme.ts';
|
|
12
12
|
export { useFlashMessage } from './use-flash-message.ts';
|
|
13
13
|
export { useAgentStream } from './use-agent-stream.ts';
|
|
14
|
-
export type { UseAgentStreamOptions, UseAgentStreamReturn, AgentStreamState } from './use-agent-stream.ts';
|
|
14
|
+
export type { UseAgentStreamOptions, UseAgentStreamReturn, AgentStreamState, } from './use-agent-stream.ts';
|