@limetech/n8n-nodes-lime 0.1.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/.eslintrc.js +58 -0
- package/.github/copilot-instructions.md +20 -0
- package/.github/workflows/publish.yml +34 -0
- package/README.md +79 -0
- package/credentials/LimeCrmApi.credentials.ts +57 -0
- package/credentials/LimeGoApi.credentials.ts +31 -0
- package/dist/credentials/LimeCrmApi.credentials.d.ts +9 -0
- package/dist/credentials/LimeCrmApi.credentials.js +53 -0
- package/dist/credentials/LimeCrmApi.credentials.js.map +1 -0
- package/dist/credentials/LimeGoApi.credentials.d.ts +15 -0
- package/dist/credentials/LimeGoApi.credentials.js +32 -0
- package/dist/credentials/LimeGoApi.credentials.js.map +1 -0
- package/dist/nodes/lime-crm/GenericTypes.d.ts +80 -0
- package/dist/nodes/lime-crm/GenericTypes.js +7 -0
- package/dist/nodes/lime-crm/GenericTypes.js.map +1 -0
- package/dist/nodes/lime-crm/LimeCrm.node.json +18 -0
- package/dist/nodes/lime-crm/LimeCrmNode.node.d.ts +17 -0
- package/dist/nodes/lime-crm/LimeCrmNode.node.js +114 -0
- package/dist/nodes/lime-crm/LimeCrmNode.node.js.map +1 -0
- package/dist/nodes/lime-crm/LimeCrmTrigger/LimeCrmTrigger.node.d.ts +17 -0
- package/dist/nodes/lime-crm/LimeCrmTrigger/LimeCrmTrigger.node.js +408 -0
- package/dist/nodes/lime-crm/LimeCrmTrigger/LimeCrmTrigger.node.js.map +1 -0
- package/dist/nodes/lime-crm/LimeCrmTrigger.node.d.ts +17 -0
- package/dist/nodes/lime-crm/LimeCrmTrigger.node.js +439 -0
- package/dist/nodes/lime-crm/LimeCrmTrigger.node.js.map +1 -0
- package/dist/nodes/lime-crm/lime-crm.svg +1 -0
- package/dist/nodes/lime-crm/methods/getAllSortableFields.d.ts +7 -0
- package/dist/nodes/lime-crm/methods/getAllSortableFields.js +53 -0
- package/dist/nodes/lime-crm/methods/getAllSortableFields.js.map +1 -0
- package/dist/nodes/lime-crm/methods/getLimeTypeProperties.d.ts +3 -0
- package/dist/nodes/lime-crm/methods/getLimeTypeProperties.js +40 -0
- package/dist/nodes/lime-crm/methods/getLimeTypeProperties.js.map +1 -0
- package/dist/nodes/lime-crm/methods/getLimeTypeRelations.d.ts +7 -0
- package/dist/nodes/lime-crm/methods/getLimeTypeRelations.js +30 -0
- package/dist/nodes/lime-crm/methods/getLimeTypeRelations.js.map +1 -0
- package/dist/nodes/lime-crm/methods/getLimeTypes.d.ts +3 -0
- package/dist/nodes/lime-crm/methods/getLimeTypes.js +33 -0
- package/dist/nodes/lime-crm/methods/getLimeTypes.js.map +1 -0
- package/dist/nodes/lime-crm/methods/getRelatedTypeProperties.d.ts +7 -0
- package/dist/nodes/lime-crm/methods/getRelatedTypeProperties.js +39 -0
- package/dist/nodes/lime-crm/methods/getRelatedTypeProperties.js.map +1 -0
- package/dist/nodes/lime-crm/methods/index.d.ts +5 -0
- package/dist/nodes/lime-crm/methods/index.js +14 -0
- package/dist/nodes/lime-crm/methods/index.js.map +1 -0
- package/dist/nodes/lime-crm/resources/limeObject/commonFields.d.ts +4 -0
- package/dist/nodes/lime-crm/resources/limeObject/commonFields.js +165 -0
- package/dist/nodes/lime-crm/resources/limeObject/commonFields.js.map +1 -0
- package/dist/nodes/lime-crm/resources/limeObject/index.d.ts +6 -0
- package/dist/nodes/lime-crm/resources/limeObject/index.js +79 -0
- package/dist/nodes/lime-crm/resources/limeObject/index.js.map +1 -0
- package/dist/nodes/lime-crm/resources/limeObject/operations/common.operation.d.ts +2 -0
- package/dist/nodes/lime-crm/resources/limeObject/operations/common.operation.js +36 -0
- package/dist/nodes/lime-crm/resources/limeObject/operations/common.operation.js.map +1 -0
- package/dist/nodes/lime-crm/resources/limeObject/operations/create.operation.d.ts +9 -0
- package/dist/nodes/lime-crm/resources/limeObject/operations/create.operation.js +234 -0
- package/dist/nodes/lime-crm/resources/limeObject/operations/create.operation.js.map +1 -0
- package/dist/nodes/lime-crm/resources/limeObject/operations/delete.operation.d.ts +9 -0
- package/dist/nodes/lime-crm/resources/limeObject/operations/delete.operation.js +136 -0
- package/dist/nodes/lime-crm/resources/limeObject/operations/delete.operation.js.map +1 -0
- package/dist/nodes/lime-crm/resources/limeObject/operations/get.operation.d.ts +9 -0
- package/dist/nodes/lime-crm/resources/limeObject/operations/get.operation.js +125 -0
- package/dist/nodes/lime-crm/resources/limeObject/operations/get.operation.js.map +1 -0
- package/dist/nodes/lime-crm/resources/limeObject/operations/getAll.operation.d.ts +3 -0
- package/dist/nodes/lime-crm/resources/limeObject/operations/getAll.operation.js +212 -0
- package/dist/nodes/lime-crm/resources/limeObject/operations/getAll.operation.js.map +1 -0
- package/dist/nodes/lime-crm/resources/limeObject/operations/search.operation.d.ts +9 -0
- package/dist/nodes/lime-crm/resources/limeObject/operations/search.operation.js +232 -0
- package/dist/nodes/lime-crm/resources/limeObject/operations/search.operation.js.map +1 -0
- package/dist/nodes/lime-crm/resources/limeObject/operations/update.operation.d.ts +9 -0
- package/dist/nodes/lime-crm/resources/limeObject/operations/update.operation.js +186 -0
- package/dist/nodes/lime-crm/resources/limeObject/operations/update.operation.js.map +1 -0
- package/dist/nodes/lime-crm/resources/limeType/index.d.ts +6 -0
- package/dist/nodes/lime-crm/resources/limeType/index.js +81 -0
- package/dist/nodes/lime-crm/resources/limeType/index.js.map +1 -0
- package/dist/nodes/lime-crm/resources/limeType/operations/getProperties.operation.d.ts +9 -0
- package/dist/nodes/lime-crm/resources/limeType/operations/getProperties.operation.js +112 -0
- package/dist/nodes/lime-crm/resources/limeType/operations/getProperties.operation.js.map +1 -0
- package/dist/nodes/lime-crm/resources/limeType/operations/getRelations.operation.d.ts +9 -0
- package/dist/nodes/lime-crm/resources/limeType/operations/getRelations.operation.js +112 -0
- package/dist/nodes/lime-crm/resources/limeType/operations/getRelations.operation.js.map +1 -0
- package/dist/nodes/lime-crm/resources/limeType/operations/getType.operation.d.ts +9 -0
- package/dist/nodes/lime-crm/resources/limeType/operations/getType.operation.js +70 -0
- package/dist/nodes/lime-crm/resources/limeType/operations/getType.operation.js.map +1 -0
- package/dist/nodes/lime-crm/resources/limeType/operations/listTypes.operation.d.ts +9 -0
- package/dist/nodes/lime-crm/resources/limeType/operations/listTypes.operation.js +86 -0
- package/dist/nodes/lime-crm/resources/limeType/operations/listTypes.operation.js.map +1 -0
- package/dist/nodes/lime-crm/resources/queryApi/index.d.ts +6 -0
- package/dist/nodes/lime-crm/resources/queryApi/index.js +57 -0
- package/dist/nodes/lime-crm/resources/queryApi/index.js.map +1 -0
- package/dist/nodes/lime-crm/resources/queryApi/operations/executeQuery.operation.d.ts +9 -0
- package/dist/nodes/lime-crm/resources/queryApi/operations/executeQuery.operation.js +559 -0
- package/dist/nodes/lime-crm/resources/queryApi/operations/executeQuery.operation.js.map +1 -0
- package/dist/nodes/lime-crm/transport/index.d.ts +2 -0
- package/dist/nodes/lime-crm/transport/index.js +50 -0
- package/dist/nodes/lime-crm/transport/index.js.map +1 -0
- package/dist/nodes/lime-go/LimeGo.node.d.ts +8 -0
- package/dist/nodes/lime-go/LimeGo.node.js +123 -0
- package/dist/nodes/lime-go/LimeGo.node.js.map +1 -0
- package/dist/nodes/lime-go/actions/organization/get.operation.d.ts +5 -0
- package/dist/nodes/lime-go/actions/organization/get.operation.js +39 -0
- package/dist/nodes/lime-go/actions/organization/get.operation.js.map +1 -0
- package/dist/nodes/lime-go/actions/organization/getByExternalKey.operation.d.ts +5 -0
- package/dist/nodes/lime-go/actions/organization/getByExternalKey.operation.js +54 -0
- package/dist/nodes/lime-go/actions/organization/getByExternalKey.operation.js.map +1 -0
- package/dist/nodes/lime-go/actions/organization/index.d.ts +7 -0
- package/dist/nodes/lime-go/actions/organization/index.js +92 -0
- package/dist/nodes/lime-go/actions/organization/index.js.map +1 -0
- package/dist/nodes/lime-go/actions/organization/organizationFields.d.ts +2 -0
- package/dist/nodes/lime-go/actions/organization/organizationFields.js +162 -0
- package/dist/nodes/lime-go/actions/organization/organizationFields.js.map +1 -0
- package/dist/nodes/lime-go/actions/organization/search.operation.d.ts +5 -0
- package/dist/nodes/lime-go/actions/organization/search.operation.js +70 -0
- package/dist/nodes/lime-go/actions/organization/search.operation.js.map +1 -0
- package/dist/nodes/lime-go/actions/organization/update.operation.d.ts +5 -0
- package/dist/nodes/lime-go/actions/organization/update.operation.js +125 -0
- package/dist/nodes/lime-go/actions/organization/update.operation.js.map +1 -0
- package/dist/nodes/lime-go/actions/person/createMail.operation.d.ts +7 -0
- package/dist/nodes/lime-go/actions/person/createMail.operation.js +130 -0
- package/dist/nodes/lime-go/actions/person/createMail.operation.js.map +1 -0
- package/dist/nodes/lime-go/actions/person/get.operation.d.ts +7 -0
- package/dist/nodes/lime-go/actions/person/get.operation.js +45 -0
- package/dist/nodes/lime-go/actions/person/get.operation.js.map +1 -0
- package/dist/nodes/lime-go/actions/person/index.d.ts +7 -0
- package/dist/nodes/lime-go/actions/person/index.js +92 -0
- package/dist/nodes/lime-go/actions/person/index.js.map +1 -0
- package/dist/nodes/lime-go/actions/person/personFields.d.ts +2 -0
- package/dist/nodes/lime-go/actions/person/personFields.js +134 -0
- package/dist/nodes/lime-go/actions/person/personFields.js.map +1 -0
- package/dist/nodes/lime-go/actions/person/search.operation.d.ts +7 -0
- package/dist/nodes/lime-go/actions/person/search.operation.js +81 -0
- package/dist/nodes/lime-go/actions/person/search.operation.js.map +1 -0
- package/dist/nodes/lime-go/actions/person/update.operation.d.ts +7 -0
- package/dist/nodes/lime-go/actions/person/update.operation.js +104 -0
- package/dist/nodes/lime-go/actions/person/update.operation.js.map +1 -0
- package/dist/nodes/lime-go/lime-go.svg +1 -0
- package/dist/nodes/lime-go/transport/graphqlRequest.d.ts +2 -0
- package/dist/nodes/lime-go/transport/graphqlRequest.js +23 -0
- package/dist/nodes/lime-go/transport/graphqlRequest.js.map +1 -0
- package/dist/nodes/lime-go/transport/transport.d.ts +3 -0
- package/dist/nodes/lime-go/transport/transport.js +58 -0
- package/dist/nodes/lime-go/transport/transport.js.map +1 -0
- package/dist/nodes/lime-go/triggers/webhook.d.ts +10 -0
- package/dist/nodes/lime-go/triggers/webhook.js +92 -0
- package/dist/nodes/lime-go/triggers/webhook.js.map +1 -0
- package/dist/package.json +49 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/docker-compose.yml +44 -0
- package/index.js +3 -0
- package/nodes/lime-crm/GenericTypes.ts +114 -0
- package/nodes/lime-crm/LimeCrm.node.json +18 -0
- package/nodes/lime-crm/LimeCrmNode.node.ts +154 -0
- package/nodes/lime-crm/LimeCrmTrigger/LimeCrmTrigger.node.ts +461 -0
- package/nodes/lime-crm/LimeCrmTrigger.node.ts +505 -0
- package/nodes/lime-crm/lime-crm.svg +1 -0
- package/nodes/lime-crm/methods/getAllSortableFields.ts +73 -0
- package/nodes/lime-crm/methods/getLimeTypeProperties.ts +48 -0
- package/nodes/lime-crm/methods/getLimeTypeRelations.ts +32 -0
- package/nodes/lime-crm/methods/getLimeTypes.ts +33 -0
- package/nodes/lime-crm/methods/getRelatedTypeProperties.ts +47 -0
- package/nodes/lime-crm/methods/index.ts +5 -0
- package/nodes/lime-crm/resources/limeObject/commonFields.ts +179 -0
- package/nodes/lime-crm/resources/limeObject/index.ts +64 -0
- package/nodes/lime-crm/resources/limeObject/operations/common.operation.ts +35 -0
- package/nodes/lime-crm/resources/limeObject/operations/create.operation.ts +234 -0
- package/nodes/lime-crm/resources/limeObject/operations/delete.operation.ts +136 -0
- package/nodes/lime-crm/resources/limeObject/operations/get.operation.ts +124 -0
- package/nodes/lime-crm/resources/limeObject/operations/getAll.operation.ts +242 -0
- package/nodes/lime-crm/resources/limeObject/operations/search.operation.ts +242 -0
- package/nodes/lime-crm/resources/limeObject/operations/update.operation.ts +201 -0
- package/nodes/lime-crm/resources/limeType/index.ts +66 -0
- package/nodes/lime-crm/resources/limeType/operations/getProperties.operation.ts +105 -0
- package/nodes/lime-crm/resources/limeType/operations/getRelations.operation.ts +105 -0
- package/nodes/lime-crm/resources/limeType/operations/getType.operation.ts +58 -0
- package/nodes/lime-crm/resources/limeType/operations/listTypes.operation.ts +76 -0
- package/nodes/lime-crm/resources/queryApi/index.ts +42 -0
- package/nodes/lime-crm/resources/queryApi/operations/executeQuery.operation.ts +605 -0
- package/nodes/lime-crm/transport/index.ts +74 -0
- package/nodes/lime-go/LimeGo.node.ts +146 -0
- package/nodes/lime-go/actions/organization/get.operation.ts +42 -0
- package/nodes/lime-go/actions/organization/getByExternalKey.operation.ts +57 -0
- package/nodes/lime-go/actions/organization/index.ts +69 -0
- package/nodes/lime-go/actions/organization/organizationFields.ts +160 -0
- package/nodes/lime-go/actions/organization/search.operation.ts +73 -0
- package/nodes/lime-go/actions/organization/update.operation.ts +140 -0
- package/nodes/lime-go/actions/person/createMail.operation.ts +140 -0
- package/nodes/lime-go/actions/person/get.operation.ts +51 -0
- package/nodes/lime-go/actions/person/index.ts +69 -0
- package/nodes/lime-go/actions/person/personFields.ts +132 -0
- package/nodes/lime-go/actions/person/search.operation.ts +88 -0
- package/nodes/lime-go/actions/person/update.operation.ts +122 -0
- package/nodes/lime-go/lime-go.svg +1 -0
- package/nodes/lime-go/transport/graphqlRequest.ts +30 -0
- package/package.json +50 -0
- package/tsconfig.json +30 -0
|
@@ -0,0 +1,605 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IExecuteFunctions,
|
|
3
|
+
INodeProperties,
|
|
4
|
+
IDataObject,
|
|
5
|
+
NodeOperationError,
|
|
6
|
+
} from 'n8n-workflow';
|
|
7
|
+
|
|
8
|
+
export const description = {
|
|
9
|
+
name: 'Execute Query',
|
|
10
|
+
value: 'executeQuery',
|
|
11
|
+
description: 'Execute a custom query against the Lime CRM database',
|
|
12
|
+
action: 'Execute a custom query',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const properties: INodeProperties[] = [
|
|
16
|
+
// Limetype selection (dropdown)
|
|
17
|
+
{
|
|
18
|
+
displayName: 'LimeType',
|
|
19
|
+
name: 'limeType',
|
|
20
|
+
type: 'options',
|
|
21
|
+
typeOptions: {
|
|
22
|
+
loadOptionsMethod: 'getLimeTypes',
|
|
23
|
+
},
|
|
24
|
+
required: true,
|
|
25
|
+
default: '',
|
|
26
|
+
description: 'The entity type in Lime CRM to query',
|
|
27
|
+
displayOptions: {
|
|
28
|
+
show: {
|
|
29
|
+
resource: [
|
|
30
|
+
'queryApi',
|
|
31
|
+
],
|
|
32
|
+
operation: [
|
|
33
|
+
'executeQuery',
|
|
34
|
+
],
|
|
35
|
+
queryMode: [
|
|
36
|
+
'guided',
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
// Query Mode toggle
|
|
43
|
+
{
|
|
44
|
+
displayName: 'Query Mode',
|
|
45
|
+
name: 'queryMode',
|
|
46
|
+
type: 'options',
|
|
47
|
+
options: [
|
|
48
|
+
{
|
|
49
|
+
name: 'Guided (UI Builder)',
|
|
50
|
+
value: 'guided',
|
|
51
|
+
description: 'Build your query using the user interface',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'Code (JSON)',
|
|
55
|
+
value: 'code',
|
|
56
|
+
description: 'Write your query as a JSON object',
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
default: 'guided',
|
|
60
|
+
displayOptions: {
|
|
61
|
+
show: {
|
|
62
|
+
resource: [
|
|
63
|
+
'queryApi',
|
|
64
|
+
],
|
|
65
|
+
operation: [
|
|
66
|
+
'executeQuery',
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
// Original JSON query field (for code mode)
|
|
73
|
+
{
|
|
74
|
+
displayName: 'Query',
|
|
75
|
+
name: 'query',
|
|
76
|
+
type: 'json',
|
|
77
|
+
default: '{\n "limetype": "company",\n "properties": ["name", "phone"],\n "filter": {\n "relation": {\n "equals": "customer"\n }\n },\n "take": 10\n}',
|
|
78
|
+
required: true,
|
|
79
|
+
description: 'The query to execute. Must be valid JSON format. See <a href="https://docs.lime-crm.com/query-api/" target="_blank">Query API documentation</a>.',
|
|
80
|
+
displayOptions: {
|
|
81
|
+
show: {
|
|
82
|
+
resource: [
|
|
83
|
+
'queryApi',
|
|
84
|
+
],
|
|
85
|
+
operation: [
|
|
86
|
+
'executeQuery',
|
|
87
|
+
],
|
|
88
|
+
queryMode: [
|
|
89
|
+
'code',
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
typeOptions: {
|
|
94
|
+
alwaysOpenEditWindow: true,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
// Properties selection (UI for adding properties) - simplified without aliases
|
|
99
|
+
{
|
|
100
|
+
displayName: 'Properties',
|
|
101
|
+
name: 'properties',
|
|
102
|
+
type: 'multiOptions',
|
|
103
|
+
typeOptions: {
|
|
104
|
+
loadOptionsMethod: 'getLimeTypeProperties',
|
|
105
|
+
loadOptionsDependsOn: ['limeType'],
|
|
106
|
+
},
|
|
107
|
+
default: [],
|
|
108
|
+
description: 'Properties to retrieve from the selected Lime type',
|
|
109
|
+
displayOptions: {
|
|
110
|
+
show: {
|
|
111
|
+
resource: [
|
|
112
|
+
'queryApi',
|
|
113
|
+
],
|
|
114
|
+
operation: [
|
|
115
|
+
'executeQuery',
|
|
116
|
+
],
|
|
117
|
+
queryMode: [
|
|
118
|
+
'guided',
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
// Relation properties (for accessing related objects)
|
|
125
|
+
{
|
|
126
|
+
displayName: 'Include Relations',
|
|
127
|
+
name: 'includeRelations',
|
|
128
|
+
type: 'boolean',
|
|
129
|
+
default: false,
|
|
130
|
+
description: 'Whether to include properties from related objects',
|
|
131
|
+
displayOptions: {
|
|
132
|
+
show: {
|
|
133
|
+
resource: [
|
|
134
|
+
'queryApi',
|
|
135
|
+
],
|
|
136
|
+
operation: [
|
|
137
|
+
'executeQuery',
|
|
138
|
+
],
|
|
139
|
+
queryMode: [
|
|
140
|
+
'guided',
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
displayName: 'Relations Configuration',
|
|
147
|
+
name: 'relationsConfig',
|
|
148
|
+
placeholder: 'Add Relation',
|
|
149
|
+
type: 'fixedCollection',
|
|
150
|
+
typeOptions: {
|
|
151
|
+
multipleValues: true,
|
|
152
|
+
},
|
|
153
|
+
default: {},
|
|
154
|
+
description: 'Configure properties from related objects',
|
|
155
|
+
displayOptions: {
|
|
156
|
+
show: {
|
|
157
|
+
resource: [
|
|
158
|
+
'queryApi',
|
|
159
|
+
],
|
|
160
|
+
operation: [
|
|
161
|
+
'executeQuery',
|
|
162
|
+
],
|
|
163
|
+
queryMode: [
|
|
164
|
+
'guided',
|
|
165
|
+
],
|
|
166
|
+
includeRelations: [
|
|
167
|
+
true,
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
options: [
|
|
172
|
+
{
|
|
173
|
+
name: 'relation',
|
|
174
|
+
displayName: 'Relation',
|
|
175
|
+
values: [
|
|
176
|
+
{
|
|
177
|
+
displayName: 'Relation Name',
|
|
178
|
+
name: 'relationName',
|
|
179
|
+
type: 'options',
|
|
180
|
+
typeOptions: {
|
|
181
|
+
loadOptionsMethod: 'getLimeTypeRelations',
|
|
182
|
+
loadOptionsDependsOn: ['limetype'],
|
|
183
|
+
},
|
|
184
|
+
default: '',
|
|
185
|
+
description: 'The name of the relation',
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
displayName: 'Properties',
|
|
189
|
+
name: 'properties',
|
|
190
|
+
type: 'multiOptions',
|
|
191
|
+
typeOptions: {
|
|
192
|
+
loadOptionsMethod: 'getRelatedTypeProperties',
|
|
193
|
+
loadOptionsDependsOn: ['limetype', 'relationsConfig.relation[].relationName'],
|
|
194
|
+
},
|
|
195
|
+
default: [],
|
|
196
|
+
description: 'Properties from the related entity',
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
},
|
|
200
|
+
],
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
// Filter (using code editor for flexibility)
|
|
204
|
+
{
|
|
205
|
+
displayName: 'Add Filter',
|
|
206
|
+
name: 'addFilter',
|
|
207
|
+
type: 'boolean',
|
|
208
|
+
default: false,
|
|
209
|
+
description: 'Whether to add a filter to the query',
|
|
210
|
+
displayOptions: {
|
|
211
|
+
show: {
|
|
212
|
+
resource: [
|
|
213
|
+
'queryApi',
|
|
214
|
+
],
|
|
215
|
+
operation: [
|
|
216
|
+
'executeQuery',
|
|
217
|
+
],
|
|
218
|
+
queryMode: [
|
|
219
|
+
'guided',
|
|
220
|
+
],
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
displayName: 'Filter',
|
|
226
|
+
name: 'filter',
|
|
227
|
+
type: 'json',
|
|
228
|
+
default: '{\n "key": "name",\n "op": "contains",\n "exp": "Lime"\n}',
|
|
229
|
+
description: 'Filter to apply to the query (JSON format)',
|
|
230
|
+
displayOptions: {
|
|
231
|
+
show: {
|
|
232
|
+
resource: [
|
|
233
|
+
'queryApi',
|
|
234
|
+
],
|
|
235
|
+
operation: [
|
|
236
|
+
'executeQuery',
|
|
237
|
+
],
|
|
238
|
+
queryMode: [
|
|
239
|
+
'guided',
|
|
240
|
+
],
|
|
241
|
+
addFilter: [
|
|
242
|
+
true,
|
|
243
|
+
],
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
typeOptions: {
|
|
247
|
+
alwaysOpenEditWindow: true,
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
|
|
251
|
+
// Pagination
|
|
252
|
+
{
|
|
253
|
+
displayName: 'Limit',
|
|
254
|
+
name: 'limit',
|
|
255
|
+
type: 'number',
|
|
256
|
+
default: 50,
|
|
257
|
+
description: 'Maximum number of records to return',
|
|
258
|
+
displayOptions: {
|
|
259
|
+
show: {
|
|
260
|
+
resource: [
|
|
261
|
+
'queryApi',
|
|
262
|
+
],
|
|
263
|
+
operation: [
|
|
264
|
+
'executeQuery',
|
|
265
|
+
],
|
|
266
|
+
queryMode: [
|
|
267
|
+
'guided',
|
|
268
|
+
],
|
|
269
|
+
returnAll: [
|
|
270
|
+
false,
|
|
271
|
+
],
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
displayName: 'Offset',
|
|
277
|
+
name: 'offset',
|
|
278
|
+
type: 'number',
|
|
279
|
+
default: 0,
|
|
280
|
+
description: 'Number of records to skip',
|
|
281
|
+
displayOptions: {
|
|
282
|
+
show: {
|
|
283
|
+
resource: [
|
|
284
|
+
'queryApi',
|
|
285
|
+
],
|
|
286
|
+
operation: [
|
|
287
|
+
'executeQuery',
|
|
288
|
+
],
|
|
289
|
+
queryMode: [
|
|
290
|
+
'guided',
|
|
291
|
+
],
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
|
|
296
|
+
// Sorting - simplified without nested structures
|
|
297
|
+
{
|
|
298
|
+
displayName: 'Add Sorting',
|
|
299
|
+
name: 'addSorting',
|
|
300
|
+
type: 'boolean',
|
|
301
|
+
default: false,
|
|
302
|
+
description: 'Whether to add sorting to the query',
|
|
303
|
+
displayOptions: {
|
|
304
|
+
show: {
|
|
305
|
+
resource: [
|
|
306
|
+
'queryApi',
|
|
307
|
+
],
|
|
308
|
+
operation: [
|
|
309
|
+
'executeQuery',
|
|
310
|
+
],
|
|
311
|
+
queryMode: [
|
|
312
|
+
'guided',
|
|
313
|
+
],
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
displayName: 'Sort Field',
|
|
319
|
+
name: 'sortField',
|
|
320
|
+
type: 'options',
|
|
321
|
+
typeOptions: {
|
|
322
|
+
loadOptionsMethod: 'getAllSortableFields',
|
|
323
|
+
loadOptionsDependsOn: ['limetype', 'includeRelations', 'relationsConfig.relation'],
|
|
324
|
+
},
|
|
325
|
+
default: '',
|
|
326
|
+
description: 'Field to sort by',
|
|
327
|
+
displayOptions: {
|
|
328
|
+
show: {
|
|
329
|
+
resource: [
|
|
330
|
+
'queryApi',
|
|
331
|
+
],
|
|
332
|
+
operation: [
|
|
333
|
+
'executeQuery',
|
|
334
|
+
],
|
|
335
|
+
queryMode: [
|
|
336
|
+
'guided',
|
|
337
|
+
],
|
|
338
|
+
addSorting: [
|
|
339
|
+
true,
|
|
340
|
+
],
|
|
341
|
+
},
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
displayName: 'Sort Direction',
|
|
346
|
+
name: 'sortDirection',
|
|
347
|
+
type: 'options',
|
|
348
|
+
options: [
|
|
349
|
+
{
|
|
350
|
+
name: 'Ascending (A-Z)',
|
|
351
|
+
value: 'ASC',
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
name: 'Descending (Z-A)',
|
|
355
|
+
value: 'DESC',
|
|
356
|
+
},
|
|
357
|
+
],
|
|
358
|
+
default: 'ASC',
|
|
359
|
+
description: 'Sort direction',
|
|
360
|
+
displayOptions: {
|
|
361
|
+
show: {
|
|
362
|
+
resource: [
|
|
363
|
+
'queryApi',
|
|
364
|
+
],
|
|
365
|
+
operation: [
|
|
366
|
+
'executeQuery',
|
|
367
|
+
],
|
|
368
|
+
queryMode: [
|
|
369
|
+
'guided',
|
|
370
|
+
],
|
|
371
|
+
addSorting: [
|
|
372
|
+
true,
|
|
373
|
+
],
|
|
374
|
+
},
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
|
|
378
|
+
// Return all or limit results
|
|
379
|
+
{
|
|
380
|
+
displayName: 'Return All',
|
|
381
|
+
name: 'returnAll',
|
|
382
|
+
type: 'boolean',
|
|
383
|
+
displayOptions: {
|
|
384
|
+
show: {
|
|
385
|
+
resource: [
|
|
386
|
+
'queryApi',
|
|
387
|
+
],
|
|
388
|
+
operation: [
|
|
389
|
+
'executeQuery',
|
|
390
|
+
],
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
default: false,
|
|
394
|
+
description: 'Whether to return all results or respect the limit parameter',
|
|
395
|
+
},
|
|
396
|
+
|
|
397
|
+
// Options for the query
|
|
398
|
+
{
|
|
399
|
+
displayName: 'Options',
|
|
400
|
+
name: 'options',
|
|
401
|
+
type: 'collection',
|
|
402
|
+
placeholder: 'Add Option',
|
|
403
|
+
default: {},
|
|
404
|
+
displayOptions: {
|
|
405
|
+
show: {
|
|
406
|
+
resource: [
|
|
407
|
+
'queryApi',
|
|
408
|
+
],
|
|
409
|
+
operation: [
|
|
410
|
+
'executeQuery',
|
|
411
|
+
],
|
|
412
|
+
},
|
|
413
|
+
},
|
|
414
|
+
options: [
|
|
415
|
+
{
|
|
416
|
+
displayName: 'Include Metadata',
|
|
417
|
+
name: 'includeMetadata',
|
|
418
|
+
type: 'boolean',
|
|
419
|
+
default: false,
|
|
420
|
+
description: 'Whether to include metadata about the query result (total count, pagination info, etc.)',
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
displayName: 'Timeout (ms)',
|
|
424
|
+
name: 'timeout',
|
|
425
|
+
type: 'number',
|
|
426
|
+
default: 30000,
|
|
427
|
+
description: 'Timeout for the query in milliseconds',
|
|
428
|
+
},
|
|
429
|
+
],
|
|
430
|
+
},
|
|
431
|
+
];
|
|
432
|
+
|
|
433
|
+
export async function execute(
|
|
434
|
+
this: IExecuteFunctions,
|
|
435
|
+
i: number,
|
|
436
|
+
) {
|
|
437
|
+
// Use the API client from the transport directory
|
|
438
|
+
const { apiRequest } = await import('../../../transport');
|
|
439
|
+
|
|
440
|
+
const queryMode = this.getNodeParameter('queryMode', i) as string;
|
|
441
|
+
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
|
442
|
+
const options = this.getNodeParameter('options', i, {}) as IDataObject;
|
|
443
|
+
|
|
444
|
+
let queryObject: IDataObject;
|
|
445
|
+
|
|
446
|
+
if (queryMode === 'code') {
|
|
447
|
+
// Handle code mode (direct JSON input)
|
|
448
|
+
const queryJson = this.getNodeParameter('query', i) as string;
|
|
449
|
+
try {
|
|
450
|
+
// Parse the JSON query
|
|
451
|
+
if (typeof queryJson === 'string') {
|
|
452
|
+
queryObject = JSON.parse(queryJson);
|
|
453
|
+
} else {
|
|
454
|
+
queryObject = queryJson as IDataObject;
|
|
455
|
+
}
|
|
456
|
+
} catch (error) {
|
|
457
|
+
throw new NodeOperationError(this.getNode(), 'Invalid JSON in query: ' + error.message);
|
|
458
|
+
}
|
|
459
|
+
} else {
|
|
460
|
+
// Handle guided mode (UI builder)
|
|
461
|
+
queryObject = {};
|
|
462
|
+
|
|
463
|
+
// 1. Add limetype
|
|
464
|
+
const limetype = this.getNodeParameter('limeType', i) as string;
|
|
465
|
+
queryObject.limetype = limetype;
|
|
466
|
+
|
|
467
|
+
// 2. Add properties - simplified approach without aliases
|
|
468
|
+
const properties = this.getNodeParameter('properties', i, []) as string[];
|
|
469
|
+
const responseFormat: IDataObject = { object: {} };
|
|
470
|
+
|
|
471
|
+
// Handle direct properties
|
|
472
|
+
properties.forEach((property) => {
|
|
473
|
+
(responseFormat.object as IDataObject)[property] = null;
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
// 3. Add relations if enabled
|
|
477
|
+
const includeRelations = this.getNodeParameter('includeRelations', i, false) as boolean;
|
|
478
|
+
if (includeRelations) {
|
|
479
|
+
const relations = this.getNodeParameter('relationsConfig.relation', i, []) as IDataObject[];
|
|
480
|
+
|
|
481
|
+
relations.forEach((relationConfig) => {
|
|
482
|
+
const relationName = relationConfig.relationName as string;
|
|
483
|
+
const relationProperties = relationConfig.properties as string[] || [];
|
|
484
|
+
|
|
485
|
+
if (relationName && relationProperties.length > 0) {
|
|
486
|
+
const relationObject: IDataObject = {};
|
|
487
|
+
|
|
488
|
+
relationProperties.forEach((property) => {
|
|
489
|
+
relationObject[property] = null;
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
(responseFormat.object as IDataObject)[relationName] = relationObject;
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
queryObject.responseFormat = responseFormat;
|
|
498
|
+
|
|
499
|
+
// 4. Add filter if enabled
|
|
500
|
+
const addFilter = this.getNodeParameter('addFilter', i, false) as boolean;
|
|
501
|
+
if (addFilter) {
|
|
502
|
+
try {
|
|
503
|
+
const filterJson = this.getNodeParameter('filter', i) as string;
|
|
504
|
+
queryObject.filter = typeof filterJson === 'string' ? JSON.parse(filterJson) : filterJson;
|
|
505
|
+
} catch (error) {
|
|
506
|
+
throw new NodeOperationError(this.getNode(), 'Invalid JSON in filter: ' + error.message);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// 5. Add pagination
|
|
511
|
+
if (!returnAll) {
|
|
512
|
+
queryObject.limit = this.getNodeParameter('limit', i, 50) as number;
|
|
513
|
+
}
|
|
514
|
+
queryObject.offset = this.getNodeParameter('offset', i, 0) as number;
|
|
515
|
+
|
|
516
|
+
// 6. Add sorting if enabled - simplified approach
|
|
517
|
+
const addSorting = this.getNodeParameter('addSorting', i, false) as boolean;
|
|
518
|
+
if (addSorting) {
|
|
519
|
+
const sortField = this.getNodeParameter('sortField', i, '') as string;
|
|
520
|
+
const sortDirection = this.getNodeParameter('sortDirection', i, 'ASC') as string;
|
|
521
|
+
|
|
522
|
+
if (sortField) {
|
|
523
|
+
const orderBy: IDataObject[] = [];
|
|
524
|
+
const orderItem: IDataObject = {};
|
|
525
|
+
orderItem[sortField] = sortDirection;
|
|
526
|
+
orderBy.push(orderItem);
|
|
527
|
+
queryObject.orderBy = orderBy;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// If returnAll is true, set a high value to override any take/limit parameter
|
|
533
|
+
if (returnAll) {
|
|
534
|
+
queryObject.limit = 10000; // Use a very high value as a practical limit
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// Add metadata option if requested
|
|
538
|
+
if (options.includeMetadata) {
|
|
539
|
+
queryObject.includemetadata = true;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
const endpoint = '/api/v1/query/';
|
|
543
|
+
|
|
544
|
+
try {
|
|
545
|
+
// Set request options
|
|
546
|
+
const requestOptions: IDataObject = {
|
|
547
|
+
method: 'GET',
|
|
548
|
+
endpoint,
|
|
549
|
+
qs: { q: JSON.stringify(queryObject) },
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
if (options.timeout) {
|
|
553
|
+
requestOptions.timeout = options.timeout as number;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
// If we need to handle pagination, do so
|
|
557
|
+
if (returnAll && queryObject.limit) {
|
|
558
|
+
const results: IDataObject[] = [];
|
|
559
|
+
let hasMoreData = true;
|
|
560
|
+
let currentOffset = queryObject.offset as number || 0;
|
|
561
|
+
|
|
562
|
+
while (hasMoreData) {
|
|
563
|
+
// Update offset for pagination
|
|
564
|
+
queryObject.offset = currentOffset;
|
|
565
|
+
requestOptions.qs = { q: JSON.stringify(queryObject) };
|
|
566
|
+
|
|
567
|
+
const response = await apiRequest.call(this, requestOptions);
|
|
568
|
+
|
|
569
|
+
// If data is received, add it to results
|
|
570
|
+
if (response && response.data && Array.isArray(response.data)) {
|
|
571
|
+
results.push(...response.data);
|
|
572
|
+
|
|
573
|
+
// If we received fewer records than limit, we've reached the end
|
|
574
|
+
if (response.data.length < (queryObject.limit as number)) {
|
|
575
|
+
hasMoreData = false;
|
|
576
|
+
} else {
|
|
577
|
+
// Otherwise, prepare for the next page
|
|
578
|
+
currentOffset += response.data.length;
|
|
579
|
+
}
|
|
580
|
+
} else {
|
|
581
|
+
hasMoreData = false;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// Prepare final response with all data
|
|
586
|
+
const finalResponse: IDataObject = { data: results };
|
|
587
|
+
|
|
588
|
+
// Include metadata if available and requested
|
|
589
|
+
if (options.includeMetadata) {
|
|
590
|
+
finalResponse.metadata = {
|
|
591
|
+
totalCount: results.length,
|
|
592
|
+
// Add other metadata if available
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
return finalResponse.objects;
|
|
597
|
+
} else {
|
|
598
|
+
// Single request without pagination handling
|
|
599
|
+
const response = await apiRequest.call(this, requestOptions);
|
|
600
|
+
return response.objects;
|
|
601
|
+
}
|
|
602
|
+
} catch (error) {
|
|
603
|
+
throw new NodeOperationError(this.getNode(), `Query execution failed: ${error.message}`);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { IExecuteFunctions, ILoadOptionsFunctions, IDataObject, NodeOperationError } from 'n8n-workflow';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Make an API request to the Lime CRM API
|
|
5
|
+
*/
|
|
6
|
+
export async function apiRequest(
|
|
7
|
+
this: IExecuteFunctions | ILoadOptionsFunctions,
|
|
8
|
+
options: IDataObject,
|
|
9
|
+
): Promise<any> {
|
|
10
|
+
// Get credentials for the API
|
|
11
|
+
const credentials = await this.getCredentials('limeCrmApi');
|
|
12
|
+
|
|
13
|
+
if (!credentials) {
|
|
14
|
+
throw new NodeOperationError(this.getNode(), 'No credentials provided');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const baseURL = credentials.url as string;
|
|
18
|
+
const apiKey = credentials.apiKey as string;
|
|
19
|
+
|
|
20
|
+
// Add common headers for all requests
|
|
21
|
+
const headers = {
|
|
22
|
+
'X-API-Key': apiKey,
|
|
23
|
+
'Accept': 'application/json',
|
|
24
|
+
'Content-Type': 'application/json',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const endpoint = options.endpoint as string;
|
|
28
|
+
const method = options.method as string || 'GET';
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const requestOptions: IDataObject = {
|
|
32
|
+
method,
|
|
33
|
+
uri: `${baseURL}${endpoint}`,
|
|
34
|
+
json: true,
|
|
35
|
+
headers,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Add query string parameters if they exist
|
|
39
|
+
if (options.qs) {
|
|
40
|
+
requestOptions.qs = options.qs;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Add request body if it exists and method is not GET
|
|
44
|
+
if (options.body && method !== 'GET') {
|
|
45
|
+
requestOptions.body = options.body;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Add timeout if specified
|
|
49
|
+
if (options.timeout) {
|
|
50
|
+
requestOptions.timeout = options.timeout as number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Execute the request using n8n's helper
|
|
54
|
+
return await this.helpers.request(requestOptions);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
// Add some context to the error message
|
|
57
|
+
if (error.response) {
|
|
58
|
+
// If we have a response with error info
|
|
59
|
+
const statusCode = error.response.statusCode;
|
|
60
|
+
const errorMessage = error.response.body?.message || error.message;
|
|
61
|
+
|
|
62
|
+
throw new NodeOperationError(
|
|
63
|
+
this.getNode(),
|
|
64
|
+
`API request failed [${statusCode}]: ${errorMessage}`
|
|
65
|
+
);
|
|
66
|
+
} else {
|
|
67
|
+
// Generic network error
|
|
68
|
+
throw new NodeOperationError(
|
|
69
|
+
this.getNode(),
|
|
70
|
+
`API request failed: ${error.message}`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|