react-native-cloud-sync 0.4.0 → 0.5.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/README.md +18 -0
- package/ios/CloudSyncError.swift +21 -0
- package/ios/CloudSyncImpl.swift +515 -95
- package/ios/RNCloudSync.mm +73 -1
- package/jest-mock.js +1 -0
- package/lib/commonjs/hooks.js +73 -9
- package/lib/commonjs/hooks.js.map +1 -1
- package/lib/commonjs/internal/autoFlush.js +10 -1
- package/lib/commonjs/internal/autoFlush.js.map +1 -1
- package/lib/commonjs/internal/base64.js +25 -5
- package/lib/commonjs/internal/base64.js.map +1 -1
- package/lib/commonjs/internal/cloudKitRest.js +91 -15
- package/lib/commonjs/internal/cloudKitRest.js.map +1 -1
- package/lib/commonjs/internal/googleDriveRest.js +304 -38
- package/lib/commonjs/internal/googleDriveRest.js.map +1 -1
- package/lib/commonjs/internal/keys.js +34 -17
- package/lib/commonjs/internal/keys.js.map +1 -1
- package/lib/commonjs/internal/records.js +48 -0
- package/lib/commonjs/internal/records.js.map +1 -0
- package/lib/commonjs/providers/cloudKit.js +85 -17
- package/lib/commonjs/providers/cloudKit.js.map +1 -1
- package/lib/commonjs/providers/cloudKitEncrypted.js +30 -7
- package/lib/commonjs/providers/cloudKitEncrypted.js.map +1 -1
- package/lib/commonjs/providers/googleDrive.js +37 -2
- package/lib/commonjs/providers/googleDrive.js.map +1 -1
- package/lib/commonjs/providers/icloudDocuments.js +27 -0
- package/lib/commonjs/providers/icloudDocuments.js.map +1 -1
- package/lib/commonjs/providers/icloudKV.js +13 -3
- package/lib/commonjs/providers/icloudKV.js.map +1 -1
- package/lib/commonjs/providers/icloudKV.web.js +8 -1
- package/lib/commonjs/providers/icloudKV.web.js.map +1 -1
- package/lib/commonjs/providers/memory.js +10 -0
- package/lib/commonjs/providers/memory.js.map +1 -1
- package/lib/commonjs/resolvers.js +27 -13
- package/lib/commonjs/resolvers.js.map +1 -1
- package/lib/commonjs/specs/NativeRNCloudSync.js +3 -0
- package/lib/commonjs/specs/NativeRNCloudSync.js.map +1 -1
- package/lib/commonjs/store.js +360 -173
- package/lib/commonjs/store.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/hooks.js +73 -9
- package/lib/module/hooks.js.map +1 -1
- package/lib/module/internal/autoFlush.js +10 -1
- package/lib/module/internal/autoFlush.js.map +1 -1
- package/lib/module/internal/base64.js +25 -5
- package/lib/module/internal/base64.js.map +1 -1
- package/lib/module/internal/cloudKitRest.js +89 -13
- package/lib/module/internal/cloudKitRest.js.map +1 -1
- package/lib/module/internal/googleDriveRest.js +304 -38
- package/lib/module/internal/googleDriveRest.js.map +1 -1
- package/lib/module/internal/keys.js +33 -17
- package/lib/module/internal/keys.js.map +1 -1
- package/lib/module/internal/records.js +41 -0
- package/lib/module/internal/records.js.map +1 -0
- package/lib/module/providers/cloudKit.js +86 -18
- package/lib/module/providers/cloudKit.js.map +1 -1
- package/lib/module/providers/cloudKitEncrypted.js +31 -8
- package/lib/module/providers/cloudKitEncrypted.js.map +1 -1
- package/lib/module/providers/googleDrive.js +37 -2
- package/lib/module/providers/googleDrive.js.map +1 -1
- package/lib/module/providers/icloudDocuments.js +28 -1
- package/lib/module/providers/icloudDocuments.js.map +1 -1
- package/lib/module/providers/icloudKV.js +13 -3
- package/lib/module/providers/icloudKV.js.map +1 -1
- package/lib/module/providers/icloudKV.web.js +8 -1
- package/lib/module/providers/icloudKV.web.js.map +1 -1
- package/lib/module/providers/memory.js +10 -0
- package/lib/module/providers/memory.js.map +1 -1
- package/lib/module/resolvers.js +27 -12
- package/lib/module/resolvers.js.map +1 -1
- package/lib/module/specs/NativeRNCloudSync.js +4 -0
- package/lib/module/specs/NativeRNCloudSync.js.map +1 -1
- package/lib/module/store.js +360 -173
- package/lib/module/store.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/commonjs/errors.d.ts +16 -16
- package/lib/typescript/commonjs/errors.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks.d.ts.map +1 -1
- package/lib/typescript/commonjs/internal/autoFlush.d.ts.map +1 -1
- package/lib/typescript/commonjs/internal/base64.d.ts.map +1 -1
- package/lib/typescript/commonjs/internal/cloudKitRest.d.ts +20 -0
- package/lib/typescript/commonjs/internal/cloudKitRest.d.ts.map +1 -1
- package/lib/typescript/commonjs/internal/googleDriveRest.d.ts +19 -0
- package/lib/typescript/commonjs/internal/googleDriveRest.d.ts.map +1 -1
- package/lib/typescript/commonjs/internal/keys.d.ts +18 -3
- package/lib/typescript/commonjs/internal/keys.d.ts.map +1 -1
- package/lib/typescript/commonjs/internal/records.d.ts +24 -0
- package/lib/typescript/commonjs/internal/records.d.ts.map +1 -0
- package/lib/typescript/commonjs/providers/cloudKit.d.ts +1 -1
- package/lib/typescript/commonjs/providers/cloudKit.d.ts.map +1 -1
- package/lib/typescript/commonjs/providers/cloudKitBackup.d.ts +1 -1
- package/lib/typescript/commonjs/providers/cloudKitBackup.d.ts.map +1 -1
- package/lib/typescript/commonjs/providers/cloudKitEncrypted.d.ts.map +1 -1
- package/lib/typescript/commonjs/providers/googleDrive.d.ts.map +1 -1
- package/lib/typescript/commonjs/providers/googleDriveFiles.d.ts.map +1 -1
- package/lib/typescript/commonjs/providers/icloudDocuments.d.ts +1 -1
- package/lib/typescript/commonjs/providers/icloudDocuments.d.ts.map +1 -1
- package/lib/typescript/commonjs/providers/icloudKV.d.ts.map +1 -1
- package/lib/typescript/commonjs/providers/icloudKV.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/providers/memory.d.ts.map +1 -1
- package/lib/typescript/commonjs/resolvers.d.ts +6 -3
- package/lib/typescript/commonjs/resolvers.d.ts.map +1 -1
- package/lib/typescript/commonjs/specs/NativeRNCloudSync.d.ts +12 -3
- package/lib/typescript/commonjs/specs/NativeRNCloudSync.d.ts.map +1 -1
- package/lib/typescript/commonjs/store.d.ts.map +1 -1
- package/lib/typescript/commonjs/types.d.ts +31 -3
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/module/errors.d.ts +16 -16
- package/lib/typescript/module/errors.d.ts.map +1 -1
- package/lib/typescript/module/hooks.d.ts.map +1 -1
- package/lib/typescript/module/internal/autoFlush.d.ts.map +1 -1
- package/lib/typescript/module/internal/base64.d.ts.map +1 -1
- package/lib/typescript/module/internal/cloudKitRest.d.ts +20 -0
- package/lib/typescript/module/internal/cloudKitRest.d.ts.map +1 -1
- package/lib/typescript/module/internal/googleDriveRest.d.ts +19 -0
- package/lib/typescript/module/internal/googleDriveRest.d.ts.map +1 -1
- package/lib/typescript/module/internal/keys.d.ts +18 -3
- package/lib/typescript/module/internal/keys.d.ts.map +1 -1
- package/lib/typescript/module/internal/records.d.ts +24 -0
- package/lib/typescript/module/internal/records.d.ts.map +1 -0
- package/lib/typescript/module/providers/cloudKit.d.ts +1 -1
- package/lib/typescript/module/providers/cloudKit.d.ts.map +1 -1
- package/lib/typescript/module/providers/cloudKitBackup.d.ts +1 -1
- package/lib/typescript/module/providers/cloudKitBackup.d.ts.map +1 -1
- package/lib/typescript/module/providers/cloudKitEncrypted.d.ts.map +1 -1
- package/lib/typescript/module/providers/googleDrive.d.ts.map +1 -1
- package/lib/typescript/module/providers/googleDriveFiles.d.ts.map +1 -1
- package/lib/typescript/module/providers/icloudDocuments.d.ts +1 -1
- package/lib/typescript/module/providers/icloudDocuments.d.ts.map +1 -1
- package/lib/typescript/module/providers/icloudKV.d.ts.map +1 -1
- package/lib/typescript/module/providers/icloudKV.web.d.ts.map +1 -1
- package/lib/typescript/module/providers/memory.d.ts.map +1 -1
- package/lib/typescript/module/resolvers.d.ts +6 -3
- package/lib/typescript/module/resolvers.d.ts.map +1 -1
- package/lib/typescript/module/specs/NativeRNCloudSync.d.ts +12 -3
- package/lib/typescript/module/specs/NativeRNCloudSync.d.ts.map +1 -1
- package/lib/typescript/module/store.d.ts.map +1 -1
- package/lib/typescript/module/types.d.ts +31 -3
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/package.json +35 -25
- package/plugin/build/index.js +45 -13
- package/react-native-cloud-sync.podspec +10 -3
- package/src/hooks.ts +69 -9
- package/src/internal/autoFlush.ts +10 -1
- package/src/internal/base64.ts +26 -5
- package/src/internal/cloudKitRest.ts +103 -14
- package/src/internal/googleDriveRest.ts +338 -37
- package/src/internal/keys.ts +42 -16
- package/src/internal/records.ts +38 -0
- package/src/providers/cloudKit.ts +96 -20
- package/src/providers/cloudKitEncrypted.ts +37 -8
- package/src/providers/googleDrive.ts +38 -2
- package/src/providers/icloudDocuments.ts +40 -2
- package/src/providers/icloudKV.ts +13 -3
- package/src/providers/icloudKV.web.ts +8 -2
- package/src/providers/memory.ts +8 -0
- package/src/resolvers.ts +28 -13
- package/src/specs/NativeRNCloudSync.ts +16 -2
- package/src/store.ts +433 -190
- package/src/types.ts +32 -3
package/README.md
CHANGED
|
@@ -23,10 +23,25 @@
|
|
|
23
23
|
<a href="https://kesha-antonov.github.io/react-native-cloud-sync/platform-notes">Platform Notes</a>
|
|
24
24
|
</p>
|
|
25
25
|
|
|
26
|
+
<p align="center">
|
|
27
|
+
<img src="assets/sync-demo.gif" width="760" alt="A book saved on an iPhone syncs through iCloud to an iPad and a Mac and through Google Drive to an Android phone and the web, then un-saved on Android it syncs back everywhere" />
|
|
28
|
+
</p>
|
|
29
|
+
|
|
26
30
|
<p align="center">
|
|
27
31
|
<sub>Using it in production? A ⭐ helps other developers find the library.</sub>
|
|
28
32
|
</p>
|
|
29
33
|
|
|
34
|
+
<!-- cryptoc-promo:start -->
|
|
35
|
+
<hr />
|
|
36
|
+
|
|
37
|
+
<h2 align="center">Sponsors</h2>
|
|
38
|
+
|
|
39
|
+
<p align="center">
|
|
40
|
+
<a href="https://getstream.io/chat/sdk/react-native/?utm_source=github&utm_medium=sponsor&utm_campaign=keshaantonov&utm_term=react-native-cloud-sync"><img width="100" height="100" src="https://raw.githubusercontent.com/kesha-antonov/react-native-chat/main/media/getstream-sponsor-logo.png" alt="Stream" /></a>
|
|
41
|
+
<br />
|
|
42
|
+
<a href="https://getstream.io/chat/sdk/react-native/?utm_source=github&utm_medium=sponsor&utm_campaign=keshaantonov&utm_term=react-native-cloud-sync"><strong>Stream</strong></a> - React Native Chat SDK
|
|
43
|
+
</p>
|
|
44
|
+
|
|
30
45
|
<hr />
|
|
31
46
|
|
|
32
47
|
<table align="center">
|
|
@@ -38,8 +53,10 @@
|
|
|
38
53
|
<br />
|
|
39
54
|
<sub>Scan to install</sub>
|
|
40
55
|
<br /><br />
|
|
56
|
+
<!-- App Store button hidden for now
|
|
41
57
|
<a href="https://apps.apple.com/app/cryptoc/id1333169178"><img height="40" src="https://cryptoc-app.web.app/img/appstore.svg?v=2" alt="Download on the App Store" /></a>
|
|
42
58
|
<br />
|
|
59
|
+
-->
|
|
43
60
|
<a href="https://play.google.com/store/apps/details?id=co.ssoul.CryptoC"><img height="59" src="https://cryptoc-app.web.app/img/googleplay.png?v=2" alt="Get it on Google Play" /></a>
|
|
44
61
|
</td>
|
|
45
62
|
<td valign="top">
|
|
@@ -61,6 +78,7 @@
|
|
|
61
78
|
</table>
|
|
62
79
|
|
|
63
80
|
<hr />
|
|
81
|
+
<!-- cryptoc-promo:end -->
|
|
64
82
|
|
|
65
83
|
## ✨ Features
|
|
66
84
|
|
package/ios/CloudSyncError.swift
CHANGED
|
@@ -69,6 +69,21 @@ enum CloudSyncError: Error {
|
|
|
69
69
|
/// (or into `nil`) is what makes a signed-out user indistinguishable from an
|
|
70
70
|
/// empty backup, which is the defect this whole package exists to avoid.
|
|
71
71
|
static func fromCKError(_ error: CKError) -> CloudSyncError {
|
|
72
|
+
// A single-item CKModifyRecordsOperation / CKFetchRecordsOperation
|
|
73
|
+
// reports a per-record failure at the operation level wrapped in
|
|
74
|
+
// `.partialFailure`. Mapping the wrapper fell through to ERR_UNKNOWN,
|
|
75
|
+
// so a quota, size-limit, permission or conflict failure on a write
|
|
76
|
+
// lost its code (and its retryAfter / serverValue) on the way to JS.
|
|
77
|
+
if error.code == .partialFailure,
|
|
78
|
+
let underlying = error.partialErrorsByItemID?.values
|
|
79
|
+
.compactMap({ $0 as? CKError })
|
|
80
|
+
// Batch siblings fail with .batchRequestFailed; the real cause
|
|
81
|
+
// is the other one.
|
|
82
|
+
.first(where: { $0.code != .batchRequestFailed })
|
|
83
|
+
?? error.partialErrorsByItemID?.values.compactMap({ $0 as? CKError }).first {
|
|
84
|
+
return fromCKError(underlying)
|
|
85
|
+
}
|
|
86
|
+
|
|
72
87
|
var info: [String: Any] = [:]
|
|
73
88
|
if let retryAfter = error.userInfo[CKErrorRetryAfterKey] as? Double {
|
|
74
89
|
info["retryAfterMs"] = retryAfter * 1000
|
|
@@ -81,6 +96,12 @@ enum CloudSyncError: Error {
|
|
|
81
96
|
message: "No iCloud account is signed in on this device.",
|
|
82
97
|
info: info
|
|
83
98
|
)
|
|
99
|
+
case .accountTemporarilyUnavailable:
|
|
100
|
+
return .coded(
|
|
101
|
+
code: CloudSyncErrorCode.accountUnavailable,
|
|
102
|
+
message: "The iCloud account is temporarily unavailable.",
|
|
103
|
+
info: info
|
|
104
|
+
)
|
|
84
105
|
case .managedAccountRestricted, .permissionFailure:
|
|
85
106
|
return .coded(
|
|
86
107
|
code: CloudSyncErrorCode.accountRestricted,
|