@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.
@@ -0,0 +1,317 @@
1
+ import { QueryCancelledError, cancelQuietly, createAbortScope, raceAbort, } from "@dalgo/adapter-runtime";
2
+ import { TypesenseHttpError, TypesenseRequestError, TypesenseResponseSizeError } from "./errors.js";
3
+ import { TypesenseJsonNumberError, parseLosslessJson } from "./json.js";
4
+ const API_KEY = "x-typesense-api-key";
5
+ const RESERVED_HEADERS = new Set([
6
+ "host",
7
+ "content-length",
8
+ "transfer-encoding",
9
+ "connection",
10
+ "trailer",
11
+ "upgrade",
12
+ "proxy-connection",
13
+ "te",
14
+ "keep-alive",
15
+ "accept",
16
+ "content-type",
17
+ "user-agent",
18
+ ]);
19
+ const HEADER_NAME = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/u;
20
+ export function positive(value, fallback, field, maximum = 16_777_216) {
21
+ const result = value ?? fallback;
22
+ if (!Number.isSafeInteger(result) || result < 1 || result > maximum) {
23
+ throw new TypeError(`${field} must be a safe integer from 1 to ${String(maximum)}`);
24
+ }
25
+ return result;
26
+ }
27
+ export function nonNegative(value, fallback, field, maximum) {
28
+ const result = value ?? fallback;
29
+ if (!Number.isSafeInteger(result) || result < 0 || result > maximum) {
30
+ throw new TypeError(`${field} must be a safe integer from 0 to ${String(maximum)}`);
31
+ }
32
+ return result;
33
+ }
34
+ export function byteLength(value) {
35
+ return new TextEncoder().encode(value).byteLength;
36
+ }
37
+ export function isObject(value) {
38
+ return typeof value === "object" && value !== null && !Array.isArray(value);
39
+ }
40
+ export function isPlainObject(value) {
41
+ return isObject(value)
42
+ && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
43
+ }
44
+ export function controlFree(value) {
45
+ for (let index = 0; index < value.length; index += 1) {
46
+ const code = value.charCodeAt(index);
47
+ if (code < 0x20 || code === 0x7f)
48
+ return false;
49
+ }
50
+ return value.isWellFormed();
51
+ }
52
+ function isLoopback(hostname) {
53
+ return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]";
54
+ }
55
+ /** Validates and normalises a credential-free Typesense origin. */
56
+ export function validBaseUrl(value, allowInsecureLoopbackHttp) {
57
+ const url = new URL(value.trim());
58
+ if (url.protocol === "http:") {
59
+ if (!isLoopback(url.hostname) || !allowInsecureLoopbackHttp) {
60
+ throw new TypeError("baseUrl must use HTTPS; loopback HTTP requires allowInsecureLoopbackHttp: true");
61
+ }
62
+ }
63
+ else if (url.protocol !== "https:") {
64
+ throw new TypeError("baseUrl must use HTTPS except for explicit loopback HTTP");
65
+ }
66
+ if (url.username !== "" || url.password !== "" || url.search !== "" || url.hash !== ""
67
+ || (url.pathname !== "" && url.pathname !== "/")) {
68
+ throw new TypeError("baseUrl must be an origin without credentials, path, query, or fragment");
69
+ }
70
+ return url.origin;
71
+ }
72
+ function headersFrom(value) {
73
+ if (!isPlainObject(value))
74
+ throw new TypeError("Typesense headers must be a plain object");
75
+ const headers = Object.create(null);
76
+ const seen = new Set();
77
+ for (const [name, headerValue] of Object.entries(value)) {
78
+ if (name === "__proto__" || !HEADER_NAME.test(name) || typeof headerValue !== "string"
79
+ || !/^[\t\x20-\x7e]*$/u.test(headerValue)) {
80
+ throw new TypeError("Typesense headers must have valid names and control-free string values");
81
+ }
82
+ const lower = name.toLowerCase();
83
+ if (seen.has(lower) || RESERVED_HEADERS.has(lower)) {
84
+ throw new TypeError("Typesense headers must not duplicate or override protocol headers");
85
+ }
86
+ seen.add(lower);
87
+ headers[name] = headerValue;
88
+ }
89
+ const keyName = Object.keys(headers).find((name) => name.toLowerCase() === API_KEY);
90
+ if (keyName === undefined || headers[keyName] === "") {
91
+ throw new TypeError("Typesense headers must include a non-empty X-TYPESENSE-API-KEY");
92
+ }
93
+ return headers;
94
+ }
95
+ /**
96
+ * One operation-wide cancellation/deadline scope plus cumulative page and byte
97
+ * counters. Every physical request of one query, batch or metadata read shares
98
+ * it, so a large result cannot reset a budget by starting a new page.
99
+ */
100
+ export class TypesenseTransport {
101
+ #origin;
102
+ #headers;
103
+ #fetch;
104
+ #timeoutMs;
105
+ #maxRequestBytes;
106
+ #maxResponseBytes;
107
+ #maxTotalBytes;
108
+ #root;
109
+ #onDispose;
110
+ constructor(options) {
111
+ this.#origin = validBaseUrl(options.baseUrl, options.allowInsecureLoopbackHttp);
112
+ this.#headers = options.headers;
113
+ this.#fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
114
+ this.#timeoutMs = options.timeoutMs;
115
+ this.#maxRequestBytes = options.maxRequestBytes;
116
+ this.#maxResponseBytes = options.maxResponseBytes;
117
+ this.#maxTotalBytes = options.maxTotalBytes;
118
+ this.#root = options.root;
119
+ this.#onDispose = options.onDispose;
120
+ }
121
+ get origin() { return this.#origin; }
122
+ get timeoutMs() { return this.#timeoutMs; }
123
+ begin(callerSignal) {
124
+ return new Operation(this.#timeoutMs, callerSignal, this.#root, this.#onDispose);
125
+ }
126
+ async request(path, parameters, operation, accepted = [], observeHeaders) {
127
+ operation.check();
128
+ if (operation.bytes >= this.#maxTotalBytes)
129
+ throw new TypesenseResponseSizeError();
130
+ let supplied;
131
+ try {
132
+ supplied = await raceAbort(Promise.resolve().then(() => typeof this.#headers === "function" ? this.#headers() : (this.#headers ?? {})), operation.signal, operation.cancelled);
133
+ }
134
+ catch {
135
+ if (operation.signal.aborted)
136
+ throw operation.cancelled();
137
+ throw operation.failed();
138
+ }
139
+ // Accessing an enumerable getter can throw an arbitrary error (including a
140
+ // RangeError that quotes a secret). Validation failures must therefore
141
+ // leave through one fixed, cause-free public error.
142
+ let headers;
143
+ try {
144
+ headers = headersFrom(supplied);
145
+ }
146
+ catch {
147
+ if (operation.signal.aborted)
148
+ throw operation.cancelled();
149
+ throw operation.failed();
150
+ }
151
+ // The internal credential-scope observer may raise a typed cursor refusal,
152
+ // which must survive; it is adapter-owned and never carries a secret.
153
+ observeHeaders?.(headers);
154
+ operation.check();
155
+ const query = parameters.toString();
156
+ const relative = `${path}${query.length === 0 ? "" : `?${query}`}`;
157
+ if (byteLength(relative) > this.#maxRequestBytes) {
158
+ throw new RangeError("Typesense request exceeds maxRequestBytes");
159
+ }
160
+ const pending = Promise.resolve().then(() => this.#fetch(`${this.#origin}${relative}`, {
161
+ method: "GET",
162
+ redirect: "error",
163
+ headers: { ...headers, accept: "application/json" },
164
+ signal: operation.signal,
165
+ }));
166
+ void pending.then((late) => { if (operation.signal.aborted)
167
+ cancelQuietly(late.body); }, () => undefined);
168
+ operation.countRequest();
169
+ let response;
170
+ try {
171
+ response = await raceAbort(pending, operation.signal, operation.cancelled);
172
+ }
173
+ catch {
174
+ if (operation.signal.aborted)
175
+ throw operation.cancelled();
176
+ throw operation.failed();
177
+ }
178
+ if (operation.signal.aborted) {
179
+ cancelQuietly(response.body);
180
+ throw operation.cancelled();
181
+ }
182
+ const remaining = this.#maxTotalBytes - operation.bytes;
183
+ const maximum = Math.min(this.#maxResponseBytes, remaining);
184
+ let consumed;
185
+ try {
186
+ consumed = await this.#read(response, maximum, operation);
187
+ }
188
+ catch (error) {
189
+ if (operation.signal.aborted) {
190
+ cancelQuietly(response.body);
191
+ throw operation.cancelled();
192
+ }
193
+ if (error instanceof TypesenseResponseSizeError)
194
+ throw error;
195
+ throw operation.failed();
196
+ }
197
+ operation.addBytes(consumed.bytes);
198
+ operation.check();
199
+ if (!response.ok && !accepted.includes(response.status)) {
200
+ throw new TypesenseHttpError(response.status);
201
+ }
202
+ let body;
203
+ if (consumed.text.length > 0) {
204
+ try {
205
+ body = parseLosslessJson(consumed.text);
206
+ }
207
+ catch (error) {
208
+ if (error instanceof TypesenseJsonNumberError)
209
+ throw error;
210
+ // The provider body must never become an error cause or message.
211
+ // eslint-disable-next-line preserve-caught-error
212
+ throw new TypeError("Typesense returned malformed JSON");
213
+ }
214
+ }
215
+ return { status: response.status, body, bytes: consumed.bytes };
216
+ }
217
+ async #read(response, maximum, operation) {
218
+ const length = response.headers.get("content-length");
219
+ if (length !== null && (!/^\d+$/u.test(length) || Number(length) > maximum)) {
220
+ cancelQuietly(response.body);
221
+ throw new TypesenseResponseSizeError();
222
+ }
223
+ if (response.body === null)
224
+ return { text: "", bytes: 0 };
225
+ const reader = response.body.getReader();
226
+ const chunks = [];
227
+ let total = 0;
228
+ try {
229
+ for (;;) {
230
+ const item = await raceAbort(reader.read(), operation.signal, operation.cancelled);
231
+ if (item.done)
232
+ break;
233
+ total += item.value.byteLength;
234
+ if (total > maximum) {
235
+ cancelQuietly(reader);
236
+ throw new TypesenseResponseSizeError();
237
+ }
238
+ chunks.push(item.value);
239
+ }
240
+ }
241
+ finally {
242
+ if (operation.signal.aborted)
243
+ cancelQuietly(reader);
244
+ try {
245
+ reader.releaseLock();
246
+ }
247
+ catch {
248
+ // A cancelled stream can retain its lock.
249
+ }
250
+ }
251
+ const bytes = new Uint8Array(total);
252
+ let offset = 0;
253
+ for (const chunk of chunks) {
254
+ bytes.set(chunk, offset);
255
+ offset += chunk.byteLength;
256
+ }
257
+ return { text: new TextDecoder().decode(bytes), bytes: total };
258
+ }
259
+ }
260
+ class Operation {
261
+ #scope;
262
+ #root;
263
+ #controller = new AbortController();
264
+ #onDispose;
265
+ #forward = () => { this.#controller.abort(); };
266
+ deadlineAt;
267
+ #listening = false;
268
+ #requests = 0;
269
+ #bytes = 0;
270
+ #disposed = false;
271
+ constructor(timeoutMs, callerSignal, root, onDispose) {
272
+ this.#root = root;
273
+ this.#onDispose = onDispose;
274
+ this.#scope = createAbortScope(callerSignal, timeoutMs);
275
+ this.deadlineAt = Date.now() + timeoutMs;
276
+ if (this.#scope.signal.aborted || root.aborted)
277
+ this.#controller.abort();
278
+ else {
279
+ this.#listening = true;
280
+ this.#scope.signal.addEventListener("abort", this.#forward, { once: true });
281
+ root.addEventListener("abort", this.#forward, { once: true });
282
+ }
283
+ }
284
+ get signal() { return this.#controller.signal; }
285
+ get requests() { return this.#requests; }
286
+ get bytes() { return this.#bytes; }
287
+ check() {
288
+ if (this.signal.aborted || this.#root.aborted)
289
+ throw this.cancelled();
290
+ if (Date.now() >= this.deadlineAt)
291
+ throw new QueryCancelledError("deadline");
292
+ }
293
+ cancelled = () => {
294
+ return new QueryCancelledError(this.#scope.deadlineExceeded ? "deadline" : "caller");
295
+ };
296
+ failed = () => {
297
+ return new TypesenseRequestError();
298
+ };
299
+ addBytes(bytes) { this.#bytes += bytes; }
300
+ countRequest() { this.#requests += 1; }
301
+ dispose() {
302
+ if (this.#disposed)
303
+ return;
304
+ this.#disposed = true;
305
+ // Ownership transfer is explicit: every listener this operation registered
306
+ // on the shared root or the scope is removed on success, error, cancel and
307
+ // close alike, so completed operations cannot remain retained.
308
+ if (this.#listening) {
309
+ this.#listening = false;
310
+ this.#scope.signal.removeEventListener("abort", this.#forward);
311
+ this.#root.removeEventListener("abort", this.#forward);
312
+ }
313
+ this.#scope.dispose();
314
+ this.#onDispose(this);
315
+ }
316
+ }
317
+ //# sourceMappingURL=transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,SAAS,GAEV,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACpG,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAQxE,MAAM,OAAO,GAAG,qBAAqB,CAAC;AACtC,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;IAC/B,MAAM;IACN,gBAAgB;IAChB,mBAAmB;IACnB,YAAY;IACZ,SAAS;IACT,SAAS;IACT,kBAAkB;IAClB,IAAI;IACJ,YAAY;IACZ,QAAQ;IACR,cAAc;IACd,YAAY;CACb,CAAC,CAAC;AACH,MAAM,WAAW,GAAG,gCAAgC,CAAC;AAErD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AC,gBAAgB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IACvF,CAAC,CAAC;IAEK,MAAM,GAAG,GAAU,EAAE;QAC1B,OAAO,IAAI,qBAAqB,EAAE,CAAC;IACrC,CAAC,CAAC;IAEK,QAAQ,CAAC,KAAa,IAAU,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC;IACvD,YAAY,KAAW,IAAI,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC;IAE7C,OAAO;QACZ,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO;QAC3B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,2EAA2E;QAC3E,2EAA2E;QAC3E,+DAA+D;QAC/D,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;YACxB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC/D,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzD,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;CACF"}
package/package.json CHANGED
@@ -1,19 +1,62 @@
1
1
  {
2
2
  "name": "@dalgo/dalgo2typesense",
3
- "version": "0.0.0-bootstrap.0",
4
- "description": "Nonfunctional bootstrap placeholder for CI trusted publishing; use the later released version.",
5
- "license": "MIT",
3
+ "version": "0.2.1",
4
+ "description": "Bounded read-only native Typesense HTTP adapter for DALgo TypeScript",
5
+ "type": "module",
6
+ "packageManager": "pnpm@11.20.0",
7
+ "sideEffects": false,
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "LICENSE",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc -p tsconfig.build.json",
21
+ "build:deps": "pnpm --filter \"@dalgo/dalgo2typesense...\" run build",
22
+ "check": "eslint . && vitest run && tsc -p tsconfig.json --noEmit && tsc -p tsconfig.build.json && tsc -p tsconfig.examples.json",
23
+ "lint": "eslint .",
24
+ "prepack": "npm --prefix ../adapter-runtime run build && npm run build",
25
+ "test": "vitest run",
26
+ "test:real": "pnpm run build:deps && node scripts/real-typesense.mjs",
27
+ "test:browser": "pnpm run build:deps && node scripts/real-typesense-browser.mjs"
28
+ },
6
29
  "repository": {
7
30
  "type": "git",
8
31
  "url": "git+https://github.com/dal-go/dalgo-http-adapters.git",
9
32
  "directory": "packages/typesense"
10
33
  },
11
- "files": [
12
- "README.md",
13
- "LICENSE"
14
- ],
34
+ "bugs": {
35
+ "url": "https://github.com/dal-go/dalgo-http-adapters/issues"
36
+ },
37
+ "homepage": "https://github.com/dal-go/dalgo-http-adapters/tree/main/packages/typesense#readme",
38
+ "license": "MIT",
15
39
  "publishConfig": {
16
40
  "access": "public",
17
41
  "registry": "https://registry.npmjs.org"
42
+ },
43
+ "engines": {
44
+ "node": ">=24"
45
+ },
46
+ "peerDependencies": {
47
+ "@dalgo/adapter-runtime": ">=0.1.0 <1.0.0",
48
+ "@dalgo/core": ">=0.7.4 <0.9.0"
49
+ },
50
+ "devDependencies": {
51
+ "@dalgo/adapter-runtime": "workspace:^",
52
+ "@dalgo/core": "^0.7.4",
53
+ "@eslint/js": "10.0.1",
54
+ "@playwright/test": "1.64.1",
55
+ "@types/node": "26.6.5",
56
+ "esbuild": "0.28.2",
57
+ "eslint": "10.11.0",
58
+ "typescript": "6.0.3",
59
+ "typescript-eslint": "8.70.0",
60
+ "vitest": "5.0.1"
18
61
  }
19
62
  }
package/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Strongo Team
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
22
-