@magemetrics/core 0.6.1 → 0.8.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 +210 -0
- package/dist/index.js +99 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -491,6 +491,18 @@ declare const inputSchema_7: z.ZodObject<{
|
|
|
491
491
|
query: z.ZodString;
|
|
492
492
|
}, z.core.$strip>;
|
|
493
493
|
|
|
494
|
+
declare const inputSchema_8: z.ZodObject<{
|
|
495
|
+
questions: z.ZodArray<z.ZodObject<{
|
|
496
|
+
question: z.ZodString;
|
|
497
|
+
header: z.ZodString;
|
|
498
|
+
multiSelect: z.ZodBoolean;
|
|
499
|
+
options: z.ZodArray<z.ZodObject<{
|
|
500
|
+
label: z.ZodString;
|
|
501
|
+
description: z.ZodString;
|
|
502
|
+
}, z.core.$strip>>;
|
|
503
|
+
}, z.core.$strip>>;
|
|
504
|
+
}, z.core.$strip>;
|
|
505
|
+
|
|
494
506
|
declare type InternalApiClient = Simplify<Client<NoAuthPaths, `${string}/${string}`>>;
|
|
495
507
|
|
|
496
508
|
export declare class MageMetricsChatTransport extends DefaultChatTransport<MMChatUIMessage> {
|
|
@@ -788,6 +800,7 @@ declare type MMUiTools = {
|
|
|
788
800
|
getAvailableTables: UiTool_5;
|
|
789
801
|
getAvailableColumnsForTable: UiTool_6;
|
|
790
802
|
webSearch: UiTool_7;
|
|
803
|
+
askUserQuestion: UiTool_8;
|
|
791
804
|
};
|
|
792
805
|
|
|
793
806
|
declare type NoAuthPaths = Simplify<{
|
|
@@ -1599,6 +1612,85 @@ declare interface operations {
|
|
|
1599
1612
|
};
|
|
1600
1613
|
};
|
|
1601
1614
|
};
|
|
1615
|
+
getColumnLineage: {
|
|
1616
|
+
parameters: {
|
|
1617
|
+
query?: never;
|
|
1618
|
+
header: {
|
|
1619
|
+
"sp-access-token": string;
|
|
1620
|
+
};
|
|
1621
|
+
path?: never;
|
|
1622
|
+
cookie?: never;
|
|
1623
|
+
};
|
|
1624
|
+
requestBody: {
|
|
1625
|
+
content: {
|
|
1626
|
+
"application/json": {
|
|
1627
|
+
/** @description The report id */
|
|
1628
|
+
report_id: number;
|
|
1629
|
+
/** @description The column name to get lineage for */
|
|
1630
|
+
column_name: string;
|
|
1631
|
+
};
|
|
1632
|
+
};
|
|
1633
|
+
};
|
|
1634
|
+
responses: {
|
|
1635
|
+
/** @description Column lineage data */
|
|
1636
|
+
200: {
|
|
1637
|
+
headers: {
|
|
1638
|
+
[name: string]: unknown;
|
|
1639
|
+
};
|
|
1640
|
+
content: {
|
|
1641
|
+
"application/json": {
|
|
1642
|
+
column_name: string;
|
|
1643
|
+
lineage: {
|
|
1644
|
+
nodes: {
|
|
1645
|
+
id: string;
|
|
1646
|
+
/** @enum {string} */
|
|
1647
|
+
type: "entity" | "attribute" | "filter" | "process" | "combine" | "result";
|
|
1648
|
+
explanation: string;
|
|
1649
|
+
}[];
|
|
1650
|
+
edges: {
|
|
1651
|
+
source: string;
|
|
1652
|
+
target: string;
|
|
1653
|
+
}[];
|
|
1654
|
+
};
|
|
1655
|
+
was_cached: boolean;
|
|
1656
|
+
};
|
|
1657
|
+
};
|
|
1658
|
+
};
|
|
1659
|
+
/** @description Invalid request - column not found in query results */
|
|
1660
|
+
400: {
|
|
1661
|
+
headers: {
|
|
1662
|
+
[name: string]: unknown;
|
|
1663
|
+
};
|
|
1664
|
+
content: {
|
|
1665
|
+
"application/json": {
|
|
1666
|
+
error: string;
|
|
1667
|
+
};
|
|
1668
|
+
};
|
|
1669
|
+
};
|
|
1670
|
+
/** @description report not found */
|
|
1671
|
+
404: {
|
|
1672
|
+
headers: {
|
|
1673
|
+
[name: string]: unknown;
|
|
1674
|
+
};
|
|
1675
|
+
content: {
|
|
1676
|
+
"application/json": {
|
|
1677
|
+
error: string;
|
|
1678
|
+
};
|
|
1679
|
+
};
|
|
1680
|
+
};
|
|
1681
|
+
/** @description Generation failed */
|
|
1682
|
+
500: {
|
|
1683
|
+
headers: {
|
|
1684
|
+
[name: string]: unknown;
|
|
1685
|
+
};
|
|
1686
|
+
content: {
|
|
1687
|
+
"application/json": {
|
|
1688
|
+
error: string;
|
|
1689
|
+
};
|
|
1690
|
+
};
|
|
1691
|
+
};
|
|
1692
|
+
};
|
|
1693
|
+
};
|
|
1602
1694
|
toggleBookmark: {
|
|
1603
1695
|
parameters: {
|
|
1604
1696
|
query?: never;
|
|
@@ -3083,6 +3175,79 @@ declare interface operations {
|
|
|
3083
3175
|
};
|
|
3084
3176
|
};
|
|
3085
3177
|
};
|
|
3178
|
+
tablePreview: {
|
|
3179
|
+
parameters: {
|
|
3180
|
+
query?: never;
|
|
3181
|
+
header?: never;
|
|
3182
|
+
path: {
|
|
3183
|
+
tableId: string;
|
|
3184
|
+
};
|
|
3185
|
+
cookie?: never;
|
|
3186
|
+
};
|
|
3187
|
+
requestBody?: never;
|
|
3188
|
+
responses: {
|
|
3189
|
+
/** @description Table preview executed successfully */
|
|
3190
|
+
200: {
|
|
3191
|
+
headers: {
|
|
3192
|
+
[name: string]: unknown;
|
|
3193
|
+
};
|
|
3194
|
+
content: {
|
|
3195
|
+
"application/json": {
|
|
3196
|
+
columns: {
|
|
3197
|
+
id: string;
|
|
3198
|
+
accessorKey: string;
|
|
3199
|
+
header: string;
|
|
3200
|
+
cell?: unknown;
|
|
3201
|
+
meta?: {
|
|
3202
|
+
[key: string]: unknown;
|
|
3203
|
+
};
|
|
3204
|
+
}[];
|
|
3205
|
+
data: {
|
|
3206
|
+
[key: string]: unknown;
|
|
3207
|
+
}[];
|
|
3208
|
+
metadata?: {
|
|
3209
|
+
wasSampled: boolean;
|
|
3210
|
+
originalCount: number;
|
|
3211
|
+
sampledCount: number;
|
|
3212
|
+
};
|
|
3213
|
+
};
|
|
3214
|
+
};
|
|
3215
|
+
};
|
|
3216
|
+
/** @description Invalid request */
|
|
3217
|
+
400: {
|
|
3218
|
+
headers: {
|
|
3219
|
+
[name: string]: unknown;
|
|
3220
|
+
};
|
|
3221
|
+
content: {
|
|
3222
|
+
"application/json": {
|
|
3223
|
+
error: string;
|
|
3224
|
+
};
|
|
3225
|
+
};
|
|
3226
|
+
};
|
|
3227
|
+
/** @description Table not found */
|
|
3228
|
+
404: {
|
|
3229
|
+
headers: {
|
|
3230
|
+
[name: string]: unknown;
|
|
3231
|
+
};
|
|
3232
|
+
content: {
|
|
3233
|
+
"application/json": {
|
|
3234
|
+
error: string;
|
|
3235
|
+
};
|
|
3236
|
+
};
|
|
3237
|
+
};
|
|
3238
|
+
/** @description Internal server error */
|
|
3239
|
+
500: {
|
|
3240
|
+
headers: {
|
|
3241
|
+
[name: string]: unknown;
|
|
3242
|
+
};
|
|
3243
|
+
content: {
|
|
3244
|
+
"application/json": {
|
|
3245
|
+
error: string;
|
|
3246
|
+
};
|
|
3247
|
+
};
|
|
3248
|
+
};
|
|
3249
|
+
};
|
|
3250
|
+
};
|
|
3086
3251
|
listSankeyUserFilters: {
|
|
3087
3252
|
parameters: {
|
|
3088
3253
|
query?: never;
|
|
@@ -3902,6 +4067,22 @@ declare interface paths {
|
|
|
3902
4067
|
patch?: never;
|
|
3903
4068
|
trace?: never;
|
|
3904
4069
|
};
|
|
4070
|
+
"/api/v1/workflows/column_lineage": {
|
|
4071
|
+
parameters: {
|
|
4072
|
+
query?: never;
|
|
4073
|
+
header?: never;
|
|
4074
|
+
path?: never;
|
|
4075
|
+
cookie?: never;
|
|
4076
|
+
};
|
|
4077
|
+
get?: never;
|
|
4078
|
+
put?: never;
|
|
4079
|
+
post: operations["getColumnLineage"];
|
|
4080
|
+
delete?: never;
|
|
4081
|
+
options?: never;
|
|
4082
|
+
head?: never;
|
|
4083
|
+
patch?: never;
|
|
4084
|
+
trace?: never;
|
|
4085
|
+
};
|
|
3905
4086
|
"/api/v1/timeline/bookmark": {
|
|
3906
4087
|
parameters: {
|
|
3907
4088
|
query?: never;
|
|
@@ -4302,6 +4483,22 @@ declare interface paths {
|
|
|
4302
4483
|
patch?: never;
|
|
4303
4484
|
trace?: never;
|
|
4304
4485
|
};
|
|
4486
|
+
"/api/v1/admin-console/tables/{tableId}/preview": {
|
|
4487
|
+
parameters: {
|
|
4488
|
+
query?: never;
|
|
4489
|
+
header?: never;
|
|
4490
|
+
path?: never;
|
|
4491
|
+
cookie?: never;
|
|
4492
|
+
};
|
|
4493
|
+
get: operations["tablePreview"];
|
|
4494
|
+
put?: never;
|
|
4495
|
+
post?: never;
|
|
4496
|
+
delete?: never;
|
|
4497
|
+
options?: never;
|
|
4498
|
+
head?: never;
|
|
4499
|
+
patch?: never;
|
|
4500
|
+
trace?: never;
|
|
4501
|
+
};
|
|
4305
4502
|
"/api/v1/admin-console/usage-insights/filters": {
|
|
4306
4503
|
parameters: {
|
|
4307
4504
|
query?: never;
|
|
@@ -4455,6 +4652,17 @@ declare const QuickActionsSchema: z.ZodArray<z.ZodObject<{
|
|
|
4455
4652
|
explanation: z.ZodString;
|
|
4456
4653
|
}, z.core.$strip>>;
|
|
4457
4654
|
|
|
4655
|
+
declare const RedactedAskUserQuestionResponse: z.ZodObject<{
|
|
4656
|
+
tool: z.ZodDefault<z.ZodLiteral<"askUserQuestion">>;
|
|
4657
|
+
result: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4658
|
+
status: z.ZodLiteral<"success">;
|
|
4659
|
+
answers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
4660
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
4661
|
+
status: z.ZodLiteral<"error">;
|
|
4662
|
+
message: z.ZodString;
|
|
4663
|
+
}, z.core.$strip>], "status">;
|
|
4664
|
+
}, z.core.$strip>;
|
|
4665
|
+
|
|
4458
4666
|
declare const redactedOutputSchema: z.ZodObject<{
|
|
4459
4667
|
tool: z.ZodLiteral<"generateDataReport">;
|
|
4460
4668
|
result: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -4612,6 +4820,8 @@ declare type UiTool_6 = InferUITool<Tool<z.infer<typeof inputSchema_6>, z.infer<
|
|
|
4612
4820
|
|
|
4613
4821
|
declare type UiTool_7 = InferUITool<Tool<z.infer<typeof inputSchema_7>, z.infer<typeof redactedOutputSchema_6>>>;
|
|
4614
4822
|
|
|
4823
|
+
declare type UiTool_8 = InferUITool<Tool<z.infer<typeof inputSchema_8>, z.infer<typeof RedactedAskUserQuestionResponse>>>;
|
|
4824
|
+
|
|
4615
4825
|
declare const UpdateCanvasSchema: z.ZodObject<{
|
|
4616
4826
|
id: z.ZodUUID;
|
|
4617
4827
|
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
package/dist/index.js
CHANGED
|
@@ -57,7 +57,7 @@ var addApiKeyHeader = (apiKey) => {
|
|
|
57
57
|
|
|
58
58
|
// package.json
|
|
59
59
|
var package_default = {
|
|
60
|
-
version: "0.
|
|
60
|
+
version: "0.8.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.1
|
|
154
|
+
// ../../node_modules/.pnpm/@asteasolutions+zod-to-openapi@8.1.0_zod@4.2.1/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)
|
|
@@ -468,6 +468,8 @@ function getOpenApiConfiguration(refOrOpenapi, metadataOrOptions, options) {
|
|
|
468
468
|
options: metadataOrOptions
|
|
469
469
|
};
|
|
470
470
|
}
|
|
471
|
+
|
|
472
|
+
// ../../node_modules/.pnpm/hono@4.11.1/node_modules/hono/dist/router/reg-exp-router/node.js
|
|
471
473
|
new Set(".\\+*[^]$()");
|
|
472
474
|
var createRoute = (routeConfig) => {
|
|
473
475
|
const route = {
|
|
@@ -1594,6 +1596,85 @@ createRoute({
|
|
|
1594
1596
|
}
|
|
1595
1597
|
}
|
|
1596
1598
|
});
|
|
1599
|
+
var ColumnLineageNodeSchema = z.object({
|
|
1600
|
+
id: z.string(),
|
|
1601
|
+
type: z.enum([
|
|
1602
|
+
"entity",
|
|
1603
|
+
"attribute",
|
|
1604
|
+
"filter",
|
|
1605
|
+
"process",
|
|
1606
|
+
"combine",
|
|
1607
|
+
"result"
|
|
1608
|
+
]),
|
|
1609
|
+
explanation: z.string()
|
|
1610
|
+
});
|
|
1611
|
+
var ColumnLineageEdgeSchema = z.object({
|
|
1612
|
+
source: z.string(),
|
|
1613
|
+
target: z.string()
|
|
1614
|
+
});
|
|
1615
|
+
var ColumnLineageResponseSchema = z.object({
|
|
1616
|
+
column_name: z.string(),
|
|
1617
|
+
lineage: z.object({
|
|
1618
|
+
nodes: z.array(ColumnLineageNodeSchema),
|
|
1619
|
+
edges: z.array(ColumnLineageEdgeSchema)
|
|
1620
|
+
}),
|
|
1621
|
+
was_cached: z.boolean()
|
|
1622
|
+
});
|
|
1623
|
+
createRoute({
|
|
1624
|
+
method: "post",
|
|
1625
|
+
path: "/api/v1/workflows/column_lineage",
|
|
1626
|
+
operationId: "getColumnLineage",
|
|
1627
|
+
request: {
|
|
1628
|
+
headers: SupabaseHeaderSchema,
|
|
1629
|
+
body: {
|
|
1630
|
+
required: true,
|
|
1631
|
+
content: {
|
|
1632
|
+
"application/json": {
|
|
1633
|
+
schema: z.object({
|
|
1634
|
+
report_id: z.number().int().describe("The report id"),
|
|
1635
|
+
column_name: z.string().describe("The column name to get lineage for")
|
|
1636
|
+
})
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
},
|
|
1641
|
+
responses: {
|
|
1642
|
+
200: {
|
|
1643
|
+
description: "Column lineage data",
|
|
1644
|
+
content: {
|
|
1645
|
+
"application/json": {
|
|
1646
|
+
schema: ColumnLineageResponseSchema
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
},
|
|
1650
|
+
400: {
|
|
1651
|
+
description: "Invalid request - column not found in query results",
|
|
1652
|
+
content: {
|
|
1653
|
+
"application/json": {
|
|
1654
|
+
schema: z.object({ error: z.string() })
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
},
|
|
1658
|
+
404: {
|
|
1659
|
+
description: "report not found",
|
|
1660
|
+
content: {
|
|
1661
|
+
"application/json": {
|
|
1662
|
+
schema: z.object({ error: z.string() })
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
},
|
|
1666
|
+
500: {
|
|
1667
|
+
description: "Generation failed",
|
|
1668
|
+
content: {
|
|
1669
|
+
"application/json": {
|
|
1670
|
+
schema: z.object({
|
|
1671
|
+
error: z.string()
|
|
1672
|
+
})
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
});
|
|
1597
1678
|
createRoute({
|
|
1598
1679
|
method: "get",
|
|
1599
1680
|
path: "/api/v1/data-reports/{report_id}",
|
|
@@ -3130,13 +3211,28 @@ var toSearchParams = ({ cursor, filters, sorting, limit }) => {
|
|
|
3130
3211
|
}
|
|
3131
3212
|
return params;
|
|
3132
3213
|
};
|
|
3214
|
+
var isToolResultMessage = (message) => {
|
|
3215
|
+
if (message.role !== "assistant") {
|
|
3216
|
+
return false;
|
|
3217
|
+
}
|
|
3218
|
+
return message.parts.some(
|
|
3219
|
+
(part) => part.type.startsWith("tool-") && "state" in part && part.state === "output-available"
|
|
3220
|
+
);
|
|
3221
|
+
};
|
|
3133
3222
|
var MageMetricsChatTransport = class extends DefaultChatTransport {
|
|
3134
3223
|
constructor(apiUrl, flowId, options) {
|
|
3135
3224
|
super({
|
|
3136
3225
|
...options,
|
|
3137
3226
|
api: `${apiUrl}/api/v1/chat/${flowId}`,
|
|
3138
3227
|
prepareSendMessagesRequest({ messages, id: chatId }) {
|
|
3139
|
-
|
|
3228
|
+
const lastMessage = messages.at(-1);
|
|
3229
|
+
if (lastMessage && isToolResultMessage(lastMessage)) {
|
|
3230
|
+
lastMessage.metadata = {
|
|
3231
|
+
...typeof lastMessage.metadata === "object" ? lastMessage.metadata : void 0,
|
|
3232
|
+
isFrontendToolSubmission: true
|
|
3233
|
+
};
|
|
3234
|
+
}
|
|
3235
|
+
return { body: { message: lastMessage, id: chatId } };
|
|
3140
3236
|
}
|
|
3141
3237
|
});
|
|
3142
3238
|
}
|