@zodic/shared 0.0.407 → 0.0.409
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/api/index.ts +1 -3
- package/app/services/ConceptService.ts +57 -55
- package/package.json +1 -1
package/app/api/index.ts
CHANGED
|
@@ -719,9 +719,7 @@ export const Api = (env: BackendBindings) => ({
|
|
|
719
719
|
},
|
|
720
720
|
config: {
|
|
721
721
|
webhook_config: {
|
|
722
|
-
endpoint:
|
|
723
|
-
'https://zodic-backend.lucdelbel.workers.dev/api/webhook/faceswap',
|
|
724
|
-
// secret: '',
|
|
722
|
+
endpoint: `${env.API_BASE_URL}/api/webhook/faceswap`,
|
|
725
723
|
},
|
|
726
724
|
},
|
|
727
725
|
});
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
KVNamespaceListKey,
|
|
3
|
-
KVNamespaceListResult,
|
|
4
|
-
} from '@cloudflare/workers-types';
|
|
5
|
-
import { and, eq, inArray, isNull, sql } from 'drizzle-orm';
|
|
1
|
+
import { and, eq, inArray, isNull } from 'drizzle-orm';
|
|
6
2
|
import { drizzle } from 'drizzle-orm/d1';
|
|
7
3
|
import { inject, injectable } from 'inversify';
|
|
8
4
|
import 'reflect-metadata';
|
|
@@ -27,14 +23,9 @@ import {
|
|
|
27
23
|
ControlNetConfig,
|
|
28
24
|
DescriptionTemplateRow,
|
|
29
25
|
} from '../../types';
|
|
30
|
-
import {
|
|
31
|
-
KVConcept,
|
|
32
|
-
sizes,
|
|
33
|
-
StructuredConceptContent,
|
|
34
|
-
} from '../../types/scopes/legacy';
|
|
26
|
+
import { sizes, StructuredConceptContent } from '../../types/scopes/legacy';
|
|
35
27
|
import { astroPrompts } from '../../utils/astroPrompts';
|
|
36
28
|
import { leonardoInitImages } from '../../utils/initImages';
|
|
37
|
-
import { buildConceptKVKey } from '../../utils/KVKeysBuilders';
|
|
38
29
|
import { AppContext } from '../base/AppContext';
|
|
39
30
|
|
|
40
31
|
@injectable()
|
|
@@ -902,7 +893,6 @@ export class ConceptService {
|
|
|
902
893
|
* Fetch and initialize a KVConcept object if not present.
|
|
903
894
|
*/
|
|
904
895
|
|
|
905
|
-
|
|
906
896
|
async generateAstroReportContent(
|
|
907
897
|
params:
|
|
908
898
|
| AstroReportParams
|
|
@@ -1662,7 +1652,7 @@ export class ConceptService {
|
|
|
1662
1652
|
|
|
1663
1653
|
async queueUserConcepts(userId: string): Promise<void> {
|
|
1664
1654
|
console.log(
|
|
1665
|
-
`[${new Date().toISOString()}] 🔧 Starting queueing of user concepts for user ${userId}`
|
|
1655
|
+
`[${new Date().toISOString()}] 🔧 Starting queueing of user concepts data for user ${userId}`
|
|
1666
1656
|
);
|
|
1667
1657
|
|
|
1668
1658
|
const lang = await this.getLang(userId);
|
|
@@ -1671,7 +1661,7 @@ export class ConceptService {
|
|
|
1671
1661
|
);
|
|
1672
1662
|
|
|
1673
1663
|
const db = this.context.drizzle();
|
|
1674
|
-
const {
|
|
1664
|
+
const { conceptsData } = schema;
|
|
1675
1665
|
|
|
1676
1666
|
// Fetch all available concepts
|
|
1677
1667
|
const concepts = await this.getAllConcepts();
|
|
@@ -1726,52 +1716,55 @@ export class ConceptService {
|
|
|
1726
1716
|
`[${new Date().toISOString()}] 🔗 Generated combination string for ${conceptSlug}: ${combinationString}`
|
|
1727
1717
|
);
|
|
1728
1718
|
|
|
1729
|
-
//
|
|
1730
|
-
const
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
const existingUserConcept = await db
|
|
1742
|
-
.select({ conceptCombinationId: userConcepts.conceptCombinationId })
|
|
1743
|
-
.from(userConcepts)
|
|
1719
|
+
// Check conceptData completion
|
|
1720
|
+
const [conceptDataEntry] = await db
|
|
1721
|
+
.select({
|
|
1722
|
+
name: conceptsData.name,
|
|
1723
|
+
description: conceptsData.description,
|
|
1724
|
+
content: conceptsData.content,
|
|
1725
|
+
poem: conceptsData.poem,
|
|
1726
|
+
postImages: conceptsData.postImages,
|
|
1727
|
+
framedImages: conceptsData.framedImages,
|
|
1728
|
+
reelImages: conceptsData.reelImages,
|
|
1729
|
+
})
|
|
1730
|
+
.from(conceptsData)
|
|
1744
1731
|
.where(
|
|
1745
1732
|
and(
|
|
1746
|
-
eq(
|
|
1747
|
-
eq(
|
|
1733
|
+
eq(conceptsData.conceptSlug, conceptSlug),
|
|
1734
|
+
eq(conceptsData.combination, combinationString),
|
|
1735
|
+
eq(conceptsData.language, lang)
|
|
1748
1736
|
)
|
|
1749
1737
|
)
|
|
1750
1738
|
.limit(1)
|
|
1751
1739
|
.execute();
|
|
1752
1740
|
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
updatedAt: sql`CURRENT_TIMESTAMP`,
|
|
1764
|
-
})
|
|
1765
|
-
.execute();
|
|
1766
|
-
console.log(
|
|
1767
|
-
`[${new Date().toISOString()}] ✅ Inserted new user concept with ID: ${userConceptId} for ${conceptSlug}`
|
|
1768
|
-
);
|
|
1769
|
-
} else {
|
|
1741
|
+
const isComplete = await this.checkConceptCompletion(
|
|
1742
|
+
conceptSlug as Concept,
|
|
1743
|
+
combinationString,
|
|
1744
|
+
lang
|
|
1745
|
+
);
|
|
1746
|
+
console.log(
|
|
1747
|
+
`[${new Date().toISOString()}] ✅ Checked completion status: ${isComplete} for ${conceptSlug}:${combinationString}`
|
|
1748
|
+
);
|
|
1749
|
+
|
|
1750
|
+
if (conceptDataEntry && isComplete) {
|
|
1770
1751
|
console.log(
|
|
1771
|
-
`[${new Date().toISOString()}]
|
|
1752
|
+
`[${new Date().toISOString()}] ✅ Concept data already complete for ${conceptSlug}:${combinationString}, skipping queue`
|
|
1772
1753
|
);
|
|
1754
|
+
continue; // Skip to the next concept if data is complete
|
|
1773
1755
|
}
|
|
1774
1756
|
|
|
1757
|
+
// Create or retrieve conceptCombination
|
|
1758
|
+
const conceptCombinationId = await this.getOrCreateConceptCombination(
|
|
1759
|
+
conceptId,
|
|
1760
|
+
combinationString,
|
|
1761
|
+
planets,
|
|
1762
|
+
userSigns
|
|
1763
|
+
);
|
|
1764
|
+
console.log(
|
|
1765
|
+
`[${new Date().toISOString()}] ✅ Created/Retrieved concept combination ID for ${conceptSlug}: ${conceptCombinationId}`
|
|
1766
|
+
);
|
|
1767
|
+
|
|
1775
1768
|
// Queue the generation
|
|
1776
1769
|
const queuePayload = {
|
|
1777
1770
|
userId,
|
|
@@ -1784,14 +1777,23 @@ export class ConceptService {
|
|
|
1784
1777
|
`[${new Date().toISOString()}] ✅ Queue Payload for ${conceptSlug}:`,
|
|
1785
1778
|
queuePayload
|
|
1786
1779
|
);
|
|
1787
|
-
|
|
1780
|
+
|
|
1781
|
+
try {
|
|
1782
|
+
await this.context.env.CONCEPT_GENERATION_QUEUE.send(queuePayload);
|
|
1783
|
+
console.log(
|
|
1784
|
+
`[${new Date().toISOString()}] ⏳ Queued concept generation for ${conceptSlug}:${combinationString}`
|
|
1785
|
+
);
|
|
1786
|
+
} catch (error) {
|
|
1787
|
+
console.log(
|
|
1788
|
+
`[${new Date().toISOString()}] Failed to queue concept generation for ${conceptSlug}:${combinationString}: Error ${
|
|
1789
|
+
(error as Error).message
|
|
1790
|
+
}`
|
|
1791
|
+
);
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1788
1794
|
console.log(
|
|
1789
|
-
`[${new Date().toISOString()}]
|
|
1795
|
+
`[${new Date().toISOString()}] ✅ Completed queueing all concepts data for user ${userId}`
|
|
1790
1796
|
);
|
|
1791
1797
|
}
|
|
1792
|
-
|
|
1793
|
-
console.log(
|
|
1794
|
-
`[${new Date().toISOString()}] ✅ Completed queueing all concepts for user ${userId}`
|
|
1795
|
-
);
|
|
1796
1798
|
}
|
|
1797
1799
|
}
|