feat: remove useless codes & modify generator

This commit is contained in:
gengyang 2020-02-16 22:26:26 +08:00
parent 44ac85f8a6
commit dcd1b33d3b
28 changed files with 440 additions and 514 deletions

View File

@ -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
allOf:
- $ref: "#/definitions/BasicSection"
@ -20,7 +20,7 @@ definitions:
type: string
icon:
type: string
tags:
tags:
type: array
items:
type: string
@ -38,12 +38,14 @@ definitions:
- screenshot
PropsSection:
type: object
required:
- props
properties:
props:
type: array
items:
properties:
name:
name:
type: string
propType:
$ref: "#/definitions/PropType"
@ -74,17 +76,17 @@ definitions:
Npm:
type: object
properties:
package:
package:
type: string
exportName:
exportName:
type: string
subName:
subName:
type: string
main:
main:
type: string
destructuring:
destructuring:
type: boolean
version:
version:
type: string
required:
- package
@ -98,7 +100,7 @@ definitions:
- $ref: "#/definitions/BasicType"
- $ref: "#/definitions/RequiredType"
- $ref: "#/definitions/ComplexType"
BasicType:
BasicType:
type: string
enum:
- array
@ -113,7 +115,7 @@ definitions:
RequiredType:
type: object
properties:
type:
type:
$ref: "#/definitions/BasicType"
isRequired:
type: boolean
@ -250,7 +252,7 @@ definitions:
allOf:
- type: object
properties:
title:
title:
type: string
extraProps:
type: object
@ -263,7 +265,7 @@ definitions:
required:
- type
properties:
type:
type:
type: string
enum:
- field
@ -306,7 +308,7 @@ definitions:
- type
- items
properties:
type:
type:
type: string
enum:
- group
@ -326,21 +328,21 @@ definitions:
nestingRule:
type: object
properties:
childWhitelist:
childWhitelist:
type: array
items:
items:
type: string
parentWhitelist:
type: array
items:
items:
type: string
descendantBlacklist:
descendantBlacklist:
type: array
items:
items:
type: string
ancestorWhitelist:
type: array
items:
items:
type: string
isNullNode:
type: boolean

View File

@ -2,19 +2,26 @@ const yaml = require('js-yaml');
const fs = require('fs');
const path = require('path');
const Ajv = require('ajv');
const { compile } = require('json-schema-to-typescript');
const ajv = new Ajv();
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
try {
const schema = yaml.load(fs.readFileSync(YamlPath, 'utf8'));
ajv.compile(schema);
fs.writeFileSync(JsonPath, JSON.stringify(schema, null, 2), 'utf-8');
console.log('yaml file is successfully transformed into json');
} catch (e) {
console.log(e);
process.exit(1);
}
(async function() {
try {
const schema = yaml.load(fs.readFileSync(YamlPath, 'utf8'));
ajv.compile(schema);
fs.writeFileSync(JsonPath, JSON.stringify(schema, null, 2), 'utf-8');
console.log('yaml file is successfully transformed into json');
const ts = await compile(schema, 'IComponentMaterial');
fs.writeFileSync(tsPath, ts);
console.log('schema.d.ts is successfully generated');
} catch (e) {
console.log(e);
process.exit(1);
}
})();

View File

