@magemetrics/core 0.11.5 → 0.11.6
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 +33 -4
- package/dist/index.js +111 -36
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Client } from 'openapi-fetch';
|
|
2
|
+
import { default as default_2 } from 'zod';
|
|
2
3
|
import { DefaultChatTransport } from 'ai';
|
|
3
4
|
import { GoTrueClient } from '@supabase/auth-js';
|
|
4
5
|
import { GoTrueClientOptions } from '@supabase/auth-js';
|
|
@@ -483,11 +484,27 @@ declare const CreateCanvasSchema: z.ZodObject<{
|
|
|
483
484
|
flow_id: z.ZodOptional<z.ZodString>;
|
|
484
485
|
}, z.core.$strip>;
|
|
485
486
|
|
|
487
|
+
/**
|
|
488
|
+
* A file attachment to include in the first message of a flow.
|
|
489
|
+
*
|
|
490
|
+
* Structurally compatible with the AI SDK's `FileUIPart`, so the output of
|
|
491
|
+
* `useFileUpload().getFileParts()` can be passed directly — no mapping needed.
|
|
492
|
+
*/
|
|
493
|
+
declare type CreateFlowFile = default_2.infer<typeof CreateFlowFileSchema>;
|
|
494
|
+
|
|
495
|
+
declare const CreateFlowFileSchema: z.ZodObject<{
|
|
496
|
+
type: z.ZodLiteral<"file">;
|
|
497
|
+
mediaType: z.ZodString;
|
|
498
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
499
|
+
url: z.ZodString;
|
|
500
|
+
}, z.core.$strip>;
|
|
501
|
+
|
|
486
502
|
/**
|
|
487
503
|
* Parameters for starting a flow
|
|
488
504
|
*/
|
|
489
505
|
export declare type CreateFlowParam = {
|
|
490
506
|
query: string;
|
|
507
|
+
files?: CreateFlowFile[];
|
|
491
508
|
} | {
|
|
492
509
|
triggerId: string;
|
|
493
510
|
variables: Record<string, string>;
|
|
@@ -667,7 +684,7 @@ declare const inputSchema_8: z.ZodObject<{
|
|
|
667
684
|
declare const inputSchema_9: z.ZodObject<{
|
|
668
685
|
questions: z.ZodArray<z.ZodObject<{
|
|
669
686
|
question: z.ZodString;
|
|
670
|
-
header: z.ZodString
|
|
687
|
+
header: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
671
688
|
multiSelect: z.ZodBoolean;
|
|
672
689
|
options: z.ZodArray<z.ZodObject<{
|
|
673
690
|
label: z.ZodString;
|
|
@@ -899,6 +916,11 @@ export declare class MageMetricsClient {
|
|
|
899
916
|
[x: string]: unknown;
|
|
900
917
|
}[]>;
|
|
901
918
|
}>;
|
|
919
|
+
getRecommendations: (count: number) => Promise<{
|
|
920
|
+
starter: string;
|
|
921
|
+
explanation: string;
|
|
922
|
+
type: string;
|
|
923
|
+
}[]>;
|
|
902
924
|
};
|
|
903
925
|
client(): PublicApiClient;
|
|
904
926
|
private createSupabaseHeaderMiddleware;
|
|
@@ -1689,13 +1711,13 @@ declare interface operations {
|
|
|
1689
1711
|
}[];
|
|
1690
1712
|
};
|
|
1691
1713
|
} | null;
|
|
1692
|
-
confidence_score
|
|
1693
|
-
confidence_score_reason
|
|
1714
|
+
confidence_score?: number;
|
|
1715
|
+
confidence_score_reason?: string;
|
|
1694
1716
|
assumptions_score?: number;
|
|
1695
1717
|
assumptions_score_reason?: string;
|
|
1718
|
+
flow_data_id: number;
|
|
1696
1719
|
friendliness_score?: number;
|
|
1697
1720
|
friendliness_score_reason?: string;
|
|
1698
|
-
flow_data_id: number;
|
|
1699
1721
|
output_dataset?: string;
|
|
1700
1722
|
sql?: string;
|
|
1701
1723
|
};
|
|
@@ -2144,6 +2166,13 @@ declare interface operations {
|
|
|
2144
2166
|
"application/json": {
|
|
2145
2167
|
userQuery: string;
|
|
2146
2168
|
applicationName?: string;
|
|
2169
|
+
files?: {
|
|
2170
|
+
/** @enum {string} */
|
|
2171
|
+
type: "file";
|
|
2172
|
+
mediaType: string;
|
|
2173
|
+
filename?: string;
|
|
2174
|
+
url: string;
|
|
2175
|
+
}[];
|
|
2147
2176
|
};
|
|
2148
2177
|
};
|
|
2149
2178
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sha256 } from '@noble/hashes/sha2.js';
|
|
2
|
-
import
|
|
2
|
+
import z7, { z } from 'zod';
|
|
3
3
|
import { GoTrueClient } from '@supabase/auth-js';
|
|
4
4
|
import createApiClient2 from 'openapi-fetch';
|
|
5
5
|
import dayjs from 'dayjs';
|
|
@@ -58,7 +58,7 @@ var addApiKeyHeader = (apiKey) => {
|
|
|
58
58
|
|
|
59
59
|
// package.json
|
|
60
60
|
var package_default = {
|
|
61
|
-
version: "0.11.
|
|
61
|
+
version: "0.11.6"};
|
|
62
62
|
|
|
63
63
|
// src/core/MageMetricsEventEmitter.ts
|
|
64
64
|
var MageMetricsEventEmitter = class {
|
|
@@ -482,7 +482,7 @@ function getOpenApiConfiguration(refOrOpenapi, metadataOrOptions, options) {
|
|
|
482
482
|
};
|
|
483
483
|
}
|
|
484
484
|
|
|
485
|
-
// ../../node_modules/.pnpm/hono@4.12.
|
|
485
|
+
// ../../node_modules/.pnpm/hono@4.12.8/node_modules/hono/dist/router/reg-exp-router/node.js
|
|
486
486
|
new Set(".\\+*[^]$()");
|
|
487
487
|
var createRoute = (routeConfig) => {
|
|
488
488
|
const route = {
|
|
@@ -1022,10 +1022,8 @@ var ReportExplainabilitySchema = z.object({
|
|
|
1022
1022
|
columns_lineage: LLMColumnsLineageResponse.nullish(),
|
|
1023
1023
|
confidence_score: z.number(),
|
|
1024
1024
|
confidence_score_reason: z.string(),
|
|
1025
|
-
assumptions_score: z.number().
|
|
1026
|
-
assumptions_score_reason: z.string().
|
|
1027
|
-
friendliness_score: z.number().optional(),
|
|
1028
|
-
friendliness_score_reason: z.string().optional(),
|
|
1025
|
+
assumptions_score: z.number().nullish(),
|
|
1026
|
+
assumptions_score_reason: z.string().nullish(),
|
|
1029
1027
|
id: z.number(),
|
|
1030
1028
|
flow_data_id: z.number(),
|
|
1031
1029
|
created_at: z.string()
|
|
@@ -1034,6 +1032,15 @@ var FrontendReportExplainabilitySchema = ReportExplainabilitySchema.omit({
|
|
|
1034
1032
|
id: true,
|
|
1035
1033
|
created_at: true
|
|
1036
1034
|
}).extend({
|
|
1035
|
+
// All scores are optional in the frontend schema so that clients
|
|
1036
|
+
// are forward-compatible when the DB columns become nullable.
|
|
1037
|
+
// The API endpoint coerces null → undefined before parsing.
|
|
1038
|
+
confidence_score: z.number().optional(),
|
|
1039
|
+
confidence_score_reason: z.string().optional(),
|
|
1040
|
+
assumptions_score: z.number().optional(),
|
|
1041
|
+
assumptions_score_reason: z.string().optional(),
|
|
1042
|
+
friendliness_score: z.number().optional(),
|
|
1043
|
+
friendliness_score_reason: z.string().optional(),
|
|
1037
1044
|
output_dataset: z.string().optional(),
|
|
1038
1045
|
sql: z.string().optional()
|
|
1039
1046
|
});
|
|
@@ -1186,12 +1193,21 @@ var columnsQueryParams = z.string().transform((str) => {
|
|
|
1186
1193
|
},
|
|
1187
1194
|
type: "string"
|
|
1188
1195
|
});
|
|
1196
|
+
var CHAT_MAX_FILE_COUNT = 10;
|
|
1197
|
+
var CHAT_ALLOWED_FILE_MEDIA_TYPES = /* @__PURE__ */ new Set(["application/pdf"]);
|
|
1198
|
+
[...CHAT_ALLOWED_FILE_MEDIA_TYPES].join(",");
|
|
1189
1199
|
|
|
1190
1200
|
// ../shared/dist/src/endpoints/companion/flows.routes.js
|
|
1191
1201
|
var FlowIdParam = z.object({ flowId: z.uuid() }).openapi("FlowId", { type: "string" });
|
|
1192
1202
|
var FlowDataIdParam = z.object({ flowDataId: z.string().pipe(z.coerce.number()) }).openapi("FlowDataId", { type: "integer" });
|
|
1193
1203
|
var ReportId = z.string().pipe(z.coerce.number());
|
|
1194
1204
|
var ReportIdParam = z.object({ report_id: ReportId }).openapi("ReportId", { type: "integer" });
|
|
1205
|
+
var CreateFlowFileSchema = z.object({
|
|
1206
|
+
type: z.literal("file"),
|
|
1207
|
+
mediaType: z.string(),
|
|
1208
|
+
filename: z.string().optional(),
|
|
1209
|
+
url: z.string()
|
|
1210
|
+
});
|
|
1195
1211
|
var RetrieveFlowDataReports = createRoute({
|
|
1196
1212
|
method: "get",
|
|
1197
1213
|
path: "/api/v1/flows/{flowId}/data-reports",
|
|
@@ -1865,7 +1881,8 @@ var CreateFlow = createRoute({
|
|
|
1865
1881
|
"application/json": {
|
|
1866
1882
|
schema: z.object({
|
|
1867
1883
|
userQuery: z.string(),
|
|
1868
|
-
applicationName: z.string().optional()
|
|
1884
|
+
applicationName: z.string().optional(),
|
|
1885
|
+
files: z.array(CreateFlowFileSchema).max(CHAT_MAX_FILE_COUNT).optional()
|
|
1869
1886
|
})
|
|
1870
1887
|
}
|
|
1871
1888
|
}
|
|
@@ -1905,6 +1922,47 @@ var CreateFlow = createRoute({
|
|
|
1905
1922
|
}
|
|
1906
1923
|
}
|
|
1907
1924
|
});
|
|
1925
|
+
var FrontendRecommendationsSchema = z.object({
|
|
1926
|
+
starter: z.string(),
|
|
1927
|
+
explanation: z.string(),
|
|
1928
|
+
type: z.string()
|
|
1929
|
+
}).describe("Starter recommendations").openapi("StarterRecommendation");
|
|
1930
|
+
|
|
1931
|
+
// ../shared/dist/src/endpoints/companion/recommendations.routes.js
|
|
1932
|
+
var GetStarterRecommendations = createRoute({
|
|
1933
|
+
method: "get",
|
|
1934
|
+
path: "/api/v1/recommendations",
|
|
1935
|
+
operationId: "getStarterRecommendations",
|
|
1936
|
+
tags: ["public"],
|
|
1937
|
+
request: {
|
|
1938
|
+
headers: SupabaseHeaderSchema,
|
|
1939
|
+
query: z.object({
|
|
1940
|
+
count: z.string().pipe(z.coerce.number()).optional().openapi({ type: "number" })
|
|
1941
|
+
})
|
|
1942
|
+
},
|
|
1943
|
+
responses: {
|
|
1944
|
+
200: {
|
|
1945
|
+
content: {
|
|
1946
|
+
"application/json": {
|
|
1947
|
+
schema: z.object({
|
|
1948
|
+
recommendations: FrontendRecommendationsSchema.array()
|
|
1949
|
+
})
|
|
1950
|
+
}
|
|
1951
|
+
},
|
|
1952
|
+
description: "Get starter recommendations"
|
|
1953
|
+
},
|
|
1954
|
+
500: {
|
|
1955
|
+
description: "Something wrong happened",
|
|
1956
|
+
content: {
|
|
1957
|
+
"application/json": {
|
|
1958
|
+
schema: z.object({
|
|
1959
|
+
error: z.string()
|
|
1960
|
+
})
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
});
|
|
1908
1966
|
|
|
1909
1967
|
// ../shared/dist/src/endpoints/companion/speech.routes.js
|
|
1910
1968
|
var SpeechTokenResponseSchema = z.object({
|
|
@@ -1940,20 +1998,20 @@ var CreateSpeechToken = createRoute({
|
|
|
1940
1998
|
}
|
|
1941
1999
|
}
|
|
1942
2000
|
});
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
status:
|
|
1946
|
-
error:
|
|
2001
|
+
z7.discriminatedUnion("status", [
|
|
2002
|
+
z7.object({
|
|
2003
|
+
status: z7.literal("error"),
|
|
2004
|
+
error: z7.string()
|
|
1947
2005
|
}),
|
|
1948
|
-
|
|
1949
|
-
status:
|
|
1950
|
-
flowId:
|
|
2006
|
+
z7.object({
|
|
2007
|
+
status: z7.literal("success"),
|
|
2008
|
+
flowId: z7.string()
|
|
1951
2009
|
})
|
|
1952
2010
|
]);
|
|
1953
|
-
var TriggerFlowBody =
|
|
1954
|
-
triggerId:
|
|
1955
|
-
variables:
|
|
1956
|
-
applicationName:
|
|
2011
|
+
var TriggerFlowBody = z7.object({
|
|
2012
|
+
triggerId: z7.string(),
|
|
2013
|
+
variables: z7.record(z7.string(), z7.string()),
|
|
2014
|
+
applicationName: z7.string().optional()
|
|
1957
2015
|
});
|
|
1958
2016
|
var TriggerFlow = createRoute({
|
|
1959
2017
|
method: "post",
|
|
@@ -1977,9 +2035,9 @@ var TriggerFlow = createRoute({
|
|
|
1977
2035
|
description: "Flow id",
|
|
1978
2036
|
content: {
|
|
1979
2037
|
"application/json": {
|
|
1980
|
-
schema:
|
|
1981
|
-
status:
|
|
1982
|
-
flowId:
|
|
2038
|
+
schema: z7.object({
|
|
2039
|
+
status: z7.literal("success"),
|
|
2040
|
+
flowId: z7.string()
|
|
1983
2041
|
})
|
|
1984
2042
|
}
|
|
1985
2043
|
}
|
|
@@ -1987,8 +2045,8 @@ var TriggerFlow = createRoute({
|
|
|
1987
2045
|
400: {
|
|
1988
2046
|
content: {
|
|
1989
2047
|
"application/json": {
|
|
1990
|
-
schema:
|
|
1991
|
-
error:
|
|
2048
|
+
schema: z7.object({
|
|
2049
|
+
error: z7.string()
|
|
1992
2050
|
})
|
|
1993
2051
|
}
|
|
1994
2052
|
},
|
|
@@ -1997,7 +2055,7 @@ var TriggerFlow = createRoute({
|
|
|
1997
2055
|
404: {
|
|
1998
2056
|
content: {
|
|
1999
2057
|
"application/json": {
|
|
2000
|
-
schema:
|
|
2058
|
+
schema: z7.object({ error: z7.string() })
|
|
2001
2059
|
}
|
|
2002
2060
|
},
|
|
2003
2061
|
description: "Unable to retrieve trigger with this id"
|
|
@@ -2006,8 +2064,8 @@ var TriggerFlow = createRoute({
|
|
|
2006
2064
|
description: "Something wrong happened",
|
|
2007
2065
|
content: {
|
|
2008
2066
|
"application/json": {
|
|
2009
|
-
schema:
|
|
2010
|
-
error:
|
|
2067
|
+
schema: z7.object({
|
|
2068
|
+
error: z7.string()
|
|
2011
2069
|
})
|
|
2012
2070
|
}
|
|
2013
2071
|
}
|
|
@@ -2037,9 +2095,9 @@ createRoute({
|
|
|
2037
2095
|
description: "Flow id",
|
|
2038
2096
|
content: {
|
|
2039
2097
|
"application/json": {
|
|
2040
|
-
schema:
|
|
2041
|
-
status:
|
|
2042
|
-
flowId:
|
|
2098
|
+
schema: z7.object({
|
|
2099
|
+
status: z7.literal("success"),
|
|
2100
|
+
flowId: z7.string()
|
|
2043
2101
|
})
|
|
2044
2102
|
}
|
|
2045
2103
|
}
|
|
@@ -2047,8 +2105,8 @@ createRoute({
|
|
|
2047
2105
|
400: {
|
|
2048
2106
|
content: {
|
|
2049
2107
|
"application/json": {
|
|
2050
|
-
schema:
|
|
2051
|
-
error:
|
|
2108
|
+
schema: z7.object({
|
|
2109
|
+
error: z7.string()
|
|
2052
2110
|
})
|
|
2053
2111
|
}
|
|
2054
2112
|
},
|
|
@@ -2057,7 +2115,7 @@ createRoute({
|
|
|
2057
2115
|
404: {
|
|
2058
2116
|
content: {
|
|
2059
2117
|
"application/json": {
|
|
2060
|
-
schema:
|
|
2118
|
+
schema: z7.object({ error: z7.string() })
|
|
2061
2119
|
}
|
|
2062
2120
|
},
|
|
2063
2121
|
description: "Unable to retrieve trigger with this id"
|
|
@@ -2066,8 +2124,8 @@ createRoute({
|
|
|
2066
2124
|
description: "Something wrong happened",
|
|
2067
2125
|
content: {
|
|
2068
2126
|
"application/json": {
|
|
2069
|
-
schema:
|
|
2070
|
-
error:
|
|
2127
|
+
schema: z7.object({
|
|
2128
|
+
error: z7.string()
|
|
2071
2129
|
})
|
|
2072
2130
|
}
|
|
2073
2131
|
}
|
|
@@ -3175,7 +3233,8 @@ var MageMetricsClient = class {
|
|
|
3175
3233
|
{
|
|
3176
3234
|
body: {
|
|
3177
3235
|
userQuery: request.query,
|
|
3178
|
-
applicationName: this.config.applicationName
|
|
3236
|
+
applicationName: this.config.applicationName,
|
|
3237
|
+
files: request.files
|
|
3179
3238
|
}
|
|
3180
3239
|
}
|
|
3181
3240
|
);
|
|
@@ -3475,6 +3534,22 @@ var MageMetricsClient = class {
|
|
|
3475
3534
|
rowCount,
|
|
3476
3535
|
data: this.api.fetchReportData
|
|
3477
3536
|
};
|
|
3537
|
+
},
|
|
3538
|
+
getRecommendations: async (count) => {
|
|
3539
|
+
await this.waitForAuth();
|
|
3540
|
+
const { data, error, response } = await this.internalApiClient.GET(
|
|
3541
|
+
GetStarterRecommendations.path,
|
|
3542
|
+
{ params: { query: { count } } }
|
|
3543
|
+
);
|
|
3544
|
+
if (error) {
|
|
3545
|
+
throw new ApiError(error.error, response, {
|
|
3546
|
+
status: response.status,
|
|
3547
|
+
statusText: response.statusText,
|
|
3548
|
+
url: response.url,
|
|
3549
|
+
method: "GET"
|
|
3550
|
+
});
|
|
3551
|
+
}
|
|
3552
|
+
return data.recommendations;
|
|
3478
3553
|
}
|
|
3479
3554
|
};
|
|
3480
3555
|
client() {
|