n8n-nodes-hudu 1.6.5 → 1.6.6

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.
@@ -1,308 +1,308 @@
1
- import type { INodeProperties } from 'n8n-workflow';
2
- import { HUDU_API_CONSTANTS } from '../utils/constants';
3
-
4
- export const magicDashOperations: INodeProperties[] = [
5
- {
6
- displayName: 'Operation',
7
- name: 'operation',
8
- type: 'options',
9
- noDataExpression: true,
10
- displayOptions: {
11
- show: {
12
- resource: ['magic_dash'],
13
- },
14
- },
15
- options: [
16
- {
17
- name: 'Create or Update',
18
- value: 'createOrUpdate',
19
- description: 'Create or update item',
20
- action: 'Create or update item',
21
- },
22
- {
23
- name: 'Delete',
24
- value: 'deleteById',
25
- description: 'Delete item',
26
- action: 'Delete item',
27
- },
28
- {
29
- name: 'Delete by Title',
30
- value: 'deleteByTitle',
31
- description: 'Delete item by title and company name',
32
- action: 'Delete item by title',
33
- },
34
- {
35
- name: 'Get',
36
- value: 'get',
37
- description: 'Get item',
38
- action: 'Get item',
39
- },
40
- {
41
- name: 'Get Many',
42
- value: 'getAll',
43
- description: 'Get many items',
44
- action: 'Get many items',
45
- },
46
- ],
47
- default: 'getAll',
48
- },
49
- ];
50
-
51
- export const magicDashFields: INodeProperties[] = [
52
- // ----------------------------------
53
- // getAll
54
- // ----------------------------------
55
- {
56
- displayName: 'Return All',
57
- name: 'returnAll',
58
- type: 'boolean',
59
- displayOptions: {
60
- show: {
61
- resource: ['magic_dash'],
62
- operation: ['getAll'],
63
- },
64
- },
65
- default: false,
66
- description: 'Whether to return all results or only up to a given limit',
67
- },
68
- {
69
- displayName: 'Limit',
70
- name: 'limit',
71
- type: 'number',
72
- displayOptions: {
73
- show: {
74
- resource: ['magic_dash'],
75
- operation: ['getAll'],
76
- returnAll: [false],
77
- },
78
- },
79
- typeOptions: {
80
- minValue: 1,
81
- },
82
- default: HUDU_API_CONSTANTS.PAGE_SIZE,
83
- description: 'Max number of results to return',
84
- },
85
- {
86
- displayName: 'Filters',
87
- name: 'filters',
88
- type: 'collection',
89
- placeholder: 'Add Filter',
90
- default: {},
91
- displayOptions: {
92
- show: {
93
- resource: ['magic_dash'],
94
- operation: ['getAll'],
95
- },
96
- },
97
- options: [
98
- {
99
- displayName: 'Company Name or ID',
100
- name: 'company_id',
101
- type: 'options',
102
- typeOptions: {
103
- loadOptionsMethod: 'getCompanies',
104
- loadOptionsParameters: {
105
- includeBlank: true,
106
- },
107
- },
108
- default: '',
109
- description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
110
- },
111
- {
112
- displayName: 'Title',
113
- name: 'title',
114
- type: 'string',
115
- default: '',
116
- description: 'Filter by title',
117
- },
118
- ],
119
- },
120
-
121
- // ----------------------------------
122
- // createOrUpdate
123
- // ----------------------------------
124
- {
125
- displayName: 'Message',
126
- name: 'message',
127
- type: 'string',
128
- required: true,
129
- displayOptions: {
130
- show: {
131
- resource: ['magic_dash'],
132
- operation: ['createOrUpdate'],
133
- },
134
- },
135
- default: '',
136
- description: 'The primary content to be displayed on the Magic Dash Item',
137
- },
138
- {
139
- displayName: 'Company Name',
140
- name: 'companyName',
141
- type: 'string',
142
- required: true,
143
- displayOptions: {
144
- show: {
145
- resource: ['magic_dash'],
146
- operation: ['createOrUpdate'],
147
- },
148
- },
149
- default: '',
150
- description: 'The company name attribute used to match an existing company',
151
- },
152
- {
153
- displayName: 'Title',
154
- name: 'title',
155
- type: 'string',
156
- required: true,
157
- displayOptions: {
158
- show: {
159
- resource: ['magic_dash'],
160
- operation: ['createOrUpdate'],
161
- },
162
- },
163
- default: '',
164
- description:
165
- 'The title attribute, used for matching existing Magic Dash Items with the same title and company name',
166
- },
167
- {
168
- displayName: 'Content',
169
- name: 'content',
170
- type: 'string',
171
- typeOptions: {
172
- rows: 4,
173
- },
174
- displayOptions: {
175
- show: {
176
- resource: ['magic_dash'],
177
- operation: ['createOrUpdate'],
178
- },
179
- },
180
- default: '',
181
- description:
182
- 'HTML content (tables, images, videos, etc.) to be displayed in the Magic Dash Item',
183
- },
184
- {
185
- displayName: 'Additional Fields',
186
- name: 'additionalFields',
187
- type: 'collection',
188
- placeholder: 'Add Field',
189
- default: {},
190
- displayOptions: {
191
- show: {
192
- resource: ['magic_dash'],
193
- operation: ['createOrUpdate'],
194
- },
195
- },
196
- options: [
197
- {
198
- displayName: 'Company Name or ID',
199
- name: 'company_id',
200
- type: 'options',
201
- typeOptions: {
202
- loadOptionsMethod: 'getCompanies',
203
- loadOptionsParameters: {
204
- includeBlank: true,
205
- },
206
- },
207
- default: '',
208
- description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
209
- },
210
- {
211
- displayName: 'Content Link',
212
- name: 'content_link',
213
- type: 'string',
214
- default: '',
215
- description: "A link to an external website associated with the Magic Dash Item's content",
216
- },
217
- {
218
- displayName: 'Icon',
219
- name: 'icon',
220
- type: 'string',
221
- default: '',
222
- description: 'Font Awesome icon code (e.g. fa-home). Search for icons at <a href="https://fontawesome.com/search">Font Awesome</a>.',
223
- },
224
- {
225
- displayName: 'Image URL',
226
- name: 'image_url',
227
- type: 'string',
228
- default: '',
229
- description: 'A URL for an image to be used in the header of the Magic Dash Item',
230
- },
231
- {
232
- displayName: 'Shade',
233
- name: 'shade',
234
- type: 'color',
235
- default: '',
236
- //description: 'An optional color for the Magic Dash Item to represent different contextual states (e.g., success, danger)',
237
- },
238
- ],
239
- },
240
-
241
- // ----------------------------------
242
- // deleteById
243
- // ----------------------------------
244
- {
245
- displayName: 'ID',
246
- name: 'id',
247
- type: 'number',
248
- displayOptions: {
249
- show: {
250
- resource: ['magic_dash'],
251
- operation: ['deleteById'],
252
- },
253
- },
254
- default: 0,
255
- required: true,
256
- description: 'The ID of the Magic Dash item to delete',
257
- },
258
-
259
- // ----------------------------------
260
- // deleteByTitle
261
- // ----------------------------------
262
- {
263
- displayName: 'Title',
264
- name: 'title',
265
- type: 'string',
266
- required: true,
267
- displayOptions: {
268
- show: {
269
- resource: ['magic_dash'],
270
- operation: ['deleteByTitle'],
271
- },
272
- },
273
- default: '',
274
- description: 'The title of the Magic Dash item to delete',
275
- },
276
- {
277
- displayName: 'Company Name',
278
- name: 'companyName',
279
- type: 'string',
280
- required: true,
281
- displayOptions: {
282
- show: {
283
- resource: ['magic_dash'],
284
- operation: ['deleteByTitle'],
285
- },
286
- },
287
- default: '',
288
- description: 'The company name for the Magic Dash item to delete',
289
- },
290
-
291
- // ----------------------------------
292
- // get
293
- // ----------------------------------
294
- {
295
- displayName: 'ID',
296
- name: 'id',
297
- type: 'number',
298
- displayOptions: {
299
- show: {
300
- resource: ['magic_dash'],
301
- operation: ['get'],
302
- },
303
- },
304
- default: 0,
305
- required: true,
306
- description: 'The ID of the Magic Dash item to get',
307
- },
308
- ];
1
+ import type { INodeProperties } from 'n8n-workflow';
2
+ import { HUDU_API_CONSTANTS } from '../utils/constants';
3
+
4
+ export const magicDashOperations: INodeProperties[] = [
5
+ {
6
+ displayName: 'Operation',
7
+ name: 'operation',
8
+ type: 'options',
9
+ noDataExpression: true,
10
+ displayOptions: {
11
+ show: {
12
+ resource: ['magic_dash'],
13
+ },
14
+ },
15
+ options: [
16
+ {
17
+ name: 'Create or Update',
18
+ value: 'createOrUpdate',
19
+ description: 'Create or update item',
20
+ action: 'Create or update item',
21
+ },
22
+ {
23
+ name: 'Delete',
24
+ value: 'deleteById',
25
+ description: 'Delete item',
26
+ action: 'Delete item',
27
+ },
28
+ {
29
+ name: 'Delete by Title',
30
+ value: 'deleteByTitle',
31
+ description: 'Delete item by title and company name',
32
+ action: 'Delete item by title',
33
+ },
34
+ {
35
+ name: 'Get',
36
+ value: 'get',
37
+ description: 'Get item',
38
+ action: 'Get item',
39
+ },
40
+ {
41
+ name: 'Get Many',
42
+ value: 'getAll',
43
+ description: 'Get many items',
44
+ action: 'Get many items',
45
+ },
46
+ ],
47
+ default: 'getAll',
48
+ },
49
+ ];
50
+
51
+ export const magicDashFields: INodeProperties[] = [
52
+ // ----------------------------------
53
+ // getAll
54
+ // ----------------------------------
55
+ {
56
+ displayName: 'Return All',
57
+ name: 'returnAll',
58
+ type: 'boolean',
59
+ displayOptions: {
60
+ show: {
61
+ resource: ['magic_dash'],
62
+ operation: ['getAll'],
63
+ },
64
+ },
65
+ default: false,
66
+ description: 'Whether to return all results or only up to a given limit',
67
+ },
68
+ {
69
+ displayName: 'Limit',
70
+ name: 'limit',
71
+ type: 'number',
72
+ displayOptions: {
73
+ show: {
74
+ resource: ['magic_dash'],
75
+ operation: ['getAll'],
76
+ returnAll: [false],
77
+ },
78
+ },
79
+ typeOptions: {
80
+ minValue: 1,
81
+ },
82
+ default: HUDU_API_CONSTANTS.PAGE_SIZE,
83
+ description: 'Max number of results to return',
84
+ },
85
+ {
86
+ displayName: 'Filters',
87
+ name: 'filters',
88
+ type: 'collection',
89
+ placeholder: 'Add Filter',
90
+ default: {},
91
+ displayOptions: {
92
+ show: {
93
+ resource: ['magic_dash'],
94
+ operation: ['getAll'],
95
+ },
96
+ },
97
+ options: [
98
+ {
99
+ displayName: 'Company Name or ID',
100
+ name: 'company_id',
101
+ type: 'options',
102
+ typeOptions: {
103
+ loadOptionsMethod: 'getCompanies',
104
+ loadOptionsParameters: {
105
+ includeBlank: true,
106
+ },
107
+ },
108
+ default: '',
109
+ description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
110
+ },
111
+ {
112
+ displayName: 'Title',
113
+ name: 'title',
114
+ type: 'string',
115
+ default: '',
116
+ description: 'Filter by title',
117
+ },
118
+ ],
119
+ },
120
+
121
+ // ----------------------------------
122
+ // createOrUpdate
123
+ // ----------------------------------
124
+ {
125
+ displayName: 'Message',
126
+ name: 'message',
127
+ type: 'string',
128
+ required: true,
129
+ displayOptions: {
130
+ show: {
131
+ resource: ['magic_dash'],
132
+ operation: ['createOrUpdate'],
133
+ },
134
+ },
135
+ default: '',
136
+ description: 'The primary content to be displayed on the Magic Dash Item',
137
+ },
138
+ {
139
+ displayName: 'Company Name',
140
+ name: 'companyName',
141
+ type: 'string',
142
+ required: true,
143
+ displayOptions: {
144
+ show: {
145
+ resource: ['magic_dash'],
146
+ operation: ['createOrUpdate'],
147
+ },
148
+ },
149
+ default: '',
150
+ description: 'The company name attribute used to match an existing company',
151
+ },
152
+ {
153
+ displayName: 'Title',
154
+ name: 'title',
155
+ type: 'string',
156
+ required: true,
157
+ displayOptions: {
158
+ show: {
159
+ resource: ['magic_dash'],
160
+ operation: ['createOrUpdate'],
161
+ },
162
+ },
163
+ default: '',
164
+ description:
165
+ 'The title attribute, used for matching existing Magic Dash Items with the same title and company name',
166
+ },
167
+ {
168
+ displayName: 'Content',
169
+ name: 'content',
170
+ type: 'string',
171
+ typeOptions: {
172
+ rows: 4,
173
+ },
174
+ displayOptions: {
175
+ show: {
176
+ resource: ['magic_dash'],
177
+ operation: ['createOrUpdate'],
178
+ },
179
+ },
180
+ default: '',
181
+ description:
182
+ 'HTML content (tables, images, videos, etc.) to be displayed in the Magic Dash Item',
183
+ },
184
+ {
185
+ displayName: 'Additional Fields',
186
+ name: 'additionalFields',
187
+ type: 'collection',
188
+ placeholder: 'Add Field',
189
+ default: {},
190
+ displayOptions: {
191
+ show: {
192
+ resource: ['magic_dash'],
193
+ operation: ['createOrUpdate'],
194
+ },
195
+ },
196
+ options: [
197
+ {
198
+ displayName: 'Company Name or ID',
199
+ name: 'company_id',
200
+ type: 'options',
201
+ typeOptions: {
202
+ loadOptionsMethod: 'getCompanies',
203
+ loadOptionsParameters: {
204
+ includeBlank: true,
205
+ },
206
+ },
207
+ default: '',
208
+ description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
209
+ },
210
+ {
211
+ displayName: 'Content Link',
212
+ name: 'content_link',
213
+ type: 'string',
214
+ default: '',
215
+ description: "A link to an external website associated with the Magic Dash Item's content",
216
+ },
217
+ {
218
+ displayName: 'Icon',
219
+ name: 'icon',
220
+ type: 'string',
221
+ default: '',
222
+ description: 'Font Awesome icon code (e.g. fa-home). Search for icons at <a href="https://fontawesome.com/search">Font Awesome</a>.',
223
+ },
224
+ {
225
+ displayName: 'Image URL',
226
+ name: 'image_url',
227
+ type: 'string',
228
+ default: '',
229
+ description: 'A URL for an image to be used in the header of the Magic Dash Item',
230
+ },
231
+ {
232
+ displayName: 'Shade',
233
+ name: 'shade',
234
+ type: 'color',
235
+ default: '',
236
+ //description: 'An optional color for the Magic Dash Item to represent different contextual states (e.g., success, danger)',
237
+ },
238
+ ],
239
+ },
240
+
241
+ // ----------------------------------
242
+ // deleteById
243
+ // ----------------------------------
244
+ {
245
+ displayName: 'ID',
246
+ name: 'id',
247
+ type: 'number',
248
+ displayOptions: {
249
+ show: {
250
+ resource: ['magic_dash'],
251
+ operation: ['deleteById'],
252
+ },
253
+ },
254
+ default: 0,
255
+ required: true,
256
+ description: 'The ID of the Magic Dash item to delete',
257
+ },
258
+
259
+ // ----------------------------------
260
+ // deleteByTitle
261
+ // ----------------------------------
262
+ {
263
+ displayName: 'Title',
264
+ name: 'title',
265
+ type: 'string',
266
+ required: true,
267
+ displayOptions: {
268
+ show: {
269
+ resource: ['magic_dash'],
270
+ operation: ['deleteByTitle'],
271
+ },
272
+ },
273
+ default: '',
274
+ description: 'The title of the Magic Dash item to delete',
275
+ },
276
+ {
277
+ displayName: 'Company Name',
278
+ name: 'companyName',
279
+ type: 'string',
280
+ required: true,
281
+ displayOptions: {
282
+ show: {
283
+ resource: ['magic_dash'],
284
+ operation: ['deleteByTitle'],
285
+ },
286
+ },
287
+ default: '',
288
+ description: 'The company name for the Magic Dash item to delete',
289
+ },
290
+
291
+ // ----------------------------------
292
+ // get
293
+ // ----------------------------------
294
+ {
295
+ displayName: 'ID',
296
+ name: 'id',
297
+ type: 'number',
298
+ displayOptions: {
299
+ show: {
300
+ resource: ['magic_dash'],
301
+ operation: ['get'],
302
+ },
303
+ },
304
+ default: 0,
305
+ required: true,
306
+ description: 'The ID of the Magic Dash item to get',
307
+ },
308
+ ];
@@ -133,29 +133,38 @@ async function handleAssetsOperation(operation, i) {
133
133
  (0, debugConfig_1.debugLog)('[MIGRATION] Migrated top-level company_id to filters', { companyId: topLevelCompanyId });
134
134
  }
