@zodic/shared 0.0.136 → 0.0.138

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.
@@ -42,6 +42,11 @@ export const makeAstrologyApiCall = async (
42
42
  language: 'en-us' | 'pt-br'
43
43
  ) => {
44
44
  const shortLanguage = language.slice(0, 2);
45
+
46
+ // ✅ Encode Authentication Header using `btoa()`
47
+ const authString = `${env.ASTROLOGY_WESTERN_USER_ID}:${env.ASTROLOGY_WESTERN_API_KEY}`;
48
+ const authHeader = `Basic ${btoa(authString)}`;
49
+
45
50
  try {
46
51
  const url = `https://json.astrologyapi.com/v1/${path}`;
47
52
  console.log(`🌍 Making Astrology API Call: ${url}`);
@@ -51,15 +56,13 @@ export const makeAstrologyApiCall = async (
51
56
  headers: {
52
57
  'Content-Type': 'application/json',
53
58
  'Accept-Language': shortLanguage,
54
- Authorization: `Bearer ${env.ASTROLOGY_WESTERN_API_KEY}`,
59
+ Authorization: authHeader, // ✅ Correct authentication header
55
60
  },
56
61
  body: JSON.stringify(payload),
57
62
  });
58
63
 
59
- // ✅ Log response status
60
64
  console.log(`🔄 Response Status (${path}):`, response.status);
61
65
 
62
- // ✅ Handle non-OK responses gracefully
63
66
  if (!response.ok) {
64
67
  console.error(
65
68
  `❌ API Error (${path}):`,
@@ -69,14 +72,12 @@ export const makeAstrologyApiCall = async (
69
72
  throw new Error(`Failed to fetch astrology data from ${path}`);
70
73
  }
71
74
 
72
- // ✅ Check if response body is empty
73
75
  const text = await response.text();
74
76
  if (!text) {
75
77
  console.error(`❌ API Response Empty (${path})`);
76
78
  throw new Error(`Empty response from ${path}`);
77
79
  }
78
80
 
79
- // ✅ Try parsing JSON
80
81
  try {
81
82
  return JSON.parse(text);
82
83
  } catch (jsonError) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zodic/shared",
3
- "version": "0.0.136",
3
+ "version": "0.0.138",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -1,3 +1,42 @@
1
1
  export function normalizeName(name: string): string {
2
- return name.toLowerCase().replace(/\s+/g, '-');
2
+ const englishName = TRANSLATION_MAP[name] || name;
3
+
4
+ return englishName.toLowerCase().replace(/\s+/g, '-');
3
5
  }
6
+
7
+ const TRANSLATION_MAP: Record<string, string> = {
8
+ // Planets
9
+ Sol: 'Sun',
10
+ Lua: 'Moon',
11
+ Mercúrio: 'Mercury',
12
+ Vênus: 'Venus',
13
+ Marte: 'Mars',
14
+ Júpiter: 'Jupiter',
15
+ Saturno: 'Saturn',
16
+ Urano: 'Uranus',
17
+ Netuno: 'Neptune',
18
+ Plutão: 'Pluto',
19
+ Ascendente: 'Ascendant',
20
+ MC: 'Midheaven',
21
+
22
+ // Signs
23
+ Áries: 'Aries',
24
+ Touro: 'Taurus',
25
+ Gémeos: 'Gemini',
26
+ Câncer: 'Cancer',
27
+ Leão: 'Leo',
28
+ Virgem: 'Virgo',
29
+ Libra: 'Libra',
30
+ Escorpião: 'Scorpio',
31
+ Sagitário: 'Sagittarius',
32
+ Capricórnio: 'Capricorn',
33
+ Aquário: 'Aquarius',
34
+ Peixes: 'Pisces',
35
+
36
+ // Aspect Types
37
+ Conjunção: 'Conjunction',
38
+ Oposição: 'Opposition',
39
+ Quadratura: 'Square',
40
+ Sextil: 'Sextile',
41
+ Trígono: 'Trine',
42
+ };