@unvired/react-native-wrapper-sdk 0.0.24 → 0.0.25

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.
@@ -44,5 +44,46 @@ export declare class FileService {
44
44
  * @param filePath Absolute path to the file
45
45
  */
46
46
  fileExists(filePath: string): Promise<boolean>;
47
+ /**
48
+ * Creates a directory
49
+ * @param dirPath Parent directory path
50
+ * @param dirName Directory name to create
51
+ */
52
+ createDirectory(dirPath: string, dirName: string): Promise<IFileEntry>;
53
+ /**
54
+ * Lists files and directories in a directory
55
+ * @param dirPath Directory path to list
56
+ */
57
+ listDirectory(dirPath: string): Promise<IFileEntry[]>;
58
+ /**
59
+ * Deletes a directory and all its contents
60
+ * @param dirPath Directory path to delete
61
+ */
62
+ deleteDirectory(dirPath: string): Promise<void>;
63
+ /**
64
+ * Copies a file
65
+ * @param sourcePath Source file path
66
+ * @param destDir Destination directory path
67
+ * @param newName New file name (optional, keeps original name if not provided)
68
+ */
69
+ copyFile(sourcePath: string, destDir: string, newName?: string): Promise<void>;
70
+ /**
71
+ * Moves/renames a file
72
+ * @param sourcePath Source file path
73
+ * @param destDir Destination directory path
74
+ * @param newName New file name (optional, keeps original name if not provided)
75
+ */
76
+ moveFile(sourcePath: string, destDir: string, newName?: string): Promise<void>;
77
+ /**
78
+ * Gets file information (size, modification date, etc.)
79
+ * @param filePath File path
80
+ */
81
+ getFileInfo(filePath: string): Promise<any>;
82
+ /**
83
+ * Appends data to an existing file
84
+ * @param filePath File path
85
+ * @param data Data to append
86
+ */
87
+ appendToFile(filePath: string, data: ArrayBuffer | string): Promise<void>;
47
88
  }
48
89
  //# sourceMappingURL=FileService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FileService.d.ts","sourceRoot":"","sources":["../../../src/lib/file/FileService.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC7B,WAAW,CAAC,eAAe,EAAE,CAAC,OAAO,EAAE,UAAU,EAA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E,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsDtG;;;OAGG;IACG,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWzD;;;OAGG;IACG,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IASpD;;;;OAIG;IACG,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAkB5E;;;OAGG;IACG,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAY3D;;;OAGG;IACG,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWrD;;;;;OAKG;IACG,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWpF;;;;;OAKG;IACG,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQpF;;;OAGG;IACG,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAgBjD;;;;OAIG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAqClF"}
@@ -152,5 +152,116 @@ class FileService {
152
152
  return false;
153
153
  }
154
154
  }
