@zodic/shared 0.0.296 → 0.0.297
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/ArchetypeService.ts +51 -20
- package/db/migrations/0013_lean_frightful_four.sql +7 -0
- package/db/migrations/meta/0013_snapshot.json +2649 -0
- package/db/migrations/meta/_journal.json +7 -0
- package/db/schema.ts +16 -2
- package/package.json +1 -1
- package/utils/isEnglishNameDuplicate.ts +22 -0
package/db/schema.ts
CHANGED
|
@@ -388,8 +388,10 @@ export const userArtifacts = sqliteTable(
|
|
|
388
388
|
.references(() => artifacts.id, { onDelete: 'cascade' }),
|
|
389
389
|
gender: text('gender').notNull(), // Gender of the user or chosen archetype
|
|
390
390
|
archetypeIndex: text('archetype_index').notNull(), // Chosen archetype for the artifact
|
|
391
|
-
archetypeDataId: text('archetype_data_id')
|
|
392
|
-
|
|
391
|
+
archetypeDataId: text('archetype_data_id').references(
|
|
392
|
+
() => archetypesData.id,
|
|
393
|
+
{ onDelete: 'cascade' }
|
|
394
|
+
), // New: References archetypesData.id, nullable
|
|
393
395
|
postImageId: text('post_image_id'), // URL for the Instagram post image
|
|
394
396
|
reelImageId: text('reel_image_id'), // URL for the Instagram reels/TikTok image
|
|
395
397
|
postImageUrl: text('post_image_url'), // URL for the Instagram post image
|
|
@@ -437,6 +439,18 @@ export const archetypesData = sqliteTable(
|
|
|
437
439
|
]
|
|
438
440
|
);
|
|
439
441
|
|
|
442
|
+
export const archetypeNameDumps = sqliteTable(
|
|
443
|
+
'archetype_name_dumps',
|
|
444
|
+
{
|
|
445
|
+
id: text('id').primaryKey(), // combination
|
|
446
|
+
combination: text('combination').notNull(),
|
|
447
|
+
rawText: text('raw_text').notNull(),
|
|
448
|
+
parsedSuccessfully: integer('parsed_successfully').default(0),
|
|
449
|
+
createdAt: integer('created_at').default(sql`CURRENT_TIMESTAMP`),
|
|
450
|
+
},
|
|
451
|
+
() => []
|
|
452
|
+
);
|
|
453
|
+
|
|
440
454
|
export const generations = sqliteTable(
|
|
441
455
|
'generations',
|
|
442
456
|
{
|
package/package.json
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { and, eq } from 'drizzle-orm';
|
|
2
|
+
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
3
|
+
import { schema } from '..';
|
|
4
|
+
|
|
5
|
+
export async function isEnglishNameDuplicate(
|
|
6
|
+
name: string,
|
|
7
|
+
db: DrizzleD1Database
|
|
8
|
+
): Promise<boolean> {
|
|
9
|
+
const result = await db
|
|
10
|
+
.select({ name: schema.archetypesData.name })
|
|
11
|
+
.from(schema.archetypesData)
|
|
12
|
+
.where(
|
|
13
|
+
and(
|
|
14
|
+
eq(schema.archetypesData.language, 'en-us'),
|
|
15
|
+
eq(schema.archetypesData.name, name)
|
|
16
|
+
)
|
|
17
|
+
)
|
|
18
|
+
.limit(1)
|
|
19
|
+
.execute();
|
|
20
|
+
|
|
21
|
+
return result.length > 0;
|
|
22
|
+
}
|