@utilix-tech/sdk 0.32.0 → 0.34.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 +8 -0
- package/README.md +15 -6
- package/dist/{chunk-CSNTHZHF.js → chunk-3YUKLV5N.js} +81 -1
- package/dist/{chunk-LXKIPPDG.js → chunk-UUT5HNST.js} +121 -1
- package/dist/{chunk-6FIB72KX.js → chunk-YEXQDI3J.js} +63 -1
- package/dist/{chunk-GDIZWDBY.js → chunk-ZPQOE7KD.js} +78 -1
- package/dist/{code-DaRvff2v.d.cts → code-BK-x8hVx.d.cts} +51 -2
- package/dist/{code-DaRvff2v.d.ts → code-BK-x8hVx.d.ts} +51 -2
- package/dist/{data-C4lCByXw.d.cts → data-CFeS9kes.d.cts} +35 -2
- package/dist/{data-C4lCByXw.d.ts → data-CFeS9kes.d.ts} +35 -2
- package/dist/index.cjs +339 -0
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/{network-D7Epuerc.d.cts → network-DfY5Ikvr.d.cts} +34 -2
- package/dist/{network-D7Epuerc.d.ts → network-DfY5Ikvr.d.ts} +34 -2
- package/dist/tools/code.cjs +120 -0
- package/dist/tools/code.d.cts +1 -1
- package/dist/tools/code.d.ts +1 -1
- package/dist/tools/code.js +1 -1
- package/dist/tools/data.cjs +62 -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/network.cjs +80 -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/dist/tools/units.cjs +77 -0
- package/dist/tools/units.d.cts +1 -1
- package/dist/tools/units.d.ts +1 -1
- package/dist/tools/units.js +1 -1
- package/dist/{units-DQYLZd1n.d.ts → units-BhoxdHhs.d.cts} +42 -2
- package/dist/{units-DQYLZd1n.d.cts → units-BhoxdHhs.d.ts} +42 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4686,6 +4686,7 @@ __export(data_exports, {
|
|
|
4686
4686
|
formatSubtitleTimestamp: () => formatSubtitleTimestamp,
|
|
4687
4687
|
formatToml: () => formatToml,
|
|
4688
4688
|
formatXml: () => formatXml,
|
|
4689
|
+
generateMarkdownToc: () => generateMarkdownToc,
|
|
4689
4690
|
getSection: () => getSection,
|
|
4690
4691
|
getSectionNames: () => getSectionNames,
|
|
4691
4692
|
getTomlStats: () => getTomlStats,
|
|
@@ -6069,6 +6070,67 @@ function parseFrontMatter(input) {
|
|
|
6069
6070
|
}
|
|
6070
6071
|
return { frontMatter, body: afterClose, hasFrontMatter: true, raw };
|
|
6071
6072
|
}
|
|
6073
|
+
function stripInlineMarkdown(text) {
|
|
6074
|
+
return text.replace(/(\*\*\*|___)(.+?)\1/g, "$2").replace(/(\*\*|__)(.+?)\1/g, "$2").replace(/(\*|_)(.+?)\1/g, "$2").replace(/`([^`]+)`/g, "$1").replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/\[([^\]]+)\]\([^)]*\)/g, "$1").trim();
|
|
6075
|
+
}
|
|
6076
|
+
function slugifyHeading(text, seen) {
|
|
6077
|
+
let slug = text.toLowerCase().trim().replace(/[^\p{L}\p{N}\s_-]/gu, "").replace(/\s/g, "-");
|
|
6078
|
+
const count = seen.get(slug) ?? 0;
|
|
6079
|
+
seen.set(slug, count + 1);
|
|
6080
|
+
if (count > 0) slug = `${slug}-${count}`;
|
|
6081
|
+
return slug;
|
|
6082
|
+
}
|
|
6083
|
+
function generateMarkdownToc(markdown, options = {}) {
|
|
6084
|
+
if (typeof markdown !== "string" || markdown.trim() === "") {
|
|
6085
|
+
return { error: "markdown is required" };
|
|
6086
|
+
}
|
|
6087
|
+
const minLevel = options.minLevel ?? 1;
|
|
6088
|
+
const maxLevel = options.maxLevel ?? 6;
|
|
6089
|
+
if (!Number.isInteger(minLevel) || !Number.isInteger(maxLevel) || minLevel < 1 || minLevel > 6 || maxLevel < 1 || maxLevel > 6 || minLevel > maxLevel) {
|
|
6090
|
+
return { error: "minLevel and maxLevel must be integers between 1 and 6, with minLevel <= maxLevel" };
|
|
6091
|
+
}
|
|
6092
|
+
const lines = markdown.replace(/\r\n/g, "\n").split("\n");
|
|
6093
|
+
const entries = [];
|
|
6094
|
+
const seen = /* @__PURE__ */ new Map();
|
|
6095
|
+
let inFence = false;
|
|
6096
|
+
let fenceMarker = "";
|
|
6097
|
+
for (const line of lines) {
|
|
6098
|
+
const fenceMatch = line.match(/^\s*(```+|~~~+)/);
|
|
6099
|
+
if (fenceMatch) {
|
|
6100
|
+
if (!inFence) {
|
|
6101
|
+
inFence = true;
|
|
6102
|
+
fenceMarker = fenceMatch[1][0];
|
|
6103
|
+
} else if (fenceMatch[1][0] === fenceMarker) {
|
|
6104
|
+
inFence = false;
|
|
6105
|
+
}
|
|
6106
|
+
continue;
|
|
6107
|
+
}
|
|
6108
|
+
if (inFence) continue;
|
|
6109
|
+
const headingMatch = line.match(/^(#{1,6})\s+(.+?)\s*#*\s*$/);
|
|
6110
|
+
if (!headingMatch) continue;
|
|
6111
|
+
const level = headingMatch[1].length;
|
|
6112
|
+
const text = stripInlineMarkdown(headingMatch[2]);
|
|
6113
|
+
if (text === "") continue;
|
|
6114
|
+
const slug = slugifyHeading(text, seen);
|
|
6115
|
+
if (level < minLevel || level > maxLevel) continue;
|
|
6116
|
+
entries.push({ level, text, slug });
|
|
6117
|
+
}
|
|
6118
|
+
if (entries.length === 0) {
|
|
6119
|
+
return { error: "No headings found in the given level range" };
|
|
6120
|
+
}
|
|
6121
|
+
const baseLevel = Math.min(...entries.map((e) => e.level));
|
|
6122
|
+
const counters = [0, 0, 0, 0, 0, 0, 0];
|
|
6123
|
+
const tocLines = entries.map((e) => {
|
|
6124
|
+
const indent = " ".repeat(e.level - baseLevel);
|
|
6125
|
+
if (options.ordered) {
|
|
6126
|
+
counters[e.level] = (counters[e.level] ?? 0) + 1;
|
|
6127
|
+
for (let l = e.level + 1; l < counters.length; l++) counters[l] = 0;
|
|
6128
|
+
return `${indent}${counters[e.level]}. [${e.text}](#${e.slug})`;
|
|
6129
|
+
}
|
|
6130
|
+
return `${indent}- [${e.text}](#${e.slug})`;
|
|
6131
|
+
});
|
|
6132
|
+
return { toc: tocLines.join("\n"), entries };
|
|
6133
|
+
}
|
|
6072
6134
|
|
|
6073
6135
|
// src/tools/generators.ts
|
|
6074
6136
|
var generators_exports = {};
|
|
@@ -7493,6 +7555,7 @@ __export(units_exports, {
|
|
|
7493
7555
|
calculateMarginMarkup: () => calculateMarginMarkup,
|
|
7494
7556
|
calculatePercentageChange: () => calculatePercentageChange,
|
|
7495
7557
|
calculateRuleOf72: () => calculateRuleOf72,
|
|
7558
|
+
calculateSavingsGoal: () => calculateSavingsGoal,
|
|
7496
7559
|
calculateSimpleInterest: () => calculateSimpleInterest,
|
|
7497
7560
|
calculateTax: () => calculateTax,
|
|
7498
7561
|
calculateTimeValue: () => calculateTimeValue,
|
|
@@ -9198,17 +9261,95 @@ function calculateEmi(principal, annualRatePercent, tenure, tenureUnit = "years"
|
|
|
9198
9261
|
yearlyBreakdown
|
|
9199
9262
|
};
|
|
9200
9263
|
}
|
|
9264
|
+
function calculateSavingsGoal(input) {
|
|
9265
|
+
const { mode, goalAmount, currentSavings, annualInterestRatePercent, monthlyContribution, months } = input;
|
|
9266
|
+
if (mode !== "time-to-goal" && mode !== "contribution-for-target") {
|
|
9267
|
+
return { error: "mode must be 'time-to-goal' or 'contribution-for-target'" };
|
|
9268
|
+
}
|
|
9269
|
+
if (!Number.isFinite(goalAmount) || goalAmount <= 0) return { error: "goalAmount must be a finite number greater than zero" };
|
|
9270
|
+
if (!Number.isFinite(currentSavings) || currentSavings < 0) return { error: "currentSavings must be a finite, non-negative number" };
|
|
9271
|
+
if (!Number.isFinite(annualInterestRatePercent) || annualInterestRatePercent < 0) {
|
|
9272
|
+
return { error: "annualInterestRatePercent must be a finite, non-negative number" };
|
|
9273
|
+
}
|
|
9274
|
+
const round4 = (n) => Math.round(n * 1e4) / 1e4;
|
|
9275
|
+
const r = annualInterestRatePercent / 100 / 12;
|
|
9276
|
+
if (mode === "time-to-goal") {
|
|
9277
|
+
if (typeof monthlyContribution !== "number" || !Number.isFinite(monthlyContribution) || monthlyContribution < 0) {
|
|
9278
|
+
return { error: "monthlyContribution must be a finite, non-negative number" };
|
|
9279
|
+
}
|
|
9280
|
+
let exactMonths;
|
|
9281
|
+
if (currentSavings >= goalAmount) {
|
|
9282
|
+
exactMonths = 0;
|
|
9283
|
+
} else if (monthlyContribution === 0) {
|
|
9284
|
+
if (r === 0) return { error: "monthlyContribution must be greater than zero when annualInterestRatePercent is zero, since savings would never grow toward the goal" };
|
|
9285
|
+
if (currentSavings <= 0) return { error: "monthlyContribution must be greater than zero when currentSavings is zero, since there is nothing to compound" };
|
|
9286
|
+
exactMonths = Math.log(goalAmount / currentSavings) / Math.log(1 + r);
|
|
9287
|
+
} else if (r === 0) {
|
|
9288
|
+
exactMonths = (goalAmount - currentSavings) / monthlyContribution;
|
|
9289
|
+
} else {
|
|
9290
|
+
const denom = currentSavings + monthlyContribution / r;
|
|
9291
|
+
const x = (goalAmount + monthlyContribution / r) / denom;
|
|
9292
|
+
exactMonths = Math.log(x) / Math.log(1 + r);
|
|
9293
|
+
}
|
|
9294
|
+
const monthsRounded = Math.max(0, Math.ceil(exactMonths));
|
|
9295
|
+
const finalBalance = r === 0 ? currentSavings + monthlyContribution * monthsRounded : currentSavings * Math.pow(1 + r, monthsRounded) + monthlyContribution * ((Math.pow(1 + r, monthsRounded) - 1) / r);
|
|
9296
|
+
const totalContributed2 = monthlyContribution * monthsRounded;
|
|
9297
|
+
const totalInterestEarned2 = finalBalance - currentSavings - totalContributed2;
|
|
9298
|
+
return {
|
|
9299
|
+
mode,
|
|
9300
|
+
goalAmount: round4(goalAmount),
|
|
9301
|
+
currentSavings: round4(currentSavings),
|
|
9302
|
+
annualInterestRatePercent: round4(annualInterestRatePercent),
|
|
9303
|
+
monthlyContribution: round4(monthlyContribution),
|
|
9304
|
+
months: round4(exactMonths),
|
|
9305
|
+
monthsRounded,
|
|
9306
|
+
years: round4(monthsRounded / 12),
|
|
9307
|
+
totalContributed: round4(totalContributed2),
|
|
9308
|
+
totalInterestEarned: round4(totalInterestEarned2),
|
|
9309
|
+
finalBalance: round4(finalBalance)
|
|
9310
|
+
};
|
|
9311
|
+
}
|
|
9312
|
+
if (typeof months !== "number" || !Number.isFinite(months) || !Number.isInteger(months) || months <= 0) {
|
|
9313
|
+
return { error: "months must be a positive integer" };
|
|
9314
|
+
}
|
|
9315
|
+
const growthOfCurrentSavings = r === 0 ? currentSavings : currentSavings * Math.pow(1 + r, months);
|
|
9316
|
+
let requiredMonthlyContribution;
|
|
9317
|
+
if (growthOfCurrentSavings >= goalAmount) {
|
|
9318
|
+
requiredMonthlyContribution = 0;
|
|
9319
|
+
} else if (r === 0) {
|
|
9320
|
+
requiredMonthlyContribution = (goalAmount - currentSavings) / months;
|
|
9321
|
+
} else {
|
|
9322
|
+
requiredMonthlyContribution = (goalAmount - growthOfCurrentSavings) * r / (Math.pow(1 + r, months) - 1);
|
|
9323
|
+
}
|
|
9324
|
+
const totalContributed = requiredMonthlyContribution * months;
|
|
9325
|
+
const totalInterestEarned = goalAmount - currentSavings - totalContributed;
|
|
9326
|
+
return {
|
|
9327
|
+
mode,
|
|
9328
|
+
goalAmount: round4(goalAmount),
|
|
9329
|
+
currentSavings: round4(currentSavings),
|
|
9330
|
+
annualInterestRatePercent: round4(annualInterestRatePercent),
|
|
9331
|
+
monthlyContribution: round4(requiredMonthlyContribution),
|
|
9332
|
+
months,
|
|
9333
|
+
monthsRounded: months,
|
|
9334
|
+
years: round4(months / 12),
|
|
9335
|
+
totalContributed: round4(totalContributed),
|
|
9336
|
+
totalInterestEarned: round4(totalInterestEarned),
|
|
9337
|
+
finalBalance: round4(goalAmount)
|
|
9338
|
+
};
|
|
9339
|
+
}
|
|
9201
9340
|
|
|
9202
9341
|
// src/tools/network.ts
|
|
9203
9342
|
var network_exports = {};
|
|
9204
9343
|
__export(network_exports, {
|
|
9205
9344
|
DNS_RECORD_TYPES: () => DNS_RECORD_TYPES,
|
|
9206
9345
|
HTTP_HEADERS: () => HTTP_HEADERS,
|
|
9346
|
+
REFERRER_POLICY_VALUES: () => REFERRER_POLICY_VALUES,
|
|
9207
9347
|
STATUS_CODES: () => STATUS_CODES,
|
|
9208
9348
|
buildCacheControl: () => buildCacheControl,
|
|
9209
9349
|
buildDnsQueryUrl: () => buildDnsQueryUrl,
|
|
9210
9350
|
buildGeoUrl: () => buildGeoUrl,
|
|
9211
9351
|
buildMapUrl: () => buildMapUrl,
|
|
9352
|
+
buildReferrerPolicy: () => buildReferrerPolicy,
|
|
9212
9353
|
countryCodeToFlag: () => countryCodeToFlag,
|
|
9213
9354
|
formatCoordinates: () => formatCoordinates,
|
|
9214
9355
|
formatTtl: () => formatTtl,
|
|
@@ -11014,6 +11155,84 @@ function buildCacheControl(options = {}) {
|
|
|
11014
11155
|
const snippet = `Cache-Control: ${header}`;
|
|
11015
11156
|
return { header, headerName: "Cache-Control", snippet, directives, warnings };
|
|
11016
11157
|
}
|
|
11158
|
+
var REFERRER_POLICY_VALUES = [
|
|
11159
|
+
"no-referrer",
|
|
11160
|
+
"no-referrer-when-downgrade",
|
|
11161
|
+
"origin",
|
|
11162
|
+
"origin-when-cross-origin",
|
|
11163
|
+
"same-origin",
|
|
11164
|
+
"strict-origin",
|
|
11165
|
+
"strict-origin-when-cross-origin",
|
|
11166
|
+
"unsafe-url"
|
|
11167
|
+
];
|
|
11168
|
+
var _REFERRER_POLICY_INFO = {
|
|
11169
|
+
"no-referrer": {
|
|
11170
|
+
explanation: "Never sends the Referer header, on any request. The strictest option; the destination learns nothing about where the request came from.",
|
|
11171
|
+
leaksPathAndQuery: false,
|
|
11172
|
+
sentOnDowngrade: false
|
|
11173
|
+
},
|
|
11174
|
+
"no-referrer-when-downgrade": {
|
|
11175
|
+
explanation: "Sends the full URL (origin, path, and query string) for same-security-level or upgrading requests, but omits the header entirely when navigating from HTTPS to HTTP. This was the legacy browser default before strict-origin-when-cross-origin.",
|
|
11176
|
+
leaksPathAndQuery: true,
|
|
11177
|
+
sentOnDowngrade: false
|
|
11178
|
+
},
|
|
11179
|
+
origin: {
|
|
11180
|
+
explanation: "Sends only the origin (scheme, host, and port) on every request, same-origin or cross-origin, including on a downgrade. The path and query string are always stripped.",
|
|
11181
|
+
leaksPathAndQuery: false,
|
|
11182
|
+
sentOnDowngrade: true
|
|
11183
|
+
},
|
|
11184
|
+
"origin-when-cross-origin": {
|
|
11185
|
+
explanation: "Sends the full URL for same-origin requests, but only the origin for cross-origin requests. Still sends the origin on a downgrade.",
|
|
11186
|
+
leaksPathAndQuery: true,
|
|
11187
|
+
sentOnDowngrade: true
|
|
11188
|
+
},
|
|
11189
|
+
"same-origin": {
|
|
11190
|
+
explanation: "Sends the full URL for same-origin requests, and no Referer header at all for cross-origin requests.",
|
|
11191
|
+
leaksPathAndQuery: true,
|
|
11192
|
+
sentOnDowngrade: false
|
|
11193
|
+
},
|
|
11194
|
+
"strict-origin": {
|
|
11195
|
+
explanation: "Sends only the origin, and only when the security level stays the same or improves (HTTPS to HTTPS, or HTTP to anything). Nothing is sent on a downgrade from HTTPS to HTTP.",
|
|
11196
|
+
leaksPathAndQuery: false,
|
|
11197
|
+
sentOnDowngrade: false
|
|
11198
|
+
},
|
|
11199
|
+
"strict-origin-when-cross-origin": {
|
|
11200
|
+
explanation: "Sends the full URL for same-origin requests, only the origin for cross-origin requests at the same or better security level, and nothing at all on a downgrade. This is the current browser default when no policy is set.",
|
|
11201
|
+
leaksPathAndQuery: true,
|
|
11202
|
+
sentOnDowngrade: false
|
|
11203
|
+
},
|
|
11204
|
+
"unsafe-url": {
|
|
11205
|
+
explanation: "Always sends the full URL, including path and query string, on every request, even on a downgrade from HTTPS to HTTP. Generally discouraged: query strings can carry session tokens or other sensitive data that then leaks to third-party destinations and to the network on an insecure connection.",
|
|
11206
|
+
leaksPathAndQuery: true,
|
|
11207
|
+
sentOnDowngrade: true
|
|
11208
|
+
}
|
|
11209
|
+
};
|
|
11210
|
+
function buildReferrerPolicy(policies) {
|
|
11211
|
+
const list = Array.isArray(policies) ? policies : [policies];
|
|
11212
|
+
const trimmed = list.map((p) => typeof p === "string" ? p.trim() : "").filter((p) => p !== "");
|
|
11213
|
+
if (trimmed.length === 0) {
|
|
11214
|
+
return { error: "At least one policy value is required" };
|
|
11215
|
+
}
|
|
11216
|
+
const entries = [];
|
|
11217
|
+
for (const value of trimmed) {
|
|
11218
|
+
if (!REFERRER_POLICY_VALUES.includes(value)) {
|
|
11219
|
+
return { error: `'${value}' is not a valid Referrer-Policy value. Valid values: ${REFERRER_POLICY_VALUES.join(", ")}` };
|
|
11220
|
+
}
|
|
11221
|
+
entries.push({ value, ..._REFERRER_POLICY_INFO[value] });
|
|
11222
|
+
}
|
|
11223
|
+
const warnings = [];
|
|
11224
|
+
const last = entries[entries.length - 1];
|
|
11225
|
+
if (last.value === "unsafe-url") {
|
|
11226
|
+
warnings.push("unsafe-url sends the full URL, including query strings, on every request, even over an insecure downgrade. Prefer strict-origin-when-cross-origin unless you have a specific reason to leak full URLs.");
|
|
11227
|
+
}
|
|
11228
|
+
if (entries.length > 1 && entries.some((e, i) => i !== entries.length - 1 && e.value === last.value)) {
|
|
11229
|
+
warnings.push("The same policy value appears more than once in the fallback chain, which has no effect beyond the first occurrence.");
|
|
11230
|
+
}
|
|
11231
|
+
const header = entries.map((e) => e.value).join(", ");
|
|
11232
|
+
const snippet = `Referrer-Policy: ${header}`;
|
|
11233
|
+
const metaTag = `<meta name="referrer" content="${last.value}">`;
|
|
11234
|
+
return { header, headerName: "Referrer-Policy", snippet, metaTag, policies: entries, warnings };
|
|
11235
|
+
}
|
|
11017
11236
|
function isValidIpv6HexGroup(g) {
|
|
11018
11237
|
return /^[0-9a-fA-F]{1,4}$/.test(g);
|
|
11019
11238
|
}
|
|
@@ -12416,6 +12635,7 @@ var code_exports = {};
|
|
|
12416
12635
|
__export(code_exports, {
|
|
12417
12636
|
ALL_FLAGS: () => ALL_FLAGS,
|
|
12418
12637
|
CHEATSHEET: () => CHEATSHEET,
|
|
12638
|
+
DEFAULT_COMMIT_TYPES: () => DEFAULT_COMMIT_TYPES,
|
|
12419
12639
|
MIME_TABLE: () => MIME_TABLE,
|
|
12420
12640
|
OPERATIONS: () => OPERATIONS,
|
|
12421
12641
|
SQL_DEFAULT_OPTIONS: () => SQL_DEFAULT_OPTIONS,
|
|
@@ -12440,6 +12660,7 @@ __export(code_exports, {
|
|
|
12440
12660
|
getJsStats: () => getJsStats,
|
|
12441
12661
|
getMethodColor: () => getMethodColor,
|
|
12442
12662
|
isValidTag: () => isValidTag,
|
|
12663
|
+
lintConventionalCommit: () => lintConventionalCommit,
|
|
12443
12664
|
lookupMime: () => lookupMime,
|
|
12444
12665
|
minifyCss: () => minifyCss,
|
|
12445
12666
|
minifyGql: () => minifyGql,
|
|
@@ -15150,6 +15371,124 @@ function detectRedos(pattern) {
|
|
|
15150
15371
|
findings: unique
|
|
15151
15372
|
};
|
|
15152
15373
|
}
|
|
15374
|
+
var DEFAULT_COMMIT_TYPES = ["build", "chore", "ci", "docs", "feat", "fix", "perf", "refactor", "revert", "style", "test"];
|
|
15375
|
+
var _DEFAULT_MAX_HEADER_LENGTH = 100;
|
|
15376
|
+
var _COMMIT_HEADER_RE = /^([A-Za-z][A-Za-z0-9-]*)(\(([^()]*)\))?(!)?: (.+)$/;
|
|
15377
|
+
var _COMMIT_FOOTER_LINE_RE = /^([A-Za-z][A-Za-z0-9-]*|BREAKING CHANGE)(: ?| #)(.*)$/;
|
|
15378
|
+
var _COMMIT_BREAKING_LOOKALIKE_RE = /^([A-Za-z][A-Za-z -]*?)(: | #)(.*)$/;
|
|
15379
|
+
var _COMMIT_BREAKING_TOKEN_RE = /^breaking[- ]change$/i;
|
|
15380
|
+
function lintConventionalCommit(message, options = {}) {
|
|
15381
|
+
if (typeof message !== "string" || message.trim() === "") {
|
|
15382
|
+
return { error: "message is required" };
|
|
15383
|
+
}
|
|
15384
|
+
if (message.length > 2e4) {
|
|
15385
|
+
return { error: "message too long (max 20,000 chars)" };
|
|
15386
|
+
}
|
|
15387
|
+
const types = options.types && options.types.length > 0 ? options.types : DEFAULT_COMMIT_TYPES;
|
|
15388
|
+
const maxHeaderLength = options.maxHeaderLength ?? _DEFAULT_MAX_HEADER_LENGTH;
|
|
15389
|
+
const findings = [];
|
|
15390
|
+
const lines = message.replace(/\r\n/g, "\n").split("\n");
|
|
15391
|
+
const header = lines[0];
|
|
15392
|
+
const match = header.match(_COMMIT_HEADER_RE);
|
|
15393
|
+
const parsed = {
|
|
15394
|
+
header,
|
|
15395
|
+
type: null,
|
|
15396
|
+
scope: null,
|
|
15397
|
+
breaking: false,
|
|
15398
|
+
description: null,
|
|
15399
|
+
body: null,
|
|
15400
|
+
footers: []
|
|
15401
|
+
};
|
|
15402
|
+
if (!match) {
|
|
15403
|
+
findings.push({
|
|
15404
|
+
rule: "header-format",
|
|
15405
|
+
severity: "error",
|
|
15406
|
+
message: "Header must match '<type>[(scope)][!]: <description>', e.g. 'feat(auth): add OAuth2 login'. A single space must follow the colon."
|
|
15407
|
+
});
|
|
15408
|
+
return { message, valid: false, parsed, findings };
|
|
15409
|
+
}
|
|
15410
|
+
const [, type, scopeGroup, scope, bang, description] = match;
|
|
15411
|
+
parsed.type = type;
|
|
15412
|
+
if (scopeGroup !== void 0) {
|
|
15413
|
+
const scopeContent = (scope ?? "").trim();
|
|
15414
|
+
if (scopeContent === "") {
|
|
15415
|
+
findings.push({ rule: "scope-empty", severity: "error", message: "Scope parentheses are present but empty; either remove the parentheses or put a scope inside them, e.g. fix(parser):." });
|
|
15416
|
+
} else {
|
|
15417
|
+
parsed.scope = scopeContent;
|
|
15418
|
+
}
|
|
15419
|
+
}
|
|
15420
|
+
const trimmedDescription = description.trim();
|
|
15421
|
+
if (trimmedDescription === "") {
|
|
15422
|
+
findings.push({ rule: "subject-empty", severity: "error", message: "The description after the colon must not be empty." });
|
|
15423
|
+
} else {
|
|
15424
|
+
parsed.description = trimmedDescription;
|
|
15425
|
+
if (trimmedDescription.endsWith(".")) {
|
|
15426
|
+
findings.push({ rule: "subject-full-stop", severity: "warning", message: "The description should not end with a period." });
|
|
15427
|
+
}
|
|
15428
|
+
}
|
|
15429
|
+
if (!types.includes(type.toLowerCase())) {
|
|
15430
|
+
findings.push({
|
|
15431
|
+
rule: "type-unknown",
|
|
15432
|
+
severity: "warning",
|
|
15433
|
+
message: `'${type}' is not one of the recognized types (${types.join(", ")}). This is only a convention, not a spec requirement, so a custom type is fine if your team has agreed on it.`
|
|
15434
|
+
});
|
|
15435
|
+
}
|
|
15436
|
+
if (type !== type.toLowerCase()) {
|
|
15437
|
+
findings.push({ rule: "type-case", severity: "warning", message: "The type is conventionally lower-case. The spec itself is not case-sensitive about this, but nearly every tool and team defaults to lower-case." });
|
|
15438
|
+
}
|
|
15439
|
+
if (header.length > maxHeaderLength) {
|
|
15440
|
+
findings.push({ rule: "header-max-length", severity: "warning", message: `Header is ${header.length} characters, longer than the recommended maximum of ${maxHeaderLength}.` });
|
|
15441
|
+
}
|
|
15442
|
+
let breaking = bang === "!";
|
|
15443
|
+
if (lines.length > 1) {
|
|
15444
|
+
if (lines[1].trim() !== "") {
|
|
15445
|
+
findings.push({ rule: "missing-blank-line-before-body", severity: "error", message: "A blank line must separate the header from the body or footer." });
|
|
15446
|
+
}
|
|
15447
|
+
const rest = lines.slice(1).join("\n");
|
|
15448
|
+
const paragraphs = rest.split(/\n{2,}/).map((p) => p.trim()).filter((p) => p !== "");
|
|
15449
|
+
let footerParagraph = null;
|
|
15450
|
+
if (paragraphs.length > 0) {
|
|
15451
|
+
const last = paragraphs[paragraphs.length - 1];
|
|
15452
|
+
const lastLines = last.split("\n");
|
|
15453
|
+
if (lastLines.every((l) => _COMMIT_FOOTER_LINE_RE.test(l.trim()))) {
|
|
15454
|
+
footerParagraph = last;
|
|
15455
|
+
paragraphs.pop();
|
|
15456
|
+
}
|
|
15457
|
+
}
|
|
15458
|
+
parsed.body = paragraphs.length > 0 ? paragraphs.join("\n\n") : null;
|
|
15459
|
+
if (footerParagraph) {
|
|
15460
|
+
for (const line of footerParagraph.split("\n")) {
|
|
15461
|
+
const fm = line.trim().match(_COMMIT_FOOTER_LINE_RE);
|
|
15462
|
+
if (!fm) continue;
|
|
15463
|
+
const [, token, , value] = fm;
|
|
15464
|
+
parsed.footers.push({ token, value: value.trim() });
|
|
15465
|
+
}
|
|
15466
|
+
}
|
|
15467
|
+
for (const f of parsed.footers) {
|
|
15468
|
+
if (_COMMIT_BREAKING_TOKEN_RE.test(f.token) && f.token !== "BREAKING CHANGE" && f.token !== "BREAKING-CHANGE") {
|
|
15469
|
+
findings.push({ rule: "breaking-change-casing", severity: "error", message: `Found '${f.token}:' as a footer, but the spec requires the breaking-change token to be exactly 'BREAKING CHANGE' or 'BREAKING-CHANGE' (uppercase).` });
|
|
15470
|
+
}
|
|
15471
|
+
}
|
|
15472
|
+
for (const p of paragraphs) {
|
|
15473
|
+
for (const line of p.split("\n")) {
|
|
15474
|
+
const bm = line.trim().match(_COMMIT_BREAKING_LOOKALIKE_RE);
|
|
15475
|
+
if (bm && _COMMIT_BREAKING_TOKEN_RE.test(bm[1]) && bm[1] !== "BREAKING CHANGE") {
|
|
15476
|
+
findings.push({ rule: "breaking-change-casing", severity: "error", message: `Found '${bm[1]}' near the end of the message, but it wasn't recognized as a breaking-change footer. The spec requires the exact uppercase token 'BREAKING CHANGE' (or 'BREAKING-CHANGE'), immediately followed by ': '.` });
|
|
15477
|
+
}
|
|
15478
|
+
}
|
|
15479
|
+
}
|
|
15480
|
+
}
|
|
15481
|
+
const breakingFooter = parsed.footers.find((f) => f.token === "BREAKING CHANGE" || f.token === "BREAKING-CHANGE");
|
|
15482
|
+
if (breakingFooter) {
|
|
15483
|
+
breaking = true;
|
|
15484
|
+
if (breakingFooter.value === "") {
|
|
15485
|
+
findings.push({ rule: "breaking-change-empty", severity: "error", message: "A 'BREAKING CHANGE:' footer must be followed by a description of the breaking change." });
|
|
15486
|
+
}
|
|
15487
|
+
}
|
|
15488
|
+
parsed.breaking = breaking;
|
|
15489
|
+
const valid = !findings.some((f) => f.severity === "error");
|
|
15490
|
+
return { message, valid, parsed, findings };
|
|
15491
|
+
}
|
|
15153
15492
|
|
|
15154
15493
|
// src/tools/color.ts
|
|
15155
15494
|
var color_exports = {};
|
package/dist/index.d.cts
CHANGED
|
@@ -2,13 +2,13 @@ export { j as json } from './json-Ta9JykSB.cjs';
|
|
|
2
2
|
export { e as encoding } from './encoding-Dk3wpmb3.cjs';
|
|
3
3
|
export { h as hashing } from './hashing-CnetQFD_.cjs';
|
|
4
4
|
export { t as text } from './text-CA-zuD0C.cjs';
|
|
5
|
-
export { d as data } from './data-
|
|
5
|
+
export { d as data } from './data-CFeS9kes.cjs';
|
|
6
6
|
export { g as generators } from './generators-Du8cBesn.cjs';
|
|
7
7
|
export { t as time } from './time-KqJjdqII.cjs';
|
|
8
|
-
export { u as units } from './units-
|
|
9
|
-
export { n as network } from './network-
|
|
8
|
+
export { u as units } from './units-BhoxdHhs.cjs';
|
|
9
|
+
export { n as network } from './network-DfY5Ikvr.cjs';
|
|
10
10
|
export { a as api } from './api-DmTNE4c1.cjs';
|
|
11
|
-
export { c as code } from './code-
|
|
11
|
+
export { c as code } from './code-BK-x8hVx.cjs';
|
|
12
12
|
export { c as color } from './color-tPwZCr9H.cjs';
|
|
13
13
|
export { c as css } from './css-Cf7AMGM-.cjs';
|
|
14
14
|
export { m as misc } from './misc-CA3N198T.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,13 +2,13 @@ export { j as json } from './json-Ta9JykSB.js';
|
|
|
2
2
|
export { e as encoding } from './encoding-Dk3wpmb3.js';
|
|
3
3
|
export { h as hashing } from './hashing-CnetQFD_.js';
|
|
4
4
|
export { t as text } from './text-CA-zuD0C.js';
|
|
5
|
-
export { d as data } from './data-
|
|
5
|
+
export { d as data } from './data-CFeS9kes.js';
|
|
6
6
|
export { g as generators } from './generators-Du8cBesn.js';
|
|
7
7
|
export { t as time } from './time-KqJjdqII.js';
|
|
8
|
-
export { u as units } from './units-
|
|
9
|
-
export { n as network } from './network-
|
|
8
|
+
export { u as units } from './units-BhoxdHhs.js';
|
|
9
|
+
export { n as network } from './network-DfY5Ikvr.js';
|
|
10
10
|
export { a as api } from './api-DmTNE4c1.js';
|
|
11
|
-
export { c as code } from './code-
|
|
11
|
+
export { c as code } from './code-BK-x8hVx.js';
|
|
12
12
|
export { c as color } from './color-tPwZCr9H.js';
|
|
13
13
|
export { c as css } from './css-Cf7AMGM-.js';
|
|
14
14
|
export { m as misc } from './misc-CA3N198T.js';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { media_exports as media } from './chunk-L6V4W4SU.js';
|
|
2
|
-
export { units_exports as units } from './chunk-
|
|
3
|
-
export { network_exports as network } from './chunk-
|
|
2
|
+
export { units_exports as units } from './chunk-ZPQOE7KD.js';
|
|
3
|
+
export { network_exports as network } from './chunk-3YUKLV5N.js';
|
|
4
4
|
export { api_exports as api } from './chunk-52ZDKSIX.js';
|
|
5
|
-
export { code_exports as code } from './chunk-
|
|
5
|
+
export { code_exports as code } from './chunk-UUT5HNST.js';
|
|
6
6
|
export { color_exports as color } from './chunk-BPVAB4P2.js';
|
|
7
7
|
export { css_exports as css } from './chunk-6YPV2AB5.js';
|
|
8
8
|
export { misc_exports as misc } from './chunk-GX7H6TAX.js';
|
|
@@ -11,7 +11,7 @@ export { json_exports as json } from './chunk-WVEKRKGU.js';
|
|
|
11
11
|
export { encoding_exports as encoding } from './chunk-DOWQZUTP.js';
|
|
12
12
|
export { hashing_exports as hashing } from './chunk-GEFVMGZR.js';
|
|
13
13
|
export { text_exports as text } from './chunk-H2USEUHD.js';
|
|
14
|
-
export { data_exports as data } from './chunk-
|
|
14
|
+
export { data_exports as data } from './chunk-YEXQDI3J.js';
|
|
15
15
|
export { generators_exports as generators } from './chunk-3TYWIX3B.js';
|
|
16
16
|
export { time_exports as time } from './chunk-IEPWZERQ.js';
|
|
17
17
|
import './chunk-MLKGABMK.js';
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* - robots-txt-validator: validateRobotsTxt
|
|
13
13
|
* - user-agent-parser: parseUserAgent
|
|
14
14
|
* - cache-control-builder: buildCacheControl
|
|
15
|
+
* - referrer-policy-builder: buildReferrerPolicy
|
|
15
16
|
* - ipv6-compressor: parseIpv6Address
|
|
16
17
|
*/
|
|
17
18
|
declare const DNS_RECORD_TYPES: readonly ["A", "AAAA", "CNAME", "MX", "TXT", "NS", "SOA", "PTR", "SRV", "CAA"];
|
|
@@ -292,6 +293,32 @@ interface CacheControlResult {
|
|
|
292
293
|
declare function buildCacheControl(options?: CacheControlOptions): CacheControlResult | {
|
|
293
294
|
error: string;
|
|
294
295
|
};
|
|
296
|
+
type ReferrerPolicyValue = 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
|
|
297
|
+
interface ReferrerPolicyEntry {
|
|
298
|
+
value: ReferrerPolicyValue;
|
|
299
|
+
explanation: string;
|
|
300
|
+
leaksPathAndQuery: boolean;
|
|
301
|
+
sentOnDowngrade: boolean;
|
|
302
|
+
}
|
|
303
|
+
interface ReferrerPolicyResult {
|
|
304
|
+
header: string;
|
|
305
|
+
headerName: 'Referrer-Policy';
|
|
306
|
+
snippet: string;
|
|
307
|
+
metaTag: string;
|
|
308
|
+
policies: ReferrerPolicyEntry[];
|
|
309
|
+
warnings: string[];
|
|
310
|
+
}
|
|
311
|
+
declare const REFERRER_POLICY_VALUES: ReferrerPolicyValue[];
|
|
312
|
+
/**
|
|
313
|
+
* Build a `Referrer-Policy` header value from one or more policy tokens
|
|
314
|
+
* (a fallback chain: a browser that doesn't recognize an earlier token
|
|
315
|
+
* falls through to the next one, per the Referrer Policy spec), with a
|
|
316
|
+
* plain-English explanation of each token and warnings for risky choices.
|
|
317
|
+
* Pure string assembly and lookup; it never inspects real request traffic.
|
|
318
|
+
*/
|
|
319
|
+
declare function buildReferrerPolicy(policies: string | string[]): ReferrerPolicyResult | {
|
|
320
|
+
error: string;
|
|
321
|
+
};
|
|
295
322
|
type Ipv6AddressType = 'unspecified' | 'loopback' | 'link-local' | 'unique-local' | 'multicast' | 'ipv4-mapped' | 'documentation' | 'global-unicast';
|
|
296
323
|
interface Ipv6ParseResult {
|
|
297
324
|
expanded: string;
|
|
@@ -328,6 +355,10 @@ type network_Ipv6AddressType = Ipv6AddressType;
|
|
|
328
355
|
type network_Ipv6ParseResult = Ipv6ParseResult;
|
|
329
356
|
type network_ParsedDnsResult = ParsedDnsResult;
|
|
330
357
|
type network_ParsedGeoResult = ParsedGeoResult;
|
|
358
|
+
declare const network_REFERRER_POLICY_VALUES: typeof REFERRER_POLICY_VALUES;
|
|
359
|
+
type network_ReferrerPolicyEntry = ReferrerPolicyEntry;
|
|
360
|
+
type network_ReferrerPolicyResult = ReferrerPolicyResult;
|
|
361
|
+
type network_ReferrerPolicyValue = ReferrerPolicyValue;
|
|
331
362
|
type network_RobotsGroup = RobotsGroup;
|
|
332
363
|
type network_RobotsIssue = RobotsIssue;
|
|
333
364
|
type network_RobotsRule = RobotsRule;
|
|
@@ -344,6 +375,7 @@ declare const network_buildCacheControl: typeof buildCacheControl;
|
|
|
344
375
|
declare const network_buildDnsQueryUrl: typeof buildDnsQueryUrl;
|
|
345
376
|
declare const network_buildGeoUrl: typeof buildGeoUrl;
|
|
346
377
|
declare const network_buildMapUrl: typeof buildMapUrl;
|
|
378
|
+
declare const network_buildReferrerPolicy: typeof buildReferrerPolicy;
|
|
347
379
|
declare const network_countryCodeToFlag: typeof countryCodeToFlag;
|
|
348
380
|
declare const network_formatCoordinates: typeof formatCoordinates;
|
|
349
381
|
declare const network_formatTtl: typeof formatTtl;
|
|
@@ -373,7 +405,7 @@ declare const network_validateHeaderValue: typeof validateHeaderValue;
|
|
|
373
405
|
declare const network_validateRobotsTxt: typeof validateRobotsTxt;
|
|
374
406
|
declare const network_validateSitemap: typeof validateSitemap;
|
|
375
407
|
declare namespace network {
|
|
376
|
-
export { type network_CacheControlDirective as CacheControlDirective, type network_CacheControlOptions as CacheControlOptions, type network_CacheControlResult as CacheControlResult, 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_Ipv6AddressType as Ipv6AddressType, type network_Ipv6ParseResult as Ipv6ParseResult, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, type network_RobotsGroup as RobotsGroup, type network_RobotsIssue as RobotsIssue, type network_RobotsRule as RobotsRule, type network_RobotsValidationResult as RobotsValidationResult, 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, type network_UaDeviceType as UaDeviceType, type network_UserAgentInfo as UserAgentInfo, network_buildCacheControl as buildCacheControl, 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_parseIpv6Address as parseIpv6Address, network_parseUserAgent as parseUserAgent, 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_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
408
|
+
export { type network_CacheControlDirective as CacheControlDirective, type network_CacheControlOptions as CacheControlOptions, type network_CacheControlResult as CacheControlResult, 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_Ipv6AddressType as Ipv6AddressType, type network_Ipv6ParseResult as Ipv6ParseResult, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, network_REFERRER_POLICY_VALUES as REFERRER_POLICY_VALUES, type network_ReferrerPolicyEntry as ReferrerPolicyEntry, type network_ReferrerPolicyResult as ReferrerPolicyResult, type network_ReferrerPolicyValue as ReferrerPolicyValue, type network_RobotsGroup as RobotsGroup, type network_RobotsIssue as RobotsIssue, type network_RobotsRule as RobotsRule, type network_RobotsValidationResult as RobotsValidationResult, 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, type network_UaDeviceType as UaDeviceType, type network_UserAgentInfo as UserAgentInfo, network_buildCacheControl as buildCacheControl, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_buildReferrerPolicy as buildReferrerPolicy, 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_parseIpv6Address as parseIpv6Address, network_parseUserAgent as parseUserAgent, 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_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
377
409
|
}
|
|
378
410
|
|
|
379
|
-
export {
|
|
411
|
+
export { isValidIpv6 as $, buildCacheControl as A, buildDnsQueryUrl as B, type CacheControlDirective as C, DNS_RECORD_TYPES as D, buildGeoUrl as E, buildMapUrl as F, type GeoResult as G, HTTP_HEADERS as H, type Ipv6AddressType as I, buildReferrerPolicy as J, countryCodeToFlag as K, formatCoordinates as L, formatTtl as M, getByCategory as N, getHeader as O, type ParsedDnsResult as P, getHeadersByCategory as Q, REFERRER_POLICY_VALUES as R, STATUS_CODES as S, getStatusByCategory as T, type UaDeviceType as U, getStatusCode as V, isClientError as W, isServerError as X, isSuccess as Y, isValidIp as Z, isValidIpv4 as _, type CacheControlOptions as a, parseDnsResponse as a0, parseGeoResponse as a1, parseHar as a2, parseIpv6Address as a3, parseUserAgent as a4, searchHeaders as a5, searchStatusCodes as a6, statusCodeToText as a7, typeNumberToLabel as a8, validateDomain as a9, validateHeaderName as aa, validateHeaderValue as ab, validateRobotsTxt as ac, validateSitemap as ad, type CacheControlResult as b, type DnsRecord as c, type DnsRecordType as d, type DnsResponse as e, type HarEntry as f, type HarParseResult as g, type HarSummary as h, type HeaderCategory as i, type HttpHeader as j, type Ipv6ParseResult as k, type ParsedGeoResult as l, type ReferrerPolicyEntry as m, network as n, type ReferrerPolicyResult as o, type ReferrerPolicyValue as p, type RobotsGroup as q, type RobotsIssue as r, type RobotsRule as s, type RobotsValidationResult as t, type SitemapIndexEntry as u, type SitemapIssue as v, type SitemapUrlEntry as w, type SitemapValidationResult as x, type StatusCode as y, type UserAgentInfo as z };
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* - robots-txt-validator: validateRobotsTxt
|
|
13
13
|
* - user-agent-parser: parseUserAgent
|
|
14
14
|
* - cache-control-builder: buildCacheControl
|
|
15
|
+
* - referrer-policy-builder: buildReferrerPolicy
|
|
15
16
|
* - ipv6-compressor: parseIpv6Address
|
|
16
17
|
*/
|
|
17
18
|
declare const DNS_RECORD_TYPES: readonly ["A", "AAAA", "CNAME", "MX", "TXT", "NS", "SOA", "PTR", "SRV", "CAA"];
|
|
@@ -292,6 +293,32 @@ interface CacheControlResult {
|
|
|
292
293
|
declare function buildCacheControl(options?: CacheControlOptions): CacheControlResult | {
|
|
293
294
|
error: string;
|
|
294
295
|
};
|
|
296
|
+
type ReferrerPolicyValue = 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
|
|
297
|
+
interface ReferrerPolicyEntry {
|
|
298
|
+
value: ReferrerPolicyValue;
|
|
299
|
+
explanation: string;
|
|
300
|
+
leaksPathAndQuery: boolean;
|
|
301
|
+
sentOnDowngrade: boolean;
|
|
302
|
+
}
|
|
303
|
+
interface ReferrerPolicyResult {
|
|
304
|
+
header: string;
|
|
305
|
+
headerName: 'Referrer-Policy';
|
|
306
|
+
snippet: string;
|
|
307
|
+
metaTag: string;
|
|
308
|
+
policies: ReferrerPolicyEntry[];
|
|
309
|
+
warnings: string[];
|
|
310
|
+
}
|
|
311
|
+
declare const REFERRER_POLICY_VALUES: ReferrerPolicyValue[];
|
|
312
|
+
/**
|
|
313
|
+
* Build a `Referrer-Policy` header value from one or more policy tokens
|
|
314
|
+
* (a fallback chain: a browser that doesn't recognize an earlier token
|
|
315
|
+
* falls through to the next one, per the Referrer Policy spec), with a
|
|
316
|
+
* plain-English explanation of each token and warnings for risky choices.
|
|
317
|
+
* Pure string assembly and lookup; it never inspects real request traffic.
|
|
318
|
+
*/
|
|
319
|
+
declare function buildReferrerPolicy(policies: string | string[]): ReferrerPolicyResult | {
|
|
320
|
+
error: string;
|
|
321
|
+
};
|
|
295
322
|
type Ipv6AddressType = 'unspecified' | 'loopback' | 'link-local' | 'unique-local' | 'multicast' | 'ipv4-mapped' | 'documentation' | 'global-unicast';
|
|
296
323
|
interface Ipv6ParseResult {
|
|
297
324
|
expanded: string;
|
|
@@ -328,6 +355,10 @@ type network_Ipv6AddressType = Ipv6AddressType;
|
|
|
328
355
|
type network_Ipv6ParseResult = Ipv6ParseResult;
|
|
329
356
|
type network_ParsedDnsResult = ParsedDnsResult;
|
|
330
357
|
type network_ParsedGeoResult = ParsedGeoResult;
|
|
358
|
+
declare const network_REFERRER_POLICY_VALUES: typeof REFERRER_POLICY_VALUES;
|
|
359
|
+
type network_ReferrerPolicyEntry = ReferrerPolicyEntry;
|
|
360
|
+
type network_ReferrerPolicyResult = ReferrerPolicyResult;
|
|
361
|
+
type network_ReferrerPolicyValue = ReferrerPolicyValue;
|
|
331
362
|
type network_RobotsGroup = RobotsGroup;
|
|
332
363
|
type network_RobotsIssue = RobotsIssue;
|
|
333
364
|
type network_RobotsRule = RobotsRule;
|
|
@@ -344,6 +375,7 @@ declare const network_buildCacheControl: typeof buildCacheControl;
|
|
|
344
375
|
declare const network_buildDnsQueryUrl: typeof buildDnsQueryUrl;
|
|
345
376
|
declare const network_buildGeoUrl: typeof buildGeoUrl;
|
|
346
377
|
declare const network_buildMapUrl: typeof buildMapUrl;
|
|
378
|
+
declare const network_buildReferrerPolicy: typeof buildReferrerPolicy;
|
|
347
379
|
declare const network_countryCodeToFlag: typeof countryCodeToFlag;
|
|
348
380
|
declare const network_formatCoordinates: typeof formatCoordinates;
|
|
349
381
|
declare const network_formatTtl: typeof formatTtl;
|
|
@@ -373,7 +405,7 @@ declare const network_validateHeaderValue: typeof validateHeaderValue;
|
|
|
373
405
|
declare const network_validateRobotsTxt: typeof validateRobotsTxt;
|
|
374
406
|
declare const network_validateSitemap: typeof validateSitemap;
|
|
375
407
|
declare namespace network {
|
|
376
|
-
export { type network_CacheControlDirective as CacheControlDirective, type network_CacheControlOptions as CacheControlOptions, type network_CacheControlResult as CacheControlResult, 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_Ipv6AddressType as Ipv6AddressType, type network_Ipv6ParseResult as Ipv6ParseResult, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, type network_RobotsGroup as RobotsGroup, type network_RobotsIssue as RobotsIssue, type network_RobotsRule as RobotsRule, type network_RobotsValidationResult as RobotsValidationResult, 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, type network_UaDeviceType as UaDeviceType, type network_UserAgentInfo as UserAgentInfo, network_buildCacheControl as buildCacheControl, 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_parseIpv6Address as parseIpv6Address, network_parseUserAgent as parseUserAgent, 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_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
408
|
+
export { type network_CacheControlDirective as CacheControlDirective, type network_CacheControlOptions as CacheControlOptions, type network_CacheControlResult as CacheControlResult, 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_Ipv6AddressType as Ipv6AddressType, type network_Ipv6ParseResult as Ipv6ParseResult, type network_ParsedDnsResult as ParsedDnsResult, type network_ParsedGeoResult as ParsedGeoResult, network_REFERRER_POLICY_VALUES as REFERRER_POLICY_VALUES, type network_ReferrerPolicyEntry as ReferrerPolicyEntry, type network_ReferrerPolicyResult as ReferrerPolicyResult, type network_ReferrerPolicyValue as ReferrerPolicyValue, type network_RobotsGroup as RobotsGroup, type network_RobotsIssue as RobotsIssue, type network_RobotsRule as RobotsRule, type network_RobotsValidationResult as RobotsValidationResult, 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, type network_UaDeviceType as UaDeviceType, type network_UserAgentInfo as UserAgentInfo, network_buildCacheControl as buildCacheControl, network_buildDnsQueryUrl as buildDnsQueryUrl, network_buildGeoUrl as buildGeoUrl, network_buildMapUrl as buildMapUrl, network_buildReferrerPolicy as buildReferrerPolicy, 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_parseIpv6Address as parseIpv6Address, network_parseUserAgent as parseUserAgent, 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_validateRobotsTxt as validateRobotsTxt, network_validateSitemap as validateSitemap };
|
|
377
409
|
}
|
|
378
410
|
|
|
379
|
-
export {
|
|
411
|
+
export { isValidIpv6 as $, buildCacheControl as A, buildDnsQueryUrl as B, type CacheControlDirective as C, DNS_RECORD_TYPES as D, buildGeoUrl as E, buildMapUrl as F, type GeoResult as G, HTTP_HEADERS as H, type Ipv6AddressType as I, buildReferrerPolicy as J, countryCodeToFlag as K, formatCoordinates as L, formatTtl as M, getByCategory as N, getHeader as O, type ParsedDnsResult as P, getHeadersByCategory as Q, REFERRER_POLICY_VALUES as R, STATUS_CODES as S, getStatusByCategory as T, type UaDeviceType as U, getStatusCode as V, isClientError as W, isServerError as X, isSuccess as Y, isValidIp as Z, isValidIpv4 as _, type CacheControlOptions as a, parseDnsResponse as a0, parseGeoResponse as a1, parseHar as a2, parseIpv6Address as a3, parseUserAgent as a4, searchHeaders as a5, searchStatusCodes as a6, statusCodeToText as a7, typeNumberToLabel as a8, validateDomain as a9, validateHeaderName as aa, validateHeaderValue as ab, validateRobotsTxt as ac, validateSitemap as ad, type CacheControlResult as b, type DnsRecord as c, type DnsRecordType as d, type DnsResponse as e, type HarEntry as f, type HarParseResult as g, type HarSummary as h, type HeaderCategory as i, type HttpHeader as j, type Ipv6ParseResult as k, type ParsedGeoResult as l, type ReferrerPolicyEntry as m, network as n, type ReferrerPolicyResult as o, type ReferrerPolicyValue as p, type RobotsGroup as q, type RobotsIssue as r, type RobotsRule as s, type RobotsValidationResult as t, type SitemapIndexEntry as u, type SitemapIssue as v, type SitemapUrlEntry as w, type SitemapValidationResult as x, type StatusCode as y, type UserAgentInfo as z };
|