155
+ /**
156
+ * Creates a directory
157
+ * @param dirPath Parent directory path
158
+ * @param dirName Directory name to create
159
+ */
160
+ async createDirectory(dirPath, dirName) {
161
+ const parentEntry = await this.resolveLocalFileSystemURL(dirPath);
162
+ return new Promise((resolve, reject) => {
163
+ if (!parentEntry.getDirectory) {
164
+ reject(new Error('getDirectory() method not available on entry'));
165
+ return;
166
+ }
167
+ parentEntry.getDirectory(dirName, { create: true }, (dirEntry) => resolve(dirEntry), (error) => reject(error));
168
+ });
169
+ }
170
+ /**
171
+ * Lists files and directories in a directory
172
+ * @param dirPath Directory path to list
173
+ */
174
+ async listDirectory(dirPath) {
175
+ const dirEntry = await this.resolveLocalFileSystemURL(dirPath);
176
+ return new Promise((resolve, reject) => {
177
+ const reader = dirEntry.createReader();
178
+ reader.readEntries((entries) => resolve(entries), (error) => reject(error));
179
+ });
180
+ }
181
+ /**
182
+ * Deletes a directory and all its contents
183
+ * @param dirPath Directory path to delete
184
+ */
185
+ async deleteDirectory(dirPath) {
186
+ const dirEntry = await this.resolveLocalFileSystemURL(dirPath);
187
+ return new Promise((resolve, reject) => {
188
+ dirEntry.removeRecursively(() => resolve(), (error) => reject(error));
189
+ });
190
+ }
191
+ /**
192
+ * Copies a file
193
+ * @param sourcePath Source file path
194
+ * @param destDir Destination directory path
195
+ * @param newName New file name (optional, keeps original name if not provided)
196
+ */
197
+ async copyFile(sourcePath, destDir, newName) {
198
+ // Read source file
199
+ const content = await this.readExternalFile(sourcePath);
200
+ // Get source file name if newName not provided
201
+ const fileName = newName || sourcePath.split('/').pop() || 'file';
202
+ // Write to destination
203
+ await this.writeExternalFile(destDir, fileName, content);
204
+ }
205
+ /**
206
+ * Moves/renames a file
207
+ * @param sourcePath Source file path
208
+ * @param destDir Destination directory path
209
+ * @param newName New file name (optional, keeps original name if not provided)
210
+ */
211
+ async moveFile(sourcePath, destDir, newName) {
212
+ // Copy file to destination
213
+ await this.copyFile(sourcePath, destDir, newName);
214
+ // Delete source file
215
+ await this.deleteExternalFile(sourcePath);
216
+ }
217
+ /**
218
+ * Gets file information (size, modification date, etc.)
219
+ * @param filePath File path
220
+ */
221
+ async getFileInfo(filePath) {
222
+ const fileEntry = await this.resolveLocalFileSystemURL(filePath);
223
+ return new Promise((resolve, reject) => {
224
+ if (!fileEntry.file) {
225
+ reject(new Error('file() method not available on entry'));
226
+ return;
227
+ }
228
+ fileEntry.file((fileMetadata) => resolve(fileMetadata), (error) => reject(error));
229
+ });
230
+ }
231
+ /**
232
+ * Appends data to an existing file
233
+ * @param filePath File path
234
+ * @param data Data to append
235
+ */
236
+ async appendToFile(filePath, data) {
237
+ // Convert data to string if it's ArrayBuffer
238
+ let content;
239
+ if (data instanceof ArrayBuffer) {
240
+ const decoder = new TextDecoder();
241
+ content = decoder.decode(data);
242
+ }
243
+ else {
244
+ content = data;
245
+ }
246
+ const fileEntry = await this.resolveLocalFileSystemURL(filePath);
247
+ return new Promise((resolve, reject) => {
248
+ if (!fileEntry.createWriter) {
249
+ reject(new Error('createWriter() method not available on file entry'));
250
+ return;
251
+ }
252
+ fileEntry.createWriter((writer) => {
253
+ writer.onwriteend = () => {
254
+ resolve();
255
+ };
256
+ writer.onerror = (error) => {
257
+ reject(error);
258
+ };
259
+ // Append the content
260
+ writer.append(content);
261
+ }, (error) => {
262
+ reject(error);
263
+ });
264
+ });
265
+ }
155
266
  }
156
267
  exports.FileService = FileService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unvired/react-native-wrapper-sdk",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "description": "Unvired SDK for React Native - Enterprise mobile platform SDK with authentication, sync, and offline database",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -163,4 +163,151 @@ export class FileService {
163
163
  }
164
164
  }
165
165
 
