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