mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-23 01:48:12 +00:00
fix: eslint
This commit is contained in:
parent
9d97e569b1
commit
c346137092
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ali/lowcode-datasource-engine",
|
"name": "@ali/lowcode-datasource-engine",
|
||||||
"version": "1.0.2-alpha.1",
|
"version": "1.0.2-alpha.2",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"files": [
|
"files": [
|
||||||
"dist",
|
"dist",
|
||||||
|
|||||||
@ -15,6 +15,7 @@ export const reloadDataSourceFactory = (
|
|||||||
dataSource.list
|
dataSource.list
|
||||||
.filter(
|
.filter(
|
||||||
(el: RuntimeDataSourceConfig) =>
|
(el: RuntimeDataSourceConfig) =>
|
||||||
|
// eslint-disable-next-line implicit-arrow-linebreak
|
||||||
el.type === 'urlParams' &&
|
el.type === 'urlParams' &&
|
||||||
(typeof el.isInit === 'boolean' ? el.isInit : true),
|
(typeof el.isInit === 'boolean' ? el.isInit : true),
|
||||||
)
|
)
|
||||||
@ -51,8 +52,13 @@ export const reloadDataSourceFactory = (
|
|||||||
ds.isInit &&
|
ds.isInit &&
|
||||||
ds.isSync
|
ds.isSync
|
||||||
) {
|
) {
|
||||||
|
try {
|
||||||
// eslint-disable-next-line no-await-in-loop
|
// eslint-disable-next-line no-await-in-loop
|
||||||
await dataSourceMap[ds.id].load();
|
await dataSourceMap[ds.id].load();
|
||||||
|
} catch (e) {
|
||||||
|
// TODO: 这个错误直接吃掉?
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import {
|
|||||||
JSExpression,
|
JSExpression,
|
||||||
JSFunction,
|
JSFunction,
|
||||||
JSONObject,
|
JSONObject,
|
||||||
|
RuntimeOptionsConfig,
|
||||||
} from '@ali/lowcode-types';
|
} from '@ali/lowcode-types';
|
||||||
|
|
||||||
export const transformExpression = (
|
export const transformExpression = (
|
||||||
@ -123,25 +124,70 @@ export const buildOptions = (
|
|||||||
) => {
|
) => {
|
||||||
const { options } = ds;
|
const { options } = ds;
|
||||||
if (!options) return undefined;
|
if (!options) return undefined;
|
||||||
|
// eslint-disable-next-line space-before-function-paren
|
||||||
return function() {
|
return function() {
|
||||||
return {
|
// 默认值
|
||||||
uri: getRuntimeValueFromConfig('string', options.uri, context),
|
const fetchOptions: RuntimeOptionsConfig = {
|
||||||
params: options.params ? buildJsonObj(options.params, context) : {},
|
uri: '',
|
||||||
method: options.method
|
params: {},
|
||||||
? getRuntimeValueFromConfig('string', options.method, context)
|
method: 'GET',
|
||||||
: 'GET',
|
isCors: true,
|
||||||
isCors: options.isCors
|
timeout: 5000,
|
||||||
? getRuntimeValueFromConfig('boolean', options.isCors, context)
|
headers: undefined,
|
||||||
: true,
|
v: '1.0',
|
||||||
timeout: options.timeout
|
};
|
||||||
? getRuntimeValueFromConfig('number', options.timeout, context)
|
Object.keys(options).forEach((key: string) => {
|
||||||
: 5000,
|
switch (key) {
|
||||||
headers: options.headers
|
case 'uri':
|
||||||
? buildJsonObj(options.headers, context)
|
fetchOptions.uri = getRuntimeValueFromConfig(
|
||||||
: undefined,
|
'string',
|
||||||
v: options.v
|
options.uri,
|
||||||
? getRuntimeValueFromConfig('string', options.v, context)
|
context,
|
||||||
: '1.0',
|
);
|
||||||
};
|
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;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user