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
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.companySearch = companySearch;
|
|
4
|
+
const http_1 = require("../../lib/http");
|
|
5
|
+
async function companySearch(i, returnData) {
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
7
|
+
// Helpers
|
|
8
|
+
const parseJsonFlexible = (val) => {
|
|
9
|
+
if (val == null || val === '')
|
|
10
|
+
return [];
|
|
11
|
+
if (Array.isArray(val))
|
|
12
|
+
return val;
|
|
13
|
+
if (typeof val === 'string') {
|
|
14
|
+
const s = val.trim();
|
|
15
|
+
if (!s)
|
|
16
|
+
return [];
|
|
17
|
+
const m = s.match(/^\s*\[Array:\s*(\[[\s\S]*\])\s*\]\s*$/i);
|
|
18
|
+
if (m) {
|
|
19
|
+
try {
|
|
20
|
+
return JSON.parse(m[1]);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
throw new Error('Invalid JSON in Custom Fields.');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
const parsed = JSON.parse(s);
|
|
28
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
throw new Error('Invalid JSON in Custom Fields.');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return [];
|
|
35
|
+
};
|
|
36
|
+
// Main (optional)
|
|
37
|
+
const keywords = this.getNodeParameter('Keywords', i, '').trim();
|
|
38
|
+
// Owner (select/manual) — optional
|
|
39
|
+
const ownerMode = this.getNodeParameter('OwnerMode', i, 'select');
|
|
40
|
+
const ownerSel = this.getNodeParameter('OwnerIdSelect', i, '');
|
|
41
|
+
const ownerMan = this.getNodeParameter('OwnerIdManual', i, '');
|
|
42
|
+
const ownerId = ownerMode === 'select' ? ownerSel : ownerMan;
|
|
43
|
+
// Additional
|
|
44
|
+
const add = this.getNodeParameter('additionalFields', i, {}) || {};
|
|
45
|
+
const searchFromTime = (_a = add.SearchFromTime) !== null && _a !== void 0 ? _a : '1000-01-01T00:00:00.000Z';
|
|
46
|
+
const searchToTime = (_b = add.SearchToTime) !== null && _b !== void 0 ? _b : '9999-12-01T00:00:00.000Z';
|
|
47
|
+
const sortOrder = (_c = add.SortOrder) !== null && _c !== void 0 ? _c : 0;
|
|
48
|
+
// Flags (send only if set)
|
|
49
|
+
const isDeleted = (_d = add.IsDeleted) !== null && _d !== void 0 ? _d : '';
|
|
50
|
+
const isPinned = (_e = add.IsPinned) !== null && _e !== void 0 ? _e : '';
|
|
51
|
+
const isVIP = (_f = add.IsVIP) !== null && _f !== void 0 ? _f : '';
|
|
52
|
+
const hasIsDeleted = Object.prototype.hasOwnProperty.call(add, 'IsDeleted') && isDeleted !== '';
|
|
53
|
+
const hasIsPinned = Object.prototype.hasOwnProperty.call(add, 'IsPinned') && isPinned !== '';
|
|
54
|
+
const hasIsVIP = Object.prototype.hasOwnProperty.call(add, 'IsVIP') && isVIP !== '';
|
|
55
|
+
const customFields = parseJsonFlexible(add.CustomFields);
|
|
56
|
+
const limit = typeof add.Limit === 'number' ? add.Limit : 10;
|
|
57
|
+
const from = 0;
|
|
58
|
+
// Build Criteria (defaults + provided filters)
|
|
59
|
+
const criteria = {
|
|
60
|
+
SearchFromTime: searchFromTime,
|
|
61
|
+
SearchToTime: searchToTime,
|
|
62
|
+
SortOrder: sortOrder,
|
|
63
|
+
};
|
|
64
|
+
if (keywords)
|
|
65
|
+
criteria['Keywords'] = keywords;
|
|
66
|
+
if (ownerId)
|
|
67
|
+
criteria['OwnerId'] = ownerId;
|
|
68
|
+
if (hasIsDeleted)
|
|
69
|
+
criteria['IsDeleted'] = isDeleted;
|
|
70
|
+
if (hasIsPinned)
|
|
71
|
+
criteria['IsPinned'] = isPinned;
|
|
72
|
+
if (hasIsVIP)
|
|
73
|
+
criteria['IsVIP'] = isVIP;
|
|
74
|
+
if (customFields.length)
|
|
75
|
+
criteria['CustomFields'] = customFields;
|
|
76
|
+
const body = { Criteria: criteria, From: from, Limit: limit };
|
|
77
|
+
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
78
|
+
method: 'POST',
|
|
79
|
+
path: '/api/contact/CompanySearch',
|
|
80
|
+
body,
|
|
81
|
+
});
|
|
82
|
+
const out = ((_g = resp === null || resp === void 0 ? void 0 : resp.Response) !== null && _g !== void 0 ? _g : resp);
|
|
83
|
+
// مطابق خواستهی شما: criteria هم در خروجی بیاید
|
|
84
|
+
returnData.push({ json: { search_respons: out, criteria: body } });
|
|
85
|
+
// returnData.push({ json: out });
|
|
86
|
+
return returnData;
|
|
87
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.companySearchProperties = void 0;
|
|
4
|
+
const showForCompanySearch = { show: { resource: ['company'], operation: ['search'] } };
|
|
5
|
+
exports.companySearchProperties = [
|
|
6
|
+
// ===== Main fields (ordered) =====
|
|
7
|
+
{
|
|
8
|
+
displayName: 'Keywords',
|
|
9
|
+
name: 'Keywords',
|
|
10
|
+
type: 'string',
|
|
11
|
+
default: '',
|
|
12
|
+
required: false,
|
|
13
|
+
displayOptions: showForCompanySearch,
|
|
14
|
+
description: 'Free-text search (optional).',
|
|
15
|
+
},
|
|
16
|
+
// Owner (select/manual) — optional
|
|
17
|
+
{
|
|
18
|
+
displayName: 'Owner Input Mode',
|
|
19
|
+
name: 'OwnerMode',
|
|
20
|
+
type: 'options',
|
|
21
|
+
options: [
|
|
22
|
+
{ name: 'Select from list', value: 'select' },
|
|
23
|
+
{ name: 'Enter ID manually', value: 'manual' },
|
|
24
|
+
],
|
|
25
|
+
default: 'select',
|
|
26
|
+
displayOptions: showForCompanySearch,
|
|
27
|
+
description: 'Choose how to set the owner filter (optional).',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
displayName: 'Owner',
|
|
31
|
+
name: 'OwnerIdSelect',
|
|
32
|
+
type: 'options',
|
|
33
|
+
typeOptions: { loadOptionsMethod: 'getUsers' },
|
|
34
|
+
default: '',
|
|
35
|
+
displayOptions: { show: { ...showForCompanySearch.show, OwnerMode: ['select'] } },
|
|
36
|
+
description: 'Select the owner user (leave empty to ignore).',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
displayName: 'Owner ID',
|
|
40
|
+
name: 'OwnerIdManual',
|
|
41
|
+
type: 'string',
|
|
42
|
+
default: '',
|
|
43
|
+
displayOptions: { show: { ...showForCompanySearch.show, OwnerMode: ['manual'] } },
|
|
44
|
+
description: 'Enter owner user ID manually (leave empty to ignore).',
|
|
45
|
+
},
|
|
46
|
+
// ===== Additional filters (collection) =====
|
|
47
|
+
{
|
|
48
|
+
displayName: 'Additional Filters',
|
|
49
|
+
name: 'additionalFields',
|
|
50
|
+
type: 'collection',
|
|
51
|
+
placeholder: 'Add filter',
|
|
52
|
+
default: {},
|
|
53
|
+
displayOptions: showForCompanySearch,
|
|
54
|
+
options: [
|
|
55
|
+
// ثابتها (با دیفالت؛ همیشه در بدنه میآیند)
|
|
56
|
+
{
|
|
57
|
+
displayName: 'Search From Time',
|
|
58
|
+
name: 'SearchFromTime',
|
|
59
|
+
type: 'dateTime',
|
|
60
|
+
default: '1000-01-01T00:00:00.000Z',
|
|
61
|
+
description: 'Lower bound for the selected time field.',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
displayName: 'Search To Time',
|
|
65
|
+
name: 'SearchToTime',
|
|
66
|
+
type: 'dateTime',
|
|
67
|
+
default: '9999-12-01T00:00:00.000Z',
|
|
68
|
+
description: 'Upper bound for the selected time field.',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
displayName: 'Sort Order',
|
|
72
|
+
name: 'SortOrder',
|
|
73
|
+
type: 'options',
|
|
74
|
+
options: [
|
|
75
|
+
{ name: 'Alphabetical', value: 0 },
|
|
76
|
+
{ name: 'Newest First', value: 1 },
|
|
77
|
+
],
|
|
78
|
+
default: 0,
|
|
79
|
+
description: 'Sorting mode.',
|
|
80
|
+
},
|
|
81
|
+
// Flags (optional)
|
|
82
|
+
{
|
|
83
|
+
displayName: 'Is Deleted',
|
|
84
|
+
name: 'IsDeleted',
|
|
85
|
+
type: 'options',
|
|
86
|
+
options: [
|
|
87
|
+
{ name: 'Not set', value: '' },
|
|
88
|
+
{ name: 'No (0)', value: 0 },
|
|
89
|
+
{ name: 'Yes (1)', value: 1 },
|
|
90
|
+
],
|
|
91
|
+
default: '',
|
|
92
|
+
description: 'Filter by deletion flag (optional).',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
displayName: 'Is Pinned',
|
|
96
|
+
name: 'IsPinned',
|
|
97
|
+
type: 'options',
|
|
98
|
+
options: [
|
|
99
|
+
{ name: 'Not set', value: '' },
|
|
100
|
+
{ name: 'True (1)', value: 1 },
|
|
101
|
+
{ name: 'False (-1)', value: -1 },
|
|
102
|
+
],
|
|
103
|
+
default: '',
|
|
104
|
+
description: 'Filter by pin flag (optional).',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
displayName: 'Is VIP',
|
|
108
|
+
name: 'IsVIP',
|
|
109
|
+
type: 'options',
|
|
110
|
+
options: [
|
|
111
|
+
{ name: 'Not set', value: '' },
|
|
112
|
+
{ name: 'True (1)', value: 1 },
|
|
113
|
+
{ name: 'False (-1)', value: -1 },
|
|
114
|
+
],
|
|
115
|
+
default: '',
|
|
116
|
+
description: 'Filter by VIP flag (optional).',
|
|
117
|
+
},
|
|
118
|
+
// CustomFields as JSON (optional)
|
|
119
|
+
{
|
|
120
|
+
displayName: 'Custom Fields (JSON)',
|
|
121
|
+
name: 'CustomFields',
|
|
122
|
+
type: 'json',
|
|
123
|
+
default: '[]',
|
|
124
|
+
description: 'JSON array of custom field filters (optional).',
|
|
125
|
+
},
|
|
126
|
+
// Pagination (Limit only; From=0 hidden)
|
|
127
|
+
{
|
|
128
|
+
displayName: 'Limit',
|
|
129
|
+
name: 'Limit',
|
|
130
|
+
type: 'number',
|
|
131
|
+
default: 10,
|
|
132
|
+
description: 'Number of results to return.',
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
];
|
|
@@ -4,3 +4,5 @@ export { dealGet } from './get.operation';
|
|
|
4
4
|
export { dealCreateProperties } from './create.properties';
|
|
5
5
|
export { dealUpdateProperties } from './update.properties';
|
|
6
6
|
export { dealGetProperties } from './get.properties';
|
|
7
|
+
export { dealSearch } from './search.operation';
|
|
8
|
+
export { dealSearchProperties } from './search.properties';
|
package/dist/nodes/deal/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dealGetProperties = exports.dealUpdateProperties = exports.dealCreateProperties = exports.dealGet = exports.dealUpdate = exports.dealCreate = void 0;
|
|
3
|
+
exports.dealSearchProperties = exports.dealSearch = 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");
|
|
@@ -13,3 +13,7 @@ var update_properties_1 = require("./update.properties");
|
|
|
13
13
|
Object.defineProperty(exports, "dealUpdateProperties", { enumerable: true, get: function () { return update_properties_1.dealUpdateProperties; } });
|
|
14
14
|
var get_properties_1 = require("./get.properties");
|
|
15
15
|
Object.defineProperty(exports, "dealGetProperties", { enumerable: true, get: function () { return get_properties_1.dealGetProperties; } });
|
|
16
|
+
var search_operation_1 = require("./search.operation");
|
|
17
|
+
Object.defineProperty(exports, "dealSearch", { enumerable: true, get: function () { return search_operation_1.dealSearch; } });
|
|
18
|
+
var search_properties_1 = require("./search.properties");
|
|
19
|
+
Object.defineProperty(exports, "dealSearchProperties", { enumerable: true, get: function () { return search_properties_1.dealSearchProperties; } });
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dealSearch = dealSearch;
|
|
4
|
+
const http_1 = require("../../lib/http");
|
|
5
|
+
async function dealSearch(i, returnData) {
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
7
|
+
// Helpers
|
|
8
|
+
const uniq = (arr) => Array.from(new Set(arr.map(s => s.trim()).filter(Boolean)));
|
|
9
|
+
const parseIdList = (input) => {
|
|
10
|
+
const out = [];
|
|
11
|
+
const pushFromString = (raw) => {
|
|
12
|
+
if (!raw)
|
|
13
|
+
return;
|
|
14
|
+
const s = raw.trim();
|
|
15
|
+
if (!s)
|
|
16
|
+
return;
|
|
17
|
+
const arrayLabel = s.match(/^\s*\[Array:\s*(\[[\s\S]*\])\s*\]\s*$/i);
|
|
18
|
+
if (arrayLabel) {
|
|
19
|
+
try {
|
|
20
|
+
const arr = JSON.parse(arrayLabel[1]);
|
|
21
|
+
recur(arr);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
catch { }
|
|
25
|
+
}
|
|
26
|
+
if (/^\s*\[/.test(s)) {
|
|
27
|
+
try {
|
|
28
|
+
const arr = JSON.parse(s);
|
|
29
|
+
recur(arr);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
throw new Error('Invalid JSON array.');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
s.split(/[\n,;]+/).map(t => t.trim()).filter(Boolean).forEach(t => out.push(t));
|
|
37
|
+
};
|
|
38
|
+
const recur = (val) => {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
if (val == null)
|
|
41
|
+
return;
|
|
42
|
+
if (Array.isArray(val)) {
|
|
43
|
+
val.forEach(recur);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
switch (typeof val) {
|
|
47
|
+
case 'string':
|
|
48
|
+
pushFromString(val);
|
|
49
|
+
return;
|
|
50
|
+
case 'number':
|
|
51
|
+
case 'boolean':
|
|
52
|
+
out.push(String(val));
|
|
53
|
+
return;
|
|
54
|
+
case 'object': {
|
|
55
|
+
const obj = val;
|
|
56
|
+
if (val instanceof Set) {
|
|
57
|
+
recur(Array.from(val));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (val instanceof Map) {
|
|
61
|
+
recur(Array.from(val.values()));
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (obj === null || obj === void 0 ? void 0 : obj.values) {
|
|
65
|
+
recur(obj.values);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (obj === null || obj === void 0 ? void 0 : obj.Value) {
|
|
69
|
+
recur(obj.Value);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
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();
|
|
73
|
+
if (s)
|
|
74
|
+
pushFromString(s);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
default: return;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
recur(input);
|
|
81
|
+
return uniq(out);
|
|
82
|
+
};
|
|
83
|
+
const parseJsonFlexible = (val) => {
|
|
84
|
+
if (val == null || val === '')
|
|
85
|
+
return [];
|
|
86
|
+
if (Array.isArray(val))
|
|
87
|
+
return val;
|
|
88
|
+
if (typeof val === 'string') {
|
|
89
|
+
const s = val.trim();
|
|
90
|
+
if (!s)
|
|
91
|
+
return [];
|
|
92
|
+
const m = s.match(/^\s*\[Array:\s*(\[[\s\S]*\])\s*\]\s*$/i);
|
|
93
|
+
if (m) {
|
|
94
|
+
try {
|
|
95
|
+
return JSON.parse(m[1]);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
throw new Error('Invalid JSON in Custom Fields.');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
const parsed = JSON.parse(s);
|
|
103
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
throw new Error('Invalid JSON in Custom Fields.');
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return [];
|
|
110
|
+
};
|
|
111
|
+
// Optional filters (no required checks)
|
|
112
|
+
const keywords = this.getNodeParameter('Keywords', i, '').trim();
|
|
113
|
+
const status = this.getNodeParameter('Status', i, '');
|
|
114
|
+
// Owner (select/manual) — optional
|
|
115
|
+
const ownerMode = this.getNodeParameter('OwnerMode', i, 'select');
|
|
116
|
+
const ownerSel = this.getNodeParameter('OwnerIdSelect', i, '');
|
|
117
|
+
const ownerMan = this.getNodeParameter('OwnerIdManual', i, '');
|
|
118
|
+
const ownerId = ownerMode === 'select' ? ownerSel : ownerMan;
|
|
119
|
+
// Lists
|
|
120
|
+
const contactIdsInput = this.getNodeParameter('ContactIds', i, []);
|
|
121
|
+
const labelIdsInput = this.getNodeParameter('LabelIds', i, []);
|
|
122
|
+
const contactIds = parseIdList(contactIdsInput);
|
|
123
|
+
const labelIds = parseIdList(labelIdsInput);
|
|
124
|
+
// Pipeline/Stage — optional pair
|
|
125
|
+
const pipeMode = (_a = this.getNodeParameter('PipelineMode', i, 'select')) !== null && _a !== void 0 ? _a : 'select';
|
|
126
|
+
let pipelineId = '';
|
|
127
|
+
let pipelineStageId = '';
|
|
128
|
+
if (pipeMode === 'select') {
|
|
129
|
+
pipelineId = this.getNodeParameter('pipelineId', i, '') || '';
|
|
130
|
+
pipelineStageId = this.getNodeParameter('pipelineStageId', i, '') || '';
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
pipelineId = this.getNodeParameter('PipelineIdManual', i, '') || '';
|
|
134
|
+
pipelineStageId = this.getNodeParameter('PipelineStageIdManual', i, '') || '';
|
|
135
|
+
}
|
|
136
|
+
const bothEmpty = !pipelineId && !pipelineStageId;
|
|
137
|
+
const bothFilled = !!pipelineId && !!pipelineStageId;
|
|
138
|
+
if (!(bothEmpty || bothFilled)) {
|
|
139
|
+
throw new Error('Pipeline and Pipeline Stage must be both provided together or both empty.');
|
|
140
|
+
}
|
|
141
|
+
// Additional
|
|
142
|
+
const add = this.getNodeParameter('additionalFields', i, {}) || {};
|
|
143
|
+
const searchFromTime = (_b = add.SearchFromTime) !== null && _b !== void 0 ? _b : '1000-01-01T00:00:00.000Z';
|
|
144
|
+
const searchToTime = (_c = add.SearchToTime) !== null && _c !== void 0 ? _c : '9999-12-01T00:00:00.000Z';
|
|
145
|
+
const sort = (_d = add.Sort) !== null && _d !== void 0 ? _d : 0;
|
|
146
|
+
const hasProb = Object.prototype.hasOwnProperty.call(add, 'Probability');
|
|
147
|
+
const probability = hasProb ? Number(add.Probability) : undefined;
|
|
148
|
+
const hasNextFrom = Object.prototype.hasOwnProperty.call(add, 'NextActivityFrom');
|
|
149
|
+
const hasNextTo = Object.prototype.hasOwnProperty.call(add, 'NextActivityTo');
|
|
150
|
+
const nextFromVal = (_e = add.NextActivityFrom) !== null && _e !== void 0 ? _e : '';
|
|
151
|
+
const nextToVal = (_f = add.NextActivityTo) !== null && _f !== void 0 ? _f : '';
|
|
152
|
+
const sourceId = (_g = add.SourceId) !== null && _g !== void 0 ? _g : '';
|
|
153
|
+
const lostReasonId = (_h = add.LostReasonId) !== null && _h !== void 0 ? _h : '';
|
|
154
|
+
const customFields = parseJsonFlexible(add.CustomFields);
|
|
155
|
+
const limit = typeof add.Limit === 'number' ? add.Limit : 10;
|
|
156
|
+
const from = 0;
|
|
157
|
+
// Build Criteria with only provided filters
|
|
158
|
+
const criteria = {
|
|
159
|
+
SearchTimeField: 1,
|
|
160
|
+
SearchFromTime: searchFromTime,
|
|
161
|
+
SearchToTime: searchToTime,
|
|
162
|
+
Sort: sort,
|
|
163
|
+
};
|
|
164
|
+
if (keywords)
|
|
165
|
+
criteria['Keywords'] = keywords;
|
|
166
|
+
if (status)
|
|
167
|
+
criteria['Status'] = status;
|
|
168
|
+
if (ownerId)
|
|
169
|
+
criteria['OwnerId'] = ownerId;
|
|
170
|
+
if (contactIds.length)
|
|
171
|
+
criteria['ContactIds'] = contactIds;
|
|
172
|
+
if (labelIds.length)
|
|
173
|
+
criteria['LabelIds'] = labelIds;
|
|
174
|
+
if (hasProb && !Number.isNaN(probability))
|
|
175
|
+
criteria['Probability'] = String(probability);
|
|
176
|
+
if (bothFilled) {
|
|
177
|
+
criteria['PipelineId'] = pipelineId;
|
|
178
|
+
criteria['PipelineStageId'] = pipelineStageId;
|
|
179
|
+
}
|
|
180
|
+
if (hasNextFrom && nextFromVal)
|
|
181
|
+
criteria['NextActivityFrom'] = nextFromVal;
|
|
182
|
+
if (hasNextTo && nextToVal)
|
|
183
|
+
criteria['NextActivityTo'] = nextToVal;
|
|
184
|
+
if (sourceId)
|
|
185
|
+
criteria['SourceId'] = sourceId;
|
|
186
|
+
if (lostReasonId)
|
|
187
|
+
criteria['LostReasonId'] = lostReasonId;
|
|
188
|
+
if (customFields === null || customFields === void 0 ? void 0 : customFields.length)
|
|
189
|
+
criteria['CustomFields'] = customFields;
|
|
190
|
+
const body = { Criteria: criteria, From: from, Limit: limit };
|
|
191
|
+
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
192
|
+
method: 'POST',
|
|
193
|
+
path: '/api/deal/search',
|
|
194
|
+
body,
|
|
195
|
+
});
|
|
196
|
+
const out = ((_j = resp === null || resp === void 0 ? void 0 : resp.Response) !== null && _j !== void 0 ? _j : resp);
|
|
197
|
+
returnData.push({ json: { search_respons: out, criteria: body } });
|
|
198
|
+
// returnData.push({ json: out });
|
|
199
|
+
return returnData;
|
|
200
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dealSearchProperties = void 0;
|
|
4
|
+
const showForDealSearch = { show: { resource: ['deal'], operation: ['search'] } };
|
|
5
|
+
exports.dealSearchProperties = [
|
|
6
|
+
// ===== Main fields (ordered) =====
|
|
7
|
+
{
|
|
8
|
+
displayName: 'Keywords',
|
|
9
|
+
name: 'Keywords',
|
|
10
|
+
type: 'string',
|
|
11
|
+
default: '',
|
|
12
|
+
required: false, // ← optional
|
|
13
|
+
displayOptions: showForDealSearch,
|
|
14
|
+
description: 'Free-text search (optional).',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
displayName: 'Status',
|
|
18
|
+
name: 'Status',
|
|
19
|
+
type: 'options',
|
|
20
|
+
options: [
|
|
21
|
+
{ name: 'Not set', value: '' }, // ← allow clearing
|
|
22
|
+
{ name: 'Pending', value: 'Pending' },
|
|
23
|
+
{ name: 'Won', value: 'Won' },
|
|
24
|
+
{ name: 'Lost', value: 'Lost' },
|
|
25
|
+
],
|
|
26
|
+
default: '', // ← not set by default
|
|
27
|
+
displayOptions: showForDealSearch,
|
|
28
|
+
description: 'Deal status filter (optional).',
|
|
29
|
+
},
|
|
30
|
+
// Owner (select/manual) — optional
|
|
31
|
+
{
|
|
32
|
+
displayName: 'Owner Input Mode',
|
|
33
|
+
name: 'OwnerMode',
|
|
34
|
+
type: 'options',
|
|
35
|
+
options: [
|
|
36
|
+
{ name: 'Select from list', value: 'select' },
|
|
37
|
+
{ name: 'Enter ID manually', value: 'manual' },
|
|
38
|
+
],
|
|
39
|
+
default: 'select',
|
|
40
|
+
displayOptions: showForDealSearch,
|
|
41
|
+
description: 'Choose how to set the owner filter (optional).',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
displayName: 'Owner',
|
|
45
|
+
name: 'OwnerIdSelect',
|
|
46
|
+
type: 'options',
|
|
47
|
+
typeOptions: { loadOptionsMethod: 'getUsers' },
|
|
48
|
+
default: '',
|
|
49
|
+
displayOptions: { show: { ...showForDealSearch.show, OwnerMode: ['select'] } },
|
|
50
|
+
description: 'Select the owner user (leave empty to ignore).',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
displayName: 'Owner ID',
|
|
54
|
+
name: 'OwnerIdManual',
|
|
55
|
+
type: 'string',
|
|
56
|
+
default: '',
|
|
57
|
+
displayOptions: { show: { ...showForDealSearch.show, OwnerMode: ['manual'] } },
|
|
58
|
+
description: 'Enter owner user ID manually (leave empty to ignore).',
|
|
59
|
+
},
|
|
60
|
+
// ContactIds (multi, robust) — optional
|
|
61
|
+
{
|
|
62
|
+
displayName: 'Contact IDs',
|
|
63
|
+
name: 'ContactIds',
|
|
64
|
+
type: 'string',
|
|
65
|
+
typeOptions: { multipleValues: true },
|
|
66
|
+
default: [],
|
|
67
|
+
displayOptions: showForDealSearch,
|
|
68
|
+
description: 'One or more contact IDs (optional). Accepts multiple, CSV/newlines, JSON array, or expression returning array.',
|
|
69
|
+
},
|
|
70
|
+
// LabelIds (multi, robust) — optional
|
|
71
|
+
{
|
|
72
|
+
displayName: 'Label IDs',
|
|
73
|
+
name: 'LabelIds',
|
|
74
|
+
type: 'string',
|
|
75
|
+
typeOptions: { multipleValues: true },
|
|
76
|
+
default: [],
|
|
77
|
+
displayOptions: showForDealSearch,
|
|
78
|
+
description: 'One or more label IDs (optional). Accepts multiple, CSV/newlines, JSON array, or expression returning array.',
|
|
79
|
+
},
|
|
80
|
+
// ===== Pipeline / Stage (TOP-LEVEL; optional) =====
|
|
81
|
+
{
|
|
82
|
+
displayName: 'Pipeline Input Mode',
|
|
83
|
+
name: 'PipelineMode',
|
|
84
|
+
type: 'options',
|
|
85
|
+
options: [
|
|
86
|
+
{ name: 'Select from list', value: 'select' },
|
|
87
|
+
{ name: 'Enter IDs manually', value: 'manual' },
|
|
88
|
+
],
|
|
89
|
+
default: 'select',
|
|
90
|
+
displayOptions: showForDealSearch,
|
|
91
|
+
description: 'Set pipeline and stage (optional). Both must be provided together or both empty.',
|
|
92
|
+
},
|
|
93
|
+
// Pipeline (select)
|
|
94
|
+
{
|
|
95
|
+
displayName: 'Pipeline',
|
|
96
|
+
name: 'pipelineId',
|
|
97
|
+
type: 'options',
|
|
98
|
+
typeOptions: { loadOptionsMethod: 'getPipelines' },
|
|
99
|
+
default: '',
|
|
100
|
+
displayOptions: { show: { ...showForDealSearch.show, PipelineMode: ['select'] } },
|
|
101
|
+
description: 'Pipeline (optional; required if stage is set).',
|
|
102
|
+
},
|
|
103
|
+
// Pipeline Stage (select) — وابسته به Pipeline
|
|
104
|
+
{
|
|
105
|
+
displayName: 'Pipeline Stage',
|
|
106
|
+
name: 'pipelineStageId',
|
|
107
|
+
type: 'options',
|
|
108
|
+
typeOptions: {
|
|
109
|
+
loadOptionsMethod: 'getStagesForPipeline',
|
|
110
|
+
loadOptionsDependsOn: ['pipelineId'], // ← حتماً باشد
|
|
111
|
+
},
|
|
112
|
+
default: '',
|
|
113
|
+
displayOptions: { show: { ...showForDealSearch.show, PipelineMode: ['select'] } },
|
|
114
|
+
description: 'Stage (optional; required if pipeline is set).',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
displayName: 'Pipeline ID (Manual)',
|
|
118
|
+
name: 'PipelineIdManual',
|
|
119
|
+
type: 'string',
|
|
120
|
+
default: '',
|
|
121
|
+
displayOptions: { show: { ...showForDealSearch.show, PipelineMode: ['manual'] } },
|
|
122
|
+
description: 'Enter pipeline ID (optional; required if stage manual is set).',
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
displayName: 'Pipeline Stage ID (Manual)',
|
|
126
|
+
name: 'PipelineStageIdManual',
|
|
127
|
+
type: 'string',
|
|
128
|
+
default: '',
|
|
129
|
+
displayOptions: { show: { ...showForDealSearch.show, PipelineMode: ['manual'] } },
|
|
130
|
+
description: 'Enter pipeline stage ID (optional; required if pipeline manual is set).',
|
|
131
|
+
},
|
|
132
|
+
// ===== Additional fields =====
|
|
133
|
+
{
|
|
134
|
+
displayName: 'Additional Filters',
|
|
135
|
+
name: 'additionalFields',
|
|
136
|
+
type: 'collection',
|
|
137
|
+
placeholder: 'Add filter',
|
|
138
|
+
default: {},
|
|
139
|
+
displayOptions: showForDealSearch,
|
|
140
|
+
options: [
|
|
141
|
+
// Time window (SearchTimeField fixed=1; keep defaults visible)
|
|
142
|
+
{
|
|
143
|
+
displayName: 'Search From Time',
|
|
144
|
+
name: 'SearchFromTime',
|
|
145
|
+
type: 'dateTime',
|
|
146
|
+
default: '1000-01-01T00:00:00.000Z',
|
|
147
|
+
description: 'Lower bound for the selected time field.',
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
displayName: 'Search To Time',
|
|
151
|
+
name: 'SearchToTime',
|
|
152
|
+
type: 'dateTime',
|
|
153
|
+
default: '9999-12-01T00:00:00.000Z',
|
|
154
|
+
description: 'Upper bound for the selected time field.',
|
|
155
|
+
},
|
|
156
|
+
// Sort (keep default 0)
|
|
157
|
+
{
|
|
158
|
+
displayName: 'Sort By',
|
|
159
|
+
name: 'Sort',
|
|
160
|
+
type: 'options',
|
|
161
|
+
options: [
|
|
162
|
+
{ name: 'Created Time', value: 0 },
|
|
163
|
+
{ name: 'Last Follow-up Time', value: 1 },
|
|
164
|
+
{ name: 'Next Follow-up Time', value: 2 },
|
|
165
|
+
{ name: 'Has Proforma Invoice', value: 3 },
|
|
166
|
+
{ name: 'Has Invoice', value: 4 },
|
|
167
|
+
{ name: 'No Invoice', value: 5 },
|
|
168
|
+
{ name: 'Has Canceled Invoice', value: 6 },
|
|
169
|
+
{ name: 'Has Proforma With Price', value: 7 },
|
|
170
|
+
{ name: 'Has Proforma Without Price', value: 8 },
|
|
171
|
+
{ name: 'Won Time', value: 9 },
|
|
172
|
+
{ name: 'Next Activity Time', value: 10 },
|
|
173
|
+
],
|
|
174
|
+
default: 0,
|
|
175
|
+
description: 'Sorting mode.',
|
|
176
|
+
},
|
|
177
|
+
// Probability (optional; only sent if provided)
|
|
178
|
+
{
|
|
179
|
+
displayName: 'Probability',
|
|
180
|
+
name: 'Probability',
|
|
181
|
+
type: 'number',
|
|
182
|
+
typeOptions: { minValue: 0, maxValue: 100 },
|
|
183
|
+
default: null,
|
|
184
|
+
description: 'Probability (0–100). Leave empty to ignore.',
|
|
185
|
+
},
|
|
186
|
+
// Next Activity range
|
|
187
|
+
{
|
|
188
|
+
displayName: 'Next Activity From',
|
|
189
|
+
name: 'NextActivityFrom',
|
|
190
|
+
type: 'dateTime',
|
|
191
|
+
default: '', // قبلاً: '1000-01-01T00:00:00.000Z'
|
|
192
|
+
description: 'Lower bound for next activity time (optional).',
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
displayName: 'Next Activity To',
|
|
196
|
+
name: 'NextActivityTo',
|
|
197
|
+
type: 'dateTime',
|
|
198
|
+
default: '', // قبلاً: '9999-12-01T00:00:00.000Z'
|
|
199
|
+
description: 'Upper bound for next activity time (optional).',
|
|
200
|
+
},
|
|
201
|
+
// Others
|
|
202
|
+
{ displayName: 'Source ID', name: 'SourceId', type: 'string', default: '' },
|
|
203
|
+
{ displayName: 'Lost Reason ID', name: 'LostReasonId', type: 'string', default: '' },
|
|
204
|
+
// CustomFields as JSON (optional)
|
|
205
|
+
{
|
|
206
|
+
displayName: 'Custom Fields (JSON)',
|
|
207
|
+
name: 'CustomFields',
|
|
208
|
+
type: 'json',
|
|
209
|
+
default: '[]',
|
|
210
|
+
description: 'JSON array of custom field filters (optional).',
|
|
211
|
+
},
|
|
212
|
+
// Pagination (keep default 10; بگو اگر میخواهی 1 باشد)
|
|
213
|
+
{
|
|
214
|
+
displayName: 'Limit',
|
|
215
|
+
name: 'Limit',
|
|
216
|
+
type: 'number',
|
|
217
|
+
default: 10,
|
|
218
|
+
description: 'Number of results to return.',
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
},
|
|
222
|
+
];
|