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,74 @@
import type { INodeProperties } from 'n8n-workflow';
import * as download from './download.operation';
import * as update from './update.operation';
import * as upload from './upload.operation';
import { downloadFilePostReceive, handleErrorPostReceive } from '../../helpers/utils';
export const description: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['file'],
},
},
options: [
{
name: 'Download',
value: 'download',
description: 'Download a file',
routing: {
request: {
method: 'GET',
url: '=/sites/{{ $parameter["site"] }}/drive/items/{{ $parameter["file"] }}/content',
json: false,
encoding: 'arraybuffer',
},
output: {
postReceive: [handleErrorPostReceive, downloadFilePostReceive],
},
},
action: 'Download file',
},
{
name: 'Update',
value: 'update',
description: 'Update a file',
routing: {
request: {
method: 'PATCH',
url: '=/sites/{{ $parameter["site"] }}/drive/items/{{ $parameter["file"] }}',
},
output: {
postReceive: [handleErrorPostReceive],
},
},
action: 'Update file',
},
{
name: 'Upload',
value: 'upload',
description: 'Upload an existing file',
routing: {
request: {
method: 'PUT',
url: '=/sites/{{ $parameter["site"] }}/drive/items/{{ $parameter["folder"] }}:/{{ $parameter["fileName"] }}:/content',
},
output: {
postReceive: [handleErrorPostReceive],
},
},
action: 'Upload file',
},
],
default: 'download',
},
...download.description,
...update.description,
...upload.description,
];

View File

@@ -0,0 +1,44 @@
import { updateDisplayOptions, type INodeProperties } from 'n8n-workflow';
import {
fileRLC,
folderRLC,
siteRLC,
untilFolderSelected,
untilSiteSelected,
} from '../common.descriptions';
const properties: INodeProperties[] = [
{
...siteRLC,
description: 'Select the site to retrieve folders from',
},
{
...folderRLC,
description: 'Select the folder to download the file from',
displayOptions: {
hide: {
...untilSiteSelected,
},
},
},
{
...fileRLC,
description: 'Select the file to download',
displayOptions: {
hide: {
...untilSiteSelected,
...untilFolderSelected,
},
},
},
];
const displayOptions = {
show: {
resource: ['file'],
operation: ['download'],
},
};
export const description = updateDisplayOptions(displayOptions, properties);

View File

@@ -0,0 +1,122 @@
import {
updateDisplayOptions,
type IExecuteSingleFunctions,
type IN8nHttpFullResponse,
type INodeExecutionData,
type INodeProperties,
} from 'n8n-workflow';
import { microsoftSharePointApiRequest } from '../../transport';
import {
fileRLC,
folderRLC,
siteRLC,
untilFolderSelected,
untilSiteSelected,
} from '../common.descriptions';
const properties: INodeProperties[] = [
{
...siteRLC,
description: 'Select the site to retrieve folders from',
},
{
...folderRLC,
description: 'Select the folder to update the file in',
displayOptions: {
hide: {
...untilSiteSelected,
},
},
},
{
...fileRLC,
description: 'Select the file to update',
displayOptions: {
hide: {
...untilSiteSelected,
...untilFolderSelected,
},
},
},
{
displayName: 'Updated File Name',
name: 'fileName',
default: '',
description: 'If not specified, the original file name will be used',
placeholder: 'e.g. My New File',
routing: {
send: {
property: 'name',
type: 'body',
value: '={{ $value }}',
},
},
type: 'string',
},
{
displayName: 'Change File Content',
name: 'changeFileContent',
default: false,
description: 'Whether to update the file contents',
placeholder: 'e.g. My New File',
required: true,
type: 'boolean',
},
{
displayName: 'Updated File Contents',
name: 'fileContents',
default: '',
description:
'Find the name of input field containing the binary data to update the file with in the Input panel on the left, in the Binary tab',
displayOptions: {
show: {
changeFileContent: [true],
},
},
hint: 'The name of the input field containing the binary file data to update the file with',
placeholder: 'data',
required: true,
routing: {
output: {
postReceive: [
async function (
this: IExecuteSingleFunctions,
items: INodeExecutionData[],
_response: IN8nHttpFullResponse,
): Promise<INodeExecutionData[]> {
for (const item of items) {
const site = this.getNodeParameter('site', undefined, {
extractValue: true,
}) as string;
const file = this.getNodeParameter('file', undefined, {
extractValue: true,
}) as string;
const binaryProperty = this.getNodeParameter('fileContents') as string;
this.helpers.assertBinaryData(binaryProperty);
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(binaryProperty);
const response = await microsoftSharePointApiRequest.call(
this,
'PUT',
`/sites/${site}/drive/items/${file}/content`,
binaryDataBuffer,
);
item.json = response;
}
return items;
},
],
},
},
type: 'string',
},
];
const displayOptions = {
show: {
resource: ['file'],
operation: ['update'],
},
};
export const description = updateDisplayOptions(displayOptions, properties);

View File

@@ -0,0 +1,54 @@
import { updateDisplayOptions, type INodeProperties } from 'n8n-workflow';
import { uploadFilePreSend } from '../../helpers/utils';
import { folderRLC, siteRLC, untilSiteSelected } from '../common.descriptions';
const properties: INodeProperties[] = [
{
...siteRLC,
description: 'Select the site to retrieve folders from',
},
{
...folderRLC,
description: 'Select the folder to upload the file to',
displayOptions: {
hide: {
...untilSiteSelected,
},
},
},
{
displayName: 'File Name',
name: 'fileName',
default: '',
description: 'The name of the file being uploaded',
placeholder: 'e.g. My New File',
required: true,
type: 'string',
},
{
displayName: 'File Contents',
name: 'fileContents',
default: '',
description:
'Find the name of input field containing the binary data to upload in the Input panel on the left, in the Binary tab',
hint: 'The name of the input field containing the binary file data to upload',
placeholder: 'data',
required: true,
routing: {
send: {
preSend: [uploadFilePreSend],
},
},
type: 'string',
},
];
const displayOptions = {
show: {
resource: ['file'],
operation: ['upload'],
},
};
export const description = updateDisplayOptions(displayOptions, properties);