n8n-nodes-didar-crm 0.0.6 → 0.0.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.
@@ -36,6 +36,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.DidarCrm = void 0;
37
37
  const DealOps = __importStar(require("./deal"));
38
38
  const Load = __importStar(require("../lib/loadOptions"));
39
+ const deal_1 = require("./deal");
40
+ const PersonOps = __importStar(require("./person"));
41
+ const person_1 = require("./person");
39
42
  class DidarCrm {
40
43
  constructor() {
41
44
  this.methods = {
@@ -62,7 +65,10 @@ class DidarCrm {
62
65
  displayName: 'Resource',
63
66
  name: 'resource',
64
67
  type: 'options',
65
- options: [{ name: 'Deal', value: 'deal' }],
68
+ options: [
69
+ { name: 'Deal', value: 'deal' },
70
+ { name: 'Person', value: 'person' },
71
+ ],
66
72
  default: 'deal',
67
73
  description: 'Choose the entity to act on.',
68
74
  },
@@ -79,449 +85,28 @@ class DidarCrm {
79
85
  default: 'create',
80
86
  description: 'Select the action to perform on the selected resource.',
81
87
  },
82
- // ========================= Deal → Create (MAIN FIELDS) =========================
83
- // 1) Title
84
- {
85
- displayName: 'Title',
86
- name: 'Title',
87
- type: 'string',
88
- default: '',
89
- displayOptions: { show: { resource: ['deal'], operation: ['create'] } },
90
- description: 'Deal title (required).',
91
- },
92
- // 2) Owner (select/manual)
93
- {
94
- displayName: 'Owner Input Mode',
95
- name: 'OwnerMode',
96
- type: 'options',
97
- options: [
98
- { name: 'Select from list', value: 'select' },
99
- { name: 'Enter ID manually', value: 'manual' },
100
- ],
101
- default: 'select',
102
- displayOptions: { show: { resource: ['deal'], operation: ['create'] } },
103
- description: 'Choose how to set the owner.',
104
- },
105
- {
106
- displayName: 'Owner',
107
- name: 'OwnerIdSelect',
108
- type: 'options',
109
- typeOptions: { loadOptionsMethod: 'getUsers' },
110
- default: '',
111
- displayOptions: {
112
- show: { resource: ['deal'], operation: ['create'], OwnerMode: ['select'] },
113
- },
114
- description: 'Select the deal owner (required if select mode).',
115
- },
116
- {
117
- displayName: 'Owner ID',
118
- name: 'OwnerIdManual',
119
- type: 'string',
120
- default: '',
121
- displayOptions: {
122
- show: { resource: ['deal'], operation: ['create'], OwnerMode: ['manual'] },
123
- },
124
- description: 'Enter owner ID manually (required if manual mode).',
125
- },
126
- // 3) Pipeline (select/manual)
127
88
  {
128
- displayName: 'Pipeline Input Mode',
129
- name: 'PipelineMode',
130
- type: 'options',
131
- options: [
132
- { name: 'Select from list', value: 'select' },
133
- { name: 'Enter ID manually', value: 'manual' },
134
- ],
135
- default: 'select',
136
- displayOptions: { show: { resource: ['deal'], operation: ['create'] } },
137
- description: 'Choose how to set the pipeline.',
138
- },
139
- {
140
- displayName: 'Pipeline',
141
- name: 'PipelineIdSelect',
142
- type: 'options',
143
- typeOptions: { loadOptionsMethod: 'getPipelines' },
144
- default: '',
145
- displayOptions: {
146
- show: { resource: ['deal'], operation: ['create'], PipelineMode: ['select'] },
147
- },
148
- description: 'Pick a pipeline (required if select mode).',
149
- },
150
- {
151
- displayName: 'Pipeline ID',
152
- name: 'PipelineId',
153
- type: 'string',
154
- default: '',
155
- displayOptions: {
156
- show: { resource: ['deal'], operation: ['create'], PipelineMode: ['manual'] },
157
- },
158
- description: 'Enter pipeline ID (required if manual mode).',
159
- },
160
- // 4) Stage (select/manual)
161
- {
162
- displayName: 'Stage Input Mode',
163
- name: 'StageMode',
164
- type: 'options',
165
- options: [
166
- { name: 'Select from list', value: 'select' },
167
- { name: 'Enter ID manually', value: 'manual' },
168
- ],
169
- default: 'select',
170
- displayOptions: { show: { resource: ['deal'], operation: ['create'] } },
171
- description: 'Choose how to set the stage.',
172
- },
173
- {
174
- displayName: 'Pipeline Stage',
175
- name: 'PipelineStageIdSelect',
176
- type: 'options',
177
- typeOptions: {
178
- loadOptionsMethod: 'getStagesForPipeline',
179
- loadOptionsDependsOn: ['PipelineIdSelect'],
180
- },
181
- default: '',
182
- displayOptions: {
183
- show: {
184
- resource: ['deal'],
185
- operation: ['create'],
186
- StageMode: ['select'],
187
- PipelineMode: ['select'],
188
- },
189
- },
190
- description: 'Pick a stage (required if select mode).',
191
- },
192
- {
193
- displayName: 'Pipeline Stage ID',
194
- name: 'PipelineStageId',
195
- type: 'string',
196
- default: '',
197
- displayOptions: {
198
- show: { resource: ['deal'], operation: ['create'], StageMode: ['manual'] },
199
- },
200
- description: 'Enter stage ID (required if manual mode).',
201
- },
202
- // 5) Person (default zero-guid)
203
- {
204
- displayName: 'Person ID',
205
- name: 'PersonId',
206
- type: 'string',
207
- default: '00000000-0000-0000-0000-000000000000',
208
- displayOptions: { show: { resource: ['deal'], operation: ['create'] } },
209
- description: 'Person ID related to the deal (required).',
210
- },
211
- // 6) Company (default zero-guid)
212
- {
213
- displayName: 'Company ID',
214
- name: 'CompanyId',
215
- type: 'string',
216
- default: '00000000-0000-0000-0000-000000000000',
217
- displayOptions: { show: { resource: ['deal'], operation: ['create'] } },
218
- description: 'Company ID related to the deal (required).',
219
- },
220
- // Status dropdown (required)
221
- {
222
- displayName: 'Status',
223
- name: 'Status',
224
- type: 'options',
225
- options: [
226
- { name: 'Pending', value: 'Pending' },
227
- { name: 'Won', value: 'Won' },
228
- { name: 'Lost', value: 'Lost' },
229
- ],
230
- default: 'Pending',
231
- displayOptions: { show: { resource: ['deal'], operation: ['create'] } },
232
- description: 'Deal status (required).',
233
- },
234
- // ========================= Additional Fields (OPTIONAL) =========================
235
- {
236
- displayName: 'Additional Fields',
237
- name: 'additionalFields',
238
- type: 'collection',
239
- placeholder: 'Add field',
240
- default: {},
241
- displayOptions: { show: { resource: ['deal'], operation: ['create'] } },
242
- options: [
243
- // طبق خواسته: SourceOther بلافاصله بعد از SourceId
244
- {
245
- displayName: 'Source ID',
246
- name: 'SourceId',
247
- type: 'string',
248
- default: '00000000-0000-0000-0000-000000000000',
249
- description: 'Source identifier (optional).',
250
- },
251
- {
252
- displayName: 'Source Other',
253
- name: 'SourceOther',
254
- type: 'string',
255
- default: '',
256
- description: 'Custom text for other/unlisted sources.',
257
- },
258
- // LostReason سه‌تایی کنار هم (در UI n8n همه در همین Collection خواهند بود)
259
- {
260
- displayName: 'Lost Reason ID',
261
- name: 'LostReasonId',
262
- type: 'string',
263
- default: '00000000-0000-0000-0000-000000000000',
264
- description: 'Lost reason identifier.',
265
- },
266
- {
267
- displayName: 'Lost Reason Note',
268
- name: 'LostReasonNote',
269
- type: 'string',
270
- default: '',
271
- description: 'Additional notes for lost reason.',
272
- },
273
- {
274
- displayName: 'Lost Reason Other',
275
- name: 'LostReasonOther',
276
- type: 'string',
277
- default: '',
278
- description: 'Custom lost reason text.',
279
- },
280
- {
281
- displayName: 'Description',
282
- name: 'Description',
283
- type: 'string',
284
- default: '',
285
- description: 'Optional description for the deal.',
286
- },
287
- {
288
- displayName: 'Creator ID',
289
- name: 'CreatorId',
290
- type: 'string',
291
- default: '00000000-0000-0000-0000-000000000000',
292
- description: 'Creator user ID (defaults to owner if empty).',
293
- },
294
- {
295
- displayName: 'Price',
296
- name: 'Price',
297
- type: 'string',
298
- default: '0',
299
- description: 'Deal price/amount.',
300
- },
301
- {
302
- displayName: 'Visibility Type',
303
- name: 'VisibilityType',
304
- type: 'options',
305
- options: [
306
- { name: 'Owner', value: '0' },
307
- { name: 'Owner Group', value: '1' },
308
- { name: 'Owner SubGroup', value: '2' },
309
- { name: 'All', value: '3' },
310
- ],
311
- default: 'Owner',
312
- description: 'Visibility setting: restricts who can see this deal.',
313
- },
314
- {
315
- displayName: 'Custom Fields (JSON)',
316
- name: 'Fields',
317
- type: 'json',
318
- default: '',
319
- placeholder: '{ "Field_8783_12_4": 12 }',
320
- description: 'JSON object of custom fields.',
321
- },
322
- ],
323
- },
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',
89
+ displayName: 'Operation',
90
+ name: 'operation',
474
91
  type: 'options',
92
+ displayOptions: { show: { resource: ['person'] } },
475
93
  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.' },
94
+ { name: 'Create', value: 'create', action: 'Create a person' },
95
+ { name: 'Update', value: 'update', action: 'Update a person by Id' },
96
+ { name: 'Get', value: 'get', action: 'Get a person by Id' },
513
97
  ],
98
+ default: 'create',
99
+ description: 'Select the action to perform on the selected resource.',
514
100
  },
515
- // ================= Deal Get (MAIN FIELDS) =========================
516
- {
517
- displayName: 'Deal Id',
518
- name: 'dealId',
519
- type: 'string',
520
- default: '',
521
- displayOptions: { show: { resource: ['deal'], operation: ['get'] } },
522
- description: 'Deal Id to fetch (required).',
523
- }
524
- ]
101
+ // Deal properties (imported)
102
+ ...deal_1.dealCreateProperties,
103
+ ...deal_1.dealUpdateProperties,
104
+ ...deal_1.dealGetProperties,
105
+ // Person properties (imported)
106
+ ...person_1.personCreateProperties,
107
+ ...person_1.personUpdateProperties,
108
+ ...person_1.personGetProperties,
109
+ ],
525
110
  };
