@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,22 @@
|
|
|
1
|
+
type LimetypeProperty = {
|
|
2
|
+
name: string;
|
|
3
|
+
localname: string;
|
|
4
|
+
type: string;
|
|
5
|
+
} & Record<string, unknown>;
|
|
6
|
+
|
|
7
|
+
type LimetypeLocalName = {
|
|
8
|
+
singular: string;
|
|
9
|
+
plural: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
type Limetype = {
|
|
13
|
+
name: string;
|
|
14
|
+
localname: LimetypeLocalName;
|
|
15
|
+
properties: LimetypeProperty[];
|
|
16
|
+
} & Record<string, unknown>;
|
|
17
|
+
|
|
18
|
+
type Limeobject = {
|
|
19
|
+
id_: number;
|
|
20
|
+
} & Record<string, unknown>;
|
|
21
|
+
|
|
22
|
+
export { LimetypeProperty, Limetype, Limeobject };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import {
|
|
2
|
+
INodeExecutionData,
|
|
3
|
+
IExecuteFunctions,
|
|
4
|
+
INodeProperties,
|
|
5
|
+
NodePropertyTypes,
|
|
6
|
+
NodeOperationError,
|
|
7
|
+
} from 'n8n-workflow';
|
|
8
|
+
|
|
9
|
+
import * as createSingleObject from './operations/createSingleObject';
|
|
10
|
+
import * as getSingleObject from './operations/getSingleObject';
|
|
11
|
+
import * as updateSingleObject from './operations/updateSingleObject.operation';
|
|
12
|
+
import * as deleteSingleObject from './operations/deleteSingleObject';
|
|
13
|
+
import * as getManyObjects from './operations/getManyObjects';
|
|
14
|
+
import * as getSingleFile from './operations/getSingleFile';
|
|
15
|
+
|
|
16
|
+
import { DATA_RESOURCE } from '../../commons';
|
|
17
|
+
|
|
18
|
+
export const dataFields: INodeProperties[] = [
|
|
19
|
+
{
|
|
20
|
+
displayName: 'Operation',
|
|
21
|
+
name: 'operation',
|
|
22
|
+
type: 'options' as NodePropertyTypes,
|
|
23
|
+
noDataExpression: true,
|
|
24
|
+
displayOptions: {
|
|
25
|
+
show: {
|
|
26
|
+
resource: [DATA_RESOURCE],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
options: [
|
|
30
|
+
createSingleObject.description,
|
|
31
|
+
getSingleObject.description,
|
|
32
|
+
updateSingleObject.description,
|
|
33
|
+
deleteSingleObject.description,
|
|
34
|
+
getManyObjects.description,
|
|
35
|
+
getSingleFile.description,
|
|
36
|
+
],
|
|
37
|
+
default: 'fetchMany',
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
...createSingleObject.properties,
|
|
41
|
+
...getSingleObject.properties,
|
|
42
|
+
...updateSingleObject.properties,
|
|
43
|
+
...deleteSingleObject.properties,
|
|
44
|
+
...getSingleFile.properties,
|
|
45
|
+
...getManyObjects.properties,
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
export async function dataOperations(
|
|
49
|
+
this: IExecuteFunctions,
|
|
50
|
+
{ operation, i }: { operation: string; i: number }
|
|
51
|
+
): Promise<INodeExecutionData> {
|
|
52
|
+
switch (operation) {
|
|
53
|
+
case 'createSingleObject': {
|
|
54
|
+
return { json: await createSingleObject.execute.call(this, i) };
|
|
55
|
+
}
|
|
56
|
+
case 'getSingleObject': {
|
|
57
|
+
return await getSingleObject.execute.call(this, i);
|
|
58
|
+
}
|
|
59
|
+
case 'updateSingleObject': {
|
|
60
|
+
return { json: await updateSingleObject.execute.call(this, i) };
|
|
61
|
+
}
|
|
62
|
+
case 'deleteSingleObject': {
|
|
63
|
+
await deleteSingleObject.execute.call(this, i);
|
|
64
|
+
return { json: { success: true } };
|
|
65
|
+
}
|
|
66
|
+
case 'getManyObjects': {
|
|
67
|
+
return {
|
|
68
|
+
json: await getManyObjects.execute.call(this, i),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
case 'getSingleFile': {
|
|
72
|
+
return await getSingleFile.execute.call(this, i);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
throw new NodeOperationError(
|
|
77
|
+
this.getNode(),
|
|
78
|
+
`The operation "${operation}" is not supported!`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
@@ -1,35 +1,38 @@
|
|
|
1
1
|
import { IDataObject, IExecuteFunctions, INodeProperties } from 'n8n-workflow';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { createLimeobject } from '../../../transport';
|
|
4
|
+
import { DATA_RESOURCE } from '../../../commons';
|
|
5
|
+
import {
|
|
6
|
+
getFileProperties,
|
|
7
|
+
processFileResponse,
|
|
8
|
+
setFileProperties,
|
|
9
|
+
} from '../../../commons/files';
|
|
5
10
|
|
|
6
11
|
export const description = {
|
|
7
|
-
name: 'Create Object',
|
|
8
|
-
value: '
|
|
9
|
-
description: 'Create a new object',
|
|
10
|
-
action: 'Create
|
|
12
|
+
name: 'Create Single Object',
|
|
13
|
+
value: 'createSingleObject',
|
|
14
|
+
description: 'Create a single new object',
|
|
15
|
+
action: 'Create 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 create',
|
|
24
29
|
displayOptions: {
|
|
25
30
|
show: {
|
|
26
|
-
resource: [
|
|
27
|
-
operation: ['
|
|
31
|
+
resource: [DATA_RESOURCE],
|
|
32
|
+
operation: ['createSingleObject'],
|
|
28
33
|
},
|
|
29
34
|
},
|
|
30
35
|
},
|
|
31
|
-
|
|
32
|
-
// Object data input method
|
|
33
36
|
{
|
|
34
37
|
displayName: 'Input Method',
|
|
35
38
|
name: 'inputMethod',
|
|
@@ -48,13 +51,11 @@ export const properties: INodeProperties[] = [
|
|
|
48
51
|
description: 'How to input the object data',
|
|
49
52
|
displayOptions: {
|
|
50
53
|
show: {
|
|
51
|
-
resource: [
|
|
52
|
-
operation: ['
|
|
54
|
+
resource: [DATA_RESOURCE],
|
|
55
|
+
operation: ['createSingleObject'],
|
|
53
56
|
},
|
|
54
57
|
},
|
|
55
58
|
},
|
|
56
|
-
|
|
57
|
-
// Dynamic properties for form input
|
|
58
59
|
{
|
|
59
60
|
displayName: 'Properties',
|
|
60
61
|
name: 'properties',
|
|
@@ -62,15 +63,12 @@ export const properties: INodeProperties[] = [
|
|
|
62
63
|
placeholder: 'Add Property',
|
|
63
64
|
typeOptions: {
|
|
64
65
|
multipleValues: true,
|
|
65
|
-
sortable: true,
|
|
66
|
-
loadOptionsMethod: 'getLimeTypeProperties',
|
|
67
|
-
loadOptionsDependsOn: ['limeType'],
|
|
68
66
|
},
|
|
69
67
|
default: {},
|
|
70
68
|
displayOptions: {
|
|
71
69
|
show: {
|
|
72
|
-
resource: [
|
|
73
|
-
operation: ['
|
|
70
|
+
resource: [DATA_RESOURCE],
|
|
71
|
+
operation: ['createSingleObject'],
|
|
74
72
|
inputMethod: ['fields'],
|
|
75
73
|
},
|
|
76
74
|
},
|
|
@@ -84,8 +82,9 @@ export const properties: INodeProperties[] = [
|
|
|
84
82
|
name: 'name',
|
|
85
83
|
type: 'options',
|
|
86
84
|
typeOptions: {
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
sortable: true,
|
|
86
|
+
loadOptionsMethod: 'getLimetypeProperties',
|
|
87
|
+
loadOptionsDependsOn: ['limetype'],
|
|
89
88
|
},
|
|
90
89
|
default: '',
|
|
91
90
|
description: 'Name of the property',
|
|
@@ -101,8 +100,6 @@ export const properties: INodeProperties[] = [
|
|
|
101
100
|
},
|
|
102
101
|
],
|
|
103
102
|
},
|
|
104
|
-
|
|
105
|
-
// JSON input
|
|
106
103
|
{
|
|
107
104
|
displayName: 'Object (JSON)',
|
|
108
105
|
name: 'objectJson',
|
|
@@ -111,8 +108,8 @@ export const properties: INodeProperties[] = [
|
|
|
111
108
|
description: 'Object to create in JSON format',
|
|
112
109
|
displayOptions: {
|
|
113
110
|
show: {
|
|
114
|
-
resource: [
|
|
115
|
-
operation: ['
|
|
111
|
+
resource: [DATA_RESOURCE],
|
|
112
|
+
operation: ['createSingleObject'],
|
|
116
113
|
inputMethod: ['json'],
|
|
117
114
|
},
|
|
118
115
|
},
|
|
@@ -123,7 +120,7 @@ export const properties: INodeProperties[] = [
|
|
|
123
120
|
];
|
|
124
121
|
|
|
125
122
|
export async function execute(this: IExecuteFunctions, i: number) {
|
|
126
|
-
const
|
|
123
|
+
const limetype = this.getNodeParameter('limetype', i) as string;
|
|
127
124
|
const inputMethod = this.getNodeParameter('inputMethod', i) as string;
|
|
128
125
|
|
|
129
126
|
let objectData: IDataObject;
|
|
@@ -148,5 +145,31 @@ export async function execute(this: IExecuteFunctions, i: number) {
|
|
|
148
145
|
}
|
|
149
146
|
}
|
|
150
147
|
|
|
151
|
-
|
|
148
|
+
const fileProperties = await getFileProperties(
|
|
149
|
+
this,
|
|
150
|
+
limetype,
|
|
151
|
+
new Set(Object.keys(objectData))
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
const setFilePropertiesResponse = await setFileProperties(
|
|
155
|
+
this,
|
|
156
|
+
i,
|
|
157
|
+
fileProperties,
|
|
158
|
+
objectData
|
|
159
|
+
);
|
|
160
|
+
if (!setFilePropertiesResponse.success) return setFilePropertiesResponse;
|
|
161
|
+
|
|
162
|
+
const createLimeobjectResponse = await createLimeobject(
|
|
163
|
+
this,
|
|
164
|
+
limetype,
|
|
165
|
+
setFilePropertiesResponse.data
|
|
166
|
+
);
|
|
167
|
+
if (!createLimeobjectResponse.success) return createLimeobjectResponse;
|
|
168
|
+
|
|
169
|
+
const response = await processFileResponse(
|
|
170
|
+
this,
|
|
171
|
+
fileProperties,
|
|
172
|
+
createLimeobjectResponse.data
|
|
173
|
+
);
|
|
174
|
+
return response.json;
|
|
152
175
|
}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { IExecuteFunctions, INodeProperties } from 'n8n-workflow';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { deleteLimeobject } from '../../../transport';
|
|
4
|
+
import { DATA_RESOURCE } from '../../../commons';
|
|
5
5
|
|
|
6
6
|
export const description = {
|
|
7
|
-
name: 'Delete Object',
|
|
8
|
-
value: '
|
|
9
|
-
description: 'Delete
|
|
10
|
-
action: 'Delete
|
|
7
|
+
name: 'Delete Single Object',
|
|
8
|
+
value: 'deleteSingleObject',
|
|
9
|
+
description: 'Delete one specific object',
|
|
10
|
+
action: 'Delete single object',
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export const properties: INodeProperties[] = [
|
|
14
14
|
// Limetype selection
|
|
15
15
|
{
|
|
16
|
-
displayName: '
|
|
17
|
-
name: '
|
|
16
|
+
displayName: 'Limetype',
|
|
17
|
+
name: 'limetype',
|
|
18
18
|
type: 'options',
|
|
19
19
|
typeOptions: {
|
|
20
|
-
loadOptionsMethod: '
|
|
20
|
+
loadOptionsMethod: 'getLimetypes',
|
|
21
21
|
},
|
|
22
22
|
required: true,
|
|
23
23
|
default: '',
|
|
24
24
|
description: 'The type of entity to delete',
|
|
25
25
|
displayOptions: {
|
|
26
26
|
show: {
|
|
27
|
-
resource: [
|
|
28
|
-
operation: ['
|
|
27
|
+
resource: [DATA_RESOURCE],
|
|
28
|
+
operation: ['deleteSingleObject'],
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
31
|
},
|
|
@@ -40,16 +40,16 @@ export const properties: INodeProperties[] = [
|
|
|
40
40
|
description: 'The ID of the object to delete',
|
|
41
41
|
displayOptions: {
|
|
42
42
|
show: {
|
|
43
|
-
resource: [
|
|
44
|
-
operation: ['
|
|
43
|
+
resource: [DATA_RESOURCE],
|
|
44
|
+
operation: ['deleteSingleObject'],
|
|
45
45
|
},
|
|
46
46
|
},
|
|
47
47
|
},
|
|
48
48
|
];
|
|
49
49
|
|
|
50
50
|
export async function execute(this: IExecuteFunctions, i: number) {
|
|
51
|
-
const
|
|
51
|
+
const limetype = this.getNodeParameter('limetype', i) as string;
|
|
52
52
|
const objectId = this.getNodeParameter('objectId', i) as string;
|
|
53
53
|
|
|
54
|
-
return await
|
|
54
|
+
return await deleteLimeobject(this, limetype, objectId);
|
|
55
55
|
}
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { IExecuteFunctions, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
|
|
3
|
+
import { queryLimeobjects } from '../../../transport';
|
|
4
|
+
import { DATA_RESOURCE } from '../../../commons';
|
|
5
|
+
|
|
6
|
+
export const description = {
|
|
7
|
+
name: 'Get Many Objects',
|
|
8
|
+
value: 'getManyObjects',
|
|
9
|
+
description: 'Get a list of many objects',
|
|
10
|
+
action: 'Get many objects',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const BATCHSIZE = 50;
|
|
14
|
+
|
|
15
|
+
interface ResponseFormat {
|
|
16
|
+
object: {
|
|
17
|
+
[key: string]: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface OrderByCollection {
|
|
22
|
+
orderByFields: {
|
|
23
|
+
propertyName: string;
|
|
24
|
+
sortDirection: 'ASC' | 'DESC';
|
|
25
|
+
}[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const properties: INodeProperties[] = [
|
|
29
|
+
{
|
|
30
|
+
displayName: 'Limetype',
|
|
31
|
+
name: 'limetype',
|
|
32
|
+
type: 'options',
|
|
33
|
+
typeOptions: {
|
|
34
|
+
loadOptionsMethod: 'getLimetypes',
|
|
35
|
+
},
|
|
36
|
+
required: true,
|
|
37
|
+
default: '',
|
|
38
|
+
description: 'The type of entity to query',
|
|
39
|
+
displayOptions: {
|
|
40
|
+
show: {
|
|
41
|
+
resource: [DATA_RESOURCE],
|
|
42
|
+
operation: ['getManyObjects'],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
displayName: 'Response Format',
|
|
48
|
+
name: 'responseFormatInputMethod',
|
|
49
|
+
type: 'options',
|
|
50
|
+
required: true,
|
|
51
|
+
default: 'fields',
|
|
52
|
+
description: 'Select how the response should be formatted',
|
|
53
|
+
displayOptions: {
|
|
54
|
+
show: {
|
|
55
|
+
resource: [DATA_RESOURCE],
|
|
56
|
+
operation: ['getManyObjects'],
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
options: [
|
|
60
|
+
{
|
|
61
|
+
name: 'Properties',
|
|
62
|
+
value: 'fields',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'JSON',
|
|
66
|
+
value: 'json',
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
displayName: 'Response Format (Form Fields)',
|
|
72
|
+
name: 'responseFormatProperties',
|
|
73
|
+
type: 'fixedCollection',
|
|
74
|
+
placeholder: 'Add Property',
|
|
75
|
+
typeOptions: {
|
|
76
|
+
multipleValues: true,
|
|
77
|
+
},
|
|
78
|
+
default: {},
|
|
79
|
+
displayOptions: {
|
|
80
|
+
show: {
|
|
81
|
+
resource: [DATA_RESOURCE],
|
|
82
|
+
operation: ['getManyObjects'],
|
|
83
|
+
responseFormatInputMethod: ['fields'],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
options: [
|
|
87
|
+
{
|
|
88
|
+
displayName: 'Property',
|
|
89
|
+
name: 'property',
|
|
90
|
+
values: [
|
|
91
|
+
{
|
|
92
|
+
displayName: 'Property Name',
|
|
93
|
+
name: 'name',
|
|
94
|
+
type: 'options',
|
|
95
|
+
typeOptions: {
|
|
96
|
+
sortable: true,
|
|
97
|
+
loadOptionsMethod: 'getNoHasManyProperties',
|
|
98
|
+
loadOptionsDependsOn: ['limetype'],
|
|
99
|
+
},
|
|
100
|
+
default: '',
|
|
101
|
+
description: 'Name of the property',
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
displayName: 'Response Format (JSON)',
|
|
109
|
+
name: 'responseFormatJson',
|
|
110
|
+
type: 'json',
|
|
111
|
+
required: true,
|
|
112
|
+
default: '{\n\t"object": {\n\t\t"_id": ""\n\t}\n}',
|
|
113
|
+
description:
|
|
114
|
+
'Information included in the response when using JSON format',
|
|
115
|
+
displayOptions: {
|
|
116
|
+
show: {
|
|
117
|
+
resource: [DATA_RESOURCE],
|
|
118
|
+
operation: ['getManyObjects'],
|
|
119
|
+
responseFormatInputMethod: ['json'],
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
displayName: 'Filter (JSON)',
|
|
125
|
+
name: 'filter',
|
|
126
|
+
type: 'json',
|
|
127
|
+
default: '{}',
|
|
128
|
+
description: "The filter DSL defining the query's conditions",
|
|
129
|
+
displayOptions: {
|
|
130
|
+
show: {
|
|
131
|
+
resource: [DATA_RESOURCE],
|
|
132
|
+
operation: ['getManyObjects'],
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
displayName: 'Limit',
|
|
138
|
+
name: 'limit',
|
|
139
|
+
type: 'number',
|
|
140
|
+
default: 50,
|
|
141
|
+
description: 'The maximum number of records to return',
|
|
142
|
+
displayOptions: {
|
|
143
|
+
show: {
|
|
144
|
+
resource: [DATA_RESOURCE],
|
|
145
|
+
operation: ['getManyObjects'],
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
displayName: 'Order By',
|
|
151
|
+
name: 'orderByInputMethod',
|
|
152
|
+
type: 'options',
|
|
153
|
+
required: true,
|
|
154
|
+
default: 'fields',
|
|
155
|
+
description: 'Select how the response should be ordered',
|
|
156
|
+
displayOptions: {
|
|
157
|
+
show: {
|
|
158
|
+
resource: [DATA_RESOURCE],
|
|
159
|
+
operation: ['getManyObjects'],
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
options: [
|
|
163
|
+
{
|
|
164
|
+
name: 'Form Fields',
|
|
165
|
+
value: 'fields',
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: 'JSON',
|
|
169
|
+
value: 'json',
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
displayName: 'Order By (Form Fields)',
|
|
175
|
+
name: 'orderByProperties',
|
|
176
|
+
type: 'fixedCollection',
|
|
177
|
+
placeholder: 'Add Property',
|
|
178
|
+
typeOptions: {
|
|
179
|
+
multipleValues: true,
|
|
180
|
+
},
|
|
181
|
+
default: {},
|
|
182
|
+
description:
|
|
183
|
+
'The list of properties by which to order the query results',
|
|
184
|
+
displayOptions: {
|
|
185
|
+
show: {
|
|
186
|
+
resource: [DATA_RESOURCE],
|
|
187
|
+
operation: ['getManyObjects'],
|
|
188
|
+
orderByInputMethod: ['fields'],
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
options: [
|
|
192
|
+
{
|
|
193
|
+
name: 'orderByFields',
|
|
194
|
+
displayName: 'Order By Fields',
|
|
195
|
+
values: [
|
|
196
|
+
{
|
|
197
|
+
displayName: 'Property Name',
|
|
198
|
+
name: 'propertyName',
|
|
199
|
+
type: 'options',
|
|
200
|
+
required: true,
|
|
201
|
+
typeOptions: {
|
|
202
|
+
sortable: true,
|
|
203
|
+
loadOptionsMethod: 'getNoHasManyProperties',
|
|
204
|
+
loadOptionsDependsOn: ['limetype'],
|
|
205
|
+
},
|
|
206
|
+
default: '',
|
|
207
|
+
description: 'Name of the property to order by',
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
displayName: 'Sort Direction',
|
|
211
|
+
name: 'sortDirection',
|
|
212
|
+
type: 'options',
|
|
213
|
+
default: 'ASC',
|
|
214
|
+
description: 'Ordering direction',
|
|
215
|
+
options: [
|
|
216
|
+
{ name: 'Ascending', value: 'ASC' },
|
|
217
|
+
{ name: 'Descending', value: 'DESC' },
|
|
218
|
+
],
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
displayName: 'Order By (JSON)',
|
|
226
|
+
name: 'orderByJson',
|
|
227
|
+
type: 'json',
|
|
228
|
+
required: true,
|
|
229
|
+
default: '[\n\t{\n\t\t"_id": "ASC"\n\t}\n]',
|
|
230
|
+
description: 'Provide ordering in JSON',
|
|
231
|
+
displayOptions: {
|
|
232
|
+
show: {
|
|
233
|
+
resource: [DATA_RESOURCE],
|
|
234
|
+
operation: ['getManyObjects'],
|
|
235
|
+
orderByInputMethod: ['json'],
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
];
|
|
240
|
+
|
|
241
|
+
function _createResponseFormatObject(
|
|
242
|
+
properties: { name: string }[] = []
|
|
243
|
+
): ResponseFormat {
|
|
244
|
+
const object: Record<string, string> = { _id: '' };
|
|
245
|
+
for (const { name } of properties) {
|
|
246
|
+
if (name) object[name] = '';
|
|
247
|
+
}
|
|
248
|
+
return { object };
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function _getOrderBy(orderByCollection: OrderByCollection) {
|
|
252
|
+
const orderBy =
|
|
253
|
+
orderByCollection.orderByFields &&
|
|
254
|
+
orderByCollection.orderByFields.map((field) => ({
|
|
255
|
+
[field.propertyName]: field.sortDirection,
|
|
256
|
+
}));
|
|
257
|
+
return orderBy || [{ _id: 'ASC' }];
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
async function _fetchLimeObjectsInBatches(
|
|
261
|
+
this: IExecuteFunctions,
|
|
262
|
+
limetype: string,
|
|
263
|
+
responseFormat: ResponseFormat,
|
|
264
|
+
filter: string,
|
|
265
|
+
limit: number,
|
|
266
|
+
orderBy: Array<{ [key: string]: 'ASC' | 'DESC' }>
|
|
267
|
+
) {
|
|
268
|
+
if (limit <= BATCHSIZE) {
|
|
269
|
+
const q = JSON.stringify({
|
|
270
|
+
limetype,
|
|
271
|
+
responseFormat: responseFormat,
|
|
272
|
+
filter: JSON.parse(filter),
|
|
273
|
+
limit: limit,
|
|
274
|
+
offset: 0,
|
|
275
|
+
orderBy: orderBy,
|
|
276
|
+
});
|
|
277
|
+
return queryLimeobjects(this, q);
|
|
278
|
+
} else {
|
|
279
|
+
let allResults: unknown[] = [];
|
|
280
|
+
let fetched = 0;
|
|
281
|
+
let currentOffset = 0;
|
|
282
|
+
while (fetched < limit) {
|
|
283
|
+
const currentLimit = Math.min(BATCHSIZE, limit - fetched);
|
|
284
|
+
const q = JSON.stringify({
|
|
285
|
+
limetype,
|
|
286
|
+
responseFormat: responseFormat,
|
|
287
|
+
filter: JSON.parse(filter),
|
|
288
|
+
limit: currentLimit,
|
|
289
|
+
offset: currentOffset,
|
|
290
|
+
orderBy,
|
|
291
|
+
});
|
|
292
|
+
const batch = await queryLimeobjects(this, q);
|
|
293
|
+
if (!batch.success) {
|
|
294
|
+
return batch;
|
|
295
|
+
}
|
|
296
|
+
const collected = batch.data.objects.length;
|
|
297
|
+
if (!batch || collected === 0) break;
|
|
298
|
+
allResults = [...allResults, ...batch.data.objects];
|
|
299
|
+
fetched += collected;
|
|
300
|
+
currentOffset += collected;
|
|
301
|
+
|
|
302
|
+
if (collected < currentLimit) break;
|
|
303
|
+
}
|
|
304
|
+
return {
|
|
305
|
+
success: true,
|
|
306
|
+
data: allResults,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export async function execute(this: IExecuteFunctions, i: number) {
|
|
312
|
+
const limetype = this.getNodeParameter('limetype', i) as string;
|
|
313
|
+
const responseFormatInputMethod = this.getNodeParameter(
|
|
314
|
+
'responseFormatInputMethod',
|
|
315
|
+
i
|
|
316
|
+
) as string;
|
|
317
|
+
const orderByInputMethod = this.getNodeParameter(
|
|
318
|
+
'orderByInputMethod',
|
|
319
|
+
i
|
|
320
|
+
) as string;
|
|
321
|
+
const filter = this.getNodeParameter('filter', i) as string;
|
|
322
|
+
const limit = this.getNodeParameter('limit', i, 50) as number;
|
|
323
|
+
|
|
324
|
+
let response;
|
|
325
|
+
if (responseFormatInputMethod === 'fields') {
|
|
326
|
+
const properties = this.getNodeParameter(
|
|
327
|
+
'responseFormatProperties',
|
|
328
|
+
i
|
|
329
|
+
) as { property: [{ name: string }] };
|
|
330
|
+
response = _createResponseFormatObject(properties.property);
|
|
331
|
+
} else if (responseFormatInputMethod === 'json') {
|
|
332
|
+
response = this.getNodeParameter('responseFormatJson', i) as string;
|
|
333
|
+
response = JSON.parse(response);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
let orderBy;
|
|
337
|
+
if (orderByInputMethod === 'fields') {
|
|
338
|
+
const orderByCollection = this.getNodeParameter(
|
|
339
|
+
'orderByProperties',
|
|
340
|
+
i
|
|
341
|
+
) as OrderByCollection;
|
|
342
|
+
orderBy = _getOrderBy(orderByCollection);
|
|
343
|
+
} else if (orderByInputMethod === 'json') {
|
|
344
|
+
orderBy = this.getNodeParameter('orderByJson', i) as string;
|
|
345
|
+
orderBy = JSON.parse(orderBy);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
return await _fetchLimeObjectsInBatches.call(
|
|
349
|
+
this,
|
|
350
|
+
limetype,
|
|
351
|
+
response,
|
|
352
|
+
filter,
|
|
353
|
+
limit,
|
|
354
|
+
orderBy
|
|
355
|
+
);
|
|
356
|
+
}
|