@superatomai/sdk-web 0.0.9 → 0.0.11

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/dist/index.js CHANGED
@@ -549,6 +549,46 @@ z.object({
549
549
  to: MessageParticipantSchema.optional(),
550
550
  payload: ReportsResponsePayloadSchema
551
551
  });
552
+ var BookmarkDataSchema = z.object({
553
+ id: z.number().optional(),
554
+ uiblock: z.any(),
555
+ // JSON object
556
+ created_at: z.string().optional(),
557
+ updated_at: z.string().optional()
558
+ });
559
+ var BookmarksRequestPayloadSchema = z.object({
560
+ operation: z.enum(["create", "update", "delete", "getAll", "getOne", "getByUser", "getByThread"]),
561
+ data: z.object({
562
+ id: z.number().optional(),
563
+ userId: z.number().optional(),
564
+ threadId: z.string().optional(),
565
+ uiblock: z.any().optional()
566
+ }).optional()
567
+ });
568
+ var BookmarksRequestMessageSchema = z.object({
569
+ id: z.string(),
570
+ type: z.literal("BOOKMARKS"),
571
+ from: MessageParticipantSchema,
572
+ to: MessageParticipantSchema.optional(),
573
+ payload: BookmarksRequestPayloadSchema
574
+ });
575
+ var BookmarksResponsePayloadSchema = z.object({
576
+ success: z.boolean(),
577
+ error: z.string().optional(),
578
+ data: z.union([
579
+ BookmarkDataSchema,
580
+ z.array(BookmarkDataSchema)
581
+ ]).optional(),
582
+ count: z.number().optional(),
583
+ message: z.string().optional()
584
+ });
585
+ z.object({
586
+ id: z.string(),
587
+ type: z.literal("BOOKMARKS_RES"),
588
+ from: MessageParticipantSchema,
589
+ to: MessageParticipantSchema.optional(),
590
+ payload: BookmarksResponsePayloadSchema
591
+ });
552
592
  var ClientConfigSchema = z.object({
553
593
  userId: z.string(),
554
594
  projectId: z.string(),
@@ -571,16 +611,22 @@ __export(services_exports, {
571
611
  QuerySpecSchema: () => QuerySpecSchema,
572
612
  UIComponentSchema: () => UIComponentSchema,
573
613
  UIElementSchema: () => UIElementSchema,
614
+ createBookmark: () => createBookmark,
574
615
  createDashboard: () => createDashboard,
575
616
  createReport: () => createReport,
576
617
  createUser: () => createUser,
618
+ deleteBookmark: () => deleteBookmark,
577
619
  deleteDashboard: () => deleteDashboard,
578
620
  deleteReport: () => deleteReport,
579
621
  deleteUser: () => deleteUser,
580
622
  getActions: () => getActions,
623
+ getAllBookmarks: () => getAllBookmarks,
581
624
  getAllDashboards: () => getAllDashboards,
582
625
  getAllReports: () => getAllReports,
583
626
  getAllUsers: () => getAllUsers,
627
+ getBookmark: () => getBookmark,
628
+ getBookmarksByThread: () => getBookmarksByThread,
629
+ getBookmarksByUser: () => getBookmarksByUser,
584
630
  getComponentSuggestions: () => getComponentSuggestions,
585
631
  getDashboard: () => getDashboard,
586
632
  getReport: () => getReport,
@@ -592,6 +638,7 @@ __export(services_exports, {
592
638
  sendComponents: () => sendComponents,
593
639
  sendUserPromptRequest: () => sendUserPromptRequest,
594
640
  sendUserPromptSuggestionsRequest: () => sendUserPromptSuggestionsRequest,
641
+ updateBookmark: () => updateBookmark,
595
642
  updateDashboard: () => updateDashboard,
596
643
  updateReport: () => updateReport,
597
644
  updateUser: () => updateUser
@@ -1177,6 +1224,173 @@ async function getReport(client, reportId, timeout) {
1177
1224
  };
1178
1225
  }
1179
1226
 
1227
+ // src/services/bookmarks/index.ts
1228
+ async function createBookmark(client, userId, uiblock, threadId, timeout) {
1229
+ const messageId = `bookmarks_create_${Date.now()}`;
1230
+ const message = BookmarksRequestMessageSchema.parse({
1231
+ id: messageId,
1232
+ type: "BOOKMARKS",
1233
+ from: { type: client.type },
1234
+ to: { type: "data-agent" },
1235
+ payload: {
1236
+ operation: "create",
1237
+ data: {
1238
+ userId,
1239
+ threadId,
1240
+ uiblock
1241
+ }
1242
+ }
1243
+ });
1244
+ const response = await client.sendWithResponse(message, timeout);
1245
+ const payload = response.payload;
1246
+ return {
1247
+ success: payload.success,
1248
+ error: payload.error,
1249
+ message: payload.message,
1250
+ data: Array.isArray(payload.data) ? payload.data[0] : payload.data
1251
+ };
1252
+ }
1253
+ async function updateBookmark(client, id, uiblock, timeout) {
1254
+ const messageId = `bookmarks_update_${Date.now()}`;
1255
+ const message = BookmarksRequestMessageSchema.parse({
1256
+ id: messageId,
1257
+ type: "BOOKMARKS",
1258
+ from: { type: client.type },
1259
+ to: { type: "data-agent" },
1260
+ payload: {
1261
+ operation: "update",
1262
+ data: {
1263
+ id,
1264
+ uiblock
1265
+ }
1266
+ }
1267
+ });
1268
+ const response = await client.sendWithResponse(message, timeout);
1269
+ const payload = response.payload;
1270
+ return {
1271
+ success: payload.success,
1272
+ error: payload.error,
1273
+ message: payload.message,
1274
+ data: Array.isArray(payload.data) ? payload.data[0] : payload.data
1275
+ };
1276
+ }
1277
+ async function deleteBookmark(client, id, timeout) {
1278
+ const messageId = `bookmarks_delete_${Date.now()}`;
1279
+ const message = BookmarksRequestMessageSchema.parse({
1280
+ id: messageId,
1281
+ type: "BOOKMARKS",
1282
+ from: { type: client.type },
1283
+ to: { type: "data-agent" },
1284
+ payload: {
1285
+ operation: "delete",
1286
+ data: {
1287
+ id
1288
+ }
1289
+ }
1290
+ });
1291
+ const response = await client.sendWithResponse(message, timeout);
1292
+ const payload = response.payload;
1293
+ return {
1294
+ success: payload.success,
1295
+ error: payload.error,
1296
+ message: payload.message,
1297
+ data: Array.isArray(payload.data) ? payload.data[0] : payload.data
1298
+ };
1299
+ }
1300
+ async function getAllBookmarks(client, timeout) {
1301
+ const messageId = `bookmarks_getall_${Date.now()}`;
1302
+ const message = BookmarksRequestMessageSchema.parse({
1303
+ id: messageId,
1304
+ type: "BOOKMARKS",
1305
+ from: { type: client.type },
1306
+ to: { type: "data-agent" },
1307
+ payload: {
1308
+ operation: "getAll"
1309
+ }
1310
+ });
1311
+ const response = await client.sendWithResponse(message, timeout);
1312
+ const payload = response.payload;
1313
+ return {
1314
+ success: payload.success,
1315
+ error: payload.error,
1316
+ data: Array.isArray(payload.data) ? payload.data : payload.data ? [payload.data] : [],
1317
+ count: payload.count,
1318
+ message: payload.message
1319
+ };
1320
+ }
1321
+ async function getBookmark(client, id, timeout) {
1322
+ const messageId = `bookmarks_getone_${Date.now()}`;
1323
+ const message = BookmarksRequestMessageSchema.parse({
1324
+ id: messageId,
1325
+ type: "BOOKMARKS",
1326
+ from: { type: client.type },
1327
+ to: { type: "data-agent" },
1328
+ payload: {
1329
+ operation: "getOne",
1330
+ data: {
1331
+ id
1332
+ }
1333
+ }
1334
+ });
1335
+ const response = await client.sendWithResponse(message, timeout);
1336
+ const payload = response.payload;
1337
+ return {
1338
+ success: payload.success,
1339
+ error: payload.error,
1340
+ data: Array.isArray(payload.data) ? payload.data[0] : payload.data,
1341
+ message: payload.message
1342
+ };
1343
+ }
1344
+ async function getBookmarksByUser(client, userId, threadId, timeout) {
1345
+ const messageId = `bookmarks_getbyuser_${Date.now()}`;
1346
+ const message = BookmarksRequestMessageSchema.parse({
1347
+ id: messageId,
1348
+ type: "BOOKMARKS",
1349
+ from: { type: client.type },
1350
+ to: { type: "data-agent" },
1351
+ payload: {
1352
+ operation: "getByUser",
1353
+ data: {
1354
+ userId,
1355
+ threadId
1356
+ }
1357
+ }
1358
+ });
1359
+ const response = await client.sendWithResponse(message, timeout);
1360
+ const payload = response.payload;
1361
+ return {
1362
+ success: payload.success,
1363
+ error: payload.error,
1364
+ data: Array.isArray(payload.data) ? payload.data : payload.data ? [payload.data] : [],
1365
+ count: payload.count,
1366
+ message: payload.message
1367
+ };
1368
+ }
1369
+ async function getBookmarksByThread(client, threadId, timeout) {
1370
+ const messageId = `bookmarks_getbythread_${Date.now()}`;
1371
+ const message = BookmarksRequestMessageSchema.parse({
1372
+ id: messageId,
1373
+ type: "BOOKMARKS",
1374
+ from: { type: client.type },
1375
+ to: { type: "data-agent" },
1376
+ payload: {
1377
+ operation: "getByThread",
1378
+ data: {
1379
+ threadId
1380
+ }
1381
+ }
1382
+ });
1383
+ const response = await client.sendWithResponse(message, timeout);
1384
+ const payload = response.payload;
1385
+ return {
1386
+ success: payload.success,
1387
+ error: payload.error,
1388
+ data: Array.isArray(payload.data) ? payload.data : payload.data ? [payload.data] : [],
1389
+ count: payload.count,
1390
+ message: payload.message
1391
+ };
1392
+ }
1393
+
1180
1394
  // src/services/actions.ts
1181
1395
  async function getActions(client, options) {
1182
1396
  const messageId = `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
@@ -1617,6 +1831,64 @@ var SuperatomClient = class {
1617
1831
  this.log("info", "Fetching dashboard:", dashboardId);
1618
1832
  return getDashboard(this, dashboardId, timeout);
1619
1833
  }
1834
+ // ==================== Bookmark Management Methods ====================
1835
+ // These methods delegate to bookmark service for bookmark CRUD operations
1836
+ /**
1837
+ * Create a new bookmark
1838
+ * Delegates to bookmarks service
1839
+ */
1840
+ async createBookmark(userId, uiblock, threadId, timeout) {
1841
+ this.log("info", "Creating bookmark for user:", userId);
1842
+ return createBookmark(this, userId, uiblock, threadId, timeout);
1843
+ }
1844
+ /**
1845
+ * Update an existing bookmark
1846
+ * Delegates to bookmarks service
1847
+ */
1848
+ async updateBookmark(id, uiblock, timeout) {
1849
+ this.log("info", "Updating bookmark:", id);
1850
+ return updateBookmark(this, id, uiblock, timeout);
1851
+ }
1852
+ /**
1853
+ * Delete a bookmark
1854
+ * Delegates to bookmarks service
1855
+ */
1856
+ async deleteBookmark(id, timeout) {
1857
+ this.log("info", "Deleting bookmark:", id);
1858
+ return deleteBookmark(this, id, timeout);
1859
+ }
1860
+ /**
1861
+ * Get all bookmarks
1862
+ * Delegates to bookmarks service
1863
+ */
1864
+ async getAllBookmarks(timeout) {
1865
+ this.log("info", "Fetching all bookmarks");
1866
+ return getAllBookmarks(this, timeout);
1867
+ }
1868
+ /**
1869
+ * Get a specific bookmark by ID
1870
+ * Delegates to bookmarks service
1871
+ */
1872
+ async getBookmark(id, timeout) {
1873
+ this.log("info", "Fetching bookmark:", id);
1874
+ return getBookmark(this, id, timeout);
1875
+ }
1876
+ /**
1877
+ * Get bookmarks by user ID (and optionally by thread ID)
1878
+ * Delegates to bookmarks service
1879
+ */
1880
+ async getBookmarksByUser(userId, threadId, timeout) {
1881
+ this.log("info", "Fetching bookmarks for user:", userId);
1882
+ return getBookmarksByUser(this, userId, threadId, timeout);
1883
+ }
1884
+ /**
1885
+ * Get bookmarks by thread ID
1886
+ * Delegates to bookmarks service
1887
+ */
1888
+ async getBookmarksByThread(threadId, timeout) {
1889
+ this.log("info", "Fetching bookmarks for thread:", threadId);
1890
+ return getBookmarksByThread(this, threadId, timeout);
1891
+ }
1620
1892
  // ==================== Report Management Methods ====================
1621
1893
  // These methods delegate to report service for admin report CRUD operations
1622
1894
  /**