n8n-nodes-didar-crm 0.0.18 → 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/nodes/DidarCrm.node.js +12 -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/package.json +1 -1
|
@@ -112,6 +112,7 @@ class DidarCrm {
|
|
|
112
112
|
{ name: 'Create', value: 'create', action: 'Create a person' },
|
|
113
113
|
{ name: 'Update', value: 'update', action: 'Update a person by Id' },
|
|
114
114
|
{ name: 'Get', value: 'get', action: 'Get a person by Id' },
|
|
115
|
+
{ name: 'Search', value: 'search', action: 'Search persons' }
|
|
115
116
|
],
|
|
116
117
|
default: 'create',
|
|
117
118
|
description: 'Select the action to perform on the selected resource.',
|
|
@@ -125,6 +126,7 @@ class DidarCrm {
|
|
|
125
126
|
{ name: 'Create', value: 'create', action: 'Create a company' },
|
|
126
127
|
{ name: 'Update', value: 'update', action: 'Update a company by Id' },
|
|
127
128
|
{ name: 'Get', value: 'get', action: 'Get a company by Id' },
|
|
129
|
+
{ name: 'Search', value: 'search', action: 'Search companies' }
|
|
128
130
|
],
|
|
129
131
|
default: 'create',
|
|
130
132
|
description: 'Select the action to perform on the selected resource.',
|
|
@@ -187,10 +189,12 @@ class DidarCrm {
|
|
|
187
189
|
...person_1.personCreateProperties,
|
|
188
190
|
...person_1.personUpdateProperties,
|
|
189
191
|
...person_1.personGetProperties,
|
|
192
|
+
...person_1.personSearchProperties,
|
|
190
193
|
// Company properties (imported)
|
|
191
194
|
...company_1.companyCreateProperties,
|
|
192
195
|
...company_1.companyUpdateProperties,
|
|
193
196
|
...company_1.companyGetProperties,
|
|
197
|
+
...company_1.companySearchProperties,
|
|
194
198
|
// Activity properties (imported)
|
|
195
199
|
...activity_1.activityCreateProperties,
|
|
196
200
|
...activity_1.activityUpdateProperties,
|
|
@@ -244,6 +248,10 @@ class DidarCrm {
|
|
|
244
248
|
await PersonOps.personGet.call(this, i, returnData);
|
|
245
249
|
continue;
|
|
246
250
|
}
|
|
251
|
+
if (operation === 'search') {
|
|
252
|
+
await PersonOps.personSearch.call(this, i, returnData);
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
247
255
|
}
|
|
248
256
|
if (resource === 'company') {
|
|
249
257
|
if (operation === 'create') {
|
|
@@ -258,6 +266,10 @@ class DidarCrm {
|
|
|
258
266
|
await CompanyOps.companyGet.call(this, i, returnData);
|
|
259
267
|
continue;
|
|
260
268
|
}
|
|
269
|
+
if (operation === 'search') {
|
|
270
|
+
await CompanyOps.companySearch.call(this, i, returnData);
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
261
273
|
}
|
|
262
274
|
if (resource === 'activity') {
|
|
263
275
|
if (operation === 'create') {
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.personSearchProperties = void 0;
|
|
4
|
+
const showForPersonSearch = { show: { resource: ['person'], operation: ['search'] } };
|
|
5
|
+
exports.personSearchProperties = [
|
|
6
|
+
// ===== Main fields (ordered) =====
|
|
7
|
+
{
|
|
8
|
+
displayName: 'Keywords',
|
|
9
|
+
name: 'Keywords',
|
|
10
|
+
type: 'string',
|
|
11
|
+
default: '',
|
|
12
|
+
required: false,
|
|
13
|
+
displayOptions: showForPersonSearch,
|
|
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: showForPersonSearch,
|
|
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: { ...showForPersonSearch.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: { ...showForPersonSearch.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: showForPersonSearch,
|
|
54
|
+
options: [
|
|
55
|
+
// Time window (these three همیشه در بدنه میآیند با دیفالتها)
|
|
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 – با Not set)
|
|
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
|
+
];
|