@utilix-tech/sdk 0.28.0 → 0.30.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +28 -11
  3. package/dist/{chunk-2CJSLYWI.js → chunk-3TYWIX3B.js} +107 -1
  4. package/dist/{chunk-Y5OOP6WN.js → chunk-CSNTHZHF.js} +90 -1
  5. package/dist/{chunk-47DTCCQJ.js → chunk-L6V4W4SU.js} +112 -1
  6. package/dist/{chunk-WO3LJMVV.js → chunk-WVEKRKGU.js} +101 -1
  7. package/dist/{generators-BGtRGpJZ.d.cts → generators-Du8cBesn.d.cts} +45 -2
  8. package/dist/{generators-BGtRGpJZ.d.ts → generators-Du8cBesn.d.ts} +45 -2
  9. package/dist/index.cjs +406 -0
  10. package/dist/index.d.cts +4 -4
  11. package/dist/index.d.ts +4 -4
  12. package/dist/index.js +4 -4
  13. package/dist/{json-DEVFIpsC.d.ts → json-Ta9JykSB.d.cts} +36 -2
  14. package/dist/{json-DEVFIpsC.d.cts → json-Ta9JykSB.d.ts} +36 -2
  15. package/dist/{media-cuxfzXxw.d.cts → media-fD8dJ5qR.d.cts} +29 -2
  16. package/dist/{media-cuxfzXxw.d.ts → media-fD8dJ5qR.d.ts} +29 -2
  17. package/dist/{network-BJOjJnmY.d.ts → network-D7Epuerc.d.cts} +23 -2
  18. package/dist/{network-BJOjJnmY.d.cts → network-D7Epuerc.d.ts} +23 -2
  19. package/dist/tools/generators.cjs +106 -0
  20. package/dist/tools/generators.d.cts +1 -1
  21. package/dist/tools/generators.d.ts +1 -1
  22. package/dist/tools/generators.js +1 -1
  23. package/dist/tools/json.cjs +100 -0
  24. package/dist/tools/json.d.cts +1 -1
  25. package/dist/tools/json.d.ts +1 -1
  26. package/dist/tools/json.js +1 -1
  27. package/dist/tools/media.cjs +111 -0
  28. package/dist/tools/media.d.cts +1 -1
  29. package/dist/tools/media.d.ts +1 -1
  30. package/dist/tools/media.js +1 -1
  31. package/dist/tools/network.cjs +89 -0
  32. package/dist/tools/network.d.cts +1 -1
  33. package/dist/tools/network.d.ts +1 -1
  34. package/dist/tools/network.js +1 -1
  35. package/package.json +1 -1
@@ -1293,6 +1293,105 @@ function resolveJsonPointer(json, pointer) {
1293
1293
  }
1294
1294
  return { pointer, found: true, value: current, tokens };
1295
1295
  }
