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.
@@ -0,0 +1,2 @@
1
+ import { INodeProperties } from 'n8n-workflow';
2
+ export declare const personGetProperties: INodeProperties[];
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.personGetProperties = void 0;
4
+ exports.personGetProperties = [
5
+ {
6
+ displayName: 'Person Id',
7
+ name: 'personId',
8
+ type: 'string',
9
+ default: '',
10
+ required: true,
11
+ displayOptions: { show: { resource: ['person'], operation: ['get'] } },
12
+ description: 'Person Id to fetch (required).',
13
+ },
14
+ ];
@@ -0,0 +1,6 @@
1
+ export { personCreate } from './create.operation';
2
+ export { personUpdate } from './update.operation';
3
+ export { personGet } from './get.operation';
4
+ export { personCreateProperties } from './create.properties';
5
+ export { personUpdateProperties } from './update.properties';
6
+ export { personGetProperties } from './get.properties';
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.personGetProperties = exports.personUpdateProperties = exports.personCreateProperties = exports.personGet = exports.personUpdate = exports.personCreate = void 0;
4
+ var create_operation_1 = require("./create.operation");
5
+ Object.defineProperty(exports, "personCreate", { enumerable: true, get: function () { return create_operation_1.personCreate; } });
6
+ var update_operation_1 = require("./update.operation");
7
+ Object.defineProperty(exports, "personUpdate", { enumerable: true, get: function () { return update_operation_1.personUpdate; } });
8
+ var get_operation_1 = require("./get.operation");
9
+ Object.defineProperty(exports, "personGet", { enumerable: true, get: function () { return get_operation_1.personGet; } });
10
+ var create_properties_1 = require("./create.properties");
11
+ Object.defineProperty(exports, "personCreateProperties", { enumerable: true, get: function () { return create_properties_1.personCreateProperties; } });
12
+ var update_properties_1 = require("./update.properties");
13
+ Object.defineProperty(exports, "personUpdateProperties", { enumerable: true, get: function () { return update_properties_1.personUpdateProperties; } });
14
+ var get_properties_1 = require("./get.properties");
15
+ Object.defineProperty(exports, "personGetProperties", { enumerable: true, get: function () { return get_properties_1.personGetProperties; } });
@@ -0,0 +1,2 @@
1
+ import { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
2
+ export declare function personUpdate(this: IExecuteFunctions, i: number, returnData: INodeExecutionData[]): Promise<void>;
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.personUpdate = personUpdate;
4
+ const http_1 = require("../../lib/http");
5
+ async function personUpdate(i, returnData) {
6
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
7
+ const id = this.getNodeParameter('Id', i, '');
8
+ if (!id)
9
+ throw new Error('Id is required.');
10
+ const lastName = this.getNodeParameter('LastName', i, '');
11
+ if (!lastName)
12
+ throw new Error('LastName is required.');
13
+ const firstName = this.getNodeParameter('FirstName', i, '');
14
+ const mobile = this.getNodeParameter('MobilePhone', i, '');
15
+ const workPhone = this.getNodeParameter('WorkPhone', i, '');
16
+ // Owner
17
+ const ownerMode = this.getNodeParameter('OwnerMode', i);
18
+ const ownerId = ownerMode === 'select'
19
+ ? this.getNodeParameter('OwnerIdSelect', i, '')
20
+ : this.getNodeParameter('OwnerIdManual', i, '');
21
+ if (!ownerId)
22
+ throw new Error('OwnerId is required (select from list or enter manually).');
23
+ const add = this.getNodeParameter('additionalFields', i, {}) || {};
24
+ const title = (_a = add.Title) !== null && _a !== void 0 ? _a : '';
25
+ const companyName = (_b = add.CompanyName) !== null && _b !== void 0 ? _b : '';
26
+ const companyId = (_c = add.CompanyId) !== null && _c !== void 0 ? _c : '00000000-0000-0000-0000-000000000000';
27
+ const birthDate = (_d = add.BirthDate) !== null && _d !== void 0 ? _d : '';
28
+ const birthDateMessageId = (_e = add.BirthDateMessageId) !== null && _e !== void 0 ? _e : '00000000-0000-0000-0000-000000000000';
29
+ const workPhoneExt = (_f = add.WorkPhoneExtension) !== null && _f !== void 0 ? _f : '';
30
+ const fax = (_g = add.Fax) !== null && _g !== void 0 ? _g : '';
31
+ const email = (_h = add.Email) !== null && _h !== void 0 ? _h : '';
32
+ const isVip = (_j = add.IsVIP) !== null && _j !== void 0 ? _j : false;
33
+ const backgroundInfo = (_k = add.BackgroundInfo) !== null && _k !== void 0 ? _k : '';
34
+ const position = (_l = add.Position) !== null && _l !== void 0 ? _l : '';
35
+ const customerCode = (_m = add.CustomerCode) !== null && _m !== void 0 ? _m : '';
36
+ const nationalCode = (_o = add.NationalCode) !== null && _o !== void 0 ? _o : '';
37
+ const zipCode = (_p = add.ZipCode) !== null && _p !== void 0 ? _p : '';
38
+ const visibilityType = (_q = add.VisibilityType) !== null && _q !== void 0 ? _q : 'Owner';
39
+ // Fields
40
+ let fields;
41
+ if (typeof add.Fields === 'string' && add.Fields.trim()) {
42
+ try {
43
+ fields = JSON.parse(add.Fields);
44
+ }
45
+ catch {
46
+ throw new Error('Invalid JSON in "Custom Fields (JSON)".');
47
+ }
48
+ }
49
+ else if (typeof add.Fields === 'object' && add.Fields) {
50
+ fields = add.Fields;
51
+ }
52
+ // helpers
53
+ const toKeyValues = (obj) => {
54
+ var _a;
55
+ if (!obj || typeof obj !== 'object')
56
+ return undefined;
57
+ const list = (_a = obj.KeyValues) !== null && _a !== void 0 ? _a : [];
58
+ if (!Array.isArray(list) || !list.length)
59
+ return undefined;
60
+ return { KeyValues: list.map(e => { var _a, _b; return ({ Key: (_a = e.Key) !== null && _a !== void 0 ? _a : '', Value: (_b = e.Value) !== null && _b !== void 0 ? _b : '' }); }) };
61
+ };
62
+ const websites = toKeyValues(add.Websites);
63
+ const otherPhones = toKeyValues(add.OtherPhones);
64
+ const otherEmails = toKeyValues(add.OtherEmails);
65
+ const addresses = toKeyValues(add.Addresses);
66
+ let bankAccounts;
67
+ if (add.BankAccounts && typeof add.BankAccounts === 'object') {
68
+ const vals = add.BankAccounts.Values;
69
+ if (Array.isArray(vals) && vals.length) {
70
+ bankAccounts = { Values: vals.map(v => {
71
+ var _a, _b, _c, _d;
72
+ return ({
73
+ Value1: (_a = v.Value1) !== null && _a !== void 0 ? _a : '', Value2: (_b = v.Value2) !== null && _b !== void 0 ? _b : '', Value3: (_c = v.Value3) !== null && _c !== void 0 ? _c : '', Value4: (_d = v.Value4) !== null && _d !== void 0 ? _d : '',
74
+ });
75
+ }) };
76
+ }
77
+ }
78
+ let segmentIds;
79
+ const seg = add.SegmentIds;
80
+ if (Array.isArray(seg))
81
+ segmentIds = seg.filter(Boolean);
82
+ else if (typeof seg === 'string' && seg)
83
+ segmentIds = [seg];
84
+ // Contact body (Type همیشه Person)
85
+ const contact = {
86
+ Id: id,
87
+ Type: 'Person',
88
+ FirstName: firstName,
89
+ LastName: lastName,
90
+ Title: title,
91
+ OwnerId: ownerId,
92
+ CompanyName: companyName,
93
+ CompanyId: companyId,
94
+ BirthDate: birthDate || undefined,
95
+ BirthDateMessageId: birthDateMessageId,
96
+ MobilePhone: mobile,
97
+ WorkPhone: workPhone,
98
+ WorkPhoneExtension: workPhoneExt,
99
+ Fax: fax,
100
+ Email: email,
101
+ IsVIP: isVip,
102
+ BackgroundInfo: backgroundInfo,
103
+ Position: position,
104
+ CustomerCode: customerCode,
105
+ NationalCode: nationalCode,
106
+ ZipCode: zipCode,
107
+ VisibilityType: visibilityType,
108
+ };
109
+ if (fields)
110
+ contact['Fields'] = fields;
111
+ if (websites)
112
+ contact['Websites'] = websites;
113
+ if (otherPhones)
114
+ contact['OtherPhones'] = otherPhones;
115
+ if (otherEmails)
116
+ contact['OtherEmails'] = otherEmails;
117
+ if (addresses)
118
+ contact['Addresses'] = addresses;
119
+ if (bankAccounts)
120
+ contact['BankAccounts'] = bankAccounts;
121
+ const body = { Contact: contact };
122
+ if (segmentIds && segmentIds.length)
123
+ body['SegmentIds'] = segmentIds;
124
+ const resp = await (0, http_1.didarRequest)(this, i, {
125
+ method: 'POST',
126
+ path: '/api/contact/save',
127
+ body,
128
+ });
129
+ returnData.push({ json: resp });
130
+ }
@@ -0,0 +1,2 @@
1
+ import { INodeProperties } from 'n8n-workflow';
2
+ export declare const personUpdateProperties: INodeProperties[];
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.personUpdateProperties = void 0;
4
+ const showForPersonUpdate = { show: { resource: ['person'], operation: ['update'] } };
5
+ exports.personUpdateProperties = [
6
+ // Id (required)
7
+ {
8
+ displayName: 'Id',
9
+ name: 'Id',
10
+ type: 'string',
11
+ default: '',
12
+ required: true,
13
+ displayOptions: showForPersonUpdate,
14
+ description: 'Person Id to update (required).',
15
+ },
16
+ // ترتیب اصلی: FirstName, LastName(required), MobilePhone, WorkPhone
17
+ {
18
+ displayName: 'First Name',
19
+ name: 'FirstName',
20
+ type: 'string',
21
+ default: '',
22
+ displayOptions: showForPersonUpdate,
23
+ description: 'Optional given name of the person.',
24
+ },
25
+ {
26
+ displayName: 'Last Name',
27
+ name: 'LastName',
28
+ type: 'string',
29
+ default: '',
30
+ required: true,
31
+ displayOptions: showForPersonUpdate,
32
+ description: 'Required family name (last name) of the person.',
33
+ },
34
+ {
35
+ displayName: 'Mobile Phone',
36
+ name: 'MobilePhone',
37
+ type: 'string',
38
+ default: '',
39
+ displayOptions: showForPersonUpdate,
40
+ description: 'Primary mobile phone number.',
41
+ },
42
+ {
43
+ displayName: 'Work Phone',
44
+ name: 'WorkPhone',
45
+ type: 'string',
46
+ default: '',
47
+ displayOptions: showForPersonUpdate,
48
+ description: 'Work phone number.',
49
+ },
50
+ // Owner (select/manual) مثل Create
51
+ {
52
+ displayName: 'Owner Input Mode',
53
+ name: 'OwnerMode',
54
+ type: 'options',
55
+ options: [
56
+ { name: 'Select from list', value: 'select' },
57
+ { name: 'Enter ID manually', value: 'manual' },
58
+ ],
59
+ default: 'select',
60
+ displayOptions: showForPersonUpdate,
61
+ description: 'Choose how to set the owner of this person.',
62
+ },
63
+ {
64
+ displayName: 'Owner',
65
+ name: 'OwnerIdSelect',
66
+ type: 'options',
67
+ typeOptions: { loadOptionsMethod: 'getUsers' },
68
+ default: '',
69
+ displayOptions: { show: { ...showForPersonUpdate.show, OwnerMode: ['select'] } },
70
+ description: 'Select the owner user (required if select mode).',
71
+ },
72
+ {
73
+ displayName: 'Owner ID',
74
+ name: 'OwnerIdManual',
75
+ type: 'string',
76
+ default: '',
77
+ displayOptions: { show: { ...showForPersonUpdate.show, OwnerMode: ['manual'] } },
78
+ description: 'Enter owner user ID manually (required if manual mode).',
79
+ },
80
+ // Additional Fields (همان Create)
81
+ {
82
+ displayName: 'Additional Fields',
83
+ name: 'additionalFields',
84
+ type: 'collection',
85
+ placeholder: 'Add field',
86
+ default: {},
87
+ displayOptions: showForPersonUpdate,
88
+ options: [
89
+ { displayName: 'Title', name: 'Title', type: 'string', default: '', description: 'Honorific or title (e.g., Mr., Ms., Dr.).' },
90
+ { displayName: 'Company Name', name: 'CompanyName', type: 'string', default: '', description: 'Related company name (plain text).' },
91
+ { displayName: 'Company ID', name: 'CompanyId', type: 'string', default: '00000000-0000-0000-0000-000000000000', description: 'Related company ID (GUID).' },
92
+ { displayName: 'Birth Date (ISO)', name: 'BirthDate', type: 'string', default: '', description: 'Birth date in ISO format (e.g., 2025-08-31T08:02:06Z).' },
93
+ { displayName: 'Birth Date Message ID', name: 'BirthDateMessageId', type: 'string', default: '00000000-0000-0000-0000-000000000000', description: 'Notification/message template ID for birthday (GUID).' },
94
+ { displayName: 'Work Phone Extension', name: 'WorkPhoneExtension', type: 'string', default: '', description: 'Extension for the work phone.' },
95
+ { displayName: 'Fax', name: 'Fax', type: 'string', default: '', description: 'Fax number.' },
96
+ { displayName: 'Email', name: 'Email', type: 'string', default: '', description: 'Primary email address.' },
97
+ { displayName: 'Is VIP', name: 'IsVIP', type: 'boolean', default: false, description: 'Mark this person as VIP.' },
98
+ { displayName: 'Background Info', name: 'BackgroundInfo', type: 'string', default: '', description: 'Notes or background information.' },
99
+ { displayName: 'Position', name: 'Position', type: 'string', default: '', description: 'Job title or position.' },
100
+ { displayName: 'Customer Code', name: 'CustomerCode', type: 'string', default: '', description: 'Internal or CRM customer code.' },
101
+ { displayName: 'National Code', name: 'NationalCode associated with the person', type: 'string', default: '', description: 'National ID code.' },
102
+ { displayName: 'Zip Code', name: 'ZipCode', type: 'string', default: '', description: 'Postal/ZIP code.' },
103
+ {
104
+ displayName: 'Visibility Type',
105
+ name: 'VisibilityType',
106
+ type: 'options',
107
+ options: [
108
+ { name: 'Owner', value: 'Owner' },
109
+ { name: 'Owner Group', value: 'OwnerGroup' },
110
+ { name: 'Owner SubGroup', value: 'OwnerSubGroup' },
111
+ { name: 'All', value: 'All' },
112
+ ],
113
+ default: 'Owner',
114
+ description: 'Visibility setting for this person.',
115
+ },
116
+ { displayName: 'Custom Fields (JSON)', name: 'Fields', type: 'json', default: '', placeholder: '{ "Field_996_0_7": "value" }', description: 'JSON object of custom fields.' },
117
+ // Lists
118
+ {
119
+ displayName: 'Websites',
120
+ name: 'Websites',
121
+ type: 'fixedCollection',
122
+ typeOptions: { multipleValues: true },
123
+ default: {},
124
+ options: [{ name: 'KeyValues', displayName: 'Website', values: [
125
+ { displayName: 'Key', name: 'Key', type: 'string', default: '' },
126
+ { displayName: 'Value', name: 'Value', type: 'string', default: '' },
127
+ ] }],
128
+ description: 'List of websites as key/value pairs.',
129
+ },
130
+ {
131
+ displayName: 'Other Phones',
132
+ name: 'OtherPhones',
133
+ type: 'fixedCollection',
134
+ typeOptions: { multipleValues: true },
135
+ default: {},
136
+ options: [{ name: 'KeyValues', displayName: 'Phone', values: [
137
+ { displayName: 'Key', name: 'Key', type: 'string', default: '' },
138
+ { displayName: 'Value', name: 'Value', type: 'string', default: '' },
139
+ ] }],
140
+ description: 'Additional phone numbers as key/value pairs.',
141
+ },
142
+ {
143
+ displayName: 'Other Emails',
144
+ name: 'OtherEmails',
145
+ type: 'fixedCollection',
146
+ typeOptions: { multipleValues: true },
147
+ default: {},
148
+ options: [{ name: 'KeyValues', displayName: 'Email', values: [
149
+ { displayName: 'Key', name: 'Key', type: 'string', default: '' },
150
+ { displayName: 'Value', name: 'Value', type: 'string', default: '' },
151
+ ] }],
152
+ description: 'Additional emails as key/value pairs.',
153
+ },
154
+ {
155
+ displayName: 'Addresses',
156
+ name: 'Addresses',
157
+ type: 'fixedCollection',
158
+ typeOptions: { multipleValues: true },
159
+ default: {},
160
+ options: [{ name: 'KeyValues', displayName: 'Address', values: [
161
+ { displayName: 'Key', name: 'Key', type: 'string', default: '' },
162
+ { displayName: 'Value', name: 'Value', type: 'string', default: '' },
163
+ ] }],
164
+ description: 'Addresses as key/value pairs (e.g., Home/Work/etc.).',
165
+ },
166
+ {
167
+ displayName: 'Bank Accounts',
168
+ name: 'BankAccounts',
169
+ type: 'fixedCollection',
170
+ typeOptions: { multipleValues: true },
171
+ default: {},
172
+ options: [{ name: 'Values', displayName: 'Bank Account', values: [
173
+ { displayName: 'Value1', name: 'Value1', type: 'string', default: '' },
174
+ { displayName: 'Value2', name: 'Value2', type: 'string', default: '' },
175
+ { displayName: 'Value3', name: 'Value3', type: 'string', default: '' },
176
+ { displayName: 'Value4', name: 'Value4', type: 'string', default: '' },
177
+ ] }],
178
+ description: 'Bank account details (four flexible fields per entry).',
179
+ },
180
+ // SegmentIds
181
+ {
182
+ displayName: 'Segment IDs',
183
+ name: 'SegmentIds',
184
+ type: 'string',
185
+ typeOptions: { multipleValues: true },
186
+ default: [],
187
+ description: 'List of segment IDs (GUIDs).',
188
+ },
189
+ ],
190
+ },
191
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-didar-crm",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Didar CRM nodes for n8n (Trigger + Deal.create)",
5
5
  "author": "You",
6
6
  "license": "MIT",