n8n-nodes-oops 0.1.0 → 0.2.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/dist/nodes/OOps/OOps.node.js +8 -1
- package/dist/nodes/OOps/OOps.node.js.map +1 -1
- package/dist/nodes/OOps/resources/approval.d.ts +1 -1
- package/dist/nodes/OOps/resources/approval.js +85 -6
- package/dist/nodes/OOps/resources/approval.js.map +1 -1
- package/dist/nodes/OOps/resources/serviceRequest.d.ts +1 -1
- package/dist/nodes/OOps/resources/serviceRequest.js +237 -7
- package/dist/nodes/OOps/resources/serviceRequest.js.map +1 -1
- package/dist/nodes/OOps/resources/task.d.ts +1 -1
- package/dist/nodes/OOps/resources/task.js +157 -8
- package/dist/nodes/OOps/resources/task.js.map +1 -1
- package/dist/nodes/OOps/shared/read.d.ts +7 -0
- package/dist/nodes/OOps/shared/read.js +128 -0
- package/dist/nodes/OOps/shared/read.js.map +1 -0
- package/dist/package.json +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -3,13 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.taskDescription = void 0;
|
|
4
4
|
exports.executeTask = executeTask;
|
|
5
5
|
const transport_1 = require("../shared/transport");
|
|
6
|
+
const read_1 = require("../shared/read");
|
|
7
|
+
const MODEL = 'itsm.request.task';
|
|
8
|
+
const RESOURCE = 'task';
|
|
6
9
|
exports.taskDescription = [
|
|
7
10
|
{
|
|
8
11
|
displayName: 'Operation',
|
|
9
12
|
name: 'operation',
|
|
10
13
|
type: 'options',
|
|
11
14
|
noDataExpression: true,
|
|
12
|
-
displayOptions: { show: { resource: [
|
|
15
|
+
displayOptions: { show: { resource: [RESOURCE] } },
|
|
13
16
|
options: [
|
|
14
17
|
{
|
|
15
18
|
name: 'Create',
|
|
@@ -17,6 +20,36 @@ exports.taskDescription = [
|
|
|
17
20
|
action: 'Create a task',
|
|
18
21
|
description: 'Add a task on an existing Service Request',
|
|
19
22
|
},
|
|
23
|
+
{
|
|
24
|
+
name: 'Get',
|
|
25
|
+
value: 'get',
|
|
26
|
+
action: 'Get a task',
|
|
27
|
+
description: 'Read fields from a single task by ID',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'Get Many',
|
|
31
|
+
value: 'getMany',
|
|
32
|
+
action: 'Get many tasks',
|
|
33
|
+
description: 'Search and read several tasks',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'Mark as Done',
|
|
37
|
+
value: 'markDone',
|
|
38
|
+
action: 'Mark a task as done',
|
|
39
|
+
description: 'Move a task to the done state',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'Start',
|
|
43
|
+
value: 'start',
|
|
44
|
+
action: 'Start a task',
|
|
45
|
+
description: 'Move a task from to do to in progress',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'Update',
|
|
49
|
+
value: 'update',
|
|
50
|
+
action: 'Update a task',
|
|
51
|
+
description: 'Update editable fields on an existing task',
|
|
52
|
+
},
|
|
20
53
|
],
|
|
21
54
|
default: 'create',
|
|
22
55
|
},
|
|
@@ -27,7 +60,7 @@ exports.taskDescription = [
|
|
|
27
60
|
required: true,
|
|
28
61
|
default: 0,
|
|
29
62
|
displayOptions: {
|
|
30
|
-
show: { resource: [
|
|
63
|
+
show: { resource: [RESOURCE], operation: ['create'] },
|
|
31
64
|
},
|
|
32
65
|
description: 'ID of the itsm.request the task belongs to',
|
|
33
66
|
},
|
|
@@ -38,7 +71,7 @@ exports.taskDescription = [
|
|
|
38
71
|
required: true,
|
|
39
72
|
default: '',
|
|
40
73
|
displayOptions: {
|
|
41
|
-
show: { resource: [
|
|
74
|
+
show: { resource: [RESOURCE], operation: ['create'] },
|
|
42
75
|
},
|
|
43
76
|
description: 'Task title (visible to the assignee)',
|
|
44
77
|
},
|
|
@@ -48,7 +81,7 @@ exports.taskDescription = [
|
|
|
48
81
|
type: 'number',
|
|
49
82
|
default: 10,
|
|
50
83
|
displayOptions: {
|
|
51
|
-
show: { resource: [
|
|
84
|
+
show: { resource: [RESOURCE], operation: ['create'] },
|
|
52
85
|
},
|
|
53
86
|
description: 'Order in which the task runs. Same sequence as another task = parallel. Different sequence = cascade.',
|
|
54
87
|
},
|
|
@@ -58,7 +91,7 @@ exports.taskDescription = [
|
|
|
58
91
|
type: 'number',
|
|
59
92
|
default: 0,
|
|
60
93
|
displayOptions: {
|
|
61
|
-
show: { resource: [
|
|
94
|
+
show: { resource: [RESOURCE], operation: ['create'] },
|
|
62
95
|
},
|
|
63
96
|
description: 'User (res.users) ID of the assignee. Leave 0 for none.',
|
|
64
97
|
},
|
|
@@ -69,9 +102,78 @@ exports.taskDescription = [
|
|
|
69
102
|
typeOptions: { rows: 4 },
|
|
70
103
|
default: '',
|
|
71
104
|
displayOptions: {
|
|
72
|
-
show: { resource: [
|
|
105
|
+
show: { resource: [RESOURCE], operation: ['create'] },
|
|
106
|
+
},
|
|
107
|
+
description: 'Long-form description shown to the assignee',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
displayName: 'Record ID',
|
|
111
|
+
name: 'recordId',
|
|
112
|
+
type: 'number',
|
|
113
|
+
required: true,
|
|
114
|
+
default: 0,
|
|
115
|
+
displayOptions: {
|
|
116
|
+
show: {
|
|
117
|
+
resource: [RESOURCE],
|
|
118
|
+
operation: ['update', 'start', 'markDone'],
|
|
119
|
+
},
|
|
73
120
|
},
|
|
121
|
+
description: 'ID of the task to act on',
|
|
74
122
|
},
|
|
123
|
+
{
|
|
124
|
+
displayName: 'Name',
|
|
125
|
+
name: 'name',
|
|
126
|
+
type: 'string',
|
|
127
|
+
default: '',
|
|
128
|
+
displayOptions: {
|
|
129
|
+
show: { resource: [RESOURCE], operation: ['update'] },
|
|
130
|
+
},
|
|
131
|
+
description: 'Leave empty to keep the current value',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
displayName: 'Sequence',
|
|
135
|
+
name: 'sequence',
|
|
136
|
+
type: 'number',
|
|
137
|
+
default: 0,
|
|
138
|
+
displayOptions: {
|
|
139
|
+
show: { resource: [RESOURCE], operation: ['update'] },
|
|
140
|
+
},
|
|
141
|
+
description: 'Leave 0 to keep the current value',
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
displayName: 'Assignee User ID',
|
|
145
|
+
name: 'assigneeId',
|
|
146
|
+
type: 'number',
|
|
147
|
+
default: 0,
|
|
148
|
+
displayOptions: {
|
|
149
|
+
show: { resource: [RESOURCE], operation: ['update'] },
|
|
150
|
+
},
|
|
151
|
+
description: 'Leave 0 to keep the current value',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
displayName: 'Description',
|
|
155
|
+
name: 'description',
|
|
156
|
+
type: 'string',
|
|
157
|
+
typeOptions: { rows: 4 },
|
|
158
|
+
default: '',
|
|
159
|
+
displayOptions: {
|
|
160
|
+
show: { resource: [RESOURCE], operation: ['update'] },
|
|
161
|
+
},
|
|
162
|
+
description: 'Leave empty to keep the current value',
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
displayName: 'Notes',
|
|
166
|
+
name: 'notes',
|
|
167
|
+
type: 'string',
|
|
168
|
+
typeOptions: { rows: 4 },
|
|
169
|
+
default: '',
|
|
170
|
+
displayOptions: {
|
|
171
|
+
show: { resource: [RESOURCE], operation: ['update'] },
|
|
172
|
+
},
|
|
173
|
+
description: 'Free-form notes from the assignee. Leave empty to keep the current value.',
|
|
174
|
+
},
|
|
175
|
+
...(0, read_1.getFields)(RESOURCE),
|
|
176
|
+
...(0, read_1.getManyFields)(RESOURCE),
|
|
75
177
|
];
|
|
76
178
|
async function executeTask(operation, i) {
|
|
77
179
|
if (operation === 'create') {
|
|
@@ -89,8 +191,55 @@ async function executeTask(operation, i) {
|
|
|
89
191
|
vals.assignee_id = assigneeId;
|
|
90
192
|
if (description)
|
|
91
193
|
vals.description = description;
|
|
92
|
-
const id = await (0, transport_1.odooExecuteKw)(this,
|
|
93
|
-
return { id, model:
|
|
194
|
+
const id = await (0, transport_1.odooExecuteKw)(this, MODEL, 'create', [vals]);
|
|
195
|
+
return { id, model: MODEL, request_id: requestId };
|
|
196
|
+
}
|
|
197
|
+
if (operation === 'update') {
|
|
198
|
+
const recordId = this.getNodeParameter('recordId', i);
|
|
199
|
+
const name = this.getNodeParameter('name', i, '');
|
|
200
|
+
const sequence = this.getNodeParameter('sequence', i, 0);
|
|
201
|
+
const assigneeId = this.getNodeParameter('assigneeId', i, 0);
|
|
202
|
+
const description = this.getNodeParameter('description', i, '');
|
|
203
|
+
const notes = this.getNodeParameter('notes', i, '');
|
|
204
|
+
const vals = {};
|
|
205
|
+
if (name)
|
|
206
|
+
vals.name = name;
|
|
207
|
+
if (sequence)
|
|
208
|
+
vals.sequence = sequence;
|
|
209
|
+
if (assigneeId)
|
|
210
|
+
vals.assignee_id = assigneeId;
|
|
211
|
+
if (description)
|
|
212
|
+
vals.description = description;
|
|
213
|
+
if (notes)
|
|
214
|
+
vals.notes = notes;
|
|
215
|
+
if (Object.keys(vals).length === 0) {
|
|
216
|
+
return { id: recordId, model: MODEL, updated: false };
|
|
217
|
+
}
|
|
218
|
+
await (0, transport_1.odooExecuteKw)(this, MODEL, 'write', [[recordId], vals]);
|
|
219
|
+
return { id: recordId, model: MODEL, updated: true };
|
|
220
|
+
}
|
|
221
|
+
if (operation === 'get') {
|
|
222
|
+
const recordId = this.getNodeParameter('recordId', i);
|
|
223
|
+
const fields = (0, read_1.parseFields)(this.getNodeParameter('fields', i, ''));
|
|
224
|
+
return (0, read_1.readOne)(this, MODEL, recordId, fields);
|
|
225
|
+
}
|
|
226
|
+
if (operation === 'getMany') {
|
|
227
|
+
const domain = (0, read_1.parseDomain)(this, this.getNodeParameter('domain', i, '[]'), i);
|
|
228
|
+
const fields = (0, read_1.parseFields)(this.getNodeParameter('fields', i, ''));
|
|
229
|
+
const limit = this.getNodeParameter('limit', i, 50);
|
|
230
|
+
const offset = this.getNodeParameter('offset', i, 0);
|
|
231
|
+
const order = this.getNodeParameter('order', i, '');
|
|
232
|
+
return (0, read_1.searchRead)(this, MODEL, domain, fields, limit, offset, order);
|
|
233
|
+
}
|
|
234
|
+
if (operation === 'start') {
|
|
235
|
+
const recordId = this.getNodeParameter('recordId', i);
|
|
236
|
+
await (0, transport_1.odooExecuteKw)(this, MODEL, 'action_start', [[recordId]]);
|
|
237
|
+
return { id: recordId, model: MODEL, operation: 'start' };
|
|
238
|
+
}
|
|
239
|
+
if (operation === 'markDone') {
|
|
240
|
+
const recordId = this.getNodeParameter('recordId', i);
|
|
241
|
+
await (0, transport_1.odooExecuteKw)(this, MODEL, 'action_done', [[recordId]]);
|
|
242
|
+
return { id: recordId, model: MODEL, operation: 'markDone' };
|
|
94
243
|
}
|
|
95
244
|
throw new Error(`Unknown operation for Task: ${operation}`);
|
|
96
245
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task.js","sourceRoot":"","sources":["../../../../nodes/OOps/resources/task.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"task.js","sourceRoot":"","sources":["../../../../nodes/OOps/resources/task.ts"],"names":[],"mappings":";;;AAmMA,kCA+EC;AA7QD,mDAAoD;AACpD,yCAOwB;AAExB,MAAM,KAAK,GAAG,mBAAmB,CAAC;AAClC,MAAM,QAAQ,GAAG,MAAM,CAAC;AAEX,QAAA,eAAe,GAAsB;IACjD;QACC,WAAW,EAAE,WAAW;QACxB,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,SAAS;QACf,gBAAgB,EAAE,IAAI;QACtB,cAAc,EAAE,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE;QAClD,OAAO,EAAE;YACR;gBACC,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,QAAQ;gBACf,MAAM,EAAE,eAAe;gBACvB,WAAW,EAAE,2CAA2C;aACxD;YACD;gBACC,IAAI,EAAE,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AAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;IAC3D,CAAC;IAED,IAAI,SAAS,KAAK,UAAU,EAAE,CAAC;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,CAAC,CAAW,CAAC;QAChE,MAAM,IAAA,yBAAa,EAAC,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC9D,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;IAC9D,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,+BAA+B,SAAS,EAAE,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IDataObject, IExecuteFunctions, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare function getFields(resource: string): INodeProperties[];
|
|
3
|
+
export declare function getManyFields(resource: string): INodeProperties[];
|
|
4
|
+
export declare function parseFields(raw: string): string[];
|
|
5
|
+
export declare function parseDomain(context: IExecuteFunctions, raw: string, itemIndex: number): unknown[];
|
|
6
|
+
export declare function readOne(context: IExecuteFunctions, model: string, recordId: number, fields: string[]): Promise<IDataObject>;
|
|
7
|
+
export declare function searchRead(context: IExecuteFunctions, model: string, domain: unknown[], fields: string[], limit: number, offset: number, order: string): Promise<IDataObject[]>;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFields = getFields;
|
|
4
|
+
exports.getManyFields = getManyFields;
|
|
5
|
+
exports.parseFields = parseFields;
|
|
6
|
+
exports.parseDomain = parseDomain;
|
|
7
|
+
exports.readOne = readOne;
|
|
8
|
+
exports.searchRead = searchRead;
|
|
9
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
10
|
+
const transport_1 = require("./transport");
|
|
11
|
+
function getFields(resource) {
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
displayName: 'Record ID',
|
|
15
|
+
name: 'recordId',
|
|
16
|
+
type: 'number',
|
|
17
|
+
required: true,
|
|
18
|
+
default: 0,
|
|
19
|
+
displayOptions: { show: { resource: [resource], operation: ['get'] } },
|
|
20
|
+
description: 'ID of the record to read',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
displayName: 'Fields',
|
|
24
|
+
name: 'fields',
|
|
25
|
+
type: 'string',
|
|
26
|
+
default: '',
|
|
27
|
+
displayOptions: { show: { resource: [resource], operation: ['get'] } },
|
|
28
|
+
description: 'Comma-separated list of fields to return. Leave empty for all fields.',
|
|
29
|
+
placeholder: 'name,state,requester_id',
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
function getManyFields(resource) {
|
|
34
|
+
return [
|
|
35
|
+
{
|
|
36
|
+
displayName: 'Domain (JSON)',
|
|
37
|
+
name: 'domain',
|
|
38
|
+
type: 'string',
|
|
39
|
+
default: '[]',
|
|
40
|
+
displayOptions: {
|
|
41
|
+
show: { resource: [resource], operation: ['getMany'] },
|
|
42
|
+
},
|
|
43
|
+
description: 'Odoo search domain as JSON. Example: [["state","=","new"]].',
|
|
44
|
+
placeholder: '[["state","=","new"]]',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
displayName: 'Fields',
|
|
48
|
+
name: 'fields',
|
|
49
|
+
type: 'string',
|
|
50
|
+
default: '',
|
|
51
|
+
displayOptions: {
|
|
52
|
+
show: { resource: [resource], operation: ['getMany'] },
|
|
53
|
+
},
|
|
54
|
+
description: 'Comma-separated list of fields to return. Leave empty for all fields.',
|
|
55
|
+
placeholder: 'name,state',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
displayName: 'Limit',
|
|
59
|
+
name: 'limit',
|
|
60
|
+
type: 'number',
|
|
61
|
+
default: 50,
|
|
62
|
+
typeOptions: { minValue: 1 },
|
|
63
|
+
displayOptions: {
|
|
64
|
+
show: { resource: [resource], operation: ['getMany'] },
|
|
65
|
+
},
|
|
66
|
+
description: 'Max number of results to return',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
displayName: 'Offset',
|
|
70
|
+
name: 'offset',
|
|
71
|
+
type: 'number',
|
|
72
|
+
default: 0,
|
|
73
|
+
displayOptions: {
|
|
74
|
+
show: { resource: [resource], operation: ['getMany'] },
|
|
75
|
+
},
|
|
76
|
+
description: 'Number of records to skip',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
displayName: 'Order',
|
|
80
|
+
name: 'order',
|
|
81
|
+
type: 'string',
|
|
82
|
+
default: '',
|
|
83
|
+
displayOptions: {
|
|
84
|
+
show: { resource: [resource], operation: ['getMany'] },
|
|
85
|
+
},
|
|
86
|
+
description: 'Odoo order clause, e.g. "create_date desc". Leave empty for the model default.',
|
|
87
|
+
placeholder: 'create_date desc',
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
function parseFields(raw) {
|
|
92
|
+
return raw
|
|
93
|
+
.split(',')
|
|
94
|
+
.map((s) => s.trim())
|
|
95
|
+
.filter(Boolean);
|
|
96
|
+
}
|
|
97
|
+
function parseDomain(context, raw, itemIndex) {
|
|
98
|
+
if (!raw || raw.trim() === '')
|
|
99
|
+
return [];
|
|
100
|
+
let parsed;
|
|
101
|
+
try {
|
|
102
|
+
parsed = JSON.parse(raw);
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), `Invalid domain JSON: ${e.message}`, { itemIndex });
|
|
106
|
+
}
|
|
107
|
+
if (!Array.isArray(parsed)) {
|
|
108
|
+
throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Domain must be a JSON array of tuples.', { itemIndex });
|
|
109
|
+
}
|
|
110
|
+
return parsed;
|
|
111
|
+
}
|
|
112
|
+
async function readOne(context, model, recordId, fields) {
|
|
113
|
+
const kwargs = fields.length ? { fields } : {};
|
|
114
|
+
const records = await (0, transport_1.odooExecuteKw)(context, model, 'read', [[recordId]], kwargs);
|
|
115
|
+
if (!records || records.length === 0) {
|
|
116
|
+
throw new Error(`${model} record ${recordId} not found.`);
|
|
117
|
+
}
|
|
118
|
+
return records[0];
|
|
119
|
+
}
|
|
120
|
+
async function searchRead(context, model, domain, fields, limit, offset, order) {
|
|
121
|
+
const kwargs = { limit, offset };
|
|
122
|
+
if (fields.length)
|
|
123
|
+
kwargs.fields = fields;
|
|
124
|
+
if (order)
|
|
125
|
+
kwargs.order = order;
|
|
126
|
+
return (0, transport_1.odooExecuteKw)(context, model, 'search_read', [domain], kwargs);
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.js","sourceRoot":"","sources":["../../../../nodes/OOps/shared/read.ts"],"names":[],"mappings":";;AAQA,8BAsBC;AAED,sCA4DC;AAED,kCAKC;AAED,kCAwBC;AAED,0BAkBC;AAED,gCAmBC;AAtKD,+CAAkD;AAMlD,2CAA4C;AAE5C,SAAgB,SAAS,CAAC,QAAgB;IACzC,OAAO;QACN;YACC,WAAW,EAAE,WAAW;YACxB,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,CAAC;YACV,cAAc,EAAE,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE;YACtE,WAAW,EAAE,0BAA0B;SACvC;QACD;YACC,WAAW,EAAE,QAAQ;YACrB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE;YACX,cAAc,EAAE,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC,KAAK,CAA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b,QAAgB,EAChB,MAAgB;IAEhB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/C,MAAM,OAAO,GAAG,MAAM,IAAA,yBAAa,EAClC,OAAO,EACP,KAAK,EACL,MAAM,EACN,CAAC,CAAC,QAAQ,CAAC,CAAC,EACZ,MAAM,CACN,CAAC;IACF,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,WAAW,QAAQ,aAAa,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC;AAEM,KAAK,UAAU,UAAU,CAC/B,OAA0B,EAC1B,KAAa,EACb,MAAiB,EACjB,MAAgB,EAChB,KAAa,EACb,MAAc,EACd,KAAa;IAEb,MAAM,MAAM,GAA4B,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC1D,IAAI,MAAM,CAAC,MAAM;QAAE,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;IAC1C,IAAI,KAAK;QAAE,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;IAChC,OAAO,IAAA,yBAAa,EACnB,OAAO,EACP,KAAK,EACL,aAAa,EACb,CAAC,MAAM,CAAC,EACR,MAAM,CACN,CAAC;AACH,CAAC"}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n-nodes-oops",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "n8n community node for OOps — the N2 ITSM suite on Odoo. Provides nodes for Service Requests, Tasks and Approvals.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/NickyN2/n8n-nodes-oops",
|