配置#
根目录文件配置#
在插件的根目录下,需要config.toml文件,该文件基本内容如下:
package='com.longgui.case'
name="示例插件"
version='1.0'
labels='case'
homepage='https://www.company.com'
logo=''
author='case@company.com'
该文件起到与 extension.__init__ 函数一样的作用.
在插件上传到插件商店时,插件商店也会通过该配置文件获取插件的基本信息。
数据库配置#
内核为了方便对插件的管理,自定义了三种插件的配置形式。
并为这些配置生成对应的Schema以使得各个与插件配置相关的API能动态适应插件的增删。
插件配置(profile)#
-
定义在 arkid.extension.models.Extension 中
与插件自身一对一的配置,json格式
使用 arkid.core.extension.Extension.register_profile_schema 注册其Schema
profile的增删改查通过 self.model 直接完成
租户配置(settings)#
-
定义在 arkid.extension.models.TenantExtension 中
在每个租户下每个插件只有一个settings的配置,json格式
使用 arkid.core.extension.Extension.register_settings_schema 注册其Schema
settings的增删改查通过:
运行时配置(config)#
-
定义在 arkid.extension.models.TenantExtensionConfig 中
每个租户下每个插件都有多个config,json格式
使用 arkid.core.extension.Extension.register_config_schema 注册其Schema
使用 arkid.core.extension.Extension.register_composite_config_schema 注册有子种类的Schema
config的增删改查通过:
注意
插件的Schema都应该调用 arkid.core.extension.create_extension_schema 方法来完成
...
package = 'com.longgui.case'
Profile = create_extension_schema(
'Profile', package,
fields = [
('name', str, Field())
]
)
Settings = create_extension_schema(
'Settings', package,
fields = [
('name', str, Field())
]
)
Config = create_extension_schema(
'Config', package,
fields = [
('name', str, Field())
]
)
class CaseExtension(extension.Extension):
def load(self):
super().load()
self.register_profile_schema(Profile)
self.register_settings_schema(Settings)
self.register_config_schema(Config)
self.register_composite_config_schema(Config, 'type_name')
...
arkid.extension.models
#
ArkStoreCategory (BaseModel)
django-model
#
ArkStoreCategory(id, is_del, is_active, updated, created, arkstore_id, arkstore_name, arkstore_parent_id, arkstore_type)
arkstore_id: IntegerField
django-field
nullable
#
ArkStoreID
arkstore_name: CharField
blank
django-field
nullable
#
ArkStore名称
arkstore_parent_id: IntegerField
django-field
nullable
#
ArkStoreParentID
arkstore_type: CharField
django-field
#
类别
created: DateTimeField
blank
django-field
nullable
#
创建时间
id: UUIDField
django-field
#
ID
is_active: BooleanField
django-field
#
是否可用
is_del: BooleanField
django-field
#
是否删除
updated: DateTimeField
blank
django-field
nullable
#
更新时间
Extension (BaseModel)
django-model
#
Extension(id, is_del, updated, created, type, labels, package, ext_dir, name, version, author, logo, homepage, is_active, expired, profile, is_allow_use_platform_config, category_id)
author: CharField
blank
django-field
nullable
#
Author
category_id: IntegerField
django-field
nullable
#
ArkStore分类ID
created: DateTimeField
blank
django-field
nullable
#
创建时间
expired: BooleanField
django-field
#
expired
ext_dir: CharField
django-field
#
完整路径名
homepage: CharField
blank
django-field
nullable
#
Homepage
id: UUIDField
django-field
#
ID
is_active: BooleanField
django-field
#
是否启动
is_allow_use_platform_config: BooleanField
django-field
#
是否允许租户使用平台配置
is_del: BooleanField
django-field
#
是否删除
labels: JSONField
blank
django-field
#
Labels
logo: CharField
blank
django-field
nullable
#
Logo
name: CharField
django-field
#
名称
package: CharField
django-field
#
标识
profile: JSONField
blank
django-field
#
Setup Profile
type: CharField
django-field
#
类型
updated: DateTimeField
blank
django-field
nullable
#
更新时间
version: CharField
django-field
#
版本
TenantExtension (BaseModel)
django-model
#
TenantExtension(id, is_del, updated, created, tenant, extension, settings, is_active, is_rented, use_platform_config)
created: DateTimeField
blank
django-field
nullable
#
创建时间
extension: ForeignKey
django-field
#
插件
id: UUIDField
django-field
#
ID
is_active: BooleanField
django-field
#
是否使用
is_del: BooleanField
django-field
#
是否删除
is_rented: BooleanField
django-field
#
是否已租赁
settings: JSONField
blank
django-field
#
Tenant Settings
tenant: ForeignKey
django-field
#
租户
updated: DateTimeField
blank
django-field
nullable
#
更新时间
use_platform_config: BooleanField
django-field
#
是否使用平台配置
TenantExtensionConfig (BaseModel)
django-model
#
TenantExtensionConfig(id, is_del, is_active, updated, created, tenant, extension, config, name, type)
config: JSONField
blank
django-field
#
Runtime Config
created: DateTimeField
blank
django-field
nullable
#
创建时间
extension: ForeignKey
django-field
#
插件
id: UUIDField
django-field
#
ID
is_active: BooleanField
django-field
#
是否可用
is_del: BooleanField
django-field
#
是否删除
name: CharField
django-field
#
名称
tenant: ForeignKey
django-field
#
租户
type: CharField
django-field
#
类型
updated: DateTimeField
blank
django-field
nullable
#
更新时间