chart2txt 0.6.0 → 0.7.1

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 (49) hide show
  1. package/README.md +103 -34
  2. package/dist/chart2txt.d.ts +9 -0
  3. package/dist/chart2txt.js +30 -0
  4. package/dist/chart2txt.min.js +1 -1
  5. package/dist/config/ChartSettings.d.ts +10 -6
  6. package/dist/config/ChartSettings.js +22 -11
  7. package/dist/constants.d.ts +17 -2
  8. package/dist/constants.js +303 -34
  9. package/dist/core/analysis.d.ts +6 -0
  10. package/dist/core/analysis.js +237 -0
  11. package/dist/core/aspectPatterns.d.ts +8 -3
  12. package/dist/core/aspectPatterns.js +234 -218
  13. package/dist/core/aspects.d.ts +14 -11
  14. package/dist/core/aspects.js +49 -32
  15. package/dist/core/dignities.d.ts +2 -27
  16. package/dist/core/dignities.js +56 -121
  17. package/dist/core/dispositors.d.ts +7 -19
  18. package/dist/core/dispositors.js +152 -126
  19. package/dist/core/grouping.d.ts +9 -0
  20. package/dist/core/grouping.js +45 -0
  21. package/dist/core/signDistributions.d.ts +20 -30
  22. package/dist/core/signDistributions.js +25 -122
  23. package/dist/core/stelliums.d.ts +10 -0
  24. package/dist/core/stelliums.js +108 -0
  25. package/dist/formatters/text/sections/aspectPatterns.d.ts +3 -1
  26. package/dist/formatters/text/sections/aspectPatterns.js +118 -94
  27. package/dist/formatters/text/sections/aspects.d.ts +3 -6
  28. package/dist/formatters/text/sections/aspects.js +35 -52
  29. package/dist/formatters/text/sections/dispositors.d.ts +4 -3
  30. package/dist/formatters/text/sections/dispositors.js +12 -8
  31. package/dist/formatters/text/sections/houseOverlays.d.ts +11 -6
  32. package/dist/formatters/text/sections/houseOverlays.js +37 -44
  33. package/dist/formatters/text/sections/metadata.d.ts +2 -0
  34. package/dist/formatters/text/sections/metadata.js +54 -0
  35. package/dist/formatters/text/sections/planets.d.ts +3 -5
  36. package/dist/formatters/text/sections/planets.js +11 -22
  37. package/dist/formatters/text/sections/signDistributions.d.ts +9 -25
  38. package/dist/formatters/text/sections/signDistributions.js +9 -55
  39. package/dist/formatters/text/textFormatter.d.ts +4 -5
  40. package/dist/formatters/text/textFormatter.js +86 -142
  41. package/dist/index.d.ts +7 -4
  42. package/dist/index.js +11 -6
  43. package/dist/types.d.ts +102 -15
  44. package/dist/types.js +15 -0
  45. package/dist/utils/formatting.d.ts +4 -0
  46. package/dist/utils/formatting.js +43 -0
  47. package/dist/utils/houseCalculations.d.ts +10 -13
  48. package/dist/utils/houseCalculations.js +15 -57
  49. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -4,9 +4,12 @@
4
4
  *
5
5
  * This is the main entry point for the library.
6
6
  */
7
- export { formatChartToText as chart2txt } from './formatters/text/textFormatter';
7
+ export { chart2txt } from './chart2txt';
8
+ export { analyzeCharts } from './core/analysis';
9
+ export { groupAspects } from './core/grouping';
10
+ export { formatReportToText } from './formatters/text/textFormatter';
8
11
  export * from './types';
9
- export { DEFAULT_SETTINGS, DEFAULT_ASPECTS, DEFAULT_ASPECT_CATEGORIES, ZODIAC_SIGNS, } from './constants';
12
+ export { DEFAULT_SETTINGS, DEFAULT_ASPECTS, ZODIAC_SIGNS } from './constants';
10
13
  export { ChartSettings } from './config/ChartSettings';
