@puckeditor/plugin-ai 0.1.0-canary.dfd624ec → 0.1.0-canary.e666268d

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,115 +1,22 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { UIMessage, ChatStatus } from 'ai';
3
+ import { PuckProviderMetadata, PuckDataParts } from '@puckeditor/platform-types';
4
+ import { ReactNode, RefObject } from 'react';
2
5
 
3
- type _JSONSchema = boolean | JSONSchema;
4
- type JSONSchema = {
5
- [k: string]: unknown;
6
- $schema?: "https://json-schema.org/draft/2020-12/schema" | "http://json-schema.org/draft-07/schema#" | "http://json-schema.org/draft-04/schema#";
7
- $id?: string;
8
- $anchor?: string;
9
- $ref?: string;
10
- $dynamicRef?: string;
11
- $dynamicAnchor?: string;
12
- $vocabulary?: Record<string, boolean>;
13
- $comment?: string;
14
- $defs?: Record<string, JSONSchema>;
15
- type?: "object" | "array" | "string" | "number" | "boolean" | "null" | "integer";
16
- additionalItems?: _JSONSchema;
17
- unevaluatedItems?: _JSONSchema;
18
- prefixItems?: _JSONSchema[];
19
- items?: _JSONSchema | _JSONSchema[];
20
- contains?: _JSONSchema;
21
- additionalProperties?: _JSONSchema;
22
- unevaluatedProperties?: _JSONSchema;
23
- properties?: Record<string, _JSONSchema>;
24
- patternProperties?: Record<string, _JSONSchema>;
25
- dependentSchemas?: Record<string, _JSONSchema>;
26
- propertyNames?: _JSONSchema;
27
- if?: _JSONSchema;
28
- then?: _JSONSchema;
29
- else?: _JSONSchema;
30
- allOf?: JSONSchema[];
31
- anyOf?: JSONSchema[];
32
- oneOf?: JSONSchema[];
33
- not?: _JSONSchema;
34
- multipleOf?: number;
35
- maximum?: number;
36
- exclusiveMaximum?: number | boolean;
37
- minimum?: number;
38
- exclusiveMinimum?: number | boolean;
39
- maxLength?: number;
40
- minLength?: number;
41
- pattern?: string;
42
- maxItems?: number;
43
- minItems?: number;
44
- uniqueItems?: boolean;
45
- maxContains?: number;
46
- minContains?: number;
47
- maxProperties?: number;
48
- minProperties?: number;
49
- required?: string[];
50
- dependentRequired?: Record<string, string[]>;
51
- enum?: Array<string | number | boolean | null>;
52
- const?: string | number | boolean | null;
53
- id?: string;
54
- title?: string;
55
- description?: string;
56
- default?: unknown;
57
- deprecated?: boolean;
58
- readOnly?: boolean;
59
- writeOnly?: boolean;
60
- nullable?: boolean;
61
- examples?: unknown[];
62
- format?: string;
63
- contentMediaType?: string;
64
- contentEncoding?: string;
65
- contentSchema?: JSONSchema;
66
- _prefault?: unknown;
67
- };
68
-
69
- type ComponentAiParams = {
70
- instructions?: string;
71
- schema?: JSONSchema;
72
- defaultZone?: { allow?: string[]; disallow?: string[]; disabled?: boolean };
73
- };
74
-
75
- type FieldAiParams = {
76
- instructions?: string;
77
- exclude?: boolean;
78
- required?: boolean;
79
- stream?: boolean;
80
- schema?: JSONSchema;
81
- };
82
-
83
- declare module "@measured/puck" {
84
- export interface ComponentMetadata {
85
- ai?: ComponentAiParams;
86
- }
6
+ type PuckMessage = UIMessage<PuckProviderMetadata, PuckDataParts>;
87
7
 
88
- export interface ComponentConfigExtensions {
89
- ai?: ComponentAiParams;
90
- }
91
-
92
- export interface FieldMetadata {
93
- ai?: FieldAiParams;
94
- }
95
-
96
- export interface BaseField {
97
- ai?: FieldAiParams;
98
- }
99
- }
100
-
101
- type AiPluginProps = {
8
+ type ChatProps$1 = {
102
9
  host?: string;
103
- chat?: {
104
- onSubmit?: (prompt: string) => void;
105
- examplePrompts?: {
106
- href: string;
107
- label: string;
108
- }[];
109
- };
10
+ onSubmit?: (prompt: string) => void;
11
+ examplePrompts?: {
12
+ href: string;
13
+ label: string;
14
+ }[];
15
+ chatId?: string;
16
+ initialMessages?: PuckMessage[];
110
17
  };
111
18
 
112
- declare function createAiPlugin(opts?: AiPluginProps): {
19
+ declare function createAIPlugin(opts?: ChatProps$1): {
113
20
  label: string;
114
21
  name: string;
115
22
  render: () => react_jsx_runtime.JSX.Element;
@@ -117,4 +24,17 @@ declare function createAiPlugin(opts?: AiPluginProps): {
117
24
  mobilePanelHeight: "min-content";
118
25
  };
119
26
 
120
- export { createAiPlugin };
27
+ type ChatProps = {
28
+ children?: ReactNode;
29
+ examplePrompts?: ReactNode;
30
+ handleSubmit?: (prompt: string) => void;
31
+ hideInput?: boolean;
32
+ inputRef?: RefObject<HTMLTextAreaElement | null>;
33
+ status?: ChatStatus;
34
+ messages?: PuckMessage[];
35
+ error?: string;
36
+ handleRetry?: () => void;
37
+ };
38
+ declare function ChatBody({ children, examplePrompts, handleSubmit, hideInput, inputRef, messages, status, error, handleRetry, }: ChatProps): react_jsx_runtime.JSX.Element;
39
+
40
+ export { ChatBody, createAIPlugin as default };
package/dist/index.d.ts CHANGED
@@ -1,115 +1,22 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { UIMessage, ChatStatus } from 'ai';
3
+ import { PuckProviderMetadata, PuckDataParts } from '@puckeditor/platform-types';
4
+ import { ReactNode, RefObject } from 'react';
2
5
 
3
- type _JSONSchema = boolean | JSONSchema;
4
- type JSONSchema = {
5
- [k: string]: unknown;
6
- $schema?: "https://json-schema.org/draft/2020-12/schema" | "http://json-schema.org/draft-07/schema#" | "http://json-schema.org/draft-04/schema#";
7
- $id?: string;
8
- $anchor?: string;
9
- $ref?: string;
10
- $dynamicRef?: string;
11
- $dynamicAnchor?: string;
12
- $vocabulary?: Record<string, boolean>;
13
- $comment?: string;
14
- $defs?: Record<string, JSONSchema>;
15
- type?: "object" | "array" | "string" | "number" | "boolean" | "null" | "integer";
16
- additionalItems?: _JSONSchema;
17
- unevaluatedItems?: _JSONSchema;
18
- prefixItems?: _JSONSchema[];
19
- items?: _JSONSchema | _JSONSchema[];
20
- contains?: _JSONSchema;
21
- additionalProperties?: _JSONSchema;
22
- unevaluatedProperties?: _JSONSchema;
23
- properties?: Record<string, _JSONSchema>;
24
- patternProperties?: Record<string, _JSONSchema>;
25
- dependentSchemas?: Record<string, _JSONSchema>;
26
- propertyNames?: _JSONSchema;
27
- if?: _JSONSchema;
28
- then?: _JSONSchema;
29
- else?: _JSONSchema;
30
- allOf?: JSONSchema[];
31
- anyOf?: JSONSchema[];
32
- oneOf?: JSONSchema[];
33
- not?: _JSONSchema;
34
- multipleOf?: number;
35
- maximum?: number;
36
- exclusiveMaximum?: number | boolean;
37
- minimum?: number;
38
- exclusiveMinimum?: number | boolean;
39
- maxLength?: number;
40
- minLength?: number;
41
- pattern?: string;
42
- maxItems?: number;
43
- minItems?: number;
44
- uniqueItems?: boolean;
45
- maxContains?: number;
46
- minContains?: number;
47
- maxProperties?: number;
48
- minProperties?: number;
49
- required?: string[];
50
- dependentRequired?: Record<string, string[]>;
51
- enum?: Array<string | number | boolean | null>;
52
- const?: string | number | boolean | null;
53
- id?: string;
54
- title?: string;
55
- description?: string;
56
- default?: unknown;
57
- deprecated?: boolean;
58
- readOnly?: boolean;
59
- writeOnly?: boolean;
60
- nullable?: boolean;
61
- examples?: unknown[];
62
- format?: string;
63
- contentMediaType?: string;
64
- contentEncoding?: string;
65
- contentSchema?: JSONSchema;
66
- _prefault?: unknown;
67
- };
68
-
69
- type ComponentAiParams = {
70
- instructions?: string;
71
- schema?: JSONSchema;
72
- defaultZone?: { allow?: string[]; disallow?: string[]; disabled?: boolean };
73
- };
74
-
75
- type FieldAiParams = {
76
- instructions?: string;
77
- exclude?: boolean;
78
- required?: boolean;
79
- stream?: boolean;
80
- schema?: JSONSchema;
81
- };
82
-
83
- declare module "@measured/puck" {
84
- export interface ComponentMetadata {
85
- ai?: ComponentAiParams;
86
- }
6
+ type PuckMessage = UIMessage<PuckProviderMetadata, PuckDataParts>;
87
7
 
88
- export interface ComponentConfigExtensions {
89
- ai?: ComponentAiParams;
90
- }
91
-
92
- export interface FieldMetadata {
93
- ai?: FieldAiParams;
94
- }
95
-
96
- export interface BaseField {
97
- ai?: FieldAiParams;
98
- }
99
- }
100
-
101
- type AiPluginProps = {
8
+ type ChatProps$1 = {
102
9
  host?: string;
103
- chat?: {
104
- onSubmit?: (prompt: string) => void;
105
- examplePrompts?: {
106
- href: string;
107
- label: string;
108
- }[];
109
- };
10
+ onSubmit?: (prompt: string) => void;
11
+ examplePrompts?: {
12
+ href: string;
13
+ label: string;
14
+ }[];
15
+ chatId?: string;
16
+ initialMessages?: PuckMessage[];
110
17
  };
111
18
 
112
- declare function createAiPlugin(opts?: AiPluginProps): {
19
+ declare function createAIPlugin(opts?: ChatProps$1): {
113
20
  label: string;
114
21
  name: string;
115
22
  render: () => react_jsx_runtime.JSX.Element;
@@ -117,4 +24,17 @@ declare function createAiPlugin(opts?: AiPluginProps): {
117
24
  mobilePanelHeight: "min-content";
118
25
  };
119
26
 
120
- export { createAiPlugin };
27
+ type ChatProps = {
28
+ children?: ReactNode;
29
+ examplePrompts?: ReactNode;
30
+ handleSubmit?: (prompt: string) => void;
31
+ hideInput?: boolean;
32
+ inputRef?: RefObject<HTMLTextAreaElement | null>;
33
+ status?: ChatStatus;
34
+ messages?: PuckMessage[];
35
+ error?: string;
36
+ handleRetry?: () => void;
37
+ };
38
+ declare function ChatBody({ children, examplePrompts, handleSubmit, hideInput, inputRef, messages, status, error, handleRetry, }: ChatProps): react_jsx_runtime.JSX.Element;
39
+
40
+ export { ChatBody, createAIPlugin as default };