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