@puckeditor/cloud-client 0.1.0-canary.ffa73f47 → 0.1.0

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 CHANGED
@@ -1,11 +1,7 @@
1
- import { UIMessage } from 'ai';
2
1
  import z from 'zod/v4';
2
+ import { UIMessage } from 'ai';
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>;
9
5
  type UserTool<INPUT extends z.ZodTypeAny = z.ZodTypeAny, OUTPUT extends z.ZodTypeAny = z.ZodTypeAny> = {
10
6
  name?: string;
11
7
  description: string;
@@ -14,28 +10,27 @@ type UserTool<INPUT extends z.ZodTypeAny = z.ZodTypeAny, OUTPUT extends z.ZodTyp
14
10
  execute: (input: z.infer<INPUT>) => Promise<z.infer<OUTPUT>> | z.infer<OUTPUT>;
15
11
  };
16
12
  declare const tool: <INPUT extends z.ZodTypeAny, OUTPUT extends z.ZodTypeAny>(t: UserTool<INPUT, OUTPUT>) => UserTool<INPUT, OUTPUT>;
17
- type UserToolRegistry = Record<string, UserTool>;
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
+
18
24
  declare const endpoints: readonly ["chat"];
19
25
  type Endpoint = (typeof endpoints)[number];
20
- type PuckCatchAll = [Endpoint | string, ...string[]];
21
- type ApiParams = {
22
- chat: {
26
+ type PuckCloudOptions = {
27
+ ai?: {
23
28
  context?: string;
24
- chatId?: string;
25
- messages: UIMessage[];
26
- config: Config;
27
- pageData: Data;
28
29
  tools?: UserToolRegistry;
29
30
  };
30
- };
31
- declare const createPuckApi: ({ apiKey, host, }?: {
32
31
  host?: string;
33
32
  apiKey?: string;
34
- }) => {
35
- all: <ThisEndpoint extends Endpoint | string>(path: [ThisEndpoint | 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
- };
39
33
  };
34
+ type UserToolRegistry = Record<string, UserTool>;
40
35
 
41
- export { type ApiParams, type Endpoint, type PuckCatchAll, createPuckApi, streamingFetch, tool };
36
+ export { type ChatParams, type Endpoint, type PuckCloudOptions, type UserTool, type UserToolRegistry, chat, endpoints, puckHandler, tool };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,7 @@
1
- import { UIMessage } from 'ai';
2
1
  import z from 'zod/v4';
2
+ import { UIMessage } from 'ai';
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>;
9
5
  type UserTool<INPUT extends z.ZodTypeAny = z.ZodTypeAny, OUTPUT extends z.ZodTypeAny = z.ZodTypeAny> = {
10
6
  name?: string;
11
7
  description: string;
@@ -14,28 +10,27 @@ type UserTool<INPUT extends z.ZodTypeAny = z.ZodTypeAny, OUTPUT extends z.ZodTyp
14
10
  execute: (input: z.infer<INPUT>) => Promise<z.infer<OUTPUT>> | z.infer<OUTPUT>;
15
11
  };
16
12
  declare const tool: <INPUT extends z.ZodTypeAny, OUTPUT extends z.ZodTypeAny>(t: UserTool<INPUT, OUTPUT>) => UserTool<INPUT, OUTPUT>;
17
- type UserToolRegistry = Record<string, UserTool>;
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
+
18
24
  declare const endpoints: readonly ["chat"];
19
25
  type Endpoint = (typeof endpoints)[number];
20
- type PuckCatchAll = [Endpoint | string, ...string[]];
21
- type ApiParams = {
22
- chat: {
26
+ type PuckCloudOptions = {
27
+ ai?: {
23
28
  context?: string;
24
- chatId?: string;
25
- messages: UIMessage[];
26
- config: Config;
27
- pageData: Data;
28
29
  tools?: UserToolRegistry;
29
30
  };
30
- };
31
- declare const createPuckApi: ({ apiKey, host, }?: {
32
31
  host?: string;
33
32
  apiKey?: string;
34
- }) => {
35
- all: <ThisEndpoint extends Endpoint | string>(path: [ThisEndpoint | 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
- };
39
33
  };
34
+ type UserToolRegistry = Record<string, UserTool>;
40
35
 
41
- export { type ApiParams, type Endpoint, type PuckCatchAll, createPuckApi, streamingFetch, tool };
36
+ export { type ChatParams, type Endpoint, type PuckCloudOptions, type UserTool, type UserToolRegistry, chat, endpoints, puckHandler, tool };