@magemetrics/core 0.11.6 → 0.12.0-rc1
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 +170 -21
- package/dist/index.js +98 -34
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -428,6 +428,8 @@ declare interface components {
|
|
|
428
428
|
/** @enum {string} */
|
|
429
429
|
model: "claude-haiku-4-5";
|
|
430
430
|
} | null;
|
|
431
|
+
/** @enum {string} */
|
|
432
|
+
execution_platform: "native" | "sandbox" | "sandbox_public";
|
|
431
433
|
master_prompt_name: string | null;
|
|
432
434
|
master_prompt_version: number | null;
|
|
433
435
|
created_at: string;
|
|
@@ -484,27 +486,12 @@ declare const CreateCanvasSchema: z.ZodObject<{
|
|
|
484
486
|
flow_id: z.ZodOptional<z.ZodString>;
|
|
485
487
|
}, z.core.$strip>;
|
|
486
488
|
|
|
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
|
-
|
|
502
489
|
/**
|
|
503
490
|
* Parameters for starting a flow
|
|
504
491
|
*/
|
|
505
492
|
export declare type CreateFlowParam = {
|
|
506
493
|
query: string;
|
|
507
|
-
|
|
494
|
+
uploadedFileIds?: UploadedFileId[];
|
|
508
495
|
} | {
|
|
509
496
|
triggerId: string;
|
|
510
497
|
variables: Record<string, string>;
|
|
@@ -621,6 +608,9 @@ declare const FrontendRecentFlowsSchema: z.ZodObject<{
|
|
|
621
608
|
created_at: z.ZodString;
|
|
622
609
|
application_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
623
610
|
user_id: z.ZodNullable<z.ZodString>;
|
|
611
|
+
context_tokens: z.ZodOptional<z.ZodNumber>;
|
|
612
|
+
acc_input_tokens: z.ZodOptional<z.ZodNumber>;
|
|
613
|
+
acc_output_tokens: z.ZodOptional<z.ZodNumber>;
|
|
624
614
|
}, z.core.$strip>;
|
|
625
615
|
|
|
626
616
|
export declare const getPublicApiClient: (apiUrl: string, apiKey: string) => Client<PublicPaths>;
|
|
@@ -631,11 +621,6 @@ declare const inputSchema: z.ZodObject<{
|
|
|
631
621
|
rawRequest: z.ZodString;
|
|
632
622
|
userRequest: z.ZodString;
|
|
633
623
|
isNewAnalysisGoal: z.ZodBoolean;
|
|
634
|
-
responseType: z.ZodEnum<{
|
|
635
|
-
text: "text";
|
|
636
|
-
visualization: "visualization";
|
|
637
|
-
table: "table";
|
|
638
|
-
}>;
|
|
639
624
|
difficultyLevel: z.ZodEnum<{
|
|
640
625
|
simple: "simple";
|
|
641
626
|
moderate: "moderate";
|
|
@@ -842,6 +827,9 @@ export declare class MageMetricsClient {
|
|
|
842
827
|
title: string | null;
|
|
843
828
|
user_id: string | null;
|
|
844
829
|
application_id?: number | null | undefined;
|
|
830
|
+
context_tokens?: number | undefined;
|
|
831
|
+
acc_input_tokens?: number | undefined;
|
|
832
|
+
acc_output_tokens?: number | undefined;
|
|
845
833
|
}>;
|
|
846
834
|
getRecentFlows: (params?: {
|
|
847
835
|
limit?: number;
|
|
@@ -849,6 +837,13 @@ export declare class MageMetricsClient {
|
|
|
849
837
|
createFlow: (request: CreateFlowParam) => Promise<{
|
|
850
838
|
flowId: string;
|
|
851
839
|
}>;
|
|
840
|
+
uploadFile: (file: File, flowId?: string) => Promise<{
|
|
841
|
+
uploadedFileId: string;
|
|
842
|
+
filename: string;
|
|
843
|
+
mediaType: string;
|
|
844
|
+
sizeBytes: number;
|
|
845
|
+
}>;
|
|
846
|
+
deleteUploadedFile: (uploadedFileId: string) => Promise<void>;
|
|
852
847
|
canvas: {
|
|
853
848
|
list: (query?: string) => Promise<{
|
|
854
849
|
id: string;
|
|
@@ -863,6 +858,9 @@ export declare class MageMetricsClient {
|
|
|
863
858
|
title: string | null;
|
|
864
859
|
user_id: string | null;
|
|
865
860
|
application_id?: number | null | undefined;
|
|
861
|
+
context_tokens?: number | undefined;
|
|
862
|
+
acc_input_tokens?: number | undefined;
|
|
863
|
+
acc_output_tokens?: number | undefined;
|
|
866
864
|
}[];
|
|
867
865
|
}[]>;
|
|
868
866
|
get: (canvasId: string) => Promise<{
|
|
@@ -1369,6 +1367,9 @@ declare interface operations {
|
|
|
1369
1367
|
title: string | null;
|
|
1370
1368
|
user_id: string | null;
|
|
1371
1369
|
application_id?: number | null;
|
|
1370
|
+
context_tokens?: number;
|
|
1371
|
+
acc_input_tokens?: number;
|
|
1372
|
+
acc_output_tokens?: number;
|
|
1372
1373
|
};
|
|
1373
1374
|
};
|
|
1374
1375
|
};
|
|
@@ -1422,6 +1423,9 @@ declare interface operations {
|
|
|
1422
1423
|
title: string | null;
|
|
1423
1424
|
user_id: string | null;
|
|
1424
1425
|
application_id?: number | null;
|
|
1426
|
+
context_tokens?: number;
|
|
1427
|
+
acc_input_tokens?: number;
|
|
1428
|
+
acc_output_tokens?: number;
|
|
1425
1429
|
}[];
|
|
1426
1430
|
};
|
|
1427
1431
|
};
|
|
@@ -2173,6 +2177,7 @@ declare interface operations {
|
|
|
2173
2177
|
filename?: string;
|
|
2174
2178
|
url: string;
|
|
2175
2179
|
}[];
|
|
2180
|
+
uploadedFileIds?: string[];
|
|
2176
2181
|
};
|
|
2177
2182
|
};
|
|
2178
2183
|
};
|
|
@@ -2966,6 +2971,9 @@ declare interface operations {
|
|
|
2966
2971
|
title: string | null;
|
|
2967
2972
|
user_id: string | null;
|
|
2968
2973
|
application_id?: number | null;
|
|
2974
|
+
context_tokens?: number;
|
|
2975
|
+
acc_input_tokens?: number;
|
|
2976
|
+
acc_output_tokens?: number;
|
|
2969
2977
|
}[];
|
|
2970
2978
|
}[];
|
|
2971
2979
|
};
|
|
@@ -3279,6 +3287,11 @@ declare interface operations {
|
|
|
3279
3287
|
/** @enum {string} */
|
|
3280
3288
|
model: "claude-haiku-4-5";
|
|
3281
3289
|
};
|
|
3290
|
+
/**
|
|
3291
|
+
* @default native
|
|
3292
|
+
* @enum {string}
|
|
3293
|
+
*/
|
|
3294
|
+
execution_platform?: "native" | "sandbox" | "sandbox_public";
|
|
3282
3295
|
master_prompt_name?: string;
|
|
3283
3296
|
master_prompt_version?: number;
|
|
3284
3297
|
};
|
|
@@ -3433,6 +3446,8 @@ declare interface operations {
|
|
|
3433
3446
|
/** @enum {string} */
|
|
3434
3447
|
model: "claude-haiku-4-5";
|
|
3435
3448
|
} | null;
|
|
3449
|
+
/** @enum {string} */
|
|
3450
|
+
execution_platform?: "native" | "sandbox" | "sandbox_public";
|
|
3436
3451
|
master_prompt_name?: string | null;
|
|
3437
3452
|
master_prompt_version?: number | null;
|
|
3438
3453
|
};
|
|
@@ -5138,6 +5153,119 @@ declare interface operations {
|
|
|
5138
5153
|
};
|
|
5139
5154
|
};
|
|
5140
5155
|
};
|
|
5156
|
+
generateDataReport: {
|
|
5157
|
+
parameters: {
|
|
5158
|
+
query?: never;
|
|
5159
|
+
header?: {
|
|
5160
|
+
"sp-access-token"?: string;
|
|
5161
|
+
};
|
|
5162
|
+
path?: never;
|
|
5163
|
+
cookie?: never;
|
|
5164
|
+
};
|
|
5165
|
+
requestBody: {
|
|
5166
|
+
content: {
|
|
5167
|
+
"application/json": {
|
|
5168
|
+
/** @description The natural language data request */
|
|
5169
|
+
request: string;
|
|
5170
|
+
};
|
|
5171
|
+
};
|
|
5172
|
+
};
|
|
5173
|
+
responses: {
|
|
5174
|
+
/** @description Data report generated successfully */
|
|
5175
|
+
200: {
|
|
5176
|
+
headers: {
|
|
5177
|
+
[name: string]: unknown;
|
|
5178
|
+
};
|
|
5179
|
+
content: {
|
|
5180
|
+
"application/json": {
|
|
5181
|
+
/** @enum {string} */
|
|
5182
|
+
status: "success";
|
|
5183
|
+
generation_id: string;
|
|
5184
|
+
sql: string;
|
|
5185
|
+
title: string | null;
|
|
5186
|
+
goal: string | null;
|
|
5187
|
+
view_name: string | null;
|
|
5188
|
+
view_schema: string | null;
|
|
5189
|
+
data_sample: {
|
|
5190
|
+
[key: string]: unknown;
|
|
5191
|
+
}[] | null;
|
|
5192
|
+
data_summary: {
|
|
5193
|
+
[key: string]: unknown;
|
|
5194
|
+
} | null;
|
|
5195
|
+
is_sample: boolean;
|
|
5196
|
+
};
|
|
5197
|
+
};
|
|
5198
|
+
};
|
|
5199
|
+
/** @description Invalid request */
|
|
5200
|
+
400: {
|
|
5201
|
+
headers: {
|
|
5202
|
+
[name: string]: unknown;
|
|
5203
|
+
};
|
|
5204
|
+
content: {
|
|
5205
|
+
"application/json": {
|
|
5206
|
+
error: string;
|
|
5207
|
+
};
|
|
5208
|
+
};
|
|
5209
|
+
};
|
|
5210
|
+
/** @description Service account authentication required */
|
|
5211
|
+
403: {
|
|
5212
|
+
headers: {
|
|
5213
|
+
[name: string]: unknown;
|
|
5214
|
+
};
|
|
5215
|
+
content: {
|
|
5216
|
+
"application/json": {
|
|
5217
|
+
error: string;
|
|
5218
|
+
};
|
|
5219
|
+
};
|
|
5220
|
+
};
|
|
5221
|
+
/** @description SQL generation failed */
|
|
5222
|
+
422: {
|
|
5223
|
+
headers: {
|
|
5224
|
+
[name: string]: unknown;
|
|
5225
|
+
};
|
|
5226
|
+
content: {
|
|
5227
|
+
"application/json": {
|
|
5228
|
+
/** @enum {string} */
|
|
5229
|
+
status: "error";
|
|
5230
|
+
error: string;
|
|
5231
|
+
error_info?: {
|
|
5232
|
+
error_message: string;
|
|
5233
|
+
/** @enum {string} */
|
|
5234
|
+
category: "timeout" | "connection_error" | "auth_error" | "resource_exhausted" | "table_not_found" | "column_not_found" | "schema_not_found" | "view_not_found" | "function_not_found" | "syntax_error" | "ambiguous_column" | "type_mismatch" | "invalid_cast" | "invalid_argument" | "division_by_zero" | "constraint_violation" | "permission_denied" | "unknown";
|
|
5235
|
+
details?: string | null;
|
|
5236
|
+
hint?: string | null;
|
|
5237
|
+
line_num?: number | null;
|
|
5238
|
+
col_num?: number | null;
|
|
5239
|
+
} | null;
|
|
5240
|
+
failed_sql?: string | null;
|
|
5241
|
+
};
|
|
5242
|
+
};
|
|
5243
|
+
};
|
|
5244
|
+
/** @description Rate limit exceeded for this API key */
|
|
5245
|
+
429: {
|
|
5246
|
+
headers: {
|
|
5247
|
+
[name: string]: unknown;
|
|
5248
|
+
};
|
|
5249
|
+
content: {
|
|
5250
|
+
"application/json": {
|
|
5251
|
+
error: string;
|
|
5252
|
+
retry_after_ms: number;
|
|
5253
|
+
};
|
|
5254
|
+
};
|
|
5255
|
+
};
|
|
5256
|
+
/** @description Internal server error */
|
|
5257
|
+
500: {
|
|
5258
|
+
headers: {
|
|
5259
|
+
[name: string]: unknown;
|
|
5260
|
+
};
|
|
5261
|
+
content: {
|
|
5262
|
+
"application/json": {
|
|
5263
|
+
error: string;
|
|
5264
|
+
};
|
|
5265
|
+
};
|
|
5266
|
+
};
|
|
5267
|
+
};
|
|
5268
|
+
};
|
|
5141
5269
|
}
|
|
5142
5270
|
|
|
5143
5271
|
declare type PatchParam<T, Config extends RemoveParamsConfig, P extends keyof Config> = Simplify<T extends {
|
|
@@ -5902,6 +6030,22 @@ declare interface paths {
|
|
|
5902
6030
|
patch: operations["updateTableColumn"];
|
|
5903
6031
|
trace?: never;
|
|
5904
6032
|
};
|
|
6033
|
+
"/api/v1/data-reports/generate": {
|
|
6034
|
+
parameters: {
|
|
6035
|
+
query?: never;
|
|
6036
|
+
header?: never;
|
|
6037
|
+
path?: never;
|
|
6038
|
+
cookie?: never;
|
|
6039
|
+
};
|
|
6040
|
+
get?: never;
|
|
6041
|
+
put?: never;
|
|
6042
|
+
post: operations["generateDataReport"];
|
|
6043
|
+
delete?: never;
|
|
6044
|
+
options?: never;
|
|
6045
|
+
head?: never;
|
|
6046
|
+
patch?: never;
|
|
6047
|
+
trace?: never;
|
|
6048
|
+
};
|
|
5905
6049
|
}
|
|
5906
6050
|
|
|
5907
6051
|
declare type PublicApiClient = Simplify<Client<PublicPaths, `${string}/${string}`>>;
|
|
@@ -6151,4 +6295,9 @@ declare const UpdateCanvasSchema: z.ZodObject<{
|
|
|
6151
6295
|
is_public: z.ZodOptional<z.ZodBoolean>;
|
|
6152
6296
|
}, z.core.$strip>;
|
|
6153
6297
|
|
|
6298
|
+
/** A previously uploaded file identifier to attach to the first message of a flow. */
|
|
6299
|
+
declare type UploadedFileId = default_2.infer<typeof UploadedFileIdSchema>;
|
|
6300
|
+
|
|
6301
|
+
declare const UploadedFileIdSchema: z.ZodUUID;
|
|
6302
|
+
|
|
6154
6303
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sha256 } from '@noble/hashes/sha2.js';
|
|
2
|
-
import
|
|
2
|
+
import z8, { 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.
|
|
61
|
+
version: "0.12.0-rc1"};
|
|
62
62
|
|
|
63
63
|
// src/core/MageMetricsEventEmitter.ts
|
|
64
64
|
var MageMetricsEventEmitter = class {
|
|
@@ -152,7 +152,7 @@ var hashString = (value) => {
|
|
|
152
152
|
return Array.from(hash).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
153
153
|
};
|
|
154
154
|
|
|
155
|
-
// ../../node_modules/.pnpm/@asteasolutions+zod-to-openapi@8.
|
|
155
|
+
// ../../node_modules/.pnpm/@asteasolutions+zod-to-openapi@8.5.0_zod@4.3.6/node_modules/@asteasolutions/zod-to-openapi/dist/index.mjs
|
|
156
156
|
function __rest(s, e) {
|
|
157
157
|
var t = {};
|
|
158
158
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -313,7 +313,7 @@ var Metadata = class {
|
|
|
313
313
|
}
|
|
314
314
|
static getOpenApiMetadata(zodSchema) {
|
|
315
315
|
const metadata = this.collectMetadata(zodSchema);
|
|
316
|
-
const _a = metadata !== null && metadata !== void 0 ? metadata : {}, rest = __rest(_a, ["_internal"]);
|
|
316
|
+
const _a = metadata !== null && metadata !== void 0 ? metadata : {}, { _internal } = _a, rest = __rest(_a, ["_internal"]);
|
|
317
317
|
return rest;
|
|
318
318
|
}
|
|
319
319
|
static getInternalMetadata(zodSchema) {
|
|
@@ -917,7 +917,11 @@ var DatabaseFlowSchema = z.object({
|
|
|
917
917
|
title: z.string().nullable(),
|
|
918
918
|
user_id: z.string().nullable(),
|
|
919
919
|
application_id: z.number().nullable().optional(),
|
|
920
|
-
flow_steps: z.array(FlowStepSchema)
|
|
920
|
+
flow_steps: z.array(FlowStepSchema),
|
|
921
|
+
// Token usage tracking (provider-reported)
|
|
922
|
+
context_tokens: z.number().optional(),
|
|
923
|
+
acc_input_tokens: z.number().optional(),
|
|
924
|
+
acc_output_tokens: z.number().optional()
|
|
921
925
|
});
|
|
922
926
|
z.object({
|
|
923
927
|
table: z.string(),
|
|
@@ -1196,6 +1200,18 @@ var columnsQueryParams = z.string().transform((str) => {
|
|
|
1196
1200
|
var CHAT_MAX_FILE_COUNT = 10;
|
|
1197
1201
|
var CHAT_ALLOWED_FILE_MEDIA_TYPES = /* @__PURE__ */ new Set(["application/pdf"]);
|
|
1198
1202
|
[...CHAT_ALLOWED_FILE_MEDIA_TYPES].join(",");
|
|
1203
|
+
var UploadedFileIdSchema = z.uuid();
|
|
1204
|
+
var UploadedFileSchema = z.object({
|
|
1205
|
+
uploadedFileId: UploadedFileIdSchema,
|
|
1206
|
+
filename: z.string(),
|
|
1207
|
+
mediaType: z.string(),
|
|
1208
|
+
sizeBytes: z.number().int().nonnegative()
|
|
1209
|
+
});
|
|
1210
|
+
z.object({
|
|
1211
|
+
uploadedFileId: UploadedFileIdSchema
|
|
1212
|
+
});
|
|
1213
|
+
var CreateUploadedFilePath = "/api/v1/uploaded-files";
|
|
1214
|
+
var DeleteUploadedFilePath = "/api/v1/uploaded-files/{uploadedFileId}";
|
|
1199
1215
|
|
|
1200
1216
|
// ../shared/dist/src/endpoints/companion/flows.routes.js
|
|
1201
1217
|
var FlowIdParam = z.object({ flowId: z.uuid() }).openapi("FlowId", { type: "string" });
|
|
@@ -1882,7 +1898,8 @@ var CreateFlow = createRoute({
|
|
|
1882
1898
|
schema: z.object({
|
|
1883
1899
|
userQuery: z.string(),
|
|
1884
1900
|
applicationName: z.string().optional(),
|
|
1885
|
-
files: z.array(CreateFlowFileSchema).max(CHAT_MAX_FILE_COUNT).optional()
|
|
1901
|
+
files: z.array(CreateFlowFileSchema).max(CHAT_MAX_FILE_COUNT).optional(),
|
|
1902
|
+
uploadedFileIds: z.array(UploadedFileIdSchema).max(CHAT_MAX_FILE_COUNT).optional()
|
|
1886
1903
|
})
|
|
1887
1904
|
}
|
|
1888
1905
|
}
|
|
@@ -1998,20 +2015,20 @@ var CreateSpeechToken = createRoute({
|
|
|
1998
2015
|
}
|
|
1999
2016
|
}
|
|
2000
2017
|
});
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
status:
|
|
2004
|
-
error:
|
|
2018
|
+
z8.discriminatedUnion("status", [
|
|
2019
|
+
z8.object({
|
|
2020
|
+
status: z8.literal("error"),
|
|
2021
|
+
error: z8.string()
|
|
2005
2022
|
}),
|
|
2006
|
-
|
|
2007
|
-
status:
|
|
2008
|
-
flowId:
|
|
2023
|
+
z8.object({
|
|
2024
|
+
status: z8.literal("success"),
|
|
2025
|
+
flowId: z8.string()
|
|
2009
2026
|
})
|
|
2010
2027
|
]);
|
|
2011
|
-
var TriggerFlowBody =
|
|
2012
|
-
triggerId:
|
|
2013
|
-
variables:
|
|
2014
|
-
applicationName:
|
|
2028
|
+
var TriggerFlowBody = z8.object({
|
|
2029
|
+
triggerId: z8.string(),
|
|
2030
|
+
variables: z8.record(z8.string(), z8.string()),
|
|
2031
|
+
applicationName: z8.string().optional()
|
|
2015
2032
|
});
|
|
2016
2033
|
var TriggerFlow = createRoute({
|
|
2017
2034
|
method: "post",
|
|
@@ -2035,9 +2052,9 @@ var TriggerFlow = createRoute({
|
|
|
2035
2052
|
description: "Flow id",
|
|
2036
2053
|
content: {
|
|
2037
2054
|
"application/json": {
|
|
2038
|
-
schema:
|
|
2039
|
-
status:
|
|
2040
|
-
flowId:
|
|
2055
|
+
schema: z8.object({
|
|
2056
|
+
status: z8.literal("success"),
|
|
2057
|
+
flowId: z8.string()
|
|
2041
2058
|
})
|
|
2042
2059
|
}
|
|
2043
2060
|
}
|
|
@@ -2045,8 +2062,8 @@ var TriggerFlow = createRoute({
|
|
|
2045
2062
|
400: {
|
|
2046
2063
|
content: {
|
|
2047
2064
|
"application/json": {
|
|
2048
|
-
schema:
|
|
2049
|
-
error:
|
|
2065
|
+
schema: z8.object({
|
|
2066
|
+
error: z8.string()
|
|
2050
2067
|
})
|
|
2051
2068
|
}
|
|
2052
2069
|
},
|
|
@@ -2055,7 +2072,7 @@ var TriggerFlow = createRoute({
|
|
|
2055
2072
|
404: {
|
|
2056
2073
|
content: {
|
|
2057
2074
|
"application/json": {
|
|
2058
|
-
schema:
|
|
2075
|
+
schema: z8.object({ error: z8.string() })
|
|
2059
2076
|
}
|
|
2060
2077
|
},
|
|
2061
2078
|
description: "Unable to retrieve trigger with this id"
|
|
@@ -2064,8 +2081,8 @@ var TriggerFlow = createRoute({
|
|
|
2064
2081
|
description: "Something wrong happened",
|
|
2065
2082
|
content: {
|
|
2066
2083
|
"application/json": {
|
|
2067
|
-
schema:
|
|
2068
|
-
error:
|
|
2084
|
+
schema: z8.object({
|
|
2085
|
+
error: z8.string()
|
|
2069
2086
|
})
|
|
2070
2087
|
}
|
|
2071
2088
|
}
|
|
@@ -2095,9 +2112,9 @@ createRoute({
|
|
|
2095
2112
|
description: "Flow id",
|
|
2096
2113
|
content: {
|
|
2097
2114
|
"application/json": {
|
|
2098
|
-
schema:
|
|
2099
|
-
status:
|
|
2100
|
-
flowId:
|
|
2115
|
+
schema: z8.object({
|
|
2116
|
+
status: z8.literal("success"),
|
|
2117
|
+
flowId: z8.string()
|
|
2101
2118
|
})
|
|
2102
2119
|
}
|
|
2103
2120
|
}
|
|
@@ -2105,8 +2122,8 @@ createRoute({
|
|
|
2105
2122
|
400: {
|
|
2106
2123
|
content: {
|
|
2107
2124
|
"application/json": {
|
|
2108
|
-
schema:
|
|
2109
|
-
error:
|
|
2125
|
+
schema: z8.object({
|
|
2126
|
+
error: z8.string()
|
|
2110
2127
|
})
|
|
2111
2128
|
}
|
|
2112
2129
|
},
|
|
@@ -2115,7 +2132,7 @@ createRoute({
|
|
|
2115
2132
|
404: {
|
|
2116
2133
|
content: {
|
|
2117
2134
|
"application/json": {
|
|
2118
|
-
schema:
|
|
2135
|
+
schema: z8.object({ error: z8.string() })
|
|
2119
2136
|
}
|
|
2120
2137
|
},
|
|
2121
2138
|
description: "Unable to retrieve trigger with this id"
|
|
@@ -2124,8 +2141,8 @@ createRoute({
|
|
|
2124
2141
|
description: "Something wrong happened",
|
|
2125
2142
|
content: {
|
|
2126
2143
|
"application/json": {
|
|
2127
|
-
schema:
|
|
2128
|
-
error:
|
|
2144
|
+
schema: z8.object({
|
|
2145
|
+
error: z8.string()
|
|
2129
2146
|
})
|
|
2130
2147
|
}
|
|
2131
2148
|
}
|
|
@@ -3234,7 +3251,7 @@ var MageMetricsClient = class {
|
|
|
3234
3251
|
body: {
|
|
3235
3252
|
userQuery: request.query,
|
|
3236
3253
|
applicationName: this.config.applicationName,
|
|
3237
|
-
|
|
3254
|
+
uploadedFileIds: request.uploadedFileIds
|
|
3238
3255
|
}
|
|
3239
3256
|
}
|
|
3240
3257
|
);
|
|
@@ -3270,6 +3287,53 @@ var MageMetricsClient = class {
|
|
|
3270
3287
|
return { flowId: data.flowId };
|
|
3271
3288
|
}
|
|
3272
3289
|
},
|
|
3290
|
+
uploadFile: async (file, flowId) => {
|
|
3291
|
+
await this.waitForAuth();
|
|
3292
|
+
const formData = new FormData();
|
|
3293
|
+
formData.append("file", file);
|
|
3294
|
+
const url = new URL(`${this.config.apiUrl}${CreateUploadedFilePath}`);
|
|
3295
|
+
if (flowId) {
|
|
3296
|
+
url.searchParams.set("flowId", flowId);
|
|
3297
|
+
}
|
|
3298
|
+
const response = await fetch(url, {
|
|
3299
|
+
method: "POST",
|
|
3300
|
+
headers: await this.getHeaders(),
|
|
3301
|
+
body: formData
|
|
3302
|
+
});
|
|
3303
|
+
const data = await response.json();
|
|
3304
|
+
if (!response.ok) {
|
|
3305
|
+
const error = typeof data === "object" && data !== null && "error" in data && typeof data.error === "string" ? data.error : "File upload failed";
|
|
3306
|
+
throw new ApiError(error, response, {
|
|
3307
|
+
status: response.status,
|
|
3308
|
+
statusText: response.statusText,
|
|
3309
|
+
url: response.url,
|
|
3310
|
+
method: "POST"
|
|
3311
|
+
});
|
|
3312
|
+
}
|
|
3313
|
+
return UploadedFileSchema.parse(data);
|
|
3314
|
+
},
|
|
3315
|
+
deleteUploadedFile: async (uploadedFileId) => {
|
|
3316
|
+
await this.waitForAuth();
|
|
3317
|
+
const path = DeleteUploadedFilePath.replace(
|
|
3318
|
+
"{uploadedFileId}",
|
|
3319
|
+
uploadedFileId
|
|
3320
|
+
);
|
|
3321
|
+
const response = await fetch(`${this.config.apiUrl}${path}`, {
|
|
3322
|
+
method: "DELETE",
|
|
3323
|
+
headers: await this.getHeaders()
|
|
3324
|
+
});
|
|
3325
|
+
if (response.ok) {
|
|
3326
|
+
return;
|
|
3327
|
+
}
|
|
3328
|
+
const data = await response.json().catch(() => null);
|
|
3329
|
+
const error = typeof data === "object" && data !== null && "error" in data && typeof data.error === "string" ? data.error : "Failed to delete uploaded file";
|
|
3330
|
+
throw new ApiError(error, response, {
|
|
3331
|
+
status: response.status,
|
|
3332
|
+
statusText: response.statusText,
|
|
3333
|
+
url: response.url,
|
|
3334
|
+
method: "DELETE"
|
|
3335
|
+
});
|
|
3336
|
+
},
|
|
3273
3337
|
canvas: {
|
|
3274
3338
|
list: async (query) => {
|
|
3275
3339
|
await this.waitForAuth();
|