mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
Merge branch 'vue3' of github.com:n8n-io/n8n into vue3
This commit is contained in:
commit
5c6de8f230
|
@ -78,6 +78,42 @@ describe('Canvas Actions', () => {
|
|||
WorkflowPage.getters.nodeConnections().should('have.length', 1);
|
||||
});
|
||||
|
||||
it('should add a connected node dragging from node creator', () => {
|
||||
WorkflowPage.actions.addNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
|
||||
cy.get('.plus-endpoint').should('be.visible').click();
|
||||
WorkflowPage.getters.nodeCreatorSearchBar().should('be.visible');
|
||||
WorkflowPage.getters.nodeCreatorSearchBar().type(CODE_NODE_NAME);
|
||||
cy.drag(
|
||||
WorkflowPage.getters.nodeCreatorNodeItems().first(),
|
||||
[100, 100],
|
||||
{
|
||||
realMouse: true,
|
||||
abs: true
|
||||
}
|
||||
);
|
||||
cy.get('body').type('{esc}');
|
||||
WorkflowPage.getters.canvasNodes().should('have.length', 2);
|
||||
WorkflowPage.getters.nodeConnections().should('have.length', 1);
|
||||
});
|
||||
|
||||
it('should open a category when trying to drag and drop it on the canvas', () => {
|
||||
WorkflowPage.actions.addNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
|
||||
cy.get('.plus-endpoint').should('be.visible').click();
|
||||
WorkflowPage.getters.nodeCreatorSearchBar().should('be.visible');
|
||||
WorkflowPage.getters.nodeCreatorSearchBar().type(CODE_NODE_NAME);
|
||||
cy.drag(
|
||||
WorkflowPage.getters.nodeCreatorActionItems().first(),
|
||||
[100, 100],
|
||||
{
|
||||
realMouse: true,
|
||||
abs: true
|
||||
}
|
||||
);
|
||||
WorkflowPage.getters.nodeCreatorCategoryItems().its('length').should('be.gt', 0);
|
||||
WorkflowPage.getters.canvasNodes().should('have.length', 1);
|
||||
WorkflowPage.getters.nodeConnections().should('have.length', 0);
|
||||
});
|
||||
|
||||
it('should add disconnected node if nothing is selected', () => {
|
||||
WorkflowPage.actions.addNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
|
||||
// Deselect nodes
|
||||
|
|
|
@ -97,6 +97,9 @@ export class WorkflowPage extends BasePage {
|
|||
nodeCredentialsCreateOption: () => cy.getByTestId('node-credentials-select-item-new'),
|
||||
nodeCredentialsEditButton: () => cy.getByTestId('credential-edit-button'),
|
||||
nodeCreatorItems: () => cy.getByTestId('item-iterator-item'),
|
||||
nodeCreatorNodeItems: () => cy.getByTestId('node-creator-node-item'),
|
||||
nodeCreatorActionItems: () => cy.getByTestId('node-creator-action-item'),
|
||||
nodeCreatorCategoryItems: () => cy.getByTestId('node-creator-category-item'),
|
||||
ndvParameters: () => cy.getByTestId('parameter-item'),
|
||||
nodeCredentialsLabel: () => cy.getByTestId('credentials-label'),
|
||||
getConnectionBetweenNodes: (sourceNodeName: string, targetNodeName: string) =>
|
||||
|
|
|
@ -103,19 +103,31 @@ Cypress.Commands.add('paste', { prevSubject: true }, (selector, pastePayload) =>
|
|||
Cypress.Commands.add('drag', (selector, pos, options) => {
|
||||
const index = options?.index || 0;
|
||||
const [xDiff, yDiff] = pos;
|
||||
const element = cy.get(selector).eq(index);
|
||||
const element = typeof selector === 'string' ? cy.get(selector).eq(index) : selector;
|
||||
element.should('exist');
|
||||
|
||||
const originalLocation = Cypress.$(selector)[index].getBoundingClientRect();
|
||||
element.then(([$el]) => {
|
||||
const originalLocation = $el.getBoundingClientRect();
|
||||
const newPosition = {
|
||||
x: options?.abs ? xDiff : originalLocation.x + xDiff,
|
||||
y: options?.abs ? yDiff : originalLocation.y + yDiff,
|
||||
}
|
||||
|
||||
element.trigger('mousedown', { force: true });
|
||||
if(options?.realMouse) {
|
||||
element.realMouseDown();
|
||||
element.realMouseMove(newPosition.x, newPosition.y);
|
||||
element.realMouseUp();
|
||||
} else {
|
||||
element.trigger('mousedown', {force: true});
|
||||
element.trigger('mousemove', {
|
||||
which: 1,
|
||||
pageX: options?.abs ? xDiff : originalLocation.right + xDiff,
|
||||
pageY: options?.abs ? yDiff : originalLocation.top + yDiff,
|
||||
pageX: newPosition.x,
|
||||
pageY: newPosition.y,
|
||||
force: true,
|
||||
});
|
||||
element.trigger('mouseup', { force: true });
|
||||
element.trigger('mouseup', {force: true});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('draganddrop', (draggableSelector, droppableSelector) => {
|
||||
|
|
|
@ -31,7 +31,7 @@ declare global {
|
|||
grantBrowserPermissions(...permissions: string[]): void;
|
||||
readClipboard(): Chainable<string>;
|
||||
paste(pastePayload: string): void;
|
||||
drag(selector: string, target: [number, number], options?: {abs?: true, index?: number}): void;
|
||||
drag(selector: string | Cypress.Chainable<JQuery<HTMLElement>>, target: [number, number], options?: {abs?: boolean, index?: number, realMouse?: boolean}): void;
|
||||
draganddrop(draggableSelector: string, droppableSelector: string): void;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import type { PropType } from 'vue';
|
|||
import { mapStores } from 'pinia';
|
||||
|
||||
import type { LanguageSupport } from '@codemirror/language';
|
||||
import type { Extension } from '@codemirror/state';
|
||||
import type { Extension, Line } from '@codemirror/state';
|
||||
import { Compartment, EditorState } from '@codemirror/state';
|
||||
import type { ViewUpdate } from '@codemirror/view';
|
||||
import { EditorView } from '@codemirror/view';
|
||||
|
@ -154,18 +154,29 @@ export default defineComponent({
|
|||
changes: { from: 0, to: this.content.length, insert: this.placeholder },
|
||||
});
|
||||
},
|
||||
highlightLine(line: number | 'final') {
|
||||
line(lineNumber: number): Line | null {
|
||||
try {
|
||||
return this.editor?.state.doc.line(lineNumber) ?? null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
highlightLine(lineNumber: number | 'final') {
|
||||
if (!this.editor) return;
|
||||
|
||||
if (line === 'final') {
|
||||
if (lineNumber === 'final') {
|
||||
this.editor.dispatch({
|
||||
selection: { anchor: this.content.length },
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const line = this.line(lineNumber);
|
||||
|
||||
if (!line) return;
|
||||
|
||||
this.editor.dispatch({
|
||||
selection: { anchor: this.editor.state.doc.line(line).from },
|
||||
selection: { anchor: line.from },
|
||||
});
|
||||
},
|
||||
trackCompletion(viewUpdate: ViewUpdate) {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
:title="displayName"
|
||||
:show-action-arrow="showActionArrow"
|
||||
:is-trigger="isTrigger"
|
||||
:data-test-id="dataTestId"
|
||||
>
|
||||
<template #icon>
|
||||
<node-icon :nodeType="nodeType" />
|
||||
|
@ -77,6 +78,9 @@ const description = computed<string>(() => {
|
|||
}) as string;
|
||||
});
|
||||
const showActionArrow = computed(() => hasActions.value);
|
||||
const dataTestId = computed(() =>
|
||||
hasActions.value ? 'node-creator-action-item' : 'node-creator-node-item',
|
||||
);
|
||||
|
||||
const hasActions = computed(() => {
|
||||
return nodeActions.value.length > 1;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
:class="$style.nodeCreator"
|
||||
:style="nodeCreatorInlineStyle"
|
||||
ref="nodeCreator"
|
||||
v-on-click-outside="onClickOutside"
|
||||
@dragover="onDragOver"
|
||||
@drop="onDrop"
|
||||
@mousedown="onMouseDown"
|
||||
|
@ -21,7 +20,7 @@
|
|||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { watch, reactive, toRefs, computed } from 'vue';
|
||||
import { watch, reactive, toRefs, computed, onBeforeUnmount } from 'vue';
|
||||
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
import { useNodeCreatorStore } from '@/stores/nodeCreator.store';
|
||||
|
@ -62,13 +61,7 @@ const viewStacksLength = computed(() => useViewStacks().viewStacks.length);
|
|||
const nodeCreatorInlineStyle = computed(() => {
|
||||
return { top: `${uiStore.bannersHeight + uiStore.headerHeight}px` };
|
||||
});
|
||||
|
||||
function onClickOutside(event: Event) {
|
||||
// We need to prevent cases where user would click inside the node creator
|
||||
// and try to drag non-draggable element. In that case the click event would
|
||||
// be fired and the node creator would be closed. So we stop that if we detect
|
||||
// that the click event originated from inside the node creator. And fire click even on the
|
||||
// original target.
|
||||
function onMouseUpOutside() {
|
||||
if (state.mousedownInsideEvent) {
|
||||
const clickEvent = new MouseEvent('click', {
|
||||
bubbles: true,
|
||||
|
@ -76,18 +69,21 @@ function onClickOutside(event: Event) {
|
|||
});
|
||||
state.mousedownInsideEvent.target?.dispatchEvent(clickEvent);
|
||||
state.mousedownInsideEvent = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.type === 'click') {
|
||||
emit('closeNodeCreator');
|
||||
unBindOnMouseUpOutside();
|
||||
}
|
||||
}
|
||||
function unBindOnMouseUpOutside() {
|
||||
document.removeEventListener('mouseup', onMouseUpOutside);
|
||||
document.removeEventListener('touchstart', onMouseUpOutside);
|
||||
}
|
||||
function onMouseUp() {
|
||||
state.mousedownInsideEvent = null;
|
||||
unBindOnMouseUpOutside();
|
||||
}
|
||||
function onMouseDown(event: MouseEvent) {
|
||||
state.mousedownInsideEvent = event;
|
||||
document.addEventListener('mouseup', onMouseUpOutside);
|
||||
document.addEventListener('touchstart', onMouseUpOutside);
|
||||
}
|
||||
function onDragOver(event: DragEvent) {
|
||||
event.preventDefault();
|
||||
|
@ -148,6 +144,10 @@ watch(
|
|||
{ immediate: true },
|
||||
);
|
||||
const { nodeCreator } = toRefs(state);
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
unBindOnMouseUpOutside();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style module lang="scss">
|
||||
|
|
|
@ -16,6 +16,7 @@ import { acceptCompletion, autocompletion, ifNotIn } from '@codemirror/autocompl
|
|||
import { indentWithTab, history, redo, toggleComment } from '@codemirror/commands';
|
||||
import { bracketMatching, foldGutter, indentOnInput, LanguageSupport } from '@codemirror/language';
|
||||
import { EditorState } from '@codemirror/state';
|
||||
import type { Line } from '@codemirror/state';
|
||||
import type { Extension } from '@codemirror/state';
|
||||
import {
|
||||
dropCursor,
|
||||
|
@ -192,18 +193,29 @@ export default defineComponent({
|
|||
onBlur() {
|
||||
this.isFocused = false;
|
||||
},
|
||||
highlightLine(line: number | 'final') {
|
||||
line(lineNumber: number): Line | null {
|
||||
try {
|
||||
return this.editor?.state.doc.line(lineNumber) ?? null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
highlightLine(lineNumber: number | 'final') {
|
||||
if (!this.editor) return;
|
||||
|
||||
if (line === 'final') {
|
||||
if (lineNumber === 'final') {
|
||||
this.editor.dispatch({
|
||||
selection: { anchor: this.modelValue.length },
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const line = this.line(lineNumber);
|
||||
|
||||
if (!line) return;
|
||||
|
||||
this.editor.dispatch({
|
||||
selection: { anchor: this.editor.state.doc.line(line).from },
|
||||
selection: { anchor: line.from },
|
||||
});
|
||||
},
|
||||
},
|
||||
|
|
|
@ -215,6 +215,8 @@ export class AwsS3V2 implements INodeType {
|
|||
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
|
||||
if (operation === 'search') {
|
||||
const bucketName = this.getNodeParameter('bucketName', i) as string;
|
||||
const servicePath = bucketName.includes('.') ? 's3' : `${bucketName}.s3`;
|
||||
const basePath = bucketName.includes('.') ? `/${bucketName}` : '';
|
||||
const returnAll = this.getNodeParameter('returnAll', 0);
|
||||
const additionalFields = this.getNodeParameter('additionalFields', 0);
|
||||
|
||||
|
@ -243,8 +245,7 @@ export class AwsS3V2 implements INodeType {
|
|||
}
|
||||
|
||||
qs['list-type'] = 2;
|
||||
|
||||
responseData = await awsApiRequestREST.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
||||
responseData = await awsApiRequestREST.call(this, servicePath, 'GET', basePath, '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
|
@ -254,9 +255,9 @@ export class AwsS3V2 implements INodeType {
|
|||
responseData = await awsApiRequestRESTAllItems.call(
|
||||
this,
|
||||
'ListBucketResult.Contents',
|
||||
`${bucketName}.s3`,
|
||||
servicePath,
|
||||
'GET',
|
||||
'',
|
||||
basePath,
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
|
@ -267,9 +268,9 @@ export class AwsS3V2 implements INodeType {
|
|||
qs['max-keys'] = this.getNodeParameter('limit', 0);
|
||||
responseData = await awsApiRequestREST.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
servicePath,
|
||||
'GET',
|
||||
'',
|
||||
basePath,
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
|
@ -282,6 +283,7 @@ export class AwsS3V2 implements INodeType {
|
|||
this.helpers.returnJsonArray(responseData as IDataObject[]),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||
returnData.push(...executionData);
|
||||
}
|
||||
}
|
||||
|
@ -289,9 +291,11 @@ export class AwsS3V2 implements INodeType {
|
|||
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html
|
||||
if (operation === 'create') {
|
||||
const bucketName = this.getNodeParameter('bucketName', i) as string;
|
||||
const servicePath = bucketName.includes('.') ? 's3' : `${bucketName}.s3`;
|
||||
const basePath = bucketName.includes('.') ? `/${bucketName}` : '';
|
||||
const folderName = this.getNodeParameter('folderName', i) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
let path = `/${folderName}/`;
|
||||
let path = `${basePath}/${folderName}/`;
|
||||
|
||||
if (additionalFields.requesterPays) {
|
||||
headers['x-amz-request-payer'] = 'requester';
|
||||
|
@ -304,7 +308,7 @@ export class AwsS3V2 implements INodeType {
|
|||
additionalFields.storageClass as string,
|
||||
).toUpperCase();
|
||||
}
|
||||
responseData = await awsApiRequestREST.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
||||
responseData = await awsApiRequestREST.call(this, servicePath, 'GET', basePath, '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
|
@ -312,7 +316,7 @@ export class AwsS3V2 implements INodeType {
|
|||
|
||||
responseData = await awsApiRequestREST.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
servicePath,
|
||||
'PUT',
|
||||
path,
|
||||
'',
|
||||
|
@ -330,9 +334,11 @@ export class AwsS3V2 implements INodeType {
|
|||
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html
|
||||
if (operation === 'delete') {
|
||||
const bucketName = this.getNodeParameter('bucketName', i) as string;
|
||||
const servicePath = bucketName.includes('.') ? 's3' : `${bucketName}.s3`;
|
||||
const basePath = bucketName.includes('.') ? `/${bucketName}` : '';
|
||||
const folderKey = this.getNodeParameter('folderKey', i) as string;
|
||||
|
||||
responseData = await awsApiRequestREST.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
||||
responseData = await awsApiRequestREST.call(this, servicePath, 'GET', basePath, '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
|
@ -341,9 +347,9 @@ export class AwsS3V2 implements INodeType {
|
|||
responseData = await awsApiRequestRESTAllItems.call(
|
||||
this,
|
||||
'ListBucketResult.Contents',
|
||||
`${bucketName}.s3`,
|
||||
servicePath,
|
||||
'GET',
|
||||
'/',
|
||||
basePath,
|
||||
'',
|
||||
{ 'list-type': 2, prefix: folderKey },
|
||||
{},
|
||||
|
@ -355,9 +361,9 @@ export class AwsS3V2 implements INodeType {
|
|||
if (responseData.length === 0) {
|
||||
responseData = await awsApiRequestREST.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
servicePath,
|
||||
'DELETE',
|
||||
`/${folderKey}`,
|
||||
`${basePath}/${folderKey}`,
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
|
@ -393,9 +399,9 @@ export class AwsS3V2 implements INodeType {
|
|||
|
||||
responseData = await awsApiRequestREST.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
servicePath,
|
||||
'POST',
|
||||
'/',
|
||||
`${basePath}/`,
|
||||
data,
|
||||
{ delete: '' },
|
||||
headers,
|
||||
|
@ -414,6 +420,8 @@ export class AwsS3V2 implements INodeType {
|
|||
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
|
||||
if (operation === 'getAll') {
|
||||
const bucketName = this.getNodeParameter('bucketName', i) as string;
|
||||
const servicePath = bucketName.includes('.') ? 's3' : `${bucketName}.s3`;
|
||||
const basePath = bucketName.includes('.') ? `/${bucketName}` : '';
|
||||
const returnAll = this.getNodeParameter('returnAll', 0);
|
||||
const options = this.getNodeParameter('options', 0);
|
||||
|
||||
|
@ -427,7 +435,7 @@ export class AwsS3V2 implements INodeType {
|
|||
|
||||
qs['list-type'] = 2;
|
||||
|
||||
responseData = await awsApiRequestREST.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
||||
responseData = await awsApiRequestREST.call(this, servicePath, 'GET', basePath, '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
|
@ -437,9 +445,9 @@ export class AwsS3V2 implements INodeType {
|
|||
responseData = await awsApiRequestRESTAllItems.call(
|
||||
this,
|
||||
'ListBucketResult.Contents',
|
||||
`${bucketName}.s3`,
|
||||
servicePath,
|
||||
'GET',
|
||||
'',
|
||||
basePath,
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
|
@ -451,9 +459,9 @@ export class AwsS3V2 implements INodeType {
|
|||
responseData = await awsApiRequestRESTAllItems.call(
|
||||
this,
|
||||
'ListBucketResult.Contents',
|
||||
`${bucketName}.s3`,
|
||||
servicePath,
|
||||
'GET',
|
||||
'',
|
||||
basePath,
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
|
@ -561,10 +569,12 @@ export class AwsS3V2 implements INodeType {
|
|||
const destinationParts = destinationPath.split('/');
|
||||
|
||||
const bucketName = destinationParts[1];
|
||||
const servicePath = bucketName.includes('.') ? 's3' : `${bucketName}.s3`;
|
||||
const basePath = bucketName.includes('.') ? `/${bucketName}` : '';
|
||||
|
||||
const destination = `/${destinationParts.slice(2, destinationParts.length).join('/')}`;
|
||||
const destination = `${basePath}/${destinationParts.slice(2, destinationParts.length).join('/')}`;
|
||||
|
||||
responseData = await awsApiRequestREST.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
||||
responseData = await awsApiRequestREST.call(this, servicePath, 'GET', basePath, '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
|
@ -572,7 +582,7 @@ export class AwsS3V2 implements INodeType {
|
|||
|
||||
responseData = await awsApiRequestREST.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
servicePath,
|
||||
'PUT',
|
||||
destination,
|
||||
'',
|
||||
|
@ -590,6 +600,8 @@ export class AwsS3V2 implements INodeType {
|
|||
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html
|
||||
if (operation === 'download') {
|
||||
const bucketName = this.getNodeParameter('bucketName', i) as string;
|
||||
const servicePath = bucketName.includes('.') ? 's3' : `${bucketName}.s3`;
|
||||
const basePath = bucketName.includes('.') ? `/${bucketName}` : '';
|
||||
|
||||
const fileKey = this.getNodeParameter('fileKey', i) as string;
|
||||
|
||||
|
@ -602,7 +614,7 @@ export class AwsS3V2 implements INodeType {
|
|||
);
|
||||
}
|
||||
|
||||
let region = await awsApiRequestREST.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
||||
let region = await awsApiRequestREST.call(this, servicePath, 'GET', basePath, '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
|
@ -610,9 +622,9 @@ export class AwsS3V2 implements INodeType {
|
|||
|
||||
const response = await awsApiRequestREST.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
servicePath,
|
||||
'GET',
|
||||
`/${fileKey}`,
|
||||
`${basePath}/${fileKey}`,
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
|
@ -652,6 +664,8 @@ export class AwsS3V2 implements INodeType {
|
|||
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html
|
||||
if (operation === 'delete') {
|
||||
const bucketName = this.getNodeParameter('bucketName', i) as string;
|
||||
const servicePath = bucketName.includes('.') ? 's3' : `${bucketName}.s3`;
|
||||
const basePath = bucketName.includes('.') ? `/${bucketName}` : '';
|
||||
|
||||
const fileKey = this.getNodeParameter('fileKey', i) as string;
|
||||
|
||||
|
@ -661,7 +675,7 @@ export class AwsS3V2 implements INodeType {
|
|||
qs.versionId = options.versionId as string;
|
||||
}
|
||||
|
||||
responseData = await awsApiRequestREST.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
||||
responseData = await awsApiRequestREST.call(this, servicePath, 'GET', basePath, '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
|
@ -669,9 +683,9 @@ export class AwsS3V2 implements INodeType {
|
|||
|
||||
responseData = await awsApiRequestREST.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
servicePath,
|
||||
'DELETE',
|
||||
`/${fileKey}`,
|
||||
`${basePath}/${fileKey}`,
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
|
@ -687,6 +701,8 @@ export class AwsS3V2 implements INodeType {
|
|||
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
|
||||
if (operation === 'getAll') {
|
||||
const bucketName = this.getNodeParameter('bucketName', i) as string;
|
||||
const servicePath = bucketName.includes('.') ? 's3' : `${bucketName}.s3`;
|
||||
const basePath = bucketName.includes('.') ? `/${bucketName}` : '';
|
||||
const returnAll = this.getNodeParameter('returnAll', 0);
|
||||
const options = this.getNodeParameter('options', 0);
|
||||
|
||||
|
@ -702,7 +718,7 @@ export class AwsS3V2 implements INodeType {
|
|||
|
||||
qs['list-type'] = 2;
|
||||
|
||||
responseData = await awsApiRequestREST.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
||||
responseData = await awsApiRequestREST.call(this, servicePath, 'GET', basePath, '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
|
@ -712,9 +728,9 @@ export class AwsS3V2 implements INodeType {
|
|||
responseData = await awsApiRequestRESTAllItems.call(
|
||||
this,
|
||||
'ListBucketResult.Contents',
|
||||
`${bucketName}.s3`,
|
||||
servicePath,
|
||||
'GET',
|
||||
'',
|
||||
basePath,
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
|
@ -726,9 +742,9 @@ export class AwsS3V2 implements INodeType {
|
|||
responseData = await awsApiRequestRESTAllItems.call(
|
||||
this,
|
||||
'ListBucketResult.Contents',
|
||||
`${bucketName}.s3`,
|
||||
servicePath,
|
||||
'GET',
|
||||
'',
|
||||
basePath,
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
|
@ -754,12 +770,14 @@ export class AwsS3V2 implements INodeType {
|
|||
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html
|
||||
if (operation === 'upload') {
|
||||
const bucketName = this.getNodeParameter('bucketName', i) as string;
|
||||
const servicePath = bucketName.includes('.') ? 's3' : `${bucketName}.s3`;
|
||||
const basePath = bucketName.includes('.') ? `/${bucketName}` : '';
|
||||
const fileName = this.getNodeParameter('fileName', i) as string;
|
||||
const isBinaryData = this.getNodeParameter('binaryData', i);
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
const tagsValues = (this.getNodeParameter('tagsUi', i) as IDataObject)
|
||||
.tagsValues as IDataObject[];
|
||||
let path = '';
|
||||
let path = `${basePath}/`;
|
||||
let body;
|
||||
|
||||
const multipartHeaders: IDataObject = {};
|
||||
|
@ -839,7 +857,7 @@ export class AwsS3V2 implements INodeType {
|
|||
multipartHeaders['x-amz-tagging'] = tags.join('&');
|
||||
}
|
||||
// Get the region of the bucket
|
||||
responseData = await awsApiRequestREST.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
||||
responseData = await awsApiRequestREST.call(this, servicePath, 'GET', basePath, '', {
|
||||
location: '',
|
||||
});
|
||||
const region = responseData.LocationConstraint._;
|
||||
|
@ -853,7 +871,7 @@ export class AwsS3V2 implements INodeType {
|
|||
uploadData = this.helpers.getBinaryStream(binaryPropertyData.id, UPLOAD_CHUNK_SIZE);
|
||||
const createMultiPartUpload = await awsApiRequestREST.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
servicePath,
|
||||
'POST',
|
||||
`/${path}?uploads`,
|
||||
body,
|
||||
|
@ -875,7 +893,7 @@ export class AwsS3V2 implements INodeType {
|
|||
try {
|
||||
await awsApiRequestREST.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
servicePath,
|
||||
'PUT',
|
||||
`/${path}?partNumber=${part}&uploadId=${uploadId}`,
|
||||
chunk,
|
||||
|
@ -889,7 +907,7 @@ export class AwsS3V2 implements INodeType {
|
|||
try {
|
||||
await awsApiRequestREST.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
servicePath,
|
||||
'DELETE',
|
||||
`/${path}?uploadId=${uploadId}`,
|
||||
);
|
||||
|
@ -902,7 +920,7 @@ export class AwsS3V2 implements INodeType {
|
|||
|
||||
const listParts = (await awsApiRequestREST.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
servicePath,
|
||||
'GET',
|
||||
`/${path}?max-parts=${900}&part-number-marker=0&uploadId=${uploadId}`,
|
||||
'',
|
||||
|
@ -954,7 +972,7 @@ export class AwsS3V2 implements INodeType {
|
|||
const data = builder.buildObject(body);
|
||||
const completeUpload = (await awsApiRequestREST.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
servicePath,
|
||||
'POST',
|
||||
`/${path}?uploadId=${uploadId}`,
|
||||
data,
|
||||
|
@ -991,7 +1009,7 @@ export class AwsS3V2 implements INodeType {
|
|||
|
||||
responseData = await awsApiRequestREST.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
servicePath,
|
||||
'PUT',
|
||||
`/${path || binaryPropertyData.fileName}`,
|
||||
body,
|
||||
|
@ -1019,7 +1037,7 @@ export class AwsS3V2 implements INodeType {
|
|||
|
||||
responseData = await awsApiRequestREST.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
servicePath,
|
||||
'PUT',
|
||||
`/${path}`,
|
||||
body,
|
||||
|
|
|
@ -119,6 +119,21 @@ export class Rundeck implements INodeType {
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Filter',
|
||||
name: 'filter',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['execute'],
|
||||
resource: ['job'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
placeholder: 'Add Filters',
|
||||
required: false,
|
||||
description: 'Filter Rundeck nodes by name',
|
||||
},
|
||||
|
||||
// ----------------------------------
|
||||
// job:getMetadata
|
||||
|
@ -161,7 +176,8 @@ export class Rundeck implements INodeType {
|
|||
const jobid = this.getNodeParameter('jobid', i) as string;
|
||||
const rundeckArguments = (this.getNodeParameter('arguments', i) as IDataObject)
|
||||
.arguments as IDataObject[];
|
||||
const response = await rundeckApi.executeJob(jobid, rundeckArguments);
|
||||
const filter = this.getNodeParameter('filter', i) as string;
|
||||
const response = await rundeckApi.executeJob(jobid, rundeckArguments, filter);
|
||||
|
||||
returnData.push(response);
|
||||
} else if (operation === 'getMetadata') {
|
||||
|
|
|
@ -49,7 +49,7 @@ export class RundeckApi {
|
|||
this.credentials = credentials as unknown as RundeckCredentials;
|
||||
}
|
||||
|
||||
async executeJob(jobId: string, args: IDataObject[]): Promise<IDataObject> {
|
||||
async executeJob(jobId: string, args: IDataObject[], filter?: string): Promise<IDataObject> {
|
||||
let params = '';
|
||||
|
||||
if (args) {
|
||||
|
@ -62,7 +62,12 @@ export class RundeckApi {
|
|||
argString: params,
|
||||
};
|
||||
|
||||
return this.request('POST', `/api/14/job/${jobId}/run`, body, {});
|
||||
const query: IDataObject = {};
|
||||
if (filter) {
|
||||
query.filter = filter;
|
||||
}
|
||||
|
||||
return this.request('POST', `/api/14/job/${jobId}/run`, body, query);
|
||||
}
|
||||
|
||||
async getJobMetadata(jobId: string): Promise<IDataObject> {
|
||||
|
|
Loading…
Reference in a new issue