@absolutejs/documents 0.0.0-stage → 0.1.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 +14 -0
- package/LICENSE +88 -0
- package/README.md +41 -2
- package/changelog.json +20 -0
- package/dist/archive/containers.d.ts +5 -0
- package/dist/binary.d.ts +13 -0
- package/dist/define.d.ts +6 -0
- package/dist/email/body.d.ts +20 -0
- package/dist/email/headers.d.ts +20 -0
- package/dist/email/mailboxContainer.d.ts +19 -0
- package/dist/email/mailboxMetadata.d.ts +25 -0
- package/dist/email/maildir.d.ts +29 -0
- package/dist/email/mbox.d.ts +5 -0
- package/dist/email/message.d.ts +21 -0
- package/dist/email/mime.d.ts +24 -0
- package/dist/email/threads.d.ts +2 -0
- package/dist/epub.d.ts +2 -0
- package/dist/extractors/archive.d.ts +5 -0
- package/dist/extractors/email.d.ts +2 -0
- package/dist/extractors/epub.d.ts +2 -0
- package/dist/extractors/image.d.ts +2 -0
- package/dist/extractors/legacy.d.ts +2 -0
- package/dist/extractors/mailbox.d.ts +2 -0
- package/dist/extractors/media.d.ts +2 -0
- package/dist/extractors/office.d.ts +2 -0
- package/dist/extractors/pdf.d.ts +2 -0
- package/dist/extractors/pdfOCR.d.ts +2 -0
- package/dist/extractors/supports.d.ts +11 -0
- package/dist/extractors/text.d.ts +2 -0
- package/dist/formats.d.ts +37 -0
- package/dist/helpers.d.ts +11 -0
- package/dist/helpers.js +39 -0
- package/dist/html.d.ts +4 -0
- package/dist/identity.d.ts +3 -0
- package/dist/index-6cd9rbkj.js +3677 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +1126 -0
- package/dist/legacy.d.ts +3 -0
- package/dist/media.d.ts +22 -0
- package/dist/ocr.d.ts +22 -0
- package/dist/office/presentation.d.ts +10 -0
- package/dist/office/spreadsheet.d.ts +26 -0
- package/dist/office/word.d.ts +20 -0
- package/dist/pdf/bounded.d.ts +33 -0
- package/dist/pdf/checkpoint.d.ts +28 -0
- package/dist/pdf/native.d.ts +39 -0
- package/dist/pdf/paged.d.ts +17 -0
- package/dist/read.d.ts +25 -0
- package/dist/registry.d.ts +5 -0
- package/dist/structured.d.ts +2 -0
- package/dist/text.d.ts +1 -0
- package/dist/types.d.ts +123 -0
- package/package.json +55 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@absolutejs/documents`.
|
|
4
|
+
|
|
5
|
+
This file is generated by `absolute-changelog` from the entries in
|
|
6
|
+
`changelog/`. Edit an entry, not this file — and add new ones under
|
|
7
|
+
`changelog/unreleased/`.
|
|
8
|
+
|
|
9
|
+
## 0.1.0 — 2026-12-05
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- **readDocument, readDocuments, readDocumentFile and readDocumentUploads read a file or upload; readWebDocument plugs into @absolutejs/search's readWebpage as its readDocument so PDFs and Office files behind a URL are read too.**
|
|
14
|
+
- **Reads files into text: PDF (native text, bounded rendering, paged OCR with resumable checkpoints), Word/Excel/PowerPoint and OpenDocument, EPUB, RTF and legacy documents, email (.eml/.emlx/.mbox, Maildir, PST/OST) with thread reconciliation, and zip/tar/gzip archives. OCR and audio/video transcription are pluggable providers. Moved out of @absolutejs/rag, which re-exports it under its original names.**
|
package/LICENSE
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
**Licensor:** Alex Kahn
|
|
4
|
+
|
|
5
|
+
**Licensed Work:** @absolutejs/documents (https://github.com/absolutejs/documents)
|
|
6
|
+
|
|
7
|
+
**Change Date:** December 5, 2030
|
|
8
|
+
|
|
9
|
+
**Change License:** Apache License, Version 2.0
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Terms
|
|
14
|
+
|
|
15
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
16
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
17
|
+
Licensor may make an Additional Use Grant, permitting limited production use.
|
|
18
|
+
|
|
19
|
+
### Additional Use Grant
|
|
20
|
+
|
|
21
|
+
You may use the Licensed Work in production, provided your use does not include
|
|
22
|
+
any of the following:
|
|
23
|
+
|
|
24
|
+
1. **Offering a Competing Service.** You may not offer the Licensed Work, or
|
|
25
|
+
any derivative or substantial portion of it, to third parties as a hosted or
|
|
26
|
+
managed service that competes with a hosted document parsing or extraction service (including, but not limited to, services like Unstructured, LlamaParse, Reducto, or Azure AI Document Intelligence). This includes any
|
|
27
|
+
product whose primary value to its users is the functionality the Licensed
|
|
28
|
+
Work provides.
|
|
29
|
+
|
|
30
|
+
2. **Resale or Redistribution as a Standalone Product.** You may not sell,
|
|
31
|
+
license, or distribute the Licensed Work, or any derivative or fork of it,
|
|
32
|
+
as a standalone commercial product.
|
|
33
|
+
|
|
34
|
+
3. **Removal of Attribution.** Any derivative work, fork, or redistribution of
|
|
35
|
+
the Licensed Work must prominently credit AbsoluteJS and include a link to
|
|
36
|
+
the original project repository (https://github.com/absolutejs/documents).
|
|
37
|
+
|
|
38
|
+
For clarity, the following uses are expressly permitted:
|
|
39
|
+
|
|
40
|
+
- Using the Licensed Work to build and operate your own applications, websites,
|
|
41
|
+
internal tools, or SaaS products (whether commercial or non-commercial), so
|
|
42
|
+
long as the Licensed Work itself is not the primary product you are selling.
|
|
43
|
+
- Using the Licensed Work as a dependency in commercial software you build and
|
|
44
|
+
sell, as long as the software is not itself a competing managed service of
|
|
45
|
+
the kind described in clause 1.
|
|
46
|
+
- Providing consulting, development, or professional services to clients using
|
|
47
|
+
the Licensed Work.
|
|
48
|
+
- Forking and modifying the Licensed Work for your own internal use, provided
|
|
49
|
+
attribution is maintained.
|
|
50
|
+
|
|
51
|
+
### Change Date and Change License
|
|
52
|
+
|
|
53
|
+
On the Change Date specified above, or on such other date as the Licensor may
|
|
54
|
+
specify by written notice, the Licensed Work will be made available under the
|
|
55
|
+
Change License (Apache License, Version 2.0). Until the Change Date, the terms
|
|
56
|
+
of this Business Source License 1.1 apply.
|
|
57
|
+
|
|
58
|
+
### Trademark
|
|
59
|
+
|
|
60
|
+
This license does not grant you any rights to use the "AbsoluteJS" or
|
|
61
|
+
"@absolutejs" name, logo, or any related trademarks. Forks and derivative works
|
|
62
|
+
must not be named or branded in a manner that suggests endorsement by or
|
|
63
|
+
affiliation with AbsoluteJS or the Licensor.
|
|
64
|
+
|
|
65
|
+
### Notices
|
|
66
|
+
|
|
67
|
+
You must not remove or obscure any licensing, copyright, or other notices
|
|
68
|
+
included in the Licensed Work.
|
|
69
|
+
|
|
70
|
+
### No Warranty
|
|
71
|
+
|
|
72
|
+
THE LICENSED WORK IS PROVIDED "AS IS". THE LICENSOR HEREBY DISCLAIMS ALL
|
|
73
|
+
WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
|
|
74
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO
|
|
75
|
+
EVENT SHALL THE LICENSOR BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY,
|
|
76
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR
|
|
77
|
+
IN CONNECTION WITH THE LICENSED WORK OR THE USE OR OTHER DEALINGS IN THE
|
|
78
|
+
LICENSED WORK.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Contact
|
|
83
|
+
|
|
84
|
+
For commercial licensing inquiries or additional permissions, contact:
|
|
85
|
+
|
|
86
|
+
- **Alex Kahn**
|
|
87
|
+
- alexkahndev@gmail.com
|
|
88
|
+
- alexkahndev.github.io
|
package/README.md
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @absolutejs/documents
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Read files into text. PDFs, Word/Excel/PowerPoint and OpenDocument, EPUB, RTF
|
|
4
|
+
and legacy documents, email (`.eml`, `.emlx`, `.mbox`, Maildir, PST/OST) and
|
|
5
|
+
zip/tar/gzip archives come back as plain text with their title, format and
|
|
6
|
+
source. OCR and audio/video transcription are providers you plug in.
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
import { readDocument, readDocumentFile } from "@absolutejs/documents";
|
|
10
|
+
|
|
11
|
+
const report = await readDocumentFile("./q3-report.pdf");
|
|
12
|
+
const upload = await readDocument({ data: bytes, name: "notes.docx" });
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
A file that holds several documents (a mailbox, an archive) returns all of
|
|
16
|
+
them from `readDocuments`. Add your own reader for a file type with
|
|
17
|
+
`createFileExtractor` and pass it in `extractors`, or order readers with
|
|
18
|
+
`createExtractorRegistry`.
|
|
19
|
+
|
|
20
|
+
## With @absolutejs/search
|
|
21
|
+
|
|
22
|
+
`readWebDocument` lets the web reader read what isn't HTML:
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { readWebpage } from "@absolutejs/search/web";
|
|
26
|
+
import { readWebDocument } from "@absolutejs/documents";
|
|
27
|
+
|
|
28
|
+
const page = await readWebpage({ url, readDocument: readWebDocument });
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## With @absolutejs/rag
|
|
32
|
+
|
|
33
|
+
rag builds on this package for ingestion and re-exports its pieces under
|
|
34
|
+
their original `RAG` names; you don't need to install both.
|
|
35
|
+
|
|
36
|
+
## PDF processing
|
|
37
|
+
|
|
38
|
+
Rendering and paged OCR use `pdftoppm` (poppler-utils) when it is installed.
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
Business Source License 1.1; see [LICENSE](LICENSE).
|
package/changelog.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"contract": 1,
|
|
3
|
+
"name": "@absolutejs/documents",
|
|
4
|
+
"releases": [
|
|
5
|
+
{
|
|
6
|
+
"changes": [
|
|
7
|
+
{
|
|
8
|
+
"kind": "added",
|
|
9
|
+
"summary": "readDocument, readDocuments, readDocumentFile and readDocumentUploads read a file or upload; readWebDocument plugs into @absolutejs/search's readWebpage as its readDocument so PDFs and Office files behind a URL are read too."
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"kind": "added",
|
|
13
|
+
"summary": "Reads files into text: PDF (native text, bounded rendering, paged OCR with resumable checkpoints), Word/Excel/PowerPoint and OpenDocument, EPUB, RTF and legacy documents, email (.eml/.emlx/.mbox, Maildir, PST/OST) with thread reconciliation, and zip/tar/gzip archives. OCR and audio/video transcription are pluggable providers. Moved out of @absolutejs/rag, which re-exports it under its original names."
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"date": "2026-12-05",
|
|
17
|
+
"version": "0.1.0"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ArchiveEntry, type ExtractionInput } from "../types";
|
|
2
|
+
export declare const isZipData: (data: Uint8Array) => boolean;
|
|
3
|
+
export declare const unzipEntries: (data: Uint8Array) => ArchiveEntry[];
|
|
4
|
+
export declare const untarEntries: (data: Uint8Array) => ArchiveEntry[];
|
|
5
|
+
export declare const decodeGzipEntries: (data: Uint8Array, input: ExtractionInput) => ArchiveEntry[];
|
package/dist/binary.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const readUInt16LE: (data: Uint8Array, offset: number) => number;
|
|
2
|
+
export declare const readUInt32LE: (data: Uint8Array, offset: number) => number;
|
|
3
|
+
export declare const decodeUtf8: (data: Uint8Array) => string;
|
|
4
|
+
/**
|
|
5
|
+
* Byte-preserving decode: each byte becomes the char with that code.
|
|
6
|
+
*
|
|
7
|
+
* A raw message must NOT be read as utf8 before its parts are parsed — a
|
|
8
|
+
* part declaring iso-8859-1 or shift_jis has already been corrupted into
|
|
9
|
+
* replacement characters by then, and no later decode can recover it. Holding
|
|
10
|
+
* the message as latin1 keeps every byte addressable until the part's own
|
|
11
|
+
* charset is known, at which point decodeWithCharset does the real decode.
|
|
12
|
+
*/
|
|
13
|
+
export declare const decodeLatin1: (data: Uint8Array) => string;
|
package/dist/define.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ArchiveExpander, type ExtractorRegistryLike, type FileExtractor, type MediaTranscriber, type OCRProvider } from "./types";
|
|
2
|
+
export declare const createArchiveExpander: (expander: ArchiveExpander) => ArchiveExpander;
|
|
3
|
+
export declare const createFileExtractor: (extractor: FileExtractor) => FileExtractor;
|
|
4
|
+
export declare const createExtractorRegistry: (registry: ExtractorRegistryLike) => ExtractorRegistryLike;
|
|
5
|
+
export declare const createMediaTranscriber: (transcriber: MediaTranscriber) => MediaTranscriber;
|
|
6
|
+
export declare const createOCRProvider: (provider: OCRProvider) => OCRProvider;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type EmailBodySection = {
|
|
2
|
+
kind: "authored_text" | "forwarded_headers" | "quoted_history" | "signature";
|
|
3
|
+
text: string;
|
|
4
|
+
forwardedHeaderFields?: Record<string, string>;
|
|
5
|
+
forwardedFromAddress?: string;
|
|
6
|
+
forwardedFromDisplayName?: string;
|
|
7
|
+
forwardedToAddresses?: string[];
|
|
8
|
+
forwardedCcAddresses?: string[];
|
|
9
|
+
forwardedBccAddresses?: string[];
|
|
10
|
+
forwardedReplyToAddresses?: string[];
|
|
11
|
+
forwardedParticipantAddresses?: string[];
|
|
12
|
+
forwardedSubject?: string;
|
|
13
|
+
forwardedDate?: string;
|
|
14
|
+
forwardedTimestamp?: string;
|
|
15
|
+
quotedDepth?: number;
|
|
16
|
+
};
|
|
17
|
+
export declare const parseEmailBodySections: (text: string) => EmailBodySection[];
|
|
18
|
+
export declare const stripEmailHtml: (value: string) => string;
|
|
19
|
+
export declare const choosePreferredEmailBodyText: (htmlText: string | undefined, plainText: string | undefined) => string | undefined;
|
|
20
|
+
export declare const chooseEmailBodyCandidate: (current: string | undefined, candidate: string | undefined) => string | undefined;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type EmailMessageLineageEntry = {
|
|
2
|
+
attachmentSource?: string;
|
|
3
|
+
messageId?: string;
|
|
4
|
+
messageSource?: string;
|
|
5
|
+
messageSourceKind?: string;
|
|
6
|
+
threadKey?: string;
|
|
7
|
+
};
|
|
8
|
+
type ParsedEmailAddressEntry = {
|
|
9
|
+
address: string;
|
|
10
|
+
displayName?: string;
|
|
11
|
+
raw: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const parseEmailAddressList: (value: string | undefined) => {
|
|
14
|
+
addresses: string[];
|
|
15
|
+
displayNames: string[];
|
|
16
|
+
entries: ParsedEmailAddressEntry[];
|
|
17
|
+
};
|
|
18
|
+
export declare const normalizeEmailTimestamp: (value: string | undefined) => string | undefined;
|
|
19
|
+
export declare const parseEmailMessageLineage: (metadata?: Record<string, unknown>) => EmailMessageLineageEntry[];
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type ParsedMailboxContainerMessage = {
|
|
2
|
+
attachments?: {
|
|
3
|
+
contentId?: string;
|
|
4
|
+
contentLocation?: string;
|
|
5
|
+
contentType?: string;
|
|
6
|
+
data: Uint8Array;
|
|
7
|
+
dispositionType?: string;
|
|
8
|
+
fileName: string;
|
|
9
|
+
role: "attached_message" | "file_attachment" | "inline_resource";
|
|
10
|
+
}[];
|
|
11
|
+
metadata: Record<string, unknown>;
|
|
12
|
+
raw: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const extractMailboxRecoveredEmbeddedReferences: (raw: string) => {
|
|
15
|
+
contentIds: string[];
|
|
16
|
+
contentLocations: string[];
|
|
17
|
+
};
|
|
18
|
+
export declare const splitMailboxContainerMessages: (raw: string) => ParsedMailboxContainerMessage[];
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const buildMailboxStateMetadata: (stateFlags: string[]) => {
|
|
2
|
+
emailMailboxIsDraft: boolean;
|
|
3
|
+
emailMailboxIsFlagged: boolean;
|
|
4
|
+
emailMailboxIsPassed: boolean;
|
|
5
|
+
emailMailboxIsRead: boolean;
|
|
6
|
+
emailMailboxIsReplied: boolean;
|
|
7
|
+
emailMailboxIsTrashed: boolean;
|
|
8
|
+
emailMailboxIsUnread: boolean;
|
|
9
|
+
emailMailboxStateFlags?: string[] | undefined;
|
|
10
|
+
};
|
|
11
|
+
export declare const parseMailboxAttachmentNames: (value: string | undefined) => string[];
|
|
12
|
+
export declare const parseMailboxStateFlags: (value: string | undefined) => string[];
|
|
13
|
+
export declare const parseMailboxFolderMetadata: (value: string | undefined) => {
|
|
14
|
+
emailMailboxFamilyKey?: undefined;
|
|
15
|
+
emailMailboxFolder?: undefined;
|
|
16
|
+
emailMailboxLeaf?: undefined;
|
|
17
|
+
emailMailboxPathDepth?: undefined;
|
|
18
|
+
emailMailboxPathSegments?: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
emailMailboxFamilyKey: string;
|
|
21
|
+
emailMailboxFolder: string | undefined;
|
|
22
|
+
emailMailboxLeaf: string | undefined;
|
|
23
|
+
emailMailboxPathDepth: number;
|
|
24
|
+
emailMailboxPathSegments: string[];
|
|
25
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare const decodeEmlxMessageData: (data: Uint8Array) => {
|
|
2
|
+
hasTrailingMetadata: boolean;
|
|
3
|
+
messageByteLength: number;
|
|
4
|
+
raw: string;
|
|
5
|
+
} | {
|
|
6
|
+
hasTrailingMetadata: boolean;
|
|
7
|
+
messageByteLength: undefined;
|
|
8
|
+
raw: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const isLikelyRawEmailData: (raw: string) => boolean;
|
|
11
|
+
export declare const parseMaildirMetadata: (source: string | undefined) => {
|
|
12
|
+
emailMailboxKey?: string | undefined;
|
|
13
|
+
emailMailboxIsDraft: boolean;
|
|
14
|
+
emailMailboxIsFlagged: boolean;
|
|
15
|
+
emailMailboxIsPassed: boolean;
|
|
16
|
+
emailMailboxIsRead: boolean;
|
|
17
|
+
emailMailboxIsReplied: boolean;
|
|
18
|
+
emailMailboxIsTrashed: boolean;
|
|
19
|
+
emailMailboxIsUnread: boolean;
|
|
20
|
+
emailMailboxStateFlags?: string[] | undefined;
|
|
21
|
+
emailMailboxFlags?: string[] | undefined;
|
|
22
|
+
emailMailboxContainerSource?: string | undefined;
|
|
23
|
+
emailMailboxPathDepth?: number | undefined;
|
|
24
|
+
emailMailboxPathSegments?: string[] | undefined;
|
|
25
|
+
emailMailboxLeaf?: string | undefined;
|
|
26
|
+
emailMailboxFamilyKey?: string | undefined;
|
|
27
|
+
emailMailboxFormat: string;
|
|
28
|
+
emailMailboxFolder: string;
|
|
29
|
+
} | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ExtractionInput } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* The part of a mail body that this message ADDS — authored text only, with
|
|
4
|
+
* quoted history, forwarded headers and the signature block dropped.
|
|
5
|
+
*
|
|
6
|
+
* Exposed rather than applied by default, deliberately. The extractor's own
|
|
7
|
+
* output is a faithful reconstruction of the message (thread lineage and
|
|
8
|
+
* forwarded chains are built from it), so stripping there would break that
|
|
9
|
+
* contract. Embedding is the case that wants only the new content: in a thread,
|
|
10
|
+
* the full text means message N re-embeds the whole of 1..N-1 plus a signature
|
|
11
|
+
* and a confidentiality footer, every time — quadratic in thread length.
|
|
12
|
+
*
|
|
13
|
+
* A message that is nothing but a forward is kept whole rather than reduced to
|
|
14
|
+
* nothing.
|
|
15
|
+
*/
|
|
16
|
+
export declare const authoredEmailText: (text: string) => string;
|
|
17
|
+
export declare const extractEmailDocumentsFromRawMessage: (input: ExtractionInput, raw: string, options?: {
|
|
18
|
+
metadata?: Record<string, unknown>;
|
|
19
|
+
source?: string;
|
|
20
|
+
title?: string;
|
|
21
|
+
}) => Promise<import("..").DocumentContent[]>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const parseHeaderBlock: (headerBlock: string) => Map<string, string>;
|
|
2
|
+
export declare const decodeEmailPartBody: (body: string, encoding: string | undefined) => Uint8Array<ArrayBuffer>;
|
|
3
|
+
/**
|
|
4
|
+
* Decode a part's bytes using the charset it DECLARED, not utf8.
|
|
5
|
+
*
|
|
6
|
+
* Every part body was read as utf8 regardless, so a Shift-JIS, ISO-8859-1 or
|
|
7
|
+
* windows-1252 message decoded into replacement characters and mojibake and was
|
|
8
|
+
* embedded that way — unsearchable, and worse than useless in a vector.
|
|
9
|
+
* Unknown or unsupported labels fall back to utf8, which is what the code did
|
|
10
|
+
* unconditionally before, so this can only improve on the previous behaviour.
|
|
11
|
+
*/
|
|
12
|
+
export declare const decodeWithCharset: (data: Uint8Array, contentType: string | undefined) => string;
|
|
13
|
+
export declare const parseMimeBoundary: (contentType: string | undefined) => string | undefined;
|
|
14
|
+
export declare const normalizeEmailContentId: (value: string | undefined) => string | undefined;
|
|
15
|
+
export declare const inferEmailAttachmentName: ({ contentId, contentLocation, contentType, filename, }: {
|
|
16
|
+
contentId?: string;
|
|
17
|
+
contentLocation?: string;
|
|
18
|
+
contentType?: string;
|
|
19
|
+
filename?: string;
|
|
20
|
+
}) => string;
|
|
21
|
+
export declare const parseEmailEmbeddedResourceReferences: (bodyHtml: string | undefined) => {
|
|
22
|
+
contentIds: string[];
|
|
23
|
+
contentLocations: string[];
|
|
24
|
+
};
|
package/dist/epub.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ArchiveExpander, type FileExtractor } from "../types";
|
|
2
|
+
export declare const createBuiltinArchiveExpander: () => ArchiveExpander;
|
|
3
|
+
export declare const createArchiveFileExtractor: (expander: ArchiveExpander, options?: {
|
|
4
|
+
entryExtractors?: FileExtractor[];
|
|
5
|
+
}) => FileExtractor;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ExtractionInput } from "../types";
|
|
2
|
+
export declare const textExtractorSupports: (input: ExtractionInput) => boolean;
|
|
3
|
+
export declare const pdfExtractorSupports: (input: ExtractionInput) => boolean;
|
|
4
|
+
export declare const mediaExtractorSupports: (input: ExtractionInput) => boolean;
|
|
5
|
+
export declare const officeExtractorSupports: (input: ExtractionInput) => boolean;
|
|
6
|
+
export declare const legacyExtractorSupports: (input: ExtractionInput) => boolean;
|
|
7
|
+
export declare const epubExtractorSupports: (input: ExtractionInput) => boolean;
|
|
8
|
+
export declare const emailExtractorSupports: (input: ExtractionInput) => boolean;
|
|
9
|
+
export declare const mailboxContainerExtractorSupports: (input: ExtractionInput) => boolean;
|
|
10
|
+
export declare const imageExtractorSupports: (input: ExtractionInput) => boolean;
|
|
11
|
+
export declare const archiveExtractorSupports: (input: ExtractionInput) => boolean;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type DocumentUpload } from "./types";
|
|
2
|
+
export declare const DEFAULT_BINARY_NAME = "document";
|
|
3
|
+
export declare const TEXT_FILE_EXTENSIONS: Set<string>;
|
|
4
|
+
export declare const officeExtension: (input: {
|
|
5
|
+
contentType?: string;
|
|
6
|
+
path?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
source?: string;
|
|
9
|
+
}) => string;
|
|
10
|
+
export declare const OFFICE_FILE_EXTENSIONS: Set<string>;
|
|
11
|
+
export declare const LEGACY_DOCUMENT_FILE_EXTENSIONS: Set<string>;
|
|
12
|
+
export declare const MAILBOX_CONTAINER_FILE_EXTENSIONS: Set<string>;
|
|
13
|
+
export declare const EMAIL_FILE_EXTENSIONS: Set<string>;
|
|
14
|
+
export declare const EPUB_FILE_EXTENSIONS: Set<string>;
|
|
15
|
+
export declare const PDF_FILE_EXTENSIONS: Set<string>;
|
|
16
|
+
export declare const AUDIO_FILE_EXTENSIONS: Set<string>;
|
|
17
|
+
export declare const VIDEO_FILE_EXTENSIONS: Set<string>;
|
|
18
|
+
export declare const IMAGE_FILE_EXTENSIONS: Set<string>;
|
|
19
|
+
export declare const ARCHIVE_FILE_EXTENSIONS: Set<string>;
|
|
20
|
+
export declare const TAR_FILE_EXTENSIONS: Set<string>;
|
|
21
|
+
export declare const GZIP_FILE_EXTENSIONS: Set<string>;
|
|
22
|
+
export declare const inferFormatFromUrl: (input: string) => "text" | "markdown" | "html" | "jsonl" | "tsv" | "csv" | "xml" | "yaml";
|
|
23
|
+
export declare const inferFormatFromName: (value: string | undefined) => "text" | "markdown" | "html" | "jsonl" | "tsv" | "csv" | "xml" | "yaml";
|
|
24
|
+
export declare const inferFormatFromContentType: (contentType: string | null) => "text" | "markdown" | "html" | "jsonl" | "tsv" | "csv" | "xml" | "yaml" | undefined;
|
|
25
|
+
export declare const decodeUploadContent: (input: DocumentUpload) => Buffer<ArrayBuffer>;
|
|
26
|
+
export declare const inferNameFromInput: (input: {
|
|
27
|
+
path?: string;
|
|
28
|
+
name?: string;
|
|
29
|
+
source?: string;
|
|
30
|
+
title?: string;
|
|
31
|
+
}) => string;
|
|
32
|
+
export declare const inferExtensionFromInput: (input: {
|
|
33
|
+
path?: string;
|
|
34
|
+
name?: string;
|
|
35
|
+
source?: string;
|
|
36
|
+
}) => string;
|
|
37
|
+
export declare const isLikelyTextData: (data: Uint8Array) => boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { reconcileLoadedEmailThreads } from "./email/threads";
|
|
2
|
+
export type { EmailBodySection } from "./email/body";
|
|
3
|
+
export { parseMaildirMetadata } from "./email/maildir";
|
|
4
|
+
export { decodeUploadContent, inferFormatFromContentType, inferFormatFromName, inferFormatFromUrl, } from "./formats";
|
|
5
|
+
export { extractMainHtmlContent, stripHtml, stripHtmlTags } from "./html";
|
|
6
|
+
export { documentIdentity, slugify } from "./identity";
|
|
7
|
+
export { extractPDFFigureLabel, inferPDFBlockHeading } from "./pdf/native";
|
|
8
|
+
export type { PDFNativeStructureBlockEntry } from "./pdf/native";
|
|
9
|
+
export type { SpreadsheetTableColumnRange, SpreadsheetTableHeaders, } from "./office/spreadsheet";
|
|
10
|
+
export { DEFAULT_FILE_EXTRACTORS, extractDocuments, getFirstExtractedDocument, } from "./registry";
|
|
11
|
+
export { normalizeWhitespace } from "./text";
|
package/dist/helpers.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
inferFormatFromUrl2,
|
|
4
|
+
inferFormatFromName2,
|
|
5
|
+
inferFormatFromContentType2,
|
|
6
|
+
decodeUploadContent2,
|
|
7
|
+
slugify2,
|
|
8
|
+
documentIdentity2,
|
|
9
|
+
normalizeWhitespace2,
|
|
10
|
+
parseMaildirMetadata2,
|
|
11
|
+
stripHtmlTags2,
|
|
12
|
+
extractMainHtmlContent2,
|
|
13
|
+
stripHtml2,
|
|
14
|
+
inferPDFBlockHeading2,
|
|
15
|
+
extractPDFFigureLabel2,
|
|
16
|
+
DEFAULT_FILE_EXTRACTORS2,
|
|
17
|
+
extractDocuments2,
|
|
18
|
+
getFirstExtractedDocument2,
|
|
19
|
+
reconcileLoadedEmailThreads2
|
|
20
|
+
} from "./index-6cd9rbkj.js";
|
|
21
|
+
export {
|
|
22
|
+
DEFAULT_FILE_EXTRACTORS2 as DEFAULT_FILE_EXTRACTORS,
|
|
23
|
+
decodeUploadContent2 as decodeUploadContent,
|
|
24
|
+
documentIdentity2 as documentIdentity,
|
|
25
|
+
extractDocuments2 as extractDocuments,
|
|
26
|
+
extractMainHtmlContent2 as extractMainHtmlContent,
|
|
27
|
+
extractPDFFigureLabel2 as extractPDFFigureLabel,
|
|
28
|
+
getFirstExtractedDocument2 as getFirstExtractedDocument,
|
|
29
|
+
inferFormatFromContentType2 as inferFormatFromContentType,
|
|
30
|
+
inferFormatFromName2 as inferFormatFromName,
|
|
31
|
+
inferFormatFromUrl2 as inferFormatFromUrl,
|
|
32
|
+
inferPDFBlockHeading2 as inferPDFBlockHeading,
|
|
33
|
+
normalizeWhitespace2 as normalizeWhitespace,
|
|
34
|
+
parseMaildirMetadata2 as parseMaildirMetadata,
|
|
35
|
+
reconcileLoadedEmailThreads2 as reconcileLoadedEmailThreads,
|
|
36
|
+
slugify2 as slugify,
|
|
37
|
+
stripHtml2 as stripHtml,
|
|
38
|
+
stripHtmlTags2 as stripHtmlTags
|
|
39
|
+
};
|
package/dist/html.d.ts
ADDED