@zodic/shared 0.0.295 → 0.0.296

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.
@@ -287,7 +287,6 @@ export class ArchetypeService {
287
287
 
288
288
  async generateArchetypeNames(
289
289
  combination: string,
290
- gender: 'male' | 'female' | 'non-binary',
291
290
  overrideExisting: boolean = false
292
291
  ) {
293
292
  const [sun, ascendant, moon] = combination.split('-') as ZodiacSignSlug[];
@@ -340,76 +339,78 @@ export class ArchetypeService {
340
339
  await Promise.all(
341
340
  englishNames.map(async (entry, i) => {
342
341
  const index = (i + 1).toString();
343
- const existingEntry = await db
344
- .select({ id: schema.archetypesData.id })
345
- .from(schema.archetypesData)
346
- .where(
347
- eq(schema.archetypesData.id, `${combination}:${gender}:${index}`)
348
- )
349
- .execute();
350
-
351
- if (overrideExisting || existingEntry.length === 0) {
352
- await db
353
- .insert(schema.archetypesData)
354
- .values({
355
- id: `${combination}:${gender}:${index}`,
356
- combination,
357
- gender,
358
- archetypeIndex: index,
359
- language: 'en-us',
360
- name: entry.name,
361
- essenceLine: entry.essenceLine,
362
- status: 'idle',
363
- })
364
- .onConflictDoUpdate({
365
- target: [schema.archetypesData.id],
366
- set: {
342
+ const ptVariant = portugueseVariants[i];
343
+
344
+ for (const gender of ['male', 'female']) {
345
+ const enId = `${combination}:${gender}:${index}`;
346
+ const ptId = `${combination}:${gender}:${index}:pt`;
347
+
348
+ const existingEn = await db
349
+ .select({ id: schema.archetypesData.id })
350
+ .from(schema.archetypesData)
351
+ .where(eq(schema.archetypesData.id, enId))
352
+ .execute();
353
+
354
+ if (overrideExisting || existingEn.length === 0) {
355
+ await db
356
+ .insert(schema.archetypesData)
357
+ .values({
358
+ id: enId,
359
+ combination,
360
+ gender,
361
+ archetypeIndex: index,
362
+ language: 'en-us',
367
363
  name: entry.name,
368
364
  essenceLine: entry.essenceLine,
369
- updatedAt: new Date().getTime(),
370
- },
371
- });
372
- }
365
+ status: 'idle',
366
+ })
367
+ .onConflictDoUpdate({
368
+ target: [schema.archetypesData.id],
369
+ set: {
370
+ name: entry.name,
371
+ essenceLine: entry.essenceLine,
372
+ updatedAt: new Date().getTime(),
373
+ },
374
+ });
375
+ }
373
376
 
374
- const existingEntryPt = await db
375
- .select({ id: schema.archetypesData.id })
376
- .from(schema.archetypesData)
377
- .where(
378
- eq(schema.archetypesData.id, `${combination}:${gender}:${index}:pt`)
379
- )
380
- .execute();
381
-
382
- if (overrideExisting || existingEntryPt.length === 0) {
383
- await db
384
- .insert(schema.archetypesData)
385
- .values({
386
- id: `${combination}:${gender}:${index}:pt`,
387
- combination,
388
- gender,
389
- archetypeIndex: index,
390
- language: 'pt-br',
391
- name: portugueseVariants[i].masc,
392
- essenceLine: portugueseVariants[i].essenceLine,
393
- status: 'idle',
394
- })
395
- .onConflictDoUpdate({
396
- target: [schema.archetypesData.id],
397
- set: {
398
- name: portugueseVariants[i].masc,
399
- essenceLine: portugueseVariants[i].essenceLine,
400
- updatedAt: new Date().getTime(),
401
- },
402
- });
377
+ const ptName = gender === 'female' ? ptVariant.fem : ptVariant.masc;
378
+
379
+ const existingPt = await db
380
+ .select({ id: schema.archetypesData.id })
381
+ .from(schema.archetypesData)
382
+ .where(eq(schema.archetypesData.id, ptId))
383
+ .execute();
384
+
385
+ if (overrideExisting || existingPt.length === 0) {
386
+ await db
387
+ .insert(schema.archetypesData)
388
+ .values({
389
+ id: ptId,
390
+ combination,
391
+ gender,
392
+ archetypeIndex: index,
393
+ language: 'pt-br',
394
+ name: ptName,
395
+ essenceLine: ptVariant.essenceLine,
396
+ status: 'idle',
397
+ })
398
+ .onConflictDoUpdate({
399
+ target: [schema.archetypesData.id],
400
+ set: {
401
+ name: ptName,
402
+ essenceLine: ptVariant.essenceLine,
403
+ updatedAt: new Date().getTime(),
404
+ },
405
+ });
406
+ }
403
407
  }
404
408
  })
405
409
  );
406
410
  }
407
411
 
408
412
  async generateArchetypeNamesBatch(
409
- entries: Array<{
410
- combination: string;
411
- gender: 'male' | 'female' | 'non-binary';
412
- }>,
413
+ entries: Array<{ combination: string }>,
413
414
  overrideExisting: boolean = false
414
415
  ) {
415
416
  const prompts = entries.map(({ combination }) => {
@@ -421,8 +422,9 @@ export class ArchetypeService {
421
422
  const messages: ChatMessages = [{ role: 'user', content: prompt }];
422
423
  const response = await this.context.api().callTogether.single(messages, {});
423
424
 
424
- if (!response)
425
+ if (!response) {
425
426
  throw new Error('No response when generating batch archetype names');
427
+ }
426
428
 
427
429
  const db = this.context.drizzle();
428
430
 
@@ -432,7 +434,7 @@ export class ArchetypeService {
432
434
  .map((b) => b.trim());
433
435
 
434
436
  for (let i = 0; i < entries.length; i++) {
435
- const { combination, gender } = entries[i];
437
+ const { combination } = entries[i];
436
438
  const block = blocks[i];
437
439
  const en = block.split('-EN')[1].split('-PT')[0].trim();
438
440
  const pt = block.split('-PT')[1].trim();
@@ -450,72 +452,77 @@ export class ArchetypeService {
450
452
  .filter(Boolean)
451
453
  .map((line) => ({
452
454
  masc: line.match(/• Masculino:\s*(.+)/)?.[1]?.trim() || '',
455
+ fem: line.match(/• Feminino:\s*(.+)/)?.[1]?.trim() || '',
453
456
  essenceLine: line.match(/• Essência:\s*(.+)/)?.[1]?.trim() || '',
454
457
  }));
455
458
 
456
459
  for (let j = 0; j < 3; j++) {
457
460
  const index = (j + 1).toString();
461
+ const englishEntry = english[j];
462
+ const ptEntry = portuguese[j];
463
+
464
+ for (const gender of ['male', 'female']) {
465
+ const enId = `${combination}:${gender}:${index}`;
466
+ const ptId = `${combination}:${gender}:${index}:pt`;
467
+ const ptName = gender === 'female' ? ptEntry.fem : ptEntry.masc;
468
+
469
+ const existingEn = await db
470
+ .select({ id: schema.archetypesData.id })
471
+ .from(schema.archetypesData)
472
+ .where(eq(schema.archetypesData.id, enId))
473
+ .execute();
474
+
475
+ if (overrideExisting || existingEn.length === 0) {
476
+ await db
477
+ .insert(schema.archetypesData)
478
+ .values({
479
+ id: enId,
480
+ combination,
481
+ gender,
482
+ archetypeIndex: index,
483
+ language: 'en-us',
484
+ name: englishEntry.name,
485
+ essenceLine: englishEntry.essenceLine,
486
+ status: 'idle',
487
+ })
488
+ .onConflictDoUpdate({
489
+ target: [schema.archetypesData.id],
490
+ set: {
491
+ name: englishEntry.name,
492
+ essenceLine: englishEntry.essenceLine,
493
+ updatedAt: new Date().getTime(),
494
+ },
495
+ });
496
+ }
458
497
 
459
- const existingEntry = await db
460
- .select({ id: schema.archetypesData.id })
461
- .from(schema.archetypesData)
462
- .where(
463
- eq(schema.archetypesData.id, `${combination}:${gender}:${index}`)
464
- )
465
- .execute();
466
-
467
- if (overrideExisting || existingEntry.length === 0) {
468
- await db
469
- .insert(schema.archetypesData)
470
- .values({
471
- id: `${combination}:${gender}:${index}`,
472
- combination,
473
- gender,
474
- archetypeIndex: index,
475
- language: 'en-us',
476
- name: english[j].name,
477
- essenceLine: english[j].essenceLine,
478
- status: 'idle',
479
- })
480
- .onConflictDoUpdate({
481
- target: [schema.archetypesData.id],
482
- set: {
483
- name: english[j].name,
484
- essenceLine: english[j].essenceLine,
485
- updatedAt: new Date().getTime(),
486
- },
487
- });
488
- }
489
-
490
- const existingEntryPt = await db
491
- .select({ id: schema.archetypesData.id })
492
- .from(schema.archetypesData)
493
- .where(
494
- eq(schema.archetypesData.id, `${combination}:${gender}:${index}:pt`)
495
- )
496
- .execute();
497
-
498
- if (overrideExisting || existingEntryPt.length === 0) {
499
- await db
500
- .insert(schema.archetypesData)
501
- .values({
502
- id: `${combination}:${gender}:${index}:pt`,
503
- combination,
504
- gender,
505
- archetypeIndex: index,
506
- language: 'pt-br',
507
- name: portuguese[j].masc,
508
- essenceLine: portuguese[j].essenceLine,
509
- status: 'idle',
510
- })
511
- .onConflictDoUpdate({
512
- target: [schema.archetypesData.id],
513
- set: {
514
- name: portuguese[j].masc,
515
- essenceLine: portuguese[j].essenceLine,
516
- updatedAt: new Date().getTime(),
517
- },
518
- });
498
+ const existingPt = await db
499
+ .select({ id: schema.archetypesData.id })
500
+ .from(schema.archetypesData)
501
+ .where(eq(schema.archetypesData.id, ptId))
502
+ .execute();
503
+
504
+ if (overrideExisting || existingPt.length === 0) {
505
+ await db
506
+ .insert(schema.archetypesData)
507
+ .values({
508
+ id: ptId,
509
+ combination,
510
+ gender,
511
+ archetypeIndex: index,
512
+ language: 'pt-br',
513
+ name: ptName,
514
+ essenceLine: ptEntry.essenceLine,
515
+ status: 'idle',
516
+ })
517
+ .onConflictDoUpdate({
518
+ target: [schema.archetypesData.id],
519
+ set: {
520
+ name: ptName,
521
+ essenceLine: ptEntry.essenceLine,
522
+ updatedAt: new Date().getTime(),
523
+ },
524
+ });
525
+ }
519
526
  }
520
527
  }
521
528
  }
@@ -89,11 +89,9 @@ export class ArchetypeWorkflow {
89
89
 
90
90
  async generateNames({
91
91
  combinations,
92
- gender,
93
92
  overrideExisting,
94
93
  }: {
95
94
  combinations: string[];
96
- gender: Gender;
97
95
  overrideExisting?: boolean;
98
96
  }): Promise<void> {
99
97
  if (combinations.length === 0) return;
@@ -101,16 +99,17 @@ export class ArchetypeWorkflow {
101
99
  if (combinations.length === 1) {
102
100
  await this.archetypeService.generateArchetypeNames(
103
101
  combinations[0],
104
- gender,
105
102
  overrideExisting
106
103
  );
107
104
  } else {
108
105
  const entries = combinations.map((combination) => ({
109
106
  combination,
110
- gender,
111
107
  }));
112
108
 
113
- await this.archetypeService.generateArchetypeNamesBatch(entries, overrideExisting);
109
+ await this.archetypeService.generateArchetypeNamesBatch(
110
+ entries,
111
+ overrideExisting
112
+ );
114
113
  }
115
114
  }
116
115
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zodic/shared",
3
- "version": "0.0.295",
3
+ "version": "0.0.296",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "publishConfig": {