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.
- package/LICENSE +2 -2
- package/README.md +116 -23
- package/dist/nodes/DidarCrm.node.js +38 -439
- package/dist/nodes/deal/_shared.fields.d.ts +8 -0
- package/dist/nodes/deal/_shared.fields.js +191 -0
- package/dist/nodes/deal/create.properties.d.ts +2 -0
- package/dist/nodes/deal/create.properties.js +13 -0
- package/dist/nodes/deal/get.properties.d.ts +2 -0
- package/dist/nodes/deal/get.properties.js +13 -0
- package/dist/nodes/deal/index.d.ts +3 -0
- package/dist/nodes/deal/index.js +7 -1
- package/dist/nodes/deal/update.properties.d.ts +2 -0
- package/dist/nodes/deal/update.properties.js +21 -0
- package/dist/nodes/person/create.operation.d.ts +2 -0
- package/dist/nodes/person/create.operation.js +132 -0
- package/dist/nodes/person/create.properties.d.ts +2 -0
- package/dist/nodes/person/create.properties.js +224 -0
- package/dist/nodes/person/get.operation.d.ts +2 -0
- package/dist/nodes/person/get.operation.js +15 -0
- package/dist/nodes/person/get.properties.d.ts +2 -0
- package/dist/nodes/person/get.properties.js +14 -0
- package/dist/nodes/person/index.d.ts +6 -0
- package/dist/nodes/person/index.js +15 -0
- package/dist/nodes/person/update.operation.d.ts +2 -0
- package/dist/nodes/person/update.operation.js +130 -0
- package/dist/nodes/person/update.properties.d.ts +2 -0
- package/dist/nodes/person/update.properties.js +191 -0
- package/package.json +1 -1
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.additionalFields = exports.statusField = exports.personCompanyFields = exports.stageFields = exports.pipelineFields = exports.ownerFields = exports.titleField = void 0;
|
|
4
|
+
// helper برای تزریق displayOptions به فیلد
|
|
5
|
+
const showFor = (op) => ({
|
|
6
|
+
resource: ['deal'],
|
|
7
|
+
operation: [op],
|
|
8
|
+
});
|
|
9
|
+
// 1) Title
|
|
10
|
+
const titleField = (op) => ({
|
|
11
|
+
displayName: 'Title',
|
|
12
|
+
name: 'Title',
|
|
13
|
+
type: 'string',
|
|
14
|
+
default: '',
|
|
15
|
+
displayOptions: { show: { ...showFor(op) } },
|
|
16
|
+
description: 'Deal title (required).',
|
|
17
|
+
});
|
|
18
|
+
exports.titleField = titleField;
|
|
19
|
+
// 2) Owner (select/manual)
|
|
20
|
+
const ownerFields = (op) => ([
|
|
21
|
+
{
|
|
22
|
+
displayName: 'Owner Input Mode',
|
|
23
|
+
name: 'OwnerMode',
|
|
24
|
+
type: 'options',
|
|
25
|
+
options: [
|
|
26
|
+
{ name: 'Select from list', value: 'select' },
|
|
27
|
+
{ name: 'Enter ID manually', value: 'manual' },
|
|
28
|
+
],
|
|
29
|
+
default: 'select',
|
|
30
|
+
displayOptions: { show: showFor(op) },
|
|
31
|
+
description: 'Choose how to set the owner.',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
displayName: 'Owner',
|
|
35
|
+
name: 'OwnerIdSelect',
|
|
36
|
+
type: 'options',
|
|
37
|
+
typeOptions: { loadOptionsMethod: 'getUsers' },
|
|
38
|
+
default: '',
|
|
39
|
+
displayOptions: { show: { ...showFor(op), OwnerMode: ['select'] } },
|
|
40
|
+
description: 'Select the deal owner (required if select mode).',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
displayName: 'Owner ID',
|
|
44
|
+
name: 'OwnerIdManual',
|
|
45
|
+
type: 'string',
|
|
46
|
+
default: '',
|
|
47
|
+
displayOptions: { show: { ...showFor(op), OwnerMode: ['manual'] } },
|
|
48
|
+
description: 'Enter owner ID manually (required if manual mode).',
|
|
49
|
+
},
|
|
50
|
+
]);
|
|
51
|
+
exports.ownerFields = ownerFields;
|
|
52
|
+
// 3) Pipeline (select/manual)
|
|
53
|
+
const pipelineFields = (op) => ([
|
|
54
|
+
{
|
|
55
|
+
displayName: 'Pipeline Input Mode',
|
|
56
|
+
name: 'PipelineMode',
|
|
57
|
+
type: 'options',
|
|
58
|
+
options: [
|
|
59
|
+
{ name: 'Select from list', value: 'select' },
|
|
60
|
+
{ name: 'Enter ID manually', value: 'manual' },
|
|
61
|
+
],
|
|
62
|
+
default: 'select',
|
|
63
|
+
displayOptions: { show: showFor(op) },
|
|
64
|
+
description: 'Choose how to set the pipeline.',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
displayName: 'Pipeline',
|
|
68
|
+
name: 'PipelineIdSelect',
|
|
69
|
+
type: 'options',
|
|
70
|
+
typeOptions: { loadOptionsMethod: 'getPipelines' },
|
|
71
|
+
default: '',
|
|
72
|
+
displayOptions: { show: { ...showFor(op), PipelineMode: ['select'] } },
|
|
73
|
+
description: 'Pick a pipeline (required if select mode).',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
displayName: 'Pipeline ID',
|
|
77
|
+
name: 'PipelineId',
|
|
78
|
+
type: 'string',
|
|
79
|
+
default: '',
|
|
80
|
+
displayOptions: { show: { ...showFor(op), PipelineMode: ['manual'] } },
|
|
81
|
+
description: 'Enter pipeline ID (required if manual mode).',
|
|
82
|
+
},
|
|
83
|
+
]);
|
|
84
|
+
exports.pipelineFields = pipelineFields;
|
|
85
|
+
// 4) Stage (select/manual)
|
|
86
|
+
const stageFields = (op) => ([
|
|
87
|
+
{
|
|
88
|
+
displayName: 'Stage Input Mode',
|
|
89
|
+
name: 'StageMode',
|
|
90
|
+
type: 'options',
|
|
91
|
+
options: [
|
|
92
|
+
{ name: 'Select from list', value: 'select' },
|
|
93
|
+
{ name: 'Enter ID manually', value: 'manual' },
|
|
94
|
+
],
|
|
95
|
+
default: 'select',
|
|
96
|
+
displayOptions: { show: showFor(op) },
|
|
97
|
+
description: 'Choose how to set the stage.',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
displayName: 'Pipeline Stage',
|
|
101
|
+
name: 'PipelineStageIdSelect',
|
|
102
|
+
type: 'options',
|
|
103
|
+
typeOptions: {
|
|
104
|
+
loadOptionsMethod: 'getStagesForPipeline',
|
|
105
|
+
loadOptionsDependsOn: ['PipelineIdSelect'],
|
|
106
|
+
},
|
|
107
|
+
default: '',
|
|
108
|
+
displayOptions: {
|
|
109
|
+
show: { ...showFor(op), StageMode: ['select'], PipelineMode: ['select'] },
|
|
110
|
+
},
|
|
111
|
+
description: 'Pick a stage (required if select mode).',
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
displayName: 'Pipeline Stage ID',
|
|
115
|
+
name: 'PipelineStageId',
|
|
116
|
+
type: 'string',
|
|
117
|
+
default: '',
|
|
118
|
+
displayOptions: { show: { ...showFor(op), StageMode: ['manual'] } },
|
|
119
|
+
description: 'Enter stage ID (required if manual mode).',
|
|
120
|
+
},
|
|
121
|
+
]);
|
|
122
|
+
exports.stageFields = stageFields;
|
|
123
|
+
// 5) Person / 6) Company
|
|
124
|
+
const personCompanyFields = (op) => ([
|
|
125
|
+
{
|
|
126
|
+
displayName: 'Person ID',
|
|
127
|
+
name: 'PersonId',
|
|
128
|
+
type: 'string',
|
|
129
|
+
default: '00000000-0000-0000-0000-000000000000',
|
|
130
|
+
displayOptions: { show: showFor(op) },
|
|
131
|
+
description: 'Person ID related to the deal (required).',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
displayName: 'Company ID',
|
|
135
|
+
name: 'CompanyId',
|
|
136
|
+
type: 'string',
|
|
137
|
+
default: '00000000-0000-0000-0000-000000000000',
|
|
138
|
+
displayOptions: { show: showFor(op) },
|
|
139
|
+
description: 'Company ID related to the deal (required).',
|
|
140
|
+
},
|
|
141
|
+
]);
|
|
142
|
+
exports.personCompanyFields = personCompanyFields;
|
|
143
|
+
// Status
|
|
144
|
+
const statusField = (op) => ({
|
|
145
|
+
displayName: 'Status',
|
|
146
|
+
name: 'Status',
|
|
147
|
+
type: 'options',
|
|
148
|
+
options: [
|
|
149
|
+
{ name: 'Pending', value: 'Pending' },
|
|
150
|
+
{ name: 'Won', value: 'Won' },
|
|
151
|
+
{ name: 'Lost', value: 'Lost' },
|
|
152
|
+
],
|
|
153
|
+
default: 'Pending',
|
|
154
|
+
displayOptions: { show: showFor(op) },
|
|
155
|
+
description: 'Deal status (required).',
|
|
156
|
+
});
|
|
157
|
+
exports.statusField = statusField;
|
|
158
|
+
// Additional Fields
|
|
159
|
+
const additionalFields = (op) => ({
|
|
160
|
+
displayName: 'Additional Fields',
|
|
161
|
+
name: 'additionalFields',
|
|
162
|
+
type: 'collection',
|
|
163
|
+
placeholder: 'Add field',
|
|
164
|
+
default: {},
|
|
165
|
+
displayOptions: { show: showFor(op) },
|
|
166
|
+
options: [
|
|
167
|
+
{ displayName: 'Source ID', name: 'SourceId', type: 'string', default: '00000000-0000-0000-0000-000000000000', description: 'Source identifier (optional).' },
|
|
168
|
+
{ displayName: 'Source Other', name: 'SourceOther', type: 'string', default: '', description: 'Custom text for other/unlisted sources.' },
|
|
169
|
+
{ displayName: 'Lost Reason ID', name: 'LostReasonId', type: 'string', default: '00000000-0000-0000-0000-000000000000', description: 'Lost reason identifier.' },
|
|
170
|
+
{ displayName: 'Lost Reason Note', name: 'LostReasonNote', type: 'string', default: '', description: 'Additional notes for lost reason.' },
|
|
171
|
+
{ displayName: 'Lost Reason Other', name: 'LostReasonOther', type: 'string', default: '', description: 'Custom lost reason text.' },
|
|
172
|
+
{ displayName: 'Description', name: 'Description', type: 'string', default: '', description: 'Optional description for the deal.' },
|
|
173
|
+
{ displayName: 'Creator ID', name: 'CreatorId', type: 'string', default: '00000000-0000-0000-0000-000000000000', description: 'Creator user ID (defaults to owner if empty).' },
|
|
174
|
+
{ displayName: 'Price', name: 'Price', type: 'string', default: '0', description: 'Deal price/amount.' },
|
|
175
|
+
{
|
|
176
|
+
displayName: 'Visibility Type',
|
|
177
|
+
name: 'VisibilityType',
|
|
178
|
+
type: 'options',
|
|
179
|
+
options: [
|
|
180
|
+
{ name: 'Owner', value: 'Owner' },
|
|
181
|
+
{ name: 'Owner Group', value: 'OwnerGroup' },
|
|
182
|
+
{ name: 'Owner SubGroup', value: 'OwnerSubGroup' },
|
|
183
|
+
{ name: 'All', value: 'All' },
|
|
184
|
+
],
|
|
185
|
+
default: 'Owner',
|
|
186
|
+
description: 'Visibility setting.',
|
|
187
|
+
},
|
|
188
|
+
{ displayName: 'Custom Fields (JSON)', name: 'Fields', type: 'json', default: '', placeholder: '{ "Field_8783_12_4": 12 }', description: 'JSON object of custom fields.' },
|
|
189
|
+
],
|
|
190
|
+
});
|
|
191
|
+
exports.additionalFields = additionalFields;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dealCreateProperties = void 0;
|
|
4
|
+
const _shared_fields_1 = require("./_shared.fields");
|
|
5
|
+
exports.dealCreateProperties = [
|
|
6
|
+
(0, _shared_fields_1.titleField)('create'),
|
|
7
|
+
...(0, _shared_fields_1.ownerFields)('create'),
|
|
8
|
+
...(0, _shared_fields_1.pipelineFields)('create'),
|
|
9
|
+
...(0, _shared_fields_1.stageFields)('create'),
|
|
10
|
+
...(0, _shared_fields_1.personCompanyFields)('create'),
|
|
11
|
+
(0, _shared_fields_1.statusField)('create'),
|
|
12
|
+
(0, _shared_fields_1.additionalFields)('create'),
|
|
13
|
+
];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dealGetProperties = void 0;
|
|
4
|
+
exports.dealGetProperties = [
|
|
5
|
+
{
|
|
6
|
+
displayName: 'Deal Id',
|
|
7
|
+
name: 'dealId',
|
|
8
|
+
type: 'string',
|
|
9
|
+
default: '',
|
|
10
|
+
displayOptions: { show: { resource: ['deal'], operation: ['get'] } },
|
|
11
|
+
description: 'Deal Id to fetch (required).',
|
|
12
|
+
},
|
|
13
|
+
];
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export { dealCreate } from './create.operation';
|
|
2
2
|
export { dealUpdate } from './update.operation';
|
|
3
3
|
export { dealGet } from './get.operation';
|
|
4
|
+
export { dealCreateProperties } from './create.properties';
|
|
5
|
+
export { dealUpdateProperties } from './update.properties';
|
|
6
|
+
export { dealGetProperties } from './get.properties';
|
package/dist/nodes/deal/index.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dealGet = exports.dealUpdate = exports.dealCreate = void 0;
|
|
3
|
+
exports.dealGetProperties = exports.dealUpdateProperties = exports.dealCreateProperties = exports.dealGet = exports.dealUpdate = exports.dealCreate = void 0;
|
|
4
4
|
var create_operation_1 = require("./create.operation");
|
|
5
5
|
Object.defineProperty(exports, "dealCreate", { enumerable: true, get: function () { return create_operation_1.dealCreate; } });
|
|
6
6
|
var update_operation_1 = require("./update.operation");
|
|
7
7
|
Object.defineProperty(exports, "dealUpdate", { enumerable: true, get: function () { return update_operation_1.dealUpdate; } });
|
|
8
8
|
var get_operation_1 = require("./get.operation");
|
|
9
9
|
Object.defineProperty(exports, "dealGet", { enumerable: true, get: function () { return get_operation_1.dealGet; } });
|
|
10
|
+
var create_properties_1 = require("./create.properties");
|
|
11
|
+
Object.defineProperty(exports, "dealCreateProperties", { enumerable: true, get: function () { return create_properties_1.dealCreateProperties; } });
|
|
12
|
+
var update_properties_1 = require("./update.properties");
|
|
13
|
+
Object.defineProperty(exports, "dealUpdateProperties", { enumerable: true, get: function () { return update_properties_1.dealUpdateProperties; } });
|
|
14
|
+
var get_properties_1 = require("./get.properties");
|
|
15
|
+
Object.defineProperty(exports, "dealGetProperties", { enumerable: true, get: function () { return get_properties_1.dealGetProperties; } });
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dealUpdateProperties = void 0;
|
|
4
|
+
const _shared_fields_1 = require("./_shared.fields");
|
|
5
|
+
exports.dealUpdateProperties = [
|
|
6
|
+
{
|
|
7
|
+
displayName: 'Id',
|
|
8
|
+
name: 'Id',
|
|
9
|
+
type: 'string',
|
|
10
|
+
default: '',
|
|
11
|
+
displayOptions: { show: { resource: ['deal'], operation: ['update'] } },
|
|
12
|
+
description: 'Deal Id to update (required).',
|
|
13
|
+
},
|
|
14
|
+
(0, _shared_fields_1.titleField)('update'),
|
|
15
|
+
...(0, _shared_fields_1.ownerFields)('update'),
|
|
16
|
+
...(0, _shared_fields_1.pipelineFields)('update'),
|
|
17
|
+
...(0, _shared_fields_1.stageFields)('update'),
|
|
18
|
+
...(0, _shared_fields_1.personCompanyFields)('update'),
|
|
19
|
+
(0, _shared_fields_1.statusField)('update'),
|
|
20
|
+
(0, _shared_fields_1.additionalFields)('update'),
|
|
21
|
+
];
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.personCreate = personCreate;
|
|
4
|
+
const http_1 = require("../../lib/http");
|
|
5
|
+
async function personCreate(i, returnData) {
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
7
|
+
// Required LastName
|
|
8
|
+
const lastName = this.getNodeParameter('LastName', i, '');
|
|
9
|
+
if (!lastName)
|
|
10
|
+
throw new Error('LastName is required.');
|
|
11
|
+
// First layer fields
|
|
12
|
+
const firstName = this.getNodeParameter('FirstName', i, '');
|
|
13
|
+
const mobile = this.getNodeParameter('MobilePhone', i, '');
|
|
14
|
+
const workPhone = this.getNodeParameter('WorkPhone', i, '');
|
|
15
|
+
// Owner selection
|
|
16
|
+
const ownerMode = this.getNodeParameter('OwnerMode', i);
|
|
17
|
+
const ownerId = ownerMode === 'select'
|
|
18
|
+
? this.getNodeParameter('OwnerIdSelect', i, '')
|
|
19
|
+
: this.getNodeParameter('OwnerIdManual', i, '');
|
|
20
|
+
if (!ownerId)
|
|
21
|
+
throw new Error('OwnerId is required (select from list or enter manually).');
|
|
22
|
+
// Additional fields
|
|
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 (JSON or object)
|
|
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
|
+
// Helper to convert fixedCollection multipleValues => { KeyValues: [{Key,Value}, ...] }
|
|
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
|
+
// Websites / OtherPhones / OtherEmails / Addresses
|
|
63
|
+
const websites = toKeyValues(add.Websites);
|
|
64
|
+
const otherPhones = toKeyValues(add.OtherPhones);
|
|
65
|
+
const otherEmails = toKeyValues(add.OtherEmails);
|
|
66
|
+
const addresses = toKeyValues(add.Addresses);
|
|
67
|
+
// BankAccounts: { Values: [{Value1,Value2,Value3,Value4}, ...] }
|
|
68
|
+
let bankAccounts;
|
|
69
|
+
if (add.BankAccounts && typeof add.BankAccounts === 'object') {
|
|
70
|
+
const vals = add.BankAccounts.Values;
|
|
71
|
+
if (Array.isArray(vals) && vals.length) {
|
|
72
|
+
bankAccounts = { Values: vals.map(v => {
|
|
73
|
+
var _a, _b, _c, _d;
|
|
74
|
+
return ({
|
|
75
|
+
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 : '',
|
|
76
|
+
});
|
|
77
|
+
}) };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// SegmentIds: string[]
|
|
81
|
+
let segmentIds;
|
|
82
|
+
const seg = add.SegmentIds;
|
|
83
|
+
if (Array.isArray(seg))
|
|
84
|
+
segmentIds = seg.filter(Boolean);
|
|
85
|
+
else if (typeof seg === 'string' && seg)
|
|
86
|
+
segmentIds = [seg];
|
|
87
|
+
// بدنه Contact
|
|
88
|
+
const contact = {
|
|
89
|
+
Type: 'Person', // hidden field, always set
|
|
90
|
+
FirstName: firstName,
|
|
91
|
+
LastName: lastName,
|
|
92
|
+
Title: title,
|
|
93
|
+
OwnerId: ownerId,
|
|
94
|
+
CompanyName: companyName,
|
|
95
|
+
CompanyId: companyId,
|
|
96
|
+
BirthDate: birthDate || undefined,
|
|
97
|
+
BirthDateMessageId: birthDateMessageId,
|
|
98
|
+
MobilePhone: mobile,
|
|
99
|
+
WorkPhone: workPhone,
|
|
100
|
+
WorkPhoneExtension: workPhoneExt,
|
|
101
|
+
Fax: fax,
|
|
102
|
+
Email: email,
|
|
103
|
+
IsVIP: isVip,
|
|
104
|
+
BackgroundInfo: backgroundInfo,
|
|
105
|
+
Position: position,
|
|
106
|
+
CustomerCode: customerCode,
|
|
107
|
+
NationalCode: nationalCode,
|
|
108
|
+
ZipCode: zipCode,
|
|
109
|
+
VisibilityType: visibilityType,
|
|
110
|
+
};
|
|
111
|
+
if (fields)
|
|
112
|
+
contact['Fields'] = fields;
|
|
113
|
+
if (websites)
|
|
114
|
+
contact['Websites'] = websites;
|
|
115
|
+
if (otherPhones)
|
|
116
|
+
contact['OtherPhones'] = otherPhones;
|
|
117
|
+
if (otherEmails)
|
|
118
|
+
contact['OtherEmails'] = otherEmails;
|
|
119
|
+
if (addresses)
|
|
120
|
+
contact['Addresses'] = addresses;
|
|
121
|
+
if (bankAccounts)
|
|
122
|
+
contact['BankAccounts'] = bankAccounts;
|
|
123
|
+
const body = { Contact: contact };
|
|
124
|
+
if (segmentIds && segmentIds.length)
|
|
125
|
+
body['SegmentIds'] = segmentIds;
|
|
126
|
+
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
127
|
+
method: 'POST',
|
|
128
|
+
path: '/api/contact/save',
|
|
129
|
+
body,
|
|
130
|
+
});
|
|
131
|
+
returnData.push({ json: resp });
|
|
132
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.personCreateProperties = void 0;
|
|
4
|
+
const showForPersonCreate = { show: { resource: ['person'], operation: ['create'] } };
|
|
5
|
+
exports.personCreateProperties = [
|
|
6
|
+
// --- مین فیلدها (بالا به پایین) ---
|
|
7
|
+
{
|
|
8
|
+
displayName: 'First Name',
|
|
9
|
+
name: 'FirstName',
|
|
10
|
+
type: 'string',
|
|
11
|
+
default: '',
|
|
12
|
+
displayOptions: showForPersonCreate,
|
|
13
|
+
description: 'Optional given name of the person.',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
displayName: 'Last Name',
|
|
17
|
+
name: 'LastName',
|
|
18
|
+
type: 'string',
|
|
19
|
+
default: '',
|
|
20
|
+
required: true,
|
|
21
|
+
displayOptions: showForPersonCreate,
|
|
22
|
+
description: 'Required family name (last name) of the person.',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
displayName: 'Mobile Phone',
|
|
26
|
+
name: 'MobilePhone',
|
|
27
|
+
type: 'string',
|
|
28
|
+
default: '',
|
|
29
|
+
displayOptions: showForPersonCreate,
|
|
30
|
+
description: 'Primary mobile phone number.',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
displayName: 'Work Phone',
|
|
34
|
+
name: 'WorkPhone',
|
|
35
|
+
type: 'string',
|
|
36
|
+
default: '',
|
|
37
|
+
displayOptions: showForPersonCreate,
|
|
38
|
+
description: 'Work phone number.',
|
|
39
|
+
},
|
|
40
|
+
// --- Owner (Select/Manual) مثل Deal ---
|
|
41
|
+
{
|
|
42
|
+
displayName: 'Owner Input Mode',
|
|
43
|
+
name: 'OwnerMode',
|
|
44
|
+
type: 'options',
|
|
45
|
+
options: [
|
|
46
|
+
{ name: 'Select from list', value: 'select' },
|
|
47
|
+
{ name: 'Enter ID manually', value: 'manual' },
|
|
48
|
+
],
|
|
49
|
+
default: 'select',
|
|
50
|
+
displayOptions: showForPersonCreate,
|
|
51
|
+
description: 'Choose how to set the owner of this person.',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
displayName: 'Owner',
|
|
55
|
+
name: 'OwnerIdSelect',
|
|
56
|
+
type: 'options',
|
|
57
|
+
typeOptions: { loadOptionsMethod: 'getUsers' },
|
|
58
|
+
default: '',
|
|
59
|
+
displayOptions: { show: { ...showForPersonCreate.show, OwnerMode: ['select'] } },
|
|
60
|
+
description: 'Select the owner user (required if select mode).',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
displayName: 'Owner ID',
|
|
64
|
+
name: 'OwnerIdManual',
|
|
65
|
+
type: 'string',
|
|
66
|
+
default: '',
|
|
67
|
+
displayOptions: { show: { ...showForPersonCreate.show, OwnerMode: ['manual'] } },
|
|
68
|
+
description: 'Enter owner user ID manually (required if manual mode).',
|
|
69
|
+
},
|
|
70
|
+
// --- Additional Fields ---
|
|
71
|
+
{
|
|
72
|
+
displayName: 'Additional Fields',
|
|
73
|
+
name: 'additionalFields',
|
|
74
|
+
type: 'collection',
|
|
75
|
+
placeholder: 'Add field',
|
|
76
|
+
default: {},
|
|
77
|
+
displayOptions: showForPersonCreate,
|
|
78
|
+
options: [
|
|
79
|
+
{ displayName: 'Title', name: 'Title', type: 'string', default: '', description: 'Honorific or title (e.g., Mr., Ms., Dr.).' },
|
|
80
|
+
{ displayName: 'Company Name', name: 'CompanyName', type: 'string', default: '', description: 'Related company name (plain text).' },
|
|
81
|
+
{ displayName: 'Company ID', name: 'CompanyId', type: 'string', default: '00000000-0000-0000-0000-000000000000', description: 'Related company ID (GUID).' },
|
|
82
|
+
{ displayName: 'Birth Date (ISO)', name: 'BirthDate', type: 'string', default: '', description: 'Birth date in ISO format (e.g., 2025-08-31T08:02:06Z).' },
|
|
83
|
+
{ displayName: 'Birth Date Message ID', name: 'BirthDateMessageId', type: 'string', default: '00000000-0000-0000-0000-000000000000', description: 'Notification/message template ID for birthday (GUID).' },
|
|
84
|
+
{ displayName: 'Work Phone Extension', name: 'WorkPhoneExtension', type: 'string', default: '', description: 'Extension for the work phone.' },
|
|
85
|
+
{ displayName: 'Fax', name: 'Fax', type: 'string', default: '', description: 'Fax number.' },
|
|
86
|
+
{ displayName: 'Email', name: 'Email', type: 'string', default: '', description: 'Primary email address.' },
|
|
87
|
+
{ displayName: 'Is VIP', name: 'IsVIP', type: 'boolean', default: false, description: 'Mark this person as VIP.' },
|
|
88
|
+
{ displayName: 'Background Info', name: 'BackgroundInfo', type: 'string', default: '', description: 'Notes or background information.' },
|
|
89
|
+
{ displayName: 'Position', name: 'Position', type: 'string', default: '', description: 'Job title or position.' },
|
|
90
|
+
{ displayName: 'Customer Code', name: 'CustomerCode', type: 'string', default: '', description: 'Internal or CRM customer code.' },
|
|
91
|
+
{ displayName: 'National Code', name: 'NationalCode', type: 'string', default: '', description: 'National ID code.' },
|
|
92
|
+
{ displayName: 'Zip Code', name: 'ZipCode', type: 'string', default: '', description: 'Postal/ZIP code.' },
|
|
93
|
+
// VisibilityType مانند Deal
|
|
94
|
+
{
|
|
95
|
+
displayName: 'Visibility Type',
|
|
96
|
+
name: 'VisibilityType',
|
|
97
|
+
type: 'options',
|
|
98
|
+
options: [
|
|
99
|
+
{ name: 'Owner', value: 'Owner' },
|
|
100
|
+
{ name: 'Owner Group', value: 'OwnerGroup' },
|
|
101
|
+
{ name: 'Owner SubGroup', value: 'OwnerSubGroup' },
|
|
102
|
+
{ name: 'All', value: 'All' },
|
|
103
|
+
],
|
|
104
|
+
default: 'Owner',
|
|
105
|
+
description: 'Visibility setting for this person.',
|
|
106
|
+
},
|
|
107
|
+
// Fields (JSON) مثل Deal
|
|
108
|
+
{
|
|
109
|
+
displayName: 'Custom Fields (JSON)',
|
|
110
|
+
name: 'Fields',
|
|
111
|
+
type: 'json',
|
|
112
|
+
default: '',
|
|
113
|
+
placeholder: '{ "Field_996_0_7": "value" }',
|
|
114
|
+
description: 'JSON object of custom fields.',
|
|
115
|
+
},
|
|
116
|
+
// Websites (Key/Value list)
|
|
117
|
+
{
|
|
118
|
+
displayName: 'Websites',
|
|
119
|
+
name: 'Websites',
|
|
120
|
+
type: 'fixedCollection',
|
|
121
|
+
typeOptions: { multipleValues: true },
|
|
122
|
+
default: {},
|
|
123
|
+
options: [
|
|
124
|
+
{
|
|
125
|
+
name: 'KeyValues',
|
|
126
|
+
displayName: 'Website',
|
|
127
|
+
values: [
|
|
128
|
+
{ displayName: 'Key', name: 'Key', type: 'string', default: '' },
|
|
129
|
+
{ displayName: 'Value', name: 'Value', type: 'string', default: '' },
|
|
130
|
+
],
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
description: 'List of websites as key/value pairs.',
|
|
134
|
+
},
|
|
135
|
+
// OtherPhones (Key/Value list)
|
|
136
|
+
{
|
|
137
|
+
displayName: 'Other Phones',
|
|
138
|
+
name: 'OtherPhones',
|
|
139
|
+
type: 'fixedCollection',
|
|
140
|
+
typeOptions: { multipleValues: true },
|
|
141
|
+
default: {},
|
|
142
|
+
options: [
|
|
143
|
+
{
|
|
144
|
+
name: 'KeyValues',
|
|
145
|
+
displayName: 'Phone',
|
|
146
|
+
values: [
|
|
147
|
+
{ displayName: 'Key', name: 'Key', type: 'string', default: '' },
|
|
148
|
+
{ displayName: 'Value', name: 'Value', type: 'string', default: '' },
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
description: 'Additional phone numbers as key/value pairs.',
|
|
153
|
+
},
|
|
154
|
+
// OtherEmails (Key/Value list)
|
|
155
|
+
{
|
|
156
|
+
displayName: 'Other Emails',
|
|
157
|
+
name: 'OtherEmails',
|
|
158
|
+
type: 'fixedCollection',
|
|
159
|
+
typeOptions: { multipleValues: true },
|
|
160
|
+
default: {},
|
|
161
|
+
options: [
|
|
162
|
+
{
|
|
163
|
+
name: 'KeyValues',
|
|
164
|
+
displayName: 'Email',
|
|
165
|
+
values: [
|
|
166
|
+
{ displayName: 'Key', name: 'Key', type: 'string', default: '' },
|
|
167
|
+
{ displayName: 'Value', name: 'Value', type: 'string', default: '' },
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
description: 'Additional emails as key/value pairs.',
|
|
172
|
+
},
|
|
173
|
+
// Addresses (Key/Value list)
|
|
174
|
+
{
|
|
175
|
+
displayName: 'Addresses',
|
|
176
|
+
name: 'Addresses',
|
|
177
|
+
type: 'fixedCollection',
|
|
178
|
+
typeOptions: { multipleValues: true },
|
|
179
|
+
default: {},
|
|
180
|
+
options: [
|
|
181
|
+
{
|
|
182
|
+
name: 'KeyValues',
|
|
183
|
+
displayName: 'Address',
|
|
184
|
+
values: [
|
|
185
|
+
{ displayName: 'Key', name: 'Key', type: 'string', default: '' },
|
|
186
|
+
{ displayName: 'Value', name: 'Value', type: 'string', default: '' },
|
|
187
|
+
],
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
description: 'Addresses as key/value pairs (e.g., Home/Work/etc.).',
|
|
191
|
+
},
|
|
192
|
+
// BankAccounts (Values[4])
|
|
193
|
+
{
|
|
194
|
+
displayName: 'Bank Accounts',
|
|
195
|
+
name: 'BankAccounts',
|
|
196
|
+
type: 'fixedCollection',
|
|
197
|
+
typeOptions: { multipleValues: true },
|
|
198
|
+
default: {},
|
|
199
|
+
options: [
|
|
200
|
+
{
|
|
201
|
+
name: 'Values',
|
|
202
|
+
displayName: 'Bank Account',
|
|
203
|
+
values: [
|
|
204
|
+
{ displayName: 'Value1', name: 'Value1', type: 'string', default: '' },
|
|
205
|
+
{ displayName: 'Value2', name: 'Value2', type: 'string', default: '' },
|
|
206
|
+
{ displayName: 'Value3', name: 'Value3', type: 'string', default: '' },
|
|
207
|
+
{ displayName: 'Value4', name: 'Value4', type: 'string', default: '' },
|
|
208
|
+
],
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
description: 'Bank account details (four flexible fields per entry).',
|
|
212
|
+
},
|
|
213
|
+
// SegmentIds (string[])
|
|
214
|
+
{
|
|
215
|
+
displayName: 'Segment IDs',
|
|
216
|
+
name: 'SegmentIds',
|
|
217
|
+
type: 'string',
|
|
218
|
+
typeOptions: { multipleValues: true }, // returns string[]
|
|
219
|
+
default: [],
|
|
220
|
+
description: 'List of segment IDs (GUIDs).',
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
},
|
|
224
|
+
];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.personGet = personGet;
|
|
4
|
+
const http_1 = require("../../lib/http");
|
|
5
|
+
async function personGet(i, returnData) {
|
|
6
|
+
const personId = this.getNodeParameter('personId', i, '');
|
|
7
|
+
if (!personId)
|
|
8
|
+
throw new Error('Person Id is required.');
|
|
9
|
+
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
10
|
+
method: 'POST',
|
|
11
|
+
path: '/api/contact/GetContactDetail',
|
|
12
|
+
body: { Id: personId },
|
|
13
|
+
});
|
|
14
|
+
returnData.push({ json: resp });
|
|
15
|
+
}
|