@umituz/react-native-ai-fal-provider 3.1.6 → 3.2.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.
Files changed (36) hide show
  1. package/package.json +1 -1
  2. package/src/exports/infrastructure.ts +0 -45
  3. package/src/exports/presentation.ts +2 -11
  4. package/src/index.ts +2 -3
  5. package/src/infrastructure/services/fal-queue-operations.ts +1 -1
  6. package/src/infrastructure/services/index.ts +0 -2
  7. package/src/infrastructure/utils/index.ts +7 -53
  8. package/src/infrastructure/utils/input-validator.util.ts +1 -1
  9. package/src/infrastructure/utils/parsers/index.ts +1 -4
  10. package/src/init/createAiProviderInitModule.ts +0 -56
  11. package/src/init/initializeFalProvider.ts +34 -0
  12. package/src/presentation/hooks/index.ts +0 -3
  13. package/src/infrastructure/services/fal-models.service.ts +0 -40
  14. package/src/infrastructure/utils/base-builders.util.ts +0 -28
  15. package/src/infrastructure/utils/collections/array-filters.util.ts +0 -63
  16. package/src/infrastructure/utils/collections/array-sorters.util.ts +0 -94
  17. package/src/infrastructure/utils/collections/index.ts +0 -7
  18. package/src/infrastructure/utils/date-format.util.ts +0 -30
  19. package/src/infrastructure/utils/error-categorizer.ts +0 -9
  20. package/src/infrastructure/utils/job-metadata/index.ts +0 -26
  21. package/src/infrastructure/utils/job-metadata/job-metadata-format.util.ts +0 -78
  22. package/src/infrastructure/utils/job-metadata/job-metadata-lifecycle.util.ts +0 -66
  23. package/src/infrastructure/utils/job-metadata/job-metadata-queries.util.ts +0 -57
  24. package/src/infrastructure/utils/job-metadata/job-metadata.types.ts +0 -19
  25. package/src/infrastructure/utils/job-storage/index.ts +0 -19
  26. package/src/infrastructure/utils/job-storage/job-storage-crud.util.ts +0 -64
  27. package/src/infrastructure/utils/job-storage/job-storage-interface.ts +0 -44
  28. package/src/infrastructure/utils/job-storage/job-storage-queries.util.ts +0 -81
  29. package/src/infrastructure/utils/number-format.util.ts +0 -86
  30. package/src/infrastructure/utils/parsers/object-validators.util.ts +0 -38
  31. package/src/infrastructure/utils/parsers/value-parsers.util.ts +0 -45
  32. package/src/infrastructure/utils/string-format.util.ts +0 -72
  33. package/src/infrastructure/validators/README.md +0 -290
  34. package/src/init/registerWithWizard.ts +0 -28
  35. package/src/presentation/hooks/README.md +0 -626
  36. package/src/presentation/hooks/use-models.ts +0 -56
