@limetech/n8n-nodes-lime 0.4.0 → 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 +93 -0
- package/README.md +1 -8
- package/credentials/LimeCrmApi.credentials.ts +6 -6
- 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 -67
- package/nodes/lime-crm/LimeCrmTrigger.node.ts +17 -24
- package/nodes/lime-crm/commons/constants.ts +2 -3
- package/nodes/lime-crm/commons/files.ts +162 -0
- package/nodes/lime-crm/commons/index.ts +4 -4
- 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 -7
- package/nodes/lime-crm/transport/limeQuery.ts +2 -4
- 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/limeQuery/index.ts +0 -40
- package/nodes/lime-crm/resources/limeQuery/operations/query.operation.ts +0 -222
- 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,162 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IBinaryData,
|
|
3
|
+
IDataObject,
|
|
4
|
+
IExecuteFunctions,
|
|
5
|
+
LoggerProxy as Logger,
|
|
6
|
+
} from 'n8n-workflow';
|
|
7
|
+
import {
|
|
8
|
+
createFile,
|
|
9
|
+
getFileContent,
|
|
10
|
+
getFileMetadata,
|
|
11
|
+
getProperties,
|
|
12
|
+
} from '../transport';
|
|
13
|
+
import { NodeResponse } from '../../nodeResponse';
|
|
14
|
+
|
|
15
|
+
type FileResponse<T> = {
|
|
16
|
+
json: NodeResponse<T>;
|
|
17
|
+
binary?: Record<string, IBinaryData>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const setFilename = (
|
|
21
|
+
preparedBinaryData: IBinaryData,
|
|
22
|
+
responseFileName: string
|
|
23
|
+
) => {
|
|
24
|
+
if (!preparedBinaryData.fileName && preparedBinaryData.fileExtension) {
|
|
25
|
+
return responseFileName;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return preparedBinaryData.fileName;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export function getFilenameFromHeader(
|
|
32
|
+
headers: Record<string, string | string[] | undefined>
|
|
33
|
+
): string | null {
|
|
34
|
+
let contentDisposition =
|
|
35
|
+
headers['content-disposition'] || headers['Content-Disposition'];
|
|
36
|
+
if (!contentDisposition) return null;
|
|
37
|
+
|
|
38
|
+
if (Array.isArray(contentDisposition)) {
|
|
39
|
+
contentDisposition = contentDisposition[0];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Try RFC 5987 filename* format
|
|
43
|
+
const filenameStarMatch = /filename\*\s*=\s*UTF-8''([^;]+)/i.exec(
|
|
44
|
+
contentDisposition
|
|
45
|
+
);
|
|
46
|
+
if (filenameStarMatch) {
|
|
47
|
+
try {
|
|
48
|
+
return decodeURIComponent(filenameStarMatch[1]);
|
|
49
|
+
} catch {
|
|
50
|
+
return filenameStarMatch[1];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Try regular filename="..." or filename=...
|
|
55
|
+
const filenameMatch =
|
|
56
|
+
/filename\s*=\s*"([^"]+)"|filename\s*=\s*([^;]+)/i.exec(
|
|
57
|
+
contentDisposition
|
|
58
|
+
);
|
|
59
|
+
if (filenameMatch) {
|
|
60
|
+
return filenameMatch[1] || filenameMatch[2];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export async function getFileProperties(
|
|
67
|
+
nodeContext: IExecuteFunctions,
|
|
68
|
+
limetype: string,
|
|
69
|
+
allowedProperties?: Set<string>
|
|
70
|
+
): Promise<Set<string>> {
|
|
71
|
+
const response = await getProperties(nodeContext, limetype);
|
|
72
|
+
|
|
73
|
+
if (!response.success) return new Set();
|
|
74
|
+
return new Set(
|
|
75
|
+
response.data
|
|
76
|
+
.filter(
|
|
77
|
+
(property) =>
|
|
78
|
+
property.type === 'file' &&
|
|
79
|
+
(!allowedProperties || allowedProperties.has(property.name))
|
|
80
|
+
)
|
|
81
|
+
.map((property) => property.name)
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export async function setFileProperties(
|
|
86
|
+
context: IExecuteFunctions,
|
|
87
|
+
i: number,
|
|
88
|
+
fileProperties: Set<string>,
|
|
89
|
+
definedProperties: IDataObject
|
|
90
|
+
): Promise<NodeResponse<IDataObject>> {
|
|
91
|
+
for (const fileProperty of fileProperties) {
|
|
92
|
+
if (!(fileProperty in definedProperties)) continue;
|
|
93
|
+
let binaryData: IBinaryData;
|
|
94
|
+
try {
|
|
95
|
+
Logger.info(
|
|
96
|
+
`Checking whether "${definedProperties[fileProperty]}" is a valid binary object for property "${fileProperty}"...`
|
|
97
|
+
);
|
|
98
|
+
binaryData = context.helpers.assertBinaryData(
|
|
99
|
+
i,
|
|
100
|
+
definedProperties[fileProperty] as string
|
|
101
|
+
);
|
|
102
|
+
} catch {
|
|
103
|
+
Logger.info(
|
|
104
|
+
`Invalid or missing binary data for "${fileProperty}". Using original value instead.`
|
|
105
|
+
);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const response = await createFile(
|
|
109
|
+
context,
|
|
110
|
+
binaryData,
|
|
111
|
+
definedProperties[fileProperty] as string
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
if (response.success) {
|
|
115
|
+
definedProperties[fileProperty] = response.data.id;
|
|
116
|
+
} else return response;
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
success: true,
|
|
120
|
+
data: definedProperties,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export async function processFileResponse<T extends Record<string, unknown>>(
|
|
125
|
+
nodeContext: IExecuteFunctions,
|
|
126
|
+
fileProperties: Set<string>,
|
|
127
|
+
data: T,
|
|
128
|
+
includeFileContent: boolean = false
|
|
129
|
+
): Promise<FileResponse<T>> {
|
|
130
|
+
let updatedData = { ...data };
|
|
131
|
+
const binaryData: Record<string, IBinaryData> = {};
|
|
132
|
+
for (const fileProperty of fileProperties) {
|
|
133
|
+
if (!data[fileProperty]) continue;
|
|
134
|
+
const fileMetadataResponse = await getFileMetadata(
|
|
135
|
+
nodeContext,
|
|
136
|
+
data[fileProperty] as string
|
|
137
|
+
);
|
|
138
|
+
if (!fileMetadataResponse.success)
|
|
139
|
+
return { json: fileMetadataResponse };
|
|
140
|
+
|
|
141
|
+
updatedData = {
|
|
142
|
+
...updatedData,
|
|
143
|
+
[fileProperty]: fileMetadataResponse.data,
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
if (includeFileContent) {
|
|
147
|
+
const fileResponse = await getFileContent(
|
|
148
|
+
nodeContext,
|
|
149
|
+
fileMetadataResponse.data.id
|
|
150
|
+
);
|
|
151
|
+
if (!fileResponse.success) return { json: fileResponse };
|
|
152
|
+
binaryData[fileProperty] = fileResponse.data;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
json: {
|
|
157
|
+
success: true,
|
|
158
|
+
data: updatedData,
|
|
159
|
+
},
|
|
160
|
+
binary: binaryData,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export {
|
|
2
2
|
LIME_CRM_API_CREDENTIAL_KEY,
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
DATA_RESOURCE,
|
|
4
|
+
METADATA_RESOURCE,
|
|
5
5
|
ERP_CONNECTOR_RESOURCE,
|
|
6
|
-
LIME_QUERY_RESOURCE,
|
|
7
6
|
} from './constants';
|
|
8
7
|
export { Webhook, getWebhook } from './webhook';
|
|
9
8
|
|
|
10
|
-
export {
|
|
9
|
+
export { verifyHmac } from './hmac';
|
|
10
|
+
export { setFilename, getFilenameFromHeader } from './files';
|
|
@@ -24,18 +24,30 @@ export interface CreateWebhook extends Webhook {
|
|
|
24
24
|
function _getEvents(hookData: WebhookFunctions): string[] {
|
|
25
25
|
const eventData = hookData.getNodeParameter('events', []) as {
|
|
26
26
|
event: Array<{
|
|
27
|
-
|
|
27
|
+
limetype: string;
|
|
28
28
|
eventType: string;
|
|
29
29
|
}>;
|
|
30
30
|
};
|
|
31
31
|
const eventItems = eventData.event;
|
|
32
32
|
const events: string[] = [];
|
|
33
33
|
for (const eventItem of eventItems) {
|
|
34
|
-
events.push(`${eventItem.
|
|
34
|
+
events.push(`${eventItem.limetype}.${eventItem.eventType}`);
|
|
35
35
|
}
|
|
36
36
|
return events;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
function _createWebhookName(hookData: WebhookFunctions): string {
|
|
40
|
+
interface Events {
|
|
41
|
+
event: Array<{
|
|
42
|
+
limetype: string;
|
|
43
|
+
eventType: string;
|
|
44
|
+
}>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const events = hookData.getNodeParameter('events') as Events;
|
|
48
|
+
return `${events.event[0].limetype}-${events.event[0].eventType}-${Date.now()}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
39
51
|
export function getWebhook(hookData: WebhookFunctions): Webhook {
|
|
40
52
|
const node = hookData.getNode();
|
|
41
53
|
const workflow = hookData.getWorkflow();
|
|
@@ -51,6 +63,6 @@ export function getWebhook(hookData: WebhookFunctions): Webhook {
|
|
|
51
63
|
events: _getEvents(hookData),
|
|
52
64
|
url: hookData.getNodeWebhookUrl('default'),
|
|
53
65
|
context: context,
|
|
54
|
-
name: hookData
|
|
66
|
+
name: _createWebhookName(hookData),
|
|
55
67
|
};
|
|
56
68
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ILoadOptionsFunctions,
|
|
3
|
+
INodePropertyOptions,
|
|
4
|
+
LoggerProxy as Logger,
|
|
5
|
+
} from 'n8n-workflow';
|
|
6
|
+
import { getProperties } from '../transport/';
|
|
7
|
+
|
|
8
|
+
async function _getProperties(nodeContext: ILoadOptionsFunctions) {
|
|
9
|
+
const limetype = nodeContext.getNodeParameter('limetype', '') as string;
|
|
10
|
+
Logger.info(`Fetching file properties for Lime type: ${limetype}`);
|
|
11
|
+
if (!limetype) return [];
|
|
12
|
+
|
|
13
|
+
const response = await getProperties(nodeContext, limetype);
|
|
14
|
+
|
|
15
|
+
return response.success ? response.data : [];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Gets property options from a specific Limetype
|
|
20
|
+
*
|
|
21
|
+
* It's not meant to be used directly in 'loadOptionsMethod'
|
|
22
|
+
*
|
|
23
|
+
* This function fetches properties for the specified Limetype and optionally filters them
|
|
24
|
+
* based on allowed types.
|
|
25
|
+
*
|
|
26
|
+
* @param [loader] - The n8n load options context
|
|
27
|
+
* @param [allowedTypes] - Optional set of property types to filter by
|
|
28
|
+
* @param [forbiddenType] - Optional set of property types to exclude
|
|
29
|
+
* @returns Array of formatted property options
|
|
30
|
+
*/
|
|
31
|
+
export async function getFilteredLimetypeProperties(
|
|
32
|
+
loader: ILoadOptionsFunctions,
|
|
33
|
+
allowedTypes?: Set<string>,
|
|
34
|
+
forbiddenType?: Set<string>
|
|
35
|
+
): Promise<INodePropertyOptions[]> {
|
|
36
|
+
const properties = await _getProperties(loader);
|
|
37
|
+
|
|
38
|
+
return properties
|
|
39
|
+
.filter(
|
|
40
|
+
(property) =>
|
|
41
|
+
(!allowedTypes || allowedTypes.has(property.type)) &&
|
|
42
|
+
(!forbiddenType || !forbiddenType.has(property.type))
|
|
43
|
+
)
|
|
44
|
+
.map((property) => ({
|
|
45
|
+
name: (property.localname as string) || (property.name as string),
|
|
46
|
+
value: property.name as string,
|
|
47
|
+
description: `Type: ${property.type as string}${(property.required as boolean) ? ' (Required)' : ''}`,
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export async function getLimetypeProperties(
|
|
52
|
+
this: ILoadOptionsFunctions
|
|
53
|
+
): Promise<INodePropertyOptions[]> {
|
|
54
|
+
return getFilteredLimetypeProperties(this);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export async function getFileProperties(
|
|
58
|
+
this: ILoadOptionsFunctions
|
|
59
|
+
): Promise<INodePropertyOptions[]> {
|
|
60
|
+
return getFilteredLimetypeProperties(this, new Set(['file']));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export async function getNoHasManyProperties(
|
|
64
|
+
this: ILoadOptionsFunctions
|
|
65
|
+
): Promise<INodePropertyOptions[]> {
|
|
66
|
+
return getFilteredLimetypeProperties(this, undefined, new Set(['hasmany']));
|
|
67
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow';
|
|
2
|
+
import { getLimetypesFromApi } from '../transport';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Load available Lime types from the API
|
|
6
|
+
*/
|
|
7
|
+
export async function getLimetypes(
|
|
8
|
+
this: ILoadOptionsFunctions
|
|
9
|
+
): Promise<INodePropertyOptions[]> {
|
|
10
|
+
const data: INodePropertyOptions[] = [];
|
|
11
|
+
const response = await getLimetypesFromApi(this);
|
|
12
|
+
if (response.success && response.data) {
|
|
13
|
+
for (const limetype of response.data) {
|
|
14
|
+
data.push({
|
|
15
|
+
name: limetype.localname?.singular || limetype.name,
|
|
16
|
+
value: limetype.name,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export { getEntitiesForErpSystem } from './getEntitiesForErpSystem';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
2
|
+
export { getLimetypes } from './getLimetypes';
|
|
3
|
+
export {
|
|
4
|
+
getFileProperties,
|
|
5
|
+
getLimetypeProperties,
|
|
6
|
+
getNoHasManyProperties,
|
|
7
|
+
} from './getLimetypeProperties';
|
|
@@ -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
|
}
|