n8n-nodes-didar-crm 0.0.12 → 0.0.13
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/dist/nodes/DidarCrm.node.js +50 -0
- package/dist/nodes/case/create.operation.d.ts +2 -0
- package/dist/nodes/case/create.operation.js +91 -0
- package/dist/nodes/case/create.properties.d.ts +2 -0
- package/dist/nodes/case/create.properties.js +165 -0
- package/dist/nodes/case/index.d.ts +2 -0
- package/dist/nodes/case/index.js +8 -0
- package/dist/nodes/company/create.properties.js +1 -1
- package/dist/nodes/note/create.operation.d.ts +2 -0
- package/dist/nodes/note/create.operation.js +56 -0
- package/dist/nodes/note/create.properties.d.ts +2 -0
- package/dist/nodes/note/create.properties.js +87 -0
- package/dist/nodes/note/index.d.ts +4 -0
- package/dist/nodes/note/index.js +12 -0
- package/dist/nodes/note/update.operation.d.ts +2 -0
- package/dist/nodes/note/update.operation.js +61 -0
- package/dist/nodes/note/update.properties.d.ts +2 -0
- package/dist/nodes/note/update.properties.js +97 -0
- package/package.json +1 -1
|
@@ -43,6 +43,10 @@ const CompanyOps = __importStar(require("./company"));
|
|
|
43
43
|
const company_1 = require("./company");
|
|
44
44
|
const ActivityOps = __importStar(require("./activity"));
|
|
45
45
|
const activity_1 = require("./activity");
|
|
46
|
+
const NoteOps = __importStar(require("./note"));
|
|
47
|
+
const note_1 = require("./note");
|
|
48
|
+
const CaseOps = __importStar(require("./case"));
|
|
49
|
+
const case_1 = require("./case");
|
|
46
50
|
class DidarCrm {
|
|
47
51
|
constructor() {
|
|
48
52
|
this.methods = {
|
|
@@ -75,6 +79,8 @@ class DidarCrm {
|
|
|
75
79
|
{ name: 'Person', value: 'person' },
|
|
76
80
|
{ name: 'Company', value: 'company' },
|
|
77
81
|
{ name: 'Activity', value: 'activity' },
|
|
82
|
+
{ name: 'Note', value: 'note' },
|
|
83
|
+
{ name: 'Case', value: 'case' },
|
|
78
84
|
],
|
|
79
85
|
default: 'deal',
|
|
80
86
|
description: 'Choose the entity to act on.',
|
|
@@ -130,6 +136,29 @@ class DidarCrm {
|
|
|
130
136
|
default: 'create',
|
|
131
137
|
description: 'Select the action to perform on the selected resource.',
|
|
132
138
|
},
|
|
139
|
+
{
|
|
140
|
+
displayName: 'Operation',
|
|
141
|
+
name: 'operation',
|
|
142
|
+
type: 'options',
|
|
143
|
+
displayOptions: { show: { resource: ['note'] } },
|
|
144
|
+
options: [
|
|
145
|
+
{ name: 'Create', value: 'create', action: 'Create a note' },
|
|
146
|
+
{ name: 'Update', value: 'update', action: 'Update a note by ID' },
|
|
147
|
+
],
|
|
148
|
+
default: 'create',
|
|
149
|
+
description: 'Select the action to perform on the selected resource.',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
displayName: 'Operation',
|
|
153
|
+
name: 'operation',
|
|
154
|
+
type: 'options',
|
|
155
|
+
displayOptions: { show: { resource: ['case'] } },
|
|
156
|
+
options: [
|
|
157
|
+
{ name: 'Create', value: 'create', action: 'Create a case' },
|
|
158
|
+
],
|
|
159
|
+
default: 'create',
|
|
160
|
+
description: 'Select the action to perform on the selected resource.',
|
|
161
|
+
},
|
|
133
162
|
// Deal properties (imported)
|
|
134
163
|
...deal_1.dealCreateProperties,
|
|
135
164
|
...deal_1.dealUpdateProperties,
|
|
@@ -145,6 +174,11 @@ class DidarCrm {
|
|
|
145
174
|
// Activity properties (imported)
|
|
146
175
|
...activity_1.activityCreateProperties,
|
|
147
176
|
...activity_1.activityUpdateProperties,
|
|
177
|
+
// Note properties (imported)
|
|
178
|
+
...note_1.noteCreateProperties,
|
|
179
|
+
...note_1.noteUpdateProperties,
|
|
180
|
+
// Case properties (imported)
|
|
181
|
+
...case_1.caseCreateProperties,
|
|
148
182
|
],
|
|
149
183
|
};
|
|
150
184
|
}
|
|
@@ -206,6 +240,22 @@ class DidarCrm {
|
|
|
206
240
|
continue;
|
|
207
241
|
} // NEW
|
|
208
242
|
}
|
|
243
|
+
if (resource === 'note') {
|
|
244
|
+
if (operation === 'create') {
|
|
245
|
+
await NoteOps.noteCreate.call(this, i, returnData);
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
if (operation === 'update') {
|
|
249
|
+
await NoteOps.noteUpdate.call(this, i, returnData);
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (resource === 'case') {
|
|
254
|
+
if (operation === 'create') {
|
|
255
|
+
await CaseOps.caseCreate.call(this, i, returnData);
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
209
259
|
}
|
|
210
260
|
return [returnData];
|
|
211
261
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.caseCreate = caseCreate;
|
|
4
|
+
const http_1 = require("../../lib/http");
|
|
5
|
+
const ZERO_GUID = '00000000-0000-0000-0000-000000000000';
|
|
6
|
+
async function caseCreate(i, returnData) {
|
|
7
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
8
|
+
// Main
|
|
9
|
+
const title = this.getNodeParameter('Title', i, '');
|
|
10
|
+
const ownerMode = this.getNodeParameter('OwnerMode', i);
|
|
11
|
+
const ownerIdSelect = this.getNodeParameter('OwnerIdSelect', i, '');
|
|
12
|
+
const ownerIdManual = this.getNodeParameter('OwnerIdManual', i, '');
|
|
13
|
+
const pipelineStageId = this.getNodeParameter('PipelineStageId', i, '');
|
|
14
|
+
const status = this.getNodeParameter('Status', i, 'InProgress');
|
|
15
|
+
if (!(title === null || title === void 0 ? void 0 : title.trim()))
|
|
16
|
+
throw new Error('Title is required.');
|
|
17
|
+
if (!(pipelineStageId === null || pipelineStageId === void 0 ? void 0 : pipelineStageId.trim()))
|
|
18
|
+
throw new Error('PipelineStageId is required.');
|
|
19
|
+
const ownerId = ownerMode === 'select' ? ownerIdSelect : ownerIdManual;
|
|
20
|
+
if (!(ownerId === null || ownerId === void 0 ? void 0 : ownerId.trim()) || ownerId === ZERO_GUID)
|
|
21
|
+
throw new Error('OwnerId is required.');
|
|
22
|
+
// Users / ResultNote (TOP-LEVEL)
|
|
23
|
+
const usersMode = this.getNodeParameter('UsersMode', i, 'select');
|
|
24
|
+
const userIdsSelect = this.getNodeParameter('UserIdsSelect', i, []);
|
|
25
|
+
const userIdsManual = this.getNodeParameter('UserIdsManual', i, []);
|
|
26
|
+
const toArray = (v) => Array.isArray(v) ? v : (typeof v === 'string' && v ? [v] : []);
|
|
27
|
+
const userIds = usersMode === 'select' ? toArray(userIdsSelect) : toArray(userIdsManual);
|
|
28
|
+
const resultNoteTop = status === 'Done' ? this.getNodeParameter('ResultNote', i, '') : '';
|
|
29
|
+
// Additional
|
|
30
|
+
const add = this.getNodeParameter('additionalFields', i, {}) || {};
|
|
31
|
+
const description = (_a = add.Description) !== null && _a !== void 0 ? _a : '';
|
|
32
|
+
const companyId = (_b = add.CompanyId) !== null && _b !== void 0 ? _b : ZERO_GUID;
|
|
33
|
+
const personId = (_c = add.PersonId) !== null && _c !== void 0 ? _c : ZERO_GUID;
|
|
34
|
+
const dealId = (_d = add.DealId) !== null && _d !== void 0 ? _d : ZERO_GUID;
|
|
35
|
+
const dueDateUi = (_e = add.DueDate) !== null && _e !== void 0 ? _e : '';
|
|
36
|
+
const caseCategoryId = (_f = add.CaseCategoryId) !== null && _f !== void 0 ? _f : '00000000-0000-0000-0000-000000000000';
|
|
37
|
+
const priority = (_g = add.Priority) !== null && _g !== void 0 ? _g : -2;
|
|
38
|
+
const visibilityType = (_h = add.VisibilityType) !== null && _h !== void 0 ? _h : 'Owner';
|
|
39
|
+
const otherContactsArr = (_j = add.OtherContactIds) !== null && _j !== void 0 ? _j : [];
|
|
40
|
+
const otherContactIds = Array.isArray(otherContactsArr) ? otherContactsArr.filter(Boolean).join(',') : '';
|
|
41
|
+
// Fields (JSON)
|
|
42
|
+
let fields;
|
|
43
|
+
if (typeof add.Fields === 'string' && add.Fields.trim()) {
|
|
44
|
+
try {
|
|
45
|
+
fields = JSON.parse(add.Fields);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
throw new Error('Invalid JSON in "Custom Fields (JSON)".');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else if (typeof add.Fields === 'object' && add.Fields) {
|
|
52
|
+
fields = add.Fields;
|
|
53
|
+
}
|
|
54
|
+
const labelIds = ((_k = add.LabelIds) !== null && _k !== void 0 ? _k : []).filter(Boolean);
|
|
55
|
+
// Dates
|
|
56
|
+
const nowIso = new Date().toISOString();
|
|
57
|
+
const dueDate = dueDateUi ? new Date(dueDateUi).toISOString() : nowIso;
|
|
58
|
+
// Payload
|
|
59
|
+
const caseObj = {
|
|
60
|
+
Title: title,
|
|
61
|
+
PipelineStageId: pipelineStageId,
|
|
62
|
+
OwnerId: ownerId,
|
|
63
|
+
Description: description,
|
|
64
|
+
CompanyId: companyId || ZERO_GUID,
|
|
65
|
+
PersonId: personId || ZERO_GUID,
|
|
66
|
+
DealId: dealId || ZERO_GUID,
|
|
67
|
+
Status: status,
|
|
68
|
+
DueDate: dueDate,
|
|
69
|
+
CaseCategoryId: caseCategoryId,
|
|
70
|
+
Priority: priority,
|
|
71
|
+
VisibilityType: visibilityType,
|
|
72
|
+
};
|
|
73
|
+
if (userIds.length)
|
|
74
|
+
caseObj['UserIds'] = userIds;
|
|
75
|
+
if (otherContactIds)
|
|
76
|
+
caseObj['OtherContactIds'] = otherContactIds;
|
|
77
|
+
if (status === 'Done' && (resultNoteTop === null || resultNoteTop === void 0 ? void 0 : resultNoteTop.trim()))
|
|
78
|
+
caseObj['ResultNote'] = resultNoteTop.trim();
|
|
79
|
+
if (fields)
|
|
80
|
+
caseObj['Fields'] = fields;
|
|
81
|
+
const body = { Case: caseObj };
|
|
82
|
+
if (labelIds.length)
|
|
83
|
+
body['SetLabelDto'] = { LabelIds: labelIds };
|
|
84
|
+
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
85
|
+
method: 'POST',
|
|
86
|
+
path: '/api/Case/Save',
|
|
87
|
+
body,
|
|
88
|
+
});
|
|
89
|
+
returnData.push({ json: ((_l = resp === null || resp === void 0 ? void 0 : resp.Response) !== null && _l !== void 0 ? _l : resp) });
|
|
90
|
+
return returnData;
|
|
91
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.caseCreateProperties = void 0;
|
|
4
|
+
const showForCaseCreate = { show: { resource: ['case'], operation: ['create'] } };
|
|
5
|
+
const ZERO_GUID = '00000000-0000-0000-0000-000000000000';
|
|
6
|
+
exports.caseCreateProperties = [
|
|
7
|
+
// ===== Main fields (order is important) =====
|
|
8
|
+
{
|
|
9
|
+
displayName: 'Title',
|
|
10
|
+
name: 'Title',
|
|
11
|
+
type: 'string',
|
|
12
|
+
default: '',
|
|
13
|
+
required: true,
|
|
14
|
+
displayOptions: showForCaseCreate,
|
|
15
|
+
description: 'Case title. Required.',
|
|
16
|
+
},
|
|
17
|
+
// Owner (MATCH Activity pattern: no "required" here; validation in operation)
|
|
18
|
+
{
|
|
19
|
+
displayName: 'Owner Input Mode',
|
|
20
|
+
name: 'OwnerMode',
|
|
21
|
+
type: 'options',
|
|
22
|
+
options: [
|
|
23
|
+
{ name: 'Select from list', value: 'select' },
|
|
24
|
+
{ name: 'Enter ID manually', value: 'manual' },
|
|
25
|
+
],
|
|
26
|
+
default: 'select',
|
|
27
|
+
displayOptions: showForCaseCreate,
|
|
28
|
+
description: 'Choose how to set the owner.',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
displayName: 'Owner',
|
|
32
|
+
name: 'OwnerIdSelect',
|
|
33
|
+
type: 'options',
|
|
34
|
+
typeOptions: { loadOptionsMethod: 'getUsers' },
|
|
35
|
+
default: '',
|
|
36
|
+
displayOptions: { show: { ...showForCaseCreate.show, OwnerMode: ['select'] } },
|
|
37
|
+
description: 'Select the owner user (required if select mode).',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
displayName: 'Owner ID',
|
|
41
|
+
name: 'OwnerIdManual',
|
|
42
|
+
type: 'string',
|
|
43
|
+
default: '',
|
|
44
|
+
displayOptions: { show: { ...showForCaseCreate.show, OwnerMode: ['manual'] } },
|
|
45
|
+
description: 'Enter owner user ID manually (required if manual mode).',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
displayName: 'Pipeline Stage ID',
|
|
49
|
+
name: 'PipelineStageId',
|
|
50
|
+
type: 'string',
|
|
51
|
+
default: '',
|
|
52
|
+
required: true,
|
|
53
|
+
displayOptions: showForCaseCreate,
|
|
54
|
+
description: 'Pipeline stage ID (enter manually). Required.',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
displayName: 'Status',
|
|
58
|
+
name: 'Status',
|
|
59
|
+
type: 'options',
|
|
60
|
+
options: [
|
|
61
|
+
{ name: 'In Progress', value: 'InProgress' },
|
|
62
|
+
{ name: 'Done', value: 'Done' },
|
|
63
|
+
],
|
|
64
|
+
default: 'InProgress',
|
|
65
|
+
required: true,
|
|
66
|
+
displayOptions: showForCaseCreate,
|
|
67
|
+
description: 'Case status.',
|
|
68
|
+
},
|
|
69
|
+
// ===== Top-level (moved out of collection to avoid dependency loops) =====
|
|
70
|
+
{
|
|
71
|
+
displayName: 'Users Input Mode',
|
|
72
|
+
name: 'UsersMode',
|
|
73
|
+
type: 'options',
|
|
74
|
+
options: [
|
|
75
|
+
{ name: 'Select from list (multi)', value: 'select' },
|
|
76
|
+
{ name: 'Enter IDs manually', value: 'manual' },
|
|
77
|
+
],
|
|
78
|
+
default: 'select',
|
|
79
|
+
displayOptions: showForCaseCreate,
|
|
80
|
+
description: 'How to provide user IDs.',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
displayName: 'Users',
|
|
84
|
+
name: 'UserIdsSelect',
|
|
85
|
+
type: 'options',
|
|
86
|
+
typeOptions: { loadOptionsMethod: 'getUsers', multipleValues: true },
|
|
87
|
+
default: [],
|
|
88
|
+
displayOptions: { show: { ...showForCaseCreate.show, UsersMode: ['select'] } },
|
|
89
|
+
description: 'Select one or more users.',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
displayName: 'User IDs (Manual)',
|
|
93
|
+
name: 'UserIdsManual',
|
|
94
|
+
type: 'string',
|
|
95
|
+
typeOptions: { multipleValues: true },
|
|
96
|
+
default: [],
|
|
97
|
+
displayOptions: { show: { ...showForCaseCreate.show, UsersMode: ['manual'] } },
|
|
98
|
+
description: 'Enter one or more user IDs (GUIDs).',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
displayName: 'Result Note',
|
|
102
|
+
name: 'ResultNote',
|
|
103
|
+
type: 'string',
|
|
104
|
+
default: '',
|
|
105
|
+
displayOptions: { show: { ...showForCaseCreate.show, Status: ['Done'] } }, // sibling condition - OK
|
|
106
|
+
description: 'Shown only when Status is Done.',
|
|
107
|
+
},
|
|
108
|
+
// ===== Additional Fields (NO child has displayOptions!) =====
|
|
109
|
+
{
|
|
110
|
+
displayName: 'Additional Fields',
|
|
111
|
+
name: 'additionalFields',
|
|
112
|
+
type: 'collection',
|
|
113
|
+
placeholder: 'Add field',
|
|
114
|
+
default: {},
|
|
115
|
+
displayOptions: showForCaseCreate,
|
|
116
|
+
options: [
|
|
117
|
+
{ displayName: 'Description', name: 'Description', type: 'string', default: '', description: 'Optional plain-text description.' },
|
|
118
|
+
{ displayName: 'Company ID', name: 'CompanyId', type: 'string', default: ZERO_GUID, description: 'Related company ID (GUID).' },
|
|
119
|
+
{ displayName: 'Person ID', name: 'PersonId', type: 'string', default: ZERO_GUID, description: 'Related person ID (GUID).' },
|
|
120
|
+
{ displayName: 'Deal ID', name: 'DealId', type: 'string', default: ZERO_GUID, description: 'Related deal ID (GUID).' },
|
|
121
|
+
{ displayName: 'Due Date', name: 'DueDate', type: 'dateTime', default: '', description: 'Due date. Defaults to now if empty.' },
|
|
122
|
+
{
|
|
123
|
+
displayName: 'Case Category',
|
|
124
|
+
name: 'CaseCategoryId',
|
|
125
|
+
type: 'options',
|
|
126
|
+
options: [
|
|
127
|
+
{ name: 'Activity Oriented', value: '00000000-0000-0000-0000-000000000000' },
|
|
128
|
+
{ name: 'Kanban', value: 'cd06853c-35df-4d9b-b124-9556474d84a1' },
|
|
129
|
+
{ name: 'Ticket', value: '37375848-a403-4186-8460-d45754f49e4c' },
|
|
130
|
+
],
|
|
131
|
+
default: '00000000-0000-0000-0000-000000000000',
|
|
132
|
+
description: 'Category of the case.',
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
displayName: 'Priority',
|
|
136
|
+
name: 'Priority',
|
|
137
|
+
type: 'options',
|
|
138
|
+
options: [
|
|
139
|
+
{ name: 'None (-2)', value: -2 },
|
|
140
|
+
{ name: 'Low (-1)', value: -1 },
|
|
141
|
+
{ name: 'Medium (0)', value: 0 },
|
|
142
|
+
{ name: 'High (1)', value: 1 },
|
|
143
|
+
],
|
|
144
|
+
default: -2,
|
|
145
|
+
description: 'Priority level.',
|
|
146
|
+
},
|
|
147
|
+
// string[] (we keep as string[] and join in operation)
|
|
148
|
+
{ displayName: 'Other Contact IDs', name: 'OtherContactIds', type: 'string', typeOptions: { multipleValues: true }, default: [], description: 'Additional related contact IDs (GUIDs).' },
|
|
149
|
+
// JSON
|
|
150
|
+
{ displayName: 'Custom Fields (JSON)', name: 'Fields', type: 'json', default: '', placeholder: '{ "Field_XXXX_0_YY": "value" }', description: 'JSON object of custom fields.' },
|
|
151
|
+
// string[]
|
|
152
|
+
{ displayName: 'Label IDs', name: 'LabelIds', type: 'string', typeOptions: { multipleValues: true }, default: [], description: 'Label IDs to be set on the case.' },
|
|
153
|
+
{ displayName: 'Visibility Type', name: 'VisibilityType', type: 'options',
|
|
154
|
+
options: [
|
|
155
|
+
{ name: 'Owner', value: 'Owner' },
|
|
156
|
+
{ name: 'Owner Group', value: 'OwnerGroup' },
|
|
157
|
+
{ name: 'Owner SubGroup', value: 'OwnerSubGroup' },
|
|
158
|
+
{ name: 'All', value: 'All' },
|
|
159
|
+
],
|
|
160
|
+
default: 'Owner',
|
|
161
|
+
description: 'Visibility setting for this case.',
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
},
|
|
165
|
+
];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.caseCreateProperties = exports.caseCreate = void 0;
|
|
4
|
+
// nodes/case/index.ts
|
|
5
|
+
var create_operation_1 = require("./create.operation");
|
|
6
|
+
Object.defineProperty(exports, "caseCreate", { enumerable: true, get: function () { return create_operation_1.caseCreate; } });
|
|
7
|
+
var create_properties_1 = require("./create.properties");
|
|
8
|
+
Object.defineProperty(exports, "caseCreateProperties", { enumerable: true, get: function () { return create_properties_1.caseCreateProperties; } });
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.noteCreate = noteCreate;
|
|
4
|
+
const http_1 = require("../../lib/http");
|
|
5
|
+
const ZERO_GUID = '00000000-0000-0000-0000-000000000000';
|
|
6
|
+
async function noteCreate(i, returnData) {
|
|
7
|
+
var _a;
|
|
8
|
+
// 1) ورودیها
|
|
9
|
+
const resultNote = this.getNodeParameter('ResultNote', i);
|
|
10
|
+
const ownerMode = this.getNodeParameter('OwnerMode', i);
|
|
11
|
+
const ownerIdSel = this.getNodeParameter('OwnerIdSelect', i, '');
|
|
12
|
+
const ownerIdMan = this.getNodeParameter('OwnerIdManual', i, '');
|
|
13
|
+
const doneDateUi = this.getNodeParameter('DoneDate', i, '');
|
|
14
|
+
const dealId = this.getNodeParameter('DealId', i, ZERO_GUID);
|
|
15
|
+
const caseId = this.getNodeParameter('CaseId', i, ZERO_GUID);
|
|
16
|
+
const contactIds = this.getNodeParameter('ContactIds', i, []);
|
|
17
|
+
// 2) اعتبارسنجیهای ضروری
|
|
18
|
+
if (!(resultNote === null || resultNote === void 0 ? void 0 : resultNote.trim())) {
|
|
19
|
+
throw new Error('ResultNote is required for Note creation.');
|
|
20
|
+
}
|
|
21
|
+
const ownerId = (ownerMode === 'select') ? ownerIdSel : ownerIdMan;
|
|
22
|
+
if (!ownerId || ownerId === ZERO_GUID) {
|
|
23
|
+
throw new Error('OwnerId is required (via select or manual).');
|
|
24
|
+
}
|
|
25
|
+
// 3) زمانها و پیشفرضها
|
|
26
|
+
const nowIso = new Date().toISOString();
|
|
27
|
+
const doneDate = doneDateUi ? new Date(doneDateUi).toISOString() : nowIso;
|
|
28
|
+
const dueDate = doneDate; // طبق نیاز: DueDate = DoneDate
|
|
29
|
+
// 4) ساخت payload مطابق الزامات شما
|
|
30
|
+
const body = {
|
|
31
|
+
Activity: {
|
|
32
|
+
ActivityTypeId: ZERO_GUID, // ثابت و نامنمایش
|
|
33
|
+
OwnerId: ownerId, // اجباری
|
|
34
|
+
ResultNote: resultNote, // اجباری
|
|
35
|
+
IsDone: true, // ثابت و نامنمایش
|
|
36
|
+
IsDeleted: false, // ثابت و نامنمایش
|
|
37
|
+
DueDate: dueDate, // نامنمایش (همان DoneDate)
|
|
38
|
+
DoneDate: doneDate, // UI یا now
|
|
39
|
+
DueDateType: 'NoTime', // ثابت و نامنمایش
|
|
40
|
+
DoneDateType: 'Notime', // ثابت و نامنمایش
|
|
41
|
+
DealId: dealId || ZERO_GUID,
|
|
42
|
+
ContactIds: Array.isArray(contactIds) ? contactIds : [],
|
|
43
|
+
CaseId: caseId || ZERO_GUID,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
// 5) ارسال درخواست
|
|
47
|
+
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
48
|
+
method: 'POST',
|
|
49
|
+
path: '/api/activity/save',
|
|
50
|
+
body,
|
|
51
|
+
});
|
|
52
|
+
// 6) خروجی نهایی n8n
|
|
53
|
+
const json = ((_a = resp === null || resp === void 0 ? void 0 : resp.Response) !== null && _a !== void 0 ? _a : resp);
|
|
54
|
+
returnData.push({ json });
|
|
55
|
+
return returnData;
|
|
56
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.noteCreateProperties = void 0;
|
|
4
|
+
const showForNoteCreate = { show: { resource: ['note'], operation: ['create'] } };
|
|
5
|
+
exports.noteCreateProperties = [
|
|
6
|
+
// --- ResultNote (required) ---
|
|
7
|
+
{
|
|
8
|
+
displayName: 'Result Note',
|
|
9
|
+
name: 'ResultNote',
|
|
10
|
+
type: 'string',
|
|
11
|
+
typeOptions: { rows: 3 },
|
|
12
|
+
default: '',
|
|
13
|
+
required: true,
|
|
14
|
+
displayOptions: showForNoteCreate,
|
|
15
|
+
description: 'The text content of the note. Required.',
|
|
16
|
+
},
|
|
17
|
+
// --- Owner (Select/Manual) ---
|
|
18
|
+
{
|
|
19
|
+
displayName: 'Owner Input Mode',
|
|
20
|
+
name: 'OwnerMode',
|
|
21
|
+
type: 'options',
|
|
22
|
+
options: [
|
|
23
|
+
{ name: 'Select from list', value: 'select' },
|
|
24
|
+
{ name: 'Enter ID manually', value: 'manual' },
|
|
25
|
+
],
|
|
26
|
+
default: 'select',
|
|
27
|
+
required: true,
|
|
28
|
+
displayOptions: showForNoteCreate,
|
|
29
|
+
description: 'Choose how to set the owner of this note.',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
displayName: 'Owner',
|
|
33
|
+
name: 'OwnerIdSelect',
|
|
34
|
+
type: 'options',
|
|
35
|
+
typeOptions: { loadOptionsMethod: 'getUsers' },
|
|
36
|
+
default: '',
|
|
37
|
+
required: true,
|
|
38
|
+
displayOptions: { show: { ...showForNoteCreate.show, OwnerMode: ['select'] } },
|
|
39
|
+
description: 'Select the owner user (required if Select mode).',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
displayName: 'Owner ID',
|
|
43
|
+
name: 'OwnerIdManual',
|
|
44
|
+
type: 'string',
|
|
45
|
+
default: '',
|
|
46
|
+
required: true,
|
|
47
|
+
displayOptions: { show: { ...showForNoteCreate.show, OwnerMode: ['manual'] } },
|
|
48
|
+
description: 'Enter the owner user ID manually (required if Manual mode).',
|
|
49
|
+
},
|
|
50
|
+
// --- DoneDate (defaults to now) ---
|
|
51
|
+
{
|
|
52
|
+
displayName: 'Done Date',
|
|
53
|
+
name: 'DoneDate',
|
|
54
|
+
type: 'dateTime',
|
|
55
|
+
default: '',
|
|
56
|
+
displayOptions: showForNoteCreate,
|
|
57
|
+
description: 'Completion date. Defaults to current date/time if not provided.',
|
|
58
|
+
},
|
|
59
|
+
// --- DealId (optional, default zero GUID) ---
|
|
60
|
+
{
|
|
61
|
+
displayName: 'Deal ID',
|
|
62
|
+
name: 'DealId',
|
|
63
|
+
type: 'string',
|
|
64
|
+
default: '00000000-0000-0000-0000-000000000000',
|
|
65
|
+
displayOptions: showForNoteCreate,
|
|
66
|
+
description: 'Optional related deal ID (GUID).',
|
|
67
|
+
},
|
|
68
|
+
// --- CaseId (optional, default zero GUID) ---
|
|
69
|
+
{
|
|
70
|
+
displayName: 'Case ID',
|
|
71
|
+
name: 'CaseId',
|
|
72
|
+
type: 'string',
|
|
73
|
+
default: '00000000-0000-0000-0000-000000000000',
|
|
74
|
+
displayOptions: showForNoteCreate,
|
|
75
|
+
description: 'Optional related case ID (GUID).',
|
|
76
|
+
},
|
|
77
|
+
// --- ContactIds (string[]) ---
|
|
78
|
+
{
|
|
79
|
+
displayName: 'Contact IDs',
|
|
80
|
+
name: 'ContactIds',
|
|
81
|
+
type: 'string',
|
|
82
|
+
typeOptions: { multipleValues: true }, // n8n returns string[]
|
|
83
|
+
default: [],
|
|
84
|
+
displayOptions: showForNoteCreate,
|
|
85
|
+
description: 'List of related contact IDs (GUIDs). Optional.',
|
|
86
|
+
},
|
|
87
|
+
];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.noteUpdateProperties = exports.noteUpdate = exports.noteCreateProperties = exports.noteCreate = void 0;
|
|
4
|
+
// nodes/note/index.ts
|
|
5
|
+
var create_operation_1 = require("./create.operation");
|
|
6
|
+
Object.defineProperty(exports, "noteCreate", { enumerable: true, get: function () { return create_operation_1.noteCreate; } });
|
|
7
|
+
var create_properties_1 = require("./create.properties");
|
|
8
|
+
Object.defineProperty(exports, "noteCreateProperties", { enumerable: true, get: function () { return create_properties_1.noteCreateProperties; } });
|
|
9
|
+
var update_operation_1 = require("./update.operation");
|
|
10
|
+
Object.defineProperty(exports, "noteUpdate", { enumerable: true, get: function () { return update_operation_1.noteUpdate; } });
|
|
11
|
+
var update_properties_1 = require("./update.properties");
|
|
12
|
+
Object.defineProperty(exports, "noteUpdateProperties", { enumerable: true, get: function () { return update_properties_1.noteUpdateProperties; } });
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.noteUpdate = noteUpdate;
|
|
4
|
+
const http_1 = require("../../lib/http");
|
|
5
|
+
const ZERO_GUID = '00000000-0000-0000-0000-000000000000';
|
|
6
|
+
async function noteUpdate(i, returnData) {
|
|
7
|
+
var _a;
|
|
8
|
+
// 1) Parameters
|
|
9
|
+
const id = this.getNodeParameter('Id', i);
|
|
10
|
+
const resultNote = this.getNodeParameter('ResultNote', i);
|
|
11
|
+
const ownerMode = this.getNodeParameter('OwnerMode', i);
|
|
12
|
+
const ownerIdSel = this.getNodeParameter('OwnerIdSelect', i, '');
|
|
13
|
+
const ownerIdMan = this.getNodeParameter('OwnerIdManual', i, '');
|
|
14
|
+
const doneDateUi = this.getNodeParameter('DoneDate', i, '');
|
|
15
|
+
const dealId = this.getNodeParameter('DealId', i, ZERO_GUID);
|
|
16
|
+
const caseId = this.getNodeParameter('CaseId', i, ZERO_GUID);
|
|
17
|
+
const contactIds = this.getNodeParameter('ContactIds', i, []);
|
|
18
|
+
// 2) Required validations
|
|
19
|
+
if (!(id === null || id === void 0 ? void 0 : id.trim())) {
|
|
20
|
+
throw new Error('Note ID is required for Note update.');
|
|
21
|
+
}
|
|
22
|
+
if (!(resultNote === null || resultNote === void 0 ? void 0 : resultNote.trim())) {
|
|
23
|
+
throw new Error('ResultNote is required for Note update.');
|
|
24
|
+
}
|
|
25
|
+
const ownerId = (ownerMode === 'select') ? ownerIdSel : ownerIdMan;
|
|
26
|
+
if (!ownerId || ownerId === ZERO_GUID) {
|
|
27
|
+
throw new Error('OwnerId is required (via select or manual).');
|
|
28
|
+
}
|
|
29
|
+
// 3) Dates
|
|
30
|
+
const nowIso = new Date().toISOString();
|
|
31
|
+
const doneDate = doneDateUi ? new Date(doneDateUi).toISOString() : nowIso;
|
|
32
|
+
const dueDate = doneDate; // same as create
|
|
33
|
+
// 4) Payload
|
|
34
|
+
const body = {
|
|
35
|
+
Activity: {
|
|
36
|
+
Id: id, // required for update
|
|
37
|
+
ActivityTypeId: ZERO_GUID, // constant
|
|
38
|
+
OwnerId: ownerId,
|
|
39
|
+
ResultNote: resultNote,
|
|
40
|
+
IsDone: true,
|
|
41
|
+
IsDeleted: false,
|
|
42
|
+
DueDate: dueDate,
|
|
43
|
+
DoneDate: doneDate,
|
|
44
|
+
DueDateType: 'NoTime',
|
|
45
|
+
DoneDateType: 'Notime',
|
|
46
|
+
DealId: dealId || ZERO_GUID,
|
|
47
|
+
ContactIds: Array.isArray(contactIds) ? contactIds : [],
|
|
48
|
+
CaseId: caseId || ZERO_GUID,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
// 5) Request
|
|
52
|
+
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
53
|
+
method: 'POST',
|
|
54
|
+
path: '/api/activity/save',
|
|
55
|
+
body, // IMPORTANT: body already has { Activity: {...} }
|
|
56
|
+
});
|
|
57
|
+
// 6) Return
|
|
58
|
+
const json = ((_a = resp === null || resp === void 0 ? void 0 : resp.Response) !== null && _a !== void 0 ? _a : resp);
|
|
59
|
+
returnData.push({ json });
|
|
60
|
+
return returnData;
|
|
61
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.noteUpdateProperties = void 0;
|
|
4
|
+
const showForNoteUpdate = { show: { resource: ['note'], operation: ['update'] } };
|
|
5
|
+
exports.noteUpdateProperties = [
|
|
6
|
+
// --- Id (required, first) ---
|
|
7
|
+
{
|
|
8
|
+
displayName: 'Note ID',
|
|
9
|
+
name: 'Id',
|
|
10
|
+
type: 'string',
|
|
11
|
+
default: '',
|
|
12
|
+
required: true,
|
|
13
|
+
displayOptions: showForNoteUpdate,
|
|
14
|
+
description: 'The ID of the note to update.',
|
|
15
|
+
},
|
|
16
|
+
// --- ResultNote (required) ---
|
|
17
|
+
{
|
|
18
|
+
displayName: 'Result Note',
|
|
19
|
+
name: 'ResultNote',
|
|
20
|
+
type: 'string',
|
|
21
|
+
typeOptions: { rows: 3 },
|
|
22
|
+
default: '',
|
|
23
|
+
required: true,
|
|
24
|
+
displayOptions: showForNoteUpdate,
|
|
25
|
+
description: 'The text content of the note. Required.',
|
|
26
|
+
},
|
|
27
|
+
// --- Owner (Select/Manual) ---
|
|
28
|
+
{
|
|
29
|
+
displayName: 'Owner Input Mode',
|
|
30
|
+
name: 'OwnerMode',
|
|
31
|
+
type: 'options',
|
|
32
|
+
options: [
|
|
33
|
+
{ name: 'Select from list', value: 'select' },
|
|
34
|
+
{ name: 'Enter ID manually', value: 'manual' },
|
|
35
|
+
],
|
|
36
|
+
default: 'select',
|
|
37
|
+
required: true,
|
|
38
|
+
displayOptions: showForNoteUpdate,
|
|
39
|
+
description: 'Choose how to set the owner of this note.',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
displayName: 'Owner',
|
|
43
|
+
name: 'OwnerIdSelect',
|
|
44
|
+
type: 'options',
|
|
45
|
+
typeOptions: { loadOptionsMethod: 'getUsers' },
|
|
46
|
+
default: '',
|
|
47
|
+
required: true,
|
|
48
|
+
displayOptions: { show: { ...showForNoteUpdate.show, OwnerMode: ['select'] } },
|
|
49
|
+
description: 'Select the owner user (required if Select mode).',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
displayName: 'Owner ID',
|
|
53
|
+
name: 'OwnerIdManual',
|
|
54
|
+
type: 'string',
|
|
55
|
+
default: '',
|
|
56
|
+
required: true,
|
|
57
|
+
displayOptions: { show: { ...showForNoteUpdate.show, OwnerMode: ['manual'] } },
|
|
58
|
+
description: 'Enter the owner user ID manually (required if Manual mode).',
|
|
59
|
+
},
|
|
60
|
+
// --- DoneDate (defaults to now if empty) ---
|
|
61
|
+
{
|
|
62
|
+
displayName: 'Done Date',
|
|
63
|
+
name: 'DoneDate',
|
|
64
|
+
type: 'dateTime',
|
|
65
|
+
default: '',
|
|
66
|
+
displayOptions: showForNoteUpdate,
|
|
67
|
+
description: 'Completion date. Defaults to current date/time if not provided.',
|
|
68
|
+
},
|
|
69
|
+
// --- DealId (optional) ---
|
|
70
|
+
{
|
|
71
|
+
displayName: 'Deal ID',
|
|
72
|
+
name: 'DealId',
|
|
73
|
+
type: 'string',
|
|
74
|
+
default: '00000000-0000-0000-0000-000000000000',
|
|
75
|
+
displayOptions: showForNoteUpdate,
|
|
76
|
+
description: 'Optional related deal ID (GUID).',
|
|
77
|
+
},
|
|
78
|
+
// --- CaseId (optional) ---
|
|
79
|
+
{
|
|
80
|
+
displayName: 'Case ID',
|
|
81
|
+
name: 'CaseId',
|
|
82
|
+
type: 'string',
|
|
83
|
+
default: '00000000-0000-0000-0000-000000000000',
|
|
84
|
+
displayOptions: showForNoteUpdate,
|
|
85
|
+
description: 'Optional related case ID (GUID).',
|
|
86
|
+
},
|
|
87
|
+
// --- ContactIds (string[]) ---
|
|
88
|
+
{
|
|
89
|
+
displayName: 'Contact IDs',
|
|
90
|
+
name: 'ContactIds',
|
|
91
|
+
type: 'string',
|
|
92
|
+
typeOptions: { multipleValues: true }, // n8n returns string[]
|
|
93
|
+
default: [],
|
|
94
|
+
displayOptions: showForNoteUpdate,
|
|
95
|
+
description: 'List of related contact IDs (GUIDs). Optional.',
|
|
96
|
+
},
|
|
97
|
+
];
|