pull:初次提交

This commit is contained in:
Yep_Q
2025-09-08 04:48:28 +08:00
parent 5c0619656d
commit f64f498365
11751 changed files with 1953723 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
import type {
IDataObject,
IExecuteFunctions,
INodeExecutionData,
INodeProperties,
} from 'n8n-workflow';
import { updateDisplayOptions, wrapData } from '@utils/utilities';
import { attachmentsUi, logRLC } from '../../descriptions';
import { theHiveApiRequest } from '../../transport';
const properties: INodeProperties[] = [logRLC, attachmentsUi];
const displayOptions = {
show: {
resource: ['log'],
operation: ['addAttachment'],
},
};
export const description = updateDisplayOptions(displayOptions, properties);
export async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {
const logId = this.getNodeParameter('logId', i, '', { extractValue: true }) as string;
const inputDataFields = (
this.getNodeParameter('attachmentsUi.values', i, []) as IDataObject[]
).map((entry) => (entry.field as string).trim());
const attachments = [];
for (const inputDataField of inputDataFields) {
const binaryData = this.helpers.assertBinaryData(i, inputDataField);
const dataBuffer = await this.helpers.getBinaryDataBuffer(i, inputDataField);
attachments.push({
value: dataBuffer,
options: {
contentType: binaryData.mimeType,
filename: binaryData.fileName,
},
});
}
await theHiveApiRequest.call(
this,
'POST',
`/v1/log/${logId}/attachments`,
undefined,
undefined,
undefined,
{
Headers: {
'Content-Type': 'multipart/form-data',
},
formData: {
attachments,
},
},
);
const executionData = this.helpers.constructExecutionMetaData(wrapData({ success: true }), {
itemData: { item: i },
});
return executionData;
}

View File

@@ -0,0 +1,115 @@
import type {
IDataObject,
IExecuteFunctions,
INodeExecutionData,
INodeProperties,
} from 'n8n-workflow';
import { updateDisplayOptions, wrapData } from '@utils/utilities';
import { attachmentsUi, taskRLC } from '../../descriptions';
import { fixFieldType, prepareInputItem } from '../../helpers/utils';
import { theHiveApiRequest } from '../../transport';
const properties: INodeProperties[] = [
taskRLC,
{
displayName: 'Fields',
name: 'logFields',
type: 'resourceMapper',
default: {
mappingMode: 'defineBelow',
value: null,
},
noDataExpression: true,
required: true,
typeOptions: {
resourceMapper: {
resourceMapperMethod: 'getLogFields',
mode: 'add',
valuesLabel: 'Fields',
},
},
},
attachmentsUi,
];
const displayOptions = {
show: {
resource: ['log'],
operation: ['create'],
},
};
export const description = updateDisplayOptions(displayOptions, properties);
export async function execute(
this: IExecuteFunctions,
i: number,
item: INodeExecutionData,
): Promise<INodeExecutionData[]> {
let responseData: IDataObject | IDataObject[] = [];
let body: IDataObject = {};
const dataMode = this.getNodeParameter('logFields.mappingMode', i) as string;
const taskId = this.getNodeParameter('taskId', i, '', { extractValue: true }) as string;
if (dataMode === 'autoMapInputData') {
const schema = this.getNodeParameter('logFields.schema', i) as IDataObject[];
body = prepareInputItem(item.json, schema, i);
}
if (dataMode === 'defineBelow') {
const logFields = this.getNodeParameter('logFields.value', i, []) as IDataObject;
body = logFields;
}
body = fixFieldType(body);
const inputDataFields = (
this.getNodeParameter('attachmentsUi.values', i, []) as IDataObject[]
).map((entry) => (entry.field as string).trim());
if (inputDataFields.length) {
const binaries = [];
for (const inputDataField of inputDataFields) {
const binaryData = this.helpers.assertBinaryData(i, inputDataField);
const dataBuffer = await this.helpers.getBinaryDataBuffer(i, inputDataField);
binaries.push({
value: dataBuffer,
options: {
contentType: binaryData.mimeType,
filename: binaryData.fileName,
},
});
}
responseData = await theHiveApiRequest.call(
this,
'POST',
`/v1/task/${taskId}/log`,
undefined,
undefined,
undefined,
{
Headers: {
'Content-Type': 'multipart/form-data',
},
formData: {
attachments: binaries,
_json: JSON.stringify(body),
},
},
);
} else {
responseData = await theHiveApiRequest.call(this, 'POST', `/v1/task/${taskId}/log`, body);
}
const executionData = this.helpers.constructExecutionMetaData(wrapData(responseData), {
itemData: { item: i },
});
return executionData;
}

