@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
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
.
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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
|
-
|
|
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
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
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
|
|
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
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
.
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
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(
|
|
109
|
+
await this.archetypeService.generateArchetypeNamesBatch(
|
|
110
|
+
entries,
|
|
111
|
+
overrideExisting
|
|
112
|
+
);
|
|
114
113
|
}
|
|
115
114
|
}
|
|
116
115
|
|