n8n-nodes-didar-crm 0.0.13 → 0.0.14
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 +6 -0
- package/dist/nodes/case/create.properties.js +4 -4
- package/dist/nodes/case/index.d.ts +2 -0
- package/dist/nodes/case/index.js +5 -1
- package/dist/nodes/case/update.operation.d.ts +2 -0
- package/dist/nodes/case/update.operation.js +95 -0
- package/dist/nodes/case/update.properties.d.ts +2 -0
- package/dist/nodes/case/update.properties.js +172 -0
- package/package.json +1 -1
|
@@ -155,6 +155,7 @@ class DidarCrm {
|
|
|
155
155
|
displayOptions: { show: { resource: ['case'] } },
|
|
156
156
|
options: [
|
|
157
157
|
{ name: 'Create', value: 'create', action: 'Create a case' },
|
|
158
|
+
{ name: 'Update', value: 'update', action: 'Update a case by ID' },
|
|
158
159
|
],
|
|
159
160
|
default: 'create',
|
|
160
161
|
description: 'Select the action to perform on the selected resource.',
|
|
@@ -179,6 +180,7 @@ class DidarCrm {
|
|
|
179
180
|
...note_1.noteUpdateProperties,
|
|
180
181
|
// Case properties (imported)
|
|
181
182
|
...case_1.caseCreateProperties,
|
|
183
|
+
...case_1.caseUpdateProperties,
|
|
182
184
|
],
|
|
183
185
|
};
|
|
184
186
|
}
|
|
@@ -255,6 +257,10 @@ class DidarCrm {
|
|
|
255
257
|
await CaseOps.caseCreate.call(this, i, returnData);
|
|
256
258
|
continue;
|
|
257
259
|
}
|
|
260
|
+
if (operation === 'update') {
|
|
261
|
+
await CaseOps.caseUpdate.call(this, i, returnData);
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
258
264
|
}
|
|
259
265
|
}
|
|
260
266
|
return [returnData];
|
|
@@ -136,10 +136,10 @@ exports.caseCreateProperties = [
|
|
|
136
136
|
name: 'Priority',
|
|
137
137
|
type: 'options',
|
|
138
138
|
options: [
|
|
139
|
-
{ name: 'None
|
|
140
|
-
{ name: 'Low
|
|
141
|
-
{ name: 'Medium
|
|
142
|
-
{ name: 'High
|
|
139
|
+
{ name: 'None', value: -2 },
|
|
140
|
+
{ name: 'Low', value: -1 },
|
|
141
|
+
{ name: 'Medium', value: 0 },
|
|
142
|
+
{ name: 'High', value: 1 },
|
|
143
143
|
],
|
|
144
144
|
default: -2,
|
|
145
145
|
description: 'Priority level.',
|
package/dist/nodes/case/index.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.caseCreateProperties = exports.caseCreate = void 0;
|
|
3
|
+
exports.caseUpdateProperties = exports.caseUpdate = exports.caseCreateProperties = exports.caseCreate = void 0;
|
|
4
4
|
// nodes/case/index.ts
|
|
5
5
|
var create_operation_1 = require("./create.operation");
|
|
6
6
|
Object.defineProperty(exports, "caseCreate", { enumerable: true, get: function () { return create_operation_1.caseCreate; } });
|
|
7
7
|
var create_properties_1 = require("./create.properties");
|
|
8
8
|
Object.defineProperty(exports, "caseCreateProperties", { enumerable: true, get: function () { return create_properties_1.caseCreateProperties; } });
|
|
9
|
+
var update_operation_1 = require("./update.operation");
|
|
10
|
+
Object.defineProperty(exports, "caseUpdate", { enumerable: true, get: function () { return update_operation_1.caseUpdate; } });
|
|
11
|
+
var update_properties_1 = require("./update.properties");
|
|
12
|
+
Object.defineProperty(exports, "caseUpdateProperties", { enumerable: true, get: function () { return update_properties_1.caseUpdateProperties; } });
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.caseUpdate = caseUpdate;
|
|
4
|
+
const http_1 = require("../../lib/http");
|
|
5
|
+
const ZERO_GUID = '00000000-0000-0000-0000-000000000000';
|
|
6
|
+
async function caseUpdate(i, returnData) {
|
|
7
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
8
|
+
// Main
|
|
9
|
+
const id = this.getNodeParameter('Id', i, '');
|
|
10
|
+
const title = this.getNodeParameter('Title', i, '');
|
|
11
|
+
const ownerMode = this.getNodeParameter('OwnerMode', i);
|
|
12
|
+
const ownerIdSelect = this.getNodeParameter('OwnerIdSelect', i, '');
|
|
13
|
+
const ownerIdManual = this.getNodeParameter('OwnerIdManual', i, '');
|
|
14
|
+
const pipelineStageId = this.getNodeParameter('PipelineStageId', i, '');
|
|
15
|
+
const status = this.getNodeParameter('Status', i, 'InProgress');
|
|
16
|
+
if (!(id === null || id === void 0 ? void 0 : id.trim()))
|
|
17
|
+
throw new Error('Case ID is required.');
|
|
18
|
+
if (!(title === null || title === void 0 ? void 0 : title.trim()))
|
|
19
|
+
throw new Error('Title is required.');
|
|
20
|
+
if (!(pipelineStageId === null || pipelineStageId === void 0 ? void 0 : pipelineStageId.trim()))
|
|
21
|
+
throw new Error('PipelineStageId is required.');
|
|
22
|
+
const ownerId = ownerMode === 'select' ? ownerIdSelect : ownerIdManual;
|
|
23
|
+
if (!(ownerId === null || ownerId === void 0 ? void 0 : ownerId.trim()) || ownerId === ZERO_GUID)
|
|
24
|
+
throw new Error('OwnerId is required.');
|
|
25
|
+
// Users / ResultNote (TOP-LEVEL)
|
|
26
|
+
const usersMode = this.getNodeParameter('UsersMode', i, 'select');
|
|
27
|
+
const userIdsSelect = this.getNodeParameter('UserIdsSelect', i, []);
|
|
28
|
+
const userIdsManual = this.getNodeParameter('UserIdsManual', i, []);
|
|
29
|
+
const toArray = (v) => Array.isArray(v) ? v : (typeof v === 'string' && v ? [v] : []);
|
|
30
|
+
const userIds = usersMode === 'select' ? toArray(userIdsSelect) : toArray(userIdsManual);
|
|
31
|
+
const resultNoteTop = status === 'Done' ? this.getNodeParameter('ResultNote', i, '') : '';
|
|
32
|
+
// Additional
|
|
33
|
+
const add = this.getNodeParameter('additionalFields', i, {}) || {};
|
|
34
|
+
const description = (_a = add.Description) !== null && _a !== void 0 ? _a : '';
|
|
35
|
+
const companyId = (_b = add.CompanyId) !== null && _b !== void 0 ? _b : ZERO_GUID;
|
|
36
|
+
const personId = (_c = add.PersonId) !== null && _c !== void 0 ? _c : ZERO_GUID;
|
|
37
|
+
const dealId = (_d = add.DealId) !== null && _d !== void 0 ? _d : ZERO_GUID;
|
|
38
|
+
const dueDateUi = (_e = add.DueDate) !== null && _e !== void 0 ? _e : '';
|
|
39
|
+
const caseCategoryId = (_f = add.CaseCategoryId) !== null && _f !== void 0 ? _f : '00000000-0000-0000-0000-000000000000';
|
|
40
|
+
const priority = (_g = add.Priority) !== null && _g !== void 0 ? _g : -2;
|
|
41
|
+
const visibilityType = (_h = add.VisibilityType) !== null && _h !== void 0 ? _h : 'Owner';
|
|
42
|
+
const otherContactsArr = (_j = add.OtherContactIds) !== null && _j !== void 0 ? _j : [];
|
|
43
|
+
const otherContactIds = Array.isArray(otherContactsArr) ? otherContactsArr.filter(Boolean).join(',') : '';
|
|
44
|
+
// Fields (JSON)
|
|
45
|
+
let fields;
|
|
46
|
+
if (typeof add.Fields === 'string' && add.Fields.trim()) {
|
|
47
|
+
try {
|
|
48
|
+
fields = JSON.parse(add.Fields);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
throw new Error('Invalid JSON in "Custom Fields (JSON)".');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else if (typeof add.Fields === 'object' && add.Fields) {
|
|
55
|
+
fields = add.Fields;
|
|
56
|
+
}
|
|
57
|
+
const labelIds = ((_k = add.LabelIds) !== null && _k !== void 0 ? _k : []).filter(Boolean);
|
|
58
|
+
// Dates
|
|
59
|
+
const nowIso = new Date().toISOString();
|
|
60
|
+
const dueDate = dueDateUi ? new Date(dueDateUi).toISOString() : nowIso;
|
|
61
|
+
// Payload
|
|
62
|
+
const caseObj = {
|
|
63
|
+
Id: id,
|
|
64
|
+
Title: title,
|
|
65
|
+
PipelineStageId: pipelineStageId,
|
|
66
|
+
OwnerId: ownerId,
|
|
67
|
+
Description: description,
|
|
68
|
+
CompanyId: companyId || ZERO_GUID,
|
|
69
|
+
PersonId: personId || ZERO_GUID,
|
|
70
|
+
DealId: dealId || ZERO_GUID,
|
|
71
|
+
Status: status,
|
|
72
|
+
DueDate: dueDate,
|
|
73
|
+
CaseCategoryId: caseCategoryId,
|
|
74
|
+
Priority: priority,
|
|
75
|
+
VisibilityType: visibilityType,
|
|
76
|
+
};
|
|
77
|
+
if (userIds.length)
|
|
78
|
+
caseObj['UserIds'] = userIds;
|
|
79
|
+
if (otherContactIds)
|
|
80
|
+
caseObj['OtherContactIds'] = otherContactIds;
|
|
81
|
+
if (status === 'Done' && (resultNoteTop === null || resultNoteTop === void 0 ? void 0 : resultNoteTop.trim()))
|
|
82
|
+
caseObj['ResultNote'] = resultNoteTop.trim();
|
|
83
|
+
if (fields)
|
|
84
|
+
caseObj['Fields'] = fields;
|
|
85
|
+
const body = { Case: caseObj };
|
|
86
|
+
if (labelIds.length)
|
|
87
|
+
body['SetLabelDto'] = { LabelIds: labelIds };
|
|
88
|
+
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
89
|
+
method: 'POST',
|
|
90
|
+
path: '/api/Case/Save',
|
|
91
|
+
body,
|
|
92
|
+
});
|
|
93
|
+
returnData.push({ json: ((_l = resp === null || resp === void 0 ? void 0 : resp.Response) !== null && _l !== void 0 ? _l : resp) });
|
|
94
|
+
return returnData;
|
|
95
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.caseUpdateProperties = void 0;
|
|
4
|
+
const showForCaseUpdate = { show: { resource: ['case'], operation: ['update'] } };
|
|
5
|
+
const ZERO_GUID = '00000000-0000-0000-0000-000000000000';
|
|
6
|
+
exports.caseUpdateProperties = [
|
|
7
|
+
// ===== Main fields (order is important) =====
|
|
8
|
+
// Id first (required)
|
|
9
|
+
{
|
|
10
|
+
displayName: 'Case ID',
|
|
11
|
+
name: 'Id',
|
|
12
|
+
type: 'string',
|
|
13
|
+
default: '',
|
|
14
|
+
required: true,
|
|
15
|
+
displayOptions: showForCaseUpdate,
|
|
16
|
+
description: 'The ID of the case to update.',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
displayName: 'Title',
|
|
20
|
+
name: 'Title',
|
|
21
|
+
type: 'string',
|
|
22
|
+
default: '',
|
|
23
|
+
required: true,
|
|
24
|
+
displayOptions: showForCaseUpdate,
|
|
25
|
+
description: 'Case title. Required.',
|
|
26
|
+
},
|
|
27
|
+
// Owner (MATCH Activity pattern: no "required" in UI)
|
|
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
|
+
displayOptions: showForCaseUpdate,
|
|
38
|
+
description: 'Choose how to set the owner.',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
displayName: 'Owner',
|
|
42
|
+
name: 'OwnerIdSelect',
|
|
43
|
+
type: 'options',
|
|
44
|
+
typeOptions: { loadOptionsMethod: 'getUsers' },
|
|
45
|
+
default: '',
|
|
46
|
+
displayOptions: { show: { ...showForCaseUpdate.show, OwnerMode: ['select'] } },
|
|
47
|
+
description: 'Select the owner user (required if select mode).',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
displayName: 'Owner ID',
|
|
51
|
+
name: 'OwnerIdManual',
|
|
52
|
+
type: 'string',
|
|
53
|
+
default: '',
|
|
54
|
+
displayOptions: { show: { ...showForCaseUpdate.show, OwnerMode: ['manual'] } },
|
|
55
|
+
description: 'Enter owner user ID manually (required if manual mode).',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
displayName: 'Pipeline Stage ID',
|
|
59
|
+
name: 'PipelineStageId',
|
|
60
|
+
type: 'string',
|
|
61
|
+
default: '',
|
|
62
|
+
required: true,
|
|
63
|
+
displayOptions: showForCaseUpdate,
|
|
64
|
+
description: 'Pipeline stage ID (enter manually). Required.',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
displayName: 'Status',
|
|
68
|
+
name: 'Status',
|
|
69
|
+
type: 'options',
|
|
70
|
+
options: [
|
|
71
|
+
{ name: 'In Progress', value: 'InProgress' },
|
|
72
|
+
{ name: 'Done', value: 'Done' },
|
|
73
|
+
],
|
|
74
|
+
default: 'InProgress',
|
|
75
|
+
required: true,
|
|
76
|
+
displayOptions: showForCaseUpdate,
|
|
77
|
+
description: 'Case status.',
|
|
78
|
+
},
|
|
79
|
+
// ===== Top-level (avoid dependency loops) =====
|
|
80
|
+
{
|
|
81
|
+
displayName: 'Users Input Mode',
|
|
82
|
+
name: 'UsersMode',
|
|
83
|
+
type: 'options',
|
|
84
|
+
options: [
|
|
85
|
+
{ name: 'Select from list (multi)', value: 'select' },
|
|
86
|
+
{ name: 'Enter IDs manually', value: 'manual' },
|
|
87
|
+
],
|
|
88
|
+
default: 'select',
|
|
89
|
+
displayOptions: showForCaseUpdate,
|
|
90
|
+
description: 'How to provide user IDs.',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
displayName: 'Users',
|
|
94
|
+
name: 'UserIdsSelect',
|
|
95
|
+
type: 'options',
|
|
96
|
+
typeOptions: { loadOptionsMethod: 'getUsers', multipleValues: true },
|
|
97
|
+
default: [],
|
|
98
|
+
displayOptions: { show: { ...showForCaseUpdate.show, UsersMode: ['select'] } },
|
|
99
|
+
description: 'Select one or more users.',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
displayName: 'User IDs (Manual)',
|
|
103
|
+
name: 'UserIdsManual',
|
|
104
|
+
type: 'string',
|
|
105
|
+
typeOptions: { multipleValues: true },
|
|
106
|
+
default: [],
|
|
107
|
+
displayOptions: { show: { ...showForCaseUpdate.show, UsersMode: ['manual'] } },
|
|
108
|
+
description: 'Enter one or more user IDs (GUIDs).',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
displayName: 'Result Note',
|
|
112
|
+
name: 'ResultNote',
|
|
113
|
+
type: 'string',
|
|
114
|
+
default: '',
|
|
115
|
+
displayOptions: { show: { ...showForCaseUpdate.show, Status: ['Done'] } },
|
|
116
|
+
description: 'Shown only when Status is Done.',
|
|
117
|
+
},
|
|
118
|
+
// ===== Additional Fields (no child has displayOptions) =====
|
|
119
|
+
{
|
|
120
|
+
displayName: 'Additional Fields',
|
|
121
|
+
name: 'additionalFields',
|
|
122
|
+
type: 'collection',
|
|
123
|
+
placeholder: 'Add field',
|
|
124
|
+
default: {},
|
|
125
|
+
displayOptions: showForCaseUpdate,
|
|
126
|
+
options: [
|
|
127
|
+
{ displayName: 'Description', name: 'Description', type: 'string', default: '', description: 'Optional plain-text description.' },
|
|
128
|
+
{ displayName: 'Company ID', name: 'CompanyId', type: 'string', default: ZERO_GUID, description: 'Related company ID (GUID).' },
|
|
129
|
+
{ displayName: 'Person ID', name: 'PersonId', type: 'string', default: ZERO_GUID, description: 'Related person ID (GUID).' },
|
|
130
|
+
{ displayName: 'Deal ID', name: 'DealId', type: 'string', default: ZERO_GUID, description: 'Related deal ID (GUID).' },
|
|
131
|
+
{ displayName: 'Due Date', name: 'DueDate', type: 'dateTime', default: '', description: 'Due date. Defaults to now if empty.' },
|
|
132
|
+
{
|
|
133
|
+
displayName: 'Case Category',
|
|
134
|
+
name: 'CaseCategoryId',
|
|
135
|
+
type: 'options',
|
|
136
|
+
options: [
|
|
137
|
+
{ name: 'Activity Oriented', value: '00000000-0000-0000-0000-000000000000' },
|
|
138
|
+
{ name: 'Kanban', value: 'cd06853c-35df-4d9b-b124-9556474d84a1' },
|
|
139
|
+
{ name: 'Ticket', value: '37375848-a403-4186-8460-d45754f49e4c' },
|
|
140
|
+
],
|
|
141
|
+
default: '00000000-0000-0000-0000-000000000000',
|
|
142
|
+
description: 'Category of the case.',
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
displayName: 'Priority',
|
|
146
|
+
name: 'Priority',
|
|
147
|
+
type: 'options',
|
|
148
|
+
options: [
|
|
149
|
+
{ name: 'None', value: -2 },
|
|
150
|
+
{ name: 'Low', value: -1 },
|
|
151
|
+
{ name: 'Medium', value: 0 },
|
|
152
|
+
{ name: 'High', value: 1 },
|
|
153
|
+
],
|
|
154
|
+
default: -2,
|
|
155
|
+
description: 'Priority level.',
|
|
156
|
+
},
|
|
157
|
+
{ displayName: 'Other Contact IDs', name: 'OtherContactIds', type: 'string', typeOptions: { multipleValues: true }, default: [], description: 'Additional related contact IDs (GUIDs).' },
|
|
158
|
+
{ displayName: 'Custom Fields (JSON)', name: 'Fields', type: 'json', default: '', placeholder: '{ "Field_XXXX_0_YY": "value" }', description: 'JSON object of custom fields.' },
|
|
159
|
+
{ displayName: 'Label IDs', name: 'LabelIds', type: 'string', typeOptions: { multipleValues: true }, default: [], description: 'Label IDs to be set on the case.' },
|
|
160
|
+
{ displayName: 'Visibility Type', name: 'VisibilityType', type: 'options',
|
|
161
|
+
options: [
|
|
162
|
+
{ name: 'Owner', value: 'Owner' },
|
|
163
|
+
{ name: 'Owner Group', value: 'OwnerGroup' },
|
|
164
|
+
{ name: 'Owner SubGroup', value: 'OwnerSubGroup' },
|
|
165
|
+
{ name: 'All', value: 'All' },
|
|
166
|
+
],
|
|
167
|
+
default: 'Owner',
|
|
168
|
+
description: 'Visibility setting for this case.',
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
},
|
|
172
|
+
];
|