From 624e2f8d1e276f10867541edf7cf573bd535e9c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=A7=E6=AF=85?= Date: Wed, 19 Aug 2020 09:50:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=BA=90=E5=BC=95=E6=93=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/datasource-engine/.gitignore | 5 + .../handlers/fetch/index.d.ts | 1 + .../datasource-engine/handlers/fetch/index.js | 1 + .../handlers/mtop/index.d.ts | 1 + .../datasource-engine/handlers/mtop/index.js | 1 + .../handlers/url-params/index.d.ts | 1 + .../handlers/url-params/index.js | 1 + packages/datasource-engine/package.json | 34 +++++ .../src/core/DataSourceEngine.ts | 134 ++++++++++++++++++ .../src/core/RuntimeDataSource.ts | 98 +++++++++++++ packages/datasource-engine/src/core/index.ts | 1 + .../datasource-engine/src/handlers/fetch.ts | 24 ++++ .../datasource-engine/src/handlers/mtop.ts | 15 ++ .../src/handlers/url-params.ts | 14 ++ packages/datasource-engine/src/index.ts | 2 + .../src/types/DataSourceConfig.ts | 6 + .../src/types/DataSourceConfigItem.ts | 17 +++ .../src/types/DataSourceEngineOptions.ts | 7 + .../src/types/DataSourceOptions.ts | 10 ++ .../src/types/IDataSourceEngine.ts | 9 ++ .../src/types/IDataSourceEngineFactory.ts | 12 ++ .../src/types/IRuntimeContext.ts | 24 ++++ .../src/types/IRuntimeDataSource.ts | 22 +++ .../src/types/RequestHandler.ts | 6 + .../src/types/RuntimeDataSourceStatus.ts | 14 ++ packages/datasource-engine/src/types/index.ts | 1 + packages/datasource-engine/src/typing.d.ts | 1 + packages/datasource-engine/tsconfig.json | 80 +++++++++++ 28 files changed, 542 insertions(+) create mode 100644 packages/datasource-engine/.gitignore create mode 100644 packages/datasource-engine/handlers/fetch/index.d.ts create mode 100644 packages/datasource-engine/handlers/fetch/index.js create mode 100644 packages/datasource-engine/handlers/mtop/index.d.ts create mode 100644 packages/datasource-engine/handlers/mtop/index.js create mode 100644 packages/datasource-engine/handlers/url-params/index.d.ts create mode 100644 packages/datasource-engine/handlers/url-params/index.js create mode 100644 packages/datasource-engine/package.json create mode 100644 packages/datasource-engine/src/core/DataSourceEngine.ts create mode 100644 packages/datasource-engine/src/core/RuntimeDataSource.ts create mode 100644 packages/datasource-engine/src/core/index.ts create mode 100644 packages/datasource-engine/src/handlers/fetch.ts create mode 100644 packages/datasource-engine/src/handlers/mtop.ts create mode 100644 packages/datasource-engine/src/handlers/url-params.ts create mode 100644 packages/datasource-engine/src/index.ts create mode 100644 packages/datasource-engine/src/types/DataSourceConfig.ts create mode 100644 packages/datasource-engine/src/types/DataSourceConfigItem.ts create mode 100644 packages/datasource-engine/src/types/DataSourceEngineOptions.ts create mode 100644 packages/datasource-engine/src/types/DataSourceOptions.ts create mode 100644 packages/datasource-engine/src/types/IDataSourceEngine.ts create mode 100644 packages/datasource-engine/src/types/IDataSourceEngineFactory.ts create mode 100644 packages/datasource-engine/src/types/IRuntimeContext.ts create mode 100644 packages/datasource-engine/src/types/IRuntimeDataSource.ts create mode 100644 packages/datasource-engine/src/types/RequestHandler.ts create mode 100644 packages/datasource-engine/src/types/RuntimeDataSourceStatus.ts create mode 100644 packages/datasource-engine/src/types/index.ts create mode 100644 packages/datasource-engine/src/typing.d.ts create mode 100644 packages/datasource-engine/tsconfig.json diff --git a/packages/datasource-engine/.gitignore b/packages/datasource-engine/.gitignore new file mode 100644 index 000000000..28b6557db --- /dev/null +++ b/packages/datasource-engine/.gitignore @@ -0,0 +1,5 @@ +/node_modules/ +*.log +.DS_Store +/es/ +/lib/ diff --git a/packages/datasource-engine/handlers/fetch/index.d.ts b/packages/datasource-engine/handlers/fetch/index.d.ts new file mode 100644 index 000000000..86829236a --- /dev/null +++ b/packages/datasource-engine/handlers/fetch/index.d.ts @@ -0,0 +1 @@ +export type * from '../../es/handlers/fetch'; diff --git a/packages/datasource-engine/handlers/fetch/index.js b/packages/datasource-engine/handlers/fetch/index.js new file mode 100644 index 000000000..5abed6279 --- /dev/null +++ b/packages/datasource-engine/handlers/fetch/index.js @@ -0,0 +1 @@ +module.exports = require('../../lib/handlers/fetch').default; diff --git a/packages/datasource-engine/handlers/mtop/index.d.ts b/packages/datasource-engine/handlers/mtop/index.d.ts new file mode 100644 index 000000000..1d11c303b --- /dev/null +++ b/packages/datasource-engine/handlers/mtop/index.d.ts @@ -0,0 +1 @@ +export type * from '../../es/handlers/mtop'; diff --git a/packages/datasource-engine/handlers/mtop/index.js b/packages/datasource-engine/handlers/mtop/index.js new file mode 100644 index 000000000..89f131c78 --- /dev/null +++ b/packages/datasource-engine/handlers/mtop/index.js @@ -0,0 +1 @@ +module.exports = require('../../lib/handlers/mtop').default; diff --git a/packages/datasource-engine/handlers/url-params/index.d.ts b/packages/datasource-engine/handlers/url-params/index.d.ts new file mode 100644 index 000000000..58e059ec8 --- /dev/null +++ b/packages/datasource-engine/handlers/url-params/index.d.ts @@ -0,0 +1 @@ +export type * from '../../es/handlers/url-params'; diff --git a/packages/datasource-engine/handlers/url-params/index.js b/packages/datasource-engine/handlers/url-params/index.js new file mode 100644 index 000000000..f9b01c61e --- /dev/null +++ b/packages/datasource-engine/handlers/url-params/index.js @@ -0,0 +1 @@ +module.exports = require('../../lib/handlers/url-params').default; diff --git a/packages/datasource-engine/package.json b/packages/datasource-engine/package.json new file mode 100644 index 000000000..321e39a55 --- /dev/null +++ b/packages/datasource-engine/package.json @@ -0,0 +1,34 @@ +{ + "name": "@ali/lowcode-datasource-engine", + "version": "0.1.11", + "description": "DataSource Engine for lowcode", + "main": "lib/index.js", + "module": "es/index.js", + "typings": "es/index.d.ts", + "files": [ + "handlers", + "src", + "lib", + "es" + ], + "scripts": { + "start": "tsc --watch", + "clean": "rm -rf es lib", + "build": "rm -rf es lib && tsc --module esnext --target es6 && mv lib es && tsc", + "prepublishOnly": "npm run build" + }, + "author": "", + "license": "ISC", + "publishConfig": { + "registry": "https://registry.npm.alibaba-inc.com" + }, + "devDependencies": { + "typescript": "^3.9.7" + }, + "dependencies": { + "@ali/universal-mtop": "^5.1.9", + "query-string": "^6.13.1", + "tslib": "^2.0.1", + "universal-request": "^2.2.0" + } +} diff --git a/packages/datasource-engine/src/core/DataSourceEngine.ts b/packages/datasource-engine/src/core/DataSourceEngine.ts new file mode 100644 index 000000000..30052ee6c --- /dev/null +++ b/packages/datasource-engine/src/core/DataSourceEngine.ts @@ -0,0 +1,134 @@ +import { + DataSourceConfig, + DataSourceEngineOptions, + IDataSourceEngine, + IDataSourceEngineFactory, + IRuntimeContext, +} from '../types'; +import { RuntimeDataSource } from './RuntimeDataSource'; + +export class DataSourceEngine implements IDataSourceEngine { + private _dataSourceMap: Record = {}; + + constructor( + private _dataSourceConfig: DataSourceConfig, + private _runtimeContext: IRuntimeContext, + private _options?: DataSourceEngineOptions, + ) { + _dataSourceConfig.list?.forEach((ds) => { + // 确保数据源都有处理器 + const requestHandler = + ds.requestHandler || _options?.requestHandlersMap?.[ds.type]; + if (!requestHandler) { + throw new Error(`No request handler for "${ds.type}" data source`); + } + + this._dataSourceMap[ds.id] = new RuntimeDataSource( + ds.id, + ds.type, + getValue(ds.options) || {}, + requestHandler.bind(_runtimeContext), + ds.dataHandler ? ds.dataHandler.bind(_runtimeContext) : undefined, + (data) => { + _runtimeContext.setState({ [ds.id]: data }); + }, + ); + }); + } + + public get dataSourceMap() { + return this._dataSourceMap; + } + + public async reloadDataSource() { + try { + const allDataSourceConfigList = this._dataSourceConfig.list || []; + + // urlParams 类型的优先加载 + for (const ds of allDataSourceConfigList) { + if (ds.type === 'urlParams' && (getValue(ds.isInit) ?? true)) { + await this._dataSourceMap[ds.id].load(); + } + } + + await sleep(0); // TODO: 如何优雅地解决 setState 的异步问题? + + // 然后是所有其他的 + const remainDataSourceConfigList = allDataSourceConfigList.filter( + (x) => x.type !== 'urlParams', + ); + + // 先发起异步的 + const asyncLoadings: Array> = []; + for (const ds of remainDataSourceConfigList) { + if (getValue(ds.isInit) ?? true) { + const options = getValue(ds.options); + if (options && !options.isSync) { + this._dataSourceMap[ds.id].setOptions(options); + asyncLoadings.push( + this._dataSourceMap[ds.id].load(options?.params).catch(() => {}), + ); + } + } + } + + try { + // 再按先后顺序发起同步请求 + for (const ds of remainDataSourceConfigList) { + if (getValue(ds.isInit) ?? true) { + const options = getValue(ds.options); + if (options && options.isSync) { + this._dataSourceMap[ds.id].setOptions(options); + await this._dataSourceMap[ds.id].load(options?.params); + await sleep(0); // TODO: 如何优雅地解决 setState 的异步问题? + } + } + } + } catch (e) {} + + await Promise.all(asyncLoadings); + } finally { + const allDataHandler = this._dataSourceConfig.dataHandler; + if (allDataHandler) { + await allDataHandler(this._getDataMapOfAll()); + } + } + } + + private _getDataMapOfAll(): Record { + const dataMap: Record = {}; + + Object.entries(this._dataSourceMap).forEach(([dsId, ds]) => { + dataMap[dsId] = ds.data; + }); + + return dataMap; + } +} + +export const create: IDataSourceEngineFactory['create'] = ( + dataSourceConfig, + runtimeContext, + options, +) => { + return new DataSourceEngine(dataSourceConfig, runtimeContext, options); +}; + +function getValue(valueOrValueGetter: T | (() => T)): T; +function getValue( + valueOrValueGetter: T | (() => T), +): T | undefined { + if (typeof valueOrValueGetter === 'function') { + try { + return valueOrValueGetter(); + } catch (e) { + return undefined; + } + } else { + return valueOrValueGetter; + } +} + +function sleep(ms: number = 0) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} diff --git a/packages/datasource-engine/src/core/RuntimeDataSource.ts b/packages/datasource-engine/src/core/RuntimeDataSource.ts new file mode 100644 index 000000000..e9ea43e87 --- /dev/null +++ b/packages/datasource-engine/src/core/RuntimeDataSource.ts @@ -0,0 +1,98 @@ +import { + DataSourceOptions, + IRuntimeDataSource, + RequestHandler, + RuntimeDataSourceStatus, +} from '../types'; + +export class RuntimeDataSource< + TParams extends Record = Record, + TRequestResult = unknown, + TResultData = unknown +> implements IRuntimeDataSource { + private _status: RuntimeDataSourceStatus = RuntimeDataSourceStatus.Initial; + private _data?: TResultData; + private _error?: Error; + private _latestOptions: DataSourceOptions; + + constructor( + private _id: string, + private _type: string, + private _initialOptions: DataSourceOptions, + private _requestHandler: RequestHandler< + DataSourceOptions, + TRequestResult + >, + private _dataHandler: + | (( + data: TRequestResult | undefined, + error: unknown | undefined, + ) => TResultData | Promise) + | undefined, + private _onLoaded: (data: TResultData) => void, + ) { + this._latestOptions = _initialOptions; + } + + public get status() { + return this._status; + } + + public get data() { + return this._data; + } + + public get error() { + return this._error; + } + + public async load(params?: TParams): Promise { + try { + this._latestOptions = { + ...this._latestOptions, + params: { + ...this._latestOptions.params, + ...params, + } as TParams, + }; + + this._status = RuntimeDataSourceStatus.Loading; + + const data = await this._request(this._latestOptions); + + this._status = RuntimeDataSourceStatus.Loaded; + + this._onLoaded(data); + + this._data = data; + return data; + } catch (err) { + this._error = err; + this._status = RuntimeDataSourceStatus.Error; + throw err; + } + } + + public setOptions(options: DataSourceOptions) { + this._latestOptions = options; + } + + private async _request(options: DataSourceOptions) { + try { + const reqResult = await this._requestHandler(options); + + const data = this._dataHandler + ? await this._dataHandler(reqResult, undefined) + : ((reqResult as unknown) as TResultData); + + return data; + } catch (err) { + if (this._dataHandler) { + const data = await this._dataHandler(undefined, err); + return data; + } + + throw err; + } + } +} diff --git a/packages/datasource-engine/src/core/index.ts b/packages/datasource-engine/src/core/index.ts new file mode 100644 index 000000000..fb9854290 --- /dev/null +++ b/packages/datasource-engine/src/core/index.ts @@ -0,0 +1 @@ +export { create } from './DataSourceEngine'; diff --git a/packages/datasource-engine/src/handlers/fetch.ts b/packages/datasource-engine/src/handlers/fetch.ts new file mode 100644 index 000000000..3db926c9f --- /dev/null +++ b/packages/datasource-engine/src/handlers/fetch.ts @@ -0,0 +1,24 @@ +import request from 'universal-request'; +import type { AsObject, RequestOptions } from 'universal-request/lib/types'; + +import { DataSourceOptions, RequestHandler } from '../types'; + +const fetchHandler: RequestHandler = async ({ + url, + uri, + data, + params, + ...otherOptions +}: DataSourceOptions) => { + const reqOptions = { + url: ((url || uri) as unknown) as string, + data: ((data || params) as unknown) as AsObject, + ...otherOptions, + }; + + const res = await request(reqOptions as RequestOptions); + + return res.data; +}; + +export default fetchHandler; diff --git a/packages/datasource-engine/src/handlers/mtop.ts b/packages/datasource-engine/src/handlers/mtop.ts new file mode 100644 index 000000000..88ab8e01b --- /dev/null +++ b/packages/datasource-engine/src/handlers/mtop.ts @@ -0,0 +1,15 @@ +import mtop from '@ali/universal-mtop'; +import { RequestHandler } from '../types'; + +const mtopHandler: RequestHandler = async ({ data, params, ...options }) => { + const reqOptions = { + ...options, + data: data || params, + }; + + const res = await mtop(reqOptions); + + return res.data; +}; + +export default mtopHandler; diff --git a/packages/datasource-engine/src/handlers/url-params.ts b/packages/datasource-engine/src/handlers/url-params.ts new file mode 100644 index 000000000..d7fbfba3d --- /dev/null +++ b/packages/datasource-engine/src/handlers/url-params.ts @@ -0,0 +1,14 @@ +import qs from 'query-string'; +import { RequestHandler } from '../types'; + +export default function urlParamsHandler({ + search, +}: { + search: string | Record; +}): RequestHandler { + const urlParams = typeof search === 'string' ? qs.parse(search) : search; + + return async () => { + return urlParams; + }; +} diff --git a/packages/datasource-engine/src/index.ts b/packages/datasource-engine/src/index.ts new file mode 100644 index 000000000..a5a9e0535 --- /dev/null +++ b/packages/datasource-engine/src/index.ts @@ -0,0 +1,2 @@ +export * from './core'; +export * from './types'; diff --git a/packages/datasource-engine/src/types/DataSourceConfig.ts b/packages/datasource-engine/src/types/DataSourceConfig.ts new file mode 100644 index 000000000..8a3687834 --- /dev/null +++ b/packages/datasource-engine/src/types/DataSourceConfig.ts @@ -0,0 +1,6 @@ +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 new file mode 100644 index 000000000..a8aa46965 --- /dev/null +++ b/packages/datasource-engine/src/types/DataSourceConfigItem.ts @@ -0,0 +1,17 @@ +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 new file mode 100644 index 000000000..f2fd84b1a --- /dev/null +++ b/packages/datasource-engine/src/types/DataSourceEngineOptions.ts @@ -0,0 +1,7 @@ +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 new file mode 100644 index 000000000..55a317496 --- /dev/null +++ b/packages/datasource-engine/src/types/DataSourceOptions.ts @@ -0,0 +1,10 @@ +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/IDataSourceEngine.ts b/packages/datasource-engine/src/types/IDataSourceEngine.ts new file mode 100644 index 000000000..4d19be842 --- /dev/null +++ b/packages/datasource-engine/src/types/IDataSourceEngine.ts @@ -0,0 +1,9 @@ +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 new file mode 100644 index 000000000..4215049ea --- /dev/null +++ b/packages/datasource-engine/src/types/IDataSourceEngineFactory.ts @@ -0,0 +1,12 @@ +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 new file mode 100644 index 000000000..4fed73205 --- /dev/null +++ b/packages/datasource-engine/src/types/IRuntimeContext.ts @@ -0,0 +1,24 @@ +import { IRuntimeDataSource } from './IRuntimeDataSource'; + +/** 运行时上下文 */ +export interface IRuntimeContext< + TState extends object = 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 new file mode 100644 index 000000000..ccf133716 --- /dev/null +++ b/packages/datasource-engine/src/types/IRuntimeDataSource.ts @@ -0,0 +1,22 @@ +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 new file mode 100644 index 000000000..aa9708585 --- /dev/null +++ b/packages/datasource-engine/src/types/RequestHandler.ts @@ -0,0 +1,6 @@ +import { DataSourceOptions } from './DataSourceOptions'; + +export type RequestHandler< + TOptions extends DataSourceOptions = DataSourceOptions, + TResult = unknown +> = (options: TOptions) => Promise; diff --git a/packages/datasource-engine/src/types/RuntimeDataSourceStatus.ts b/packages/datasource-engine/src/types/RuntimeDataSourceStatus.ts new file mode 100644 index 000000000..e089860ab --- /dev/null +++ b/packages/datasource-engine/src/types/RuntimeDataSourceStatus.ts @@ -0,0 +1,14 @@ +/** 数据源的状态 */ +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 new file mode 100644 index 000000000..31f0f3947 --- /dev/null +++ b/packages/datasource-engine/src/types/index.ts @@ -0,0 +1 @@ +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'; \ No newline at end of file diff --git a/packages/datasource-engine/src/typing.d.ts b/packages/datasource-engine/src/typing.d.ts new file mode 100644 index 000000000..2a2deec30 --- /dev/null +++ b/packages/datasource-engine/src/typing.d.ts @@ -0,0 +1 @@ +declare module '@ali/universal-mtop'; diff --git a/packages/datasource-engine/tsconfig.json b/packages/datasource-engine/tsconfig.json new file mode 100644 index 000000000..e06677d2b --- /dev/null +++ b/packages/datasource-engine/tsconfig.json @@ -0,0 +1,80 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig.json to read more about this file */ + + /* Basic Options */ + // "incremental": true, /* Enable incremental compilation */ + "target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */, + "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, + "lib": [ + "DOM", + "ES2015", + "ES2016", + "ES2017", + "ES2018", + "ES2019" + ] /* 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": "./lib" /* Redirect output structure to the directory. */, + "rootDir": "./src" /* 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": false /* 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": [ + "src" + ] /* List of root folders whose combined content represents the structure of the project at runtime. */, + "typeRoots": [ + "./node_modules/@types" + ] /* 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 */ + "skipLibCheck": true /* Skip type checking of declaration files. */, + "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ + } +}