dbgate/packages/tools/src/packageTools.ts

25 lines
706 B
TypeScript
Raw Normal View History

2020-11-24 18:06:05 +00:00
import _camelCase from 'lodash/camelCase';
export function extractShellApiPlugins(functionName, props): string[] {
const res = [];
const nsMatch = functionName.match(/^([^@]+)@([^@]+)/);
if (nsMatch) {
res.push(nsMatch[2]);
}
if (props && props.connection && props.connection.engine) {
const nsMatchEngine = props.connection.engine.match(/^([^@]+)@([^@]+)/);
if (nsMatchEngine) {
res.push(nsMatchEngine[2]);
}
}
return res;
}
export function extractShellApiFunctionName(functionName) {
const nsMatch = functionName.match(/^([^@]+)@([^@]+)/);
if (nsMatch) {
2020-11-24 18:06:05 +00:00
return `${_camelCase(nsMatch[2])}.shellApi.${nsMatch[1]}`;
}
return `dbgateApi.${functionName}`;
}