@wrcb/cb-common 1.0.910 → 1.0.912
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/build/helpers/ageFromBirthDate.d.ts +6 -0
- package/build/helpers/ageFromBirthDate.js +22 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/types/influencerBook.d.ts +5 -1
- package/build/types/mediaGen.d.ts +3 -1
- package/build/types/mediaGen.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Idade completa em anos na data `now`. Aceita Date ou string ISO (YYYY-MM-DD
|
|
3
|
+
* ou data-hora). Devolve `null` se a data não existir ou for inválida.
|
|
4
|
+
* Usa UTC para a data de nascimento não "andar um dia" conforme o fuso.
|
|
5
|
+
*/
|
|
6
|
+
export declare function ageFromBirthDate(birthDate: Date | string | null | undefined, now?: Date): number | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ageFromBirthDate = ageFromBirthDate;
|
|
4
|
+
/**
|
|
5
|
+
* Idade completa em anos na data `now`. Aceita Date ou string ISO (YYYY-MM-DD
|
|
6
|
+
* ou data-hora). Devolve `null` se a data não existir ou for inválida.
|
|
7
|
+
* Usa UTC para a data de nascimento não "andar um dia" conforme o fuso.
|
|
8
|
+
*/
|
|
9
|
+
function ageFromBirthDate(birthDate, now = new Date()) {
|
|
10
|
+
if (!birthDate)
|
|
11
|
+
return null;
|
|
12
|
+
const birth = birthDate instanceof Date ? birthDate : new Date(birthDate);
|
|
13
|
+
if (Number.isNaN(birth.getTime()))
|
|
14
|
+
return null;
|
|
15
|
+
let age = now.getUTCFullYear() - birth.getUTCFullYear();
|
|
16
|
+
const beforeBirthday = now.getUTCMonth() < birth.getUTCMonth() ||
|
|
17
|
+
(now.getUTCMonth() === birth.getUTCMonth() &&
|
|
18
|
+
now.getUTCDate() < birth.getUTCDate());
|
|
19
|
+
if (beforeBirthday)
|
|
20
|
+
age -= 1;
|
|
21
|
+
return age < 0 ? null : age;
|
|
22
|
+
}
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -106,3 +106,4 @@ __exportStar(require("./services/CurrencyService"), exports);
|
|
|
106
106
|
// notas-br — tabela de billing compartilhada entre gn-business e cb-payments
|
|
107
107
|
__exportStar(require("./config/notasBrBilling"), exports);
|
|
108
108
|
__exportStar(require("./helpers/calculateBonus"), exports);
|
|
109
|
+
__exportStar(require("./helpers/ageFromBirthDate"), exports);
|
|
@@ -28,14 +28,18 @@ export interface InfluencerProfileDTO {
|
|
|
28
28
|
userId: string;
|
|
29
29
|
/** Descrição física que vale para TODAS as imagens dela. */
|
|
30
30
|
visualPrompt: string;
|
|
31
|
+
/** Calculada da data de nascimento quando ela existe; senão, o valor guardado. */
|
|
31
32
|
age: number;
|
|
33
|
+
/** Data de nascimento (ISO) usada para calcular a idade; `null` se ainda não informada. */
|
|
34
|
+
birthDate: string | null;
|
|
32
35
|
referencePrompt: string;
|
|
33
36
|
references: InfluencerReferenceSheetDTO[];
|
|
34
37
|
loraStatus: InfluencerLoraStatus;
|
|
35
38
|
}
|
|
36
39
|
export interface UpsertInfluencerProfileBody {
|
|
37
40
|
visualPrompt: string;
|
|
38
|
-
|
|
41
|
+
/** Data de nascimento (YYYY-MM-DD). A idade é sempre calculada a partir dela. */
|
|
42
|
+
birthDate?: string | null;
|
|
39
43
|
}
|
|
40
44
|
export interface GenerateInfluencerReferenceBody {
|
|
41
45
|
/** Se vier, substitui o prompt de referência guardado. */
|
|
@@ -2,7 +2,9 @@ export declare enum MediaProviderName {
|
|
|
2
2
|
/** GPU alugada sob demanda no Vast.ai. */
|
|
3
3
|
VastAi = "vastai",
|
|
4
4
|
/** API paga por imagem da Runware. */
|
|
5
|
-
Runware = "runware"
|
|
5
|
+
Runware = "runware",
|
|
6
|
+
/** API paga por uso da fal.ai (imagem, vídeo e treino de LoRA). */
|
|
7
|
+
Fal = "fal"
|
|
6
8
|
}
|
|
7
9
|
export declare enum MediaJobKind {
|
|
8
10
|
Image = "image",
|
package/build/types/mediaGen.js
CHANGED
|
@@ -10,6 +10,8 @@ var MediaProviderName;
|
|
|
10
10
|
MediaProviderName["VastAi"] = "vastai";
|
|
11
11
|
/** API paga por imagem da Runware. */
|
|
12
12
|
MediaProviderName["Runware"] = "runware";
|
|
13
|
+
/** API paga por uso da fal.ai (imagem, vídeo e treino de LoRA). */
|
|
14
|
+
MediaProviderName["Fal"] = "fal";
|
|
13
15
|
})(MediaProviderName || (exports.MediaProviderName = MediaProviderName = {}));
|
|
14
16
|
var MediaJobKind;
|
|
15
17
|
(function (MediaJobKind) {
|