• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 } 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 */
36declare namespace dataShare {
37  /**
38   * Manages create datashare helper options.
39   *
40   * @interface DataShareHelperOptions
41   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
42   * @systemapi
43   * @stagemodelonly
44   * @since 10
45   */
46  interface DataShareHelperOptions {
47    /**
48     * Specifies whether the {@link DataShareHelper} in proxy mode.
49     * If value is true, the {@link DataShareHelper} to be created is in proxy mode, and all operations will not open provider APP as possible
50     *
51     * @default false
52     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
53     * @systemapi
54     * @stagemodelonly
55     * @since 10
56     */
57    isProxy?: boolean;
58  }
59
60  /**
61   * Obtains the dataShareHelper.
62   *
63   * @param { Context } context - Indicates the application context.
64   * @param { string } uri - Indicates the path of the file to open.
65   * @param { AsyncCallback<DataShareHelper> } callback - {DataShareHelper}: The dataShareHelper for consumer.
66   * @throws { BusinessError } 401 - Parameter error.
67   * @throws { BusinessError } 15700010 - The DataShareHelper is not initialized successfully.
68   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
69   * @systemapi
70   * @stagemodelonly
71   * @since 9
72   */
73  function createDataShareHelper(context: Context, uri: string, callback: AsyncCallback<DataShareHelper>): void;
74  /**
75   * Obtains the dataShareHelper.
76   *
77   * @param { Context } context - Indicates the application context.
78   * @param { string } uri - Indicates the path of the file to open.
79   * @param { DataShareHelperOptions } options - Indicates the optional config.
80   * @param { AsyncCallback<DataShareHelper> } callback - {DataShareHelper}: The dataShareHelper for consumer.
81   * @throws { BusinessError } 401 - Parameter error.
82   * @throws { BusinessError } 15700010 - The DataShareHelper is not initialized successfully.
83   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
84   * @systemapi
85   * @stagemodelonly
86   * @since 10
87   */
88  function createDataShareHelper(
89    context: Context,
90    uri: string,
91    options: DataShareHelperOptions,
92    callback: AsyncCallback<DataShareHelper>
93  ): void;
94
95  /**
96   * Obtains the dataShareHelper.
97   *
98   * @param { Context } context - Indicates the application context.
99   * @param { string } uri - Indicates the path of the file to open.
100   * @returns { Promise<DataShareHelper> } {DataShareHelper}: The dataShareHelper for consumer.
101   * @throws { BusinessError } 401 - Parameter error.
102   * @throws { BusinessError } 15700010 - The DataShareHelper is not initialized successfully.
103   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
104   * @systemapi
105   * @stagemodelonly
106   * @since 9
107   */
108  /**
109   * Obtains the dataShareHelper.
110   *
111   * @param { Context } context - Indicates the application context.
112   * @param { string } uri - Indicates the path of the file to open.
113   * @param { DataShareHelperOptions } options - Indicates the optional config.
114   * @returns { Promise<DataShareHelper> } {DataShareHelper}: The dataShareHelper for consumer.
115   * @throws { BusinessError } 401 - Parameter error.
116   * @throws { BusinessError } 15700010 - The DataShareHelper is not initialized successfully.
117   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
118   * @systemapi
119   * @stagemodelonly
120   * @since 10
121   */
122  function createDataShareHelper(
123    context: Context,
124    uri: string,
125    options?: DataShareHelperOptions
126  ): Promise<DataShareHelper>;
127
128  /**
129   * Enables silent access dynamically.
130   *
131   * @param { Context } context - Indicates the application context.
132   * @param { string } uri - Indicates the uri of the data share silent proxy resource.
133   * @returns { Promise<void> } The promise returned by the function.
134   * @throws { BusinessError } 401 - Parameter error.
135   * @throws { BusinessError } 15700011 - The uri is not exist.
136   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
137   * @systemapi
138   * @stagemodelonly
139   * @since 11
140   */
141  function enableSilentProxy(context: Context, uri?: string): Promise<void>;
142
143  /**
144   * Disables silent access dynamically.
145   *
146   * @param { Context } context - Indicates the application context.
147   * @param { string } uri - Indicates the uri of the data share silent proxy resource.
148   * @returns { Promise<void> } The promise returned by the function.
149   * @throws { BusinessError } 401 - Parameter error.
150   * @throws { BusinessError } 15700011 - The uri is not exist.
151   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
152   * @systemapi
153   * @stagemodelonly
154   * @since 11
155   */
156  function disableSilentProxy(context: Context, uri?: string): Promise<void>;
157
158  /**
159   * Specifies the {@link Template} id structure.
160   * A template is marked by the template id. Note that the template id is auto generated in {@link DataShareHelper#addTemplate}.
161   * After {@link DataShareHelper#addTemplate}, can use the template id to direct a template.
162   *
163   * @interface TemplateId
164   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
165   * @systemapi
166   * @stagemodelonly
167   * @since 10
168   */
169  interface TemplateId {
170    /**
171     * Specifies the id of subscriber, who process the callback
172     * Same as subscriberId in {@link DataShareHelper#addTemplate}
173     *
174     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
175     * @systemapi
176     * @stagemodelonly
177     * @since 10
178     */
179    subscriberId: string;
180    /**
181     * Specifies the bundleName of template owner, who create the template
182     * Same as the caller's bundleName of {@link DataShareHelper#addTemplate}
183     *
184     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
185     * @systemapi
186     * @stagemodelonly
187     * @since 10
188     */
189    bundleNameOfOwner: string;
190  }
191
192  /**
193   * Specifies the published item structure.
194   *
195   * @interface PublishedItem
196   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
197   * @systemapi
198   * @stagemodelonly
199   * @since 10
200   */
201  interface PublishedItem {
202    /**
203     * Specifies the key of the published data
204     *
205     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
206     * @systemapi
207     * @stagemodelonly
208     * @since 10
209     */
210    key: string;
211    /**
212     * Specifies the published data
213     * If the data is large, use ArrayBuffer.
214     *
215     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
216     * @systemapi
217     * @stagemodelonly
218     * @since 10
219     */
220    data: string | ArrayBuffer;
221    /**
222     * Specifies the subscriber id
223     *
224     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
225     * @systemapi
226     * @stagemodelonly
227     * @since 10
228     */
229    subscriberId: string;
230  }
231
232  /**
233   * Specifies the change node structure of rdb store data in callback.
234   *
235   * @interface RdbDataChangeNode
236   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
237   * @systemapi
238   * @stagemodelonly
239   * @since 10
240   */
241  interface RdbDataChangeNode {
242    /**
243     * Specifies the uri of the callback.
244     *
245     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
246     * @systemapi
247     * @stagemodelonly
248     * @since 10
249     */
250    uri: string;
251    /**
252     * Specifies the templateId of the callback.
253     *
254     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
255     * @systemapi
256     * @stagemodelonly
257     * @since 10
258     */
259    templateId: TemplateId;
260    /**
261     * Specifies the datas of the callback.
262     * every node is a json, json's key is [key of {@link Template#predicates}
263     * and value is the query result from rdb store query by value of{@link Template#predicates}].
264     *
265     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
266     * @systemapi
267     * @stagemodelonly
268     * @since 10
269     */
270    data: Array<string>;
271  }
272
273  /**
274   * Specifies the change node structure of published data in callback.
275   *
276   * @interface PublishedDataChangeNode
277   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
278   * @systemapi
279   * @stagemodelonly
280   * @since 10
281   */
282  interface PublishedDataChangeNode {
283    /**
284     * Specifies the bundleName of the callback.
285     *
286     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
287     * @systemapi
288     * @stagemodelonly
289     * @since 10
290     */
291    bundleName: string;
292    /**
293     * Specifies the datas of the callback.
294     *
295     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
296     * @systemapi
297     * @stagemodelonly
298     * @since 10
299     */
300    data: Array<PublishedItem>;
301  }
302
303  /**
304   * Specifies the template structure in subscribe.
305   *
306   * @interface Template
307   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
308   * @systemapi
309   * @stagemodelonly
310   * @since 10
311   */
312  interface Template {
313    /**
314     * Specifies the predicates of the template.
315     * When the callback in {@link DataShareHelper#on(string, Array<string>, TemplateId, AsyncCallback<ChangeNode>)}
316     * is called, the predicates is used to generate data in {@link ChangeNode}. Only for rdb store data.
317     *
318     * @type { [key: string]: string }
319     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
320     * @systemapi
321     * @stagemodelonly
322     * @since 10
323     */
324    /**
325     * Specifies the predicates of the template.
326     * When the callback in {@link DataShareHelper#on(string, Array<string>, TemplateId, AsyncCallback<ChangeNode>)}
327     * is called, the predicates is used to generate data in {@link ChangeNode}. Only for rdb store data.
328     *
329     * @type { Record<string, string> }
330     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
331     * @systemapi
332     * @stagemodelonly
333     * @since 11
334     */
335    predicates: Record<string, string>;
336
337    /**
338     * Specifies the scheduler sql of the template.
339     * When modify the subscribed uri's data, scheduler is auto called.
340     *
341     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
342     * @systemapi
343     * @stagemodelonly
344     * @since 10
345     */
346    scheduler: string;
347  }
348  /**
349   * Specifies the operation result structure.
350   *
351   * @interface OperationResult
352   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
353   * @systemapi
354   * @stagemodelonly
355   * @since 10
356   */
357  interface OperationResult {
358    /**
359     * Specifies the key of the operation result.
360     *
361     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
362     * @systemapi
363     * @stagemodelonly
364     * @since 10
365     */
366    key: string;
367
368    /**
369     * Specifies the operation result.
370     *
371     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
372     * @systemapi
373     * @stagemodelonly
374     * @since 10
375     */
376    result: number;
377  }
378
379  /**
380   * DataShareHelper
381   *
382   * @interface DataShareHelper
383   * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
384   * @systemapi
385   * @stagemodelonly
386   * @since 9
387   */
388  interface DataShareHelper {
389    /**
390     * Registers an observer to observe data specified by the given uri.
391     *
392     * @param { 'dataChange' } type - Type must be 'dataChange'.
393     * @param { string } uri - Indicates the path of the data to operate.
394     * @param { AsyncCallback<void> } callback - The callback of on.
395     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
396     * @systemapi
397     * @stagemodelonly
398     * @since 9
399     */
400    on(type: 'dataChange', uri: string, callback: AsyncCallback<void>): void;
401
402    /**
403     * Deregisters an observer used for monitoring data specified by the given uri.
404     *
405     * @param { 'dataChange' } type - Type must be 'dataChange'.
406     * @param { string } uri - Indicates the path of the data to operate.
407     * @param { AsyncCallback<void> } callback - The callback of off.
408     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
409     * @systemapi
410     * @stagemodelonly
411     * @since 9
412     */
413    off(type: 'dataChange', uri: string, callback?: AsyncCallback<void>): void;
414
415    /**
416     * Adds a template of {@link #on(string, Array<string>, TemplateId, AsyncCallback<ChangeNode>)}.
417     *
418     * @param { string } uri - Indicates the uri to add.
419     * @param { string } subscriberId - The subscribe id to add..
420     * @param { Template } template - The template to add.
421     * @throws { BusinessError } 401 - Parameter error.
422     * @throws { BusinessError } 15700011 - The uri is not exist.
423     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
424     * @systemapi
425     * @stagemodelonly
426     * @since 10
427     */
428    addTemplate(uri: string, subscriberId: string, template: Template): void;
429
430    /**
431     * Deletes a template of {@link #on(string, Array<string>, TemplateId, AsyncCallback<ChangeNode>)}.
432     *
433     * @param { string } uri - Indicates the uri to delete.
434     * @param { string } subscriberId - The subscribe id.
435     * @throws { BusinessError } 401 - Parameter error.
436     * @throws { BusinessError } 15700011 - The uri is not exist.
437     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
438     * @systemapi
439     * @stagemodelonly
440     * @since 10
441     */
442    delTemplate(uri: string, subscriberId: string): void;
443
444    /**
445     * Registers observers to observe rdb data specified by the given uri and template.
446     *
447     * @param { 'rdbDataChange' } type - Type must be 'rdbDataChange'.
448     * @param { Array<string> } uris - Indicates the paths of the data to operate.
449     * @param { TemplateId } templateId - The template of on.
450     * @param { AsyncCallback<RdbDataChangeNode> } callback - The callback of on.
451     * @returns { Array<OperationResult> } : The operation result.
452     * @throws { BusinessError } 401 - Parameter error.
453     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
454     * @systemapi
455     * @stagemodelonly
456     * @since 10
457     */
458    on(
459      type: 'rdbDataChange',
460      uris: Array<string>,
461      templateId: TemplateId,
462      callback: AsyncCallback<RdbDataChangeNode>
463    ): Array<OperationResult>;
464
465    /**
466     * Deregisters observers used for monitoring data specified by the given uri and template.
467     *
468     * @param { 'rdbDataChange' } type - Type must be 'rdbDataChange'.
469     * @param { Array<string> } uris - Indicates the paths of the data to operate.
470     * @param { TemplateId } templateId - The template of off.
471     * @param { AsyncCallback<RdbDataChangeNode> } callback - The callback of off.
472     * @returns { Array<OperationResult> } : The operation result.
473     * @throws { BusinessError } 401 - Parameter error.
474     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
475     * @systemapi
476     * @stagemodelonly
477     * @since 10
478     */
479    off(
480      type: 'rdbDataChange',
481      uris: Array<string>,
482      templateId: TemplateId,
483      callback?: AsyncCallback<RdbDataChangeNode>
484    ): Array<OperationResult>;
485
486    /**
487     * Registers observers to observe published data specified by the given key and subscriberId.
488     *
489     * @param { 'publishedDataChange' } type - Type must be 'publishedDataChange'.
490     * @param { Array<string> } uris - Indicates the uris of the data to operate.
491     * @param { string } subscriberId - The subscriberId of on.
492     * @param { AsyncCallback<PublishedDataChangeNode> } callback - The callback of on.
493     * @returns { Array<OperationResult> } : The operation result.
494     * @throws { BusinessError } 401 - Parameter error.
495     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
496     * @systemapi
497     * @stagemodelonly
498     * @since 10
499     */
500    on(
501      type: 'publishedDataChange',
502      uris: Array<string>,
503      subscriberId: string,
504      callback: AsyncCallback<PublishedDataChangeNode>
505    ): Array<OperationResult>;
506
507    /**
508     * Deregisters observers used for monitoring data specified by the given key and subscriberId.
509     *
510     * @param { 'publishedDataChange' } type - Type must be 'publishedDataChange'.
511     * @param { Array<string> } uris - Indicates the uris of the data to operate.
512     * @param { string } subscriberId - The subscriberId of off.
513     * @param { AsyncCallback<PublishedDataChangeNode> } callback - The callback of off.
514     * @returns { Array<OperationResult> } : The operation result.
515     * @throws { BusinessError } 401 - Parameter error.
516     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
517     * @systemapi
518     * @stagemodelonly
519     * @since 10
520     */
521    off(
522      type: 'publishedDataChange',
523      uris: Array<string>,
524      subscriberId: string,
525      callback?: AsyncCallback<PublishedDataChangeNode>
526    ): Array<OperationResult>;
527
528    /**
529     * Update a single data into host data area.
530     *
531     * @param { Array<PublishedItem> } data - Indicates the data to publish.
532     * @param { string } bundleName - Indicates the bundleName of data to publish.
533     * @param { number } version - Indicates the version of data to publish, larger is newer.
534     * @param { AsyncCallback<Array<OperationResult>> } callback
535     * @throws { BusinessError } 401 - Parameter error.
536     * @throws { BusinessError } 15700012 - The data area is not exist.
537     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
538     * @systemapi
539     * @stagemodelonly
540     * @since 10
541     */
542    publish(
543      data: Array<PublishedItem>,
544      bundleName: string,
545      version: number,
546      callback: AsyncCallback<Array<OperationResult>>
547    ): void;
548
549    /**
550     * Update a single data into host data area.
551     *
552     * @param { Array<PublishedItem> } data - Indicates the data to publish.
553     * @param { string } bundleName - Indicates the bundleName of data to publish.
554     * @param { AsyncCallback<Array<OperationResult>> } callback
555     * @throws { BusinessError } 401 - Parameter error.
556     * @throws { BusinessError } 15700012 - The data area is not exist.
557     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
558     * @systemapi
559     * @stagemodelonly
560     * @since 10
561     */
562    publish(
563      data: Array<PublishedItem>,
564      bundleName: string,
565      callback: AsyncCallback<Array<OperationResult>>
566    ): void;
567
568    /**
569     * Update a single data into host data area.
570     *
571     * @param { Array<PublishedItem> } data - Indicates the data to publish.
572     * @param { string } bundleName - Indicates the bundleName of data to publish.
573     * @param { number } version - Indicates the version of data to publish, larger is newer.
574     * @returns { Promise<Array<OperationResult>> }
575     * @throws { BusinessError } 401 - Parameter error.
576     * @throws { BusinessError } 15700012 - The data area is not exist.
577     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
578     * @systemapi
579     * @stagemodelonly
580     * @since 10
581     */
582    publish(data: Array<PublishedItem>, bundleName: string, version?: number): Promise<Array<OperationResult>>;
583
584    /**
585     * Registers a one-time observer to observe data specified by the given uri and template.
586     *
587     * @param { string } bundleName - Indicates the bundleName of data to publish.
588     * @param { AsyncCallback<Array<PublishedItem>> } callback
589     * @throws { BusinessError } 401 - Parameter error.
590     * @throws { BusinessError } 15700012 - The data area is not exist.
591     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
592     * @systemapi
593     * @stagemodelonly
594     * @since 10
595     */
596    getPublishedData(bundleName: string, callback: AsyncCallback<Array<PublishedItem>>): void;
597
598    /**
599     * Registers a one-time observer to observe data specified by the given uri and template.
600     *
601     * @param { string } bundleName - Indicates the bundleName of data to publish.
602     * @returns { Promise<Array<PublishedItem>> }
603     * @throws { BusinessError } 401 - Parameter error.
604     * @throws { BusinessError } 15700012 - The data area is not exist.
605     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
606     * @systemapi
607     * @stagemodelonly
608     * @since 10
609     */
610    getPublishedData(bundleName: string): Promise<Array<PublishedItem>>;
611
612    /**
613     * Inserts a single data record into the database.
614     *
615     * @param { string } uri - Indicates the path of the data to operate.
616     * @param { ValuesBucket } value - Indicates the data record to insert. If this parameter is null,
617     * a blank row will be inserted.
618     * @param { AsyncCallback<number> } callback - {number}: the index of the inserted data record.
619     * @throws { BusinessError } 401 - Parameter error.
620     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
621     * @systemapi
622     * @stagemodelonly
623     * @since 9
624     */
625    insert(uri: string, value: ValuesBucket, callback: AsyncCallback<number>): void;
626
627    /**
628     * Inserts a single data record into the database.
629     *
630     * @param { string } uri - Indicates the path of the data to operate.
631     * @param { ValuesBucket } value - Indicates the data record to insert. If this parameter is null,
632     * a blank row will be inserted.
633     * @returns { Promise<number> } {number}: the index of the inserted data record.
634     * @throws { BusinessError } 401 - Parameter error.
635     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
636     * @systemapi
637     * @stagemodelonly
638     * @since 9
639     */
640    insert(uri: string, value: ValuesBucket): Promise<number>;
641
642    /**
643     * Deletes one or more data records from the database.
644     *
645     * @param { string } uri - Indicates the path of the data to operate.
646     * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria.
647     * You should define the processing logic when this parameter is null.
648     * @param { AsyncCallback<number> } callback - {number}: the number of data records deleted.
649     * @throws { BusinessError } 401 - Parameter error.
650     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
651     * @systemapi
652     * @stagemodelonly
653     * @since 9
654     */
655    delete(uri: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback<number>): void;
656
657    /**
658     * Deletes one or more data records from the database.
659     *
660     * @param { string } uri - Indicates the path of the data to operate.
661     * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria.
662     * You should define the processing logic when this parameter is null.
663     * @returns { Promise<number> } {number}: the number of data records deleted.
664     * @throws { BusinessError } 401 - Parameter error.
665     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
666     * @systemapi
667     * @stagemodelonly
668     * @since 9
669     */
670    delete(uri: string, predicates: dataSharePredicates.DataSharePredicates): Promise<number>;
671
672    /**
673     * Queries data in the database.
674     *
675     * @param { string } uri - Indicates the path of data to query.
676     * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria.
677     * You should define the processing logic when this parameter is null.
678     * @param { Array<string> } columns - Indicates the columns to query.
679     * If this parameter is null, all columns are queried.
680     * @param { AsyncCallback<DataShareResultSet> } callback - {DataShareResultSet}: the query result.
681     * @throws { BusinessError } 401 - Parameter error.
682     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
683     * @systemapi
684     * @stagemodelonly
685     * @since 9
686     */
687    query(
688      uri: string,
689      predicates: dataSharePredicates.DataSharePredicates,
690      columns: Array<string>,
691      callback: AsyncCallback<DataShareResultSet>
692    ): void;
693
694    /**
695     * Queries data in the database.
696     *
697     * @param { string } uri - Indicates the path of data to query.
698     * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria.
699     * You should define the processing logic when this parameter is null.
700     * @param { Array<string> } columns - Indicates the columns to query.
701     * If this parameter is null, all columns are queried.
702     * @returns { Promise<DataShareResultSet> } {DataShareResultSet}: the query result.
703     * @throws { BusinessError } 401 - Parameter error.
704     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
705     * @systemapi
706     * @stagemodelonly
707     * @since 9
708     */
709    query(
710      uri: string,
711      predicates: dataSharePredicates.DataSharePredicates,
712      columns: Array<string>
713    ): Promise<DataShareResultSet>;
714
715    /**
716     * Updates data records in the database.
717     *
718     * @param { string } uri - Indicates the path of data to update.
719     * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria.
720     * You should define the processing logic when this parameter is null.
721     * @param { ValuesBucket } value - Indicates the data to update. This parameter can be null.
722     * @param { AsyncCallback<number> } callback - {number}: the number of data records updated.
723     * @throws { BusinessError } 401 - Parameter error.
724     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
725     * @systemapi
726     * @stagemodelonly
727     * @since 9
728     */
729    update(
730      uri: string,
731      predicates: dataSharePredicates.DataSharePredicates,
732      value: ValuesBucket,
733      callback: AsyncCallback<number>
734    ): void;
735
736    /**
737     * Updates data records in the database.
738     *
739     * @param { string } uri - Indicates the path of data to update.
740     * @param { dataSharePredicates.DataSharePredicates } predicates - Indicates filter criteria.
741     * You should define the processing logic when this parameter is null.
742     * @param { ValuesBucket } value - Indicates the data to update. This parameter can be null.
743     * @returns { Promise<number> } {number}: the number of data records updated.
744     * @throws { BusinessError } 401 - Parameter error.
745     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
746     * @systemapi
747     * @stagemodelonly
748     * @since 9
749     */
750    update(uri: string, predicates: dataSharePredicates.DataSharePredicates, value: ValuesBucket): Promise<number>;
751
752    /**
753     * Inserts multiple data records into the database.
754     *
755     * @param { string } uri - Indicates the path of the data to operate.
756     * @param { Array<ValuesBucket> } values - Indicates the data records to insert.
757     * @param { AsyncCallback<number> } callback - {number}: the number of data records inserted.
758     * @throws { BusinessError } 401 - Parameter error.
759     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
760     * @systemapi
761     * @stagemodelonly
762     * @since 9
763     */
764    batchInsert(uri: string, values: Array<ValuesBucket>, callback: AsyncCallback<number>): void;
765
766    /**
767     * Inserts multiple data records into the database.
768     *
769     * @param { string } uri - Indicates the path of the data to operate.
770     * @param { Array<ValuesBucket> } values - Indicates the data records to insert.
771     * @returns { Promise<number> } {number}: the number of data records inserted.
772     * @throws { BusinessError } 401 - Parameter error.
773     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
774     * @systemapi
775     * @stagemodelonly
776     * @since 9
777     */
778    batchInsert(uri: string, values: Array<ValuesBucket>): Promise<number>;
779
780    /**
781     * Converts the given {@code uri} that refers to the DataShare into a normalized {@link ohos.utils.net.Uri}.
782     * A normalized uri can be used across devices, persisted, backed up, and restored.
783     * <p>To transfer a normalized uri from another environment to the current environment, you should call this
784     * method again to re-normalize the uri for the current environment or call {@link #denormalizeUri(Uri)}
785     * to convert it to a denormalized uri that can be used only in the current environment.
786     *
787     * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to normalize.
788     * @param { AsyncCallback<string> } callback - {string}: the normalized Uri,
789     * if the DataShare supports uri normalization.
790     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
791     * @systemapi
792     * @stagemodelonly
793     * @since 9
794     */
795    normalizeUri(uri: string, callback: AsyncCallback<string>): void;
796
797    /**
798     * Converts the given {@code uri} that refers to the DataShare into a normalized {@link ohos.utils.net.Uri}.
799     * A normalized uri can be used across devices, persisted, backed up, and restored.
800     * <p>To transfer a normalized uri from another environment to the current environment, you should call this
801     * method again to re-normalize the uri for the current environment or call {@link #denormalizeUri(Uri)}
802     * to convert it to a denormalized uri that can be used only in the current environment.
803     *
804     * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to normalize.
805     * @returns { Promise<string> } {string}: the normalized Uri if the DataShare supports uri normalization;
806     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
807     * @systemapi
808     * @stagemodelonly
809     * @since 9
810     */
811    normalizeUri(uri: string): Promise<string>;
812
813    /**
814     * Converts the given normalized {@code uri} generated by {@link #normalizeUri(Uri)} into a denormalized one.
815     *
816     * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to denormalize.
817     * @param { AsyncCallback<string> } callback - {string}: the denormalized {@code Uri} object if
818     * the denormalization is successful; returns the original {@code Uri} passed to this method if
819     * there is nothing to do; returns {@code null} if the data identified by the normalized {@code Uri}
820     * cannot be found in the current environment.
821     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
822     * @systemapi
823     * @stagemodelonly
824     * @since 9
825     */
826    denormalizeUri(uri: string, callback: AsyncCallback<string>): void;
827
828    /**
829     * Converts the given normalized {@code uri} generated by {@link #normalizeUri(Uri)} into a denormalized one.
830     *
831     * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to denormalize.
832     * @returns { Promise<string> } {string}: the denormalized {@code Uri} object if the denormalization
833     * is successful; returns the original {@code Uri} passed to this method if there is nothing to do;
834     * returns {@code null} if the data identified by the normalized {@code Uri} cannot be found in the
835     * current environment.
836     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
837     * @systemapi
838     * @stagemodelonly
839     * @since 9
840     */
841    denormalizeUri(uri: string): Promise<string>;
842
843    /**
844     * Notifies the registered observers of a change to the data resource specified by Uri.
845     *
846     * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to notifyChange.
847     * @param { AsyncCallback<void> } callback - The callback of notifyChange.
848     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
849     * @systemapi
850     * @stagemodelonly
851     * @since 9
852     */
853    notifyChange(uri: string, callback: AsyncCallback<void>): void;
854
855    /**
856     * Notifies the registered observers of a change to the data resource specified by Uri.
857     *
858     * @param { string } uri - Indicates the {@link ohos.utils.net.Uri} object to notifyChange.
859     * @returns { Promise<void> } The promise returned by the function.
860     * @syscap SystemCapability.DistributedDataManager.DataShare.Consumer
861     * @systemapi
862     * @stagemodelonly
863     * @since 9
864     */
865    notifyChange(uri: string): Promise<void>;
866  }
867}
868
869export default dataShare;
870