@magemetrics/core 0.14.1 → 0.15.0

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +27 -161
  2. package/dist/index.js +65 -226
  3. package/package.json +6 -6
package/dist/index.d.ts CHANGED
@@ -14,7 +14,7 @@ import { z } from 'zod';
14
14
 
15
15
  export declare const ASK_USER_QUESTION: "askUserQuestion";
16
16
 
17
- export declare type AskUserQuestionInput = z.infer<typeof inputSchema_9>;
17
+ export declare type AskUserQuestionInput = z.infer<typeof inputSchema_5>;
18
18
 
19
19
  export declare type AskUserQuestionPart = Extract<MMChatUIMessagePart, {
20
20
  type: `tool-${typeof ASK_USER_QUESTION}`;
@@ -709,6 +709,8 @@ export declare class DirectAuthProvider implements AuthProvider {
709
709
  private setState;
710
710
  }
711
711
 
712
+ export declare const EXPLORE_SCHEMA: "exploreSchema";
713
+
712
714
  /**
713
715
  * External authentication provider that handles the full token exchange flow.
714
716
  *
@@ -1065,10 +1067,6 @@ export declare const GENERATE_DATA_REPORT: "generateDataReport";
1065
1067
 
1066
1068
  export declare const GENERATE_VISUALIZATION: "generateVisualization";
1067
1069
 
1068
- export declare const GET_AVAILABLE_COLUMNS_FOR_TABLE: "getAvailableColumnsForTable";
1069
-
1070
- export declare const GET_AVAILABLE_TABLES: "getAvailableTables";
1071
-
1072
1070
  export declare const getMessageTextContent: (message: MMChatUIMessage) => string | undefined;
1073
1071
 
1074
1072
  export declare const getPublicApiClient: (apiUrl: string, apiKey: string) => Client<PublicPaths>;
@@ -1104,10 +1102,6 @@ declare const inputSchema: z.ZodObject<{
1104
1102
  }>;
1105
1103
  }, z.core.$strip>;
1106
1104
 
1107
- declare const inputSchema_10: z.ZodObject<{
1108
- question: z.ZodString;
1109
- }, z.core.$strip>;
1110
-
1111
1105
  declare const inputSchema_2: z.ZodObject<{
1112
1106
  reportId: z.ZodUnion<[z.ZodNumber, z.ZodUUID]>;
1113
1107
  chartType: z.ZodEnum<{
@@ -1124,35 +1118,12 @@ declare const inputSchema_3: z.ZodObject<{
1124
1118
  }, z.core.$strip>;
1125
1119
 
1126
1120
  declare const inputSchema_4: z.ZodObject<{
1127
- value: z.ZodString;
1128
- }, z.core.$strip>;
1129
-
1130
- declare const inputSchema_5: z.ZodObject<{}, z.core.$strip>;
1131
-
1132
- declare const inputSchema_6: z.ZodObject<{
1133
- dataset: z.ZodString;
1134
- table_name: z.ZodString;
1135
- includeDescriptions: z.ZodDefault<z.ZodBoolean>;
1136
- includeDataTypes: z.ZodDefault<z.ZodBoolean>;
1137
- includeSampleValues: z.ZodDefault<z.ZodBoolean>;
1138
- includeStatistics: z.ZodDefault<z.ZodBoolean>;
1139
- includeFreshness: z.ZodDefault<z.ZodBoolean>;
1140
- }, z.core.$strip>;
1141
-
1142
- declare const inputSchema_7: z.ZodObject<{
1143
- reportId: z.ZodNumber;
1144
- limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
1145
- offset: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
1146
- skipSampleRows: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
1147
- }, z.core.$strip>;
1148
-
1149
- declare const inputSchema_8: z.ZodObject<{
1150
1121
  query: z.ZodString;
1151
1122
  fromDate: z.ZodOptional<z.ZodISODate>;
1152
1123
  toDate: z.ZodOptional<z.ZodISODate>;
1153
1124
  }, z.core.$strip>;
1154
1125
 
1155
- declare const inputSchema_9: z.ZodObject<{
1126
+ declare const inputSchema_5: z.ZodObject<{
1156
1127
  questions: z.ZodArray<z.ZodObject<{
1157
1128
  question: z.ZodString;
1158
1129
  header: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
@@ -1164,6 +1135,10 @@ declare const inputSchema_9: z.ZodObject<{
1164
1135
  }, z.core.$strip>>;
1165
1136
  }, z.core.$strip>;
1166
1137
 
1138
+ declare const inputSchema_6: z.ZodObject<{
1139
+ question: z.ZodString;
1140
+ }, z.core.$strip>;
1141
+
1167
1142
  export declare const isAskUserQuestionPart: (part: MMChatUIMessagePart) => part is AskUserQuestionPart;
1168
1143
 
1169
1144
  export declare const isFrontendV1Visualization: (visualization: FrontendVisualization | V1FrontendVisualization) => visualization is V1FrontendVisualization;
@@ -1591,13 +1566,9 @@ export declare type MMUiTools = {
1591
1566
  generateDataReport: UiTool;
1592
1567
  generateVisualization: UiTool_2;
1593
1568
  think: UiTool_3;
1594
- valueBasedColumnSearch: UiTool_4;
1595
- getAvailableTables: UiTool_5;
1596
- getAvailableColumnsForTable: UiTool_6;
1597
- paginateDataReport: UiTool_7;
1598
- webSearch: UiTool_8;
1599
- askUserQuestion: UiTool_9;
1600
- exploreSchema: UiTool_10;
1569
+ webSearch: UiTool_4;
1570
+ askUserQuestion: UiTool_5;
1571
+ exploreSchema: UiTool_6;
1601
1572
  };
1602
1573
 
1603
1574
  declare interface operations {
@@ -6274,8 +6245,6 @@ declare interface operations {
6274
6245
  };
6275
6246
  }
6276
6247
 
6277
- export declare const PAGINATE_DATA_REPORT: "paginateDataReport";
6278
-
6279
6248
  declare type PatchParam<T, Config extends RemoveParamsConfig, P extends keyof Config> = Simplify<T extends {
6280
6249
  [key in P]: infer H;
6281
6250
  } ? H extends Partial<Record<string, unknown>> ? Config[P] extends string ? Omit<H, Config[P]> : H : never : never>;
@@ -7169,6 +7138,19 @@ declare const RedactedAskUserQuestionResponse: z.ZodObject<{
7169
7138
 
7170
7139
  export declare type RedactedAskUserQuestionResponseType = z.output<typeof RedactedAskUserQuestionResponse>;
7171
7140
 
7141
+ declare const RedactedExploreSchemaResponse: z.ZodObject<{
7142
+ tool: z.ZodDefault<z.ZodLiteral<"exploreSchema">>;
7143
+ result: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
7144
+ status: z.ZodLiteral<"success">;
7145
+ public: z.ZodObject<{}, z.core.$loose>;
7146
+ }, z.core.$strip>, z.ZodObject<{
7147
+ status: z.ZodLiteral<"error">;
7148
+ message: z.ZodString;
7149
+ }, z.core.$strip>], "status">>;
7150
+ }, z.core.$strip>;
7151
+
7152
+ export declare type RedactedExploreSchemaResponseType = z.output<typeof RedactedExploreSchemaResponse>;
7153
+
7172
7154
  declare const RedactedGenerateDataReportResponse: z.ZodObject<{
7173
7155
  tool: z.ZodDefault<z.ZodLiteral<"generateDataReport">>;
7174
7156
  result: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -7226,32 +7208,6 @@ declare const RedactedGenerateVisualizationResponse: z.ZodObject<{
7226
7208
 
7227
7209
  export declare type RedactedGenerateVisualizationResponseType = z.infer<typeof RedactedGenerateVisualizationResponse>;
7228
7210
 
7229
- declare const RedactedGetAvailableColumnsForTableResponse: z.ZodObject<{
7230
- tool: z.ZodDefault<z.ZodLiteral<"getAvailableColumnsForTable">>;
7231
- result: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
7232
- status: z.ZodLiteral<"success">;
7233
- public: z.ZodObject<{}, z.core.$loose>;
7234
- }, z.core.$strip>, z.ZodObject<{
7235
- status: z.ZodLiteral<"error">;
7236
- message: z.ZodString;
7237
- }, z.core.$strip>], "status">>;
7238
- }, z.core.$strip>;
7239
-
7240
- export declare type RedactedGetAvailableColumnsForTableResponseType = z.infer<typeof RedactedGetAvailableColumnsForTableResponse>;
7241
-
7242
- declare const RedactedGetAvailableTablesResponse: z.ZodObject<{
7243
- tool: z.ZodDefault<z.ZodLiteral<"getAvailableTables">>;
7244
- result: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
7245
- status: z.ZodLiteral<"success">;
7246
- public: z.ZodObject<{}, z.core.$loose>;
7247
- }, z.core.$strip>, z.ZodObject<{
7248
- status: z.ZodLiteral<"error">;
7249
- message: z.ZodString;
7250
- }, z.core.$strip>], "status">>;
7251
- }, z.core.$strip>;
7252
-
7253
- export declare type RedactedGetAvailableTablesResponseType = z.output<typeof RedactedGetAvailableTablesResponse>;
7254
-
7255
7211
  declare const redactedOutputSchema: z.ZodObject<{
7256
7212
  tool: z.ZodLiteral<"generateDataReport">;
7257
7213
  result: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -7306,55 +7262,6 @@ declare const redactedOutputSchema_2: z.ZodObject<{
7306
7262
  }, z.core.$strip>;
7307
7263
 
7308
7264
  declare const redactedOutputSchema_3: z.ZodObject<{
7309
- tool: z.ZodLiteral<"valueBasedColumnSearch">;
7310
- result: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
7311
- status: z.ZodLiteral<"success">;
7312
- public: z.ZodObject<{}, z.core.$loose>;
7313
- }, z.core.$strip>, z.ZodObject<{
7314
- status: z.ZodLiteral<"error">;
7315
- message: z.ZodString;
7316
- }, z.core.$strip>], "status">>;
7317
- }, z.core.$strip>;
7318
-
7319
- declare const redactedOutputSchema_4: z.ZodObject<{
7320
- tool: z.ZodLiteral<"getAvailableTables">;
7321
- result: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
7322
- status: z.ZodLiteral<"success">;
7323
- public: z.ZodObject<{}, z.core.$loose>;
7324
- }, z.core.$strip>, z.ZodObject<{
7325
- status: z.ZodLiteral<"error">;
7326
- message: z.ZodString;
7327
- }, z.core.$strip>], "status">>;
7328
- }, z.core.$strip>;
7329
-
7330
- declare const redactedOutputSchema_5: z.ZodObject<{
7331
- tool: z.ZodLiteral<"getAvailableColumnsForTable">;
7332
- result: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
7333
- status: z.ZodLiteral<"success">;
7334
- public: z.ZodObject<{}, z.core.$loose>;
7335
- }, z.core.$strip>, z.ZodObject<{
7336
- status: z.ZodLiteral<"error">;
7337
- message: z.ZodString;
7338
- }, z.core.$strip>], "status">>;
7339
- }, z.core.$strip>;
7340
-
7341
- declare const redactedOutputSchema_6: z.ZodObject<{
7342
- tool: z.ZodLiteral<"paginateDataReport">;
7343
- result: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
7344
- status: z.ZodLiteral<"success">;
7345
- public: z.ZodObject<{
7346
- totalRows: z.ZodNumber;
7347
- fetchedRows: z.ZodNumber;
7348
- offset: z.ZodNumber;
7349
- hasMore: z.ZodBoolean;
7350
- }, z.core.$strip>;
7351
- }, z.core.$strip>, z.ZodObject<{
7352
- status: z.ZodLiteral<"error">;
7353
- message: z.ZodString;
7354
- }, z.core.$strip>], "status">>;
7355
- }, z.core.$strip>;
7356
-
7357
- declare const redactedOutputSchema_7: z.ZodObject<{
7358
7265
  tool: z.ZodLiteral<"search">;
7359
7266
  result: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
7360
7267
  status: z.ZodLiteral<"success">;
@@ -7372,7 +7279,7 @@ declare const redactedOutputSchema_7: z.ZodObject<{
7372
7279
  }, z.core.$strip>], "status">>;
7373
7280
  }, z.core.$strip>;
7374
7281
 
7375
- declare const redactedOutputSchema_8: z.ZodObject<{
7282
+ declare const redactedOutputSchema_4: z.ZodObject<{
7376
7283
  tool: z.ZodLiteral<"exploreSchema">;
7377
7284
  result: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
7378
7285
  status: z.ZodLiteral<"success">;
@@ -7383,24 +7290,6 @@ declare const redactedOutputSchema_8: z.ZodObject<{
7383
7290
  }, z.core.$strip>], "status">>;
7384
7291
  }, z.core.$strip>;
7385
7292
 
7386
- declare const RedactedPaginateDataReportResponse: z.ZodObject<{
7387
- tool: z.ZodDefault<z.ZodLiteral<"paginateDataReport">>;
7388
- result: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
7389
- status: z.ZodLiteral<"success">;
7390
- public: z.ZodObject<{
7391
- totalRows: z.ZodNumber;
7392
- fetchedRows: z.ZodNumber;
7393
- offset: z.ZodNumber;
7394
- hasMore: z.ZodBoolean;
7395
- }, z.core.$strip>;
7396
- }, z.core.$strip>, z.ZodObject<{
7397
- status: z.ZodLiteral<"error">;
7398
- message: z.ZodString;
7399
- }, z.core.$strip>], "status">>;
7400
- }, z.core.$strip>;
7401
-
7402
- export declare type RedactedPaginateDataReportResponseType = z.output<typeof RedactedPaginateDataReportResponse>;
7403
-
7404
7293
  declare const RedactedThinkResponse: z.ZodObject<{
7405
7294
  tool: z.ZodDefault<z.ZodLiteral<"think">>;
7406
7295
  result: z.ZodOptional<z.ZodObject<{
@@ -7411,19 +7300,6 @@ declare const RedactedThinkResponse: z.ZodObject<{
7411
7300
 
7412
7301
  export declare type RedactedThinkResponseType = z.output<typeof RedactedThinkResponse>;
7413
7302
 
7414
- declare const RedactedValueBasedColumnSearchResponse: z.ZodObject<{
7415
- tool: z.ZodDefault<z.ZodLiteral<"valueBasedColumnSearch">>;
7416
- result: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
7417
- status: z.ZodLiteral<"success">;
7418
- public: z.ZodObject<{}, z.core.$loose>;
7419
- }, z.core.$strip>, z.ZodObject<{
7420
- status: z.ZodLiteral<"error">;
7421
- message: z.ZodString;
7422
- }, z.core.$strip>], "status">>;
7423
- }, z.core.$strip>;
7424
-
7425
- export declare type RedactedValueBasedColumnSearchResponseType = z.infer<typeof RedactedValueBasedColumnSearchResponse>;
7426
-
7427
7303
  declare const RedactedWebSearchToolResponse: z.ZodObject<{
7428
7304
  tool: z.ZodDefault<z.ZodLiteral<"search">>;
7429
7305
  result: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -7575,23 +7451,15 @@ export declare const toUploadedFileRefUrl: (uploadedFileId: string) => string;
7575
7451
 
7576
7452
  declare type UiTool = InferUITool<Tool<z.infer<typeof inputSchema>, z.infer<typeof redactedOutputSchema>>>;
7577
7453
 
7578
- declare type UiTool_10 = InferUITool<Tool<z.infer<typeof inputSchema_10>, z.infer<typeof redactedOutputSchema_8>>>;
7579
-
7580
7454
  declare type UiTool_2 = InferUITool<Tool<z.infer<typeof inputSchema_2>, z.infer<typeof redactedOutputSchema_2>>>;
7581
7455
 
7582
7456
  declare type UiTool_3 = InferUITool<Tool<z.infer<typeof inputSchema_3>, z.infer<typeof RedactedThinkResponse>>>;
7583
7457
 
7584
7458
  declare type UiTool_4 = InferUITool<Tool<z.infer<typeof inputSchema_4>, z.infer<typeof redactedOutputSchema_3>>>;
7585
7459
 
7586
- declare type UiTool_5 = InferUITool<Tool<z.infer<typeof inputSchema_5>, z.infer<typeof redactedOutputSchema_4>>>;
7587
-
7588
- declare type UiTool_6 = InferUITool<Tool<z.infer<typeof inputSchema_6>, z.infer<typeof redactedOutputSchema_5>>>;
7460
+ declare type UiTool_5 = InferUITool<Tool<z.infer<typeof inputSchema_5>, z.infer<typeof RedactedAskUserQuestionResponse>>>;
7589
7461
 
7590
- declare type UiTool_7 = InferUITool<Tool<z.infer<typeof inputSchema_7>, z.infer<typeof redactedOutputSchema_6>>>;
7591
-
7592
- declare type UiTool_8 = InferUITool<Tool<z.infer<typeof inputSchema_8>, z.infer<typeof redactedOutputSchema_7>>>;
7593
-
7594
- declare type UiTool_9 = InferUITool<Tool<z.infer<typeof inputSchema_9>, z.infer<typeof RedactedAskUserQuestionResponse>>>;
7462
+ declare type UiTool_6 = InferUITool<Tool<z.infer<typeof inputSchema_6>, z.infer<typeof redactedOutputSchema_4>>>;
7595
7463
 
7596
7464
  declare const UpdateCanvasSchema: z.ZodObject<{
7597
7465
  id: z.ZodUUID;
@@ -7759,8 +7627,6 @@ export declare const validateUploadedFiles: (uploadedFiles: ReadonlyArray<{
7759
7627
  size_bytes: number;
7760
7628
  }>) => void;
7761
7629
 
7762
- export declare const VALUE_BASED_COLUMN_SEARCH: "valueBasedColumnSearch";
7763
-
7764
7630
  export declare const WEB_SEARCH: "webSearch";
7765
7631
 
7766
7632
  export { }
package/dist/index.js CHANGED
@@ -58,7 +58,7 @@ var addApiKeyHeader = (apiKey) => {
58
58
 
59
59
  // package.json
60
60
  var package_default = {
61
- version: "0.14.1"};
61
+ version: "0.15.0"};
62
62
 
63
63
  // src/core/MageMetricsEventEmitter.ts
64
64
  var MageMetricsEventEmitter = class {
@@ -483,7 +483,7 @@ function getOpenApiConfiguration(refOrOpenapi, metadataOrOptions, options) {
483
483
  };
484
484
  }
485
485
 
486
- // ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/router/reg-exp-router/node.js
486
+ // ../../node_modules/.pnpm/hono@4.12.25/node_modules/hono/dist/router/reg-exp-router/node.js
487
487
  new Set(".\\+*[^]$()");
488
488
  var createRoute = (routeConfig) => {
489
489
  const route = {
@@ -4725,6 +4725,40 @@ var getMessageTextContent = (message) => {
4725
4725
  }
4726
4726
  return content;
4727
4727
  };
4728
+ var EXPLORE_SCHEMA = "exploreSchema";
4729
+ var SuccessVersion2 = z.object({
4730
+ status: z.literal("success"),
4731
+ public: z.looseObject({}),
4732
+ private: z.object({
4733
+ answer: z.string()
4734
+ })
4735
+ });
4736
+ var RedactedSuccessVersion = SuccessVersion2.omit({
4737
+ private: true
4738
+ });
4739
+ var ErrorVersion2 = z.object({
4740
+ status: z.literal("error"),
4741
+ message: z.string()
4742
+ });
4743
+ var ExploreSchemaResponse = z.object({
4744
+ tool: z.literal(EXPLORE_SCHEMA).default(EXPLORE_SCHEMA),
4745
+ result: z.discriminatedUnion("status", [SuccessVersion2, ErrorVersion2]).optional()
4746
+ });
4747
+ ExploreSchemaResponse.extend({
4748
+ result: z.discriminatedUnion("status", [RedactedSuccessVersion, ErrorVersion2]).optional()
4749
+ });
4750
+ z.object({
4751
+ question: z.string().describe("A natural language question about the available data schema, tables, columns, data structure, or specific data values.")
4752
+ });
4753
+ var outputResultSchema = z.discriminatedUnion("status", [SuccessVersion2, ErrorVersion2]).optional();
4754
+ z.object({
4755
+ tool: z.literal(EXPLORE_SCHEMA),
4756
+ result: outputResultSchema
4757
+ });
4758
+ z.object({
4759
+ tool: z.literal(EXPLORE_SCHEMA),
4760
+ result: z.discriminatedUnion("status", [RedactedSuccessVersion, ErrorVersion2]).optional()
4761
+ });
4728
4762
  var GENERATE_DATA_REPORT = "generateDataReport";
4729
4763
  var SqlErrorCategory = z.enum([
4730
4764
  // Infrastructure errors (retriable - SQL might still be valid)
@@ -4761,7 +4795,7 @@ var SqlGenerationErrorInfo = z.object({
4761
4795
  line_num: z.number().nullish(),
4762
4796
  col_num: z.number().nullish()
4763
4797
  });
4764
- var SuccessVersion2 = z.object({
4798
+ var SuccessVersion3 = z.object({
4765
4799
  status: z.literal("success"),
4766
4800
  public: z.object({
4767
4801
  flowDataId: z.number(),
@@ -4774,10 +4808,10 @@ var SuccessVersion2 = z.object({
4774
4808
  dataReportSummary: z.string()
4775
4809
  })
4776
4810
  });
4777
- var RedactedSuccessVersion = SuccessVersion2.omit({
4811
+ var RedactedSuccessVersion2 = SuccessVersion3.omit({
4778
4812
  private: true
4779
4813
  });
4780
- var ErrorVersion2 = z.object({
4814
+ var ErrorVersion3 = z.object({
4781
4815
  status: z.literal("error"),
4782
4816
  message: z.string(),
4783
4817
  errorInfo: SqlGenerationErrorInfo.optional(),
@@ -4789,11 +4823,11 @@ var RedactedErrorVersion = z.object({
4789
4823
  });
4790
4824
  var GenerateDataReportResponse = z.object({
4791
4825
  tool: z.literal(GENERATE_DATA_REPORT).default(GENERATE_DATA_REPORT),
4792
- result: z.discriminatedUnion("status", [SuccessVersion2, ErrorVersion2]).optional()
4826
+ result: z.discriminatedUnion("status", [SuccessVersion3, ErrorVersion3]).optional()
4793
4827
  });
4794
4828
  GenerateDataReportResponse.extend({
4795
4829
  result: z.discriminatedUnion("status", [
4796
- SuccessVersion2.omit({ private: true }),
4830
+ SuccessVersion3.omit({ private: true }),
4797
4831
  RedactedErrorVersion
4798
4832
  ]).optional()
4799
4833
  });
@@ -4803,20 +4837,20 @@ z.object({
4803
4837
  isNewAnalysisGoal: z.boolean().describe("Indicates whether this request represents a new analysis goal very different from the current conversation flow (true), or continues/modifies the existing analysis (false)."),
4804
4838
  difficultyLevel: z.enum(["simple", "moderate", "complex"]).describe("Complexity level of the SQL query based on the user request.")
4805
4839
  });
4806
- var outputResultSchema = z.discriminatedUnion("status", [SuccessVersion2, ErrorVersion2]).optional();
4840
+ var outputResultSchema2 = z.discriminatedUnion("status", [SuccessVersion3, ErrorVersion3]).optional();
4807
4841
  z.object({
4808
4842
  tool: z.literal(GENERATE_DATA_REPORT),
4809
- result: outputResultSchema
4843
+ result: outputResultSchema2
4810
4844
  });
4811
4845
  z.object({
4812
4846
  tool: z.literal(GENERATE_DATA_REPORT),
4813
4847
  result: z.discriminatedUnion("status", [
4814
- RedactedSuccessVersion,
4848
+ RedactedSuccessVersion2,
4815
4849
  RedactedErrorVersion
4816
4850
  ]).optional()
4817
4851
  });
4818
4852
  var GENERATE_VISUALIZATION = "generateVisualization";
4819
- var SuccessVersion3 = z.object({
4853
+ var SuccessVersion4 = z.object({
4820
4854
  status: z.literal("success"),
4821
4855
  public: z.object({
4822
4856
  flowDataId: z.number(),
@@ -4831,21 +4865,21 @@ var SuccessVersion3 = z.object({
4831
4865
  dataReportSummary: z.string().optional()
4832
4866
  })
4833
4867
  });
4834
- var RedactedSuccessVersion2 = SuccessVersion3.omit({
4868
+ var RedactedSuccessVersion3 = SuccessVersion4.omit({
4835
4869
  private: true
4836
4870
  });
4837
- var ErrorVersion3 = z.object({
4871
+ var ErrorVersion4 = z.object({
4838
4872
  status: z.literal("error"),
4839
4873
  message: z.string()
4840
4874
  });
4841
4875
  var GenerateVisualizationResponse = z.object({
4842
4876
  tool: z.literal(GENERATE_VISUALIZATION).default(GENERATE_VISUALIZATION),
4843
- result: z.discriminatedUnion("status", [SuccessVersion3, ErrorVersion3]).optional()
4877
+ result: z.discriminatedUnion("status", [SuccessVersion4, ErrorVersion4]).optional()
4844
4878
  });
4845
4879
  GenerateVisualizationResponse.extend({
4846
4880
  result: z.discriminatedUnion("status", [
4847
- SuccessVersion3.omit({ private: true }),
4848
- ErrorVersion3
4881
+ SuccessVersion4.omit({ private: true }),
4882
+ ErrorVersion4
4849
4883
  ]).optional()
4850
4884
  });
4851
4885
  z.object({
@@ -4853,226 +4887,31 @@ z.object({
4853
4887
  chartType: z.enum(["bar", "line/area", "scatter", "pie"]).describe("Type of visualization to generate"),
4854
4888
  explanations: z.string().describe("Mandatory instructions for the visualization engine. This must include: 1) Aggregation logic (e.g., 'Sum revenue', 'Count IDs'), 2) Grouping details, 3) Limits for high-cardinality data (e.g., 'Sort descending and keep only the Top 10 results'), and 4) The specific columns to display on the plot (identifying metrics, axis, and dimensions).")
4855
4889
  });
4856
- var outputResultSchema2 = z.discriminatedUnion("status", [SuccessVersion3, ErrorVersion3]).optional();
4857
- z.object({
4858
- tool: z.literal(GENERATE_VISUALIZATION),
4859
- result: outputResultSchema2
4860
- });
4861
- z.object({
4862
- tool: z.literal(GENERATE_VISUALIZATION),
4863
- result: z.discriminatedUnion("status", [RedactedSuccessVersion2, ErrorVersion3]).optional()
4864
- });
4865
- var GET_AVAILABLE_COLUMNS_FOR_TABLE = "getAvailableColumnsForTable";
4866
- var ColumnMetadataSchema2 = z.object({
4867
- // Always returned (not gated by any flag)
4868
- name: z.string(),
4869
- // includeDescriptions flag
4870
- description: z.string().nullable().optional(),
4871
- // includeDataTypes flag
4872
- data_type: z.string().nullable().optional(),
4873
- canonical_data_type: z.string().nullable().optional(),
4874
- // includeSampleValues flag
4875
- sample_values: z.array(z.unknown()).nullable().optional(),
4876
- // includeStatistics flag
4877
- null_percentage: z.number().nullable().optional(),
4878
- unique_values: z.number().nullable().optional(),
4879
- min_value: z.number().nullable().optional(),
4880
- max_value: z.number().nullable().optional(),
4881
- min_date: z.string().nullable().optional(),
4882
- max_date: z.string().nullable().optional(),
4883
- has_null: z.boolean().nullable().optional(),
4884
- // includeFreshness flag
4885
- updated_at: z.string().nullable().optional()
4886
- });
4887
- var SuccessVersion4 = z.object({
4888
- status: z.literal("success"),
4889
- public: z.looseObject({}),
4890
- private: z.object({
4891
- message: z.string().optional(),
4892
- columns: ColumnMetadataSchema2.array()
4893
- })
4894
- });
4895
- var RedactedSuccessVersion3 = SuccessVersion4.omit({
4896
- private: true
4897
- });
4898
- var ErrorVersion4 = z.object({
4899
- status: z.literal("error"),
4900
- message: z.string()
4901
- });
4902
- var GetAvailableColumnsForTableResponse = z.object({
4903
- tool: z.literal(GET_AVAILABLE_COLUMNS_FOR_TABLE).default(GET_AVAILABLE_COLUMNS_FOR_TABLE),
4904
- result: z.discriminatedUnion("status", [SuccessVersion4, ErrorVersion4]).optional()
4905
- });
4906
- GetAvailableColumnsForTableResponse.extend({
4907
- result: z.discriminatedUnion("status", [
4908
- SuccessVersion4.omit({ private: true }),
4909
- ErrorVersion4
4910
- ]).optional()
4911
- });
4912
- z.object({
4913
- dataset: z.string().describe("The dataset (schema) the table belongs to."),
4914
- table_name: z.string().describe("A table name of the database for which to retrieve all column names and information."),
4915
- includeDescriptions: z.boolean().default(true).describe("Include semantic column descriptions in metadata. Default: true."),
4916
- includeDataTypes: z.boolean().default(true).describe("Include canonical and raw data types in metadata. Default: true."),
4917
- includeSampleValues: z.boolean().default(false).describe("Include indexing-time snapshot example values in metadata. Use only for illustrative examples, NOT for min/max questions. Default: false."),
4918
- includeStatistics: z.boolean().default(false).describe("Include min/max, cardinality, and null statistics in metadata. Set to true when answering questions about extremes or data distribution shape (but not full distributions, which require querying the data directly). Default: false."),
4919
- includeFreshness: z.boolean().default(false).describe("Include last synced timestamp for columns. Set to true when answering questions about data freshness or when the data was last updated. Default: false.")
4920
- });
4921
4890
  var outputResultSchema3 = z.discriminatedUnion("status", [SuccessVersion4, ErrorVersion4]).optional();
4922
4891
  z.object({
4923
- tool: z.literal(GET_AVAILABLE_COLUMNS_FOR_TABLE),
4892
+ tool: z.literal(GENERATE_VISUALIZATION),
4924
4893
  result: outputResultSchema3
4925
4894
  });
4926
4895
  z.object({
4927
- tool: z.literal(GET_AVAILABLE_COLUMNS_FOR_TABLE),
4896
+ tool: z.literal(GENERATE_VISUALIZATION),
4928
4897
  result: z.discriminatedUnion("status", [RedactedSuccessVersion3, ErrorVersion4]).optional()
4929
4898
  });
4930
- var GET_AVAILABLE_TABLES = "getAvailableTables";
4931
- var SuccessVersion5 = z.object({
4932
- status: z.literal("success"),
4933
- public: z.looseObject({}),
4934
- private: z.object({
4935
- tables: z.array(z.object({
4936
- dataset: z.string(),
4937
- table_name: z.string(),
4938
- description: z.string().nullable()
4939
- }))
4940
- })
4941
- });
4942
- var RedactedSuccessVersion4 = SuccessVersion5.omit({
4943
- private: true
4944
- });
4945
- var ErrorVersion5 = z.object({
4946
- status: z.literal("error"),
4947
- message: z.string()
4948
- });
4949
- var GetAvailableTablesResponse = z.object({
4950
- tool: z.literal(GET_AVAILABLE_TABLES).default(GET_AVAILABLE_TABLES),
4951
- result: z.discriminatedUnion("status", [SuccessVersion5, ErrorVersion5]).optional()
4952
- });
4953
- GetAvailableTablesResponse.extend({
4954
- result: z.discriminatedUnion("status", [
4955
- SuccessVersion5.omit({ private: true }),
4956
- ErrorVersion5
4957
- ]).optional()
4958
- });
4959
- z.object({}).describe("This tool requires no parameters and returns all table names available in the database.");
4960
- var outputResultSchema4 = z.discriminatedUnion("status", [SuccessVersion5, ErrorVersion5]).optional();
4961
- z.object({
4962
- tool: z.literal(GET_AVAILABLE_TABLES),
4963
- result: outputResultSchema4
4964
- });
4965
- z.object({
4966
- tool: z.literal(GET_AVAILABLE_TABLES),
4967
- result: z.discriminatedUnion("status", [RedactedSuccessVersion4, ErrorVersion5]).optional()
4968
- });
4969
- var PAGINATE_DATA_REPORT = "paginateDataReport";
4970
- z.object({
4971
- reportId: z.number().describe("The ID of the report to fetch data from"),
4972
- limit: z.number().optional().default(50).describe("Number of rows to fetch (default 50)"),
4973
- offset: z.number().optional().default(0).describe("Row offset - skip this many rows from the start (default 0)"),
4974
- skipSampleRows: z.boolean().optional().default(true).describe("Skip rows already shown in the data_sample from generateDataReport (default true). Set to false only if you need to re-fetch from the beginning.")
4975
- });
4976
- var SuccessVersion6 = z.object({
4977
- status: z.literal("success"),
4978
- public: z.object({
4979
- totalRows: z.number(),
4980
- fetchedRows: z.number(),
4981
- offset: z.number(),
4982
- hasMore: z.boolean()
4983
- }),
4984
- /* the data is in the private field to avoid sending it to the frontend
4985
- * this is not a security feature as the user has access to the report anyway */
4986
- private: z.object({
4987
- data: z.array(z.record(z.string(), z.unknown()))
4988
- })
4989
- });
4990
- var RedactedSuccessVersion5 = SuccessVersion6.omit({
4991
- private: true
4992
- });
4993
- var ErrorVersion6 = z.object({
4994
- status: z.literal("error"),
4995
- message: z.string()
4996
- });
4997
- var PaginateDataReportResponse = z.object({
4998
- tool: z.literal(PAGINATE_DATA_REPORT).default(PAGINATE_DATA_REPORT),
4999
- result: z.discriminatedUnion("status", [SuccessVersion6, ErrorVersion6]).optional()
5000
- });
5001
- PaginateDataReportResponse.extend({
5002
- result: z.discriminatedUnion("status", [RedactedSuccessVersion5, ErrorVersion6]).optional()
5003
- });
5004
- var outputResultSchema5 = z.discriminatedUnion("status", [SuccessVersion6, ErrorVersion6]).optional();
5005
- z.object({
5006
- tool: z.literal(PAGINATE_DATA_REPORT),
5007
- result: outputResultSchema5
5008
- });
5009
- z.object({
5010
- tool: z.literal(PAGINATE_DATA_REPORT),
5011
- result: z.discriminatedUnion("status", [RedactedSuccessVersion5, ErrorVersion6]).optional()
5012
- });
5013
4899
  var THINK = "think";
