@zodic/shared 0.0.239 → 0.0.241
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/app/services/ConceptService.ts +259 -3
- package/db/migrations/0001_mysterious_mystique.sql +47 -0
- package/db/migrations/meta/0001_snapshot.json +2200 -0
- package/db/migrations/meta/_journal.json +7 -0
- package/db/schema.ts +45 -41
- package/package.json +1 -1
- package/types/scopes/generic.ts +40 -0
- package/types/scopes/legacy.ts +60 -54
- package/utils/astroPrompts/index.ts +64 -6
- package/utils/buildMessages.ts +59 -1
- package/utils/index.ts +8 -0
package/db/schema.ts
CHANGED
|
@@ -182,64 +182,68 @@ export const astroAspects = sqliteTable(
|
|
|
182
182
|
);
|
|
183
183
|
|
|
184
184
|
export const astroReports = sqliteTable(
|
|
185
|
-
|
|
185
|
+
'astro_reports',
|
|
186
186
|
{
|
|
187
|
-
id: text(
|
|
188
|
-
type: text(
|
|
189
|
-
name: text(
|
|
190
|
-
sign: text(
|
|
191
|
-
house: integer(
|
|
192
|
-
enDescription: text(
|
|
193
|
-
ptDescription: text(
|
|
194
|
-
enReport: text(
|
|
195
|
-
ptReport: text(
|
|
196
|
-
createdAt: integer(
|
|
197
|
-
updatedAt: integer(
|
|
187
|
+
id: text('id').primaryKey(), // Unique identifier
|
|
188
|
+
type: text('type').notNull(), // 'planet', 'key_point', 'karmic_point', 'arabic_part'
|
|
189
|
+
name: text('name').notNull(), // Slug (e.g., 'sun', 'pars_fortuna')
|
|
190
|
+
sign: text('sign'), // Slug (e.g., 'aries', 'taurus') - nullable for house-only reports
|
|
191
|
+
house: integer('house'), // Nullable, only for applicable placements
|
|
192
|
+
enDescription: text('en_description'), // General explanation of the placement
|
|
193
|
+
ptDescription: text('pt_description'),
|
|
194
|
+
enReport: text('en_report'), // Full report content in English
|
|
195
|
+
ptReport: text('pt_report'), // Full report content in Portuguese
|
|
196
|
+
createdAt: integer('created_at').default(sql`CURRENT_TIMESTAMP`),
|
|
197
|
+
updatedAt: integer('updated_at').default(sql`CURRENT_TIMESTAMP`),
|
|
198
198
|
},
|
|
199
199
|
(t) => [
|
|
200
|
-
index(
|
|
201
|
-
index(
|
|
202
|
-
index(
|
|
200
|
+
index('astro_reports_type_idx').on(t.type),
|
|
201
|
+
index('astro_reports_name_sign_idx').on(t.name, t.sign), // Most critical index (name + sign)
|
|
202
|
+
index('astro_reports_name_house_idx').on(t.name, t.house), // Most critical index (name + house)
|
|
203
203
|
]
|
|
204
204
|
);
|
|
205
205
|
|
|
206
206
|
export const houseReports = sqliteTable(
|
|
207
|
-
|
|
207
|
+
'house_reports',
|
|
208
208
|
{
|
|
209
|
-
id: text(
|
|
210
|
-
sign: text(
|
|
211
|
-
house: integer(
|
|
212
|
-
enDescription: text(
|
|
213
|
-
ptDescription: text(
|
|
214
|
-
enReport: text(
|
|
215
|
-
ptReport: text(
|
|
216
|
-
createdAt: integer(
|
|
217
|
-
updatedAt: integer(
|
|
209
|
+
id: text('id').primaryKey(), // Unique identifier
|
|
210
|
+
sign: text('sign').notNull(), // Lowercase slug (e.g., 'aries', 'taurus')
|
|
211
|
+
house: integer('house').notNull(), // House placement (1-12)
|
|
212
|
+
enDescription: text('en_description'), // General explanation of the sign in a house
|
|
213
|
+
ptDescription: text('pt_description'),
|
|
214
|
+
enReport: text('en_report'), // Full report content in English
|
|
215
|
+
ptReport: text('pt_report'), // Full report content in Portuguese
|
|
216
|
+
createdAt: integer('created_at').default(sql`CURRENT_TIMESTAMP`),
|
|
217
|
+
updatedAt: integer('updated_at').default(sql`CURRENT_TIMESTAMP`),
|
|
218
218
|
},
|
|
219
219
|
(t) => [
|
|
220
|
-
index(
|
|
220
|
+
index('house_reports_sign_house_idx').on(t.sign, t.house), // Optimized index for sign + house lookups
|
|
221
221
|
]
|
|
222
222
|
);
|
|
223
223
|
|
|
224
224
|
export const aspectReports = sqliteTable(
|
|
225
|
-
|
|
225
|
+
'aspect_reports',
|
|
226
226
|
{
|
|
227
|
-
id: text(
|
|
228
|
-
aspectingPlanet: text(
|
|
229
|
-
aspectedPlanet: text(
|
|
230
|
-
aspect: text(
|
|
231
|
-
enDescription: text(
|
|
232
|
-
ptDescription: text(
|
|
233
|
-
enReport: text(
|
|
234
|
-
ptReport: text(
|
|
235
|
-
createdAt: integer(
|
|
236
|
-
updatedAt: integer(
|
|
227
|
+
id: text('id').primaryKey(), // Unique identifier
|
|
228
|
+
aspectingPlanet: text('aspecting_planet').notNull(), // Planet/point initiating the aspect (e.g., 'sun', 'mars')
|
|
229
|
+
aspectedPlanet: text('aspected_planet').notNull(), // Planet/point receiving the aspect (e.g., 'moon', 'venus')
|
|
230
|
+
aspect: text('aspect').notNull(), // Aspect type ('conjunction', 'trine', 'square', etc.)
|
|
231
|
+
enDescription: text('en_description'), // General explanation of the aspect
|
|
232
|
+
ptDescription: text('pt_description'),
|
|
233
|
+
enReport: text('en_report'), // Full report content in English
|
|
234
|
+
ptReport: text('pt_report'), // Full report content in Portuguese
|
|
235
|
+
createdAt: integer('created_at').default(sql`CURRENT_TIMESTAMP`),
|
|
236
|
+
updatedAt: integer('updated_at').default(sql`CURRENT_TIMESTAMP`),
|
|
237
237
|
},
|
|
238
238
|
(t) => [
|
|
239
|
-
index(
|
|
240
|
-
index(
|
|
241
|
-
index(
|
|
242
|
-
index(
|
|
239
|
+
index('aspect_reports_aspecting_idx').on(t.aspectingPlanet),
|
|
240
|
+
index('aspect_reports_aspected_idx').on(t.aspectedPlanet),
|
|
241
|
+
index('aspect_reports_aspect_idx').on(t.aspect),
|
|
242
|
+
index('aspect_reports_combined_idx').on(
|
|
243
|
+
t.aspectingPlanet,
|
|
244
|
+
t.aspectedPlanet,
|
|
245
|
+
t.aspect
|
|
246
|
+
), // Optimized for aspect lookups
|
|
243
247
|
]
|
|
244
248
|
);
|
|
245
249
|
|
package/package.json
CHANGED
package/types/scopes/generic.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { AspectType, PointSlug, ZodiacSign } from "./legacy";
|
|
2
|
+
|
|
1
3
|
export type Provider = 'google' | 'facebook';
|
|
2
4
|
|
|
3
5
|
export type ProviderInfo = {
|
|
@@ -31,6 +33,44 @@ export type AstroEntity = {
|
|
|
31
33
|
house: number;
|
|
32
34
|
};
|
|
33
35
|
|
|
36
|
+
export interface ContentItem {
|
|
37
|
+
type: "title" | "subtitle" | "p" | "bullet-point";
|
|
38
|
+
title?: string;
|
|
39
|
+
content: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface AstrologicalReport {
|
|
43
|
+
language: string;
|
|
44
|
+
title: ContentItem[];
|
|
45
|
+
sections: Record<string, ContentItem[]>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
export type AstroReportParams =
|
|
50
|
+
| {
|
|
51
|
+
reportType: "sign";
|
|
52
|
+
type: "planet" | "key_point" | "karmic_point" | "arabic_part";
|
|
53
|
+
pointName: PointSlug;
|
|
54
|
+
sign: ZodiacSign;
|
|
55
|
+
}
|
|
56
|
+
| {
|
|
57
|
+
reportType: "house";
|
|
58
|
+
type: "planet" | "karmic_point"; // Only planets and karmic points for house reports
|
|
59
|
+
pointName: PointSlug;
|
|
60
|
+
house: number;
|
|
61
|
+
}
|
|
62
|
+
| {
|
|
63
|
+
reportType: "signInHouse";
|
|
64
|
+
sign: ZodiacSign;
|
|
65
|
+
houseNumber: number;
|
|
66
|
+
}
|
|
67
|
+
| {
|
|
68
|
+
reportType: "aspect";
|
|
69
|
+
aspectingPlanet: PointSlug;
|
|
70
|
+
aspectedPlanet: PointSlug;
|
|
71
|
+
aspectingType: AspectType;
|
|
72
|
+
};
|
|
73
|
+
|
|
34
74
|
export type NatalChartInterpretation = {
|
|
35
75
|
planets: Planet[];
|
|
36
76
|
houses: House[];
|
package/types/scopes/legacy.ts
CHANGED
|
@@ -3,18 +3,18 @@ import { BackendBindings } from './cloudflare';
|
|
|
3
3
|
import { ControlNetConfig, Gender } from './generic';
|
|
4
4
|
|
|
5
5
|
export const zodiacSigns = [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
'aries',
|
|
7
|
+
'taurus',
|
|
8
|
+
'gemini',
|
|
9
|
+
'cancer',
|
|
10
|
+
'leo',
|
|
11
|
+
'virgo',
|
|
12
|
+
'libra',
|
|
13
|
+
'scorpio',
|
|
14
|
+
'sagittarius',
|
|
15
|
+
'capricorn',
|
|
16
|
+
'aquarius',
|
|
17
|
+
'pisces',
|
|
18
18
|
] as const;
|
|
19
19
|
export type ZodiacSignSlug = (typeof zodiacSigns)[number];
|
|
20
20
|
|
|
@@ -22,55 +22,61 @@ export type ZodiacSignSlug = (typeof zodiacSigns)[number];
|
|
|
22
22
|
export const houses = Array.from({ length: 12 }, (_, i) => i + 1);
|
|
23
23
|
|
|
24
24
|
// Aspects
|
|
25
|
-
export const aspects = [
|
|
25
|
+
export const aspects = [
|
|
26
|
+
'conjunction',
|
|
27
|
+
'opposition',
|
|
28
|
+
'trine',
|
|
29
|
+
'square',
|
|
30
|
+
'sextile',
|
|
31
|
+
] as const;
|
|
26
32
|
export type AspectType = (typeof aspects)[number];
|
|
27
33
|
|
|
28
34
|
export const pointTypes: Record<PointSlug, string> = {
|
|
29
|
-
sun:
|
|
30
|
-
moon:
|
|
31
|
-
mercury:
|
|
32
|
-
venus:
|
|
33
|
-
mars:
|
|
34
|
-
jupiter:
|
|
35
|
-
saturn:
|
|
36
|
-
uranus:
|
|
37
|
-
neptune:
|
|
38
|
-
pluto:
|
|
39
|
-
ascendant:
|
|
40
|
-
descendant:
|
|
41
|
-
midheaven:
|
|
42
|
-
imum_coeli:
|
|
43
|
-
north_node:
|
|
44
|
-
south_node:
|
|
45
|
-
chiron:
|
|
46
|
-
lilith:
|
|
47
|
-
vertex:
|
|
48
|
-
antivertex:
|
|
49
|
-
pars_fortuna:
|
|
50
|
-
pars_spiritus:
|
|
51
|
-
pars_victoria:
|
|
52
|
-
pars_amoris:
|
|
53
|
-
pars_eros:
|
|
54
|
-
pars_fortitudo:
|
|
55
|
-
pars_necessitatis:
|
|
35
|
+
sun: 'planet',
|
|
36
|
+
moon: 'planet',
|
|
37
|
+
mercury: 'planet',
|
|
38
|
+
venus: 'planet',
|
|
39
|
+
mars: 'planet',
|
|
40
|
+
jupiter: 'planet',
|
|
41
|
+
saturn: 'planet',
|
|
42
|
+
uranus: 'planet',
|
|
43
|
+
neptune: 'planet',
|
|
44
|
+
pluto: 'planet',
|
|
45
|
+
ascendant: 'key_point',
|
|
46
|
+
descendant: 'key_point',
|
|
47
|
+
midheaven: 'key_point',
|
|
48
|
+
imum_coeli: 'key_point',
|
|
49
|
+
north_node: 'karmic_point',
|
|
50
|
+
south_node: 'karmic_point',
|
|
51
|
+
chiron: 'karmic_point',
|
|
52
|
+
lilith: 'arabic_part',
|
|
53
|
+
vertex: 'arabic_part',
|
|
54
|
+
antivertex: 'arabic_part',
|
|
55
|
+
pars_fortuna: 'arabic_part',
|
|
56
|
+
pars_spiritus: 'arabic_part',
|
|
57
|
+
pars_victoria: 'arabic_part',
|
|
58
|
+
pars_amoris: 'arabic_part',
|
|
59
|
+
pars_eros: 'arabic_part',
|
|
60
|
+
pars_fortitudo: 'arabic_part',
|
|
61
|
+
pars_necessitatis: 'arabic_part',
|
|
56
62
|
};
|
|
57
63
|
|
|
58
64
|
// Subset of 14 points for aspects
|
|
59
65
|
export const aspectPoints: PointSlug[] = [
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
'sun',
|
|
67
|
+
'moon',
|
|
68
|
+
'mercury',
|
|
69
|
+
'venus',
|
|
70
|
+
'mars',
|
|
71
|
+
'jupiter',
|
|
72
|
+
'saturn',
|
|
73
|
+
'uranus',
|
|
74
|
+
'neptune',
|
|
75
|
+
'pluto',
|
|
76
|
+
'ascendant',
|
|
77
|
+
'descendant',
|
|
78
|
+
'midheaven',
|
|
79
|
+
'imum_coeli',
|
|
74
80
|
];
|
|
75
81
|
|
|
76
82
|
export type PointSlug = keyof typeof pointNameMap;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AspectType,
|
|
3
|
+
PointSlug,
|
|
4
|
+
ZodiacSign,
|
|
5
|
+
zodiacSignMap,
|
|
6
|
+
} from '../../types/scopes/legacy';
|
|
2
7
|
import { pointNameMap } from './pointNameMap';
|
|
3
8
|
|
|
4
9
|
// Interfaces for each function's parameters
|
|
5
10
|
interface PlanetOrPointParams {
|
|
6
|
-
type: 'planet' | 'key_point' | 'karmic_point' | '
|
|
11
|
+
type: 'planet' | 'key_point' | 'karmic_point' | 'arabic_part';
|
|
7
12
|
sign: ZodiacSign;
|
|
8
13
|
pointName: PointSlug;
|
|
9
14
|
}
|
|
@@ -16,13 +21,36 @@ interface HouseParams {
|
|
|
16
21
|
interface AspectParams {
|
|
17
22
|
aspectingPlanet: PointSlug;
|
|
18
23
|
aspectedPlanet: PointSlug;
|
|
19
|
-
aspectingType:
|
|
24
|
+
aspectingType: AspectType; // e.g., "conjunct", "square", "trine"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Parameters for each prompt type
|
|
28
|
+
interface PlanetOrPointParams {
|
|
29
|
+
type: 'planet' | 'key_point' | 'karmic_point' | 'arabic_part';
|
|
30
|
+
sign: ZodiacSign;
|
|
31
|
+
pointName: PointSlug;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface HousePlacementParams {
|
|
35
|
+
type: 'planet' | 'key_point' | 'karmic_point' | 'arabic_part';
|
|
36
|
+
house: number; // e.g., "1", "2", etc.
|
|
37
|
+
pointName: PointSlug;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface HouseParams {
|
|
41
|
+
houseNumber: number;
|
|
42
|
+
sign: ZodiacSign;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface AspectParams {
|
|
46
|
+
aspectingPlanet: PointSlug;
|
|
47
|
+
aspectedPlanet: PointSlug;
|
|
48
|
+
aspectingType: AspectType;
|
|
20
49
|
}
|
|
21
50
|
|
|
22
|
-
// Modular astroPrompts object
|
|
23
51
|
export const astroPrompts = {
|
|
24
52
|
planetOrPoint: ({ type, sign, pointName }: PlanetOrPointParams): string => {
|
|
25
|
-
const validTypes = ['planet', 'key_point', 'karmic_point', '
|
|
53
|
+
const validTypes = ['planet', 'key_point', 'karmic_point', 'arabic_part'];
|
|
26
54
|
if (!validTypes.includes(type)) {
|
|
27
55
|
throw new Error(
|
|
28
56
|
`Invalid type for planetOrPoint: ${type}. Must be one of ${validTypes.join(
|
|
@@ -48,6 +76,37 @@ export const astroPrompts = {
|
|
|
48
76
|
`.trim();
|
|
49
77
|
},
|
|
50
78
|
|
|
79
|
+
housePlacement: ({
|
|
80
|
+
type,
|
|
81
|
+
house,
|
|
82
|
+
pointName,
|
|
83
|
+
}: HousePlacementParams): string => {
|
|
84
|
+
const validTypes = ['planet', 'key_point', 'karmic_point', 'arabic_part'];
|
|
85
|
+
if (!validTypes.includes(type)) {
|
|
86
|
+
throw new Error(
|
|
87
|
+
`Invalid type for housePlacement: ${type}. Must be one of ${validTypes.join(
|
|
88
|
+
', '
|
|
89
|
+
)}`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const formattedPointName = pointNameMap[pointName] || pointName;
|
|
94
|
+
return `
|
|
95
|
+
Make me a report for the astrological placement: ${formattedPointName} in House ${house}.
|
|
96
|
+
The response should include an English version and a Portuguese version.
|
|
97
|
+
Use "###" for titles and "####" for subtitles.
|
|
98
|
+
The response format should be exactly like this:
|
|
99
|
+
|
|
100
|
+
-- EN
|
|
101
|
+
|
|
102
|
+
[English Report - structured with headings, sections, and detailed explanations]
|
|
103
|
+
|
|
104
|
+
-- PT
|
|
105
|
+
|
|
106
|
+
[Portuguese Report - structured exactly the same as the English version]
|
|
107
|
+
`.trim();
|
|
108
|
+
},
|
|
109
|
+
|
|
51
110
|
house: ({ houseNumber, sign }: HouseParams): string => {
|
|
52
111
|
return `
|
|
53
112
|
Make me a report for the astrological placement: House ${houseNumber} in ${zodiacSignMap[sign]}.
|
|
@@ -88,4 +147,3 @@ export const astroPrompts = {
|
|
|
88
147
|
`.trim();
|
|
89
148
|
},
|
|
90
149
|
};
|
|
91
|
-
|
package/utils/buildMessages.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AstroReportParams,
|
|
3
|
+
BackendBindings,
|
|
4
|
+
ChatMessages,
|
|
5
|
+
Concept,
|
|
6
|
+
Crown,
|
|
7
|
+
} from '../types';
|
|
8
|
+
import { astroPrompts } from './astroPrompts';
|
|
2
9
|
import { conceptPrompts } from './conceptPrompts';
|
|
3
10
|
import { mapConceptToPlanets } from './mapConceptToPlanets';
|
|
4
11
|
|
|
@@ -280,4 +287,55 @@ export const buildLLMMessages = (env: BackendBindings) => ({
|
|
|
280
287
|
content: `Translate this concept name into Brazilian Portuguese: "${englishName}"`,
|
|
281
288
|
},
|
|
282
289
|
],
|
|
290
|
+
|
|
291
|
+
generateAstroReportContent: ({
|
|
292
|
+
params,
|
|
293
|
+
}: {
|
|
294
|
+
params: AstroReportParams;
|
|
295
|
+
}): ChatMessages => {
|
|
296
|
+
let prompt: string;
|
|
297
|
+
|
|
298
|
+
switch (params.reportType) {
|
|
299
|
+
case 'sign':
|
|
300
|
+
prompt = astroPrompts.planetOrPoint({
|
|
301
|
+
type: params.type,
|
|
302
|
+
sign: params.sign,
|
|
303
|
+
pointName: params.pointName,
|
|
304
|
+
});
|
|
305
|
+
break;
|
|
306
|
+
|
|
307
|
+
case 'house':
|
|
308
|
+
prompt = astroPrompts.housePlacement({
|
|
309
|
+
type: params.type,
|
|
310
|
+
house: params.house,
|
|
311
|
+
pointName: params.pointName,
|
|
312
|
+
});
|
|
313
|
+
break;
|
|
314
|
+
|
|
315
|
+
case 'signInHouse':
|
|
316
|
+
prompt = astroPrompts.house({
|
|
317
|
+
houseNumber: params.houseNumber,
|
|
318
|
+
sign: params.sign,
|
|
319
|
+
});
|
|
320
|
+
break;
|
|
321
|
+
|
|
322
|
+
case 'aspect':
|
|
323
|
+
prompt = astroPrompts.aspect({
|
|
324
|
+
aspectingPlanet: params.aspectingPlanet,
|
|
325
|
+
aspectedPlanet: params.aspectedPlanet,
|
|
326
|
+
aspectingType: params.aspectingType,
|
|
327
|
+
});
|
|
328
|
+
break;
|
|
329
|
+
|
|
330
|
+
default:
|
|
331
|
+
throw new Error(`Unknown report type: ${(params as any).reportType}`);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return [
|
|
335
|
+
{
|
|
336
|
+
role: 'user',
|
|
337
|
+
content: prompt,
|
|
338
|
+
},
|
|
339
|
+
];
|
|
340
|
+
},
|
|
283
341
|
});
|
package/utils/index.ts
CHANGED
|
@@ -129,3 +129,11 @@ export function chunkArray<T>(array: T[], size: number): T[][] {
|
|
|
129
129
|
}
|
|
130
130
|
return result;
|
|
131
131
|
}
|
|
132
|
+
|
|
133
|
+
// Utility function to clean text
|
|
134
|
+
export function cleanText(text: string): string {
|
|
135
|
+
return text.replace(/\"/g, ''); // Replace \" with "
|
|
136
|
+
// Add more replacements here if needed, e.g.:
|
|
137
|
+
// .replace(/\\'/g, "'") // Replace \' with '
|
|
138
|
+
// .replace(/[^\w\s.,!?":'-]/g, "") // Remove all but common punctuation
|
|
139
|
+
}
|