@zodic/shared 0.0.117 → 0.0.119

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.
@@ -1,37 +1,36 @@
1
- import { BackendBindings } from '@zodic/shared';
1
+ import { BackendBindings } from '../../../types';
2
2
 
3
3
  export async function makeAstrologyApiCall(
4
4
  path: string,
5
- payload: any | null,
6
- env: BackendBindings
7
- ): Promise<any> {
8
- const auth = `Basic ${btoa(
9
- `${env.ASTROLOGY_WESTERN_USER_ID}:${env.ASTROLOGY_WESTERN_API_KEY}`
10
- )}`;
5
+ payload: any,
6
+ env: BackendBindings,
7
+ language: string
8
+ ) {
9
+ const shortLanguage = language.slice(0, 2); // Extracts only "en" or "pt"
11
10
 
12
- const url = `https://json.astrologyapi.com/v1/${path}`
11
+ const endpoint = `https://astrologyapi.com/api/${path}`;
12
+ const headers = {
13
+ Authorization: `Bearer ${env.ASTROLOGY_WESTERN_API_KEY}`,
14
+ 'Content-Type': 'application/json',
15
+ 'Accept-Language': shortLanguage, // Sends "en" or "pt"
16
+ };
13
17
 
14
18
  try {
15
- const response = await fetch(url, {
16
- method: payload ? 'POST' : 'GET',
17
- headers: {
18
- 'Content-Type': 'application/json',
19
- Authorization: auth,
20
- 'Accept-Language': 'en',
21
- },
22
- body: payload ? JSON.stringify(payload) : undefined,
19
+ const response = await fetch(endpoint, {
20
+ method: 'POST',
21
+ headers,
22
+ body: JSON.stringify(payload),
23
23
  });
24
24
 
25
25
  if (!response.ok) {
26
- const errorText = await response.text();
27
- throw new Error(
28
- `Astrology API call failed: ${response.statusText} - ${errorText}`
29
- );
26
+ const error = await response.json();
27
+ console.error('Astrology API Error:', error);
28
+ throw new Error(`Astrology API Error: ${response.status}`);
30
29
  }
31
30
 
32
31
  return await response.json();
33
- } catch (error) {
34
- console.error(`Error calling Astrology API: ${url}`, error);
35
- throw new Error('Failed to fetch astrology data');
32
+ } catch (err: any) {
33
+ console.error('Error calling Astrology API:', err.message);
34
+ throw err;
36
35
  }
37
36
  }
package/app/api/index.ts CHANGED
@@ -390,6 +390,7 @@ export const Api = (env: BackendBindings) => ({
390
390
  lat,
391
391
  lon,
392
392
  tzone,
393
+ language = 'en-us', // Default to English
393
394
  }: {
394
395
  day: number;
395
396
  month: number;
@@ -399,11 +400,17 @@ export const Api = (env: BackendBindings) => ({
399
400
  lat: number;
400
401
  lon: number;
401
402
  tzone: number;
403
+ language?: 'en-us' | 'pt-br';
402
404
  }): Promise<NatalChartInterpretation> => {
403
405
  const path = `natal_chart_interpretation`;
404
406
  const payload = { day, month, year, hour, min, lat, lon, tzone };
405
407
 
406
- return makeAstrologyApiCall(path, payload, env);
408
+ return (await makeAstrologyApiCall(
409
+ path,
410
+ payload,
411
+ env,
412
+ language
413
+ )) as NatalChartInterpretation;
407
414
  },
408
415
 
409
416
  getHouseCuspsReport: async ({
@@ -415,6 +422,7 @@ export const Api = (env: BackendBindings) => ({
415
422
  lat,
416
423
  lon,
417
424
  tzone,
425
+ language = 'en-us',
418
426
  }: {
419
427
  day: number;
420
428
  month: number;
@@ -424,11 +432,17 @@ export const Api = (env: BackendBindings) => ({
424
432
  lat: number;
425
433
  lon: number;
426
434
  tzone: number;
435
+ language?: 'en-us' | 'pt-br';
427
436
  }): Promise<HouseCuspsReport[]> => {
428
437
  const path = `house_cusps_report/tropical`;
429
438
  const payload = { day, month, year, hour, min, lat, lon, tzone };
430
439
 
431
- return makeAstrologyApiCall(path, payload, env);
440
+ return (await makeAstrologyApiCall(
441
+ path,
442
+ payload,
443
+ env,
444
+ language
445
+ )) as HouseCuspsReport[];
432
446
  },
433
447
 
434
448
  getNatalHouseCuspReports: async ({
@@ -440,6 +454,7 @@ export const Api = (env: BackendBindings) => ({
440
454
  lat,
441
455
  lon,
442
456
  tzone,
457
+ language = 'en-us',
443
458
  }: {
444
459
  day: number;
445
460
  month: number;
@@ -449,11 +464,17 @@ export const Api = (env: BackendBindings) => ({
449
464
  lat: number;
450
465
  lon: number;
451
466
  tzone: number;
467
+ language?: 'en-us' | 'pt-br';
452
468
  }): Promise<NatalHouseCuspReport[]> => {
453
469
  const path = `natal_house_cusp_report`;
454
470
  const payload = { day, month, year, hour, min, lat, lon, tzone };
455
471
 
456
- return makeAstrologyApiCall(path, payload, env);
472
+ return (await makeAstrologyApiCall(
473
+ path,
474
+ payload,
475
+ env,
476
+ language
477
+ )) as NatalHouseCuspReport[];
457
478
  },
458
479
 
459
480
  getPlanetSignReport: async ({
@@ -466,6 +487,7 @@ export const Api = (env: BackendBindings) => ({
466
487
  lat,
467
488
  lon,
468
489
  tzone,
490
+ language = 'en-us',
469
491
  }: {
470
492
  planetName: string;
471
493
  day: number;
@@ -476,11 +498,16 @@ export const Api = (env: BackendBindings) => ({
476
498
  lat: number;
477
499
  lon: number;
478
500
  tzone: number;
501
+ language?: 'en-us' | 'pt-br';
479
502
  }): Promise<{ planet_name: string; sign: string; report: string }> => {
480
503
  const path = `general_sign_report/tropical/${planetName}`;
481
504
  const payload = { day, month, year, hour, min, lat, lon, tzone };
482
505
 
483
- return makeAstrologyApiCall(path, payload, env);
506
+ return (await makeAstrologyApiCall(path, payload, env, language)) as {
507
+ planet_name: string;
508
+ sign: string;
509
+ report: string;
510
+ };
484
511
  },
485
512
 
486
513
  getAscendantReport: async ({
@@ -492,6 +519,7 @@ export const Api = (env: BackendBindings) => ({
492
519
  lat,
493
520
  lon,
494
521
  tzone,
522
+ language = 'en-us',
495
523
  }: {
496
524
  day: number;
497
525
  month: number;
@@ -501,11 +529,15 @@ export const Api = (env: BackendBindings) => ({
501
529
  lat: number;
502
530
  lon: number;
503
531
  tzone: number;
532
+ language?: 'en-us' | 'pt-br';
504
533
  }): Promise<{ ascendant: string; report: string }> => {
505
534
  const path = `general_ascendant_report/tropical`;
506
535
  const payload = { day, month, year, hour, min, lat, lon, tzone };
507
536
 
508
- return makeAstrologyApiCall(path, payload, env);
537
+ return (await makeAstrologyApiCall(path, payload, env, language)) as {
538
+ ascendant: string;
539
+ report: string;
540
+ };
509
541
  },
510
542
  },
511
543
 
package/db/schema.ts CHANGED
@@ -98,8 +98,6 @@ export const astroPlanets = sqliteTable(
98
98
  normDegree: real('norm_degree'), // Degree within the sign (0-29°)
99
99
  speed: real('speed'), // Speed of the planet
100
100
  isRetro: integer('is_retro'), // 0 (false) or 1 (true) for retrograde
101
- signReport: text('sign_report'), // NEW: Report for the planet's sign
102
- houseReport: text('house_report'), // NEW: Report for the planet's house
103
101
  },
104
102
  (t) => [index('astro_planets_user_id_idx').on(t.userId)]
105
103
  );
@@ -114,7 +112,6 @@ export const astroHouses = sqliteTable(
114
112
  house: integer('house').notNull(), // House number (1-12)
115
113
  sign: text('sign').notNull(), // Sign ruling the house (e.g., "Sagittarius")
116
114
  degree: real('degree').notNull(), // Starting degree of the house
117
- signReport: text('sign_report'), // NEW: Report for the house's sign
118
115
  },
119
116
  (t) => [index('astro_houses_user_id_idx').on(t.userId)]
120
117
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zodic/shared",
3
- "version": "0.0.117",
3
+ "version": "0.0.119",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -313,5 +313,5 @@ export type ControlNetConfig =
313
313
  initImageId: string;
314
314
  initImageType: 'UPLOADED' | 'GENERATED';
315
315
  preprocessorId: 19; // Edge to Image
316
- weight: string;
316
+ weight: number;
317
317
  };
@@ -29,7 +29,7 @@ export const leonardoInitImages: LeonardoInitImages = {
29
29
  imageUrl:
30
30
  'https://cdn.leonardo.ai/users/b117a933-e5c9-45b2-96aa-4b619c2d74ba/initImages/c489e496-00c4-4958-8bcd-4460a43a43bf.jpg',
31
31
  preprocessorId: 19,
32
- weight: '0.3',
32
+ weight: 0.3,
33
33
  },
34
34
  ring: {
35
35
  imageId: null,
@@ -52,7 +52,7 @@ type ControlNetSettings =
52
52
  imageId: string;
53
53
  imageUrl: string;
54
54
  preprocessorId: 19;
55
- weight: string;
55
+ weight: number;
56
56
  strengthType?: null;
57
57
  }
58
58
  | {