• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 type rpc from './@ohos.rpc';
22import type cloudData from './@ohos.data.cloudData';
23import type relationalStore from './@ohos.data.relationalStore';
24
25/**
26 * Provides interfaces to implement extended cloud capabilities.
27 *
28 * @namespace cloudExtension
29 * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
30 * @since 11
31 */
32declare namespace cloudExtension {
33  /**
34   * Provides interface for managing cloud assets.
35   *
36   * @interface CloudAsset
37   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
38   * @systemapi
39   * @since 11
40   */
41  export interface CloudAsset extends relationalStore.Asset {
42    /**
43     * Asset ID.
44     *
45     * @type { string }
46     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
47     * @systemapi
48     * @since 11
49     */
50    assetId: string;
51
52    /**
53     * Asset hash value.
54     *
55     * @type { string }
56     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
57     * @systemapi
58     * @since 11
59     */
60    hash: string;
61  }
62
63  /**
64   * Indicates cloud assets in one column.
65   *
66   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
67   * @systemapi
68   * @since 11
69   */
70  type CloudAssets = Array<CloudAsset>;
71
72  /**
73   * Indicates possible cloud types.
74   *
75   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
76   * @systemapi
77   * @since 11
78   */
79  type CloudType = null | number | string | boolean | Uint8Array | CloudAsset | CloudAssets;
80
81  /**
82   * Defines cloud information.
83   *
84   * @interface CloudInfo
85   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
86   * @systemapi
87   * @since 11
88   */
89  export interface CloudInfo {
90    /**
91     * Cloud information. For details, see {@link ServiceInfo}.
92     *
93     * @type { ServiceInfo }
94     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
95     * @systemapi
96     * @since 11
97     */
98    cloudInfo: ServiceInfo;
99
100    /**
101     * Defines brief application information.
102     *
103     * @type { Record<string, AppBriefInfo> }
104     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
105     * @systemapi
106     * @since 11
107     */
108    apps: Record<string, AppBriefInfo>;
109  }
110
111  /**
112   * Defines cloud service information.
113   *
114   * @interface ServiceInfo
115   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
116   * @systemapi
117   * @since 11
118   */
119  export interface ServiceInfo {
120    /**
121     * Whether cloud is enabled. The value <b>true</b> means cloud is enabled;
122     * the value <b>false</b> means the opposite.
123     *
124     * @type { boolean }
125     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
126     * @systemapi
127     * @since 11
128     */
129    enableCloud: boolean;
130
131    /**
132     * ID of the cloud account generated by using SHA-256.
133     *
134     * @type { string }
135     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
136     * @systemapi
137     * @since 11
138     */
139    id: string;
140
141    /**
142     * Total space (in KB) of the account on the server.
143     *
144     * @type { number }
145     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
146     * @systemapi
147     * @since 11
148     */
149    totalSpace: number;
150
151    /**
152     * Available space (in KB) of the account on the server.
153     *
154     * @type { number }
155     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
156     * @systemapi
157     * @since 11
158     */
159    remainingSpace: number;
160
161    /**
162     * Current user of the device.
163     *
164     * @type { number }
165     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
166     * @systemapi
167     * @since 11
168     */
169    user: number;
170  }
171
172  /**
173   * Defines the brief application information.
174   *
175   * @interface AppBriefInfo
176   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
177   * @systemapi
178   * @since 11
179   */
180  export interface AppBriefInfo {
181    /**
182     * ID of the application.
183     *
184     * @type { string }
185     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
186     * @systemapi
187     * @since 11
188     */
189    appId: string;
190
191    /**
192     * Bundle name.
193     *
194     * @type { string }
195     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
196     * @systemapi
197     * @since 11
198     */
199    bundleName: string;
200
201    /**
202     * Whether cloud is enabled for the application.
203     * The value <b>true</b> means the cloud is enabled; the <b>false</b> means
204     * the opposite.
205     *
206     * @type { boolean }
207     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
208     * @systemapi
209     * @since 11
210     */
211    cloudSwitch: boolean;
212
213    /**
214     * Application instance ID.
215     *
216     * @type { number }
217     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
218     * @systemapi
219     * @since 11
220     */
221    instanceId: number;
222  }
223
224  /**
225   * Enumerates the field types.
226   *
227   * @enum { number }
228   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
229   * @systemapi
230   * @since 11
231   */
232  export enum FieldType {
233    /**
234     * NULL.
235     *
236     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
237     * @systemapi
238     * @since 11
239     */
240    NULL = 0,
241
242    /**
243     * Number.
244     *
245     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
246     * @systemapi
247     * @since 11
248     */
249    NUMBER = 1,
250
251    /**
252     * Real.
253     *
254     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
255     * @systemapi
256     * @since 11
257     */
258    REAL = 2,
259
260    /**
261     * Text.
262     *
263     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
264     * @systemapi
265     * @since 11
266     */
267    TEXT = 3,
268
269    /**
270     * Boolean.
271     *
272     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
273     * @systemapi
274     * @since 11
275     */
276    BOOL = 4,
277
278    /**
279     * BLOB.
280     *
281     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
282     * @systemapi
283     * @since 11
284     */
285    BLOB = 5,
286
287    /**
288     * Asset. For details, see {@link relationalStore.Asset}.
289     *
290     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
291     * @systemapi
292     * @since 11
293     */
294    ASSET = 6,
295
296    /**
297     * Assets. For details, see {@link relationalStore.Assets}.
298     *
299     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
300     * @systemapi
301     * @since 11
302     */
303    ASSETS = 7
304  }
305
306  /**
307   * Defines the fields.
308   *
309   * @interface Field
310   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
311   * @systemapi
312   * @since 11
313   */
314  export interface Field {
315    /**
316     * Alias of the field on the server.
317     *
318     * @type { string }
319     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
320     * @systemapi
321     * @since 11
322     */
323    alias: string;
324
325    /**
326     * Column name.
327     *
328     * @type { string }
329     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
330     * @systemapi
331     * @since 11
332     */
333    colName: string;
334
335    /**
336     * Type of the field. For details, see {@link FieldType}.
337     *
338     * @type { FieldType }
339     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
340     * @systemapi
341     * @since 11
342     */
343    type: FieldType;
344
345    /**
346     * Whether the current column holds the primary key.
347     *
348     * @type { boolean }
349     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
350     * @systemapi
351     * @since 11
352     */
353    primary: boolean;
354
355    /**
356     * Whether the current column is nullable.
357     *
358     * @type { boolean }
359     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
360     * @systemapi
361     * @since 11
362     */
363    nullable: boolean;
364  }
365
366  /**
367   * Defines a table.
368   *
369   * @interface Table
370   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
371   * @systemapi
372   * @since 11
373   */
374  export interface Table {
375    /**
376     * Alias of the table on the server.
377     *
378     * @type { string }
379     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
380     * @systemapi
381     * @since 11
382     */
383    alias: string;
384
385    /**
386     * Name of the table.
387     *
388     * @type { string }
389     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
390     * @systemapi
391     * @since 11
392     */
393    name: string;
394
395    /**
396     * Fields in the table. For details, see {@link Field}.
397     *
398     * @type { Array<Field> }
399     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
400     * @systemapi
401     * @since 11
402     */
403    fields: Array<Field>;
404  }
405
406  /**
407   * Defines a database.
408   *
409   * @interface Database
410   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
411   * @systemapi
412   * @since 11
413   */
414  export interface Database {
415    /**
416     * Name of the database.
417     *
418     * @type { string }
419     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
420     * @systemapi
421     * @since 11
422     */
423    name: string;
424
425    /**
426     * Alias of the database on the server.
427     *
428     * @type { string }
429     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
430     * @systemapi
431     * @since 11
432     */
433    alias: string;
434
435    /**
436     * Tables in the database. For details, see {@link Table}.
437     *
438     * @type { Array<Table> }
439     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
440     * @systemapi
441     * @since 11
442     */
443    tables: Array<Table>;
444  }
445
446  /**
447   * Defines the application schema.
448   *
449   * @interface AppSchema
450   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
451   * @systemapi
452   * @since 11
453   */
454  export interface AppSchema {
455
456    /**
457     * Bundle name of the application.
458     *
459     * @type { string }
460     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
461     * @systemapi
462     * @since 11
463     */
464    bundleName: string;
465
466    /**
467     * Schema version.
468     *
469     * @type { number }
470     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
471     * @systemapi
472     * @since 11
473     */
474    version: number;
475
476    /**
477     * Databases {@link Database} of the application.
478     *
479     * @type { Array<Database> }
480     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
481     * @systemapi
482     * @since 11
483     */
484    databases: Array<Database>;
485  }
486
487  /**
488   * Defines the data in the cloud.
489   *
490   * @interface CloudData
491   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
492   * @systemapi
493   * @since 11
494   */
495  export interface CloudData {
496    /**
497     * Next cursor for query.
498     *
499     * @type { string }
500     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
501     * @systemapi
502     * @since 11
503     */
504    nextCursor: string;
505
506    /**
507     * Whether the server has more data to query {@link CloudDB.query()}.
508     *
509     * @type { boolean }
510     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
511     * @systemapi
512     * @since 11
513     */
514    hasMore: boolean;
515
516    /**
517     * Array of data queried, including the data values and extension
518     * values {@link ExtensionValue}.
519     *
520     * @type { Array<Record<string, CloudType>> }
521     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
522     * @systemapi
523     * @since 11
524     */
525    values: Array<Record<string, CloudType>>;
526  }
527
528  /**
529   * Defines the subscription information.
530   *
531   * @interface SubscribeInfo
532   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
533   * @systemapi
534   * @since 11
535   */
536  export interface SubscribeInfo {
537    /**
538     * Subscription expiration time, in milliseconds.
539     *
540     * @type { number }
541     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
542     * @systemapi
543     * @since 11
544     */
545    expirationTime: number;
546
547    /**
548     * Data to be observed.
549     *
550     * @type { Record<string, Array<SubscribeId>> }
551     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
552     * @systemapi
553     * @since 11
554     */
555    subscribe: Record<string, Array<SubscribeId>>;
556  }
557
558  /**
559   * Defines the subscription ID.
560   *
561   * @interface SubscribeId
562   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
563   * @systemapi
564   * @since 11
565   */
566  export interface SubscribeId {
567    /**
568     * Alias of the database on the server.
569     *
570     * @type { string }
571     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
572     * @systemapi
573     * @since 11
574     */
575    databaseAlias: string;
576
577    /**
578     * Subscription ID generated by {@link CloudService.subscribe()}.
579     *
580     * @type { string }
581     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
582     * @systemapi
583     * @since 11
584     */
585    id: string;
586  }
587
588  /**
589   * Enumerates the operations that can be performed on the database.
590   *
591   * @enum { number }
592   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
593   * @systemapi
594   * @since 11
595   */
596  export enum Flag {
597    /**
598     * Insert data.
599     *
600     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
601     * @systemapi
602     * @since 11
603     */
604    INSERT = 0,
605
606    /**
607     * Update data.
608     *
609     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
610     * @systemapi
611     * @since 11
612     */
613    UPDATE = 1,
614
615    /**
616     * Delete data.
617     *
618     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
619     * @systemapi
620     * @since 11
621     */
622    DELETE = 2
623  }
624
625  /**
626   * Defines the extension values.
627   *
628   * @interface ExtensionValue
629   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
630   * @systemapi
631   * @since 11
632   */
633  export interface ExtensionValue {
634    /**
635     * ID generated by {@link CloudDB.insert()}.
636     * An ID is generated for each row when data is first inserted to the cloud.
637     * The ID must be unique for each table.
638     *
639     * @type { string }
640     * @readonly
641     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
642     * @systemapi
643     * @since 11
644     */
645    readonly id: string;
646
647    /**
648     * Time when the row data was created.
649     *
650     * @type { number }
651     * @readonly
652     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
653     * @systemapi
654     * @since 11
655     */
656    readonly createTime: number;
657
658    /**
659     * Time when the row data was last modified.
660     *
661     * @type { number }
662     * @readonly
663     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
664     * @systemapi
665     * @since 11
666     */
667    readonly modifyTime: number;
668
669    /**
670     * Database operation.
671     *
672     * @type { Flag }
673     * @readonly
674     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
675     * @systemapi
676     * @since 11
677     */
678    readonly operation: Flag;
679  }
680
681  /**
682   * Defines the lock information.
683   *
684   * @interface LockInfo
685   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
686   * @systemapi
687   * @since 11
688   */
689  export interface LockInfo {
690    /**
691     * Duration for which the cloud database is locked, in seconds.
692     *
693     * @type { number }
694     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
695     * @systemapi
696     * @since 11
697     */
698    interval: number;
699
700    /**
701     * Lock ID for locking the cloud database.
702     *
703     * @type { number }
704     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
705     * @systemapi
706     * @since 11
707     */
708    lockId: number;
709  }
710
711  /**
712   * Enumerates the error codes.
713   *
714   * @enum { number }
715   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
716   * @systemapi
717   * @since 11
718   */
719  export enum ErrorCode {
720    /**
721     * Successful.
722     *
723     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
724     * @systemapi
725     * @since 11
726     */
727    SUCCESS = 0,
728
729    /**
730     * Unknown error.
731     *
732     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
733     * @systemapi
734     * @since 11
735     */
736    UNKNOWN_ERROR = 1,
737
738    /**
739     * Network error.
740     *
741     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
742     * @systemapi
743     * @since 11
744     */
745    NETWORK_ERROR = 2,
746
747    /**
748     * Cloud is disabled.
749     *
750     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
751     * @systemapi
752     * @since 11
753     */
754    CLOUD_DISABLED = 3,
755
756    /**
757     * The cloud database is locked by others.
758     *
759     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
760     * @systemapi
761     * @since 11
762     */
763    LOCKED_BY_OTHERS = 4,
764
765    /**
766     * The number of records exceeds the limit.
767     *
768     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
769     * @systemapi
770     * @since 11
771     */
772    RECORD_LIMIT_EXCEEDED = 5,
773
774    /**
775     * The cloud has no space for the asset.
776     *
777     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
778     * @systemapi
779     * @since 11
780     */
781    NO_SPACE_FOR_ASSET = 6
782  }
783
784  /**
785   * Defines the result.
786   *
787   * @interface Result
788   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
789   * @systemapi
790   * @since 11
791   */
792  export interface Result<T> {
793    /**
794     * Error code.
795     *
796     * @type { number }
797     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
798     * @systemapi
799     * @since 11
800     */
801    code: number;
802
803    /**
804     * Error code description.
805     *
806     * @type { ?string }
807     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
808     * @systemapi
809     * @since 11
810     */
811    description?: string;
812
813    /**
814     * Result value.
815     *
816     * @type { ?T }
817     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
818     * @systemapi
819     * @since 11
820     */
821    value?: T;
822  }
823
824  /**
825   * Creates a share service stub with the specified instance.
826   *
827   * @param { ShareCenter } instance - Indicates the <b>ShareCenter</b> instance.
828   * @returns { Promise<rpc.RemoteObject> } Returns remote object.
829   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
830   * @systemapi
831   * @since 11
832   */
833  function createShareServiceStub(instance: ShareCenter): Promise<rpc.RemoteObject>;
834
835  /**
836   * Creates a cloud service stub with the specified instance.
837   *
838   * @param { CloudService } instance - Indicates the <b>CloudService</b> instance.
839   * @returns { Promise<rpc.RemoteObject> } Returns the remote object.
840   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
841   * @systemapi
842   * @since 11
843   */
844  function createCloudServiceStub(instance: CloudService): Promise<rpc.RemoteObject>;
845
846  /**
847   * Creates a cloud database stub with the specified instance.
848   *
849   * @param { CloudDB } instance - Indicates the <b>CloudDB</b> instance.
850   * @returns { Promise<rpc.RemoteObject> } Returns the remote object.
851   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
852   * @systemapi
853   * @since 11
854   */
855  function createCloudDBStub(instance: CloudDB): Promise<rpc.RemoteObject>;
856
857  /**
858   * Creates an asset loader stub with the specified instance.
859   *
860   * @param { AssetLoader } instance - Indicates the <b>AssetLoader</b> instance.
861   * @returns { Promise<rpc.RemoteObject> } Returns remote object.
862   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
863   * @systemapi
864   * @since 11
865   */
866  function createAssetLoaderStub(instance: AssetLoader): Promise<rpc.RemoteObject>;
867
868  /**
869   * Provides interfaces for the operations on the cloud database.
870   *
871   * @interface CloudDB
872   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
873   * @systemapi
874   * @since 11
875   */
876  export interface CloudDB {
877    /**
878     * Generates the IDs of the rows of data to be inserted to the cloud.
879     * The IDs must be unique for each table.
880     *
881     * @param { number } count - Indicates the number of IDs to generate.
882     * @returns { Promise<Result<Array<string>>> } Returns the IDs generated.
883     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
884     * @systemapi
885     * @since 11
886     */
887    generateId(count: number): Promise<Result<Array<string>>>;
888
889    /**
890     * Inserts data to the cloud.
891     *
892     * @param { string } table - Indicates the table name.
893     * @param { Array<Record<string, CloudType>> } values - Indicates the data to insert.
894     * @param { Array<Record<string, CloudType>> } extensions - Indicates the extension
895     * values {@link ExtensionValue}.
896     * @returns { Promise<Array<Result<Record<string, CloudType>>>> } Returns the insert result.
897     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
898     * @systemapi
899     * @since 11
900     */
901    insert(
902      table: string,
903      values: Array<Record<string, CloudType>>,
904      extensions: Array<Record<string, CloudType>>
905    ): Promise<Array<Result<Record<string, CloudType>>>>;
906
907    /**
908     * Updates data in the cloud.
909     *
910     * @param { string } table - Indicates the table name.
911     * @param { Array<Record<string, CloudType>> } values - Indicates the new data.
912     * @param { Array<Record<string, CloudType>> } extensions - Indicates the extension
913     * values {@link ExtensionValue}.
914     * @returns { Promise<Array<Result<Record<string, CloudType>>>> } Returns the update result.
915     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
916     * @systemapi
917     * @since 11
918     */
919    update(
920      table: string,
921      values: Array<Record<string, CloudType>>,
922      extensions: Array<Record<string, CloudType>>
923    ): Promise<Array<Result<Record<string, CloudType>>>>;
924
925    /**
926     * Deletes data.
927     *
928     * @param { string } table - Indicates the table name.
929     * @param { Array<Record<string, CloudType>> } extensions - Indicates the extension
930     * values {@link ExtensionValue}.
931     * @returns { Promise<Array<Result<Record<string, CloudType>>>> } Returns the delete result.
932     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
933     * @systemapi
934     * @since 11
935     */
936    delete(
937      table: string,
938      extensions: Array<Record<string, CloudType>>
939    ): Promise<Array<Result<Record<string, CloudType>>>>;
940
941    /**
942     * Queries data.
943     *
944     * @param { string } table - Indicates the table name.
945     * @param { Array<string> } fields - Indicates the columns to query.
946     * @param { number } queryCount - Indicates the number of data records
947     * to query.
948     * @param { string } queryCursor - Indicates the cursor.
949     * @returns { Promise<Result<CloudData>> } Returns the query result.
950     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
951     * @systemapi
952     * @since 11
953     */
954    query(table: string, fields: Array<string>, queryCount: number, queryCursor: string): Promise<Result<CloudData>>;
955
956    /**
957     * Locks the cloud database.
958     * The cloud database will be unlocked when the lock interval has expired.
959     * When the cloud database is locked, other devices cannot synchronize data
960     * with the cloud.
961     *
962     * @returns { Promise<Result<LockInfo>> } Returns the locked information.
963     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
964     * @systemapi
965     * @since 11
966     */
967    lock(): Promise<Result<LockInfo>>;
968
969    /**
970     * Uses the heartbeat to extend the lock interval if it is not enough.
971     *
972     * @param { number } lockId - Indicates the lock ID of the heartbeat.
973     * @returns { Promise<Result<LockInfo>> } Returns the time.
974     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
975     * @systemapi
976     * @since 11
977     */
978    heartbeat(lockId: number): Promise<Result<LockInfo>>;
979
980    /**
981     * Unlocks the cloud database.
982     *
983     * @param { number } lockId - Indicates the lock ID.
984     * @returns { Promise<Result<boolean>> } Returns the unlock result.
985     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
986     * @systemapi
987     * @since 11
988     */
989    unlock(lockId: number): Promise<Result<boolean>>;
990  }
991
992  /**
993   * Provides interfaces for implementing the asset loader.
994   *
995   * @interface AssetLoader
996   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
997   * @systemapi
998   * @since 11
999   */
1000  export interface AssetLoader {
1001    /**
1002     * Downloads assets.
1003     *
1004     * @param { string } table - Indicates the name of the table.
1005     * @param { string } gid - Indicates the GID.
1006     * @param { string } prefix - Indicates the prefix information.
1007     * @param { Array<CloudAsset> } assets - Indicates the assets to download.
1008     * @returns { Promise<Array<Result<CloudAsset>>> } Returns the asset download result.
1009     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
1010     * @systemapi
1011     * @since 11
1012     */
1013    download(table: string, gid: string, prefix: string, assets: Array<CloudAsset>): Promise<Array<Result<CloudAsset>>>;
1014
1015    /**
1016     * Uploads assets.
1017     *
1018     * @param { string } table - Indicates the name of the table.
1019     * @param { string } gid - Indicates the GID.
1020     * @param { Array<CloudAsset> } assets - Indicates the assets to upload.
1021     * @returns { Promise<Array<Result<CloudAsset>>> } Returns the asset upload result.
1022     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
1023     * @systemapi
1024     * @since 11
1025     */
1026    upload(table: string, gid: string, assets: Array<CloudAsset>): Promise<Array<Result<CloudAsset>>>;
1027  }
1028
1029  /**
1030   * Provides interfaces for implementing ShareCenter.
1031   *
1032   * @interface ShareCenter
1033   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
1034   * @systemapi
1035   * @since 11
1036   */
1037  export interface ShareCenter {
1038    /**
1039     * Shares data with specific participants.
1040     *
1041     * @param { number } userId - Indicates the user ID.
1042     * @param { string } bundleName - Indicates the bundle name.
1043     * @param { string } sharingResource - Indicates the sharing resource.
1044     * @param { Array<cloudData.sharing.Participant> } participants - Indicates the participant.
1045     * @returns { Promise<Result<Array<Result<cloudData.sharing.Participant>>>> } Returns the sharing result.
1046     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
1047     * @systemapi
1048     * @since 11
1049     */
1050    share(
1051      userId: number,
1052      bundleName: string,
1053      sharingResource: string,
1054      participants: Array<cloudData.sharing.Participant>
1055    ): Promise<Result<Array<Result<cloudData.sharing.Participant>>>>;
1056
1057    /**
1058     * UnShares data with specific participants.
1059     *
1060     * @param { number } userId - Indicates the user ID.
1061     * @param { string } bundleName - Indicates the bundle name.
1062     * @param { string } sharingResource - Indicates the sharing resource.
1063     * @param { Array<cloudData.sharing.Participant> } participants - Indicates the participant.
1064     * @returns { Promise<Result<Array<Result<cloudData.sharing.Participant>>>> } Returns the sharing result.
1065     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
1066     * @systemapi
1067     * @since 11
1068     */
1069    unshare(
1070      userId: number,
1071      bundleName: string,
1072      sharingResource: string,
1073      participants: Array<cloudData.sharing.Participant>
1074    ): Promise<Result<Array<Result<cloudData.sharing.Participant>>>>;
1075
1076    /**
1077     * Exits the sharing.
1078     *
1079     * @param { number } userId - Indicates the user ID.
1080     * @param { string } bundleName - Indicates the bundle name.
1081     * @param { string } sharingResource - Indicates the sharing resource.
1082     * @returns { Promise<Result<void>> } Returns the exit result.
1083     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
1084     * @systemapi
1085     * @since 11
1086     */
1087    exit(userId: number, bundleName: string, sharingResource: string): Promise<Result<void>>;
1088
1089    /**
1090     * Changes privilege of the specific participants.
1091     *
1092     * @param { number } userId - Indicates the user ID.
1093     * @param { string } bundleName - Indicates the bundle name.
1094     * @param { string } sharingResource - Indicates the sharing resource.
1095     * @param { Array<cloudData.sharing.Participant> } participants - Indicates the participant.
1096     * @returns { Promise<Result<Array<Result<cloudData.sharing.Participant>>>> } Returns the changing result.
1097     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
1098     * @systemapi
1099     * @since 11
1100     */
1101    changePrivilege(
1102      userId: number,
1103      bundleName: string,
1104      sharingResource: string,
1105      participants: Array<cloudData.sharing.Participant>
1106    ): Promise<Result<Array<Result<cloudData.sharing.Participant>>>>;
1107
1108    /**
1109     * Queries participants of the specific sharing resource.
1110     *
1111     * @param { number } userId - Indicates the user ID.
1112     * @param { string } bundleName - Indicates the bundle name.
1113     * @param { string } sharingResource - Indicates the sharing resource.
1114     * @returns { Promise<Result<Array<cloudData.sharing.Participant>>> } Returns the query result.
1115     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
1116     * @systemapi
1117     * @since 11
1118     */
1119    queryParticipants(
1120      userId: number,
1121      bundleName: string,
1122      sharingResource: string
1123    ): Promise<Result<Array<cloudData.sharing.Participant>>>;
1124
1125    /**
1126     * Queries participants based on the specified invitation code.
1127     *
1128     * @param { number } userId - Indicates the user ID.
1129     * @param { string } bundleName - Indicates the bundle name.
1130     * @param { string } invitationCode - Indicates the invitation code.
1131     * @returns { Promise<Result<Array<cloudData.sharing.Participant>>> } Returns the query result.
1132     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
1133     * @systemapi
1134     * @since 11
1135     */
1136    queryParticipantsByInvitation(
1137      userId: number,
1138      bundleName: string,
1139      invitationCode: string
1140    ): Promise<Result<Array<cloudData.sharing.Participant>>>;
1141
1142    /**
1143     * Confirms invitation.
1144     *
1145     * @param { number } userId - Indicates the user ID.
1146     * @param { string } bundleName - Indicates the bundle name.
1147     * @param { string } invitationCode - Indicates the invitation code.
1148     * @param { cloudData.sharing.State } state - Indicates the state.
1149     * @returns { Promise<Result<string>> } Returns the sharing resource.
1150     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
1151     * @systemapi
1152     * @since 11
1153     */
1154    confirmInvitation(
1155      userId: number,
1156      bundleName: string,
1157      invitationCode: string,
1158      state: cloudData.sharing.State
1159    ): Promise<Result<string>>;
1160
1161    /**
1162     * Changes confirmation.
1163     *
1164     * @param { number } userId - Indicates the user ID.
1165     * @param { string } bundleName - Indicates the bundle name.
1166     * @param { string } sharingResource - Indicates the sharing resource.
1167     * @param { cloudData.sharing.State } state - Indicates the state.
1168     * @returns { Promise<Result<void>> } Returns the change result.
1169     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
1170     * @systemapi
1171     * @since 11
1172     */
1173    changeConfirmation(
1174      userId: number,
1175      bundleName: string,
1176      sharingResource: string,
1177      state: cloudData.sharing.State
1178    ): Promise<Result<void>>;
1179  }
1180
1181  /**
1182   * Provides interfaces for implementing CloudService.
1183   *
1184   * @interface CloudService
1185   * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
1186   * @systemapi
1187   * @since 11
1188   */
1189  export interface CloudService {
1190    /**
1191     * Obtains the service information.
1192     *
1193     * @returns { Promise<ServiceInfo> } Returns the service information obtained.
1194     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
1195     * @systemapi
1196     * @since 11
1197     */
1198    getServiceInfo(): Promise<ServiceInfo>;
1199
1200    /**
1201     * Obtains the brief application information.
1202     *
1203     * @returns { Promise<Record<string, AppBriefInfo>> }
1204     * Returns the key-value pairs corresponding to <b>bundle</b> and
1205     * <b>AppBriefInfo</b>.
1206     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
1207     * @systemapi
1208     * @since 11
1209     */
1210    getAppBriefInfo(): Promise<Record<string, AppBriefInfo>>;
1211
1212    /**
1213     * Obtains the application schema information.
1214     *
1215     * @param { string } bundleName - Indicates the bundle name of the application.
1216     * @returns { Promise<Result<AppSchema>> } Returns <b>AppSchema</b>.
1217     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
1218     * @systemapi
1219     * @since 11
1220     */
1221    getAppSchema(bundleName: string): Promise<Result<AppSchema>>;
1222
1223    /**
1224     * Subscribes to data changes in the cloud.
1225     * When the cloud server data is changed, the server notifies the device of
1226     * the data change.
1227     *
1228     * @param { Record<string, Array<Database>> } subInfo - Indicates
1229     * the data to be subscribed to, that is, the key-value pairs corresponding
1230     * to an array of bundle names and databases.
1231     * @param { number } expirationTime - Indicates the subscription expiration
1232     * time.
1233     * @returns { Promise<Result<SubscribeInfo>> } Returns <b>SubscribeInfo</b>.
1234     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
1235     * @systemapi
1236     * @since 11
1237     */
1238    subscribe(
1239      subInfo: Record<string, Array<Database>>,
1240      expirationTime: number
1241    ): Promise<Result<SubscribeInfo>>;
1242
1243    /**
1244     * Unsubscribes from the data changes in the cloud.
1245     *
1246     * @param { Record<string, Array<string>> } unsubscribeInfo - Indicates
1247     * the data to be unsubscribe from, that is, the key-value pairs
1248     *  corresponding to an array of bundle names and databases.
1249     * @returns { Promise<number> } Returns unsubscribeInfo result.
1250     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
1251     * @systemapi
1252     * @since 11
1253     */
1254    unsubscribe(unsubscribeInfo: Record<string, Array<string>>): Promise<number>;
1255
1256    /**
1257     * Connects to a database.
1258     *
1259     * @param { string } bundleName - Indicates the bundle name of the application.
1260     * @param { Database } database - Indicates the database to connect.
1261     * @returns { Promise<rpc.RemoteObject> } Returns connectDB RemoteObject.
1262     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
1263     * @systemapi
1264     * @since 11
1265     */
1266    connectDB(bundleName: string, database: Database): Promise<rpc.RemoteObject>;
1267
1268    /**
1269     * Connects to an assetLoader.
1270     *
1271     * @param { string } bundleName - Indicates the bundle name of the application.
1272     * @param { Database } database - Indicates the database of bundle.
1273     * @returns { Promise<rpc.RemoteObject> } Returns connectAssetLoader RemoteObject.
1274     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
1275     * @systemapi
1276     * @since 11
1277     */
1278    connectAssetLoader(bundleName: string, database: Database): Promise<rpc.RemoteObject>;
1279
1280    /**
1281     * Connects to a share center.
1282     *
1283     * @param { number } userId - Indicates the user ID.
1284     * @param { string } bundleName - Indicates the bundle name.
1285     * @returns { Promise<rpc.RemoteObject> } Returns shareCenter RemoteObject.
1286     * @syscap SystemCapability.DistributedDataManager.CloudSync.Server
1287     * @systemapi
1288     * @since 11
1289     */
1290    connectShareCenter(userId: number, bundleName: string): Promise<rpc.RemoteObject>;
1291  }
1292}
1293
1294export default cloudExtension;