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 } from './@ohos.base'; 22import image from "./@ohos.multimedia.image"; 23import Want from "./@ohos.app.ability.Want"; 24 25/** 26 * Provide methods for sharing data between different applications across unified data channels. 27 * 28 * @namespace unifiedDataChannel 29 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 30 * @since 10 31 */ 32/** 33 * Provide methods for sharing data between different applications across unified data channels. 34 * 35 * @namespace unifiedDataChannel 36 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 37 * @atomicservice 38 * @since 11 39 */ 40declare namespace unifiedDataChannel { 41 /** 42 * Types of scope that UnifiedData can be used. 43 * @enum { number } 44 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 45 * @atomicservice 46 * @since 12 47 */ 48 enum ShareOptions { 49 /** 50 * IN_APP indicates that only use in the same app is allowed. 51 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 52 * @atomicservice 53 * @since 12 54 */ 55 IN_APP, 56 /** 57 * CROSS_APP indicates that use in any app in this device is allowed. 58 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 59 * @atomicservice 60 * @since 12 61 */ 62 CROSS_APP 63 } 64 65 /** 66 * Indicated delay get UnifiedData 67 * 68 * @typedef {function} GetDelayData 69 * @param { string } type - the type of UnifiedData required. 70 * @returns { UnifiedData } Return the UnifiedData required. 71 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 72 * @atomicservice 73 * @since 12 74 */ 75 type GetDelayData = (type: string) => UnifiedData; 76 77 /** 78 * Indicates type of value. 79 * @typedef {number | string | boolean | image.PixelMap | Want | ArrayBuffer | object | null | undefined} 80 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 81 * @atomicservice 82 * @since 12 83 */ 84 type ValueType = number | string | boolean | image.PixelMap | Want | ArrayBuffer | object | null | undefined; 85 86 /** 87 * Describe the unified data properties. 88 * 89 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 90 * @atomicservice 91 * @since 12 92 */ 93 class UnifiedDataProperties { 94 /** 95 * extra property data. key-value pairs. 96 * @type { ?Record<string, object> } 97 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 98 * @atomicservice 99 * @since 12 100 */ 101 extras?: Record<string, object>; 102 103 /** 104 * the user-defined tag of a UnifiedData object. 105 * @type { ?string } 106 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 107 * @atomicservice 108 * @since 12 109 */ 110 tag?: string; 111 /** 112 * a timestamp, which indicates when data is written. 113 * @type { ?Date } 114 * @readonly 115 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 116 * @atomicservice 117 * @since 12 118 */ 119 readonly timestamp?: Date; 120 /** 121 * Indicates the scope of clipboard data which can be used. 122 * If it is not set or is incorrectly set, The default value is CrossDevice. 123 * @type { ?ShareOptions } 124 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 125 * @atomicservice 126 * @since 12 127 */ 128 shareOptions?: ShareOptions; 129 130 /** 131 * Indicated delay get UnifiedData. 132 * @type { ?GetDelayData } 133 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 134 * @atomicservice 135 * @since 12 136 */ 137 getDelayData?: GetDelayData; 138 } 139 140 /** 141 * Describe the unified data. 142 * 143 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 144 * @since 10 145 */ 146 /** 147 * Describe the unified data. 148 * 149 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 150 * @atomicservice 151 * @since 11 152 */ 153 class UnifiedData { 154 /** 155 * Create unified data with a record 156 * 157 * @param { UnifiedRecord } record - Record will add into unified data. 158 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 159 * <br>2.Incorrect parameters types. 160 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 161 * @since 10 162 */ 163 /** 164 * Create unified data with a record 165 * 166 * @param { UnifiedRecord } record - Record will add into unified data. 167 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 168 * <br>2.Incorrect parameters types. 169 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 170 * @atomicservice 171 * @since 11 172 */ 173 constructor(record: UnifiedRecord); 174 /** 175 * Create a empty unified data. 176 * 177 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 178 * @atomicservice 179 * @since 12 180 */ 181 constructor(); 182 /** 183 * Add a record into unified data 184 * 185 * @param { UnifiedRecord } record - Record will add into unified data. 186 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 187 * <br>2.Incorrect parameters types. 188 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 189 * @since 10 190 */ 191 /** 192 * Add a record into unified data 193 * 194 * @param { UnifiedRecord } record - Record will add into unified data. 195 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 196 * <br>2.Incorrect parameters types. 197 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 198 * @atomicservice 199 * @since 11 200 */ 201 addRecord(record: UnifiedRecord): void; 202 /** 203 * Get all records of unified data 204 * 205 * @returns { Array<UnifiedRecord> } Return the records of unified data 206 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 207 * @since 10 208 */ 209 /** 210 * Get all records of unified data 211 * 212 * @returns { Array<UnifiedRecord> } Return the records of unified data 213 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 214 * @atomicservice 215 * @since 11 216 */ 217 getRecords(): Array<UnifiedRecord>; 218 219 /** 220 * Checks whether there is a specified type of data in DataProperties. 221 * @param { string } type - indicates to query data type. 222 * @returns { boolean } if having mimeType in UnifiedData returns true, else returns false. 223 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 224 * <br>2.Incorrect parameters types. 225 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 226 * @atomicservice 227 * @since 12 228 */ 229 hasType(type: string): boolean; 230 231 /** 232 * UTD types of all content in the UnifiedData. 233 * @returns { Array<string> } type of array 234 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 235 * @atomicservice 236 * @since 12 237 */ 238 getTypes(): Array<string>; 239 240 /** 241 * UnifiedData properties. 242 * @type { UnifiedDataProperties } 243 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 244 * @atomicservice 245 * @since 12 246 */ 247 properties: UnifiedDataProperties; 248 } 249 250 /** 251 * The data abstract supported by unified data 252 * 253 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 254 * @since 10 255 */ 256 /** 257 * The data abstract supported by unified data 258 * 259 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 260 * @atomicservice 261 * @since 11 262 */ 263 class Summary { 264 /** 265 * A map for each type and data size, key is data type, value is the corresponding data size 266 * 267 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 268 * @since 10 269 */ 270 /** 271 * A map for each type and data size, key is data type, value is the corresponding data size 272 * 273 * @type { Record<string, number> } 274 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 275 * @atomicservice 276 * @since 11 277 */ 278 summary: Record<string, number>; 279 /** 280 * Total data size of data in Bytes 281 * 282 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 283 * @since 10 284 */ 285 /** 286 * Total data size of data in Bytes 287 * 288 * @type { number } 289 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 290 * @atomicservice 291 * @since 11 292 */ 293 totalSize: number; 294 } 295 296 /** 297 * Describe the unified record 298 * 299 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 300 * @since 10 301 */ 302 /** 303 * Describe the unified record 304 * 305 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 306 * @atomicservice 307 * @since 11 308 */ 309 class UnifiedRecord { 310 /** 311 * Get type of unified record 312 * 313 * @returns { string } Return the type of unified data 314 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 315 * @since 10 316 */ 317 /** 318 * Get type of unified record 319 * 320 * @returns { string } Return the type of unified data 321 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 322 * @atomicservice 323 * @since 11 324 */ 325 getType(): string; 326 327 /** 328 * Create unified record. 329 * 330 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 331 * @atomicservice 332 * @since 12 333 */ 334 constructor(); 335 336 /** 337 * Create unified record by type and value. 338 * 339 * @param { string } type - indicates to data type of unified record. It can not be empty. When type of value is object, parameter type must be pixel-map or want UTD type. 340 * @param { ValueType } value - indicates to value of unified record. 341 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 342 * <br>2.Incorrect parameters types; 343 * <br>3.Parameter verification failed. 344 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 345 * @atomicservice 346 * @since 12 347 */ 348 constructor(type: string, value: ValueType); 349 350 /** 351 * Get the value of unified record. 352 * 353 * @returns { ValueType } Return the value of unified record. 354 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 355 * @atomicservice 356 * @since 12 357 */ 358 getValue(): ValueType; 359 } 360 361 /** 362 * Describe the unified text data 363 * 364 * @extends UnifiedRecord 365 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 366 * @since 10 367 */ 368 /** 369 * Describe the unified text data 370 * 371 * @extends UnifiedRecord 372 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 373 * @atomicservice 374 * @since 11 375 */ 376 class Text extends UnifiedRecord { 377 /** 378 * Indicates the details of unified text 379 * 380 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 381 * @since 10 382 */ 383 /** 384 * Indicates the details of unified text 385 * 386 * @type { ?Record<string, string> } 387 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 388 * @atomicservice 389 * @since 11 390 */ 391 details?: Record<string, string>; 392 } 393 394 /** 395 * Describe the unified plain text data 396 * 397 * @extends Text 398 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 399 * @since 10 400 */ 401 /** 402 * Describe the unified plain text data 403 * 404 * @extends Text 405 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 406 * @atomicservice 407 * @since 11 408 */ 409 class PlainText extends Text { 410 /** 411 * Indicates the content of text 412 * 413 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 414 * @since 10 415 */ 416 /** 417 * Indicates the content of text 418 * 419 * @type { string } 420 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 421 * @atomicservice 422 * @since 11 423 */ 424 textContent: string; 425 /** 426 * Indicates the abstract of text 427 * 428 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 429 * @since 10 430 */ 431 /** 432 * Indicates the abstract of text 433 * 434 * @type { ?string } 435 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 436 * @atomicservice 437 * @since 11 438 */ 439 abstract?: string; 440 } 441 442 /** 443 * Describe the unified link data 444 * 445 * @extends Text 446 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 447 * @since 10 448 */ 449 /** 450 * Describe the unified link data 451 * 452 * @extends Text 453 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 454 * @atomicservice 455 * @since 11 456 */ 457 class Hyperlink extends Text { 458 /** 459 * Indicates the url of a link 460 * 461 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 462 * @since 10 463 */ 464 /** 465 * Indicates the url of a link 466 * 467 * @type { string } 468 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 469 * @atomicservice 470 * @since 11 471 */ 472 url: string; 473 /** 474 * Indicates the description of a link 475 * 476 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 477 * @since 10 478 */ 479 /** 480 * Indicates the description of a link 481 * 482 * @type { ?string } 483 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 484 * @atomicservice 485 * @since 11 486 */ 487 description?: string; 488 } 489 490 /** 491 * Describe the unified html data 492 * 493 * @extends Text 494 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 495 * @since 10 496 */ 497 /** 498 * Describe the unified html data 499 * 500 * @extends Text 501 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 502 * @atomicservice 503 * @since 11 504 */ 505 class HTML extends Text { 506 /** 507 * Indicates the content of html, with html tags 508 * 509 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 510 * @since 10 511 */ 512 /** 513 * Indicates the content of html, with html tags 514 * 515 * @type { string } 516 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 517 * @atomicservice 518 * @since 11 519 */ 520 htmlContent: string; 521 /** 522 * Indicates the plain content of html 523 * 524 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 525 * @since 10 526 */ 527 /** 528 * Indicates the plain content of html 529 * 530 * @type { ?string } 531 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 532 * @atomicservice 533 * @since 11 534 */ 535 plainContent?: string; 536 } 537 538 /** 539 * Describe the unified file data 540 * 541 * @extends UnifiedRecord 542 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 543 * @since 10 544 */ 545 /** 546 * Describe the unified file data 547 * 548 * @extends UnifiedRecord 549 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 550 * @atomicservice 551 * @since 11 552 */ 553 class File extends UnifiedRecord { 554 /** 555 * Indicates the details of unified File 556 * 557 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 558 * @since 10 559 */ 560 /** 561 * Indicates the details of unified File 562 * 563 * @type { ?Record<string, string> } 564 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 565 * @atomicservice 566 * @since 11 567 */ 568 details?: Record<string, string>; 569 /** 570 * Indicates the uri of file 571 * 572 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 573 * @since 10 574 */ 575 /** 576 * Indicates the uri of file 577 * 578 * @type { string } 579 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 580 * @atomicservice 581 * @since 11 582 */ 583 uri: string; 584 } 585 586 /** 587 * Describe the unified image data 588 * 589 * @extends File 590 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 591 * @since 10 592 */ 593 /** 594 * Describe the unified image data 595 * 596 * @extends File 597 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 598 * @atomicservice 599 * @since 11 600 */ 601 class Image extends File { 602 /** 603 * Indicates the uri of image 604 * 605 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 606 * @since 10 607 */ 608 /** 609 * Indicates the uri of image 610 * 611 * @type { string } 612 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 613 * @atomicservice 614 * @since 11 615 */ 616 imageUri: string; 617 } 618 619 /** 620 * Describe the unified video data 621 * 622 * @extends File 623 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 624 * @since 10 625 */ 626 /** 627 * Describe the unified video data 628 * 629 * @extends File 630 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 631 * @atomicservice 632 * @since 11 633 */ 634 class Video extends File { 635 /** 636 * Indicates the uri of video 637 * 638 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 639 * @since 10 640 */ 641 /** 642 * Indicates the uri of video 643 * 644 * @type { string } 645 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 646 * @atomicservice 647 * @since 11 648 */ 649 videoUri: string; 650 } 651 652 /** 653 * Describe the unified audio data 654 * 655 * @extends File 656 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 657 * @since 10 658 */ 659 /** 660 * Describe the unified audio data 661 * 662 * @extends File 663 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 664 * @atomicservice 665 * @since 11 666 */ 667 class Audio extends File { 668 /** 669 * Indicates the uri of audio 670 * 671 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 672 * @since 10 673 */ 674 /** 675 * Indicates the uri of audio 676 * 677 * @type { string } 678 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 679 * @atomicservice 680 * @since 11 681 */ 682 audioUri: string; 683 } 684 685 /** 686 * Describe the unified folder data 687 * 688 * @extends File 689 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 690 * @since 10 691 */ 692 /** 693 * Describe the unified folder data 694 * 695 * @extends File 696 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 697 * @atomicservice 698 * @since 11 699 */ 700 class Folder extends File { 701 /** 702 * Indicates the uri of folder 703 * 704 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 705 * @since 10 706 */ 707 /** 708 * Indicates the uri of folder 709 * 710 * @type { string } 711 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 712 * @atomicservice 713 * @since 11 714 */ 715 folderUri: string; 716 } 717 718 /** 719 * Describe system defined type data(this kind of data is provided and bound to OpenHarmony, 720 * also can be parsed by system provided API) 721 * 722 * @extends UnifiedRecord 723 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 724 * @since 10 725 */ 726 /** 727 * Describe system defined type data(this kind of data is provided and bound to OpenHarmony, 728 * also can be parsed by system provided API) 729 * 730 * @extends UnifiedRecord 731 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 732 * @atomicservice 733 * @since 11 734 */ 735 class SystemDefinedRecord extends UnifiedRecord { 736 /** 737 * Indicates the details of system defined data 738 * 739 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 740 * @since 10 741 */ 742 /** 743 * Indicates the details of system defined data 744 * 745 * @type { ?Record<string, number | string | Uint8Array> } 746 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 747 * @atomicservice 748 * @since 11 749 */ 750 details?: Record<string, number | string | Uint8Array>; 751 } 752 753 /** 754 * Describe system defined form data(this kind of data is provided and bound to OpenHarmony, 755 * also can be parsed by system provided API) 756 * 757 * @extends SystemDefinedRecord 758 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 759 * @since 10 760 */ 761 /** 762 * Describe system defined form data(this kind of data is provided and bound to OpenHarmony, 763 * also can be parsed by system provided API) 764 * 765 * @extends SystemDefinedRecord 766 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 767 * @atomicservice 768 * @since 11 769 */ 770 class SystemDefinedForm extends SystemDefinedRecord { 771 /** 772 * Indicates the id of form 773 * 774 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 775 * @since 10 776 */ 777 /** 778 * Indicates the id of form 779 * 780 * @type { number } 781 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 782 * @atomicservice 783 * @since 11 784 */ 785 formId: number; 786 /** 787 * Indicates the name of form 788 * 789 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 790 * @since 10 791 */ 792 /** 793 * Indicates the name of form 794 * 795 * @type { string } 796 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 797 * @atomicservice 798 * @since 11 799 */ 800 formName: string; 801 /** 802 * Indicates the bundle name of form 803 * 804 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 805 * @since 10 806 */ 807 /** 808 * Indicates the bundle name of form 809 * 810 * @type { string } 811 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 812 * @atomicservice 813 * @since 11 814 */ 815 bundleName: string; 816 /** 817 * Indicates the ability name of form 818 * 819 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 820 * @since 10 821 */ 822 /** 823 * Indicates the ability name of form 824 * 825 * @type { string } 826 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 827 * @atomicservice 828 * @since 11 829 */ 830 abilityName: string; 831 /** 832 * Indicates the module of form 833 * 834 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 835 * @since 10 836 */ 837 /** 838 * Indicates the module of form 839 * 840 * @type { string } 841 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 842 * @atomicservice 843 * @since 11 844 */ 845 module: string; 846 } 847 848 /** 849 * Describe system defined app item data(this kind of data is provided and bound to OpenHarmony, 850 * also can be parsed by system provided API) 851 * 852 * @extends SystemDefinedRecord 853 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 854 * @since 10 855 */ 856 /** 857 * Describe system defined app item data(this kind of data is provided and bound to OpenHarmony, 858 * also can be parsed by system provided API) 859 * 860 * @extends SystemDefinedRecord 861 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 862 * @atomicservice 863 * @since 11 864 */ 865 class SystemDefinedAppItem extends SystemDefinedRecord { 866 /** 867 * Indicates the app id 868 * 869 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 870 * @since 10 871 */ 872 /** 873 * Indicates the app id 874 * 875 * @type { string } 876 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 877 * @atomicservice 878 * @since 11 879 */ 880 appId: string; 881 /** 882 * Indicates the app name 883 * 884 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 885 * @since 10 886 */ 887 /** 888 * Indicates the app name 889 * 890 * @type { string } 891 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 892 * @atomicservice 893 * @since 11 894 */ 895 appName: string; 896 /** 897 * Indicates the id of app icon 898 * 899 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 900 * @since 10 901 */ 902 /** 903 * Indicates the id of app icon 904 * 905 * @type { string } 906 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 907 * @atomicservice 908 * @since 11 909 */ 910 appIconId: string; 911 /** 912 * Indicates the id of app label 913 * 914 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 915 * @since 10 916 */ 917 /** 918 * Indicates the id of app label 919 * 920 * @type { string } 921 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 922 * @atomicservice 923 * @since 11 924 */ 925 appLabelId: string; 926 /** 927 * Indicates the bundle name of app 928 * 929 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 930 * @since 10 931 */ 932 /** 933 * Indicates the bundle name of app 934 * 935 * @type { string } 936 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 937 * @atomicservice 938 * @since 11 939 */ 940 bundleName: string; 941 /** 942 * Indicates the ability name of app 943 * 944 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 945 * @since 10 946 */ 947 /** 948 * Indicates the ability name of app 949 * 950 * @type { string } 951 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 952 * @atomicservice 953 * @since 11 954 */ 955 abilityName: string; 956 } 957 958 /** 959 * Describe system defined pixel map data(this kind of data is provided and bound to OpenHarmony, 960 * also can be parsed by system provided API) 961 * 962 * @extends SystemDefinedRecord 963 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 964 * @since 10 965 */ 966 /** 967 * Describe system defined pixel map data(this kind of data is provided and bound to OpenHarmony, 968 * also can be parsed by system provided API) 969 * 970 * @extends SystemDefinedRecord 971 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 972 * @atomicservice 973 * @since 11 974 */ 975 class SystemDefinedPixelMap extends SystemDefinedRecord { 976 /** 977 * Indicates the raw data of pixel map 978 * 979 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 980 * @since 10 981 */ 982 /** 983 * Indicates the raw data of pixel map 984 * 985 * @type { Uint8Array } 986 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 987 * @atomicservice 988 * @since 11 989 */ 990 rawData: Uint8Array; 991 } 992 993 /** 994 * Describe application defined data(this kind of data is provided and bound to OpenHarmony, 995 * also can be parsed by system provided API) 996 * 997 * @extends UnifiedRecord 998 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 999 * @since 10 1000 */ 1001 /** 1002 * Describe application defined data(this kind of data is provided and bound to OpenHarmony, 1003 * also can be parsed by system provided API) 1004 * 1005 * @extends UnifiedRecord 1006 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1007 * @atomicservice 1008 * @since 11 1009 */ 1010 class ApplicationDefinedRecord extends UnifiedRecord { 1011 /** 1012 * Indicates the type of data, should always be started with 'ApplicationDefined.', will 1013 * return error otherwise 1014 * 1015 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1016 * @since 10 1017 */ 1018 /** 1019 * Indicates the type of data, should always be started with 'ApplicationDefined.', will 1020 * return error otherwise 1021 * 1022 * @type { string } 1023 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1024 * @atomicservice 1025 * @since 11 1026 */ 1027 applicationDefinedType: string; 1028 /** 1029 * Indicates the raw data of application defined data 1030 * 1031 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1032 * @since 10 1033 */ 1034 /** 1035 * Indicates the raw data of application defined data 1036 * 1037 * @type { Uint8Array } 1038 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1039 * @atomicservice 1040 * @since 11 1041 */ 1042 rawData: Uint8Array; 1043 } 1044 1045 /** 1046 * Describe the sharing channel that UDMF support 1047 * 1048 * @enum { string } 1049 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1050 * @since 10 1051 */ 1052 /** 1053 * Describe the sharing channel that UDMF support 1054 * 1055 * @enum { string } 1056 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1057 * @atomicservice 1058 * @since 11 1059 */ 1060 enum Intention { 1061 /** 1062 * Indicates the intention of data hub 1063 * 1064 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1065 * @since 10 1066 */ 1067 /** 1068 * Indicates the intention of data hub 1069 * 1070 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1071 * @atomicservice 1072 * @since 11 1073 */ 1074 DATA_HUB = 'DataHub', 1075 1076 /** 1077 * Indicates the intention of drag 1078 * 1079 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1080 * @systemapi 1081 * @StageModelOnly 1082 * @since 12 1083 */ 1084 DRAG = 'Drag' 1085 } 1086 1087 /** 1088 * Describe the optional arguments of data operation 1089 * 1090 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1091 * @since 10 1092 */ 1093 /** 1094 * Describe the optional arguments of data operation 1095 * 1096 * @typedef { object } 1097 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1098 * @atomicservice 1099 * @since 11 1100 */ 1101 type Options = { 1102 /** 1103 * Indicates the target Intention 1104 * 1105 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1106 * @since 10 1107 */ 1108 /** 1109 * Indicates the target Intention 1110 * 1111 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1112 * @atomicservice 1113 * @since 11 1114 */ 1115 intention?: Intention; 1116 1117 /** 1118 * Indicates the unique identifier of target UnifiedData 1119 * 1120 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1121 * @since 10 1122 */ 1123 /** 1124 * Indicates the unique identifier of target UnifiedData 1125 * 1126 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1127 * @atomicservice 1128 * @since 11 1129 */ 1130 key?: string; 1131 }; 1132 1133 /** 1134 * Insert data into unified data channel by Intention 1135 * 1136 * @param { Options } options - fill the intention field to indicate the target {@link Intention}. 1137 * @param { UnifiedData } data - {@link UnifiedData} data object to insert into target intention. 1138 * @param { AsyncCallback<string> } callback - {string}: the unique identifier. 1139 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 1140 * <br>2.Incorrect parameters types. 1141 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1142 * @since 10 1143 */ 1144 /** 1145 * Insert data into unified data channel by Intention 1146 * 1147 * @param { Options } options - fill the intention field to indicate the target {@link Intention}. 1148 * @param { UnifiedData } data - {@link UnifiedData} data object to insert into target intention. 1149 * @param { AsyncCallback<string> } callback - {string}: the unique identifier. 1150 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 1151 * <br>2.Incorrect parameters types. 1152 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1153 * @atomicservice 1154 * @since 11 1155 */ 1156 function insertData(options: Options, data: UnifiedData, callback: AsyncCallback<string>): void; 1157 1158 /** 1159 * Insert data into unified data channel by Intention 1160 * 1161 * @param { Options } options - fill the intention field to indicate the target {@link Intention}. 1162 * @param { UnifiedData } data - {@link UnifiedData} data object to insert into target intention. 1163 * @returns { Promise<string> } {string}: the unique identifier. 1164 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 1165 * <br>2.Incorrect parameters types. 1166 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1167 * @since 10 1168 */ 1169 /** 1170 * Insert data into unified data channel by Intention 1171 * 1172 * @param { Options } options - fill the intention field to indicate the target {@link Intention}. 1173 * @param { UnifiedData } data - {@link UnifiedData} data object to insert into target intention. 1174 * @returns { Promise<string> } {string}: the unique identifier. 1175 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 1176 * <br>2.Incorrect parameters types. 1177 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1178 * @atomicservice 1179 * @since 11 1180 */ 1181 function insertData(options: Options, data: UnifiedData): Promise<string>; 1182 1183 /** 1184 * Update data to unified data channel by Unique Identifier 1185 * 1186 * @param { Options } options - fill the unique identifier field to indicate the target {@link UnifiedData}. 1187 * @param { UnifiedData } data - {@link UnifiedData} data object to update the target data. 1188 * @param { AsyncCallback<void> } callback - the callback of updateData. 1189 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 1190 * <br>2.Incorrect parameters types. 1191 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1192 * @since 10 1193 */ 1194 /** 1195 * Update data to unified data channel by Unique Identifier 1196 * 1197 * @param { Options } options - fill the unique identifier field to indicate the target {@link UnifiedData}. 1198 * @param { UnifiedData } data - {@link UnifiedData} data object to update the target data. 1199 * @param { AsyncCallback<void> } callback - the callback of updateData. 1200 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 1201 * <br>2.Incorrect parameters types. 1202 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1203 * @atomicservice 1204 * @since 11 1205 */ 1206 function updateData(options: Options, data: UnifiedData, callback: AsyncCallback<void>): void; 1207 1208 /** 1209 * Update data to unified data channel by Unique Identifier 1210 * 1211 * @param { Options } options - fill the unique identifier field to indicate the target {@link UnifiedData}. 1212 * @param { UnifiedData } data - {@link UnifiedData} data object to update the target data. 1213 * @returns { Promise<void> } the promise returned by the function. 1214 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 1215 * <br>2.Incorrect parameters types. 1216 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1217 * @since 10 1218 */ 1219 /** 1220 * Update data to unified data channel by Unique Identifier 1221 * 1222 * @param { Options } options - fill the unique identifier field to indicate the target {@link UnifiedData}. 1223 * @param { UnifiedData } data - {@link UnifiedData} data object to update the target data. 1224 * @returns { Promise<void> } the promise returned by the function. 1225 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 1226 * <br>2.Incorrect parameters types. 1227 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1228 * @atomicservice 1229 * @since 11 1230 */ 1231 function updateData(options: Options, data: UnifiedData): Promise<void>; 1232 1233 /** 1234 * Query data of unified data channel by Intention or Unique Identifier 1235 * 1236 * @param { Options } options - fill the intention or unique identifier field to indicate the target {@link Intention} or {@link UnifiedData}. 1237 * @param { AsyncCallback<Array<UnifiedData>> } callback - {Array<UnifiedData>}: the target {@link UnifiedData} object array. 1238 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 1239 * <br>2.Incorrect parameters types. 1240 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1241 * @since 10 1242 */ 1243 /** 1244 * Query data of unified data channel by Intention or Unique Identifier 1245 * 1246 * @param { Options } options - fill the intention or unique identifier field to indicate the target {@link Intention} or {@link UnifiedData}. 1247 * @param { AsyncCallback<Array<UnifiedData>> } callback - {Array<UnifiedData>}: the target {@link UnifiedData} object array. 1248 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 1249 * <br>2.Incorrect parameters types. 1250 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1251 * @atomicservice 1252 * @since 11 1253 */ 1254 function queryData(options: Options, callback: AsyncCallback<Array<UnifiedData>>): void; 1255 1256 /** 1257 * Query data of unified data channel by Intention or Unique Identifier 1258 * 1259 * @param { Options } options - fill the intention or unique identifier field to indicate the target {@link Intention} or {@link UnifiedData}. 1260 * @returns { Promise<Array<UnifiedData>> } {Array<UnifiedData>}: the target {@link UnifiedData} object array. 1261 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 1262 * <br>2.Incorrect parameters types. 1263 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1264 * @since 10 1265 */ 1266 /** 1267 * Query data of unified data channel by Intention or Unique Identifier 1268 * 1269 * @param { Options } options - fill the intention or unique identifier field to indicate the target {@link Intention} or {@link UnifiedData}. 1270 * @returns { Promise<Array<UnifiedData>> } {Array<UnifiedData>}: the target {@link UnifiedData} object array. 1271 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 1272 * <br>2.Incorrect parameters types. 1273 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1274 * @atomicservice 1275 * @since 11 1276 */ 1277 function queryData(options: Options): Promise<Array<UnifiedData>>; 1278 1279 /** 1280 * Delete data of unified data channel by Intention or Unique Identifier 1281 * 1282 * @param { Options } options - fill the intention or unique identifier field to indicate the target {@link Intention} or {@link UnifiedData}. 1283 * @param { AsyncCallback<Array<UnifiedData>> } callback - {Array<UnifiedData>}: the deleted {@link UnifiedData} object array. 1284 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 1285 * <br>2.Incorrect parameters types. 1286 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1287 * @since 10 1288 */ 1289 /** 1290 * Delete data of unified data channel by Intention or Unique Identifier 1291 * 1292 * @param { Options } options - fill the intention or unique identifier field to indicate the target {@link Intention} or {@link UnifiedData}. 1293 * @param { AsyncCallback<Array<UnifiedData>> } callback - {Array<UnifiedData>}: the deleted {@link UnifiedData} object array. 1294 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 1295 * <br>2.Incorrect parameters types. 1296 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1297 * @atomicservice 1298 * @since 11 1299 */ 1300 function deleteData(options: Options, callback: AsyncCallback<Array<UnifiedData>>): void; 1301 1302 /** 1303 * Delete data of unified data channel by Intention or Unique Identifier 1304 * 1305 * @param { Options } options - fill the intention or unique identifier field to indicate the target {@link Intention} or {@link UnifiedData}. 1306 * @returns { Promise<Array<UnifiedData>> } {Array<UnifiedData>}: the deleted {@link UnifiedData} object array. 1307 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 1308 * <br>2.Incorrect parameters types. 1309 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1310 * @since 10 1311 */ 1312 /** 1313 * Delete data of unified data channel by Intention or Unique Identifier 1314 * 1315 * @param { Options } options - fill the intention or unique identifier field to indicate the target {@link Intention} or {@link UnifiedData}. 1316 * @returns { Promise<Array<UnifiedData>> } {Array<UnifiedData>}: the deleted {@link UnifiedData} object array. 1317 * @throws { BusinessError } 401 - Parameter error. Possible causes:1.Mandatory parameters are left unspecified; 1318 * <br>2.Incorrect parameters types. 1319 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1320 * @atomicservice 1321 * @since 11 1322 */ 1323 function deleteData(options: Options): Promise<Array<UnifiedData>>; 1324 1325 /** 1326 * Set app sharing options. 1327 * 1328 * @param { Intention } intention - Describe the sharing channel that UDMF support. 1329 * @param { ShareOptions } shareOptions - Types of scope that UnifiedData can be used. 1330 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1331 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1332 * 2. Incorrect parameter types. 1333 * @throws { BusinessError } 20400001 - Settings already exist. 1334 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1335 * @systemapi 1336 * @StageModelOnly 1337 * @since 12 1338 */ 1339 function setAppShareOptions(intention: Intention, shareOptions: ShareOptions): void; 1340 1341 /** 1342 * Remove app sharing options. 1343 * 1344 * @param { Intention } intention - Describe the sharing channel that UDMF support. 1345 * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application uses system API. 1346 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 1347 * 2. Incorrect parameter types. 1348 * @syscap SystemCapability.DistributedDataManager.UDMF.Core 1349 * @systemapi 1350 * @StageModelOnly 1351 * @since 12 1352 */ 1353 function removeAppShareOptions(intention: Intention): void; 1354} 1355 1356export default unifiedDataChannel; 1357