5014
- var outputResultSchema6 = z.object({
4900
+ var outputResultSchema4 = z.object({
5015
4901
  status: z.literal("success"),
5016
4902
  public: z.looseObject({}),
5017
4903
  private: z.looseObject({})
5018
4904
  });
5019
4905
  var ThinkResponse = z.object({
5020
4906
  tool: z.literal(THINK).default(THINK),
5021
- result: outputResultSchema6.optional()
4907
+ result: outputResultSchema4.optional()
5022
4908
  });
5023
4909
  ThinkResponse.extend({
5024
- result: outputResultSchema6.omit({ private: true }).optional()
4910
+ result: outputResultSchema4.omit({ private: true }).optional()
5025
4911
  });
5026
4912
  z.object({
5027
4913
  thought: z.string().describe("A thought to think about.")
5028
4914
  });
5029
- var VALUE_BASED_COLUMN_SEARCH = "valueBasedColumnSearch";
5030
- var SuccessVersion7 = z.object({
5031
- status: z.literal("success"),
5032
- public: z.looseObject({}),
5033
- private: z.object({
5034
- message: z.string().optional(),
5035
- columns: z.object({
5036
- name: z.string(),
5037
- data_type: z.string().nullable(),
5038
- description: z.string().nullable(),
5039
- table: z.object({
5040
- table_name: z.string(),
5041
- description: z.string().nullable()
5042
- }),
5043
- matched_values: z.string().array()
5044
- }).array()
5045
- })
5046
- });
5047
- var RedactedSuccessVersion6 = SuccessVersion7.omit({
5048
- private: true
5049
- });
5050
- var ErrorVersion7 = z.object({
5051
- status: z.literal("error"),
5052
- message: z.string()
5053
- });
5054
- var ValueBasedColumnSearchResponse = z.object({
5055
- tool: z.literal(VALUE_BASED_COLUMN_SEARCH).default(VALUE_BASED_COLUMN_SEARCH),
5056
- result: z.discriminatedUnion("status", [SuccessVersion7, ErrorVersion7]).optional()
5057
- });
5058
- ValueBasedColumnSearchResponse.extend({
5059
- result: z.discriminatedUnion("status", [
5060
- SuccessVersion7.omit({ private: true }),
5061
- ErrorVersion7
5062
- ]).optional()
5063
- });
5064
- z.object({
5065
- value: z.string().describe("A literal data value as it would appear in a cell (e.g. 'France', 'PRD-00123', 'Apple iPhone'). Must NOT be a column name or concept.")
5066
- });
5067
- var outputResultSchema7 = z.discriminatedUnion("status", [SuccessVersion7, ErrorVersion7]).optional();
5068
- z.object({
5069
- tool: z.literal(VALUE_BASED_COLUMN_SEARCH),
5070
- result: outputResultSchema7
5071
- });
5072
- z.object({
5073
- tool: z.literal(VALUE_BASED_COLUMN_SEARCH),
5074
- result: z.discriminatedUnion("status", [RedactedSuccessVersion6, ErrorVersion7]).optional()
5075
- });
5076
4915
  var WEB_SEARCH = "webSearch";
5077
4916
  var Source = z.object({
5078
4917
  sourceType: z.literal("url"),
@@ -5080,7 +4919,7 @@ var Source = z.object({
5080
4919
  url: z.string(),
5081
4920
  title: z.string()
5082
4921
  });
5083
- var SuccessVersion8 = z.object({
4922
+ var SuccessVersion5 = z.object({
5084
4923
  status: z.literal("success"),
5085
4924
  public: z.object({
5086
4925
  sources: z.array(Source).optional().describe("Array of source objects.")
@@ -5089,21 +4928,21 @@ var SuccessVersion8 = z.object({
5089
4928
  answer: z.string().optional().describe("The answer from the search results, if successful.")
5090
4929
  })
5091
4930
  });
5092
- var RedactedSuccessVersion7 = SuccessVersion8.omit({
4931
+ var RedactedSuccessVersion4 = SuccessVersion5.omit({
5093
4932
  private: true
5094
4933
  });
5095
- var ErrorVersion8 = z.object({
4934
+ var ErrorVersion5 = z.object({
5096
4935
  status: z.literal("error"),
5097
4936
  message: z.string()
5098
4937
  });
5099
4938
  var WebSearchToolResponse = z.object({
5100
4939
  tool: z.literal("search").default("search"),
5101
- result: z.discriminatedUnion("status", [SuccessVersion8, ErrorVersion8]).optional()
4940
+ result: z.discriminatedUnion("status", [SuccessVersion5, ErrorVersion5]).optional()
5102
4941
  });
5103
4942
  WebSearchToolResponse.extend({
5104
4943
  result: z.discriminatedUnion("status", [
5105
- SuccessVersion8.omit({ private: true }),
5106
- ErrorVersion8
4944
+ SuccessVersion5.omit({ private: true }),
4945
+ ErrorVersion5
5107
4946
  ]).optional()
5108
4947
  });
5109
4948
  z.object({
@@ -5111,13 +4950,13 @@ z.object({
5111
4950
  fromDate: z.iso.date().optional().describe("Only include content published after this date (YYYY-MM-DD). Useful for recent news or time-specific analysis."),
5112
4951
  toDate: z.iso.date().optional().describe("Only include content published before this date (YYYY-MM-DD). Combine with fromDate for a date range.")
5113
4952
  });
5114
- var outputResultSchema8 = z.discriminatedUnion("status", [SuccessVersion8, ErrorVersion8]).optional();
4953
+ var outputResultSchema5 = z.discriminatedUnion("status", [SuccessVersion5, ErrorVersion5]).optional();
5115
4954
  z.object({
5116
- result: outputResultSchema8
4955
+ result: outputResultSchema5
5117
4956
  });
5118
4957
  z.object({
5119
4958
  tool: z.literal("search"),
5120
- result: z.discriminatedUnion("status", [RedactedSuccessVersion7, ErrorVersion8]).optional()
4959
+ result: z.discriminatedUnion("status", [RedactedSuccessVersion4, ErrorVersion5]).optional()
5121
4960
  });
5122
4961
 
5123
- export { ASK_USER_QUESTION, BrowserStorageAdapter, CHAT_ALLOWED_FILE_MEDIA_TYPES, CHAT_FILE_ACCEPT, CHAT_MAX_COMBINED_FILE_SIZE, CHAT_MAX_FILE_COUNT, CHAT_MAX_FILE_SIZE, CHECK_KEY, DirectAuthProvider, ExternalAuthProvider, GENERATE_DATA_REPORT, GENERATE_VISUALIZATION, GET_AVAILABLE_COLUMNS_FOR_TABLE, GET_AVAILABLE_TABLES, MageMetricsChatTransport, MageMetricsClient, MageMetricsEventEmitter, MemoryStorageAdapter, PAGINATE_DATA_REPORT, THINK, TOKEN_STORAGE_KEY, UPLOADED_FILE_REF_PREFIX, VALUE_BASED_COLUMN_SEARCH, WEB_SEARCH, getMessageTextContent, getPublicApiClient, getUploadedFileIdFromUrl, hasOnlyInitialUserMessage, isAskUserQuestionPart, isFrontendV1Visualization, isFrontendV1VisualizationWithData, isFrontendV2Visualization, isFrontendV2VisualizationWithData, toSearchParams, toUploadedFileRefUrl, validateUploadedFiles };
4962
+ export { ASK_USER_QUESTION, BrowserStorageAdapter, CHAT_ALLOWED_FILE_MEDIA_TYPES, CHAT_FILE_ACCEPT, CHAT_MAX_COMBINED_FILE_SIZE, CHAT_MAX_FILE_COUNT, CHAT_MAX_FILE_SIZE, CHECK_KEY, DirectAuthProvider, EXPLORE_SCHEMA, ExternalAuthProvider, GENERATE_DATA_REPORT, GENERATE_VISUALIZATION, MageMetricsChatTransport, MageMetricsClient, MageMetricsEventEmitter, MemoryStorageAdapter, THINK, TOKEN_STORAGE_KEY, UPLOADED_FILE_REF_PREFIX, WEB_SEARCH, getMessageTextContent, getPublicApiClient, getUploadedFileIdFromUrl, hasOnlyInitialUserMessage, isAskUserQuestionPart, isFrontendV1Visualization, isFrontendV1VisualizationWithData, isFrontendV2Visualization, isFrontendV2VisualizationWithData, toSearchParams, toUploadedFileRefUrl, validateUploadedFiles };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magemetrics/core",
3
- "version": "0.14.1",
3
+ "version": "0.15.0",
4
4
  "description": "MageMetrics client library",
5
5
  "files": [
6
6
  "dist/"
@@ -34,12 +34,12 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@noble/hashes": "^2.2.0",
37
- "@supabase/auth-js": "^2.107.0",
38
- "@xyflow/system": "^0.0.76",
39
- "ai": "6.0.175",
40
- "dayjs": "^1.11.20",
37
+ "@supabase/auth-js": "^2.108.1",
38
+ "@xyflow/system": "^0.0.77",
39
+ "ai": "6.0.200",
40
+ "dayjs": "^1.11.21",
41
41
  "openapi-fetch": "^0.17.0",
42
- "type-fest": "^5.6.0",
42
+ "type-fest": "^5.7.0",
43
43
  "zod": "^4.4.3"
44
44
  }
45
45
  }