11
- import { formatChartToText } from './formatters/text/textFormatter';
12
- export default formatChartToText;
14
+ import { chart2txt } from './chart2txt';
15
+ export default chart2txt;
package/dist/index.js CHANGED
@@ -20,21 +20,26 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
20
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.ChartSettings = exports.ZODIAC_SIGNS = exports.DEFAULT_ASPECT_CATEGORIES = exports.DEFAULT_ASPECTS = exports.DEFAULT_SETTINGS = exports.chart2txt = void 0;
24
- // Core formatter function
23
+ exports.ChartSettings = exports.ZODIAC_SIGNS = exports.DEFAULT_ASPECTS = exports.DEFAULT_SETTINGS = exports.formatReportToText = exports.groupAspects = exports.analyzeCharts = exports.chart2txt = void 0;
24
+ // Core functions
25
+ var chart2txt_1 = require("./chart2txt");
26
+ Object.defineProperty(exports, "chart2txt", { enumerable: true, get: function () { return chart2txt_1.chart2txt; } });
27
+ var analysis_1 = require("./core/analysis");
28
+ Object.defineProperty(exports, "analyzeCharts", { enumerable: true, get: function () { return analysis_1.analyzeCharts; } });
29
+ var grouping_1 = require("./core/grouping");
30
+ Object.defineProperty(exports, "groupAspects", { enumerable: true, get: function () { return grouping_1.groupAspects; } });
25
31
  var textFormatter_1 = require("./formatters/text/textFormatter");
26
- Object.defineProperty(exports, "chart2txt", { enumerable: true, get: function () { return textFormatter_1.formatChartToText; } });
32
+ Object.defineProperty(exports, "formatReportToText", { enumerable: true, get: function () { return textFormatter_1.formatReportToText; } });
27
33
  // Export all types for library users
28
34
  __exportStar(require("./types"), exports);
29
35
  // Export constants that might be useful for users (e.g., for custom settings)
30
36
  var constants_1 = require("./constants");
31
37
  Object.defineProperty(exports, "DEFAULT_SETTINGS", { enumerable: true, get: function () { return constants_1.DEFAULT_SETTINGS; } });
32
38
  Object.defineProperty(exports, "DEFAULT_ASPECTS", { enumerable: true, get: function () { return constants_1.DEFAULT_ASPECTS; } });
33
- Object.defineProperty(exports, "DEFAULT_ASPECT_CATEGORIES", { enumerable: true, get: function () { return constants_1.DEFAULT_ASPECT_CATEGORIES; } });
34
39
  Object.defineProperty(exports, "ZODIAC_SIGNS", { enumerable: true, get: function () { return constants_1.ZODIAC_SIGNS; } });
35
40
  // Export ChartSettings class for advanced configuration
36
41
  var ChartSettings_1 = require("./config/ChartSettings");
37
42
  Object.defineProperty(exports, "ChartSettings", { enumerable: true, get: function () { return ChartSettings_1.ChartSettings; } });
38
43
  // Default export for convenience (e.g. UMD builds or simple script tags)
39
- const textFormatter_2 = require("./formatters/text/textFormatter");
40
- exports.default = textFormatter_2.formatChartToText;
44
+ const chart2txt_2 = require("./chart2txt");
45
+ exports.default = chart2txt_2.chart2txt;
package/dist/types.d.ts CHANGED
@@ -17,28 +17,46 @@ export interface ChartData {
17
17
  }
18
18
  export type MultiChartData = ChartData[];
19
19
  export declare function isMultiChartData(obj: ChartData | MultiChartData): obj is MultiChartData;
20
+ export type UnionedPoint = [Point, string];
21
+ export declare enum AspectClassification {
22
+ Major = "major",
23
+ Minor = "minor",
24
+ Esoteric = "esoteric"
25
+ }
26
+ export declare enum PlanetCategory {
27
+ Luminaries = "luminaries",
28
+ Personal = "personal",
29
+ Social = "social",
30
+ Outer = "outer",
31
+ Angles = "angles"
32
+ }
20
33
  export interface Aspect {
21
34
  name: string;
22
35
  angle: number;
23
36
  orb: number;
37
+ classification?: AspectClassification;
38
+ }
39
+ export type AspectStrength = 'tight' | 'moderate' | 'wide';
40
+ export interface AspectStrengthThresholds {
41
+ tight: number;
42
+ moderate: number;
24
43
  }
25
44
  export interface AspectData {
26
45
  planetA: string;
27
46
  planetB: string;
47
+ p1ChartName?: string;
48
+ p2ChartName?: string;
28
49
  aspectType: string;
29
50
  orb: number;
30
51
  application?: 'applying' | 'separating' | 'exact';
31
52
  }
