n8n-nodes-notion-advanced 1.2.18-beta → 1.2.20-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);
@@ -1104,30 +1128,6 @@ class NotionAITool {
1104
1128
  return null;
1105
1129
  }
1106
1130
  },
1107
- // Strong/Bold: <strong>content</strong> or <b>content</b> (only as standalone)
1108
- {
1109
- regex: /(?:^|>|\s)<(strong|b)>(.*?)<\/(strong|b)>(?=<|$|\s)/gis,
1110
- blockCreator: (tag, content) => {
1111
- return {
1112
- type: 'paragraph',
1113
- paragraph: {
1114
- rich_text: NotionAITool.parseBasicMarkdown(`**${content.trim()}**`),
1115
- },
1116
- };
1117
- }
1118
- },
1119
- // Emphasis/Italic: <em>content</em> or <i>content</i> (only as standalone)
1120
- {
1121
- regex: /(?:^|>|\s)<(em|i)>(.*?)<\/(em|i)>(?=<|$|\s)/gis,
1122
- blockCreator: (tag, content) => {
1123
- return {
1124
- type: 'paragraph',
1125
- paragraph: {
1126
- rich_text: NotionAITool.parseBasicMarkdown(`*${content.trim()}*`),
1127
- },
1128
- };
1129
- }
1130
- },
1131
1131
  // Line breaks: <br/> or <br>
1132
1132
  {
1133
1133
  regex: /<br\s*\/?>/gis,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-notion-advanced",
3
- "version": "1.2.18-beta",
3
+ "version": "1.2.20-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": [