@onekeyfe/react-native-cloud-kit-module 1.1.6
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/CloudKitModule.podspec +29 -0
- package/LICENSE +20 -0
- package/README.md +39 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +128 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/cloudkitmodule/CloudKitModule.kt +51 -0
- package/android/src/main/java/com/margelo/nitro/cloudkitmodule/CloudKitModulePackage.kt +22 -0
- package/ios/CloudKitModule.swift +186 -0
- package/ios/CloudKitModuleCore.swift +195 -0
- package/lib/module/CloudKitModule.nitro.js +4 -0
- package/lib/module/CloudKitModule.nitro.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/CloudKitModule.nitro.d.ts +55 -0
- package/lib/typescript/src/CloudKitModule.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +17 -0
- package/nitrogen/generated/android/c++/JAccountInfoResult.hpp +62 -0
- package/nitrogen/generated/android/c++/JDeleteRecordParams.hpp +57 -0
- package/nitrogen/generated/android/c++/JFetchRecordParams.hpp +57 -0
- package/nitrogen/generated/android/c++/JHybridCloudKitModuleSpec.cpp +192 -0
- package/nitrogen/generated/android/c++/JHybridCloudKitModuleSpec.hpp +70 -0
- package/nitrogen/generated/android/c++/JQueryRecordsParams.hpp +53 -0
- package/nitrogen/generated/android/c++/JQueryRecordsResult.hpp +73 -0
- package/nitrogen/generated/android/c++/JRecordExistsParams.hpp +57 -0
- package/nitrogen/generated/android/c++/JRecordResult.hpp +73 -0
- package/nitrogen/generated/android/c++/JSaveRecordParams.hpp +65 -0
- package/nitrogen/generated/android/c++/JSaveRecordResult.hpp +57 -0
- package/nitrogen/generated/android/cloudkitmodule+autolinking.cmake +81 -0
- package/nitrogen/generated/android/cloudkitmodule+autolinking.gradle +27 -0
- package/nitrogen/generated/android/cloudkitmoduleOnLoad.cpp +44 -0
- package/nitrogen/generated/android/cloudkitmoduleOnLoad.hpp +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cloudkitmodule/AccountInfoResult.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cloudkitmodule/DeleteRecordParams.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cloudkitmodule/FetchRecordParams.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cloudkitmodule/HybridCloudKitModuleSpec.kt +76 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cloudkitmodule/QueryRecordsParams.kt +29 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cloudkitmodule/QueryRecordsResult.kt +29 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cloudkitmodule/RecordExistsParams.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cloudkitmodule/RecordResult.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cloudkitmodule/SaveRecordParams.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cloudkitmodule/SaveRecordResult.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cloudkitmodule/cloudkitmoduleOnLoad.kt +35 -0
- package/nitrogen/generated/ios/CloudKitModule+autolinking.rb +60 -0
- package/nitrogen/generated/ios/CloudKitModule-Swift-Cxx-Bridge.cpp +80 -0
- package/nitrogen/generated/ios/CloudKitModule-Swift-Cxx-Bridge.hpp +340 -0
- package/nitrogen/generated/ios/CloudKitModule-Swift-Cxx-Umbrella.hpp +74 -0
- package/nitrogen/generated/ios/CloudKitModuleAutolinking.mm +33 -0
- package/nitrogen/generated/ios/CloudKitModuleAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridCloudKitModuleSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridCloudKitModuleSpecSwift.hpp +150 -0
- package/nitrogen/generated/ios/swift/AccountInfoResult.swift +76 -0
- package/nitrogen/generated/ios/swift/DeleteRecordParams.swift +46 -0
- package/nitrogen/generated/ios/swift/FetchRecordParams.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_AccountInfoResult.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_QueryRecordsResult.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_SaveRecordResult.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_RecordResult_.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridCloudKitModuleSpec.swift +55 -0
- package/nitrogen/generated/ios/swift/HybridCloudKitModuleSpec_cxx.swift +250 -0
- package/nitrogen/generated/ios/swift/QueryRecordsParams.swift +35 -0
- package/nitrogen/generated/ios/swift/QueryRecordsResult.swift +43 -0
- package/nitrogen/generated/ios/swift/RecordExistsParams.swift +46 -0
- package/nitrogen/generated/ios/swift/RecordResult.swift +90 -0
- package/nitrogen/generated/ios/swift/SaveRecordParams.swift +68 -0
- package/nitrogen/generated/ios/swift/SaveRecordResult.swift +46 -0
- package/nitrogen/generated/shared/c++/AccountInfoResult.hpp +76 -0
- package/nitrogen/generated/shared/c++/DeleteRecordParams.hpp +71 -0
- package/nitrogen/generated/shared/c++/FetchRecordParams.hpp +71 -0
- package/nitrogen/generated/shared/c++/HybridCloudKitModuleSpec.cpp +27 -0
- package/nitrogen/generated/shared/c++/HybridCloudKitModuleSpec.hpp +95 -0
- package/nitrogen/generated/shared/c++/QueryRecordsParams.hpp +67 -0
- package/nitrogen/generated/shared/c++/QueryRecordsResult.hpp +69 -0
- package/nitrogen/generated/shared/c++/RecordExistsParams.hpp +71 -0
- package/nitrogen/generated/shared/c++/RecordResult.hpp +87 -0
- package/nitrogen/generated/shared/c++/SaveRecordParams.hpp +79 -0
- package/nitrogen/generated/shared/c++/SaveRecordResult.hpp +71 -0
- package/package.json +174 -0
- package/src/CloudKitModule.nitro.ts +64 -0
- package/src/index.tsx +8 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
//
|
|
2
|
+
// CloudKitModuleCore.swift
|
|
3
|
+
// OneKeyWallet
|
|
4
|
+
//
|
|
5
|
+
// Created by OneKey on 2025-01-27.
|
|
6
|
+
// Core implementation layer for CloudKit operations (React Native independent)
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
import Foundation
|
|
10
|
+
import CloudKit
|
|
11
|
+
|
|
12
|
+
// MARK: - Constants
|
|
13
|
+
|
|
14
|
+
struct CloudKitConstants {
|
|
15
|
+
static let recordDataField = "data"
|
|
16
|
+
static let recordMetaField = "meta"
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// MARK: - Error Types
|
|
20
|
+
|
|
21
|
+
enum CloudKitModuleError: Error {
|
|
22
|
+
case invalidParameters(String)
|
|
23
|
+
case operationFailed(String)
|
|
24
|
+
case recordNotFound
|
|
25
|
+
case noRecordReturned
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// MARK: - CloudKit Module Core
|
|
29
|
+
|
|
30
|
+
class CloudKitModuleCore {
|
|
31
|
+
|
|
32
|
+
// MARK: - Properties
|
|
33
|
+
|
|
34
|
+
// let container = CKContainer(identifier: "iCloud.so.onekey.wallet")
|
|
35
|
+
private let container = CKContainer.default()
|
|
36
|
+
private lazy var database = container.privateCloudDatabase
|
|
37
|
+
|
|
38
|
+
// MARK: - Check Availability
|
|
39
|
+
|
|
40
|
+
func isAvailable() async throws -> Bool {
|
|
41
|
+
let status = try await container.accountStatus()
|
|
42
|
+
return status == .available
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// MARK: - Get Account Info
|
|
46
|
+
|
|
47
|
+
func getAccountInfo() async throws -> AccountInfoResult {
|
|
48
|
+
let status = try await container.accountStatus()
|
|
49
|
+
var userId: String?
|
|
50
|
+
if status == .available {
|
|
51
|
+
do {
|
|
52
|
+
let userRecordID = try await container.userRecordID()
|
|
53
|
+
userId = userRecordID.recordName
|
|
54
|
+
} catch {
|
|
55
|
+
userId = nil
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
let name: String
|
|
59
|
+
switch status {
|
|
60
|
+
case .available:
|
|
61
|
+
name = "available"
|
|
62
|
+
case .noAccount:
|
|
63
|
+
name = "noAccount"
|
|
64
|
+
case .restricted:
|
|
65
|
+
name = "restricted"
|
|
66
|
+
default:
|
|
67
|
+
name = "couldNotDetermine"
|
|
68
|
+
}
|
|
69
|
+
return AccountInfoResult(status: Double(status.rawValue), statusName: name, containerUserId: userId)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// MARK: - Save Record
|
|
73
|
+
|
|
74
|
+
func saveRecord(params: SaveRecordParams) async throws -> SaveRecordResult {
|
|
75
|
+
let ckRecordID = CKRecord.ID(recordName: params.recordID)
|
|
76
|
+
let recordToSave: CKRecord
|
|
77
|
+
do {
|
|
78
|
+
// Update existing record if found
|
|
79
|
+
let record = try await database.record(for: ckRecordID)
|
|
80
|
+
recordToSave = record
|
|
81
|
+
} catch let error as CKError where error.code == .unknownItem {
|
|
82
|
+
// Create new record when not found
|
|
83
|
+
let record = CKRecord(recordType: params.recordType, recordID: ckRecordID)
|
|
84
|
+
recordToSave = record
|
|
85
|
+
}
|
|
86
|
+
recordToSave[CloudKitConstants.recordDataField] = params.data as CKRecordValue
|
|
87
|
+
recordToSave[CloudKitConstants.recordMetaField] = params.meta as CKRecordValue
|
|
88
|
+
let savedRecord = try await database.save(recordToSave)
|
|
89
|
+
let createdAt = Int64((savedRecord.creationDate?.timeIntervalSince1970 ?? 0) * 1000)
|
|
90
|
+
return SaveRecordResult(
|
|
91
|
+
recordID: savedRecord.recordID.recordName,
|
|
92
|
+
createdAt: Double(createdAt)
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// MARK: - Fetch Record
|
|
97
|
+
|
|
98
|
+
func fetchRecord(params: FetchRecordParams) async throws -> RecordResult? {
|
|
99
|
+
let ckRecordID = CKRecord.ID(recordName: params.recordID)
|
|
100
|
+
|
|
101
|
+
do {
|
|
102
|
+
let record = try await database.record(for: ckRecordID)
|
|
103
|
+
|
|
104
|
+
let data = record[CloudKitConstants.recordDataField] as? String ?? ""
|
|
105
|
+
let meta = record[CloudKitConstants.recordMetaField] as? String ?? ""
|
|
106
|
+
let createdAt = Int64((record.creationDate?.timeIntervalSince1970 ?? 0) * 1000)
|
|
107
|
+
let modifiedAt = Int64((record.modificationDate?.timeIntervalSince1970 ?? 0) * 1000)
|
|
108
|
+
|
|
109
|
+
return RecordResult(
|
|
110
|
+
recordID: record.recordID.recordName,
|
|
111
|
+
recordType: record.recordType,
|
|
112
|
+
data: data,
|
|
113
|
+
meta: meta,
|
|
114
|
+
createdAt: Double(createdAt),
|
|
115
|
+
modifiedAt: Double(modifiedAt)
|
|
116
|
+
)
|
|
117
|
+
} catch let error as CKError where error.code == .unknownItem {
|
|
118
|
+
return nil
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// MARK: - Delete Record
|
|
123
|
+
|
|
124
|
+
func deleteRecord(params: DeleteRecordParams) async throws {
|
|
125
|
+
let ckRecordID = CKRecord.ID(recordName: params.recordID)
|
|
126
|
+
|
|
127
|
+
do {
|
|
128
|
+
_ = try await database.deleteRecord(withID: ckRecordID)
|
|
129
|
+
} catch let error as CKError where error.code == .unknownItem {
|
|
130
|
+
// Item not found is considered success for delete
|
|
131
|
+
return
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// MARK: - Record Exists
|
|
136
|
+
|
|
137
|
+
func recordExists(params: RecordExistsParams) async throws -> Bool {
|
|
138
|
+
let ckRecordID = CKRecord.ID(recordName: params.recordID)
|
|
139
|
+
|
|
140
|
+
do {
|
|
141
|
+
_ = try await database.record(for: ckRecordID)
|
|
142
|
+
return true
|
|
143
|
+
} catch let error as CKError where error.code == .unknownItem {
|
|
144
|
+
return false
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// MARK: - Query Records
|
|
149
|
+
|
|
150
|
+
func queryRecords(params: QueryRecordsParams) async throws -> QueryRecordsResult {
|
|
151
|
+
let predicate = NSPredicate(value: true)
|
|
152
|
+
let query = CKQuery(recordType: params.recordType, predicate: predicate)
|
|
153
|
+
|
|
154
|
+
// Use CKQueryOperation with desiredKeys to fetch only meta (exclude large data field)
|
|
155
|
+
return try await withCheckedThrowingContinuation { continuation in
|
|
156
|
+
var results: [RecordResult] = []
|
|
157
|
+
let operation = CKQueryOperation(query: query)
|
|
158
|
+
operation.desiredKeys = [CloudKitConstants.recordMetaField]
|
|
159
|
+
// operation.resultsLimit = 500 // Optional: tune as needed
|
|
160
|
+
|
|
161
|
+
operation.recordMatchedBlock = { _, result in
|
|
162
|
+
switch result {
|
|
163
|
+
case .success(let record):
|
|
164
|
+
let meta = record[CloudKitConstants.recordMetaField] as? String ?? ""
|
|
165
|
+
let createdAt = Int64((record.creationDate?.timeIntervalSince1970 ?? 0) * 1000)
|
|
166
|
+
let modifiedAt = Int64((record.modificationDate?.timeIntervalSince1970 ?? 0) * 1000)
|
|
167
|
+
let rr = RecordResult(
|
|
168
|
+
recordID: record.recordID.recordName,
|
|
169
|
+
recordType: record.recordType,
|
|
170
|
+
data: "",
|
|
171
|
+
meta: meta,
|
|
172
|
+
createdAt: Double(createdAt),
|
|
173
|
+
modifiedAt: Double(modifiedAt)
|
|
174
|
+
)
|
|
175
|
+
results.append(rr)
|
|
176
|
+
case .failure:
|
|
177
|
+
break
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
operation.queryResultBlock = { result in
|
|
182
|
+
switch result {
|
|
183
|
+
case .success:
|
|
184
|
+
// Sort by modification time descending to return latest first
|
|
185
|
+
let sorted = results.sorted { $0.modifiedAt > $1.modifiedAt }
|
|
186
|
+
continuation.resume(returning: QueryRecordsResult(records: sorted))
|
|
187
|
+
case .failure(let error):
|
|
188
|
+
continuation.resume(throwing: error)
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
self.database.add(operation)
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["CloudKitModule.nitro.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NitroModules","CloudKitModuleHybridObject","createHybridObject","CloudKit"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AAGzD,MAAMC,0BAA0B,GAC9BD,YAAY,CAACE,kBAAkB,CAAiB,gBAAgB,CAAC;AAEnE,OAAO,MAAMC,QAAQ,GAAGF,0BAA0B","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
export interface SaveRecordParams {
|
|
3
|
+
recordType: string;
|
|
4
|
+
recordID: string;
|
|
5
|
+
data: string;
|
|
6
|
+
meta: string;
|
|
7
|
+
}
|
|
8
|
+
export interface FetchRecordParams {
|
|
9
|
+
recordType: string;
|
|
10
|
+
recordID: string;
|
|
11
|
+
}
|
|
12
|
+
export interface DeleteRecordParams {
|
|
13
|
+
recordType: string;
|
|
14
|
+
recordID: string;
|
|
15
|
+
}
|
|
16
|
+
export interface RecordExistsParams {
|
|
17
|
+
recordType: string;
|
|
18
|
+
recordID: string;
|
|
19
|
+
}
|
|
20
|
+
export interface QueryRecordsParams {
|
|
21
|
+
recordType: string;
|
|
22
|
+
}
|
|
23
|
+
export interface AccountInfoResult {
|
|
24
|
+
status: number;
|
|
25
|
+
statusName: string;
|
|
26
|
+
containerUserId?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface SaveRecordResult {
|
|
29
|
+
recordID: string;
|
|
30
|
+
createdAt: number;
|
|
31
|
+
}
|
|
32
|
+
export interface RecordResult {
|
|
33
|
+
recordID: string;
|
|
34
|
+
recordType: string;
|
|
35
|
+
data: string;
|
|
36
|
+
meta: string;
|
|
37
|
+
createdAt: number;
|
|
38
|
+
modifiedAt: number;
|
|
39
|
+
}
|
|
40
|
+
export interface QueryRecordsResult {
|
|
41
|
+
records: RecordResult[];
|
|
42
|
+
}
|
|
43
|
+
export interface CloudKitModule extends HybridObject<{
|
|
44
|
+
ios: 'swift';
|
|
45
|
+
android: 'kotlin';
|
|
46
|
+
}> {
|
|
47
|
+
isAvailable(): Promise<boolean>;
|
|
48
|
+
getAccountInfo(): Promise<AccountInfoResult>;
|
|
49
|
+
saveRecord(params: SaveRecordParams): Promise<SaveRecordResult>;
|
|
50
|
+
fetchRecord(params: FetchRecordParams): Promise<RecordResult | null>;
|
|
51
|
+
deleteRecord(params: DeleteRecordParams): Promise<boolean>;
|
|
52
|
+
recordExists(params: RecordExistsParams): Promise<boolean>;
|
|
53
|
+
queryRecords(params: QueryRecordsParams): Promise<QueryRecordsResult>;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=CloudKitModule.nitro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CloudKitModule.nitro.d.ts","sourceRoot":"","sources":["../../../src/CloudKitModule.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG/D,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;CACpB;AAGD,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,cACf,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,CAAC;IACzD,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAChC,cAAc,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC7C,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAChE,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IACrE,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3D,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3D,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CACvE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAK7D,eAAO,MAAM,QAAQ,gBAA6B,CAAC;AACnD,mBAAmB,wBAAwB,CAAC"}
|
package/nitro.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cxxNamespace": ["cloudkitmodule"],
|
|
3
|
+
"ios": {
|
|
4
|
+
"iosModuleName": "CloudKitModule"
|
|
5
|
+
},
|
|
6
|
+
"android": {
|
|
7
|
+
"androidNamespace": ["cloudkitmodule"],
|
|
8
|
+
"androidCxxLibName": "cloudkitmodule"
|
|
9
|
+
},
|
|
10
|
+
"autolinking": {
|
|
11
|
+
"CloudKitModule": {
|
|
12
|
+
"swift": "CloudKitModule",
|
|
13
|
+
"kotlin": "CloudKitModule"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"ignorePaths": ["node_modules"]
|
|
17
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JAccountInfoResult.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "AccountInfoResult.hpp"
|
|
12
|
+
|
|
13
|
+
#include <optional>
|
|
14
|
+
#include <string>
|
|
15
|
+
|
|
16
|
+
namespace margelo::nitro::cloudkitmodule {
|
|
17
|
+
|
|
18
|
+
using namespace facebook;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The C++ JNI bridge between the C++ struct "AccountInfoResult" and the the Kotlin data class "AccountInfoResult".
|
|
22
|
+
*/
|
|
23
|
+
struct JAccountInfoResult final: public jni::JavaClass<JAccountInfoResult> {
|
|
24
|
+
public:
|
|
25
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/cloudkitmodule/AccountInfoResult;";
|
|
26
|
+
|
|
27
|
+
public:
|
|
28
|
+
/**
|
|
29
|
+
* Convert this Java/Kotlin-based struct to the C++ struct AccountInfoResult by copying all values to C++.
|
|
30
|
+
*/
|
|
31
|
+
[[maybe_unused]]
|
|
32
|
+
[[nodiscard]]
|
|
33
|
+
AccountInfoResult toCpp() const {
|
|
34
|
+
static const auto clazz = javaClassStatic();
|
|
35
|
+
static const auto fieldStatus = clazz->getField<double>("status");
|
|
36
|
+
double status = this->getFieldValue(fieldStatus);
|
|
37
|
+
static const auto fieldStatusName = clazz->getField<jni::JString>("statusName");
|
|
38
|
+
jni::local_ref<jni::JString> statusName = this->getFieldValue(fieldStatusName);
|
|
39
|
+
static const auto fieldContainerUserId = clazz->getField<jni::JString>("containerUserId");
|
|
40
|
+
jni::local_ref<jni::JString> containerUserId = this->getFieldValue(fieldContainerUserId);
|
|
41
|
+
return AccountInfoResult(
|
|
42
|
+
status,
|
|
43
|
+
statusName->toStdString(),
|
|
44
|
+
containerUserId != nullptr ? std::make_optional(containerUserId->toStdString()) : std::nullopt
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
/**
|
|
50
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
51
|
+
*/
|
|
52
|
+
[[maybe_unused]]
|
|
53
|
+
static jni::local_ref<JAccountInfoResult::javaobject> fromCpp(const AccountInfoResult& value) {
|
|
54
|
+
return newInstance(
|
|
55
|
+
value.status,
|
|
56
|
+
jni::make_jstring(value.statusName),
|
|
57
|
+
value.containerUserId.has_value() ? jni::make_jstring(value.containerUserId.value()) : nullptr
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
} // namespace margelo::nitro::cloudkitmodule
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JDeleteRecordParams.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "DeleteRecordParams.hpp"
|
|
12
|
+
|
|
13
|
+
#include <string>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::cloudkitmodule {
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "DeleteRecordParams" and the the Kotlin data class "DeleteRecordParams".
|
|
21
|
+
*/
|
|
22
|
+
struct JDeleteRecordParams final: public jni::JavaClass<JDeleteRecordParams> {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/cloudkitmodule/DeleteRecordParams;";
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Convert this Java/Kotlin-based struct to the C++ struct DeleteRecordParams by copying all values to C++.
|
|
29
|
+
*/
|
|
30
|
+
[[maybe_unused]]
|
|
31
|
+
[[nodiscard]]
|
|
32
|
+
DeleteRecordParams toCpp() const {
|
|
33
|
+
static const auto clazz = javaClassStatic();
|
|
34
|
+
static const auto fieldRecordType = clazz->getField<jni::JString>("recordType");
|
|
35
|
+
jni::local_ref<jni::JString> recordType = this->getFieldValue(fieldRecordType);
|
|
36
|
+
static const auto fieldRecordID = clazz->getField<jni::JString>("recordID");
|
|
37
|
+
jni::local_ref<jni::JString> recordID = this->getFieldValue(fieldRecordID);
|
|
38
|
+
return DeleteRecordParams(
|
|
39
|
+
recordType->toStdString(),
|
|
40
|
+
recordID->toStdString()
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public:
|
|
45
|
+
/**
|
|
46
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
47
|
+
*/
|
|
48
|
+
[[maybe_unused]]
|
|
49
|
+
static jni::local_ref<JDeleteRecordParams::javaobject> fromCpp(const DeleteRecordParams& value) {
|
|
50
|
+
return newInstance(
|
|
51
|
+
jni::make_jstring(value.recordType),
|
|
52
|
+
jni::make_jstring(value.recordID)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
} // namespace margelo::nitro::cloudkitmodule
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JFetchRecordParams.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "FetchRecordParams.hpp"
|
|
12
|
+
|
|
13
|
+
#include <string>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::cloudkitmodule {
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "FetchRecordParams" and the the Kotlin data class "FetchRecordParams".
|
|
21
|
+
*/
|
|
22
|
+
struct JFetchRecordParams final: public jni::JavaClass<JFetchRecordParams> {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/cloudkitmodule/FetchRecordParams;";
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Convert this Java/Kotlin-based struct to the C++ struct FetchRecordParams by copying all values to C++.
|
|
29
|
+
*/
|
|
30
|
+
[[maybe_unused]]
|
|
31
|
+
[[nodiscard]]
|
|
32
|
+
FetchRecordParams toCpp() const {
|
|
33
|
+
static const auto clazz = javaClassStatic();
|
|
34
|
+
static const auto fieldRecordType = clazz->getField<jni::JString>("recordType");
|
|
35
|
+
jni::local_ref<jni::JString> recordType = this->getFieldValue(fieldRecordType);
|
|
36
|
+
static const auto fieldRecordID = clazz->getField<jni::JString>("recordID");
|
|
37
|
+
jni::local_ref<jni::JString> recordID = this->getFieldValue(fieldRecordID);
|
|
38
|
+
return FetchRecordParams(
|
|
39
|
+
recordType->toStdString(),
|
|
40
|
+
recordID->toStdString()
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public:
|
|
45
|
+
/**
|
|
46
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
47
|
+
*/
|
|
48
|
+
[[maybe_unused]]
|
|
49
|
+
static jni::local_ref<JFetchRecordParams::javaobject> fromCpp(const FetchRecordParams& value) {
|
|
50
|
+
return newInstance(
|
|
51
|
+
jni::make_jstring(value.recordType),
|
|
52
|
+
jni::make_jstring(value.recordID)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
} // namespace margelo::nitro::cloudkitmodule
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridCloudKitModuleSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "JHybridCloudKitModuleSpec.hpp"
|
|
9
|
+
|
|
10
|
+
// Forward declaration of `AccountInfoResult` to properly resolve imports.
|
|
11
|
+
namespace margelo::nitro::cloudkitmodule { struct AccountInfoResult; }
|
|
12
|
+
// Forward declaration of `SaveRecordResult` to properly resolve imports.
|
|
13
|
+
namespace margelo::nitro::cloudkitmodule { struct SaveRecordResult; }
|
|
14
|
+
// Forward declaration of `RecordResult` to properly resolve imports.
|
|
15
|
+
namespace margelo::nitro::cloudkitmodule { struct RecordResult; }
|
|
16
|
+
// Forward declaration of `QueryRecordsResult` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::cloudkitmodule { struct QueryRecordsResult; }
|
|
18
|
+
// Forward declaration of `SaveRecordParams` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::cloudkitmodule { struct SaveRecordParams; }
|
|
20
|
+
// Forward declaration of `FetchRecordParams` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::cloudkitmodule { struct FetchRecordParams; }
|
|
22
|
+
// Forward declaration of `DeleteRecordParams` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::cloudkitmodule { struct DeleteRecordParams; }
|
|
24
|
+
// Forward declaration of `RecordExistsParams` to properly resolve imports.
|
|
25
|
+
namespace margelo::nitro::cloudkitmodule { struct RecordExistsParams; }
|
|
26
|
+
// Forward declaration of `QueryRecordsParams` to properly resolve imports.
|
|
27
|
+
namespace margelo::nitro::cloudkitmodule { struct QueryRecordsParams; }
|
|
28
|
+
|
|
29
|
+
#include <NitroModules/Promise.hpp>
|
|
30
|
+
#include <NitroModules/JPromise.hpp>
|
|
31
|
+
#include "AccountInfoResult.hpp"
|
|
32
|
+
#include "JAccountInfoResult.hpp"
|
|
33
|
+
#include <string>
|
|
34
|
+
#include <optional>
|
|
35
|
+
#include "SaveRecordResult.hpp"
|
|
36
|
+
#include "JSaveRecordResult.hpp"
|
|
37
|
+
#include "RecordResult.hpp"
|
|
38
|
+
#include "JRecordResult.hpp"
|
|
39
|
+
#include "QueryRecordsResult.hpp"
|
|
40
|
+
#include "JQueryRecordsResult.hpp"
|
|
41
|
+
#include <vector>
|
|
42
|
+
#include "SaveRecordParams.hpp"
|
|
43
|
+
#include "JSaveRecordParams.hpp"
|
|
44
|
+
#include "FetchRecordParams.hpp"
|
|
45
|
+
#include "JFetchRecordParams.hpp"
|
|
46
|
+
#include "DeleteRecordParams.hpp"
|
|
47
|
+
#include "JDeleteRecordParams.hpp"
|
|
48
|
+
#include "RecordExistsParams.hpp"
|
|
49
|
+
#include "JRecordExistsParams.hpp"
|
|
50
|
+
#include "QueryRecordsParams.hpp"
|
|
51
|
+
#include "JQueryRecordsParams.hpp"
|
|
52
|
+
|
|
53
|
+
namespace margelo::nitro::cloudkitmodule {
|
|
54
|
+
|
|
55
|
+
jni::local_ref<JHybridCloudKitModuleSpec::jhybriddata> JHybridCloudKitModuleSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
56
|
+
return makeCxxInstance(jThis);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
void JHybridCloudKitModuleSpec::registerNatives() {
|
|
60
|
+
registerHybrid({
|
|
61
|
+
makeNativeMethod("initHybrid", JHybridCloudKitModuleSpec::initHybrid),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
size_t JHybridCloudKitModuleSpec::getExternalMemorySize() noexcept {
|
|
66
|
+
static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
|
|
67
|
+
return method(_javaPart);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
void JHybridCloudKitModuleSpec::dispose() noexcept {
|
|
71
|
+
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
|
|
72
|
+
method(_javaPart);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Properties
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
// Methods
|
|
79
|
+
std::shared_ptr<Promise<bool>> JHybridCloudKitModuleSpec::isAvailable() {
|
|
80
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("isAvailable");
|
|
81
|
+
auto __result = method(_javaPart);
|
|
82
|
+
return [&]() {
|
|
83
|
+
auto __promise = Promise<bool>::create();
|
|
84
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
85
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
86
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
87
|
+
});
|
|
88
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
89
|
+
jni::JniException __jniError(__throwable);
|
|
90
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
91
|
+
});
|
|
92
|
+
return __promise;
|
|
93
|
+
}();
|
|
94
|
+
}
|
|
95
|
+
std::shared_ptr<Promise<AccountInfoResult>> JHybridCloudKitModuleSpec::getAccountInfo() {
|
|
96
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getAccountInfo");
|
|
97
|
+
auto __result = method(_javaPart);
|
|
98
|
+
return [&]() {
|
|
99
|
+
auto __promise = Promise<AccountInfoResult>::create();
|
|
100
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
101
|
+
auto __result = jni::static_ref_cast<JAccountInfoResult>(__boxedResult);
|
|
102
|
+
__promise->resolve(__result->toCpp());
|
|
103
|
+
});
|
|
104
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
105
|
+
jni::JniException __jniError(__throwable);
|
|
106
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
107
|
+
});
|
|
108
|
+
return __promise;
|
|
109
|
+
}();
|
|
110
|
+
}
|
|
111
|
+
std::shared_ptr<Promise<SaveRecordResult>> JHybridCloudKitModuleSpec::saveRecord(const SaveRecordParams& params) {
|
|
112
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JSaveRecordParams> /* params */)>("saveRecord");
|
|
113
|
+
auto __result = method(_javaPart, JSaveRecordParams::fromCpp(params));
|
|
114
|
+
return [&]() {
|
|
115
|
+
auto __promise = Promise<SaveRecordResult>::create();
|
|
116
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
117
|
+
auto __result = jni::static_ref_cast<JSaveRecordResult>(__boxedResult);
|
|
118
|
+
__promise->resolve(__result->toCpp());
|
|
119
|
+
});
|
|
120
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
121
|
+
jni::JniException __jniError(__throwable);
|
|
122
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
123
|
+
});
|
|
124
|
+
return __promise;
|
|
125
|
+
}();
|
|
126
|
+
}
|
|
127
|
+
std::shared_ptr<Promise<std::optional<RecordResult>>> JHybridCloudKitModuleSpec::fetchRecord(const FetchRecordParams& params) {
|
|
128
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JFetchRecordParams> /* params */)>("fetchRecord");
|
|
129
|
+
auto __result = method(_javaPart, JFetchRecordParams::fromCpp(params));
|
|
130
|
+
return [&]() {
|
|
131
|
+
auto __promise = Promise<std::optional<RecordResult>>::create();
|
|
132
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
133
|
+
auto __result = jni::static_ref_cast<JRecordResult>(__boxedResult);
|
|
134
|
+
__promise->resolve(__result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt);
|
|
135
|
+
});
|
|
136
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
137
|
+
jni::JniException __jniError(__throwable);
|
|
138
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
139
|
+
});
|
|
140
|
+
return __promise;
|
|
141
|
+
}();
|
|
142
|
+
}
|
|
143
|
+
std::shared_ptr<Promise<bool>> JHybridCloudKitModuleSpec::deleteRecord(const DeleteRecordParams& params) {
|
|
144
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JDeleteRecordParams> /* params */)>("deleteRecord");
|
|
145
|
+
auto __result = method(_javaPart, JDeleteRecordParams::fromCpp(params));
|
|
146
|
+
return [&]() {
|
|
147
|
+
auto __promise = Promise<bool>::create();
|
|
148
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
149
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
150
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
151
|
+
});
|
|
152
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
153
|
+
jni::JniException __jniError(__throwable);
|
|
154
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
155
|
+
});
|
|
156
|
+
return __promise;
|
|
157
|
+
}();
|
|
158
|
+
}
|
|
159
|
+
std::shared_ptr<Promise<bool>> JHybridCloudKitModuleSpec::recordExists(const RecordExistsParams& params) {
|
|
160
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JRecordExistsParams> /* params */)>("recordExists");
|
|
161
|
+
auto __result = method(_javaPart, JRecordExistsParams::fromCpp(params));
|
|
162
|
+
return [&]() {
|
|
163
|
+
auto __promise = Promise<bool>::create();
|
|
164
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
165
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
166
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
167
|
+
});
|
|
168
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
169
|
+
jni::JniException __jniError(__throwable);
|
|
170
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
171
|
+
});
|
|
172
|
+
return __promise;
|
|
173
|
+
}();
|
|
174
|
+
}
|
|
175
|
+
std::shared_ptr<Promise<QueryRecordsResult>> JHybridCloudKitModuleSpec::queryRecords(const QueryRecordsParams& params) {
|
|
176
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JQueryRecordsParams> /* params */)>("queryRecords");
|
|
177
|
+
auto __result = method(_javaPart, JQueryRecordsParams::fromCpp(params));
|
|
178
|
+
return [&]() {
|
|
179
|
+
auto __promise = Promise<QueryRecordsResult>::create();
|
|
180
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
181
|
+
auto __result = jni::static_ref_cast<JQueryRecordsResult>(__boxedResult);
|
|
182
|
+
__promise->resolve(__result->toCpp());
|
|
183
|
+
});
|
|
184
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
185
|
+
jni::JniException __jniError(__throwable);
|
|
186
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
187
|
+
});
|
|
188
|
+
return __promise;
|
|
189
|
+
}();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
} // namespace margelo::nitro::cloudkitmodule
|