1296
+ function _schemaRefName(ref) {
1297
+ const parts = ref.split("/");
1298
+ return _capitalize(parts[parts.length - 1] || "Ref");
1299
+ }
1300
+ function _schemaLiteralType(value) {
1301
+ if (typeof value === "string") return JSON.stringify(value);
1302
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
1303
+ if (value === null) return "null";
1304
+ return JSON.stringify(value);
1305
+ }
1306
+ function _safePropertyKey(key) {
1307
+ return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : JSON.stringify(key);
1308
+ }
1309
+ function _schemaToTsType(schema, name, interfaces) {
1310
+ if (schema.$ref) return _schemaRefName(schema.$ref);
1311
+ if (schema.const !== void 0) return _schemaLiteralType(schema.const);
1312
+ if (schema.enum) return schema.enum.map(_schemaLiteralType).join(" | ");
1313
+ if (schema.oneOf) return schema.oneOf.map((s, i) => _schemaToTsType(s, `${name}Variant${i}`, interfaces)).join(" | ");
1314
+ if (schema.anyOf) return schema.anyOf.map((s, i) => _schemaToTsType(s, `${name}Variant${i}`, interfaces)).join(" | ");
1315
+ if (schema.allOf) return schema.allOf.map((s, i) => _schemaToTsType(s, `${name}Part${i}`, interfaces)).join(" & ");
1316
+ const types = Array.isArray(schema.type) ? schema.type : schema.type ? [schema.type] : [];
1317
+ const nullable = types.includes("null");
1318
+ const nonNullTypes = types.filter((t) => t !== "null");
1319
+ const primaryType = nonNullTypes[0] ?? (schema.properties || schema.additionalProperties !== void 0 ? "object" : void 0);
1320
+ let result;
1321
+ switch (primaryType) {
1322
+ case "string":
1323
+ result = "string";
1324
+ break;
1325
+ case "number":
1326
+ case "integer":
1327
+ result = "number";
1328
+ break;
1329
+ case "boolean":
1330
+ result = "boolean";
1331
+ break;
1332
+ case "array": {
1333
+ const itemsSchema = Array.isArray(schema.items) ? schema.items[0] : schema.items;
1334
+ const itemType = itemsSchema ? _schemaToTsType(itemsSchema, `${name}Item`, interfaces) : "unknown";
1335
+ result = `${itemType}[]`;
1336
+ break;
1337
+ }
1338
+ case "object": {
1339
+ _buildSchemaInterface(schema, name, interfaces);
1340
+ result = name;
1341
+ break;
1342
+ }
1343
+ default:
1344
+ result = "unknown";
1345
+ }
1346
+ return nullable ? `${result} | null` : result;
1347
+ }
1348
+ function _buildSchemaInterface(schema, name, interfaces) {
1349
+ if (interfaces.has(name)) return;
1350
+ const required = new Set(schema.required ?? []);
1351
+ const lines = [`interface ${name} {`];
1352
+ for (const [key, propSchema] of Object.entries(schema.properties ?? {})) {
1353
+ if (propSchema.description) lines.push(` /** ${propSchema.description} */`);
1354
+ const optional = required.has(key) ? "" : "?";
1355
+ const propType = _schemaToTsType(propSchema, _capitalize(key), interfaces);
1356
+ lines.push(` ${_safePropertyKey(key)}${optional}: ${propType};`);
1357
+ }
1358
+ if (schema.additionalProperties === true) {
1359
+ lines.push(" [key: string]: unknown;");
1360
+ } else if (schema.additionalProperties && typeof schema.additionalProperties === "object") {
1361
+ const addType = _schemaToTsType(schema.additionalProperties, `${name}Value`, interfaces);
1362
+ lines.push(` [key: string]: ${addType};`);
1363
+ }
1364
+ lines.push("}");
1365
+ interfaces.set(name, lines.join("\n"));
1366
+ }
1367
+ function jsonSchemaToTypescript(schemaJson, options) {
1368
+ let schema;
1369
+ try {
1370
+ schema = JSON.parse(schemaJson);
1371
+ } catch {
1372
+ return { error: "Invalid JSON input" };
1373
+ }
1374
+ if (typeof schema !== "object" || schema === null || Array.isArray(schema)) {
1375
+ return { error: "Schema must be a JSON object" };
1376
+ }
1377
+ const rootName = options?.rootName ?? "Root";
1378
+ const typedSchema = schema;
1379
+ const interfaces = /* @__PURE__ */ new Map();
1380
+ const defs = { ...typedSchema.$defs ?? {}, ...typedSchema.definitions ?? {} };
1381
+ for (const [defName, defSchema] of Object.entries(defs)) {
1382
+ const defTypeName = _capitalize(defName);
1383
+ const defType = _schemaToTsType(defSchema, defTypeName, interfaces);
1384
+ if (!interfaces.has(defTypeName)) {
1385
+ interfaces.set(defTypeName, `type ${defTypeName} = ${defType};`);
1386
+ }
1387
+ }
1388
+ const rootType = _schemaToTsType(typedSchema, rootName, interfaces);
1389
+ const parts = [...interfaces.values()];
1390
+ if (!interfaces.has(rootName)) {
1391
+ parts.push(`type ${rootName} = ${rootType};`);
1392
+ }
1393
+ return parts.join("\n\n");
1394
+ }
1296
1395
 
1297
1396
  exports.csvToJson = csvToJson;
1298
1397
  exports.detectFormat = detectFormat;
@@ -1305,6 +1404,7 @@ exports.getJsonStats = getJsonStats;
1305
1404
  exports.inferGoType = inferGoType;
1306
1405
  exports.inferPythonType = inferPythonType;
1307
1406
  exports.inferType = inferType;
1407
+ exports.jsonSchemaToTypescript = jsonSchemaToTypescript;
1308
1408
  exports.jsonToCsv = jsonToCsv;
1309
1409
  exports.jsonToGo = jsonToGo;
1310
1410
  exports.jsonToPython = jsonToPython;
