llm-large-files 0.8.2 → 0.10.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/CHANGELOG.md +981 -0
- package/README.md +22 -17
- package/dist/access.d.ts +128 -0
- package/dist/access.d.ts.map +1 -0
- package/dist/access.js +234 -0
- package/dist/access.js.map +1 -0
- package/dist/aggregate.d.ts +6 -0
- package/dist/aggregate.d.ts.map +1 -1
- package/dist/aggregate.js +86 -13
- package/dist/aggregate.js.map +1 -1
- package/dist/analyze.d.ts +4 -0
- package/dist/analyze.d.ts.map +1 -1
- package/dist/analyze.js +2 -2
- package/dist/analyze.js.map +1 -1
- package/dist/answer-info.d.ts +26 -0
- package/dist/answer-info.d.ts.map +1 -0
- package/dist/answer-info.js +32 -0
- package/dist/answer-info.js.map +1 -0
- package/dist/anthropic/adapter.d.ts +5 -1
- package/dist/anthropic/adapter.d.ts.map +1 -1
- package/dist/anthropic/adapter.js +35 -10
- package/dist/anthropic/adapter.js.map +1 -1
- package/dist/ask.d.ts +159 -14
- package/dist/ask.d.ts.map +1 -1
- package/dist/ask.js +743 -113
- package/dist/ask.js.map +1 -1
- package/dist/cache.d.ts +12 -3
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +18 -5
- package/dist/cache.js.map +1 -1
- package/dist/citations.d.ts +36 -0
- package/dist/citations.d.ts.map +1 -0
- package/dist/citations.js +291 -0
- package/dist/citations.js.map +1 -0
- package/dist/encoding.js +5 -3
- package/dist/encoding.js.map +1 -1
- package/dist/error-info.d.ts +70 -0
- package/dist/error-info.d.ts.map +1 -0
- package/dist/error-info.js +253 -0
- package/dist/error-info.js.map +1 -0
- package/dist/errors.d.ts +74 -8
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +104 -15
- package/dist/errors.js.map +1 -1
- package/dist/events.d.ts +57 -13
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +42 -11
- package/dist/events.js.map +1 -1
- package/dist/evidence.d.ts +4 -2
- package/dist/evidence.d.ts.map +1 -1
- package/dist/evidence.js +35 -5
- package/dist/evidence.js.map +1 -1
- package/dist/extract.d.ts +32 -8
- package/dist/extract.d.ts.map +1 -1
- package/dist/extract.js +52 -36
- package/dist/extract.js.map +1 -1
- package/dist/gemini/adapter.d.ts +54 -7
- package/dist/gemini/adapter.d.ts.map +1 -1
- package/dist/gemini/adapter.js +152 -41
- package/dist/gemini/adapter.js.map +1 -1
- package/dist/gemini/chat.d.ts +38 -53
- package/dist/gemini/chat.d.ts.map +1 -1
- package/dist/gemini/chat.js +20 -25
- package/dist/gemini/chat.js.map +1 -1
- package/dist/gemini/endpoints.d.ts +59 -11
- package/dist/gemini/endpoints.d.ts.map +1 -1
- package/dist/gemini/endpoints.js +33 -7
- package/dist/gemini/endpoints.js.map +1 -1
- package/dist/gemini/errors.d.ts +39 -5
- package/dist/gemini/errors.d.ts.map +1 -1
- package/dist/gemini/errors.js +70 -9
- package/dist/gemini/errors.js.map +1 -1
- package/dist/gemini/generate.d.ts +53 -2
- package/dist/gemini/generate.d.ts.map +1 -1
- package/dist/gemini/generate.js +100 -50
- package/dist/gemini/generate.js.map +1 -1
- package/dist/gemini/index.d.ts +4 -4
- package/dist/gemini/index.d.ts.map +1 -1
- package/dist/http.d.ts +41 -3
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +40 -2
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +13 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/ingest.d.ts +78 -0
- package/dist/ingest.d.ts.map +1 -0
- package/dist/ingest.js +893 -0
- package/dist/ingest.js.map +1 -0
- package/dist/library.d.ts +295 -33
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +458 -650
- package/dist/library.js.map +1 -1
- package/dist/map-reduce.d.ts +176 -10
- package/dist/map-reduce.d.ts.map +1 -1
- package/dist/map-reduce.js +807 -61
- package/dist/map-reduce.js.map +1 -1
- package/dist/model.d.ts +79 -6
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +80 -4
- package/dist/model.js.map +1 -1
- package/dist/node/handlers.d.ts +247 -14
- package/dist/node/handlers.d.ts.map +1 -1
- package/dist/node/handlers.js +491 -227
- package/dist/node/handlers.js.map +1 -1
- package/dist/node/index.d.ts +3 -2
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +2 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/ingest-child.d.ts +7 -1
- package/dist/node/ingest-child.d.ts.map +1 -1
- package/dist/node/ingest-child.js +19 -4
- package/dist/node/ingest-child.js.map +1 -1
- package/dist/node/isolated.d.ts +3 -1
- package/dist/node/isolated.d.ts.map +1 -1
- package/dist/node/isolated.js +11 -4
- package/dist/node/isolated.js.map +1 -1
- package/dist/node/originals.d.ts +19 -0
- package/dist/node/originals.d.ts.map +1 -0
- package/dist/node/originals.js +82 -0
- package/dist/node/originals.js.map +1 -0
- package/dist/node/spool.d.ts +106 -0
- package/dist/node/spool.d.ts.map +1 -0
- package/dist/node/spool.js +378 -0
- package/dist/node/spool.js.map +1 -0
- package/dist/node/sse.d.ts +6 -4
- package/dist/node/sse.d.ts.map +1 -1
- package/dist/node/sse.js +9 -7
- package/dist/node/sse.js.map +1 -1
- package/dist/openai/adapter.d.ts +5 -1
- package/dist/openai/adapter.d.ts.map +1 -1
- package/dist/openai/adapter.js +53 -12
- package/dist/openai/adapter.js.map +1 -1
- package/dist/output-limit.d.ts +2 -1
- package/dist/output-limit.d.ts.map +1 -1
- package/dist/output-limit.js +5 -2
- package/dist/output-limit.js.map +1 -1
- package/dist/pdf-layout.d.ts.map +1 -1
- package/dist/pdf-layout.js +71 -12
- package/dist/pdf-layout.js.map +1 -1
- package/dist/pdf-outline.d.ts +71 -0
- package/dist/pdf-outline.d.ts.map +1 -0
- package/dist/pdf-outline.js +414 -0
- package/dist/pdf-outline.js.map +1 -0
- package/dist/plan.d.ts +137 -7
- package/dist/plan.d.ts.map +1 -1
- package/dist/plan.js +248 -26
- package/dist/plan.js.map +1 -1
- package/dist/prepare.d.ts +50 -0
- package/dist/prepare.d.ts.map +1 -0
- package/dist/prepare.js +207 -0
- package/dist/prepare.js.map +1 -0
- package/dist/ranged.d.ts +16 -11
- package/dist/ranged.d.ts.map +1 -1
- package/dist/ranged.js +56 -12
- package/dist/ranged.js.map +1 -1
- package/dist/retry.d.ts +3 -1
- package/dist/retry.d.ts.map +1 -1
- package/dist/retry.js +6 -2
- package/dist/retry.js.map +1 -1
- package/dist/scope.d.ts +25 -0
- package/dist/scope.d.ts.map +1 -0
- package/dist/scope.js +60 -0
- package/dist/scope.js.map +1 -0
- package/dist/search.d.ts +7 -0
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +72 -10
- package/dist/search.js.map +1 -1
- package/dist/source.d.ts +60 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +170 -0
- package/dist/source.js.map +1 -0
- package/dist/stores.d.ts +126 -31
- package/dist/stores.d.ts.map +1 -1
- package/dist/stores.js +655 -141
- package/dist/stores.js.map +1 -1
- package/dist/testing/fake-fetch.d.ts +31 -0
- package/dist/testing/fake-fetch.d.ts.map +1 -0
- package/dist/testing/fake-fetch.js +66 -0
- package/dist/testing/fake-fetch.js.map +1 -0
- package/dist/testing/fake-model.d.ts +38 -0
- package/dist/testing/fake-model.d.ts.map +1 -0
- package/dist/testing/fake-model.js +62 -0
- package/dist/testing/fake-model.js.map +1 -0
- package/dist/testing/index.d.ts +7 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +9 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/store-checks.d.ts +72 -0
- package/dist/testing/store-checks.d.ts.map +1 -0
- package/dist/testing/store-checks.js +619 -0
- package/dist/testing/store-checks.js.map +1 -0
- package/dist/tools.d.ts +47 -2
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +440 -71
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +165 -14
- package/dist/types.d.ts.map +1 -1
- package/dist/whole-cost.d.ts +37 -0
- package/dist/whole-cost.d.ts.map +1 -0
- package/dist/whole-cost.js +46 -0
- package/dist/whole-cost.js.map +1 -0
- package/docs/README.md +21 -8
- package/docs/getting-started.md +18 -13
- package/docs/guides/anthropic.md +17 -10
- package/docs/guides/conversations.md +112 -47
- package/docs/guides/costs-and-limits.md +147 -42
- package/docs/guides/deployment.md +380 -86
- package/docs/guides/errors-and-reliability.md +317 -67
- package/docs/guides/explorer-model.md +4 -1
- package/docs/guides/openai-compatible.md +47 -7
- package/docs/guides/own-adapter-and-loop.md +60 -16
- package/docs/guides/pdfs.md +219 -36
- package/docs/guides/storage.md +676 -145
- package/docs/guides/testing.md +149 -129
- package/docs/guides/vertex-and-gemini.md +169 -57
- package/docs/guides/web-app.md +318 -80
- package/docs/how-it-works.md +155 -30
- package/docs/measurements.md +215 -13
- package/docs/publishing.md +185 -37
- package/docs/reference/anthropic.md +12 -7
- package/docs/reference/ask.md +415 -47
- package/docs/reference/errors-and-retries.md +194 -14
- package/docs/reference/events.md +77 -27
- package/docs/reference/gemini.md +252 -87
- package/docs/reference/library.md +886 -178
- package/docs/reference/node.md +659 -111
- package/docs/reference/openai.md +21 -10
- package/docs/reference/testing.md +311 -0
- package/docs/reference/tools.md +285 -30
- package/docs/security.md +404 -78
- package/docs/troubleshooting.md +151 -70
- package/docs/upgrading-0.10.md +472 -0
- package/docs/upgrading-0.9.md +890 -0
- package/package.json +16 -3
- package/src/access.ts +267 -0
- package/src/aggregate.ts +92 -14
- package/src/analyze.ts +2 -2
- package/src/answer-info.ts +45 -0
- package/src/anthropic/adapter.ts +40 -11
- package/src/ask.ts +866 -115
- package/src/cache.ts +20 -5
- package/src/citations.ts +294 -0
- package/src/encoding.ts +6 -4
- package/src/error-info.ts +290 -0
- package/src/errors.ts +131 -15
- package/src/events.ts +112 -24
- package/src/evidence.ts +35 -5
- package/src/extract.ts +56 -34
- package/src/gemini/adapter.ts +196 -43
- package/src/gemini/chat.ts +63 -78
- package/src/gemini/endpoints.ts +89 -16
- package/src/gemini/errors.ts +74 -11
- package/src/gemini/generate.ts +147 -57
- package/src/gemini/index.ts +4 -4
- package/src/http.ts +65 -4
- package/src/index.ts +13 -8
- package/src/ingest.ts +958 -0
- package/src/library.ts +711 -651
- package/src/map-reduce.ts +858 -70
- package/src/model.ts +113 -9
- package/src/node/handlers.ts +709 -221
- package/src/node/index.ts +14 -2
- package/src/node/ingest-child.ts +24 -6
- package/src/node/isolated.ts +11 -4
- package/src/node/originals.ts +78 -0
- package/src/node/spool.ts +379 -0
- package/src/node/sse.ts +9 -7
- package/src/openai/adapter.ts +56 -13
- package/src/output-limit.ts +5 -2
- package/src/pdf-layout.ts +69 -11
- package/src/pdf-outline.ts +400 -0
- package/src/plan.ts +287 -36
- package/src/prepare.ts +253 -0
- package/src/ranged.ts +48 -14
- package/src/retry.ts +6 -2
- package/src/scope.ts +63 -0
- package/src/search.ts +69 -13
- package/src/source.ts +178 -0
- package/src/stores.ts +702 -142
- package/src/testing/fake-fetch.ts +80 -0
- package/src/testing/fake-model.ts +78 -0
- package/src/testing/index.ts +11 -0
- package/src/testing/store-checks.ts +660 -0
- package/src/tools.ts +461 -73
- package/src/types.ts +151 -14
- package/src/whole-cost.ts +64 -0
package/README.md
CHANGED
|
@@ -6,7 +6,8 @@ context window**.
|
|
|
6
6
|
Your users upload a 50 MB log or a 900-page book. Your model connector accepts 10 MB per request
|
|
7
7
|
and 1M tokens of context. This package bridges the gap:
|
|
8
8
|
|
|
9
|
-
- **Files that fit** go into the prompt whole.
|
|
9
|
+
- **Files that fit** go into the prompt whole, with their lines numbered. A table sent whole still
|
|
10
|
+
gets tools, so its counts and sums are exact.
|
|
10
11
|
- **Files that don't** become a short summary card, and the model gets tools to **search**,
|
|
11
12
|
**read line ranges**, or **read the whole file in parts** (map-reduce). Answers cite line numbers.
|
|
12
13
|
- **Pictures in a PDF** are not in its text. The model can **look at the real pages** when it
|
|
@@ -114,7 +115,8 @@ text is asked for again, a repeated call gets a pointer to the result already sh
|
|
|
114
115
|
each file is read whole at most once a question.
|
|
115
116
|
|
|
116
117
|
A question that fails throws `DocumentsNotFoundError` for a file that expired, was deleted, or
|
|
117
|
-
belongs to another `owner`, `DocumentStoreError` when the store cannot be read
|
|
118
|
+
belongs to another `owner`, `DocumentStoreError` when the store cannot be read or does not answer
|
|
119
|
+
within 30 s (`storeTimeoutMs`), or a
|
|
118
120
|
`ModelRequestError` whose `kind` (`"rate_limit"`, `"quota"`, `"timeout"`, `"context_overflow"`, …)
|
|
119
121
|
tells you what to show the user. `partialResultOf(error)` gives what it found and paid for:
|
|
120
122
|
[Errors and reliability](docs/guides/errors-and-reliability.md).
|
|
@@ -205,7 +207,7 @@ A large PDF goes to the model as text, and text cannot show a chart. Keep the up
|
|
|
205
207
|
the model gets a tool, `view_pages`, that hands it the pages it asks for as a small PDF:
|
|
206
208
|
|
|
207
209
|
```bash
|
|
208
|
-
npm install unpdf @cantoo/pdf-lib # Node 24; for Node
|
|
210
|
+
npm install unpdf @cantoo/pdf-lib # Node 24; for Node 22, see Requirements
|
|
209
211
|
```
|
|
210
212
|
|
|
211
213
|
```ts
|
|
@@ -256,13 +258,14 @@ What each model gets, and what it costs: [An explorer model](docs/guides/explore
|
|
|
256
258
|
|---|---|
|
|
257
259
|
| **Formats** | Text, Markdown, logs (UTF-8 and UTF-16, and Hebrew, Arabic, Cyrillic, Japanese and Western European text in its older encoding), JSON/JSONL, CSV/TSV, HTML (the text a browser shows), DOCX (headings, clause numbers, tables, notes and comments), PPTX (slides in show order, tables, speaker notes), XLSX (every sheet, a line per row, with its row number), PDF (text layer, with tables rebuilt so empty cells stay empty; pages with a picture are marked, and the model can look at the pages themselves; scans of up to 30 pages when PDFs are kept) |
|
|
258
260
|
| **Logs** | Detected automatically; the card shows level counts, the time range, and the most frequent errors grouped by shape (`timeout after <n>ms to <ip>`) |
|
|
259
|
-
| **Books and documents** | An outline of headings with line numbers, including Markdown, "Chapter 12", numbered sections, and Hebrew chapter titles |
|
|
260
|
-
| **Counting** | Exact counts of matching lines, per hour, per code or per message shape, in one search; exact sums, averages and groups over the rows of a CSV, an Excel sheet or a table of a document with `aggregate_table`, which reads every row and runs no code |
|
|
261
|
+
| **Books and documents** | An outline of headings with line numbers, including Markdown, "Chapter 12", numbered sections, and Hebrew chapter titles; for a PDF, Hebrew included, the lines set in larger type (new in 0.10.0) |
|
|
262
|
+
| **Counting** | Exact counts of matching lines, per hour, per code or per message shape, in one search; exact sums, averages and groups over the rows of a CSV, an Excel sheet or a table of a document with `aggregate_table`, which reads every row and runs no code. Since 0.10.0 a table small enough to be sent whole gets these tools too |
|
|
263
|
+
| **Citations** | Answers cite line numbers, of files sent whole too (numbered since 0.10.0); `result.citations` checks each against what the tools showed, Hebrew forms ("שורה 12") included |
|
|
261
264
|
| **Every language** | Search finds a Hebrew word with any prefix letter, words written with or without accents, quotes or gershayim either way; regex `\w` and `\b` know every script |
|
|
262
265
|
| **Limits** | One budget covers tokens *and* request bytes, so files fit both your context window and your connector's payload limit. It assumes 1M tokens and 10 MB: set `budget.contextTokens` for your model's window (an adapter's `contextTokens` can only make it smaller) |
|
|
263
|
-
| **Reliability** | Retries, waits on a silent model, recovery from a request too large, error kinds: see [Errors and reliability](docs/guides/errors-and-reliability.md) |
|
|
266
|
+
| **Reliability** | Retries, waits on a silent model, recovery from a request too large, error kinds, answers that say when a filter or the output limit stopped them, and a time limit on every store call, so a network volume that hangs does not hold a server: see [Errors and reliability](docs/guides/errors-and-reliability.md) |
|
|
264
267
|
| **Models** | Gemini and Vertex AI, any OpenAI-compatible endpoint, Claude, or an adapter of your own. Two models of different providers can share a question |
|
|
265
|
-
| **Cost** | Usage summed over every request of a question, for each model, with ceilings on whole-file reads, requests and input tokens |
|
|
268
|
+
| **Cost** | Usage summed over every request of a question, for each model, with ceilings on whole-file reads, requests and input tokens; since 0.10.0 every question has a ceiling on input tokens by default |
|
|
266
269
|
| **Privacy** | Documents can belong to an `owner`; other users can't plan, read, or delete them |
|
|
267
270
|
| **Hostile uploads** | Limits on the text, pages and time of one file; zip bombs and PDFs built to exhaust a server are refused when the checks recognize them, with a code (`"hostile"`); ingest pauses for other requests between pages and slices. Not every hostile file is refused, and some steps hold the server for a while: read untrusted uploads in child processes with `createIsolatedExtractors`, which refuses a file that runs out of memory or time while the server goes on ([Security](docs/security.md#uploads)) |
|
|
268
271
|
| **Storage** | In memory, on disk with expiry, or your own store (Redis, S3, a database) |
|
|
@@ -271,7 +274,9 @@ What each model gets, and what it costs: [An explorer model](docs/guides/explore
|
|
|
271
274
|
|
|
272
275
|
With `gemini-3.8-flash` on the Gemini API, a 5 MB log of about 1.27M tokens, over the 1M window,
|
|
273
276
|
got the right root cause of an outage, citing the right lines, in about 60 s over 11 tool calls.
|
|
274
|
-
|
|
277
|
+
For 0.10.0, an eval of Hebrew and English questions ran three times each on `gemini-3.5-flash-lite`
|
|
278
|
+
and `gemini-3.8-flash`: counts over tables sent whole were right in 24 of 24 on both. Every live
|
|
279
|
+
result with its date, model and setup, and what has not been run live, such as the
|
|
275
280
|
Claude adapter: [Measurements](docs/measurements.md).
|
|
276
281
|
|
|
277
282
|
## Documentation
|
|
@@ -306,8 +311,10 @@ Reference, one page per module:
|
|
|
306
311
|
- [`llm-large-files/openai`](docs/reference/openai.md): `openAiCompatible()` and its options.
|
|
307
312
|
- [`llm-large-files/anthropic`](docs/reference/anthropic.md): `anthropic()` and its options.
|
|
308
313
|
- [`llm-large-files/node`](docs/reference/node.md): `createDocumentHandlers`, its routes and responses, `createIsolatedExtractors`.
|
|
314
|
+
- [`llm-large-files/testing`](docs/reference/testing.md): `fakeModel` and `fakeFetch`, for your tests (new in 0.9.0).
|
|
309
315
|
|
|
310
316
|
[Changelog](CHANGELOG.md): what each version changed, and what to change in your code when you upgrade.
|
|
317
|
+
[Upgrading to 0.10](docs/upgrading-0.10.md) takes an application from 0.9.0 step by step.
|
|
311
318
|
|
|
312
319
|
Also: [How it works](docs/how-it-works.md), [Security](docs/security.md),
|
|
313
320
|
[Troubleshooting](docs/troubleshooting.md) and [Measurements](docs/measurements.md). For
|
|
@@ -315,21 +322,19 @@ maintainers: [Contributing](https://github.com/renanbazinin/llm-large-files/blob
|
|
|
315
322
|
|
|
316
323
|
## Requirements
|
|
317
324
|
|
|
318
|
-
Node.js
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
325
|
+
Node.js 22.12 or newer. The package is ESM, and CommonJS code can `require()` it. For DOCX, PPTX
|
|
326
|
+
and XLSX install `jszip`, for PDF install `unpdf`, and to mark and show the pages of a PDF, and
|
|
327
|
+
refuse a page built to hold the server before it is read, install `@cantoo/pdf-lib`. All three are
|
|
328
|
+
optional:
|
|
322
329
|
|
|
323
330
|
```bash
|
|
324
331
|
npm install jszip unpdf @cantoo/pdf-lib # Node 24 and later
|
|
325
332
|
npm install jszip unpdf@1 @cantoo/pdf-lib # Node 22
|
|
326
|
-
npm install jszip unpdf@1.7.0 @cantoo/pdf-lib # Node 20
|
|
327
333
|
```
|
|
328
334
|
|
|
329
|
-
On Node 24 and later, `npm install unpdf` installs unpdf 2, which asks for Node 24. On Node
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
what to install.
|
|
335
|
+
On Node 24 and later, `npm install unpdf` installs unpdf 2, which asks for Node 24. On Node 22, the
|
|
336
|
+
pdf.js of unpdf 1.5.0 to 1.6.0 would stop the whole process. Such an unpdf is refused at the first
|
|
337
|
+
PDF, with a message that says what to install.
|
|
333
338
|
|
|
334
339
|
## License
|
|
335
340
|
|
package/dist/access.d.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { DocumentStoreError, type DocumentStoreOperation } from "./errors.js";
|
|
2
|
+
import type { DocumentContext, DocumentMeta, DocumentScope } from "./types.js";
|
|
3
|
+
/** The TypeError of a call without an owner, when the library requires one (`requireOwner`). */
|
|
4
|
+
export declare const OWNER_REQUIRED = "owner is required: requireOwner is on";
|
|
5
|
+
/** The TypeError of a call without a scope, when the library requires one (`requireScope`). */
|
|
6
|
+
export declare const SCOPE_REQUIRED = "scope is required: requireScope is on";
|
|
7
|
+
/**
|
|
8
|
+
* Refuses an owner that every caller without a user would share: an empty string (what
|
|
9
|
+
* `user?.id ?? ""` gives), one of spaces only, or null. Undefined is no owner. A number is let
|
|
10
|
+
* through, as before, for JavaScript code that passes numeric user IDs.
|
|
11
|
+
*/
|
|
12
|
+
export declare function checkOwner(owner: unknown): void;
|
|
13
|
+
/** What a library requires of every call (`LargeFilesOptions.requireOwner` and `requireScope`). */
|
|
14
|
+
export type AccessRules = {
|
|
15
|
+
readonly requireOwner: boolean;
|
|
16
|
+
readonly requireScope: boolean;
|
|
17
|
+
};
|
|
18
|
+
/** A caller, checked: its owner, its scope (a frozen copy), and what the store calls made for it carry. */
|
|
19
|
+
export type Caller = {
|
|
20
|
+
readonly owner?: string;
|
|
21
|
+
readonly scope?: DocumentScope;
|
|
22
|
+
/** The context of the store calls made for this caller. */
|
|
23
|
+
readonly context: DocumentContext;
|
|
24
|
+
/** The key of the scope (`scopeKey`): what this caller's copies of documents are kept under in memory. */
|
|
25
|
+
readonly key: string;
|
|
26
|
+
/**
|
|
27
|
+
* Ends this caller's waits for the store (`AccessOptions.signal`), with its reason: never a store
|
|
28
|
+
* call that other callers wait on too. New in 0.10.0.
|
|
29
|
+
*/
|
|
30
|
+
readonly signal?: AbortSignal;
|
|
31
|
+
};
|
|
32
|
+
/** The context of a store call: a frozen object, without the fields that are absent. */
|
|
33
|
+
export declare function storeContext(scope: DocumentScope | undefined, owner: string | undefined): DocumentContext;
|
|
34
|
+
/**
|
|
35
|
+
* The caller of a call made with `access`. Null is no owner and no scope, as a database gives a
|
|
36
|
+
* field that was left out. The scope is checked (`checkScope`: a `DocumentScopeError` when it is
|
|
37
|
+
* not valid). Under `requireOwner`, a call without an owner, or with one that `checkOwner` refuses,
|
|
38
|
+
* is a TypeError; under `requireScope`, a call without a scope. A `signal` that is not an
|
|
39
|
+
* `AbortSignal` is a TypeError (0.10.0).
|
|
40
|
+
*/
|
|
41
|
+
export declare function callerOf(access: {
|
|
42
|
+
readonly owner?: unknown;
|
|
43
|
+
readonly scope?: unknown;
|
|
44
|
+
readonly signal?: unknown;
|
|
45
|
+
} | undefined, rules: AccessRules): Caller;
|
|
46
|
+
/**
|
|
47
|
+
* Whether `caller` may use the document `meta` describes. A document with an owner serves only that
|
|
48
|
+
* owner, and one with a scope only a caller of the same scope, segment by segment. A document
|
|
49
|
+
* without an owner serves any caller, unless the library requires owners; the same for scopes.
|
|
50
|
+
* Null is no owner and no scope, as a database gives a field that was left out. A refusal is never
|
|
51
|
+
* told: the document reads as missing.
|
|
52
|
+
*/
|
|
53
|
+
export declare function mayUse(meta: DocumentMeta, caller: Caller, rules: AccessRules): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Whether the document `found` has exactly this owner and this scope: no owner is the same as no
|
|
56
|
+
* owner only, and so for scopes. An owner or a scope of null counts as none. A scope that is not a
|
|
57
|
+
* list of segments (damaged, or written by hand) is nobody's.
|
|
58
|
+
*/
|
|
59
|
+
export declare function heldBy(found: DocumentMeta, owner: string | undefined, scope: DocumentScope | undefined): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* The context of the reads of a document's text (`get`, `readTextRange`, `getIndex`, and `putIndex`
|
|
62
|
+
* when its index is built again), once `caller` may use it (`mayUse`): the caller's scope, where
|
|
63
|
+
* `getMeta` found the document, and the owner only when the document has one. The copy kept in memory
|
|
64
|
+
* is kept under the caller's scope, and shared by every caller of it, whose owners differ when the
|
|
65
|
+
* document has none: so its reads carry one context whoever makes them. A document whose metadata
|
|
66
|
+
* has no scope (one of 0.8, moved into a scope) is still read in the scope it was found in. The
|
|
67
|
+
* owner sent is the caller's, which `mayUse` found the same as the document's; it is left out when
|
|
68
|
+
* the document has none.
|
|
69
|
+
*/
|
|
70
|
+
export declare function documentContext(meta: DocumentMeta, caller: Caller): DocumentContext;
|
|
71
|
+
/**
|
|
72
|
+
* The metadata a store gave for `id`, when it is that of `id`: metadata of another document (a
|
|
73
|
+
* store that looked up the wrong one) is none. An owner or a scope of null, as a database gives a
|
|
74
|
+
* field that was left out, is left out.
|
|
75
|
+
*/
|
|
76
|
+
export declare function metaOf(found: DocumentMeta | undefined, id: string): DocumentMeta | undefined;
|
|
77
|
+
/** Whether `ms` is a time limit a timer can keep: 0, and a time past what a timer can wait, are none. */
|
|
78
|
+
export declare const isTimeLimit: (ms: number) => boolean;
|
|
79
|
+
/** A time limit in the words of a message: "500 ms", "30 s", "2 min". */
|
|
80
|
+
export declare function formatDuration(ms: number): string;
|
|
81
|
+
/** Store calls of this process past their time limit that have not settled, and calls to the disk of the upload handlers. New in 0.10.0. */
|
|
82
|
+
export declare function stuckCalls(): number;
|
|
83
|
+
/**
|
|
84
|
+
* Counts `call` as stuck once it has run `ms` without settling, until it settles: whether or not
|
|
85
|
+
* anyone still waits for it. A call that settles within `ms` never counts, and nothing counts
|
|
86
|
+
* without a time limit (`isTimeLimit`). `late` is called when it passes `ms`. Returns `call`.
|
|
87
|
+
* New in 0.10.0.
|
|
88
|
+
*/
|
|
89
|
+
export declare function watchStuck<T>(call: Promise<T>, ms: number, late?: () => void): Promise<T>;
|
|
90
|
+
/** The time limit of a store call, and the limit on calls left stuck, of one library (`storeTimeoutMs`, `maxStuckStoreCalls`). New in 0.10.0. */
|
|
91
|
+
export type StoreCallOptions = {
|
|
92
|
+
/** The most time the call may take, in milliseconds. 0, or a time past what a timer can wait, sets none. */
|
|
93
|
+
timeoutMs?: number;
|
|
94
|
+
/**
|
|
95
|
+
* While this many calls of the process are stuck (`stuckCalls`), the call is refused at once, with
|
|
96
|
+
* a `DocumentStoreError` of code "STORE_STUCK", and the store is not called. Defaults to no limit.
|
|
97
|
+
*/
|
|
98
|
+
maxStuck?: number;
|
|
99
|
+
/** Whether the call counts as stuck once past `timeoutMs`. Defaults to true; false for a sweep. */
|
|
100
|
+
counts?: boolean;
|
|
101
|
+
/** Ends the caller's wait with its reason. The call itself goes on: a store call cannot be stopped. */
|
|
102
|
+
signal?: AbortSignal;
|
|
103
|
+
};
|
|
104
|
+
/** Refuses a call of `operation` while `maxStuck` calls of the process are stuck: the store is not answering. New in 0.10.0. */
|
|
105
|
+
export declare function checkStuck(operation: DocumentStoreOperation, maxStuck: number): void;
|
|
106
|
+
/** A store call that did not end within `ms`. */
|
|
107
|
+
export declare const storeTimeout: (operation: DocumentStoreOperation, ms: number) => DocumentStoreError;
|
|
108
|
+
/**
|
|
109
|
+
* A call of the store. What it throws is passed on as a `DocumentStoreError` of `operation`, with
|
|
110
|
+
* the store's error as `cause`: the store's own error may name a path, a host or a bucket, and a
|
|
111
|
+
* store that failed is not a document that is gone. A `DocumentStoreError` is passed on as it is,
|
|
112
|
+
* and so is a `DocumentScopeError`: a scope the store cannot use is a mistake of the call, and the
|
|
113
|
+
* same call would fail again.
|
|
114
|
+
*
|
|
115
|
+
* New in 0.10.0, `options`: a call that does not end within `timeoutMs` is a `DocumentStoreError`
|
|
116
|
+
* of code "ETIMEDOUT", and counts as stuck until it ends; while `maxStuck` calls are stuck, it is
|
|
117
|
+
* refused at once ("STORE_STUCK"); `signal` ends the caller's wait with its reason, as it is.
|
|
118
|
+
*/
|
|
119
|
+
export declare function storeCall<T>(operation: DocumentStoreOperation, call: () => Promise<T>, options?: StoreCallOptions): Promise<T>;
|
|
120
|
+
/**
|
|
121
|
+
* Refuses metadata written by a newer version of the package (`metaVersion` above
|
|
122
|
+
* `DOCUMENT_META_VERSION`), which may mean what this version cannot tell: a `DocumentStoreError`
|
|
123
|
+
* with code "NEWER_VERSION", not a document that is missing, so that an application does not
|
|
124
|
+
* ingest the file again over it. Metadata without a version (before 0.9.0), or with null as a
|
|
125
|
+
* database gives a field that was left out, is read as before.
|
|
126
|
+
*/
|
|
127
|
+
export declare function checkMetaVersion(meta: DocumentMeta): void;
|
|
128
|
+
//# sourceMappingURL=access.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access.d.ts","sourceRoot":"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AE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAIpF;AAED,iDAAiD;AACjD,eAAO,MAAM,YAAY,GAAI,WAAW,sBAAsB,EAAE,IAAI,MAAM,uBAGzE,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,SAAS,EAAE,sBAAsB,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,CAAC,CAAC,CA+BxI;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAKzD"}
|
package/dist/access.js
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
// Who is asking, and what they may use: the owner and the scope of a call, the context the store is
|
|
2
|
+
// given for it, and the rule that decides which documents serve it. New in 0.9.0.
|
|
3
|
+
import { DocumentScopeError, DocumentStoreError } from "./errors.js";
|
|
4
|
+
import { until } from "./http.js";
|
|
5
|
+
import { checkScope, sameScope, scopeKey } from "./scope.js";
|
|
6
|
+
import { DOCUMENT_META_VERSION } from "./stores.js";
|
|
7
|
+
/** The TypeError of a call without an owner, when the library requires one (`requireOwner`). */
|
|
8
|
+
export const OWNER_REQUIRED = "owner is required: requireOwner is on";
|
|
9
|
+
/** The TypeError of a call without a scope, when the library requires one (`requireScope`). */
|
|
10
|
+
export const SCOPE_REQUIRED = "scope is required: requireScope is on";
|
|
11
|
+
/**
|
|
12
|
+
* Refuses an owner that every caller without a user would share: an empty string (what
|
|
13
|
+
* `user?.id ?? ""` gives), one of spaces only, or null. Undefined is no owner. A number is let
|
|
14
|
+
* through, as before, for JavaScript code that passes numeric user IDs.
|
|
15
|
+
*/
|
|
16
|
+
export function checkOwner(owner) {
|
|
17
|
+
if (owner === undefined || (typeof owner === "string" && owner.trim() !== "") || (typeof owner === "number" && Number.isFinite(owner)))
|
|
18
|
+
return;
|
|
19
|
+
throw new TypeError("owner must be a string that is not empty or only spaces, such as the signed-in user's ID. To let anyone with the document's ID use it, leave owner out.");
|
|
20
|
+
}
|
|
21
|
+
/** The context of a store call: a frozen object, without the fields that are absent. */
|
|
22
|
+
export function storeContext(scope, owner) {
|
|
23
|
+
return Object.freeze({ ...(scope !== undefined ? { scope } : {}), ...(owner !== undefined ? { owner } : {}) });
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The caller of a call made with `access`. Null is no owner and no scope, as a database gives a
|
|
27
|
+
* field that was left out. The scope is checked (`checkScope`: a `DocumentScopeError` when it is
|
|
28
|
+
* not valid). Under `requireOwner`, a call without an owner, or with one that `checkOwner` refuses,
|
|
29
|
+
* is a TypeError; under `requireScope`, a call without a scope. A `signal` that is not an
|
|
30
|
+
* `AbortSignal` is a TypeError (0.10.0).
|
|
31
|
+
*/
|
|
32
|
+
export function callerOf(access, rules) {
|
|
33
|
+
const owner = (access?.owner ?? undefined);
|
|
34
|
+
if (rules.requireOwner) {
|
|
35
|
+
if (owner === undefined)
|
|
36
|
+
throw new TypeError(OWNER_REQUIRED);
|
|
37
|
+
checkOwner(owner);
|
|
38
|
+
}
|
|
39
|
+
const scope = checkScope(access?.scope ?? undefined);
|
|
40
|
+
if (rules.requireScope && scope === undefined)
|
|
41
|
+
throw new TypeError(SCOPE_REQUIRED);
|
|
42
|
+
const signal = access?.signal ?? undefined;
|
|
43
|
+
if (signal !== undefined && !(signal instanceof AbortSignal))
|
|
44
|
+
throw new TypeError("signal must be an AbortSignal.");
|
|
45
|
+
return {
|
|
46
|
+
...(owner !== undefined ? { owner } : {}),
|
|
47
|
+
...(scope !== undefined ? { scope } : {}),
|
|
48
|
+
context: storeContext(scope, owner),
|
|
49
|
+
key: scopeKey(scope),
|
|
50
|
+
...(signal !== undefined ? { signal } : {}),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Whether `caller` may use the document `meta` describes. A document with an owner serves only that
|
|
55
|
+
* owner, and one with a scope only a caller of the same scope, segment by segment. A document
|
|
56
|
+
* without an owner serves any caller, unless the library requires owners; the same for scopes.
|
|
57
|
+
* Null is no owner and no scope, as a database gives a field that was left out. A refusal is never
|
|
58
|
+
* told: the document reads as missing.
|
|
59
|
+
*/
|
|
60
|
+
export function mayUse(meta, caller, rules) {
|
|
61
|
+
const owner = meta.owner ?? undefined;
|
|
62
|
+
if (owner === undefined ? rules.requireOwner : owner !== caller.owner)
|
|
63
|
+
return false;
|
|
64
|
+
const scope = meta.scope ?? undefined;
|
|
65
|
+
if (scope === undefined)
|
|
66
|
+
return !rules.requireScope;
|
|
67
|
+
// A scope that is not a list of segments (damaged, or written by hand) serves nobody.
|
|
68
|
+
return Array.isArray(scope) && sameScope(scope, caller.scope);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Whether the document `found` has exactly this owner and this scope: no owner is the same as no
|
|
72
|
+
* owner only, and so for scopes. An owner or a scope of null counts as none. A scope that is not a
|
|
73
|
+
* list of segments (damaged, or written by hand) is nobody's.
|
|
74
|
+
*/
|
|
75
|
+
export function heldBy(found, owner, scope) {
|
|
76
|
+
const theirs = found.scope ?? undefined;
|
|
77
|
+
if ((found.owner ?? undefined) !== owner)
|
|
78
|
+
return false;
|
|
79
|
+
return theirs === undefined ? scope === undefined : Array.isArray(theirs) && sameScope(theirs, scope);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The context of the reads of a document's text (`get`, `readTextRange`, `getIndex`, and `putIndex`
|
|
83
|
+
* when its index is built again), once `caller` may use it (`mayUse`): the caller's scope, where
|
|
84
|
+
* `getMeta` found the document, and the owner only when the document has one. The copy kept in memory
|
|
85
|
+
* is kept under the caller's scope, and shared by every caller of it, whose owners differ when the
|
|
86
|
+
* document has none: so its reads carry one context whoever makes them. A document whose metadata
|
|
87
|
+
* has no scope (one of 0.8, moved into a scope) is still read in the scope it was found in. The
|
|
88
|
+
* owner sent is the caller's, which `mayUse` found the same as the document's; it is left out when
|
|
89
|
+
* the document has none.
|
|
90
|
+
*/
|
|
91
|
+
export function documentContext(meta, caller) {
|
|
92
|
+
return storeContext(caller.scope, (meta.owner ?? undefined) === undefined ? undefined : caller.owner);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The metadata a store gave for `id`, when it is that of `id`: metadata of another document (a
|
|
96
|
+
* store that looked up the wrong one) is none. An owner or a scope of null, as a database gives a
|
|
97
|
+
* field that was left out, is left out.
|
|
98
|
+
*/
|
|
99
|
+
export function metaOf(found, id) {
|
|
100
|
+
if (typeof found !== "object" || found === null || found.id !== id)
|
|
101
|
+
return undefined;
|
|
102
|
+
const { owner, scope } = found;
|
|
103
|
+
if (owner !== null && scope !== null)
|
|
104
|
+
return found;
|
|
105
|
+
const { owner: _owner, scope: _scope, ...rest } = found;
|
|
106
|
+
return { ...rest, ...(owner !== null && owner !== undefined ? { owner: owner } : {}), ...(scope !== null && scope !== undefined ? { scope: scope } : {}) };
|
|
107
|
+
}
|
|
108
|
+
/** The longest a Node.js timer waits: a longer time limit is no limit. */
|
|
109
|
+
const LONGEST_TIMER_MS = 2 ** 31 - 1;
|
|
110
|
+
/** Whether `ms` is a time limit a timer can keep: 0, and a time past what a timer can wait, are none. */
|
|
111
|
+
export const isTimeLimit = (ms) => ms > 0 && ms <= LONGEST_TIMER_MS;
|
|
112
|
+
/** A time limit in the words of a message: "500 ms", "30 s", "2 min". */
|
|
113
|
+
export function formatDuration(ms) {
|
|
114
|
+
if (ms < 1_000)
|
|
115
|
+
return `${Math.max(1, Math.round(ms))} ms`;
|
|
116
|
+
if (ms < 120_000)
|
|
117
|
+
return `${Number((ms / 1_000).toFixed(1))} s`;
|
|
118
|
+
return `${Number((ms / 60_000).toFixed(1))} min`;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The calls of this process that ran past their time limit and have not settled. One count for
|
|
122
|
+
* every library, and for every copy of the package (two versions side by side, or one bundled):
|
|
123
|
+
* the calls of a process share one pool of threads (libuv's, `UV_THREADPOOL_SIZE`), and a call
|
|
124
|
+
* that does not answer holds one of them. New in 0.10.0.
|
|
125
|
+
*/
|
|
126
|
+
const STUCK = Symbol.for("llm-large-files.stuckCalls");
|
|
127
|
+
const stuck = (() => {
|
|
128
|
+
const shared = globalThis;
|
|
129
|
+
const found = shared[STUCK];
|
|
130
|
+
if (typeof found === "object" && found !== null && typeof found.count === "number")
|
|
131
|
+
return found;
|
|
132
|
+
return (shared[STUCK] = { count: 0 });
|
|
133
|
+
})();
|
|
134
|
+
/** Store calls of this process past their time limit that have not settled, and calls to the disk of the upload handlers. New in 0.10.0. */
|
|
135
|
+
export function stuckCalls() {
|
|
136
|
+
return stuck.count;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Counts `call` as stuck once it has run `ms` without settling, until it settles: whether or not
|
|
140
|
+
* anyone still waits for it. A call that settles within `ms` never counts, and nothing counts
|
|
141
|
+
* without a time limit (`isTimeLimit`). `late` is called when it passes `ms`. Returns `call`.
|
|
142
|
+
* New in 0.10.0.
|
|
143
|
+
*/
|
|
144
|
+
export function watchStuck(call, ms, late) {
|
|
145
|
+
if (!isTimeLimit(ms))
|
|
146
|
+
return call;
|
|
147
|
+
let counted = false;
|
|
148
|
+
// The timer keeps the process alive: a call that never ends may hold nothing that does, and a
|
|
149
|
+
// caller that waits on it would be lost.
|
|
150
|
+
const timer = setTimeout(() => {
|
|
151
|
+
counted = true;
|
|
152
|
+
stuck.count++;
|
|
153
|
+
late?.();
|
|
154
|
+
}, ms);
|
|
155
|
+
const settle = () => {
|
|
156
|
+
clearTimeout(timer);
|
|
157
|
+
if (counted)
|
|
158
|
+
stuck.count--;
|
|
159
|
+
};
|
|
160
|
+
call.then(settle, settle);
|
|
161
|
+
return call;
|
|
162
|
+
}
|
|
163
|
+
/** Refuses a call of `operation` while `maxStuck` calls of the process are stuck: the store is not answering. New in 0.10.0. */
|
|
164
|
+
export function checkStuck(operation, maxStuck) {
|
|
165
|
+
if (stuck.count < maxStuck)
|
|
166
|
+
return;
|
|
167
|
+
const found = Object.assign(new Error(`${stuck.count} store calls of this process ran past their time limit and have not ended (the limit is ${maxStuck}): the store is not answering.`), { code: "STORE_STUCK" });
|
|
168
|
+
throw new DocumentStoreError(found, { operation, code: "STORE_STUCK" });
|
|
169
|
+
}
|
|
170
|
+
/** A store call that did not end within `ms`. */
|
|
171
|
+
export const storeTimeout = (operation, ms) => new DocumentStoreError(Object.assign(new Error(`The store did not answer within ${formatDuration(ms)}.`), { code: "ETIMEDOUT" }), { operation, code: "ETIMEDOUT" });
|
|
172
|
+
/**
|
|
173
|
+
* A call of the store. What it throws is passed on as a `DocumentStoreError` of `operation`, with
|
|
174
|
+
* the store's error as `cause`: the store's own error may name a path, a host or a bucket, and a
|
|
175
|
+
* store that failed is not a document that is gone. A `DocumentStoreError` is passed on as it is,
|
|
176
|
+
* and so is a `DocumentScopeError`: a scope the store cannot use is a mistake of the call, and the
|
|
177
|
+
* same call would fail again.
|
|
178
|
+
*
|
|
179
|
+
* New in 0.10.0, `options`: a call that does not end within `timeoutMs` is a `DocumentStoreError`
|
|
180
|
+
* of code "ETIMEDOUT", and counts as stuck until it ends; while `maxStuck` calls are stuck, it is
|
|
181
|
+
* refused at once ("STORE_STUCK"); `signal` ends the caller's wait with its reason, as it is.
|
|
182
|
+
*/
|
|
183
|
+
export async function storeCall(operation, call, options = {}) {
|
|
184
|
+
const { timeoutMs = 0, maxStuck = Number.POSITIVE_INFINITY, counts = true, signal } = options;
|
|
185
|
+
checkStuck(operation, maxStuck);
|
|
186
|
+
// A caller that has left starts no call. (Its signal may be an object made like an AbortSignal,
|
|
187
|
+
// which `ToolOptions.signal` takes as before 0.10.0.)
|
|
188
|
+
if (signal?.aborted)
|
|
189
|
+
throw signal.reason;
|
|
190
|
+
let running;
|
|
191
|
+
try {
|
|
192
|
+
running = Promise.resolve(call());
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
running = Promise.reject(error);
|
|
196
|
+
}
|
|
197
|
+
let waited = running;
|
|
198
|
+
if (isTimeLimit(timeoutMs)) {
|
|
199
|
+
waited = new Promise((resolve, reject) => {
|
|
200
|
+
const late = () => reject(storeTimeout(operation, timeoutMs));
|
|
201
|
+
if (counts)
|
|
202
|
+
watchStuck(running, timeoutMs, late);
|
|
203
|
+
else {
|
|
204
|
+
const timer = setTimeout(late, timeoutMs);
|
|
205
|
+
const settle = () => clearTimeout(timer);
|
|
206
|
+
running.then(settle, settle);
|
|
207
|
+
}
|
|
208
|
+
running.then(resolve, reject);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
try {
|
|
212
|
+
return await until(waited, signal);
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
if (signal?.aborted && error === signal.reason)
|
|
216
|
+
throw error;
|
|
217
|
+
throw DocumentStoreError.is(error) || DocumentScopeError.is(error) ? error : new DocumentStoreError(error, { operation });
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Refuses metadata written by a newer version of the package (`metaVersion` above
|
|
222
|
+
* `DOCUMENT_META_VERSION`), which may mean what this version cannot tell: a `DocumentStoreError`
|
|
223
|
+
* with code "NEWER_VERSION", not a document that is missing, so that an application does not
|
|
224
|
+
* ingest the file again over it. Metadata without a version (before 0.9.0), or with null as a
|
|
225
|
+
* database gives a field that was left out, is read as before.
|
|
226
|
+
*/
|
|
227
|
+
export function checkMetaVersion(meta) {
|
|
228
|
+
const version = meta.metaVersion ?? 0;
|
|
229
|
+
if (typeof version === "number" && version <= DOCUMENT_META_VERSION)
|
|
230
|
+
return;
|
|
231
|
+
const found = new RangeError(`The metadata of ${String(meta.id)} has metaVersion ${String(version)}; this version of llm-large-files reads up to ${DOCUMENT_META_VERSION}.`);
|
|
232
|
+
throw new DocumentStoreError(found, { operation: "read", code: "NEWER_VERSION" });
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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AI,qBAAqB;QAAE,OAAO;IAC5E,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,mBAAmB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,oBAAoB,MAAM,CAAC,OAAO,CAAC,iDAAiD,qBAAqB,GAAG,CAAC,CAAC;IAC7K,MAAM,IAAI,kBAAkB,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC;AACpF,CAAC"}
|
package/dist/aggregate.d.ts
CHANGED
|
@@ -83,6 +83,12 @@ export type AggregateResult = {
|
|
|
83
83
|
distinctCapped: boolean;
|
|
84
84
|
/** For each numeric metric, how many matched rows had a value in its column that is not a number (left out). */
|
|
85
85
|
notNumbers: Record<string, number>;
|
|
86
|
+
/** The filters whose value named a column: each row's cell of `column` was compared with its cell of `with` (since 0.10.0). */
|
|
87
|
+
compared?: Array<{
|
|
88
|
+
column: string;
|
|
89
|
+
op: FilterOp;
|
|
90
|
+
with: string;
|
|
91
|
+
}>;
|
|
86
92
|
};
|
|
87
93
|
/**
|
|
88
94
|
* A number as a person writes it in a table: "1,234.5", "-12", "(1,200)" for a negative, "₪4,750",
|
package/dist/aggregate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregate.d.ts","sourceRoot":"","sources":["../src/aggregate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAG9D;;;;;;;;;;;;;;;GAeG;AAEH,uFAAuF;AACvF,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAC3C,yCAAyC;AACzC,eAAO,MAAM,gBAAgB,MAAM,CAAC;AACpC,2GAA2G;AAC3G,eAAO,MAAM,mBAAmB,UAAY,CAAC;AAU7C,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,gBAAgB,CAAC;AACrF,eAAO,MAA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