@anvailabs/proximadb-client 0.3.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.
Files changed (65) hide show
  1. package/README.md +160 -0
  2. package/dist/client.d.ts +319 -0
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/client.js +681 -0
  5. package/dist/client.js.map +1 -0
  6. package/dist/collection.d.ts +227 -0
  7. package/dist/collection.d.ts.map +1 -0
  8. package/dist/collection.js +436 -0
  9. package/dist/collection.js.map +1 -0
  10. package/dist/esm/client.js +674 -0
  11. package/dist/esm/client.js.map +1 -0
  12. package/dist/esm/collection.js +428 -0
  13. package/dist/esm/collection.js.map +1 -0
  14. package/dist/esm/filter.js +228 -0
  15. package/dist/esm/filter.js.map +1 -0
  16. package/dist/esm/generated/schema.js +6 -0
  17. package/dist/esm/generated/schema.js.map +1 -0
  18. package/dist/esm/graph.js +678 -0
  19. package/dist/esm/graph.js.map +1 -0
  20. package/dist/esm/index.js +86 -0
  21. package/dist/esm/index.js.map +1 -0
  22. package/dist/esm/search.js +317 -0
  23. package/dist/esm/search.js.map +1 -0
  24. package/dist/esm/transport.js +33 -0
  25. package/dist/esm/transport.js.map +1 -0
  26. package/dist/esm/types.js +181 -0
  27. package/dist/esm/types.js.map +1 -0
  28. package/dist/filter.d.ts +51 -0
  29. package/dist/filter.d.ts.map +1 -0
  30. package/dist/filter.js +241 -0
  31. package/dist/filter.js.map +1 -0
  32. package/dist/generated/schema.d.ts +4271 -0
  33. package/dist/generated/schema.d.ts.map +1 -0
  34. package/dist/generated/schema.js +7 -0
  35. package/dist/generated/schema.js.map +1 -0
  36. package/dist/graph.d.ts +350 -0
  37. package/dist/graph.d.ts.map +1 -0
  38. package/dist/graph.js +690 -0
  39. package/dist/graph.js.map +1 -0
  40. package/dist/index.d.ts +58 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +126 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/search.d.ts +160 -0
  45. package/dist/search.d.ts.map +1 -0
  46. package/dist/search.js +322 -0
  47. package/dist/search.js.map +1 -0
  48. package/dist/transport.d.ts +40 -0
  49. package/dist/transport.d.ts.map +1 -0
  50. package/dist/transport.js +39 -0
  51. package/dist/transport.js.map +1 -0
  52. package/dist/types.d.ts +632 -0
  53. package/dist/types.d.ts.map +1 -0
  54. package/dist/types.js +185 -0
  55. package/dist/types.js.map +1 -0
  56. package/package.json +72 -0
  57. package/src/client.ts +856 -0
  58. package/src/collection.ts +578 -0
  59. package/src/filter.ts +280 -0
  60. package/src/generated/schema.ts +4271 -0
  61. package/src/graph.ts +811 -0
  62. package/src/index.ts +184 -0
  63. package/src/search.ts +401 -0
  64. package/src/transport.ts +52 -0
  65. package/src/types.ts +726 -0
