easy-email-pro-theme 1.59.9 → 1.60.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/lib/index.js +896 -245
- package/lib/typings/components/AIAgent/applyResult.d.ts +2 -0
- package/lib/typings/hooks/aiBatchUpdate.d.ts +28 -0
- package/lib/typings/hooks/aiEditorTransaction.d.ts +8 -0
- package/lib/typings/hooks/aiExternalHistory.d.ts +10 -0
- package/lib/typings/hooks/aiSubjectUpdate.d.ts +4 -0
- package/lib/typings/hooks/aiTransactionalMutation.d.ts +3 -0
- package/lib/typings/hooks/useApplyAiToolCalls.d.ts +26 -0
- package/lib/typings/themes/Retro/components/ElementInteract/ElementTools/index.d.ts +1 -0
- package/lib/typings/typings/custom-types.d.ts +2 -0
- package/package.json +2 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type AiBatchUpdateToolCall, type AiToolTarget, type Element } from "easy-email-pro-core";
|
|
2
|
+
import { Editor, Path } from "slate";
|
|
3
|
+
export declare const MAX_AI_BATCH_TARGETS = 200;
|
|
4
|
+
export type ResolvedBatchTarget = {
|
|
5
|
+
element: Element;
|
|
6
|
+
path: Path;
|
|
7
|
+
};
|
|
8
|
+
export type ResolvedBatchUpdate = {
|
|
9
|
+
call: AiBatchUpdateToolCall;
|
|
10
|
+
targets: ResolvedBatchTarget[];
|
|
11
|
+
};
|
|
12
|
+
export type BatchApplyResult = {
|
|
13
|
+
applied: number;
|
|
14
|
+
skipped: number;
|
|
15
|
+
errors: string[];
|
|
16
|
+
};
|
|
17
|
+
export type BatchFieldApplyResult = {
|
|
18
|
+
changed: boolean;
|
|
19
|
+
error?: string;
|
|
20
|
+
};
|
|
21
|
+
export declare function validateBatchUpdateCall(call: AiBatchUpdateToolCall): void;
|
|
22
|
+
export declare function resolveBatchUpdateTargets(editor: Editor, call: AiBatchUpdateToolCall, resolveRoot?: (target: AiToolTarget) => Path | null): ResolvedBatchUpdate;
|
|
23
|
+
export declare function assertBatchTargetLimit(batches: ResolvedBatchUpdate[], limit?: number): void;
|
|
24
|
+
export declare function getBatchRecordUpdate(current: Record<string, unknown>, key: string, nextValue: unknown): {
|
|
25
|
+
changed: boolean;
|
|
26
|
+
value: {} | undefined;
|
|
27
|
+
};
|
|
28
|
+
export declare function applyResolvedBatchUpdate(resolved: ResolvedBatchUpdate, applyField: (target: ResolvedBatchTarget, field: "text" | "attributes" | "mobileAttributes" | "data" | "visibility", value: unknown) => boolean | BatchFieldApplyResult): BatchApplyResult;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Editor } from "slate";
|
|
2
|
+
import { HistoryEditor } from "slate-history";
|
|
3
|
+
import { type AiExternalHistoryChange } from "./aiExternalHistory";
|
|
4
|
+
type AiEditorTransactionOptions = {
|
|
5
|
+
getExternalChange?: () => AiExternalHistoryChange | null;
|
|
6
|
+
};
|
|
7
|
+
export declare function runAiEditorTransaction<T>(editor: Editor & HistoryEditor, apply: () => T, options?: AiEditorTransactionOptions): T;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Editor } from "slate";
|
|
2
|
+
import type { HistoryEditor } from "slate-history";
|
|
3
|
+
type HistoryBatch = HistoryEditor["history"]["undos"][number];
|
|
4
|
+
export type AiExternalHistoryChange = {
|
|
5
|
+
before: string;
|
|
6
|
+
after: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function installAiExternalHistory(editor: Editor & HistoryEditor, setValue: (value: string) => void): void;
|
|
9
|
+
export declare function attachAiExternalHistory(batch: HistoryBatch, change: AiExternalHistoryChange): void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function validateAiSubject(value: unknown): string;
|
|
2
|
+
export declare function isAiSubjectChanged(current: string, next: string): boolean;
|
|
3
|
+
export declare function subjectAfterApplyingTemplate(current: string, template: unknown): string;
|
|
4
|
+
export declare function emailAfterApplyingAiTemplate<TCurrent extends Record<string, unknown>>(current: TCurrent, template: unknown): TCurrent;
|
|
@@ -9,6 +9,9 @@ export type AiEditorToolTarget = {
|
|
|
9
9
|
index?: number;
|
|
10
10
|
};
|
|
11
11
|
export type AiEditorToolCall = {
|
|
12
|
+
name: "update_subject";
|
|
13
|
+
subject: string;
|
|
14
|
+
} | {
|
|
12
15
|
name: "update_text";
|
|
13
16
|
target: AiEditorToolTarget;
|
|
14
17
|
text: string;
|
|
@@ -68,6 +71,29 @@ export type AiEditorToolCall = {
|
|
|
68
71
|
} | {
|
|
69
72
|
name: "apply_template";
|
|
70
73
|
template: unknown;
|
|
74
|
+
} | {
|
|
75
|
+
name: "batch_update";
|
|
76
|
+
selector: {
|
|
77
|
+
scope: "template" | "descendants";
|
|
78
|
+
root?: AiEditorToolTarget;
|
|
79
|
+
types: string[];
|
|
80
|
+
where?: Array<{
|
|
81
|
+
field: "text" | "attribute" | "mobileAttribute" | "data";
|
|
82
|
+
key?: string;
|
|
83
|
+
operator: "equals" | "contains" | "exists";
|
|
84
|
+
value?: unknown;
|
|
85
|
+
}>;
|
|
86
|
+
};
|
|
87
|
+
changes: {
|
|
88
|
+
text?: string;
|
|
89
|
+
attributes?: Record<string, unknown>;
|
|
90
|
+
mobileAttributes?: Record<string, unknown>;
|
|
91
|
+
data?: Record<string, unknown>;
|
|
92
|
+
visibility?: {
|
|
93
|
+
desktop: boolean;
|
|
94
|
+
mobile: boolean;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
71
97
|
};
|
|
72
98
|
export type AiEditorToolApplyResult = {
|
|
73
99
|
applied: number;
|
|
@@ -26,6 +26,8 @@ export interface EditorContextProps {
|
|
|
26
26
|
initialValuesRef: React.MutableRefObject<EmailTemplate>;
|
|
27
27
|
getFieldValue: (path: Path | null, name: string) => any;
|
|
28
28
|
setFieldValue: (path: Path | null, name: string, value: any) => void;
|
|
29
|
+
setFieldValueTransactional: (path: Path | null, name: string, value: any) => void;
|
|
30
|
+
syncValues: (values: EmailTemplate) => void;
|
|
29
31
|
getFieldDirty: (path: Path | null, name: string) => boolean;
|
|
30
32
|
reset: (values: EmailTemplate) => void;
|
|
31
33
|
valid: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easy-email-pro-theme",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.60.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib"
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "vite build && npm run typings",
|
|
50
|
+
"test:ai-agent": "cd ../.. && packages/easy-email-pro-core/node_modules/.bin/tsx packages/easy-email-pro-theme/test/aiBatchUpdate.test.ts && packages/easy-email-pro-core/node_modules/.bin/tsx packages/easy-email-pro-theme/test/aiEditorTransaction.test.ts && packages/easy-email-pro-core/node_modules/.bin/tsx packages/easy-email-pro-theme/test/aiAgentBatchSummary.test.ts && packages/easy-email-pro-core/node_modules/.bin/tsx packages/easy-email-pro-theme/test/aiTransactionalMutation.test.ts && packages/easy-email-pro-core/node_modules/.bin/tsx packages/easy-email-pro-theme/test/aiSubjectUpdate.test.ts",
|
|
50
51
|
"typings": "tsc --declaration --emitDeclarationOnly --project tsconfig.alias.json && tsc-alias -p tsconfig.alias.json",
|
|
51
52
|
"lint": "eslint --fix --ext .tsx,.ts src/"
|
|
52
53
|
}
|