@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.
- package/README.md +160 -0
- package/dist/client.d.ts +319 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +681 -0
- package/dist/client.js.map +1 -0
- package/dist/collection.d.ts +227 -0
- package/dist/collection.d.ts.map +1 -0
- package/dist/collection.js +436 -0
- package/dist/collection.js.map +1 -0
- package/dist/esm/client.js +674 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/collection.js +428 -0
- package/dist/esm/collection.js.map +1 -0
- package/dist/esm/filter.js +228 -0
- package/dist/esm/filter.js.map +1 -0
- package/dist/esm/generated/schema.js +6 -0
- package/dist/esm/generated/schema.js.map +1 -0
- package/dist/esm/graph.js +678 -0
- package/dist/esm/graph.js.map +1 -0
- package/dist/esm/index.js +86 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/search.js +317 -0
- package/dist/esm/search.js.map +1 -0
- package/dist/esm/transport.js +33 -0
- package/dist/esm/transport.js.map +1 -0
- package/dist/esm/types.js +181 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/filter.d.ts +51 -0
- package/dist/filter.d.ts.map +1 -0
- package/dist/filter.js +241 -0
- package/dist/filter.js.map +1 -0
- package/dist/generated/schema.d.ts +4271 -0
- package/dist/generated/schema.d.ts.map +1 -0
- package/dist/generated/schema.js +7 -0
- package/dist/generated/schema.js.map +1 -0
- package/dist/graph.d.ts +350 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +690 -0
- package/dist/graph.js.map +1 -0
- package/dist/index.d.ts +58 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +126 -0
- package/dist/index.js.map +1 -0
- package/dist/search.d.ts +160 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +322 -0
- package/dist/search.js.map +1 -0
- package/dist/transport.d.ts +40 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +39 -0
- package/dist/transport.js.map +1 -0
- package/dist/types.d.ts +632 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +185 -0
- package/dist/types.js.map +1 -0
- package/package.json +72 -0
- package/src/client.ts +856 -0
- package/src/collection.ts +578 -0
- package/src/filter.ts +280 -0
- package/src/generated/schema.ts +4271 -0
- package/src/graph.ts +811 -0
- package/src/index.ts +184 -0
- package/src/search.ts +401 -0
- package/src/transport.ts +52 -0
- package/src/types.ts +726 -0
package/dist/search.js
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ProximaDB TypeScript SDK - Search Builder
|
|
4
|
+
*
|
|
5
|
+
* Provides a fluent API for building and executing vector similarity searches.
|
|
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.SearchBuilder = void 0;
|
|
12
|
+
exports.createSearchBuilder = createSearchBuilder;
|
|
13
|
+
const types_1 = require("./types");
|
|
14
|
+
const filter_1 = require("./filter");
|
|
15
|
+
/**
|
|
16
|
+
* Builder for search queries with fluent API
|
|
17
|
+
*/
|
|
18
|
+
class SearchBuilder {
|
|
19
|
+
client;
|
|
20
|
+
collectionName;
|
|
21
|
+
queryVector = null;
|
|
22
|
+
k = 10;
|
|
23
|
+
filterExpr = null;
|
|
24
|
+
filterBuilder = null;
|
|
25
|
+
searchMode = types_1.SearchMode.Exact;
|
|
26
|
+
nprobeValue = null;
|
|
27
|
+
adaptiveThreshold = null;
|
|
28
|
+
includeVectorsFlag = false;
|
|
29
|
+
minScoreValue = null;
|
|
30
|
+
timeoutMsValue = null;
|
|
31
|
+
constructor(client, collection) {
|
|
32
|
+
this.client = client;
|
|
33
|
+
this.collectionName = collection;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Set the query vector
|
|
37
|
+
*/
|
|
38
|
+
vector(vec) {
|
|
39
|
+
this.queryVector = vec;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Set the number of results to return
|
|
44
|
+
*/
|
|
45
|
+
topK(k) {
|
|
46
|
+
this.k = k;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Alias for topK
|
|
51
|
+
*/
|
|
52
|
+
limit(k) {
|
|
53
|
+
return this.topK(k);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Set a filter expression string
|
|
57
|
+
*/
|
|
58
|
+
filter(filterStr) {
|
|
59
|
+
this.filterExpr = filterStr;
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Apply a pre-built filter
|
|
64
|
+
*/
|
|
65
|
+
withFilter(filterObj) {
|
|
66
|
+
this.filterExpr = (0, filter_1.filterToExpression)(filterObj);
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Set the search mode
|
|
71
|
+
*/
|
|
72
|
+
mode(searchMode) {
|
|
73
|
+
this.searchMode = searchMode;
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Use exact search (100% recall)
|
|
78
|
+
*/
|
|
79
|
+
exact() {
|
|
80
|
+
this.searchMode = types_1.SearchMode.Exact;
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Use approximate search for faster results
|
|
85
|
+
*/
|
|
86
|
+
approximate() {
|
|
87
|
+
this.searchMode = types_1.SearchMode.Approximate;
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Use approximate search with specific nprobe value
|
|
92
|
+
*/
|
|
93
|
+
approximateWithNprobe(nprobe) {
|
|
94
|
+
this.searchMode = types_1.SearchMode.Approximate;
|
|
95
|
+
this.nprobeValue = nprobe;
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Use adaptive search mode
|
|
100
|
+
*/
|
|
101
|
+
adaptive(threshold) {
|
|
102
|
+
this.searchMode = types_1.SearchMode.Adaptive;
|
|
103
|
+
this.adaptiveThreshold = threshold;
|
|
104
|
+
return this;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Include vectors in results
|
|
108
|
+
*/
|
|
109
|
+
includeVectors(include = true) {
|
|
110
|
+
this.includeVectorsFlag = include;
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Include metadata in results
|
|
115
|
+
*/
|
|
116
|
+
includeMetadata(_include = true) {
|
|
117
|
+
return this;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Set minimum score threshold
|
|
121
|
+
*/
|
|
122
|
+
minScore(score) {
|
|
123
|
+
this.minScoreValue = score;
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Set request timeout in milliseconds
|
|
128
|
+
*/
|
|
129
|
+
timeoutMs(timeout) {
|
|
130
|
+
this.timeoutMsValue = timeout;
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Set timeout in seconds (convenience method)
|
|
135
|
+
*/
|
|
136
|
+
timeoutSecs(secs) {
|
|
137
|
+
this.timeoutMsValue = secs * 1000;
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
// =========================================================================
|
|
141
|
+
// Inline filter methods for convenience
|
|
142
|
+
// =========================================================================
|
|
143
|
+
/**
|
|
144
|
+
* Add an equality filter condition
|
|
145
|
+
*/
|
|
146
|
+
filterEq(field, value) {
|
|
147
|
+
this.ensureFilterBuilder();
|
|
148
|
+
this.filterBuilder = this.filterBuilder.eq(field, value);
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Add a not-equal filter condition
|
|
153
|
+
*/
|
|
154
|
+
filterNe(field, value) {
|
|
155
|
+
this.ensureFilterBuilder();
|
|
156
|
+
this.filterBuilder = this.filterBuilder.ne(field, value);
|
|
157
|
+
return this;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Add a greater-than filter condition
|
|
161
|
+
*/
|
|
162
|
+
filterGt(field, value) {
|
|
163
|
+
this.ensureFilterBuilder();
|
|
164
|
+
this.filterBuilder = this.filterBuilder.gt(field, value);
|
|
165
|
+
return this;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Add a greater-than-or-equal filter condition
|
|
169
|
+
*/
|
|
170
|
+
filterGte(field, value) {
|
|
171
|
+
this.ensureFilterBuilder();
|
|
172
|
+
this.filterBuilder = this.filterBuilder.gte(field, value);
|
|
173
|
+
return this;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Add a less-than filter condition
|
|
177
|
+
*/
|
|
178
|
+
filterLt(field, value) {
|
|
179
|
+
this.ensureFilterBuilder();
|
|
180
|
+
this.filterBuilder = this.filterBuilder.lt(field, value);
|
|
181
|
+
return this;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Add a less-than-or-equal filter condition
|
|
185
|
+
*/
|
|
186
|
+
filterLte(field, value) {
|
|
187
|
+
this.ensureFilterBuilder();
|
|
188
|
+
this.filterBuilder = this.filterBuilder.lte(field, value);
|
|
189
|
+
return this;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Add a range filter condition (inclusive)
|
|
193
|
+
*/
|
|
194
|
+
filterRange(field, min, max) {
|
|
195
|
+
this.ensureFilterBuilder();
|
|
196
|
+
this.filterBuilder = this.filterBuilder.range(field, min, max);
|
|
197
|
+
return this;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Add an IN filter condition
|
|
201
|
+
*/
|
|
202
|
+
filterIn(field, values) {
|
|
203
|
+
this.ensureFilterBuilder();
|
|
204
|
+
this.filterBuilder = this.filterBuilder.inList(field, values);
|
|
205
|
+
return this;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Add a contains filter condition
|
|
209
|
+
*/
|
|
210
|
+
filterContains(field, value) {
|
|
211
|
+
this.ensureFilterBuilder();
|
|
212
|
+
this.filterBuilder = this.filterBuilder.contains(field, value);
|
|
213
|
+
return this;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Add an exists filter condition
|
|
217
|
+
*/
|
|
218
|
+
filterExists(field) {
|
|
219
|
+
this.ensureFilterBuilder();
|
|
220
|
+
this.filterBuilder = this.filterBuilder.exists(field);
|
|
221
|
+
return this;
|
|
222
|
+
}
|
|
223
|
+
ensureFilterBuilder() {
|
|
224
|
+
if (this.filterBuilder === null) {
|
|
225
|
+
this.filterBuilder = filter_1.FilterBuilder.new();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
buildFilter() {
|
|
229
|
+
if (this.filterBuilder !== null) {
|
|
230
|
+
return this.filterBuilder.toExpression();
|
|
231
|
+
}
|
|
232
|
+
return this.filterExpr ?? undefined;
|
|
233
|
+
}
|
|
234
|
+
buildSearchModeString() {
|
|
235
|
+
switch (this.searchMode) {
|
|
236
|
+
case types_1.SearchMode.Exact:
|
|
237
|
+
return "exact";
|
|
238
|
+
case types_1.SearchMode.Approximate:
|
|
239
|
+
if (this.nprobeValue !== null) {
|
|
240
|
+
return "approximate:" + this.nprobeValue;
|
|
241
|
+
}
|
|
242
|
+
return "approximate";
|
|
243
|
+
case types_1.SearchMode.Adaptive:
|
|
244
|
+
if (this.adaptiveThreshold !== null) {
|
|
245
|
+
return "adaptive:" + this.adaptiveThreshold;
|
|
246
|
+
}
|
|
247
|
+
return "adaptive:10000";
|
|
248
|
+
default:
|
|
249
|
+
return "exact";
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Execute the search query
|
|
254
|
+
*/
|
|
255
|
+
async execute() {
|
|
256
|
+
if (this.queryVector === null) {
|
|
257
|
+
throw new Error("Query vector is required");
|
|
258
|
+
}
|
|
259
|
+
if (this.k <= 0 || this.k > 10000) {
|
|
260
|
+
throw new Error("topK must be between 1 and 10000");
|
|
261
|
+
}
|
|
262
|
+
const request = {
|
|
263
|
+
vector: this.queryVector,
|
|
264
|
+
top_k: this.k,
|
|
265
|
+
filter: this.buildFilter(),
|
|
266
|
+
searchMode: this.buildSearchModeString(),
|
|
267
|
+
include_vector: this.includeVectorsFlag,
|
|
268
|
+
include_text: false,
|
|
269
|
+
timeoutMs: this.timeoutMsValue ?? undefined,
|
|
270
|
+
};
|
|
271
|
+
const response = (await this.client.searchRecordsRequest(this.collectionName, request));
|
|
272
|
+
let results = response.results;
|
|
273
|
+
// Apply min_score filter if set
|
|
274
|
+
if (this.minScoreValue !== null) {
|
|
275
|
+
results = results.filter((r) => r.score >= this.minScoreValue);
|
|
276
|
+
}
|
|
277
|
+
return results;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Execute the search and return a streaming iterator
|
|
281
|
+
*/
|
|
282
|
+
async *stream() {
|
|
283
|
+
const results = await this.execute();
|
|
284
|
+
for (const result of results) {
|
|
285
|
+
yield result;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Create an async iterator for streaming results
|
|
290
|
+
*/
|
|
291
|
+
async iterate() {
|
|
292
|
+
const results = await this.execute();
|
|
293
|
+
let index = 0;
|
|
294
|
+
const total = results.length;
|
|
295
|
+
const iterator = {
|
|
296
|
+
[Symbol.asyncIterator]() {
|
|
297
|
+
return iterator;
|
|
298
|
+
},
|
|
299
|
+
async next() {
|
|
300
|
+
if (index < results.length) {
|
|
301
|
+
return { value: results[index++], done: false };
|
|
302
|
+
}
|
|
303
|
+
return { value: undefined, done: true };
|
|
304
|
+
},
|
|
305
|
+
getTotal() {
|
|
306
|
+
return total;
|
|
307
|
+
},
|
|
308
|
+
isComplete() {
|
|
309
|
+
return index >= results.length;
|
|
310
|
+
},
|
|
311
|
+
};
|
|
312
|
+
return iterator;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
exports.SearchBuilder = SearchBuilder;
|
|
316
|
+
/**
|
|
317
|
+
* Create a new search builder
|
|
318
|
+
*/
|
|
319
|
+
function createSearchBuilder(client, collection) {
|
|
320
|
+
return new SearchBuilder(client, collection);
|
|
321
|
+
}
|
|
322
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAoYH,kDAKC;AAjYD,mCAAqC;AACrC,qCAA6D;AA+B7D;;GAEG;AACH,MAAa,aAAa;IAChB,MAAM,CAAmB;IACzB,cAAc,CAAS;IACvB,WAAW,GAAoB,IAAI,CAAC;IACpC,CAAC,GAAW,EAAE,CAAC;IACf,UAAU,GAAkB,IAAI,CAAC;IACjC,aAAa,GAAyB,IAAI,CAAC;IAC3C,UAAU,GAAe,kBAAU,CAAC,KAAK,CAAC;IAC1C,WAAW,GAAkB,IAAI,CAAC;IAClC,iBAAiB,GAAkB,IAAI,CAAC;IACxC,kBAAkB,GAAY,KAAK,CAAC;IACpC,aAAa,GAAkB,IAAI,CAAC;IACpC,cAAc,GAAkB,IAAI,CAAC;IAE7C,YAAY,MAAwB,EAAE,UAAkB;QACtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,GAAa;QAClB,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,CAAS;QACZ,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,CAAS;QACb,OAAO,IAAI,CAAC,IAAI,CAA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,CAAC,IAAI;gBACR,IAAI,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;oBAC3B,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;gBACnD,CAAC;gBACD,OAAO,EAAE,KAAK,EAAE,SAAoC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YACrE,CAAC;YACD,QAAQ;gBACN,OAAO,KAAK,CAAC;YACf,CAAC;YACD,UAAU;gBACR,OAAO,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;YACjC,CAAC;SACF,CAAC;QAEF,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AApVD,sCAoVC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CACjC,MAAwB,EACxB,UAAkB;IAElB,OAAO,IAAI,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProximaDB TypeScript SDK - Generated REST transport seam (TD-126 Phase 4)
|
|
3
|
+
*
|
|
4
|
+
* This is the thin, hand-written ergonomic facade over the GENERATED REST
|
|
5
|
+
* transport. The wire contract — path templates, path/query parameter
|
|
6
|
+
* encoding, request/response JSON shapes — is generated from
|
|
7
|
+
* `docs/openapi/proximadb-openapi.yaml` into `src/generated/schema.ts`
|
|
8
|
+
* (openapi-typescript, pinned in package.json; regenerate with
|
|
9
|
+
* `npm run gen-sdk`). `openapi-fetch` turns those generated `paths` types into
|
|
10
|
+
* a typed runtime client.
|
|
11
|
+
*
|
|
12
|
+
* Generators don't do ergonomics; this layer is the value-add: it injects the
|
|
13
|
+
* facade's own `fetch` (which owns bearer auth, retries, and error mapping —
|
|
14
|
+
* see `client.ts`) into the typed client, so the generated wire plumbing and
|
|
15
|
+
* the hand-written transport policy compose without either reimplementing the
|
|
16
|
+
* other. This mirrors the merged Go pilot (TD-126 Phase 2), where the generated
|
|
17
|
+
* `genrest.Client` is driven through `RequestEditorFn`s + a custom `http.Client`.
|
|
18
|
+
*
|
|
19
|
+
* Copyright 2025 ProximaDB Contributors
|
|
20
|
+
* Licensed under the Apache License, Version 2.0
|
|
21
|
+
*/
|
|
22
|
+
import type { Client } from "openapi-fetch";
|
|
23
|
+
import type { paths } from "./generated/schema";
|
|
24
|
+
/**
|
|
25
|
+
* The typed REST client over the generated OpenAPI `paths`.
|
|
26
|
+
*/
|
|
27
|
+
export type GeneratedClient = Client<paths>;
|
|
28
|
+
/**
|
|
29
|
+
* A fetch implementation matching the facade's transport policy. It is given a
|
|
30
|
+
* resolved `Request` (URL + method + body assembled by the generated client)
|
|
31
|
+
* and must return a native `Response`. The facade implements auth/retry/error
|
|
32
|
+
* mapping inside this function (see `ProximaDBClient`).
|
|
33
|
+
*/
|
|
34
|
+
export type TransportFetch = (input: Request) => Promise<Response>;
|
|
35
|
+
/**
|
|
36
|
+
* Construct the generated typed REST client, routing every request the
|
|
37
|
+
* generated client issues through the facade's transport `fetch`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function createTransport(baseUrl: string, fetchImpl: TransportFetch): GeneratedClient;
|
|
40
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEnE;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,cAAc,GACxB,eAAe,CAKjB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ProximaDB TypeScript SDK - Generated REST transport seam (TD-126 Phase 4)
|
|
4
|
+
*
|
|
5
|
+
* This is the thin, hand-written ergonomic facade over the GENERATED REST
|
|
6
|
+
* transport. The wire contract — path templates, path/query parameter
|
|
7
|
+
* encoding, request/response JSON shapes — is generated from
|
|
8
|
+
* `docs/openapi/proximadb-openapi.yaml` into `src/generated/schema.ts`
|
|
9
|
+
* (openapi-typescript, pinned in package.json; regenerate with
|
|
10
|
+
* `npm run gen-sdk`). `openapi-fetch` turns those generated `paths` types into
|
|
11
|
+
* a typed runtime client.
|
|
12
|
+
*
|
|
13
|
+
* Generators don't do ergonomics; this layer is the value-add: it injects the
|
|
14
|
+
* facade's own `fetch` (which owns bearer auth, retries, and error mapping —
|
|
15
|
+
* see `client.ts`) into the typed client, so the generated wire plumbing and
|
|
16
|
+
* the hand-written transport policy compose without either reimplementing the
|
|
17
|
+
* other. This mirrors the merged Go pilot (TD-126 Phase 2), where the generated
|
|
18
|
+
* `genrest.Client` is driven through `RequestEditorFn`s + a custom `http.Client`.
|
|
19
|
+
*
|
|
20
|
+
* Copyright 2025 ProximaDB Contributors
|
|
21
|
+
* Licensed under the Apache License, Version 2.0
|
|
22
|
+
*/
|
|
23
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.createTransport = createTransport;
|
|
28
|
+
const openapi_fetch_1 = __importDefault(require("openapi-fetch"));
|
|
29
|
+
/**
|
|
30
|
+
* Construct the generated typed REST client, routing every request the
|
|
31
|
+
* generated client issues through the facade's transport `fetch`.
|
|
32
|
+
*/
|
|
33
|
+
function createTransport(baseUrl, fetchImpl) {
|
|
34
|
+
return (0, openapi_fetch_1.default)({
|
|
35
|
+
baseUrl,
|
|
36
|
+
fetch: fetchImpl,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;AAuBH,0CAQC;AA7BD,kEAAyC;AAiBzC;;;GAGG;AACH,SAAgB,eAAe,CAC7B,OAAe,EACf,SAAyB;IAEzB,OAAO,IAAA,uBAAY,EAAQ;QACzB,OAAO;QACP,KAAK,EAAE,SAAS;KACjB,CAAC,CAAC;AACL,CAAC"}
|