n8n-nodes-base 1.86.1 → 1.87.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/credentials/HttpBearerAuth.credentials.js +63 -0
- package/dist/credentials/HttpBearerAuth.credentials.js.map +1 -0
- package/dist/credentials/MicrosoftAzureCosmosDbSharedKeyApi.credentials.js +109 -0
- package/dist/credentials/MicrosoftAzureCosmosDbSharedKeyApi.credentials.js.map +1 -0
- package/dist/known/credentials.json +11 -0
- package/dist/known/nodes.json +4 -0
- package/dist/nodes/EmailReadImap/v2/utils.js +4 -1
- package/dist/nodes/EmailReadImap/v2/utils.js.map +1 -1
- package/dist/nodes/Form/Form.node.js +2 -2
- package/dist/nodes/Form/Form.node.js.map +1 -1
- package/dist/nodes/Form/v2/FormTriggerV2.node.js +2 -2
- package/dist/nodes/Form/v2/FormTriggerV2.node.js.map +1 -1
- package/dist/nodes/Microsoft/AzureCosmosDb/AzureCosmosDb.node.js +87 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/AzureCosmosDb.node.js.map +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/AzureCosmosDb.node.json +18 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/AzureCosmosDb.svg +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/common.js +163 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/common.js.map +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/container/Container.resource.js +141 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/container/Container.resource.js.map +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/container/create.operation.js +166 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/container/create.operation.js.map +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/container/delete.operation.js +40 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/container/delete.operation.js.map +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/container/get.operation.js +47 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/container/get.operation.js.map +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/container/getAll.operation.js +47 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/container/getAll.operation.js.map +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/index.js +42 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/index.js.map +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/item/Item.resource.js +210 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/item/Item.resource.js.map +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/item/create.operation.js +72 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/item/create.operation.js.map +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/item/delete.operation.js +64 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/item/delete.operation.js.map +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/item/get.operation.js +77 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/item/get.operation.js.map +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/item/getAll.operation.js +48 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/item/getAll.operation.js.map +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/item/query.operation.js +102 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/item/query.operation.js.map +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/item/update.operation.js +83 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/descriptions/item/update.operation.js.map +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/helpers/constants.js +52 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/helpers/constants.js.map +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/helpers/errorHandler.js +108 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/helpers/errorHandler.js.map +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/helpers/interfaces.js +17 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/helpers/interfaces.js.map +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/helpers/utils.js +200 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/helpers/utils.js.map +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/methods/index.js +39 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/methods/index.js.map +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/methods/listSearch.js +75 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/methods/listSearch.js.map +1 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/transport/index.js +43 -0
- package/dist/nodes/Microsoft/AzureCosmosDb/transport/index.js.map +1 -0
- package/dist/nodes/Wait/Wait.node.js +2 -2
- package/dist/nodes/Wait/Wait.node.js.map +1 -1
- package/dist/nodes/Webhook/error.d.ts +8 -0
- package/dist/nodes/Webhook/utils.d.ts +32 -0
- package/dist/nodes/Webhook/utils.js +13 -0
- package/dist/nodes/Webhook/utils.js.map +1 -1
- package/dist/test/nodes/FakeCredentialsMap.js +6 -0
- package/dist/test/nodes/FakeCredentialsMap.js.map +1 -1
- package/dist/types/credentials.json +2 -0
- package/dist/types/nodes.json +6 -5
- package/package.json +9 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../nodes/Microsoft/AzureCosmosDb/descriptions/item/query.operation.ts"],"sourcesContent":["import { updateDisplayOptions, type INodeProperties } from 'n8n-workflow';\n\nimport { validateQueryParameters } from '../../helpers/utils';\nimport { containerResourceLocator } from '../common';\n\nconst properties: INodeProperties[] = [\n\t{ ...containerResourceLocator, description: 'Select the container you want to use' },\n\t{\n\t\tdisplayName: 'Query',\n\t\tname: 'query',\n\t\tdefault: '',\n\t\tdescription:\n\t\t\t\"The SQL query to execute. Use $1, $2, $3, etc., to reference the 'Query Parameters' set in the options below.\",\n\t\thint: 'Consider using query parameters to prevent SQL injection attacks. Add them in the options below.',\n\t\tnoDataExpression: true,\n\t\tplaceholder: 'e.g. SELECT id, name FROM c WHERE c.name = $1',\n\t\trequired: true,\n\t\trouting: {\n\t\t\tsend: {\n\t\t\t\ttype: 'body',\n\t\t\t\tproperty: 'query',\n\t\t\t\tvalue: \"={{ $value.replace(/\\\\$(\\\\d+)/g, '@Param$1') }}\",\n\t\t\t},\n\t\t},\n\t\ttype: 'string',\n\t\ttypeOptions: {\n\t\t\teditor: 'sqlEditor',\n\t\t\tsqlDialect: 'StandardSQL',\n\t\t},\n\t},\n\t{\n\t\tdisplayName: 'Simplify',\n\t\tname: 'simple',\n\t\tdefault: true,\n\t\tdescription: 'Whether to return a simplified version of the response instead of the raw data',\n\t\ttype: 'boolean',\n\t},\n\t{\n\t\tdisplayName: 'Options',\n\t\tname: 'options',\n\t\tdefault: {},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Query Options',\n\t\t\t\tname: 'queryOptions',\n\t\t\t\tvalues: [\n\t\t\t\t\t{\n\t\t\t\t\t\tdisplayName: 'Query Parameters',\n\t\t\t\t\t\tname: 'queryParameters',\n\t\t\t\t\t\tdefault: '',\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'Comma-separated list of values used as query parameters. Use $1, $2, $3, etc., in your query.',\n\t\t\t\t\t\thint: 'Reference them in your query as $1, $2, $3…',\n\t\t\t\t\t\tplaceholder: 'e.g. value1,value2,value3',\n\t\t\t\t\t\trouting: {\n\t\t\t\t\t\t\tsend: {\n\t\t\t\t\t\t\t\tpreSend: [validateQueryParameters],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttype: 'string',\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t],\n\t\tplaceholder: 'Add options',\n\t\ttype: 'fixedCollection',\n\t\ttypeOptions: {\n\t\t\tmultipleValues: false,\n\t\t},\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\tresource: ['item'],\n\t\toperation: ['query'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA2D;AAE3D,mBAAwC;AACxC,oBAAyC;AAEzC,MAAM,aAAgC;AAAA,EACrC,EAAE,GAAG,wCAA0B,aAAa,uCAAuC;AAAA,EACnF;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aACC;AAAA,IACD,MAAM;AAAA,IACN,kBAAkB;AAAA,IAClB,aAAa;AAAA,IACb,UAAU;AAAA,IACV,SAAS;AAAA,MACR,MAAM;AAAA,QACL,MAAM;AAAA,QACN,UAAU;AAAA,QACV,OAAO;AAAA,MACR;AAAA,IACD;AAAA,IACA,MAAM;AAAA,IACN,aAAa;AAAA,MACZ,QAAQ;AAAA,MACR,YAAY;AAAA,IACb;AAAA,EACD;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,IACb,MAAM;AAAA,EACP;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,SAAS,CAAC;AAAA,IACV,SAAS;AAAA,MACR;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,QAAQ;AAAA,UACP;AAAA,YACC,aAAa;AAAA,YACb,MAAM;AAAA,YACN,SAAS;AAAA,YACT,aACC;AAAA,YACD,MAAM;AAAA,YACN,aAAa;AAAA,YACb,SAAS;AAAA,cACR,MAAM;AAAA,gBACL,SAAS,CAAC,oCAAuB;AAAA,cAClC;AAAA,YACD;AAAA,YACA,MAAM;AAAA,UACP;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,IACA,aAAa;AAAA,IACb,MAAM;AAAA,IACN,aAAa;AAAA,MACZ,gBAAgB;AAAA,IACjB;AAAA,EACD;AACD;AAEA,MAAM,iBAAiB;AAAA,EACtB,MAAM;AAAA,IACL,UAAU,CAAC,MAAM;AAAA,IACjB,WAAW,CAAC,OAAO;AAAA,EACpB;AACD;AAEO,MAAM,kBAAc,0CAAqB,gBAAgB,UAAU;","names":[]}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var update_operation_exports = {};
|
|
20
|
+
__export(update_operation_exports, {
|
|
21
|
+
description: () => description
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(update_operation_exports);
|
|
24
|
+
var import_n8n_workflow = require("n8n-workflow");
|
|
25
|
+
var import_utils = require("../../helpers/utils");
|
|
26
|
+
var import_common = require("../common");
|
|
27
|
+
const properties = [
|
|
28
|
+
{ ...import_common.containerResourceLocator, description: "Select the container you want to use" },
|
|
29
|
+
{ ...import_common.itemResourceLocator, description: "Select the item to be updated" },
|
|
30
|
+
{
|
|
31
|
+
displayName: "Item Contents",
|
|
32
|
+
name: "customProperties",
|
|
33
|
+
default: "{}",
|
|
34
|
+
description: "The item contents as a JSON object",
|
|
35
|
+
displayOptions: {
|
|
36
|
+
hide: {
|
|
37
|
+
...import_utils.untilContainerSelected,
|
|
38
|
+
...import_utils.untilItemSelected
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
required: true,
|
|
42
|
+
routing: {
|
|
43
|
+
send: {
|
|
44
|
+
preSend: [import_utils.validateCustomProperties]
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
type: "json"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
displayName: "Additional Fields",
|
|
51
|
+
name: "additionalFields",
|
|
52
|
+
default: {},
|
|
53
|
+
displayOptions: {
|
|
54
|
+
hide: {
|
|
55
|
+
...import_utils.untilContainerSelected,
|
|
56
|
+
...import_utils.untilItemSelected
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
options: [
|
|
60
|
+
{
|
|
61
|
+
displayName: "Partition Key",
|
|
62
|
+
name: "partitionKey",
|
|
63
|
+
type: "string",
|
|
64
|
+
hint: "Only required if a custom partition key is set for the container",
|
|
65
|
+
default: ""
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
placeholder: "Add Partition Key",
|
|
69
|
+
type: "collection"
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
const displayOptions = {
|
|
73
|
+
show: {
|
|
74
|
+
resource: ["item"],
|
|
75
|
+
operation: ["update"]
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const description = (0, import_n8n_workflow.updateDisplayOptions)(displayOptions, properties);
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
description
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=update.operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../nodes/Microsoft/AzureCosmosDb/descriptions/item/update.operation.ts"],"sourcesContent":["import type { INodeProperties } from 'n8n-workflow';\nimport { updateDisplayOptions } from 'n8n-workflow';\n\nimport {\n\tuntilContainerSelected,\n\tuntilItemSelected,\n\tvalidateCustomProperties,\n} from '../../helpers/utils';\nimport { containerResourceLocator, itemResourceLocator } from '../common';\n\nconst properties: INodeProperties[] = [\n\t{ ...containerResourceLocator, description: 'Select the container you want to use' },\n\t{ ...itemResourceLocator, description: 'Select the item to be updated' },\n\t{\n\t\tdisplayName: 'Item Contents',\n\t\tname: 'customProperties',\n\t\tdefault: '{}',\n\t\tdescription: 'The item contents as a JSON object',\n\t\tdisplayOptions: {\n\t\t\thide: {\n\t\t\t\t...untilContainerSelected,\n\t\t\t\t...untilItemSelected,\n\t\t\t},\n\t\t},\n\t\trequired: true,\n\t\trouting: {\n\t\t\tsend: {\n\t\t\t\tpreSend: [validateCustomProperties],\n\t\t\t},\n\t\t},\n\t\ttype: 'json',\n\t},\n\t{\n\t\tdisplayName: 'Additional Fields',\n\t\tname: 'additionalFields',\n\t\tdefault: {},\n\t\tdisplayOptions: {\n\t\t\thide: {\n\t\t\t\t...untilContainerSelected,\n\t\t\t\t...untilItemSelected,\n\t\t\t},\n\t\t},\n\t\toptions: [\n\t\t\t{\n\t\t\t\tdisplayName: 'Partition Key',\n\t\t\t\tname: 'partitionKey',\n\t\t\t\ttype: 'string',\n\t\t\t\thint: 'Only required if a custom partition key is set for the container',\n\t\t\t\tdefault: '',\n\t\t\t},\n\t\t],\n\t\tplaceholder: 'Add Partition Key',\n\t\ttype: 'collection',\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\tresource: ['item'],\n\t\toperation: ['update'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAqC;AAErC,mBAIO;AACP,oBAA8D;AAE9D,MAAM,aAAgC;AAAA,EACrC,EAAE,GAAG,wCAA0B,aAAa,uCAAuC;AAAA,EACnF,EAAE,GAAG,mCAAqB,aAAa,gCAAgC;AAAA,EACvE;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aAAa;AAAA,IACb,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,GAAG;AAAA,QACH,GAAG;AAAA,MACJ;AAAA,IACD;AAAA,IACA,UAAU;AAAA,IACV,SAAS;AAAA,MACR,MAAM;AAAA,QACL,SAAS,CAAC,qCAAwB;AAAA,MACnC;AAAA,IACD;AAAA,IACA,MAAM;AAAA,EACP;AAAA,EACA;AAAA,IACC,aAAa;AAAA,IACb,MAAM;AAAA,IACN,SAAS,CAAC;AAAA,IACV,gBAAgB;AAAA,MACf,MAAM;AAAA,QACL,GAAG;AAAA,QACH,GAAG;AAAA,MACJ;AAAA,IACD;AAAA,IACA,SAAS;AAAA,MACR;AAAA,QACC,aAAa;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN,SAAS;AAAA,MACV;AAAA,IACD;AAAA,IACA,aAAa;AAAA,IACb,MAAM;AAAA,EACP;AACD;AAEA,MAAM,iBAAiB;AAAA,EACtB,MAAM;AAAA,IACL,UAAU,CAAC,MAAM;AAAA,IACjB,WAAW,CAAC,QAAQ;AAAA,EACrB;AACD;AAEO,MAAM,kBAAc,0CAAqB,gBAAgB,UAAU;","names":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var constants_exports = {};
|
|
20
|
+
__export(constants_exports, {
|
|
21
|
+
CURRENT_VERSION: () => CURRENT_VERSION,
|
|
22
|
+
HeaderConstants: () => HeaderConstants,
|
|
23
|
+
RESOURCE_TYPES: () => RESOURCE_TYPES
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(constants_exports);
|
|
26
|
+
const RESOURCE_TYPES = [
|
|
27
|
+
"dbs",
|
|
28
|
+
"colls",
|
|
29
|
+
"sprocs",
|
|
30
|
+
"udfs",
|
|
31
|
+
"triggers",
|
|
32
|
+
"users",
|
|
33
|
+
"permissions",
|
|
34
|
+
"docs"
|
|
35
|
+
];
|
|
36
|
+
const CURRENT_VERSION = "2018-12-31";
|
|
37
|
+
const HeaderConstants = {
|
|
38
|
+
AUTHORIZATION: "authorization",
|
|
39
|
+
X_MS_CONTINUATION: "x-ms-continuation",
|
|
40
|
+
X_MS_COSMOS_OFFER_AUTOPILOT_SETTING: "x-ms-cosmos-offer-autopilot-setting",
|
|
41
|
+
X_MS_DOCUMENTDB_IS_UPSERT: "x-ms-documentdb-is-upsert",
|
|
42
|
+
X_MS_DOCUMENTDB_PARTITIONKEY: "x-ms-documentdb-partitionkey",
|
|
43
|
+
X_MS_MAX_ITEM_COUNT: "x-ms-max-item-count",
|
|
44
|
+
X_MS_OFFER_THROUGHPUT: "x-ms-offer-throughput"
|
|
45
|
+
};
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
CURRENT_VERSION,
|
|
49
|
+
HeaderConstants,
|
|
50
|
+
RESOURCE_TYPES
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../nodes/Microsoft/AzureCosmosDb/helpers/constants.ts"],"sourcesContent":["export const RESOURCE_TYPES = [\n\t'dbs',\n\t'colls',\n\t'sprocs',\n\t'udfs',\n\t'triggers',\n\t'users',\n\t'permissions',\n\t'docs',\n];\n\nexport const CURRENT_VERSION = '2018-12-31';\n\nexport const HeaderConstants = {\n\tAUTHORIZATION: 'authorization',\n\tX_MS_CONTINUATION: 'x-ms-continuation',\n\tX_MS_COSMOS_OFFER_AUTOPILOT_SETTING: 'x-ms-cosmos-offer-autopilot-setting',\n\tX_MS_DOCUMENTDB_IS_UPSERT: 'x-ms-documentdb-is-upsert',\n\tX_MS_DOCUMENTDB_PARTITIONKEY: 'x-ms-documentdb-partitionkey',\n\tX_MS_MAX_ITEM_COUNT: 'x-ms-max-item-count',\n\tX_MS_OFFER_THROUGHPUT: 'x-ms-offer-throughput',\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,iBAAiB;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,MAAM,kBAAkB;AAExB,MAAM,kBAAkB;AAAA,EAC9B,eAAe;AAAA,EACf,mBAAmB;AAAA,EACnB,qCAAqC;AAAA,EACrC,2BAA2B;AAAA,EAC3B,8BAA8B;AAAA,EAC9B,qBAAqB;AAAA,EACrB,uBAAuB;AACxB;","names":[]}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var errorHandler_exports = {};
|
|
20
|
+
__export(errorHandler_exports, {
|
|
21
|
+
ErrorMap: () => ErrorMap,
|
|
22
|
+
handleError: () => handleError
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(errorHandler_exports);
|
|
25
|
+
var import_n8n_workflow = require("n8n-workflow");
|
|
26
|
+
const ErrorMap = {
|
|
27
|
+
Container: {
|
|
28
|
+
Conflict: {
|
|
29
|
+
getMessage: (id) => `Container "${id}" already exists.`,
|
|
30
|
+
description: "Use a unique value for 'ID' and try again."
|
|
31
|
+
},
|
|
32
|
+
NotFound: {
|
|
33
|
+
getMessage: (id) => `Container "${id}" was not found.`,
|
|
34
|
+
description: "Double-check the value in the parameter 'Container' and try again."
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
Item: {
|
|
38
|
+
NotFound: {
|
|
39
|
+
getMessage: (id) => `Item "${id}" was not found.`,
|
|
40
|
+
description: "Double-check the values in the parameter 'Item' and 'Partition Key' (if applicable) and try again."
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
async function handleError(data, response) {
|
|
45
|
+
if (String(response.statusCode).startsWith("4") || String(response.statusCode).startsWith("5")) {
|
|
46
|
+
const resource = this.getNodeParameter("resource");
|
|
47
|
+
const error = response.body;
|
|
48
|
+
let errorMessage = error.message;
|
|
49
|
+
let errorDetails = void 0;
|
|
50
|
+
if (resource === "container") {
|
|
51
|
+
if (error.code === "Conflict") {
|
|
52
|
+
const newContainerValue = this.getNodeParameter("containerCreate");
|
|
53
|
+
throw new import_n8n_workflow.NodeApiError(this.getNode(), error, {
|
|
54
|
+
message: ErrorMap.Container.Conflict.getMessage(newContainerValue ?? "Unknown"),
|
|
55
|
+
description: ErrorMap.Container.Conflict.description
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (error.code === "NotFound") {
|
|
59
|
+
const containerValue = this.getNodeParameter("container", void 0, {
|
|
60
|
+
extractValue: true
|
|
61
|
+
});
|
|
62
|
+
throw new import_n8n_workflow.NodeApiError(this.getNode(), error, {
|
|
63
|
+
message: ErrorMap.Container.NotFound.getMessage(containerValue ?? "Unknown"),
|
|
64
|
+
description: ErrorMap.Container.NotFound.description
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
} else if (resource === "item") {
|
|
68
|
+
if (error.code === "NotFound") {
|
|
69
|
+
const itemValue = this.getNodeParameter("item", void 0, {
|
|
70
|
+
extractValue: true
|
|
71
|
+
});
|
|
72
|
+
throw new import_n8n_workflow.NodeApiError(this.getNode(), error, {
|
|
73
|
+
message: ErrorMap.Item.NotFound.getMessage(itemValue ?? "Unknown"),
|
|
74
|
+
description: ErrorMap.Item.NotFound.description
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
errorMessage = (0, import_n8n_workflow.jsonParse)(errorMessage).message;
|
|
80
|
+
} catch {
|
|
81
|
+
}
|
|
82
|
+
const match = errorMessage.match(/Message: ({.*?})/);
|
|
83
|
+
if (match?.[1]) {
|
|
84
|
+
try {
|
|
85
|
+
errorDetails = (0, import_n8n_workflow.jsonParse)(match[1]).Errors;
|
|
86
|
+
} catch {
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (errorDetails && errorDetails.length > 0) {
|
|
90
|
+
throw new import_n8n_workflow.NodeApiError(this.getNode(), error, {
|
|
91
|
+
message: error.code,
|
|
92
|
+
description: errorDetails.join("\n")
|
|
93
|
+
});
|
|
94
|
+
} else {
|
|
95
|
+
throw new import_n8n_workflow.NodeApiError(this.getNode(), error, {
|
|
96
|
+
message: error.code,
|
|
97
|
+
description: error.message
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return data;
|
|
102
|
+
}
|
|
103
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
104
|
+
0 && (module.exports = {
|
|
105
|
+
ErrorMap,
|
|
106
|
+
handleError
|
|
107
|
+
});
|
|
108
|
+
//# sourceMappingURL=errorHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../nodes/Microsoft/AzureCosmosDb/helpers/errorHandler.ts"],"sourcesContent":["import type {\n\tIExecuteSingleFunctions,\n\tIN8nHttpFullResponse,\n\tINodeExecutionData,\n\tJsonObject,\n} from 'n8n-workflow';\nimport { jsonParse, NodeApiError } from 'n8n-workflow';\n\nimport type { IErrorResponse } from './interfaces';\n\nexport const ErrorMap = {\n\tContainer: {\n\t\tConflict: {\n\t\t\tgetMessage: (id: string) => `Container \"${id}\" already exists.`,\n\t\t\tdescription: \"Use a unique value for 'ID' and try again.\",\n\t\t},\n\t\tNotFound: {\n\t\t\tgetMessage: (id: string) => `Container \"${id}\" was not found.`,\n\t\t\tdescription: \"Double-check the value in the parameter 'Container' and try again.\",\n\t\t},\n\t},\n\tItem: {\n\t\tNotFound: {\n\t\t\tgetMessage: (id: string) => `Item \"${id}\" was not found.`,\n\t\t\tdescription:\n\t\t\t\t\"Double-check the values in the parameter 'Item' and 'Partition Key' (if applicable) and try again.\",\n\t\t},\n\t},\n};\n\nexport async function handleError(\n\tthis: IExecuteSingleFunctions,\n\tdata: INodeExecutionData[],\n\tresponse: IN8nHttpFullResponse,\n): Promise<INodeExecutionData[]> {\n\tif (String(response.statusCode).startsWith('4') || String(response.statusCode).startsWith('5')) {\n\t\tconst resource = this.getNodeParameter('resource') as string;\n\t\tconst error = response.body as IErrorResponse;\n\t\tlet errorMessage = error.message;\n\n\t\tlet errorDetails: string[] | undefined = undefined;\n\n\t\tif (resource === 'container') {\n\t\t\tif (error.code === 'Conflict') {\n\t\t\t\tconst newContainerValue = this.getNodeParameter('containerCreate') as string;\n\t\t\t\tthrow new NodeApiError(this.getNode(), error as unknown as JsonObject, {\n\t\t\t\t\tmessage: ErrorMap.Container.Conflict.getMessage(newContainerValue ?? 'Unknown'),\n\t\t\t\t\tdescription: ErrorMap.Container.Conflict.description,\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (error.code === 'NotFound') {\n\t\t\t\tconst containerValue = this.getNodeParameter('container', undefined, {\n\t\t\t\t\textractValue: true,\n\t\t\t\t}) as string;\n\t\t\t\tthrow new NodeApiError(this.getNode(), error as unknown as JsonObject, {\n\t\t\t\t\tmessage: ErrorMap.Container.NotFound.getMessage(containerValue ?? 'Unknown'),\n\t\t\t\t\tdescription: ErrorMap.Container.NotFound.description,\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (resource === 'item') {\n\t\t\tif (error.code === 'NotFound') {\n\t\t\t\tconst itemValue = this.getNodeParameter('item', undefined, {\n\t\t\t\t\textractValue: true,\n\t\t\t\t}) as string;\n\t\t\t\tthrow new NodeApiError(this.getNode(), error as unknown as JsonObject, {\n\t\t\t\t\tmessage: ErrorMap.Item.NotFound.getMessage(itemValue ?? 'Unknown'),\n\t\t\t\t\tdescription: ErrorMap.Item.NotFound.description,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\t// Certain error responses have nested Message\n\t\t\terrorMessage = jsonParse<{\n\t\t\t\tmessage: string;\n\t\t\t}>(errorMessage).message;\n\t\t} catch {}\n\n\t\tconst match = errorMessage.match(/Message: ({.*?})/);\n\t\tif (match?.[1]) {\n\t\t\ttry {\n\t\t\t\terrorDetails = jsonParse<{\n\t\t\t\t\tErrors: string[];\n\t\t\t\t}>(match[1]).Errors;\n\t\t\t} catch {}\n\t\t}\n\n\t\tif (errorDetails && errorDetails.length > 0) {\n\t\t\tthrow new NodeApiError(this.getNode(), error as unknown as JsonObject, {\n\t\t\t\tmessage: error.code,\n\t\t\t\tdescription: errorDetails.join('\\n'),\n\t\t\t});\n\t\t} else {\n\t\t\tthrow new NodeApiError(this.getNode(), error as unknown as JsonObject, {\n\t\t\t\tmessage: error.code,\n\t\t\t\tdescription: error.message,\n\t\t\t});\n\t\t}\n\t}\n\treturn data;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,0BAAwC;AAIjC,MAAM,WAAW;AAAA,EACvB,WAAW;AAAA,IACV,UAAU;AAAA,MACT,YAAY,CAAC,OAAe,cAAc,EAAE;AAAA,MAC5C,aAAa;AAAA,IACd;AAAA,IACA,UAAU;AAAA,MACT,YAAY,CAAC,OAAe,cAAc,EAAE;AAAA,MAC5C,aAAa;AAAA,IACd;AAAA,EACD;AAAA,EACA,MAAM;AAAA,IACL,UAAU;AAAA,MACT,YAAY,CAAC,OAAe,SAAS,EAAE;AAAA,MACvC,aACC;AAAA,IACF;AAAA,EACD;AACD;AAEA,eAAsB,YAErB,MACA,UACgC;AAChC,MAAI,OAAO,SAAS,UAAU,EAAE,WAAW,GAAG,KAAK,OAAO,SAAS,UAAU,EAAE,WAAW,GAAG,GAAG;AAC/F,UAAM,WAAW,KAAK,iBAAiB,UAAU;AACjD,UAAM,QAAQ,SAAS;AACvB,QAAI,eAAe,MAAM;AAEzB,QAAI,eAAqC;AAEzC,QAAI,aAAa,aAAa;AAC7B,UAAI,MAAM,SAAS,YAAY;AAC9B,cAAM,oBAAoB,KAAK,iBAAiB,iBAAiB;AACjE,cAA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AK,QAAQ,GAAG,OAAgC;AAAA,QACtE,SAAS,MAAM;AAAA,QACf,aAAa,MAAM;AAAA,MACpB,CAAC;AAAA,IACF;AAAA,EACD;AACA,SAAO;AACR;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var interfaces_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(interfaces_exports);
|
|
17
|
+
//# sourceMappingURL=interfaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../nodes/Microsoft/AzureCosmosDb/helpers/interfaces.ts"],"sourcesContent":["export interface ICosmosDbCredentials {\n\taccount: string;\n\tkey: string;\n\tdatabase: string;\n\tbaseUrl: string;\n}\n\nexport interface IErrorResponse {\n\tcode: string;\n\tmessage: string;\n}\n\nexport interface IContainer {\n\tpartitionKey: {\n\t\tpaths: string[];\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var utils_exports = {};
|
|
20
|
+
__export(utils_exports, {
|
|
21
|
+
getPartitionKey: () => getPartitionKey,
|
|
22
|
+
processJsonInput: () => processJsonInput,
|
|
23
|
+
simplifyData: () => simplifyData,
|
|
24
|
+
untilContainerSelected: () => untilContainerSelected,
|
|
25
|
+
untilItemSelected: () => untilItemSelected,
|
|
26
|
+
validateCustomProperties: () => validateCustomProperties,
|
|
27
|
+
validatePartitionKey: () => validatePartitionKey,
|
|
28
|
+
validateQueryParameters: () => validateQueryParameters
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(utils_exports);
|
|
31
|
+
var import_n8n_workflow = require("n8n-workflow");
|
|
32
|
+
var import_constants = require("./constants");
|
|
33
|
+
var import_errorHandler = require("./errorHandler");
|
|
34
|
+
var import_transport = require("../transport");
|
|
35
|
+
async function getPartitionKey() {
|
|
36
|
+
const container = this.getNodeParameter("container", void 0, {
|
|
37
|
+
extractValue: true
|
|
38
|
+
});
|
|
39
|
+
let partitionKeyField = void 0;
|
|
40
|
+
try {
|
|
41
|
+
const responseData = await import_transport.azureCosmosDbApiRequest.call(
|
|
42
|
+
this,
|
|
43
|
+
"GET",
|
|
44
|
+
`/colls/${container}`
|
|
45
|
+
);
|
|
46
|
+
partitionKeyField = responseData.partitionKey?.paths[0]?.replace("/", "");
|
|
47
|
+
} catch (error) {
|
|
48
|
+
const err = error;
|
|
49
|
+
if (err.httpCode === "404") {
|
|
50
|
+
err.message = import_errorHandler.ErrorMap.Container.NotFound.getMessage(container);
|
|
51
|
+
err.description = import_errorHandler.ErrorMap.Container.NotFound.description;
|
|
52
|
+
}
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
55
|
+
if (!partitionKeyField) {
|
|
56
|
+
throw new import_n8n_workflow.NodeOperationError(this.getNode(), "Partition key not found", {
|
|
57
|
+
description: "Failed to determine the partition key for this collection"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return partitionKeyField;
|
|
61
|
+
}
|
|
62
|
+
async function simplifyData(items, _response) {
|
|
63
|
+
const simple = this.getNodeParameter("simple");
|
|
64
|
+
if (!simple) {
|
|
65
|
+
return items;
|
|
66
|
+
}
|
|
67
|
+
const simplifyFields = (data) => {
|
|
68
|
+
const simplifiedData = Object.keys(data).filter((key) => !key.startsWith("_")).reduce((acc, key) => {
|
|
69
|
+
acc[key] = data[key];
|
|
70
|
+
return acc;
|
|
71
|
+
}, {});
|
|
72
|
+
return simplifiedData;
|
|
73
|
+
};
|
|
74
|
+
return items.map((item) => {
|
|
75
|
+
const simplifiedData = simplifyFields(item.json);
|
|
76
|
+
return { json: simplifiedData };
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async function validateQueryParameters(requestOptions) {
|
|
80
|
+
const query = this.getNodeParameter("query", "");
|
|
81
|
+
const queryOptions = this.getNodeParameter("options.queryOptions");
|
|
82
|
+
const parameterNames = query.replace(/\$(\d+)/g, "@Param$1").match(/@\w+/g) ?? [];
|
|
83
|
+
const queryParamsString = queryOptions?.queryParameters;
|
|
84
|
+
const parameterValues = queryParamsString ? queryParamsString.split(",").map((param) => param.trim()) : [];
|
|
85
|
+
if (parameterNames.length !== parameterValues.length) {
|
|
86
|
+
throw new import_n8n_workflow.NodeOperationError(this.getNode(), "Empty parameter value provided", {
|
|
87
|
+
description: "Please provide non-empty values for the query parameters"
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
requestOptions.body = {
|
|
91
|
+
...requestOptions.body,
|
|
92
|
+
parameters: parameterNames.map((name, index) => ({
|
|
93
|
+
name,
|
|
94
|
+
value: parameterValues[index]
|
|
95
|
+
}))
|
|
96
|
+
};
|
|
97
|
+
return requestOptions;
|
|
98
|
+
}
|
|
99
|
+
function processJsonInput(jsonData, inputName, fallbackValue = void 0, disallowSpacesIn) {
|
|
100
|
+
let values = {};
|
|
101
|
+
const input = inputName ? `'${inputName}' ` : "";
|
|
102
|
+
if (typeof jsonData === "string") {
|
|
103
|
+
try {
|
|
104
|
+
values = (0, import_n8n_workflow.jsonParse)(jsonData, { fallbackValue });
|
|
105
|
+
} catch (error) {
|
|
106
|
+
throw new import_n8n_workflow.OperationalError(`Input ${input}must contain a valid JSON`, { level: "warning" });
|
|
107
|
+
}
|
|
108
|
+
} else if (jsonData && typeof jsonData === "object") {
|
|
109
|
+
values = jsonData;
|
|
110
|
+
} else {
|
|
111
|
+
throw new import_n8n_workflow.OperationalError(`Input ${input}must contain a valid JSON`, { level: "warning" });
|
|
112
|
+
}
|
|
113
|
+
disallowSpacesIn?.forEach((key) => {
|
|
114
|
+
const value = values[key];
|
|
115
|
+
if (typeof value === "string" && value.includes(" ")) {
|
|
116
|
+
throw new import_n8n_workflow.OperationalError(
|
|
117
|
+
`${inputName ? `'${inputName}'` : ""} property '${key}' should not contain spaces (received "${value}")`,
|
|
118
|
+
{ level: "warning" }
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
return values;
|
|
123
|
+
}
|
|
124
|
+
async function validatePartitionKey(requestOptions) {
|
|
125
|
+
const operation = this.getNodeParameter("operation");
|
|
126
|
+
let customProperties = this.getNodeParameter("customProperties", {});
|
|
127
|
+
const partitionKey = await getPartitionKey.call(this);
|
|
128
|
+
if (typeof customProperties === "string") {
|
|
129
|
+
try {
|
|
130
|
+
customProperties = (0, import_n8n_workflow.jsonParse)(customProperties);
|
|
131
|
+
} catch (error) {
|
|
132
|
+
throw new import_n8n_workflow.NodeOperationError(this.getNode(), 'Invalid JSON format in "Item Contents"', {
|
|
133
|
+
description: 'Ensure the "Item Contents" field contains a valid JSON object'
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
let partitionKeyValue = "";
|
|
138
|
+
const needsPartitionKey = ["update", "delete", "get"].includes(operation);
|
|
139
|
+
if (operation === "create") {
|
|
140
|
+
if (!(partitionKey in customProperties) || !customProperties[partitionKey]) {
|
|
141
|
+
throw new import_n8n_workflow.NodeOperationError(this.getNode(), "Partition key not found in 'Item Contents'", {
|
|
142
|
+
description: `Partition key '${partitionKey}' must be present and have a valid, non-empty value in 'Item Contents'.`
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
partitionKeyValue = customProperties[partitionKey];
|
|
146
|
+
} else if (needsPartitionKey) {
|
|
147
|
+
try {
|
|
148
|
+
partitionKeyValue = partitionKey === "id" ? String(this.getNodeParameter("item", void 0, { extractValue: true }) ?? "") : String(this.getNodeParameter("additionalFields.partitionKey", void 0) ?? "");
|
|
149
|
+
if (!partitionKeyValue) {
|
|
150
|
+
throw new import_n8n_workflow.NodeOperationError(this.getNode(), "Partition key is empty", {
|
|
151
|
+
description: 'Ensure the "Partition Key" field has a valid, non-empty value.'
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
} catch (error) {
|
|
155
|
+
throw new import_n8n_workflow.NodeOperationError(this.getNode(), "Partition key is missing or empty", {
|
|
156
|
+
description: 'Ensure the "Partition Key" field exists and has a valid, non-empty value.'
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
if (operation === "update") {
|
|
160
|
+
const idValue = String(
|
|
161
|
+
this.getNodeParameter("item", void 0, { extractValue: true }) ?? ""
|
|
162
|
+
);
|
|
163
|
+
requestOptions.body.id = idValue;
|
|
164
|
+
requestOptions.body[partitionKey] = partitionKeyValue;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
requestOptions.headers = {
|
|
168
|
+
...requestOptions.headers,
|
|
169
|
+
[import_constants.HeaderConstants.X_MS_DOCUMENTDB_PARTITIONKEY]: `["${partitionKeyValue}"]`
|
|
170
|
+
};
|
|
171
|
+
return requestOptions;
|
|
172
|
+
}
|
|
173
|
+
async function validateCustomProperties(requestOptions) {
|
|
174
|
+
const rawCustomProperties = this.getNodeParameter("customProperties");
|
|
175
|
+
const customProperties = processJsonInput(rawCustomProperties, "Item Contents");
|
|
176
|
+
if (Object.keys(customProperties).length === 0 || Object.values(customProperties).every((val) => val === void 0 || val === null || val === "")) {
|
|
177
|
+
throw new import_n8n_workflow.NodeOperationError(this.getNode(), "Item contents are empty", {
|
|
178
|
+
description: 'Ensure the "Item Contents" field contains at least one valid property.'
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
requestOptions.body = {
|
|
182
|
+
...requestOptions.body,
|
|
183
|
+
...customProperties
|
|
184
|
+
};
|
|
185
|
+
return requestOptions;
|
|
186
|
+
}
|
|
187
|
+
const untilContainerSelected = { container: [""] };
|
|
188
|
+
const untilItemSelected = { item: [""] };
|
|
189
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
190
|
+
0 && (module.exports = {
|
|
191
|
+
getPartitionKey,
|
|
192
|
+
processJsonInput,
|
|
193
|
+
simplifyData,
|
|
194
|
+
untilContainerSelected,
|
|
195
|
+
untilItemSelected,
|
|
196
|
+
validateCustomProperties,
|
|
197
|
+
validatePartitionKey,
|
|
198
|
+
validateQueryParameters
|
|
199
|
+
});
|
|
200
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../nodes/Microsoft/AzureCosmosDb/helpers/utils.ts"],"sourcesContent":["import type {\n\tIDataObject,\n\tIExecuteSingleFunctions,\n\tIHttpRequestOptions,\n\tIN8nHttpFullResponse,\n\tINodeExecutionData,\n\tNodeApiError,\n} from 'n8n-workflow';\nimport { jsonParse, NodeOperationError, OperationalError } from 'n8n-workflow';\n\nimport { HeaderConstants } from './constants';\nimport { ErrorMap } from './errorHandler';\nimport type { IContainer } from './interfaces';\nimport { azureCosmosDbApiRequest } from '../transport';\n\nexport async function getPartitionKey(this: IExecuteSingleFunctions): Promise<string> {\n\tconst container = this.getNodeParameter('container', undefined, {\n\t\textractValue: true,\n\t}) as string;\n\n\tlet partitionKeyField: string | undefined = undefined;\n\ttry {\n\t\tconst responseData = (await azureCosmosDbApiRequest.call(\n\t\t\tthis,\n\t\t\t'GET',\n\t\t\t`/colls/${container}`,\n\t\t)) as IContainer;\n\t\tpartitionKeyField = responseData.partitionKey?.paths[0]?.replace('/', '');\n\t} catch (error) {\n\t\tconst err = error as NodeApiError;\n\t\tif (err.httpCode === '404') {\n\t\t\terr.message = ErrorMap.Container.NotFound.getMessage(container);\n\t\t\terr.description = ErrorMap.Container.NotFound.description;\n\t\t}\n\t\tthrow err;\n\t}\n\n\tif (!partitionKeyField) {\n\t\tthrow new NodeOperationError(this.getNode(), 'Partition key not found', {\n\t\t\tdescription: 'Failed to determine the partition key for this collection',\n\t\t});\n\t}\n\n\treturn partitionKeyField;\n}\n\nexport async function simplifyData(\n\tthis: IExecuteSingleFunctions,\n\titems: INodeExecutionData[],\n\t_response: IN8nHttpFullResponse,\n): Promise<INodeExecutionData[]> {\n\tconst simple = this.getNodeParameter('simple') as boolean;\n\n\tif (!simple) {\n\t\treturn items;\n\t}\n\n\tconst simplifyFields = (data: IDataObject): IDataObject => {\n\t\tconst simplifiedData = Object.keys(data)\n\t\t\t.filter((key) => !key.startsWith('_'))\n\t\t\t.reduce((acc, key) => {\n\t\t\t\tacc[key] = data[key];\n\t\t\t\treturn acc;\n\t\t\t}, {} as IDataObject);\n\n\t\treturn simplifiedData;\n\t};\n\n\treturn items.map((item) => {\n\t\tconst simplifiedData = simplifyFields(item.json);\n\t\treturn { json: simplifiedData } as INodeExecutionData;\n\t});\n}\n\nexport async function validateQueryParameters(\n\tthis: IExecuteSingleFunctions,\n\trequestOptions: IHttpRequestOptions,\n): Promise<IHttpRequestOptions> {\n\tconst query = this.getNodeParameter('query', '') as string;\n\tconst queryOptions = this.getNodeParameter('options.queryOptions') as IDataObject;\n\n\tconst parameterNames = query.replace(/\\$(\\d+)/g, '@Param$1').match(/@\\w+/g) ?? [];\n\n\tconst queryParamsString = queryOptions?.queryParameters as string;\n\tconst parameterValues = queryParamsString\n\t\t? queryParamsString.split(',').map((param) => param.trim())\n\t\t: [];\n\n\tif (parameterNames.length !== parameterValues.length) {\n\t\tthrow new NodeOperationError(this.getNode(), 'Empty parameter value provided', {\n\t\t\tdescription: 'Please provide non-empty values for the query parameters',\n\t\t});\n\t}\n\n\trequestOptions.body = {\n\t\t...(requestOptions.body as IDataObject),\n\t\tparameters: parameterNames.map((name, index) => ({\n\t\t\tname,\n\t\t\tvalue: parameterValues[index],\n\t\t})),\n\t};\n\n\treturn requestOptions;\n}\n\nexport function processJsonInput<T>(\n\tjsonData: T,\n\tinputName?: string,\n\tfallbackValue: T | undefined = undefined,\n\tdisallowSpacesIn?: string[],\n): Record<string, unknown> {\n\tlet values: Record<string, unknown> = {};\n\n\tconst input = inputName ? `'${inputName}' ` : '';\n\n\tif (typeof jsonData === 'string') {\n\t\ttry {\n\t\t\tvalues = jsonParse(jsonData, { fallbackValue }) as Record<string, unknown>;\n\t\t} catch (error) {\n\t\t\tthrow new OperationalError(`Input ${input}must contain a valid JSON`, { level: 'warning' });\n\t\t}\n\t} else if (jsonData && typeof jsonData === 'object') {\n\t\tvalues = jsonData as Record<string, unknown>;\n\t} else {\n\t\tthrow new OperationalError(`Input ${input}must contain a valid JSON`, { level: 'warning' });\n\t}\n\n\tdisallowSpacesIn?.forEach((key) => {\n\t\tconst value = values[key];\n\t\tif (typeof value === 'string' && value.includes(' ')) {\n\t\t\tthrow new OperationalError(\n\t\t\t\t`${inputName ? `'${inputName}'` : ''} property '${key}' should not contain spaces (received \"${value}\")`,\n\t\t\t\t{ level: 'warning' },\n\t\t\t);\n\t\t}\n\t});\n\n\treturn values;\n}\n\nexport async function validatePartitionKey(\n\tthis: IExecuteSingleFunctions,\n\trequestOptions: IHttpRequestOptions,\n): Promise<IHttpRequestOptions> {\n\tconst operation = this.getNodeParameter('operation') as string;\n\tlet customProperties = this.getNodeParameter('customProperties', {}) as IDataObject;\n\n\tconst partitionKey = await getPartitionKey.call(this);\n\n\tif (typeof customProperties === 'string') {\n\t\ttry {\n\t\t\tcustomProperties = jsonParse(customProperties);\n\t\t} catch (error) {\n\t\t\tthrow new NodeOperationError(this.getNode(), 'Invalid JSON format in \"Item Contents\"', {\n\t\t\t\tdescription: 'Ensure the \"Item Contents\" field contains a valid JSON object',\n\t\t\t});\n\t\t}\n\t}\n\n\tlet partitionKeyValue: string = '';\n\tconst needsPartitionKey = ['update', 'delete', 'get'].includes(operation);\n\n\tif (operation === 'create') {\n\t\tif (!(partitionKey in customProperties) || !customProperties[partitionKey]) {\n\t\t\tthrow new NodeOperationError(this.getNode(), \"Partition key not found in 'Item Contents'\", {\n\t\t\t\tdescription: `Partition key '${partitionKey}' must be present and have a valid, non-empty value in 'Item Contents'.`,\n\t\t\t});\n\t\t}\n\t\tpartitionKeyValue = customProperties[partitionKey] as string;\n\t} else if (needsPartitionKey) {\n\t\ttry {\n\t\t\tpartitionKeyValue =\n\t\t\t\tpartitionKey === 'id'\n\t\t\t\t\t? String(this.getNodeParameter('item', undefined, { extractValue: true }) ?? '')\n\t\t\t\t\t: String(this.getNodeParameter('additionalFields.partitionKey', undefined) ?? '');\n\n\t\t\tif (!partitionKeyValue) {\n\t\t\t\tthrow new NodeOperationError(this.getNode(), 'Partition key is empty', {\n\t\t\t\t\tdescription: 'Ensure the \"Partition Key\" field has a valid, non-empty value.',\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow new NodeOperationError(this.getNode(), 'Partition key is missing or empty', {\n\t\t\t\tdescription: 'Ensure the \"Partition Key\" field exists and has a valid, non-empty value.',\n\t\t\t});\n\t\t}\n\n\t\tif (operation === 'update') {\n\t\t\tconst idValue = String(\n\t\t\t\tthis.getNodeParameter('item', undefined, { extractValue: true }) ?? '',\n\t\t\t);\n\n\t\t\t(requestOptions.body as IDataObject).id = idValue;\n\t\t\t(requestOptions.body as IDataObject)[partitionKey] = partitionKeyValue;\n\t\t}\n\t}\n\n\trequestOptions.headers = {\n\t\t...requestOptions.headers,\n\t\t[HeaderConstants.X_MS_DOCUMENTDB_PARTITIONKEY]: `[\"${partitionKeyValue}\"]`,\n\t};\n\n\treturn requestOptions;\n}\n\nexport async function validateCustomProperties(\n\tthis: IExecuteSingleFunctions,\n\trequestOptions: IHttpRequestOptions,\n): Promise<IHttpRequestOptions> {\n\tconst rawCustomProperties = this.getNodeParameter('customProperties') as IDataObject;\n\tconst customProperties = processJsonInput(rawCustomProperties, 'Item Contents');\n\tif (\n\t\tObject.keys(customProperties).length === 0 ||\n\t\tObject.values(customProperties).every((val) => val === undefined || val === null || val === '')\n\t) {\n\t\tthrow new NodeOperationError(this.getNode(), 'Item contents are empty', {\n\t\t\tdescription: 'Ensure the \"Item Contents\" field contains at least one valid property.',\n\t\t});\n\t}\n\trequestOptions.body = {\n\t\t...(requestOptions.body as IDataObject),\n\t\t...customProperties,\n\t};\n\treturn requestOptions;\n}\n\nexport const untilContainerSelected = { container: [''] };\n\nexport const untilItemSelected = { item: [''] };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,0BAAgE;AAEhE,uBAAgC;AAChC,0BAAyB;AAEzB,uBAAwC;AAExC,eAAsB,kBAAgE;AACrF,QAAM,YAAY,KAAK,iBAAiB,aAAa,QAAW;AA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,EAAE,cAAc,KAAK,CAAC,KAAK;AAAA,MACrE;AAEA,MAAC,eAAe,KAAqB,KAAK;AAC1C,MAAC,eAAe,KAAqB,YAAY,IAAI;AAAA,IACtD;AAAA,EACD;AAEA,iBAAe,UAAU;AAAA,IACxB,GAAG,eAAe;AAAA,IAClB,CAAC,iCAAgB,4BAA4B,GAAG,KAAK,iBAAiB;AAAA,EACvE;AAEA,SAAO;AACR;AAEA,eAAsB,yBAErB,gBAC+B;AAC/B,QAAM,sBAAsB,KAAK,iBAAiB,kBAAkB;AACpE,QAAM,mBAAmB,iBAAiB,qBAAqB,eAAe;AAC9E,MACC,OAAO,KAAK,gBAAgB,EAAE,WAAW,KACzC,OAAO,OAAO,gBAAgB,EAAE,MAAM,CAAC,QAAQ,QAAQ,UAAa,QAAQ,QAAQ,QAAQ,EAAE,GAC7F;AACD,UAAM,IAAI,uCAAmB,KAAK,QAAQ,GAAG,2BAA2B;AAAA,MACvE,aAAa;AAAA,IACd,CAAC;AAAA,EACF;AACA,iBAAe,OAAO;AAAA,IACrB,GAAI,eAAe;AAAA,IACnB,GAAG;AAAA,EACJ;AACA,SAAO;AACR;AAEO,MAAM,yBAAyB,EAAE,WAAW,CAAC,EAAE,EAAE;AAEjD,MAAM,oBAAoB,EAAE,MAAM,CAAC,EAAE,EAAE;","names":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var methods_exports = {};
|
|
30
|
+
__export(methods_exports, {
|
|
31
|
+
listSearch: () => listSearch
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(methods_exports);
|
|
34
|
+
var listSearch = __toESM(require("./listSearch"));
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
listSearch
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../nodes/Microsoft/AzureCosmosDb/methods/index.ts"],"sourcesContent":["export * as listSearch from './listSearch';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA4B;","names":[]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var listSearch_exports = {};
|
|
20
|
+
__export(listSearch_exports, {
|
|
21
|
+
searchContainers: () => searchContainers,
|
|
22
|
+
searchItems: () => searchItems
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(listSearch_exports);
|
|
25
|
+
var import_constants = require("../helpers/constants");
|
|
26
|
+
var import_transport = require("../transport");
|
|
27
|
+
function formatResults(items, filter) {
|
|
28
|
+
return items.map(({ id }) => ({
|
|
29
|
+
name: String(id).replace(/ /g, ""),
|
|
30
|
+
value: String(id)
|
|
31
|
+
})).filter(({ name }) => !filter || name.includes(filter)).sort((a, b) => a.name.localeCompare(b.name));
|
|
32
|
+
}
|
|
33
|
+
async function searchContainers(filter, paginationToken) {
|
|
34
|
+
const headers = paginationToken ? { [import_constants.HeaderConstants.X_MS_CONTINUATION]: paginationToken } : {};
|
|
35
|
+
const responseData = await import_transport.azureCosmosDbApiRequest.call(
|
|
36
|
+
this,
|
|
37
|
+
"GET",
|
|
38
|
+
"/colls",
|
|
39
|
+
{},
|
|
40
|
+
{},
|
|
41
|
+
headers,
|
|
42
|
+
true
|
|
43
|
+
);
|
|
44
|
+
const containers = responseData.body.DocumentCollections;
|
|
45
|
+
return {
|
|
46
|
+
results: formatResults(containers, filter),
|
|
47
|
+
paginationToken: responseData.headers[import_constants.HeaderConstants.X_MS_CONTINUATION]
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
async function searchItems(filter, paginationToken) {
|
|
51
|
+
const container = this.getCurrentNodeParameter("container", {
|
|
52
|
+
extractValue: true
|
|
53
|
+
});
|
|
54
|
+
const headers = paginationToken ? { [import_constants.HeaderConstants.X_MS_CONTINUATION]: paginationToken } : {};
|
|
55
|
+
const responseData = await import_transport.azureCosmosDbApiRequest.call(
|
|
56
|
+
this,
|
|
57
|
+
"GET",
|
|
58
|
+
`/colls/${container}/docs`,
|
|
59
|
+
{},
|
|
60
|
+
{},
|
|
61
|
+
headers,
|
|
62
|
+
true
|
|
63
|
+
);
|
|
64
|
+
const items = responseData.body.Documents;
|
|
65
|
+
return {
|
|
66
|
+
results: formatResults(items, filter),
|
|
67
|
+
paginationToken: responseData.headers[import_constants.HeaderConstants.X_MS_CONTINUATION]
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
searchContainers,
|
|
73
|
+
searchItems
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=listSearch.js.map
|