166
+ /**
167
+ * Creates a directory
168
+ * @param dirPath Parent directory path
169
+ * @param dirName Directory name to create
170
+ */
171
+ async createDirectory(dirPath: string, dirName: string): Promise<IFileEntry> {
172
+ const parentEntry = await this.resolveLocalFileSystemURL(dirPath);
173
+
174
+ return new Promise((resolve, reject) => {
175
+ if (!parentEntry.getDirectory) {
176
+ reject(new Error('getDirectory() method not available on entry'));
177
+ return;
178
+ }
179
+
180
+ parentEntry.getDirectory(
181
+ dirName,
182
+ { create: true },
183
+ (dirEntry: IFileEntry) => resolve(dirEntry),
184
+ (error: any) => reject(error)
185
+ );
186
+ });
187
+ }
188
+
189
+ /**
190
+ * Lists files and directories in a directory
191
+ * @param dirPath Directory path to list
192
+ */
193
+ async listDirectory(dirPath: string): Promise<IFileEntry[]> {
194
+ const dirEntry = await this.resolveLocalFileSystemURL(dirPath);
195
+
196
+ return new Promise((resolve, reject) => {
197
+ const reader = dirEntry.createReader();
198
+ reader.readEntries(
199
+ (entries: IFileEntry[]) => resolve(entries),
200
+ (error: any) => reject(error)
201
+ );
202
+ });
203
+ }
204
+
205
+ /**
206
+ * Deletes a directory and all its contents
207
+ * @param dirPath Directory path to delete
208
+ */
209
+ async deleteDirectory(dirPath: string): Promise<void> {
210
+ const dirEntry = await this.resolveLocalFileSystemURL(dirPath);
211
+
212
+ return new Promise((resolve, reject) => {
213
+ dirEntry.removeRecursively(
214
+ () => resolve(),
215
+ (error: any) => reject(error)
216
+ );
217
+ });
218
+ }
219
+
220
+ /**
221
+ * Copies a file
222
+ * @param sourcePath Source file path
223
+ * @param destDir Destination directory path
224
+ * @param newName New file name (optional, keeps original name if not provided)
225
+ */
226
+ async copyFile(sourcePath: string, destDir: string, newName?: string): Promise<void> {
227
+ // Read source file
228
+ const content = await this.readExternalFile(sourcePath);
229
+
230
+ // Get source file name if newName not provided
231
+ const fileName = newName || sourcePath.split('/').pop() || 'file';
232
+
233
+ // Write to destination
234
+ await this.writeExternalFile(destDir, fileName, content);
235
+ }
236
+
237
+ /**
238
+ * Moves/renames a file
239
+ * @param sourcePath Source file path
240
+ * @param destDir Destination directory path
241
+ * @param newName New file name (optional, keeps original name if not provided)
242
+ */
243
+ async moveFile(sourcePath: string, destDir: string, newName?: string): Promise<void> {
244
+ // Copy file to destination
245
+ await this.copyFile(sourcePath, destDir, newName);
246
+
247
+ // Delete source file
248
+ await this.deleteExternalFile(sourcePath);
249
+ }
250
+
251
+ /**
252
+ * Gets file information (size, modification date, etc.)
253
+ * @param filePath File path
254
+ */
255
+ async getFileInfo(filePath: string): Promise<any> {
256
+ const fileEntry = await this.resolveLocalFileSystemURL(filePath);
257
+
258
+ return new Promise((resolve, reject) => {
259
+ if (!fileEntry.file) {
260
+ reject(new Error('file() method not available on entry'));
261
+ return;
262
+ }
263
+
264
+ fileEntry.file(
265
+ (fileMetadata: any) => resolve(fileMetadata),
266
+ (error: any) => reject(error)
267
+ );
268
+ });
269
+ }
270
+
271
+ /**
272
+ * Appends data to an existing file
273
+ * @param filePath File path
274
+ * @param data Data to append
275
+ */
276
+ async appendToFile(filePath: string, data: ArrayBuffer | string): Promise<void> {
277
+ // Convert data to string if it's ArrayBuffer
278
+ let content: string;
279
+ if (data instanceof ArrayBuffer) {
280
+ const decoder = new TextDecoder();
281
+ content = decoder.decode(data);
282
+ } else {
283
+ content = data;
284
+ }
285
+
286
+ const fileEntry = await this.resolveLocalFileSystemURL(filePath);
287
+
288
+ return new Promise((resolve, reject) => {
289
+ if (!fileEntry.createWriter) {
290
+ reject(new Error('createWriter() method not available on file entry'));
291
+ return;
292
+ }
293
+
294
+ fileEntry.createWriter(
295
+ (writer: any) => {
296
+ writer.onwriteend = () => {
297
+ resolve();
298
+ };
299
+ writer.onerror = (error: any) => {
300
+ reject(error);
301
+ };
302
+
303
+ // Append the content
304
+ writer.append(content);
305
+ },
306
+ (error: any) => {
307
+ reject(error);
308
+ }
309
+ );
310
+ });
311
+ }
312
+
166
313
  }