@magemetrics/core 0.11.4 → 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 +36 -5
- package/dist/index.js +112 -38
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
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';
|
|
@@ -366,10 +367,12 @@ declare interface components {
|
|
|
366
367
|
[key: string]: unknown;
|
|
367
368
|
};
|
|
368
369
|
};
|
|
370
|
+
AgentRunCountsResponse: {
|
|
371
|
+
[key: string]: number;
|
|
372
|
+
};
|
|
369
373
|
Agent: {
|
|
370
374
|
/** Format: uuid */
|
|
371
375
|
id: string;
|
|
372
|
-
company_id: number;
|
|
373
376
|
name: string;
|
|
374
377
|
objective: string | null;
|
|
375
378
|
generated_objective_fragment: string | null;
|
|
@@ -481,11 +484,27 @@ declare const CreateCanvasSchema: z.ZodObject<{
|
|
|
481
484
|
flow_id: z.ZodOptional<z.ZodString>;
|
|
482
485
|
}, z.core.$strip>;
|
|
483
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
|
+
|
|
484
502
|
/**
|
|
485
503
|
* Parameters for starting a flow
|
|
486
504
|
*/
|
|
487
505
|
export declare type CreateFlowParam = {
|
|
488
506
|
query: string;
|
|
507
|
+
files?: CreateFlowFile[];
|
|
489
508
|
} | {
|
|
490
509
|
triggerId: string;
|
|
491
510
|
variables: Record<string, string>;
|
|
@@ -665,7 +684,7 @@ declare const inputSchema_8: z.ZodObject<{
|
|
|
665
684
|
declare const inputSchema_9: z.ZodObject<{
|
|
666
685
|
questions: z.ZodArray<z.ZodObject<{
|
|
667
686
|
question: z.ZodString;
|
|
668
|
-
header: z.ZodString
|
|
687
|
+
header: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
669
688
|
multiSelect: z.ZodBoolean;
|
|
670
689
|
options: z.ZodArray<z.ZodObject<{
|
|
671
690
|
label: z.ZodString;
|
|
@@ -897,6 +916,11 @@ export declare class MageMetricsClient {
|
|
|
897
916
|
[x: string]: unknown;
|
|
898
917
|
}[]>;
|
|
899
918
|
}>;
|
|
919
|
+
getRecommendations: (count: number) => Promise<{
|
|
920
|
+
starter: string;
|
|
921
|
+
explanation: string;
|
|
922
|
+
type: string;
|
|
923
|
+
}[]>;
|
|
900
924
|
};
|
|
901
925
|
client(): PublicApiClient;
|
|
902
926
|
private createSupabaseHeaderMiddleware;
|
|
@@ -1687,13 +1711,13 @@ declare interface operations {
|
|
|
1687
1711
|
}[];
|
|
1688
1712
|
};
|
|
1689
1713
|
} | null;
|
|
1690
|
-
confidence_score
|
|
1691
|
-
confidence_score_reason
|
|
1714
|
+
confidence_score?: number;
|
|
1715
|
+
confidence_score_reason?: string;
|
|
1692
1716
|
assumptions_score?: number;
|
|
1693
1717
|
assumptions_score_reason?: string;
|
|
1718
|
+
flow_data_id: number;
|
|
1694
1719
|
friendliness_score?: number;
|
|
1695
1720
|
friendliness_score_reason?: string;
|
|
1696
|
-
flow_data_id: number;
|
|
1697
1721
|
output_dataset?: string;
|
|
1698
1722
|
sql?: string;
|
|
1699
1723
|
};
|
|
@@ -2142,6 +2166,13 @@ declare interface operations {
|
|
|
2142
2166
|
"application/json": {
|
|
2143
2167
|
userQuery: string;
|
|
2144
2168
|
applicationName?: string;
|
|
2169
|
+
files?: {
|
|
2170
|
+
/** @enum {string} */
|
|
2171
|
+
type: "file";
|
|
2172
|
+
mediaType: string;
|
|
2173
|
+
filename?: string;
|
|
2174
|
+
url: string;
|
|
2175
|
+
}[];
|
|
2145
2176
|
};
|
|
2146
2177
|
};
|
|
2147
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 = {
|
|
@@ -845,10 +845,9 @@ var ExternalAuthProvider = class {
|
|
|
845
845
|
}
|
|
846
846
|
}
|
|
847
847
|
};
|
|
848
|
-
var
|
|
848
|
+
var SupabaseHeaderSchema = z.object({
|
|
849
849
|
[HEADER_SP_TOKEN]: z.string().optional()
|
|
850
850
|
});
|
|
851
|
-
var SupabaseHeaderSchema = SupabaseUserHeaderSchema;
|
|
852
851
|
var FEEDBACK_OPTIONS = [
|
|
853
852
|
{ label: "Helpful", value: "helpful" },
|
|
854
853
|
{ label: "Partially helpful", value: "partially helpful" },
|
|
@@ -1023,10 +1022,8 @@ var ReportExplainabilitySchema = z.object({
|
|
|
1023
1022
|
columns_lineage: LLMColumnsLineageResponse.nullish(),
|
|
1024
1023
|
confidence_score: z.number(),
|
|
1025
1024
|
confidence_score_reason: z.string(),
|
|
1026
|
-
assumptions_score: z.number().
|
|
1027
|
-
assumptions_score_reason: z.string().
|
|
1028
|
-
friendliness_score: z.number().optional(),
|
|
1029
|
-
friendliness_score_reason: z.string().optional(),
|
|
1025
|
+
assumptions_score: z.number().nullish(),
|
|
1026
|
+
assumptions_score_reason: z.string().nullish(),
|
|
1030
1027
|
id: z.number(),
|
|
1031
1028
|
flow_data_id: z.number(),
|
|
1032
1029
|
created_at: z.string()
|
|
@@ -1035,6 +1032,15 @@ var FrontendReportExplainabilitySchema = ReportExplainabilitySchema.omit({
|
|
|
1035
1032
|
id: true,
|
|
1036
1033
|
created_at: true
|
|
1037
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(),
|
|
1038
1044
|
output_dataset: z.string().optional(),
|
|
1039
1045
|
sql: z.string().optional()
|
|
1040
1046
|
});
|
|
@@ -1187,12 +1193,21 @@ var columnsQueryParams = z.string().transform((str) => {
|
|
|
1187
1193
|
},
|
|
1188
1194
|
type: "string"
|
|
1189
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(",");
|
|
1190
1199
|
|
|
1191
1200
|
// ../shared/dist/src/endpoints/companion/flows.routes.js
|
|
1192
1201
|
var FlowIdParam = z.object({ flowId: z.uuid() }).openapi("FlowId", { type: "string" });
|
|
1193
1202
|
var FlowDataIdParam = z.object({ flowDataId: z.string().pipe(z.coerce.number()) }).openapi("FlowDataId", { type: "integer" });
|
|
1194
1203
|
var ReportId = z.string().pipe(z.coerce.number());
|
|
1195
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
|
+
});
|
|
1196
1211
|
var RetrieveFlowDataReports = createRoute({
|
|
1197
1212
|
method: "get",
|
|
1198
1213
|
path: "/api/v1/flows/{flowId}/data-reports",
|
|
@@ -1866,7 +1881,8 @@ var CreateFlow = createRoute({
|
|
|
1866
1881
|
"application/json": {
|
|
1867
1882
|
schema: z.object({
|
|
1868
1883
|
userQuery: z.string(),
|
|
1869
|
-
applicationName: z.string().optional()
|
|
1884
|
+
applicationName: z.string().optional(),
|
|
1885
|
+
files: z.array(CreateFlowFileSchema).max(CHAT_MAX_FILE_COUNT).optional()
|
|
1870
1886
|
})
|
|
1871
1887
|
}
|
|
1872
1888
|
}
|
|
@@ -1906,6 +1922,47 @@ var CreateFlow = createRoute({
|
|
|
1906
1922
|
}
|
|
1907
1923
|
}
|
|
1908
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
|
+
});
|
|
1909
1966
|
|
|
1910
1967
|
// ../shared/dist/src/endpoints/companion/speech.routes.js
|
|
1911
1968
|
var SpeechTokenResponseSchema = z.object({
|
|
@@ -1941,20 +1998,20 @@ var CreateSpeechToken = createRoute({
|
|
|
1941
1998
|
}
|
|
1942
1999
|
}
|
|
1943
2000
|
});
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
status:
|
|
1947
|
-
error:
|
|
2001
|
+
z7.discriminatedUnion("status", [
|
|
2002
|
+
z7.object({
|
|
2003
|
+
status: z7.literal("error"),
|
|
2004
|
+
error: z7.string()
|
|
1948
2005
|
}),
|
|
1949
|
-
|
|
1950
|
-
status:
|
|
1951
|
-
flowId:
|
|
2006
|
+
z7.object({
|
|
2007
|
+
status: z7.literal("success"),
|
|
2008
|
+
flowId: z7.string()
|
|
1952
2009
|
})
|
|
1953
2010
|
]);
|
|
1954
|
-
var TriggerFlowBody =
|
|
1955
|
-
triggerId:
|
|
1956
|
-
variables:
|
|
1957
|
-
applicationName:
|
|
2011
|
+
var TriggerFlowBody = z7.object({
|
|
2012
|
+
triggerId: z7.string(),
|
|
2013
|
+
variables: z7.record(z7.string(), z7.string()),
|
|
2014
|
+
applicationName: z7.string().optional()
|
|
1958
2015
|
});
|
|
1959
2016
|
var TriggerFlow = createRoute({
|
|
1960
2017
|
method: "post",
|
|
@@ -1978,9 +2035,9 @@ var TriggerFlow = createRoute({
|
|
|
1978
2035
|
description: "Flow id",
|
|
1979
2036
|
content: {
|
|
1980
2037
|
"application/json": {
|
|
1981
|
-
schema:
|
|
1982
|
-
status:
|
|
1983
|
-
flowId:
|
|
2038
|
+
schema: z7.object({
|
|
2039
|
+
status: z7.literal("success"),
|
|
2040
|
+
flowId: z7.string()
|
|
1984
2041
|
})
|
|
1985
2042
|
}
|
|
1986
2043
|
}
|
|
@@ -1988,8 +2045,8 @@ var TriggerFlow = createRoute({
|
|
|
1988
2045
|
400: {
|
|
1989
2046
|
content: {
|
|
1990
2047
|
"application/json": {
|
|
1991
|
-
schema:
|
|
1992
|
-
error:
|
|
2048
|
+
schema: z7.object({
|
|
2049
|
+
error: z7.string()
|
|
1993
2050
|
})
|
|
1994
2051
|
}
|
|
1995
2052
|
},
|
|
@@ -1998,7 +2055,7 @@ var TriggerFlow = createRoute({
|
|
|
1998
2055
|
404: {
|
|
1999
2056
|
content: {
|
|
2000
2057
|
"application/json": {
|
|
2001
|
-
schema:
|
|
2058
|
+
schema: z7.object({ error: z7.string() })
|
|
2002
2059
|
}
|
|
2003
2060
|
},
|
|
2004
2061
|
description: "Unable to retrieve trigger with this id"
|
|
@@ -2007,8 +2064,8 @@ var TriggerFlow = createRoute({
|
|
|
2007
2064
|
description: "Something wrong happened",
|
|
2008
2065
|
content: {
|
|
2009
2066
|
"application/json": {
|
|
2010
|
-
schema:
|
|
2011
|
-
error:
|
|
2067
|
+
schema: z7.object({
|
|
2068
|
+
error: z7.string()
|
|
2012
2069
|
})
|
|
2013
2070
|
}
|
|
2014
2071
|
}
|
|
@@ -2038,9 +2095,9 @@ createRoute({
|
|
|
2038
2095
|
description: "Flow id",
|
|
2039
2096
|
content: {
|
|
2040
2097
|
"application/json": {
|
|
2041
|
-
schema:
|
|
2042
|
-
status:
|
|
2043
|
-
flowId:
|
|
2098
|
+
schema: z7.object({
|
|
2099
|
+
status: z7.literal("success"),
|
|
2100
|
+
flowId: z7.string()
|
|
2044
2101
|
})
|
|
2045
2102
|
}
|
|
2046
2103
|
}
|
|
@@ -2048,8 +2105,8 @@ createRoute({
|
|
|
2048
2105
|
400: {
|
|
2049
2106
|
content: {
|
|
2050
2107
|
"application/json": {
|
|
2051
|
-
schema:
|
|
2052
|
-
error:
|
|
2108
|
+
schema: z7.object({
|
|
2109
|
+
error: z7.string()
|
|
2053
2110
|
})
|
|
2054
2111
|
}
|
|
2055
2112
|
},
|
|
@@ -2058,7 +2115,7 @@ createRoute({
|
|
|
2058
2115
|
404: {
|
|
2059
2116
|
content: {
|
|
2060
2117
|
"application/json": {
|
|
2061
|
-
schema:
|
|
2118
|
+
schema: z7.object({ error: z7.string() })
|
|
2062
2119
|
}
|
|
2063
2120
|
},
|
|
2064
2121
|
description: "Unable to retrieve trigger with this id"
|
|
@@ -2067,8 +2124,8 @@ createRoute({
|
|
|
2067
2124
|
description: "Something wrong happened",
|
|
2068
2125
|
content: {
|
|
2069
2126
|
"application/json": {
|
|
2070
|
-
schema:
|
|
2071
|
-
error:
|
|
2127
|
+
schema: z7.object({
|
|
2128
|
+
error: z7.string()
|
|
2072
2129
|
})
|
|
2073
2130
|
}
|
|
2074
2131
|
}
|
|
@@ -3176,7 +3233,8 @@ var MageMetricsClient = class {
|
|
|
3176
3233
|
{
|
|
3177
3234
|
body: {
|
|
3178
3235
|
userQuery: request.query,
|
|
3179
|
-
applicationName: this.config.applicationName
|
|
3236
|
+
applicationName: this.config.applicationName,
|
|
3237
|
+
files: request.files
|
|
3180
3238
|
}
|
|
3181
3239
|
}
|
|
3182
3240
|
);
|
|
@@ -3476,6 +3534,22 @@ var MageMetricsClient = class {
|
|
|
3476
3534
|
rowCount,
|
|
3477
3535
|
data: this.api.fetchReportData
|
|
3478
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;
|
|
3479
3553
|
}
|
|
3480
3554
|
};
|
|
3481
3555
|
client() {
|