@superatomai/sdk-web 0.0.29 → 0.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1000,6 +1000,69 @@ var MenusResponseMessageSchema = zod.z.object({
1000
1000
  to: MessageParticipantSchema.optional(),
1001
1001
  payload: MenusResponsePayloadSchema
1002
1002
  });
1003
+ var SchemaColumnStatisticsSchema = zod.z.object({
1004
+ distinct: zod.z.number().optional(),
1005
+ min: zod.z.number().optional(),
1006
+ max: zod.z.number().optional()
1007
+ });
1008
+ var SchemaColumnSchema = zod.z.object({
1009
+ name: zod.z.string(),
1010
+ type: zod.z.string(),
1011
+ nativeType: zod.z.string(),
1012
+ nullable: zod.z.boolean(),
1013
+ description: zod.z.string(),
1014
+ statistics: SchemaColumnStatisticsSchema.optional(),
1015
+ cardinality: zod.z.enum(["unique", "high", "medium", "low"]).optional(),
1016
+ sampleValues: zod.z.array(zod.z.string()).optional()
1017
+ });
1018
+ var SchemaTableSchema = zod.z.object({
1019
+ name: zod.z.string(),
1020
+ fullName: zod.z.string(),
1021
+ rowCount: zod.z.number(),
1022
+ description: zod.z.string(),
1023
+ columns: zod.z.array(SchemaColumnSchema)
1024
+ });
1025
+ var SchemaRelationshipSchema = zod.z.object({
1026
+ from: zod.z.string(),
1027
+ to: zod.z.string(),
1028
+ type: zod.z.string(),
1029
+ keys: zod.z.array(zod.z.string())
1030
+ });
1031
+ var DatabaseSchemaSchema = zod.z.object({
1032
+ database: zod.z.string(),
1033
+ databaseType: zod.z.string().optional(),
1034
+ schema: zod.z.string(),
1035
+ description: zod.z.string(),
1036
+ tables: zod.z.array(SchemaTableSchema),
1037
+ relationships: zod.z.array(SchemaRelationshipSchema).optional()
1038
+ });
1039
+ var SchemaRequestPayloadSchema = zod.z.object({
1040
+ /** If true, returns the formatted documentation string in addition to raw JSON */
1041
+ formatted: zod.z.boolean().optional()
1042
+ });
1043
+ var SchemaRequestMessageSchema = zod.z.object({
1044
+ id: zod.z.string(),
1045
+ type: zod.z.literal("SCHEMA_REQ"),
1046
+ from: MessageParticipantSchema,
1047
+ to: MessageParticipantSchema.optional(),
1048
+ payload: SchemaRequestPayloadSchema
1049
+ });
1050
+ var SchemaResponsePayloadSchema = zod.z.object({
1051
+ success: zod.z.boolean(),
1052
+ error: zod.z.string().optional(),
1053
+ data: zod.z.object({
1054
+ schema: DatabaseSchemaSchema,
1055
+ /** Formatted schema documentation (only if formatted: true was requested) */
1056
+ formatted: zod.z.string().optional()
1057
+ }).optional()
1058
+ });
1059
+ zod.z.object({
1060
+ id: zod.z.string(),
1061
+ type: zod.z.literal("SCHEMA_RES"),
1062
+ from: MessageParticipantSchema,
1063
+ to: MessageParticipantSchema.optional(),
1064
+ payload: SchemaResponsePayloadSchema
1065
+ });
1003
1066
  var ClientConfigSchema = zod.z.object({
1004
1067
  userId: zod.z.string(),
1005
1068
  projectId: zod.z.string(),
@@ -1062,6 +1125,7 @@ __export(services_exports, {
1062
1125
  getMenusHierarchy: () => getMenusHierarchy,
1063
1126
  getReport: () => getReport,
1064
1127
  getRootMenus: () => getRootMenus,
1128
+ getSchema: () => getSchema,
1065
1129
  getUI: () => getUI,
1066
1130
  getUser: () => getUser,
1067
1131
  queryArtifacts: () => queryArtifacts,
@@ -2874,6 +2938,27 @@ async function reorderMenus(client, items, timeout) {
2874
2938
  };
2875
2939
  }
2876
2940
 
2941
+ // src/services/schema.ts
2942
+ async function getSchema(client, options = {}) {
2943
+ const messageId = `msg_${Date.now()}_${Math.random().toString(36).substring(7)}`;
2944
+ const message = SchemaRequestMessageSchema.parse({
2945
+ id: messageId,
2946
+ type: "SCHEMA_REQ",
2947
+ from: { type: client.type },
2948
+ to: { type: "data-agent" },
2949
+ payload: {
2950
+ formatted: options.formatted ?? false
2951
+ }
2952
+ });
2953
+ const response = await client.sendWithResponse(message, options.timeout);
2954
+ const payload = response.payload;
2955
+ return {
2956
+ success: payload.success,
2957
+ error: payload.error,
2958
+ data: payload.data
2959
+ };
2960
+ }
2961
+
2877
2962
  // src/client.ts
2878
2963
  var SuperatomClient = class {
2879
2964
  constructor(config) {
@@ -3702,6 +3787,15 @@ var SuperatomClient = class {
3702
3787
  this.log("info", "Reordering", items.length, "menus");
3703
3788
  return reorderMenus(this, items, timeout);
3704
3789
  }
3790
+ // ==================== Schema Methods ====================
3791
+ /**
3792
+ * Get the database schema
3793
+ * Retrieves the schema.json containing table definitions, columns, and relationships
3794
+ */
3795
+ async getSchema(options) {
3796
+ this.log("info", "Fetching database schema");
3797
+ return getSchema(this, options);
3798
+ }
3705
3799
  /**
3706
3800
  * Internal logging
3707
3801
  */