@magemetrics/core 0.4.2 → 0.5.0

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 CHANGED
@@ -266,10 +266,12 @@ declare const ExtractInsightResponseSchema: z.ZodUnion<[z.ZodObject<{
266
266
  declare type FrontendRecentFlows = z.infer<typeof FrontendRecentFlowsSchema>;
267
267
 
268
268
  declare const FrontendRecentFlowsSchema: z.ZodObject<{
269
+ title: z.ZodNullable<z.ZodString>;
269
270
  id: z.ZodString;
270
271
  request: z.ZodString;
271
272
  created_at: z.ZodString;
272
273
  user_id: z.ZodNullable<z.ZodString>;
274
+ application_id: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
273
275
  }, z.core.$strip>;
274
276
 
275
277
  /**
@@ -304,10 +306,6 @@ declare const inputSchema_2: z.ZodObject<{
304
306
  scatter: "scatter";
305
307
  pie: "pie";
306
308
  }>;
307
- columnConfiguration: z.ZodObject<{
308
- dimensionColumn: z.ZodString;
309
- valueColumns: z.ZodArray<z.ZodString>;
310
- }, z.core.$strip>;
311
309
  explanations: z.ZodString;
312
310
  }, z.core.$strip>;
313
311
 
@@ -466,6 +464,14 @@ export declare class MageMetricsClient {
466
464
  status: string | null;
467
465
  is_removed: boolean;
468
466
  }[]>;
467
+ getFlow: (flowId: string) => Promise<{
468
+ created_at: string;
469
+ id: string;
470
+ request: string;
471
+ title: string | null;
472
+ user_id: string | null;
473
+ application_id?: number | null;
474
+ }>;
469
475
  getRecentFlows: (params?: {
470
476
  limit?: number;
471
477
  }) => Promise<FrontendRecentFlows[]>;
@@ -474,21 +480,26 @@ export declare class MageMetricsClient {
474
480
  }>;
475
481
  canvas: {
476
482
  list: (query?: string) => Promise<{
477
- title: string | null;
478
483
  id: string;
479
- nodes: any[];
480
- edges: any[];
484
+ title: string | null;
481
485
  is_public: boolean;
482
- canvas_flows: {
483
- flow_id: string;
486
+ nodes: unknown[];
487
+ edges: unknown[];
488
+ flows: {
489
+ created_at: string;
490
+ id: string;
491
+ request: string;
492
+ title: string | null;
493
+ user_id: string | null;
494
+ application_id?: number | null;
484
495
  }[];
485
496
  }[]>;
486
497
  get: (canvasId: string) => Promise<{
487
- title: string | null;
488
498
  id: string;
489
- nodes: any[];
490
- edges: any[];
499
+ title: string | null;
491
500
  is_public: boolean;
501
+ nodes: unknown[];
502
+ edges: unknown[];
492
503
  }>;
493
504
  create: (body: CreateCanvas) => Promise<{
494
505
  id: string;
@@ -515,6 +526,10 @@ export declare class MageMetricsClient {
515
526
  fetchReportData: (reportId: number, { columns, limit, sorting, filters, cursor }: ReportDataFilters, signal?: AbortSignal) => Promise<{
516
527
  [key: string]: unknown;
517
528
  }[]>;
529
+ createSpeechToken: () => Promise<{
530
+ token: string;
531
+ expiresAt: string;
532
+ }>;
518
533
  getReport: (reportId: number) => Promise<{
519
534
  columns: {
520
535
  name: string;
@@ -563,6 +578,7 @@ export declare interface MageMetricsClientConfig {
563
578
  externalJwt?: string;
564
579
  additionalHeaders?: Record<string, string>;
565
580
  storageAdapter?: AsyncStorage_2;
581
+ applicationName?: string;
566
582
  }
567
583
 
568
584
  /**
@@ -1040,9 +1056,9 @@ declare interface operations {
1040
1056
  created_at: string;
1041
1057
  id: string;
1042
1058
  request: string;
1059
+ title: string | null;
1043
1060
  user_id: string | null;
1044
- user_friendly_goal?: string;
1045
- has_chat_messages: boolean;
1061
+ application_id?: number | null;
1046
1062
  };
1047
1063
  };
1048
1064
  };
@@ -1093,7 +1109,9 @@ declare interface operations {
1093
1109
  created_at: string;
1094
1110
  id: string;
1095
1111
  request: string;
1112
+ title: string | null;
1096
1113
  user_id: string | null;
1114
+ application_id?: number | null;
1097
1115
  }[];
1098
1116
  };
1099
1117
  };
@@ -1838,6 +1856,7 @@ declare interface operations {
1838
1856
  content: {
1839
1857
  "application/json": {
1840
1858
  userQuery: string;
1859
+ applicationName?: string;
1841
1860
  };
1842
1861
  };
1843
1862
  };
@@ -1855,6 +1874,17 @@ declare interface operations {
1855
1874
  };
1856
1875
  };
1857
1876
  };
1877
+ /** @description Application not found */
1878
+ 400: {
1879
+ headers: {
1880
+ [name: string]: unknown;
1881
+ };
1882
+ content: {
1883
+ "application/json": {
1884
+ error: string;
1885
+ };
1886
+ };
1887
+ };
1858
1888
  /** @description Something wrong happened */
1859
1889
  500: {
1860
1890
  headers: {
@@ -1918,6 +1948,47 @@ declare interface operations {
1918
1948
  };
1919
1949
  };
1920
1950
  };
1951
+ createSpeechToken: {
1952
+ parameters: {
1953
+ query?: never;
1954
+ header: {
1955
+ "sp-access-token": string;
1956
+ };
1957
+ path?: never;
1958
+ cookie?: never;
1959
+ };
1960
+ requestBody?: never;
1961
+ responses: {
1962
+ /** @description A short-lived token that can be used to stream audio. */
1963
+ 200: {
1964
+ headers: {
1965
+ [name: string]: unknown;
1966
+ };
1967
+ content: {
1968
+ "application/json": {
1969
+ /** @description Temporary AssemblyAI streaming token */
1970
+ token: string;
1971
+ /**
1972
+ * Format: date-time
1973
+ * @description ISO timestamp describing when the token expires.
1974
+ */
1975
+ expiresAt: string;
1976
+ };
1977
+ };
1978
+ };
1979
+ /** @description Failed to create a speech token */
1980
+ 500: {
1981
+ headers: {
1982
+ [name: string]: unknown;
1983
+ };
1984
+ content: {
1985
+ "application/json": {
1986
+ error: string;
1987
+ };
1988
+ };
1989
+ };
1990
+ };
1991
+ };
1921
1992
  getStarterRecommendations: {
1922
1993
  parameters: {
1923
1994
  query?: {
@@ -2436,8 +2507,13 @@ declare interface operations {
2436
2507
  is_public: boolean;
2437
2508
  nodes: unknown[];
2438
2509
  edges: unknown[];
2439
- canvas_flows: {
2440
- flow_id: string;
2510
+ flows: {
2511
+ created_at: string;
2512
+ id: string;
2513
+ request: string;
2514
+ title: string | null;
2515
+ user_id: string | null;
2516
+ application_id?: number | null;
2441
2517
  }[];
2442
2518
  }[];
2443
2519
  };
@@ -3501,6 +3577,22 @@ declare interface paths {
3501
3577
  patch?: never;
3502
3578
  trace?: never;
3503
3579
  };
3580
+ "/api/v1/speech/token": {
3581
+ parameters: {
3582
+ query?: never;
3583
+ header?: never;
3584
+ path?: never;
3585
+ cookie?: never;
3586
+ };
3587
+ get?: never;
3588
+ put?: never;
3589
+ post: operations["createSpeechToken"];
3590
+ delete?: never;
3591
+ options?: never;
3592
+ head?: never;
3593
+ patch?: never;
3594
+ trace?: never;
3595
+ };
3504
3596
  "/api/v1/recommendations": {
3505
3597
  parameters: {
3506
3598
  query?: never;
package/dist/index.js CHANGED
@@ -577,7 +577,9 @@ var DatabaseFlowSchema = z.object({
577
577
  created_at: z.string(),
578
578
  id: z.string(),
579
579
  request: z.string(),
580
+ title: z.string().nullable(),
580
581
  user_id: z.string().nullable(),
582
+ application_id: z.number().nullable().optional(),
581
583
  flow_steps: z.array(FlowStepSchema),
582
584
  flow_chat_messages: z.array(z.object({ count: z.number() }))
583
585
  });
@@ -589,9 +591,6 @@ z.object({
589
591
  var FrontendFlowSchema = DatabaseFlowSchema.omit({
590
592
  flow_chat_messages: true,
591
593
  flow_steps: true
592
- }).extend({
593
- user_friendly_goal: z.string().optional(),
594
- has_chat_messages: z.boolean()
595
594
  });
596
595
  var FrontendRecentFlowsSchema = DatabaseFlowSchema.omit({
597
596
  flow_steps: true,
@@ -1161,7 +1160,7 @@ createRoute({
1161
1160
  }
1162
1161
  }
1163
1162
  });
1164
- createRoute({
1163
+ var RetrieveFlow = createRoute({
1165
1164
  method: "get",
1166
1165
  path: "/api/v1/flows/{flowId}",
1167
1166
  operationId: "retrieveFlow",
@@ -1866,7 +1865,8 @@ var CreateFlow = createRoute({
1866
1865
  content: {
1867
1866
  "application/json": {
1868
1867
  schema: z.object({
1869
- userQuery: z.string()
1868
+ userQuery: z.string(),
1869
+ applicationName: z.string().optional()
1870
1870
  })
1871
1871
  }
1872
1872
  }
@@ -1884,6 +1884,16 @@ var CreateFlow = createRoute({
1884
1884
  }
1885
1885
  }
1886
1886
  },
1887
+ 400: {
1888
+ description: "Application not found",
1889
+ content: {
1890
+ "application/json": {
1891
+ schema: z.object({
1892
+ error: z.string()
1893
+ })
1894
+ }
1895
+ }
1896
+ },
1887
1897
  500: {
1888
1898
  description: "Something wrong happened",
1889
1899
  content: {
@@ -2319,6 +2329,40 @@ var ExchangeExternalToken = createRoute({
2319
2329
  }
2320
2330
  });
2321
2331
 
2332
+ // ../shared/dist/src/endpoints/companion/speech.routes.js
2333
+ var SpeechTokenResponseSchema = z.object({
2334
+ token: z.string().describe("Temporary AssemblyAI streaming token"),
2335
+ expiresAt: z.string().datetime().describe("ISO timestamp describing when the token expires.")
2336
+ });
2337
+ var CreateSpeechToken = createRoute({
2338
+ method: "post",
2339
+ path: "/api/v1/speech/token",
2340
+ operationId: "createSpeechToken",
2341
+ request: {
2342
+ headers: SupabaseHeaderSchema
2343
+ },
2344
+ responses: {
2345
+ 200: {
2346
+ description: "A short-lived token that can be used to stream audio.",
2347
+ content: {
2348
+ "application/json": {
2349
+ schema: SpeechTokenResponseSchema
2350
+ }
2351
+ }
2352
+ },
2353
+ 500: {
2354
+ description: "Failed to create a speech token",
2355
+ content: {
2356
+ "application/json": {
2357
+ schema: z.object({
2358
+ error: z.string()
2359
+ })
2360
+ }
2361
+ }
2362
+ }
2363
+ }
2364
+ });
2365
+
2322
2366
  // ../shared/dist/src/endpoints/end2end/run.routes.js
2323
2367
  var End2EndApiResponseSchema = z.discriminatedUnion("status", [
2324
2368
  z.object({
@@ -2576,9 +2620,7 @@ var ListCanvases = createRoute({
2576
2620
  content: {
2577
2621
  "application/json": {
2578
2622
  schema: z.array(FrontendCanvasSchema.extend({
2579
- canvas_flows: z.object({
2580
- flow_id: z.string()
2581
- }).array()
2623
+ flows: FrontendFlowSchema.array()
2582
2624
  }))
2583
2625
  }
2584
2626
  }
@@ -3108,7 +3150,7 @@ var toSearchParams = ({ cursor, filters, sorting, limit }) => {
3108
3150
 
3109
3151
  // package.json
3110
3152
  var package_default = {
3111
- version: "0.4.2"};
3153
+ version: "0.5.0"};
3112
3154
  var MageMetricsChatTransport = class extends DefaultChatTransport {
3113
3155
  constructor(apiUrl, flowId, options) {
3114
3156
  super({
@@ -3325,6 +3367,22 @@ var MageMetricsClient = class {
3325
3367
  }
3326
3368
  return data;
3327
3369
  },
3370
+ getFlow: async (flowId) => {
3371
+ await this.waitForAuth();
3372
+ const { data, error, response } = await this.internalApiClient.GET(
3373
+ RetrieveFlow.path,
3374
+ { params: { path: { flowId } } }
3375
+ );
3376
+ if (error) {
3377
+ throw new ApiError(error.error, response, {
3378
+ status: response.status,
3379
+ statusText: response.statusText,
3380
+ url: response.url,
3381
+ method: "GET"
3382
+ });
3383
+ }
3384
+ return data;
3385
+ },
3328
3386
  getRecentFlows: async (params = {}) => {
3329
3387
  await this.waitForAuth();
3330
3388
  const { data, error, response } = await this.internalApiClient.GET(
@@ -3354,7 +3412,8 @@ var MageMetricsClient = class {
3354
3412
  CreateFlow.path,
3355
3413
  {
3356
3414
  body: {
3357
- userQuery: request.query
3415
+ userQuery: request.query,
3416
+ applicationName: this.config.applicationName
3358
3417
  }
3359
3418
  }
3360
3419
  );
@@ -3414,11 +3473,7 @@ var MageMetricsClient = class {
3414
3473
  method: "GET"
3415
3474
  });
3416
3475
  }
3417
- return FrontendCanvasSchema.extend({
3418
- canvas_flows: z.object({
3419
- flow_id: z.string()
3420
- }).array()
3421
- }).array().parse(data);
3476
+ return data;
3422
3477
  },
3423
3478
  get: async (canvasId) => {
3424
3479
  await this.waitForAuth();
@@ -3440,7 +3495,7 @@ var MageMetricsClient = class {
3440
3495
  method: "GET"
3441
3496
  });
3442
3497
  }
3443
- return FrontendCanvasSchema.parse(data);
3498
+ return data;
3444
3499
  },
3445
3500
  create: async (body) => {
3446
3501
  await this.waitForAuth();
@@ -3631,6 +3686,22 @@ var MageMetricsClient = class {
3631
3686
  }
3632
3687
  return data;
3633
3688
  },
3689
+ createSpeechToken: async () => {
3690
+ await this.waitForAuth();
3691
+ const { data, error, response } = await this.internalApiClient.POST(
3692
+ CreateSpeechToken.path,
3693
+ {}
3694
+ );
3695
+ if (error) {
3696
+ throw new ApiError(error.error, response, {
3697
+ status: response.status,
3698
+ statusText: response.statusText,
3699
+ url: response.url,
3700
+ method: "POST"
3701
+ });
3702
+ }
3703
+ return data;
3704
+ },
3634
3705
  getReport: async (reportId) => {
3635
3706
  const params = { params: { path: { report_id: String(reportId) } } };
3636
3707
  const columnsPromise = this.internalApiClient.GET(