react-native-cloud-storage 0.4.1 → 0.4.2

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 (59) hide show
  1. package/lib/commonjs/RNCloudStorage.js +2 -2
  2. package/lib/commonjs/RNCloudStorage.js.map +1 -1
  3. package/lib/commonjs/createRNCloudStorage.js +5 -5
  4. package/lib/commonjs/createRNCloudStorage.js.map +1 -1
  5. package/lib/commonjs/google-drive/index.js +7 -7
  6. package/lib/commonjs/google-drive/index.js.map +1 -1
  7. package/lib/commonjs/hooks/useCloudFile.js.map +1 -1
  8. package/lib/commonjs/index.js +7 -7
  9. package/lib/commonjs/index.js.map +1 -1
  10. package/lib/commonjs/types/main.js +6 -6
  11. package/lib/commonjs/types/main.js.map +1 -1
  12. package/lib/commonjs/types/native.js +13 -13
  13. package/lib/commonjs/types/native.js.map +1 -1
  14. package/lib/commonjs/utils/{NativeStorageError.js → CloudStorageError.js} +3 -3
  15. package/lib/commonjs/utils/CloudStorageError.js.map +1 -0
  16. package/lib/module/RNCloudStorage.js +2 -2
  17. package/lib/module/RNCloudStorage.js.map +1 -1
  18. package/lib/module/createRNCloudStorage.js +6 -6
  19. package/lib/module/createRNCloudStorage.js.map +1 -1
  20. package/lib/module/google-drive/index.js +8 -8
  21. package/lib/module/google-drive/index.js.map +1 -1
  22. package/lib/module/hooks/useCloudFile.js.map +1 -1
  23. package/lib/module/index.js +4 -4
  24. package/lib/module/index.js.map +1 -1
  25. package/lib/module/types/main.js +4 -4
  26. package/lib/module/types/main.js.map +1 -1
  27. package/lib/module/types/native.js +11 -11
  28. package/lib/module/types/native.js.map +1 -1
  29. package/lib/module/utils/CloudStorageError.js +9 -0
  30. package/lib/module/utils/CloudStorageError.js.map +1 -0
  31. package/lib/typescript/RNCloudStorage.d.ts +8 -8
  32. package/lib/typescript/RNCloudStorage.d.ts.map +1 -1
  33. package/lib/typescript/google-drive/index.d.ts +8 -8
  34. package/lib/typescript/google-drive/index.d.ts.map +1 -1
  35. package/lib/typescript/hooks/useCloudFile.d.ts +2 -2
  36. package/lib/typescript/hooks/useCloudFile.d.ts.map +1 -1
  37. package/lib/typescript/index.d.ts +4 -4
  38. package/lib/typescript/index.d.ts.map +1 -1
  39. package/lib/typescript/types/main.d.ts +2 -2
  40. package/lib/typescript/types/main.d.ts.map +1 -1
  41. package/lib/typescript/types/native.d.ts +8 -8
  42. package/lib/typescript/types/native.d.ts.map +1 -1
  43. package/lib/typescript/utils/CloudStorageError.d.ts +8 -0
  44. package/lib/typescript/utils/CloudStorageError.d.ts.map +1 -0
  45. package/package.json +1 -1
  46. package/src/RNCloudStorage.ts +8 -8
  47. package/src/createRNCloudStorage.ts +6 -6
  48. package/src/google-drive/index.ts +29 -24
  49. package/src/hooks/useCloudFile.ts +2 -2
  50. package/src/index.ts +4 -4
  51. package/src/types/main.ts +2 -2
  52. package/src/types/native.ts +8 -8
  53. package/src/utils/CloudStorageError.ts +14 -0
  54. package/lib/commonjs/utils/NativeStorageError.js.map +0 -1
  55. package/lib/module/utils/NativeStorageError.js +0 -9
  56. package/lib/module/utils/NativeStorageError.js.map +0 -1
  57. package/lib/typescript/utils/NativeStorageError.d.ts +0 -8
  58. package/lib/typescript/utils/NativeStorageError.d.ts.map +0 -1
  59. package/src/utils/NativeStorageError.ts +0 -14
