@utilix-tech/sdk 0.7.0 → 0.9.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 +21 -3
- package/README.md +21 -6
- package/dist/{chunk-5CKOJXFU.js → chunk-GUUYEIU6.js} +211 -1
- package/dist/{chunk-V5JKVDBA.js → chunk-LI5AME5R.js} +93 -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 +320 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/{media-D66WnthC.d.cts → media-C3ZvGyKc.d.cts} +27 -2
- package/dist/{media-D66WnthC.d.ts → media-C3ZvGyKc.d.ts} +27 -2
- package/dist/{network-DwyAjwJS.d.ts → network-Cy02-FIO.d.cts} +40 -2
- package/dist/{network-DwyAjwJS.d.cts → network-Cy02-FIO.d.ts} +40 -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 +210 -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 +91 -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 +8 -3
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* - http-status : HTTP status code lookup and search
|
|
9
9
|
* - http-headers : HTTP header reference lookup and validation
|
|
10
10
|
* - har-viewer : parseHar
|
|
11
|
+
* - sitemap-validator: validateSitemap
|
|
11
12
|
*/
|
|
12
13
|
declare const DNS_RECORD_TYPES: readonly ["A", "AAAA", "CNAME", "MX", "TXT", "NS", "SOA", "PTR", "SRV", "CAA"];
|
|
13
14
|
type DnsRecordType = typeof DNS_RECORD_TYPES[number];
|
|
@@ -157,6 +158,38 @@ interface HarParseResult {
|
|
|
157
158
|
declare function parseHar(input: string): HarParseResult | {
|
|
158
159
|
error: string;
|
|
159
160
|
};
|
|
161
|
+
interface SitemapUrlEntry {
|
|
162
|
+
loc: string;
|
|
163
|
+
lastmod?: string;
|
|
164
|
+
changefreq?: string;
|
|
165
|
+
priority?: string;
|
|
166
|
+
line: number;
|
|
167
|
+
}
|
|
168
|
+
interface SitemapIndexEntry {
|
|
169
|
+
loc: string;
|
|
170
|
+
lastmod?: string;
|
|
171
|
+
line: number;
|
|
172
|
+
}
|
|
173
|
+
interface SitemapIssue {
|
|
174
|
+
severity: 'error' | 'warning';
|
|
175
|
+
line: number;
|
|
176
|
+
message: string;
|
|
177
|
+
}
|
|
178
|
+
interface SitemapValidationResult {
|
|
179
|
+
type: 'urlset' | 'sitemapindex';
|
|
180
|
+
urlCount: number;
|
|
181
|
+
entries: SitemapUrlEntry[] | SitemapIndexEntry[];
|
|
182
|
+
issues: SitemapIssue[];
|
|
183
|
+
valid: boolean;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Validate a sitemap.xml (urlset) or sitemap index (sitemapindex) against the
|
|
187
|
+
* sitemaps.org protocol: required <loc>, absolute URLs, valid <changefreq>/
|
|
188
|
+
* <priority>/<lastmod> values, the 50,000-URL limit, and duplicate entries.
|
|
189
|
+
*/
|
|
190
|
+
declare function validateSitemap(xml: string): SitemapValidationResult | {
|
|
191
|
+
error: string;
|
|
192
|
+
};
|
|
160
193
|
|
|
161
194
|
declare const network_DNS_RECORD_TYPES: typeof DNS_RECORD_TYPES;
|
|
162
195
|
type network_DnsRecord = DnsRecord;
|
|
@@ -172,6 +205,10 @@ type network_HttpHeader = HttpHeader;
|
|
|
172
205
|
type network_ParsedDnsResult = ParsedDnsResult;
|
|
173
206
|
type network_ParsedGeoResult = ParsedGeoResult;
|
|
174
207
|
declare const network_STATUS_CODES: typeof STATUS_CODES;
|
|
208
|
+
type network_SitemapIndexEntry = SitemapIndexEntry;
|
|
209
|
+
type network_SitemapIssue = SitemapIssue;
|
|
210
|
+
type network_SitemapUrlEntry = SitemapUrlEntry;
|
|
211
|
+
type network_SitemapValidationResult = SitemapValidationResult;
|
|
175
212
|
type network_StatusCode = StatusCode;
|
|
176
213
|
declare const network_buildDnsQueryUrl: typeof buildDnsQueryUrl;
|
|
177
214
|
declare const network_buildGeoUrl: typeof buildGeoUrl;
|
|
@@ -200,8 +237,9 @@ declare const network_typeNumberToLabel: typeof typeNumberToLabel;
|
|
|
200
237
|
declare const network_validateDomain: typeof validateDomain;
|
|
201
238
|
declare const network_validateHeaderName: typeof validateHeaderName;
|
|
202
239
|
declare const network_validateHeaderValue: typeof validateHeaderValue;
|
|
240
|
+
declare const network_validateSitemap: typeof validateSitemap;
|
|
203
241
|
declare namespace network {
|
|
204
|
-
export { network_DNS_RECORD_TYPES as DNS_RECORD_TYPES, type network_DnsRecord as DnsRecord, type network_DnsRecordType as DnsRecordType, type network_DnsResponse as DnsResponse, type network_GeoResult as GeoResult, network_HTTP_HEADERS as HTTP_HEADERS, type network_HarEntry as HarEntry, type network_HarParseResult as HarParseResult, type network_HarSummary as HarSummary, type network_HeaderCategory as HeaderCategory, type network_HttpHeader as HttpHeader, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, network_STATUS_CODES as STATUS_CODES, type network_StatusCode as StatusCode, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_countryCodeToFlag as countryCodeToFlag, network_formatCoordinates as formatCoordinates, network_formatTtl as formatTtl, network_getByCategory as getByCategory, network_getHeader as getHeader, network_getHeadersByCategory as getHeadersByCategory, network_getStatusByCategory as getStatusByCategory, network_getStatusCode as getStatusCode, network_isClientError as isClientError, network_isServerError as isServerError, network_isSuccess as isSuccess, network_isValidIp as isValidIp, network_isValidIpv4 as isValidIpv4, network_isValidIpv6 as isValidIpv6, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_searchHeaders as searchHeaders, network_searchStatusCodes as searchStatusCodes, network_statusCodeToText as statusCodeToText, network_typeNumberToLabel as typeNumberToLabel, network_validateDomain as validateDomain, network_validateHeaderName as validateHeaderName, network_validateHeaderValue as validateHeaderValue };
|
|
242
|
+
export { network_DNS_RECORD_TYPES as DNS_RECORD_TYPES, type network_DnsRecord as DnsRecord, type network_DnsRecordType as DnsRecordType, type network_DnsResponse as DnsResponse, type network_GeoResult as GeoResult, network_HTTP_HEADERS as HTTP_HEADERS, type network_HarEntry as HarEntry, type network_HarParseResult as HarParseResult, type network_HarSummary as HarSummary, type network_HeaderCategory as HeaderCategory, type network_HttpHeader as HttpHeader, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, network_STATUS_CODES as STATUS_CODES, type network_SitemapIndexEntry as SitemapIndexEntry, type network_SitemapIssue as SitemapIssue, type network_SitemapUrlEntry as SitemapUrlEntry, type network_SitemapValidationResult as SitemapValidationResult, type network_StatusCode as StatusCode, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_countryCodeToFlag as countryCodeToFlag, network_formatCoordinates as formatCoordinates, network_formatTtl as formatTtl, network_getByCategory as getByCategory, network_getHeader as getHeader, network_getHeadersByCategory as getHeadersByCategory, network_getStatusByCategory as getStatusByCategory, network_getStatusCode as getStatusCode, network_isClientError as isClientError, network_isServerError as isServerError, network_isSuccess as isSuccess, network_isValidIp as isValidIp, network_isValidIpv4 as isValidIpv4, network_isValidIpv6 as isValidIpv6, network_parseDnsResponse as parseDnsResponse, network_parseGeoResponse as parseGeoResponse, network_parseHar as parseHar, network_searchHeaders as searchHeaders, network_searchStatusCodes as searchStatusCodes, network_statusCodeToText as statusCodeToText, network_typeNumberToLabel as typeNumberToLabel, network_validateDomain as validateDomain, network_validateHeaderName as validateHeaderName, network_validateHeaderValue as validateHeaderValue, network_validateSitemap as validateSitemap };
|
|
205
243
|
}
|
|
206
244
|
|
|
207
|
-
export {
|
|
245
|
+
export { isClientError as A, isServerError as B, isSuccess as C, DNS_RECORD_TYPES as D, isValidIp as E, isValidIpv4 as F, type GeoResult as G, HTTP_HEADERS as H, isValidIpv6 as I, parseDnsResponse as J, parseGeoResponse as K, parseHar as L, searchHeaders as M, searchStatusCodes as N, statusCodeToText as O, type ParsedDnsResult as P, typeNumberToLabel as Q, validateDomain as R, STATUS_CODES as S, validateHeaderName as T, validateHeaderValue as U, validateSitemap as V, type DnsRecord as a, type DnsRecordType as b, type DnsResponse as c, type HarEntry as d, type HarParseResult as e, type HarSummary as f, type HeaderCategory as g, type HttpHeader as h, type ParsedGeoResult as i, type SitemapIndexEntry as j, type SitemapIssue as k, type SitemapUrlEntry as l, type SitemapValidationResult as m, network as n, type StatusCode as o, buildDnsQueryUrl as p, buildGeoUrl as q, buildMapUrl as r, countryCodeToFlag as s, formatCoordinates as t, formatTtl as u, getByCategory as v, getHeader as w, getHeadersByCategory as x, getStatusByCategory as y, getStatusCode as z };
|
package/dist/tools/data.cjs
CHANGED
|
@@ -1064,6 +1064,23 @@ function envToExport(input) {
|
|
|
1064
1064
|
function validateEnvKey(key) {
|
|
1065
1065
|
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(key);
|
|
1066
1066
|
}
|
|
1067
|
+
function diffEnvExample(envInput, exampleInput) {
|
|
1068
|
+
const envParsed = parseEnv(envInput);
|
|
1069
|
+
if (envParsed.errors.length > 0) {
|
|
1070
|
+
return { error: `.env: ${envParsed.errors.map((e) => `Line ${e.line}: ${e.message}`).join("; ")}` };
|
|
1071
|
+
}
|
|
1072
|
+
const exampleParsed = parseEnv(exampleInput);
|
|
1073
|
+
if (exampleParsed.errors.length > 0) {
|
|
1074
|
+
return { error: `.env.example: ${exampleParsed.errors.map((e) => `Line ${e.line}: ${e.message}`).join("; ")}` };
|
|
1075
|
+
}
|
|
1076
|
+
const envKeys = new Set(envParsed.entries.map((e) => e.key));
|
|
1077
|
+
const exampleValues = new Map(exampleParsed.entries.map((e) => [e.key, e.value]));
|
|
1078
|
+
const missingInExample = [...envKeys].filter((k) => !exampleValues.has(k)).sort();
|
|
1079
|
+
const missingInEnv = [...exampleValues.keys()].filter((k) => !envKeys.has(k)).sort();
|
|
1080
|
+
const emptyValueInExample = [...exampleValues.entries()].filter(([k, v]) => envKeys.has(k) && v === "").map(([k]) => k).sort();
|
|
1081
|
+
const keysInBoth = [...envKeys].filter((k) => exampleValues.has(k)).length;
|
|
1082
|
+
return { missingInExample, missingInEnv, emptyValueInExample, keysInBoth };
|
|
1083
|
+
}
|
|
1067
1084
|
function validateNdjson(input) {
|
|
1068
1085
|
const rawLines = input.split("\n");
|
|
1069
1086
|
const lines = [];
|
|
@@ -1125,6 +1142,7 @@ function jsonArrayToNdjson(input) {
|
|
|
1125
1142
|
|
|
1126
1143
|
exports.csvToJson = csvToJson;
|
|
1127
1144
|
exports.detectDelimiter = detectDelimiter;
|
|
1145
|
+
exports.diffEnvExample = diffEnvExample;
|
|
1128
1146
|
exports.envToExport = envToExport;
|
|
1129
1147
|
exports.envToJson = envToJson;
|
|
1130
1148
|
exports.formatNdjson = formatNdjson;
|
package/dist/tools/data.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as CsvParseResult, E as
|
|
1
|
+
export { C as CsvParseResult, E as EnvDiffError, a as EnvDiffResult, b as EnvEntry, c as EnvParseResult, I as IniSection, N as NdjsonLineResult, e as NdjsonValidateResult, P as ParseOptions, f as ParsedIni, T as TomlFormatResult, V as ValidationResult, X as XmlFormatResult, g as XmlToJsonOptions, h as csvToJson, i as detectDelimiter, j as diffEnvExample, k as envToExport, l as envToJson, m as formatNdjson, n as formatToml, o as formatXml, p as getSection, q as getSectionNames, r as getTomlStats, s as getXmlStats, t as getYamlStats, u as iniToJson, v as jsonArrayToNdjson, w as jsonToIni, x as jsonToToml, y as jsonToXml, z as minifyNdjson, A as minifyToml, B as minifyXml, D as ndjsonToJsonArray, F as parseCsv, G as parseEnv, H as parseIni, J as parseXmlToObject, K as stringifyIni, L as toCsvString, M as tomlToJson, O as validateEnvKey, Q as validateIni, R as validateNdjson, S as validateToml, U as validateXml, W as validateYaml, Y as xmlToJson } from '../data-D8XTI7Du.cjs';
|
package/dist/tools/data.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { C as CsvParseResult, E as
|
|
1
|
+
export { C as CsvParseResult, E as EnvDiffError, a as EnvDiffResult, b as EnvEntry, c as EnvParseResult, I as IniSection, N as NdjsonLineResult, e as NdjsonValidateResult, P as ParseOptions, f as ParsedIni, T as TomlFormatResult, V as ValidationResult, X as XmlFormatResult, g as XmlToJsonOptions, h as csvToJson, i as detectDelimiter, j as diffEnvExample, k as envToExport, l as envToJson, m as formatNdjson, n as formatToml, o as formatXml, p as getSection, q as getSectionNames, r as getTomlStats, s as getXmlStats, t as getYamlStats, u as iniToJson, v as jsonArrayToNdjson, w as jsonToIni, x as jsonToToml, y as jsonToXml, z as minifyNdjson, A as minifyToml, B as minifyXml, D as ndjsonToJsonArray, F as parseCsv, G as parseEnv, H as parseIni, J as parseXmlToObject, K as stringifyIni, L as toCsvString, M as tomlToJson, O as validateEnvKey, Q as validateIni, R as validateNdjson, S as validateToml, U as validateXml, W as validateYaml, Y as xmlToJson } from '../data-D8XTI7Du.js';
|
package/dist/tools/data.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { csvToJson, 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 } from '../chunk-
|
|
1
|
+
export { csvToJson, 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 } from '../chunk-TINQFTLO.js';
|
|
2
2
|
import '../chunk-MLKGABMK.js';
|
package/dist/tools/media.cjs
CHANGED
|
@@ -513,8 +513,218 @@ function readWavInfo(bytes) {
|
|
|
513
513
|
fileSize
|
|
514
514
|
};
|
|
515
515
|
}
|
|
516
|
+
var ID3V1_GENRES = [
|
|
517
|
+
"Blues",
|
|
518
|
+
"Classic Rock",
|
|
519
|
+
"Country",
|
|
520
|
+
"Dance",
|
|
521
|
+
"Disco",
|
|
522
|
+
"Funk",
|
|
523
|
+
"Grunge",
|
|
524
|
+
"Hip-Hop",
|
|
525
|
+
"Jazz",
|
|
526
|
+
"Metal",
|
|
527
|
+
"New Age",
|
|
528
|
+
"Oldies",
|
|
529
|
+
"Other",
|
|
530
|
+
"Pop",
|
|
531
|
+
"R&B",
|
|
532
|
+
"Rap",
|
|
533
|
+
"Reggae",
|
|
534
|
+
"Rock",
|
|
535
|
+
"Techno",
|
|
536
|
+
"Industrial",
|
|
537
|
+
"Alternative",
|
|
538
|
+
"Ska",
|
|
539
|
+
"Death Metal",
|
|
540
|
+
"Pranks",
|
|
541
|
+
"Soundtrack",
|
|
542
|
+
"Euro-Techno",
|
|
543
|
+
"Ambient",
|
|
544
|
+
"Trip-Hop",
|
|
545
|
+
"Vocal",
|
|
546
|
+
"Jazz+Funk",
|
|
547
|
+
"Fusion",
|
|
548
|
+
"Trance",
|
|
549
|
+
"Classical",
|
|
550
|
+
"Instrumental",
|
|
551
|
+
"Acid",
|
|
552
|
+
"House",
|
|
553
|
+
"Game",
|
|
554
|
+
"Sound Clip",
|
|
555
|
+
"Gospel",
|
|
556
|
+
"Noise",
|
|
557
|
+
"AlternRock",
|
|
558
|
+
"Bass",
|
|
559
|
+
"Soul",
|
|
560
|
+
"Punk",
|
|
561
|
+
"Space",
|
|
562
|
+
"Meditative",
|
|
563
|
+
"Instrumental Pop",
|
|
564
|
+
"Instrumental Rock",
|
|
565
|
+
"Ethnic",
|
|
566
|
+
"Gothic",
|
|
567
|
+
"Darkwave",
|
|
568
|
+
"Techno-Industrial",
|
|
569
|
+
"Electronic",
|
|
570
|
+
"Pop-Folk",
|
|
571
|
+
"Eurodance",
|
|
572
|
+
"Dream",
|
|
573
|
+
"Southern Rock",
|
|
574
|
+
"Comedy",
|
|
575
|
+
"Cult",
|
|
576
|
+
"Gangsta",
|
|
577
|
+
"Top 40",
|
|
578
|
+
"Christian Rap",
|
|
579
|
+
"Pop/Funk",
|
|
580
|
+
"Jungle",
|
|
581
|
+
"Native American",
|
|
582
|
+
"Cabaret",
|
|
583
|
+
"New Wave",
|
|
584
|
+
"Psychedelic",
|
|
585
|
+
"Rave",
|
|
586
|
+
"Showtunes",
|
|
587
|
+
"Trailer",
|
|
588
|
+
"Lo-Fi",
|
|
589
|
+
"Tribal",
|
|
590
|
+
"Acid Punk",
|
|
591
|
+
"Acid Jazz",
|
|
592
|
+
"Polka",
|
|
593
|
+
"Retro",
|
|
594
|
+
"Musical",
|
|
595
|
+
"Rock & Roll",
|
|
596
|
+
"Hard Rock"
|
|
597
|
+
];
|
|
598
|
+
function readSynchsafeUInt32(bytes, offset) {
|
|
599
|
+
return (bytes[offset] & 127) << 21 | (bytes[offset + 1] & 127) << 14 | (bytes[offset + 2] & 127) << 7 | bytes[offset + 3] & 127;
|
|
600
|
+
}
|
|
601
|
+
function readUInt32BE(bytes, offset) {
|
|
602
|
+
return (bytes[offset] << 24 | bytes[offset + 1] << 16 | bytes[offset + 2] << 8 | bytes[offset + 3]) >>> 0;
|
|
603
|
+
}
|
|
604
|
+
function decodeId3Text(frameBytes) {
|
|
605
|
+
if (frameBytes.length === 0) return "";
|
|
606
|
+
const encodingByte = frameBytes[0];
|
|
607
|
+
const content = frameBytes.subarray(1);
|
|
608
|
+
let out = "";
|
|
609
|
+
if (encodingByte === 3) {
|
|
610
|
+
out = Buffer.from(content).toString("utf8");
|
|
611
|
+
} else if (encodingByte === 1 || encodingByte === 2) {
|
|
612
|
+
let little = encodingByte === 1;
|
|
613
|
+
let start = 0;
|
|
614
|
+
if (encodingByte === 1 && content.length >= 2) {
|
|
615
|
+
if (content[0] === 255 && content[1] === 254) {
|
|
616
|
+
little = true;
|
|
617
|
+
start = 2;
|
|
618
|
+
} else if (content[0] === 254 && content[1] === 255) {
|
|
619
|
+
little = false;
|
|
620
|
+
start = 2;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
for (let i = start; i + 1 < content.length; i += 2) {
|
|
624
|
+
const code = little ? content[i] | content[i + 1] << 8 : content[i] << 8 | content[i + 1];
|
|
625
|
+
if (code === 0) break;
|
|
626
|
+
out += String.fromCharCode(code);
|
|
627
|
+
}
|
|
628
|
+
} else {
|
|
629
|
+
for (const b of content) {
|
|
630
|
+
if (b === 0) break;
|
|
631
|
+
out += String.fromCharCode(b);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return out.replace(/\0+$/, "").trim();
|
|
635
|
+
}
|
|
636
|
+
function readId3v2(bytes) {
|
|
637
|
+
if (bytes.length < 10 || bytes[0] !== 73 || bytes[1] !== 68 || bytes[2] !== 51) return null;
|
|
638
|
+
const majorVersion = bytes[3];
|
|
639
|
+
const revision = bytes[4];
|
|
640
|
+
const tagSize = readSynchsafeUInt32(bytes, 6);
|
|
641
|
+
const version = `ID3v2.${majorVersion}.${revision}`;
|
|
642
|
+
if (majorVersion !== 3 && majorVersion !== 4) {
|
|
643
|
+
return { version, frames: {}, frameCount: 0 };
|
|
644
|
+
}
|
|
645
|
+
const frames = {};
|
|
646
|
+
let offset = 10;
|
|
647
|
+
const end = Math.min(10 + tagSize, bytes.length);
|
|
648
|
+
let frameCount = 0;
|
|
649
|
+
while (offset + 10 <= end) {
|
|
650
|
+
const frameId = String.fromCharCode(bytes[offset], bytes[offset + 1], bytes[offset + 2], bytes[offset + 3]);
|
|
651
|
+
if (frameId === "\0\0\0\0") break;
|
|
652
|
+
const frameSize = majorVersion === 4 ? readSynchsafeUInt32(bytes, offset + 4) : readUInt32BE(bytes, offset + 4);
|
|
653
|
+
const frameStart = offset + 10;
|
|
654
|
+
if (frameSize <= 0 || frameStart + frameSize > bytes.length) break;
|
|
655
|
+
const frameBytes = bytes.subarray(frameStart, frameStart + frameSize);
|
|
656
|
+
if (frameId[0] === "T" && frameId !== "TXXX") {
|
|
657
|
+
frames[frameId] = decodeId3Text(frameBytes);
|
|
658
|
+
} else if (frameId === "COMM" && frameBytes.length > 4) {
|
|
659
|
+
const rebuilt = new Uint8Array(frameBytes.length - 3);
|
|
660
|
+
rebuilt[0] = frameBytes[0];
|
|
661
|
+
rebuilt.set(frameBytes.subarray(4), 1);
|
|
662
|
+
const decoded = decodeId3Text(rebuilt);
|
|
663
|
+
const parts = decoded.split("\0");
|
|
664
|
+
frames["COMM"] = (parts[parts.length - 1] || decoded).trim();
|
|
665
|
+
}
|
|
666
|
+
frameCount++;
|
|
667
|
+
offset = frameStart + frameSize;
|
|
668
|
+
}
|
|
669
|
+
return { version, frames, frameCount };
|
|
670
|
+
}
|
|
671
|
+
function readId3v1(bytes) {
|
|
672
|
+
if (bytes.length < 128) return null;
|
|
673
|
+
const start = bytes.length - 128;
|
|
674
|
+
if (String.fromCharCode(bytes[start], bytes[start + 1], bytes[start + 2]) !== "TAG") return null;
|
|
675
|
+
const readField = (offset, length) => {
|
|
676
|
+
let s = "";
|
|
677
|
+
for (let i = 0; i < length; i++) {
|
|
678
|
+
const b = bytes[start + offset + i];
|
|
679
|
+
if (b === 0) break;
|
|
680
|
+
s += String.fromCharCode(b);
|
|
681
|
+
}
|
|
682
|
+
return s.trim();
|
|
683
|
+
};
|
|
684
|
+
const title = readField(3, 30);
|
|
685
|
+
const artist = readField(33, 30);
|
|
686
|
+
const album = readField(63, 30);
|
|
687
|
+
const year = readField(93, 4);
|
|
688
|
+
const isV11 = bytes[start + 125] === 0 && bytes[start + 126] !== 0;
|
|
689
|
+
const comment = readField(97, isV11 ? 28 : 30);
|
|
690
|
+
const genreIndex = bytes[start + 127];
|
|
691
|
+
const genre = ID3V1_GENRES[genreIndex] ?? `Unknown (${genreIndex})`;
|
|
692
|
+
const result = { genre };
|
|
693
|
+
if (title) result.title = title;
|
|
694
|
+
if (artist) result.artist = artist;
|
|
695
|
+
if (album) result.album = album;
|
|
696
|
+
if (year) result.year = year;
|
|
697
|
+
if (comment) result.comment = comment;
|
|
698
|
+
if (isV11) result.trackNumber = String(bytes[start + 126]);
|
|
699
|
+
return result;
|
|
700
|
+
}
|
|
701
|
+
function readId3Tags(bytes) {
|
|
702
|
+
const v2 = readId3v2(bytes);
|
|
703
|
+
const v1 = readId3v1(bytes);
|
|
704
|
+
if (v2 && Object.keys(v2.frames).length > 0) {
|
|
705
|
+
const f = v2.frames;
|
|
706
|
+
const result = { version: v2.version, frameCount: v2.frameCount };
|
|
707
|
+
if (f["TIT2"]) result.title = f["TIT2"];
|
|
708
|
+
if (f["TPE1"]) result.artist = f["TPE1"];
|
|
709
|
+
if (f["TALB"]) result.album = f["TALB"];
|
|
710
|
+
const year = f["TYER"] || f["TDRC"];
|
|
711
|
+
if (year) result.year = year;
|
|
712
|
+
if (f["TCON"]) result.genre = f["TCON"];
|
|
713
|
+
if (f["COMM"]) result.comment = f["COMM"];
|
|
714
|
+
if (f["TRCK"]) result.trackNumber = f["TRCK"];
|
|
715
|
+
return result;
|
|
716
|
+
}
|
|
717
|
+
if (v1) {
|
|
718
|
+
return { version: v1.trackNumber !== void 0 ? "ID3v1.1" : "ID3v1", ...v1 };
|
|
719
|
+
}
|
|
720
|
+
if (v2) {
|
|
721
|
+
return { error: `Unsupported ID3 tag version: ${v2.version} (only ID3v2.3, ID3v2.4, and ID3v1/1.1 are supported)` };
|
|
722
|
+
}
|
|
723
|
+
return { error: "No ID3v1 or ID3v2.3/2.4 tags found in this file" };
|
|
724
|
+
}
|
|
516
725
|
|
|
517
726
|
exports.readExifData = readExifData;
|
|
727
|
+
exports.readId3Tags = readId3Tags;
|
|
518
728
|
exports.readImageInfo = readImageInfo;
|
|
519
729
|
exports.readPdfMetadata = readPdfMetadata;
|
|
520
730
|
exports.readWavInfo = readWavInfo;
|
package/dist/tools/media.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { E as ExifData, a as ExifError, I as
|
|
1
|
+
export { E as ExifData, a as ExifError, I as Id3Tags, b as Id3TagsError, c as ImageFormat, d as ImageInfo, e as ImageInfoError, P as PdfMetadata, f as PdfMetadataError, W as WavInfo, g as WavInfoError, r as readExifData, h as readId3Tags, i as readImageInfo, j as readPdfMetadata, k as readWavInfo } from '../media-C3ZvGyKc.cjs';
|
package/dist/tools/media.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { E as ExifData, a as ExifError, I as
|
|
1
|
+
export { E as ExifData, a as ExifError, I as Id3Tags, b as Id3TagsError, c as ImageFormat, d as ImageInfo, e as ImageInfoError, P as PdfMetadata, f as PdfMetadataError, W as WavInfo, g as WavInfoError, r as readExifData, h as readId3Tags, i as readImageInfo, j as readPdfMetadata, k as readWavInfo } from '../media-C3ZvGyKc.js';
|
package/dist/tools/media.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { readExifData, readImageInfo, readPdfMetadata, readWavInfo } from '../chunk-
|
|
1
|
+
export { readExifData, readId3Tags, readImageInfo, readPdfMetadata, readWavInfo } from '../chunk-GUUYEIU6.js';
|
|
2
2
|
import '../chunk-MLKGABMK.js';
|
package/dist/tools/network.cjs
CHANGED
|
@@ -1407,6 +1407,96 @@ function parseHar(input) {
|
|
|
1407
1407
|
summary: { totalRequests, totalSize, totalTime, avgTime, failedRequests, methods, statusCodes }
|
|
1408
1408
|
};
|
|
1409
1409
|
}
|
|
1410
|
+
var VALID_CHANGEFREQ = /* @__PURE__ */ new Set(["always", "hourly", "daily", "weekly", "monthly", "yearly", "never"]);
|
|
1411
|
+
function sitemapLineNumber(xml, index) {
|
|
1412
|
+
let line = 1;
|
|
1413
|
+
for (let i = 0; i < index; i++) {
|
|
1414
|
+
if (xml[i] === "\n") line++;
|
|
1415
|
+
}
|
|
1416
|
+
return line;
|
|
1417
|
+
}
|
|
1418
|
+
function extractSitemapTag(block, tag) {
|
|
1419
|
+
const m = block.match(new RegExp(`<${tag}[^>]*>([\\s\\S]*?)</${tag}>`, "i"));
|
|
1420
|
+
return m ? m[1].trim() : void 0;
|
|
1421
|
+
}
|
|
1422
|
+
function isValidW3CDatetime(s) {
|
|
1423
|
+
return /^\d{4}(-\d{2}(-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2}))?)?)?$/.test(s);
|
|
1424
|
+
}
|
|
1425
|
+
function isAbsoluteHttpUrl(s) {
|
|
1426
|
+
return /^https?:\/\//i.test(s);
|
|
1427
|
+
}
|
|
1428
|
+
function validateSitemap(xml) {
|
|
1429
|
+
if (!xml || !xml.trim()) return { error: "Input is empty" };
|
|
1430
|
+
const trimmed = xml.trim();
|
|
1431
|
+
const issues = [];
|
|
1432
|
+
if (!/^\s*<\?xml/i.test(trimmed)) {
|
|
1433
|
+
issues.push({ severity: "warning", line: 1, message: 'Missing XML declaration (<?xml version="1.0" encoding="UTF-8"?>)' });
|
|
1434
|
+
}
|
|
1435
|
+
const isUrlset = /<urlset[\s>]/i.test(trimmed);
|
|
1436
|
+
const isSitemapIndex = /<sitemapindex[\s>]/i.test(trimmed);
|
|
1437
|
+
if (!isUrlset && !isSitemapIndex) {
|
|
1438
|
+
return { error: "Not a valid sitemap: root element must be <urlset> or <sitemapindex>" };
|
|
1439
|
+
}
|
|
1440
|
+
if (isUrlset && isSitemapIndex) {
|
|
1441
|
+
return { error: "Ambiguous file: contains both <urlset> and <sitemapindex> root elements" };
|
|
1442
|
+
}
|
|
1443
|
+
const type = isUrlset ? "urlset" : "sitemapindex";
|
|
1444
|
+
if (isUrlset && !/xmlns\s*=\s*["']http:\/\/www\.sitemaps\.org\/schemas\/sitemap\/0\.9["']/i.test(trimmed)) {
|
|
1445
|
+
issues.push({ severity: "warning", line: 1, message: "Missing or non-standard xmlns namespace (expected http://www.sitemaps.org/schemas/sitemap/0.9)" });
|
|
1446
|
+
}
|
|
1447
|
+
const blockTag = isUrlset ? "url" : "sitemap";
|
|
1448
|
+
const blockRe = new RegExp(`<${blockTag}>([\\s\\S]*?)</${blockTag}>`, "gi");
|
|
1449
|
+
const seenLocs = /* @__PURE__ */ new Set();
|
|
1450
|
+
const entries = [];
|
|
1451
|
+
let match;
|
|
1452
|
+
while ((match = blockRe.exec(trimmed)) !== null) {
|
|
1453
|
+
const block = match[1];
|
|
1454
|
+
const line = sitemapLineNumber(trimmed, match.index);
|
|
1455
|
+
const loc = extractSitemapTag(block, "loc");
|
|
1456
|
+
if (!loc) {
|
|
1457
|
+
issues.push({ severity: "error", line, message: `<${blockTag}> entry is missing required <loc>` });
|
|
1458
|
+
continue;
|
|
1459
|
+
}
|
|
1460
|
+
if (!isAbsoluteHttpUrl(loc)) {
|
|
1461
|
+
issues.push({ severity: "error", line, message: `<loc>${loc}</loc> must be an absolute URL starting with http:// or https://` });
|
|
1462
|
+
}
|
|
1463
|
+
if (/&(?!amp;|lt;|gt;|apos;|quot;|#\d+;)/.test(loc)) {
|
|
1464
|
+
issues.push({ severity: "error", line, message: `<loc>${loc}</loc> contains an unescaped '&' (use & instead)` });
|
|
1465
|
+
}
|
|
1466
|
+
if (seenLocs.has(loc)) {
|
|
1467
|
+
issues.push({ severity: "warning", line, message: `Duplicate <loc>${loc}</loc>` });
|
|
1468
|
+
}
|
|
1469
|
+
seenLocs.add(loc);
|
|
1470
|
+
const lastmod = extractSitemapTag(block, "lastmod");
|
|
1471
|
+
if (lastmod !== void 0 && !isValidW3CDatetime(lastmod)) {
|
|
1472
|
+
issues.push({ severity: "warning", line, message: `<lastmod>${lastmod}</lastmod> is not a valid W3C datetime` });
|
|
1473
|
+
}
|
|
1474
|
+
if (type === "urlset") {
|
|
1475
|
+
const changefreq = extractSitemapTag(block, "changefreq");
|
|
1476
|
+
if (changefreq !== void 0 && !VALID_CHANGEFREQ.has(changefreq.toLowerCase())) {
|
|
1477
|
+
issues.push({ severity: "error", line, message: `<changefreq>${changefreq}</changefreq> must be one of: ${[...VALID_CHANGEFREQ].join(", ")}` });
|
|
1478
|
+
}
|
|
1479
|
+
const priority = extractSitemapTag(block, "priority");
|
|
1480
|
+
if (priority !== void 0) {
|
|
1481
|
+
const p = Number(priority);
|
|
1482
|
+
if (Number.isNaN(p) || p < 0 || p > 1) {
|
|
1483
|
+
issues.push({ severity: "error", line, message: `<priority>${priority}</priority> must be a number between 0.0 and 1.0` });
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
entries.push({ loc, lastmod, changefreq, priority, line });
|
|
1487
|
+
} else {
|
|
1488
|
+
entries.push({ loc, lastmod, line });
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
if (entries.length === 0) {
|
|
1492
|
+
issues.push({ severity: "error", line: 1, message: `No <${blockTag}> entries found` });
|
|
1493
|
+
}
|
|
1494
|
+
if (type === "urlset" && entries.length > 5e4) {
|
|
1495
|
+
issues.push({ severity: "error", line: 1, message: `Sitemap contains ${entries.length} URLs, exceeding the 50,000 URL limit per the sitemaps.org spec` });
|
|
1496
|
+
}
|
|
1497
|
+
const valid = !issues.some((i) => i.severity === "error");
|
|
1498
|
+
return { type, urlCount: entries.length, entries, issues, valid };
|
|
1499
|
+
}
|
|
1410
1500
|
|
|
1411
1501
|
exports.DNS_RECORD_TYPES = DNS_RECORD_TYPES;
|
|
1412
1502
|
exports.HTTP_HEADERS = HTTP_HEADERS;
|
|
@@ -1438,3 +1528,4 @@ exports.typeNumberToLabel = typeNumberToLabel;
|
|
|
1438
1528
|
exports.validateDomain = validateDomain;
|
|
1439
1529
|
exports.validateHeaderName = validateHeaderName;
|
|
1440
1530
|
exports.validateHeaderValue = validateHeaderValue;
|
|
1531
|
+
exports.validateSitemap = validateSitemap;
|
package/dist/tools/network.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { D as DNS_RECORD_TYPES, a as DnsRecord, b as DnsRecordType, c as DnsResponse, G as GeoResult, H as HTTP_HEADERS, d as HarEntry, e as HarParseResult, f as HarSummary, g as HeaderCategory, h as HttpHeader, P as ParsedDnsResult, i as ParsedGeoResult, S as STATUS_CODES, j as
|
|
1
|
+
export { D as DNS_RECORD_TYPES, a as DnsRecord, b as DnsRecordType, c as DnsResponse, G as GeoResult, H as HTTP_HEADERS, d as HarEntry, e as HarParseResult, f as HarSummary, g as HeaderCategory, h as HttpHeader, P as ParsedDnsResult, i as ParsedGeoResult, S as STATUS_CODES, j as SitemapIndexEntry, k as SitemapIssue, l as SitemapUrlEntry, m as SitemapValidationResult, o as StatusCode, p as buildDnsQueryUrl, q as buildGeoUrl, r as buildMapUrl, s as countryCodeToFlag, t as formatCoordinates, u as formatTtl, v as getByCategory, w as getHeader, x as getHeadersByCategory, y as getStatusByCategory, z as getStatusCode, A as isClientError, B as isServerError, C as isSuccess, E as isValidIp, F as isValidIpv4, I as isValidIpv6, J as parseDnsResponse, K as parseGeoResponse, L as parseHar, M as searchHeaders, N as searchStatusCodes, O as statusCodeToText, Q as typeNumberToLabel, R as validateDomain, T as validateHeaderName, U as validateHeaderValue, V as validateSitemap } from '../network-Cy02-FIO.cjs';
|
package/dist/tools/network.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { D as DNS_RECORD_TYPES, a as DnsRecord, b as DnsRecordType, c as DnsResponse, G as GeoResult, H as HTTP_HEADERS, d as HarEntry, e as HarParseResult, f as HarSummary, g as HeaderCategory, h as HttpHeader, P as ParsedDnsResult, i as ParsedGeoResult, S as STATUS_CODES, j as
|
|
1
|
+
export { D as DNS_RECORD_TYPES, a as DnsRecord, b as DnsRecordType, c as DnsResponse, G as GeoResult, H as HTTP_HEADERS, d as HarEntry, e as HarParseResult, f as HarSummary, g as HeaderCategory, h as HttpHeader, P as ParsedDnsResult, i as ParsedGeoResult, S as STATUS_CODES, j as SitemapIndexEntry, k as SitemapIssue, l as SitemapUrlEntry, m as SitemapValidationResult, o as StatusCode, p as buildDnsQueryUrl, q as buildGeoUrl, r as buildMapUrl, s as countryCodeToFlag, t as formatCoordinates, u as formatTtl, v as getByCategory, w as getHeader, x as getHeadersByCategory, y as getStatusByCategory, z as getStatusCode, A as isClientError, B as isServerError, C as isSuccess, E as isValidIp, F as isValidIpv4, I as isValidIpv6, J as parseDnsResponse, K as parseGeoResponse, L as parseHar, M as searchHeaders, N as searchStatusCodes, O as statusCodeToText, Q as typeNumberToLabel, R as validateDomain, T as validateHeaderName, U as validateHeaderValue, V as validateSitemap } from '../network-Cy02-FIO.js';
|
package/dist/tools/network.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { DNS_RECORD_TYPES, HTTP_HEADERS, STATUS_CODES, buildDnsQueryUrl, buildGeoUrl, buildMapUrl, countryCodeToFlag, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, parseDnsResponse, parseGeoResponse, parseHar, searchHeaders, searchStatusCodes, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue } from '../chunk-
|
|
1
|
+
export { DNS_RECORD_TYPES, HTTP_HEADERS, STATUS_CODES, buildDnsQueryUrl, buildGeoUrl, buildMapUrl, countryCodeToFlag, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, parseDnsResponse, parseGeoResponse, parseHar, searchHeaders, searchStatusCodes, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue, validateSitemap } from '../chunk-LI5AME5R.js';
|
|
2
2
|
import '../chunk-MLKGABMK.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utilix-tech/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"description": "154+ developer utility tools for Node.js: JSON, encoding, hashing, color, CSS, network and more. Runs locally, no API key required.",
|
|
5
5
|
"author": "Utilix <hello@utilix.tech>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://www.utilix.tech/docs#node-sdk",
|
|
@@ -28,7 +28,12 @@
|
|
|
28
28
|
"regex",
|
|
29
29
|
"uuid",
|
|
30
30
|
"api-client",
|
|
31
|
-
"utilix"
|
|
31
|
+
"utilix",
|
|
32
|
+
"ai-agent",
|
|
33
|
+
"llm-tools",
|
|
34
|
+
"rag",
|
|
35
|
+
"yaml",
|
|
36
|
+
"base64"
|
|
32
37
|
],
|
|
33
38
|
"engines": {
|
|
34
39
|
"node": ">=18"
|