n8n-nodes-didar-crm 0.0.16 → 0.0.18

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.
@@ -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) ? v : (typeof v === 'string' && v ? [v] : []);
30
- const userIds = usersMode === 'select' ? toArray(userIdsSelect) : toArray(userIdsManual);
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
- { displayName: 'Visibility Type', name: 'VisibilityType', type: 'options',
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 { 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';
@@ -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,2 @@
1
+ import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
2
+ export declare function dealSearch(this: IExecuteFunctions, i: number, returnData: INodeExecutionData[]): Promise<INodeExecutionData[]>;
@@ -0,0 +1,199 @@
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: { a: out, b: body } });
198
+ return returnData;
199
+ }
@@ -0,0 +1,2 @@
1
+ import type { INodeProperties } from 'n8n-workflow';
2
+ export declare const dealSearchProperties: INodeProperties[];
@@ -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
+ ];