diff --git a/packages/datasource-engine/.eslintignore b/packages/datasource-engine/.eslintignore
deleted file mode 100644
index fecb7c26d..000000000
--- a/packages/datasource-engine/.eslintignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/node_modules
-/es
-/lib
\ No newline at end of file
diff --git a/packages/datasource-engine/.eslintrc.js b/packages/datasource-engine/.eslintrc.js
deleted file mode 100644
index 6cbc6c8e9..000000000
--- a/packages/datasource-engine/.eslintrc.js
+++ /dev/null
@@ -1,8 +0,0 @@
-module.exports = {
- extends: '../../.eslintrc',
- rules: {
- '@typescript-eslint/no-parameter-properties': 0,
- 'no-param-reassign': 0,
- 'max-len': 0,
- },
-};
diff --git a/packages/datasource-engine/.gitignore b/packages/datasource-engine/.gitignore
deleted file mode 100644
index d3509362e..000000000
--- a/packages/datasource-engine/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-/node_modules/
-*.log
-.DS_Store
-/es/
-/lib/
-/dist
diff --git a/packages/datasource-engine/.prettierrc.js b/packages/datasource-engine/.prettierrc.js
deleted file mode 100644
index 21ec86215..000000000
--- a/packages/datasource-engine/.prettierrc.js
+++ /dev/null
@@ -1,5 +0,0 @@
-module.exports = {
- singleQuote: true,
- trailingComma: 'all',
- printWidth: 120,
-};
diff --git a/packages/datasource-engine/CHANGELOG.md b/packages/datasource-engine/CHANGELOG.md
deleted file mode 100644
index 210be5bbd..000000000
--- a/packages/datasource-engine/CHANGELOG.md
+++ /dev/null
@@ -1,144 +0,0 @@
-# Change Log
-
-All notable changes to this project will be documented in this file.
-See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
-
-
-## [1.0.22](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-engine@1.0.21...@ali/lowcode-datasource-engine@1.0.22) (2020-11-16)
-
-
-### Bug Fixes
-
-* datasource engine adpater ([52d0d88](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/52d0d88))
-
-
-
-
-
-## [1.0.21](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-engine@1.0.20...@ali/lowcode-datasource-engine@1.0.21) (2020-11-10)
-
-
-### Bug Fixes
-
-* 合并数据源引擎修复代码 ([53f3554](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/53f3554))
-
-
-
-
-
-## [1.0.20](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-engine@1.0.18...@ali/lowcode-datasource-engine@1.0.20) (2020-11-10)
-
-
-### Bug Fixes
-
-* add package json typings ([6378595](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6378595))
-* datasource package.json files 新增lib文件 ([a8a1749](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/a8a1749))
-
-
-### Features
-
-* update datasource engine ([bf7b7d1](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/bf7b7d1))
-
-
-
-
-
-## [1.0.18](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-engine@1.0.17...@ali/lowcode-datasource-engine@1.0.18) (2020-11-05)
-
-
-### Bug Fixes
-
-* datasource版本错误问题 ([a247878](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/a247878))
-
-
-
-
-
-## [1.0.17](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-engine@1.0.16...@ali/lowcode-datasource-engine@1.0.17) (2020-11-05)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-engine
-
-
-## [1.0.16](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-engine@1.0.15...@ali/lowcode-datasource-engine@1.0.16) (2020-11-05)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-engine
-
-
-## [1.0.15](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-engine@1.0.14...@ali/lowcode-datasource-engine@1.0.15) (2020-11-04)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-engine
-
-
-## [1.0.14](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-engine@0.1.17...@ali/lowcode-datasource-engine@1.0.14) (2020-11-04)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-engine
-
-
-## [1.0.13](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-engine@0.1.17...@ali/lowcode-datasource-engine@1.0.13) (2020-11-04)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-engine
-
-
-## [0.1.17](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-engine@0.1.16...@ali/lowcode-datasource-engine@0.1.17) (2020-11-02)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-engine
-
-
-## [0.1.16](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-engine@0.1.15...@ali/lowcode-datasource-engine@0.1.16) (2020-10-20)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-engine
-
-
-## [0.1.15](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-engine@0.1.14...@ali/lowcode-datasource-engine@0.1.15) (2020-10-19)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-engine
-
-
-## [0.1.14](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-engine@0.1.13...@ali/lowcode-datasource-engine@0.1.14) (2020-09-29)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-engine
-
-
-## [0.1.13](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-engine@0.1.12...@ali/lowcode-datasource-engine@0.1.13) (2020-09-28)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-engine
-
-
-## 0.1.12 (2020-09-28)
-
-
-### Features
-
-* 🎸 按 826 对齐结论调整出码和数据源引擎 ([b9a562e](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b9a562e))
-* 🎸 添加数据源引擎 ([624e2f8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/624e2f8))
-* 🎸 与国凯的数据源保持一致,将 urlParams 所需的 search 参数直接传入 ([19fabc1](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/19fabc1))
diff --git a/packages/datasource-engine/ava.config.js b/packages/datasource-engine/ava.config.js
deleted file mode 100644
index 987ecb184..000000000
--- a/packages/datasource-engine/ava.config.js
+++ /dev/null
@@ -1,8 +0,0 @@
-export default {
- babel: {
- compileEnhancements: false,
- },
- files: ['./test/core/*.ts', './test/scenes/**/*.test.ts'],
- require: ['ts-node/register/transpile-only'],
- extensions: ['ts'],
-};
diff --git a/packages/datasource-engine/interpret.d.ts b/packages/datasource-engine/interpret.d.ts
deleted file mode 100644
index b37fce092..000000000
--- a/packages/datasource-engine/interpret.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { create } from './dist/interpret';
diff --git a/packages/datasource-engine/interpret.js b/packages/datasource-engine/interpret.js
deleted file mode 100644
index 2cc45ddc7..000000000
--- a/packages/datasource-engine/interpret.js
+++ /dev/null
@@ -1 +0,0 @@
-module.exports = require('./dist/interpret/index');
diff --git a/packages/datasource-engine/package.json b/packages/datasource-engine/package.json
deleted file mode 100644
index 4ee8366eb..000000000
--- a/packages/datasource-engine/package.json
+++ /dev/null
@@ -1,39 +0,0 @@
-{
- "name": "@ali/lowcode-datasource-engine",
- "version": "1.0.23-alpha.2",
- "description": "DataSource Engine for lowcode",
- "main": "dist/index.js",
- "typings": "dist/index.d.ts",
- "files": [
- "dist",
- "src",
- "interpret*",
- "runtime*"
- ],
- "scripts": {
- "clean": "rm -rf dist",
- "build": "npm run clean && tsc ",
- "test": "ava",
- "prepublishOnly": "npm run build"
- },
- "dependencies": {
- "@ali/lowcode-datasource-types": "^1.0.21",
- "@ali/lowcode-types": "^1.0.20",
- "promise.allsettled": "^1.0.2",
- "typescript": "^3.9.7"
- },
- "devDependencies": {
- "@ava/babel": "^1.0.1",
- "@types/promise.allsettled": "^1.0.3",
- "@types/sinon": "^9.0.5",
- "ava": "3.11.1",
- "get-port": "^5.1.1",
- "json5": "^2.1.3",
- "sinon": "^9.0.3",
- "ts-node": "^8.10.2",
- "tslib": "^2.0.1"
- },
- "publishConfig": {
- "registry": "https://registry.npm.alibaba-inc.com"
- }
-}
diff --git a/packages/datasource-engine/readme.md b/packages/datasource-engine/readme.md
deleted file mode 100644
index d5be75f84..000000000
--- a/packages/datasource-engine/readme.md
+++ /dev/null
@@ -1,51 +0,0 @@
-## 关于 @ali/lc-datasource-engine
-
-低代码引擎数据源核心代码
-
-## doc
-
-[原理介绍](https://yuque.antfin-inc.com/docs/share/6ba9dab7-0712-4302-a5bb-b17d4a5f8505?# 《DataSource Engine》)
-
-
-[fetch流程图](https://yuque.antfin-inc.com/docs/share/e9baef9a-3586-40fc-8708-eaeee0d7937e?# 《fetch 流程》)
-
-
-## 使用
-
-```ts
-// 面向运行时渲染,直接给 schema
-import { create } from '@ali/lowcode-datasource-engine/interpret';
-
-// 面向出码,需要给处理过后的内容
-import { create } from '@ali/lowcode-datasource-engine/runtime';
-
-import { createFetchHandler } from '@ali/lowcode-datasource-fetch-handler';
-
-import { createMtopHandler } from '@ali/lowcode-datasource-mtop-handler';
-
-// dataSource 可以是 schema 协议内容 或者是运行时的转化后的配置内容 (出码专用)
-
-
-// context 上下文(setState 为必选)
-const dataSourceEngine = create(dataSource, context, {
- requestHandlersMap: { // 可选参数,以下内容为当前默认的内容
- urlParams: handlersMap.urlParams('?bar=1&test=2'),
- fetch: createFetchHandler,
- mtop: createMtopHandler
- },
-});
-
-
-console.log(dsf.dataSourceMap) // 符合集团协议的 datasourceMap https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#QUSn5
-
-dsf.dataSourceMap['id'].load() // 加载
-
-dsf.dataSourceMap['id'].status // 获取状态
-
-dsf.dataSourceMap['id'].data // 获取数据
-
-dsf.dataSourceMap['id'].error // 获取错误信息
-
-dsf.reloadDataSource(); // 刷新所有数据源
-
-```
diff --git a/packages/datasource-engine/runtime.d.ts b/packages/datasource-engine/runtime.d.ts
deleted file mode 100644
index 61344f9b4..000000000
--- a/packages/datasource-engine/runtime.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { create } from './dist/runtime';
diff --git a/packages/datasource-engine/runtime.js b/packages/datasource-engine/runtime.js
deleted file mode 100644
index 28f19824a..000000000
--- a/packages/datasource-engine/runtime.js
+++ /dev/null
@@ -1 +0,0 @@
-module.exports = require('./dist/runtime/index');
diff --git a/packages/datasource-engine/src/core/RuntimeDataSourceItem.ts b/packages/datasource-engine/src/core/RuntimeDataSourceItem.ts
deleted file mode 100644
index 5d71e2e1b..000000000
--- a/packages/datasource-engine/src/core/RuntimeDataSourceItem.ts
+++ /dev/null
@@ -1,143 +0,0 @@
-/* eslint-disable @typescript-eslint/indent */
-import {
- IDataSourceRuntimeContext,
- IRuntimeDataSource,
- RequestHandler,
- RuntimeDataSourceConfig,
- RuntimeDataSourceStatus,
- RuntimeOptionsConfig,
- UrlParamsHandler,
-} from '@ali/lowcode-types';
-
-class RuntimeDataSourceItem = Record, TResultData = unknown>
- implements IRuntimeDataSource {
- private _data?: TResultData;
-
- private _error?: Error;
-
- private _status = RuntimeDataSourceStatus.Initial;
-
- private _dataSourceConfig: RuntimeDataSourceConfig;
-
- private _request: RequestHandler<{ data: TResultData }> | UrlParamsHandler;
-
- private _context: IDataSourceRuntimeContext;
-
- private _options?: RuntimeOptionsConfig;
-
- constructor(
- dataSourceConfig: RuntimeDataSourceConfig,
- request: RequestHandler<{ data: TResultData }> | UrlParamsHandler,
- context: IDataSourceRuntimeContext,
- ) {
- this._dataSourceConfig = dataSourceConfig;
- this._request = request;
- this._context = context;
- }
-
- get data() {
- return this._data;
- }
-
- get error() {
- return this._error;
- }
-
- get status() {
- return this._status;
- }
-
- async load(params?: TParams) {
- if (!this._dataSourceConfig) return;
- // 考虑没有绑定对应的 handler 的情况
- if (!this._request) {
- this._error = new Error(`no ${this._dataSourceConfig.type} handler provide`);
- this._status = RuntimeDataSourceStatus.Error;
- throw this._error;
- }
-
- // TODO: urlParams 有没有更好的处理方式
- if (this._dataSourceConfig.type === 'urlParams') {
- const response = await (this._request as UrlParamsHandler)(this._context);
- this._context.setState({
- [this._dataSourceConfig.id]: response,
- });
-
- this._data = response;
- this._status = RuntimeDataSourceStatus.Loaded;
- return response;
- }
-
- if (!this._dataSourceConfig.options) {
- throw new Error(`${this._dataSourceConfig.id} has no options`);
- }
-
- if (typeof this._dataSourceConfig.options === 'function') {
- this._options = this._dataSourceConfig.options();
- }
-
- // 考虑转换之后是 null 的场景
- if (!this._options) {
- throw new Error(`${this._dataSourceConfig.id} options transform error`);
- }
-
- // 临时变量存,每次可能结果不一致,不做缓存
- let shouldFetch = true;
-
- if (this._dataSourceConfig.shouldFetch) {
- if (typeof this._dataSourceConfig.shouldFetch === 'function') {
- shouldFetch = this._dataSourceConfig.shouldFetch();
- } else if (typeof this._dataSourceConfig.shouldFetch === 'boolean') {
- shouldFetch = this._dataSourceConfig.shouldFetch;
- }
- }
-
- if (!shouldFetch) {
- this._status = RuntimeDataSourceStatus.Error;
- this._error = new Error(`the ${this._dataSourceConfig.id} request should not fetch, please check the condition`);
- throw this._error;
- }
-
- let fetchOptions = this._options;
-
- // willFetch
- try {
- fetchOptions = await this._dataSourceConfig.willFetch!(this._options);
- } catch (error) {
- console.error(error);
- }
-
- // 约定如果 params 有内容,直接做替换,如果没有就用默认的 options 的
- if (params && fetchOptions) {
- fetchOptions.params = params;
- }
-
- const dataHandler = this._dataSourceConfig.dataHandler!;
- const { errorHandler } = this._dataSourceConfig;
-
- // 调用实际的请求,获取到对应的数据和状态后赋值给当前的 dataSource
- try {
- this._status = RuntimeDataSourceStatus.Loading;
-
- // _context 会给传,但是用不用由 handler 说了算
- const result = await (this._request as RequestHandler<{
- data: TResultData;
- }>)(fetchOptions, this._context).then(dataHandler, errorHandler);
-
- // setState
- this._context.setState({
- [this._dataSourceConfig.id]: result,
- });
- // 结果赋值
- this._data = result;
- this._status = RuntimeDataSourceStatus.Loaded;
- return this._data;
- } catch (error) {
- this._error = error;
- this._status = RuntimeDataSourceStatus.Error;
- throw error;
- }
- }
-}
-
-export { RuntimeDataSourceItem };
diff --git a/packages/datasource-engine/src/core/adapter.ts b/packages/datasource-engine/src/core/adapter.ts
deleted file mode 100644
index 47bf48618..000000000
--- a/packages/datasource-engine/src/core/adapter.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-import { getRuntimeValueFromConfig, getRuntimeJsValue, buildOptions, buildShouldFetch } from './../utils';
-// 将不同渠道给的 schema 转为 runtime 需要的类型
-
-import { defaultDataHandler, defaultWillFetch } from '../helpers';
-import {
- DataSourceMap,
- IDataSourceRuntimeContext,
- InterpretDataSource,
- InterpretDataSourceConfig,
- RuntimeDataSourceConfig,
-} from '@ali/lowcode-types';
-
-const adapt2Runtime = (dataSource: InterpretDataSource, context: IDataSourceRuntimeContext) => {
- const { list: interpretConfigList, dataHandler: interpretDataHandler } = dataSource;
- const dataHandler: (dataMap?: DataSourceMap) => void = interpretDataHandler
- ? getRuntimeJsValue(interpretDataHandler, context)
- : undefined;
-
- // 为空判断
- if (!interpretConfigList || !interpretConfigList.length) {
- return {
- list: [],
- dataHandler,
- };
- }
- const list: RuntimeDataSourceConfig[] = interpretConfigList.map((el: InterpretDataSourceConfig) => {
- return {
- id: el.id,
- isInit: getRuntimeValueFromConfig('boolean', el.isInit, context), // 默认 true
- isSync: getRuntimeValueFromConfig('boolean', el.isSync, context), // 默认 false
- type: el.type || 'fetch',
- willFetch: el.willFetch ? getRuntimeJsValue(el.willFetch, context) : defaultWillFetch,
- shouldFetch: buildShouldFetch(el, context),
- dataHandler: el.dataHandler ? getRuntimeJsValue(el.dataHandler, context) : defaultDataHandler,
- errorHandler: el.errorHandler ? getRuntimeJsValue(el.errorHandler, context) : undefined,
- requestHandler: el.requestHandler ? getRuntimeJsValue(el.requestHandler, context) : undefined,
- options: buildOptions(el, context),
- };
- });
-
- return {
- list,
- dataHandler,
- };
-};
-
-export { adapt2Runtime };
diff --git a/packages/datasource-engine/src/core/index.ts b/packages/datasource-engine/src/core/index.ts
deleted file mode 100644
index 846867d09..000000000
--- a/packages/datasource-engine/src/core/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { RuntimeDataSourceItem } from './RuntimeDataSourceItem';
-export { adapt2Runtime } from './adapter';
diff --git a/packages/datasource-engine/src/core/reloadDataSourceFactory.ts b/packages/datasource-engine/src/core/reloadDataSourceFactory.ts
deleted file mode 100644
index 717837aed..000000000
--- a/packages/datasource-engine/src/core/reloadDataSourceFactory.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-import { DataSourceMap, RuntimeDataSource, RuntimeDataSourceConfig } from '@ali/lowcode-types';
-import allSettled from 'promise.allsettled';
-
-// 兼容低版本的浏览器
-const promiseSettled = typeof Promise.allSettled === 'function' ? Promise.allSettled.bind(Promise) : allSettled;
-
-export const reloadDataSourceFactory = (
- dataSource: RuntimeDataSource,
- dataSourceMap: DataSourceMap,
- dataHandler?: (dataSourceMap: DataSourceMap) => void,
-) => async () => {
- const allAsyncLoadings: Array> = [];
-
- // TODO: 那么,如果有新的类型过来,这个地方怎么处理???
- // 单独处理 urlParams 类型的
- dataSource.list
- .filter(
- (el: RuntimeDataSourceConfig) =>
- // eslint-disable-next-line implicit-arrow-linebreak
- el.type === 'urlParams' && (typeof el.isInit === 'boolean' ? el.isInit : true),
- )
- .forEach((el: RuntimeDataSourceConfig) => {
- dataSourceMap[el.id].load();
- });
-
- const remainRuntimeDataSourceList = dataSource.list.filter((el: RuntimeDataSourceConfig) => el.type !== 'urlParams');
-
- // 处理并行
- for (const ds of remainRuntimeDataSourceList) {
- if (!ds.options) {
- continue;
- }
- if (
- // 需要考虑出码直接不传值的情况
- ds.isInit &&
- !ds.isSync
- ) {
- allAsyncLoadings.push(dataSourceMap[ds.id].load());
- }
- }
-
- // 处理串行
- for (const ds of remainRuntimeDataSourceList) {
- if (!ds.options) {
- continue;
- }
-
- if (
- // 需要考虑出码直接不传值的情况
- ds.isInit &&
- ds.isSync
- ) {
- try {
- // eslint-disable-next-line no-await-in-loop
- await dataSourceMap[ds.id].load();
- } catch (e) {
- // TODO: 这个错误直接吃掉?
- console.error(e);
- }
- }
- }
-
- await promiseSettled(allAsyncLoadings);
-
- // 所有的初始化请求都结束之后,调用钩子函数
-
- if (dataHandler) {
- dataHandler(dataSourceMap);
- }
-};
diff --git a/packages/datasource-engine/src/helpers/index.ts b/packages/datasource-engine/src/helpers/index.ts
deleted file mode 100644
index 6202e61b2..000000000
--- a/packages/datasource-engine/src/helpers/index.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import {
- DataHandler,
- RequestHandler,
- RequestHandlersMap,
- RuntimeDataSourceConfig,
- RuntimeOptionsConfig,
- UrlParamsHandler,
- WillFetch,
-} from '@ali/lowcode-types';
-
-// 默认的 dataSourceItem 的 dataHandler
-export const defaultDataHandler: DataHandler = async (response: { data: T }) => response.data;
-
-// 默认的 dataSourceItem 的 willFetch
-export const defaultWillFetch: WillFetch = (options: RuntimeOptionsConfig) => options;
-
-// 默认的 dataSourceItem 的 shouldFetch
-export const defaultShouldFetch = () => true;
-
-type GetRequestHandler = (
- ds: RuntimeDataSourceConfig,
- requestHandlersMap: RequestHandlersMap<{ data: T }>,
-) => RequestHandler<{ data: T }> | UrlParamsHandler;
-
-// 从当前 dataSourceItem 中获取 requestHandler
-export const getRequestHandler: GetRequestHandler = (ds, requestHandlersMap) => {
- if (ds.type === 'custom') {
- // 自定义类型处理
- return (ds.requestHandler as unknown) as RequestHandler<{ data: unknown }>; // 理论上这里应该是能强转的,就算为空,应该在 request 请求的时候触发失败
- }
- // type 协议默认值 fetch
- return requestHandlersMap[ds.type || 'fetch'];
-};
diff --git a/packages/datasource-engine/src/index.ts b/packages/datasource-engine/src/index.ts
deleted file mode 100644
index 560958856..000000000
--- a/packages/datasource-engine/src/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import createInterpret from './interpret/DataSourceEngineFactory';
-import createRuntime from './runtime/RuntimeDataSourceEngineFactory';
-
-export { createInterpret, createRuntime };
diff --git a/packages/datasource-engine/src/interpret/DataSourceEngineFactory.ts b/packages/datasource-engine/src/interpret/DataSourceEngineFactory.ts
deleted file mode 100644
index 15d4dc5d8..000000000
--- a/packages/datasource-engine/src/interpret/DataSourceEngineFactory.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-import { adapt2Runtime } from '../core/adapter';
-import { RuntimeDataSourceItem } from '../core/RuntimeDataSourceItem';
-import { reloadDataSourceFactory } from '../core/reloadDataSourceFactory';
-import {
- IDataSourceRuntimeContext,
- InterpretDataSource,
- IRuntimeDataSource,
- RequestHandlersMap,
- RuntimeDataSource,
- RuntimeDataSourceConfig,
-} from '@ali/lowcode-types';
-import { getRequestHandler } from '../helpers';
-
-/**
- * @param dataSource
- * @param context
- * @param extraConfig: { requestHandlersMap }
- */
-
-export default (
- dataSource: InterpretDataSource,
- context: IDataSourceRuntimeContext,
- extraConfig: {
- requestHandlersMap: RequestHandlersMap<{ data: unknown }>;
- } = { requestHandlersMap: {} },
-) => {
- const { requestHandlersMap } = extraConfig;
-
- const runtimeDataSource: RuntimeDataSource = adapt2Runtime(dataSource, context);
-
- const dataSourceMap = runtimeDataSource.list.reduce(
- (prev: Record, current: RuntimeDataSourceConfig) => {
- prev[current.id] = new RuntimeDataSourceItem(current, getRequestHandler(current, requestHandlersMap), context);
- return prev;
- },
- {},
- );
-
- return {
- dataSourceMap,
- reloadDataSource: reloadDataSourceFactory(runtimeDataSource, dataSourceMap, runtimeDataSource.dataHandler),
- };
-};
diff --git a/packages/datasource-engine/src/interpret/index.ts b/packages/datasource-engine/src/interpret/index.ts
deleted file mode 100644
index e139eac42..000000000
--- a/packages/datasource-engine/src/interpret/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import createInterpret from './DataSourceEngineFactory';
-
-export const create = createInterpret;
diff --git a/packages/datasource-engine/src/runtime/RuntimeDataSourceEngineFactory.ts b/packages/datasource-engine/src/runtime/RuntimeDataSourceEngineFactory.ts
deleted file mode 100644
index e1cdead62..000000000
--- a/packages/datasource-engine/src/runtime/RuntimeDataSourceEngineFactory.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-/* eslint-disable @typescript-eslint/indent */
-import {
- IRuntimeDataSource,
- IDataSourceRuntimeContext,
- RequestHandlersMap,
- RuntimeDataSourceConfig,
- RuntimeDataSource,
-} from '@ali/lowcode-types';
-
-import { RuntimeDataSourceItem } from '../core';
-import { reloadDataSourceFactory } from '../core/reloadDataSourceFactory';
-import { defaultDataHandler, defaultShouldFetch, defaultWillFetch, getRequestHandler } from '../helpers';
-
-/**
- * @param dataSource
- * @param context
- * @param extraConfig: { requestHandlersMap }
- */
-
-export default (
- dataSource: RuntimeDataSource,
- context: IDataSourceRuntimeContext,
- extraConfig: {
- requestHandlersMap: RequestHandlersMap<{ data: unknown }>;
- } = { requestHandlersMap: {} },
-) => {
- const { requestHandlersMap } = extraConfig;
-
- // TODO: 对于出码类型,需要做一层数据兼容,给一些必要的值设置默认值,先兜底几个必要的
- dataSource.list.forEach(ds => {
- ds.isInit = ds.isInit || true;
- ds.isSync = ds.isSync || false;
- // eslint-disable-next-line no-nested-ternary
- ds.shouldFetch = !ds.shouldFetch
- ? defaultShouldFetch
- : typeof ds.shouldFetch === 'function'
- ? ds.shouldFetch.bind(context)
- : ds.shouldFetch;
- ds.willFetch = ds.willFetch ? ds.willFetch.bind(context) : defaultWillFetch;
- ds.dataHandler = ds.dataHandler ? ds.dataHandler.bind(context) : defaultDataHandler;
- });
-
- const dataSourceMap = dataSource.list.reduce(
- (prev: Record, current: RuntimeDataSourceConfig) => {
- prev[current.id] = new RuntimeDataSourceItem(current, getRequestHandler(current, requestHandlersMap), context);
- return prev;
- },
- {},
- );
-
- return {
- dataSourceMap,
- reloadDataSource: reloadDataSourceFactory(dataSource, dataSourceMap, dataSource.dataHandler),
- };
-};
diff --git a/packages/datasource-engine/src/runtime/index.ts b/packages/datasource-engine/src/runtime/index.ts
deleted file mode 100644
index 8123c7207..000000000
--- a/packages/datasource-engine/src/runtime/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import createRuntime from './RuntimeDataSourceEngineFactory';
-
-export const create = createRuntime;
diff --git a/packages/datasource-engine/src/types/DataSourceConfig.ts b/packages/datasource-engine/src/types/DataSourceConfig.ts
deleted file mode 100644
index 8a3687834..000000000
--- a/packages/datasource-engine/src/types/DataSourceConfig.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { DataSourceConfigItem } from './DataSourceConfigItem';
-
-export type DataSourceConfig = {
- list?: DataSourceConfigItem[];
- dataHandler?: (dataMap: Record) => void | Promise;
-};
diff --git a/packages/datasource-engine/src/types/DataSourceConfigItem.ts b/packages/datasource-engine/src/types/DataSourceConfigItem.ts
deleted file mode 100644
index a8aa46965..000000000
--- a/packages/datasource-engine/src/types/DataSourceConfigItem.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { DataSourceOptions } from './DataSourceOptions';
-import { RequestHandler } from './RequestHandler';
-
-export type DataSourceConfigItem = {
- id: string;
- type: string;
- isInit?: boolean | (() => boolean | undefined);
-
- options?: DataSourceOptions | (() => DataSourceOptions | undefined);
-
- requestHandler?: RequestHandler;
-
- dataHandler?: (
- data: unknown | undefined,
- error: unknown | undefined,
- ) => unknown;
-};
diff --git a/packages/datasource-engine/src/types/DataSourceEngineOptions.ts b/packages/datasource-engine/src/types/DataSourceEngineOptions.ts
deleted file mode 100644
index f2fd84b1a..000000000
--- a/packages/datasource-engine/src/types/DataSourceEngineOptions.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { RequestHandler } from './RequestHandler';
-
-export type DataSourceEngineOptions = {
- requestHandlersMap?: {
- [dataSourceType: string]: RequestHandler;
- };
-};
diff --git a/packages/datasource-engine/src/types/DataSourceOptions.ts b/packages/datasource-engine/src/types/DataSourceOptions.ts
deleted file mode 100644
index 55a317496..000000000
--- a/packages/datasource-engine/src/types/DataSourceOptions.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-export type DataSourceOptions> = {
- uri?: string;
- params?: TParams;
- method?: string;
- isCors?: boolean;
- timeout?: number;
- headers?: Record;
- isSync?: boolean;
- [key: string]: unknown;
-};
diff --git a/packages/datasource-engine/src/types/DataSourceResponse.ts b/packages/datasource-engine/src/types/DataSourceResponse.ts
deleted file mode 100644
index 36bd45fff..000000000
--- a/packages/datasource-engine/src/types/DataSourceResponse.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export type DataSourceResponse = {
- data: TData;
-};
diff --git a/packages/datasource-engine/src/types/IDataSourceEngine.ts b/packages/datasource-engine/src/types/IDataSourceEngine.ts
deleted file mode 100644
index 4d19be842..000000000
--- a/packages/datasource-engine/src/types/IDataSourceEngine.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { IRuntimeDataSource } from './IRuntimeDataSource';
-
-export interface IDataSourceEngine {
- /** 数据源, key 是数据源的 ID */
- readonly dataSourceMap: Record;
-
- /** 重新加载所有的数据源 */
- reloadDataSource(): Promise;
-}
diff --git a/packages/datasource-engine/src/types/IDataSourceEngineFactory.ts b/packages/datasource-engine/src/types/IDataSourceEngineFactory.ts
deleted file mode 100644
index 4215049ea..000000000
--- a/packages/datasource-engine/src/types/IDataSourceEngineFactory.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { DataSourceConfig } from './DataSourceConfig';
-import { DataSourceEngineOptions } from './DataSourceEngineOptions';
-import { IDataSourceEngine } from './IDataSourceEngine';
-import { IRuntimeContext } from './IRuntimeContext';
-
-export interface IDataSourceEngineFactory {
- create(
- dataSourceConfig: DataSourceConfig,
- runtimeContext: IRuntimeContext,
- options?: DataSourceEngineOptions,
- ): IDataSourceEngine;
-}
diff --git a/packages/datasource-engine/src/types/IRuntimeContext.ts b/packages/datasource-engine/src/types/IRuntimeContext.ts
deleted file mode 100644
index a0cc022c9..000000000
--- a/packages/datasource-engine/src/types/IRuntimeContext.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import { IRuntimeDataSource } from './IRuntimeDataSource';
-
-/** 运行时上下文 */
-export interface IRuntimeContext<
- TState = Record
-> {
- /** 当前容器的状态 */
- readonly state: TState;
-
- /** 设置状态(浅合并) */
- setState(state: Partial): void;
-
- /** 数据源, key 是数据源的 ID */
- dataSourceMap: Record;
-
- /** 重新加载所有的数据源 */
- reloadDataSource(): Promise;
-
- /** 页面容器 */
- readonly page: IRuntimeContext & { props: Record };
-
- /** 低代码业务组件容器 */
- readonly component: IRuntimeContext & { props: Record };
-}
diff --git a/packages/datasource-engine/src/types/IRuntimeDataSource.ts b/packages/datasource-engine/src/types/IRuntimeDataSource.ts
deleted file mode 100644
index ccf133716..000000000
--- a/packages/datasource-engine/src/types/IRuntimeDataSource.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { RuntimeDataSourceStatus } from './RuntimeDataSourceStatus';
-
-/**
- * 运行时的数据源(对外暴露的接口)
- * @see https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#Jwgj5
- */
-export interface IRuntimeDataSource {
- /** 当前状态(initial/loading/loaded/error) */
- readonly status: RuntimeDataSourceStatus;
-
- /** 加载成功时的数据 */
- readonly data?: TResultData;
-
- /** 加载出错的时候的错误信息 */
- readonly error?: Error;
-
- /**
- * 加载数据 (无论是否曾经加载过)
- * 注意:若提供 params,则会和默认配置的参数做浅合并;否则会使用默认配置的参数。
- */
- load(params?: TParams): Promise;
-}
diff --git a/packages/datasource-engine/src/types/RequestHandler.ts b/packages/datasource-engine/src/types/RequestHandler.ts
deleted file mode 100644
index c8a96f099..000000000
--- a/packages/datasource-engine/src/types/RequestHandler.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { DataSourceOptions } from './DataSourceOptions';
-import { DataSourceResponse } from './DataSourceResponse';
-
-export type RequestHandler<
- TOptions extends DataSourceOptions = DataSourceOptions,
- TResult extends DataSourceResponse = DataSourceResponse
-> = (options: TOptions) => Promise;
diff --git a/packages/datasource-engine/src/types/RuntimeDataSourceStatus.ts b/packages/datasource-engine/src/types/RuntimeDataSourceStatus.ts
deleted file mode 100644
index e089860ab..000000000
--- a/packages/datasource-engine/src/types/RuntimeDataSourceStatus.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-/** 数据源的状态 */
-export enum RuntimeDataSourceStatus {
- /** 初始状态,尚未加载 */
- Initial = 'init',
-
- /** 正在加载 */
- Loading = 'loading',
-
- /** 已加载(无错误) */
- Loaded = 'loaded',
-
- /** 加载出错了 */
- Error = 'error',
-}
diff --git a/packages/datasource-engine/src/types/index.ts b/packages/datasource-engine/src/types/index.ts
deleted file mode 100644
index 070f086bb..000000000
--- a/packages/datasource-engine/src/types/index.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-export * from './DataSourceConfig';
-export * from './DataSourceConfigItem';
-export * from './DataSourceEngineOptions';
-export * from './DataSourceOptions';
-export * from './IDataSourceEngine';
-export * from './IDataSourceEngineFactory';
-export * from './IRuntimeContext';
-export * from './IRuntimeDataSource';
-export * from './RequestHandler';
-export * from './RuntimeDataSourceStatus';
diff --git a/packages/datasource-engine/src/typing.d.ts b/packages/datasource-engine/src/typing.d.ts
deleted file mode 100644
index 2a2deec30..000000000
--- a/packages/datasource-engine/src/typing.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-declare module '@ali/universal-mtop';
diff --git a/packages/datasource-engine/src/typings.d.ts b/packages/datasource-engine/src/typings.d.ts
deleted file mode 100644
index d82d18b87..000000000
--- a/packages/datasource-engine/src/typings.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-declare module '@ali/mirror-io-client-mopen';
-declare module '@ali/mirror-io-client-mtop';
-declare module '@ali/mirror-io-client-universal-mtop';
diff --git a/packages/datasource-engine/src/utils.ts b/packages/datasource-engine/src/utils.ts
deleted file mode 100644
index f0109068d..000000000
--- a/packages/datasource-engine/src/utils.ts
+++ /dev/null
@@ -1,139 +0,0 @@
-/* eslint-disable no-new-func */
-
-import {
- CompositeValue,
- IDataSourceRuntimeContext,
- InterpretDataSourceConfig,
- isJSExpression,
- isJSFunction,
- JSExpression,
- JSFunction,
- JSONObject,
- RuntimeOptionsConfig,
-} from '@ali/lowcode-types';
-
-export const transformExpression = (code: string, context: IDataSourceRuntimeContext) => {
- try {
- return new Function(`return (${code})`).call(context);
- } catch (error) {
- console.error(`transformExpression error, code is ${code}, context is ${context}, error is ${error}`);
- }
-};
-
-export const transformFunction = (code: string, context: IDataSourceRuntimeContext) => {
- try {
- return new Function(`return (${code})`).call(context).bind(context);
- } catch (error) {
- console.error(`transformFunction error, code is ${code}, context is ${context}, error is ${error}`);
- }
-};
-
-export const transformBoolStr = (str: string) => {
- return str !== 'false';
-};
-
-export const getRuntimeJsValue = (value: JSExpression | JSFunction, context: IDataSourceRuntimeContext) => {
- if (!['JSExpression', 'JSFunction'].includes(value.type)) {
- console.error(`translate error, value is ${JSON.stringify(value)}`);
- return '';
- }
- // TODO: 类型修复
- const code = value.compiled || value.value;
- return value.type === 'JSFunction' ? transformFunction(code, context) : transformExpression(code, context);
-};
-
-export const getRuntimeBaseValue = (type: string, value: any) => {
- switch (type) {
- case 'string':
- return `${value}`;
- case 'boolean':
- return typeof value === 'string' ? transformBoolStr(value as string) : !!value;
- case 'number':
- return Number(value);
- default:
- return value;
- }
-};
-
-export const getRuntimeValueFromConfig = (type: string, value: CompositeValue, context: IDataSourceRuntimeContext) => {
- if (!value) return undefined;
- if (isJSExpression(value) || isJSFunction(value)) {
- return getRuntimeBaseValue(type, getRuntimeJsValue(value, context));
- }
- return value;
-};
-
-export const buildJsonObj = (params: JSONObject | JSExpression, context: IDataSourceRuntimeContext) => {
- const result: Record = {};
- if (isJSExpression(params)) {
- return transformExpression(params.value, context);
- }
- Object.keys(params).forEach((key: string) => {
- const currentParam: any = params[key];
- if (isJSExpression(currentParam)) {
- result[key] = transformExpression(currentParam.value, context);
- } else {
- result[key] = currentParam;
- }
- });
-
- return result;
-};
-
-export const buildShouldFetch = (ds: InterpretDataSourceConfig, context: IDataSourceRuntimeContext) => {
- if (!ds.options || !ds.shouldFetch) {
- return true; // 默认为 true
- }
- if (isJSExpression(ds.shouldFetch) || isJSFunction(ds.shouldFetch)) {
- return getRuntimeJsValue(ds.shouldFetch, context);
- }
-
- return getRuntimeBaseValue('boolean', ds.shouldFetch);
-};
-
-export const buildOptions = (ds: InterpretDataSourceConfig, context: IDataSourceRuntimeContext) => {
- const { options } = ds;
- if (!options) return undefined;
- // eslint-disable-next-line space-before-function-paren
- return function() {
- // 默认值
- const fetchOptions: RuntimeOptionsConfig = {
- uri: '',
- params: {},
- method: 'GET',
- isCors: true,
- timeout: 5000,
- headers: undefined,
- v: '1.0',
- };
- Object.keys(options).forEach((key: string) => {
- switch (key) {
- case 'uri':
- fetchOptions.uri = getRuntimeValueFromConfig('string', options.uri, context);
- break;
- case 'params':
- fetchOptions.params = buildJsonObj(options.params!, context);
- break;
- case 'method':
- fetchOptions.method = getRuntimeValueFromConfig('string', options.method, context);
- break;
- case 'isCors':
- fetchOptions.isCors = getRuntimeValueFromConfig('boolean', options.isCors, context);
- break;
- case 'timeout':
- fetchOptions.timeout = getRuntimeValueFromConfig('number', options.timeout, context);
- break;
- case 'headers':
- fetchOptions.headers = buildJsonObj(options.headers!, context);
- break;
- case 'v':
- fetchOptions.v = getRuntimeValueFromConfig('string', options.v, context);
- break;
- default:
- // 其余的除了做表达式或者 function 的转换,直接透传
- fetchOptions[key] = getRuntimeValueFromConfig('unknown', options[key], context);
- }
- });
- return fetchOptions;
- };
-};
diff --git a/packages/datasource-engine/test/_helpers/bind-runtime-context.ts b/packages/datasource-engine/test/_helpers/bind-runtime-context.ts
deleted file mode 100644
index d8c4d471e..000000000
--- a/packages/datasource-engine/test/_helpers/bind-runtime-context.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-export function bindRuntimeContext(x: T, ctx: U): T {
- if (typeof x === 'function') {
- return x.bind(ctx);
- }
-
- if (typeof x !== 'object') {
- return x;
- }
-
- if (x === null) {
- return null;
- }
-
- if (Array.isArray(x)) {
- return (x.map((item) => bindRuntimeContext(item, ctx)) as unknown) as T;
- }
-
- const res = {} as Record;
-
- Object.entries(x).forEach(([k, v]) => {
- res[k] = bindRuntimeContext(v, ctx);
- });
-
- return (res as unknown) as T;
-}
diff --git a/packages/datasource-engine/test/_helpers/delay.ts b/packages/datasource-engine/test/_helpers/delay.ts
deleted file mode 100644
index 81b6039c3..000000000
--- a/packages/datasource-engine/test/_helpers/delay.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export async function delay(ms: number = 0) {
- return new Promise((resolve) => setTimeout(resolve, ms));
-}
diff --git a/packages/datasource-engine/test/_helpers/index.ts b/packages/datasource-engine/test/_helpers/index.ts
deleted file mode 100644
index 3ef1ff216..000000000
--- a/packages/datasource-engine/test/_helpers/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export * from './mock-context';
-export * from './delay';
-export * from './bind-runtime-context';
diff --git a/packages/datasource-engine/test/_helpers/mock-context.ts b/packages/datasource-engine/test/_helpers/mock-context.ts
deleted file mode 100644
index 7b62f29b7..000000000
--- a/packages/datasource-engine/test/_helpers/mock-context.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-import {
- IDataSourceRuntimeContext,
- IDataSourceEngine
-} from '@ali/lowcode-types';
-
-export class MockContext = Record>
- implements IDataSourceRuntimeContext {
- private _dataSourceEngine: IDataSourceEngine;
-
- public constructor(
- private _state: TState,
- private _createDataSourceEngine: (
- context: IDataSourceRuntimeContext
- ) => IDataSourceEngine,
- private _customMethods: Record any> = {}
- ) {
- this._dataSourceEngine = _createDataSourceEngine(this);
-
- // 自定义方法
- Object.assign(this, _customMethods);
- }
-
- public get state() {
- return this._state;
- }
-
- public setState(state: Partial) {
- this._state = {
- ...this._state,
- ...state,
- };
- }
-
- public get dataSourceMap() {
- return this._dataSourceEngine.dataSourceMap;
- }
-
- public async reloadDataSource(): Promise {
- this._dataSourceEngine.reloadDataSource();
- }
-
- public get page(): any {
- throw new Error('this.page should not be accessed by datasource-engine');
- }
-
- public get component(): any {
- throw new Error(
- 'this.component should not be accessed by datasource-engine'
- );
- }
-
- [customMethod: string]: any;
-}
diff --git a/packages/datasource-engine/test/scenes/p0-0-custom-request-handlers/README.md b/packages/datasource-engine/test/scenes/p0-0-custom-request-handlers/README.md
deleted file mode 100644
index 355853ddd..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-custom-request-handlers/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# 关于此场景
-
-数据源的 type 可以是 `custom` 类型的, 此时需要提供 `requestHandler` 给数据源
diff --git a/packages/datasource-engine/test/scenes/p0-0-custom-request-handlers/_datasource-runtime.ts b/packages/datasource-engine/test/scenes/p0-0-custom-request-handlers/_datasource-runtime.ts
deleted file mode 100644
index fc46c3459..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-custom-request-handlers/_datasource-runtime.ts
+++ /dev/null
@@ -1,67 +0,0 @@
-import { RuntimeDataSource } from '@ali/lowcode-types';
-
-// 这里仅仅是数据源部分的:
-// @see: https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#XMeF5
-export const dataSource: RuntimeDataSource = {
- list: [
- {
- id: 'user',
- isInit: true,
- type: 'custom',
- isSync: true,
- requestHandler: options => {
- return new Promise(res => {
- setTimeout(() => {
- // test return data
- res({
- data: {
- id: 9527,
- name: 'Alice',
- uri: options.uri,
- },
- });
- }, 1000);
- });
- },
- options() {
- return {
- uri: 'https://mocks.alibaba-inc.com/user.json',
- };
- },
- },
- {
- id: 'orders',
- isInit: true,
- type: 'custom',
- isSync: true,
- requestHandler: () => {
- return new Promise((res, rej) => {
- setTimeout(() => {
- // test return data
- rej(new Error('test error'));
- }, 1000);
- });
- },
- options() {
- return {
- uri: 'https://mocks.alibaba-inc.com/orders.json',
- params: {
- userId: this.state.user.id,
- },
- };
- },
- },
- {
- // 这个 api 是假的,调不通的,当前场景是故意需要报错的
- id: 'members',
- isInit: true,
- type: 'custom',
- isSync: true,
- options() {
- return {
- uri: 'https://mocks.alibaba-inc.com/members.json',
- };
- },
- },
- ],
-};
diff --git a/packages/datasource-engine/test/scenes/p0-0-custom-request-handlers/_datasource-schema.ts b/packages/datasource-engine/test/scenes/p0-0-custom-request-handlers/_datasource-schema.ts
deleted file mode 100644
index 0a71914ca..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-custom-request-handlers/_datasource-schema.ts
+++ /dev/null
@@ -1,67 +0,0 @@
-import { InterpretDataSource } from '@ali/lowcode-types';
-
-// 这里仅仅是数据源部分的 schema:
-// @see: https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#XMeF5
-export const DATA_SOURCE_SCHEMA: InterpretDataSource = {
- list: [
- {
- id: 'user',
- isInit: true,
- type: 'custom',
- isSync: true,
- requestHandler: {
- type: 'JSFunction',
- value: `function(options){
- return new Promise(res => {
- setTimeout(() => {
- // test return data
- res({
- data: {
- id: 9527,
- name: 'Alice',
- uri: options.uri,
- }
- });
- }, 1000);
- });
- }`,
- },
- options: {
- uri: 'https://mocks.alibaba-inc.com/user.json',
- },
- },
- {
- id: 'orders',
- isInit: true,
- type: 'custom',
- isSync: true,
- requestHandler: {
- type: 'JSFunction',
- value: `function(options){
- return new Promise((res, rej) => {
- setTimeout(() => {
- // test return data
- return rej(new Error('test error'));
- }, 1000);
- });
- }`,
- },
- options: {
- uri: 'https://mocks.alibaba-inc.com/orders.json',
- params: {
- type: 'JSExpression',
- value: '{ userId: this.state.user.id }',
- },
- },
- },
- {
- id: 'members',
- isInit: true,
- type: 'custom',
- isSync: true,
- options: {
- uri: 'https://mocks.alibaba-inc.com/members.json',
- },
- },
- ],
-};
diff --git a/packages/datasource-engine/test/scenes/p0-0-custom-request-handlers/_macro-normal.ts b/packages/datasource-engine/test/scenes/p0-0-custom-request-handlers/_macro-normal.ts
deleted file mode 100644
index 1fe39c61e..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-custom-request-handlers/_macro-normal.ts
+++ /dev/null
@@ -1,90 +0,0 @@
-import {
- InterpretDataSource,
- IDataSourceEngine,
- IDataSourceRuntimeContext,
- RuntimeDataSource,
- RuntimeDataSourceStatus,
-} from '@ali/lowcode-types';
-import sinon from 'sinon';
-
-import { bindRuntimeContext, MockContext } from '../../_helpers';
-
-import type { ExecutionContext, Macro } from 'ava';
-import type { SinonFakeTimers } from 'sinon';
-
-export const normalScene: Macro<[
- {
- create: (
- dataSource: any,
- ctx: IDataSourceRuntimeContext,
- options?: any
- ) => IDataSourceEngine;
- dataSource: RuntimeDataSource | InterpretDataSource;
- }
-]> = async (
- t: ExecutionContext<{ clock: SinonFakeTimers }>,
- { create, dataSource },
-) => {
- const { clock } = t.context;
-
- const USER_DATA = {
- id: 9527,
- name: 'Alice',
- uri: 'https://mocks.alibaba-inc.com/user.json'
- };
- const ERROR_MSG = 'test error';
-
-
- const context = new MockContext>({}, (ctx) => create(bindRuntimeContext(dataSource, ctx), ctx));
-
- const setState = sinon.spy(context, 'setState');
-
- // 一开始应该是初始状态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Initial);
- t.is(context.dataSourceMap.orders.status, RuntimeDataSourceStatus.Initial);
- t.is(context.dataSourceMap.members.status, RuntimeDataSourceStatus.Initial);
-
- const loading = context.reloadDataSource();
-
- await clock.tickAsync(50);
-
- // 中间应该有 loading 态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Loading);
-
- await clock.tickAsync(1050);
-
- // 中间应该有 loading 态
- t.is(context.dataSourceMap.orders.status, RuntimeDataSourceStatus.Loading);
-
- await clock.tickAsync(1050);
-
- // members 因为没有 requestHandler 直接就挂了
- t.is(context.dataSourceMap.members.status, RuntimeDataSourceStatus.Error)
-
- await Promise.all([clock.runAllAsync(), loading]);
-
- // 最后 user 应该成功了,loaded
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Loaded);
- // 最后 orders 应该失败了,error 状态
- t.is(context.dataSourceMap.orders.status, RuntimeDataSourceStatus.Error);
-
- // 检查数据源的数据
- t.deepEqual(context.dataSourceMap.user.data, USER_DATA);
- t.is(context.dataSourceMap.user.error, undefined);
- t.deepEqual(context.dataSourceMap.orders.data, undefined);
- t.not(context.dataSourceMap.orders.error, undefined);
- t.deepEqual(context.dataSourceMap.members.data, undefined);
- t.not(context.dataSourceMap.members.error, undefined);
- t.regex(context.dataSourceMap.orders.error!.message, new RegExp(ERROR_MSG));
- t.regex(context.dataSourceMap.members.error!.message, new RegExp('no custom handler provide'));
-
-
-
- // 检查状态数据
- t.assert(setState.calledOnce);
- t.deepEqual(context.state.user, USER_DATA);
- t.is(context.state.orders, undefined);
- t.is(context.state.members, undefined);
-};
-
-normalScene.title = (providedTitle) => providedTitle || 'normal scene';
diff --git a/packages/datasource-engine/test/scenes/p0-0-custom-request-handlers/normal-interpret.test.ts b/packages/datasource-engine/test/scenes/p0-0-custom-request-handlers/normal-interpret.test.ts
deleted file mode 100644
index 9dac84e8d..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-custom-request-handlers/normal-interpret.test.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon, { SinonFakeTimers } from 'sinon';
-
-import { create } from '../../../src/interpret';
-
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-import { normalScene } from './_macro-normal';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(normalScene, {
- create,
- dataSource: DATA_SOURCE_SCHEMA,
-});
diff --git a/packages/datasource-engine/test/scenes/p0-0-custom-request-handlers/normal-runtime.test.ts b/packages/datasource-engine/test/scenes/p0-0-custom-request-handlers/normal-runtime.test.ts
deleted file mode 100644
index 761979c30..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-custom-request-handlers/normal-runtime.test.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon, { SinonFakeTimers } from 'sinon';
-
-import { create } from '../../../src/runtime';
-
-import { dataSource } from './_datasource-runtime';
-import { normalScene } from './_macro-normal';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(normalScene, {
- create,
- dataSource,
-});
diff --git a/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/README.md b/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/README.md
deleted file mode 100644
index e7ab03e28..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# 关于此场景
-
-这个是一个及其简单的场景 -- 就是直接调用 fetch,没有啥 dataHandler 之类的
diff --git a/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/_datasource-runtime.ts b/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/_datasource-runtime.ts
deleted file mode 100644
index 58002ead2..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/_datasource-runtime.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { RuntimeDataSource } from '@ali/lowcode-types';
-
-// 这里仅仅是数据源部分的:
-// @see: https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#XMeF5
-export const dataSource: RuntimeDataSource = {
- list: [
- {
- id: 'user',
- type: 'fetch',
- options: () => ({
- uri: 'https://mocks.alibaba-inc.com/user.json',
- }),
- },
- ],
-};
diff --git a/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/_datasource-schema.ts b/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/_datasource-schema.ts
deleted file mode 100644
index 848a85687..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/_datasource-schema.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { InterpretDataSource } from '@ali/lowcode-types';
-
-// 这里仅仅是数据源部分的 schema:
-// @see: https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#XMeF5
-export const DATA_SOURCE_SCHEMA: InterpretDataSource = {
- list: [
- {
- id: 'user',
- type: 'fetch',
- options: {
- uri: 'https://mocks.alibaba-inc.com/user.json',
- },
- },
- ],
-};
diff --git a/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/_macro-abnormal.ts b/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/_macro-abnormal.ts
deleted file mode 100644
index 78c0f5cb2..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/_macro-abnormal.ts
+++ /dev/null
@@ -1,72 +0,0 @@
-import {
- InterpretDataSource,
- IDataSourceEngine,
- IDataSourceRuntimeContext,
- RuntimeDataSource,
- RuntimeDataSourceStatus,
-} from '@ali/lowcode-types';
-import sinon from 'sinon';
-
-import { delay, MockContext } from '../../_helpers';
-// import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-
-import type { ExecutionContext, Macro } from 'ava';
-import type { SinonFakeTimers } from 'sinon';
-
-export const abnormalScene: Macro<[
- {
- create: (
- dataSource: any,
- ctx: IDataSourceRuntimeContext,
- options: any
- ) => IDataSourceEngine;
- dataSource: RuntimeDataSource | InterpretDataSource;
- }
-]> = async (
- t: ExecutionContext<{ clock: SinonFakeTimers }>,
- { create, dataSource },
- ) => {
- const { clock } = t.context;
- const ERROR_MSG = 'test error';
- const fetchHandler = sinon.fake(async () => {
- await delay(100);
- throw new Error(ERROR_MSG);
- });
-
- const context = new MockContext>({}, (ctx) => create(dataSource, ctx, {
- requestHandlersMap: {
- fetch: fetchHandler,
- },
- }));
-
- const setState = sinon.spy(context, 'setState');
-
- // 一开始应该是初始状态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Initial);
-
- const loading = context.reloadDataSource();
-
- await clock.tickAsync(50);
-
- // 中间应该有 loading 态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Loading);
-
- await Promise.all([clock.runAllAsync(), loading]);
-
- // 最后应该失败了,error 状态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Error);
-
- // 检查数据源的数据
- t.deepEqual(context.dataSourceMap.user.data, undefined);
- t.not(context.dataSourceMap.user.error, undefined);
- t.regex(context.dataSourceMap.user.error!.message, new RegExp(ERROR_MSG));
-
- // 检查状态数据
- t.assert(setState.notCalled);
- t.deepEqual(context.state.user, undefined);
-
- // fetchHandler 不应该被调
- t.assert(fetchHandler.calledOnce);
- };
-
-abnormalScene.title = (providedTitle) => providedTitle || 'abnormal scene';
diff --git a/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/_macro-normal.ts b/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/_macro-normal.ts
deleted file mode 100644
index 9d2a7e353..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/_macro-normal.ts
+++ /dev/null
@@ -1,81 +0,0 @@
-import {
- InterpretDataSource,
- IDataSourceEngine,
- IDataSourceRuntimeContext,
- RuntimeDataSource,
- RuntimeDataSourceStatus,
-} from '@ali/lowcode-types';
-import sinon from 'sinon';
-
-import { delay, MockContext } from '../../_helpers';
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-
-import type { ExecutionContext, Macro } from 'ava';
-import type { SinonFakeTimers } from 'sinon';
-
-export const normalScene: Macro<[
- {
- create: (
- dataSource: any,
- ctx: IDataSourceRuntimeContext,
- options: any
- ) => IDataSourceEngine;
- dataSource: RuntimeDataSource | InterpretDataSource;
- }
-]> = async (
- t: ExecutionContext<{ clock: SinonFakeTimers }>,
- { create, dataSource },
- ) => {
- const { clock } = t.context;
-
- const USER_DATA = {
- name: 'Alice',
- age: 18,
- };
-
- const fetchHandler = sinon.fake(async () => {
- await delay(100);
- return { data: USER_DATA };
- });
-
- const context = new MockContext>({}, (ctx) => create(dataSource, ctx, {
- requestHandlersMap: {
- fetch: fetchHandler,
- },
- }));
-
- const setState = sinon.spy(context, 'setState');
-
- // 一开始应该是初始状态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Initial);
-
- const loading = context.reloadDataSource();
-
- await clock.tickAsync(50);
-
- // 中间应该有 loading 态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Loading);
-
- await Promise.all([clock.runAllAsync(), loading]);
-
- // 最后应该成功了,loaded 状态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Loaded);
-
- // 检查数据源的数据
- t.deepEqual(context.dataSourceMap.user.data, USER_DATA);
- t.deepEqual(context.dataSourceMap.user.error, undefined);
-
- // 检查状态数据
- t.assert(setState.calledOnce);
- t.deepEqual(context.state.user, USER_DATA);
-
- // fetchHandler 应该被调用了一次
- t.assert(fetchHandler.calledOnce);
-
- const firstListItemOptions = DATA_SOURCE_SCHEMA.list[0].options;
- const fetchHandlerCallArgs = fetchHandler.firstCall.args[0];
- // 检查调用参数
- t.is(firstListItemOptions.uri, fetchHandlerCallArgs.uri);
- };
-
-normalScene.title = (providedTitle) => providedTitle || 'normal scene';
diff --git a/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/abnormal-interpret.test.ts b/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/abnormal-interpret.test.ts
deleted file mode 100644
index 816523b10..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/abnormal-interpret.test.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon from 'sinon';
-
-import { create } from '../../../src/interpret';
-
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-import { abnormalScene } from './_macro-abnormal';
-
-import type { SinonFakeTimers } from 'sinon';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(abnormalScene, {
- create,
- dataSource: DATA_SOURCE_SCHEMA,
-});
diff --git a/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/abnormal-runtime.test.ts b/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/abnormal-runtime.test.ts
deleted file mode 100644
index c338af3b1..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/abnormal-runtime.test.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon, { SinonFakeTimers } from 'sinon';
-
-import { create } from '../../../src/runtime';
-
-import { dataSource } from './_datasource-runtime';
-import { abnormalScene } from './_macro-abnormal';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(abnormalScene, {
- create,
- dataSource,
-});
diff --git a/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/normal-interpret.test.ts b/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/normal-interpret.test.ts
deleted file mode 100644
index 9dac84e8d..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/normal-interpret.test.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon, { SinonFakeTimers } from 'sinon';
-
-import { create } from '../../../src/interpret';
-
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-import { normalScene } from './_macro-normal';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(normalScene, {
- create,
- dataSource: DATA_SOURCE_SCHEMA,
-});
diff --git a/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/normal-runtime.test.ts b/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/normal-runtime.test.ts
deleted file mode 100644
index 761979c30..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-simplest-defaults/normal-runtime.test.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon, { SinonFakeTimers } from 'sinon';
-
-import { create } from '../../../src/runtime';
-
-import { dataSource } from './_datasource-runtime';
-import { normalScene } from './_macro-normal';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(normalScene, {
- create,
- dataSource,
-});
diff --git a/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/README.md b/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/README.md
deleted file mode 100644
index 3aa7d33e4..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# 关于此场景
-
-有些场景下,多个数据源之间有依赖关系,这时候可以将其都设置为 `isSync: true`, 这样这些数据源就会按配置面板的顺序进行串行调用。
diff --git a/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/_datasource-runtime.ts b/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/_datasource-runtime.ts
deleted file mode 100644
index c5fe1194c..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/_datasource-runtime.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { RuntimeDataSource } from '@ali/lowcode-types';
-
-// 这里仅仅是数据源部分的:
-// @see: https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#XMeF5
-export const dataSource: RuntimeDataSource = {
- list: [
- {
- id: 'user',
- isInit: true,
- type: 'fetch',
- isSync: true,
- options() {
- return {
- uri: 'https://mocks.alibaba-inc.com/user.json',
- };
- },
- },
- {
- id: 'orders',
- isInit: true,
- type: 'fetch',
- isSync: true,
- options() {
- return {
- uri: 'https://mocks.alibaba-inc.com/orders.json',
- params: {
- userId: this.state.user.id,
- },
- };
- },
- },
- ],
-};
diff --git a/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/_datasource-schema.ts b/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/_datasource-schema.ts
deleted file mode 100644
index 2c75c180a..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/_datasource-schema.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import { InterpretDataSource } from '@ali/lowcode-types';
-
-// 这里仅仅是数据源部分的 schema:
-// @see: https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#XMeF5
-export const DATA_SOURCE_SCHEMA: InterpretDataSource = {
- list: [
- {
- id: 'user',
- isInit: true,
- type: 'fetch',
- isSync: true,
- options: {
- uri: 'https://mocks.alibaba-inc.com/user.json',
- },
- },
- {
- id: 'orders',
- isInit: true,
- type: 'fetch',
- isSync: true,
- options: {
- uri: 'https://mocks.alibaba-inc.com/orders.json',
- params: {
- type: 'JSExpression',
- value: '{ userId: this.state.user.id }',
- },
- },
- },
- ],
-};
diff --git a/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/_macro-abnormal.ts b/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/_macro-abnormal.ts
deleted file mode 100644
index f0fa43060..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/_macro-abnormal.ts
+++ /dev/null
@@ -1,96 +0,0 @@
-import {
- InterpretDataSource,
- IDataSourceEngine,
- IDataSourceRuntimeContext,
- RuntimeDataSource,
- RuntimeDataSourceStatus,
-} from '@ali/lowcode-types';
-import sinon from 'sinon';
-
-import { bindRuntimeContext, delay, MockContext } from '../../_helpers';
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-
-import type { ExecutionContext, Macro } from 'ava';
-import type { SinonFakeTimers } from 'sinon';
-
-export const abnormalScene: Macro<[
- {
- create: (
- dataSource: any,
- ctx: IDataSourceRuntimeContext,
- options: any
- ) => IDataSourceEngine;
- dataSource: RuntimeDataSource | InterpretDataSource;
- }
-]> = async (
- t: ExecutionContext<{ clock: SinonFakeTimers }>,
- { create, dataSource },
-) => {
- const { clock } = t.context;
-
- const USER_DATA = {
- id: 9527,
- name: 'Alice',
- };
- const ERROR_MSG = 'test error';
- const fetchHandler = sinon.fake(async ({ uri }) => {
- await delay(100);
- if (/user/.test(uri)) {
- return { data: USER_DATA };
- } else {
- throw new Error(ERROR_MSG);
- }
- });
-
- const context = new MockContext>({}, (ctx) => create(bindRuntimeContext(dataSource, ctx), ctx, {
- requestHandlersMap: {
- fetch: fetchHandler,
- },
- }));
-
- const setState = sinon.spy(context, 'setState');
-
- // 一开始应该是初始状态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Initial);
- t.is(context.dataSourceMap.orders.status, RuntimeDataSourceStatus.Initial);
-
- const loading = context.reloadDataSource();
-
- await clock.tickAsync(50);
-
- // 中间应该有 loading 态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Loading);
-
- await clock.tickAsync(50);
-
- t.is(context.dataSourceMap.orders.status, RuntimeDataSourceStatus.Loading);
-
- await Promise.all([clock.runAllAsync(), loading]);
-
- // 最后 user 应该成功了,loaded
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Loaded);
- // 最后 orders 应该失败了,error 状态
- t.is(context.dataSourceMap.orders.status, RuntimeDataSourceStatus.Error);
-
- // 检查数据源的数据
- t.deepEqual(context.dataSourceMap.user.data, USER_DATA);
- t.is(context.dataSourceMap.user.error, undefined);
- t.deepEqual(context.dataSourceMap.orders.data, undefined);
- t.not(context.dataSourceMap.orders.error, undefined);
- t.regex(context.dataSourceMap.orders.error!.message, new RegExp(ERROR_MSG));
-
- // 检查状态数据
- t.assert(setState.calledOnce);
- t.deepEqual(context.state.user, USER_DATA);
- t.is(context.state.orders, undefined);
-
- // fetchHandler 应该被调用了2次
- t.assert(fetchHandler.calledTwice);
-
- const firstListItemOptions = DATA_SOURCE_SCHEMA.list[0].options;
- const fetchHandlerCallArgs = fetchHandler.firstCall.args[0];
- // 检查调用参数
- t.is(firstListItemOptions.uri, fetchHandlerCallArgs.uri);
-};
-
-abnormalScene.title = (providedTitle) => providedTitle || 'abnormal scene';
diff --git a/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/_macro-normal.ts b/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/_macro-normal.ts
deleted file mode 100644
index c6a95c672..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/_macro-normal.ts
+++ /dev/null
@@ -1,92 +0,0 @@
-import {
- InterpretDataSource,
- IDataSourceEngine,
- IDataSourceRuntimeContext,
- RuntimeDataSource,
- RuntimeDataSourceStatus,
-} from '@ali/lowcode-types';
-import sinon from 'sinon';
-
-import { bindRuntimeContext, delay, MockContext } from '../../_helpers';
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-
-import type { ExecutionContext, Macro } from 'ava';
-import type { SinonFakeTimers } from 'sinon';
-
-export const normalScene: Macro<[
- {
- create: (
- dataSource: any,
- ctx: IDataSourceRuntimeContext,
- options: any
- ) => IDataSourceEngine;
- dataSource: RuntimeDataSource | InterpretDataSource;
- }
-]> = async (
- t: ExecutionContext<{ clock: SinonFakeTimers }>,
- { create, dataSource },
- ) => {
- const { clock } = t.context;
-
- const USER_DATA = {
- id: 9527,
- name: 'Alice',
- };
-
- const ORDERS_DATA = [{ id: 123 }, { id: 456 }];
-
- const fetchHandler = sinon.fake(async ({ uri }) => {
- await delay(100);
- return { data: /user/.test(uri) ? USER_DATA : ORDERS_DATA };
- });
-
- const context = new MockContext>({}, (ctx) => create(bindRuntimeContext(dataSource, ctx), ctx, {
- requestHandlersMap: {
- fetch: fetchHandler,
- },
- }));
-
- const setState = sinon.spy(context, 'setState');
-
- // 一开始应该是初始状态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Initial);
- t.is(context.dataSourceMap.orders.status, RuntimeDataSourceStatus.Initial);
-
- const loading = context.reloadDataSource();
-
- await clock.tickAsync(50);
-
- // 中间应该有 loading 态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Loading);
-
- await clock.tickAsync(50);
-
- t.is(context.dataSourceMap.orders.status, RuntimeDataSourceStatus.Loading);
-
- await Promise.all([clock.runAllAsync(), loading]);
-
- // 最后应该成功了,loaded 状态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Loaded);
- t.is(context.dataSourceMap.orders.status, RuntimeDataSourceStatus.Loaded);
-
- // 检查数据源的数据
- t.deepEqual(context.dataSourceMap.user.data, USER_DATA);
- t.deepEqual(context.dataSourceMap.user.error, undefined);
- t.deepEqual(context.dataSourceMap.orders.data, ORDERS_DATA);
- t.deepEqual(context.dataSourceMap.orders.error, undefined);
-
- // 检查状态数据
- t.assert(setState.calledTwice);
- t.deepEqual(context.state.user, USER_DATA);
- t.deepEqual(context.state.orders, ORDERS_DATA);
-
- // fetchHandler 应该被调用了2次
- t.assert(fetchHandler.calledTwice);
-
- // 检查调用参数
- const firstListItemOptions = DATA_SOURCE_SCHEMA.list[0].options;
- const fetchHandlerCallArgs = fetchHandler.firstCall.args[0];
- t.is(firstListItemOptions.uri, fetchHandlerCallArgs.uri);
- };
-
-normalScene.title = (providedTitle) => providedTitle || 'normal scene';
diff --git a/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/abnormal-interpret.test.ts b/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/abnormal-interpret.test.ts
deleted file mode 100644
index 816523b10..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/abnormal-interpret.test.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon from 'sinon';
-
-import { create } from '../../../src/interpret';
-
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-import { abnormalScene } from './_macro-abnormal';
-
-import type { SinonFakeTimers } from 'sinon';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(abnormalScene, {
- create,
- dataSource: DATA_SOURCE_SCHEMA,
-});
diff --git a/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/abnormal-runtime.test.ts b/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/abnormal-runtime.test.ts
deleted file mode 100644
index c338af3b1..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/abnormal-runtime.test.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon, { SinonFakeTimers } from 'sinon';
-
-import { create } from '../../../src/runtime';
-
-import { dataSource } from './_datasource-runtime';
-import { abnormalScene } from './_macro-abnormal';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(abnormalScene, {
- create,
- dataSource,
-});
diff --git a/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/normal-interpret.test.ts b/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/normal-interpret.test.ts
deleted file mode 100644
index 9dac84e8d..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/normal-interpret.test.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon, { SinonFakeTimers } from 'sinon';
-
-import { create } from '../../../src/interpret';
-
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-import { normalScene } from './_macro-normal';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(normalScene, {
- create,
- dataSource: DATA_SOURCE_SCHEMA,
-});
diff --git a/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/normal-runtime.test.ts b/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/normal-runtime.test.ts
deleted file mode 100644
index 761979c30..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-sync-datasources-dealt-in-serial/normal-runtime.test.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon, { SinonFakeTimers } from 'sinon';
-
-import { create } from '../../../src/runtime';
-
-import { dataSource } from './_datasource-runtime';
-import { normalScene } from './_macro-normal';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(normalScene, {
- create,
- dataSource,
-});
diff --git a/packages/datasource-engine/test/scenes/p0-0-url-params/README.md b/packages/datasource-engine/test/scenes/p0-0-url-params/README.md
deleted file mode 100644
index e7ab03e28..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-url-params/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# 关于此场景
-
-这个是一个及其简单的场景 -- 就是直接调用 fetch,没有啥 dataHandler 之类的
diff --git a/packages/datasource-engine/test/scenes/p0-0-url-params/_datasource-runtime.ts b/packages/datasource-engine/test/scenes/p0-0-url-params/_datasource-runtime.ts
deleted file mode 100644
index 09b060b49..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-url-params/_datasource-runtime.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { RuntimeDataSource } from '@ali/lowcode-types';
-
-// 这里仅仅是数据源部分的:
-// @see: https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#XMeF5
-export const dataSource: RuntimeDataSource = {
- list: [
- {
- id: 'urlParams',
- isInit: true,
- type: 'urlParams',
- },
- ],
-};
diff --git a/packages/datasource-engine/test/scenes/p0-0-url-params/_datasource-schema.ts b/packages/datasource-engine/test/scenes/p0-0-url-params/_datasource-schema.ts
deleted file mode 100644
index 20fcb2154..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-url-params/_datasource-schema.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { InterpretDataSource } from '@ali/lowcode-types';
-
-// 这里仅仅是数据源部分的 schema:
-// @see: https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#XMeF5
-export const DATA_SOURCE_SCHEMA: InterpretDataSource = {
- list: [
- {
- id: 'urlParams',
- isInit: true,
- type: 'urlParams',
- },
- ],
-};
diff --git a/packages/datasource-engine/test/scenes/p0-0-url-params/_macro-normal.ts b/packages/datasource-engine/test/scenes/p0-0-url-params/_macro-normal.ts
deleted file mode 100644
index 0156af315..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-url-params/_macro-normal.ts
+++ /dev/null
@@ -1,72 +0,0 @@
-import {
- InterpretDataSource,
- IDataSourceEngine,
- IDataSourceRuntimeContext,
- RuntimeDataSource,
- RuntimeDataSourceStatus,
-} from '@ali/lowcode-types';
-import sinon from 'sinon';
-
-import { MockContext } from '../../_helpers';
-
-import type { ExecutionContext, Macro } from 'ava';
-import type { SinonFakeTimers } from 'sinon';
-
-export const normalScene: Macro<[
- {
- create: (
- dataSource: any,
- ctx: IDataSourceRuntimeContext,
- options: any
- ) => IDataSourceEngine;
- dataSource: RuntimeDataSource | InterpretDataSource;
- }
-]> = async (
- t: ExecutionContext<{ clock: SinonFakeTimers }>,
- { create, dataSource },
- ) => {
- const { clock } = t.context;
-
- const URL_PARAMS = {
- name: 'Alice',
- age: '18',
- };
-
- const urlParamsHandler = sinon.fake(async () => {
- return URL_PARAMS; // TODO: 别的都是返回的套了一层 data 的,但是 urlParams 的为啥不一样?
- });
-
- const context = new MockContext>({}, (ctx) => create(dataSource, ctx, {
- requestHandlersMap: {
- urlParams: urlParamsHandler,
- },
- }));
-
- const setState = sinon.spy(context, 'setState');
-
- // 一开始应该是初始状态
- t.is(context.dataSourceMap.urlParams.status, RuntimeDataSourceStatus.Initial);
-
- const loading = context.reloadDataSource();
-
- await Promise.all([clock.runAllAsync(), loading]);
-
- // 最后应该成功了,loaded 状态
- t.is(context.dataSourceMap.urlParams.status, RuntimeDataSourceStatus.Loaded);
-
- // 检查数据源的数据
- t.deepEqual(context.dataSourceMap.urlParams.data, URL_PARAMS);
- t.deepEqual(context.dataSourceMap.urlParams.error, undefined);
-
- // 检查状态数据
- t.assert(setState.calledOnce);
- t.deepEqual(context.state.urlParams, URL_PARAMS);
-
- // fetchHandler 应该被调用了一次
- t.assert(urlParamsHandler.calledOnce);
-
- // 检查调用参数 url 没有 options
- t.deepEqual(urlParamsHandler.firstCall.args, [context]);
- };
-
-normalScene.title = (providedTitle) => providedTitle || 'normal scene';
diff --git a/packages/datasource-engine/test/scenes/p0-0-url-params/normal-interpret.test.ts b/packages/datasource-engine/test/scenes/p0-0-url-params/normal-interpret.test.ts
deleted file mode 100644
index 9dac84e8d..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-url-params/normal-interpret.test.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon, { SinonFakeTimers } from 'sinon';
-
-import { create } from '../../../src/interpret';
-
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-import { normalScene } from './_macro-normal';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(normalScene, {
- create,
- dataSource: DATA_SOURCE_SCHEMA,
-});
diff --git a/packages/datasource-engine/test/scenes/p0-0-url-params/normal-runtime.test.ts b/packages/datasource-engine/test/scenes/p0-0-url-params/normal-runtime.test.ts
deleted file mode 100644
index 761979c30..000000000
--- a/packages/datasource-engine/test/scenes/p0-0-url-params/normal-runtime.test.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon, { SinonFakeTimers } from 'sinon';
-
-import { create } from '../../../src/runtime';
-
-import { dataSource } from './_datasource-runtime';
-import { normalScene } from './_macro-normal';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(normalScene, {
- create,
- dataSource,
-});
diff --git a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/README.md b/packages/datasource-engine/test/scenes/p0-1-custom-response-status/README.md
deleted file mode 100644
index cccb18844..000000000
--- a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/README.md
+++ /dev/null
@@ -1,26 +0,0 @@
-# 关于此场景
-
-这个是一个很常见的场景 -- 查出来的数据里面套的还有一层数据,可能有异常状态得需要处理下。
-
-比如,期望的正常的数据应该是:
-
-```json
-{
- "success": true,
- "data": {
- // ...
- }
-}
-```
-
-而异常场景下,服务端会返回:
-
-```json
-{
- "success": false,
- "message": "这是错误原因",
- "code": "错误码"
-}
-```
-
--- 这时候期望有异常监控埋点。
diff --git a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/_datasource-runtime.ts b/packages/datasource-engine/test/scenes/p0-1-custom-response-status/_datasource-runtime.ts
deleted file mode 100644
index 4b06ca7b8..000000000
--- a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/_datasource-runtime.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import { RuntimeDataSource } from '@ali/lowcode-types';
-
-// 这里仅仅是数据源部分的:
-// @see: https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#XMeF5
-export const dataSource: RuntimeDataSource = {
- list: [
- {
- id: 'user',
- isInit: true,
- type: 'fetch',
- options: () => ({
- uri: 'https://mocks.alibaba-inc.com/user.json',
- }),
- dataHandler: function dataHandler(response: any) {
- const { data } = response;
- if (!data) {
- throw new Error('empty data!');
- }
-
- if (data.success) {
- return data.data;
- }
-
- this.recordError({ type: 'FETCH_ERROR', detail: data });
-
- throw new Error(data.message);
- },
- },
- ],
-};
diff --git a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/_datasource-schema.ts b/packages/datasource-engine/test/scenes/p0-1-custom-response-status/_datasource-schema.ts
deleted file mode 100644
index 2352df683..000000000
--- a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/_datasource-schema.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { InterpretDataSource } from '@ali/lowcode-types';
-
-// 这里仅仅是数据源部分的 schema:
-// @see: https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#XMeF5
-export const DATA_SOURCE_SCHEMA: InterpretDataSource = {
- list: [
- {
- id: 'user',
- isInit: true,
- type: 'fetch',
- options: {
- uri: 'https://mocks.alibaba-inc.com/user.json',
- },
- dataHandler: {
- type: 'JSFunction',
- value: `
-function dataHandler(response){
- const { data } = response;
- if (!data) {
- throw new Error('empty data!');
- }
-
- if (data.success){
- return data.data;
- }
-
- this.recordError({ type: 'FETCH_ERROR', detail: data });
-
- throw new Error(data.message);
-}
-`,
- },
- },
- ],
-};
diff --git a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/_macro-abnormal.ts b/packages/datasource-engine/test/scenes/p0-1-custom-response-status/_macro-abnormal.ts
deleted file mode 100644
index a07619bd4..000000000
--- a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/_macro-abnormal.ts
+++ /dev/null
@@ -1,95 +0,0 @@
-import {
- InterpretDataSource,
- IDataSourceEngine,
- IDataSourceRuntimeContext,
- RuntimeDataSource,
- RuntimeDataSourceStatus,
-} from '@ali/lowcode-types';
-import sinon from 'sinon';
-
-import { bindRuntimeContext, delay, MockContext } from '../../_helpers';
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-
-import type { ExecutionContext, Macro } from 'ava';
-import type { SinonFakeTimers } from 'sinon';
-
-export const abnormalScene: Macro<[
- {
- create: (
- dataSource: any,
- ctx: IDataSourceRuntimeContext,
- options: any
- ) => IDataSourceEngine;
- dataSource: RuntimeDataSource | InterpretDataSource;
- }
-]> = async (
- t: ExecutionContext<{ clock: SinonFakeTimers }>,
- { create, dataSource },
- ) => {
- const { clock } = t.context;
- const ERROR_MSG = 'test error';
- const fetchHandler = sinon.fake(async () => {
- await delay(100);
- return {
- data: {
- success: false,
- message: ERROR_MSG,
- code: 'E_FOO',
- },
- };
- });
-
- const context = new MockContext>(
- {},
- (ctx) => create(bindRuntimeContext(dataSource, ctx), ctx, {
- requestHandlersMap: {
- fetch: fetchHandler,
- },
- }),
- {
- recordError() { },
- },
- );
-
- const setState = sinon.spy(context, 'setState');
- const recordError = sinon.spy(context, 'recordError');
-
- // 一开始应该是初始状态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Initial);
-
- const loading = context.reloadDataSource();
-
- await clock.tickAsync(50);
-
- // 中间应该有 loading 态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Loading);
-
- await Promise.all([clock.runAllAsync(), loading]);
-
- // 最后应该失败了,error 状态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Error);
-
- // 检查数据源的数据
- t.deepEqual(context.dataSourceMap.user.data, undefined);
- t.not(context.dataSourceMap.user.error, undefined);
-
- t.regex(context.dataSourceMap.user.error!.message, new RegExp(ERROR_MSG));
-
- // 检查状态数据
- t.assert(setState.notCalled);
- t.deepEqual(context.state.user, undefined);
-
- // fetchHandler 应该被调用了一次
- t.assert(fetchHandler.calledOnce);
-
- // 检查调用参数
- const firstListItemOptions = DATA_SOURCE_SCHEMA.list[0].options;
- const fetchHandlerCallArgs = fetchHandler.firstCall.args[0];
- t.is(firstListItemOptions.uri, fetchHandlerCallArgs.uri);
-
- // 埋点应该也会被调用
- t.assert(recordError.calledOnce);
- t.snapshot(recordError.firstCall.args);
- };
-
-abnormalScene.title = (providedTitle) => providedTitle || 'abnormal scene';
diff --git a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/_macro-normal.ts b/packages/datasource-engine/test/scenes/p0-1-custom-response-status/_macro-normal.ts
deleted file mode 100644
index 8774ef200..000000000
--- a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/_macro-normal.ts
+++ /dev/null
@@ -1,96 +0,0 @@
-import {
- InterpretDataSource,
- IDataSourceEngine,
- IDataSourceRuntimeContext,
- RuntimeDataSource,
- RuntimeDataSourceStatus,
-} from '@ali/lowcode-types';
-import sinon from 'sinon';
-
-import { bindRuntimeContext, delay, MockContext } from '../../_helpers';
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-
-import type { ExecutionContext, Macro } from 'ava';
-import type { SinonFakeTimers } from 'sinon';
-
-export const normalScene: Macro<[
- {
- create: (
- dataSource: any,
- ctx: IDataSourceRuntimeContext,
- options: any
- ) => IDataSourceEngine;
- dataSource: RuntimeDataSource | InterpretDataSource;
- }
-]> = async (
- t: ExecutionContext<{ clock: SinonFakeTimers }>,
- { create, dataSource },
- ) => {
- const { clock } = t.context;
-
- const USER_DATA = {
- name: 'Alice',
- age: 18,
- };
-
- const fetchHandler = sinon.fake(async () => {
- await delay(100);
- return {
- data: {
- success: true,
- data: USER_DATA,
- },
- };
- });
-
- const context = new MockContext>(
- {},
- (ctx) => create(bindRuntimeContext(dataSource, ctx), ctx, {
- requestHandlersMap: {
- fetch: fetchHandler,
- },
- }),
- {
- recordError() { },
- },
- );
-
- const setState = sinon.spy(context, 'setState');
- const recordError = sinon.spy(context, 'recordError');
-
- // 一开始应该是初始状态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Initial);
-
- const loading = context.reloadDataSource();
-
- await clock.tickAsync(50);
-
- // 中间应该有 loading 态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Loading);
-
- await Promise.all([clock.runAllAsync(), loading]);
-
- // 最后应该成功了,loaded 状态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Loaded);
-
- // 检查数据源的数据
- t.deepEqual(context.dataSourceMap.user.data, USER_DATA);
- t.deepEqual(context.dataSourceMap.user.error, undefined);
-
- // 检查状态数据
- t.assert(setState.calledOnce);
- t.deepEqual(context.state.user, USER_DATA);
-
- // fetchHandler 应该被调用了一次
- t.assert(fetchHandler.calledOnce);
-
- // 检查调用参数
- const firstListItemOptions = DATA_SOURCE_SCHEMA.list[0].options;
- const fetchHandlerCallArgs = fetchHandler.firstCall.args[0];
- t.is(firstListItemOptions.uri, fetchHandlerCallArgs.uri);
-
- // 埋点不应该被调用
- t.assert(recordError.notCalled);
- };
-
-normalScene.title = (providedTitle) => providedTitle || 'normal scene';
diff --git a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/abnormal-interpret.test.ts b/packages/datasource-engine/test/scenes/p0-1-custom-response-status/abnormal-interpret.test.ts
deleted file mode 100644
index 7f3169a50..000000000
--- a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/abnormal-interpret.test.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon from 'sinon';
-
-import { create } from '../../../src/interpret';
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-import { abnormalScene } from './_macro-abnormal';
-
-import type { SinonFakeTimers } from 'sinon';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(abnormalScene, {
- create,
- dataSource: DATA_SOURCE_SCHEMA,
-});
diff --git a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/abnormal-runtime.test.ts b/packages/datasource-engine/test/scenes/p0-1-custom-response-status/abnormal-runtime.test.ts
deleted file mode 100644
index c338af3b1..000000000
--- a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/abnormal-runtime.test.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon, { SinonFakeTimers } from 'sinon';
-
-import { create } from '../../../src/runtime';
-
-import { dataSource } from './_datasource-runtime';
-import { abnormalScene } from './_macro-abnormal';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(abnormalScene, {
- create,
- dataSource,
-});
diff --git a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/normal-interpret.test.ts b/packages/datasource-engine/test/scenes/p0-1-custom-response-status/normal-interpret.test.ts
deleted file mode 100644
index 9dac84e8d..000000000
--- a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/normal-interpret.test.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon, { SinonFakeTimers } from 'sinon';
-
-import { create } from '../../../src/interpret';
-
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-import { normalScene } from './_macro-normal';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(normalScene, {
- create,
- dataSource: DATA_SOURCE_SCHEMA,
-});
diff --git a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/normal-runtime.test.ts b/packages/datasource-engine/test/scenes/p0-1-custom-response-status/normal-runtime.test.ts
deleted file mode 100644
index 761979c30..000000000
--- a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/normal-runtime.test.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon, { SinonFakeTimers } from 'sinon';
-
-import { create } from '../../../src/runtime';
-
-import { dataSource } from './_datasource-runtime';
-import { normalScene } from './_macro-normal';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(normalScene, {
- create,
- dataSource,
-});
diff --git a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/snapshots/abnormal-interpret.test.ts.md b/packages/datasource-engine/test/scenes/p0-1-custom-response-status/snapshots/abnormal-interpret.test.ts.md
deleted file mode 100644
index 5baeac319..000000000
--- a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/snapshots/abnormal-interpret.test.ts.md
+++ /dev/null
@@ -1,20 +0,0 @@
-# Snapshot report for `test/scenes/custom-response-status/abnormal-interpret.test.ts`
-
-The actual snapshot is saved in `abnormal-interpret.test.ts.snap`.
-
-Generated by [AVA](https://avajs.dev).
-
-## abnormal scene
-
-> Snapshot 1
-
- [
- {
- detail: {
- code: 'E_FOO',
- message: 'test error',
- success: false,
- },
- type: 'FETCH_ERROR',
- },
- ]
diff --git a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/snapshots/abnormal-interpret.test.ts.snap b/packages/datasource-engine/test/scenes/p0-1-custom-response-status/snapshots/abnormal-interpret.test.ts.snap
deleted file mode 100644
index 6a9794bde..000000000
Binary files a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/snapshots/abnormal-interpret.test.ts.snap and /dev/null differ
diff --git a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/snapshots/abnormal-runtime.test.ts.md b/packages/datasource-engine/test/scenes/p0-1-custom-response-status/snapshots/abnormal-runtime.test.ts.md
deleted file mode 100644
index 7c65d528f..000000000
--- a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/snapshots/abnormal-runtime.test.ts.md
+++ /dev/null
@@ -1,20 +0,0 @@
-# Snapshot report for `test/scenes/p0-1-custom-response-status/abnormal-runtime.test.ts`
-
-The actual snapshot is saved in `abnormal-runtime.test.ts.snap`.
-
-Generated by [AVA](https://avajs.dev).
-
-## abnormal scene
-
-> Snapshot 1
-
- [
- {
- detail: {
- code: 'E_FOO',
- message: 'test error',
- success: false,
- },
- type: 'FETCH_ERROR',
- },
- ]
diff --git a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/snapshots/abnormal-runtime.test.ts.snap b/packages/datasource-engine/test/scenes/p0-1-custom-response-status/snapshots/abnormal-runtime.test.ts.snap
deleted file mode 100644
index 6a9794bde..000000000
Binary files a/packages/datasource-engine/test/scenes/p0-1-custom-response-status/snapshots/abnormal-runtime.test.ts.snap and /dev/null differ
diff --git a/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/README.md b/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/README.md
deleted file mode 100644
index d2eb4a470..000000000
--- a/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# 关于此场景
-
-有些数据源的错误可以忽略(吃掉)-- 通过 dataHandler 捕获 error,只要其不重新抛出 error 而且不返回 rejected 状态的 Promise.
diff --git a/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/_datasource-runtime.ts b/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/_datasource-runtime.ts
deleted file mode 100644
index d9ac8d6d0..000000000
--- a/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/_datasource-runtime.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { RuntimeDataSource } from '@ali/lowcode-types';
-
-export const DEFAULT_USER_DATA = { id: 0, name: 'guest' }; // 返回一个兜底的数据
-
-// 这里仅仅是数据源部分的:
-// @see: https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#XMeF5
-export const dataSource: RuntimeDataSource = {
- list: [
- {
- id: 'user',
- isInit: true,
- type: 'fetch',
- options: () => ({
- uri: 'https://mocks.alibaba-inc.com/user.json',
- }),
- dataHandler: function dataHandler(response: any) {
- return response.data;
- },
- },
- ],
-};
diff --git a/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/_datasource-schema.ts b/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/_datasource-schema.ts
deleted file mode 100644
index 1b33622a9..000000000
--- a/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/_datasource-schema.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import { InterpretDataSource } from '@ali/lowcode-types';
-
-// 这里仅仅是数据源部分的 schema:
-// @see: https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#XMeF5
-export const DATA_SOURCE_SCHEMA: InterpretDataSource = {
- list: [
- {
- id: 'user',
- isInit: true,
- type: 'fetch',
- options: {
- uri: 'https://mocks.alibaba-inc.com/user.json',
- },
- dataHandler: {
- type: 'JSFunction',
- value: `
-function dataHandler(response) {
- return response.data;
-}
-`,
- },
- },
- ],
-};
diff --git a/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/_macro-abnormal.ts b/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/_macro-abnormal.ts
deleted file mode 100644
index 4b5a2237e..000000000
--- a/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/_macro-abnormal.ts
+++ /dev/null
@@ -1,78 +0,0 @@
-import {
- InterpretDataSource,
- IDataSourceEngine,
- IDataSourceRuntimeContext,
- RuntimeDataSource,
- RuntimeDataSourceStatus,
-} from '@ali/lowcode-types';
-import sinon from 'sinon';
-
-import { delay, MockContext } from '../../_helpers';
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-
-import type { ExecutionContext, Macro } from 'ava';
-import type { SinonFakeTimers } from 'sinon';
-
-export const abnormalScene: Macro<[
- {
- create: (
- dataSource: any,
- ctx: IDataSourceRuntimeContext,
- options: any
- ) => IDataSourceEngine;
- dataSource: RuntimeDataSource | InterpretDataSource;
- }
-]> = async (
- t: ExecutionContext<{ clock: SinonFakeTimers }>,
- { create, dataSource },
- ) => {
- const { clock } = t.context;
- const ERROR_MSG = 'test error';
- const fetchHandler = sinon.fake(async () => {
- await delay(100);
- throw new Error(ERROR_MSG);
- });
-
- const context = new MockContext>({}, (ctx) => create(dataSource, ctx, {
- requestHandlersMap: {
- fetch: fetchHandler,
- },
- }));
-
- const setState = sinon.spy(context, 'setState');
-
- // 一开始应该是初始状态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Initial);
-
- const loading = context.reloadDataSource();
-
- await clock.tickAsync(50);
-
- // 中间应该有 loading 态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Loading);
-
- await Promise.all([clock.runAllAsync(), loading]);
-
- // 注意 error 是会被吃掉了,还是 loaded 状态
- // FIXME: 根据协议内容,dataHandler 返回的结果是需要抛出错误的,那么 fetchHandler 的错误难道不需要处理?
- // TODO: 提案:request 如果挂了,不应该需要走 dataHandler 了,没有意义
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Error);
-
- // 检查数据源的数据
- t.deepEqual(context.dataSourceMap.user.data, undefined);
- t.not(context.dataSourceMap.user.error, undefined);
- t.regex(context.dataSourceMap.user.error!.message, new RegExp(ERROR_MSG));
-
- // 检查状态数据
- t.assert(setState.notCalled);
-
- // fetchHandler 应该没调
- t.assert.skip(fetchHandler.notCalled);
-
- // 检查调用参数
- const firstListItemOptions = DATA_SOURCE_SCHEMA.list[0].options;
- const fetchHandlerCallArgs = fetchHandler.firstCall.args[0];
- t.is(firstListItemOptions.uri, fetchHandlerCallArgs.uri);
- };
-
-abnormalScene.title = (providedTitle) => providedTitle || 'abnormal scene';
diff --git a/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/_macro-normal.ts b/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/_macro-normal.ts
deleted file mode 100644
index c8484c434..000000000
--- a/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/_macro-normal.ts
+++ /dev/null
@@ -1,81 +0,0 @@
-import {
- InterpretDataSource,
- IDataSourceEngine,
- IDataSourceRuntimeContext,
- RuntimeDataSource,
- RuntimeDataSourceStatus,
-} from '@ali/lowcode-types';
-import sinon from 'sinon';
-
-import { delay, MockContext } from '../../_helpers';
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-
-import type { ExecutionContext, Macro } from 'ava';
-import type { SinonFakeTimers } from 'sinon';
-
-export const normalScene: Macro<[
- {
- create: (
- dataSource: any,
- ctx: IDataSourceRuntimeContext,
- options: any
- ) => IDataSourceEngine;
- dataSource: RuntimeDataSource | InterpretDataSource;
- }
-]> = async (
- t: ExecutionContext<{ clock: SinonFakeTimers }>,
- { create, dataSource },
- ) => {
- const { clock } = t.context;
-
- const USER_DATA = {
- name: 'Alice',
- age: 18,
- };
-
- const fetchHandler = sinon.fake(async () => {
- await delay(100);
- return { data: USER_DATA };
- });
-
- const context = new MockContext>({}, (ctx) => create(dataSource, ctx, {
- requestHandlersMap: {
- fetch: fetchHandler,
- },
- }));
-
- const setState = sinon.spy(context, 'setState');
-
- // 一开始应该是初始状态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Initial);
-
- const loading = context.reloadDataSource();
-
- await clock.tickAsync(50);
-
- // 中间应该有 loading 态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Loading);
-
- await Promise.all([clock.runAllAsync(), loading]);
-
- // 最后应该成功了,loaded 状态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Loaded);
-
- // 检查数据源的数据
- t.deepEqual(context.dataSourceMap.user.data, USER_DATA);
- t.deepEqual(context.dataSourceMap.user.error, undefined);
-
- // 检查状态数据
- t.assert(setState.calledOnce);
- t.deepEqual(context.state.user, USER_DATA);
-
- // fetchHandler 应该被调用了一次
- t.assert(fetchHandler.calledOnce);
-
- // 检查调用参数
- const firstListItemOptions = DATA_SOURCE_SCHEMA.list[0].options;
- const fetchHandlerCallArgs = fetchHandler.firstCall.args[0];
- t.is(firstListItemOptions.uri, fetchHandlerCallArgs.uri);
- };
-
-normalScene.title = (providedTitle) => providedTitle || 'normal scene';
diff --git a/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/abnormal-interpret.test.ts b/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/abnormal-interpret.test.ts
deleted file mode 100644
index 816523b10..000000000
--- a/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/abnormal-interpret.test.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon from 'sinon';
-
-import { create } from '../../../src/interpret';
-
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-import { abnormalScene } from './_macro-abnormal';
-
-import type { SinonFakeTimers } from 'sinon';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(abnormalScene, {
- create,
- dataSource: DATA_SOURCE_SCHEMA,
-});
diff --git a/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/abnormal-runtime.test.ts b/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/abnormal-runtime.test.ts
deleted file mode 100644
index c338af3b1..000000000
--- a/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/abnormal-runtime.test.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon, { SinonFakeTimers } from 'sinon';
-
-import { create } from '../../../src/runtime';
-
-import { dataSource } from './_datasource-runtime';
-import { abnormalScene } from './_macro-abnormal';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(abnormalScene, {
- create,
- dataSource,
-});
diff --git a/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/normal-interpret.test.ts b/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/normal-interpret.test.ts
deleted file mode 100644
index 9dac84e8d..000000000
--- a/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/normal-interpret.test.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon, { SinonFakeTimers } from 'sinon';
-
-import { create } from '../../../src/interpret';
-
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-import { normalScene } from './_macro-normal';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(normalScene, {
- create,
- dataSource: DATA_SOURCE_SCHEMA,
-});
diff --git a/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/normal-runtime.test.ts b/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/normal-runtime.test.ts
deleted file mode 100644
index 761979c30..000000000
--- a/packages/datasource-engine/test/scenes/p0-1-data-handler-can-eat-errors/normal-runtime.test.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon, { SinonFakeTimers } from 'sinon';
-
-import { create } from '../../../src/runtime';
-
-import { dataSource } from './_datasource-runtime';
-import { normalScene } from './_macro-normal';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(normalScene, {
- create,
- dataSource,
-});
diff --git a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/README.md b/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/README.md
deleted file mode 100644
index 4f8590da4..000000000
--- a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# 关于此场景
-
-某些场景下 dataHandler 不能同步返回,比如可能需要读取某个特殊的异步的数据源并合并响应数据。
diff --git a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/_datasource-runtime.ts b/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/_datasource-runtime.ts
deleted file mode 100644
index 19d35f910..000000000
--- a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/_datasource-runtime.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import { RuntimeDataSource } from '@ali/lowcode-types';
-
-// 这里仅仅是数据源部分的:
-// @see: https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#XMeF5
-export const dataSource: RuntimeDataSource = {
- list: [
- {
- id: 'user',
- isInit: true,
- type: 'fetch',
- options: () => ({
- uri: 'https://mocks.alibaba-inc.com/user.json',
- }),
- dataHandler: async function dataHandler(response: any) {
- const { data } = response;
- if (!data) {
- throw new Error('empty data!');
- }
-
- if (data.success) {
- return data.data;
- }
-
- this.recordError({ type: 'FETCH_ERROR', detail: data });
-
- throw new Error(data.message);
- },
- },
- ],
-};
diff --git a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/_datasource-schema.ts b/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/_datasource-schema.ts
deleted file mode 100644
index f163ea6c2..000000000
--- a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/_datasource-schema.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { InterpretDataSource } from '@ali/lowcode-types';
-
-// 这里仅仅是数据源部分的 schema:
-// @see: https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#XMeF5
-export const DATA_SOURCE_SCHEMA: InterpretDataSource = {
- list: [
- {
- id: 'user',
- isInit: true,
- type: 'fetch',
- options: {
- uri: 'https://mocks.alibaba-inc.com/user.json',
- },
- dataHandler: {
- type: 'JSFunction',
- value: `
-async function dataHandler(response){
- const { data } = response;
- if (!data) {
- throw new Error('empty data!');
- }
-
- if (data.success){
- return data.data;
- }
-
- this.recordError({ type: 'FETCH_ERROR', detail: data });
-
- throw new Error(data.message);
-}
-`,
- },
- },
- ],
-};
diff --git a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/_macro-abnormal.ts b/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/_macro-abnormal.ts
deleted file mode 100644
index a07619bd4..000000000
--- a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/_macro-abnormal.ts
+++ /dev/null
@@ -1,95 +0,0 @@
-import {
- InterpretDataSource,
- IDataSourceEngine,
- IDataSourceRuntimeContext,
- RuntimeDataSource,
- RuntimeDataSourceStatus,
-} from '@ali/lowcode-types';
-import sinon from 'sinon';
-
-import { bindRuntimeContext, delay, MockContext } from '../../_helpers';
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-
-import type { ExecutionContext, Macro } from 'ava';
-import type { SinonFakeTimers } from 'sinon';
-
-export const abnormalScene: Macro<[
- {
- create: (
- dataSource: any,
- ctx: IDataSourceRuntimeContext,
- options: any
- ) => IDataSourceEngine;
- dataSource: RuntimeDataSource | InterpretDataSource;
- }
-]> = async (
- t: ExecutionContext<{ clock: SinonFakeTimers }>,
- { create, dataSource },
- ) => {
- const { clock } = t.context;
- const ERROR_MSG = 'test error';
- const fetchHandler = sinon.fake(async () => {
- await delay(100);
- return {
- data: {
- success: false,
- message: ERROR_MSG,
- code: 'E_FOO',
- },
- };
- });
-
- const context = new MockContext>(
- {},
- (ctx) => create(bindRuntimeContext(dataSource, ctx), ctx, {
- requestHandlersMap: {
- fetch: fetchHandler,
- },
- }),
- {
- recordError() { },
- },
- );
-
- const setState = sinon.spy(context, 'setState');
- const recordError = sinon.spy(context, 'recordError');
-
- // 一开始应该是初始状态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Initial);
-
- const loading = context.reloadDataSource();
-
- await clock.tickAsync(50);
-
- // 中间应该有 loading 态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Loading);
-
- await Promise.all([clock.runAllAsync(), loading]);
-
- // 最后应该失败了,error 状态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Error);
-
- // 检查数据源的数据
- t.deepEqual(context.dataSourceMap.user.data, undefined);
- t.not(context.dataSourceMap.user.error, undefined);
-
- t.regex(context.dataSourceMap.user.error!.message, new RegExp(ERROR_MSG));
-
- // 检查状态数据
- t.assert(setState.notCalled);
- t.deepEqual(context.state.user, undefined);
-
- // fetchHandler 应该被调用了一次
- t.assert(fetchHandler.calledOnce);
-
- // 检查调用参数
- const firstListItemOptions = DATA_SOURCE_SCHEMA.list[0].options;
- const fetchHandlerCallArgs = fetchHandler.firstCall.args[0];
- t.is(firstListItemOptions.uri, fetchHandlerCallArgs.uri);
-
- // 埋点应该也会被调用
- t.assert(recordError.calledOnce);
- t.snapshot(recordError.firstCall.args);
- };
-
-abnormalScene.title = (providedTitle) => providedTitle || 'abnormal scene';
diff --git a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/_macro-normal.ts b/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/_macro-normal.ts
deleted file mode 100644
index 8774ef200..000000000
--- a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/_macro-normal.ts
+++ /dev/null
@@ -1,96 +0,0 @@
-import {
- InterpretDataSource,
- IDataSourceEngine,
- IDataSourceRuntimeContext,
- RuntimeDataSource,
- RuntimeDataSourceStatus,
-} from '@ali/lowcode-types';
-import sinon from 'sinon';
-
-import { bindRuntimeContext, delay, MockContext } from '../../_helpers';
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-
-import type { ExecutionContext, Macro } from 'ava';
-import type { SinonFakeTimers } from 'sinon';
-
-export const normalScene: Macro<[
- {
- create: (
- dataSource: any,
- ctx: IDataSourceRuntimeContext,
- options: any
- ) => IDataSourceEngine;
- dataSource: RuntimeDataSource | InterpretDataSource;
- }
-]> = async (
- t: ExecutionContext<{ clock: SinonFakeTimers }>,
- { create, dataSource },
- ) => {
- const { clock } = t.context;
-
- const USER_DATA = {
- name: 'Alice',
- age: 18,
- };
-
- const fetchHandler = sinon.fake(async () => {
- await delay(100);
- return {
- data: {
- success: true,
- data: USER_DATA,
- },
- };
- });
-
- const context = new MockContext>(
- {},
- (ctx) => create(bindRuntimeContext(dataSource, ctx), ctx, {
- requestHandlersMap: {
- fetch: fetchHandler,
- },
- }),
- {
- recordError() { },
- },
- );
-
- const setState = sinon.spy(context, 'setState');
- const recordError = sinon.spy(context, 'recordError');
-
- // 一开始应该是初始状态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Initial);
-
- const loading = context.reloadDataSource();
-
- await clock.tickAsync(50);
-
- // 中间应该有 loading 态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Loading);
-
- await Promise.all([clock.runAllAsync(), loading]);
-
- // 最后应该成功了,loaded 状态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Loaded);
-
- // 检查数据源的数据
- t.deepEqual(context.dataSourceMap.user.data, USER_DATA);
- t.deepEqual(context.dataSourceMap.user.error, undefined);
-
- // 检查状态数据
- t.assert(setState.calledOnce);
- t.deepEqual(context.state.user, USER_DATA);
-
- // fetchHandler 应该被调用了一次
- t.assert(fetchHandler.calledOnce);
-
- // 检查调用参数
- const firstListItemOptions = DATA_SOURCE_SCHEMA.list[0].options;
- const fetchHandlerCallArgs = fetchHandler.firstCall.args[0];
- t.is(firstListItemOptions.uri, fetchHandlerCallArgs.uri);
-
- // 埋点不应该被调用
- t.assert(recordError.notCalled);
- };
-
-normalScene.title = (providedTitle) => providedTitle || 'normal scene';
diff --git a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/abnormal-interpret.test.ts b/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/abnormal-interpret.test.ts
deleted file mode 100644
index 7f3169a50..000000000
--- a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/abnormal-interpret.test.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon from 'sinon';
-
-import { create } from '../../../src/interpret';
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-import { abnormalScene } from './_macro-abnormal';
-
-import type { SinonFakeTimers } from 'sinon';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(abnormalScene, {
- create,
- dataSource: DATA_SOURCE_SCHEMA,
-});
diff --git a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/abnormal-runtime.test.ts b/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/abnormal-runtime.test.ts
deleted file mode 100644
index c338af3b1..000000000
--- a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/abnormal-runtime.test.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon, { SinonFakeTimers } from 'sinon';
-
-import { create } from '../../../src/runtime';
-
-import { dataSource } from './_datasource-runtime';
-import { abnormalScene } from './_macro-abnormal';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(abnormalScene, {
- create,
- dataSource,
-});
diff --git a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/normal-interpret.test.ts b/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/normal-interpret.test.ts
deleted file mode 100644
index 9dac84e8d..000000000
--- a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/normal-interpret.test.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon, { SinonFakeTimers } from 'sinon';
-
-import { create } from '../../../src/interpret';
-
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-import { normalScene } from './_macro-normal';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(normalScene, {
- create,
- dataSource: DATA_SOURCE_SCHEMA,
-});
diff --git a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/normal-runtime.test.ts b/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/normal-runtime.test.ts
deleted file mode 100644
index 761979c30..000000000
--- a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/normal-runtime.test.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon, { SinonFakeTimers } from 'sinon';
-
-import { create } from '../../../src/runtime';
-
-import { dataSource } from './_datasource-runtime';
-import { normalScene } from './_macro-normal';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(normalScene, {
- create,
- dataSource,
-});
diff --git a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/snapshots/abnormal-interpret.test.ts.md b/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/snapshots/abnormal-interpret.test.ts.md
deleted file mode 100644
index 558b612d6..000000000
--- a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/snapshots/abnormal-interpret.test.ts.md
+++ /dev/null
@@ -1,20 +0,0 @@
-# Snapshot report for `test/scenes/data-handler-returns-promise/abnormal-interpret.test.ts`
-
-The actual snapshot is saved in `abnormal-interpret.test.ts.snap`.
-
-Generated by [AVA](https://avajs.dev).
-
-## abnormal scene
-
-> Snapshot 1
-
- [
- {
- detail: {
- code: 'E_FOO',
- message: 'test error',
- success: false,
- },
- type: 'FETCH_ERROR',
- },
- ]
diff --git a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/snapshots/abnormal-interpret.test.ts.snap b/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/snapshots/abnormal-interpret.test.ts.snap
deleted file mode 100644
index 6a9794bde..000000000
Binary files a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/snapshots/abnormal-interpret.test.ts.snap and /dev/null differ
diff --git a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/snapshots/abnormal-runtime.test.ts.md b/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/snapshots/abnormal-runtime.test.ts.md
deleted file mode 100644
index 98deb8904..000000000
--- a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/snapshots/abnormal-runtime.test.ts.md
+++ /dev/null
@@ -1,20 +0,0 @@
-# Snapshot report for `test/scenes/p1-0-data-handler-returns-promise/abnormal-runtime.test.ts`
-
-The actual snapshot is saved in `abnormal-runtime.test.ts.snap`.
-
-Generated by [AVA](https://avajs.dev).
-
-## abnormal scene
-
-> Snapshot 1
-
- [
- {
- detail: {
- code: 'E_FOO',
- message: 'test error',
- success: false,
- },
- type: 'FETCH_ERROR',
- },
- ]
diff --git a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/snapshots/abnormal-runtime.test.ts.snap b/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/snapshots/abnormal-runtime.test.ts.snap
deleted file mode 100644
index 6a9794bde..000000000
Binary files a/packages/datasource-engine/test/scenes/p1-0-data-handler-returns-promise/snapshots/abnormal-runtime.test.ts.snap and /dev/null differ
diff --git a/packages/datasource-engine/test/scenes/p1-1-shouldfetch-control-request/README.md b/packages/datasource-engine/test/scenes/p1-1-shouldfetch-control-request/README.md
deleted file mode 100644
index efde6173c..000000000
--- a/packages/datasource-engine/test/scenes/p1-1-shouldfetch-control-request/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# 关于此场景
-
-某些场景下 shouldFetch 的结果可以影响请求是否被发出去。
diff --git a/packages/datasource-engine/test/scenes/p1-1-shouldfetch-control-request/_datasource-runtime.ts b/packages/datasource-engine/test/scenes/p1-1-shouldfetch-control-request/_datasource-runtime.ts
deleted file mode 100644
index 49d30425e..000000000
--- a/packages/datasource-engine/test/scenes/p1-1-shouldfetch-control-request/_datasource-runtime.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import { RuntimeDataSource } from '@ali/lowcode-types';
-
-// 这里仅仅是数据源部分的:
-// @see: https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#XMeF5
-export const dataSource: RuntimeDataSource = {
- list: [
- {
- id: 'user',
- isInit: true,
- type: 'fetch',
- isSync: true,
- options: () => ({
- uri: 'https://mocks.alibaba-inc.com/user.json',
- }),
- },
- {
- id: 'orders',
- isInit: true,
- type: 'fetch',
- isSync: true,
- shouldFetch: () => false,
- options() {
- return {
- uri: 'https://mocks.alibaba-inc.com/orders.json',
- params: {
- userId: this.state.user.id,
- },
- };
- },
- },
- ],
-};
diff --git a/packages/datasource-engine/test/scenes/p1-1-shouldfetch-control-request/_datasource-schema.ts b/packages/datasource-engine/test/scenes/p1-1-shouldfetch-control-request/_datasource-schema.ts
deleted file mode 100644
index 4032c9a35..000000000
--- a/packages/datasource-engine/test/scenes/p1-1-shouldfetch-control-request/_datasource-schema.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-import { InterpretDataSource } from '@ali/lowcode-types';
-
-// 这里仅仅是数据源部分的 schema:
-// @see: https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#XMeF5
-export const DATA_SOURCE_SCHEMA: InterpretDataSource = {
- list: [
- {
- id: 'user',
- isInit: true,
- type: 'fetch',
- isSync: true,
- options: {
- uri: 'https://mocks.alibaba-inc.com/user.json',
- },
- },
- {
- id: 'orders',
- isInit: true,
- type: 'fetch',
- isSync: true,
- shouldFetch: {
- type: 'JSFunction',
- value: `
- function (){
- return false;
- }
- `,
- },
- options: {
- uri: 'https://mocks.alibaba-inc.com/orders.json',
- params: {
- type: 'JSExpression',
- value: '{ userId: this.state.user.id }',
- },
- },
- },
- ],
-};
diff --git a/packages/datasource-engine/test/scenes/p1-1-shouldfetch-control-request/_macro-normal.ts b/packages/datasource-engine/test/scenes/p1-1-shouldfetch-control-request/_macro-normal.ts
deleted file mode 100644
index a12e0a48c..000000000
--- a/packages/datasource-engine/test/scenes/p1-1-shouldfetch-control-request/_macro-normal.ts
+++ /dev/null
@@ -1,108 +0,0 @@
-import {
- InterpretDataSource,
- IDataSourceEngine,
- IDataSourceRuntimeContext,
- RuntimeDataSource,
- RuntimeDataSourceStatus,
-} from '@ali/lowcode-types';
-import sinon from 'sinon';
-
-import { bindRuntimeContext, delay, MockContext } from '../../_helpers';
-
-import type { ExecutionContext, Macro } from 'ava';
-import type { SinonFakeTimers } from 'sinon';
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-
-export const normalScene: Macro<[
- {
- create: (
- dataSource: any,
- ctx: IDataSourceRuntimeContext,
- options: any
- ) => IDataSourceEngine;
- dataSource: RuntimeDataSource | InterpretDataSource;
- }
-]> = async (
- t: ExecutionContext<{ clock: SinonFakeTimers }>,
- { create, dataSource },
- ) => {
- const { clock } = t.context;
- const ORDERS_ERROR_MSG =
- 'the orders request should not fetch, please check the condition';
-
- const USER_DATA = {
- name: 'Alice',
- age: 18,
- };
-
- const fetchHandler = sinon.fake(async () => {
- await delay(100);
- return {
- data: USER_DATA,
- };
- });
-
- const context = new MockContext>(
- {},
- (ctx) => create(bindRuntimeContext(dataSource, ctx), ctx, {
- requestHandlersMap: {
- fetch: fetchHandler,
- },
- }),
- {
- recordError() { },
- },
- );
-
- const setState = sinon.spy(context, 'setState');
- // const recordError = sinon.spy(context, 'recordError');
-
- // 一开始应该是初始状态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Initial);
- t.is(context.dataSourceMap.orders.status, RuntimeDataSourceStatus.Initial);
-
- const loading = context.reloadDataSource();
-
- await clock.tickAsync(50);
-
- // 中间应该有 loading 态
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Loading);
-
- await clock.tickAsync(50);
-
- // 中间应该有 loading 态
- t.is(context.dataSourceMap.orders.status, RuntimeDataSourceStatus.Error);
-
- await Promise.all([clock.runAllAsync(), loading]);
-
- // 最后 user 成功, orders 失败
- t.is(context.dataSourceMap.user.status, RuntimeDataSourceStatus.Loaded);
- t.is(context.dataSourceMap.orders.status, RuntimeDataSourceStatus.Error);
-
- // 检查数据源的数据
- t.deepEqual(context.dataSourceMap.user.data, USER_DATA);
- t.is(context.dataSourceMap.user.error, undefined);
- t.regex(
- context.dataSourceMap.orders.error!.message,
- new RegExp(ORDERS_ERROR_MSG),
- );
-
- // 检查状态数据
- t.assert(setState.calledOnce);
- t.deepEqual(context.state.user, USER_DATA);
-
- // fetchHandler 应该被调用了 1 次
- t.assert(fetchHandler.calledOnce);
-
- // 检查调用参数
-
- const firstListItemOptions = DATA_SOURCE_SCHEMA.list[0].options;
- const fetchHandlerCallArgs = fetchHandler.firstCall.args[0];
- t.is(firstListItemOptions.uri, fetchHandlerCallArgs.uri);
-
- // // 埋点应该也会被调用
- // t.assert(recordError.calledOnce);
- // t.snapshot(recordError.firstCall.args);
- };
-
-normalScene.title = (providedTitle) => providedTitle || 'normal scene';
diff --git a/packages/datasource-engine/test/scenes/p1-1-shouldfetch-control-request/normal-interpret.test.ts b/packages/datasource-engine/test/scenes/p1-1-shouldfetch-control-request/normal-interpret.test.ts
deleted file mode 100644
index 9dac84e8d..000000000
--- a/packages/datasource-engine/test/scenes/p1-1-shouldfetch-control-request/normal-interpret.test.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon, { SinonFakeTimers } from 'sinon';
-
-import { create } from '../../../src/interpret';
-
-import { DATA_SOURCE_SCHEMA } from './_datasource-schema';
-import { normalScene } from './_macro-normal';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(normalScene, {
- create,
- dataSource: DATA_SOURCE_SCHEMA,
-});
diff --git a/packages/datasource-engine/test/scenes/p1-1-shouldfetch-control-request/normal-runtime.test.ts b/packages/datasource-engine/test/scenes/p1-1-shouldfetch-control-request/normal-runtime.test.ts
deleted file mode 100644
index 761979c30..000000000
--- a/packages/datasource-engine/test/scenes/p1-1-shouldfetch-control-request/normal-runtime.test.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import test, { ExecutionContext } from 'ava';
-import sinon, { SinonFakeTimers } from 'sinon';
-
-import { create } from '../../../src/runtime';
-
-import { dataSource } from './_datasource-runtime';
-import { normalScene } from './_macro-normal';
-
-test.before((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock = sinon.useFakeTimers();
-});
-
-test.after((t: ExecutionContext<{ clock: SinonFakeTimers }>) => {
- t.context.clock.restore();
-});
-
-test(normalScene, {
- create,
- dataSource,
-});
diff --git a/packages/datasource-engine/tsconfig.json b/packages/datasource-engine/tsconfig.json
deleted file mode 100644
index ef698791a..000000000
--- a/packages/datasource-engine/tsconfig.json
+++ /dev/null
@@ -1,68 +0,0 @@
-{
- "compilerOptions": {
- /* Basic Options */
- // "incremental": true, /* Enable incremental compilation */
- "target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
- "module": "esnext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
- "lib": ["ESNext", "DOM"] /* Specify library files to be included in the compilation. */,
- // "allowJs": true, /* Allow javascript files to be compiled. */
- // "checkJs": true, /* Report errors in .js files. */
- "jsx": "preserve" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */,
- "declaration": true /* Generates corresponding '.d.ts' file. */,
- // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
- // "sourceMap": true, /* Generates corresponding '.map' file. */
- // "outFile": "./", /* Concatenate and emit output to single file. */
- "outDir": "dist" /* Redirect output structure to the directory. */,
- // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
- // "composite": true, /* Enable project compilation */
- // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
- // "removeComments": true, /* Do not emit comments to output. */
- // "noEmit": true, /* Do not emit outputs. */
- "importHelpers": true /* Import emit helpers from 'tslib'. */,
- // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
- // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
-
- /* Strict Type-Checking Options */
- "strict": true /* Enable all strict type-checking options. */,
- // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
- // "strictNullChecks": true, /* Enable strict null checks. */
- // "strictFunctionTypes": true, /* Enable strict checking of function types. */
- // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
- // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
- // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
- // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
-
- /* Additional Checks */
- // "noUnusedLocals": true, /* Report errors on unused locals. */
- // "noUnusedParameters": true, /* Report errors on unused parameters. */
- // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
- // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
-
- /* Module Resolution Options */
- "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
- // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
- // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
- // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
- // "typeRoots": [], /* List of folders to include type definitions from. */
- // "types": [], /* Type declaration files to be included in compilation. */
- "allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */,
- "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
- // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
-
- /* Source Map Options */
- // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
- // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
- // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
-
- /* Experimental Options */
- // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
- // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
-
- /* Advanced Options */
- "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
- "skipLibCheck": true
- },
- "include": ["src"]
-}
diff --git a/packages/datasource-fetch-handler/.eslintignore b/packages/datasource-fetch-handler/.eslintignore
deleted file mode 100644
index fecb7c26d..000000000
--- a/packages/datasource-fetch-handler/.eslintignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/node_modules
-/es
-/lib
\ No newline at end of file
diff --git a/packages/datasource-fetch-handler/.eslintrc.js b/packages/datasource-fetch-handler/.eslintrc.js
deleted file mode 100644
index 8c13fcaf4..000000000
--- a/packages/datasource-fetch-handler/.eslintrc.js
+++ /dev/null
@@ -1,7 +0,0 @@
-module.exports = {
- extends: '../../.eslintrc',
- rules: {
- '@typescript-eslint/no-parameter-properties': 1,
- 'no-param-reassign': 0,
- },
-};
diff --git a/packages/datasource-fetch-handler/.prettierrc.js b/packages/datasource-fetch-handler/.prettierrc.js
deleted file mode 100644
index de2f53cdf..000000000
--- a/packages/datasource-fetch-handler/.prettierrc.js
+++ /dev/null
@@ -1,4 +0,0 @@
-module.exports = {
- singleQuote: true,
- trailingComma: 'all',
-};
diff --git a/packages/datasource-fetch-handler/CHANGELOG.md b/packages/datasource-fetch-handler/CHANGELOG.md
deleted file mode 100644
index 1aa80fee2..000000000
--- a/packages/datasource-fetch-handler/CHANGELOG.md
+++ /dev/null
@@ -1,82 +0,0 @@
-# Change Log
-
-All notable changes to this project will be documented in this file.
-See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
-
-
-## [1.0.21](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-fetch-handler@1.0.20...@ali/lowcode-datasource-fetch-handler@1.0.21) (2020-11-16)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-fetch-handler
-
-
-## [1.0.20](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-fetch-handler@1.0.9...@ali/lowcode-datasource-fetch-handler@1.0.20) (2020-11-10)
-
-
-### Bug Fixes
-
-* 设计和预览两种场景下 requestHandlersMap 的接入 ([f9e5397](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f9e5397))
-
-
-
-
-
-## [1.0.9](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-fetch-handler@1.0.8...@ali/lowcode-datasource-fetch-handler@1.0.9) (2020-11-10)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-fetch-handler
-
-
-## [1.0.8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-fetch-handler@1.0.7...@ali/lowcode-datasource-fetch-handler@1.0.8) (2020-11-05)
-
-
-### Features
-
-* split datasource types ([fd80698](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/fd80698))
-
-
-
-
-
-## [1.0.7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-fetch-handler@1.0.6...@ali/lowcode-datasource-fetch-handler@1.0.7) (2020-11-05)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-fetch-handler
-
-
-## [1.0.6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-fetch-handler@1.0.5...@ali/lowcode-datasource-fetch-handler@1.0.6) (2020-11-05)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-fetch-handler
-
-
-## [1.0.5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-fetch-handler@1.0.4...@ali/lowcode-datasource-fetch-handler@1.0.5) (2020-11-04)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-fetch-handler
-
-
-## 1.0.4 (2020-11-04)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-fetch-handler
-
-
-## 1.0.3 (2020-11-04)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-fetch-handler
diff --git a/packages/datasource-fetch-handler/package.json b/packages/datasource-fetch-handler/package.json
deleted file mode 100644
index 4b1525a58..000000000
--- a/packages/datasource-fetch-handler/package.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "name": "@ali/lowcode-datasource-fetch-handler",
- "version": "1.0.21",
- "main": "lib/index.js",
- "module": "es/index.js",
- "typings": "es/index.d.ts",
- "files": [
- "src",
- "lib",
- "es"
- ],
- "scripts": {
- "dev": "tsc --watch",
- "clean": "rm -rf es lib",
- "build": "npm run clean && tsc && tsc --outDir ./lib --module commonjs ",
- "prepublishOnly": "npm run build"
- },
- "dependencies": {
- "@ali/lowcode-datasource-types": "^1.0.21",
- "typescript": "^3.9.7",
- "universal-request": "^2.2.0"
- },
- "publishConfig": {
- "registry": "https://registry.npm.alibaba-inc.com"
- },
- "gitHead": "829e504c52a294fc28966ab0e491f4d2de1d4c90"
-}
diff --git a/packages/datasource-fetch-handler/src/index.ts b/packages/datasource-fetch-handler/src/index.ts
deleted file mode 100644
index 95e0d0491..000000000
--- a/packages/datasource-fetch-handler/src/index.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { RuntimeOptionsConfig } from '@ali/lowcode-datasource-types';
-
-import request from 'universal-request';
-import { RequestOptions, AsObject } from 'universal-request/lib/types';
-
-// config 留着扩展
-export function createFetchHandler(config?: Record) {
- // eslint-disable-next-line space-before-function-paren
- return async function(options: RuntimeOptionsConfig) {
- const requestConfig: RequestOptions = {
- ...options,
- url: options.uri,
- method: options.method as RequestOptions['method'],
- data: options.params as AsObject,
- headers: options.headers as AsObject,
- ...config,
- };
- const response = await request(requestConfig);
- return response;
- };
-}
diff --git a/packages/datasource-fetch-handler/tsconfig.json b/packages/datasource-fetch-handler/tsconfig.json
deleted file mode 100644
index 4f788e5ed..000000000
--- a/packages/datasource-fetch-handler/tsconfig.json
+++ /dev/null
@@ -1,68 +0,0 @@
-{
- "compilerOptions": {
- "outDir": "es",
- "target": "es6",
- "module": "esnext",
- /* Basic Options */
- // "incremental": true, /* Enable incremental compilation */
- // "target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
- // "module": "esnext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
- "lib": [
- "ESNext",
- "DOM"
- ] /* Specify library files to be included in the compilation. */,
- // "allowJs": true, /* Allow javascript files to be compiled. */
- // "checkJs": true, /* Report errors in .js files. */
- // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
- "declaration": true /* Generates corresponding '.d.ts' file. */,
- // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
- // "sourceMap": true, /* Generates corresponding '.map' file. */
- // "outFile": "./", /* Concatenate and emit output to single file. */
- // "outDir": "es" /* Redirect output structure to the directory. */,
- // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
- // "composite": true, /* Enable project compilation */
- // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
- // "removeComments": true, /* Do not emit comments to output. */
- // "noEmit": true, /* Do not emit outputs. */
- // "importHelpers": true, /* Import emit helpers from 'tslib'. */
- // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
- // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
- /* Strict Type-Checking Options */
- "strict": true /* Enable all strict type-checking options. */,
- // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
- // "strictNullChecks": true, /* Enable strict null checks. */
- // "strictFunctionTypes": true, /* Enable strict checking of function types. */
- // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
- // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
- // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
- // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
- /* Additional Checks */
- // "noUnusedLocals": true, /* Report errors on unused locals. */
- // "noUnusedParameters": true, /* Report errors on unused parameters. */
- // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
- // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
- /* Module Resolution Options */
- "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
- // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
- // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
- // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
- // "typeRoots": [], /* List of folders to include type definitions from. */
- // "types": [], /* Type declaration files to be included in compilation. */
- // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
- "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
- // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
- /* Source Map Options */
- // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
- // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
- // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
- /* Experimental Options */
- // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
- // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
- /* Advanced Options */
- "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
- "skipLibCheck": true
- },
- "include": ["src/**/*"]
-}
diff --git a/packages/datasource-jsonp-handler/.eslintignore b/packages/datasource-jsonp-handler/.eslintignore
deleted file mode 100644
index fecb7c26d..000000000
--- a/packages/datasource-jsonp-handler/.eslintignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/node_modules
-/es
-/lib
\ No newline at end of file
diff --git a/packages/datasource-jsonp-handler/.eslintrc.js b/packages/datasource-jsonp-handler/.eslintrc.js
deleted file mode 100644
index 8c13fcaf4..000000000
--- a/packages/datasource-jsonp-handler/.eslintrc.js
+++ /dev/null
@@ -1,7 +0,0 @@
-module.exports = {
- extends: '../../.eslintrc',
- rules: {
- '@typescript-eslint/no-parameter-properties': 1,
- 'no-param-reassign': 0,
- },
-};
diff --git a/packages/datasource-jsonp-handler/.prettierrc.js b/packages/datasource-jsonp-handler/.prettierrc.js
deleted file mode 100644
index de2f53cdf..000000000
--- a/packages/datasource-jsonp-handler/.prettierrc.js
+++ /dev/null
@@ -1,4 +0,0 @@
-module.exports = {
- singleQuote: true,
- trailingComma: 'all',
-};
diff --git a/packages/datasource-jsonp-handler/CHANGELOG.md b/packages/datasource-jsonp-handler/CHANGELOG.md
deleted file mode 100644
index f35cc97a3..000000000
--- a/packages/datasource-jsonp-handler/CHANGELOG.md
+++ /dev/null
@@ -1,82 +0,0 @@
-# Change Log
-
-All notable changes to this project will be documented in this file.
-See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
-
-
-## [1.0.21](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-jsonp-handler@1.0.20...@ali/lowcode-datasource-jsonp-handler@1.0.21) (2020-11-16)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-jsonp-handler
-
-
-## [1.0.20](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-jsonp-handler@1.0.6...@ali/lowcode-datasource-jsonp-handler@1.0.20) (2020-11-10)
-
-
-### Bug Fixes
-
-* 设计和预览两种场景下 requestHandlersMap 的接入 ([f9e5397](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f9e5397))
-
-
-
-
-
-## [1.0.6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-jsonp-handler@1.0.5...@ali/lowcode-datasource-jsonp-handler@1.0.6) (2020-11-10)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-jsonp-handler
-
-
-## [1.0.5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-jsonp-handler@1.0.4...@ali/lowcode-datasource-jsonp-handler@1.0.5) (2020-11-05)
-
-
-### Features
-
-* split datasource types ([fd80698](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/fd80698))
-
-
-
-
-
-## [1.0.4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-jsonp-handler@1.0.3...@ali/lowcode-datasource-jsonp-handler@1.0.4) (2020-11-05)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-jsonp-handler
-
-
-## [1.0.3](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-jsonp-handler@1.0.2...@ali/lowcode-datasource-jsonp-handler@1.0.3) (2020-11-05)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-jsonp-handler
-
-
-## [1.0.2](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-jsonp-handler@1.0.1...@ali/lowcode-datasource-jsonp-handler@1.0.2) (2020-11-04)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-jsonp-handler
-
-
-## 1.0.1 (2020-11-04)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-jsonp-handler
-
-
-# 1.0.0 (2020-11-04)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-jsonp-handler
diff --git a/packages/datasource-jsonp-handler/package.json b/packages/datasource-jsonp-handler/package.json
deleted file mode 100644
index 454e092e0..000000000
--- a/packages/datasource-jsonp-handler/package.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "name": "@ali/lowcode-datasource-jsonp-handler",
- "version": "1.0.21",
- "main": "lib/index.js",
- "module": "es/index.js",
- "typings": "es/index.d.ts",
- "files": [
- "src",
- "lib",
- "es"
- ],
- "scripts": {
- "dev": "tsc --watch",
- "clean": "rm -rf es lib",
- "build": "npm run clean && tsc && tsc --outDir ./lib --module commonjs ",
- "prepublishOnly": "npm run build"
- },
- "dependencies": {
- "@ali/lowcode-datasource-types": "^1.0.21",
- "jsonp": "^0.2.1",
- "typescript": "^3.9.7"
- },
- "publishConfig": {
- "registry": "https://registry.npm.alibaba-inc.com"
- },
- "devDependencies": {
- "@types/jsonp": "^0.2.0"
- }
-}
diff --git a/packages/datasource-jsonp-handler/src/index.ts b/packages/datasource-jsonp-handler/src/index.ts
deleted file mode 100644
index de3882513..000000000
--- a/packages/datasource-jsonp-handler/src/index.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import { RuntimeOptionsConfig } from '@ali/lowcode-datasource-types';
-import jsonp from 'jsonp';
-
-const handleJsonpFetch = (url: string, param: string, name: string) => {
- return new Promise((res, rej) => {
- jsonp(url, { param, name }, (error: Error | null, data: any) => {
- if (error) {
- return rej(error);
- }
- res({ data });
- });
- });
-};
-
-// config 留着扩展
-// eslint-disable-next-line @typescript-eslint/no-unused-vars
-export function createJsonpHandler(config?: Record) {
- // eslint-disable-next-line space-before-function-paren
- return async function(options: RuntimeOptionsConfig) {
- const params =
- typeof options.params === 'object'
- ? JSON.stringify(options.params)
- : options.params;
- const response = await handleJsonpFetch(
- options.uri,
- params || '',
- options.name as string | '',
- );
- return response;
- };
-}
diff --git a/packages/datasource-jsonp-handler/tsconfig.json b/packages/datasource-jsonp-handler/tsconfig.json
deleted file mode 100644
index eeea7a79b..000000000
--- a/packages/datasource-jsonp-handler/tsconfig.json
+++ /dev/null
@@ -1,65 +0,0 @@
-{
- "compilerOptions": {
- "outDir": "es",
- "target": "es6",
- "module": "esnext",
- /* Basic Options */
- // "incremental": true, /* Enable incremental compilation */
- // "target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
- // "module": "esnext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
- "lib": ["ESNext", "DOM"] /* Specify library files to be included in the compilation. */,
- // "allowJs": true, /* Allow javascript files to be compiled. */
- // "checkJs": true, /* Report errors in .js files. */
- // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
- "declaration": true /* Generates corresponding '.d.ts' file. */,
- // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
- // "sourceMap": true, /* Generates corresponding '.map' file. */
- // "outFile": "./", /* Concatenate and emit output to single file. */
- // "outDir": "es" /* Redirect output structure to the directory. */,
- // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
- // "composite": true, /* Enable project compilation */
- // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
- // "removeComments": true, /* Do not emit comments to output. */
- // "noEmit": true, /* Do not emit outputs. */
- // "importHelpers": true, /* Import emit helpers from 'tslib'. */
- // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
- // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
- /* Strict Type-Checking Options */
- "strict": true /* Enable all strict type-checking options. */,
- // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
- // "strictNullChecks": true, /* Enable strict null checks. */
- // "strictFunctionTypes": true, /* Enable strict checking of function types. */
- // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
- // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
- // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
- // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
- /* Additional Checks */
- // "noUnusedLocals": true, /* Report errors on unused locals. */
- // "noUnusedParameters": true, /* Report errors on unused parameters. */
- // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
- // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
- /* Module Resolution Options */
- "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
- // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
- // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
- // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
- // "typeRoots": [], /* List of folders to include type definitions from. */
- // "types": [], /* Type declaration files to be included in compilation. */
- // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
- "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
- // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
- /* Source Map Options */
- // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
- // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
- // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
- /* Experimental Options */
- // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
- // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
- /* Advanced Options */
- "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
- "skipLibCheck": true
- },
- "include": ["src/**/*"]
-}
diff --git a/packages/datasource-mopen-handler/.eslintignore b/packages/datasource-mopen-handler/.eslintignore
deleted file mode 100644
index fecb7c26d..000000000
--- a/packages/datasource-mopen-handler/.eslintignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/node_modules
-/es
-/lib
\ No newline at end of file
diff --git a/packages/datasource-mopen-handler/.eslintrc.js b/packages/datasource-mopen-handler/.eslintrc.js
deleted file mode 100644
index 8c13fcaf4..000000000
--- a/packages/datasource-mopen-handler/.eslintrc.js
+++ /dev/null
@@ -1,7 +0,0 @@
-module.exports = {
- extends: '../../.eslintrc',
- rules: {
- '@typescript-eslint/no-parameter-properties': 1,
- 'no-param-reassign': 0,
- },
-};
diff --git a/packages/datasource-mopen-handler/.prettierrc.js b/packages/datasource-mopen-handler/.prettierrc.js
deleted file mode 100644
index de2f53cdf..000000000
--- a/packages/datasource-mopen-handler/.prettierrc.js
+++ /dev/null
@@ -1,4 +0,0 @@
-module.exports = {
- singleQuote: true,
- trailingComma: 'all',
-};
diff --git a/packages/datasource-mopen-handler/CHANGELOG.md b/packages/datasource-mopen-handler/CHANGELOG.md
deleted file mode 100644
index 9291ff25a..000000000
--- a/packages/datasource-mopen-handler/CHANGELOG.md
+++ /dev/null
@@ -1,82 +0,0 @@
-# Change Log
-
-All notable changes to this project will be documented in this file.
-See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
-
-
-## [1.0.21](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-mopen-handler@1.0.20...@ali/lowcode-datasource-mopen-handler@1.0.21) (2020-11-16)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-mopen-handler
-
-
-## [1.0.20](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-mopen-handler@1.0.9...@ali/lowcode-datasource-mopen-handler@1.0.20) (2020-11-10)
-
-
-### Bug Fixes
-
-* 设计和预览两种场景下 requestHandlersMap 的接入 ([f9e5397](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f9e5397))
-
-
-
-
-
-## [1.0.9](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-mopen-handler@1.0.8...@ali/lowcode-datasource-mopen-handler@1.0.9) (2020-11-10)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-mopen-handler
-
-
-## [1.0.8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-mopen-handler@1.0.7...@ali/lowcode-datasource-mopen-handler@1.0.8) (2020-11-05)
-
-
-### Features
-
-* split datasource types ([fd80698](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/fd80698))
-
-
-
-
-
-## [1.0.7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-mopen-handler@1.0.6...@ali/lowcode-datasource-mopen-handler@1.0.7) (2020-11-05)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-mopen-handler
-
-
-## [1.0.6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-mopen-handler@1.0.5...@ali/lowcode-datasource-mopen-handler@1.0.6) (2020-11-05)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-mopen-handler
-
-
-## [1.0.5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-mopen-handler@1.0.4...@ali/lowcode-datasource-mopen-handler@1.0.5) (2020-11-04)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-mopen-handler
-
-
-## 1.0.4 (2020-11-04)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-mopen-handler
-
-
-## 1.0.3 (2020-11-04)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-mopen-handler
diff --git a/packages/datasource-mopen-handler/package.json b/packages/datasource-mopen-handler/package.json
deleted file mode 100644
index 55c7d6768..000000000
--- a/packages/datasource-mopen-handler/package.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "name": "@ali/lowcode-datasource-mopen-handler",
- "version": "1.0.21",
- "main": "lib/index.js",
- "module": "es/index.js",
- "typings": "es/index.d.ts",
- "files": [
- "src",
- "lib",
- "es"
- ],
- "scripts": {
- "dev": "tsc --watch",
- "clean": "rm -rf es lib",
- "build": "npm run clean && tsc && tsc --outDir ./lib --module commonjs ",
- "prepublishOnly": "npm run build"
- },
- "dependencies": {
- "@ali/lowcode-datasource-types": "^1.0.21",
- "@ali/mirror-io-client-mopen": "1.0.0-beta.16",
- "typescript": "^3.9.7"
- },
- "publishConfig": {
- "registry": "https://registry.npm.alibaba-inc.com"
- },
- "gitHead": "829e504c52a294fc28966ab0e491f4d2de1d4c90"
-}
diff --git a/packages/datasource-mopen-handler/src/index.ts b/packages/datasource-mopen-handler/src/index.ts
deleted file mode 100644
index beed626e0..000000000
--- a/packages/datasource-mopen-handler/src/index.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import {
- MopenClient,
- MopenClientConfig,
- MOPEN_APPKEY_XSPACE_PRE_ONLINE,
- MOPEN_DOMAIN_TAOBAO_PRE_ONLINE,
-} from '@ali/mirror-io-client-mopen';
-import { RuntimeOptionsConfig } from '@ali/lowcode-datasource-types';
-
-type Method = 'get' | 'post' | 'GET' | 'POST';
-
-type DataType = 'jsonp' | 'json' | 'originaljsonp';
-
-export function createMopenHandler(
- config: MopenClientConfig = {
- mtopDomain: MOPEN_DOMAIN_TAOBAO_PRE_ONLINE,
- appKey: MOPEN_APPKEY_XSPACE_PRE_ONLINE,
- },
-) {
- // eslint-disable-next-line space-before-function-paren
- return async function(options: RuntimeOptionsConfig): Promise<{ data: T }> {
- const { data, response } = await MopenClient.request({
- config,
- ...options,
- api: options.uri,
- v: options.v as string,
- data: options.params,
- type: (options.method as Method) || 'get',
- dataType: (options.dataType as DataType) || 'json',
- timeout: options.timeout,
- headers: options.headers,
- });
- return { ...response, data };
- };
-}
diff --git a/packages/datasource-mopen-handler/tsconfig.json b/packages/datasource-mopen-handler/tsconfig.json
deleted file mode 100644
index 4f788e5ed..000000000
--- a/packages/datasource-mopen-handler/tsconfig.json
+++ /dev/null
@@ -1,68 +0,0 @@
-{
- "compilerOptions": {
- "outDir": "es",
- "target": "es6",
- "module": "esnext",
- /* Basic Options */
- // "incremental": true, /* Enable incremental compilation */
- // "target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
- // "module": "esnext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
- "lib": [
- "ESNext",
- "DOM"
- ] /* Specify library files to be included in the compilation. */,
- // "allowJs": true, /* Allow javascript files to be compiled. */
- // "checkJs": true, /* Report errors in .js files. */
- // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
- "declaration": true /* Generates corresponding '.d.ts' file. */,
- // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
- // "sourceMap": true, /* Generates corresponding '.map' file. */
- // "outFile": "./", /* Concatenate and emit output to single file. */
- // "outDir": "es" /* Redirect output structure to the directory. */,
- // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
- // "composite": true, /* Enable project compilation */
- // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
- // "removeComments": true, /* Do not emit comments to output. */
- // "noEmit": true, /* Do not emit outputs. */
- // "importHelpers": true, /* Import emit helpers from 'tslib'. */
- // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
- // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
- /* Strict Type-Checking Options */
- "strict": true /* Enable all strict type-checking options. */,
- // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
- // "strictNullChecks": true, /* Enable strict null checks. */
- // "strictFunctionTypes": true, /* Enable strict checking of function types. */
- // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
- // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
- // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
- // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
- /* Additional Checks */
- // "noUnusedLocals": true, /* Report errors on unused locals. */
- // "noUnusedParameters": true, /* Report errors on unused parameters. */
- // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
- // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
- /* Module Resolution Options */
- "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
- // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
- // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
- // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
- // "typeRoots": [], /* List of folders to include type definitions from. */
- // "types": [], /* Type declaration files to be included in compilation. */
- // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
- "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
- // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
- /* Source Map Options */
- // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
- // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
- // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
- /* Experimental Options */
- // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
- // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
- /* Advanced Options */
- "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
- "skipLibCheck": true
- },
- "include": ["src/**/*"]
-}
diff --git a/packages/datasource-mtop-handler/.eslintignore b/packages/datasource-mtop-handler/.eslintignore
deleted file mode 100644
index fecb7c26d..000000000
--- a/packages/datasource-mtop-handler/.eslintignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/node_modules
-/es
-/lib
\ No newline at end of file
diff --git a/packages/datasource-mtop-handler/.eslintrc.js b/packages/datasource-mtop-handler/.eslintrc.js
deleted file mode 100644
index 8c13fcaf4..000000000
--- a/packages/datasource-mtop-handler/.eslintrc.js
+++ /dev/null
@@ -1,7 +0,0 @@
-module.exports = {
- extends: '../../.eslintrc',
- rules: {
- '@typescript-eslint/no-parameter-properties': 1,
- 'no-param-reassign': 0,
- },
-};
diff --git a/packages/datasource-mtop-handler/.prettierrc.js b/packages/datasource-mtop-handler/.prettierrc.js
deleted file mode 100644
index a425d3f76..000000000
--- a/packages/datasource-mtop-handler/.prettierrc.js
+++ /dev/null
@@ -1,4 +0,0 @@
-module.exports = {
- singleQuote: true,
- trailingComma: 'es5',
-};
diff --git a/packages/datasource-mtop-handler/CHANGELOG.md b/packages/datasource-mtop-handler/CHANGELOG.md
deleted file mode 100644
index c09332918..000000000
--- a/packages/datasource-mtop-handler/CHANGELOG.md
+++ /dev/null
@@ -1,82 +0,0 @@
-# Change Log
-
-All notable changes to this project will be documented in this file.
-See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
-
-
-## [1.0.21](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-mtop-handler@1.0.20...@ali/lowcode-datasource-mtop-handler@1.0.21) (2020-11-16)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-mtop-handler
-
-
-## [1.0.20](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-mtop-handler@1.0.8...@ali/lowcode-datasource-mtop-handler@1.0.20) (2020-11-10)
-
-
-### Bug Fixes
-
-* 设计和预览两种场景下 requestHandlersMap 的接入 ([f9e5397](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f9e5397))
-
-
-
-
-
-## [1.0.8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-mtop-handler@1.0.7...@ali/lowcode-datasource-mtop-handler@1.0.8) (2020-11-10)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-mtop-handler
-
-
-## [1.0.7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-mtop-handler@1.0.6...@ali/lowcode-datasource-mtop-handler@1.0.7) (2020-11-05)
-
-
-### Features
-
-* split datasource types ([fd80698](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/fd80698))
-
-
-
-
-
-## [1.0.6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-mtop-handler@1.0.5...@ali/lowcode-datasource-mtop-handler@1.0.6) (2020-11-05)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-mtop-handler
-
-
-## [1.0.5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-mtop-handler@1.0.4...@ali/lowcode-datasource-mtop-handler@1.0.5) (2020-11-05)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-mtop-handler
-
-
-## [1.0.4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-mtop-handler@1.0.3...@ali/lowcode-datasource-mtop-handler@1.0.4) (2020-11-04)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-mtop-handler
-
-
-## 1.0.3 (2020-11-04)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-mtop-handler
-
-
-## 1.0.2 (2020-11-04)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-mtop-handler
diff --git a/packages/datasource-mtop-handler/package.json b/packages/datasource-mtop-handler/package.json
deleted file mode 100644
index f8f12da7b..000000000
--- a/packages/datasource-mtop-handler/package.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "name": "@ali/lowcode-datasource-mtop-handler",
- "version": "1.0.22-alpha.1",
- "main": "lib/index.js",
- "module": "es/index.js",
- "typings": "es/index.d.ts",
- "files": [
- "src",
- "lib",
- "es"
- ],
- "scripts": {
- "dev": "tsc --watch",
- "clean": "rm -rf es lib",
- "build": "npm run clean && tsc && tsc --outDir ./lib --module commonjs ",
- "prepublishOnly": "npm run build"
- },
- "dependencies": {
- "@ali/lowcode-datasource-types": "^1.0.22-alpha.2",
- "@ali/universal-mtop": "^5.1.9",
- "typescript": "^3.9.7"
- },
- "publishConfig": {
- "registry": "https://registry.npm.alibaba-inc.com"
- },
- "gitHead": "829e504c52a294fc28966ab0e491f4d2de1d4c90"
-}
diff --git a/packages/datasource-mtop-handler/src/index.ts b/packages/datasource-mtop-handler/src/index.ts
deleted file mode 100644
index db11cfc76..000000000
--- a/packages/datasource-mtop-handler/src/index.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-import mtopRequest from '@ali/universal-mtop';
-
-import { RuntimeOptionsConfig } from '@ali/lowcode-datasource-types';
-
-export type Method = 'get' | 'post' | 'GET' | 'POST';
-
-export type DataType = 'jsonp' | 'json' | 'originaljsonp';
-
-// 考虑一下 mtop 类型的问题,官方没有提供 ts 文件
-export function createMtopHandler(config?: MTopConfig) {
- if (config && Object.keys(config).length > 0) {
- Object.keys(config).forEach((key: string) => {
- mtopRequest.config(key, config[key]);
- });
- }
- // eslint-disable-next-line space-before-function-paren
- return async function(options: RuntimeOptionsConfig): Promise<{ data: T }> {
- const response = await mtopRequest.request({
- api: options.uri || options.api, // 兼容老的结构
- v: (options.v as string) || '1.0',
- data: options.params,
- type: (options.method as Method) || 'get',
- dataType: (options.dataType as DataType) || 'json',
- timeout: options.timeout,
- headers: options.headers,
- });
- if (response.ret && response.ret[0].indexOf('SUCCESS::') > -1) {
- // 校验成功
- return response;
- }
- // 默认异常
- let errorMsg = '未知异常';
- if (response.ret && response.ret[0]) {
- errorMsg = response.ret[0];
- }
- throw new Error(errorMsg);
- };
-}
diff --git a/packages/datasource-mtop-handler/src/typings.d.ts b/packages/datasource-mtop-handler/src/typings.d.ts
deleted file mode 100644
index 11f4d02cd..000000000
--- a/packages/datasource-mtop-handler/src/typings.d.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-declare interface MTopConfig {
- prefix?: string;
- subDomain?: string;
- mainDomain?: string;
- [index: string]: unknown;
-}
-
-declare module '@ali/universal-mtop' {
- const request: (config: any) => Promise<{ data: T; ret: string[] }>;
- const config: (key: string, value: unknown) => void;
-}
diff --git a/packages/datasource-mtop-handler/tsconfig.json b/packages/datasource-mtop-handler/tsconfig.json
deleted file mode 100644
index 4f788e5ed..000000000
--- a/packages/datasource-mtop-handler/tsconfig.json
+++ /dev/null
@@ -1,68 +0,0 @@
-{
- "compilerOptions": {
- "outDir": "es",
- "target": "es6",
- "module": "esnext",
- /* Basic Options */
- // "incremental": true, /* Enable incremental compilation */
- // "target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
- // "module": "esnext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
- "lib": [
- "ESNext",
- "DOM"
- ] /* Specify library files to be included in the compilation. */,
- // "allowJs": true, /* Allow javascript files to be compiled. */
- // "checkJs": true, /* Report errors in .js files. */
- // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
- "declaration": true /* Generates corresponding '.d.ts' file. */,
- // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
- // "sourceMap": true, /* Generates corresponding '.map' file. */
- // "outFile": "./", /* Concatenate and emit output to single file. */
- // "outDir": "es" /* Redirect output structure to the directory. */,
- // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
- // "composite": true, /* Enable project compilation */
- // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
- // "removeComments": true, /* Do not emit comments to output. */
- // "noEmit": true, /* Do not emit outputs. */
- // "importHelpers": true, /* Import emit helpers from 'tslib'. */
- // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
- // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
- /* Strict Type-Checking Options */
- "strict": true /* Enable all strict type-checking options. */,
- // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
- // "strictNullChecks": true, /* Enable strict null checks. */
- // "strictFunctionTypes": true, /* Enable strict checking of function types. */
- // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
- // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
- // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
- // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
- /* Additional Checks */
- // "noUnusedLocals": true, /* Report errors on unused locals. */
- // "noUnusedParameters": true, /* Report errors on unused parameters. */
- // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
- // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
- /* Module Resolution Options */
- "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
- // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
- // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
- // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
- // "typeRoots": [], /* List of folders to include type definitions from. */
- // "types": [], /* Type declaration files to be included in compilation. */
- // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
- "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
- // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
- /* Source Map Options */
- // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
- // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
- // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
- /* Experimental Options */
- // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
- // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
- /* Advanced Options */
- "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
- "skipLibCheck": true
- },
- "include": ["src/**/*"]
-}
diff --git a/packages/datasource-types/.eslintignore b/packages/datasource-types/.eslintignore
deleted file mode 100644
index a218a6cce..000000000
--- a/packages/datasource-types/.eslintignore
+++ /dev/null
@@ -1,3 +0,0 @@
-lib
-es
-node_modules
\ No newline at end of file
diff --git a/packages/datasource-types/.eslintrc.js b/packages/datasource-types/.eslintrc.js
deleted file mode 100644
index f7538bcee..000000000
--- a/packages/datasource-types/.eslintrc.js
+++ /dev/null
@@ -1,7 +0,0 @@
-module.exports = {
- extends: '../../.eslintrc',
- rules: {
- '@typescript-eslint/member-ordering': 0,
- indent: 0,
- },
-};
diff --git a/packages/datasource-types/.prettierrc.js b/packages/datasource-types/.prettierrc.js
deleted file mode 100644
index 092b67059..000000000
--- a/packages/datasource-types/.prettierrc.js
+++ /dev/null
@@ -1,6 +0,0 @@
-module.exports = {
- printWidth: 80,
- singleQuote: true,
- trailingComma: 'all',
- tabSize: 2,
-};
diff --git a/packages/datasource-types/CHANGELOG.md b/packages/datasource-types/CHANGELOG.md
deleted file mode 100644
index 63f515379..000000000
--- a/packages/datasource-types/CHANGELOG.md
+++ /dev/null
@@ -1,43 +0,0 @@
-# Change Log
-
-All notable changes to this project will be documented in this file.
-See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
-
-
-## [1.0.21](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-types@1.0.20...@ali/lowcode-datasource-types@1.0.21) (2020-11-16)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-types
-
-
-## [1.0.20](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-types@1.0.2...@ali/lowcode-datasource-types@1.0.20) (2020-11-10)
-
-
-### Bug Fixes
-
-* 设计和预览两种场景下 requestHandlersMap 的接入 ([f9e5397](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f9e5397))
-* 修复数据源的接入问题 ([98ae1ed](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/98ae1ed))
-
-
-
-
-
-## [1.0.2](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-types@1.0.1...@ali/lowcode-datasource-types@1.0.2) (2020-11-10)
-
-
-### Features
-
-* update datasource engine ([bf7b7d1](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/bf7b7d1))
-
-
-
-
-
-## 1.0.1 (2020-11-05)
-
-
-### Features
-
-* split datasource types ([fd80698](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/fd80698))
diff --git a/packages/datasource-types/package.json b/packages/datasource-types/package.json
deleted file mode 100644
index ce01675d8..000000000
--- a/packages/datasource-types/package.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "name": "@ali/lowcode-datasource-types",
- "version": "1.0.22-alpha.2",
- "main": "lib/index.js",
- "module": "es/index.js",
- "typings": "es/index.d.ts",
- "files": [
- "src",
- "lib",
- "es"
- ],
- "scripts": {
- "dev": "tsc --watch",
- "clean": "rm -rf es lib",
- "build": "npm run clean && tsc && tsc --outDir ./lib --module commonjs ",
- "prepublishOnly": "npm run build"
- },
- "publishConfig": {
- "registry": "https://registry.npm.alibaba-inc.com"
- }
-}
diff --git a/packages/datasource-types/src/data-source-handlers.ts b/packages/datasource-types/src/data-source-handlers.ts
deleted file mode 100644
index 4ee7f6a0b..000000000
--- a/packages/datasource-types/src/data-source-handlers.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import {
- IDataSourceRuntimeContext,
- RuntimeOptionsConfig,
-} from './data-source-runtime';
-
-export type RequestHandler = (
- options: RuntimeOptionsConfig,
- context?: IDataSourceRuntimeContext,
-) => Promise;
-
-export type UrlParamsHandler = (
- context?: IDataSourceRuntimeContext,
-) => Promise;
-
-export type RequestHandlersMap = Record>;
-
-// 仅在 type=custom 的时候生效的 handler
-export type CustomRequestHandler = (
- options: RuntimeOptionsConfig,
- context?: IDataSourceRuntimeContext,
-) => Promise;
diff --git a/packages/datasource-types/src/data-source-interpret.ts b/packages/datasource-types/src/data-source-interpret.ts
deleted file mode 100644
index 0c303b55f..000000000
--- a/packages/datasource-types/src/data-source-interpret.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import {
- CompositeValue,
- JSExpression,
- JSFunction,
- JSONObject,
-} from './value-type';
-
-/**
- * 数据源对象
- * @see https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#XMeF5
- */
-export interface InterpretDataSource {
- list: InterpretDataSourceConfig[];
- dataHandler?: JSFunction;
-}
-
-/**
- * 数据源对象
- * @see https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#XMeF5
- */
-export interface InterpretDataSourceConfig {
- id: string;
- isInit?: boolean | JSExpression;
- isSync?: boolean | JSExpression;
- type?: string;
- requestHandler?: JSFunction;
- dataHandler?: JSFunction;
- errorHandler?: JSFunction;
- willFetch?: JSFunction;
- shouldFetch?: JSFunction;
- options?: {
- uri: string | JSExpression;
- api?: string | JSExpression; // 兼容
- params?: JSONObject | JSExpression;
- method?: string | JSExpression;
- isCors?: boolean | JSExpression;
- timeout?: number | JSExpression;
- headers?: JSONObject | JSExpression;
- [option: string]: CompositeValue;
- };
- [otherKey: string]: CompositeValue;
-}
diff --git a/packages/datasource-types/src/data-source-runtime.ts b/packages/datasource-types/src/data-source-runtime.ts
deleted file mode 100644
index 191492737..000000000
--- a/packages/datasource-types/src/data-source-runtime.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-import { IRuntimeDataSource } from './data-source';
-import { CustomRequestHandler } from './data-source-handlers';
-
-// 先定义运行模式的类型
-export interface RuntimeDataSource {
- list: RuntimeDataSourceConfig[];
- dataHandler?: (dataSourceMap: DataSourceMap) => void;
-}
-
-export type DataSourceMap = Record;
-
-export interface RuntimeDataSourceConfig {
- id: string;
- isInit?: boolean;
- isSync?: boolean;
- type?: string;
- willFetch?: WillFetch;
- shouldFetch?: () => boolean;
- requestHandler?: CustomRequestHandler;
- dataHandler?: DataHandler;
- errorHandler?: ErrorHandler;
- options?: RuntimeOptions;
- [otherKey: string]: unknown;
-}
-
-export type WillFetch = (
- options: RuntimeOptionsConfig,
-) => Promise | RuntimeOptionsConfig;
-
-export type DataHandler = (response: {
- data: T;
- [index: string]: unknown;
-}) => Promise;
-
-export type ErrorHandler = (err: unknown) => Promise;
-
-export type RuntimeOptions = () => RuntimeOptionsConfig;
-
-export interface RuntimeOptionsConfig {
- uri: string;
- api?: string;
- params?: Record;
- method?: string;
- isCors?: boolean;
- timeout?: number;
- headers?: Record;
- [option: string]: unknown;
-}
-
-// 可以采用 react 的 state,但是需要注意必须提供同步的 setState 功能
-export interface IDataSourceRuntimeContext<
- TState extends Record = Record
-> {
- /** 当前数据源的内容 */
- state: TState;
- /** 设置状态(浅合并) */
- setState(state: Partial): void;
-}
diff --git a/packages/datasource-types/src/data-source.ts b/packages/datasource-types/src/data-source.ts
deleted file mode 100644
index f93ca2ded..000000000
--- a/packages/datasource-types/src/data-source.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-import { RequestHandlersMap } from './data-source-handlers';
-import {
- IDataSourceRuntimeContext,
- RuntimeDataSource,
-} from './data-source-runtime';
-
-/** 数据源的状态 */
-export enum RuntimeDataSourceStatus {
- /** 初始状态,尚未加载 */
- Initial = 'init',
-
- /** 正在加载 */
- Loading = 'loading',
-
- /** 已加载(无错误) */
- Loaded = 'loaded',
-
- /** 加载出错了 */
- Error = 'error',
-}
-
-/**
- * 运行时的数据源(对外暴露的接口)
- * @see https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#Jwgj5
- */
-export interface IRuntimeDataSource {
- /** 当前状态(initial/loading/loaded/error) */
- readonly status: RuntimeDataSourceStatus;
-
- /** 加载成功时的数据 */
- readonly data?: TResultData;
-
- /** 加载出错的时候的错误信息 */
- readonly error?: Error;
-
- /**
- * 加载数据 (无论是否曾经加载过)
- * 注意:若提供 params,则会和默认配置的参数做浅合并;否则会使用默认配置的参数。
- */
- load(params?: TParams): Promise;
-}
-
-/**
- * DataSourceEngineFactory
- * 用来定义 engine 的工厂函数类型
- */
-export interface IRuntimeDataSourceEngineFactory {
- create(
- dataSource: RuntimeDataSource,
- context: IDataSourceRuntimeContext,
- extraConfig?: {
- requestHandlersMap: RequestHandlersMap;
- [key: string]: any;
- },
- ): IDataSourceEngine;
-}
-
-// create 返回的 DataSourceEngine 定义
-export interface IDataSourceEngine {
- /** 数据源, key 是数据源的 ID */
- dataSourceMap: Record;
-
- /** 重新加载所有的数据源 */
- reloadDataSource(): Promise;
-}
diff --git a/packages/datasource-types/src/index.ts b/packages/datasource-types/src/index.ts
deleted file mode 100644
index f7f9d21d3..000000000
--- a/packages/datasource-types/src/index.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export * from './data-source';
-export * from './data-source-handlers';
-export * from './data-source-interpret';
-export * from './data-source-runtime';
diff --git a/packages/datasource-types/src/value-type.ts b/packages/datasource-types/src/value-type.ts
deleted file mode 100644
index bb959b498..000000000
--- a/packages/datasource-types/src/value-type.ts
+++ /dev/null
@@ -1,91 +0,0 @@
-// 表达式
-export interface JSExpression {
- type: 'JSExpression';
- /**
- * 表达式字符串
- */
- value: string;
- /**
- * 模拟值
- */
- mock?: any;
- /** 源码 */
- compiled?: string;
-}
-
-// 函数
-export interface JSFunction {
- type: 'JSFunction';
- /**
- * 表达式字符串
- */
- value: string;
-}
-
-/**
- * 事件函数类型
- * @see https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#feHTW
- */
-export interface JSFunction {
- type: 'JSFunction';
-
- /**
- * 函数定义,或直接函数表达式
- */
- value: string;
-
- /** 源码 */
- compiled?: string;
-}
-
-// 函数
-export interface JSFunction {
- type: 'JSFunction';
- /**
- * 函数字符串
- */
- value: string;
- /**
- * 模拟值
- */
- mock?: any;
- /**
- * 额外扩展属性,如 extType、events
- */
- [key: string]: any;
-}
-
-// JSON 基本类型
-export type JSONValue =
- | boolean
- | string
- | number
- | null
- | undefined
- | JSONArray
- | JSONObject;
-export type JSONArray = JSONValue[];
-export interface JSONObject {
- [key: string]: JSONValue;
-}
-
-// 复合类型
-export type CompositeValue =
- | JSONValue
- | JSExpression
- | JSFunction
- // | JSSlot // 后续这里应该要再提取一个 base types
- | CompositeArray
- | CompositeObject;
-export type CompositeArray = CompositeValue[];
-export interface CompositeObject {
- [key: string]: CompositeValue;
-}
-
-export function isJSExpression(data: any): data is JSExpression {
- return data && data.type === 'JSExpression';
-}
-
-export function isJSFunction(x: any): x is JSFunction {
- return typeof x === 'object' && x && x.type === 'JSFunction';
-}
diff --git a/packages/datasource-types/tsconfig.json b/packages/datasource-types/tsconfig.json
deleted file mode 100644
index af012d64b..000000000
--- a/packages/datasource-types/tsconfig.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "extends": "../../tsconfig.json",
- "compilerOptions": {
- "outDir": "es"
- },
- "include": ["./src/"]
-}
diff --git a/packages/datasource-universal-mtop-handler/.eslintignore b/packages/datasource-universal-mtop-handler/.eslintignore
deleted file mode 100644
index fecb7c26d..000000000
--- a/packages/datasource-universal-mtop-handler/.eslintignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/node_modules
-/es
-/lib
\ No newline at end of file
diff --git a/packages/datasource-universal-mtop-handler/.eslintrc.js b/packages/datasource-universal-mtop-handler/.eslintrc.js
deleted file mode 100644
index 8c13fcaf4..000000000
--- a/packages/datasource-universal-mtop-handler/.eslintrc.js
+++ /dev/null
@@ -1,7 +0,0 @@
-module.exports = {
- extends: '../../.eslintrc',
- rules: {
- '@typescript-eslint/no-parameter-properties': 1,
- 'no-param-reassign': 0,
- },
-};
diff --git a/packages/datasource-universal-mtop-handler/.prettierrc.js b/packages/datasource-universal-mtop-handler/.prettierrc.js
deleted file mode 100644
index de2f53cdf..000000000
--- a/packages/datasource-universal-mtop-handler/.prettierrc.js
+++ /dev/null
@@ -1,4 +0,0 @@
-module.exports = {
- singleQuote: true,
- trailingComma: 'all',
-};
diff --git a/packages/datasource-universal-mtop-handler/CHANGELOG.md b/packages/datasource-universal-mtop-handler/CHANGELOG.md
deleted file mode 100644
index 591bf31fe..000000000
--- a/packages/datasource-universal-mtop-handler/CHANGELOG.md
+++ /dev/null
@@ -1,82 +0,0 @@
-# Change Log
-
-All notable changes to this project will be documented in this file.
-See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
-
-
-## [1.0.21](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-universal-mtop-handler@1.0.20...@ali/lowcode-datasource-universal-mtop-handler@1.0.21) (2020-11-16)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-universal-mtop-handler
-
-
-## [1.0.20](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-universal-mtop-handler@1.0.8...@ali/lowcode-datasource-universal-mtop-handler@1.0.20) (2020-11-10)
-
-
-### Bug Fixes
-
-* 设计和预览两种场景下 requestHandlersMap 的接入 ([f9e5397](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f9e5397))
-
-
-
-
-
-## [1.0.8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-universal-mtop-handler@1.0.7...@ali/lowcode-datasource-universal-mtop-handler@1.0.8) (2020-11-10)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-universal-mtop-handler
-
-
-## [1.0.7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-universal-mtop-handler@1.0.6...@ali/lowcode-datasource-universal-mtop-handler@1.0.7) (2020-11-05)
-
-
-### Features
-
-* split datasource types ([fd80698](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/fd80698))
-
-
-
-
-
-## [1.0.6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-universal-mtop-handler@1.0.5...@ali/lowcode-datasource-universal-mtop-handler@1.0.6) (2020-11-05)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-universal-mtop-handler
-
-
-## [1.0.5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-universal-mtop-handler@1.0.4...@ali/lowcode-datasource-universal-mtop-handler@1.0.5) (2020-11-05)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-universal-mtop-handler
-
-
-## [1.0.4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-universal-mtop-handler@1.0.3...@ali/lowcode-datasource-universal-mtop-handler@1.0.4) (2020-11-04)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-universal-mtop-handler
-
-
-## 1.0.3 (2020-11-04)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-universal-mtop-handler
-
-
-## 1.0.2 (2020-11-04)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-universal-mtop-handler
diff --git a/packages/datasource-universal-mtop-handler/package.json b/packages/datasource-universal-mtop-handler/package.json
deleted file mode 100644
index 65b8cc4a7..000000000
--- a/packages/datasource-universal-mtop-handler/package.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "name": "@ali/lowcode-datasource-universal-mtop-handler",
- "version": "1.0.21",
- "main": "lib/index.js",
- "module": "es/index.js",
- "typings": "es/index.d.ts",
- "files": [
- "src",
- "lib",
- "es"
- ],
- "scripts": {
- "dev": "tsc --watch",
- "clean": "rm -rf es lib",
- "build": "npm run clean && tsc && tsc --outDir ./lib --module commonjs ",
- "prepublishOnly": "npm run build"
- },
- "dependencies": {
- "@ali/lowcode-datasource-types": "^1.0.21",
- "@ali/mirror-io-client-universal-mtop": "1.0.0-beta.16",
- "typescript": "^3.9.7"
- },
- "publishConfig": {
- "registry": "https://registry.npm.alibaba-inc.com"
- },
- "gitHead": "829e504c52a294fc28966ab0e491f4d2de1d4c90"
-}
diff --git a/packages/datasource-universal-mtop-handler/src/index.ts b/packages/datasource-universal-mtop-handler/src/index.ts
deleted file mode 100644
index 09138fcbe..000000000
--- a/packages/datasource-universal-mtop-handler/src/index.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import {
- UniversalMtopClient,
- UniversalMtopClientConfig,
-} from '@ali/mirror-io-client-universal-mtop';
-
-import { RuntimeOptionsConfig } from '@ali/lowcode-datasource-types';
-
-type Method = 'get' | 'post' | 'GET' | 'POST';
-
-type DataType = 'jsonp' | 'json' | 'originaljsonp';
-
-export function createMopenHandler(
- config?: UniversalMtopClientConfig,
-) {
- // eslint-disable-next-line space-before-function-paren
- return async function(options: RuntimeOptionsConfig): Promise<{ data: T }> {
- const { data, response } = await UniversalMtopClient.request({
- config,
- ...options,
- api: options.uri,
- v: options.v as string,
- data: options.params,
- type: (options.method as Method) || 'get',
- dataType: (options.dataType as DataType) || 'json',
- timeout: options.timeout,
- headers: options.headers,
- });
- return { ...response, data };
- };
-}
diff --git a/packages/datasource-universal-mtop-handler/tsconfig.json b/packages/datasource-universal-mtop-handler/tsconfig.json
deleted file mode 100644
index 4f788e5ed..000000000
--- a/packages/datasource-universal-mtop-handler/tsconfig.json
+++ /dev/null
@@ -1,68 +0,0 @@
-{
- "compilerOptions": {
- "outDir": "es",
- "target": "es6",
- "module": "esnext",
- /* Basic Options */
- // "incremental": true, /* Enable incremental compilation */
- // "target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
- // "module": "esnext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
- "lib": [
- "ESNext",
- "DOM"
- ] /* Specify library files to be included in the compilation. */,
- // "allowJs": true, /* Allow javascript files to be compiled. */
- // "checkJs": true, /* Report errors in .js files. */
- // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
- "declaration": true /* Generates corresponding '.d.ts' file. */,
- // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
- // "sourceMap": true, /* Generates corresponding '.map' file. */
- // "outFile": "./", /* Concatenate and emit output to single file. */
- // "outDir": "es" /* Redirect output structure to the directory. */,
- // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
- // "composite": true, /* Enable project compilation */
- // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
- // "removeComments": true, /* Do not emit comments to output. */
- // "noEmit": true, /* Do not emit outputs. */
- // "importHelpers": true, /* Import emit helpers from 'tslib'. */
- // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
- // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
- /* Strict Type-Checking Options */
- "strict": true /* Enable all strict type-checking options. */,
- // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
- // "strictNullChecks": true, /* Enable strict null checks. */
- // "strictFunctionTypes": true, /* Enable strict checking of function types. */
- // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
- // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
- // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
- // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
- /* Additional Checks */
- // "noUnusedLocals": true, /* Report errors on unused locals. */
- // "noUnusedParameters": true, /* Report errors on unused parameters. */
- // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
- // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
- /* Module Resolution Options */
- "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
- // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
- // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
- // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
- // "typeRoots": [], /* List of folders to include type definitions from. */
- // "types": [], /* Type declaration files to be included in compilation. */
- // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
- "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
- // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
- /* Source Map Options */
- // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
- // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
- // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
- /* Experimental Options */
- // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
- // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
- /* Advanced Options */
- "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
- "skipLibCheck": true
- },
- "include": ["src/**/*"]
-}
diff --git a/packages/datasource-url-params-handler/.eslintignore b/packages/datasource-url-params-handler/.eslintignore
deleted file mode 100644
index fecb7c26d..000000000
--- a/packages/datasource-url-params-handler/.eslintignore
+++ /dev/null
@@ -1,3 +0,0 @@
-/node_modules
-/es
-/lib
\ No newline at end of file
diff --git a/packages/datasource-url-params-handler/.eslintrc.js b/packages/datasource-url-params-handler/.eslintrc.js
deleted file mode 100644
index 8c13fcaf4..000000000
--- a/packages/datasource-url-params-handler/.eslintrc.js
+++ /dev/null
@@ -1,7 +0,0 @@
-module.exports = {
- extends: '../../.eslintrc',
- rules: {
- '@typescript-eslint/no-parameter-properties': 1,
- 'no-param-reassign': 0,
- },
-};
diff --git a/packages/datasource-url-params-handler/.prettierrc.js b/packages/datasource-url-params-handler/.prettierrc.js
deleted file mode 100644
index e69de29bb..000000000
diff --git a/packages/datasource-url-params-handler/CHANGELOG.md b/packages/datasource-url-params-handler/CHANGELOG.md
deleted file mode 100644
index c5991ac44..000000000
--- a/packages/datasource-url-params-handler/CHANGELOG.md
+++ /dev/null
@@ -1,82 +0,0 @@
-# Change Log
-
-All notable changes to this project will be documented in this file.
-See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
-
-
-## [1.0.21](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-url-params-handler@1.0.20...@ali/lowcode-datasource-url-params-handler@1.0.21) (2020-11-16)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-url-params-handler
-
-
-## [1.0.20](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-url-params-handler@1.0.8...@ali/lowcode-datasource-url-params-handler@1.0.20) (2020-11-10)
-
-
-### Bug Fixes
-
-* 设计和预览两种场景下 requestHandlersMap 的接入 ([f9e5397](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/f9e5397))
-
-
-
-
-
-## [1.0.8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-url-params-handler@1.0.7...@ali/lowcode-datasource-url-params-handler@1.0.8) (2020-11-10)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-url-params-handler
-
-
-## [1.0.7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-url-params-handler@1.0.6...@ali/lowcode-datasource-url-params-handler@1.0.7) (2020-11-05)
-
-
-### Features
-
-* split datasource types ([fd80698](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/fd80698))
-
-
-
-
-
-## [1.0.6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-url-params-handler@1.0.5...@ali/lowcode-datasource-url-params-handler@1.0.6) (2020-11-05)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-url-params-handler
-
-
-## [1.0.5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-url-params-handler@1.0.4...@ali/lowcode-datasource-url-params-handler@1.0.5) (2020-11-05)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-url-params-handler
-
-
-## [1.0.4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-datasource-url-params-handler@1.0.3...@ali/lowcode-datasource-url-params-handler@1.0.4) (2020-11-04)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-url-params-handler
-
-
-## 1.0.3 (2020-11-04)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-url-params-handler
-
-
-## 1.0.2 (2020-11-04)
-
-
-
-
-**Note:** Version bump only for package @ali/lowcode-datasource-url-params-handler
diff --git a/packages/datasource-url-params-handler/package.json b/packages/datasource-url-params-handler/package.json
deleted file mode 100644
index 21c79cc6e..000000000
--- a/packages/datasource-url-params-handler/package.json
+++ /dev/null
@@ -1,27 +0,0 @@
-{
- "name": "@ali/lowcode-datasource-url-params-handler",
- "version": "1.0.21",
- "main": "lib/index.js",
- "module": "es/index.js",
- "typings": "es/index.d.ts",
- "files": [
- "src",
- "lib",
- "es"
- ],
- "scripts": {
- "dev": "tsc --watch",
- "clean": "rm -rf es lib",
- "build": "npm run clean && tsc && tsc --outDir ./lib --module commonjs ",
- "prepublishOnly": "npm run build"
- },
- "dependencies": {
- "@ali/lowcode-datasource-types": "^1.0.21",
- "query-string": "^6.13.1",
- "typescript": "^3.9.7"
- },
- "publishConfig": {
- "registry": "https://registry.npm.alibaba-inc.com"
- },
- "gitHead": "829e504c52a294fc28966ab0e491f4d2de1d4c90"
-}
diff --git a/packages/datasource-url-params-handler/src/index.ts b/packages/datasource-url-params-handler/src/index.ts
deleted file mode 100644
index 3b2fb8ee6..000000000
--- a/packages/datasource-url-params-handler/src/index.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import qs from 'query-string';
-import { UrlParamsHandler } from '@ali/lowcode-datasource-types';
-
-export function createUrlParamsHandler(
- searchString: string | T = '',
-): UrlParamsHandler {
- // eslint-disable-next-line space-before-function-paren
- return async function(): Promise {
- if (typeof searchString === 'string') {
- const params = (qs.parse(searchString) as unknown) as T;
- return params;
- }
-
- return searchString;
- };
-}
diff --git a/packages/datasource-url-params-handler/tsconfig.json b/packages/datasource-url-params-handler/tsconfig.json
deleted file mode 100644
index eeea7a79b..000000000
--- a/packages/datasource-url-params-handler/tsconfig.json
+++ /dev/null
@@ -1,65 +0,0 @@
-{
- "compilerOptions": {
- "outDir": "es",
- "target": "es6",
- "module": "esnext",
- /* Basic Options */
- // "incremental": true, /* Enable incremental compilation */
- // "target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
- // "module": "esnext" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
- "lib": ["ESNext", "DOM"] /* Specify library files to be included in the compilation. */,
- // "allowJs": true, /* Allow javascript files to be compiled. */
- // "checkJs": true, /* Report errors in .js files. */
- // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
- "declaration": true /* Generates corresponding '.d.ts' file. */,
- // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
- // "sourceMap": true, /* Generates corresponding '.map' file. */
- // "outFile": "./", /* Concatenate and emit output to single file. */
- // "outDir": "es" /* Redirect output structure to the directory. */,
- // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
- // "composite": true, /* Enable project compilation */
- // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
- // "removeComments": true, /* Do not emit comments to output. */
- // "noEmit": true, /* Do not emit outputs. */
- // "importHelpers": true, /* Import emit helpers from 'tslib'. */
- // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
- // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
- /* Strict Type-Checking Options */
- "strict": true /* Enable all strict type-checking options. */,
- // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
- // "strictNullChecks": true, /* Enable strict null checks. */
- // "strictFunctionTypes": true, /* Enable strict checking of function types. */
- // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
- // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
- // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
- // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
- /* Additional Checks */
- // "noUnusedLocals": true, /* Report errors on unused locals. */
- // "noUnusedParameters": true, /* Report errors on unused parameters. */
- // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
- // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
- /* Module Resolution Options */
- "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
- // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
- // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
- // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
- // "typeRoots": [], /* List of folders to include type definitions from. */
- // "types": [], /* Type declaration files to be included in compilation. */
- // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
- "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
- // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
- /* Source Map Options */
- // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
- // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
- // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
- /* Experimental Options */
- // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
- // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
- /* Advanced Options */
- "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
- "skipLibCheck": true
- },
- "include": ["src/**/*"]
-}