@superatomai/sdk-node 0.0.1

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,1239 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const DSLRendererPropsSchema$1: z.ZodObject<{
4
+ dsl: z.ZodObject<{
5
+ id: z.ZodString;
6
+ name: z.ZodOptional<z.ZodString>;
7
+ props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
8
+ states: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
9
+ methods: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
10
+ fn: z.ZodString;
11
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
12
+ }, "strip", z.ZodTypeAny, {
13
+ fn: string;
14
+ params?: Record<string, any> | undefined;
15
+ }, {
16
+ fn: string;
17
+ params?: Record<string, any> | undefined;
18
+ }>>>;
19
+ effects: z.ZodOptional<z.ZodArray<z.ZodObject<{
20
+ fn: z.ZodString;
21
+ deps: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
22
+ }, "strip", z.ZodTypeAny, {
23
+ fn: string;
24
+ deps?: string[] | undefined;
25
+ }, {
26
+ fn: string;
27
+ deps?: string[] | undefined;
28
+ }>, "many">>;
29
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
30
+ render: z.ZodType<any, z.ZodTypeDef, any>;
31
+ query: z.ZodOptional<z.ZodObject<{
32
+ graphql: z.ZodOptional<z.ZodString>;
33
+ sql: z.ZodOptional<z.ZodString>;
34
+ variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
35
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
36
+ key: z.ZodOptional<z.ZodString>;
37
+ refetchPolicy: z.ZodOptional<z.ZodEnum<["cache-first", "network-only", "cache-and-network"]>>;
38
+ dependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
39
+ }, "strip", z.ZodTypeAny, {
40
+ params?: Record<string, any> | undefined;
41
+ key?: string | undefined;
42
+ graphql?: string | undefined;
43
+ sql?: string | undefined;
44
+ variables?: Record<string, any> | undefined;
45
+ refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
46
+ dependencies?: string[] | undefined;
47
+ }, {
48
+ params?: Record<string, any> | undefined;
49
+ key?: string | undefined;
50
+ graphql?: string | undefined;
51
+ sql?: string | undefined;
52
+ variables?: Record<string, any> | undefined;
53
+ refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
54
+ dependencies?: string[] | undefined;
55
+ }>>;
56
+ }, "strip", z.ZodTypeAny, {
57
+ id: string;
58
+ name?: string | undefined;
59
+ query?: {
60
+ params?: Record<string, any> | undefined;
61
+ key?: string | undefined;
62
+ graphql?: string | undefined;
63
+ sql?: string | undefined;
64
+ variables?: Record<string, any> | undefined;
65
+ refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
66
+ dependencies?: string[] | undefined;
67
+ } | undefined;
68
+ props?: Record<string, any> | undefined;
69
+ states?: Record<string, any> | undefined;
70
+ methods?: Record<string, {
71
+ fn: string;
72
+ params?: Record<string, any> | undefined;
73
+ }> | undefined;
74
+ effects?: {
75
+ fn: string;
76
+ deps?: string[] | undefined;
77
+ }[] | undefined;
78
+ data?: Record<string, any> | undefined;
79
+ render?: any;
80
+ }, {
81
+ id: string;
82
+ name?: string | undefined;
83
+ query?: {
84
+ params?: Record<string, any> | undefined;
85
+ key?: string | undefined;
86
+ graphql?: string | undefined;
87
+ sql?: string | undefined;
88
+ variables?: Record<string, any> | undefined;
89
+ refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
90
+ dependencies?: string[] | undefined;
91
+ } | undefined;
92
+ props?: Record<string, any> | undefined;
93
+ states?: Record<string, any> | undefined;
94
+ methods?: Record<string, {
95
+ fn: string;
96
+ params?: Record<string, any> | undefined;
97
+ }> | undefined;
98
+ effects?: {
99
+ fn: string;
100
+ deps?: string[] | undefined;
101
+ }[] | undefined;
102
+ data?: Record<string, any> | undefined;
103
+ render?: any;
104
+ }>;
105
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
106
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
107
+ }, "strip", z.ZodTypeAny, {
108
+ dsl: {
109
+ id: string;
110
+ name?: string | undefined;
111
+ query?: {
112
+ params?: Record<string, any> | undefined;
113
+ key?: string | undefined;
114
+ graphql?: string | undefined;
115
+ sql?: string | undefined;
116
+ variables?: Record<string, any> | undefined;
117
+ refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
118
+ dependencies?: string[] | undefined;
119
+ } | undefined;
120
+ props?: Record<string, any> | undefined;
121
+ states?: Record<string, any> | undefined;
122
+ methods?: Record<string, {
123
+ fn: string;
124
+ params?: Record<string, any> | undefined;
125
+ }> | undefined;
126
+ effects?: {
127
+ fn: string;
128
+ deps?: string[] | undefined;
129
+ }[] | undefined;
130
+ data?: Record<string, any> | undefined;
131
+ render?: any;
132
+ };
133
+ data?: Record<string, any> | undefined;
134
+ context?: Record<string, any> | undefined;
135
+ }, {
136
+ dsl: {
137
+ id: string;
138
+ name?: string | undefined;
139
+ query?: {
140
+ params?: Record<string, any> | undefined;
141
+ key?: string | undefined;
142
+ graphql?: string | undefined;
143
+ sql?: string | undefined;
144
+ variables?: Record<string, any> | undefined;
145
+ refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
146
+ dependencies?: string[] | undefined;
147
+ } | undefined;
148
+ props?: Record<string, any> | undefined;
149
+ states?: Record<string, any> | undefined;
150
+ methods?: Record<string, {
151
+ fn: string;
152
+ params?: Record<string, any> | undefined;
153
+ }> | undefined;
154
+ effects?: {
155
+ fn: string;
156
+ deps?: string[] | undefined;
157
+ }[] | undefined;
158
+ data?: Record<string, any> | undefined;
159
+ render?: any;
160
+ };
161
+ data?: Record<string, any> | undefined;
162
+ context?: Record<string, any> | undefined;
163
+ }>;
164
+ type DSLRendererProps$1 = z.infer<typeof DSLRendererPropsSchema$1>;
165
+
166
+ declare const DSLRendererPropsSchema: z.ZodObject<{
167
+ dsl: z.ZodObject<{
168
+ id: z.ZodString;
169
+ name: z.ZodOptional<z.ZodString>;
170
+ props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
171
+ states: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
172
+ methods: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
173
+ fn: z.ZodString;
174
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
175
+ }, "strip", z.ZodTypeAny, {
176
+ fn: string;
177
+ params?: Record<string, any> | undefined;
178
+ }, {
179
+ fn: string;
180
+ params?: Record<string, any> | undefined;
181
+ }>>>;
182
+ effects: z.ZodOptional<z.ZodArray<z.ZodObject<{
183
+ fn: z.ZodString;
184
+ deps: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
185
+ }, "strip", z.ZodTypeAny, {
186
+ fn: string;
187
+ deps?: string[] | undefined;
188
+ }, {
189
+ fn: string;
190
+ deps?: string[] | undefined;
191
+ }>, "many">>;
192
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
193
+ render: z.ZodType<any, z.ZodTypeDef, any>;
194
+ query: z.ZodOptional<z.ZodObject<{
195
+ graphql: z.ZodOptional<z.ZodString>;
196
+ sql: z.ZodOptional<z.ZodString>;
197
+ variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
198
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
199
+ key: z.ZodOptional<z.ZodString>;
200
+ refetchPolicy: z.ZodOptional<z.ZodEnum<["cache-first", "network-only", "cache-and-network"]>>;
201
+ dependencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
202
+ }, "strip", z.ZodTypeAny, {
203
+ params?: Record<string, any> | undefined;
204
+ key?: string | undefined;
205
+ graphql?: string | undefined;
206
+ sql?: string | undefined;
207
+ variables?: Record<string, any> | undefined;
208
+ refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
209
+ dependencies?: string[] | undefined;
210
+ }, {
211
+ params?: Record<string, any> | undefined;
212
+ key?: string | undefined;
213
+ graphql?: string | undefined;
214
+ sql?: string | undefined;
215
+ variables?: Record<string, any> | undefined;
216
+ refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
217
+ dependencies?: string[] | undefined;
218
+ }>>;
219
+ }, "strip", z.ZodTypeAny, {
220
+ id: string;
221
+ name?: string | undefined;
222
+ query?: {
223
+ params?: Record<string, any> | undefined;
224
+ key?: string | undefined;
225
+ graphql?: string | undefined;
226
+ sql?: string | undefined;
227
+ variables?: Record<string, any> | undefined;
228
+ refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
229
+ dependencies?: string[] | undefined;
230
+ } | undefined;
231
+ props?: Record<string, any> | undefined;
232
+ states?: Record<string, any> | undefined;
233
+ methods?: Record<string, {
234
+ fn: string;
235
+ params?: Record<string, any> | undefined;
236
+ }> | undefined;
237
+ effects?: {
238
+ fn: string;
239
+ deps?: string[] | undefined;
240
+ }[] | undefined;
241
+ data?: Record<string, any> | undefined;
242
+ render?: any;
243
+ }, {
244
+ id: string;
245
+ name?: string | undefined;
246
+ query?: {
247
+ params?: Record<string, any> | undefined;
248
+ key?: string | undefined;
249
+ graphql?: string | undefined;
250
+ sql?: string | undefined;
251
+ variables?: Record<string, any> | undefined;
252
+ refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
253
+ dependencies?: string[] | undefined;
254
+ } | undefined;
255
+ props?: Record<string, any> | undefined;
256
+ states?: Record<string, any> | undefined;
257
+ methods?: Record<string, {
258
+ fn: string;
259
+ params?: Record<string, any> | undefined;
260
+ }> | undefined;
261
+ effects?: {
262
+ fn: string;
263
+ deps?: string[] | undefined;
264
+ }[] | undefined;
265
+ data?: Record<string, any> | undefined;
266
+ render?: any;
267
+ }>;
268
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
269
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
270
+ }, "strip", z.ZodTypeAny, {
271
+ dsl: {
272
+ id: string;
273
+ name?: string | undefined;
274
+ query?: {
275
+ params?: Record<string, any> | undefined;
276
+ key?: string | undefined;
277
+ graphql?: string | undefined;
278
+ sql?: string | undefined;
279
+ variables?: Record<string, any> | undefined;
280
+ refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
281
+ dependencies?: string[] | undefined;
282
+ } | undefined;
283
+ props?: Record<string, any> | undefined;
284
+ states?: Record<string, any> | undefined;
285
+ methods?: Record<string, {
286
+ fn: string;
287
+ params?: Record<string, any> | undefined;
288
+ }> | undefined;
289
+ effects?: {
290
+ fn: string;
291
+ deps?: string[] | undefined;
292
+ }[] | undefined;
293
+ data?: Record<string, any> | undefined;
294
+ render?: any;
295
+ };
296
+ data?: Record<string, any> | undefined;
297
+ context?: Record<string, any> | undefined;
298
+ }, {
299
+ dsl: {
300
+ id: string;
301
+ name?: string | undefined;
302
+ query?: {
303
+ params?: Record<string, any> | undefined;
304
+ key?: string | undefined;
305
+ graphql?: string | undefined;
306
+ sql?: string | undefined;
307
+ variables?: Record<string, any> | undefined;
308
+ refetchPolicy?: "cache-first" | "network-only" | "cache-and-network" | undefined;
309
+ dependencies?: string[] | undefined;
310
+ } | undefined;
311
+ props?: Record<string, any> | undefined;
312
+ states?: Record<string, any> | undefined;
313
+ methods?: Record<string, {
314
+ fn: string;
315
+ params?: Record<string, any> | undefined;
316
+ }> | undefined;
317
+ effects?: {
318
+ fn: string;
319
+ deps?: string[] | undefined;
320
+ }[] | undefined;
321
+ data?: Record<string, any> | undefined;
322
+ render?: any;
323
+ };
324
+ data?: Record<string, any> | undefined;
325
+ context?: Record<string, any> | undefined;
326
+ }>;
327
+ type DSLRendererProps = z.infer<typeof DSLRendererPropsSchema>;
328
+
329
+ declare const MessageSchema: z.ZodObject<{
330
+ id: z.ZodOptional<z.ZodString>;
331
+ type: z.ZodString;
332
+ from: z.ZodObject<{
333
+ id: z.ZodOptional<z.ZodString>;
334
+ type: z.ZodOptional<z.ZodString>;
335
+ }, "strip", z.ZodTypeAny, {
336
+ id?: string | undefined;
337
+ type?: string | undefined;
338
+ }, {
339
+ id?: string | undefined;
340
+ type?: string | undefined;
341
+ }>;
342
+ to: z.ZodOptional<z.ZodObject<{
343
+ id: z.ZodOptional<z.ZodString>;
344
+ type: z.ZodOptional<z.ZodString>;
345
+ }, "strip", z.ZodTypeAny, {
346
+ id?: string | undefined;
347
+ type?: string | undefined;
348
+ }, {
349
+ id?: string | undefined;
350
+ type?: string | undefined;
351
+ }>>;
352
+ payload: z.ZodUnknown;
353
+ }, "strip", z.ZodTypeAny, {
354
+ type: string;
355
+ from: {
356
+ id?: string | undefined;
357
+ type?: string | undefined;
358
+ };
359
+ id?: string | undefined;
360
+ to?: {
361
+ id?: string | undefined;
362
+ type?: string | undefined;
363
+ } | undefined;
364
+ payload?: unknown;
365
+ }, {
366
+ type: string;
367
+ from: {
368
+ id?: string | undefined;
369
+ type?: string | undefined;
370
+ };
371
+ id?: string | undefined;
372
+ to?: {
373
+ id?: string | undefined;
374
+ type?: string | undefined;
375
+ } | undefined;
376
+ payload?: unknown;
377
+ }>;
378
+ type Message = z.infer<typeof MessageSchema>;
379
+ declare const IncomingMessageSchema: z.ZodObject<{
380
+ id: z.ZodOptional<z.ZodString>;
381
+ type: z.ZodString;
382
+ from: z.ZodObject<{
383
+ id: z.ZodOptional<z.ZodString>;
384
+ type: z.ZodOptional<z.ZodString>;
385
+ }, "strip", z.ZodTypeAny, {
386
+ id?: string | undefined;
387
+ type?: string | undefined;
388
+ }, {
389
+ id?: string | undefined;
390
+ type?: string | undefined;
391
+ }>;
392
+ to: z.ZodOptional<z.ZodObject<{
393
+ id: z.ZodOptional<z.ZodString>;
394
+ type: z.ZodOptional<z.ZodString>;
395
+ }, "strip", z.ZodTypeAny, {
396
+ id?: string | undefined;
397
+ type?: string | undefined;
398
+ }, {
399
+ id?: string | undefined;
400
+ type?: string | undefined;
401
+ }>>;
402
+ payload: z.ZodUnknown;
403
+ }, "strip", z.ZodTypeAny, {
404
+ type: string;
405
+ from: {
406
+ id?: string | undefined;
407
+ type?: string | undefined;
408
+ };
409
+ id?: string | undefined;
410
+ to?: {
411
+ id?: string | undefined;
412
+ type?: string | undefined;
413
+ } | undefined;
414
+ payload?: unknown;
415
+ }, {
416
+ type: string;
417
+ from: {
418
+ id?: string | undefined;
419
+ type?: string | undefined;
420
+ };
421
+ id?: string | undefined;
422
+ to?: {
423
+ id?: string | undefined;
424
+ type?: string | undefined;
425
+ } | undefined;
426
+ payload?: unknown;
427
+ }>;
428
+ type IncomingMessage = z.infer<typeof IncomingMessageSchema>;
429
+ type CollectionOperation = 'getMany' | 'getOne' | 'query' | 'mutation' | 'updateOne' | 'deleteOne' | 'createOne';
430
+ type CollectionHandler<TParams = any, TResult = any> = (params: TParams) => Promise<TResult> | TResult;
431
+ type LLMProvider = 'anthropic' | 'groq';
432
+ interface SuperatomSDKConfig {
433
+ url?: string;
434
+ apiKey: string;
435
+ projectId: string;
436
+ userId?: string;
437
+ type?: string;
438
+ bundleDir?: string;
439
+ ANTHROPIC_API_KEY?: string;
440
+ GROQ_API_KEY?: string;
441
+ LLM_PROVIDERS?: LLMProvider[];
442
+ }
443
+
444
+ interface User {
445
+ username: string;
446
+ password: string;
447
+ wsIds: string[];
448
+ }
449
+ interface UsersData {
450
+ users: User[];
451
+ }
452
+ /**
453
+ * UserManager class to handle CRUD operations on users with file persistence
454
+ * and in-memory caching. Changes are synced to file periodically.
455
+ */
456
+ declare class UserManager {
457
+ private users;
458
+ private filePath;
459
+ private hasChanged;
460
+ private syncInterval;
461
+ private syncIntervalMs;
462
+ private isInitialized;
463
+ /**
464
+ * Initialize UserManager with file path and sync interval
465
+ * @param projectId - Project ID to use in file path (default: 'snowflake-dataset')
466
+ * @param syncIntervalMs - Interval in milliseconds to sync changes to file (default: 5000ms)
467
+ */
468
+ constructor(projectId?: string, syncIntervalMs?: number);
469
+ /**
470
+ * Initialize the UserManager by loading users from file and starting sync interval
471
+ */
472
+ init(): Promise<void>;
473
+ /**
474
+ * Load users from the JSON file into memory
475
+ */
476
+ private loadUsersFromFile;
477
+ /**
478
+ * Save users from memory to the JSON file
479
+ */
480
+ private saveUsersToFile;
481
+ /**
482
+ * Start the periodic sync interval
483
+ */
484
+ private startSyncInterval;
485
+ /**
486
+ * Stop the periodic sync interval
487
+ */
488
+ stopSyncInterval(): void;
489
+ /**
490
+ * Force sync users to file immediately
491
+ */
492
+ forceSync(): Promise<void>;
493
+ /**
494
+ * Create a new user
495
+ * @param user - User object to create
496
+ * @returns The created user
497
+ */
498
+ createUser(user: User): User;
499
+ /**
500
+ * Read a user by username
501
+ * @param username - Username to retrieve
502
+ * @returns The user if found, undefined otherwise
503
+ */
504
+ getUser(username: string): User | undefined;
505
+ /**
506
+ * Read all users
507
+ * @returns Array of all users
508
+ */
509
+ getAllUsers(): User[];
510
+ /**
511
+ * Find users by a predicate function
512
+ * @param predicate - Function to filter users
513
+ * @returns Array of matching users
514
+ */
515
+ findUsers(predicate: (user: User) => boolean): User[];
516
+ /**
517
+ * Update an existing user by username
518
+ * @param username - Username of user to update
519
+ * @param updates - Partial user object with fields to update
520
+ * @returns The updated user
521
+ */
522
+ updateUser(username: string, updates: Partial<User>): User;
523
+ /**
524
+ * Delete a user by username
525
+ * @param username - Username of user to delete
526
+ * @returns true if user was deleted, false if not found
527
+ */
528
+ deleteUser(username: string): boolean;
529
+ /**
530
+ * Delete all users
531
+ */
532
+ deleteAllUsers(): void;
533
+ /**
534
+ * Get the count of users
535
+ * @returns Number of users in memory
536
+ */
537
+ getUserCount(): number;
538
+ /**
539
+ * Check if a user exists
540
+ * @param username - Username to check
541
+ * @returns true if user exists, false otherwise
542
+ */
543
+ userExists(username: string): boolean;
544
+ /**
545
+ * Add a WebSocket ID to a user's wsIds array
546
+ * @param username - Username to update
547
+ * @param wsId - WebSocket ID to add
548
+ * @returns true if successful, false if user not found
549
+ */
550
+ addWsId(username: string, wsId: string): boolean;
551
+ /**
552
+ * Remove a WebSocket ID from a user's wsIds array
553
+ * @param username - Username to update
554
+ * @param wsId - WebSocket ID to remove
555
+ * @returns true if successful, false if user not found
556
+ */
557
+ removeWsId(username: string, wsId: string): boolean;
558
+ /**
559
+ * Get the change status
560
+ * @returns true if there are unsaved changes, false otherwise
561
+ */
562
+ hasUnsavedChanges(): boolean;
563
+ /**
564
+ * Cleanup resources and stop sync interval
565
+ */
566
+ destroy(): Promise<void>;
567
+ }
568
+
569
+ /**
570
+ * DashboardManager class to handle CRUD operations on dashboards
571
+ * All operations read/write directly to files (no in-memory caching)
572
+ */
573
+ declare class DashboardManager {
574
+ private dashboardsBasePath;
575
+ private projectId;
576
+ /**
577
+ * Initialize DashboardManager with project ID
578
+ * @param projectId - Project ID to use in file path
579
+ */
580
+ constructor(projectId?: string);
581
+ /**
582
+ * Get the file path for a specific dashboard
583
+ * @param dashboardId - Dashboard ID
584
+ * @returns Full path to dashboard data.json file
585
+ */
586
+ private getDashboardPath;
587
+ /**
588
+ * Create a new dashboard
589
+ * @param dashboardId - Unique dashboard ID
590
+ * @param dashboard - Dashboard data
591
+ * @returns Created dashboard with metadata
592
+ */
593
+ createDashboard(dashboardId: string, dashboard: DSLRendererProps$1): DSLRendererProps$1;
594
+ /**
595
+ * Get a specific dashboard by ID
596
+ * @param dashboardId - Dashboard ID
597
+ * @returns Dashboard data or null if not found
598
+ */
599
+ getDashboard(dashboardId: string): DSLRendererProps$1 | null;
600
+ /**
601
+ * Get all dashboards
602
+ * @returns Array of dashboard objects with their IDs
603
+ */
604
+ getAllDashboards(): Array<{
605
+ dashboardId: string;
606
+ dashboard: DSLRendererProps$1;
607
+ }>;
608
+ /**
609
+ * Update an existing dashboard
610
+ * @param dashboardId - Dashboard ID
611
+ * @param dashboard - Updated dashboard data
612
+ * @returns Updated dashboard or null if not found
613
+ */
614
+ updateDashboard(dashboardId: string, dashboard: DSLRendererProps$1): DSLRendererProps$1 | null;
615
+ /**
616
+ * Delete a dashboard
617
+ * @param dashboardId - Dashboard ID
618
+ * @returns True if deleted, false if not found
619
+ */
620
+ deleteDashboard(dashboardId: string): boolean;
621
+ /**
622
+ * Check if a dashboard exists
623
+ * @param dashboardId - Dashboard ID
624
+ * @returns True if dashboard exists, false otherwise
625
+ */
626
+ dashboardExists(dashboardId: string): boolean;
627
+ /**
628
+ * Get dashboard count
629
+ * @returns Number of dashboards
630
+ */
631
+ getDashboardCount(): number;
632
+ }
633
+
634
+ /**
635
+ * ReportManager class to handle CRUD operations on reports
636
+ * All operations read/write directly to files (no in-memory caching)
637
+ */
638
+ declare class ReportManager {
639
+ private reportsBasePath;
640
+ private projectId;
641
+ /**
642
+ * Initialize ReportManager with project ID
643
+ * @param projectId - Project ID to use in file path
644
+ */
645
+ constructor(projectId?: string);
646
+ /**
647
+ * Get the file path for a specific report
648
+ * @param reportId - Report ID
649
+ * @returns Full path to report data.json file
650
+ */
651
+ private getReportPath;
652
+ /**
653
+ * Create a new report
654
+ * @param reportId - Unique report ID
655
+ * @param report - Report data
656
+ * @returns Created report with metadata
657
+ */
658
+ createReport(reportId: string, report: DSLRendererProps): DSLRendererProps;
659
+ /**
660
+ * Get a specific report by ID
661
+ * @param reportId - Report ID
662
+ * @returns Report data or null if not found
663
+ */
664
+ getReport(reportId: string): DSLRendererProps | null;
665
+ /**
666
+ * Get all reports
667
+ * @returns Array of report objects with their IDs
668
+ */
669
+ getAllReports(): Array<{
670
+ reportId: string;
671
+ report: DSLRendererProps;
672
+ }>;
673
+ /**
674
+ * Update an existing report
675
+ * @param reportId - Report ID
676
+ * @param report - Updated report data
677
+ * @returns Updated report or null if not found
678
+ */
679
+ updateReport(reportId: string, report: DSLRendererProps): DSLRendererProps | null;
680
+ /**
681
+ * Delete a report
682
+ * @param reportId - Report ID
683
+ * @returns True if deleted, false if not found
684
+ */
685
+ deleteReport(reportId: string): boolean;
686
+ /**
687
+ * Check if a report exists
688
+ * @param reportId - Report ID
689
+ * @returns True if report exists, false otherwise
690
+ */
691
+ reportExists(reportId: string): boolean;
692
+ /**
693
+ * Get report count
694
+ * @returns Number of reports
695
+ */
696
+ getReportCount(): number;
697
+ }
698
+
699
+ interface LLMMessages {
700
+ sys: string;
701
+ user: string;
702
+ }
703
+ interface LLMOptions {
704
+ model?: string;
705
+ maxTokens?: number;
706
+ temperature?: number;
707
+ topP?: number;
708
+ apiKey?: string;
709
+ partial?: (chunk: string) => void;
710
+ }
711
+ declare class LLM {
712
+ static text(messages: LLMMessages, options?: LLMOptions): Promise<string>;
713
+ static stream<T = string>(messages: LLMMessages, options?: LLMOptions, json?: boolean): Promise<T extends string ? string : any>;
714
+ /**
715
+ * Parse model string to extract provider and model name
716
+ * @param modelString - Format: "provider/model-name" or just "model-name"
717
+ * @returns [provider, modelName]
718
+ *
719
+ * @example
720
+ * "anthropic/claude-sonnet-4-5" → ["anthropic", "claude-sonnet-4-5"]
721
+ * "groq/gpt-oss-120b" → ["groq", "gpt-oss-120b"]
722
+ * "claude-sonnet-4-5" → ["anthropic", "claude-sonnet-4-5"] (default)
723
+ */
724
+ private static _parseModel;
725
+ private static _anthropicText;
726
+ private static _anthropicStream;
727
+ private static _groqText;
728
+ private static _groqStream;
729
+ /**
730
+ * Parse JSON string, handling markdown code blocks and surrounding text
731
+ * Enhanced version from anthropic.ts implementation
732
+ * @param text - Text that may contain JSON wrapped in ```json...``` or with surrounding text
733
+ * @returns Parsed JSON object
734
+ */
735
+ private static _parseJSON;
736
+ }
737
+
738
+ interface CapturedLog {
739
+ timestamp: number;
740
+ level: 'info' | 'error' | 'warn' | 'debug';
741
+ message: string;
742
+ type?: 'explanation' | 'query' | 'general';
743
+ data?: Record<string, any>;
744
+ }
745
+ /**
746
+ * UILogCollector captures logs during user prompt processing
747
+ * and sends them to runtime via ui_logs message with uiBlockId as the message id
748
+ * Logs are sent in real-time for streaming effect in the UI
749
+ */
750
+ declare class UILogCollector {
751
+ private logs;
752
+ private uiBlockId;
753
+ private clientId;
754
+ private sendMessage;
755
+ constructor(clientId: string, sendMessage: (message: Message) => void, uiBlockId?: string);
756
+ /**
757
+ * Check if logging is enabled (uiBlockId is provided)
758
+ */
759
+ isEnabled(): boolean;
760
+ /**
761
+ * Add a log entry with timestamp and immediately send to runtime
762
+ */
763
+ private addLog;
764
+ /**
765
+ * Send a single log to runtime immediately
766
+ */
767
+ private sendLogImmediately;
768
+ /**
769
+ * Log info message
770
+ */
771
+ info(message: string, type?: 'explanation' | 'query' | 'general', data?: Record<string, any>): void;
772
+ /**
773
+ * Log error message
774
+ */
775
+ error(message: string, type?: 'explanation' | 'query' | 'general', data?: Record<string, any>): void;
776
+ /**
777
+ * Log warning message
778
+ */
779
+ warn(message: string, type?: 'explanation' | 'query' | 'general', data?: Record<string, any>): void;
780
+ /**
781
+ * Log debug message
782
+ */
783
+ debug(message: string, type?: 'explanation' | 'query' | 'general', data?: Record<string, any>): void;
784
+ /**
785
+ * Log LLM explanation with typed metadata
786
+ */
787
+ logExplanation(message: string, explanation: string, data?: Record<string, any>): void;
788
+ /**
789
+ * Log generated query with typed metadata
790
+ */
791
+ logQuery(message: string, query: string, data?: Record<string, any>): void;
792
+ /**
793
+ * Send all collected logs at once (optional, for final summary)
794
+ */
795
+ sendAllLogs(): void;
796
+ /**
797
+ * Get all collected logs
798
+ */
799
+ getLogs(): CapturedLog[];
800
+ /**
801
+ * Clear all logs
802
+ */
803
+ clearLogs(): void;
804
+ /**
805
+ * Set uiBlockId (in case it's provided later)
806
+ */
807
+ setUIBlockId(uiBlockId: string): void;
808
+ }
809
+
810
+ /**
811
+ * Represents an action that can be performed on a UIBlock
812
+ */
813
+ interface Action {
814
+ id: string;
815
+ name: string;
816
+ type: string;
817
+ [key: string]: any;
818
+ }
819
+
820
+ /**
821
+ * UIBlock represents a single user and assistant message block in a thread
822
+ * Contains user question, component metadata, component data, and available actions
823
+ */
824
+ declare class UIBlock {
825
+ private id;
826
+ private userQuestion;
827
+ private generatedComponentMetadata;
828
+ private componentData;
829
+ private actions;
830
+ private createdAt;
831
+ /**
832
+ * Creates a new UIBlock instance
833
+ * @param userQuestion - The user's question or input
834
+ * @param componentData - The component data object
835
+ * @param generatedComponentMetadata - Optional metadata about the generated component
836
+ * @param actions - Optional array of available actions
837
+ * @param id - Optional custom ID, generates UUID if not provided
838
+ */
839
+ constructor(userQuestion: string, componentData?: Record<string, any>, generatedComponentMetadata?: Record<string, any>, actions?: Action[], id?: string);
840
+ /**
841
+ * Get the UIBlock ID
842
+ */
843
+ getId(): string;
844
+ /**
845
+ * Get the user question
846
+ */
847
+ getUserQuestion(): string;
848
+ /**
849
+ * Set or update the user question
850
+ */
851
+ setUserQuestion(question: string): void;
852
+ /**
853
+ * Get component metadata
854
+ */
855
+ getComponentMetadata(): Record<string, any>;
856
+ /**
857
+ * Set or update component metadata
858
+ */
859
+ setComponentMetadata(metadata: Record<string, any>): void;
860
+ /**
861
+ * Get component data
862
+ */
863
+ getComponentData(): Record<string, any>;
864
+ /**
865
+ * Calculate size of data in bytes
866
+ */
867
+ private getDataSizeInBytes;
868
+ /**
869
+ * Limit array data to maximum rows
870
+ */
871
+ private limitArrayData;
872
+ /**
873
+ * Check if data exceeds size limit
874
+ */
875
+ private exceedsSizeLimit;
876
+ /**
877
+ * Process and limit data before storing
878
+ */
879
+ private processDataForStorage;
880
+ /**
881
+ * Set or update component data with size and row limits
882
+ */
883
+ setComponentData(data: Record<string, any>): void;
884
+ /**
885
+ * Get all actions (only if they are resolved, not if fetching)
886
+ */
887
+ getActions(): Action[] | null | Promise<Action[]>;
888
+ /**
889
+ * Get or fetch actions
890
+ * If actions don't exist or are a Promise, calls the generateFn and stores the promise
891
+ * If actions already exist, returns them
892
+ * @param generateFn - Async function to generate actions
893
+ * @returns Promise resolving to Action[]
894
+ */
895
+ getOrFetchActions(generateFn: () => Promise<Action[]>): Promise<Action[]>;
896
+ /**
897
+ * Add a single action (only if actions are resolved)
898
+ */
899
+ addAction(action: Action): void;
900
+ /**
901
+ * Add multiple actions (only if actions are resolved)
902
+ */
903
+ addActions(actions: Action[]): void;
904
+ /**
905
+ * Remove an action by ID (only if actions are resolved)
906
+ */
907
+ removeAction(actionId: string): boolean;
908
+ /**
909
+ * Clear all actions
910
+ */
911
+ clearActions(): void;
912
+ /**
913
+ * Get creation timestamp
914
+ */
915
+ getCreatedAt(): Date;
916
+ /**
917
+ * Convert UIBlock to JSON-serializable object
918
+ */
919
+ toJSON(): Record<string, any>;
920
+ }
921
+
922
+ /**
923
+ * Thread represents a conversation thread containing multiple UIBlocks
924
+ * Each UIBlock in a thread represents a user question and assistant response pair
925
+ */
926
+ declare class Thread {
927
+ private id;
928
+ private uiblocks;
929
+ private createdAt;
930
+ /**
931
+ * Creates a new Thread instance
932
+ * @param id - Optional custom ID, generates UUID if not provided
933
+ */
934
+ constructor(id?: string);
935
+ /**
936
+ * Get the thread ID
937
+ */
938
+ getId(): string;
939
+ /**
940
+ * Add a UIBlock to the thread
941
+ */
942
+ addUIBlock(uiblock: UIBlock): void;
943
+ /**
944
+ * Get a UIBlock by ID
945
+ */
946
+ getUIBlock(id: string): UIBlock | undefined;
947
+ /**
948
+ * Get all UIBlocks in the thread
949
+ */
950
+ getUIBlocks(): UIBlock[];
951
+ /**
952
+ * Get UIBlocks as a Map
953
+ */
954
+ getUIBlocksMap(): Map<string, UIBlock>;
955
+ /**
956
+ * Remove a UIBlock by ID
957
+ */
958
+ removeUIBlock(id: string): boolean;
959
+ /**
960
+ * Check if UIBlock exists
961
+ */
962
+ hasUIBlock(id: string): boolean;
963
+ /**
964
+ * Get number of UIBlocks in the thread
965
+ */
966
+ getUIBlockCount(): number;
967
+ /**
968
+ * Clear all UIBlocks from the thread
969
+ */
970
+ clear(): void;
971
+ /**
972
+ * Get creation timestamp
973
+ */
974
+ getCreatedAt(): Date;
975
+ /**
976
+ * Get conversation context from recent UIBlocks (excluding current one)
977
+ * Returns formatted string with previous questions and component summaries
978
+ * @param limit - Maximum number of previous UIBlocks to include (default: 5)
979
+ * @param currentUIBlockId - ID of current UIBlock to exclude from context (optional)
980
+ * @returns Formatted conversation history string
981
+ */
982
+ getConversationContext(limit?: number, currentUIBlockId?: string): string;
983
+ /**
984
+ * Convert Thread to JSON-serializable object
985
+ */
986
+ toJSON(): Record<string, any>;
987
+ }
988
+
989
+ /**
990
+ * ThreadManager manages all threads globally
991
+ * Provides methods to create, retrieve, and delete threads
992
+ */
993
+ declare class ThreadManager {
994
+ private static instance;
995
+ private threads;
996
+ private constructor();
997
+ /**
998
+ * Get singleton instance of ThreadManager
999
+ */
1000
+ static getInstance(): ThreadManager;
1001
+ /**
1002
+ * Create a new thread
1003
+ * @param id - Optional custom ID, generates UUID if not provided
1004
+ * @returns The created Thread instance
1005
+ */
1006
+ createThread(id?: string): Thread;
1007
+ /**
1008
+ * Get a thread by ID
1009
+ */
1010
+ getThread(id: string): Thread | undefined;
1011
+ /**
1012
+ * Get all threads
1013
+ */
1014
+ getAllThreads(): Thread[];
1015
+ /**
1016
+ * Get threads as a Map
1017
+ */
1018
+ getThreadsMap(): Map<string, Thread>;
1019
+ /**
1020
+ * Delete a thread by ID
1021
+ */
1022
+ deleteThread(id: string): boolean;
1023
+ /**
1024
+ * Check if thread exists
1025
+ */
1026
+ hasThread(id: string): boolean;
1027
+ /**
1028
+ * Get number of threads
1029
+ */
1030
+ getThreadCount(): number;
1031
+ /**
1032
+ * Clear all threads
1033
+ */
1034
+ clearAll(): void;
1035
+ /**
1036
+ * Find a UIBlock by ID across all threads
1037
+ * @param uiBlockId - The UIBlock ID to search for
1038
+ * @returns Object with thread and uiBlock if found, undefined otherwise
1039
+ */
1040
+ findUIBlockById(uiBlockId: string): {
1041
+ thread: Thread;
1042
+ uiBlock: UIBlock;
1043
+ } | undefined;
1044
+ /**
1045
+ * Convert all threads to JSON-serializable object
1046
+ */
1047
+ toJSON(): Record<string, any>;
1048
+ }
1049
+
1050
+ /**
1051
+ * CleanupService handles cleanup of old threads and UIBlocks
1052
+ * to prevent memory bloat and maintain optimal performance
1053
+ */
1054
+ declare class CleanupService {
1055
+ private static instance;
1056
+ private cleanupInterval;
1057
+ private constructor();
1058
+ /**
1059
+ * Get singleton instance of CleanupService
1060
+ */
1061
+ static getInstance(): CleanupService;
1062
+ /**
1063
+ * Clean up old threads based on retention period
1064
+ * @param retentionDays - Number of days to keep threads (defaults to config)
1065
+ * @returns Number of threads deleted
1066
+ */
1067
+ cleanupOldThreads(retentionDays?: number): number;
1068
+ /**
1069
+ * Clean up old UIBlocks within threads based on retention period
1070
+ * @param retentionDays - Number of days to keep UIBlocks (defaults to config)
1071
+ * @returns Object with number of UIBlocks deleted per thread
1072
+ */
1073
+ cleanupOldUIBlocks(retentionDays?: number): {
1074
+ [threadId: string]: number;
1075
+ };
1076
+ /**
1077
+ * Clear all component data from UIBlocks to free memory
1078
+ * Keeps metadata but removes the actual data
1079
+ * @param retentionDays - Number of days to keep full data (defaults to config)
1080
+ * @returns Number of UIBlocks whose data was cleared
1081
+ */
1082
+ clearOldUIBlockData(retentionDays?: number): number;
1083
+ /**
1084
+ * Run full cleanup (threads, UIBlocks, and data)
1085
+ * @returns Cleanup statistics
1086
+ */
1087
+ runFullCleanup(): {
1088
+ threadsDeleted: number;
1089
+ uiblocksDeleted: {
1090
+ [threadId: string]: number;
1091
+ };
1092
+ dataCleared: number;
1093
+ };
1094
+ /**
1095
+ * Start automatic cleanup at regular intervals
1096
+ * @param intervalHours - Hours between cleanup runs (default: 24)
1097
+ */
1098
+ startAutoCleanup(intervalHours?: number): void;
1099
+ /**
1100
+ * Stop automatic cleanup
1101
+ */
1102
+ stopAutoCleanup(): void;
1103
+ /**
1104
+ * Check if auto cleanup is running
1105
+ */
1106
+ isAutoCleanupRunning(): boolean;
1107
+ /**
1108
+ * Get current memory usage statistics
1109
+ */
1110
+ getMemoryStats(): {
1111
+ threadCount: number;
1112
+ totalUIBlocks: number;
1113
+ avgUIBlocksPerThread: number;
1114
+ };
1115
+ }
1116
+
1117
+ /**
1118
+ * Configuration for data storage limits in UIBlocks
1119
+ */
1120
+ declare const STORAGE_CONFIG: {
1121
+ /**
1122
+ * Maximum number of rows to store in UIBlock data
1123
+ */
1124
+ MAX_ROWS_PER_BLOCK: number;
1125
+ /**
1126
+ * Maximum size in bytes per UIBlock (1MB)
1127
+ */
1128
+ MAX_SIZE_PER_BLOCK_BYTES: number;
1129
+ /**
1130
+ * Number of days to keep threads before cleanup
1131
+ */
1132
+ THREAD_RETENTION_DAYS: number;
1133
+ /**
1134
+ * Number of days to keep UIBlocks before cleanup
1135
+ */
1136
+ UIBLOCK_RETENTION_DAYS: number;
1137
+ };
1138
+
1139
+ /**
1140
+ * Configuration for conversation context and history management
1141
+ */
1142
+ declare const CONTEXT_CONFIG: {
1143
+ /**
1144
+ * Maximum number of previous UIBlocks to include as conversation context
1145
+ * Set to 0 to disable conversation history
1146
+ * Higher values provide more context but may increase token usage
1147
+ */
1148
+ MAX_CONVERSATION_CONTEXT_BLOCKS: number;
1149
+ };
1150
+
1151
+ declare const SDK_VERSION = "0.0.8";
1152
+ type MessageTypeHandler = (message: IncomingMessage) => void | Promise<void>;
1153
+ declare class SuperatomSDK {
1154
+ private ws;
1155
+ private url;
1156
+ private apiKey;
1157
+ private projectId;
1158
+ private userId;
1159
+ private type;
1160
+ private bundleDir;
1161
+ private messageHandlers;
1162
+ private messageTypeHandlers;
1163
+ private connected;
1164
+ private reconnectAttempts;
1165
+ private maxReconnectAttempts;
1166
+ private collections;
1167
+ private components;
1168
+ private anthropicApiKey;
1169
+ private groqApiKey;
1170
+ private llmProviders;
1171
+ private userManager;
1172
+ private dashboardManager;
1173
+ private reportManager;
1174
+ constructor(config: SuperatomSDKConfig);
1175
+ /**
1176
+ * Initialize UserManager for the project
1177
+ */
1178
+ private initializeUserManager;
1179
+ /**
1180
+ * Get the UserManager instance for this SDK
1181
+ */
1182
+ getUserManager(): UserManager;
1183
+ /**
1184
+ * Initialize DashboardManager for the project
1185
+ */
1186
+ private initializeDashboardManager;
1187
+ /**
1188
+ * Get the DashboardManager instance for this SDK
1189
+ */
1190
+ getDashboardManager(): DashboardManager;
1191
+ /**
1192
+ * Initialize ReportManager for the project
1193
+ */
1194
+ private initializeReportManager;
1195
+ /**
1196
+ * Get the ReportManager instance for this SDK
1197
+ */
1198
+ getReportManager(): ReportManager;
1199
+ /**
1200
+ * Connect to the Superatom WebSocket service
1201
+ */
1202
+ connect(): Promise<void>;
1203
+ /**
1204
+ * Handle incoming WebSocket messages
1205
+ */
1206
+ private handleMessage;
1207
+ /**
1208
+ * Send a message to the Superatom service
1209
+ */
1210
+ send(message: Message): void;
1211
+ /**
1212
+ * Register a message handler to receive all messages
1213
+ */
1214
+ onMessage(handler: (message: IncomingMessage) => void): () => void;
1215
+ /**
1216
+ * Register a handler for a specific message type
1217
+ */
1218
+ onMessageType(type: string, handler: MessageTypeHandler): () => void;
1219
+ /**
1220
+ * Disconnect from the WebSocket service
1221
+ */
1222
+ disconnect(): void;
1223
+ /**
1224
+ * Cleanup and disconnect - stops reconnection attempts and closes the connection
1225
+ */
1226
+ destroy(): Promise<void>;
1227
+ /**
1228
+ * Check if the SDK is currently connected
1229
+ */
1230
+ isConnected(): boolean;
1231
+ /**
1232
+ * Register a collection handler for data operations
1233
+ */
1234
+ addCollection<TParams = any, TResult = any>(collectionName: string, operation: CollectionOperation | string, handler: CollectionHandler<TParams, TResult>): void;
1235
+ private handleReconnect;
1236
+ private storeComponents;
1237
+ }
1238
+
1239
+ export { type Action, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CollectionHandler, type CollectionOperation, type IncomingMessage, LLM, type Message, SDK_VERSION, STORAGE_CONFIG, SuperatomSDK, type SuperatomSDKConfig, Thread, ThreadManager, UIBlock, UILogCollector, type User, UserManager, type UsersData };