n8n-nodes-base 1.31.1 → 1.32.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.
Files changed (61) hide show
  1. package/dist/build.tsbuildinfo +1 -1
  2. package/dist/nodes/Notion/NotionTrigger.node.d.ts +2 -4
  3. package/dist/nodes/Notion/NotionTrigger.node.js +3 -5
  4. package/dist/nodes/Notion/NotionTrigger.node.js.map +1 -1
  5. package/dist/nodes/Notion/{GenericFunctions.d.ts → shared/GenericFunctions.d.ts} +1 -1
  6. package/dist/nodes/Notion/{GenericFunctions.js → shared/GenericFunctions.js} +4 -4
  7. package/dist/nodes/Notion/shared/GenericFunctions.js.map +1 -0
  8. package/dist/nodes/Notion/shared/descriptions/BlockDescription.js.map +1 -0
  9. package/dist/nodes/Notion/shared/descriptions/Blocks.js.map +1 -0
  10. package/dist/nodes/Notion/shared/descriptions/DatabaseDescription.js.map +1 -0
  11. package/dist/nodes/Notion/{DatabasePageDescription.js → shared/descriptions/DatabasePageDescription.js} +1 -1
  12. package/dist/nodes/Notion/shared/descriptions/DatabasePageDescription.js.map +1 -0
  13. package/dist/nodes/Notion/shared/descriptions/Filters.js.map +1 -0
  14. package/dist/nodes/Notion/shared/descriptions/PageDescription.js.map +1 -0
  15. package/dist/nodes/Notion/shared/descriptions/UserDescription.js.map +1 -0
  16. package/dist/nodes/Notion/shared/methods/index.d.ts +1 -0
  17. package/dist/nodes/Notion/shared/methods/index.js +28 -0
  18. package/dist/nodes/Notion/shared/methods/index.js.map +1 -0
  19. package/dist/nodes/Notion/{SearchFunctions.js → shared/methods/listSearch.js} +2 -2
  20. package/dist/nodes/Notion/shared/methods/listSearch.js.map +1 -0
  21. package/dist/nodes/Notion/v1/NotionV1.node.d.ts +2 -4
  22. package/dist/nodes/Notion/v1/NotionV1.node.js +4 -6
  23. package/dist/nodes/Notion/v1/NotionV1.node.js.map +1 -1
  24. package/dist/nodes/Notion/v1/VersionDescription.js +5 -5
  25. package/dist/nodes/Notion/v1/VersionDescription.js.map +1 -1
  26. package/dist/nodes/Notion/v2/NotionV2.node.d.ts +5 -15
  27. package/dist/nodes/Notion/v2/NotionV2.node.js +477 -461
  28. package/dist/nodes/Notion/v2/NotionV2.node.js.map +1 -1
  29. package/dist/nodes/Notion/v2/VersionDescription.js +5 -5
  30. package/dist/nodes/Notion/v2/VersionDescription.js.map +1 -1
  31. package/dist/nodes/Notion/v2/methods/index.d.ts +1 -0
  32. package/dist/nodes/Notion/v2/methods/index.js +28 -0
  33. package/dist/nodes/Notion/v2/methods/index.js.map +1 -0
  34. package/dist/nodes/Notion/v2/methods/loadOptions.d.ts +9 -0
  35. package/dist/nodes/Notion/v2/methods/loadOptions.js +174 -0
  36. package/dist/nodes/Notion/v2/methods/loadOptions.js.map +1 -0
  37. package/dist/types/nodes.json +1 -1
  38. package/package.json +1 -1
  39. package/dist/nodes/Notion/BlockDescription.js.map +0 -1
  40. package/dist/nodes/Notion/Blocks.js.map +0 -1
  41. package/dist/nodes/Notion/DatabaseDescription.js.map +0 -1
  42. package/dist/nodes/Notion/DatabasePageDescription.js.map +0 -1
  43. package/dist/nodes/Notion/Filters.js.map +0 -1
  44. package/dist/nodes/Notion/GenericFunctions.js.map +0 -1
  45. package/dist/nodes/Notion/PageDescription.js.map +0 -1
  46. package/dist/nodes/Notion/SearchFunctions.js.map +0 -1
  47. package/dist/nodes/Notion/UserDescription.js.map +0 -1
  48. /package/dist/nodes/Notion/{BlockDescription.d.ts → shared/descriptions/BlockDescription.d.ts} +0 -0
  49. /package/dist/nodes/Notion/{BlockDescription.js → shared/descriptions/BlockDescription.js} +0 -0
  50. /package/dist/nodes/Notion/{Blocks.d.ts → shared/descriptions/Blocks.d.ts} +0 -0
  51. /package/dist/nodes/Notion/{Blocks.js → shared/descriptions/Blocks.js} +0 -0
  52. /package/dist/nodes/Notion/{DatabaseDescription.d.ts → shared/descriptions/DatabaseDescription.d.ts} +0 -0
  53. /package/dist/nodes/Notion/{DatabaseDescription.js → shared/descriptions/DatabaseDescription.js} +0 -0
  54. /package/dist/nodes/Notion/{DatabasePageDescription.d.ts → shared/descriptions/DatabasePageDescription.d.ts} +0 -0
  55. /package/dist/nodes/Notion/{Filters.d.ts → shared/descriptions/Filters.d.ts} +0 -0
  56. /package/dist/nodes/Notion/{Filters.js → shared/descriptions/Filters.js} +0 -0
  57. /package/dist/nodes/Notion/{PageDescription.d.ts → shared/descriptions/PageDescription.d.ts} +0 -0
  58. /package/dist/nodes/Notion/{PageDescription.js → shared/descriptions/PageDescription.js} +0 -0
  59. /package/dist/nodes/Notion/{UserDescription.d.ts → shared/descriptions/UserDescription.d.ts} +0 -0
  60. /package/dist/nodes/Notion/{UserDescription.js → shared/descriptions/UserDescription.js} +0 -0
  61. /package/dist/nodes/Notion/{SearchFunctions.d.ts → shared/methods/listSearch.d.ts} +0 -0
@@ -1,180 +1,14 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.NotionV2 = void 0;
7
4
  const n8n_workflow_1 = require("n8n-workflow");
