mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-02 15:27:18 +00:00
36 lines
753 B
TypeScript
36 lines
753 B
TypeScript
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);
|
|
}
|
|
`,
|
|
},
|
|
},
|
|
],
|
|
};
|