n8n-nodes-didar-crm 0.0.4 → 0.0.5

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.
@@ -321,10 +321,197 @@ class DidarCrm {
321
321
  },
322
322
  ],
323
323
  },
324
- // ========================= Deal Update / Get (بدون تغییر) =========================
325
- { displayName: 'Deal Id', name: 'dealId', type: 'string', default: '', displayOptions: { show: { resource: ['deal'], operation: ['update'] } }, description: 'Target deal Id (required).' },
326
- { displayName: 'Update Body (JSON)', name: 'updateBody', type: 'json', default: '', displayOptions: { show: { resource: ['deal'], operation: ['update'] } }, description: 'JSON fields to update; merged into Deal with Id.' },
327
- { displayName: 'Deal Id', name: 'dealId', type: 'string', default: '', displayOptions: { show: { resource: ['deal'], operation: ['get'] } }, description: 'Deal Id to fetch (required).' },
324
+ // ===== Deal.Update fields (exact mirror of Create, plus Id at top) =====
325
+ {
326
+ displayName: 'Id',
327
+ name: 'Id',
328
+ type: 'string',
329
+ default: '',
330
+ displayOptions: { show: { resource: ['deal'], operation: ['update'] } },
331
+ description: 'Deal Id to update (required).',
332
+ },
333
+ // 1) Title
334
+ {
335
+ displayName: 'Title',
336
+ name: 'Title',
337
+ type: 'string',
338
+ default: '',
339
+ displayOptions: { show: { resource: ['deal'], operation: ['update'] } },
340
+ description: 'Deal title (required).',
341
+ },
342
+ // 2) Owner (select/manual)
343
+ {
344
+ displayName: 'Owner Input Mode',
345
+ name: 'OwnerMode',
346
+ type: 'options',
347
+ options: [
348
+ { name: 'Select from list', value: 'select' },
349
+ { name: 'Enter ID manually', value: 'manual' },
350
+ ],
351
+ default: 'select',
352
+ displayOptions: { show: { resource: ['deal'], operation: ['update'] } },
353
+ description: 'Choose how to set the owner.',
354
+ },
355
+ {
356
+ displayName: 'Owner',
357
+ name: 'OwnerIdSelect',
358
+ type: 'options',
359
+ typeOptions: { loadOptionsMethod: 'getUsers' },
360
+ default: '',
361
+ displayOptions: {
362
+ show: { resource: ['deal'], operation: ['update'], OwnerMode: ['select'] },
363
+ },
364
+ description: 'Select the deal owner (required if select mode).',
365
+ },
366
+ {
367
+ displayName: 'Owner ID',
368
+ name: 'OwnerIdManual',
369
+ type: 'string',
370
+ default: '',
371
+ displayOptions: {
372
+ show: { resource: ['deal'], operation: ['update'], OwnerMode: ['manual'] },
373
+ },
374
+ description: 'Enter owner ID manually (required if manual mode).',
375
+ },
376
+ // 3) Pipeline (select/manual)
377
+ {
378
+ displayName: 'Pipeline Input Mode',
379
+ name: 'PipelineMode',
380
+ type: 'options',
381
+ options: [
382
+ { name: 'Select from list', value: 'select' },
383
+ { name: 'Enter ID manually', value: 'manual' },
384
+ ],
385
+ default: 'select',
386
+ displayOptions: { show: { resource: ['deal'], operation: ['update'] } },
387
+ description: 'Choose how to set the pipeline.',
388
+ },
389
+ {
390
+ displayName: 'Pipeline',
391
+ name: 'PipelineIdSelect',
392
+ type: 'options',
393
+ typeOptions: { loadOptionsMethod: 'getPipelines' },
394
+ default: '',
395
+ displayOptions: {
396
+ show: { resource: ['deal'], operation: ['update'], PipelineMode: ['select'] },
397
+ },
398
+ description: 'Pick a pipeline (required if select mode).',
399
+ },
400
+ {
401
+ displayName: 'Pipeline ID',
402
+ name: 'PipelineId',
403
+ type: 'string',
404
+ default: '',
405
+ displayOptions: {
406
+ show: { resource: ['deal'], operation: ['update'], PipelineMode: ['manual'] },
407
+ },
408
+ description: 'Enter pipeline ID (required if manual mode).',
409
+ },
410
+ // 4) Stage (select/manual)
411
+ {
412
+ displayName: 'Stage Input Mode',
413
+ name: 'StageMode',
414
+ type: 'options',
415
+ options: [
416
+ { name: 'Select from list', value: 'select' },
417
+ { name: 'Enter ID manually', value: 'manual' },
418
+ ],
419
+ default: 'select',
420
+ displayOptions: { show: { resource: ['deal'], operation: ['update'] } },
421
+ description: 'Choose how to set the stage.',
422
+ },
423
+ {
424
+ displayName: 'Pipeline Stage',
425
+ name: 'PipelineStageIdSelect',
426
+ type: 'options',
427
+ typeOptions: {
428
+ loadOptionsMethod: 'getStagesForPipeline',
429
+ loadOptionsDependsOn: ['PipelineIdSelect'],
430
+ },
431
+ default: '',
432
+ displayOptions: {
433
+ show: {
434
+ resource: ['deal'],
435
+ operation: ['update'],
436
+ StageMode: ['select'],
437
+ PipelineMode: ['select'],
438
+ },
439
+ },
440
+ description: 'Pick a stage (required if select mode).',
441
+ },
442
+ {
443
+ displayName: 'Pipeline Stage ID',
444
+ name: 'PipelineStageId',
445
+ type: 'string',
446
+ default: '',
447
+ displayOptions: {
448
+ show: { resource: ['deal'], operation: ['update'], StageMode: ['manual'] },
449
+ },
450
+ description: 'Enter stage ID (required if manual mode).',
451
+ },
452
+ // 5) Person
453
+ {
454
+ displayName: 'Person ID',
455
+ name: 'PersonId',
456
+ type: 'string',
457
+ default: '00000000-0000-0000-0000-000000000000',
458
+ displayOptions: { show: { resource: ['deal'], operation: ['update'] } },
459
+ description: 'Person ID related to the deal (required).',
460
+ },
461
+ // 6) Company
462
+ {
463
+ displayName: 'Company ID',
464
+ name: 'CompanyId',
465
+ type: 'string',
466
+ default: '00000000-0000-0000-0000-000000000000',
467
+ displayOptions: { show: { resource: ['deal'], operation: ['update'] } },
468
+ description: 'Company ID related to the deal (required).',
469
+ },
470
+ // Status dropdown
471
+ {
472
+ displayName: 'Status',
473
+ name: 'Status',
474
+ type: 'options',
475
+ options: [
476
+ { name: 'Pending', value: 'Pending' },
477
+ { name: 'Won', value: 'Won' },
478
+ { name: 'Lost', value: 'Lost' },
479
+ ],
480
+ default: 'Pending',
481
+ displayOptions: { show: { resource: ['deal'], operation: ['update'] } },
482
+ description: 'Deal status (required).',
483
+ },
484
+ // Additional Fields (same as create)
485
+ {
486
+ displayName: 'Additional Fields',
487
+ name: 'additionalFields',
488
+ type: 'collection',
489
+ placeholder: 'Add field',
490
+ default: {},
491
+ displayOptions: { show: { resource: ['deal'], operation: ['update'] } },
492
+ options: [
493
+ { displayName: 'Source ID', name: 'SourceId', type: 'string', default: '00000000-0000-0000-0000-000000000000', description: 'Source identifier (optional).' },
494
+ { displayName: 'Source Other', name: 'SourceOther', type: 'string', default: '', description: 'Custom text for other/unlisted sources.' },
495
+ { displayName: 'Lost Reason ID', name: 'LostReasonId', type: 'string', default: '00000000-0000-0000-0000-000000000000', description: 'Lost reason identifier.' },
496
+ { displayName: 'Lost Reason Note', name: 'LostReasonNote', type: 'string', default: '', description: 'Additional notes for lost reason.' },
497
+ { displayName: 'Lost Reason Other', name: 'LostReasonOther', type: 'string', default: '', description: 'Custom lost reason text.' },
498
+ { displayName: 'Description', name: 'Description', type: 'string', default: '', description: 'Optional description for the deal.' },
499
+ { displayName: 'Creator ID', name: 'CreatorId', type: 'string', default: '00000000-0000-0000-0000-000000000000', description: 'Creator user ID (defaults to owner if empty).' },
500
+ { displayName: 'Price', name: 'Price', type: 'string', default: '0', description: 'Deal price/amount.' },
501
+ {
502
+ displayName: 'Visibility Type', name: 'VisibilityType', type: 'options',
503
+ options: [
504
+ { name: 'Owner', value: 'Owner' },
505
+ { name: 'Owner Group', value: 'OwnerGroup' },
506
+ { name: 'Owner SubGroup', value: 'OwnerSubGroup' },
507
+ { name: 'All', value: 'All' },
508
+ ],
509
+ default: 'Owner',
510
+ description: 'Visibility setting.'
511
+ },
512
+ { displayName: 'Custom Fields (JSON)', name: 'Fields', type: 'json', default: '', placeholder: '{ "Field_8783_12_4": 12 }', description: 'JSON object of custom fields.' },
513
+ ],
514
+ },
328
515
  ]