135
135
  (0, debugConfig_1.debugLog)('[RESOURCE_PARAMS] Get all assets parameters', { returnAll, filters, limit });
136
- const endpoint = '/assets';
137
136
  const mappedFilters = { ...filters };
138
137
  if (mappedFilters.hasOwnProperty('archived')) {
139
138
  mappedFilters.archived = String(mappedFilters.archived).toLowerCase() === 'true';
140
139
  }
141
- (0, debugConfig_1.debugLog)('[RESOURCE_PROCESSING] Processed filters', mappedFilters);
142
- const qs = {
143
- ...mappedFilters,
144
- };
145
140
  if (filters.updated_at) {
146
141
  const dateFilterValue = (0, utils_1.processDateRange)(filters.updated_at);
147
142
  if (dateFilterValue) {
148
- qs.updated_at = dateFilterValue;
143
+ mappedFilters.updated_at = dateFilterValue;
144
+ }
145
+ else if (typeof filters.updated_at === 'string') {
146
+ mappedFilters.updated_at = filters.updated_at;
149
147
  }
150
148
  else {
151
- if (typeof filters.updated_at === 'string') {
152
- qs.updated_at = filters.updated_at;
153
- }
154
- else {
155
- delete qs.updated_at;
156
- }
149
+ delete mappedFilters.updated_at;
157
150
  }
158
151
  }
