hivewrite-sdk 1.1.92 → 1.1.93

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/index.d.ts CHANGED
@@ -24,6 +24,42 @@ export interface AuthData {
24
24
  }
25
25
  }
26
26
 
27
+ export interface SaveDesign {
28
+ body: { blocks: any[] };
29
+ canvasSettings: CanvasSettings;
30
+ name: string;
31
+ category?: string;
32
+ thumbnail?: string;
33
+ description?: string;
34
+ templateId?: string | null;
35
+ version?: string | number | null;
36
+ }
37
+
38
+ export interface SaveContext {
39
+ design: SaveDesign;
40
+ html: string;
41
+ source: 'manual' | 'autosave';
42
+ templateId: string | null;
43
+ version: string | number | null;
44
+ user_id: string | null;
45
+ }
46
+
47
+
48
+ export interface SaveResult {
49
+ success: boolean;
50
+ templateId?: string | null;
51
+ version?: string | number | null;
52
+ message?: string;
53
+ error?: string;
54
+ code?: 'VALIDATION' | 'NO_CALLBACK' | 'BACKEND' | 'UNKNOWN';
55
+ }
56
+
57
+ export type SaveCallback = (
58
+ design: SaveDesign,
59
+ user_id: string | null,
60
+ context: SaveContext
61
+ ) => SaveResult | boolean | void | Promise<SaveResult | boolean | void>;
62
+
27
63
  export interface SDKConfig {
28
64
  onTokenRefresh: () => Promise<string>;
29
65
  accessToken: string;
@@ -48,8 +84,8 @@ export interface SDKConfig {
48
84
  autosave?: number;
49
85
  callbacks?: {
50
86
  onLoad?: () => void;
51
- onSave?: (json: any, user_id?: string | null) => void;
52
- onAutoSave?: (json: any, user_id?: string | null) => void;
87
+ onSave?: SaveCallback;
88
+ onAutoSave?: SaveCallback;
53
89
  onExport?: (html: string, user_id?: string | null) => void;
54
90
  onImageUpload?: (file: File, user_id?: string | null) => Promise<string>;
55
91
  onError?: (error: any, user_id?: string | null) => void;
@@ -59,14 +95,28 @@ export interface SDKConfig {
59
95
 
60
96
  export interface EmailEditorSDK {
61
97
  init(config: SDKConfig): Promise<void>;
62
- save(): void;
98
+ save(): Promise<SaveResult>;
99
+ setTemplateId(templateId: string | null, version?: string | number | null): void;
100
+ getTemplateId(): string | null;
101
+ getTemplateVersion(): string | number | null;
63
102
  exportHtml(callback?: (html: string, user_id?: string | null) => void): any;
64
103
  exportMjml(callback?: (mjml: string, user_id?: string | null) => void): any;
65
104
  exportJson(callback?: (json: any, user_id?: string | null) => void): any;
66
105
  export(options: { format: 'html' | 'json' | 'mjml', minify?: boolean }, callback?: (data: any, user_id?: string | null) => void): any;
67
106
  setTheme(theme: 'light' | 'dark'): void;
68
107
  setLocale(locale: 'en' | 'es' | 'fr'): void;
69
- loadDesign(design: { blocks?: any[], canvasSettings?: CanvasSettings, templateSettings?: { name: string, category: string, thumbnail: string, description: string } }): void;
108
+ loadDesign(design: {
109
+ blocks?: any[];
110
+ body?: { blocks?: any[] };
111
+ canvasSettings?: CanvasSettings;
112
+ templateSettings?: { name: string, category: string, thumbnail: string, description: string };
113
+ name?: string;
114
+ category?: string;
115
+ thumbnail?: string;
116
+ description?: string;
117
+ templateId?: string | null;
118
+ version?: string | number | null;
119
+ }): void;
70
120
  showLoader(): void;
71
121
  hideLoader(): void;
72
122
  destroy(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hivewrite-sdk",
3
- "version": "1.1.92",
3
+ "version": "1.1.93",
4
4
  "description": "Email Editor SDK for React and JavaScript applications",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",