n8n-nodes-digit 0.1.20 → 0.1.21

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.
@@ -241,14 +241,16 @@ class DIGIT {
241
241
  }
242
242
  }
243
243
  // ==================================================
244
- // NOTIFICATIONSEND EMAIL (FIXED)
244
+ // REGISTRYSAVE DATA
245
245
  // ==================================================
246
- if (resource === 'notification') {
247
- const operation = this.getNodeParameter('notificationOperation', 0);
248
- if (operation === 'notification_send_email') {
246
+ if (resource === 'registry') {
247
+ const operation = this.getNodeParameter('registryOperation', 0);
248
+ if (operation === 'registry_save') {
249
249
  for (let i = 0; i < items.length; i++) {
250
250
  try {
251
251
  const tenantId = this.getNodeParameter('tenantId', i);
252
+ const clientId = this.getNodeParameter('clientId', i);
253
+ const schemaCode = this.getNodeParameter('schemaCode', i);
252
254
  const accessToken = this.getNodeParameter('accessToken', i);
253
255
  const cleanToken = accessToken.replace(/^Bearer\s+/i, '').trim();
254
256
  let body;
@@ -258,32 +260,120 @@ class DIGIT {
258
260
  catch {
259
261
  throw new Error('Invalid JSON in Request Body');
260
262
  }
261
- const url = new URL('/notification/v1/email/send', baseUrl).toString();
263
+ const url = new URL(`/registry/v1/schema/${schemaCode}/data`, baseUrl).toString();
262
264
  const response = await this.helpers.httpRequest({
263
265
  method: 'POST',
264
266
  url,
265
267
  headers: {
266
268
  'X-Tenant-ID': tenantId,
269
+ 'X-Client-ID': clientId,
267
270
  Authorization: `Bearer ${cleanToken}`,
268
271
  'Content-Type': 'application/json',
269
272
  },
270
273
  body,
271
274
  json: true,
272
275
  });
273
- // Push only JSON-safe data
274
- returnData.push({
275
- json: response,
276
+ returnData.push({ json: response });
277
+ }
278
+ catch (error) {
279
+ if (this.continueOnFail()) {
280
+ returnData.push({ json: { error: error.message } });
281
+ }
282
+ else {
283
+ throw error;
284
+ }
285
+ }
286
+ }
287
+ return [returnData];
288
+ }
289
+ }
290
+ // ==================================================
291
+ // REGISTRY — SEARCH
292
+ // ==================================================
293
+ if (resource === 'registry') {
294
+ const operation = this.getNodeParameter('registryOperation', 0);
295
+ if (operation === 'registry_search') {
296
+ for (let i = 0; i < items.length; i++) {
297
+ try {
298
+ const tenantId = this.getNodeParameter('tenantId', i);
299
+ const clientId = this.getNodeParameter('clientId', i);
300
+ const schemaCode = this.getNodeParameter('schemaCode', i);
301
+ const accessToken = this.getNodeParameter('accessToken', i);
302
+ const cleanToken = accessToken.replace(/^Bearer\s+/i, '').trim();
303
+ let body;
304
+ try {
305
+ body = JSON.parse(this.getNodeParameter('requestBody', i));
306
+ }
307
+ catch {
308
+ throw new Error('Invalid JSON in Request Body');
309
+ }
310
+ const url = new URL(`/registry/v1/schema/${schemaCode}/data/_search`, baseUrl).toString();
311
+ const response = await this.helpers.httpRequest({
312
+ method: 'POST',
313
+ url,
314
+ headers: {
315
+ 'X-Tenant-ID': tenantId,
316
+ 'X-Client-ID': clientId,
317
+ Authorization: `Bearer ${cleanToken}`,
318
+ 'Content-Type': 'application/json',
319
+ },
320
+ body,
321
+ json: true,
276
322
  });
323
+ returnData.push({ json: response });
277
324
  }
278
325
  catch (error) {
279
326
  if (this.continueOnFail()) {
280
- // Never push raw error object
281
- returnData.push({
282
- json: {
283
- error: error.message,
284
- statusCode: error.statusCode || null,
285
- },
286
- });
327
+ returnData.push({ json: { error: error.message } });
328
+ }
329
+ else {
330
+ throw error;
331
+ }
332
+ }
333
+ }
334
+ return [returnData];
335
+ }
336
+ }
337
+ // ==================================================
338
+ // REGISTRY — UPDATE
339
+ // ==================================================
340
+ if (resource === 'registry') {
341
+ const operation = this.getNodeParameter('registryOperation', 0);
342
+ if (operation === 'registry_update') {
343
+ for (let i = 0; i < items.length; i++) {
344
+ try {
345
+ const tenantId = this.getNodeParameter('tenantId', i);
346
+ const clientId = this.getNodeParameter('clientId', i);
347
+ const schemaCode = this.getNodeParameter('schemaCode', i);
348
+ const recordId = this.getNodeParameter('recordId', i);
349
+ const accessToken = this.getNodeParameter('accessToken', i);
350
+ const cleanToken = accessToken.replace(/^Bearer\s+/i, '').trim();
351
+ let body;
352
+ try {
353
+ body = JSON.parse(this.getNodeParameter('requestBody', i));
354
+ }
355
+ catch {
356
+ throw new Error('Invalid JSON in Request Body');
357
+ }
358
+ const url = new URL(`/registry/v1/schema/${schemaCode}/data`, baseUrl);
359
+ url.searchParams.set('id', recordId);
360
+ const response = await this.helpers.httpRequest({
361
+ method: 'PUT',
362
+ url: url.toString(),
363
+ headers: {
364
+ 'X-Tenant-ID': tenantId,
365
+ 'X-Client-ID': clientId,
366
+ Authorization: `Bearer ${cleanToken}`,
367
+ 'Content-Type': 'application/json',
368
+ },
369
+ body,
370
+ json: true,
371
+ });
372
+ returnData.push({ json: response });
373
+ }
374
+ catch (error) {
375
+ if (this.continueOnFail()) {
376
+ returnData.push({ json: { error: error.message } });
287
377
  }
288
378
  else {
289
379
  throw error;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-digit",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "DIGIT Platform nodes for n8n",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-digit",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "description": "DIGIT Platform nodes for n8n",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",