1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit ArkData 19 */ 20 21import { AsyncCallback, Callback } from './@ohos.base'; 22import type relationalStore from './@ohos.data.relationalStore'; 23import commonType from './@ohos.data.commonType'; 24 25/** 26 * Provides methods for cloud capabilities. 27 * 28 * @namespace cloudData 29 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 30 * @since 10 31 */ 32declare namespace cloudData { 33 /** 34 * Describes the clear action type. 35 * 36 * @enum { number } 37 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 38 * @systemapi 39 * @since 10 40 */ 41 enum ClearAction { 42 /** 43 * Indicates clearing cloud-related data only, which includes cloud meta data and cloud-related local data. 44 * 45 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 46 * @systemapi 47 * @since 10 48 */ 49 CLEAR_CLOUD_INFO, 50 51 /** 52 * Indicates clearing all cloud-related file data,which synchronized with the cloud. 53 * 54 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 55 * @systemapi 56 * @since 10 57 */ 58 CLEAR_CLOUD_DATA_AND_INFO 59 } 60 61 /** 62 * ID of the event, which indicates the change of the data in the cloud. 63 * 64 * @constant 65 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 66 * @systemapi 67 * @since 11 68 */ 69 const DATA_CHANGE_EVENT_ID = 'cloud_data_change'; 70 71 /** 72 * Extra data for data change notification. 73 * 74 * @interface ExtraData 75 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 76 * @systemapi 77 * @since 11 78 */ 79 interface ExtraData { 80 /** 81 * Event ID. 82 * 83 * @type { string } 84 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 85 * @systemapi 86 * @since 11 87 */ 88 eventId: string; 89 90 /** 91 * Extra data, which contains the following fields. 92 * '{ 93 * "data": "{ 94 * "accountId": "aaa", 95 * "bundleName": "com.bbb.xxx", 96 * "containerName": "alias", 97 * "databaseScopes": ["private", "shared"], 98 * "recordTypes": ["xxx", "yyy", "zzz"] 99 * }" 100 * }' 101 * All fields are mandatory. 102 * 103 * @type { string } 104 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 105 * @systemapi 106 * @since 11 107 */ 108 extraData: string; 109 } 110 111 /** 112 * Additional data for querying data statistics information. 113 * 114 * @interface StatisticInfo 115 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 116 * @systemapi 117 * @since 12 118 */ 119 interface StatisticInfo { 120 /** 121 * Cloud table name. 122 * 123 * @type { string } 124 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 125 * @systemapi 126 * @since 12 127 */ 128 table: string; 129 130 /** 131 * Number of records to be inserted to the cloud. 132 * 133 * @type { number } 134 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 135 * @systemapi 136 * @since 12 137 */ 138 inserted: number; 139 140 /** 141 * Number of inconsistent records between the local device and the cloud. 142 * 143 * @type { number } 144 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 145 * @systemapi 146 * @since 12 147 */ 148 updated: number; 149 150 /** 151 * Number of consistent records between the local device and the cloud. 152 * 153 * @type { number } 154 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 155 * @systemapi 156 * @since 12 157 */ 158 normal: number; 159 } 160 161 /** 162 * Describes sync status. 163 * 164 * @enum { number } 165 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 166 * @systemapi 167 * @since 18 168 */ 169 enum SyncStatus { 170 /** 171 * Indicates cloud sync status is running. 172 * 173 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 174 * @systemapi 175 * @since 18 176 */ 177 RUNNING = 0, 178 179 /** 180 * Indicates cloud sync status was finished. 181 * 182 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 183 * @systemapi 184 * @since 18 185 */ 186 FINISHED = 1 187 } 188 189 /** 190 * Sync information. 191 * 192 * @interface SyncInfo 193 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 194 * @systemapi 195 * @since 12 196 */ 197 interface SyncInfo { 198 /** 199 * Sync start time. 200 * 201 * @type { Date } 202 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 203 * @systemapi 204 * @since 12 205 */ 206 startTime: Date; 207 208 /** 209 * Sync finish time. 210 * 211 * @type { Date } 212 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 213 * @systemapi 214 * @since 12 215 */ 216 finishTime: Date; 217 218 /** 219 * Sync progress. 220 * 221 * @type { relationalStore.ProgressCode } 222 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 223 * @systemapi 224 * @since 12 225 */ 226 code: relationalStore.ProgressCode; 227 228 /** 229 * Sync status. 230 * 231 * @type { ?SyncStatus } 232 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 233 * @systemapi 234 * @since 18 235 */ 236 syncStatus?: SyncStatus; 237 } 238 239 /** 240 * Provides methods to set CloudSync config. 241 * 242 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 243 * @systemapi 244 * @since 10 245 */ 246 class Config { 247 /** 248 * Enables the cloud function. 249 * 250 * @permission ohos.permission.CLOUDDATA_CONFIG 251 * @param { string } accountId - Indicates the account ID. The account ID is required by hashing cloud account. 252 * @param { object } switches - Indicates switches information of all applications. 253 * switches will overwrite the saved application switch information.If the specific application switch changes, 254 * the {@link changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean)} method will notify the data manager service. 255 * @param { AsyncCallback<void> } callback - the callback of enableCloud. 256 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 257 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 258 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 259 * 3. Parameter verification failed. 260 * @throws { BusinessError } 801 - Capability not supported. 261 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 262 * @systemapi 263 * @since 10 264 */ 265 /** 266 * Enables the cloud function. 267 * 268 * @permission ohos.permission.CLOUDDATA_CONFIG 269 * @param { string } accountId - Indicates the account ID. The account ID is required by hashing cloud account. 270 * @param { Record<string, boolean> } switches - Indicates switches information of all applications. 271 * switches will overwrite the saved application switch information.If the specific application switch changes, 272 * the {@link changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean)} method will notify the data manager service. 273 * @param { AsyncCallback<void> } callback - the callback of enableCloud. 274 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 275 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 276 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 277 * 3. Parameter verification failed. 278 * @throws { BusinessError } 801 - Capability not supported. 279 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 280 * @systemapi 281 * @since 11 282 */ 283 static enableCloud( 284 accountId: string, 285 switches: Record<string, boolean>, 286 callback: AsyncCallback<void> 287 ): void; 288 289 /** 290 * Enables the cloud function. 291 * 292 * @permission ohos.permission.CLOUDDATA_CONFIG 293 * @param { string } accountId - Indicates the account ID. The account ID is required by hashing cloud account. 294 * @param { object } switches - Indicates switches information of all applications. 295 * switches will overwrite the saved application switch information.If the specific application switch changes, 296 * the {@link changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean)} method will notify the data manager service. 297 * @returns { Promise<void> } the promise returned by the function. 298 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 299 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 300 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 301 * 3. Parameter verification failed. 302 * @throws { BusinessError } 801 - Capability not supported. 303 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 304 * @systemapi 305 * @since 10 306 */ 307 /** 308 * Enables the cloud function. 309 * 310 * @permission ohos.permission.CLOUDDATA_CONFIG 311 * @param { string } accountId - Indicates the account ID. The account ID is required by hashing cloud account. 312 * @param { Record<string, boolean> } switches - Indicates switches information of all applications. 313 * switches will overwrite the saved application switch information.If the specific application switch changes, 314 * the {@link changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean)} method will notify the data manager service. 315 * @returns { Promise<void> } the promise returned by the function. 316 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 317 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 318 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 319 * 3. Parameter verification failed. 320 * @throws { BusinessError } 801 - Capability not supported. 321 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 322 * @systemapi 323 * @since 11 324 */ 325 static enableCloud(accountId: string, switches: Record<string, boolean>): Promise<void>; 326 327 /** 328 * Disables the cloud function. 329 * 330 * @permission ohos.permission.CLOUDDATA_CONFIG 331 * @param { string } accountId - Indicates the account ID. The account ID is required by hashing cloud account. 332 * @param { AsyncCallback<void> } callback - the callback of disableCloud. 333 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 334 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 335 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 336 * 3. Parameter verification failed. 337 * @throws { BusinessError } 801 - Capability not supported. 338 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 339 * @systemapi 340 * @since 10 341 */ 342 static disableCloud(accountId: string, callback: AsyncCallback<void>): void; 343 344 /** 345 * Disables the cloud function. 346 * 347 * @permission ohos.permission.CLOUDDATA_CONFIG 348 * @param { string } accountId - Indicates the account ID. The account ID is required by hashing cloud account. 349 * @returns { Promise<void> } the promise returned by the function. 350 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 351 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 352 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 353 * 3. Parameter verification failed. 354 * @throws { BusinessError } 801 - Capability not supported. 355 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 356 * @systemapi 357 * @since 10 358 */ 359 static disableCloud(accountId: string): Promise<void>; 360 361 /** 362 * Changes the cloud switch of a single application. 363 * 364 * @permission ohos.permission.CLOUDDATA_CONFIG 365 * @param { string } accountId - Indicates the account ID. The account ID is required by hashing cloud account. 366 * @param { string } bundleName - Indicates the name of application. 367 * @param { boolean } status - Indicates the condition of cloud sync switch.true means the switch is on,false means switch is off. 368 * @param { AsyncCallback<void> } callback - the callback of changeAppCloudSwitch. 369 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 370 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 371 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 372 * 3. Parameter verification failed. 373 * @throws { BusinessError } 801 - Capability not supported. 374 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 375 * @systemapi 376 * @since 10 377 */ 378 static changeAppCloudSwitch( 379 accountId: string, 380 bundleName: string, 381 status: boolean, 382 callback: AsyncCallback<void> 383 ): void; 384 385 /** 386 * Changes the cloud switch of a single application. 387 * 388 * @permission ohos.permission.CLOUDDATA_CONFIG 389 * @param { string } accountId - Indicates the account ID. The account ID is required by hashing cloud account. 390 * @param { string } bundleName - Indicates the name of application. 391 * @param { boolean } status - Indicates the condition of cloud sync switch.true means the switch is on,false means switch is off. 392 * @returns { Promise<void> } the promise returned by the function. 393 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 394 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 395 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 396 * 3. Parameter verification failed. 397 * @throws { BusinessError } 801 - Capability not supported. 398 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 399 * @systemapi 400 * @since 10 401 */ 402 static changeAppCloudSwitch(accountId: string, bundleName: string, status: boolean): Promise<void>; 403 404 /** 405 * Notifies changes of the cloud records. 406 * 407 * @permission ohos.permission.CLOUDDATA_CONFIG 408 * @param { ExtraData } extInfo - Indicates the extra data for 409 * notification {@link ExtraData}. 410 * @param { number } [userId] - Indicates the user ID. 411 * @returns { Promise<void> } Promise used to return the result. 412 * @throws { BusinessError } 201 - Permission verification failed, which 413 * is usually returned by <b>VerifyAccessToken</b>. 414 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 415 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 416 * 3. Parameter verification failed. 417 * @throws { BusinessError } 801 - Capability not supported. 418 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 419 * @systemapi 420 * @since 11 421 */ 422 static notifyDataChange(extInfo: ExtraData, userId?: number): Promise<void>; 423 424 /** 425 * Notifies changes of the cloud records. 426 * 427 * @permission ohos.permission.CLOUDDATA_CONFIG 428 * @param { ExtraData } extInfo - Indicates the extra data for 429 * notification {@link ExtraData}. 430 * @param { AsyncCallback<void> } callback - Indicates the callback invoked 431 * to return the data changes. 432 * @throws { BusinessError } 201 - Permission verification failed, which 433 * is usually returned by <b>VerifyAccessToken</b>. 434 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 435 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 436 * 3. Parameter verification failed. 437 * @throws { BusinessError } 801 - Capability not supported. 438 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 439 * @systemapi 440 * @since 11 441 */ 442 static notifyDataChange(extInfo: ExtraData, callback: AsyncCallback<void>): void; 443 444 /** 445 * Notifies changes of the cloud records. 446 * 447 * @permission ohos.permission.CLOUDDATA_CONFIG 448 * @param { ExtraData } extInfo - Indicates the extra data for 449 * notification {@link ExtraData}. 450 * @param { number } userId - Indicates the user ID. 451 * @param { AsyncCallback<void> } callback - Indicates the callback invoked 452 * to return the data changes. 453 * @throws { BusinessError } 201 - Permission verification failed, which 454 * is usually returned by <b>VerifyAccessToken</b>. 455 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 456 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 457 * 3. Parameter verification failed. 458 * @throws { BusinessError } 801 - Capability not supported. 459 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 460 * @systemapi 461 * @since 11 462 */ 463 static notifyDataChange(extInfo: ExtraData, userId: number, callback: AsyncCallback<void>): void; 464 465 /** 466 * notifies changes of the cloud records 467 * 468 * @permission ohos.permission.CLOUDDATA_CONFIG 469 * @param { string } accountId - Indicates the account ID. The account ID is required by hashing cloud account. 470 * @param { string } bundleName - Indicates the name of application. 471 * @returns { Promise<void> } the promise returned by the function. 472 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 473 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 474 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 475 * 3. Parameter verification failed. 476 * @throws { BusinessError } 801 - Capability not supported. 477 * @syscap SystemCapability.DistributedDataManager.CloudSync.Server 478 * @systemapi 479 * @since 10 480 */ 481 static notifyDataChange(accountId: string, bundleName: string): Promise<void>; 482 483 /** 484 * notifies changes of the cloud records 485 * 486 * @permission ohos.permission.CLOUDDATA_CONFIG 487 * @param { string } accountId - Indicates the account ID. The account ID is required by hashing cloud account. 488 * @param { string } bundleName - Indicates the name of application. 489 * @param { AsyncCallback<void> } callback - the callback of notifyDataChange. 490 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 491 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 492 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 493 * 3. Parameter verification failed. 494 * @throws { BusinessError } 801 - Capability not supported. 495 * @syscap SystemCapability.DistributedDataManager.CloudSync.Server 496 * @systemapi 497 * @since 10 498 */ 499 static notifyDataChange(accountId: string, bundleName: string, callback: AsyncCallback<void>): void; 500 501 /** 502 * Queries statistics of the cloud records. 503 * 504 * @permission ohos.permission.CLOUDDATA_CONFIG 505 * @param { string } accountId - Indicates the account ID. The account ID is required by hashing cloud account. 506 * @param { string } bundleName - Indicates the name of application. 507 * @param { string } [storeId] - Indicates the store ID. 508 * @returns { Promise<Record<string, Array<StatisticInfo>>> } Promise used to return the result. 509 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 510 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 511 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 512 * 3. Parameter verification failed. 513 * @throws { BusinessError } 801 - Capability not supported. 514 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 515 * @systemapi 516 * @since 12 517 */ 518 static queryStatistics( 519 accountId: string, 520 bundleName: string, 521 storeId?: string 522 ): Promise<Record<string, Array<StatisticInfo>>>; 523 524 /** 525 * Queries last sync information. 526 * 527 * @permission ohos.permission.CLOUDDATA_CONFIG 528 * @param { string } accountId - Indicates the account ID. The account ID is required by hashing cloud account. 529 * @param { string } bundleName - Indicates the name of application. 530 * @param { string } [storeId] - Indicates the store ID. 531 * @returns { Promise<Record<string, SyncInfo>> } Promise used to return the result. 532 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 533 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 534 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 535 * 3. Parameter verification failed. 536 * @throws { BusinessError } 801 - Capability not supported. 537 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 538 * @systemapi 539 * @since 12 540 */ 541 static queryLastSyncInfo( 542 accountId: string, 543 bundleName: string, 544 storeId?: string 545 ): Promise<Record<string, SyncInfo>>; 546 547 /** 548 * deletes cloud information from local data. 549 * 550 * @permission ohos.permission.CLOUDDATA_CONFIG 551 * @param { string } accountId - Indicates the account ID. The account ID is required by hashing cloud account. 552 * @param { object } appActions - Indicates the way in which the application data is to be cleared. 553 * @param { AsyncCallback<void> } callback - the callback of clear. 554 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 555 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 556 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 557 * 3. Parameter verification failed. 558 * @throws { BusinessError } 801 - Capability not supported. 559 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 560 * @systemapi 561 * @since 10 562 */ 563 /** 564 * deletes cloud information from local data. 565 * 566 * @permission ohos.permission.CLOUDDATA_CONFIG 567 * @param { string } accountId - Indicates the account ID. The account ID is required by hashing cloud account. 568 * @param { Record<string, ClearAction> } appActions - Indicates the way in which the application data is to be cleared. 569 * @param { AsyncCallback<void> } callback - the callback of clear. 570 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 571 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 572 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 573 * 3. Parameter verification failed. 574 * @throws { BusinessError } 801 - Capability not supported. 575 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 576 * @systemapi 577 * @since 11 578 */ 579 static clear( 580 accountId: string, 581 appActions: Record<string, ClearAction>, 582 callback: AsyncCallback<void> 583 ): void; 584 585 /** 586 * deletes cloud information from local data. 587 * 588 * @permission ohos.permission.CLOUDDATA_CONFIG 589 * @param { string } accountId - Indicates the account ID. The account ID is required by hashing the information of specific opened cloud. 590 * @param { object } appActions - Indicates the way in which the application data is to be cleared. 591 * @returns { Promise<void> } the promise returned by the function. 592 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 593 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 594 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 595 * 3. Parameter verification failed. 596 * @throws { BusinessError } 801 - Capability not supported. 597 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 598 * @systemapi 599 * @since 10 600 */ 601 /** 602 * deletes cloud information from local data. 603 * 604 * @permission ohos.permission.CLOUDDATA_CONFIG 605 * @param { string } accountId - Indicates the account ID. The account ID is required by hashing the information of specific opened cloud. 606 * @param { Record<string, ClearAction> } appActions - Indicates the way in which the application data is to be cleared. 607 * @returns { Promise<void> } the promise returned by the function. 608 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 609 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 610 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 611 * 3. Parameter verification failed. 612 * @throws { BusinessError } 801 - Capability not supported. 613 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 614 * @systemapi 615 * @since 11 616 */ 617 static clear(accountId: string, appActions: Record<string, ClearAction>): Promise<void>; 618 619 /** 620 * Sets global cloud strategy. 621 * 622 * @permission ohos.permission.CLOUDDATA_CONFIG 623 * @param { StrategyType } strategy - Indicates the strategy type of the cloud sync. 624 * @param { Array<commonType.ValueType> } param - Indicates specific strategy of the cloud sync. 625 * @returns { Promise<void> } Promise used to return the result. 626 * @throws { BusinessError } 201 - Permission verification failed, usually the result returned by VerifyAccessToken. 627 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 628 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 629 * 3. Parameter verification failed. 630 * @throws { BusinessError } 801 - Capability not supported. 631 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 632 * @systemapi 633 * @since 12 634 */ 635 static setGlobalCloudStrategy(strategy: StrategyType, param?: Array<commonType.ValueType>): Promise<void>; 636 637 /** 638 * Sync data to cloud. 639 * 640 * @permission ohos.permission.CLOUDDATA_CONFIG 641 * @param { string } bundleName - Indicates the name of application. 642 * @param { string } storeId - Indicates the store ID. 643 * @param { relationalStore.SyncMode } mode - indicates the database synchronization mode. 644 * @param { Callback<relationalStore.ProgressDetails> } progress - the specified sync condition by 645 * <br>the instance object of {@link ProgressDetails}. 646 * @returns { Promise<void> } : The promise returned by the function. 647 * @throws { BusinessError } 201 - Permission verification failed, 648 * <br>usually the result returned by VerifyAccessToken. 649 * @throws { BusinessError } 202 - Permission verification failed, 650 * <br>application which is not a system application uses system API. 651 * @throws { BusinessError } 801 - Capability not supported. 652 * @throws { BusinessError } 14800001 - Invalid arguments. Possible causes: 1. Parameter is out of valid range. 653 * @static 654 * @syscap SystemCapability.DistributedDataManager.CloudSync.Config 655 * @systemapi 656 * @since 20 657 */ 658 static cloudSync( 659 bundleName: string, 660 storeId: string, 661 mode: relationalStore.SyncMode, 662 progress: Callback<relationalStore.ProgressDetails> 663 ): Promise<void>; 664 } 665 666 /** 667 * Enumerates the strategy types of cloud sync. 668 * 669 * @enum { number } 670 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 671 * @since 12 672 */ 673 enum StrategyType { 674 675 /** 676 * Sync via the network. 677 * 678 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 679 * @since 12 680 */ 681 NETWORK 682 } 683 684 /** 685 * Enumerates the types of cloud sync via the network. 686 * 687 * @enum { number } 688 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 689 * @since 12 690 */ 691 enum NetWorkStrategy { 692 693 /** 694 * Sync using WiFi. 695 * 696 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 697 * @since 12 698 */ 699 WIFI = 1, 700 701 /** 702 * Sync using the cellular network. 703 * 704 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 705 * @since 12 706 */ 707 CELLULAR = 2, 708 } 709 710 /** 711 * Sets cloud strategy. 712 * 713 * @param { StrategyType } strategy - Indicates the strategy type of the cloud sync. 714 * @param { Array<commonType.ValueType> } param - Indicates specific strategy of the cloud sync. 715 * @returns { Promise<void> } Promise used to return the result. 716 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 717 * 3. Parameter verification failed. 718 * @throws { BusinessError } 801 - Capability not supported. 719 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 720 * @since 12 721 */ 722 function setCloudStrategy(strategy: StrategyType, param?: Array<commonType.ValueType>): Promise<void>; 723 724 /** 725 * Provides methods to implement cloud sharing. 726 * 727 * @namespace sharing 728 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 729 * @systemapi 730 * @since 11 731 */ 732 export namespace sharing { 733 /** 734 * Enumerates the roles. 735 * 736 * @enum { number } 737 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 738 * @systemapi 739 * @since 11 740 */ 741 enum Role { 742 /** 743 * ROLE_INVITER: means inviter of cloud sharing. 744 * 745 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 746 * @systemapi 747 * @since 11 748 */ 749 ROLE_INVITER = 0, 750 751 /** 752 * ROLE_INVITEE: means invitee of cloud sharing. 753 * 754 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 755 * @systemapi 756 * @since 11 757 */ 758 ROLE_INVITEE = 1, 759 } 760 761 /** 762 * Enumerates the states of sharing invitation. 763 * 764 * @enum { number } 765 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 766 * @systemapi 767 * @since 11 768 */ 769 enum State { 770 /** 771 * STATE_UNKNOWN: Unknown state. 772 * 773 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 774 * @systemapi 775 * @since 11 776 */ 777 STATE_UNKNOWN = 0, 778 779 /** 780 * STATE_ACCEPTED: Accept the sharing invitation. 781 * 782 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 783 * @systemapi 784 * @since 11 785 */ 786 STATE_ACCEPTED = 1, 787 788 /** 789 * STATE_REJECTED: Reject the sharing invitation. 790 * 791 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 792 * @systemapi 793 * @since 11 794 */ 795 STATE_REJECTED = 2, 796 797 /** 798 * STATE_SUSPENDED: Suspend the sharing process. 799 * 800 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 801 * @systemapi 802 * @since 11 803 */ 804 STATE_SUSPENDED = 3, 805 806 /** 807 * STATE_UNAVAILABLE: The sharing process unavailable. 808 * 809 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 810 * @systemapi 811 * @since 12 812 */ 813 STATE_UNAVAILABLE = 4, 814 } 815 816 /** 817 * Enumerates the error code of sharing invitation. 818 * 819 * @enum { number } 820 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 821 * @systemapi 822 * @since 11 823 */ 824 enum SharingCode { 825 /** 826 * SUCCESS: means sharing success. 827 * 828 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 829 * @systemapi 830 * @since 11 831 */ 832 SUCCESS = 0, 833 834 /** 835 * REPEATED_REQUEST: means the user has been invited. 836 * 837 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 838 * @systemapi 839 * @since 11 840 */ 841 REPEATED_REQUEST = 1, 842 843 /** 844 * NOT_INVITER: means the participant is not inviter. 845 * 846 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 847 * @systemapi 848 * @since 11 849 */ 850 NOT_INVITER = 2, 851 852 /** 853 * NOT_INVITER_OR_INVITEE: means the participant is not inviter or invitee. 854 * 855 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 856 * @systemapi 857 * @since 11 858 */ 859 NOT_INVITER_OR_INVITEE = 3, 860 861 /** 862 * OVER_QUOTA: means the number of sharing times today of current user has reached maximum. 863 * 864 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 865 * @systemapi 866 * @since 11 867 */ 868 OVER_QUOTA = 4, 869 870 /** 871 * TOO_MANY_PARTICIPANTS: means the number of participants reaches the maximum. 872 * 873 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 874 * @systemapi 875 * @since 11 876 */ 877 TOO_MANY_PARTICIPANTS = 5, 878 879 /** 880 * INVALID_ARGS: means invalid arguments. 881 * 882 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 883 * @systemapi 884 * @since 11 885 */ 886 INVALID_ARGS = 6, 887 888 /** 889 * NETWORK_ERROR: means the network is unavailable. 890 * 891 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 892 * @systemapi 893 * @since 11 894 */ 895 NETWORK_ERROR = 7, 896 897 /** 898 * CLOUD_DISABLED: means cloud is disabled. 899 * 900 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 901 * @systemapi 902 * @since 11 903 */ 904 CLOUD_DISABLED = 8, 905 906 /** 907 * SERVER_ERROR: means invoke cloud space failed. 908 * 909 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 910 * @systemapi 911 * @since 11 912 */ 913 SERVER_ERROR = 9, 914 915 /** 916 * INNER_ERROR: means an unknown error has occurred. 917 * 918 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 919 * @systemapi 920 * @since 11 921 */ 922 INNER_ERROR = 10, 923 924 /** 925 * INVALID_INVITATION: means the invitation has expired or does not exist. 926 * 927 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 928 * @systemapi 929 * @since 11 930 */ 931 INVALID_INVITATION = 11, 932 933 /** 934 * RATE_LIMIT: means the data transfer is rate-limited. 935 * 936 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 937 * @systemapi 938 * @since 11 939 */ 940 RATE_LIMIT = 12, 941 942 /** 943 * CUSTOM_ERROR: means error codes that exceed this enumerated value are custom error codes. 944 * 945 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 946 * @systemapi 947 * @since 11 948 */ 949 CUSTOM_ERROR = 1000, 950 } 951 952 /** 953 * Result interface. 954 * 955 * @interface Result 956 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 957 * @systemapi 958 * @since 11 959 */ 960 interface Result<T> { 961 /** 962 * Error code. 963 * 964 * @type { number } 965 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 966 * @systemapi 967 * @since 11 968 */ 969 code: number; 970 971 /** 972 * Error code description. 973 * 974 * @type { ?string } 975 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 976 * @systemapi 977 * @since 11 978 */ 979 description?: string; 980 981 /** 982 * The result value. 983 * 984 * @type { ?T } 985 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 986 * @systemapi 987 * @since 11 988 */ 989 value?: T; 990 } 991 992 /** 993 * Privilege for the shared data. 994 * 995 * @interface Privilege 996 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 997 * @systemapi 998 * @since 11 999 */ 1000 interface Privilege { 1001 /** 1002 * Whether the participants can write the shared data. The value <b>true</b> 1003 * means the participants can write the shared data; the value <b>false</b> 1004 * means the opposite. 1005 * 1006 * @type { ?boolean } 1007 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1008 * @systemapi 1009 * @since 11 1010 */ 1011 writable?: boolean; 1012 1013 /** 1014 * Whether the participants can read the shared data. The value <b>true</b> 1015 * means the participants can read the shared data; the value <b>false</b> 1016 * means the opposite. 1017 * 1018 * @type { ?boolean } 1019 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1020 * @systemapi 1021 * @since 11 1022 */ 1023 readable?: boolean; 1024 1025 /** 1026 * Whether the participants can create data. The value <b>true</b> 1027 * means the participants can create data; the value <b>false</b> 1028 * means the opposite. 1029 * 1030 * @type { ?boolean } 1031 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1032 * @systemapi 1033 * @since 11 1034 */ 1035 creatable?: boolean; 1036 1037 /** 1038 * Whether the participants can delete the shared data. The value <b>true</b> 1039 * means the participants can delete the shared data; the value <b>false</b> 1040 * means the opposite. 1041 * 1042 * @type { ?boolean } 1043 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1044 * @systemapi 1045 * @since 11 1046 */ 1047 deletable?: boolean; 1048 1049 /** 1050 * Whether the participants can share the data. The value <b>true</b> 1051 * means the participants can share the data; the value <b>false</b> 1052 * means the opposite. 1053 * 1054 * @type { ?boolean } 1055 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1056 * @systemapi 1057 * @since 11 1058 */ 1059 shareable?: boolean; 1060 } 1061 1062 /** 1063 * Participants in cloud sharing. 1064 * 1065 * @interface Participant 1066 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1067 * @systemapi 1068 * @since 11 1069 */ 1070 interface Participant { 1071 /** 1072 * Identity of participant. 1073 * 1074 * @type { string } 1075 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1076 * @systemapi 1077 * @since 11 1078 */ 1079 identity: string; 1080 1081 /** 1082 * Role of the participant, which can be inviter or invitee. 1083 * 1084 * @type { ?Role } 1085 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1086 * @systemapi 1087 * @since 11 1088 */ 1089 role?: Role; 1090 1091 /** 1092 * State of the sharing invitation. 1093 * 1094 * @type { ?State } 1095 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1096 * @systemapi 1097 * @since 11 1098 */ 1099 state?: State; 1100 1101 /** 1102 * Permissions for the shared data. 1103 * 1104 * @type { ?Privilege } 1105 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1106 * @systemapi 1107 * @since 11 1108 */ 1109 privilege?: Privilege; 1110 1111 /** 1112 * Attach information. 1113 * 1114 * @type { ?string } 1115 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1116 * @systemapi 1117 * @since 11 1118 */ 1119 attachInfo?: string; 1120 } 1121 1122 /** 1123 * Allocates shared resources based on conditions, 1124 * and shares data with the specified privilege to participants. 1125 * 1126 * @param { string } storeId - Indicates relational store name. 1127 * @param { relationalStore.RdbPredicates } predicates - See {@link relationalStore.RdbPredicates}. 1128 * @param { Array<Participant> } participants - Participants to share. 1129 * @param { Array<string> } [columns] - Columns to be shared. 1130 * @returns { Promise<relationalStore.ResultSet> } - Promise used to return {@link relationalStore.ResultSet}. 1131 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1132 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 1133 * 3. Parameter verification failed. 1134 * @throws { BusinessError } 801 - Capability not supported. 1135 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1136 * @systemapi 1137 * @since 11 1138 */ 1139 function allocResourceAndShare( 1140 storeId: string, 1141 predicates: relationalStore.RdbPredicates, 1142 participants: Array<Participant>, 1143 columns?: Array<string> 1144 ): Promise<relationalStore.ResultSet>; 1145 1146 /** 1147 * Allocates shared resources based on conditions, 1148 * and shares data with the specified privilege to participants. 1149 * 1150 * @param { string } storeId - Indicates relational store name. 1151 * @param { relationalStore.RdbPredicates } predicates - See {@link relationalStore.RdbPredicates}. 1152 * @param { Array<Participant> } participants - Participants to share. 1153 * @param { AsyncCallback<relationalStore.ResultSet> } callback - Indicates the 1154 * callback invoked to return the {@link relationalStore.ResultSet}. 1155 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1156 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 1157 * 3. Parameter verification failed. 1158 * @throws { BusinessError } 801 - Capability not supported. 1159 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1160 * @systemapi 1161 * @since 11 1162 */ 1163 function allocResourceAndShare( 1164 storeId: string, 1165 predicates: relationalStore.RdbPredicates, 1166 participants: Array<Participant>, 1167 callback: AsyncCallback<relationalStore.ResultSet> 1168 ): void; 1169 1170 /** 1171 * Allocates shared resources based on conditions, 1172 * and shares data with the specified privilege to participants. 1173 * 1174 * @param { string } storeId - Indicates relational store name. 1175 * @param { relationalStore.RdbPredicates } predicates - See {@link relationalStore.RdbPredicates}. 1176 * @param { Array<Participant> } participants - Participants to share. 1177 * @param { Array<string> } columns - Columns to be shared. 1178 * @param { AsyncCallback<relationalStore.ResultSet> } callback - Indicates the 1179 * callback invoked to return the {@link relationalStore.ResultSet}. 1180 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1181 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 1182 * 3. Parameter verification failed. 1183 * @throws { BusinessError } 801 - Capability not supported. 1184 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1185 * @systemapi 1186 * @since 11 1187 */ 1188 function allocResourceAndShare( 1189 storeId: string, 1190 predicates: relationalStore.RdbPredicates, 1191 participants: Array<Participant>, 1192 columns: Array<string>, 1193 callback: AsyncCallback<relationalStore.ResultSet> 1194 ): void; 1195 1196 /** 1197 * Shares data with the specified privilege to participants. 1198 * 1199 * @param { string } sharingResource - Indicates the sharing resource. 1200 * @param { Array<Participant> } participants - Indicates the participants 1201 * involved in the data sharing. 1202 * @param { AsyncCallback<Result<Array<Result<Participant>>>> } callback - Indicates the 1203 * callback invoked to return the result. 1204 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1205 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 1206 * 3. Parameter verification failed. 1207 * @throws { BusinessError } 801 - Capability not supported. 1208 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1209 * @systemapi 1210 * @since 11 1211 */ 1212 function share( 1213 sharingResource: string, 1214 participants: Array<Participant>, 1215 callback: AsyncCallback<Result<Array<Result<Participant>>>> 1216 ): void; 1217 1218 /** 1219 * Shares data with the specified privilege to participants. 1220 * 1221 * @param { string } sharingResource - Indicates the sharing resource. 1222 * @param { Array<Participant> } participants - Indicates the participants 1223 * involved in the data sharing. 1224 * @returns { Promise<Result<Array<Result<Participant>>>> } - Promise used to return the result. 1225 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1226 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 1227 * 3. Parameter verification failed. 1228 * @throws { BusinessError } 801 - Capability not supported. 1229 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1230 * @systemapi 1231 * @since 11 1232 */ 1233 function share( 1234 sharingResource: string, 1235 participants: Array<Participant> 1236 ): Promise<Result<Array<Result<Participant>>>>; 1237 1238 /** 1239 * UnShares data. 1240 * 1241 * @param { string } sharingResource - Indicates the sharing resource. 1242 * @param { Array<Participant> } participants - Indicates the participants 1243 * involved. 1244 * @param { AsyncCallback<Result<Array<Result<Participant>>>> } callback - Indicates the callback invoked 1245 * to return the result. 1246 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1247 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 1248 * 3. Parameter verification failed. 1249 * @throws { BusinessError } 801 - Capability not supported. 1250 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1251 * @systemapi 1252 * @since 11 1253 */ 1254 function unshare( 1255 sharingResource: string, 1256 participants: Array<Participant>, 1257 callback: AsyncCallback<Result<Array<Result<Participant>>>> 1258 ): void; 1259 1260 /** 1261 * UnShares data. 1262 * 1263 * @param { string } sharingResource - Indicates the sharing resource. 1264 * @param { Array<Participant> } participants - Indicates the participants 1265 * involved. 1266 * @returns { Promise<Result<Array<Result<Participant>>>> } - Promise used to return the result. 1267 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1268 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 1269 * 3. Parameter verification failed. 1270 * @throws { BusinessError } 801 - Capability not supported. 1271 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1272 * @systemapi 1273 * @since 11 1274 */ 1275 function unshare( 1276 sharingResource: string, 1277 participants: Array<Participant> 1278 ): Promise<Result<Array<Result<Participant>>>>; 1279 1280 /** 1281 * Exit sharing. 1282 * 1283 * @param { string } sharingResource - Indicates the sharing resource. 1284 * @param { AsyncCallback<Result<void>> } callback - The callback of exit. 1285 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1286 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 1287 * 3. Parameter verification failed. 1288 * @throws { BusinessError } 801 - Capability not supported. 1289 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1290 * @systemapi 1291 * @since 11 1292 */ 1293 function exit(sharingResource: string, callback: AsyncCallback<Result<void>>): void; 1294 1295 /** 1296 * Exit sharing. 1297 * 1298 * @param { string } sharingResource - Indicates the sharing resource. 1299 * @returns { Promise<Result<void>> } - The promise returned by the function. 1300 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1301 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 1302 * 3. Parameter verification failed. 1303 * @throws { BusinessError } 801 - Capability not supported. 1304 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1305 * @systemapi 1306 * @since 11 1307 */ 1308 function exit(sharingResource: string): Promise<Result<void>>; 1309 1310 /** 1311 * Changes the permissions for the shared data. 1312 * 1313 * @param { string } sharingResource - Indicates the sharing resource. 1314 * @param { Array<Participant> } participants - Indicates the participants 1315 * whose permissions are to be changed. 1316 * @param { AsyncCallback<Result<Array<Result<Participant>>>> } callback - Indicates the 1317 * callback invoked to return the result. 1318 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1319 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 1320 * 3. Parameter verification failed. 1321 * @throws { BusinessError } 801 - Capability not supported. 1322 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1323 * @systemapi 1324 * @since 11 1325 */ 1326 function changePrivilege( 1327 sharingResource: string, 1328 participants: Array<Participant>, 1329 callback: AsyncCallback<Result<Array<Result<Participant>>>> 1330 ): void; 1331 1332 /** 1333 * Changes the permissions for the shared data. 1334 * 1335 * @param { string } sharingResource - Indicates the sharing resource. 1336 * @param { Array<Participant> } participants - Indicates the participants 1337 * whose permissions are to be changed. 1338 * @returns { Promise<Result<Array<Result<Participant>>>> } - Promise used to return the result. 1339 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1340 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 1341 * 3. Parameter verification failed. 1342 * @throws { BusinessError } 801 - Capability not supported. 1343 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1344 * @systemapi 1345 * @since 11 1346 */ 1347 function changePrivilege( 1348 sharingResource: string, 1349 participants: Array<Participant> 1350 ): Promise<Result<Array<Result<Participant>>>>; 1351 1352 /** 1353 * Queries the participants based on the specified shared data. 1354 * 1355 * @param { string } sharingResource - Indicates the sharing resource. 1356 * @param { AsyncCallback<Result<Array<Participant>>> } callback - Indicates the 1357 * callback invoked to return the participants obtained. 1358 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1359 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 1360 * 3. Parameter verification failed. 1361 * @throws { BusinessError } 801 - Capability not supported. 1362 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1363 * @systemapi 1364 * @since 11 1365 */ 1366 function queryParticipants(sharingResource: string, callback: AsyncCallback<Result<Array<Participant>>>): void; 1367 1368 /** 1369 * Queries the participants based on the specified shared data. 1370 * 1371 * @param { string } sharingResource - Indicates the sharing resource. 1372 * @returns { Promise<Result<Array<Participant>>> } - Promise used to return the result. 1373 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1374 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 1375 * 3. Parameter verification failed. 1376 * @throws { BusinessError } 801 - Capability not supported. 1377 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1378 * @systemapi 1379 * @since 11 1380 */ 1381 function queryParticipants(sharingResource: string): Promise<Result<Array<Participant>>>; 1382 1383 /** 1384 * Queries the participants based on the specified invitation code. 1385 * 1386 * @param { string } invitationCode - Indicates the invitation code. 1387 * @param { AsyncCallback<Result<Array<Participant>>> } callback - Indicates the 1388 * callback invoked to return the participants obtained. 1389 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1390 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 1391 * 3. Parameter verification failed. 1392 * @throws { BusinessError } 801 - Capability not supported. 1393 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1394 * @systemapi 1395 * @since 11 1396 */ 1397 function queryParticipantsByInvitation( 1398 invitationCode: string, 1399 callback: AsyncCallback<Result<Array<Participant>>> 1400 ): void; 1401 1402 /** 1403 * Queries the participants based on the specified invitation code. 1404 * 1405 * @param { string } invitationCode - Indicates the invitation code. 1406 * @returns { Promise<Result<Array<Participant>>> } - Promise used to return the result. 1407 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1408 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 1409 * 3. Parameter verification failed. 1410 * @throws { BusinessError } 801 - Capability not supported. 1411 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1412 * @systemapi 1413 * @since 11 1414 */ 1415 function queryParticipantsByInvitation(invitationCode: string): Promise<Result<Array<Participant>>>; 1416 1417 /** 1418 * Confirms the invitation of cloud sharing. 1419 * 1420 * @param { string } invitationCode - Indicates the invitation code. 1421 * @param { State } state - Indicates the state of invitation. 1422 * @param { AsyncCallback<Result<string>> } callback - Indicates the callback 1423 * invoked to return the sharing resource. 1424 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1425 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 1426 * 3. Parameter verification failed. 1427 * @throws { BusinessError } 801 - Capability not supported. 1428 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1429 * @systemapi 1430 * @since 11 1431 */ 1432 function confirmInvitation(invitationCode: string, state: State, callback: AsyncCallback<Result<string>>): void; 1433 1434 /** 1435 * Confirms the invitation of cloud sharing. 1436 * 1437 * @param { string } invitationCode - Indicates the invitation code. 1438 * @param { State } state - Indicates the state of invitation. 1439 * @returns { Promise<Result<string>> } - Promise used to return the sharing resource. 1440 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1441 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 1442 * 3. Parameter verification failed. 1443 * @throws { BusinessError } 801 - Capability not supported. 1444 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1445 * @systemapi 1446 * @since 11 1447 */ 1448 function confirmInvitation(invitationCode: string, state: State): Promise<Result<string>>; 1449 1450 /** 1451 * Changes confirmation of shared record. 1452 * 1453 * @param { string } sharingResource - Indicates the sharing resource. 1454 * @param { State } state - Indicates the state of invitation. 1455 * @param { AsyncCallback<Result<void>> } callback - Indicates the callback. 1456 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1457 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 1458 * 3. Parameter verification failed. 1459 * @throws { BusinessError } 801 - Capability not supported. 1460 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1461 * @systemapi 1462 * @since 11 1463 */ 1464 function changeConfirmation(sharingResource: string, state: State, callback: AsyncCallback<Result<void>>): void; 1465 1466 /** 1467 * Changes confirmation of shared record. 1468 * 1469 * @param { string } sharingResource - Indicates the sharing resource. 1470 * @param { State } state - Indicates the state of invitation. 1471 * @returns { Promise<Result<void>> } - The promise returned by the function. 1472 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1473 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 1474 * 3. Parameter verification failed. 1475 * @throws { BusinessError } 801 - Capability not supported. 1476 * @syscap SystemCapability.DistributedDataManager.CloudSync.Client 1477 * @systemapi 1478 * @since 11 1479 */ 1480 function changeConfirmation(sharingResource: string, state: State): Promise<Result<void>>; 1481 } 1482} 1483 1484export default cloudData; 1485