@reifydb/client 0.4.2 → 0.4.7

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
@@ -73,6 +73,22 @@ interface SubscriptionCallbacks<T = any> {
73
73
  onUpdate?: (rows: T[]) => void;
74
74
  onRemove?: (rows: T[]) => void;
75
75
  }
76
+ interface LogoutRequest {
77
+ id: string;
78
+ type: "Logout";
79
+ payload: {};
80
+ }
81
+ interface LogoutResponse {
82
+ id: string;
83
+ type: "Logout";
84
+ payload: {
85
+ status: string;
86
+ };
87
+ }
88
+ interface LoginResult {
89
+ token: string;
90
+ identity: string;
91
+ }
76
92
 
77
93
  interface WsClientOptions {
78
94
  url: string;
@@ -124,6 +140,10 @@ declare class WsClient {
124
140
  * but the schema expects a bigint type (Int8, Int16, Uint8, Uint16).
125
141
  */
126
142
  private coerceToPrimitiveType;
143
+ loginWithPassword(principal: string, password: string): Promise<LoginResult>;
144
+ loginWithToken(principal: string, token: string): Promise<LoginResult>;
145
+ login(method: string, principal: string, credentials: Record<string, string>): Promise<LoginResult>;
146
+ logout(): Promise<void>;
127
147
  disconnect(): void;
128
148
  private handleDisconnect;
129
149
  private attemptReconnect;
@@ -134,14 +154,56 @@ declare class WsClient {
134
154
  private rejectAllPendingRequests;
135
155
  }
136
156
 
157
+ interface HttpClientOptions {
158
+ url: string;
159
+ timeoutMs?: number;
160
+ token?: string;
161
+ }
162
+ declare class HttpClient {
163
+ private options;
164
+ private constructor();
165
+ static connect(options: HttpClientOptions): HttpClient;
166
+ loginWithPassword(principal: string, password: string): Promise<LoginResult>;
167
+ loginWithToken(principal: string, token: string): Promise<LoginResult>;
168
+ login(method: string, principal: string, credentials: Record<string, string>): Promise<LoginResult>;
169
+ logout(): Promise<void>;
170
+ admin<const S extends readonly SchemaNode[]>(statements: string | string[], params: any, schemas: S): Promise<FrameResults<S>>;
171
+ command<const S extends readonly SchemaNode[]>(statements: string | string[], params: any, schemas: S): Promise<FrameResults<S>>;
172
+ query<const S extends readonly SchemaNode[]>(statements: string | string[], params: any, schemas: S): Promise<FrameResults<S>>;
173
+ private send;
174
+ private transformResult;
175
+ private coerceToPrimitiveType;
176
+ }
177
+
178
+ interface JsonHttpClientOptions {
179
+ url: string;
180
+ timeoutMs?: number;
181
+ token?: string;
182
+ unwrap?: boolean;
183
+ }
184
+ declare class JsonHttpClient {
185
+ private options;
186
+ private constructor();
187
+ static connect(options: JsonHttpClientOptions): JsonHttpClient;
188
+ loginWithPassword(principal: string, password: string): Promise<LoginResult>;
189
+ loginWithToken(principal: string, token: string): Promise<LoginResult>;
190
+ login(method: string, principal: string, credentials: Record<string, string>): Promise<LoginResult>;
191
+ logout(): Promise<void>;
192
+ admin(statements: string | string[], params?: any): Promise<any>;
193
+ command(statements: string | string[], params?: any): Promise<any>;
194
+ query(statements: string | string[], params?: any): Promise<any>;
195
+ private send;
196
+ }
197
+
137
198
  interface JsonWsClientOptions {
138
199
  url: string;
139
200
  timeoutMs?: number;
140
201
  token?: string;
141
202
  maxReconnectAttempts?: number;
142
203
  reconnectDelayMs?: number;
204
+ unwrap?: boolean;
143
205
  }
144
- declare class JsonWsClient {
206
+ declare class JsonWebsocketClient {
145
207
  private options;
146
208
  private nextId;
147
209
  private socket;
@@ -150,34 +212,22 @@ declare class JsonWsClient {
150
212
  private shouldReconnect;
151
213
  private isReconnecting;
152
214
  private constructor();
153
- static connect(options: JsonWsClientOptions): Promise<JsonWsClient>;
154
- query<T = any>(statements: string | string[], params?: Params): Promise<T[][]>;
155
- command<T = any>(statements: string | string[], params?: Params): Promise<T[][]>;
156
- admin<T = any>(statements: string | string[], params?: Params): Promise<T[][]>;
215
+ static connect(options: JsonWsClientOptions): Promise<JsonWebsocketClient>;
216
+ admin(statements: string | string[], params?: any): Promise<any>;
217
+ command(statements: string | string[], params?: any): Promise<any>;
218
+ query(statements: string | string[], params?: any): Promise<any>;
219
+ send(req: AdminRequest | CommandRequest | QueryRequest): Promise<any>;
220
+ loginWithPassword(principal: string, password: string): Promise<LoginResult>;
221
+ loginWithToken(principal: string, token: string): Promise<LoginResult>;
222
+ login(method: string, principal: string, credentials: Record<string, string>): Promise<LoginResult>;
223
+ logout(): Promise<void>;
157
224
  disconnect(): void;
158
- private send;
159
225
  private handleDisconnect;
160
226
  private attemptReconnect;
161
227
  private setupSocketHandlers;
162
228
  private rejectAllPendingRequests;
163
229
  }
164
230
 
165
- interface JsonHttpClientOptions {
166
- url: string;
167
- token?: string;
168
- apiKey?: string;
169
- timeoutMs?: number;
170
- }
171
- declare class JsonHttpClient {
172
- private options;
173
- private constructor();
174
- static connect(options: JsonHttpClientOptions): JsonHttpClient;
175
- query<T = any>(statements: string | string[], params?: Params): Promise<T[][]>;
176
- command<T = any>(statements: string | string[], params?: Params): Promise<T[][]>;
177
- admin<T = any>(statements: string | string[], params?: Params): Promise<T[][]>;
178
- private send;
179
- }
180
-
181
231
  declare class Client {
182
232
  /**
183
233
  * Connect to ReifyDB via WebSocket
@@ -187,19 +237,26 @@ declare class Client {
187
237
  */
188
238
  static connect_ws(url: string, options?: Omit<WsClientOptions, 'url'>): Promise<WsClient>;
189
239
  /**
190
- * Connect to ReifyDB via WebSocket with JSON format responses
191
- * @param url WebSocket URL
240
+ * Connect to ReifyDB via HTTP
241
+ * @param url HTTP URL
192
242
  * @param options Optional configuration
193
- * @returns Connected JSON WebSocket client
243
+ * @returns HTTP client (sync, no connection to await)
194
244
  */
195
- static connect_json_ws(url: string, options?: Omit<JsonWsClientOptions, 'url'>): Promise<JsonWsClient>;
245
+ static connect_http(url: string, options?: Omit<HttpClientOptions, 'url'>): HttpClient;
196
246
  /**
197
- * Connect to ReifyDB via HTTP with JSON format responses
198
- * @param url Base HTTP URL
247
+ * Connect to ReifyDB via HTTP with JSON response format
248
+ * @param url HTTP URL
199
249
  * @param options Optional configuration
200
- * @returns JSON HTTP client
250
+ * @returns JSON HTTP client (sync, no connection to await)
201
251
  */
202
252
  static connect_json_http(url: string, options?: Omit<JsonHttpClientOptions, 'url'>): JsonHttpClient;
253
+ /**
254
+ * Connect to ReifyDB via WebSocket with JSON response format
255
+ * @param url WebSocket URL
256
+ * @param options Optional configuration
257
+ * @returns Connected JSON WebSocket client
258
+ */
259
+ static connect_json_ws(url: string, options?: Omit<JsonWsClientOptions, 'url'>): Promise<JsonWebsocketClient>;
203
260
  }
204
261
 
205
- export { type ChangeMessage, Client, JsonHttpClient, type JsonHttpClientOptions, JsonWsClient, type JsonWsClientOptions, type SubscribeRequest, type SubscribedResponse, type SubscriptionCallbacks, type SubscriptionOperation, type UnsubscribeRequest, type UnsubscribedResponse, WsClient, type WsClientOptions };
262
+ export { type ChangeMessage, Client, HttpClient, type HttpClientOptions, JsonHttpClient, type JsonHttpClientOptions, JsonWebsocketClient, type JsonWsClientOptions, type LoginResult, type LogoutRequest, type LogoutResponse, type SubscribeRequest, type SubscribedResponse, type SubscriptionCallbacks, type SubscriptionOperation, type UnsubscribeRequest, type UnsubscribedResponse, WsClient, type WsClientOptions };