View File

@@ -0,0 +1,45 @@
import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow';
import { updateDisplayOptions, wrapData } from '@utils/utilities';
import { logRLC } from '../../descriptions';
import { theHiveApiRequest } from '../../transport';
const properties: INodeProperties[] = [
logRLC,
{
displayName: 'Attachment Name or ID',
name: 'attachmentId',
type: 'options',
default: '',
required: true,
description:
'ID of the attachment. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
typeOptions: {
loadOptionsMethod: 'loadLogAttachments',
loadOptionsDependsOn: ['logId.value'],
},
},
];
const displayOptions = {
show: {
resource: ['log'],
operation: ['deleteAttachment'],
},
};
export const description = updateDisplayOptions(displayOptions, properties);
export async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {
const logId = this.getNodeParameter('logId', i, '', { extractValue: true }) as string;
const attachmentId = this.getNodeParameter('attachmentId', i) as string;
await theHiveApiRequest.call(this, 'DELETE', `/v1/log/${logId}/attachments/${attachmentId}`);
const executionData = this.helpers.constructExecutionMetaData(wrapData({ success: true }), {
itemData: { item: i },
});
return executionData;
}

View File

@@ -0,0 +1,29 @@
import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow';
import { updateDisplayOptions, wrapData } from '@utils/utilities';
import { logRLC } from '../../descriptions';
import { theHiveApiRequest } from '../../transport';
const properties: INodeProperties[] = [logRLC];
const displayOptions = {
show: {
resource: ['log'],
operation: ['deleteLog'],
},
};
export const description = updateDisplayOptions(displayOptions, properties);
export async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {
const logId = this.getNodeParameter('logId', i, '', { extractValue: true }) as string;
await theHiveApiRequest.call(this, 'DELETE', `/v1/log/${logId}`);
const executionData = this.helpers.constructExecutionMetaData(wrapData({ success: true }), {
itemData: { item: i },
});
return executionData;
}

View File

@@ -0,0 +1,74 @@
import type {
IDataObject,
IExecuteFunctions,
INodeExecutionData,
INodeProperties,
} from 'n8n-workflow';
import { updateDisplayOptions, wrapData } from '@utils/utilities';
import { logRLC, responderOptions } from '../../descriptions';
import { theHiveApiRequest } from '../../transport';
const properties: INodeProperties[] = [{ ...logRLC, name: 'id' }, responderOptions];
const displayOptions = {
show: {
resource: ['log'],
operation: ['executeResponder'],
},
};
export const description = updateDisplayOptions(displayOptions, properties);
export async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {
let responseData: IDataObject | IDataObject[] = [];
const logId = this.getNodeParameter('id', i);
const responderId = this.getNodeParameter('responder', i) as string;
let body: IDataObject;
let response;
const qs: IDataObject = {};
body = {
responderId,
objectId: logId,
objectType: 'case_task_log',
};
response = await theHiveApiRequest.call(this, 'POST', '/connector/cortex/action' as string, body);
body = {
query: [
{
_name: 'listAction',
},
{
_name: 'filter',
_and: [
{
_field: 'cortexId',
_value: response.cortexId,
},
{
_field: 'objectId',
_value: response.objectId,
},
{
_field: 'startDate',
_value: response.startDate,
},
],
},
],
};
qs.name = 'log-actions';
do {
response = await theHiveApiRequest.call(this, 'POST', '/v1/query', body, qs);
} while (response.status === 'Waiting' || response.status === 'InProgress');
responseData = response;
const executionData = this.helpers.constructExecutionMetaData(wrapData(responseData), {
itemData: { item: i },
});
return executionData;
}

View File

