n8n-nodes-didar-crm 0.0.28 → 0.0.30

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.
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.caseSearch = caseSearch;
4
4
  const http_1 = require("../../lib/http");
5
5
  async function caseSearch(i, returnData) {
6
- var _a, _b, _c;
6
+ var _a, _b, _c, _d;
7
7
  // Helpers
8
8
  const uniq = (arr) => Array.from(new Set(arr.map(s => s.trim()).filter(Boolean)));
9
9
  const parseIdList = (input) => {
@@ -126,6 +126,7 @@ async function caseSearch(i, returnData) {
126
126
  const searchFromTime = (_a = add.SearchFromTime) !== null && _a !== void 0 ? _a : '1000-01-01T00:00:00.000Z';
127
127
  const searchToTime = (_b = add.SearchToTime) !== null && _b !== void 0 ? _b : '9999-12-01T00:00:00.000Z';
128
128
  const customFields = parseJsonFlexible(add.CustomFields);
129
+ const dealId = (_c = add.DealId) !== null && _c !== void 0 ? _c : '00000000-0000-0000-0000-000000000000';
129
130
  const limit = typeof add.Limit === 'number' ? add.Limit : 10;
130
131
  const from = 0;
131
132
  // Build Criteria with only provided filters
@@ -138,6 +139,9 @@ async function caseSearch(i, returnData) {
138
139
  criteria['Keywords'] = keywords;
139
140
  if (ownerId)
140
141
  criteria['OwnerId'] = ownerId;
142
+ if (dealId && dealId !== '00000000-0000-0000-0000-000000000000' && dealId.trim()) {
143
+ criteria['DealId'] = dealId.trim();
144
+ }
141
145
  if (contactIds.length)
142
146
  criteria['ContactIds'] = contactIds;
143
147
  if (customFields === null || customFields === void 0 ? void 0 : customFields.length)
@@ -149,7 +153,7 @@ async function caseSearch(i, returnData) {
149
153
  path: '/api/Case/search',
150
154
  body,
151
155
  });
152
- const out = ((_c = resp === null || resp === void 0 ? void 0 : resp.Response) !== null && _c !== void 0 ? _c : resp);
156
+ const out = ((_d = resp === null || resp === void 0 ? void 0 : resp.Response) !== null && _d !== void 0 ? _d : resp);
153
157
  // Return with criteria for debugging
154
158
  returnData.push({ json: { search_respons: out, criteria: body } });
155
159
  return returnData;
@@ -81,6 +81,13 @@ exports.caseSearchProperties = [
81
81
  default: '[]',
82
82
  description: 'JSON array of custom field filters (optional).',
83
83
  },
84
+ {
85
+ displayName: 'Deal ID',
86
+ name: 'DealId',
87
+ type: 'string',
88
+ default: '00000000-0000-0000-0000-000000000000',
89
+ description: 'Deal ID to filter cases (optional). Default is empty GUID.',
90
+ },
84
91
  {
85
92
  displayName: 'Limit',
86
93
  name: 'Limit',
@@ -2,6 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.dealCreate = dealCreate;
4
4
  const http_1 = require("../../lib/http");
5
+ // تابع اعتبارسنجی GUID
6
+ const validateGuid = (value, fieldName) => {
7
+ if (!value)
8
+ return; // اگر خالی باشد، اجازه می‌دهیم (اعتبارسنجی وجود در جای دیگر انجام می‌شود)
9
+ const guidRegex = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
10
+ if (!guidRegex.test(value.trim())) {
11
+ throw new Error(`${fieldName} must be a valid GUID format (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).`);
12
+ }
13
+ };
5
14
  const parseJsonArrayFlexible = (val, fieldLabel = 'DealItems') => {
6
15
  if (val == null || val === '')
7
16
  return [];
@@ -143,9 +152,11 @@ async function dealCreate(i, returnData) {
143
152
  const personId = this.getNodeParameter('PersonId', i, '');
144
153
  if (!personId)
145
154
  throw new Error('PersonId is required.');
155
+ validateGuid(personId, 'PersonId');
146
156
  const companyId = this.getNodeParameter('CompanyId', i, '');
147
157
  if (!companyId)
148
158
  throw new Error('CompanyId is required.');
159
+ validateGuid(companyId, 'CompanyId');
149
160
  const status = this.getNodeParameter('Status', i, '');
150
161
  if (!status)
151
162
  throw new Error('Status is required.');
@@ -2,6 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.dealUpdate = dealUpdate;
4
4
  const http_1 = require("../../lib/http");
5
+ // تابع اعتبارسنجی GUID
6
+ const validateGuid = (value, fieldName) => {
7
+ if (!value)
8
+ return; // اگر خالی باشد، اجازه می‌دهیم (اعتبارسنجی وجود در جای دیگر انجام می‌شود)
9
+ const guidRegex = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
10
+ if (!guidRegex.test(value.trim())) {
11
+ throw new Error(`${fieldName} must be a valid GUID format (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).`);
12
+ }
13
+ };
5
14
  const parseJsonArrayFlexible = (val, fieldLabel = 'DealItems') => {
6
15
  if (val == null || val === '')
7
16
  return [];
@@ -149,9 +158,11 @@ async function dealUpdate(i, returnData) {
149
158
  const personId = this.getNodeParameter('PersonId', i, '');
150
159
  if (!personId)
151
160
  throw new Error('PersonId is required.');
161
+ validateGuid(personId, 'PersonId');
152
162
  const companyId = this.getNodeParameter('CompanyId', i, '');
153
163
  if (!companyId)
154
164
  throw new Error('CompanyId is required.');
165
+ validateGuid(companyId, 'CompanyId');
155
166
  const status = this.getNodeParameter('Status', i, '');
156
167
  if (!status)
157
168
  throw new Error('Status is required.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-didar-crm",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "description": "Didar CRM nodes for n8n (Trigger + Deal.create)",
5
5
  "author": "You",
6
6
  "license": "MIT",