8
- const moment_timezone_1 = __importDefault(require("moment-timezone"));
9
- const GenericFunctions_1 = require("../GenericFunctions");
10
- const SearchFunctions_1 = require("../SearchFunctions");
5
+ const GenericFunctions_1 = require("../shared/GenericFunctions");
6
+ const methods_1 = require("../shared/methods");
7
+ const methods_2 = require("./methods");
11
8
  const VersionDescription_1 = require("./VersionDescription");
12
9
  class NotionV2 {
13
10
  constructor(baseDescription) {
14
- this.methods = {
15
- listSearch: {
16
- getDatabases: SearchFunctions_1.getDatabases,
17
- },
18
- loadOptions: {
19
- async getDatabaseProperties() {
20
- const returnData = [];
21
- const databaseId = this.getCurrentNodeParameter('databaseId', {
22
- extractValue: true,
23
- });
24
- const { properties } = await GenericFunctions_1.notionApiRequest.call(this, 'GET', `/databases/${databaseId}`);
25
- for (const key of Object.keys(properties)) {
26
- if (![
27
- 'created_time',
28
- 'last_edited_time',
29
- 'created_by',
30
- 'last_edited_by',
31
- 'formula',
32
- 'rollup',
33
- ].includes(properties[key].type)) {
34
- returnData.push({
35
- name: `${key}`,
36
- value: `${key}|${properties[key].type}`,
37
- });
38
- }
39
- }
40
- returnData.sort((a, b) => {
41
- if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) {
42
- return -1;
43
- }
44
- if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) {
45
- return 1;
46
- }
47
- return 0;
48
- });
49
- return returnData;
50
- },
51
- async getFilterProperties() {
52
- const returnData = [];
53
- const databaseId = this.getCurrentNodeParameter('databaseId', {
54
- extractValue: true,
55
- });
56
- const { properties } = await GenericFunctions_1.notionApiRequest.call(this, 'GET', `/databases/${databaseId}`);
57
- for (const key of Object.keys(properties)) {
58
- returnData.push({
59
- name: `${key}`,
60
- value: `${key}|${properties[key].type}`,
61
- });
62
- }
63
- returnData.sort((a, b) => {
64
- if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) {
65
- return -1;
66
- }
67
- if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) {
68
- return 1;
69
- }
70
- return 0;
71
- });
72
- return returnData;
73
- },
74
- async getBlockTypes() {
75
- return (0, GenericFunctions_1.getBlockTypes)();
76
- },
77
- async getPropertySelectValues() {
78
- const [name, type] = this.getCurrentNodeParameter('&key').split('|');
79
- const databaseId = this.getCurrentNodeParameter('databaseId', {
80
- extractValue: true,
81
- });
82
- const resource = this.getCurrentNodeParameter('resource');
83
- const operation = this.getCurrentNodeParameter('operation');
84
- const { properties } = await GenericFunctions_1.notionApiRequest.call(this, 'GET', `/databases/${databaseId}`);
85
- if (resource === 'databasePage') {
86
- if (['multi_select', 'select', 'status'].includes(type) && operation === 'getAll') {
87
- return properties[name][type].options.map((option) => ({
88
- name: option.name,
89
- value: option.name,
90
- }));
91
- }
92
- else if (['multi_select', 'select', 'status'].includes(type) &&
93
- ['create', 'update'].includes(operation)) {
94
- return properties[name][type].options.map((option) => ({
95
- name: option.name,
96
- value: option.name,
97
- }));
98
- }
99
- }
100
- return properties[name][type].options.map((option) => ({
101
- name: option.name,
102
- value: option.id,
103
- }));
104
- },
105
- async getUsers() {
106
- const returnData = [];
107
- const users = await GenericFunctions_1.notionApiRequestAllItems.call(this, 'results', 'GET', '/users');
108
- for (const user of users) {
109
- if (user.type === 'person') {
110
- returnData.push({
111
- name: user.name,
112
- value: user.id,
113
- });
114
- }
115
- }
116
- return returnData;
117
- },
118
- async getDatabaseIdFromPage() {
119
- const returnData = [];
120
- const pageId = (0, GenericFunctions_1.extractPageId)(this.getCurrentNodeParameter('pageId', { extractValue: true }));
121
- const { parent: { database_id: databaseId }, } = await GenericFunctions_1.notionApiRequest.call(this, 'GET', `/pages/${pageId}`);
122
- const { properties } = await GenericFunctions_1.notionApiRequest.call(this, 'GET', `/databases/${databaseId}`);
123
- for (const key of Object.keys(properties)) {
124
- if (![
125
- 'created_time',
126
- 'last_edited_time',
127
- 'created_by',
128
- 'last_edited_by',
129
- 'formula',
130
- 'rollup',
131
- ].includes(properties[key].type)) {
132
- returnData.push({
133
- name: `${key}`,
134
- value: `${key}|${properties[key].type}`,
135
- });
136
- }
137
- }
138
- returnData.sort((a, b) => {
139
- if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) {
140
- return -1;
141
- }
142
- if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) {
143
- return 1;
144
- }
145
- return 0;
146
- });
147
- return returnData;
148
- },
149
- async getDatabaseOptionsFromPage() {
150
- const pageId = (0, GenericFunctions_1.extractPageId)(this.getCurrentNodeParameter('pageId', { extractValue: true }));
151
- const [name, type] = this.getCurrentNodeParameter('&key').split('|');
152
- const { parent: { database_id: databaseId }, } = await GenericFunctions_1.notionApiRequest.call(this, 'GET', `/pages/${pageId}`);
153
- const { properties } = await GenericFunctions_1.notionApiRequest.call(this, 'GET', `/databases/${databaseId}`);
154
- return properties[name][type].options.map((option) => ({
155
- name: option.name,
156
- value: option.name,
157
- }));
158
- },
159
- async getTimezones() {
160
- const returnData = [];
161
- for (const timezone of moment_timezone_1.default.tz.names()) {
162
- const timezoneName = timezone;
163
- const timezoneId = timezone;
164
- returnData.push({
165
- name: timezoneName,
166
- value: timezoneId,
167
- });
168
- }
169
- returnData.unshift({
170
- name: 'Default',
171
- value: 'default',
172
- description: 'Timezone set in n8n',
173
- });
174
- return returnData;
175
- },
176
- },
177
- };
11
+ this.methods = { listSearch: methods_1.listSearch, loadOptions: methods_2.loadOptions };
178
12
  this.description = {
179
13
  ...baseDescription,
180
14
  ...VersionDescription_1.versionDescription,
@@ -183,135 +17,200 @@ class NotionV2 {
183
17
  async execute() {
184
18
  var _a, _b, _c;
185
19
  const items = this.getInputData();
186
- const returnData = [];
187
- const length = items.length;
188
- let responseData;
189
- const qs = {};
190
- const timezone = this.getTimezone();
191
20
  const resource = this.getNodeParameter('resource', 0);
192
21
  const operation = this.getNodeParameter('operation', 0);
22
+ const itemsLength = items.length;
23
+ const timezone = this.getTimezone();
24
+ const qs = {};
25
+ let returnData = [];
26
+ let responseData;
193
27
  let download = false;
194
28
  if (resource === 'block') {
195
29
  if (operation === 'append') {
196
- for (let i = 0; i < length; i++) {
197
- const blockId = (0, GenericFunctions_1.extractPageId)(this.getNodeParameter('blockId', i, '', { extractValue: true }));
198
- const blockValues = this.getNodeParameter('blockUi.blockValues', i, []);
199
- (0, GenericFunctions_1.extractDatabaseMentionRLC)(blockValues);
200
- const body = {
201
- children: (0, GenericFunctions_1.formatBlocks)(blockValues),
202
- };
203
- const block = await GenericFunctions_1.notionApiRequest.call(this, 'PATCH', `/blocks/${blockId}/children`, body);
204
- const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(block), { itemData: { item: i } });
205
- returnData.push(...executionData);
30
+ for (let i = 0; i < itemsLength; i++) {
31
+ try {
32
+ const blockId = (0, GenericFunctions_1.extractPageId)(this.getNodeParameter('blockId', i, '', { extractValue: true }));
33
+ const blockValues = this.getNodeParameter('blockUi.blockValues', i, []);
34
+ (0, GenericFunctions_1.extractDatabaseMentionRLC)(blockValues);
35
+ const body = {
36
+ children: (0, GenericFunctions_1.formatBlocks)(blockValues),
37
+ };
38
+ const block = await GenericFunctions_1.notionApiRequest.call(this, 'PATCH', `/blocks/${blockId}/children`, body);
39
+ const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(block), { itemData: { item: i } });
40
+ returnData = returnData.concat(executionData);
41
+ }
42
+ catch (error) {
43
+ if (this.continueOnFail()) {
44
+ returnData.push({
45
+ json: { error: error.message },
46
+ pairedItem: { item: i },
47
+ });
48
+ }
49
+ else {
50
+ throw error;
51
+ }
52
+ }
206
53
  }
207
54
  }
208
55
  if (operation === 'getAll') {
209
- for (let i = 0; i < length; i++) {
210
- const blockId = (0, GenericFunctions_1.extractPageId)(this.getNodeParameter('blockId', i, '', { extractValue: true }));
211
- const returnAll = this.getNodeParameter('returnAll', i);
212
- const fetchNestedBlocks = this.getNodeParameter('fetchNestedBlocks', i);
213
- if (returnAll) {
214
- responseData = await GenericFunctions_1.notionApiRequestAllItems.call(this, 'results', 'GET', `/blocks/${blockId}/children`, {});
215
- if (fetchNestedBlocks) {
216
- responseData = await GenericFunctions_1.notionApiRequestGetBlockChildrens.call(this, responseData);
217
- }
218
- }
219
- else {
220
- const limit = this.getNodeParameter('limit', i);
221
- qs.page_size = limit;
222
- responseData = await GenericFunctions_1.notionApiRequest.call(this, 'GET', `/blocks/${blockId}/children`, {}, qs);
223
- const results = responseData.results;
224
- if (fetchNestedBlocks) {
225
- responseData = await GenericFunctions_1.notionApiRequestGetBlockChildrens.call(this, results, [], limit);
56
+ for (let i = 0; i < itemsLength; i++) {
57
+ try {
58
+ const blockId = (0, GenericFunctions_1.extractPageId)(this.getNodeParameter('blockId', i, '', { extractValue: true }));
59
+ const returnAll = this.getNodeParameter('returnAll', i);
60
+ const fetchNestedBlocks = this.getNodeParameter('fetchNestedBlocks', i);
61
+ if (returnAll) {
62
+ responseData = await GenericFunctions_1.notionApiRequestAllItems.call(this, 'results', 'GET', `/blocks/${blockId}/children`, {});
63
+ if (fetchNestedBlocks) {
64
+ responseData = await GenericFunctions_1.notionApiRequestGetBlockChildrens.call(this, responseData);
65
+ }
226
66
  }
227
67
  else {
228
- responseData = results;
68
+ const limit = this.getNodeParameter('limit', i);
69
+ qs.page_size = limit;
70
+ responseData = await GenericFunctions_1.notionApiRequest.call(this, 'GET', `/blocks/${blockId}/children`, {}, qs);
71
+ const results = responseData.results;
72
+ if (fetchNestedBlocks) {
73
+ responseData = await GenericFunctions_1.notionApiRequestGetBlockChildrens.call(this, results, [], limit);
74
+ }
75
+ else {
76
+ responseData = results;
77
+ }
78
+ }
79
+ responseData = responseData.map((_data) => ({
80
+ object: _data.object,
81
+ parent_id: blockId,
82
+ ..._data,
83
+ }));
84
+ const nodeVersion = this.getNode().typeVersion;
85
+ if (nodeVersion > 2) {
86
+ const simplifyOutput = this.getNodeParameter('simplifyOutput', i);
87
+ if (simplifyOutput) {
88
+ responseData = (0, GenericFunctions_1.simplifyBlocksOutput)(responseData, blockId);
89
+ }
229
90
  }
91
+ const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
92
+ returnData = returnData.concat(executionData);
230
93
  }
231
- responseData = responseData.map((_data) => ({
232
- object: _data.object,
233
- parent_id: blockId,
234
- ..._data,
235
- }));
236
- const nodeVersion = this.getNode().typeVersion;
237
- if (nodeVersion > 2) {
238
- const simplifyOutput = this.getNodeParameter('simplifyOutput', i);
239
- if (simplifyOutput) {
240
- responseData = (0, GenericFunctions_1.simplifyBlocksOutput)(responseData, blockId);
94
+ catch (error) {
95
+ if (this.continueOnFail()) {
96
+ returnData.push({
97
+ json: { error: error.message },
98
+ pairedItem: { item: i },
99
+ });
100
+ }
101
+ else {
102
+ throw error;
241
103
  }
242
104
  }
243
- const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
244
- returnData.push(...executionData);
245
105
  }
246
106
  }
247
107
  }
248
108
  if (resource === 'database') {
249
109
  if (operation === 'get') {
250
110
  const simple = this.getNodeParameter('simple', 0);
251
- for (let i = 0; i < length; i++) {
252
- const databaseId = (0, GenericFunctions_1.extractDatabaseId)(this.getNodeParameter('databaseId', i, '', { extractValue: true }));
253
- responseData = await GenericFunctions_1.notionApiRequest.call(this, 'GET', `/databases/${databaseId}`);
254
- if (simple) {
255
- responseData = (0, GenericFunctions_1.simplifyObjects)(responseData, download)[0];
111
+ for (let i = 0; i < itemsLength; i++) {
112
+ try {
113
+ const databaseId = (0, GenericFunctions_1.extractDatabaseId)(this.getNodeParameter('databaseId', i, '', { extractValue: true }));
114
+ responseData = await GenericFunctions_1.notionApiRequest.call(this, 'GET', `/databases/${databaseId}`);
115
+ if (simple) {
116
+ responseData = (0, GenericFunctions_1.simplifyObjects)(responseData, download)[0];
117
+ }
118
+ const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
119
+ returnData = returnData.concat(executionData);
120
+ }
121
+ catch (error) {
122
+ if (this.continueOnFail()) {
123
+ returnData.push({
124
+ json: { error: error.message },
125
+ pairedItem: { item: i },
126
+ });
127
+ }
128
+ else {
129
+ throw error;
130
+ }
256
131
  }
257
- const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
258
- returnData.push(...executionData);
259
132
  }
260
133
  }
261
134
  if (operation === 'getAll') {
262
135
  const simple = this.getNodeParameter('simple', 0);
263
- for (let i = 0; i < length; i++) {
264
- const body = {
265
- filter: { property: 'object', value: 'database' },
266
- };
267
- const returnAll = this.getNodeParameter('returnAll', i);
268
- if (returnAll) {
269
- responseData = await GenericFunctions_1.notionApiRequestAllItems.call(this, 'results', 'POST', '/search', body);
270
- }
271
- else {
272
- body.page_size = this.getNodeParameter('limit', i);
273
- responseData = await GenericFunctions_1.notionApiRequest.call(this, 'POST', '/search', body);
274
- responseData = responseData.results;
136
+ for (let i = 0; i < itemsLength; i++) {
137
+ try {
138
+ const body = {
139
+ filter: { property: 'object', value: 'database' },
140
+ };
141
+ const returnAll = this.getNodeParameter('returnAll', i);
142
+ if (returnAll) {
143
+ responseData = await GenericFunctions_1.notionApiRequestAllItems.call(this, 'results', 'POST', '/search', body);
144
+ }
145
+ else {
146
+ body.page_size = this.getNodeParameter('limit', i);
147
+ responseData = await GenericFunctions_1.notionApiRequest.call(this, 'POST', '/search', body);
148
+ responseData = responseData.results;
149
+ }
150
+ if (simple) {
151
+ responseData = (0, GenericFunctions_1.simplifyObjects)(responseData, download);
152
+ }
153
+ const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
154
+ returnData = returnData.concat(executionData);
275
155
  }
276
- if (simple) {
277
- responseData = (0, GenericFunctions_1.simplifyObjects)(responseData, download);
156
+ catch (error) {
157
+ if (this.continueOnFail()) {
158
+ returnData.push({
159
+ json: { error: error.message },
160
+ pairedItem: { item: i },
161
+ });
162
+ }
163
+ else {
164
+ throw error;
165
+ }
278
166
  }
279
- const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
280
- returnData.push(...executionData);
281
167
  }
282
168
  }
283
169
  if (operation === 'search') {
284
- for (let i = 0; i < length; i++) {
285
- const text = this.getNodeParameter('text', i);
286
- const options = this.getNodeParameter('options', i);
287
- const returnAll = this.getNodeParameter('returnAll', i);
288
- const simple = this.getNodeParameter('simple', i);
289
- const body = {
290
- filter: {
291
- property: 'object',
292
- value: 'database',
293
- },
294
- };
295
- if (text) {
296
- body.query = text;
297
- }
298
- if (options.sort) {
299
- const sort = ((_a = options.sort) === null || _a === void 0 ? void 0 : _a.sortValue) || {};
300
- body.sort = sort;
301
- }
302
- if (returnAll) {
303
- responseData = await GenericFunctions_1.notionApiRequestAllItems.call(this, 'results', 'POST', '/search', body);
304
- }
305
- else {
306
- qs.limit = this.getNodeParameter('limit', i);
307
- responseData = await GenericFunctions_1.notionApiRequestAllItems.call(this, 'results', 'POST', '/search', body);
308
- responseData = responseData.splice(0, qs.limit);
170
+ for (let i = 0; i < itemsLength; i++) {
171
+ try {
172
+ const text = this.getNodeParameter('text', i);
173
+ const options = this.getNodeParameter('options', i);
174
+ const returnAll = this.getNodeParameter('returnAll', i);
175
+ const simple = this.getNodeParameter('simple', i);
176
+ const body = {
177
+ filter: {
178
+ property: 'object',
179
+ value: 'database',
180
+ },
181
+ };
182
+ if (text) {
183
+ body.query = text;
184
+ }
185
+ if (options.sort) {
186
+ const sort = ((_a = options.sort) === null || _a === void 0 ? void 0 : _a.sortValue) || {};
187
+ body.sort = sort;
188
+ }
189
+ if (returnAll) {
190
+ responseData = await GenericFunctions_1.notionApiRequestAllItems.call(this, 'results', 'POST', '/search', body);
191
+ }
192
+ else {
193
+ qs.limit = this.getNodeParameter('limit', i);
194
+ responseData = await GenericFunctions_1.notionApiRequestAllItems.call(this, 'results', 'POST', '/search', body);
195
+ responseData = responseData.splice(0, qs.limit);
196
+ }
197
+ if (simple) {
198
+ responseData = (0, GenericFunctions_1.simplifyObjects)(responseData, download);
199
+ }
200
+ const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
201
+ returnData = returnData.concat(executionData);
309
202
  }
310
- if (simple) {
311
- responseData = (0, GenericFunctions_1.simplifyObjects)(responseData, download);
203
+ catch (error) {
204
+ if (this.continueOnFail()) {
205
+ returnData.push({
206
+ json: { error: error.message },
207
+ pairedItem: { item: i },
208
+ });
209
+ }
210
+ else {
211
+ throw error;
212
+ }
312
213
  }
313
- const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
314
- returnData.push(...executionData);
315
214
  }
316
215
  }
317
216
  }
@@ -327,256 +226,373 @@ class NotionV2 {
327
226
  titleKey = key;
328
227
  }
329
228
  }
330
- for (let i = 0; i < length; i++) {
331
- const title = this.getNodeParameter('title', i);
332
- const simple = this.getNodeParameter('simple', i);
333
- const body = {
334
- parent: {},
335
- properties: {},
336
- };
337
- if (title !== '') {
338
- body.properties[titleKey] = {
339
- title: [
340
- {
341
- text: {
342
- content: title,
343
- },
344
- },
345
- ],
229
+ for (let i = 0; i < itemsLength; i++) {
230
+ try {
231
+ const title = this.getNodeParameter('title', i);
232
+ const simple = this.getNodeParameter('simple', i);
233
+ const body = {
234
+ parent: {},
235
+ properties: {},
346
236
  };
237
+ if (title !== '') {
238
+ body.properties[titleKey] = {
239
+ title: [
240
+ {
241
+ text: {
242
+ content: title,
243
+ },
244
+ },
245
+ ],
246
+ };
247
+ }
248
+ body.parent.database_id = this.getNodeParameter('databaseId', i, '', {
249
+ extractValue: true,
250
+ });
251
+ const propertiesValues = this.getNodeParameter('propertiesUi.propertyValues', i, []);
252
+ if (propertiesValues.length !== 0) {
253
+ body.properties = Object.assign(body.properties, GenericFunctions_1.mapProperties.call(this, propertiesValues, timezone, 2));
254
+ }
255
+ const blockValues = this.getNodeParameter('blockUi.blockValues', i, []);
256
+ (0, GenericFunctions_1.extractDatabaseMentionRLC)(blockValues);
257
+ body.children = (0, GenericFunctions_1.formatBlocks)(blockValues);
258
+ const options = this.getNodeParameter('options', i);
259
+ if (options.icon) {
260
+ if (options.iconType && options.iconType === 'file') {
261
+ body.icon = { external: { url: options.icon } };
262
+ }
263
+ else {
264
+ body.icon = { emoji: options.icon };
265
+ }
266
+ }
267
+ responseData = await GenericFunctions_1.notionApiRequest.call(this, 'POST', '/pages', body);
268
+ if (simple) {
269
+ responseData = (0, GenericFunctions_1.simplifyObjects)(responseData);
270
+ }
271
+ const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
272
+ returnData = returnData.concat(executionData);
347
273
  }
348
- body.parent.database_id = this.getNodeParameter('databaseId', i, '', {
349
- extractValue: true,
350
- });
351
- const propertiesValues = this.getNodeParameter('propertiesUi.propertyValues', i, []);
352
- if (propertiesValues.length !== 0) {
353
- body.properties = Object.assign(body.properties, GenericFunctions_1.mapProperties.call(this, propertiesValues, timezone, 2));
354
- }
355
- const blockValues = this.getNodeParameter('blockUi.blockValues', i, []);
356
- (0, GenericFunctions_1.extractDatabaseMentionRLC)(blockValues);
357
- body.children = (0, GenericFunctions_1.formatBlocks)(blockValues);
358
- const options = this.getNodeParameter('options', i);
359
- if (options.icon) {
360
- if (options.iconType && options.iconType === 'file') {
361
- body.icon = { external: { url: options.icon } };
274
+ catch (error) {
275
+ if (this.continueOnFail()) {
276
+ returnData.push({
277
+ json: { error: error.message },
278
+ pairedItem: { item: i },
279
+ });
362
280
  }
363
281
  else {
364
- body.icon = { emoji: options.icon };
282
+ throw error;
365
283
  }
366
284
  }
367
- responseData = await GenericFunctions_1.notionApiRequest.call(this, 'POST', '/pages', body);
368
- if (simple) {
369
- responseData = (0, GenericFunctions_1.simplifyObjects)(responseData);
370
- }
371
- const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
372
- returnData.push(...executionData);
373
285
  }
374
286
  }
375
287
  if (operation === 'get') {
376
- for (let i = 0; i < length; i++) {
377
- const pageId = (0, GenericFunctions_1.extractPageId)(this.getNodeParameter('pageId', i, '', { extractValue: true }));
378
- const simple = this.getNodeParameter('simple', i);
379
- responseData = await GenericFunctions_1.notionApiRequest.call(this, 'GET', `/pages/${pageId}`);
380
- if (simple) {
381
- responseData = (0, GenericFunctions_1.simplifyObjects)(responseData, download);
288
+ for (let i = 0; i < itemsLength; i++) {
289
+ try {
290
+ const pageId = (0, GenericFunctions_1.extractPageId)(this.getNodeParameter('pageId', i, '', { extractValue: true }));
291
+ const simple = this.getNodeParameter('simple', i);
292
+ responseData = await GenericFunctions_1.notionApiRequest.call(this, 'GET', `/pages/${pageId}`);
293
+ if (simple) {
294
+ responseData = (0, GenericFunctions_1.simplifyObjects)(responseData, download);
295
+ }
296
+ const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
297
+ returnData = returnData.concat(executionData);
298
+ }
299
+ catch (error) {
300
+ if (this.continueOnFail()) {
301
+ returnData.push({
302
+ json: { error: error.message },
303
+ pairedItem: { item: i },
304
+ });
305
+ }
306
+ else {
307
+ throw error;
308
+ }
382
309
  }
383
- const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
384
- returnData.push(...executionData);
385
310
  }
386
311
  }
387
312
  if (operation === 'getAll') {
388
- for (let i = 0; i < length; i++) {
389
- download = this.getNodeParameter('options.downloadFiles', 0, false);
390
- const simple = this.getNodeParameter('simple', 0);
391
- const databaseId = this.getNodeParameter('databaseId', i, '', {
392
- extractValue: true,
393
- });
394
- const returnAll = this.getNodeParameter('returnAll', i);
395
- const filterType = this.getNodeParameter('filterType', 0);
396
- const conditions = this.getNodeParameter('filters.conditions', i, []);
397
- const sort = this.getNodeParameter('options.sort.sortValue', i, []);
398
- const body = {
399
- filter: {},
400
- };
401
- if (filterType === 'manual') {
402
- const matchType = this.getNodeParameter('matchType', 0);
403
- if (matchType === 'anyFilter') {
404
- Object.assign(body.filter, {
405
- or: conditions.map((data) => (0, GenericFunctions_1.mapFilters)([data], timezone)),
406
- });
313
+ for (let i = 0; i < itemsLength; i++) {
314
+ try {
315
+ download = this.getNodeParameter('options.downloadFiles', 0, false);
316
+ const simple = this.getNodeParameter('simple', 0);
317
+ const databaseId = this.getNodeParameter('databaseId', i, '', {
318
+ extractValue: true,
319
+ });
320
+ const returnAll = this.getNodeParameter('returnAll', i);
321
+ const filterType = this.getNodeParameter('filterType', 0);
322
+ const conditions = this.getNodeParameter('filters.conditions', i, []);
323
+ const sort = this.getNodeParameter('options.sort.sortValue', i, []);
324
+ const body = {
325
+ filter: {},
326
+ };
327
+ if (filterType === 'manual') {
328
+ const matchType = this.getNodeParameter('matchType', 0);
329
+ if (matchType === 'anyFilter') {
330
+ Object.assign(body.filter, {
331
+ or: conditions.map((data) => (0, GenericFunctions_1.mapFilters)([data], timezone)),
332
+ });
333
+ }
334
+ else if (matchType === 'allFilters') {
335
+ Object.assign(body.filter, {
336
+ and: conditions.map((data) => (0, GenericFunctions_1.mapFilters)([data], timezone)),
337
+ });
338
+ }
407
339
  }
408
- else if (matchType === 'allFilters') {
409
- Object.assign(body.filter, {
410
- and: conditions.map((data) => (0, GenericFunctions_1.mapFilters)([data], timezone)),
411
- });
340
+ else if (filterType === 'json') {
341
+ const filterJson = this.getNodeParameter('filterJson', i);
342
+ if ((0, GenericFunctions_1.validateJSON)(filterJson) !== undefined) {
343
+ body.filter = (0, n8n_workflow_1.jsonParse)(filterJson);
344
+ }
345
+ else {
346
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), {
347
+ message: 'Filters (JSON) must be a valid json',
348
+ });
349
+ }
412
350
  }
413
- }
414
- else if (filterType === 'json') {
415
- const filterJson = this.getNodeParameter('filterJson', i);
416
- if ((0, GenericFunctions_1.validateJSON)(filterJson) !== undefined) {
417
- body.filter = (0, n8n_workflow_1.jsonParse)(filterJson);
351
+ if (!Object.keys(body.filter).length) {
352
+ delete body.filter;
353
+ }
354
+ if (sort) {
355
+ body.sorts = (0, GenericFunctions_1.mapSorting)(sort);
356
+ }
357
+ if (returnAll) {
358
+ responseData = await GenericFunctions_1.notionApiRequestAllItems.call(this, 'results', 'POST', `/databases/${databaseId}/query`, body, {});
418
359
  }
419
360
  else {
420
- throw new n8n_workflow_1.NodeApiError(this.getNode(), {
421
- message: 'Filters (JSON) must be a valid json',
422
- });
361
+ body.page_size = this.getNodeParameter('limit', i);
362
+ responseData = await GenericFunctions_1.notionApiRequest.call(this, 'POST', `/databases/${databaseId}/query`, body, qs);
363
+ responseData = responseData.results;
423
364
  }
365
+ if (download) {
366
+ responseData = await GenericFunctions_1.downloadFiles.call(this, responseData, [
367
+ { item: i },
368
+ ]);
369
+ }
370
+ if (simple) {
371
+ responseData = (0, GenericFunctions_1.simplifyObjects)(responseData, download);
372
+ }
373
+ const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
374
+ returnData = returnData.concat(executionData);
424
375
  }
425
- if (!Object.keys(body.filter).length) {
426
- delete body.filter;
427
- }
428
- if (sort) {
429
- body.sorts = (0, GenericFunctions_1.mapSorting)(sort);
430
- }
431
- if (returnAll) {
432
- responseData = await GenericFunctions_1.notionApiRequestAllItems.call(this, 'results', 'POST', `/databases/${databaseId}/query`, body, {});
433
- }
434
- else {
435
- body.page_size = this.getNodeParameter('limit', i);
436
- responseData = await GenericFunctions_1.notionApiRequest.call(this, 'POST', `/databases/${databaseId}/query`, body, qs);
437
- responseData = responseData.results;
438
- }
439
- if (download) {
440
- responseData = await GenericFunctions_1.downloadFiles.call(this, responseData, [
441
- { item: i },
442
- ]);
443
- }
444
- if (simple) {
445
- responseData = (0, GenericFunctions_1.simplifyObjects)(responseData, download);
376
+ catch (error) {
377
+ if (this.continueOnFail()) {
378
+ returnData.push({
379
+ json: { error: error.message },
380
+ pairedItem: { item: i },
381
+ });
382
+ }
383
+ else {
384
+ throw error;
385
+ }
446
386
  }
447
- const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
448
- returnData.push(...executionData);
449
387
  }
450
388
  }
451
389
  if (operation === 'update') {
452
- for (let i = 0; i < length; i++) {
453
- const pageId = (0, GenericFunctions_1.extractPageId)(this.getNodeParameter('pageId', i, '', { extractValue: true }));
454
- const simple = this.getNodeParameter('simple', i);
455
- const properties = this.getNodeParameter('propertiesUi.propertyValues', i, []);
456
- const body = {
457
- properties: {},
458
- };
459
- if (properties.length !== 0) {
460
- body.properties = GenericFunctions_1.mapProperties.call(this, properties, timezone, 2);
390
+ for (let i = 0; i < itemsLength; i++) {
391
+ try {
392
+ const pageId = (0, GenericFunctions_1.extractPageId)(this.getNodeParameter('pageId', i, '', { extractValue: true }));
393
+ const simple = this.getNodeParameter('simple', i);
394
+ const properties = this.getNodeParameter('propertiesUi.propertyValues', i, []);
395
+ const body = {
396
+ properties: {},
397
+ };
398
+ if (properties.length !== 0) {
399
+ body.properties = GenericFunctions_1.mapProperties.call(this, properties, timezone, 2);
400
+ }
401
+ const options = this.getNodeParameter('options', i);
402
+ if (options.icon) {
403
+ if (options.iconType && options.iconType === 'file') {
404
+ body.icon = { type: 'external', external: { url: options.icon } };
405
+ }
406
+ else {
407
+ body.icon = { type: 'emoji', emoji: options.icon };
408
+ }
409
+ }
410
+ responseData = await GenericFunctions_1.notionApiRequest.call(this, 'PATCH', `/pages/${pageId}`, body);
411
+ if (simple) {
412
+ responseData = (0, GenericFunctions_1.simplifyObjects)(responseData, false);
413
+ }
414
+ const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
415
+ returnData = returnData.concat(executionData);
461
416
  }
462
- const options = this.getNodeParameter('options', i);
463
- if (options.icon) {
464
- if (options.iconType && options.iconType === 'file') {
465
- body.icon = { type: 'external', external: { url: options.icon } };
417
+ catch (error) {
418
+ if (this.continueOnFail()) {
419
+ returnData.push({
420
+ json: { error: error.message },
421
+ pairedItem: { item: i },
422
+ });
466
423
  }
467
424
  else {
468
- body.icon = { type: 'emoji', emoji: options.icon };
425
+ throw error;
469
426
  }
470
427
  }
471
- responseData = await GenericFunctions_1.notionApiRequest.call(this, 'PATCH', `/pages/${pageId}`, body);
472
- if (simple) {
473
- responseData = (0, GenericFunctions_1.simplifyObjects)(responseData, false);
474
- }
475
- const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
476
- returnData.push(...executionData);
477
428
  }
478
429
  }
479
430
  }
480
431
  if (resource === 'user') {
481
432
  if (operation === 'get') {
482
- for (let i = 0; i < length; i++) {
483
- const userId = this.getNodeParameter('userId', i);
484
- responseData = await GenericFunctions_1.notionApiRequest.call(this, 'GET', `/users/${userId}`);
485
- const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
486
- returnData.push(...executionData);
433
+ for (let i = 0; i < itemsLength; i++) {
434
+ try {
435
+ const userId = this.getNodeParameter('userId', i);
436
+ responseData = await GenericFunctions_1.notionApiRequest.call(this, 'GET', `/users/${userId}`);
437
+ const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
438
+ returnData = returnData.concat(executionData);
439
+ }
440
+ catch (error) {
441
+ if (this.continueOnFail()) {
442
+ returnData.push({
443
+ json: { error: error.message },
444
+ pairedItem: { item: i },
445
+ });
446
+ }
447
+ else {
448
+ throw error;
449
+ }
450
+ }
487
451
  }
488
452
  }
489
453
  if (operation === 'getAll') {
490
- for (let i = 0; i < length; i++) {
491
- const returnAll = this.getNodeParameter('returnAll', i);
492
- if (returnAll) {
493
- responseData = await GenericFunctions_1.notionApiRequestAllItems.call(this, 'results', 'GET', '/users');
454
+ for (let i = 0; i < itemsLength; i++) {
455
+ try {
456
+ const returnAll = this.getNodeParameter('returnAll', i);
457
+ if (returnAll) {
458
+ responseData = await GenericFunctions_1.notionApiRequestAllItems.call(this, 'results', 'GET', '/users');
459
+ }
460
+ else {
461
+ qs.limit = this.getNodeParameter('limit', i);
462
+ responseData = await GenericFunctions_1.notionApiRequestAllItems.call(this, 'results', 'GET', '/users');
463
+ responseData = responseData.splice(0, qs.limit);
464
+ }
465
+ const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
466
+ returnData = returnData.concat(executionData);
494
467
  }
495
- else {
496
- qs.limit = this.getNodeParameter('limit', i);
497
- responseData = await GenericFunctions_1.notionApiRequestAllItems.call(this, 'results', 'GET', '/users');
498
- responseData = responseData.splice(0, qs.limit);
468
+ catch (error) {
469
+ if (this.continueOnFail()) {
470
+ returnData.push({
471
+ json: { error: error.message },
472
+ pairedItem: { item: i },
473
+ });
474
+ }
475
+ else {
476
+ throw error;
477
+ }
499
478
  }
500
- const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
501
- returnData.push(...executionData);
502
479
  }
503
480
  }
504
481
  }
505
482
  if (resource === 'page') {
506
483
  if (operation === 'archive') {
507
- for (let i = 0; i < length; i++) {
508
- const pageId = (0, GenericFunctions_1.extractPageId)(this.getNodeParameter('pageId', i, '', { extractValue: true }));
509
- const simple = this.getNodeParameter('simple', i);
510
- responseData = await GenericFunctions_1.notionApiRequest.call(this, 'PATCH', `/pages/${pageId}`, {
511
- archived: true,
512
- });
513
- if (simple) {
514
- responseData = (0, GenericFunctions_1.simplifyObjects)(responseData, download);
484
+ for (let i = 0; i < itemsLength; i++) {
485
+ try {
486
+ const pageId = (0, GenericFunctions_1.extractPageId)(this.getNodeParameter('pageId', i, '', { extractValue: true }));
487
+ const simple = this.getNodeParameter('simple', i);
488
+ responseData = await GenericFunctions_1.notionApiRequest.call(this, 'PATCH', `/pages/${pageId}`, {
489
+ archived: true,
490
+ });
491
+ if (simple) {
492
+ responseData = (0, GenericFunctions_1.simplifyObjects)(responseData, download);
493
+ }
494
+ const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
495
+ returnData = returnData.concat(executionData);
496
+ }
497
+ catch (error) {
498
+ if (this.continueOnFail()) {
499
+ returnData.push({
500
+ json: { error: error.message },
501
+ pairedItem: { item: i },
502
+ });
503
+ }
504
+ else {
505
+ throw error;
506
+ }
515
507
  }
516
- const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
517
- returnData.push(...executionData);
518
508
  }
519
509
  }
520
510
  if (operation === 'create') {
521
- for (let i = 0; i < length; i++) {
522
- const simple = this.getNodeParameter('simple', i);
523
- const body = {
524
- parent: {},
525
- properties: {},
526
- };
527
- body.parent.page_id = (0, GenericFunctions_1.extractPageId)(this.getNodeParameter('pageId', i, '', { extractValue: true }));
528
- body.properties = (0, GenericFunctions_1.formatTitle)(this.getNodeParameter('title', i));
529
- const blockValues = this.getNodeParameter('blockUi.blockValues', i, []);
530
- (0, GenericFunctions_1.extractDatabaseMentionRLC)(blockValues);
531
- body.children = (0, GenericFunctions_1.formatBlocks)(blockValues);
532
- const options = this.getNodeParameter('options', i);
533
- if (options.icon) {
534
- if (options.iconType && options.iconType === 'file') {
535
- body.icon = { external: { url: options.icon } };
511
+ for (let i = 0; i < itemsLength; i++) {
512
+ try {
513
+ const simple = this.getNodeParameter('simple', i);
514
+ const body = {
515
+ parent: {},
516
+ properties: {},
517
+ };
518
+ body.parent.page_id = (0, GenericFunctions_1.extractPageId)(this.getNodeParameter('pageId', i, '', { extractValue: true }));
519
+ body.properties = (0, GenericFunctions_1.formatTitle)(this.getNodeParameter('title', i));
520
+ const blockValues = this.getNodeParameter('blockUi.blockValues', i, []);
521
+ (0, GenericFunctions_1.extractDatabaseMentionRLC)(blockValues);
522
+ body.children = (0, GenericFunctions_1.formatBlocks)(blockValues);
523
+ const options = this.getNodeParameter('options', i);
524
+ if (options.icon) {
525
+ if (options.iconType && options.iconType === 'file') {
526
+ body.icon = { external: { url: options.icon } };
527
+ }
528
+ else {
529
+ body.icon = { emoji: options.icon };
530
+ }
536
531
  }
537
- else {
538
- body.icon = { emoji: options.icon };
532
+ responseData = await GenericFunctions_1.notionApiRequest.call(this, 'POST', '/pages', body);
533
+ if (simple) {
534
+ responseData = (0, GenericFunctions_1.simplifyObjects)(responseData, download);
539
535
  }
536
+ const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
537
+ returnData = returnData.concat(executionData);
540
538
  }
541
- responseData = await GenericFunctions_1.notionApiRequest.call(this, 'POST', '/pages', body);
542
- if (simple) {
543
- responseData = (0, GenericFunctions_1.simplifyObjects)(responseData, download);
539
+ catch (error) {
540
+ if (this.continueOnFail()) {
541
+ returnData.push({
542
+ json: { error: error.message },
543
+ pairedItem: { item: i },
544
+ });
545
+ }
546
+ else {
547
+ throw error;
548
+ }
544
549
  }
545
- const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
546
- returnData.push(...executionData);
547
550
  }
548
551
  }
549
552
  if (operation === 'search') {
550
- for (let i = 0; i < length; i++) {
551
- const text = this.getNodeParameter('text', i);
552
- const options = this.getNodeParameter('options', i);
553
- const returnAll = this.getNodeParameter('returnAll', i);
554
- const simple = this.getNodeParameter('simple', i);
555
- const body = {};
556
- if (text) {
557
- body.query = text;
558
- }
559
- if (options.filter) {
560
- const filter = ((_b = options.filter) === null || _b === void 0 ? void 0 : _b.filters) || [];
561
- body.filter = filter;
562
- }
563
- if (options.sort) {
564
- const sort = ((_c = options.sort) === null || _c === void 0 ? void 0 : _c.sortValue) || {};
565
- body.sort = sort;
566
- }
567
- if (returnAll) {
568
- responseData = await GenericFunctions_1.notionApiRequestAllItems.call(this, 'results', 'POST', '/search', body);
569
- }
570
- else {
571
- qs.limit = this.getNodeParameter('limit', i);
572
- responseData = await GenericFunctions_1.notionApiRequestAllItems.call(this, 'results', 'POST', '/search', body);
573
- responseData = responseData.splice(0, qs.limit);
553
+ for (let i = 0; i < itemsLength; i++) {
554
+ try {
555
+ const text = this.getNodeParameter('text', i);
556
+ const options = this.getNodeParameter('options', i);
557
+ const returnAll = this.getNodeParameter('returnAll', i);
558
+ const simple = this.getNodeParameter('simple', i);
559
+ const body = {};
560
+ if (text) {
561
+ body.query = text;
562
+ }
563
+ if (options.filter) {
564
+ const filter = ((_b = options.filter) === null || _b === void 0 ? void 0 : _b.filters) || [];
565
+ body.filter = filter;
566
+ }
567
+ if (options.sort) {
568
+ const sort = ((_c = options.sort) === null || _c === void 0 ? void 0 : _c.sortValue) || {};
569
+ body.sort = sort;
570
+ }
571
+ if (returnAll) {
572
+ responseData = await GenericFunctions_1.notionApiRequestAllItems.call(this, 'results', 'POST', '/search', body);
573
+ }
574
+ else {
575
+ qs.limit = this.getNodeParameter('limit', i);
576
+ responseData = await GenericFunctions_1.notionApiRequestAllItems.call(this, 'results', 'POST', '/search', body);
577
+ responseData = responseData.splice(0, qs.limit);
578
+ }
579
+ if (simple) {
580
+ responseData = (0, GenericFunctions_1.simplifyObjects)(responseData, download);
581
+ }
582
+ const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
583
+ returnData = returnData.concat(executionData);
574
584
  }
575
- if (simple) {
576
- responseData = (0, GenericFunctions_1.simplifyObjects)(responseData, download);
585
+ catch (error) {
586
+ if (this.continueOnFail()) {
587
+ returnData.push({
588
+ json: { error: error.message },
589
+ pairedItem: { item: i },
590
+ });
591
+ }
592
+ else {
593
+ throw error;
594
+ }
577
595
  }
578
- const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
579
- returnData.push(...executionData);
580
596
  }
581
597
  }
582
598
  }