n8n-nodes-didar-crm 0.0.18 → 0.0.20
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 +53 -0
- package/dist/nodes/activity/index.d.ts +2 -0
- package/dist/nodes/activity/index.js +5 -1
- package/dist/nodes/activity/search.operation.d.ts +2 -0
- package/dist/nodes/activity/search.operation.js +162 -0
- package/dist/nodes/activity/search.properties.d.ts +2 -0
- package/dist/nodes/activity/search.properties.js +193 -0
- package/dist/nodes/case/index.d.ts +2 -0
- package/dist/nodes/case/index.js +5 -1
- package/dist/nodes/case/search.operation.d.ts +2 -0
- package/dist/nodes/case/search.operation.js +156 -0
- package/dist/nodes/case/search.properties.d.ts +2 -0
- package/dist/nodes/case/search.properties.js +93 -0
- 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/search.operation.js +2 -1
- 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/dist/nodes/product/index.d.ts +2 -0
- package/dist/nodes/product/index.js +5 -1
- package/dist/nodes/product/search.operation.d.ts +2 -0
- package/dist/nodes/product/search.operation.js +30 -0
- package/dist/nodes/product/search.properties.d.ts +2 -0
- package/dist/nodes/product/search.properties.js +23 -0
- package/dist/nodes/supplementary/get-base-info.operation.d.ts +2 -0
- package/dist/nodes/supplementary/get-base-info.operation.js +26 -0
- package/dist/nodes/supplementary/get-base-info.properties.d.ts +2 -0
- package/dist/nodes/supplementary/get-base-info.properties.js +20 -0
- package/dist/nodes/supplementary/index.d.ts +2 -0
- package/dist/nodes/supplementary/index.js +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.caseSearch = caseSearch;
|
|
4
|
+
const http_1 = require("../../lib/http");
|
|
5
|
+
async function caseSearch(i, returnData) {
|
|
6
|
+
var _a, _b, _c;
|
|
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
|
+
// Handles `[Array: [ ... ]]`
|
|
18
|
+
const arrayLabel = s.match(/^\s*\[Array:\s*(\[[\s\S]*\])\s*\]\s*$/i);
|
|
19
|
+
if (arrayLabel) {
|
|
20
|
+
try {
|
|
21
|
+
const arr = JSON.parse(arrayLabel[1]);
|
|
22
|
+
recur(arr);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
catch { }
|
|
26
|
+
}
|
|
27
|
+
// Handles direct JSON arrays like `["a","b"]`
|
|
28
|
+
if (/^\s*\[/.test(s)) {
|
|
29
|
+
try {
|
|
30
|
+
const arr = JSON.parse(s);
|
|
31
|
+
recur(arr);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
throw new Error('Invalid JSON array.');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// Split by common separators
|
|
39
|
+
s.split(/[\n,;]+/).map(t => t.trim()).filter(Boolean).forEach(t => out.push(t));
|
|
40
|
+
};
|
|
41
|
+
const recur = (val) => {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
if (val == null)
|
|
44
|
+
return;
|
|
45
|
+
if (Array.isArray(val)) {
|
|
46
|
+
val.forEach(recur);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
switch (typeof val) {
|
|
50
|
+
case 'string':
|
|
51
|
+
pushFromString(val);
|
|
52
|
+
return;
|
|
53
|
+
case 'number':
|
|
54
|
+
case 'boolean':
|
|
55
|
+
out.push(String(val));
|
|
56
|
+
return;
|
|
57
|
+
case 'object': {
|
|
58
|
+
const obj = val;
|
|
59
|
+
if (val instanceof Set) {
|
|
60
|
+
recur(Array.from(val));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (val instanceof Map) {
|
|
64
|
+
recur(Array.from(val.values()));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (obj === null || obj === void 0 ? void 0 : obj.values) {
|
|
68
|
+
recur(obj.values);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (obj === null || obj === void 0 ? void 0 : obj.Value) {
|
|
72
|
+
recur(obj.Value);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
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();
|
|
76
|
+
if (s)
|
|
77
|
+
pushFromString(s);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
default: return;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
recur(input);
|
|
84
|
+
return uniq(out);
|
|
85
|
+
};
|
|
86
|
+
const parseJsonFlexible = (val) => {
|
|
87
|
+
if (val == null || val === '')
|
|
88
|
+
return [];
|
|
89
|
+
if (Array.isArray(val))
|
|
90
|
+
return val;
|
|
91
|
+
if (typeof val === 'string') {
|
|
92
|
+
const s = val.trim();
|
|
93
|
+
if (!s)
|
|
94
|
+
return [];
|
|
95
|
+
const m = s.match(/^\s*\[Array:\s*(\[[\s\S]*\])\s*\]\s*$/i);
|
|
96
|
+
if (m) {
|
|
97
|
+
try {
|
|
98
|
+
return JSON.parse(m[1]);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
throw new Error('Invalid JSON in Custom Fields.');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
const parsed = JSON.parse(s);
|
|
106
|
+
return Array.isArray(parsed) ? parsed : [];
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
throw new Error('Invalid JSON in Custom Fields.');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return [];
|
|
113
|
+
};
|
|
114
|
+
// --- Main fields ---
|
|
115
|
+
const keywords = this.getNodeParameter('Keywords', i, '').trim();
|
|
116
|
+
// Owner (select/manual) — optional
|
|
117
|
+
const ownerMode = this.getNodeParameter('OwnerMode', i, 'select');
|
|
118
|
+
const ownerSel = this.getNodeParameter('OwnerIdSelect', i, '');
|
|
119
|
+
const ownerMan = this.getNodeParameter('OwnerIdManual', i, '');
|
|
120
|
+
const ownerId = ownerMode === 'select' ? ownerSel : ownerMan;
|
|
121
|
+
// ContactIds
|
|
122
|
+
const contactIdsInput = this.getNodeParameter('ContactIds', i, []);
|
|
123
|
+
const contactIds = parseIdList(contactIdsInput);
|
|
124
|
+
// Additional
|
|
125
|
+
const add = this.getNodeParameter('additionalFields', i, {}) || {};
|
|
126
|
+
const searchFromTime = (_a = add.SearchFromTime) !== null && _a !== void 0 ? _a : '1000-01-01T00:00:00.000Z';
|
|
127
|
+
const searchToTime = (_b = add.SearchToTime) !== null && _b !== void 0 ? _b : '9999-12-01T00:00:00.000Z';
|
|
128
|
+
const customFields = parseJsonFlexible(add.CustomFields);
|
|
129
|
+
const limit = typeof add.Limit === 'number' ? add.Limit : 10;
|
|
130
|
+
const from = 0;
|
|
131
|
+
// Build Criteria with only provided filters
|
|
132
|
+
const criteria = {
|
|
133
|
+
SearchTimeField: 1,
|
|
134
|
+
SearchFromTime: searchFromTime,
|
|
135
|
+
SearchToTime: searchToTime,
|
|
136
|
+
};
|
|
137
|
+
if (keywords)
|
|
138
|
+
criteria['Keywords'] = keywords;
|
|
139
|
+
if (ownerId)
|
|
140
|
+
criteria['OwnerId'] = ownerId;
|
|
141
|
+
if (contactIds.length)
|
|
142
|
+
criteria['ContactIds'] = contactIds;
|
|
143
|
+
if (customFields === null || customFields === void 0 ? void 0 : customFields.length)
|
|
144
|
+
criteria['CustomFields'] = customFields;
|
|
145
|
+
const body = { Criteria: criteria, From: from, Limit: limit };
|
|
146
|
+
// --- Request ---
|
|
147
|
+
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
148
|
+
method: 'POST',
|
|
149
|
+
path: '/api/Case/search',
|
|
150
|
+
body,
|
|
151
|
+
});
|
|
152
|
+
const out = ((_c = resp === null || resp === void 0 ? void 0 : resp.Response) !== null && _c !== void 0 ? _c : resp);
|
|
153
|
+
// Return with criteria for debugging
|
|
154
|
+
returnData.push({ json: { search_respons: out, criteria: body } });
|
|
155
|
+
return returnData;
|
|
156
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.caseSearchProperties = void 0;
|
|
4
|
+
const showForCaseSearch = { show: { resource: ['case'], operation: ['search'] } };
|
|
5
|
+
exports.caseSearchProperties = [
|
|
6
|
+
// ===== Main fields =====
|
|
7
|
+
{
|
|
8
|
+
displayName: 'Keywords',
|
|
9
|
+
name: 'Keywords',
|
|
10
|
+
type: 'string',
|
|
11
|
+
default: '',
|
|
12
|
+
required: false,
|
|
13
|
+
displayOptions: showForCaseSearch,
|
|
14
|
+
description: 'Free-text search (optional).',
|
|
15
|
+
},
|
|
16
|
+
// Owner (select/manual)
|
|
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: showForCaseSearch,
|
|
27
|
+
description: 'Choose how to filter by owner (optional).',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
displayName: 'Owner',
|
|
31
|
+
name: 'OwnerIdSelect',
|
|
32
|
+
type: 'options',
|
|
33
|
+
typeOptions: { loadOptionsMethod: 'getUsers' },
|
|
34
|
+
default: '',
|
|
35
|
+
displayOptions: { show: { ...showForCaseSearch.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: { ...showForCaseSearch.show, OwnerMode: ['manual'] } },
|
|
44
|
+
description: 'Enter the owner user ID manually (leave empty to ignore).',
|
|
45
|
+
},
|
|
46
|
+
// ===== Additional filters =====
|
|
47
|
+
{
|
|
48
|
+
displayName: 'Additional Filters',
|
|
49
|
+
name: 'additionalFields',
|
|
50
|
+
type: 'collection',
|
|
51
|
+
placeholder: 'Add filter',
|
|
52
|
+
default: {},
|
|
53
|
+
displayOptions: showForCaseSearch,
|
|
54
|
+
options: [
|
|
55
|
+
{
|
|
56
|
+
displayName: 'Search From Time',
|
|
57
|
+
name: 'SearchFromTime',
|
|
58
|
+
type: 'dateTime',
|
|
59
|
+
default: '1000-01-01T00:00:00.000Z',
|
|
60
|
+
description: 'Lower bound for the selected time field.',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
displayName: 'Search To Time',
|
|
64
|
+
name: 'SearchToTime',
|
|
65
|
+
type: 'dateTime',
|
|
66
|
+
default: '9999-12-01T00:00:00.000Z',
|
|
67
|
+
description: 'Upper bound for the selected time field.',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
displayName: 'Contact IDs',
|
|
71
|
+
name: 'ContactIds',
|
|
72
|
+
type: 'string',
|
|
73
|
+
typeOptions: { multipleValues: true },
|
|
74
|
+
default: [],
|
|
75
|
+
description: 'One or more contact IDs (optional). Accepts multiple, CSV/newlines, JSON array, or expression returning array.',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
displayName: 'Custom Fields (JSON)',
|
|
79
|
+
name: 'CustomFields',
|
|
80
|
+
type: 'json',
|
|
81
|
+
default: '[]',
|
|
82
|
+
description: 'JSON array of custom field filters (optional).',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
displayName: 'Limit',
|
|
86
|
+
name: 'Limit',
|
|
87
|
+
type: 'number',
|
|
88
|
+
default: 10,
|
|
89
|
+
description: 'Number of results to return.',
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
];
|
|
@@ -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; } });
|
|
@@ -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
|
+
];
|
|
@@ -194,6 +194,7 @@ async function dealSearch(i, returnData) {
|
|
|
194
194
|
body,
|
|
195
195
|
});
|
|
196
196
|
const out = ((_j = resp === null || resp === void 0 ? void 0 : resp.Response) !== null && _j !== void 0 ? _j : resp);
|
|
197
|
-
returnData.push({ json: {
|
|
197
|
+
returnData.push({ json: { search_respons: out, criteria: body } });
|
|
198
|
+
// returnData.push({ json: out });
|
|
198
199
|
return returnData;
|
|
199
200
|
}
|
|
@@ -4,3 +4,5 @@ export { personGet } from './get.operation';
|
|
|
4
4
|
export { personCreateProperties } from './create.properties';
|
|
5
5
|
export { personUpdateProperties } from './update.properties';
|
|
6
6
|
export { personGetProperties } from './get.properties';
|
|
7
|
+
export { personSearch } from './search.operation';
|
|
8
|
+
export { personSearchProperties } from './search.properties';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.personGetProperties = exports.personUpdateProperties = exports.personCreateProperties = exports.personGet = exports.personUpdate = exports.personCreate = void 0;
|
|
3
|
+
exports.personSearchProperties = exports.personSearch = exports.personGetProperties = exports.personUpdateProperties = exports.personCreateProperties = exports.personGet = exports.personUpdate = exports.personCreate = void 0;
|
|
4
4
|
var create_operation_1 = require("./create.operation");
|
|
5
5
|
Object.defineProperty(exports, "personCreate", { enumerable: true, get: function () { return create_operation_1.personCreate; } });
|
|
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, "personUpdateProperties", { enumerable: true, get: function () { return update_properties_1.personUpdateProperties; } });
|
|
14
14
|
var get_properties_1 = require("./get.properties");
|
|
15
15
|
Object.defineProperty(exports, "personGetProperties", { enumerable: true, get: function () { return get_properties_1.personGetProperties; } });
|
|
16
|
+
var search_operation_1 = require("./search.operation");
|
|
17
|
+
Object.defineProperty(exports, "personSearch", { enumerable: true, get: function () { return search_operation_1.personSearch; } });
|
|
18
|
+
var search_properties_1 = require("./search.properties");
|
|
19
|
+
Object.defineProperty(exports, "personSearchProperties", { enumerable: true, get: function () { return search_properties_1.personSearchProperties; } });
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.personSearch = personSearch;
|
|
4
|
+
const http_1 = require("../../lib/http");
|
|
5
|
+
async function personSearch(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 (only fixed 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/PersonSearch',
|
|
80
|
+
body,
|
|
81
|
+
});
|
|
82
|
+
const out = ((_g = resp === null || resp === void 0 ? void 0 : resp.Response) !== null && _g !== void 0 ? _g : resp);
|
|
83
|
+
// returnData.push({ json: out });
|
|
84
|
+
returnData.push({ json: { search_respons: out, criteria: body } });
|
|
85
|
+
return returnData;
|
|
86
|
+
}
|