@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,18 @@
|
|
|
1
|
+
import { type ModelOutputCapability } from '@genfeedai/constants';
|
|
2
|
+
import { type ModelKey } from '@genfeedai/enums';
|
|
3
|
+
import type { IModel } from '@genfeedai/interfaces';
|
|
4
|
+
export declare function getDefaultAspectRatio(modelKey: ModelKey | string, capability?: ModelOutputCapability | null): string;
|
|
5
|
+
export declare function getAspectRatiosForModel(modelKey: ModelKey | string, capability?: ModelOutputCapability | null): readonly string[];
|
|
6
|
+
export declare function normalizeAspectRatioForModel(modelKey: ModelKey | string, aspectRatio: string, capability?: ModelOutputCapability | null): string;
|
|
7
|
+
export declare function calculateAspectRatio(width?: number, height?: number): string;
|
|
8
|
+
export declare function isAspectRatioSupported(modelKey: ModelKey | string, aspectRatio: string, capability?: ModelOutputCapability | null): boolean;
|
|
9
|
+
export declare function convertRatioToOrientation(ratio: string): 'portrait' | 'landscape';
|
|
10
|
+
/** Get default aspect ratio from an IModel document (DB-backed with constant fallback). */
|
|
11
|
+
export declare function getDefaultAspectRatioFromModel(model: IModel): string;
|
|
12
|
+
/** Get available aspect ratios from an IModel document. */
|
|
13
|
+
export declare function getAspectRatiosFromModel(model: IModel): readonly string[];
|
|
14
|
+
/** Normalize an aspect ratio for an IModel document. */
|
|
15
|
+
export declare function normalizeAspectRatioFromModel(model: IModel, aspectRatio: string): string;
|
|
16
|
+
/** Check if an aspect ratio is supported by an IModel document. */
|
|
17
|
+
export declare function isAspectRatioSupportedFromModel(model: IModel, aspectRatio: string): boolean;
|
|
18
|
+
//# sourceMappingURL=aspect-ratio.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aspect-ratio.helper.d.ts","sourceRoot":"","sources":["../src/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mEAAmE;AACnE,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAClB,OAAO,CAMT"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { MODEL_OUTPUT_CAPABILITIES, } from '@genfeedai/constants';
|
|
2
|
+
import { ModelCategory } from '@genfeedai/enums';
|
|
3
|
+
import { getModelCapability } from '@helpers/model-capability.helper';
|
|
4
|
+
const CATEGORIES_WITHOUT_ASPECT_RATIO = new Set([
|
|
5
|
+
ModelCategory.TEXT,
|
|
6
|
+
ModelCategory.EMBEDDING,
|
|
7
|
+
ModelCategory.MUSIC,
|
|
8
|
+
ModelCategory.IMAGE_UPSCALE,
|
|
9
|
+
ModelCategory.VIDEO_UPSCALE,
|
|
10
|
+
]);
|
|
11
|
+
const DEFAULT_ASPECT_RATIO_BY_CATEGORY = {
|
|
12
|
+
[ModelCategory.VIDEO]: '16:9',
|
|
13
|
+
[ModelCategory.VIDEO_EDIT]: '16:9',
|
|
14
|
+
[ModelCategory.VOICE]: '16:9',
|
|
15
|
+
[ModelCategory.IMAGE]: '1:1',
|
|
16
|
+
[ModelCategory.IMAGE_EDIT]: '1:1',
|
|
17
|
+
};
|
|
18
|
+
function getModelAspectRatioConfig(modelKey, capability) {
|
|
19
|
+
const cap = capability ?? MODEL_OUTPUT_CAPABILITIES[modelKey];
|
|
20
|
+
if (!cap) {
|
|
21
|
+
return { available: ['1:1', '9:16', '16:9'], default: '16:9' };
|
|
22
|
+
}
|
|
23
|
+
if (CATEGORIES_WITHOUT_ASPECT_RATIO.has(cap.category)) {
|
|
24
|
+
return { available: [], default: '16:9' };
|
|
25
|
+
}
|
|
26
|
+
const defaultRatio = DEFAULT_ASPECT_RATIO_BY_CATEGORY[cap.category] ?? '16:9';
|
|
27
|
+
if (cap.category === ModelCategory.VIDEO) {
|
|
28
|
+
return {
|
|
29
|
+
available: cap.aspectRatios ?? [],
|
|
30
|
+
default: cap.defaultAspectRatio ?? defaultRatio,
|
|
31
|
+
usesOrientation: cap.usesOrientation,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
available: cap.aspectRatios ?? [],
|
|
36
|
+
default: cap.defaultAspectRatio ??
|
|
37
|
+
defaultRatio,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export function getDefaultAspectRatio(modelKey, capability) {
|
|
41
|
+
return getModelAspectRatioConfig(modelKey, capability).default;
|
|
42
|
+
}
|
|
43
|
+
export function getAspectRatiosForModel(modelKey, capability) {
|
|
44
|
+
return getModelAspectRatioConfig(modelKey, capability).available;
|
|
45
|
+
}
|
|
46
|
+
export function normalizeAspectRatioForModel(modelKey, aspectRatio, capability) {
|
|
47
|
+
const config = getModelAspectRatioConfig(modelKey, capability);
|
|
48
|
+
if (config.available.includes(aspectRatio)) {
|
|
49
|
+
return aspectRatio;
|
|
50
|
+
}
|
|
51
|
+
if (config.usesOrientation) {
|
|
52
|
+
return convertRatioToOrientation(aspectRatio);
|
|
53
|
+
}
|
|
54
|
+
return config.default;
|
|
55
|
+
}
|
|
56
|
+
const ASPECT_RATIO_MAP = [
|
|
57
|
+
{ label: '16:9', ratio: 16 / 9 },
|
|
58
|
+
{ label: '21:9', ratio: 21 / 9 },
|
|
59
|
+
{ label: '4:3', ratio: 4 / 3 },
|
|
60
|
+
{ label: '3:2', ratio: 3 / 2 },
|
|
61
|
+
{ label: '5:4', ratio: 5 / 4 },
|
|
62
|
+
{ label: '2:1', ratio: 2 / 1 },
|
|
63
|
+
{ label: '9:16', ratio: 9 / 16 },
|
|
64
|
+
{ label: '3:4', ratio: 3 / 4 },
|
|
65
|
+
{ label: '2:3', ratio: 2 / 3 },
|
|
66
|
+
{ label: '4:5', ratio: 4 / 5 },
|
|
67
|
+
{ label: '1:2', ratio: 1 / 2 },
|
|
68
|
+
{ label: '1:1', ratio: 1 },
|
|
69
|
+
];
|
|
70
|
+
const TOLERANCE = 0.1;
|
|
71
|
+
export function calculateAspectRatio(width, height) {
|
|
72
|
+
if (!width || !height) {
|
|
73
|
+
return '16:9';
|
|
74
|
+
}
|
|
75
|
+
const gcd = calculateGCD(width, height);
|
|
76
|
+
const ratio = width / gcd / (height / gcd);
|
|
77
|
+
for (const { ratio: targetRatio, label } of ASPECT_RATIO_MAP) {
|
|
78
|
+
if (Math.abs(ratio - targetRatio) < TOLERANCE) {
|
|
79
|
+
return label;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return width > height ? '16:9' : '9:16';
|
|
83
|
+
}
|
|
84
|
+
function calculateGCD(a, b) {
|
|
85
|
+
return b === 0 ? a : calculateGCD(b, a % b);
|
|
86
|
+
}
|
|
87
|
+
export function isAspectRatioSupported(modelKey, aspectRatio, capability) {
|
|
88
|
+
return getModelAspectRatioConfig(modelKey, capability).available.includes(aspectRatio);
|
|
89
|
+
}
|
|
90
|
+
const PORTRAIT_RATIOS = new Set(['9:16', '3:4', '2:3', '1:2']);
|
|
91
|
+
export function convertRatioToOrientation(ratio) {
|
|
92
|
+
if (PORTRAIT_RATIOS.has(ratio)) {
|
|
93
|
+
return 'portrait';
|
|
94
|
+
}
|
|
95
|
+
return 'landscape';
|
|
96
|
+
}
|
|
97
|
+
// ============================================================================
|
|
98
|
+
// IModel-based overloads
|
|
99
|
+
// ============================================================================
|
|
100
|
+
/** Get default aspect ratio from an IModel document (DB-backed with constant fallback). */
|
|
101
|
+
export function getDefaultAspectRatioFromModel(model) {
|
|
102
|
+
return getDefaultAspectRatio(model.key, getModelCapability(model));
|
|
103
|
+
}
|
|
104
|
+
/** Get available aspect ratios from an IModel document. */
|
|
105
|
+
export function getAspectRatiosFromModel(model) {
|
|
106
|
+
return getAspectRatiosForModel(model.key, getModelCapability(model));
|
|
107
|
+
}
|
|
108
|
+
/** Normalize an aspect ratio for an IModel document. */
|
|
109
|
+
export function normalizeAspectRatioFromModel(model, aspectRatio) {
|
|
110
|
+
return normalizeAspectRatioForModel(model.key, aspectRatio, getModelCapability(model));
|
|
111
|
+
}
|
|
112
|
+
/** Check if an aspect ratio is supported by an IModel document. */
|
|
113
|
+
export function isAspectRatioSupportedFromModel(model, aspectRatio) {
|
|
114
|
+
return isAspectRatioSupported(model.key, aspectRatio, getModelCapability(model));
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=aspect-ratio.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aspect-ratio.helper.js","sourceRoot":"","sources":["../src/aspect-ratio.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,GAE1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAiB,MAAM,kBAAkB,CAAC;AAGhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,MAAM,+BAA+B,GAAG,IAAI,GAAG,CAAC;IAC9C,aAAa,CAAC,IAAI;IAClB,aAAa,CAAC,SAAS;IACvB,aAAa,CAAC,KAAK;IACnB,aAAa,CAAC,aAAa;IAC3B,aAAa,CAAC,aAAa;CAC5B,CAAC,CAAC;AAEH,MAAM,gCAAgC,GAA2B;IAC/D,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,MAAM;IAC7B,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,MAAM;IAClC,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,MAAM;IAC7B,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,KAAK;IAC5B,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,KAAK;CAClC,CAAC;AAEF,SAAS,yBAAyB,CAChC,QAA2B,EAC3B,UAAyC;IAMzC,MAAM,GAAG,GAAG,UAAU,IAAI,yBAAyB,CAAC,QAAoB,CAAC,CAAC;IAC1E,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IACjE,CAAC;IAED,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AU,wBAAwB,CAAC,KAAa;IACpD,OAAO,uBAAuB,CAAC,KAAK,CAAC,GAAG,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;AACvE,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,6BAA6B,CAC3C,KAAa,EACb,WAAmB;IAEnB,OAAO,4BAA4B,CACjC,KAAK,CAAC,GAAG,EACT,WAAW,EACX,kBAAkB,CAAC,KAAK,CAAC,CAC1B,CAAC;AACJ,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,+BAA+B,CAC7C,KAAa,EACb,WAAmB;IAEnB,OAAO,sBAAsB,CAC3B,KAAK,CAAC,GAAG,EACT,WAAW,EACX,kBAAkB,CAAC,KAAK,CAAC,CAC1B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Genfeed.ai Pricing Configuration
|
|
3
|
+
*
|
|
4
|
+
* SINGLE SOURCE OF TRUTH for all pricing across the platform.
|
|
5
|
+
* See: https://github.com/genfeedai/cloud/issues?q=is%3Aissue+pricing
|
|
6
|
+
*
|
|
7
|
+
* Pricing Strategy:
|
|
8
|
+
* - Output-based pricing (videos, images, voice) - NOT credit-based
|
|
9
|
+
* - Premium positioning ($499-$4,999/month)
|
|
10
|
+
* - Credits are tracked internally but NEVER shown to users
|
|
11
|
+
* - Auto-select premium AI models (no user decision fatigue)
|
|
12
|
+
*
|
|
13
|
+
* @updated 2026-01-21
|
|
14
|
+
*/
|
|
15
|
+
interface PricingOutputsProps {
|
|
16
|
+
/** Video generation in minutes per month */
|
|
17
|
+
videoMinutes?: number;
|
|
18
|
+
/** Number of images per month */
|
|
19
|
+
images?: number;
|
|
20
|
+
/** Voice generation in minutes per month */
|
|
21
|
+
voiceMinutes?: number;
|
|
22
|
+
}
|
|
23
|
+
interface PricingPlanProps {
|
|
24
|
+
/** Display label (e.g., "Pro", "Scale", "Enterprise") */
|
|
25
|
+
label: string;
|
|
26
|
+
/** Stripe price ID for checkout */
|
|
27
|
+
stripePriceId?: string;
|
|
28
|
+
/** Plan type */
|
|
29
|
+
type: 'subscription' | 'payg' | 'self-hosted' | 'enterprise' | 'byok';
|
|
30
|
+
/** Short description */
|
|
31
|
+
description: string;
|
|
32
|
+
/** Billing interval */
|
|
33
|
+
interval: 'month' | 'year' | 'payg';
|
|
34
|
+
/** Feature list for pricing card */
|
|
35
|
+
features: string[];
|
|
36
|
+
/** Monthly price in USD (null for contact sales) */
|
|
37
|
+
price: number | null;
|
|
38
|
+
/** Output quotas (videos, images, voice) - user-facing */
|
|
39
|
+
outputs?: PricingOutputsProps | null;
|
|
40
|
+
/** CTA button text */
|
|
41
|
+
cta?: string;
|
|
42
|
+
/** CTA button link */
|
|
43
|
+
ctaHref?: string;
|
|
44
|
+
/** Target audience description */
|
|
45
|
+
target?: string;
|
|
46
|
+
/** Value proposition one-liner */
|
|
47
|
+
valueProposition?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface ServiceOfferingProps {
|
|
50
|
+
/** Service name */
|
|
51
|
+
name: string;
|
|
52
|
+
/** Short description */
|
|
53
|
+
description: string;
|
|
54
|
+
/** What's included */
|
|
55
|
+
includes: string[];
|
|
56
|
+
/** How it works — ordered steps */
|
|
57
|
+
process: {
|
|
58
|
+
step: string;
|
|
59
|
+
description: string;
|
|
60
|
+
}[];
|
|
61
|
+
/** CTA link (Calendly) */
|
|
62
|
+
ctaHref: string;
|
|
63
|
+
}
|
|
64
|
+
export interface TrainingPackageProps {
|
|
65
|
+
/** Package name */
|
|
66
|
+
name: string;
|
|
67
|
+
/** Short description */
|
|
68
|
+
description: string;
|
|
69
|
+
/** What's included */
|
|
70
|
+
includes: string[];
|
|
71
|
+
/** Price label (e.g. "$499", "Custom") */
|
|
72
|
+
priceLabel: string;
|
|
73
|
+
/** CTA link (Calendly) */
|
|
74
|
+
ctaHref: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* BYOK Platform Fee Configuration
|
|
78
|
+
* 5% fee on BYOK usage after a free monthly threshold.
|
|
79
|
+
* Exchange rate: 1 credit = $0.01
|
|
80
|
+
*/
|
|
81
|
+
export declare const BYOK_FEE_PERCENTAGE = 5;
|
|
82
|
+
export declare const BYOK_FREE_THRESHOLD_CREDITS = 500;
|
|
83
|
+
export declare const BYOK_CREDIT_VALUE_DOLLARS = 0.01;
|
|
84
|
+
export declare const BYOK_FEE_PER_CREDIT: number;
|
|
85
|
+
/**
|
|
86
|
+
* Apply 70% margin to a provider cost in USD.
|
|
87
|
+
* Returns the sell price in credits (1 credit = $0.01).
|
|
88
|
+
*
|
|
89
|
+
* Formula: Sell Price (USD) = providerCostUsd / 0.30
|
|
90
|
+
* Credits = Sell Price / BYOK_CREDIT_VALUE_DOLLARS
|
|
91
|
+
*
|
|
92
|
+
* @example applyMargin(0.15) → 50 credits ($0.50 sell price on $0.15 cost)
|
|
93
|
+
* @example applyMargin(0.50) → 167 credits ($1.67 sell price on $0.50 cost)
|
|
94
|
+
*/
|
|
95
|
+
export declare function applyMargin(providerCostUsd: number): number;
|
|
96
|
+
/**
|
|
97
|
+
* Internal credit costs (hidden from users)
|
|
98
|
+
* Used for margin tracking and cost accounting only
|
|
99
|
+
*
|
|
100
|
+
* Exchange rate: 1 credit = $0.01
|
|
101
|
+
* Pricing formula: Sell Price = Cost / 0.30 (70% margin target)
|
|
102
|
+
*
|
|
103
|
+
* See: https://github.com/genfeedai/cloud/issues?q=is%3Aissue+pricing
|
|
104
|
+
*/
|
|
105
|
+
export declare const INTERNAL_CREDIT_COSTS: {
|
|
106
|
+
/** Avatar/Lip-sync per second: 100 credits = $1.00/sec */
|
|
107
|
+
readonly avatarPerSecond: 100;
|
|
108
|
+
/** Image (1K/2K): 50 credits = $0.50 (70% margin on $0.15 cost) */
|
|
109
|
+
readonly image: 50;
|
|
110
|
+
/** Image (4K): 100 credits = $1.00 (70% margin on $0.30 cost) */
|
|
111
|
+
readonly image4k: 100;
|
|
112
|
+
/** Video per second: 75 credits = $0.75/sec */
|
|
113
|
+
readonly videoPerSecond: 75;
|
|
114
|
+
/** Voice per minute: 17 credits = $0.17 (70% margin on $0.05 cost) */
|
|
115
|
+
readonly voicePerMinute: 17;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Video duration helpers
|
|
119
|
+
* Standard video durations and their credit costs
|
|
120
|
+
*/
|
|
121
|
+
export declare const VIDEO_CREDIT_COSTS: {
|
|
122
|
+
/** 4 second video: 300 credits = $3.00 */
|
|
123
|
+
readonly video4s: number;
|
|
124
|
+
/** 8 second video: 600 credits = $6.00 */
|
|
125
|
+
readonly video8s: number;
|
|
126
|
+
/** 15 second video: 1125 credits = $11.25 */
|
|
127
|
+
readonly video15s: number;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Avatar duration helpers
|
|
131
|
+
* Standard avatar durations and their credit costs
|
|
132
|
+
*/
|
|
133
|
+
export declare const AVATAR_CREDIT_COSTS: {
|
|
134
|
+
/** 4 second avatar: 400 credits = $4.00 */
|
|
135
|
+
readonly avatar4s: number;
|
|
136
|
+
/** 8 second avatar: 800 credits = $8.00 */
|
|
137
|
+
readonly avatar8s: number;
|
|
138
|
+
/** 15 second avatar: 1500 credits = $15.00 */
|
|
139
|
+
readonly avatar15s: number;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Website pricing plans - displayed on public pricing page
|
|
143
|
+
* Output-based pricing for premium positioning
|
|
144
|
+
*/
|
|
145
|
+
export declare const websitePlans: PricingPlanProps[];
|
|
146
|
+
/**
|
|
147
|
+
* Get plan by label
|
|
148
|
+
*/
|
|
149
|
+
export declare function getPlanByLabel(label: string): PricingPlanProps | undefined;
|
|
150
|
+
/**
|
|
151
|
+
* Get Pro tier plan
|
|
152
|
+
*/
|
|
153
|
+
export declare function getProPlan(): PricingPlanProps;
|
|
154
|
+
/**
|
|
155
|
+
* Get Scale tier plan
|
|
156
|
+
*/
|
|
157
|
+
export declare function getScalePlan(): PricingPlanProps;
|
|
158
|
+
/**
|
|
159
|
+
* Get Enterprise tier plan
|
|
160
|
+
*/
|
|
161
|
+
export declare function getEnterprisePlan(): PricingPlanProps;
|
|
162
|
+
/**
|
|
163
|
+
* Format price for display
|
|
164
|
+
*/
|
|
165
|
+
export declare function formatPrice(price: number | null): string;
|
|
166
|
+
/**
|
|
167
|
+
* Format outputs for display
|
|
168
|
+
*/
|
|
169
|
+
export declare function formatOutputs(outputs: PricingPlanProps['outputs']): string | null;
|
|
170
|
+
/**
|
|
171
|
+
* Creator Tier - $50/month (UNLISTED - invite only)
|
|
172
|
+
*
|
|
173
|
+
* This is a secret offering for individual content creators.
|
|
174
|
+
* NOT displayed on the website or pricing page.
|
|
175
|
+
* Only accessible via direct link or invite.
|
|
176
|
+
*/
|
|
177
|
+
export declare const creatorPlan: PricingPlanProps;
|
|
178
|
+
/**
|
|
179
|
+
* Get Creator tier plan (unlisted)
|
|
180
|
+
*/
|
|
181
|
+
export declare function getCreatorPlan(): PricingPlanProps;
|
|
182
|
+
/**
|
|
183
|
+
* Dedicated Server plan - Custom pricing for open-source models on dedicated infrastructure
|
|
184
|
+
*/
|
|
185
|
+
export declare const dedicatedServerPlan: PricingPlanProps;
|
|
186
|
+
/**
|
|
187
|
+
* PAYG Credit Pack tiers
|
|
188
|
+
* Stripe charges base credits × $0.01. Bonus credits delivered via metadata.
|
|
189
|
+
* Exchange rate: 1 credit = $0.01
|
|
190
|
+
*/
|
|
191
|
+
export interface CreditPackTier {
|
|
192
|
+
/** Display label */
|
|
193
|
+
label: string;
|
|
194
|
+
/** Number of base credits in pack */
|
|
195
|
+
credits: number;
|
|
196
|
+
/** Bonus credits (null = no bonus) */
|
|
197
|
+
bonus: number | null;
|
|
198
|
+
}
|
|
199
|
+
export declare const PAYG_CREDIT_PACKS: CreditPackTier[];
|
|
200
|
+
/** Subset of credit packs shown on public pages (website, home). Settings/checkout use full list. */
|
|
201
|
+
export declare const WEBSITE_CREDIT_PACKS: CreditPackTier[];
|
|
202
|
+
/**
|
|
203
|
+
* Get total credits for a pack (base + bonus).
|
|
204
|
+
*/
|
|
205
|
+
export declare function creditPackTotalCredits(pack: CreditPackTier): number;
|
|
206
|
+
/**
|
|
207
|
+
* Convert credits to approximate output estimates.
|
|
208
|
+
* Uses INTERNAL_CREDIT_COSTS for calculations.
|
|
209
|
+
*/
|
|
210
|
+
export declare function creditsToOutputEstimate(credits: number): {
|
|
211
|
+
images: number;
|
|
212
|
+
videoMinutes: number;
|
|
213
|
+
voiceMinutes: number;
|
|
214
|
+
};
|
|
215
|
+
/**
|
|
216
|
+
* Calculate the dollar price for a credit pack.
|
|
217
|
+
* Exchange rate: 1 credit = $0.01 (bonus credits are free).
|
|
218
|
+
*/
|
|
219
|
+
export declare function creditPackPrice(pack: CreditPackTier): number;
|
|
220
|
+
/**
|
|
221
|
+
* Done-For-You content service offering
|
|
222
|
+
* Full-service content creation retainer
|
|
223
|
+
*/
|
|
224
|
+
export declare const contentServiceOffering: ServiceOfferingProps;
|
|
225
|
+
/**
|
|
226
|
+
* Setup & Training packages
|
|
227
|
+
* One-time onboarding and training sessions
|
|
228
|
+
*/
|
|
229
|
+
export declare const TRAINING_PACKAGES: TrainingPackageProps[];
|
|
230
|
+
export {};
|
|
231
|
+
//# sourceMappingURL=pricing.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing.helper.d.ts","sourceRoot":"","sources":["../../../src/business/pricing/pricing.helper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,UAAU,mBAAmB;IAC3B,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,gBAAgB;IACxB,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,aAAa,CAAC,EAAE,MA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