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);
|
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', () => {
|
it('should add disconnected node if nothing is selected', () => {
|
||||||
WorkflowPage.actions.addNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
|
WorkflowPage.actions.addNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
|
||||||
// Deselect nodes
|
// Deselect nodes
|
||||||
|
|
|
@ -97,6 +97,9 @@ export class WorkflowPage extends BasePage {
|
||||||
nodeCredentialsCreateOption: () => cy.getByTestId('node-credentials-select-item-new'),
|
nodeCredentialsCreateOption: () => cy.getByTestId('node-credentials-select-item-new'),
|
||||||
nodeCredentialsEditButton: () => cy.getByTestId('credential-edit-button'),
|
nodeCredentialsEditButton: () => cy.getByTestId('credential-edit-button'),
|
||||||
nodeCreatorItems: () => cy.getByTestId('item-iterator-item'),
|
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'),
|
ndvParameters: () => cy.getByTestId('parameter-item'),
|
||||||
nodeCredentialsLabel: () => cy.getByTestId('credentials-label'),
|
nodeCredentialsLabel: () => cy.getByTestId('credentials-label'),
|
||||||
getConnectionBetweenNodes: (sourceNodeName: string, targetNodeName: string) =>
|
getConnectionBetweenNodes: (sourceNodeName: string, targetNodeName: string) =>
|
||||||
|
|
|
@ -103,19 +103,31 @@ Cypress.Commands.add('paste', { prevSubject: true }, (selector, pastePayload) =>
|
||||||
Cypress.Commands.add('drag', (selector, pos, options) => {
|
Cypress.Commands.add('drag', (selector, pos, options) => {
|
||||||
const index = options?.index || 0;
|
const index = options?.index || 0;
|
||||||
const [xDiff, yDiff] = pos;
|
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');
|
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.trigger('mousemove', {
|
element.realMouseDown();
|
||||||
which: 1,
|
element.realMouseMove(newPosition.x, newPosition.y);
|
||||||
pageX: options?.abs ? xDiff : originalLocation.right + xDiff,
|
element.realMouseUp();
|
||||||
pageY: options?.abs ? yDiff : originalLocation.top + yDiff,
|
} else {
|
||||||
force: true,
|
element.trigger('mousedown', {force: true});
|
||||||
|
element.trigger('mousemove', {
|
||||||
|
which: 1,
|
||||||
|
pageX: newPosition.x,
|
||||||
|
pageY: newPosition.y,
|
||||||
|
force: true,
|
||||||
|
});
|
||||||
|
element.trigger('mouseup', {force: true});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
element.trigger('mouseup', { force: true });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Cypress.Commands.add('draganddrop', (draggableSelector, droppableSelector) => {
|
Cypress.Commands.add('draganddrop', (draggableSelector, droppableSelector) => {
|
||||||
|
|
|
@ -31,7 +31,7 @@ declare global {
|
||||||
grantBrowserPermissions(...permissions: string[]): void;
|
grantBrowserPermissions(...permissions: string[]): void;
|
||||||
readClipboard(): Chainable<string>;
|
readClipboard(): Chainable<string>;
|
||||||
paste(pastePayload: string): void;
|
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;
|
draganddrop(draggableSelector: string, droppableSelector: string): void;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import type { PropType } from 'vue';
|
||||||
import { mapStores } from 'pinia';
|
import { mapStores } from 'pinia';
|
||||||
|
|
||||||
import type { LanguageSupport } from '@codemirror/language';
|
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 { Compartment, EditorState } from '@codemirror/state';
|
||||||
import type { ViewUpdate } from '@codemirror/view';
|
import type { ViewUpdate } from '@codemirror/view';
|
||||||
import { EditorView } 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 },
|
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 (!this.editor) return;
|
||||||
|
|
||||||
if (line === 'final') {
|
if (lineNumber === 'final') {
|
||||||
this.editor.dispatch({
|
this.editor.dispatch({
|
||||||
selection: { anchor: this.content.length },
|
selection: { anchor: this.content.length },
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const line = this.line(lineNumber);
|
||||||
|
|
||||||
|
if (!line) return;
|
||||||
|
|
||||||
this.editor.dispatch({
|
this.editor.dispatch({
|
||||||
selection: { anchor: this.editor.state.doc.line(line).from },
|
selection: { anchor: line.from },
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
trackCompletion(viewUpdate: ViewUpdate) {
|
trackCompletion(viewUpdate: ViewUpdate) {
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
:title="displayName"
|
:title="displayName"
|
||||||
:show-action-arrow="showActionArrow"
|
:show-action-arrow="showActionArrow"
|
||||||
:is-trigger="isTrigger"
|
:is-trigger="isTrigger"
|
||||||
|
:data-test-id="dataTestId"
|
||||||
>
|
>
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<node-icon :nodeType="nodeType" />
|
<node-icon :nodeType="nodeType" />
|
||||||
|
@ -77,6 +78,9 @@ const description = computed<string>(() => {
|
||||||
}) as string;
|
}) as string;
|
||||||
});
|
});
|
||||||
const showActionArrow = computed(() => hasActions.value);
|
const showActionArrow = computed(() => hasActions.value);
|
||||||
|
const dataTestId = computed(() =>
|
||||||
|
hasActions.value ? 'node-creator-action-item' : 'node-creator-node-item',
|
||||||
|
);
|
||||||
|
|
||||||
const hasActions = computed(() => {
|
const hasActions = computed(() => {
|
||||||
return nodeActions.value.length > 1;
|
return nodeActions.value.length > 1;
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
:class="$style.nodeCreator"
|
:class="$style.nodeCreator"
|
||||||
:style="nodeCreatorInlineStyle"
|
:style="nodeCreatorInlineStyle"
|
||||||
ref="nodeCreator"
|
ref="nodeCreator"
|
||||||
v-on-click-outside="onClickOutside"
|
|
||||||
@dragover="onDragOver"
|
@dragover="onDragOver"
|
||||||
@drop="onDrop"
|
@drop="onDrop"
|
||||||
@mousedown="onMouseDown"
|
@mousedown="onMouseDown"
|
||||||
|
@ -21,7 +20,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<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 { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||||
import { useNodeCreatorStore } from '@/stores/nodeCreator.store';
|
import { useNodeCreatorStore } from '@/stores/nodeCreator.store';
|
||||||
|
@ -62,13 +61,7 @@ const viewStacksLength = computed(() => useViewStacks().viewStacks.length);
|
||||||
const nodeCreatorInlineStyle = computed(() => {
|
const nodeCreatorInlineStyle = computed(() => {
|
||||||
return { top: `${uiStore.bannersHeight + uiStore.headerHeight}px` };
|
return { top: `${uiStore.bannersHeight + uiStore.headerHeight}px` };
|
||||||
});
|
});
|
||||||
|
function onMouseUpOutside() {
|
||||||
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.
|
|
||||||
if (state.mousedownInsideEvent) {
|
if (state.mousedownInsideEvent) {
|
||||||
const clickEvent = new MouseEvent('click', {
|
const clickEvent = new MouseEvent('click', {
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
|
@ -76,18 +69,21 @@ function onClickOutside(event: Event) {
|
||||||
});
|
});
|
||||||
state.mousedownInsideEvent.target?.dispatchEvent(clickEvent);
|
state.mousedownInsideEvent.target?.dispatchEvent(clickEvent);
|
||||||
state.mousedownInsideEvent = null;
|
state.mousedownInsideEvent = null;
|
||||||
return;
|
unBindOnMouseUpOutside();
|
||||||
}
|
|
||||||
|
|
||||||
if (event.type === 'click') {
|
|
||||||
emit('closeNodeCreator');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function unBindOnMouseUpOutside() {
|
||||||
|
document.removeEventListener('mouseup', onMouseUpOutside);
|
||||||
|
document.removeEventListener('touchstart', onMouseUpOutside);
|
||||||
|
}
|
||||||
function onMouseUp() {
|
function onMouseUp() {
|
||||||
state.mousedownInsideEvent = null;
|
state.mousedownInsideEvent = null;
|
||||||
|
unBindOnMouseUpOutside();
|
||||||
}
|
}
|
||||||
function onMouseDown(event: MouseEvent) {
|
function onMouseDown(event: MouseEvent) {
|
||||||
state.mousedownInsideEvent = event;
|
state.mousedownInsideEvent = event;
|
||||||
|
document.addEventListener('mouseup', onMouseUpOutside);
|
||||||
|
document.addEventListener('touchstart', onMouseUpOutside);
|
||||||
}
|
}
|
||||||
function onDragOver(event: DragEvent) {
|
function onDragOver(event: DragEvent) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -148,6 +144,10 @@ watch(
|
||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
);
|
);
|
||||||
const { nodeCreator } = toRefs(state);
|
const { nodeCreator } = toRefs(state);
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
unBindOnMouseUpOutside();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style module lang="scss">
|
<style module lang="scss">
|
||||||
|
|
|
@ -16,6 +16,7 @@ import { acceptCompletion, autocompletion, ifNotIn } from '@codemirror/autocompl
|
||||||
import { indentWithTab, history, redo, toggleComment } from '@codemirror/commands';
|
import { indentWithTab, history, redo, toggleComment } from '@codemirror/commands';
|
||||||
import { bracketMatching, foldGutter, indentOnInput, LanguageSupport } from '@codemirror/language';
|
import { bracketMatching, foldGutter, indentOnInput, LanguageSupport } from '@codemirror/language';
|
||||||
import { EditorState } from '@codemirror/state';
|
import { EditorState } from '@codemirror/state';
|
||||||
|
import type { Line } from '@codemirror/state';
|
||||||
import type { Extension } from '@codemirror/state';
|
import type { Extension } from '@codemirror/state';
|
||||||
import {
|
import {
|
||||||
dropCursor,
|
dropCursor,
|
||||||
|
@ -192,18 +193,29 @@ export default defineComponent({
|
||||||
onBlur() {
|
onBlur() {
|
||||||
this.isFocused = false;
|
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 (!this.editor) return;
|
||||||
|
|
||||||
if (line === 'final') {
|
if (lineNumber === 'final') {
|
||||||
this.editor.dispatch({
|
this.editor.dispatch({
|
||||||
selection: { anchor: this.modelValue.length },
|
selection: { anchor: this.modelValue.length },
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const line = this.line(lineNumber);
|
||||||
|
|
||||||
|
if (!line) return;
|
||||||
|
|
||||||
this.editor.dispatch({
|
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
|
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
|
||||||
if (operation === 'search') {
|
if (operation === 'search') {
|
||||||
const bucketName = this.getNodeParameter('bucketName', i) as string;
|
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 returnAll = this.getNodeParameter('returnAll', 0);
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', 0);
|
const additionalFields = this.getNodeParameter('additionalFields', 0);
|
||||||
|
|
||||||
|
@ -243,8 +245,7 @@ export class AwsS3V2 implements INodeType {
|
||||||
}
|
}
|
||||||
|
|
||||||
qs['list-type'] = 2;
|
qs['list-type'] = 2;
|
||||||
|
responseData = await awsApiRequestREST.call(this, servicePath, 'GET', basePath, '', {
|
||||||
responseData = await awsApiRequestREST.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
|
||||||
location: '',
|
location: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -254,9 +255,9 @@ export class AwsS3V2 implements INodeType {
|
||||||
responseData = await awsApiRequestRESTAllItems.call(
|
responseData = await awsApiRequestRESTAllItems.call(
|
||||||
this,
|
this,
|
||||||
'ListBucketResult.Contents',
|
'ListBucketResult.Contents',
|
||||||
`${bucketName}.s3`,
|
servicePath,
|
||||||
'GET',
|
'GET',
|
||||||
'',
|
basePath,
|
||||||
'',
|
'',
|
||||||
qs,
|
qs,
|
||||||
{},
|
{},
|
||||||
|
@ -267,9 +268,9 @@ export class AwsS3V2 implements INodeType {
|
||||||
qs['max-keys'] = this.getNodeParameter('limit', 0);
|
qs['max-keys'] = this.getNodeParameter('limit', 0);
|
||||||
responseData = await awsApiRequestREST.call(
|
responseData = await awsApiRequestREST.call(
|
||||||
this,
|
this,
|
||||||
`${bucketName}.s3`,
|
servicePath,
|
||||||
'GET',
|
'GET',
|
||||||
'',
|
basePath,
|
||||||
'',
|
'',
|
||||||
qs,
|
qs,
|
||||||
{},
|
{},
|
||||||
|
@ -282,6 +283,7 @@ export class AwsS3V2 implements INodeType {
|
||||||
this.helpers.returnJsonArray(responseData as IDataObject[]),
|
this.helpers.returnJsonArray(responseData as IDataObject[]),
|
||||||
{ itemData: { item: i } },
|
{ itemData: { item: i } },
|
||||||
);
|
);
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||||
returnData.push(...executionData);
|
returnData.push(...executionData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -289,9 +291,11 @@ export class AwsS3V2 implements INodeType {
|
||||||
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html
|
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html
|
||||||
if (operation === 'create') {
|
if (operation === 'create') {
|
||||||
const bucketName = this.getNodeParameter('bucketName', i) as string;
|
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 folderName = this.getNodeParameter('folderName', i) as string;
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||||
let path = `/${folderName}/`;
|
let path = `${basePath}/${folderName}/`;
|
||||||
|
|
||||||
if (additionalFields.requesterPays) {
|
if (additionalFields.requesterPays) {
|
||||||
headers['x-amz-request-payer'] = 'requester';
|
headers['x-amz-request-payer'] = 'requester';
|
||||||
|
@ -304,7 +308,7 @@ export class AwsS3V2 implements INodeType {
|
||||||
additionalFields.storageClass as string,
|
additionalFields.storageClass as string,
|
||||||
).toUpperCase();
|
).toUpperCase();
|
||||||
}
|
}
|
||||||
responseData = await awsApiRequestREST.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
responseData = await awsApiRequestREST.call(this, servicePath, 'GET', basePath, '', {
|
||||||
location: '',
|
location: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -312,7 +316,7 @@ export class AwsS3V2 implements INodeType {
|
||||||
|
|
||||||
responseData = await awsApiRequestREST.call(
|
responseData = await awsApiRequestREST.call(
|
||||||
this,
|
this,
|
||||||
`${bucketName}.s3`,
|
servicePath,
|
||||||
'PUT',
|
'PUT',
|
||||||
path,
|
path,
|
||||||
'',
|
'',
|
||||||
|
@ -330,9 +334,11 @@ export class AwsS3V2 implements INodeType {
|
||||||
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html
|
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html
|
||||||
if (operation === 'delete') {
|
if (operation === 'delete') {
|
||||||
const bucketName = this.getNodeParameter('bucketName', i) as string;
|
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;
|
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: '',
|
location: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -341,9 +347,9 @@ export class AwsS3V2 implements INodeType {
|
||||||
responseData = await awsApiRequestRESTAllItems.call(
|
responseData = await awsApiRequestRESTAllItems.call(
|
||||||
this,
|
this,
|
||||||
'ListBucketResult.Contents',
|
'ListBucketResult.Contents',
|
||||||
`${bucketName}.s3`,
|
servicePath,
|
||||||
'GET',
|
'GET',
|
||||||
'/',
|
basePath,
|
||||||
'',
|
'',
|
||||||
{ 'list-type': 2, prefix: folderKey },
|
{ 'list-type': 2, prefix: folderKey },
|
||||||
{},
|
{},
|
||||||
|
@ -355,9 +361,9 @@ export class AwsS3V2 implements INodeType {
|
||||||
if (responseData.length === 0) {
|
if (responseData.length === 0) {
|
||||||
responseData = await awsApiRequestREST.call(
|
responseData = await awsApiRequestREST.call(
|
||||||
this,
|
this,
|
||||||
`${bucketName}.s3`,
|
servicePath,
|
||||||
'DELETE',
|
'DELETE',
|
||||||
`/${folderKey}`,
|
`${basePath}/${folderKey}`,
|
||||||
'',
|
'',
|
||||||
qs,
|
qs,
|
||||||
{},
|
{},
|
||||||
|
@ -393,9 +399,9 @@ export class AwsS3V2 implements INodeType {
|
||||||
|
|
||||||
responseData = await awsApiRequestREST.call(
|
responseData = await awsApiRequestREST.call(
|
||||||
this,
|
this,
|
||||||
`${bucketName}.s3`,
|
servicePath,
|
||||||
'POST',
|
'POST',
|
||||||
'/',
|
`${basePath}/`,
|
||||||
data,
|
data,
|
||||||
{ delete: '' },
|
{ delete: '' },
|
||||||
headers,
|
headers,
|
||||||
|
@ -414,6 +420,8 @@ export class AwsS3V2 implements INodeType {
|
||||||
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
|
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
|
||||||
if (operation === 'getAll') {
|
if (operation === 'getAll') {
|
||||||
const bucketName = this.getNodeParameter('bucketName', i) as string;
|
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 returnAll = this.getNodeParameter('returnAll', 0);
|
||||||
const options = this.getNodeParameter('options', 0);
|
const options = this.getNodeParameter('options', 0);
|
||||||
|
|
||||||
|
@ -427,7 +435,7 @@ export class AwsS3V2 implements INodeType {
|
||||||
|
|
||||||
qs['list-type'] = 2;
|
qs['list-type'] = 2;
|
||||||
|
|
||||||
responseData = await awsApiRequestREST.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
responseData = await awsApiRequestREST.call(this, servicePath, 'GET', basePath, '', {
|
||||||
location: '',
|
location: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -437,9 +445,9 @@ export class AwsS3V2 implements INodeType {
|
||||||
responseData = await awsApiRequestRESTAllItems.call(
|
responseData = await awsApiRequestRESTAllItems.call(
|
||||||
this,
|
this,
|
||||||
'ListBucketResult.Contents',
|
'ListBucketResult.Contents',
|
||||||
`${bucketName}.s3`,
|
servicePath,
|
||||||
'GET',
|
'GET',
|
||||||
'',
|
basePath,
|
||||||
'',
|
'',
|
||||||
qs,
|
qs,
|
||||||
{},
|
{},
|
||||||
|
@ -451,9 +459,9 @@ export class AwsS3V2 implements INodeType {
|
||||||
responseData = await awsApiRequestRESTAllItems.call(
|
responseData = await awsApiRequestRESTAllItems.call(
|
||||||
this,
|
this,
|
||||||
'ListBucketResult.Contents',
|
'ListBucketResult.Contents',
|
||||||
`${bucketName}.s3`,
|
servicePath,
|
||||||
'GET',
|
'GET',
|
||||||
'',
|
basePath,
|
||||||
'',
|
'',
|
||||||
qs,
|
qs,
|
||||||
{},
|
{},
|
||||||
|
@ -561,10 +569,12 @@ export class AwsS3V2 implements INodeType {
|
||||||
const destinationParts = destinationPath.split('/');
|
const destinationParts = destinationPath.split('/');
|
||||||
|
|
||||||
const bucketName = destinationParts[1];
|
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: '',
|
location: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -572,7 +582,7 @@ export class AwsS3V2 implements INodeType {
|
||||||
|
|
||||||
responseData = await awsApiRequestREST.call(
|
responseData = await awsApiRequestREST.call(
|
||||||
this,
|
this,
|
||||||
`${bucketName}.s3`,
|
servicePath,
|
||||||
'PUT',
|
'PUT',
|
||||||
destination,
|
destination,
|
||||||
'',
|
'',
|
||||||
|
@ -590,6 +600,8 @@ export class AwsS3V2 implements INodeType {
|
||||||
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html
|
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html
|
||||||
if (operation === 'download') {
|
if (operation === 'download') {
|
||||||
const bucketName = this.getNodeParameter('bucketName', i) as string;
|
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;
|
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: '',
|
location: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -610,9 +622,9 @@ export class AwsS3V2 implements INodeType {
|
||||||
|
|
||||||
const response = await awsApiRequestREST.call(
|
const response = await awsApiRequestREST.call(
|
||||||
this,
|
this,
|
||||||
`${bucketName}.s3`,
|
servicePath,
|
||||||
'GET',
|
'GET',
|
||||||
`/${fileKey}`,
|
`${basePath}/${fileKey}`,
|
||||||
'',
|
'',
|
||||||
qs,
|
qs,
|
||||||
{},
|
{},
|
||||||
|
@ -652,6 +664,8 @@ export class AwsS3V2 implements INodeType {
|
||||||
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html
|
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html
|
||||||
if (operation === 'delete') {
|
if (operation === 'delete') {
|
||||||
const bucketName = this.getNodeParameter('bucketName', i) as string;
|
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;
|
const fileKey = this.getNodeParameter('fileKey', i) as string;
|
||||||
|
|
||||||
|
@ -661,7 +675,7 @@ export class AwsS3V2 implements INodeType {
|
||||||
qs.versionId = options.versionId as string;
|
qs.versionId = options.versionId as string;
|
||||||
}
|
}
|
||||||
|
|
||||||
responseData = await awsApiRequestREST.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
responseData = await awsApiRequestREST.call(this, servicePath, 'GET', basePath, '', {
|
||||||
location: '',
|
location: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -669,9 +683,9 @@ export class AwsS3V2 implements INodeType {
|
||||||
|
|
||||||
responseData = await awsApiRequestREST.call(
|
responseData = await awsApiRequestREST.call(
|
||||||
this,
|
this,
|
||||||
`${bucketName}.s3`,
|
servicePath,
|
||||||
'DELETE',
|
'DELETE',
|
||||||
`/${fileKey}`,
|
`${basePath}/${fileKey}`,
|
||||||
'',
|
'',
|
||||||
qs,
|
qs,
|
||||||
{},
|
{},
|
||||||
|
@ -687,6 +701,8 @@ export class AwsS3V2 implements INodeType {
|
||||||
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
|
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
|
||||||
if (operation === 'getAll') {
|
if (operation === 'getAll') {
|
||||||
const bucketName = this.getNodeParameter('bucketName', i) as string;
|
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 returnAll = this.getNodeParameter('returnAll', 0);
|
||||||
const options = this.getNodeParameter('options', 0);
|
const options = this.getNodeParameter('options', 0);
|
||||||
|
|
||||||
|
@ -702,7 +718,7 @@ export class AwsS3V2 implements INodeType {
|
||||||
|
|
||||||
qs['list-type'] = 2;
|
qs['list-type'] = 2;
|
||||||
|
|
||||||
responseData = await awsApiRequestREST.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
responseData = await awsApiRequestREST.call(this, servicePath, 'GET', basePath, '', {
|
||||||
location: '',
|
location: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -712,9 +728,9 @@ export class AwsS3V2 implements INodeType {
|
||||||
responseData = await awsApiRequestRESTAllItems.call(
|
responseData = await awsApiRequestRESTAllItems.call(
|
||||||
this,
|
this,
|
||||||
'ListBucketResult.Contents',
|
'ListBucketResult.Contents',
|
||||||
`${bucketName}.s3`,
|
servicePath,
|
||||||
'GET',
|
'GET',
|
||||||
'',
|
basePath,
|
||||||
'',
|
'',
|
||||||
qs,
|
qs,
|
||||||
{},
|
{},
|
||||||
|
@ -726,9 +742,9 @@ export class AwsS3V2 implements INodeType {
|
||||||
responseData = await awsApiRequestRESTAllItems.call(
|
responseData = await awsApiRequestRESTAllItems.call(
|
||||||
this,
|
this,
|
||||||
'ListBucketResult.Contents',
|
'ListBucketResult.Contents',
|
||||||
`${bucketName}.s3`,
|
servicePath,
|
||||||
'GET',
|
'GET',
|
||||||
'',
|
basePath,
|
||||||
'',
|
'',
|
||||||
qs,
|
qs,
|
||||||
{},
|
{},
|
||||||
|
@ -754,12 +770,14 @@ export class AwsS3V2 implements INodeType {
|
||||||
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html
|
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html
|
||||||
if (operation === 'upload') {
|
if (operation === 'upload') {
|
||||||
const bucketName = this.getNodeParameter('bucketName', i) as string;
|
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 fileName = this.getNodeParameter('fileName', i) as string;
|
||||||
const isBinaryData = this.getNodeParameter('binaryData', i);
|
const isBinaryData = this.getNodeParameter('binaryData', i);
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||||
const tagsValues = (this.getNodeParameter('tagsUi', i) as IDataObject)
|
const tagsValues = (this.getNodeParameter('tagsUi', i) as IDataObject)
|
||||||
.tagsValues as IDataObject[];
|
.tagsValues as IDataObject[];
|
||||||
let path = '';
|
let path = `${basePath}/`;
|
||||||
let body;
|
let body;
|
||||||
|
|
||||||
const multipartHeaders: IDataObject = {};
|
const multipartHeaders: IDataObject = {};
|
||||||
|
@ -839,7 +857,7 @@ export class AwsS3V2 implements INodeType {
|
||||||
multipartHeaders['x-amz-tagging'] = tags.join('&');
|
multipartHeaders['x-amz-tagging'] = tags.join('&');
|
||||||
}
|
}
|
||||||
// Get the region of the bucket
|
// Get the region of the bucket
|
||||||
responseData = await awsApiRequestREST.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
responseData = await awsApiRequestREST.call(this, servicePath, 'GET', basePath, '', {
|
||||||
location: '',
|
location: '',
|
||||||
});
|
});
|
||||||
const region = responseData.LocationConstraint._;
|
const region = responseData.LocationConstraint._;
|
||||||
|
@ -853,7 +871,7 @@ export class AwsS3V2 implements INodeType {
|
||||||
uploadData = this.helpers.getBinaryStream(binaryPropertyData.id, UPLOAD_CHUNK_SIZE);
|
uploadData = this.helpers.getBinaryStream(binaryPropertyData.id, UPLOAD_CHUNK_SIZE);
|
||||||
const createMultiPartUpload = await awsApiRequestREST.call(
|
const createMultiPartUpload = await awsApiRequestREST.call(
|
||||||
this,
|
this,
|
||||||
`${bucketName}.s3`,
|
servicePath,
|
||||||
'POST',
|
'POST',
|
||||||
`/${path}?uploads`,
|
`/${path}?uploads`,
|
||||||
body,
|
body,
|
||||||
|
@ -875,7 +893,7 @@ export class AwsS3V2 implements INodeType {
|
||||||
try {
|
try {
|
||||||
await awsApiRequestREST.call(
|
await awsApiRequestREST.call(
|
||||||
this,
|
this,
|
||||||
`${bucketName}.s3`,
|
servicePath,
|
||||||
'PUT',
|
'PUT',
|
||||||
`/${path}?partNumber=${part}&uploadId=${uploadId}`,
|
`/${path}?partNumber=${part}&uploadId=${uploadId}`,
|
||||||
chunk,
|
chunk,
|
||||||
|
@ -889,7 +907,7 @@ export class AwsS3V2 implements INodeType {
|
||||||
try {
|
try {
|
||||||
await awsApiRequestREST.call(
|
await awsApiRequestREST.call(
|
||||||
this,
|
this,
|
||||||
`${bucketName}.s3`,
|
servicePath,
|
||||||
'DELETE',
|
'DELETE',
|
||||||
`/${path}?uploadId=${uploadId}`,
|
`/${path}?uploadId=${uploadId}`,
|
||||||
);
|
);
|
||||||
|
@ -902,7 +920,7 @@ export class AwsS3V2 implements INodeType {
|
||||||
|
|
||||||
const listParts = (await awsApiRequestREST.call(
|
const listParts = (await awsApiRequestREST.call(
|
||||||
this,
|
this,
|
||||||
`${bucketName}.s3`,
|
servicePath,
|
||||||
'GET',
|
'GET',
|
||||||
`/${path}?max-parts=${900}&part-number-marker=0&uploadId=${uploadId}`,
|
`/${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 data = builder.buildObject(body);
|
||||||
const completeUpload = (await awsApiRequestREST.call(
|
const completeUpload = (await awsApiRequestREST.call(
|
||||||
this,
|
this,
|
||||||
`${bucketName}.s3`,
|
servicePath,
|
||||||
'POST',
|
'POST',
|
||||||
`/${path}?uploadId=${uploadId}`,
|
`/${path}?uploadId=${uploadId}`,
|
||||||
data,
|
data,
|
||||||
|
@ -991,7 +1009,7 @@ export class AwsS3V2 implements INodeType {
|
||||||
|
|
||||||
responseData = await awsApiRequestREST.call(
|
responseData = await awsApiRequestREST.call(
|
||||||
this,
|
this,
|
||||||
`${bucketName}.s3`,
|
servicePath,
|
||||||
'PUT',
|
'PUT',
|
||||||
`/${path || binaryPropertyData.fileName}`,
|
`/${path || binaryPropertyData.fileName}`,
|
||||||
body,
|
body,
|
||||||
|
@ -1019,7 +1037,7 @@ export class AwsS3V2 implements INodeType {
|
||||||
|
|
||||||
responseData = await awsApiRequestREST.call(
|
responseData = await awsApiRequestREST.call(
|
||||||
this,
|
this,
|
||||||
`${bucketName}.s3`,
|
servicePath,
|
||||||
'PUT',
|
'PUT',
|
||||||
`/${path}`,
|
`/${path}`,
|
||||||
body,
|
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
|
// job:getMetadata
|
||||||
|
@ -161,7 +176,8 @@ export class Rundeck implements INodeType {
|
||||||
const jobid = this.getNodeParameter('jobid', i) as string;
|
const jobid = this.getNodeParameter('jobid', i) as string;
|
||||||
const rundeckArguments = (this.getNodeParameter('arguments', i) as IDataObject)
|
const rundeckArguments = (this.getNodeParameter('arguments', i) as IDataObject)
|
||||||
.arguments 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);
|
returnData.push(response);
|
||||||
} else if (operation === 'getMetadata') {
|
} else if (operation === 'getMetadata') {
|
||||||
|
|
|
@ -49,7 +49,7 @@ export class RundeckApi {
|
||||||
this.credentials = credentials as unknown as RundeckCredentials;
|
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 = '';
|
let params = '';
|
||||||
|
|
||||||
if (args) {
|
if (args) {
|
||||||
|
@ -62,7 +62,12 @@ export class RundeckApi {
|
||||||
argString: params,
|
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> {
|
async getJobMetadata(jobId: string): Promise<IDataObject> {
|
||||||
|
|
Loading…
Reference in a new issue