@jjlmoya/utils-travel 1.27.0 → 1.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/package.json +2 -2
  2. package/scripts/validate-icons.mjs +57 -0
  3. package/src/entries.ts +2 -1
  4. package/src/index.ts +1 -0
  5. package/src/tests/locale_completeness.test.ts +2 -2
  6. package/src/tests/mfe_assets_contract.test.ts +48 -0
  7. package/src/tests/tool_validation.test.ts +2 -2
  8. package/src/tool/airport-connection-buffer-calculator/airport-connection-buffer-calculator.css +683 -0
  9. package/src/tool/airport-connection-buffer-calculator/airport-data.test.ts +15 -0
  10. package/src/tool/airport-connection-buffer-calculator/airport-data.ts +76 -0
  11. package/src/tool/airport-connection-buffer-calculator/bcbp.test.ts +17 -0
  12. package/src/tool/airport-connection-buffer-calculator/bcbp.ts +33 -0
  13. package/src/tool/airport-connection-buffer-calculator/bibliography.astro +6 -0
  14. package/src/tool/airport-connection-buffer-calculator/bibliography.ts +29 -0
  15. package/src/tool/airport-connection-buffer-calculator/component.astro +97 -0
  16. package/src/tool/airport-connection-buffer-calculator/controller.ts +253 -0
  17. package/src/tool/airport-connection-buffer-calculator/dom-views.ts +71 -0
  18. package/src/tool/airport-connection-buffer-calculator/entry.ts +30 -0
  19. package/src/tool/airport-connection-buffer-calculator/evaluator.ts +12 -0
  20. package/src/tool/airport-connection-buffer-calculator/i18n/de.ts +66 -0
  21. package/src/tool/airport-connection-buffer-calculator/i18n/en.ts +161 -0
  22. package/src/tool/airport-connection-buffer-calculator/i18n/es.ts +51 -0
  23. package/src/tool/airport-connection-buffer-calculator/i18n/fr.ts +40 -0
  24. package/src/tool/airport-connection-buffer-calculator/i18n/id.ts +23 -0
  25. package/src/tool/airport-connection-buffer-calculator/i18n/it.ts +23 -0
  26. package/src/tool/airport-connection-buffer-calculator/i18n/ja.ts +16 -0
  27. package/src/tool/airport-connection-buffer-calculator/i18n/ko.ts +16 -0
  28. package/src/tool/airport-connection-buffer-calculator/i18n/nl.ts +16 -0
  29. package/src/tool/airport-connection-buffer-calculator/i18n/pl.ts +16 -0
  30. package/src/tool/airport-connection-buffer-calculator/i18n/pt.ts +16 -0
  31. package/src/tool/airport-connection-buffer-calculator/i18n/ru.ts +16 -0
  32. package/src/tool/airport-connection-buffer-calculator/i18n/shared.ts +144 -0
  33. package/src/tool/airport-connection-buffer-calculator/i18n/sv.ts +16 -0
  34. package/src/tool/airport-connection-buffer-calculator/i18n/tr.ts +16 -0
  35. package/src/tool/airport-connection-buffer-calculator/i18n/zh.ts +16 -0
  36. package/src/tool/airport-connection-buffer-calculator/index.ts +11 -0
  37. package/src/tool/airport-connection-buffer-calculator/logic.test.ts +94 -0
  38. package/src/tool/airport-connection-buffer-calculator/logic.ts +107 -0
  39. package/src/tool/airport-connection-buffer-calculator/scanner.ts +54 -0
  40. package/src/tool/airport-connection-buffer-calculator/seo.astro +14 -0
  41. package/src/tool/airport-connection-buffer-calculator/storage.ts +88 -0
  42. package/src/tool/airport-connection-buffer-calculator/ui.ts +88 -0
  43. package/src/tool/mini-adventures/component.astro +1 -2
  44. package/src/tool/mini-adventures/i18n/de.ts +1 -1
  45. package/src/tool/mini-adventures/i18n/en.ts +1 -1
  46. package/src/tool/mini-adventures/i18n/es.ts +1 -1
  47. package/src/tool/mini-adventures/i18n/fr.ts +1 -1
  48. package/src/tool/mini-adventures/i18n/id.ts +1 -1
  49. package/src/tool/mini-adventures/i18n/it.ts +1 -1
  50. package/src/tool/mini-adventures/i18n/ja.ts +1 -1
  51. package/src/tool/mini-adventures/i18n/ko.ts +1 -1
  52. package/src/tool/mini-adventures/i18n/nl.ts +1 -1
  53. package/src/tool/mini-adventures/i18n/pl.ts +1 -1
  54. package/src/tool/mini-adventures/i18n/pt.ts +1 -1
  55. package/src/tool/mini-adventures/i18n/ru.ts +1 -1
  56. package/src/tool/mini-adventures/i18n/sv.ts +1 -1
  57. package/src/tool/mini-adventures/i18n/tr.ts +1 -1
  58. package/src/tool/mini-adventures/i18n/zh.ts +1 -1
  59. package/src/tools.ts +4 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jjlmoya/utils-travel",
