@umituz/react-native-ai-generation-content 1.17.116 → 1.17.118
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 +1 -1
- package/src/domains/creations/index.ts +0 -3
- package/src/domains/creations/application/services/CreationsService.ts +0 -74
- package/src/domains/creations/domain/services/ICreationsStorageService.ts +0 -13
- package/src/domains/creations/infrastructure/services/CreationsStorageService.ts +0 -49
package/package.json
CHANGED
|
@@ -105,10 +105,7 @@ export {
|
|
|
105
105
|
CreationsRepository,
|
|
106
106
|
type RepositoryOptions,
|
|
107
107
|
} from "./infrastructure/repositories";
|
|
108
|
-
export { CreationsStorageService } from "./infrastructure/services/CreationsStorageService";
|
|
109
108
|
export { createCreationsRepository } from "./infrastructure/adapters";
|
|
110
|
-
export { CreationsService } from "./application/services/CreationsService";
|
|
111
|
-
export type { ICreationsStorageService } from "./domain/services/ICreationsStorageService";
|
|
112
109
|
|
|
113
110
|
// =============================================================================
|
|
114
111
|
// PRESENTATION LAYER - Hooks
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { generateUUID } from "@umituz/react-native-uuid";
|
|
3
|
-
import type { ICreationsRepository } from "../../domain/repositories/ICreationsRepository";
|
|
4
|
-
import type { ICreationsStorageService } from "../../domain/services/ICreationsStorageService";
|
|
5
|
-
import type { CreationType } from "../../domain/value-objects";
|
|
6
|
-
import { BaseRepository } from "@umituz/react-native-firebase";
|
|
7
|
-
import type { Creation } from "../../domain/entities/Creation";
|
|
8
|
-
|
|
9
|
-
export interface CreateCreationDTO {
|
|
10
|
-
userId: string;
|
|
11
|
-
type: CreationType;
|
|
12
|
-
prompt: string;
|
|
13
|
-
metadata?: Record<string, unknown>;
|
|
14
|
-
imageUri: string; // can be local file uri or base64
|
|
15
|
-
aspectRatio?: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export class CreationsService extends BaseRepository {
|
|
19
|
-
constructor(
|
|
20
|
-
private readonly repository: ICreationsRepository,
|
|
21
|
-
private readonly storageService: ICreationsStorageService,
|
|
22
|
-
private readonly _collectionName: string = "creations" // Default to generic name, app can override via repo
|
|
23
|
-
) {
|
|
24
|
-
super();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async saveCreation(dto: CreateCreationDTO): Promise<string> {
|
|
28
|
-
const db = this.getDb();
|
|
29
|
-
if (!db) throw new Error("Firestore not initialized");
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
const creationId = generateUUID();
|
|
33
|
-
|
|
34
|
-
const imageUrl = await this.storageService.uploadCreationImage(
|
|
35
|
-
dto.userId,
|
|
36
|
-
creationId,
|
|
37
|
-
dto.imageUri
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
await this.repository.create(dto.userId, {
|
|
41
|
-
id: creationId,
|
|
42
|
-
uri: imageUrl,
|
|
43
|
-
type: dto.type.id,
|
|
44
|
-
prompt: dto.prompt,
|
|
45
|
-
metadata: dto.metadata || {},
|
|
46
|
-
createdAt: new Date(),
|
|
47
|
-
isShared: false,
|
|
48
|
-
isFavorite: false,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
return creationId;
|
|
52
|
-
} catch (error) {
|
|
53
|
-
// eslint-disable-next-line no-console
|
|
54
|
-
console.error(error);
|
|
55
|
-
throw error;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async getCreation(userId: string, id: string): Promise<Creation | null> {
|
|
60
|
-
return this.repository.getById(userId, id);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
async updateCreation(
|
|
64
|
-
userId: string,
|
|
65
|
-
id: string,
|
|
66
|
-
updates: { metadata?: Record<string, unknown> },
|
|
67
|
-
): Promise<boolean> {
|
|
68
|
-
return this.repository.update(userId, id, updates);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async deleteCreation(userId: string, id: string): Promise<boolean> {
|
|
72
|
-
return this.repository.delete(userId, id);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface ICreationsStorageService {
|
|
2
|
-
uploadCreationImage(
|
|
3
|
-
userId: string,
|
|
4
|
-
creationId: string,
|
|
5
|
-
imageUri: string,
|
|
6
|
-
mimeType?: string
|
|
7
|
-
): Promise<string>;
|
|
8
|
-
|
|
9
|
-
deleteCreationImage(
|
|
10
|
-
userId: string,
|
|
11
|
-
creationId: string
|
|
12
|
-
): Promise<boolean>;
|
|
13
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
uploadFile,
|
|
3
|
-
uploadBase64Image,
|
|
4
|
-
} from "@umituz/react-native-firebase";
|
|
5
|
-
import type { ICreationsStorageService } from "../../domain/services/ICreationsStorageService";
|
|
6
|
-
|
|
7
|
-
declare const __DEV__: boolean;
|
|
8
|
-
|
|
9
|
-
export class CreationsStorageService implements ICreationsStorageService {
|
|
10
|
-
constructor(private readonly storagePathPrefix: string = "creations") { }
|
|
11
|
-
|
|
12
|
-
private getPath(userId: string, creationId: string): string {
|
|
13
|
-
return `${this.storagePathPrefix}/${userId}/${creationId}.jpg`;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async uploadCreationImage(
|
|
17
|
-
userId: string,
|
|
18
|
-
creationId: string,
|
|
19
|
-
imageUri: string,
|
|
20
|
-
mimeType = "image/jpeg"
|
|
21
|
-
): Promise<string> {
|
|
22
|
-
const path = this.getPath(userId, creationId);
|
|
23
|
-
|
|
24
|
-
try {
|
|
25
|
-
if (imageUri.startsWith("data:")) {
|
|
26
|
-
const result = await uploadBase64Image(imageUri, path, { mimeType });
|
|
27
|
-
return result.downloadUrl;
|
|
28
|
-
}
|
|
29
|
-
const result = await uploadFile(imageUri, path, { mimeType });
|
|
30
|
-
return result.downloadUrl;
|
|
31
|
-
} catch (error) {
|
|
32
|
-
if (__DEV__) {
|
|
33
|
-
// eslint-disable-next-line no-console
|
|
34
|
-
console.error("[CreationsStorageService] upload failed", error);
|
|
35
|
-
}
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async deleteCreationImage(
|
|
41
|
-
_userId: string,
|
|
42
|
-
_creationId: string
|
|
43
|
-
): Promise<boolean> {
|
|
44
|
-
// Delete logic not strictly required for saving loop, but good to have
|
|
45
|
-
// Needs storage reference delete implementation in rn-firebase first
|
|
46
|
-
// For now we skip implementing delete in this iteration as priority is saving
|
|
47
|
-
return Promise.resolve(true);
|
|
48
|
-
}
|
|
49
|
-
}
|