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