@weirdfingers/boards 0.1.4

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,508 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import React, { ReactNode } from 'react';
3
+ import * as urql from 'urql';
4
+
5
+ /**
6
+ * Core authentication types and interfaces.
7
+ */
8
+ interface User$1 {
9
+ id: string;
10
+ email: string;
11
+ name?: string;
12
+ avatar?: string;
13
+ metadata: Record<string, unknown>;
14
+ credits: {
15
+ balance: number;
16
+ reserved: number;
17
+ };
18
+ }
19
+ interface AuthProvider$1 {
20
+ id: string;
21
+ name: string;
22
+ type: 'oauth' | 'email' | 'magic-link' | 'custom';
23
+ config: Record<string, unknown>;
24
+ }
25
+ interface SignInOptions {
26
+ provider?: string;
27
+ redirectTo?: string;
28
+ [key: string]: unknown;
29
+ }
30
+ interface AuthState$1 {
31
+ user: User$1 | null;
32
+ status: 'loading' | 'authenticated' | 'unauthenticated' | 'error';
33
+ signIn: (provider?: AuthProvider$1, options?: SignInOptions) => Promise<void>;
34
+ signOut: () => Promise<void>;
35
+ getToken: () => Promise<string | null>;
36
+ refreshToken: () => Promise<string | null>;
37
+ }
38
+ interface AuthProviderConfig {
39
+ /**
40
+ * Tenant identifier for multi-tenant applications.
41
+ * If not provided, defaults to single-tenant mode.
42
+ */
43
+ tenantId?: string;
44
+ /**
45
+ * Additional configuration specific to the auth provider.
46
+ */
47
+ [key: string]: unknown;
48
+ }
49
+ interface AuthContextValue extends AuthState$1 {
50
+ /**
51
+ * Whether the auth system is initializing.
52
+ */
53
+ isInitializing: boolean;
54
+ /**
55
+ * Any error that occurred during authentication.
56
+ */
57
+ error: Error | null;
58
+ /**
59
+ * Clear any authentication errors.
60
+ */
61
+ clearError: () => void;
62
+ }
63
+
64
+ /**
65
+ * Base authentication provider abstract class.
66
+ */
67
+
68
+ declare abstract class BaseAuthProvider {
69
+ protected config: AuthProviderConfig;
70
+ constructor(config?: AuthProviderConfig);
71
+ /**
72
+ * Initialize the auth provider.
73
+ * Called once when the provider is created.
74
+ */
75
+ abstract initialize(): Promise<void>;
76
+ /**
77
+ * Get the current authentication state.
78
+ */
79
+ abstract getAuthState(): Promise<AuthState$1>;
80
+ /**
81
+ * Sign in with the provider.
82
+ */
83
+ abstract signIn(opts?: Record<string, unknown>): Promise<void>;
84
+ /**
85
+ * Sign out from the provider.
86
+ */
87
+ abstract signOut(): Promise<void>;
88
+ /**
89
+ * Get the current authentication token.
90
+ */
91
+ abstract getToken(): Promise<string | null>;
92
+ /**
93
+ * Get the current user information.
94
+ */
95
+ abstract getUser(): Promise<User$1 | null>;
96
+ /**
97
+ * Listen for auth state changes.
98
+ * Returns an unsubscribe function.
99
+ */
100
+ abstract onAuthStateChange(callback: (state: AuthState$1) => void): () => void;
101
+ /**
102
+ * Clean up resources when the provider is destroyed.
103
+ */
104
+ abstract destroy(): Promise<void>;
105
+ /**
106
+ * Get the tenant ID from config.
107
+ */
108
+ protected getTenantId(): string;
109
+ }
110
+
111
+ interface AuthProviderProps {
112
+ provider: BaseAuthProvider;
113
+ children: React.ReactNode;
114
+ }
115
+ declare function AuthProvider({ provider, children }: AuthProviderProps): react_jsx_runtime.JSX.Element;
116
+ declare function useAuth(): AuthContextValue;
117
+ declare function useAuthOptional(): AuthContextValue | null;
118
+
119
+ /**
120
+ * No-auth provider for local development without authentication.
121
+ */
122
+
123
+ interface NoAuthConfig extends AuthProviderConfig {
124
+ /**
125
+ * Default user ID for development.
126
+ * Defaults to 'dev-user'.
127
+ */
128
+ defaultUserId?: string;
129
+ /**
130
+ * Default user email for development.
131
+ * Defaults to 'dev@example.com'.
132
+ */
133
+ defaultEmail?: string;
134
+ /**
135
+ * Default display name for development.
136
+ * Defaults to 'Development User'.
137
+ */
138
+ defaultDisplayName?: string;
139
+ }
140
+ declare class NoAuthProvider extends BaseAuthProvider {
141
+ protected config: NoAuthConfig;
142
+ private listeners;
143
+ private currentState;
144
+ private defaultUser;
145
+ constructor(config?: NoAuthConfig);
146
+ initialize(): Promise<void>;
147
+ getAuthState(): Promise<AuthState$1>;
148
+ signIn(): Promise<void>;
149
+ signOut(): Promise<void>;
150
+ getToken(): Promise<string | null>;
151
+ refreshToken(): Promise<string | null>;
152
+ getUser(): Promise<User$1 | null>;
153
+ onAuthStateChange(callback: (state: AuthState$1) => void): () => void;
154
+ destroy(): Promise<void>;
155
+ private updateState;
156
+ }
157
+
158
+ interface ApiConfig {
159
+ /**
160
+ * Base URL for the backend API (e.g., "http://localhost:8088")
161
+ * Used for REST endpoints like SSE streams
162
+ */
163
+ apiUrl: string;
164
+ /**
165
+ * GraphQL endpoint URL (e.g., "http://localhost:8088/graphql")
166
+ */
167
+ graphqlUrl: string;
168
+ /**
169
+ * WebSocket URL for GraphQL subscriptions
170
+ */
171
+ subscriptionUrl?: string;
172
+ }
173
+ declare function useApiConfig(): ApiConfig;
174
+
175
+ /**
176
+ * GraphQL client configuration with authentication.
177
+ */
178
+ interface AuthState {
179
+ getToken(): Promise<string | null>;
180
+ }
181
+ interface ClientConfig {
182
+ url: string;
183
+ subscriptionUrl?: string;
184
+ auth: AuthState;
185
+ tenantId?: string;
186
+ }
187
+ declare function createGraphQLClient({ url, subscriptionUrl, auth, tenantId, }: ClientConfig): urql.Client;
188
+
189
+ /**
190
+ * GraphQL queries and mutations for the Boards API.
191
+ */
192
+ declare const USER_FRAGMENT: urql.TypedDocumentNode<any, urql.AnyVariables>;
193
+ declare const BOARD_FRAGMENT: urql.TypedDocumentNode<any, urql.AnyVariables>;
194
+ declare const GENERATION_FRAGMENT: urql.TypedDocumentNode<any, urql.AnyVariables>;
195
+ declare const GET_CURRENT_USER: urql.TypedDocumentNode<any, urql.AnyVariables>;
196
+ declare const GET_BOARDS: urql.TypedDocumentNode<any, urql.AnyVariables>;
197
+ declare const GET_BOARD: urql.TypedDocumentNode<any, urql.AnyVariables>;
198
+ declare const GET_GENERATORS: urql.TypedDocumentNode<any, urql.AnyVariables>;
199
+ declare const GET_GENERATIONS: urql.TypedDocumentNode<any, urql.AnyVariables>;
200
+ declare const GET_GENERATION: urql.TypedDocumentNode<any, urql.AnyVariables>;
201
+ declare const CREATE_BOARD: urql.TypedDocumentNode<any, urql.AnyVariables>;
202
+ declare const UPDATE_BOARD: urql.TypedDocumentNode<any, urql.AnyVariables>;
203
+ declare const DELETE_BOARD: urql.TypedDocumentNode<any, urql.AnyVariables>;
204
+ declare const ADD_BOARD_MEMBER: urql.TypedDocumentNode<any, urql.AnyVariables>;
205
+ declare const UPDATE_BOARD_MEMBER_ROLE: urql.TypedDocumentNode<any, urql.AnyVariables>;
206
+ declare const REMOVE_BOARD_MEMBER: urql.TypedDocumentNode<any, urql.AnyVariables>;
207
+ declare const CREATE_GENERATION: urql.TypedDocumentNode<any, urql.AnyVariables>;
208
+ declare const CANCEL_GENERATION: urql.TypedDocumentNode<any, urql.AnyVariables>;
209
+ declare const RETRY_GENERATION: urql.TypedDocumentNode<any, urql.AnyVariables>;
210
+ interface CreateBoardInput {
211
+ title: string;
212
+ description?: string;
213
+ isPublic?: boolean;
214
+ settings?: Record<string, unknown>;
215
+ metadata?: Record<string, unknown>;
216
+ }
217
+ interface UpdateBoardInput {
218
+ title?: string;
219
+ description?: string;
220
+ isPublic?: boolean;
221
+ settings?: Record<string, unknown>;
222
+ metadata?: Record<string, unknown>;
223
+ }
224
+ interface CreateGenerationInput {
225
+ boardId: string;
226
+ generatorName: string;
227
+ artifactType: ArtifactType;
228
+ inputParams: Record<string, unknown>;
229
+ metadata?: Record<string, unknown>;
230
+ }
231
+ declare enum BoardRole {
232
+ VIEWER = "VIEWER",
233
+ EDITOR = "EDITOR",
234
+ ADMIN = "ADMIN"
235
+ }
236
+ declare enum GenerationStatus {
237
+ PENDING = "PENDING",
238
+ RUNNING = "RUNNING",
239
+ COMPLETED = "COMPLETED",
240
+ FAILED = "FAILED",
241
+ CANCELLED = "CANCELLED"
242
+ }
243
+ declare enum ArtifactType {
244
+ IMAGE = "image",
245
+ VIDEO = "video",
246
+ AUDIO = "audio",
247
+ TEXT = "text",
248
+ LORA = "lora",
249
+ MODEL = "model"
250
+ }
251
+
252
+ /**
253
+ * Hook for managing multiple boards.
254
+ */
255
+
256
+ interface Board$1 {
257
+ id: string;
258
+ tenantId: string;
259
+ ownerId: string;
260
+ title: string;
261
+ description?: string;
262
+ isPublic: boolean;
263
+ settings: Record<string, unknown>;
264
+ metadata: Record<string, unknown>;
265
+ createdAt: string;
266
+ updatedAt: string;
267
+ generationCount: number;
268
+ owner: {
269
+ id: string;
270
+ email: string;
271
+ displayName: string;
272
+ avatarUrl?: string;
273
+ createdAt: string;
274
+ };
275
+ }
276
+ interface UseBoardsOptions {
277
+ limit?: number;
278
+ offset?: number;
279
+ }
280
+ interface BoardsHook {
281
+ boards: Board$1[];
282
+ loading: boolean;
283
+ error: Error | null;
284
+ createBoard: (data: CreateBoardInput) => Promise<Board$1>;
285
+ deleteBoard: (boardId: string) => Promise<void>;
286
+ searchBoards: (query: string) => Promise<Board$1[]>;
287
+ refresh: () => Promise<void>;
288
+ setSearchQuery: (query: string) => void;
289
+ searchQuery: string;
290
+ }
291
+ declare function useBoards(options?: UseBoardsOptions): BoardsHook;
292
+
293
+ /**
294
+ * Hook for managing a single board.
295
+ */
296
+
297
+ interface User {
298
+ id: string;
299
+ email: string;
300
+ displayName: string;
301
+ avatarUrl?: string;
302
+ createdAt: string;
303
+ }
304
+ interface BoardMember {
305
+ id: string;
306
+ boardId: string;
307
+ userId: string;
308
+ role: BoardRole;
309
+ invitedBy?: string;
310
+ joinedAt: string;
311
+ user: User;
312
+ inviter?: User;
313
+ }
314
+ interface Generation {
315
+ id: string;
316
+ boardId: string;
317
+ userId: string;
318
+ generatorName: string;
319
+ artifactType: string;
320
+ status: string;
321
+ progress: number;
322
+ storageUrl?: string | null;
323
+ thumbnailUrl?: string | null;
324
+ inputParams: Record<string, unknown>;
325
+ outputMetadata: Record<string, unknown>;
326
+ errorMessage?: string | null;
327
+ createdAt: string;
328
+ updatedAt: string;
329
+ completedAt?: string | null;
330
+ }
331
+ interface Board {
332
+ id: string;
333
+ tenantId: string;
334
+ ownerId: string;
335
+ title: string;
336
+ description?: string;
337
+ isPublic: boolean;
338
+ settings: Record<string, unknown>;
339
+ metadata: Record<string, unknown>;
340
+ createdAt: string;
341
+ updatedAt: string;
342
+ generationCount: number;
343
+ owner: User;
344
+ members: BoardMember[];
345
+ generations: Generation[];
346
+ }
347
+ type MemberRole = BoardRole;
348
+ interface BoardPermissions {
349
+ canEdit: boolean;
350
+ canDelete: boolean;
351
+ canAddMembers: boolean;
352
+ canRemoveMembers: boolean;
353
+ canGenerate: boolean;
354
+ canExport: boolean;
355
+ }
356
+ interface ShareLinkOptions {
357
+ expiresIn?: number;
358
+ permissions?: string[];
359
+ }
360
+ interface ShareLink {
361
+ id: string;
362
+ url: string;
363
+ expiresAt?: string;
364
+ permissions: string[];
365
+ }
366
+ interface BoardHook {
367
+ board: Board | null;
368
+ members: BoardMember[];
369
+ permissions: BoardPermissions;
370
+ loading: boolean;
371
+ error: Error | null;
372
+ updateBoard: (updates: Partial<UpdateBoardInput>) => Promise<Board>;
373
+ deleteBoard: () => Promise<void>;
374
+ refresh: () => Promise<void>;
375
+ addMember: (email: string, role: MemberRole) => Promise<BoardMember>;
376
+ removeMember: (memberId: string) => Promise<void>;
377
+ updateMemberRole: (memberId: string, role: MemberRole) => Promise<BoardMember>;
378
+ generateShareLink: (options: ShareLinkOptions) => Promise<ShareLink>;
379
+ revokeShareLink: (linkId: string) => Promise<void>;
380
+ }
381
+ declare function useBoard(boardId: string): BoardHook;
382
+
383
+ /**
384
+ * Hook for managing AI generations with real-time progress via SSE.
385
+ */
386
+
387
+ interface GenerationRequest {
388
+ model: string;
389
+ artifactType: ArtifactType;
390
+ inputs: GenerationInputs;
391
+ boardId: string;
392
+ options?: GenerationOptions;
393
+ }
394
+ interface GenerationInputs {
395
+ prompt: string;
396
+ negativePrompt?: string;
397
+ image?: string | File;
398
+ mask?: string | File;
399
+ loras?: LoRAInput[];
400
+ seed?: number;
401
+ steps?: number;
402
+ guidance?: number;
403
+ aspectRatio?: string;
404
+ style?: string;
405
+ [key: string]: unknown;
406
+ }
407
+ interface GenerationOptions {
408
+ priority?: "low" | "normal" | "high";
409
+ timeout?: number;
410
+ webhookUrl?: string;
411
+ [key: string]: unknown;
412
+ }
413
+ interface LoRAInput {
414
+ id: string;
415
+ weight: number;
416
+ }
417
+ interface GenerationProgress {
418
+ jobId: string;
419
+ status: "queued" | "processing" | "completed" | "failed" | "cancelled";
420
+ progress: number;
421
+ phase: string;
422
+ message?: string | null;
423
+ estimatedTimeRemaining?: number;
424
+ currentStep?: string;
425
+ logs?: string[];
426
+ }
427
+ interface GenerationResult {
428
+ id: string;
429
+ jobId: string;
430
+ boardId: string;
431
+ request: GenerationRequest;
432
+ artifacts: Artifact[];
433
+ credits: {
434
+ cost: number;
435
+ balanceBefore: number;
436
+ balance: number;
437
+ };
438
+ performance: {
439
+ queueTime: number;
440
+ processingTime: number;
441
+ totalTime: number;
442
+ };
443
+ createdAt: Date;
444
+ }
445
+ interface Artifact {
446
+ id: string;
447
+ type: string;
448
+ url: string;
449
+ thumbnailUrl?: string;
450
+ metadata: Record<string, unknown>;
451
+ }
452
+ interface GenerationHook {
453
+ progress: GenerationProgress | null;
454
+ result: GenerationResult | null;
455
+ error: Error | null;
456
+ isGenerating: boolean;
457
+ submit: (request: GenerationRequest) => Promise<string>;
458
+ cancel: (jobId: string) => Promise<void>;
459
+ retry: (jobId: string) => Promise<void>;
460
+ history: GenerationResult[];
461
+ clearHistory: () => void;
462
+ }
463
+ declare function useGeneration(): GenerationHook;
464
+
465
+ /**
466
+ * Hook for fetching available generators.
467
+ */
468
+
469
+ interface Generator {
470
+ name: string;
471
+ description: string;
472
+ artifactType: ArtifactType;
473
+ inputSchema: Record<string, unknown>;
474
+ }
475
+ interface UseGeneratorsOptions {
476
+ artifactType?: string;
477
+ }
478
+ interface GeneratorsHook {
479
+ generators: Generator[];
480
+ loading: boolean;
481
+ error: Error | null;
482
+ }
483
+ declare function useGenerators(options?: UseGeneratorsOptions): GeneratorsHook;
484
+
485
+ interface BoardsProviderProps {
486
+ children: ReactNode;
487
+ /**
488
+ * Base URL for the backend API (e.g., "http://localhost:8088")
489
+ * Used for REST endpoints like SSE streams
490
+ */
491
+ apiUrl: string;
492
+ /**
493
+ * GraphQL endpoint URL (e.g., "http://localhost:8088/graphql")
494
+ * If not provided, defaults to `${apiUrl}/graphql`
495
+ */
496
+ graphqlUrl?: string;
497
+ /**
498
+ * WebSocket URL for GraphQL subscriptions
499
+ */
500
+ subscriptionUrl?: string;
501
+ authProvider: BaseAuthProvider;
502
+ tenantId?: string;
503
+ }
504
+ declare function BoardsProvider({ children, apiUrl, graphqlUrl, subscriptionUrl, authProvider, tenantId, }: BoardsProviderProps): react_jsx_runtime.JSX.Element;
505
+
506
+ declare const VERSION = "0.1.0";
507
+
508
+ export { ADD_BOARD_MEMBER, type ApiConfig, ArtifactType, type AuthContextValue, AuthProvider, type AuthProviderConfig, type AuthState$1 as AuthState, BOARD_FRAGMENT, BaseAuthProvider, BoardRole, BoardsProvider, CANCEL_GENERATION, CREATE_BOARD, CREATE_GENERATION, type CreateBoardInput, type CreateGenerationInput, DELETE_BOARD, GENERATION_FRAGMENT, GET_BOARD, GET_BOARDS, GET_CURRENT_USER, GET_GENERATION, GET_GENERATIONS, GET_GENERATORS, GenerationStatus, NoAuthProvider, REMOVE_BOARD_MEMBER, RETRY_GENERATION, type SignInOptions, UPDATE_BOARD, UPDATE_BOARD_MEMBER_ROLE, USER_FRAGMENT, type UpdateBoardInput, type User$1 as User, VERSION, createGraphQLClient, useApiConfig, useAuth, useAuthOptional, useBoard, useBoards, useGeneration, useGenerators };