提交 cb61ac5d authored 作者: vipcxj's avatar vipcxj

add: 数据源批处理和特性支持查询api

上级 fd33936f
...@@ -25,9 +25,11 @@ export const datasourceApi = (coordinate) => { ...@@ -25,9 +25,11 @@ export const datasourceApi = (coordinate) => {
remove: partial(removeGlobalDatasource, [datasourceName]), remove: partial(removeGlobalDatasource, [datasourceName]),
removeMeta: partial(removeGlobalDatasourceMeta, [datasourceName]), removeMeta: partial(removeGlobalDatasourceMeta, [datasourceName]),
meta: partial(getGlobalDatasourceMeta, [datasourceName]), meta: partial(getGlobalDatasourceMeta, [datasourceName]),
validateUpdate: partial(validateUpdateGlobalDatasource, datasourceName), validateUpdate: partial(validateUpdateGlobalDatasource, [datasourceName]),
validateCreate: partial(validateCreateGlobalDatasource, datasourceName), validateCreate: partial(validateCreateGlobalDatasource, [datasourceName]),
validateRemove: partial(validateRemoveGlobalDatasource, datasourceName), validateRemove: partial(validateRemoveGlobalDatasource, [datasourceName]),
feature: partial(getGlobalDatasourceFeature, [datasourceName]),
invoke: partial(invokeGlobalDatasource, [datasourceName]),
}; };
} else if (containerType === 'module') { } else if (containerType === 'module') {
return { return {
...@@ -47,6 +49,8 @@ export const datasourceApi = (coordinate) => { ...@@ -47,6 +49,8 @@ export const datasourceApi = (coordinate) => {
validateUpdate: partial(validateUpdateModuleDatasource, [containerName, datasourceName]), validateUpdate: partial(validateUpdateModuleDatasource, [containerName, datasourceName]),
validateCreate: partial(validateCreateModuleDatasource, [containerName, datasourceName]), validateCreate: partial(validateCreateModuleDatasource, [containerName, datasourceName]),
validateRemove: partial(validateRemoveModuleDatasource, [containerName, datasourceName]), validateRemove: partial(validateRemoveModuleDatasource, [containerName, datasourceName]),
feature: partial(getModuleDatasourceFeature, [containerName, datasourceName]),
invoke: partial(invokeModuleDatasource, [containerName, datasourceName]),
}; };
} else { } else {
throw new Error(`Unsupported containerType: ${containerType}`); throw new Error(`Unsupported containerType: ${containerType}`);
...@@ -54,35 +58,35 @@ export const datasourceApi = (coordinate) => { ...@@ -54,35 +58,35 @@ export const datasourceApi = (coordinate) => {
}; };
export async function calcGlobalDatasource(name, { pst, psz, filters = [], sortBys = [], sortTypes = [], params = {}, dmPath }) { export async function calcGlobalDatasource(name, { pst, psz, filters = [], sortBys = [], sortTypes = [], params = {}, dmPath }) {
return request(`${config.apiContextPath}/api/datasource/${name}`, makeParams({ pst, psz, dmPath }, { filters, sortBys, sortTypes, params })); return request(`${config.apiContextPath}/api/datasource/user/${encodeURIComponent(name)}`, makeParams({ pst, psz, dmPath }, { filters, sortBys, sortTypes, params }));
} }
export async function calcGlobalDatasourceMeta(name, { params = {}, dmPath }) { export async function calcGlobalDatasourceMeta(name, { params = {}, dmPath }) {
return request(`${config.apiContextPath}/api/datasource/${name}/meta/query`, makeParams({ dmPath }, { params })); return request(`${config.apiContextPath}/api/datasource/user/${encodeURIComponent(name)}/meta/query`, makeParams({ dmPath }, { params }));
} }
export async function countGlobalDatasource(name, { filters = [], params = {}, dmPath }) { export async function countGlobalDatasource(name, { filters = [], params = {}, dmPath }) {
return request(`${config.apiContextPath}/api/datasource/${name}/count`, makeParams({ dmPath }, { filters, params })); return request(`${config.apiContextPath}/api/datasource/user/${encodeURIComponent(name)}/count`, makeParams({ dmPath }, { filters, params }));
} }
export async function countGlobalDatasourceMeta(name, { params = {}, dmPath }) { export async function countGlobalDatasourceMeta(name, { params = {}, dmPath }) {
return request(`${config.apiContextPath}/api/datasource/${name}/meta/count`, makeParams({ dmPath }, { params })); return request(`${config.apiContextPath}/api/datasource/user/${encodeURIComponent(name)}/meta/count`, makeParams({ dmPath }, { params }));
} }
export async function cursorGlobalDatasource(name, key, params = {}, dmPath) { export async function cursorGlobalDatasource(name, key, params = {}, dmPath) {
return request(`${config.apiContextPath}/api/datasource/${name}/cursor`, makeParams({ key, dmPath }, { params })); return request(`${config.apiContextPath}/api/datasource/user/${encodeURIComponent(name)}/cursor`, makeParams({ key, dmPath }, { params }));
} }
export async function cursorGlobalDatasourceMeta(name, key, params = {}, dmPath) { export async function cursorGlobalDatasourceMeta(name, key, params = {}, dmPath) {
return request(`${config.apiContextPath}/api/datasource/${name}/meta/cursor`, makeParams({ key, dmPath }, { params })); return request(`${config.apiContextPath}/api/datasource/user/${encodeURIComponent(name)}/meta/cursor`, makeParams({ key, dmPath }, { params }));
} }
export async function validateUpdateGlobalDatasource(name, key, params = {}, dmPath) { export async function validateUpdateGlobalDatasource(name, key, params = {}, dmPath) {
return request(`${config.apiContextPath}/api/datasource/${name}/update/validate`, makeParams({ key, dmPath }, { params })); return request(`${config.apiContextPath}/api/datasource/user/${encodeURIComponent(name)}/update/validate`, makeParams({ key, dmPath }, { params }));
} }
export async function updateGlobalDatasource(name, key, params = {}, dmPath) { export async function updateGlobalDatasource(name, key, params = {}, dmPath) {
return post(`${config.apiContextPath}/api/datasource/${name}/update`, { return post(`${config.apiContextPath}/api/datasource/user/${encodeURIComponent(name)}/update`, {
key, key,
params, params,
dmPath, dmPath,
...@@ -90,7 +94,7 @@ export async function updateGlobalDatasource(name, key, params = {}, dmPath) { ...@@ -90,7 +94,7 @@ export async function updateGlobalDatasource(name, key, params = {}, dmPath) {
} }
export async function updateGlobalDatasourceMeta(name, key, params = {}, dmPath) { export async function updateGlobalDatasourceMeta(name, key, params = {}, dmPath) {
return post(`${config.apiContextPath}/api/datasource/${name}/meta/update`, { return post(`${config.apiContextPath}/api/datasource/user/${encodeURIComponent(name)}/meta/update`, {
key, key,
params, params,
dmPath, dmPath,
...@@ -98,29 +102,29 @@ export async function updateGlobalDatasourceMeta(name, key, params = {}, dmPath) ...@@ -98,29 +102,29 @@ export async function updateGlobalDatasourceMeta(name, key, params = {}, dmPath)
} }
export async function validateCreateGlobalDatasource(name, params = {}, dmPath) { export async function validateCreateGlobalDatasource(name, params = {}, dmPath) {
return request(`${config.apiContextPath}/api/datasource/${name}/create/validate`, makeParams({ dmPath }, { params })); return request(`${config.apiContextPath}/api/datasource/user/${encodeURIComponent(name)}/create/validate`, makeParams({ dmPath }, { params }));
} }
export async function createGlobalDatasource(name, params = {}, dmPath) { export async function createGlobalDatasource(name, params = {}, dmPath) {
return post(`${config.apiContextPath}/api/datasource/${name}/create`, { return post(`${config.apiContextPath}/api/datasource/user/${encodeURIComponent(name)}/create`, {
params, params,
dmPath, dmPath,
}); });
} }
export async function createGlobalDatasourceMeta(name, params = {}, dmPath) { export async function createGlobalDatasourceMeta(name, params = {}, dmPath) {
return post(`${config.apiContextPath}/api/datasource/${name}/meta/create`, { return post(`${config.apiContextPath}/api/datasource/user/${encodeURIComponent(name)}/meta/create`, {
params, params,
dmPath, dmPath,
}); });
} }
export async function validateRemoveGlobalDatasource(name, key, params = {}, dmPath) { export async function validateRemoveGlobalDatasource(name, key, params = {}, dmPath) {
return request(`${config.apiContextPath}/api/datasource/${name}/remove/validate`, makeParams({ key, dmPath }, { params })); return request(`${config.apiContextPath}/api/datasource/user/${encodeURIComponent(name)}/remove/validate`, makeParams({ key, dmPath }, { params }));
} }
export async function removeGlobalDatasource(name, key, params = {}, dmPath) { export async function removeGlobalDatasource(name, key, params = {}, dmPath) {
return post(`${config.apiContextPath}/api/datasource/${name}/remove`, { return post(`${config.apiContextPath}/api/datasource/user/${encodeURIComponent(name)}/remove`, {
key, key,
params, params,
dmPath, dmPath,
...@@ -128,47 +132,58 @@ export async function removeGlobalDatasource(name, key, params = {}, dmPath) { ...@@ -128,47 +132,58 @@ export async function removeGlobalDatasource(name, key, params = {}, dmPath) {
} }
export async function removeGlobalDatasourceMeta(name, key, params = {}, dmPath) { export async function removeGlobalDatasourceMeta(name, key, params = {}, dmPath) {
return post(`${config.apiContextPath}/api/datasource/${name}/meta/remove`, { return post(`${config.apiContextPath}/api/datasource/user/${encodeURIComponent(name)}/meta/remove`, {
key, key,
params, params,
dmPath, dmPath,
}); });
} }
export async function getGlobalDatasourceMeta(name) { export async function getGlobalDatasourceMeta(name, dmPath) {
return request(`${config.apiContextPath}/api/datasource/${name}/meta`); return request(`${config.apiContextPath}/api/datasource/user/${encodeURIComponent(name)}/meta`, makeParams({ dmPath }, {}));
}
export async function getGlobalDatasourceFeature(name, dmPath) {
return request(`${config.apiContextPath}/api/datasource/user/${encodeURIComponent(name)}/feature`, makeParams({ dmPath }, {}));
}
export async function invokeGlobalDatasource(dsName, opName, params = {}, dmPath, { pst, psz, filters = [], includeKeys, excludeKeys, termWhenFail = true }) {
return post(`${config.apiContextPath}/api/datasource/user/${encodeURIComponent(dsName)}/operation/${encodeURIComponent(opName)}/invoke`, {
includeKeys,
excludeKeys,
}, makeParams({ twf: termWhenFail ? 1 : 0, pst, psz }, { filters, params }));
} }
export async function calcModuleDatasource(mdName, dsName, { pst, psz, filters = [], sortBys = [], sortTypes = [], params = {}, dmPath }) { export async function calcModuleDatasource(mdName, dsName, { pst, psz, filters = [], sortBys = [], sortTypes = [], params = {}, dmPath }) {
return request(`${config.apiContextPath}/api/module/user/${mdName}/datasource/${dsName}`, makeParams({ pst, psz, dmPath }, { filters, sortBys, sortTypes, params })); return request(`${config.apiContextPath}/api/module/user/${encodeURIComponent(mdName)}/datasource/${encodeURIComponent(dsName)}`, makeParams({ pst, psz, dmPath }, { filters, sortBys, sortTypes, params }));
} }
export async function calcModuleDatasourceMeta(mdName, dsName, { params = {}, dmPath }) { export async function calcModuleDatasourceMeta(mdName, dsName, { params = {}, dmPath }) {
return request(`${config.apiContextPath}/api/module/user/${mdName}/datasource/${dsName}/meta/query`, makeParams({ dmPath }, { params })); return request(`${config.apiContextPath}/api/module/user/${encodeURIComponent(mdName)}/datasource/${encodeURIComponent(dsName)}/meta/query`, makeParams({ dmPath }, { params }));
} }
export async function countModuleDatasource(mdName, dsName, { filters = [], params = {}, dmPath }) { export async function countModuleDatasource(mdName, dsName, { filters = [], params = {}, dmPath }) {
return request(`${config.apiContextPath}/api/module/user/${mdName}/datasource/${dsName}/count`, makeParams({ dmPath }, { filters, params })); return request(`${config.apiContextPath}/api/module/user/${encodeURIComponent(mdName)}/datasource/${encodeURIComponent(dsName)}/count`, makeParams({ dmPath }, { filters, params }));
} }
export async function countModuleDatasourceMeta(mdName, dsName, { params = {}, dmPath }) { export async function countModuleDatasourceMeta(mdName, dsName, { params = {}, dmPath }) {
return request(`${config.apiContextPath}/api/module/user/${mdName}/datasource/${dsName}/meta/count`, makeParams({ dmPath }, { params })); return request(`${config.apiContextPath}/api/module/user/${encodeURIComponent(mdName)}/datasource/${encodeURIComponent(dsName)}/meta/count`, makeParams({ dmPath }, { params }));
} }
export async function cursorModuleDatasource(mdName, dsName, key, params = {}, dmPath) { export async function cursorModuleDatasource(mdName, dsName, key, params = {}, dmPath) {
return request(`${config.apiContextPath}/api/module/user/${mdName}/datasource/${dsName}/cursor`, makeParams({ key, dmPath }, { params })); return request(`${config.apiContextPath}/api/module/user/${encodeURIComponent(mdName)}/datasource/${encodeURIComponent(dsName)}/cursor`, makeParams({ key, dmPath }, { params }));
} }
export async function cursorModuleDatasourceMeta(mdName, dsName, key, params = {}, dmPath) { export async function cursorModuleDatasourceMeta(mdName, dsName, key, params = {}, dmPath) {
return request(`${config.apiContextPath}/api/module/user/${mdName}/datasource/${dsName}/meta/cursor`, makeParams({ key, dmPath }, { params })); return request(`${config.apiContextPath}/api/module/user/${encodeURIComponent(mdName)}/datasource/${encodeURIComponent(dsName)}/meta/cursor`, makeParams({ key, dmPath }, { params }));
} }
export async function validateUpdateModuleDatasource(mdName, dsName, key, params = {}, dmPath) { export async function validateUpdateModuleDatasource(mdName, dsName, key, params = {}, dmPath) {
return request(`${config.apiContextPath}/api/module/user/${mdName}/datasource/${dsName}/update/validate`, makeParams({ key, dmPath }, { params })); return request(`${config.apiContextPath}/api/module/user/${encodeURIComponent(mdName)}/datasource/${encodeURIComponent(dsName)}/update/validate`, makeParams({ key, dmPath }, { params }));
} }
export async function updateModuleDatasource(mdName, dsName, key, params = {}, dmPath) { export async function updateModuleDatasource(mdName, dsName, key, params = {}, dmPath) {
return post(`${config.apiContextPath}/api/module/user/${mdName}/datasource/${dsName}/update`, { return post(`${config.apiContextPath}/api/module/user/${encodeURIComponent(mdName)}/datasource/${encodeURIComponent(dsName)}/update`, {
key, key,
params, params,
dmPath, dmPath,
...@@ -176,7 +191,7 @@ export async function updateModuleDatasource(mdName, dsName, key, params = {}, d ...@@ -176,7 +191,7 @@ export async function updateModuleDatasource(mdName, dsName, key, params = {}, d
} }
export async function updateModuleDatasourceMeta(mdName, dsName, key, params = {}, dmPath) { export async function updateModuleDatasourceMeta(mdName, dsName, key, params = {}, dmPath) {
return post(`${config.apiContextPath}/api/module/user/${mdName}/datasource/${dsName}/meta/update`, { return post(`${config.apiContextPath}/api/module/user/${encodeURIComponent(mdName)}/datasource/${encodeURIComponent(dsName)}/meta/update`, {
key, key,
params, params,
dmPath, dmPath,
...@@ -184,29 +199,29 @@ export async function updateModuleDatasourceMeta(mdName, dsName, key, params = { ...@@ -184,29 +199,29 @@ export async function updateModuleDatasourceMeta(mdName, dsName, key, params = {
} }
export async function validateCreateModuleDatasource(mdName, dsName, params = {}, dmPath) { export async function validateCreateModuleDatasource(mdName, dsName, params = {}, dmPath) {
return request(`${config.apiContextPath}/api/module/user/${mdName}/datasource/${dsName}/create/validate`, makeParams({ dmPath }, { params })); return request(`${config.apiContextPath}/api/module/user/${encodeURIComponent(mdName)}/datasource/${encodeURIComponent(dsName)}/create/validate`, makeParams({ dmPath }, { params }));
} }
export async function createModuleDatasource(mdName, dsName, params = {}, dmPath) { export async function createModuleDatasource(mdName, dsName, params = {}, dmPath) {
return post(`${config.apiContextPath}/api/module/user/${mdName}/datasource/${dsName}/create`, { return post(`${config.apiContextPath}/api/module/user/${encodeURIComponent(mdName)}/datasource/${encodeURIComponent(dsName)}/create`, {
params, params,
dmPath, dmPath,
}); });
} }
export async function createModuleDatasourceMeta(mdName, dsName, params = {}, dmPath) { export async function createModuleDatasourceMeta(mdName, dsName, params = {}, dmPath) {
return post(`${config.apiContextPath}/api/module/user/${mdName}/datasource/${dsName}/meta/create`, { return post(`${config.apiContextPath}/api/module/user/${encodeURIComponent(mdName)}/datasource/${encodeURIComponent(dsName)}/meta/create`, {
params, params,
dmPath, dmPath,
}); });
} }
export async function validateRemoveModuleDatasource(mdName, dsName, key, params = {}, dmPath) { export async function validateRemoveModuleDatasource(mdName, dsName, key, params = {}, dmPath) {
return request(`${config.apiContextPath}/api/module/user/${mdName}/datasource/${dsName}/remove/validate`, makeParams({ key, dmPath }, { params })); return request(`${config.apiContextPath}/api/module/user/${encodeURIComponent(mdName)}/datasource/${encodeURIComponent(dsName)}/remove/validate`, makeParams({ key, dmPath }, { params }));
} }
export async function removeModuleDatasource(mdName, dsName, key, params = {}, dmPath) { export async function removeModuleDatasource(mdName, dsName, key, params = {}, dmPath) {
return post(`${config.apiContextPath}/api/module/user/${mdName}/datasource/${dsName}/remove`, { return post(`${config.apiContextPath}/api/module/user/${encodeURIComponent(mdName)}/datasource/${encodeURIComponent(dsName)}/remove`, {
key, key,
params, params,
dmPath, dmPath,
...@@ -214,15 +229,26 @@ export async function removeModuleDatasource(mdName, dsName, key, params = {}, d ...@@ -214,15 +229,26 @@ export async function removeModuleDatasource(mdName, dsName, key, params = {}, d
} }
export async function removeModuleDatasourceMeta(mdName, dsName, key, params = {}, dmPath) { export async function removeModuleDatasourceMeta(mdName, dsName, key, params = {}, dmPath) {
return post(`${config.apiContextPath}/api/module/user/${mdName}/datasource/${dsName}/meta/remove`, { return post(`${config.apiContextPath}/api/module/user/${encodeURIComponent(mdName)}/datasource/${encodeURIComponent(dsName)}/meta/remove`, {
key, key,
params, params,
dmPath, dmPath,
}); });
} }
export async function getModuleDatasourceMeta(mdName, dsName) { export async function getModuleDatasourceMeta(mdName, dsName, dmPath) {
return request(`${config.apiContextPath}/api/module/user/${mdName}/datasource/${dsName}/meta`); return request(`${config.apiContextPath}/api/module/user/${encodeURIComponent(mdName)}/datasource/${encodeURIComponent(dsName)}/meta`, makeParams({ dmPath }, {}));
}
export async function getModuleDatasourceFeature(mdName, dsName, dmPath) {
return request(`${config.apiContextPath}/api/module/user/${encodeURIComponent(mdName)}/datasource/${encodeURIComponent(dsName)}/feature`, makeParams({ dmPath }, {}));
}
export async function invokeModuleDatasource(mdName, dsName, opName, params = {}, dmPath, { pst, psz, filters = [], includeKeys, excludeKeys, termWhenFail = true }) {
return post(`${config.apiContextPath}/api/module/user/${encodeURIComponent(mdName)}/datasource/${encodeURIComponent(dsName)}/operation/${encodeURIComponent(opName)}/invoke`, {
includeKeys,
excludeKeys,
}, makeParams({ twf: termWhenFail ? 1 : 0, pst, psz }, { filters, params }));
} }
export class Datasource { export class Datasource {
...@@ -314,4 +340,12 @@ export class Datasource { ...@@ -314,4 +340,12 @@ export class Datasource {
const dmPath = await this.dealWithPath(); const dmPath = await this.dealWithPath();
return this.api.validateRemove(key, params, dmPath); return this.api.validateRemove(key, params, dmPath);
} }
async feature() {
const dmPath = await this.dealWithPath();
return this.api.feature(dmPath);
}
async invoke(name, params = {}, { pst, psz, filters = [], includeKeys, excludeKeys, termWhenFail = true }) {
const dmPath = await this.dealWithPath();
return this.api.invoke(name, params, dmPath, { pst, psz, filters, includeKeys, excludeKeys, termWhenFail });
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论