@@ -1,290 +0,0 @@
1
- # Validators
2
-
3
- AI oluşturulan içerik için doğrulama fonksiyonları.
4
-
5
- ## validateNSFWContent
6
-
7
- AI oluşturulan içeriğin NSFW (Not Safe For Work) içerik içerip içermediğini kontrol eder.
8
-
9
- ### Kullanım
10
-
11
- ```typescript
12
- import { validateNSFWContent } from '@umituz/react-native-ai-fal-provider';
13
-
14
- try {
15
- const result = await falProvider.subscribe(modelId, input);
16
-
17
- // NSFW kontrolü
18
- validateNSFWContent(result);
19
-
20
- // Güvenli içerik, kullanmaya devam et
21
- console.log('İçerik güvenli');
22
- } catch (error) {
23
- if (error instanceof NSFWContentError) {
24
- console.error('NSFW içerik tespit edildi!');
25
- // Kullanıcıya mesaj göster
26
- }
27
- }
28
- ```
29
-
30
- ### Parametreler
31
-
32
- ```typescript
33
- function validateNSFWContent(result: Record<string, unknown>): void;
34
- ```
35
-
36
- **Parametre:**
37
- - `result`: FAL API yanıt objesi
38
-
39
- **Hata:** NSFW içerik tespit edilirse `NSFWContentError` fırlatır
40
-
41
- ### Nasıl Çalışır?
42
-
43
- FAL API bazı yanıtlarında `has_nsfw_concepts` alanını döndürür. Bu alan, içeriğin farklı NSFW kategorilerinde olup olmadığını belirten bir boolean dizisidir.
44
-
45
- ```typescript
46
- {
47
- "images": [...],
48
- "has_nsfw_concepts": [false, false, true, false]
49
- // NSFW içerik tespit edildi
50
- }
51
- ```
52
-
53
- ### Örnek Uygulama
54
-
55
- ```typescript
56
- import { useFalGeneration } from '@umituz/react-native-ai-fal-provider';
57
- import { validateNSFWContent, NSFWContentError } from '@umituz/react-native-ai-fal-provider';
58
-
59
- function SafeImageGenerator() {
60
- const { data, error, isLoading, generate } = useFalGeneration({
61
- onError: (error) => {
62
- if (error instanceof NSFWContentError) {
63
- Alert.alert(
64
- 'Uygunsuz İçerik',
65
- 'Oluşturulan içerik uygun değil. Lütfen farklı bir prompt deneyin.'
66
- );
67
- }
68
- },
69
- });
70
-
71
- const handleGenerate = async (prompt: string) => {
72
- const result = await generate('fal-ai/flux/schnell', { prompt });
73
-
74
- if (result) {
75
- try {
76
- validateNSFWContent(result);
77
- // İçerik güvenli, göster
78
- displayImage(result.images[0].url);
79
- } catch (validationError) {
80
- if (validationError instanceof NSFWContentError) {
81
- // NSFW içerik tespit edildi
82
- hideImage();
83
- showWarning('Bu içerik gösterilemez');
84
- }
85
- }
86
- }
87
- };
88
-
89
- return (
90
- <View>
91
- <Button onPress={() => handleGenerate(prompt)} />
92
- {isLoading && <ActivityIndicator />}
93
- </View>
94
- );
95
- }
96
- ```
97
-
98
- ### Custom Validation
99
-
100
- ```typescript
101
- import { validateNSFWContent } from '@umituz/react-native-ai-fal-provider';
102
-
103
- class ContentValidator {
104
- static validate(result: Record<string, unknown>): boolean {
105
- try {
106
- validateNSFWContent(result);
107
- return true;
108
- } catch (error) {
109
- if (error instanceof NSFWContentError) {
110
- return false;
111
- }
112
- throw error;
113
- }
114
- }
115
- }
116
-
117
- // Kullanım
118
- const isValid = ContentValidator.validate(result);
119
- if (!isValid) {
120
- console.log('İçerik NSFW');
121
- }
122
- ```
123
-
124
- ### İntegrasyon
125
-
126
- #### FalProvider ile
127
-
128
- ```typescript
129
- import { falProvider } from '@umituz/react-native-ai-fal-provider';
130
- import { validateNSFWContent } from '@umituz/react-native-ai-fal-provider';
131
-
132
- const safeSubscribe = async <T>(
133
- model: string,
134
- input: Record<string, unknown>
135
- ): Promise<T> => {
136
- const result = await falProvider.subscribe<T>(model, input);
137
-
138
- // Validate
139
- validateNSFWContent(result);
140
-
141
- return result;
142
- };
143
-
144
- // Kullanım
145
- try {
146
- const result = await safeSubscribe('fal-ai/flux/schnell', { prompt: '...' });
147
- console.log('Güvenli içerik:', result);
148
- } catch (error) {
149
- if (error instanceof NSFWContentError) {
150
- console.error('NSFW içerik');
151
- }
152
- }
153
- ```
154
-
155
- #### Middleware Pattern
156
-
157
- ```typescript
158
- import { validateNSFWContent } from '@umituz/react-native-ai-fal-provider';
159
-
160
- const withNSFWValidation = async (
161
- generator: () => Promise<Record<string, unknown>>
162
- ) => {
163
- const result = await generator();
164
- validateNSFWContent(result);
165
- return result;
166
- };
167
-
168
- // Kullanım
169
- const result = await withNSFWValidation(async () => {
170
- return await falProvider.subscribe('fal-ai/flux/schnell', { prompt });
171
- });
172
- ```
173
-
174
- ## NSFWContentError
175
-
176
- NSFW içerik tespit edildiğinde fırlatılan özel hata sınıfı.
177
-
178
- ```typescript
179
- class NSFWContentError extends Error {
180
- constructor(message = 'NSFW content detected') {
181
- super(message);
182
- this.name = 'NSFWContentError';
183
- }
184
- }
185
- ```
186
-
187
- ### Kullanım
188
-
189
- ```typescript
190
- import { NSFWContentError } from '@umituz/react-native-ai-fal-provider';
191
-
192
- try {
193
- validateNSFWContent(result);
194
- } catch (error) {
195
- if (error instanceof NSFWContentError) {
196
- console.error('NSFW:', error.message);
197
- }
198
- }
199
- ```
200
-
201
- ### Hata İşleme
202
-
203
- ```typescript
204
- const handleError = (error: unknown) => {
205
- if (error instanceof NSFWContentError) {
206
- // NSFW spesifik hata yönetimi
207
- return {
208
- type: 'NSFW_CONTENT',
209
- message: 'İçerik uygun değil',
210
- retryable: false,
211
- };
212
- }
213
- // Diğer hatalar
214
- return mapFalError(error);
215
- };
216
- ```
217
-
218
- ## Best Practices
219
-
220
- ### 1. Her Zaman Doğrulayın
221
-
222
- ```typescript
223
- // ❌ Yanlış
224
- const result = await falProvider.subscribe(modelId, input);
225
- displayImage(result.images[0].url); // Doğrulama yok
226
-
227
- // ✅ Doğru
228
- const result = await falProvider.subscribe(modelId, input);
229
- validateNSFWContent(result); // Doğrula
230
- displayImage(result.images[0].url);
231
- ```
232
-
233
- ### 2. Hata Yakalama
234
-
235
- ```typescript
236
- try {
237
- const result = await generate();
238
- validateNSFWContent(result);
239
- showResult(result);
240
- } catch (error) {
241
- if (error instanceof NSFWContentError) {
242
- showNSFWWarning();
243
- } else {
244
- showGenericError();
245
- }
246
- }
247
- ```
248
-
249
- ### 3. Kullanıcı Bildirimi
250
-
251
- ```typescript
252
- const handleNSFW = () => {
253
- Alert.alert(
254
- 'Uygunsuz İçerik',
255
- 'Bu içerik politikalara uymadığı için gösterilemiyor. Lütfen farklı bir prompt deneyin.',
256
- [{ text: 'Tamam' }]
257
- );
258
- };
259
- ```
260
-
261
- ### 4. Loglama
262
-
263
- ```typescript
264
- try {
265
- validateNSFWContent(result);
266
- } catch (error) {
267
- if (error instanceof NSFWContentError) {
268
- // Analytics'e gönder
269
- analytics.track('NSFW_CONTENT_DETECTED', {
270
- model: modelId,
271
- prompt: input.prompt,
272
- });
273
-
274
- // Log'a kaydet
275
- logger.warn('NSFW content detected', { modelId, prompt });
276
- }
277
- }
278
- ```
279
-
280
- ## Notlar
281
-
282
- - `validateNSFWContent` sadece FAL API'nin `has_nsfw_concepts` alanını döndürdüğü durumda çalışır
283
- - Tüm modeller bu alanı döndürmez
284
- - NSFW tespiti model-side veya FAL-side yapılabilir
285
- - Kullanıcı deneyimini etkilememek için hataları graceful şekilde ele alın
286
-
287
- ## Daha Fazla Bilgi
288
-
289
- - [FAL Content Policy](https://fal.ai/docs/content-policy)
290
- - [FAL NSFW Detection](https://fal.ai/docs/nsfw)
@@ -1,28 +0,0 @@
1
- /**
2
- * Wizard Flow Registration Helper
3
- * Use this when your app uses GenericWizardFlow from @umituz/react-native-ai-generation-content
4
- */
5
-
6
- import { providerRegistry } from '@umituz/react-native-ai-generation-content';
7
- import { falProvider } from '../infrastructure/services';
8
-
9
- /**
10
- * Register FAL provider with the wizard flow provider registry.
11
- * Optionally accepts a custom registry for backward compatibility.
12
- *
13
- * @example
14
- * ```typescript
15
- * import { registerWithWizard } from '@umituz/react-native-ai-fal-provider';
16
- *
17
- * // No need to import providerRegistry separately anymore
18
- * registerWithWizard();
19
- * ```
20
- */
21
- export function registerWithWizard(registry?: {
22
- register: (provider: unknown) => void;
23
- setActiveProvider: (id: string) => void;
24
- }): void {
25
- const reg = registry ?? providerRegistry;
26
- reg.register(falProvider);
27
- reg.setActiveProvider('fal');
28
- }