mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 21:07:28 -08:00
simplify load resource options from store
This commit is contained in:
parent
5640c7bd00
commit
9e8fddcdb6
|
@ -239,48 +239,49 @@ async function initFetching(inlineLoading = false): Promise<void> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const createRequestParams = (methodName: string) => {
|
||||||
|
if (!props.node) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const requestParams: DynamicNodeParameters.ResourceMapperFieldsRequest = {
|
||||||
|
nodeTypeAndVersion: {
|
||||||
|
name: props.node?.type,
|
||||||
|
version: props.node?.typeVersion,
|
||||||
|
},
|
||||||
|
currentNodeParameters: resolveRequiredParameters(
|
||||||
|
props.parameter,
|
||||||
|
props.node.parameters,
|
||||||
|
) as INodeParameters,
|
||||||
|
path: props.path,
|
||||||
|
methodName,
|
||||||
|
credentials: props.node.credentials,
|
||||||
|
};
|
||||||
|
|
||||||
|
return requestParams;
|
||||||
|
};
|
||||||
|
|
||||||
async function loadFieldsToMap(): Promise<void> {
|
async function loadFieldsToMap(): Promise<void> {
|
||||||
if (!props.node) {
|
if (!props.node) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { resourceMapperMethod = undefined, localResourceMapperMethod = undefined } =
|
const { resourceMapperMethod, localResourceMapperMethod } =
|
||||||
props.parameter.typeOptions?.resourceMapper ?? {};
|
props.parameter.typeOptions?.resourceMapper ?? {};
|
||||||
|
|
||||||
let fetchedFields = null;
|
let fetchedFields = null;
|
||||||
|
|
||||||
if (typeof resourceMapperMethod === 'string') {
|
if (typeof resourceMapperMethod === 'string') {
|
||||||
const requestParams: DynamicNodeParameters.ResourceMapperFieldsRequest = {
|
const requestParams = createRequestParams(
|
||||||
nodeTypeAndVersion: {
|
resourceMapperMethod,
|
||||||
name: props.node?.type,
|
) as DynamicNodeParameters.ResourceMapperFieldsRequest;
|
||||||
version: props.node.typeVersion,
|
|
||||||
},
|
|
||||||
currentNodeParameters: resolveRequiredParameters(
|
|
||||||
props.parameter,
|
|
||||||
props.node.parameters,
|
|
||||||
) as INodeParameters,
|
|
||||||
path: props.path,
|
|
||||||
methodName: resourceMapperMethod,
|
|
||||||
credentials: props.node.credentials,
|
|
||||||
};
|
|
||||||
fetchedFields = await nodeTypesStore.getResourceMapperFields(requestParams);
|
fetchedFields = await nodeTypesStore.getResourceMapperFields(requestParams);
|
||||||
} else {
|
} else if (typeof localResourceMapperMethod === 'string') {
|
||||||
if (typeof localResourceMapperMethod === 'string') {
|
const requestParams = createRequestParams(
|
||||||
const requestParams: DynamicNodeParameters.ResourceMapperFieldsRequest = {
|
localResourceMapperMethod,
|
||||||
nodeTypeAndVersion: {
|
) as DynamicNodeParameters.ResourceMapperFieldsRequest;
|
||||||
name: props.node?.type,
|
|
||||||
version: props.node.typeVersion,
|
|
||||||
},
|
|
||||||
currentNodeParameters: resolveRequiredParameters(
|
|
||||||
props.parameter,
|
|
||||||
props.node.parameters,
|
|
||||||
) as INodeParameters,
|
|
||||||
path: props.path,
|
|
||||||
methodName: localResourceMapperMethod,
|
|
||||||
};
|
|
||||||
fetchedFields = await nodeTypesStore.getLocalResourceMapperFields(requestParams);
|
fetchedFields = await nodeTypesStore.getLocalResourceMapperFields(requestParams);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (fetchedFields !== null) {
|
if (fetchedFields !== null) {
|
||||||
const newSchema = fetchedFields.fields.map((field) => {
|
const newSchema = fetchedFields.fields.map((field) => {
|
||||||
|
|
Loading…
Reference in a new issue