@genfeedai/helpers 2.2.2
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/dist/aspect-ratio.helper.d.ts +18 -0
- package/dist/aspect-ratio.helper.d.ts.map +1 -0
- package/dist/aspect-ratio.helper.js +116 -0
- package/dist/aspect-ratio.helper.js.map +1 -0
- package/dist/business/pricing/pricing.helper.d.ts +231 -0
- package/dist/business/pricing/pricing.helper.d.ts.map +1 -0
- package/dist/business/pricing/pricing.helper.js +443 -0
- package/dist/business/pricing/pricing.helper.js.map +1 -0
- package/dist/business/tier-models/tier-models.helper.d.ts +16 -0
- package/dist/business/tier-models/tier-models.helper.d.ts.map +1 -0
- package/dist/business/tier-models/tier-models.helper.js +42 -0
- package/dist/business/tier-models/tier-models.helper.js.map +1 -0
- package/dist/deserializer.helper.d.ts +2 -0
- package/dist/deserializer.helper.d.ts.map +1 -0
- package/dist/deserializer.helper.js +3 -0
- package/dist/deserializer.helper.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/model-capability.helper.d.ts +17 -0
- package/dist/model-capability.helper.d.ts.map +1 -0
- package/dist/model-capability.helper.js +184 -0
- package/dist/model-capability.helper.js.map +1 -0
- package/dist/quality-routing.helper.d.ts +29 -0
- package/dist/quality-routing.helper.d.ts.map +1 -0
- package/dist/quality-routing.helper.js +216 -0
- package/dist/quality-routing.helper.js.map +1 -0
- package/dist/serializer.helper.d.ts +25 -0
- package/dist/serializer.helper.d.ts.map +1 -0
- package/dist/serializer.helper.js +46 -0
- package/dist/serializer.helper.js.map +1 -0
- package/dist/social-url.helper.d.ts +8 -0
- package/dist/social-url.helper.d.ts.map +1 -0
- package/dist/social-url.helper.js +50 -0
- package/dist/social-url.helper.js.map +1 -0
- package/dist/types/model-like.type.d.ts +32 -0
- package/dist/types/model-like.type.d.ts.map +1 -0
- package/dist/types/model-like.type.js +3 -0
- package/dist/types/model-like.type.js.map +1 -0
- package/dist/video-duration.helper.d.ts +9 -0
- package/dist/video-duration.helper.d.ts.map +1 -0
- package/dist/video-duration.helper.js +43 -0
- package/dist/video-duration.helper.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { MODEL_OUTPUT_CAPABILITIES, } from '@genfeedai/constants';
|
|
2
|
+
import { ModelCategory } from '@genfeedai/enums';
|
|
3
|
+
const DEFAULT_MAX_OUTPUTS = 4;
|
|
4
|
+
const DEFAULT_MAX_REFERENCES = 1;
|
|
5
|
+
function buildBaseFields(model) {
|
|
6
|
+
return {
|
|
7
|
+
isBatchSupported: model.isBatchSupported ?? false,
|
|
8
|
+
maxOutputs: model.maxOutputs ?? DEFAULT_MAX_OUTPUTS,
|
|
9
|
+
maxReferences: model.maxReferences ?? DEFAULT_MAX_REFERENCES,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function buildImageCapability(model) {
|
|
13
|
+
return {
|
|
14
|
+
...buildBaseFields(model),
|
|
15
|
+
category: ModelCategory.IMAGE,
|
|
16
|
+
...(model.isReferencesMandatory != null && {
|
|
17
|
+
isReferencesMandatory: model.isReferencesMandatory,
|
|
18
|
+
}),
|
|
19
|
+
...(model.isImagenModel != null && {
|
|
20
|
+
isImagenModel: model.isImagenModel,
|
|
21
|
+
}),
|
|
22
|
+
...(model.aspectRatios != null && { aspectRatios: model.aspectRatios }),
|
|
23
|
+
...(model.defaultAspectRatio != null && {
|
|
24
|
+
defaultAspectRatio: model.defaultAspectRatio,
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function buildVideoCapability(model) {
|
|
29
|
+
return {
|
|
30
|
+
...buildBaseFields(model),
|
|
31
|
+
category: ModelCategory.VIDEO,
|
|
32
|
+
...(model.hasEndFrame != null && { hasEndFrame: model.hasEndFrame }),
|
|
33
|
+
...(model.hasInterpolation != null && {
|
|
34
|
+
hasInterpolation: model.hasInterpolation,
|
|
35
|
+
}),
|
|
36
|
+
...(model.hasSpeech != null && { hasSpeech: model.hasSpeech }),
|
|
37
|
+
...(model.hasAudioToggle != null && {
|
|
38
|
+
hasAudioToggle: model.hasAudioToggle,
|
|
39
|
+
}),
|
|
40
|
+
...(model.hasDurationEditing != null && {
|
|
41
|
+
hasDurationEditing: model.hasDurationEditing,
|
|
42
|
+
}),
|
|
43
|
+
...(model.hasResolutionOptions != null && {
|
|
44
|
+
hasResolutionOptions: model.hasResolutionOptions,
|
|
45
|
+
}),
|
|
46
|
+
...(model.aspectRatios != null && { aspectRatios: model.aspectRatios }),
|
|
47
|
+
...(model.defaultAspectRatio != null && {
|
|
48
|
+
defaultAspectRatio: model.defaultAspectRatio,
|
|
49
|
+
}),
|
|
50
|
+
...(model.usesOrientation != null && {
|
|
51
|
+
usesOrientation: model.usesOrientation,
|
|
52
|
+
}),
|
|
53
|
+
...(model.durations != null && { durations: model.durations }),
|
|
54
|
+
...(model.defaultDuration != null && {
|
|
55
|
+
defaultDuration: model.defaultDuration,
|
|
56
|
+
}),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function buildImageEditCapability(model) {
|
|
60
|
+
return {
|
|
61
|
+
...buildBaseFields(model),
|
|
62
|
+
category: ModelCategory.IMAGE_EDIT,
|
|
63
|
+
...(model.aspectRatios != null && { aspectRatios: model.aspectRatios }),
|
|
64
|
+
...(model.defaultAspectRatio != null && {
|
|
65
|
+
defaultAspectRatio: model.defaultAspectRatio,
|
|
66
|
+
}),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function buildVideoEditCapability(model) {
|
|
70
|
+
return {
|
|
71
|
+
...buildBaseFields(model),
|
|
72
|
+
category: ModelCategory.VIDEO_EDIT,
|
|
73
|
+
...(model.hasDurationEditing != null && {
|
|
74
|
+
hasDurationEditing: model.hasDurationEditing,
|
|
75
|
+
}),
|
|
76
|
+
...(model.aspectRatios != null && { aspectRatios: model.aspectRatios }),
|
|
77
|
+
...(model.defaultAspectRatio != null && {
|
|
78
|
+
defaultAspectRatio: model.defaultAspectRatio,
|
|
79
|
+
}),
|
|
80
|
+
...(model.durations != null && { durations: model.durations }),
|
|
81
|
+
...(model.defaultDuration != null && {
|
|
82
|
+
defaultDuration: model.defaultDuration,
|
|
83
|
+
}),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function buildMusicCapability(model) {
|
|
87
|
+
return {
|
|
88
|
+
...buildBaseFields(model),
|
|
89
|
+
category: ModelCategory.MUSIC,
|
|
90
|
+
...(model.hasDurationEditing != null && {
|
|
91
|
+
hasDurationEditing: model.hasDurationEditing,
|
|
92
|
+
}),
|
|
93
|
+
...(model.durations != null && { durations: model.durations }),
|
|
94
|
+
...(model.defaultDuration != null && {
|
|
95
|
+
defaultDuration: model.defaultDuration,
|
|
96
|
+
}),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function buildVoiceCapability(model) {
|
|
100
|
+
return {
|
|
101
|
+
...buildBaseFields(model),
|
|
102
|
+
category: ModelCategory.VOICE,
|
|
103
|
+
...(model.hasDurationEditing != null && {
|
|
104
|
+
hasDurationEditing: model.hasDurationEditing,
|
|
105
|
+
}),
|
|
106
|
+
...(model.aspectRatios != null && { aspectRatios: model.aspectRatios }),
|
|
107
|
+
...(model.defaultAspectRatio != null && {
|
|
108
|
+
defaultAspectRatio: model.defaultAspectRatio,
|
|
109
|
+
}),
|
|
110
|
+
...(model.durations != null && { durations: model.durations }),
|
|
111
|
+
...(model.defaultDuration != null && {
|
|
112
|
+
defaultDuration: model.defaultDuration,
|
|
113
|
+
}),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function buildTextCapability(model) {
|
|
117
|
+
return {
|
|
118
|
+
...buildBaseFields(model),
|
|
119
|
+
category: ModelCategory.TEXT,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function buildEmbeddingCapability(model) {
|
|
123
|
+
return {
|
|
124
|
+
...buildBaseFields(model),
|
|
125
|
+
category: ModelCategory.EMBEDDING,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function buildImageUpscaleCapability(model) {
|
|
129
|
+
return {
|
|
130
|
+
...buildBaseFields(model),
|
|
131
|
+
category: ModelCategory.IMAGE_UPSCALE,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function buildVideoUpscaleCapability(model) {
|
|
135
|
+
return {
|
|
136
|
+
...buildBaseFields(model),
|
|
137
|
+
category: ModelCategory.VIDEO_UPSCALE,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
const CATEGORY_BUILDERS = {
|
|
141
|
+
[ModelCategory.IMAGE]: buildImageCapability,
|
|
142
|
+
[ModelCategory.VIDEO]: buildVideoCapability,
|
|
143
|
+
[ModelCategory.IMAGE_EDIT]: buildImageEditCapability,
|
|
144
|
+
[ModelCategory.VIDEO_EDIT]: buildVideoEditCapability,
|
|
145
|
+
[ModelCategory.MUSIC]: buildMusicCapability,
|
|
146
|
+
[ModelCategory.VOICE]: buildVoiceCapability,
|
|
147
|
+
[ModelCategory.TEXT]: buildTextCapability,
|
|
148
|
+
[ModelCategory.EMBEDDING]: buildEmbeddingCapability,
|
|
149
|
+
[ModelCategory.IMAGE_UPSCALE]: buildImageUpscaleCapability,
|
|
150
|
+
[ModelCategory.VIDEO_UPSCALE]: buildVideoUpscaleCapability,
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Build a ModelOutputCapability from DB fields on the IModel document.
|
|
154
|
+
* Returns null if the model has no capability fields populated (maxOutputs is undefined).
|
|
155
|
+
*/
|
|
156
|
+
export function getModelCapabilityFromDoc(model) {
|
|
157
|
+
if (model.maxOutputs == null) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
const builder = CATEGORY_BUILDERS[model.category];
|
|
161
|
+
if (!builder) {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
return builder(model);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Get capability from DB fields first, falling back to the static constant.
|
|
168
|
+
*/
|
|
169
|
+
export function getModelCapability(model) {
|
|
170
|
+
return (getModelCapabilityFromDoc(model) ??
|
|
171
|
+
MODEL_OUTPUT_CAPABILITIES[model.key] ??
|
|
172
|
+
null);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Get capability by model key string. If an IModel document is provided,
|
|
176
|
+
* uses DB fields with constant fallback. Otherwise looks up the static constant only.
|
|
177
|
+
*/
|
|
178
|
+
export function getModelCapabilityByKey(modelKey, model) {
|
|
179
|
+
if (model) {
|
|
180
|
+
return getModelCapability(model);
|
|
181
|
+
}
|
|
182
|
+
return MODEL_OUTPUT_CAPABILITIES[modelKey] ?? null;
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=model-capability.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-capability.helper.js","sourceRoot":"","sources":["../src/model-capability.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,yBAAyB,GAQ1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAiB,MAAM,kBAAkB,CAAC;AAGhE,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAC9B,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAEjC,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO;QACL,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,IAAI,KAAK;QACjD,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,mBAAmB;QACnD,aAAa,EAAE,KAAK,CAAC,aAAa,IAAI,sBAAsB;KAC7D,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAa;IACzC,OAAO;QACL,GAAG,eAAe,CAAC,KAAK,CAAC;QACzB,QAAQ,EAAE,aAAa,CAAC,KAAK;QAC7B,GAAG,CAAC,KAAK,CAAC,qBAAqB,IAAI,IAAI,IAAI;YACzC,qBAAqB,EAAE,KAAK,C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UAAU,yBAAyB,CACvC,KAAa;IAEb,IAAI,KAAK,CAAC,UAAU,IAAI,IAAI,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,iBAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAElD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,KAAa;IAEb,OAAO,CACL,yBAAyB,CAAC,KAAK,CAAC;QAChC,yBAAyB,CAAC,KAAK,CAAC,GAAG,CAAC;QACpC,IAAI,CACL,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,QAAgB,EAChB,KAAc;IAEd,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,yBAAyB,CAAC,QAAoB,CAAC,IAAI,IAAI,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type IngredientFormat, ModelCategory, ModelKey, QualityTier } from '@genfeedai/enums';
|
|
2
|
+
import type { IModel } from '@genfeedai/interfaces';
|
|
3
|
+
export interface QualityTierOption {
|
|
4
|
+
value: QualityTier;
|
|
5
|
+
label: string;
|
|
6
|
+
description: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const QUALITY_TIER_OPTIONS: QualityTierOption[];
|
|
9
|
+
export declare const DEFAULT_QUALITY_TIER = QualityTier.HIGH;
|
|
10
|
+
export declare const IMAGE_QUALITY_MODELS: Record<QualityTier, ModelKey[]>;
|
|
11
|
+
export declare const VIDEO_QUALITY_MODELS: Record<QualityTier, ModelKey[]>;
|
|
12
|
+
export declare const MUSIC_QUALITY_MODELS: Record<QualityTier, ModelKey[]>;
|
|
13
|
+
export declare const CATEGORY_QUALITY_MODELS: Partial<Record<ModelCategory, Record<QualityTier, ModelKey[]>>>;
|
|
14
|
+
export declare function resolveQualityToModel(quality: QualityTier, category: ModelCategory, format: IngredientFormat | string, availableModelKeys: string[]): ModelKey | null;
|
|
15
|
+
export declare function getQualityTierForModel(modelKey: string, category: ModelCategory): QualityTier;
|
|
16
|
+
export declare function getQualityTierLabel(quality: QualityTier): string;
|
|
17
|
+
export declare function isQualityTierSupportedForCategory(category: ModelCategory): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Resolve quality tier to a model using model documents from the database.
|
|
20
|
+
* Models are filtered by category, quality tier, format compatibility, and active status.
|
|
21
|
+
* Falls back to lower tiers if the requested tier has no compatible models.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveQualityToModelFromDb(quality: QualityTier, category: ModelCategory, format: IngredientFormat | string, models: IModel[]): IModel | null;
|
|
24
|
+
/**
|
|
25
|
+
* Get the quality tier for a model from its DB document.
|
|
26
|
+
* Falls back to DEFAULT_QUALITY_TIER if not set.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getQualityTierFromModel(model: IModel): QualityTier;
|
|
29
|
+
//# sourceMappingURL=quality-routing.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quality-routing.helper.d.ts","sourceRoot":"","sources":["../src/quality-routing.helper.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,gBAAgB,EACrB,aAAa,EACb,QAAQ,EACR,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAKpD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,WAAW,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,oBAAoB,EAAE,iBAAiB,EAgBnD,CAAC;AAEF,eAAO,MAAM,oBAAoB,mBAAmB,CAAC;AAErD,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,WAAW,EAAE,QAAQ,EAAE,CA6BhE,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,WAAW,EAAE,QAAQ,EAAE,CAyBhE,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,WAAW,EAAE,QAAQ,EAAE,CAKhE,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,OAAO,CAC3C,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,WAAW,EAAE,QAAQ,EAAE,CAAC,CAAC,CAKvD,CAAC;AAyBF,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,aAAa,EACvB,MAAM,EAAE,gBAAgB,GAAG,MAAM,EACjC,kBAAkB,EAAE,MAAM,EAAE,GAC3B,QAAQ,GAAG,IAAI,CAoDjB;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,aAAa,GACtB,WAAW,CAqBb;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAGhE;AAQD,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,aAAa,GACtB,OAAO,CAET;AAcD;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,aAAa,EACvB,MAAM,EAAE,gBAAgB,GAAG,MAAM,EACjC,MAAM,EAAE,MAAM,EAAE,GACf,MAAM,GAAG,IAAI,CAqCf;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAElE"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { MODEL_OUTPUT_CAPABILITIES } from '@genfeedai/constants';
|
|
2
|
+
import { ModelCategory, ModelKey, QualityTier, } from '@genfeedai/enums';
|
|
3
|
+
import { isAspectRatioSupported } from '@helpers/aspect-ratio.helper';
|
|
4
|
+
import { getModelCapability } from '@helpers/model-capability.helper';
|
|
5
|
+
export const QUALITY_TIER_OPTIONS = [
|
|
6
|
+
{
|
|
7
|
+
description: 'Fast & affordable',
|
|
8
|
+
label: 'Standard',
|
|
9
|
+
value: QualityTier.STANDARD,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
description: 'Best balance',
|
|
13
|
+
label: 'Premium',
|
|
14
|
+
value: QualityTier.HIGH,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
description: 'Maximum quality',
|
|
18
|
+
label: 'Ultra',
|
|
19
|
+
value: QualityTier.ULTRA,
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
export const DEFAULT_QUALITY_TIER = QualityTier.HIGH;
|
|
23
|
+
export const IMAGE_QUALITY_MODELS = {
|
|
24
|
+
[QualityTier.BASIC]: [
|
|
25
|
+
ModelKey.REPLICATE_IDEOGRAM_AI_IDEOGRAM_V3_TURBO,
|
|
26
|
+
ModelKey.REPLICATE_BLACK_FOREST_LABS_FLUX_SCHNELL,
|
|
27
|
+
ModelKey.REPLICATE_GOOGLE_IMAGEN_3_FAST,
|
|
28
|
+
ModelKey.REPLICATE_GOOGLE_IMAGEN_4_FAST,
|
|
29
|
+
ModelKey.REPLICATE_BLACK_FOREST_LABS_FLUX_1_1_PRO,
|
|
30
|
+
],
|
|
31
|
+
[QualityTier.STANDARD]: [
|
|
32
|
+
ModelKey.REPLICATE_IDEOGRAM_AI_IDEOGRAM_V3_TURBO,
|
|
33
|
+
ModelKey.REPLICATE_BLACK_FOREST_LABS_FLUX_SCHNELL,
|
|
34
|
+
ModelKey.REPLICATE_GOOGLE_IMAGEN_3_FAST,
|
|
35
|
+
ModelKey.REPLICATE_GOOGLE_IMAGEN_4_FAST,
|
|
36
|
+
ModelKey.REPLICATE_BLACK_FOREST_LABS_FLUX_1_1_PRO,
|
|
37
|
+
],
|
|
38
|
+
[QualityTier.HIGH]: [
|
|
39
|
+
ModelKey.REPLICATE_IDEOGRAM_AI_IDEOGRAM_V3_BALANCED,
|
|
40
|
+
ModelKey.REPLICATE_BLACK_FOREST_LABS_FLUX_2_PRO,
|
|
41
|
+
ModelKey.REPLICATE_GOOGLE_IMAGEN_3,
|
|
42
|
+
ModelKey.REPLICATE_GOOGLE_IMAGEN_4,
|
|
43
|
+
ModelKey.REPLICATE_BYTEDANCE_SEEDREAM_4_5,
|
|
44
|
+
],
|
|
45
|
+
[QualityTier.ULTRA]: [
|
|
46
|
+
ModelKey.REPLICATE_IDEOGRAM_AI_IDEOGRAM_V3_QUALITY,
|
|
47
|
+
ModelKey.REPLICATE_GOOGLE_IMAGEN_4_ULTRA,
|
|
48
|
+
ModelKey.REPLICATE_OPENAI_GPT_IMAGE_1_5,
|
|
49
|
+
ModelKey.REPLICATE_GOOGLE_NANO_BANANA_PRO,
|
|
50
|
+
ModelKey.REPLICATE_BLACK_FOREST_LABS_FLUX_KONTEXT_PRO,
|
|
51
|
+
],
|
|
52
|
+
};
|
|
53
|
+
export const VIDEO_QUALITY_MODELS = {
|
|
54
|
+
[QualityTier.BASIC]: [
|
|
55
|
+
ModelKey.REPLICATE_GOOGLE_VEO_3_FAST,
|
|
56
|
+
ModelKey.REPLICATE_GOOGLE_VEO_3_1_FAST,
|
|
57
|
+
ModelKey.REPLICATE_KWAIVGI_KLING_V2_5_TURBO_PRO,
|
|
58
|
+
ModelKey.REPLICATE_WAN_VIDEO_WAN_2_2_I2V_FAST,
|
|
59
|
+
],
|
|
60
|
+
[QualityTier.STANDARD]: [
|
|
61
|
+
ModelKey.REPLICATE_GOOGLE_VEO_3_FAST,
|
|
62
|
+
ModelKey.REPLICATE_GOOGLE_VEO_3_1_FAST,
|
|
63
|
+
ModelKey.REPLICATE_KWAIVGI_KLING_V2_5_TURBO_PRO,
|
|
64
|
+
ModelKey.REPLICATE_WAN_VIDEO_WAN_2_2_I2V_FAST,
|
|
65
|
+
],
|
|
66
|
+
[QualityTier.HIGH]: [
|
|
67
|
+
ModelKey.REPLICATE_GOOGLE_VEO_3,
|
|
68
|
+
ModelKey.REPLICATE_KWAIVGI_KLING_V2_1,
|
|
69
|
+
ModelKey.REPLICATE_KWAIVGI_KLING_V2_1_MASTER,
|
|
70
|
+
ModelKey.REPLICATE_OPENAI_SORA_2,
|
|
71
|
+
],
|
|
72
|
+
[QualityTier.ULTRA]: [
|
|
73
|
+
ModelKey.REPLICATE_GOOGLE_VEO_3_1,
|
|
74
|
+
ModelKey.REPLICATE_OPENAI_SORA_2_PRO,
|
|
75
|
+
ModelKey.REPLICATE_KWAIVGI_KLING_V1_6_PRO,
|
|
76
|
+
ModelKey.REPLICATE_GOOGLE_VEO_2,
|
|
77
|
+
],
|
|
78
|
+
};
|
|
79
|
+
export const MUSIC_QUALITY_MODELS = {
|
|
80
|
+
[QualityTier.BASIC]: [ModelKey.REPLICATE_META_MUSICGEN],
|
|
81
|
+
[QualityTier.STANDARD]: [ModelKey.REPLICATE_META_MUSICGEN],
|
|
82
|
+
[QualityTier.HIGH]: [ModelKey.REPLICATE_META_MUSICGEN],
|
|
83
|
+
[QualityTier.ULTRA]: [ModelKey.REPLICATE_META_MUSICGEN],
|
|
84
|
+
};
|
|
85
|
+
export const CATEGORY_QUALITY_MODELS = {
|
|
86
|
+
[ModelCategory.IMAGE]: IMAGE_QUALITY_MODELS,
|
|
87
|
+
[ModelCategory.VIDEO]: VIDEO_QUALITY_MODELS,
|
|
88
|
+
[ModelCategory.MUSIC]: MUSIC_QUALITY_MODELS,
|
|
89
|
+
};
|
|
90
|
+
function getQualityModelsForCategory(category) {
|
|
91
|
+
return CATEGORY_QUALITY_MODELS[category] ?? null;
|
|
92
|
+
}
|
|
93
|
+
const FORMAT_TO_ASPECT_RATIO = {
|
|
94
|
+
landscape: '16:9',
|
|
95
|
+
portrait: '9:16',
|
|
96
|
+
square: '1:1',
|
|
97
|
+
};
|
|
98
|
+
function formatToAspectRatio(format) {
|
|
99
|
+
return FORMAT_TO_ASPECT_RATIO[format] ?? '16:9';
|
|
100
|
+
}
|
|
101
|
+
function isModelFormatCompatible(modelKey, format) {
|
|
102
|
+
return isAspectRatioSupported(modelKey, formatToAspectRatio(format));
|
|
103
|
+
}
|
|
104
|
+
export function resolveQualityToModel(quality, category, format, availableModelKeys) {
|
|
105
|
+
const qualityModels = getQualityModelsForCategory(category);
|
|
106
|
+
if (!qualityModels) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
const tierModels = qualityModels[quality];
|
|
110
|
+
const availableSet = new Set(availableModelKeys);
|
|
111
|
+
for (const modelKey of tierModels) {
|
|
112
|
+
if (availableSet.has(modelKey) &&
|
|
113
|
+
isModelFormatCompatible(modelKey, format)) {
|
|
114
|
+
return modelKey;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const tierOrder = [
|
|
118
|
+
QualityTier.ULTRA,
|
|
119
|
+
QualityTier.HIGH,
|
|
120
|
+
QualityTier.STANDARD,
|
|
121
|
+
QualityTier.BASIC,
|
|
122
|
+
];
|
|
123
|
+
const currentTierIndex = tierOrder.indexOf(quality);
|
|
124
|
+
for (let i = currentTierIndex + 1; i < tierOrder.length; i++) {
|
|
125
|
+
const fallbackTier = tierOrder[i];
|
|
126
|
+
const fallbackModels = qualityModels[fallbackTier];
|
|
127
|
+
for (const modelKey of fallbackModels) {
|
|
128
|
+
if (availableSet.has(modelKey) &&
|
|
129
|
+
isModelFormatCompatible(modelKey, format)) {
|
|
130
|
+
return modelKey;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const categoryAvailableModels = availableModelKeys.filter((key) => {
|
|
135
|
+
const capability = MODEL_OUTPUT_CAPABILITIES[key];
|
|
136
|
+
return (capability?.category === category &&
|
|
137
|
+
isModelFormatCompatible(key, format));
|
|
138
|
+
});
|
|
139
|
+
return categoryAvailableModels.length > 0
|
|
140
|
+
? categoryAvailableModels[0]
|
|
141
|
+
: null;
|
|
142
|
+
}
|
|
143
|
+
export function getQualityTierForModel(modelKey, category) {
|
|
144
|
+
const qualityModels = getQualityModelsForCategory(category);
|
|
145
|
+
if (!qualityModels) {
|
|
146
|
+
return DEFAULT_QUALITY_TIER;
|
|
147
|
+
}
|
|
148
|
+
const tiers = [
|
|
149
|
+
QualityTier.ULTRA,
|
|
150
|
+
QualityTier.HIGH,
|
|
151
|
+
QualityTier.STANDARD,
|
|
152
|
+
QualityTier.BASIC,
|
|
153
|
+
];
|
|
154
|
+
for (const tier of tiers) {
|
|
155
|
+
if (qualityModels[tier].includes(modelKey)) {
|
|
156
|
+
return tier;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return DEFAULT_QUALITY_TIER;
|
|
160
|
+
}
|
|
161
|
+
export function getQualityTierLabel(quality) {
|
|
162
|
+
const option = QUALITY_TIER_OPTIONS.find((o) => o.value === quality);
|
|
163
|
+
return option?.label ?? 'Premium';
|
|
164
|
+
}
|
|
165
|
+
const QUALITY_TIER_SUPPORTED_CATEGORIES = new Set([
|
|
166
|
+
ModelCategory.IMAGE,
|
|
167
|
+
ModelCategory.VIDEO,
|
|
168
|
+
ModelCategory.MUSIC,
|
|
169
|
+
]);
|
|
170
|
+
export function isQualityTierSupportedForCategory(category) {
|
|
171
|
+
return QUALITY_TIER_SUPPORTED_CATEGORIES.has(category);
|
|
172
|
+
}
|
|
173
|
+
// ============================================================================
|
|
174
|
+
// DB-backed quality resolution
|
|
175
|
+
// ============================================================================
|
|
176
|
+
function isModelFormatCompatibleFromDoc(model, format) {
|
|
177
|
+
const cap = getModelCapability(model);
|
|
178
|
+
return isAspectRatioSupported(model.key, formatToAspectRatio(format), cap);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Resolve quality tier to a model using model documents from the database.
|
|
182
|
+
* Models are filtered by category, quality tier, format compatibility, and active status.
|
|
183
|
+
* Falls back to lower tiers if the requested tier has no compatible models.
|
|
184
|
+
*/
|
|
185
|
+
export function resolveQualityToModelFromDb(quality, category, format, models) {
|
|
186
|
+
const activeModels = models.filter((m) => m.category === category && m.isActive && !m.isDeleted);
|
|
187
|
+
const tierMatch = activeModels.find((m) => m.qualityTier === quality && isModelFormatCompatibleFromDoc(m, format));
|
|
188
|
+
if (tierMatch) {
|
|
189
|
+
return tierMatch;
|
|
190
|
+
}
|
|
191
|
+
const tierOrder = [
|
|
192
|
+
QualityTier.ULTRA,
|
|
193
|
+
QualityTier.HIGH,
|
|
194
|
+
QualityTier.STANDARD,
|
|
195
|
+
QualityTier.BASIC,
|
|
196
|
+
];
|
|
197
|
+
const currentIndex = tierOrder.indexOf(quality);
|
|
198
|
+
for (let i = currentIndex + 1; i < tierOrder.length; i++) {
|
|
199
|
+
const fallbackTier = tierOrder[i];
|
|
200
|
+
const fallbackMatch = activeModels.find((m) => m.qualityTier === fallbackTier &&
|
|
201
|
+
isModelFormatCompatibleFromDoc(m, format));
|
|
202
|
+
if (fallbackMatch) {
|
|
203
|
+
return fallbackMatch;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
const anyMatch = activeModels.find((m) => isModelFormatCompatibleFromDoc(m, format));
|
|
207
|
+
return anyMatch ?? null;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Get the quality tier for a model from its DB document.
|
|
211
|
+
* Falls back to DEFAULT_QUALITY_TIER if not set.
|
|
212
|
+
*/
|
|
213
|
+
export function getQualityTierFromModel(model) {
|
|
214
|
+
return model.qualityTier ?? DEFAULT_QUALITY_TIER;
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=quality-routing.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quality-routing.helper.js","sourceRoot":"","sources":["../src/quality-routing.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAEL,aAAa,EACb,QAAQ,EACR,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;A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CAAC,WAAW,KAAK,OAAO,IAAI,8BAA8B,CAAC,CAAC,EAAE,MAAM,CAAC,CACzE,CAAC;IACF,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,SAAS,GAAkB;QAC/B,WAAW,CAAC,KAAK;QACjB,WAAW,CAAC,IAAI;QAChB,WAAW,CAAC,QAAQ;QACpB,WAAW,CAAC,KAAK;KAClB,CAAC;IACF,MAAM,YAAY,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAEhD,KAAK,IAAI,CAAC,GAAG,YAAY,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACzD,MAAM,YAAY,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,aAAa,GAAG,YAAY,CAAC,IAAI,CACrC,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,WAAW,KAAK,YAAY;YAC9B,8BAA8B,CAAC,CAAC,EAAE,MAAM,CAAC,CAC5C,CAAC;QACF,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO,aAAa,CAAC;QACvB,CAAC;IACH,CAAC;IAED,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CACvC,8BAA8B,CAAC,CAAC,EAAE,MAAM,CAAC,CAC1C,CAAC;IACF,OAAO,QAAQ,IAAI,IAAI,CAAC;AAC1B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAa;IACnD,OAAO,KAAK,CAAC,WAAW,IAAI,oBAAoB,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Serializer } from 'ts-jsonapi';
|
|
2
|
+
export declare function createEntityAttributes(customAttributes: string[]): string[];
|
|
3
|
+
export interface ISerializerConfig {
|
|
4
|
+
type: string;
|
|
5
|
+
attributes: string[];
|
|
6
|
+
relationships?: Record<string, ISerializerRelationship>;
|
|
7
|
+
where?: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
export interface ISerializerRelationship {
|
|
10
|
+
type: string;
|
|
11
|
+
ref?: string;
|
|
12
|
+
attributes?: string[];
|
|
13
|
+
where?: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export interface ISerializerOptions {
|
|
16
|
+
id?: string;
|
|
17
|
+
keyForAttribute?: CaseOption | ((attribute: string) => string);
|
|
18
|
+
nullIfMissing?: boolean;
|
|
19
|
+
pluralizeType?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export type SerializerMode = 'api' | 'frontend' | 'default';
|
|
22
|
+
type CaseOption = 'dash-case' | 'lisp-case' | 'spinal-case' | 'kebab-case' | 'underscore_case' | 'snake_case' | 'camelCase' | 'CamelCase';
|
|
23
|
+
export declare function getSerializer(data: ISerializerConfig, mode?: SerializerMode, customOptions?: ISerializerOptions): Serializer;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=serializer.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializer.helper.d.ts","sourceRoot":"","sources":["../src/serializer.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,wBAAgB,sBAAsB,CAAC,gBAAgB,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAI3E;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,eAAe,CAAC,EAAE,UAAU,GAAG,CAAC,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;IAC/D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,UAAU,GAAG,SAAS,CAAC;AAc5D,KAAK,UAAU,GACX,WAAW,GACX,WAAW,GACX,aAAa,GACb,YAAY,GACZ,iBAAiB,GACjB,YAAY,GACZ,WAAW,GACX,WAAW,CAAC;AA0BhB,wBAAgB,aAAa,CAC3B,IAAI,EAAE,iBAAiB,EACvB,IAAI,GAAE,cAA0B,EAChC,aAAa,CAAC,EAAE,kBAAkB,cAuBnC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Serializer } from 'ts-jsonapi';
|
|
2
|
+
export function createEntityAttributes(customAttributes) {
|
|
3
|
+
return [
|
|
4
|
+
...new Set([...customAttributes, 'createdAt', 'updatedAt', 'isDeleted']),
|
|
5
|
+
];
|
|
6
|
+
}
|
|
7
|
+
const PASSTHROUGH_KEY = (attribute) => attribute;
|
|
8
|
+
const DEFAULT_OPTIONS = {
|
|
9
|
+
id: 'id',
|
|
10
|
+
keyForAttribute: PASSTHROUGH_KEY,
|
|
11
|
+
nullIfMissing: true,
|
|
12
|
+
pluralizeType: false,
|
|
13
|
+
};
|
|
14
|
+
const MODE_OPTIONS = {
|
|
15
|
+
api: {
|
|
16
|
+
id: '_id',
|
|
17
|
+
keyForAttribute: 'camelCase',
|
|
18
|
+
nullIfMissing: true,
|
|
19
|
+
pluralizeType: false,
|
|
20
|
+
},
|
|
21
|
+
default: DEFAULT_OPTIONS,
|
|
22
|
+
frontend: DEFAULT_OPTIONS,
|
|
23
|
+
};
|
|
24
|
+
function getDefaultOptions(mode) {
|
|
25
|
+
return MODE_OPTIONS[mode];
|
|
26
|
+
}
|
|
27
|
+
export function getSerializer(data, mode = 'default', customOptions) {
|
|
28
|
+
const defaultOptions = getDefaultOptions(mode);
|
|
29
|
+
const options = { ...defaultOptions, ...customOptions };
|
|
30
|
+
const serializerOptions = {
|
|
31
|
+
...data,
|
|
32
|
+
id: options.id ?? 'id',
|
|
33
|
+
keyForAttribute: options.keyForAttribute ?? 'camelCase',
|
|
34
|
+
nullIfMissing: options.nullIfMissing ?? true,
|
|
35
|
+
pluralizeType: options.pluralizeType ?? false,
|
|
36
|
+
};
|
|
37
|
+
const serializer = new Serializer(data.type, serializerOptions);
|
|
38
|
+
const originalSerialize = serializer.serialize.bind(serializer);
|
|
39
|
+
const serializerWithPayload = serializer;
|
|
40
|
+
serializerWithPayload.serialize = (payload) => {
|
|
41
|
+
serializerWithPayload.payload = {};
|
|
42
|
+
return originalSerialize(payload);
|
|
43
|
+
};
|
|
44
|
+
return serializer;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=serializer.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializer.helper.js","sourceRoot":"","sources":["../src/serializer.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,UAAU,sBAAsB,CAAC,gBAA0B;IAC/D,OAAO;QACL,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;KACzE,CAAC;AACJ,CAAC;AA+CD,MAAM,eAAe,GAAG,CAAC,SAAiB,EAAU,EAAE,CAAC,SAAS,CAAC;AAEjE,MAAM,eAAe,GAAuB;IAC1C,EAAE,EAAE,IAAI;IACR,eAAe,EAAE,eAAe;IAChC,aAAa,EAAE,IAAI;IACnB,aAAa,EA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lHelper {
|
|
2
|
+
static buildTwitterUrl(tweetId: string, username: string): string;
|
|
3
|
+
static buildYoutubeUrl(videoId: string): string;
|
|
4
|
+
static buildInstagramUrl(postId: string): string;
|
|
5
|
+
static buildTikTokUrl(videoId: string, username?: string): string;
|
|
6
|
+
static buildLinkedInUrl(postId: string): string;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=social-url.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"social-url.helper.d.ts","sourceRoot":"","sources":["../src/social-url.helper.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAe;IAC1B,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAuBjE,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAQ/C,MAAM,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAQhD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM;IAajE,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;CAQhD"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export class SocialUrlHelper {
|
|
2
|
+
static buildTwitterUrl(tweetId, username) {
|
|
3
|
+
if (!tweetId) {
|
|
4
|
+
throw new Error('Tweet ID is required');
|
|
5
|
+
}
|
|
6
|
+
if (!username) {
|
|
7
|
+
throw new Error('Username is required for reliable Twitter URLs');
|
|
8
|
+
}
|
|
9
|
+
// Remove @ symbol if present
|
|
10
|
+
const cleanUsername = username.replace(/^@/, '');
|
|
11
|
+
if (!cleanUsername) {
|
|
12
|
+
throw new Error('Username cannot be empty');
|
|
13
|
+
}
|
|
14
|
+
// Validate tweet ID format (should be numeric)
|
|
15
|
+
if (!/^\d+$/.test(tweetId)) {
|
|
16
|
+
throw new Error(`Invalid tweet ID format: ${tweetId}`);
|
|
17
|
+
}
|
|
18
|
+
return `https://x.com/${cleanUsername}/status/${tweetId}`;
|
|
19
|
+
}
|
|
20
|
+
static buildYoutubeUrl(videoId) {
|
|
21
|
+
if (!videoId) {
|
|
22
|
+
throw new Error('Video ID is required');
|
|
23
|
+
}
|
|
24
|
+
return `https://www.youtube.com/watch?v=${videoId}`;
|
|
25
|
+
}
|
|
26
|
+
static buildInstagramUrl(postId) {
|
|
27
|
+
if (!postId) {
|
|
28
|
+
throw new Error('Post ID is required');
|
|
29
|
+
}
|
|
30
|
+
return `https://www.instagram.com/p/${postId}/`;
|
|
31
|
+
}
|
|
32
|
+
static buildTikTokUrl(videoId, username) {
|
|
33
|
+
if (!videoId) {
|
|
34
|
+
throw new Error('Video ID is required');
|
|
35
|
+
}
|
|
36
|
+
if (username) {
|
|
37
|
+
const cleanUsername = username.replace(/^@/, '');
|
|
38
|
+
return `https://www.tiktok.com/@${cleanUsername}/video/${videoId}`;
|
|
39
|
+
}
|
|
40
|
+
return `https://www.tiktok.com/video/${videoId}`;
|
|
41
|
+
}
|
|
42
|
+
static buildLinkedInUrl(postId) {
|
|
43
|
+
if (!postId) {
|
|
44
|
+
throw new Error('Post ID is required');
|
|
45
|
+
}
|
|
46
|
+
const urn = postId.startsWith('activity:') ? postId : `activity:${postId}`;
|
|
47
|
+
return `https://www.linkedin.com/feed/update/${urn}/`;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=social-url.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"social-url.helper.js","sourceRoot":"","sources":["../src/social-url.helper.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,eAAe;IAC1B,MAAM,CAAC,eAAe,CAAC,OAAe,EAAE,QAAgB;QACtD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC1C,CAAC;QACD,IAAI,CAAC,QA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MAAM,CAAC,gBAAgB,CAAC,MAAc;QACpC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QACzC,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,MAAM,EAAE,CAAC;QAC3E,OAAO,wCAAwC,GAAG,GAAG,CAAC;IACxD,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ModelCategory, type ModelKey, type ModelProvider, type QualityTier } from '@genfeedai/enums';
|
|
2
|
+
export interface ModelLike {
|
|
3
|
+
aspectRatios?: readonly string[];
|
|
4
|
+
category: ModelCategory;
|
|
5
|
+
cost?: number;
|
|
6
|
+
createdAt?: string;
|
|
7
|
+
defaultAspectRatio?: string;
|
|
8
|
+
defaultDuration?: number;
|
|
9
|
+
durations?: number[];
|
|
10
|
+
hasAudioToggle?: boolean;
|
|
11
|
+
hasDurationEditing?: boolean;
|
|
12
|
+
hasEndFrame?: boolean;
|
|
13
|
+
hasInterpolation?: boolean;
|
|
14
|
+
hasResolutionOptions?: boolean;
|
|
15
|
+
hasSpeech?: boolean;
|
|
16
|
+
id?: string;
|
|
17
|
+
isActive?: boolean;
|
|
18
|
+
isBatchSupported?: boolean;
|
|
19
|
+
isDefault?: boolean;
|
|
20
|
+
isDeleted?: boolean;
|
|
21
|
+
isImagenModel?: boolean;
|
|
22
|
+
isReferencesMandatory?: boolean;
|
|
23
|
+
key: ModelKey;
|
|
24
|
+
label?: string;
|
|
25
|
+
maxOutputs?: number;
|
|
26
|
+
maxReferences?: number;
|
|
27
|
+
provider?: ModelProvider;
|
|
28
|
+
qualityTier?: QualityTier;
|
|
29
|
+
updatedAt?: string;
|
|
30
|
+
usesOrientation?: boolean;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=model-like.type.d.ts.map
|
|
@@ -0,0 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