feat(ServiceNow Node): Add attachment functionality (#3137)

*  Add ServiceNow attachment functionality

* 🔨 download fix

*  improvements

*  parameter name fix

*  download attachment for get all operation

*  filters update

*  hint update

*  Small improvements

Co-authored-by: Michael Kret <michael.k@radency.com>
Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
This commit is contained in:
pemontto
2022-05-27 17:39:55 +01:00
committed by GitHub
parent b687ba11cc
commit c38f6af499
4 changed files with 464 additions and 2 deletions

View File

@@ -82,9 +82,34 @@ export async function serviceNowRequestAllItems(this: IExecuteFunctions | ILoadO
return returnData;
}
export async function serviceNowDownloadAttachment(
this: IExecuteFunctions,
endpoint: string,
fileName: string,
contentType: string,
) {
const fileData = await serviceNowApiRequest.call(
this,
'GET',
`${endpoint}/file`,
{},
{},
'',
{ json: false, encoding: null, resolveWithFullResponse: true },
);
const binaryData = await this.helpers.prepareBinaryData(
Buffer.from(fileData.body as string),
fileName,
contentType,
);
return binaryData;
}
export const mapEndpoint = (resource: string, operation: string) => {
const resourceEndpoint = new Map([
['attachment', 'sys_dictionary'],
['tableRecord', 'sys_dictionary'],
['businessService', 'cmdb_ci_service'],
['configurationItems', 'cmdb_ci'],