vibeusage 0.2.23 → 0.3.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/README.md +25 -20
- package/README.zh-CN.md +7 -2
- package/node_modules/@insforge/sdk/LICENSE +201 -201
- package/node_modules/@insforge/sdk/README.md +326 -259
- package/node_modules/@insforge/sdk/dist/index.d.mts +377 -182
- package/node_modules/@insforge/sdk/dist/index.d.ts +377 -182
- package/node_modules/@insforge/sdk/dist/index.js +1172 -677
- package/node_modules/@insforge/sdk/dist/index.js.map +1 -1
- package/node_modules/@insforge/sdk/dist/index.mjs +1171 -677
- package/node_modules/@insforge/sdk/dist/index.mjs.map +1 -1
- package/node_modules/@insforge/sdk/package.json +68 -68
- package/node_modules/@insforge/shared-schemas/dist/ai-api.schema.d.ts +1120 -43
- package/node_modules/@insforge/shared-schemas/dist/ai-api.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/ai-api.schema.js +179 -5
- package/node_modules/@insforge/shared-schemas/dist/ai-api.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/ai.schema.d.ts +25 -25
- package/node_modules/@insforge/shared-schemas/dist/ai.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/ai.schema.js +2 -2
- package/node_modules/@insforge/shared-schemas/dist/ai.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/auth-api.schema.d.ts +197 -51
- package/node_modules/@insforge/shared-schemas/dist/auth-api.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/auth-api.schema.js +87 -23
- package/node_modules/@insforge/shared-schemas/dist/auth-api.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/auth.schema.d.ts +32 -3
- package/node_modules/@insforge/shared-schemas/dist/auth.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/auth.schema.js +21 -3
- package/node_modules/@insforge/shared-schemas/dist/auth.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/cloud-events.schema.d.ts +380 -0
- package/node_modules/@insforge/shared-schemas/dist/cloud-events.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/cloud-events.schema.js +74 -0
- package/node_modules/@insforge/shared-schemas/dist/cloud-events.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/database-api.schema.d.ts +13 -13
- package/node_modules/@insforge/shared-schemas/dist/database-api.schema.js +1 -1
- package/node_modules/@insforge/shared-schemas/dist/database-api.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/deployments-api.schema.d.ts +735 -0
- package/node_modules/@insforge/shared-schemas/dist/deployments-api.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/deployments-api.schema.js +209 -0
- package/node_modules/@insforge/shared-schemas/dist/deployments-api.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/deployments.schema.d.ts +37 -0
- package/node_modules/@insforge/shared-schemas/dist/deployments.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/deployments.schema.js +25 -0
- package/node_modules/@insforge/shared-schemas/dist/deployments.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/docs.schema.d.ts +5 -1
- package/node_modules/@insforge/shared-schemas/dist/docs.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/docs.schema.js +34 -4
- package/node_modules/@insforge/shared-schemas/dist/docs.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/email-api.schema.js +1 -1
- package/node_modules/@insforge/shared-schemas/dist/email-api.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/functions-api.schema.d.ts +186 -6
- package/node_modules/@insforge/shared-schemas/dist/functions-api.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/functions-api.schema.js +21 -2
- package/node_modules/@insforge/shared-schemas/dist/functions-api.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/functions.schema.d.ts +5 -5
- package/node_modules/@insforge/shared-schemas/dist/functions.schema.js +1 -1
- package/node_modules/@insforge/shared-schemas/dist/functions.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/index.d.ts +24 -18
- package/node_modules/@insforge/shared-schemas/dist/index.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/index.js +24 -18
- package/node_modules/@insforge/shared-schemas/dist/index.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/logs-api.schema.js +1 -1
- package/node_modules/@insforge/shared-schemas/dist/logs-api.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/logs.schema.d.ts +43 -0
- package/node_modules/@insforge/shared-schemas/dist/logs.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/logs.schema.js +11 -0
- package/node_modules/@insforge/shared-schemas/dist/logs.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/metadata.schema.d.ts +229 -172
- package/node_modules/@insforge/shared-schemas/dist/metadata.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/metadata.schema.js +27 -7
- package/node_modules/@insforge/shared-schemas/dist/metadata.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/rate-limit-api.schema.d.ts +51 -0
- package/node_modules/@insforge/shared-schemas/dist/rate-limit-api.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/rate-limit-api.schema.js +31 -0
- package/node_modules/@insforge/shared-schemas/dist/rate-limit-api.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/rate-limit.schema.d.ts +31 -0
- package/node_modules/@insforge/shared-schemas/dist/rate-limit.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/rate-limit.schema.js +12 -0
- package/node_modules/@insforge/shared-schemas/dist/rate-limit.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/realtime-api.schema.d.ts +39 -20
- package/node_modules/@insforge/shared-schemas/dist/realtime-api.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/realtime-api.schema.js +5 -1
- package/node_modules/@insforge/shared-schemas/dist/realtime-api.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/realtime.schema.d.ts +12 -4
- package/node_modules/@insforge/shared-schemas/dist/realtime.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/realtime.schema.js +6 -0
- package/node_modules/@insforge/shared-schemas/dist/realtime.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/schedules-api.schema.d.ts +287 -0
- package/node_modules/@insforge/shared-schemas/dist/schedules-api.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/schedules-api.schema.js +81 -0
- package/node_modules/@insforge/shared-schemas/dist/schedules-api.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/schedules.schema.d.ts +77 -0
- package/node_modules/@insforge/shared-schemas/dist/schedules.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/schedules.schema.js +36 -0
- package/node_modules/@insforge/shared-schemas/dist/schedules.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/secrets-api.schema.d.ts +113 -0
- package/node_modules/@insforge/shared-schemas/dist/secrets-api.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/secrets-api.schema.js +31 -0
- package/node_modules/@insforge/shared-schemas/dist/secrets-api.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/secrets.schema.d.ts +31 -0
- package/node_modules/@insforge/shared-schemas/dist/secrets.schema.d.ts.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/secrets.schema.js +13 -0
- package/node_modules/@insforge/shared-schemas/dist/secrets.schema.js.map +1 -0
- package/node_modules/@insforge/shared-schemas/dist/storage-api.schema.d.ts +27 -2
- package/node_modules/@insforge/shared-schemas/dist/storage-api.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/storage-api.schema.js +9 -1
- package/node_modules/@insforge/shared-schemas/dist/storage-api.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/storage.schema.d.ts +17 -0
- package/node_modules/@insforge/shared-schemas/dist/storage.schema.d.ts.map +1 -1
- package/node_modules/@insforge/shared-schemas/dist/storage.schema.js +6 -0
- package/node_modules/@insforge/shared-schemas/dist/storage.schema.js.map +1 -1
- package/node_modules/@insforge/shared-schemas/package.json +2 -1
- package/package.json +5 -6
- package/src/cli.js +2 -2
- package/src/commands/init.js +20 -362
- package/src/commands/status.js +58 -51
- package/src/commands/sync.js +37 -25
- package/src/commands/uninstall.js +121 -104
- package/src/lib/claude-config.js +130 -35
- package/src/lib/diagnostics.js +88 -57
- package/src/lib/doctor.js +50 -0
- package/src/lib/insforge-client.js +13 -9
- package/src/lib/integrations/claude.js +106 -0
- package/src/lib/integrations/codex.js +88 -0
- package/src/lib/integrations/context.js +76 -0
- package/src/lib/integrations/every-code.js +88 -0
- package/src/lib/integrations/gemini.js +86 -0
- package/src/lib/integrations/index.js +85 -0
- package/src/lib/integrations/openclaw-legacy.js +123 -0
- package/src/lib/integrations/openclaw-session.js +132 -0
- package/src/lib/integrations/opencode.js +86 -0
- package/src/lib/integrations/utils.js +39 -0
- package/src/lib/opencode-sqlite.js +113 -0
- package/src/lib/opencode-usage-audit.js +3 -2
- package/src/lib/rollout.js +227 -1
- package/src/lib/runtime-config.js +7 -5
- package/src/lib/vibeusage-api.js +11 -7
- package/src/shared/copy-registry.cjs +142 -0
- package/src/shared/copy-registry.cjs.d.ts +33 -0
- package/src/shared/runtime-defaults.cjs +11 -0
- package/src/shared/runtime-defaults.cjs.d.ts +3 -0
- package/src/shared/vibeusage-function-contract.cjs +34 -0
- package/src/shared/vibeusage-function-contract.cjs.d.ts +4 -0
- package/src/commands/activate-if-needed.js +0 -41
- package/src/lib/activation-check.js +0 -341
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UserSchema, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse, OAuthProvidersSchema,
|
|
1
|
+
import { UserSchema, CreateUserRequest, CreateUserResponse, CreateSessionRequest, CreateSessionResponse, OAuthProvidersSchema, RefreshSessionResponse, GetProfileResponse, SendVerificationEmailRequest, VerifyEmailRequest, VerifyEmailResponse, SendResetPasswordEmailRequest, ExchangeResetPasswordTokenRequest, ExchangeResetPasswordTokenResponse, ResetPasswordResponse, GetPublicAuthConfigResponse, StorageFileSchema, ListObjectsResponseSchema, ChatCompletionRequest, ImageGenerationRequest, EmbeddingsRequest, SubscribeResponse, SocketMessage, SendRawEmailRequest, SendEmailResponse } from '@insforge/shared-schemas';
|
|
2
2
|
export { AuthErrorResponse, CreateSessionRequest, CreateUserRequest, RealtimeErrorPayload, SendRawEmailRequest as SendEmailOptions, SendEmailResponse, SocketMessage, SubscribeResponse, UserSchema } from '@insforge/shared-schemas';
|
|
3
3
|
import * as _supabase_postgrest_js from '@supabase/postgrest-js';
|
|
4
4
|
|
|
@@ -24,39 +24,74 @@ interface InsForgeConfig {
|
|
|
24
24
|
* This token will be used for all authenticated requests
|
|
25
25
|
*/
|
|
26
26
|
edgeFunctionToken?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Direct URL to Deno Subhosting functions (optional)
|
|
29
|
+
* When provided, SDK will try this URL first for function invocations.
|
|
30
|
+
* Falls back to proxy URL if subhosting returns 404.
|
|
31
|
+
* @example "https://{appKey}.functions.insforge.app"
|
|
32
|
+
*/
|
|
33
|
+
functionsUrl?: string;
|
|
27
34
|
/**
|
|
28
35
|
* Custom fetch implementation (useful for Node.js environments)
|
|
29
36
|
*/
|
|
30
37
|
fetch?: typeof fetch;
|
|
31
38
|
/**
|
|
32
|
-
*
|
|
39
|
+
* Enable server-side auth mode (SSR/Node runtime)
|
|
40
|
+
* In this mode auth endpoints use `client_type=mobile` and refresh_token body flow.
|
|
41
|
+
* @default false
|
|
33
42
|
*/
|
|
34
|
-
|
|
43
|
+
isServerMode?: boolean;
|
|
35
44
|
/**
|
|
36
|
-
*
|
|
37
|
-
* @default true
|
|
45
|
+
* Custom headers to include with every request
|
|
38
46
|
*/
|
|
39
|
-
|
|
47
|
+
headers?: Record<string, string>;
|
|
40
48
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
49
|
+
* Enable debug logging for HTTP requests and responses.
|
|
50
|
+
* When true, request/response details are logged to the console.
|
|
51
|
+
* Can also be a custom log function for advanced use cases.
|
|
52
|
+
* @default false
|
|
43
53
|
*/
|
|
44
|
-
|
|
54
|
+
debug?: boolean | ((message: string, ...args: any[]) => void);
|
|
45
55
|
/**
|
|
46
|
-
*
|
|
56
|
+
* Request timeout in milliseconds.
|
|
57
|
+
* Requests that exceed this duration will be aborted.
|
|
58
|
+
* Set to 0 to disable timeout.
|
|
59
|
+
* @default 30000
|
|
47
60
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
61
|
+
timeout?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Maximum number of retry attempts for failed requests.
|
|
64
|
+
* Retries are triggered on network errors and server errors (5xx).
|
|
65
|
+
* Client errors (4xx) are never retried.
|
|
66
|
+
* Set to 0 to disable retries.
|
|
67
|
+
* @default 3
|
|
68
|
+
*/
|
|
69
|
+
retryCount?: number;
|
|
70
|
+
/**
|
|
71
|
+
* Initial delay in milliseconds before the first retry.
|
|
72
|
+
* The delay doubles with each subsequent attempt (exponential backoff)
|
|
73
|
+
* with ±15% jitter to prevent thundering herd.
|
|
74
|
+
* @default 500
|
|
75
|
+
*/
|
|
76
|
+
retryDelay?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Automatically refresh the access token when a request fails with 401 INVALID_TOKEN.
|
|
79
|
+
* When true, the SDK will attempt a token refresh and retry the original request.
|
|
80
|
+
* @default true
|
|
81
|
+
*/
|
|
82
|
+
autoRefreshToken?: boolean;
|
|
54
83
|
}
|
|
55
84
|
interface AuthSession {
|
|
56
85
|
user: UserSchema;
|
|
57
86
|
accessToken: string;
|
|
58
87
|
expiresAt?: Date;
|
|
59
88
|
}
|
|
89
|
+
interface AuthRefreshResponse {
|
|
90
|
+
user: UserSchema;
|
|
91
|
+
accessToken: string;
|
|
92
|
+
csrfToken?: string;
|
|
93
|
+
refreshToken?: string;
|
|
94
|
+
}
|
|
60
95
|
interface ApiError {
|
|
61
96
|
error: string;
|
|
62
97
|
message: string;
|
|
@@ -71,60 +106,83 @@ declare class InsForgeError extends Error {
|
|
|
71
106
|
static fromApiError(apiError: ApiError): InsForgeError;
|
|
72
107
|
}
|
|
73
108
|
|
|
74
|
-
|
|
75
|
-
params?: Record<string, string>;
|
|
76
|
-
}
|
|
77
|
-
declare class HttpClient {
|
|
78
|
-
readonly baseUrl: string;
|
|
79
|
-
readonly fetch: typeof fetch;
|
|
80
|
-
private defaultHeaders;
|
|
81
|
-
private anonKey;
|
|
82
|
-
private userToken;
|
|
83
|
-
constructor(config: InsForgeConfig);
|
|
84
|
-
private buildUrl;
|
|
85
|
-
request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
86
|
-
get<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
87
|
-
post<T>(path: string, body?: any, options?: RequestOptions): Promise<T>;
|
|
88
|
-
put<T>(path: string, body?: any, options?: RequestOptions): Promise<T>;
|
|
89
|
-
patch<T>(path: string, body?: any, options?: RequestOptions): Promise<T>;
|
|
90
|
-
delete<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
91
|
-
setAuthToken(token: string | null): void;
|
|
92
|
-
getHeaders(): Record<string, string>;
|
|
93
|
-
}
|
|
94
|
-
|
|
109
|
+
type LogFunction = (message: string, ...args: any[]) => void;
|
|
95
110
|
/**
|
|
96
|
-
*
|
|
111
|
+
* Debug logger for the InsForge SDK.
|
|
112
|
+
* Logs HTTP request/response details with automatic redaction of sensitive data.
|
|
97
113
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* // Enable via SDK config
|
|
117
|
+
* const client = new InsForgeClient({ debug: true });
|
|
118
|
+
*
|
|
119
|
+
* // Or with a custom log function
|
|
120
|
+
* const client = new InsForgeClient({
|
|
121
|
+
* debug: (msg) => myLogger.info(msg)
|
|
122
|
+
* });
|
|
123
|
+
* ```
|
|
101
124
|
*/
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
private
|
|
106
|
-
private storage;
|
|
107
|
-
private _mode;
|
|
108
|
-
constructor(storage?: TokenStorage);
|
|
125
|
+
declare class Logger {
|
|
126
|
+
/** Whether debug logging is currently enabled */
|
|
127
|
+
enabled: boolean;
|
|
128
|
+
private customLog;
|
|
109
129
|
/**
|
|
110
|
-
*
|
|
130
|
+
* Creates a new Logger instance.
|
|
131
|
+
* @param debug - Set to true to enable console logging, or pass a custom log function
|
|
111
132
|
*/
|
|
112
|
-
|
|
133
|
+
constructor(debug?: boolean | LogFunction);
|
|
113
134
|
/**
|
|
114
|
-
*
|
|
135
|
+
* Logs a debug message at the info level.
|
|
136
|
+
* @param message - The message to log
|
|
137
|
+
* @param args - Additional arguments to pass to the log function
|
|
115
138
|
*/
|
|
116
|
-
|
|
139
|
+
log(message: string, ...args: any[]): void;
|
|
117
140
|
/**
|
|
118
|
-
*
|
|
119
|
-
*
|
|
141
|
+
* Logs a debug message at the warning level.
|
|
142
|
+
* @param message - The message to log
|
|
143
|
+
* @param args - Additional arguments to pass to the log function
|
|
120
144
|
*/
|
|
121
|
-
|
|
145
|
+
warn(message: string, ...args: any[]): void;
|
|
122
146
|
/**
|
|
123
|
-
*
|
|
147
|
+
* Logs a debug message at the error level.
|
|
148
|
+
* @param message - The message to log
|
|
149
|
+
* @param args - Additional arguments to pass to the log function
|
|
124
150
|
*/
|
|
125
|
-
|
|
151
|
+
error(message: string, ...args: any[]): void;
|
|
126
152
|
/**
|
|
127
|
-
*
|
|
153
|
+
* Logs an outgoing HTTP request with method, URL, headers, and body.
|
|
154
|
+
* Sensitive headers and body fields are automatically redacted.
|
|
155
|
+
* @param method - HTTP method (GET, POST, etc.)
|
|
156
|
+
* @param url - The full request URL
|
|
157
|
+
* @param headers - Request headers (sensitive values will be redacted)
|
|
158
|
+
* @param body - Request body (sensitive fields will be masked)
|
|
159
|
+
*/
|
|
160
|
+
logRequest(method: string, url: string, headers?: Record<string, string>, body?: any): void;
|
|
161
|
+
/**
|
|
162
|
+
* Logs an incoming HTTP response with method, URL, status, duration, and body.
|
|
163
|
+
* Error responses (4xx/5xx) are logged at the error level.
|
|
164
|
+
* @param method - HTTP method (GET, POST, etc.)
|
|
165
|
+
* @param url - The full request URL
|
|
166
|
+
* @param status - HTTP response status code
|
|
167
|
+
* @param durationMs - Request duration in milliseconds
|
|
168
|
+
* @param body - Response body (sensitive fields will be masked, large bodies truncated)
|
|
169
|
+
*/
|
|
170
|
+
logResponse(method: string, url: string, status: number, durationMs: number, body?: any): void;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Token Manager for InsForge SDK
|
|
175
|
+
*
|
|
176
|
+
* Memory-only token storage.
|
|
177
|
+
*/
|
|
178
|
+
|
|
179
|
+
declare class TokenManager {
|
|
180
|
+
private accessToken;
|
|
181
|
+
private user;
|
|
182
|
+
onTokenChange: (() => void) | null;
|
|
183
|
+
constructor();
|
|
184
|
+
/**
|
|
185
|
+
* Save session in memory
|
|
128
186
|
*/
|
|
129
187
|
saveSession(session: AuthSession): void;
|
|
130
188
|
/**
|
|
@@ -148,143 +206,203 @@ declare class TokenManager {
|
|
|
148
206
|
*/
|
|
149
207
|
setUser(user: UserSchema): void;
|
|
150
208
|
/**
|
|
151
|
-
* Clear
|
|
209
|
+
* Clear in-memory session
|
|
152
210
|
*/
|
|
153
211
|
clearSession(): void;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
type JsonRequestBody = Record<string, unknown> | unknown[] | null;
|
|
215
|
+
interface RequestOptions extends Omit<RequestInit, 'body'> {
|
|
216
|
+
params?: Record<string, string>;
|
|
217
|
+
body?: RequestInit['body'] | JsonRequestBody;
|
|
218
|
+
/** Allow retrying non-idempotent requests (POST, PATCH). Off by default to prevent duplicate writes. */
|
|
219
|
+
idempotent?: boolean;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* HTTP client with built-in retry, timeout, and exponential backoff support.
|
|
223
|
+
* Handles authentication, request serialization, and error normalization.
|
|
224
|
+
*/
|
|
225
|
+
declare class HttpClient {
|
|
226
|
+
readonly baseUrl: string;
|
|
227
|
+
readonly fetch: typeof fetch;
|
|
228
|
+
private defaultHeaders;
|
|
229
|
+
private anonKey;
|
|
230
|
+
private userToken;
|
|
231
|
+
private logger;
|
|
232
|
+
private autoRefreshToken;
|
|
233
|
+
private isRefreshing;
|
|
234
|
+
private refreshPromise;
|
|
235
|
+
private tokenManager;
|
|
236
|
+
private refreshToken;
|
|
237
|
+
private timeout;
|
|
238
|
+
private retryCount;
|
|
239
|
+
private retryDelay;
|
|
154
240
|
/**
|
|
155
|
-
*
|
|
241
|
+
* Creates a new HttpClient instance.
|
|
242
|
+
* @param config - SDK configuration including baseUrl, timeout, retry settings, and fetch implementation.
|
|
243
|
+
* @param tokenManager - Token manager for session persistence.
|
|
244
|
+
* @param logger - Optional logger instance for request/response debugging.
|
|
156
245
|
*/
|
|
157
|
-
|
|
246
|
+
constructor(config: InsForgeConfig, tokenManager?: TokenManager, logger?: Logger);
|
|
247
|
+
/**
|
|
248
|
+
* Builds a full URL from a path and optional query parameters.
|
|
249
|
+
* Normalizes PostgREST select parameters for proper syntax.
|
|
250
|
+
*/
|
|
251
|
+
private buildUrl;
|
|
252
|
+
/** Checks if an HTTP status code is eligible for retry (5xx server errors). */
|
|
253
|
+
private isRetryableStatus;
|
|
254
|
+
/**
|
|
255
|
+
* Computes the delay before the next retry using exponential backoff with jitter.
|
|
256
|
+
* @param attempt - The current retry attempt number (1-based).
|
|
257
|
+
* @returns Delay in milliseconds.
|
|
258
|
+
*/
|
|
259
|
+
private computeRetryDelay;
|
|
260
|
+
/**
|
|
261
|
+
* Performs an HTTP request with automatic retry and timeout handling.
|
|
262
|
+
* Retries on network errors and 5xx server errors with exponential backoff.
|
|
263
|
+
* Client errors (4xx) and timeouts are thrown immediately without retry.
|
|
264
|
+
* @param method - HTTP method (GET, POST, PUT, PATCH, DELETE).
|
|
265
|
+
* @param path - API path relative to the base URL.
|
|
266
|
+
* @param options - Optional request configuration including headers, body, and query params.
|
|
267
|
+
* @returns Parsed response data.
|
|
268
|
+
* @throws {InsForgeError} On timeout, network failure, or HTTP error responses.
|
|
269
|
+
*/
|
|
270
|
+
private handleRequest;
|
|
271
|
+
request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
272
|
+
/** Performs a GET request. */
|
|
273
|
+
get<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
274
|
+
/** Performs a POST request with an optional JSON body. */
|
|
275
|
+
post<T>(path: string, body?: any, options?: RequestOptions): Promise<T>;
|
|
276
|
+
/** Performs a PUT request with an optional JSON body. */
|
|
277
|
+
put<T>(path: string, body?: any, options?: RequestOptions): Promise<T>;
|
|
278
|
+
/** Performs a PATCH request with an optional JSON body. */
|
|
279
|
+
patch<T>(path: string, body?: any, options?: RequestOptions): Promise<T>;
|
|
280
|
+
/** Performs a DELETE request. */
|
|
281
|
+
delete<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
282
|
+
/** Sets or clears the user authentication token for subsequent requests. */
|
|
283
|
+
setAuthToken(token: string | null): void;
|
|
284
|
+
setRefreshToken(token: string | null): void;
|
|
285
|
+
/** Returns the current default headers including the authorization header if set. */
|
|
286
|
+
getHeaders(): Record<string, string>;
|
|
287
|
+
handleTokenRefresh(): Promise<AuthRefreshResponse>;
|
|
158
288
|
}
|
|
159
289
|
|
|
160
290
|
/**
|
|
161
291
|
* Auth module for InsForge SDK
|
|
162
|
-
*
|
|
292
|
+
* Handles authentication, sessions, profiles, and email verification
|
|
163
293
|
*/
|
|
164
294
|
|
|
295
|
+
interface AuthOptions {
|
|
296
|
+
isServerMode?: boolean;
|
|
297
|
+
}
|
|
165
298
|
declare class Auth {
|
|
166
299
|
private http;
|
|
167
300
|
private tokenManager;
|
|
168
|
-
|
|
301
|
+
private options;
|
|
302
|
+
private authCallbackHandled;
|
|
303
|
+
constructor(http: HttpClient, tokenManager: TokenManager, options?: AuthOptions);
|
|
304
|
+
private isServerMode;
|
|
169
305
|
/**
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
* Matches the backend's OAuth callback response (backend/src/api/routes/auth.ts:540-544)
|
|
306
|
+
* Save session from API response
|
|
307
|
+
* Handles token storage, CSRF token, and HTTP auth header
|
|
173
308
|
*/
|
|
174
|
-
private
|
|
309
|
+
private saveSessionFromResponse;
|
|
175
310
|
/**
|
|
176
|
-
*
|
|
311
|
+
* Detect and handle OAuth callback parameters in URL
|
|
312
|
+
* Supports PKCE flow (insforge_code)
|
|
177
313
|
*/
|
|
314
|
+
private detectAuthCallback;
|
|
178
315
|
signUp(request: CreateUserRequest): Promise<{
|
|
179
316
|
data: CreateUserResponse | null;
|
|
180
317
|
error: InsForgeError | null;
|
|
181
318
|
}>;
|
|
182
|
-
/**
|
|
183
|
-
* Sign in with email and password
|
|
184
|
-
*/
|
|
185
319
|
signInWithPassword(request: CreateSessionRequest): Promise<{
|
|
186
320
|
data: CreateSessionResponse | null;
|
|
187
321
|
error: InsForgeError | null;
|
|
188
322
|
}>;
|
|
323
|
+
signOut(): Promise<{
|
|
324
|
+
error: InsForgeError | null;
|
|
325
|
+
}>;
|
|
189
326
|
/**
|
|
190
|
-
* Sign in with OAuth provider
|
|
327
|
+
* Sign in with OAuth provider using PKCE flow
|
|
191
328
|
*/
|
|
192
329
|
signInWithOAuth(options: {
|
|
193
|
-
provider: OAuthProvidersSchema;
|
|
330
|
+
provider: OAuthProvidersSchema | string;
|
|
194
331
|
redirectTo?: string;
|
|
195
332
|
skipBrowserRedirect?: boolean;
|
|
196
333
|
}): Promise<{
|
|
197
334
|
data: {
|
|
198
335
|
url?: string;
|
|
199
336
|
provider?: string;
|
|
337
|
+
codeVerifier?: string;
|
|
200
338
|
};
|
|
201
339
|
error: InsForgeError | null;
|
|
202
340
|
}>;
|
|
203
341
|
/**
|
|
204
|
-
*
|
|
342
|
+
* Exchange OAuth authorization code for tokens (PKCE flow)
|
|
343
|
+
* Called automatically on initialization when insforge_code is in URL
|
|
205
344
|
*/
|
|
206
|
-
|
|
345
|
+
exchangeOAuthCode(code: string, codeVerifier?: string): Promise<{
|
|
346
|
+
data: CreateSessionResponse | null;
|
|
207
347
|
error: InsForgeError | null;
|
|
208
348
|
}>;
|
|
209
349
|
/**
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
* This is a public endpoint that doesn't require authentication
|
|
350
|
+
* Sign in with an ID token from a native SDK (Google One Tap, etc.)
|
|
351
|
+
* Use this for native mobile apps or Google One Tap on web.
|
|
213
352
|
*
|
|
214
|
-
* @
|
|
215
|
-
*
|
|
216
|
-
* @example
|
|
217
|
-
* ```ts
|
|
218
|
-
* const { data, error } = await insforge.auth.getPublicAuthConfig();
|
|
219
|
-
* if (data) {
|
|
220
|
-
* console.log(`OAuth providers: ${data.oauth.data.length}`);
|
|
221
|
-
* console.log(`Password min length: ${data.email.passwordMinLength}`);
|
|
222
|
-
* }
|
|
223
|
-
* ```
|
|
353
|
+
* @param credentials.provider - The identity provider (currently only 'google' is supported)
|
|
354
|
+
* @param credentials.token - The ID token from the native SDK
|
|
224
355
|
*/
|
|
225
|
-
|
|
226
|
-
|
|
356
|
+
signInWithIdToken(credentials: {
|
|
357
|
+
provider: 'google';
|
|
358
|
+
token: string;
|
|
359
|
+
}): Promise<{
|
|
360
|
+
data: CreateSessionResponse | null;
|
|
227
361
|
error: InsForgeError | null;
|
|
228
362
|
}>;
|
|
229
363
|
/**
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
error: any | null;
|
|
238
|
-
}>;
|
|
239
|
-
/**
|
|
240
|
-
* Get any user's profile by ID
|
|
241
|
-
* Returns profile information from the users table
|
|
364
|
+
* Refresh the current auth session.
|
|
365
|
+
*
|
|
366
|
+
* Browser mode:
|
|
367
|
+
* - Uses httpOnly refresh cookie and optional CSRF header.
|
|
368
|
+
*
|
|
369
|
+
* Server mode (`isServerMode: true`):
|
|
370
|
+
* - Uses mobile auth flow and requires `refreshToken` in request body.
|
|
242
371
|
*/
|
|
243
|
-
|
|
244
|
-
|
|
372
|
+
refreshSession(options?: {
|
|
373
|
+
refreshToken?: string;
|
|
374
|
+
}): Promise<{
|
|
375
|
+
data: RefreshSessionResponse | null;
|
|
245
376
|
error: InsForgeError | null;
|
|
246
377
|
}>;
|
|
247
378
|
/**
|
|
248
|
-
* Get
|
|
249
|
-
* Returns the stored JWT token and basic user info from local storage
|
|
379
|
+
* Get current user, automatically waits for pending OAuth callback
|
|
250
380
|
*/
|
|
251
|
-
|
|
381
|
+
getCurrentUser(): Promise<{
|
|
252
382
|
data: {
|
|
253
|
-
|
|
383
|
+
user: UserSchema | null;
|
|
254
384
|
};
|
|
255
385
|
error: InsForgeError | null;
|
|
256
386
|
}>;
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
*/
|
|
387
|
+
getProfile(userId: string): Promise<{
|
|
388
|
+
data: GetProfileResponse | null;
|
|
389
|
+
error: InsForgeError | null;
|
|
390
|
+
}>;
|
|
262
391
|
setProfile(profile: Record<string, unknown>): Promise<{
|
|
263
392
|
data: GetProfileResponse | null;
|
|
264
393
|
error: InsForgeError | null;
|
|
265
394
|
}>;
|
|
266
|
-
|
|
267
|
-
* Send email verification (code or link based on config)
|
|
268
|
-
*
|
|
269
|
-
* Send email verification using the method configured in auth settings (verifyEmailMethod).
|
|
270
|
-
* When method is 'code', sends a 6-digit numeric code. When method is 'link', sends a magic link.
|
|
271
|
-
* Prevents user enumeration by returning success even if email doesn't exist.
|
|
272
|
-
*/
|
|
273
|
-
sendVerificationEmail(request: SendVerificationEmailRequest): Promise<{
|
|
395
|
+
resendVerificationEmail(request: SendVerificationEmailRequest): Promise<{
|
|
274
396
|
data: {
|
|
275
397
|
success: boolean;
|
|
276
398
|
message: string;
|
|
277
399
|
} | null;
|
|
278
400
|
error: InsForgeError | null;
|
|
279
401
|
}>;
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
* When method is 'code', sends a 6-digit numeric code for two-step flow.
|
|
285
|
-
* When method is 'link', sends a magic link.
|
|
286
|
-
* Prevents user enumeration by returning success even if email doesn't exist.
|
|
287
|
-
*/
|
|
402
|
+
verifyEmail(request: VerifyEmailRequest): Promise<{
|
|
403
|
+
data: VerifyEmailResponse | null;
|
|
404
|
+
error: InsForgeError | null;
|
|
405
|
+
}>;
|
|
288
406
|
sendResetPasswordEmail(request: SendResetPasswordEmailRequest): Promise<{
|
|
289
407
|
data: {
|
|
290
408
|
success: boolean;
|
|
@@ -292,60 +410,19 @@ declare class Auth {
|
|
|
292
410
|
} | null;
|
|
293
411
|
error: InsForgeError | null;
|
|
294
412
|
}>;
|
|
295
|
-
/**
|
|
296
|
-
* Exchange reset password code for reset token
|
|
297
|
-
*
|
|
298
|
-
* Step 1 of two-step password reset flow (only used when resetPasswordMethod is 'code'):
|
|
299
|
-
* 1. Verify the 6-digit code sent to user's email
|
|
300
|
-
* 2. Return a reset token that can be used to actually reset the password
|
|
301
|
-
*
|
|
302
|
-
* This endpoint is not used when resetPasswordMethod is 'link' (magic link flow is direct).
|
|
303
|
-
*/
|
|
304
413
|
exchangeResetPasswordToken(request: ExchangeResetPasswordTokenRequest): Promise<{
|
|
305
|
-
data:
|
|
306
|
-
token: string;
|
|
307
|
-
expiresAt: string;
|
|
308
|
-
} | null;
|
|
414
|
+
data: ExchangeResetPasswordTokenResponse | null;
|
|
309
415
|
error: InsForgeError | null;
|
|
310
416
|
}>;
|
|
311
|
-
/**
|
|
312
|
-
* Reset password with token
|
|
313
|
-
*
|
|
314
|
-
* Reset user password with a token. The token can be:
|
|
315
|
-
* - Magic link token (64-character hex token from send-reset-password when method is 'link')
|
|
316
|
-
* - Reset token (from exchange-reset-password-token after code verification when method is 'code')
|
|
317
|
-
*
|
|
318
|
-
* Both token types use RESET_PASSWORD purpose and are verified the same way.
|
|
319
|
-
*
|
|
320
|
-
* Flow summary:
|
|
321
|
-
* - Code method: send-reset-password → exchange-reset-password-token → reset-password (with resetToken)
|
|
322
|
-
* - Link method: send-reset-password → reset-password (with link token directly)
|
|
323
|
-
*/
|
|
324
417
|
resetPassword(request: {
|
|
325
418
|
newPassword: string;
|
|
326
419
|
otp: string;
|
|
327
420
|
}): Promise<{
|
|
328
|
-
data:
|
|
329
|
-
message: string;
|
|
330
|
-
redirectTo?: string;
|
|
331
|
-
} | null;
|
|
421
|
+
data: ResetPasswordResponse | null;
|
|
332
422
|
error: InsForgeError | null;
|
|
333
423
|
}>;
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
*
|
|
337
|
-
* Verify email address using the method configured in auth settings (verifyEmailMethod):
|
|
338
|
-
* - Code verification: Provide both `email` and `otp` (6-digit numeric code)
|
|
339
|
-
* - Link verification: Provide only `otp` (64-character hex token from magic link)
|
|
340
|
-
*
|
|
341
|
-
* Successfully verified users will receive a session token.
|
|
342
|
-
*
|
|
343
|
-
* The email verification link sent to users always points to the backend API endpoint.
|
|
344
|
-
* If `verifyEmailRedirectTo` is configured, the backend will redirect to that URL after successful verification.
|
|
345
|
-
* Otherwise, a default success page is displayed.
|
|
346
|
-
*/
|
|
347
|
-
verifyEmail(request: VerifyEmailRequest): Promise<{
|
|
348
|
-
data: VerifyEmailResponse | null;
|
|
424
|
+
getPublicAuthConfig(): Promise<{
|
|
425
|
+
data: GetPublicAuthConfigResponse | null;
|
|
349
426
|
error: InsForgeError | null;
|
|
350
427
|
}>;
|
|
351
428
|
}
|
|
@@ -393,6 +470,27 @@ declare class Database {
|
|
|
393
470
|
* - Upserts
|
|
394
471
|
*/
|
|
395
472
|
from(table: string): _supabase_postgrest_js.PostgrestQueryBuilder<any, any, any, string, unknown>;
|
|
473
|
+
/**
|
|
474
|
+
* Call a PostgreSQL function (RPC)
|
|
475
|
+
*
|
|
476
|
+
* @example
|
|
477
|
+
* // Call a function with parameters
|
|
478
|
+
* const { data, error } = await client.database
|
|
479
|
+
* .rpc('get_user_stats', { user_id: 123 });
|
|
480
|
+
*
|
|
481
|
+
* // Call a function with no parameters
|
|
482
|
+
* const { data, error } = await client.database
|
|
483
|
+
* .rpc('get_all_active_users');
|
|
484
|
+
*
|
|
485
|
+
* // With options (head, count, get)
|
|
486
|
+
* const { data, count } = await client.database
|
|
487
|
+
* .rpc('search_posts', { query: 'hello' }, { count: 'exact' });
|
|
488
|
+
*/
|
|
489
|
+
rpc(fn: string, args?: Record<string, unknown>, options?: {
|
|
490
|
+
head?: boolean;
|
|
491
|
+
get?: boolean;
|
|
492
|
+
count?: 'exact' | 'planned' | 'estimated';
|
|
493
|
+
}): _supabase_postgrest_js.PostgrestFilterBuilder<any, any, any, any, string, null, "RPC">;
|
|
396
494
|
}
|
|
397
495
|
|
|
398
496
|
/**
|
|
@@ -489,6 +587,7 @@ declare class AI {
|
|
|
489
587
|
private http;
|
|
490
588
|
readonly chat: Chat;
|
|
491
589
|
readonly images: Images;
|
|
590
|
+
readonly embeddings: Embeddings;
|
|
492
591
|
constructor(http: HttpClient);
|
|
493
592
|
}
|
|
494
593
|
declare class Chat {
|
|
@@ -510,16 +609,46 @@ declare class ChatCompletions {
|
|
|
510
609
|
* });
|
|
511
610
|
* console.log(completion.choices[0].message.content);
|
|
512
611
|
*
|
|
513
|
-
* // With images
|
|
612
|
+
* // With images (OpenAI-compatible format)
|
|
514
613
|
* const response = await client.ai.chat.completions.create({
|
|
515
614
|
* model: 'gpt-4-vision',
|
|
516
615
|
* messages: [{
|
|
517
616
|
* role: 'user',
|
|
518
|
-
* content:
|
|
519
|
-
*
|
|
617
|
+
* content: [
|
|
618
|
+
* { type: 'text', text: 'What is in this image?' },
|
|
619
|
+
* { type: 'image_url', image_url: { url: 'https://example.com/image.jpg' } }
|
|
620
|
+
* ]
|
|
520
621
|
* }]
|
|
521
622
|
* });
|
|
522
623
|
*
|
|
624
|
+
* // With PDF files
|
|
625
|
+
* const pdfResponse = await client.ai.chat.completions.create({
|
|
626
|
+
* model: 'anthropic/claude-3.5-sonnet',
|
|
627
|
+
* messages: [{
|
|
628
|
+
* role: 'user',
|
|
629
|
+
* content: [
|
|
630
|
+
* { type: 'text', text: 'Summarize this document' },
|
|
631
|
+
* { type: 'file', file: { filename: 'doc.pdf', file_data: 'https://example.com/doc.pdf' } }
|
|
632
|
+
* ]
|
|
633
|
+
* }],
|
|
634
|
+
* fileParser: { enabled: true, pdf: { engine: 'mistral-ocr' } }
|
|
635
|
+
* });
|
|
636
|
+
*
|
|
637
|
+
* // With web search
|
|
638
|
+
* const searchResponse = await client.ai.chat.completions.create({
|
|
639
|
+
* model: 'openai/gpt-4',
|
|
640
|
+
* messages: [{ role: 'user', content: 'What are the latest news about AI?' }],
|
|
641
|
+
* webSearch: { enabled: true, maxResults: 5 }
|
|
642
|
+
* });
|
|
643
|
+
* // Access citations from response.choices[0].message.annotations
|
|
644
|
+
*
|
|
645
|
+
* // With thinking/reasoning mode (Anthropic models)
|
|
646
|
+
* const thinkingResponse = await client.ai.chat.completions.create({
|
|
647
|
+
* model: 'anthropic/claude-3.5-sonnet',
|
|
648
|
+
* messages: [{ role: 'user', content: 'Solve this complex math problem...' }],
|
|
649
|
+
* thinking: true
|
|
650
|
+
* });
|
|
651
|
+
*
|
|
523
652
|
* // Streaming - returns async iterable
|
|
524
653
|
* const stream = await client.ai.chat.completions.create({
|
|
525
654
|
* model: 'gpt-4',
|
|
@@ -540,6 +669,47 @@ declare class ChatCompletions {
|
|
|
540
669
|
*/
|
|
541
670
|
private parseSSEStream;
|
|
542
671
|
}
|
|
672
|
+
declare class Embeddings {
|
|
673
|
+
private http;
|
|
674
|
+
constructor(http: HttpClient);
|
|
675
|
+
/**
|
|
676
|
+
* Create embeddings for text input - OpenAI-like response format
|
|
677
|
+
*
|
|
678
|
+
* @example
|
|
679
|
+
* ```typescript
|
|
680
|
+
* // Single text input
|
|
681
|
+
* const response = await client.ai.embeddings.create({
|
|
682
|
+
* model: 'openai/text-embedding-3-small',
|
|
683
|
+
* input: 'Hello world'
|
|
684
|
+
* });
|
|
685
|
+
* console.log(response.data[0].embedding); // number[]
|
|
686
|
+
*
|
|
687
|
+
* // Multiple text inputs
|
|
688
|
+
* const response = await client.ai.embeddings.create({
|
|
689
|
+
* model: 'openai/text-embedding-3-small',
|
|
690
|
+
* input: ['Hello world', 'Goodbye world']
|
|
691
|
+
* });
|
|
692
|
+
* response.data.forEach((item, i) => {
|
|
693
|
+
* console.log(`Embedding ${i}:`, item.embedding.slice(0, 5)); // First 5 dimensions
|
|
694
|
+
* });
|
|
695
|
+
*
|
|
696
|
+
* // With custom dimensions (if supported by model)
|
|
697
|
+
* const response = await client.ai.embeddings.create({
|
|
698
|
+
* model: 'openai/text-embedding-3-small',
|
|
699
|
+
* input: 'Hello world',
|
|
700
|
+
* dimensions: 256
|
|
701
|
+
* });
|
|
702
|
+
*
|
|
703
|
+
* // With base64 encoding format
|
|
704
|
+
* const response = await client.ai.embeddings.create({
|
|
705
|
+
* model: 'openai/text-embedding-3-small',
|
|
706
|
+
* input: 'Hello world',
|
|
707
|
+
* encoding_format: 'base64'
|
|
708
|
+
* });
|
|
709
|
+
* ```
|
|
710
|
+
*/
|
|
711
|
+
create(params: EmbeddingsRequest): Promise<any>;
|
|
712
|
+
}
|
|
543
713
|
declare class Images {
|
|
544
714
|
private http;
|
|
545
715
|
constructor(http: HttpClient);
|
|
@@ -602,15 +772,27 @@ interface FunctionInvokeOptions {
|
|
|
602
772
|
*/
|
|
603
773
|
declare class Functions {
|
|
604
774
|
private http;
|
|
605
|
-
|
|
775
|
+
private functionsUrl;
|
|
776
|
+
constructor(http: HttpClient, functionsUrl?: string);
|
|
777
|
+
/**
|
|
778
|
+
* Derive the subhosting URL from the base URL.
|
|
779
|
+
* Base URL pattern: https://{appKey}.{region}.insforge.app
|
|
780
|
+
* Functions URL: https://{appKey}.functions.insforge.app
|
|
781
|
+
* Only applies to .insforge.app domains.
|
|
782
|
+
*/
|
|
783
|
+
private static deriveSubhostingUrl;
|
|
606
784
|
/**
|
|
607
785
|
* Invokes an Edge Function
|
|
786
|
+
*
|
|
787
|
+
* If functionsUrl is configured, tries direct subhosting first.
|
|
788
|
+
* Falls back to proxy URL if subhosting returns 404.
|
|
789
|
+
*
|
|
608
790
|
* @param slug The function slug to invoke
|
|
609
791
|
* @param options Request options
|
|
610
792
|
*/
|
|
611
793
|
invoke<T = any>(slug: string, options?: FunctionInvokeOptions): Promise<{
|
|
612
794
|
data: T | null;
|
|
613
|
-
error:
|
|
795
|
+
error: InsForgeError | null;
|
|
614
796
|
}>;
|
|
615
797
|
}
|
|
616
798
|
|
|
@@ -658,7 +840,8 @@ declare class Realtime {
|
|
|
658
840
|
private connectPromise;
|
|
659
841
|
private subscribedChannels;
|
|
660
842
|
private eventListeners;
|
|
661
|
-
|
|
843
|
+
private anonKey?;
|
|
844
|
+
constructor(baseUrl: string, tokenManager: TokenManager, anonKey?: string);
|
|
662
845
|
private notifyListeners;
|
|
663
846
|
/**
|
|
664
847
|
* Connect to the realtime server
|
|
@@ -669,6 +852,12 @@ declare class Realtime {
|
|
|
669
852
|
* Disconnect from the realtime server
|
|
670
853
|
*/
|
|
671
854
|
disconnect(): void;
|
|
855
|
+
/**
|
|
856
|
+
* Handle token changes (e.g., after auth refresh)
|
|
857
|
+
* Updates socket auth so reconnects use the new token
|
|
858
|
+
* If connected, triggers reconnect to apply new token immediately
|
|
859
|
+
*/
|
|
860
|
+
private onTokenChange;
|
|
672
861
|
/**
|
|
673
862
|
* Check if connected to the realtime server
|
|
674
863
|
*/
|
|
@@ -778,7 +967,7 @@ declare class Emails {
|
|
|
778
967
|
*/
|
|
779
968
|
send(options: SendRawEmailRequest): Promise<{
|
|
780
969
|
data: SendEmailResponse | null;
|
|
781
|
-
error:
|
|
970
|
+
error: InsForgeError | null;
|
|
782
971
|
}>;
|
|
783
972
|
}
|
|
784
973
|
|
|
@@ -818,6 +1007,12 @@ declare class Emails {
|
|
|
818
1007
|
* const { data, error } = await client.functions.invoke('my-function', {
|
|
819
1008
|
* body: { message: 'Hello from SDK' }
|
|
820
1009
|
* });
|
|
1010
|
+
*
|
|
1011
|
+
* // Enable debug logging
|
|
1012
|
+
* const debugClient = new InsForgeClient({
|
|
1013
|
+
* baseUrl: 'http://localhost:7130',
|
|
1014
|
+
* debug: true
|
|
1015
|
+
* });
|
|
821
1016
|
* ```
|
|
822
1017
|
*/
|
|
823
1018
|
declare class InsForgeClient {
|
|
@@ -851,4 +1046,4 @@ declare class InsForgeClient {
|
|
|
851
1046
|
|
|
852
1047
|
declare function createClient(config: InsForgeConfig): InsForgeClient;
|
|
853
1048
|
|
|
854
|
-
export { AI, type ApiError, Auth, type AuthSession, type InsForgeConfig as ClientOptions, type ConnectionState, Database, Emails, type EventCallback, type FunctionInvokeOptions, Functions, HttpClient, InsForgeClient, type InsForgeConfig, InsForgeError, Realtime, Storage, StorageBucket, type StorageResponse, TokenManager,
|
|
1049
|
+
export { AI, type ApiError, Auth, type AuthSession, type InsForgeConfig as ClientOptions, type ConnectionState, Database, Emails, type EventCallback, type FunctionInvokeOptions, Functions, HttpClient, InsForgeClient, type InsForgeConfig, InsForgeError, Logger, Realtime, Storage, StorageBucket, type StorageResponse, TokenManager, createClient, InsForgeClient as default };
|