n8n-nodes-didar-crm 0.0.13 → 0.0.15
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 +13 -0
- package/dist/nodes/DidarCrm.node.d.ts +1 -0
- package/dist/nodes/DidarCrm.node.js +35 -0
- package/dist/nodes/case/create.properties.js +4 -4
- package/dist/nodes/case/index.d.ts +2 -0
- package/dist/nodes/case/index.js +5 -1
- package/dist/nodes/case/update.operation.d.ts +2 -0
- package/dist/nodes/case/update.operation.js +95 -0
- package/dist/nodes/case/update.properties.d.ts +2 -0
- package/dist/nodes/case/update.properties.js +172 -0
- package/dist/nodes/product/create.operation.d.ts +2 -0
- package/dist/nodes/product/create.operation.js +126 -0
- package/dist/nodes/product/create.properties.d.ts +2 -0
- package/dist/nodes/product/create.properties.js +125 -0
- package/dist/nodes/product/index.d.ts +4 -0
- package/dist/nodes/product/index.js +12 -0
- package/dist/nodes/product/update.operation.d.ts +2 -0
- package/dist/nodes/product/update.operation.js +110 -0
- package/dist/nodes/product/update.properties.d.ts +2 -0
- package/dist/nodes/product/update.properties.js +96 -0
- package/package.json +1 -1
|
@@ -3,3 +3,4 @@ export declare function getPipelines(this: ILoadOptionsFunctions): Promise<INode
|
|
|
3
3
|
export declare function getStagesForPipeline(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
4
4
|
export declare function getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
5
5
|
export declare function getActivityTypes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
|
|
6
|
+
export declare function getProductCategories(this: ILoadOptionsFunctions): Promise<any>;
|
package/dist/lib/loadOptions.js
CHANGED
|
@@ -4,6 +4,8 @@ exports.getPipelines = getPipelines;
|
|
|
4
4
|
exports.getStagesForPipeline = getStagesForPipeline;
|
|
5
5
|
exports.getUsers = getUsers;
|
|
6
6
|
exports.getActivityTypes = getActivityTypes;
|
|
7
|
+
exports.getProductCategories = getProductCategories;
|
|
8
|
+
const http_1 = require("./http");
|
|
7
9
|
async function getPipelines() {
|
|
8
10
|
var _a;
|
|
9
11
|
const creds = await this.getCredentials('didarApi');
|
|
@@ -99,3 +101,14 @@ async function getActivityTypes() {
|
|
|
99
101
|
.filter((x) => (x === null || x === void 0 ? void 0 : x.Id) && (x === null || x === void 0 ? void 0 : x.Title))
|
|
100
102
|
.map((x) => ({ name: x.Title, value: x.Id }));
|
|
101
103
|
}
|
|
104
|
+
async function getProductCategories() {
|
|
105
|
+
const resp = await http_1.didarRequest(this, 0, { method: 'POST', path: '/api/product/categories' });
|
|
106
|
+
const list = Array.isArray(resp === null || resp === void 0 ? void 0 : resp.Response) ? resp.Response : resp; // در بعضی APIها Response دارند
|
|
107
|
+
return (list || []).map((cat) => {
|
|
108
|
+
var _a, _b;
|
|
109
|
+
return ({
|
|
110
|
+
name: (_b = (_a = cat.Title) !== null && _a !== void 0 ? _a : cat.Name) !== null && _b !== void 0 ? _b : cat.Id,
|
|
111
|
+
value: cat.Id,
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
@@ -6,6 +6,7 @@ export declare class DidarCrm implements INodeType {
|
|
|
6
6
|
getStagesForPipeline: (this: ILoadOptionsFunctions) => Promise<INodePropertyOptions[]>;
|
|
7
7
|
getUsers: (this: ILoadOptionsFunctions) => Promise<INodePropertyOptions[]>;
|
|
8
8
|
getActivityTypes: (this: ILoadOptionsFunctions) => Promise<INodePropertyOptions[]>;
|
|
9
|
+
getProductCategories: (this: ILoadOptionsFunctions) => Promise<INodePropertyOptions[]>;
|
|
9
10
|
};
|
|
10
11
|
};
|
|
11
12
|
description: INodeTypeDescription;
|
|
@@ -47,6 +47,8 @@ const NoteOps = __importStar(require("./note"));
|
|
|
47
47
|
const note_1 = require("./note");
|
|
48
48
|
const CaseOps = __importStar(require("./case"));
|
|
49
49
|
const case_1 = require("./case");
|
|
50
|
+
const ProductOps = __importStar(require("./product"));
|
|
51
|
+
const product_1 = require("./product");
|
|
50
52
|
class DidarCrm {
|
|
51
53
|
constructor() {
|
|
52
54
|
this.methods = {
|
|
@@ -55,6 +57,7 @@ class DidarCrm {
|
|
|
55
57
|
getStagesForPipeline: Load.getStagesForPipeline,
|
|
56
58
|
getUsers: Load.getUsers,
|
|
57
59
|
getActivityTypes: Load.getActivityTypes,
|
|
60
|
+
getProductCategories: Load.getProductCategories,
|
|
58
61
|
},
|
|
59
62
|
};
|
|
60
63
|
this.description = {
|
|
@@ -81,6 +84,7 @@ class DidarCrm {
|
|
|
81
84
|
{ name: 'Activity', value: 'activity' },
|
|
82
85
|
{ name: 'Note', value: 'note' },
|
|
83
86
|
{ name: 'Case', value: 'case' },
|
|
87
|
+
{ name: 'Product', value: 'product' },
|
|
84
88
|
],
|
|
85
89
|
default: 'deal',
|
|
86
90
|
description: 'Choose the entity to act on.',
|
|
@@ -155,6 +159,19 @@ class DidarCrm {
|
|
|
155
159
|
displayOptions: { show: { resource: ['case'] } },
|
|
156
160
|
options: [
|
|
157
161
|
{ name: 'Create', value: 'create', action: 'Create a case' },
|
|
162
|
+
{ name: 'Update', value: 'update', action: 'Update a case by ID' },
|
|
163
|
+
],
|
|
164
|
+
default: 'create',
|
|
165
|
+
description: 'Select the action to perform on the selected resource.',
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
displayName: 'Operation',
|
|
169
|
+
name: 'operation',
|
|
170
|
+
type: 'options',
|
|
171
|
+
displayOptions: { show: { resource: ['product'] } },
|
|
172
|
+
options: [
|
|
173
|
+
{ name: 'Create', value: 'create', action: 'Create a product' },
|
|
174
|
+
{ name: 'Update', value: 'update', action: 'Update a product by ID' },
|
|
158
175
|
],
|
|
159
176
|
default: 'create',
|
|
160
177
|
description: 'Select the action to perform on the selected resource.',
|
|
@@ -179,6 +196,10 @@ class DidarCrm {
|
|
|
179
196
|
...note_1.noteUpdateProperties,
|
|
180
197
|
// Case properties (imported)
|
|
181
198
|
...case_1.caseCreateProperties,
|
|
199
|
+
...case_1.caseUpdateProperties,
|
|
200
|
+
// Product properties (imported)
|
|
201
|
+
...product_1.productCreateProperties,
|
|
202
|
+
...product_1.productUpdateProperties,
|
|
182
203
|
],
|
|
183
204
|
};
|
|
184
205
|
}
|
|
@@ -255,6 +276,20 @@ class DidarCrm {
|
|
|
255
276
|
await CaseOps.caseCreate.call(this, i, returnData);
|
|
256
277
|
continue;
|
|
257
278
|
}
|
|
279
|
+
if (operation === 'update') {
|
|
280
|
+
await CaseOps.caseUpdate.call(this, i, returnData);
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (resource === 'product') {
|
|
285
|
+
if (operation === 'create') {
|
|
286
|
+
await ProductOps.productCreate.call(this, i, returnData);
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
if (operation === 'update') {
|
|
290
|
+
await ProductOps.productUpdate.call(this, i, returnData);
|
|
291
|
+
continue;
|
|
292
|
+
} // NEW
|
|
258
293
|
}
|
|
259
294
|
}
|
|
260
295
|
return [returnData];
|
|
@@ -136,10 +136,10 @@ exports.caseCreateProperties = [
|
|
|
136
136
|
name: 'Priority',
|
|
137
137
|
type: 'options',
|
|
138
138
|
options: [
|
|
139
|
-
{ name: 'None
|
|
140
|
-
{ name: 'Low
|
|
141
|
-
{ name: 'Medium
|
|
142
|
-
{ name: 'High
|
|
139
|
+
{ name: 'None', value: -2 },
|
|
140
|
+
{ name: 'Low', value: -1 },
|
|
141
|
+
{ name: 'Medium', value: 0 },
|
|
142
|
+
{ name: 'High', value: 1 },
|
|
143
143
|
],
|
|
144
144
|
default: -2,
|
|
145
145
|
description: 'Priority level.',
|
package/dist/nodes/case/index.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.caseCreateProperties = exports.caseCreate = void 0;
|
|
3
|
+
exports.caseUpdateProperties = exports.caseUpdate = exports.caseCreateProperties = exports.caseCreate = void 0;
|
|
4
4
|
// nodes/case/index.ts
|
|
5
5
|
var create_operation_1 = require("./create.operation");
|
|
6
6
|
Object.defineProperty(exports, "caseCreate", { enumerable: true, get: function () { return create_operation_1.caseCreate; } });
|
|
7
7
|
var create_properties_1 = require("./create.properties");
|
|
8
8
|
Object.defineProperty(exports, "caseCreateProperties", { enumerable: true, get: function () { return create_properties_1.caseCreateProperties; } });
|
|
9
|
+
var update_operation_1 = require("./update.operation");
|
|
10
|
+
Object.defineProperty(exports, "caseUpdate", { enumerable: true, get: function () { return update_operation_1.caseUpdate; } });
|
|
11
|
+
var update_properties_1 = require("./update.properties");
|
|
12
|
+
Object.defineProperty(exports, "caseUpdateProperties", { enumerable: true, get: function () { return update_properties_1.caseUpdateProperties; } });
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.caseUpdate = caseUpdate;
|
|
4
|
+
const http_1 = require("../../lib/http");
|
|
5
|
+
const ZERO_GUID = '00000000-0000-0000-0000-000000000000';
|
|
6
|
+
async function caseUpdate(i, returnData) {
|
|
7
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
8
|
+
// Main
|
|
9
|
+
const id = this.getNodeParameter('Id', i, '');
|
|
10
|
+
const title = this.getNodeParameter('Title', i, '');
|
|
11
|
+
const ownerMode = this.getNodeParameter('OwnerMode', i);
|
|
12
|
+
const ownerIdSelect = this.getNodeParameter('OwnerIdSelect', i, '');
|
|
13
|
+
const ownerIdManual = this.getNodeParameter('OwnerIdManual', i, '');
|
|
14
|
+
const pipelineStageId = this.getNodeParameter('PipelineStageId', i, '');
|
|
15
|
+
const status = this.getNodeParameter('Status', i, 'InProgress');
|
|
16
|
+
if (!(id === null || id === void 0 ? void 0 : id.trim()))
|
|
17
|
+
throw new Error('Case ID is required.');
|
|
18
|
+
if (!(title === null || title === void 0 ? void 0 : title.trim()))
|
|
19
|
+
throw new Error('Title is required.');
|
|
20
|
+
if (!(pipelineStageId === null || pipelineStageId === void 0 ? void 0 : pipelineStageId.trim()))
|
|
21
|
+
throw new Error('PipelineStageId is required.');
|
|
22
|
+
const ownerId = ownerMode === 'select' ? ownerIdSelect : ownerIdManual;
|
|
23
|
+
if (!(ownerId === null || ownerId === void 0 ? void 0 : ownerId.trim()) || ownerId === ZERO_GUID)
|
|
24
|
+
throw new Error('OwnerId is required.');
|
|
25
|
+
// Users / ResultNote (TOP-LEVEL)
|
|
26
|
+
const usersMode = this.getNodeParameter('UsersMode', i, 'select');
|
|
27
|
+
const userIdsSelect = this.getNodeParameter('UserIdsSelect', i, []);
|
|
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);
|
|
31
|
+
const resultNoteTop = status === 'Done' ? this.getNodeParameter('ResultNote', i, '') : '';
|
|
32
|
+
// Additional
|
|
33
|
+
const add = this.getNodeParameter('additionalFields', i, {}) || {};
|
|
34
|
+
const description = (_a = add.Description) !== null && _a !== void 0 ? _a : '';
|
|
35
|
+
const companyId = (_b = add.CompanyId) !== null && _b !== void 0 ? _b : ZERO_GUID;
|
|
36
|
+
const personId = (_c = add.PersonId) !== null && _c !== void 0 ? _c : ZERO_GUID;
|
|
37
|
+
const dealId = (_d = add.DealId) !== null && _d !== void 0 ? _d : ZERO_GUID;
|
|
38
|
+
const dueDateUi = (_e = add.DueDate) !== null && _e !== void 0 ? _e : '';
|
|
39
|
+
const caseCategoryId = (_f = add.CaseCategoryId) !== null && _f !== void 0 ? _f : '00000000-0000-0000-0000-000000000000';
|
|
40
|
+
const priority = (_g = add.Priority) !== null && _g !== void 0 ? _g : -2;
|
|
41
|
+
const visibilityType = (_h = add.VisibilityType) !== null && _h !== void 0 ? _h : 'Owner';
|
|
42
|
+
const otherContactsArr = (_j = add.OtherContactIds) !== null && _j !== void 0 ? _j : [];
|
|
43
|
+
const otherContactIds = Array.isArray(otherContactsArr) ? otherContactsArr.filter(Boolean).join(',') : '';
|
|
44
|
+
// Fields (JSON)
|
|
45
|
+
let fields;
|
|
46
|
+
if (typeof add.Fields === 'string' && add.Fields.trim()) {
|
|
47
|
+
try {
|
|
48
|
+
fields = JSON.parse(add.Fields);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
throw new Error('Invalid JSON in "Custom Fields (JSON)".');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else if (typeof add.Fields === 'object' && add.Fields) {
|
|
55
|
+
fields = add.Fields;
|
|
56
|
+
}
|
|
57
|
+
const labelIds = ((_k = add.LabelIds) !== null && _k !== void 0 ? _k : []).filter(Boolean);
|
|
58
|
+
// Dates
|
|
59
|
+
const nowIso = new Date().toISOString();
|
|
60
|
+
const dueDate = dueDateUi ? new Date(dueDateUi).toISOString() : nowIso;
|
|
61
|
+
// Payload
|
|
62
|
+
const caseObj = {
|
|
63
|
+
Id: id,
|
|
64
|
+
Title: title,
|
|
65
|
+
PipelineStageId: pipelineStageId,
|
|
66
|
+
OwnerId: ownerId,
|
|
67
|
+
Description: description,
|
|
68
|
+
CompanyId: companyId || ZERO_GUID,
|
|
69
|
+
PersonId: personId || ZERO_GUID,
|
|
70
|
+
DealId: dealId || ZERO_GUID,
|
|
71
|
+
Status: status,
|
|
72
|
+
DueDate: dueDate,
|
|
73
|
+
CaseCategoryId: caseCategoryId,
|
|
74
|
+
Priority: priority,
|
|
75
|
+
VisibilityType: visibilityType,
|
|
76
|
+
};
|
|
77
|
+
if (userIds.length)
|
|
78
|
+
caseObj['UserIds'] = userIds;
|
|
79
|
+
if (otherContactIds)
|
|
80
|
+
caseObj['OtherContactIds'] = otherContactIds;
|
|
81
|
+
if (status === 'Done' && (resultNoteTop === null || resultNoteTop === void 0 ? void 0 : resultNoteTop.trim()))
|
|
82
|
+
caseObj['ResultNote'] = resultNoteTop.trim();
|
|
83
|
+
if (fields)
|
|
84
|
+
caseObj['Fields'] = fields;
|
|
85
|
+
const body = { Case: caseObj };
|
|
86
|
+
if (labelIds.length)
|
|
87
|
+
body['SetLabelDto'] = { LabelIds: labelIds };
|
|
88
|
+
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
89
|
+
method: 'POST',
|
|
90
|
+
path: '/api/Case/Save',
|
|
91
|
+
body,
|
|
92
|
+
});
|
|
93
|
+
returnData.push({ json: ((_l = resp === null || resp === void 0 ? void 0 : resp.Response) !== null && _l !== void 0 ? _l : resp) });
|
|
94
|
+
return returnData;
|
|
95
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.caseUpdateProperties = void 0;
|
|
4
|
+
const showForCaseUpdate = { show: { resource: ['case'], operation: ['update'] } };
|
|
5
|
+
const ZERO_GUID = '00000000-0000-0000-0000-000000000000';
|
|
6
|
+
exports.caseUpdateProperties = [
|
|
7
|
+
// ===== Main fields (order is important) =====
|
|
8
|
+
// Id first (required)
|
|
9
|
+
{
|
|
10
|
+
displayName: 'Case ID',
|
|
11
|
+
name: 'Id',
|
|
12
|
+
type: 'string',
|
|
13
|
+
default: '',
|
|
14
|
+
required: true,
|
|
15
|
+
displayOptions: showForCaseUpdate,
|
|
16
|
+
description: 'The ID of the case to update.',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
displayName: 'Title',
|
|
20
|
+
name: 'Title',
|
|
21
|
+
type: 'string',
|
|
22
|
+
default: '',
|
|
23
|
+
required: true,
|
|
24
|
+
displayOptions: showForCaseUpdate,
|
|
25
|
+
description: 'Case title. Required.',
|
|
26
|
+
},
|
|
27
|
+
// Owner (MATCH Activity pattern: no "required" in UI)
|
|
28
|
+
{
|
|
29
|
+
displayName: 'Owner Input Mode',
|
|
30
|
+
name: 'OwnerMode',
|
|
31
|
+
type: 'options',
|
|
32
|
+
options: [
|
|
33
|
+
{ name: 'Select from list', value: 'select' },
|
|
34
|
+
{ name: 'Enter ID manually', value: 'manual' },
|
|
35
|
+
],
|
|
36
|
+
default: 'select',
|
|
37
|
+
displayOptions: showForCaseUpdate,
|
|
38
|
+
description: 'Choose how to set the owner.',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
displayName: 'Owner',
|
|
42
|
+
name: 'OwnerIdSelect',
|
|
43
|
+
type: 'options',
|
|
44
|
+
typeOptions: { loadOptionsMethod: 'getUsers' },
|
|
45
|
+
default: '',
|
|
46
|
+
displayOptions: { show: { ...showForCaseUpdate.show, OwnerMode: ['select'] } },
|
|
47
|
+
description: 'Select the owner user (required if select mode).',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
displayName: 'Owner ID',
|
|
51
|
+
name: 'OwnerIdManual',
|
|
52
|
+
type: 'string',
|
|
53
|
+
default: '',
|
|
54
|
+
displayOptions: { show: { ...showForCaseUpdate.show, OwnerMode: ['manual'] } },
|
|
55
|
+
description: 'Enter owner user ID manually (required if manual mode).',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
displayName: 'Pipeline Stage ID',
|
|
59
|
+
name: 'PipelineStageId',
|
|
60
|
+
type: 'string',
|
|
61
|
+
default: '',
|
|
62
|
+
required: true,
|
|
63
|
+
displayOptions: showForCaseUpdate,
|
|
64
|
+
description: 'Pipeline stage ID (enter manually). Required.',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
displayName: 'Status',
|
|
68
|
+
name: 'Status',
|
|
69
|
+
type: 'options',
|
|
70
|
+
options: [
|
|
71
|
+
{ name: 'In Progress', value: 'InProgress' },
|
|
72
|
+
{ name: 'Done', value: 'Done' },
|
|
73
|
+
],
|
|
74
|
+
default: 'InProgress',
|
|
75
|
+
required: true,
|
|
76
|
+
displayOptions: showForCaseUpdate,
|
|
77
|
+
description: 'Case status.',
|
|
78
|
+
},
|
|
79
|
+
// ===== Top-level (avoid dependency loops) =====
|
|
80
|
+
{
|
|
81
|
+
displayName: 'Users Input Mode',
|
|
82
|
+
name: 'UsersMode',
|
|
83
|
+
type: 'options',
|
|
84
|
+
options: [
|
|
85
|
+
{ name: 'Select from list (multi)', value: 'select' },
|
|
86
|
+
{ name: 'Enter IDs manually', value: 'manual' },
|
|
87
|
+
],
|
|
88
|
+
default: 'select',
|
|
89
|
+
displayOptions: showForCaseUpdate,
|
|
90
|
+
description: 'How to provide user IDs.',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
displayName: 'Users',
|
|
94
|
+
name: 'UserIdsSelect',
|
|
95
|
+
type: 'options',
|
|
96
|
+
typeOptions: { loadOptionsMethod: 'getUsers', multipleValues: true },
|
|
97
|
+
default: [],
|
|
98
|
+
displayOptions: { show: { ...showForCaseUpdate.show, UsersMode: ['select'] } },
|
|
99
|
+
description: 'Select one or more users.',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
displayName: 'User IDs (Manual)',
|
|
103
|
+
name: 'UserIdsManual',
|
|
104
|
+
type: 'string',
|
|
105
|
+
typeOptions: { multipleValues: true },
|
|
106
|
+
default: [],
|
|
107
|
+
displayOptions: { show: { ...showForCaseUpdate.show, UsersMode: ['manual'] } },
|
|
108
|
+
description: 'Enter one or more user IDs (GUIDs).',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
displayName: 'Result Note',
|
|
112
|
+
name: 'ResultNote',
|
|
113
|
+
type: 'string',
|
|
114
|
+
default: '',
|
|
115
|
+
displayOptions: { show: { ...showForCaseUpdate.show, Status: ['Done'] } },
|
|
116
|
+
description: 'Shown only when Status is Done.',
|
|
117
|
+
},
|
|
118
|
+
// ===== Additional Fields (no child has displayOptions) =====
|
|
119
|
+
{
|
|
120
|
+
displayName: 'Additional Fields',
|
|
121
|
+
name: 'additionalFields',
|
|
122
|
+
type: 'collection',
|
|
123
|
+
placeholder: 'Add field',
|
|
124
|
+
default: {},
|
|
125
|
+
displayOptions: showForCaseUpdate,
|
|
126
|
+
options: [
|
|
127
|
+
{ displayName: 'Description', name: 'Description', type: 'string', default: '', description: 'Optional plain-text description.' },
|
|
128
|
+
{ displayName: 'Company ID', name: 'CompanyId', type: 'string', default: ZERO_GUID, description: 'Related company ID (GUID).' },
|
|
129
|
+
{ displayName: 'Person ID', name: 'PersonId', type: 'string', default: ZERO_GUID, description: 'Related person ID (GUID).' },
|
|
130
|
+
{ displayName: 'Deal ID', name: 'DealId', type: 'string', default: ZERO_GUID, description: 'Related deal ID (GUID).' },
|
|
131
|
+
{ displayName: 'Due Date', name: 'DueDate', type: 'dateTime', default: '', description: 'Due date. Defaults to now if empty.' },
|
|
132
|
+
{
|
|
133
|
+
displayName: 'Case Category',
|
|
134
|
+
name: 'CaseCategoryId',
|
|
135
|
+
type: 'options',
|
|
136
|
+
options: [
|
|
137
|
+
{ name: 'Activity Oriented', value: '00000000-0000-0000-0000-000000000000' },
|
|
138
|
+
{ name: 'Kanban', value: 'cd06853c-35df-4d9b-b124-9556474d84a1' },
|
|
139
|
+
{ name: 'Ticket', value: '37375848-a403-4186-8460-d45754f49e4c' },
|
|
140
|
+
],
|
|
141
|
+
default: '00000000-0000-0000-0000-000000000000',
|
|
142
|
+
description: 'Category of the case.',
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
displayName: 'Priority',
|
|
146
|
+
name: 'Priority',
|
|
147
|
+
type: 'options',
|
|
148
|
+
options: [
|
|
149
|
+
{ name: 'None', value: -2 },
|
|
150
|
+
{ name: 'Low', value: -1 },
|
|
151
|
+
{ name: 'Medium', value: 0 },
|
|
152
|
+
{ name: 'High', value: 1 },
|
|
153
|
+
],
|
|
154
|
+
default: -2,
|
|
155
|
+
description: 'Priority level.',
|
|
156
|
+
},
|
|
157
|
+
{ displayName: 'Other Contact IDs', name: 'OtherContactIds', type: 'string', typeOptions: { multipleValues: true }, default: [], description: 'Additional related contact IDs (GUIDs).' },
|
|
158
|
+
{ displayName: 'Custom Fields (JSON)', name: 'Fields', type: 'json', default: '', placeholder: '{ "Field_XXXX_0_YY": "value" }', description: 'JSON object of custom fields.' },
|
|
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',
|
|
161
|
+
options: [
|
|
162
|
+
{ name: 'Owner', value: 'Owner' },
|
|
163
|
+
{ name: 'Owner Group', value: 'OwnerGroup' },
|
|
164
|
+
{ name: 'Owner SubGroup', value: 'OwnerSubGroup' },
|
|
165
|
+
{ name: 'All', value: 'All' },
|
|
166
|
+
],
|
|
167
|
+
default: 'Owner',
|
|
168
|
+
description: 'Visibility setting for this case.',
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
},
|
|
172
|
+
];
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.productCreate = productCreate;
|
|
4
|
+
const http_1 = require("../../lib/http");
|
|
5
|
+
async function productCreate(i, returnData) {
|
|
6
|
+
var _a;
|
|
7
|
+
// 1) Read main params
|
|
8
|
+
const title = this.getNodeParameter('Title', i, '');
|
|
9
|
+
if (!(title === null || title === void 0 ? void 0 : title.trim()))
|
|
10
|
+
throw new Error('Title is required.');
|
|
11
|
+
const code = this.getNodeParameter('Code', i, '');
|
|
12
|
+
const unit = this.getNodeParameter('Unit', i, '');
|
|
13
|
+
const unitPrice = this.getNodeParameter('UnitPrice', i, 0);
|
|
14
|
+
const productCategoryId = this.getNodeParameter('ProductCategoryId', i, '');
|
|
15
|
+
const isActive = this.getNodeParameter('IsActive', i, true);
|
|
16
|
+
const description = this.getNodeParameter('Description', i, '');
|
|
17
|
+
// 2) Variants (optional)
|
|
18
|
+
// const variantsUi = (this.getNodeParameter('Variants', i, {}) as IDataObject) || {};
|
|
19
|
+
// let variants: IDataObject[] | undefined;
|
|
20
|
+
// if (variantsUi && typeof variantsUi === 'object' && Array.isArray((variantsUi as any).Variant)) {
|
|
21
|
+
// variants = ((variantsUi as any).Variant as IDataObject[])
|
|
22
|
+
// .filter(v => v && typeof v === 'object')
|
|
23
|
+
// .map(v => {
|
|
24
|
+
// const vTitle = (v.Title as string) ?? '';
|
|
25
|
+
// if (!vTitle?.trim()) throw new Error('Each Variant requires a Title.');
|
|
26
|
+
// const vCode = (v.VariantCode as string) ?? '';
|
|
27
|
+
// const vPrice = (typeof v.UnitPrice === 'number') ? (v.UnitPrice as number) : 0;
|
|
28
|
+
// return {
|
|
29
|
+
// Title: vTitle,
|
|
30
|
+
// TitleForInvoice: vTitle, // hidden rule
|
|
31
|
+
// IsDeleted: false, // hidden rule
|
|
32
|
+
// IsDefault: true, // hidden rule
|
|
33
|
+
// UnitPrice: vPrice,
|
|
34
|
+
// VariantCode: vCode,
|
|
35
|
+
// } as IDataObject;
|
|
36
|
+
// });
|
|
37
|
+
// if (!variants.length) variants = undefined;
|
|
38
|
+
// }
|
|
39
|
+
// 2) Variants (dynamic JSON)
|
|
40
|
+
let variants;
|
|
41
|
+
const variantsUi = this.getNodeParameter('Variants', i, '[]');
|
|
42
|
+
// نرمالسازی: هم رشتهٔ JSON قبول کن، هم آبجکت/آرایه (اگر از expression آمده باشد)
|
|
43
|
+
let parsed;
|
|
44
|
+
if (typeof variantsUi === 'string') {
|
|
45
|
+
const trimmed = variantsUi.trim();
|
|
46
|
+
if (trimmed) {
|
|
47
|
+
try {
|
|
48
|
+
parsed = JSON.parse(trimmed);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
throw new Error('Invalid JSON in "Variants". It must be a JSON array of objects.');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
parsed = [];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
parsed = variantsUi;
|
|
60
|
+
}
|
|
61
|
+
// باید آرایهٔ آبجکت باشد
|
|
62
|
+
if (parsed != null) {
|
|
63
|
+
if (!Array.isArray(parsed))
|
|
64
|
+
throw new Error('"Variants" must be an array.');
|
|
65
|
+
// Map و validate
|
|
66
|
+
variants = parsed.map((v, idx) => {
|
|
67
|
+
var _a, _b, _c;
|
|
68
|
+
if (typeof v !== 'object' || v == null) {
|
|
69
|
+
throw new Error(`"Variants[${idx}]" must be an object.`);
|
|
70
|
+
}
|
|
71
|
+
const vTitle = ((_a = v.Title) !== null && _a !== void 0 ? _a : '').toString();
|
|
72
|
+
if (!vTitle.trim())
|
|
73
|
+
throw new Error(`"Variants[${idx}].Title" is required.`);
|
|
74
|
+
const vCode = ((_b = v.VariantCode) !== null && _b !== void 0 ? _b : '').toString();
|
|
75
|
+
const vPrice = typeof v.UnitPrice === 'number' ? v.UnitPrice : Number((_c = v.UnitPrice) !== null && _c !== void 0 ? _c : 0) || 0;
|
|
76
|
+
return {
|
|
77
|
+
Title: vTitle,
|
|
78
|
+
TitleForInvoice: vTitle, // hidden rule
|
|
79
|
+
IsDeleted: false, // hidden rule
|
|
80
|
+
IsDefault: true, // hidden rule
|
|
81
|
+
UnitPrice: vPrice,
|
|
82
|
+
VariantCode: vCode,
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
if (!variants.length)
|
|
86
|
+
variants = undefined;
|
|
87
|
+
}
|
|
88
|
+
// 3) Fields (JSON)
|
|
89
|
+
let fields;
|
|
90
|
+
const fieldsUi = this.getNodeParameter('Fields', i, '');
|
|
91
|
+
if (typeof fieldsUi === 'string' && fieldsUi.trim()) {
|
|
92
|
+
try {
|
|
93
|
+
fields = JSON.parse(fieldsUi);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
throw new Error('Invalid JSON in "Custom Fields (JSON)".');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else if (typeof fieldsUi === 'object' && fieldsUi) {
|
|
100
|
+
fields = fieldsUi;
|
|
101
|
+
}
|
|
102
|
+
// 4) Build payload
|
|
103
|
+
const product = {
|
|
104
|
+
Title: title,
|
|
105
|
+
Code: code,
|
|
106
|
+
Unit: unit,
|
|
107
|
+
UnitPrice: typeof unitPrice === 'number' ? unitPrice : Number(unitPrice) || 0,
|
|
108
|
+
Description: description,
|
|
109
|
+
IsActive: !!isActive,
|
|
110
|
+
};
|
|
111
|
+
if (productCategoryId)
|
|
112
|
+
product['ProductCategoryId'] = productCategoryId;
|
|
113
|
+
if (variants)
|
|
114
|
+
product['Variants'] = variants;
|
|
115
|
+
if (fields)
|
|
116
|
+
product['Fields'] = fields;
|
|
117
|
+
const body = { Product: product };
|
|
118
|
+
// 5) Request
|
|
119
|
+
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
120
|
+
method: 'POST',
|
|
121
|
+
path: '/api/product/save',
|
|
122
|
+
body,
|
|
123
|
+
});
|
|
124
|
+
returnData.push({ json: ((_a = resp === null || resp === void 0 ? void 0 : resp.Response) !== null && _a !== void 0 ? _a : resp) });
|
|
125
|
+
return returnData;
|
|
126
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.productCreateProperties = void 0;
|
|
4
|
+
const showForProductCreate = { show: { resource: ['product'], operation: ['create'] } };
|
|
5
|
+
exports.productCreateProperties = [
|
|
6
|
+
// ===== Main (ordered) =====
|
|
7
|
+
{
|
|
8
|
+
displayName: 'Title',
|
|
9
|
+
name: 'Title',
|
|
10
|
+
type: 'string',
|
|
11
|
+
default: '',
|
|
12
|
+
required: true,
|
|
13
|
+
displayOptions: showForProductCreate,
|
|
14
|
+
description: 'Product title. Required.',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
displayName: 'Code',
|
|
18
|
+
name: 'Code',
|
|
19
|
+
type: 'string',
|
|
20
|
+
default: '',
|
|
21
|
+
displayOptions: showForProductCreate,
|
|
22
|
+
description: 'Internal product code (optional).',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
displayName: 'Product Category',
|
|
26
|
+
name: 'ProductCategoryId',
|
|
27
|
+
type: 'options',
|
|
28
|
+
typeOptions: { loadOptionsMethod: 'getProductCategories' },
|
|
29
|
+
default: '',
|
|
30
|
+
displayOptions: showForProductCreate,
|
|
31
|
+
description: 'Select a product category (optional).',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
displayName: 'Unit',
|
|
35
|
+
name: 'Unit',
|
|
36
|
+
type: 'string',
|
|
37
|
+
default: '',
|
|
38
|
+
displayOptions: showForProductCreate,
|
|
39
|
+
description: 'Unit name (e.g., USD, item, box).',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
displayName: 'Unit Price',
|
|
43
|
+
name: 'UnitPrice',
|
|
44
|
+
type: 'number',
|
|
45
|
+
typeOptions: { numberPrecision: 10 },
|
|
46
|
+
default: 0,
|
|
47
|
+
displayOptions: showForProductCreate,
|
|
48
|
+
description: 'Base price for the product.',
|
|
49
|
+
},
|
|
50
|
+
// Variants (optional, list)
|
|
51
|
+
// {
|
|
52
|
+
// displayName: 'Variants',
|
|
53
|
+
// name: 'Variants',
|
|
54
|
+
// type: 'fixedCollection',
|
|
55
|
+
// typeOptions: { multipleValues: true },
|
|
56
|
+
// default: {},
|
|
57
|
+
// displayOptions: showForProductCreate,
|
|
58
|
+
// options: [
|
|
59
|
+
// {
|
|
60
|
+
// name: 'Variant',
|
|
61
|
+
// displayName: 'Variant',
|
|
62
|
+
// values: [
|
|
63
|
+
// {
|
|
64
|
+
// displayName: 'Title',
|
|
65
|
+
// name: 'Title',
|
|
66
|
+
// type: 'string',
|
|
67
|
+
// default: '',
|
|
68
|
+
// description: 'Variant title. Required.',
|
|
69
|
+
// },
|
|
70
|
+
// {
|
|
71
|
+
// displayName: 'Variant Code',
|
|
72
|
+
// name: 'VariantCode',
|
|
73
|
+
// type: 'string',
|
|
74
|
+
// default: '',
|
|
75
|
+
// description: 'Variant code (optional).',
|
|
76
|
+
// },
|
|
77
|
+
// {
|
|
78
|
+
// displayName: 'Unit Price',
|
|
79
|
+
// name: 'UnitPrice',
|
|
80
|
+
// type: 'number',
|
|
81
|
+
// typeOptions: { numberPrecision: 10 },
|
|
82
|
+
// default: 0,
|
|
83
|
+
// description: 'Variant price (optional; defaults to 0).',
|
|
84
|
+
// },
|
|
85
|
+
// // نکته: TitleForInvoice, IsDeleted, IsDefault در UI نمایش داده نمیشوند — در operation ست میکنیم.
|
|
86
|
+
// ],
|
|
87
|
+
// },
|
|
88
|
+
// ],
|
|
89
|
+
// description: 'Optional list of variants.',
|
|
90
|
+
// },
|
|
91
|
+
{
|
|
92
|
+
displayName: 'Variants',
|
|
93
|
+
name: 'Variants',
|
|
94
|
+
type: 'json',
|
|
95
|
+
default: '[]',
|
|
96
|
+
displayOptions: showForProductCreate,
|
|
97
|
+
description: 'JSON array of variant objects. Example: ' +
|
|
98
|
+
'[{"Title":"V1","VariantCode":"A1","UnitPrice":1000},{"Title":"V2","VariantCode":"A2", "UnitPrice":0}]',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
displayName: 'Active',
|
|
102
|
+
name: 'IsActive',
|
|
103
|
+
type: 'boolean',
|
|
104
|
+
default: true,
|
|
105
|
+
displayOptions: showForProductCreate,
|
|
106
|
+
description: 'Whether the product is active.',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
displayName: 'Description',
|
|
110
|
+
name: 'Description',
|
|
111
|
+
type: 'string',
|
|
112
|
+
default: '',
|
|
113
|
+
displayOptions: showForProductCreate,
|
|
114
|
+
description: 'Optional description.',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
displayName: 'Custom Fields (JSON)',
|
|
118
|
+
name: 'Fields',
|
|
119
|
+
type: 'json',
|
|
120
|
+
default: '',
|
|
121
|
+
placeholder: '{ "Field_6_0_26": "value" }',
|
|
122
|
+
displayOptions: showForProductCreate,
|
|
123
|
+
description: 'JSON object of custom fields.',
|
|
124
|
+
},
|
|
125
|
+
];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.productUpdateProperties = exports.productUpdate = exports.productCreateProperties = exports.productCreate = void 0;
|
|
4
|
+
// nodes/product/index.ts
|
|
5
|
+
var create_operation_1 = require("./create.operation");
|
|
6
|
+
Object.defineProperty(exports, "productCreate", { enumerable: true, get: function () { return create_operation_1.productCreate; } });
|
|
7
|
+
var create_properties_1 = require("./create.properties");
|
|
8
|
+
Object.defineProperty(exports, "productCreateProperties", { enumerable: true, get: function () { return create_properties_1.productCreateProperties; } });
|
|
9
|
+
var update_operation_1 = require("./update.operation");
|
|
10
|
+
Object.defineProperty(exports, "productUpdate", { enumerable: true, get: function () { return update_operation_1.productUpdate; } });
|
|
11
|
+
var update_properties_1 = require("./update.properties");
|
|
12
|
+
Object.defineProperty(exports, "productUpdateProperties", { enumerable: true, get: function () { return update_properties_1.productUpdateProperties; } });
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.productUpdate = productUpdate;
|
|
4
|
+
const http_1 = require("../../lib/http");
|
|
5
|
+
async function productUpdate(i, returnData) {
|
|
6
|
+
var _a;
|
|
7
|
+
// 1) Main params
|
|
8
|
+
const id = this.getNodeParameter('Id', i, '');
|
|
9
|
+
if (!(id === null || id === void 0 ? void 0 : id.trim()))
|
|
10
|
+
throw new Error('Product ID is required.');
|
|
11
|
+
const title = this.getNodeParameter('Title', i, '');
|
|
12
|
+
if (!(title === null || title === void 0 ? void 0 : title.trim()))
|
|
13
|
+
throw new Error('Title is required.');
|
|
14
|
+
const code = this.getNodeParameter('Code', i, '');
|
|
15
|
+
const unit = this.getNodeParameter('Unit', i, '');
|
|
16
|
+
const unitPrice = this.getNodeParameter('UnitPrice', i, 0);
|
|
17
|
+
const productCategoryId = this.getNodeParameter('ProductCategoryId', i, '');
|
|
18
|
+
const isActive = this.getNodeParameter('IsActive', i, true);
|
|
19
|
+
const description = this.getNodeParameter('Description', i, '');
|
|
20
|
+
// 2) Variants (dynamic JSON, each may include Id)
|
|
21
|
+
let variants;
|
|
22
|
+
const variantsUi = this.getNodeParameter('Variants', i, '[]');
|
|
23
|
+
let parsed;
|
|
24
|
+
if (typeof variantsUi === 'string') {
|
|
25
|
+
const trimmed = variantsUi.trim();
|
|
26
|
+
if (trimmed) {
|
|
27
|
+
try {
|
|
28
|
+
parsed = JSON.parse(trimmed);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
throw new Error('Invalid JSON in "Variants". It must be a JSON array of objects.');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
parsed = [];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
parsed = variantsUi;
|
|
40
|
+
}
|
|
41
|
+
if (parsed != null) {
|
|
42
|
+
if (!Array.isArray(parsed))
|
|
43
|
+
throw new Error('"Variants" must be an array.');
|
|
44
|
+
variants = parsed.map((v, idx) => {
|
|
45
|
+
var _a, _b, _c;
|
|
46
|
+
if (typeof v !== 'object' || v == null) {
|
|
47
|
+
throw new Error(`"Variants[${idx}]" must be an object.`);
|
|
48
|
+
}
|
|
49
|
+
const vTitle = ((_a = v.Title) !== null && _a !== void 0 ? _a : '').toString();
|
|
50
|
+
if (!vTitle.trim())
|
|
51
|
+
throw new Error(`"Variants[${idx}].Title" is required.`);
|
|
52
|
+
const vCode = ((_b = v.VariantCode) !== null && _b !== void 0 ? _b : '').toString();
|
|
53
|
+
const vPrice = typeof v.UnitPrice === 'number' ? v.UnitPrice : Number((_c = v.UnitPrice) !== null && _c !== void 0 ? _c : 0) || 0;
|
|
54
|
+
const variant = {
|
|
55
|
+
Title: vTitle,
|
|
56
|
+
TitleForInvoice: vTitle, // hidden rule (same as create)
|
|
57
|
+
IsDeleted: false, // hidden rule
|
|
58
|
+
IsDefault: true, // hidden rule
|
|
59
|
+
UnitPrice: vPrice,
|
|
60
|
+
VariantCode: vCode,
|
|
61
|
+
};
|
|
62
|
+
// If variant Id provided (update existing variant)
|
|
63
|
+
if (typeof v.Id === 'string' && v.Id.trim()) {
|
|
64
|
+
variant['Id'] = v.Id.trim();
|
|
65
|
+
}
|
|
66
|
+
return variant;
|
|
67
|
+
});
|
|
68
|
+
if (!variants.length)
|
|
69
|
+
variants = undefined;
|
|
70
|
+
}
|
|
71
|
+
// 3) Fields (JSON)
|
|
72
|
+
let fields;
|
|
73
|
+
const fieldsUi = this.getNodeParameter('Fields', i, '');
|
|
74
|
+
if (typeof fieldsUi === 'string' && fieldsUi.trim()) {
|
|
75
|
+
try {
|
|
76
|
+
fields = JSON.parse(fieldsUi);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
throw new Error('Invalid JSON in "Custom Fields (JSON)".');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else if (typeof fieldsUi === 'object' && fieldsUi) {
|
|
83
|
+
fields = fieldsUi;
|
|
84
|
+
}
|
|
85
|
+
// 4) Build payload
|
|
86
|
+
const product = {
|
|
87
|
+
Id: id,
|
|
88
|
+
Title: title,
|
|
89
|
+
Code: code,
|
|
90
|
+
Unit: unit,
|
|
91
|
+
UnitPrice: typeof unitPrice === 'number' ? unitPrice : Number(unitPrice) || 0,
|
|
92
|
+
Description: description,
|
|
93
|
+
IsActive: !!isActive,
|
|
94
|
+
};
|
|
95
|
+
if (productCategoryId)
|
|
96
|
+
product['ProductCategoryId'] = productCategoryId;
|
|
97
|
+
if (variants)
|
|
98
|
+
product['Variants'] = variants;
|
|
99
|
+
if (fields)
|
|
100
|
+
product['Fields'] = fields;
|
|
101
|
+
const body = { Product: product };
|
|
102
|
+
// 5) Request
|
|
103
|
+
const resp = await (0, http_1.didarRequest)(this, i, {
|
|
104
|
+
method: 'POST',
|
|
105
|
+
path: '/api/product/save',
|
|
106
|
+
body,
|
|
107
|
+
});
|
|
108
|
+
returnData.push({ json: ((_a = resp === null || resp === void 0 ? void 0 : resp.Response) !== null && _a !== void 0 ? _a : resp) });
|
|
109
|
+
return returnData;
|
|
110
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.productUpdateProperties = void 0;
|
|
4
|
+
const showForProductUpdate = { show: { resource: ['product'], operation: ['update'] } };
|
|
5
|
+
exports.productUpdateProperties = [
|
|
6
|
+
// ===== Main (ordered) =====
|
|
7
|
+
{
|
|
8
|
+
displayName: 'Product ID',
|
|
9
|
+
name: 'Id',
|
|
10
|
+
type: 'string',
|
|
11
|
+
default: '',
|
|
12
|
+
required: true,
|
|
13
|
+
displayOptions: showForProductUpdate,
|
|
14
|
+
description: 'The ID of the product to update. Required.',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
displayName: 'Title',
|
|
18
|
+
name: 'Title',
|
|
19
|
+
type: 'string',
|
|
20
|
+
default: '',
|
|
21
|
+
required: true,
|
|
22
|
+
displayOptions: showForProductUpdate,
|
|
23
|
+
description: 'Product title. Required.',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
displayName: 'Code',
|
|
27
|
+
name: 'Code',
|
|
28
|
+
type: 'string',
|
|
29
|
+
default: '',
|
|
30
|
+
displayOptions: showForProductUpdate,
|
|
31
|
+
description: 'Internal product code (optional).',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
displayName: 'Product Category',
|
|
35
|
+
name: 'ProductCategoryId',
|
|
36
|
+
type: 'options',
|
|
37
|
+
typeOptions: { loadOptionsMethod: 'getProductCategories' },
|
|
38
|
+
default: '',
|
|
39
|
+
displayOptions: showForProductUpdate,
|
|
40
|
+
description: 'Select a product category (optional).',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
displayName: 'Unit',
|
|
44
|
+
name: 'Unit',
|
|
45
|
+
type: 'string',
|
|
46
|
+
default: '',
|
|
47
|
+
displayOptions: showForProductUpdate,
|
|
48
|
+
description: 'Unit name (e.g., USD, item, box).',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
displayName: 'Unit Price',
|
|
52
|
+
name: 'UnitPrice',
|
|
53
|
+
type: 'number',
|
|
54
|
+
typeOptions: { numberPrecision: 10 },
|
|
55
|
+
default: 0,
|
|
56
|
+
displayOptions: showForProductUpdate,
|
|
57
|
+
description: 'Base price for the product.',
|
|
58
|
+
},
|
|
59
|
+
// Variants as dynamic JSON (each item may include Id on update)
|
|
60
|
+
{
|
|
61
|
+
displayName: 'Variants',
|
|
62
|
+
name: 'Variants',
|
|
63
|
+
type: 'json',
|
|
64
|
+
default: '[]',
|
|
65
|
+
displayOptions: showForProductUpdate,
|
|
66
|
+
description: 'JSON array of variant objects. For update, each item may include "Id". ' +
|
|
67
|
+
'Example: ' +
|
|
68
|
+
'[{"Id":"<GUID>","Title":"V1","VariantCode":"A1","UnitPrice":1000},' +
|
|
69
|
+
'{"Id":"<GUID>","Title":"V2","VariantCode":"A2","UnitPrice":0}]',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
displayName: 'Active',
|
|
73
|
+
name: 'IsActive',
|
|
74
|
+
type: 'boolean',
|
|
75
|
+
default: true,
|
|
76
|
+
displayOptions: showForProductUpdate,
|
|
77
|
+
description: 'Whether the product is active.',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
displayName: 'Description',
|
|
81
|
+
name: 'Description',
|
|
82
|
+
type: 'string',
|
|
83
|
+
default: '',
|
|
84
|
+
displayOptions: showForProductUpdate,
|
|
85
|
+
description: 'Optional description.',
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
displayName: 'Custom Fields (JSON)',
|
|
89
|
+
name: 'Fields',
|
|
90
|
+
type: 'json',
|
|
91
|
+
default: '',
|
|
92
|
+
placeholder: '{ "Field_6_0_26": "value" }',
|
|
93
|
+
displayOptions: showForProductUpdate,
|
|
94
|
+
description: 'JSON object of custom fields.',
|
|
95
|
+
},
|
|
96
|
+
];
|