From 9bc2bab74341cb7040fd2edbbbf7c5d818a9de72 Mon Sep 17 00:00:00 2001 From: shaoyuanzhao Date: Tue, 30 Jan 2024 00:05:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=90=9C=E7=B4=A2=E9=85=8D?= =?UTF-8?q?=E7=BD=AEschema=5Fjson?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: shaoyuanzhao --- modulecheck/BUILD.gn | 5 + modulecheck/arkdataSchema.json | 279 +++++++++++++++++++++++++++++++++ 2 files changed, 284 insertions(+) create mode 100644 modulecheck/arkdataSchema.json diff --git a/modulecheck/BUILD.gn b/modulecheck/BUILD.gn index 74a7b6f7..696d1068 100644 --- a/modulecheck/BUILD.gn +++ b/modulecheck/BUILD.gn @@ -57,3 +57,8 @@ ohos_prebuilt_etc("shortcutsSchema_json") { source = "shortcuts.json" install_enable = false } + +ohos_prebuilt_etc("arkdataSchema_json") { + source = "arkdataSchema.json" + install_enable = false +} diff --git a/modulecheck/arkdataSchema.json b/modulecheck/arkdataSchema.json new file mode 100644 index 00000000..53dfd4c6 --- /dev/null +++ b/modulecheck/arkdataSchema.json @@ -0,0 +1,279 @@ +{ + "title": "Arkdata schema for schema.json5", + "$schema:": "http://json-schema.org/draft-07/schema#", + "$id": "https://example.com/message.schema.json", + "description": "A validated arkdata schema", + "type": "object", + "required": [ "dbSchema" ], + "propertyNames": { + "enum": [ + "dbSchema" + ] + }, + "properties": { + "dbSchema": { + "description": "Indicates the database schema.", + "type": "array", + "minItems": 1, + "items": { "$ref": "#/$defs/dbSchemaItem" } + }, + "searchConfig": { + "description": "Indicates the search config. Here you can declare tables and fields in database you want to synchronize to the search.", + "type": "object", + "required": [ "UTDMapping" ], + "properties": { + "UTDMapping": { + "description": "Indicates the mapping relationship between fields in database and fields in search.", + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "required": [ "version", "type", "dbName", "tables", "mappings" ], + "properties": { + "version": { + "description": "Indicates the version number of mapping relationship. e.g. 1.0", + "type": "string", + "minLength":3, + "maxLength": 32, + "pattern": "^([0-9]+.[0-9]+)$" + }, + "type": { + "description": "Indicates the type name of mapping relationship.", + "enum": [ "Contact", "CallRecord", "CalendarEvent", "SettingItem", "Message", "Note" ] + }, + "dbName": { + "description": "Indicates the data that needs to be synced comes from the databases declared below.", + "type": "array", + "minItems": 1, + "items": { "$ref": "#/$defs/dbName" } + }, + "tables": { + "description": "Indicates the data that needs to be synced comes from the tables declared below.", + "type": "array", + "minItems": 1, + "items": { "$ref": "#/$defs/tableName" } + }, + "mappings": { + "description": "Indicates the details of the mapping relationship.", + "type": "array", + "minItems": 1, + "items": { "$ref": "#/$defs/mapping" } + } + } + } + } + } + } + }, + "$defs": { + "dbSchemaItem": { + "description": "Indicates the schema details of database.", + "type": "object", + "required": [ "version", "bundleName", "dbName", "tables" ], + "properties": { + "version": { + "description": "Indicates the version number of database schema.", + "type": "integer", + "minnum": 1 + }, + "bundleName": { + "description": "Indicates the package name of the application.", + "type": "string", + "minLength": 7, + "maxLength": 128, + "pattern": "^[a-zA-Z][0-9a-zA-Z_.]+$" + }, + "dbName": { "$ref": "#/$defs/dbName" }, + "tables": { + "description": "Indicates the details of each table.", + "type": "array", + "minItems": 1, + "items": { "$ref": "#/$defs/table" } + } + } + }, + "table": { + "description": "Indicates the detials of table.", + "type": "object", + "required": [ "cloudType", "tableName", "fields" ], + "properties": { + "cloudType": { + "description": "Indicates the types of table.", + "type": "array", + "minItems": 1, + "items": { + "enum": [ "Local", "DriveKit", "Cloud DB" ] + }, + "uniqueItems": true + }, + "tableName": { "$ref": "#/$defs/tableName" }, + "fields": { + "description": "Indicates the collection of database field.", + "type": "array", + "minItems": 1, + "items": { "$ref": "#/$defs/field" } + }, + "indexes": { + "description": "Indicates the collection of database index.", + "type": "array", + "items": { "$ref": "#/$defs/index" } + } + } + }, + "field": { + "description": "Indicates the attributes of field.", + "type": "object", + "required": [ "columnName", "type" ], + "properties": { + "columnName": { "$ref": "#/$defs/columnName" }, + "type": { + "description": "Indicates the data type of field.", + "enum": [ "Text", "Interger", "Long", "Float", "Double", "Bytes", "Asset" ] + }, + "primaryKey": { + "description": "Specifies whether the field is a primary key.", + "type": "boolean" + }, + "autoIncrement": { + "description": "Specifies whether the field increase automatically.", + "type": "boolean" + }, + "notNull": { + "description": "Specifies whether the field can not be empty.", + "type": "boolean" + }, + "foreignKey": { + "description": "Indicates the information of foreign keys.", + "type": "array", + "items": { + "description": "Indicates the configuration of foreign key", + "type": "array", + "required": [ "tableName", "columnName" ], + "properties": { + "tableName": { "$ref": "#/$defs/tableName" }, + "columnName": { "$ref": "#/$defs/columnName" } + } + } + } + } + }, + "index": { + "description": "Indicates the details of index.", + "type": "object", + "required": [ "indexName", "indexList" ], + "properties": { + "indexName": { + "description": "Indicates the index name.", + "type": "string", + "minLength": 1, + "maxLength": 255 + }, + "indexList": { + "type": "array", + "minItems": 1, + "items": { + "description": "Indicates the configuration of index", + "type": "object", + "required": [ "columnName", "sortType" ], + "properties": { + "columnName": { "$ref": "#/$defs/columnName" }, + "sortType": { + "enum": [ "ASC", "DESC" ] + } + } + } + } + } + }, + "mapping": { + "description": "Indicates the mapping relationship between database fields and search fields.", + "type": "object", + "required": [ "name" ], + "properties": { + "name": { + "description": "Indicates the field name of search.", + "type": "string", + "minLength": 1, + "maxLength": 255 + }, + "primaryKey": { + "description": "Specifies whether the field is a search primary key.", + "type": "boolean" + }, + "constant": { + "description": "Indicates the entity name of search.", + "enum": [ "Contact", "CallRecord", "CalendarEvent", "SettingItem", "Message", "Note" ] + }, + "value": { + "description": "Indicates the search field which is mapped to one field in database.", + "type": "object", + "required": [ "tableName", "columnName" ], + "properties": { + "tableName": { "$ref": "#/$defs/tableName" }, + "columnName": { "$ref": "#/$defs/columnName" } + } + }, + "values": { + "description": "Indicates the search field which is mapped to multiple fields in database.", + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "required": [ "keyName", "tableName", "columnName" ], + "properties": { + "keyName": { + "description": "Indicates the element name of search field.", + "type": "string", + "minLength": 1, + "maxLength": 255 + }, + "tableName": { "$ref": "#/$defs/tableName" }, + "columnName": { "$ref": "#/$defs/columnName" } + } + } + }, + "where": { + "description": "Indicates the constraints.", + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "properties": { + "equalto": { + "description": "Indicates the equality constraints.", + "type": "object", + "properties": { + "tableName": { "$ref": "#/$defs/tableName" }, + "columnName": { "$ref": "#/$defs/columnName" }, + "value": { + "description": "Indicates the expected value of the column." + } + } + } + } + } + } + } + }, + "dbName": { + "description": "Indicates the database Name.", + "type": "string", + "minLength": 3, + "maxLength": 255, + "pattern": "^[0-9a-zA-Z_]{1,}$" + }, + "tableName": { + "description": "Indicates the table Name.", + "type": "string", + "minLength": 1, + "maxLength": 255, + "pattern": "^[0-9a-z_]{1,}$" + }, + "columnName": { + "description": "Indicates the column name.", + "type": "string", + "minLength": 1, + "maxLength": 255 + } + } +} \ No newline at end of file -- Gitee