fix(AWS Rekognition Node): Fix all different action type (#6136)
* Fix broken logic with type action * Unit test base * Add unit test using only nock * Fix failing test * remove console log --------- Co-authored-by: Marcus <marcus@n8n.io>
This commit is contained in:
@@ -389,64 +389,62 @@ export class AwsRekognition implements INodeType {
|
||||
|
||||
if (type === 'detectText') {
|
||||
action = 'RekognitionService.DetectText';
|
||||
|
||||
body.Filters = {};
|
||||
|
||||
const box =
|
||||
((additionalFields.regionsOfInterestUi as IDataObject)
|
||||
?.regionsOfInterestValues as IDataObject[]) || [];
|
||||
|
||||
if (box.length !== 0) {
|
||||
//@ts-ignore
|
||||
body.Filters.RegionsOfInterest = box.map((entry: IDataObject) => {
|
||||
return { BoundingBox: keysTPascalCase(entry) };
|
||||
});
|
||||
}
|
||||
|
||||
const wordFilter = (additionalFields.wordFilterUi as IDataObject) || {};
|
||||
if (Object.keys(wordFilter).length !== 0) {
|
||||
//@ts-ignore
|
||||
body.Filters.WordFilter = keysTPascalCase(wordFilter);
|
||||
}
|
||||
|
||||
const isBinaryData = this.getNodeParameter('binaryData', i);
|
||||
if (isBinaryData) {
|
||||
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
||||
const binaryPropertyData = this.helpers.assertBinaryData(i, binaryPropertyName);
|
||||
Object.assign(body, {
|
||||
Image: {
|
||||
Bytes: binaryPropertyData.data,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
const bucket = this.getNodeParameter('bucket', i) as string;
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
|
||||
Object.assign(body, {
|
||||
Image: {
|
||||
S3Object: {
|
||||
Bucket: bucket,
|
||||
Name: name,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (additionalFields.version) {
|
||||
//@ts-ignore
|
||||
body.Image.S3Object.Version = additionalFields.version as string;
|
||||
}
|
||||
}
|
||||
|
||||
responseData = await awsApiRequestREST.call(
|
||||
this,
|
||||
'rekognition',
|
||||
'POST',
|
||||
'',
|
||||
JSON.stringify(body),
|
||||
{},
|
||||
{ 'X-Amz-Target': action, 'Content-Type': 'application/x-amz-json-1.1' },
|
||||
);
|
||||
}
|
||||
body.Filters = {};
|
||||
|
||||
const box =
|
||||
((additionalFields.regionsOfInterestUi as IDataObject)
|
||||
?.regionsOfInterestValues as IDataObject[]) || [];
|
||||
|
||||
if (box.length !== 0) {
|
||||
//@ts-ignore
|
||||
body.Filters.RegionsOfInterest = box.map((entry: IDataObject) => {
|
||||
return { BoundingBox: keysTPascalCase(entry) };
|
||||
});
|
||||
}
|
||||
|
||||
const wordFilter = (additionalFields.wordFilterUi as IDataObject) || {};
|
||||
if (Object.keys(wordFilter).length !== 0) {
|
||||
//@ts-ignore
|
||||
body.Filters.WordFilter = keysTPascalCase(wordFilter);
|
||||
}
|
||||
|
||||
const isBinaryData = this.getNodeParameter('binaryData', i);
|
||||
if (isBinaryData) {
|
||||
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
||||
const binaryPropertyData = this.helpers.assertBinaryData(i, binaryPropertyName);
|
||||
Object.assign(body, {
|
||||
Image: {
|
||||
Bytes: binaryPropertyData.data,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
const bucket = this.getNodeParameter('bucket', i) as string;
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
|
||||
Object.assign(body, {
|
||||
Image: {
|
||||
S3Object: {
|
||||
Bucket: bucket,
|
||||
Name: name,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (additionalFields.version) {
|
||||
//@ts-ignore
|
||||
body.Image.S3Object.Version = additionalFields.version as string;
|
||||
}
|
||||
}
|
||||
responseData = await awsApiRequestREST.call(
|
||||
this,
|
||||
'rekognition',
|
||||
'POST',
|
||||
'',
|
||||
JSON.stringify(body),
|
||||
{},
|
||||
{ 'X-Amz-Target': action, 'Content-Type': 'application/x-amz-json-1.1' },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user