n8n-nodes-notion-advanced 1.2.17-beta → 1.2.19-beta

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.
@@ -25,6 +25,7 @@ interface XMLNode {
25
25
  export declare class NotionAITool implements INodeType {
26
26
  description: INodeTypeDescription;
27
27
  execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
28
+ static getFlexibleParameter(executeFunctions: IExecuteFunctions, itemIndex: number, primaryName: string, alternativeNames?: string[], defaultValue?: any): any;
28
29
  static createPageWithContent(executeFunctions: IExecuteFunctions, itemIndex: number): Promise<IDataObject>;
29
30
  static addContentToPage(executeFunctions: IExecuteFunctions, itemIndex: number): Promise<IDataObject>;
30
31
  static searchPages(executeFunctions: IExecuteFunctions, itemIndex: number): Promise<IDataObject>;
@@ -303,10 +303,34 @@ class NotionAITool {
303
303
  }
304
304
  return [this.helpers.returnJsonArray(responseData)];
305
305
  }
306
+ // Helper method to support both camelCase and underscore parameter names for AI agent compatibility
307
+ static getFlexibleParameter(executeFunctions, itemIndex, primaryName, alternativeNames = [], defaultValue) {
308
+ try {
309
+ // First try the primary (camelCase) parameter name
310
+ return executeFunctions.getNodeParameter(primaryName, itemIndex, defaultValue);
311
+ }
312
+ catch (error) {
313
+ // If that fails, try each alternative name
314
+ for (const altName of alternativeNames) {
315
+ try {
316
+ return executeFunctions.getNodeParameter(altName, itemIndex, defaultValue);
317
+ }
318
+ catch (altError) {
319
+ // Continue to next alternative
320
+ }
321
+ }
322
+ // If all parameter names fail, return default value or throw original error
323
+ if (defaultValue !== undefined) {
324
+ return defaultValue;
325
+ }
326
+ throw error;
327
+ }
328
+ }
306
329
  static async createPageWithContent(executeFunctions, itemIndex) {
307
- const pageTitle = executeFunctions.getNodeParameter('pageTitle', itemIndex);
308
- const parentId = executeFunctions.getNodeParameter('parentId', itemIndex);
309
- const content = executeFunctions.getNodeParameter('content', itemIndex, '');
330
+ // Support both camelCase and underscore parameter names for AI agent compatibility
331
+ const pageTitle = NotionAITool.getFlexibleParameter(executeFunctions, itemIndex, 'pageTitle', ['Page_Title', 'page_title']);
332
+ const parentId = NotionAITool.getFlexibleParameter(executeFunctions, itemIndex, 'parentId', ['Parent_Page_Database_ID', 'parent_id', 'parentPageDatabaseId']);
333
+ const content = NotionAITool.getFlexibleParameter(executeFunctions, itemIndex, 'content', ['Content'], '');
310
334
  const additionalOptions = executeFunctions.getNodeParameter('additionalOptions', itemIndex, {});
311
335
  const resolvedParentId = await NotionUtils_1.resolvePageId.call(executeFunctions, parentId);
312
336
  // Create the page first
@@ -343,8 +367,8 @@ class NotionAITool {
343
367
  };
344
368
  }
345
369
  static async addContentToPage(executeFunctions, itemIndex) {
346
- const targetPageId = executeFunctions.getNodeParameter('targetPageId', itemIndex);
347
- const content = executeFunctions.getNodeParameter('content', itemIndex);
370
+ const targetPageId = NotionAITool.getFlexibleParameter(executeFunctions, itemIndex, 'targetPageId', ['Target_Page_ID', 'target_page_id']);
371
+ const content = NotionAITool.getFlexibleParameter(executeFunctions, itemIndex, 'content', ['Content']);
348
372
  const resolvedPageId = await NotionUtils_1.resolvePageId.call(executeFunctions, targetPageId);
349
373
  const blocks = NotionAITool.parseContentToBlocks(content);
350
374
  if (blocks.length === 0) {
@@ -362,7 +386,7 @@ class NotionAITool {
362
386
  }
363
387
  static async searchPages(executeFunctions, itemIndex) {
364
388
  var _a, _b;
365
- const searchQuery = executeFunctions.getNodeParameter('searchQuery', itemIndex, '');
389
+ const searchQuery = NotionAITool.getFlexibleParameter(executeFunctions, itemIndex, 'searchQuery', ['Search_Query', 'search_query'], '');
366
390
  const additionalOptions = executeFunctions.getNodeParameter('additionalOptions', itemIndex, {});
367
391
  const maxResults = additionalOptions.maxResults || 20;
368
392
  const body = {
@@ -383,8 +407,8 @@ class NotionAITool {
383
407
  };
384
408
  }
385
409
  static async updatePageProperties(executeFunctions, itemIndex) {
386
- const targetPageId = executeFunctions.getNodeParameter('targetPageId', itemIndex);
387
- const propertiesToUpdate = executeFunctions.getNodeParameter('propertiesToUpdate', itemIndex);
410
+ const targetPageId = NotionAITool.getFlexibleParameter(executeFunctions, itemIndex, 'targetPageId', ['Target_Page_ID', 'target_page_id']);
411
+ const propertiesToUpdate = NotionAITool.getFlexibleParameter(executeFunctions, itemIndex, 'propertiesToUpdate', ['Properties_To_Update', 'properties_to_update']);
388
412
  const resolvedPageId = await NotionUtils_1.resolvePageId.call(executeFunctions, targetPageId);
389
413
  const properties = NotionAITool.parsePropertiesToUpdate(propertiesToUpdate);
390
414
  const result = await NotionUtils_1.notionApiRequest.call(executeFunctions, 'PATCH', `/pages/${resolvedPageId}`, {
@@ -398,8 +422,8 @@ class NotionAITool {
398
422
  };
399
423
  }
400
424
  static async createDatabaseEntry(executeFunctions, itemIndex) {
401
- const parentId = executeFunctions.getNodeParameter('parentId', itemIndex);
402
- const entryProperties = executeFunctions.getNodeParameter('entryProperties', itemIndex);
425
+ const parentId = NotionAITool.getFlexibleParameter(executeFunctions, itemIndex, 'parentId', ['Parent_Page_Database_ID', 'parent_id', 'parentPageDatabaseId']);
426
+ const entryProperties = NotionAITool.getFlexibleParameter(executeFunctions, itemIndex, 'entryProperties', ['Entry_Properties', 'entry_properties']);
403
427
  const resolvedParentId = await NotionUtils_1.resolvePageId.call(executeFunctions, parentId);
404
428
  const properties = NotionAITool.parsePropertiesToUpdate(entryProperties);
405
429
  const result = await NotionUtils_1.notionApiRequest.call(executeFunctions, 'POST', '/pages', {
@@ -415,8 +439,8 @@ class NotionAITool {
415
439
  }
416
440
  static async queryDatabase(executeFunctions, itemIndex) {
417
441
  var _a, _b;
418
- const databaseId = executeFunctions.getNodeParameter('databaseId', itemIndex);
419
- const queryFilter = executeFunctions.getNodeParameter('queryFilter', itemIndex, '');
442
+ const databaseId = NotionAITool.getFlexibleParameter(executeFunctions, itemIndex, 'databaseId', ['Database_ID', 'database_id']);
443
+ const queryFilter = NotionAITool.getFlexibleParameter(executeFunctions, itemIndex, 'queryFilter', ['Query_Filter', 'query_filter'], '');
420
444
  const additionalOptions = executeFunctions.getNodeParameter('additionalOptions', itemIndex, {});
421
445
  const maxResults = additionalOptions.maxResults || 20;
422
446
  const resolvedDatabaseId = await NotionUtils_1.resolvePageId.call(executeFunctions, databaseId);
@@ -459,6 +483,16 @@ class NotionAITool {
459
483
  // Skip completely empty lines and XML placeholders (now using dynamic prefix check)
460
484
  if (!trimmedLine || /__XML_[a-f0-9]{8}_\d+__/.test(trimmedLine))
461
485
  continue;
486
+ // Skip lines that contain XML tag patterns (to prevent double processing)
487
+ const xmlTagPatterns = [
488
+ /<[^>]+>/, // Any XML/HTML tag
489
+ /&lt;[^&]+&gt;/, // HTML-encoded tags
490
+ /<(h[1-6]|p|ul|ol|li|strong|em|b|i|code|blockquote|callout|todo|image|embed|bookmark|equation|toggle|divider|quote|pre)\b[^>]*>/i,
491
+ ];
492
+ const hasXmlTags = xmlTagPatterns.some(pattern => pattern.test(trimmedLine));
493
+ if (hasXmlTags) {
494
+ continue; // Skip processing this line as it contains XML content that should be handled hierarchically
495
+ }
462
496
  // Traditional markdown patterns (for backwards compatibility)
463
497
  if (trimmedLine.startsWith('# ')) {
464
498
  blocks.push({
@@ -1225,6 +1259,15 @@ class NotionAITool {
1225
1259
  fallbackPatterns.forEach(pattern => {
1226
1260
  cleaned = cleaned.replace(pattern, '');
1227
1261
  });
1262
+ // Remove entire lines containing XML content to prevent double processing
1263
+ const xmlContentLines = [
1264
+ /^.*<[^>]+>.*$/gm, // Any line with XML/HTML tags
1265
+ /^.*&lt;[^&]+&gt;.*$/gm, // HTML-encoded tags
1266
+ /^.*<(h[1-6]|p|ul|ol|li|strong|em|b|i|code|blockquote|callout|todo|image|embed|bookmark|equation|toggle|divider|quote|pre)\b[^>]*>.*$/gim, // Specific XML content
1267
+ ];
1268
+ xmlContentLines.forEach(pattern => {
1269
+ cleaned = cleaned.replace(pattern, '');
1270
+ });
1228
1271
  // Remove common HTML tags that might be left behind
1229
1272
  const htmlTagsToRemove = [
1230
1273
  /<\/?ul\s*[^>]*>/gi,
@@ -1243,6 +1286,18 @@ class NotionAITool {
1243
1286
  /<\/?s\s*[^>]*>/gi,
1244
1287
  /<\/?del\s*[^>]*>/gi,
1245
1288
  /<\/?mark\s*[^>]*>/gi,
1289
+ /<\/?h[1-6]\s*[^>]*>/gi,
1290
+ /<\/?blockquote\s*[^>]*>/gi,
1291
+ /<\/?callout\s*[^>]*>/gi,
1292
+ /<\/?todo\s*[^>]*>/gi,
1293
+ /<\/?image\s*[^>]*>/gi,
1294
+ /<\/?embed\s*[^>]*>/gi,
1295
+ /<\/?bookmark\s*[^>]*>/gi,
1296
+ /<\/?equation\s*[^>]*>/gi,
1297
+ /<\/?toggle\s*[^>]*>/gi,
1298
+ /<\/?quote\s*[^>]*>/gi,
1299
+ /<\/?pre\s*[^>]*>/gi,
1300
+ /<\/?divider\s*[^>]*>/gi,
1246
1301
  /<br\s*\/?>/gi,
1247
1302
  ];
1248
1303
  htmlTagsToRemove.forEach(regex => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-notion-advanced",
3
- "version": "1.2.17-beta",
3
+ "version": "1.2.19-beta",
4
4
  "description": "Advanced n8n Notion nodes: Full-featured workflow node + AI Agent Tool for intelligent Notion automation with 25+ block types (BETA)",
5
5
  "scripts": {},
6
6
  "files": [