@magemetrics/core 0.9.0 → 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 -4
- package/dist/index.js +132 -82
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -142,6 +142,8 @@ declare interface components {
|
|
|
142
142
|
dataType: string;
|
|
143
143
|
renderType?: string;
|
|
144
144
|
unit?: string;
|
|
145
|
+
/** @enum {string} */
|
|
146
|
+
canonicalDataType?: "numeric" | "boolean" | "datetime" | "text" | "array" | "json" | "other";
|
|
145
147
|
}[];
|
|
146
148
|
/** Format: uuid */
|
|
147
149
|
CanvasId: string;
|
|
@@ -713,6 +715,7 @@ export declare class MageMetricsClient {
|
|
|
713
715
|
dataType: string;
|
|
714
716
|
renderType?: string;
|
|
715
717
|
unit?: string;
|
|
718
|
+
canonicalDataType?: "numeric" | "boolean" | "datetime" | "text" | "array" | "json" | "other";
|
|
716
719
|
}[];
|
|
717
720
|
rowCount: {
|
|
718
721
|
count: number;
|
|
@@ -949,7 +952,7 @@ declare interface operations {
|
|
|
949
952
|
/** @example name:asc,date:desc */
|
|
950
953
|
order?: string;
|
|
951
954
|
cursor?: number;
|
|
952
|
-
/** @example status:active,name:John%20Doe */
|
|
955
|
+
/** @example status:eq:active,name:contains:John%20Doe */
|
|
953
956
|
filter?: string;
|
|
954
957
|
};
|
|
955
958
|
header?: never;
|
|
@@ -1890,7 +1893,7 @@ declare interface operations {
|
|
|
1890
1893
|
/** @example name:asc,date:desc */
|
|
1891
1894
|
order?: string;
|
|
1892
1895
|
cursor?: number;
|
|
1893
|
-
/** @example status:active,name:John%20Doe */
|
|
1896
|
+
/** @example status:eq:active,name:contains:John%20Doe */
|
|
1894
1897
|
filter?: string;
|
|
1895
1898
|
};
|
|
1896
1899
|
header: {
|
|
@@ -4237,7 +4240,26 @@ declare const redactedOutputSchema: z.ZodObject<{
|
|
|
4237
4240
|
}, z.core.$strip>;
|
|
4238
4241
|
}, z.core.$strip>, z.ZodObject<{
|
|
4239
4242
|
status: z.ZodLiteral<"error">;
|
|
4240
|
-
|
|
4243
|
+
category: z.ZodOptional<z.ZodEnum<{
|
|
4244
|
+
unknown: "unknown";
|
|
4245
|
+
timeout: "timeout";
|
|
4246
|
+
connection_error: "connection_error";
|
|
4247
|
+
auth_error: "auth_error";
|
|
4248
|
+
resource_exhausted: "resource_exhausted";
|
|
4249
|
+
table_not_found: "table_not_found";
|
|
4250
|
+
column_not_found: "column_not_found";
|
|
4251
|
+
schema_not_found: "schema_not_found";
|
|
4252
|
+
view_not_found: "view_not_found";
|
|
4253
|
+
function_not_found: "function_not_found";
|
|
4254
|
+
syntax_error: "syntax_error";
|
|
4255
|
+
ambiguous_column: "ambiguous_column";
|
|
4256
|
+
type_mismatch: "type_mismatch";
|
|
4257
|
+
invalid_cast: "invalid_cast";
|
|
4258
|
+
invalid_argument: "invalid_argument";
|
|
4259
|
+
division_by_zero: "division_by_zero";
|
|
4260
|
+
constraint_violation: "constraint_violation";
|
|
4261
|
+
permission_denied: "permission_denied";
|
|
4262
|
+
}>>;
|
|
4241
4263
|
}, z.core.$strip>], "status">>;
|
|
4242
4264
|
}, z.core.$strip>;
|
|
4243
4265
|
|
|
@@ -4374,7 +4396,26 @@ declare const SignalWithReportIdSchema: z.ZodObject<{
|
|
|
4374
4396
|
|
|
4375
4397
|
declare type SortingState = ColumnSort[];
|
|
4376
4398
|
|
|
4377
|
-
declare type TableFilters = Record<string,
|
|
4399
|
+
declare type TableFilters = Record<string, TableFilterValue>;
|
|
4400
|
+
|
|
4401
|
+
declare type TableFilterValue = z.infer<typeof TableFilterValueSchema>;
|
|
4402
|
+
|
|
4403
|
+
declare const TableFilterValueSchema: z.ZodObject<{
|
|
4404
|
+
operator: z.ZodEnum<{
|
|
4405
|
+
endsWith: "endsWith";
|
|
4406
|
+
startsWith: "startsWith";
|
|
4407
|
+
contains: "contains";
|
|
4408
|
+
eq: "eq";
|
|
4409
|
+
gt: "gt";
|
|
4410
|
+
gte: "gte";
|
|
4411
|
+
lt: "lt";
|
|
4412
|
+
lte: "lte";
|
|
4413
|
+
neq: "neq";
|
|
4414
|
+
regex: "regex";
|
|
4415
|
+
between: "between";
|
|
4416
|
+
}>;
|
|
4417
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>]>;
|
|
4418
|
+
}, z.core.$strip>;
|
|
4378
4419
|
|
|
4379
4420
|
/**
|
|
4380
4421
|
* Token storage keys
|
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.9.
|
|
60
|
+
version: "0.9.1"};
|
|
61
61
|
|
|
62
62
|
// src/core/MageMetricsEventEmitter.ts
|
|
63
63
|
var MageMetricsEventEmitter = class {
|
|
@@ -990,15 +990,26 @@ var ReportColumnsSchema = z.object({
|
|
|
990
990
|
name: z.string(),
|
|
991
991
|
data_type: z.string()
|
|
992
992
|
}).array();
|
|
993
|
+
var CanonicalDataTypeSchema = z.enum([
|
|
994
|
+
"numeric",
|
|
995
|
+
"boolean",
|
|
996
|
+
"datetime",
|
|
997
|
+
"text",
|
|
998
|
+
"array",
|
|
999
|
+
"json",
|
|
1000
|
+
"other"
|
|
1001
|
+
]);
|
|
993
1002
|
z.object({
|
|
994
1003
|
render_type: z.string().nullish(),
|
|
995
|
-
unit: z.string().nullish()
|
|
1004
|
+
unit: z.string().nullish(),
|
|
1005
|
+
canonical_data_type: CanonicalDataTypeSchema.nullish()
|
|
996
1006
|
});
|
|
997
1007
|
var FrontendReportColumnsSchema = z.object({
|
|
998
1008
|
...ReportColumnsSchema.element.shape,
|
|
999
1009
|
dataType: z.string(),
|
|
1000
1010
|
renderType: z.string().optional(),
|
|
1001
|
-
unit: z.string().optional()
|
|
1011
|
+
unit: z.string().optional(),
|
|
1012
|
+
canonicalDataType: CanonicalDataTypeSchema.optional()
|
|
1002
1013
|
}).array().openapi("ReportColumns");
|
|
1003
1014
|
z.object({
|
|
1004
1015
|
goal: z.string(),
|
|
@@ -1025,6 +1036,84 @@ var FrontendReportExplainabilitySchema = ReportExplainabilitySchema.omit({
|
|
|
1025
1036
|
output_dataset: z.string().optional(),
|
|
1026
1037
|
sql: z.string().optional()
|
|
1027
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
|
+
};
|
|
1028
1117
|
|
|
1029
1118
|
// ../shared/dist/src/endpoints/utils.js
|
|
1030
1119
|
var limitQueryParams = z.string().pipe(z.coerce.number()).optional().openapi({
|
|
@@ -1063,16 +1152,25 @@ var filterQueryParams = z.string().transform((str) => {
|
|
|
1063
1152
|
if (!str)
|
|
1064
1153
|
return [];
|
|
1065
1154
|
return str.split(",").map((part) => {
|
|
1066
|
-
const
|
|
1067
|
-
|
|
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 };
|
|
1068
1165
|
});
|
|
1069
1166
|
}).pipe(z.array(z.object({
|
|
1070
1167
|
column: z.string(),
|
|
1168
|
+
operator: FilterOperatorSchema,
|
|
1071
1169
|
value: z.string()
|
|
1072
1170
|
}))).optional().openapi({
|
|
1073
1171
|
param: {
|
|
1074
1172
|
required: false,
|
|
1075
|
-
example: "status:active,name:John%20Doe"
|
|
1173
|
+
example: "status:eq:active,name:contains:John%20Doe"
|
|
1076
1174
|
},
|
|
1077
1175
|
type: "string"
|
|
1078
1176
|
});
|
|
@@ -1822,20 +1920,20 @@ var CreateSpeechToken = createRoute({
|
|
|
1822
1920
|
}
|
|
1823
1921
|
}
|
|
1824
1922
|
});
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
status:
|
|
1828
|
-
error:
|
|
1923
|
+
z6.discriminatedUnion("status", [
|
|
1924
|
+
z6.object({
|
|
1925
|
+
status: z6.literal("error"),
|
|
1926
|
+
error: z6.string()
|
|
1829
1927
|
}),
|
|
1830
|
-
|
|
1831
|
-
status:
|
|
1832
|
-
flowId:
|
|
1928
|
+
z6.object({
|
|
1929
|
+
status: z6.literal("success"),
|
|
1930
|
+
flowId: z6.string()
|
|
1833
1931
|
})
|
|
1834
1932
|
]);
|
|
1835
|
-
var TriggerFlowBody =
|
|
1836
|
-
triggerId:
|
|
1837
|
-
variables:
|
|
1838
|
-
applicationName:
|
|
1933
|
+
var TriggerFlowBody = z6.object({
|
|
1934
|
+
triggerId: z6.string(),
|
|
1935
|
+
variables: z6.record(z6.string(), z6.string()),
|
|
1936
|
+
applicationName: z6.string().optional()
|
|
1839
1937
|
});
|
|
1840
1938
|
var TriggerFlow = createRoute({
|
|
1841
1939
|
method: "post",
|
|
@@ -1858,9 +1956,9 @@ var TriggerFlow = createRoute({
|
|
|
1858
1956
|
description: "Flow id",
|
|
1859
1957
|
content: {
|
|
1860
1958
|
"application/json": {
|
|
1861
|
-
schema:
|
|
1862
|
-
status:
|
|
1863
|
-
flowId:
|
|
1959
|
+
schema: z6.object({
|
|
1960
|
+
status: z6.literal("success"),
|
|
1961
|
+
flowId: z6.string()
|
|
1864
1962
|
})
|
|
1865
1963
|
}
|
|
1866
1964
|
}
|
|
@@ -1868,8 +1966,8 @@ var TriggerFlow = createRoute({
|
|
|
1868
1966
|
400: {
|
|
1869
1967
|
content: {
|
|
1870
1968
|
"application/json": {
|
|
1871
|
-
schema:
|
|
1872
|
-
error:
|
|
1969
|
+
schema: z6.object({
|
|
1970
|
+
error: z6.string()
|
|
1873
1971
|
})
|
|
1874
1972
|
}
|
|
1875
1973
|
},
|
|
@@ -1878,7 +1976,7 @@ var TriggerFlow = createRoute({
|
|
|
1878
1976
|
404: {
|
|
1879
1977
|
content: {
|
|
1880
1978
|
"application/json": {
|
|
1881
|
-
schema:
|
|
1979
|
+
schema: z6.object({ error: z6.string() })
|
|
1882
1980
|
}
|
|
1883
1981
|
},
|
|
1884
1982
|
description: "Unable to retrieve trigger with this id"
|
|
@@ -1887,8 +1985,8 @@ var TriggerFlow = createRoute({
|
|
|
1887
1985
|
description: "Something wrong happened",
|
|
1888
1986
|
content: {
|
|
1889
1987
|
"application/json": {
|
|
1890
|
-
schema:
|
|
1891
|
-
error:
|
|
1988
|
+
schema: z6.object({
|
|
1989
|
+
error: z6.string()
|
|
1892
1990
|
})
|
|
1893
1991
|
}
|
|
1894
1992
|
}
|
|
@@ -1918,9 +2016,9 @@ createRoute({
|
|
|
1918
2016
|
description: "Flow id",
|
|
1919
2017
|
content: {
|
|
1920
2018
|
"application/json": {
|
|
1921
|
-
schema:
|
|
1922
|
-
status:
|
|
1923
|
-
flowId:
|
|
2019
|
+
schema: z6.object({
|
|
2020
|
+
status: z6.literal("success"),
|
|
2021
|
+
flowId: z6.string()
|
|
1924
2022
|
})
|
|
1925
2023
|
}
|
|
1926
2024
|
}
|
|
@@ -1928,8 +2026,8 @@ createRoute({
|
|
|
1928
2026
|
400: {
|
|
1929
2027
|
content: {
|
|
1930
2028
|
"application/json": {
|
|
1931
|
-
schema:
|
|
1932
|
-
error:
|
|
2029
|
+
schema: z6.object({
|
|
2030
|
+
error: z6.string()
|
|
1933
2031
|
})
|
|
1934
2032
|
}
|
|
1935
2033
|
},
|
|
@@ -1938,7 +2036,7 @@ createRoute({
|
|
|
1938
2036
|
404: {
|
|
1939
2037
|
content: {
|
|
1940
2038
|
"application/json": {
|
|
1941
|
-
schema:
|
|
2039
|
+
schema: z6.object({ error: z6.string() })
|
|
1942
2040
|
}
|
|
1943
2041
|
},
|
|
1944
2042
|
description: "Unable to retrieve trigger with this id"
|
|
@@ -1947,8 +2045,8 @@ createRoute({
|
|
|
1947
2045
|
description: "Something wrong happened",
|
|
1948
2046
|
content: {
|
|
1949
2047
|
"application/json": {
|
|
1950
|
-
schema:
|
|
1951
|
-
error:
|
|
2048
|
+
schema: z6.object({
|
|
2049
|
+
error: z6.string()
|
|
1952
2050
|
})
|
|
1953
2051
|
}
|
|
1954
2052
|
}
|
|
@@ -2811,54 +2909,6 @@ var ListVisualizationsForFlow = createRoute({
|
|
|
2811
2909
|
}
|
|
2812
2910
|
}
|
|
2813
2911
|
});
|
|
2814
|
-
var DataTableSchema = z.object({
|
|
2815
|
-
id: z.number(),
|
|
2816
|
-
dataset: z.string(),
|
|
2817
|
-
table_name: z.string(),
|
|
2818
|
-
description: z.string().nullable(),
|
|
2819
|
-
primary_key_names: z.string().array(),
|
|
2820
|
-
row_count: z.number().nullable(),
|
|
2821
|
-
created_at: z.string(),
|
|
2822
|
-
updated_at: z.string(),
|
|
2823
|
-
source_id: z.number(),
|
|
2824
|
-
parent_table_id: z.number().nullable()
|
|
2825
|
-
});
|
|
2826
|
-
var DataTableColumnSchema = z.object({
|
|
2827
|
-
id: z.number(),
|
|
2828
|
-
name: z.string(),
|
|
2829
|
-
data_type: z.string().nullable(),
|
|
2830
|
-
description: z.string().nullable(),
|
|
2831
|
-
null_percentage: z.number().nullable(),
|
|
2832
|
-
unique_values: z.number().nullable(),
|
|
2833
|
-
sample_values: z.array(z.unknown()).nullable()
|
|
2834
|
-
});
|
|
2835
|
-
DataTableSchema.extend({
|
|
2836
|
-
columns: z.array(DataTableColumnSchema)
|
|
2837
|
-
});
|
|
2838
|
-
var toSearchParams = ({ cursor, filters, sorting, limit }) => {
|
|
2839
|
-
const params = {};
|
|
2840
|
-
if (limit !== void 0) {
|
|
2841
|
-
params.limit = limit;
|
|
2842
|
-
}
|
|
2843
|
-
if (cursor !== void 0) {
|
|
2844
|
-
params.cursor = cursor;
|
|
2845
|
-
}
|
|
2846
|
-
const sortingParams = sorting?.map((c) => `${c.id}:${c.desc ? "DESC" : "ASC"}`).join(",");
|
|
2847
|
-
if (sortingParams) {
|
|
2848
|
-
params.order = sortingParams;
|
|
2849
|
-
}
|
|
2850
|
-
if (filters) {
|
|
2851
|
-
const filterParams = Object.entries(filters).flatMap(([key, value]) => {
|
|
2852
|
-
if (!(typeof value === "string" || typeof value === "boolean" || typeof value === "number"))
|
|
2853
|
-
return [];
|
|
2854
|
-
return `${key}:${encodeURIComponent(value)}`;
|
|
2855
|
-
}).join(",");
|
|
2856
|
-
if (filterParams.length > 0) {
|
|
2857
|
-
params.filter = filterParams;
|
|
2858
|
-
}
|
|
2859
|
-
}
|
|
2860
|
-
return params;
|
|
2861
|
-
};
|
|
2862
2912
|
var isToolResultMessage = (message) => {
|
|
2863
2913
|
if (message.role !== "assistant") {
|
|
2864
2914
|
return false;
|