@superatomai/sdk-web 0.0.18 → 0.0.20
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.cjs +113 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +84 -1
- package/dist/index.d.ts +84 -1
- package/dist/index.js +113 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -332,6 +332,42 @@ var UserPromptSuggestionsResponseMessageSchema = zod.z.object({
|
|
|
332
332
|
to: MessageParticipantSchema.optional(),
|
|
333
333
|
payload: UserPromptSuggestionsResponsePayloadSchema
|
|
334
334
|
});
|
|
335
|
+
var DashCompRequestPayloadSchema = zod.z.object({
|
|
336
|
+
prompt: zod.z.string(),
|
|
337
|
+
SA_RUNTIME: zod.z.object({
|
|
338
|
+
threadId: zod.z.string().optional(),
|
|
339
|
+
uiBlockId: zod.z.string().optional()
|
|
340
|
+
}).optional()
|
|
341
|
+
});
|
|
342
|
+
var DashCompRequestMessageSchema = zod.z.object({
|
|
343
|
+
id: zod.z.string(),
|
|
344
|
+
type: zod.z.literal("DASH_COMP_REQ"),
|
|
345
|
+
from: MessageParticipantSchema,
|
|
346
|
+
to: MessageParticipantSchema.optional(),
|
|
347
|
+
payload: DashCompRequestPayloadSchema
|
|
348
|
+
});
|
|
349
|
+
zod.z.object({
|
|
350
|
+
toolId: zod.z.string(),
|
|
351
|
+
toolName: zod.z.string(),
|
|
352
|
+
action: zod.z.enum(["get", "create", "update", "delete"]),
|
|
353
|
+
params: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
354
|
+
});
|
|
355
|
+
var DashCompResponsePayloadSchema = zod.z.object({
|
|
356
|
+
success: zod.z.boolean(),
|
|
357
|
+
errors: zod.z.array(zod.z.string()).optional(),
|
|
358
|
+
data: zod.z.object({
|
|
359
|
+
component: ComponentSchema.optional(),
|
|
360
|
+
reasoning: zod.z.string().optional(),
|
|
361
|
+
dataSource: zod.z.enum(["database", "external_tool", "none"]).optional()
|
|
362
|
+
}).optional()
|
|
363
|
+
});
|
|
364
|
+
zod.z.object({
|
|
365
|
+
id: zod.z.string(),
|
|
366
|
+
type: zod.z.literal("DASH_COMP_RES"),
|
|
367
|
+
from: MessageParticipantSchema,
|
|
368
|
+
to: MessageParticipantSchema.optional(),
|
|
369
|
+
payload: DashCompResponsePayloadSchema
|
|
370
|
+
});
|
|
335
371
|
var BundleRequestPayloadSchema = zod.z.object({
|
|
336
372
|
devbundlereq: zod.z.boolean().optional().default(false)
|
|
337
373
|
});
|
|
@@ -534,6 +570,7 @@ var DashboardsRequestPayloadSchema = zod.z.object({
|
|
|
534
570
|
published: zod.z.boolean().optional(),
|
|
535
571
|
createdBy: zod.z.number().optional(),
|
|
536
572
|
updatedBy: zod.z.number().optional(),
|
|
573
|
+
allowedUsers: zod.z.array(zod.z.number()).optional(),
|
|
537
574
|
dashboard: DSLRendererPropsSchema.optional(),
|
|
538
575
|
// Query operation fields
|
|
539
576
|
filters: DashboardQueryFiltersSchema.optional(),
|
|
@@ -871,6 +908,7 @@ __export(services_exports, {
|
|
|
871
908
|
sendAuthLoginRequest: () => sendAuthLoginRequest,
|
|
872
909
|
sendAuthVerifyRequest: () => sendAuthVerifyRequest,
|
|
873
910
|
sendComponents: () => sendComponents,
|
|
911
|
+
sendDashCompRequest: () => sendDashCompRequest,
|
|
874
912
|
sendUserPromptRequest: () => sendUserPromptRequest,
|
|
875
913
|
sendUserPromptSuggestionsRequest: () => sendUserPromptSuggestionsRequest,
|
|
876
914
|
updateBookmark: () => updateBookmark,
|
|
@@ -1251,7 +1289,7 @@ async function queryUsers(client, options = {}, timeout) {
|
|
|
1251
1289
|
|
|
1252
1290
|
// src/services/dashboards/index.ts
|
|
1253
1291
|
async function createDashboard(client, options, timeout) {
|
|
1254
|
-
const { dashboardId, projectId, name, description, published, createdBy, dashboard } = options;
|
|
1292
|
+
const { dashboardId, projectId, name, description, published, createdBy, allowedUsers, dashboard } = options;
|
|
1255
1293
|
const messageId = `dashboards_create_${Date.now()}`;
|
|
1256
1294
|
const message = DashboardsRequestMessageSchema.parse({
|
|
1257
1295
|
id: messageId,
|
|
@@ -1267,6 +1305,7 @@ async function createDashboard(client, options, timeout) {
|
|
|
1267
1305
|
description,
|
|
1268
1306
|
published,
|
|
1269
1307
|
createdBy,
|
|
1308
|
+
allowedUsers,
|
|
1270
1309
|
dashboard
|
|
1271
1310
|
}
|
|
1272
1311
|
}
|
|
@@ -1283,7 +1322,7 @@ async function createDashboard(client, options, timeout) {
|
|
|
1283
1322
|
};
|
|
1284
1323
|
}
|
|
1285
1324
|
async function updateDashboard(client, options, timeout) {
|
|
1286
|
-
const { id, name, description, published, createdBy, updatedBy, dashboard } = options;
|
|
1325
|
+
const { id, name, description, published, createdBy, updatedBy, allowedUsers, dashboard } = options;
|
|
1287
1326
|
const messageId = `dashboards_update_${Date.now()}`;
|
|
1288
1327
|
const message = DashboardsRequestMessageSchema.parse({
|
|
1289
1328
|
id: messageId,
|
|
@@ -1299,6 +1338,7 @@ async function updateDashboard(client, options, timeout) {
|
|
|
1299
1338
|
published,
|
|
1300
1339
|
createdBy,
|
|
1301
1340
|
updatedBy,
|
|
1341
|
+
allowedUsers,
|
|
1302
1342
|
dashboard
|
|
1303
1343
|
}
|
|
1304
1344
|
}
|
|
@@ -2177,6 +2217,51 @@ async function getKbNodeTags(client, timeout) {
|
|
|
2177
2217
|
};
|
|
2178
2218
|
}
|
|
2179
2219
|
|
|
2220
|
+
// src/services/dash-comp.ts
|
|
2221
|
+
async function sendDashCompRequest(client, options) {
|
|
2222
|
+
const { prompt, threadId, uiBlockId, timeout } = options;
|
|
2223
|
+
const messageId = `dash_comp_req_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
2224
|
+
const message = DashCompRequestMessageSchema.parse({
|
|
2225
|
+
id: messageId,
|
|
2226
|
+
type: "DASH_COMP_REQ",
|
|
2227
|
+
from: {
|
|
2228
|
+
type: client.type
|
|
2229
|
+
},
|
|
2230
|
+
to: {
|
|
2231
|
+
type: "data-agent"
|
|
2232
|
+
},
|
|
2233
|
+
payload: {
|
|
2234
|
+
prompt,
|
|
2235
|
+
SA_RUNTIME: threadId || uiBlockId ? {
|
|
2236
|
+
threadId,
|
|
2237
|
+
uiBlockId
|
|
2238
|
+
} : void 0
|
|
2239
|
+
}
|
|
2240
|
+
});
|
|
2241
|
+
try {
|
|
2242
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2243
|
+
const payload = response.payload;
|
|
2244
|
+
if (!payload.success) {
|
|
2245
|
+
return {
|
|
2246
|
+
success: false,
|
|
2247
|
+
errors: payload.errors || ["Unknown error occurred"]
|
|
2248
|
+
};
|
|
2249
|
+
}
|
|
2250
|
+
return {
|
|
2251
|
+
success: true,
|
|
2252
|
+
component: payload.data?.component,
|
|
2253
|
+
reasoning: payload.data?.reasoning,
|
|
2254
|
+
dataSource: payload.data?.dataSource
|
|
2255
|
+
};
|
|
2256
|
+
} catch (error) {
|
|
2257
|
+
const errorMessage = error instanceof Error ? error.message : "Request failed";
|
|
2258
|
+
return {
|
|
2259
|
+
success: false,
|
|
2260
|
+
errors: [errorMessage]
|
|
2261
|
+
};
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2180
2265
|
// src/client.ts
|
|
2181
2266
|
var SuperatomClient = class {
|
|
2182
2267
|
constructor(config) {
|
|
@@ -2844,6 +2929,32 @@ var SuperatomClient = class {
|
|
|
2844
2929
|
this.log("info", "Fetching KB node tags");
|
|
2845
2930
|
return getKbNodeTags(this, timeout);
|
|
2846
2931
|
}
|
|
2932
|
+
// ==================== Dashboard Component Methods ====================
|
|
2933
|
+
// These methods delegate to dash-comp service for component selection
|
|
2934
|
+
/**
|
|
2935
|
+
* Request a dashboard component based on user prompt
|
|
2936
|
+
* Uses LLM to pick the best component and generate props
|
|
2937
|
+
* Supports both database queries and external tools as data sources
|
|
2938
|
+
* Delegates to dash-comp service
|
|
2939
|
+
*
|
|
2940
|
+
* @example
|
|
2941
|
+
* ```typescript
|
|
2942
|
+
* const response = await client.sendDashCompRequest({
|
|
2943
|
+
* prompt: "Show me a bar chart of sales by category",
|
|
2944
|
+
* threadId: "thread-123",
|
|
2945
|
+
* });
|
|
2946
|
+
*
|
|
2947
|
+
* if (response.success && response.component) {
|
|
2948
|
+
* console.log('Component:', response.component.name);
|
|
2949
|
+
* console.log('Props:', response.component.props);
|
|
2950
|
+
* console.log('Data source:', response.dataSource);
|
|
2951
|
+
* }
|
|
2952
|
+
* ```
|
|
2953
|
+
*/
|
|
2954
|
+
async sendDashCompRequest(options) {
|
|
2955
|
+
this.log("info", "Sending dash comp request for prompt:", options.prompt.substring(0, 50) + "...");
|
|
2956
|
+
return sendDashCompRequest(this, options);
|
|
2957
|
+
}
|
|
2847
2958
|
/**
|
|
2848
2959
|
* Internal logging
|
|
2849
2960
|
*/
|