package/dist/client.js ADDED
@@ -0,0 +1,681 @@
1
+ "use strict";
2
+ /**
3
+ * ProximaDB TypeScript SDK - Client
4
+ *
5
+ * Main entry point for connecting to ProximaDB servers.
6
+ *
7
+ * Copyright 2025 ProximaDB Contributors
8
+ * Licensed under the Apache License, Version 2.0
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.ClientBuilder = exports.ProximaDBClient = void 0;
12
+ exports.connect = connect;
13
+ exports.connectRest = connectRest;
14
+ const types_1 = require("./types");
15
+ const collection_1 = require("./collection");
16
+ const graph_1 = require("./graph");
17
+ const transport_1 = require("./transport");
18
+ /**
19
+ * Default client configuration
20
+ */
21
+ const DEFAULT_CONFIG = {
22
+ url: "http://localhost:5678",
23
+ timeoutMs: 30000,
24
+ maxRetries: 3,
25
+ apiKey: "",
26
+ poolConnections: true,
27
+ maxIdleConnections: 10,
28
+ };
29
+ /**
30
+ * Get the global fetch function
31
+ */
32
+ function getFetch() {
33
+ if (typeof globalThis.fetch === "function") {
34
+ return globalThis.fetch.bind(globalThis);
35
+ }
36
+ throw new Error("No fetch implementation available. " +
37
+ "Node.js 18+ includes fetch natively. " +
38
+ "For older versions, install node-fetch.");
39
+ }
40
+ /**
41
+ * ProximaDB client for connecting to a remote server
42
+ */
43
+ class ProximaDBClient {
44
+ config;
45
+ fetchFn;
46
+ /**
47
+ * Generated typed REST transport (TD-126 Phase 4). Core collection / record
48
+ * / search operations route through this; it owns URL/path/query/body
49
+ * encoding per the OpenAPI spec. Auth, retries, and error mapping are
50
+ * injected via the facade's own fetch (see `transportFetch`).
51
+ */
52
+ gen;
53
+ /**
54
+ * Create a new client with the given URL
55
+ */
56
+ static connect(url) {
57
+ return new ProximaDBClient({ url });
58
+ }
59
+ /**
60
+ * Create a new client builder
61
+ */
62
+ static builder() {
63
+ return new ClientBuilder();
64
+ }
65
+ /**
66
+ * Create a client with configuration
67
+ */
68
+ constructor(config = {}) {
69
+ this.config = { ...DEFAULT_CONFIG, ...config };
70
+ this.fetchFn = getFetch();
71
+ // Validate URL
72
+ try {
73
+ new URL(this.config.url);
74
+ }
75
+ catch {
76
+ throw new types_1.ProximaDBError("Invalid URL: " + this.config.url, types_1.ErrorCode.InvalidConfig);
77
+ }
78
+ // Wire the generated typed transport. Every request the generated client
79
+ // issues is funneled through `transportFetch`, the facade's own fetch that
80
+ // applies bearer auth, retries, and error mapping — exactly as the legacy
81
+ // generic `request<T>` path does.
82
+ this.gen = (0, transport_1.createTransport)(this.config.url, (req) => this.transportFetch(req));
83
+ }
84
+ /**
85
+ * Transport `fetch` handed to the generated client.
86
+ *
87
+ * The generated client assembles a resolved `Request` (URL + method + body);
88
+ * this normalizes it back to the facade's `(url, init)` retry/auth/error
89
+ * pipeline so the wire plumbing and transport policy compose. The returned
90
+ * value is a `Response`-shaped object the generated client parses; on an
91
+ * unsuccessful response a `ProximaDBError` is thrown (matching the generic
92
+ * path), so callers never see a non-2xx body.
93
+ */
94
+ async transportFetch(req) {
95
+ const method = (req.method || "GET").toUpperCase();
96
+ let body = undefined;
97
+ if (method !== "GET" && method !== "DELETE") {
98
+ const text = await req.clone().text();
99
+ if (text.length > 0) {
100
+ body = JSON.parse(text);
101
+ }
102
+ }
103
+ const data = await this.request(method, req.url, body);
104
+ // Re-wrap the already-parsed, validated body as a Response so the
105
+ // generated client can read `.json()`/`.ok` without re-issuing I/O.
106
+ return new Response(JSON.stringify(data ?? null), {
107
+ status: 200,
108
+ headers: { "Content-Type": "application/json" },
109
+ });
110
+ }
111
+ /**
112
+ * Get the server URL
113
+ */
114
+ url() {
115
+ return this.config.url;
116
+ }
117
+ /**
118
+ * Get the client configuration
119
+ */
120
+ getConfig() {
121
+ return { ...this.config };
122
+ }
123
+ // =========================================================================
124
+ // HTTP Methods
125
+ // =========================================================================
126
+ /**
127
+ * Make a GET request
128
+ */
129
+ async get(requestUrl) {
130
+ return this.request("GET", requestUrl);
131
+ }
132
+ /**
133
+ * Make a POST request
134
+ */
135
+ async post(requestUrl, body) {
136
+ return this.request("POST", requestUrl, body);
137
+ }
138
+ /**
139
+ * Make a PUT request
140
+ */
141
+ async put(requestUrl, body) {
142
+ return this.request("PUT", requestUrl, body);
143
+ }
144
+ /**
145
+ * Make a DELETE request
146
+ */
147
+ async delete(requestUrl) {
148
+ return this.request("DELETE", requestUrl);
149
+ }
150
+ /**
151
+ * Make an HTTP request with retry logic
152
+ */
153
+ async request(method, requestUrl, body) {
154
+ const headers = {
155
+ "Content-Type": "application/json",
156
+ Accept: "application/json",
157
+ };
158
+ if (this.config.apiKey) {
159
+ headers["Authorization"] = "Bearer " + this.config.apiKey;
160
+ }
161
+ const buildInit = (signal) => {
162
+ const init = {
163
+ method,
164
+ headers,
165
+ signal,
166
+ };
167
+ if (body !== undefined) {
168
+ init.body = JSON.stringify(body);
169
+ }
170
+ return init;
171
+ };
172
+ let lastError = null;
173
+ for (let attempt = 0; attempt <= this.config.maxRetries; attempt++) {
174
+ const controller = new AbortController();
175
+ const timeoutId = setTimeout(() => controller.abort(), this.config.timeoutMs);
176
+ try {
177
+ const response = await this.fetchFn(requestUrl, buildInit(controller.signal));
178
+ return await this.handleResponse(response);
179
+ }
180
+ catch (e) {
181
+ lastError = e instanceof Error ? e : new Error(String(e));
182
+ // Don't retry on client errors (4xx)
183
+ if (lastError instanceof types_1.ProximaDBError) {
184
+ if (lastError.statusCode && lastError.statusCode >= 400 && lastError.statusCode < 500) {
185
+ throw lastError;
186
+ }
187
+ }
188
+ // Wait before retry with exponential backoff
189
+ if (attempt < this.config.maxRetries) {
190
+ const delay = Math.min(1000 * Math.pow(2, attempt), 10000);
191
+ await new Promise((resolve) => setTimeout(resolve, delay));
192
+ }
193
+ }
194
+ finally {
195
+ clearTimeout(timeoutId);
196
+ }
197
+ }
198
+ throw lastError ?? new Error("Request failed after retries");
199
+ }
200
+ /**
201
+ * Handle HTTP response
202
+ */
203
+ async handleResponse(response) {
204
+ if (response.ok) {
205
+ try {
206
+ return (await response.json());
207
+ }
208
+ catch {
209
+ throw new types_1.ProximaDBError("Failed to parse response JSON", types_1.ErrorCode.ServerError, response.status);
210
+ }
211
+ }
212
+ const statusCode = response.status;
213
+ let message = response.statusText;
214
+ try {
215
+ message = await response.text();
216
+ }
217
+ catch {
218
+ // Use statusText if text() fails
219
+ }
220
+ switch (statusCode) {
221
+ case 401:
222
+ throw new types_1.ProximaDBError(message, types_1.ErrorCode.AuthenticationFailed, statusCode);
223
+ case 403:
224
+ throw new types_1.ProximaDBError(message, types_1.ErrorCode.AuthorizationDenied, statusCode);
225
+ case 404:
226
+ throw new types_1.ProximaDBError(message, types_1.ErrorCode.CollectionNotFound, statusCode);
227
+ case 409:
228
+ throw new types_1.ProximaDBError(message, types_1.ErrorCode.CollectionExists, statusCode);
229
+ case 429:
230
+ throw new types_1.ProximaDBError(message, types_1.ErrorCode.RateLimited, statusCode);
231
+ default:
232
+ throw new types_1.ProximaDBError(message, types_1.ErrorCode.ServerError, statusCode);
233
+ }
234
+ }
235
+ // =========================================================================
236
+ // Collection Operations
237
+ // =========================================================================
238
+ /**
239
+ * Get a handle to a collection for fluent operations
240
+ */
241
+ collection(name) {
242
+ return new collection_1.CollectionHandle(this, name);
243
+ }
244
+ /**
245
+ * Create a collection builder
246
+ */
247
+ createCollection(name) {
248
+ return new collection_1.CollectionBuilder(this, name);
249
+ }
250
+ /**
251
+ * Delete a collection
252
+ *
253
+ * Routed through the generated typed transport (TD-126 Phase 4).
254
+ * Wire endpoint: DELETE /api/v2/collections/{collection_id}
255
+ * OpenAPI operationId: deleteCollection
256
+ */
257
+ async deleteCollection(name) {
258
+ await this.gen.DELETE("/api/v2/collections/{collection_id}", {
259
+ params: { path: { collection_id: name } },
260
+ });
261
+ }
262
+ /**
263
+ * List all collections
264
+ *
265
+ * Routed through the generated typed transport (TD-126 Phase 4).
266
+ * Wire endpoint: GET /api/v2/collections
267
+ * OpenAPI operationId: listCollections
268
+ */
269
+ async listCollections() {
270
+ const { data } = await this.gen.GET("/api/v2/collections", {});
271
+ return (data?.collections ?? []);
272
+ }
273
+ /**
274
+ * Get the schema for a collection
275
+ *
276
+ * Routed through the generated typed transport (TD-126 Phase 4).
277
+ * Wire endpoint: GET /api/v2/collections/{collection_id}/schema
278
+ * OpenAPI operationId: getCollectionSchema
279
+ */
280
+ async getCollectionSchema(collectionId) {
281
+ const { data } = await this.gen.GET("/api/v2/collections/{collection_id}/schema", { params: { path: { collection_id: collectionId } } });
282
+ return data;
283
+ }
284
+ /**
285
+ * Update the schema for a collection
286
+ *
287
+ * Routed through the generated typed transport (TD-126 Phase 4).
288
+ * Wire endpoint: PUT /api/v2/collections/{collection_id}/schema
289
+ * OpenAPI operationId: updateCollectionSchema
290
+ */
291
+ async updateCollectionSchema(collectionId, schema) {
292
+ const { data } = await this.gen.PUT("/api/v2/collections/{collection_id}/schema", {
293
+ params: { path: { collection_id: collectionId } },
294
+ body: schema,
295
+ });
296
+ return data;
297
+ }
298
+ // =========================================================================
299
+ // Query Facade (AQL / UQL)
300
+ // =========================================================================
301
+ /**
302
+ * Execute an AQL or UQL query through the shared query facade
303
+ *
304
+ * Wire endpoint: POST /api/v2/query
305
+ * OpenAPI operationId: executeQuery
306
+ */
307
+ async executeQuery(req) {
308
+ const { data } = await this.gen.POST("/api/v2/query", {
309
+ body: req,
310
+ });
311
+ return data;
312
+ }
313
+ /**
314
+ * Explain an AQL or UQL query through the shared query facade
315
+ *
316
+ * Wire endpoint: POST /api/v2/query/explain
317
+ * OpenAPI operationId: explainQuery
318
+ */
319
+ async explainQuery(req) {
320
+ const { data } = await this.gen.POST("/api/v2/query/explain", {
321
+ body: req,
322
+ });
323
+ return data;
324
+ }
325
+ // =========================================================================
326
+ // Typed transport for core collection / record / search ops (TD-126 Phase 4)
327
+ //
328
+ // These route the builders' wire calls through the generated typed client.
329
+ // The builders (collection.ts / search.ts) call these instead of hand-building
330
+ // URL strings, so the core CRUD + search paths are spec-generated end to end.
331
+ // =========================================================================
332
+ /**
333
+ * Create a collection.
334
+ * Wire endpoint: POST /api/v2/collections (createCollection)
335
+ */
336
+ async createCollectionRequest(body) {
337
+ const { data } = await this.gen.POST("/api/v2/collections", {
338
+ body: body,
339
+ });
340
+ return data;
341
+ }
342
+ /**
343
+ * Get collection details.
344
+ * Wire endpoint: GET /api/v2/collections/{collection_id} (getCollection)
345
+ */
346
+ async getCollectionRequest(collectionId) {
347
+ const { data } = await this.gen.GET("/api/v2/collections/{collection_id}", {
348
+ params: { path: { collection_id: collectionId } },
349
+ });
350
+ return data;
351
+ }
352
+ /**
353
+ * Insert / upsert records in a batch.
354
+ * Wire endpoint: POST /api/v2/collections/{collection_id}/records/batch (insertRecords)
355
+ */
356
+ async insertRecordsRequest(collectionId, body) {
357
+ const { data } = await this.gen.POST("/api/v2/collections/{collection_id}/records/batch", {
358
+ params: { path: { collection_id: collectionId } },
359
+ body: body,
360
+ });
361
+ return data;
362
+ }
363
+ /**
364
+ * Get a single record by ID.
365
+ * Wire endpoint: GET /api/v2/collections/{collection_id}/records/{record_id} (getRecord)
366
+ */
367
+ async getRecordRequest(collectionId, recordId, includeVector, includeText) {
368
+ const { data } = await this.gen.GET("/api/v2/collections/{collection_id}/records/{record_id}", {
369
+ params: {
370
+ path: { collection_id: collectionId, record_id: recordId },
371
+ query: { include_vector: includeVector, include_text: includeText },
372
+ },
373
+ });
374
+ return data;
375
+ }
376
+ /**
377
+ * Delete a single record by ID.
378
+ * Wire endpoint: DELETE /api/v2/collections/{collection_id}/records/{record_id} (deleteRecord)
379
+ */
380
+ async deleteRecordRequest(collectionId, recordId) {
381
+ await this.gen.DELETE("/api/v2/collections/{collection_id}/records/{record_id}", {
382
+ params: { path: { collection_id: collectionId, record_id: recordId } },
383
+ });
384
+ }
385
+ /**
386
+ * Vector similarity search.
387
+ * Wire endpoint: POST /api/v2/collections/{collection_id}/search (searchRecords)
388
+ */
389
+ async searchRecordsRequest(collectionId, body) {
390
+ const { data } = await this.gen.POST("/api/v2/collections/{collection_id}/search", {
391
+ params: { path: { collection_id: collectionId } },
392
+ body: body,
393
+ });
394
+ return data;
395
+ }
396
+ // =========================================================================
397
+ // Graph Operations
398
+ // =========================================================================
399
+ /**
400
+ * Get a handle to a graph for fluent operations
401
+ */
402
+ graph(name) {
403
+ return new graph_1.GraphHandle(this, name);
404
+ }
405
+ /**
406
+ * Create a graph builder.
407
+ *
408
+ * Wire endpoint: POST /api/v2/graphs
409
+ * OpenAPI operationId: createGraph
410
+ *
411
+ * The argument is the server-true `graph_id` (unique identifier). Use
412
+ * `.name(...)` on the returned builder to set the optional display name.
413
+ */
414
+ createGraph(graphId) {
415
+ return new graph_1.GraphBuilder(this, graphId);
416
+ }
417
+ /**
418
+ * Delete a graph
419
+ *
420
+ * Routed through the generated typed transport (TD-126 Phase 4).
421
+ * Wire endpoint: DELETE /api/v2/graphs/{graph_id}
422
+ * OpenAPI operationId: deleteGraph
423
+ */
424
+ async deleteGraph(name) {
425
+ await this.gen.DELETE("/api/v2/graphs/{graph_id}", {
426
+ params: { path: { graph_id: name } },
427
+ });
428
+ }
429
+ /**
430
+ * List all graphs
431
+ *
432
+ * Routed through the generated typed transport (TD-126 Phase 4).
433
+ * Wire endpoint: GET /api/v2/graphs
434
+ * OpenAPI operationId: listGraphs
435
+ */
436
+ async listGraphs() {
437
+ const { data } = await this.gen.GET("/api/v2/graphs", {});
438
+ return (data?.graphs ?? []);
439
+ }
440
+ // =========================================================================
441
+ // Typed transport for graph ops (TD-126 Phase 4)
442
+ //
443
+ // Seam methods routing the graph builders' / handle's wire calls through the
444
+ // generated typed client, mirroring the core collection / record / search
445
+ // seams above. The public graph API (graph.ts builders + handle) is
446
+ // unchanged; only the wire dispatch moves off hand-built URL strings.
447
+ // =========================================================================
448
+ /**
449
+ * Create a graph collection.
450
+ * Wire endpoint: POST /api/v2/graphs (createGraph)
451
+ */
452
+ async createGraphRequest(body) {
453
+ const { data } = await this.gen.POST("/api/v2/graphs", {
454
+ body: body,
455
+ });
456
+ return data;
457
+ }
458
+ /**
459
+ * Get a graph collection by id.
460
+ * Wire endpoint: GET /api/v2/graphs/{graph_id} (getGraph)
461
+ */
462
+ async getGraphRequest(graphId) {
463
+ const { data } = await this.gen.GET("/api/v2/graphs/{graph_id}", {
464
+ params: { path: { graph_id: graphId } },
465
+ });
466
+ return data;
467
+ }
468
+ /**
469
+ * Get graph statistics.
470
+ * Wire endpoint: GET /api/v2/graphs/{graph_id}/stats (getGraphStats)
471
+ */
472
+ async getGraphStatsRequest(graphId) {
473
+ const { data } = await this.gen.GET("/api/v2/graphs/{graph_id}/stats", {
474
+ params: { path: { graph_id: graphId } },
475
+ });
476
+ return data;
477
+ }
478
+ /**
479
+ * Create a node in a graph.
480
+ * Wire endpoint: POST /api/v2/graphs/{graph_id}/nodes (createNode)
481
+ */
482
+ async createNodeRequest(graphId, body) {
483
+ const { data } = await this.gen.POST("/api/v2/graphs/{graph_id}/nodes", {
484
+ params: { path: { graph_id: graphId } },
485
+ body: body,
486
+ });
487
+ return data;
488
+ }
489
+ /**
490
+ * Create multiple nodes in a single call.
491
+ * Wire endpoint: POST /api/v2/graphs/{graph_id}/nodes/batch (batchCreateNodes)
492
+ */
493
+ async batchCreateNodesRequest(graphId, body) {
494
+ const { data } = await this.gen.POST("/api/v2/graphs/{graph_id}/nodes/batch", {
495
+ params: { path: { graph_id: graphId } },
496
+ body: body,
497
+ });
498
+ return data;
499
+ }
500
+ /**
501
+ * Get a node by id.
502
+ * Wire endpoint: GET /api/v2/graphs/{graph_id}/nodes/{node_id} (getNode)
503
+ */
504
+ async getNodeRequest(graphId, nodeId) {
505
+ const { data } = await this.gen.GET("/api/v2/graphs/{graph_id}/nodes/{node_id}", {
506
+ params: { path: { graph_id: graphId, node_id: nodeId } },
507
+ });
508
+ return data;
509
+ }
510
+ /**
511
+ * Delete a node by id.
512
+ * Wire endpoint: DELETE /api/v2/graphs/{graph_id}/nodes/{node_id} (deleteNode)
513
+ */
514
+ async deleteNodeRequest(graphId, nodeId) {
515
+ await this.gen.DELETE("/api/v2/graphs/{graph_id}/nodes/{node_id}", {
516
+ params: { path: { graph_id: graphId, node_id: nodeId } },
517
+ });
518
+ }
519
+ /**
520
+ * Create an edge in a graph.
521
+ * Wire endpoint: POST /api/v2/graphs/{graph_id}/edges (createEdge)
522
+ */
523
+ async createEdgeRequest(graphId, body) {
524
+ const { data } = await this.gen.POST("/api/v2/graphs/{graph_id}/edges", {
525
+ params: { path: { graph_id: graphId } },
526
+ body: body,
527
+ });
528
+ return data;
529
+ }
530
+ /**
531
+ * Create multiple edges in a single call.
532
+ * Wire endpoint: POST /api/v2/graphs/{graph_id}/edges/batch (batchCreateEdges)
533
+ */
534
+ async batchCreateEdgesRequest(graphId, body) {
535
+ const { data } = await this.gen.POST("/api/v2/graphs/{graph_id}/edges/batch", {
536
+ params: { path: { graph_id: graphId } },
537
+ body: body,
538
+ });
539
+ return data;
540
+ }
541
+ /**
542
+ * Traverse a graph from a start node.
543
+ * Wire endpoint: POST /api/v2/graphs/{graph_id}/traverse (traverseGraph)
544
+ */
545
+ async traverseGraphRequest(graphId, body) {
546
+ const { data } = await this.gen.POST("/api/v2/graphs/{graph_id}/traverse", {
547
+ params: { path: { graph_id: graphId } },
548
+ body: body,
549
+ });
550
+ return data;
551
+ }
552
+ // =========================================================================
553
+ // Health and Monitoring
554
+ // =========================================================================
555
+ /**
556
+ * Check if the server is healthy
557
+ *
558
+ * Routed through the generated typed transport (TD-126 Phase 4).
559
+ * Wire endpoint: GET /health
560
+ * OpenAPI operationId: getHealth
561
+ */
562
+ async health() {
563
+ const { data } = await this.gen.GET("/health", {});
564
+ return data;
565
+ }
566
+ /**
567
+ * Kubernetes-style liveness probe
568
+ *
569
+ * Routed through the generated typed transport (TD-126 Phase 4).
570
+ * Wire endpoint: GET /health/live
571
+ * OpenAPI operationId: getLiveness
572
+ */
573
+ async healthLive() {
574
+ const { data } = await this.gen.GET("/health/live", {});
575
+ return data;
576
+ }
577
+ /**
578
+ * Kubernetes-style readiness probe
579
+ *
580
+ * Routed through the generated typed transport (TD-126 Phase 4).
581
+ * Wire endpoint: GET /health/ready
582
+ * OpenAPI operationId: getReadiness
583
+ */
584
+ async healthReady() {
585
+ const { data } = await this.gen.GET("/health/ready", {});
586
+ return data;
587
+ }
588
+ /**
589
+ * Check if the server is reachable
590
+ */
591
+ async ping() {
592
+ try {
593
+ await this.health();
594
+ return true;
595
+ }
596
+ catch {
597
+ return false;
598
+ }
599
+ }
600
+ }
601
+ exports.ProximaDBClient = ProximaDBClient;
602
+ // ============================================================================
603
+ // CLIENT BUILDER
604
+ // ============================================================================
605
+ /**
606
+ * Builder for creating a ProximaDB client with custom configuration
607
+ */
608
+ class ClientBuilder {
609
+ config = {};
610
+ /**
611
+ * Set the server URL
612
+ */
613
+ url(serverUrl) {
614
+ this.config.url = serverUrl;
615
+ return this;
616
+ }
617
+ /**
618
+ * Set the request timeout in milliseconds
619
+ */
620
+ timeoutMs(timeout) {
621
+ this.config.timeoutMs = timeout;
622
+ return this;
623
+ }
624
+ /**
625
+ * Set the maximum number of retries
626
+ */
627
+ maxRetries(retries) {
628
+ this.config.maxRetries = retries;
629
+ return this;
630
+ }
631
+ /**
632
+ * Set the API key for authentication
633
+ */
634
+ apiKey(key) {
635
+ this.config.apiKey = key;
636
+ return this;
637
+ }
638
+ /**
639
+ * Enable or disable connection pooling
640
+ */
641
+ poolConnections(enable) {
642
+ this.config.poolConnections = enable;
643
+ return this;
644
+ }
645
+ /**
646
+ * Set maximum idle connections in pool
647
+ */
648
+ maxIdleConnections(max) {
649
+ this.config.maxIdleConnections = max;
650
+ return this;
651
+ }
652
+ /**
653
+ * Build the ProximaDB client
654
+ */
655
+ build() {
656
+ return new ProximaDBClient(this.config);
657
+ }
658
+ /**
659
+ * Connect to the server (alias for build)
660
+ */
661
+ connect() {
662
+ return this.build();
663
+ }
664
+ }
665
+ exports.ClientBuilder = ClientBuilder;
666
+ // ============================================================================
667
+ // CONVENIENCE FUNCTIONS
668
+ // ============================================================================
669
+ /**
670
+ * Create a ProximaDB client connected to the given URL
671
+ */
672
+ function connect(url = "http://localhost:5678") {
673
+ return ProximaDBClient.connect(url);
674
+ }
675
+ /**
676
+ * Create a ProximaDB client with REST protocol
677
+ */
678
+ function connectRest(url = "http://localhost:5678") {
679
+ return ProximaDBClient.connect(url);
680
+ }
681
+ //# sourceMappingURL=client.js.map