reflet-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,290 @@
1
+ /**
2
+ * Reflet SDK Types
3
+ */
4
+ interface RefletConfig {
5
+ /** Your board's public API key (fb_pub_xxx) */
6
+ publicKey: string;
7
+ /** API base URL (defaults to https://api.reflet.app) */
8
+ baseUrl?: string;
9
+ /** User identification for SSO */
10
+ user?: RefletUser;
11
+ /** Pre-signed user token (alternative to user object) */
12
+ userToken?: string;
13
+ }
14
+ interface RefletUser {
15
+ /** Unique identifier for the user in your system */
16
+ id: string;
17
+ /** User's email address */
18
+ email?: string;
19
+ /** User's display name */
20
+ name?: string;
21
+ /** URL to user's avatar image */
22
+ avatar?: string;
23
+ /** Additional metadata */
24
+ metadata?: Record<string, unknown>;
25
+ }
26
+ interface BoardConfig {
27
+ id: string;
28
+ name: string;
29
+ slug: string;
30
+ description?: string;
31
+ isPublic: boolean;
32
+ settings?: BoardSettings;
33
+ organization: {
34
+ id: string;
35
+ name: string;
36
+ slug: string;
37
+ logo?: string;
38
+ primaryColor?: string;
39
+ };
40
+ statuses: BoardStatus[];
41
+ }
42
+ interface BoardSettings {
43
+ allowAnonymousVoting?: boolean;
44
+ requireApproval?: boolean;
45
+ defaultStatus?: FeedbackStatus;
46
+ }
47
+ interface BoardStatus {
48
+ id: string;
49
+ name: string;
50
+ color: string;
51
+ icon?: string;
52
+ order: number;
53
+ }
54
+ type FeedbackStatus = "open" | "under_review" | "planned" | "in_progress" | "completed" | "closed";
55
+ interface FeedbackItem {
56
+ id: string;
57
+ title: string;
58
+ description: string;
59
+ status: FeedbackStatus;
60
+ voteCount: number;
61
+ commentCount: number;
62
+ isPinned: boolean;
63
+ hasVoted: boolean;
64
+ createdAt: number;
65
+ updatedAt: number;
66
+ completedAt?: number;
67
+ tags: FeedbackTag[];
68
+ boardStatus: {
69
+ id: string;
70
+ name: string;
71
+ color: string;
72
+ } | null;
73
+ author: FeedbackAuthor | null;
74
+ }
75
+ interface FeedbackDetail extends FeedbackItem {
76
+ isSubscribed: boolean;
77
+ }
78
+ interface FeedbackTag {
79
+ id: string;
80
+ name: string;
81
+ color: string;
82
+ }
83
+ interface FeedbackAuthor {
84
+ name?: string;
85
+ email?: string;
86
+ avatar?: string;
87
+ isExternal: boolean;
88
+ }
89
+ interface FeedbackListResponse {
90
+ items: FeedbackItem[];
91
+ total: number;
92
+ hasMore: boolean;
93
+ }
94
+ interface FeedbackListParams {
95
+ /** Filter by custom status ID */
96
+ statusId?: string;
97
+ /** Filter by status name */
98
+ status?: FeedbackStatus;
99
+ /** Search in title and description */
100
+ search?: string;
101
+ /** Sort order */
102
+ sortBy?: "votes" | "newest" | "oldest" | "comments";
103
+ /** Number of items to return (max 100) */
104
+ limit?: number;
105
+ /** Offset for pagination */
106
+ offset?: number;
107
+ }
108
+ interface CreateFeedbackParams {
109
+ title: string;
110
+ description: string;
111
+ }
112
+ interface CreateFeedbackResponse {
113
+ feedbackId: string;
114
+ isApproved: boolean;
115
+ }
116
+ interface VoteResponse {
117
+ voted: boolean;
118
+ voteCount: number;
119
+ }
120
+ interface Comment {
121
+ id: string;
122
+ body: string;
123
+ isOfficial: boolean;
124
+ author: FeedbackAuthor | null;
125
+ replies: CommentReply[];
126
+ createdAt: number;
127
+ updatedAt: number;
128
+ }
129
+ interface CommentReply {
130
+ id: string;
131
+ body: string;
132
+ isOfficial: boolean;
133
+ author: FeedbackAuthor | null;
134
+ createdAt: number;
135
+ updatedAt: number;
136
+ }
137
+ interface AddCommentParams {
138
+ feedbackId: string;
139
+ body: string;
140
+ parentId?: string;
141
+ }
142
+ interface AddCommentResponse {
143
+ commentId: string;
144
+ }
145
+ interface SubscribeResponse {
146
+ subscribed: boolean;
147
+ alreadySubscribed?: boolean;
148
+ }
149
+ interface UnsubscribeResponse {
150
+ unsubscribed: boolean;
151
+ wasNotSubscribed?: boolean;
152
+ }
153
+ interface Roadmap {
154
+ lanes: RoadmapLane[];
155
+ }
156
+ interface RoadmapLane {
157
+ id: string;
158
+ name: string;
159
+ color: string;
160
+ items: RoadmapItem[];
161
+ }
162
+ interface RoadmapItem {
163
+ id: string;
164
+ title: string;
165
+ status: FeedbackStatus;
166
+ voteCount: number;
167
+ }
168
+ interface ChangelogEntry {
169
+ id: string;
170
+ title: string;
171
+ description?: string;
172
+ version?: string;
173
+ publishedAt?: number;
174
+ feedback: {
175
+ id: string;
176
+ title: string;
177
+ }[];
178
+ }
179
+ declare class RefletError extends Error {
180
+ readonly status: number;
181
+ readonly code?: string;
182
+ constructor(message: string, status: number, code?: string);
183
+ }
184
+ declare class RefletAuthError extends RefletError {
185
+ constructor(message: string);
186
+ }
187
+ declare class RefletValidationError extends RefletError {
188
+ constructor(message: string);
189
+ }
190
+ declare class RefletNotFoundError extends RefletError {
191
+ constructor(message: string);
192
+ }
193
+
194
+ /**
195
+ * Reflet SDK Client
196
+ *
197
+ * @example
198
+ * ```ts
199
+ * import { Reflet } from '@reflet/sdk';
200
+ *
201
+ * const reflet = new Reflet({
202
+ * publicKey: 'fb_pub_xxx',
203
+ * user: { id: 'user_123', email: 'user@example.com', name: 'John' }
204
+ * });
205
+ *
206
+ * // List feedback
207
+ * const { items } = await reflet.list({ status: 'open' });
208
+ *
209
+ * // Vote on feedback
210
+ * await reflet.vote('feedback_id');
211
+ *
212
+ * // Submit new feedback
213
+ * await reflet.create({ title: 'Great idea', description: 'Details...' });
214
+ * ```
215
+ */
216
+ declare class Reflet {
217
+ private readonly publicKey;
218
+ private readonly baseUrl;
219
+ private userToken;
220
+ private user;
221
+ constructor(config: RefletConfig);
222
+ /**
223
+ * Update the user identification
224
+ */
225
+ setUser(user: RefletUser | undefined): void;
226
+ /**
227
+ * Set the user token directly (for server-signed tokens)
228
+ */
229
+ setUserToken(token: string | undefined): void;
230
+ /**
231
+ * Get the board configuration
232
+ */
233
+ getConfig(): Promise<BoardConfig>;
234
+ /**
235
+ * List feedback items with optional filtering
236
+ */
237
+ list(params?: FeedbackListParams): Promise<FeedbackListResponse>;
238
+ /**
239
+ * Get a single feedback item by ID
240
+ */
241
+ get(feedbackId: string): Promise<FeedbackDetail>;
242
+ /**
243
+ * Create new feedback
244
+ * Requires user identification
245
+ */
246
+ create(params: CreateFeedbackParams): Promise<CreateFeedbackResponse>;
247
+ /**
248
+ * Toggle vote on feedback
249
+ * Requires user identification
250
+ */
251
+ vote(feedbackId: string, type?: "upvote" | "downvote"): Promise<VoteResponse>;
252
+ /**
253
+ * Get comments for a feedback item
254
+ */
255
+ getComments(feedbackId: string, sortBy?: "newest" | "oldest"): Promise<Comment[]>;
256
+ /**
257
+ * Add a comment to feedback
258
+ * Requires user identification
259
+ */
260
+ comment(params: AddCommentParams): Promise<AddCommentResponse>;
261
+ /**
262
+ * Subscribe to feedback updates
263
+ * Requires user identification
264
+ */
265
+ subscribe(feedbackId: string): Promise<SubscribeResponse>;
266
+ /**
267
+ * Unsubscribe from feedback updates
268
+ * Requires user identification
269
+ */
270
+ unsubscribe(feedbackId: string): Promise<UnsubscribeResponse>;
271
+ /**
272
+ * Get roadmap data
273
+ */
274
+ getRoadmap(): Promise<Roadmap>;
275
+ /**
276
+ * Get changelog entries
277
+ */
278
+ getChangelog(limit?: number): Promise<ChangelogEntry[]>;
279
+ /**
280
+ * Make an authenticated API request
281
+ */
282
+ private request;
283
+ /**
284
+ * Generate a simple user token for client-side use
285
+ * Note: For production, use server-side token signing
286
+ */
287
+ private generateUserToken;
288
+ }
289
+
290
+ export { type AddCommentParams, type AddCommentResponse, type BoardConfig, type BoardSettings, type BoardStatus, type ChangelogEntry, type Comment, type CommentReply, type CreateFeedbackParams, type CreateFeedbackResponse, type FeedbackAuthor, type FeedbackDetail, type FeedbackItem, type FeedbackListParams, type FeedbackListResponse, type FeedbackStatus, type FeedbackTag, Reflet, RefletAuthError, type RefletConfig, RefletError, RefletNotFoundError, type RefletUser, RefletValidationError, type Roadmap, type RoadmapItem, type RoadmapLane, type SubscribeResponse, type UnsubscribeResponse, type VoteResponse };
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { Reflet, RefletAuthError, RefletError, RefletNotFoundError, RefletValidationError } from './chunk-RDQP4VCA.js';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,158 @@
1
+ import { RefletUser, Reflet, FeedbackListParams, AddCommentParams, BoardConfig, ChangelogEntry, Comment, CreateFeedbackParams, FeedbackDetail, FeedbackItem, Roadmap } from './index.js';
2
+ export { FeedbackStatus, FeedbackTag, RefletConfig, RoadmapItem, RoadmapLane } from './index.js';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+ import { ReactNode } from 'react';
5
+
6
+ interface RefletContextValue {
7
+ client: Reflet;
8
+ isReady: boolean;
9
+ user: RefletUser | undefined;
10
+ setUser: (user: RefletUser | undefined) => void;
11
+ }
12
+ interface RefletProviderProps {
13
+ /** Your board's public API key */
14
+ publicKey: string;
15
+ /** API base URL (optional) */
16
+ baseUrl?: string;
17
+ /** Initial user identification */
18
+ user?: RefletUser;
19
+ /** Pre-signed user token (alternative to user) */
20
+ userToken?: string;
21
+ /** Children */
22
+ children: ReactNode;
23
+ }
24
+ /**
25
+ * Provider component for Reflet SDK
26
+ *
27
+ * @example
28
+ * ```tsx
29
+ * import { RefletProvider } from '@reflet/sdk/react';
30
+ *
31
+ * function App() {
32
+ * return (
33
+ * <RefletProvider
34
+ * publicKey="fb_pub_xxx"
35
+ * user={{ id: 'user_123', email: 'user@example.com', name: 'John' }}
36
+ * >
37
+ * <YourApp />
38
+ * </RefletProvider>
39
+ * );
40
+ * }
41
+ * ```
42
+ */
43
+ declare function RefletProvider({ publicKey, baseUrl, user: initialUser, userToken, children, }: RefletProviderProps): react_jsx_runtime.JSX.Element;
44
+ declare function useRefletContext(): RefletContextValue;
45
+ declare function useRefletClient(): Reflet;
46
+
47
+ interface UseQueryResult<T> {
48
+ data: T | undefined;
49
+ isLoading: boolean;
50
+ error: Error | null;
51
+ refetch: () => Promise<void>;
52
+ }
53
+ interface UseMutationResult<TData, TVariables> {
54
+ mutate: (variables: TVariables) => Promise<TData>;
55
+ isLoading: boolean;
56
+ error: Error | null;
57
+ data: TData | undefined;
58
+ reset: () => void;
59
+ }
60
+ /**
61
+ * Hook to fetch board configuration
62
+ */
63
+ declare function useBoardConfig(): UseQueryResult<BoardConfig>;
64
+ interface UseFeedbackListOptions extends FeedbackListParams {
65
+ /** Auto-fetch on mount */
66
+ enabled?: boolean;
67
+ }
68
+ /**
69
+ * Hook to fetch feedback list with filtering
70
+ *
71
+ * @example
72
+ * ```tsx
73
+ * const { data, isLoading } = useFeedbackList({ status: 'open', sortBy: 'votes' });
74
+ * ```
75
+ */
76
+ declare function useFeedbackList(options?: UseFeedbackListOptions): UseQueryResult<{
77
+ items: FeedbackItem[];
78
+ total: number;
79
+ hasMore: boolean;
80
+ }>;
81
+ /**
82
+ * Hook to fetch a single feedback item
83
+ *
84
+ * @example
85
+ * ```tsx
86
+ * const { data: feedback, isLoading } = useFeedback('feedback_id');
87
+ * ```
88
+ */
89
+ declare function useFeedback(feedbackId: string | undefined): UseQueryResult<FeedbackDetail>;
90
+ /**
91
+ * Hook to fetch comments for a feedback item
92
+ */
93
+ declare function useComments(feedbackId: string | undefined, sortBy?: "newest" | "oldest"): UseQueryResult<Comment[]>;
94
+ /**
95
+ * Hook to fetch roadmap data
96
+ */
97
+ declare function useRoadmap(): UseQueryResult<Roadmap>;
98
+ /**
99
+ * Hook to fetch changelog entries
100
+ */
101
+ declare function useChangelog(limit?: number): UseQueryResult<ChangelogEntry[]>;
102
+ /**
103
+ * Hook to create new feedback
104
+ *
105
+ * @example
106
+ * ```tsx
107
+ * const { mutate: createFeedback, isLoading } = useCreateFeedback();
108
+ *
109
+ * const handleSubmit = async (data) => {
110
+ * const result = await createFeedback(data);
111
+ * console.log('Created:', result.feedbackId);
112
+ * };
113
+ * ```
114
+ */
115
+ declare function useCreateFeedback(): UseMutationResult<{
116
+ feedbackId: string;
117
+ isApproved: boolean;
118
+ }, CreateFeedbackParams>;
119
+ /**
120
+ * Hook to vote on feedback
121
+ *
122
+ * @example
123
+ * ```tsx
124
+ * const { mutate: vote } = useVote();
125
+ *
126
+ * <button onClick={() => vote({ feedbackId: 'xxx' })}>
127
+ * Vote
128
+ * </button>
129
+ * ```
130
+ */
131
+ declare function useVote(): UseMutationResult<{
132
+ voted: boolean;
133
+ voteCount: number;
134
+ }, {
135
+ feedbackId: string;
136
+ type?: "upvote" | "downvote";
137
+ }>;
138
+ /**
139
+ * Hook to add a comment
140
+ */
141
+ declare function useAddComment(): UseMutationResult<{
142
+ commentId: string;
143
+ }, AddCommentParams>;
144
+ /**
145
+ * Hook to subscribe/unsubscribe to feedback
146
+ */
147
+ declare function useSubscription(): {
148
+ subscribe: (feedbackId: string) => Promise<{
149
+ subscribed: boolean;
150
+ }>;
151
+ unsubscribe: (feedbackId: string) => Promise<{
152
+ unsubscribed: boolean;
153
+ }>;
154
+ isLoading: boolean;
155
+ error: Error | null;
156
+ };
157
+
158
+ export { AddCommentParams, BoardConfig, ChangelogEntry, Comment, CreateFeedbackParams, FeedbackDetail, FeedbackItem, FeedbackListParams, Reflet, RefletProvider, type RefletProviderProps, RefletUser, Roadmap, type UseFeedbackListOptions, useAddComment, useBoardConfig, useChangelog, useComments, useCreateFeedback, useFeedback, useFeedbackList, useRefletClient, useRefletContext, useRoadmap, useSubscription, useVote };