@umituz/react-native-ai-generation-content 1.12.37 → 1.12.38
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 +2 -2
- package/src/domains/creations/domain/value-objects/CreationsConfig.ts +0 -12
- package/src/domains/creations/infrastructure/adapters/createRepository.ts +3 -8
- package/src/domains/creations/infrastructure/repositories/CreationsFetcher.ts +1 -1
- package/src/domains/creations/infrastructure/repositories/CreationsRepository.ts +6 -20
- package/src/domains/creations/infrastructure/repositories/CreationsWriter.ts +1 -1
- package/src/domains/creations/infrastructure/repositories/FirestorePathResolver.ts +0 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.38",
|
|
4
4
|
"description": "Provider-agnostic AI generation orchestration for React Native",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@typescript-eslint/parser": "^7.0.0",
|
|
69
69
|
"@umituz/react-native-animation": "*",
|
|
70
70
|
"@umituz/react-native-design-system": "^2.3.33",
|
|
71
|
-
"@umituz/react-native-firebase": "
|
|
71
|
+
"@umituz/react-native-firebase": "^1.13.20",
|
|
72
72
|
"@umituz/react-native-haptics": "^1.0.2",
|
|
73
73
|
"@umituz/react-native-image": "*",
|
|
74
74
|
"@umituz/react-native-offline": "*",
|
|
@@ -25,17 +25,6 @@ export interface CreationsTranslations {
|
|
|
25
25
|
readonly filterTitle: string;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
/**
|
|
29
|
-
* Path builder function type
|
|
30
|
-
* Allows apps to define custom Firestore path structures
|
|
31
|
-
* @example
|
|
32
|
-
* // Default: users/{userId}/creations
|
|
33
|
-
* pathBuilder: (userId) => ["users", userId, "creations"]
|
|
34
|
-
* // Alternative: creations/{userId}/items
|
|
35
|
-
* pathBuilder: (userId) => ["creations", userId, "items"]
|
|
36
|
-
*/
|
|
37
|
-
export type PathBuilder = (userId: string) => string[];
|
|
38
|
-
|
|
39
28
|
/**
|
|
40
29
|
* Document mapper function type
|
|
41
30
|
* Allows apps to map their specific document structure to Creation
|
|
@@ -49,7 +38,6 @@ export interface CreationsConfig {
|
|
|
49
38
|
readonly translations: CreationsTranslations;
|
|
50
39
|
readonly maxThumbnails?: number;
|
|
51
40
|
readonly gridColumns?: number;
|
|
52
|
-
readonly pathBuilder?: PathBuilder;
|
|
53
41
|
readonly documentMapper?: DocumentMapper;
|
|
54
42
|
}
|
|
55
43
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Architecture:
|
|
6
6
|
* - Factory pattern for repository creation
|
|
7
|
-
* -
|
|
7
|
+
* - Standard path: users/{userId}/{collectionName}
|
|
8
8
|
* - Supports custom document mapping per app
|
|
9
9
|
* - App-agnostic: No Firestore instance needed (BaseRepository handles it)
|
|
10
10
|
*
|
|
@@ -25,16 +25,10 @@ import type { ICreationsRepository } from "../../domain/repositories/ICreationsR
|
|
|
25
25
|
* @returns ICreationsRepository instance
|
|
26
26
|
*
|
|
27
27
|
* @example
|
|
28
|
-
* // Basic usage
|
|
28
|
+
* // Basic usage (path: users/{userId}/photos)
|
|
29
29
|
* const repo = createCreationsRepository("photos");
|
|
30
30
|
*
|
|
31
31
|
* @example
|
|
32
|
-
* // Custom path structure
|
|
33
|
-
* const repo = createCreationsRepository("creations", {
|
|
34
|
-
* pathBuilder: (userId) => ["gallery", userId, "items"],
|
|
35
|
-
* });
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
32
|
* // Custom document mapper
|
|
39
33
|
* const repo = createCreationsRepository("photos", {
|
|
40
34
|
* documentMapper: (id, data) => ({
|
|
@@ -43,6 +37,7 @@ import type { ICreationsRepository } from "../../domain/repositories/ICreationsR
|
|
|
43
37
|
* type: data.category,
|
|
44
38
|
* createdAt: data.timestamp?.toDate() || new Date(),
|
|
45
39
|
* isShared: data.public ?? false,
|
|
40
|
+
* isFavorite: data.favorite ?? false,
|
|
46
41
|
* }),
|
|
47
42
|
* });
|
|
48
43
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getDocs, getDoc, query, orderBy } from "firebase/firestore";
|
|
2
|
+
import { type FirestorePathResolver } from "@umituz/react-native-firebase";
|
|
2
3
|
import type { DocumentMapper } from "../../domain/value-objects/CreationsConfig";
|
|
3
4
|
import type { Creation, CreationDocument } from "../../domain/entities/Creation";
|
|
4
|
-
import type { FirestorePathResolver } from "./FirestorePathResolver";
|
|
5
5
|
|
|
6
6
|
declare const __DEV__: boolean;
|
|
7
7
|
|
|
@@ -1,32 +1,19 @@
|
|
|
1
|
-
import { BaseRepository } from "@umituz/react-native-firebase";
|
|
1
|
+
import { BaseRepository, FirestorePathResolver } from "@umituz/react-native-firebase";
|
|
2
2
|
import type { ICreationsRepository } from "../../domain/repositories/ICreationsRepository";
|
|
3
3
|
import type { Creation } from "../../domain/entities/Creation";
|
|
4
4
|
import { mapDocumentToCreation } from "../../domain/entities/Creation";
|
|
5
|
-
import type {
|
|
6
|
-
PathBuilder,
|
|
7
|
-
DocumentMapper,
|
|
8
|
-
} from "../../domain/value-objects/CreationsConfig";
|
|
9
|
-
import { FirestorePathResolver } from "./FirestorePathResolver";
|
|
5
|
+
import type { DocumentMapper } from "../../domain/value-objects/CreationsConfig";
|
|
10
6
|
import { CreationsFetcher } from "./CreationsFetcher";
|
|
11
7
|
import { CreationsWriter } from "./CreationsWriter";
|
|
12
8
|
|
|
13
9
|
/**
|
|
14
10
|
* Repository options for dynamic configuration
|
|
15
|
-
* Apps can customize
|
|
11
|
+
* Apps can customize document mapping
|
|
16
12
|
*/
|
|
17
13
|
export interface RepositoryOptions {
|
|
18
|
-
readonly pathBuilder?: PathBuilder;
|
|
19
14
|
readonly documentMapper?: DocumentMapper;
|
|
20
15
|
}
|
|
21
16
|
|
|
22
|
-
/**
|
|
23
|
-
* Default path builder: users/{userId}/{collectionName}
|
|
24
|
-
*/
|
|
25
|
-
const createDefaultPathBuilder =
|
|
26
|
-
(collectionName: string): PathBuilder =>
|
|
27
|
-
(userId: string) =>
|
|
28
|
-
["users", userId, collectionName];
|
|
29
|
-
|
|
30
17
|
/**
|
|
31
18
|
* Creations Repository Implementation
|
|
32
19
|
* Delegates to specialized classes for different responsibilities
|
|
@@ -36,7 +23,7 @@ const createDefaultPathBuilder =
|
|
|
36
23
|
* - Uses FirestorePathResolver for path resolution
|
|
37
24
|
* - Uses CreationsFetcher for read operations
|
|
38
25
|
* - Uses CreationsWriter for write operations
|
|
39
|
-
* -
|
|
26
|
+
* - Standard path: users/{userId}/{collectionName}
|
|
40
27
|
*/
|
|
41
28
|
export class CreationsRepository
|
|
42
29
|
extends BaseRepository
|
|
@@ -46,15 +33,14 @@ export class CreationsRepository
|
|
|
46
33
|
private readonly writer: CreationsWriter;
|
|
47
34
|
|
|
48
35
|
constructor(
|
|
49
|
-
|
|
36
|
+
collectionName: string,
|
|
50
37
|
options?: RepositoryOptions,
|
|
51
38
|
) {
|
|
52
39
|
super();
|
|
53
40
|
|
|
54
|
-
const pathBuilder = options?.pathBuilder ?? createDefaultPathBuilder(_collectionName);
|
|
55
41
|
const documentMapper = options?.documentMapper ?? mapDocumentToCreation;
|
|
56
42
|
|
|
57
|
-
this.pathResolver = new FirestorePathResolver(
|
|
43
|
+
this.pathResolver = new FirestorePathResolver(collectionName, this.getDb());
|
|
58
44
|
this.fetcher = new CreationsFetcher(this.pathResolver, documentMapper);
|
|
59
45
|
this.writer = new CreationsWriter(this.pathResolver);
|
|
60
46
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { setDoc, updateDoc, deleteDoc } from "firebase/firestore";
|
|
2
|
+
import { type FirestorePathResolver } from "@umituz/react-native-firebase";
|
|
2
3
|
import type { Creation, CreationDocument } from "../../domain/entities/Creation";
|
|
3
|
-
import type { FirestorePathResolver } from "./FirestorePathResolver";
|
|
4
4
|
|
|
5
5
|
declare const __DEV__: boolean;
|
|
6
6
|
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Firestore } from "firebase/firestore";
|
|
2
|
-
import { collection, doc } from "firebase/firestore";
|
|
3
|
-
import type { PathBuilder } from "../../domain/value-objects/CreationsConfig";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Resolves Firestore paths for creations
|
|
7
|
-
* Single Responsibility: Path resolution
|
|
8
|
-
*/
|
|
9
|
-
export class FirestorePathResolver {
|
|
10
|
-
constructor(
|
|
11
|
-
private readonly pathBuilder: PathBuilder,
|
|
12
|
-
private readonly db: Firestore | null,
|
|
13
|
-
) { }
|
|
14
|
-
|
|
15
|
-
getUserCollection(userId: string) {
|
|
16
|
-
if (!this.db) return null;
|
|
17
|
-
const pathSegments = this.pathBuilder(userId);
|
|
18
|
-
return collection(this.db, pathSegments[0], ...pathSegments.slice(1));
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
getDocRef(userId: string, creationId: string) {
|
|
22
|
-
if (!this.db) return null;
|
|
23
|
-
const pathSegments = this.pathBuilder(userId);
|
|
24
|
-
return doc(this.db, pathSegments[0], ...pathSegments.slice(1), creationId);
|
|
25
|
-
}
|
|
26
|
-
}
|