n8n-nodes-didar-crm 0.0.19 → 0.0.21
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/README.md +38 -12
- 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/deal/_shared.fields.js +8 -0
- package/dist/nodes/deal/create.operation.js +44 -1
- package/dist/nodes/deal/update.operation.js +41 -1
- 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/didaryab-search.operation.d.ts +2 -0
- package/dist/nodes/supplementary/didaryab-search.operation.js +27 -0
- package/dist/nodes/supplementary/didaryab-search.properties.d.ts +2 -0
- package/dist/nodes/supplementary/didaryab-search.properties.js +32 -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 +6 -0
- package/dist/nodes/supplementary/index.js +16 -0
- package/dist/nodes/supplementary/popup-callerid.operation.d.ts +2 -0
- package/dist/nodes/supplementary/popup-callerid.operation.js +40 -0
- package/dist/nodes/supplementary/popup-callerid.properties.d.ts +2 -0
- package/dist/nodes/supplementary/popup-callerid.properties.js +34 -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
|
+
];
|
|
@@ -186,6 +186,14 @@ const additionalFields = (op) => ({
|
|
|
186
186
|
description: 'Visibility setting.',
|
|
187
187
|
},
|
|
188
188
|
{ displayName: 'Custom Fields (JSON)', name: 'Fields', type: 'json', default: '', placeholder: '{ "Field_8783_12_4": 12 }', description: 'JSON object of custom fields.' },
|
|
189
|
+
{
|
|
190
|
+
displayName: 'Deal Items (JSON)',
|
|
191
|
+
name: 'DealItems',
|
|
192
|
+
type: 'string',
|
|
193
|
+
default: '',
|
|
194
|
+
placeholder: `[{"ProductId":"...","Quantity":"1","UnitPrice":"1000","Price":"1000","Discount":"0","Description":"...","VariantId":"..."}]`,
|
|
195
|
+
description: 'JSON array of deal items, or an expression that resolves to an array. Also accepts strings like [Array: [...]].',
|
|
196
|
+
},
|
|
189
197
|
],
|
|
190
198
|
});
|
|
191
199
|
exports.additionalFields = additionalFields;
|
|
@@ -2,6 +2,43 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dealCreate = dealCreate;
|
|
4
4
|
const http_1 = require("../../lib/http");
|
|
5
|
+
const parseJsonArrayFlexible = (val, fieldLabel = 'DealItems') => {
|
|
6
|
+
if (val == null || val === '')
|
|
7
|
+
return [];
|
|
8
|
+
if (Array.isArray(val))
|
|
9
|
+
return val;
|
|
10
|
+
if (typeof val === 'string') {
|
|
11
|
+
const s = val.trim();
|
|
12
|
+
if (!s)
|
|
13
|
+
return [];
|
|
14
|
+
// پشتیبانی از برچسب n8n: [Array: [...]]
|
|
15
|
+
const m = s.match(/^\s*\[Array:\s*(\[[\s\S]*\])\s*\]\s*$/i);
|
|
16
|
+
if (m) {
|
|
17
|
+
try {
|
|
18
|
+
return JSON.parse(m[1]);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
throw new Error(`Invalid JSON in ${fieldLabel}.`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// تلاش برای JSON.parse عادی (آرایه یا آبجکت)
|
|
25
|
+
try {
|
|
26
|
+
const parsed = JSON.parse(s);
|
|
27
|
+
if (Array.isArray(parsed))
|
|
28
|
+
return parsed;
|
|
29
|
+
if (parsed && typeof parsed === 'object')
|
|
30
|
+
return [parsed];
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
throw new Error(`Invalid JSON in ${fieldLabel}.`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// اگر آبجکت تکی بود، تبدیل به آرایه
|
|
38
|
+
if (typeof val === 'object')
|
|
39
|
+
return [val];
|
|
40
|
+
return [];
|
|
41
|
+
};
|
|
5
42
|
async function dealCreate(i, returnData) {
|
|
6
43
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
7
44
|
// --- Required composed: Owner / Pipeline / Stage ---
|
|
@@ -47,6 +84,8 @@ async function dealCreate(i, returnData) {
|
|
|
47
84
|
const creatorId = (_g = add.CreatorId) !== null && _g !== void 0 ? _g : ownerId;
|
|
48
85
|
const price = (_h = add.Price) !== null && _h !== void 0 ? _h : '0';
|
|
49
86
|
const visibilityType = (_j = add.VisibilityType) !== null && _j !== void 0 ? _j : '1';
|
|
87
|
+
const dealItemsRaw = add.DealItems;
|
|
88
|
+
const dealItemsArr = parseJsonArrayFlexible(dealItemsRaw, 'DealItems');
|
|
50
89
|
// Custom fields
|
|
51
90
|
let fields;
|
|
52
91
|
if (typeof add.Fields === 'string' && add.Fields.trim()) {
|
|
@@ -80,10 +119,14 @@ async function dealCreate(i, returnData) {
|
|
|
80
119
|
};
|
|
81
120
|
if (fields)
|
|
82
121
|
bodyDeal['Fields'] = fields;
|
|
122
|
+
const body = { Deal: bodyDeal };
|
|
123
|
+
if (dealItemsArr.length) {
|
|
124
|
+
body['DealItems'] = dealItemsArr;
|
|
125
|
+
}
|
|
83
126
|
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
84
127
|
method: 'POST',
|
|
85
128
|
path: '/api/deal/save',
|
|
86
|
-
body
|
|
129
|
+
body,
|
|
87
130
|
});
|
|
88
131
|
returnData.push({ json: resp });
|
|
89
132
|
}
|
|
@@ -2,6 +2,40 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.dealUpdate = dealUpdate;
|
|
4
4
|
const http_1 = require("../../lib/http");
|
|
5
|
+
const parseJsonArrayFlexible = (val, fieldLabel = 'DealItems') => {
|
|
6
|
+
if (val == null || val === '')
|
|
7
|
+
return [];
|
|
8
|
+
if (Array.isArray(val))
|
|
9
|
+
return val;
|
|
10
|
+
if (typeof val === 'string') {
|
|
11
|
+
const s = val.trim();
|
|
12
|
+
if (!s)
|
|
13
|
+
return [];
|
|
14
|
+
const m = s.match(/^\s*\[Array:\s*(\[[\s\S]*\])\s*\]\s*$/i);
|
|
15
|
+
if (m) {
|
|
16
|
+
try {
|
|
17
|
+
return JSON.parse(m[1]);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
throw new Error(`Invalid JSON in ${fieldLabel}.`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const parsed = JSON.parse(s);
|
|
25
|
+
if (Array.isArray(parsed))
|
|
26
|
+
return parsed;
|
|
27
|
+
if (parsed && typeof parsed === 'object')
|
|
28
|
+
return [parsed];
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
throw new Error(`Invalid JSON in ${fieldLabel}.`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (typeof val === 'object')
|
|
36
|
+
return [val];
|
|
37
|
+
return [];
|
|
38
|
+
};
|
|
5
39
|
async function dealUpdate(i, returnData) {
|
|
6
40
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
7
41
|
// ---- Required Id ----
|
|
@@ -56,6 +90,8 @@ async function dealUpdate(i, returnData) {
|
|
|
56
90
|
const creatorId = (_g = add.CreatorId) !== null && _g !== void 0 ? _g : ownerId; // همرفتار با create
|
|
57
91
|
const price = (_h = add.Price) !== null && _h !== void 0 ? _h : '0';
|
|
58
92
|
const visibilityType = (_j = add.VisibilityType) !== null && _j !== void 0 ? _j : 'Owner'; // دراپداون متنی
|
|
93
|
+
const dealItemsRaw = add.DealItems;
|
|
94
|
+
const dealItemsArr = parseJsonArrayFlexible(dealItemsRaw, 'DealItems');
|
|
59
95
|
// Custom fields
|
|
60
96
|
let fields;
|
|
61
97
|
if (typeof add.Fields === 'string' && add.Fields.trim()) {
|
|
@@ -91,11 +127,15 @@ async function dealUpdate(i, returnData) {
|
|
|
91
127
|
};
|
|
92
128
|
if (fields)
|
|
93
129
|
bodyDeal['Fields'] = fields;
|
|
130
|
+
const body = { Deal: bodyDeal };
|
|
131
|
+
if (dealItemsArr.length) {
|
|
132
|
+
body['DealItems'] = dealItemsArr;
|
|
133
|
+
}
|
|
94
134
|
// ---- Request ----
|
|
95
135
|
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
96
136
|
method: 'POST',
|
|
97
137
|
path: '/api/deal/save',
|
|
98
|
-
body
|
|
138
|
+
body,
|
|
99
139
|
});
|
|
100
140
|
returnData.push({ json: resp });
|
|
101
141
|
}
|
|
@@ -4,3 +4,5 @@ export { productUpdate } from './update.operation';
|
|
|
4
4
|
export { productUpdateProperties } from './update.properties';
|
|
5
5
|
export { productGetByCodes } from './getByCodes.operation';
|
|
6
6
|
export { productGetByCodesProperties } from './getByCodes.properties';
|
|
7
|
+
export { productSearch } from './search.operation';
|
|
8
|
+
export { productSearchProperties } from './search.properties';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.productGetByCodesProperties = exports.productGetByCodes = exports.productUpdateProperties = exports.productUpdate = exports.productCreateProperties = exports.productCreate = void 0;
|
|
3
|
+
exports.productSearchProperties = exports.productSearch = exports.productGetByCodesProperties = exports.productGetByCodes = exports.productUpdateProperties = exports.productUpdate = exports.productCreateProperties = exports.productCreate = void 0;
|
|
4
4
|
// nodes/product/index.ts
|
|
5
5
|
var create_operation_1 = require("./create.operation");
|
|
6
6
|
Object.defineProperty(exports, "productCreate", { enumerable: true, get: function () { return create_operation_1.productCreate; } });
|
|
@@ -14,3 +14,7 @@ var getByCodes_operation_1 = require("./getByCodes.operation");
|
|
|
14
14
|
Object.defineProperty(exports, "productGetByCodes", { enumerable: true, get: function () { return getByCodes_operation_1.productGetByCodes; } });
|
|
15
15
|
var getByCodes_properties_1 = require("./getByCodes.properties");
|
|
16
16
|
Object.defineProperty(exports, "productGetByCodesProperties", { enumerable: true, get: function () { return getByCodes_properties_1.productGetByCodesProperties; } });
|
|
17
|
+
var search_operation_1 = require("./search.operation");
|
|
18
|
+
Object.defineProperty(exports, "productSearch", { enumerable: true, get: function () { return search_operation_1.productSearch; } });
|
|
19
|
+
var search_properties_1 = require("./search.properties");
|
|
20
|
+
Object.defineProperty(exports, "productSearchProperties", { enumerable: true, get: function () { return search_properties_1.productSearchProperties; } });
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.productSearch = productSearch;
|
|
4
|
+
const http_1 = require("../../lib/http");
|
|
5
|
+
async function productSearch(i, returnData) {
|
|
6
|
+
var _a;
|
|
7
|
+
// پارامترها
|
|
8
|
+
const keywords = this.getNodeParameter('Keywords', i, '').trim();
|
|
9
|
+
const limit = this.getNodeParameter('Limit', i, 10);
|
|
10
|
+
const from = 0;
|
|
11
|
+
// بدنه
|
|
12
|
+
const criteria = {};
|
|
13
|
+
if (keywords)
|
|
14
|
+
criteria['Keywords'] = keywords;
|
|
15
|
+
const body = {
|
|
16
|
+
Criteria: criteria,
|
|
17
|
+
From: from,
|
|
18
|
+
Limit: limit,
|
|
19
|
+
};
|
|
20
|
+
// درخواست
|
|
21
|
+
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
22
|
+
method: 'POST',
|
|
23
|
+
path: '/api/product/search',
|
|
24
|
+
body,
|
|
25
|
+
});
|
|
26
|
+
const out = ((_a = resp === null || resp === void 0 ? void 0 : resp.Response) !== null && _a !== void 0 ? _a : resp);
|
|
27
|
+
// خروجی
|
|
28
|
+
returnData.push({ json: { search_response: out, criteria: body } });
|
|
29
|
+
return returnData;
|
|
30
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.productSearchProperties = void 0;
|
|
4
|
+
const showForProductSearch = { show: { resource: ['product'], operation: ['search'] } };
|
|
5
|
+
exports.productSearchProperties = [
|
|
6
|
+
{
|
|
7
|
+
displayName: 'Keywords',
|
|
8
|
+
name: 'Keywords',
|
|
9
|
+
type: 'string',
|
|
10
|
+
default: '',
|
|
11
|
+
displayOptions: showForProductSearch,
|
|
12
|
+
description: 'Search term to match product fields.',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
displayName: 'Limit',
|
|
16
|
+
name: 'Limit',
|
|
17
|
+
type: 'number',
|
|
18
|
+
typeOptions: { minValue: 1, maxValue: 100 },
|
|
19
|
+
default: 10,
|
|
20
|
+
displayOptions: showForProductSearch,
|
|
21
|
+
description: 'Maximum number of results to return.',
|
|
22
|
+
},
|
|
23
|
+
];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.didaryabSearch = didaryabSearch;
|
|
4
|
+
const http_1 = require("../../lib/http");
|
|
5
|
+
async function didaryabSearch(i, returnData) {
|
|
6
|
+
var _a;
|
|
7
|
+
const keyword = this.getNodeParameter('Keyword', i, '').trim();
|
|
8
|
+
const types = this.getNodeParameter('Types', i, []);
|
|
9
|
+
// normalize types to string[]
|
|
10
|
+
const typesArr = Array.isArray(types) ? types : (types ? [types] : []);
|
|
11
|
+
if (!keyword)
|
|
12
|
+
throw new Error('Keyword is required.');
|
|
13
|
+
if (!typesArr.length)
|
|
14
|
+
throw new Error('At least one type must be selected.');
|
|
15
|
+
const body = {
|
|
16
|
+
Keyword: keyword,
|
|
17
|
+
Types: typesArr,
|
|
18
|
+
};
|
|
19
|
+
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
20
|
+
method: 'POST',
|
|
21
|
+
path: '/api/search/search',
|
|
22
|
+
body,
|
|
23
|
+
});
|
|
24
|
+
const out = ((_a = resp === null || resp === void 0 ? void 0 : resp.Response) !== null && _a !== void 0 ? _a : resp);
|
|
25
|
+
returnData.push({ json: { search_response: out, criteria: body } });
|
|
26
|
+
return returnData;
|
|
27
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.didaryabSearchProperties = void 0;
|
|
4
|
+
const showForDidaryab = { show: { resource: ['supplementary'], operation: ['didaryabSearch'] } };
|
|
5
|
+
exports.didaryabSearchProperties = [
|
|
6
|
+
{
|
|
7
|
+
displayName: 'Keyword',
|
|
8
|
+
name: 'Keyword',
|
|
9
|
+
type: 'string',
|
|
10
|
+
default: '',
|
|
11
|
+
required: true,
|
|
12
|
+
displayOptions: showForDidaryab,
|
|
13
|
+
description: 'Search term.',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
displayName: 'Types',
|
|
17
|
+
name: 'Types',
|
|
18
|
+
type: 'multiOptions',
|
|
19
|
+
options: [
|
|
20
|
+
{ name: 'Contact', value: 'contact' },
|
|
21
|
+
{ name: 'Company', value: 'company' },
|
|
22
|
+
{ name: 'Deal', value: 'deal' },
|
|
23
|
+
{ name: 'Case', value: 'case' },
|
|
24
|
+
{ name: 'Attachment', value: 'attachment' },
|
|
25
|
+
],
|
|
26
|
+
// default: all checked
|
|
27
|
+
default: ['contact', 'company', 'deal', 'case', 'attachment'],
|
|
28
|
+
required: true,
|
|
29
|
+
displayOptions: showForDidaryab,
|
|
30
|
+
description: 'Select one or more entity types to search.',
|
|
31
|
+
},
|
|
32
|
+
];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBaseInfo = getBaseInfo;
|
|
4
|
+
const http_1 = require("../../lib/http");
|
|
5
|
+
async function getBaseInfo(i, returnData) {
|
|
6
|
+
var _a;
|
|
7
|
+
const dataset = this.getNodeParameter('dataset', i);
|
|
8
|
+
const map = {
|
|
9
|
+
pipelines: { path: '/api/pipeline/list/0', method: 'POST' },
|
|
10
|
+
activityTypes: { path: '/api/activity/GetActivityType', method: 'POST' },
|
|
11
|
+
customFields: { path: '/api/customfield/GetCustomfieldList', method: 'POST' },
|
|
12
|
+
productCategories: { path: '/api/product/categories', method: 'POST' },
|
|
13
|
+
};
|
|
14
|
+
const conf = map[dataset];
|
|
15
|
+
if (!conf)
|
|
16
|
+
throw new Error('Unsupported dataset.');
|
|
17
|
+
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
18
|
+
method: conf.method || 'POST',
|
|
19
|
+
path: conf.path,
|
|
20
|
+
body: {}, // these endpoints are POST even if body is empty
|
|
21
|
+
});
|
|
22
|
+
// Always return full payload (no limiting)
|
|
23
|
+
const data = ((_a = resp === null || resp === void 0 ? void 0 : resp.Response) !== null && _a !== void 0 ? _a : resp);
|
|
24
|
+
returnData.push({ json: { dataset, data } });
|
|
25
|
+
return returnData;
|
|
26
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBaseInfoProperties = void 0;
|
|
4
|
+
const showForGetBaseInfo = { show: { resource: ['supplementary'], operation: ['getBaseInfo'] } };
|
|
5
|
+
exports.getBaseInfoProperties = [
|
|
6
|
+
{
|
|
7
|
+
displayName: 'Dataset',
|
|
8
|
+
name: 'dataset',
|
|
9
|
+
type: 'options',
|
|
10
|
+
options: [
|
|
11
|
+
{ name: 'Pipelines', value: 'pipelines' },
|
|
12
|
+
{ name: 'Activity Types', value: 'activityTypes' },
|
|
13
|
+
{ name: 'Custom Fields List', value: 'customFields' },
|
|
14
|
+
{ name: 'Product Categories', value: 'productCategories' },
|
|
15
|
+
],
|
|
16
|
+
default: 'pipelines',
|
|
17
|
+
displayOptions: showForGetBaseInfo,
|
|
18
|
+
description: 'Choose which base information to fetch.',
|
|
19
|
+
},
|
|
20
|
+
];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { getBaseInfo } from './get-base-info.operation';
|
|
2
|
+
export { getBaseInfoProperties } from './get-base-info.properties';
|
|
3
|
+
export { didaryabSearch } from './didaryab-search.operation';
|
|
4
|
+
export { didaryabSearchProperties } from './didaryab-search.properties';
|
|
5
|
+
export { popupCallerId } from './popup-callerid.operation';
|
|
6
|
+
export { popupCallerIdProperties } from './popup-callerid.properties';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.popupCallerIdProperties = exports.popupCallerId = exports.didaryabSearchProperties = exports.didaryabSearch = exports.getBaseInfoProperties = exports.getBaseInfo = void 0;
|
|
4
|
+
// nodes/supplementary/index.ts
|
|
5
|
+
var get_base_info_operation_1 = require("./get-base-info.operation");
|
|
6
|
+
Object.defineProperty(exports, "getBaseInfo", { enumerable: true, get: function () { return get_base_info_operation_1.getBaseInfo; } });
|
|
7
|
+
var get_base_info_properties_1 = require("./get-base-info.properties");
|
|
8
|
+
Object.defineProperty(exports, "getBaseInfoProperties", { enumerable: true, get: function () { return get_base_info_properties_1.getBaseInfoProperties; } });
|
|
9
|
+
var didaryab_search_operation_1 = require("./didaryab-search.operation");
|
|
10
|
+
Object.defineProperty(exports, "didaryabSearch", { enumerable: true, get: function () { return didaryab_search_operation_1.didaryabSearch; } });
|
|
11
|
+
var didaryab_search_properties_1 = require("./didaryab-search.properties");
|
|
12
|
+
Object.defineProperty(exports, "didaryabSearchProperties", { enumerable: true, get: function () { return didaryab_search_properties_1.didaryabSearchProperties; } });
|
|
13
|
+
var popup_callerid_operation_1 = require("./popup-callerid.operation");
|
|
14
|
+
Object.defineProperty(exports, "popupCallerId", { enumerable: true, get: function () { return popup_callerid_operation_1.popupCallerId; } });
|
|
15
|
+
var popup_callerid_properties_1 = require("./popup-callerid.properties");
|
|
16
|
+
Object.defineProperty(exports, "popupCallerIdProperties", { enumerable: true, get: function () { return popup_callerid_properties_1.popupCallerIdProperties; } });
|