@utilix-tech/sdk 0.76.0 → 0.78.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 +7 -0
- package/README.md +19 -4
- package/dist/{chunk-CXUOV672.js → chunk-KWS4ZCYG.js} +119 -1
- package/dist/{chunk-HJVSH7FQ.js → chunk-XOUS3M5Z.js} +33 -1
- package/dist/{chunk-PT4N4UBL.js → chunk-ZWFZRDQ4.js} +70 -1
- package/dist/{data-26TALa9U.d.ts → data-DIyBrJ6l.d.cts} +13 -2
- package/dist/{data-26TALa9U.d.cts → data-DIyBrJ6l.d.ts} +13 -2
- package/dist/index.cjs +219 -0
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/{media-56zrIBw4.d.cts → media-DF8BS-iA.d.cts} +33 -2
- package/dist/{media-56zrIBw4.d.ts → media-DF8BS-iA.d.ts} +33 -2
- package/dist/{network-Da3meCWM.d.cts → network-BskZe1n2.d.cts} +34 -2
- package/dist/{network-Da3meCWM.d.ts → network-BskZe1n2.d.ts} +34 -2
- package/dist/tools/data.cjs +32 -0
- package/dist/tools/data.d.cts +1 -1
- package/dist/tools/data.d.ts +1 -1
- package/dist/tools/data.js +1 -1
- package/dist/tools/media.cjs +69 -0
- package/dist/tools/media.d.cts +1 -1
- package/dist/tools/media.d.ts +1 -1
- package/dist/tools/media.js +1 -1
- package/dist/tools/network.cjs +118 -0
- package/dist/tools/network.d.cts +1 -1
- package/dist/tools/network.d.ts +1 -1
- package/dist/tools/network.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Full release notes for all Utilix surfaces (browser tools, REST API, SDKs, MCP server) live at [utilix.tech/changelog](https://utilix.tech/changelog). This file tracks just this package.
|
|
4
4
|
|
|
5
|
+
## 0.78.0
|
|
6
|
+
- Add `ndjsonToCsv` (ndjson-to-csv): convert newline-delimited JSON (one flat object per line) into CSV, inferring the header row from the union of keys across all lines.
|
|
7
|
+
|
|
8
|
+
## 0.77.0
|
|
9
|
+
- Add `readPdfOutline` (pdf-outline-extractor): walk a PDF's /Outlines bookmark tree (the Root -> Outlines -> First/Next/First chain) and list every bookmark's title, nesting level, and link target, in document order.
|
|
10
|
+
- Add `scoreSecurityHeaders` (security-headers-scorecard): score a pasted block of raw HTTP response headers against commonly recommended security headers (CSP, HSTS, X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Permissions-Policy, Cross-Origin-*), with an overall 0-100 score and A-F letter grade.
|
|
11
|
+
|
|
5
12
|
## 0.76.0
|
|
6
13
|
- Add `detectWordyPhrases` (wordy-phrase-detector): scan text against a curated table of wordy/redundant phrases ("due to the fact that", "in order to") and flag each occurrence with a suggested concise replacement, an occurrence count, and character offsets.
|
|
7
14
|
- Add `checkOxfordCommaConsistency` (oxford-comma-checker): scan a document for comma-before-and/or usage in three-or-more-item lists and flag documents that mix Oxford comma styles.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @utilix-tech/sdk
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**706 developer utility functions for Node.js: runs locally, no API key required.**
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@utilix-tech/sdk)
|
|
6
6
|
[](https://www.npmjs.com/package/@utilix-tech/sdk)
|
|
@@ -219,7 +219,7 @@ import { parseCsv, csvToJson, validateYaml, resolveYamlAnchors, tomlToJson, json
|
|
|
219
219
|
validateNdjson, formatNdjson, ndjsonToJsonArray, diffEnvExample,
|
|
220
220
|
parseSubtitles, convertSubtitles, shiftSubtitles, analyzeCaptionSpeed, parseFrontMatter,
|
|
221
221
|
generateMarkdownToc, csvToSqlInsert, findCsvDuplicateRows, calculateMarkdownTaskListProgress,
|
|
222
|
-
inferCsvColumnTypes, dedupeNdjson } from "@utilix-tech/sdk/data";
|
|
222
|
+
inferCsvColumnTypes, dedupeNdjson, ndjsonToCsv } from "@utilix-tech/sdk/data";
|
|
223
223
|
|
|
224
224
|
// CSV
|
|
225
225
|
const rows = parseCsv("name,age\nalice,30\nbob,25");
|
|
@@ -250,6 +250,10 @@ ndjsonToJsonArray('{"id":1}\n{"id":2}'); // '[\n { "id": 1 },\n { "id": 2
|
|
|
250
250
|
dedupeNdjson('{"id":1}\n{"id":2}\n{"id":1}');
|
|
251
251
|
// { totalLines: 3, uniqueLines: 2, duplicatesRemoved: 1, output: "{\"id\":1}\n{\"id\":2}", removedLines: [3] }
|
|
252
252
|
|
|
253
|
+
// Convert NDJSON to CSV, inferring the header row from the union of keys
|
|
254
|
+
ndjsonToCsv('{"id":1,"name":"Ann"}\n{"id":2,"city":"NYC"}');
|
|
255
|
+
// 'id,name,city\n1,Ann,\n2,,NYC'
|
|
256
|
+
|
|
253
257
|
// Diff a .env file against its .env.example template
|
|
254
258
|
diffEnvExample("FOO=1\nBAR=2", "FOO=\nBAR=y\nBAZ=z");
|
|
255
259
|
// { missingInExample: [], missingInEnv: ["BAZ"], emptyValueInExample: ["FOO"], keysInBoth: 2 }
|
|
@@ -710,6 +714,11 @@ buildRobotsMetaTag({ flags: ["noindex", "nofollow"], name: "googlebot" });
|
|
|
710
714
|
// Cookie header byte-size budget: per-cookie and total sizes against RFC 6265's 4096-byte limit
|
|
711
715
|
calculateCookieSizeBudget("session=abc123; theme=dark; cart=42");
|
|
712
716
|
// { cookieCount: 3, totalBytes: 35, budgetBytes: 4096, exceedsBudget: false, cookies: [...] }
|
|
717
|
+
|
|
718
|
+
// Score pasted response headers against commonly recommended security headers
|
|
719
|
+
import { scoreSecurityHeaders } from "@utilix-tech/sdk/network";
|
|
720
|
+
scoreSecurityHeaders("Content-Security-Policy: default-src 'self'\nStrict-Transport-Security: max-age=63072000");
|
|
721
|
+
// { score: 22, grade: "F", passCount: 2, warningCount: 0, missingCount: 7, totalChecks: 9, checks: [...] }
|
|
713
722
|
```
|
|
714
723
|
|
|
715
724
|
---
|
|
@@ -910,10 +919,10 @@ analyzeString("café"); // { length: 4, codePoints: [...], ... }
|
|
|
910
919
|
|
|
911
920
|
---
|
|
912
921
|
|
|
913
|
-
### `/media`: Image Header Parsing, EXIF, PDF Metadata
|
|
922
|
+
### `/media`: Image Header Parsing, EXIF, PDF Metadata, Page Dimensions & Outlines, WAV, ID3, ICO, FLAC, Video, GIF & MIDI Metadata
|
|
914
923
|
|
|
915
924
|
```ts
|
|
916
|
-
import { readImageInfo, readExifData, readPdfMetadata, readPdfPageDimensions, readWavInfo, readId3Tags, readIcoInfo, readFlacInfo, readVideoInfo, inspectGifFrames, readMidiInfo } from "@utilix-tech/sdk/media";
|
|
925
|
+
import { readImageInfo, readExifData, readPdfMetadata, readPdfPageDimensions, readPdfOutline, readWavInfo, readId3Tags, readIcoInfo, readFlacInfo, readVideoInfo, inspectGifFrames, readMidiInfo } from "@utilix-tech/sdk/media";
|
|
917
926
|
|
|
918
927
|
// Reads format, dimensions, bit depth, and alpha channel straight from
|
|
919
928
|
// file bytes: no decoding, no canvas, no image library.
|
|
@@ -939,6 +948,12 @@ readPdfMetadata(new Uint8Array(pdfBytes));
|
|
|
939
948
|
readPdfPageDimensions(new Uint8Array(pdfBytes));
|
|
940
949
|
// { version: "1.7", pageCount: 12, pages: [{ pageNumber: 1, widthPt: 612, heightPt: 792, rotation: 0, orientation: "portrait", paperSize: "Letter" }, ...] }
|
|
941
950
|
|
|
951
|
+
// Walks a PDF's /Outlines bookmark tree (Root -> Outlines -> First/Next/
|
|
952
|
+
// First chain) to list every bookmark's title, nesting level, and link
|
|
953
|
+
// target, in document order: no PDF rendering library required.
|
|
954
|
+
readPdfOutline(new Uint8Array(pdfBytes));
|
|
955
|
+
// { version: "1.7", bookmarkCount: 3, bookmarks: [{ title: "Chapter 1", level: 0, destType: "page", target: "3 0 R" }, ...] }
|
|
956
|
+
|
|
942
957
|
// Reads sample rate, channels, bit depth, and duration from a WAV file's
|
|
943
958
|
// RIFF/fmt/data chunk headers: no audio library required.
|
|
944
959
|
const wavBytes = await fs.promises.readFile("recording.wav");
|
|
@@ -72,6 +72,7 @@ __export(network_exports, {
|
|
|
72
72
|
parseVaryHeader: () => parseVaryHeader,
|
|
73
73
|
parseXContentTypeOptionsHeader: () => parseXContentTypeOptionsHeader,
|
|
74
74
|
parseXRobotsTag: () => parseXRobotsTag,
|
|
75
|
+
scoreSecurityHeaders: () => scoreSecurityHeaders,
|
|
75
76
|
searchHeaders: () => searchHeaders,
|
|
76
77
|
searchStatusCodes: () => searchStatusCodes,
|
|
77
78
|
splitSitemap: () => splitSitemap,
|
|
@@ -3511,5 +3512,122 @@ function calculateCookieSizeBudget(cookieHeader, budgetBytes = DEFAULT_COOKIE_BU
|
|
|
3511
3512
|
exceedsBudget: totalBytes > budgetBytes
|
|
3512
3513
|
};
|
|
3513
3514
|
}
|
|
3515
|
+
function parseRawHeaderBlock(raw) {
|
|
3516
|
+
const map = /* @__PURE__ */ new Map();
|
|
3517
|
+
for (const line of raw.split(/\r?\n/)) {
|
|
3518
|
+
const trimmed = line.trim();
|
|
3519
|
+
if (!trimmed) continue;
|
|
3520
|
+
const idx = trimmed.indexOf(":");
|
|
3521
|
+
if (idx === -1) continue;
|
|
3522
|
+
const name = trimmed.slice(0, idx).trim().toLowerCase();
|
|
3523
|
+
const value = trimmed.slice(idx + 1).trim();
|
|
3524
|
+
if (!map.has(name)) map.set(name, value);
|
|
3525
|
+
}
|
|
3526
|
+
return map;
|
|
3527
|
+
}
|
|
3528
|
+
var SECURITY_HEADER_CHECKS = [
|
|
3529
|
+
{
|
|
3530
|
+
header: "Content-Security-Policy",
|
|
3531
|
+
evaluate: (v) => {
|
|
3532
|
+
if (!v) return { status: "missing", note: "Without a CSP, an injected script runs with full page privileges." };
|
|
3533
|
+
if (/unsafe-inline|unsafe-eval/i.test(v)) return { status: "warning", note: "Contains unsafe-inline or unsafe-eval, which weakens XSS protection." };
|
|
3534
|
+
return { status: "pass", note: "Present. Use the CSP Header Builder tool to validate its directives in depth." };
|
|
3535
|
+
}
|
|
3536
|
+
},
|
|
3537
|
+
{
|
|
3538
|
+
header: "Strict-Transport-Security",
|
|
3539
|
+
evaluate: (v) => {
|
|
3540
|
+
if (!v) return { status: "missing", note: "Without HSTS, a user's first visit (and any later downgrade) can be sent over plain HTTP." };
|
|
3541
|
+
const maxAgeMatch = v.match(/max-age\s*=\s*(\d+)/i);
|
|
3542
|
+
if (!maxAgeMatch) return { status: "warning", note: "Present but missing a max-age directive." };
|
|
3543
|
+
const maxAge = Number(maxAgeMatch[1]);
|
|
3544
|
+
if (maxAge < 31536e3) return { status: "warning", note: "max-age is below the recommended 1 year (31536000 seconds)." };
|
|
3545
|
+
return { status: "pass", note: "Present with a max-age of at least 1 year." };
|
|
3546
|
+
}
|
|
3547
|
+
},
|
|
3548
|
+
{
|
|
3549
|
+
header: "X-Content-Type-Options",
|
|
3550
|
+
evaluate: (v) => {
|
|
3551
|
+
if (!v) return { status: "missing", note: "Without this header, browsers may MIME-sniff a response into an unintended content type." };
|
|
3552
|
+
if (v.trim().toLowerCase() !== "nosniff") return { status: "warning", note: `"nosniff" is the only valid value; this value won't take effect.` };
|
|
3553
|
+
return { status: "pass", note: "Set to the only valid value, nosniff." };
|
|
3554
|
+
}
|
|
3555
|
+
},
|
|
3556
|
+
{
|
|
3557
|
+
header: "X-Frame-Options",
|
|
3558
|
+
evaluate: (v) => {
|
|
3559
|
+
if (!v) return { status: "missing", note: "Without this (or a CSP frame-ancestors directive), the page can be framed by another site for clickjacking." };
|
|
3560
|
+
const upper = v.trim().toUpperCase();
|
|
3561
|
+
if (upper === "DENY" || upper === "SAMEORIGIN") return { status: "pass", note: `Framing restricted (${upper}).` };
|
|
3562
|
+
if (upper.startsWith("ALLOW-FROM")) return { status: "warning", note: "ALLOW-FROM is deprecated and ignored by most modern browsers." };
|
|
3563
|
+
return { status: "warning", note: "Unrecognized value." };
|
|
3564
|
+
}
|
|
3565
|
+
},
|
|
3566
|
+
{
|
|
3567
|
+
header: "Referrer-Policy",
|
|
3568
|
+
evaluate: (v) => {
|
|
3569
|
+
if (!v) return { status: "missing", note: "Without this header, the browser's default referrer behavior applies, which can leak full URLs to third parties." };
|
|
3570
|
+
if (v.trim().toLowerCase() === "unsafe-url") return { status: "warning", note: "unsafe-url leaks the full URL, including path and query string, to every destination." };
|
|
3571
|
+
return { status: "pass", note: "Present." };
|
|
3572
|
+
}
|
|
3573
|
+
},
|
|
3574
|
+
{
|
|
3575
|
+
header: "Permissions-Policy",
|
|
3576
|
+
evaluate: (v) => {
|
|
3577
|
+
if (!v) return { status: "missing", note: "Without this header, embedded content can use powerful browser features (camera, geolocation, etc.) unless restricted another way." };
|
|
3578
|
+
return { status: "pass", note: "Present." };
|
|
3579
|
+
}
|
|
3580
|
+
},
|
|
3581
|
+
{
|
|
3582
|
+
header: "Cross-Origin-Opener-Policy",
|
|
3583
|
+
evaluate: (v) => {
|
|
3584
|
+
if (!v) return { status: "missing", note: "Without COOP, this page can be put in the same browsing context group as a malicious opener window." };
|
|
3585
|
+
const lower = v.trim().toLowerCase();
|
|
3586
|
+
if (lower === "same-origin") return { status: "pass", note: "Set to same-origin, the strongest isolation value." };
|
|
3587
|
+
return { status: "warning", note: `Set to "${v.trim()}", which is weaker than same-origin.` };
|
|
3588
|
+
}
|
|
3589
|
+
},
|
|
3590
|
+
{
|
|
3591
|
+
header: "Cross-Origin-Embedder-Policy",
|
|
3592
|
+
evaluate: (v) => {
|
|
3593
|
+
if (!v) return { status: "missing", note: "Required alongside COOP for cross-origin isolation (e.g. to use SharedArrayBuffer)." };
|
|
3594
|
+
const lower = v.trim().toLowerCase();
|
|
3595
|
+
if (lower === "require-corp" || lower === "credentialless") return { status: "pass", note: `Set to ${lower}.` };
|
|
3596
|
+
return { status: "warning", note: `Unrecognized value "${v.trim()}".` };
|
|
3597
|
+
}
|
|
3598
|
+
},
|
|
3599
|
+
{
|
|
3600
|
+
header: "Cross-Origin-Resource-Policy",
|
|
3601
|
+
evaluate: (v) => {
|
|
3602
|
+
if (!v) return { status: "missing", note: "Without CORP, this resource can be loaded cross-origin by any site that knows its URL." };
|
|
3603
|
+
const lower = v.trim().toLowerCase();
|
|
3604
|
+
if (lower === "same-origin" || lower === "same-site") return { status: "pass", note: `Set to ${lower}.` };
|
|
3605
|
+
if (lower === "cross-origin") return { status: "warning", note: "Set to cross-origin, which allows any site to load this resource." };
|
|
3606
|
+
return { status: "warning", note: `Unrecognized value "${v.trim()}".` };
|
|
3607
|
+
}
|
|
3608
|
+
}
|
|
3609
|
+
];
|
|
3610
|
+
function scoreSecurityHeaders(rawHeaders) {
|
|
3611
|
+
if (typeof rawHeaders !== "string" || !rawHeaders.trim()) {
|
|
3612
|
+
return { error: 'Paste one or more response headers, one per line in "Name: value" form' };
|
|
3613
|
+
}
|
|
3614
|
+
const headerMap = parseRawHeaderBlock(rawHeaders);
|
|
3615
|
+
if (headerMap.size === 0) {
|
|
3616
|
+
return { error: 'Could not parse any "Name: value" header lines from the input' };
|
|
3617
|
+
}
|
|
3618
|
+
const checks = SECURITY_HEADER_CHECKS.map((def) => {
|
|
3619
|
+
const value = headerMap.get(def.header.toLowerCase()) ?? null;
|
|
3620
|
+
const { status, note } = def.evaluate(value);
|
|
3621
|
+
return { header: def.header, status, value, note };
|
|
3622
|
+
});
|
|
3623
|
+
const passCount = checks.filter((c) => c.status === "pass").length;
|
|
3624
|
+
const warningCount = checks.filter((c) => c.status === "warning").length;
|
|
3625
|
+
const missingCount = checks.filter((c) => c.status === "missing").length;
|
|
3626
|
+
const totalChecks = checks.length;
|
|
3627
|
+
const points = passCount + warningCount * 0.5;
|
|
3628
|
+
const score = Math.round(points / totalChecks * 100);
|
|
3629
|
+
const grade = score >= 90 ? "A" : score >= 75 ? "B" : score >= 60 ? "C" : score >= 40 ? "D" : "F";
|
|
3630
|
+
return { checks, score, grade, passCount, warningCount, missingCount, totalChecks };
|
|
3631
|
+
}
|
|
3514
3632
|
|
|
3515
|
-
export { CLIENT_HINTS, DNS_RECORD_TYPES, HTTP_HEADERS, LINK_REL_VALUES, PERMISSIONS_POLICY_FEATURES, REFERRER_POLICY_VALUES, STATUS_CODES, X_CONTENT_TYPE_OPTIONS_HEADER, analyzeEmailHeaders, assessContentTypeRisk, buildAcceptLanguage, buildCacheControl, buildClientHints, buildContentDisposition, buildDnsQueryUrl, buildGeoUrl, buildHsts, buildLinkHeader, buildMapUrl, buildPermissionsPolicy, buildPreferHeader, buildPriorityHeader, buildRangeHeader, buildReferrerPolicy, buildRetryAfterHeader, buildRobotsMetaTag, buildVaryHeader, buildXContentTypeOptionsHeader, buildXRobotsTag, calculateCookieSizeBudget, checkSetCookieHeader, countryCodeToFlag, extractMultipartBoundary, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, listCloseCodes, listOpcodes, lookupCloseCode, lookupOpcode, network_exports, parseAcceptLanguage, parseClientHintHeaders, parseContentDisposition, parseContentRangeHeader, parseDnsResponse, parseGeoResponse, parseHar, parseHsts, parseIpv6Address, parseMultipartFormData, parsePermissionsPolicy, parsePreferHeader, parsePriorityHeader, parseRetryAfterHeader, parseRobotsMetaTag, parseUserAgent, parseVaryHeader, parseXContentTypeOptionsHeader, parseXRobotsTag, searchHeaders, searchStatusCodes, splitSitemap, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue, validateManifest, validateRobotsTxt, validateSitemap };
|
|
3633
|
+
export { CLIENT_HINTS, DNS_RECORD_TYPES, HTTP_HEADERS, LINK_REL_VALUES, PERMISSIONS_POLICY_FEATURES, REFERRER_POLICY_VALUES, STATUS_CODES, X_CONTENT_TYPE_OPTIONS_HEADER, analyzeEmailHeaders, assessContentTypeRisk, buildAcceptLanguage, buildCacheControl, buildClientHints, buildContentDisposition, buildDnsQueryUrl, buildGeoUrl, buildHsts, buildLinkHeader, buildMapUrl, buildPermissionsPolicy, buildPreferHeader, buildPriorityHeader, buildRangeHeader, buildReferrerPolicy, buildRetryAfterHeader, buildRobotsMetaTag, buildVaryHeader, buildXContentTypeOptionsHeader, buildXRobotsTag, calculateCookieSizeBudget, checkSetCookieHeader, countryCodeToFlag, extractMultipartBoundary, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, listCloseCodes, listOpcodes, lookupCloseCode, lookupOpcode, network_exports, parseAcceptLanguage, parseClientHintHeaders, parseContentDisposition, parseContentRangeHeader, parseDnsResponse, parseGeoResponse, parseHar, parseHsts, parseIpv6Address, parseMultipartFormData, parsePermissionsPolicy, parsePreferHeader, parsePriorityHeader, parseRetryAfterHeader, parseRobotsMetaTag, parseUserAgent, parseVaryHeader, parseXContentTypeOptionsHeader, parseXRobotsTag, scoreSecurityHeaders, searchHeaders, searchStatusCodes, splitSitemap, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue, validateManifest, validateRobotsTxt, validateSitemap };
|
|
@@ -37,6 +37,7 @@ __export(data_exports, {
|
|
|
37
37
|
minifyNdjson: () => minifyNdjson,
|
|
38
38
|
minifyToml: () => minifyToml,
|
|
39
39
|
minifyXml: () => minifyXml,
|
|
40
|
+
ndjsonToCsv: () => ndjsonToCsv,
|
|
40
41
|
ndjsonToJsonArray: () => ndjsonToJsonArray,
|
|
41
42
|
parseCsv: () => parseCsv,
|
|
42
43
|
parseEnv: () => parseEnv,
|
|
@@ -1174,6 +1175,37 @@ function jsonArrayToNdjson(input) {
|
|
|
1174
1175
|
if (!Array.isArray(parsed)) return { error: "Input must be a JSON array" };
|
|
1175
1176
|
return parsed.map((item) => JSON.stringify(item)).join("\n");
|
|
1176
1177
|
}
|
|
1178
|
+
function _stringifyCsvValue(value) {
|
|
1179
|
+
if (value === void 0 || value === null) return "";
|
|
1180
|
+
if (typeof value === "string") return value;
|
|
1181
|
+
if (typeof value === "object") return JSON.stringify(value);
|
|
1182
|
+
return String(value);
|
|
1183
|
+
}
|
|
1184
|
+
function ndjsonToCsv(input) {
|
|
1185
|
+
const result = validateNdjson(input);
|
|
1186
|
+
if (!result.valid) return { error: _firstNdjsonError(result) };
|
|
1187
|
+
if (result.lines.length === 0) return { error: "No records found" };
|
|
1188
|
+
const records = result.lines.map((l) => JSON.parse(l.raw));
|
|
1189
|
+
for (const record of records) {
|
|
1190
|
+
if (typeof record !== "object" || record === null || Array.isArray(record)) {
|
|
1191
|
+
return { error: "Every line must be a flat JSON object to convert to CSV" };
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
const headers = [];
|
|
1195
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1196
|
+
for (const record of records) {
|
|
1197
|
+
for (const key of Object.keys(record)) {
|
|
1198
|
+
if (!seen.has(key)) {
|
|
1199
|
+
seen.add(key);
|
|
1200
|
+
headers.push(key);
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
const rows = records.map(
|
|
1205
|
+
(record) => headers.map((h) => _stringifyCsvValue(record[h]))
|
|
1206
|
+
);
|
|
1207
|
+
return toCsvString(headers, rows);
|
|
1208
|
+
}
|
|
1177
1209
|
function dedupeNdjson(input, keyField) {
|
|
1178
1210
|
const validated = validateNdjson(input);
|
|
1179
1211
|
if (!validated.valid) return { error: _firstNdjsonError(validated) };
|
|
@@ -1944,4 +1976,4 @@ function alignMarkdownTables(markdown) {
|
|
|
1944
1976
|
return { output: outputLines.join("\n"), tables, warnings };
|
|
1945
1977
|
}
|
|
1946
1978
|
|
|
1947
|
-
export { alignMarkdownTables, analyzeCaptionSpeed, calculateMarkdownTaskListProgress, convertSubtitles, csvToJson, csvToSqlInsert, data_exports, dedupeNdjson, detectDelimiter, detectSubtitleFormat, diffEnvExample, envToExport, envToJson, findCsvDuplicateRows, formatNdjson, formatSubtitleTimestamp, formatToml, formatXml, generateMarkdownToc, getSection, getSectionNames, getTomlStats, getXmlStats, getYamlStats, inferCsvColumnTypes, iniToJson, jsonArrayToNdjson, jsonToIni, jsonToToml, jsonToXml, minifyNdjson, minifyToml, minifyXml, ndjsonToJsonArray, parseCsv, parseEnv, parseFrontMatter, parseIni, parseSubtitleTimestamp, parseSubtitles, parseXmlToObject, resolveYamlAnchors, serializeSubtitles, shiftSubtitles, stringifyIni, toCsvString, tomlToJson, validateEnvKey, validateIni, validateNdjson, validateToml, validateXml, validateYaml, xmlToJson };
|
|
1979
|
+
export { alignMarkdownTables, analyzeCaptionSpeed, calculateMarkdownTaskListProgress, convertSubtitles, csvToJson, csvToSqlInsert, data_exports, dedupeNdjson, detectDelimiter, detectSubtitleFormat, diffEnvExample, envToExport, envToJson, findCsvDuplicateRows, formatNdjson, formatSubtitleTimestamp, formatToml, formatXml, generateMarkdownToc, getSection, getSectionNames, getTomlStats, getXmlStats, getYamlStats, inferCsvColumnTypes, iniToJson, jsonArrayToNdjson, jsonToIni, jsonToToml, jsonToXml, minifyNdjson, minifyToml, minifyXml, ndjsonToCsv, ndjsonToJsonArray, parseCsv, parseEnv, parseFrontMatter, parseIni, parseSubtitleTimestamp, parseSubtitles, parseXmlToObject, resolveYamlAnchors, serializeSubtitles, shiftSubtitles, stringifyIni, toCsvString, tomlToJson, validateEnvKey, validateIni, validateNdjson, validateToml, validateXml, validateYaml, xmlToJson };
|
|
@@ -11,6 +11,7 @@ __export(media_exports, {
|
|
|
11
11
|
readImageInfo: () => readImageInfo,
|
|
12
12
|
readMidiInfo: () => readMidiInfo,
|
|
13
13
|
readPdfMetadata: () => readPdfMetadata,
|
|
14
|
+
readPdfOutline: () => readPdfOutline,
|
|
14
15
|
readPdfPageDimensions: () => readPdfPageDimensions,
|
|
15
16
|
readVideoInfo: () => readVideoInfo,
|
|
16
17
|
readWavInfo: () => readWavInfo
|
|
@@ -581,6 +582,74 @@ function readPdfPageDimensions(bytes) {
|
|
|
581
582
|
if (out.length === 0) return { error: "Could not locate any page objects in this PDF" };
|
|
582
583
|
return { version, pageCount: out.length, pages: out };
|
|
583
584
|
}
|
|
585
|
+
function parsePdfOutlineDest(dict) {
|
|
586
|
+
const directRef = dict.match(/\/Dest\s*\[\s*(\d+)\s+(\d+)\s+R/);
|
|
587
|
+
if (directRef) return { destType: "page", target: `${directRef[1]} ${directRef[2]} R` };
|
|
588
|
+
const directName = dict.match(/\/Dest\s*\/([^\s/()<>[\]]+)/);
|
|
589
|
+
if (directName) return { destType: "named", target: directName[1] };
|
|
590
|
+
const directString = dict.match(/\/Dest\s*\(((?:\\.|[^\\()])*)\)/);
|
|
591
|
+
if (directString) return { destType: "named", target: decodePdfString(directString[1], false) };
|
|
592
|
+
const actionUri = dict.match(/\/S\s*\/URI[\s\S]*?\/URI\s*\(((?:\\.|[^\\()])*)\)/);
|
|
593
|
+
if (actionUri) return { destType: "uri", target: decodePdfString(actionUri[1], false) };
|
|
594
|
+
const actionGotoRef = dict.match(/\/S\s*\/GoTo[\s\S]*?\/D\s*\[\s*(\d+)\s+(\d+)\s+R/);
|
|
595
|
+
if (actionGotoRef) return { destType: "page", target: `${actionGotoRef[1]} ${actionGotoRef[2]} R` };
|
|
596
|
+
const actionGotoName = dict.match(/\/S\s*\/GoTo[\s\S]*?\/D\s*\/([^\s/()<>[\]]+)/);
|
|
597
|
+
if (actionGotoName) return { destType: "named", target: actionGotoName[1] };
|
|
598
|
+
return { destType: "none", target: null };
|
|
599
|
+
}
|
|
600
|
+
function walkPdfOutlineChain(objMap, startRef, level, visited, out) {
|
|
601
|
+
let ref = startRef;
|
|
602
|
+
while (ref) {
|
|
603
|
+
if (visited.has(ref)) break;
|
|
604
|
+
visited.add(ref);
|
|
605
|
+
const body = objMap.get(ref);
|
|
606
|
+
if (!body) break;
|
|
607
|
+
const titleRaw = extractDictField(body, "Title");
|
|
608
|
+
const { destType, target } = parsePdfOutlineDest(body);
|
|
609
|
+
out.push({ title: titleRaw ?? "(untitled)", level, destType, target });
|
|
610
|
+
const firstMatch = body.match(/\/First\s+(\d+)\s+(\d+)\s+R/);
|
|
611
|
+
if (firstMatch) walkPdfOutlineChain(objMap, `${firstMatch[1]} ${firstMatch[2]}`, level + 1, visited, out);
|
|
612
|
+
const nextMatch = body.match(/\/Next\s+(\d+)\s+(\d+)\s+R/);
|
|
613
|
+
ref = nextMatch ? `${nextMatch[1]} ${nextMatch[2]}` : null;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
function readPdfOutline(bytes) {
|
|
617
|
+
if (bytes.length < 8) return { error: "File too small to be a PDF" };
|
|
618
|
+
const header = bytesToLatin1(bytes.subarray(0, 16));
|
|
619
|
+
const versionMatch = header.match(/%PDF-(\d\.\d)/);
|
|
620
|
+
if (!versionMatch) return { error: "Not a valid PDF file (missing %PDF header)" };
|
|
621
|
+
const version = versionMatch[1];
|
|
622
|
+
const text = bytesToLatin1(bytes);
|
|
623
|
+
const objBlocks = [...text.matchAll(/(\d+)\s+(\d+)\s+obj([\s\S]*?)endobj/g)];
|
|
624
|
+
const objMap = /* @__PURE__ */ new Map();
|
|
625
|
+
for (const b of objBlocks) objMap.set(`${b[1]} ${b[2]}`, b[3]);
|
|
626
|
+
let outlinesBody = null;
|
|
627
|
+
const trailerMatches = [...text.matchAll(/trailer\s*<<([\s\S]*?)>>/g)];
|
|
628
|
+
if (trailerMatches.length > 0) {
|
|
629
|
+
const trailer = trailerMatches[trailerMatches.length - 1][1];
|
|
630
|
+
const rootRef = trailer.match(/\/Root\s+(\d+)\s+(\d+)\s+R/);
|
|
631
|
+
if (rootRef) {
|
|
632
|
+
const catalogBody = objMap.get(`${rootRef[1]} ${rootRef[2]}`);
|
|
633
|
+
const outlinesRef = catalogBody?.match(/\/Outlines\s+(\d+)\s+(\d+)\s+R/);
|
|
634
|
+
if (outlinesRef) outlinesBody = objMap.get(`${outlinesRef[1]} ${outlinesRef[2]}`) ?? null;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
if (!outlinesBody) {
|
|
638
|
+
for (const b of objBlocks) {
|
|
639
|
+
if (/\/Type\s*\/Outlines\b/.test(b[3])) {
|
|
640
|
+
outlinesBody = b[3];
|
|
641
|
+
break;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
if (!outlinesBody) return { error: "No /Outlines bookmark tree found in this PDF" };
|
|
646
|
+
const out = [];
|
|
647
|
+
const firstMatch = outlinesBody.match(/\/First\s+(\d+)\s+(\d+)\s+R/);
|
|
648
|
+
if (firstMatch) {
|
|
649
|
+
walkPdfOutlineChain(objMap, `${firstMatch[1]} ${firstMatch[2]}`, 0, /* @__PURE__ */ new Set(), out);
|
|
650
|
+
}
|
|
651
|
+
return { version, bookmarkCount: out.length, bookmarks: out };
|
|
652
|
+
}
|
|
584
653
|
var AUDIO_FORMAT_LABELS = {
|
|
585
654
|
1: "PCM",
|
|
586
655
|
3: "IEEE float",
|
|
@@ -1438,4 +1507,4 @@ function readMidiInfo(bytes) {
|
|
|
1438
1507
|
};
|
|
1439
1508
|
}
|
|
1440
1509
|
|
|
1441
|
-
export { inspectGifFrames, media_exports, readExifData, readFlacInfo, readIcoInfo, readId3Tags, readImageInfo, readMidiInfo, readPdfMetadata, readPdfPageDimensions, readVideoInfo, readWavInfo };
|
|
1510
|
+
export { inspectGifFrames, media_exports, readExifData, readFlacInfo, readIcoInfo, readId3Tags, readImageInfo, readMidiInfo, readPdfMetadata, readPdfOutline, readPdfPageDimensions, readVideoInfo, readWavInfo };
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* - env-diff-checker: diffEnvExample
|
|
14
14
|
* - ndjson-formatter: validateNdjson, minifyNdjson, formatNdjson, ndjsonToJsonArray, jsonArrayToNdjson
|
|
15
15
|
* - ndjson-dedup: dedupeNdjson
|
|
16
|
+
* - ndjson-to-csv-converter: ndjsonToCsv
|
|
16
17
|
* - subtitle-converter: parseSubtitleTimestamp, formatSubtitleTimestamp, detectSubtitleFormat, parseSubtitles, serializeSubtitles, convertSubtitles, shiftSubtitles
|
|
17
18
|
* - markdown-front-matter-parser: parseFrontMatter
|
|
18
19
|
* - markdown-toc-generator: generateMarkdownToc
|
|
@@ -218,6 +219,15 @@ declare function ndjsonToJsonArray(input: string): string | {
|
|
|
218
219
|
declare function jsonArrayToNdjson(input: string): string | {
|
|
219
220
|
error: string;
|
|
220
221
|
};
|
|
222
|
+
/**
|
|
223
|
+
* Convert NDJSON (one flat JSON object per line) into CSV, inferring the
|
|
224
|
+
* header row from the union of keys across every line in the order each
|
|
225
|
+
* key is first seen. A value that is itself an object or array is embedded
|
|
226
|
+
* as a JSON string rather than expanded into further columns.
|
|
227
|
+
*/
|
|
228
|
+
declare function ndjsonToCsv(input: string): string | {
|
|
229
|
+
error: string;
|
|
230
|
+
};
|
|
221
231
|
interface NdjsonDedupeResult {
|
|
222
232
|
totalLines: number;
|
|
223
233
|
uniqueLines: number;
|
|
@@ -610,6 +620,7 @@ declare const data_jsonToXml: typeof jsonToXml;
|
|
|
610
620
|
declare const data_minifyNdjson: typeof minifyNdjson;
|
|
611
621
|
declare const data_minifyToml: typeof minifyToml;
|
|
612
622
|
declare const data_minifyXml: typeof minifyXml;
|
|
623
|
+
declare const data_ndjsonToCsv: typeof ndjsonToCsv;
|
|
613
624
|
declare const data_ndjsonToJsonArray: typeof ndjsonToJsonArray;
|
|
614
625
|
declare const data_parseCsv: typeof parseCsv;
|
|
615
626
|
declare const data_parseEnv: typeof parseEnv;
|
|
@@ -632,7 +643,7 @@ declare const data_validateXml: typeof validateXml;
|
|
|
632
643
|
declare const data_validateYaml: typeof validateYaml;
|
|
633
644
|
declare const data_xmlToJson: typeof xmlToJson;
|
|
634
645
|
declare namespace data {
|
|
635
|
-
export { type data_CaptionSpeedCue as CaptionSpeedCue, type data_CaptionSpeedResult as CaptionSpeedResult, type data_ConvertedSubtitles as ConvertedSubtitles, type data_CsvColumnType as CsvColumnType, type data_CsvColumnTypeInfo as CsvColumnTypeInfo, type data_CsvColumnTypeOptions as CsvColumnTypeOptions, type data_CsvColumnTypeResult as CsvColumnTypeResult, type data_CsvDuplicateGroup as CsvDuplicateGroup, type data_CsvDuplicateOptions as CsvDuplicateOptions, type data_CsvDuplicateResult as CsvDuplicateResult, type data_CsvParseResult as CsvParseResult, type data_CsvToSqlOptions as CsvToSqlOptions, type data_CsvToSqlResult as CsvToSqlResult, type data_EnvDiffError as EnvDiffError, type data_EnvDiffResult as EnvDiffResult, type data_EnvEntry as EnvEntry, type data_EnvParseResult as EnvParseResult, type data_FrontMatterError as FrontMatterError, type data_FrontMatterResult as FrontMatterResult, type data_IniSection as IniSection, type data_MarkdownTableAlignResult as MarkdownTableAlignResult, type data_MarkdownTableColumnAlignment as MarkdownTableColumnAlignment, type data_MarkdownTableInfo as MarkdownTableInfo, type data_MarkdownTaskListItem as MarkdownTaskListItem, type data_MarkdownTaskListProgressResult as MarkdownTaskListProgressResult, type data_MarkdownTaskListSectionSummary as MarkdownTaskListSectionSummary, type data_MarkdownTocEntry as MarkdownTocEntry, type data_MarkdownTocOptions as MarkdownTocOptions, type data_MarkdownTocResult as MarkdownTocResult, type data_NdjsonDedupeResult as NdjsonDedupeResult, type data_NdjsonLineResult as NdjsonLineResult, type data_NdjsonValidateResult as NdjsonValidateResult, type data_ParseOptions as ParseOptions, type data_ParsedIni as ParsedIni, type data_ParsedSubtitles as ParsedSubtitles, type data_SubtitleCue as SubtitleCue, type data_SubtitleFormat as SubtitleFormat, type data_TomlFormatResult as TomlFormatResult, type data_ValidationResult as ValidationResult, type data_XmlFormatResult as XmlFormatResult, type data_XmlToJsonOptions as XmlToJsonOptions, type data_YamlAnchorInfo as YamlAnchorInfo, type data_YamlAnchorResolveError as YamlAnchorResolveError, type data_YamlAnchorResolveResult as YamlAnchorResolveResult, data_alignMarkdownTables as alignMarkdownTables, data_analyzeCaptionSpeed as analyzeCaptionSpeed, data_calculateMarkdownTaskListProgress as calculateMarkdownTaskListProgress, data_convertSubtitles as convertSubtitles, data_csvToJson as csvToJson, data_csvToSqlInsert as csvToSqlInsert, data_dedupeNdjson as dedupeNdjson, data_detectDelimiter as detectDelimiter, data_detectSubtitleFormat as detectSubtitleFormat, data_diffEnvExample as diffEnvExample, data_envToExport as envToExport, data_envToJson as envToJson, data_findCsvDuplicateRows as findCsvDuplicateRows, data_formatNdjson as formatNdjson, data_formatSubtitleTimestamp as formatSubtitleTimestamp, data_formatToml as formatToml, data_formatXml as formatXml, data_generateMarkdownToc as generateMarkdownToc, data_getSection as getSection, data_getSectionNames as getSectionNames, data_getTomlStats as getTomlStats, data_getXmlStats as getXmlStats, data_getYamlStats as getYamlStats, data_inferCsvColumnTypes as inferCsvColumnTypes, data_iniToJson as iniToJson, data_jsonArrayToNdjson as jsonArrayToNdjson, data_jsonToIni as jsonToIni, data_jsonToToml as jsonToToml, data_jsonToXml as jsonToXml, data_minifyNdjson as minifyNdjson, data_minifyToml as minifyToml, data_minifyXml as minifyXml, data_ndjsonToJsonArray as ndjsonToJsonArray, data_parseCsv as parseCsv, data_parseEnv as parseEnv, data_parseFrontMatter as parseFrontMatter, data_parseIni as parseIni, data_parseSubtitleTimestamp as parseSubtitleTimestamp, data_parseSubtitles as parseSubtitles, data_parseXmlToObject as parseXmlToObject, data_resolveYamlAnchors as resolveYamlAnchors, data_serializeSubtitles as serializeSubtitles, data_shiftSubtitles as shiftSubtitles, data_stringifyIni as stringifyIni, data_toCsvString as toCsvString, data_tomlToJson as tomlToJson, data_validateEnvKey as validateEnvKey, data_validateIni as validateIni, data_validateNdjson as validateNdjson, data_validateToml as validateToml, data_validateXml as validateXml, data_validateYaml as validateYaml, data_xmlToJson as xmlToJson };
|
|
646
|
+
export { type data_CaptionSpeedCue as CaptionSpeedCue, type data_CaptionSpeedResult as CaptionSpeedResult, type data_ConvertedSubtitles as ConvertedSubtitles, type data_CsvColumnType as CsvColumnType, type data_CsvColumnTypeInfo as CsvColumnTypeInfo, type data_CsvColumnTypeOptions as CsvColumnTypeOptions, type data_CsvColumnTypeResult as CsvColumnTypeResult, type data_CsvDuplicateGroup as CsvDuplicateGroup, type data_CsvDuplicateOptions as CsvDuplicateOptions, type data_CsvDuplicateResult as CsvDuplicateResult, type data_CsvParseResult as CsvParseResult, type data_CsvToSqlOptions as CsvToSqlOptions, type data_CsvToSqlResult as CsvToSqlResult, type data_EnvDiffError as EnvDiffError, type data_EnvDiffResult as EnvDiffResult, type data_EnvEntry as EnvEntry, type data_EnvParseResult as EnvParseResult, type data_FrontMatterError as FrontMatterError, type data_FrontMatterResult as FrontMatterResult, type data_IniSection as IniSection, type data_MarkdownTableAlignResult as MarkdownTableAlignResult, type data_MarkdownTableColumnAlignment as MarkdownTableColumnAlignment, type data_MarkdownTableInfo as MarkdownTableInfo, type data_MarkdownTaskListItem as MarkdownTaskListItem, type data_MarkdownTaskListProgressResult as MarkdownTaskListProgressResult, type data_MarkdownTaskListSectionSummary as MarkdownTaskListSectionSummary, type data_MarkdownTocEntry as MarkdownTocEntry, type data_MarkdownTocOptions as MarkdownTocOptions, type data_MarkdownTocResult as MarkdownTocResult, type data_NdjsonDedupeResult as NdjsonDedupeResult, type data_NdjsonLineResult as NdjsonLineResult, type data_NdjsonValidateResult as NdjsonValidateResult, type data_ParseOptions as ParseOptions, type data_ParsedIni as ParsedIni, type data_ParsedSubtitles as ParsedSubtitles, type data_SubtitleCue as SubtitleCue, type data_SubtitleFormat as SubtitleFormat, type data_TomlFormatResult as TomlFormatResult, type data_ValidationResult as ValidationResult, type data_XmlFormatResult as XmlFormatResult, type data_XmlToJsonOptions as XmlToJsonOptions, type data_YamlAnchorInfo as YamlAnchorInfo, type data_YamlAnchorResolveError as YamlAnchorResolveError, type data_YamlAnchorResolveResult as YamlAnchorResolveResult, data_alignMarkdownTables as alignMarkdownTables, data_analyzeCaptionSpeed as analyzeCaptionSpeed, data_calculateMarkdownTaskListProgress as calculateMarkdownTaskListProgress, data_convertSubtitles as convertSubtitles, data_csvToJson as csvToJson, data_csvToSqlInsert as csvToSqlInsert, data_dedupeNdjson as dedupeNdjson, data_detectDelimiter as detectDelimiter, data_detectSubtitleFormat as detectSubtitleFormat, data_diffEnvExample as diffEnvExample, data_envToExport as envToExport, data_envToJson as envToJson, data_findCsvDuplicateRows as findCsvDuplicateRows, data_formatNdjson as formatNdjson, data_formatSubtitleTimestamp as formatSubtitleTimestamp, data_formatToml as formatToml, data_formatXml as formatXml, data_generateMarkdownToc as generateMarkdownToc, data_getSection as getSection, data_getSectionNames as getSectionNames, data_getTomlStats as getTomlStats, data_getXmlStats as getXmlStats, data_getYamlStats as getYamlStats, data_inferCsvColumnTypes as inferCsvColumnTypes, data_iniToJson as iniToJson, data_jsonArrayToNdjson as jsonArrayToNdjson, data_jsonToIni as jsonToIni, data_jsonToToml as jsonToToml, data_jsonToXml as jsonToXml, data_minifyNdjson as minifyNdjson, data_minifyToml as minifyToml, data_minifyXml as minifyXml, data_ndjsonToCsv as ndjsonToCsv, data_ndjsonToJsonArray as ndjsonToJsonArray, data_parseCsv as parseCsv, data_parseEnv as parseEnv, data_parseFrontMatter as parseFrontMatter, data_parseIni as parseIni, data_parseSubtitleTimestamp as parseSubtitleTimestamp, data_parseSubtitles as parseSubtitles, data_parseXmlToObject as parseXmlToObject, data_resolveYamlAnchors as resolveYamlAnchors, data_serializeSubtitles as serializeSubtitles, data_shiftSubtitles as shiftSubtitles, data_stringifyIni as stringifyIni, data_toCsvString as toCsvString, data_tomlToJson as tomlToJson, data_validateEnvKey as validateEnvKey, data_validateIni as validateIni, data_validateNdjson as validateNdjson, data_validateToml as validateToml, data_validateXml as validateXml, data_validateYaml as validateYaml, data_xmlToJson as xmlToJson };
|
|
636
647
|
}
|
|
637
648
|
|
|
638
|
-
export { detectSubtitleFormat as $, type NdjsonValidateResult as A, type ParsedIni as B, type CaptionSpeedCue as C, type ParsedSubtitles as D, type EnvDiffError as E, type FrontMatterError as F, type SubtitleFormat as G, type XmlToJsonOptions as H, type IniSection as I, type YamlAnchorResolveError as J, type YamlAnchorResolveResult as K, alignMarkdownTables as L, type MarkdownTableAlignResult as M, type NdjsonDedupeResult as N, analyzeCaptionSpeed as O, type ParseOptions as P, calculateMarkdownTaskListProgress as Q, convertSubtitles as R, type SubtitleCue as S, type TomlFormatResult as T, csvToJson as U, type ValidationResult as V, csvToSqlInsert as W, type XmlFormatResult as X, type YamlAnchorInfo as Y, dedupeNdjson as Z, detectDelimiter as _, type CaptionSpeedResult as a, diffEnvExample as a0, envToExport as a1, envToJson as a2, findCsvDuplicateRows as a3, formatNdjson as a4, formatSubtitleTimestamp as a5, formatToml as a6, formatXml as a7, generateMarkdownToc as a8, getSection as a9,
|
|
649
|
+
export { detectSubtitleFormat as $, type NdjsonValidateResult as A, type ParsedIni as B, type CaptionSpeedCue as C, type ParsedSubtitles as D, type EnvDiffError as E, type FrontMatterError as F, type SubtitleFormat as G, type XmlToJsonOptions as H, type IniSection as I, type YamlAnchorResolveError as J, type YamlAnchorResolveResult as K, alignMarkdownTables as L, type MarkdownTableAlignResult as M, type NdjsonDedupeResult as N, analyzeCaptionSpeed as O, type ParseOptions as P, calculateMarkdownTaskListProgress as Q, convertSubtitles as R, type SubtitleCue as S, type TomlFormatResult as T, csvToJson as U, type ValidationResult as V, csvToSqlInsert as W, type XmlFormatResult as X, type YamlAnchorInfo as Y, dedupeNdjson as Z, detectDelimiter as _, type CaptionSpeedResult as a, diffEnvExample as a0, envToExport as a1, envToJson as a2, findCsvDuplicateRows as a3, formatNdjson as a4, formatSubtitleTimestamp as a5, formatToml as a6, formatXml as a7, generateMarkdownToc as a8, getSection as a9, toCsvString as aA, tomlToJson as aB, validateEnvKey as aC, validateIni as aD, validateNdjson as aE, validateToml as aF, validateXml as aG, validateYaml as aH, xmlToJson as aI, getSectionNames as aa, getTomlStats as ab, getXmlStats as ac, getYamlStats as ad, inferCsvColumnTypes as ae, iniToJson as af, jsonArrayToNdjson as ag, jsonToIni as ah, jsonToToml as ai, jsonToXml as aj, minifyNdjson as ak, minifyToml as al, minifyXml as am, ndjsonToCsv as an, ndjsonToJsonArray as ao, parseCsv as ap, parseEnv as aq, parseFrontMatter as ar, parseIni as as, parseSubtitleTimestamp as at, parseSubtitles as au, parseXmlToObject as av, resolveYamlAnchors as aw, serializeSubtitles as ax, shiftSubtitles as ay, stringifyIni as az, type ConvertedSubtitles as b, type CsvColumnType as c, data as d, type CsvColumnTypeInfo as e, type CsvColumnTypeOptions as f, type CsvColumnTypeResult as g, type CsvDuplicateGroup as h, type CsvDuplicateOptions as i, type CsvDuplicateResult as j, type CsvParseResult as k, type CsvToSqlOptions as l, type CsvToSqlResult as m, type EnvDiffResult as n, type EnvEntry as o, type EnvParseResult as p, type FrontMatterResult as q, type MarkdownTableColumnAlignment as r, type MarkdownTableInfo as s, type MarkdownTaskListItem as t, type MarkdownTaskListProgressResult as u, type MarkdownTaskListSectionSummary as v, type MarkdownTocEntry as w, type MarkdownTocOptions as x, type MarkdownTocResult as y, type NdjsonLineResult as z };
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* - env-diff-checker: diffEnvExample
|
|
14
14
|
* - ndjson-formatter: validateNdjson, minifyNdjson, formatNdjson, ndjsonToJsonArray, jsonArrayToNdjson
|
|
15
15
|
* - ndjson-dedup: dedupeNdjson
|
|
16
|
+
* - ndjson-to-csv-converter: ndjsonToCsv
|
|
16
17
|
* - subtitle-converter: parseSubtitleTimestamp, formatSubtitleTimestamp, detectSubtitleFormat, parseSubtitles, serializeSubtitles, convertSubtitles, shiftSubtitles
|
|
17
18
|
* - markdown-front-matter-parser: parseFrontMatter
|
|
18
19
|
* - markdown-toc-generator: generateMarkdownToc
|
|
@@ -218,6 +219,15 @@ declare function ndjsonToJsonArray(input: string): string | {
|
|
|
218
219
|
declare function jsonArrayToNdjson(input: string): string | {
|
|
219
220
|
error: string;
|
|
220
221
|
};
|
|
222
|
+
/**
|
|
223
|
+
* Convert NDJSON (one flat JSON object per line) into CSV, inferring the
|
|
224
|
+
* header row from the union of keys across every line in the order each
|
|
225
|
+
* key is first seen. A value that is itself an object or array is embedded
|
|
226
|
+
* as a JSON string rather than expanded into further columns.
|
|
227
|
+
*/
|
|
228
|
+
declare function ndjsonToCsv(input: string): string | {
|
|
229
|
+
error: string;
|
|
230
|
+
};
|
|
221
231
|
interface NdjsonDedupeResult {
|
|
222
232
|
totalLines: number;
|
|
223
233
|
uniqueLines: number;
|
|
@@ -610,6 +620,7 @@ declare const data_jsonToXml: typeof jsonToXml;
|
|
|
610
620
|
declare const data_minifyNdjson: typeof minifyNdjson;
|
|
611
621
|
declare const data_minifyToml: typeof minifyToml;
|
|
612
622
|
declare const data_minifyXml: typeof minifyXml;
|
|
623
|
+
declare const data_ndjsonToCsv: typeof ndjsonToCsv;
|
|
613
624
|
declare const data_ndjsonToJsonArray: typeof ndjsonToJsonArray;
|
|
614
625
|
declare const data_parseCsv: typeof parseCsv;
|
|
615
626
|
declare const data_parseEnv: typeof parseEnv;
|
|
@@ -632,7 +643,7 @@ declare const data_validateXml: typeof validateXml;
|
|
|
632
643
|
declare const data_validateYaml: typeof validateYaml;
|
|
633
644
|
declare const data_xmlToJson: typeof xmlToJson;
|
|
634
645
|
declare namespace data {
|
|
635
|
-
export { type data_CaptionSpeedCue as CaptionSpeedCue, type data_CaptionSpeedResult as CaptionSpeedResult, type data_ConvertedSubtitles as ConvertedSubtitles, type data_CsvColumnType as CsvColumnType, type data_CsvColumnTypeInfo as CsvColumnTypeInfo, type data_CsvColumnTypeOptions as CsvColumnTypeOptions, type data_CsvColumnTypeResult as CsvColumnTypeResult, type data_CsvDuplicateGroup as CsvDuplicateGroup, type data_CsvDuplicateOptions as CsvDuplicateOptions, type data_CsvDuplicateResult as CsvDuplicateResult, type data_CsvParseResult as CsvParseResult, type data_CsvToSqlOptions as CsvToSqlOptions, type data_CsvToSqlResult as CsvToSqlResult, type data_EnvDiffError as EnvDiffError, type data_EnvDiffResult as EnvDiffResult, type data_EnvEntry as EnvEntry, type data_EnvParseResult as EnvParseResult, type data_FrontMatterError as FrontMatterError, type data_FrontMatterResult as FrontMatterResult, type data_IniSection as IniSection, type data_MarkdownTableAlignResult as MarkdownTableAlignResult, type data_MarkdownTableColumnAlignment as MarkdownTableColumnAlignment, type data_MarkdownTableInfo as MarkdownTableInfo, type data_MarkdownTaskListItem as MarkdownTaskListItem, type data_MarkdownTaskListProgressResult as MarkdownTaskListProgressResult, type data_MarkdownTaskListSectionSummary as MarkdownTaskListSectionSummary, type data_MarkdownTocEntry as MarkdownTocEntry, type data_MarkdownTocOptions as MarkdownTocOptions, type data_MarkdownTocResult as MarkdownTocResult, type data_NdjsonDedupeResult as NdjsonDedupeResult, type data_NdjsonLineResult as NdjsonLineResult, type data_NdjsonValidateResult as NdjsonValidateResult, type data_ParseOptions as ParseOptions, type data_ParsedIni as ParsedIni, type data_ParsedSubtitles as ParsedSubtitles, type data_SubtitleCue as SubtitleCue, type data_SubtitleFormat as SubtitleFormat, type data_TomlFormatResult as TomlFormatResult, type data_ValidationResult as ValidationResult, type data_XmlFormatResult as XmlFormatResult, type data_XmlToJsonOptions as XmlToJsonOptions, type data_YamlAnchorInfo as YamlAnchorInfo, type data_YamlAnchorResolveError as YamlAnchorResolveError, type data_YamlAnchorResolveResult as YamlAnchorResolveResult, data_alignMarkdownTables as alignMarkdownTables, data_analyzeCaptionSpeed as analyzeCaptionSpeed, data_calculateMarkdownTaskListProgress as calculateMarkdownTaskListProgress, data_convertSubtitles as convertSubtitles, data_csvToJson as csvToJson, data_csvToSqlInsert as csvToSqlInsert, data_dedupeNdjson as dedupeNdjson, data_detectDelimiter as detectDelimiter, data_detectSubtitleFormat as detectSubtitleFormat, data_diffEnvExample as diffEnvExample, data_envToExport as envToExport, data_envToJson as envToJson, data_findCsvDuplicateRows as findCsvDuplicateRows, data_formatNdjson as formatNdjson, data_formatSubtitleTimestamp as formatSubtitleTimestamp, data_formatToml as formatToml, data_formatXml as formatXml, data_generateMarkdownToc as generateMarkdownToc, data_getSection as getSection, data_getSectionNames as getSectionNames, data_getTomlStats as getTomlStats, data_getXmlStats as getXmlStats, data_getYamlStats as getYamlStats, data_inferCsvColumnTypes as inferCsvColumnTypes, data_iniToJson as iniToJson, data_jsonArrayToNdjson as jsonArrayToNdjson, data_jsonToIni as jsonToIni, data_jsonToToml as jsonToToml, data_jsonToXml as jsonToXml, data_minifyNdjson as minifyNdjson, data_minifyToml as minifyToml, data_minifyXml as minifyXml, data_ndjsonToJsonArray as ndjsonToJsonArray, data_parseCsv as parseCsv, data_parseEnv as parseEnv, data_parseFrontMatter as parseFrontMatter, data_parseIni as parseIni, data_parseSubtitleTimestamp as parseSubtitleTimestamp, data_parseSubtitles as parseSubtitles, data_parseXmlToObject as parseXmlToObject, data_resolveYamlAnchors as resolveYamlAnchors, data_serializeSubtitles as serializeSubtitles, data_shiftSubtitles as shiftSubtitles, data_stringifyIni as stringifyIni, data_toCsvString as toCsvString, data_tomlToJson as tomlToJson, data_validateEnvKey as validateEnvKey, data_validateIni as validateIni, data_validateNdjson as validateNdjson, data_validateToml as validateToml, data_validateXml as validateXml, data_validateYaml as validateYaml, data_xmlToJson as xmlToJson };
|
|
646
|
+
export { type data_CaptionSpeedCue as CaptionSpeedCue, type data_CaptionSpeedResult as CaptionSpeedResult, type data_ConvertedSubtitles as ConvertedSubtitles, type data_CsvColumnType as CsvColumnType, type data_CsvColumnTypeInfo as CsvColumnTypeInfo, type data_CsvColumnTypeOptions as CsvColumnTypeOptions, type data_CsvColumnTypeResult as CsvColumnTypeResult, type data_CsvDuplicateGroup as CsvDuplicateGroup, type data_CsvDuplicateOptions as CsvDuplicateOptions, type data_CsvDuplicateResult as CsvDuplicateResult, type data_CsvParseResult as CsvParseResult, type data_CsvToSqlOptions as CsvToSqlOptions, type data_CsvToSqlResult as CsvToSqlResult, type data_EnvDiffError as EnvDiffError, type data_EnvDiffResult as EnvDiffResult, type data_EnvEntry as EnvEntry, type data_EnvParseResult as EnvParseResult, type data_FrontMatterError as FrontMatterError, type data_FrontMatterResult as FrontMatterResult, type data_IniSection as IniSection, type data_MarkdownTableAlignResult as MarkdownTableAlignResult, type data_MarkdownTableColumnAlignment as MarkdownTableColumnAlignment, type data_MarkdownTableInfo as MarkdownTableInfo, type data_MarkdownTaskListItem as MarkdownTaskListItem, type data_MarkdownTaskListProgressResult as MarkdownTaskListProgressResult, type data_MarkdownTaskListSectionSummary as MarkdownTaskListSectionSummary, type data_MarkdownTocEntry as MarkdownTocEntry, type data_MarkdownTocOptions as MarkdownTocOptions, type data_MarkdownTocResult as MarkdownTocResult, type data_NdjsonDedupeResult as NdjsonDedupeResult, type data_NdjsonLineResult as NdjsonLineResult, type data_NdjsonValidateResult as NdjsonValidateResult, type data_ParseOptions as ParseOptions, type data_ParsedIni as ParsedIni, type data_ParsedSubtitles as ParsedSubtitles, type data_SubtitleCue as SubtitleCue, type data_SubtitleFormat as SubtitleFormat, type data_TomlFormatResult as TomlFormatResult, type data_ValidationResult as ValidationResult, type data_XmlFormatResult as XmlFormatResult, type data_XmlToJsonOptions as XmlToJsonOptions, type data_YamlAnchorInfo as YamlAnchorInfo, type data_YamlAnchorResolveError as YamlAnchorResolveError, type data_YamlAnchorResolveResult as YamlAnchorResolveResult, data_alignMarkdownTables as alignMarkdownTables, data_analyzeCaptionSpeed as analyzeCaptionSpeed, data_calculateMarkdownTaskListProgress as calculateMarkdownTaskListProgress, data_convertSubtitles as convertSubtitles, data_csvToJson as csvToJson, data_csvToSqlInsert as csvToSqlInsert, data_dedupeNdjson as dedupeNdjson, data_detectDelimiter as detectDelimiter, data_detectSubtitleFormat as detectSubtitleFormat, data_diffEnvExample as diffEnvExample, data_envToExport as envToExport, data_envToJson as envToJson, data_findCsvDuplicateRows as findCsvDuplicateRows, data_formatNdjson as formatNdjson, data_formatSubtitleTimestamp as formatSubtitleTimestamp, data_formatToml as formatToml, data_formatXml as formatXml, data_generateMarkdownToc as generateMarkdownToc, data_getSection as getSection, data_getSectionNames as getSectionNames, data_getTomlStats as getTomlStats, data_getXmlStats as getXmlStats, data_getYamlStats as getYamlStats, data_inferCsvColumnTypes as inferCsvColumnTypes, data_iniToJson as iniToJson, data_jsonArrayToNdjson as jsonArrayToNdjson, data_jsonToIni as jsonToIni, data_jsonToToml as jsonToToml, data_jsonToXml as jsonToXml, data_minifyNdjson as minifyNdjson, data_minifyToml as minifyToml, data_minifyXml as minifyXml, data_ndjsonToCsv as ndjsonToCsv, data_ndjsonToJsonArray as ndjsonToJsonArray, data_parseCsv as parseCsv, data_parseEnv as parseEnv, data_parseFrontMatter as parseFrontMatter, data_parseIni as parseIni, data_parseSubtitleTimestamp as parseSubtitleTimestamp, data_parseSubtitles as parseSubtitles, data_parseXmlToObject as parseXmlToObject, data_resolveYamlAnchors as resolveYamlAnchors, data_serializeSubtitles as serializeSubtitles, data_shiftSubtitles as shiftSubtitles, data_stringifyIni as stringifyIni, data_toCsvString as toCsvString, data_tomlToJson as tomlToJson, data_validateEnvKey as validateEnvKey, data_validateIni as validateIni, data_validateNdjson as validateNdjson, data_validateToml as validateToml, data_validateXml as validateXml, data_validateYaml as validateYaml, data_xmlToJson as xmlToJson };
|
|
636
647
|
}
|
|
637
648
|
|
|
638
|
-
export { detectSubtitleFormat as $, type NdjsonValidateResult as A, type ParsedIni as B, type CaptionSpeedCue as C, type ParsedSubtitles as D, type EnvDiffError as E, type FrontMatterError as F, type SubtitleFormat as G, type XmlToJsonOptions as H, type IniSection as I, type YamlAnchorResolveError as J, type YamlAnchorResolveResult as K, alignMarkdownTables as L, type MarkdownTableAlignResult as M, type NdjsonDedupeResult as N, analyzeCaptionSpeed as O, type ParseOptions as P, calculateMarkdownTaskListProgress as Q, convertSubtitles as R, type SubtitleCue as S, type TomlFormatResult as T, csvToJson as U, type ValidationResult as V, csvToSqlInsert as W, type XmlFormatResult as X, type YamlAnchorInfo as Y, dedupeNdjson as Z, detectDelimiter as _, type CaptionSpeedResult as a, diffEnvExample as a0, envToExport as a1, envToJson as a2, findCsvDuplicateRows as a3, formatNdjson as a4, formatSubtitleTimestamp as a5, formatToml as a6, formatXml as a7, generateMarkdownToc as a8, getSection as a9,
|
|
649
|
+
export { detectSubtitleFormat as $, type NdjsonValidateResult as A, type ParsedIni as B, type CaptionSpeedCue as C, type ParsedSubtitles as D, type EnvDiffError as E, type FrontMatterError as F, type SubtitleFormat as G, type XmlToJsonOptions as H, type IniSection as I, type YamlAnchorResolveError as J, type YamlAnchorResolveResult as K, alignMarkdownTables as L, type MarkdownTableAlignResult as M, type NdjsonDedupeResult as N, analyzeCaptionSpeed as O, type ParseOptions as P, calculateMarkdownTaskListProgress as Q, convertSubtitles as R, type SubtitleCue as S, type TomlFormatResult as T, csvToJson as U, type ValidationResult as V, csvToSqlInsert as W, type XmlFormatResult as X, type YamlAnchorInfo as Y, dedupeNdjson as Z, detectDelimiter as _, type CaptionSpeedResult as a, diffEnvExample as a0, envToExport as a1, envToJson as a2, findCsvDuplicateRows as a3, formatNdjson as a4, formatSubtitleTimestamp as a5, formatToml as a6, formatXml as a7, generateMarkdownToc as a8, getSection as a9, toCsvString as aA, tomlToJson as aB, validateEnvKey as aC, validateIni as aD, validateNdjson as aE, validateToml as aF, validateXml as aG, validateYaml as aH, xmlToJson as aI, getSectionNames as aa, getTomlStats as ab, getXmlStats as ac, getYamlStats as ad, inferCsvColumnTypes as ae, iniToJson as af, jsonArrayToNdjson as ag, jsonToIni as ah, jsonToToml as ai, jsonToXml as aj, minifyNdjson as ak, minifyToml as al, minifyXml as am, ndjsonToCsv as an, ndjsonToJsonArray as ao, parseCsv as ap, parseEnv as aq, parseFrontMatter as ar, parseIni as as, parseSubtitleTimestamp as at, parseSubtitles as au, parseXmlToObject as av, resolveYamlAnchors as aw, serializeSubtitles as ax, shiftSubtitles as ay, stringifyIni as az, type ConvertedSubtitles as b, type CsvColumnType as c, data as d, type CsvColumnTypeInfo as e, type CsvColumnTypeOptions as f, type CsvColumnTypeResult as g, type CsvDuplicateGroup as h, type CsvDuplicateOptions as i, type CsvDuplicateResult as j, type CsvParseResult as k, type CsvToSqlOptions as l, type CsvToSqlResult as m, type EnvDiffResult as n, type EnvEntry as o, type EnvParseResult as p, type FrontMatterResult as q, type MarkdownTableColumnAlignment as r, type MarkdownTableInfo as s, type MarkdownTaskListItem as t, type MarkdownTaskListProgressResult as u, type MarkdownTaskListSectionSummary as v, type MarkdownTocEntry as w, type MarkdownTocOptions as x, type MarkdownTocResult as y, type NdjsonLineResult as z };
|