n8n-nodes-docspell 0.1.0 → 0.43.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/README.md +29 -3
- package/dist/credentials/DocspellApi.credentials.d.ts +2 -1
- package/dist/credentials/DocspellApi.credentials.js +20 -36
- package/dist/credentials/DocspellApi.credentials.js.map +1 -1
- package/dist/credentials/DocspellSession.d.ts +7 -0
- package/dist/credentials/DocspellSession.js +91 -0
- package/dist/credentials/DocspellSession.js.map +1 -0
- package/dist/credentials/docspell.svg +1 -0
- package/dist/nodes/Common/GenericFunctions.d.ts +31 -0
- package/dist/nodes/Common/GenericFunctions.js +125 -0
- package/dist/nodes/Common/GenericFunctions.js.map +1 -0
- package/dist/nodes/Docspell/Docspell.node.d.ts +12 -2
- package/dist/nodes/Docspell/Docspell.node.js +88 -37
- package/dist/nodes/Docspell/Docspell.node.js.map +1 -1
- package/dist/nodes/Docspell/methods/loadOptions.d.ts +9 -0
- package/dist/nodes/Docspell/methods/loadOptions.js +44 -0
- package/dist/nodes/Docspell/methods/loadOptions.js.map +1 -0
- package/dist/nodes/Docspell/resources/attachment/download.d.ts +4 -0
- package/dist/nodes/Docspell/resources/attachment/download.js +89 -0
- package/dist/nodes/Docspell/resources/attachment/download.js.map +1 -0
- package/dist/nodes/Docspell/resources/attachment/index.d.ts +2 -0
- package/dist/nodes/Docspell/resources/attachment/index.js +24 -0
- package/dist/nodes/Docspell/resources/attachment/index.js.map +1 -0
- package/dist/nodes/Docspell/resources/item/get.d.ts +3 -0
- package/dist/nodes/Docspell/resources/item/get.js +28 -0
- package/dist/nodes/Docspell/resources/item/get.js.map +1 -0
- package/dist/nodes/Docspell/resources/item/index.d.ts +2 -0
- package/dist/nodes/Docspell/resources/item/index.js +56 -0
- package/dist/nodes/Docspell/resources/item/index.js.map +1 -0
- package/dist/nodes/Docspell/resources/item/search.d.ts +10 -0
- package/dist/nodes/Docspell/resources/item/search.js +104 -0
- package/dist/nodes/Docspell/resources/item/search.js.map +1 -0
- package/dist/nodes/Docspell/resources/item/update.d.ts +13 -0
- package/dist/nodes/Docspell/resources/item/update.js +271 -0
- package/dist/nodes/Docspell/resources/item/update.js.map +1 -0
- package/dist/nodes/Docspell/resources/item/updateMany.d.ts +3 -0
- package/dist/nodes/Docspell/resources/item/updateMany.js +147 -0
- package/dist/nodes/Docspell/resources/item/updateMany.js.map +1 -0
- package/dist/nodes/Docspell/resources/item/upload.d.ts +3 -0
- package/dist/nodes/Docspell/resources/item/upload.js +163 -0
- package/dist/nodes/Docspell/resources/item/upload.js.map +1 -0
- package/dist/nodes/Docspell/resources/organization/get.d.ts +3 -0
- package/dist/nodes/Docspell/resources/organization/get.js +28 -0
- package/dist/nodes/Docspell/resources/organization/get.js.map +1 -0
- package/dist/nodes/Docspell/resources/organization/getAll.d.ts +3 -0
- package/dist/nodes/Docspell/resources/organization/getAll.js +50 -0
- package/dist/nodes/Docspell/resources/organization/getAll.js.map +1 -0
- package/dist/nodes/Docspell/resources/organization/index.d.ts +2 -0
- package/dist/nodes/Docspell/resources/organization/index.js +32 -0
- package/dist/nodes/Docspell/resources/organization/index.js.map +1 -0
- package/dist/package.json +58 -22
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +58 -22
- package/dist/nodes/Docspell/openapi.json +0 -12493
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LABEL_OF = exports.ENDPOINT_OF = exports.itemUpdateDescription = exports.removeCustomFieldsProperty = exports.customFieldsProperty = exports.updateFieldOptions = void 0;
|
|
4
|
+
exports.executeItemUpdate = executeItemUpdate;
|
|
5
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
|
+
const GenericFunctions_1 = require("../../../Common/GenericFunctions");
|
|
7
|
+
const show = { resource: ['item'], operation: ['update'] };
|
|
8
|
+
exports.updateFieldOptions = [
|
|
9
|
+
{
|
|
10
|
+
displayName: 'Concerning Equipment Name or ID',
|
|
11
|
+
name: 'concEquipment',
|
|
12
|
+
type: 'options',
|
|
13
|
+
typeOptions: { loadOptionsMethod: 'getEquipment' },
|
|
14
|
+
default: '',
|
|
15
|
+
description: 'None removes the current one. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
displayName: 'Concerning Person Name or ID',
|
|
19
|
+
name: 'concPerson',
|
|
20
|
+
type: 'options',
|
|
21
|
+
typeOptions: { loadOptionsMethod: 'getPersons' },
|
|
22
|
+
default: '',
|
|
23
|
+
description: 'None removes the current one. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
displayName: 'Correspondent Organization Name or ID',
|
|
27
|
+
name: 'corrOrg',
|
|
28
|
+
type: 'options',
|
|
29
|
+
typeOptions: { loadOptionsMethod: 'getOrganizations' },
|
|
30
|
+
default: '',
|
|
31
|
+
description: 'None removes the current one. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
displayName: 'Correspondent Person Name or ID',
|
|
35
|
+
name: 'corrPerson',
|
|
36
|
+
type: 'options',
|
|
37
|
+
typeOptions: { loadOptionsMethod: 'getPersons' },
|
|
38
|
+
default: '',
|
|
39
|
+
description: 'None removes the current one. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
displayName: 'Direction',
|
|
43
|
+
name: 'direction',
|
|
44
|
+
type: 'options',
|
|
45
|
+
default: 'incoming',
|
|
46
|
+
options: [
|
|
47
|
+
{ name: 'Incoming', value: 'incoming' },
|
|
48
|
+
{ name: 'Outgoing', value: 'outgoing' },
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
{ displayName: 'Due Date', name: 'dueDate', type: 'dateTime', default: '', description: 'Leave empty to remove' },
|
|
52
|
+
{
|
|
53
|
+
displayName: 'Folder Name or ID',
|
|
54
|
+
name: 'folder',
|
|
55
|
+
type: 'options',
|
|
56
|
+
typeOptions: { loadOptionsMethod: 'getFolders' },
|
|
57
|
+
default: '',
|
|
58
|
+
description: 'None removes the current one. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
59
|
+
},
|
|
60
|
+
{ displayName: 'Item Date', name: 'itemDate', type: 'dateTime', default: '', description: 'Leave empty to remove' },
|
|
61
|
+
{ displayName: 'Name', name: 'name', type: 'string', default: '', description: 'The new name of the item. It cannot be empty.' },
|
|
62
|
+
{ displayName: 'Notes', name: 'notes', type: 'string', typeOptions: { rows: 4 }, default: '', description: 'Leave empty to remove the notes' },
|
|
63
|
+
{
|
|
64
|
+
displayName: 'Tag Names or IDs',
|
|
65
|
+
name: 'tags',
|
|
66
|
+
type: 'multiOptions',
|
|
67
|
+
typeOptions: { loadOptionsMethod: 'getTags' },
|
|
68
|
+
default: [],
|
|
69
|
+
description: 'A tag that does not exist is an error. With Replace, choosing none removes all tags. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
displayName: 'Tags Mode',
|
|
73
|
+
name: 'tagsMode',
|
|
74
|
+
type: 'options',
|
|
75
|
+
default: 'replace',
|
|
76
|
+
description: 'What to do with the tags listed under Tags',
|
|
77
|
+
options: [
|
|
78
|
+
{ name: 'Replace', value: 'replace', description: 'The item gets exactly these tags' },
|
|
79
|
+
{ name: 'Add', value: 'add', description: 'Keep the current tags and add these' },
|
|
80
|
+
{ name: 'Remove', value: 'remove', description: 'Remove only these tags' },
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
const customFieldsProperty = (name, show) => ({
|
|
85
|
+
displayName: 'Custom Fields',
|
|
86
|
+
name,
|
|
87
|
+
type: 'fixedCollection',
|
|
88
|
+
typeOptions: { multipleValues: true },
|
|
89
|
+
placeholder: 'Add Custom Field',
|
|
90
|
+
default: {},
|
|
91
|
+
description: 'Custom fields to set. The field must already exist in Docspell.',
|
|
92
|
+
displayOptions: { show },
|
|
93
|
+
options: [
|
|
94
|
+
{
|
|
95
|
+
displayName: 'Field',
|
|
96
|
+
name: 'values',
|
|
97
|
+
values: [
|
|
98
|
+
{
|
|
99
|
+
displayName: 'Field Name or ID',
|
|
100
|
+
name: 'field',
|
|
101
|
+
type: 'options',
|
|
102
|
+
typeOptions: { loadOptionsMethod: 'getCustomFields' },
|
|
103
|
+
default: '',
|
|
104
|
+
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
|
105
|
+
},
|
|
106
|
+
{ displayName: 'Value', name: 'value', type: 'string', default: '' },
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
});
|
|
111
|
+
exports.customFieldsProperty = customFieldsProperty;
|
|
112
|
+
const removeCustomFieldsProperty = (show) => ({
|
|
113
|
+
displayName: 'Remove Custom Field Names or IDs',
|
|
114
|
+
name: 'removeCustomFields',
|
|
115
|
+
type: 'multiOptions',
|
|
116
|
+
typeOptions: { loadOptionsMethod: 'getCustomFields' },
|
|
117
|
+
default: [],
|
|
118
|
+
description: 'Custom fields whose value is removed. An item that does not have the field is left as it is. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
119
|
+
displayOptions: { show },
|
|
120
|
+
});
|
|
121
|
+
exports.removeCustomFieldsProperty = removeCustomFieldsProperty;
|
|
122
|
+
exports.itemUpdateDescription = [
|
|
123
|
+
{
|
|
124
|
+
displayName: 'Item ID',
|
|
125
|
+
name: 'itemId',
|
|
126
|
+
type: 'string',
|
|
127
|
+
required: true,
|
|
128
|
+
default: '',
|
|
129
|
+
description: 'The ID of the item, as returned by Search',
|
|
130
|
+
displayOptions: { show },
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
displayName: 'Update Fields',
|
|
134
|
+
name: 'updateFields',
|
|
135
|
+
type: 'collection',
|
|
136
|
+
placeholder: 'Add Field',
|
|
137
|
+
default: {},
|
|
138
|
+
description: 'Only the fields added here are changed. Where noted, an empty value removes the current one.',
|
|
139
|
+
displayOptions: { show },
|
|
140
|
+
options: exports.updateFieldOptions,
|
|
141
|
+
},
|
|
142
|
+
(0, exports.customFieldsProperty)('customFields', show),
|
|
143
|
+
(0, exports.removeCustomFieldsProperty)(show),
|
|
144
|
+
];
|
|
145
|
+
exports.ENDPOINT_OF = {
|
|
146
|
+
concEquipment: 'concEquipment',
|
|
147
|
+
concPerson: 'concPerson',
|
|
148
|
+
corrOrg: 'corrOrg',
|
|
149
|
+
corrPerson: 'corrPerson',
|
|
150
|
+
};
|
|
151
|
+
exports.LABEL_OF = {
|
|
152
|
+
concEquipment: 'concerning equipment',
|
|
153
|
+
concPerson: 'concerning person',
|
|
154
|
+
corrOrg: 'correspondent organization',
|
|
155
|
+
corrPerson: 'correspondent person',
|
|
156
|
+
};
|
|
157
|
+
async function executeItemUpdate(context, itemIndex) {
|
|
158
|
+
var _a, _b;
|
|
159
|
+
const fail = (message) => new n8n_workflow_1.NodeOperationError(context.getNode(), message, { itemIndex });
|
|
160
|
+
const itemId = context.getNodeParameter('itemId', itemIndex, '').trim();
|
|
161
|
+
if (!itemId)
|
|
162
|
+
throw fail('The Item ID is empty');
|
|
163
|
+
const itemPath = `/sec/item/${encodeURIComponent(itemId)}`;
|
|
164
|
+
const fields = context.getNodeParameter('updateFields', itemIndex, {});
|
|
165
|
+
const customFields = ((_a = context.getNodeParameter('customFields', itemIndex, {})
|
|
166
|
+
.values) !== null && _a !== void 0 ? _a : []).filter((entry) => entry.field.trim() !== '');
|
|
167
|
+
const removeCustomFields = (0, GenericFunctions_1.tagTokens)(context.getNodeParameter('removeCustomFields', itemIndex, []));
|
|
168
|
+
if (Object.keys(fields).length === 0 && customFields.length === 0 && removeCustomFields.length === 0) {
|
|
169
|
+
throw fail('Choose at least one field to update');
|
|
170
|
+
}
|
|
171
|
+
if ('name' in fields && String(fields.name).trim() === '')
|
|
172
|
+
throw fail('The name cannot be empty');
|
|
173
|
+
if ('tags' in fields && (0, GenericFunctions_1.hasMissingTag)(fields.tags)) {
|
|
174
|
+
throw fail('The tags value is empty (null or undefined). Leave the field empty to remove all tags.');
|
|
175
|
+
}
|
|
176
|
+
const fieldsToRemove = await (0, GenericFunctions_1.resolveRemovedCustomFields)(context, removeCustomFields, customFields.map((entry) => entry.field.trim()), fail);
|
|
177
|
+
const itemDate = 'itemDate' in fields ? (0, GenericFunctions_1.dateBody)('Item Date', fields.itemDate, fail) : undefined;
|
|
178
|
+
const dueDate = 'dueDate' in fields ? (0, GenericFunctions_1.dateBody)('Due Date', fields.dueDate, fail) : undefined;
|
|
179
|
+
const applied = [];
|
|
180
|
+
const put = async (label, method, endpoint, body) => {
|
|
181
|
+
const result = await (0, GenericFunctions_1.docspellApiRequest)(context, { method, endpoint: `${itemPath}${endpoint}`, body });
|
|
182
|
+
if (result.success === false) {
|
|
183
|
+
const reason = result.message === 'Not found' ? `item "${itemId}" was not found` : String(result.message);
|
|
184
|
+
const done = applied.length > 0 ? ` (already applied: ${applied.join(', ')})` : '';
|
|
185
|
+
throw fail(`Could not update the ${label}: ${reason}${done}`);
|
|
186
|
+
}
|
|
187
|
+
applied.push(label);
|
|
188
|
+
};
|
|
189
|
+
const steps = [];
|
|
190
|
+
if ('name' in fields)
|
|
191
|
+
steps.push({ label: 'name', run: () => put('name', 'PUT', '/name', { text: fields.name }) });
|
|
192
|
+
if ('notes' in fields) {
|
|
193
|
+
steps.push({ label: 'notes', run: () => put('notes', 'PUT', '/notes', fields.notes === '' ? { text: null } : { text: fields.notes }) });
|
|
194
|
+
}
|
|
195
|
+
if ('direction' in fields) {
|
|
196
|
+
steps.push({ label: 'direction', run: () => put('direction', 'PUT', '/direction', { direction: fields.direction }) });
|
|
197
|
+
}
|
|
198
|
+
if (itemDate)
|
|
199
|
+
steps.push({ label: 'item date', run: () => put('item date', 'PUT', '/date', itemDate) });
|
|
200
|
+
if (dueDate)
|
|
201
|
+
steps.push({ label: 'due date', run: () => put('due date', 'PUT', '/duedate', dueDate) });
|
|
202
|
+
if ('folder' in fields) {
|
|
203
|
+
steps.push({ label: 'folder', run: () => put('folder', 'PUT', '/folder', fields.folder === '' ? { id: null } : { id: fields.folder }) });
|
|
204
|
+
}
|
|
205
|
+
for (const key of Object.keys(exports.ENDPOINT_OF)) {
|
|
206
|
+
if (key in fields) {
|
|
207
|
+
steps.push({
|
|
208
|
+
label: exports.LABEL_OF[key],
|
|
209
|
+
run: () => put(exports.LABEL_OF[key], 'PUT', `/${exports.ENDPOINT_OF[key]}`, fields[key] === '' ? { id: null } : { id: fields[key] }),
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if ('tags' in fields) {
|
|
214
|
+
const wanted = (0, GenericFunctions_1.tagTokens)(fields.tags);
|
|
215
|
+
const mode = (_b = fields.tagsMode) !== null && _b !== void 0 ? _b : 'replace';
|
|
216
|
+
const { ids, unknown } = await (0, GenericFunctions_1.resolveTags)(context, wanted);
|
|
217
|
+
if (unknown.length > 0) {
|
|
218
|
+
throw fail(`Tag${unknown.length > 1 ? 's' : ''} not found in Docspell: ${unknown.map((tag) => `"${tag}"`).join(', ')}`);
|
|
219
|
+
}
|
|
220
|
+
if (mode === 'remove') {
|
|
221
|
+
if (ids.length > 0)
|
|
222
|
+
steps.push({ label: 'tags', run: () => put('tags', 'POST', '/tagsremove', { items: ids }) });
|
|
223
|
+
}
|
|
224
|
+
else if (mode === 'add') {
|
|
225
|
+
if (ids.length > 0) {
|
|
226
|
+
steps.push({
|
|
227
|
+
label: 'tags',
|
|
228
|
+
run: async () => {
|
|
229
|
+
var _a;
|
|
230
|
+
const item = (await (0, GenericFunctions_1.docspellApiRequest)(context, { method: 'GET', endpoint: itemPath }));
|
|
231
|
+
const current = ((_a = item.tags) !== null && _a !== void 0 ? _a : []).map((tag) => tag.id);
|
|
232
|
+
await put('tags', 'PUT', '/tags', { items: [...new Set([...current, ...ids])] });
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
steps.push({ label: 'tags', run: () => put('tags', 'PUT', '/tags', { items: ids }) });
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
for (const { field, value } of customFields) {
|
|
242
|
+
const label = `custom field "${field.trim()}"`;
|
|
243
|
+
steps.push({ label, run: () => put(label, 'PUT', '/customfield', { field: field.trim(), value }) });
|
|
244
|
+
}
|
|
245
|
+
for (const field of fieldsToRemove) {
|
|
246
|
+
const label = `removal of custom field "${field.name}"`;
|
|
247
|
+
steps.push({
|
|
248
|
+
label,
|
|
249
|
+
run: async () => {
|
|
250
|
+
var _a;
|
|
251
|
+
const current = (await (0, GenericFunctions_1.docspellApiRequest)(context, { method: 'GET', endpoint: itemPath }));
|
|
252
|
+
if (((_a = current.customfields) !== null && _a !== void 0 ? _a : []).some((entry) => entry.id === field.id)) {
|
|
253
|
+
await put(label, 'DELETE', `/customfield/${encodeURIComponent(field.id)}`, {});
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
let item;
|
|
259
|
+
try {
|
|
260
|
+
for (const step of steps)
|
|
261
|
+
await step.run();
|
|
262
|
+
item = await (0, GenericFunctions_1.docspellApiRequest)(context, { method: 'GET', endpoint: itemPath }, { 404: `Item "${itemId}" was not found` });
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
return (0, GenericFunctions_1.rethrowWithApplied)(applied, error, fail);
|
|
266
|
+
}
|
|
267
|
+
return context.helpers.constructExecutionMetaData(context.helpers.returnJsonArray(item), {
|
|
268
|
+
itemData: { item: itemIndex },
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../../nodes/Docspell/resources/item/update.ts"],"names":[],"mappings":";;;AAgLA,8CA2HC;AA1SD,+CAAkD;AAGlD,uEAAuK;AAEvK,MAAM,IAAI,GAAG,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;AAG9C,QAAA,kBAAkB,GAAsB;IACpD;QACC,WAAW,EAAE,iCAAiC;QAC9C,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,EAAE,iBAAiB,EAAE,cAAc,EAAE;QAClD,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,+IAA+I;KAC5J;IACD;QACC,WAAW,EAAE,8BAA8B;QAC3C,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,EAAE,iBAAiB,EAAE,YAAY,EAAE;QAChD,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,+IAA+I;KAC5J;IACD;QACC,WAAW,EAAE,uCAAuC;QACpD,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,EAAE,iBAAiB,EAAE,kBAAkB,EAAE;QACtD,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,+IAA+I;KAC5J;IACD;QACC,WAAW,EAAE,iCAAiC;QAC9C,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,EAAE,iBAAiB,EAAE,YAAY,EAAE;QAChD,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,+IAA+I;KAC5J;IACD;QACC,WAAW,EAAE,WAAW;QACxB,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,UAAU;QACnB,OAAO,EAAE;YACR,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EA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EAAE,EAAE,CAAC,CAAC;gBAChF,CAAC;YACF,CAAC;SACD,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,IAAiB,CAAC;IACtB,IAAI,CAAC;QACJ,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;QAC3C,IAAI,GAAG,MAAM,IAAA,qCAAkB,EAAC,OAAO,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,EAAE,SAAS,MAAM,iBAAiB,EAAE,CAAC,CAAC;IAC5H,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,IAAA,qCAAkB,EAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,0BAA0B,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE;QACxF,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KAC7B,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare const itemUpdateManyDescription: INodeProperties[];
|
|
3
|
+
export declare function executeItemUpdateMany(context: IExecuteFunctions, itemIndex: number): Promise<INodeExecutionData[]>;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.itemUpdateManyDescription = void 0;
|
|
4
|
+
exports.executeItemUpdateMany = executeItemUpdateMany;
|
|
5
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
|
+
const GenericFunctions_1 = require("../../../Common/GenericFunctions");
|
|
7
|
+
const update_1 = require("./update");
|
|
8
|
+
const show = { resource: ['item'], operation: ['updateMany'] };
|
|
9
|
+
exports.itemUpdateManyDescription = [
|
|
10
|
+
{
|
|
11
|
+
displayName: 'Item IDs',
|
|
12
|
+
name: 'itemIds',
|
|
13
|
+
type: 'string',
|
|
14
|
+
required: true,
|
|
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
|
+
displayOptions: { show },
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
displayName: 'Update Fields',
|
|
21
|
+
name: 'bulkFields',
|
|
22
|
+
type: 'collection',
|
|
23
|
+
placeholder: 'Add Field',
|
|
24
|
+
default: {},
|
|
25
|
+
description: 'Only the fields added here are changed, on every item. Where noted, an empty value removes the current one.',
|
|
26
|
+
displayOptions: { show },
|
|
27
|
+
options: update_1.updateFieldOptions.filter((option) => option.name !== 'notes'),
|
|
28
|
+
},
|
|
29
|
+
(0, update_1.customFieldsProperty)('bulkCustomFields', show),
|
|
30
|
+
(0, update_1.removeCustomFieldsProperty)(show),
|
|
31
|
+
];
|
|
32
|
+
function idList(value) {
|
|
33
|
+
const entries = Array.isArray(value) ? value : [value];
|
|
34
|
+
const ids = entries.flatMap((entry) => String(entry !== null && entry !== void 0 ? entry : '').split(/[\s,]+/)).filter((id) => id !== '');
|
|
35
|
+
return [...new Set(ids)];
|
|
36
|
+
}
|
|
37
|
+
async function executeItemUpdateMany(context, itemIndex) {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
const fail = (message) => new n8n_workflow_1.NodeOperationError(context.getNode(), message, { itemIndex });
|
|
40
|
+
const ids = idList(context.getNodeParameter('itemIds', itemIndex, ''));
|
|
41
|
+
if (ids.length === 0)
|
|
42
|
+
throw fail('No item IDs were given');
|
|
43
|
+
const fields = context.getNodeParameter('bulkFields', itemIndex, {});
|
|
44
|
+
const customFields = ((_a = context.getNodeParameter('bulkCustomFields', itemIndex, {}).values) !== null && _a !== void 0 ? _a : []).filter((entry) => entry.field.trim() !== '');
|
|
45
|
+
const removeTokens = (0, GenericFunctions_1.tagTokens)(context.getNodeParameter('removeCustomFields', itemIndex, []));
|
|
46
|
+
if (Object.keys(fields).length === 0 && customFields.length === 0 && removeTokens.length === 0) {
|
|
47
|
+
throw fail('Choose at least one field to update');
|
|
48
|
+
}
|
|
49
|
+
if ('name' in fields && String(fields.name).trim() === '')
|
|
50
|
+
throw fail('The name cannot be empty');
|
|
51
|
+
if ('tags' in fields && (0, GenericFunctions_1.hasMissingTag)(fields.tags)) {
|
|
52
|
+
throw fail('The tags value is empty (null or undefined). Leave the field empty to remove all tags.');
|
|
53
|
+
}
|
|
54
|
+
const itemDate = 'itemDate' in fields ? (0, GenericFunctions_1.dateBody)('Item Date', fields.itemDate, fail) : undefined;
|
|
55
|
+
const dueDate = 'dueDate' in fields ? (0, GenericFunctions_1.dateBody)('Due Date', fields.dueDate, fail) : undefined;
|
|
56
|
+
const removeCustomFields = (await (0, GenericFunctions_1.resolveRemovedCustomFields)(context, removeTokens, customFields.map((entry) => entry.field.trim()), fail)).map((field) => field.name);
|
|
57
|
+
const current = [];
|
|
58
|
+
const missing = [];
|
|
59
|
+
for (const id of ids) {
|
|
60
|
+
try {
|
|
61
|
+
current.push(await (0, GenericFunctions_1.docspellApiRequest)(context, { method: 'GET', endpoint: `/sec/item/${encodeURIComponent(id)}` }, { 404: `Item "${id}" was not found` }));
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
if (error.httpCode !== '404')
|
|
65
|
+
throw error;
|
|
66
|
+
missing.push(id);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (missing.length > 0) {
|
|
70
|
+
throw fail(`Item${missing.length > 1 ? 's' : ''} not found in Docspell: ${missing.map((id) => `"${id}"`).join(', ')}. Nothing was changed.`);
|
|
71
|
+
}
|
|
72
|
+
const applied = [];
|
|
73
|
+
const put = async (label, method, endpoint, body, items = ids) => {
|
|
74
|
+
const result = await (0, GenericFunctions_1.docspellApiRequest)(context, { method, endpoint: `/sec/items${endpoint}`, body: { items, ...body } });
|
|
75
|
+
if (result.success === false) {
|
|
76
|
+
const done = applied.length > 0 ? ` (already applied: ${applied.join(', ')})` : '';
|
|
77
|
+
throw fail(`Could not update the ${label}: ${String(result.message)}${done}`);
|
|
78
|
+
}
|
|
79
|
+
applied.push(label);
|
|
80
|
+
};
|
|
81
|
+
const steps = [];
|
|
82
|
+
if ('name' in fields)
|
|
83
|
+
steps.push({ label: 'name', run: () => put('name', 'PUT', '/name', { name: fields.name }) });
|
|
84
|
+
if ('direction' in fields) {
|
|
85
|
+
steps.push({ label: 'direction', run: () => put('direction', 'PUT', '/direction', { direction: fields.direction }) });
|
|
86
|
+
}
|
|
87
|
+
if (itemDate)
|
|
88
|
+
steps.push({ label: 'item date', run: () => put('item date', 'PUT', '/date', itemDate) });
|
|
89
|
+
if (dueDate)
|
|
90
|
+
steps.push({ label: 'due date', run: () => put('due date', 'PUT', '/duedate', dueDate) });
|
|
91
|
+
if ('folder' in fields) {
|
|
92
|
+
steps.push({ label: 'folder', run: () => put('folder', 'PUT', '/folder', { ref: fields.folder === '' ? null : fields.folder }) });
|
|
93
|
+
}
|
|
94
|
+
for (const key of Object.keys(update_1.ENDPOINT_OF)) {
|
|
95
|
+
if (key in fields) {
|
|
96
|
+
steps.push({
|
|
97
|
+
label: update_1.LABEL_OF[key],
|
|
98
|
+
run: () => put(update_1.LABEL_OF[key], 'PUT', `/${update_1.ENDPOINT_OF[key]}`, { ref: fields[key] === '' ? null : fields[key] }),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if ('tags' in fields) {
|
|
103
|
+
const mode = (_b = fields.tagsMode) !== null && _b !== void 0 ? _b : 'replace';
|
|
104
|
+
const { ids: tagIds, unknown } = await (0, GenericFunctions_1.resolveTags)(context, (0, GenericFunctions_1.tagTokens)(fields.tags));
|
|
105
|
+
if (unknown.length > 0) {
|
|
106
|
+
throw fail(`Tag${unknown.length > 1 ? 's' : ''} not found in Docspell: ${unknown.map((tag) => `"${tag}"`).join(', ')}`);
|
|
107
|
+
}
|
|
108
|
+
if (mode === 'remove') {
|
|
109
|
+
if (tagIds.length > 0)
|
|
110
|
+
steps.push({ label: 'tags', run: () => put('tags', 'POST', '/tagsremove', { refs: tagIds }) });
|
|
111
|
+
}
|
|
112
|
+
else if (mode === 'add') {
|
|
113
|
+
if (tagIds.length > 0)
|
|
114
|
+
steps.push({ label: 'tags', run: () => put('tags', 'POST', '/tags', { refs: tagIds }) });
|
|
115
|
+
}
|
|
116
|
+
else if (tagIds.length > 0) {
|
|
117
|
+
steps.push({ label: 'tags', run: () => put('tags', 'PUT', '/tags', { refs: tagIds }) });
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
const tagged = ids.filter((_, index) => { var _a; return ((_a = current[index].tags) !== null && _a !== void 0 ? _a : []).length > 0; });
|
|
121
|
+
if (tagged.length > 0)
|
|
122
|
+
steps.push({ label: 'tags', run: () => put('tags', 'PUT', '/tags', { refs: [] }, tagged) });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
for (const { field, value } of customFields) {
|
|
126
|
+
const label = `custom field "${field.trim()}"`;
|
|
127
|
+
steps.push({ label, run: () => put(label, 'PUT', '/customfield', { field: { field: field.trim(), value } }) });
|
|
128
|
+
}
|
|
129
|
+
for (const name of removeCustomFields) {
|
|
130
|
+
const label = `removal of custom field "${name}"`;
|
|
131
|
+
steps.push({ label, run: () => put(label, 'POST', '/customfieldremove', { name }) });
|
|
132
|
+
}
|
|
133
|
+
const result = [];
|
|
134
|
+
try {
|
|
135
|
+
for (const step of steps)
|
|
136
|
+
await step.run();
|
|
137
|
+
for (const id of ids) {
|
|
138
|
+
const item = await (0, GenericFunctions_1.docspellApiRequest)(context, { method: 'GET', endpoint: `/sec/item/${encodeURIComponent(id)}` }, { 404: `Item "${id}" was not found` });
|
|
139
|
+
result.push(...context.helpers.constructExecutionMetaData(context.helpers.returnJsonArray(item), { itemData: { item: itemIndex } }));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
return (0, GenericFunctions_1.rethrowWithApplied)(applied, error, fail);
|
|
144
|
+
}
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=updateMany.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateMany.js","sourceRoot":"","sources":["../../../../../nodes/Docspell/resources/item/updateMany.ts"],"names":[],"mappings":";;;AA8CA,sDAqHC;AAlKD,+CAAkD;AAElD,uEAAuK;AACvK,qCAAuH;AAEvH,MAAM,IAAI,GAAG,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC;AAElD,QAAA,yBAAyB,GAAsB;IAC3D;QACC,WAAW,EAAE,UAAU;QACvB,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,EAAE;QACX,WAAW,EACV,mKAAmK;QACpK,cAAc,EAAE,EAAE,IAAI,EAAE;KACxB;IACD;QACC,WAAW,EAAE,eAAe;QAC5B,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,WAAW;QACxB,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,6GAA6G;QAC1H,cAAc,EAAE,EAAE,IAAI,EAAE;QAExB,OAAO,EAAE,2BAAkB,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC;KACvE;IACD,IAAA,6BAAoB,EAAC,kBAAkB,EAAE,IAAI,CAAC;IAC9C,IAAA,mCAA0B,EAAC,IAAI,CAAC;CAChC,CAAC;AAGF,SAAS,MAAM,CAAC,KAAc;IAC7B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAA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AiB,EAAE,CAAC,CAAC;YAC1J,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,0BAA0B,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC;QACtI,CAAC;IACF,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,IAAA,qCAAkB,EAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare const itemUploadDescription: INodeProperties[];
|
|
3
|
+
export declare function executeItemUpload(context: IExecuteFunctions, itemIndex: number): Promise<INodeExecutionData[]>;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.itemUploadDescription = void 0;
|
|
4
|
+
exports.executeItemUpload = executeItemUpload;
|
|
5
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
6
|
+
const GenericFunctions_1 = require("../../../Common/GenericFunctions");
|
|
7
|
+
const show = { resource: ['item'], operation: ['upload'] };
|
|
8
|
+
exports.itemUploadDescription = [
|
|
9
|
+
{
|
|
10
|
+
displayName: 'Input Binary Field',
|
|
11
|
+
name: 'binaryPropertyName',
|
|
12
|
+
type: 'string',
|
|
13
|
+
required: true,
|
|
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
|
+
displayOptions: { show },
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
displayName: 'Options',
|
|
20
|
+
name: 'options',
|
|
21
|
+
type: 'collection',
|
|
22
|
+
placeholder: 'Add Option',
|
|
23
|
+
default: {},
|
|
24
|
+
displayOptions: { show },
|
|
25
|
+
options: [
|
|
26
|
+
{
|
|
27
|
+
displayName: 'Attachments Only',
|
|
28
|
+
name: 'attachmentsOnly',
|
|
29
|
+
type: 'boolean',
|
|
30
|
+
default: false,
|
|
31
|
+
description: 'Whether to import only the attachments of e-mail files and discard the e-mail body',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
displayName: 'Direction',
|
|
35
|
+
name: 'direction',
|
|
36
|
+
type: 'options',
|
|
37
|
+
options: [
|
|
38
|
+
{ name: 'Incoming', value: 'incoming' },
|
|
39
|
+
{ name: 'Outgoing', value: 'outgoing' },
|
|
40
|
+
],
|
|
41
|
+
default: 'incoming',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
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
|
+
},
|
|
51
|
+
{
|
|
52
|
+
displayName: 'Flatten Archives',
|
|
53
|
+
name: 'flattenArchives',
|
|
54
|
+
type: 'boolean',
|
|
55
|
+
default: false,
|
|
56
|
+
description: 'Whether to treat every ZIP file as a container of independent files, each becoming its own item',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
displayName: 'Folder Name or ID',
|
|
60
|
+
name: 'folder',
|
|
61
|
+
type: 'options',
|
|
62
|
+
typeOptions: { loadOptionsMethod: 'getFolders' },
|
|
63
|
+
default: '',
|
|
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
|
+
},
|
|
66
|
+
{
|
|
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
|
+
},
|
|
74
|
+
{
|
|
75
|
+
displayName: 'One Item for All Files',
|
|
76
|
+
name: 'oneItem',
|
|
77
|
+
type: 'boolean',
|
|
78
|
+
default: false,
|
|
79
|
+
description: 'Whether to put all files of an upload into a single Docspell item instead of one item per file',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
displayName: 'Skip Duplicates',
|
|
83
|
+
name: 'skipDuplicates',
|
|
84
|
+
type: 'boolean',
|
|
85
|
+
default: false,
|
|
86
|
+
description: 'Whether to skip a file that Docspell already has, found by its checksum',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
displayName: 'Tag Names or IDs',
|
|
90
|
+
name: 'tags',
|
|
91
|
+
type: 'multiOptions',
|
|
92
|
+
typeOptions: { loadOptionsMethod: 'getTags' },
|
|
93
|
+
default: [],
|
|
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
|
+
},
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
];
|
|
99
|
+
async function executeItemUpload(context, itemIndex) {
|
|
100
|
+
var _a, _b, _c, _d, _e;
|
|
101
|
+
const fail = (message) => new n8n_workflow_1.NodeOperationError(context.getNode(), message, { itemIndex });
|
|
102
|
+
const propertyNames = (0, GenericFunctions_1.splitList)(context.getNodeParameter('binaryPropertyName', itemIndex, 'data'));
|
|
103
|
+
if (propertyNames.length === 0)
|
|
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
|
+
throw fail(`Language "${language}" is not a three-letter code such as eng or deu`);
|
|
109
|
+
}
|
|
110
|
+
if (options.oneItem === true && options.flattenArchives === true) {
|
|
111
|
+
throw fail('"One Item for All Files" and "Flatten Archives" contradict each other');
|
|
112
|
+
}
|
|
113
|
+
const form = new FormData();
|
|
114
|
+
const fileNames = [];
|
|
115
|
+
const files = [];
|
|
116
|
+
for (const propertyName of propertyNames) {
|
|
117
|
+
const binary = context.helpers.assertBinaryData(itemIndex, propertyName);
|
|
118
|
+
const buffer = await context.helpers.getBinaryDataBuffer(itemIndex, propertyName);
|
|
119
|
+
const fileName = (_b = binary.fileName) !== null && _b !== void 0 ? _b : propertyName;
|
|
120
|
+
fileNames.push(fileName);
|
|
121
|
+
files.push({ blob: new Blob([new Uint8Array(buffer)], { type: binary.mimeType }), fileName });
|
|
122
|
+
}
|
|
123
|
+
const meta = { multiple: options.oneItem !== true };
|
|
124
|
+
if (options.direction)
|
|
125
|
+
meta.direction = options.direction;
|
|
126
|
+
if (options.skipDuplicates === true)
|
|
127
|
+
meta.skipDuplicates = true;
|
|
128
|
+
if (options.flattenArchives === true)
|
|
129
|
+
meta.flattenArchives = true;
|
|
130
|
+
if (options.attachmentsOnly === true)
|
|
131
|
+
meta.attachmentsOnly = true;
|
|
132
|
+
if (language !== '')
|
|
133
|
+
meta.language = language.toLowerCase();
|
|
134
|
+
if (options.fileFilter)
|
|
135
|
+
meta.fileFilter = options.fileFilter;
|
|
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, { method: 'GET', endpoint: '/sec/folder' }));
|
|
139
|
+
const found = (_d = items.find((entry) => entry.id === folder)) !== null && _d !== void 0 ? _d : items.find((entry) => entry.name === folder);
|
|
140
|
+
if (!found)
|
|
141
|
+
throw fail(`Folder "${folder}" was not found in Docspell`);
|
|
142
|
+
meta.folder = found.id;
|
|
143
|
+
}
|
|
144
|
+
if ('tags' in options && (0, GenericFunctions_1.hasMissingTag)(options.tags)) {
|
|
145
|
+
throw fail('The tags value is empty (null or undefined). Leave the field empty for no tags.');
|
|
146
|
+
}
|
|
147
|
+
const wantedTags = (0, GenericFunctions_1.tagTokens)(options.tags);
|
|
148
|
+
if (wantedTags.length > 0) {
|
|
149
|
+
const { names, unknown } = await (0, GenericFunctions_1.resolveTags)(context, wantedTags);
|
|
150
|
+
if (unknown.length > 0) {
|
|
151
|
+
throw fail(`Tag${unknown.length > 1 ? 's' : ''} not found in Docspell: ${unknown.map((tag) => `"${tag}"`).join(', ')}`);
|
|
152
|
+
}
|
|
153
|
+
meta.tags = { items: names };
|
|
154
|
+
}
|
|
155
|
+
form.append('meta', new Blob([JSON.stringify(meta)], { type: 'application/json' }));
|
|
156
|
+
for (const { blob, fileName } of files)
|
|
157
|
+
form.append('file', blob, fileName);
|
|
158
|
+
const result = await (0, GenericFunctions_1.docspellApiRequest)(context, { method: 'POST', endpoint: '/sec/upload/item', body: form });
|
|
159
|
+
if (result.success === false)
|
|
160
|
+
throw fail(`Docspell did not accept the upload: ${String(result.message)}`);
|
|
161
|
+
return context.helpers.constructExecutionMetaData(context.helpers.returnJsonArray({ success: true, message: String((_e = result.message) !== null && _e !== void 0 ? _e : ''), files: fileNames }), { itemData: { item: itemIndex } });
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=upload.js.map
|