@utilix-tech/sdk 0.6.0 → 0.8.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 +18 -3
- package/README.md +29 -8
- package/dist/{chunk-YBBYFAOV.js → chunk-F57WMKZO.js} +69 -1
- package/dist/{chunk-FXBB7O5A.js → chunk-GUUYEIU6.js} +269 -2
- package/dist/{chunk-DNCOIO5N.js → chunk-TINQFTLO.js} +19 -1
- package/dist/{data-CakDxAcT.d.ts → data-D8XTI7Du.d.cts} +21 -2
- package/dist/{data-CakDxAcT.d.cts → data-D8XTI7Du.d.ts} +21 -2
- package/dist/index.cjs +354 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/media-C3ZvGyKc.d.cts +132 -0
- package/dist/media-C3ZvGyKc.d.ts +132 -0
- package/dist/{text-CI7JAl7F.d.cts → text-Bbx-tZ43.d.cts} +23 -2
- package/dist/{text-CI7JAl7F.d.ts → text-Bbx-tZ43.d.ts} +23 -2
- package/dist/tools/data.cjs +18 -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 +267 -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/text.cjs +68 -0
- package/dist/tools/text.d.cts +1 -1
- package/dist/tools/text.d.ts +1 -1
- package/dist/tools/text.js +1 -1
- package/package.json +8 -3
- package/dist/media-CHaBS1dI.d.cts +0 -82
- package/dist/media-CHaBS1dI.d.ts +0 -82
package/CHANGELOG.md
CHANGED
|
@@ -2,11 +2,26 @@
|
|
|
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.
|
|
6
|
-
-
|
|
5
|
+
## 0.8.0
|
|
6
|
+
- Added ID3 Tag Reader and .env.example Diff Checker.
|
|
7
|
+
|
|
8
|
+
## 0.7.0
|
|
9
|
+
- Added WAV Audio Info and Readability Score Calculator.
|
|
10
|
+
|
|
11
|
+
## 0.6.0
|
|
12
|
+
- Added EXIF Viewer and Commit Message Generator (AI).
|
|
13
|
+
|
|
14
|
+
## 0.5.0
|
|
15
|
+
- Added PDF Metadata Reader and JWK Viewer.
|
|
16
|
+
|
|
17
|
+
## 0.4.1
|
|
18
|
+
- Added HAR File Viewer and NDJSON Formatter/Validator.
|
|
19
|
+
|
|
20
|
+
## 0.4.0
|
|
21
|
+
- Metadata fixes: corrected repository/bug tracker links, updated the stale dependency, added missing package files.
|
|
7
22
|
|
|
8
23
|
## 0.3.0
|
|
9
|
-
- Added the `media` module.
|
|
24
|
+
- Added the `media` module (Passive Voice Detector, Image Info).
|
|
10
25
|
|
|
11
26
|
## 0.2.0
|
|
12
27
|
- 400+ functions across 14 modules, including the `ai_agent` module for LLM/RAG pipelines.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @utilix-tech/sdk
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**526 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)
|
|
@@ -127,7 +127,7 @@ generateHtpasswdFile([{ username: "alice", password: "secret" }]);
|
|
|
127
127
|
|
|
128
128
|
```ts
|
|
129
129
|
import { convertCase, slugify, countWords, generateWords, generateParagraphs,
|
|
130
|
-
escapeString, htmlToMarkdown, applyOps, detectPassiveVoice } from "@utilix-tech/sdk/text";
|
|
130
|
+
escapeString, htmlToMarkdown, applyOps, detectPassiveVoice, scoreReadability } from "@utilix-tech/sdk/text";
|
|
131
131
|
|
|
132
132
|
convertCase("hello world", "camelCase"); // "helloWorld"
|
|
133
133
|
convertCase("hello world", "PascalCase"); // "HelloWorld"
|
|
@@ -148,16 +148,20 @@ htmlToMarkdown("<h1>Hello</h1><p>World</p>");
|
|
|
148
148
|
|
|
149
149
|
// Flag passive-voice sentences, e.g. "was written", "were approved by the team"
|
|
150
150
|
detectPassiveVoice("The report was reviewed by the committee. They approved it.");
|
|
151
|
+
|
|
152
|
+
// Flesch Reading Ease, Flesch-Kincaid Grade Level, and Gunning Fog Index
|
|
153
|
+
scoreReadability("The cat sat on the mat. It was a sunny day.");
|
|
154
|
+
// { fleschReadingEase: 109, fleschKincaidGrade: -0.6, gunningFog: 2.2, readingLevel: "Very easy (5th grade)", ... }
|
|
151
155
|
```
|
|
152
156
|
|
|
153
157
|
---
|
|
154
158
|
|
|
155
|
-
### `/data`: CSV / YAML / TOML / XML / INI / NDJSON
|
|
159
|
+
### `/data`: CSV / YAML / TOML / XML / INI / NDJSON / .env diff
|
|
156
160
|
|
|
157
161
|
```ts
|
|
158
162
|
import { parseCsv, csvToJson, validateYaml, tomlToJson, jsonToToml,
|
|
159
163
|
formatXml, xmlToJson, jsonToXml, parseIni,
|
|
160
|
-
validateNdjson, formatNdjson, ndjsonToJsonArray } from "@utilix-tech/sdk/data";
|
|
164
|
+
validateNdjson, formatNdjson, ndjsonToJsonArray, diffEnvExample } from "@utilix-tech/sdk/data";
|
|
161
165
|
|
|
162
166
|
// CSV
|
|
163
167
|
const rows = parseCsv("name,age\nalice,30\nbob,25");
|
|
@@ -181,6 +185,10 @@ parseIni("[db]\nhost=localhost\nport=5432");
|
|
|
181
185
|
validateNdjson('{"id":1}\n{"id":2}'); // { valid: true, totalLines: 2, ... }
|
|
182
186
|
formatNdjson('{"id":1}'); // '{\n "id": 1\n}'
|
|
183
187
|
ndjsonToJsonArray('{"id":1}\n{"id":2}'); // '[\n { "id": 1 },\n { "id": 2 }\n]'
|
|
188
|
+
|
|
189
|
+
// Diff a .env file against its .env.example template
|
|
190
|
+
diffEnvExample("FOO=1\nBAR=2", "FOO=\nBAR=y\nBAZ=z");
|
|
191
|
+
// { missingInExample: [], missingInEnv: ["BAZ"], emptyValueInExample: ["FOO"], keysInBoth: 2 }
|
|
184
192
|
```
|
|
185
193
|
|
|
186
194
|
---
|
|
@@ -416,10 +424,10 @@ analyzeString("café"); // { length: 4, codePoints: [...], ... }
|
|
|
416
424
|
|
|
417
425
|
---
|
|
418
426
|
|
|
419
|
-
### `/media`: Image Header Parsing, EXIF &
|
|
427
|
+
### `/media`: Image Header Parsing, EXIF, PDF, WAV & ID3 Metadata
|
|
420
428
|
|
|
421
429
|
```ts
|
|
422
|
-
import { readImageInfo, readExifData, readPdfMetadata } from "@utilix-tech/sdk/media";
|
|
430
|
+
import { readImageInfo, readExifData, readPdfMetadata, readWavInfo, readId3Tags } from "@utilix-tech/sdk/media";
|
|
423
431
|
|
|
424
432
|
// Reads format, dimensions, bit depth, and alpha channel straight from
|
|
425
433
|
// file bytes: no decoding, no canvas, no image library.
|
|
@@ -438,9 +446,22 @@ readExifData(new Uint8Array(jpegBytes));
|
|
|
438
446
|
const pdfBytes = await fs.promises.readFile("report.pdf");
|
|
439
447
|
readPdfMetadata(new Uint8Array(pdfBytes));
|
|
440
448
|
// { version: "1.7", pageCount: 12, title: "Q3 Report", author: "Jane Doe", ... }
|
|
449
|
+
|
|
450
|
+
// Reads sample rate, channels, bit depth, and duration from a WAV file's
|
|
451
|
+
// RIFF/fmt/data chunk headers: no audio library required.
|
|
452
|
+
const wavBytes = await fs.promises.readFile("recording.wav");
|
|
453
|
+
readWavInfo(new Uint8Array(wavBytes));
|
|
454
|
+
// { audioFormat: 1, audioFormatLabel: "PCM", channels: 2, sampleRate: 44100, bitsPerSample: 16, durationSeconds: 12.4, ... }
|
|
455
|
+
|
|
456
|
+
// Reads title, artist, album, year, genre, comment, and track number from
|
|
457
|
+
// an MP3's ID3 tags. Prefers ID3v2.3/2.4 text frames, falls back to the
|
|
458
|
+
// classic 128-byte ID3v1/1.1 trailer.
|
|
459
|
+
const mp3Bytes = await fs.promises.readFile("track.mp3");
|
|
460
|
+
readId3Tags(new Uint8Array(mp3Bytes));
|
|
461
|
+
// { version: "ID3v2.3.0", title: "Track Name", artist: "Artist Name", genre: "Rock", ... }
|
|
441
462
|
```
|
|
442
463
|
|
|
443
|
-
`readImageInfo` supports PNG, JPEG, GIF, WebP, and BMP. `readExifData` supports JPEG only.
|
|
464
|
+
`readImageInfo` supports PNG, JPEG, GIF, WebP, and BMP. `readExifData` supports JPEG only. `readWavInfo` supports the canonical RIFF/WAVE container only. `readId3Tags` decodes ID3v2.3/2.4 and ID3v1/1.1 only (ID3v2.2 is detected but not decoded).
|
|
444
465
|
|
|
445
466
|
---
|
|
446
467
|
|
|
@@ -463,7 +484,7 @@ readPdfMetadata(new Uint8Array(pdfBytes));
|
|
|
463
484
|
| `@utilix-tech/sdk/css` | CSS gradient, box-shadow, border-radius, keyframe animation generators |
|
|
464
485
|
| `@utilix-tech/sdk/misc` | SVG optimize/sanitize, file size format, Unicode inspector |
|
|
465
486
|
| `@utilix-tech/sdk/ai_agent` | Token estimate/trim, chunk text, extract URLs/JSON/keywords, sanitize HTML, flatten/merge JSON, dedupe lines, validate schema, PII/secret/injection detect |
|
|
466
|
-
| `@utilix-tech/sdk/media` | Image format & dimension reading from raw bytes (PNG, JPEG, GIF, WebP, BMP); PDF metadata reading |
|
|
487
|
+
| `@utilix-tech/sdk/media` | Image format & dimension reading from raw bytes (PNG, JPEG, GIF, WebP, BMP); PDF metadata reading; WAV audio info |
|
|
467
488
|
|
|
468
489
|
---
|
|
469
490
|
|
|
@@ -51,6 +51,7 @@ __export(text_exports, {
|
|
|
51
51
|
readabilityScore: () => readabilityScore,
|
|
52
52
|
renderMarkdown: () => renderMarkdown,
|
|
53
53
|
romanToNumber: () => romanToNumber,
|
|
54
|
+
scoreReadability: () => scoreReadability,
|
|
54
55
|
sentenceCount: () => sentenceCount,
|
|
55
56
|
slugify: () => slugify,
|
|
56
57
|
slugifyAll: () => slugifyAll,
|
|
@@ -2389,5 +2390,72 @@ function detectPassiveVoice(text) {
|
|
|
2389
2390
|
const passivePercent = totalSentences > 0 ? Math.round(passiveSentences / totalSentences * 1e3) / 10 : 0;
|
|
2390
2391
|
return { sentences: analyzed, totalSentences, passiveSentences, passivePercent };
|
|
2391
2392
|
}
|
|
2393
|
+
function countSyllables(word) {
|
|
2394
|
+
const w = word.toLowerCase().replace(/[^a-z]/g, "");
|
|
2395
|
+
if (w.length === 0) return 0;
|
|
2396
|
+
if (w.length <= 3) return 1;
|
|
2397
|
+
let count = 0;
|
|
2398
|
+
let prevWasVowel = false;
|
|
2399
|
+
for (const ch of w) {
|
|
2400
|
+
const isVowel = "aeiouy".includes(ch);
|
|
2401
|
+
if (isVowel && !prevWasVowel) count++;
|
|
2402
|
+
prevWasVowel = isVowel;
|
|
2403
|
+
}
|
|
2404
|
+
if (w.endsWith("e") && !w.endsWith("le") && count > 1) count--;
|
|
2405
|
+
if (w.endsWith("le") && w.length > 2 && !"aeiouy".includes(w[w.length - 3])) count++;
|
|
2406
|
+
return Math.max(count, 1);
|
|
2407
|
+
}
|
|
2408
|
+
function readabilityGradeLabel(fleschReadingEase) {
|
|
2409
|
+
if (fleschReadingEase >= 90) return "Very easy (5th grade)";
|
|
2410
|
+
if (fleschReadingEase >= 80) return "Easy (6th grade)";
|
|
2411
|
+
if (fleschReadingEase >= 70) return "Fairly easy (7th grade)";
|
|
2412
|
+
if (fleschReadingEase >= 60) return "Standard (8th-9th grade)";
|
|
2413
|
+
if (fleschReadingEase >= 50) return "Fairly difficult (10th-12th grade)";
|
|
2414
|
+
if (fleschReadingEase >= 30) return "Difficult (college)";
|
|
2415
|
+
return "Very difficult (college graduate)";
|
|
2416
|
+
}
|
|
2417
|
+
function round1(n) {
|
|
2418
|
+
return Math.round(n * 10) / 10;
|
|
2419
|
+
}
|
|
2420
|
+
function scoreReadability(text) {
|
|
2421
|
+
const sentences = splitIntoSentences(text);
|
|
2422
|
+
const words = text.match(/[a-zA-Z']+/g) ?? [];
|
|
2423
|
+
const sentenceCount2 = Math.max(sentences.length, 1);
|
|
2424
|
+
const wordCount = words.length;
|
|
2425
|
+
const syllableCounts = words.map(countSyllables);
|
|
2426
|
+
const syllableCount2 = syllableCounts.reduce((a, b) => a + b, 0);
|
|
2427
|
+
const complexWordCount = syllableCounts.filter((c) => c >= 3).length;
|
|
2428
|
+
if (wordCount === 0) {
|
|
2429
|
+
return {
|
|
2430
|
+
wordCount: 0,
|
|
2431
|
+
sentenceCount: 0,
|
|
2432
|
+
syllableCount: 0,
|
|
2433
|
+
complexWordCount: 0,
|
|
2434
|
+
avgWordsPerSentence: 0,
|
|
2435
|
+
avgSyllablesPerWord: 0,
|
|
2436
|
+
fleschReadingEase: 0,
|
|
2437
|
+
fleschKincaidGrade: 0,
|
|
2438
|
+
gunningFog: 0,
|
|
2439
|
+
readingLevel: "No text to score"
|
|
2440
|
+
};
|
|
2441
|
+
}
|
|
2442
|
+
const avgWordsPerSentence = wordCount / sentenceCount2;
|
|
2443
|
+
const avgSyllablesPerWord = syllableCount2 / wordCount;
|
|
2444
|
+
const fleschReadingEase = round1(206.835 - 1.015 * avgWordsPerSentence - 84.6 * avgSyllablesPerWord);
|
|
2445
|
+
const fleschKincaidGrade = round1(0.39 * avgWordsPerSentence + 11.8 * avgSyllablesPerWord - 15.59);
|
|
2446
|
+
const gunningFog = round1(0.4 * (avgWordsPerSentence + 100 * (complexWordCount / wordCount)));
|
|
2447
|
+
return {
|
|
2448
|
+
wordCount,
|
|
2449
|
+
sentenceCount: sentences.length,
|
|
2450
|
+
syllableCount: syllableCount2,
|
|
2451
|
+
complexWordCount,
|
|
2452
|
+
avgWordsPerSentence: round1(avgWordsPerSentence),
|
|
2453
|
+
avgSyllablesPerWord: round1(avgSyllablesPerWord),
|
|
2454
|
+
fleschReadingEase,
|
|
2455
|
+
fleschKincaidGrade,
|
|
2456
|
+
gunningFog,
|
|
2457
|
+
readingLevel: readabilityGradeLabel(fleschReadingEase)
|
|
2458
|
+
};
|
|
2459
|
+
}
|
|
2392
2460
|
|
|
2393
|
-
export { CASE_FORMATS, DEFAULT_CONVERT_OPTIONS, ESCAPE_MODES, LINE_OPS, MORSE_CODE, addBorder, analyzeText, applyOp, applyOps, centerText, convertAll, convertCase, countWords, csvToHtml, csvToMarkdown, detectDelimiter, detectPassiveVoice, diffLines, diffLinesSimple, diffStats, escapeAll, escapeString, extractHeadings, formatReadingTime, generate, generateDiff, generateHtmlTable, generateMarkdownTable, generateParagraphs, generateSentences, generateWords, getAvailableFonts, getMorseForChar, getMorseTiming, htmlToMarkdown, isValidMorse, markdownToHtml, morseToText, numberToOrdinal, numberToRoman, numberToWords, ordinalWords, parseDiff, parseTableData, readabilityScore, renderMarkdown, romanToNumber, sentenceCount, slugify, slugifyAll, syllableCount, textToAscii, textToMorse, text_exports, unescapeString, wordFrequency };
|
|
2461
|
+
export { CASE_FORMATS, DEFAULT_CONVERT_OPTIONS, ESCAPE_MODES, LINE_OPS, MORSE_CODE, addBorder, analyzeText, applyOp, applyOps, centerText, convertAll, convertCase, countWords, csvToHtml, csvToMarkdown, detectDelimiter, detectPassiveVoice, diffLines, diffLinesSimple, diffStats, escapeAll, escapeString, extractHeadings, formatReadingTime, generate, generateDiff, generateHtmlTable, generateMarkdownTable, generateParagraphs, generateSentences, generateWords, getAvailableFonts, getMorseForChar, getMorseTiming, htmlToMarkdown, isValidMorse, markdownToHtml, morseToText, numberToOrdinal, numberToRoman, numberToWords, ordinalWords, parseDiff, parseTableData, readabilityScore, renderMarkdown, romanToNumber, scoreReadability, sentenceCount, slugify, slugifyAll, syllableCount, textToAscii, textToMorse, text_exports, unescapeString, wordFrequency };
|
|
@@ -4,8 +4,10 @@ import { __export } from './chunk-MLKGABMK.js';
|
|
|
4
4
|
var media_exports = {};
|
|
5
5
|
__export(media_exports, {
|
|
6
6
|
readExifData: () => readExifData,
|
|
7
|
+
readId3Tags: () => readId3Tags,
|
|
7
8
|
readImageInfo: () => readImageInfo,
|
|
8
|
-
readPdfMetadata: () => readPdfMetadata
|
|
9
|
+
readPdfMetadata: () => readPdfMetadata,
|
|
10
|
+
readWavInfo: () => readWavInfo
|
|
9
11
|
});
|
|
10
12
|
function readU32BE(bytes, offset) {
|
|
11
13
|
return (bytes[offset] << 24 | bytes[offset + 1] << 16 | bytes[offset + 2] << 8 | bytes[offset + 3]) >>> 0;
|
|
@@ -463,5 +465,270 @@ function readPdfMetadata(bytes) {
|
|
|
463
465
|
encrypted
|
|
464
466
|
};
|
|
465
467
|
}
|
|
468
|
+
var AUDIO_FORMAT_LABELS = {
|
|
469
|
+
1: "PCM",
|
|
470
|
+
3: "IEEE float",
|
|
471
|
+
6: "A-law",
|
|
472
|
+
7: "mu-law",
|
|
473
|
+
65534: "Extensible"
|
|
474
|
+
};
|
|
475
|
+
function readAscii4(bytes, offset) {
|
|
476
|
+
return String.fromCharCode(bytes[offset], bytes[offset + 1], bytes[offset + 2], bytes[offset + 3]);
|
|
477
|
+
}
|
|
478
|
+
function readWavInfo(bytes) {
|
|
479
|
+
if (bytes.length < 12) return { error: "File is too small to be a valid WAV file" };
|
|
480
|
+
if (readAscii4(bytes, 0) !== "RIFF") return { error: 'Not a RIFF file (missing "RIFF" header)' };
|
|
481
|
+
if (readAscii4(bytes, 8) !== "WAVE") return { error: 'Not a WAVE file (missing "WAVE" format marker)' };
|
|
482
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
483
|
+
const fileSize = view.getUint32(4, true) + 8;
|
|
484
|
+
let offset = 12;
|
|
485
|
+
let fmt = null;
|
|
486
|
+
let dataSize = null;
|
|
487
|
+
while (offset + 8 <= bytes.length) {
|
|
488
|
+
const chunkId = readAscii4(bytes, offset);
|
|
489
|
+
const chunkSize = view.getUint32(offset + 4, true);
|
|
490
|
+
const dataOffset = offset + 8;
|
|
491
|
+
if (chunkId === "fmt ") {
|
|
492
|
+
if (dataOffset + 16 > bytes.length) return { error: 'Truncated "fmt " chunk' };
|
|
493
|
+
fmt = {
|
|
494
|
+
audioFormat: view.getUint16(dataOffset, true),
|
|
495
|
+
channels: view.getUint16(dataOffset + 2, true),
|
|
496
|
+
sampleRate: view.getUint32(dataOffset + 4, true),
|
|
497
|
+
byteRate: view.getUint32(dataOffset + 8, true),
|
|
498
|
+
blockAlign: view.getUint16(dataOffset + 12, true),
|
|
499
|
+
bitsPerSample: view.getUint16(dataOffset + 14, true)
|
|
500
|
+
};
|
|
501
|
+
} else if (chunkId === "data") {
|
|
502
|
+
dataSize = Math.min(chunkSize, bytes.length - dataOffset);
|
|
503
|
+
}
|
|
504
|
+
offset = dataOffset + chunkSize + chunkSize % 2;
|
|
505
|
+
if (fmt && dataSize !== null) break;
|
|
506
|
+
}
|
|
507
|
+
if (!fmt) return { error: 'No "fmt " chunk found in this WAV file' };
|
|
508
|
+
if (dataSize === null) return { error: 'No "data" chunk found in this WAV file' };
|
|
509
|
+
if (fmt.byteRate <= 0) return { error: 'Invalid byte rate in "fmt " chunk' };
|
|
510
|
+
const durationSeconds = Math.round(dataSize / fmt.byteRate * 1e3) / 1e3;
|
|
511
|
+
return {
|
|
512
|
+
audioFormat: fmt.audioFormat,
|
|
513
|
+
audioFormatLabel: AUDIO_FORMAT_LABELS[fmt.audioFormat] ?? `Unknown (0x${fmt.audioFormat.toString(16)})`,
|
|
514
|
+
channels: fmt.channels,
|
|
515
|
+
sampleRate: fmt.sampleRate,
|
|
516
|
+
byteRate: fmt.byteRate,
|
|
517
|
+
blockAlign: fmt.blockAlign,
|
|
518
|
+
bitsPerSample: fmt.bitsPerSample,
|
|
519
|
+
dataSize,
|
|
520
|
+
durationSeconds,
|
|
521
|
+
fileSize
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
var ID3V1_GENRES = [
|
|
525
|
+
"Blues",
|
|
526
|
+
"Classic Rock",
|
|
527
|
+
"Country",
|
|
528
|
+
"Dance",
|
|
529
|
+
"Disco",
|
|
530
|
+
"Funk",
|
|
531
|
+
"Grunge",
|
|
532
|
+
"Hip-Hop",
|
|
533
|
+
"Jazz",
|
|
534
|
+
"Metal",
|
|
535
|
+
"New Age",
|
|
536
|
+
"Oldies",
|
|
537
|
+
"Other",
|
|
538
|
+
"Pop",
|
|
539
|
+
"R&B",
|
|
540
|
+
"Rap",
|
|
541
|
+
"Reggae",
|
|
542
|
+
"Rock",
|
|
543
|
+
"Techno",
|
|
544
|
+
"Industrial",
|
|
545
|
+
"Alternative",
|
|
546
|
+
"Ska",
|
|
547
|
+
"Death Metal",
|
|
548
|
+
"Pranks",
|
|
549
|
+
"Soundtrack",
|
|
550
|
+
"Euro-Techno",
|
|
551
|
+
"Ambient",
|
|
552
|
+
"Trip-Hop",
|
|
553
|
+
"Vocal",
|
|
554
|
+
"Jazz+Funk",
|
|
555
|
+
"Fusion",
|
|
556
|
+
"Trance",
|
|
557
|
+
"Classical",
|
|
558
|
+
"Instrumental",
|
|
559
|
+
"Acid",
|
|
560
|
+
"House",
|
|
561
|
+
"Game",
|
|
562
|
+
"Sound Clip",
|
|
563
|
+
"Gospel",
|
|
564
|
+
"Noise",
|
|
565
|
+
"AlternRock",
|
|
566
|
+
"Bass",
|
|
567
|
+
"Soul",
|
|
568
|
+
"Punk",
|
|
569
|
+
"Space",
|
|
570
|
+
"Meditative",
|
|
571
|
+
"Instrumental Pop",
|
|
572
|
+
"Instrumental Rock",
|
|
573
|
+
"Ethnic",
|
|
574
|
+
"Gothic",
|
|
575
|
+
"Darkwave",
|
|
576
|
+
"Techno-Industrial",
|
|
577
|
+
"Electronic",
|
|
578
|
+
"Pop-Folk",
|
|
579
|
+
"Eurodance",
|
|
580
|
+
"Dream",
|
|
581
|
+
"Southern Rock",
|
|
582
|
+
"Comedy",
|
|
583
|
+
"Cult",
|
|
584
|
+
"Gangsta",
|
|
585
|
+
"Top 40",
|
|
586
|
+
"Christian Rap",
|
|
587
|
+
"Pop/Funk",
|
|
588
|
+
"Jungle",
|
|
589
|
+
"Native American",
|
|
590
|
+
"Cabaret",
|
|
591
|
+
"New Wave",
|
|
592
|
+
"Psychedelic",
|
|
593
|
+
"Rave",
|
|
594
|
+
"Showtunes",
|
|
595
|
+
"Trailer",
|
|
596
|
+
"Lo-Fi",
|
|
597
|
+
"Tribal",
|
|
598
|
+
"Acid Punk",
|
|
599
|
+
"Acid Jazz",
|
|
600
|
+
"Polka",
|
|
601
|
+
"Retro",
|
|
602
|
+
"Musical",
|
|
603
|
+
"Rock & Roll",
|
|
604
|
+
"Hard Rock"
|
|
605
|
+
];
|
|
606
|
+
function readSynchsafeUInt32(bytes, offset) {
|
|
607
|
+
return (bytes[offset] & 127) << 21 | (bytes[offset + 1] & 127) << 14 | (bytes[offset + 2] & 127) << 7 | bytes[offset + 3] & 127;
|
|
608
|
+
}
|
|
609
|
+
function readUInt32BE(bytes, offset) {
|
|
610
|
+
return (bytes[offset] << 24 | bytes[offset + 1] << 16 | bytes[offset + 2] << 8 | bytes[offset + 3]) >>> 0;
|
|
611
|
+
}
|
|
612
|
+
function decodeId3Text(frameBytes) {
|
|
613
|
+
if (frameBytes.length === 0) return "";
|
|
614
|
+
const encodingByte = frameBytes[0];
|
|
615
|
+
const content = frameBytes.subarray(1);
|
|
616
|
+
let out = "";
|
|
617
|
+
if (encodingByte === 3) {
|
|
618
|
+
out = Buffer.from(content).toString("utf8");
|
|
619
|
+
} else if (encodingByte === 1 || encodingByte === 2) {
|
|
620
|
+
let little = encodingByte === 1;
|
|
621
|
+
let start = 0;
|
|
622
|
+
if (encodingByte === 1 && content.length >= 2) {
|
|
623
|
+
if (content[0] === 255 && content[1] === 254) {
|
|
624
|
+
little = true;
|
|
625
|
+
start = 2;
|
|
626
|
+
} else if (content[0] === 254 && content[1] === 255) {
|
|
627
|
+
little = false;
|
|
628
|
+
start = 2;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
for (let i = start; i + 1 < content.length; i += 2) {
|
|
632
|
+
const code = little ? content[i] | content[i + 1] << 8 : content[i] << 8 | content[i + 1];
|
|
633
|
+
if (code === 0) break;
|
|
634
|
+
out += String.fromCharCode(code);
|
|
635
|
+
}
|
|
636
|
+
} else {
|
|
637
|
+
for (const b of content) {
|
|
638
|
+
if (b === 0) break;
|
|
639
|
+
out += String.fromCharCode(b);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
return out.replace(/\0+$/, "").trim();
|
|
643
|
+
}
|
|
644
|
+
function readId3v2(bytes) {
|
|
645
|
+
if (bytes.length < 10 || bytes[0] !== 73 || bytes[1] !== 68 || bytes[2] !== 51) return null;
|
|
646
|
+
const majorVersion = bytes[3];
|
|
647
|
+
const revision = bytes[4];
|
|
648
|
+
const tagSize = readSynchsafeUInt32(bytes, 6);
|
|
649
|
+
const version = `ID3v2.${majorVersion}.${revision}`;
|
|
650
|
+
if (majorVersion !== 3 && majorVersion !== 4) {
|
|
651
|
+
return { version, frames: {}, frameCount: 0 };
|
|
652
|
+
}
|
|
653
|
+
const frames = {};
|
|
654
|
+
let offset = 10;
|
|
655
|
+
const end = Math.min(10 + tagSize, bytes.length);
|
|
656
|
+
let frameCount = 0;
|
|
657
|
+
while (offset + 10 <= end) {
|
|
658
|
+
const frameId = String.fromCharCode(bytes[offset], bytes[offset + 1], bytes[offset + 2], bytes[offset + 3]);
|
|
659
|
+
if (frameId === "\0\0\0\0") break;
|
|
660
|
+
const frameSize = majorVersion === 4 ? readSynchsafeUInt32(bytes, offset + 4) : readUInt32BE(bytes, offset + 4);
|
|
661
|
+
const frameStart = offset + 10;
|
|
662
|
+
if (frameSize <= 0 || frameStart + frameSize > bytes.length) break;
|
|
663
|
+
const frameBytes = bytes.subarray(frameStart, frameStart + frameSize);
|
|
664
|
+
if (frameId[0] === "T" && frameId !== "TXXX") {
|
|
665
|
+
frames[frameId] = decodeId3Text(frameBytes);
|
|
666
|
+
} else if (frameId === "COMM" && frameBytes.length > 4) {
|
|
667
|
+
const rebuilt = new Uint8Array(frameBytes.length - 3);
|
|
668
|
+
rebuilt[0] = frameBytes[0];
|
|
669
|
+
rebuilt.set(frameBytes.subarray(4), 1);
|
|
670
|
+
const decoded = decodeId3Text(rebuilt);
|
|
671
|
+
const parts = decoded.split("\0");
|
|
672
|
+
frames["COMM"] = (parts[parts.length - 1] || decoded).trim();
|
|
673
|
+
}
|
|
674
|
+
frameCount++;
|
|
675
|
+
offset = frameStart + frameSize;
|
|
676
|
+
}
|
|
677
|
+
return { version, frames, frameCount };
|
|
678
|
+
}
|
|
679
|
+
function readId3v1(bytes) {
|
|
680
|
+
if (bytes.length < 128) return null;
|
|
681
|
+
const start = bytes.length - 128;
|
|
682
|
+
if (String.fromCharCode(bytes[start], bytes[start + 1], bytes[start + 2]) !== "TAG") return null;
|
|
683
|
+
const readField = (offset, length) => {
|
|
684
|
+
let s = "";
|
|
685
|
+
for (let i = 0; i < length; i++) {
|
|
686
|
+
const b = bytes[start + offset + i];
|
|
687
|
+
if (b === 0) break;
|
|
688
|
+
s += String.fromCharCode(b);
|
|
689
|
+
}
|
|
690
|
+
return s.trim();
|
|
691
|
+
};
|
|
692
|
+
const title = readField(3, 30);
|
|
693
|
+
const artist = readField(33, 30);
|
|
694
|
+
const album = readField(63, 30);
|
|
695
|
+
const year = readField(93, 4);
|
|
696
|
+
const isV11 = bytes[start + 125] === 0 && bytes[start + 126] !== 0;
|
|
697
|
+
const comment = readField(97, isV11 ? 28 : 30);
|
|
698
|
+
const genreIndex = bytes[start + 127];
|
|
699
|
+
const genre = ID3V1_GENRES[genreIndex] ?? `Unknown (${genreIndex})`;
|
|
700
|
+
const result = { genre };
|
|
701
|
+
if (title) result.title = title;
|
|
702
|
+
if (artist) result.artist = artist;
|
|
703
|
+
if (album) result.album = album;
|
|
704
|
+
if (year) result.year = year;
|
|
705
|
+
if (comment) result.comment = comment;
|
|
706
|
+
if (isV11) result.trackNumber = String(bytes[start + 126]);
|
|
707
|
+
return result;
|
|
708
|
+
}
|
|
709
|
+
function readId3Tags(bytes) {
|
|
710
|
+
const v2 = readId3v2(bytes);
|
|
711
|
+
const v1 = readId3v1(bytes);
|
|
712
|
+
if (v2 && Object.keys(v2.frames).length > 0) {
|
|
713
|
+
const f = v2.frames;
|
|
714
|
+
const result = { version: v2.version, frameCount: v2.frameCount };
|
|
715
|
+
if (f["TIT2"]) result.title = f["TIT2"];
|
|
716
|
+
if (f["TPE1"]) result.artist = f["TPE1"];
|
|
717
|
+
if (f["TALB"]) result.album = f["TALB"];
|
|
718
|
+
const year = f["TYER"] || f["TDRC"];
|
|
719
|
+
if (year) result.year = year;
|
|
720
|
+
if (f["TCON"]) result.genre = f["TCON"];
|
|
721
|
+
if (f["COMM"]) result.comment = f["COMM"];
|
|
722
|
+
if (f["TRCK"]) result.trackNumber = f["TRCK"];
|
|
723
|
+
return result;
|
|
724
|
+
}
|
|
725
|
+
if (v1) {
|
|
726
|
+
return { version: v1.trackNumber !== void 0 ? "ID3v1.1" : "ID3v1", ...v1 };
|
|
727
|
+
}
|
|
728
|
+
if (v2) {
|
|
729
|
+
return { error: `Unsupported ID3 tag version: ${v2.version} (only ID3v2.3, ID3v2.4, and ID3v1/1.1 are supported)` };
|
|
730
|
+
}
|
|
731
|
+
return { error: "No ID3v1 or ID3v2.3/2.4 tags found in this file" };
|
|
732
|
+
}
|
|
466
733
|
|
|
467
|
-
export { media_exports, readExifData, readImageInfo, readPdfMetadata };
|
|
734
|
+
export { media_exports, readExifData, readId3Tags, readImageInfo, readPdfMetadata, readWavInfo };
|
|
@@ -7,6 +7,7 @@ var data_exports = {};
|
|
|
7
7
|
__export(data_exports, {
|
|
8
8
|
csvToJson: () => csvToJson,
|
|
9
9
|
detectDelimiter: () => detectDelimiter,
|
|
10
|
+
diffEnvExample: () => diffEnvExample,
|
|
10
11
|
envToExport: () => envToExport,
|
|
11
12
|
envToJson: () => envToJson,
|
|
12
13
|
formatNdjson: () => formatNdjson,
|
|
@@ -1081,6 +1082,23 @@ function envToExport(input) {
|
|
|
1081
1082
|
function validateEnvKey(key) {
|
|
1082
1083
|
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(key);
|
|
1083
1084
|
}
|
|
1085
|
+
function diffEnvExample(envInput, exampleInput) {
|
|
1086
|
+
const envParsed = parseEnv(envInput);
|
|
1087
|
+
if (envParsed.errors.length > 0) {
|
|
1088
|
+
return { error: `.env: ${envParsed.errors.map((e) => `Line ${e.line}: ${e.message}`).join("; ")}` };
|
|
1089
|
+
}
|
|
1090
|
+
const exampleParsed = parseEnv(exampleInput);
|
|
1091
|
+
if (exampleParsed.errors.length > 0) {
|
|
1092
|
+
return { error: `.env.example: ${exampleParsed.errors.map((e) => `Line ${e.line}: ${e.message}`).join("; ")}` };
|
|
1093
|
+
}
|
|
1094
|
+
const envKeys = new Set(envParsed.entries.map((e) => e.key));
|
|
1095
|
+
const exampleValues = new Map(exampleParsed.entries.map((e) => [e.key, e.value]));
|
|
1096
|
+
const missingInExample = [...envKeys].filter((k) => !exampleValues.has(k)).sort();
|
|
1097
|
+
const missingInEnv = [...exampleValues.keys()].filter((k) => !envKeys.has(k)).sort();
|
|
1098
|
+
const emptyValueInExample = [...exampleValues.entries()].filter(([k, v]) => envKeys.has(k) && v === "").map(([k]) => k).sort();
|
|
1099
|
+
const keysInBoth = [...envKeys].filter((k) => exampleValues.has(k)).length;
|
|
1100
|
+
return { missingInExample, missingInEnv, emptyValueInExample, keysInBoth };
|
|
1101
|
+
}
|
|
1084
1102
|
function validateNdjson(input) {
|
|
1085
1103
|
const rawLines = input.split("\n");
|
|
1086
1104
|
const lines = [];
|
|
@@ -1140,4 +1158,4 @@ function jsonArrayToNdjson(input) {
|
|
|
1140
1158
|
return parsed.map((item) => JSON.stringify(item)).join("\n");
|
|
1141
1159
|
}
|
|
1142
1160
|
|
|
1143
|
-
export { csvToJson, data_exports, detectDelimiter, envToExport, envToJson, formatNdjson, formatToml, formatXml, getSection, getSectionNames, getTomlStats, getXmlStats, getYamlStats, iniToJson, jsonArrayToNdjson, jsonToIni, jsonToToml, jsonToXml, minifyNdjson, minifyToml, minifyXml, ndjsonToJsonArray, parseCsv, parseEnv, parseIni, parseXmlToObject, stringifyIni, toCsvString, tomlToJson, validateEnvKey, validateIni, validateNdjson, validateToml, validateXml, validateYaml, xmlToJson };
|
|
1161
|
+
export { csvToJson, data_exports, detectDelimiter, diffEnvExample, envToExport, envToJson, formatNdjson, formatToml, formatXml, getSection, getSectionNames, getTomlStats, getXmlStats, getYamlStats, iniToJson, jsonArrayToNdjson, jsonToIni, jsonToToml, jsonToXml, minifyNdjson, minifyToml, minifyXml, ndjsonToJsonArray, parseCsv, parseEnv, parseIni, parseXmlToObject, stringifyIni, toCsvString, tomlToJson, validateEnvKey, validateIni, validateNdjson, validateToml, validateXml, validateYaml, xmlToJson };
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* - csv-viewer : detectDelimiter, parseCsv, csvToJson, toCsvString
|
|
11
11
|
* - ini-parser : parseIni, stringifyIni, iniToJson, jsonToIni, getSection, getSectionNames, validateIni
|
|
12
12
|
* - env-parser : parseEnv, envToJson, envToExport, validateEnvKey
|
|
13
|
+
* - env-diff-checker: diffEnvExample
|
|
13
14
|
* - ndjson-formatter: validateNdjson, minifyNdjson, formatNdjson, ndjsonToJsonArray, jsonArrayToNdjson
|
|
14
15
|
*/
|
|
15
16
|
interface ValidationResult {
|
|
@@ -168,6 +169,21 @@ declare function envToJson(input: string): string | {
|
|
|
168
169
|
};
|
|
169
170
|
declare function envToExport(input: string): string;
|
|
170
171
|
declare function validateEnvKey(key: string): boolean;
|
|
172
|
+
interface EnvDiffResult {
|
|
173
|
+
missingInExample: string[];
|
|
174
|
+
missingInEnv: string[];
|
|
175
|
+
emptyValueInExample: string[];
|
|
176
|
+
keysInBoth: number;
|
|
177
|
+
}
|
|
178
|
+
interface EnvDiffError {
|
|
179
|
+
error: string;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Diff a .env file against its .env.example template. Flags keys present in
|
|
183
|
+
* one file but not the other, plus keys that exist in both but whose
|
|
184
|
+
* .env.example value is an empty placeholder (i.e. undocumented default).
|
|
185
|
+
*/
|
|
186
|
+
declare function diffEnvExample(envInput: string, exampleInput: string): EnvDiffResult | EnvDiffError;
|
|
171
187
|
interface NdjsonLineResult {
|
|
172
188
|
line: number;
|
|
173
189
|
raw: string;
|
|
@@ -196,6 +212,8 @@ declare function jsonArrayToNdjson(input: string): string | {
|
|
|
196
212
|
};
|
|
197
213
|
|
|
198
214
|
type data_CsvParseResult = CsvParseResult;
|
|
215
|
+
type data_EnvDiffError = EnvDiffError;
|
|
216
|
+
type data_EnvDiffResult = EnvDiffResult;
|
|
199
217
|
type data_EnvEntry = EnvEntry;
|
|
200
218
|
type data_EnvParseResult = EnvParseResult;
|
|
201
219
|
type data_IniSection = IniSection;
|
|
@@ -209,6 +227,7 @@ type data_XmlFormatResult = XmlFormatResult;
|
|
|
209
227
|
type data_XmlToJsonOptions = XmlToJsonOptions;
|
|
210
228
|
declare const data_csvToJson: typeof csvToJson;
|
|
211
229
|
declare const data_detectDelimiter: typeof detectDelimiter;
|
|
230
|
+
declare const data_diffEnvExample: typeof diffEnvExample;
|
|
212
231
|
declare const data_envToExport: typeof envToExport;
|
|
213
232
|
declare const data_envToJson: typeof envToJson;
|
|
214
233
|
declare const data_formatNdjson: typeof formatNdjson;
|
|
@@ -243,7 +262,7 @@ declare const data_validateXml: typeof validateXml;
|
|
|
243
262
|
declare const data_validateYaml: typeof validateYaml;
|
|
244
263
|
declare const data_xmlToJson: typeof xmlToJson;
|
|
245
264
|
declare namespace data {
|
|
246
|
-
export { type data_CsvParseResult as CsvParseResult, type data_EnvEntry as EnvEntry, type data_EnvParseResult as EnvParseResult, type data_IniSection as IniSection, type data_NdjsonLineResult as NdjsonLineResult, type data_NdjsonValidateResult as NdjsonValidateResult, type data_ParseOptions as ParseOptions, type data_ParsedIni as ParsedIni, type data_TomlFormatResult as TomlFormatResult, type data_ValidationResult as ValidationResult, type data_XmlFormatResult as XmlFormatResult, type data_XmlToJsonOptions as XmlToJsonOptions, data_csvToJson as csvToJson, data_detectDelimiter as detectDelimiter, data_envToExport as envToExport, data_envToJson as envToJson, data_formatNdjson as formatNdjson, data_formatToml as formatToml, data_formatXml as formatXml, data_getSection as getSection, data_getSectionNames as getSectionNames, data_getTomlStats as getTomlStats, data_getXmlStats as getXmlStats, data_getYamlStats as getYamlStats, 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_parseIni as parseIni, data_parseXmlToObject as parseXmlToObject, 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 };
|
|
265
|
+
export { type data_CsvParseResult as CsvParseResult, type data_EnvDiffError as EnvDiffError, type data_EnvDiffResult as EnvDiffResult, type data_EnvEntry as EnvEntry, type data_EnvParseResult as EnvParseResult, type data_IniSection as IniSection, type data_NdjsonLineResult as NdjsonLineResult, type data_NdjsonValidateResult as NdjsonValidateResult, type data_ParseOptions as ParseOptions, type data_ParsedIni as ParsedIni, type data_TomlFormatResult as TomlFormatResult, type data_ValidationResult as ValidationResult, type data_XmlFormatResult as XmlFormatResult, type data_XmlToJsonOptions as XmlToJsonOptions, data_csvToJson as csvToJson, data_detectDelimiter as detectDelimiter, data_diffEnvExample as diffEnvExample, data_envToExport as envToExport, data_envToJson as envToJson, data_formatNdjson as formatNdjson, data_formatToml as formatToml, data_formatXml as formatXml, data_getSection as getSection, data_getSectionNames as getSectionNames, data_getTomlStats as getTomlStats, data_getXmlStats as getXmlStats, data_getYamlStats as getYamlStats, 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_parseIni as parseIni, data_parseXmlToObject as parseXmlToObject, 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 };
|
|
247
266
|
}
|
|
248
267
|
|
|
249
|
-
export {
|
|
268
|
+
export { minifyToml as A, minifyXml as B, type CsvParseResult as C, ndjsonToJsonArray as D, type EnvDiffError as E, parseCsv as F, parseEnv as G, parseIni as H, type IniSection as I, parseXmlToObject as J, stringifyIni as K, toCsvString as L, tomlToJson as M, type NdjsonLineResult as N, validateEnvKey as O, type ParseOptions as P, validateIni as Q, validateNdjson as R, validateToml as S, type TomlFormatResult as T, validateXml as U, type ValidationResult as V, validateYaml as W, type XmlFormatResult as X, xmlToJson as Y, type EnvDiffResult as a, type EnvEntry as b, type EnvParseResult as c, data as d, type NdjsonValidateResult as e, type ParsedIni as f, type XmlToJsonOptions as g, csvToJson as h, detectDelimiter as i, diffEnvExample as j, envToExport as k, envToJson as l, formatNdjson as m, formatToml as n, formatXml as o, getSection as p, getSectionNames as q, getTomlStats as r, getXmlStats as s, getYamlStats as t, iniToJson as u, jsonArrayToNdjson as v, jsonToIni as w, jsonToToml as x, jsonToXml as y, minifyNdjson as z };
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* - csv-viewer : detectDelimiter, parseCsv, csvToJson, toCsvString
|
|
11
11
|
* - ini-parser : parseIni, stringifyIni, iniToJson, jsonToIni, getSection, getSectionNames, validateIni
|
|
12
12
|
* - env-parser : parseEnv, envToJson, envToExport, validateEnvKey
|
|
13
|
+
* - env-diff-checker: diffEnvExample
|
|
13
14
|
* - ndjson-formatter: validateNdjson, minifyNdjson, formatNdjson, ndjsonToJsonArray, jsonArrayToNdjson
|
|
14
15
|
*/
|
|
15
16
|
interface ValidationResult {
|
|
@@ -168,6 +169,21 @@ declare function envToJson(input: string): string | {
|
|
|
168
169
|
};
|
|
169
170
|
declare function envToExport(input: string): string;
|
|
170
171
|
declare function validateEnvKey(key: string): boolean;
|
|
172
|
+
interface EnvDiffResult {
|
|
173
|
+
missingInExample: string[];
|
|
174
|
+
missingInEnv: string[];
|
|
175
|
+
emptyValueInExample: string[];
|
|
176
|
+
keysInBoth: number;
|
|
177
|
+
}
|
|
178
|
+
interface EnvDiffError {
|
|
179
|
+
error: string;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Diff a .env file against its .env.example template. Flags keys present in
|
|
183
|
+
* one file but not the other, plus keys that exist in both but whose
|
|
184
|
+
* .env.example value is an empty placeholder (i.e. undocumented default).
|
|
185
|
+
*/
|
|
186
|
+
declare function diffEnvExample(envInput: string, exampleInput: string): EnvDiffResult | EnvDiffError;
|
|
171
187
|
interface NdjsonLineResult {
|
|
172
188
|
line: number;
|
|
173
189
|
raw: string;
|
|
@@ -196,6 +212,8 @@ declare function jsonArrayToNdjson(input: string): string | {
|
|
|
196
212
|
};
|
|
197
213
|
|
|
198
214
|
type data_CsvParseResult = CsvParseResult;
|
|
215
|
+
type data_EnvDiffError = EnvDiffError;
|
|
216
|
+
type data_EnvDiffResult = EnvDiffResult;
|
|
199
217
|
type data_EnvEntry = EnvEntry;
|
|
200
218
|
type data_EnvParseResult = EnvParseResult;
|
|
201
219
|
type data_IniSection = IniSection;
|
|
@@ -209,6 +227,7 @@ type data_XmlFormatResult = XmlFormatResult;
|
|
|
209
227
|
type data_XmlToJsonOptions = XmlToJsonOptions;
|
|
210
228
|
declare const data_csvToJson: typeof csvToJson;
|
|
211
229
|
declare const data_detectDelimiter: typeof detectDelimiter;
|
|
230
|
+
declare const data_diffEnvExample: typeof diffEnvExample;
|
|
212
231
|
declare const data_envToExport: typeof envToExport;
|
|
213
232
|
declare const data_envToJson: typeof envToJson;
|
|
214
233
|
declare const data_formatNdjson: typeof formatNdjson;
|
|
@@ -243,7 +262,7 @@ declare const data_validateXml: typeof validateXml;
|
|
|
243
262
|
declare const data_validateYaml: typeof validateYaml;
|
|
244
263
|
declare const data_xmlToJson: typeof xmlToJson;
|
|
245
264
|
declare namespace data {
|
|
246
|
-
export { type data_CsvParseResult as CsvParseResult, type data_EnvEntry as EnvEntry, type data_EnvParseResult as EnvParseResult, type data_IniSection as IniSection, type data_NdjsonLineResult as NdjsonLineResult, type data_NdjsonValidateResult as NdjsonValidateResult, type data_ParseOptions as ParseOptions, type data_ParsedIni as ParsedIni, type data_TomlFormatResult as TomlFormatResult, type data_ValidationResult as ValidationResult, type data_XmlFormatResult as XmlFormatResult, type data_XmlToJsonOptions as XmlToJsonOptions, data_csvToJson as csvToJson, data_detectDelimiter as detectDelimiter, data_envToExport as envToExport, data_envToJson as envToJson, data_formatNdjson as formatNdjson, data_formatToml as formatToml, data_formatXml as formatXml, data_getSection as getSection, data_getSectionNames as getSectionNames, data_getTomlStats as getTomlStats, data_getXmlStats as getXmlStats, data_getYamlStats as getYamlStats, 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_parseIni as parseIni, data_parseXmlToObject as parseXmlToObject, 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 };
|
|
265
|
+
export { type data_CsvParseResult as CsvParseResult, type data_EnvDiffError as EnvDiffError, type data_EnvDiffResult as EnvDiffResult, type data_EnvEntry as EnvEntry, type data_EnvParseResult as EnvParseResult, type data_IniSection as IniSection, type data_NdjsonLineResult as NdjsonLineResult, type data_NdjsonValidateResult as NdjsonValidateResult, type data_ParseOptions as ParseOptions, type data_ParsedIni as ParsedIni, type data_TomlFormatResult as TomlFormatResult, type data_ValidationResult as ValidationResult, type data_XmlFormatResult as XmlFormatResult, type data_XmlToJsonOptions as XmlToJsonOptions, data_csvToJson as csvToJson, data_detectDelimiter as detectDelimiter, data_diffEnvExample as diffEnvExample, data_envToExport as envToExport, data_envToJson as envToJson, data_formatNdjson as formatNdjson, data_formatToml as formatToml, data_formatXml as formatXml, data_getSection as getSection, data_getSectionNames as getSectionNames, data_getTomlStats as getTomlStats, data_getXmlStats as getXmlStats, data_getYamlStats as getYamlStats, 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_parseIni as parseIni, data_parseXmlToObject as parseXmlToObject, 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 };
|
|
247
266
|
}
|
|
248
267
|
|
|
249
|
-
export {
|
|
268
|
+
export { minifyToml as A, minifyXml as B, type CsvParseResult as C, ndjsonToJsonArray as D, type EnvDiffError as E, parseCsv as F, parseEnv as G, parseIni as H, type IniSection as I, parseXmlToObject as J, stringifyIni as K, toCsvString as L, tomlToJson as M, type NdjsonLineResult as N, validateEnvKey as O, type ParseOptions as P, validateIni as Q, validateNdjson as R, validateToml as S, type TomlFormatResult as T, validateXml as U, type ValidationResult as V, validateYaml as W, type XmlFormatResult as X, xmlToJson as Y, type EnvDiffResult as a, type EnvEntry as b, type EnvParseResult as c, data as d, type NdjsonValidateResult as e, type ParsedIni as f, type XmlToJsonOptions as g, csvToJson as h, detectDelimiter as i, diffEnvExample as j, envToExport as k, envToJson as l, formatNdjson as m, formatToml as n, formatXml as o, getSection as p, getSectionNames as q, getTomlStats as r, getXmlStats as s, getYamlStats as t, iniToJson as u, jsonArrayToNdjson as v, jsonToIni as w, jsonToToml as x, jsonToXml as y, minifyNdjson as z };
|