@malto/sdk 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.
@@ -0,0 +1,202 @@
1
+ type SdkMode = "bubble" | "modal" | "inline" | "trigger";
2
+ type SdkPosition = "bottom-right" | "bottom-left" | "top-right" | "top-left";
3
+ type SdkFeature = "submit" | "vote" | "list" | "comment" | "roadmap" | "changelog";
4
+ type IdentifyPayload = {
5
+ externalUserId: string;
6
+ email: string;
7
+ name?: string;
8
+ hash: string;
9
+ };
10
+ type MaltoConfig = {
11
+ apiKey: string;
12
+ apiUrl?: string;
13
+ mode?: SdkMode;
14
+ position?: SdkPosition;
15
+ triggerLabel?: string;
16
+ primaryColor?: string;
17
+ /** Override CSS variables exposed by the widget. Keys are CSS custom property names without leading `--`. */
18
+ cssVars?: Partial<MaltoCssVars>;
19
+ /**
20
+ * Raw CSS injected after the base stylesheet. Wins over base styles except
21
+ * !important rules.
22
+ *
23
+ * **Security**: this string is rendered into the DOM via a <style> element.
24
+ * Treat it as code, not data. The SDK strips obvious break-out patterns
25
+ * (</style>, </script>, expression(), javascript:) but cannot prevent every
26
+ * CSS-based exfiltration vector. Never pass user-supplied CSS.
27
+ */
28
+ customCss?: string;
29
+ /** Border radius scale: "sm" 8px, "md" 14px (default), "lg" 22px. */
30
+ radius?: "sm" | "md" | "lg";
31
+ /** Color scheme. "auto" follows OS preference. */
32
+ appearance?: "light" | "dark" | "auto";
33
+ zIndex?: number;
34
+ views?: SdkFeature[];
35
+ identify?: IdentifyPayload;
36
+ target?: string | HTMLElement;
37
+ onReady?: () => void;
38
+ onError?: (err: Error) => void;
39
+ };
40
+ type MaltoCssVars = {
41
+ primary: string;
42
+ primaryContrast: string;
43
+ surface: string;
44
+ surfaceMuted: string;
45
+ border: string;
46
+ text: string;
47
+ textMuted: string;
48
+ radius: string;
49
+ shadow: string;
50
+ font: string;
51
+ };
52
+ type BoardInfo = {
53
+ slug: string | null;
54
+ companyName: string | null;
55
+ companyLogoUrl: string | null;
56
+ boardName: string | null;
57
+ boardDescription: string | null;
58
+ boardThemeColor: string | null;
59
+ };
60
+ type WidgetSettings = {
61
+ enabledFeatures: SdkFeature[];
62
+ defaultMode: SdkMode;
63
+ position: SdkPosition;
64
+ primaryColor: string | null;
65
+ triggerLabel: string | null;
66
+ requireIdentity: boolean;
67
+ };
68
+ type BoardResponse = {
69
+ board: BoardInfo;
70
+ widget: WidgetSettings;
71
+ };
72
+ type FeedbackItem = {
73
+ id: string;
74
+ title: string;
75
+ description: string | null;
76
+ status: string;
77
+ votes: number;
78
+ createdAt: string;
79
+ hasVoted?: boolean;
80
+ };
81
+ type CommentItem = {
82
+ id: string;
83
+ body: string;
84
+ createdAt: string;
85
+ author: {
86
+ id: string;
87
+ name: string;
88
+ avatarUrl: string | null;
89
+ };
90
+ likes: number;
91
+ hasLiked: boolean;
92
+ };
93
+ type SessionResponse = {
94
+ sessionToken: string;
95
+ expiresAt: string;
96
+ user: {
97
+ email: string;
98
+ name: string | null;
99
+ };
100
+ };
101
+ type ReleaseItem = {
102
+ id: string;
103
+ title: string;
104
+ body: string;
105
+ category: string;
106
+ publishedAt: string | null;
107
+ };
108
+
109
+ type ClientOptions = {
110
+ apiKey: string;
111
+ apiUrl?: string;
112
+ getSessionToken: () => string | null;
113
+ };
114
+ declare class MaltoClient {
115
+ private readonly apiKey;
116
+ private readonly apiUrl;
117
+ private readonly getSessionToken;
118
+ constructor(opts: ClientOptions);
119
+ private request;
120
+ board(): Promise<BoardResponse>;
121
+ listFeedbacks(): Promise<FeedbackItem[]>;
122
+ feedback(id: string): Promise<FeedbackItem>;
123
+ createFeedback(input: {
124
+ title: string;
125
+ description?: string;
126
+ category?: string;
127
+ }): Promise<FeedbackItem>;
128
+ vote(id: string): Promise<{
129
+ voted: boolean;
130
+ votes: number;
131
+ }>;
132
+ comments(id: string): Promise<CommentItem[]>;
133
+ addComment(id: string, body: string, parentId?: string): Promise<CommentItem>;
134
+ roadmap(): Promise<Record<string, FeedbackItem[]>>;
135
+ releases(): Promise<ReleaseItem[]>;
136
+ startMagicLink(input: {
137
+ email: string;
138
+ name?: string;
139
+ returnUrl?: string;
140
+ }): Promise<{
141
+ ok: true;
142
+ }>;
143
+ verifyMagicLink(token: string): Promise<SessionResponse>;
144
+ identify(payload: IdentifyPayload): Promise<SessionResponse>;
145
+ }
146
+ declare class MaltoApiError extends Error {
147
+ status: number;
148
+ constructor(message: string, status: number);
149
+ }
150
+
151
+ declare class MaltoWidget {
152
+ private readonly config;
153
+ private readonly client;
154
+ private readonly apiKeyPrefix;
155
+ private resolvedMode;
156
+ private root;
157
+ private container;
158
+ private trigger;
159
+ private board;
160
+ private state;
161
+ constructor(config: MaltoConfig);
162
+ mount(): Promise<void>;
163
+ unmount(): void;
164
+ open(): void;
165
+ close(): void;
166
+ setIdentify(identify: IdentifyPayload | null): void;
167
+ private runIdentify;
168
+ private renderHost;
169
+ private buildBubble;
170
+ private resolveTarget;
171
+ private render;
172
+ private buildPanelBody;
173
+ private buildHeader;
174
+ private buildTabs;
175
+ private tabBtn;
176
+ private go;
177
+ private allowedViews;
178
+ private buildView;
179
+ private viewList;
180
+ private feedbackRow;
181
+ private viewSubmit;
182
+ private viewAuth;
183
+ private viewRoadmap;
184
+ private viewChangelog;
185
+ private viewDetail;
186
+ private skeletonList;
187
+ private emptyState;
188
+ private loadFeedbacks;
189
+ private loadRoadmap;
190
+ private loadReleases;
191
+ private loadComments;
192
+ private handleVote;
193
+ }
194
+
195
+ declare function init(config: MaltoConfig): MaltoWidget;
196
+ declare function open(): void;
197
+ declare function close(): void;
198
+ declare function identify(payload: IdentifyPayload): void;
199
+ declare function reset(apiKey: string): void;
200
+ declare function destroy(): void;
201
+
202
+ export { type BoardInfo, type BoardResponse, type CommentItem, type FeedbackItem, type IdentifyPayload, MaltoApiError, MaltoClient, type MaltoConfig, type MaltoCssVars, MaltoWidget, type ReleaseItem, type SdkFeature, type SdkMode, type SdkPosition, type SessionResponse, type WidgetSettings, close, destroy, identify, init, open, reset };
@@ -0,0 +1,202 @@
1
+ type SdkMode = "bubble" | "modal" | "inline" | "trigger";
2
+ type SdkPosition = "bottom-right" | "bottom-left" | "top-right" | "top-left";
3
+ type SdkFeature = "submit" | "vote" | "list" | "comment" | "roadmap" | "changelog";
4
+ type IdentifyPayload = {
5
+ externalUserId: string;
6
+ email: string;
7
+ name?: string;
8
+ hash: string;
9
+ };
10
+ type MaltoConfig = {
11
+ apiKey: string;
12
+ apiUrl?: string;
13
+ mode?: SdkMode;
14
+ position?: SdkPosition;
15
+ triggerLabel?: string;
16
+ primaryColor?: string;
17
+ /** Override CSS variables exposed by the widget. Keys are CSS custom property names without leading `--`. */
18
+ cssVars?: Partial<MaltoCssVars>;
19
+ /**
20
+ * Raw CSS injected after the base stylesheet. Wins over base styles except
21
+ * !important rules.
22
+ *
23
+ * **Security**: this string is rendered into the DOM via a <style> element.
24
+ * Treat it as code, not data. The SDK strips obvious break-out patterns
25
+ * (</style>, </script>, expression(), javascript:) but cannot prevent every
26
+ * CSS-based exfiltration vector. Never pass user-supplied CSS.
27
+ */
28
+ customCss?: string;
29
+ /** Border radius scale: "sm" 8px, "md" 14px (default), "lg" 22px. */
30
+ radius?: "sm" | "md" | "lg";
31
+ /** Color scheme. "auto" follows OS preference. */
32
+ appearance?: "light" | "dark" | "auto";
33
+ zIndex?: number;
34
+ views?: SdkFeature[];
35
+ identify?: IdentifyPayload;
36
+ target?: string | HTMLElement;
37
+ onReady?: () => void;
38
+ onError?: (err: Error) => void;
39
+ };
40
+ type MaltoCssVars = {
41
+ primary: string;
42
+ primaryContrast: string;
43
+ surface: string;
44
+ surfaceMuted: string;
45
+ border: string;
46
+ text: string;
47
+ textMuted: string;
48
+ radius: string;
49
+ shadow: string;
50
+ font: string;
51
+ };
52
+ type BoardInfo = {
53
+ slug: string | null;
54
+ companyName: string | null;
55
+ companyLogoUrl: string | null;
56
+ boardName: string | null;
57
+ boardDescription: string | null;
58
+ boardThemeColor: string | null;
59
+ };
60
+ type WidgetSettings = {
61
+ enabledFeatures: SdkFeature[];
62
+ defaultMode: SdkMode;
63
+ position: SdkPosition;
64
+ primaryColor: string | null;
65
+ triggerLabel: string | null;
66
+ requireIdentity: boolean;
67
+ };
68
+ type BoardResponse = {
69
+ board: BoardInfo;
70
+ widget: WidgetSettings;
71
+ };
72
+ type FeedbackItem = {
73
+ id: string;
74
+ title: string;
75
+ description: string | null;
76
+ status: string;
77
+ votes: number;
78
+ createdAt: string;
79
+ hasVoted?: boolean;
80
+ };
81
+ type CommentItem = {
82
+ id: string;
83
+ body: string;
84
+ createdAt: string;
85
+ author: {
86
+ id: string;
87
+ name: string;
88
+ avatarUrl: string | null;
89
+ };
90
+ likes: number;
91
+ hasLiked: boolean;
92
+ };
93
+ type SessionResponse = {
94
+ sessionToken: string;
95
+ expiresAt: string;
96
+ user: {
97
+ email: string;
98
+ name: string | null;
99
+ };
100
+ };
101
+ type ReleaseItem = {
102
+ id: string;
103
+ title: string;
104
+ body: string;
105
+ category: string;
106
+ publishedAt: string | null;
107
+ };
108
+
109
+ type ClientOptions = {
110
+ apiKey: string;
111
+ apiUrl?: string;
112
+ getSessionToken: () => string | null;
113
+ };
114
+ declare class MaltoClient {
115
+ private readonly apiKey;
116
+ private readonly apiUrl;
117
+ private readonly getSessionToken;
118
+ constructor(opts: ClientOptions);
119
+ private request;
120
+ board(): Promise<BoardResponse>;
121
+ listFeedbacks(): Promise<FeedbackItem[]>;
122
+ feedback(id: string): Promise<FeedbackItem>;
123
+ createFeedback(input: {
124
+ title: string;
125
+ description?: string;
126
+ category?: string;
127
+ }): Promise<FeedbackItem>;
128
+ vote(id: string): Promise<{
129
+ voted: boolean;
130
+ votes: number;
131
+ }>;
132
+ comments(id: string): Promise<CommentItem[]>;
133
+ addComment(id: string, body: string, parentId?: string): Promise<CommentItem>;
134
+ roadmap(): Promise<Record<string, FeedbackItem[]>>;
135
+ releases(): Promise<ReleaseItem[]>;
136
+ startMagicLink(input: {
137
+ email: string;
138
+ name?: string;
139
+ returnUrl?: string;
140
+ }): Promise<{
141
+ ok: true;
142
+ }>;
143
+ verifyMagicLink(token: string): Promise<SessionResponse>;
144
+ identify(payload: IdentifyPayload): Promise<SessionResponse>;
145
+ }
146
+ declare class MaltoApiError extends Error {
147
+ status: number;
148
+ constructor(message: string, status: number);
149
+ }
150
+
151
+ declare class MaltoWidget {
152
+ private readonly config;
153
+ private readonly client;
154
+ private readonly apiKeyPrefix;
155
+ private resolvedMode;
156
+ private root;
157
+ private container;
158
+ private trigger;
159
+ private board;
160
+ private state;
161
+ constructor(config: MaltoConfig);
162
+ mount(): Promise<void>;
163
+ unmount(): void;
164
+ open(): void;
165
+ close(): void;
166
+ setIdentify(identify: IdentifyPayload | null): void;
167
+ private runIdentify;
168
+ private renderHost;
169
+ private buildBubble;
170
+ private resolveTarget;
171
+ private render;
172
+ private buildPanelBody;
173
+ private buildHeader;
174
+ private buildTabs;
175
+ private tabBtn;
176
+ private go;
177
+ private allowedViews;
178
+ private buildView;
179
+ private viewList;
180
+ private feedbackRow;
181
+ private viewSubmit;
182
+ private viewAuth;
183
+ private viewRoadmap;
184
+ private viewChangelog;
185
+ private viewDetail;
186
+ private skeletonList;
187
+ private emptyState;
188
+ private loadFeedbacks;
189
+ private loadRoadmap;
190
+ private loadReleases;
191
+ private loadComments;
192
+ private handleVote;
193
+ }
194
+
195
+ declare function init(config: MaltoConfig): MaltoWidget;
196
+ declare function open(): void;
197
+ declare function close(): void;
198
+ declare function identify(payload: IdentifyPayload): void;
199
+ declare function reset(apiKey: string): void;
200
+ declare function destroy(): void;
201
+
202
+ export { type BoardInfo, type BoardResponse, type CommentItem, type FeedbackItem, type IdentifyPayload, MaltoApiError, MaltoClient, type MaltoConfig, type MaltoCssVars, MaltoWidget, type ReleaseItem, type SdkFeature, type SdkMode, type SdkPosition, type SessionResponse, type WidgetSettings, close, destroy, identify, init, open, reset };