@superatomai/sdk-web 0.0.1-mds
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/README.md +755 -0
- package/dist/index.cjs +3904 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4099 -0
- package/dist/index.d.ts +4099 -0
- package/dist/index.js +3845 -0
- package/dist/index.js.map +1 -0
- package/package.json +41 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,3904 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var ExpressionSchema = zod.z.object({
|
|
11
|
+
$exp: zod.z.string(),
|
|
12
|
+
$deps: zod.z.array(zod.z.string()).optional()
|
|
13
|
+
});
|
|
14
|
+
var BindingSchema = zod.z.object({
|
|
15
|
+
$bind: zod.z.string(),
|
|
16
|
+
$transform: zod.z.array(
|
|
17
|
+
zod.z.object({
|
|
18
|
+
name: zod.z.string(),
|
|
19
|
+
args: zod.z.array(zod.z.any()).optional()
|
|
20
|
+
})
|
|
21
|
+
).optional()
|
|
22
|
+
});
|
|
23
|
+
var ForDirectiveSchema = zod.z.object({
|
|
24
|
+
in: zod.z.union([ExpressionSchema, BindingSchema, zod.z.string()]),
|
|
25
|
+
as: zod.z.string(),
|
|
26
|
+
key: zod.z.string().optional(),
|
|
27
|
+
index: zod.z.string().optional()
|
|
28
|
+
});
|
|
29
|
+
var QuerySpecSchema = zod.z.object({
|
|
30
|
+
graphql: zod.z.string().optional(),
|
|
31
|
+
sql: zod.z.string().optional(),
|
|
32
|
+
variables: zod.z.record(zod.z.string(), zod.z.any()).optional(),
|
|
33
|
+
params: zod.z.record(zod.z.string(), zod.z.any()).optional(),
|
|
34
|
+
key: zod.z.string().optional(),
|
|
35
|
+
refetchPolicy: zod.z.enum(["cache-first", "network-only", "cache-and-network"]).optional(),
|
|
36
|
+
dependencies: zod.z.array(zod.z.string()).optional()
|
|
37
|
+
});
|
|
38
|
+
var UIElementSchema = zod.z.lazy(
|
|
39
|
+
() => zod.z.object({
|
|
40
|
+
id: zod.z.string(),
|
|
41
|
+
type: zod.z.string(),
|
|
42
|
+
key: zod.z.union([zod.z.string(), ExpressionSchema]).optional(),
|
|
43
|
+
props: zod.z.record(zod.z.string(), zod.z.any()).optional(),
|
|
44
|
+
query: QuerySpecSchema.optional(),
|
|
45
|
+
if: ExpressionSchema.optional(),
|
|
46
|
+
elseIf: ExpressionSchema.optional(),
|
|
47
|
+
for: ForDirectiveSchema.optional(),
|
|
48
|
+
"link-to": zod.z.union([
|
|
49
|
+
zod.z.string(),
|
|
50
|
+
ExpressionSchema,
|
|
51
|
+
BindingSchema,
|
|
52
|
+
zod.z.object({
|
|
53
|
+
ui: zod.z.union([zod.z.string(), ExpressionSchema, BindingSchema]),
|
|
54
|
+
params: zod.z.record(zod.z.string(), zod.z.any()).optional()
|
|
55
|
+
})
|
|
56
|
+
]).optional(),
|
|
57
|
+
_meta: zod.z.object({
|
|
58
|
+
id: zod.z.string().optional(),
|
|
59
|
+
version: zod.z.string().optional(),
|
|
60
|
+
created: zod.z.string().optional(),
|
|
61
|
+
lastModified: zod.z.string().optional()
|
|
62
|
+
}).optional(),
|
|
63
|
+
children: zod.z.any().optional(),
|
|
64
|
+
else: UIElementSchema.optional(),
|
|
65
|
+
slots: zod.z.record(zod.z.string(), zod.z.union([UIElementSchema, zod.z.array(UIElementSchema)])).optional(),
|
|
66
|
+
platform: zod.z.object({
|
|
67
|
+
web: zod.z.any().optional(),
|
|
68
|
+
ios: zod.z.any().optional(),
|
|
69
|
+
android: zod.z.any().optional()
|
|
70
|
+
}).optional()
|
|
71
|
+
})
|
|
72
|
+
);
|
|
73
|
+
var PageSchema = zod.z.object({
|
|
74
|
+
id: zod.z.string(),
|
|
75
|
+
name: zod.z.string(),
|
|
76
|
+
order: zod.z.number(),
|
|
77
|
+
icon: zod.z.string().optional(),
|
|
78
|
+
render: UIElementSchema
|
|
79
|
+
});
|
|
80
|
+
var UIComponentSchema = zod.z.object({
|
|
81
|
+
id: zod.z.string(),
|
|
82
|
+
name: zod.z.string().optional(),
|
|
83
|
+
props: zod.z.record(zod.z.string(), zod.z.any()).optional(),
|
|
84
|
+
states: zod.z.record(zod.z.string(), zod.z.any()).optional(),
|
|
85
|
+
methods: zod.z.record(
|
|
86
|
+
zod.z.string(),
|
|
87
|
+
zod.z.object({
|
|
88
|
+
fn: zod.z.string(),
|
|
89
|
+
params: zod.z.record(zod.z.string(), zod.z.any()).optional()
|
|
90
|
+
})
|
|
91
|
+
).optional(),
|
|
92
|
+
effects: zod.z.array(
|
|
93
|
+
zod.z.object({
|
|
94
|
+
fn: zod.z.string(),
|
|
95
|
+
deps: zod.z.array(zod.z.string()).optional()
|
|
96
|
+
})
|
|
97
|
+
).optional(),
|
|
98
|
+
data: zod.z.record(zod.z.string(), zod.z.any()).optional(),
|
|
99
|
+
// OLD: Single page (optional for backward compatibility)
|
|
100
|
+
render: UIElementSchema.optional(),
|
|
101
|
+
// NEW: Multi-page support
|
|
102
|
+
pages: zod.z.array(PageSchema).optional(),
|
|
103
|
+
defaultPageId: zod.z.string().optional(),
|
|
104
|
+
query: QuerySpecSchema.optional()
|
|
105
|
+
});
|
|
106
|
+
var DSLRendererPropsSchema = zod.z.object({
|
|
107
|
+
dsl: UIComponentSchema,
|
|
108
|
+
data: zod.z.record(zod.z.string(), zod.z.any()).optional(),
|
|
109
|
+
context: zod.z.record(zod.z.string(), zod.z.any()).optional()
|
|
110
|
+
});
|
|
111
|
+
var ExpressionSchema2 = zod.z.object({
|
|
112
|
+
$exp: zod.z.string(),
|
|
113
|
+
$deps: zod.z.array(zod.z.string()).optional()
|
|
114
|
+
});
|
|
115
|
+
var BindingSchema2 = zod.z.object({
|
|
116
|
+
$bind: zod.z.string(),
|
|
117
|
+
$transform: zod.z.array(
|
|
118
|
+
zod.z.object({
|
|
119
|
+
name: zod.z.string(),
|
|
120
|
+
args: zod.z.array(zod.z.any()).optional()
|
|
121
|
+
})
|
|
122
|
+
).optional()
|
|
123
|
+
});
|
|
124
|
+
var ForDirectiveSchema2 = zod.z.object({
|
|
125
|
+
in: zod.z.union([ExpressionSchema2, BindingSchema2, zod.z.string()]),
|
|
126
|
+
as: zod.z.string(),
|
|
127
|
+
key: zod.z.string().optional(),
|
|
128
|
+
index: zod.z.string().optional()
|
|
129
|
+
});
|
|
130
|
+
var QuerySpecSchema2 = zod.z.object({
|
|
131
|
+
graphql: zod.z.string().optional(),
|
|
132
|
+
sql: zod.z.string().optional(),
|
|
133
|
+
variables: zod.z.record(zod.z.string(), zod.z.any()).optional(),
|
|
134
|
+
params: zod.z.record(zod.z.string(), zod.z.any()).optional(),
|
|
135
|
+
key: zod.z.string().optional(),
|
|
136
|
+
refetchPolicy: zod.z.enum(["cache-first", "network-only", "cache-and-network"]).optional(),
|
|
137
|
+
dependencies: zod.z.array(zod.z.string()).optional()
|
|
138
|
+
});
|
|
139
|
+
var UIElementSchema2 = zod.z.lazy(
|
|
140
|
+
() => zod.z.object({
|
|
141
|
+
id: zod.z.string(),
|
|
142
|
+
type: zod.z.string(),
|
|
143
|
+
key: zod.z.union([zod.z.string(), ExpressionSchema2]).optional(),
|
|
144
|
+
props: zod.z.record(zod.z.string(), zod.z.any()).optional(),
|
|
145
|
+
query: QuerySpecSchema2.optional(),
|
|
146
|
+
if: ExpressionSchema2.optional(),
|
|
147
|
+
elseIf: ExpressionSchema2.optional(),
|
|
148
|
+
for: ForDirectiveSchema2.optional(),
|
|
149
|
+
"link-to": zod.z.union([
|
|
150
|
+
zod.z.string(),
|
|
151
|
+
ExpressionSchema2,
|
|
152
|
+
BindingSchema2,
|
|
153
|
+
zod.z.object({
|
|
154
|
+
ui: zod.z.union([zod.z.string(), ExpressionSchema2, BindingSchema2]),
|
|
155
|
+
params: zod.z.record(zod.z.string(), zod.z.any()).optional()
|
|
156
|
+
})
|
|
157
|
+
]).optional(),
|
|
158
|
+
_meta: zod.z.object({
|
|
159
|
+
id: zod.z.string().optional(),
|
|
160
|
+
version: zod.z.string().optional(),
|
|
161
|
+
created: zod.z.string().optional(),
|
|
162
|
+
lastModified: zod.z.string().optional()
|
|
163
|
+
}).optional(),
|
|
164
|
+
children: zod.z.any().optional(),
|
|
165
|
+
else: UIElementSchema2.optional(),
|
|
166
|
+
slots: zod.z.record(zod.z.string(), zod.z.union([UIElementSchema2, zod.z.array(UIElementSchema2)])).optional(),
|
|
167
|
+
platform: zod.z.object({
|
|
168
|
+
web: zod.z.any().optional(),
|
|
169
|
+
ios: zod.z.any().optional(),
|
|
170
|
+
android: zod.z.any().optional()
|
|
171
|
+
}).optional()
|
|
172
|
+
})
|
|
173
|
+
);
|
|
174
|
+
var UIComponentSchema2 = zod.z.object({
|
|
175
|
+
id: zod.z.string(),
|
|
176
|
+
name: zod.z.string().optional(),
|
|
177
|
+
props: zod.z.record(zod.z.string(), zod.z.any()).optional(),
|
|
178
|
+
states: zod.z.record(zod.z.string(), zod.z.any()).optional(),
|
|
179
|
+
methods: zod.z.record(
|
|
180
|
+
zod.z.string(),
|
|
181
|
+
zod.z.object({
|
|
182
|
+
fn: zod.z.string(),
|
|
183
|
+
params: zod.z.record(zod.z.string(), zod.z.any()).optional()
|
|
184
|
+
})
|
|
185
|
+
).optional(),
|
|
186
|
+
effects: zod.z.array(
|
|
187
|
+
zod.z.object({
|
|
188
|
+
fn: zod.z.string(),
|
|
189
|
+
deps: zod.z.array(zod.z.string()).optional()
|
|
190
|
+
})
|
|
191
|
+
).optional(),
|
|
192
|
+
data: zod.z.record(zod.z.string(), zod.z.any()).optional(),
|
|
193
|
+
// Made optional to align with dashboards schema (dashboards use pages instead)
|
|
194
|
+
render: UIElementSchema2.optional(),
|
|
195
|
+
query: QuerySpecSchema2.optional()
|
|
196
|
+
});
|
|
197
|
+
var DSLRendererPropsSchema2 = zod.z.object({
|
|
198
|
+
dsl: UIComponentSchema2,
|
|
199
|
+
data: zod.z.record(zod.z.string(), zod.z.any()).optional(),
|
|
200
|
+
context: zod.z.record(zod.z.string(), zod.z.any()).optional()
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// src/types.ts
|
|
204
|
+
var MessageParticipantSchema = zod.z.object({
|
|
205
|
+
id: zod.z.string().optional(),
|
|
206
|
+
type: zod.z.string().optional()
|
|
207
|
+
});
|
|
208
|
+
var MessageSchema = zod.z.object({
|
|
209
|
+
id: zod.z.string(),
|
|
210
|
+
type: zod.z.string(),
|
|
211
|
+
from: MessageParticipantSchema,
|
|
212
|
+
to: MessageParticipantSchema.optional(),
|
|
213
|
+
payload: zod.z.unknown()
|
|
214
|
+
});
|
|
215
|
+
var AuthLoginPayloadSchema = zod.z.object({
|
|
216
|
+
login_data: zod.z.string()
|
|
217
|
+
// Base64 encoded login data (username + SHA-1 hashed password)
|
|
218
|
+
});
|
|
219
|
+
var AuthLoginRequestMessageSchema = zod.z.object({
|
|
220
|
+
id: zod.z.string(),
|
|
221
|
+
type: zod.z.literal("AUTH_LOGIN_REQ"),
|
|
222
|
+
from: MessageParticipantSchema,
|
|
223
|
+
to: MessageParticipantSchema.optional(),
|
|
224
|
+
payload: AuthLoginPayloadSchema
|
|
225
|
+
});
|
|
226
|
+
var AuthLoginResponsePayloadSchema = zod.z.object({
|
|
227
|
+
success: zod.z.boolean(),
|
|
228
|
+
error: zod.z.string().optional(),
|
|
229
|
+
data: zod.z.unknown().optional()
|
|
230
|
+
// User ID or additional auth data
|
|
231
|
+
});
|
|
232
|
+
var AuthLoginResponseMessageSchema = zod.z.object({
|
|
233
|
+
id: zod.z.string(),
|
|
234
|
+
type: zod.z.literal("AUTH_LOGIN_RES"),
|
|
235
|
+
from: MessageParticipantSchema,
|
|
236
|
+
to: MessageParticipantSchema.optional(),
|
|
237
|
+
payload: AuthLoginResponsePayloadSchema
|
|
238
|
+
});
|
|
239
|
+
var AuthVerifyPayloadSchema = zod.z.object({
|
|
240
|
+
token: zod.z.string()
|
|
241
|
+
// Base64 encoded authentication token
|
|
242
|
+
});
|
|
243
|
+
var AuthVerifyRequestMessageSchema = zod.z.object({
|
|
244
|
+
id: zod.z.string(),
|
|
245
|
+
type: zod.z.literal("AUTH_VERIFY_REQ"),
|
|
246
|
+
from: MessageParticipantSchema,
|
|
247
|
+
to: MessageParticipantSchema.optional(),
|
|
248
|
+
payload: AuthVerifyPayloadSchema
|
|
249
|
+
});
|
|
250
|
+
var AuthVerifyResponsePayloadSchema = zod.z.object({
|
|
251
|
+
success: zod.z.boolean(),
|
|
252
|
+
error: zod.z.string().optional(),
|
|
253
|
+
data: zod.z.unknown().optional()
|
|
254
|
+
});
|
|
255
|
+
var AuthVerifyResponseMessageSchema = zod.z.object({
|
|
256
|
+
id: zod.z.string(),
|
|
257
|
+
type: zod.z.literal("AUTH_VERIFY_RES"),
|
|
258
|
+
from: MessageParticipantSchema,
|
|
259
|
+
to: MessageParticipantSchema.optional(),
|
|
260
|
+
payload: AuthVerifyResponsePayloadSchema
|
|
261
|
+
});
|
|
262
|
+
var UserPromptRequestPayloadSchema = zod.z.object({
|
|
263
|
+
prompt: zod.z.string(),
|
|
264
|
+
userId: zod.z.string().optional(),
|
|
265
|
+
SA_RUNTIME: zod.z.object({
|
|
266
|
+
threadId: zod.z.string(),
|
|
267
|
+
uiBlockId: zod.z.string()
|
|
268
|
+
}).optional(),
|
|
269
|
+
responseMode: zod.z.enum(["component", "text"]).optional()
|
|
270
|
+
});
|
|
271
|
+
var UserPromptRequestMessageSchema = zod.z.object({
|
|
272
|
+
id: zod.z.string(),
|
|
273
|
+
type: zod.z.literal("USER_PROMPT_REQ"),
|
|
274
|
+
from: MessageParticipantSchema,
|
|
275
|
+
to: MessageParticipantSchema.optional(),
|
|
276
|
+
payload: UserPromptRequestPayloadSchema
|
|
277
|
+
});
|
|
278
|
+
var ComponentPropsSchema = zod.z.object({
|
|
279
|
+
query: zod.z.string().or(zod.z.record(zod.z.string(), zod.z.unknown())).nullable().optional(),
|
|
280
|
+
title: zod.z.string().optional(),
|
|
281
|
+
description: zod.z.string().optional(),
|
|
282
|
+
config: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
283
|
+
}).passthrough();
|
|
284
|
+
var ComponentSchema = zod.z.object({
|
|
285
|
+
id: zod.z.string(),
|
|
286
|
+
name: zod.z.string(),
|
|
287
|
+
type: zod.z.string(),
|
|
288
|
+
description: zod.z.string(),
|
|
289
|
+
props: ComponentPropsSchema,
|
|
290
|
+
category: zod.z.string().optional(),
|
|
291
|
+
keywords: zod.z.array(zod.z.string()).optional()
|
|
292
|
+
});
|
|
293
|
+
var UserPromptResponsePayloadSchema = zod.z.object({
|
|
294
|
+
success: zod.z.boolean(),
|
|
295
|
+
error: zod.z.string().optional(),
|
|
296
|
+
data: zod.z.object({
|
|
297
|
+
component: ComponentSchema.optional()
|
|
298
|
+
}).optional(),
|
|
299
|
+
uiBlockId: zod.z.string().optional(),
|
|
300
|
+
threadId: zod.z.string().optional()
|
|
301
|
+
});
|
|
302
|
+
var UserPromptResponseMessageSchema = zod.z.object({
|
|
303
|
+
id: zod.z.string(),
|
|
304
|
+
type: zod.z.literal("USER_PROMPT_RES"),
|
|
305
|
+
from: MessageParticipantSchema,
|
|
306
|
+
to: MessageParticipantSchema.optional(),
|
|
307
|
+
payload: UserPromptResponsePayloadSchema
|
|
308
|
+
});
|
|
309
|
+
var UserPromptSuggestionsRequestPayloadSchema = zod.z.object({
|
|
310
|
+
prompt: zod.z.string(),
|
|
311
|
+
userId: zod.z.string().optional(),
|
|
312
|
+
limit: zod.z.number().int().positive().default(5)
|
|
313
|
+
});
|
|
314
|
+
var UserPromptSuggestionsRequestMessageSchema = zod.z.object({
|
|
315
|
+
id: zod.z.string(),
|
|
316
|
+
type: zod.z.literal("USER_PROMPT_SUGGESTIONS_REQ"),
|
|
317
|
+
from: MessageParticipantSchema,
|
|
318
|
+
to: MessageParticipantSchema.optional(),
|
|
319
|
+
payload: UserPromptSuggestionsRequestPayloadSchema
|
|
320
|
+
});
|
|
321
|
+
var UserPromptSuggestionsResponsePayloadSchema = zod.z.object({
|
|
322
|
+
success: zod.z.boolean(),
|
|
323
|
+
error: zod.z.string().optional(),
|
|
324
|
+
data: zod.z.object({
|
|
325
|
+
prompt: zod.z.string(),
|
|
326
|
+
suggestions: zod.z.array(ComponentSchema),
|
|
327
|
+
count: zod.z.number(),
|
|
328
|
+
message: zod.z.string().optional()
|
|
329
|
+
}).optional()
|
|
330
|
+
});
|
|
331
|
+
var UserPromptSuggestionsResponseMessageSchema = zod.z.object({
|
|
332
|
+
id: zod.z.string(),
|
|
333
|
+
type: zod.z.literal("USER_PROMPT_SUGGESTIONS_RES"),
|
|
334
|
+
from: MessageParticipantSchema,
|
|
335
|
+
to: MessageParticipantSchema.optional(),
|
|
336
|
+
payload: UserPromptSuggestionsResponsePayloadSchema
|
|
337
|
+
});
|
|
338
|
+
var DashCompRequestPayloadSchema = zod.z.object({
|
|
339
|
+
prompt: zod.z.string(),
|
|
340
|
+
userId: zod.z.string().optional(),
|
|
341
|
+
SA_RUNTIME: zod.z.object({
|
|
342
|
+
threadId: zod.z.string().optional(),
|
|
343
|
+
uiBlockId: zod.z.string().optional()
|
|
344
|
+
}).optional(),
|
|
345
|
+
existingComponents: zod.z.array(ComponentSchema).optional(),
|
|
346
|
+
req_type: zod.z.enum(["create", "update", "filter"]).optional()
|
|
347
|
+
});
|
|
348
|
+
var DashCompRequestMessageSchema = zod.z.object({
|
|
349
|
+
id: zod.z.string(),
|
|
350
|
+
type: zod.z.literal("DASH_COMP_REQ"),
|
|
351
|
+
from: MessageParticipantSchema,
|
|
352
|
+
to: MessageParticipantSchema.optional(),
|
|
353
|
+
payload: DashCompRequestPayloadSchema
|
|
354
|
+
});
|
|
355
|
+
zod.z.object({
|
|
356
|
+
toolId: zod.z.string(),
|
|
357
|
+
toolName: zod.z.string(),
|
|
358
|
+
action: zod.z.enum(["get", "create", "update", "delete"]),
|
|
359
|
+
params: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
360
|
+
});
|
|
361
|
+
zod.z.object({
|
|
362
|
+
filterId: zod.z.string(),
|
|
363
|
+
filterField: zod.z.string(),
|
|
364
|
+
targetComponentId: zod.z.string(),
|
|
365
|
+
targetField: zod.z.string()
|
|
366
|
+
});
|
|
367
|
+
var DashCompResponsePayloadSchema = zod.z.object({
|
|
368
|
+
success: zod.z.boolean(),
|
|
369
|
+
errors: zod.z.array(zod.z.string()).optional(),
|
|
370
|
+
data: zod.z.object({
|
|
371
|
+
// For create/update requests
|
|
372
|
+
component: ComponentSchema.optional(),
|
|
373
|
+
reasoning: zod.z.string().optional(),
|
|
374
|
+
dataSource: zod.z.enum(["database", "external_tool", "none"]).optional(),
|
|
375
|
+
// For filter requests
|
|
376
|
+
filterComponent: ComponentSchema.optional(),
|
|
377
|
+
updatedComponents: zod.z.array(ComponentSchema).optional(),
|
|
378
|
+
filterBindings: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
379
|
+
}).optional()
|
|
380
|
+
});
|
|
381
|
+
zod.z.object({
|
|
382
|
+
id: zod.z.string(),
|
|
383
|
+
type: zod.z.literal("DASH_COMP_RES"),
|
|
384
|
+
from: MessageParticipantSchema,
|
|
385
|
+
to: MessageParticipantSchema.optional(),
|
|
386
|
+
payload: DashCompResponsePayloadSchema
|
|
387
|
+
});
|
|
388
|
+
var BundleRequestPayloadSchema = zod.z.object({
|
|
389
|
+
devbundlereq: zod.z.boolean().optional().default(false)
|
|
390
|
+
});
|
|
391
|
+
var BundleRequestMessageSchema = zod.z.object({
|
|
392
|
+
id: zod.z.string(),
|
|
393
|
+
type: zod.z.literal("BUNDLE_REQ"),
|
|
394
|
+
from: MessageParticipantSchema,
|
|
395
|
+
to: MessageParticipantSchema.optional(),
|
|
396
|
+
payload: BundleRequestPayloadSchema
|
|
397
|
+
});
|
|
398
|
+
var BundleChunkPayloadSchema = zod.z.object({
|
|
399
|
+
chunk: zod.z.string(),
|
|
400
|
+
chunkIndex: zod.z.number(),
|
|
401
|
+
totalChunks: zod.z.number(),
|
|
402
|
+
isComplete: zod.z.boolean(),
|
|
403
|
+
progress: zod.z.number()
|
|
404
|
+
});
|
|
405
|
+
var BundleChunkMessageSchema = zod.z.object({
|
|
406
|
+
id: zod.z.string(),
|
|
407
|
+
type: zod.z.literal("BUNDLE_CHUNK"),
|
|
408
|
+
from: MessageParticipantSchema,
|
|
409
|
+
to: MessageParticipantSchema.optional(),
|
|
410
|
+
payload: BundleChunkPayloadSchema
|
|
411
|
+
});
|
|
412
|
+
var BundleErrorPayloadSchema = zod.z.object({
|
|
413
|
+
error: zod.z.string()
|
|
414
|
+
});
|
|
415
|
+
var BundleErrorMessageSchema = zod.z.object({
|
|
416
|
+
id: zod.z.string(),
|
|
417
|
+
type: zod.z.literal("BUNDLE_RES"),
|
|
418
|
+
from: MessageParticipantSchema,
|
|
419
|
+
to: MessageParticipantSchema.optional(),
|
|
420
|
+
payload: BundleErrorPayloadSchema
|
|
421
|
+
});
|
|
422
|
+
var DataRequestPayloadSchema = zod.z.object({
|
|
423
|
+
collection: zod.z.string(),
|
|
424
|
+
op: zod.z.string(),
|
|
425
|
+
params: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
426
|
+
SA_RUNTIME: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
427
|
+
});
|
|
428
|
+
var DataRequestMessageSchema = zod.z.object({
|
|
429
|
+
id: zod.z.string(),
|
|
430
|
+
type: zod.z.literal("DATA_REQ"),
|
|
431
|
+
from: MessageParticipantSchema,
|
|
432
|
+
to: MessageParticipantSchema.optional(),
|
|
433
|
+
payload: DataRequestPayloadSchema
|
|
434
|
+
});
|
|
435
|
+
var DataResponsePayloadSchema = zod.z.object({
|
|
436
|
+
collection: zod.z.string(),
|
|
437
|
+
op: zod.z.string(),
|
|
438
|
+
data: zod.z.unknown(),
|
|
439
|
+
executionMs: zod.z.number().optional(),
|
|
440
|
+
error: zod.z.string().optional()
|
|
441
|
+
});
|
|
442
|
+
var DataResponseMessageSchema = zod.z.object({
|
|
443
|
+
id: zod.z.string(),
|
|
444
|
+
type: zod.z.literal("DATA_RES"),
|
|
445
|
+
from: MessageParticipantSchema,
|
|
446
|
+
to: MessageParticipantSchema.optional(),
|
|
447
|
+
payload: DataResponsePayloadSchema
|
|
448
|
+
});
|
|
449
|
+
var UILogEntrySchema = zod.z.object({
|
|
450
|
+
timestamp: zod.z.number(),
|
|
451
|
+
level: zod.z.enum(["info", "error", "warn", "debug"]),
|
|
452
|
+
message: zod.z.string(),
|
|
453
|
+
type: zod.z.enum(["explanation", "query", "general"]).optional(),
|
|
454
|
+
data: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
455
|
+
});
|
|
456
|
+
var UILogsPayloadSchema = zod.z.object({
|
|
457
|
+
logs: zod.z.array(UILogEntrySchema)
|
|
458
|
+
});
|
|
459
|
+
var UILogsMessageSchema = zod.z.object({
|
|
460
|
+
id: zod.z.string(),
|
|
461
|
+
// uiBlockId
|
|
462
|
+
type: zod.z.literal("UI_LOGS"),
|
|
463
|
+
from: MessageParticipantSchema,
|
|
464
|
+
to: MessageParticipantSchema.optional(),
|
|
465
|
+
payload: UILogsPayloadSchema
|
|
466
|
+
});
|
|
467
|
+
var ActionsRequestPayloadSchema = zod.z.object({
|
|
468
|
+
userId: zod.z.string().optional(),
|
|
469
|
+
SA_RUNTIME: zod.z.object({
|
|
470
|
+
threadId: zod.z.string(),
|
|
471
|
+
uiBlockId: zod.z.string()
|
|
472
|
+
}).optional()
|
|
473
|
+
});
|
|
474
|
+
var ActionsRequestMessageSchema = zod.z.object({
|
|
475
|
+
id: zod.z.string(),
|
|
476
|
+
from: MessageParticipantSchema,
|
|
477
|
+
type: zod.z.literal("ACTIONS"),
|
|
478
|
+
payload: ActionsRequestPayloadSchema
|
|
479
|
+
});
|
|
480
|
+
var ActionsResponsePayloadSchema = zod.z.object({
|
|
481
|
+
success: zod.z.boolean(),
|
|
482
|
+
data: zod.z.any().optional(),
|
|
483
|
+
error: zod.z.string().optional()
|
|
484
|
+
});
|
|
485
|
+
var ActionsResponseMessageSchema = zod.z.object({
|
|
486
|
+
id: zod.z.string(),
|
|
487
|
+
type: zod.z.literal("ACTIONS_RES"),
|
|
488
|
+
from: MessageParticipantSchema,
|
|
489
|
+
to: MessageParticipantSchema.optional(),
|
|
490
|
+
payload: ActionsResponsePayloadSchema
|
|
491
|
+
});
|
|
492
|
+
var ComponentsSendPayloadSchema = zod.z.object({
|
|
493
|
+
components: zod.z.array(zod.z.any())
|
|
494
|
+
});
|
|
495
|
+
var ComponentsSendMessageSchema = zod.z.object({
|
|
496
|
+
id: zod.z.string(),
|
|
497
|
+
type: zod.z.literal("COMPONENT_LIST_RES"),
|
|
498
|
+
from: MessageParticipantSchema,
|
|
499
|
+
to: MessageParticipantSchema.optional(),
|
|
500
|
+
payload: ComponentsSendPayloadSchema
|
|
501
|
+
});
|
|
502
|
+
var UserQueryFiltersSchema = zod.z.object({
|
|
503
|
+
username: zod.z.string().optional(),
|
|
504
|
+
email: zod.z.string().optional(),
|
|
505
|
+
role: zod.z.string().optional(),
|
|
506
|
+
fullname: zod.z.string().optional(),
|
|
507
|
+
id: zod.z.number().optional()
|
|
508
|
+
});
|
|
509
|
+
var UsersRequestPayloadSchema = zod.z.object({
|
|
510
|
+
operation: zod.z.enum(["create", "update", "delete", "getAll", "getOne", "query"]),
|
|
511
|
+
data: zod.z.object({
|
|
512
|
+
id: zod.z.number().optional(),
|
|
513
|
+
username: zod.z.string().optional(),
|
|
514
|
+
email: zod.z.string().email("Invalid email format").optional(),
|
|
515
|
+
password: zod.z.string().optional(),
|
|
516
|
+
fullname: zod.z.string().optional(),
|
|
517
|
+
role: zod.z.string().optional(),
|
|
518
|
+
userInfo: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
519
|
+
// Query operation fields
|
|
520
|
+
filters: UserQueryFiltersSchema.optional(),
|
|
521
|
+
limit: zod.z.number().optional(),
|
|
522
|
+
sort: zod.z.enum(["ASC", "DESC"]).optional()
|
|
523
|
+
}).optional()
|
|
524
|
+
});
|
|
525
|
+
var UsersRequestMessageSchema = zod.z.object({
|
|
526
|
+
id: zod.z.string(),
|
|
527
|
+
type: zod.z.literal("USERS"),
|
|
528
|
+
from: MessageParticipantSchema,
|
|
529
|
+
to: MessageParticipantSchema.optional(),
|
|
530
|
+
payload: UsersRequestPayloadSchema
|
|
531
|
+
});
|
|
532
|
+
var UsersResponsePayloadSchema = zod.z.object({
|
|
533
|
+
success: zod.z.boolean(),
|
|
534
|
+
error: zod.z.string().optional(),
|
|
535
|
+
data: zod.z.object({
|
|
536
|
+
username: zod.z.string().optional(),
|
|
537
|
+
email: zod.z.string().optional(),
|
|
538
|
+
fullname: zod.z.string().optional(),
|
|
539
|
+
role: zod.z.string().optional(),
|
|
540
|
+
message: zod.z.string().optional(),
|
|
541
|
+
users: zod.z.array(zod.z.object({
|
|
542
|
+
id: zod.z.number(),
|
|
543
|
+
username: zod.z.string(),
|
|
544
|
+
email: zod.z.string().optional(),
|
|
545
|
+
fullname: zod.z.string().optional(),
|
|
546
|
+
role: zod.z.string().optional(),
|
|
547
|
+
userInfo: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
548
|
+
wsIds: zod.z.array(zod.z.string()).optional(),
|
|
549
|
+
createdAt: zod.z.string().optional(),
|
|
550
|
+
updatedAt: zod.z.string().optional()
|
|
551
|
+
})).optional(),
|
|
552
|
+
user: zod.z.object({
|
|
553
|
+
id: zod.z.number(),
|
|
554
|
+
username: zod.z.string(),
|
|
555
|
+
email: zod.z.string().optional(),
|
|
556
|
+
fullname: zod.z.string().optional(),
|
|
557
|
+
role: zod.z.string().optional(),
|
|
558
|
+
userInfo: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
559
|
+
wsIds: zod.z.array(zod.z.string()).optional(),
|
|
560
|
+
createdAt: zod.z.string().optional(),
|
|
561
|
+
updatedAt: zod.z.string().optional()
|
|
562
|
+
}).optional(),
|
|
563
|
+
count: zod.z.number().optional()
|
|
564
|
+
}).optional()
|
|
565
|
+
});
|
|
566
|
+
zod.z.object({
|
|
567
|
+
id: zod.z.string(),
|
|
568
|
+
type: zod.z.literal("USERS_RES"),
|
|
569
|
+
from: MessageParticipantSchema,
|
|
570
|
+
to: MessageParticipantSchema.optional(),
|
|
571
|
+
payload: UsersResponsePayloadSchema
|
|
572
|
+
});
|
|
573
|
+
var DashboardQueryFiltersSchema = zod.z.object({
|
|
574
|
+
dashboardId: zod.z.string().optional(),
|
|
575
|
+
projectId: zod.z.string().optional(),
|
|
576
|
+
createdBy: zod.z.string().optional(),
|
|
577
|
+
updatedBy: zod.z.string().optional(),
|
|
578
|
+
name: zod.z.string().optional(),
|
|
579
|
+
published: zod.z.boolean().optional()
|
|
580
|
+
});
|
|
581
|
+
var DashboardsRequestPayloadSchema = zod.z.object({
|
|
582
|
+
operation: zod.z.enum(["create", "update", "delete", "getAll", "getOne", "query"]),
|
|
583
|
+
data: zod.z.object({
|
|
584
|
+
id: zod.z.number().optional(),
|
|
585
|
+
dashboardId: zod.z.string().optional(),
|
|
586
|
+
projectId: zod.z.string().optional(),
|
|
587
|
+
name: zod.z.string().optional(),
|
|
588
|
+
description: zod.z.string().optional(),
|
|
589
|
+
published: zod.z.boolean().optional(),
|
|
590
|
+
createdBy: zod.z.string().optional(),
|
|
591
|
+
updatedBy: zod.z.string().optional(),
|
|
592
|
+
allowedUsers: zod.z.array(zod.z.string()).optional(),
|
|
593
|
+
dashboard: DSLRendererPropsSchema.optional(),
|
|
594
|
+
// Query operation fields
|
|
595
|
+
filters: DashboardQueryFiltersSchema.optional(),
|
|
596
|
+
limit: zod.z.number().optional(),
|
|
597
|
+
sort: zod.z.enum(["ASC", "DESC"]).optional()
|
|
598
|
+
}).optional()
|
|
599
|
+
});
|
|
600
|
+
var DashboardsRequestMessageSchema = zod.z.object({
|
|
601
|
+
id: zod.z.string(),
|
|
602
|
+
type: zod.z.literal("DASHBOARDS"),
|
|
603
|
+
from: MessageParticipantSchema,
|
|
604
|
+
to: MessageParticipantSchema.optional(),
|
|
605
|
+
payload: DashboardsRequestPayloadSchema
|
|
606
|
+
});
|
|
607
|
+
var DashboardsResponsePayloadSchema = zod.z.object({
|
|
608
|
+
success: zod.z.boolean(),
|
|
609
|
+
error: zod.z.string().optional(),
|
|
610
|
+
data: zod.z.object({
|
|
611
|
+
dashboardId: zod.z.string().optional(),
|
|
612
|
+
dashboard: DSLRendererPropsSchema.optional(),
|
|
613
|
+
dashboards: zod.z.array(zod.z.object({
|
|
614
|
+
dashboardId: zod.z.string(),
|
|
615
|
+
dashboard: DSLRendererPropsSchema
|
|
616
|
+
})).optional(),
|
|
617
|
+
count: zod.z.number().optional(),
|
|
618
|
+
message: zod.z.string().optional()
|
|
619
|
+
}).optional()
|
|
620
|
+
});
|
|
621
|
+
zod.z.object({
|
|
622
|
+
id: zod.z.string(),
|
|
623
|
+
type: zod.z.literal("DASHBOARDS_RES"),
|
|
624
|
+
from: MessageParticipantSchema,
|
|
625
|
+
to: MessageParticipantSchema.optional(),
|
|
626
|
+
payload: DashboardsResponsePayloadSchema
|
|
627
|
+
});
|
|
628
|
+
var ReportQueryFiltersSchema = zod.z.object({
|
|
629
|
+
reportId: zod.z.string().optional(),
|
|
630
|
+
projectId: zod.z.string().optional(),
|
|
631
|
+
createdBy: zod.z.string().optional(),
|
|
632
|
+
updatedBy: zod.z.string().optional(),
|
|
633
|
+
name: zod.z.string().optional(),
|
|
634
|
+
published: zod.z.boolean().optional()
|
|
635
|
+
});
|
|
636
|
+
var ReportsRequestPayloadSchema = zod.z.object({
|
|
637
|
+
operation: zod.z.enum(["create", "update", "delete", "getAll", "getOne", "query"]),
|
|
638
|
+
data: zod.z.object({
|
|
639
|
+
id: zod.z.number().optional(),
|
|
640
|
+
reportId: zod.z.string().optional(),
|
|
641
|
+
projectId: zod.z.string().optional(),
|
|
642
|
+
name: zod.z.string().optional(),
|
|
643
|
+
description: zod.z.string().optional(),
|
|
644
|
+
published: zod.z.boolean().optional(),
|
|
645
|
+
createdBy: zod.z.string().optional(),
|
|
646
|
+
updatedBy: zod.z.string().optional(),
|
|
647
|
+
report: DSLRendererPropsSchema2.optional(),
|
|
648
|
+
// Query operation fields
|
|
649
|
+
filters: ReportQueryFiltersSchema.optional(),
|
|
650
|
+
limit: zod.z.number().optional(),
|
|
651
|
+
sort: zod.z.enum(["ASC", "DESC"]).optional()
|
|
652
|
+
}).optional()
|
|
653
|
+
});
|
|
654
|
+
var ReportsRequestMessageSchema = zod.z.object({
|
|
655
|
+
id: zod.z.string(),
|
|
656
|
+
type: zod.z.literal("REPORTS"),
|
|
657
|
+
from: MessageParticipantSchema,
|
|
658
|
+
to: MessageParticipantSchema.optional(),
|
|
659
|
+
payload: ReportsRequestPayloadSchema
|
|
660
|
+
});
|
|
661
|
+
var ReportsResponsePayloadSchema = zod.z.object({
|
|
662
|
+
success: zod.z.boolean(),
|
|
663
|
+
error: zod.z.string().optional(),
|
|
664
|
+
data: zod.z.object({
|
|
665
|
+
reportId: zod.z.string().optional(),
|
|
666
|
+
report: DSLRendererPropsSchema2.optional(),
|
|
667
|
+
reports: zod.z.array(zod.z.object({
|
|
668
|
+
reportId: zod.z.string(),
|
|
669
|
+
report: DSLRendererPropsSchema2
|
|
670
|
+
})).optional(),
|
|
671
|
+
count: zod.z.number().optional(),
|
|
672
|
+
message: zod.z.string().optional()
|
|
673
|
+
}).optional()
|
|
674
|
+
});
|
|
675
|
+
zod.z.object({
|
|
676
|
+
id: zod.z.string(),
|
|
677
|
+
type: zod.z.literal("REPORTS_RES"),
|
|
678
|
+
from: MessageParticipantSchema,
|
|
679
|
+
to: MessageParticipantSchema.optional(),
|
|
680
|
+
payload: ReportsResponsePayloadSchema
|
|
681
|
+
});
|
|
682
|
+
var UIQueryFiltersSchema = zod.z.object({
|
|
683
|
+
uiId: zod.z.string().optional(),
|
|
684
|
+
projectId: zod.z.string().optional(),
|
|
685
|
+
createdBy: zod.z.string().optional(),
|
|
686
|
+
updatedBy: zod.z.string().optional(),
|
|
687
|
+
name: zod.z.string().optional()
|
|
688
|
+
});
|
|
689
|
+
var UIsRequestPayloadSchema = zod.z.object({
|
|
690
|
+
operation: zod.z.enum(["create", "update", "delete", "getAll", "getOne", "query"]),
|
|
691
|
+
data: zod.z.object({
|
|
692
|
+
id: zod.z.number().optional(),
|
|
693
|
+
uiId: zod.z.string().optional(),
|
|
694
|
+
projectId: zod.z.string().optional(),
|
|
695
|
+
name: zod.z.string().optional(),
|
|
696
|
+
description: zod.z.string().optional(),
|
|
697
|
+
createdBy: zod.z.string().optional(),
|
|
698
|
+
updatedBy: zod.z.string().optional(),
|
|
699
|
+
ui: DSLRendererPropsSchema.optional(),
|
|
700
|
+
// Query operation fields
|
|
701
|
+
filters: UIQueryFiltersSchema.optional(),
|
|
702
|
+
limit: zod.z.number().optional(),
|
|
703
|
+
sort: zod.z.enum(["ASC", "DESC"]).optional()
|
|
704
|
+
}).optional()
|
|
705
|
+
});
|
|
706
|
+
var UIsRequestMessageSchema = zod.z.object({
|
|
707
|
+
id: zod.z.string(),
|
|
708
|
+
type: zod.z.literal("UIS"),
|
|
709
|
+
from: MessageParticipantSchema,
|
|
710
|
+
to: MessageParticipantSchema.optional(),
|
|
711
|
+
payload: UIsRequestPayloadSchema
|
|
712
|
+
});
|
|
713
|
+
var UIsResponsePayloadSchema = zod.z.object({
|
|
714
|
+
success: zod.z.boolean(),
|
|
715
|
+
error: zod.z.string().optional(),
|
|
716
|
+
data: zod.z.object({
|
|
717
|
+
uiId: zod.z.union([zod.z.string(), zod.z.number()]).optional(),
|
|
718
|
+
ui: DSLRendererPropsSchema.optional(),
|
|
719
|
+
uis: zod.z.array(zod.z.object({
|
|
720
|
+
uiId: zod.z.string(),
|
|
721
|
+
ui: DSLRendererPropsSchema.optional()
|
|
722
|
+
})).optional(),
|
|
723
|
+
count: zod.z.number().optional(),
|
|
724
|
+
message: zod.z.string().optional()
|
|
725
|
+
}).optional()
|
|
726
|
+
});
|
|
727
|
+
zod.z.object({
|
|
728
|
+
id: zod.z.string(),
|
|
729
|
+
type: zod.z.literal("UIS_RES"),
|
|
730
|
+
from: MessageParticipantSchema,
|
|
731
|
+
to: MessageParticipantSchema.optional(),
|
|
732
|
+
payload: UIsResponsePayloadSchema
|
|
733
|
+
});
|
|
734
|
+
var DBUIBlockSchema = zod.z.object({
|
|
735
|
+
id: zod.z.string(),
|
|
736
|
+
component: zod.z.record(zod.z.string(), zod.z.any()).nullable(),
|
|
737
|
+
analysis: zod.z.string().nullable(),
|
|
738
|
+
user_prompt: zod.z.string()
|
|
739
|
+
});
|
|
740
|
+
var BookmarkDataSchema = zod.z.object({
|
|
741
|
+
id: zod.z.number().optional(),
|
|
742
|
+
uiblock: DBUIBlockSchema,
|
|
743
|
+
created_at: zod.z.string().optional(),
|
|
744
|
+
updated_at: zod.z.string().optional()
|
|
745
|
+
});
|
|
746
|
+
var BookmarkQueryFiltersSchema = zod.z.object({
|
|
747
|
+
userId: zod.z.string().optional(),
|
|
748
|
+
threadId: zod.z.string().optional(),
|
|
749
|
+
name: zod.z.string().optional()
|
|
750
|
+
});
|
|
751
|
+
var BookmarksRequestPayloadSchema = zod.z.object({
|
|
752
|
+
operation: zod.z.enum(["create", "update", "delete", "getAll", "getOne", "query"]),
|
|
753
|
+
data: zod.z.object({
|
|
754
|
+
id: zod.z.number().optional(),
|
|
755
|
+
userId: zod.z.string().optional(),
|
|
756
|
+
threadId: zod.z.string().optional(),
|
|
757
|
+
name: zod.z.string().optional(),
|
|
758
|
+
description: zod.z.string().optional(),
|
|
759
|
+
uiblock: DBUIBlockSchema.optional(),
|
|
760
|
+
// Query operation fields
|
|
761
|
+
filters: BookmarkQueryFiltersSchema.optional(),
|
|
762
|
+
limit: zod.z.number().optional(),
|
|
763
|
+
sort: zod.z.enum(["ASC", "DESC"]).optional()
|
|
764
|
+
}).optional()
|
|
765
|
+
});
|
|
766
|
+
var BookmarksRequestMessageSchema = zod.z.object({
|
|
767
|
+
id: zod.z.string(),
|
|
768
|
+
type: zod.z.literal("BOOKMARKS"),
|
|
769
|
+
from: MessageParticipantSchema,
|
|
770
|
+
to: MessageParticipantSchema.optional(),
|
|
771
|
+
payload: BookmarksRequestPayloadSchema
|
|
772
|
+
});
|
|
773
|
+
var BookmarksResponsePayloadSchema = zod.z.object({
|
|
774
|
+
success: zod.z.boolean(),
|
|
775
|
+
error: zod.z.string().optional(),
|
|
776
|
+
data: zod.z.union([
|
|
777
|
+
BookmarkDataSchema,
|
|
778
|
+
zod.z.array(BookmarkDataSchema)
|
|
779
|
+
]).optional(),
|
|
780
|
+
count: zod.z.number().optional(),
|
|
781
|
+
message: zod.z.string().optional()
|
|
782
|
+
});
|
|
783
|
+
zod.z.object({
|
|
784
|
+
id: zod.z.string(),
|
|
785
|
+
type: zod.z.literal("BOOKMARKS_RES"),
|
|
786
|
+
from: MessageParticipantSchema,
|
|
787
|
+
to: MessageParticipantSchema.optional(),
|
|
788
|
+
payload: BookmarksResponsePayloadSchema
|
|
789
|
+
});
|
|
790
|
+
var ArtifactDataSchema = zod.z.object({
|
|
791
|
+
id: zod.z.number().optional(),
|
|
792
|
+
name: zod.z.string(),
|
|
793
|
+
createdBy: zod.z.string().nullable().optional(),
|
|
794
|
+
dsl: zod.z.record(zod.z.string(), zod.z.any()).nullable().optional(),
|
|
795
|
+
type: zod.z.string().nullable().optional(),
|
|
796
|
+
filters: zod.z.any().nullable().optional(),
|
|
797
|
+
status: zod.z.string().nullable().optional(),
|
|
798
|
+
deleted: zod.z.boolean().optional(),
|
|
799
|
+
createdAt: zod.z.string().optional(),
|
|
800
|
+
updatedAt: zod.z.string().optional()
|
|
801
|
+
});
|
|
802
|
+
var ArtifactsQueryFiltersSchema = zod.z.object({
|
|
803
|
+
createdBy: zod.z.string().optional(),
|
|
804
|
+
type: zod.z.string().optional(),
|
|
805
|
+
status: zod.z.string().optional(),
|
|
806
|
+
name: zod.z.string().optional(),
|
|
807
|
+
deleted: zod.z.boolean().optional(),
|
|
808
|
+
createdAt: zod.z.string().optional()
|
|
809
|
+
});
|
|
810
|
+
var ArtifactsRequestPayloadSchema = zod.z.object({
|
|
811
|
+
operation: zod.z.enum(["create", "update", "delete", "getAll", "getOne", "query"]),
|
|
812
|
+
data: zod.z.object({
|
|
813
|
+
id: zod.z.number().optional(),
|
|
814
|
+
name: zod.z.string().optional(),
|
|
815
|
+
createdBy: zod.z.string().optional(),
|
|
816
|
+
dsl: zod.z.record(zod.z.string(), zod.z.any()).optional(),
|
|
817
|
+
status: zod.z.string().optional(),
|
|
818
|
+
deleted: zod.z.boolean().optional(),
|
|
819
|
+
limit: zod.z.number().optional(),
|
|
820
|
+
offset: zod.z.number().optional(),
|
|
821
|
+
// Query operation fields
|
|
822
|
+
filters: ArtifactsQueryFiltersSchema.optional(),
|
|
823
|
+
sort: zod.z.enum(["ASC", "DESC"]).optional(),
|
|
824
|
+
// Menu grouping fields
|
|
825
|
+
type: zod.z.string().optional(),
|
|
826
|
+
menuId: zod.z.number().optional(),
|
|
827
|
+
artifactGroupName: zod.z.string().optional(),
|
|
828
|
+
artifactGroupId: zod.z.string().optional(),
|
|
829
|
+
artifactGroupIcon: zod.z.string().optional()
|
|
830
|
+
}).optional()
|
|
831
|
+
});
|
|
832
|
+
var ArtifactsRequestMessageSchema = zod.z.object({
|
|
833
|
+
id: zod.z.string(),
|
|
834
|
+
type: zod.z.literal("ARTIFACTS"),
|
|
835
|
+
from: MessageParticipantSchema,
|
|
836
|
+
to: MessageParticipantSchema.optional(),
|
|
837
|
+
payload: ArtifactsRequestPayloadSchema
|
|
838
|
+
});
|
|
839
|
+
var ArtifactsResponsePayloadSchema = zod.z.object({
|
|
840
|
+
success: zod.z.boolean(),
|
|
841
|
+
error: zod.z.string().optional(),
|
|
842
|
+
data: zod.z.union([
|
|
843
|
+
ArtifactDataSchema,
|
|
844
|
+
zod.z.array(ArtifactDataSchema)
|
|
845
|
+
]).optional(),
|
|
846
|
+
count: zod.z.number().optional(),
|
|
847
|
+
message: zod.z.string().optional()
|
|
848
|
+
});
|
|
849
|
+
zod.z.object({
|
|
850
|
+
id: zod.z.string(),
|
|
851
|
+
type: zod.z.literal("ARTIFACTS_RES"),
|
|
852
|
+
from: MessageParticipantSchema,
|
|
853
|
+
to: MessageParticipantSchema.optional(),
|
|
854
|
+
payload: ArtifactsResponsePayloadSchema
|
|
855
|
+
});
|
|
856
|
+
var KbNodeTypeSchema = zod.z.enum(["global", "user", "query"]);
|
|
857
|
+
var KbNodeDataSchema = zod.z.object({
|
|
858
|
+
id: zod.z.number().optional(),
|
|
859
|
+
title: zod.z.string(),
|
|
860
|
+
content: zod.z.string(),
|
|
861
|
+
category: zod.z.string().nullable().optional(),
|
|
862
|
+
tags: zod.z.array(zod.z.string()).nullable().optional(),
|
|
863
|
+
type: KbNodeTypeSchema.nullable().optional(),
|
|
864
|
+
createdBy: zod.z.string(),
|
|
865
|
+
updatedBy: zod.z.string().optional(),
|
|
866
|
+
createdAt: zod.z.string().optional(),
|
|
867
|
+
updatedAt: zod.z.string().optional()
|
|
868
|
+
});
|
|
869
|
+
var KbNodesQueryFiltersSchema = zod.z.object({
|
|
870
|
+
query: zod.z.string().optional(),
|
|
871
|
+
category: zod.z.string().optional(),
|
|
872
|
+
tags: zod.z.array(zod.z.string()).optional(),
|
|
873
|
+
type: KbNodeTypeSchema.optional(),
|
|
874
|
+
createdBy: zod.z.string().optional()
|
|
875
|
+
});
|
|
876
|
+
var KbNodesRequestPayloadSchema = zod.z.object({
|
|
877
|
+
operation: zod.z.enum(["create", "update", "delete", "getAll", "getOne", "search", "getByCategory", "getByUser", "getCategories", "getTags"]),
|
|
878
|
+
data: zod.z.object({
|
|
879
|
+
id: zod.z.number().optional(),
|
|
880
|
+
title: zod.z.string().optional(),
|
|
881
|
+
content: zod.z.string().optional(),
|
|
882
|
+
category: zod.z.string().optional(),
|
|
883
|
+
tags: zod.z.array(zod.z.string()).optional(),
|
|
884
|
+
type: KbNodeTypeSchema.optional(),
|
|
885
|
+
createdBy: zod.z.string().optional(),
|
|
886
|
+
updatedBy: zod.z.string().optional(),
|
|
887
|
+
userId: zod.z.string().optional(),
|
|
888
|
+
// Query/search operation fields
|
|
889
|
+
query: zod.z.string().optional(),
|
|
890
|
+
filters: KbNodesQueryFiltersSchema.optional(),
|
|
891
|
+
limit: zod.z.number().optional(),
|
|
892
|
+
offset: zod.z.number().optional()
|
|
893
|
+
}).optional()
|
|
894
|
+
});
|
|
895
|
+
var KbNodesRequestMessageSchema = zod.z.object({
|
|
896
|
+
id: zod.z.string(),
|
|
897
|
+
type: zod.z.literal("KB_NODES"),
|
|
898
|
+
from: MessageParticipantSchema,
|
|
899
|
+
to: MessageParticipantSchema.optional(),
|
|
900
|
+
payload: KbNodesRequestPayloadSchema
|
|
901
|
+
});
|
|
902
|
+
var KbNodesResponsePayloadSchema = zod.z.object({
|
|
903
|
+
success: zod.z.boolean(),
|
|
904
|
+
error: zod.z.string().optional(),
|
|
905
|
+
data: zod.z.object({
|
|
906
|
+
// Single node operations
|
|
907
|
+
id: zod.z.number().optional(),
|
|
908
|
+
title: zod.z.string().optional(),
|
|
909
|
+
content: zod.z.string().optional(),
|
|
910
|
+
category: zod.z.string().nullable().optional(),
|
|
911
|
+
tags: zod.z.array(zod.z.string()).nullable().optional(),
|
|
912
|
+
type: KbNodeTypeSchema.nullable().optional(),
|
|
913
|
+
createdBy: zod.z.string().optional(),
|
|
914
|
+
updatedBy: zod.z.string().optional(),
|
|
915
|
+
createdAt: zod.z.string().optional(),
|
|
916
|
+
updatedAt: zod.z.string().optional(),
|
|
917
|
+
message: zod.z.string().optional(),
|
|
918
|
+
// GetOne response
|
|
919
|
+
node: KbNodeDataSchema.optional(),
|
|
920
|
+
// List operations
|
|
921
|
+
nodes: zod.z.array(KbNodeDataSchema).optional(),
|
|
922
|
+
count: zod.z.number().optional(),
|
|
923
|
+
// getByCategory/getByUser
|
|
924
|
+
userId: zod.z.string().optional(),
|
|
925
|
+
// getCategories
|
|
926
|
+
categories: zod.z.array(zod.z.string()).optional()
|
|
927
|
+
// getTags
|
|
928
|
+
}).optional()
|
|
929
|
+
});
|
|
930
|
+
var KbNodesResponseMessageSchema = zod.z.object({
|
|
931
|
+
id: zod.z.string(),
|
|
932
|
+
type: zod.z.literal("KB_NODES_RES"),
|
|
933
|
+
from: MessageParticipantSchema,
|
|
934
|
+
to: MessageParticipantSchema.optional(),
|
|
935
|
+
payload: KbNodesResponsePayloadSchema
|
|
936
|
+
});
|
|
937
|
+
var MenuDataSchema = zod.z.object({
|
|
938
|
+
id: zod.z.number().optional(),
|
|
939
|
+
name: zod.z.string(),
|
|
940
|
+
componentName: zod.z.string(),
|
|
941
|
+
icon: zod.z.string().nullable().optional(),
|
|
942
|
+
userMessage: zod.z.string().nullable().optional(),
|
|
943
|
+
parentId: zod.z.number().nullable().optional(),
|
|
944
|
+
sortOrder: zod.z.number().optional(),
|
|
945
|
+
props: zod.z.record(zod.z.string(), zod.z.unknown()).nullable().optional(),
|
|
946
|
+
isActive: zod.z.boolean().optional(),
|
|
947
|
+
createdAt: zod.z.string().optional(),
|
|
948
|
+
updatedAt: zod.z.string().optional(),
|
|
949
|
+
children: zod.z.lazy(() => zod.z.array(MenuDataSchema)).optional(),
|
|
950
|
+
menuJson: zod.z.record(zod.z.string(), zod.z.unknown()).nullable().optional(),
|
|
951
|
+
version: zod.z.number().optional()
|
|
952
|
+
});
|
|
953
|
+
var MenuQueryFiltersSchema = zod.z.object({
|
|
954
|
+
parentId: zod.z.number().nullable().optional(),
|
|
955
|
+
isActive: zod.z.boolean().optional()
|
|
956
|
+
});
|
|
957
|
+
var MenusRequestPayloadSchema = zod.z.object({
|
|
958
|
+
operation: zod.z.enum(["create", "update", "delete", "getAll", "getOne", "query", "getRootMenus", "getChildMenus", "getHierarchy", "reorder"]),
|
|
959
|
+
data: zod.z.object({
|
|
960
|
+
id: zod.z.number().optional(),
|
|
961
|
+
name: zod.z.string().optional(),
|
|
962
|
+
componentName: zod.z.string().optional(),
|
|
963
|
+
icon: zod.z.string().optional(),
|
|
964
|
+
userMessage: zod.z.string().optional(),
|
|
965
|
+
parentId: zod.z.number().nullable().optional(),
|
|
966
|
+
sortOrder: zod.z.number().optional(),
|
|
967
|
+
props: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
968
|
+
isActive: zod.z.boolean().optional(),
|
|
969
|
+
// Query operation fields
|
|
970
|
+
filters: MenuQueryFiltersSchema.optional(),
|
|
971
|
+
limit: zod.z.number().optional(),
|
|
972
|
+
sort: zod.z.enum(["ASC", "DESC"]).optional(),
|
|
973
|
+
// Reorder operation
|
|
974
|
+
items: zod.z.array(zod.z.object({
|
|
975
|
+
id: zod.z.number(),
|
|
976
|
+
sortOrder: zod.z.number()
|
|
977
|
+
})).optional()
|
|
978
|
+
}).optional()
|
|
979
|
+
});
|
|
980
|
+
var MenusRequestMessageSchema = zod.z.object({
|
|
981
|
+
id: zod.z.string(),
|
|
982
|
+
type: zod.z.literal("MENUS"),
|
|
983
|
+
from: MessageParticipantSchema,
|
|
984
|
+
to: MessageParticipantSchema.optional(),
|
|
985
|
+
payload: MenusRequestPayloadSchema
|
|
986
|
+
});
|
|
987
|
+
var MenusResponsePayloadSchema = zod.z.object({
|
|
988
|
+
success: zod.z.boolean(),
|
|
989
|
+
error: zod.z.string().optional(),
|
|
990
|
+
data: zod.z.union([
|
|
991
|
+
MenuDataSchema,
|
|
992
|
+
zod.z.array(MenuDataSchema)
|
|
993
|
+
]).optional(),
|
|
994
|
+
count: zod.z.number().optional(),
|
|
995
|
+
message: zod.z.string().optional()
|
|
996
|
+
});
|
|
997
|
+
var MenusResponseMessageSchema = zod.z.object({
|
|
998
|
+
id: zod.z.string(),
|
|
999
|
+
type: zod.z.literal("MENUS_RES"),
|
|
1000
|
+
from: MessageParticipantSchema,
|
|
1001
|
+
to: MessageParticipantSchema.optional(),
|
|
1002
|
+
payload: MenusResponsePayloadSchema
|
|
1003
|
+
});
|
|
1004
|
+
var SchemaColumnStatisticsSchema = zod.z.object({
|
|
1005
|
+
distinct: zod.z.number().optional(),
|
|
1006
|
+
min: zod.z.number().optional(),
|
|
1007
|
+
max: zod.z.number().optional()
|
|
1008
|
+
});
|
|
1009
|
+
var SchemaColumnSchema = zod.z.object({
|
|
1010
|
+
name: zod.z.string(),
|
|
1011
|
+
type: zod.z.string(),
|
|
1012
|
+
nativeType: zod.z.string(),
|
|
1013
|
+
nullable: zod.z.boolean(),
|
|
1014
|
+
description: zod.z.string(),
|
|
1015
|
+
statistics: SchemaColumnStatisticsSchema.optional(),
|
|
1016
|
+
cardinality: zod.z.enum(["unique", "high", "medium", "low"]).optional(),
|
|
1017
|
+
sampleValues: zod.z.array(zod.z.string()).optional()
|
|
1018
|
+
});
|
|
1019
|
+
var SchemaTableSchema = zod.z.object({
|
|
1020
|
+
name: zod.z.string(),
|
|
1021
|
+
fullName: zod.z.string(),
|
|
1022
|
+
rowCount: zod.z.number(),
|
|
1023
|
+
description: zod.z.string(),
|
|
1024
|
+
columns: zod.z.array(SchemaColumnSchema)
|
|
1025
|
+
});
|
|
1026
|
+
var SchemaRelationshipSchema = zod.z.object({
|
|
1027
|
+
from: zod.z.string(),
|
|
1028
|
+
to: zod.z.string(),
|
|
1029
|
+
type: zod.z.string(),
|
|
1030
|
+
keys: zod.z.array(zod.z.string())
|
|
1031
|
+
});
|
|
1032
|
+
var DatabaseSchemaSchema = zod.z.object({
|
|
1033
|
+
database: zod.z.string(),
|
|
1034
|
+
databaseType: zod.z.string().optional(),
|
|
1035
|
+
schema: zod.z.string(),
|
|
1036
|
+
description: zod.z.string(),
|
|
1037
|
+
tables: zod.z.array(SchemaTableSchema),
|
|
1038
|
+
relationships: zod.z.array(SchemaRelationshipSchema).optional()
|
|
1039
|
+
});
|
|
1040
|
+
var SchemaRequestPayloadSchema = zod.z.object({
|
|
1041
|
+
/** If true, returns the formatted documentation string in addition to raw JSON */
|
|
1042
|
+
formatted: zod.z.boolean().optional()
|
|
1043
|
+
});
|
|
1044
|
+
var SchemaRequestMessageSchema = zod.z.object({
|
|
1045
|
+
id: zod.z.string(),
|
|
1046
|
+
type: zod.z.literal("SCHEMA_REQ"),
|
|
1047
|
+
from: MessageParticipantSchema,
|
|
1048
|
+
to: MessageParticipantSchema.optional(),
|
|
1049
|
+
payload: SchemaRequestPayloadSchema
|
|
1050
|
+
});
|
|
1051
|
+
var SchemaResponsePayloadSchema = zod.z.object({
|
|
1052
|
+
success: zod.z.boolean(),
|
|
1053
|
+
error: zod.z.string().optional(),
|
|
1054
|
+
data: zod.z.object({
|
|
1055
|
+
schema: DatabaseSchemaSchema,
|
|
1056
|
+
/** Formatted schema documentation (only if formatted: true was requested) */
|
|
1057
|
+
formatted: zod.z.string().optional()
|
|
1058
|
+
}).optional()
|
|
1059
|
+
});
|
|
1060
|
+
zod.z.object({
|
|
1061
|
+
id: zod.z.string(),
|
|
1062
|
+
type: zod.z.literal("SCHEMA_RES"),
|
|
1063
|
+
from: MessageParticipantSchema,
|
|
1064
|
+
to: MessageParticipantSchema.optional(),
|
|
1065
|
+
payload: SchemaResponsePayloadSchema
|
|
1066
|
+
});
|
|
1067
|
+
var ClientConfigSchema = zod.z.object({
|
|
1068
|
+
userId: zod.z.string(),
|
|
1069
|
+
projectId: zod.z.string(),
|
|
1070
|
+
baseUrl: zod.z.string().default("wss://ws.superatom.ai/websocket"),
|
|
1071
|
+
type: zod.z.string().default("runtime"),
|
|
1072
|
+
maxReconnectAttempts: zod.z.number().min(0).default(Infinity),
|
|
1073
|
+
initialReconnectDelay: zod.z.number().min(0).default(1e3),
|
|
1074
|
+
maxReconnectDelay: zod.z.number().min(0).default(3e4),
|
|
1075
|
+
defaultTimeout: zod.z.number().min(0).default(3e4),
|
|
1076
|
+
debug: zod.z.boolean().default(false)
|
|
1077
|
+
});
|
|
1078
|
+
|
|
1079
|
+
// src/services/index.ts
|
|
1080
|
+
var services_exports = {};
|
|
1081
|
+
__export(services_exports, {
|
|
1082
|
+
BindingSchema: () => BindingSchema,
|
|
1083
|
+
DSLRendererPropsSchema: () => DSLRendererPropsSchema,
|
|
1084
|
+
ExpressionSchema: () => ExpressionSchema,
|
|
1085
|
+
ForDirectiveSchema: () => ForDirectiveSchema,
|
|
1086
|
+
PageSchema: () => PageSchema,
|
|
1087
|
+
QuerySpecSchema: () => QuerySpecSchema,
|
|
1088
|
+
UIComponentSchema: () => UIComponentSchema,
|
|
1089
|
+
UIElementSchema: () => UIElementSchema,
|
|
1090
|
+
createArtifact: () => createArtifact,
|
|
1091
|
+
createBookmark: () => createBookmark,
|
|
1092
|
+
createDashboard: () => createDashboard,
|
|
1093
|
+
createKbNode: () => createKbNode,
|
|
1094
|
+
createMenu: () => createMenu,
|
|
1095
|
+
createReport: () => createReport,
|
|
1096
|
+
createUI: () => createUI,
|
|
1097
|
+
createUser: () => createUser,
|
|
1098
|
+
deleteArtifact: () => deleteArtifact,
|
|
1099
|
+
deleteBookmark: () => deleteBookmark,
|
|
1100
|
+
deleteDashboard: () => deleteDashboard,
|
|
1101
|
+
deleteKbNode: () => deleteKbNode,
|
|
1102
|
+
deleteMenu: () => deleteMenu,
|
|
1103
|
+
deleteReport: () => deleteReport,
|
|
1104
|
+
deleteUI: () => deleteUI,
|
|
1105
|
+
deleteUser: () => deleteUser,
|
|
1106
|
+
getActions: () => getActions,
|
|
1107
|
+
getAllArtifacts: () => getAllArtifacts,
|
|
1108
|
+
getAllBookmarks: () => getAllBookmarks,
|
|
1109
|
+
getAllDashboards: () => getAllDashboards,
|
|
1110
|
+
getAllKbNodes: () => getAllKbNodes,
|
|
1111
|
+
getAllMenus: () => getAllMenus,
|
|
1112
|
+
getAllReports: () => getAllReports,
|
|
1113
|
+
getAllUIs: () => getAllUIs,
|
|
1114
|
+
getAllUsers: () => getAllUsers,
|
|
1115
|
+
getArtifact: () => getArtifact,
|
|
1116
|
+
getBookmark: () => getBookmark,
|
|
1117
|
+
getChildMenus: () => getChildMenus,
|
|
1118
|
+
getComponentSuggestions: () => getComponentSuggestions,
|
|
1119
|
+
getDashboard: () => getDashboard,
|
|
1120
|
+
getKbNode: () => getKbNode,
|
|
1121
|
+
getKbNodeCategories: () => getKbNodeCategories,
|
|
1122
|
+
getKbNodeTags: () => getKbNodeTags,
|
|
1123
|
+
getKbNodesByCategory: () => getKbNodesByCategory,
|
|
1124
|
+
getKbNodesByUser: () => getKbNodesByUser,
|
|
1125
|
+
getMenu: () => getMenu,
|
|
1126
|
+
getMenusHierarchy: () => getMenusHierarchy,
|
|
1127
|
+
getReport: () => getReport,
|
|
1128
|
+
getRootMenus: () => getRootMenus,
|
|
1129
|
+
getSchema: () => getSchema,
|
|
1130
|
+
getUI: () => getUI,
|
|
1131
|
+
getUser: () => getUser,
|
|
1132
|
+
queryArtifacts: () => queryArtifacts,
|
|
1133
|
+
queryBookmarks: () => queryBookmarks,
|
|
1134
|
+
queryDashboards: () => queryDashboards,
|
|
1135
|
+
queryMenus: () => queryMenus,
|
|
1136
|
+
queryReports: () => queryReports,
|
|
1137
|
+
queryUIs: () => queryUIs,
|
|
1138
|
+
queryUsers: () => queryUsers,
|
|
1139
|
+
reorderMenus: () => reorderMenus,
|
|
1140
|
+
requestBundle: () => requestBundle,
|
|
1141
|
+
requestData: () => requestData,
|
|
1142
|
+
searchKbNodes: () => searchKbNodes,
|
|
1143
|
+
sendAuthLoginRequest: () => sendAuthLoginRequest,
|
|
1144
|
+
sendAuthVerifyRequest: () => sendAuthVerifyRequest,
|
|
1145
|
+
sendComponents: () => sendComponents,
|
|
1146
|
+
sendDashCompRequest: () => sendDashCompRequest,
|
|
1147
|
+
sendUserPromptRequest: () => sendUserPromptRequest,
|
|
1148
|
+
sendUserPromptSuggestionsRequest: () => sendUserPromptSuggestionsRequest,
|
|
1149
|
+
updateArtifact: () => updateArtifact,
|
|
1150
|
+
updateBookmark: () => updateBookmark,
|
|
1151
|
+
updateDashboard: () => updateDashboard,
|
|
1152
|
+
updateKbNode: () => updateKbNode,
|
|
1153
|
+
updateMenu: () => updateMenu,
|
|
1154
|
+
updateReport: () => updateReport,
|
|
1155
|
+
updateUI: () => updateUI,
|
|
1156
|
+
updateUser: () => updateUser
|
|
1157
|
+
});
|
|
1158
|
+
|
|
1159
|
+
// src/services/auth.ts
|
|
1160
|
+
async function sendAuthLoginRequest(client, loginDataBase64, timeout) {
|
|
1161
|
+
const messageId = `login_${Date.now()}`;
|
|
1162
|
+
const message = AuthLoginRequestMessageSchema.parse({
|
|
1163
|
+
id: messageId,
|
|
1164
|
+
type: "AUTH_LOGIN_REQ",
|
|
1165
|
+
from: {
|
|
1166
|
+
type: client.type
|
|
1167
|
+
},
|
|
1168
|
+
to: {
|
|
1169
|
+
type: "data-agent"
|
|
1170
|
+
},
|
|
1171
|
+
payload: {
|
|
1172
|
+
login_data: loginDataBase64
|
|
1173
|
+
}
|
|
1174
|
+
});
|
|
1175
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1176
|
+
console.log("sdk auth login response", response);
|
|
1177
|
+
return response;
|
|
1178
|
+
}
|
|
1179
|
+
async function sendAuthVerifyRequest(client, token, timeout) {
|
|
1180
|
+
const messageId = `verify_${Date.now()}`;
|
|
1181
|
+
const message = AuthVerifyRequestMessageSchema.parse({
|
|
1182
|
+
id: messageId,
|
|
1183
|
+
type: "AUTH_VERIFY_REQ",
|
|
1184
|
+
from: {
|
|
1185
|
+
type: client.type
|
|
1186
|
+
},
|
|
1187
|
+
to: {
|
|
1188
|
+
type: "data-agent"
|
|
1189
|
+
},
|
|
1190
|
+
payload: {
|
|
1191
|
+
token
|
|
1192
|
+
}
|
|
1193
|
+
});
|
|
1194
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1195
|
+
return response;
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
// src/services/userPrompt.ts
|
|
1199
|
+
async function sendUserPromptRequest(client, prompt, threadId, uiBlockId, userId, responseMode, onStream, timeout) {
|
|
1200
|
+
const messageId = `user_prompt_req_msg_${Date.now()}`;
|
|
1201
|
+
const message = UserPromptRequestMessageSchema.parse({
|
|
1202
|
+
id: messageId,
|
|
1203
|
+
type: "USER_PROMPT_REQ",
|
|
1204
|
+
from: {
|
|
1205
|
+
type: client.type
|
|
1206
|
+
},
|
|
1207
|
+
to: {
|
|
1208
|
+
type: "data-agent"
|
|
1209
|
+
},
|
|
1210
|
+
payload: {
|
|
1211
|
+
prompt,
|
|
1212
|
+
userId,
|
|
1213
|
+
SA_RUNTIME: {
|
|
1214
|
+
threadId,
|
|
1215
|
+
uiBlockId
|
|
1216
|
+
},
|
|
1217
|
+
responseMode
|
|
1218
|
+
}
|
|
1219
|
+
});
|
|
1220
|
+
let streamUnsubscribe = null;
|
|
1221
|
+
if (responseMode === "text" && onStream) {
|
|
1222
|
+
streamUnsubscribe = client.onMessage((msg) => {
|
|
1223
|
+
if (msg.type === "USER_PROMPT_STREAM" && msg.id === `stream_${uiBlockId}`) {
|
|
1224
|
+
const chunk = msg.payload?.chunk;
|
|
1225
|
+
if (chunk) {
|
|
1226
|
+
onStream(chunk);
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
});
|
|
1230
|
+
}
|
|
1231
|
+
try {
|
|
1232
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1233
|
+
return response;
|
|
1234
|
+
} finally {
|
|
1235
|
+
if (streamUnsubscribe) {
|
|
1236
|
+
streamUnsubscribe();
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
async function sendUserPromptSuggestionsRequest(client, prompt, userId, limit = 5, timeout) {
|
|
1241
|
+
if (!prompt || prompt.trim().length === 0) {
|
|
1242
|
+
return null;
|
|
1243
|
+
}
|
|
1244
|
+
const messageId = `suggestions_${Date.now()}`;
|
|
1245
|
+
const message = UserPromptSuggestionsRequestMessageSchema.parse({
|
|
1246
|
+
id: messageId,
|
|
1247
|
+
type: "USER_PROMPT_SUGGESTIONS_REQ",
|
|
1248
|
+
from: {
|
|
1249
|
+
type: client.type
|
|
1250
|
+
},
|
|
1251
|
+
to: {
|
|
1252
|
+
type: "data-agent"
|
|
1253
|
+
},
|
|
1254
|
+
payload: {
|
|
1255
|
+
prompt,
|
|
1256
|
+
userId,
|
|
1257
|
+
limit
|
|
1258
|
+
}
|
|
1259
|
+
});
|
|
1260
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1261
|
+
return response;
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
// src/services/bundle.ts
|
|
1265
|
+
async function requestBundle(client, options) {
|
|
1266
|
+
const messageId = `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
1267
|
+
const message = BundleRequestMessageSchema.parse({
|
|
1268
|
+
id: messageId,
|
|
1269
|
+
type: "BUNDLE_REQ",
|
|
1270
|
+
from: { type: client.type },
|
|
1271
|
+
to: { type: "data-agent" },
|
|
1272
|
+
payload: { devbundlereq: options?.devbundlereq ?? false }
|
|
1273
|
+
});
|
|
1274
|
+
const chunks = [];
|
|
1275
|
+
let totalChunks = 0;
|
|
1276
|
+
const unsubscribe = client.onMessage((msg) => {
|
|
1277
|
+
try {
|
|
1278
|
+
if (msg.type === "BUNDLE_CHUNK" && msg.id?.startsWith(messageId)) {
|
|
1279
|
+
const chunkMessage = BundleChunkMessageSchema.parse(msg);
|
|
1280
|
+
const payload = chunkMessage.payload;
|
|
1281
|
+
chunks[payload.chunkIndex] = payload.chunk;
|
|
1282
|
+
totalChunks = payload.totalChunks;
|
|
1283
|
+
if (options?.onProgress) {
|
|
1284
|
+
options.onProgress(payload.progress);
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
} catch (error) {
|
|
1288
|
+
console.error("[SuperAtom] Failed to parse bundle chunk:", error);
|
|
1289
|
+
}
|
|
1290
|
+
});
|
|
1291
|
+
client.send(message);
|
|
1292
|
+
const timeout = options?.timeout ?? 6e4;
|
|
1293
|
+
const startTime = Date.now();
|
|
1294
|
+
return new Promise((resolve, reject) => {
|
|
1295
|
+
const checkInterval = setInterval(() => {
|
|
1296
|
+
if (Date.now() - startTime > timeout) {
|
|
1297
|
+
clearInterval(checkInterval);
|
|
1298
|
+
unsubscribe();
|
|
1299
|
+
reject(new Error(`Bundle request timeout after ${timeout}ms`));
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
if (totalChunks > 0 && chunks.length === totalChunks) {
|
|
1303
|
+
clearInterval(checkInterval);
|
|
1304
|
+
unsubscribe();
|
|
1305
|
+
const bundle = chunks.join("");
|
|
1306
|
+
resolve(bundle);
|
|
1307
|
+
}
|
|
1308
|
+
}, 100);
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
// src/services/data.ts
|
|
1313
|
+
async function requestData(client, options) {
|
|
1314
|
+
const messageId = `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
1315
|
+
const message = DataRequestMessageSchema.parse({
|
|
1316
|
+
id: messageId,
|
|
1317
|
+
type: "DATA_REQ",
|
|
1318
|
+
from: { type: client.type },
|
|
1319
|
+
to: { type: "data-agent" },
|
|
1320
|
+
payload: {
|
|
1321
|
+
collection: options.collection,
|
|
1322
|
+
op: options.operation,
|
|
1323
|
+
params: options.params,
|
|
1324
|
+
SA_RUNTIME: options.SA_RUNTIME
|
|
1325
|
+
}
|
|
1326
|
+
});
|
|
1327
|
+
const response = await client.sendWithResponse(message, options.timeout);
|
|
1328
|
+
const payload = response.payload;
|
|
1329
|
+
return {
|
|
1330
|
+
data: payload.data,
|
|
1331
|
+
error: payload.error,
|
|
1332
|
+
executionMs: payload.executionMs
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
// src/services/component.ts
|
|
1337
|
+
async function getComponentSuggestions(client, query, options) {
|
|
1338
|
+
const messageId = `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
1339
|
+
const message = {
|
|
1340
|
+
id: messageId,
|
|
1341
|
+
type: "USER_PROMPT_REQ",
|
|
1342
|
+
to: { type: "data-agent" },
|
|
1343
|
+
payload: {
|
|
1344
|
+
prompt: query
|
|
1345
|
+
}
|
|
1346
|
+
};
|
|
1347
|
+
const response = await client.sendWithResponse(message, options?.timeout);
|
|
1348
|
+
const payload = response.payload;
|
|
1349
|
+
return {
|
|
1350
|
+
component: payload.component,
|
|
1351
|
+
error: payload.error
|
|
1352
|
+
};
|
|
1353
|
+
}
|
|
1354
|
+
async function sendComponents(client, components) {
|
|
1355
|
+
const messageId = `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
1356
|
+
const ws_msg = {
|
|
1357
|
+
id: messageId,
|
|
1358
|
+
type: "COMPONENT_LIST_RES",
|
|
1359
|
+
from: {
|
|
1360
|
+
type: client.type
|
|
1361
|
+
},
|
|
1362
|
+
to: {
|
|
1363
|
+
type: "data-agent"
|
|
1364
|
+
},
|
|
1365
|
+
payload: {
|
|
1366
|
+
components
|
|
1367
|
+
}
|
|
1368
|
+
};
|
|
1369
|
+
client.send(ws_msg);
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
// src/services/users.ts
|
|
1373
|
+
async function createUser(client, username, password, email, fullname, role, userInfo, timeout) {
|
|
1374
|
+
const messageId = `users_create_${Date.now()}`;
|
|
1375
|
+
const message = UsersRequestMessageSchema.parse({
|
|
1376
|
+
id: messageId,
|
|
1377
|
+
type: "USERS",
|
|
1378
|
+
from: { type: client.type },
|
|
1379
|
+
to: { type: "data-agent" },
|
|
1380
|
+
payload: {
|
|
1381
|
+
operation: "create",
|
|
1382
|
+
data: {
|
|
1383
|
+
username,
|
|
1384
|
+
password,
|
|
1385
|
+
email,
|
|
1386
|
+
fullname,
|
|
1387
|
+
role,
|
|
1388
|
+
userInfo
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
});
|
|
1392
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1393
|
+
const payload = response.payload;
|
|
1394
|
+
return {
|
|
1395
|
+
success: payload.success,
|
|
1396
|
+
error: payload.error,
|
|
1397
|
+
message: payload.data?.message,
|
|
1398
|
+
username: payload.data?.username,
|
|
1399
|
+
email: payload.data?.email,
|
|
1400
|
+
fullname: payload.data?.fullname,
|
|
1401
|
+
role: payload.data?.role
|
|
1402
|
+
};
|
|
1403
|
+
}
|
|
1404
|
+
async function updateUser(client, id, updates, timeout) {
|
|
1405
|
+
const messageId = `users_update_${Date.now()}`;
|
|
1406
|
+
const message = UsersRequestMessageSchema.parse({
|
|
1407
|
+
id: messageId,
|
|
1408
|
+
type: "USERS",
|
|
1409
|
+
from: { type: client.type },
|
|
1410
|
+
to: { type: "data-agent" },
|
|
1411
|
+
payload: {
|
|
1412
|
+
operation: "update",
|
|
1413
|
+
data: {
|
|
1414
|
+
id,
|
|
1415
|
+
...updates
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
});
|
|
1419
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1420
|
+
const payload = response.payload;
|
|
1421
|
+
return {
|
|
1422
|
+
success: payload.success,
|
|
1423
|
+
error: payload.error,
|
|
1424
|
+
message: payload.data?.message,
|
|
1425
|
+
username: payload.data?.username,
|
|
1426
|
+
email: payload.data?.email,
|
|
1427
|
+
fullname: payload.data?.fullname,
|
|
1428
|
+
role: payload.data?.role
|
|
1429
|
+
};
|
|
1430
|
+
}
|
|
1431
|
+
async function deleteUser(client, id, timeout) {
|
|
1432
|
+
const messageId = `users_delete_${Date.now()}`;
|
|
1433
|
+
const message = UsersRequestMessageSchema.parse({
|
|
1434
|
+
id: messageId,
|
|
1435
|
+
type: "USERS",
|
|
1436
|
+
from: { type: client.type },
|
|
1437
|
+
to: { type: "data-agent" },
|
|
1438
|
+
payload: {
|
|
1439
|
+
operation: "delete",
|
|
1440
|
+
data: {
|
|
1441
|
+
id
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
});
|
|
1445
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1446
|
+
const payload = response.payload;
|
|
1447
|
+
return {
|
|
1448
|
+
success: payload.success,
|
|
1449
|
+
error: payload.error,
|
|
1450
|
+
message: payload.data?.message,
|
|
1451
|
+
username: payload.data?.username,
|
|
1452
|
+
email: payload.data?.email,
|
|
1453
|
+
fullname: payload.data?.fullname,
|
|
1454
|
+
role: payload.data?.role
|
|
1455
|
+
};
|
|
1456
|
+
}
|
|
1457
|
+
async function getAllUsers(client, timeout) {
|
|
1458
|
+
const messageId = `users_getall_${Date.now()}`;
|
|
1459
|
+
const message = UsersRequestMessageSchema.parse({
|
|
1460
|
+
id: messageId,
|
|
1461
|
+
type: "USERS",
|
|
1462
|
+
from: { type: client.type },
|
|
1463
|
+
to: { type: "data-agent" },
|
|
1464
|
+
payload: {
|
|
1465
|
+
operation: "getAll"
|
|
1466
|
+
}
|
|
1467
|
+
});
|
|
1468
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1469
|
+
const payload = response.payload;
|
|
1470
|
+
return {
|
|
1471
|
+
success: payload.success,
|
|
1472
|
+
error: payload.error,
|
|
1473
|
+
users: payload.data?.users,
|
|
1474
|
+
count: payload.data?.count,
|
|
1475
|
+
message: payload.data?.message
|
|
1476
|
+
};
|
|
1477
|
+
}
|
|
1478
|
+
async function getUser(client, username, timeout) {
|
|
1479
|
+
const messageId = `users_getone_${Date.now()}`;
|
|
1480
|
+
const message = UsersRequestMessageSchema.parse({
|
|
1481
|
+
id: messageId,
|
|
1482
|
+
type: "USERS",
|
|
1483
|
+
from: { type: client.type },
|
|
1484
|
+
to: { type: "data-agent" },
|
|
1485
|
+
payload: {
|
|
1486
|
+
operation: "getOne",
|
|
1487
|
+
data: {
|
|
1488
|
+
username
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
});
|
|
1492
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1493
|
+
const payload = response.payload;
|
|
1494
|
+
return {
|
|
1495
|
+
success: payload.success,
|
|
1496
|
+
error: payload.error,
|
|
1497
|
+
user: payload.data?.user,
|
|
1498
|
+
message: payload.data?.message
|
|
1499
|
+
};
|
|
1500
|
+
}
|
|
1501
|
+
async function queryUsers(client, options = {}, timeout) {
|
|
1502
|
+
const { filters, limit, sort } = options;
|
|
1503
|
+
const messageId = `users_query_${Date.now()}`;
|
|
1504
|
+
const message = UsersRequestMessageSchema.parse({
|
|
1505
|
+
id: messageId,
|
|
1506
|
+
type: "USERS",
|
|
1507
|
+
from: { type: client.type },
|
|
1508
|
+
to: { type: "data-agent" },
|
|
1509
|
+
payload: {
|
|
1510
|
+
operation: "query",
|
|
1511
|
+
data: {
|
|
1512
|
+
filters,
|
|
1513
|
+
limit,
|
|
1514
|
+
sort
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
});
|
|
1518
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1519
|
+
const payload = response.payload;
|
|
1520
|
+
return {
|
|
1521
|
+
success: payload.success,
|
|
1522
|
+
error: payload.error,
|
|
1523
|
+
users: payload.data?.users,
|
|
1524
|
+
count: payload.data?.count,
|
|
1525
|
+
message: payload.data?.message
|
|
1526
|
+
};
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
// src/services/dashboards/index.ts
|
|
1530
|
+
async function createDashboard(client, options, timeout) {
|
|
1531
|
+
const { dashboardId, projectId, name, description, published, createdBy, allowedUsers, dashboard } = options;
|
|
1532
|
+
const messageId = `dashboards_create_${Date.now()}`;
|
|
1533
|
+
const message = DashboardsRequestMessageSchema.parse({
|
|
1534
|
+
id: messageId,
|
|
1535
|
+
type: "DASHBOARDS",
|
|
1536
|
+
from: { type: client.type },
|
|
1537
|
+
to: { type: "data-agent" },
|
|
1538
|
+
payload: {
|
|
1539
|
+
operation: "create",
|
|
1540
|
+
data: {
|
|
1541
|
+
dashboardId,
|
|
1542
|
+
projectId,
|
|
1543
|
+
name,
|
|
1544
|
+
description,
|
|
1545
|
+
published,
|
|
1546
|
+
createdBy,
|
|
1547
|
+
allowedUsers,
|
|
1548
|
+
dashboard
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
});
|
|
1552
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1553
|
+
const payload = response.payload;
|
|
1554
|
+
return {
|
|
1555
|
+
success: payload.success,
|
|
1556
|
+
error: payload.error,
|
|
1557
|
+
message: payload.data?.message,
|
|
1558
|
+
id: payload.data?.id,
|
|
1559
|
+
dashboardId: payload.data?.dashboardId,
|
|
1560
|
+
dashboard: payload.data?.dashboard
|
|
1561
|
+
};
|
|
1562
|
+
}
|
|
1563
|
+
async function updateDashboard(client, options, timeout) {
|
|
1564
|
+
const { id, name, description, published, createdBy, updatedBy, allowedUsers, dashboard } = options;
|
|
1565
|
+
const messageId = `dashboards_update_${Date.now()}`;
|
|
1566
|
+
const message = DashboardsRequestMessageSchema.parse({
|
|
1567
|
+
id: messageId,
|
|
1568
|
+
type: "DASHBOARDS",
|
|
1569
|
+
from: { type: client.type },
|
|
1570
|
+
to: { type: "data-agent" },
|
|
1571
|
+
payload: {
|
|
1572
|
+
operation: "update",
|
|
1573
|
+
data: {
|
|
1574
|
+
id,
|
|
1575
|
+
name,
|
|
1576
|
+
description,
|
|
1577
|
+
published,
|
|
1578
|
+
createdBy,
|
|
1579
|
+
updatedBy,
|
|
1580
|
+
allowedUsers,
|
|
1581
|
+
dashboard
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
});
|
|
1585
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1586
|
+
const payload = response.payload;
|
|
1587
|
+
return {
|
|
1588
|
+
success: payload.success,
|
|
1589
|
+
error: payload.error,
|
|
1590
|
+
message: payload.data?.message,
|
|
1591
|
+
id: payload.data?.id,
|
|
1592
|
+
dashboardId: payload.data?.dashboardId,
|
|
1593
|
+
dashboard: payload.data?.dashboard
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1596
|
+
async function deleteDashboard(client, id, timeout) {
|
|
1597
|
+
const messageId = `dashboards_delete_${Date.now()}`;
|
|
1598
|
+
const message = DashboardsRequestMessageSchema.parse({
|
|
1599
|
+
id: messageId,
|
|
1600
|
+
type: "DASHBOARDS",
|
|
1601
|
+
from: { type: client.type },
|
|
1602
|
+
to: { type: "data-agent" },
|
|
1603
|
+
payload: {
|
|
1604
|
+
operation: "delete",
|
|
1605
|
+
data: {
|
|
1606
|
+
id
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
});
|
|
1610
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1611
|
+
const payload = response.payload;
|
|
1612
|
+
return {
|
|
1613
|
+
success: payload.success,
|
|
1614
|
+
error: payload.error,
|
|
1615
|
+
message: payload.data?.message,
|
|
1616
|
+
id: payload.data?.id
|
|
1617
|
+
};
|
|
1618
|
+
}
|
|
1619
|
+
async function getAllDashboards(client, timeout) {
|
|
1620
|
+
const messageId = `dashboards_getall_${Date.now()}`;
|
|
1621
|
+
const message = DashboardsRequestMessageSchema.parse({
|
|
1622
|
+
id: messageId,
|
|
1623
|
+
type: "DASHBOARDS",
|
|
1624
|
+
from: { type: client.type },
|
|
1625
|
+
to: { type: "data-agent" },
|
|
1626
|
+
payload: {
|
|
1627
|
+
operation: "getAll"
|
|
1628
|
+
}
|
|
1629
|
+
});
|
|
1630
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1631
|
+
const payload = response.payload;
|
|
1632
|
+
return {
|
|
1633
|
+
success: payload.success,
|
|
1634
|
+
error: payload.error,
|
|
1635
|
+
dashboards: payload.data?.dashboards,
|
|
1636
|
+
count: payload.data?.count,
|
|
1637
|
+
message: payload.data?.message
|
|
1638
|
+
};
|
|
1639
|
+
}
|
|
1640
|
+
async function getDashboard(client, id, timeout) {
|
|
1641
|
+
const messageId = `dashboards_getone_${Date.now()}`;
|
|
1642
|
+
const message = DashboardsRequestMessageSchema.parse({
|
|
1643
|
+
id: messageId,
|
|
1644
|
+
type: "DASHBOARDS",
|
|
1645
|
+
from: { type: client.type },
|
|
1646
|
+
to: { type: "data-agent" },
|
|
1647
|
+
payload: {
|
|
1648
|
+
operation: "getOne",
|
|
1649
|
+
data: {
|
|
1650
|
+
id
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
});
|
|
1654
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1655
|
+
const payload = response.payload;
|
|
1656
|
+
return {
|
|
1657
|
+
success: payload.success,
|
|
1658
|
+
error: payload.error,
|
|
1659
|
+
id: payload.data?.id,
|
|
1660
|
+
dashboardId: payload.data?.dashboardId,
|
|
1661
|
+
dashboard: payload.data?.dashboard,
|
|
1662
|
+
message: payload.data?.message
|
|
1663
|
+
};
|
|
1664
|
+
}
|
|
1665
|
+
async function queryDashboards(client, options = {}, timeout) {
|
|
1666
|
+
const { filters, limit, sort } = options;
|
|
1667
|
+
const messageId = `dashboards_query_${Date.now()}`;
|
|
1668
|
+
const message = DashboardsRequestMessageSchema.parse({
|
|
1669
|
+
id: messageId,
|
|
1670
|
+
type: "DASHBOARDS",
|
|
1671
|
+
from: { type: client.type },
|
|
1672
|
+
to: { type: "data-agent" },
|
|
1673
|
+
payload: {
|
|
1674
|
+
operation: "query",
|
|
1675
|
+
data: {
|
|
1676
|
+
filters,
|
|
1677
|
+
limit,
|
|
1678
|
+
sort
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
});
|
|
1682
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1683
|
+
const payload = response.payload;
|
|
1684
|
+
return {
|
|
1685
|
+
success: payload.success,
|
|
1686
|
+
error: payload.error,
|
|
1687
|
+
dashboards: payload.data?.dashboards,
|
|
1688
|
+
count: payload.data?.count,
|
|
1689
|
+
message: payload.data?.message
|
|
1690
|
+
};
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
// src/services/reports/index.ts
|
|
1694
|
+
async function createReport(client, options, timeout) {
|
|
1695
|
+
const { reportId, projectId, name, description, published, createdBy, report } = options;
|
|
1696
|
+
const messageId = `reports_create_${Date.now()}`;
|
|
1697
|
+
const message = ReportsRequestMessageSchema.parse({
|
|
1698
|
+
id: messageId,
|
|
1699
|
+
type: "REPORTS",
|
|
1700
|
+
from: { type: client.type },
|
|
1701
|
+
to: { type: "data-agent" },
|
|
1702
|
+
payload: {
|
|
1703
|
+
operation: "create",
|
|
1704
|
+
data: {
|
|
1705
|
+
reportId,
|
|
1706
|
+
projectId,
|
|
1707
|
+
name,
|
|
1708
|
+
description,
|
|
1709
|
+
published,
|
|
1710
|
+
createdBy,
|
|
1711
|
+
report
|
|
1712
|
+
}
|
|
1713
|
+
}
|
|
1714
|
+
});
|
|
1715
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1716
|
+
const payload = response.payload;
|
|
1717
|
+
return {
|
|
1718
|
+
success: payload.success,
|
|
1719
|
+
error: payload.error,
|
|
1720
|
+
message: payload.data?.message,
|
|
1721
|
+
id: payload.data?.id,
|
|
1722
|
+
reportId: payload.data?.reportId,
|
|
1723
|
+
report: payload.data?.report
|
|
1724
|
+
};
|
|
1725
|
+
}
|
|
1726
|
+
async function updateReport(client, options, timeout) {
|
|
1727
|
+
const { id, name, description, published, createdBy, updatedBy, report } = options;
|
|
1728
|
+
const messageId = `reports_update_${Date.now()}`;
|
|
1729
|
+
const message = ReportsRequestMessageSchema.parse({
|
|
1730
|
+
id: messageId,
|
|
1731
|
+
type: "REPORTS",
|
|
1732
|
+
from: { type: client.type },
|
|
1733
|
+
to: { type: "data-agent" },
|
|
1734
|
+
payload: {
|
|
1735
|
+
operation: "update",
|
|
1736
|
+
data: {
|
|
1737
|
+
id,
|
|
1738
|
+
name,
|
|
1739
|
+
description,
|
|
1740
|
+
published,
|
|
1741
|
+
createdBy,
|
|
1742
|
+
updatedBy,
|
|
1743
|
+
report
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
});
|
|
1747
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1748
|
+
const payload = response.payload;
|
|
1749
|
+
return {
|
|
1750
|
+
success: payload.success,
|
|
1751
|
+
error: payload.error,
|
|
1752
|
+
message: payload.data?.message,
|
|
1753
|
+
id: payload.data?.id,
|
|
1754
|
+
reportId: payload.data?.reportId,
|
|
1755
|
+
report: payload.data?.report
|
|
1756
|
+
};
|
|
1757
|
+
}
|
|
1758
|
+
async function deleteReport(client, id, timeout) {
|
|
1759
|
+
const messageId = `reports_delete_${Date.now()}`;
|
|
1760
|
+
const message = ReportsRequestMessageSchema.parse({
|
|
1761
|
+
id: messageId,
|
|
1762
|
+
type: "REPORTS",
|
|
1763
|
+
from: { type: client.type },
|
|
1764
|
+
to: { type: "data-agent" },
|
|
1765
|
+
payload: {
|
|
1766
|
+
operation: "delete",
|
|
1767
|
+
data: {
|
|
1768
|
+
id
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
});
|
|
1772
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1773
|
+
const payload = response.payload;
|
|
1774
|
+
return {
|
|
1775
|
+
success: payload.success,
|
|
1776
|
+
error: payload.error,
|
|
1777
|
+
message: payload.data?.message,
|
|
1778
|
+
id: payload.data?.id
|
|
1779
|
+
};
|
|
1780
|
+
}
|
|
1781
|
+
async function getAllReports(client, timeout) {
|
|
1782
|
+
const messageId = `reports_getall_${Date.now()}`;
|
|
1783
|
+
const message = ReportsRequestMessageSchema.parse({
|
|
1784
|
+
id: messageId,
|
|
1785
|
+
type: "REPORTS",
|
|
1786
|
+
from: { type: client.type },
|
|
1787
|
+
to: { type: "data-agent" },
|
|
1788
|
+
payload: {
|
|
1789
|
+
operation: "getAll"
|
|
1790
|
+
}
|
|
1791
|
+
});
|
|
1792
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1793
|
+
const payload = response.payload;
|
|
1794
|
+
return {
|
|
1795
|
+
success: payload.success,
|
|
1796
|
+
error: payload.error,
|
|
1797
|
+
reports: payload.data?.reports,
|
|
1798
|
+
count: payload.data?.count,
|
|
1799
|
+
message: payload.data?.message
|
|
1800
|
+
};
|
|
1801
|
+
}
|
|
1802
|
+
async function getReport(client, id, timeout) {
|
|
1803
|
+
const messageId = `reports_getone_${Date.now()}`;
|
|
1804
|
+
const message = ReportsRequestMessageSchema.parse({
|
|
1805
|
+
id: messageId,
|
|
1806
|
+
type: "REPORTS",
|
|
1807
|
+
from: { type: client.type },
|
|
1808
|
+
to: { type: "data-agent" },
|
|
1809
|
+
payload: {
|
|
1810
|
+
operation: "getOne",
|
|
1811
|
+
data: {
|
|
1812
|
+
id
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
});
|
|
1816
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1817
|
+
const payload = response.payload;
|
|
1818
|
+
return {
|
|
1819
|
+
success: payload.success,
|
|
1820
|
+
error: payload.error,
|
|
1821
|
+
id: payload.data?.id,
|
|
1822
|
+
reportId: payload.data?.reportId,
|
|
1823
|
+
report: payload.data?.report,
|
|
1824
|
+
message: payload.data?.message
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1827
|
+
async function queryReports(client, options = {}, timeout) {
|
|
1828
|
+
const { filters, limit, sort } = options;
|
|
1829
|
+
const messageId = `reports_query_${Date.now()}`;
|
|
1830
|
+
const message = ReportsRequestMessageSchema.parse({
|
|
1831
|
+
id: messageId,
|
|
1832
|
+
type: "REPORTS",
|
|
1833
|
+
from: { type: client.type },
|
|
1834
|
+
to: { type: "data-agent" },
|
|
1835
|
+
payload: {
|
|
1836
|
+
operation: "query",
|
|
1837
|
+
data: {
|
|
1838
|
+
filters,
|
|
1839
|
+
limit,
|
|
1840
|
+
sort
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
});
|
|
1844
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1845
|
+
const payload = response.payload;
|
|
1846
|
+
return {
|
|
1847
|
+
success: payload.success,
|
|
1848
|
+
error: payload.error,
|
|
1849
|
+
reports: payload.data?.reports,
|
|
1850
|
+
count: payload.data?.count,
|
|
1851
|
+
message: payload.data?.message
|
|
1852
|
+
};
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
// src/services/bookmarks/index.ts
|
|
1856
|
+
async function createBookmark(client, options, timeout) {
|
|
1857
|
+
const { userId, uiblock, threadId, name, description } = options;
|
|
1858
|
+
const messageId = `bookmarks_create_${Date.now()}`;
|
|
1859
|
+
const message = BookmarksRequestMessageSchema.parse({
|
|
1860
|
+
id: messageId,
|
|
1861
|
+
type: "BOOKMARKS",
|
|
1862
|
+
from: { type: client.type },
|
|
1863
|
+
to: { type: "data-agent" },
|
|
1864
|
+
payload: {
|
|
1865
|
+
operation: "create",
|
|
1866
|
+
data: {
|
|
1867
|
+
userId,
|
|
1868
|
+
threadId,
|
|
1869
|
+
name,
|
|
1870
|
+
description,
|
|
1871
|
+
uiblock
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
});
|
|
1875
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1876
|
+
const payload = response.payload;
|
|
1877
|
+
return {
|
|
1878
|
+
success: payload.success,
|
|
1879
|
+
error: payload.error,
|
|
1880
|
+
message: payload.message,
|
|
1881
|
+
data: Array.isArray(payload.data) ? payload.data[0] : payload.data
|
|
1882
|
+
};
|
|
1883
|
+
}
|
|
1884
|
+
async function updateBookmark(client, options, timeout) {
|
|
1885
|
+
const { id, uiblock, threadId, name, description } = options;
|
|
1886
|
+
const messageId = `bookmarks_update_${Date.now()}`;
|
|
1887
|
+
const message = BookmarksRequestMessageSchema.parse({
|
|
1888
|
+
id: messageId,
|
|
1889
|
+
type: "BOOKMARKS",
|
|
1890
|
+
from: { type: client.type },
|
|
1891
|
+
to: { type: "data-agent" },
|
|
1892
|
+
payload: {
|
|
1893
|
+
operation: "update",
|
|
1894
|
+
data: {
|
|
1895
|
+
id,
|
|
1896
|
+
threadId,
|
|
1897
|
+
name,
|
|
1898
|
+
description,
|
|
1899
|
+
uiblock
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
});
|
|
1903
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1904
|
+
const payload = response.payload;
|
|
1905
|
+
return {
|
|
1906
|
+
success: payload.success,
|
|
1907
|
+
error: payload.error,
|
|
1908
|
+
message: payload.message,
|
|
1909
|
+
data: Array.isArray(payload.data) ? payload.data[0] : payload.data
|
|
1910
|
+
};
|
|
1911
|
+
}
|
|
1912
|
+
async function deleteBookmark(client, id, timeout) {
|
|
1913
|
+
const messageId = `bookmarks_delete_${Date.now()}`;
|
|
1914
|
+
const message = BookmarksRequestMessageSchema.parse({
|
|
1915
|
+
id: messageId,
|
|
1916
|
+
type: "BOOKMARKS",
|
|
1917
|
+
from: { type: client.type },
|
|
1918
|
+
to: { type: "data-agent" },
|
|
1919
|
+
payload: {
|
|
1920
|
+
operation: "delete",
|
|
1921
|
+
data: {
|
|
1922
|
+
id
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
});
|
|
1926
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1927
|
+
const payload = response.payload;
|
|
1928
|
+
return {
|
|
1929
|
+
success: payload.success,
|
|
1930
|
+
error: payload.error,
|
|
1931
|
+
message: payload.message,
|
|
1932
|
+
data: Array.isArray(payload.data) ? payload.data[0] : payload.data
|
|
1933
|
+
};
|
|
1934
|
+
}
|
|
1935
|
+
async function getAllBookmarks(client, timeout) {
|
|
1936
|
+
const messageId = `bookmarks_getall_${Date.now()}`;
|
|
1937
|
+
const message = BookmarksRequestMessageSchema.parse({
|
|
1938
|
+
id: messageId,
|
|
1939
|
+
type: "BOOKMARKS",
|
|
1940
|
+
from: { type: client.type },
|
|
1941
|
+
to: { type: "data-agent" },
|
|
1942
|
+
payload: {
|
|
1943
|
+
operation: "getAll"
|
|
1944
|
+
}
|
|
1945
|
+
});
|
|
1946
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1947
|
+
const payload = response.payload;
|
|
1948
|
+
return {
|
|
1949
|
+
success: payload.success,
|
|
1950
|
+
error: payload.error,
|
|
1951
|
+
data: Array.isArray(payload.data) ? payload.data : payload.data ? [payload.data] : [],
|
|
1952
|
+
count: payload.count,
|
|
1953
|
+
message: payload.message
|
|
1954
|
+
};
|
|
1955
|
+
}
|
|
1956
|
+
async function getBookmark(client, id, timeout) {
|
|
1957
|
+
const messageId = `bookmarks_getone_${Date.now()}`;
|
|
1958
|
+
const message = BookmarksRequestMessageSchema.parse({
|
|
1959
|
+
id: messageId,
|
|
1960
|
+
type: "BOOKMARKS",
|
|
1961
|
+
from: { type: client.type },
|
|
1962
|
+
to: { type: "data-agent" },
|
|
1963
|
+
payload: {
|
|
1964
|
+
operation: "getOne",
|
|
1965
|
+
data: {
|
|
1966
|
+
id
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
});
|
|
1970
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1971
|
+
const payload = response.payload;
|
|
1972
|
+
return {
|
|
1973
|
+
success: payload.success,
|
|
1974
|
+
error: payload.error,
|
|
1975
|
+
data: Array.isArray(payload.data) ? payload.data[0] : payload.data,
|
|
1976
|
+
message: payload.message
|
|
1977
|
+
};
|
|
1978
|
+
}
|
|
1979
|
+
async function queryBookmarks(client, options = {}, timeout) {
|
|
1980
|
+
const { filters, limit, sort } = options;
|
|
1981
|
+
const messageId = `bookmarks_query_${Date.now()}`;
|
|
1982
|
+
const message = BookmarksRequestMessageSchema.parse({
|
|
1983
|
+
id: messageId,
|
|
1984
|
+
type: "BOOKMARKS",
|
|
1985
|
+
from: { type: client.type },
|
|
1986
|
+
to: { type: "data-agent" },
|
|
1987
|
+
payload: {
|
|
1988
|
+
operation: "query",
|
|
1989
|
+
data: {
|
|
1990
|
+
filters,
|
|
1991
|
+
limit,
|
|
1992
|
+
sort
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
});
|
|
1996
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
1997
|
+
const payload = response.payload;
|
|
1998
|
+
return {
|
|
1999
|
+
success: payload.success,
|
|
2000
|
+
error: payload.error,
|
|
2001
|
+
data: Array.isArray(payload.data) ? payload.data : payload.data ? [payload.data] : [],
|
|
2002
|
+
count: payload.count,
|
|
2003
|
+
message: payload.message
|
|
2004
|
+
};
|
|
2005
|
+
}
|
|
2006
|
+
|
|
2007
|
+
// src/services/artifacts/index.ts
|
|
2008
|
+
async function createArtifact(client, options, timeout) {
|
|
2009
|
+
console.log("[SDK-WEB] createArtifact called with options:", JSON.stringify(options, null, 2));
|
|
2010
|
+
const { name, createdBy, dsl, type, filters, status } = options;
|
|
2011
|
+
console.log("[SDK-WEB] Extracted parameters:", JSON.stringify({
|
|
2012
|
+
name,
|
|
2013
|
+
createdBy,
|
|
2014
|
+
dsl: dsl ? "present" : "undefined",
|
|
2015
|
+
type,
|
|
2016
|
+
filters: filters ? "present" : "undefined",
|
|
2017
|
+
status
|
|
2018
|
+
}, null, 2));
|
|
2019
|
+
const messageId = `artifacts_create_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
2020
|
+
const messageData = {
|
|
2021
|
+
name,
|
|
2022
|
+
createdBy,
|
|
2023
|
+
dsl,
|
|
2024
|
+
type,
|
|
2025
|
+
filters,
|
|
2026
|
+
status
|
|
2027
|
+
};
|
|
2028
|
+
console.log("[SDK-WEB] Sending message data:", JSON.stringify(messageData, null, 2));
|
|
2029
|
+
const message = ArtifactsRequestMessageSchema.parse({
|
|
2030
|
+
id: messageId,
|
|
2031
|
+
type: "ARTIFACTS",
|
|
2032
|
+
from: { type: client.type },
|
|
2033
|
+
to: { type: "data-agent" },
|
|
2034
|
+
payload: {
|
|
2035
|
+
operation: "create",
|
|
2036
|
+
data: messageData
|
|
2037
|
+
}
|
|
2038
|
+
});
|
|
2039
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2040
|
+
const payload = response.payload;
|
|
2041
|
+
return {
|
|
2042
|
+
success: payload.success,
|
|
2043
|
+
error: payload.error,
|
|
2044
|
+
message: payload.message,
|
|
2045
|
+
data: Array.isArray(payload.data) ? payload.data[0] : payload.data
|
|
2046
|
+
};
|
|
2047
|
+
}
|
|
2048
|
+
async function updateArtifact(client, options, timeout) {
|
|
2049
|
+
const { id, name, dsl, type, filters, status, deleted } = options;
|
|
2050
|
+
const messageId = `artifacts_update_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
2051
|
+
const message = ArtifactsRequestMessageSchema.parse({
|
|
2052
|
+
id: messageId,
|
|
2053
|
+
type: "ARTIFACTS",
|
|
2054
|
+
from: { type: client.type },
|
|
2055
|
+
to: { type: "data-agent" },
|
|
2056
|
+
payload: {
|
|
2057
|
+
operation: "update",
|
|
2058
|
+
data: {
|
|
2059
|
+
id,
|
|
2060
|
+
name,
|
|
2061
|
+
dsl,
|
|
2062
|
+
type,
|
|
2063
|
+
filters,
|
|
2064
|
+
status,
|
|
2065
|
+
deleted
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
});
|
|
2069
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2070
|
+
const payload = response.payload;
|
|
2071
|
+
return {
|
|
2072
|
+
success: payload.success,
|
|
2073
|
+
error: payload.error,
|
|
2074
|
+
message: payload.message,
|
|
2075
|
+
data: Array.isArray(payload.data) ? payload.data[0] : payload.data
|
|
2076
|
+
};
|
|
2077
|
+
}
|
|
2078
|
+
async function deleteArtifact(client, id, timeout) {
|
|
2079
|
+
const messageId = `artifacts_delete_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
2080
|
+
const message = ArtifactsRequestMessageSchema.parse({
|
|
2081
|
+
id: messageId,
|
|
2082
|
+
type: "ARTIFACTS",
|
|
2083
|
+
from: { type: client.type },
|
|
2084
|
+
to: { type: "data-agent" },
|
|
2085
|
+
payload: {
|
|
2086
|
+
operation: "delete",
|
|
2087
|
+
data: {
|
|
2088
|
+
id
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
});
|
|
2092
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2093
|
+
const payload = response.payload;
|
|
2094
|
+
return {
|
|
2095
|
+
success: payload.success,
|
|
2096
|
+
error: payload.error,
|
|
2097
|
+
message: payload.message,
|
|
2098
|
+
data: Array.isArray(payload.data) ? payload.data[0] : payload.data
|
|
2099
|
+
};
|
|
2100
|
+
}
|
|
2101
|
+
async function getAllArtifacts(client, limit, timeout) {
|
|
2102
|
+
const messageId = `artifacts_getall_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
2103
|
+
const message = ArtifactsRequestMessageSchema.parse({
|
|
2104
|
+
id: messageId,
|
|
2105
|
+
type: "ARTIFACTS",
|
|
2106
|
+
from: { type: client.type },
|
|
2107
|
+
to: { type: "data-agent" },
|
|
2108
|
+
payload: {
|
|
2109
|
+
operation: "getAll",
|
|
2110
|
+
data: limit ? { limit } : void 0
|
|
2111
|
+
}
|
|
2112
|
+
});
|
|
2113
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2114
|
+
const payload = response.payload;
|
|
2115
|
+
return {
|
|
2116
|
+
success: payload.success,
|
|
2117
|
+
error: payload.error,
|
|
2118
|
+
data: Array.isArray(payload.data) ? payload.data : payload.data ? [payload.data] : [],
|
|
2119
|
+
count: payload.count,
|
|
2120
|
+
message: payload.message
|
|
2121
|
+
};
|
|
2122
|
+
}
|
|
2123
|
+
async function getArtifact(client, id, timeout) {
|
|
2124
|
+
const messageId = `artifacts_getone_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
2125
|
+
const message = ArtifactsRequestMessageSchema.parse({
|
|
2126
|
+
id: messageId,
|
|
2127
|
+
type: "ARTIFACTS",
|
|
2128
|
+
from: { type: client.type },
|
|
2129
|
+
to: { type: "data-agent" },
|
|
2130
|
+
payload: {
|
|
2131
|
+
operation: "getOne",
|
|
2132
|
+
data: {
|
|
2133
|
+
id
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
});
|
|
2137
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2138
|
+
const payload = response.payload;
|
|
2139
|
+
return {
|
|
2140
|
+
success: payload.success,
|
|
2141
|
+
error: payload.error,
|
|
2142
|
+
data: Array.isArray(payload.data) ? payload.data[0] : payload.data,
|
|
2143
|
+
message: payload.message
|
|
2144
|
+
};
|
|
2145
|
+
}
|
|
2146
|
+
async function queryArtifacts(client, options = {}, timeout) {
|
|
2147
|
+
const { filters, limit, offset, sort } = options;
|
|
2148
|
+
const messageId = `artifacts_query_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
2149
|
+
console.log("[SDK-WEB] queryArtifacts - options.filters:", JSON.stringify(filters, null, 2));
|
|
2150
|
+
const messageBeforeParse = {
|
|
2151
|
+
id: messageId,
|
|
2152
|
+
type: "ARTIFACTS",
|
|
2153
|
+
from: { type: client.type },
|
|
2154
|
+
to: { type: "data-agent" },
|
|
2155
|
+
payload: {
|
|
2156
|
+
operation: "query",
|
|
2157
|
+
data: {
|
|
2158
|
+
filters,
|
|
2159
|
+
limit,
|
|
2160
|
+
offset,
|
|
2161
|
+
sort
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
};
|
|
2165
|
+
console.log("[SDK-WEB] queryArtifacts - BEFORE parse - payload.data.filters:", JSON.stringify(messageBeforeParse.payload.data.filters, null, 2));
|
|
2166
|
+
const message = ArtifactsRequestMessageSchema.parse(messageBeforeParse);
|
|
2167
|
+
console.log("[SDK-WEB] queryArtifacts - AFTER parse - payload.data.filters:", JSON.stringify(message.payload.data?.filters, null, 2));
|
|
2168
|
+
console.log("[SDK-WEB] queryArtifacts - filters.type:", message.payload.data?.filters?.type);
|
|
2169
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2170
|
+
const payload = response.payload;
|
|
2171
|
+
return {
|
|
2172
|
+
success: payload.success,
|
|
2173
|
+
error: payload.error,
|
|
2174
|
+
data: Array.isArray(payload.data) ? payload.data : payload.data ? [payload.data] : [],
|
|
2175
|
+
count: payload.count,
|
|
2176
|
+
message: payload.message
|
|
2177
|
+
};
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
// src/services/actions.ts
|
|
2181
|
+
async function getActions(client, options) {
|
|
2182
|
+
const messageId = `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
2183
|
+
const message = ActionsRequestMessageSchema.parse({
|
|
2184
|
+
id: messageId,
|
|
2185
|
+
type: "ACTIONS",
|
|
2186
|
+
from: { type: client.type },
|
|
2187
|
+
to: { type: "data-agent" },
|
|
2188
|
+
payload: {
|
|
2189
|
+
userId: options.userId,
|
|
2190
|
+
SA_RUNTIME: options.SA_RUNTIME
|
|
2191
|
+
}
|
|
2192
|
+
});
|
|
2193
|
+
const response = await client.sendWithResponse(message, options.timeout);
|
|
2194
|
+
const payload = response.payload;
|
|
2195
|
+
return {
|
|
2196
|
+
success: payload.success,
|
|
2197
|
+
data: payload.data,
|
|
2198
|
+
error: payload.error
|
|
2199
|
+
};
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
// src/services/uis/index.ts
|
|
2203
|
+
async function createUI(client, options, timeout) {
|
|
2204
|
+
const { uiId, projectId, name, description, createdBy, ui } = options;
|
|
2205
|
+
const messageId = `uis_create_${Date.now()}`;
|
|
2206
|
+
const message = UIsRequestMessageSchema.parse({
|
|
2207
|
+
id: messageId,
|
|
2208
|
+
type: "UIS",
|
|
2209
|
+
from: { type: client.type },
|
|
2210
|
+
to: { type: "data-agent" },
|
|
2211
|
+
payload: {
|
|
2212
|
+
operation: "create",
|
|
2213
|
+
data: {
|
|
2214
|
+
uiId,
|
|
2215
|
+
projectId,
|
|
2216
|
+
name,
|
|
2217
|
+
description,
|
|
2218
|
+
createdBy,
|
|
2219
|
+
ui
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
});
|
|
2223
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2224
|
+
const payload = response.payload;
|
|
2225
|
+
return {
|
|
2226
|
+
success: payload.success,
|
|
2227
|
+
error: payload.error,
|
|
2228
|
+
message: payload.data?.message,
|
|
2229
|
+
id: payload.data?.id,
|
|
2230
|
+
uiId: payload.data?.uiId,
|
|
2231
|
+
ui: payload.data?.ui
|
|
2232
|
+
};
|
|
2233
|
+
}
|
|
2234
|
+
async function updateUI(client, options, timeout) {
|
|
2235
|
+
const { id, name, description, createdBy, updatedBy, ui } = options;
|
|
2236
|
+
const messageId = `uis_update_${Date.now()}`;
|
|
2237
|
+
const message = UIsRequestMessageSchema.parse({
|
|
2238
|
+
id: messageId,
|
|
2239
|
+
type: "UIS",
|
|
2240
|
+
from: { type: client.type },
|
|
2241
|
+
to: { type: "data-agent" },
|
|
2242
|
+
payload: {
|
|
2243
|
+
operation: "update",
|
|
2244
|
+
data: {
|
|
2245
|
+
id,
|
|
2246
|
+
name,
|
|
2247
|
+
description,
|
|
2248
|
+
createdBy,
|
|
2249
|
+
updatedBy,
|
|
2250
|
+
ui
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
});
|
|
2254
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2255
|
+
const payload = response.payload;
|
|
2256
|
+
return {
|
|
2257
|
+
success: payload.success,
|
|
2258
|
+
error: payload.error,
|
|
2259
|
+
message: payload.data?.message,
|
|
2260
|
+
id: payload.data?.id,
|
|
2261
|
+
uiId: payload.data?.uiId,
|
|
2262
|
+
ui: payload.data?.ui
|
|
2263
|
+
};
|
|
2264
|
+
}
|
|
2265
|
+
async function deleteUI(client, id, timeout) {
|
|
2266
|
+
const messageId = `uis_delete_${Date.now()}`;
|
|
2267
|
+
const message = UIsRequestMessageSchema.parse({
|
|
2268
|
+
id: messageId,
|
|
2269
|
+
type: "UIS",
|
|
2270
|
+
from: { type: client.type },
|
|
2271
|
+
to: { type: "data-agent" },
|
|
2272
|
+
payload: {
|
|
2273
|
+
operation: "delete",
|
|
2274
|
+
data: {
|
|
2275
|
+
id
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
});
|
|
2279
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2280
|
+
const payload = response.payload;
|
|
2281
|
+
return {
|
|
2282
|
+
success: payload.success,
|
|
2283
|
+
error: payload.error,
|
|
2284
|
+
message: payload.data?.message,
|
|
2285
|
+
id: payload.data?.id
|
|
2286
|
+
};
|
|
2287
|
+
}
|
|
2288
|
+
async function getAllUIs(client, timeout) {
|
|
2289
|
+
const messageId = `uis_getall_${Date.now()}`;
|
|
2290
|
+
const message = UIsRequestMessageSchema.parse({
|
|
2291
|
+
id: messageId,
|
|
2292
|
+
type: "UIS",
|
|
2293
|
+
from: { type: client.type },
|
|
2294
|
+
to: { type: "data-agent" },
|
|
2295
|
+
payload: {
|
|
2296
|
+
operation: "getAll"
|
|
2297
|
+
}
|
|
2298
|
+
});
|
|
2299
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2300
|
+
const payload = response.payload;
|
|
2301
|
+
return {
|
|
2302
|
+
success: payload.success,
|
|
2303
|
+
error: payload.error,
|
|
2304
|
+
uis: payload.data?.uis,
|
|
2305
|
+
count: payload.data?.count,
|
|
2306
|
+
message: payload.data?.message
|
|
2307
|
+
};
|
|
2308
|
+
}
|
|
2309
|
+
async function getUI(client, id, timeout) {
|
|
2310
|
+
const messageId = `uis_getone_${Date.now()}`;
|
|
2311
|
+
const message = UIsRequestMessageSchema.parse({
|
|
2312
|
+
id: messageId,
|
|
2313
|
+
type: "UIS",
|
|
2314
|
+
from: { type: client.type },
|
|
2315
|
+
to: { type: "data-agent" },
|
|
2316
|
+
payload: {
|
|
2317
|
+
operation: "getOne",
|
|
2318
|
+
data: {
|
|
2319
|
+
id
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2322
|
+
});
|
|
2323
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2324
|
+
const payload = response.payload;
|
|
2325
|
+
return {
|
|
2326
|
+
success: payload.success,
|
|
2327
|
+
error: payload.error,
|
|
2328
|
+
id: payload.data?.id,
|
|
2329
|
+
uiId: payload.data?.uiId,
|
|
2330
|
+
ui: payload.data?.ui,
|
|
2331
|
+
message: payload.data?.message
|
|
2332
|
+
};
|
|
2333
|
+
}
|
|
2334
|
+
async function queryUIs(client, options = {}, timeout) {
|
|
2335
|
+
const { filters, limit, sort } = options;
|
|
2336
|
+
const messageId = `uis_query_${Date.now()}`;
|
|
2337
|
+
const message = UIsRequestMessageSchema.parse({
|
|
2338
|
+
id: messageId,
|
|
2339
|
+
type: "UIS",
|
|
2340
|
+
from: { type: client.type },
|
|
2341
|
+
to: { type: "data-agent" },
|
|
2342
|
+
payload: {
|
|
2343
|
+
operation: "query",
|
|
2344
|
+
data: {
|
|
2345
|
+
filters,
|
|
2346
|
+
limit,
|
|
2347
|
+
sort
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
});
|
|
2351
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2352
|
+
const payload = response.payload;
|
|
2353
|
+
return {
|
|
2354
|
+
success: payload.success,
|
|
2355
|
+
error: payload.error,
|
|
2356
|
+
uis: payload.data?.uis,
|
|
2357
|
+
count: payload.data?.count,
|
|
2358
|
+
message: payload.data?.message
|
|
2359
|
+
};
|
|
2360
|
+
}
|
|
2361
|
+
|
|
2362
|
+
// src/services/kb-nodes.ts
|
|
2363
|
+
async function createKbNode(client, title, content, createdBy, category, tags, type, timeout) {
|
|
2364
|
+
const messageId = `kb_nodes_create_${Date.now()}`;
|
|
2365
|
+
const message = KbNodesRequestMessageSchema.parse({
|
|
2366
|
+
id: messageId,
|
|
2367
|
+
type: "KB_NODES",
|
|
2368
|
+
from: { type: client.type },
|
|
2369
|
+
to: { type: "data-agent" },
|
|
2370
|
+
payload: {
|
|
2371
|
+
operation: "create",
|
|
2372
|
+
data: {
|
|
2373
|
+
title,
|
|
2374
|
+
content,
|
|
2375
|
+
createdBy,
|
|
2376
|
+
category,
|
|
2377
|
+
tags,
|
|
2378
|
+
type: type || "query"
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2381
|
+
});
|
|
2382
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2383
|
+
const payload = response.payload;
|
|
2384
|
+
return {
|
|
2385
|
+
success: payload.success,
|
|
2386
|
+
error: payload.error,
|
|
2387
|
+
message: payload.data?.message,
|
|
2388
|
+
node: payload.data ? {
|
|
2389
|
+
id: payload.data.id,
|
|
2390
|
+
title: payload.data.title || title,
|
|
2391
|
+
content: payload.data.content || content,
|
|
2392
|
+
category: payload.data.category,
|
|
2393
|
+
tags: payload.data.tags,
|
|
2394
|
+
type: payload.data.type,
|
|
2395
|
+
createdBy: payload.data.createdBy || createdBy,
|
|
2396
|
+
updatedBy: payload.data.updatedBy,
|
|
2397
|
+
createdAt: payload.data.createdAt,
|
|
2398
|
+
updatedAt: payload.data.updatedAt
|
|
2399
|
+
} : void 0
|
|
2400
|
+
};
|
|
2401
|
+
}
|
|
2402
|
+
async function updateKbNode(client, id, updatedBy, updates, timeout) {
|
|
2403
|
+
const messageId = `kb_nodes_update_${Date.now()}`;
|
|
2404
|
+
const message = KbNodesRequestMessageSchema.parse({
|
|
2405
|
+
id: messageId,
|
|
2406
|
+
type: "KB_NODES",
|
|
2407
|
+
from: { type: client.type },
|
|
2408
|
+
to: { type: "data-agent" },
|
|
2409
|
+
payload: {
|
|
2410
|
+
operation: "update",
|
|
2411
|
+
data: {
|
|
2412
|
+
id,
|
|
2413
|
+
updatedBy,
|
|
2414
|
+
...updates
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
});
|
|
2418
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2419
|
+
const payload = response.payload;
|
|
2420
|
+
return {
|
|
2421
|
+
success: payload.success,
|
|
2422
|
+
error: payload.error,
|
|
2423
|
+
message: payload.data?.message,
|
|
2424
|
+
node: payload.data ? {
|
|
2425
|
+
id: payload.data.id,
|
|
2426
|
+
title: payload.data.title || "",
|
|
2427
|
+
content: payload.data.content || "",
|
|
2428
|
+
category: payload.data.category,
|
|
2429
|
+
tags: payload.data.tags,
|
|
2430
|
+
type: payload.data.type,
|
|
2431
|
+
createdBy: payload.data.createdBy || "",
|
|
2432
|
+
updatedBy: payload.data.updatedBy,
|
|
2433
|
+
createdAt: payload.data.createdAt,
|
|
2434
|
+
updatedAt: payload.data.updatedAt
|
|
2435
|
+
} : void 0
|
|
2436
|
+
};
|
|
2437
|
+
}
|
|
2438
|
+
async function deleteKbNode(client, id, timeout) {
|
|
2439
|
+
const messageId = `kb_nodes_delete_${Date.now()}`;
|
|
2440
|
+
const message = KbNodesRequestMessageSchema.parse({
|
|
2441
|
+
id: messageId,
|
|
2442
|
+
type: "KB_NODES",
|
|
2443
|
+
from: { type: client.type },
|
|
2444
|
+
to: { type: "data-agent" },
|
|
2445
|
+
payload: {
|
|
2446
|
+
operation: "delete",
|
|
2447
|
+
data: {
|
|
2448
|
+
id
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
});
|
|
2452
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2453
|
+
const payload = response.payload;
|
|
2454
|
+
return {
|
|
2455
|
+
success: payload.success,
|
|
2456
|
+
error: payload.error,
|
|
2457
|
+
message: payload.data?.message
|
|
2458
|
+
};
|
|
2459
|
+
}
|
|
2460
|
+
async function getAllKbNodes(client, limit, offset, timeout) {
|
|
2461
|
+
const messageId = `kb_nodes_getall_${Date.now()}`;
|
|
2462
|
+
const message = KbNodesRequestMessageSchema.parse({
|
|
2463
|
+
id: messageId,
|
|
2464
|
+
type: "KB_NODES",
|
|
2465
|
+
from: { type: client.type },
|
|
2466
|
+
to: { type: "data-agent" },
|
|
2467
|
+
payload: {
|
|
2468
|
+
operation: "getAll",
|
|
2469
|
+
data: {
|
|
2470
|
+
limit,
|
|
2471
|
+
offset
|
|
2472
|
+
}
|
|
2473
|
+
}
|
|
2474
|
+
});
|
|
2475
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2476
|
+
const payload = response.payload;
|
|
2477
|
+
return {
|
|
2478
|
+
success: payload.success,
|
|
2479
|
+
error: payload.error,
|
|
2480
|
+
nodes: payload.data?.nodes,
|
|
2481
|
+
count: payload.data?.count,
|
|
2482
|
+
message: payload.data?.message
|
|
2483
|
+
};
|
|
2484
|
+
}
|
|
2485
|
+
async function getKbNode(client, id, timeout) {
|
|
2486
|
+
const messageId = `kb_nodes_getone_${Date.now()}`;
|
|
2487
|
+
const message = KbNodesRequestMessageSchema.parse({
|
|
2488
|
+
id: messageId,
|
|
2489
|
+
type: "KB_NODES",
|
|
2490
|
+
from: { type: client.type },
|
|
2491
|
+
to: { type: "data-agent" },
|
|
2492
|
+
payload: {
|
|
2493
|
+
operation: "getOne",
|
|
2494
|
+
data: {
|
|
2495
|
+
id
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
});
|
|
2499
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2500
|
+
const payload = response.payload;
|
|
2501
|
+
return {
|
|
2502
|
+
success: payload.success,
|
|
2503
|
+
error: payload.error,
|
|
2504
|
+
node: payload.data?.node,
|
|
2505
|
+
message: payload.data?.message
|
|
2506
|
+
};
|
|
2507
|
+
}
|
|
2508
|
+
async function searchKbNodes(client, options = {}, timeout) {
|
|
2509
|
+
const { query, category, tags, type, createdBy, limit, offset } = options;
|
|
2510
|
+
const messageId = `kb_nodes_search_${Date.now()}`;
|
|
2511
|
+
const message = KbNodesRequestMessageSchema.parse({
|
|
2512
|
+
id: messageId,
|
|
2513
|
+
type: "KB_NODES",
|
|
2514
|
+
from: { type: client.type },
|
|
2515
|
+
to: { type: "data-agent" },
|
|
2516
|
+
payload: {
|
|
2517
|
+
operation: "search",
|
|
2518
|
+
data: {
|
|
2519
|
+
query,
|
|
2520
|
+
category,
|
|
2521
|
+
tags,
|
|
2522
|
+
type,
|
|
2523
|
+
createdBy,
|
|
2524
|
+
limit,
|
|
2525
|
+
offset
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
});
|
|
2529
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2530
|
+
const payload = response.payload;
|
|
2531
|
+
return {
|
|
2532
|
+
success: payload.success,
|
|
2533
|
+
error: payload.error,
|
|
2534
|
+
nodes: payload.data?.nodes,
|
|
2535
|
+
count: payload.data?.count,
|
|
2536
|
+
message: payload.data?.message
|
|
2537
|
+
};
|
|
2538
|
+
}
|
|
2539
|
+
async function getKbNodesByCategory(client, category, limit, offset, timeout) {
|
|
2540
|
+
const messageId = `kb_nodes_getbycategory_${Date.now()}`;
|
|
2541
|
+
const message = KbNodesRequestMessageSchema.parse({
|
|
2542
|
+
id: messageId,
|
|
2543
|
+
type: "KB_NODES",
|
|
2544
|
+
from: { type: client.type },
|
|
2545
|
+
to: { type: "data-agent" },
|
|
2546
|
+
payload: {
|
|
2547
|
+
operation: "getByCategory",
|
|
2548
|
+
data: {
|
|
2549
|
+
category,
|
|
2550
|
+
limit,
|
|
2551
|
+
offset
|
|
2552
|
+
}
|
|
2553
|
+
}
|
|
2554
|
+
});
|
|
2555
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2556
|
+
const payload = response.payload;
|
|
2557
|
+
return {
|
|
2558
|
+
success: payload.success,
|
|
2559
|
+
error: payload.error,
|
|
2560
|
+
nodes: payload.data?.nodes,
|
|
2561
|
+
count: payload.data?.count,
|
|
2562
|
+
category: payload.data?.category || category,
|
|
2563
|
+
message: payload.data?.message
|
|
2564
|
+
};
|
|
2565
|
+
}
|
|
2566
|
+
async function getKbNodesByUser(client, userId, limit, offset, timeout) {
|
|
2567
|
+
const messageId = `kb_nodes_getbyuser_${Date.now()}`;
|
|
2568
|
+
const message = KbNodesRequestMessageSchema.parse({
|
|
2569
|
+
id: messageId,
|
|
2570
|
+
type: "KB_NODES",
|
|
2571
|
+
from: { type: client.type },
|
|
2572
|
+
to: { type: "data-agent" },
|
|
2573
|
+
payload: {
|
|
2574
|
+
operation: "getByUser",
|
|
2575
|
+
data: {
|
|
2576
|
+
userId,
|
|
2577
|
+
limit,
|
|
2578
|
+
offset
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
});
|
|
2582
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2583
|
+
const payload = response.payload;
|
|
2584
|
+
return {
|
|
2585
|
+
success: payload.success,
|
|
2586
|
+
error: payload.error,
|
|
2587
|
+
nodes: payload.data?.nodes,
|
|
2588
|
+
count: payload.data?.count,
|
|
2589
|
+
userId: payload.data?.userId || userId,
|
|
2590
|
+
message: payload.data?.message
|
|
2591
|
+
};
|
|
2592
|
+
}
|
|
2593
|
+
async function getKbNodeCategories(client, timeout) {
|
|
2594
|
+
const messageId = `kb_nodes_getcategories_${Date.now()}`;
|
|
2595
|
+
const message = KbNodesRequestMessageSchema.parse({
|
|
2596
|
+
id: messageId,
|
|
2597
|
+
type: "KB_NODES",
|
|
2598
|
+
from: { type: client.type },
|
|
2599
|
+
to: { type: "data-agent" },
|
|
2600
|
+
payload: {
|
|
2601
|
+
operation: "getCategories"
|
|
2602
|
+
}
|
|
2603
|
+
});
|
|
2604
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2605
|
+
const payload = response.payload;
|
|
2606
|
+
return {
|
|
2607
|
+
success: payload.success,
|
|
2608
|
+
error: payload.error,
|
|
2609
|
+
categories: payload.data?.categories,
|
|
2610
|
+
count: payload.data?.count,
|
|
2611
|
+
message: payload.data?.message
|
|
2612
|
+
};
|
|
2613
|
+
}
|
|
2614
|
+
async function getKbNodeTags(client, timeout) {
|
|
2615
|
+
const messageId = `kb_nodes_gettags_${Date.now()}`;
|
|
2616
|
+
const message = KbNodesRequestMessageSchema.parse({
|
|
2617
|
+
id: messageId,
|
|
2618
|
+
type: "KB_NODES",
|
|
2619
|
+
from: { type: client.type },
|
|
2620
|
+
to: { type: "data-agent" },
|
|
2621
|
+
payload: {
|
|
2622
|
+
operation: "getTags"
|
|
2623
|
+
}
|
|
2624
|
+
});
|
|
2625
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2626
|
+
const payload = response.payload;
|
|
2627
|
+
const responseData = payload.data;
|
|
2628
|
+
return {
|
|
2629
|
+
success: payload.success,
|
|
2630
|
+
error: payload.error,
|
|
2631
|
+
tags: responseData?.tags,
|
|
2632
|
+
count: payload.data?.count,
|
|
2633
|
+
message: payload.data?.message
|
|
2634
|
+
};
|
|
2635
|
+
}
|
|
2636
|
+
|
|
2637
|
+
// src/services/dash-comp.ts
|
|
2638
|
+
async function sendDashCompRequest(client, options) {
|
|
2639
|
+
const { prompt, userId, threadId, uiBlockId, timeout, existingComponents, reqType } = options;
|
|
2640
|
+
const messageId = `dash_comp_req_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
2641
|
+
const message = DashCompRequestMessageSchema.parse({
|
|
2642
|
+
id: messageId,
|
|
2643
|
+
type: "DASH_COMP_REQ",
|
|
2644
|
+
from: {
|
|
2645
|
+
type: client.type
|
|
2646
|
+
},
|
|
2647
|
+
to: {
|
|
2648
|
+
type: "data-agent"
|
|
2649
|
+
},
|
|
2650
|
+
payload: {
|
|
2651
|
+
prompt,
|
|
2652
|
+
userId,
|
|
2653
|
+
SA_RUNTIME: threadId || uiBlockId ? {
|
|
2654
|
+
threadId,
|
|
2655
|
+
uiBlockId
|
|
2656
|
+
} : void 0,
|
|
2657
|
+
existingComponents,
|
|
2658
|
+
req_type: reqType
|
|
2659
|
+
}
|
|
2660
|
+
});
|
|
2661
|
+
try {
|
|
2662
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2663
|
+
const payload = response.payload;
|
|
2664
|
+
if (!payload.success) {
|
|
2665
|
+
return {
|
|
2666
|
+
success: false,
|
|
2667
|
+
errors: payload.errors || ["Unknown error occurred"]
|
|
2668
|
+
};
|
|
2669
|
+
}
|
|
2670
|
+
if (reqType === "filter") {
|
|
2671
|
+
return {
|
|
2672
|
+
success: true,
|
|
2673
|
+
filterComponent: payload.data?.filterComponent,
|
|
2674
|
+
updatedComponents: payload.data?.updatedComponents,
|
|
2675
|
+
filterBindings: payload.data?.filterBindings,
|
|
2676
|
+
reasoning: payload.data?.reasoning
|
|
2677
|
+
};
|
|
2678
|
+
}
|
|
2679
|
+
return {
|
|
2680
|
+
success: true,
|
|
2681
|
+
component: payload.data?.component,
|
|
2682
|
+
reasoning: payload.data?.reasoning,
|
|
2683
|
+
dataSource: payload.data?.dataSource
|
|
2684
|
+
};
|
|
2685
|
+
} catch (error) {
|
|
2686
|
+
const errorMessage = error instanceof Error ? error.message : "Request failed";
|
|
2687
|
+
return {
|
|
2688
|
+
success: false,
|
|
2689
|
+
errors: [errorMessage]
|
|
2690
|
+
};
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
|
|
2694
|
+
// src/services/menus/index.ts
|
|
2695
|
+
async function createMenu(client, options, timeout) {
|
|
2696
|
+
const { name, componentName, icon, userMessage, parentId, sortOrder, props, isActive } = options;
|
|
2697
|
+
const messageId = `menus_create_${Date.now()}`;
|
|
2698
|
+
const message = MenusRequestMessageSchema.parse({
|
|
2699
|
+
id: messageId,
|
|
2700
|
+
type: "MENUS",
|
|
2701
|
+
from: { type: client.type },
|
|
2702
|
+
to: { type: "data-agent" },
|
|
2703
|
+
payload: {
|
|
2704
|
+
operation: "create",
|
|
2705
|
+
data: {
|
|
2706
|
+
name,
|
|
2707
|
+
componentName,
|
|
2708
|
+
icon,
|
|
2709
|
+
userMessage,
|
|
2710
|
+
parentId,
|
|
2711
|
+
sortOrder,
|
|
2712
|
+
props,
|
|
2713
|
+
isActive
|
|
2714
|
+
}
|
|
2715
|
+
}
|
|
2716
|
+
});
|
|
2717
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2718
|
+
const payload = response.payload;
|
|
2719
|
+
return {
|
|
2720
|
+
success: payload.success,
|
|
2721
|
+
error: payload.error,
|
|
2722
|
+
message: payload.message,
|
|
2723
|
+
data: payload.data
|
|
2724
|
+
};
|
|
2725
|
+
}
|
|
2726
|
+
async function updateMenu(client, options, timeout) {
|
|
2727
|
+
const { id, name, componentName, icon, userMessage, parentId, sortOrder, props, isActive } = options;
|
|
2728
|
+
const messageId = `menus_update_${Date.now()}`;
|
|
2729
|
+
const message = MenusRequestMessageSchema.parse({
|
|
2730
|
+
id: messageId,
|
|
2731
|
+
type: "MENUS",
|
|
2732
|
+
from: { type: client.type },
|
|
2733
|
+
to: { type: "data-agent" },
|
|
2734
|
+
payload: {
|
|
2735
|
+
operation: "update",
|
|
2736
|
+
data: {
|
|
2737
|
+
id,
|
|
2738
|
+
name,
|
|
2739
|
+
componentName,
|
|
2740
|
+
icon,
|
|
2741
|
+
userMessage,
|
|
2742
|
+
parentId,
|
|
2743
|
+
sortOrder,
|
|
2744
|
+
props,
|
|
2745
|
+
isActive
|
|
2746
|
+
}
|
|
2747
|
+
}
|
|
2748
|
+
});
|
|
2749
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2750
|
+
const payload = response.payload;
|
|
2751
|
+
return {
|
|
2752
|
+
success: payload.success,
|
|
2753
|
+
error: payload.error,
|
|
2754
|
+
message: payload.message,
|
|
2755
|
+
data: payload.data
|
|
2756
|
+
};
|
|
2757
|
+
}
|
|
2758
|
+
async function deleteMenu(client, id, timeout) {
|
|
2759
|
+
const messageId = `menus_delete_${Date.now()}`;
|
|
2760
|
+
const message = MenusRequestMessageSchema.parse({
|
|
2761
|
+
id: messageId,
|
|
2762
|
+
type: "MENUS",
|
|
2763
|
+
from: { type: client.type },
|
|
2764
|
+
to: { type: "data-agent" },
|
|
2765
|
+
payload: {
|
|
2766
|
+
operation: "delete",
|
|
2767
|
+
data: {
|
|
2768
|
+
id
|
|
2769
|
+
}
|
|
2770
|
+
}
|
|
2771
|
+
});
|
|
2772
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2773
|
+
const payload = response.payload;
|
|
2774
|
+
return {
|
|
2775
|
+
success: payload.success,
|
|
2776
|
+
error: payload.error,
|
|
2777
|
+
message: payload.message,
|
|
2778
|
+
data: payload.data
|
|
2779
|
+
};
|
|
2780
|
+
}
|
|
2781
|
+
async function getAllMenus(client, timeout) {
|
|
2782
|
+
const messageId = `menus_getall_${Date.now()}`;
|
|
2783
|
+
const message = MenusRequestMessageSchema.parse({
|
|
2784
|
+
id: messageId,
|
|
2785
|
+
type: "MENUS",
|
|
2786
|
+
from: { type: client.type },
|
|
2787
|
+
to: { type: "data-agent" },
|
|
2788
|
+
payload: {
|
|
2789
|
+
operation: "getAll"
|
|
2790
|
+
}
|
|
2791
|
+
});
|
|
2792
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2793
|
+
const payload = response.payload;
|
|
2794
|
+
return {
|
|
2795
|
+
success: payload.success,
|
|
2796
|
+
error: payload.error,
|
|
2797
|
+
menus: Array.isArray(payload.data) ? payload.data : void 0,
|
|
2798
|
+
count: payload.count,
|
|
2799
|
+
message: payload.message
|
|
2800
|
+
};
|
|
2801
|
+
}
|
|
2802
|
+
async function getMenu(client, id, timeout) {
|
|
2803
|
+
const messageId = `menus_getone_${Date.now()}`;
|
|
2804
|
+
const message = MenusRequestMessageSchema.parse({
|
|
2805
|
+
id: messageId,
|
|
2806
|
+
type: "MENUS",
|
|
2807
|
+
from: { type: client.type },
|
|
2808
|
+
to: { type: "data-agent" },
|
|
2809
|
+
payload: {
|
|
2810
|
+
operation: "getOne",
|
|
2811
|
+
data: {
|
|
2812
|
+
id
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
});
|
|
2816
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2817
|
+
const payload = response.payload;
|
|
2818
|
+
return {
|
|
2819
|
+
success: payload.success,
|
|
2820
|
+
error: payload.error,
|
|
2821
|
+
menu: payload.data,
|
|
2822
|
+
message: payload.message
|
|
2823
|
+
};
|
|
2824
|
+
}
|
|
2825
|
+
async function getRootMenus(client, timeout) {
|
|
2826
|
+
const messageId = `menus_getrootmenus_${Date.now()}`;
|
|
2827
|
+
const message = MenusRequestMessageSchema.parse({
|
|
2828
|
+
id: messageId,
|
|
2829
|
+
type: "MENUS",
|
|
2830
|
+
from: { type: client.type },
|
|
2831
|
+
to: { type: "data-agent" },
|
|
2832
|
+
payload: {
|
|
2833
|
+
operation: "getRootMenus"
|
|
2834
|
+
}
|
|
2835
|
+
});
|
|
2836
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2837
|
+
const payload = response.payload;
|
|
2838
|
+
return {
|
|
2839
|
+
success: payload.success,
|
|
2840
|
+
error: payload.error,
|
|
2841
|
+
menus: Array.isArray(payload.data) ? payload.data : void 0,
|
|
2842
|
+
count: payload.count,
|
|
2843
|
+
message: payload.message
|
|
2844
|
+
};
|
|
2845
|
+
}
|
|
2846
|
+
async function getChildMenus(client, parentId, timeout) {
|
|
2847
|
+
const messageId = `menus_getchildmenus_${Date.now()}`;
|
|
2848
|
+
const message = MenusRequestMessageSchema.parse({
|
|
2849
|
+
id: messageId,
|
|
2850
|
+
type: "MENUS",
|
|
2851
|
+
from: { type: client.type },
|
|
2852
|
+
to: { type: "data-agent" },
|
|
2853
|
+
payload: {
|
|
2854
|
+
operation: "getChildMenus",
|
|
2855
|
+
data: {
|
|
2856
|
+
parentId
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
});
|
|
2860
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2861
|
+
const payload = response.payload;
|
|
2862
|
+
return {
|
|
2863
|
+
success: payload.success,
|
|
2864
|
+
error: payload.error,
|
|
2865
|
+
menus: Array.isArray(payload.data) ? payload.data : void 0,
|
|
2866
|
+
count: payload.count,
|
|
2867
|
+
message: payload.message
|
|
2868
|
+
};
|
|
2869
|
+
}
|
|
2870
|
+
async function getMenusHierarchy(client, timeout) {
|
|
2871
|
+
const messageId = `menus_gethierarchy_${Date.now()}`;
|
|
2872
|
+
const message = MenusRequestMessageSchema.parse({
|
|
2873
|
+
id: messageId,
|
|
2874
|
+
type: "MENUS",
|
|
2875
|
+
from: { type: client.type },
|
|
2876
|
+
to: { type: "data-agent" },
|
|
2877
|
+
payload: {
|
|
2878
|
+
operation: "getHierarchy"
|
|
2879
|
+
}
|
|
2880
|
+
});
|
|
2881
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2882
|
+
const payload = response.payload;
|
|
2883
|
+
return {
|
|
2884
|
+
success: payload.success,
|
|
2885
|
+
error: payload.error,
|
|
2886
|
+
menus: Array.isArray(payload.data) ? payload.data : void 0,
|
|
2887
|
+
count: payload.count,
|
|
2888
|
+
message: payload.message
|
|
2889
|
+
};
|
|
2890
|
+
}
|
|
2891
|
+
async function queryMenus(client, options = {}, timeout) {
|
|
2892
|
+
const { filters, limit, sort } = options;
|
|
2893
|
+
const messageId = `menus_query_${Date.now()}`;
|
|
2894
|
+
const message = MenusRequestMessageSchema.parse({
|
|
2895
|
+
id: messageId,
|
|
2896
|
+
type: "MENUS",
|
|
2897
|
+
from: { type: client.type },
|
|
2898
|
+
to: { type: "data-agent" },
|
|
2899
|
+
payload: {
|
|
2900
|
+
operation: "query",
|
|
2901
|
+
data: {
|
|
2902
|
+
filters,
|
|
2903
|
+
limit,
|
|
2904
|
+
sort
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
});
|
|
2908
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2909
|
+
const payload = response.payload;
|
|
2910
|
+
return {
|
|
2911
|
+
success: payload.success,
|
|
2912
|
+
error: payload.error,
|
|
2913
|
+
menus: Array.isArray(payload.data) ? payload.data : void 0,
|
|
2914
|
+
count: payload.count,
|
|
2915
|
+
message: payload.message
|
|
2916
|
+
};
|
|
2917
|
+
}
|
|
2918
|
+
async function reorderMenus(client, items, timeout) {
|
|
2919
|
+
const messageId = `menus_reorder_${Date.now()}`;
|
|
2920
|
+
const message = MenusRequestMessageSchema.parse({
|
|
2921
|
+
id: messageId,
|
|
2922
|
+
type: "MENUS",
|
|
2923
|
+
from: { type: client.type },
|
|
2924
|
+
to: { type: "data-agent" },
|
|
2925
|
+
payload: {
|
|
2926
|
+
operation: "reorder",
|
|
2927
|
+
data: {
|
|
2928
|
+
items
|
|
2929
|
+
}
|
|
2930
|
+
}
|
|
2931
|
+
});
|
|
2932
|
+
const response = await client.sendWithResponse(message, timeout);
|
|
2933
|
+
const payload = response.payload;
|
|
2934
|
+
return {
|
|
2935
|
+
success: payload.success,
|
|
2936
|
+
error: payload.error,
|
|
2937
|
+
message: payload.message,
|
|
2938
|
+
data: Array.isArray(payload.data) ? payload.data : void 0
|
|
2939
|
+
};
|
|
2940
|
+
}
|
|
2941
|
+
|
|
2942
|
+
// src/services/schema.ts
|
|
2943
|
+
async function getSchema(client, options = {}) {
|
|
2944
|
+
const messageId = `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
2945
|
+
const message = SchemaRequestMessageSchema.parse({
|
|
2946
|
+
id: messageId,
|
|
2947
|
+
type: "SCHEMA_REQ",
|
|
2948
|
+
from: { type: client.type },
|
|
2949
|
+
to: { type: "data-agent" },
|
|
2950
|
+
payload: {
|
|
2951
|
+
formatted: options.formatted ?? false
|
|
2952
|
+
}
|
|
2953
|
+
});
|
|
2954
|
+
const response = await client.sendWithResponse(message, options.timeout);
|
|
2955
|
+
const payload = response.payload;
|
|
2956
|
+
return {
|
|
2957
|
+
success: payload.success,
|
|
2958
|
+
error: payload.error,
|
|
2959
|
+
data: payload.data
|
|
2960
|
+
};
|
|
2961
|
+
}
|
|
2962
|
+
|
|
2963
|
+
// src/client.ts
|
|
2964
|
+
var SuperatomClient = class {
|
|
2965
|
+
constructor(config) {
|
|
2966
|
+
this.socket = null;
|
|
2967
|
+
this.reconnectAttempts = 0;
|
|
2968
|
+
this.reconnectTimer = null;
|
|
2969
|
+
this.shouldReconnect = true;
|
|
2970
|
+
this.messageHandlers = /* @__PURE__ */ new Set();
|
|
2971
|
+
this.connectionHandlers = /* @__PURE__ */ new Set();
|
|
2972
|
+
this.disconnectionHandlers = /* @__PURE__ */ new Set();
|
|
2973
|
+
this.errorHandlers = /* @__PURE__ */ new Set();
|
|
2974
|
+
this.connectPromise = null;
|
|
2975
|
+
this.connectResolve = null;
|
|
2976
|
+
const parsed = ClientConfigSchema.parse(config);
|
|
2977
|
+
this.config = parsed;
|
|
2978
|
+
}
|
|
2979
|
+
/**
|
|
2980
|
+
* Get WebSocket URL with query parameters
|
|
2981
|
+
*/
|
|
2982
|
+
getWebSocketUrl() {
|
|
2983
|
+
const params = new URLSearchParams({
|
|
2984
|
+
userId: this.config.userId,
|
|
2985
|
+
projectId: this.config.projectId,
|
|
2986
|
+
type: this.config.type
|
|
2987
|
+
});
|
|
2988
|
+
return `${this.config.baseUrl}?${params.toString()}`;
|
|
2989
|
+
}
|
|
2990
|
+
/**
|
|
2991
|
+
* Calculate reconnection delay with exponential backoff
|
|
2992
|
+
*/
|
|
2993
|
+
calculateReconnectDelay() {
|
|
2994
|
+
const delay = Math.min(
|
|
2995
|
+
this.config.initialReconnectDelay * Math.pow(2, this.reconnectAttempts),
|
|
2996
|
+
this.config.maxReconnectDelay
|
|
2997
|
+
);
|
|
2998
|
+
return delay + Math.random() * 1e3;
|
|
2999
|
+
}
|
|
3000
|
+
/**
|
|
3001
|
+
* Schedule reconnection attempt
|
|
3002
|
+
*/
|
|
3003
|
+
scheduleReconnect() {
|
|
3004
|
+
if (!this.shouldReconnect) {
|
|
3005
|
+
return;
|
|
3006
|
+
}
|
|
3007
|
+
if (this.reconnectAttempts >= this.config.maxReconnectAttempts) {
|
|
3008
|
+
const error = new Error("Max reconnection attempts reached");
|
|
3009
|
+
this.log("error", error.message);
|
|
3010
|
+
this.errorHandlers.forEach((handler) => handler(error));
|
|
3011
|
+
return;
|
|
3012
|
+
}
|
|
3013
|
+
const delay = this.calculateReconnectDelay();
|
|
3014
|
+
this.log("info", `Scheduling reconnection attempt ${this.reconnectAttempts + 1} in ${delay}ms`);
|
|
3015
|
+
this.reconnectTimer = setTimeout(() => {
|
|
3016
|
+
this.reconnectAttempts++;
|
|
3017
|
+
this.connect();
|
|
3018
|
+
}, delay);
|
|
3019
|
+
}
|
|
3020
|
+
/**
|
|
3021
|
+
* Setup WebSocket event handlers
|
|
3022
|
+
*/
|
|
3023
|
+
setupSocketHandlers() {
|
|
3024
|
+
if (!this.socket) {
|
|
3025
|
+
return;
|
|
3026
|
+
}
|
|
3027
|
+
this.socket.onopen = () => {
|
|
3028
|
+
this.log("info", "Connected to SuperAtom");
|
|
3029
|
+
this.reconnectAttempts = 0;
|
|
3030
|
+
if (this.connectResolve) {
|
|
3031
|
+
this.connectResolve();
|
|
3032
|
+
this.connectResolve = null;
|
|
3033
|
+
}
|
|
3034
|
+
this.connectionHandlers.forEach((handler) => handler());
|
|
3035
|
+
};
|
|
3036
|
+
this.socket.onmessage = (event) => {
|
|
3037
|
+
try {
|
|
3038
|
+
const parsed = JSON.parse(event.data);
|
|
3039
|
+
const message = MessageSchema.parse(parsed);
|
|
3040
|
+
this.messageHandlers.forEach((handler) => handler(message));
|
|
3041
|
+
} catch (error) {
|
|
3042
|
+
this.log("error", "Failed to parse message:", error);
|
|
3043
|
+
const err = error instanceof Error ? error : new Error("Parse error");
|
|
3044
|
+
this.errorHandlers.forEach((handler) => handler(err));
|
|
3045
|
+
}
|
|
3046
|
+
};
|
|
3047
|
+
this.socket.onclose = (event) => {
|
|
3048
|
+
this.log("info", "Disconnected from SuperAtom", {
|
|
3049
|
+
code: event.code,
|
|
3050
|
+
reason: event.reason,
|
|
3051
|
+
wasClean: event.wasClean
|
|
3052
|
+
});
|
|
3053
|
+
this.disconnectionHandlers.forEach((handler) => handler());
|
|
3054
|
+
if (this.shouldReconnect && !event.wasClean) {
|
|
3055
|
+
this.scheduleReconnect();
|
|
3056
|
+
}
|
|
3057
|
+
};
|
|
3058
|
+
this.socket.onerror = (error) => {
|
|
3059
|
+
this.log("error", "WebSocket error:", error);
|
|
3060
|
+
this.errorHandlers.forEach((handler) => handler(error));
|
|
3061
|
+
};
|
|
3062
|
+
}
|
|
3063
|
+
/**
|
|
3064
|
+
* Connect to SuperAtom WebSocket server
|
|
3065
|
+
* Returns a Promise that resolves when the connection is established
|
|
3066
|
+
* The Promise never rejects - failures are logged silently and auto-reconnect is triggered
|
|
3067
|
+
*/
|
|
3068
|
+
connect() {
|
|
3069
|
+
if (this.socket?.readyState === WebSocket.OPEN) {
|
|
3070
|
+
this.log("warn", "Already connected");
|
|
3071
|
+
return Promise.resolve();
|
|
3072
|
+
}
|
|
3073
|
+
if (this.socket?.readyState === WebSocket.CONNECTING && this.connectPromise) {
|
|
3074
|
+
this.log("warn", "Connection already in progress");
|
|
3075
|
+
return this.connectPromise;
|
|
3076
|
+
}
|
|
3077
|
+
this.connectPromise = new Promise((resolve) => {
|
|
3078
|
+
this.connectResolve = resolve;
|
|
3079
|
+
});
|
|
3080
|
+
try {
|
|
3081
|
+
this.socket = new WebSocket(this.getWebSocketUrl());
|
|
3082
|
+
this.setupSocketHandlers();
|
|
3083
|
+
} catch (error) {
|
|
3084
|
+
this.log("error", "Failed to create WebSocket:", error);
|
|
3085
|
+
const err = error instanceof Error ? error : new Error("Connection failed");
|
|
3086
|
+
this.errorHandlers.forEach((handler) => handler(err));
|
|
3087
|
+
this.scheduleReconnect();
|
|
3088
|
+
}
|
|
3089
|
+
return this.connectPromise;
|
|
3090
|
+
}
|
|
3091
|
+
/**
|
|
3092
|
+
* Disconnect from WebSocket server
|
|
3093
|
+
*/
|
|
3094
|
+
disconnect() {
|
|
3095
|
+
this.shouldReconnect = false;
|
|
3096
|
+
if (this.reconnectTimer) {
|
|
3097
|
+
clearTimeout(this.reconnectTimer);
|
|
3098
|
+
this.reconnectTimer = null;
|
|
3099
|
+
}
|
|
3100
|
+
if (this.socket) {
|
|
3101
|
+
this.socket.close(1e3, "Client disconnect");
|
|
3102
|
+
this.socket = null;
|
|
3103
|
+
}
|
|
3104
|
+
this.reconnectAttempts = 0;
|
|
3105
|
+
}
|
|
3106
|
+
/**
|
|
3107
|
+
* Update client configuration
|
|
3108
|
+
*/
|
|
3109
|
+
updateConfig(config) {
|
|
3110
|
+
const merged = { ...this.config, ...config };
|
|
3111
|
+
const parsed = ClientConfigSchema.parse(merged);
|
|
3112
|
+
this.config = parsed;
|
|
3113
|
+
}
|
|
3114
|
+
/**
|
|
3115
|
+
* Reconnect with new configuration
|
|
3116
|
+
* Disconnects from existing connection and reconnects with updated config
|
|
3117
|
+
* Returns a Promise that resolves when the new connection is established
|
|
3118
|
+
*/
|
|
3119
|
+
reconnectWithConfig(config) {
|
|
3120
|
+
this.updateConfig(config);
|
|
3121
|
+
if (this.socket) {
|
|
3122
|
+
this.disconnect();
|
|
3123
|
+
}
|
|
3124
|
+
this.shouldReconnect = true;
|
|
3125
|
+
return this.connect();
|
|
3126
|
+
}
|
|
3127
|
+
/**
|
|
3128
|
+
* Send a message to the server
|
|
3129
|
+
*/
|
|
3130
|
+
send(message) {
|
|
3131
|
+
if (!this.socket || this.socket.readyState !== WebSocket.OPEN) {
|
|
3132
|
+
throw new Error("WebSocket is not connected");
|
|
3133
|
+
}
|
|
3134
|
+
const fullMessage = {
|
|
3135
|
+
...message,
|
|
3136
|
+
from: message.from || { type: this.config.type }
|
|
3137
|
+
};
|
|
3138
|
+
try {
|
|
3139
|
+
this.socket.send(JSON.stringify(fullMessage));
|
|
3140
|
+
} catch (error) {
|
|
3141
|
+
this.log("error", "Failed to send message:", error);
|
|
3142
|
+
throw error;
|
|
3143
|
+
}
|
|
3144
|
+
}
|
|
3145
|
+
/**
|
|
3146
|
+
* Send a message and wait for a response with the same ID
|
|
3147
|
+
* Uses closure-based approach - no global state management needed
|
|
3148
|
+
*/
|
|
3149
|
+
async sendWithResponse(message, timeout) {
|
|
3150
|
+
const messageId = message.id || `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
3151
|
+
const messageWithId = { ...message, id: messageId };
|
|
3152
|
+
const timeoutMs = timeout ?? this.config.defaultTimeout;
|
|
3153
|
+
this.send(messageWithId);
|
|
3154
|
+
return new Promise((resolve, reject) => {
|
|
3155
|
+
let isResolved = false;
|
|
3156
|
+
const responseHandler = (msg) => {
|
|
3157
|
+
if (msg.id === messageId && !isResolved) {
|
|
3158
|
+
isResolved = true;
|
|
3159
|
+
clearTimeout(timer);
|
|
3160
|
+
unsubscribe();
|
|
3161
|
+
resolve(msg);
|
|
3162
|
+
}
|
|
3163
|
+
};
|
|
3164
|
+
const unsubscribe = this.onMessage(responseHandler);
|
|
3165
|
+
const timer = setTimeout(() => {
|
|
3166
|
+
if (!isResolved) {
|
|
3167
|
+
isResolved = true;
|
|
3168
|
+
unsubscribe();
|
|
3169
|
+
reject(new Error(`Request timeout after ${timeoutMs}ms`));
|
|
3170
|
+
}
|
|
3171
|
+
}, timeoutMs);
|
|
3172
|
+
});
|
|
3173
|
+
}
|
|
3174
|
+
/**
|
|
3175
|
+
* Register message handler
|
|
3176
|
+
*/
|
|
3177
|
+
onMessage(handler) {
|
|
3178
|
+
this.messageHandlers.add(handler);
|
|
3179
|
+
return () => this.messageHandlers.delete(handler);
|
|
3180
|
+
}
|
|
3181
|
+
/**
|
|
3182
|
+
* Register connection handler
|
|
3183
|
+
*/
|
|
3184
|
+
onConnect(handler) {
|
|
3185
|
+
this.connectionHandlers.add(handler);
|
|
3186
|
+
return () => this.connectionHandlers.delete(handler);
|
|
3187
|
+
}
|
|
3188
|
+
/**
|
|
3189
|
+
* Register disconnection handler
|
|
3190
|
+
*/
|
|
3191
|
+
onDisconnect(handler) {
|
|
3192
|
+
this.disconnectionHandlers.add(handler);
|
|
3193
|
+
return () => this.disconnectionHandlers.delete(handler);
|
|
3194
|
+
}
|
|
3195
|
+
/**
|
|
3196
|
+
* Register error handler
|
|
3197
|
+
*/
|
|
3198
|
+
onError(handler) {
|
|
3199
|
+
this.errorHandlers.add(handler);
|
|
3200
|
+
return () => this.errorHandlers.delete(handler);
|
|
3201
|
+
}
|
|
3202
|
+
/**
|
|
3203
|
+
* Check if client is connected
|
|
3204
|
+
*/
|
|
3205
|
+
isConnected() {
|
|
3206
|
+
return this.socket?.readyState === WebSocket.OPEN;
|
|
3207
|
+
}
|
|
3208
|
+
/**
|
|
3209
|
+
* Get current reconnection attempts
|
|
3210
|
+
*/
|
|
3211
|
+
getReconnectAttempts() {
|
|
3212
|
+
return this.reconnectAttempts;
|
|
3213
|
+
}
|
|
3214
|
+
/**
|
|
3215
|
+
* Get client type
|
|
3216
|
+
*/
|
|
3217
|
+
get type() {
|
|
3218
|
+
return this.config.type;
|
|
3219
|
+
}
|
|
3220
|
+
/**
|
|
3221
|
+
* Send a message and wait for response with timeout (alias for sendWithResponse)
|
|
3222
|
+
*/
|
|
3223
|
+
async ask(message, options) {
|
|
3224
|
+
return this.sendWithResponse(message, options?.timeout);
|
|
3225
|
+
}
|
|
3226
|
+
// ==================== Service Methods ====================
|
|
3227
|
+
// These methods delegate to service functions for better code organization
|
|
3228
|
+
/**
|
|
3229
|
+
* Send authentication login request
|
|
3230
|
+
* Delegates to auth service
|
|
3231
|
+
*/
|
|
3232
|
+
async sendAuthLoginRequest(loginDataBase64, timeout) {
|
|
3233
|
+
this.log("info", "Sending auth login request");
|
|
3234
|
+
return sendAuthLoginRequest(this, loginDataBase64, timeout);
|
|
3235
|
+
}
|
|
3236
|
+
/**
|
|
3237
|
+
* Send authentication verify request
|
|
3238
|
+
* Delegates to auth service
|
|
3239
|
+
*/
|
|
3240
|
+
async sendAuthVerifyRequest(token, timeout) {
|
|
3241
|
+
this.log("info", "Sending auth verify request");
|
|
3242
|
+
return sendAuthVerifyRequest(this, token, timeout);
|
|
3243
|
+
}
|
|
3244
|
+
/**
|
|
3245
|
+
* Send a user prompt request
|
|
3246
|
+
* Delegates to user prompt service
|
|
3247
|
+
* @param userId - User ID for the request
|
|
3248
|
+
* @param responseMode - 'component' for component response (default), 'text' for text streaming
|
|
3249
|
+
* @param onStream - Optional callback for streaming text chunks (only for text mode)
|
|
3250
|
+
*/
|
|
3251
|
+
async sendUserPromptRequest(prompt, threadId, uiBlockId, userId, responseMode, onStream, timeout) {
|
|
3252
|
+
this.log("info", "Sending user prompt request with streaming support");
|
|
3253
|
+
return sendUserPromptRequest(this, prompt, threadId, uiBlockId, userId, responseMode, onStream, timeout);
|
|
3254
|
+
}
|
|
3255
|
+
/**
|
|
3256
|
+
* Send a user prompt suggestions request
|
|
3257
|
+
* Delegates to user prompt service
|
|
3258
|
+
* @param userId - User ID for the request
|
|
3259
|
+
*/
|
|
3260
|
+
async sendUserPromptSuggestionsRequest(prompt, userId, limit = 5, timeout) {
|
|
3261
|
+
this.log("info", "Sending user prompt suggestions request");
|
|
3262
|
+
return sendUserPromptSuggestionsRequest(this, prompt, userId, limit, timeout);
|
|
3263
|
+
}
|
|
3264
|
+
/**
|
|
3265
|
+
* Request bundle from server
|
|
3266
|
+
* Delegates to bundle service
|
|
3267
|
+
*/
|
|
3268
|
+
async requestBundle(options) {
|
|
3269
|
+
this.log("info", "Requesting bundle from server");
|
|
3270
|
+
return requestBundle(this, options);
|
|
3271
|
+
}
|
|
3272
|
+
/**
|
|
3273
|
+
* Request data from a collection
|
|
3274
|
+
* Delegates to data service
|
|
3275
|
+
*/
|
|
3276
|
+
async requestData(options) {
|
|
3277
|
+
this.log("info", `Requesting data from collection: ${options.collection}, operation: ${options.operation}`);
|
|
3278
|
+
return requestData(this, options);
|
|
3279
|
+
}
|
|
3280
|
+
/**
|
|
3281
|
+
* Get AI-powered component suggestions based on a query
|
|
3282
|
+
* Delegates to component service
|
|
3283
|
+
*/
|
|
3284
|
+
async getComponentSuggestions(query, options) {
|
|
3285
|
+
this.log("info", "Requesting component suggestions for query:", query);
|
|
3286
|
+
return getComponentSuggestions(this, query, options);
|
|
3287
|
+
}
|
|
3288
|
+
/**
|
|
3289
|
+
* Get AI-powered component suggestions based on a query
|
|
3290
|
+
* Delegates to component service
|
|
3291
|
+
* @param userId - User ID for the request
|
|
3292
|
+
*/
|
|
3293
|
+
async getActions(options) {
|
|
3294
|
+
this.log("info", "Requesting actions");
|
|
3295
|
+
return getActions(this, options);
|
|
3296
|
+
}
|
|
3297
|
+
async sendComponents(components) {
|
|
3298
|
+
this.log("info", "Sending components");
|
|
3299
|
+
return sendComponents(this, components);
|
|
3300
|
+
}
|
|
3301
|
+
// ==================== User Management Methods ====================
|
|
3302
|
+
// These methods delegate to user service for admin user CRUD operations
|
|
3303
|
+
/**
|
|
3304
|
+
* Create a new user
|
|
3305
|
+
* Delegates to users service
|
|
3306
|
+
*/
|
|
3307
|
+
async createUser(username, password, email, fullname, role, userInfo, timeout) {
|
|
3308
|
+
this.log("info", "Creating user:", username);
|
|
3309
|
+
return createUser(this, username, password, email, fullname, role, userInfo, timeout);
|
|
3310
|
+
}
|
|
3311
|
+
/**
|
|
3312
|
+
* Update an existing user
|
|
3313
|
+
* Delegates to users service
|
|
3314
|
+
*/
|
|
3315
|
+
async updateUser(id, updates, timeout) {
|
|
3316
|
+
this.log("info", "Updating user:", id);
|
|
3317
|
+
return updateUser(this, id, updates, timeout);
|
|
3318
|
+
}
|
|
3319
|
+
/**
|
|
3320
|
+
* Delete a user
|
|
3321
|
+
* Delegates to users service
|
|
3322
|
+
*/
|
|
3323
|
+
async deleteUser(id, timeout) {
|
|
3324
|
+
this.log("info", "Deleting user:", id);
|
|
3325
|
+
return deleteUser(this, id, timeout);
|
|
3326
|
+
}
|
|
3327
|
+
/**
|
|
3328
|
+
* Get all users
|
|
3329
|
+
* Delegates to users service
|
|
3330
|
+
*/
|
|
3331
|
+
async getAllUsers(timeout) {
|
|
3332
|
+
this.log("info", "Fetching all users");
|
|
3333
|
+
return getAllUsers(this, timeout);
|
|
3334
|
+
}
|
|
3335
|
+
/**
|
|
3336
|
+
* Get a specific user by username
|
|
3337
|
+
* Delegates to users service
|
|
3338
|
+
*/
|
|
3339
|
+
async getUser(username, timeout) {
|
|
3340
|
+
this.log("info", "Fetching user:", username);
|
|
3341
|
+
return getUser(this, username, timeout);
|
|
3342
|
+
}
|
|
3343
|
+
/**
|
|
3344
|
+
* Query users with filters, limit, and sort
|
|
3345
|
+
* Delegates to users service
|
|
3346
|
+
*/
|
|
3347
|
+
async queryUsers(options = {}, timeout) {
|
|
3348
|
+
this.log("info", "Querying users with filters:", options.filters);
|
|
3349
|
+
return queryUsers(this, options, timeout);
|
|
3350
|
+
}
|
|
3351
|
+
// ==================== Dashboard Management Methods ====================
|
|
3352
|
+
// These methods delegate to dashboard service for admin dashboard CRUD operations
|
|
3353
|
+
/**
|
|
3354
|
+
* Create a new dashboard
|
|
3355
|
+
* Delegates to dashboards service
|
|
3356
|
+
*/
|
|
3357
|
+
async createDashboard(options, timeout) {
|
|
3358
|
+
this.log("info", "Creating dashboard:", options.dashboardId, options.projectId);
|
|
3359
|
+
return createDashboard(this, options, timeout);
|
|
3360
|
+
}
|
|
3361
|
+
/**
|
|
3362
|
+
* Update an existing dashboard
|
|
3363
|
+
* Delegates to dashboards service
|
|
3364
|
+
*/
|
|
3365
|
+
async updateDashboard(options, timeout) {
|
|
3366
|
+
this.log("info", "Updating dashboard:", options.id);
|
|
3367
|
+
return updateDashboard(this, options, timeout);
|
|
3368
|
+
}
|
|
3369
|
+
/**
|
|
3370
|
+
* Delete a dashboard
|
|
3371
|
+
* Delegates to dashboards service
|
|
3372
|
+
*/
|
|
3373
|
+
async deleteDashboard(id, timeout) {
|
|
3374
|
+
this.log("info", "Deleting dashboard:", id);
|
|
3375
|
+
return deleteDashboard(this, id, timeout);
|
|
3376
|
+
}
|
|
3377
|
+
/**
|
|
3378
|
+
* Get all dashboards
|
|
3379
|
+
* Delegates to dashboards service
|
|
3380
|
+
*/
|
|
3381
|
+
async getAllDashboards(timeout) {
|
|
3382
|
+
this.log("info", "Fetching all dashboards");
|
|
3383
|
+
return getAllDashboards(this, timeout);
|
|
3384
|
+
}
|
|
3385
|
+
/**
|
|
3386
|
+
* Get a specific dashboard by ID
|
|
3387
|
+
* Delegates to dashboards service
|
|
3388
|
+
*/
|
|
3389
|
+
async getDashboard(id, timeout) {
|
|
3390
|
+
this.log("info", "Fetching dashboard:", id);
|
|
3391
|
+
return getDashboard(this, id, timeout);
|
|
3392
|
+
}
|
|
3393
|
+
/**
|
|
3394
|
+
* Query dashboards with filters
|
|
3395
|
+
* Delegates to dashboards service
|
|
3396
|
+
*/
|
|
3397
|
+
async queryDashboards(options, timeout) {
|
|
3398
|
+
this.log("info", "Querying dashboards with filters:", options?.filters);
|
|
3399
|
+
return queryDashboards(this, options, timeout);
|
|
3400
|
+
}
|
|
3401
|
+
// ==================== Bookmark Management Methods ====================
|
|
3402
|
+
// These methods delegate to bookmark service for bookmark CRUD operations
|
|
3403
|
+
/**
|
|
3404
|
+
* Create a new bookmark
|
|
3405
|
+
* Delegates to bookmarks service
|
|
3406
|
+
*/
|
|
3407
|
+
async createBookmark(options, timeout) {
|
|
3408
|
+
this.log("info", "Creating bookmark for user:", options.userId);
|
|
3409
|
+
return createBookmark(this, options, timeout);
|
|
3410
|
+
}
|
|
3411
|
+
/**
|
|
3412
|
+
* Update an existing bookmark
|
|
3413
|
+
* Delegates to bookmarks service
|
|
3414
|
+
*/
|
|
3415
|
+
async updateBookmark(options, timeout) {
|
|
3416
|
+
this.log("info", "Updating bookmark:", options.id);
|
|
3417
|
+
return updateBookmark(this, options, timeout);
|
|
3418
|
+
}
|
|
3419
|
+
/**
|
|
3420
|
+
* Delete a bookmark
|
|
3421
|
+
* Delegates to bookmarks service
|
|
3422
|
+
*/
|
|
3423
|
+
async deleteBookmark(id, timeout) {
|
|
3424
|
+
this.log("info", "Deleting bookmark:", id);
|
|
3425
|
+
return deleteBookmark(this, id, timeout);
|
|
3426
|
+
}
|
|
3427
|
+
/**
|
|
3428
|
+
* Get all bookmarks
|
|
3429
|
+
* Delegates to bookmarks service
|
|
3430
|
+
*/
|
|
3431
|
+
async getAllBookmarks(timeout) {
|
|
3432
|
+
this.log("info", "Fetching all bookmarks");
|
|
3433
|
+
return getAllBookmarks(this, timeout);
|
|
3434
|
+
}
|
|
3435
|
+
/**
|
|
3436
|
+
* Get a specific bookmark by ID
|
|
3437
|
+
* Delegates to bookmarks service
|
|
3438
|
+
*/
|
|
3439
|
+
async getBookmark(id, timeout) {
|
|
3440
|
+
this.log("info", "Fetching bookmark:", id);
|
|
3441
|
+
return getBookmark(this, id, timeout);
|
|
3442
|
+
}
|
|
3443
|
+
/**
|
|
3444
|
+
* Query bookmarks with filters, limit, and sort
|
|
3445
|
+
* Delegates to bookmarks service
|
|
3446
|
+
*/
|
|
3447
|
+
async queryBookmarks(options = {}, timeout) {
|
|
3448
|
+
this.log("info", "Querying bookmarks with filters:", options.filters);
|
|
3449
|
+
return queryBookmarks(this, options, timeout);
|
|
3450
|
+
}
|
|
3451
|
+
// ==================== Artifact Management Methods ====================
|
|
3452
|
+
// These methods delegate to artifact service for artifact CRUD operations
|
|
3453
|
+
/**
|
|
3454
|
+
* Create a new artifact
|
|
3455
|
+
* Delegates to artifacts service
|
|
3456
|
+
*/
|
|
3457
|
+
async createArtifact(options, timeout) {
|
|
3458
|
+
this.log("info", "Creating artifact:", options.name);
|
|
3459
|
+
return createArtifact(this, options, timeout);
|
|
3460
|
+
}
|
|
3461
|
+
/**
|
|
3462
|
+
* Update an existing artifact
|
|
3463
|
+
* Delegates to artifacts service
|
|
3464
|
+
*/
|
|
3465
|
+
async updateArtifact(options, timeout) {
|
|
3466
|
+
this.log("info", "Updating artifact:", options.id);
|
|
3467
|
+
return updateArtifact(this, options, timeout);
|
|
3468
|
+
}
|
|
3469
|
+
/**
|
|
3470
|
+
* Delete an artifact (soft delete)
|
|
3471
|
+
* Delegates to artifacts service
|
|
3472
|
+
*/
|
|
3473
|
+
async deleteArtifact(id, timeout) {
|
|
3474
|
+
this.log("info", "Deleting artifact:", id);
|
|
3475
|
+
return deleteArtifact(this, id, timeout);
|
|
3476
|
+
}
|
|
3477
|
+
/**
|
|
3478
|
+
* Get all artifacts
|
|
3479
|
+
* Delegates to artifacts service
|
|
3480
|
+
*/
|
|
3481
|
+
async getAllArtifacts(limit, timeout) {
|
|
3482
|
+
this.log("info", "Fetching all artifacts");
|
|
3483
|
+
return getAllArtifacts(this, limit, timeout);
|
|
3484
|
+
}
|
|
3485
|
+
/**
|
|
3486
|
+
* Get a specific artifact by ID
|
|
3487
|
+
* Delegates to artifacts service
|
|
3488
|
+
*/
|
|
3489
|
+
async getArtifact(id, timeout) {
|
|
3490
|
+
this.log("info", "Fetching artifact:", id);
|
|
3491
|
+
return getArtifact(this, id, timeout);
|
|
3492
|
+
}
|
|
3493
|
+
/**
|
|
3494
|
+
* Query artifacts with filters
|
|
3495
|
+
* Delegates to artifacts service
|
|
3496
|
+
*/
|
|
3497
|
+
async queryArtifacts(options = {}, timeout) {
|
|
3498
|
+
this.log("info", "Querying artifacts with filters:", JSON.stringify(options.filters));
|
|
3499
|
+
return queryArtifacts(this, options, timeout);
|
|
3500
|
+
}
|
|
3501
|
+
// ==================== Report Management Methods ====================
|
|
3502
|
+
// These methods delegate to report service for admin report CRUD operations
|
|
3503
|
+
/**
|
|
3504
|
+
* Create a new report
|
|
3505
|
+
* Delegates to reports service
|
|
3506
|
+
*/
|
|
3507
|
+
async createReport(options, timeout) {
|
|
3508
|
+
this.log("info", "Creating report:", options.reportId);
|
|
3509
|
+
return createReport(this, options, timeout);
|
|
3510
|
+
}
|
|
3511
|
+
/**
|
|
3512
|
+
* Update an existing report
|
|
3513
|
+
* Delegates to reports service
|
|
3514
|
+
*/
|
|
3515
|
+
async updateReport(options, timeout) {
|
|
3516
|
+
this.log("info", "Updating report:", options.id);
|
|
3517
|
+
return updateReport(this, options, timeout);
|
|
3518
|
+
}
|
|
3519
|
+
/**
|
|
3520
|
+
* Delete a report
|
|
3521
|
+
* Delegates to reports service
|
|
3522
|
+
*/
|
|
3523
|
+
async deleteReport(id, timeout) {
|
|
3524
|
+
this.log("info", "Deleting report:", id);
|
|
3525
|
+
return deleteReport(this, id, timeout);
|
|
3526
|
+
}
|
|
3527
|
+
/**
|
|
3528
|
+
* Get all reports
|
|
3529
|
+
* Delegates to reports service
|
|
3530
|
+
*/
|
|
3531
|
+
async getAllReports(timeout) {
|
|
3532
|
+
this.log("info", "Fetching all reports");
|
|
3533
|
+
return getAllReports(this, timeout);
|
|
3534
|
+
}
|
|
3535
|
+
/**
|
|
3536
|
+
* Get a specific report by ID
|
|
3537
|
+
* Delegates to reports service
|
|
3538
|
+
*/
|
|
3539
|
+
async getReport(id, timeout) {
|
|
3540
|
+
this.log("info", "Fetching report:", id);
|
|
3541
|
+
return getReport(this, id, timeout);
|
|
3542
|
+
}
|
|
3543
|
+
/**
|
|
3544
|
+
* Query reports with filters
|
|
3545
|
+
* Delegates to reports service
|
|
3546
|
+
*/
|
|
3547
|
+
async queryReports(options, timeout) {
|
|
3548
|
+
this.log("info", "Querying reports with filters:", options?.filters);
|
|
3549
|
+
return queryReports(this, options, timeout);
|
|
3550
|
+
}
|
|
3551
|
+
// ==================== UI Management Methods ====================
|
|
3552
|
+
// These methods delegate to uis service for admin UI CRUD operations
|
|
3553
|
+
/**
|
|
3554
|
+
* Create a new UI
|
|
3555
|
+
* Delegates to uis service
|
|
3556
|
+
*/
|
|
3557
|
+
async createUI(options, timeout) {
|
|
3558
|
+
this.log("info", "Creating UI:", options.uiId);
|
|
3559
|
+
return createUI(this, options, timeout);
|
|
3560
|
+
}
|
|
3561
|
+
/**
|
|
3562
|
+
* Update an existing UI
|
|
3563
|
+
* Delegates to uis service
|
|
3564
|
+
*/
|
|
3565
|
+
async updateUI(options, timeout) {
|
|
3566
|
+
this.log("info", "Updating UI:", options.id);
|
|
3567
|
+
return updateUI(this, options, timeout);
|
|
3568
|
+
}
|
|
3569
|
+
/**
|
|
3570
|
+
* Delete a UI
|
|
3571
|
+
* Delegates to uis service
|
|
3572
|
+
*/
|
|
3573
|
+
async deleteUI(id, timeout) {
|
|
3574
|
+
this.log("info", "Deleting UI:", id);
|
|
3575
|
+
return deleteUI(this, id, timeout);
|
|
3576
|
+
}
|
|
3577
|
+
/**
|
|
3578
|
+
* Get all UIs
|
|
3579
|
+
* Delegates to uis service
|
|
3580
|
+
*/
|
|
3581
|
+
async getAllUIs(timeout) {
|
|
3582
|
+
this.log("info", "Fetching all UIs");
|
|
3583
|
+
return getAllUIs(this, timeout);
|
|
3584
|
+
}
|
|
3585
|
+
/**
|
|
3586
|
+
* Get a specific UI by ID
|
|
3587
|
+
* Delegates to uis service
|
|
3588
|
+
*/
|
|
3589
|
+
async getUI(id, timeout) {
|
|
3590
|
+
this.log("info", "Fetching UI:", id);
|
|
3591
|
+
return getUI(this, id, timeout);
|
|
3592
|
+
}
|
|
3593
|
+
/**
|
|
3594
|
+
* Query UIs with filters
|
|
3595
|
+
* Delegates to uis service
|
|
3596
|
+
*/
|
|
3597
|
+
async queryUIs(options, timeout) {
|
|
3598
|
+
this.log("info", "Querying UIs with filters:", options?.filters);
|
|
3599
|
+
return queryUIs(this, options, timeout);
|
|
3600
|
+
}
|
|
3601
|
+
// ==================== KB Nodes (Knowledge Base) Management Methods ====================
|
|
3602
|
+
// These methods delegate to kb-nodes service for knowledge base CRUD operations
|
|
3603
|
+
/**
|
|
3604
|
+
* Create a new knowledge base node
|
|
3605
|
+
* Delegates to kb-nodes service
|
|
3606
|
+
*/
|
|
3607
|
+
async createKbNode(title, content, createdBy, category, tags, type, timeout) {
|
|
3608
|
+
this.log("info", "Creating KB node:", title);
|
|
3609
|
+
return createKbNode(this, title, content, createdBy, category, tags, type, timeout);
|
|
3610
|
+
}
|
|
3611
|
+
/**
|
|
3612
|
+
* Update an existing knowledge base node
|
|
3613
|
+
* Delegates to kb-nodes service
|
|
3614
|
+
*/
|
|
3615
|
+
async updateKbNode(id, updatedBy, updates, timeout) {
|
|
3616
|
+
this.log("info", "Updating KB node:", id);
|
|
3617
|
+
return updateKbNode(this, id, updatedBy, updates, timeout);
|
|
3618
|
+
}
|
|
3619
|
+
/**
|
|
3620
|
+
* Delete a knowledge base node
|
|
3621
|
+
* Delegates to kb-nodes service
|
|
3622
|
+
*/
|
|
3623
|
+
async deleteKbNode(id, timeout) {
|
|
3624
|
+
this.log("info", "Deleting KB node:", id);
|
|
3625
|
+
return deleteKbNode(this, id, timeout);
|
|
3626
|
+
}
|
|
3627
|
+
/**
|
|
3628
|
+
* Get all knowledge base nodes
|
|
3629
|
+
* Delegates to kb-nodes service
|
|
3630
|
+
*/
|
|
3631
|
+
async getAllKbNodes(limit, offset, timeout) {
|
|
3632
|
+
this.log("info", "Fetching all KB nodes");
|
|
3633
|
+
return getAllKbNodes(this, limit, offset, timeout);
|
|
3634
|
+
}
|
|
3635
|
+
/**
|
|
3636
|
+
* Get a specific knowledge base node by ID
|
|
3637
|
+
* Delegates to kb-nodes service
|
|
3638
|
+
*/
|
|
3639
|
+
async getKbNode(id, timeout) {
|
|
3640
|
+
this.log("info", "Fetching KB node:", id);
|
|
3641
|
+
return getKbNode(this, id, timeout);
|
|
3642
|
+
}
|
|
3643
|
+
/**
|
|
3644
|
+
* Search knowledge base nodes with full-text search and filters
|
|
3645
|
+
* Delegates to kb-nodes service
|
|
3646
|
+
*/
|
|
3647
|
+
async searchKbNodes(options = {}, timeout) {
|
|
3648
|
+
this.log("info", "Searching KB nodes with query:", options.query);
|
|
3649
|
+
return searchKbNodes(this, options, timeout);
|
|
3650
|
+
}
|
|
3651
|
+
/**
|
|
3652
|
+
* Get knowledge base nodes by category
|
|
3653
|
+
* Delegates to kb-nodes service
|
|
3654
|
+
*/
|
|
3655
|
+
async getKbNodesByCategory(category, limit, offset, timeout) {
|
|
3656
|
+
this.log("info", "Fetching KB nodes by category:", category);
|
|
3657
|
+
return getKbNodesByCategory(this, category, limit, offset, timeout);
|
|
3658
|
+
}
|
|
3659
|
+
/**
|
|
3660
|
+
* Get knowledge base nodes by user (creator)
|
|
3661
|
+
* Delegates to kb-nodes service
|
|
3662
|
+
*/
|
|
3663
|
+
async getKbNodesByUser(userId, limit, offset, timeout) {
|
|
3664
|
+
this.log("info", "Fetching KB nodes by user:", userId);
|
|
3665
|
+
return getKbNodesByUser(this, userId, limit, offset, timeout);
|
|
3666
|
+
}
|
|
3667
|
+
/**
|
|
3668
|
+
* Get all unique categories from knowledge base nodes
|
|
3669
|
+
* Delegates to kb-nodes service
|
|
3670
|
+
*/
|
|
3671
|
+
async getKbNodeCategories(timeout) {
|
|
3672
|
+
this.log("info", "Fetching KB node categories");
|
|
3673
|
+
return getKbNodeCategories(this, timeout);
|
|
3674
|
+
}
|
|
3675
|
+
/**
|
|
3676
|
+
* Get all unique tags from knowledge base nodes
|
|
3677
|
+
* Delegates to kb-nodes service
|
|
3678
|
+
*/
|
|
3679
|
+
async getKbNodeTags(timeout) {
|
|
3680
|
+
this.log("info", "Fetching KB node tags");
|
|
3681
|
+
return getKbNodeTags(this, timeout);
|
|
3682
|
+
}
|
|
3683
|
+
// ==================== Dashboard Component Methods ====================
|
|
3684
|
+
// These methods delegate to dash-comp service for component selection
|
|
3685
|
+
/**
|
|
3686
|
+
* Request a dashboard component based on user prompt
|
|
3687
|
+
* Uses LLM to pick the best component and generate props
|
|
3688
|
+
* Supports both database queries and external tools as data sources
|
|
3689
|
+
* Delegates to dash-comp service
|
|
3690
|
+
*
|
|
3691
|
+
* @example
|
|
3692
|
+
* ```typescript
|
|
3693
|
+
* const response = await client.sendDashCompRequest({
|
|
3694
|
+
* prompt: "Show me a bar chart of sales by category",
|
|
3695
|
+
* threadId: "thread-123",
|
|
3696
|
+
* });
|
|
3697
|
+
*
|
|
3698
|
+
* if (response.success && response.component) {
|
|
3699
|
+
* console.log('Component:', response.component.name);
|
|
3700
|
+
* console.log('Props:', response.component.props);
|
|
3701
|
+
* console.log('Data source:', response.dataSource);
|
|
3702
|
+
* }
|
|
3703
|
+
* ```
|
|
3704
|
+
*/
|
|
3705
|
+
async sendDashCompRequest(options) {
|
|
3706
|
+
this.log("info", "Sending dash comp request for prompt:", options.prompt.substring(0, 50) + "...");
|
|
3707
|
+
return sendDashCompRequest(this, options);
|
|
3708
|
+
}
|
|
3709
|
+
// ==================== Menu Management Methods ====================
|
|
3710
|
+
// These methods delegate to menus service for menu CRUD operations
|
|
3711
|
+
/**
|
|
3712
|
+
* Create a new menu
|
|
3713
|
+
* Delegates to menus service
|
|
3714
|
+
*/
|
|
3715
|
+
async createMenu(options, timeout) {
|
|
3716
|
+
this.log("info", "Creating menu:", options.name);
|
|
3717
|
+
return createMenu(this, options, timeout);
|
|
3718
|
+
}
|
|
3719
|
+
/**
|
|
3720
|
+
* Update an existing menu
|
|
3721
|
+
* Delegates to menus service
|
|
3722
|
+
*/
|
|
3723
|
+
async updateMenu(options, timeout) {
|
|
3724
|
+
this.log("info", "Updating menu:", options.id);
|
|
3725
|
+
return updateMenu(this, options, timeout);
|
|
3726
|
+
}
|
|
3727
|
+
/**
|
|
3728
|
+
* Delete a menu
|
|
3729
|
+
* Delegates to menus service
|
|
3730
|
+
*/
|
|
3731
|
+
async deleteMenu(id, timeout) {
|
|
3732
|
+
this.log("info", "Deleting menu:", id);
|
|
3733
|
+
return deleteMenu(this, id, timeout);
|
|
3734
|
+
}
|
|
3735
|
+
/**
|
|
3736
|
+
* Get all menus
|
|
3737
|
+
* Delegates to menus service
|
|
3738
|
+
*/
|
|
3739
|
+
async getAllMenus(timeout) {
|
|
3740
|
+
this.log("info", "Fetching all menus");
|
|
3741
|
+
return getAllMenus(this, timeout);
|
|
3742
|
+
}
|
|
3743
|
+
/**
|
|
3744
|
+
* Get a specific menu by ID
|
|
3745
|
+
* Delegates to menus service
|
|
3746
|
+
*/
|
|
3747
|
+
async getMenu(id, timeout) {
|
|
3748
|
+
this.log("info", "Fetching menu:", id);
|
|
3749
|
+
return getMenu(this, id, timeout);
|
|
3750
|
+
}
|
|
3751
|
+
/**
|
|
3752
|
+
* Get root menus (top-level sidebar items)
|
|
3753
|
+
* Delegates to menus service
|
|
3754
|
+
*/
|
|
3755
|
+
async getRootMenus(timeout) {
|
|
3756
|
+
this.log("info", "Fetching root menus");
|
|
3757
|
+
return getRootMenus(this, timeout);
|
|
3758
|
+
}
|
|
3759
|
+
/**
|
|
3760
|
+
* Get child menus by parent ID
|
|
3761
|
+
* Delegates to menus service
|
|
3762
|
+
*/
|
|
3763
|
+
async getChildMenus(parentId, timeout) {
|
|
3764
|
+
this.log("info", "Fetching child menus for parent:", parentId);
|
|
3765
|
+
return getChildMenus(this, parentId, timeout);
|
|
3766
|
+
}
|
|
3767
|
+
/**
|
|
3768
|
+
* Get menus with hierarchy (nested structure)
|
|
3769
|
+
* Delegates to menus service
|
|
3770
|
+
*/
|
|
3771
|
+
async getMenusHierarchy(timeout) {
|
|
3772
|
+
this.log("info", "Fetching menus hierarchy");
|
|
3773
|
+
return getMenusHierarchy(this, timeout);
|
|
3774
|
+
}
|
|
3775
|
+
/**
|
|
3776
|
+
* Query menus with filters
|
|
3777
|
+
* Delegates to menus service
|
|
3778
|
+
*/
|
|
3779
|
+
async queryMenus(options, timeout) {
|
|
3780
|
+
this.log("info", "Querying menus with filters:", options?.filters);
|
|
3781
|
+
return queryMenus(this, options, timeout);
|
|
3782
|
+
}
|
|
3783
|
+
/**
|
|
3784
|
+
* Reorder menus
|
|
3785
|
+
* Delegates to menus service
|
|
3786
|
+
*/
|
|
3787
|
+
async reorderMenus(items, timeout) {
|
|
3788
|
+
this.log("info", "Reordering", items.length, "menus");
|
|
3789
|
+
return reorderMenus(this, items, timeout);
|
|
3790
|
+
}
|
|
3791
|
+
// ==================== Schema Methods ====================
|
|
3792
|
+
/**
|
|
3793
|
+
* Get the database schema
|
|
3794
|
+
* Retrieves the schema.json containing table definitions, columns, and relationships
|
|
3795
|
+
*/
|
|
3796
|
+
async getSchema(options) {
|
|
3797
|
+
this.log("info", "Fetching database schema");
|
|
3798
|
+
return getSchema(this, options);
|
|
3799
|
+
}
|
|
3800
|
+
/**
|
|
3801
|
+
* Internal logging
|
|
3802
|
+
*/
|
|
3803
|
+
log(level, ...args) {
|
|
3804
|
+
if (!this.config.debug && level === "debug") {
|
|
3805
|
+
return;
|
|
3806
|
+
}
|
|
3807
|
+
console[level]("[SuperAtom]", ...args);
|
|
3808
|
+
}
|
|
3809
|
+
};
|
|
3810
|
+
|
|
3811
|
+
// src/setup.ts
|
|
3812
|
+
function setup(components) {
|
|
3813
|
+
if (typeof window === "undefined") {
|
|
3814
|
+
throw new Error("setup() can only be called in a browser environment");
|
|
3815
|
+
}
|
|
3816
|
+
window.SUPERATOM = window.SUPERATOM || {};
|
|
3817
|
+
window.SA = window.SUPERATOM;
|
|
3818
|
+
window.SUPERATOM.COMPONENTS = components;
|
|
3819
|
+
if (window.SUPERATOM.runtime?.componentsLoaded) {
|
|
3820
|
+
window.SUPERATOM.runtime.componentsLoaded();
|
|
3821
|
+
}
|
|
3822
|
+
}
|
|
3823
|
+
function getComponents() {
|
|
3824
|
+
if (typeof window === "undefined") {
|
|
3825
|
+
return void 0;
|
|
3826
|
+
}
|
|
3827
|
+
return window.SUPERATOM?.COMPONENTS;
|
|
3828
|
+
}
|
|
3829
|
+
function getComponent(name) {
|
|
3830
|
+
if (typeof window === "undefined") {
|
|
3831
|
+
return void 0;
|
|
3832
|
+
}
|
|
3833
|
+
return window.SUPERATOM?.COMPONENTS?.[name];
|
|
3834
|
+
}
|
|
3835
|
+
function hasComponents() {
|
|
3836
|
+
if (typeof window === "undefined") {
|
|
3837
|
+
return false;
|
|
3838
|
+
}
|
|
3839
|
+
return !!window.SUPERATOM?.COMPONENTS;
|
|
3840
|
+
}
|
|
3841
|
+
|
|
3842
|
+
// src/index.ts
|
|
3843
|
+
var SDK_VERSION = "0.1.0";
|
|
3844
|
+
|
|
3845
|
+
exports.ActionsRequestMessageSchema = ActionsRequestMessageSchema;
|
|
3846
|
+
exports.ActionsRequestPayloadSchema = ActionsRequestPayloadSchema;
|
|
3847
|
+
exports.ActionsResponseMessageSchema = ActionsResponseMessageSchema;
|
|
3848
|
+
exports.ActionsResponsePayloadSchema = ActionsResponsePayloadSchema;
|
|
3849
|
+
exports.AuthLoginPayloadSchema = AuthLoginPayloadSchema;
|
|
3850
|
+
exports.AuthLoginRequestMessageSchema = AuthLoginRequestMessageSchema;
|
|
3851
|
+
exports.AuthLoginResponseMessageSchema = AuthLoginResponseMessageSchema;
|
|
3852
|
+
exports.AuthLoginResponsePayloadSchema = AuthLoginResponsePayloadSchema;
|
|
3853
|
+
exports.AuthVerifyPayloadSchema = AuthVerifyPayloadSchema;
|
|
3854
|
+
exports.AuthVerifyRequestMessageSchema = AuthVerifyRequestMessageSchema;
|
|
3855
|
+
exports.AuthVerifyResponseMessageSchema = AuthVerifyResponseMessageSchema;
|
|
3856
|
+
exports.AuthVerifyResponsePayloadSchema = AuthVerifyResponsePayloadSchema;
|
|
3857
|
+
exports.BundleChunkMessageSchema = BundleChunkMessageSchema;
|
|
3858
|
+
exports.BundleChunkPayloadSchema = BundleChunkPayloadSchema;
|
|
3859
|
+
exports.BundleErrorMessageSchema = BundleErrorMessageSchema;
|
|
3860
|
+
exports.BundleErrorPayloadSchema = BundleErrorPayloadSchema;
|
|
3861
|
+
exports.BundleRequestMessageSchema = BundleRequestMessageSchema;
|
|
3862
|
+
exports.BundleRequestPayloadSchema = BundleRequestPayloadSchema;
|
|
3863
|
+
exports.ClientConfigSchema = ClientConfigSchema;
|
|
3864
|
+
exports.ComponentSchema = ComponentSchema;
|
|
3865
|
+
exports.ComponentsSendMessageSchema = ComponentsSendMessageSchema;
|
|
3866
|
+
exports.ComponentsSendPayloadSchema = ComponentsSendPayloadSchema;
|
|
3867
|
+
exports.DataRequestMessageSchema = DataRequestMessageSchema;
|
|
3868
|
+
exports.DataRequestPayloadSchema = DataRequestPayloadSchema;
|
|
3869
|
+
exports.DataResponseMessageSchema = DataResponseMessageSchema;
|
|
3870
|
+
exports.DataResponsePayloadSchema = DataResponsePayloadSchema;
|
|
3871
|
+
exports.KbNodeDataSchema = KbNodeDataSchema;
|
|
3872
|
+
exports.KbNodesQueryFiltersSchema = KbNodesQueryFiltersSchema;
|
|
3873
|
+
exports.KbNodesRequestMessageSchema = KbNodesRequestMessageSchema;
|
|
3874
|
+
exports.KbNodesRequestPayloadSchema = KbNodesRequestPayloadSchema;
|
|
3875
|
+
exports.KbNodesResponseMessageSchema = KbNodesResponseMessageSchema;
|
|
3876
|
+
exports.KbNodesResponsePayloadSchema = KbNodesResponsePayloadSchema;
|
|
3877
|
+
exports.MenuDataSchema = MenuDataSchema;
|
|
3878
|
+
exports.MenuQueryFiltersSchema = MenuQueryFiltersSchema;
|
|
3879
|
+
exports.MenusRequestMessageSchema = MenusRequestMessageSchema;
|
|
3880
|
+
exports.MenusRequestPayloadSchema = MenusRequestPayloadSchema;
|
|
3881
|
+
exports.MenusResponseMessageSchema = MenusResponseMessageSchema;
|
|
3882
|
+
exports.MenusResponsePayloadSchema = MenusResponsePayloadSchema;
|
|
3883
|
+
exports.MessageParticipantSchema = MessageParticipantSchema;
|
|
3884
|
+
exports.MessageSchema = MessageSchema;
|
|
3885
|
+
exports.SDK_VERSION = SDK_VERSION;
|
|
3886
|
+
exports.SuperatomClient = SuperatomClient;
|
|
3887
|
+
exports.UILogEntrySchema = UILogEntrySchema;
|
|
3888
|
+
exports.UILogsMessageSchema = UILogsMessageSchema;
|
|
3889
|
+
exports.UILogsPayloadSchema = UILogsPayloadSchema;
|
|
3890
|
+
exports.UserPromptRequestMessageSchema = UserPromptRequestMessageSchema;
|
|
3891
|
+
exports.UserPromptRequestPayloadSchema = UserPromptRequestPayloadSchema;
|
|
3892
|
+
exports.UserPromptResponseMessageSchema = UserPromptResponseMessageSchema;
|
|
3893
|
+
exports.UserPromptResponsePayloadSchema = UserPromptResponsePayloadSchema;
|
|
3894
|
+
exports.UserPromptSuggestionsRequestMessageSchema = UserPromptSuggestionsRequestMessageSchema;
|
|
3895
|
+
exports.UserPromptSuggestionsRequestPayloadSchema = UserPromptSuggestionsRequestPayloadSchema;
|
|
3896
|
+
exports.UserPromptSuggestionsResponseMessageSchema = UserPromptSuggestionsResponseMessageSchema;
|
|
3897
|
+
exports.UserPromptSuggestionsResponsePayloadSchema = UserPromptSuggestionsResponsePayloadSchema;
|
|
3898
|
+
exports.getComponent = getComponent;
|
|
3899
|
+
exports.getComponents = getComponents;
|
|
3900
|
+
exports.hasComponents = hasComponents;
|
|
3901
|
+
exports.services = services_exports;
|
|
3902
|
+
exports.setup = setup;
|
|
3903
|
+
//# sourceMappingURL=index.cjs.map
|
|
3904
|
+
//# sourceMappingURL=index.cjs.map
|