@zodic/shared 0.0.273 → 0.0.275

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.
@@ -850,7 +850,6 @@ export class ConceptService {
850
850
  * Queue image generation for a concept.
851
851
  */
852
852
  async generateImages(
853
- language: Languages,
854
853
  conceptSlug: Concept,
855
854
  combinationString: string
856
855
  ): Promise<void> {
@@ -859,7 +858,7 @@ export class ConceptService {
859
858
  const { generations, conceptCombinations, concepts } = schema;
860
859
 
861
860
  console.log(
862
- `🚀 Queuing image generation for concept: ${conceptSlug}, combination: ${combinationString}, language: ${language}`
861
+ `🚀 Queuing image generation for concept: ${conceptSlug}, combination: ${combinationString}`
863
862
  );
864
863
 
865
864
  const conceptEntries = await db
@@ -871,7 +870,7 @@ export class ConceptService {
871
870
  and(
872
871
  eq(conceptsData.conceptSlug, conceptSlug),
873
872
  eq(conceptsData.combination, combinationString),
874
- eq(conceptsData.language, language) // ✅ Fetch both languages
873
+ eq(conceptsData.language, "en-us") // ✅ Fetch both languages
875
874
  )
876
875
  )
877
876
  .limit(1);
@@ -2018,4 +2017,81 @@ export class ConceptService {
2018
2017
  console.log(`🎉 Parsing complete. Total reports: ${reports.length}`);
2019
2018
  return reports;
2020
2019
  }
2020
+
2021
+ async ensureConceptDataComplete(
2022
+ conceptSlug: Concept,
2023
+ combinationString: string
2024
+ ): Promise<boolean> {
2025
+ const db = this.context.drizzle();
2026
+ console.log(
2027
+ `🔍 Ensuring concept data complete for ${conceptSlug}:${combinationString}`
2028
+ );
2029
+
2030
+ // ✅ Check concepts_data for completeness (English for simplicity)
2031
+ let conceptDataEntry = (
2032
+ await db
2033
+ .select({
2034
+ leonardoPrompt: conceptsData.leonardoPrompt,
2035
+ postImages: conceptsData.postImages,
2036
+ reelImages: conceptsData.reelImages,
2037
+ })
2038
+ .from(conceptsData)
2039
+ .where(
2040
+ and(
2041
+ eq(conceptsData.conceptSlug, conceptSlug),
2042
+ eq(conceptsData.combination, combinationString),
2043
+ eq(conceptsData.language, 'en-us')
2044
+ )
2045
+ )
2046
+ .limit(1)
2047
+ .execute()
2048
+ )[0];
2049
+
2050
+ const hasImages =
2051
+ conceptDataEntry?.postImages &&
2052
+ conceptDataEntry?.reelImages &&
2053
+ JSON.parse(conceptDataEntry.postImages || '[]').length > 0 &&
2054
+ JSON.parse(conceptDataEntry.reelImages || '[]').length > 0;
2055
+
2056
+ // ✅ Generate leonardoPrompt if missing
2057
+ if (!conceptDataEntry?.leonardoPrompt) {
2058
+ console.log(
2059
+ `🚀 Generating Leonardo prompt for ${conceptSlug}:${combinationString}`
2060
+ );
2061
+ await this.generatePrompt(conceptSlug, combinationString);
2062
+ // Re-fetch updated data
2063
+ conceptDataEntry = (
2064
+ await db
2065
+ .select({
2066
+ leonardoPrompt: conceptsData.leonardoPrompt,
2067
+ postImages: conceptsData.postImages,
2068
+ reelImages: conceptsData.reelImages,
2069
+ })
2070
+ .from(conceptsData)
2071
+ .where(
2072
+ and(
2073
+ eq(conceptsData.conceptSlug, conceptSlug),
2074
+ eq(conceptsData.combination, combinationString),
2075
+ eq(conceptsData.language, 'en-us')
2076
+ )
2077
+ )
2078
+ .limit(1)
2079
+ .execute()
2080
+ )[0];
2081
+ }
2082
+
2083
+ // ✅ Generate images if missing
2084
+ if (!hasImages) {
2085
+ console.log(
2086
+ `🖼️ Generating images for ${conceptSlug}:${combinationString}`
2087
+ );
2088
+ await this.generateImages(conceptSlug, combinationString);
2089
+ return false; // Images are being generated, not complete yet
2090
+ }
2091
+
2092
+ console.log(
2093
+ `✅ Concept data complete for ${conceptSlug}:${combinationString}`
2094
+ );
2095
+ return true; // Everything is ready
2096
+ }
2021
2097
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zodic/shared",
3
- "version": "0.0.273",
3
+ "version": "0.0.275",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -541,3 +541,16 @@ export type ConceptProgress = {
541
541
  ratePerMinute: number;
542
542
  estimatedTimeMinutes: number | 'N/A';
543
543
  };
544
+
545
+ export type UserConceptData = {
546
+ name: string; // From conceptsData.name (text, notNull)
547
+ description: string; // From conceptsData.description (text, notNull)
548
+ poem: string; // From conceptsData.poem (text, defaults to '[]', but assuming parsed as string)
549
+ content: any[]; // From conceptsData.content (text, JSON-stringified array, parsed)
550
+ images: {
551
+ post: any[]; // From conceptsData.postImages (text, JSON-stringified array, parsed)
552
+ reel: any[]; // From conceptsData.reelImages (text, JSON-stringified array, parsed)
553
+ };
554
+ combinationString: string; // e.g., "sagittarius-aquarius-libra"
555
+ conceptSlug: Concept;
556
+ };