mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-14 21:12:53 +00:00
feat: remove useless codes & modify generator
This commit is contained in:
parent
44ac85f8a6
commit
dcd1b33d3b
@ -1,4 +1,4 @@
|
|||||||
$id: '@ali/low-code-component-protocol-schema'
|
$id: "@ali/low-code-component-protocol-schema"
|
||||||
description: json schema for low code component protocol
|
description: json schema for low code component protocol
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: "#/definitions/BasicSection"
|
- $ref: "#/definitions/BasicSection"
|
||||||
@ -38,6 +38,8 @@ definitions:
|
|||||||
- screenshot
|
- screenshot
|
||||||
PropsSection:
|
PropsSection:
|
||||||
type: object
|
type: object
|
||||||
|
required:
|
||||||
|
- props
|
||||||
properties:
|
properties:
|
||||||
props:
|
props:
|
||||||
type: array
|
type: array
|
||||||
|
|||||||
@ -2,19 +2,26 @@ const yaml = require('js-yaml');
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const Ajv = require('ajv');
|
const Ajv = require('ajv');
|
||||||
|
const { compile } = require('json-schema-to-typescript');
|
||||||
|
|
||||||
const ajv = new Ajv();
|
const ajv = new Ajv();
|
||||||
|
|
||||||
const YamlPath = path.resolve(__dirname, '../schemas/schema.yml');
|
const YamlPath = path.resolve(__dirname, '../schemas/schema.yml');
|
||||||
const JsonPath = path.resolve(__dirname, '../src/schema.json');
|
const JsonPath = path.resolve(__dirname, '../src/validate/schema.json');
|
||||||
|
const tsPath = path.resolve(__dirname, '../src/otter-core/schema/types.ts');
|
||||||
// Get document, or throw exception on error
|
// Get document, or throw exception on error
|
||||||
|
|
||||||
try {
|
(async function() {
|
||||||
const schema = yaml.load(fs.readFileSync(YamlPath, 'utf8'));
|
try {
|
||||||
ajv.compile(schema);
|
const schema = yaml.load(fs.readFileSync(YamlPath, 'utf8'));
|
||||||
fs.writeFileSync(JsonPath, JSON.stringify(schema, null, 2), 'utf-8');
|
ajv.compile(schema);
|
||||||
console.log('yaml file is successfully transformed into json');
|
fs.writeFileSync(JsonPath, JSON.stringify(schema, null, 2), 'utf-8');
|
||||||
} catch (e) {
|
console.log('yaml file is successfully transformed into json');
|
||||||
console.log(e);
|
const ts = await compile(schema, 'IComponentMaterial');
|
||||||
process.exit(1);
|
fs.writeFileSync(tsPath, ts);
|
||||||
}
|
console.log('schema.d.ts is successfully generated');
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import LocalAccesser from './accesser/LocalAccesser';
|
import LocalAccesser from './accesser/LocalAccesser';
|
||||||
import OnlineAccesser from './accesser/OnlineAccesser';
|
import OnlineAccesser from './accesser/OnlineAccesser';
|
||||||
import { IMaterialinSchema } from './otter-core';
|
import { IComponentMaterial } from './otter-core';
|
||||||
import { IAccesser, IMaterializeOptions } from './types';
|
import { IAccesser, IMaterializeOptions } from './types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +34,7 @@ class Materialize {
|
|||||||
* @returns {Promise<IMaterialinSchema>}
|
* @returns {Promise<IMaterialinSchema>}
|
||||||
* @memberof Materialize
|
* @memberof Materialize
|
||||||
*/
|
*/
|
||||||
public async start(): Promise<IMaterialinSchema> {
|
public async start(): Promise<IComponentMaterial> {
|
||||||
// 分发请求到对应接入器
|
// 分发请求到对应接入器
|
||||||
if (this.options.accesser === 'local') {
|
if (this.options.accesser === 'local') {
|
||||||
this.accesser = new LocalAccesser(this.options);
|
this.accesser = new LocalAccesser(this.options);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { IMaterialinSchema } from '../otter-core';
|
import { IComponentMaterial } from '../otter-core';
|
||||||
import { IAccesser, IMaterializeOptions } from '../types';
|
import { IAccesser, IMaterializeOptions } from '../types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,7 +20,7 @@ abstract class BaseAccesser implements IAccesser {
|
|||||||
this.options = options;
|
this.options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract access(): Promise<IMaterialinSchema>;
|
public abstract access(): Promise<IComponentMaterial>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default BaseAccesser;
|
export default BaseAccesser;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import Generator from '../generator/Generator';
|
import Generator from '../generator/Generator';
|
||||||
import { debug, IMaterialinSchema } from '../otter-core';
|
import { debug, IComponentMaterial } from '../otter-core';
|
||||||
import BaseParser from '../parser/BaseParser';
|
import BaseParser from '../parser/BaseParser';
|
||||||
import ReactParser from '../parser/ReactParser';
|
import ReactParser from '../parser/ReactParser';
|
||||||
import Scanner from '../scanner/Scanner';
|
import Scanner from '../scanner/Scanner';
|
||||||
@ -38,7 +38,7 @@ class LocalAccesser extends BaseAccesser {
|
|||||||
*/
|
*/
|
||||||
private generator!: Generator;
|
private generator!: Generator;
|
||||||
|
|
||||||
public async access(): Promise<IMaterialinSchema> {
|
public async access(): Promise<IComponentMaterial> {
|
||||||
await this.init();
|
await this.init();
|
||||||
// 开始扫描
|
// 开始扫描
|
||||||
const matScanModel: IMaterialScanModel = await this.scanner.scan();
|
const matScanModel: IMaterialScanModel = await this.scanner.scan();
|
||||||
@ -49,7 +49,7 @@ class LocalAccesser extends BaseAccesser {
|
|||||||
);
|
);
|
||||||
log('matParsedModels', matParsedModels);
|
log('matParsedModels', matParsedModels);
|
||||||
// 开始生产
|
// 开始生产
|
||||||
const material: IMaterialinSchema = await this.generator.generate(
|
const material: IComponentMaterial = await this.generator.generate(
|
||||||
matScanModel,
|
matScanModel,
|
||||||
matParsedModels,
|
matParsedModels,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { ensureDir, ensureFile, writeFile } from 'fs-extra';
|
|||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import semver from 'semver';
|
import semver from 'semver';
|
||||||
import uuid from 'short-uuid';
|
import uuid from 'short-uuid';
|
||||||
import { debug, IMaterialinSchema, OtterError } from '../otter-core';
|
import { debug, IComponentMaterial, OtterError } from '../otter-core';
|
||||||
import { IMaterializeOptions } from '../types';
|
import { IMaterializeOptions } from '../types';
|
||||||
import BaseAccesser from './BaseAccesser';
|
import BaseAccesser from './BaseAccesser';
|
||||||
import LocalAccesser from './LocalAccesser';
|
import LocalAccesser from './LocalAccesser';
|
||||||
@ -25,7 +25,7 @@ class OnlineAccesser extends BaseAccesser {
|
|||||||
*/
|
*/
|
||||||
private tempDir: string = '';
|
private tempDir: string = '';
|
||||||
|
|
||||||
public async access(): Promise<IMaterialinSchema> {
|
public async access(): Promise<IComponentMaterial> {
|
||||||
// 创建临时目录
|
// 创建临时目录
|
||||||
this.tempDir = await this.createTempDir();
|
this.tempDir = await this.createTempDir();
|
||||||
// 创建组件包
|
// 创建组件包
|
||||||
|
|||||||
@ -1,18 +0,0 @@
|
|||||||
/**
|
|
||||||
* 获取打包后的 bundle 文件(物料化场景下可以使用此扩展点)
|
|
||||||
* - 扩展点名称:mat:build:bundle
|
|
||||||
* - 对应 Studio 所处状态:进入 就绪态 前
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @param {{
|
|
||||||
* bundleJS: string, // bundle 文件内容
|
|
||||||
* bundleObj: {[key: string]: any} // bundle 对象
|
|
||||||
* }} params
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
|
||||||
export default function matBuildBundle(params: {
|
|
||||||
bundleJS: string; // bundle 文件内容
|
|
||||||
bundleObj: { [key: string]: any }; // bundle 对象
|
|
||||||
}): Promise<void> {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
import { writeFile } from 'fs-extra';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理 containerJS(物料化场景下可以使用此扩展点)
|
|
||||||
* - 扩展点名称:mat:config:container
|
|
||||||
* - 对应 Studio 所处状态:进入 就绪态 前
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @param {{
|
|
||||||
* filePath: string,
|
|
||||||
* fileContent: string,
|
|
||||||
* }} params
|
|
||||||
* @returns {Promise<{
|
|
||||||
* filePath: string,
|
|
||||||
* fileContent: string,
|
|
||||||
* }>}
|
|
||||||
*/
|
|
||||||
export default async function matConfigContainer(params: {
|
|
||||||
filePath: string;
|
|
||||||
fileContent: string;
|
|
||||||
}): Promise<{
|
|
||||||
filePath: string;
|
|
||||||
fileContent: string;
|
|
||||||
}> {
|
|
||||||
await writeFile(params.filePath, params.fileContent);
|
|
||||||
|
|
||||||
return {
|
|
||||||
filePath: params.filePath,
|
|
||||||
fileContent: params.fileContent,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import { writeFile } from 'fs-extra';
|
import { writeFile } from 'fs-extra';
|
||||||
import { IMaterialinManifest } from '../otter-core';
|
import { IComponentMaterial } from '../otter-core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 配置 manifest(物料化场景下可以使用此扩展点)
|
* 配置 manifest(物料化场景下可以使用此扩展点)
|
||||||
@ -8,29 +8,29 @@ import { IMaterialinManifest } from '../otter-core';
|
|||||||
*
|
*
|
||||||
* @export
|
* @export
|
||||||
* @param {{
|
* @param {{
|
||||||
* manifestObj: IMaterialinManifest,
|
* manifestObj: IComponentMaterial,
|
||||||
* manifestFilePath: string,
|
* manifestFilePath: string,
|
||||||
* }} params
|
* }} params
|
||||||
* @returns {Promise<{
|
* @returns {Promise<{
|
||||||
* manifestJS: string,
|
* manifestJS: string,
|
||||||
* manifestFilePath: string,
|
* manifestFilePath: string,
|
||||||
* manifestObj: IMaterialinManifest,
|
* manifestObj: IComponentMaterial,
|
||||||
* }>}
|
* }>}
|
||||||
*/
|
*/
|
||||||
export default async function matConfigManifest(params: {
|
export default async function matConfigManifest(params: {
|
||||||
manifestObj: IMaterialinManifest;
|
manifestObj: IComponentMaterial;
|
||||||
manifestFilePath: string;
|
manifestFilePath: string;
|
||||||
}): Promise<{
|
}): Promise<{
|
||||||
manifestJS: string;
|
manifestJSON: string;
|
||||||
manifestFilePath: string;
|
manifestFilePath: string;
|
||||||
manifestObj: IMaterialinManifest;
|
manifestObj: IComponentMaterial;
|
||||||
}> {
|
}> {
|
||||||
const manifestJS = `export default ${JSON.stringify(params.manifestObj)}`;
|
const manifestJSON = JSON.stringify(params.manifestObj);
|
||||||
|
|
||||||
await writeFile(params.manifestFilePath, manifestJS);
|
await writeFile(params.manifestFilePath, manifestJSON);
|
||||||
|
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
manifestJS,
|
manifestJSON,
|
||||||
manifestObj: params.manifestObj,
|
manifestObj: params.manifestObj,
|
||||||
manifestFilePath: params.manifestFilePath,
|
manifestFilePath: params.manifestFilePath,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,27 +0,0 @@
|
|||||||
/**
|
|
||||||
* 生成 build 文件,可用于多组件导出场景(物料化场景下可以使用此扩展点)
|
|
||||||
* - 扩展点名称:mat:generate:buildjs
|
|
||||||
* - 对应 Studio 所处状态:进入 就绪态 前
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @param {{
|
|
||||||
* buildFileContent: string; // build 文件内容
|
|
||||||
* buildFilePath: string; // build 文件默认路径
|
|
||||||
* }} params
|
|
||||||
* @returns {Promise<{
|
|
||||||
* buildFileContent: string;
|
|
||||||
* buildFilePath: string;
|
|
||||||
* }>}
|
|
||||||
*/
|
|
||||||
export default function matGenerateBuildJS(params: {
|
|
||||||
buildFileContent: string; // build 文件内容
|
|
||||||
buildFilePath: string; // build 文件默认路径
|
|
||||||
}): Promise<{
|
|
||||||
buildFileContent: string;
|
|
||||||
buildFilePath: string;
|
|
||||||
}> {
|
|
||||||
return Promise.resolve({
|
|
||||||
buildFilePath: params.buildFilePath,
|
|
||||||
buildFileContent: params.buildFileContent,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
import { IMaterialinSchema } from '../otter-core';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 加载物料(物料接入场景下可以使用此扩展点)
|
|
||||||
* - 扩展点名称:mat:config:load
|
|
||||||
* - 对应 Studio 所处状态:进入 就绪态 前
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @param {string[]} pkgNameList
|
|
||||||
* @returns {Promise<IMaterialinSchema[]>}
|
|
||||||
*/
|
|
||||||
export default function matLoadMaterials(
|
|
||||||
pkgNameList: string[],
|
|
||||||
): Promise<IMaterialinSchema[]> {
|
|
||||||
return Promise.resolve([]);
|
|
||||||
}
|
|
||||||
@ -1,12 +1,6 @@
|
|||||||
import { ExtensionName } from '../types';
|
import { ExtensionName } from '../types';
|
||||||
import MatBuildBundle from './MatBuildBundle';
|
|
||||||
import MatConfigContainer from './MatConfigContainer';
|
|
||||||
import MatConfigManifest from './MatConfigManifest';
|
import MatConfigManifest from './MatConfigManifest';
|
||||||
import MatGenerateBuildJS from './MatGenerateBuildJS';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
[ExtensionName.CONFIGMANIFEST]: MatConfigManifest,
|
[ExtensionName.CONFIGMANIFEST]: MatConfigManifest,
|
||||||
[ExtensionName.BUILDBUNDLE]: MatBuildBundle,
|
|
||||||
[ExtensionName.CONFIGCONTAINER]: MatConfigContainer,
|
|
||||||
[ExtensionName.GENERATEBUILDJS]: MatGenerateBuildJS,
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,8 +1,12 @@
|
|||||||
import { dirname, join } from 'path';
|
import { dirname, join } from 'path';
|
||||||
import defaultExtension from '../extensions';
|
import defaultExtension from '../extensions';
|
||||||
import { debug, IMaterialinManifest, IMaterialinProp } from '../otter-core';
|
|
||||||
import {
|
import {
|
||||||
ICompiler,
|
debug,
|
||||||
|
IComponentMaterial,
|
||||||
|
PropsSection,
|
||||||
|
PropType,
|
||||||
|
} from '../otter-core';
|
||||||
|
import {
|
||||||
IGenerator,
|
IGenerator,
|
||||||
IMaterializeOptions,
|
IMaterializeOptions,
|
||||||
IMaterialParsedModel,
|
IMaterialParsedModel,
|
||||||
@ -29,14 +33,6 @@ class Generator implements IGenerator {
|
|||||||
*/
|
*/
|
||||||
protected options!: IMaterializeOptions;
|
protected options!: IMaterializeOptions;
|
||||||
|
|
||||||
/**
|
|
||||||
* 编译器实例
|
|
||||||
* @protected
|
|
||||||
* @type {ICompiler}
|
|
||||||
* @memberof BaseGenerator
|
|
||||||
*/
|
|
||||||
protected compiler!: ICompiler;
|
|
||||||
|
|
||||||
constructor(options: IMaterializeOptions) {
|
constructor(options: IMaterializeOptions) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
}
|
}
|
||||||
@ -62,7 +58,10 @@ class Generator implements IGenerator {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 组装 manifest
|
// 组装 manifest
|
||||||
const manifest: any = await this.genManifest(matParsedModel);
|
const manifest: any = await this.genManifest(
|
||||||
|
matScanModel,
|
||||||
|
matParsedModel,
|
||||||
|
);
|
||||||
|
|
||||||
containerList.push(manifest);
|
containerList.push(manifest);
|
||||||
}
|
}
|
||||||
@ -95,21 +94,25 @@ class Generator implements IGenerator {
|
|||||||
* @memberof LocalGenerator
|
* @memberof LocalGenerator
|
||||||
*/
|
*/
|
||||||
public async genManifest(
|
public async genManifest(
|
||||||
|
matScanModel: IMaterialScanModel,
|
||||||
matParsedModel: IMaterialParsedModel,
|
matParsedModel: IMaterialParsedModel,
|
||||||
): Promise<{
|
): Promise<{
|
||||||
manifestFilePath: string; // manifest 文件路径
|
manifestFilePath: string; // manifest 文件路径
|
||||||
manifestJS: string; // manifest 文件内容
|
manifestJS: string; // manifest 文件内容
|
||||||
manifestObj: IMaterialinManifest; // manifest 文件对象
|
manifestObj: IComponentMaterial; // manifest 文件对象
|
||||||
}> {
|
}> {
|
||||||
const manifestObj: IMaterialinManifest = {
|
const manifestObj: Partial<IComponentMaterial> = {
|
||||||
name: matParsedModel.defaultExportName,
|
componentName: matParsedModel.defaultExportName,
|
||||||
settings: {
|
title: '',
|
||||||
type: 'element_inline',
|
docUrl: '',
|
||||||
insertionModes: 'tbrl',
|
screenshot: '',
|
||||||
handles: ['cut', 'copy', 'duplicate', 'delete', 'paste'],
|
npm: {
|
||||||
shouldActive: true,
|
package: matScanModel.pkgName,
|
||||||
shouldDrag: true,
|
version: matScanModel.pkgVersion,
|
||||||
props: [],
|
exportName: matParsedModel.defaultExportName,
|
||||||
|
main: matScanModel.mainEntry,
|
||||||
|
destructuring: false,
|
||||||
|
subName: '',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -119,7 +122,7 @@ class Generator implements IGenerator {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 填充 props
|
// 填充 props
|
||||||
manifestObj.settings.props = this.populateProps(matParsedModel);
|
manifestObj.props = this.populateProps(matParsedModel);
|
||||||
// 执行扩展点
|
// 执行扩展点
|
||||||
const manifest: any = await this.executeExtensionPoint(
|
const manifest: any = await this.executeExtensionPoint(
|
||||||
'mat:config:manifest',
|
'mat:config:manifest',
|
||||||
@ -145,17 +148,17 @@ class Generator implements IGenerator {
|
|||||||
*/
|
*/
|
||||||
public populateProps(
|
public populateProps(
|
||||||
matParsedModel: IMaterialParsedModel,
|
matParsedModel: IMaterialParsedModel,
|
||||||
): IMaterialinProp[] {
|
): PropsSection['props'] {
|
||||||
// 填充 props
|
// 填充 props
|
||||||
const props: IMaterialinProp[] = [];
|
const props: PropsSection['props'] = [];
|
||||||
matParsedModel.propsTypes.forEach(item => {
|
matParsedModel.propsTypes.forEach(item => {
|
||||||
const defaultValueItem = matParsedModel.propsDefaults.find(
|
const defaultValueItem = matParsedModel.propsDefaults.find(
|
||||||
inner => inner.name === item.name,
|
inner => inner.name === item.name,
|
||||||
);
|
);
|
||||||
props.push({
|
props.push({
|
||||||
name: item.name,
|
name: item.name,
|
||||||
label: item.name,
|
propType: item.type as PropType,
|
||||||
renderer: '',
|
description: '',
|
||||||
defaultValue: defaultValueItem
|
defaultValue: defaultValueItem
|
||||||
? defaultValueItem.defaultValue
|
? defaultValueItem.defaultValue
|
||||||
: undefined,
|
: undefined,
|
||||||
|
|||||||
@ -1,238 +1,179 @@
|
|||||||
// 搭建基础协议、搭建入料协议的数据规范
|
/* tslint:disable */
|
||||||
|
/**
|
||||||
|
* This file was automatically generated by json-schema-to-typescript.
|
||||||
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
||||||
|
* and run json-schema-to-typescript to regenerate this file.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 搭建基础协议
|
* json schema for low code component protocol
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @interface IBasicSchema
|
|
||||||
*/
|
*/
|
||||||
export interface IBasicSchema {
|
export type IComponentMaterial = BasicSection & PropsSection & ConfigureSection;
|
||||||
version: string; // 当前协议版本号
|
export type PropType = BasicType | RequiredType | ComplexType;
|
||||||
componentsMap: IComponentsMapItem[]; // 组件映射关系(用于描述 componentName 到公域组件映射关系的规范)
|
export type BasicType =
|
||||||
componentsTree: IComponentsTreeItem[]; // 描述模版/页面/区块/低代码业务组件的组件树(用于描述搭建出来的组件树结构的规范)
|
| 'array'
|
||||||
}
|
| 'bool'
|
||||||
|
| 'func'
|
||||||
/**
|
| 'number'
|
||||||
* 搭建基础协议 - 单个组件描述
|
| 'object'
|
||||||
*
|
| 'string'
|
||||||
* @export
|
| 'node'
|
||||||
* @interface IComponentsMapItem
|
| 'element'
|
||||||
*/
|
| 'any';
|
||||||
export interface IComponentsMapItem {
|
export type ComplexType =
|
||||||
componentName: string; // 组件名称
|
| OneOf
|
||||||
package: string; // 组件包的名称
|
| OneOfType
|
||||||
version: string; // 组件包的版本
|
| ArrayOf
|
||||||
originalPackage: string; // 组件的原始包名称
|
| ObjectOf
|
||||||
originalVersion: string; // 组件的原始包版本
|
| Shape
|
||||||
destructuring: boolean; // 组件是否是解构方式方式导出
|
| Exact;
|
||||||
exportName: string; // 导出命名
|
export type ConfigureProp = {
|
||||||
subName?: string; // 下标子组件名称
|
title?: string;
|
||||||
}
|
extraProps?: {
|
||||||
|
[k: string]: any;
|
||||||
/**
|
|
||||||
* 搭建基础协议 - 单个组件树节点描述
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @interface IComponentsTreeItem
|
|
||||||
*/
|
|
||||||
export interface IComponentsTreeItem {
|
|
||||||
id: string; // 节点的唯一标识
|
|
||||||
componentName: string; // 组件名称
|
|
||||||
pkg: string; // 组件所属的包
|
|
||||||
props?: {
|
|
||||||
className?: string; // 组件样式类名
|
|
||||||
style?: { [cssAttribute: string]: string | number }; // 组件内联样式
|
|
||||||
[propName: string]: any; // 业务属性
|
|
||||||
}; // 组件属性对象
|
|
||||||
children?: IComponentsTreeItem[] | string; // 子节点
|
|
||||||
dataSource?: IDataSource; // 数据源
|
|
||||||
state?: {
|
|
||||||
// 初始数据状态
|
|
||||||
[key: string]: any;
|
|
||||||
};
|
};
|
||||||
methods?: {
|
[k: string]: any;
|
||||||
// 自定事件绑定
|
} & (ConfigureFieldProp | ConfigureGroupProp);
|
||||||
[methodName: string]: IJSExpression;
|
|
||||||
};
|
|
||||||
lifeCycles?: {
|
|
||||||
// 组件生命周期
|
|
||||||
didMount?: IJSExpression;
|
|
||||||
willMount?: IJSExpression;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
export interface BasicSection {
|
||||||
* 搭建基础协议 - 函数表达式
|
componentName: string;
|
||||||
*
|
title: string;
|
||||||
* @export
|
description?: string;
|
||||||
* @interface IComponentLifeCycle
|
docUrl: string;
|
||||||
*/
|
screenshot: string;
|
||||||
export interface IJSExpression {
|
icon?: string;
|
||||||
type: 'JSExpression';
|
tags?: string[];
|
||||||
value: string;
|
devMode?: 'proCode' | 'lowCode';
|
||||||
|
npm: Npm;
|
||||||
|
[k: string]: any;
|
||||||
}
|
}
|
||||||
|
export interface Npm {
|
||||||
/**
|
|
||||||
* 搭建基础协议 - 数据源
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @interface IDataSource
|
|
||||||
*/
|
|
||||||
export interface IDataSource {
|
|
||||||
list: IDataSourceRequest[]; // 数据源配置列表
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 搭建基础协议 - 数据源单个配置
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @interface IDataSourceRequest
|
|
||||||
*/
|
|
||||||
export interface IDataSourceRequest {
|
|
||||||
id: string; // 数据请求 ID
|
|
||||||
isInit: boolean; // 表示在组件初始化渲染时是否自动发送当前数据请求
|
|
||||||
type: 'fetch' | 'jsonp' | 'custom'; // 数据请求类型
|
|
||||||
options?: IRequestOptions; // 请求参数配置
|
|
||||||
dataHandler?: any; // 数据结果处理函数,形如:(data, err) => Object
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 搭建基础协议 - 请求参数配置
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @interface IRequestOptions
|
|
||||||
*/
|
|
||||||
export interface IRequestOptions {
|
|
||||||
uri: string; // 请求地址
|
|
||||||
params?: {
|
|
||||||
// 请求参数
|
|
||||||
[key: string]: any;
|
|
||||||
};
|
|
||||||
method: 'GET' | 'POST';
|
|
||||||
isCors: boolean; // 是否支持跨域,对应credentials = 'include'
|
|
||||||
timeout: number; // 超时时长
|
|
||||||
headers?: {
|
|
||||||
// 自定义请求头
|
|
||||||
[key: string]: any;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 组件描述协议
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @interface IMaterialinSchema
|
|
||||||
*/
|
|
||||||
export interface IMaterialinSchema {
|
|
||||||
version: string; // 当前协议版本号
|
|
||||||
components: IMaterialinComponent[]; // 组件集合
|
|
||||||
pkgInfo: IMaterialinPkgInfo; // 组件包信息描述
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 组件描述协议 - 组件包信息描述(供出码引擎消费)
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @interface IMaterialinPkgInfo
|
|
||||||
*/
|
|
||||||
export interface IMaterialinPkgInfo {
|
|
||||||
// 包名
|
|
||||||
package: string;
|
package: string;
|
||||||
// 版本号
|
exportName: string;
|
||||||
|
subName: string;
|
||||||
|
main: string;
|
||||||
|
destructuring: boolean;
|
||||||
version: string;
|
version: string;
|
||||||
// 源版本号
|
[k: string]: any;
|
||||||
originalVersion: string;
|
|
||||||
// 源组件包
|
|
||||||
originalPackage: string;
|
|
||||||
// 组件是否是 export 方式导出
|
|
||||||
defaultExportedName: string;
|
|
||||||
}
|
}
|
||||||
|
export interface PropsSection {
|
||||||
/**
|
props: {
|
||||||
* 组件描述协议 - 单个组件描述
|
name: string;
|
||||||
*
|
propType: PropType;
|
||||||
* @export
|
description?: string;
|
||||||
* @interface IMaterialinComponent
|
defaultValue?: any;
|
||||||
*/
|
[k: string]: any;
|
||||||
export interface IMaterialinComponent {
|
}[];
|
||||||
componentName: string; // 组件名
|
[k: string]: any;
|
||||||
manifest: IMaterialinManifest; // 组件配置信息描述
|
|
||||||
origin: any; // 组件源
|
|
||||||
}
|
}
|
||||||
|
export interface RequiredType {
|
||||||
/**
|
type: BasicType;
|
||||||
* 组件描述协议 - 组件配置信息描述
|
isRequired?: boolean;
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @interface IMaterialinManifest
|
|
||||||
*/
|
|
||||||
export interface IMaterialinManifest {
|
|
||||||
name: string; // 组件名
|
|
||||||
settings: IMaterialinSettings; // 定义组件的配置属性
|
|
||||||
description?: string; // 组件的描述
|
|
||||||
coverImage?: string; // 组件的封面图 URL
|
|
||||||
category?: string; // 组件的分类
|
|
||||||
presets?: IMaterialinPreset[]; // 定义组件左侧预览信息
|
|
||||||
}
|
}
|
||||||
|
export interface OneOf {
|
||||||
/**
|
type: 'oneOf';
|
||||||
* 组件描述协议 - 组件配置属性(直接影响组件在编排工作区中的行为表现)
|
value: string[];
|
||||||
*
|
isRequired?: boolean;
|
||||||
* @export
|
[k: string]: any;
|
||||||
* @interface IMaterialinSettings
|
|
||||||
*/
|
|
||||||
export interface IMaterialinSettings {
|
|
||||||
type: 'element_inline' | 'element_block' | 'container'; // 定义组件在编排画布上的渲染类型
|
|
||||||
// 定义组件对于拖拽行为的响应,支持:t、b、r、l、v 组合;形如:tbrl
|
|
||||||
// t:允许元素在组件顶部插入
|
|
||||||
// b:允许元素在组件底部插入
|
|
||||||
// r:允许元素在组件右侧插入
|
|
||||||
// l:允许元素在组件左侧插入
|
|
||||||
// v:允许将元素拖放到组件内部
|
|
||||||
insertionModes: string; // 定义组件在编排画布上的响应模式
|
|
||||||
handles: Array<'cut' | 'copy' | 'paste' | 'delete' | 'duplicate'>; // 定义组件需要响应的右键菜单操作
|
|
||||||
shouldActive: boolean; // 用于控制物料组件在画布区块中是否响应用户鼠标的 Click 操作
|
|
||||||
shouldDrag: boolean; // 用于控制物料组件在画布区块中是否可以被用户拖拽
|
|
||||||
props: IMaterialinProp[]; // 物料组件属性配置
|
|
||||||
lifeCycle?: IMaterialinLifeCycle; // 组件生命周期
|
|
||||||
}
|
}
|
||||||
|
export interface OneOfType {
|
||||||
/**
|
type: 'oneOfType';
|
||||||
* 组件描述协议 - 定义组件左侧预览信息
|
value: PropType[];
|
||||||
*
|
isRequired?: boolean;
|
||||||
* @export
|
[k: string]: any;
|
||||||
* @interface IMaterialinPreset
|
|
||||||
*/
|
|
||||||
export interface IMaterialinPreset {
|
|
||||||
alias: string; // 组件的别名
|
|
||||||
thumbnail: string; // 组件的预览缩略图 URL
|
|
||||||
colSpan?: number; // 代表组件所占栅格数
|
|
||||||
customProps?: object; // 自定义属性值
|
|
||||||
}
|
}
|
||||||
|
export interface ArrayOf {
|
||||||
/**
|
type: 'arrayOf';
|
||||||
* 组件描述协议 - 组件属性的描述
|
value: PropType;
|
||||||
*
|
isRequired?: boolean;
|
||||||
* @export
|
[k: string]: any;
|
||||||
* @interface IMaterialinProp
|
|
||||||
*/
|
|
||||||
export interface IMaterialinProp {
|
|
||||||
name: string; // 属性名
|
|
||||||
label: string; // 属性展示名称
|
|
||||||
renderer: string; // 属性编辑器类型
|
|
||||||
defaultValue?: any; // 属性默认值
|
|
||||||
params?: any; // 属性编辑器的参数
|
|
||||||
placeholder?: string; // 属性编辑器的 placeholder 信息
|
|
||||||
hint?: string; // 属性编辑器的提示信息(类似于 tooltip 效果),用于帮助用户理解属性的使用方法
|
|
||||||
}
|
}
|
||||||
|
export interface ObjectOf {
|
||||||
/**
|
type: 'objectOf';
|
||||||
* 组件描述协议 - 组件生命周期描述
|
value: PropType;
|
||||||
*
|
isRequired?: boolean;
|
||||||
* @export
|
[k: string]: any;
|
||||||
* @interface IMaterialinLifeCycle
|
}
|
||||||
*/
|
export interface Shape {
|
||||||
export interface IMaterialinLifeCycle {
|
type: 'shape';
|
||||||
didMount?: any; // 组件渲染完成后的钩子
|
value: {
|
||||||
didUpdate?: any; // 组件数据状态更新时的钩子
|
name?: string;
|
||||||
|
propType?: PropType;
|
||||||
|
}[];
|
||||||
|
isRequired?: boolean;
|
||||||
|
[k: string]: any;
|
||||||
|
}
|
||||||
|
export interface Exact {
|
||||||
|
type: 'exact';
|
||||||
|
value: {
|
||||||
|
name?: string;
|
||||||
|
propType?: PropType;
|
||||||
|
}[];
|
||||||
|
isRequired?: boolean;
|
||||||
|
[k: string]: any;
|
||||||
|
}
|
||||||
|
export interface ConfigureSection {
|
||||||
|
configure?: {
|
||||||
|
props?: ConfigureProp[];
|
||||||
|
styles?: {
|
||||||
|
[k: string]: any;
|
||||||
|
};
|
||||||
|
events?: {
|
||||||
|
[k: string]: any;
|
||||||
|
};
|
||||||
|
component?: ConfigureComponent;
|
||||||
|
[k: string]: any;
|
||||||
|
};
|
||||||
|
[k: string]: any;
|
||||||
|
}
|
||||||
|
export interface ConfigureFieldProp {
|
||||||
|
type: 'field';
|
||||||
|
name?: string;
|
||||||
|
setter?: ConfigureFieldSetter;
|
||||||
|
[k: string]: any;
|
||||||
|
}
|
||||||
|
export interface ConfigureFieldSetter {
|
||||||
|
componentName:
|
||||||
|
| 'List'
|
||||||
|
| 'Object'
|
||||||
|
| 'Function'
|
||||||
|
| 'Node'
|
||||||
|
| 'Mixin'
|
||||||
|
| 'Expression'
|
||||||
|
| 'Switch'
|
||||||
|
| 'Number'
|
||||||
|
| 'Input'
|
||||||
|
| 'TextArea'
|
||||||
|
| 'Date'
|
||||||
|
| 'DateYear'
|
||||||
|
| 'DateMonth'
|
||||||
|
| 'DateRange'
|
||||||
|
| 'ColorPicker'
|
||||||
|
| 'CodeEditor'
|
||||||
|
| 'Select'
|
||||||
|
| 'RadioGroup';
|
||||||
|
props?: {
|
||||||
|
[k: string]: any;
|
||||||
|
};
|
||||||
|
[k: string]: any;
|
||||||
|
}
|
||||||
|
export interface ConfigureGroupProp {
|
||||||
|
type: 'group';
|
||||||
|
items: ConfigureProp[];
|
||||||
|
[k: string]: any;
|
||||||
|
}
|
||||||
|
export interface ConfigureComponent {
|
||||||
|
isContainer?: boolean;
|
||||||
|
isModal?: boolean;
|
||||||
|
descriptor?: string;
|
||||||
|
nestingRule?: {
|
||||||
|
childWhitelist?: string[];
|
||||||
|
parentWhitelist?: string[];
|
||||||
|
descendantBlacklist?: string[];
|
||||||
|
ancestorWhitelist?: string[];
|
||||||
|
[k: string]: any;
|
||||||
|
};
|
||||||
|
isNullNode?: boolean;
|
||||||
|
isLayout?: boolean;
|
||||||
|
[k: string]: any;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
import { IBasicSchema } from './schema/types';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @export
|
* @export
|
||||||
@ -22,19 +20,3 @@ export interface IComponents {
|
|||||||
[componentName: string]: any; // 组件
|
[componentName: string]: any; // 组件
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 渲染引擎的输入
|
|
||||||
* 编排引擎、渲染引擎使用
|
|
||||||
*
|
|
||||||
* @export
|
|
||||||
* @interface IRenderInputData
|
|
||||||
*/
|
|
||||||
export interface IRenderInputData {
|
|
||||||
schema: IBasicSchema;
|
|
||||||
components: IComponents;
|
|
||||||
options?: {
|
|
||||||
domId?: string;
|
|
||||||
propsHooks?: { [propName: string]: any };
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|||||||
@ -2,16 +2,8 @@
|
|||||||
* 扩展点名称
|
* 扩展点名称
|
||||||
*/
|
*/
|
||||||
enum ExtensionName {
|
enum ExtensionName {
|
||||||
/** 加载物料 */
|
|
||||||
LOADMATERIALS = 'mat:load:materials',
|
|
||||||
/** 配置 manifest */
|
/** 配置 manifest */
|
||||||
CONFIGMANIFEST = 'mat:config:manifest',
|
CONFIGMANIFEST = 'mat:config:manifest',
|
||||||
/** 获取打包后的 bundle */
|
|
||||||
BUILDBUNDLE = 'mat:build:bundle',
|
|
||||||
/** 配置 containerJS */
|
|
||||||
CONFIGCONTAINER = 'mat:config:container',
|
|
||||||
/** 生成 buildJS */
|
|
||||||
GENERATEBUILDJS = 'mat:generate:buildjs',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ExtensionName;
|
export default ExtensionName;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { IMaterialinSchema } from '../otter-core';
|
import { IComponentMaterial } from '../otter-core';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 接入器接口(用于定义物料化组件的接入渠道)
|
* 接入器接口(用于定义物料化组件的接入渠道)
|
||||||
@ -10,7 +10,7 @@ interface IAccesser {
|
|||||||
* @returns {Promise<IMaterialinSchema>}
|
* @returns {Promise<IMaterialinSchema>}
|
||||||
* @memberof IAccesser
|
* @memberof IAccesser
|
||||||
*/
|
*/
|
||||||
access(): Promise<IMaterialinSchema>;
|
access(): Promise<IComponentMaterial>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default IAccesser;
|
export default IAccesser;
|
||||||
|
|||||||
@ -1,10 +0,0 @@
|
|||||||
/**
|
|
||||||
* 扩展点:获取打包后的 bundle 文件
|
|
||||||
* (物料化场景)
|
|
||||||
*/
|
|
||||||
type IExtensionBuildBundle = (params: {
|
|
||||||
bundleJS: string; // bundle 文件内容
|
|
||||||
bundleObj: { [key: string]: any }; // bundle 对象
|
|
||||||
}) => Promise<void>;
|
|
||||||
|
|
||||||
export default IExtensionBuildBundle;
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
/**
|
|
||||||
* 扩展点:配置 container
|
|
||||||
* (物料化场景)
|
|
||||||
*/
|
|
||||||
type IExtensionConfigContainer = (params: {
|
|
||||||
filePath: string; // container 文件默认路径
|
|
||||||
fileContent: string; // container 文件内容
|
|
||||||
}) => Promise<{
|
|
||||||
filePath: string;
|
|
||||||
fileContent: string;
|
|
||||||
}>;
|
|
||||||
|
|
||||||
export default IExtensionConfigContainer;
|
|
||||||
@ -1,15 +1,15 @@
|
|||||||
import { IMaterialinManifest } from '../otter-core';
|
import { IComponentMaterial } from '../otter-core';
|
||||||
/**
|
/**
|
||||||
* 扩展点:配置 manifest
|
* 扩展点:配置 manifest
|
||||||
* (物料化场景)
|
* (物料化场景)
|
||||||
*/
|
*/
|
||||||
type IExtensionConfigManifest = (params: {
|
type IExtensionConfigManifest = (params: {
|
||||||
manifestObj: IMaterialinManifest; // manifest 配置对象
|
manifestObj: IComponentMaterial; // manifest 配置对象
|
||||||
manifestFilePath: string; // manifest 文件默认路径
|
manifestFilePath: string; // manifest 文件默认路径
|
||||||
}) => Promise<{
|
}) => Promise<{
|
||||||
manifestJS: string; // manifest 文件内容
|
manifestJSON: string; // manifest 文件内容
|
||||||
manifestFilePath: string; // manifest 文件路径
|
manifestFilePath: string; // manifest 文件路径
|
||||||
manifestObj: IMaterialinManifest; // manifest 文件对象
|
manifestObj: IComponentMaterial; // manifest 文件对象
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
export default IExtensionConfigManifest;
|
export default IExtensionConfigManifest;
|
||||||
|
|||||||
@ -1,13 +0,0 @@
|
|||||||
/**
|
|
||||||
* 扩展点:生成 build 文件
|
|
||||||
* (物料化场景)
|
|
||||||
*/
|
|
||||||
type IExtensionGenerateBuildJS = (params: {
|
|
||||||
buildFilePath: string; // 文件默认路径
|
|
||||||
buildFileContent: string; // 文件内容
|
|
||||||
}) => Promise<{
|
|
||||||
buildFilePath: string;
|
|
||||||
buildFileContent: string;
|
|
||||||
}>;
|
|
||||||
|
|
||||||
export default IExtensionGenerateBuildJS;
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
import { IMaterialinSchema } from '../otter-core';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 扩展点:加载物料(物料接入场景)
|
|
||||||
*
|
|
||||||
* @interface IExtensionLoadMaterials
|
|
||||||
*/
|
|
||||||
type IExtensionLoadMaterials = (
|
|
||||||
pkgNameList: string[],
|
|
||||||
) => Promise<IMaterialinSchema[]>;
|
|
||||||
|
|
||||||
export default IExtensionLoadMaterials;
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { IMaterialinSchema } from '../otter-core';
|
import { IComponentMaterial } from '../otter-core';
|
||||||
import IMaterialParsedModel from './IMaterialParsedModel';
|
import IMaterialParsedModel from './IMaterialParsedModel';
|
||||||
import IMaterialScanModel from './IMaterialScanModel';
|
import IMaterialScanModel from './IMaterialScanModel';
|
||||||
|
|
||||||
@ -16,5 +16,5 @@ export default interface IGenerator {
|
|||||||
generate(
|
generate(
|
||||||
matScanModel: IMaterialScanModel,
|
matScanModel: IMaterialScanModel,
|
||||||
matParsedModels: IMaterialParsedModel[],
|
matParsedModels: IMaterialParsedModel[],
|
||||||
): Promise<IMaterialinSchema>;
|
): Promise<IComponentMaterial>;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,23 +0,0 @@
|
|||||||
import ExtensionName from './ExtensionName';
|
|
||||||
import IExtensionLoadMaterials from './IExtensionLoadMaterials';
|
|
||||||
|
|
||||||
interface IMaterialInOptions {
|
|
||||||
/**
|
|
||||||
* 配置从哪些 CDN 加载组件
|
|
||||||
* (当 channel=online 时生效)
|
|
||||||
* 形如:
|
|
||||||
* https://unpkg.alibaba-inc.com/
|
|
||||||
* https://unpkg.com/
|
|
||||||
* https://cdn.jsdelivr.net/npm/
|
|
||||||
*/
|
|
||||||
cdn?: string[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 扩展点
|
|
||||||
*/
|
|
||||||
extensions?: {
|
|
||||||
[ExtensionName.LOADMATERIALS]?: IExtensionLoadMaterials;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export default IMaterialInOptions;
|
|
||||||
@ -1,8 +1,5 @@
|
|||||||
import ExtensionName from './ExtensionName';
|
import ExtensionName from './ExtensionName';
|
||||||
import IExtensionBuildBundle from './IExtensionBuildBundle';
|
|
||||||
import IExtensionConfigContainer from './IExtensionConfigContainer';
|
|
||||||
import IExtensionConfigManifest from './IExtensionConfigManifest';
|
import IExtensionConfigManifest from './IExtensionConfigManifest';
|
||||||
import IExtensionGenerateBuildJS from './IExtensionGenerateBuildJS';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物料化配置项
|
* 物料化配置项
|
||||||
@ -45,9 +42,6 @@ interface IMaterializeOptions {
|
|||||||
*/
|
*/
|
||||||
extensions?: {
|
extensions?: {
|
||||||
[ExtensionName.CONFIGMANIFEST]?: IExtensionConfigManifest;
|
[ExtensionName.CONFIGMANIFEST]?: IExtensionConfigManifest;
|
||||||
[ExtensionName.CONFIGCONTAINER]?: IExtensionConfigContainer;
|
|
||||||
[ExtensionName.BUILDBUNDLE]?: IExtensionBuildBundle;
|
|
||||||
[ExtensionName.GENERATEBUILDJS]?: IExtensionGenerateBuildJS;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -3,12 +3,8 @@ import EcologyType from './EcologyType';
|
|||||||
import ExtensionName from './ExtensionName';
|
import ExtensionName from './ExtensionName';
|
||||||
import IAccesser from './IAccesser';
|
import IAccesser from './IAccesser';
|
||||||
import ICompiler from './ICompiler';
|
import ICompiler from './ICompiler';
|
||||||
import IExtensionBuildBundle from './IExtensionBuildBundle';
|
|
||||||
import IExtensionConfigContainer from './IExtensionConfigContainer';
|
|
||||||
import IExtensionConfigManifest from './IExtensionConfigManifest';
|
import IExtensionConfigManifest from './IExtensionConfigManifest';
|
||||||
import IExtensionLoadMaterials from './IExtensionLoadMaterials';
|
|
||||||
import IGenerator from './IGenerator';
|
import IGenerator from './IGenerator';
|
||||||
import IMaterialInOptions from './IMaterialInOptions';
|
|
||||||
import IMaterializeOptions from './IMaterializeOptions';
|
import IMaterializeOptions from './IMaterializeOptions';
|
||||||
import IMaterialParsedModel from './IMaterialParsedModel';
|
import IMaterialParsedModel from './IMaterialParsedModel';
|
||||||
import IMaterialScanModel from './IMaterialScanModel';
|
import IMaterialScanModel from './IMaterialScanModel';
|
||||||
@ -22,10 +18,6 @@ export {
|
|||||||
IScanner,
|
IScanner,
|
||||||
ExtensionName,
|
ExtensionName,
|
||||||
IExtensionConfigManifest,
|
IExtensionConfigManifest,
|
||||||
IExtensionConfigContainer,
|
|
||||||
IExtensionLoadMaterials,
|
|
||||||
IExtensionBuildBundle,
|
|
||||||
IMaterialInOptions,
|
|
||||||
IMaterializeOptions,
|
IMaterializeOptions,
|
||||||
IMaterialScanModel,
|
IMaterialScanModel,
|
||||||
IMaterialParsedModel,
|
IMaterialParsedModel,
|
||||||
|
|||||||
179
packages/material-parser/src/validate/schema.d.ts
vendored
Normal file
179
packages/material-parser/src/validate/schema.d.ts
vendored
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
/* tslint:disable */
|
||||||
|
/**
|
||||||
|
* This file was automatically generated by json-schema-to-typescript.
|
||||||
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
||||||
|
* and run json-schema-to-typescript to regenerate this file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* json schema for low code component protocol
|
||||||
|
*/
|
||||||
|
export type ComponentMaterial = BasicSection & PropsSection & ConfigureSection;
|
||||||
|
export type PropType = BasicType | RequiredType | ComplexType;
|
||||||
|
export type BasicType =
|
||||||
|
| 'array'
|
||||||
|
| 'bool'
|
||||||
|
| 'func'
|
||||||
|
| 'number'
|
||||||
|
| 'object'
|
||||||
|
| 'string'
|
||||||
|
| 'node'
|
||||||
|
| 'element'
|
||||||
|
| 'any';
|
||||||
|
export type ComplexType =
|
||||||
|
| OneOf
|
||||||
|
| OneOfType
|
||||||
|
| ArrayOf
|
||||||
|
| ObjectOf
|
||||||
|
| Shape
|
||||||
|
| Exact;
|
||||||
|
export type ConfigureProp = {
|
||||||
|
title?: string;
|
||||||
|
extraProps?: {
|
||||||
|
[k: string]: any;
|
||||||
|
};
|
||||||
|
[k: string]: any;
|
||||||
|
} & (ConfigureFieldProp | ConfigureGroupProp);
|
||||||
|
|
||||||
|
export interface BasicSection {
|
||||||
|
componentName: string;
|
||||||
|
title: string;
|
||||||
|
description?: string;
|
||||||
|
docUrl: string;
|
||||||
|
screenshot: string;
|
||||||
|
icon?: string;
|
||||||
|
tags?: string[];
|
||||||
|
devMode?: 'proCode' | 'lowCode';
|
||||||
|
npm: Npm;
|
||||||
|
[k: string]: any;
|
||||||
|
}
|
||||||
|
export interface Npm {
|
||||||
|
package: string;
|
||||||
|
exportName: string;
|
||||||
|
subName: string;
|
||||||
|
main: string;
|
||||||
|
destructuring: boolean;
|
||||||
|
version: string;
|
||||||
|
[k: string]: any;
|
||||||
|
}
|
||||||
|
export interface PropsSection {
|
||||||
|
props?: {
|
||||||
|
name: string;
|
||||||
|
propType: PropType;
|
||||||
|
description?: string;
|
||||||
|
defaultValue?: any;
|
||||||
|
[k: string]: any;
|
||||||
|
}[];
|
||||||
|
[k: string]: any;
|
||||||
|
}
|
||||||
|
export interface RequiredType {
|
||||||
|
type: BasicType;
|
||||||
|
isRequired?: boolean;
|
||||||
|
}
|
||||||
|
export interface OneOf {
|
||||||
|
type: 'oneOf';
|
||||||
|
value: string[];
|
||||||
|
isRequired?: boolean;
|
||||||
|
[k: string]: any;
|
||||||
|
}
|
||||||
|
export interface OneOfType {
|
||||||
|
type: 'oneOfType';
|
||||||
|
value: PropType[];
|
||||||
|
isRequired?: boolean;
|
||||||
|
[k: string]: any;
|
||||||
|
}
|
||||||
|
export interface ArrayOf {
|
||||||
|
type: 'arrayOf';
|
||||||
|
value: PropType;
|
||||||
|
isRequired?: boolean;
|
||||||
|
[k: string]: any;
|
||||||
|
}
|
||||||
|
export interface ObjectOf {
|
||||||
|
type: 'objectOf';
|
||||||
|
value: PropType;
|
||||||
|
isRequired?: boolean;
|
||||||
|
[k: string]: any;
|
||||||
|
}
|
||||||
|
export interface Shape {
|
||||||
|
type: 'shape';
|
||||||
|
value: {
|
||||||
|
name?: string;
|
||||||
|
propType?: PropType;
|
||||||
|
}[];
|
||||||
|
isRequired?: boolean;
|
||||||
|
[k: string]: any;
|
||||||
|
}
|
||||||
|
export interface Exact {
|
||||||
|
type: 'exact';
|
||||||
|
value: {
|
||||||
|
name?: string;
|
||||||
|
propType?: PropType;
|
||||||
|
}[];
|
||||||
|
isRequired?: boolean;
|
||||||
|
[k: string]: any;
|
||||||
|
}
|
||||||
|
export interface ConfigureSection {
|
||||||
|
configure?: {
|
||||||
|
props?: ConfigureProp[];
|
||||||
|
styles?: {
|
||||||
|
[k: string]: any;
|
||||||
|
};
|
||||||
|
events?: {
|
||||||
|
[k: string]: any;
|
||||||
|
};
|
||||||
|
component?: ConfigureComponent;
|
||||||
|
[k: string]: any;
|
||||||
|
};
|
||||||
|
[k: string]: any;
|
||||||
|
}
|
||||||
|
export interface ConfigureFieldProp {
|
||||||
|
type: 'field';
|
||||||
|
name?: string;
|
||||||
|
setter?: ConfigureFieldSetter;
|
||||||
|
[k: string]: any;
|
||||||
|
}
|
||||||
|
export interface ConfigureFieldSetter {
|
||||||
|
componentName:
|
||||||
|
| 'List'
|
||||||
|
| 'Object'
|
||||||
|
| 'Function'
|
||||||
|
| 'Node'
|
||||||
|
| 'Mixin'
|
||||||
|
| 'Expression'
|
||||||
|
| 'Switch'
|
||||||
|
| 'Number'
|
||||||
|
| 'Input'
|
||||||
|
| 'TextArea'
|
||||||
|
| 'Date'
|
||||||
|
| 'DateYear'
|
||||||
|
| 'DateMonth'
|
||||||
|
| 'DateRange'
|
||||||
|
| 'ColorPicker'
|
||||||
|
| 'CodeEditor'
|
||||||
|
| 'Select'
|
||||||
|
| 'RadioGroup';
|
||||||
|
props?: {
|
||||||
|
[k: string]: any;
|
||||||
|
};
|
||||||
|
[k: string]: any;
|
||||||
|
}
|
||||||
|
export interface ConfigureGroupProp {
|
||||||
|
type: 'group';
|
||||||
|
items: ConfigureProp[];
|
||||||
|
[k: string]: any;
|
||||||
|
}
|
||||||
|
export interface ConfigureComponent {
|
||||||
|
isContainer?: boolean;
|
||||||
|
isModal?: boolean;
|
||||||
|
descriptor?: string;
|
||||||
|
nestingRule?: {
|
||||||
|
childWhitelist?: string[];
|
||||||
|
parentWhitelist?: string[];
|
||||||
|
descendantBlacklist?: string[];
|
||||||
|
ancestorWhitelist?: string[];
|
||||||
|
[k: string]: any;
|
||||||
|
};
|
||||||
|
isNullNode?: boolean;
|
||||||
|
isLayout?: boolean;
|
||||||
|
[k: string]: any;
|
||||||
|
}
|
||||||
@ -60,6 +60,9 @@
|
|||||||
},
|
},
|
||||||
"PropsSection": {
|
"PropsSection": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"props"
|
||||||
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
"props": {
|
"props": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user