32
- export interface AspectCategory {
33
- name: string;
34
- minOrb?: number;
35
- maxOrb: number;
36
- }
37
53
  export interface PlanetPosition {
38
54
  name: string;
39
55
  degree: number;
40
56
  sign: string;
57
+ speed?: number;
41
58
  house?: number;
59
+ chartName?: string;
42
60
  }
43
61
  export interface TSquare {
44
62
  type: 'T-Square';
@@ -93,15 +111,84 @@ export interface Kite {
93
111
  averageOrb: number;
94
112
  }
95
113
  export type AspectPattern = TSquare | GrandTrine | Stellium | GrandCross | Yod | MysticRectangle | Kite;
96
- export interface Settings {
97
- includeSignDegree: boolean;
98
- includeAscendant: boolean;
99
- houseSystemName: string;
100
- includeHouseDegree: boolean;
101
- aspectDefinitions: Aspect[];
102
- aspectCategories: AspectCategory[];
103
- skipOutOfSignAspects: boolean;
104
- includeAspectPatterns: boolean;
105
- dateFormat: string;
114
+ export interface ChartAnalysis {
115
+ chart: ChartData;
116
+ placements: {
117
+ planets: PlanetPosition[];
118
+ [key: string]: any;
119
+ };
120
+ aspects: AspectData[];
121
+ groupedAspects?: Map<string, AspectData[]>;
122
+ patterns: AspectPattern[];
123
+ stelliums: Stellium[];
124
+ signDistributions: {
125
+ elements: {
126
+ [key: string]: string[];
127
+ };
128
+ modalities: {
129
+ [key: string]: number;
130
+ };
131
+ polarities: {
132
+ [key: string]: number;
133
+ };
134
+ };
135
+ dispositors: {
136
+ [key: string]: string;
137
+ };
138
+ }
139
+ export interface PairwiseAnalysis {
140
+ chart1: ChartData;
141
+ chart2: ChartData;
142
+ synastryAspects: AspectData[];
143
+ groupedSynastryAspects?: Map<string, AspectData[]>;
144
+ compositePatterns: AspectPattern[];
145
+ houseOverlays: {
146
+ chart1InChart2Houses: {
147
+ [key: string]: number;
148
+ };
149
+ chart2InChart1Houses: {
150
+ [key: string]: number;
151
+ };
152
+ };
153
+ }
154
+ export interface GlobalAnalysis {
155
+ charts: ChartData[];
156
+ patterns: AspectPattern[];
157
+ }
158
+ export interface TransitAnalysis {
159
+ natalChart: ChartData;
160
+ transitChart: ChartData;
161
+ aspects: AspectData[];
162
+ groupedAspects?: Map<string, AspectData[]>;
163
+ patterns: AspectPattern[];
164
+ }
165
+ export interface AstrologicalReport {
166
+ settings: Settings;
167
+ chartAnalyses: ChartAnalysis[];
168
+ pairwiseAnalyses: PairwiseAnalysis[];
169
+ globalAnalysis?: GlobalAnalysis;
170
+ transitAnalyses: TransitAnalysis[];
171
+ globalTransitAnalysis?: GlobalAnalysis;
172
+ }
173
+ export interface AnalysisSettings {
174
+ aspectDefinitions?: Aspect[] | 'traditional' | 'modern' | 'tight' | 'wide';
175
+ skipOutOfSignAspects?: boolean;
176
+ includeAspectPatterns?: boolean;
177
+ includeSignDistributions?: boolean;
178
+ includeDispositors?: boolean | 'finals';
179
+ includeHouseOverlays?: boolean;
180
+ }
181
+ export interface GroupingSettings {
182
+ aspectStrengthThresholds?: AspectStrengthThresholds;
183
+ }
184
+ export interface FormattingSettings {
185
+ dateFormat?: string;
186
+ houseSystemName?: string;
187
+ }
188
+ export interface Settings extends AnalysisSettings, GroupingSettings, FormattingSettings {
106
189
  }
107
190
  export type PartialSettings = Partial<Settings>;
191
+ export type ChartDataWithInfo = {
192
+ data: ChartData;
193
+ index: number;
194
+ };
package/dist/types.js CHANGED
@@ -1,6 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PlanetCategory = exports.AspectClassification = void 0;
3
4
  exports.isMultiChartData = isMultiChartData;
4
5
  function isMultiChartData(obj) {
5
6
  return Array.isArray(obj);
6
7
  }
8
+ var AspectClassification;
9
+ (function (AspectClassification) {
10
+ AspectClassification["Major"] = "major";
11
+ AspectClassification["Minor"] = "minor";
12
+ AspectClassification["Esoteric"] = "esoteric";
13
+ })(AspectClassification || (exports.AspectClassification = AspectClassification = {}));
14
+ var PlanetCategory;
15
+ (function (PlanetCategory) {
16
+ PlanetCategory["Luminaries"] = "luminaries";
17
+ PlanetCategory["Personal"] = "personal";
18
+ PlanetCategory["Social"] = "social";
19
+ PlanetCategory["Outer"] = "outer";
20
+ PlanetCategory["Angles"] = "angles";
21
+ })(PlanetCategory || (exports.PlanetCategory = PlanetCategory = {}));
@@ -1,6 +1,10 @@
1
+ import { Point, PlanetPosition } from '../types';
1
2
  /**
2
3
  * Converts a number to its ordinal form (1st, 2nd, 3rd, etc.)
3
4
  * @param num The number to convert
4
5
  * @returns The ordinal string
5
6
  */
6
7
  export declare function getOrdinal(num: number): string;
8
+ export declare function getSign(degree: number): string;
9
+ export declare function getHouse(degree: number, houseCusps: number[]): number;
10
+ export declare function getPlanetPositions(planets: Point[], houseCusps?: number[]): PlanetPosition[];
@@ -1,6 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getOrdinal = getOrdinal;
4
+ exports.getSign = getSign;
5
+ exports.getHouse = getHouse;
6
+ exports.getPlanetPositions = getPlanetPositions;
7
+ const constants_1 = require("../constants");
8
+ function normalizeDegree(degree) {
9
+ return ((degree % 360) + 360) % 360;
10
+ }
4
11
  /**
5
12
  * Converts a number to its ordinal form (1st, 2nd, 3rd, etc.)
6
13
  * @param num The number to convert
@@ -11,3 +18,39 @@ function getOrdinal(num) {
11
18
  const v = num % 100;
12
19
  return num + (suffix[(v - 20) % 10] || suffix[v] || suffix[0]);
13
20
  }
21
+ function getSign(degree) {
22
+ const signIndex = Math.floor(degree / 30);
23
+ return constants_1.ZODIAC_SIGNS[signIndex];
24
+ }
25
+ function getHouse(degree, houseCusps) {
26
+ for (let i = 0; i < 12; i++) {
27
+ const cusp1 = houseCusps[i];
28
+ const cusp2 = houseCusps[(i + 1) % 12];
29
+ if (cusp1 < cusp2) {
30
+ if (degree >= cusp1 && degree < cusp2) {
31
+ return i + 1;
32
+ }
33
+ }
34
+ else {
35
+ if (degree >= cusp1 || degree < cusp2) {
36
+ return i + 1;
37
+ }
38
+ }
39
+ }
40
+ return -1; // Should not happen
41
+ }
42
+ function getPlanetPositions(planets, houseCusps) {
43
+ return planets.map((planet) => {
44
+ const normalizedDegree = normalizeDegree(planet.degree);
45
+ const position = {
46
+ name: planet.name,
47
+ degree: normalizedDegree,
48
+ sign: getSign(normalizedDegree),
49
+ speed: planet.speed,
50
+ };
51
+ if (houseCusps) {
52
+ position.house = getHouse(normalizedDegree, houseCusps);
53
+ }
54
+ return position;
55
+ });
56
+ }
@@ -1,13 +1,10 @@
1
- /**
2
- * Validates house cusps array for correctness
3
- * @param houseCusps Array of 12 house cusp degrees
4
- * @returns True if valid, false otherwise
5
- */
6
- export declare function validateHouseCusps(houseCusps: number[] | undefined): boolean;
7
- /**
8
- * Determines which house a point falls into based on house cusps
9
- * @param pointDegree The degree of the point (will be normalized)
10
- * @param houseCusps Array of 12 house cusp degrees
11
- * @returns House number (1-12) or null if calculation fails
12
- */
13
- export declare function getHouseForPoint(pointDegree: number, houseCusps: number[] | undefined): number | null;
1
+ import { ChartData } from '../types';
2
+ export declare function calculateHouseOverlays(chart1: ChartData, chart2: ChartData): {
3
+ chart1InChart2Houses: {
4
+ [key: string]: number;
5
+ };
6
+ chart2InChart1Houses: {
7
+ [key: string]: number;
8
+ };
9
+ };
10
+ export declare function getHouseForPoint(degree: number, houseCusps: number[]): number;
@@ -1,65 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateHouseCusps = validateHouseCusps;
3
+ exports.calculateHouseOverlays = calculateHouseOverlays;
4
4
  exports.getHouseForPoint = getHouseForPoint;
5
- const astrology_1 = require("../core/astrology");
6
- const precision_1 = require("./precision");
7
- /**
8
- * Validates house cusps array for correctness
9
- * @param houseCusps Array of 12 house cusp degrees
10
- * @returns True if valid, false otherwise
11
- */
12
- function validateHouseCusps(houseCusps) {
13
- if (!houseCusps || houseCusps.length !== 12) {
14
- return false;
15
- }
16
- // Check that all cusp values are finite numbers
17
- for (const cusp of houseCusps) {
18
- if (!isFinite(cusp)) {
19
- return false;
20
- }
21
- }
22
- return true;
23
- }
24
- /**
25
- * Determines which house a point falls into based on house cusps
26
- * @param pointDegree The degree of the point (will be normalized)
27
- * @param houseCusps Array of 12 house cusp degrees
28
- * @returns House number (1-12) or null if calculation fails
29
- */
30
- function getHouseForPoint(pointDegree, houseCusps) {
31
- if (!validateHouseCusps(houseCusps)) {
32
- return null;
33
- }
34
- if (!isFinite(pointDegree)) {
35
- return null;
36
- }
37
- const normalizedPoint = (0, precision_1.roundDegrees)((0, astrology_1.normalizeDegree)(pointDegree));
38
- const normalizedCusps = houseCusps.map((cusp) => (0, precision_1.roundDegrees)((0, astrology_1.normalizeDegree)(cusp)));
39
- // Check if point is exactly on any cusp (within precision tolerance)
40
- for (let i = 0; i < 12; i++) {
41
- if ((0, precision_1.isOnCusp)(normalizedPoint, normalizedCusps[i])) {
42
- // Point is exactly on cusp - assign to the house that starts at this cusp
43
- return i + 1;
5
+ const formatting_1 = require("./formatting");
6
+ function calculateHouseOverlays(chart1, chart2) {
7
+ const chart1InChart2Houses = {};
8
+ if (chart2.houseCusps) {
9
+ for (const planet of chart1.planets) {
10
+ chart1InChart2Houses[planet.name] = (0, formatting_1.getHouse)(planet.degree, chart2.houseCusps);
44
11
  }
45
12
  }
46
- for (let i = 0; i < 12; i++) {
47
- const cuspStart = normalizedCusps[i];
48
- const cuspEnd = normalizedCusps[(i + 1) % 12];
49
- if (cuspStart < cuspEnd) {
50
- // Normal case: cusp doesn't cross 0° boundary
51
- if (normalizedPoint > cuspStart && normalizedPoint < cuspEnd) {
52
- return i + 1;
53
- }
54
- }
55
- else {
56
- // Wraparound case: cusp crosses 0°/360° boundary
57
- if (normalizedPoint > cuspStart || normalizedPoint < cuspEnd) {
58
- return i + 1;
59
- }
13
+ const chart2InChart1Houses = {};
14
+ if (chart1.houseCusps) {
15
+ for (const planet of chart2.planets) {
16
+ chart2InChart1Houses[planet.name] = (0, formatting_1.getHouse)(planet.degree, chart1.houseCusps);
60
17
  }
61
18
  }
62
- // This should never happen if cusps properly cover 360 degrees
63
- console.warn(`Point at ${normalizedPoint}° does not fall in any house`);
64
- return null;
19
+ return { chart1InChart2Houses, chart2InChart1Houses };
20
+ }
21
+ function getHouseForPoint(degree, houseCusps) {
22
+ return (0, formatting_1.getHouse)(degree, houseCusps);
65
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chart2txt",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "description": "Convert astrological chart data to human-readable text",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",