@magemetrics/core 0.8.2 → 0.9.1
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.d.ts +45 -449
- package/dist/index.js +193 -516
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sha256 } from '@noble/hashes/sha2.js';
|
|
2
|
-
import
|
|
2
|
+
import z6, { z } from 'zod';
|
|
3
3
|
import { GoTrueClient } from '@supabase/auth-js';
|
|
4
4
|
import createApiClient2 from 'openapi-fetch';
|
|
5
5
|
import dayjs from 'dayjs';
|
|
@@ -57,7 +57,7 @@ var addApiKeyHeader = (apiKey) => {
|
|
|
57
57
|
|
|
58
58
|
// package.json
|
|
59
59
|
var package_default = {
|
|
60
|
-
version: "0.
|
|
60
|
+
version: "0.9.1"};
|
|
61
61
|
|
|
62
62
|
// src/core/MageMetricsEventEmitter.ts
|
|
63
63
|
var MageMetricsEventEmitter = class {
|
|
@@ -151,7 +151,7 @@ var hashString = (value) => {
|
|
|
151
151
|
return Array.from(hash).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
152
152
|
};
|
|
153
153
|
|
|
154
|
-
// ../../node_modules/.pnpm/@asteasolutions+zod-to-openapi@8.1.0_zod@4.
|
|
154
|
+
// ../../node_modules/.pnpm/@asteasolutions+zod-to-openapi@8.1.0_zod@4.3.5/node_modules/@asteasolutions/zod-to-openapi/dist/index.mjs
|
|
155
155
|
function __rest(s, e) {
|
|
156
156
|
var t = {};
|
|
157
157
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -469,7 +469,7 @@ function getOpenApiConfiguration(refOrOpenapi, metadataOrOptions, options) {
|
|
|
469
469
|
};
|
|
470
470
|
}
|
|
471
471
|
|
|
472
|
-
// ../../node_modules/.pnpm/hono@4.11.
|
|
472
|
+
// ../../node_modules/.pnpm/hono@4.11.4/node_modules/hono/dist/router/reg-exp-router/node.js
|
|
473
473
|
new Set(".\\+*[^]$()");
|
|
474
474
|
var createRoute = (routeConfig) => {
|
|
475
475
|
const route = {
|
|
@@ -839,131 +839,6 @@ var ExternalAuthProvider = class {
|
|
|
839
839
|
}
|
|
840
840
|
}
|
|
841
841
|
};
|
|
842
|
-
|
|
843
|
-
// ../shared/dist/src/endpoints/admin-console/sqlPreview.routes.js
|
|
844
|
-
var TanStackColumnSchema = z.object({
|
|
845
|
-
id: z.string(),
|
|
846
|
-
accessorKey: z.string(),
|
|
847
|
-
header: z.string(),
|
|
848
|
-
cell: z.any().optional(),
|
|
849
|
-
meta: z.record(z.string(), z.any()).optional()
|
|
850
|
-
});
|
|
851
|
-
var SqlPreviewResponseSchema = z.object({
|
|
852
|
-
columns: z.array(TanStackColumnSchema),
|
|
853
|
-
data: z.array(z.record(z.string(), z.any())),
|
|
854
|
-
metadata: z.object({
|
|
855
|
-
wasSampled: z.boolean(),
|
|
856
|
-
originalCount: z.number(),
|
|
857
|
-
sampledCount: z.number()
|
|
858
|
-
}).optional()
|
|
859
|
-
});
|
|
860
|
-
var SqlPreviewErrorSchema = z.object({
|
|
861
|
-
error: z.string()
|
|
862
|
-
});
|
|
863
|
-
createRoute({
|
|
864
|
-
method: "post",
|
|
865
|
-
path: "/api/v1/admin-console/sql/preview",
|
|
866
|
-
operationId: "sqlPreview",
|
|
867
|
-
request: {
|
|
868
|
-
body: {
|
|
869
|
-
content: {
|
|
870
|
-
"application/json": {
|
|
871
|
-
schema: z.object({
|
|
872
|
-
sql: z.string().min(1, "SQL query is required")
|
|
873
|
-
})
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
},
|
|
878
|
-
responses: {
|
|
879
|
-
200: {
|
|
880
|
-
description: "SQL query executed successfully",
|
|
881
|
-
content: {
|
|
882
|
-
"application/json": {
|
|
883
|
-
schema: SqlPreviewResponseSchema
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
},
|
|
887
|
-
400: {
|
|
888
|
-
description: "Invalid SQL query or request",
|
|
889
|
-
content: {
|
|
890
|
-
"application/json": {
|
|
891
|
-
schema: SqlPreviewErrorSchema
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
},
|
|
895
|
-
500: {
|
|
896
|
-
description: "Internal server error",
|
|
897
|
-
content: {
|
|
898
|
-
"application/json": {
|
|
899
|
-
schema: SqlPreviewErrorSchema
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
});
|
|
905
|
-
|
|
906
|
-
// ../shared/dist/src/endpoints/utils.js
|
|
907
|
-
var limitQueryParams = z.string().pipe(z.coerce.number()).optional().openapi({
|
|
908
|
-
param: {
|
|
909
|
-
required: false
|
|
910
|
-
},
|
|
911
|
-
type: "integer"
|
|
912
|
-
});
|
|
913
|
-
var orderQueryParams = z.string().transform((str) => {
|
|
914
|
-
if (!str)
|
|
915
|
-
return [];
|
|
916
|
-
return str.split(",").map((part) => {
|
|
917
|
-
const [column, direction = "ASC"] = part.split(":");
|
|
918
|
-
return {
|
|
919
|
-
column,
|
|
920
|
-
direction: direction.toUpperCase()
|
|
921
|
-
};
|
|
922
|
-
});
|
|
923
|
-
}).pipe(z.array(z.object({
|
|
924
|
-
column: z.string(),
|
|
925
|
-
direction: z.enum(["ASC", "DESC"])
|
|
926
|
-
}))).optional().openapi({
|
|
927
|
-
param: {
|
|
928
|
-
required: false,
|
|
929
|
-
example: "name:asc,date:desc"
|
|
930
|
-
},
|
|
931
|
-
type: "string"
|
|
932
|
-
});
|
|
933
|
-
var cursorParams = z.string().pipe(z.coerce.number()).optional().openapi({
|
|
934
|
-
param: {
|
|
935
|
-
required: false
|
|
936
|
-
},
|
|
937
|
-
type: "number"
|
|
938
|
-
});
|
|
939
|
-
var filterQueryParams = z.string().transform((str) => {
|
|
940
|
-
if (!str)
|
|
941
|
-
return [];
|
|
942
|
-
return str.split(",").map((part) => {
|
|
943
|
-
const [column, value = ""] = part.split(":").map(decodeURIComponent);
|
|
944
|
-
return { column, value };
|
|
945
|
-
});
|
|
946
|
-
}).pipe(z.array(z.object({
|
|
947
|
-
column: z.string(),
|
|
948
|
-
value: z.string()
|
|
949
|
-
}))).optional().openapi({
|
|
950
|
-
param: {
|
|
951
|
-
required: false,
|
|
952
|
-
example: "status:active,name:John%20Doe"
|
|
953
|
-
},
|
|
954
|
-
type: "string"
|
|
955
|
-
});
|
|
956
|
-
var columnsQueryParams = z.string().transform((str) => {
|
|
957
|
-
if (!str)
|
|
958
|
-
return [];
|
|
959
|
-
return str.split(",");
|
|
960
|
-
}).optional().openapi({
|
|
961
|
-
param: {
|
|
962
|
-
required: false,
|
|
963
|
-
example: "name,date"
|
|
964
|
-
},
|
|
965
|
-
type: "string"
|
|
966
|
-
});
|
|
967
842
|
var SupabaseUserHeaderSchema = z.object({
|
|
968
843
|
[HEADER_SP_TOKEN]: z.string()
|
|
969
844
|
});
|
|
@@ -1115,15 +990,26 @@ var ReportColumnsSchema = z.object({
|
|
|
1115
990
|
name: z.string(),
|
|
1116
991
|
data_type: z.string()
|
|
1117
992
|
}).array();
|
|
993
|
+
var CanonicalDataTypeSchema = z.enum([
|
|
994
|
+
"numeric",
|
|
995
|
+
"boolean",
|
|
996
|
+
"datetime",
|
|
997
|
+
"text",
|
|
998
|
+
"array",
|
|
999
|
+
"json",
|
|
1000
|
+
"other"
|
|
1001
|
+
]);
|
|
1118
1002
|
z.object({
|
|
1119
1003
|
render_type: z.string().nullish(),
|
|
1120
|
-
unit: z.string().nullish()
|
|
1004
|
+
unit: z.string().nullish(),
|
|
1005
|
+
canonical_data_type: CanonicalDataTypeSchema.nullish()
|
|
1121
1006
|
});
|
|
1122
1007
|
var FrontendReportColumnsSchema = z.object({
|
|
1123
1008
|
...ReportColumnsSchema.element.shape,
|
|
1124
1009
|
dataType: z.string(),
|
|
1125
1010
|
renderType: z.string().optional(),
|
|
1126
|
-
unit: z.string().optional()
|
|
1011
|
+
unit: z.string().optional(),
|
|
1012
|
+
canonicalDataType: CanonicalDataTypeSchema.optional()
|
|
1127
1013
|
}).array().openapi("ReportColumns");
|
|
1128
1014
|
z.object({
|
|
1129
1015
|
goal: z.string(),
|
|
@@ -1150,6 +1036,155 @@ var FrontendReportExplainabilitySchema = ReportExplainabilitySchema.omit({
|
|
|
1150
1036
|
output_dataset: z.string().optional(),
|
|
1151
1037
|
sql: z.string().optional()
|
|
1152
1038
|
});
|
|
1039
|
+
var FilterOperatorSchema = z.enum([
|
|
1040
|
+
// Text operators
|
|
1041
|
+
"eq",
|
|
1042
|
+
"neq",
|
|
1043
|
+
"contains",
|
|
1044
|
+
"startsWith",
|
|
1045
|
+
"endsWith",
|
|
1046
|
+
"regex",
|
|
1047
|
+
// Numeric operators
|
|
1048
|
+
"gt",
|
|
1049
|
+
"lt",
|
|
1050
|
+
"gte",
|
|
1051
|
+
"lte",
|
|
1052
|
+
"between"
|
|
1053
|
+
]);
|
|
1054
|
+
z.object({
|
|
1055
|
+
operator: FilterOperatorSchema,
|
|
1056
|
+
value: z.union([
|
|
1057
|
+
z.string(),
|
|
1058
|
+
z.number(),
|
|
1059
|
+
z.boolean(),
|
|
1060
|
+
z.tuple([z.number(), z.number()])
|
|
1061
|
+
// for "between" operator
|
|
1062
|
+
])
|
|
1063
|
+
});
|
|
1064
|
+
var DataTableSchema = z.object({
|
|
1065
|
+
id: z.number(),
|
|
1066
|
+
dataset: z.string(),
|
|
1067
|
+
table_name: z.string(),
|
|
1068
|
+
description: z.string().nullable(),
|
|
1069
|
+
primary_key_names: z.string().array(),
|
|
1070
|
+
row_count: z.number().nullable(),
|
|
1071
|
+
created_at: z.string(),
|
|
1072
|
+
updated_at: z.string(),
|
|
1073
|
+
source_id: z.number(),
|
|
1074
|
+
parent_table_id: z.number().nullable()
|
|
1075
|
+
});
|
|
1076
|
+
var DataTableColumnSchema = z.object({
|
|
1077
|
+
id: z.number(),
|
|
1078
|
+
name: z.string(),
|
|
1079
|
+
data_type: z.string().nullable(),
|
|
1080
|
+
description: z.string().nullable(),
|
|
1081
|
+
null_percentage: z.number().nullable(),
|
|
1082
|
+
unique_values: z.number().nullable(),
|
|
1083
|
+
sample_values: z.array(z.unknown()).nullable()
|
|
1084
|
+
});
|
|
1085
|
+
DataTableSchema.extend({
|
|
1086
|
+
columns: z.array(DataTableColumnSchema)
|
|
1087
|
+
});
|
|
1088
|
+
var toSearchParams = ({ cursor, filters, sorting, limit }) => {
|
|
1089
|
+
const params = {};
|
|
1090
|
+
if (limit !== void 0) {
|
|
1091
|
+
params.limit = limit;
|
|
1092
|
+
}
|
|
1093
|
+
if (cursor !== void 0) {
|
|
1094
|
+
params.cursor = cursor;
|
|
1095
|
+
}
|
|
1096
|
+
const sortingParams = sorting?.map((c) => `${c.id}:${c.desc ? "DESC" : "ASC"}`).join(",");
|
|
1097
|
+
if (sortingParams) {
|
|
1098
|
+
params.order = sortingParams;
|
|
1099
|
+
}
|
|
1100
|
+
if (filters) {
|
|
1101
|
+
const filterParams = Object.entries(filters).flatMap(([column, filter]) => {
|
|
1102
|
+
const { operator, value } = filter;
|
|
1103
|
+
if (operator === "between" && Array.isArray(value)) {
|
|
1104
|
+
return `${column}:${operator}:${encodeURIComponent(`${value[0]},${value[1]}`)}`;
|
|
1105
|
+
}
|
|
1106
|
+
if (typeof value === "string" || typeof value === "boolean" || typeof value === "number") {
|
|
1107
|
+
return `${column}:${operator}:${encodeURIComponent(value)}`;
|
|
1108
|
+
}
|
|
1109
|
+
return [];
|
|
1110
|
+
}).join(",");
|
|
1111
|
+
if (filterParams.length > 0) {
|
|
1112
|
+
params.filter = filterParams;
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
return params;
|
|
1116
|
+
};
|
|
1117
|
+
|
|
1118
|
+
// ../shared/dist/src/endpoints/utils.js
|
|
1119
|
+
var limitQueryParams = z.string().pipe(z.coerce.number()).optional().openapi({
|
|
1120
|
+
param: {
|
|
1121
|
+
required: false
|
|
1122
|
+
},
|
|
1123
|
+
type: "integer"
|
|
1124
|
+
});
|
|
1125
|
+
var orderQueryParams = z.string().transform((str) => {
|
|
1126
|
+
if (!str)
|
|
1127
|
+
return [];
|
|
1128
|
+
return str.split(",").map((part) => {
|
|
1129
|
+
const [column, direction = "ASC"] = part.split(":");
|
|
1130
|
+
return {
|
|
1131
|
+
column,
|
|
1132
|
+
direction: direction.toUpperCase()
|
|
1133
|
+
};
|
|
1134
|
+
});
|
|
1135
|
+
}).pipe(z.array(z.object({
|
|
1136
|
+
column: z.string(),
|
|
1137
|
+
direction: z.enum(["ASC", "DESC"])
|
|
1138
|
+
}))).optional().openapi({
|
|
1139
|
+
param: {
|
|
1140
|
+
required: false,
|
|
1141
|
+
example: "name:asc,date:desc"
|
|
1142
|
+
},
|
|
1143
|
+
type: "string"
|
|
1144
|
+
});
|
|
1145
|
+
var cursorParams = z.string().pipe(z.coerce.number()).optional().openapi({
|
|
1146
|
+
param: {
|
|
1147
|
+
required: false
|
|
1148
|
+
},
|
|
1149
|
+
type: "number"
|
|
1150
|
+
});
|
|
1151
|
+
var filterQueryParams = z.string().transform((str) => {
|
|
1152
|
+
if (!str)
|
|
1153
|
+
return [];
|
|
1154
|
+
return str.split(",").map((part) => {
|
|
1155
|
+
const parts = part.split(":");
|
|
1156
|
+
const column = decodeURIComponent(parts[0] ?? "");
|
|
1157
|
+
const operatorRaw = parts[1] ?? "";
|
|
1158
|
+
const isNewFormat = parts.length >= 3 && FilterOperatorSchema.safeParse(operatorRaw).success;
|
|
1159
|
+
if (isNewFormat) {
|
|
1160
|
+
const value2 = decodeURIComponent(parts.slice(2).join(":"));
|
|
1161
|
+
return { column, operator: operatorRaw, value: value2 };
|
|
1162
|
+
}
|
|
1163
|
+
const value = decodeURIComponent(parts.slice(1).join(":"));
|
|
1164
|
+
return { column, operator: "eq", value };
|
|
1165
|
+
});
|
|
1166
|
+
}).pipe(z.array(z.object({
|
|
1167
|
+
column: z.string(),
|
|
1168
|
+
operator: FilterOperatorSchema,
|
|
1169
|
+
value: z.string()
|
|
1170
|
+
}))).optional().openapi({
|
|
1171
|
+
param: {
|
|
1172
|
+
required: false,
|
|
1173
|
+
example: "status:eq:active,name:contains:John%20Doe"
|
|
1174
|
+
},
|
|
1175
|
+
type: "string"
|
|
1176
|
+
});
|
|
1177
|
+
var columnsQueryParams = z.string().transform((str) => {
|
|
1178
|
+
if (!str)
|
|
1179
|
+
return [];
|
|
1180
|
+
return str.split(",");
|
|
1181
|
+
}).optional().openapi({
|
|
1182
|
+
param: {
|
|
1183
|
+
required: false,
|
|
1184
|
+
example: "name,date"
|
|
1185
|
+
},
|
|
1186
|
+
type: "string"
|
|
1187
|
+
});
|
|
1153
1188
|
|
|
1154
1189
|
// ../shared/dist/src/endpoints/companion/flows.routes.js
|
|
1155
1190
|
var FlowIdParam = z.object({ flowId: z.uuid() }).openapi("FlowId", { type: "string" });
|
|
@@ -1852,295 +1887,6 @@ var CreateFlow = createRoute({
|
|
|
1852
1887
|
}
|
|
1853
1888
|
});
|
|
1854
1889
|
|
|
1855
|
-
// ../shared/dist/src/endpoints/admin-console/contextualInsights.routes.js
|
|
1856
|
-
var ExtractInsightResponseSchema = z.object({
|
|
1857
|
-
type: z.literal("text"),
|
|
1858
|
-
insight: z.string()
|
|
1859
|
-
}).or(z.object({
|
|
1860
|
-
type: z.literal("missing")
|
|
1861
|
-
}));
|
|
1862
|
-
createRoute({
|
|
1863
|
-
method: "post",
|
|
1864
|
-
path: "/api/v1/admin-console/contextual-insights/generate-template",
|
|
1865
|
-
operationId: "generateInsightTemplate",
|
|
1866
|
-
request: {
|
|
1867
|
-
body: {
|
|
1868
|
-
content: {
|
|
1869
|
-
"application/json": {
|
|
1870
|
-
schema: z.object({
|
|
1871
|
-
request: z.string(),
|
|
1872
|
-
insight_type: z.string(),
|
|
1873
|
-
additional_context: z.string().optional()
|
|
1874
|
-
})
|
|
1875
|
-
}
|
|
1876
|
-
}
|
|
1877
|
-
}
|
|
1878
|
-
},
|
|
1879
|
-
responses: {
|
|
1880
|
-
200: {
|
|
1881
|
-
description: "Insight template generated successfully",
|
|
1882
|
-
content: {
|
|
1883
|
-
"application/json": {
|
|
1884
|
-
schema: z.object({
|
|
1885
|
-
expanded_request: z.string()
|
|
1886
|
-
})
|
|
1887
|
-
}
|
|
1888
|
-
}
|
|
1889
|
-
},
|
|
1890
|
-
500: {
|
|
1891
|
-
description: "Something wrong happened",
|
|
1892
|
-
content: {
|
|
1893
|
-
"application/json": {
|
|
1894
|
-
schema: z.object({
|
|
1895
|
-
error: z.string()
|
|
1896
|
-
})
|
|
1897
|
-
}
|
|
1898
|
-
}
|
|
1899
|
-
}
|
|
1900
|
-
}
|
|
1901
|
-
});
|
|
1902
|
-
createRoute({
|
|
1903
|
-
method: "get",
|
|
1904
|
-
path: "/api/v1/admin-console/contextual-insights/preview/{report_id}/data",
|
|
1905
|
-
operationId: "getContextualInsightPreviewData",
|
|
1906
|
-
request: {
|
|
1907
|
-
params: ReportIdParam,
|
|
1908
|
-
query: z.object({
|
|
1909
|
-
limit: limitQueryParams,
|
|
1910
|
-
order: orderQueryParams,
|
|
1911
|
-
cursor: cursorParams,
|
|
1912
|
-
filter: filterQueryParams
|
|
1913
|
-
})
|
|
1914
|
-
},
|
|
1915
|
-
responses: {
|
|
1916
|
-
200: {
|
|
1917
|
-
description: "The preview data for the contextual insight",
|
|
1918
|
-
content: {
|
|
1919
|
-
"application/json": {
|
|
1920
|
-
schema: SqlPreviewResponseSchema
|
|
1921
|
-
}
|
|
1922
|
-
}
|
|
1923
|
-
},
|
|
1924
|
-
404: {
|
|
1925
|
-
content: {
|
|
1926
|
-
"application/json": {
|
|
1927
|
-
schema: z.object({ error: z.string() })
|
|
1928
|
-
}
|
|
1929
|
-
},
|
|
1930
|
-
description: "Unable to retrieve flow data with this id"
|
|
1931
|
-
},
|
|
1932
|
-
500: {
|
|
1933
|
-
description: "Something wrong happened",
|
|
1934
|
-
content: {
|
|
1935
|
-
"application/json": {
|
|
1936
|
-
schema: z.object({
|
|
1937
|
-
error: z.string()
|
|
1938
|
-
})
|
|
1939
|
-
}
|
|
1940
|
-
}
|
|
1941
|
-
}
|
|
1942
|
-
}
|
|
1943
|
-
});
|
|
1944
|
-
createRoute({
|
|
1945
|
-
method: "get",
|
|
1946
|
-
path: "/api/v1/admin-console/contextual-insights/preview/{report_id}/sample-values",
|
|
1947
|
-
operationId: "getContextualInsightColumnSampleValues",
|
|
1948
|
-
request: {
|
|
1949
|
-
params: ReportIdParam,
|
|
1950
|
-
query: z.object({
|
|
1951
|
-
column_name: z.string().openapi({
|
|
1952
|
-
param: {
|
|
1953
|
-
required: true
|
|
1954
|
-
},
|
|
1955
|
-
type: "string",
|
|
1956
|
-
description: "The column name to get sample values for"
|
|
1957
|
-
})
|
|
1958
|
-
})
|
|
1959
|
-
},
|
|
1960
|
-
responses: {
|
|
1961
|
-
200: {
|
|
1962
|
-
description: "Sample values for the specified column",
|
|
1963
|
-
content: {
|
|
1964
|
-
"application/json": {
|
|
1965
|
-
schema: z.object({
|
|
1966
|
-
options: z.array(z.unknown())
|
|
1967
|
-
})
|
|
1968
|
-
}
|
|
1969
|
-
}
|
|
1970
|
-
},
|
|
1971
|
-
404: {
|
|
1972
|
-
content: {
|
|
1973
|
-
"application/json": {
|
|
1974
|
-
schema: z.object({ error: z.string() })
|
|
1975
|
-
}
|
|
1976
|
-
},
|
|
1977
|
-
description: "Unable to retrieve flow data with this id"
|
|
1978
|
-
},
|
|
1979
|
-
500: {
|
|
1980
|
-
description: "Something wrong happened",
|
|
1981
|
-
content: {
|
|
1982
|
-
"application/json": {
|
|
1983
|
-
schema: z.object({
|
|
1984
|
-
error: z.string()
|
|
1985
|
-
})
|
|
1986
|
-
}
|
|
1987
|
-
}
|
|
1988
|
-
}
|
|
1989
|
-
}
|
|
1990
|
-
});
|
|
1991
|
-
var GenerateInsight = createRoute({
|
|
1992
|
-
method: "post",
|
|
1993
|
-
path: "/api/v1/contextual-insights/generate-insight",
|
|
1994
|
-
operationId: "generateInsight",
|
|
1995
|
-
request: {
|
|
1996
|
-
body: {
|
|
1997
|
-
content: {
|
|
1998
|
-
"application/json": {
|
|
1999
|
-
schema: z.object({
|
|
2000
|
-
selected_filter_value: z.string(),
|
|
2001
|
-
custom_id: z.string()
|
|
2002
|
-
})
|
|
2003
|
-
}
|
|
2004
|
-
}
|
|
2005
|
-
}
|
|
2006
|
-
},
|
|
2007
|
-
responses: {
|
|
2008
|
-
200: {
|
|
2009
|
-
description: "Insight generated successfully",
|
|
2010
|
-
content: {
|
|
2011
|
-
"application/json": {
|
|
2012
|
-
schema: ExtractInsightResponseSchema
|
|
2013
|
-
}
|
|
2014
|
-
}
|
|
2015
|
-
},
|
|
2016
|
-
404: {
|
|
2017
|
-
description: "Insight not found",
|
|
2018
|
-
content: {
|
|
2019
|
-
"application/json": {
|
|
2020
|
-
schema: z.object({
|
|
2021
|
-
error: z.string()
|
|
2022
|
-
})
|
|
2023
|
-
}
|
|
2024
|
-
}
|
|
2025
|
-
},
|
|
2026
|
-
400: {
|
|
2027
|
-
description: "Invalid request",
|
|
2028
|
-
content: {
|
|
2029
|
-
"application/json": {
|
|
2030
|
-
schema: z.object({
|
|
2031
|
-
error: z.string()
|
|
2032
|
-
})
|
|
2033
|
-
}
|
|
2034
|
-
}
|
|
2035
|
-
},
|
|
2036
|
-
500: {
|
|
2037
|
-
description: "Something wrong happened",
|
|
2038
|
-
content: {
|
|
2039
|
-
"application/json": {
|
|
2040
|
-
schema: z.object({
|
|
2041
|
-
error: z.string()
|
|
2042
|
-
})
|
|
2043
|
-
}
|
|
2044
|
-
}
|
|
2045
|
-
}
|
|
2046
|
-
}
|
|
2047
|
-
});
|
|
2048
|
-
createRoute({
|
|
2049
|
-
method: "post",
|
|
2050
|
-
path: "/api/v1/admin-console/contextual-insights/extract-insight",
|
|
2051
|
-
operationId: "extractInsight",
|
|
2052
|
-
request: {
|
|
2053
|
-
body: {
|
|
2054
|
-
content: {
|
|
2055
|
-
"application/json": {
|
|
2056
|
-
schema: z.object({
|
|
2057
|
-
flow_id: z.string(),
|
|
2058
|
-
report_id: z.number(),
|
|
2059
|
-
topic: z.string(),
|
|
2060
|
-
expanded_request: z.string(),
|
|
2061
|
-
insight_type: z.string(),
|
|
2062
|
-
selected_filter: z.string(),
|
|
2063
|
-
selected_filter_value: z.string(),
|
|
2064
|
-
additional_context: z.string().optional()
|
|
2065
|
-
})
|
|
2066
|
-
}
|
|
2067
|
-
}
|
|
2068
|
-
}
|
|
2069
|
-
},
|
|
2070
|
-
responses: {
|
|
2071
|
-
200: {
|
|
2072
|
-
description: "Insight extracted successfully",
|
|
2073
|
-
content: {
|
|
2074
|
-
"application/json": {
|
|
2075
|
-
schema: ExtractInsightResponseSchema
|
|
2076
|
-
}
|
|
2077
|
-
}
|
|
2078
|
-
},
|
|
2079
|
-
500: {
|
|
2080
|
-
description: "Something wrong happened",
|
|
2081
|
-
content: {
|
|
2082
|
-
"application/json": {
|
|
2083
|
-
schema: z.object({
|
|
2084
|
-
error: z.string()
|
|
2085
|
-
})
|
|
2086
|
-
}
|
|
2087
|
-
}
|
|
2088
|
-
}
|
|
2089
|
-
}
|
|
2090
|
-
});
|
|
2091
|
-
createRoute({
|
|
2092
|
-
method: "post",
|
|
2093
|
-
path: "/api/v1/admin-console/contextual-insights/suggest-filter-column",
|
|
2094
|
-
operationId: "suggestFilterColumn",
|
|
2095
|
-
request: {
|
|
2096
|
-
body: {
|
|
2097
|
-
content: {
|
|
2098
|
-
"application/json": {
|
|
2099
|
-
schema: z.object({
|
|
2100
|
-
report_id: z.number(),
|
|
2101
|
-
request: z.string(),
|
|
2102
|
-
insight_type: z.string(),
|
|
2103
|
-
additional_context: z.string().optional()
|
|
2104
|
-
})
|
|
2105
|
-
}
|
|
2106
|
-
}
|
|
2107
|
-
}
|
|
2108
|
-
},
|
|
2109
|
-
responses: {
|
|
2110
|
-
200: {
|
|
2111
|
-
description: "Filter column suggestion generated successfully",
|
|
2112
|
-
content: {
|
|
2113
|
-
"application/json": {
|
|
2114
|
-
schema: z.object({
|
|
2115
|
-
recommended_column: z.string(),
|
|
2116
|
-
reasoning: z.string()
|
|
2117
|
-
})
|
|
2118
|
-
}
|
|
2119
|
-
}
|
|
2120
|
-
},
|
|
2121
|
-
404: {
|
|
2122
|
-
description: "Report not found",
|
|
2123
|
-
content: {
|
|
2124
|
-
"application/json": {
|
|
2125
|
-
schema: z.object({
|
|
2126
|
-
error: z.string()
|
|
2127
|
-
})
|
|
2128
|
-
}
|
|
2129
|
-
}
|
|
2130
|
-
},
|
|
2131
|
-
500: {
|
|
2132
|
-
description: "Something wrong happened",
|
|
2133
|
-
content: {
|
|
2134
|
-
"application/json": {
|
|
2135
|
-
schema: z.object({
|
|
2136
|
-
error: z.string()
|
|
2137
|
-
})
|
|
2138
|
-
}
|
|
2139
|
-
}
|
|
2140
|
-
}
|
|
2141
|
-
}
|
|
2142
|
-
});
|
|
2143
|
-
|
|
2144
1890
|
// ../shared/dist/src/endpoints/companion/speech.routes.js
|
|
2145
1891
|
var SpeechTokenResponseSchema = z.object({
|
|
2146
1892
|
token: z.string().describe("Temporary AssemblyAI streaming token"),
|
|
@@ -2174,20 +1920,20 @@ var CreateSpeechToken = createRoute({
|
|
|
2174
1920
|
}
|
|
2175
1921
|
}
|
|
2176
1922
|
});
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
status:
|
|
2180
|
-
error:
|
|
1923
|
+
z6.discriminatedUnion("status", [
|
|
1924
|
+
z6.object({
|
|
1925
|
+
status: z6.literal("error"),
|
|
1926
|
+
error: z6.string()
|
|
2181
1927
|
}),
|
|
2182
|
-
|
|
2183
|
-
status:
|
|
2184
|
-
flowId:
|
|
1928
|
+
z6.object({
|
|
1929
|
+
status: z6.literal("success"),
|
|
1930
|
+
flowId: z6.string()
|
|
2185
1931
|
})
|
|
2186
1932
|
]);
|
|
2187
|
-
var TriggerFlowBody =
|
|
2188
|
-
triggerId:
|
|
2189
|
-
variables:
|
|
2190
|
-
applicationName:
|
|
1933
|
+
var TriggerFlowBody = z6.object({
|
|
1934
|
+
triggerId: z6.string(),
|
|
1935
|
+
variables: z6.record(z6.string(), z6.string()),
|
|
1936
|
+
applicationName: z6.string().optional()
|
|
2191
1937
|
});
|
|
2192
1938
|
var TriggerFlow = createRoute({
|
|
2193
1939
|
method: "post",
|
|
@@ -2210,9 +1956,9 @@ var TriggerFlow = createRoute({
|
|
|
2210
1956
|
description: "Flow id",
|
|
2211
1957
|
content: {
|
|
2212
1958
|
"application/json": {
|
|
2213
|
-
schema:
|
|
2214
|
-
status:
|
|
2215
|
-
flowId:
|
|
1959
|
+
schema: z6.object({
|
|
1960
|
+
status: z6.literal("success"),
|
|
1961
|
+
flowId: z6.string()
|
|
2216
1962
|
})
|
|
2217
1963
|
}
|
|
2218
1964
|
}
|
|
@@ -2220,8 +1966,8 @@ var TriggerFlow = createRoute({
|
|
|
2220
1966
|
400: {
|
|
2221
1967
|
content: {
|
|
2222
1968
|
"application/json": {
|
|
2223
|
-
schema:
|
|
2224
|
-
error:
|
|
1969
|
+
schema: z6.object({
|
|
1970
|
+
error: z6.string()
|
|
2225
1971
|
})
|
|
2226
1972
|
}
|
|
2227
1973
|
},
|
|
@@ -2230,7 +1976,7 @@ var TriggerFlow = createRoute({
|
|
|
2230
1976
|
404: {
|
|
2231
1977
|
content: {
|
|
2232
1978
|
"application/json": {
|
|
2233
|
-
schema:
|
|
1979
|
+
schema: z6.object({ error: z6.string() })
|
|
2234
1980
|
}
|
|
2235
1981
|
},
|
|
2236
1982
|
description: "Unable to retrieve trigger with this id"
|
|
@@ -2239,8 +1985,8 @@ var TriggerFlow = createRoute({
|
|
|
2239
1985
|
description: "Something wrong happened",
|
|
2240
1986
|
content: {
|
|
2241
1987
|
"application/json": {
|
|
2242
|
-
schema:
|
|
2243
|
-
error:
|
|
1988
|
+
schema: z6.object({
|
|
1989
|
+
error: z6.string()
|
|
2244
1990
|
})
|
|
2245
1991
|
}
|
|
2246
1992
|
}
|
|
@@ -2270,9 +2016,9 @@ createRoute({
|
|
|
2270
2016
|
description: "Flow id",
|
|
2271
2017
|
content: {
|
|
2272
2018
|
"application/json": {
|
|
2273
|
-
schema:
|
|
2274
|
-
status:
|
|
2275
|
-
flowId:
|
|
2019
|
+
schema: z6.object({
|
|
2020
|
+
status: z6.literal("success"),
|
|
2021
|
+
flowId: z6.string()
|
|
2276
2022
|
})
|
|
2277
2023
|
}
|
|
2278
2024
|
}
|
|
@@ -2280,8 +2026,8 @@ createRoute({
|
|
|
2280
2026
|
400: {
|
|
2281
2027
|
content: {
|
|
2282
2028
|
"application/json": {
|
|
2283
|
-
schema:
|
|
2284
|
-
error:
|
|
2029
|
+
schema: z6.object({
|
|
2030
|
+
error: z6.string()
|
|
2285
2031
|
})
|
|
2286
2032
|
}
|
|
2287
2033
|
},
|
|
@@ -2290,7 +2036,7 @@ createRoute({
|
|
|
2290
2036
|
404: {
|
|
2291
2037
|
content: {
|
|
2292
2038
|
"application/json": {
|
|
2293
|
-
schema:
|
|
2039
|
+
schema: z6.object({ error: z6.string() })
|
|
2294
2040
|
}
|
|
2295
2041
|
},
|
|
2296
2042
|
description: "Unable to retrieve trigger with this id"
|
|
@@ -2299,8 +2045,8 @@ createRoute({
|
|
|
2299
2045
|
description: "Something wrong happened",
|
|
2300
2046
|
content: {
|
|
2301
2047
|
"application/json": {
|
|
2302
|
-
schema:
|
|
2303
|
-
error:
|
|
2048
|
+
schema: z6.object({
|
|
2049
|
+
error: z6.string()
|
|
2304
2050
|
})
|
|
2305
2051
|
}
|
|
2306
2052
|
}
|
|
@@ -3163,54 +2909,6 @@ var ListVisualizationsForFlow = createRoute({
|
|
|
3163
2909
|
}
|
|
3164
2910
|
}
|
|
3165
2911
|
});
|
|
3166
|
-
var DataTableSchema = z.object({
|
|
3167
|
-
id: z.number(),
|
|
3168
|
-
dataset: z.string(),
|
|
3169
|
-
table_name: z.string(),
|
|
3170
|
-
description: z.string().nullable(),
|
|
3171
|
-
primary_key_names: z.string().array(),
|
|
3172
|
-
row_count: z.number().nullable(),
|
|
3173
|
-
created_at: z.string(),
|
|
3174
|
-
updated_at: z.string(),
|
|
3175
|
-
source_id: z.number(),
|
|
3176
|
-
parent_table_id: z.number().nullable()
|
|
3177
|
-
});
|
|
3178
|
-
var DataTableColumnSchema = z.object({
|
|
3179
|
-
id: z.number(),
|
|
3180
|
-
name: z.string(),
|
|
3181
|
-
data_type: z.string().nullable(),
|
|
3182
|
-
description: z.string().nullable(),
|
|
3183
|
-
null_percentage: z.number().nullable(),
|
|
3184
|
-
unique_values: z.number().nullable(),
|
|
3185
|
-
sample_values: z.array(z.unknown()).nullable()
|
|
3186
|
-
});
|
|
3187
|
-
DataTableSchema.extend({
|
|
3188
|
-
columns: z.array(DataTableColumnSchema)
|
|
3189
|
-
});
|
|
3190
|
-
var toSearchParams = ({ cursor, filters, sorting, limit }) => {
|
|
3191
|
-
const params = {};
|
|
3192
|
-
if (limit !== void 0) {
|
|
3193
|
-
params.limit = limit;
|
|
3194
|
-
}
|
|
3195
|
-
if (cursor !== void 0) {
|
|
3196
|
-
params.cursor = cursor;
|
|
3197
|
-
}
|
|
3198
|
-
const sortingParams = sorting?.map((c) => `${c.id}:${c.desc ? "DESC" : "ASC"}`).join(",");
|
|
3199
|
-
if (sortingParams) {
|
|
3200
|
-
params.order = sortingParams;
|
|
3201
|
-
}
|
|
3202
|
-
if (filters) {
|
|
3203
|
-
const filterParams = Object.entries(filters).flatMap(([key, value]) => {
|
|
3204
|
-
if (!(typeof value === "string" || typeof value === "boolean" || typeof value === "number"))
|
|
3205
|
-
return [];
|
|
3206
|
-
return `${key}:${encodeURIComponent(value)}`;
|
|
3207
|
-
}).join(",");
|
|
3208
|
-
if (filterParams.length > 0) {
|
|
3209
|
-
params.filter = filterParams;
|
|
3210
|
-
}
|
|
3211
|
-
}
|
|
3212
|
-
return params;
|
|
3213
|
-
};
|
|
3214
2912
|
var isToolResultMessage = (message) => {
|
|
3215
2913
|
if (message.role !== "assistant") {
|
|
3216
2914
|
return false;
|
|
@@ -3624,27 +3322,6 @@ var MageMetricsClient = class {
|
|
|
3624
3322
|
const filename = contentDisposition ? contentDisposition.split("filename=")[1]?.replace(/"/g, "") || `mm-export-${reportId}.csv` : `mm-export-${reportId}.csv`;
|
|
3625
3323
|
return { filename, data };
|
|
3626
3324
|
},
|
|
3627
|
-
generateContextualInsight: async (payload) => {
|
|
3628
|
-
await this.waitForAuth();
|
|
3629
|
-
const { data, error, response } = await this.internalApiClient.POST(
|
|
3630
|
-
GenerateInsight.path,
|
|
3631
|
-
{
|
|
3632
|
-
body: {
|
|
3633
|
-
selected_filter_value: payload.selectedFilterValue,
|
|
3634
|
-
custom_id: payload.customId
|
|
3635
|
-
}
|
|
3636
|
-
}
|
|
3637
|
-
);
|
|
3638
|
-
if (error) {
|
|
3639
|
-
throw new ApiError(error.error, response, {
|
|
3640
|
-
status: response.status,
|
|
3641
|
-
statusText: response.statusText,
|
|
3642
|
-
url: response.url,
|
|
3643
|
-
method: "POST"
|
|
3644
|
-
});
|
|
3645
|
-
}
|
|
3646
|
-
return data;
|
|
3647
|
-
},
|
|
3648
3325
|
getChatTransport: (flowId, options) => {
|
|
3649
3326
|
return new MageMetricsChatTransport(this.config.apiUrl, flowId, {
|
|
3650
3327
|
...options,
|