@@ -0,0 +1,45 @@
import type {
IDataObject,
IExecuteFunctions,
INodeExecutionData,
INodeProperties,
} from 'n8n-workflow';
import { updateDisplayOptions, wrapData } from '@utils/utilities';
import { logRLC } from '../../descriptions';
import { theHiveApiRequest } from '../../transport';
const properties: INodeProperties[] = [logRLC];
const displayOptions = {
show: {
resource: ['log'],
operation: ['get'],
},
};
export const description = updateDisplayOptions(displayOptions, properties);
export async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {
let responseData: IDataObject | IDataObject[] = [];
const logId = this.getNodeParameter('logId', i, '', { extractValue: true }) as string;
const body = {
query: [
{
_name: 'getLog',
idOrName: logId,
},
],
};
responseData = await theHiveApiRequest.call(this, 'POST', '/v1/query', body);
const executionData = this.helpers.constructExecutionMetaData(wrapData(responseData), {
itemData: { item: i },
});
return executionData;
}

View File

@@ -0,0 +1,71 @@
import type { INodeProperties } from 'n8n-workflow';
import * as addAttachment from './addAttachment.operation';
import * as create from './create.operation';
import * as deleteAttachment from './deleteAttachment.operation';
import * as deleteLog from './deleteLog.operation';
import * as executeResponder from './executeResponder.operation';
import * as get from './get.operation';
import * as search from './search.operation';
export { addAttachment, create, deleteAttachment, deleteLog, executeResponder, get, search };
export const description: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
noDataExpression: true,
type: 'options',
required: true,
default: 'create',
options: [
{
name: 'Add Attachment',
value: 'addAttachment',
action: 'Add attachment to a task log',
},
{
name: 'Create',
value: 'create',
action: 'Create a task log',
},
{
name: 'Delete',
value: 'deleteLog',
action: 'Delete task log',
},
{
name: 'Delete Attachment',
value: 'deleteAttachment',
action: 'Delete attachment from a task log',
},
{
name: 'Execute Responder',
value: 'executeResponder',
action: 'Execute responder on a task log',
},
{
name: 'Get',
value: 'get',
action: 'Get a task log',
},
{
name: 'Search',
value: 'search',
action: 'Search task logs',
},
],
displayOptions: {
show: {
resource: ['log'],
},
},
},
...addAttachment.description,
...create.description,
...deleteAttachment.description,
...deleteLog.description,
...executeResponder.description,
...get.description,
...search.description,
];

View File

@@ -0,0 +1,89 @@
import type {
IDataObject,
IExecuteFunctions,
INodeExecutionData,
INodeProperties,
} from 'n8n-workflow';
import { updateDisplayOptions, wrapData } from '@utils/utilities';
import {
taskRLC,
genericFiltersCollection,
returnAllAndLimit,
sortCollection,
searchOptions,
} from '../../descriptions';
import type { QueryScope } from '../../helpers/interfaces';
import { theHiveApiQuery } from '../../transport';
const properties: INodeProperties[] = [
{
displayName: 'Search in All Tasks',
name: 'allTasks',
type: 'boolean',
default: true,
description: 'Whether to search in all tasks or only in selected task',
},
{
...taskRLC,
displayOptions: {
show: {
allTasks: [false],
},
},
},
...returnAllAndLimit,
genericFiltersCollection,
sortCollection,
searchOptions,
];
const displayOptions = {
show: {
resource: ['log'],
operation: ['search'],
},
};
export const description = updateDisplayOptions(displayOptions, properties);
export async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {
let responseData: IDataObject | IDataObject[] = [];
const allTasks = this.getNodeParameter('allTasks', i) as boolean;
const filtersValues = this.getNodeParameter('filters.values', i, []) as IDataObject[];
const sortFields = this.getNodeParameter('sort.fields', i, []) as IDataObject[];
const returnAll = this.getNodeParameter('returnAll', i);
const { returnCount, extraData } = this.getNodeParameter('options', i);
let limit;
let scope: QueryScope;
if (allTasks) {
scope = { query: 'listLog' };
} else {
const taskId = this.getNodeParameter('taskId', i, '', { extractValue: true }) as string;
scope = { query: 'getTask', id: taskId, restrictTo: 'logs' };
}
if (!returnAll) {
limit = this.getNodeParameter('limit', i);
}
responseData = await theHiveApiQuery.call(
this,
scope,
filtersValues,
sortFields,
limit,
returnCount as boolean,
extraData as string[],
);
const executionData = this.helpers.constructExecutionMetaData(wrapData(responseData), {
itemData: { item: i },
});
return executionData;
}