react-native-cloud-sync 0.1.0
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/LICENSE +21 -0
- package/README.md +360 -0
- package/app.plugin.js +3 -0
- package/ios/CloudSyncError.swift +144 -0
- package/ios/CloudSyncImpl.swift +1263 -0
- package/ios/RNCloudSync.h +25 -0
- package/ios/RNCloudSync.mm +477 -0
- package/jest-mock.js +136 -0
- package/lib/commonjs/config.js +85 -0
- package/lib/commonjs/config.js.map +1 -0
- package/lib/commonjs/errors.js +244 -0
- package/lib/commonjs/errors.js.map +1 -0
- package/lib/commonjs/hooks.js +257 -0
- package/lib/commonjs/hooks.js.map +1 -0
- package/lib/commonjs/index.js +244 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/internal/autoFlush.js +65 -0
- package/lib/commonjs/internal/autoFlush.js.map +1 -0
- package/lib/commonjs/internal/base64.js +58 -0
- package/lib/commonjs/internal/base64.js.map +1 -0
- package/lib/commonjs/internal/bytes.js +32 -0
- package/lib/commonjs/internal/bytes.js.map +1 -0
- package/lib/commonjs/internal/cloudKitRest.js +527 -0
- package/lib/commonjs/internal/cloudKitRest.js.map +1 -0
- package/lib/commonjs/internal/enums.js +23 -0
- package/lib/commonjs/internal/enums.js.map +1 -0
- package/lib/commonjs/internal/googleDriveRest.js +624 -0
- package/lib/commonjs/internal/googleDriveRest.js.map +1 -0
- package/lib/commonjs/internal/keys.js +139 -0
- package/lib/commonjs/internal/keys.js.map +1 -0
- package/lib/commonjs/internal/logger.js +29 -0
- package/lib/commonjs/internal/logger.js.map +1 -0
- package/lib/commonjs/internal/nativeModule.js +125 -0
- package/lib/commonjs/internal/nativeModule.js.map +1 -0
- package/lib/commonjs/internal/timeout.js +72 -0
- package/lib/commonjs/internal/timeout.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/providers/cloudKit.js +398 -0
- package/lib/commonjs/providers/cloudKit.js.map +1 -0
- package/lib/commonjs/providers/cloudKitBackup.js +86 -0
- package/lib/commonjs/providers/cloudKitBackup.js.map +1 -0
- package/lib/commonjs/providers/cloudKitEncrypted.js +150 -0
- package/lib/commonjs/providers/cloudKitEncrypted.js.map +1 -0
- package/lib/commonjs/providers/googleDrive.js +219 -0
- package/lib/commonjs/providers/googleDrive.js.map +1 -0
- package/lib/commonjs/providers/googleDriveFiles.js +68 -0
- package/lib/commonjs/providers/googleDriveFiles.js.map +1 -0
- package/lib/commonjs/providers/icloudDocuments.js +121 -0
- package/lib/commonjs/providers/icloudDocuments.js.map +1 -0
- package/lib/commonjs/providers/icloudKV.js +171 -0
- package/lib/commonjs/providers/icloudKV.js.map +1 -0
- package/lib/commonjs/providers/icloudKV.web.js +42 -0
- package/lib/commonjs/providers/icloudKV.web.js.map +1 -0
- package/lib/commonjs/providers/memory.js +201 -0
- package/lib/commonjs/providers/memory.js.map +1 -0
- package/lib/commonjs/resolvers.js +128 -0
- package/lib/commonjs/resolvers.js.map +1 -0
- package/lib/commonjs/specs/NativeRNCloudSync.js +14 -0
- package/lib/commonjs/specs/NativeRNCloudSync.js.map +1 -0
- package/lib/commonjs/store.js +1064 -0
- package/lib/commonjs/store.js.map +1 -0
- package/lib/commonjs/testing.js +32 -0
- package/lib/commonjs/testing.js.map +1 -0
- package/lib/commonjs/types.js +86 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/config.js +72 -0
- package/lib/module/config.js.map +1 -0
- package/lib/module/errors.js +231 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/hooks.js +250 -0
- package/lib/module/hooks.js.map +1 -0
- package/lib/module/index.js +46 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/internal/autoFlush.js +62 -0
- package/lib/module/internal/autoFlush.js.map +1 -0
- package/lib/module/internal/base64.js +53 -0
- package/lib/module/internal/base64.js.map +1 -0
- package/lib/module/internal/bytes.js +28 -0
- package/lib/module/internal/bytes.js.map +1 -0
- package/lib/module/internal/cloudKitRest.js +518 -0
- package/lib/module/internal/cloudKitRest.js.map +1 -0
- package/lib/module/internal/enums.js +18 -0
- package/lib/module/internal/enums.js.map +1 -0
- package/lib/module/internal/googleDriveRest.js +620 -0
- package/lib/module/internal/googleDriveRest.js.map +1 -0
- package/lib/module/internal/keys.js +134 -0
- package/lib/module/internal/keys.js.map +1 -0
- package/lib/module/internal/logger.js +23 -0
- package/lib/module/internal/logger.js.map +1 -0
- package/lib/module/internal/nativeModule.js +117 -0
- package/lib/module/internal/nativeModule.js.map +1 -0
- package/lib/module/internal/timeout.js +67 -0
- package/lib/module/internal/timeout.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/providers/cloudKit.js +392 -0
- package/lib/module/providers/cloudKit.js.map +1 -0
- package/lib/module/providers/cloudKitBackup.js +82 -0
- package/lib/module/providers/cloudKitBackup.js.map +1 -0
- package/lib/module/providers/cloudKitEncrypted.js +146 -0
- package/lib/module/providers/cloudKitEncrypted.js.map +1 -0
- package/lib/module/providers/googleDrive.js +214 -0
- package/lib/module/providers/googleDrive.js.map +1 -0
- package/lib/module/providers/googleDriveFiles.js +64 -0
- package/lib/module/providers/googleDriveFiles.js.map +1 -0
- package/lib/module/providers/icloudDocuments.js +117 -0
- package/lib/module/providers/icloudDocuments.js.map +1 -0
- package/lib/module/providers/icloudKV.js +165 -0
- package/lib/module/providers/icloudKV.js.map +1 -0
- package/lib/module/providers/icloudKV.web.js +36 -0
- package/lib/module/providers/icloudKV.web.js.map +1 -0
- package/lib/module/providers/memory.js +197 -0
- package/lib/module/providers/memory.js.map +1 -0
- package/lib/module/resolvers.js +120 -0
- package/lib/module/resolvers.js.map +1 -0
- package/lib/module/specs/NativeRNCloudSync.js +12 -0
- package/lib/module/specs/NativeRNCloudSync.js.map +1 -0
- package/lib/module/store.js +1061 -0
- package/lib/module/store.js.map +1 -0
- package/lib/module/testing.js +17 -0
- package/lib/module/testing.js.map +1 -0
- package/lib/module/types.js +82 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/commonjs/config.d.ts +33 -0
- package/lib/typescript/commonjs/config.d.ts.map +1 -0
- package/lib/typescript/commonjs/errors.d.ts +140 -0
- package/lib/typescript/commonjs/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks.d.ts +109 -0
- package/lib/typescript/commonjs/hooks.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +37 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/autoFlush.d.ts +45 -0
- package/lib/typescript/commonjs/internal/autoFlush.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/base64.d.ts +12 -0
- package/lib/typescript/commonjs/internal/base64.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/bytes.d.ts +12 -0
- package/lib/typescript/commonjs/internal/bytes.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/cloudKitRest.d.ts +149 -0
- package/lib/typescript/commonjs/internal/cloudKitRest.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/enums.d.ts +10 -0
- package/lib/typescript/commonjs/internal/enums.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/googleDriveRest.d.ts +232 -0
- package/lib/typescript/commonjs/internal/googleDriveRest.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/keys.d.ts +28 -0
- package/lib/typescript/commonjs/internal/keys.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/logger.d.ts +10 -0
- package/lib/typescript/commonjs/internal/logger.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/nativeModule.d.ts +29 -0
- package/lib/typescript/commonjs/internal/nativeModule.d.ts.map +1 -0
- package/lib/typescript/commonjs/internal/timeout.d.ts +36 -0
- package/lib/typescript/commonjs/internal/timeout.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/providers/cloudKit.d.ts +86 -0
- package/lib/typescript/commonjs/providers/cloudKit.d.ts.map +1 -0
- package/lib/typescript/commonjs/providers/cloudKitBackup.d.ts +65 -0
- package/lib/typescript/commonjs/providers/cloudKitBackup.d.ts.map +1 -0
- package/lib/typescript/commonjs/providers/cloudKitEncrypted.d.ts +37 -0
- package/lib/typescript/commonjs/providers/cloudKitEncrypted.d.ts.map +1 -0
- package/lib/typescript/commonjs/providers/googleDrive.d.ts +35 -0
- package/lib/typescript/commonjs/providers/googleDrive.d.ts.map +1 -0
- package/lib/typescript/commonjs/providers/googleDriveFiles.d.ts +59 -0
- package/lib/typescript/commonjs/providers/googleDriveFiles.d.ts.map +1 -0
- package/lib/typescript/commonjs/providers/icloudDocuments.d.ts +101 -0
- package/lib/typescript/commonjs/providers/icloudDocuments.d.ts.map +1 -0
- package/lib/typescript/commonjs/providers/icloudKV.d.ts +26 -0
- package/lib/typescript/commonjs/providers/icloudKV.d.ts.map +1 -0
- package/lib/typescript/commonjs/providers/icloudKV.web.d.ts +12 -0
- package/lib/typescript/commonjs/providers/icloudKV.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/providers/memory.d.ts +90 -0
- package/lib/typescript/commonjs/providers/memory.d.ts.map +1 -0
- package/lib/typescript/commonjs/resolvers.d.ts +60 -0
- package/lib/typescript/commonjs/resolvers.d.ts.map +1 -0
- package/lib/typescript/commonjs/specs/NativeRNCloudSync.d.ts +133 -0
- package/lib/typescript/commonjs/specs/NativeRNCloudSync.d.ts.map +1 -0
- package/lib/typescript/commonjs/store.d.ts +118 -0
- package/lib/typescript/commonjs/store.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing.d.ts +16 -0
- package/lib/typescript/commonjs/testing.d.ts.map +1 -0
- package/lib/typescript/commonjs/types.d.ts +367 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/module/config.d.ts +33 -0
- package/lib/typescript/module/config.d.ts.map +1 -0
- package/lib/typescript/module/errors.d.ts +140 -0
- package/lib/typescript/module/errors.d.ts.map +1 -0
- package/lib/typescript/module/hooks.d.ts +109 -0
- package/lib/typescript/module/hooks.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +37 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/internal/autoFlush.d.ts +45 -0
- package/lib/typescript/module/internal/autoFlush.d.ts.map +1 -0
- package/lib/typescript/module/internal/base64.d.ts +12 -0
- package/lib/typescript/module/internal/base64.d.ts.map +1 -0
- package/lib/typescript/module/internal/bytes.d.ts +12 -0
- package/lib/typescript/module/internal/bytes.d.ts.map +1 -0
- package/lib/typescript/module/internal/cloudKitRest.d.ts +149 -0
- package/lib/typescript/module/internal/cloudKitRest.d.ts.map +1 -0
- package/lib/typescript/module/internal/enums.d.ts +10 -0
- package/lib/typescript/module/internal/enums.d.ts.map +1 -0
- package/lib/typescript/module/internal/googleDriveRest.d.ts +232 -0
- package/lib/typescript/module/internal/googleDriveRest.d.ts.map +1 -0
- package/lib/typescript/module/internal/keys.d.ts +28 -0
- package/lib/typescript/module/internal/keys.d.ts.map +1 -0
- package/lib/typescript/module/internal/logger.d.ts +10 -0
- package/lib/typescript/module/internal/logger.d.ts.map +1 -0
- package/lib/typescript/module/internal/nativeModule.d.ts +29 -0
- package/lib/typescript/module/internal/nativeModule.d.ts.map +1 -0
- package/lib/typescript/module/internal/timeout.d.ts +36 -0
- package/lib/typescript/module/internal/timeout.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/providers/cloudKit.d.ts +86 -0
- package/lib/typescript/module/providers/cloudKit.d.ts.map +1 -0
- package/lib/typescript/module/providers/cloudKitBackup.d.ts +65 -0
- package/lib/typescript/module/providers/cloudKitBackup.d.ts.map +1 -0
- package/lib/typescript/module/providers/cloudKitEncrypted.d.ts +37 -0
- package/lib/typescript/module/providers/cloudKitEncrypted.d.ts.map +1 -0
- package/lib/typescript/module/providers/googleDrive.d.ts +35 -0
- package/lib/typescript/module/providers/googleDrive.d.ts.map +1 -0
- package/lib/typescript/module/providers/googleDriveFiles.d.ts +59 -0
- package/lib/typescript/module/providers/googleDriveFiles.d.ts.map +1 -0
- package/lib/typescript/module/providers/icloudDocuments.d.ts +101 -0
- package/lib/typescript/module/providers/icloudDocuments.d.ts.map +1 -0
- package/lib/typescript/module/providers/icloudKV.d.ts +26 -0
- package/lib/typescript/module/providers/icloudKV.d.ts.map +1 -0
- package/lib/typescript/module/providers/icloudKV.web.d.ts +12 -0
- package/lib/typescript/module/providers/icloudKV.web.d.ts.map +1 -0
- package/lib/typescript/module/providers/memory.d.ts +90 -0
- package/lib/typescript/module/providers/memory.d.ts.map +1 -0
- package/lib/typescript/module/resolvers.d.ts +60 -0
- package/lib/typescript/module/resolvers.d.ts.map +1 -0
- package/lib/typescript/module/specs/NativeRNCloudSync.d.ts +133 -0
- package/lib/typescript/module/specs/NativeRNCloudSync.d.ts.map +1 -0
- package/lib/typescript/module/store.d.ts +118 -0
- package/lib/typescript/module/store.d.ts.map +1 -0
- package/lib/typescript/module/testing.d.ts +16 -0
- package/lib/typescript/module/testing.d.ts.map +1 -0
- package/lib/typescript/module/types.d.ts +367 -0
- package/lib/typescript/module/types.d.ts.map +1 -0
- package/package.json +186 -0
- package/plugin/build/index.d.ts +45 -0
- package/plugin/build/index.js +93 -0
- package/react-native-cloud-sync.podspec +48 -0
- package/src/config.ts +94 -0
- package/src/errors.ts +263 -0
- package/src/hooks.ts +337 -0
- package/src/index.ts +113 -0
- package/src/internal/autoFlush.ts +87 -0
- package/src/internal/base64.ts +63 -0
- package/src/internal/bytes.ts +28 -0
- package/src/internal/cloudKitRest.ts +654 -0
- package/src/internal/enums.ts +35 -0
- package/src/internal/googleDriveRest.ts +765 -0
- package/src/internal/keys.ts +160 -0
- package/src/internal/logger.ts +23 -0
- package/src/internal/nativeModule.ts +149 -0
- package/src/internal/timeout.ts +83 -0
- package/src/providers/cloudKit.ts +510 -0
- package/src/providers/cloudKitBackup.ts +124 -0
- package/src/providers/cloudKitEncrypted.ts +175 -0
- package/src/providers/googleDrive.ts +251 -0
- package/src/providers/googleDriveFiles.ts +117 -0
- package/src/providers/icloudDocuments.ts +175 -0
- package/src/providers/icloudKV.ts +206 -0
- package/src/providers/icloudKV.web.ts +41 -0
- package/src/providers/memory.ts +302 -0
- package/src/resolvers.ts +133 -0
- package/src/specs/NativeRNCloudSync.ts +184 -0
- package/src/store.ts +1288 -0
- package/src/testing.ts +22 -0
- package/src/types.ts +426 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { AbortLike } from '../internal/timeout.js';
|
|
2
|
+
export interface DriveFileProgressEvent {
|
|
3
|
+
bytesTransferred: number;
|
|
4
|
+
bytesTotal: number;
|
|
5
|
+
/** `bytesTransferred / bytesTotal`, or 0 while `bytesTotal` is still 0. */
|
|
6
|
+
fraction: number;
|
|
7
|
+
}
|
|
8
|
+
export interface DriveFileSaveOptions {
|
|
9
|
+
/** Called repeatedly while the upload is in flight. */
|
|
10
|
+
onProgress?: (e: DriveFileProgressEvent) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Cancels the transfer, rejecting with `ERR_CANCELLED`.
|
|
13
|
+
*
|
|
14
|
+
* Checked between chunks, so a cancel takes effect during the transfer rather
|
|
15
|
+
* than only once the whole file has moved - which is the entire point when
|
|
16
|
+
* the file is several hundred megabytes. Bytes already accepted stay in the
|
|
17
|
+
* resumable session; a later `save` of the same name starts a fresh one.
|
|
18
|
+
*
|
|
19
|
+
* Typed structurally rather than as the DOM `AbortSignal`, so any polyfill
|
|
20
|
+
* works and consumers do not need `lib.dom` in their tsconfig.
|
|
21
|
+
*/
|
|
22
|
+
signal?: AbortLike;
|
|
23
|
+
}
|
|
24
|
+
export interface DriveFileFetchOptions {
|
|
25
|
+
/** Called repeatedly while the download is in flight. */
|
|
26
|
+
onProgress?: (e: DriveFileProgressEvent) => void;
|
|
27
|
+
/** Cancels the transfer, rejecting with `ERR_CANCELLED`. Checked between chunks. */
|
|
28
|
+
signal?: AbortLike;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Binary files in Drive's `appDataFolder`, for anything too large to hold in
|
|
32
|
+
* memory as a JS string the way `googleDrive.setItem` does - the Android/web
|
|
33
|
+
* equivalent of `cloudKitAssets`' `CKAsset` on Apple platforms.
|
|
34
|
+
*
|
|
35
|
+
* Uploads use Drive's resumable protocol, reading the source in fixed chunks;
|
|
36
|
+
* downloads write in the same fixed chunks. Neither ever holds more than one
|
|
37
|
+
* chunk (8 MiB by default) in memory. Both go through a `GoogleDriveFileAdapter`
|
|
38
|
+
* (`configureGoogleDriveFiles`) for the actual disk I/O - this package has no
|
|
39
|
+
* filesystem dependency of its own, so the host app supplies one using
|
|
40
|
+
* whichever fs library it already has. See the CloudKit/Google Drive guides
|
|
41
|
+
* for the file adapter's exact contract and setup examples.
|
|
42
|
+
*/
|
|
43
|
+
export declare const googleDriveFiles: {
|
|
44
|
+
/** Uploads `fileUri` as `name`, overwriting whatever was there. */
|
|
45
|
+
save: (options: {
|
|
46
|
+
name: string;
|
|
47
|
+
fileUri: string;
|
|
48
|
+
} & DriveFileSaveOptions) => Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Downloads `name` into `destinationUri`, resolving `destinationUri` back
|
|
51
|
+
* once complete, or `null` when no such file exists - `destinationUri` is
|
|
52
|
+
* never touched in that case.
|
|
53
|
+
*/
|
|
54
|
+
fetch: (options: {
|
|
55
|
+
name: string;
|
|
56
|
+
destinationUri: string;
|
|
57
|
+
} & DriveFileFetchOptions) => Promise<string | null>;
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=googleDriveFiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"googleDriveFiles.d.ts","sourceRoot":"","sources":["../../../../src/providers/googleDriveFiles.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAqB,CAAA;AAIpD,MAAM,WAAW,sBAAsB;IACrC,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,MAAM,CAAA;IAClB,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,uDAAuD;IACvD,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,sBAAsB,KAAK,IAAI,CAAA;IAChD;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,SAAS,CAAA;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,yDAAyD;IACzD,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,sBAAsB,KAAK,IAAI,CAAA;IAChD,oFAAoF;IACpF,MAAM,CAAC,EAAE,SAAS,CAAA;CACnB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB;IAC3B,mEAAmE;oBAExD;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,oBAAoB,KAChE,OAAO,CAAC,IAAI,CAAC;IAoBhB;;;;OAIG;qBAEQ;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAE,GAAG,qBAAqB,KACxE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAqB1B,CAAA"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export interface DocumentEntry {
|
|
2
|
+
name: string;
|
|
3
|
+
sizeBytes: number;
|
|
4
|
+
/**
|
|
5
|
+
* False when the file exists in the account but has no local copy on this
|
|
6
|
+
* device.
|
|
7
|
+
*
|
|
8
|
+
* The distinction that makes iCloud Drive different from a normal directory:
|
|
9
|
+
* a listing shows files this device has never downloaded, and reading one
|
|
10
|
+
* without calling {@link icloudDocuments.fetch} first gives you nothing.
|
|
11
|
+
*/
|
|
12
|
+
isDownloaded: boolean;
|
|
13
|
+
isDownloading: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface DocumentFetchOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Copy the file here once it is downloaded, and resolve this path instead of
|
|
18
|
+
* the in-container one.
|
|
19
|
+
*
|
|
20
|
+
* Worth doing for anything you intend to keep: the system may evict a
|
|
21
|
+
* downloaded copy from the container to reclaim space, turning it back into a
|
|
22
|
+
* placeholder.
|
|
23
|
+
*/
|
|
24
|
+
destinationUri?: string;
|
|
25
|
+
/**
|
|
26
|
+
* How long to wait for the download. Default 60000.
|
|
27
|
+
*
|
|
28
|
+
* A timeout is not a failure of the transfer - iOS keeps downloading in the
|
|
29
|
+
* background - so `ERR_TIMEOUT` here means "not yet", and it is classified as
|
|
30
|
+
* retryable for exactly that reason.
|
|
31
|
+
*/
|
|
32
|
+
timeoutMs?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Files in the user's own iCloud Drive.
|
|
36
|
+
*
|
|
37
|
+
* This is the one thing no `CKRecord` or `CKAsset` API can do, and the most
|
|
38
|
+
* common iCloud request in mobile apps: *put this file where the user can find
|
|
39
|
+
* it*. A `CKAsset` lives in the app's private CloudKit database - the user
|
|
40
|
+
* cannot see it, open it, or hand it to another app. A file written here lands
|
|
41
|
+
* in the app's folder in iCloud Drive, visible in Files.app, syncing to every
|
|
42
|
+
* device signed into the same Apple ID, and surviving the app being deleted.
|
|
43
|
+
*
|
|
44
|
+
* Requirements beyond the CloudKit entitlement:
|
|
45
|
+
*
|
|
46
|
+
* - the **iCloud Documents** service on the container (the config plugin's
|
|
47
|
+
* `iCloudDocuments: true` option adds it);
|
|
48
|
+
* - an `NSUbiquitousContainers` Info.plist entry with
|
|
49
|
+
* `NSUbiquitousContainerIsDocumentScopePublic` set, or the folder syncs but
|
|
50
|
+
* stays invisible in Files.app. The plugin writes this too.
|
|
51
|
+
*
|
|
52
|
+
* Apple platforms only, and unlike the other providers that is not a gap to be
|
|
53
|
+
* filled later: there is no REST surface for iCloud Drive and no browser API.
|
|
54
|
+
* Use {@link googleDriveFiles} for user-visible files elsewhere.
|
|
55
|
+
*
|
|
56
|
+
* Not a {@link CloudProvider}: the contract there is keys to string values, and
|
|
57
|
+
* this moves files by path. Same reason `cloudKitAssets` is its own API.
|
|
58
|
+
*/
|
|
59
|
+
export declare const icloudDocuments: {
|
|
60
|
+
/** Whether this device has a usable iCloud Drive container right now. */
|
|
61
|
+
isAvailable: () => Promise<boolean>;
|
|
62
|
+
/**
|
|
63
|
+
* Copies a local file into iCloud Drive under `name`, replacing whatever was
|
|
64
|
+
* there. Resolves the resulting iCloud path.
|
|
65
|
+
*
|
|
66
|
+
* Resolving means "handed to iCloud", not "in the cloud" - the system uploads
|
|
67
|
+
* in the background whether or not the app is running. Same distinction as
|
|
68
|
+
* `icloudKVSync()`, and for the same reason: there is no API that waits for
|
|
69
|
+
* the upload.
|
|
70
|
+
*/
|
|
71
|
+
save: (options: {
|
|
72
|
+
fileUri: string;
|
|
73
|
+
name: string;
|
|
74
|
+
}) => Promise<string>;
|
|
75
|
+
/**
|
|
76
|
+
* Downloads `name` if this device does not have it yet, then resolves a local
|
|
77
|
+
* path - or `null` when no such file exists in the account.
|
|
78
|
+
*
|
|
79
|
+
* The download step is the point. A file listed by {@link list} may be a
|
|
80
|
+
* placeholder with no local bytes, and opening that gives you an empty file
|
|
81
|
+
* rather than an error.
|
|
82
|
+
*
|
|
83
|
+
* Byte-level progress is not reported: that needs an `NSMetadataQuery`, which
|
|
84
|
+
* needs a live run loop, and this runs off the main thread on purpose. Use
|
|
85
|
+
* {@link list} to poll `isDownloading` if you need to show something.
|
|
86
|
+
*/
|
|
87
|
+
fetch: (options: {
|
|
88
|
+
name: string;
|
|
89
|
+
} & DocumentFetchOptions) => Promise<string | null>;
|
|
90
|
+
/**
|
|
91
|
+
* Everything in the app's iCloud Drive folder, including files this device
|
|
92
|
+
* has not downloaded.
|
|
93
|
+
*/
|
|
94
|
+
list: () => Promise<DocumentEntry[]>;
|
|
95
|
+
/**
|
|
96
|
+
* Deletes a file from iCloud Drive - on every device, and from the user's
|
|
97
|
+
* Files.app. Resolves false when it was already gone.
|
|
98
|
+
*/
|
|
99
|
+
remove: (name: string) => Promise<boolean>;
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=icloudDocuments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icloudDocuments.d.ts","sourceRoot":"","sources":["../../../../src/providers/icloudDocuments.ts"],"names":[],"mappings":"AA0BA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB;;;;;;;OAOG;IACH,YAAY,EAAE,OAAO,CAAA;IACrB,aAAa,EAAE,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,eAAe;IAC1B,yEAAyE;uBAClD,OAAO,CAAC,OAAO,CAAC;IAYvC;;;;;;;;OAQG;oBACmB;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAG,OAAO,CAAC,MAAM,CAAC;IAUzE;;;;;;;;;;;OAWG;qBAEQ;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,oBAAoB,KAC/C,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAczB;;;OAGG;gBACa,OAAO,CAAC,aAAa,EAAE,CAAC;IAUxC;;;OAGG;mBACkB,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC;CAS/C,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CloudProvider } from '../types.js';
|
|
2
|
+
export declare const icloudKV: CloudProvider;
|
|
3
|
+
/**
|
|
4
|
+
* Every key and value in the store, in one call.
|
|
5
|
+
*
|
|
6
|
+
* Not part of the {@link CloudProvider} contract, because no other provider can
|
|
7
|
+
* do it cheaply - CloudKit and Drive would both have to fetch every record.
|
|
8
|
+
* Here the whole store is already a local dictionary, so this is one bridge hop
|
|
9
|
+
* against the N+1 that `getAllKeys()` plus a read per key would cost.
|
|
10
|
+
*
|
|
11
|
+
* Values the store holds as something other than a string (it also accepts
|
|
12
|
+
* numbers, dates and data) are omitted rather than coerced, since a
|
|
13
|
+
* stringified number would not round-trip back through `setItem`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getAllItems(): Promise<Record<string, string>>;
|
|
16
|
+
/**
|
|
17
|
+
* Flushes pending changes to disk.
|
|
18
|
+
*
|
|
19
|
+
* Exposed separately because it is not part of the generic {@link CloudProvider}
|
|
20
|
+
* contract - and because its semantics are routinely misread. It maps to
|
|
21
|
+
* `NSUbiquitousKeyValueStore.synchronize()`, which schedules an upload; it does
|
|
22
|
+
* not wait for or confirm one. A resolved `sync()` means "queued", never
|
|
23
|
+
* "stored in iCloud".
|
|
24
|
+
*/
|
|
25
|
+
export declare function sync(): Promise<boolean>;
|
|
26
|
+
//# sourceMappingURL=icloudKV.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icloudKV.d.ts","sourceRoot":"","sources":["../../../../src/providers/icloudKV.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAGV,aAAa,EAGd,MAAM,aAAU,CAAA;AA2CjB,eAAO,MAAM,QAAQ,EAAE,aA2GtB,CAAA;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAQnE;AAED;;;;;;;;GAQG;AACH,wBAAsB,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,CAQ7C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CloudProvider } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Web build of the iCloud key-value provider.
|
|
4
|
+
*
|
|
5
|
+
* Every operation rejects with `ERR_UNSUPPORTED_PLATFORM` rather than resolving
|
|
6
|
+
* `null` or silently no-oping, so a web build fails loudly at the call site
|
|
7
|
+
* instead of appearing to work and quietly dropping data.
|
|
8
|
+
*/
|
|
9
|
+
export declare const icloudKV: CloudProvider;
|
|
10
|
+
export declare function sync(): Promise<boolean>;
|
|
11
|
+
export declare function getAllItems(): Promise<Record<string, string>>;
|
|
12
|
+
//# sourceMappingURL=icloudKV.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icloudKV.web.d.ts","sourceRoot":"","sources":["../../../../src/providers/icloudKV.web.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAiB,aAAa,EAAE,MAAM,aAAU,CAAA;AAY5D;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,EAAE,aAYtB,CAAA;AAED,wBAAgB,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,CAEvC;AAED,wBAAgB,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAE7D"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ErrorCode } from '../errors.js';
|
|
2
|
+
import type { AccountChangeEvent, AccountStatus, CloudProvider, RemoteChangeEvent } from '../types.js';
|
|
3
|
+
export type FaultOp = 'getItem' | 'setItem' | 'removeItem' | 'getAllKeys' | 'getAccountStatus';
|
|
4
|
+
export interface Fault {
|
|
5
|
+
code: ErrorCode;
|
|
6
|
+
message?: string;
|
|
7
|
+
retryAfterMs?: number;
|
|
8
|
+
limitBytes?: number;
|
|
9
|
+
actualBytes?: number;
|
|
10
|
+
serverValue?: string | null;
|
|
11
|
+
/**
|
|
12
|
+
* Fail only this many times, then succeed. Useful for asserting that retry and
|
|
13
|
+
* outbox logic converges instead of looping.
|
|
14
|
+
*/
|
|
15
|
+
times?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Fail only for keys this returns true for. Defaults to every key.
|
|
18
|
+
*
|
|
19
|
+
* Real backends fail per record, not per operation - one oversized or
|
|
20
|
+
* conflicting key while the rest of a batch goes through. Scoping a fault to
|
|
21
|
+
* a key is also what makes interleaving tests deterministic, since two
|
|
22
|
+
* operations in flight no longer compete for the same `times` budget.
|
|
23
|
+
*/
|
|
24
|
+
only?: (key: string) => boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface MemoryProviderOptions {
|
|
27
|
+
/** Seed data the provider starts with. */
|
|
28
|
+
initial?: Record<string, string>;
|
|
29
|
+
/** Per-operation failures to inject. */
|
|
30
|
+
faults?: Partial<Record<FaultOp, Fault>>;
|
|
31
|
+
/** Account status reported by `getAccountStatus`. Defaults to `available`. */
|
|
32
|
+
accountStatus?: AccountStatus;
|
|
33
|
+
/** Artificial delay in ms applied to every operation. */
|
|
34
|
+
latencyMs?: number;
|
|
35
|
+
/**
|
|
36
|
+
* What `isAvailable()` reports. Defaults to true.
|
|
37
|
+
*
|
|
38
|
+
* Set false to reproduce the signed-out fleet - the case where the store must
|
|
39
|
+
* refuse to answer a read rather than resolving `null`, because `null` there
|
|
40
|
+
* reads as "no backup exists" and the documented first-launch recipe seeds
|
|
41
|
+
* empty state over the user's real data.
|
|
42
|
+
*/
|
|
43
|
+
available?: boolean;
|
|
44
|
+
/** A name other than `'memory'`, for tests that need two distinct doubles. */
|
|
45
|
+
name?: string;
|
|
46
|
+
/** Quota reported by `getQuota()`. Omitted means the provider reports none. */
|
|
47
|
+
quota?: {
|
|
48
|
+
usedBytes?: number;
|
|
49
|
+
totalBytes?: number;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** A provider name other than the four built in. Used to type custom doubles. */
|
|
53
|
+
export type MemoryProviderName = string;
|
|
54
|
+
export interface MemoryProvider extends CloudProvider {
|
|
55
|
+
/** Direct read of the backing map, bypassing fault injection. */
|
|
56
|
+
dump: () => Record<string, string>;
|
|
57
|
+
/** Replace the backing data without going through `setItem`. */
|
|
58
|
+
seed: (data: Record<string, string>) => void;
|
|
59
|
+
/** Clear data, faults and listeners. */
|
|
60
|
+
reset: () => void;
|
|
61
|
+
/** Install or replace a fault at runtime. */
|
|
62
|
+
setFault: (op: FaultOp, fault: Fault | null) => void;
|
|
63
|
+
/** Fire a remote-change event, as if another device had written. */
|
|
64
|
+
emitRemoteChange: (e: Partial<RemoteChangeEvent>) => void;
|
|
65
|
+
/** Fire an account-change event, including the identity-switch case. */
|
|
66
|
+
emitAccountChange: (e: Partial<AccountChangeEvent>) => void;
|
|
67
|
+
/** Flip what `isAvailable()` reports, to simulate signing out mid-session. */
|
|
68
|
+
setAvailable: (value: boolean) => void;
|
|
69
|
+
/** How many times each operation has been called. */
|
|
70
|
+
readonly calls: Readonly<Record<FaultOp, number>>;
|
|
71
|
+
/** How many times the store asked this provider to drop cached state. */
|
|
72
|
+
readonly cacheClears: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* An in-memory provider with fault injection.
|
|
76
|
+
*
|
|
77
|
+
* This exists because cloud storage is the hardest thing in a mobile app to test
|
|
78
|
+
* honestly. iCloud on the simulator is unreliable enough that the most-used
|
|
79
|
+
* library in this space gave up on it publicly - "We've therefore stopped
|
|
80
|
+
* testing the library on the simulator and test on a real device only and would
|
|
81
|
+
* encourage users to do the same." Real-device-only testing means the failure
|
|
82
|
+
* paths that matter most (signed out, offline, quota exceeded, rate limited,
|
|
83
|
+
* account switched mid-session) are effectively never exercised.
|
|
84
|
+
*
|
|
85
|
+
* So they are exercised here instead, deterministically, in Jest. This is
|
|
86
|
+
* exported from the package entry (`react-native-cloud-sync/testing`)
|
|
87
|
+
* rather than buried in source, so it is usable without reaching into internals.
|
|
88
|
+
*/
|
|
89
|
+
export declare function createMemoryProvider(options?: MemoryProviderOptions): MemoryProvider;
|
|
90
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../../src/providers/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,MAAM,cAAW,CAAA;AACrD,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,iBAAiB,EAElB,MAAM,aAAU,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I,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAA;IAC5C,wCAAwC;IACxC,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,6CAA6C;IAC7C,QAAQ,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,CAAA;IACpD,oEAAoE;IACpE,gBAAgB,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAA;IACzD,wEAAwE;IACxE,iBAAiB,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAA;IAC3D,8EAA8E;IAC9E,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACtC,qDAAqD;IACrD,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAA;IACjD,yEAAyE;IACzE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAC7B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,qBAA0B,GAAG,cAAc,CAoMxF"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ResolveFn } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves by a numeric timestamp inside a JSON value.
|
|
4
|
+
*
|
|
5
|
+
* The common shape by far: values are JSON objects carrying `updatedAt` (or
|
|
6
|
+
* similar), and the newest wins. Candidates that are not JSON, or that lack the
|
|
7
|
+
* field, lose to any that have it - a value you cannot date is not evidence
|
|
8
|
+
* against one you can.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* createCloudStore({
|
|
12
|
+
* providers: ['icloudKV', 'googleDrive'],
|
|
13
|
+
* writeMode: 'mirror',
|
|
14
|
+
* resolve: resolveByTimestamp('updatedAt'),
|
|
15
|
+
* })
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveByTimestamp(field?: string): ResolveFn;
|
|
19
|
+
/** Always takes the first provider that has a value. The default behaviour. */
|
|
20
|
+
export declare const resolveByPreferenceOrder: ResolveFn;
|
|
21
|
+
/**
|
|
22
|
+
* Resolves by the *server's* last-modified time rather than a timestamp inside
|
|
23
|
+
* the value.
|
|
24
|
+
*
|
|
25
|
+
* {@link resolveByTimestamp} requires every value to be JSON carrying a field
|
|
26
|
+
* the app remembered to update - a real constraint, and one that silently fails
|
|
27
|
+
* open the day someone writes a plain string or forgets to bump `updatedAt`.
|
|
28
|
+
* Both CloudKit (`modified.timestamp`) and Drive (`modifiedTime`) already
|
|
29
|
+
* report a modification time, one query parameter away, so this orders on that
|
|
30
|
+
* instead and works on payloads the app never had to instrument.
|
|
31
|
+
*
|
|
32
|
+
* The catch, and the reason this is not the default: `NSUbiquitousKeyValueStore`
|
|
33
|
+
* exposes no per-key timestamp at all, so an `icloudKV` candidate never carries
|
|
34
|
+
* one. Pass `fallback` to say what should happen then - by default an undated
|
|
35
|
+
* candidate loses to any dated one, and preference order breaks a tie among
|
|
36
|
+
* undated ones.
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* createCloudStore({
|
|
40
|
+
* providers: ['cloudKit', 'googleDrive'], // both report server time
|
|
41
|
+
* writeMode: 'mirror',
|
|
42
|
+
* resolve: resolveByModifiedAt(),
|
|
43
|
+
* })
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function resolveByModifiedAt(options?: {
|
|
47
|
+
fallback?: ResolveFn;
|
|
48
|
+
}): ResolveFn;
|
|
49
|
+
/**
|
|
50
|
+
* Tries each resolver in turn and takes the first non-null answer.
|
|
51
|
+
*
|
|
52
|
+
* The practical combination for a mixed fleet: server time where the provider
|
|
53
|
+
* reports it, an embedded timestamp where it does not.
|
|
54
|
+
*
|
|
55
|
+
* ```ts
|
|
56
|
+
* resolveFirstOf(resolveByModifiedAt(), resolveByTimestamp('updatedAt'))
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function resolveFirstOf(...resolvers: ResolveFn[]): ResolveFn;
|
|
60
|
+
//# sourceMappingURL=resolvers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../src/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,SAAS,EAAE,MAAM,YAAS,CAAA;AAE1D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,SAAc,GAAG,SAAS,CAqBjE;AAoBD,+EAA+E;AAC/E,eAAO,MAAM,wBAAwB,EAAE,SACa,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAO,GACrC,SAAS,CAsBX;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,GAAG,SAAS,EAAE,SAAS,EAAE,GAAG,SAAS,CAQnE"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import type { EventEmitter } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
/**
|
|
4
|
+
* Codegen cannot express an index signature, so dynamic dictionaries cross the
|
|
5
|
+
* bridge as `UnsafeObject`. Same workaround react-native-background-downloader
|
|
6
|
+
* uses for its header maps.
|
|
7
|
+
*/
|
|
8
|
+
export type UnsafeObject = {
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
};
|
|
11
|
+
export type RemoteChangeNativeEvent = {
|
|
12
|
+
keys: string[];
|
|
13
|
+
/** One of ChangeReason. Kept as a plain string - codegen has no string unions. */
|
|
14
|
+
reason: string;
|
|
15
|
+
provider: string;
|
|
16
|
+
};
|
|
17
|
+
export type AccountChangeNativeEvent = {
|
|
18
|
+
/** One of AccountStatus. */
|
|
19
|
+
status: string;
|
|
20
|
+
identityChanged: boolean;
|
|
21
|
+
provider: string;
|
|
22
|
+
};
|
|
23
|
+
export type DocumentEntryNativeEvent = {
|
|
24
|
+
name: string;
|
|
25
|
+
sizeBytes: number;
|
|
26
|
+
/** False when the file exists in the account but has no local copy yet. */
|
|
27
|
+
isDownloaded: boolean;
|
|
28
|
+
isDownloading: boolean;
|
|
29
|
+
};
|
|
30
|
+
export type AssetProgressNativeEvent = {
|
|
31
|
+
recordName: string;
|
|
32
|
+
fieldName: string;
|
|
33
|
+
bytesTransferred: number;
|
|
34
|
+
bytesTotal: number;
|
|
35
|
+
};
|
|
36
|
+
export interface Spec extends TurboModule {
|
|
37
|
+
getConstants: () => {
|
|
38
|
+
/** The iCloud container id resolved from entitlements, or '' if unset. */
|
|
39
|
+
containerIdentifier: string;
|
|
40
|
+
/** True when the build carries an iCloud entitlement at all. */
|
|
41
|
+
hasICloudEntitlement: boolean;
|
|
42
|
+
};
|
|
43
|
+
getAccountStatus: () => Promise<string>;
|
|
44
|
+
isAvailable: () => Promise<boolean>;
|
|
45
|
+
kvGetItem: (key: string) => Promise<string | null>;
|
|
46
|
+
kvSetItem: (key: string, value: string) => Promise<void>;
|
|
47
|
+
kvRemoveItem: (key: string) => Promise<void>;
|
|
48
|
+
kvGetAllKeys: () => Promise<string[]>;
|
|
49
|
+
/**
|
|
50
|
+
* Every key and value at once - one bridge hop where `kvGetAllKeys` plus N
|
|
51
|
+
* `kvGetItem` calls would be N+1. Non-string values are omitted rather than
|
|
52
|
+
* coerced, since a stringified number would not round-trip through
|
|
53
|
+
* `kvSetItem`.
|
|
54
|
+
*/
|
|
55
|
+
kvGetAllItems: () => Promise<UnsafeObject>;
|
|
56
|
+
/**
|
|
57
|
+
* Flushes pending KV changes to disk.
|
|
58
|
+
*
|
|
59
|
+
* Note this is `NSUbiquitousKeyValueStore.synchronize()`, which despite the
|
|
60
|
+
* name does NOT confirm a server round trip - it only schedules the upload.
|
|
61
|
+
* Callers must not treat a resolved `kvSync()` as "the cloud has my data".
|
|
62
|
+
*/
|
|
63
|
+
kvSync: () => Promise<boolean>;
|
|
64
|
+
/**
|
|
65
|
+
* How full the key-value store is, against Apple's documented ceilings.
|
|
66
|
+
*
|
|
67
|
+
* Measured from `dictionaryRepresentation` (a local plist, not a network
|
|
68
|
+
* call) because Apple exposes no usage API. Without it an app can only learn
|
|
69
|
+
* it is near the 1 MB *total* by exceeding it, and exceeding it is silent.
|
|
70
|
+
*/
|
|
71
|
+
kvGetUsage: () => Promise<{
|
|
72
|
+
usedBytes: number;
|
|
73
|
+
totalBytes: number;
|
|
74
|
+
keyCount: number;
|
|
75
|
+
maxKeys: number;
|
|
76
|
+
}>;
|
|
77
|
+
/**
|
|
78
|
+
* `encrypted` reads the value out of `CKRecord.encryptedValues` rather than
|
|
79
|
+
* the plain field. A field is one or the other, never both - CloudKit records
|
|
80
|
+
* encryption in the schema - so reading the wrong side returns null, which is
|
|
81
|
+
* indistinguishable from a missing record.
|
|
82
|
+
*/
|
|
83
|
+
ckGetRecord: (recordType: string, recordName: string, zoneName: string | null, encrypted: boolean) => Promise<string | null>;
|
|
84
|
+
/**
|
|
85
|
+
* `encrypted` writes through `CKRecord.encryptedValues`, so CloudKit
|
|
86
|
+
* end-to-end encrypts the value with a key from the user's iCloud Keychain.
|
|
87
|
+
* Nothing server-side can read it back - including CloudKit Web Services, and
|
|
88
|
+
* therefore this package's Android and web paths.
|
|
89
|
+
*/
|
|
90
|
+
ckSaveRecord: (recordType: string, recordName: string, value: string, zoneName: string | null, encrypted: boolean) => Promise<void>;
|
|
91
|
+
ckDeleteRecord: (recordName: string, zoneName: string | null) => Promise<boolean>;
|
|
92
|
+
ckQueryRecordNames: (recordType: string, zoneName: string | null) => Promise<string[]>;
|
|
93
|
+
ckCreateZone: (zoneName: string) => Promise<void>;
|
|
94
|
+
ckDeleteZone: (zoneName: string) => Promise<void>;
|
|
95
|
+
ckListZones: () => Promise<string[]>;
|
|
96
|
+
/** Uploads a local file as a CKAsset field. Emits `onAssetProgress` while running. */
|
|
97
|
+
ckSaveAsset: (recordType: string, recordName: string, fieldName: string, fileUri: string, zoneName: string | null) => Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Downloads a CKAsset field. Emits `onAssetProgress` while running.
|
|
100
|
+
*
|
|
101
|
+
* `destinationUri` is where the bytes land; null picks a temporary path.
|
|
102
|
+
* Worth passing for anything the user keeps or hands to a share sheet - the
|
|
103
|
+
* default is in `NSTemporaryDirectory`, which iOS may reclaim.
|
|
104
|
+
*/
|
|
105
|
+
ckFetchAsset: (recordName: string, fieldName: string, zoneName: string | null, destinationUri: string | null) => Promise<string | null>;
|
|
106
|
+
/**
|
|
107
|
+
* Cancels an in-flight asset transfer. Resolves true when there was one.
|
|
108
|
+
*
|
|
109
|
+
* The cancelled call's own promise rejects with `ERR_CANCELLED` - CloudKit
|
|
110
|
+
* reports the cancellation as `CKError.operationCancelled`, which the error
|
|
111
|
+
* mapper already recognises.
|
|
112
|
+
*/
|
|
113
|
+
ckCancelAsset: (recordName: string, fieldName: string) => Promise<boolean>;
|
|
114
|
+
/** Whether a usable iCloud Drive container exists on this device right now. */
|
|
115
|
+
docIsAvailable: () => Promise<boolean>;
|
|
116
|
+
/** Copies a local file into iCloud Drive under `name`. Resolves its iCloud path. */
|
|
117
|
+
docSave: (fileUri: string, name: string) => Promise<string>;
|
|
118
|
+
/**
|
|
119
|
+
* Ensures `name` has been downloaded and resolves a local path, or null when
|
|
120
|
+
* no such file exists. Copies out to `destinationUri` when one is given.
|
|
121
|
+
*/
|
|
122
|
+
docFetch: (name: string, destinationUri: string | null, timeoutMs: number) => Promise<string | null>;
|
|
123
|
+
docList: () => Promise<DocumentEntryNativeEvent[]>;
|
|
124
|
+
/** Resolves true when something was deleted, false when it was already gone. */
|
|
125
|
+
docRemove: (name: string) => Promise<boolean>;
|
|
126
|
+
readonly onRemoteChange: EventEmitter<RemoteChangeNativeEvent>;
|
|
127
|
+
readonly onAccountChange: EventEmitter<AccountChangeNativeEvent>;
|
|
128
|
+
readonly onAssetProgress: EventEmitter<AssetProgressNativeEvent>;
|
|
129
|
+
setLogsEnabled: (enabled: boolean) => void;
|
|
130
|
+
}
|
|
131
|
+
declare const _default: Spec | null;
|
|
132
|
+
export default _default;
|
|
133
|
+
//# sourceMappingURL=NativeRNCloudSync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeRNCloudSync.d.ts","sourceRoot":"","sources":["../../../../src/specs/NativeRNCloudSync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAA;AAE7E;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAA;AAEpD,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,kFAAkF;IAClF,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,eAAe,EAAE,OAAO,CAAA;IACxB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,2EAA2E;IAC3E,YAAY,EAAE,OAAO,CAAA;IACrB,aAAa,EAAE,OAAO,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,M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AAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;IAC3D;;;OAGG;IACH,QAAQ,EAAE,CACR,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM,GAAG,IAAI,EAC7B,SAAS,EAAE,MAAM,KACd,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IAC3B,OAAO,EAAE,MAAM,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAAA;IAClD,gFAAgF;IAChF,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IAI7C,QAAQ,CAAC,cAAc,EAAE,YAAY,CAAC,uBAAuB,CAAC,CAAA;IAC9D,QAAQ,CAAC,eAAe,EAAE,YAAY,CAAC,wBAAwB,CAAC,CAAA;IAChE,QAAQ,CAAC,eAAe,EAAE,YAAY,CAAC,wBAAwB,CAAC,CAAA;IAIhE,cAAc,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;CAC3C;;AAED,wBAA2D"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { CloudSyncError } from './errors.js';
|
|
2
|
+
import { type AccountChangeEvent, type CloudProvider, type CloudStoreOptions, type DroppedWrite, type OutboxEntry, type ProviderName, type QuotaInfo, type RemoteChangeEvent, type Unsubscribe } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* A durable place to park failed writes.
|
|
5
|
+
*
|
|
6
|
+
* Defaults to memory, which is honest but loses the queue on app restart. Pass
|
|
7
|
+
* an MMKV-backed adapter in production so an offline write survives being
|
|
8
|
+
* killed - that is the whole point of the outbox.
|
|
9
|
+
*
|
|
10
|
+
* Both methods are synchronous: the outbox is read and rewritten on the write
|
|
11
|
+
* path, where there is nowhere to await. AsyncStorage therefore cannot be
|
|
12
|
+
* wrapped directly; keep a synchronous cache in front of it if that is the
|
|
13
|
+
* only store you have.
|
|
14
|
+
*/
|
|
15
|
+
export interface OutboxStorage {
|
|
16
|
+
getString: (key: string) => string | null | undefined;
|
|
17
|
+
set: (key: string, value: string) => void;
|
|
18
|
+
}
|
|
19
|
+
export interface MigrateOptions {
|
|
20
|
+
from: ProviderName;
|
|
21
|
+
to: ProviderName;
|
|
22
|
+
/**
|
|
23
|
+
* Keep going when a single key fails instead of aborting the whole
|
|
24
|
+
* migration. Default true.
|
|
25
|
+
*
|
|
26
|
+
* A serial loop that throws on the first bad key leaves the user half
|
|
27
|
+
* migrated with no record of how far it got, which is the worst of both
|
|
28
|
+
* outcomes. The failures come back in the result instead.
|
|
29
|
+
*/
|
|
30
|
+
continueOnError?: boolean;
|
|
31
|
+
/** Only migrate keys this returns true for. */
|
|
32
|
+
filter?: (key: string) => boolean;
|
|
33
|
+
/** Called after each key, for a progress bar over a long migration. */
|
|
34
|
+
onProgress?: (done: number, total: number) => void;
|
|
35
|
+
}
|
|
36
|
+
export interface MigrateResult {
|
|
37
|
+
copied: string[];
|
|
38
|
+
/** Keys that held no value at the source and so had nothing to copy. */
|
|
39
|
+
skipped: string[];
|
|
40
|
+
/** Keys that could not be copied, with the reason for each. */
|
|
41
|
+
failed: {
|
|
42
|
+
key: string;
|
|
43
|
+
error: CloudSyncError;
|
|
44
|
+
}[];
|
|
45
|
+
}
|
|
46
|
+
export interface FlushResult {
|
|
47
|
+
drained: number;
|
|
48
|
+
remaining: number;
|
|
49
|
+
/** Entries abandoned during this flush. Also reported through `onDropped`. */
|
|
50
|
+
dropped: DroppedWrite[];
|
|
51
|
+
}
|
|
52
|
+
export interface CloudStore {
|
|
53
|
+
getItem: (key: string) => Promise<string | null>;
|
|
54
|
+
setItem: (key: string, value: string) => Promise<void>;
|
|
55
|
+
removeItem: (key: string) => Promise<void>;
|
|
56
|
+
getAllKeys: () => Promise<string[]>;
|
|
57
|
+
/** Reads many keys, batching per provider where the provider supports it. */
|
|
58
|
+
multiGet: (keys: string[]) => Promise<[string, string | null][]>;
|
|
59
|
+
/** Writes many pairs, batching per destination. */
|
|
60
|
+
multiSet: (entries: [string, string][]) => Promise<void>;
|
|
61
|
+
/** Removes many keys, batching per provider. */
|
|
62
|
+
multiRemove: (keys: string[]) => Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Removes every key this store can see. Enumerated, not hardcoded - a
|
|
65
|
+
* "delete my data" flow that forgets a key has not deleted the user's data.
|
|
66
|
+
*/
|
|
67
|
+
clear: () => Promise<{
|
|
68
|
+
removed: string[];
|
|
69
|
+
}>;
|
|
70
|
+
/**
|
|
71
|
+
* Every key and value the store can see, as one object.
|
|
72
|
+
*
|
|
73
|
+
* `getAllKeys()` followed by `multiGet()`, so it costs whatever those cost -
|
|
74
|
+
* one batched request per provider that batches, a loop where one does not.
|
|
75
|
+
* Here because it is the shape a debug screen or an export actually wants,
|
|
76
|
+
* and because every key-value library being migrated from has it.
|
|
77
|
+
*/
|
|
78
|
+
getAllItems: () => Promise<Record<string, string>>;
|
|
79
|
+
/** Per-provider storage usage, for the providers that report it. */
|
|
80
|
+
getQuota: () => Promise<QuotaInfo[]>;
|
|
81
|
+
/** Copies every key from one provider to another. Does not delete the source. */
|
|
82
|
+
migrate: (opts: MigrateOptions) => Promise<MigrateResult>;
|
|
83
|
+
/** Attempts to drain queued writes. Safe to call on reconnect or foreground. */
|
|
84
|
+
flushOutbox: () => Promise<FlushResult>;
|
|
85
|
+
/** Entries still waiting, for surfacing a "pending sync" indicator. */
|
|
86
|
+
pendingWrites: () => OutboxEntry[];
|
|
87
|
+
/**
|
|
88
|
+
* Abandons queued writes, optionally only those matching `filter`. Returns
|
|
89
|
+
* how many were removed.
|
|
90
|
+
*
|
|
91
|
+
* The counterpart to `pendingWrites()`: a UI that can show a stuck write
|
|
92
|
+
* should be able to let the user give up on it.
|
|
93
|
+
*/
|
|
94
|
+
discardPendingWrites: (filter?: (e: OutboxEntry) => boolean) => number;
|
|
95
|
+
/** Registers an extra provider (e.g. the in-memory test double). */
|
|
96
|
+
registerProvider: (provider: CloudProvider) => void;
|
|
97
|
+
/**
|
|
98
|
+
* Remote-change events from every configured provider, merged.
|
|
99
|
+
*
|
|
100
|
+
* Previously only the raw providers exposed this, so the facade - the
|
|
101
|
+
* recommended entry point - could not be subscribed to at all.
|
|
102
|
+
*/
|
|
103
|
+
onRemoteChange: (listener: (e: RemoteChangeEvent) => void) => Unsubscribe;
|
|
104
|
+
/**
|
|
105
|
+
* Account-change events from every configured provider, merged.
|
|
106
|
+
*
|
|
107
|
+
* The store also acts on these itself: an `identityChanged` event drops
|
|
108
|
+
* provider caches and abandons queued writes, because both belong to the
|
|
109
|
+
* account that just went away.
|
|
110
|
+
*/
|
|
111
|
+
onAccountChange: (listener: (e: AccountChangeEvent) => void) => Unsubscribe;
|
|
112
|
+
/** Releases the store's own provider subscriptions. */
|
|
113
|
+
dispose: () => void;
|
|
114
|
+
}
|
|
115
|
+
export declare function createCloudStore(options: CloudStoreOptions & {
|
|
116
|
+
outboxStorage?: OutboxStorage;
|
|
117
|
+
}): CloudStore;
|
|
118
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/store.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAA0C,MAAM,aAAU,CAAA;AACjF,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EAEtB,KAAK,YAAY,EAEjB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,iBAAiB,EAGtB,KAAK,WAAW,EAEjB,MAAM,YAAS,CAAA;AAEhB;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACrD,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CAC1C;AAg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