@@ -0,0 +1,9 @@
1
+ class CloudStorageError extends Error {
2
+ constructor(message, code, details) {
3
+ super(message);
4
+ this.code = code;
5
+ this.details = details;
6
+ }
7
+ }
8
+ export default CloudStorageError;
9
+ //# sourceMappingURL=CloudStorageError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CloudStorageError","Error","constructor","message","code","details"],"sourceRoot":"../../../src","sources":["utils/CloudStorageError.ts"],"mappings":"AAEA,MAAMA,iBAAiB,SAASC,KAAK,CAAC;EAIpCC,WAAWA,CAACC,OAAe,EAAEC,IAA2B,EAAEC,OAAa,EAAE;IACvE,KAAK,CAACF,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,OAAO,GAAGA,OAAO;EACxB;AACF;AAEA,eAAeL,iBAAiB"}
@@ -1,6 +1,6 @@
1
- import type { StorageFileStat, StorageScope } from './types/main';
1
+ import type { CloudStorageFileStat, CloudStorageScope } from './types/main';
2
2
  declare const RNCloudStorage: {
3
- googleDriveAccessToken: string;
3
+ getGoogleDriveAccessToken: () => string | undefined;
4
4
  setGoogleDriveAccessToken: (accessToken: string) => string;
5
5
  /**
6
6
  * Tests whether or not the cloud storage is available. Always returns true for Google Drive. iCloud may be
@@ -14,7 +14,7 @@ declare const RNCloudStorage: {
14
14
  * @param scope The directory scope the path is in.
15
15
  * @returns A promise that resolves to true if the path exists, false otherwise.
16
16
  */
17
- exists: (path: string, scope: StorageScope) => Promise<boolean>;
17
+ exists: (path: string, scope: CloudStorageScope) => Promise<boolean>;
18
18
  /**
19
19
  * Writes to the file at the given path, creating it if it doesn't exist or overwriting it if it does.
20
20
  * @param path The file to write to.
@@ -22,28 +22,28 @@ declare const RNCloudStorage: {
22
22
  * @param scope The directory scope the path is in.
23
23
  * @returns A promise that resolves when the file has been written.
24
24
  */
25
- writeFile: (path: string, data: string, scope: StorageScope) => Promise<void>;
25
+ writeFile: (path: string, data: string, scope: CloudStorageScope) => Promise<void>;
26
26
  /**
27
27
  * Reads the contents of the file at the given path.
28
28
  * @param path The file to read.
29
29
  * @param scope The directory scope the path is in.
30
30
  * @returns A promise that resolves to the contents of the file.
31
31
  */
32
- readFile: (path: string, scope: StorageScope) => Promise<string>;
32
+ readFile: (path: string, scope: CloudStorageScope) => Promise<string>;
33
33
  /**
34
34
  * Deletes the file at the given path.
35
35
  * @param path The file to delete.
36
36
  * @param scope The directory scope the path is in.
37
37
  * @returns A promise that resolves when the file has been deleted.
38
38
  */
39
- unlink: (path: string, scope: StorageScope) => Promise<void>;
39
+ unlink: (path: string, scope: CloudStorageScope) => Promise<void>;
40
40
  /**
41
41
  * Gets the size, creation time, and modification time of the file at the given path.
42
42
  * @param path The file to stat.
43
43
  * @param scope The directory scope the path is in.
44
- * @returns A promise that resolves to the StorageFileStat object.
44
+ * @returns A promise that resolves to the CloudStorageFileStat object.
45
45
  */
46
- stat: (path: string, scope: StorageScope) => Promise<StorageFileStat>;
46
+ stat: (path: string, scope: CloudStorageScope) => Promise<CloudStorageFileStat>;
47
47
  };
48
48
  export default RNCloudStorage;
49
49
  //# sourceMappingURL=RNCloudStorage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RNCloudStorage.d.ts","sourceRoot":"","sources":["../../src/RNCloudStorage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGlE,QAAA,MAAM,cAAc;;6CAEuB,MAAM;IAE/C;;;;OAIG;4BACyB,QAAQ,OAAO,CAAC;IAI5C;;;;;OAKG;mBACY,MAAM,SAAS,YAAY,KAAG,QAAQ,OAAO,CAAC;IAI7D;;;;;;OAMG;sBACe,MAAM,QAAQ,MAAM,SAAS,YAAY,KAAG,QAAQ,IAAI,CAAC;IAI3E;;;;;OAKG;qBACc,MAAM,SAAS,YAAY,KAAG,QAAQ,MAAM,CAAC;IAI9D;;;;;OAKG;mBACY,MAAM,SAAS,YAAY,KAAG,QAAQ,IAAI,CAAC;IAI1D;;;;;OAKG;iBACgB,MAAM,SAAS,YAAY,KAAG,QAAQ,eAAe,CAAC;CAW1E,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"RNCloudStorage.d.ts","sourceRoot":"","sources":["../../src/RNCloudStorage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAG5E,QAAA,MAAM,cAAc;;6CAEuB,MAAM;IAE/C;;;;OAIG;4BACyB,QAAQ,OAAO,CAAC;IAI5C;;;;;OAKG;mBACY,MAAM,SAAS,iBAAiB,KAAG,QAAQ,OAAO,CAAC;IAIlE;;;;;;OAMG;sBACe,MAAM,QAAQ,MAAM,SAAS,iBAAiB,KAAG,QAAQ,IAAI,CAAC;IAIhF;;;;;OAKG;qBACc,MAAM,SAAS,iBAAiB,KAAG,QAAQ,MAAM,CAAC;IAInE;;;;;OAKG;mBACY,MAAM,SAAS,iBAAiB,KAAG,QAAQ,IAAI,CAAC;IAI/D;;;;;OAKG;iBACgB,MAAM,SAAS,iBAAiB,KAAG,QAAQ,oBAAoB,CAAC;CAWpF,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1,21 +1,21 @@
1
1
  import type NativeRNCloudStorage from '../types/native';