3
- "version": "1.27.0",
3
+ "version": "1.29.0",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -36,7 +36,7 @@
36
36
  "postinstall": "node scripts/postinstall.mjs",
37
37
  "predev": "node scripts/postinstall.mjs",
38
38
  "prestart": "node scripts/postinstall.mjs",
39
- "prebuild": "node scripts/postinstall.mjs",
39
+ "prebuild": "node scripts/postinstall.mjs && node scripts/validate-icons.mjs",
40
40
  "qa": "npm run lint && npm run test && npm run build",
41
41
  "cf:dry-run": "npm run build && wrangler deploy --dry-run",
42
42
  "cf:preview": "npm run build && wrangler deploy --config wrangler.staging.jsonc",
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { createRequire } from 'node:module';
4
+ import { readFileSync, readdirSync } from 'node:fs';
5
+ import { dirname, join, relative, resolve } from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+
8
+ const require = createRequire(import.meta.url);
9
+ const packageJsonPath = require.resolve('@iconify-json/mdi/package.json');
10
+ const packageRoot = dirname(packageJsonPath);
11
+ const iconSet = JSON.parse(readFileSync(join(packageRoot, 'icons.json'), 'utf8'));
12
+ const availableIcons = new Set([
13
+ ...Object.keys(iconSet.icons ?? {}),
14
+ ...Object.keys(iconSet.aliases ?? {}),
15
+ ]);
16
+
17
+ const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
18
+ const sourceRoot = resolve(repoRoot, 'src');
19
+ const extensions = new Set(['.astro', '.js', '.mjs', '.ts', '.tsx']);
20
+ const iconPattern = /\bmdi:([a-z0-9-]+)\b/g;
21
+ const failures = [];
22
+ let references = 0;
23
+
24
+ function walk(directory) {
25
+ const entries = readdirSync(directory, { withFileTypes: true });
26
+ for (const entry of entries) {
27
+ const path = join(directory, entry.name);
28
+ if (entry.isDirectory()) {
29
+ if (entry.name !== 'node_modules' && entry.name !== 'dist' && entry.name !== 'tests') {
30
+ walk(path);
31
+ }
32
+ continue;
33
+ }
34
+ if (!extensions.has(path.slice(path.lastIndexOf('.')))) continue;
35
+
36
+ const source = readFileSync(path, 'utf8');
37
+ for (const match of source.matchAll(iconPattern)) {
38
+ references += 1;
39
+ const iconName = match[1];
40
+ if (availableIcons.has(iconName)) continue;
41
+
42
+ const line = source.slice(0, match.index).split('\n').length;
43
+ failures.push(`${relative(repoRoot, path)}:${line} — mdi:${iconName}`);
44
+ }
45
+ }
46
+ }
47
+
48
+ walk(sourceRoot);
49
+
50
+ if (failures.length > 0) {
51
+ console.error('Invalid MDI icons found:');
52
+ for (const failure of failures) console.error(`- ${failure}`);
53
+ console.error(`Checked ${references} MDI icon references against @iconify-json/mdi.`);
54
+ process.exitCode = 1;
55
+ } else {
56
+ console.log(`MDI icon validation passed: ${references} references checked.`);
57
+ }
package/src/entries.ts CHANGED
@@ -6,5 +6,6 @@ import { schengenCalculator } from './tool/schengen-calculator/entry';
6
6
  import { fuelCostCalculator } from './tool/fuel-cost-calculator/entry';
7
7
  import { tripExpenseSplitter } from './tool/trip-expense-splitter/entry';
8
8
  import { jetLagRecoveryPlanner } from './tool/jet-lag-recovery-planner/entry';
9
+ import { airportConnectionBuffer } from './tool/airport-connection-buffer-calculator/entry';
9
10
 
