@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
package/dist/index.js
CHANGED
|
@@ -15975,6 +15975,7 @@ var extractNativePDFText = (data) => {
|
|
|
15975
15975
|
var readUInt16LE = (data, offset) => data[offset] | data[offset + 1] << 8;
|
|
15976
15976
|
var readUInt32LE = (data, offset) => (data[offset] | data[offset + 1] << 8 | data[offset + 2] << 16 | data[offset + 3] << 24) >>> 0;
|
|
15977
15977
|
var decodeUtf8 = (data) => Buffer.from(data).toString("utf8");
|
|
15978
|
+
var decodeLatin1 = (data) => Buffer.from(data).toString("latin1");
|
|
15978
15979
|
var isZipData = (data) => data.length >= 4 && data[0] === 80 && data[1] === 75 && data[2] === 3 && data[3] === 4;
|
|
15979
15980
|
var unzipEntries = (data) => {
|
|
15980
15981
|
const entries = [];
|
|
@@ -17159,7 +17160,19 @@ var decodeEmailPartBody = (body, encoding) => {
|
|
|
17159
17160
|
if (normalizedEncoding === "quoted-printable") {
|
|
17160
17161
|
return new Uint8Array(Buffer.from(decodeQuotedPrintable(body), "latin1"));
|
|
17161
17162
|
}
|
|
17162
|
-
return new Uint8Array(Buffer.from(body, "
|
|
17163
|
+
return new Uint8Array(Buffer.from(body, "latin1"));
|
|
17164
|
+
};
|
|
17165
|
+
var parseMimeCharset = (contentType) => contentType?.match(/charset\s*=\s*"?([^";\s]+)"?/i)?.[1];
|
|
17166
|
+
var decodeWithCharset = (data, contentType) => {
|
|
17167
|
+
const charset = parseMimeCharset(contentType)?.trim().toLowerCase();
|
|
17168
|
+
if (!charset || charset === "utf-8" || charset === "utf8") {
|
|
17169
|
+
return decodeUtf8(data);
|
|
17170
|
+
}
|
|
17171
|
+
try {
|
|
17172
|
+
return new TextDecoder(charset).decode(data);
|
|
17173
|
+
} catch {
|
|
17174
|
+
return decodeUtf8(data);
|
|
17175
|
+
}
|
|
17163
17176
|
};
|
|
17164
17177
|
var parseMimeBoundary = (contentType) => {
|
|
17165
17178
|
const match = contentType?.match(/boundary="?([^";]+)"?/i);
|
|
@@ -17578,7 +17591,7 @@ var parseEmailMimeParts = (body, contentType, transferEncoding) => {
|
|
|
17578
17591
|
const contentLocation = normalizeWhitespace(headers.get("content-location") ?? "");
|
|
17579
17592
|
const filename = disposition?.match(/filename="?([^";]+)"?/i)?.[1] ?? nestedContentType?.match(/name="?([^";]+)"?/i)?.[1];
|
|
17580
17593
|
const decodedBytes = decodeEmailPartBody(nestedBody, transferEncoding2);
|
|
17581
|
-
const decodedText =
|
|
17594
|
+
const decodedText = decodeWithCharset(decodedBytes, nestedContentType);
|
|
17582
17595
|
const normalizedContentType = nestedContentType?.toLowerCase() ?? "";
|
|
17583
17596
|
const isMultipart = normalizedContentType.startsWith("multipart/");
|
|
17584
17597
|
const isHtml = normalizedContentType.includes("text/html");
|
|
@@ -17625,7 +17638,7 @@ var parseEmailMimeParts = (body, contentType, transferEncoding) => {
|
|
|
17625
17638
|
}
|
|
17626
17639
|
}
|
|
17627
17640
|
};
|
|
17628
|
-
const topLevelBody = transferEncoding && !parseMimeBoundary(contentType) ?
|
|
17641
|
+
const topLevelBody = transferEncoding && !parseMimeBoundary(contentType) ? decodeWithCharset(decodeEmailPartBody(body, transferEncoding), contentType) : body;
|
|
17629
17642
|
collectMimeParts(topLevelBody, contentType);
|
|
17630
17643
|
return {
|
|
17631
17644
|
attachments,
|
|
@@ -18275,7 +18288,7 @@ var createEmailExtractor = () => ({
|
|
|
18275
18288
|
const source = input.source ?? input.path ?? input.name ?? `${slugify(input.title ?? DEFAULT_BINARY_NAME)}.eml`;
|
|
18276
18289
|
const extension = inferExtensionFromInput(input);
|
|
18277
18290
|
const emlx = extension === ".emlx" ? decodeEmlxMessageData(input.data) : undefined;
|
|
18278
|
-
const raw = emlx?.raw ??
|
|
18291
|
+
const raw = emlx?.raw ?? decodeLatin1(input.data);
|
|
18279
18292
|
if (extension === ".emlx") {
|
|
18280
18293
|
return extractEmailDocumentsFromRawMessage(input, raw, {
|
|
18281
18294
|
metadata: {
|
|
@@ -36383,5 +36396,5 @@ export {
|
|
|
36383
36396
|
addRAGEvaluationSuiteCase
|
|
36384
36397
|
};
|
|
36385
36398
|
|
|
36386
|
-
//# debugId=
|
|
36399
|
+
//# debugId=935E9CE2ED17498064756E2164756E21
|
|
36387
36400
|
//# sourceMappingURL=index.js.map
|