@ -1,6 +1,6 @@
import LocalAccesser from './accesser/LocalAccesser';
import OnlineAccesser from './accesser/OnlineAccesser';
import { IMaterialinSchema } from './otter-core';
import { IComponentMaterial } from './otter-core';
import { IAccesser, IMaterializeOptions } from './types';
/**
@ -34,7 +34,7 @@ class Materialize {
* @returns {Promise<IMaterialinSchema>}
* @memberof Materialize
*/
public async start(): Promise<IMaterialinSchema> {
public async start(): Promise<IComponentMaterial> {
// 分发请求到对应接入器
if (this.options.accesser === 'local') {
this.accesser = new LocalAccesser(this.options);

View File

@ -1,4 +1,4 @@
import { IMaterialinSchema } from '../otter-core';
import { IComponentMaterial } from '../otter-core';
import { IAccesser, IMaterializeOptions } from '../types';
/**
@ -20,7 +20,7 @@ abstract class BaseAccesser implements IAccesser {
this.options = options;
}
public abstract access(): Promise<IMaterialinSchema>;
public abstract access(): Promise<IComponentMaterial>;
}
export default BaseAccesser;

View File

@ -1,5 +1,5 @@
import Generator from '../generator/Generator';
import { debug, IMaterialinSchema } from '../otter-core';
import { debug, IComponentMaterial } from '../otter-core';
import BaseParser from '../parser/BaseParser';
import ReactParser from '../parser/ReactParser';
import Scanner from '../scanner/Scanner';
@ -38,7 +38,7 @@ class LocalAccesser extends BaseAccesser {
*/
private generator!: Generator;
public async access(): Promise<IMaterialinSchema> {
public async access(): Promise<IComponentMaterial> {
await this.init();
// 开始扫描
const matScanModel: IMaterialScanModel = await this.scanner.scan();
@ -49,7 +49,7 @@ class LocalAccesser extends BaseAccesser {
);
log('matParsedModels', matParsedModels);
// 开始生产
const material: IMaterialinSchema = await this.generator.generate(
const material: IComponentMaterial = await this.generator.generate(
matScanModel,
matParsedModels,
);

View File

@ -3,7 +3,7 @@ import { ensureDir, ensureFile, writeFile } from 'fs-extra';
import { join } from 'path';
import semver from 'semver';
import uuid from 'short-uuid';
import { debug, IMaterialinSchema, OtterError } from '../otter-core';
import { debug, IComponentMaterial, OtterError } from '../otter-core';
import { IMaterializeOptions } from '../types';
import BaseAccesser from './BaseAccesser';
import LocalAccesser from './LocalAccesser';
@ -25,7 +25,7 @@ class OnlineAccesser extends BaseAccesser {
*/
private tempDir: string = '';
public async access(): Promise<IMaterialinSchema> {
public async access(): Promise<IComponentMaterial> {
// 创建临时目录
this.tempDir = await this.createTempDir();
// 创建组件包

View File

@ -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();
}

View File

@ -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,
};
}

View File

@ -1,5 +1,5 @@
import { writeFile } from 'fs-extra';
import { IMaterialinManifest } from '../otter-core';
import { IComponentMaterial } from '../otter-core';
/**
* manifest使
@ -8,29 +8,29 @@ import { IMaterialinManifest } from '../otter-core';
*
* @export
* @param {{
* manifestObj: IMaterialinManifest,
* manifestObj: IComponentMaterial,
* manifestFilePath: string,
* }} params
* @returns {Promise<{
* manifestJS: string,
* manifestFilePath: string,
* manifestObj: IMaterialinManifest,
* manifestObj: IComponentMaterial,
* }>}
*/
export default async function matConfigManifest(params: {
manifestObj: IMaterialinManifest;
manifestObj: IComponentMaterial;
manifestFilePath: string;
}): Promise<{
manifestJS: string;
manifestJSON: 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({
manifestJS,
manifestJSON,
manifestObj: params.manifestObj,
manifestFilePath: params.manifestFilePath,
});

View File

@ -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,
});
}

View File

@ -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([]);
}

View File

@ -1,12 +1,6 @@
import { ExtensionName } from '../types';
import MatBuildBundle from './MatBuildBundle';
import MatConfigContainer from './MatConfigContainer';
import MatConfigManifest from './MatConfigManifest';
import MatGenerateBuildJS from './MatGenerateBuildJS';
export default {
[ExtensionName.CONFIGMANIFEST]: MatConfigManifest,
[ExtensionName.BUILDBUNDLE]: MatBuildBundle,
[ExtensionName.CONFIGCONTAINER]: MatConfigContainer,
[ExtensionName.GENERATEBUILDJS]: MatGenerateBuildJS,
};

View File

@ -1,8 +1,12 @@
import { dirname, join } from 'path';
import defaultExtension from '../extensions';
import { debug, IMaterialinManifest, IMaterialinProp } from '../otter-core';
import {
ICompiler,
debug,
IComponentMaterial,
PropsSection,
PropType,
} from '../otter-core';
import {
IGenerator,
IMaterializeOptions,
IMaterialParsedModel,
@ -29,14 +33,6 @@ class Generator implements IGenerator {
*/
protected options!: IMaterializeOptions;
/**
*
* @protected
* @type {ICompiler}
* @memberof BaseGenerator
*/
protected compiler!: ICompiler;
constructor(options: IMaterializeOptions) {
this.options = options;
}
@ -62,7 +58,10 @@ class Generator implements IGenerator {
continue;
}
// 组装 manifest
const manifest: any = await this.genManifest(matParsedModel);
const manifest: any = await this.genManifest(
matScanModel,
matParsedModel,
);
containerList.push(manifest);
}
@ -95,21 +94,25 @@ class Generator implements IGenerator {
* @memberof LocalGenerator
*/
public async genManifest(
matScanModel: IMaterialScanModel,
matParsedModel: IMaterialParsedModel,
): Promise<{
manifestFilePath: string; // manifest 文件路径
manifestJS: string; // manifest 文件内容
manifestObj: IMaterialinManifest; // manifest 文件对象
manifestObj: IComponentMaterial; // manifest 文件对象
}> {
const manifestObj: IMaterialinManifest = {
name: matParsedModel.defaultExportName,
settings: {
type: 'element_inline',
insertionModes: 'tbrl',
handles: ['cut', 'copy', 'duplicate', 'delete', 'paste'],
shouldActive: true,
shouldDrag: true,
props: [],
const manifestObj: Partial<IComponentMaterial> = {
componentName: matParsedModel.defaultExportName,
title: '',
docUrl: '',
screenshot: '',
npm: {
package: matScanModel.pkgName,
version: matScanModel.pkgVersion,
exportName: matParsedModel.defaultExportName,
main: matScanModel.mainEntry,
destructuring: false,
subName: '',
},
};
@ -119,7 +122,7 @@ class Generator implements IGenerator {
);
// 填充 props
manifestObj.settings.props = this.populateProps(matParsedModel);
manifestObj.props = this.populateProps(matParsedModel);
// 执行扩展点
const manifest: any = await this.executeExtensionPoint(
'mat:config:manifest',
@ -145,17 +148,17 @@ class Generator implements IGenerator {
*/
public populateProps(
matParsedModel: IMaterialParsedModel,
): IMaterialinProp[] {
): PropsSection['props'] {
// 填充 props
const props: IMaterialinProp[] = [];
const props: PropsSection['props'] = [];
matParsedModel.propsTypes.forEach(item => {
const defaultValueItem = matParsedModel.propsDefaults.find(
inner => inner.name === item.name,
);
props.push({
name: item.name,
label: item.name,
renderer: '',
propType: item.type as PropType,
description: '',
defaultValue: defaultValueItem
? defaultValueItem.defaultValue
: undefined,

View File

@ -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.
*/
/**
*
*
* @export
* @interface IBasicSchema
* json schema for low code component protocol
*/
export interface IBasicSchema {
version: string; // 当前协议版本号
componentsMap: IComponentsMapItem[]; // 组件映射关系(用于描述 componentName 到公域组件映射关系的规范)
componentsTree: IComponentsTreeItem[]; // 描述模版/页面/区块/低代码业务组件的组件树(用于描述搭建出来的组件树结构的规范)
}
/**
* -
*
* @export
* @interface IComponentsMapItem
*/
export interface IComponentsMapItem {
componentName: string; // 组件名称
package: string; // 组件包的名称
version: string; // 组件包的版本
originalPackage: string; // 组件的原始包名称
originalVersion: string; // 组件的原始包版本
destructuring: boolean; // 组件是否是解构方式方式导出
exportName: string; // 导出命名
subName?: string; // 下标子组件名称
}
/**
* -
*
* @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;
export type IComponentMaterial = 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;
};
methods?: {
// 自定事件绑定
[methodName: string]: IJSExpression;
};
lifeCycles?: {
// 组件生命周期
didMount?: IJSExpression;
willMount?: IJSExpression;
};
}
[k: string]: any;
} & (ConfigureFieldProp | ConfigureGroupProp);
/**
* -
*
* @export
* @interface IComponentLifeCycle
*/
export interface IJSExpression {
type: 'JSExpression';
value: string;
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 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 {
// 包名
export interface Npm {
package: string;
// 版本号
exportName: string;
subName: string;
main: string;
destructuring: boolean;
version: string;
// 源版本号
originalVersion: string;
// 源组件包
originalPackage: string;
// 组件是否是 export 方式导出
defaultExportedName: string;
[k: string]: any;
}
/**
* -
*
* @export
* @interface IMaterialinComponent
*/
export interface IMaterialinComponent {
componentName: string; // 组件名
manifest: IMaterialinManifest; // 组件配置信息描述
origin: any; // 组件源
export interface PropsSection {
props: {
name: string;
propType: PropType;
description?: string;
defaultValue?: any;
[k: string]: any;
}[];
[k: string]: any;
}
/**
* -
*
* @export
* @interface IMaterialinManifest
*/
export interface IMaterialinManifest {
name: string; // 组件名
settings: IMaterialinSettings; // 定义组件的配置属性
description?: string; // 组件的描述
coverImage?: string; // 组件的封面图 URL
category?: string; // 组件的分类
presets?: IMaterialinPreset[]; // 定义组件左侧预览信息
export interface RequiredType {
type: BasicType;
isRequired?: boolean;
}
/**
* -
*
* @export
* @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 OneOf {
type: 'oneOf';
value: string[];
isRequired?: boolean;
[k: string]: any;
}
/**
* -
*
* @export
* @interface IMaterialinPreset
*/
export interface IMaterialinPreset {
alias: string; // 组件的别名
thumbnail: string; // 组件的预览缩略图 URL
colSpan?: number; // 代表组件所占栅格数
customProps?: object; // 自定义属性值
export interface OneOfType {
type: 'oneOfType';
value: PropType[];
isRequired?: boolean;
[k: string]: any;
}
/**
* -
*
* @export
* @interface IMaterialinProp
*/
export interface IMaterialinProp {
name: string; // 属性名
label: string; // 属性展示名称
renderer: string; // 属性编辑器类型
defaultValue?: any; // 属性默认值
params?: any; // 属性编辑器的参数
placeholder?: string; // 属性编辑器的 placeholder 信息
hint?: string; // 属性编辑器的提示信息(类似于 tooltip 效果),用于帮助用户理解属性的使用方法
export interface ArrayOf {
type: 'arrayOf';
value: PropType;
isRequired?: boolean;
[k: string]: any;
}
/**
* -
*
* @export
* @interface IMaterialinLifeCycle
*/
export interface IMaterialinLifeCycle {
didMount?: any; // 组件渲染完成后的钩子
didUpdate?: 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;
}

View File

@ -1,5 +1,3 @@
import { IBasicSchema } from './schema/types';
/**
*
* @export
@ -22,19 +20,3 @@ export interface IComponents {
[componentName: string]: any; // 组件
};
}
/**
*
* 使
*
* @export
* @interface IRenderInputData
*/
export interface IRenderInputData {
schema: IBasicSchema;
components: IComponents;
options?: {
domId?: string;
propsHooks?: { [propName: string]: any };
};
}

View File

@ -2,16 +2,8 @@
*
*/
enum ExtensionName {
/** 加载物料 */
LOADMATERIALS = 'mat:load:materials',
/** 配置 manifest */
CONFIGMANIFEST = 'mat:config:manifest',
/** 获取打包后的 bundle */
BUILDBUNDLE = 'mat:build:bundle',
/** 配置 containerJS */
CONFIGCONTAINER = 'mat:config:container',
/** 生成 buildJS */
GENERATEBUILDJS = 'mat:generate:buildjs',
}
export default ExtensionName;

View File

@ -1,4 +1,4 @@
import { IMaterialinSchema } from '../otter-core';
import { IComponentMaterial } from '../otter-core';
/**
*
@ -10,7 +10,7 @@ interface IAccesser {
* @returns {Promise<IMaterialinSchema>}
* @memberof IAccesser
*/
access(): Promise<IMaterialinSchema>;
access(): Promise<IComponentMaterial>;
}
export default IAccesser;

View File

@ -1,10 +0,0 @@
/**
* bundle
*
*/
type IExtensionBuildBundle = (params: {
bundleJS: string; // bundle 文件内容
bundleObj: { [key: string]: any }; // bundle 对象
}) => Promise<void>;
export default IExtensionBuildBundle;

View File

@ -1,13 +0,0 @@
/**
* container
*
*/
type IExtensionConfigContainer = (params: {
filePath: string; // container 文件默认路径
fileContent: string; // container 文件内容
}) => Promise<{
filePath: string;
fileContent: string;
}>;
export default IExtensionConfigContainer;

View File

@ -1,15 +1,15 @@
import { IMaterialinManifest } from '../otter-core';
import { IComponentMaterial } from '../otter-core';
/**
* manifest
*
*/
type IExtensionConfigManifest = (params: {
manifestObj: IMaterialinManifest; // manifest 配置对象
manifestObj: IComponentMaterial; // manifest 配置对象
manifestFilePath: string; // manifest 文件默认路径
}) => Promise<{
manifestJS: string; // manifest 文件内容
manifestJSON: string; // manifest 文件内容
manifestFilePath: string; // manifest 文件路径
manifestObj: IMaterialinManifest; // manifest 文件对象
manifestObj: IComponentMaterial; // manifest 文件对象
}>;
export default IExtensionConfigManifest;

View File

@ -1,13 +0,0 @@
/**
* build
*
*/
type IExtensionGenerateBuildJS = (params: {
buildFilePath: string; // 文件默认路径
buildFileContent: string; // 文件内容
}) => Promise<{
buildFilePath: string;
buildFileContent: string;
}>;
export default IExtensionGenerateBuildJS;

View File

@ -1,12 +0,0 @@
import { IMaterialinSchema } from '../otter-core';
/**
*
*
* @interface IExtensionLoadMaterials
*/
type IExtensionLoadMaterials = (
pkgNameList: string[],
) => Promise<IMaterialinSchema[]>;
export default IExtensionLoadMaterials;

View File

@ -1,4 +1,4 @@
import { IMaterialinSchema } from '../otter-core';
import { IComponentMaterial } from '../otter-core';
import IMaterialParsedModel from './IMaterialParsedModel';
import IMaterialScanModel from './IMaterialScanModel';
@ -16,5 +16,5 @@ export default interface IGenerator {
generate(
matScanModel: IMaterialScanModel,
matParsedModels: IMaterialParsedModel[],
): Promise<IMaterialinSchema>;
): Promise<IComponentMaterial>;
}

View File

@ -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;

View File

@ -1,8 +1,5 @@
import ExtensionName from './ExtensionName';
import IExtensionBuildBundle from './IExtensionBuildBundle';
import IExtensionConfigContainer from './IExtensionConfigContainer';
import IExtensionConfigManifest from './IExtensionConfigManifest';
import IExtensionGenerateBuildJS from './IExtensionGenerateBuildJS';
/**
*
@ -45,9 +42,6 @@ interface IMaterializeOptions {
*/
extensions?: {
[ExtensionName.CONFIGMANIFEST]?: IExtensionConfigManifest;
[ExtensionName.CONFIGCONTAINER]?: IExtensionConfigContainer;
[ExtensionName.BUILDBUNDLE]?: IExtensionBuildBundle;
[ExtensionName.GENERATEBUILDJS]?: IExtensionGenerateBuildJS;
};
/**

View File

@ -3,12 +3,8 @@ import EcologyType from './EcologyType';
import ExtensionName from './ExtensionName';
import IAccesser from './IAccesser';
import ICompiler from './ICompiler';
import IExtensionBuildBundle from './IExtensionBuildBundle';
import IExtensionConfigContainer from './IExtensionConfigContainer';
import IExtensionConfigManifest from './IExtensionConfigManifest';
import IExtensionLoadMaterials from './IExtensionLoadMaterials';
import IGenerator from './IGenerator';
import IMaterialInOptions from './IMaterialInOptions';
import IMaterializeOptions from './IMaterializeOptions';
import IMaterialParsedModel from './IMaterialParsedModel';
import IMaterialScanModel from './IMaterialScanModel';
@ -22,10 +18,6 @@ export {
IScanner,
ExtensionName,
IExtensionConfigManifest,
IExtensionConfigContainer,
IExtensionLoadMaterials,
IExtensionBuildBundle,
IMaterialInOptions,
IMaterializeOptions,
IMaterialScanModel,
IMaterialParsedModel,

View 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;
}

View File

@ -60,6 +60,9 @@
},
"PropsSection": {
"type": "object",
"required": [
"props"
],
"properties": {
"props": {
"type": "array",