329
516
  };
330
517
  }
@@ -3,26 +3,99 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.dealUpdate = dealUpdate;
4
4
  const http_1 = require("../../lib/http");
5
5
  async function dealUpdate(i, returnData) {
6
- const dealId = this.getNodeParameter('dealId', i, '');
6
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
7
+ // ---- Required Id ----
8
+ const dealId = this.getNodeParameter('Id', i, '');
7
9
  if (!dealId)
8
- throw new Error('Deal Id is required.');
9
- const updateBodyParam = this.getNodeParameter('updateBody', i, '');
10
- let updateFields = {};
11
- if (typeof updateBodyParam === 'string' && updateBodyParam.trim()) {
10
+ throw new Error('Id (Deal Id) is required for update.');
11
+ // --- Owner (required, same as create) ---
12
+ const ownerMode = this.getNodeParameter('OwnerMode', i);
13
+ const ownerId = ownerMode === 'select'
14
+ ? this.getNodeParameter('OwnerIdSelect', i, '')
15
+ : this.getNodeParameter('OwnerIdManual', i, '');
16
+ if (!ownerId) {
17
+ throw new Error('OwnerId is required (select from list or enter manually).');
18
+ }
19
+ // --- Pipeline (required) ---
20
+ const pipelineMode = this.getNodeParameter('PipelineMode', i);
21
+ const pipelineId = pipelineMode === 'select'
22
+ ? this.getNodeParameter('PipelineIdSelect', i, '')
23
+ : this.getNodeParameter('PipelineId', i, '');
24
+ if (!pipelineId) {
25
+ throw new Error('PipelineId is required (select from list or enter manually).');
26
+ }
27
+ // --- Stage (required) ---
28
+ const stageMode = this.getNodeParameter('StageMode', i);
29
+ const pipelineStageId = stageMode === 'select'
30
+ ? this.getNodeParameter('PipelineStageIdSelect', i, '')
31
+ : this.getNodeParameter('PipelineStageId', i, '');
32
+ if (!pipelineStageId) {
33
+ throw new Error('PipelineStageId is required (select from list or enter manually).');
34
+ }
35
+ // --- Required simple fields (same as create) ---
36
+ const title = this.getNodeParameter('Title', i, '');
37
+ if (!title)
38
+ throw new Error('Title is required.');
39
+ const personId = this.getNodeParameter('PersonId', i, '');
40
+ if (!personId)
41
+ throw new Error('PersonId is required.');
42
+ const companyId = this.getNodeParameter('CompanyId', i, '');
43
+ if (!companyId)
44
+ throw new Error('CompanyId is required.');
45
+ const status = this.getNodeParameter('Status', i, '');
46
+ if (!status)
47
+ throw new Error('Status is required.');
48
+ // --- Additional Fields (collection) ---
49
+ const add = this.getNodeParameter('additionalFields', i, {}) || {};
50
+ const description = (_a = add.Description) !== null && _a !== void 0 ? _a : '';
51
+ const sourceId = (_b = add.SourceId) !== null && _b !== void 0 ? _b : '00000000-0000-0000-0000-000000000000';
52
+ const sourceOther = (_c = add.SourceOther) !== null && _c !== void 0 ? _c : '';
53
+ const lostReasonId = (_d = add.LostReasonId) !== null && _d !== void 0 ? _d : '00000000-0000-0000-0000-000000000000';
54
+ const lostReasonNote = (_e = add.LostReasonNote) !== null && _e !== void 0 ? _e : '';
55
+ const lostReasonOther = (_f = add.LostReasonOther) !== null && _f !== void 0 ? _f : '';
56
+ const creatorId = (_g = add.CreatorId) !== null && _g !== void 0 ? _g : ownerId; // هم‌رفتار با create
57
+ const price = (_h = add.Price) !== null && _h !== void 0 ? _h : '0';
58
+ const visibilityType = (_j = add.VisibilityType) !== null && _j !== void 0 ? _j : 'Owner'; // دراپ‌داون متنی
59
+ // Custom fields
60
+ let fields;
61
+ if (typeof add.Fields === 'string' && add.Fields.trim()) {
12
62
  try {
13
- updateFields = JSON.parse(updateBodyParam);
63
+ fields = JSON.parse(add.Fields);
14
64
  }
15
65
  catch {
16
- throw new Error('Invalid JSON in "Update Body (JSON)".');
66
+ throw new Error('Invalid JSON in "Custom Fields (JSON)".');
17
67
  }
18
68
  }
19
- else if (typeof updateBodyParam === 'object' && updateBodyParam) {
20
- updateFields = updateBodyParam;
69
+ else if (typeof add.Fields === 'object' && add.Fields) {
70
+ fields = add.Fields;
21
71
  }
72
+ // ---- Build body (same as create, + Id) ----
73
+ const bodyDeal = {
74
+ Id: dealId,
75
+ OwnerId: ownerId,
76
+ PersonId: personId,
77
+ CompanyId: companyId,
78
+ SourceId: sourceId,
79
+ PipelineId: pipelineId,
80
+ PipelineStageId: pipelineStageId,
81
+ LostReasonId: lostReasonId,
82
+ CreatorId: creatorId,
83
+ Title: title,
84
+ Description: description,
85
+ SourceOther: sourceOther,
86
+ LostReasonNote: lostReasonNote,
87
+ LostReasonOther: lostReasonOther,
88
+ Price: price,
89
+ VisibilityType: visibilityType,
90
+ Status: status,
91
+ };
92
+ if (fields)
93
+ bodyDeal['Fields'] = fields;
94
+ // ---- Request ----
22
95
  const resp = await (0, http_1.didarRequest)(this, i, {
23
96
  method: 'POST',
24
97
  path: '/api/deal/save',
25
- body: { Deal: { Id: dealId, ...updateFields } },
98
+ body: { Deal: bodyDeal },
26
99
  });
27
100
  returnData.push({ json: resp });
28
101
  }
@@ -0,0 +1,12 @@
1
+ <svg width="108" height="108" viewBox="0 0 108 108" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <rect width="108" height="108" rx="16" fill="#00AF9D"/>
3
+ <g clip-path="url(#clip0_10086_93586)">
4
+ <path d="M80.9364 51.8304C80.7997 50.263 80.5115 48.7126 80.0758 47.2008C79.941 46.7394 79.7907 46.2884 79.63 45.8374C76.5816 37.273 68.8571 31.0985 59.8002 31.0311L56.1297 31H31.1882C30.1116 31 29.0791 31.4277 28.3178 32.1889C27.5566 32.9502 27.1289 33.9827 27.1289 35.0593C27.1289 36.1359 27.5566 37.1684 28.3178 37.9296C29.0791 38.6909 30.1116 39.1186 31.1882 39.1186H44.7295C49.0912 39.1186 53.4529 39.1186 57.8146 39.1186H59.6187C65.3681 39.1497 72.0609 44.759 73.3155 50.5551C73.357 50.7417 73.3933 50.9335 73.4244 51.1253C73.8032 53.6559 73.5466 56.2409 72.6779 58.6477C72.0322 60.4649 71.084 62.1598 69.8732 63.6609C65.0155 69.2754 60.3497 68.8451 59.0795 68.8866C58.8307 68.8866 58.5611 68.8866 58.2967 68.8866H31.1882C30.2121 68.9002 29.2736 69.265 28.5446 69.9142C27.8157 70.5635 27.3451 71.4537 27.2191 72.4217C27.0932 73.3897 27.3202 74.3707 27.8588 75.1849C28.3973 75.9991 29.2112 76.592 30.1513 76.8548L30.0891 76.9948H30.9808H31.1882H57.8146H59.0744C59.2558 76.9948 59.4373 76.9948 59.5928 76.9948H59.8987C69.1007 76.8341 76.9393 70.4004 79.827 61.5405C80.6088 59.1516 81.0163 56.6561 81.0349 54.1426C81.0401 53.3597 81.0038 52.5925 80.9364 51.8304Z" fill="white"/>
5
+ <path d="M31.1882 58.1342H62.9781C64.0547 58.1342 65.0872 57.7065 65.8485 56.9453C66.6097 56.184 67.0374 55.1515 67.0374 54.0749C67.0374 52.9983 66.6097 51.9658 65.8485 51.2046C65.0872 50.4433 64.0547 50.0156 62.9781 50.0156H31.1882C30.1116 50.0156 29.0791 50.4433 28.3178 51.2046C27.5566 51.9658 27.1289 52.9983 27.1289 54.0749C27.1289 55.1515 27.5566 56.184 28.3178 56.9453C29.0791 57.7065 30.1116 58.1342 31.1882 58.1342Z" fill="white"/>
6
+ </g>
7
+ <defs>
8
+ <clipPath id="clip0_10086_93586">
9
+ <rect width="53.8645" height="46" fill="white" transform="translate(27.1709 31)"/>
10
+ </clipPath>
11
+ </defs>
12
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-didar-crm",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Didar CRM nodes for n8n (Trigger + Deal.create)",
5
5
  "author": "You",
6
6
  "license": "MIT",