@jjlmoya/utils-finance 1.30.0 → 1.32.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/package.json +1 -1
- package/src/category/i18n/en.ts +1 -1
- package/src/category/i18n/es.ts +4 -4
- package/src/category/i18n/fr.ts +159 -159
- package/src/category/i18n/pl.ts +1 -1
- package/src/category/i18n/ru.ts +158 -158
- package/src/category/index.ts +39 -38
- package/src/category/seo.astro +1 -1
- package/src/components/PreviewNavSidebar.astro +1 -1
- package/src/components/PreviewToolbar.astro +1 -1
- package/src/data.ts +1 -1
- package/src/entries.ts +4 -1
- package/src/env.d.ts +1 -1
- package/src/index.ts +1 -0
- package/src/layouts/PreviewLayout.astro +113 -113
- package/src/pages/index.astro +1 -1
- package/src/tests/bibliography_wellformed_export.test.ts +46 -0
- package/src/tests/category_seo_quality.test.ts +76 -0
- package/src/tests/faq_count.test.ts +1 -1
- package/src/tests/locale_completeness.test.ts +2 -2
- package/src/tests/mocks/astro_mock.js +1 -1
- package/src/tests/no_h1_in_components.test.ts +1 -1
- package/src/tests/script_density.test.ts +94 -94
- package/src/tests/seo_length.test.ts +23 -23
- package/src/tests/seo_translation_completeness.test.ts +69 -0
- package/src/tests/seo_wellformed_export.test.ts +65 -0
- package/src/tests/tool_validation.test.ts +17 -17
- package/src/tool/compoundInterest/compound-interest-calculator.css +236 -236
- package/src/tool/compoundInterest/entry.ts +32 -32
- package/src/tool/compoundInterest/i18n/de.ts +195 -195
- package/src/tool/compoundInterest/i18n/fr.ts +195 -195
- package/src/tool/compoundInterest/i18n/it.ts +195 -195
- package/src/tool/compoundInterest/i18n/pl.ts +194 -194
- package/src/tool/compoundInterest/i18n/ru.ts +195 -195
- package/src/tool/compoundInterest/i18n/tr.ts +195 -195
- package/src/tool/compoundInterest/i18n/zh.ts +189 -189
- package/src/tool/compoundInterest/seo.astro +15 -15
- package/src/tool/courtFeeCalculator/i18n/it.ts +158 -158
- package/src/tool/courtFeeCalculator/i18n/ru.ts +158 -158
- package/src/tool/courtFeeCalculator/i18n/tr.ts +158 -158
- package/src/tool/courtFeeCalculator/seo.astro +15 -15
- package/src/tool/courtFeeCalculator/spanish-court-fees-calculator.css +197 -197
- package/src/tool/debtSnowball/bibliography.ts +12 -12
- package/src/tool/debtSnowball/i18n/de.ts +16 -16
- package/src/tool/debtSnowball/i18n/id.ts +16 -16
- package/src/tool/debtSnowball/i18n/it.ts +168 -168
- package/src/tool/debtSnowball/i18n/nl.ts +16 -16
- package/src/tool/debtSnowball/i18n/pl.ts +168 -168
- package/src/tool/debtSnowball/i18n/pt.ts +1 -1
- package/src/tool/debtSnowball/i18n/ru.ts +1 -1
- package/src/tool/debtSnowball/i18n/sv.ts +22 -29
- package/src/tool/debtSnowball/i18n/tr.ts +168 -168
- package/src/tool/debtSnowball/i18n/zh.ts +168 -168
- package/src/tool/debtSnowball/seo.astro +15 -15
- package/src/tool/dividendYield/bibliography.astro +14 -0
- package/src/tool/dividendYield/bibliography.ts +12 -0
- package/src/tool/dividendYield/component.astro +83 -0
- package/src/tool/dividendYield/controller.ts +85 -0
- package/src/tool/dividendYield/dividend-yield-calculator.css +352 -0
- package/src/tool/dividendYield/dom-views.ts +58 -0
- package/src/tool/dividendYield/entry.ts +29 -0
- package/src/tool/dividendYield/evaluator.ts +16 -0
- package/src/tool/dividendYield/i18n/de.ts +53 -0
- package/src/tool/dividendYield/i18n/en.ts +138 -0
- package/src/tool/dividendYield/i18n/es.ts +49 -0
- package/src/tool/dividendYield/i18n/fr.ts +49 -0
- package/src/tool/dividendYield/i18n/id.ts +49 -0
- package/src/tool/dividendYield/i18n/it.ts +49 -0
- package/src/tool/dividendYield/i18n/ja.ts +49 -0
- package/src/tool/dividendYield/i18n/ko.ts +25 -0
- package/src/tool/dividendYield/i18n/nl.ts +25 -0
- package/src/tool/dividendYield/i18n/pl.ts +25 -0
- package/src/tool/dividendYield/i18n/pt.ts +25 -0
- package/src/tool/dividendYield/i18n/ru.ts +25 -0
- package/src/tool/dividendYield/i18n/sv.ts +25 -0
- package/src/tool/dividendYield/i18n/tr.ts +25 -0
- package/src/tool/dividendYield/i18n/zh.ts +25 -0
- package/src/tool/dividendYield/index.ts +11 -0
- package/src/tool/dividendYield/logic.test.ts +73 -0
- package/src/tool/dividendYield/logic.ts +55 -0
- package/src/tool/dividendYield/seo.astro +14 -0
- package/src/tool/dividendYield/storage.ts +24 -0
- package/src/tool/dividendYield/ui.ts +33 -0
- package/src/tool/financialFreedom/financial-freedom-calculator.css +311 -311
- package/src/tool/financialFreedom/i18n/en.ts +182 -182
- package/src/tool/financialFreedom/i18n/fr.ts +128 -128
- package/src/tool/financialFreedom/i18n/id.ts +24 -7
- package/src/tool/financialFreedom/i18n/it.ts +24 -7
- package/src/tool/financialFreedom/i18n/ja.ts +1 -1
- package/src/tool/financialFreedom/i18n/nl.ts +24 -7
- package/src/tool/financialFreedom/i18n/pl.ts +24 -7
- package/src/tool/financialFreedom/i18n/pt.ts +24 -7
- package/src/tool/financialFreedom/i18n/ru.ts +128 -128
- package/src/tool/financialFreedom/i18n/sv.ts +1 -1
- package/src/tool/financialFreedom/i18n/tr.ts +2 -2
- package/src/tool/financialFreedom/i18n/zh.ts +128 -128
- package/src/tool/fireCalculator/i18n/it.ts +241 -241
- package/src/tool/fireCalculator/i18n/ru.ts +241 -241
- package/src/tool/fireCalculator/i18n/tr.ts +241 -241
- package/src/tool/fireCalculator/i18n/zh.ts +241 -241
- package/src/tool/fireCalculator/seo.astro +15 -15
- package/src/tool/ibanBicSwiftConverter/i18n/fr.ts +151 -151
- package/src/tool/ibanBicSwiftConverter/i18n/it.ts +118 -118
- package/src/tool/ibanBicSwiftConverter/i18n/ru.ts +118 -118
- package/src/tool/ibanBicSwiftConverter/i18n/tr.ts +118 -118
- package/src/tool/ibanBicSwiftConverter/iban-to-bic-swift-converter.css +366 -366
- package/src/tool/ibanBicSwiftConverter/seo.astro +15 -15
- package/src/tool/inflation/bibliography.ts +20 -20
- package/src/tool/inflation/entry.ts +32 -32
- package/src/tool/inflation/i18n/de.ts +284 -284
- package/src/tool/inflation/i18n/fr.ts +284 -284
- package/src/tool/inflation/i18n/it.ts +284 -284
- package/src/tool/inflation/i18n/nl.ts +284 -284
- package/src/tool/inflation/i18n/pl.ts +284 -284
- package/src/tool/inflation/i18n/pt.ts +284 -284
- package/src/tool/inflation/i18n/ru.ts +284 -284
- package/src/tool/inflation/i18n/sv.ts +284 -284
- package/src/tool/inflation/i18n/tr.ts +284 -284
- package/src/tool/inflation/i18n/zh.ts +284 -284
- package/src/tool/inflation/seo.astro +15 -15
- package/src/tool/lateInterest/bibliography.ts +16 -16
- package/src/tool/lateInterest/entry.ts +32 -32
- package/src/tool/lateInterest/i18n/de.ts +213 -213
- package/src/tool/lateInterest/i18n/es.ts +213 -213
- package/src/tool/lateInterest/i18n/it.ts +213 -213
- package/src/tool/lateInterest/i18n/nl.ts +213 -213
- package/src/tool/lateInterest/i18n/pl.ts +213 -213
- package/src/tool/lateInterest/i18n/pt.ts +213 -213
- package/src/tool/lateInterest/i18n/ru.ts +213 -213
- package/src/tool/lateInterest/i18n/sv.ts +213 -213
- package/src/tool/lateInterest/i18n/tr.ts +213 -213
- package/src/tool/lateInterest/i18n/zh.ts +213 -213
- package/src/tool/lateInterest/seo.astro +15 -15
- package/src/tool/legalInterestRate/i18n/it.ts +129 -129
- package/src/tool/legalInterestRate/i18n/ru.ts +129 -129
- package/src/tool/legalInterestRate/i18n/tr.ts +128 -121
- package/src/tool/legalInterestRate/i18n/zh.ts +11 -4
- package/src/tool/legalInterestRate/seo.astro +15 -15
- package/src/tool/lotteryOptimizer/i18n/it.ts +163 -163
- package/src/tool/lotteryOptimizer/i18n/pl.ts +163 -163
- package/src/tool/lotteryOptimizer/i18n/ru.ts +163 -163
- package/src/tool/lotteryOptimizer/i18n/tr.ts +163 -163
- package/src/tool/lotteryOptimizer/i18n/zh.ts +162 -155
- package/src/tool/lotteryOptimizer/seo.astro +15 -15
- package/src/tool/mortgage/bibliography.ts +20 -20
- package/src/tool/mortgage/entry.ts +32 -32
- package/src/tool/mortgage/i18n/de.ts +210 -210
- package/src/tool/mortgage/i18n/es.ts +210 -210
- package/src/tool/mortgage/i18n/fr.ts +210 -210
- package/src/tool/mortgage/i18n/id.ts +210 -210
- package/src/tool/mortgage/i18n/it.ts +210 -210
- package/src/tool/mortgage/i18n/nl.ts +210 -210
- package/src/tool/mortgage/i18n/pl.ts +210 -210
- package/src/tool/mortgage/i18n/ru.ts +210 -210
- package/src/tool/mortgage/i18n/tr.ts +210 -210
- package/src/tool/mortgage/i18n/zh.ts +210 -210
- package/src/tool/mortgage/mortgage-calculator.css +595 -595
- package/src/tool/mortgage/seo.astro +15 -15
- package/src/tool/percentageCalculator/bibliography.ts +16 -16
- package/src/tool/percentageCalculator/entry.ts +32 -32
- package/src/tool/percentageCalculator/i18n/de.ts +220 -220
- package/src/tool/percentageCalculator/i18n/en.ts +220 -220
- package/src/tool/percentageCalculator/i18n/es.ts +220 -220
- package/src/tool/percentageCalculator/i18n/fr.ts +220 -220
- package/src/tool/percentageCalculator/i18n/it.ts +220 -220
- package/src/tool/percentageCalculator/i18n/pl.ts +220 -220
- package/src/tool/percentageCalculator/i18n/ru.ts +220 -220
- package/src/tool/percentageCalculator/i18n/tr.ts +220 -220
- package/src/tool/percentageCalculator/i18n/zh.ts +220 -220
- package/src/tool/percentageCalculator/seo.astro +15 -15
- package/src/tool/profitability/i18n/de.ts +24 -7
- package/src/tool/profitability/i18n/fr.ts +121 -104
- package/src/tool/profitability/i18n/id.ts +2 -2
- package/src/tool/profitability/i18n/it.ts +24 -7
- package/src/tool/profitability/i18n/ja.ts +1 -1
- package/src/tool/profitability/i18n/nl.ts +24 -7
- package/src/tool/profitability/i18n/pl.ts +1 -1
- package/src/tool/profitability/i18n/pt.ts +24 -7
- package/src/tool/profitability/i18n/ru.ts +118 -118
- package/src/tool/profitability/i18n/sv.ts +1 -1
- package/src/tool/profitability/i18n/tr.ts +1 -1
- package/src/tool/profitability/i18n/zh.ts +118 -118
- package/src/tool/profitability/profitability-calculator.css +229 -229
- package/src/tool/rentIncreaseCalculator/i18n/it.ts +125 -125
- package/src/tool/rentIncreaseCalculator/i18n/tr.ts +125 -125
- package/src/tool/rentIncreaseCalculator/rent-increase-calculator.css +326 -326
- package/src/tool/rentIncreaseCalculator/seo.astro +15 -15
- package/src/tool/revolvingCardCalculator/i18n/de.ts +38 -20
- package/src/tool/revolvingCardCalculator/i18n/es.ts +19 -18
- package/src/tool/revolvingCardCalculator/i18n/fr.ts +32 -28
- package/src/tool/revolvingCardCalculator/i18n/id.ts +18 -18
- package/src/tool/revolvingCardCalculator/i18n/it.ts +18 -18
- package/src/tool/revolvingCardCalculator/i18n/ja.ts +2 -2
- package/src/tool/revolvingCardCalculator/i18n/ko.ts +2 -2
- package/src/tool/revolvingCardCalculator/i18n/nl.ts +22 -19
- package/src/tool/revolvingCardCalculator/i18n/pl.ts +2 -2
- package/src/tool/revolvingCardCalculator/i18n/pt.ts +2 -2
- package/src/tool/revolvingCardCalculator/i18n/ru.ts +2 -2
- package/src/tool/revolvingCardCalculator/i18n/sv.ts +2 -2
- package/src/tool/revolvingCardCalculator/i18n/tr.ts +2 -2
- package/src/tool/revolvingCardCalculator/i18n/zh.ts +6 -6
- package/src/tool/salaryEmployerCost/i18n/de.ts +10 -10
- package/src/tool/salaryEmployerCost/i18n/fr.ts +9 -9
- package/src/tool/salaryEmployerCost/i18n/id.ts +9 -9
- package/src/tool/salaryEmployerCost/i18n/it.ts +9 -9
- package/src/tool/salaryEmployerCost/i18n/ja.ts +1 -1
- package/src/tool/salaryEmployerCost/i18n/ko.ts +1 -1
- package/src/tool/salaryEmployerCost/i18n/nl.ts +2 -2
- package/src/tool/salaryEmployerCost/i18n/pl.ts +2 -2
- package/src/tool/salaryEmployerCost/i18n/pt.ts +2 -2
- package/src/tool/salaryEmployerCost/i18n/ru.ts +2 -2
- package/src/tool/salaryEmployerCost/i18n/sv.ts +2 -2
- package/src/tool/salaryEmployerCost/i18n/tr.ts +2 -2
- package/src/tool/salaryEmployerCost/i18n/zh.ts +2 -2
- package/src/tools.ts +2 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { ALL_TOOLS } from '../tools';
|
|
3
|
+
|
|
4
|
+
const ASIAN_LOCALES = ['ja', 'ko', 'zh'];
|
|
5
|
+
|
|
6
|
+
function getSimpleSectionLength(section: any): number {
|
|
7
|
+
if (section.type === 'title') return section.text ? section.text.length : 0;
|
|
8
|
+
if (section.type === 'paragraph') return section.html ? section.html.replace(/<[^>]*>/g, '').length : 0;
|
|
9
|
+
if (section.type === 'list') return section.items ? section.items.join('').length : 0;
|
|
10
|
+
return 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getComplexSectionLength(section: any): number {
|
|
14
|
+
if (section.type === 'diagnostic' || section.type === 'tip') {
|
|
15
|
+
return (section.title ? section.title.length : 0) + (section.html ? section.html.replace(/<[^>]*>/g, '').length : 0);
|
|
16
|
+
}
|
|
17
|
+
if (section.type === 'table') {
|
|
18
|
+
return ((section.headers || []).join('').length) + ((section.rows || []).flat().join('').length);
|
|
19
|
+
}
|
|
20
|
+
return 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getSectionLength(section: any): number {
|
|
24
|
+
return getSimpleSectionLength(section) || getComplexSectionLength(section);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function calculateSeoTextLength(seoSections: any[]): number {
|
|
28
|
+
return seoSections.reduce((acc, section) => acc + getSectionLength(section), 0);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function checkLocaleSeoLength(toolId: string, locale: string, localeLen: number, enLen: number): void {
|
|
32
|
+
const isAsian = ASIAN_LOCALES.includes(locale);
|
|
33
|
+
const minLength = Math.floor(enLen * (isAsian ? 0.25 : 0.70));
|
|
34
|
+
const msgType = isAsian ? 'suspiciously short' : 'truncated/lazy';
|
|
35
|
+
|
|
36
|
+
expect(
|
|
37
|
+
localeLen,
|
|
38
|
+
`[LAZY SEO TRANSLATION] Tool "${toolId}" locale "${locale}" SEO text is ${msgType} (${localeLen} chars vs EN ${enLen} chars, expected min ${minLength})`,
|
|
39
|
+
).toBeGreaterThanOrEqual(minLength);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function auditSingleLocale(toolId: string, locale: string, loader: any, enSeoLength: number): Promise<void> {
|
|
43
|
+
if (locale === 'en' || !loader) return;
|
|
44
|
+
const content = await loader();
|
|
45
|
+
if (!content.seo || !Array.isArray(content.seo)) return;
|
|
46
|
+
|
|
47
|
+
checkLocaleSeoLength(toolId, locale, calculateSeoTextLength(content.seo), enSeoLength);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
describe('SEO Translation Completeness & Laziness Audit', () => {
|
|
51
|
+
ALL_TOOLS.forEach(({ entry }) => {
|
|
52
|
+
describe(`Tool: ${entry.id}`, () => {
|
|
53
|
+
it('should not have lazy or truncated SEO content compared to English reference', async () => {
|
|
54
|
+
const enLoader = entry.i18n['en' as keyof typeof entry.i18n];
|
|
55
|
+
if (!enLoader) return;
|
|
56
|
+
|
|
57
|
+
const enContent = await enLoader();
|
|
58
|
+
if (!enContent.seo || !Array.isArray(enContent.seo)) return;
|
|
59
|
+
|
|
60
|
+
const enSeoLength = calculateSeoTextLength(enContent.seo);
|
|
61
|
+
|
|
62
|
+
for (const [locale, loader] of Object.entries(entry.i18n)) {
|
|
63
|
+
await auditSingleLocale(entry.id, locale, loader, enSeoLength);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { readdirSync, readFileSync, existsSync } from 'fs';
|
|
3
|
+
import { join, relative } from 'path';
|
|
4
|
+
|
|
5
|
+
function findSeoAstroFiles(dir: string): string[] {
|
|
6
|
+
const files: string[] = [];
|
|
7
|
+
if (!existsSync(dir)) return files;
|
|
8
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
9
|
+
|
|
10
|
+
for (const entry of entries) {
|
|
11
|
+
const fullPath = join(dir, entry.name);
|
|
12
|
+
if (entry.isDirectory()) {
|
|
13
|
+
files.push(...findSeoAstroFiles(fullPath));
|
|
14
|
+
} else if (entry.isFile() && entry.name === 'seo.astro') {
|
|
15
|
+
files.push(fullPath);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return files;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const toolDir = join(process.cwd(), 'src', 'tool');
|
|
23
|
+
const seoFiles = findSeoAstroFiles(toolDir);
|
|
24
|
+
|
|
25
|
+
describe('SEO Component Wellformed Export', () => {
|
|
26
|
+
it('found tool seo.astro components', () => {
|
|
27
|
+
expect(seoFiles.length).toBeGreaterThan(0);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
seoFiles.forEach((file) => {
|
|
31
|
+
const relativePath = relative(process.cwd(), file);
|
|
32
|
+
|
|
33
|
+
it(`${relativePath} should dynamically load SEO sections and use SEORenderer`, () => {
|
|
34
|
+
const content = readFileSync(file, 'utf-8');
|
|
35
|
+
|
|
36
|
+
const usesSeoRenderer =
|
|
37
|
+
content.includes('@jjlmoya/utils-shared') &&
|
|
38
|
+
(content.includes('SEORenderer') || content.includes('SEOArticle'));
|
|
39
|
+
|
|
40
|
+
const acquiresDynamicContent =
|
|
41
|
+
content.includes('.i18n') ||
|
|
42
|
+
content.includes('loader') ||
|
|
43
|
+
content.includes('await loader') ||
|
|
44
|
+
content.includes('.seo');
|
|
45
|
+
|
|
46
|
+
const isBrokenPattern =
|
|
47
|
+
/sections\s*=\s*\[\s*\]/.test(content) && !acquiresDynamicContent;
|
|
48
|
+
|
|
49
|
+
expect(
|
|
50
|
+
usesSeoRenderer,
|
|
51
|
+
`File "${relativePath}" does not import or use SEORenderer from @jjlmoya/utils-shared.`,
|
|
52
|
+
).toBe(true);
|
|
53
|
+
|
|
54
|
+
expect(
|
|
55
|
+
isBrokenPattern,
|
|
56
|
+
`File "${relativePath}" relies on a static sections=[] prop default without fetching content from entry.i18n, resulting in empty SEO text on consumers.`,
|
|
57
|
+
).toBe(false);
|
|
58
|
+
|
|
59
|
+
expect(
|
|
60
|
+
acquiresDynamicContent,
|
|
61
|
+
`File "${relativePath}" does not fetch dynamic i18n content for SEO rendering.`,
|
|
62
|
+
).toBe(true);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { ALL_TOOLS } from '../tools';
|
|
3
|
-
import { financeCategory } from '../data';
|
|
4
|
-
|
|
5
|
-
describe('Tool Validation Suite', () => {
|
|
6
|
-
describe('Library Registration', () => {
|
|
7
|
-
it('should have
|
|
8
|
-
expect(ALL_TOOLS.length).toBe(
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('financeCategory should be defined', () => {
|
|
12
|
-
expect(financeCategory).toBeDefined();
|
|
13
|
-
expect(financeCategory.i18n).toBeDefined();
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { ALL_TOOLS } from '../tools';
|
|
3
|
+
import { financeCategory } from '../data';
|
|
4
|
+
|
|
5
|
+
describe('Tool Validation Suite', () => {
|
|
6
|
+
describe('Library Registration', () => {
|
|
7
|
+
it('should have 18 tools in ALL_TOOLS', () => {
|
|
8
|
+
expect(ALL_TOOLS.length).toBe(18);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('financeCategory should be defined', () => {
|
|
12
|
+
expect(financeCategory).toBeDefined();
|
|
13
|
+
expect(financeCategory.i18n).toBeDefined();
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|