2
- import { type NativeRNCloudStorageFileStat, type NativeRNCloudStorageScope } from '../types/native';
2
+ import { type NativeRNCloudCloudStorageFileStat, type NativeRNCloudCloudStorageScope } from '../types/native';
3
3
  declare class GoogleDriveApiClient implements NativeRNCloudStorage {
4
4
  private static drive;
5
5
  constructor();
6
- static set accessToken(accessToken: string);
7
- static get accessToken(): string;
6
+ static set accessToken(accessToken: string | undefined);
7
+ static get accessToken(): string | undefined;
8
8
  isCloudAvailable: () => Promise<boolean>;
9
9
  private getRootDirectory;
10
10
  private resolvePathToDirectories;
11
11
  private findParentDirectoryId;
12
12
  private listFiles;
13
13
  private getFileId;
14
- fileExists(path: string, scope: NativeRNCloudStorageScope): Promise<boolean>;
15
- createFile(path: string, data: string, scope: NativeRNCloudStorageScope, overwrite: boolean): Promise<void>;
16
- readFile(path: string, scope: NativeRNCloudStorageScope): Promise<string>;
17
- deleteFile(path: string, scope: NativeRNCloudStorageScope): Promise<void>;
18
- statFile(path: string, scope: NativeRNCloudStorageScope): Promise<NativeRNCloudStorageFileStat>;
14
+ fileExists(path: string, scope: NativeRNCloudCloudStorageScope): Promise<boolean>;
15
+ createFile(path: string, data: string, scope: NativeRNCloudCloudStorageScope, overwrite: boolean): Promise<void>;
16
+ readFile(path: string, scope: NativeRNCloudCloudStorageScope): Promise<string>;
17
+ deleteFile(path: string, scope: NativeRNCloudCloudStorageScope): Promise<void>;
18
+ statFile(path: string, scope: NativeRNCloudCloudStorageScope): Promise<NativeRNCloudCloudStorageFileStat>;
19
19
  }
20
20
  export default GoogleDriveApiClient;
