n8n-nodes-docspell 0.43.5 → 0.43.7
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/README.md +1 -1
- package/dist/credentials/DocspellApi.credentials.d.ts +1 -1
- package/dist/credentials/DocspellApi.credentials.js +24 -24
- package/dist/credentials/DocspellApi.credentials.js.map +1 -1
- package/dist/credentials/DocspellSession.js +7 -7
- package/dist/credentials/DocspellSession.js.map +1 -1
- package/dist/nodes/Common/GenericFunctions.d.ts +2 -2
- package/dist/nodes/Common/GenericFunctions.js +24 -20
- package/dist/nodes/Common/GenericFunctions.js.map +1 -1
- package/dist/nodes/Docspell/Docspell.node.d.ts +1 -1
- package/dist/nodes/Docspell/Docspell.node.js +24 -24
- package/dist/nodes/Docspell/Docspell.node.js.map +1 -1
- package/dist/nodes/Docspell/Docspell.node.json +1 -3
- package/dist/nodes/Docspell/methods/loadOptions.d.ts +1 -1
- package/dist/nodes/Docspell/methods/loadOptions.js +9 -8
- package/dist/nodes/Docspell/methods/loadOptions.js.map +1 -1
- package/dist/nodes/Docspell/resources/attachment/download.d.ts +1 -1
- package/dist/nodes/Docspell/resources/attachment/download.js +37 -33
- package/dist/nodes/Docspell/resources/attachment/download.js.map +1 -1
- package/dist/nodes/Docspell/resources/attachment/index.d.ts +1 -1
- package/dist/nodes/Docspell/resources/attachment/index.js +9 -9
- package/dist/nodes/Docspell/resources/attachment/index.js.map +1 -1
- package/dist/nodes/Docspell/resources/item/get.d.ts +1 -1
- package/dist/nodes/Docspell/resources/item/get.js +9 -9
- package/dist/nodes/Docspell/resources/item/get.js.map +1 -1
- package/dist/nodes/Docspell/resources/item/index.d.ts +1 -1
- package/dist/nodes/Docspell/resources/item/index.js +25 -25
- package/dist/nodes/Docspell/resources/item/index.js.map +1 -1
- package/dist/nodes/Docspell/resources/item/search.d.ts +1 -1
- package/dist/nodes/Docspell/resources/item/search.js +40 -40
- package/dist/nodes/Docspell/resources/item/search.js.map +1 -1
- package/dist/nodes/Docspell/resources/item/update.d.ts +1 -1
- package/dist/nodes/Docspell/resources/item/update.js +179 -125
- package/dist/nodes/Docspell/resources/item/update.js.map +1 -1
- package/dist/nodes/Docspell/resources/item/updateMany.d.ts +1 -1
- package/dist/nodes/Docspell/resources/item/updateMany.js +80 -53
- package/dist/nodes/Docspell/resources/item/updateMany.js.map +1 -1
- package/dist/nodes/Docspell/resources/item/upload.d.ts +1 -1
- package/dist/nodes/Docspell/resources/item/upload.js +80 -69
- package/dist/nodes/Docspell/resources/item/upload.js.map +1 -1
- package/dist/nodes/Docspell/resources/organization/get.d.ts +1 -1
- package/dist/nodes/Docspell/resources/organization/get.js +9 -9
- package/dist/nodes/Docspell/resources/organization/get.js.map +1 -1
- package/dist/nodes/Docspell/resources/organization/getAll.d.ts +1 -1
- package/dist/nodes/Docspell/resources/organization/getAll.js +20 -20
- package/dist/nodes/Docspell/resources/organization/getAll.js.map +1 -1
- package/dist/nodes/Docspell/resources/organization/index.d.ts +1 -1
- package/dist/nodes/Docspell/resources/organization/index.js +13 -13
- package/dist/nodes/Docspell/resources/organization/index.js.map +1 -1
- package/dist/package.json +19 -17
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -17
|
@@ -5,138 +5,165 @@ exports.executeItemUpdateMany = executeItemUpdateMany;
|
|
|
5
5
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
6
|
const GenericFunctions_1 = require("../../../Common/GenericFunctions");
|
|
7
7
|
const update_1 = require("./update");
|
|
8
|
-
const show = { resource: [
|
|
8
|
+
const show = { resource: ["item"], operation: ["updateMany"] };
|
|
9
9
|
exports.itemUpdateManyDescription = [
|
|
10
10
|
{
|
|
11
|
-
displayName:
|
|
12
|
-
name:
|
|
13
|
-
type:
|
|
11
|
+
displayName: "Item IDs",
|
|
12
|
+
name: "itemIds",
|
|
13
|
+
type: "string",
|
|
14
14
|
required: true,
|
|
15
|
-
default:
|
|
16
|
-
description:
|
|
15
|
+
default: "",
|
|
16
|
+
description: "The IDs of the items to change, separated by commas, spaces or new lines. Use an expression to take them from earlier items, for example the results of a Search.",
|
|
17
17
|
displayOptions: { show },
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
|
-
displayName:
|
|
21
|
-
name:
|
|
22
|
-
type:
|
|
23
|
-
placeholder:
|
|
20
|
+
displayName: "Update Fields",
|
|
21
|
+
name: "bulkFields",
|
|
22
|
+
type: "collection",
|
|
23
|
+
placeholder: "Add Field",
|
|
24
24
|
default: {},
|
|
25
|
-
description:
|
|
25
|
+
description: "Only the fields added here are changed, on every item. Where noted, an empty value removes the current one.",
|
|
26
26
|
displayOptions: { show },
|
|
27
|
-
options: update_1.updateFieldOptions.filter((option) => option.name !==
|
|
27
|
+
options: update_1.updateFieldOptions.filter((option) => option.name !== "notes"),
|
|
28
28
|
},
|
|
29
|
-
(0, update_1.customFieldsProperty)(
|
|
29
|
+
(0, update_1.customFieldsProperty)("bulkCustomFields", show),
|
|
30
30
|
(0, update_1.removeCustomFieldsProperty)(show),
|
|
31
31
|
];
|
|
32
32
|
function idList(value) {
|
|
33
33
|
const entries = Array.isArray(value) ? value : [value];
|
|
34
|
-
const ids = entries
|
|
34
|
+
const ids = entries
|
|
35
|
+
.flatMap((entry) => String(entry !== null && entry !== void 0 ? entry : "").split(/[\s,]+/))
|
|
36
|
+
.filter((id) => id !== "");
|
|
35
37
|
return [...new Set(ids)];
|
|
36
38
|
}
|
|
37
39
|
async function executeItemUpdateMany(context, itemIndex) {
|
|
38
40
|
var _a, _b;
|
|
39
41
|
const fail = (message) => new n8n_workflow_1.NodeOperationError(context.getNode(), message, { itemIndex });
|
|
40
|
-
const ids = idList(context.getNodeParameter(
|
|
42
|
+
const ids = idList(context.getNodeParameter("itemIds", itemIndex, ""));
|
|
41
43
|
if (ids.length === 0)
|
|
42
|
-
throw fail(
|
|
43
|
-
const fields = context.getNodeParameter(
|
|
44
|
-
const customFields = ((_a = context.getNodeParameter(
|
|
45
|
-
const removeTokens = (0, GenericFunctions_1.tagTokens)(context.getNodeParameter(
|
|
44
|
+
throw fail("No item IDs were given");
|
|
45
|
+
const fields = context.getNodeParameter("bulkFields", itemIndex, {});
|
|
46
|
+
const customFields = ((_a = context.getNodeParameter("bulkCustomFields", itemIndex, {}).values) !== null && _a !== void 0 ? _a : []).filter((entry) => entry.field.trim() !== "");
|
|
47
|
+
const removeTokens = (0, GenericFunctions_1.tagTokens)(context.getNodeParameter("removeCustomFields", itemIndex, []));
|
|
46
48
|
if (Object.keys(fields).length === 0 && customFields.length === 0 && removeTokens.length === 0) {
|
|
47
|
-
throw fail(
|
|
49
|
+
throw fail("Choose at least one field to update");
|
|
48
50
|
}
|
|
49
|
-
if (
|
|
50
|
-
throw fail(
|
|
51
|
-
if (
|
|
52
|
-
throw fail(
|
|
51
|
+
if ("name" in fields && String(fields.name).trim() === "")
|
|
52
|
+
throw fail("The name cannot be empty");
|
|
53
|
+
if ("tags" in fields && (0, GenericFunctions_1.hasMissingTag)(fields.tags)) {
|
|
54
|
+
throw fail("The tags value is empty (null or undefined). Leave the field empty to remove all tags.");
|
|
53
55
|
}
|
|
54
|
-
const itemDate =
|
|
55
|
-
const dueDate =
|
|
56
|
+
const itemDate = "itemDate" in fields ? (0, GenericFunctions_1.dateBody)("Item Date", fields.itemDate, fail) : undefined;
|
|
57
|
+
const dueDate = "dueDate" in fields ? (0, GenericFunctions_1.dateBody)("Due Date", fields.dueDate, fail) : undefined;
|
|
56
58
|
const removeCustomFields = (await (0, GenericFunctions_1.resolveRemovedCustomFields)(context, removeTokens, customFields.map((entry) => entry.field.trim()), fail)).map((field) => field.name);
|
|
57
59
|
const current = [];
|
|
58
60
|
const missing = [];
|
|
59
61
|
for (const id of ids) {
|
|
60
62
|
try {
|
|
61
|
-
current.push(await (0, GenericFunctions_1.docspellApiRequest)(context, { method:
|
|
63
|
+
current.push(await (0, GenericFunctions_1.docspellApiRequest)(context, { method: "GET", endpoint: `/sec/item/${encodeURIComponent(id)}` }, { 404: `Item "${id}" was not found` }));
|
|
62
64
|
}
|
|
63
65
|
catch (error) {
|
|
64
|
-
if (error.httpCode !==
|
|
66
|
+
if (error.httpCode !== "404")
|
|
65
67
|
throw error;
|
|
66
68
|
missing.push(id);
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
if (missing.length > 0) {
|
|
70
|
-
throw fail(`Item${missing.length > 1 ?
|
|
72
|
+
throw fail(`Item${missing.length > 1 ? "s" : ""} not found in Docspell: ${missing.map((id) => `"${id}"`).join(", ")}. Nothing was changed.`);
|
|
71
73
|
}
|
|
72
74
|
const applied = [];
|
|
73
75
|
const put = async (label, method, endpoint, body, items = ids) => {
|
|
74
|
-
const result = await (0, GenericFunctions_1.docspellApiRequest)(context, {
|
|
76
|
+
const result = await (0, GenericFunctions_1.docspellApiRequest)(context, {
|
|
77
|
+
method,
|
|
78
|
+
endpoint: `/sec/items${endpoint}`,
|
|
79
|
+
body: { items, ...body },
|
|
80
|
+
});
|
|
75
81
|
if (result.success === false) {
|
|
76
|
-
const done = applied.length > 0 ? ` (already applied: ${applied.join(
|
|
82
|
+
const done = applied.length > 0 ? ` (already applied: ${applied.join(", ")})` : "";
|
|
77
83
|
throw fail(`Could not update the ${label}: ${String(result.message)}${done}`);
|
|
78
84
|
}
|
|
79
85
|
applied.push(label);
|
|
80
86
|
};
|
|
81
87
|
const steps = [];
|
|
82
|
-
if (
|
|
83
|
-
steps.push({
|
|
84
|
-
|
|
85
|
-
|
|
88
|
+
if ("name" in fields)
|
|
89
|
+
steps.push({
|
|
90
|
+
label: "name",
|
|
91
|
+
run: () => put("name", "PUT", "/name", { name: fields.name }),
|
|
92
|
+
});
|
|
93
|
+
if ("direction" in fields) {
|
|
94
|
+
steps.push({
|
|
95
|
+
label: "direction",
|
|
96
|
+
run: () => put("direction", "PUT", "/direction", { direction: fields.direction }),
|
|
97
|
+
});
|
|
86
98
|
}
|
|
87
99
|
if (itemDate)
|
|
88
|
-
steps.push({ label:
|
|
100
|
+
steps.push({ label: "item date", run: () => put("item date", "PUT", "/date", itemDate) });
|
|
89
101
|
if (dueDate)
|
|
90
|
-
steps.push({ label:
|
|
91
|
-
if (
|
|
92
|
-
steps.push({
|
|
102
|
+
steps.push({ label: "due date", run: () => put("due date", "PUT", "/duedate", dueDate) });
|
|
103
|
+
if ("folder" in fields) {
|
|
104
|
+
steps.push({
|
|
105
|
+
label: "folder",
|
|
106
|
+
run: () => put("folder", "PUT", "/folder", {
|
|
107
|
+
ref: fields.folder === "" ? null : fields.folder,
|
|
108
|
+
}),
|
|
109
|
+
});
|
|
93
110
|
}
|
|
94
111
|
for (const key of Object.keys(update_1.ENDPOINT_OF)) {
|
|
95
112
|
if (key in fields) {
|
|
96
113
|
steps.push({
|
|
97
114
|
label: update_1.LABEL_OF[key],
|
|
98
|
-
run: () => put(update_1.LABEL_OF[key],
|
|
115
|
+
run: () => put(update_1.LABEL_OF[key], "PUT", `/${update_1.ENDPOINT_OF[key]}`, {
|
|
116
|
+
ref: fields[key] === "" ? null : fields[key],
|
|
117
|
+
}),
|
|
99
118
|
});
|
|
100
119
|
}
|
|
101
120
|
}
|
|
102
|
-
if (
|
|
103
|
-
const mode = (_b = fields.tagsMode) !== null && _b !== void 0 ? _b :
|
|
121
|
+
if ("tags" in fields) {
|
|
122
|
+
const mode = (_b = fields.tagsMode) !== null && _b !== void 0 ? _b : "replace";
|
|
104
123
|
const { ids: tagIds, unknown } = await (0, GenericFunctions_1.resolveTags)(context, (0, GenericFunctions_1.tagTokens)(fields.tags));
|
|
105
124
|
if (unknown.length > 0) {
|
|
106
|
-
throw fail(`Tag${unknown.length > 1 ?
|
|
125
|
+
throw fail(`Tag${unknown.length > 1 ? "s" : ""} not found in Docspell: ${unknown.map((tag) => `"${tag}"`).join(", ")}`);
|
|
107
126
|
}
|
|
108
|
-
if (mode ===
|
|
127
|
+
if (mode === "remove") {
|
|
109
128
|
if (tagIds.length > 0)
|
|
110
|
-
steps.push({
|
|
129
|
+
steps.push({
|
|
130
|
+
label: "tags",
|
|
131
|
+
run: () => put("tags", "POST", "/tagsremove", { refs: tagIds }),
|
|
132
|
+
});
|
|
111
133
|
}
|
|
112
|
-
else if (mode ===
|
|
134
|
+
else if (mode === "add") {
|
|
113
135
|
if (tagIds.length > 0)
|
|
114
|
-
steps.push({ label:
|
|
136
|
+
steps.push({ label: "tags", run: () => put("tags", "POST", "/tags", { refs: tagIds }) });
|
|
115
137
|
}
|
|
116
138
|
else if (tagIds.length > 0) {
|
|
117
|
-
steps.push({ label:
|
|
139
|
+
steps.push({ label: "tags", run: () => put("tags", "PUT", "/tags", { refs: tagIds }) });
|
|
118
140
|
}
|
|
119
141
|
else {
|
|
120
142
|
const tagged = ids.filter((_, index) => { var _a; return ((_a = current[index].tags) !== null && _a !== void 0 ? _a : []).length > 0; });
|
|
121
143
|
if (tagged.length > 0)
|
|
122
|
-
steps.push({ label:
|
|
144
|
+
steps.push({ label: "tags", run: () => put("tags", "PUT", "/tags", { refs: [] }, tagged) });
|
|
123
145
|
}
|
|
124
146
|
}
|
|
125
147
|
for (const { field, value } of customFields) {
|
|
126
148
|
const label = `custom field "${field.trim()}"`;
|
|
127
|
-
steps.push({
|
|
149
|
+
steps.push({
|
|
150
|
+
label,
|
|
151
|
+
run: () => put(label, "PUT", "/customfield", { field: { field: field.trim(), value } }),
|
|
152
|
+
});
|
|
128
153
|
}
|
|
129
154
|
for (const name of removeCustomFields) {
|
|
130
155
|
const label = `removal of custom field "${name}"`;
|
|
131
|
-
steps.push({ label, run: () => put(label,
|
|
156
|
+
steps.push({ label, run: () => put(label, "POST", "/customfieldremove", { name }) });
|
|
132
157
|
}
|
|
133
158
|
const result = [];
|
|
134
159
|
try {
|
|
135
160
|
for (const step of steps)
|
|
136
161
|
await step.run();
|
|
137
162
|
for (const id of ids) {
|
|
138
|
-
const item = await (0, GenericFunctions_1.docspellApiRequest)(context, { method:
|
|
139
|
-
result.push(...context.helpers.constructExecutionMetaData(context.helpers.returnJsonArray(item), {
|
|
163
|
+
const item = await (0, GenericFunctions_1.docspellApiRequest)(context, { method: "GET", endpoint: `/sec/item/${encodeURIComponent(id)}` }, { 404: `Item "${id}" was not found` });
|
|
164
|
+
result.push(...context.helpers.constructExecutionMetaData(context.helpers.returnJsonArray(item), {
|
|
165
|
+
itemData: { item: itemIndex },
|
|
166
|
+
}));
|
|
140
167
|
}
|
|
141
168
|
}
|
|
142
169
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateMany.js","sourceRoot":"","sources":["../../../../../nodes/Docspell/resources/item/updateMany.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"updateMany.js","sourceRoot":"","sources":["../../../../../nodes/Docspell/resources/item/updateMany.ts"],"names":[],"mappings":";;;AAoEA,sDA0LC;AAxPD,+CAAkD;AAElD,uEAQ0C;AAC1C,qCAMkB;AAElB,MAAM,IAAI,GAAG,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC;AAElD,QAAA,yBAAyB,GAAsB;IAC1D;QACE,WAAW,EAAE,UAAU;QACvB,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,EAAE;QACX,WAAW,EACT,mKAAmK;QACrK,cAAc,EAAE,EAAE,IAAI,EAAE;KACzB;IACD;QACE,WAAW,EAAE,eAAe;QAC5B,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,WAAW;QACxB,OAAO,EAAE,EAAE;QACX,WAAW,EACT,6GAA6G;QAC/G,cAAc,EAAE,EAAE,IAAI,EAAE;QAExB,OAAO,EAAE,2BAAkB,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC;KACxE;IACD,IAAA,6BAAoB,EAAC,kBAAkB,EAAE,IAAI,CAAC;IAC9C,IAAA,mCAA0B,EAA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,EACP,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,kBAAkB,CAAC,EAAE,CAAC,EAAE,EAAE,EAClE,EAAE,GAAG,EAAE,SAAS,EAAE,iBAAiB,EAAE,CACtC,CAAC;YACF,MAAM,CAAC,IAAI,CACT,GAAG,OAAO,CAAC,OAAO,CAAC,0BAA0B,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE;gBACnF,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;aAC9B,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAA,qCAAkB,EAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from "n8n-workflow";
|
|
2
2
|
export declare const itemUploadDescription: INodeProperties[];
|
|
3
3
|
export declare function executeItemUpload(context: IExecuteFunctions, itemIndex: number): Promise<INodeExecutionData[]>;
|
|
@@ -4,92 +4,92 @@ exports.itemUploadDescription = void 0;
|
|
|
4
4
|
exports.executeItemUpload = executeItemUpload;
|
|
5
5
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
6
|
const GenericFunctions_1 = require("../../../Common/GenericFunctions");
|
|
7
|
-
const show = { resource: [
|
|
7
|
+
const show = { resource: ["item"], operation: ["upload"] };
|
|
8
8
|
exports.itemUploadDescription = [
|
|
9
9
|
{
|
|
10
|
-
displayName:
|
|
11
|
-
name:
|
|
12
|
-
type:
|
|
10
|
+
displayName: "Input Binary Field",
|
|
11
|
+
name: "binaryPropertyName",
|
|
12
|
+
type: "string",
|
|
13
13
|
required: true,
|
|
14
|
-
default:
|
|
15
|
-
description:
|
|
14
|
+
default: "data",
|
|
15
|
+
description: "Name of the binary property that holds the file. Separate several names with commas to upload several files at once.",
|
|
16
16
|
displayOptions: { show },
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
|
-
displayName:
|
|
20
|
-
name:
|
|
21
|
-
type:
|
|
22
|
-
placeholder:
|
|
19
|
+
displayName: "Options",
|
|
20
|
+
name: "options",
|
|
21
|
+
type: "collection",
|
|
22
|
+
placeholder: "Add Option",
|
|
23
23
|
default: {},
|
|
24
24
|
displayOptions: { show },
|
|
25
25
|
options: [
|
|
26
26
|
{
|
|
27
|
-
displayName:
|
|
28
|
-
name:
|
|
29
|
-
type:
|
|
27
|
+
displayName: "Attachments Only",
|
|
28
|
+
name: "attachmentsOnly",
|
|
29
|
+
type: "boolean",
|
|
30
30
|
default: false,
|
|
31
|
-
description:
|
|
31
|
+
description: "Whether to import only the attachments of e-mail files and discard the e-mail body",
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
|
-
displayName:
|
|
35
|
-
name:
|
|
36
|
-
type:
|
|
34
|
+
displayName: "Direction",
|
|
35
|
+
name: "direction",
|
|
36
|
+
type: "options",
|
|
37
37
|
options: [
|
|
38
|
-
{ name:
|
|
39
|
-
{ name:
|
|
38
|
+
{ name: "Incoming", value: "incoming" },
|
|
39
|
+
{ name: "Outgoing", value: "outgoing" },
|
|
40
40
|
],
|
|
41
|
-
default:
|
|
41
|
+
default: "incoming",
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
|
-
displayName:
|
|
45
|
-
name:
|
|
46
|
-
type:
|
|
47
|
-
default:
|
|
48
|
-
placeholder:
|
|
49
|
-
description:
|
|
44
|
+
displayName: "File Filter",
|
|
45
|
+
name: "fileFilter",
|
|
46
|
+
type: "string",
|
|
47
|
+
default: "",
|
|
48
|
+
placeholder: "*.pdf",
|
|
49
|
+
description: "A glob that selects which files to import from archives such as ZIP files or e-mails",
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
|
-
displayName:
|
|
53
|
-
name:
|
|
54
|
-
type:
|
|
52
|
+
displayName: "Flatten Archives",
|
|
53
|
+
name: "flattenArchives",
|
|
54
|
+
type: "boolean",
|
|
55
55
|
default: false,
|
|
56
|
-
description:
|
|
56
|
+
description: "Whether to treat every ZIP file as a container of independent files, each becoming its own item",
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
|
-
displayName:
|
|
60
|
-
name:
|
|
61
|
-
type:
|
|
62
|
-
typeOptions: { loadOptionsMethod:
|
|
63
|
-
default:
|
|
59
|
+
displayName: "Folder Name or ID",
|
|
60
|
+
name: "folder",
|
|
61
|
+
type: "options",
|
|
62
|
+
typeOptions: { loadOptionsMethod: "getFolders" },
|
|
63
|
+
default: "",
|
|
64
64
|
description: 'The new items go into this folder. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
|
-
displayName:
|
|
68
|
-
name:
|
|
69
|
-
type:
|
|
70
|
-
default:
|
|
71
|
-
placeholder:
|
|
72
|
-
description:
|
|
67
|
+
displayName: "Language",
|
|
68
|
+
name: "language",
|
|
69
|
+
type: "string",
|
|
70
|
+
default: "",
|
|
71
|
+
placeholder: "eng",
|
|
72
|
+
description: "Three-letter code of the document language, such as eng or deu. Defaults to the language in your Docspell settings.",
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
|
-
displayName:
|
|
76
|
-
name:
|
|
77
|
-
type:
|
|
75
|
+
displayName: "One Item for All Files",
|
|
76
|
+
name: "oneItem",
|
|
77
|
+
type: "boolean",
|
|
78
78
|
default: false,
|
|
79
|
-
description:
|
|
79
|
+
description: "Whether to put all files of an upload into a single Docspell item instead of one item per file",
|
|
80
80
|
},
|
|
81
81
|
{
|
|
82
|
-
displayName:
|
|
83
|
-
name:
|
|
84
|
-
type:
|
|
82
|
+
displayName: "Skip Duplicates",
|
|
83
|
+
name: "skipDuplicates",
|
|
84
|
+
type: "boolean",
|
|
85
85
|
default: false,
|
|
86
|
-
description:
|
|
86
|
+
description: "Whether to skip a file that Docspell already has, found by its checksum",
|
|
87
87
|
},
|
|
88
88
|
{
|
|
89
|
-
displayName:
|
|
90
|
-
name:
|
|
91
|
-
type:
|
|
92
|
-
typeOptions: { loadOptionsMethod:
|
|
89
|
+
displayName: "Tag Names or IDs",
|
|
90
|
+
name: "tags",
|
|
91
|
+
type: "multiOptions",
|
|
92
|
+
typeOptions: { loadOptionsMethod: "getTags" },
|
|
93
93
|
default: [],
|
|
94
94
|
description: 'A tag that does not exist is an error. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
95
95
|
},
|
|
@@ -99,12 +99,12 @@ exports.itemUploadDescription = [
|
|
|
99
99
|
async function executeItemUpload(context, itemIndex) {
|
|
100
100
|
var _a, _b, _c, _d, _e;
|
|
101
101
|
const fail = (message) => new n8n_workflow_1.NodeOperationError(context.getNode(), message, { itemIndex });
|
|
102
|
-
const propertyNames = (0, GenericFunctions_1.splitList)(context.getNodeParameter(
|
|
102
|
+
const propertyNames = (0, GenericFunctions_1.splitList)(context.getNodeParameter("binaryPropertyName", itemIndex, "data"));
|
|
103
103
|
if (propertyNames.length === 0)
|
|
104
|
-
throw fail(
|
|
105
|
-
const options = context.getNodeParameter(
|
|
106
|
-
const language = String((_a = options.language) !== null && _a !== void 0 ? _a :
|
|
107
|
-
if (language !==
|
|
104
|
+
throw fail("Name the binary field that holds the file");
|
|
105
|
+
const options = context.getNodeParameter("options", itemIndex, {});
|
|
106
|
+
const language = String((_a = options.language) !== null && _a !== void 0 ? _a : "").trim();
|
|
107
|
+
if (language !== "" && !/^[a-z]{3}$/i.test(language)) {
|
|
108
108
|
throw fail(`Language "${language}" is not a three-letter code such as eng or deu`);
|
|
109
109
|
}
|
|
110
110
|
if (options.oneItem === true && options.flattenArchives === true) {
|
|
@@ -129,35 +129,46 @@ async function executeItemUpload(context, itemIndex) {
|
|
|
129
129
|
meta.flattenArchives = true;
|
|
130
130
|
if (options.attachmentsOnly === true)
|
|
131
131
|
meta.attachmentsOnly = true;
|
|
132
|
-
if (language !==
|
|
132
|
+
if (language !== "")
|
|
133
133
|
meta.language = language.toLowerCase();
|
|
134
134
|
if (options.fileFilter)
|
|
135
135
|
meta.fileFilter = options.fileFilter;
|
|
136
|
-
const folder = String((_c = options.folder) !== null && _c !== void 0 ? _c :
|
|
137
|
-
if (folder !==
|
|
138
|
-
const { items } = (await (0, GenericFunctions_1.docspellApiRequest)(context, {
|
|
136
|
+
const folder = String((_c = options.folder) !== null && _c !== void 0 ? _c : "").trim();
|
|
137
|
+
if (folder !== "") {
|
|
138
|
+
const { items } = (await (0, GenericFunctions_1.docspellApiRequest)(context, {
|
|
139
|
+
method: "GET",
|
|
140
|
+
endpoint: "/sec/folder",
|
|
141
|
+
}));
|
|
139
142
|
const found = (_d = items.find((entry) => entry.id === folder)) !== null && _d !== void 0 ? _d : items.find((entry) => entry.name === folder);
|
|
140
143
|
if (!found)
|
|
141
144
|
throw fail(`Folder "${folder}" was not found in Docspell`);
|
|
142
145
|
meta.folder = found.id;
|
|
143
146
|
}
|
|
144
|
-
if (
|
|
145
|
-
throw fail(
|
|
147
|
+
if ("tags" in options && (0, GenericFunctions_1.hasMissingTag)(options.tags)) {
|
|
148
|
+
throw fail("The tags value is empty (null or undefined). Leave the field empty for no tags.");
|
|
146
149
|
}
|
|
147
150
|
const wantedTags = (0, GenericFunctions_1.tagTokens)(options.tags);
|
|
148
151
|
if (wantedTags.length > 0) {
|
|
149
152
|
const { names, unknown } = await (0, GenericFunctions_1.resolveTags)(context, wantedTags);
|
|
150
153
|
if (unknown.length > 0) {
|
|
151
|
-
throw fail(`Tag${unknown.length > 1 ?
|
|
154
|
+
throw fail(`Tag${unknown.length > 1 ? "s" : ""} not found in Docspell: ${unknown.map((tag) => `"${tag}"`).join(", ")}`);
|
|
152
155
|
}
|
|
153
156
|
meta.tags = { items: names };
|
|
154
157
|
}
|
|
155
|
-
form.append(
|
|
158
|
+
form.append("meta", new Blob([JSON.stringify(meta)], { type: "application/json" }));
|
|
156
159
|
for (const { blob, fileName } of files)
|
|
157
|
-
form.append(
|
|
158
|
-
const result = await (0, GenericFunctions_1.docspellApiRequest)(context, {
|
|
160
|
+
form.append("file", blob, fileName);
|
|
161
|
+
const result = await (0, GenericFunctions_1.docspellApiRequest)(context, {
|
|
162
|
+
method: "POST",
|
|
163
|
+
endpoint: "/sec/upload/item",
|
|
164
|
+
body: form,
|
|
165
|
+
});
|
|
159
166
|
if (result.success === false)
|
|
160
167
|
throw fail(`Docspell did not accept the upload: ${String(result.message)}`);
|
|
161
|
-
return context.helpers.constructExecutionMetaData(context.helpers.returnJsonArray({
|
|
168
|
+
return context.helpers.constructExecutionMetaData(context.helpers.returnJsonArray({
|
|
169
|
+
success: true,
|
|
170
|
+
message: String((_e = result.message) !== null && _e !== void 0 ? _e : ""),
|
|
171
|
+
files: fileNames,
|
|
172
|
+
}), { itemData: { item: itemIndex } });
|
|
162
173
|
}
|
|
163
174
|
//# sourceMappingURL=upload.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.js","sourceRoot":"","sources":["../../../../../nodes/Docspell/resources/item/upload.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"upload.js","sourceRoot":"","sources":["../../../../../nodes/Docspell/resources/item/upload.ts"],"names":[],"mappings":";;;AAsHA,8CA0FC;AA1MD,+CAAkD;AAElD,uEAM0C;AAE1C,MAAM,IAAI,GAAG,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;AAE9C,QAAA,qBAAqB,GAAsB;IACtD;QACE,WAAW,EAAE,oBAAoB;QACjC,IAAI,EAAE,oBAAoB;QAC1B,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,MAAM;QACf,WAAW,EACT,sHAAsH;QACxH,cAAc,EAAE,EAAE,IAAI,EAAE;KACzB;IACD;QAC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AS;KACjB,CAAC,EACF,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,CAClC,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from "n8n-workflow";
|
|
2
2
|
export declare const organizationGetDescription: INodeProperties[];
|
|
3
3
|
export declare function executeOrganizationGet(context: IExecuteFunctions, itemIndex: number): Promise<INodeExecutionData[]>;
|
|
@@ -6,21 +6,21 @@ const n8n_workflow_1 = require("n8n-workflow");
|
|
|
6
6
|
const GenericFunctions_1 = require("../../../Common/GenericFunctions");
|
|
7
7
|
exports.organizationGetDescription = [
|
|
8
8
|
{
|
|
9
|
-
displayName:
|
|
10
|
-
name:
|
|
11
|
-
type:
|
|
9
|
+
displayName: "Organization ID",
|
|
10
|
+
name: "organizationId",
|
|
11
|
+
type: "string",
|
|
12
12
|
required: true,
|
|
13
|
-
default:
|
|
14
|
-
description:
|
|
15
|
-
displayOptions: { show: { resource: [
|
|
13
|
+
default: "",
|
|
14
|
+
description: "The ID of the organization, such as the correspondent organization of an item",
|
|
15
|
+
displayOptions: { show: { resource: ["organization"], operation: ["get"] } },
|
|
16
16
|
},
|
|
17
17
|
];
|
|
18
18
|
async function executeOrganizationGet(context, itemIndex) {
|
|
19
|
-
const organizationId = context.getNodeParameter(
|
|
19
|
+
const organizationId = context.getNodeParameter("organizationId", itemIndex, "").trim();
|
|
20
20
|
if (!organizationId) {
|
|
21
|
-
throw new n8n_workflow_1.NodeOperationError(context.getNode(),
|
|
21
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), "The Organization ID is empty", { itemIndex });
|
|
22
22
|
}
|
|
23
|
-
const organization = await (0, GenericFunctions_1.docspellApiRequest)(context, { method:
|
|
23
|
+
const organization = await (0, GenericFunctions_1.docspellApiRequest)(context, { method: "GET", endpoint: `/sec/organization/${encodeURIComponent(organizationId)}` }, { 404: `Organization "${organizationId}" was not found` });
|
|
24
24
|
return context.helpers.constructExecutionMetaData(context.helpers.returnJsonArray(organization), {
|
|
25
25
|
itemData: { item: itemIndex },
|
|
26
26
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../../../nodes/Docspell/resources/organization/get.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../../../nodes/Docspell/resources/organization/get.ts"],"names":[],"mappings":";;;AAsBA,wDAuBC;AAvCD,+CAAkD;AAElD,uEAAsE;AAEzD,QAAA,0BAA0B,GAAsB;IAC3D;QACE,WAAW,EAAE,iBAAiB;QAC9B,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,+EAA+E;QAC5F,cAAc,EAAE,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE;KAC7E;CACF,CAAC;AAEK,KAAK,UAAU,sBAAsB,CAC1C,OAA0B,EAC1B,SAAiB;IAEjB,MAAM,cAAc,GAClB,OAAO,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,SAAS,EAAE,EAAE,CACzD,CAAC,IAAI,EAAE,CAAC;IACT,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,iCAAkB,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,8BAA8B,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;IACjG,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,IAAA,qCAAkB,EAC3C,OAAO,EACP,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,qBAAqB,kBAAkB,CAAC,cAAc,CAAC,EAAE,EAAE,EACtF,EAAE,GAAG,EAAE,iBAAiB,cAAc,iBAAiB,EAAE,CAC1D,CAAC;IAEF,OAAO,OAAO,CAAC,OAAO,CAAC,0BAA0B,CAC/C,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,YAA2B,CAAC,EAC5D;QACE,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KAC9B,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from "n8n-workflow";
|
|
2
2
|
export declare const organizationGetAllDescription: INodeProperties[];
|
|
3
3
|
export declare function executeOrganizationGetAll(context: IExecuteFunctions, itemIndex: number): Promise<INodeExecutionData[]>;
|