first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,176 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import * as create from './create.operation';
|
||||
import * as del from './delete.operation';
|
||||
import * as get from './get.operation';
|
||||
import * as getAll from './getAll.operation';
|
||||
import * as query from './query.operation';
|
||||
import * as update from './update.operation';
|
||||
import { HeaderConstants } from '../../helpers/constants';
|
||||
import { handleError } from '../../helpers/errorHandler';
|
||||
import { simplifyData, validatePartitionKey } from '../../helpers/utils';
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['item'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a new item',
|
||||
routing: {
|
||||
send: {
|
||||
preSend: [validatePartitionKey],
|
||||
},
|
||||
request: {
|
||||
method: 'POST',
|
||||
url: '=/colls/{{ $parameter["container"] }}/docs',
|
||||
headers: {
|
||||
[HeaderConstants.X_MS_DOCUMENTDB_IS_UPSERT]: 'True',
|
||||
},
|
||||
},
|
||||
output: {
|
||||
postReceive: [handleError],
|
||||
},
|
||||
},
|
||||
action: 'Create item',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
description: 'Delete an existing item',
|
||||
routing: {
|
||||
send: {
|
||||
preSend: [validatePartitionKey],
|
||||
},
|
||||
request: {
|
||||
method: 'DELETE',
|
||||
url: '=/colls/{{ $parameter["container"] }}/docs/{{ $parameter["item"] }}',
|
||||
},
|
||||
output: {
|
||||
postReceive: [
|
||||
handleError,
|
||||
{
|
||||
type: 'set',
|
||||
properties: {
|
||||
value: '={{ { "deleted": true } }}',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
action: 'Delete item',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Retrieve an item',
|
||||
routing: {
|
||||
send: {
|
||||
preSend: [validatePartitionKey],
|
||||
},
|
||||
request: {
|
||||
method: 'GET',
|
||||
url: '=/colls/{{ $parameter["container"]}}/docs/{{$parameter["item"]}}',
|
||||
headers: {
|
||||
[HeaderConstants.X_MS_DOCUMENTDB_IS_UPSERT]: 'True',
|
||||
},
|
||||
},
|
||||
output: {
|
||||
postReceive: [handleError, simplifyData],
|
||||
},
|
||||
},
|
||||
action: 'Get item',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Retrieve a list of items',
|
||||
routing: {
|
||||
request: {
|
||||
method: 'GET',
|
||||
url: '=/colls/{{ $parameter["container"] }}/docs',
|
||||
},
|
||||
output: {
|
||||
postReceive: [
|
||||
handleError,
|
||||
{
|
||||
type: 'rootProperty',
|
||||
properties: {
|
||||
property: 'Documents',
|
||||
},
|
||||
},
|
||||
simplifyData,
|
||||
],
|
||||
},
|
||||
},
|
||||
action: 'Get many items',
|
||||
},
|
||||
{
|
||||
name: 'Execute Query',
|
||||
value: 'query',
|
||||
routing: {
|
||||
request: {
|
||||
method: 'POST',
|
||||
url: '=/colls/{{ $parameter["container"] }}/docs',
|
||||
headers: {
|
||||
'Content-Type': 'application/query+json',
|
||||
'x-ms-documentdb-isquery': 'True',
|
||||
'x-ms-documentdb-query-enablecrosspartition': 'True',
|
||||
},
|
||||
},
|
||||
output: {
|
||||
postReceive: [
|
||||
handleError,
|
||||
{
|
||||
type: 'rootProperty',
|
||||
properties: {
|
||||
property: 'Documents',
|
||||
},
|
||||
},
|
||||
simplifyData,
|
||||
],
|
||||
},
|
||||
},
|
||||
action: 'Query items',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update an existing item',
|
||||
routing: {
|
||||
send: {
|
||||
preSend: [validatePartitionKey],
|
||||
},
|
||||
request: {
|
||||
method: 'PUT',
|
||||
url: '=/colls/{{ $parameter["container"] }}/docs/{{ $parameter["item"] }}',
|
||||
headers: {
|
||||
'Content-Type': 'application/json-patch+json',
|
||||
},
|
||||
},
|
||||
output: {
|
||||
postReceive: [handleError],
|
||||
},
|
||||
},
|
||||
action: 'Update item',
|
||||
},
|
||||
],
|
||||
default: 'getAll',
|
||||
},
|
||||
|
||||
...create.description,
|
||||
...del.description,
|
||||
...get.description,
|
||||
...getAll.description,
|
||||
...query.description,
|
||||
...update.description,
|
||||
];
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
import type {
|
||||
IDataObject,
|
||||
IExecuteSingleFunctions,
|
||||
IHttpRequestOptions,
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { updateDisplayOptions } from 'n8n-workflow';
|
||||
|
||||
import { processJsonInput, untilContainerSelected } from '../../helpers/utils';
|
||||
import { containerResourceLocator } from '../common';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
{ ...containerResourceLocator, description: 'Select the container you want to use' },
|
||||
{
|
||||
displayName: 'Item Contents',
|
||||
name: 'customProperties',
|
||||
default: '{\n\t"id": "replace_with_new_document_id"\n}',
|
||||
description: 'The item contents as a JSON object',
|
||||
displayOptions: {
|
||||
hide: {
|
||||
...untilContainerSelected,
|
||||
},
|
||||
},
|
||||
hint: 'The item requires an ID and partition key value if a custom key is set',
|
||||
required: true,
|
||||
routing: {
|
||||
send: {
|
||||
preSend: [
|
||||
async function (
|
||||
this: IExecuteSingleFunctions,
|
||||
requestOptions: IHttpRequestOptions,
|
||||
): Promise<IHttpRequestOptions> {
|
||||
const rawCustomProperties = this.getNodeParameter('customProperties') as IDataObject;
|
||||
const customProperties = processJsonInput(
|
||||
rawCustomProperties,
|
||||
'Item Contents',
|
||||
undefined,
|
||||
['id'],
|
||||
);
|
||||
requestOptions.body = customProperties;
|
||||
return requestOptions;
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
type: 'json',
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['item'],
|
||||
operation: ['create'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
import { updateDisplayOptions, type INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { untilContainerSelected, untilItemSelected } from '../../helpers/utils';
|
||||
import { containerResourceLocator, itemResourceLocator } from '../common';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
{ ...containerResourceLocator, description: 'Select the container you want to use' },
|
||||
{ ...itemResourceLocator, description: 'Select the item to be deleted' },
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
hide: {
|
||||
...untilContainerSelected,
|
||||
...untilItemSelected,
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Partition Key',
|
||||
name: 'partitionKey',
|
||||
default: '',
|
||||
hint: 'Only required if a custom partition key is set for the container',
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
placeholder: 'Add Partition Key',
|
||||
type: 'collection',
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['item'],
|
||||
operation: ['delete'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
@@ -0,0 +1,53 @@
|
||||
import { updateDisplayOptions, type INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { untilContainerSelected, untilItemSelected } from '../../helpers/utils';
|
||||
import { containerResourceLocator, itemResourceLocator } from '../common';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
{ ...containerResourceLocator, description: 'Select the container you want to use' },
|
||||
{ ...itemResourceLocator, description: 'Select the item you want to retrieve' },
|
||||
{
|
||||
displayName: 'Simplify',
|
||||
name: 'simple',
|
||||
default: true,
|
||||
description: 'Whether to return a simplified version of the response instead of the raw data',
|
||||
displayOptions: {
|
||||
hide: {
|
||||
...untilContainerSelected,
|
||||
...untilItemSelected,
|
||||
},
|
||||
},
|
||||
type: 'boolean',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
hide: {
|
||||
...untilContainerSelected,
|
||||
...untilItemSelected,
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Partition Key',
|
||||
name: 'partitionKey',
|
||||
default: '',
|
||||
hint: 'Only required if a custom partition key is set for the container',
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
placeholder: 'Add Partition Key',
|
||||
type: 'collection',
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['item'],
|
||||
operation: ['get'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
import { updateDisplayOptions, type INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { containerResourceLocator, paginationParameters } from '../common';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
{ ...containerResourceLocator, description: 'Select the container you want to use' },
|
||||
...paginationParameters,
|
||||
{
|
||||
displayName: 'Simplify',
|
||||
name: 'simple',
|
||||
default: true,
|
||||
description: 'Whether to return a simplified version of the response instead of the raw data',
|
||||
type: 'boolean',
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['item'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
import { updateDisplayOptions, type INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { validateQueryParameters } from '../../helpers/utils';
|
||||
import { containerResourceLocator } from '../common';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
{ ...containerResourceLocator, description: 'Select the container you want to use' },
|
||||
{
|
||||
displayName: 'Query',
|
||||
name: 'query',
|
||||
default: '',
|
||||
description:
|
||||
"The SQL query to execute. Use $1, $2, $3, etc., to reference the 'Query Parameters' set in the options below.",
|
||||
hint: 'Consider using query parameters to prevent SQL injection attacks. Add them in the options below.',
|
||||
noDataExpression: true,
|
||||
placeholder: 'e.g. SELECT id, name FROM c WHERE c.name = $1',
|
||||
required: true,
|
||||
routing: {
|
||||
send: {
|
||||
type: 'body',
|
||||
property: 'query',
|
||||
value: "={{ $value.replace(/\\$(\\d+)/g, '@Param$1') }}",
|
||||
},
|
||||
},
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
editor: 'sqlEditor',
|
||||
sqlDialect: 'StandardSQL',
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Simplify',
|
||||
name: 'simple',
|
||||
default: true,
|
||||
description: 'Whether to return a simplified version of the response instead of the raw data',
|
||||
type: 'boolean',
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Query Options',
|
||||
name: 'queryOptions',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Query Parameters',
|
||||
name: 'queryParameters',
|
||||
default: '',
|
||||
description:
|
||||
'Comma-separated list of values used as query parameters. Use $1, $2, $3, etc., in your query.',
|
||||
hint: 'Reference them in your query as $1, $2, $3…',
|
||||
placeholder: 'e.g. value1,value2,value3',
|
||||
routing: {
|
||||
send: {
|
||||
preSend: [validateQueryParameters],
|
||||
},
|
||||
},
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
placeholder: 'Add options',
|
||||
type: 'fixedCollection',
|
||||
typeOptions: {
|
||||
multipleValues: false,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['item'],
|
||||
operation: ['query'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
import { updateDisplayOptions } from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
untilContainerSelected,
|
||||
untilItemSelected,
|
||||
validateCustomProperties,
|
||||
} from '../../helpers/utils';
|
||||
import { containerResourceLocator, itemResourceLocator } from '../common';
|
||||
|
||||
const properties: INodeProperties[] = [
|
||||
{ ...containerResourceLocator, description: 'Select the container you want to use' },
|
||||
{ ...itemResourceLocator, description: 'Select the item to be updated' },
|
||||
{
|
||||
displayName: 'Item Contents',
|
||||
name: 'customProperties',
|
||||
default: '{}',
|
||||
description: 'The item contents as a JSON object',
|
||||
displayOptions: {
|
||||
hide: {
|
||||
...untilContainerSelected,
|
||||
...untilItemSelected,
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
routing: {
|
||||
send: {
|
||||
preSend: [validateCustomProperties],
|
||||
},
|
||||
},
|
||||
type: 'json',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
hide: {
|
||||
...untilContainerSelected,
|
||||
...untilItemSelected,
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Partition Key',
|
||||
name: 'partitionKey',
|
||||
type: 'string',
|
||||
hint: 'Only required if a custom partition key is set for the container',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
placeholder: 'Add Partition Key',
|
||||
type: 'collection',
|
||||
},
|
||||
];
|
||||
|
||||
const displayOptions = {
|
||||
show: {
|
||||
resource: ['item'],
|
||||
operation: ['update'],
|
||||
},
|
||||
};
|
||||
|
||||
export const description = updateDisplayOptions(displayOptions, properties);
|
||||
Reference in New Issue
Block a user