152
+ const companyId = mappedFilters.company_id;
153
+ const filtersRequiringAssetsEndpoint = ['id', 'name', 'primary_serial', 'asset_layout_id', 'slug', 'search', 'updated_at'];
154
+ const hasFiltersRequiringAssetsEndpoint = filtersRequiringAssetsEndpoint.some(key => mappedFilters.hasOwnProperty(key) && mappedFilters[key] !== undefined && mappedFilters[key] !== '');
155
+ let endpoint;
156
+ let qs;
157
+ if (companyId && !hasFiltersRequiringAssetsEndpoint) {
158
+ endpoint = `/companies/${companyId}/assets`;
159
+ qs = { ...mappedFilters };
160
+ delete qs.company_id;
161
+ (0, debugConfig_1.debugLog)('[RESOURCE_PROCESSING] Using company-specific endpoint', { endpoint, qs });
162
+ }
163
+ else {
164
+ endpoint = '/assets';
165
+ qs = { ...mappedFilters };
166
+ (0, debugConfig_1.debugLog)('[RESOURCE_PROCESSING] Using generic assets endpoint', { endpoint, qs });
167
+ }
159
168
  responseData = await operations_1.handleGetAllOperation.call(this, endpoint, 'assets', qs, returnAll, limit);
160
169
  (0, debugConfig_1.debugLog)('[API_RESPONSE] Get all assets response');
161
170
  break;