10
- export const ALL_ENTRIES = [luggageCalculator, miniAdventures, suitcaseChecklist, tipCalculator, schengenCalculator, fuelCostCalculator, tripExpenseSplitter, jetLagRecoveryPlanner];
11
+ export const ALL_ENTRIES = [luggageCalculator, miniAdventures, suitcaseChecklist, tipCalculator, schengenCalculator, fuelCostCalculator, tripExpenseSplitter, jetLagRecoveryPlanner, airportConnectionBuffer];
package/src/index.ts CHANGED
@@ -22,3 +22,4 @@ export { suitcaseChecklist, SUITCASE_CHECKLIST_TOOL } from './tool/suitcase-chec
22
22
  export { miniAdventures, MINI_ADVENTURES_TOOL } from './tool/mini-adventures';
23
23
  export { schengenCalculator, SCHENGEN_CALCULATOR_TOOL } from './tool/schengen-calculator';
24
24
  export { fuelCostCalculator, FUEL_COST_CALCULATOR_TOOL } from './tool/fuel-cost-calculator';
25
+ export { airportConnectionBuffer, AIRPORT_CONNECTION_BUFFER_TOOL } from './tool/airport-connection-buffer-calculator';
@@ -22,7 +22,7 @@ describe('Locale Completeness Validation', () => {
22
22
  });
23
23
  });
24
24
 
25
- it('all 8 tools registered', () => {
26
- expect(ALL_TOOLS.length).toBe(8);
25
+ it('all 9 tools registered', () => {
26
+ expect(ALL_TOOLS.length).toBe(9);
27
27
  });
28
28
  });
@@ -0,0 +1,48 @@
1
+ import { existsSync, readdirSync, statSync } from 'node:fs';
2
+ import { basename, join } from 'node:path';
3
+ import { describe, expect, it } from 'vitest';
4
+ import { ALL_TOOLS } from '../tools';
5
+ import { CATEGORY_OG_IMAGE, getUtilityOgImage } from '../mfe/assets';
6
+
7
+ const categoryImageMatch = CATEGORY_OG_IMAGE.match(
8
+ /^(\/_utilities\/[^/]+\/images)\/([^/]+\.webp)\?version=(.+)$/,
9
+ );
10
+
11
+ if (!categoryImageMatch) {
12
+ throw new Error(`Unexpected CATEGORY_OG_IMAGE format: ${CATEGORY_OG_IMAGE}`);
13
+ }
14
+
15
+ const [, imageUrlRoot, categoryImage, assetVersion] = categoryImageMatch;
16
+ const assetRoot = join(process.cwd(), 'public', imageUrlRoot.slice(1));
17
+ const categorySlug = basename(categoryImage, '.webp');
18
+
19
+ describe('MFE asset contract', () => {
20
+ it('has one non-empty English-slug OG image per category and registered tool', async () => {
21
+ const expectedSlugs = new Set([categorySlug]);
22
+
23
+ for (const { entry } of ALL_TOOLS) {
24
+ const englishLoader = entry.i18n.en;
25
+ if (!englishLoader) throw new Error(`Missing English locale for ${entry.id}`);
26
+
27
+ const englishContent = await englishLoader();
28
+ expectedSlugs.add(englishContent.slug);
29
+ }
30
+
31
+ const actualSlugs = new Set(
32
+ readdirSync(assetRoot)
33
+ .filter((filename) => filename.endsWith('.webp'))
34
+ .map((filename) => filename.slice(0, -'.webp'.length)),
35
+ );
36
+
37
+ expect(actualSlugs).toEqual(expectedSlugs);
38
+
39
+ for (const slug of expectedSlugs) {
40
+ const imagePath = join(assetRoot, `${slug}.webp`);
41
+ expect(existsSync(imagePath), `${imagePath} should exist`).toBe(true);
42
+ expect(statSync(imagePath).size, `${imagePath} should not be empty`).toBeGreaterThan(0);
43
+ expect(getUtilityOgImage(slug)).toBe(
44
+ `${imageUrlRoot}/${slug}.webp?version=${assetVersion}`,
45
+ );
46
+ }
47
+ }, 30000);
48
+ });
@@ -4,8 +4,8 @@ import { travelCategory } from '../category';
4
4
 
5
5
  describe('Tool Validation Suite', () => {
6
6
  describe('Library Registration', () => {
7
- it('should have 8 tools in ALL_TOOLS', () => {
8
- expect(ALL_TOOLS.length).toBe(8);
7
+ it('should have 9 tools in ALL_TOOLS', () => {
8
+ expect(ALL_TOOLS.length).toBe(9);
9
9
  });
10
10
 
11
11
  it('travelCategory should be defined', () => {