@oxyhq/services 5.9.1 → 5.9.3
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/README.md +1 -33
- package/lib/commonjs/core/OxyServices.js +159 -0
- package/lib/commonjs/core/OxyServices.js.map +1 -0
- package/lib/commonjs/core/OxyServicesMain.js +51 -0
- package/lib/commonjs/core/OxyServicesMain.js.map +1 -0
- package/lib/commonjs/core/analytics/AnalyticsService.js +67 -0
- package/lib/commonjs/core/analytics/AnalyticsService.js.map +1 -0
- package/lib/commonjs/core/auth/AuthService.js +526 -0
- package/lib/commonjs/core/auth/AuthService.js.map +1 -0
- package/lib/commonjs/core/devices/DeviceService.js +61 -0
- package/lib/commonjs/core/devices/DeviceService.js.map +1 -0
- package/lib/commonjs/core/files/FileService.js +176 -0
- package/lib/commonjs/core/files/FileService.js.map +1 -0
- package/lib/commonjs/core/index.js +103 -1707
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/core/karma/KarmaService.js +100 -0
- package/lib/commonjs/core/karma/KarmaService.js.map +1 -0
- package/lib/commonjs/core/locations/LocationService.js +131 -0
- package/lib/commonjs/core/locations/LocationService.js.map +1 -0
- package/lib/commonjs/core/payments/PaymentService.js +124 -0
- package/lib/commonjs/core/payments/PaymentService.js.map +1 -0
- package/lib/commonjs/core/users/UserService.js +234 -0
- package/lib/commonjs/core/users/UserService.js.map +1 -0
- package/lib/commonjs/index.js +164 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/session.js +2 -0
- package/lib/{module/types/middleware.js.map → commonjs/models/session.js.map} +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +28 -24
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js +2 -2
- package/lib/commonjs/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/FileManagementScreen.js +12 -12
- package/lib/commonjs/ui/screens/FileManagementScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/ProfileScreen.js +2 -2
- package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SessionManagementScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SignInScreen.js +1 -1
- package/lib/commonjs/ui/screens/SignInScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaLeaderboardScreen.js +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaLeaderboardScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaRulesScreen.js +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaRulesScreen.js.map +1 -1
- package/lib/commonjs/ui/stores/followStore.js +4 -4
- package/lib/commonjs/ui/stores/followStore.js.map +1 -1
- package/lib/commonjs/utils/apiUtils.js +93 -0
- package/lib/commonjs/utils/apiUtils.js.map +1 -0
- package/lib/commonjs/utils/asyncUtils.js +219 -0
- package/lib/commonjs/utils/asyncUtils.js.map +1 -0
- package/lib/commonjs/utils/errorUtils.js +148 -0
- package/lib/commonjs/utils/errorUtils.js.map +1 -0
- package/lib/commonjs/utils/hookUtils.js +399 -0
- package/lib/commonjs/utils/hookUtils.js.map +1 -0
- package/lib/commonjs/utils/loggerUtils.js +160 -0
- package/lib/commonjs/utils/loggerUtils.js.map +1 -0
- package/lib/commonjs/utils/validationUtils.js +174 -0
- package/lib/commonjs/utils/validationUtils.js.map +1 -0
- package/lib/module/core/OxyServices.js +153 -0
- package/lib/module/core/OxyServices.js.map +1 -0
- package/lib/module/core/OxyServicesMain.js +47 -0
- package/lib/module/core/OxyServicesMain.js.map +1 -0
- package/lib/module/core/analytics/AnalyticsService.js +62 -0
- package/lib/module/core/analytics/AnalyticsService.js.map +1 -0
- package/lib/module/core/auth/AuthService.js +521 -0
- package/lib/module/core/auth/AuthService.js.map +1 -0
- package/lib/module/core/devices/DeviceService.js +57 -0
- package/lib/module/core/devices/DeviceService.js.map +1 -0
- package/lib/module/core/files/FileService.js +171 -0
- package/lib/module/core/files/FileService.js.map +1 -0
- package/lib/module/core/index.js +25 -1694
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/core/karma/KarmaService.js +95 -0
- package/lib/module/core/karma/KarmaService.js.map +1 -0
- package/lib/module/core/locations/LocationService.js +127 -0
- package/lib/module/core/locations/LocationService.js.map +1 -0
- package/lib/module/core/payments/PaymentService.js +119 -0
- package/lib/module/core/payments/PaymentService.js.map +1 -0
- package/lib/module/core/users/UserService.js +230 -0
- package/lib/module/core/users/UserService.js.map +1 -0
- package/lib/module/index.js +8 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/session.js +2 -0
- package/lib/{commonjs/types/middleware.js.map → module/models/session.js.map} +1 -1
- package/lib/module/ui/context/OxyContext.js +28 -24
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/screens/AccountSwitcherScreen.js +2 -2
- package/lib/module/ui/screens/AccountSwitcherScreen.js.map +1 -1
- package/lib/module/ui/screens/FileManagementScreen.js +12 -12
- package/lib/module/ui/screens/FileManagementScreen.js.map +1 -1
- package/lib/module/ui/screens/ProfileScreen.js +2 -2
- package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/module/ui/screens/SessionManagementScreen.js.map +1 -1
- package/lib/module/ui/screens/SignInScreen.js +1 -1
- package/lib/module/ui/screens/SignInScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaCenterScreen.js +1 -1
- package/lib/module/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js +1 -1
- package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaRulesScreen.js +1 -1
- package/lib/module/ui/screens/karma/KarmaRulesScreen.js.map +1 -1
- package/lib/module/ui/stores/followStore.js +4 -4
- package/lib/module/ui/stores/followStore.js.map +1 -1
- package/lib/module/utils/apiUtils.js +85 -0
- package/lib/module/utils/apiUtils.js.map +1 -0
- package/lib/module/utils/asyncUtils.js +202 -0
- package/lib/module/utils/asyncUtils.js.map +1 -0
- package/lib/module/utils/errorUtils.js +139 -0
- package/lib/module/utils/errorUtils.js.map +1 -0
- package/lib/module/utils/hookUtils.js +381 -0
- package/lib/module/utils/hookUtils.js.map +1 -0
- package/lib/module/utils/loggerUtils.js +149 -0
- package/lib/module/utils/loggerUtils.js.map +1 -0
- package/lib/module/utils/validationUtils.js +154 -0
- package/lib/module/utils/validationUtils.js.map +1 -0
- package/lib/typescript/core/OxyServices.d.ts +64 -0
- package/lib/typescript/core/OxyServices.d.ts.map +1 -0
- package/lib/typescript/core/OxyServicesMain.d.ts +33 -0
- package/lib/typescript/core/OxyServicesMain.d.ts.map +1 -0
- package/lib/typescript/core/analytics/AnalyticsService.d.ts +26 -0
- package/lib/typescript/core/analytics/AnalyticsService.d.ts.map +1 -0
- package/lib/typescript/core/auth/AuthService.d.ts +165 -0
- package/lib/typescript/core/auth/AuthService.d.ts.map +1 -0
- package/lib/typescript/core/devices/DeviceService.d.ts +20 -0
- package/lib/typescript/core/devices/DeviceService.d.ts.map +1 -0
- package/lib/typescript/core/files/FileService.d.ts +59 -0
- package/lib/typescript/core/files/FileService.d.ts.map +1 -0
- package/lib/typescript/core/index.d.ts +19 -657
- package/lib/typescript/core/index.d.ts.map +1 -1
- package/lib/typescript/core/karma/KarmaService.d.ts +50 -0
- package/lib/typescript/core/karma/KarmaService.d.ts.map +1 -0
- package/lib/typescript/core/locations/LocationService.d.ts +39 -0
- package/lib/typescript/core/locations/LocationService.d.ts.map +1 -0
- package/lib/typescript/core/payments/PaymentService.d.ts +50 -0
- package/lib/typescript/core/payments/PaymentService.d.ts.map +1 -0
- package/lib/typescript/core/users/UserService.d.ts +111 -0
- package/lib/typescript/core/users/UserService.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +7 -3
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/models/{secureSession.d.ts → session.d.ts} +4 -4
- package/lib/typescript/models/session.d.ts.map +1 -0
- package/lib/typescript/ui/context/OxyContext.d.ts +2 -2
- package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/utils/apiUtils.d.ts +61 -0
- package/lib/typescript/utils/apiUtils.d.ts.map +1 -0
- package/lib/typescript/utils/asyncUtils.d.ts +64 -0
- package/lib/typescript/utils/asyncUtils.d.ts.map +1 -0
- package/lib/typescript/utils/errorUtils.d.ts +45 -0
- package/lib/typescript/utils/errorUtils.d.ts.map +1 -0
- package/lib/typescript/utils/hookUtils.d.ts +102 -0
- package/lib/typescript/utils/hookUtils.d.ts.map +1 -0
- package/lib/typescript/utils/loggerUtils.d.ts +49 -0
- package/lib/typescript/utils/loggerUtils.d.ts.map +1 -0
- package/lib/typescript/utils/validationUtils.d.ts +80 -0
- package/lib/typescript/utils/validationUtils.d.ts.map +1 -0
- package/package.json +2 -8
- package/src/core/OxyServices.ts +168 -0
- package/src/core/OxyServicesMain.ts +57 -0
- package/src/core/analytics/AnalyticsService.ts +64 -0
- package/src/core/auth/AuthService.ts +544 -0
- package/src/core/devices/DeviceService.ts +55 -0
- package/src/core/files/FileService.ts +194 -0
- package/src/core/index.ts +26 -1769
- package/src/core/karma/KarmaService.ts +104 -0
- package/src/core/locations/LocationService.ts +141 -0
- package/src/core/payments/PaymentService.ts +133 -0
- package/src/core/users/UserService.ts +241 -0
- package/src/index.ts +29 -8
- package/src/models/{secureSession.ts → session.ts} +5 -5
- package/src/ui/context/OxyContext.tsx +34 -30
- package/src/ui/screens/AccountSwitcherScreen.tsx +4 -4
- package/src/ui/screens/FileManagementScreen.tsx +12 -12
- package/src/ui/screens/ProfileScreen.tsx +3 -3
- package/src/ui/screens/SessionManagementScreen.tsx +2 -2
- package/src/ui/screens/SignInScreen.tsx +1 -1
- package/src/ui/screens/karma/KarmaCenterScreen.tsx +2 -2
- package/src/ui/screens/karma/KarmaLeaderboardScreen.tsx +3 -3
- package/src/ui/screens/karma/KarmaRulesScreen.tsx +3 -3
- package/src/ui/stores/followStore.ts +4 -4
- package/src/utils/apiUtils.ts +102 -0
- package/src/utils/asyncUtils.ts +265 -0
- package/src/utils/errorUtils.ts +172 -0
- package/src/utils/hookUtils.ts +397 -0
- package/src/utils/loggerUtils.ts +153 -0
- package/src/utils/validationUtils.ts +158 -0
- package/lib/commonjs/models/secureSession.js +0 -2
- package/lib/commonjs/models/secureSession.js.map +0 -1
- package/lib/commonjs/types/middleware.js +0 -6
- package/lib/module/models/secureSession.js +0 -2
- package/lib/module/models/secureSession.js.map +0 -1
- package/lib/module/types/middleware.js +0 -4
- package/lib/typescript/models/secureSession.d.ts.map +0 -1
- package/lib/typescript/types/middleware.d.ts +0 -19
- package/lib/typescript/types/middleware.d.ts.map +0 -1
- package/src/types/middleware.ts +0 -20
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { OxyServices } from '../OxyServices';
|
|
2
|
+
import {
|
|
3
|
+
FileMetadata,
|
|
4
|
+
FileUploadResponse,
|
|
5
|
+
FileListResponse,
|
|
6
|
+
FileUpdateRequest,
|
|
7
|
+
FileDeleteResponse
|
|
8
|
+
} from '../../models/interfaces';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Default cloud URL for Oxy services, cloud is where the user files are. (e.g. images, videos, etc.). Not the API.
|
|
12
|
+
*/
|
|
13
|
+
export const OXY_CLOUD_URL = 'https://cloud.oxy.so';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* File service for handling file operations and management
|
|
17
|
+
*/
|
|
18
|
+
export class FileService extends OxyServices {
|
|
19
|
+
/**
|
|
20
|
+
* Upload a single file
|
|
21
|
+
* Note: This method is deprecated. Use the new raw upload approach instead.
|
|
22
|
+
*/
|
|
23
|
+
async uploadFile(
|
|
24
|
+
file: File | Blob | any, // Use 'any' to handle Buffer type in cross-platform scenarios
|
|
25
|
+
filename: string,
|
|
26
|
+
metadata?: Record<string, any>
|
|
27
|
+
): Promise<FileMetadata> {
|
|
28
|
+
try {
|
|
29
|
+
const formData = new FormData();
|
|
30
|
+
formData.append('file', file, filename);
|
|
31
|
+
|
|
32
|
+
if (metadata) {
|
|
33
|
+
formData.append('metadata', JSON.stringify(metadata));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const res = await this.getClient().post('/files/upload', formData, {
|
|
37
|
+
headers: {
|
|
38
|
+
'Content-Type': 'multipart/form-data'
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return res.data;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
throw this.handleError(error);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Upload multiple files
|
|
49
|
+
* Note: This method is deprecated. Use the new raw upload approach instead.
|
|
50
|
+
*/
|
|
51
|
+
async uploadFiles(
|
|
52
|
+
files: (File | Blob | any)[],
|
|
53
|
+
filenames: string[],
|
|
54
|
+
metadata?: Record<string, any>
|
|
55
|
+
): Promise<FileUploadResponse> {
|
|
56
|
+
try {
|
|
57
|
+
const formData = new FormData();
|
|
58
|
+
|
|
59
|
+
files.forEach((file, index) => {
|
|
60
|
+
formData.append('files', file, filenames[index]);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
if (metadata) {
|
|
64
|
+
formData.append('metadata', JSON.stringify(metadata));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const res = await this.getClient().post('/files/upload-multiple', formData, {
|
|
68
|
+
headers: {
|
|
69
|
+
'Content-Type': 'multipart/form-data'
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return res.data;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
throw this.handleError(error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Get file metadata
|
|
80
|
+
*/
|
|
81
|
+
async getFileMetadata(fileId: string): Promise<FileMetadata> {
|
|
82
|
+
try {
|
|
83
|
+
const res = await this.getClient().get(`/files/${fileId}/metadata`);
|
|
84
|
+
return res.data;
|
|
85
|
+
} catch (error) {
|
|
86
|
+
throw this.handleError(error);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Update file metadata
|
|
92
|
+
*/
|
|
93
|
+
async updateFileMetadata(fileId: string, updates: FileUpdateRequest): Promise<FileMetadata> {
|
|
94
|
+
try {
|
|
95
|
+
const res = await this.getClient().put(`/files/${fileId}/metadata`, updates);
|
|
96
|
+
return res.data;
|
|
97
|
+
} catch (error) {
|
|
98
|
+
throw this.handleError(error);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Delete file
|
|
104
|
+
*/
|
|
105
|
+
async deleteFile(fileId: string): Promise<FileDeleteResponse> {
|
|
106
|
+
try {
|
|
107
|
+
const res = await this.getClient().delete(`/files/${fileId}`);
|
|
108
|
+
return res.data;
|
|
109
|
+
} catch (error) {
|
|
110
|
+
throw this.handleError(error);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Get file download URL
|
|
116
|
+
*/
|
|
117
|
+
getFileDownloadUrl(fileId: string): string {
|
|
118
|
+
return `${OXY_CLOUD_URL}/files/${fileId}/download`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Get file stream URL
|
|
123
|
+
*/
|
|
124
|
+
getFileStreamUrl(fileId: string): string {
|
|
125
|
+
return `${OXY_CLOUD_URL}/files/${fileId}/stream`;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* List user files
|
|
130
|
+
*/
|
|
131
|
+
async listUserFiles(
|
|
132
|
+
userId: string,
|
|
133
|
+
limit?: number,
|
|
134
|
+
offset?: number,
|
|
135
|
+
filters?: Record<string, any>
|
|
136
|
+
): Promise<FileListResponse> {
|
|
137
|
+
try {
|
|
138
|
+
const params = new URLSearchParams();
|
|
139
|
+
if (limit) params.append('limit', limit.toString());
|
|
140
|
+
if (offset) params.append('offset', offset.toString());
|
|
141
|
+
|
|
142
|
+
if (filters) {
|
|
143
|
+
Object.entries(filters).forEach(([key, value]) => {
|
|
144
|
+
params.append(key, value.toString());
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const res = await this.getClient().get(`/files/user/${userId}?${params.toString()}`);
|
|
149
|
+
return res.data;
|
|
150
|
+
} catch (error) {
|
|
151
|
+
throw this.handleError(error);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Download file content
|
|
157
|
+
*/
|
|
158
|
+
async downloadFileContent(fileId: string): Promise<Response> {
|
|
159
|
+
try {
|
|
160
|
+
const res = await this.getClient().get(`/files/${fileId}/content`, {
|
|
161
|
+
responseType: 'blob'
|
|
162
|
+
});
|
|
163
|
+
return res.data;
|
|
164
|
+
} catch (error) {
|
|
165
|
+
throw this.handleError(error);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Get file content as text
|
|
171
|
+
*/
|
|
172
|
+
async getFileContentAsText(fileId: string): Promise<string> {
|
|
173
|
+
try {
|
|
174
|
+
const res = await this.getClient().get(`/files/${fileId}/content/text`);
|
|
175
|
+
return res.data;
|
|
176
|
+
} catch (error) {
|
|
177
|
+
throw this.handleError(error);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Get file content as blob
|
|
183
|
+
*/
|
|
184
|
+
async getFileContentAsBlob(fileId: string): Promise<Blob> {
|
|
185
|
+
try {
|
|
186
|
+
const res = await this.getClient().get(`/files/${fileId}/content/blob`, {
|
|
187
|
+
responseType: 'blob'
|
|
188
|
+
});
|
|
189
|
+
return res.data;
|
|
190
|
+
} catch (error) {
|
|
191
|
+
throw this.handleError(error);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|