@umituz/react-native-ai-generation-content 1.83.66 → 1.83.68
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 +11 -11
- package/src/domains/generation/wizard/infrastructure/strategies/video-generation.strategy.ts +2 -2
- package/src/exports/infrastructure.ts +1 -6
- package/src/infrastructure/orchestration/index.ts +0 -20
- package/src/infrastructure/orchestration/GenerationOrchestrator.ts +0 -128
- package/src/infrastructure/orchestration/orchestrator.errors.ts +0 -29
- package/src/infrastructure/orchestration/orchestrator.types.ts +0 -44
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.83.
|
|
3
|
+
"version": "1.83.68",
|
|
4
4
|
"description": "Provider-agnostic AI generation orchestration for React Native with result preview components",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -41,16 +41,16 @@
|
|
|
41
41
|
"url": "git+https://github.com/umituz/react-native-ai-generation-content.git"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@umituz/react-native-auth": "
|
|
44
|
+
"@umituz/react-native-auth": "*"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"@react-navigation/native": ">=6.0.0",
|
|
48
48
|
"@tanstack/react-query": ">=5.0.0",
|
|
49
|
-
"@umituz/react-native-ai-fal-provider": "
|
|
50
|
-
"@umituz/react-native-design-system": "
|
|
51
|
-
"@umituz/react-native-firebase": "
|
|
52
|
-
"@umituz/react-native-subscription": "
|
|
53
|
-
"@umituz/react-native-video-editor": "
|
|
49
|
+
"@umituz/react-native-ai-fal-provider": "*",
|
|
50
|
+
"@umituz/react-native-design-system": "*",
|
|
51
|
+
"@umituz/react-native-firebase": "*",
|
|
52
|
+
"@umituz/react-native-subscription": "*",
|
|
53
|
+
"@umituz/react-native-video-editor": "*",
|
|
54
54
|
"expo": ">=54.0.0",
|
|
55
55
|
"expo-video": ">=1.0.0",
|
|
56
56
|
"firebase": ">=10.0.0",
|
|
@@ -72,10 +72,10 @@
|
|
|
72
72
|
"@types/react": "~19.1.10",
|
|
73
73
|
"@typescript-eslint/eslint-plugin": "^8.54.0",
|
|
74
74
|
"@typescript-eslint/parser": "^8.54.0",
|
|
75
|
-
"@umituz/react-native-ai-fal-provider": "
|
|
76
|
-
"@umituz/react-native-design-system": "
|
|
77
|
-
"@umituz/react-native-firebase": "
|
|
78
|
-
"@umituz/react-native-subscription": "
|
|
75
|
+
"@umituz/react-native-ai-fal-provider": "*",
|
|
76
|
+
"@umituz/react-native-design-system": "*",
|
|
77
|
+
"@umituz/react-native-firebase": "*",
|
|
78
|
+
"@umituz/react-native-subscription": "*",
|
|
79
79
|
"eslint": "^9.39.2",
|
|
80
80
|
"eslint-plugin-react": "^7.37.5",
|
|
81
81
|
"eslint-plugin-react-hooks": "^7.0.1",
|
package/src/domains/generation/wizard/infrastructure/strategies/video-generation.strategy.ts
CHANGED
|
@@ -55,8 +55,8 @@ export async function buildVideoInput(
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
return {
|
|
58
|
-
sourceImageBase64: photos[0],
|
|
59
|
-
targetImageBase64: photos[1] || photos[0],
|
|
58
|
+
sourceImageBase64: photos[0] || undefined,
|
|
59
|
+
targetImageBase64: photos[1] || photos[0] || undefined,
|
|
60
60
|
prompt: finalPrompt,
|
|
61
61
|
duration: extractDuration(wizardData),
|
|
62
62
|
aspectRatio: extractAspectRatio(wizardData),
|
|
@@ -66,12 +66,7 @@ export type {
|
|
|
66
66
|
|
|
67
67
|
// Orchestration
|
|
68
68
|
export type {
|
|
69
|
-
|
|
70
|
-
GenerationMetadata as OrchestratorGenerationMetadata, GenerationCapability as OrchestratorGenerationCapability,
|
|
71
|
-
OrchestratorConfig as GenerationOrchestratorConfig,
|
|
72
|
-
} from "../infrastructure/orchestration";
|
|
73
|
-
export {
|
|
74
|
-
GenerationOrchestrator, NetworkUnavailableError, InsufficientCreditsError, AuthenticationRequiredError,
|
|
69
|
+
GenerationCapability as OrchestratorGenerationCapability,
|
|
75
70
|
} from "../infrastructure/orchestration";
|
|
76
71
|
|
|
77
72
|
// Providers
|
|
@@ -3,24 +3,4 @@
|
|
|
3
3
|
* Exports generic orchestration utilities for AI generation
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
// GenerationOrchestrator
|
|
7
|
-
export { GenerationOrchestrator } from "./GenerationOrchestrator";
|
|
8
|
-
|
|
9
|
-
// Types
|
|
10
|
-
export type {
|
|
11
|
-
CreditService,
|
|
12
|
-
PaywallService,
|
|
13
|
-
NetworkService,
|
|
14
|
-
AuthService,
|
|
15
|
-
GenerationMetadata,
|
|
16
|
-
OrchestratorConfig,
|
|
17
|
-
} from "./orchestrator.types";
|
|
18
|
-
|
|
19
6
|
export type { GenerationCapability } from "../../domain/entities/generation.types";
|
|
20
|
-
|
|
21
|
-
// Errors
|
|
22
|
-
export {
|
|
23
|
-
NetworkUnavailableError,
|
|
24
|
-
InsufficientCreditsError,
|
|
25
|
-
AuthenticationRequiredError,
|
|
26
|
-
} from "./orchestrator.errors";
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AI Generation Orchestrator
|
|
3
|
-
* Orchestrates AI generation business operations
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
contentModerationService,
|
|
8
|
-
ContentPolicyViolationError,
|
|
9
|
-
} from "../../domains/content-moderation";
|
|
10
|
-
import type { OrchestratorConfig, GenerationMetadata } from "./orchestrator.types";
|
|
11
|
-
import type { GenerationCapability } from "../../domain/entities/generation.types";
|
|
12
|
-
import {
|
|
13
|
-
NetworkUnavailableError,
|
|
14
|
-
InsufficientCreditsError,
|
|
15
|
-
AuthenticationRequiredError,
|
|
16
|
-
} from "./orchestrator.errors";
|
|
17
|
-
|
|
18
|
-
export class GenerationOrchestrator {
|
|
19
|
-
constructor(private config: OrchestratorConfig) {}
|
|
20
|
-
|
|
21
|
-
private requireAuthenticatedUser(): string {
|
|
22
|
-
const { authService } = this.config;
|
|
23
|
-
const isAuthenticated = authService.isAuthenticated();
|
|
24
|
-
const userId = authService.getUserId();
|
|
25
|
-
|
|
26
|
-
if (!isAuthenticated || !userId) {
|
|
27
|
-
throw new AuthenticationRequiredError();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return userId;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
requireNetwork(): void {
|
|
34
|
-
if (!this.config.networkService.isOnline()) {
|
|
35
|
-
throw new NetworkUnavailableError();
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async moderateContent(
|
|
40
|
-
contentType: "text" | "image",
|
|
41
|
-
content: string,
|
|
42
|
-
metadata?: GenerationMetadata,
|
|
43
|
-
): Promise<void> {
|
|
44
|
-
const actualUserId = this.requireAuthenticatedUser();
|
|
45
|
-
|
|
46
|
-
const moderationResult = await contentModerationService.moderate({
|
|
47
|
-
userId: actualUserId,
|
|
48
|
-
contentType,
|
|
49
|
-
content,
|
|
50
|
-
metadata,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
if (!moderationResult.isAllowed) {
|
|
54
|
-
throw new ContentPolicyViolationError(
|
|
55
|
-
moderationResult.violations,
|
|
56
|
-
moderationResult.violations[0]?.suggestion,
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
calculateCreditCost(
|
|
62
|
-
capability: GenerationCapability,
|
|
63
|
-
metadata?: GenerationMetadata,
|
|
64
|
-
): number {
|
|
65
|
-
if (metadata?.creditCost && typeof metadata.creditCost === "number") {
|
|
66
|
-
return metadata.creditCost;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return this.config.calculateCreditCost(capability, metadata);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async checkCreditsAndShowPaywall(
|
|
73
|
-
capability: GenerationCapability,
|
|
74
|
-
metadata?: GenerationMetadata,
|
|
75
|
-
): Promise<boolean> {
|
|
76
|
-
const creditCost = this.calculateCreditCost(capability, metadata);
|
|
77
|
-
const actualUserId = this.requireAuthenticatedUser();
|
|
78
|
-
|
|
79
|
-
const currentCredits = await this.config.creditService.getBalance(actualUserId);
|
|
80
|
-
|
|
81
|
-
if (currentCredits < creditCost) {
|
|
82
|
-
this.config.paywallService.show(creditCost);
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
async processCredits(
|
|
90
|
-
capability: GenerationCapability,
|
|
91
|
-
metadata?: GenerationMetadata,
|
|
92
|
-
): Promise<number> {
|
|
93
|
-
const actualUserId = this.requireAuthenticatedUser();
|
|
94
|
-
const creditCost = this.calculateCreditCost(capability, metadata);
|
|
95
|
-
|
|
96
|
-
const currentCredits = await this.config.creditService.getBalance(actualUserId);
|
|
97
|
-
|
|
98
|
-
const success = await this.config.creditService.deduct(actualUserId, creditCost);
|
|
99
|
-
|
|
100
|
-
if (!success) {
|
|
101
|
-
this.config.paywallService.show(creditCost);
|
|
102
|
-
throw new InsufficientCreditsError(creditCost, currentCredits, capability);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return creditCost;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async refundCreditsIfApplicable(amount: number, error: unknown): Promise<void> {
|
|
109
|
-
if (amount <= 0) return;
|
|
110
|
-
|
|
111
|
-
const isNonRefundable =
|
|
112
|
-
error instanceof ContentPolicyViolationError ||
|
|
113
|
-
error instanceof InsufficientCreditsError ||
|
|
114
|
-
(error instanceof Error &&
|
|
115
|
-
(error.message.toLowerCase().includes("invalid input") ||
|
|
116
|
-
error.message.toLowerCase().includes("cancelled") ||
|
|
117
|
-
error.message.toLowerCase().includes("user cancel")));
|
|
118
|
-
|
|
119
|
-
if (!isNonRefundable) {
|
|
120
|
-
try {
|
|
121
|
-
const actualUserId = this.requireAuthenticatedUser();
|
|
122
|
-
await this.config.creditService.add(actualUserId, amount);
|
|
123
|
-
} catch (refundError) {
|
|
124
|
-
console.error("[GenerationOrchestrator] REFUND FAILED - user may have lost credits. Amount:", amount, "Error:", refundError);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Orchestrator Errors
|
|
3
|
-
* Custom error classes for AI generation orchestration
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export class NetworkUnavailableError extends Error {
|
|
7
|
-
constructor() {
|
|
8
|
-
super("No internet connection. Please check your network and try again.");
|
|
9
|
-
this.name = "NetworkUnavailableError";
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export class InsufficientCreditsError extends Error {
|
|
14
|
-
constructor(
|
|
15
|
-
public required: number,
|
|
16
|
-
public current: number,
|
|
17
|
-
public capability: string,
|
|
18
|
-
) {
|
|
19
|
-
super(`Insufficient credits. Required: ${required}, Current: ${current}`);
|
|
20
|
-
this.name = "InsufficientCreditsError";
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class AuthenticationRequiredError extends Error {
|
|
25
|
-
constructor() {
|
|
26
|
-
super("User not authenticated. This operation requires authentication.");
|
|
27
|
-
this.name = "AuthenticationRequiredError";
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Orchestrator Types
|
|
3
|
-
* Type definitions for AI generation orchestration
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export interface CreditService {
|
|
7
|
-
getBalance(userId: string): Promise<number>;
|
|
8
|
-
deduct(userId: string, amount: number): Promise<boolean>;
|
|
9
|
-
add(userId: string, amount: number): Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface PaywallService {
|
|
13
|
-
show(requiredCredits: number): void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface NetworkService {
|
|
17
|
-
isOnline(): boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface AuthService {
|
|
21
|
-
getUserId(): string | null;
|
|
22
|
-
isAuthenticated(): boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface GenerationMetadata {
|
|
26
|
-
creditCost?: number;
|
|
27
|
-
numImages?: number;
|
|
28
|
-
duration?: number;
|
|
29
|
-
isPremium?: boolean;
|
|
30
|
-
[key: string]: unknown;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
import type { GenerationCapability } from "../../domain/entities/generation.types";
|
|
34
|
-
|
|
35
|
-
export interface OrchestratorConfig {
|
|
36
|
-
creditService: CreditService;
|
|
37
|
-
paywallService: PaywallService;
|
|
38
|
-
networkService: NetworkService;
|
|
39
|
-
authService: AuthService;
|
|
40
|
-
calculateCreditCost: (
|
|
41
|
-
capability: GenerationCapability,
|
|
42
|
-
metadata?: GenerationMetadata,
|
|
43
|
-
) => number;
|
|
44
|
-
}
|