n8n-nodes-dopomogai 1.3.5 → 1.3.8

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.
@@ -202,7 +202,7 @@ class DopomogaiChat {
202
202
  const op = this.getNodeParameter('operation', i);
203
203
  // ---------------- Chat (blocking) ----------------
204
204
  if (op === 'chatBlocking') {
205
- const creds = (0, http_1.getCreds)(this);
205
+ const creds = await (0, http_1.getCreds)(this);
206
206
  const agentId = this.getNodeParameter('agentId', i);
207
207
  const conversationId = this.getNodeParameter('conversationId', i, '');
208
208
  const messageText = this.getNodeParameter('messageText', i, '');
@@ -263,7 +263,7 @@ class DopomogaiChat {
263
263
  }
264
264
  // ---------------- Submit tool result (blocking) ----------------
265
265
  if (op === 'submitToolResultBlocking') {
266
- const creds = (0, http_1.getCreds)(this);
266
+ const creds = await (0, http_1.getCreds)(this);
267
267
  const agentId = this.getNodeParameter('toolAgentId', i);
268
268
  const conversationId = this.getNodeParameter('toolConversationId', i);
269
269
  const toolCallId = this.getNodeParameter('toolCallId', i);
@@ -93,7 +93,7 @@ class DopomogaiFiles {
93
93
  for (let i = 0; i < items.length; i++) {
94
94
  const op = this.getNodeParameter('operation', i);
95
95
  if (op === 'upload') {
96
- const creds = (0, http_1.getCreds)(this);
96
+ const creds = await (0, http_1.getCreds)(this);
97
97
  const binaryProperty = this.getNodeParameter('binaryProperty', i, 'data');
98
98
  const purpose = this.getNodeParameter('purpose', i, 'agent_input');
99
99
  const agentId = this.getNodeParameter('agentId', i, '');
@@ -114,7 +114,7 @@ class DopomogaiFiles {
114
114
  continue;
115
115
  }
116
116
  if (op === 'getMetadata') {
117
- const creds = (0, http_1.getCreds)(this);
117
+ const creds = await (0, http_1.getCreds)(this);
118
118
  const fileId = this.getNodeParameter('fileId', i);
119
119
  const { data } = await (0, http_1.requestJson)(this, { method: 'GET', path: `/api/v1/files/${fileId}` });
120
120
  out.push({
@@ -4,7 +4,7 @@ export type DopomogaiCreds = {
4
4
  apiKey: string;
5
5
  sendAs: 'authorizationBearer' | 'xApiKey';
6
6
  };
7
- export declare function getCreds(ctx: IExecuteFunctions): DopomogaiCreds;
7
+ export declare function getCreds(ctx: IExecuteFunctions): Promise<DopomogaiCreds>;
8
8
  export declare function buildHeaders(creds: DopomogaiCreds, extra?: Record<string, string>): Record<string, string>;
9
9
  export declare function requestJson<T>(ctx: IExecuteFunctions, opts: {
10
10
  method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
@@ -4,16 +4,20 @@ exports.getCreds = getCreds;
4
4
  exports.buildHeaders = buildHeaders;
5
5
  exports.requestJson = requestJson;
6
6
  exports.requestFormData = requestFormData;
7
- function getCreds(ctx) {
8
- const c = ctx.getCredentials('dopomogaiApiKey');
9
- if (!c?.apiBaseUrl)
10
- throw new Error('Missing credentials.apiBaseUrl');
11
- if (!c?.apiKey)
12
- throw new Error('Missing credentials.apiKey');
7
+ async function getCreds(ctx) {
8
+ const c = await ctx.getCredentials('dopomogaiApiKey');
9
+ // Defensive: use default if missing, as n8n sometimes fails to return all fields if definition is stale
10
+ const apiBaseUrl = String(c?.apiBaseUrl || 'https://api.dopomogai.com').replace(/\/+$/, '');
11
+ const apiKey = c?.apiKey;
12
+ const sendAs = c?.sendAs || 'authorizationBearer';
13
+ if (!apiKey) {
14
+ const foundKeys = Object.keys(c || {}).join(', ');
15
+ throw new Error(`DopomogAI API Key is missing in credentials record. Keys found: ${foundKeys || 'none'}`);
16
+ }
13
17
  return {
14
- apiBaseUrl: String(c.apiBaseUrl).replace(/\/+$/, ''),
15
- apiKey: String(c.apiKey),
16
- sendAs: (c.sendAs || 'authorizationBearer'),
18
+ apiBaseUrl,
19
+ apiKey: String(apiKey),
20
+ sendAs: sendAs,
17
21
  };
18
22
  }
19
23
  function buildHeaders(creds, extra) {
@@ -40,7 +44,7 @@ function pickErrorMessage(payload) {
40
44
  return '';
41
45
  }
42
46
  async function requestJson(ctx, opts) {
43
- const creds = getCreds(ctx);
47
+ const creds = await getCreds(ctx);
44
48
  const url = new URL(`${creds.apiBaseUrl}${opts.path}`);
45
49
  if (opts.query) {
46
50
  for (const [k, v] of Object.entries(opts.query)) {
@@ -73,7 +77,7 @@ async function requestJson(ctx, opts) {
73
77
  return { data: payload, status: res.status, headers: res.headers };
74
78
  }
75
79
  async function requestFormData(ctx, opts) {
76
- const creds = getCreds(ctx);
80
+ const creds = await getCreds(ctx);
77
81
  const url = new URL(`${creds.apiBaseUrl}${opts.path}`);
78
82
  if (opts.query) {
79
83
  for (const [k, v] of Object.entries(opts.query)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-dopomogai",
3
- "version": "1.3.5",
3
+ "version": "1.3.8",
4
4
  "description": "n8n community nodes for DopomogAI (Agents, Chat, Conversations, Files, Tools, KB).",
5
5
  "license": "MIT",
6
6
  "author": "DopomogAI",