@puckeditor/cloud-client 0.1.0-canary.f87c29b6 → 0.1.0-canary.ff784f5d
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/index.d.mts +21 -16
- package/dist/index.d.ts +21 -16
- package/dist/index.js +2417 -2339
- package/dist/index.mjs +2435 -2355
- package/package.json +3 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import z from 'zod/v4';
|
|
2
1
|
import { UIMessage } from 'ai';
|
|
2
|
+
import z from 'zod/v4';
|
|
3
3
|
import { Config, Data } from '@measured/puck';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Generator function that streams the response body from a fetch request.
|
|
7
|
+
*/
|
|
8
|
+
declare function streamingFetch(input: RequestInfo | URL, init?: RequestInit): AsyncGenerator<string, void, unknown>;
|
|
5
9
|
type UserTool<INPUT extends z.ZodTypeAny = z.ZodTypeAny, OUTPUT extends z.ZodTypeAny = z.ZodTypeAny> = {
|
|
6
10
|
name?: string;
|
|
7
11
|
description: string;
|
|
@@ -10,27 +14,28 @@ type UserTool<INPUT extends z.ZodTypeAny = z.ZodTypeAny, OUTPUT extends z.ZodTyp
|
|
|
10
14
|
execute: (input: z.infer<INPUT>) => Promise<z.infer<OUTPUT>> | z.infer<OUTPUT>;
|
|
11
15
|
};
|
|
12
16
|
declare const tool: <INPUT extends z.ZodTypeAny, OUTPUT extends z.ZodTypeAny>(t: UserTool<INPUT, OUTPUT>) => UserTool<INPUT, OUTPUT>;
|
|
13
|
-
|
|
14
|
-
type ChatParams = {
|
|
15
|
-
chatId?: string;
|
|
16
|
-
messages: UIMessage[];
|
|
17
|
-
config: Config;
|
|
18
|
-
pageData: Data;
|
|
19
|
-
};
|
|
20
|
-
declare function chat({ chatId, messages: initialMessages, config, pageData }: ChatParams, { ai, apiKey, host, }: PuckCloudOptions): Response;
|
|
21
|
-
|
|
22
|
-
declare function puckHandler(request: Request, options: PuckCloudOptions): Promise<Response>;
|
|
23
|
-
|
|
17
|
+
type UserToolRegistry = Record<string, UserTool>;
|
|
24
18
|
declare const endpoints: readonly ["chat"];
|
|
25
19
|
type Endpoint = (typeof endpoints)[number];
|
|
26
|
-
type
|
|
27
|
-
|
|
20
|
+
type PuckCatchAll = [Endpoint | string, ...string[]];
|
|
21
|
+
type ApiParams = {
|
|
22
|
+
chat: {
|
|
28
23
|
context?: string;
|
|
24
|
+
chatId?: string;
|
|
25
|
+
messages: UIMessage[];
|
|
26
|
+
config: Config;
|
|
27
|
+
pageData: Data;
|
|
29
28
|
tools?: UserToolRegistry;
|
|
30
29
|
};
|
|
30
|
+
};
|
|
31
|
+
declare const createPuckApi: ({ apiKey, host, }?: {
|
|
31
32
|
host?: string;
|
|
32
33
|
apiKey?: string;
|
|
34
|
+
}) => {
|
|
35
|
+
all: <ThisEndpoint extends Endpoint | string>(path: [ThisEndpoint | string, ...string[]] | string[] | string, body: ThisEndpoint extends Endpoint ? ApiParams[ThisEndpoint] : any) => Promise<Response>;
|
|
36
|
+
ai: {
|
|
37
|
+
chat: ({ chatId, context, messages: initialMessages, config, pageData, tools, }: ApiParams["chat"]) => Promise<Response>;
|
|
38
|
+
};
|
|
33
39
|
};
|
|
34
|
-
type UserToolRegistry = Record<string, UserTool>;
|
|
35
40
|
|
|
36
|
-
export { type
|
|
41
|
+
export { type ApiParams, type Endpoint, type PuckCatchAll, createPuckApi, createPuckApi as default, streamingFetch, tool };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import z from 'zod/v4';
|
|
2
1
|
import { UIMessage } from 'ai';
|
|
2
|
+
import z from 'zod/v4';
|
|
3
3
|
import { Config, Data } from '@measured/puck';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Generator function that streams the response body from a fetch request.
|
|
7
|
+
*/
|
|
8
|
+
declare function streamingFetch(input: RequestInfo | URL, init?: RequestInit): AsyncGenerator<string, void, unknown>;
|
|
5
9
|
type UserTool<INPUT extends z.ZodTypeAny = z.ZodTypeAny, OUTPUT extends z.ZodTypeAny = z.ZodTypeAny> = {
|
|
6
10
|
name?: string;
|
|
7
11
|
description: string;
|
|
@@ -10,27 +14,28 @@ type UserTool<INPUT extends z.ZodTypeAny = z.ZodTypeAny, OUTPUT extends z.ZodTyp
|
|
|
10
14
|
execute: (input: z.infer<INPUT>) => Promise<z.infer<OUTPUT>> | z.infer<OUTPUT>;
|
|
11
15
|
};
|
|
12
16
|
declare const tool: <INPUT extends z.ZodTypeAny, OUTPUT extends z.ZodTypeAny>(t: UserTool<INPUT, OUTPUT>) => UserTool<INPUT, OUTPUT>;
|
|
13
|
-
|
|
14
|
-
type ChatParams = {
|
|
15
|
-
chatId?: string;
|
|
16
|
-
messages: UIMessage[];
|
|
17
|
-
config: Config;
|
|
18
|
-
pageData: Data;
|
|
19
|
-
};
|
|
20
|
-
declare function chat({ chatId, messages: initialMessages, config, pageData }: ChatParams, { ai, apiKey, host, }: PuckCloudOptions): Response;
|
|
21
|
-
|
|
22
|
-
declare function puckHandler(request: Request, options: PuckCloudOptions): Promise<Response>;
|
|
23
|
-
|
|
17
|
+
type UserToolRegistry = Record<string, UserTool>;
|
|
24
18
|
declare const endpoints: readonly ["chat"];
|
|
25
19
|
type Endpoint = (typeof endpoints)[number];
|
|
26
|
-
type
|
|
27
|
-
|
|
20
|
+
type PuckCatchAll = [Endpoint | string, ...string[]];
|
|
21
|
+
type ApiParams = {
|
|
22
|
+
chat: {
|
|
28
23
|
context?: string;
|
|
24
|
+
chatId?: string;
|
|
25
|
+
messages: UIMessage[];
|
|
26
|
+
config: Config;
|
|
27
|
+
pageData: Data;
|
|
29
28
|
tools?: UserToolRegistry;
|
|
30
29
|
};
|
|
30
|
+
};
|
|
31
|
+
declare const createPuckApi: ({ apiKey, host, }?: {
|
|
31
32
|
host?: string;
|
|
32
33
|
apiKey?: string;
|
|
34
|
+
}) => {
|
|
35
|
+
all: <ThisEndpoint extends Endpoint | string>(path: [ThisEndpoint | string, ...string[]] | string[] | string, body: ThisEndpoint extends Endpoint ? ApiParams[ThisEndpoint] : any) => Promise<Response>;
|
|
36
|
+
ai: {
|
|
37
|
+
chat: ({ chatId, context, messages: initialMessages, config, pageData, tools, }: ApiParams["chat"]) => Promise<Response>;
|
|
38
|
+
};
|
|
33
39
|
};
|
|
34
|
-
type UserToolRegistry = Record<string, UserTool>;
|
|
35
40
|
|
|
36
|
-
export { type
|
|
41
|
+
export { type ApiParams, type Endpoint, type PuckCatchAll, createPuckApi, createPuckApi as default, streamingFetch, tool };
|