@zodic/shared 0.0.243 → 0.0.245

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.
@@ -2174,15 +2174,25 @@ export class ConceptService {
2174
2174
  }
2175
2175
 
2176
2176
  private parseAstrologicalReport(response: string): AstrologicalReport[] {
2177
+ console.log("📌 Starting parseAstrologicalReport");
2178
+
2177
2179
  const reports: AstrologicalReport[] = [];
2178
2180
  const languageSections = response
2179
2181
  .split(/--\s*(EN|PT)\s*\n/)
2180
2182
  .filter(Boolean);
2183
+ console.log(`🔍 Split response into ${languageSections.length} sections`);
2181
2184
 
2182
2185
  for (let i = 0; i < languageSections.length; i += 2) {
2183
2186
  const language = languageSections[i].trim();
2184
2187
  const content = languageSections[i + 1]?.trim();
2185
- if (!content || !language.match(/^(EN|PT)$/)) continue;
2188
+ console.log(`🚀 Processing section ${i / 2 + 1}: Language = ${language}`);
2189
+
2190
+ if (!content || !language.match(/^(EN|PT)$/)) {
2191
+ console.warn(`⚠️ Skipping section ${i / 2 + 1}: Invalid content or language (${language})`);
2192
+ continue;
2193
+ }
2194
+
2195
+ console.log(`📜 Raw content for ${language}:\n${content.slice(0, 500)}${content.length > 500 ? "..." : ""}`);
2186
2196
 
2187
2197
  const report: AstrologicalReport = {
2188
2198
  language,
@@ -2191,35 +2201,63 @@ export class ConceptService {
2191
2201
  };
2192
2202
 
2193
2203
  const lines = content.split('\n').map((line) => line.trim());
2204
+ console.log(`🔢 Split into ${lines.length} lines`);
2205
+
2194
2206
  let currentSection = '';
2207
+ for (let j = 0; j < lines.length; j++) {
2208
+ const line = lines[j];
2209
+ console.log(`📏 Processing line ${j + 1}: "${line}"`);
2195
2210
 
2196
- for (const line of lines) {
2197
2211
  if (line.startsWith('### ') && report.title.length === 0) {
2212
+ const titleContent = cleanText(line.replace('### ', ''));
2213
+ console.log(`🏷️ Found title: "${titleContent}"`);
2198
2214
  report.title.push({
2199
2215
  type: 'title',
2200
- content: cleanText(line.replace('### ', '')),
2216
+ content: titleContent,
2201
2217
  });
2202
2218
  continue;
2203
2219
  }
2204
2220
 
2205
2221
  if (line.startsWith('#### ')) {
2206
2222
  currentSection = cleanText(line.replace('#### ', '').trim());
2223
+ console.log(`🗂️ New section: "${currentSection}"`);
2207
2224
  report.sections[currentSection] = report.sections[currentSection] || [];
2208
2225
  continue;
2209
2226
  }
2210
2227
 
2211
- if (!line || !currentSection) continue;
2228
+ if (!line || !currentSection) {
2229
+ console.log(`⏩ Skipping line: ${!line ? "Empty" : "No current section"}`);
2230
+ continue;
2231
+ }
2212
2232
 
2213
2233
  if (line.match(/^\d+\.\s/) || line.startsWith('- ')) {
2214
2234
  const listItem = line.replace(/^\d+\.\s|- /, '').trim();
2215
- const boldMatch = listItem.match(/^\*\*(.+?)\*\*[:\s]*(.+)$/); // Updated regex
2235
+ console.log(`🔹 Bullet point detected: "${listItem}"`);
2236
+ const boldMatch = listItem.match(/^\*\*(.+?)\*\*[:\s]*(.+)?$/); // Updated to allow standalone bold
2237
+
2216
2238
  if (boldMatch) {
2239
+ const title = cleanText(boldMatch[1]);
2240
+ let content = boldMatch[2] ? cleanText(boldMatch[2]) : '';
2241
+
2242
+ // Look ahead for content if none on the same line
2243
+ if (!content && j + 1 < lines.length) {
2244
+ const nextLine = lines[j + 1];
2245
+ console.log(`🔍 Checking next line for content: "${nextLine}"`);
2246
+ if (nextLine && !nextLine.match(/^\d+\.\s|- /) && !nextLine.startsWith('#### ') && !nextLine.startsWith('### ')) {
2247
+ content = cleanText(nextLine);
2248
+ console.log(`✅ Found content in next line: "${content}"`);
2249
+ j++; // Skip the next line since we’ve consumed it
2250
+ }
2251
+ }
2252
+
2253
+ console.log(`✅ Bold match found - Title: "${title}", Content: "${content || 'None'}"`);
2217
2254
  report.sections[currentSection].push({
2218
2255
  type: 'bullet-point',
2219
- title: cleanText(boldMatch[1]),
2220
- content: cleanText(boldMatch[2]),
2256
+ title,
2257
+ content: content || '', // Empty string if no content found
2221
2258
  });
2222
2259
  } else {
2260
+ console.log(`❌ No bold match - Full content: "${listItem}"`);
2223
2261
  report.sections[currentSection].push({
2224
2262
  type: 'bullet-point',
2225
2263
  content: cleanText(listItem),
@@ -2228,15 +2266,18 @@ export class ConceptService {
2228
2266
  continue;
2229
2267
  }
2230
2268
 
2269
+ console.log(`📝 Paragraph: "${line}"`);
2231
2270
  report.sections[currentSection].push({
2232
2271
  type: 'p',
2233
2272
  content: cleanText(line),
2234
2273
  });
2235
2274
  }
2236
2275
 
2276
+ console.log(`🏁 Finished parsing ${language} section. Result:\n${JSON.stringify(report, null, 2)}`);
2237
2277
  reports.push(report);
2238
2278
  }
2239
2279
 
2280
+ console.log(`🎉 Parsing complete. Total reports: ${reports.length}`);
2240
2281
  return reports;
2241
2282
  }
2242
2283
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zodic/shared",
3
- "version": "0.0.243",
3
+ "version": "0.0.245",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "publishConfig": {