@thunderduck-io/client 0.0.0-stage → 0.1.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/dist/index.js ADDED
@@ -0,0 +1,534 @@
1
+ // src/errors.ts
2
+ var ThunderduckError = class extends Error {
3
+ /** HTTP status, when the error came from a response. */
4
+ status;
5
+ /** The server's `detail` (or raw body) when there was one. */
6
+ detail;
7
+ constructor(message, options = {}) {
8
+ super(message, options.cause === void 0 ? void 0 : { cause: options.cause });
9
+ this.name = new.target.name;
10
+ this.status = options.status;
11
+ this.detail = options.detail;
12
+ }
13
+ };
14
+ var ThunderduckAuthError = class extends ThunderduckError {
15
+ };
16
+ var ThunderduckNoAccessError = class extends ThunderduckError {
17
+ };
18
+ var ThunderduckQueryError = class extends ThunderduckError {
19
+ };
20
+ var ThunderduckCancelledError = class extends ThunderduckError {
21
+ };
22
+ var ThunderduckTimeoutError = class extends ThunderduckError {
23
+ };
24
+ var ThunderduckResultExpiredError = class extends ThunderduckError {
25
+ };
26
+
27
+ // src/client.ts
28
+ var DEFAULT_BASE_URL = "https://api.thunderduck.ai";
29
+ var DEFAULT_PAGE_SIZE = 1e3;
30
+ var DEFAULT_POLL_INTERVAL_MS = 1e3;
31
+ var DEFAULT_TIMEOUT_MS = 3e5;
32
+ var DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
33
+ var DEFAULT_MAX_REDIRECTS = 3;
34
+ var REDIRECT_STATUSES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
35
+ var UNKNOWN_USER_DETAIL = "no thunderduck user for this identity; sign in to the console once";
36
+ var INACTIVE_USER_DETAIL = "user no longer active";
37
+ var NO_ACCESS_MESSAGE = "This account has no Thunderduck access yet \u2014 sign in to the console once at https://console.thunderduck.ai, then try again.";
38
+ var SUSPENDED_MESSAGE = "Your Thunderduck account is suspended.";
39
+ var Thunderduck = class {
40
+ baseUrl;
41
+ token;
42
+ getToken;
43
+ fetchImpl;
44
+ pollIntervalMs;
45
+ timeoutMs;
46
+ requestTimeoutMs;
47
+ maxRedirects;
48
+ constructor(options = {}) {
49
+ if (!options.token && !options.getToken) {
50
+ throw new ThunderduckError(
51
+ "either `token` or `getToken` is required (create one in the console: Settings \u2192 API tokens)"
52
+ );
53
+ }
54
+ if (options.token && options.getToken) {
55
+ throw new ThunderduckError("pass `token` or `getToken`, not both");
56
+ }
57
+ const fetchImpl = options.fetch ?? globalThis.fetch;
58
+ if (typeof fetchImpl !== "function") {
59
+ throw new ThunderduckError(
60
+ "no global fetch available; pass one as `fetch` (Node 18+ has it)"
61
+ );
62
+ }
63
+ this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
64
+ this.token = options.token;
65
+ this.getToken = options.getToken;
66
+ this.fetchImpl = fetchImpl;
67
+ this.pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
68
+ this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
69
+ this.requestTimeoutMs = options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
70
+ this.maxRedirects = options.maxRedirects ?? DEFAULT_MAX_REDIRECTS;
71
+ }
72
+ // ---- queries -------------------------------------------------------------
73
+ /** Submit SQL and return its execution id, without waiting for it. */
74
+ async submit(sql, options = {}) {
75
+ const body = { sql };
76
+ if (options.forceRefresh !== void 0) body.force_refresh = options.forceRefresh;
77
+ const response = await this.send("/queries", {
78
+ method: "POST",
79
+ body,
80
+ signal: options.signal
81
+ });
82
+ if (response.status !== 200 && response.status !== 201) {
83
+ this.fail(response, "submit");
84
+ }
85
+ const raw = this.parse(response.text, "submit");
86
+ const id = raw.id;
87
+ if (id === void 0 || id === null || `${id}` === "") {
88
+ throw new ThunderduckError("the API returned no execution id for this query");
89
+ }
90
+ return {
91
+ id: `${id}`,
92
+ backend: typeof raw.backend === "string" ? raw.backend : "eks",
93
+ namespace: typeof raw.namespace === "string" ? raw.namespace : null,
94
+ jobName: typeof raw.job_name === "string" ? raw.job_name : null,
95
+ raw
96
+ };
97
+ }
98
+ /** One execution by id. Throws when it does not exist. */
99
+ async execution(id, options = {}) {
100
+ const execution = await this.executionOrNull(id, options);
101
+ if (execution === null) {
102
+ throw new ThunderduckError(`execution ${id} not found`, { status: 404 });
103
+ }
104
+ return execution;
105
+ }
106
+ /**
107
+ * Poll until the run is terminal. Returns only `success`; throws
108
+ * `ThunderduckQueryError` on `error`, `ThunderduckCancelledError` on
109
+ * `cancelled`, and `ThunderduckTimeoutError` when the deadline passes.
110
+ *
111
+ * A 404 while polling means "not visible yet" — the row is inserted at submit
112
+ * time, but a poll can still race it — so it keeps polling rather than
113
+ * failing.
114
+ */
115
+ async awaitExecution(id, options = {}) {
116
+ const timeoutMs = options.timeoutMs ?? this.timeoutMs;
117
+ const pollIntervalMs = options.pollIntervalMs ?? this.pollIntervalMs;
118
+ const deadline = Date.now() + timeoutMs;
119
+ for (; ; ) {
120
+ const execution = await this.executionOrNull(id, options);
121
+ if (execution !== null) {
122
+ if (execution.status === "success") return execution;
123
+ if (execution.status === "error") {
124
+ throw new ThunderduckQueryError(
125
+ execution.errorMessage ?? "query failed without a message",
126
+ { detail: execution.errorMessage ?? void 0 }
127
+ );
128
+ }
129
+ if (execution.status === "cancelled") {
130
+ throw new ThunderduckCancelledError("query was cancelled");
131
+ }
132
+ }
133
+ if (Date.now() >= deadline) {
134
+ throw new ThunderduckTimeoutError(
135
+ `query ${id} did not finish within ${timeoutMs} ms`
136
+ );
137
+ }
138
+ await sleep(pollIntervalMs, options.signal);
139
+ }
140
+ }
141
+ /** A fully buffered query: submit, wait, then walk every result page. */
142
+ async query(sql, options = {}) {
143
+ const job = await this.submit(sql, options);
144
+ const execution = await this.awaitExecution(job.id, options);
145
+ const rows = [];
146
+ let columns = [];
147
+ let columnTypes = [];
148
+ let total = 0;
149
+ for await (const batch of this.batches(job.id, options)) {
150
+ columns = batch.columns;
151
+ columnTypes = batch.columnTypes;
152
+ total = batch.total;
153
+ rows.push(...batch.rows);
154
+ }
155
+ return { id: job.id, columns, columnTypes, rows, total, offset: 0, execution };
156
+ }
157
+ /**
158
+ * Submit, wait, then yield result pages — for results too large to buffer.
159
+ * A statement with no stored result (an INSERT, say) yields nothing.
160
+ */
161
+ async *iterate(sql, options = {}) {
162
+ const job = await this.submit(sql, options);
163
+ await this.awaitExecution(job.id, options);
164
+ yield* this.batches(job.id, options);
165
+ }
166
+ /** One page of an execution's stored result, or null when it stored none. */
167
+ async resultPage(id, options = {}) {
168
+ const limit = options.limit ?? DEFAULT_PAGE_SIZE;
169
+ const offset = options.offset ?? 0;
170
+ const query = new URLSearchParams({ limit: `${limit}`, offset: `${offset}` });
171
+ const response = await this.send(`/executions/${encodeURIComponent(id)}/result?${query}`, {
172
+ method: "GET",
173
+ signal: options.signal
174
+ });
175
+ if (response.status === 404) return null;
176
+ if (response.status === 409) {
177
+ throw new ThunderduckResultExpiredError(
178
+ `the run succeeded but its stored result has expired; re-run the query${suffix(this.detailOf(response))}`,
179
+ { status: 409, detail: this.detailOf(response) }
180
+ );
181
+ }
182
+ if (response.status !== 200) this.fail(response, "result fetch");
183
+ const raw = this.parse(response.text, "result fetch");
184
+ const rows = Array.isArray(raw.rows) ? raw.rows : [];
185
+ return {
186
+ id: typeof raw.execution_uuid === "string" ? raw.execution_uuid : id,
187
+ columns: asStrings(raw.columns),
188
+ columnTypes: asStrings(raw.column_types),
189
+ rows,
190
+ rowCount: toNumber(raw.row_count) ?? rows.length,
191
+ total: toNumber(raw.total) ?? rows.length,
192
+ limit: toNumber(raw.limit) ?? limit,
193
+ offset: toNumber(raw.offset) ?? offset
194
+ };
195
+ }
196
+ /**
197
+ * Best-effort cancel: an unknown or already-finished run is not an error.
198
+ * A rejected token still is — swallowing it would make a stop button look
199
+ * like it worked while hiding a dead credential.
200
+ */
201
+ async cancel(id, options = {}) {
202
+ const response = await this.send(`/executions/${encodeURIComponent(id)}/cancel`, {
203
+ method: "POST",
204
+ signal: options.signal
205
+ });
206
+ if (response.status === 200 || response.status === 202 || response.status === 204) return;
207
+ if (response.status === 401 || response.status === 403) this.fail(response, "cancel");
208
+ if (response.status === 404) return;
209
+ }
210
+ // ---- catalog -------------------------------------------------------------
211
+ /** Catalogs, namespaces, tables and columns this token may see. */
212
+ async catalogSchema(options = {}) {
213
+ const response = await this.send("/catalog/schema", {
214
+ method: "GET",
215
+ signal: options.signal
216
+ });
217
+ if (response.status !== 200) this.fail(response, "catalog fetch");
218
+ const raw = this.parse(response.text, "catalog fetch");
219
+ const catalogs = Array.isArray(raw.catalogs) ? raw.catalogs : [];
220
+ return {
221
+ catalogs: catalogs.map((tree) => toCatalogTree(tree)),
222
+ error: typeof raw.error === "string" ? raw.error : null
223
+ };
224
+ }
225
+ // ---- downloads -----------------------------------------------------------
226
+ /** Mint a short-lived presigned URL for the run's stored result. */
227
+ async downloadUrl(id, options = {}) {
228
+ const response = await this.send(
229
+ `/executions/${encodeURIComponent(id)}/download-url`,
230
+ { method: "GET", signal: options.signal }
231
+ );
232
+ if (response.status !== 200) this.fail(response, "download-url");
233
+ const raw = this.parse(response.text, "download-url");
234
+ if (typeof raw.url !== "string") {
235
+ throw new ThunderduckError("the API returned no download URL for this execution");
236
+ }
237
+ return { url: raw.url, expiresIn: toNumber(raw.expires_in) ?? 0 };
238
+ }
239
+ /**
240
+ * The stored result, as the presigned GET response. Never sends the bearer:
241
+ * the URL is self-authenticating, and a client that attached our token to it
242
+ * would hand the token to whatever host the URL names.
243
+ */
244
+ async download(id, options = {}) {
245
+ const { url } = await this.downloadUrl(id, options);
246
+ return this.fetchImpl(url, { signal: options.signal });
247
+ }
248
+ // ---- internals -----------------------------------------------------------
249
+ async *batches(id, options) {
250
+ const pageSize = options.pageSize ?? DEFAULT_PAGE_SIZE;
251
+ const maxRows = options.maxRows ?? Number.POSITIVE_INFINITY;
252
+ let offset = 0;
253
+ let total = Number.POSITIVE_INFINITY;
254
+ while (offset < total && offset < maxRows) {
255
+ const remaining = maxRows - offset;
256
+ const limit = Math.max(1, Math.min(pageSize, Number.isFinite(remaining) ? remaining : pageSize));
257
+ const page = await this.resultPage(id, { limit, offset, signal: options.signal });
258
+ if (page === null) return;
259
+ total = page.total;
260
+ if (page.rows.length === 0) return;
261
+ yield {
262
+ columns: page.columns,
263
+ columnTypes: page.columnTypes,
264
+ rows: page.rows,
265
+ total: page.total,
266
+ offset: page.offset
267
+ };
268
+ offset = page.offset + page.rows.length;
269
+ if (page.rows.length < limit) return;
270
+ }
271
+ }
272
+ async executionOrNull(id, options) {
273
+ const response = await this.send(`/executions/${encodeURIComponent(id)}`, {
274
+ method: "GET",
275
+ signal: options.signal
276
+ });
277
+ if (response.status === 404) return null;
278
+ if (response.status !== 200) this.fail(response, "status check");
279
+ const raw = this.parse(response.text, "status check");
280
+ return {
281
+ id: typeof raw.uuid === "string" ? raw.uuid : id,
282
+ status: typeof raw.status === "string" ? raw.status : "running",
283
+ query: typeof raw.query === "string" ? raw.query : "",
284
+ errorMessage: asString(raw.error_message),
285
+ resultLocation: asString(raw.result_location),
286
+ resultRowCount: toNumber(raw.result_row_count),
287
+ startedAt: asString(raw.start),
288
+ finishedAt: asString(raw.end),
289
+ executionTimeMs: toNumber(raw.execution_time_ms),
290
+ queryTimeMs: toNumber(raw.query_time_ms),
291
+ totalRuntimeMs: toNumber(raw.total_runtime_ms),
292
+ peakMemoryBytes: toNumber(raw.peak_memory_bytes),
293
+ source: asString(raw.source),
294
+ raw
295
+ };
296
+ }
297
+ /**
298
+ * One logical request: token, redirects (same origin only), one retry after a
299
+ * 401 when a token provider can refresh.
300
+ */
301
+ async send(path, options) {
302
+ let refreshed = false;
303
+ for (; ; ) {
304
+ const token = options.tokenless ? void 0 : await this.currentToken(refreshed);
305
+ const response = await this.followRedirects(path, {
306
+ method: options.method,
307
+ body: options.body,
308
+ signal: options.signal,
309
+ token
310
+ });
311
+ if (response.status === 401 && !options.tokenless && !refreshed && this.getToken !== void 0) {
312
+ refreshed = true;
313
+ continue;
314
+ }
315
+ return response;
316
+ }
317
+ }
318
+ async followRedirects(path, init) {
319
+ let url = new URL(`${this.baseUrl}${path}`);
320
+ const origin = url.origin;
321
+ let method = init.method;
322
+ let body = init.body === void 0 ? void 0 : JSON.stringify(init.body);
323
+ for (let hop = 0; ; hop++) {
324
+ const headers = { Accept: "application/json" };
325
+ if (init.token !== void 0) headers.Authorization = `Bearer ${init.token}`;
326
+ if (body !== void 0) headers["Content-Type"] = "application/json";
327
+ const response = await this.fetchText(url, { method, body, headers, signal: init.signal });
328
+ if (!REDIRECT_STATUSES.has(response.status)) return response;
329
+ const location = response.headers.get("location");
330
+ if (location === null) return response;
331
+ if (hop >= this.maxRedirects) {
332
+ throw new ThunderduckError(`too many redirects for ${method} ${url.pathname}`);
333
+ }
334
+ const next = new URL(location, url);
335
+ if (next.origin !== origin) {
336
+ throw new ThunderduckError(
337
+ `refusing to follow a redirect to another host: ${next.origin}`
338
+ );
339
+ }
340
+ url = next;
341
+ if (response.status === 303) {
342
+ method = "GET";
343
+ body = void 0;
344
+ }
345
+ }
346
+ }
347
+ async fetchText(url, init) {
348
+ const { signal, dispose } = combineWithTimeout(init.signal, this.requestTimeoutMs);
349
+ try {
350
+ const response = await this.fetchImpl(url, {
351
+ method: init.method,
352
+ body: init.body,
353
+ headers: init.headers,
354
+ redirect: "manual",
355
+ signal
356
+ });
357
+ const text = await response.text();
358
+ return { status: response.status, text, headers: response.headers };
359
+ } catch (error) {
360
+ if (signal.aborted && signal.reason instanceof ThunderduckTimeoutError) {
361
+ throw signal.reason;
362
+ }
363
+ if (signal.aborted) throw error;
364
+ throw new ThunderduckError(
365
+ `request to ${url.origin}${url.pathname} failed: ${messageOf(error)}`,
366
+ { cause: error }
367
+ );
368
+ } finally {
369
+ dispose();
370
+ }
371
+ }
372
+ async currentToken(forceRefresh) {
373
+ if (this.getToken !== void 0) {
374
+ const token = await this.getToken(forceRefresh);
375
+ if (typeof token !== "string" || token === "") {
376
+ throw new ThunderduckAuthError("getToken() returned an empty token");
377
+ }
378
+ return token;
379
+ }
380
+ return this.token;
381
+ }
382
+ parse(text, context) {
383
+ if (text === "") {
384
+ throw new ThunderduckError(`empty response body from ${context}`);
385
+ }
386
+ try {
387
+ return JSON.parse(text);
388
+ } catch (error) {
389
+ throw new ThunderduckError(`unparseable response body from ${context}`, {
390
+ detail: text.slice(0, 200),
391
+ cause: error
392
+ });
393
+ }
394
+ }
395
+ detailOf(response) {
396
+ if (response.text === "") return void 0;
397
+ try {
398
+ const parsed = JSON.parse(response.text);
399
+ const detail = parsed.detail ?? parsed.message ?? parsed.error;
400
+ if (typeof detail === "string") return detail;
401
+ if (detail !== void 0) return JSON.stringify(detail);
402
+ } catch {
403
+ }
404
+ return response.text.slice(0, 500);
405
+ }
406
+ /** Turn an unexpected status into the most specific error this client has. */
407
+ fail(response, context) {
408
+ const detail = this.detailOf(response);
409
+ const { status } = response;
410
+ if (status === 404 && detail === UNKNOWN_USER_DETAIL) {
411
+ throw new ThunderduckNoAccessError(NO_ACCESS_MESSAGE, { status, detail });
412
+ }
413
+ if (status === 401 && detail === INACTIVE_USER_DETAIL) {
414
+ throw new ThunderduckNoAccessError(SUSPENDED_MESSAGE, { status, detail });
415
+ }
416
+ if (status === 401 || status === 403) {
417
+ throw new ThunderduckAuthError(
418
+ `authentication failed (HTTP ${status})${suffix(detail)}`,
419
+ { status, detail }
420
+ );
421
+ }
422
+ if (status === 409) {
423
+ throw new ThunderduckResultExpiredError(
424
+ `the run succeeded but its stored result has expired; re-run the query${suffix(detail)}`,
425
+ { status, detail }
426
+ );
427
+ }
428
+ throw new ThunderduckError(
429
+ `${context} failed (HTTP ${status})${suffix(detail)}`,
430
+ { status, detail }
431
+ );
432
+ }
433
+ };
434
+ function suffix(detail) {
435
+ return detail === void 0 || detail === "" ? "" : `: ${detail}`;
436
+ }
437
+ function messageOf(error) {
438
+ return error instanceof Error ? error.message : String(error);
439
+ }
440
+ function asString(value) {
441
+ return typeof value === "string" ? value : null;
442
+ }
443
+ function asStrings(value) {
444
+ return Array.isArray(value) ? value.map((item) => `${item}`) : [];
445
+ }
446
+ function toNumber(value) {
447
+ if (typeof value === "number") return Number.isFinite(value) ? value : null;
448
+ if (typeof value === "string" && value.trim() !== "") {
449
+ const parsed = Number(value);
450
+ return Number.isFinite(parsed) ? parsed : null;
451
+ }
452
+ return null;
453
+ }
454
+ function toCatalogTree(raw) {
455
+ const tables = Array.isArray(raw.tables) ? raw.tables : null;
456
+ const namespaces = Array.isArray(raw.namespaces) ? raw.namespaces : null;
457
+ return {
458
+ name: typeof raw.name === "string" ? raw.name : "",
459
+ type: asString(raw.type),
460
+ tables: tables === null ? null : tables.map((table) => toCatalogTable(table)),
461
+ namespaces: namespaces === null ? null : namespaces.map((namespace) => {
462
+ const entry = namespace;
463
+ const nsTables = Array.isArray(entry.tables) ? entry.tables : [];
464
+ return {
465
+ name: typeof entry.name === "string" ? entry.name : "",
466
+ tables: nsTables.map((table) => toCatalogTable(table))
467
+ };
468
+ }),
469
+ error: asString(raw.error)
470
+ };
471
+ }
472
+ function toCatalogTable(raw) {
473
+ const columns = Array.isArray(raw.columns) ? raw.columns : [];
474
+ return {
475
+ name: typeof raw.name === "string" ? raw.name : "",
476
+ kind: typeof raw.kind === "string" ? raw.kind : "table",
477
+ columns: columns.map((column) => {
478
+ const entry = column;
479
+ return {
480
+ name: typeof entry.name === "string" ? entry.name : "",
481
+ type: typeof entry.type === "string" ? entry.type : "",
482
+ semantics: entry.semantics !== null && typeof entry.semantics === "object" ? entry.semantics : null
483
+ };
484
+ })
485
+ };
486
+ }
487
+ function sleep(ms, signal) {
488
+ return new Promise((resolve, reject) => {
489
+ if (signal?.aborted) {
490
+ reject(signal.reason);
491
+ return;
492
+ }
493
+ const timer = setTimeout(() => {
494
+ signal?.removeEventListener("abort", onAbort);
495
+ resolve();
496
+ }, ms);
497
+ const onAbort = () => {
498
+ clearTimeout(timer);
499
+ reject(signal?.reason);
500
+ };
501
+ signal?.addEventListener("abort", onAbort, { once: true });
502
+ });
503
+ }
504
+ function combineWithTimeout(caller, timeoutMs) {
505
+ const controller = new AbortController();
506
+ const onAbort = () => controller.abort(caller?.reason);
507
+ const timer = setTimeout(
508
+ () => controller.abort(
509
+ new ThunderduckTimeoutError(`request timed out after ${timeoutMs} ms`)
510
+ ),
511
+ timeoutMs
512
+ );
513
+ if (caller !== void 0) {
514
+ if (caller.aborted) onAbort();
515
+ else caller.addEventListener("abort", onAbort, { once: true });
516
+ }
517
+ return {
518
+ signal: controller.signal,
519
+ dispose: () => {
520
+ clearTimeout(timer);
521
+ caller?.removeEventListener("abort", onAbort);
522
+ }
523
+ };
524
+ }
525
+ export {
526
+ Thunderduck,
527
+ ThunderduckAuthError,
528
+ ThunderduckCancelledError,
529
+ ThunderduckError,
530
+ ThunderduckNoAccessError,
531
+ ThunderduckQueryError,
532
+ ThunderduckResultExpiredError,
533
+ ThunderduckTimeoutError
534
+ };
package/package.json CHANGED
@@ -1,6 +1,62 @@
1
1
  {
2
2
  "name": "@thunderduck-io/client",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Official TypeScript client for the Thunderduck REST API: query every catalog, page results, cancel runs, download exports.",
5
+ "keywords": [
6
+ "thunderduck",
7
+ "duckdb",
8
+ "lakehouse",
9
+ "iceberg",
10
+ "sql",
11
+ "client"
12
+ ],
13
+ "license": "Apache-2.0",
14
+ "homepage": "https://docs.thunderduck.ai/clients/node",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/thunderduck-io/thunderduck-node.git"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/thunderduck-io/thunderduck-node/issues"
21
+ },
22
+ "engines": {
23
+ "node": ">=18"
24
+ },
25
+ "type": "module",
26
+ "main": "./dist/index.cjs",
27
+ "module": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "import": {
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.js"
34
+ },
35
+ "require": {
36
+ "types": "./dist/index.d.cts",
37
+ "default": "./dist/index.cjs"
38
+ }
39
+ }
40
+ },
41
+ "files": [
42
+ "dist",
43
+ "SECURITY.md",
44
+ "CONTRIBUTING.md"
45
+ ],
46
+ "sideEffects": false,
47
+ "scripts": {
48
+ "build": "tsup src/index.ts --format esm,cjs --dts --target node18 --clean",
49
+ "typecheck": "tsc --noEmit",
50
+ "test": "npm run build && node --test test/client.test.mjs",
51
+ "prepublishOnly": "npm test"
52
+ },
53
+ "devDependencies": {
54
+ "@types/node": "^20.11.0",
55
+ "tsup": "^8.0.0",
56
+ "typescript": "^5.4.0"
57
+ },
58
+ "publishConfig": {
59
+ "access": "public",
60
+ "provenance": true
61
+ }
62
+ }