@@ -1 +1 @@
1
- export { C as ConvertOptions, a as CsvOptions, D as DiffNode, b as DiffType, G as GoField, c as GoStruct, J as JsonDiffResult, d as JsonParseResult, e as JsonPathResult, f as JsonPointerResult, P as ParseStatus, g as PythonClass, h as PythonField, i as PythonMode, V as ValidationError, k as ValidationResult, Z as ZodOptions, l as csvToJson, m as detectFormat, n as diffJson, o as evaluateJsonPath, p as formatDiffLine, q as formatJson, r as generateExample, s as getJsonStats, t as inferGoType, u as inferPythonType, v as inferType, w as jsonToCsv, x as jsonToGo, y as jsonToPython, z as jsonToTypescript, A as jsonToYaml, B as jsonToZod, E as minifyJson, F as parseJson, H as parseStructs, I as resolveJsonPointer, K as toPascalCase, L as toSnakeCase, M as validateJson, N as validateJsonPath, O as validateJsonString, Q as yamlToJson } from '../json-DEVFIpsC.cjs';
1
+ export { C as ConvertOptions, a as CsvOptions, D as DiffNode, b as DiffType, G as GoField, c as GoStruct, J as JsonDiffResult, d as JsonParseResult, e as JsonPathResult, f as JsonPointerResult, g as JsonSchemaLike, h as JsonSchemaToTsOptions, P as ParseStatus, i as PythonClass, k as PythonField, l as PythonMode, V as ValidationError, m as ValidationResult, Z as ZodOptions, n as csvToJson, o as detectFormat, p as diffJson, q as evaluateJsonPath, r as formatDiffLine, s as formatJson, t as generateExample, u as getJsonStats, v as inferGoType, w as inferPythonType, x as inferType, y as jsonSchemaToTypescript, z as jsonToCsv, A as jsonToGo, B as jsonToPython, E as jsonToTypescript, F as jsonToYaml, H as jsonToZod, I as minifyJson, K as parseJson, L as parseStructs, M as resolveJsonPointer, N as toPascalCase, O as toSnakeCase, Q as validateJson, R as validateJsonPath, S as validateJsonString, T as yamlToJson } from '../json-Ta9JykSB.cjs';
@@ -1 +1 @@
1
- export { C as ConvertOptions, a as CsvOptions, D as DiffNode, b as DiffType, G as GoField, c as GoStruct, J as JsonDiffResult, d as JsonParseResult, e as JsonPathResult, f as JsonPointerResult, P as ParseStatus, g as PythonClass, h as PythonField, i as PythonMode, V as ValidationError, k as ValidationResult, Z as ZodOptions, l as csvToJson, m as detectFormat, n as diffJson, o as evaluateJsonPath, p as formatDiffLine, q as formatJson, r as generateExample, s as getJsonStats, t as inferGoType, u as inferPythonType, v as inferType, w as jsonToCsv, x as jsonToGo, y as jsonToPython, z as jsonToTypescript, A as jsonToYaml, B as jsonToZod, E as minifyJson, F as parseJson, H as parseStructs, I as resolveJsonPointer, K as toPascalCase, L as toSnakeCase, M as validateJson, N as validateJsonPath, O as validateJsonString, Q as yamlToJson } from '../json-DEVFIpsC.js';
1
+ export { C as ConvertOptions, a as CsvOptions, D as DiffNode, b as DiffType, G as GoField, c as GoStruct, J as JsonDiffResult, d as JsonParseResult, e as JsonPathResult, f as JsonPointerResult, g as JsonSchemaLike, h as JsonSchemaToTsOptions, P as ParseStatus, i as PythonClass, k as PythonField, l as PythonMode, V as ValidationError, m as ValidationResult, Z as ZodOptions, n as csvToJson, o as detectFormat, p as diffJson, q as evaluateJsonPath, r as formatDiffLine, s as formatJson, t as generateExample, u as getJsonStats, v as inferGoType, w as inferPythonType, x as inferType, y as jsonSchemaToTypescript, z as jsonToCsv, A as jsonToGo, B as jsonToPython, E as jsonToTypescript, F as jsonToYaml, H as jsonToZod, I as minifyJson, K as parseJson, L as parseStructs, M as resolveJsonPointer, N as toPascalCase, O as toSnakeCase, Q as validateJson, R as validateJsonPath, S as validateJsonString, T as yamlToJson } from '../json-Ta9JykSB.js';
@@ -1,2 +1,2 @@
1
- export { csvToJson, detectFormat, diffJson, evaluateJsonPath, formatDiffLine, formatJson, generateExample, getJsonStats, inferGoType, inferPythonType, inferType, jsonToCsv, jsonToGo, jsonToPython, jsonToTypescript, jsonToYaml, jsonToZod, minifyJson, parseJson, parseStructs, resolveJsonPointer, toPascalCase, toSnakeCase, validateJson, validateJsonPath, validateJsonString, yamlToJson } from '../chunk-WO3LJMVV.js';
1
+ export { csvToJson, detectFormat, diffJson, evaluateJsonPath, formatDiffLine, formatJson, generateExample, getJsonStats, inferGoType, inferPythonType, inferType, jsonSchemaToTypescript, jsonToCsv, jsonToGo, jsonToPython, jsonToTypescript, jsonToYaml, jsonToZod, minifyJson, parseJson, parseStructs, resolveJsonPointer, toPascalCase, toSnakeCase, validateJson, validateJsonPath, validateJsonString, yamlToJson } from '../chunk-WVEKRKGU.js';
2
2
  import '../chunk-MLKGABMK.js';
@@ -457,6 +457,116 @@ function readPdfMetadata(bytes) {
457
457
  encrypted
458
458
  };
459
459
  }
