@smartmemory/sdk-js 1.4.119 → 1.4.120
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/README.md +69 -9
- package/dist/connection.js +5 -0
- package/dist/{core-BLQpDtod.js → core-DUg_hHl8.js} +538 -583
- package/dist/core.js +11 -10
- package/dist/fetch.js +18 -37
- package/dist/index-BKI1h_Wn.js +107 -0
- package/dist/index.js +1 -1
- package/dist/progress.js +166 -142
- package/dist/react.js +1 -1
- package/dist/recovery-JyUr2KHh.js +34 -0
- package/package.json +10 -2
- package/types/connection.d.ts +30 -0
- package/types/fetch.d.ts +12 -0
- package/types/progress.d.ts +48 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartmemory/sdk-js",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.120",
|
|
4
4
|
"description": "Unified JavaScript SDK for SmartMemory API — auth + API client for all frontends",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,16 +23,24 @@
|
|
|
23
23
|
"default": "./dist/react/analytics.js"
|
|
24
24
|
},
|
|
25
25
|
"./fetch": {
|
|
26
|
+
"types": "./types/fetch.d.ts",
|
|
26
27
|
"development": "./src/fetch/index.js",
|
|
27
28
|
"default": "./dist/fetch.js"
|
|
28
29
|
},
|
|
29
30
|
"./progress": {
|
|
31
|
+
"types": "./types/progress.d.ts",
|
|
30
32
|
"development": "./src/progress.ts",
|
|
31
33
|
"default": "./dist/progress.js"
|
|
34
|
+
},
|
|
35
|
+
"./connection": {
|
|
36
|
+
"types": "./types/connection.d.ts",
|
|
37
|
+
"development": "./src/connection/index.js",
|
|
38
|
+
"default": "./dist/connection.js"
|
|
32
39
|
}
|
|
33
40
|
},
|
|
34
41
|
"files": [
|
|
35
|
-
"dist"
|
|
42
|
+
"dist",
|
|
43
|
+
"types"
|
|
36
44
|
],
|
|
37
45
|
"scripts": {
|
|
38
46
|
"build": "vite build",
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type ConnectionState = 'connected' | 'reconnecting' | 'signed_out';
|
|
2
|
+
export interface ConnectionSnapshot {
|
|
3
|
+
readonly status: ConnectionState;
|
|
4
|
+
readonly reason: string | null;
|
|
5
|
+
}
|
|
6
|
+
export declare class ConnectionStatus {
|
|
7
|
+
readonly snapshot: ConnectionSnapshot;
|
|
8
|
+
subscribe(listener: (snapshot: ConnectionSnapshot) => void): () => void;
|
|
9
|
+
report(source: string | symbol, reason: string | null): void;
|
|
10
|
+
signedOut(): void;
|
|
11
|
+
authenticated(): void;
|
|
12
|
+
}
|
|
13
|
+
/** Structural type for client.connection / client.auth.connection. */
|
|
14
|
+
export interface RecoveryClient {
|
|
15
|
+
connection: ConnectionStatus;
|
|
16
|
+
auth: RecoveryAuth;
|
|
17
|
+
}
|
|
18
|
+
export interface RecoveryAuth {
|
|
19
|
+
apiBaseUrl: string;
|
|
20
|
+
connection: ConnectionStatus;
|
|
21
|
+
getAuthHeaders(extra?: HeadersInit): Record<string, string>;
|
|
22
|
+
getRequestOptions(extra?: RequestInit): RequestInit;
|
|
23
|
+
refreshToken(): Promise<string | null>;
|
|
24
|
+
clearLocalAuth(): void;
|
|
25
|
+
}
|
|
26
|
+
export declare class SessionRefreshError extends Error {
|
|
27
|
+
constructor(message: string, status?: number, recoverable?: boolean);
|
|
28
|
+
status: number;
|
|
29
|
+
recoverable: boolean;
|
|
30
|
+
}
|
package/types/fetch.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RecoveryAuth } from './connection.js';
|
|
2
|
+
export type { RecoveryAuth, RecoveryClient, ConnectionSnapshot, ConnectionState } from './connection.js';
|
|
3
|
+
export interface AuthFetchOptions {
|
|
4
|
+
fetchFn?: typeof fetch;
|
|
5
|
+
apiBases?: string[];
|
|
6
|
+
}
|
|
7
|
+
export interface InterceptorOptions extends AuthFetchOptions {
|
|
8
|
+
urlPatterns?: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare function createAuthFetch(authCore: RecoveryAuth, options?: AuthFetchOptions): typeof fetch;
|
|
11
|
+
/** Returns an injectable fetch; does not mutate global fetch or return an uninstaller. */
|
|
12
|
+
export declare function installInterceptor(authCore: RecoveryAuth, options?: InterceptorOptions): typeof fetch;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface ProgressEvent {
|
|
2
|
+
run_id: string;
|
|
3
|
+
scope: string;
|
|
4
|
+
seq: number;
|
|
5
|
+
ts: number;
|
|
6
|
+
kind: string;
|
|
7
|
+
status: 'started' | 'progress' | 'ok' | 'warn' | 'error' | 'skipped';
|
|
8
|
+
payload: Record<string, unknown>;
|
|
9
|
+
/** Optional — pipeline stage name when applicable */
|
|
10
|
+
stage?: string | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ProgressAuth {
|
|
14
|
+
getAuthHeaders(): Record<string, string>;
|
|
15
|
+
getRequestOptions(options?: RequestInit): RequestInit;
|
|
16
|
+
refreshToken(): Promise<unknown>;
|
|
17
|
+
clearLocalAuth(): void;
|
|
18
|
+
connection?: ProgressConnection;
|
|
19
|
+
}
|
|
20
|
+
export interface ProgressConnection {
|
|
21
|
+
report(source: string | symbol, reason: string | null): void;
|
|
22
|
+
}
|
|
23
|
+
export interface SubscribeProgressOptions {
|
|
24
|
+
baseUrl?: string;
|
|
25
|
+
/** Static credentials remain supported. Prefer auth for session recovery. */
|
|
26
|
+
token?: string;
|
|
27
|
+
apiKey?: string;
|
|
28
|
+
workspaceId?: string;
|
|
29
|
+
auth?: ProgressAuth;
|
|
30
|
+
/** Synchronous live headers, read on every connection; overrides static headers. */
|
|
31
|
+
getHeaders?: () => Record<string, string>;
|
|
32
|
+
connection?: ProgressConnection;
|
|
33
|
+
fetchFn?: typeof fetch;
|
|
34
|
+
runId?: string;
|
|
35
|
+
fromSeq?: number;
|
|
36
|
+
since?: string;
|
|
37
|
+
useCookieAuth?: boolean;
|
|
38
|
+
/** Default true. Set false for deliberate finite replay; EOF invokes onComplete. */
|
|
39
|
+
reconnect?: boolean;
|
|
40
|
+
onComplete?: () => void;
|
|
41
|
+
onEvent: (event: ProgressEvent) => void;
|
|
42
|
+
/** Terminal errors only; transient interruption invokes onReconnect. */
|
|
43
|
+
onError: (err: unknown) => void;
|
|
44
|
+
onReconnect?: () => void;
|
|
45
|
+
}
|
|
46
|
+
export interface ProgressSubscription { close(): void; }
|
|
47
|
+
|
|
48
|
+
export declare function subscribeProgress(options: SubscribeProgressOptions): ProgressSubscription;
|