1/* 2 * Copyright (c) 2022 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 type { AsyncCallback } from './@ohos.base'; 22import Context from './application/Context'; 23import DataShareResultSet from './@ohos.data.DataShareResultSet'; 24import dataSharePredicates from './@ohos.data.dataSharePredicates'; 25import { ValuesBucket, ValueType } from './@ohos.data.ValuesBucket'; 26 27/** 28 * This module provides the dataShare capability for consumer. 29 * 30 * @namespace dataShare 31 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 32 * @systemapi 33 * @stagemodelonly 34 * @since 9 35 */ 36/** 37 * This module provides the dataShare capability for consumer. 38 * 39 * @namespace dataShare 40 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 41 * @stagemodelonly 42 * @since 20 43 * @arkts 1.1&1.2 44 */ 45declare namespace dataShare { 46 /** 47 * Manages create datashare helper options. 48 * 49 * @interface DataShareHelperOptions 50 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 51 * @systemapi 52 * @stagemodelonly 53 * @since arkts {'1.1':'10', '1.2':'20'} 54 * @arkts 1.1&1.2 55 */ 56 interface DataShareHelperOptions { 57 /** 58 * Specifies whether the {@link DataShareHelper} in proxy mode. 59 * If value is true, the {@link DataShareHelper} to be created is in proxy mode, and all operations will not open provider APP as possible 60 * 61 * @type { ?boolean } 62 * @default false 63 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 64 * @systemapi 65 * @stagemodelonly 66 * @since arkts {'1.1':'10', '1.2':'20'} 67 * @arkts 1.1&1.2 68 */ 69 isProxy?: boolean; 70 /** 71 * Specifies the time to wait for connecting extension, in seconds. 72 * 73 * @type { ?number } 74 * @default 2 75 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 76 * @systemapi 77 * @stagemodelonly 78 * @since 18 79 */ 80 waitTime?: number; 81 } 82 83 /** 84 * Obtains the dataShareHelper. 85 * 86 * @param { Context } context - Indicates the application context. 87 * @param { string } uri - Indicates the path of the file to open. 88 * @param { AsyncCallback<DataShareHelper> } callback - {DataShareHelper}: The dataShareHelper for consumer. 89 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 90 * 2. Incorrect parameters types. 91 * @throws { BusinessError } 15700010 - The DataShareHelper fails to be initialized. 92 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 93 * @systemapi 94 * @stagemodelonly 95 * @since 9 96 */ 97 /** 98 * Obtains the dataShareHelper. 99 * 100 * @param { Context } context - Indicates the application context. 101 * @param { string } uri - Indicates the path of the file to open. 102 * @param { AsyncCallback<DataShareHelper> } callback - {DataShareHelper}: The dataShareHelper for consumer. 103 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 104 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 105 * 2. Incorrect parameters types. 106 * @throws { BusinessError } 15700010 - The DataShareHelper fails to be initialized. 107 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 108 * @systemapi 109 * @stagemodelonly 110 * @since arkts {'1.1':'19', '1.2':'20'} 111 * @arkts 1.1&1.2 112 */ 113 function createDataShareHelper(context: Context, uri: string, callback: AsyncCallback<DataShareHelper>): void; 114 /** 115 * Obtains the dataShareHelper. 116 * 117 * @param { Context } context - Indicates the application context. 118 * @param { string } uri - Indicates the path of the file to open. 119 * @param { DataShareHelperOptions } options - Indicates the optional config. 120 * @param { AsyncCallback<DataShareHelper> } callback - {DataShareHelper}: The dataShareHelper for consumer. 121 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 122 * 2. Incorrect parameters types. 123 * @throws { BusinessError } 15700010 - The DataShareHelper fails to be initialized. 124 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 125 * @systemapi 126 * @stagemodelonly 127 * @since 10 128 */ 129 /** 130 * Obtains the dataShareHelper. 131 * 132 * @param { Context } context - Indicates the application context. 133 * @param { string } uri - Indicates the path of the file to open. 134 * @param { DataShareHelperOptions } options - Indicates the optional config. 135 * @param { AsyncCallback<DataShareHelper> } callback - {DataShareHelper}: The dataShareHelper for consumer. 136 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 137 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 138 * 2. Incorrect parameters types. 139 * @throws { BusinessError } 15700010 - The DataShareHelper fails to be initialized. 140 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 141 * @systemapi 142 * @stagemodelonly 143 * @since arkts {'1.1':'19', '1.2':'20'} 144 * @arkts 1.1&1.2 145 */ 146 function createDataShareHelper( 147 context: Context, 148 uri: string, 149 options: DataShareHelperOptions, 150 callback: AsyncCallback<DataShareHelper> 151 ): void; 152 153 /** 154 * Obtains the dataShareHelper. 155 * 156 * @param { Context } context - Indicates the application context. 157 * @param { string } uri - Indicates the path of the file to open. 158 * @returns { Promise<DataShareHelper> } {DataShareHelper}: The dataShareHelper for consumer. 159 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 160 * 2. Incorrect parameters types. 161 * @throws { BusinessError } 15700010 - The DataShareHelper fails to be initialized. 162 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 163 * @systemapi 164 * @stagemodelonly 165 * @since 9 166 */ 167 /** 168 * Obtains the dataShareHelper. 169 * 170 * @param { Context } context - Indicates the application context. 171 * @param { string } uri - Indicates the path of the file to open. 172 * @param { DataShareHelperOptions } options - Indicates the optional config. 173 * @returns { Promise<DataShareHelper> } {DataShareHelper}: The dataShareHelper for consumer. 174 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 175 * 2. Incorrect parameters types. 176 * @throws { BusinessError } 15700010 - The DataShareHelper fails to be initialized. 177 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 178 * @systemapi 179 * @stagemodelonly 180 * @since 10 181 */ 182 /** 183 * Obtains the dataShareHelper. 184 * 185 * @param { Context } context - Indicates the application context. 186 * @param { string } uri - Indicates the path of the file to open. 187 * @param { DataShareHelperOptions } options - Indicates the optional config. 188 * @returns { Promise<DataShareHelper> } {DataShareHelper}: The dataShareHelper for consumer. 189 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 190 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 191 * 2. Incorrect parameters types. 192 * @throws { BusinessError } 15700010 - The DataShareHelper fails to be initialized. 193 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 194 * @systemapi 195 * @stagemodelonly 196 * @since arkts {'1.1':'19', '1.2':'20'} 197 * @arkts 1.1&1.2 198 */ 199 function createDataShareHelper( 200 context: Context, 201 uri: string, 202 options?: DataShareHelperOptions 203 ): Promise<DataShareHelper>; 204 205 /** 206 * Enables silent access dynamically. 207 * 208 * @param { Context } context - Indicates the application context. 209 * @param { string } uri - Indicates the uri of the data share silent proxy resource. 210 * @returns { Promise<void> } The promise returned by the function. 211 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 212 * 2. Incorrect parameters types. 213 * @throws { BusinessError } 15700011 - The URI does not exist. 214 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 215 * @systemapi 216 * @stagemodelonly 217 * @since 11 218 */ 219 /** 220 * Enables silent access dynamically. 221 * 222 * @param { Context } context - Indicates the application context. 223 * @param { string } uri - Indicates the uri of the data share silent proxy resource. 224 * @returns { Promise<void> } The promise returned by the function. 225 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 226 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 227 * 2. Incorrect parameters types. 228 * @throws { BusinessError } 15700011 - The URI does not exist. 229 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 230 * @systemapi 231 * @stagemodelonly 232 * @since arkts {'1.1':'19', '1.2':'20'} 233 * @arkts 1.1&1.2 234 */ 235 function enableSilentProxy(context: Context, uri?: string): Promise<void>; 236 237 /** 238 * Disables silent access dynamically. 239 * 240 * @param { Context } context - Indicates the application context. 241 * @param { string } uri - Indicates the uri of the data share silent proxy resource. 242 * @returns { Promise<void> } The promise returned by the function. 243 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 244 * 2. Incorrect parameters types. 245 * @throws { BusinessError } 15700011 - The URI does not exist. 246 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 247 * @systemapi 248 * @stagemodelonly 249 * @since 11 250 */ 251 /** 252 * Disables silent access dynamically. 253 * 254 * @param { Context } context - Indicates the application context. 255 * @param { string } uri - Indicates the uri of the data share silent proxy resource. 256 * @returns { Promise<void> } The promise returned by the function. 257 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 258 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 259 * 2. Incorrect parameters types. 260 * @throws { BusinessError } 15700011 - The URI does not exist. 261 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 262 * @systemapi 263 * @stagemodelonly 264 * @since arkts {'1.1':'19', '1.2':'20'} 265 * @arkts 1.1&1.2 266 */ 267 function disableSilentProxy(context: Context, uri?: string): Promise<void>; 268 269 /** 270 * Specifies the {@link Template} id structure. 271 * A template is marked by the template id. Note that the template id is auto generated in {@link DataShareHelper#addTemplate}. 272 * After {@link DataShareHelper#addTemplate}, can use the template id to direct a template. 273 * 274 * @interface TemplateId 275 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 276 * @systemapi 277 * @stagemodelonly 278 * @since 10 279 */ 280 interface TemplateId { 281 /** 282 * Specifies the id of subscriber, who process the callback 283 * Same as subscriberId in {@link DataShareHelper#addTemplate} 284 * 285 * @type { string } 286 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 287 * @systemapi 288 * @stagemodelonly 289 * @since 10 290 */ 291 subscriberId: string; 292 /** 293 * Specifies the bundleName of template owner, who create the template 294 * Same as the caller's bundleName of {@link DataShareHelper#addTemplate} 295 * 296 * @type { string } 297 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 298 * @systemapi 299 * @stagemodelonly 300 * @since 10 301 */ 302 bundleNameOfOwner: string; 303 } 304 305 /** 306 * Specifies the published item structure. 307 * 308 * @interface PublishedItem 309 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 310 * @systemapi 311 * @stagemodelonly 312 * @since 10 313 */ 314 interface PublishedItem { 315 /** 316 * Specifies the key of the published data 317 * 318 * @type { string } 319 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 320 * @systemapi 321 * @stagemodelonly 322 * @since 10 323 */ 324 key: string; 325 /** 326 * Specifies the published data 327 * If the data is large, use ArrayBuffer. 328 * 329 * @type { string | ArrayBuffer } 330 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 331 * @systemapi 332 * @stagemodelonly 333 * @since 10 334 */ 335 data: string | ArrayBuffer; 336 /** 337 * Specifies the subscriber id 338 * 339 * @type { string } 340 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 341 * @systemapi 342 * @stagemodelonly 343 * @since 10 344 */ 345 subscriberId: string; 346 } 347 348 /** 349 * Specifies the change node structure of rdb store data in callback. 350 * 351 * @interface RdbDataChangeNode 352 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 353 * @systemapi 354 * @stagemodelonly 355 * @since 10 356 */ 357 interface RdbDataChangeNode { 358 /** 359 * Specifies the uri of the callback. 360 * 361 * @type { string } 362 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 363 * @systemapi 364 * @stagemodelonly 365 * @since 10 366 */ 367 uri: string; 368 /** 369 * Specifies the templateId of the callback. 370 * 371 * @type { TemplateId } 372 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 373 * @systemapi 374 * @stagemodelonly 375 * @since 10 376 */ 377 templateId: TemplateId; 378 /** 379 * Specifies the datas of the callback. 380 * every node is a json, json's key is [key of {@link Template#predicates} 381 * and value is the query result from rdb store query by value of{@link Template#predicates}]. 382 * 383 * @type { Array<string> } 384 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 385 * @systemapi 386 * @stagemodelonly 387 * @since 10 388 */ 389 data: Array<string>; 390 } 391 392 /** 393 * Specifies the change node structure of published data in callback. 394 * 395 * @interface PublishedDataChangeNode 396 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 397 * @systemapi 398 * @stagemodelonly 399 * @since 10 400 */ 401 interface PublishedDataChangeNode { 402 /** 403 * Specifies the bundleName of the callback. 404 * 405 * @type { string } 406 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 407 * @systemapi 408 * @stagemodelonly 409 * @since 10 410 */ 411 bundleName: string; 412 /** 413 * Specifies the datas of the callback. 414 * 415 * @type { Array<PublishedItem> } 416 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 417 * @systemapi 418 * @stagemodelonly 419 * @since 10 420 */ 421 data: Array<PublishedItem>; 422 } 423 424 /** 425 * Specifies the template structure in subscribe. 426 * 427 * @interface Template 428 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 429 * @systemapi 430 * @stagemodelonly 431 * @since 10 432 */ 433 interface Template { 434 /** 435 * Specifies the predicates of the template. 436 * When the callback in {@link DataShareHelper#on(string, Array<string>, TemplateId, AsyncCallback<ChangeNode>)} 437 * is called, the predicates is used to generate data in {@link ChangeNode}. Only for rdb store data. 438 * 439 * @type { [key: string]: string } 440 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 441 * @systemapi 442 * @stagemodelonly 443 * @since 10 444 */ 445 /** 446 * Specifies the predicates of the template. 447 * When the callback in {@link DataShareHelper#on(string, Array<string>, TemplateId, AsyncCallback<ChangeNode>)} 448 * is called, the predicates is used to generate data in {@link ChangeNode}. Only for rdb store data. 449 * 450 * @type { Record<string, string> } 451 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 452 * @systemapi 453 * @stagemodelonly 454 * @since 11 455 */ 456 predicates: Record<string, string>; 457 458 /** 459 * Specifies the scheduler sql of the template. 460 * When modify the subscribed uri's data, scheduler is auto called. 461 * 462 * @type { string } 463 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 464 * @systemapi 465 * @stagemodelonly 466 * @since 10 467 */ 468 scheduler: string; 469 470 /** 471 * Specifies the update sql of the template. 472 * The update is called after the predicates execution is complete. 473 * 474 * @type { ?string } 475 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 476 * @systemapi 477 * @stagemodelonly 478 * @since 18 479 */ 480 update?: string; 481 } 482 /** 483 * Specifies the operation result structure. 484 * 485 * @interface OperationResult 486 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 487 * @systemapi 488 * @stagemodelonly 489 * @since 10 490 */ 491 interface OperationResult { 492 /** 493 * Specifies the key of the operation result. 494 * 495 * @type { string } 496 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 497 * @systemapi 498 * @stagemodelonly 499 * @since 10 500 */ 501 key: string; 502 503 /** 504 * Specifies the operation result. 505 * 506 * @type { number } 507 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 508 * @systemapi 509 * @stagemodelonly 510 * @since 10 511 */ 512 result: number; 513 } 514 515 /** 516 * Struct for a batch update operation. 517 * 518 * @interface UpdateOperation 519 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 520 * @systemapi 521 * @stagemodelonly 522 * @since 12 523 */ 524 interface UpdateOperation { 525 /** 526 * Indicates the data to update. 527 * 528 * @type { ValuesBucket } 529 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 530 * @systemapi 531 * @stagemodelonly 532 * @since 12 533 */ 534 values: ValuesBucket; 535 536 /** 537 * Indicates filter criteria. 538 * 539 * @type { dataSharePredicates.DataSharePredicates } 540 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 541 * @systemapi 542 * @stagemodelonly 543 * @since 12 544 */ 545 predicates: dataSharePredicates.DataSharePredicates; 546 } 547 548 /** 549 * Enumerates the data change types. 550 * 551 * @enum { number } 552 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 553 * @systemapi 554 * @stagemodelonly 555 * @since 12 556 */ 557 /** 558 * Enumerates the data change types. 559 * 560 * @enum { number } 561 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 562 * @stagemodelonly 563 * @since 20 564 * @arkts 1.1&1.2 565 */ 566 enum ChangeType { 567 /** 568 * Data inserted. 569 * 570 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 571 * @systemapi 572 * @stagemodelonly 573 * @since 12 574 */ 575 /** 576 * Data inserted. 577 * 578 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 579 * @stagemodelonly 580 * @since 20 581 * @arkts 1.1&1.2 582 */ 583 INSERT = 0, 584 585 /** 586 * Data deleted. 587 * 588 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 589 * @systemapi 590 * @stagemodelonly 591 * @since 12 592 */ 593 /** 594 * Data deleted. 595 * 596 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 597 * @stagemodelonly 598 * @since 20 599 * @arkts 1.1&1.2 600 */ 601 DELETE, 602 /** 603 * Data updated. 604 * 605 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 606 * @systemapi 607 * @stagemodelonly 608 * @since 12 609 */ 610 /** 611 * Data updated. 612 * 613 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 614 * @stagemodelonly 615 * @since 20 616 * @arkts 1.1&1.2 617 */ 618 UPDATE 619 } 620 /** 621 * Enumerates the subscription types. 622 * 623 * @enum { number } 624 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 625 * @systemapi 626 * @stagemodelonly 627 * @since arkts {'1.1':'12', '1.2':'20'} 628 * @arkts 1.1&1.2 629 */ 630 enum SubscriptionType { 631 /** 632 * Subscribe to the change of the data with the specified URI. 633 * 634 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 635 * @systemapi 636 * @stagemodelonly 637 * @since arkts {'1.1':'12', '1.2':'20'} 638 * @arkts 1.1&1.2 639 */ 640 SUBSCRIPTION_TYPE_EXACT_URI = 0, 641 } 642 643 /** 644 * Struct for the data change. 645 * 646 * @interface ChangeInfo 647 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 648 * @systemapi 649 * @stagemodelonly 650 * @since arkts {'1.1':'12', '1.2':'20'} 651 * @arkts 1.1&1.2 652 */ 653 interface ChangeInfo { 654 /** 655 * Type of the data change. 656 * 657 * @type { ChangeType } 658 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 659 * @systemapi 660 * @stagemodelonly 661 * @since arkts {'1.1':'12', '1.2':'20'} 662 * @arkts 1.1&1.2 663 */ 664 type: ChangeType; 665 666 /** 667 * URI of the data changed. 668 * 669 * @type { string } 670 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 671 * @systemapi 672 * @stagemodelonly 673 * @since arkts {'1.1':'12', '1.2':'20'} 674 * @arkts 1.1&1.2 675 */ 676 uri: string; 677 /** 678 * Data changed. 679 * 680 * @type { Array<ValuesBucket> } 681 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 682 * @systemapi 683 * @stagemodelonly 684 * @since arkts {'1.1':'12', '1.2':'20'} 685 * @arkts 1.1&1.2 686 */ 687 values: Array<ValuesBucket>; 688 } 689 690 /** 691 * Provides a DataShareHelper interface to access data. 692 * 693 * @interface DataShareHelper 694 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 695 * @systemapi 696 * @stagemodelonly 697 * @since arkts {'1.1':'9', '1.2':'20'} 698 * @arkts 1.1&1.2 699 */ 700 interface DataShareHelper { 701 /** 702 * Registers an observer to observe data specified by the given uri. 703 * 704 * @param { 'dataChange' } type - Type must be 'dataChange'. 705 * @param { string } uri - Indicates the path of the data to operate. 706 * @param { AsyncCallback<void> } callback - The callback of on. 707 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 708 * @systemapi 709 * @stagemodelonly 710 * @since 9 711 */ 712 /** 713 * Registers an observer to observe data specified by the given uri. 714 * 715 * @param { 'dataChange' } type - Type must be 'dataChange'. 716 * @param { string } uri - Indicates the path of the data to operate. 717 * @param { AsyncCallback<void> } callback - The callback of on. 718 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 719 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 720 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 721 * 2. Incorrect parameters types. 722 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 723 * @systemapi 724 * @stagemodelonly 725 * @since arkts {'1.1':'12', '1.2':'20'} 726 * @arkts 1.1&1.2 727 */ 728 on(type: 'dataChange', uri: string, callback: AsyncCallback<void>): void; 729 730 /** 731 * Deregisters an observer used for monitoring data specified by the given uri. 732 * 733 * @param { 'dataChange' } type - Type must be 'dataChange'. 734 * @param { string } uri - Indicates the path of the data to operate. 735 * @param { AsyncCallback<void> } callback - The callback of off. 736 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 737 * @systemapi 738 * @stagemodelonly 739 * @since 9 740 */ 741 /** 742 * Deregisters an observer used for monitoring data specified by the given uri. 743 * 744 * @param { 'dataChange' } type - Type must be 'dataChange'. 745 * @param { string } uri - Indicates the path of the data to operate. 746 * @param { AsyncCallback<void> } callback - The callback of off. 747 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 748 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 749 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 750 * 2. Incorrect parameters types. 751 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 752 * @systemapi 753 * @stagemodelonly 754 * @since arkts {'1.1':'12', '1.2':'20'} 755 * @arkts 1.1&1.2 756 */ 757 off(type: 'dataChange', uri: string, callback?: AsyncCallback<void>): void; 758 /** 759 * Subscribes to the change of the data specified by the given URI. 760 * 761 * @param { 'dataChange' } event - Indicates the event type, which must be 'dataChange'. 762 * @param { SubscriptionType } type - Indicates the subscription type, which is defined in {@link SubscriptionType}. 763 * @param { string } uri - Indicates the path of the data to subscribe. 764 * @param { AsyncCallback<ChangeInfo> } callback - Indicates the callback used to return the data change. 765 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 766 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 767 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 768 * 2. Incorrect parameters types. 769 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 770 * @systemapi 771 * @stagemodelonly 772 * @since arkts {'1.1':'12', '1.2':'20'} 773 * @arkts 1.1&1.2 774 */ 775 on(event: 'dataChange', type:SubscriptionType, uri: string, callback: AsyncCallback<ChangeInfo>): void; 776 777 /** 778 * Unsubscribes from the change of the data specified by the given URI. 779 * 780 * @param { 'dataChange' } event - Indicates the event type, which must be 'dataChange'. 781 * @param { SubscriptionType } type - Indicates the subscription type, which is defined in {@link SubscriptionType}. 782 * @param { string } uri - Indicates the path of the data to unsubscribe. 783 * @param { AsyncCallback<ChangeInfo> } callback - Indicates the callback to unsubscribe. 784 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 785 * 2. Incorrect parameters types. 786 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 787 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 788 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 789 * @systemapi 790 * @stagemodelonly 791 * @since arkts {'1.1':'12', '1.2':'20'} 792 * @arkts 1.1&1.2 793 */ 794 off(event: 'dataChange', type:SubscriptionType, uri: string, callback?: AsyncCallback<ChangeInfo>): void; 795 796 /** 797 * Adds a template of {@link #on(string, Array<string>, TemplateId, AsyncCallback<ChangeNode>)}. 798 * 799 * @param { string } uri - Indicates the uri to add. 800 * @param { string } subscriberId - The subscribe id to add.. 801 * @param { Template } template - The template to add. 802 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 803 * 2. Incorrect parameters types. 804 * @throws { BusinessError } 15700011 - The URI does not exist. 805 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 806 * @systemapi 807 * @stagemodelonly 808 * @since 10 809 */ 810 /** 811 * Adds a template of {@link #on(string, Array<string>, TemplateId, AsyncCallback<ChangeNode>)}. 812 * 813 * @param { string } uri - Indicates the uri to add. 814 * @param { string } subscriberId - The subscribe id to add.. 815 * @param { Template } template - The template to add. 816 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 817 * 2. Incorrect parameters types. 818 * @throws { BusinessError } 15700011 - The URI does not exist. 819 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 820 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 821 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 822 * @systemapi 823 * @stagemodelonly 824 * @since 12 825 */ 826 addTemplate(uri: string, subscriberId: string, template: Template): void; 827 828 /** 829 * Deletes a template of {@link #on(string, Array<string>, TemplateId, AsyncCallback<ChangeNode>)}. 830 * 831 * @param { string } uri - Indicates the uri to delete. 832 * @param { string } subscriberId - The subscribe id. 833 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 834 * 2. Incorrect parameters types. 835 * @throws { BusinessError } 15700011 - The URI does not exist. 836 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 837 * @systemapi 838 * @stagemodelonly 839 * @since 10 840 */ 841 /** 842 * Deletes a template of {@link #on(string, Array<string>, TemplateId, AsyncCallback<ChangeNode>)}. 843 * 844 * @param { string } uri - Indicates the uri to delete. 845 * @param { string } subscriberId - The subscribe id. 846 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 847 * 2. Incorrect parameters types. 848 * @throws { BusinessError } 15700011 - The URI does not exist. 849 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 850 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 851 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 852 * @systemapi 853 * @stagemodelonly 854 * @since 12 855 */ 856 delTemplate(uri: string, subscriberId: string): void; 857 858 /** 859 * Registers observers to observe rdb data specified by the given uri and template. 860 * 861 * @param { 'rdbDataChange' } type - Type must be 'rdbDataChange'. 862 * @param { Array<string> } uris - Indicates the paths of the data to operate. 863 * @param { TemplateId } templateId - The template of on. 864 * @param { AsyncCallback<RdbDataChangeNode> } callback - The callback of on. 865 * @returns { Array<OperationResult> } : The operation result. 866 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 867 * 2. Incorrect parameters types. 868 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 869 * @systemapi 870 * @stagemodelonly 871 * @since 10 872 */ 873 /** 874 * Registers observers to observe rdb data specified by the given uri and template. 875 * 876 * @param { 'rdbDataChange' } type - Type must be 'rdbDataChange'. 877 * @param { Array<string> } uris - Indicates the paths of the data to operate. 878 * @param { TemplateId } templateId - The template of on. 879 * @param { AsyncCallback<RdbDataChangeNode> } callback - The callback of on. 880 * @returns { Array<OperationResult> } : The operation result. 881 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 882 * 2. Incorrect parameters types. 883 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 884 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 885 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 886 * @systemapi 887 * @stagemodelonly 888 * @since 12 889 */ 890 on( 891 type: 'rdbDataChange', 892 uris: Array<string>, 893 templateId: TemplateId, 894 callback: AsyncCallback<RdbDataChangeNode> 895 ): Array<OperationResult>; 896 897 /** 898 * Deregisters observers used for monitoring data specified by the given uri and template. 899 * 900 * @param { 'rdbDataChange' } type - Type must be 'rdbDataChange'. 901 * @param { Array<string> } uris - Indicates the paths of the data to operate. 902 * @param { TemplateId } templateId - The template of off. 903 * @param { AsyncCallback<RdbDataChangeNode> } callback - The callback of off. 904 * @returns { Array<OperationResult> } : The operation result. 905 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 906 * 2. Incorrect parameters types. 907 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 908 * @systemapi 909 * @stagemodelonly 910 * @since 10 911 */ 912 /** 913 * Deregisters observers used for monitoring data specified by the given uri and template. 914 * 915 * @param { 'rdbDataChange' } type - Type must be 'rdbDataChange'. 916 * @param { Array<string> } uris - Indicates the paths of the data to operate. 917 * @param { TemplateId } templateId - The template of off. 918 * @param { AsyncCallback<RdbDataChangeNode> } callback - The callback of off. 919 * @returns { Array<OperationResult> } : The operation result. 920 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 921 * 2. Incorrect parameters types. 922 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 923 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 924 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 925 * @systemapi 926 * @stagemodelonly 927 * @since 12 928 */ 929 off( 930 type: 'rdbDataChange', 931 uris: Array<string>, 932 templateId: TemplateId, 933 callback?: AsyncCallback<RdbDataChangeNode> 934 ): Array<OperationResult>; 935 936 /** 937 * Registers observers to observe published data specified by the given key and subscriberId. 938 * 939 * @param { 'publishedDataChange' } type - Type must be 'publishedDataChange'. 940 * @param { Array<string> } uris - Indicates the uris of the data to operate. 941 * @param { string } subscriberId - The subscriberId of on. 942 * @param { AsyncCallback<PublishedDataChangeNode> } callback - The callback of on. 943 * @returns { Array<OperationResult> } : The operation result. 944 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 945 * 2. Incorrect parameters types. 946 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 947 * @systemapi 948 * @stagemodelonly 949 * @since 10 950 */ 951 /** 952 * Registers observers to observe published data specified by the given key and subscriberId. 953 * 954 * @param { 'publishedDataChange' } type - Type must be 'publishedDataChange'. 955 * @param { Array<string> } uris - Indicates the uris of the data to operate. 956 * @param { string } subscriberId - The subscriberId of on. 957 * @param { AsyncCallback<PublishedDataChangeNode> } callback - The callback of on. 958 * @returns { Array<OperationResult> } : The operation result. 959 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 960 * 2. Incorrect parameters types. 961 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 962 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 963 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 964 * @systemapi 965 * @stagemodelonly 966 * @since 12 967 */ 968 on( 969 type: 'publishedDataChange', 970 uris: Array<string>, 971 subscriberId: string, 972 callback: AsyncCallback<PublishedDataChangeNode> 973 ): Array<OperationResult>; 974 975 /** 976 * Deregisters observers used for monitoring data specified by the given key and subscriberId. 977 * 978 * @param { 'publishedDataChange' } type - Type must be 'publishedDataChange'. 979 * @param { Array<string> } uris - Indicates the uris of the data to operate. 980 * @param { string } subscriberId - The subscriberId of off. 981 * @param { AsyncCallback<PublishedDataChangeNode> } callback - The callback of off. 982 * @returns { Array<OperationResult> } : The operation result. 983 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 984 * 2. Incorrect parameters types. 985 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 986 * @systemapi 987 * @stagemodelonly 988 * @since 10 989 */ 990 /** 991 * Deregisters observers used for monitoring data specified by the given key and subscriberId. 992 * 993 * @param { 'publishedDataChange' } type - Type must be 'publishedDataChange'. 994 * @param { Array<string> } uris - Indicates the uris of the data to operate. 995 * @param { string } subscriberId - The subscriberId of off. 996 * @param { AsyncCallback<PublishedDataChangeNode> } callback - The callback of off. 997 * @returns { Array<OperationResult> } : The operation result. 998 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 999 * 2. Incorrect parameters types. 1000 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1001 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1002 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1003 * @systemapi 1004 * @stagemodelonly 1005 * @since 12 1006 */ 1007 off( 1008 type: 'publishedDataChange', 1009 uris: Array<string>, 1010 subscriberId: string, 1011 callback?: AsyncCallback<PublishedDataChangeNode> 1012 ): Array<OperationResult>; 1013 1014 /** 1015 * Update a single data into host data area. 1016 * 1017 * @param { Array<PublishedItem> } data - Indicates the data to publish. 1018 * @param { string } bundleName - Indicates the bundleName of data to publish. 1019 * @param { number } version - Indicates the version of data to publish, larger is newer. 1020 * @param { AsyncCallback<Array<OperationResult>> } callback 1021 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1022 * 2. Incorrect parameters types. 1023 * @throws { BusinessError } 15700012 - The data area does not exist. 1024 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1025 * @systemapi 1026 * @stagemodelonly 1027 * @since 10 1028 */ 1029 /** 1030 * Update a single data into host data area. 1031 * 1032 * @param { Array<PublishedItem> } data - Indicates the data to publish. 1033 * @param { string } bundleName - Indicates the bundleName of data to publish. 1034 * @param { number } version - Indicates the version of data to publish, larger is newer. 1035 * @param { AsyncCallback<Array<OperationResult>> } callback 1036 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1037 * 2. Incorrect parameters types. 1038 * @throws { BusinessError } 15700012 - The data area does not exist. 1039 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1040 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1041 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1042 * @systemapi 1043 * @stagemodelonly 1044 * @since 12 1045 */ 1046 publish( 1047 data: Array<PublishedItem>, 1048 bundleName: string, 1049 version: number, 1050 callback: AsyncCallback<Array<OperationResult>> 1051 ): void; 1052 1053 /** 1054 * Update a single data into host data area. 1055 * 1056 * @param { Array<PublishedItem> } data - Indicates the data to publish. 1057 * @param { string } bundleName - Indicates the bundleName of data to publish. 1058 * @param { AsyncCallback<Array<OperationResult>> } callback 1059 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1060 * 2. Incorrect parameters types. 1061 * @throws { BusinessError } 15700012 - The data area does not exist. 1062 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1063 * @systemapi 1064 * @stagemodelonly 1065 * @since 10 1066 */ 1067 /** 1068 * Update a single data into host data area. 1069 * 1070 * @param { Array<PublishedItem> } data - Indicates the data to publish. 1071 * @param { string } bundleName - Indicates the bundleName of data to publish. 1072 * @param { AsyncCallback<Array<OperationResult>> } callback 1073 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1074 * 2. Incorrect parameters types. 1075 * @throws { BusinessError } 15700012 - The data area does not exist. 1076 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1077 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1078 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1079 * @systemapi 1080 * @stagemodelonly 1081 * @since 12 1082 */ 1083 publish( 1084 data: Array<PublishedItem>, 1085 bundleName: string, 1086 callback: AsyncCallback<Array<OperationResult>> 1087 ): void; 1088 1089 /** 1090 * Update a single data into host data area. 1091 * 1092 * @param { Array<PublishedItem> } data - Indicates the data to publish. 1093 * @param { string } bundleName - Indicates the bundleName of data to publish. 1094 * @param { number } version - Indicates the version of data to publish, larger is newer. 1095 * @returns { Promise<Array<OperationResult>> } 1096 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1097 * 2. Incorrect parameters types. 1098 * @throws { BusinessError } 15700012 - The data area does not exist. 1099 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1100 * @systemapi 1101 * @stagemodelonly 1102 * @since 10 1103 */ 1104 /** 1105 * Update a single data into host data area. 1106 * 1107 * @param { Array<PublishedItem> } data - Indicates the data to publish. 1108 * @param { string } bundleName - Indicates the bundleName of data to publish. 1109 * @param { number } version - Indicates the version of data to publish, larger is newer. 1110 * @returns { Promise<Array<OperationResult>> } 1111 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1112 * 2. Incorrect parameters types. 1113 * @throws { BusinessError } 15700012 - The data area does not exist. 1114 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1115 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1116 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1117 * @systemapi 1118 * @stagemodelonly 1119 * @since 12 1120 */ 1121 publish(data: Array<PublishedItem>, bundleName: string, version?: number): Promise<Array<OperationResult>>; 1122 1123 /** 1124 * Registers a one-time observer to observe data specified by the given uri and template. 1125 * 1126 * @param { string } bundleName - Indicates the bundleName of data to publish. 1127 * @param { AsyncCallback<Array<PublishedItem>> } callback 1128 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1129 * 2. Incorrect parameters types. 1130 * @throws { BusinessError } 15700012 - The data area does not exist. 1131 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1132 * @systemapi 1133 * @stagemodelonly 1134 * @since 10 1135 */ 1136 /** 1137 * Registers a one-time observer to observe data specified by the given uri and template. 1138 * 1139 * @param { string } bundleName - Indicates the bundleName of data to publish. 1140 * @param { AsyncCallback<Array<PublishedItem>> } callback 1141 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1142 * 2. Incorrect parameters types. 1143 * @throws { BusinessError } 15700012 - The data area does not exist. 1144 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1145 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1146 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1147 * @systemapi 1148 * @stagemodelonly 1149 * @since 12 1150 */ 1151 getPublishedData(bundleName: string, callback: AsyncCallback<Array<PublishedItem>>): void; 1152 1153 /** 1154 * Registers a one-time observer to observe data specified by the given uri and template. 1155 * 1156 * @param { string } bundleName - Indicates the bundleName of data to publish. 1157 * @returns { Promise<Array<PublishedItem>> } 1158 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1159 * 2. Incorrect parameters types. 1160 * @throws { BusinessError } 15700012 - The data area does not exist. 1161 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1162 * @systemapi 1163 * @stagemodelonly 1164 * @since 10 1165 */ 1166 /** 1167 * Registers a one-time observer to observe data specified by the given uri and template. 1168 * 1169 * @param { string } bundleName - Indicates the bundleName of data to publish. 1170 * @returns { Promise<Array<PublishedItem>> } 1171 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1172 * 2. Incorrect parameters types. 1173 * @throws { BusinessError } 15700012 - The data area does not exist. 1174 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1175 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1176 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1177 * @systemapi 1178 * @stagemodelonly 1179 * @since 12 1180 */ 1181 getPublishedData(bundleName: string): Promise<Array<PublishedItem>>; 1182 1183 /** 1184 * Inserts a single data record into the database. 1185 * 1186 * @param { string } uri - Indicates the path of the data to operate. 1187 * @param { ValuesBucket } value - Indicates the data record to insert. If this parameter is null, 1188 * a blank row will be inserted. 1189 * @param { AsyncCallback<number> } callback - {number}: the index of the inserted data record. 1190 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1191 * 2. Incorrect parameters types. 1192 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1193 * @systemapi 1194 * @stagemodelonly 1195 * @since 9 1196 */ 1197 /** 1198 * Inserts a single data record into the database. 1199 * 1200 * @param { string } uri - Indicates the path of the data to operate. 1201 * @param { ValuesBucket } value - Indicates the data record to insert. If this parameter is null, 1202 * a blank row will be inserted. 1203 * @param { AsyncCallback<number> } callback - {number}: the index of the inserted data record. 1204 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1205 * 2. Incorrect parameters types. 1206 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1207 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1208 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1209 * @systemapi 1210 * @stagemodelonly 1211 * @since 12 1212 */ 1213 insert(uri: string, value: ValuesBucket, callback: AsyncCallback<number>): void; 1214 1215 /** 1216 * Inserts a single data record into the database. 1217 * 1218 * @param { string } uri - Indicates the path of the data to operate. 1219 * @param { ValuesBucket } value - Indicates the data record to insert. If this parameter is null, 1220 * a blank row will be inserted. 1221 * @returns { Promise<number> } {number}: the index of the inserted data record. 1222 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1223 * 2. Incorrect parameters types. 1224 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1225 * @systemapi 1226 * @stagemodelonly 1227 * @since 9 1228 */ 1229 /** 1230 * Inserts a single data record into the database. 1231 * 1232 * @param { string } uri - Indicates the path of the data to operate. 1233 * @param { ValuesBucket } value - Indicates the data record to insert. If this parameter is null, 1234 * a blank row will be inserted. 1235 * @returns { Promise<number> } {number}: the index of the inserted data record. 1236 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1237 * 2. Incorrect parameters types. 1238 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1239 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1240 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1241 * @systemapi 1242 * @stagemodelonly 1243 * @since 12 1244 */ 1245 insert(uri: string, value: ValuesBucket): Promise<number>; 1246 1247 /** 1248 * Deletes one or more data records from the database. 1249 * 1250 * @param { string } uri - Indicates the path of the data to operate. 1251 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1252 * You should define the processing logic when this parameter is null. 1253 * @param { AsyncCallback<number> } callback - {number}: the number of data records deleted. 1254 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1255 * 2. Incorrect parameters types. 1256 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1257 * @systemapi 1258 * @stagemodelonly 1259 * @since 9 1260 */ 1261 /** 1262 * Deletes one or more data records from the database. 1263 * 1264 * @param { string } uri - Indicates the path of the data to operate. 1265 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1266 * You should define the processing logic when this parameter is null. 1267 * @param { AsyncCallback<number> } callback - {number}: the number of data records deleted. 1268 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1269 * 2. Incorrect parameters types. 1270 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1271 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1272 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1273 * @systemapi 1274 * @stagemodelonly 1275 * @since 12 1276 */ 1277 delete(uri: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>): void; 1278 1279 /** 1280 * Deletes one or more data records from the database. 1281 * 1282 * @param { string } uri - Indicates the path of the data to operate. 1283 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1284 * You should define the processing logic when this parameter is null. 1285 * @returns { Promise<number> } {number}: the number of data records deleted. 1286 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1287 * 2. Incorrect parameters types. 1288 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1289 * @systemapi 1290 * @stagemodelonly 1291 * @since 9 1292 */ 1293 /** 1294 * Deletes one or more data records from the database. 1295 * 1296 * @param { string } uri - Indicates the path of the data to operate. 1297 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1298 * You should define the processing logic when this parameter is null. 1299 * @returns { Promise<number> } {number}: the number of data records deleted. 1300 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1301 * 2. Incorrect parameters types. 1302 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1303 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1304 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1305 * @systemapi 1306 * @stagemodelonly 1307 * @since 12 1308 */ 1309 delete(uri: string, predicates: dataSharePredicates.DataSharePredicates): Promise<number>; 1310 1311 /** 1312 * Queries data in the database. 1313 * 1314 * @param { string } uri - Indicates the path of data to query. 1315 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1316 * You should define the processing logic when this parameter is null. 1317 * @param { Array<string> } columns - Indicates the columns to query. 1318 * If this parameter is null, all columns are queried. 1319 * @param { AsyncCallback<DataShareResultSet> } callback - {DataShareResultSet}: the query result. 1320 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1321 * 2. Incorrect parameters types. 1322 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1323 * @systemapi 1324 * @stagemodelonly 1325 * @since 9 1326 */ 1327 /** 1328 * Queries data in the database. 1329 * 1330 * @param { string } uri - Indicates the path of data to query. 1331 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1332 * You should define the processing logic when this parameter is null. 1333 * @param { Array<string> } columns - Indicates the columns to query. 1334 * If this parameter is null, all columns are queried. 1335 * @param { AsyncCallback<DataShareResultSet> } callback - {DataShareResultSet}: the query result. 1336 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1337 * 2. Incorrect parameters types. 1338 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1339 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1340 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1341 * @systemapi 1342 * @stagemodelonly 1343 * @since arkts {'1.1':'12', '1.2':'20'} 1344 * @arkts 1.1&1.2 1345 */ 1346 query( 1347 uri: string, 1348 predicates: dataSharePredicates.DataSharePredicates, 1349 columns: Array<string>, 1350 callback: AsyncCallback<DataShareResultSet> 1351 ): void; 1352 1353 /** 1354 * Queries data in the database. 1355 * 1356 * @param { string } uri - Indicates the path of data to query. 1357 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1358 * You should define the processing logic when this parameter is null. 1359 * @param { Array<string> } columns - Indicates the columns to query. 1360 * If this parameter is null, all columns are queried. 1361 * @returns { Promise<DataShareResultSet> } {DataShareResultSet}: the query result. 1362 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1363 * 2. Incorrect parameters types. 1364 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1365 * @systemapi 1366 * @stagemodelonly 1367 * @since 9 1368 */ 1369 /** 1370 * Queries data in the database. 1371 * 1372 * @param { string } uri - Indicates the path of data to query. 1373 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1374 * You should define the processing logic when this parameter is null. 1375 * @param { Array<string> } columns - Indicates the columns to query. 1376 * If this parameter is null, all columns are queried. 1377 * @returns { Promise<DataShareResultSet> } {DataShareResultSet}: the query result. 1378 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1379 * 2. Incorrect parameters types. 1380 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1381 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1382 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1383 * @systemapi 1384 * @stagemodelonly 1385 * @since arkts {'1.1':'12', '1.2':'20'} 1386 * @arkts 1.1&1.2 1387 */ 1388 query( 1389 uri: string, 1390 predicates: dataSharePredicates.DataSharePredicates, 1391 columns: Array<string> 1392 ): Promise<DataShareResultSet>; 1393 1394 /** 1395 * Updates data records in the database. 1396 * 1397 * @param { string } uri - Indicates the path of data to update. 1398 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1399 * You should define the processing logic when this parameter is null. 1400 * @param { ValuesBucket } value - Indicates the data to update. This parameter can be null. 1401 * @param { AsyncCallback<number> } callback - {number}: the number of data records updated. 1402 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1403 * 2. Incorrect parameters types. 1404 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1405 * @systemapi 1406 * @stagemodelonly 1407 * @since 9 1408 */ 1409 /** 1410 * Updates data records in the database. 1411 * 1412 * @param { string } uri - Indicates the path of data to update. 1413 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1414 * You should define the processing logic when this parameter is null. 1415 * @param { ValuesBucket } value - Indicates the data to update. This parameter can be null. 1416 * @param { AsyncCallback<number> } callback - {number}: the number of data records updated. 1417 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1418 * 2. Incorrect parameters types. 1419 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1420 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1421 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1422 * @systemapi 1423 * @stagemodelonly 1424 * @since arkts {'1.1':'12', '1.2':'20'} 1425 * @arkts 1.1&1.2 1426 */ 1427 update( 1428 uri: string, 1429 predicates: dataSharePredicates.DataSharePredicates, 1430 value: ValuesBucket, 1431 callback: AsyncCallback<number> 1432 ): void; 1433 1434 /** 1435 * Updates data records in the database. 1436 * 1437 * @param { string } uri - Indicates the path of data to update. 1438 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1439 * You should define the processing logic when this parameter is null. 1440 * @param { ValuesBucket } value - Indicates the data to update. This parameter can be null. 1441 * @returns { Promise<number> } {number}: the number of data records updated. 1442 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1443 * 2. Incorrect parameters types. 1444 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1445 * @systemapi 1446 * @stagemodelonly 1447 * @since 9 1448 */ 1449 /** 1450 * Updates data records in the database. 1451 * 1452 * @param { string } uri - Indicates the path of data to update. 1453 * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria. 1454 * You should define the processing logic when this parameter is null. 1455 * @param { ValuesBucket } value - Indicates the data to update. This parameter can be null. 1456 * @returns { Promise<number> } {number}: the number of data records updated. 1457 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1458 * 2. Incorrect parameters types. 1459 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1460 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1461 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1462 * @systemapi 1463 * @stagemodelonly 1464 * @since arkts {'1.1':'12', '1.2':'20'} 1465 * @arkts 1.1&1.2 1466 */ 1467 update(uri: string, predicates: dataSharePredicates.DataSharePredicates, value: ValuesBucket): Promise<number>; 1468 1469 /** 1470 * Updates data records in the database. 1471 * 1472 * @param { Record<string, Array<UpdateOperation>> } operations - Indicates the data to update. 1473 * @returns {Promise<Record<string, Array<number>>>} {Record<string, Array<number>>}: The result set of batch operations. 1474 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1475 * 2. Incorrect parameters types. 1476 * @throws { BusinessError } 15700000 - Inner error. Possible causes: 1.The internal status is abnormal; 1477 * 2.The interface is incorrectly used; 3.Permission configuration error; 4.A system error. 1478 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1479 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1480 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1481 * @systemapi 1482 * @stagemodelonly 1483 * @since 12 1484 */ 1485 batchUpdate(operations: Record<string, Array<UpdateOperation>>): Promise<Record<string, Array<number>>>; 1486 1487 /** 1488 * Inserts multiple data records into the database. 1489 * 1490 * @param { string } uri - Indicates the path of the data to operate. 1491 * @param { Array<ValuesBucket> } values - Indicates the data records to insert. 1492 * @param { AsyncCallback<number> } callback - {number}: the number of data records inserted. 1493 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1494 * 2. Incorrect parameters types. 1495 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1496 * @systemapi 1497 * @stagemodelonly 1498 * @since 9 1499 */ 1500 /** 1501 * Inserts multiple data records into the database. 1502 * 1503 * @param { string } uri - Indicates the path of the data to operate. 1504 * @param { Array<ValuesBucket> } values - Indicates the data records to insert. 1505 * @param { AsyncCallback<number> } callback - {number}: the number of data records inserted. 1506 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1507 * 2. Incorrect parameters types. 1508 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1509 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1510 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1511 * @systemapi 1512 * @stagemodelonly 1513 * @since 12 1514 */ 1515 batchInsert(uri: string, values: Array<ValuesBucket>, callback: AsyncCallback<number>): void; 1516 1517 /** 1518 * Inserts multiple data records into the database. 1519 * 1520 * @param { string } uri - Indicates the path of the data to operate. 1521 * @param { Array<ValuesBucket> } values - Indicates the data records to insert. 1522 * @returns { Promise<number> } {number}: the number of data records inserted. 1523 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1524 * 2. Incorrect parameters types. 1525 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1526 * @systemapi 1527 * @stagemodelonly 1528 * @since 9 1529 */ 1530 /** 1531 * Inserts multiple data records into the database. 1532 * 1533 * @param { string } uri - Indicates the path of the data to operate. 1534 * @param { Array<ValuesBucket> } values - Indicates the data records to insert. 1535 * @returns { Promise<number> } {number}: the number of data records inserted. 1536 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1537 * 2. Incorrect parameters types. 1538 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1539 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1540 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1541 * @systemapi 1542 * @stagemodelonly 1543 * @since 12 1544 */ 1545 batchInsert(uri: string, values: Array<ValuesBucket>): Promise<number>; 1546 1547 /** 1548 * Converts the given {@code uri} that refers to the DataShare into a normalized {@link ohos.utils.net.Uri}. 1549 * A normalized uri can be used across devices, persisted, backed up, and restored. 1550 * <p>To transfer a normalized uri from another environment to the current environment, you should call this 1551 * method again to re-normalize the uri for the current environment or call {@link #denormalizeUri(Uri)} 1552 * to convert it to a denormalized uri that can be used only in the current environment. 1553 * 1554 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to normalize. 1555 * @param { AsyncCallback<string> } callback - {string}: the normalized Uri, 1556 * if the DataShare supports uri normalization. 1557 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1558 * @systemapi 1559 * @stagemodelonly 1560 * @since 9 1561 */ 1562 /** 1563 * Converts the given {@code uri} that refers to the DataShare into a normalized {@link ohos.utils.net.Uri}. 1564 * A normalized uri can be used across devices, persisted, backed up, and restored. 1565 * <p>To transfer a normalized uri from another environment to the current environment, you should call this 1566 * method again to re-normalize the uri for the current environment or call {@link #denormalizeUri(Uri)} 1567 * to convert it to a denormalized uri that can be used only in the current environment. 1568 * 1569 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to normalize. 1570 * @param { AsyncCallback<string> } callback - {string}: the normalized Uri, 1571 * if the DataShare supports uri normalization. 1572 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1573 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1574 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1575 * 2. Incorrect parameters types. 1576 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1577 * @systemapi 1578 * @stagemodelonly 1579 * @since 12 1580 */ 1581 normalizeUri(uri: string, callback: AsyncCallback<string>): void; 1582 1583 /** 1584 * Converts the given {@code uri} that refers to the DataShare into a normalized {@link ohos.utils.net.Uri}. 1585 * A normalized uri can be used across devices, persisted, backed up, and restored. 1586 * <p>To transfer a normalized uri from another environment to the current environment, you should call this 1587 * method again to re-normalize the uri for the current environment or call {@link #denormalizeUri(Uri)} 1588 * to convert it to a denormalized uri that can be used only in the current environment. 1589 * 1590 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to normalize. 1591 * @returns { Promise<string> } {string}: the normalized Uri if the DataShare supports uri normalization; 1592 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1593 * @systemapi 1594 * @stagemodelonly 1595 * @since 9 1596 */ 1597 /** 1598 * Converts the given {@code uri} that refers to the DataShare into a normalized {@link ohos.utils.net.Uri}. 1599 * A normalized uri can be used across devices, persisted, backed up, and restored. 1600 * <p>To transfer a normalized uri from another environment to the current environment, you should call this 1601 * method again to re-normalize the uri for the current environment or call {@link #denormalizeUri(Uri)} 1602 * to convert it to a denormalized uri that can be used only in the current environment. 1603 * 1604 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to normalize. 1605 * @returns { Promise<string> } {string}: the normalized Uri if the DataShare supports uri normalization; 1606 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1607 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1608 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1609 * 2. Incorrect parameters types. 1610 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1611 * @systemapi 1612 * @stagemodelonly 1613 * @since 12 1614 */ 1615 normalizeUri(uri: string): Promise<string>; 1616 1617 /** 1618 * Converts the given normalized {@code uri} generated by {@link #normalizeUri(Uri)} into a denormalized one. 1619 * 1620 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to denormalize. 1621 * @param { AsyncCallback<string> } callback - {string}: the denormalized {@code Uri} object if 1622 * the denormalization is successful; returns the original {@code Uri} passed to this method if 1623 * there is nothing to do; returns {@code null} if the data identified by the normalized {@code Uri} 1624 * cannot be found in the current environment. 1625 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1626 * @systemapi 1627 * @stagemodelonly 1628 * @since 9 1629 */ 1630 /** 1631 * Converts the given normalized {@code uri} generated by {@link #normalizeUri(Uri)} into a denormalized one. 1632 * 1633 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to denormalize. 1634 * @param { AsyncCallback<string> } callback - {string}: the denormalized {@code Uri} object if 1635 * the denormalization is successful; returns the original {@code Uri} passed to this method if 1636 * there is nothing to do; returns {@code null} if the data identified by the normalized {@code Uri} 1637 * cannot be found in the current environment. 1638 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1639 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1640 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1641 * 2. Incorrect parameters types. 1642 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1643 * @systemapi 1644 * @stagemodelonly 1645 * @since 12 1646 */ 1647 denormalizeUri(uri: string, callback: AsyncCallback<string>): void; 1648 1649 /** 1650 * Converts the given normalized {@code uri} generated by {@link #normalizeUri(Uri)} into a denormalized one. 1651 * 1652 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to denormalize. 1653 * @returns { Promise<string> } {string}: the denormalized {@code Uri} object if the denormalization 1654 * is successful; returns the original {@code Uri} passed to this method if there is nothing to do; 1655 * returns {@code null} if the data identified by the normalized {@code Uri} cannot be found in the 1656 * current environment. 1657 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1658 * @systemapi 1659 * @stagemodelonly 1660 * @since 9 1661 */ 1662 /** 1663 * Converts the given normalized {@code uri} generated by {@link #normalizeUri(Uri)} into a denormalized one. 1664 * 1665 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to denormalize. 1666 * @returns { Promise<string> } {string}: the denormalized {@code Uri} object if the denormalization 1667 * is successful; returns the original {@code Uri} passed to this method if there is nothing to do; 1668 * returns {@code null} if the data identified by the normalized {@code Uri} cannot be found in the 1669 * current environment. 1670 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1671 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1672 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1673 * 2. Incorrect parameters types. 1674 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1675 * @systemapi 1676 * @stagemodelonly 1677 * @since 12 1678 */ 1679 denormalizeUri(uri: string): Promise<string>; 1680 1681 /** 1682 * Notifies the registered observers of a change to the data resource specified by Uri. 1683 * 1684 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to notifyChange. 1685 * @param { AsyncCallback<void> } callback - The callback of notifyChange. 1686 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1687 * @systemapi 1688 * @stagemodelonly 1689 * @since 9 1690 */ 1691 /** 1692 * Notifies the registered observers of a change to the data resource specified by Uri. 1693 * 1694 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to notifyChange. 1695 * @param { AsyncCallback<void> } callback - The callback of notifyChange. 1696 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1697 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1698 * @throws { BusinessError } 401 - Parameter error.Mandatory parameters are left unspecified. 1699 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1700 * @systemapi 1701 * @stagemodelonly 1702 * @since 12 1703 */ 1704 notifyChange(uri: string, callback: AsyncCallback<void>): void; 1705 1706 /** 1707 * Notifies the registered observers of a change to the data resource specified by Uri. 1708 * 1709 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to notifyChange. 1710 * @returns { Promise<void> } The promise returned by the function. 1711 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1712 * @systemapi 1713 * @stagemodelonly 1714 * @since 9 1715 */ 1716 /** 1717 * Notifies the registered observers of a change to the data resource specified by Uri. 1718 * 1719 * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to notifyChange. 1720 * @returns { Promise<void> } The promise returned by the function. 1721 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1722 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1723 * @throws { BusinessError } 401 - Parameter error.Mandatory parameters are left unspecified. 1724 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1725 * @systemapi 1726 * @stagemodelonly 1727 * @since 12 1728 */ 1729 notifyChange(uri: string): Promise<void>; 1730 1731 /** 1732 * Notifies the registered observers of the data change. 1733 * 1734 * @param { ChangeInfo } data - Indicates the data change information. 1735 * @returns { Promise<void> } Promise that returns no value. 1736 * @throws { BusinessError } 15700013 - The DataShareHelper instance is already closed. 1737 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1738 * @throws { BusinessError } 401 - Parameter error.Possible causes: 1. Mandatory parameters are left unspecified; 1739 * 2. Incorrect parameters types. 1740 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1741 * @systemapi 1742 * @stagemodelonly 1743 * @since 12 1744 */ 1745 notifyChange(data: ChangeInfo): Promise<void>; 1746 1747 /** 1748 * Close the connection between datashare and extension. 1749 * 1750 * @returns { Promise<void> } The promise returned by the function. 1751 * @throws { BusinessError } 15700000 - Inner error. Possible causes: 1.The internal status is abnormal; 1752 * 2.The interface is incorrectly used; 3.Permission configuration error; 4.A system error. 1753 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1754 * @systemapi 1755 * @stagemodelonly 1756 * @since 12 1757 */ 1758 /** 1759 * Close the connection between datashare and extension. 1760 * 1761 * @returns { Promise<void> } The promise returned by the function. 1762 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 1763 * @throws { BusinessError } 15700000 - Inner error. Possible causes: 1.The internal status is abnormal; 1764 * 2.The interface is incorrectly used; 3.Permission configuration error; 4.A system error. 1765 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1766 * @systemapi 1767 * @stagemodelonly 1768 * @since 19 1769 */ 1770 close(): Promise<void>; 1771 } 1772 1773 /** 1774 * Obtains the data proxy handle, which can be used to subscribe, publish, and access globally shared data. 1775 * 1776 * @returns { Promise<DataProxyHandle> } Handle used for the data proxy operations. 1777 * @throws { BusinessError } 15700000 - Inner error. Possible causes: The service is not ready or is being 1778 * restarted abnormally. 1779 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1780 * @stagemodelonly 1781 * @since 20 1782 * @arkts 1.1&1.2 1783 */ 1784 function createDataProxyHandle(): Promise<DataProxyHandle>; 1785 1786 /** 1787 * Specifies the proxy data structure. 1788 * 1789 * @interface ProxyData 1790 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1791 * @stagemodelonly 1792 * @since 20 1793 * @arkts 1.1&1.2 1794 */ 1795 interface ProxyData { 1796 /** 1797 * URI for proxy data that uniquely identifies a proxy data item. Maximum length 256 bytes. 1798 * 1799 * @type { string } 1800 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1801 * @stagemodelonly 1802 * @since 20 1803 * @arkts 1.1&1.2 1804 */ 1805 uri: string; 1806 1807 /** 1808 * Value of the proxy data. Maximum length 4096 bytes. 1809 * When the proxy data is first published, if it is not filled in, it is set to an empty string by default. 1810 * When updating the proxy data, if it is not filled in, the value of the proxy data is not updated. 1811 * 1812 * @type { ?ValueType } 1813 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1814 * @stagemodelonly 1815 * @since 20 1816 * @arkts 1.1&1.2 1817 */ 1818 value?: ValueType; 1819 1820 /** 1821 * List of applications that are allowed to subscribe and read proxy data. The maximum length of the list is 256. 1822 * Uses appId to represent the allowed application. 1823 * When the proxy data is first published, if it is not filled in, it defaults to an empty array. 1824 * When updating the proxy data, if it is not filled in, the allowList of the proxy data is not updated. 1825 * An empty allowList array indicates that only the publisher can access the data. 1826 * 1827 * @type { ?string[] } 1828 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1829 * @stagemodelonly 1830 * @since 20 1831 * @arkts 1.1&1.2 1832 */ 1833 allowList?: string[]; 1834 } 1835 1836 /** 1837 * Structure that describes the info of the proxy data changed. 1838 * 1839 * @interface DataProxyChangeInfo 1840 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1841 * @stagemodelonly 1842 * @since 20 1843 * @arkts 1.1&1.2 1844 */ 1845 interface DataProxyChangeInfo { 1846 /** 1847 * Type of the data changed. 1848 * 1849 * @type { ChangeType } 1850 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1851 * @stagemodelonly 1852 * @since 20 1853 * @arkts 1.1&1.2 1854 */ 1855 type: ChangeType; 1856 1857 /** 1858 * URI of the data changed. 1859 * 1860 * @type { string } 1861 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1862 * @stagemodelonly 1863 * @since 20 1864 * @arkts 1.1&1.2 1865 */ 1866 uri: string; 1867 1868 /** 1869 * Value of the data changed. 1870 * 1871 * @type { ValueType } 1872 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1873 * @stagemodelonly 1874 * @since 20 1875 * @arkts 1.1&1.2 1876 */ 1877 value: ValueType; 1878 } 1879 1880 /** 1881 * Enumeration of data proxy operation error codes. 1882 * 1883 * @enum { number } DataProxyErrorCode 1884 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1885 * @stagemodelonly 1886 * @since 20 1887 * @arkts 1.1&1.2 1888 */ 1889 enum DataProxyErrorCode { 1890 /** 1891 * Operation successful. 1892 * 1893 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1894 * @stagemodelonly 1895 * @since 20 1896 * @arkts 1.1&1.2 1897 */ 1898 SUCCESS = 0, 1899 1900 /** 1901 * URI format is incorrect or does not exist. 1902 * 1903 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1904 * @stagemodelonly 1905 * @since 20 1906 * @arkts 1.1&1.2 1907 */ 1908 URI_NOT_EXIST = 1, 1909 1910 /** 1911 * Do not have permission to perform this operation on this URI. 1912 * 1913 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1914 * @stagemodelonly 1915 * @since 20 1916 * @arkts 1.1&1.2 1917 */ 1918 NO_PERMISSION = 2, 1919 1920 /** 1921 * Exceeds the upper limit of the number of data records. 1922 * 1923 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1924 * @stagemodelonly 1925 * @since 20 1926 * @arkts 1.1&1.2 1927 */ 1928 OVER_LIMIT = 3 1929 } 1930 1931 /** 1932 * Structure that indicates the result of a single data proxy operation. 1933 * 1934 * @interface DataProxyResult 1935 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1936 * @stagemodelonly 1937 * @since 20 1938 * @arkts 1.1&1.2 1939 */ 1940 interface DataProxyResult { 1941 /** 1942 * URI of the data being operated on. 1943 * 1944 * @type { string } 1945 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1946 * @stagemodelonly 1947 * @since 20 1948 * @arkts 1.1&1.2 1949 */ 1950 uri: string; 1951 1952 /** 1953 * Error code of the operation result. 1954 * @type { DataProxyErrorCode } 1955 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1956 * @stagemodelonly 1957 * @since 20 1958 * @arkts 1.1&1.2 1959 */ 1960 result: DataProxyErrorCode; 1961 } 1962 1963 /** 1964 * Structure that indicates the result of a single getting operation. 1965 * 1966 * @interface DataProxyGetResult 1967 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1968 * @stagemodelonly 1969 * @since 20 1970 * @arkts 1.1&1.2 1971 */ 1972 interface DataProxyGetResult { 1973 /** 1974 * URI of the data being operated on. 1975 * 1976 * @type { string } 1977 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1978 * @stagemodelonly 1979 * @since 20 1980 * @arkts 1.1&1.2 1981 */ 1982 uri: string; 1983 1984 /** 1985 * Error code of the operation result. 1986 * 1987 * @type { DataProxyErrorCode } 1988 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 1989 * @stagemodelonly 1990 * @since 20 1991 * @arkts 1.1&1.2 1992 */ 1993 result: DataProxyErrorCode; 1994 1995 /** 1996 * If the getting operation is successful, it is the value of the proxy data, 1997 * if the getting operation is failed, it is undefined. 1998 * 1999 * @type { ValueType | undefined } 2000 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 2001 * @stagemodelonly 2002 * @since 20 2003 * @arkts 1.1&1.2 2004 */ 2005 value: ValueType | undefined; 2006 2007 /** 2008 * If the getting operation is successful, it is the allowList of the proxy data, 2009 * if the getting operation is failed, it is undefined. 2010 * Only the publisher can obtain the allowList. Other applications can only obtain the value. 2011 * 2012 * @type { string[] | undefined} 2013 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 2014 * @stagemodelonly 2015 * @since 20 2016 * @arkts 1.1&1.2 2017 */ 2018 allowList: string[] | undefined; 2019 } 2020 2021 /** 2022 * Enumeration of data proxy types. 2023 * 2024 * @enum { number } DataProxyType 2025 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 2026 * @stagemodelonly 2027 * @since 20 2028 * @arkts 1.1&1.2 2029 */ 2030 enum DataProxyType { 2031 /** 2032 * Indicates shared configuration between applications. 2033 * 2034 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 2035 * @stagemodelonly 2036 * @since 20 2037 * @arkts 1.1&1.2 2038 */ 2039 SHARED_CONFIG = 0 2040 } 2041 2042 /** 2043 * Structure that indicates the configuration for data proxy operation. 2044 * 2045 * @interface DataProxyConfig 2046 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 2047 * @stagemodelonly 2048 * @since 20 2049 * @arkts 1.1&1.2 2050 */ 2051 interface DataProxyConfig { 2052 /** 2053 * Type of the data proxy operation. 2054 * 2055 * @type { DataProxyType } 2056 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 2057 * @stagemodelonly 2058 * @since 20 2059 * @arkts 1.1&1.2 2060 */ 2061 type: DataProxyType; 2062 } 2063 2064 /** 2065 * Handle for data proxy operations. 2066 * 2067 * @interface DataProxyHandle 2068 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 2069 * @stagemodelonly 2070 * @since 20 2071 * @arkts 1.1&1.2 2072 */ 2073 interface DataProxyHandle { 2074 /** 2075 * Registers observers to observe proxy data change specified by the given URIs. 2076 * 2077 * @param { 'dataChange' } event - Event type must be 'sharedDataChange'. 2078 * @param { string[] } uris - Indicates the uris of the data to operate. 2079 * @param { DataProxyConfig } config - Indicates the configuration of the data proxy operation. 2080 * @param { AsyncCallback<DataProxyChangeInfo[]> } callback - The callback function when data changes. 2081 * @returns { DataProxyResult[] } : The operation result. 2082 * @throws { BusinessError } 15700000 - Inner error. Possible causes: The service is not ready or is being 2083 * restarted abnormally. 2084 * @throws { BusinessError } 15700014 - The parameter format is incorrect or the value range is invalid. 2085 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 2086 * @stagemodelonly 2087 * @since 20 2088 * @arkts 1.1&1.2 2089 */ 2090 on( 2091 event: 'dataChange', 2092 uris: string[], 2093 config: DataProxyConfig, 2094 callback: AsyncCallback<DataProxyChangeInfo[]> 2095 ): DataProxyResult[]; 2096 2097 /** 2098 * Deregisters observers to observe proxy data change specified by the given URIs. 2099 * 2100 * @param { 'dataChange' } event - Event type must be 'sharedDataChange'. 2101 * @param { string[] } uris - Indicates the uris of the data to operate. 2102 * @param { DataProxyConfig } config - Indicates the configuration of the data proxy operation. 2103 * @param { AsyncCallback<DataProxyChangeInfo[]> } [callback] - The callback function when data changes. 2104 * @returns { DataProxyResult[] } : The operation result. 2105 * @throws { BusinessError } 15700000 - Inner error. Possible causes: The service is not ready or is being 2106 * restarted abnormally. 2107 * @throws { BusinessError } 15700014 - The parameter format is incorrect or the value range is invalid. 2108 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 2109 * @stagemodelonly 2110 * @since 20 2111 * @arkts 1.1&1.2 2112 */ 2113 off( 2114 event: 'dataChange', 2115 uris: string[], 2116 config: DataProxyConfig, 2117 callback?: AsyncCallback<DataProxyChangeInfo[]> 2118 ): DataProxyResult[]; 2119 2120 /** 2121 * Publishes proxy data. The data that is published can be accessed by the publisher and the applications 2122 * specified in the allowList. 2123 * If the URI being published already exists, update the corresponding data. 2124 * Only the publisher is allowed to update the data. 2125 * 2126 * @param { ProxyData[] } data - Indicates the data to create or update. 2127 * @param { DataProxyConfig } config - Indicates the configuration of the data proxy operation. 2128 * @returns { Promise<DataProxyResult[]> } : The operation result. 2129 * @throws { BusinessError } 15700000 - Inner error. Possible causes: The service is not ready or is being 2130 * restarted abnormally. 2131 * @throws { BusinessError } 15700014 - The parameter format is incorrect or the value range is invalid. 2132 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 2133 * @stagemodelonly 2134 * @since 20 2135 * @arkts 1.1&1.2 2136 */ 2137 publish(data: ProxyData[], config: DataProxyConfig): Promise<DataProxyResult[]>; 2138 2139 /** 2140 * Deletes the proxy data specified by the URIs. 2141 * Only the data publisher can delete the data. 2142 * 2143 * @param { string[] } uris - Indicates the uris of data to delete. 2144 * @param { DataProxyConfig } config - Indicates the configuration of the data proxy operation. 2145 * @returns { Promise<DataProxyResult[]> } : The operation result. 2146 * @throws { BusinessError } 15700000 - Inner error. Possible causes: The service is not ready or is being 2147 * restarted abnormally. 2148 * @throws { BusinessError } 15700014 - The parameter format is incorrect or the value range is invalid. 2149 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 2150 * @stagemodelonly 2151 * @since 20 2152 * @arkts 1.1&1.2 2153 */ 2154 delete(uris: string[], config: DataProxyConfig): Promise<DataProxyResult[]>; 2155 2156 /** 2157 * Gets published data specified by the URIs. 2158 * Only the publisher itself and applications in the allowList can get the data. 2159 * 2160 * @param { string[] } uris - Indicates the uris of data to get. 2161 * @param { DataProxyConfig } config - Indicates the configuration of the data proxy operation. 2162 * @returns { Promise<DataProxyGetResult[]> } : The operation result. 2163 * @throws { BusinessError } 15700000 - Inner error. Possible causes: The service is not ready or is being 2164 * restarted abnormally. 2165 * @throws { BusinessError } 15700014 - The parameter format is incorrect or the value range is invalid. 2166 * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer 2167 * @stagemodelonly 2168 * @since 20 2169 * @arkts 1.1&1.2 2170 */ 2171 get(uris: string[], config: DataProxyConfig): Promise<DataProxyGetResult[]>; 2172 } 2173 2174} 2175 2176export default dataShare; 2177