460
+ var PDF_COMMON_PAPER_SIZES = [
461
+ { name: "Letter", widthPt: 612, heightPt: 792 },
462
+ { name: "Legal", widthPt: 612, heightPt: 1008 },
463
+ { name: "Tabloid", widthPt: 792, heightPt: 1224 },
464
+ { name: "A3", widthPt: 842, heightPt: 1191 },
465
+ { name: "A4", widthPt: 595, heightPt: 842 },
466
+ { name: "A5", widthPt: 420, heightPt: 595 },
467
+ { name: "B5", widthPt: 499, heightPt: 709 }
468
+ ];
469
+ function matchPaperSize(widthPt, heightPt) {
470
+ for (const size of PDF_COMMON_PAPER_SIZES) {
471
+ const w = Math.abs(widthPt - size.widthPt) <= 1;
472
+ const h = Math.abs(heightPt - size.heightPt) <= 1;
473
+ const wSwapped = Math.abs(widthPt - size.heightPt) <= 1;
474
+ const hSwapped = Math.abs(heightPt - size.widthPt) <= 1;
475
+ if (w && h || wSwapped && hSwapped) return size.name;
476
+ }
477
+ return null;
478
+ }
479
+ function parsePdfMediaBox(dict) {
480
+ const m = dict.match(/\/MediaBox\s*\[\s*(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)\s+(-?[\d.]+)\s*\]/);
481
+ if (!m) return null;
482
+ return [Number(m[1]), Number(m[2]), Number(m[3]), Number(m[4])];
483
+ }
484
+ function parsePdfRotate(dict) {
485
+ const m = dict.match(/\/Rotate\s+(-?\d+)/);
486
+ return m ? Number(m[1]) : null;
487
+ }
488
+ function buildPdfPageDimension(pageNumber, mediaBox, rotate) {
489
+ const rotation = (rotate % 360 + 360) % 360;
490
+ if (!mediaBox) {
491
+ return { pageNumber, widthPt: null, heightPt: null, widthIn: null, heightIn: null, rotation, orientation: null, paperSize: null };
492
+ }
493
+ const [llx, lly, urx, ury] = mediaBox;
494
+ let widthPt = Math.abs(urx - llx);
495
+ let heightPt = Math.abs(ury - lly);
496
+ if (rotation === 90 || rotation === 270) [widthPt, heightPt] = [heightPt, widthPt];
497
+ const orientation = widthPt === heightPt ? "square" : widthPt > heightPt ? "landscape" : "portrait";
498
+ return {
499
+ pageNumber,
500
+ widthPt: round2(widthPt),
501
+ heightPt: round2(heightPt),
502
+ widthIn: round2(widthPt / 72),
503
+ heightIn: round2(heightPt / 72),
504
+ rotation,
505
+ orientation,
506
+ paperSize: matchPaperSize(widthPt, heightPt)
507
+ };
508
+ }
509
+ function walkPdfPageTree(objMap, nodeBody, inherited, visited, nodeKey, out) {
510
+ if (visited.has(nodeKey)) return;
511
+ visited.add(nodeKey);
512
+ const mediaBox = parsePdfMediaBox(nodeBody) ?? inherited.mediaBox;
513
+ const rotateMatch = parsePdfRotate(nodeBody);
514
+ const rotate = rotateMatch !== null ? rotateMatch : inherited.rotate;
515
+ if (/\/Type\s*\/Page(?!s)\b/.test(nodeBody)) {
516
+ out.push(buildPdfPageDimension(out.length + 1, mediaBox, rotate));
517
+ return;
518
+ }
519
+ const kidsMatch = nodeBody.match(/\/Kids\s*\[([^\]]*)\]/);
520
+ if (!kidsMatch) return;
521
+ const kidRefs = [...kidsMatch[1].matchAll(/(\d+)\s+(\d+)\s+R/g)];
522
+ for (const ref of kidRefs) {
523
+ const key = `${ref[1]} ${ref[2]}`;
524
+ const body = objMap.get(key);
525
+ if (body) walkPdfPageTree(objMap, body, { mediaBox, rotate }, visited, key, out);
526
+ }
527
+ }
528
+ function readPdfPageDimensions(bytes) {
529
+ if (bytes.length < 8) return { error: "File too small to be a PDF" };
530
+ const header = bytesToLatin1(bytes.subarray(0, 16));
531
+ const versionMatch = header.match(/%PDF-(\d\.\d)/);
532
+ if (!versionMatch) return { error: "Not a valid PDF file (missing %PDF header)" };
533
+ const version = versionMatch[1];
534
+ const text = bytesToLatin1(bytes);
535
+ const objBlocks = [...text.matchAll(/(\d+)\s+(\d+)\s+obj([\s\S]*?)endobj/g)];
536
+ const objMap = /* @__PURE__ */ new Map();
537
+ for (const b of objBlocks) objMap.set(`${b[1]} ${b[2]}`, b[3]);
538
+ const out = [];
539
+ const visited = /* @__PURE__ */ new Set();
540
+ let pagesRootBody = null;
541
+ const trailerMatches = [...text.matchAll(/trailer\s*<<([\s\S]*?)>>/g)];
542
+ if (trailerMatches.length > 0) {
543
+ const trailer = trailerMatches[trailerMatches.length - 1][1];
544
+ const rootRef = trailer.match(/\/Root\s+(\d+)\s+(\d+)\s+R/);
545
+ if (rootRef) {
546
+ const catalogBody = objMap.get(`${rootRef[1]} ${rootRef[2]}`);
547
+ const pagesRef = catalogBody?.match(/\/Pages\s+(\d+)\s+(\d+)\s+R/);
548
+ if (pagesRef) pagesRootBody = objMap.get(`${pagesRef[1]} ${pagesRef[2]}`) ?? null;
549
+ }
550
+ }
551
+ if (!pagesRootBody) {
552
+ for (const b of objBlocks) {
553
+ if (/\/Type\s*\/Pages\b/.test(b[3]) && !/\/Parent\s+\d+\s+\d+\s+R/.test(b[3])) {
554
+ pagesRootBody = b[3];
555
+ break;
556
+ }
557
+ }
558
+ }
559
+ if (pagesRootBody) walkPdfPageTree(objMap, pagesRootBody, { mediaBox: null, rotate: 0 }, visited, "root", out);
560
+ if (out.length === 0) {
561
+ for (const b of objBlocks) {
562
+ if (/\/Type\s*\/Page(?!s)\b/.test(b[3])) {
563
+ out.push(buildPdfPageDimension(out.length + 1, parsePdfMediaBox(b[3]), parsePdfRotate(b[3]) ?? 0));
564
+ }
565
+ }
566
+ }
567
+ if (out.length === 0) return { error: "Could not locate any page objects in this PDF" };
568
+ return { version, pageCount: out.length, pages: out };
569
+ }
460
570
  var AUDIO_FORMAT_LABELS = {
461
571
  1: "PCM",
462
572
  3: "IEEE float",
@@ -1105,5 +1215,6 @@ exports.readIcoInfo = readIcoInfo;
1105
1215
  exports.readId3Tags = readId3Tags;
1106
1216
  exports.readImageInfo = readImageInfo;
1107
1217
  exports.readPdfMetadata = readPdfMetadata;
1218
+ exports.readPdfPageDimensions = readPdfPageDimensions;
1108
1219
  exports.readVideoInfo = readVideoInfo;
1109
1220
  exports.readWavInfo = readWavInfo;
@@ -1 +1 @@
1
- export { E as ExifData, a as ExifError, F as FlacInfo, b as FlacInfoError, I as IcoImageEntry, c as IcoInfo, d as IcoInfoError, e as Id3Tags, f as Id3TagsError, g as ImageFormat, h as ImageInfo, i as ImageInfoError, P as PdfMetadata, j as PdfMetadataError, V as VideoInfo, k as VideoInfoError, W as WavInfo, l as WavInfoError, r as readExifData, n as readFlacInfo, o as readIcoInfo, p as readId3Tags, q as readImageInfo, s as readPdfMetadata, t as readVideoInfo, u as readWavInfo } from '../media-cuxfzXxw.cjs';
1
+ export { E as ExifData, a as ExifError, F as FlacInfo, b as FlacInfoError, I as IcoImageEntry, c as IcoInfo, d as IcoInfoError, e as Id3Tags, f as Id3TagsError, g as ImageFormat, h as ImageInfo, i as ImageInfoError, P as PdfMetadata, j as PdfMetadataError, k as PdfPageDimension, l as PdfPageDimensionsResult, n as PdfPageOrientation, V as VideoInfo, o as VideoInfoError, W as WavInfo, p as WavInfoError, r as readExifData, q as readFlacInfo, s as readIcoInfo, t as readId3Tags, u as readImageInfo, v as readPdfMetadata, w as readPdfPageDimensions, x as readVideoInfo, y as readWavInfo } from '../media-fD8dJ5qR.cjs';
@@ -1 +1 @@
1
- export { E as ExifData, a as ExifError, F as FlacInfo, b as FlacInfoError, I as IcoImageEntry, c as IcoInfo, d as IcoInfoError, e as Id3Tags, f as Id3TagsError, g as ImageFormat, h as ImageInfo, i as ImageInfoError, P as PdfMetadata, j as PdfMetadataError, V as VideoInfo, k as VideoInfoError, W as WavInfo, l as WavInfoError, r as readExifData, n as readFlacInfo, o as readIcoInfo, p as readId3Tags, q as readImageInfo, s as readPdfMetadata, t as readVideoInfo, u as readWavInfo } from '../media-cuxfzXxw.js';
1
+ export { E as ExifData, a as ExifError, F as FlacInfo, b as FlacInfoError, I as IcoImageEntry, c as IcoInfo, d as IcoInfoError, e as Id3Tags, f as Id3TagsError, g as ImageFormat, h as ImageInfo, i as ImageInfoError, P as PdfMetadata, j as PdfMetadataError, k as PdfPageDimension, l as PdfPageDimensionsResult, n as PdfPageOrientation, V as VideoInfo, o as VideoInfoError, W as WavInfo, p as WavInfoError, r as readExifData, q as readFlacInfo, s as readIcoInfo, t as readId3Tags, u as readImageInfo, v as readPdfMetadata, w as readPdfPageDimensions, x as readVideoInfo, y as readWavInfo } from '../media-fD8dJ5qR.js';
@@ -1,2 +1,2 @@
1
- export { readExifData, readFlacInfo, readIcoInfo, readId3Tags, readImageInfo, readPdfMetadata, readVideoInfo, readWavInfo } from '../chunk-47DTCCQJ.js';
1
+ export { readExifData, readFlacInfo, readIcoInfo, readId3Tags, readImageInfo, readPdfMetadata, readPdfPageDimensions, readVideoInfo, readWavInfo } from '../chunk-L6V4W4SU.js';
2
2
  import '../chunk-MLKGABMK.js';
@@ -1777,6 +1777,94 @@ function buildCacheControl(options = {}) {
1777
1777
  const snippet = `Cache-Control: ${header}`;
1778
1778
  return { header, headerName: "Cache-Control", snippet, directives, warnings };
1779
1779
  }
1780
+ function isValidIpv6HexGroup(g) {
1781
+ return /^[0-9a-fA-F]{1,4}$/.test(g);
1782
+ }
1783
+ function isValidIpv6Ipv4Quad(quad) {
1784
+ const parts = quad.split(".");
1785
+ if (parts.length !== 4) return false;
1786
+ return parts.every((p) => /^\d{1,3}$/.test(p) && Number(p) <= 255);
1787
+ }
1788
+ function classifyIpv6(groups) {
1789
+ const first = parseInt(groups[0], 16);
1790
+ if (groups.every((g) => g === "0000")) return "unspecified";
1791
+ if (groups.slice(0, 7).every((g) => g === "0000") && groups[7] === "0001") return "loopback";
1792
+ if (groups.slice(0, 4).every((g) => g === "0000") && groups[4] === "0000" && groups[5] === "ffff") return "ipv4-mapped";
1793
+ if (groups[0] === "2001" && groups[1] === "0db8") return "documentation";
1794
+ if ((first & 65280) === 65280) return "multicast";
1795
+ if ((first & 65472) === 65152) return "link-local";
1796
+ if ((first & 65024) === 64512) return "unique-local";
1797
+ return "global-unicast";
1798
+ }
1799
+ function compressIpv6Groups(groups) {
1800
+ const short = groups.map((g) => g.replace(/^0+(?=.)/, ""));
1801
+ let bestStart = -1;
1802
+ let bestLen = 0;
1803
+ let curStart = -1;
1804
+ let curLen = 0;
1805
+ for (let i = 0; i < short.length; i++) {
1806
+ if (short[i] === "0") {
1807
+ if (curStart === -1) curStart = i;
1808
+ curLen++;
1809
+ if (curLen > bestLen) {
1810
+ bestLen = curLen;
1811
+ bestStart = curStart;
1812
+ }
1813
+ } else {
1814
+ curStart = -1;
1815
+ curLen = 0;
1816
+ }
1817
+ }
1818
+ if (bestLen < 2) return short.join(":");
1819
+ const before = short.slice(0, bestStart).join(":");
1820
+ const after = short.slice(bestStart + bestLen).join(":");
1821
+ return `${before}::${after}`;
1822
+ }
1823
+ function parseIpv6Address(input) {
1824
+ let s = input.trim();
1825
+ if (s.startsWith("[") && s.includes("]")) s = s.slice(1, s.indexOf("]"));
1826
+ let zoneId = null;
1827
+ const pctIdx = s.indexOf("%");
1828
+ if (pctIdx !== -1) {
1829
+ zoneId = s.slice(pctIdx + 1);
1830
+ s = s.slice(0, pctIdx);
1831
+ }
1832
+ if (!s) return { error: "Empty address" };
1833
+ const doubleColonCount = (s.match(/::/g) ?? []).length;
1834
+ if (doubleColonCount > 1) return { error: 'Address contains more than one "::"' };
1835
+ const ipv4Match = s.match(/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
1836
+ if (ipv4Match) {
1837
+ const quad = ipv4Match[1];
1838
+ if (!isValidIpv6Ipv4Quad(quad)) return { error: `Invalid embedded IPv4 address: ${quad}` };
1839
+ const parts = quad.split(".").map(Number);
1840
+ const hi = (parts[0] << 8 | parts[1]).toString(16);
1841
+ const lo = (parts[2] << 8 | parts[3]).toString(16);
1842
+ s = s.slice(0, s.length - quad.length) + `${hi}:${lo}`;
1843
+ }
1844
+ let groups;
1845
+ if (s.includes("::")) {
1846
+ const [left, right] = s.split("::");
1847
+ const leftGroups = left ? left.split(":") : [];
1848
+ const rightGroups = right ? right.split(":") : [];
1849
+ const missing = 8 - (leftGroups.length + rightGroups.length);
1850
+ if (missing < 1) return { error: 'The "::" shorthand must represent at least one group of zeros' };
1851
+ if (![...leftGroups, ...rightGroups].every(isValidIpv6HexGroup)) return { error: "Invalid hex group in address" };
1852
+ groups = [...leftGroups, ...Array(missing).fill("0"), ...rightGroups];
1853
+ } else {
1854
+ groups = s.split(":");
1855
+ if (groups.length !== 8) return { error: `Expected 8 groups, got ${groups.length}` };
1856
+ if (!groups.every(isValidIpv6HexGroup)) return { error: "Invalid hex group in address" };
1857
+ }
1858
+ const expandedGroups = groups.map((g) => g.padStart(4, "0").toLowerCase());
1859
+ const suffix = zoneId ? `%${zoneId}` : "";
1860
+ return {
1861
+ expanded: expandedGroups.join(":") + suffix,
1862
+ compressed: compressIpv6Groups(expandedGroups) + suffix,
1863
+ groups: expandedGroups,
1864
+ zoneId,
1865
+ addressType: classifyIpv6(expandedGroups)
1866
+ };
1867
+ }
1780
1868
 
1781
1869
  exports.DNS_RECORD_TYPES = DNS_RECORD_TYPES;
1782
1870
  exports.HTTP_HEADERS = HTTP_HEADERS;
@@ -1802,6 +1890,7 @@ exports.isValidIpv6 = isValidIpv6;
1802
1890
  exports.parseDnsResponse = parseDnsResponse;
1803
1891
  exports.parseGeoResponse = parseGeoResponse;
1804
1892
  exports.parseHar = parseHar;
1893
+ exports.parseIpv6Address = parseIpv6Address;
1805
1894
  exports.parseUserAgent = parseUserAgent;
1806
1895
  exports.searchHeaders = searchHeaders;
1807
1896
  exports.searchStatusCodes = searchStatusCodes;
@@ -1 +1 @@
1
- export { C as CacheControlDirective, a as CacheControlOptions, b as CacheControlResult, D as DNS_RECORD_TYPES, c as DnsRecord, d as DnsRecordType, e as DnsResponse, G as GeoResult, H as HTTP_HEADERS, f as HarEntry, g as HarParseResult, h as HarSummary, i as HeaderCategory, j as HttpHeader, P as ParsedDnsResult, k as ParsedGeoResult, R as RobotsGroup, l as RobotsIssue, m as RobotsRule, o as RobotsValidationResult, S as STATUS_CODES, p as SitemapIndexEntry, q as SitemapIssue, r as SitemapUrlEntry, s as SitemapValidationResult, t as StatusCode, U as UaDeviceType, u as UserAgentInfo, v as buildCacheControl, w as buildDnsQueryUrl, x as buildGeoUrl, y as buildMapUrl, z as countryCodeToFlag, A as formatCoordinates, B as formatTtl, E as getByCategory, F as getHeader, I as getHeadersByCategory, J as getStatusByCategory, K as getStatusCode, L as isClientError, M as isServerError, N as isSuccess, O as isValidIp, Q as isValidIpv4, T as isValidIpv6, V as parseDnsResponse, W as parseGeoResponse, X as parseHar, Y as parseUserAgent, Z as searchHeaders, _ as searchStatusCodes, $ as statusCodeToText, a0 as typeNumberToLabel, a1 as validateDomain, a2 as validateHeaderName, a3 as validateHeaderValue, a4 as validateRobotsTxt, a5 as validateSitemap } from '../network-BJOjJnmY.cjs';
1
+ export { C as CacheControlDirective, a as CacheControlOptions, b as CacheControlResult, D as DNS_RECORD_TYPES, c as DnsRecord, d as DnsRecordType, e as DnsResponse, G as GeoResult, H as HTTP_HEADERS, f as HarEntry, g as HarParseResult, h as HarSummary, i as HeaderCategory, j as HttpHeader, I as Ipv6AddressType, k as Ipv6ParseResult, P as ParsedDnsResult, l as ParsedGeoResult, R as RobotsGroup, m as RobotsIssue, o as RobotsRule, p as RobotsValidationResult, S as STATUS_CODES, q as SitemapIndexEntry, r as SitemapIssue, s as SitemapUrlEntry, t as SitemapValidationResult, u as StatusCode, U as UaDeviceType, v as UserAgentInfo, w as buildCacheControl, x as buildDnsQueryUrl, y as buildGeoUrl, z as buildMapUrl, A as countryCodeToFlag, B as formatCoordinates, E as formatTtl, F as getByCategory, J as getHeader, K as getHeadersByCategory, L as getStatusByCategory, M as getStatusCode, N as isClientError, O as isServerError, Q as isSuccess, T as isValidIp, V as isValidIpv4, W as isValidIpv6, X as parseDnsResponse, Y as parseGeoResponse, Z as parseHar, _ as parseIpv6Address, $ as parseUserAgent, a0 as searchHeaders, a1 as searchStatusCodes, a2 as statusCodeToText, a3 as typeNumberToLabel, a4 as validateDomain, a5 as validateHeaderName, a6 as validateHeaderValue, a7 as validateRobotsTxt, a8 as validateSitemap } from '../network-D7Epuerc.cjs';
@@ -1 +1 @@
1
- export { C as CacheControlDirective, a as CacheControlOptions, b as CacheControlResult, D as DNS_RECORD_TYPES, c as DnsRecord, d as DnsRecordType, e as DnsResponse, G as GeoResult, H as HTTP_HEADERS, f as HarEntry, g as HarParseResult, h as HarSummary, i as HeaderCategory, j as HttpHeader, P as ParsedDnsResult, k as ParsedGeoResult, R as RobotsGroup, l as RobotsIssue, m as RobotsRule, o as RobotsValidationResult, S as STATUS_CODES, p as SitemapIndexEntry, q as SitemapIssue, r as SitemapUrlEntry, s as SitemapValidationResult, t as StatusCode, U as UaDeviceType, u as UserAgentInfo, v as buildCacheControl, w as buildDnsQueryUrl, x as buildGeoUrl, y as buildMapUrl, z as countryCodeToFlag, A as formatCoordinates, B as formatTtl, E as getByCategory, F as getHeader, I as getHeadersByCategory, J as getStatusByCategory, K as getStatusCode, L as isClientError, M as isServerError, N as isSuccess, O as isValidIp, Q as isValidIpv4, T as isValidIpv6, V as parseDnsResponse, W as parseGeoResponse, X as parseHar, Y as parseUserAgent, Z as searchHeaders, _ as searchStatusCodes, $ as statusCodeToText, a0 as typeNumberToLabel, a1 as validateDomain, a2 as validateHeaderName, a3 as validateHeaderValue, a4 as validateRobotsTxt, a5 as validateSitemap } from '../network-BJOjJnmY.js';
1
+ export { C as CacheControlDirective, a as CacheControlOptions, b as CacheControlResult, D as DNS_RECORD_TYPES, c as DnsRecord, d as DnsRecordType, e as DnsResponse, G as GeoResult, H as HTTP_HEADERS, f as HarEntry, g as HarParseResult, h as HarSummary, i as HeaderCategory, j as HttpHeader, I as Ipv6AddressType, k as Ipv6ParseResult, P as ParsedDnsResult, l as ParsedGeoResult, R as RobotsGroup, m as RobotsIssue, o as RobotsRule, p as RobotsValidationResult, S as STATUS_CODES, q as SitemapIndexEntry, r as SitemapIssue, s as SitemapUrlEntry, t as SitemapValidationResult, u as StatusCode, U as UaDeviceType, v as UserAgentInfo, w as buildCacheControl, x as buildDnsQueryUrl, y as buildGeoUrl, z as buildMapUrl, A as countryCodeToFlag, B as formatCoordinates, E as formatTtl, F as getByCategory, J as getHeader, K as getHeadersByCategory, L as getStatusByCategory, M as getStatusCode, N as isClientError, O as isServerError, Q as isSuccess, T as isValidIp, V as isValidIpv4, W as isValidIpv6, X as parseDnsResponse, Y as parseGeoResponse, Z as parseHar, _ as parseIpv6Address, $ as parseUserAgent, a0 as searchHeaders, a1 as searchStatusCodes, a2 as statusCodeToText, a3 as typeNumberToLabel, a4 as validateDomain, a5 as validateHeaderName, a6 as validateHeaderValue, a7 as validateRobotsTxt, a8 as validateSitemap } from '../network-D7Epuerc.js';
@@ -1,2 +1,2 @@
1
- export { DNS_RECORD_TYPES, HTTP_HEADERS, STATUS_CODES, buildCacheControl, buildDnsQueryUrl, buildGeoUrl, buildMapUrl, countryCodeToFlag, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, parseDnsResponse, parseGeoResponse, parseHar, parseUserAgent, searchHeaders, searchStatusCodes, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue, validateRobotsTxt, validateSitemap } from '../chunk-Y5OOP6WN.js';
1
+ export { DNS_RECORD_TYPES, HTTP_HEADERS, STATUS_CODES, buildCacheControl, buildDnsQueryUrl, buildGeoUrl, buildMapUrl, countryCodeToFlag, formatCoordinates, formatTtl, getByCategory, getHeader, getHeadersByCategory, getStatusByCategory, getStatusCode, isClientError, isServerError, isSuccess, isValidIp, isValidIpv4, isValidIpv6, parseDnsResponse, parseGeoResponse, parseHar, parseIpv6Address, parseUserAgent, searchHeaders, searchStatusCodes, statusCodeToText, typeNumberToLabel, validateDomain, validateHeaderName, validateHeaderValue, validateRobotsTxt, validateSitemap } from '../chunk-CSNTHZHF.js';
2
2
  import '../chunk-MLKGABMK.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@utilix-tech/sdk",
3
- "version": "0.28.0",
3
+ "version": "0.30.0",
4
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",