@limetech/n8n-nodes-lime 2.3.1-dev.1 → 2.5.0-dev.1
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/.github/workflows/lint.yml +1 -1
- package/.github/workflows/release.yml +16 -2
- package/.github/workflows/test-and-build.yml +0 -15
- package/CHANGELOG.md +35 -2
- package/nodes/errorHandling.ts +60 -0
- package/nodes/lime-crm/LimeCrmNode.node.ts +8 -0
- package/nodes/lime-crm/LimeCrmTrigger.node.ts +19 -5
- package/nodes/lime-crm/methods/getLimetypeProperties.ts +3 -1
- package/nodes/lime-crm/methods/getLimetypes.ts +2 -1
- package/nodes/lime-crm/methods/index.ts +5 -0
- package/nodes/lime-crm/methods/resourceMapping.ts +141 -0
- package/nodes/lime-crm/models/limetype.ts +18 -0
- package/nodes/lime-crm/resources/admin/index.ts +9 -4
- package/nodes/lime-crm/resources/admin/operations/getManyUsers.operation.ts +10 -2
- package/nodes/lime-crm/resources/admin/operations/getSingleUser.operation.ts +14 -15
- package/nodes/lime-crm/resources/data/index.ts +15 -6
- package/nodes/lime-crm/resources/data/operations/createSingleObject.operation.ts +25 -71
- package/nodes/lime-crm/resources/data/operations/deleteSingleObject.operation.ts +7 -2
- package/nodes/lime-crm/resources/data/operations/getManyObjects.operation.ts +6 -2
- package/nodes/lime-crm/resources/data/operations/getSingleFile.operation.ts +15 -3
- package/nodes/lime-crm/resources/data/operations/getSingleObject.operation.ts +15 -6
- package/nodes/lime-crm/resources/data/operations/updateSingleObject.operation.ts +41 -57
- package/nodes/lime-crm/resources/metadata/index.ts +7 -3
- package/nodes/lime-crm/resources/metadata/operations/getAllLimetypes.operation.ts +6 -2
- package/nodes/lime-crm/resources/metadata/operations/getSingleFileMetadata.operation.ts +18 -15
- package/nodes/lime-crm/resources/metadata/operations/getSingleLimetype.operation.ts +8 -3
- package/nodes/lime-crm/transport/commons.ts +34 -20
- package/nodes/lime-crm/transport/files.ts +72 -47
- package/nodes/lime-crm/transport/limeQuery.ts +2 -2
- package/nodes/lime-crm/transport/limeobjects.ts +22 -10
- package/nodes/lime-crm/transport/limetypes.ts +37 -16
- package/nodes/lime-crm/transport/users.ts +74 -38
- package/nodes/lime-crm/transport/webhooks.ts +5 -4
- package/nodes/lime-crm/utils/files.ts +27 -10
- package/nodes/lime-crm/utils/index.ts +1 -1
- package/nodes/response.ts +41 -3
- package/package.json +4 -2
- package/tests/nodes/lime-crm/methods.spec.ts +91 -0
- package/tests/nodes/lime-crm/utils.spec.ts +60 -25
- package/nodes/lime-crm/utils/propertyAdapters.ts +0 -75
- package/restore_script/README +0 -42
- package/restore_script/api_key_upload.txt +0 -0
- package/restore_script/cli.py +0 -73
- package/restore_script/download.py +0 -73
- package/restore_script/main.py +0 -19
- package/restore_script/poetry.lock +0 -162
- package/restore_script/pyproject.toml +0 -15
- package/restore_script/transfer.py +0 -41
- package/restore_script/upload.py +0 -66
- package/restore_script/utils.py +0 -42
- /package/{restore_script/api_key_download.txt → Dockerfile} +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { IDataObject, IExecuteFunctions, INodeProperties } from 'n8n-workflow';
|
|
2
2
|
|
|
3
3
|
import { createLimeobject, getProperties } from '../../../transport';
|
|
4
|
-
import { DATA_RESOURCE
|
|
4
|
+
import { DATA_RESOURCE } from '../../../models';
|
|
5
5
|
import {
|
|
6
|
-
adaptProperty,
|
|
7
6
|
getFilePropertiesNames,
|
|
8
|
-
getPropertyType,
|
|
9
7
|
processFileResponse,
|
|
10
8
|
setFileProperties,
|
|
11
9
|
} from '../../../utils';
|
|
12
10
|
|
|
11
|
+
import { parseResourceMapperFields } from '../../../methods';
|
|
12
|
+
|
|
13
13
|
/**
|
|
14
14
|
* Description and metadata for the "Create Single Object" operation in Lime CRM.
|
|
15
15
|
*
|
|
@@ -76,12 +76,20 @@ export const properties: INodeProperties[] = [
|
|
|
76
76
|
{
|
|
77
77
|
displayName: 'Properties',
|
|
78
78
|
name: 'properties',
|
|
79
|
-
type: '
|
|
79
|
+
type: 'resourceMapper',
|
|
80
80
|
placeholder: 'Add Property',
|
|
81
81
|
typeOptions: {
|
|
82
|
-
|
|
82
|
+
resourceMapper: {
|
|
83
|
+
resourceMapperMethod: 'getCreateMappingColumns',
|
|
84
|
+
mode: 'add',
|
|
85
|
+
addAllFields: false,
|
|
86
|
+
supportAutoMap: false,
|
|
87
|
+
},
|
|
88
|
+
loadOptionsDependsOn: ['limetype'],
|
|
89
|
+
},
|
|
90
|
+
default: {
|
|
91
|
+
value: null,
|
|
83
92
|
},
|
|
84
|
-
default: {},
|
|
85
93
|
displayOptions: {
|
|
86
94
|
show: {
|
|
87
95
|
resource: [DATA_RESOURCE],
|
|
@@ -89,33 +97,6 @@ export const properties: INodeProperties[] = [
|
|
|
89
97
|
inputMethod: ['fields'],
|
|
90
98
|
},
|
|
91
99
|
},
|
|
92
|
-
options: [
|
|
93
|
-
{
|
|
94
|
-
displayName: 'Property',
|
|
95
|
-
name: 'property',
|
|
96
|
-
values: [
|
|
97
|
-
{
|
|
98
|
-
displayName: 'Property Name',
|
|
99
|
-
name: 'name',
|
|
100
|
-
type: 'options',
|
|
101
|
-
typeOptions: {
|
|
102
|
-
sortable: true,
|
|
103
|
-
loadOptionsMethod: 'getNoHasManyProperties',
|
|
104
|
-
loadOptionsDependsOn: ['limetype'],
|
|
105
|
-
},
|
|
106
|
-
default: '',
|
|
107
|
-
description: 'Name of the property',
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
displayName: 'Property Value',
|
|
111
|
-
name: 'value',
|
|
112
|
-
type: 'string',
|
|
113
|
-
default: '',
|
|
114
|
-
description: 'Value of the property',
|
|
115
|
-
},
|
|
116
|
-
],
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
100
|
},
|
|
120
101
|
{
|
|
121
102
|
displayName: 'Object (JSON)',
|
|
@@ -136,39 +117,6 @@ export const properties: INodeProperties[] = [
|
|
|
136
117
|
},
|
|
137
118
|
];
|
|
138
119
|
|
|
139
|
-
/**
|
|
140
|
-
*
|
|
141
|
-
* @param context - Node execution context
|
|
142
|
-
* @param i - The index of the current item in the workflow execution
|
|
143
|
-
* @param properties - List of {@link LimeTypeProperty} fetched from Lime CRM
|
|
144
|
-
* @returns IDataObject - parsed data from Simple Fields mode
|
|
145
|
-
*/
|
|
146
|
-
function parseSimpleFieldsData(
|
|
147
|
-
context: IExecuteFunctions,
|
|
148
|
-
i: number,
|
|
149
|
-
properties: LimetypeProperty[]
|
|
150
|
-
): IDataObject {
|
|
151
|
-
const objectData: IDataObject = {};
|
|
152
|
-
const propertiesInput = context.getNodeParameter(
|
|
153
|
-
'properties.property',
|
|
154
|
-
i,
|
|
155
|
-
[]
|
|
156
|
-
) as IDataObject[];
|
|
157
|
-
|
|
158
|
-
if (propertiesInput && propertiesInput.length > 0) {
|
|
159
|
-
for (const prop of propertiesInput) {
|
|
160
|
-
if (prop.name && prop.value !== undefined) {
|
|
161
|
-
const propertyName = prop.name as string;
|
|
162
|
-
objectData[propertyName] = adaptProperty(
|
|
163
|
-
prop.value as string,
|
|
164
|
-
getPropertyType(propertyName, properties)
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return objectData;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
120
|
/**
|
|
173
121
|
* Execute the "Create Single Object" operation for Lime CRM.
|
|
174
122
|
*
|
|
@@ -195,13 +143,16 @@ export async function execute(this: IExecuteFunctions, i: number) {
|
|
|
195
143
|
|
|
196
144
|
let objectData: IDataObject;
|
|
197
145
|
|
|
198
|
-
const
|
|
146
|
+
const propertiesResponse = await getProperties(this, limetype);
|
|
147
|
+
if (!propertiesResponse.success) return propertiesResponse.data;
|
|
148
|
+
|
|
149
|
+
const properties = propertiesResponse.data;
|
|
199
150
|
|
|
200
151
|
if (inputMethod === 'json') {
|
|
201
152
|
const jsonInput = this.getNodeParameter('objectJson', i) as string;
|
|
202
153
|
objectData = JSON.parse(jsonInput);
|
|
203
154
|
} else {
|
|
204
|
-
objectData =
|
|
155
|
+
objectData = parseResourceMapperFields(this, i, 'properties');
|
|
205
156
|
}
|
|
206
157
|
|
|
207
158
|
const fileProperties = getFilePropertiesNames(
|
|
@@ -215,17 +166,20 @@ export async function execute(this: IExecuteFunctions, i: number) {
|
|
|
215
166
|
fileProperties,
|
|
216
167
|
objectData
|
|
217
168
|
);
|
|
169
|
+
if (!setFilePropertiesResponse.success)
|
|
170
|
+
return setFilePropertiesResponse.data;
|
|
218
171
|
|
|
219
172
|
const createLimeobjectResponse = await createLimeobject(
|
|
220
173
|
this,
|
|
221
174
|
limetype,
|
|
222
|
-
setFilePropertiesResponse
|
|
175
|
+
setFilePropertiesResponse.data
|
|
223
176
|
);
|
|
177
|
+
if (!createLimeobjectResponse.success) return createLimeobjectResponse.data;
|
|
224
178
|
|
|
225
179
|
const response = await processFileResponse(
|
|
226
180
|
this,
|
|
227
181
|
fileProperties,
|
|
228
|
-
createLimeobjectResponse
|
|
182
|
+
createLimeobjectResponse.data
|
|
229
183
|
);
|
|
230
|
-
return response.json;
|
|
184
|
+
return response.json.data;
|
|
231
185
|
}
|
|
@@ -2,6 +2,7 @@ import { IExecuteFunctions, INodeProperties } from 'n8n-workflow';
|
|
|
2
2
|
|
|
3
3
|
import { deleteLimeobject } from '../../../transport';
|
|
4
4
|
import { DATA_RESOURCE } from '../../../models';
|
|
5
|
+
import { WorkflowResponse } from '../../../../response';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Description and metadata for the "Delete Single Object" operation in Lime CRM.
|
|
@@ -75,9 +76,13 @@ export const properties: INodeProperties[] = [
|
|
|
75
76
|
*
|
|
76
77
|
* @public
|
|
77
78
|
*/
|
|
78
|
-
export async function execute(
|
|
79
|
+
export async function execute(
|
|
80
|
+
this: IExecuteFunctions,
|
|
81
|
+
i: number
|
|
82
|
+
): Promise<WorkflowResponse<Record<string, never>>> {
|
|
79
83
|
const limetype = this.getNodeParameter('limetype', i) as string;
|
|
80
84
|
const objectId = this.getNodeParameter('objectId', i) as string;
|
|
81
85
|
|
|
82
|
-
|
|
86
|
+
const response = await deleteLimeobject(this, limetype, objectId);
|
|
87
|
+
return response.data;
|
|
83
88
|
}
|
|
@@ -2,6 +2,7 @@ import { IExecuteFunctions, INodeProperties } from 'n8n-workflow';
|
|
|
2
2
|
|
|
3
3
|
import { IncludedProperties, queryLimeobjects } from '../../../transport';
|
|
4
4
|
import { DATA_RESOURCE, DEFAULT_API_OBJECT_LIMIT } from '../../../models';
|
|
5
|
+
import { WorkflowResponse } from '../../../../response';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Description and metadata for the "Get Many Objects" operation in Lime CRM.
|
|
@@ -389,7 +390,7 @@ async function fetchLimeObjects(
|
|
|
389
390
|
filter: string,
|
|
390
391
|
limit: number | null,
|
|
391
392
|
orderBy: Record<string, 'ASC' | 'DESC'>[]
|
|
392
|
-
): Promise<IncludedProperties[]
|
|
393
|
+
): Promise<WorkflowResponse<IncludedProperties[]>> {
|
|
393
394
|
const allResults: IncludedProperties[] = [];
|
|
394
395
|
const parsedFilter = JSON.parse(filter);
|
|
395
396
|
const unlimited = limit === null || limit === 0;
|
|
@@ -413,7 +414,10 @@ async function fetchLimeObjects(
|
|
|
413
414
|
orderBy: orderBy,
|
|
414
415
|
});
|
|
415
416
|
|
|
416
|
-
const
|
|
417
|
+
const batchResponse = await queryLimeobjects(this, q);
|
|
418
|
+
if (!batchResponse.success) return batchResponse.data;
|
|
419
|
+
|
|
420
|
+
const batch = batchResponse.data;
|
|
417
421
|
|
|
418
422
|
const collected = batch.objects.length;
|
|
419
423
|
if (collected === 0) break;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
IExecuteFunctions,
|
|
3
|
+
INodeExecutionData,
|
|
3
4
|
INodeProperties,
|
|
4
5
|
NodeOperationError,
|
|
5
6
|
} from 'n8n-workflow';
|
|
@@ -125,15 +126,22 @@ export const properties: INodeProperties[] = [
|
|
|
125
126
|
*
|
|
126
127
|
* @public
|
|
127
128
|
*/
|
|
128
|
-
export async function execute(
|
|
129
|
+
export async function execute(
|
|
130
|
+
this: IExecuteFunctions,
|
|
131
|
+
i: number
|
|
132
|
+
): Promise<INodeExecutionData> {
|
|
129
133
|
const source = this.getNodeParameter('source', i) as string;
|
|
130
134
|
const id = this.getNodeParameter('identifier', i) as string;
|
|
131
135
|
|
|
132
136
|
if (source == 'byFile') {
|
|
133
137
|
const fileResponse = await getFileContent(this, id);
|
|
138
|
+
if (!fileResponse.success)
|
|
139
|
+
return {
|
|
140
|
+
json: fileResponse.data,
|
|
141
|
+
};
|
|
134
142
|
return {
|
|
135
143
|
json: {},
|
|
136
|
-
binary: { data: fileResponse },
|
|
144
|
+
binary: { data: fileResponse.data },
|
|
137
145
|
};
|
|
138
146
|
}
|
|
139
147
|
if (source == 'byLimeobject') {
|
|
@@ -146,11 +154,15 @@ export async function execute(this: IExecuteFunctions, i: number) {
|
|
|
146
154
|
id,
|
|
147
155
|
property
|
|
148
156
|
);
|
|
157
|
+
if (!fileResponse.success)
|
|
158
|
+
return {
|
|
159
|
+
json: fileResponse.data,
|
|
160
|
+
};
|
|
149
161
|
|
|
150
162
|
return {
|
|
151
163
|
json: {},
|
|
152
164
|
binary: {
|
|
153
|
-
data: fileResponse,
|
|
165
|
+
data: fileResponse.data,
|
|
154
166
|
},
|
|
155
167
|
};
|
|
156
168
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { IExecuteFunctions, INodeProperties } from 'n8n-workflow';
|
|
2
2
|
|
|
3
3
|
import { getLimeobject, getProperties } from '../../../transport';
|
|
4
|
-
import { DATA_RESOURCE } from '../../../models';
|
|
4
|
+
import { DATA_RESOURCE, Limeobject } from '../../../models';
|
|
5
5
|
import { getFilePropertiesNames, processFileResponse } from '../../../utils';
|
|
6
|
-
|
|
6
|
+
import { WorkflowFileResponse } from '../../../../response';
|
|
7
7
|
/**
|
|
8
8
|
* Description and metadata for the "Get Single Object" operation in Lime CRM.
|
|
9
9
|
*
|
|
@@ -94,7 +94,10 @@ export const properties: INodeProperties[] = [
|
|
|
94
94
|
*
|
|
95
95
|
* @public
|
|
96
96
|
*/
|
|
97
|
-
export async function execute(
|
|
97
|
+
export async function execute(
|
|
98
|
+
this: IExecuteFunctions,
|
|
99
|
+
i: number
|
|
100
|
+
): Promise<WorkflowFileResponse<Limeobject>> {
|
|
98
101
|
const limetype = this.getNodeParameter('limetype', i) as string;
|
|
99
102
|
const objectId = this.getNodeParameter('objectId', i) as string;
|
|
100
103
|
const includeFileContent = this.getNodeParameter(
|
|
@@ -103,14 +106,20 @@ export async function execute(this: IExecuteFunctions, i: number) {
|
|
|
103
106
|
) as boolean;
|
|
104
107
|
|
|
105
108
|
const limeObjectResponse = await getLimeobject(this, limetype, objectId);
|
|
109
|
+
if (!limeObjectResponse.success) return { json: limeObjectResponse.data };
|
|
106
110
|
|
|
107
111
|
const propertiesResponse = await getProperties(this, limetype);
|
|
112
|
+
if (!propertiesResponse.success) return { json: propertiesResponse.data };
|
|
108
113
|
|
|
109
|
-
const fileProperties = getFilePropertiesNames(propertiesResponse);
|
|
110
|
-
|
|
114
|
+
const fileProperties = getFilePropertiesNames(propertiesResponse.data);
|
|
115
|
+
const fileResponse = await processFileResponse<Limeobject>(
|
|
111
116
|
this,
|
|
112
117
|
fileProperties,
|
|
113
|
-
limeObjectResponse,
|
|
118
|
+
limeObjectResponse.data,
|
|
114
119
|
includeFileContent
|
|
115
120
|
);
|
|
121
|
+
return {
|
|
122
|
+
json: fileResponse.json.data,
|
|
123
|
+
binary: fileResponse.binary,
|
|
124
|
+
};
|
|
116
125
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { IDataObject, IExecuteFunctions, INodeProperties } from 'n8n-workflow';
|
|
2
2
|
import { getProperties, updateLimeobject } from '../../../transport';
|
|
3
|
-
import { DATA_RESOURCE } from '../../../models';
|
|
3
|
+
import { DATA_RESOURCE, Limeobject } from '../../../models';
|
|
4
4
|
import {
|
|
5
|
-
adaptProperty,
|
|
6
5
|
getFilePropertiesNames,
|
|
7
|
-
getPropertyType,
|
|
8
6
|
processFileResponse,
|
|
9
7
|
setFileProperties,
|
|
10
8
|
} from '../../../utils';
|
|
9
|
+
import { WorkflowFileResponse } from '../../../../response';
|
|
10
|
+
import { parseResourceMapperFields } from '../../../methods';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Description and metadata for the "Update Single Object" operation in Lime CRM.
|
|
@@ -71,7 +71,7 @@ export const properties: INodeProperties[] = [
|
|
|
71
71
|
options: [
|
|
72
72
|
{
|
|
73
73
|
name: 'Simple Fields',
|
|
74
|
-
value: '
|
|
74
|
+
value: 'fields',
|
|
75
75
|
description: 'Define fields using the UI',
|
|
76
76
|
},
|
|
77
77
|
{
|
|
@@ -80,7 +80,7 @@ export const properties: INodeProperties[] = [
|
|
|
80
80
|
description: 'Define fields using JSON',
|
|
81
81
|
},
|
|
82
82
|
],
|
|
83
|
-
default: '
|
|
83
|
+
default: 'fields',
|
|
84
84
|
description: 'How to input the data',
|
|
85
85
|
displayOptions: {
|
|
86
86
|
show: {
|
|
@@ -109,48 +109,29 @@ export const properties: INodeProperties[] = [
|
|
|
109
109
|
},
|
|
110
110
|
},
|
|
111
111
|
{
|
|
112
|
-
displayName: '
|
|
113
|
-
name: '
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
displayName: 'Properties',
|
|
113
|
+
name: 'properties',
|
|
114
|
+
type: 'resourceMapper',
|
|
115
|
+
placeholder: 'Add Property',
|
|
116
116
|
typeOptions: {
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
resourceMapper: {
|
|
118
|
+
resourceMapperMethod: 'getUpdateMappingColumns',
|
|
119
|
+
mode: 'add',
|
|
120
|
+
addAllFields: false,
|
|
121
|
+
supportAutoMap: false,
|
|
122
|
+
},
|
|
123
|
+
loadOptionsDependsOn: ['limetype'],
|
|
124
|
+
},
|
|
125
|
+
default: {
|
|
126
|
+
value: null,
|
|
119
127
|
},
|
|
120
|
-
default: {},
|
|
121
128
|
displayOptions: {
|
|
122
129
|
show: {
|
|
123
130
|
resource: [DATA_RESOURCE],
|
|
124
131
|
operation: ['updateSingleObject'],
|
|
125
|
-
inputType: ['
|
|
132
|
+
inputType: ['fields'],
|
|
126
133
|
},
|
|
127
134
|
},
|
|
128
|
-
options: [
|
|
129
|
-
{
|
|
130
|
-
name: 'field',
|
|
131
|
-
displayName: 'Field',
|
|
132
|
-
values: [
|
|
133
|
-
{
|
|
134
|
-
displayName: 'Field Name',
|
|
135
|
-
name: 'fieldName',
|
|
136
|
-
type: 'options',
|
|
137
|
-
typeOptions: {
|
|
138
|
-
loadOptionsMethod: 'getNoHasManyProperties',
|
|
139
|
-
loadOptionsDependsOn: ['limetype'],
|
|
140
|
-
},
|
|
141
|
-
default: '',
|
|
142
|
-
description: 'The name of the field',
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
displayName: 'Field Value',
|
|
146
|
-
name: 'fieldValue',
|
|
147
|
-
type: 'string',
|
|
148
|
-
default: '',
|
|
149
|
-
description: 'The value of the field',
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
},
|
|
153
|
-
],
|
|
154
135
|
},
|
|
155
136
|
];
|
|
156
137
|
|
|
@@ -175,32 +156,28 @@ export const properties: INodeProperties[] = [
|
|
|
175
156
|
*
|
|
176
157
|
* @public
|
|
177
158
|
*/
|
|
178
|
-
export async function execute(
|
|
159
|
+
export async function execute(
|
|
160
|
+
this: IExecuteFunctions,
|
|
161
|
+
i: number
|
|
162
|
+
): Promise<WorkflowFileResponse<Limeobject>> {
|
|
179
163
|
const limetype = this.getNodeParameter('limetype', i) as string;
|
|
180
164
|
const id = this.getNodeParameter('id', i) as string;
|
|
181
165
|
const inputType = this.getNodeParameter('inputType', i) as string;
|
|
182
166
|
|
|
183
167
|
let body: IDataObject = {};
|
|
184
168
|
|
|
185
|
-
const
|
|
169
|
+
const propertiesResponse = await getProperties(this, limetype);
|
|
170
|
+
if (!propertiesResponse.success)
|
|
171
|
+
return {
|
|
172
|
+
json: propertiesResponse.data,
|
|
173
|
+
};
|
|
174
|
+
const properties = propertiesResponse.data;
|
|
186
175
|
|
|
187
176
|
if (inputType === 'json') {
|
|
188
177
|
const jsonData = this.getNodeParameter('jsonData', i) as string;
|
|
189
178
|
body = JSON.parse(jsonData);
|
|
190
179
|
} else {
|
|
191
|
-
|
|
192
|
-
'simpleFields.field',
|
|
193
|
-
i,
|
|
194
|
-
[]
|
|
195
|
-
) as IDataObject[];
|
|
196
|
-
for (const field of simpleFields) {
|
|
197
|
-
const fieldName = field.fieldName as string;
|
|
198
|
-
const fieldValue = field.fieldValue as string;
|
|
199
|
-
body[fieldName] = adaptProperty(
|
|
200
|
-
fieldValue,
|
|
201
|
-
getPropertyType(fieldName, properties)
|
|
202
|
-
);
|
|
203
|
-
}
|
|
180
|
+
body = parseResourceMapperFields(this, i, 'properties');
|
|
204
181
|
}
|
|
205
182
|
|
|
206
183
|
const fileProperties = getFilePropertiesNames(properties);
|
|
@@ -213,11 +190,18 @@ export async function execute(this: IExecuteFunctions, i: number) {
|
|
|
213
190
|
id,
|
|
214
191
|
body
|
|
215
192
|
);
|
|
193
|
+
if (!updateLimeobjectResponse.success)
|
|
194
|
+
return {
|
|
195
|
+
json: updateLimeobjectResponse.data,
|
|
196
|
+
};
|
|
216
197
|
|
|
217
|
-
const response = await processFileResponse(
|
|
198
|
+
const response = await processFileResponse<Limeobject>(
|
|
218
199
|
this,
|
|
219
200
|
fileProperties,
|
|
220
|
-
updateLimeobjectResponse
|
|
201
|
+
updateLimeobjectResponse.data
|
|
221
202
|
);
|
|
222
|
-
return
|
|
203
|
+
return {
|
|
204
|
+
json: response.json.data,
|
|
205
|
+
binary: response.binary,
|
|
206
|
+
};
|
|
223
207
|
}
|
|
@@ -69,9 +69,13 @@ export async function metadataOperations(
|
|
|
69
69
|
switch (operation) {
|
|
70
70
|
case 'getAllLimetypes': {
|
|
71
71
|
const results = await operations.getAllLimetypes.execute.call(this);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
if (Array.isArray(results)) {
|
|
73
|
+
return results.map((limetype) => ({
|
|
74
|
+
json: limetype,
|
|
75
|
+
}));
|
|
76
|
+
} else {
|
|
77
|
+
return { json: results };
|
|
78
|
+
}
|
|
75
79
|
}
|
|
76
80
|
case 'getSingleLimetype': {
|
|
77
81
|
return {
|
|
@@ -2,6 +2,7 @@ import { IExecuteFunctions } from 'n8n-workflow';
|
|
|
2
2
|
|
|
3
3
|
import { getLimetypesFromApi } from '../../../transport';
|
|
4
4
|
import { Limetype } from '../../../models';
|
|
5
|
+
import { WorkflowResponse } from '../../../../response';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Description and metadata for the "Get All Limetypes" operation in Lime CRM.
|
|
@@ -23,6 +24,9 @@ export const description = {
|
|
|
23
24
|
*
|
|
24
25
|
* @public
|
|
25
26
|
*/
|
|
26
|
-
export async function execute(
|
|
27
|
-
|
|
27
|
+
export async function execute(
|
|
28
|
+
this: IExecuteFunctions
|
|
29
|
+
): Promise<WorkflowResponse<Limetype[]>> {
|
|
30
|
+
const response = await getLimetypesFromApi(this);
|
|
31
|
+
return response.data;
|
|
28
32
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IExecuteFunctions,
|
|
3
|
-
INodeProperties,
|
|
4
|
-
NodeOperationError,
|
|
5
|
-
} from 'n8n-workflow';
|
|
1
|
+
import { IExecuteFunctions, INodeProperties } from 'n8n-workflow';
|
|
6
2
|
import {
|
|
7
3
|
FileMetadata,
|
|
8
4
|
getFileMetadata,
|
|
9
5
|
getFileMetadataByLimeobject,
|
|
10
6
|
} from '../../../transport';
|
|
11
7
|
import { METADATA_RESOURCE } from '../../../models';
|
|
8
|
+
import { APIResponse, WorkflowResponse } from '../../../../response';
|
|
9
|
+
import { handleWorkflowError } from '../../../../errorHandling';
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
12
|
* Description and metadata for the "Get Single File Metadata" operation in Lime CRM.
|
|
@@ -127,21 +125,26 @@ export const properties: INodeProperties[] = [
|
|
|
127
125
|
export async function execute(
|
|
128
126
|
this: IExecuteFunctions,
|
|
129
127
|
i: number
|
|
130
|
-
): Promise<FileMetadata
|
|
128
|
+
): Promise<WorkflowResponse<FileMetadata>> {
|
|
131
129
|
const source = this.getNodeParameter('source', i) as string;
|
|
132
130
|
const id = this.getNodeParameter('identifier', i) as string;
|
|
131
|
+
let response: APIResponse<FileMetadata>;
|
|
133
132
|
|
|
134
133
|
if (source == 'byFile') {
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
if (source == 'byLimeobject') {
|
|
134
|
+
response = await getFileMetadata(this, id);
|
|
135
|
+
} else if (source == 'byLimeobject') {
|
|
138
136
|
const limetype = this.getNodeParameter('limetype', i) as string;
|
|
139
137
|
const property = this.getNodeParameter('property', i) as string;
|
|
140
|
-
|
|
138
|
+
response = await getFileMetadataByLimeobject(
|
|
139
|
+
this,
|
|
140
|
+
limetype,
|
|
141
|
+
id,
|
|
142
|
+
property
|
|
143
|
+
);
|
|
144
|
+
} else {
|
|
145
|
+
response = handleWorkflowError(this, {
|
|
146
|
+
message: `The source "${source} is not supported`,
|
|
147
|
+
});
|
|
141
148
|
}
|
|
142
|
-
|
|
143
|
-
throw new NodeOperationError(
|
|
144
|
-
this.getNode(),
|
|
145
|
-
`The source "${source}" is not supported!`
|
|
146
|
-
);
|
|
149
|
+
return response.data;
|
|
147
150
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IExecuteFunctions, INodeProperties } from 'n8n-workflow';
|
|
2
2
|
import { getLimetype } from '../../../transport/limetypes';
|
|
3
|
-
import { METADATA_RESOURCE } from '../../../models';
|
|
3
|
+
import { Limetype, METADATA_RESOURCE } from '../../../models';
|
|
4
|
+
import { WorkflowResponse } from '../../../../response';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Description and metadata for the "Get Single Limetype" operation in Lime CRM.
|
|
@@ -51,8 +52,12 @@ export const properties: INodeProperties[] = [
|
|
|
51
52
|
*
|
|
52
53
|
* @public
|
|
53
54
|
*/
|
|
54
|
-
export async function execute(
|
|
55
|
+
export async function execute(
|
|
56
|
+
this: IExecuteFunctions,
|
|
57
|
+
i: number
|
|
58
|
+
): Promise<WorkflowResponse<Limetype>> {
|
|
55
59
|
const limetype = this.getNodeParameter('limetype', i) as string;
|
|
56
60
|
|
|
57
|
-
|
|
61
|
+
const response = await getLimetype(this, limetype);
|
|
62
|
+
return response.data;
|
|
58
63
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { LIME_CRM_API_CREDENTIAL_KEY } from '../models';
|
|
2
|
-
import { IAllExecuteFunctions,
|
|
2
|
+
import { IAllExecuteFunctions, JsonObject } from 'n8n-workflow';
|
|
3
|
+
import { WorkflowErrorContext, handleWorkflowError } from '../utils';
|
|
4
|
+
import { APIResponse, SuccessResponse } from '../../response';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* HTTP methods supported by the Lime CRM API.
|
|
@@ -31,6 +33,16 @@ export function removeKeys<T extends object, K extends keyof T>(
|
|
|
31
33
|
return obj;
|
|
32
34
|
}
|
|
33
35
|
|
|
36
|
+
export function prepareResponseWithoutKeys<T extends object, K extends keyof T>(
|
|
37
|
+
response: SuccessResponse<T>,
|
|
38
|
+
keys: K[]
|
|
39
|
+
): SuccessResponse<Omit<T, K>> {
|
|
40
|
+
return {
|
|
41
|
+
success: true,
|
|
42
|
+
data: removeKeys(response.data, keys),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
34
46
|
/**
|
|
35
47
|
* Retrieve the base URL for the Lime CRM API from stored credentials.
|
|
36
48
|
*
|
|
@@ -85,31 +97,33 @@ interface LimeAPIArguments {
|
|
|
85
97
|
export async function callLimeApi<T>(
|
|
86
98
|
nodeContext: IAllExecuteFunctions,
|
|
87
99
|
options: LimeAPIArguments
|
|
88
|
-
): Promise<T
|
|
100
|
+
): Promise<APIResponse<T>> {
|
|
89
101
|
try {
|
|
90
|
-
|
|
91
|
-
nodeContext
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
102
|
+
const response =
|
|
103
|
+
await nodeContext.helpers.requestWithAuthentication.call(
|
|
104
|
+
nodeContext,
|
|
105
|
+
LIME_CRM_API_CREDENTIAL_KEY,
|
|
106
|
+
{
|
|
107
|
+
method: options.method,
|
|
108
|
+
url: options.url,
|
|
109
|
+
json: options.json || true,
|
|
110
|
+
baseURL: await getLimeUrl(nodeContext),
|
|
111
|
+
...options.requestOptions,
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
return {
|
|
115
|
+
success: true,
|
|
116
|
+
data: response,
|
|
117
|
+
};
|
|
101
118
|
} catch (error) {
|
|
102
|
-
const errorContext = {
|
|
103
|
-
|
|
119
|
+
const errorContext: WorkflowErrorContext = {
|
|
120
|
+
message: error instanceof Error ? error.message : String(error),
|
|
104
121
|
status: error?.cause?.status,
|
|
105
122
|
metadata: {
|
|
106
123
|
...options.requestOptions,
|
|
107
124
|
...options.errorMetadata,
|
|
108
|
-
},
|
|
125
|
+
} as JsonObject,
|
|
109
126
|
};
|
|
110
|
-
|
|
111
|
-
nodeContext.getNode(),
|
|
112
|
-
JSON.stringify(errorContext)
|
|
113
|
-
);
|
|
127
|
+
return handleWorkflowError(nodeContext, errorContext, true);
|
|
114
128
|
}
|
|
115
129
|
}
|