@wecode-team/cms-supabase-api 0.1.55 → 0.2.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/dist/handlers/ai-agent.d.ts +32 -0
- package/dist/handlers/ai-import.d.ts +12 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.esm.js +3218 -1553
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3221 -1552
- package/dist/index.js.map +1 -1
- package/dist/services/ai-agent/config.d.ts +4 -0
- package/dist/services/ai-agent/index.d.ts +4 -0
- package/dist/services/ai-agent/prompt.d.ts +2 -0
- package/dist/services/ai-agent/service.d.ts +11 -0
- package/dist/services/ai-agent/tool/context.d.ts +19 -0
- package/dist/services/ai-agent/tool/create-data.d.ts +3 -0
- package/dist/services/ai-agent/tool/index.d.ts +6 -0
- package/dist/services/ai-agent/tool/read-data.d.ts +3 -0
- package/dist/services/ai-agent/tool/update-data.d.ts +3 -0
- package/dist/services/ai-agent/tools.d.ts +3 -0
- package/dist/services/ai-agent/types.d.ts +54 -0
- package/dist/services/ai-agent/utils.d.ts +1 -0
- package/dist/services/ai-agent.service.d.ts +1 -0
- package/dist/services/ai-import.service.d.ts +29 -0
- package/dist/utils/route-helpers.d.ts +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AiAgentRequest, AiAgentResult, AiAgentStreamEmit } from "./types";
|
|
2
|
+
export declare class AiAgentService {
|
|
3
|
+
readData(_tableName: string, _args: Record<string, any>): Promise<{
|
|
4
|
+
data: never[];
|
|
5
|
+
}>;
|
|
6
|
+
createData(_tableName: string, _args: Record<string, any>): Promise<{
|
|
7
|
+
data: null;
|
|
8
|
+
}>;
|
|
9
|
+
ask(tableName: string, request: AiAgentRequest): Promise<AiAgentResult>;
|
|
10
|
+
streamAsk(tableName: string, request: AiAgentRequest, emit: AiAgentStreamEmit, signal?: AbortSignal): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CmsModelAttributes, SchemaField, SupabaseFilter } from "../../../types";
|
|
2
|
+
export declare const SYSTEM_FIELDS: Set<string>;
|
|
3
|
+
export declare const ALLOWED_FILTER_OPERATORS: SupabaseFilter["operator"][];
|
|
4
|
+
export declare function isRecord(value: unknown): value is Record<string, any>;
|
|
5
|
+
export declare function getWritableFields(model?: Partial<CmsModelAttributes>): SchemaField[];
|
|
6
|
+
export declare function getFieldStorageName(field: SchemaField): string;
|
|
7
|
+
export declare function buildCreateDataProperties(model?: Partial<CmsModelAttributes>): {
|
|
8
|
+
properties: Record<string, any>;
|
|
9
|
+
required: string[];
|
|
10
|
+
};
|
|
11
|
+
export declare function buildUpdateDataProperties(model?: Partial<CmsModelAttributes>): {
|
|
12
|
+
properties: Record<string, any>;
|
|
13
|
+
required: string[];
|
|
14
|
+
};
|
|
15
|
+
export declare function getReadableFieldNames(model?: Partial<CmsModelAttributes>): string[];
|
|
16
|
+
export declare function normalizeCreateData(rawData: Record<string, any>, model?: Partial<CmsModelAttributes>): Record<string, any>;
|
|
17
|
+
export declare function normalizeUpdateData(rawData: Record<string, any>, model?: Partial<CmsModelAttributes>): Record<string, any>;
|
|
18
|
+
export declare function normalizeReadFilters(filters: unknown, model?: Partial<CmsModelAttributes>): SupabaseFilter[] | undefined;
|
|
19
|
+
export declare function resolveModel(tableName: string, requestModel?: Partial<CmsModelAttributes>): Promise<Partial<CmsModelAttributes> | undefined>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import type { CmsModelAttributes } from "../../../types";
|
|
3
|
+
export { createCreateDataTool } from "./create-data";
|
|
4
|
+
export { createReadDataTool } from "./read-data";
|
|
5
|
+
export { createUpdateDataTool } from "./update-data";
|
|
6
|
+
export declare function createAiAgentTools(tableName: string, requestModel?: Partial<CmsModelAttributes>): AgentTool[];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Message } from "@earendil-works/pi-ai";
|
|
2
|
+
import type { CmsModelAttributes } from "../../types";
|
|
3
|
+
export type AiAgentToolName = "read_data" | "create_data" | "update_data";
|
|
4
|
+
export type AiAgentMessage = Message;
|
|
5
|
+
export interface AiAgentRequest {
|
|
6
|
+
input?: string;
|
|
7
|
+
model?: Partial<CmsModelAttributes>;
|
|
8
|
+
messages?: AiAgentMessage[];
|
|
9
|
+
}
|
|
10
|
+
export interface AiAgentResult {
|
|
11
|
+
tableName: string;
|
|
12
|
+
input: string;
|
|
13
|
+
reply: string;
|
|
14
|
+
tools: Array<{
|
|
15
|
+
name: AiAgentToolName;
|
|
16
|
+
description: string;
|
|
17
|
+
parameters: Record<string, any>;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
export type AiAgentStreamEvent = {
|
|
21
|
+
type: "start";
|
|
22
|
+
tableName: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: "agent_message";
|
|
25
|
+
message: AiAgentMessage;
|
|
26
|
+
} | {
|
|
27
|
+
type: "message_delta";
|
|
28
|
+
delta: string;
|
|
29
|
+
} | {
|
|
30
|
+
type: "message_done";
|
|
31
|
+
reply: string;
|
|
32
|
+
} | {
|
|
33
|
+
type: "tool_start";
|
|
34
|
+
toolCallId: string;
|
|
35
|
+
toolName: string;
|
|
36
|
+
args: any;
|
|
37
|
+
} | {
|
|
38
|
+
type: "tool_update";
|
|
39
|
+
toolCallId: string;
|
|
40
|
+
toolName: string;
|
|
41
|
+
partialResult: any;
|
|
42
|
+
} | {
|
|
43
|
+
type: "tool_done";
|
|
44
|
+
toolCallId: string;
|
|
45
|
+
toolName: string;
|
|
46
|
+
result: any;
|
|
47
|
+
isError: boolean;
|
|
48
|
+
} | {
|
|
49
|
+
type: "error";
|
|
50
|
+
message: string;
|
|
51
|
+
} | {
|
|
52
|
+
type: "done";
|
|
53
|
+
};
|
|
54
|
+
export type AiAgentStreamEmit = (event: AiAgentStreamEvent) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getEventErrorMessage(error: unknown): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ai-agent";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CmsModelAttributes } from "../types";
|
|
2
|
+
export type AiImportToolName = "read_data" | "create_data";
|
|
3
|
+
export interface AiImportToolDefinition {
|
|
4
|
+
name: AiImportToolName;
|
|
5
|
+
description: string;
|
|
6
|
+
parameters: Record<string, any>;
|
|
7
|
+
}
|
|
8
|
+
export interface AiImportRequest {
|
|
9
|
+
input?: string;
|
|
10
|
+
model?: Partial<CmsModelAttributes>;
|
|
11
|
+
}
|
|
12
|
+
export interface AiImportResult {
|
|
13
|
+
tableName: string;
|
|
14
|
+
input: string;
|
|
15
|
+
tools: AiImportToolDefinition[];
|
|
16
|
+
records: Record<string, any>[];
|
|
17
|
+
message: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class AiImportService {
|
|
20
|
+
getToolDefinitions(): AiImportToolDefinition[];
|
|
21
|
+
readData(_tableName: string, _args: Record<string, any>): Promise<{
|
|
22
|
+
data: never[];
|
|
23
|
+
}>;
|
|
24
|
+
createData(_tableName: string, _args: Record<string, any>): Promise<{
|
|
25
|
+
data: null;
|
|
26
|
+
}>;
|
|
27
|
+
importData(tableName: string, request: AiImportRequest): Promise<AiImportResult>;
|
|
28
|
+
}
|
|
29
|
+
export declare function getAiImportService(): AiImportService;
|
|
@@ -9,4 +9,5 @@ export declare function createDynamicAuthRoute(app: Hono): Hono<import("hono/typ
|
|
|
9
9
|
export declare function createAuthRoute(app: Hono, tableName: string): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
10
10
|
export declare function createOssUploadRoute(app: Hono, options?: CmsRouteOptions): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
11
11
|
export declare function createConfigRoute(app: Hono, options?: CmsRouteOptions): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
12
|
+
export declare function createAiAgentRoute(app: Hono, options?: CmsRouteOptions): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
12
13
|
export declare function createCmsRoutes(app: Hono, options?: CmsRouteOptions): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wecode-team/cms-supabase-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "A CMS API package using Hono framework with Supabase and dynamic table management",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -51,6 +51,8 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@babel/runtime": "^7.22.5",
|
|
54
|
+
"@earendil-works/pi-agent-core": "^0.79.4",
|
|
55
|
+
"@earendil-works/pi-ai": "^0.79.4",
|
|
54
56
|
"@wecode-team/email-verify": "^0.0.2",
|
|
55
57
|
"@wecode-team/oss": "^0.0.1",
|
|
56
58
|
"bcryptjs": "^2.4.3",
|