@limetech/n8n-nodes-lime 0.3.8 → 0.5.0
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/.prettierignore +3 -1
- package/CHANGELOG.md +100 -0
- package/README.md +1 -8
- package/credentials/LimeCrmApi.credentials.ts +6 -6
- package/dist/nodes/lime-crm/LimeCrmNode.node.js +13 -0
- package/dist/nodes/lime-crm/LimeCrmNode.node.js.map +1 -1
- package/dist/nodes/lime-crm/commons/constants.d.ts +1 -0
- package/dist/nodes/lime-crm/commons/constants.js +2 -1
- package/dist/nodes/lime-crm/commons/constants.js.map +1 -1
- package/dist/nodes/lime-crm/commons/index.d.ts +1 -1
- package/dist/nodes/lime-crm/commons/index.js +2 -1
- package/dist/nodes/lime-crm/commons/index.js.map +1 -1
- package/dist/nodes/lime-crm/resources/limeQuery/index.d.ts +6 -0
- package/dist/nodes/lime-crm/resources/limeQuery/index.js +66 -0
- package/dist/nodes/lime-crm/resources/limeQuery/index.js.map +1 -0
- package/dist/nodes/lime-crm/resources/limeQuery/operations/query.operation.d.ts +9 -0
- package/dist/nodes/lime-crm/resources/limeQuery/operations/query.operation.js +191 -0
- package/dist/nodes/lime-crm/resources/limeQuery/operations/query.operation.js.map +1 -0
- package/dist/nodes/lime-crm/resources/limeType/index.d.ts +3 -3
- package/dist/nodes/lime-crm/transport/index.d.ts +1 -0
- package/dist/nodes/lime-crm/transport/index.js +3 -1
- package/dist/nodes/lime-crm/transport/index.js.map +1 -1
- package/dist/nodes/lime-crm/transport/limeQuery.d.ts +10 -0
- package/dist/nodes/lime-crm/transport/limeQuery.js +15 -0
- package/dist/nodes/lime-crm/transport/limeQuery.js.map +1 -0
- package/dist/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docker-compose.yml +9 -3
- package/nodes/fortnox/Fortnox.node.ts +3 -3
- package/nodes/fortnox/FortnoxTrigger.node.ts +2 -2
- package/nodes/lime-crm/LimeCrmNode.node.ts +54 -53
- package/nodes/lime-crm/LimeCrmTrigger.node.ts +17 -24
- package/nodes/lime-crm/commons/constants.ts +2 -2
- package/nodes/lime-crm/commons/files.ts +162 -0
- package/nodes/lime-crm/commons/index.ts +4 -3
- package/nodes/lime-crm/commons/webhook.ts +15 -3
- package/nodes/lime-crm/methods/getLimetypeProperties.ts +67 -0
- package/nodes/lime-crm/methods/getLimetypes.ts +21 -0
- package/nodes/lime-crm/methods/index.ts +6 -2
- package/nodes/lime-crm/model.ts +22 -0
- package/nodes/lime-crm/resources/data/index.ts +80 -0
- package/nodes/lime-crm/resources/{limeObject/operations/create.operation.ts → data/operations/createSingleObject.ts} +53 -30
- package/nodes/lime-crm/resources/{limeObject/operations/delete.operation.ts → data/operations/deleteSingleObject.ts} +15 -15
- package/nodes/lime-crm/resources/data/operations/getManyObjects.ts +356 -0
- package/nodes/lime-crm/resources/data/operations/getSingleFile.ts +138 -0
- package/nodes/lime-crm/resources/data/operations/getSingleObject.ts +83 -0
- package/nodes/lime-crm/resources/{limeObject/operations/update.operation.ts → data/operations/updateSingleObject.operation.ts} +51 -23
- package/nodes/lime-crm/resources/erpConnector/index.ts +3 -3
- package/nodes/lime-crm/resources/erpConnector/operations/transform.operation.ts +14 -14
- package/nodes/lime-crm/resources/erpConnector/transform.ts +3 -3
- package/nodes/lime-crm/resources/erpConnector/transformers/baseTransformer.ts +2 -2
- package/nodes/lime-crm/resources/erpConnector/transformers/fortnox.ts +8 -8
- package/nodes/lime-crm/resources/metadata/index.ts +57 -0
- package/nodes/lime-crm/resources/metadata/operations/getAllLimetypes.operation.ts +18 -0
- package/nodes/lime-crm/resources/metadata/operations/getSingleFileMetadata.ts +130 -0
- package/nodes/lime-crm/resources/metadata/operations/getSingleLimetype.ts +36 -0
- package/nodes/lime-crm/transport/commons.ts +14 -2
- package/nodes/lime-crm/transport/files.ts +155 -0
- package/nodes/lime-crm/transport/index.ts +14 -6
- package/nodes/lime-crm/transport/limeQuery.ts +26 -0
- package/nodes/lime-crm/transport/limeobjects.ts +79 -44
- package/nodes/lime-crm/transport/limetypes.ts +80 -24
- package/package.json +4 -3
- package/restore_script/README +42 -0
- package/restore_script/api_key_download.txt +0 -0
- package/restore_script/api_key_upload.txt +0 -0
- package/restore_script/cli.py +73 -0
- package/restore_script/download.py +73 -0
- package/restore_script/main.py +19 -0
- package/restore_script/poetry.lock +162 -0
- package/restore_script/pyproject.toml +15 -0
- package/restore_script/transfer.py +41 -0
- package/restore_script/upload.py +66 -0
- package/restore_script/utils.py +42 -0
- package/tests/transform.spec.ts +6 -6
- package/nodes/lime-crm/commons/limetype.ts +0 -11
- package/nodes/lime-crm/methods/getLimeTypeProperties.ts +0 -27
- package/nodes/lime-crm/methods/getLimeTypes.ts +0 -23
- package/nodes/lime-crm/resources/limeObject/index.ts +0 -64
- package/nodes/lime-crm/resources/limeObject/operations/fetchMany.operation.ts +0 -112
- package/nodes/lime-crm/resources/limeObject/operations/get.operation.ts +0 -54
- package/nodes/lime-crm/resources/limeType/index.ts +0 -58
- package/nodes/lime-crm/resources/limeType/operations/getProperties.operation.ts +0 -42
- package/nodes/lime-crm/resources/limeType/operations/getType.operation.ts +0 -36
- package/nodes/lime-crm/resources/limeType/operations/listTypes.operation.ts +0 -18
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IExecuteFunctions,
|
|
3
|
+
INodeProperties,
|
|
4
|
+
NodeOperationError,
|
|
5
|
+
} from 'n8n-workflow';
|
|
6
|
+
import { getFileContent, getFileContentByLimetype } from '../../../transport';
|
|
7
|
+
import { DATA_RESOURCE } from '../../../commons';
|
|
8
|
+
|
|
9
|
+
export const description = {
|
|
10
|
+
name: 'Get Single File',
|
|
11
|
+
value: 'getSingleFile',
|
|
12
|
+
description: 'Get the file data for one specific file',
|
|
13
|
+
action: 'Get single file',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const properties: INodeProperties[] = [
|
|
17
|
+
{
|
|
18
|
+
displayName: 'Get by',
|
|
19
|
+
name: 'source',
|
|
20
|
+
type: 'options',
|
|
21
|
+
required: true,
|
|
22
|
+
placeholder: 'Add Source',
|
|
23
|
+
displayOptions: {
|
|
24
|
+
show: {
|
|
25
|
+
resource: [DATA_RESOURCE],
|
|
26
|
+
operation: ['getSingleFile'],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
options: [
|
|
30
|
+
{
|
|
31
|
+
name: 'File ID',
|
|
32
|
+
value: 'byFile',
|
|
33
|
+
description: 'Get file by its ID',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'Limeobject ID',
|
|
37
|
+
value: 'byLimeobject',
|
|
38
|
+
description: "Get file by it's associated Limeobject ID",
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
default: 'byFile',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
displayName: 'Limetype',
|
|
45
|
+
name: 'limetype',
|
|
46
|
+
type: 'options',
|
|
47
|
+
typeOptions: {
|
|
48
|
+
loadOptionsMethod: 'getLimetypes',
|
|
49
|
+
},
|
|
50
|
+
required: true,
|
|
51
|
+
default: '',
|
|
52
|
+
description: 'The type of entity associated with the file',
|
|
53
|
+
displayOptions: {
|
|
54
|
+
show: {
|
|
55
|
+
resource: [DATA_RESOURCE],
|
|
56
|
+
operation: ['getSingleFile'],
|
|
57
|
+
source: ['byLimeobject'],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
displayName: 'Identifier',
|
|
63
|
+
name: 'identifier',
|
|
64
|
+
type: 'string',
|
|
65
|
+
required: true,
|
|
66
|
+
default: '',
|
|
67
|
+
description: 'The ID of the file or Limeobject to retrieve',
|
|
68
|
+
displayOptions: {
|
|
69
|
+
show: {
|
|
70
|
+
resource: [DATA_RESOURCE],
|
|
71
|
+
operation: ['getSingleFile'],
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
placeholder: 'e.g., 12345',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
displayName: 'File type property',
|
|
78
|
+
name: 'property',
|
|
79
|
+
type: 'options',
|
|
80
|
+
typeOptions: {
|
|
81
|
+
loadOptionsMethod: 'getFileProperties',
|
|
82
|
+
loadOptionsDependsOn: ['limetype'],
|
|
83
|
+
},
|
|
84
|
+
required: true,
|
|
85
|
+
default: '',
|
|
86
|
+
description: 'The type of entity associated with the file',
|
|
87
|
+
displayOptions: {
|
|
88
|
+
show: {
|
|
89
|
+
resource: [DATA_RESOURCE],
|
|
90
|
+
operation: ['getSingleFile'],
|
|
91
|
+
source: ['byLimeobject'],
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
export async function execute(this: IExecuteFunctions, i: number) {
|
|
98
|
+
const source = this.getNodeParameter('source', i) as string;
|
|
99
|
+
const id = this.getNodeParameter('identifier', i) as string;
|
|
100
|
+
|
|
101
|
+
if (source == 'byFile') {
|
|
102
|
+
const fileResponse = await getFileContent(this, id);
|
|
103
|
+
if (!fileResponse.success) {
|
|
104
|
+
return { json: fileResponse };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
json: { success: fileResponse.success },
|
|
109
|
+
binary: { data: fileResponse.data },
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (source == 'byLimeobject') {
|
|
113
|
+
const limetype = this.getNodeParameter('limetype', i) as string;
|
|
114
|
+
const property = this.getNodeParameter('property', i) as string;
|
|
115
|
+
|
|
116
|
+
const fileResponse = await getFileContentByLimetype(
|
|
117
|
+
this,
|
|
118
|
+
limetype,
|
|
119
|
+
id,
|
|
120
|
+
property
|
|
121
|
+
);
|
|
122
|
+
if (!fileResponse.success) {
|
|
123
|
+
return { json: fileResponse };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
json: { success: fileResponse.success },
|
|
128
|
+
binary: {
|
|
129
|
+
data: fileResponse.data,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
throw new NodeOperationError(
|
|
135
|
+
this.getNode(),
|
|
136
|
+
`The source "${source}" is not supported!`
|
|
137
|
+
);
|
|
138
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { IExecuteFunctions, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
|
|
3
|
+
import { getLimeobject } from '../../../transport';
|
|
4
|
+
import { DATA_RESOURCE } from '../../../commons';
|
|
5
|
+
import { getFileProperties, processFileResponse } from '../../../commons/files';
|
|
6
|
+
|
|
7
|
+
export const description = {
|
|
8
|
+
name: 'Get Single Object',
|
|
9
|
+
value: 'getSingleObject',
|
|
10
|
+
description: 'Get one specific object',
|
|
11
|
+
action: 'Get single object',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const properties: INodeProperties[] = [
|
|
15
|
+
{
|
|
16
|
+
displayName: 'Limetype',
|
|
17
|
+
name: 'limetype',
|
|
18
|
+
type: 'options',
|
|
19
|
+
typeOptions: {
|
|
20
|
+
loadOptionsMethod: 'getLimetypes',
|
|
21
|
+
},
|
|
22
|
+
required: true,
|
|
23
|
+
default: '',
|
|
24
|
+
description: 'The type of entity to retrieve',
|
|
25
|
+
displayOptions: {
|
|
26
|
+
show: {
|
|
27
|
+
resource: [DATA_RESOURCE],
|
|
28
|
+
operation: ['getSingleObject'],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
{
|
|
34
|
+
displayName: 'Object ID',
|
|
35
|
+
name: 'objectId',
|
|
36
|
+
type: 'string',
|
|
37
|
+
required: true,
|
|
38
|
+
default: '',
|
|
39
|
+
description: 'The ID of the object to retrieve',
|
|
40
|
+
displayOptions: {
|
|
41
|
+
show: {
|
|
42
|
+
resource: [DATA_RESOURCE],
|
|
43
|
+
operation: ['getSingleObject'],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
displayName: 'Include file content',
|
|
49
|
+
name: 'includeFileContent',
|
|
50
|
+
type: 'boolean',
|
|
51
|
+
default: false,
|
|
52
|
+
description:
|
|
53
|
+
'Include file binary data if the Limetype has any file properties. ' +
|
|
54
|
+
'Keep performance in mind before activating this. ' +
|
|
55
|
+
'For Limetypes without any file properties, this setting is ignored.',
|
|
56
|
+
displayOptions: {
|
|
57
|
+
show: {
|
|
58
|
+
resource: [DATA_RESOURCE],
|
|
59
|
+
operation: ['getSingleObject'],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
export async function execute(this: IExecuteFunctions, i: number) {
|
|
66
|
+
const limetype = this.getNodeParameter('limetype', i) as string;
|
|
67
|
+
const objectId = this.getNodeParameter('objectId', i) as string;
|
|
68
|
+
const includeFileContent = this.getNodeParameter(
|
|
69
|
+
'includeFileContent',
|
|
70
|
+
i
|
|
71
|
+
) as boolean;
|
|
72
|
+
|
|
73
|
+
const limeObjectResponse = await getLimeobject(this, limetype, objectId);
|
|
74
|
+
if (!limeObjectResponse.success) return { json: limeObjectResponse };
|
|
75
|
+
|
|
76
|
+
const fileProperties = await getFileProperties(this, limetype);
|
|
77
|
+
return processFileResponse(
|
|
78
|
+
this,
|
|
79
|
+
fileProperties,
|
|
80
|
+
limeObjectResponse.data,
|
|
81
|
+
includeFileContent
|
|
82
|
+
);
|
|
83
|
+
}
|
|
@@ -1,30 +1,35 @@
|
|
|
1
1
|
import { IDataObject, IExecuteFunctions, INodeProperties } from 'n8n-workflow';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { updateLimeobject } from '../../../transport';
|
|
3
|
+
import { DATA_RESOURCE } from '../../../commons';
|
|
4
|
+
import {
|
|
5
|
+
getFileProperties,
|
|
6
|
+
processFileResponse,
|
|
7
|
+
setFileProperties,
|
|
8
|
+
} from '../../../commons/files';
|
|
4
9
|
|
|
5
10
|
// Input fields for update operation
|
|
6
11
|
export const description = {
|
|
7
|
-
name: 'Update',
|
|
8
|
-
value: '
|
|
9
|
-
description: 'Update
|
|
10
|
-
action: 'Update
|
|
12
|
+
name: 'Update Single Object',
|
|
13
|
+
value: 'updateSingleObject',
|
|
14
|
+
description: 'Update one specific object',
|
|
15
|
+
action: 'Update single object',
|
|
11
16
|
};
|
|
12
17
|
|
|
13
18
|
export const properties: INodeProperties[] = [
|
|
14
19
|
{
|
|
15
|
-
displayName: '
|
|
16
|
-
name: '
|
|
20
|
+
displayName: 'Limetype',
|
|
21
|
+
name: 'limetype',
|
|
17
22
|
type: 'options',
|
|
18
23
|
typeOptions: {
|
|
19
|
-
loadOptionsMethod: '
|
|
24
|
+
loadOptionsMethod: 'getLimetypes',
|
|
20
25
|
},
|
|
21
26
|
required: true,
|
|
22
27
|
default: '',
|
|
23
28
|
description: 'The type of entity to update',
|
|
24
29
|
displayOptions: {
|
|
25
30
|
show: {
|
|
26
|
-
resource: [
|
|
27
|
-
operation: ['
|
|
31
|
+
resource: [DATA_RESOURCE],
|
|
32
|
+
operation: ['updateSingleObject'],
|
|
28
33
|
},
|
|
29
34
|
},
|
|
30
35
|
},
|
|
@@ -37,8 +42,8 @@ export const properties: INodeProperties[] = [
|
|
|
37
42
|
description: 'ID of the record to update',
|
|
38
43
|
displayOptions: {
|
|
39
44
|
show: {
|
|
40
|
-
resource: [
|
|
41
|
-
operation: ['
|
|
45
|
+
resource: [DATA_RESOURCE],
|
|
46
|
+
operation: ['updateSingleObject'],
|
|
42
47
|
},
|
|
43
48
|
},
|
|
44
49
|
},
|
|
@@ -62,8 +67,8 @@ export const properties: INodeProperties[] = [
|
|
|
62
67
|
description: 'How to input the data',
|
|
63
68
|
displayOptions: {
|
|
64
69
|
show: {
|
|
65
|
-
resource: [
|
|
66
|
-
operation: ['
|
|
70
|
+
resource: [DATA_RESOURCE],
|
|
71
|
+
operation: ['updateSingleObject'],
|
|
67
72
|
},
|
|
68
73
|
},
|
|
69
74
|
},
|
|
@@ -80,8 +85,8 @@ export const properties: INodeProperties[] = [
|
|
|
80
85
|
},
|
|
81
86
|
displayOptions: {
|
|
82
87
|
show: {
|
|
83
|
-
resource: [
|
|
84
|
-
operation: ['
|
|
88
|
+
resource: [DATA_RESOURCE],
|
|
89
|
+
operation: ['updateSingleObject'],
|
|
85
90
|
inputType: ['json'],
|
|
86
91
|
},
|
|
87
92
|
},
|
|
@@ -98,8 +103,8 @@ export const properties: INodeProperties[] = [
|
|
|
98
103
|
default: {},
|
|
99
104
|
displayOptions: {
|
|
100
105
|
show: {
|
|
101
|
-
resource: [
|
|
102
|
-
operation: ['
|
|
106
|
+
resource: [DATA_RESOURCE],
|
|
107
|
+
operation: ['updateSingleObject'],
|
|
103
108
|
inputType: ['simple'],
|
|
104
109
|
},
|
|
105
110
|
},
|
|
@@ -113,8 +118,8 @@ export const properties: INodeProperties[] = [
|
|
|
113
118
|
name: 'fieldName',
|
|
114
119
|
type: 'options',
|
|
115
120
|
typeOptions: {
|
|
116
|
-
loadOptionsMethod: '
|
|
117
|
-
loadOptionsDependsOn: ['
|
|
121
|
+
loadOptionsMethod: 'getLimetypeProperties',
|
|
122
|
+
loadOptionsDependsOn: ['limetype'],
|
|
118
123
|
},
|
|
119
124
|
default: '',
|
|
120
125
|
description: 'The name of the field',
|
|
@@ -133,7 +138,7 @@ export const properties: INodeProperties[] = [
|
|
|
133
138
|
];
|
|
134
139
|
|
|
135
140
|
export async function execute(this: IExecuteFunctions, i: number) {
|
|
136
|
-
const
|
|
141
|
+
const limetype = this.getNodeParameter('limetype', i) as string;
|
|
137
142
|
const id = this.getNodeParameter('id', i) as string;
|
|
138
143
|
const inputType = this.getNodeParameter('inputType', i) as string;
|
|
139
144
|
|
|
@@ -153,5 +158,28 @@ export async function execute(this: IExecuteFunctions, i: number) {
|
|
|
153
158
|
}
|
|
154
159
|
}
|
|
155
160
|
|
|
156
|
-
|
|
161
|
+
const fileProperties = await getFileProperties(this, limetype);
|
|
162
|
+
|
|
163
|
+
const setFilePropertiesResponse = await setFileProperties(
|
|
164
|
+
this,
|
|
165
|
+
i,
|
|
166
|
+
fileProperties,
|
|
167
|
+
body
|
|
168
|
+
);
|
|
169
|
+
if (!setFilePropertiesResponse.success) return setFilePropertiesResponse;
|
|
170
|
+
|
|
171
|
+
const updateLimeobjectResponse = await updateLimeobject(
|
|
172
|
+
this,
|
|
173
|
+
limetype,
|
|
174
|
+
id,
|
|
175
|
+
body
|
|
176
|
+
);
|
|
177
|
+
if (!updateLimeobjectResponse.success) return updateLimeobjectResponse;
|
|
178
|
+
|
|
179
|
+
const response = await processFileResponse(
|
|
180
|
+
this,
|
|
181
|
+
fileProperties,
|
|
182
|
+
updateLimeobjectResponse.data
|
|
183
|
+
);
|
|
184
|
+
return response.json;
|
|
157
185
|
}
|
|
@@ -33,11 +33,11 @@ export async function erpConnectorOperations(
|
|
|
33
33
|
{ operation, i }: { operation: string; i: number }
|
|
34
34
|
) {
|
|
35
35
|
if (operation === 'createOrUpdateObjects') {
|
|
36
|
-
return await createOrUpdateObjects.execute.call(this, i);
|
|
36
|
+
return { json: await createOrUpdateObjects.execute.call(this, i) };
|
|
37
37
|
}
|
|
38
38
|
if (operation === 'transformErpData') {
|
|
39
|
-
return await transform.execute.call(this, i);
|
|
39
|
+
return { json: await transform.execute.call(this, i) };
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
throw new Error(`The operation "${operation}" is not supported!`);
|
|
43
43
|
}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from 'n8n-workflow';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
-
|
|
8
|
+
CustomLimetypeNames,
|
|
9
9
|
Entity,
|
|
10
10
|
ErpData,
|
|
11
11
|
ErpSystem,
|
|
@@ -69,7 +69,7 @@ const defaults: { [key in Entity]: string[] } = {
|
|
|
69
69
|
coworker: ['name'],
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
function
|
|
72
|
+
function getLimetypesPropertiesMapping(): INodeProperties[] {
|
|
73
73
|
return Object.keys(defaults).map((key) => ({
|
|
74
74
|
displayName: key,
|
|
75
75
|
name: key,
|
|
@@ -82,7 +82,7 @@ function getLimeTypesPropertiesMapping(): INodeProperties[] {
|
|
|
82
82
|
}));
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
function getPropertiesMapping(
|
|
85
|
+
function getPropertiesMapping(limetype: Entity): INodePropertyCollection[] {
|
|
86
86
|
return [
|
|
87
87
|
{
|
|
88
88
|
displayName: 'Properties',
|
|
@@ -94,7 +94,7 @@ function getPropertiesMapping(limeType: Entity): INodePropertyCollection[] {
|
|
|
94
94
|
type: 'options',
|
|
95
95
|
default: '',
|
|
96
96
|
description: 'Name of the property',
|
|
97
|
-
options: defaults[
|
|
97
|
+
options: defaults[limetype]?.map((property) => ({
|
|
98
98
|
name: property,
|
|
99
99
|
value: property,
|
|
100
100
|
})),
|
|
@@ -187,8 +187,8 @@ export const properties: INodeProperties[] = [
|
|
|
187
187
|
},
|
|
188
188
|
},
|
|
189
189
|
{
|
|
190
|
-
displayName: 'Custom
|
|
191
|
-
name: '
|
|
190
|
+
displayName: 'Custom Limetype Name',
|
|
191
|
+
name: 'customLimetypeNames',
|
|
192
192
|
type: 'collection',
|
|
193
193
|
default: {},
|
|
194
194
|
description: 'Optional custom name for the Lime CRM types.',
|
|
@@ -224,8 +224,8 @@ export const properties: INodeProperties[] = [
|
|
|
224
224
|
operation: ['transformErpData'],
|
|
225
225
|
},
|
|
226
226
|
},
|
|
227
|
-
description: 'Select
|
|
228
|
-
options:
|
|
227
|
+
description: 'Select Limetype',
|
|
228
|
+
options: getLimetypesPropertiesMapping(),
|
|
229
229
|
},
|
|
230
230
|
];
|
|
231
231
|
|
|
@@ -238,10 +238,10 @@ export async function execute(this: IExecuteFunctions, i: number) {
|
|
|
238
238
|
'searchParameters',
|
|
239
239
|
i
|
|
240
240
|
) as SearchParameters;
|
|
241
|
-
const
|
|
242
|
-
'
|
|
241
|
+
const customLimetypeNames = this.getNodeParameter(
|
|
242
|
+
'customLimetypeNames',
|
|
243
243
|
i
|
|
244
|
-
) as
|
|
244
|
+
) as CustomLimetypeNames;
|
|
245
245
|
const customPropertiesMapping = this.getNodeParameter(
|
|
246
246
|
'customPropertiesMapping',
|
|
247
247
|
i
|
|
@@ -249,8 +249,8 @@ export async function execute(this: IExecuteFunctions, i: number) {
|
|
|
249
249
|
|
|
250
250
|
const customPropertiesNames = Object.fromEntries(
|
|
251
251
|
Object.entries(customPropertiesMapping).map(
|
|
252
|
-
([
|
|
253
|
-
|
|
252
|
+
([limetype, { properties }]) => [
|
|
253
|
+
limetype,
|
|
254
254
|
Object.fromEntries(
|
|
255
255
|
properties.map(
|
|
256
256
|
({ defaultPropertyName, customPropertyName }) => [
|
|
@@ -268,7 +268,7 @@ export async function execute(this: IExecuteFunctions, i: number) {
|
|
|
268
268
|
entity,
|
|
269
269
|
data[0].json as ErpData,
|
|
270
270
|
searchParameters,
|
|
271
|
-
|
|
271
|
+
customLimetypeNames,
|
|
272
272
|
customPropertiesNames
|
|
273
273
|
);
|
|
274
274
|
}
|
|
@@ -4,7 +4,7 @@ export type Entity = 'invoice' | 'invoicerow' | 'company' | 'coworker';
|
|
|
4
4
|
export type ErpSystem = 'fortnox';
|
|
5
5
|
export type ErpData = Record<string, unknown>;
|
|
6
6
|
|
|
7
|
-
export type
|
|
7
|
+
export type CustomLimetypeNames = Partial<Record<Entity, string>>;
|
|
8
8
|
|
|
9
9
|
export type CustomPropertiesNames = Partial<
|
|
10
10
|
Record<Entity, Record<string, string>>
|
|
@@ -33,7 +33,7 @@ export function transform(
|
|
|
33
33
|
entity: Entity,
|
|
34
34
|
data: ErpData,
|
|
35
35
|
searchParameters: SearchParameters,
|
|
36
|
-
|
|
36
|
+
customLimetypeNames?: CustomLimetypeNames,
|
|
37
37
|
customPropertiesNames?: CustomPropertiesNames
|
|
38
38
|
): LimeCrmData {
|
|
39
39
|
if (erpSystem === 'fortnox') {
|
|
@@ -41,7 +41,7 @@ export function transform(
|
|
|
41
41
|
entity,
|
|
42
42
|
data,
|
|
43
43
|
searchParameters,
|
|
44
|
-
|
|
44
|
+
customLimetypeNames,
|
|
45
45
|
customPropertiesNames
|
|
46
46
|
);
|
|
47
47
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
CustomLimetypeNames,
|
|
3
3
|
CustomPropertiesNames,
|
|
4
4
|
Entity,
|
|
5
5
|
ErpData,
|
|
@@ -12,7 +12,7 @@ export abstract class BaseTransformer {
|
|
|
12
12
|
entity: Entity,
|
|
13
13
|
data: ErpData,
|
|
14
14
|
searchParameters: SearchParameters,
|
|
15
|
-
|
|
15
|
+
customLimetypeNames?: CustomLimetypeNames,
|
|
16
16
|
customPropertiesNames?: CustomPropertiesNames
|
|
17
17
|
): LimeCrmData;
|
|
18
18
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseTransformer } from './baseTransformer';
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
CustomLimetypeNames,
|
|
4
4
|
CustomPropertiesNames,
|
|
5
5
|
Entity,
|
|
6
6
|
ErpData,
|
|
@@ -111,7 +111,7 @@ export class FortnoxTransformer extends BaseTransformer {
|
|
|
111
111
|
entity: Entity,
|
|
112
112
|
data: ErpData,
|
|
113
113
|
searchParameters: SearchParameters,
|
|
114
|
-
|
|
114
|
+
customLimetypeNames?: CustomLimetypeNames,
|
|
115
115
|
customPropertiesNames?: CustomPropertiesNames
|
|
116
116
|
): LimeCrmData {
|
|
117
117
|
if (entity === 'invoice') {
|
|
@@ -119,7 +119,7 @@ export class FortnoxTransformer extends BaseTransformer {
|
|
|
119
119
|
return this._transformInvoice(
|
|
120
120
|
data as FortnoxInvoiceData,
|
|
121
121
|
searchParameters,
|
|
122
|
-
|
|
122
|
+
customLimetypeNames,
|
|
123
123
|
customPropertiesNames
|
|
124
124
|
);
|
|
125
125
|
}
|
|
@@ -133,13 +133,13 @@ export class FortnoxTransformer extends BaseTransformer {
|
|
|
133
133
|
protected _transformInvoice(
|
|
134
134
|
data: FortnoxInvoiceData,
|
|
135
135
|
searchParameters: SearchParameters,
|
|
136
|
-
|
|
136
|
+
customLimetypeNames?: CustomLimetypeNames,
|
|
137
137
|
customPropertiesNames?: CustomPropertiesNames
|
|
138
138
|
): LimeCrmData {
|
|
139
139
|
const limeCrmData: LimeCrmData = [];
|
|
140
140
|
|
|
141
141
|
const invoice: LimeCrmObjectData = {
|
|
142
|
-
_limetype:
|
|
142
|
+
_limetype: customLimetypeNames?.invoice || 'invoice',
|
|
143
143
|
_search: searchParameters,
|
|
144
144
|
};
|
|
145
145
|
|
|
@@ -165,7 +165,7 @@ export class FortnoxTransformer extends BaseTransformer {
|
|
|
165
165
|
value: invoiceRow['RowId'],
|
|
166
166
|
create: true,
|
|
167
167
|
},
|
|
168
|
-
|
|
168
|
+
customLimetypeNames,
|
|
169
169
|
customPropertiesNames
|
|
170
170
|
)
|
|
171
171
|
);
|
|
@@ -177,13 +177,13 @@ export class FortnoxTransformer extends BaseTransformer {
|
|
|
177
177
|
protected _transformInvoiceRow(
|
|
178
178
|
data: FortnoxInvoiceRowData,
|
|
179
179
|
searchParameters: SearchParameters,
|
|
180
|
-
|
|
180
|
+
customLimetypeNames?: CustomLimetypeNames,
|
|
181
181
|
customPropertiesNames?: CustomPropertiesNames
|
|
182
182
|
): LimeCrmData {
|
|
183
183
|
const limeCrmData: LimeCrmData = [];
|
|
184
184
|
|
|
185
185
|
const invoiceRow: LimeCrmObjectData = {
|
|
186
|
-
_limetype:
|
|
186
|
+
_limetype: customLimetypeNames?.invoicerow || 'invoicerow',
|
|
187
187
|
_search: searchParameters,
|
|
188
188
|
};
|
|
189
189
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
INodeExecutionData,
|
|
3
|
+
IExecuteFunctions,
|
|
4
|
+
INodeProperties,
|
|
5
|
+
NodePropertyTypes,
|
|
6
|
+
NodeOperationError,
|
|
7
|
+
} from 'n8n-workflow';
|
|
8
|
+
|
|
9
|
+
import * as getSingleLimetype from './operations/getSingleLimetype';
|
|
10
|
+
import * as getAllLimetypes from './operations/getAllLimetypes.operation';
|
|
11
|
+
import * as getSingleFileMetadata from '../metadata/operations/getSingleFileMetadata';
|
|
12
|
+
import { METADATA_RESOURCE } from '../../commons';
|
|
13
|
+
|
|
14
|
+
export const metadataFields: INodeProperties[] = [
|
|
15
|
+
{
|
|
16
|
+
displayName: 'Operation',
|
|
17
|
+
name: 'operation',
|
|
18
|
+
type: 'options' as NodePropertyTypes,
|
|
19
|
+
noDataExpression: true,
|
|
20
|
+
displayOptions: {
|
|
21
|
+
show: {
|
|
22
|
+
resource: [METADATA_RESOURCE],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
options: [
|
|
26
|
+
getAllLimetypes.description,
|
|
27
|
+
getSingleLimetype.description,
|
|
28
|
+
getSingleFileMetadata.description,
|
|
29
|
+
],
|
|
30
|
+
default: 'listTypes',
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
...getSingleLimetype.properties,
|
|
34
|
+
...getSingleFileMetadata.properties,
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
export async function metadataOperations(
|
|
38
|
+
this: IExecuteFunctions,
|
|
39
|
+
{ operation, i }: { operation: string; i: number }
|
|
40
|
+
): Promise<INodeExecutionData> {
|
|
41
|
+
switch (operation) {
|
|
42
|
+
case 'getAllLimetypes': {
|
|
43
|
+
return { json: await getAllLimetypes.execute.call(this) };
|
|
44
|
+
}
|
|
45
|
+
case 'getSingleLimetype': {
|
|
46
|
+
return { json: await getSingleLimetype.execute.call(this, i) };
|
|
47
|
+
}
|
|
48
|
+
case 'getSingleFileMetadata': {
|
|
49
|
+
return { json: await getSingleFileMetadata.execute.call(this, i) };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
throw new NodeOperationError(
|
|
54
|
+
this.getNode(),
|
|
55
|
+
`The operation "${operation}" is not supported!`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IExecuteFunctions } from 'n8n-workflow';
|
|
2
|
+
|
|
3
|
+
import { getLimetypesFromApi } from '../../../transport';
|
|
4
|
+
import { Limetype } from '../../../model';
|
|
5
|
+
import { NodeResponse } from '../../../../nodeResponse';
|
|
6
|
+
|
|
7
|
+
export const description = {
|
|
8
|
+
name: 'Get all Limetypes',
|
|
9
|
+
value: 'getAllLimetypes',
|
|
10
|
+
description: 'Get a list of all available Limetypes',
|
|
11
|
+
action: 'Get all Limetypes',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export async function execute(
|
|
15
|
+
this: IExecuteFunctions
|
|
16
|
+
): Promise<NodeResponse<Limetype[]>> {
|
|
17
|
+
return await getLimetypesFromApi(this);
|
|
18
|
+
}
|