@umituz/react-native-ai-fal-provider 3.1.0 → 3.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-ai-fal-provider",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "FAL AI provider for React Native - implements IAIProvider interface for unified AI generation",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -116,5 +116,6 @@ export { InMemoryJobStorage } from "../infrastructure/utils";
116
116
  export {
117
117
  calculateVideoCredits,
118
118
  calculateImageCredits,
119
+ calculateCreditsFromConfig,
119
120
  } from "../infrastructure/utils";
120
121
  export type { GenerationResolution } from "../infrastructure/utils";
@@ -109,5 +109,6 @@ export type { GenerationState } from "./fal-generation-state-manager.util";
109
109
  export {
110
110
  calculateVideoCredits,
111
111
  calculateImageCredits,
112
+ calculateCreditsFromConfig,
112
113
  } from "./pricing/fal-pricing.util";
113
114
  export type { GenerationResolution } from "./pricing/fal-pricing.util";
@@ -1,3 +1,5 @@
1
+ import type { VideoModelConfig } from "@umituz/react-native-ai-generation-content";
2
+
1
3
  /**
2
4
  * FAL AI Pricing Utilities
3
5
  * Single Responsibility: Credit calculations for FAL AI generation
@@ -39,3 +41,13 @@ export function calculateVideoCredits(
39
41
  export function calculateImageCredits(): number {
40
42
  return Math.ceil((COSTS.IMAGE * MARKUP) / CREDIT_PRICE);
41
43
  }
44
+
45
+ export function calculateCreditsFromConfig(
46
+ config: VideoModelConfig,
47
+ duration: number,
48
+ resolution: string,
49
+ ): number {
50
+ const costPerSec = config.pricing.costPerSecond[resolution] ?? 0;
51
+ const cost = costPerSec * duration;
52
+ return Math.max(1, Math.ceil((cost * MARKUP) / CREDIT_PRICE));
53
+ }