weifuwu 0.18.3 → 0.18.4
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/cli.ts +10 -101
- package/dist/cli.js +7 -95
- package/dist/dist/agent/client.d.ts +2 -0
- package/dist/dist/agent/index.d.ts +2 -0
- package/dist/dist/agent/migrate.d.ts +6 -0
- package/dist/dist/agent/rest.d.ts +13 -0
- package/dist/dist/agent/run.d.ts +17 -0
- package/dist/dist/agent/types.d.ts +51 -0
- package/dist/dist/ai/workflow.d.ts +14 -0
- package/dist/dist/analytics.d.ts +15 -0
- package/dist/dist/client-locale.d.ts +5 -0
- package/dist/dist/client-pref.d.ts +3 -0
- package/dist/dist/client-state.d.ts +22 -0
- package/dist/dist/client-theme.d.ts +7 -0
- package/dist/dist/compress.d.ts +6 -0
- package/dist/dist/cookie.d.ts +12 -0
- package/dist/dist/deploy/config.d.ts +2 -0
- package/dist/dist/deploy/gateway.d.ts +2 -0
- package/dist/dist/deploy/index.d.ts +4 -0
- package/dist/dist/deploy/manager.d.ts +16 -0
- package/dist/dist/deploy/process.d.ts +14 -0
- package/dist/dist/deploy/types.d.ts +62 -0
- package/dist/dist/head.d.ts +6 -0
- package/dist/dist/helmet.d.ts +18 -0
- package/dist/dist/iii/client.d.ts +2 -0
- package/dist/dist/iii/index.d.ts +4 -0
- package/dist/dist/iii/register-worker.d.ts +10 -0
- package/dist/dist/iii/rest.d.ts +3 -0
- package/dist/dist/iii/stream.d.ts +82 -0
- package/dist/dist/iii/types.d.ts +133 -0
- package/dist/dist/iii/worker.d.ts +2 -0
- package/dist/dist/iii/ws.d.ts +29 -0
- package/dist/dist/index.js +8180 -0
- package/dist/dist/messager/agent.d.ts +6 -0
- package/dist/dist/messager/client.d.ts +2 -0
- package/dist/dist/messager/index.d.ts +2 -0
- package/dist/dist/messager/migrate.d.ts +2 -0
- package/dist/dist/messager/rest.d.ts +15 -0
- package/dist/dist/messager/types.d.ts +56 -0
- package/dist/dist/messager/ws.d.ts +14 -0
- package/dist/dist/preferences.d.ts +14 -0
- package/dist/dist/react.d.ts +12 -0
- package/dist/dist/react.js +637 -0
- package/dist/dist/request-id.d.ts +6 -0
- package/dist/dist/seo.d.ts +39 -0
- package/dist/dist/ssr/compile.d.ts +2 -0
- package/dist/dist/tenant/client.d.ts +2 -0
- package/dist/dist/tenant/graphql.d.ts +3 -0
- package/dist/dist/tenant/index.d.ts +2 -0
- package/dist/dist/tenant/migrate.d.ts +6 -0
- package/dist/dist/tenant/rest.d.ts +3 -0
- package/dist/dist/tenant/schema.d.ts +5 -0
- package/dist/dist/tenant/types.d.ts +48 -0
- package/dist/dist/tenant/utils.d.ts +10 -0
- package/dist/dist/types.d.ts +19 -0
- package/dist/dist/use-flash-message.d.ts +1 -0
- package/dist/error-boundary.d.ts +2 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +185 -34
- package/dist/layout.d.ts +2 -0
- package/dist/live.d.ts +6 -0
- package/dist/not-found.d.ts +2 -0
- package/dist/ssr.d.ts +2 -0
- package/dist/stream.d.ts +14 -0
- package/dist/tailwind.d.ts +2 -0
- package/package.json +3 -4
- /package/dist/{ssr/compile.d.ts → compile.d.ts} +0 -0
- /package/dist/{ssr → dist/ssr}/error-boundary.d.ts +0 -0
- /package/dist/{ssr → dist/ssr}/index.d.ts +0 -0
- /package/dist/{ssr → dist/ssr}/index.js +0 -0
- /package/dist/{ssr → dist/ssr}/layout.d.ts +0 -0
- /package/dist/{ssr → dist/ssr}/live.d.ts +0 -0
- /package/dist/{ssr → dist/ssr}/not-found.d.ts +0 -0
- /package/dist/{ssr → dist/ssr}/ssr.d.ts +0 -0
- /package/dist/{ssr → dist/ssr}/stream.d.ts +0 -0
- /package/dist/{ssr → dist/ssr}/tailwind.d.ts +0 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Redis } from '../vendor.ts';
|
|
2
|
+
import type { PostgresClient } from '../postgres/types.ts';
|
|
3
|
+
import type { StreamUpdateOp, StreamSubscription } from './types.ts';
|
|
4
|
+
export declare function createStream(opts?: {
|
|
5
|
+
pg?: PostgresClient;
|
|
6
|
+
redis?: Redis;
|
|
7
|
+
streamTTL?: number;
|
|
8
|
+
}): {
|
|
9
|
+
subscribe(ws: WebSocket, sub: StreamSubscription): void;
|
|
10
|
+
unsubscribe(ws: WebSocket): void;
|
|
11
|
+
migrate(): Promise<void>;
|
|
12
|
+
close(): Promise<void>;
|
|
13
|
+
set(stream: string, group: string, item: string, data: unknown): Promise<{
|
|
14
|
+
old_value: null;
|
|
15
|
+
new_value: unknown;
|
|
16
|
+
}>;
|
|
17
|
+
get(stream: string, group: string, item: string): Promise<{
|
|
18
|
+
value: any;
|
|
19
|
+
}>;
|
|
20
|
+
delete(stream: string, group: string, item: string): Promise<{
|
|
21
|
+
old_value: any;
|
|
22
|
+
}>;
|
|
23
|
+
list(stream: string, group: string): Promise<{
|
|
24
|
+
items: {
|
|
25
|
+
item_id: any;
|
|
26
|
+
data: any;
|
|
27
|
+
}[];
|
|
28
|
+
}>;
|
|
29
|
+
list_groups(stream: string): Promise<{
|
|
30
|
+
groups: any[];
|
|
31
|
+
}>;
|
|
32
|
+
list_all(): Promise<{
|
|
33
|
+
streams: {
|
|
34
|
+
stream_name: any;
|
|
35
|
+
group_count: number;
|
|
36
|
+
item_count: number;
|
|
37
|
+
}[];
|
|
38
|
+
count: number;
|
|
39
|
+
}>;
|
|
40
|
+
send(stream: string, group: string, type: string, data: unknown, id?: string): Promise<void>;
|
|
41
|
+
update(stream: string, group: string, item: string, ops: StreamUpdateOp[]): Promise<{
|
|
42
|
+
old_value: any;
|
|
43
|
+
new_value: any;
|
|
44
|
+
}>;
|
|
45
|
+
} | {
|
|
46
|
+
subscribe(ws: WebSocket, sub: StreamSubscription): void;
|
|
47
|
+
unsubscribe(ws: WebSocket): void;
|
|
48
|
+
migrate(): Promise<void>;
|
|
49
|
+
close(): Promise<void>;
|
|
50
|
+
set(stream: string, group: string, item: string, data: unknown): Promise<{
|
|
51
|
+
old_value: unknown;
|
|
52
|
+
new_value: unknown;
|
|
53
|
+
}>;
|
|
54
|
+
get(stream: string, group: string, item: string): Promise<{
|
|
55
|
+
value: any;
|
|
56
|
+
}>;
|
|
57
|
+
delete(stream: string, group: string, item: string): Promise<{
|
|
58
|
+
old_value: any;
|
|
59
|
+
}>;
|
|
60
|
+
list(stream: string, group: string): Promise<{
|
|
61
|
+
items: {
|
|
62
|
+
item_id: string;
|
|
63
|
+
data: any;
|
|
64
|
+
}[];
|
|
65
|
+
}>;
|
|
66
|
+
list_groups(stream: string): Promise<{
|
|
67
|
+
groups: string[];
|
|
68
|
+
}>;
|
|
69
|
+
list_all(): Promise<{
|
|
70
|
+
streams: {
|
|
71
|
+
stream_name: string;
|
|
72
|
+
group_count: number;
|
|
73
|
+
item_count: number;
|
|
74
|
+
}[];
|
|
75
|
+
count: number;
|
|
76
|
+
}>;
|
|
77
|
+
send(stream: string, group: string, type: string, data: unknown, id?: string): Promise<void>;
|
|
78
|
+
update(stream: string, group: string, item: string, ops: StreamUpdateOp[]): Promise<{
|
|
79
|
+
old_value: any;
|
|
80
|
+
new_value: any;
|
|
81
|
+
}>;
|
|
82
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { Router } from '../router.ts';
|
|
2
|
+
import type { Redis } from '../vendor.ts';
|
|
3
|
+
import type { PostgresClient } from '../postgres/types.ts';
|
|
4
|
+
export type FunctionHandler = (payload: unknown, ctx: FunctionContext) => unknown | Promise<unknown>;
|
|
5
|
+
export interface FunctionContext {
|
|
6
|
+
engine: IIIModule;
|
|
7
|
+
functionId: string;
|
|
8
|
+
workerName: string;
|
|
9
|
+
triggerId?: string;
|
|
10
|
+
user?: unknown;
|
|
11
|
+
}
|
|
12
|
+
export interface TriggerInput {
|
|
13
|
+
type: string;
|
|
14
|
+
function_id: string;
|
|
15
|
+
config: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
export interface IIIOptions {
|
|
18
|
+
pg?: PostgresClient;
|
|
19
|
+
redis?: Redis;
|
|
20
|
+
/** TTL in seconds for Redis stream keys. Default: 3600 (1 hour). Set to 0 for no expiration. */
|
|
21
|
+
streamTTL?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface TriggerRequest {
|
|
24
|
+
function_id: string;
|
|
25
|
+
payload: unknown;
|
|
26
|
+
action?: 'sync' | 'void';
|
|
27
|
+
timeout_ms?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface TriggerOptions {
|
|
30
|
+
action?: 'sync' | 'void';
|
|
31
|
+
timeout_ms?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface IIIModule extends Router {
|
|
34
|
+
wsHandler: () => any;
|
|
35
|
+
addWorker: (worker: Worker) => void;
|
|
36
|
+
trigger: (request: TriggerRequest) => Promise<unknown>;
|
|
37
|
+
removeWorker: (worker: Worker) => void;
|
|
38
|
+
listWorkers: () => WorkerInfo[];
|
|
39
|
+
listFunctions: () => FunctionInfo[];
|
|
40
|
+
listTriggers: () => TriggerInfo[];
|
|
41
|
+
migrate: () => Promise<void>;
|
|
42
|
+
shutdown: () => Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
export interface WorkerInfo {
|
|
45
|
+
id: string;
|
|
46
|
+
name: string;
|
|
47
|
+
status: 'connected' | 'disconnected';
|
|
48
|
+
connectedAt: number;
|
|
49
|
+
functionCount: number;
|
|
50
|
+
triggerCount: number;
|
|
51
|
+
}
|
|
52
|
+
export interface FunctionInfo {
|
|
53
|
+
id: string;
|
|
54
|
+
workerId: string;
|
|
55
|
+
workerName: string;
|
|
56
|
+
triggers: string[];
|
|
57
|
+
}
|
|
58
|
+
export interface TriggerInfo {
|
|
59
|
+
id: string;
|
|
60
|
+
type: string;
|
|
61
|
+
function_id: string;
|
|
62
|
+
config: Record<string, unknown>;
|
|
63
|
+
workerId: string;
|
|
64
|
+
}
|
|
65
|
+
export interface Worker {
|
|
66
|
+
readonly name: string;
|
|
67
|
+
registerFunction: (id: string, handler: FunctionHandler, opts?: {
|
|
68
|
+
description?: string;
|
|
69
|
+
}) => Worker;
|
|
70
|
+
unregisterFunction: (id: string) => Worker;
|
|
71
|
+
registerTrigger: (input: TriggerInput) => Worker;
|
|
72
|
+
unregisterTrigger: (functionId: string) => Worker;
|
|
73
|
+
getFunctions: () => {
|
|
74
|
+
id: string;
|
|
75
|
+
handler: FunctionHandler;
|
|
76
|
+
}[];
|
|
77
|
+
getTriggers: () => {
|
|
78
|
+
id: string;
|
|
79
|
+
input: TriggerInput;
|
|
80
|
+
}[];
|
|
81
|
+
}
|
|
82
|
+
export interface RemoteWorker {
|
|
83
|
+
registerFunction: (id: string, handler: FunctionHandler) => void;
|
|
84
|
+
unregisterFunction: (id: string) => void;
|
|
85
|
+
registerTrigger: (input: TriggerInput) => void;
|
|
86
|
+
unregisterTrigger: (functionId: string) => void;
|
|
87
|
+
trigger: (request: TriggerRequest) => Promise<unknown>;
|
|
88
|
+
shutdown: () => void;
|
|
89
|
+
}
|
|
90
|
+
export interface FunctionRegistration {
|
|
91
|
+
id: string;
|
|
92
|
+
handler: FunctionHandler;
|
|
93
|
+
workerId: string;
|
|
94
|
+
workerName: string;
|
|
95
|
+
triggers: string[];
|
|
96
|
+
}
|
|
97
|
+
export interface TriggerRegistration {
|
|
98
|
+
id: string;
|
|
99
|
+
type: string;
|
|
100
|
+
function_id: string;
|
|
101
|
+
config: Record<string, unknown>;
|
|
102
|
+
workerId: string;
|
|
103
|
+
}
|
|
104
|
+
export interface WorkerRegistration {
|
|
105
|
+
id: string;
|
|
106
|
+
name: string;
|
|
107
|
+
ws?: WebSocket;
|
|
108
|
+
functions: FunctionRegistration[];
|
|
109
|
+
triggers: TriggerRegistration[];
|
|
110
|
+
}
|
|
111
|
+
export type StreamUpdateOp = {
|
|
112
|
+
op: 'set';
|
|
113
|
+
value: unknown;
|
|
114
|
+
} | {
|
|
115
|
+
op: 'merge';
|
|
116
|
+
value: Record<string, unknown>;
|
|
117
|
+
} | {
|
|
118
|
+
op: 'increment';
|
|
119
|
+
value: number;
|
|
120
|
+
} | {
|
|
121
|
+
op: 'decrement';
|
|
122
|
+
value: number;
|
|
123
|
+
} | {
|
|
124
|
+
op: 'append';
|
|
125
|
+
value: unknown;
|
|
126
|
+
} | {
|
|
127
|
+
op: 'remove';
|
|
128
|
+
};
|
|
129
|
+
export interface StreamSubscription {
|
|
130
|
+
stream_name: string;
|
|
131
|
+
group_id?: string;
|
|
132
|
+
item_id?: string;
|
|
133
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Context } from '../types.ts';
|
|
2
|
+
interface WsHandlerDeps {
|
|
3
|
+
registerRemoteWorker: (ws: WebSocket, name: string) => string;
|
|
4
|
+
unregisterRemoteWorker: (workerId: string) => void;
|
|
5
|
+
registerRemoteFunction: (workerId: string, id: string) => void;
|
|
6
|
+
unregisterRemoteFunction: (workerId: string, id: string) => void;
|
|
7
|
+
registerRemoteTrigger: (workerId: string, input: {
|
|
8
|
+
type: string;
|
|
9
|
+
function_id: string;
|
|
10
|
+
config: Record<string, unknown>;
|
|
11
|
+
}) => void;
|
|
12
|
+
unregisterRemoteTrigger: (workerId: string, functionId: string) => void;
|
|
13
|
+
addStreamSubscriber: (ws: WebSocket, sub: {
|
|
14
|
+
stream_name: string;
|
|
15
|
+
group_id?: string;
|
|
16
|
+
item_id?: string;
|
|
17
|
+
}) => void;
|
|
18
|
+
removeStreamSubscriber: (ws: WebSocket) => void;
|
|
19
|
+
handleInvokeResult: (invocationId: string, result: unknown) => void;
|
|
20
|
+
handleInvokeError: (invocationId: string, error: string) => void;
|
|
21
|
+
handleInvoke: (ws: WebSocket, invocationId: string, functionId: string, payload: unknown) => void;
|
|
22
|
+
}
|
|
23
|
+
export declare function createWsHandler(deps: WsHandlerDeps): {
|
|
24
|
+
open(_ws: WebSocket, _ctx: Context): void;
|
|
25
|
+
message(ws: WebSocket, ctx: Context, data: string | Buffer): Promise<void>;
|
|
26
|
+
close(ws: WebSocket): void;
|
|
27
|
+
error(ws: WebSocket): void;
|
|
28
|
+
};
|
|
29
|
+
export {};
|