From b4044e656ac1fbb2917b1cdbc307e72ba4795f91 Mon Sep 17 00:00:00 2001 From: mylinchi Date: Mon, 14 Apr 2025 16:58:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=96=B0=E5=A2=9EDataGraph=E6=93=8D?= =?UTF-8?q?=E4=BD=9CApi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: mylinchi --- api/@ohos.data.dataGraph.d.ts | 405 ++++++++++++++++++++++++++++++++++ kits/@kit.ArkData.d.ts | 3 +- 2 files changed, 407 insertions(+), 1 deletion(-) create mode 100644 api/@ohos.data.dataGraph.d.ts diff --git a/api/@ohos.data.dataGraph.d.ts b/api/@ohos.data.dataGraph.d.ts new file mode 100644 index 0000000000..95ffa3ccc0 --- /dev/null +++ b/api/@ohos.data.dataGraph.d.ts @@ -0,0 +1,405 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * @kit ArkData + */ + +/** + * Provides methods for dataGraph create and delete. + * + * @namespace dataGraph + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ +declare namespace dataGraph { + /** + * Defines Vertex Type. + * + * @interface Vertex + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + interface Vertex { + /** + * The Vertex element identifier. + * + * @type { string } + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + vid: string; + + /** + * Db name of the label name. + * + * @type { string } + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + storeName: string; + + /** + * Label name of the vertex id. + * + * @type { string } + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + tableName: string; + + /** + * Description of the vertex. + * + * @type { ?string } + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + description?: string; + } + + /** + * Defines Edge Type. + * + * @interface Edge + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + interface Edge { + /** + * The Edge element identifier. + * + * @type { ?string } + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + eid?: string; + + /** + * The Start Vertex element identifier. + * + * @type { Vertex } + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + start: Vertex; + + /** + * The End Vertex element identifier. + * + * @type { Vertex } + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + end: Vertex; + + /** + * Description of the edge. + * + * @type { ?string } + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + description?: string; + } + + /** + * Defines PathSegment Type. + * + * @interface PathSegment + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + interface PathSegment { + /** + * Start vertex. + * + * @type { Vertex } + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + start: Vertex; + + /** + * End vertex. + * + * @type { Vertex } + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + end: Vertex; + + /** + * The edge between start vertex and end vertex. + * + * @type { Edge } + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + edge: Edge; + } + + /** + * Defines Path Type. + * + * @interface Path + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + interface Path { + /** + * Start vertex. + * + * @type { Vertex } + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + start: Vertex; + + /** + * End vertex. + * + * @type { Vertex } + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + end: Vertex; + + /** + * Segments in the path. + * + * @type { Array } + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + segments: Array; + } + + /** + * The execution result of query vertex interface. + * + * @interface Result + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + interface Result { + /** + * The data records of querying the database. + * + * @type { ?Array> } + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + records?: Array>; + } + + /** + * Defines Condition HopType. + * + * @enum { number } + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + enum HopType { + /** + * SINGLE_HOP: one hop relation query. + * + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + SINGLE_HOP = 1 + } + + /** + * Defines Query Condition. + * + * @interface Condition + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + interface Condition { + /** + * vid. + * + * @type { string } + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + vid: string; + + /** + * hop type. + * + * @type { ?HopType } + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + hopType?: HopType, + } + + /** + * Add a vertex. + * + * @permission ohos.permission.DATA_GRAPH_WRITE + * @param { Vertex } vertex - The vertex will be added to data graph. + * @returns { Promise } The Promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission + *
"ohos.permission.DATA_GRAPH_WRITE". + * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application + *
uses system API. + * @throws { BusinessError } 32900000 - Inner error. + * @throws { BusinessError } 32900001 - Database corrupted. + * @throws { BusinessError } 32900002 - Already closed. + * @throws { BusinessError } 32900003 - The database is busy. + * @throws { BusinessError } 32900004 - The database is out of memory. + * @throws { BusinessError } 32900005 - The database is full. + * @throws { BusinessError } 32900008 - The input required element is empty. + * @throws { BusinessError } 32900009 - The input element is out of range. + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + function addVertex(vertex: Vertex): Promise; + + /** + * Add an edge. + * + * @permission ohos.permission.DATA_GRAPH_WRITE + * @param { Edge } edge - The edge will be added to data graph. + * @returns { Promise } The Promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission + *
"ohos.permission.DATA_GRAPH_WRITE". + * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application + *
uses system API. + * @throws { BusinessError } 32900000 - Inner error. + * @throws { BusinessError } 32900001 - Database corrupted. + * @throws { BusinessError } 32900002 - Already closed. + * @throws { BusinessError } 32900003 - The database is busy. + * @throws { BusinessError } 32900004 - The database is out of memory. + * @throws { BusinessError } 32900005 - The database is full. + * @throws { BusinessError } 32900006 - The vertex is not defined. + * @throws { BusinessError } 32900008 - The input required element is empty. + * @throws { BusinessError } 32900009 - The input element is out of range. + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + function addEdge(edge: Edge): Promise; + + /** + * Query vertex info that meet the condition. + * + * @permission ohos.permission.DATA_GRAPH_READ + * @param { Condition } condition - The specified query condition. + * @returns { Promise } The {@link Result} object if the query operation is successful. + * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission + *
"ohos.permission.DATA_GRAPH_READ". + * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application + *
uses system API. + * @throws { BusinessError } 32900000 - Inner error. + * @throws { BusinessError } 32900001 - Database corrupted. + * @throws { BusinessError } 32900002 - Already closed. + * @throws { BusinessError } 32900003 - The database is busy. + * @throws { BusinessError } 32900004 - The database is out of memory. + * @throws { BusinessError } 32900005 - The database is full. + * @throws { BusinessError } 32900006 - The vertex is not defined. + * @throws { BusinessError } 32900008 - The input required element is empty. + * @throws { BusinessError } 32900009 - The input element is out of range. + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + function queryVertex(condition: Condition): Promise; + + /** + * Delete the vertexs of the data graph. + * + * @permission ohos.permission.DATA_GRAPH_WRITE + * @param { Array } vids - The vertex id in array will be deleted from data graph. + * @returns { Promise } The Promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission + *
"ohos.permission.DATA_GRAPH_WRITE". + * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application + *
uses system API. + * @throws { BusinessError } 32900000 - Inner error. + * @throws { BusinessError } 32900001 - Database corrupted. + * @throws { BusinessError } 32900002 - Already closed. + * @throws { BusinessError } 32900003 - The database is busy. + * @throws { BusinessError } 32900004 - The database is out of memory. + * @throws { BusinessError } 32900005 - The database is full. + * @throws { BusinessError } 32900006 - The vertex is not defined. + * @throws { BusinessError } 32900008 - The input required element is empty. + * @throws { BusinessError } 32900009 - The input element is out of range. + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + function deleteVertex(vids: Array): Promise; + + /** + * Delete the edges of the data graph. + * + * @permission ohos.permission.DATA_GRAPH_WRITE + * @param { Array } edges - The edge in array will be deleted from data graph. + * @returns { Promise } The Promise returned by the function. + * @throws { BusinessError } 201 - Permission denied. Interface caller does not have permission + *
"ohos.permission.DATA_GRAPH_WRITE". + * @throws { BusinessError } 202 - Permission verification failed, application which is not a system application + *
uses system API. + * @throws { BusinessError } 32900000 - Inner error. + * @throws { BusinessError } 32900001 - Database corrupted. + * @throws { BusinessError } 32900002 - Already closed. + * @throws { BusinessError } 32900003 - The database is busy. + * @throws { BusinessError } 32900004 - The database is out of memory. + * @throws { BusinessError } 32900005 - The database is full. + * @throws { BusinessError } 32900006 - The vertex is not defined. + * @throws { BusinessError } 32900007 - The edge is not defined. + * @throws { BusinessError } 32900008 - The input required element is empty. + * @throws { BusinessError } 32900009 - The input element is out of range. + * @syscap SystemCapability.DistributedDataManager.DataIntelligence.DataGraph + * @systemapi + * @since 20 + */ + function deleteEdge(edges: Array): Promise; +} + +export default dataGraph; diff --git a/kits/@kit.ArkData.d.ts b/kits/@kit.ArkData.d.ts index fb5e391298..1584bd87c1 100644 --- a/kits/@kit.ArkData.d.ts +++ b/kits/@kit.ArkData.d.ts @@ -39,10 +39,11 @@ import sendableRelationalStore from '@ohos.data.sendableRelationalStore'; import graphStore from '@ohos.data.graphStore'; import collaborationEditObject from '@ohos.data.collaborationEditObject'; import intelligence from '@ohos.data.intelligence'; +import dataGraph from '@ohos.data.dataGraph'; export { DataShareExtensionAbility, DataShareResultSet, DataType, ValueType, ValuesBucket, cloudData, cloudExtension, commonType, dataShare, dataSharePredicates, distributedDataObject, distributedKVStore, preferences, relationalStore, unifiedDataChannel, uniformTypeDescriptor, uniformDataStruct, sendablePreferences, dataAbility, - sendableRelationalStore, graphStore, collaborationEditObject, intelligence + sendableRelationalStore, graphStore, collaborationEditObject, intelligence, dataGraph }; -- Gitee