@dalgo/dalgo2typesense 0.0.0-bootstrap.0 → 0.2.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 +257 -4
- package/dist/capabilities.d.ts +185 -0
- package/dist/capabilities.js +76 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/database.d.ts +86 -0
- package/dist/database.js +1050 -0
- package/dist/database.js.map +1 -0
- package/dist/errors.d.ts +43 -0
- package/dist/errors.js +63 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/json.d.ts +32 -0
- package/dist/json.js +222 -0
- package/dist/json.js.map +1 -0
- package/dist/metadata.d.ts +54 -0
- package/dist/metadata.js +159 -0
- package/dist/metadata.js.map +1 -0
- package/dist/search.d.ts +82 -0
- package/dist/search.js +238 -0
- package/dist/search.js.map +1 -0
- package/dist/structured.d.ts +79 -0
- package/dist/structured.js +399 -0
- package/dist/structured.js.map +1 -0
- package/dist/transport.d.ts +51 -0
- package/dist/transport.js +317 -0
- package/dist/transport.js.map +1 -0
- package/package.json +50 -7
- package/LICENSE +0 -22
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import { DOCUMENT_ID, UnsupportedError, } from "@dalgo/core";
|
|
2
|
+
import { isLosslessNumber } from "./json.js";
|
|
3
|
+
const SIMPLE_FIELD = /^[A-Za-z][A-Za-z0-9_]{0,127}$/u;
|
|
4
|
+
const DEFAULT_MAX_DEPTH = 8;
|
|
5
|
+
const DEFAULT_MAX_CONDITIONS = 64;
|
|
6
|
+
const MAX_STRING_BYTES = 1_024;
|
|
7
|
+
const MAX_IN_VALUES = 100;
|
|
8
|
+
/**
|
|
9
|
+
* Units of verification work charged between two macrotask pulses. An ordinary
|
|
10
|
+
* AND/OR leaf costs one unit and every IN literal costs one more, so a bounded
|
|
11
|
+
* tree smaller than this budget still yields once enough rows are verified. A
|
|
12
|
+
* shared operation/window state is used, never a per-row counter.
|
|
13
|
+
*/
|
|
14
|
+
const YIELD_WORK = 32;
|
|
15
|
+
export function structuredField(value) {
|
|
16
|
+
const name = value === DOCUMENT_ID ? "id" : String(value);
|
|
17
|
+
if (name === "id")
|
|
18
|
+
return "id";
|
|
19
|
+
if (!SIMPLE_FIELD.test(name)) {
|
|
20
|
+
throw new UnsupportedError("Typesense structured queries support simple top-level fields only");
|
|
21
|
+
}
|
|
22
|
+
return name;
|
|
23
|
+
}
|
|
24
|
+
export function projectionFields(value, maximum) {
|
|
25
|
+
if (value === undefined)
|
|
26
|
+
return undefined;
|
|
27
|
+
if (!Array.isArray(value) || value.length === 0 || value.length > maximum) {
|
|
28
|
+
throw new UnsupportedError(`Typesense projection must contain from 1 to ${String(maximum)} fields`);
|
|
29
|
+
}
|
|
30
|
+
const fields = value.map((field) => structuredField(field));
|
|
31
|
+
if (new Set(fields).size !== fields.length) {
|
|
32
|
+
throw new UnsupportedError("Typesense projection fields must be unique");
|
|
33
|
+
}
|
|
34
|
+
return Object.freeze(fields);
|
|
35
|
+
}
|
|
36
|
+
export function orderFields(orders, maximum) {
|
|
37
|
+
if (orders.length > maximum) {
|
|
38
|
+
throw new UnsupportedError(`Typesense sort_by exceeds ${String(maximum)} fields`);
|
|
39
|
+
}
|
|
40
|
+
const result = [];
|
|
41
|
+
const seen = new Set();
|
|
42
|
+
for (const order of orders) {
|
|
43
|
+
const field = structuredField(order.field);
|
|
44
|
+
if (field === "id")
|
|
45
|
+
throw new UnsupportedError("Typesense does not invent an id sort");
|
|
46
|
+
if (order.direction !== "asc" && order.direction !== "desc") {
|
|
47
|
+
throw new UnsupportedError("Typesense sort directions");
|
|
48
|
+
}
|
|
49
|
+
if (seen.has(field))
|
|
50
|
+
throw new UnsupportedError("Typesense duplicate sort fields");
|
|
51
|
+
seen.add(field);
|
|
52
|
+
result.push({ field, direction: order.direction });
|
|
53
|
+
}
|
|
54
|
+
return Object.freeze(result.map((item) => Object.freeze(item)));
|
|
55
|
+
}
|
|
56
|
+
export function isNumericSchemaType(type) {
|
|
57
|
+
return type === "int32" || type === "int64" || type === "float";
|
|
58
|
+
}
|
|
59
|
+
export function isNumericField(fields, field) {
|
|
60
|
+
return isNumericSchemaType(fields.get(field));
|
|
61
|
+
}
|
|
62
|
+
function stringLiteral(value) {
|
|
63
|
+
if (value.length === 0)
|
|
64
|
+
throw new UnsupportedError("Typesense filter strings must not be empty");
|
|
65
|
+
if (!value.isWellFormed()) {
|
|
66
|
+
throw new UnsupportedError("Typesense filter strings must be valid, bounded and control-free");
|
|
67
|
+
}
|
|
68
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
69
|
+
const code = value.charCodeAt(index);
|
|
70
|
+
if (code < 0x20 || code === 0x7f || code === 0x60) {
|
|
71
|
+
throw new UnsupportedError("Typesense filter strings must be valid, bounded and control-free");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (new TextEncoder().encode(value).byteLength > MAX_STRING_BYTES) {
|
|
75
|
+
throw new UnsupportedError("Typesense filter strings exceed the supported byte length");
|
|
76
|
+
}
|
|
77
|
+
return { class: "string", value, wire: `\`${value}\`` };
|
|
78
|
+
}
|
|
79
|
+
function numberLiteral(value) {
|
|
80
|
+
if (!isLosslessNumber(value)) {
|
|
81
|
+
throw new UnsupportedError("Typesense filter numbers must be finite, lossless safe values and not -0");
|
|
82
|
+
}
|
|
83
|
+
return { class: "number", value, wire: String(value) };
|
|
84
|
+
}
|
|
85
|
+
export function filterLiteral(value) {
|
|
86
|
+
if (typeof value === "string")
|
|
87
|
+
return stringLiteral(value);
|
|
88
|
+
if (typeof value === "number")
|
|
89
|
+
return numberLiteral(value);
|
|
90
|
+
if (typeof value === "boolean")
|
|
91
|
+
return { class: "boolean", value, wire: value ? "true" : "false" };
|
|
92
|
+
throw new UnsupportedError("Typesense filter values must be string, lossless number or boolean scalars");
|
|
93
|
+
}
|
|
94
|
+
function membershipLiterals(values) {
|
|
95
|
+
if (values.length === 0)
|
|
96
|
+
throw new UnsupportedError("Typesense IN lists must not be empty");
|
|
97
|
+
if (values.length > MAX_IN_VALUES) {
|
|
98
|
+
throw new UnsupportedError(`Typesense IN lists must not exceed ${String(MAX_IN_VALUES)} values`);
|
|
99
|
+
}
|
|
100
|
+
const literals = values.map((value) => filterLiteral(value));
|
|
101
|
+
const first = literals[0]?.class;
|
|
102
|
+
if (!literals.every((literal) => literal.class === first)) {
|
|
103
|
+
throw new UnsupportedError("Typesense IN lists must use one scalar class");
|
|
104
|
+
}
|
|
105
|
+
const wires = new Set(literals.map((literal) => literal.wire));
|
|
106
|
+
if (wires.size !== literals.length) {
|
|
107
|
+
throw new UnsupportedError("Typesense IN lists must not repeat a value");
|
|
108
|
+
}
|
|
109
|
+
return Object.freeze(literals);
|
|
110
|
+
}
|
|
111
|
+
function comparison(field, operator, right) {
|
|
112
|
+
if (operator === "!=" || operator === "not-in") {
|
|
113
|
+
throw new UnsupportedError("Typesense structured negative predicates are refused before I/O");
|
|
114
|
+
}
|
|
115
|
+
if (operator === "array-contains" || operator === "array-contains-any") {
|
|
116
|
+
throw new UnsupportedError("Typesense structured array membership is not an exact core contract and is refused before I/O");
|
|
117
|
+
}
|
|
118
|
+
if (operator === "in") {
|
|
119
|
+
if (!Array.isArray(right))
|
|
120
|
+
throw new UnsupportedError("Typesense structured IN requires an array value");
|
|
121
|
+
return { kind: "comparison", field, operator, literals: membershipLiterals(right) };
|
|
122
|
+
}
|
|
123
|
+
if (operator !== "==" && operator !== "<" && operator !== "<=" && operator !== ">" && operator !== ">=") {
|
|
124
|
+
throw new UnsupportedError("Typesense structured comparison operator is not supported");
|
|
125
|
+
}
|
|
126
|
+
if (right === null)
|
|
127
|
+
throw new UnsupportedError("Typesense structured null comparisons are refused before I/O");
|
|
128
|
+
return { kind: "comparison", field, operator, literal: filterLiteral(right) };
|
|
129
|
+
}
|
|
130
|
+
function expressionScalar(expression) {
|
|
131
|
+
if (expression.kind === "literal")
|
|
132
|
+
return expression.value;
|
|
133
|
+
throw new UnsupportedError("Typesense structured comparisons require a literal right operand");
|
|
134
|
+
}
|
|
135
|
+
function expressionMembership(expression) {
|
|
136
|
+
if (expression.kind === "values")
|
|
137
|
+
return expression.values;
|
|
138
|
+
if (expression.kind === "literal" && Array.isArray(expression.value))
|
|
139
|
+
return expression.value;
|
|
140
|
+
throw new UnsupportedError("Typesense structured IN requires a values list");
|
|
141
|
+
}
|
|
142
|
+
function comparisonFromCondition(node) {
|
|
143
|
+
if (node.left.kind !== "field" || node.left.field.source !== "") {
|
|
144
|
+
throw new UnsupportedError("Typesense structured comparisons require one unqualified field on the left");
|
|
145
|
+
}
|
|
146
|
+
const field = structuredField(node.left.field.field);
|
|
147
|
+
if (node.operator === "in")
|
|
148
|
+
return comparison(field, node.operator, expressionMembership(node.right));
|
|
149
|
+
return comparison(field, node.operator, expressionScalar(node.right));
|
|
150
|
+
}
|
|
151
|
+
function compileWhere(value, depth, maxDepth, maxConditions, charge) {
|
|
152
|
+
void maxConditions;
|
|
153
|
+
charge();
|
|
154
|
+
if (depth > maxDepth)
|
|
155
|
+
throw new UnsupportedError("Typesense condition tree exceeds the configured depth bound");
|
|
156
|
+
if (!("kind" in value))
|
|
157
|
+
return comparisonFromCondition(value);
|
|
158
|
+
if (value.kind === "and" || value.kind === "or") {
|
|
159
|
+
const group = value;
|
|
160
|
+
if (group.conditions.length === 0)
|
|
161
|
+
throw new UnsupportedError("Typesense empty condition groups");
|
|
162
|
+
return {
|
|
163
|
+
kind: "group",
|
|
164
|
+
operator: group.kind,
|
|
165
|
+
children: group.conditions.map((child) => compileWhere(child, depth + 1, maxDepth, maxConditions, charge)),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
if (value.kind === "is-null" || value.kind === "is-not-null") {
|
|
169
|
+
void value;
|
|
170
|
+
throw new UnsupportedError("Typesense structured null tests are refused before I/O");
|
|
171
|
+
}
|
|
172
|
+
throw new UnsupportedError("Typesense condition type is not supported");
|
|
173
|
+
}
|
|
174
|
+
function collect(node, fields, ranges) {
|
|
175
|
+
if (node.kind === "group") {
|
|
176
|
+
for (const child of node.children)
|
|
177
|
+
collect(child, fields, ranges);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
fields.add(node.field);
|
|
181
|
+
if (node.operator === "<" || node.operator === "<=" || node.operator === ">" || node.operator === ">=") {
|
|
182
|
+
ranges.add(node.field);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function render(node, numeric, maxBytes) {
|
|
186
|
+
if (node.kind === "group") {
|
|
187
|
+
const parts = node.children.map((child) => render(child, numeric, maxBytes));
|
|
188
|
+
const result = `(${parts.join(node.operator === "and" ? " && " : " || ")})`;
|
|
189
|
+
if (new TextEncoder().encode(result).byteLength > maxBytes)
|
|
190
|
+
throw new RangeError("Typesense structured filter exceeds maxFilterBytes");
|
|
191
|
+
return result;
|
|
192
|
+
}
|
|
193
|
+
const literal = node.literal?.wire;
|
|
194
|
+
switch (node.operator) {
|
|
195
|
+
case "==": return `${node.field}:=${String(literal)}`;
|
|
196
|
+
case "<":
|
|
197
|
+
case "<=": {
|
|
198
|
+
if (!isNumericField(numeric, node.field))
|
|
199
|
+
throw new UnsupportedError("Typesense structured ranges require a schema-declared scalar numeric field");
|
|
200
|
+
return `${node.field}:<=${String(literal)}`;
|
|
201
|
+
}
|
|
202
|
+
case ">":
|
|
203
|
+
case ">=": {
|
|
204
|
+
if (!isNumericField(numeric, node.field))
|
|
205
|
+
throw new UnsupportedError("Typesense structured ranges require a schema-declared scalar numeric field");
|
|
206
|
+
return `${node.field}:>=${String(literal)}`;
|
|
207
|
+
}
|
|
208
|
+
case "in": return `${node.field}:=[${(node.literals ?? []).map((item) => item.wire).join(",")}]`;
|
|
209
|
+
default: throw new UnsupportedError("Typesense structured comparison operator is not supported");
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/** Renders the final filter after the database has supplied the real schema. */
|
|
213
|
+
export function renderPredicate(node, numeric, maxBytes) {
|
|
214
|
+
return render(node, numeric, maxBytes);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Builds and validates the complete admitted condition AST before any request.
|
|
218
|
+
* Numeric ranges are rendered later, once the real collection schema proves
|
|
219
|
+
* that the field is a scalar numeric type.
|
|
220
|
+
*/
|
|
221
|
+
export function predicateRoot(query, options) {
|
|
222
|
+
const maxDepth = options.maxDepth ?? DEFAULT_MAX_DEPTH;
|
|
223
|
+
const maxConditions = options.maxConditions ?? DEFAULT_MAX_CONDITIONS;
|
|
224
|
+
let budget = 0;
|
|
225
|
+
const charge = () => {
|
|
226
|
+
budget += 1;
|
|
227
|
+
if (budget > maxConditions)
|
|
228
|
+
throw new UnsupportedError("Typesense condition tree exceeds the configured complexity bound");
|
|
229
|
+
};
|
|
230
|
+
const flat = [];
|
|
231
|
+
for (const filter of query.filters) {
|
|
232
|
+
flat.push(comparison(structuredField(filter.field), filter.operator, filter.value));
|
|
233
|
+
charge();
|
|
234
|
+
}
|
|
235
|
+
const where = query.where === undefined ? undefined : compileWhere(query.where, 1, maxDepth, maxConditions, charge);
|
|
236
|
+
const children = [...flat, ...(where === undefined ? [] : [where])];
|
|
237
|
+
if (children.length === 0)
|
|
238
|
+
return undefined;
|
|
239
|
+
return children.length === 1 ? children[0] : { kind: "group", operator: "and", children };
|
|
240
|
+
}
|
|
241
|
+
export function collectPredicate(node) {
|
|
242
|
+
const fields = new Set();
|
|
243
|
+
const ranges = new Set();
|
|
244
|
+
collect(node, fields, ranges);
|
|
245
|
+
return { fields: Object.freeze([...fields].sort()), ranges: Object.freeze([...ranges].sort()) };
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* A deterministic, secret-free serialisation of the admitted predicate that
|
|
249
|
+
* retains the original operators and literal classes.
|
|
250
|
+
*
|
|
251
|
+
* The rendered native filter is deliberately not enough to identify a query:
|
|
252
|
+
* Typesense candidate normalisation widens `>`/`<` to `>=`/`<=` and two
|
|
253
|
+
* different exact predicates can therefore render one identical filter string.
|
|
254
|
+
* Cursor identity must bind the exact validated AST so a stricter handle can
|
|
255
|
+
* never be replayed as its widened neighbour.
|
|
256
|
+
*/
|
|
257
|
+
export function canonicalPredicate(node) {
|
|
258
|
+
return node === undefined ? null : canonicalNode(node);
|
|
259
|
+
}
|
|
260
|
+
function canonicalNode(node) {
|
|
261
|
+
if (node.kind === "group") {
|
|
262
|
+
return { kind: "group", operator: node.operator, children: node.children.map(canonicalNode) };
|
|
263
|
+
}
|
|
264
|
+
if (node.operator === "in") {
|
|
265
|
+
return {
|
|
266
|
+
kind: "comparison",
|
|
267
|
+
field: node.field,
|
|
268
|
+
operator: node.operator,
|
|
269
|
+
literals: (node.literals ?? []).map((literal) => ({ class: literal.class, value: literal.value })),
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
return {
|
|
273
|
+
kind: "comparison",
|
|
274
|
+
field: node.field,
|
|
275
|
+
operator: node.operator,
|
|
276
|
+
literal: node.literal === undefined ? null : { class: node.literal.class, value: node.literal.value },
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
export function createVerifierState() {
|
|
280
|
+
return { work: 0 };
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Creates an exact verifier. The work budget is shared across all rows of one
|
|
284
|
+
* operation, so a query that verifies many small rows still reaches the
|
|
285
|
+
* macrotask cadence: a bounded per-row counter could never yield for trees
|
|
286
|
+
* smaller than the old 256-node threshold.
|
|
287
|
+
*/
|
|
288
|
+
export function createVerifier(node, state = createVerifierState()) {
|
|
289
|
+
return async (data, check) => {
|
|
290
|
+
check();
|
|
291
|
+
const truth = await evaluate(node, data, state, check);
|
|
292
|
+
check();
|
|
293
|
+
return truth === "true";
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
async function evaluate(node, data, state, check) {
|
|
297
|
+
check();
|
|
298
|
+
if (node.kind === "group") {
|
|
299
|
+
state.work += 1;
|
|
300
|
+
const stopOn = node.operator === "or" ? "true" : "false";
|
|
301
|
+
let unknown = false;
|
|
302
|
+
for (const child of node.children) {
|
|
303
|
+
const truth = await evaluate(child, data, state, check);
|
|
304
|
+
if (truth === stopOn)
|
|
305
|
+
return truth;
|
|
306
|
+
if (truth === "unknown")
|
|
307
|
+
unknown = true;
|
|
308
|
+
await pulse(state, check);
|
|
309
|
+
}
|
|
310
|
+
if (unknown)
|
|
311
|
+
return "unknown";
|
|
312
|
+
return node.operator === "or" ? "false" : "true";
|
|
313
|
+
}
|
|
314
|
+
state.work += 1;
|
|
315
|
+
const value = Object.hasOwn(data, node.field) ? data[node.field] : undefined;
|
|
316
|
+
let result;
|
|
317
|
+
if (node.operator === "in") {
|
|
318
|
+
result = inTruth(value, node.literals ?? []);
|
|
319
|
+
// The whole RHS list is real comparison work; charge every item so a long
|
|
320
|
+
// IN list cannot hide a large synchronous block from the pulse budget.
|
|
321
|
+
state.work += (node.literals ?? []).length;
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
const literal = node.literal;
|
|
325
|
+
if (literal === undefined)
|
|
326
|
+
throw new UnsupportedError("Typesense comparison has no literal");
|
|
327
|
+
if (value === null || value === undefined)
|
|
328
|
+
result = "unknown";
|
|
329
|
+
else if (node.operator === "==")
|
|
330
|
+
result = equal(value, literal.value) ? "true" : "false";
|
|
331
|
+
else {
|
|
332
|
+
const order = compare(value, literal.value);
|
|
333
|
+
result = node.operator === "<" ? (order < 0 ? "true" : "false")
|
|
334
|
+
: node.operator === "<=" ? (order <= 0 ? "true" : "false")
|
|
335
|
+
: node.operator === ">" ? (order > 0 ? "true" : "false")
|
|
336
|
+
: order >= 0 ? "true" : "false";
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
await pulse(state, check);
|
|
340
|
+
return result;
|
|
341
|
+
}
|
|
342
|
+
async function pulse(state, check) {
|
|
343
|
+
if (state.work < YIELD_WORK)
|
|
344
|
+
return;
|
|
345
|
+
state.work = 0;
|
|
346
|
+
check();
|
|
347
|
+
await yieldToEventLoop();
|
|
348
|
+
check();
|
|
349
|
+
}
|
|
350
|
+
/** Yields an actual macrotask, not merely a promise microtask. */
|
|
351
|
+
export function yieldToEventLoop() {
|
|
352
|
+
return new Promise((resolve) => { setTimeout(resolve, 0); });
|
|
353
|
+
}
|
|
354
|
+
/** The exact TypeScript core membership semantics: the entire left operand. */
|
|
355
|
+
function inTruth(left, literals) {
|
|
356
|
+
let truth = "false";
|
|
357
|
+
if (literals.length > 0) {
|
|
358
|
+
if (literals.some((literal) => left !== null && left !== undefined && equal(left, literal.value)))
|
|
359
|
+
truth = "true";
|
|
360
|
+
else if (left === null || left === undefined)
|
|
361
|
+
truth = "unknown";
|
|
362
|
+
}
|
|
363
|
+
return truth;
|
|
364
|
+
}
|
|
365
|
+
function equal(left, right) {
|
|
366
|
+
if (typeof left === "number" && typeof right === "number") {
|
|
367
|
+
return Number.isFinite(left) && Number.isFinite(right) && left === right;
|
|
368
|
+
}
|
|
369
|
+
return left === right;
|
|
370
|
+
}
|
|
371
|
+
/** Mirrors the pinned core's comparison order: null, then type rank, then value. */
|
|
372
|
+
function compare(left, right) {
|
|
373
|
+
if (left === right)
|
|
374
|
+
return 0;
|
|
375
|
+
if (left === undefined || left === null)
|
|
376
|
+
return right === undefined || right === null ? 0 : -1;
|
|
377
|
+
if (right === undefined || right === null)
|
|
378
|
+
return 1;
|
|
379
|
+
const leftType = typeof left;
|
|
380
|
+
const rightType = typeof right;
|
|
381
|
+
if ((leftType === "number" && rightType === "number")
|
|
382
|
+
|| (leftType === "string" && rightType === "string")
|
|
383
|
+
|| (leftType === "boolean" && rightType === "boolean")) {
|
|
384
|
+
return left < right ? -1 : 1;
|
|
385
|
+
}
|
|
386
|
+
return typeRank(left) - typeRank(right);
|
|
387
|
+
}
|
|
388
|
+
function typeRank(value) {
|
|
389
|
+
if (Array.isArray(value))
|
|
390
|
+
return 0;
|
|
391
|
+
if (typeof value === "boolean")
|
|
392
|
+
return 1;
|
|
393
|
+
if (typeof value === "number")
|
|
394
|
+
return 2;
|
|
395
|
+
if (typeof value === "string")
|
|
396
|
+
return 3;
|
|
397
|
+
return 4;
|
|
398
|
+
}
|
|
399
|
+
//# sourceMappingURL=structured.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structured.js","sourceRoot":"","sources":["../src/structured.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,GAQjB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAU7C,MAAM,YAAY,GAAG,gCAAgC,CAAC;AACtD,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAC/B,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B;;;;;GAKG;AACH,MAAM,UAAU,GAAG,EAAE,CAAC;AAkCtB,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,MAAM,IAAI,GAAG,KAAK,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1D,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,gBAAgB,CAAC,mEAAmE,CAAC,CAAC;IAClG,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAoC,EAAE,OAAe;IACpF,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,OAAO,EAAE,CAAC;QAC1E,MAAM,IAAI,gBAAgB,CAAC,+CAA+C,MAAM,CAAC,OAAO,CAAC,SAA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CAAC,QAAQ,KAAK,QAAQ,IAAI,SAAS,KAAK,QAAQ,CAAC;WACjD,CAAC,QAAQ,KAAK,SAAS,IAAI,SAAS,KAAK,SAAS,CAAC,EAAE,CAAC;QACzD,OAAQ,IAAkC,GAAI,KAAmC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7F,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IACnC,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC;IACzC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC;IACxC,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type TypesenseFetch = typeof globalThis.fetch;
|
|
2
|
+
export type TypesenseHeaders = Readonly<Record<string, string>>;
|
|
3
|
+
export type TypesenseHeaderProvider = TypesenseHeaders | (() => TypesenseHeaders | Promise<TypesenseHeaders>);
|
|
4
|
+
export declare function positive(value: number | undefined, fallback: number, field: string, maximum?: number): number;
|
|
5
|
+
export declare function nonNegative(value: number | undefined, fallback: number, field: string, maximum: number): number;
|
|
6
|
+
export declare function byteLength(value: string): number;
|
|
7
|
+
export declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
8
|
+
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
9
|
+
export declare function controlFree(value: string): boolean;
|
|
10
|
+
/** Validates and normalises a credential-free Typesense origin. */
|
|
11
|
+
export declare function validBaseUrl(value: string, allowInsecureLoopbackHttp: boolean): string;
|
|
12
|
+
export interface TypesenseOperation {
|
|
13
|
+
readonly signal: AbortSignal;
|
|
14
|
+
readonly deadlineAt: number;
|
|
15
|
+
readonly requests: number;
|
|
16
|
+
readonly bytes: number;
|
|
17
|
+
check(): void;
|
|
18
|
+
cancelled(): Error;
|
|
19
|
+
failed(): Error;
|
|
20
|
+
addBytes(bytes: number): void;
|
|
21
|
+
countRequest(): void;
|
|
22
|
+
dispose(): void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* One operation-wide cancellation/deadline scope plus cumulative page and byte
|
|
26
|
+
* counters. Every physical request of one query, batch or metadata read shares
|
|
27
|
+
* it, so a large result cannot reset a budget by starting a new page.
|
|
28
|
+
*/
|
|
29
|
+
export declare class TypesenseTransport {
|
|
30
|
+
#private;
|
|
31
|
+
constructor(options: {
|
|
32
|
+
readonly baseUrl: string;
|
|
33
|
+
readonly allowInsecureLoopbackHttp: boolean;
|
|
34
|
+
readonly headers?: TypesenseHeaderProvider;
|
|
35
|
+
readonly fetch?: TypesenseFetch;
|
|
36
|
+
readonly timeoutMs: number;
|
|
37
|
+
readonly maxRequestBytes: number;
|
|
38
|
+
readonly maxResponseBytes: number;
|
|
39
|
+
readonly maxTotalBytes: number;
|
|
40
|
+
readonly root: AbortSignal;
|
|
41
|
+
readonly onDispose: (operation: TypesenseOperation) => void;
|
|
42
|
+
});
|
|
43
|
+
get origin(): string;
|
|
44
|
+
get timeoutMs(): number;
|
|
45
|
+
begin(callerSignal?: AbortSignal): TypesenseOperation;
|
|
46
|
+
request(path: string, parameters: URLSearchParams, operation: TypesenseOperation, accepted?: readonly number[], observeHeaders?: (headers: TypesenseHeaders) => void): Promise<{
|
|
47
|
+
readonly status: number;
|
|
48
|
+
readonly body: unknown;
|
|
49
|
+
readonly bytes: number;
|
|
50
|
+
}>;
|
|
51
|
+
}
|