n8n-nodes-didar-crm 0.0.17 → 0.0.19
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/lib/loadOptions.d.ts +4 -1
- package/dist/lib/loadOptions.js +10 -1
- package/dist/nodes/DidarCrm.node.js +18 -0
- package/dist/nodes/activity/create.operation.js +94 -6
- package/dist/nodes/activity/update.operation.js +93 -6
- package/dist/nodes/case/create.operation.js +98 -2
- package/dist/nodes/case/create.properties.js +3 -2
- package/dist/nodes/case/update.operation.js +98 -2
- package/dist/nodes/case/update.properties.js +3 -2
- package/dist/nodes/company/index.d.ts +2 -0
- package/dist/nodes/company/index.js +5 -1
- package/dist/nodes/company/search.operation.d.ts +2 -0
- package/dist/nodes/company/search.operation.js +87 -0
- package/dist/nodes/company/search.properties.d.ts +2 -0
- package/dist/nodes/company/search.properties.js +136 -0
- package/dist/nodes/deal/index.d.ts +2 -0
- package/dist/nodes/deal/index.js +5 -1
- package/dist/nodes/deal/search.operation.d.ts +2 -0
- package/dist/nodes/deal/search.operation.js +200 -0
- package/dist/nodes/deal/search.properties.d.ts +2 -0
- package/dist/nodes/deal/search.properties.js +222 -0
- package/dist/nodes/note/create.operation.js +90 -2
- package/dist/nodes/note/update.operation.js +90 -2
- package/dist/nodes/person/index.d.ts +2 -0
- package/dist/nodes/person/index.js +5 -1
- package/dist/nodes/person/search.operation.d.ts +2 -0
- package/dist/nodes/person/search.operation.js +86 -0
- package/dist/nodes/person/search.properties.d.ts +2 -0
- package/dist/nodes/person/search.properties.js +136 -0
- package/package.json +1 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
|
|
2
2
|
export declare function getPipelines(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
3
|
-
export declare function getStagesForPipeline(this: ILoadOptionsFunctions): Promise<
|
|
3
|
+
export declare function getStagesForPipeline(this: ILoadOptionsFunctions): Promise<{
|
|
4
|
+
name: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}[]>;
|
|
4
7
|
export declare function getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
5
8
|
export declare function getActivityTypes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
6
9
|
export declare function getProductCategories(this: ILoadOptionsFunctions): Promise<any>;
|
package/dist/lib/loadOptions.js
CHANGED
|
@@ -29,7 +29,15 @@ async function getPipelines() {
|
|
|
29
29
|
}
|
|
30
30
|
async function getStagesForPipeline() {
|
|
31
31
|
var _a, _b;
|
|
32
|
-
|
|
32
|
+
// اول سعی کن از نام استاندارد search/ایجاد جدید بخوانی:
|
|
33
|
+
let pipelineId = this.getCurrentNodeParameter('pipelineId') || '';
|
|
34
|
+
// فالبک برای نودهای قدیمی/جداگانه که شاید اسم دیگری داشته باشند:
|
|
35
|
+
if (!pipelineId) {
|
|
36
|
+
try {
|
|
37
|
+
pipelineId = this.getCurrentNodeParameter('PipelineIdSelect') || '';
|
|
38
|
+
}
|
|
39
|
+
catch { }
|
|
40
|
+
}
|
|
33
41
|
if (!pipelineId)
|
|
34
42
|
return [];
|
|
35
43
|
const creds = await this.getCredentials('didarApi');
|
|
@@ -44,6 +52,7 @@ async function getStagesForPipeline() {
|
|
|
44
52
|
url,
|
|
45
53
|
json: true,
|
|
46
54
|
headers: { 'Content-Type': 'application/json' },
|
|
55
|
+
body: {}, // بعضی سرورها POST بدون body را دوست ندارند
|
|
47
56
|
};
|
|
48
57
|
if (useCookie && cookie)
|
|
49
58
|
options.headers.Cookie = cookie;
|
|
@@ -98,6 +98,7 @@ class DidarCrm {
|
|
|
98
98
|
{ name: 'Create', value: 'create', action: 'Create a deal' },
|
|
99
99
|
{ name: 'Update', value: 'update', action: 'Update a deal by Id' },
|
|
100
100
|
{ name: 'Get', value: 'get', action: 'Get a deal by Id' },
|
|
101
|
+
{ name: 'Search', value: 'search', action: 'Search deals' },
|
|
101
102
|
],
|
|
102
103
|
default: 'create',
|
|
103
104
|
description: 'Select the action to perform on the selected resource.',
|
|
@@ -111,6 +112,7 @@ class DidarCrm {
|
|
|
111
112
|
{ name: 'Create', value: 'create', action: 'Create a person' },
|
|
112
113
|
{ name: 'Update', value: 'update', action: 'Update a person by Id' },
|
|
113
114
|
{ name: 'Get', value: 'get', action: 'Get a person by Id' },
|
|
115
|
+
{ name: 'Search', value: 'search', action: 'Search persons' }
|
|
114
116
|
],
|
|
115
117
|
default: 'create',
|
|
116
118
|
description: 'Select the action to perform on the selected resource.',
|
|
@@ -124,6 +126,7 @@ class DidarCrm {
|
|
|
124
126
|
{ name: 'Create', value: 'create', action: 'Create a company' },
|
|
125
127
|
{ name: 'Update', value: 'update', action: 'Update a company by Id' },
|
|
126
128
|
{ name: 'Get', value: 'get', action: 'Get a company by Id' },
|
|
129
|
+
{ name: 'Search', value: 'search', action: 'Search companies' }
|
|
127
130
|
],
|
|
128
131
|
default: 'create',
|
|
129
132
|
description: 'Select the action to perform on the selected resource.',
|
|
@@ -181,14 +184,17 @@ class DidarCrm {
|
|
|
181
184
|
...deal_1.dealCreateProperties,
|
|
182
185
|
...deal_1.dealUpdateProperties,
|
|
183
186
|
...deal_1.dealGetProperties,
|
|
187
|
+
...deal_1.dealSearchProperties,
|
|
184
188
|
// Person properties (imported)
|
|
185
189
|
...person_1.personCreateProperties,
|
|
186
190
|
...person_1.personUpdateProperties,
|
|
187
191
|
...person_1.personGetProperties,
|
|
192
|
+
...person_1.personSearchProperties,
|
|
188
193
|
// Company properties (imported)
|
|
189
194
|
...company_1.companyCreateProperties,
|
|
190
195
|
...company_1.companyUpdateProperties,
|
|
191
196
|
...company_1.companyGetProperties,
|
|
197
|
+
...company_1.companySearchProperties,
|
|
192
198
|
// Activity properties (imported)
|
|
193
199
|
...activity_1.activityCreateProperties,
|
|
194
200
|
...activity_1.activityUpdateProperties,
|
|
@@ -224,6 +230,10 @@ class DidarCrm {
|
|
|
224
230
|
await DealOps.dealGet.call(this, i, returnData);
|
|
225
231
|
continue;
|
|
226
232
|
}
|
|
233
|
+
if (operation === 'search') {
|
|
234
|
+
await DealOps.dealSearch.call(this, i, returnData);
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
227
237
|
}
|
|
228
238
|
if (resource === 'person') {
|
|
229
239
|
if (operation === 'create') {
|
|
@@ -238,6 +248,10 @@ class DidarCrm {
|
|
|
238
248
|
await PersonOps.personGet.call(this, i, returnData);
|
|
239
249
|
continue;
|
|
240
250
|
}
|
|
251
|
+
if (operation === 'search') {
|
|
252
|
+
await PersonOps.personSearch.call(this, i, returnData);
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
241
255
|
}
|
|
242
256
|
if (resource === 'company') {
|
|
243
257
|
if (operation === 'create') {
|
|
@@ -252,6 +266,10 @@ class DidarCrm {
|
|
|
252
266
|
await CompanyOps.companyGet.call(this, i, returnData);
|
|
253
267
|
continue;
|
|
254
268
|
}
|
|
269
|
+
if (operation === 'search') {
|
|
270
|
+
await CompanyOps.companySearch.call(this, i, returnData);
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
255
273
|
}
|
|
256
274
|
if (resource === 'activity') {
|
|
257
275
|
if (operation === 'create') {
|
|
@@ -35,12 +35,100 @@ async function activityCreate(i, returnData) {
|
|
|
35
35
|
const dealId = (_h = add.DealId) !== null && _h !== void 0 ? _h : '00000000-0000-0000-0000-000000000000';
|
|
36
36
|
const caseId = (_j = add.CaseId) !== null && _j !== void 0 ? _j : '00000000-0000-0000-0000-000000000000';
|
|
37
37
|
// ContactIds: string[]
|
|
38
|
-
let contactIds;
|
|
39
|
-
const cids = add.ContactIds;
|
|
40
|
-
if (Array.isArray(cids))
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
// let contactIds: string[] | undefined;
|
|
39
|
+
// const cids = add.ContactIds as string[] | string | undefined;
|
|
40
|
+
// if (Array.isArray(cids)) contactIds = cids.filter(Boolean);
|
|
41
|
+
// else if (typeof cids === 'string' && cids) contactIds = [cids];
|
|
42
|
+
// ---- Robust ContactIds parsing: string | string[] | JSON array | CSV/newlines | [Array: [...]] ----
|
|
43
|
+
const rawContactIds = add.ContactIds;
|
|
44
|
+
const parseIdList = (input) => {
|
|
45
|
+
const out = [];
|
|
46
|
+
const pushFromString = (raw) => {
|
|
47
|
+
if (!raw)
|
|
48
|
+
return;
|
|
49
|
+
const s = raw.trim();
|
|
50
|
+
if (!s)
|
|
51
|
+
return;
|
|
52
|
+
// Handle n8n visualization: [Array: [...]]
|
|
53
|
+
const arrayLabel = s.match(/^\s*\[Array:\s*(\[[\s\S]*\])\s*\]\s*$/i);
|
|
54
|
+
if (arrayLabel) {
|
|
55
|
+
try {
|
|
56
|
+
const arr = JSON.parse(arrayLabel[1]);
|
|
57
|
+
recur(arr);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
catch { /* fall through */ }
|
|
61
|
+
}
|
|
62
|
+
// JSON array
|
|
63
|
+
if (/^\s*\[/.test(s)) {
|
|
64
|
+
try {
|
|
65
|
+
const arr = JSON.parse(s);
|
|
66
|
+
recur(arr);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
throw new Error('Invalid JSON in "Contact IDs". Expected a JSON array of strings.');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Otherwise CSV/newlines/semicolon
|
|
74
|
+
s.split(/[\n,;]+/)
|
|
75
|
+
.map((t) => t.trim())
|
|
76
|
+
.filter(Boolean)
|
|
77
|
+
.forEach((t) => out.push(t));
|
|
78
|
+
};
|
|
79
|
+
const recur = (val) => {
|
|
80
|
+
var _a, _b;
|
|
81
|
+
if (val == null)
|
|
82
|
+
return;
|
|
83
|
+
if (Array.isArray(val)) {
|
|
84
|
+
val.forEach(recur);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
switch (typeof val) {
|
|
88
|
+
case 'string':
|
|
89
|
+
pushFromString(val);
|
|
90
|
+
return;
|
|
91
|
+
case 'number':
|
|
92
|
+
case 'boolean':
|
|
93
|
+
out.push(String(val));
|
|
94
|
+
return;
|
|
95
|
+
case 'object': {
|
|
96
|
+
const obj = val;
|
|
97
|
+
// Map/Set support
|
|
98
|
+
if (val instanceof Set) {
|
|
99
|
+
recur(Array.from(val));
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (val instanceof Map) {
|
|
103
|
+
recur(Array.from(val.values()));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
// Common wrappers
|
|
107
|
+
if (obj === null || obj === void 0 ? void 0 : obj.values) {
|
|
108
|
+
recur(obj.values);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (obj === null || obj === void 0 ? void 0 : obj.Value) {
|
|
112
|
+
recur(obj.Value);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
// Fallback: try toString
|
|
116
|
+
const s = ((_b = (_a = obj === null || obj === void 0 ? void 0 : obj.toString) === null || _a === void 0 ? void 0 : _a.call(obj)) !== null && _b !== void 0 ? _b : '').toString();
|
|
117
|
+
if (s)
|
|
118
|
+
pushFromString(s);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
default:
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
recur(input);
|
|
126
|
+
// Normalize and dedupe
|
|
127
|
+
return Array.from(new Set(out.map((x) => x.trim()).filter(Boolean)));
|
|
128
|
+
};
|
|
129
|
+
const contactIdsParsed = parseIdList(rawContactIds);
|
|
130
|
+
const contactIds = contactIdsParsed;
|
|
131
|
+
// Creator
|
|
44
132
|
const creatorId = (_k = add.CreatorId) !== null && _k !== void 0 ? _k : '00000000-0000-0000-0000-000000000000';
|
|
45
133
|
const recurrenceType = (_l = add.RecurrenceType) !== null && _l !== void 0 ? _l : '';
|
|
46
134
|
const recurrenceDataNum = Number((_m = add.RecurrenceData) !== null && _m !== void 0 ? _m : 0);
|
|
@@ -37,12 +37,99 @@ async function activityUpdate(i, returnData) {
|
|
|
37
37
|
const dealId = (_h = add.DealId) !== null && _h !== void 0 ? _h : '00000000-0000-0000-0000-000000000000';
|
|
38
38
|
const caseId = (_j = add.CaseId) !== null && _j !== void 0 ? _j : '00000000-0000-0000-0000-000000000000';
|
|
39
39
|
// ContactIds: string[]
|
|
40
|
-
let contactIds;
|
|
41
|
-
const cids = add.ContactIds;
|
|
42
|
-
if (Array.isArray(cids))
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
// let contactIds: string[] | undefined;
|
|
41
|
+
// const cids = add.ContactIds as string[] | string | undefined;
|
|
42
|
+
// if (Array.isArray(cids)) contactIds = cids.filter(Boolean);
|
|
43
|
+
// else if (typeof cids === 'string' && cids) contactIds = [cids];
|
|
44
|
+
// ---- Robust ContactIds parsing: string | string[] | JSON array | CSV/newlines | [Array: [...]] ----
|
|
45
|
+
const rawContactIds = add.ContactIds;
|
|
46
|
+
const parseIdList = (input) => {
|
|
47
|
+
const out = [];
|
|
48
|
+
const pushFromString = (raw) => {
|
|
49
|
+
if (!raw)
|
|
50
|
+
return;
|
|
51
|
+
const s = raw.trim();
|
|
52
|
+
if (!s)
|
|
53
|
+
return;
|
|
54
|
+
// Handle n8n visualization: [Array: [...]]
|
|
55
|
+
const arrayLabel = s.match(/^\s*\[Array:\s*(\[[\s\S]*\])\s*\]\s*$/i);
|
|
56
|
+
if (arrayLabel) {
|
|
57
|
+
try {
|
|
58
|
+
const arr = JSON.parse(arrayLabel[1]);
|
|
59
|
+
recur(arr);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
catch { /* fall through */ }
|
|
63
|
+
}
|
|
64
|
+
// JSON array
|
|
65
|
+
if (/^\s*\[/.test(s)) {
|
|
66
|
+
try {
|
|
67
|
+
const arr = JSON.parse(s);
|
|
68
|
+
recur(arr);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
throw new Error('Invalid JSON in "Contact IDs". Expected a JSON array of strings.');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Otherwise CSV/newlines/semicolon
|
|
76
|
+
s.split(/[\n,;]+/)
|
|
77
|
+
.map((t) => t.trim())
|
|
78
|
+
.filter(Boolean)
|
|
79
|
+
.forEach((t) => out.push(t));
|
|
80
|
+
};
|
|
81
|
+
const recur = (val) => {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
if (val == null)
|
|
84
|
+
return;
|
|
85
|
+
if (Array.isArray(val)) {
|
|
86
|
+
val.forEach(recur);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
switch (typeof val) {
|
|
90
|
+
case 'string':
|
|
91
|
+
pushFromString(val);
|
|
92
|
+
return;
|
|
93
|
+
case 'number':
|
|
94
|
+
case 'boolean':
|
|
95
|
+
out.push(String(val));
|
|
96
|
+
return;
|
|
97
|
+
case 'object': {
|
|
98
|
+
const obj = val;
|
|
99
|
+
// Map/Set support
|
|
100
|
+
if (val instanceof Set) {
|
|
101
|
+
recur(Array.from(val));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (val instanceof Map) {
|
|
105
|
+
recur(Array.from(val.values()));
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
// Common wrappers
|
|
109
|
+
if (obj === null || obj === void 0 ? void 0 : obj.values) {
|
|
110
|
+
recur(obj.values);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (obj === null || obj === void 0 ? void 0 : obj.Value) {
|
|
114
|
+
recur(obj.Value);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
// Fallback: try toString
|
|
118
|
+
const s = ((_b = (_a = obj === null || obj === void 0 ? void 0 : obj.toString) === null || _a === void 0 ? void 0 : _a.call(obj)) !== null && _b !== void 0 ? _b : '').toString();
|
|
119
|
+
if (s)
|
|
120
|
+
pushFromString(s);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
default:
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
recur(input);
|
|
128
|
+
// Normalize and dedupe
|
|
129
|
+
return Array.from(new Set(out.map((x) => x.trim()).filter(Boolean)));
|
|
130
|
+
};
|
|
131
|
+
const contactIdsParsed = parseIdList(rawContactIds);
|
|
132
|
+
const contactIds = contactIdsParsed;
|
|
46
133
|
const creatorId = (_k = add.CreatorId) !== null && _k !== void 0 ? _k : '00000000-0000-0000-0000-000000000000';
|
|
47
134
|
const recurrenceType = (_l = add.RecurrenceType) !== null && _l !== void 0 ? _l : '';
|
|
48
135
|
const recurrenceDataNum = Number((_m = add.RecurrenceData) !== null && _m !== void 0 ? _m : 0);
|
|
@@ -23,8 +23,104 @@ async function caseCreate(i, returnData) {
|
|
|
23
23
|
const usersMode = this.getNodeParameter('UsersMode', i, 'select');
|
|
24
24
|
const userIdsSelect = this.getNodeParameter('UserIdsSelect', i, []);
|
|
25
25
|
const userIdsManual = this.getNodeParameter('UserIdsManual', i, []);
|
|
26
|
-
const toArray = (v) => Array.isArray(v)
|
|
27
|
-
|
|
26
|
+
const toArray = (v) => Array.isArray(v)
|
|
27
|
+
? v.map((x) => (x !== null && x !== void 0 ? x : '').toString().trim()).filter(Boolean)
|
|
28
|
+
: (typeof v === 'string' && v ? [v.trim()] : []);
|
|
29
|
+
// --- Robust parser for Manual input ---
|
|
30
|
+
const parseManualIds = (input) => {
|
|
31
|
+
const out = [];
|
|
32
|
+
const pushFromString = (raw) => {
|
|
33
|
+
if (!raw)
|
|
34
|
+
return;
|
|
35
|
+
const s = raw.trim();
|
|
36
|
+
if (!s)
|
|
37
|
+
return;
|
|
38
|
+
// Handle "[Array: [...]]" visualization
|
|
39
|
+
const arrayLabel = s.match(/^\s*\[Array:\s*(\[[\s\S]*\])\s*\]\s*$/i);
|
|
40
|
+
if (arrayLabel) {
|
|
41
|
+
try {
|
|
42
|
+
const arr = JSON.parse(arrayLabel[1]);
|
|
43
|
+
recur(arr);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
catch { /* fall through */ }
|
|
47
|
+
}
|
|
48
|
+
// Try JSON array
|
|
49
|
+
if (/^\s*\[/.test(s)) {
|
|
50
|
+
try {
|
|
51
|
+
const arr = JSON.parse(s);
|
|
52
|
+
recur(arr);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
throw new Error('Invalid JSON in "User IDs (Manual)". Expected a JSON array of strings.');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Otherwise treat as CSV/newline/semicolon separated
|
|
60
|
+
s.split(/[\n,;]+/)
|
|
61
|
+
.map((t) => t.trim())
|
|
62
|
+
.filter(Boolean)
|
|
63
|
+
.forEach((t) => out.push(t));
|
|
64
|
+
};
|
|
65
|
+
const recur = (val) => {
|
|
66
|
+
var _a, _b;
|
|
67
|
+
if (val == null)
|
|
68
|
+
return;
|
|
69
|
+
if (Array.isArray(val)) {
|
|
70
|
+
val.forEach(recur);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
switch (typeof val) {
|
|
74
|
+
case 'string':
|
|
75
|
+
pushFromString(val);
|
|
76
|
+
return;
|
|
77
|
+
case 'number':
|
|
78
|
+
case 'boolean':
|
|
79
|
+
out.push(String(val));
|
|
80
|
+
return;
|
|
81
|
+
case 'object': {
|
|
82
|
+
// Common wrappers
|
|
83
|
+
const obj = val;
|
|
84
|
+
if (obj.values) {
|
|
85
|
+
recur(obj.values);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (obj.Value) {
|
|
89
|
+
recur(obj.Value);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
// Map/Set support
|
|
93
|
+
if (val instanceof Set) {
|
|
94
|
+
recur(Array.from(val));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (val instanceof Map) {
|
|
98
|
+
recur(Array.from(val.values()));
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
// Fallback: string representation
|
|
102
|
+
const s = ((_b = (_a = obj === null || obj === void 0 ? void 0 : obj.toString) === null || _a === void 0 ? void 0 : _a.call(obj)) !== null && _b !== void 0 ? _b : '').toString();
|
|
103
|
+
if (s)
|
|
104
|
+
pushFromString(s);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
default:
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
recur(input);
|
|
112
|
+
// Normalize & dedupe
|
|
113
|
+
return Array.from(new Set(out.map((x) => x.trim()).filter(Boolean)));
|
|
114
|
+
};
|
|
115
|
+
const usersFromSelect = toArray(userIdsSelect);
|
|
116
|
+
const usersFromManual = parseManualIds(userIdsManual);
|
|
117
|
+
// Final pick based on UsersMode
|
|
118
|
+
let userIds = usersMode === 'select' ? usersFromSelect : usersFromManual;
|
|
119
|
+
// Optional: strict GUID validation (enable if needed)
|
|
120
|
+
// const guidRe = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
121
|
+
// userIds = userIds.filter(id => guidRe.test(id));
|
|
122
|
+
userIds = Array.from(new Set(userIds)).filter(Boolean);
|
|
123
|
+
// resultNote
|
|
28
124
|
const resultNoteTop = status === 'Done' ? this.getNodeParameter('ResultNote', i, '') : '';
|
|
29
125
|
// Additional
|
|
30
126
|
const add = this.getNodeParameter('additionalFields', i, {}) || {};
|
|
@@ -95,7 +95,7 @@ exports.caseCreateProperties = [
|
|
|
95
95
|
typeOptions: { multipleValues: true },
|
|
96
96
|
default: [],
|
|
97
97
|
displayOptions: { show: { ...showForCaseCreate.show, UsersMode: ['manual'] } },
|
|
98
|
-
description: 'Enter one or more user IDs (GUIDs).',
|
|
98
|
+
description: 'Enter one or more user IDs (GUIDs or GUIDs,GUIDs or [GUIDs,GUIDs]). Accepts multiple fields, CSV/newlines, JSON array, or an expression returning an array.',
|
|
99
99
|
},
|
|
100
100
|
{
|
|
101
101
|
displayName: 'Result Note',
|
|
@@ -150,7 +150,8 @@ exports.caseCreateProperties = [
|
|
|
150
150
|
{ displayName: 'Custom Fields (JSON)', name: 'Fields', type: 'json', default: '', placeholder: '{ "Field_XXXX_0_YY": "value" }', description: 'JSON object of custom fields.' },
|
|
151
151
|
// string[]
|
|
152
152
|
{ displayName: 'Label IDs', name: 'LabelIds', type: 'string', typeOptions: { multipleValues: true }, default: [], description: 'Label IDs to be set on the case.' },
|
|
153
|
-
{
|
|
153
|
+
{
|
|
154
|
+
displayName: 'Visibility Type', name: 'VisibilityType', type: 'options',
|
|
154
155
|
options: [
|
|
155
156
|
{ name: 'Owner', value: 'Owner' },
|
|
156
157
|
{ name: 'Owner Group', value: 'OwnerGroup' },
|
|
@@ -26,8 +26,104 @@ async function caseUpdate(i, returnData) {
|
|
|
26
26
|
const usersMode = this.getNodeParameter('UsersMode', i, 'select');
|
|
27
27
|
const userIdsSelect = this.getNodeParameter('UserIdsSelect', i, []);
|
|
28
28
|
const userIdsManual = this.getNodeParameter('UserIdsManual', i, []);
|
|
29
|
-
const toArray = (v) => Array.isArray(v)
|
|
30
|
-
|
|
29
|
+
const toArray = (v) => Array.isArray(v)
|
|
30
|
+
? v.map((x) => (x !== null && x !== void 0 ? x : '').toString().trim()).filter(Boolean)
|
|
31
|
+
: (typeof v === 'string' && v ? [v.trim()] : []);
|
|
32
|
+
// --- Robust parser for Manual input ---
|
|
33
|
+
const parseManualIds = (input) => {
|
|
34
|
+
const out = [];
|
|
35
|
+
const pushFromString = (raw) => {
|
|
36
|
+
if (!raw)
|
|
37
|
+
return;
|
|
38
|
+
const s = raw.trim();
|
|
39
|
+
if (!s)
|
|
40
|
+
return;
|
|
41
|
+
// Handle "[Array: [...]]" visualization
|
|
42
|
+
const arrayLabel = s.match(/^\s*\[Array:\s*(\[[\s\S]*\])\s*\]\s*$/i);
|
|
43
|
+
if (arrayLabel) {
|
|
44
|
+
try {
|
|
45
|
+
const arr = JSON.parse(arrayLabel[1]);
|
|
46
|
+
recur(arr);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
catch { /* fall through */ }
|
|
50
|
+
}
|
|
51
|
+
// Try JSON array
|
|
52
|
+
if (/^\s*\[/.test(s)) {
|
|
53
|
+
try {
|
|
54
|
+
const arr = JSON.parse(s);
|
|
55
|
+
recur(arr);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
throw new Error('Invalid JSON in "User IDs (Manual)". Expected a JSON array of strings.');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Otherwise treat as CSV/newline/semicolon separated
|
|
63
|
+
s.split(/[\n,;]+/)
|
|
64
|
+
.map((t) => t.trim())
|
|
65
|
+
.filter(Boolean)
|
|
66
|
+
.forEach((t) => out.push(t));
|
|
67
|
+
};
|
|
68
|
+
const recur = (val) => {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
if (val == null)
|
|
71
|
+
return;
|
|
72
|
+
if (Array.isArray(val)) {
|
|
73
|
+
val.forEach(recur);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
switch (typeof val) {
|
|
77
|
+
case 'string':
|
|
78
|
+
pushFromString(val);
|
|
79
|
+
return;
|
|
80
|
+
case 'number':
|
|
81
|
+
case 'boolean':
|
|
82
|
+
out.push(String(val));
|
|
83
|
+
return;
|
|
84
|
+
case 'object': {
|
|
85
|
+
// Common wrappers
|
|
86
|
+
const obj = val;
|
|
87
|
+
if (obj.values) {
|
|
88
|
+
recur(obj.values);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (obj.Value) {
|
|
92
|
+
recur(obj.Value);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
// Map/Set support
|
|
96
|
+
if (val instanceof Set) {
|
|
97
|
+
recur(Array.from(val));
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (val instanceof Map) {
|
|
101
|
+
recur(Array.from(val.values()));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
// Fallback: string representation
|
|
105
|
+
const s = ((_b = (_a = obj === null || obj === void 0 ? void 0 : obj.toString) === null || _a === void 0 ? void 0 : _a.call(obj)) !== null && _b !== void 0 ? _b : '').toString();
|
|
106
|
+
if (s)
|
|
107
|
+
pushFromString(s);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
default:
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
recur(input);
|
|
115
|
+
// Normalize & dedupe
|
|
116
|
+
return Array.from(new Set(out.map((x) => x.trim()).filter(Boolean)));
|
|
117
|
+
};
|
|
118
|
+
const usersFromSelect = toArray(userIdsSelect);
|
|
119
|
+
const usersFromManual = parseManualIds(userIdsManual);
|
|
120
|
+
// Final pick based on UsersMode
|
|
121
|
+
let userIds = usersMode === 'select' ? usersFromSelect : usersFromManual;
|
|
122
|
+
// Optional: strict GUID validation (enable if needed)
|
|
123
|
+
// const guidRe = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
124
|
+
// userIds = userIds.filter(id => guidRe.test(id));
|
|
125
|
+
userIds = Array.from(new Set(userIds)).filter(Boolean);
|
|
126
|
+
// resultNote
|
|
31
127
|
const resultNoteTop = status === 'Done' ? this.getNodeParameter('ResultNote', i, '') : '';
|
|
32
128
|
// Additional
|
|
33
129
|
const add = this.getNodeParameter('additionalFields', i, {}) || {};
|
|
@@ -105,7 +105,7 @@ exports.caseUpdateProperties = [
|
|
|
105
105
|
typeOptions: { multipleValues: true },
|
|
106
106
|
default: [],
|
|
107
107
|
displayOptions: { show: { ...showForCaseUpdate.show, UsersMode: ['manual'] } },
|
|
108
|
-
description: 'Enter one or more user IDs (GUIDs).',
|
|
108
|
+
description: 'Enter one or more user IDs (GUIDs or GUIDs,GUIDs or [GUIDs,GUIDs]). Accepts multiple fields, CSV/newlines, JSON array, or an expression returning an array.',
|
|
109
109
|
},
|
|
110
110
|
{
|
|
111
111
|
displayName: 'Result Note',
|
|
@@ -157,7 +157,8 @@ exports.caseUpdateProperties = [
|
|
|
157
157
|
{ displayName: 'Other Contact IDs', name: 'OtherContactIds', type: 'string', typeOptions: { multipleValues: true }, default: [], description: 'Additional related contact IDs (GUIDs).' },
|
|
158
158
|
{ displayName: 'Custom Fields (JSON)', name: 'Fields', type: 'json', default: '', placeholder: '{ "Field_XXXX_0_YY": "value" }', description: 'JSON object of custom fields.' },
|
|
159
159
|
{ displayName: 'Label IDs', name: 'LabelIds', type: 'string', typeOptions: { multipleValues: true }, default: [], description: 'Label IDs to be set on the case.' },
|
|
160
|
-
{
|
|
160
|
+
{
|
|
161
|
+
displayName: 'Visibility Type', name: 'VisibilityType', type: 'options',
|
|
161
162
|
options: [
|
|
162
163
|
{ name: 'Owner', value: 'Owner' },
|
|
163
164
|
{ name: 'Owner Group', value: 'OwnerGroup' },
|
|
@@ -4,3 +4,5 @@ export { companyUpdate } from './update.operation';
|
|
|
4
4
|
export { companyUpdateProperties } from './update.properties';
|
|
5
5
|
export { companyGet } from './get.operation';
|
|
6
6
|
export { companyGetProperties } from './get.properties';
|
|
7
|
+
export { companySearch } from './search.operation';
|
|
8
|
+
export { companySearchProperties } from './search.properties';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.companyGetProperties = exports.companyGet = exports.companyUpdateProperties = exports.companyUpdate = exports.companyCreateProperties = exports.companyCreate = void 0;
|
|
3
|
+
exports.companySearchProperties = exports.companySearch = exports.companyGetProperties = exports.companyGet = exports.companyUpdateProperties = exports.companyUpdate = exports.companyCreateProperties = exports.companyCreate = void 0;
|
|
4
4
|
var create_operation_1 = require("./create.operation");
|
|
5
5
|
Object.defineProperty(exports, "companyCreate", { enumerable: true, get: function () { return create_operation_1.companyCreate; } });
|
|
6
6
|
var create_properties_1 = require("./create.properties");
|
|
@@ -13,3 +13,7 @@ var get_operation_1 = require("./get.operation");
|
|
|
13
13
|
Object.defineProperty(exports, "companyGet", { enumerable: true, get: function () { return get_operation_1.companyGet; } });
|
|
14
14
|
var get_properties_1 = require("./get.properties");
|
|
15
15
|
Object.defineProperty(exports, "companyGetProperties", { enumerable: true, get: function () { return get_properties_1.companyGetProperties; } });
|
|
16
|
+
var search_operation_1 = require("./search.operation");
|
|
17
|
+
Object.defineProperty(exports, "companySearch", { enumerable: true, get: function () { return search_operation_1.companySearch; } });
|
|
18
|
+
var search_properties_1 = require("./search.properties");
|
|
19
|
+
Object.defineProperty(exports, "companySearchProperties", { enumerable: true, get: function () { return search_properties_1.companySearchProperties; } });
|