@magemetrics/core 0.1.3 → 0.1.5
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 +55 -94
- package/dist/index.js +371 -81
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Client } from 'openapi-fetch';
|
|
2
2
|
import { DefaultChatTransport } from 'ai';
|
|
3
|
+
import { GoTrueClientOptions } from '@supabase/auth-js';
|
|
3
4
|
import { HttpChatTransportInitOptions } from 'ai';
|
|
4
5
|
import type { InferUITool } from 'ai';
|
|
5
6
|
import type { Simplify } from 'type-fest';
|
|
@@ -78,6 +79,11 @@ export declare class BrowserStorageAdapter implements AsyncStorage {
|
|
|
78
79
|
|
|
79
80
|
export declare const CHECK_KEY = "mm-ai-check-key";
|
|
80
81
|
|
|
82
|
+
export declare interface ColumnSort {
|
|
83
|
+
desc: boolean;
|
|
84
|
+
id: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
81
87
|
declare interface components {
|
|
82
88
|
schemas: {
|
|
83
89
|
VisualizationData: {
|
|
@@ -484,9 +490,11 @@ declare const inputSchema_7: z.ZodObject<{
|
|
|
484
490
|
declare type InternalApiClient = Simplify<Client<NoAuthPaths, `${string}/${string}`>>;
|
|
485
491
|
|
|
486
492
|
export declare class MageMetricsChatTransport extends DefaultChatTransport<MMChatUIMessage> {
|
|
487
|
-
constructor(apiUrl: string, flowId: string, options
|
|
493
|
+
constructor(apiUrl: string, flowId: string, options: MageMetricsChatTransportOptions);
|
|
488
494
|
}
|
|
489
495
|
|
|
496
|
+
declare type MageMetricsChatTransportOptions = Omit<HttpChatTransportInitOptions<MMChatUIMessage>, "api" | "prepareSendMessagesRequest">;
|
|
497
|
+
|
|
490
498
|
/**
|
|
491
499
|
* Core MageMetrics client that handles authentication lifecycle and provides
|
|
492
500
|
* a promise-based API that automatically waits for authentication to complete.
|
|
@@ -503,9 +511,14 @@ export declare class MageMetricsClient {
|
|
|
503
511
|
private authApiResponse;
|
|
504
512
|
private authPromise;
|
|
505
513
|
private processedJwt;
|
|
514
|
+
private userId;
|
|
506
515
|
private storageAdapter;
|
|
507
516
|
private events;
|
|
508
|
-
|
|
517
|
+
private authOptions;
|
|
518
|
+
constructor(config: MageMetricsClientConfig, auth?: Pick<GoTrueClientOptions, "fetch">);
|
|
519
|
+
toJSON(): {
|
|
520
|
+
config: string;
|
|
521
|
+
};
|
|
509
522
|
/**
|
|
510
523
|
* Add an event listener for authentication state changes
|
|
511
524
|
* @param type the type of the event
|
|
@@ -525,9 +538,13 @@ export declare class MageMetricsClient {
|
|
|
525
538
|
waitForAuth(): Promise<void>;
|
|
526
539
|
updateExternalJwt(jwt: string): Promise<void>;
|
|
527
540
|
get state(): AuthState;
|
|
528
|
-
|
|
541
|
+
getHeaders(): Promise<Record<string, string>>;
|
|
529
542
|
private clearStorage;
|
|
530
543
|
logout(): Promise<void>;
|
|
544
|
+
auth: {
|
|
545
|
+
startAutoRefresh: () => Promise<void> | undefined;
|
|
546
|
+
stopAuthRefresh: () => Promise<void> | undefined;
|
|
547
|
+
};
|
|
531
548
|
/**
|
|
532
549
|
* Public API methods that automatically wait for authentication
|
|
533
550
|
*/
|
|
@@ -544,22 +561,30 @@ export declare class MageMetricsClient {
|
|
|
544
561
|
data: Blob | string;
|
|
545
562
|
}>;
|
|
546
563
|
generateContextualInsight: (payload: GenerateInsightParam) => Promise<ExtractInsightResponse>;
|
|
564
|
+
getChatTransport: (flowId: string, options?: MageMetricsChatTransportOptions) => MageMetricsChatTransport;
|
|
565
|
+
getChatMessages: (flowId: string) => Promise<MMChatUIMessage[]>;
|
|
566
|
+
fetchReportData: (reportId: number, { columns, limit, sorting, filters, cursor }: ReportDataFilters) => Promise<Record<string, unknown>[]>;
|
|
567
|
+
getReport: (reportId: number) => Promise<{
|
|
568
|
+
columns: {
|
|
569
|
+
name: string;
|
|
570
|
+
data_type: string;
|
|
571
|
+
dataType: string;
|
|
572
|
+
renderType?: string;
|
|
573
|
+
unit?: string;
|
|
574
|
+
}[];
|
|
575
|
+
rowCount: {
|
|
576
|
+
count: number;
|
|
577
|
+
};
|
|
578
|
+
data: (reportId: number, { columns, limit, sorting, filters, cursor }: ReportDataFilters) => Promise<Record<string, unknown>[]>;
|
|
579
|
+
}>;
|
|
547
580
|
};
|
|
548
|
-
/**
|
|
549
|
-
* Initialize authentication flow
|
|
550
|
-
*/
|
|
551
|
-
private initializeAuth;
|
|
552
581
|
/**
|
|
553
582
|
* Perform the complete authentication flow
|
|
554
583
|
*/
|
|
555
584
|
private performAuthFlow;
|
|
556
585
|
private getApiInformation;
|
|
557
586
|
private initializeSupabaseClient;
|
|
558
|
-
client():
|
|
559
|
-
/**
|
|
560
|
-
* Initialize the API client with Supabase headers
|
|
561
|
-
*/
|
|
562
|
-
private initializeApiClient;
|
|
587
|
+
client(): InternalApiClient;
|
|
563
588
|
/**
|
|
564
589
|
* Handle the authentication logic (check session or exchange token)
|
|
565
590
|
*/
|
|
@@ -593,6 +618,11 @@ export declare interface MageMetricsClientConfig {
|
|
|
593
618
|
export declare type MageMetricsEvent = {
|
|
594
619
|
type: "authStateChange";
|
|
595
620
|
detail: AuthState;
|
|
621
|
+
} | {
|
|
622
|
+
type: "userChange";
|
|
623
|
+
detail: {
|
|
624
|
+
id: string;
|
|
625
|
+
};
|
|
596
626
|
};
|
|
597
627
|
|
|
598
628
|
/**
|
|
@@ -623,7 +653,7 @@ export declare class MemoryStorageAdapter implements AsyncStorage {
|
|
|
623
653
|
removeItem(key: string): Promise<void>;
|
|
624
654
|
}
|
|
625
655
|
|
|
626
|
-
declare type MMChatUIMessage = UIMessage<unknown, CustomDataParts, MMUiTools>;
|
|
656
|
+
export declare type MMChatUIMessage = UIMessage<unknown, CustomDataParts, MMUiTools>;
|
|
627
657
|
|
|
628
658
|
declare type MMUiTools = {
|
|
629
659
|
generateDataReport: UiTool;
|
|
@@ -1892,71 +1922,6 @@ declare interface operations {
|
|
|
1892
1922
|
};
|
|
1893
1923
|
};
|
|
1894
1924
|
};
|
|
1895
|
-
retrieveChatTimeline: {
|
|
1896
|
-
parameters: {
|
|
1897
|
-
query?: never;
|
|
1898
|
-
header: {
|
|
1899
|
-
"sp-access-token": string;
|
|
1900
|
-
};
|
|
1901
|
-
path: {
|
|
1902
|
-
flowId: string;
|
|
1903
|
-
};
|
|
1904
|
-
cookie?: never;
|
|
1905
|
-
};
|
|
1906
|
-
requestBody?: never;
|
|
1907
|
-
responses: {
|
|
1908
|
-
/** @description The timeline of generated insights for the flow */
|
|
1909
|
-
200: {
|
|
1910
|
-
headers: {
|
|
1911
|
-
[name: string]: unknown;
|
|
1912
|
-
};
|
|
1913
|
-
content: {
|
|
1914
|
-
"application/json": ({
|
|
1915
|
-
/** @enum {string} */
|
|
1916
|
-
type: "dataReport";
|
|
1917
|
-
flowDataId: number;
|
|
1918
|
-
flowId: string;
|
|
1919
|
-
title: string;
|
|
1920
|
-
bookmarked: boolean;
|
|
1921
|
-
answer: string | null;
|
|
1922
|
-
} | {
|
|
1923
|
-
/** @enum {string} */
|
|
1924
|
-
type: "visualization";
|
|
1925
|
-
flowId: string;
|
|
1926
|
-
flowDataId: number;
|
|
1927
|
-
flowDataVisualizationId: number;
|
|
1928
|
-
title: string;
|
|
1929
|
-
bookmarked: boolean;
|
|
1930
|
-
} | {
|
|
1931
|
-
/** @enum {string} */
|
|
1932
|
-
type: "message";
|
|
1933
|
-
})[];
|
|
1934
|
-
};
|
|
1935
|
-
};
|
|
1936
|
-
/** @description Unable to retrieve flow with this id */
|
|
1937
|
-
404: {
|
|
1938
|
-
headers: {
|
|
1939
|
-
[name: string]: unknown;
|
|
1940
|
-
};
|
|
1941
|
-
content: {
|
|
1942
|
-
"application/json": {
|
|
1943
|
-
error: string;
|
|
1944
|
-
};
|
|
1945
|
-
};
|
|
1946
|
-
};
|
|
1947
|
-
/** @description Something wrong happened */
|
|
1948
|
-
500: {
|
|
1949
|
-
headers: {
|
|
1950
|
-
[name: string]: unknown;
|
|
1951
|
-
};
|
|
1952
|
-
content: {
|
|
1953
|
-
"application/json": {
|
|
1954
|
-
error: string;
|
|
1955
|
-
};
|
|
1956
|
-
};
|
|
1957
|
-
};
|
|
1958
|
-
};
|
|
1959
|
-
};
|
|
1960
1925
|
retrieveChatMessages: {
|
|
1961
1926
|
parameters: {
|
|
1962
1927
|
query?: never;
|
|
@@ -3328,22 +3293,6 @@ declare interface paths {
|
|
|
3328
3293
|
patch?: never;
|
|
3329
3294
|
trace?: never;
|
|
3330
3295
|
};
|
|
3331
|
-
"/api/v1/chat/{flowId}/timeline": {
|
|
3332
|
-
parameters: {
|
|
3333
|
-
query?: never;
|
|
3334
|
-
header?: never;
|
|
3335
|
-
path?: never;
|
|
3336
|
-
cookie?: never;
|
|
3337
|
-
};
|
|
3338
|
-
get: operations["retrieveChatTimeline"];
|
|
3339
|
-
put?: never;
|
|
3340
|
-
post?: never;
|
|
3341
|
-
delete?: never;
|
|
3342
|
-
options?: never;
|
|
3343
|
-
head?: never;
|
|
3344
|
-
patch?: never;
|
|
3345
|
-
trace?: never;
|
|
3346
|
-
};
|
|
3347
3296
|
"/api/v1/chat/{flowId}/messages": {
|
|
3348
3297
|
parameters: {
|
|
3349
3298
|
query?: never;
|
|
@@ -4232,6 +4181,14 @@ declare type RemoveParamsConfig = Simplify<{
|
|
|
4232
4181
|
cookie?: string;
|
|
4233
4182
|
}>;
|
|
4234
4183
|
|
|
4184
|
+
declare type ReportDataFilters = {
|
|
4185
|
+
columns?: string[];
|
|
4186
|
+
limit: number;
|
|
4187
|
+
sorting: SortingState;
|
|
4188
|
+
filters: TableFilters;
|
|
4189
|
+
cursor?: number;
|
|
4190
|
+
};
|
|
4191
|
+
|
|
4235
4192
|
declare const SignalWithReportIdSchema: z.ZodObject<{
|
|
4236
4193
|
rule: z.ZodString;
|
|
4237
4194
|
metric: z.ZodString;
|
|
@@ -4253,6 +4210,10 @@ declare const SignalWithReportIdSchema: z.ZodObject<{
|
|
|
4253
4210
|
reportId: number;
|
|
4254
4211
|
}>;
|
|
4255
4212
|
|
|
4213
|
+
declare type SortingState = ColumnSort[];
|
|
4214
|
+
|
|
4215
|
+
declare type TableFilters = Record<string, string | number>;
|
|
4216
|
+
|
|
4256
4217
|
/**
|
|
4257
4218
|
* Token storage keys
|
|
4258
4219
|
*/
|