refactor: Use getDynamicData instead of getData

This commit is contained in:
Faruk AYDIN
2022-11-10 19:46:04 +01:00
parent a415c7ef4e
commit d2b8d2beff
33 changed files with 57 additions and 42 deletions

View File

@@ -0,0 +1,4 @@
import listObjects from './list-objects';
import listFields from './list-fields';
export default [listObjects, listFields];

View File

@@ -0,0 +1,34 @@
import { IGlobalVariable } from '@automatisch/types';
type TResponse = {
fields: TField[];
};
type TField = {
name: string;
label: string;
};
export default {
name: 'List fields',
key: 'listFields',
async run($: IGlobalVariable) {
const { object } = $.step.parameters;
if (!object) return { data: [] };
const response = await $.http.get<TResponse>(
`/services/data/v56.0/sobjects/${object}/describe`
);
const fields = response.data.fields.map((field) => {
return {
value: field.name,
name: field.label,
};
});
return { data: fields };
},
};

View File

@@ -0,0 +1,30 @@
import { IGlobalVariable } from '@automatisch/types';
type TResponse = {
sobjects: TObject[];
};
type TObject = {
name: string;
label: string;
};
export default {
name: 'List objects',
key: 'listObjects',
async run($: IGlobalVariable) {
const response = await $.http.get<TResponse>(
'/services/data/v56.0/sobjects'
);
const objects = response.data.sobjects.map((object) => {
return {
value: object.name,
name: object.label,
};
});
return { data: objects };
},
};