21
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/google-drive/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,oBAAoB,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAEL,KAAK,4BAA4B,EACjC,KAAK,yBAAyB,EAC/B,MAAM,iBAAiB,CAAC;AAIzB,cAAM,oBAAqB,YAAW,oBAAoB;IACxD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAwB;;IAsB5C,WAAkB,WAAW,CAAC,WAAW,EAAE,MAAM,EAEhD;IAED,WAAkB,WAAW,IAAI,MAAM,CAEtC;IAEM,gBAAgB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAA0D;IAEzG,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,wBAAwB;IAQhC,OAAO,CAAC,qBAAqB;YAiDf,SAAS;YAST,SAAS;IAgBjB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,OAAO,CAAC;IAU5E,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA2B3G,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC;IAMzE,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC;IAKzE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,4BAA4B,CAAC;CAatG;AAED,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/google-drive/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,oBAAoB,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAEL,KAAK,iCAAiC,EACtC,KAAK,8BAA8B,EACpC,MAAM,iBAAiB,CAAC;AAIzB,cAAM,oBAAqB,YAAW,oBAAoB;IACxD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAwB;;IAsB5C,WAAkB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,EAE5D;IAED,WAAkB,WAAW,IAAI,MAAM,GAAG,SAAS,CAElD;IAEM,gBAAgB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAA0D;IAEzG,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,wBAAwB;IAQhC,OAAO,CAAC,qBAAqB;YAiDf,SAAS;YAST,SAAS;IAgBjB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,OAAO,CAAC;IAUjF,UAAU,CACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,8BAA8B,EACrC,SAAS,EAAE,OAAO,GACjB,OAAO,CAAC,IAAI,CAAC;IA2BV,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,MAAM,CAAC;IAM9E,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,IAAI,CAAC;IAK9E,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,iCAAiC,CAAC;CAahH;AAED,eAAe,oBAAoB,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { StorageScope } from '../types/main';
2
- export declare const useCloudFile: (path: string, scope: StorageScope) => {
1
+ import type { CloudStorageScope } from '../types/main';
2
+ export declare const useCloudFile: (path: string, scope: CloudStorageScope) => {
3
3
  content: string | null;
4
4
  read: () => Promise<void>;
5
5
  update: (newContent: string) => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"useCloudFile.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCloudFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAIlD,eAAO,MAAM,YAAY,SAAU,MAAM,SAAS,YAAY;;;yBAiBvC,MAAM;;CAkB5B,CAAC"}
1
+ {"version":3,"file":"useCloudFile.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCloudFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAIvD,eAAO,MAAM,YAAY,SAAU,MAAM,SAAS,iBAAiB;;;yBAiB5C,MAAM;;CAkB5B,CAAC"}
@@ -1,10 +1,10 @@
1
1
  import RNCloudStorage from './RNCloudStorage';
2
- import { NativeStorageErrorCode } from './types/native';
2
+ import { CloudStorageErrorCode } from './types/native';
3
3
  export * from './types/main';
4
4
  export * from './hooks/useCloudFile';
5
5
  export * from './hooks/useIsCloudAvailable';
6
- import NativeStorageError from './utils/NativeStorageError';
7
- export { NativeStorageError };
8
- export { NativeStorageErrorCode };
6
+ import CloudStorageError from './utils/CloudStorageError';
7
+ export { CloudStorageError };
8
+ export { CloudStorageErrorCode };
9
9
  export default RNCloudStorage;
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,OAAO,iBAAiB,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,CAAC;AACjC,eAAe,cAAc,CAAC"}
@@ -1,8 +1,8 @@
1
- export declare enum StorageScope {
1
+ export declare enum CloudStorageScope {
2
2
  Documents = "documents",
3
3
  AppData = "app_data"
4
4
  }
5
- export interface StorageFileStat {
5
+ export interface CloudStorageFileStat {
6
6
  size: number;
7
7
  birthtimeMs: number;
8
8
  mtimeMs: number;
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/types/main.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,SAAS,cAAc;IACvB,OAAO,aAAa;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,EAAE,IAAI,CAAC;IACZ,WAAW,EAAE,MAAM,OAAO,CAAC;IAC3B,MAAM,EAAE,MAAM,OAAO,CAAC;CACvB"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/types/main.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB;IAC3B,SAAS,cAAc;IACvB,OAAO,aAAa;CACrB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,EAAE,IAAI,CAAC;IACZ,WAAW,EAAE,MAAM,OAAO,CAAC;IAC3B,MAAM,EAAE,MAAM,OAAO,CAAC;CACvB"}
@@ -1,12 +1,12 @@
1
- export type NativeRNCloudStorageScope = 'documents' | 'app_data';
2
- export interface NativeRNCloudStorageFileStat {
1
+ export type NativeRNCloudCloudStorageScope = 'documents' | 'app_data';
2
+ export interface NativeRNCloudCloudStorageFileStat {
3
3
  size: number;
4
4
  birthtimeMs: number;
5
5
  mtimeMs: number;
6
6
  isDirectory: boolean;
7
7
  isFile: boolean;
8
8
  }
9
- export declare enum NativeStorageErrorCode {
9
+ export declare enum CloudStorageErrorCode {
10
10
  FILE_NOT_FOUND = "ERR_FILE_NOT_FOUND",
11
11
  DIRECTORY_NOT_FOUND = "ERR_NO_DIRECTORY_FOUND",
12
12
  FILE_ALREADY_EXISTS = "ERR_FILE_EXISTS",
@@ -18,11 +18,11 @@ export declare enum NativeStorageErrorCode {
18
18
  GOOGLE_DRIVE_ACCESS_TOKEN_MISSING = "ERR_GOOGLE_DRIVE_ACCESS_TOKEN_MISSING"
19
19
  }
20
20
  export default interface NativeRNCloudStorage {
21
- fileExists: (path: string, scope: NativeRNCloudStorageScope) => Promise<boolean>;
22
- createFile: (path: string, data: string, scope: NativeRNCloudStorageScope, overwrite: boolean) => Promise<void>;
23
- readFile: (path: string, scope: NativeRNCloudStorageScope) => Promise<string>;
24
- deleteFile: (path: string, scope: NativeRNCloudStorageScope) => Promise<void>;
25
- statFile: (path: string, scope: NativeRNCloudStorageScope) => Promise<NativeRNCloudStorageFileStat>;
21
+ fileExists: (path: string, scope: NativeRNCloudCloudStorageScope) => Promise<boolean>;
22
+ createFile: (path: string, data: string, scope: NativeRNCloudCloudStorageScope, overwrite: boolean) => Promise<void>;
23
+ readFile: (path: string, scope: NativeRNCloudCloudStorageScope) => Promise<string>;
24
+ deleteFile: (path: string, scope: NativeRNCloudCloudStorageScope) => Promise<void>;
25
+ statFile: (path: string, scope: NativeRNCloudCloudStorageScope) => Promise<NativeRNCloudCloudStorageFileStat>;
26
26
  isCloudAvailable: () => Promise<boolean>;
27
27
  }
28
28
  //# sourceMappingURL=native.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../src/types/native.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,yBAAyB,GAAG,WAAW,GAAG,UAAU,CAAC;AAEjE,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,oBAAY,sBAAsB;IAChC,cAAc,uBAAuB;IACrC,mBAAmB,2BAA2B;IAC9C,mBAAmB,oBAAoB;IACvC,WAAW,oBAAoB;IAC/B,UAAU,mBAAmB;IAC7B,YAAY,qBAAqB;IACjC,UAAU,mBAAmB;IAC7B,OAAO,gBAAgB;IACvB,iCAAiC,0CAA0C;CAC5E;AAED,MAAM,CAAC,OAAO,WAAW,oBAAoB;IAC3C,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjF,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,EAAE,SAAS,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChH,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9E,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9E,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,KAAK,OAAO,CAAC,4BAA4B,CAAC,CAAC;IACpG,gBAAgB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1C"}
1
+ {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../../src/types/native.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,8BAA8B,GAAG,WAAW,GAAG,UAAU,CAAC;AAEtE,MAAM,WAAW,iCAAiC;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,oBAAY,qBAAqB;IAC/B,cAAc,uBAAuB;IACrC,mBAAmB,2BAA2B;IAC9C,mBAAmB,oBAAoB;IACvC,WAAW,oBAAoB;IAC/B,UAAU,mBAAmB;IAC7B,YAAY,qBAAqB;IACjC,UAAU,mBAAmB;IAC7B,OAAO,gBAAgB;IACvB,iCAAiC,0CAA0C;CAC5E;AAED,MAAM,CAAC,OAAO,WAAW,oBAAoB;IAC3C,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACtF,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B,EAAE,SAAS,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrH,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACnF,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACnF,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B,KAAK,OAAO,CAAC,iCAAiC,CAAC,CAAC;IAC9G,gBAAgB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1C"}
@@ -0,0 +1,8 @@
1
+ import type { CloudStorageErrorCode } from '../types/native';
2
+ declare class CloudStorageError extends Error {
3
+ code: CloudStorageErrorCode;
4
+ details?: any;
5
+ constructor(message: string, code: CloudStorageErrorCode, details?: any);
6
+ }
7
+ export default CloudStorageError;
8
+ //# sourceMappingURL=CloudStorageError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CloudStorageError.d.ts","sourceRoot":"","sources":["../../../src/utils/CloudStorageError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,cAAM,iBAAkB,SAAQ,KAAK;IACnC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,CAAC,EAAE,GAAG,CAAC;gBAEF,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,EAAE,OAAO,CAAC,EAAE,GAAG;CAKxE;AAED,eAAe,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-cloud-storage",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Save to & read from iCloud and Google Drive using React Native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -1,10 +1,10 @@
1
1
  import createRNCloudStorage from './createRNCloudStorage';
2
2
  import GoogleDriveApiClient from './google-drive';
3
- import type { StorageFileStat, StorageScope } from './types/main';
3
+ import type { CloudStorageFileStat, CloudStorageScope } from './types/main';
4
4
 
5
5
  const nativeInstance = createRNCloudStorage();
6
6
  const RNCloudStorage = {
7
- googleDriveAccessToken: GoogleDriveApiClient.accessToken,
7
+ getGoogleDriveAccessToken: () => GoogleDriveApiClient.accessToken,
8
8
  setGoogleDriveAccessToken: (accessToken: string) => (GoogleDriveApiClient.accessToken = accessToken),
9
9
 
10
10
  /**
@@ -22,7 +22,7 @@ const RNCloudStorage = {
22
22
  * @param scope The directory scope the path is in.
23
23
  * @returns A promise that resolves to true if the path exists, false otherwise.
24
24
  */
25
- exists: (path: string, scope: StorageScope): Promise<boolean> => {
25
+ exists: (path: string, scope: CloudStorageScope): Promise<boolean> => {
26
26
  return nativeInstance.fileExists(path, scope);
27
27
  },
28
28
 
@@ -33,7 +33,7 @@ const RNCloudStorage = {
33
33
  * @param scope The directory scope the path is in.
34
34
  * @returns A promise that resolves when the file has been written.
35
35
  */
36
- writeFile: (path: string, data: string, scope: StorageScope): Promise<void> => {
36
+ writeFile: (path: string, data: string, scope: CloudStorageScope): Promise<void> => {
37
37
  return nativeInstance.createFile(path, data, scope, true);
38
38
  },
39
39
 
@@ -43,7 +43,7 @@ const RNCloudStorage = {
43
43
  * @param scope The directory scope the path is in.
44
44
  * @returns A promise that resolves to the contents of the file.
45
45
  */
46
- readFile: (path: string, scope: StorageScope): Promise<string> => {
46
+ readFile: (path: string, scope: CloudStorageScope): Promise<string> => {
47
47
  return nativeInstance.readFile(path, scope);
48
48
  },
49
49
 
@@ -53,7 +53,7 @@ const RNCloudStorage = {
53
53
  * @param scope The directory scope the path is in.
54
54
  * @returns A promise that resolves when the file has been deleted.
55
55
  */
56
- unlink: (path: string, scope: StorageScope): Promise<void> => {
56
+ unlink: (path: string, scope: CloudStorageScope): Promise<void> => {
57
57
  return nativeInstance.deleteFile(path, scope);
58
58
  },
59
59
 
@@ -61,9 +61,9 @@ const RNCloudStorage = {
61
61
  * Gets the size, creation time, and modification time of the file at the given path.
62
62
  * @param path The file to stat.
63
63
  * @param scope The directory scope the path is in.
64
- * @returns A promise that resolves to the StorageFileStat object.
64
+ * @returns A promise that resolves to the CloudStorageFileStat object.
65
65
  */
66
- stat: async (path: string, scope: StorageScope): Promise<StorageFileStat> => {
66
+ stat: async (path: string, scope: CloudStorageScope): Promise<CloudStorageFileStat> => {
67
67
  const native = await nativeInstance.statFile(path, scope);
68
68
 
69
69
  return {
@@ -1,8 +1,8 @@
1
1
  import { NativeModules, Platform } from 'react-native';
2
2
  import type NativeRNCloudStorage from './types/native';
3
3
  import GoogleDriveApiClient from './google-drive';
4
- import { NativeStorageErrorCode } from './types/native';
5
- import NativeStorageError from './utils/NativeStorageError';
4
+ import { CloudStorageErrorCode } from './types/native';
5
+ import CloudStorageError from './utils/CloudStorageError';
6
6
 
7
7
  const LINKING_ERROR =
8
8
  `The package 'react-native-cloud-storage' doesn't seem to be linked. Make sure: \n\n` +
@@ -10,7 +10,7 @@ const LINKING_ERROR =
10
10
  '- You rebuilt the app after installing the package\n' +
11
11
  '- You are not using Expo Go\n';
12
12
 
13
- // proxy NativeModules.CloudStorage to catch any errors thrown by the native module and wrap them in a NativeStorageError
13
+ // proxy NativeModules.CloudStorage to catch any errors thrown by the native module and wrap them in a CloudStorageError
14
14
  const nativeIosInstance = NativeModules.CloudStorage
15
15
  ? new Proxy(NativeModules.CloudStorage, {
16
16
  get(target: NativeRNCloudStorage, prop: keyof NativeRNCloudStorage) {
@@ -21,10 +21,10 @@ const nativeIosInstance = NativeModules.CloudStorage
21
21
  // @ts-expect-error - we can't know the types of the functions and their arguments
22
22
  return await originalFunction(...args);
23
23
  } catch (error: any) {
24
- if (error?.code && Object.values(NativeStorageErrorCode).includes(error.code)) {
25
- throw new NativeStorageError(error?.message || '', error.code as NativeStorageErrorCode);
24
+ if (error?.code && Object.values(CloudStorageErrorCode).includes(error.code)) {
25
+ throw new CloudStorageError(error?.message || '', error.code as CloudStorageErrorCode);
26
26
  } else {
27
- throw new NativeStorageError('Unknown error', NativeStorageErrorCode.UNKNOWN, error);
27
+ throw new CloudStorageError('Unknown error', CloudStorageErrorCode.UNKNOWN, error);
28
28
  }
29
29
  }
30
30
  };
@@ -1,12 +1,12 @@
1
1
  import { GDrive, MimeTypes } from 'react-native-google-drive-api-wrapper-js';
2
2
  import type NativeRNCloudStorage from '../types/native';
3
3
  import {
4
- NativeStorageErrorCode,
5
- type NativeRNCloudStorageFileStat,
6
- type NativeRNCloudStorageScope,
4
+ CloudStorageErrorCode,
5
+ type NativeRNCloudCloudStorageFileStat,
6
+ type NativeRNCloudCloudStorageScope,
7
7
  } from '../types/native';
8
8
  import type { GoogleDriveDetailedFile, GoogleDriveFile, GoogleDriveListOperationResponse } from './types';
9
- import NativeStorageError from '../utils/NativeStorageError';
9
+ import CloudStorageError from '../utils/CloudStorageError';
10
10
 
11
11
  class GoogleDriveApiClient implements NativeRNCloudStorage {
12
12
  private static drive: GDrive = new GDrive();
@@ -18,9 +18,9 @@ class GoogleDriveApiClient implements NativeRNCloudStorage {
18
18
  get(target: GoogleDriveApiClient, prop: keyof GoogleDriveApiClient) {
19
19
  if (typeof target[prop] === 'function' && prop !== 'isCloudAvailable') {
20
20
  if (!GoogleDriveApiClient.drive.accessToken) {
21
- throw new NativeStorageError(
21
+ throw new CloudStorageError(
22
22
  `Google Drive access token is not set, cannot call function ${prop.toString()}`,
23
- NativeStorageErrorCode.GOOGLE_DRIVE_ACCESS_TOKEN_MISSING
23
+ CloudStorageErrorCode.GOOGLE_DRIVE_ACCESS_TOKEN_MISSING
24
24
  );
25
25
  }
26
26
  }
@@ -31,17 +31,17 @@ class GoogleDriveApiClient implements NativeRNCloudStorage {
31
31
  }
32
32
 
33
33
  // when setting accessToken, set it on the GDrive instance
34
- public static set accessToken(accessToken: string) {
34
+ public static set accessToken(accessToken: string | undefined) {
35
35
  GoogleDriveApiClient.drive.accessToken = accessToken;
36
36
  }
37
37
 
38
- public static get accessToken(): string {
38
+ public static get accessToken(): string | undefined {
39
39
  return GoogleDriveApiClient.drive.accessToken;
40
40
  }
41
41
 
42
42
  public isCloudAvailable: () => Promise<boolean> = async () => !!GoogleDriveApiClient.accessToken?.length;
43
43
 
44
- private getRootDirectory(scope: NativeRNCloudStorageScope): 'drive' | 'appDataFolder' {
44
+ private getRootDirectory(scope: NativeRNCloudCloudStorageScope): 'drive' | 'appDataFolder' {
45
45
  switch (scope) {
46
46
  case 'documents':
47
47
  return 'drive';
@@ -80,9 +80,9 @@ class GoogleDriveApiClient implements NativeRNCloudStorage {
80
80
  }
81
81
 
82
82
  if (!topDirectoryId) {
83
- throw new NativeStorageError(
83
+ throw new CloudStorageError(
84
84
  `Could not find top directory with name ${directoryTree[0]}`,
85
- NativeStorageErrorCode.DIRECTORY_NOT_FOUND
85
+ CloudStorageErrorCode.DIRECTORY_NOT_FOUND
86
86
  );
87
87
  }
88
88
 
@@ -91,15 +91,15 @@ class GoogleDriveApiClient implements NativeRNCloudStorage {
91
91
  for (let i = 1; i < directoryTree.length; i++) {
92
92
  const currentDirectory = files.find((f) => f.id === currentDirectoryId);
93
93
  if (!currentDirectory)
94
- throw new NativeStorageError(
94
+ throw new CloudStorageError(
95
95
  `Could not find directory with id ${currentDirectoryId}`,
96
- NativeStorageErrorCode.DIRECTORY_NOT_FOUND
96
+ CloudStorageErrorCode.DIRECTORY_NOT_FOUND
97
97
  );
98
98
  const nextDirectory = files.find((f) => f.name === directoryTree[i] && f.parents![0] === currentDirectoryId);
99
99
  if (!nextDirectory)
100
- throw new NativeStorageError(
100
+ throw new CloudStorageError(
101
101
  `Could not find directory with name ${directoryTree[i]}`,
102
- NativeStorageErrorCode.DIRECTORY_NOT_FOUND
102
+ CloudStorageErrorCode.DIRECTORY_NOT_FOUND
103
103
  );
104
104
  currentDirectoryId = nextDirectory.id;
105
105
  }
@@ -107,7 +107,7 @@ class GoogleDriveApiClient implements NativeRNCloudStorage {
107
107
  return currentDirectoryId;
108
108
  }
109
109
 
110
- private async listFiles(scope: NativeRNCloudStorageScope): Promise<GoogleDriveFile[]> {
110
+ private async listFiles(scope: NativeRNCloudCloudStorageScope): Promise<GoogleDriveFile[]> {
111
111
  const files: GoogleDriveListOperationResponse = await GoogleDriveApiClient.drive.files.list({
112
112
  spaces: [this.getRootDirectory(scope)],
113
113
  fields: 'files(id,kind,mimeType,name,parents,spaces)',
@@ -116,7 +116,7 @@ class GoogleDriveApiClient implements NativeRNCloudStorage {
116
116
  return files.files;
117
117
  }
118
118
 
119
- private async getFileId(path: string, scope: NativeRNCloudStorageScope): Promise<string> {
119
+ private async getFileId(path: string, scope: NativeRNCloudCloudStorageScope): Promise<string> {
120
120
  const files = await this.listFiles(scope);
121
121
  const { directories, filename } = this.resolvePathToDirectories(path);
122
122
  const parentDirectoryId = this.findParentDirectoryId(files, directories);
@@ -128,21 +128,26 @@ class GoogleDriveApiClient implements NativeRNCloudStorage {
128
128
  } else {
129
129
  file = files.find((f) => f.name === filename && f.parents![0] === parentDirectoryId);
130
130
  }
131
- if (!file) throw new NativeStorageError(`File not found`, NativeStorageErrorCode.FILE_NOT_FOUND);
131
+ if (!file) throw new CloudStorageError(`File not found`, CloudStorageErrorCode.FILE_NOT_FOUND);
132
132
  return file.id;
133
133
  }
134
134
 
135
- async fileExists(path: string, scope: NativeRNCloudStorageScope): Promise<boolean> {
135
+ async fileExists(path: string, scope: NativeRNCloudCloudStorageScope): Promise<boolean> {
136
136
  try {
137
137
  await this.getFileId(path, scope);
138
138
  return true;
139
139
  } catch (e: any) {
140
- if (e instanceof NativeStorageError && e.code === NativeStorageErrorCode.FILE_NOT_FOUND) return false;
140
+ if (e instanceof CloudStorageError && e.code === CloudStorageErrorCode.FILE_NOT_FOUND) return false;
141
141
  else throw e;
142
142
  }
143
143
  }
144
144
 
145
- async createFile(path: string, data: string, scope: NativeRNCloudStorageScope, overwrite: boolean): Promise<void> {
145
+ async createFile(
146
+ path: string,
147
+ data: string,
148
+ scope: NativeRNCloudCloudStorageScope,
149
+ overwrite: boolean
150
+ ): Promise<void> {
146
151
  let fileId: string | undefined;
147
152
  if (overwrite) {
148
153
  try {
@@ -169,18 +174,18 @@ class GoogleDriveApiClient implements NativeRNCloudStorage {
169
174
  await uploader.execute();
170
175
  }
171
176
 
172
- async readFile(path: string, scope: NativeRNCloudStorageScope): Promise<string> {
177
+ async readFile(path: string, scope: NativeRNCloudCloudStorageScope): Promise<string> {
173
178
  const fileId = await this.getFileId(path, scope);
174
179
  const content = await GoogleDriveApiClient.drive.files.getText(fileId);
175
180
  return content;
176
181
  }
177
182
 
178
- async deleteFile(path: string, scope: NativeRNCloudStorageScope): Promise<void> {
183
+ async deleteFile(path: string, scope: NativeRNCloudCloudStorageScope): Promise<void> {
179
184
  const fileId = await this.getFileId(path, scope);
180
185
  await GoogleDriveApiClient.drive.files.delete(fileId);
181
186
  }
182
187
 
183
- async statFile(path: string, scope: NativeRNCloudStorageScope): Promise<NativeRNCloudStorageFileStat> {
188
+ async statFile(path: string, scope: NativeRNCloudCloudStorageScope): Promise<NativeRNCloudCloudStorageFileStat> {
184
189
  const fileId = await this.getFileId(path, scope);
185
190
  const file: GoogleDriveDetailedFile = await GoogleDriveApiClient.drive.files.get(fileId, {
186
191
  fields: 'id,kind,mimeType,name,parents,spaces,size,createdTime,modifiedTime',
@@ -1,8 +1,8 @@
1
- import type { StorageScope } from '../types/main';
1
+ import type { CloudStorageScope } from '../types/main';
2
2
  import RNCloudStorage from '../RNCloudStorage';
3
3
  import { useCallback, useEffect, useState } from 'react';
4
4
 
5
- export const useCloudFile = (path: string, scope: StorageScope) => {
5
+ export const useCloudFile = (path: string, scope: CloudStorageScope) => {
6
6
  const [content, setContent] = useState<string | null>(null);
7
7
 
8
8
  const read = useCallback(async () => {
package/src/index.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import RNCloudStorage from './RNCloudStorage';
2
- import { NativeStorageErrorCode } from './types/native';
2
+ import { CloudStorageErrorCode } from './types/native';
3
3
  export * from './types/main';
4
4
  export * from './hooks/useCloudFile';
5
5
  export * from './hooks/useIsCloudAvailable';
6
- import NativeStorageError from './utils/NativeStorageError';
6
+ import CloudStorageError from './utils/CloudStorageError';
7
7
 
8
- export { NativeStorageError };
9
- export { NativeStorageErrorCode };
8
+ export { CloudStorageError };
9
+ export { CloudStorageErrorCode };
10
10
  export default RNCloudStorage;
package/src/types/main.ts CHANGED
@@ -1,9 +1,9 @@
1
- export enum StorageScope {
1
+ export enum CloudStorageScope {
2
2
  Documents = 'documents',
3
3
  AppData = 'app_data',
4
4
  }
5
5
 
6
- export interface StorageFileStat {
6
+ export interface CloudStorageFileStat {
7
7
  size: number;
8
8
  birthtimeMs: number;
9
9
  mtimeMs: number;
@@ -1,6 +1,6 @@
1
- export type NativeRNCloudStorageScope = 'documents' | 'app_data';
1
+ export type NativeRNCloudCloudStorageScope = 'documents' | 'app_data';
2
2
 
3
- export interface NativeRNCloudStorageFileStat {
3
+ export interface NativeRNCloudCloudStorageFileStat {
4
4
  size: number;
5
5
  birthtimeMs: number;
6
6
  mtimeMs: number;
@@ -8,7 +8,7 @@ export interface NativeRNCloudStorageFileStat {
8
8
  isFile: boolean;
9
9
  }
10
10
 
11
- export enum NativeStorageErrorCode {
11
+ export enum CloudStorageErrorCode {
12
12
  FILE_NOT_FOUND = 'ERR_FILE_NOT_FOUND',
13
13
  DIRECTORY_NOT_FOUND = 'ERR_NO_DIRECTORY_FOUND',
14
14
  FILE_ALREADY_EXISTS = 'ERR_FILE_EXISTS',
@@ -21,10 +21,10 @@ export enum NativeStorageErrorCode {
21
21
  }
22
22
 
23
23
  export default interface NativeRNCloudStorage {
24
- fileExists: (path: string, scope: NativeRNCloudStorageScope) => Promise<boolean>;
25
- createFile: (path: string, data: string, scope: NativeRNCloudStorageScope, overwrite: boolean) => Promise<void>;
26
- readFile: (path: string, scope: NativeRNCloudStorageScope) => Promise<string>;
27
- deleteFile: (path: string, scope: NativeRNCloudStorageScope) => Promise<void>;
28
- statFile: (path: string, scope: NativeRNCloudStorageScope) => Promise<NativeRNCloudStorageFileStat>;
24
+ fileExists: (path: string, scope: NativeRNCloudCloudStorageScope) => Promise<boolean>;
25
+ createFile: (path: string, data: string, scope: NativeRNCloudCloudStorageScope, overwrite: boolean) => Promise<void>;
26
+ readFile: (path: string, scope: NativeRNCloudCloudStorageScope) => Promise<string>;
27
+ deleteFile: (path: string, scope: NativeRNCloudCloudStorageScope) => Promise<void>;
28
+ statFile: (path: string, scope: NativeRNCloudCloudStorageScope) => Promise<NativeRNCloudCloudStorageFileStat>;
29
29
  isCloudAvailable: () => Promise<boolean>;
30
30
  }
@@ -0,0 +1,14 @@
1
+ import type { CloudStorageErrorCode } from '../types/native';
2
+
3
+ class CloudStorageError extends Error {
4
+ code: CloudStorageErrorCode;
5
+ details?: any;
6
+
7
+ constructor(message: string, code: CloudStorageErrorCode, details?: any) {
8
+ super(message);
9
+ this.code = code;
10
+ this.details = details;
11
+ }
12
+ }
13
+
14
+ export default CloudStorageError;
@@ -1 +0,0 @@
1
- {"version":3,"names":["NativeStorageError","Error","constructor","message","code","details","_default","exports","default"],"sourceRoot":"../../../src","sources":["utils/NativeStorageError.ts"],"mappings":";;;;;;AAEA,MAAMA,kBAAkB,SAASC,KAAK,CAAC;EAIrCC,WAAWA,CAACC,OAAe,EAAEC,IAA4B,EAAEC,OAAa,EAAE;IACxE,KAAK,CAACF,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,OAAO,GAAGA,OAAO;EACxB;AACF;AAAC,IAAAC,QAAA,GAEcN,kBAAkB;AAAAO,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -1,9 +0,0 @@
1
- class NativeStorageError extends Error {
2
- constructor(message, code, details) {
3
- super(message);
4
- this.code = code;
5
- this.details = details;
6
- }
7
- }
8
- export default NativeStorageError;
9
- //# sourceMappingURL=NativeStorageError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["NativeStorageError","Error","constructor","message","code","details"],"sourceRoot":"../../../src","sources":["utils/NativeStorageError.ts"],"mappings":"AAEA,MAAMA,kBAAkB,SAASC,KAAK,CAAC;EAIrCC,WAAWA,CAACC,OAAe,EAAEC,IAA4B,EAAEC,OAAa,EAAE;IACxE,KAAK,CAACF,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,OAAO,GAAGA,OAAO;EACxB;AACF;AAEA,eAAeL,kBAAkB"}
@@ -1,8 +0,0 @@
1
- import type { NativeStorageErrorCode } from '../types/native';
2
- declare class NativeStorageError extends Error {
3
- code: NativeStorageErrorCode;
4
- details?: any;
5
- constructor(message: string, code: NativeStorageErrorCode, details?: any);
6
- }
7
- export default NativeStorageError;
8
- //# sourceMappingURL=NativeStorageError.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NativeStorageError.d.ts","sourceRoot":"","sources":["../../../src/utils/NativeStorageError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE9D,cAAM,kBAAmB,SAAQ,KAAK;IACpC,IAAI,EAAE,sBAAsB,CAAC;IAC7B,OAAO,CAAC,EAAE,GAAG,CAAC;gBAEF,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,sBAAsB,EAAE,OAAO,CAAC,EAAE,GAAG;CAKzE;AAED,eAAe,kBAAkB,CAAC"}
@@ -1,14 +0,0 @@
1
- import type { NativeStorageErrorCode } from '../types/native';
2
-
3
- class NativeStorageError extends Error {
4
- code: NativeStorageErrorCode;
5
- details?: any;
6
-
7
- constructor(message: string, code: NativeStorageErrorCode, details?: any) {
8
- super(message);
9
- this.code = code;
10
- this.details = details;
11
- }
12
- }
13
-
14
- export default NativeStorageError;