@umituz/react-native-ai-generation-content 1.85.0 → 1.87.0

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-generation-content",
3
- "version": "1.85.0",
3
+ "version": "1.87.0",
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",
@@ -10,6 +10,9 @@ import type { CreationTypeId, CreationCategory } from "./creation-types";
10
10
  */
11
11
  export const IMAGE_CREATION_TYPES: CreationTypeId[] = [
12
12
  "text-to-image",
13
+ "imagine",
14
+ "wardrobe",
15
+ "historical-wardrobe",
13
16
  "upscale",
14
17
  "remove-background",
15
18
  "photo-restore",
@@ -22,6 +25,17 @@ export const IMAGE_CREATION_TYPES: CreationTypeId[] = [
22
25
  "ai-brush",
23
26
  "hd-touch-up",
24
27
  "anime-selfie",
28
+ "aging",
29
+ "headshot",
30
+ "retouch",
31
+ "magic-edit",
32
+ "color-grading",
33
+ "art-style",
34
+ "mood-filter",
35
+ "face-expression",
36
+ "scene-composer",
37
+ "ai-background",
38
+ "effects",
25
39
  ];
26
40
 
27
41
  /**
@@ -8,6 +8,9 @@
8
8
  */
9
9
  export type CreationTypeId =
10
10
  | "text-to-image"
11
+ | "imagine"
12
+ | "wardrobe"
13
+ | "historical-wardrobe"
11
14
  | "text-to-video"
12
15
  | "image-to-video"
13
16
  | "upscale"
@@ -21,7 +24,18 @@ export type CreationTypeId =
21
24
  | "background-replacement"
22
25
  | "ai-brush"
23
26
  | "hd-touch-up"
24
- | "anime-selfie";
27
+ | "anime-selfie"
28
+ | "aging"
29
+ | "headshot"
30
+ | "retouch"
31
+ | "magic-edit"
32
+ | "color-grading"
33
+ | "art-style"
34
+ | "mood-filter"
35
+ | "face-expression"
36
+ | "scene-composer"
37
+ | "ai-background"
38
+ | "effects";
25
39
 
26
40
  /**
27
41
  * Creation status values
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Generation Execution Utilities
3
+ * Shared utilities for image and audio generation executors to eliminate code duplication
4
+ */
5
+
6
+ import { generateUUID } from "@umituz/react-native-design-system/uuid";
7
+
8
+ /**
9
+ * Resolve type from config - handles both static string and function types
10
+ */
11
+ export function resolveType<P>(
12
+ typeConfig: string | ((params: P) => string),
13
+ params: P
14
+ ): string {
15
+ return typeof typeConfig === "function" ? typeConfig(params) : typeConfig;
16
+ }
17
+
18
+ /**
19
+ * Handle credit refund with error logging
20
+ */
21
+ export async function handleCreditRefund(
22
+ refundCredits: (amount: number) => Promise<void> | Promise<boolean>,
23
+ cost: number,
24
+ typeLabel: string
25
+ ): Promise<void> {
26
+ try {
27
+ await refundCredits(cost);
28
+ } catch {
29
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
30
+ console.error(`[${typeLabel}] Refund failed`);
31
+ }
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Log generation error in development
37
+ */
38
+ export function logGenerationError(
39
+ typeLabel: string,
40
+ error: unknown
41
+ ): void {
42
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
43
+ console.error(`[${typeLabel}]`, error);
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Generate unique creation ID using Design System UUID
49
+ */
50
+ export function generateCreationId(): string {
51
+ return generateUUID();
52
+ }
@@ -14,6 +14,7 @@ import { useGenerationServices } from "../../../infrastructure/providers/generat
14
14
  import { resolveProvider } from "../../../infrastructure/services/provider-resolver";
15
15
  import { createCreationsRepository } from "../../../domains/creations/infrastructure/adapters";
16
16
  import type { GenerationTarget } from "./useImageGenerationExecutor";
17
+ import { handleCreditRefund, logGenerationError, generateCreationId } from "./generation-execution.utils";
17
18
 
18
19
  /** Domain-specific audio generation input returned by buildInput */
19
20
  export interface AudioGenerationInput {
@@ -95,7 +96,7 @@ export function useAudioGenerationExecutor<P>(
95
96
  if (!audioUrl) throw new Error("No audio returned");
96
97
 
97
98
  await repository.create(userId, {
98
- id: `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
99
+ id: generateCreationId(),
99
100
  type: config.type,
100
101
  uri: audioUrl,
101
102
  createdAt: new Date(),
@@ -117,18 +118,12 @@ export function useAudioGenerationExecutor<P>(
117
118
  const message =
118
119
  err instanceof Error ? err.message : "Generation failed";
119
120
  setError(message);
121
+
120
122
  if (deducted) {
121
- try {
122
- await refundCredits(cost);
123
- } catch {
124
- if (typeof __DEV__ !== "undefined" && __DEV__) {
125
- console.error(`[${config.type}] Refund failed`);
126
- }
127
- }
128
- }
129
- if (typeof __DEV__ !== "undefined" && __DEV__) {
130
- console.error(`[${config.type}]`, err);
123
+ await handleCreditRefund(refundCredits, cost, config.type);
131
124
  }
125
+
126
+ logGenerationError(config.type, err);
132
127
  return null;
133
128
  } finally {
134
129
  setIsLoading(false);
@@ -16,6 +16,7 @@ import { useGenerationServices } from "../../../infrastructure/providers/generat
16
16
  import { resolveProvider } from "../../../infrastructure/services/provider-resolver";
17
17
  import { createCreationsRepository } from "../../../domains/creations/infrastructure/adapters";
18
18
  import { preprocessImageInputs } from "../../../infrastructure/utils/image-input-preprocessor.util";
19
+ import { resolveType, handleCreditRefund, logGenerationError, generateCreationId } from "./generation-execution.utils";
19
20
 
20
21
  /** Target for generation: which model on which provider */
21
22
  export interface GenerationTarget {
@@ -101,8 +102,8 @@ export function useImageGenerationExecutor<P>(
101
102
  if (!imageUrl) throw new Error("No image returned");
102
103
 
103
104
  await repository.create(userId, {
104
- id: `${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
105
- type: typeof config.type === "function" ? config.type(params) : config.type,
105
+ id: generateCreationId(),
106
+ type: resolveType(config.type, params),
106
107
  uri: imageUrl,
107
108
  createdAt: new Date(),
108
109
  isShared: false,
@@ -123,19 +124,13 @@ export function useImageGenerationExecutor<P>(
123
124
  const message =
124
125
  err instanceof Error ? err.message : "Generation failed";
125
126
  setError(message);
126
- const typeLabel = typeof config.type === "function" ? config.type(params) : config.type;
127
+ const typeLabel = resolveType(config.type, params);
128
+
127
129
  if (deducted) {
128
- try {
129
- await refundCredits(cost);
130
- } catch {
131
- if (typeof __DEV__ !== "undefined" && __DEV__) {
132
- console.error(`[${typeLabel}] Refund failed`);
133
- }
134
- }
135
- }
136
- if (typeof __DEV__ !== "undefined" && __DEV__) {
137
- console.error(`[${typeLabel}]`, err);
130
+ await handleCreditRefund(refundCredits, cost, typeLabel);
138
131
  }
132
+
133
+ logGenerationError(typeLabel, err);
139
134
  return null;
140
135
  } finally {
141
136
  setIsLoading(false);