@absolutejs/rag 0.4.0 → 0.5.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/dist/adapter-kit/index.js +18 -5
- package/dist/adapter-kit/index.js.map +3 -3
- package/dist/index.js +18 -5
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
|
@@ -15696,6 +15696,7 @@ var extractNativePDFText = (data) => {
|
|
|
15696
15696
|
var readUInt16LE = (data, offset) => data[offset] | data[offset + 1] << 8;
|
|
15697
15697
|
var readUInt32LE = (data, offset) => (data[offset] | data[offset + 1] << 8 | data[offset + 2] << 16 | data[offset + 3] << 24) >>> 0;
|
|
15698
15698
|
var decodeUtf8 = (data) => Buffer.from(data).toString("utf8");
|
|
15699
|
+
var decodeLatin1 = (data) => Buffer.from(data).toString("latin1");
|
|
15699
15700
|
var isZipData = (data) => data.length >= 4 && data[0] === 80 && data[1] === 75 && data[2] === 3 && data[3] === 4;
|
|
15700
15701
|
var unzipEntries = (data) => {
|
|
15701
15702
|
const entries = [];
|
|
@@ -16880,7 +16881,19 @@ var decodeEmailPartBody = (body, encoding) => {
|
|
|
16880
16881
|
if (normalizedEncoding === "quoted-printable") {
|
|
16881
16882
|
return new Uint8Array(Buffer.from(decodeQuotedPrintable(body), "latin1"));
|
|
16882
16883
|
}
|
|
16883
|
-
return new Uint8Array(Buffer.from(body, "
|
|
16884
|
+
return new Uint8Array(Buffer.from(body, "latin1"));
|
|
16885
|
+
};
|
|
16886
|
+
var parseMimeCharset = (contentType) => contentType?.match(/charset\s*=\s*"?([^";\s]+)"?/i)?.[1];
|
|
16887
|
+
var decodeWithCharset = (data, contentType) => {
|
|
16888
|
+
const charset = parseMimeCharset(contentType)?.trim().toLowerCase();
|
|
16889
|
+
if (!charset || charset === "utf-8" || charset === "utf8") {
|
|
16890
|
+
return decodeUtf8(data);
|
|
16891
|
+
}
|
|
16892
|
+
try {
|
|
16893
|
+
return new TextDecoder(charset).decode(data);
|
|
16894
|
+
} catch {
|
|
16895
|
+
return decodeUtf8(data);
|
|
16896
|
+
}
|
|
16884
16897
|
};
|
|
16885
16898
|
var parseMimeBoundary = (contentType) => {
|
|
16886
16899
|
const match = contentType?.match(/boundary="?([^";]+)"?/i);
|
|
@@ -17299,7 +17312,7 @@ var parseEmailMimeParts = (body, contentType, transferEncoding) => {
|
|
|
17299
17312
|
const contentLocation = normalizeWhitespace(headers.get("content-location") ?? "");
|
|
17300
17313
|
const filename = disposition?.match(/filename="?([^";]+)"?/i)?.[1] ?? nestedContentType?.match(/name="?([^";]+)"?/i)?.[1];
|
|
17301
17314
|
const decodedBytes = decodeEmailPartBody(nestedBody, transferEncoding2);
|
|
17302
|
-
const decodedText =
|
|
17315
|
+
const decodedText = decodeWithCharset(decodedBytes, nestedContentType);
|
|
17303
17316
|
const normalizedContentType = nestedContentType?.toLowerCase() ?? "";
|
|
17304
17317
|
const isMultipart = normalizedContentType.startsWith("multipart/");
|
|
17305
17318
|
const isHtml = normalizedContentType.includes("text/html");
|
|
@@ -17346,7 +17359,7 @@ var parseEmailMimeParts = (body, contentType, transferEncoding) => {
|
|
|
17346
17359
|
}
|
|
17347
17360
|
}
|
|
17348
17361
|
};
|
|
17349
|
-
const topLevelBody = transferEncoding && !parseMimeBoundary(contentType) ?
|
|
17362
|
+
const topLevelBody = transferEncoding && !parseMimeBoundary(contentType) ? decodeWithCharset(decodeEmailPartBody(body, transferEncoding), contentType) : body;
|
|
17350
17363
|
collectMimeParts(topLevelBody, contentType);
|
|
17351
17364
|
return {
|
|
17352
17365
|
attachments,
|
|
@@ -17996,7 +18009,7 @@ var createEmailExtractor = () => ({
|
|
|
17996
18009
|
const source = input.source ?? input.path ?? input.name ?? `${slugify(input.title ?? DEFAULT_BINARY_NAME)}.eml`;
|
|
17997
18010
|
const extension = inferExtensionFromInput(input);
|
|
17998
18011
|
const emlx = extension === ".emlx" ? decodeEmlxMessageData(input.data) : undefined;
|
|
17999
|
-
const raw = emlx?.raw ??
|
|
18012
|
+
const raw = emlx?.raw ?? decodeLatin1(input.data);
|
|
18000
18013
|
if (extension === ".emlx") {
|
|
18001
18014
|
return extractEmailDocumentsFromRawMessage(input, raw, {
|
|
18002
18015
|
metadata: {
|
|
@@ -31352,5 +31365,5 @@ export {
|
|
|
31352
31365
|
RAG_NATIVE_QUERY_CANDIDATE_LIMIT
|
|
31353
31366
|
};
|
|
31354
31367
|
|
|
31355
|
-
//# debugId=
|
|
31368
|
+
//# debugId=7097CF082CBBCC6664756E2164756E21
|
|
31356
31369
|
//# sourceMappingURL=index.js.map
|