@utilix-tech/sdk 0.1.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/LICENSE +21 -0
- package/README.md +199 -0
- package/dist/api-8aZtWhSj.d.cts +308 -0
- package/dist/api-8aZtWhSj.d.ts +308 -0
- package/dist/chunk-2CJSLYWI.js +520 -0
- package/dist/chunk-3BAHSW4C.js +1385 -0
- package/dist/chunk-6YPV2AB5.js +1246 -0
- package/dist/chunk-BPVAB4P2.js +1126 -0
- package/dist/chunk-FL53T24A.js +257 -0
- package/dist/chunk-L6KCTHUW.js +1086 -0
- package/dist/chunk-MLKGABMK.js +7 -0
- package/dist/chunk-ROTPLW7T.js +265 -0
- package/dist/chunk-TSAGO3XP.js +1253 -0
- package/dist/chunk-UC656APA.js +1080 -0
- package/dist/chunk-W4UBLYFU.js +1219 -0
- package/dist/chunk-XST6X3HT.js +896 -0
- package/dist/chunk-XXYZLLHI.js +2227 -0
- package/dist/chunk-ZKL2VX2G.js +2215 -0
- package/dist/chunk-ZPQZEIXP.js +685 -0
- package/dist/code-QNrdLIR3.d.cts +327 -0
- package/dist/code-QNrdLIR3.d.ts +327 -0
- package/dist/color-tPwZCr9H.d.cts +229 -0
- package/dist/color-tPwZCr9H.d.ts +229 -0
- package/dist/css-Cf7AMGM-.d.cts +318 -0
- package/dist/css-Cf7AMGM-.d.ts +318 -0
- package/dist/data-rMjWNiOJ.d.cts +215 -0
- package/dist/data-rMjWNiOJ.d.ts +215 -0
- package/dist/encoding-7gmq-vkV.d.cts +108 -0
- package/dist/encoding-7gmq-vkV.d.ts +108 -0
- package/dist/generators-BGtRGpJZ.d.cts +118 -0
- package/dist/generators-BGtRGpJZ.d.ts +118 -0
- package/dist/hashing-CnetQFD_.d.cts +76 -0
- package/dist/hashing-CnetQFD_.d.ts +76 -0
- package/dist/index.cjs +15466 -0
- package/dist/index.d.cts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +20 -0
- package/dist/json-BjSoIS1h.d.cts +198 -0
- package/dist/json-BjSoIS1h.d.ts +198 -0
- package/dist/misc-DcVBManm.d.cts +201 -0
- package/dist/misc-DcVBManm.d.ts +201 -0
- package/dist/network-CNtmrDeN.d.cts +170 -0
- package/dist/network-CNtmrDeN.d.ts +170 -0
- package/dist/text-DqAjPtQ0.d.cts +319 -0
- package/dist/text-DqAjPtQ0.d.ts +319 -0
- package/dist/time-DbT8fjaF.d.cts +145 -0
- package/dist/time-DbT8fjaF.d.ts +145 -0
- package/dist/tools/api.cjs +1216 -0
- package/dist/tools/api.d.cts +1 -0
- package/dist/tools/api.d.ts +1 -0
- package/dist/tools/api.js +2 -0
- package/dist/tools/code.cjs +2212 -0
- package/dist/tools/code.d.cts +1 -0
- package/dist/tools/code.d.ts +1 -0
- package/dist/tools/code.js +2 -0
- package/dist/tools/color.cjs +1122 -0
- package/dist/tools/color.d.cts +1 -0
- package/dist/tools/color.d.ts +1 -0
- package/dist/tools/color.js +2 -0
- package/dist/tools/css.cjs +1242 -0
- package/dist/tools/css.d.cts +1 -0
- package/dist/tools/css.d.ts +1 -0
- package/dist/tools/css.js +2 -0
- package/dist/tools/data.cjs +1097 -0
- package/dist/tools/data.d.cts +1 -0
- package/dist/tools/data.d.ts +1 -0
- package/dist/tools/data.js +2 -0
- package/dist/tools/encoding.cjs +261 -0
- package/dist/tools/encoding.d.cts +1 -0
- package/dist/tools/encoding.d.ts +1 -0
- package/dist/tools/encoding.js +2 -0
- package/dist/tools/generators.cjs +521 -0
- package/dist/tools/generators.d.cts +1 -0
- package/dist/tools/generators.d.ts +1 -0
- package/dist/tools/generators.js +2 -0
- package/dist/tools/hashing.cjs +259 -0
- package/dist/tools/hashing.d.cts +1 -0
- package/dist/tools/hashing.d.ts +1 -0
- package/dist/tools/hashing.js +2 -0
- package/dist/tools/json.cjs +1270 -0
- package/dist/tools/json.d.cts +1 -0
- package/dist/tools/json.d.ts +1 -0
- package/dist/tools/json.js +2 -0
- package/dist/tools/misc.cjs +1082 -0
- package/dist/tools/misc.d.cts +1 -0
- package/dist/tools/misc.d.ts +1 -0
- package/dist/tools/misc.js +2 -0
- package/dist/tools/network.cjs +1381 -0
- package/dist/tools/network.d.cts +1 -0
- package/dist/tools/network.d.ts +1 -0
- package/dist/tools/network.js +2 -0
- package/dist/tools/text.cjs +2224 -0
- package/dist/tools/text.d.cts +1 -0
- package/dist/tools/text.d.ts +1 -0
- package/dist/tools/text.js +2 -0
- package/dist/tools/time.cjs +681 -0
- package/dist/tools/time.d.cts +1 -0
- package/dist/tools/time.d.ts +1 -0
- package/dist/tools/time.js +2 -0
- package/dist/tools/units.cjs +892 -0
- package/dist/tools/units.d.cts +1 -0
- package/dist/tools/units.d.ts +1 -0
- package/dist/tools/units.js +2 -0
- package/dist/units-6lwDYBvX.d.cts +302 -0
- package/dist/units-6lwDYBvX.d.ts +302 -0
- package/package.json +148 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module misc
|
|
3
|
+
* Miscellaneous tools for the @utilix/sdk Node.js SDK.
|
|
4
|
+
*
|
|
5
|
+
* Tools covered:
|
|
6
|
+
* - unicode : analyzeString, toUnicodeEscape, fromUnicodeEscape, codePointToChar, charToCodePoint
|
|
7
|
+
* - favicon-gen : generateSvgFavicon, svgToDataUrl (Node-compatible), DEFAULT_CONFIG, COLOR_PRESETS
|
|
8
|
+
* - svg-viewer : analyzeSvg, sanitizeSvg, optimizeSvg, formatSvg, minifySvg
|
|
9
|
+
* - image-compressor : formatBytes, calcSavings, detectFormatFromDataUrl, detectFormatFromFilename,
|
|
10
|
+
* getDefaultQuality, getSupportedOutputFormats, formatLabel, calcResizeDimensions
|
|
11
|
+
* - image-converter : getConversionWarnings, getSupportedFormats, getDownloadFilename,
|
|
12
|
+
* FORMAT_EXTENSIONS, FORMAT_LABELS
|
|
13
|
+
* - number-words : numberToWords, numberToOrdinal, ordinalWords, numberToRoman, romanToNumber
|
|
14
|
+
* - random-data : generateSingle, generateData, DATA_TYPES
|
|
15
|
+
*
|
|
16
|
+
* NOTE: Canvas-based image compression/conversion is not supported in Node. The relevant
|
|
17
|
+
* functions (compressImage, convertImage) are intentionally omitted; use the REST API or
|
|
18
|
+
* the Python SDK instead. The pure-logic helpers from both modules ARE exported.
|
|
19
|
+
*/
|
|
20
|
+
interface CodePoint {
|
|
21
|
+
char: string;
|
|
22
|
+
codePoint: number;
|
|
23
|
+
hex: string;
|
|
24
|
+
htmlEntity: string;
|
|
25
|
+
htmlHex: string;
|
|
26
|
+
utf8Bytes: string;
|
|
27
|
+
utf16: string;
|
|
28
|
+
name?: string;
|
|
29
|
+
category: string;
|
|
30
|
+
}
|
|
31
|
+
declare function analyzeString(input: string): CodePoint[];
|
|
32
|
+
declare function toUnicodeEscape(input: string): string;
|
|
33
|
+
declare function fromUnicodeEscape(input: string): string | {
|
|
34
|
+
error: string;
|
|
35
|
+
};
|
|
36
|
+
declare function codePointToChar(codePoint: number): string;
|
|
37
|
+
declare function charToCodePoint(char: string): number;
|
|
38
|
+
type Shape = 'square' | 'circle' | 'rounded';
|
|
39
|
+
interface FaviconConfig {
|
|
40
|
+
text: string;
|
|
41
|
+
bgColor: string;
|
|
42
|
+
textColor: string;
|
|
43
|
+
shape: Shape;
|
|
44
|
+
fontSize: number;
|
|
45
|
+
fontWeight: 'normal' | 'bold';
|
|
46
|
+
size: 32 | 48 | 64 | 128;
|
|
47
|
+
}
|
|
48
|
+
declare function generateSvgFavicon(config: FaviconConfig): string;
|
|
49
|
+
/** Convert an SVG string to a base64 data URL. Node-compatible (uses Buffer). */
|
|
50
|
+
declare function svgToDataUrl(svg: string): string;
|
|
51
|
+
declare const DEFAULT_CONFIG: FaviconConfig;
|
|
52
|
+
declare const COLOR_PRESETS: Array<{
|
|
53
|
+
name: string;
|
|
54
|
+
bg: string;
|
|
55
|
+
text: string;
|
|
56
|
+
}>;
|
|
57
|
+
interface SvgInfo {
|
|
58
|
+
width: string | null;
|
|
59
|
+
height: string | null;
|
|
60
|
+
viewBox: string | null;
|
|
61
|
+
elementCount: number;
|
|
62
|
+
hasAnimation: boolean;
|
|
63
|
+
hasScript: boolean;
|
|
64
|
+
hasExternalRef: boolean;
|
|
65
|
+
usedElements: string[];
|
|
66
|
+
}
|
|
67
|
+
declare function analyzeSvg(svg: string): SvgInfo | {
|
|
68
|
+
error: string;
|
|
69
|
+
};
|
|
70
|
+
declare function sanitizeSvg(svg: string): string;
|
|
71
|
+
declare function optimizeSvg(svg: string): string;
|
|
72
|
+
declare function formatSvg(svg: string): string;
|
|
73
|
+
declare function minifySvg(svg: string): string;
|
|
74
|
+
type ImageFormat = 'image/jpeg' | 'image/png' | 'image/webp' | 'image/gif';
|
|
75
|
+
interface CompressionOptions {
|
|
76
|
+
quality: number;
|
|
77
|
+
maxWidth?: number;
|
|
78
|
+
maxHeight?: number;
|
|
79
|
+
outputFormat: ImageFormat;
|
|
80
|
+
}
|
|
81
|
+
interface CompressionResult {
|
|
82
|
+
originalSize: number;
|
|
83
|
+
compressedSize: number;
|
|
84
|
+
savedBytes: number;
|
|
85
|
+
savedPercent: number;
|
|
86
|
+
width: number;
|
|
87
|
+
height: number;
|
|
88
|
+
format: ImageFormat;
|
|
89
|
+
dataUrl: string;
|
|
90
|
+
}
|
|
91
|
+
declare function formatBytes(bytes: number): string;
|
|
92
|
+
declare function calcSavings(originalBytes: number, compressedBytes: number): {
|
|
93
|
+
savedBytes: number;
|
|
94
|
+
savedPercent: number;
|
|
95
|
+
};
|
|
96
|
+
declare function detectFormatFromDataUrl(dataUrl: string): ImageFormat | null;
|
|
97
|
+
declare function detectFormatFromFilename(filename: string): ImageFormat | null;
|
|
98
|
+
declare function getDefaultQuality(format: ImageFormat): number;
|
|
99
|
+
declare function getSupportedOutputFormats(): ImageFormat[];
|
|
100
|
+
declare function formatLabel(format: ImageFormat): string;
|
|
101
|
+
declare function calcResizeDimensions(width: number, height: number, maxWidth?: number, maxHeight?: number): {
|
|
102
|
+
width: number;
|
|
103
|
+
height: number;
|
|
104
|
+
changed: boolean;
|
|
105
|
+
};
|
|
106
|
+
/** Narrower type used by image-converter (no gif output) */
|
|
107
|
+
type ConvertImageFormat = 'image/jpeg' | 'image/png' | 'image/webp';
|
|
108
|
+
interface ConversionOptions {
|
|
109
|
+
outputFormat: ConvertImageFormat;
|
|
110
|
+
quality?: number;
|
|
111
|
+
backgroundColor?: string;
|
|
112
|
+
}
|
|
113
|
+
declare const FORMAT_EXTENSIONS: Record<ConvertImageFormat, string>;
|
|
114
|
+
declare const FORMAT_LABELS: Record<ConvertImageFormat, string>;
|
|
115
|
+
declare function getConversionWarnings(from: ConvertImageFormat, to: ConvertImageFormat): string[];
|
|
116
|
+
declare function getSupportedFormats(): ConvertImageFormat[];
|
|
117
|
+
declare function getDownloadFilename(originalName: string, outputFormat: ConvertImageFormat): string;
|
|
118
|
+
declare function numberToWords(n: number): string | {
|
|
119
|
+
error: string;
|
|
120
|
+
};
|
|
121
|
+
declare function numberToOrdinal(n: number): string | {
|
|
122
|
+
error: string;
|
|
123
|
+
};
|
|
124
|
+
declare function ordinalWords(n: number): string | {
|
|
125
|
+
error: string;
|
|
126
|
+
};
|
|
127
|
+
declare function numberToRoman(n: number): string | {
|
|
128
|
+
error: string;
|
|
129
|
+
};
|
|
130
|
+
declare function romanToNumber(roman: string): number | {
|
|
131
|
+
error: string;
|
|
132
|
+
};
|
|
133
|
+
type DataType = 'name' | 'email' | 'uuid' | 'phone' | 'date' | 'number' | 'boolean' | 'color' | 'url' | 'ipv4' | 'sentence' | 'paragraph';
|
|
134
|
+
interface RandomConfig {
|
|
135
|
+
type: DataType;
|
|
136
|
+
count: number;
|
|
137
|
+
options?: {
|
|
138
|
+
min?: number;
|
|
139
|
+
max?: number;
|
|
140
|
+
dateFormat?: 'iso' | 'us' | 'eu';
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
declare const DATA_TYPES: {
|
|
144
|
+
value: DataType;
|
|
145
|
+
label: string;
|
|
146
|
+
example: string;
|
|
147
|
+
}[];
|
|
148
|
+
declare function generateSingle(type: DataType, options?: RandomConfig['options']): string;
|
|
149
|
+
declare function generateData(config: RandomConfig): string[];
|
|
150
|
+
|
|
151
|
+
declare const misc_COLOR_PRESETS: typeof COLOR_PRESETS;
|
|
152
|
+
type misc_CodePoint = CodePoint;
|
|
153
|
+
type misc_CompressionOptions = CompressionOptions;
|
|
154
|
+
type misc_CompressionResult = CompressionResult;
|
|
155
|
+
type misc_ConversionOptions = ConversionOptions;
|
|
156
|
+
type misc_ConvertImageFormat = ConvertImageFormat;
|
|
157
|
+
declare const misc_DATA_TYPES: typeof DATA_TYPES;
|
|
158
|
+
declare const misc_DEFAULT_CONFIG: typeof DEFAULT_CONFIG;
|
|
159
|
+
type misc_DataType = DataType;
|
|
160
|
+
declare const misc_FORMAT_EXTENSIONS: typeof FORMAT_EXTENSIONS;
|
|
161
|
+
declare const misc_FORMAT_LABELS: typeof FORMAT_LABELS;
|
|
162
|
+
type misc_FaviconConfig = FaviconConfig;
|
|
163
|
+
type misc_ImageFormat = ImageFormat;
|
|
164
|
+
type misc_RandomConfig = RandomConfig;
|
|
165
|
+
type misc_Shape = Shape;
|
|
166
|
+
type misc_SvgInfo = SvgInfo;
|
|
167
|
+
declare const misc_analyzeString: typeof analyzeString;
|
|
168
|
+
declare const misc_analyzeSvg: typeof analyzeSvg;
|
|
169
|
+
declare const misc_calcResizeDimensions: typeof calcResizeDimensions;
|
|
170
|
+
declare const misc_calcSavings: typeof calcSavings;
|
|
171
|
+
declare const misc_charToCodePoint: typeof charToCodePoint;
|
|
172
|
+
declare const misc_codePointToChar: typeof codePointToChar;
|
|
173
|
+
declare const misc_detectFormatFromDataUrl: typeof detectFormatFromDataUrl;
|
|
174
|
+
declare const misc_detectFormatFromFilename: typeof detectFormatFromFilename;
|
|
175
|
+
declare const misc_formatBytes: typeof formatBytes;
|
|
176
|
+
declare const misc_formatLabel: typeof formatLabel;
|
|
177
|
+
declare const misc_formatSvg: typeof formatSvg;
|
|
178
|
+
declare const misc_fromUnicodeEscape: typeof fromUnicodeEscape;
|
|
179
|
+
declare const misc_generateData: typeof generateData;
|
|
180
|
+
declare const misc_generateSingle: typeof generateSingle;
|
|
181
|
+
declare const misc_generateSvgFavicon: typeof generateSvgFavicon;
|
|
182
|
+
declare const misc_getConversionWarnings: typeof getConversionWarnings;
|
|
183
|
+
declare const misc_getDefaultQuality: typeof getDefaultQuality;
|
|
184
|
+
declare const misc_getDownloadFilename: typeof getDownloadFilename;
|
|
185
|
+
declare const misc_getSupportedFormats: typeof getSupportedFormats;
|
|
186
|
+
declare const misc_getSupportedOutputFormats: typeof getSupportedOutputFormats;
|
|
187
|
+
declare const misc_minifySvg: typeof minifySvg;
|
|
188
|
+
declare const misc_numberToOrdinal: typeof numberToOrdinal;
|
|
189
|
+
declare const misc_numberToRoman: typeof numberToRoman;
|
|
190
|
+
declare const misc_numberToWords: typeof numberToWords;
|
|
191
|
+
declare const misc_optimizeSvg: typeof optimizeSvg;
|
|
192
|
+
declare const misc_ordinalWords: typeof ordinalWords;
|
|
193
|
+
declare const misc_romanToNumber: typeof romanToNumber;
|
|
194
|
+
declare const misc_sanitizeSvg: typeof sanitizeSvg;
|
|
195
|
+
declare const misc_svgToDataUrl: typeof svgToDataUrl;
|
|
196
|
+
declare const misc_toUnicodeEscape: typeof toUnicodeEscape;
|
|
197
|
+
declare namespace misc {
|
|
198
|
+
export { misc_COLOR_PRESETS as COLOR_PRESETS, type misc_CodePoint as CodePoint, type misc_CompressionOptions as CompressionOptions, type misc_CompressionResult as CompressionResult, type misc_ConversionOptions as ConversionOptions, type misc_ConvertImageFormat as ConvertImageFormat, misc_DATA_TYPES as DATA_TYPES, misc_DEFAULT_CONFIG as DEFAULT_CONFIG, type misc_DataType as DataType, misc_FORMAT_EXTENSIONS as FORMAT_EXTENSIONS, misc_FORMAT_LABELS as FORMAT_LABELS, type misc_FaviconConfig as FaviconConfig, type misc_ImageFormat as ImageFormat, type misc_RandomConfig as RandomConfig, type misc_Shape as Shape, type misc_SvgInfo as SvgInfo, misc_analyzeString as analyzeString, misc_analyzeSvg as analyzeSvg, misc_calcResizeDimensions as calcResizeDimensions, misc_calcSavings as calcSavings, misc_charToCodePoint as charToCodePoint, misc_codePointToChar as codePointToChar, misc_detectFormatFromDataUrl as detectFormatFromDataUrl, misc_detectFormatFromFilename as detectFormatFromFilename, misc_formatBytes as formatBytes, misc_formatLabel as formatLabel, misc_formatSvg as formatSvg, misc_fromUnicodeEscape as fromUnicodeEscape, misc_generateData as generateData, misc_generateSingle as generateSingle, misc_generateSvgFavicon as generateSvgFavicon, misc_getConversionWarnings as getConversionWarnings, misc_getDefaultQuality as getDefaultQuality, misc_getDownloadFilename as getDownloadFilename, misc_getSupportedFormats as getSupportedFormats, misc_getSupportedOutputFormats as getSupportedOutputFormats, misc_minifySvg as minifySvg, misc_numberToOrdinal as numberToOrdinal, misc_numberToRoman as numberToRoman, misc_numberToWords as numberToWords, misc_optimizeSvg as optimizeSvg, misc_ordinalWords as ordinalWords, misc_romanToNumber as romanToNumber, misc_sanitizeSvg as sanitizeSvg, misc_svgToDataUrl as svgToDataUrl, misc_toUnicodeEscape as toUnicodeEscape };
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export { getConversionWarnings as A, getDefaultQuality as B, COLOR_PRESETS as C, DATA_TYPES as D, getDownloadFilename as E, FORMAT_EXTENSIONS as F, getSupportedFormats as G, getSupportedOutputFormats as H, type ImageFormat as I, minifySvg as J, numberToOrdinal as K, numberToRoman as L, numberToWords as M, optimizeSvg as N, ordinalWords as O, romanToNumber as P, sanitizeSvg as Q, type RandomConfig as R, type Shape as S, svgToDataUrl as T, toUnicodeEscape as U, type CodePoint as a, type CompressionOptions as b, type CompressionResult as c, type ConversionOptions as d, type ConvertImageFormat as e, DEFAULT_CONFIG as f, type DataType as g, FORMAT_LABELS as h, type FaviconConfig as i, type SvgInfo as j, analyzeString as k, analyzeSvg as l, misc as m, calcResizeDimensions as n, calcSavings as o, charToCodePoint as p, codePointToChar as q, detectFormatFromDataUrl as r, detectFormatFromFilename as s, formatBytes as t, formatLabel as u, formatSvg as v, fromUnicodeEscape as w, generateData as x, generateSingle as y, generateSvgFavicon as z };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module network
|
|
3
|
+
* Network utility tools for the @utilix/sdk Node.js SDK.
|
|
4
|
+
*
|
|
5
|
+
* Tools covered:
|
|
6
|
+
* - dns-lookup : DNS record querying via Cloudflare DoH
|
|
7
|
+
* - ip-geolocation: IP address geolocation via ip-api.com
|
|
8
|
+
* - http-status : HTTP status code lookup and search
|
|
9
|
+
* - http-headers : HTTP header reference lookup and validation
|
|
10
|
+
*/
|
|
11
|
+
declare const DNS_RECORD_TYPES: readonly ["A", "AAAA", "CNAME", "MX", "TXT", "NS", "SOA", "PTR", "SRV", "CAA"];
|
|
12
|
+
type DnsRecordType = typeof DNS_RECORD_TYPES[number];
|
|
13
|
+
interface DnsRecord {
|
|
14
|
+
name: string;
|
|
15
|
+
type: number;
|
|
16
|
+
TTL: number;
|
|
17
|
+
data: string;
|
|
18
|
+
}
|
|
19
|
+
interface DnsResponse {
|
|
20
|
+
Status: number;
|
|
21
|
+
TC: boolean;
|
|
22
|
+
RD: boolean;
|
|
23
|
+
RA: boolean;
|
|
24
|
+
AD: boolean;
|
|
25
|
+
CD: boolean;
|
|
26
|
+
Question: Array<{
|
|
27
|
+
name: string;
|
|
28
|
+
type: number;
|
|
29
|
+
}>;
|
|
30
|
+
Answer?: DnsRecord[];
|
|
31
|
+
Authority?: DnsRecord[];
|
|
32
|
+
Comment?: string;
|
|
33
|
+
}
|
|
34
|
+
interface ParsedDnsResult {
|
|
35
|
+
domain: string;
|
|
36
|
+
type: DnsRecordType;
|
|
37
|
+
records: Array<{
|
|
38
|
+
name: string;
|
|
39
|
+
ttl: number;
|
|
40
|
+
data: string;
|
|
41
|
+
typeLabel: string;
|
|
42
|
+
}>;
|
|
43
|
+
status: 'ok' | 'nxdomain' | 'error';
|
|
44
|
+
statusText: string;
|
|
45
|
+
raw: DnsResponse;
|
|
46
|
+
}
|
|
47
|
+
declare function buildDnsQueryUrl(domain: string, type: DnsRecordType): string;
|
|
48
|
+
declare function typeNumberToLabel(typeNum: number): string;
|
|
49
|
+
declare function parseDnsResponse(response: DnsResponse, domain: string, type: DnsRecordType): ParsedDnsResult;
|
|
50
|
+
declare function validateDomain(domain: string): boolean;
|
|
51
|
+
declare function formatTtl(seconds: number): string;
|
|
52
|
+
declare function statusCodeToText(status: number): string;
|
|
53
|
+
interface GeoResult {
|
|
54
|
+
ip: string;
|
|
55
|
+
country: string;
|
|
56
|
+
countryCode: string;
|
|
57
|
+
region: string;
|
|
58
|
+
regionName: string;
|
|
59
|
+
city: string;
|
|
60
|
+
zip: string;
|
|
61
|
+
lat: number;
|
|
62
|
+
lon: number;
|
|
63
|
+
timezone: string;
|
|
64
|
+
isp: string;
|
|
65
|
+
org: string;
|
|
66
|
+
as: string;
|
|
67
|
+
query: string;
|
|
68
|
+
}
|
|
69
|
+
interface ParsedGeoResult {
|
|
70
|
+
ip: string;
|
|
71
|
+
location: string;
|
|
72
|
+
coordinates: string;
|
|
73
|
+
timezone: string;
|
|
74
|
+
isp: string;
|
|
75
|
+
org: string;
|
|
76
|
+
asn: string;
|
|
77
|
+
mapUrl: string;
|
|
78
|
+
countryFlag: string;
|
|
79
|
+
}
|
|
80
|
+
declare function buildGeoUrl(ip?: string): string;
|
|
81
|
+
declare function parseGeoResponse(data: GeoResult & {
|
|
82
|
+
status?: string;
|
|
83
|
+
message?: string;
|
|
84
|
+
}): ParsedGeoResult | {
|
|
85
|
+
error: string;
|
|
86
|
+
};
|
|
87
|
+
declare function isValidIpv4(ip: string): boolean;
|
|
88
|
+
declare function isValidIpv6(ip: string): boolean;
|
|
89
|
+
declare function isValidIp(ip: string): boolean;
|
|
90
|
+
declare function countryCodeToFlag(code: string): string;
|
|
91
|
+
declare function formatCoordinates(lat: number, lon: number): string;
|
|
92
|
+
declare function buildMapUrl(lat: number, lon: number, zoom?: number): string;
|
|
93
|
+
interface StatusCode {
|
|
94
|
+
code: number;
|
|
95
|
+
name: string;
|
|
96
|
+
description: string;
|
|
97
|
+
category: '1xx' | '2xx' | '3xx' | '4xx' | '5xx';
|
|
98
|
+
mdn?: string;
|
|
99
|
+
}
|
|
100
|
+
declare const STATUS_CODES: StatusCode[];
|
|
101
|
+
declare function getStatusCode(code: number): StatusCode | undefined;
|
|
102
|
+
declare function getStatusByCategory(category: '1xx' | '2xx' | '3xx' | '4xx' | '5xx'): StatusCode[];
|
|
103
|
+
declare function searchStatusCodes(query: string): StatusCode[];
|
|
104
|
+
declare function isSuccess(code: number): boolean;
|
|
105
|
+
declare function isClientError(code: number): boolean;
|
|
106
|
+
declare function isServerError(code: number): boolean;
|
|
107
|
+
type HeaderCategory = 'request' | 'response' | 'both' | 'security' | 'cors' | 'caching' | 'deprecated';
|
|
108
|
+
interface HttpHeader {
|
|
109
|
+
name: string;
|
|
110
|
+
category: HeaderCategory;
|
|
111
|
+
description: string;
|
|
112
|
+
example: string;
|
|
113
|
+
mdn?: string;
|
|
114
|
+
standard: boolean;
|
|
115
|
+
}
|
|
116
|
+
declare const HTTP_HEADERS: HttpHeader[];
|
|
117
|
+
declare function getHeader(name: string): HttpHeader | undefined;
|
|
118
|
+
declare function getHeadersByCategory(category: HeaderCategory): HttpHeader[];
|
|
119
|
+
/** Alias kept for source-level compatibility with the web app's getByCategory export. */
|
|
120
|
+
declare function getByCategory(category: HeaderCategory): HttpHeader[];
|
|
121
|
+
declare function searchHeaders(query: string): HttpHeader[];
|
|
122
|
+
declare function validateHeaderName(name: string): boolean;
|
|
123
|
+
declare function validateHeaderValue(name: string, value: string): {
|
|
124
|
+
valid: boolean;
|
|
125
|
+
warning?: string;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
declare const network_DNS_RECORD_TYPES: typeof DNS_RECORD_TYPES;
|
|
129
|
+
type network_DnsRecord = DnsRecord;
|
|
130
|
+
type network_DnsRecordType = DnsRecordType;
|
|
131
|
+
type network_DnsResponse = DnsResponse;
|
|
132
|
+
type network_GeoResult = GeoResult;
|
|
133
|
+
declare const network_HTTP_HEADERS: typeof HTTP_HEADERS;
|
|
134
|
+
type network_HeaderCategory = HeaderCategory;
|
|
135
|
+
type network_HttpHeader = HttpHeader;
|
|
136
|
+
type network_ParsedDnsResult = ParsedDnsResult;
|
|
137
|
+
type network_ParsedGeoResult = ParsedGeoResult;
|
|
138
|
+
declare const network_STATUS_CODES: typeof STATUS_CODES;
|
|
139
|
+
type network_StatusCode = StatusCode;
|
|
140
|
+
declare const network_buildDnsQueryUrl: typeof buildDnsQueryUrl;
|
|
141
|
+
declare const network_buildGeoUrl: typeof buildGeoUrl;
|
|
142
|
+
declare const network_buildMapUrl: typeof buildMapUrl;
|
|
143
|
+
declare const network_countryCodeToFlag: typeof countryCodeToFlag;
|
|
144
|
+
declare const network_formatCoordinates: typeof formatCoordinates;
|
|
145
|
+
declare const network_formatTtl: typeof formatTtl;
|
|
146
|
+
declare const network_getByCategory: typeof getByCategory;
|
|
147
|
+
declare const network_getHeader: typeof getHeader;
|
|
148
|
+
declare const network_getHeadersByCategory: typeof getHeadersByCategory;
|
|
149
|
+
declare const network_getStatusByCategory: typeof getStatusByCategory;
|
|
150
|
+
declare const network_getStatusCode: typeof getStatusCode;
|
|
151
|
+
declare const network_isClientError: typeof isClientError;
|
|
152
|
+
declare const network_isServerError: typeof isServerError;
|
|
153
|
+
declare const network_isSuccess: typeof isSuccess;
|
|
154
|
+
declare const network_isValidIp: typeof isValidIp;
|
|
155
|
+
declare const network_isValidIpv4: typeof isValidIpv4;
|
|
156
|
+
declare const network_isValidIpv6: typeof isValidIpv6;
|
|
157
|
+
declare const network_parseDnsResponse: typeof parseDnsResponse;
|
|
158
|
+
declare const network_parseGeoResponse: typeof parseGeoResponse;
|
|
159
|
+
declare const network_searchHeaders: typeof searchHeaders;
|
|
160
|
+
declare const network_searchStatusCodes: typeof searchStatusCodes;
|
|
161
|
+
declare const network_statusCodeToText: typeof statusCodeToText;
|
|
162
|
+
declare const network_typeNumberToLabel: typeof typeNumberToLabel;
|
|
163
|
+
declare const network_validateDomain: typeof validateDomain;
|
|
164
|
+
declare const network_validateHeaderName: typeof validateHeaderName;
|
|
165
|
+
declare const network_validateHeaderValue: typeof validateHeaderValue;
|
|
166
|
+
declare namespace network {
|
|
167
|
+
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_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_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 };
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export { parseGeoResponse as A, searchHeaders as B, searchStatusCodes as C, DNS_RECORD_TYPES as D, statusCodeToText as E, typeNumberToLabel as F, type GeoResult as G, HTTP_HEADERS as H, validateDomain as I, validateHeaderName as J, validateHeaderValue as K, type ParsedDnsResult as P, STATUS_CODES as S, type DnsRecord as a, type DnsRecordType as b, type DnsResponse as c, type HeaderCategory as d, type HttpHeader as e, type ParsedGeoResult as f, type StatusCode as g, buildDnsQueryUrl as h, buildGeoUrl as i, buildMapUrl as j, countryCodeToFlag as k, formatCoordinates as l, formatTtl as m, network as n, getByCategory as o, getHeader as p, getHeadersByCategory as q, getStatusByCategory as r, getStatusCode as s, isClientError as t, isServerError as u, isSuccess as v, isValidIp as w, isValidIpv4 as x, isValidIpv6 as y, parseDnsResponse as z };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module network
|
|
3
|
+
* Network utility tools for the @utilix/sdk Node.js SDK.
|
|
4
|
+
*
|
|
5
|
+
* Tools covered:
|
|
6
|
+
* - dns-lookup : DNS record querying via Cloudflare DoH
|
|
7
|
+
* - ip-geolocation: IP address geolocation via ip-api.com
|
|
8
|
+
* - http-status : HTTP status code lookup and search
|
|
9
|
+
* - http-headers : HTTP header reference lookup and validation
|
|
10
|
+
*/
|
|
11
|
+
declare const DNS_RECORD_TYPES: readonly ["A", "AAAA", "CNAME", "MX", "TXT", "NS", "SOA", "PTR", "SRV", "CAA"];
|
|
12
|
+
type DnsRecordType = typeof DNS_RECORD_TYPES[number];
|
|
13
|
+
interface DnsRecord {
|
|
14
|
+
name: string;
|
|
15
|
+
type: number;
|
|
16
|
+
TTL: number;
|
|
17
|
+
data: string;
|
|
18
|
+
}
|
|
19
|
+
interface DnsResponse {
|
|
20
|
+
Status: number;
|
|
21
|
+
TC: boolean;
|
|
22
|
+
RD: boolean;
|
|
23
|
+
RA: boolean;
|
|
24
|
+
AD: boolean;
|
|
25
|
+
CD: boolean;
|
|
26
|
+
Question: Array<{
|
|
27
|
+
name: string;
|
|
28
|
+
type: number;
|
|
29
|
+
}>;
|
|
30
|
+
Answer?: DnsRecord[];
|
|
31
|
+
Authority?: DnsRecord[];
|
|
32
|
+
Comment?: string;
|
|
33
|
+
}
|
|
34
|
+
interface ParsedDnsResult {
|
|
35
|
+
domain: string;
|
|
36
|
+
type: DnsRecordType;
|
|
37
|
+
records: Array<{
|
|
38
|
+
name: string;
|
|
39
|
+
ttl: number;
|
|
40
|
+
data: string;
|
|
41
|
+
typeLabel: string;
|
|
42
|
+
}>;
|
|
43
|
+
status: 'ok' | 'nxdomain' | 'error';
|
|
44
|
+
statusText: string;
|
|
45
|
+
raw: DnsResponse;
|
|
46
|
+
}
|
|
47
|
+
declare function buildDnsQueryUrl(domain: string, type: DnsRecordType): string;
|
|
48
|
+
declare function typeNumberToLabel(typeNum: number): string;
|
|
49
|
+
declare function parseDnsResponse(response: DnsResponse, domain: string, type: DnsRecordType): ParsedDnsResult;
|
|
50
|
+
declare function validateDomain(domain: string): boolean;
|
|
51
|
+
declare function formatTtl(seconds: number): string;
|
|
52
|
+
declare function statusCodeToText(status: number): string;
|
|
53
|
+
interface GeoResult {
|
|
54
|
+
ip: string;
|
|
55
|
+
country: string;
|
|
56
|
+
countryCode: string;
|
|
57
|
+
region: string;
|
|
58
|
+
regionName: string;
|
|
59
|
+
city: string;
|
|
60
|
+
zip: string;
|
|
61
|
+
lat: number;
|
|
62
|
+
lon: number;
|
|
63
|
+
timezone: string;
|
|
64
|
+
isp: string;
|
|
65
|
+
org: string;
|
|
66
|
+
as: string;
|
|
67
|
+
query: string;
|
|
68
|
+
}
|
|
69
|
+
interface ParsedGeoResult {
|
|
70
|
+
ip: string;
|
|
71
|
+
location: string;
|
|
72
|
+
coordinates: string;
|
|
73
|
+
timezone: string;
|
|
74
|
+
isp: string;
|
|
75
|
+
org: string;
|
|
76
|
+
asn: string;
|
|
77
|
+
mapUrl: string;
|
|
78
|
+
countryFlag: string;
|
|
79
|
+
}
|
|
80
|
+
declare function buildGeoUrl(ip?: string): string;
|
|
81
|
+
declare function parseGeoResponse(data: GeoResult & {
|
|
82
|
+
status?: string;
|
|
83
|
+
message?: string;
|
|
84
|
+
}): ParsedGeoResult | {
|
|
85
|
+
error: string;
|
|
86
|
+
};
|
|
87
|
+
declare function isValidIpv4(ip: string): boolean;
|
|
88
|
+
declare function isValidIpv6(ip: string): boolean;
|
|
89
|
+
declare function isValidIp(ip: string): boolean;
|
|
90
|
+
declare function countryCodeToFlag(code: string): string;
|
|
91
|
+
declare function formatCoordinates(lat: number, lon: number): string;
|
|
92
|
+
declare function buildMapUrl(lat: number, lon: number, zoom?: number): string;
|
|
93
|
+
interface StatusCode {
|
|
94
|
+
code: number;
|
|
95
|
+
name: string;
|
|
96
|
+
description: string;
|
|
97
|
+
category: '1xx' | '2xx' | '3xx' | '4xx' | '5xx';
|
|
98
|
+
mdn?: string;
|
|
99
|
+
}
|
|
100
|
+
declare const STATUS_CODES: StatusCode[];
|
|
101
|
+
declare function getStatusCode(code: number): StatusCode | undefined;
|
|
102
|
+
declare function getStatusByCategory(category: '1xx' | '2xx' | '3xx' | '4xx' | '5xx'): StatusCode[];
|
|
103
|
+
declare function searchStatusCodes(query: string): StatusCode[];
|
|
104
|
+
declare function isSuccess(code: number): boolean;
|
|
105
|
+
declare function isClientError(code: number): boolean;
|
|
106
|
+
declare function isServerError(code: number): boolean;
|
|
107
|
+
type HeaderCategory = 'request' | 'response' | 'both' | 'security' | 'cors' | 'caching' | 'deprecated';
|
|
108
|
+
interface HttpHeader {
|
|
109
|
+
name: string;
|
|
110
|
+
category: HeaderCategory;
|
|
111
|
+
description: string;
|
|
112
|
+
example: string;
|
|
113
|
+
mdn?: string;
|
|
114
|
+
standard: boolean;
|
|
115
|
+
}
|
|
116
|
+
declare const HTTP_HEADERS: HttpHeader[];
|
|
117
|
+
declare function getHeader(name: string): HttpHeader | undefined;
|
|
118
|
+
declare function getHeadersByCategory(category: HeaderCategory): HttpHeader[];
|
|
119
|
+
/** Alias kept for source-level compatibility with the web app's getByCategory export. */
|
|
120
|
+
declare function getByCategory(category: HeaderCategory): HttpHeader[];
|
|
121
|
+
declare function searchHeaders(query: string): HttpHeader[];
|
|
122
|
+
declare function validateHeaderName(name: string): boolean;
|
|
123
|
+
declare function validateHeaderValue(name: string, value: string): {
|
|
124
|
+
valid: boolean;
|
|
125
|
+
warning?: string;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
declare const network_DNS_RECORD_TYPES: typeof DNS_RECORD_TYPES;
|
|
129
|
+
type network_DnsRecord = DnsRecord;
|
|
130
|
+
type network_DnsRecordType = DnsRecordType;
|
|
131
|
+
type network_DnsResponse = DnsResponse;
|
|
132
|
+
type network_GeoResult = GeoResult;
|
|
133
|
+
declare const network_HTTP_HEADERS: typeof HTTP_HEADERS;
|
|
134
|
+
type network_HeaderCategory = HeaderCategory;
|
|
135
|
+
type network_HttpHeader = HttpHeader;
|
|
136
|
+
type network_ParsedDnsResult = ParsedDnsResult;
|
|
137
|
+
type network_ParsedGeoResult = ParsedGeoResult;
|
|
138
|
+
declare const network_STATUS_CODES: typeof STATUS_CODES;
|
|
139
|
+
type network_StatusCode = StatusCode;
|
|
140
|
+
declare const network_buildDnsQueryUrl: typeof buildDnsQueryUrl;
|
|
141
|
+
declare const network_buildGeoUrl: typeof buildGeoUrl;
|
|
142
|
+
declare const network_buildMapUrl: typeof buildMapUrl;
|
|
143
|
+
declare const network_countryCodeToFlag: typeof countryCodeToFlag;
|
|
144
|
+
declare const network_formatCoordinates: typeof formatCoordinates;
|
|
145
|
+
declare const network_formatTtl: typeof formatTtl;
|
|
146
|
+
declare const network_getByCategory: typeof getByCategory;
|
|
147
|
+
declare const network_getHeader: typeof getHeader;
|
|
148
|
+
declare const network_getHeadersByCategory: typeof getHeadersByCategory;
|
|
149
|
+
declare const network_getStatusByCategory: typeof getStatusByCategory;
|
|
150
|
+
declare const network_getStatusCode: typeof getStatusCode;
|
|
151
|
+
declare const network_isClientError: typeof isClientError;
|
|
152
|
+
declare const network_isServerError: typeof isServerError;
|
|
153
|
+
declare const network_isSuccess: typeof isSuccess;
|
|
154
|
+
declare const network_isValidIp: typeof isValidIp;
|
|
155
|
+
declare const network_isValidIpv4: typeof isValidIpv4;
|
|
156
|
+
declare const network_isValidIpv6: typeof isValidIpv6;
|
|
157
|
+
declare const network_parseDnsResponse: typeof parseDnsResponse;
|
|
158
|
+
declare const network_parseGeoResponse: typeof parseGeoResponse;
|
|
159
|
+
declare const network_searchHeaders: typeof searchHeaders;
|
|
160
|
+
declare const network_searchStatusCodes: typeof searchStatusCodes;
|
|
161
|
+
declare const network_statusCodeToText: typeof statusCodeToText;
|
|
162
|
+
declare const network_typeNumberToLabel: typeof typeNumberToLabel;
|
|
163
|
+
declare const network_validateDomain: typeof validateDomain;
|
|
164
|
+
declare const network_validateHeaderName: typeof validateHeaderName;
|
|
165
|
+
declare const network_validateHeaderValue: typeof validateHeaderValue;
|
|
166
|
+
declare namespace network {
|
|
167
|
+
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_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_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 };
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export { parseGeoResponse as A, searchHeaders as B, searchStatusCodes as C, DNS_RECORD_TYPES as D, statusCodeToText as E, typeNumberToLabel as F, type GeoResult as G, HTTP_HEADERS as H, validateDomain as I, validateHeaderName as J, validateHeaderValue as K, type ParsedDnsResult as P, STATUS_CODES as S, type DnsRecord as a, type DnsRecordType as b, type DnsResponse as c, type HeaderCategory as d, type HttpHeader as e, type ParsedGeoResult as f, type StatusCode as g, buildDnsQueryUrl as h, buildGeoUrl as i, buildMapUrl as j, countryCodeToFlag as k, formatCoordinates as l, formatTtl as m, network as n, getByCategory as o, getHeader as p, getHeadersByCategory as q, getStatusByCategory as r, getStatusCode as s, isClientError as t, isServerError as u, isSuccess as v, isValidIp as w, isValidIpv4 as x, isValidIpv6 as y, parseDnsResponse as z };
|