mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
fix(KoboToolbox Node): fix hook logs not working correctly (#4286)
This commit is contained in:
parent
298c4f20a9
commit
ebf45157e6
|
@ -22,25 +22,25 @@ export const hookOperations: INodeProperties[] = [
|
||||||
name: 'Get Many',
|
name: 'Get Many',
|
||||||
value: 'getAll',
|
value: 'getAll',
|
||||||
description: 'List many hooks on a form',
|
description: 'List many hooks on a form',
|
||||||
action: 'Get many hooks',
|
action: 'Get Many hooks',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Logs',
|
name: 'Logs',
|
||||||
value: 'getLogs',
|
value: 'getLogs',
|
||||||
description: 'Get hook logs',
|
description: 'Get hook logs',
|
||||||
action: 'Logs a hook',
|
action: 'Get Logs for a hook',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Retry All',
|
name: 'Retry All',
|
||||||
value: 'retryAll',
|
value: 'retryAll',
|
||||||
description: 'Retry all failed attempts for a given hook',
|
description: 'Retry all failed attempts for a given hook',
|
||||||
action: 'Retry all hooks',
|
action: 'Retry All hooks',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Retry One',
|
name: 'Retry One',
|
||||||
value: 'retryOne',
|
value: 'retryOne',
|
||||||
description: 'Retry a specific hook',
|
description: 'Retry a specific hook',
|
||||||
action: 'Retry one hook',
|
action: 'Retry One hook',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: 'getAll',
|
default: 'getAll',
|
||||||
|
@ -127,7 +127,7 @@ export const hookFields: INodeProperties[] = [
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource: ['hook'],
|
resource: ['hook'],
|
||||||
operation: ['getAll', 'getLogs'],
|
operation: ['getAll'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
description: 'Whether to return all results or only up to a given limit',
|
description: 'Whether to return all results or only up to a given limit',
|
||||||
|
@ -142,11 +142,71 @@ export const hookFields: INodeProperties[] = [
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource: ['hook'],
|
resource: ['hook'],
|
||||||
operation: ['getAll', 'getLogs'],
|
operation: ['getAll'],
|
||||||
returnAll: [false],
|
returnAll: [false],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
default: 1000,
|
default: 1000,
|
||||||
description: 'Max number of results to return',
|
description: 'Max number of results to return',
|
||||||
},
|
},
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* hook:getLogs */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
{
|
||||||
|
displayName: 'Log Status',
|
||||||
|
name: 'status',
|
||||||
|
type: 'options',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: ['hook'],
|
||||||
|
operation: ['getLogs'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
description: 'Only retrieve logs with a specific status',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'All',
|
||||||
|
value: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Failed',
|
||||||
|
value: '0',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Pending',
|
||||||
|
value: '1',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Success',
|
||||||
|
value: '2',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Start Date',
|
||||||
|
name: 'startDate',
|
||||||
|
type: 'dateTime',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: ['hook'],
|
||||||
|
operation: ['getLogs'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
description: 'Minimum date for the hook log to retrieve',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'End Date',
|
||||||
|
name: 'endDate',
|
||||||
|
type: 'dateTime',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: ['hook'],
|
||||||
|
operation: ['getLogs'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
description: 'Maximum date for the hook log to retrieve',
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -323,13 +323,17 @@ export class KoBoToolbox implements INodeType {
|
||||||
// Hook: getLogs
|
// Hook: getLogs
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
const hookId = this.getNodeParameter('hookId', i) as string;
|
const hookId = this.getNodeParameter('hookId', i) as string;
|
||||||
|
const startDate = this.getNodeParameter('startDate', i, null);
|
||||||
|
const endDate = this.getNodeParameter('endDate', i, null);
|
||||||
|
const status = this.getNodeParameter('status', i, null);
|
||||||
|
|
||||||
responseData = await koBoToolboxApiRequest.call(this, {
|
responseData = await koBoToolboxApiRequest.call(this, {
|
||||||
url: `/api/v2/assets/${formId}/hooks/${hookId}/logs/`,
|
url: `/api/v2/assets/${formId}/hooks/${hookId}/logs/`,
|
||||||
qs: {
|
qs: {
|
||||||
start: this.getNodeParameter('start', i, 0) as number,
|
...(startDate && { start: startDate }),
|
||||||
limit: this.getNodeParameter('limit', i, 1000) as number,
|
...(endDate && { end: endDate }),
|
||||||
|
...(status && { status }),
|
||||||
},
|
},
|
||||||
scroll: this.getNodeParameter('returnAll', i) as boolean,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,6 +346,7 @@ export class KoBoToolbox implements INodeType {
|
||||||
|
|
||||||
responseData = [
|
responseData = [
|
||||||
await koBoToolboxApiRequest.call(this, {
|
await koBoToolboxApiRequest.call(this, {
|
||||||
|
method: 'PATCH',
|
||||||
url: `/api/v2/assets/${formId}/hooks/${hookId}/logs/${logId}/retry/`,
|
url: `/api/v2/assets/${formId}/hooks/${hookId}/logs/${logId}/retry/`,
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue