@onekeyfe/react-native-cloud-kit-module 1.1.13 → 1.1.15
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.
|
@@ -30,7 +30,7 @@ class CloudKitModule : HybridCloudKitModuleSpec() {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
override fun fetchRecord(params: FetchRecordParams): Promise<RecordResult?> {
|
|
33
|
-
|
|
33
|
+
return Promise.resolved(null)
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
override fun deleteRecord(params: DeleteRecordParams): Promise<Unit> {
|
package/ios/CloudKitModule.swift
CHANGED
|
@@ -3,12 +3,13 @@ import CloudKit
|
|
|
3
3
|
import NitroModules
|
|
4
4
|
|
|
5
5
|
class CloudKitModule: HybridCloudKitModuleSpec {
|
|
6
|
+
|
|
6
7
|
// MARK: - Properties
|
|
7
8
|
private let container = CKContainer.default()
|
|
8
9
|
private lazy var database = container.privateCloudDatabase
|
|
9
10
|
|
|
10
11
|
// MARK: - Check Availability
|
|
11
|
-
|
|
12
|
+
|
|
12
13
|
public func isAvailable() throws -> Promise<Bool> {
|
|
13
14
|
return Promise.async {
|
|
14
15
|
let status = try await self.container.accountStatus()
|
|
@@ -17,7 +18,7 @@ class CloudKitModule: HybridCloudKitModuleSpec {
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
// MARK: - Get Account Info
|
|
20
|
-
|
|
21
|
+
|
|
21
22
|
public func getAccountInfo() throws -> Promise<AccountInfoResult> {
|
|
22
23
|
return Promise.async {
|
|
23
24
|
let status = try await self.container.accountStatus()
|
|
@@ -47,7 +48,7 @@ class CloudKitModule: HybridCloudKitModuleSpec {
|
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
// MARK: - Save Record
|
|
50
|
-
|
|
51
|
+
|
|
51
52
|
public func saveRecord(params: SaveRecordParams) throws -> Promise<SaveRecordResult> {
|
|
52
53
|
return Promise.async {
|
|
53
54
|
let ckRecordID = CKRecord.ID(recordName: params.recordID)
|
|
@@ -74,20 +75,20 @@ class CloudKitModule: HybridCloudKitModuleSpec {
|
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
// MARK: - Fetch Record
|
|
77
|
-
|
|
78
|
+
|
|
78
79
|
public func fetchRecord(params: FetchRecordParams) throws -> Promise<RecordResult?> {
|
|
79
80
|
return Promise.async {
|
|
80
81
|
let ckRecordID = CKRecord.ID(recordName: params.recordID)
|
|
81
|
-
|
|
82
|
+
|
|
82
83
|
do {
|
|
83
84
|
let record = try await self.database.record(for: ckRecordID)
|
|
84
|
-
|
|
85
|
+
|
|
85
86
|
let data = record[CloudKitConstants.recordDataField] as? String ?? ""
|
|
86
87
|
let meta = record[CloudKitConstants.recordMetaField] as? String ?? ""
|
|
87
88
|
let createdAt = Int64((record.creationDate?.timeIntervalSince1970 ?? 0) * 1000)
|
|
88
89
|
let modifiedAt = Int64((record.modificationDate?.timeIntervalSince1970 ?? 0) * 1000)
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
|
|
91
|
+
return RecordResult(
|
|
91
92
|
recordID: record.recordID.recordName,
|
|
92
93
|
recordType: record.recordType,
|
|
93
94
|
data: data,
|
|
@@ -95,7 +96,6 @@ class CloudKitModule: HybridCloudKitModuleSpec {
|
|
|
95
96
|
createdAt: Double(createdAt),
|
|
96
97
|
modifiedAt: Double(modifiedAt)
|
|
97
98
|
)
|
|
98
|
-
return result
|
|
99
99
|
} catch let error as CKError where error.code == .unknownItem {
|
|
100
100
|
return nil
|
|
101
101
|
}
|
|
@@ -103,11 +103,11 @@ class CloudKitModule: HybridCloudKitModuleSpec {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
// MARK: - Delete Record
|
|
106
|
-
|
|
106
|
+
|
|
107
107
|
public func deleteRecord(params: DeleteRecordParams) throws -> Promise<Void> {
|
|
108
108
|
return Promise.async {
|
|
109
109
|
let ckRecordID = CKRecord.ID(recordName: params.recordID)
|
|
110
|
-
|
|
110
|
+
|
|
111
111
|
do {
|
|
112
112
|
_ = try await self.database.deleteRecord(withID: ckRecordID)
|
|
113
113
|
return Void()
|
|
@@ -119,11 +119,11 @@ class CloudKitModule: HybridCloudKitModuleSpec {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
// MARK: - Record Exists
|
|
122
|
-
|
|
122
|
+
|
|
123
123
|
public func recordExists(params: RecordExistsParams) throws -> Promise<Bool> {
|
|
124
124
|
return Promise.async {
|
|
125
125
|
let ckRecordID = CKRecord.ID(recordName: params.recordID)
|
|
126
|
-
|
|
126
|
+
|
|
127
127
|
do {
|
|
128
128
|
_ = try await self.database.record(for: ckRecordID)
|
|
129
129
|
return true
|
|
@@ -134,7 +134,7 @@ class CloudKitModule: HybridCloudKitModuleSpec {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
// MARK: - Query Records
|
|
137
|
-
|
|
137
|
+
|
|
138
138
|
public func queryRecords(params: QueryRecordsParams) throws -> Promise<QueryRecordsResult> {
|
|
139
139
|
return Promise.async {
|
|
140
140
|
let predicate = NSPredicate(value: true)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/react-native-cloud-kit-module",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.15",
|
|
4
4
|
"description": "react-native-cloud-kit-module",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"react": "19.2.0",
|
|
83
83
|
"react-native": "0.83.0",
|
|
84
84
|
"react-native-builder-bob": "^0.40.13",
|
|
85
|
-
"react-native-nitro-modules": "0.
|
|
85
|
+
"react-native-nitro-modules": "0.33.2",
|
|
86
86
|
"release-it": "^19.0.4",
|
|
87
87
|
"turbo": "^2.5.6",
|
|
88
88
|
"typescript": "^5.9.2"
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"peerDependencies": {
|
|
91
91
|
"react": "*",
|
|
92
92
|
"react-native": "*",
|
|
93
|
-
"react-native-nitro-modules": "
|
|
93
|
+
"react-native-nitro-modules": "0.33.2"
|
|
94
94
|
},
|
|
95
95
|
"react-native-builder-bob": {
|
|
96
96
|
"source": "src",
|