526
111
  }
527
112
  async execute() {
@@ -544,6 +129,20 @@ class DidarCrm {
544
129
  continue;
545
130
  }
546
131
  }
132
+ if (resource === 'person') {
133
+ if (operation === 'create') {
134
+ await PersonOps.personCreate.call(this, i, returnData);
135
+ continue;
136
+ }
137
+ if (operation === 'update') {
138
+ await PersonOps.personUpdate.call(this, i, returnData);
139
+ continue;
140
+ }
141
+ if (operation === 'get') {
142
+ await PersonOps.personGet.call(this, i, returnData);
143
+ continue;
144
+ }
145
+ }
547
146
  }
548
147
  return [returnData];
549
148
  }
@@ -0,0 +1,8 @@
1
+ import { INodeProperties } from 'n8n-workflow';
2
+ export declare const titleField: (op: "create" | "update") => INodeProperties;
3
+ export declare const ownerFields: (op: "create" | "update") => INodeProperties[];
4
+ export declare const pipelineFields: (op: "create" | "update") => INodeProperties[];
5
+ export declare const stageFields: (op: "create" | "update") => INodeProperties[];
6
+ export declare const personCompanyFields: (op: "create" | "update") => INodeProperties[];
7
+ export declare const statusField: (op: "create" | "update") => INodeProperties;
8
+ export declare const additionalFields: (op: "create" | "update") => INodeProperties;