n8n-nodes-didar-crm 0.0.9 → 0.0.11
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/lib/loadOptions.d.ts +1 -0
- package/dist/lib/loadOptions.js +25 -0
- package/dist/nodes/DidarCrm.node.d.ts +1 -0
- package/dist/nodes/DidarCrm.node.js +29 -0
- package/dist/nodes/activity/create.operation.d.ts +2 -0
- package/dist/nodes/activity/create.operation.js +90 -0
- package/dist/nodes/activity/create.properties.d.ts +2 -0
- package/dist/nodes/activity/create.properties.js +162 -0
- package/dist/nodes/activity/index.d.ts +4 -0
- package/dist/nodes/activity/index.js +11 -0
- package/dist/nodes/activity/update.operation.d.ts +2 -0
- package/dist/nodes/activity/update.operation.js +93 -0
- package/dist/nodes/activity/update.properties.d.ts +2 -0
- package/dist/nodes/activity/update.properties.js +173 -0
- package/package.json +9 -3
|
@@ -2,3 +2,4 @@ import { ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
|
|
|
2
2
|
export declare function getPipelines(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
3
3
|
export declare function getStagesForPipeline(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
4
4
|
export declare function getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
5
|
+
export declare function getActivityTypes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
package/dist/lib/loadOptions.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getPipelines = getPipelines;
|
|
4
4
|
exports.getStagesForPipeline = getStagesForPipeline;
|
|
5
5
|
exports.getUsers = getUsers;
|
|
6
|
+
exports.getActivityTypes = getActivityTypes;
|
|
6
7
|
async function getPipelines() {
|
|
7
8
|
var _a;
|
|
8
9
|
const creds = await this.getCredentials('didarApi');
|
|
@@ -74,3 +75,27 @@ async function getUsers() {
|
|
|
74
75
|
value: u.UserId, // اگر OwnerId باید از UserId بیاد، این را به u.UserId تغییر بده
|
|
75
76
|
}));
|
|
76
77
|
}
|
|
78
|
+
async function getActivityTypes() {
|
|
79
|
+
var _a;
|
|
80
|
+
const creds = await this.getCredentials('didarApi');
|
|
81
|
+
const baseUrl = creds.baseUrl;
|
|
82
|
+
const apiKey = creds.apiKey;
|
|
83
|
+
const useCookie = creds.useCookie;
|
|
84
|
+
const cookie = creds.cookie;
|
|
85
|
+
const urlBase = (baseUrl || '').replace(/\/+$/, '');
|
|
86
|
+
const url = `${urlBase}/api/activity/GetActivityType?apikey=${encodeURIComponent(apiKey)}`;
|
|
87
|
+
const options = {
|
|
88
|
+
method: 'POST',
|
|
89
|
+
url,
|
|
90
|
+
json: true,
|
|
91
|
+
headers: { 'Content-Type': 'application/json' },
|
|
92
|
+
body: {},
|
|
93
|
+
};
|
|
94
|
+
if (useCookie && cookie)
|
|
95
|
+
options.headers.Cookie = cookie;
|
|
96
|
+
const resp = await this.helpers.httpRequest(options);
|
|
97
|
+
const list = ((_a = resp === null || resp === void 0 ? void 0 : resp.Response) !== null && _a !== void 0 ? _a : []);
|
|
98
|
+
return list
|
|
99
|
+
.filter((x) => (x === null || x === void 0 ? void 0 : x.Id) && (x === null || x === void 0 ? void 0 : x.Title))
|
|
100
|
+
.map((x) => ({ name: x.Title, value: x.Id }));
|
|
101
|
+
}
|
|
@@ -5,6 +5,7 @@ export declare class DidarCrm implements INodeType {
|
|
|
5
5
|
getPipelines: (this: ILoadOptionsFunctions) => Promise<INodePropertyOptions[]>;
|
|
6
6
|
getStagesForPipeline: (this: ILoadOptionsFunctions) => Promise<INodePropertyOptions[]>;
|
|
7
7
|
getUsers: (this: ILoadOptionsFunctions) => Promise<INodePropertyOptions[]>;
|
|
8
|
+
getActivityTypes: (this: ILoadOptionsFunctions) => Promise<INodePropertyOptions[]>;
|
|
8
9
|
};
|
|
9
10
|
};
|
|
10
11
|
description: INodeTypeDescription;
|
|
@@ -41,6 +41,8 @@ const PersonOps = __importStar(require("./person"));
|
|
|
41
41
|
const person_1 = require("./person");
|
|
42
42
|
const CompanyOps = __importStar(require("./company"));
|
|
43
43
|
const company_1 = require("./company");
|
|
44
|
+
const ActivityOps = __importStar(require("./activity"));
|
|
45
|
+
const activity_1 = require("./activity");
|
|
44
46
|
class DidarCrm {
|
|
45
47
|
constructor() {
|
|
46
48
|
this.methods = {
|
|
@@ -48,6 +50,7 @@ class DidarCrm {
|
|
|
48
50
|
getPipelines: Load.getPipelines,
|
|
49
51
|
getStagesForPipeline: Load.getStagesForPipeline,
|
|
50
52
|
getUsers: Load.getUsers,
|
|
53
|
+
getActivityTypes: Load.getActivityTypes,
|
|
51
54
|
},
|
|
52
55
|
};
|
|
53
56
|
this.description = {
|
|
@@ -71,6 +74,7 @@ class DidarCrm {
|
|
|
71
74
|
{ name: 'Deal', value: 'deal' },
|
|
72
75
|
{ name: 'Person', value: 'person' },
|
|
73
76
|
{ name: 'Company', value: 'company' },
|
|
77
|
+
{ name: 'Activity', value: 'activity' },
|
|
74
78
|
],
|
|
75
79
|
default: 'deal',
|
|
76
80
|
description: 'Choose the entity to act on.',
|
|
@@ -114,6 +118,18 @@ class DidarCrm {
|
|
|
114
118
|
default: 'create',
|
|
115
119
|
description: 'Select the action to perform on the selected resource.',
|
|
116
120
|
},
|
|
121
|
+
{
|
|
122
|
+
displayName: 'Operation',
|
|
123
|
+
name: 'operation',
|
|
124
|
+
type: 'options',
|
|
125
|
+
displayOptions: { show: { resource: ['activity'] } },
|
|
126
|
+
options: [
|
|
127
|
+
{ name: 'Create', value: 'create', action: 'Create an activity' },
|
|
128
|
+
{ name: 'Update', value: 'update', action: 'Update an activity by Id' }, // NEW
|
|
129
|
+
],
|
|
130
|
+
default: 'create',
|
|
131
|
+
description: 'Select the action to perform on the selected resource.',
|
|
132
|
+
},
|
|
117
133
|
// Deal properties (imported)
|
|
118
134
|
...deal_1.dealCreateProperties,
|
|
119
135
|
...deal_1.dealUpdateProperties,
|
|
@@ -126,6 +142,9 @@ class DidarCrm {
|
|
|
126
142
|
...company_1.companyCreateProperties,
|
|
127
143
|
...company_1.companyUpdateProperties,
|
|
128
144
|
...company_1.companyGetProperties,
|
|
145
|
+
// Activity properties (imported)
|
|
146
|
+
...activity_1.activityCreateProperties,
|
|
147
|
+
...activity_1.activityUpdateProperties,
|
|
129
148
|
],
|
|
130
149
|
};
|
|
131
150
|
}
|
|
@@ -177,6 +196,16 @@ class DidarCrm {
|
|
|
177
196
|
continue;
|
|
178
197
|
} // NEW
|
|
179
198
|
}
|
|
199
|
+
if (resource === 'activity') {
|
|
200
|
+
if (operation === 'create') {
|
|
201
|
+
await ActivityOps.activityCreate.call(this, i, returnData);
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
if (operation === 'update') {
|
|
205
|
+
await ActivityOps.activityUpdate.call(this, i, returnData);
|
|
206
|
+
continue;
|
|
207
|
+
} // NEW
|
|
208
|
+
}
|
|
180
209
|
}
|
|
181
210
|
return [returnData];
|
|
182
211
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.activityCreate = activityCreate;
|
|
4
|
+
const http_1 = require("../../lib/http");
|
|
5
|
+
async function activityCreate(i, returnData) {
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
7
|
+
// Required basics
|
|
8
|
+
const title = this.getNodeParameter('Title', i, '');
|
|
9
|
+
if (!title)
|
|
10
|
+
throw new Error('Title is required.');
|
|
11
|
+
// ActivityType: select/manual
|
|
12
|
+
const typeMode = this.getNodeParameter('ActivityTypeMode', i);
|
|
13
|
+
const activityTypeId = typeMode === 'select'
|
|
14
|
+
? this.getNodeParameter('ActivityTypeIdSelect', i, '')
|
|
15
|
+
: this.getNodeParameter('ActivityTypeIdManual', i, '');
|
|
16
|
+
if (!activityTypeId)
|
|
17
|
+
throw new Error('ActivityTypeId is required (select from list or enter manually).');
|
|
18
|
+
const isDone = this.getNodeParameter('IsDone', i, false);
|
|
19
|
+
// Additional fields
|
|
20
|
+
const add = this.getNodeParameter('additionalFields', i, {}) || {};
|
|
21
|
+
// Owner
|
|
22
|
+
let ownerId = '';
|
|
23
|
+
if (add.OwnerMode === 'select')
|
|
24
|
+
ownerId = add.OwnerIdSelect || '';
|
|
25
|
+
else if (add.OwnerMode === 'manual')
|
|
26
|
+
ownerId = add.OwnerIdManual || '';
|
|
27
|
+
// OwnerId اختیاری است مگر شما الزامش کنید؛ اگر لازم شد همینجا ارور دهید.
|
|
28
|
+
const note = (_a = add.Note) !== null && _a !== void 0 ? _a : '';
|
|
29
|
+
const resultNote = (_b = add.ResultNote) !== null && _b !== void 0 ? _b : '';
|
|
30
|
+
const isDeleted = (_c = add.IsDeleted) !== null && _c !== void 0 ? _c : false;
|
|
31
|
+
const isPinned = (_d = add.IsPinned) !== null && _d !== void 0 ? _d : false;
|
|
32
|
+
const dueDate = (_e = add.DueDate) !== null && _e !== void 0 ? _e : '';
|
|
33
|
+
const duration = Number((_f = add.Duration) !== null && _f !== void 0 ? _f : 0);
|
|
34
|
+
const doneDate = (_g = add.DoneDate) !== null && _g !== void 0 ? _g : '';
|
|
35
|
+
const dealId = (_h = add.DealId) !== null && _h !== void 0 ? _h : '00000000-0000-0000-0000-000000000000';
|
|
36
|
+
const caseId = (_j = add.CaseId) !== null && _j !== void 0 ? _j : '00000000-0000-0000-0000-000000000000';
|
|
37
|
+
// ContactIds: string[]
|
|
38
|
+
let contactIds;
|
|
39
|
+
const cids = add.ContactIds;
|
|
40
|
+
if (Array.isArray(cids))
|
|
41
|
+
contactIds = cids.filter(Boolean);
|
|
42
|
+
else if (typeof cids === 'string' && cids)
|
|
43
|
+
contactIds = [cids];
|
|
44
|
+
const creatorId = (_k = add.CreatorId) !== null && _k !== void 0 ? _k : '00000000-0000-0000-0000-000000000000';
|
|
45
|
+
const recurrenceType = (_l = add.RecurrenceType) !== null && _l !== void 0 ? _l : '';
|
|
46
|
+
const recurrenceDataNum = Number((_m = add.RecurrenceData) !== null && _m !== void 0 ? _m : 0);
|
|
47
|
+
const recurrenceEndDate = (_o = add.RecurrenceEndDate) !== null && _o !== void 0 ? _o : '';
|
|
48
|
+
// Build body
|
|
49
|
+
const activity = {
|
|
50
|
+
ActivityTypeId: activityTypeId,
|
|
51
|
+
Title: title,
|
|
52
|
+
IsDone: isDone,
|
|
53
|
+
};
|
|
54
|
+
if (ownerId)
|
|
55
|
+
activity['OwnerId'] = ownerId;
|
|
56
|
+
if (note)
|
|
57
|
+
activity['Note'] = note;
|
|
58
|
+
if (resultNote)
|
|
59
|
+
activity['ResultNote'] = resultNote;
|
|
60
|
+
if (isDeleted)
|
|
61
|
+
activity['IsDeleted'] = true;
|
|
62
|
+
if (isPinned)
|
|
63
|
+
activity['IsPinned'] = true;
|
|
64
|
+
if (dueDate)
|
|
65
|
+
activity['DueDate'] = dueDate;
|
|
66
|
+
if (duration > 0)
|
|
67
|
+
activity['Duration'] = duration;
|
|
68
|
+
if (doneDate)
|
|
69
|
+
activity['DoneDate'] = doneDate;
|
|
70
|
+
if (dealId)
|
|
71
|
+
activity['DealId'] = dealId;
|
|
72
|
+
if (caseId)
|
|
73
|
+
activity['CaseId'] = caseId;
|
|
74
|
+
if (contactIds === null || contactIds === void 0 ? void 0 : contactIds.length)
|
|
75
|
+
activity['ContactIds'] = contactIds;
|
|
76
|
+
if (creatorId)
|
|
77
|
+
activity['CreatorId'] = creatorId;
|
|
78
|
+
if (recurrenceType)
|
|
79
|
+
activity['RecurrenceType'] = recurrenceType;
|
|
80
|
+
if (recurrenceDataNum > 0)
|
|
81
|
+
activity['RecurrenceData'] = recurrenceDataNum;
|
|
82
|
+
if (recurrenceEndDate)
|
|
83
|
+
activity['RecurrenceEndDate'] = recurrenceEndDate;
|
|
84
|
+
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
85
|
+
method: 'POST',
|
|
86
|
+
path: '/api/activity/save',
|
|
87
|
+
body: { Activity: activity },
|
|
88
|
+
});
|
|
89
|
+
returnData.push({ json: resp });
|
|
90
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.activityCreateProperties = void 0;
|
|
4
|
+
const showForActivityCreate = { show: { resource: ['activity'], operation: ['create'] } };
|
|
5
|
+
exports.activityCreateProperties = [
|
|
6
|
+
// ===== MAIN (به ترتیب خواستهشده) =====
|
|
7
|
+
{
|
|
8
|
+
displayName: 'Title',
|
|
9
|
+
name: 'Title',
|
|
10
|
+
type: 'string',
|
|
11
|
+
default: '',
|
|
12
|
+
required: true,
|
|
13
|
+
displayOptions: showForActivityCreate,
|
|
14
|
+
description: 'Activity title (required).',
|
|
15
|
+
},
|
|
16
|
+
// ActivityTypeId: Select / Manual
|
|
17
|
+
{
|
|
18
|
+
displayName: 'Activity Type Input Mode',
|
|
19
|
+
name: 'ActivityTypeMode',
|
|
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: showForActivityCreate,
|
|
27
|
+
description: 'Choose how to set the activity type.',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
displayName: 'Activity Type',
|
|
31
|
+
name: 'ActivityTypeIdSelect',
|
|
32
|
+
type: 'options',
|
|
33
|
+
typeOptions: { loadOptionsMethod: 'getActivityTypes' },
|
|
34
|
+
default: '',
|
|
35
|
+
displayOptions: { show: { ...showForActivityCreate.show, ActivityTypeMode: ['select'] } },
|
|
36
|
+
description: 'Select the activity type (required if select mode).',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
displayName: 'Activity Type ID',
|
|
40
|
+
name: 'ActivityTypeIdManual',
|
|
41
|
+
type: 'string',
|
|
42
|
+
default: '',
|
|
43
|
+
displayOptions: { show: { ...showForActivityCreate.show, ActivityTypeMode: ['manual'] } },
|
|
44
|
+
description: 'Enter activity type ID manually (required if manual mode).',
|
|
45
|
+
},
|
|
46
|
+
// Owner (Select/Manual)
|
|
47
|
+
{
|
|
48
|
+
displayName: 'Owner Input Mode',
|
|
49
|
+
name: 'OwnerMode',
|
|
50
|
+
type: 'options',
|
|
51
|
+
options: [
|
|
52
|
+
{ name: 'Select from list', value: 'select' },
|
|
53
|
+
{ name: 'Enter ID manually', value: 'manual' },
|
|
54
|
+
],
|
|
55
|
+
default: 'select',
|
|
56
|
+
description: 'Choose how to set the owner.',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
displayName: 'Owner',
|
|
60
|
+
name: 'OwnerIdSelect',
|
|
61
|
+
type: 'options',
|
|
62
|
+
typeOptions: { loadOptionsMethod: 'getUsers' },
|
|
63
|
+
default: '',
|
|
64
|
+
displayOptions: { show: { OwnerMode: ['select'] } },
|
|
65
|
+
description: 'Select the owner user (required if select mode).',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
displayName: 'Owner ID',
|
|
69
|
+
name: 'OwnerIdManual',
|
|
70
|
+
type: 'string',
|
|
71
|
+
default: '',
|
|
72
|
+
displayOptions: { show: { OwnerMode: ['manual'] } },
|
|
73
|
+
description: 'Enter owner user ID manually (required if manual mode).',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
displayName: 'Is Done',
|
|
77
|
+
name: 'IsDone',
|
|
78
|
+
type: 'boolean',
|
|
79
|
+
default: false,
|
|
80
|
+
displayOptions: showForActivityCreate,
|
|
81
|
+
description: 'Mark the activity as completed.',
|
|
82
|
+
},
|
|
83
|
+
// ===== Additional Fields =====
|
|
84
|
+
{
|
|
85
|
+
displayName: 'Additional Fields',
|
|
86
|
+
name: 'additionalFields',
|
|
87
|
+
type: 'collection',
|
|
88
|
+
placeholder: 'Add field',
|
|
89
|
+
default: {},
|
|
90
|
+
displayOptions: showForActivityCreate,
|
|
91
|
+
options: [
|
|
92
|
+
{ displayName: 'Note', name: 'Note', type: 'string', default: '', description: 'Activity note/description.' },
|
|
93
|
+
{ displayName: 'Result Note', name: 'ResultNote', type: 'string', default: '', description: 'Result/Outcome notes.' },
|
|
94
|
+
{ displayName: 'Is Deleted', name: 'IsDeleted', type: 'boolean', default: false, description: 'Soft-delete flag.' },
|
|
95
|
+
{ displayName: 'Is Pinned', name: 'IsPinned', type: 'boolean', default: false, description: 'Pin this activity.' },
|
|
96
|
+
{ displayName: 'Due Date', name: 'DueDate', type: 'dateTime', default: '', description: 'Planned due date/time (ISO).' },
|
|
97
|
+
{ displayName: 'Duration', name: 'Duration', type: 'number', default: 0, description: 'Duration in minutes (>= 0). Only sent if > 0.' },
|
|
98
|
+
{ displayName: 'Done Date', name: 'DoneDate', type: 'dateTime', default: '', description: 'Completion date/time (ISO).' },
|
|
99
|
+
{
|
|
100
|
+
displayName: 'Deal ID',
|
|
101
|
+
name: 'DealId',
|
|
102
|
+
type: 'string',
|
|
103
|
+
default: '00000000-0000-0000-0000-000000000000',
|
|
104
|
+
description: 'Related deal ID (zero-guid if none).',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
displayName: 'Case ID',
|
|
108
|
+
name: 'CaseId',
|
|
109
|
+
type: 'string',
|
|
110
|
+
default: '00000000-0000-0000-0000-000000000000',
|
|
111
|
+
description: 'Related case ID (zero-guid if none).',
|
|
112
|
+
},
|
|
113
|
+
// ContactIds: string[]
|
|
114
|
+
{
|
|
115
|
+
displayName: 'Contact IDs',
|
|
116
|
+
name: 'ContactIds',
|
|
117
|
+
type: 'string',
|
|
118
|
+
typeOptions: { multipleValues: true },
|
|
119
|
+
default: [],
|
|
120
|
+
description: 'List of related contact IDs.',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
displayName: 'Creator ID',
|
|
124
|
+
name: 'CreatorId',
|
|
125
|
+
type: 'string',
|
|
126
|
+
default: '00000000-0000-0000-0000-000000000000',
|
|
127
|
+
description: 'Creator user ID (GUID).',
|
|
128
|
+
},
|
|
129
|
+
// Recurrence
|
|
130
|
+
{
|
|
131
|
+
displayName: 'Recurrence Type',
|
|
132
|
+
name: 'RecurrenceType',
|
|
133
|
+
type: 'options',
|
|
134
|
+
options: [
|
|
135
|
+
{ name: '—', value: '' },
|
|
136
|
+
{ name: 'OneTime', value: 'OneTime' },
|
|
137
|
+
{ name: 'Hourly', value: 'Hourly' },
|
|
138
|
+
{ name: 'Daily', value: 'Daily' },
|
|
139
|
+
{ name: 'Weekly', value: 'Weekly' },
|
|
140
|
+
{ name: 'Monthly', value: 'Monthly' },
|
|
141
|
+
{ name: 'Yearly', value: 'Yearly' },
|
|
142
|
+
],
|
|
143
|
+
default: '',
|
|
144
|
+
description: 'Recurrence pattern; leave empty for non-recurring.',
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
displayName: 'Recurrence Data',
|
|
148
|
+
name: 'RecurrenceData',
|
|
149
|
+
type: 'number',
|
|
150
|
+
default: 0,
|
|
151
|
+
description: 'Positive integer. Only sent if > 0.',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
displayName: 'Recurrence End Date',
|
|
155
|
+
name: 'RecurrenceEndDate',
|
|
156
|
+
type: 'dateTime',
|
|
157
|
+
default: '',
|
|
158
|
+
description: 'End date/time for recurrence (ISO).',
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.activityUpdateProperties = exports.activityUpdate = exports.activityCreateProperties = exports.activityCreate = void 0;
|
|
4
|
+
var create_operation_1 = require("./create.operation");
|
|
5
|
+
Object.defineProperty(exports, "activityCreate", { enumerable: true, get: function () { return create_operation_1.activityCreate; } });
|
|
6
|
+
var create_properties_1 = require("./create.properties");
|
|
7
|
+
Object.defineProperty(exports, "activityCreateProperties", { enumerable: true, get: function () { return create_properties_1.activityCreateProperties; } });
|
|
8
|
+
var update_operation_1 = require("./update.operation"); // NEW
|
|
9
|
+
Object.defineProperty(exports, "activityUpdate", { enumerable: true, get: function () { return update_operation_1.activityUpdate; } });
|
|
10
|
+
var update_properties_1 = require("./update.properties"); // NEW
|
|
11
|
+
Object.defineProperty(exports, "activityUpdateProperties", { enumerable: true, get: function () { return update_properties_1.activityUpdateProperties; } });
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.activityUpdate = activityUpdate;
|
|
4
|
+
const http_1 = require("../../lib/http");
|
|
5
|
+
async function activityUpdate(i, returnData) {
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
7
|
+
// Required
|
|
8
|
+
const id = this.getNodeParameter('Id', i, '');
|
|
9
|
+
if (!id)
|
|
10
|
+
throw new Error('Id is required.');
|
|
11
|
+
const title = this.getNodeParameter('Title', i, '');
|
|
12
|
+
if (!title)
|
|
13
|
+
throw new Error('Title is required.');
|
|
14
|
+
// ActivityType: select/manual
|
|
15
|
+
const typeMode = this.getNodeParameter('ActivityTypeMode', i);
|
|
16
|
+
const activityTypeId = typeMode === 'select'
|
|
17
|
+
? this.getNodeParameter('ActivityTypeIdSelect', i, '')
|
|
18
|
+
: this.getNodeParameter('ActivityTypeIdManual', i, '');
|
|
19
|
+
if (!activityTypeId)
|
|
20
|
+
throw new Error('ActivityTypeId is required (select from list or enter manually).');
|
|
21
|
+
// Owner
|
|
22
|
+
const ownerMode = this.getNodeParameter('OwnerMode', i);
|
|
23
|
+
const ownerId = ownerMode === 'select'
|
|
24
|
+
? this.getNodeParameter('OwnerIdSelect', i, '')
|
|
25
|
+
: this.getNodeParameter('OwnerIdManual', i, '');
|
|
26
|
+
// if (!ownerId) throw new Error('OwnerId is required (select from list or enter manually).');
|
|
27
|
+
const isDone = this.getNodeParameter('IsDone', i, false);
|
|
28
|
+
// Additional fields
|
|
29
|
+
const add = this.getNodeParameter('additionalFields', i, {}) || {};
|
|
30
|
+
const note = (_a = add.Note) !== null && _a !== void 0 ? _a : '';
|
|
31
|
+
const resultNote = (_b = add.ResultNote) !== null && _b !== void 0 ? _b : '';
|
|
32
|
+
const isDeleted = (_c = add.IsDeleted) !== null && _c !== void 0 ? _c : false;
|
|
33
|
+
const isPinned = (_d = add.IsPinned) !== null && _d !== void 0 ? _d : false;
|
|
34
|
+
const dueDate = (_e = add.DueDate) !== null && _e !== void 0 ? _e : '';
|
|
35
|
+
const duration = Number((_f = add.Duration) !== null && _f !== void 0 ? _f : 0);
|
|
36
|
+
const doneDate = (_g = add.DoneDate) !== null && _g !== void 0 ? _g : '';
|
|
37
|
+
const dealId = (_h = add.DealId) !== null && _h !== void 0 ? _h : '00000000-0000-0000-0000-000000000000';
|
|
38
|
+
const caseId = (_j = add.CaseId) !== null && _j !== void 0 ? _j : '00000000-0000-0000-0000-000000000000';
|
|
39
|
+
// ContactIds: string[]
|
|
40
|
+
let contactIds;
|
|
41
|
+
const cids = add.ContactIds;
|
|
42
|
+
if (Array.isArray(cids))
|
|
43
|
+
contactIds = cids.filter(Boolean);
|
|
44
|
+
else if (typeof cids === 'string' && cids)
|
|
45
|
+
contactIds = [cids];
|
|
46
|
+
const creatorId = (_k = add.CreatorId) !== null && _k !== void 0 ? _k : '00000000-0000-0000-0000-000000000000';
|
|
47
|
+
const recurrenceType = (_l = add.RecurrenceType) !== null && _l !== void 0 ? _l : '';
|
|
48
|
+
const recurrenceDataNum = Number((_m = add.RecurrenceData) !== null && _m !== void 0 ? _m : 0);
|
|
49
|
+
const recurrenceEndDate = (_o = add.RecurrenceEndDate) !== null && _o !== void 0 ? _o : '';
|
|
50
|
+
// Build body (با Id)
|
|
51
|
+
const activity = {
|
|
52
|
+
Id: id,
|
|
53
|
+
ActivityTypeId: activityTypeId,
|
|
54
|
+
Title: title,
|
|
55
|
+
IsDone: isDone,
|
|
56
|
+
};
|
|
57
|
+
if (ownerId)
|
|
58
|
+
activity['OwnerId'] = ownerId;
|
|
59
|
+
if (note)
|
|
60
|
+
activity['Note'] = note;
|
|
61
|
+
if (resultNote)
|
|
62
|
+
activity['ResultNote'] = resultNote;
|
|
63
|
+
if (isDeleted)
|
|
64
|
+
activity['IsDeleted'] = true;
|
|
65
|
+
if (isPinned)
|
|
66
|
+
activity['IsPinned'] = true;
|
|
67
|
+
if (dueDate)
|
|
68
|
+
activity['DueDate'] = dueDate;
|
|
69
|
+
if (duration > 0)
|
|
70
|
+
activity['Duration'] = duration;
|
|
71
|
+
if (doneDate)
|
|
72
|
+
activity['DoneDate'] = doneDate;
|
|
73
|
+
if (dealId)
|
|
74
|
+
activity['DealId'] = dealId;
|
|
75
|
+
if (caseId)
|
|
76
|
+
activity['CaseId'] = caseId;
|
|
77
|
+
if (contactIds === null || contactIds === void 0 ? void 0 : contactIds.length)
|
|
78
|
+
activity['ContactIds'] = contactIds;
|
|
79
|
+
if (creatorId)
|
|
80
|
+
activity['CreatorId'] = creatorId;
|
|
81
|
+
if (recurrenceType)
|
|
82
|
+
activity['RecurrenceType'] = recurrenceType;
|
|
83
|
+
if (recurrenceDataNum > 0)
|
|
84
|
+
activity['RecurrenceData'] = recurrenceDataNum;
|
|
85
|
+
if (recurrenceEndDate)
|
|
86
|
+
activity['RecurrenceEndDate'] = recurrenceEndDate;
|
|
87
|
+
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
88
|
+
method: 'POST',
|
|
89
|
+
path: '/api/activity/save',
|
|
90
|
+
body: { Activity: activity },
|
|
91
|
+
});
|
|
92
|
+
returnData.push({ json: resp });
|
|
93
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.activityUpdateProperties = void 0;
|
|
4
|
+
const showForActivityUpdate = { show: { resource: ['activity'], operation: ['update'] } };
|
|
5
|
+
exports.activityUpdateProperties = [
|
|
6
|
+
// === REQUIRED: Id
|
|
7
|
+
{
|
|
8
|
+
displayName: 'Id',
|
|
9
|
+
name: 'Id',
|
|
10
|
+
type: 'string',
|
|
11
|
+
default: '',
|
|
12
|
+
required: true,
|
|
13
|
+
displayOptions: showForActivityUpdate,
|
|
14
|
+
description: 'Activity Id to update (required).',
|
|
15
|
+
},
|
|
16
|
+
// ===== MAIN (مثل ایجاد، با همان ترتیب) =====
|
|
17
|
+
{
|
|
18
|
+
displayName: 'Title',
|
|
19
|
+
name: 'Title',
|
|
20
|
+
type: 'string',
|
|
21
|
+
default: '',
|
|
22
|
+
required: true,
|
|
23
|
+
displayOptions: showForActivityUpdate,
|
|
24
|
+
description: 'Activity title (required).',
|
|
25
|
+
},
|
|
26
|
+
// ActivityTypeId: Select / Manual
|
|
27
|
+
{
|
|
28
|
+
displayName: 'Activity Type Input Mode',
|
|
29
|
+
name: 'ActivityTypeMode',
|
|
30
|
+
type: 'options',
|
|
31
|
+
options: [
|
|
32
|
+
{ name: 'Select from list', value: 'select' },
|
|
33
|
+
{ name: 'Enter ID manually', value: 'manual' },
|
|
34
|
+
],
|
|
35
|
+
default: 'select',
|
|
36
|
+
displayOptions: showForActivityUpdate,
|
|
37
|
+
description: 'Choose how to set the activity type.',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
displayName: 'Activity Type',
|
|
41
|
+
name: 'ActivityTypeIdSelect',
|
|
42
|
+
type: 'options',
|
|
43
|
+
typeOptions: { loadOptionsMethod: 'getActivityTypes' },
|
|
44
|
+
default: '',
|
|
45
|
+
displayOptions: { show: { resource: ['activity'], operation: ['update'], ActivityTypeMode: ['select'] } },
|
|
46
|
+
description: 'Select the activity type (required if select mode).',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
displayName: 'Activity Type ID',
|
|
50
|
+
name: 'ActivityTypeIdManual',
|
|
51
|
+
type: 'string',
|
|
52
|
+
default: '',
|
|
53
|
+
displayOptions: { show: { resource: ['activity'], operation: ['update'], ActivityTypeMode: ['manual'] } },
|
|
54
|
+
description: 'Enter activity type ID manually (required if manual mode).',
|
|
55
|
+
},
|
|
56
|
+
// // Owner (فقط اینجا، نه در Additional Fields)
|
|
57
|
+
// {
|
|
58
|
+
// displayName: 'Owner Input Mode',
|
|
59
|
+
// name: 'OwnerMode',
|
|
60
|
+
// type: 'options',
|
|
61
|
+
// options: [
|
|
62
|
+
// { name: 'Select from list', value: 'select' },
|
|
63
|
+
// { name: 'Enter ID manually', value: 'manual' },
|
|
64
|
+
// ],
|
|
65
|
+
// default: 'select',
|
|
66
|
+
// displayOptions: showForActivityUpdate,
|
|
67
|
+
// description: 'Choose how to set the owner.',
|
|
68
|
+
// },
|
|
69
|
+
// {
|
|
70
|
+
// displayName: 'Owner',
|
|
71
|
+
// name: 'OwnerIdSelect',
|
|
72
|
+
// type: 'options',
|
|
73
|
+
// typeOptions: { loadOptionsMethod: 'getUsers' },
|
|
74
|
+
// default: '',
|
|
75
|
+
// displayOptions: { show: { resource: ['activity'], operation: ['update'], OwnerMode: ['select'] } },
|
|
76
|
+
// description: 'Select the owner user (required if select mode).',
|
|
77
|
+
// },
|
|
78
|
+
// {
|
|
79
|
+
// displayName: 'Owner ID',
|
|
80
|
+
// name: 'OwnerIdManual',
|
|
81
|
+
// type: 'string',
|
|
82
|
+
// default: '',
|
|
83
|
+
// displayOptions: { show: { resource: ['activity'], operation: ['update'], OwnerMode: ['manual'] } },
|
|
84
|
+
// description: 'Enter owner user ID manually (required if manual mode).',
|
|
85
|
+
// },
|
|
86
|
+
// {
|
|
87
|
+
// displayName: 'Is Done',
|
|
88
|
+
// name: 'IsDone',
|
|
89
|
+
// type: 'boolean',
|
|
90
|
+
// default: false,
|
|
91
|
+
// displayOptions: showForActivityUpdate,
|
|
92
|
+
// description: 'Mark the activity as completed.',
|
|
93
|
+
// },
|
|
94
|
+
// ===== Additional Fields (بدون Owner) =====
|
|
95
|
+
{
|
|
96
|
+
displayName: 'Additional Fields',
|
|
97
|
+
name: 'additionalFields',
|
|
98
|
+
type: 'collection',
|
|
99
|
+
placeholder: 'Add field',
|
|
100
|
+
default: {},
|
|
101
|
+
displayOptions: showForActivityUpdate,
|
|
102
|
+
options: [
|
|
103
|
+
{ displayName: 'Note', name: 'Note', type: 'string', default: '', description: 'Activity note/description.' },
|
|
104
|
+
{ displayName: 'Result Note', name: 'ResultNote', type: 'string', default: '', description: 'Result/Outcome notes.' },
|
|
105
|
+
{ displayName: 'Is Deleted', name: 'IsDeleted', type: 'boolean', default: false, description: 'Soft-delete flag.' },
|
|
106
|
+
{ displayName: 'Is Pinned', name: 'IsPinned', type: 'boolean', default: false, description: 'Pin this activity.' },
|
|
107
|
+
{ displayName: 'Due Date', name: 'DueDate', type: 'dateTime', default: '', description: 'Planned due date/time (ISO).' },
|
|
108
|
+
{ displayName: 'Duration', name: 'Duration', type: 'number', default: 0, description: 'Duration in minutes (>= 0). Only sent if > 0.' },
|
|
109
|
+
{ displayName: 'Done Date', name: 'DoneDate', type: 'dateTime', default: '', description: 'Completion date/time (ISO).' },
|
|
110
|
+
{
|
|
111
|
+
displayName: 'Deal ID',
|
|
112
|
+
name: 'DealId',
|
|
113
|
+
type: 'string',
|
|
114
|
+
default: '00000000-0000-0000-0000-000000000000',
|
|
115
|
+
description: 'Related deal ID (zero-guid if none).',
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
displayName: 'Case ID',
|
|
119
|
+
name: 'CaseId',
|
|
120
|
+
type: 'string',
|
|
121
|
+
default: '00000000-0000-0000-0000-000000000000',
|
|
122
|
+
description: 'Related case ID (zero-guid if none).',
|
|
123
|
+
},
|
|
124
|
+
// ContactIds: string[]
|
|
125
|
+
{
|
|
126
|
+
displayName: 'Contact IDs',
|
|
127
|
+
name: 'ContactIds',
|
|
128
|
+
type: 'string',
|
|
129
|
+
typeOptions: { multipleValues: true },
|
|
130
|
+
default: [],
|
|
131
|
+
description: 'List of related contact IDs.',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
displayName: 'Creator ID',
|
|
135
|
+
name: 'CreatorId',
|
|
136
|
+
type: 'string',
|
|
137
|
+
default: '00000000-0000-0000-0000-000000000000',
|
|
138
|
+
description: 'Creator user ID (GUID).',
|
|
139
|
+
},
|
|
140
|
+
// Recurrence
|
|
141
|
+
{
|
|
142
|
+
displayName: 'Recurrence Type',
|
|
143
|
+
name: 'RecurrenceType',
|
|
144
|
+
type: 'options',
|
|
145
|
+
options: [
|
|
146
|
+
{ name: '—', value: '' },
|
|
147
|
+
{ name: 'OneTime', value: 'OneTime' },
|
|
148
|
+
{ name: 'Hourly', value: 'Hourly' },
|
|
149
|
+
{ name: 'Daily', value: 'Daily' },
|
|
150
|
+
{ name: 'Weekly', value: 'Weekly' },
|
|
151
|
+
{ name: 'Monthly', value: 'Monthly' },
|
|
152
|
+
{ name: 'Yearly', value: 'Yearly' },
|
|
153
|
+
],
|
|
154
|
+
default: '',
|
|
155
|
+
description: 'Recurrence pattern; leave empty for non-recurring.',
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
displayName: 'Recurrence Data',
|
|
159
|
+
name: 'RecurrenceData',
|
|
160
|
+
type: 'number',
|
|
161
|
+
default: 0,
|
|
162
|
+
description: 'Positive integer. Only sent if > 0.',
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
displayName: 'Recurrence End Date',
|
|
166
|
+
name: 'RecurrenceEndDate',
|
|
167
|
+
type: 'dateTime',
|
|
168
|
+
default: '',
|
|
169
|
+
description: 'End date/time for recurrence (ISO).',
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
},
|
|
173
|
+
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-didar-crm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "Didar CRM nodes for n8n (Trigger + Deal.create)",
|
|
5
5
|
"author": "You",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,8 +18,10 @@
|
|
|
18
18
|
"didar"
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
|
-
"
|
|
22
|
-
"
|
|
21
|
+
"clean": "rimraf dist",
|
|
22
|
+
"build:ts": "tsc -p .",
|
|
23
|
+
"build:assets": "cpx \"nodes/**/*.svg\" dist/nodes",
|
|
24
|
+
"build": "npm-run-all clean build:ts build:assets"
|
|
23
25
|
},
|
|
24
26
|
"n8n": {
|
|
25
27
|
"nodes": [
|
|
@@ -32,7 +34,11 @@
|
|
|
32
34
|
},
|
|
33
35
|
"devDependencies": {
|
|
34
36
|
"@types/node": "^20.0.0",
|
|
37
|
+
"@types/request": "^2.48.13",
|
|
38
|
+
"cpx": "^1.5.0",
|
|
35
39
|
"n8n-workflow": "^1.0.0",
|
|
40
|
+
"npm-run-all": "^4.1.5",
|
|
41
|
+
"rimraf": "^6.0.1",
|
|
36
42
|
"typescript": "^5.4.0"
|
|
37
43
|
}
|
|
38
44
|
}
|