n8n-nodes-hudu 1.3.5 → 1.4.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.
Files changed (96) hide show
  1. package/README.md +9 -7
  2. package/dist/nodes/Hudu/Hudu.node.js +2 -18
  3. package/dist/nodes/Hudu/Hudu.node.js.map +1 -1
  4. package/dist/nodes/Hudu/Hudu.node.ts +2 -30
  5. package/dist/nodes/Hudu/descriptions/asset_layouts.description.js +99 -10
  6. package/dist/nodes/Hudu/descriptions/asset_layouts.description.js.map +1 -1
  7. package/dist/nodes/Hudu/descriptions/asset_layouts.description.ts +99 -10
  8. package/dist/nodes/Hudu/descriptions/assets.description.js +38 -137
  9. package/dist/nodes/Hudu/descriptions/assets.description.js.map +1 -1
  10. package/dist/nodes/Hudu/descriptions/assets.description.ts +511 -609
  11. package/dist/nodes/Hudu/descriptions/index.js +0 -3
  12. package/dist/nodes/Hudu/descriptions/index.js.map +1 -1
  13. package/dist/nodes/Hudu/descriptions/index.ts +0 -3
  14. package/dist/nodes/Hudu/descriptions/resources.js +0 -12
  15. package/dist/nodes/Hudu/descriptions/resources.js.map +1 -1
  16. package/dist/nodes/Hudu/descriptions/resources.ts +0 -12
  17. package/dist/nodes/Hudu/optionLoaders/asset_layouts/getAssetLayoutFields.js +122 -70
  18. package/dist/nodes/Hudu/optionLoaders/asset_layouts/getAssetLayoutFields.js.map +1 -1
  19. package/dist/nodes/Hudu/optionLoaders/asset_layouts/getAssetLayoutFields.ts +143 -107
  20. package/dist/nodes/Hudu/optionLoaders/asset_layouts/index.js +0 -1
  21. package/dist/nodes/Hudu/optionLoaders/asset_layouts/index.js.map +1 -1
  22. package/dist/nodes/Hudu/optionLoaders/asset_layouts/index.ts +0 -1
  23. package/dist/nodes/Hudu/optionLoaders/assets/index.js +1 -2
  24. package/dist/nodes/Hudu/optionLoaders/assets/index.js.map +1 -1
  25. package/dist/nodes/Hudu/optionLoaders/assets/index.ts +1 -2
  26. package/dist/nodes/Hudu/resources/asset_layouts/asset_layouts.handler.js +11 -9
  27. package/dist/nodes/Hudu/resources/asset_layouts/asset_layouts.handler.js.map +1 -1
  28. package/dist/nodes/Hudu/resources/asset_layouts/asset_layouts.handler.ts +13 -10
  29. package/dist/nodes/Hudu/resources/assets/assets.handler.js +116 -50
  30. package/dist/nodes/Hudu/resources/assets/assets.handler.js.map +1 -1
  31. package/dist/nodes/Hudu/resources/assets/assets.handler.ts +172 -51
  32. package/dist/nodes/Hudu/resources/assets/assets.types.ts +43 -43
  33. package/dist/nodes/Hudu/resources/index.js +0 -6
  34. package/dist/nodes/Hudu/resources/index.js.map +1 -1
  35. package/dist/nodes/Hudu/resources/index.ts +0 -12
  36. package/dist/nodes/Hudu/utils/assetFieldUtils.js +273 -0
  37. package/dist/nodes/Hudu/utils/assetFieldUtils.js.map +1 -0
  38. package/dist/nodes/Hudu/utils/assetFieldUtils.ts +437 -0
  39. package/dist/nodes/Hudu/utils/constants.js +1 -0
  40. package/dist/nodes/Hudu/utils/constants.js.map +1 -1
  41. package/dist/nodes/Hudu/utils/constants.ts +1 -0
  42. package/dist/nodes/Hudu/utils/debugConfig.js +7 -4
  43. package/dist/nodes/Hudu/utils/debugConfig.js.map +1 -1
  44. package/dist/nodes/Hudu/utils/debugConfig.ts +9 -4
  45. package/dist/nodes/Hudu/utils/errorParser.js +57 -0
  46. package/dist/nodes/Hudu/utils/errorParser.js.map +1 -0
  47. package/dist/nodes/Hudu/utils/errorParser.ts +90 -0
  48. package/dist/nodes/Hudu/utils/fieldErrorUtils.js +17 -0
  49. package/dist/nodes/Hudu/utils/fieldErrorUtils.js.map +1 -0
  50. package/dist/nodes/Hudu/utils/fieldErrorUtils.ts +57 -0
  51. package/dist/nodes/Hudu/utils/fieldTypeUtils.js +145 -0
  52. package/dist/nodes/Hudu/utils/fieldTypeUtils.js.map +1 -0
  53. package/dist/nodes/Hudu/utils/fieldTypeUtils.ts +220 -0
  54. package/dist/nodes/Hudu/utils/index.js +3 -0
  55. package/dist/nodes/Hudu/utils/index.js.map +1 -1
  56. package/dist/nodes/Hudu/utils/index.ts +25 -19
  57. package/dist/nodes/Hudu/utils/requestUtils.js +71 -24
  58. package/dist/nodes/Hudu/utils/requestUtils.js.map +1 -1
  59. package/dist/nodes/Hudu/utils/requestUtils.ts +88 -26
  60. package/package.json +1 -1
  61. package/dist/nodes/Hudu/descriptions/HuduAssetCustomFieldDescription.js +0 -75
  62. package/dist/nodes/Hudu/descriptions/HuduAssetCustomFieldDescription.js.map +0 -1
  63. package/dist/nodes/Hudu/descriptions/HuduAssetCustomFieldDescription.ts +0 -73
  64. package/dist/nodes/Hudu/descriptions/HuduAssetLinkFieldDescription.js +0 -77
  65. package/dist/nodes/Hudu/descriptions/HuduAssetLinkFieldDescription.js.map +0 -1
  66. package/dist/nodes/Hudu/descriptions/HuduAssetLinkFieldDescription.ts +0 -75
  67. package/dist/nodes/Hudu/descriptions/HuduAssetStandardFieldDescription.js +0 -74
  68. package/dist/nodes/Hudu/descriptions/HuduAssetStandardFieldDescription.js.map +0 -1
  69. package/dist/nodes/Hudu/descriptions/HuduAssetStandardFieldDescription.ts +0 -72
  70. package/dist/nodes/Hudu/optionLoaders/asset_layouts/getAssetLinkFields.js +0 -51
  71. package/dist/nodes/Hudu/optionLoaders/asset_layouts/getAssetLinkFields.js.map +0 -1
  72. package/dist/nodes/Hudu/optionLoaders/asset_layouts/getAssetLinkFields.ts +0 -70
  73. package/dist/nodes/Hudu/optionLoaders/assets/getAssetCustomFields.js +0 -71
  74. package/dist/nodes/Hudu/optionLoaders/assets/getAssetCustomFields.js.map +0 -1
  75. package/dist/nodes/Hudu/optionLoaders/assets/getAssetCustomFields.ts +0 -80
  76. package/dist/nodes/Hudu/optionLoaders/assets/getLinkableAssets.js +0 -117
  77. package/dist/nodes/Hudu/optionLoaders/assets/getLinkableAssets.js.map +0 -1
  78. package/dist/nodes/Hudu/optionLoaders/assets/getLinkableAssets.ts +0 -147
  79. package/dist/nodes/Hudu/resources/assetCustomField/assetCustomField.handler.js +0 -222
  80. package/dist/nodes/Hudu/resources/assetCustomField/assetCustomField.handler.js.map +0 -1
  81. package/dist/nodes/Hudu/resources/assetCustomField/assetCustomField.handler.ts +0 -293
  82. package/dist/nodes/Hudu/resources/assetCustomField/assetCustomField.types.js +0 -3
  83. package/dist/nodes/Hudu/resources/assetCustomField/assetCustomField.types.js.map +0 -1
  84. package/dist/nodes/Hudu/resources/assetCustomField/assetCustomField.types.ts +0 -1
  85. package/dist/nodes/Hudu/resources/assetLinkField/assetLinkField.handler.js +0 -262
  86. package/dist/nodes/Hudu/resources/assetLinkField/assetLinkField.handler.js.map +0 -1
  87. package/dist/nodes/Hudu/resources/assetLinkField/assetLinkField.handler.ts +0 -363
  88. package/dist/nodes/Hudu/resources/assetLinkField/assetLinkField.types.js +0 -3
  89. package/dist/nodes/Hudu/resources/assetLinkField/assetLinkField.types.js.map +0 -1
  90. package/dist/nodes/Hudu/resources/assetLinkField/assetLinkField.types.ts +0 -1
  91. package/dist/nodes/Hudu/resources/assetStandardField/assetStandardField.handler.js +0 -93
  92. package/dist/nodes/Hudu/resources/assetStandardField/assetStandardField.handler.js.map +0 -1
  93. package/dist/nodes/Hudu/resources/assetStandardField/assetStandardField.handler.ts +0 -141
  94. package/dist/nodes/Hudu/resources/assetStandardField/assetStandardField.types.js +0 -3
  95. package/dist/nodes/Hudu/resources/assetStandardField/assetStandardField.types.js.map +0 -1
  96. package/dist/nodes/Hudu/resources/assetStandardField/assetStandardField.types.ts +0 -1
@@ -0,0 +1,437 @@
1
+ import { DateTime } from 'luxon';
2
+ import type { IExecuteFunctions, IDataObject } from 'n8n-workflow';
3
+ import type { IAssetLayoutFieldEntity } from '../resources/asset_layout_fields/asset_layout_fields.types';
4
+ import { getCompanyIdForAsset } from './operations/getCompanyIdForAsset';
5
+ import { NodeOperationError } from 'n8n-workflow';
6
+ import { debugLog } from './debugConfig';
7
+ import { huduApiRequest } from './requestUtils';
8
+ import {
9
+ normaliseFieldType,
10
+ getExpectedJavaScriptType,
11
+ isFieldTypeUpdatable,
12
+ detectFieldType
13
+ } from './fieldTypeUtils';
14
+ import { ASSET_LAYOUT_FIELD_TYPES } from './constants';
15
+
16
+ /**
17
+ * Interface for asset metadata with fields and layout info
18
+ */
19
+ export interface AssetWithMetadata {
20
+ assetId: number;
21
+ companyId: number;
22
+ assetLayoutId: number;
23
+ name: string;
24
+ fields: IDataObject[];
25
+ assetObject: IDataObject;
26
+ }
27
+
28
+ /**
29
+ * Interface for field definition used in validation
30
+ */
31
+ export interface FieldDefinition {
32
+ id: string;
33
+ label: string;
34
+ fieldType: string;
35
+ required: boolean;
36
+ linkableId?: number;
37
+ }
38
+
39
+ /**
40
+ * Retrieves asset metadata including company, layout, and fields.
41
+ * Extends getCompanyIdForAsset to provide a richer metadata object.
42
+ *
43
+ * @param context n8n execution context (this)
44
+ * @param assetId The asset ID to look up
45
+ * @param itemIndex Optional item index for error context
46
+ * @returns AssetWithMetadata
47
+ */
48
+ export async function getAssetWithMetadata(
49
+ context: IExecuteFunctions,
50
+ assetId: number,
51
+ itemIndex: number
52
+ ): Promise<AssetWithMetadata> {
53
+ debugLog('[RESOURCE_PROCESSING] Fetching asset metadata', { assetId });
54
+ const { companyId, assetObject } = await getCompanyIdForAsset(context, assetId, itemIndex);
55
+
56
+ if (!assetObject) {
57
+ debugLog('[RESOURCE_PROCESSING] Asset object not found', { assetId });
58
+ throw new NodeOperationError(context.getNode(), `Asset with ID '${assetId}' not found.`, { itemIndex });
59
+ }
60
+
61
+ const assetLayoutIdRaw = assetObject.asset_layout_id;
62
+ let assetLayoutId: number;
63
+ if (typeof assetLayoutIdRaw === 'number') {
64
+ assetLayoutId = assetLayoutIdRaw;
65
+ } else if (typeof assetLayoutIdRaw === 'string' && !isNaN(Number(assetLayoutIdRaw))) {
66
+ assetLayoutId = Number(assetLayoutIdRaw);
67
+ } else {
68
+ debugLog('[RESOURCE_PROCESSING] Invalid asset layout ID type', { assetId, assetLayoutIdRaw });
69
+ throw new NodeOperationError(context.getNode(), `Asset with ID '${assetId}' has an invalid asset_layout_id.`, { itemIndex });
70
+ }
71
+
72
+ const name = assetObject.name;
73
+ const fields = Array.isArray(assetObject.fields) ? assetObject.fields : [];
74
+
75
+ if (!assetLayoutId) {
76
+ debugLog('[RESOURCE_PROCESSING] Asset layout ID not found', { assetId });
77
+ throw new NodeOperationError(context.getNode(), `Asset with ID '${assetId}' does not have an asset_layout_id.`, { itemIndex });
78
+ }
79
+
80
+ debugLog('[RESOURCE_PROCESSING] Asset metadata retrieved', { assetId, companyId, assetLayoutId, name, fieldsCount: fields.length });
81
+
82
+ return {
83
+ assetId: Number(assetId),
84
+ companyId: typeof companyId === 'string' ? Number(companyId) : companyId,
85
+ assetLayoutId,
86
+ name: name as string,
87
+ fields,
88
+ assetObject,
89
+ };
90
+ }
91
+
92
+ /**
93
+ * Validates a field for mapping by checking existence, type, and required status.
94
+ * Enhanced version that accepts layout fields as parameter for better efficiency.
95
+ *
96
+ * @param context n8n execution context (this)
97
+ * @param layoutFields Array of asset layout fields (pre-fetched)
98
+ * @param fieldIdentifier The field label or ID
99
+ * @param expectedJsType The expected JavaScript type for validation
100
+ * @param itemIndex Optional item index for error context
101
+ * @returns FieldDefinition
102
+ */
103
+ export function validateFieldForMapping(
104
+ context: IExecuteFunctions,
105
+ layoutFields: IAssetLayoutFieldEntity[],
106
+ fieldIdentifier: string,
107
+ expectedJsType: string,
108
+ itemIndex: number
109
+ ): FieldDefinition {
110
+ debugLog('[RESOURCE_VALIDATION] Validating field for mapping', { fieldIdentifier, expectedJsType, fieldsCount: layoutFields.length });
111
+
112
+ if (!Array.isArray(layoutFields) || layoutFields.length === 0) {
113
+ debugLog('[RESOURCE_VALIDATION] No layout fields provided', { fieldIdentifier });
114
+ throw new NodeOperationError(context.getNode(), `No layout fields available for validation of field '${fieldIdentifier}'.`, { itemIndex });
115
+ }
116
+
117
+ // Find the field by label or ID
118
+ const field = layoutFields.find((f: IAssetLayoutFieldEntity) =>
119
+ f.label === fieldIdentifier || String(f.id) === String(fieldIdentifier)
120
+ ) as IAssetLayoutFieldEntity | undefined;
121
+
122
+ if (!field) {
123
+ debugLog('[RESOURCE_VALIDATION] Field not found in layout', { fieldIdentifier, availableFields: layoutFields.map(f => f.label) });
124
+ throw new NodeOperationError(context.getNode(), `Field '${fieldIdentifier}' not found in asset layout. Available fields: ${layoutFields.map(f => f.label).join(', ')}.`, { itemIndex });
125
+ }
126
+
127
+ // Normalise the field type for consistent comparison
128
+ const normalisedFieldType = normaliseFieldType(field.field_type);
129
+ const expectedFieldJsType = getExpectedJavaScriptType(normalisedFieldType);
130
+
131
+ // Validate field type compatibility
132
+ if (normalisedFieldType === ASSET_LAYOUT_FIELD_TYPES.ASSET_TAG || normalisedFieldType === ASSET_LAYOUT_FIELD_TYPES.RELATION) {
133
+ if (expectedJsType !== 'string' && expectedJsType !== 'number') {
134
+ throw new NodeOperationError(
135
+ context.getNode(),
136
+ `Field '${fieldIdentifier}' of type ${normalisedFieldType} expects a string or a number, but got ${expectedJsType}.`,
137
+ { itemIndex },
138
+ );
139
+ }
140
+ } else if (expectedFieldJsType !== expectedJsType) {
141
+ debugLog('[RESOURCE_VALIDATION] Field type mismatch', {
142
+ fieldIdentifier,
143
+ expected: expectedJsType,
144
+ actual: expectedFieldJsType,
145
+ huduFieldType: normalisedFieldType
146
+ });
147
+ throw new NodeOperationError(
148
+ context.getNode(),
149
+ `Field '${fieldIdentifier}' type mismatch: expected JavaScript type '${expectedJsType}', but field type '${normalisedFieldType}' expects '${expectedFieldJsType}'.`,
150
+ { itemIndex }
151
+ );
152
+ }
153
+
154
+ // Check if field type supports updates
155
+ if (!isFieldTypeUpdatable(normalisedFieldType)) {
156
+ debugLog('[RESOURCE_VALIDATION] Field type not updatable', { fieldIdentifier, fieldType: normalisedFieldType });
157
+ throw new NodeOperationError(
158
+ context.getNode(),
159
+ `Field '${fieldIdentifier}' of type '${normalisedFieldType}' cannot be updated via the API. Please use a different field type or update manually in Hudu.`,
160
+ { itemIndex }
161
+ );
162
+ }
163
+
164
+ debugLog('[RESOURCE_VALIDATION] Field validated successfully', {
165
+ fieldIdentifier,
166
+ fieldType: normalisedFieldType,
167
+ detectedType: detectFieldType(field),
168
+ jsType: expectedFieldJsType
169
+ });
170
+
171
+ return {
172
+ id: String(field.id),
173
+ label: field.label,
174
+ fieldType: normalisedFieldType,
175
+ required: !!field.required,
176
+ linkableId: field.linkable_id,
177
+ };
178
+ }
179
+
180
+ /**
181
+ * Legacy version of validateFieldForMapping that fetches layout fields.
182
+ * Maintained for backward compatibility. New code should use the enhanced version.
183
+ *
184
+ * @param context n8n execution context (this)
185
+ * @param assetLayoutId The asset layout ID
186
+ * @param fieldIdentifier The field label or ID
187
+ * @param fieldType The expected field type
188
+ * @param itemIndex Optional item index for error context
189
+ * @returns FieldDefinition
190
+ * @deprecated Use the enhanced validateFieldForMapping with pre-fetched layout fields
191
+ */
192
+ export async function validateFieldForMappingLegacy(
193
+ context: IExecuteFunctions,
194
+ assetLayoutId: number,
195
+ fieldIdentifier: string,
196
+ fieldType: string,
197
+ itemIndex: number
198
+ ): Promise<FieldDefinition> {
199
+ debugLog('[RESOURCE_VALIDATION] Using legacy field validation (consider upgrading)', { assetLayoutId, fieldIdentifier, fieldType });
200
+
201
+ // Fetch asset layout fields
202
+ const layoutResponseRaw = await huduApiRequest.call(context, 'GET', '/asset_layouts', {}, { id: assetLayoutId });
203
+ const layoutResponse = Array.isArray(layoutResponseRaw) ? layoutResponseRaw[0] : layoutResponseRaw;
204
+ const layout = (layoutResponse && typeof layoutResponse === 'object' && 'asset_layout' in layoutResponse)
205
+ ? (layoutResponse as { asset_layout: { fields: IAssetLayoutFieldEntity[] } }).asset_layout
206
+ : undefined;
207
+ if (!layout || !Array.isArray(layout.fields)) {
208
+ debugLog('[RESOURCE_VALIDATION] Asset layout not found or has no fields', { assetLayoutId });
209
+ throw new NodeOperationError(context.getNode(), `Asset layout with ID '${assetLayoutId}' not found or has no fields.`, { itemIndex });
210
+ }
211
+
212
+ // Use the enhanced validation with fetched fields
213
+ const expectedJsType = getExpectedJavaScriptType(normaliseFieldType(fieldType));
214
+ return validateFieldForMapping(context, layout.fields, fieldIdentifier, expectedJsType, itemIndex);
215
+ }
216
+
217
+ /**
218
+ * Transforms a value for update based on Hudu field type.
219
+ * Handles type conversion and formatting for all supported Hudu field types.
220
+ * Enhanced version that uses specific Hudu field type constants.
221
+ *
222
+ * @param value The value to transform
223
+ * @param fieldType The Hudu field type (from ASSET_LAYOUT_FIELD_TYPES)
224
+ * @returns Transformed value ready for Hudu API
225
+ */
226
+ export function transformFieldValueForUpdate(value: any, fieldType: string): any {
227
+ debugLog('[RESOURCE_TRANSFORM] Transforming field value', { value, fieldType, valueType: typeof value });
228
+
229
+ // Normalise the field type to handle variations
230
+ const normalisedFieldType = normaliseFieldType(fieldType);
231
+
232
+ // Handle null/undefined values
233
+ if (value === null || value === undefined) {
234
+ debugLog('[RESOURCE_TRANSFORM] Null/undefined value, returning empty string', { fieldType: normalisedFieldType });
235
+ return '';
236
+ }
237
+
238
+ switch (normalisedFieldType) {
239
+ case ASSET_LAYOUT_FIELD_TYPES.NUMBER:
240
+ if (typeof value === 'number') return value;
241
+ if (typeof value === 'string' && value.trim() !== '' && !isNaN(Number(value))) {
242
+ const numValue = Number(value);
243
+ debugLog('[RESOURCE_TRANSFORM] Converted string to number', { original: value, converted: numValue });
244
+ return numValue;
245
+ }
246
+ throw new Error(`Invalid value for Number field: ${value}. Expected a numeric value.`);
247
+
248
+ case ASSET_LAYOUT_FIELD_TYPES.CHECKBOX:
249
+ if (typeof value === 'boolean') return value;
250
+ if (typeof value === 'string') {
251
+ const lower = value.trim().toLowerCase();
252
+ if (lower === 'true' || lower === 'yes' || lower === '1') {
253
+ debugLog('[RESOURCE_TRANSFORM] Converted string to true', { original: value });
254
+ return true;
255
+ }
256
+ if (lower === 'false' || lower === 'no' || lower === '0' || lower === '') {
257
+ debugLog('[RESOURCE_TRANSFORM] Converted string to false', { original: value });
258
+ return false;
259
+ }
260
+ }
261
+ throw new Error(`Invalid value for CheckBox field: ${value}. Expected true/false, yes/no, or 1/0.`);
262
+
263
+ case ASSET_LAYOUT_FIELD_TYPES.DATE:
264
+ // Hudu expects dates in YYYY-MM-DD format. We use Luxon for robust parsing.
265
+ // This handles ISO strings from n8n's date picker without timezone shifts.
266
+ try {
267
+ const dt = DateTime.fromISO(value);
268
+ if (dt.isValid) {
269
+ const dateString = dt.toFormat('yyyy-MM-dd');
270
+ debugLog('[RESOURCE_TRANSFORM] Converted ISO string to yyyy-MM-dd', { original: value, converted: dateString });
271
+ return dateString;
272
+ }
273
+ } catch (e) {
274
+ // Ignore parsing errors and try other formats
275
+ }
276
+
277
+ // Fallback for other common date formats
278
+ try {
279
+ const dt = DateTime.fromFormat(value, 'yyyy-MM-dd');
280
+ if (dt.isValid) {
281
+ return value; // Already in correct format
282
+ }
283
+ } catch(e) {
284
+ // Fallback for other common date formats
285
+ }
286
+
287
+ // Final attempt with forgiving parsing for other formats like 'DD/MM/YYYY' etc.
288
+ try {
289
+ const dt = DateTime.fromJSDate(new Date(value));
290
+ if (dt.isValid) {
291
+ const dateString = dt.toFormat('yyyy-MM-dd');
292
+ debugLog('[RESOURCE_TRANSFORM] Converted JS Date to yyyy-MM-dd (fallback)', { original: value, converted: dateString });
293
+ return dateString;
294
+ }
295
+ } catch (e) {
296
+ // Let it fall through to the error
297
+ }
298
+
299
+ throw new Error(`Invalid value for Date field: '${value}'. Expected a valid date string (e.g., YYYY-MM-DD or a full ISO timestamp).`);
300
+
301
+ case ASSET_LAYOUT_FIELD_TYPES.LIST_SELECT:
302
+ // List fields may require JSON stringification for complex values
303
+ if (typeof value === 'object' && value !== null) {
304
+ const jsonString = JSON.stringify(value);
305
+ debugLog('[RESOURCE_TRANSFORM] Stringified object for List field', { original: value, converted: jsonString });
306
+ return jsonString;
307
+ }
308
+ if (Array.isArray(value)) {
309
+ const jsonString = JSON.stringify(value);
310
+ debugLog('[RESOURCE_TRANSFORM] Stringified array for List field', { original: value, converted: jsonString });
311
+ return jsonString;
312
+ }
313
+ // For simple values, return as string
314
+ const stringValue = String(value);
315
+ debugLog('[RESOURCE_TRANSFORM] Converted to string for List field', { original: value, converted: stringValue });
316
+ return stringValue;
317
+
318
+ case ASSET_LAYOUT_FIELD_TYPES.RELATION:
319
+ case ASSET_LAYOUT_FIELD_TYPES.ASSET_TAG:
320
+ // Asset link fields expect an array of asset IDs
321
+ if (Array.isArray(value)) {
322
+ debugLog('[RESOURCE_TRANSFORM] Value is already an array for AssetTag/Relation', { value });
323
+ return value.map(Number); // Ensure all elements are numbers
324
+ }
325
+ if (typeof value === 'number') {
326
+ const result = [value];
327
+ debugLog('[RESOURCE_TRANSFORM] Converted single number to array for AssetTag/Relation', { result });
328
+ return result;
329
+ }
330
+ if (typeof value === 'string' && value.trim() !== '') {
331
+ const ids = value.split(',').map(id => {
332
+ const num = Number(id.trim());
333
+ if (isNaN(num)) {
334
+ throw new Error(`Invalid non-numeric ID '${id.trim()}' found in list for AssetTag/Relation field.`);
335
+ }
336
+ return num;
337
+ });
338
+ debugLog('[RESOURCE_TRANSFORM] Parsed comma-separated string to ID array for AssetTag/Relation', { original: value, converted: ids });
339
+ return ids;
340
+ }
341
+ // Return empty array if value is empty string, null, or undefined
342
+ return [];
343
+
344
+ case ASSET_LAYOUT_FIELD_TYPES.ADDRESS_DATA:
345
+ // Address fields expect objects
346
+ if (typeof value === 'object' && value !== null) {
347
+ debugLog('[RESOURCE_TRANSFORM] Using object for Address field', { value });
348
+ return value;
349
+ }
350
+ if (typeof value === 'string') {
351
+ try {
352
+ const parsed = JSON.parse(value);
353
+ if (typeof parsed === 'object' && parsed !== null) {
354
+ debugLog('[RESOURCE_TRANSFORM] Parsed JSON string for Address field', { original: value, parsed });
355
+ return parsed;
356
+ }
357
+ } catch (error) {
358
+ throw new Error(`Invalid JSON for Address field: ${value}. Please provide a valid JSON object string. Error: ${(error as Error).message}`);
359
+ }
360
+ }
361
+ throw new Error(`Invalid value for Address field: ${value}. Expected an address object or JSON string.`);
362
+
363
+ case ASSET_LAYOUT_FIELD_TYPES.EMAIL:
364
+ case ASSET_LAYOUT_FIELD_TYPES.PHONE:
365
+ case ASSET_LAYOUT_FIELD_TYPES.WEBSITE:
366
+ case ASSET_LAYOUT_FIELD_TYPES.PASSWORD:
367
+ case ASSET_LAYOUT_FIELD_TYPES.TEXT:
368
+ case ASSET_LAYOUT_FIELD_TYPES.RICH_TEXT:
369
+ case ASSET_LAYOUT_FIELD_TYPES.EMBED:
370
+ // These field types expect string values
371
+ const stringResult = String(value);
372
+ debugLog('[RESOURCE_TRANSFORM] Converted to string for text-based field', {
373
+ fieldType: normalisedFieldType,
374
+ original: value,
375
+ converted: stringResult
376
+ });
377
+ return stringResult;
378
+
379
+ case ASSET_LAYOUT_FIELD_TYPES.HEADING:
380
+ // Heading fields are display-only and shouldn't be updated
381
+ throw new Error(`Heading fields cannot be updated. Field type '${normalisedFieldType}' is for display purposes only.`);
382
+
383
+ case ASSET_LAYOUT_FIELD_TYPES.DROPDOWN:
384
+ // Legacy dropdown fields are not supported for updates
385
+ throw new Error(`Dropdown fields cannot be updated via the API. Please convert the field to a List type in Hudu to enable API updates.`);
386
+
387
+ default:
388
+ // For unknown field types, default to string conversion with a warning
389
+ debugLog('[RESOURCE_TRANSFORM] Unknown field type, defaulting to string conversion', {
390
+ fieldType: normalisedFieldType,
391
+ originalFieldType: fieldType,
392
+ value
393
+ });
394
+ return String(value);
395
+ }
396
+ }
397
+
398
+ /**
399
+ * Updates an asset with mapped fields using the correct API endpoint and payload structure.
400
+ *
401
+ * @param context n8n execution context (this)
402
+ * @param assetId The asset ID
403
+ * @param companyId The company ID
404
+ * @param mappedFields Object of field/value pairs to update
405
+ * @param itemIndex Optional item index for error context
406
+ * @returns API response
407
+ */
408
+ export async function updateAssetWithMappedFields(
409
+ context: IExecuteFunctions,
410
+ assetId: number,
411
+ companyId: number,
412
+ mappedFields: IDataObject,
413
+ itemIndex: number
414
+ ): Promise<IDataObject> {
415
+ debugLog('[RESOURCE_PROCESSING] Preparing to update asset with mapped fields', { assetId, companyId, mappedFields });
416
+
417
+ // Construct the update payload
418
+ const payload: IDataObject = {};
419
+ for (const [key, value] of Object.entries(mappedFields)) {
420
+ payload[key] = value;
421
+ }
422
+
423
+ debugLog('[RESOURCE_PROCESSING] Final update payload', payload);
424
+
425
+ // Construct the endpoint
426
+ const endpoint = `/companies/${companyId}/assets/${assetId}`;
427
+
428
+ try {
429
+ debugLog('[API_REQUEST] Sending asset update request', { endpoint, payload });
430
+ const response = await huduApiRequest.call(context, 'PUT', endpoint, payload);
431
+ debugLog('[API_RESPONSE] Asset update response received', response);
432
+ return response as IDataObject;
433
+ } catch (error) {
434
+ debugLog('[API_RESPONSE] Asset update failed', { error });
435
+ throw new NodeOperationError(context.getNode(), `Failed to update asset with ID '${assetId}': ${(error as Error).message}`, { itemIndex });
436
+ }
437
+ }
@@ -20,6 +20,7 @@ exports.ASSET_LAYOUT_FIELD_TYPES = {
20
20
  EMAIL: 'Email',
21
21
  PHONE: 'Phone',
22
22
  ASSET_TAG: 'AssetTag',
23
+ RELATION: 'Relation',
23
24
  ADDRESS_DATA: 'AddressData',
24
25
  DROPDOWN: 'Dropdown',
25
26
  };
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/nodes/Hudu/utils/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,kBAAkB,GAAG;IAChC,SAAS,EAAE,EAAE;IACb,YAAY,EAAE,CAAC;IACf,aAAa,EAAE,SAAS;CAChB,CAAC;AAKE,QAAA,wBAAwB,GAAG;IACtC,IAAI,EAAE,MAAM;IACZ,SAAS,EAAE,UAAU;IACrB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ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,GAAG;IACvB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,KAAK;IACV,OAAO,EAAE,QAAQ;IACjB,QAAQ,EAAE,SAAS;IACnB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE;QACN,SAAS,EAAE,SAAS;QACpB,SAAS,EAAE,SAAS;QACpB,MAAM,EAAE,QAAQ;KACjB;CACF,CAAC"}
@@ -21,6 +21,7 @@ export const ASSET_LAYOUT_FIELD_TYPES = {
21
21
  EMAIL: 'Email',
22
22
  PHONE: 'Phone',
23
23
  ASSET_TAG: 'AssetTag',
24
+ RELATION: 'Relation',
24
25
  ADDRESS_DATA: 'AddressData',
25
26
  DROPDOWN: 'Dropdown',
26
27
  } as const;
@@ -2,11 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.debugStringify = exports.redactSensitiveData = exports.debugLog = exports.DEBUG_CONFIG = void 0;
4
4
  exports.DEBUG_CONFIG = {
5
- API_REQUEST: false,
6
- API_RESPONSE: false,
5
+ API_REQUEST: true,
6
+ API_RESPONSE: true,
7
+ API_ERROR: true,
7
8
  OPERATION_CREATE: false,
8
9
  OPERATION_UPDATE: false,
9
- OPERATION_DELETE: false,
10
+ OPERATION_DELETE: true,
10
11
  OPERATION_GET: false,
11
12
  OPERATION_GET_ALL: false,
12
13
  OPERATION_ARCHIVE: false,
@@ -22,6 +23,7 @@ exports.DEBUG_CONFIG = {
22
23
  ASSET_OPTIONS: false,
23
24
  FIELD_TYPE_MAPPING: false,
24
25
  OPTION_LOADING: false,
26
+ DIAGNOSTIC_LOGGING: true,
25
27
  };
26
28
  const DEBUG_CATEGORY_MAP = {
27
29
  'RESOURCE_MAPPING': 'RESOURCE_MAPPING',
@@ -35,6 +37,7 @@ const DEBUG_CATEGORY_MAP = {
35
37
  'FieldTypeMapping': 'FIELD_TYPE_MAPPING',
36
38
  'API_REQUEST': 'API_REQUEST',
37
39
  'API_RESPONSE': 'API_RESPONSE',
40
+ 'API_ERROR': 'API_ERROR',
38
41
  'OPERATION_CREATE': 'OPERATION_CREATE',
39
42
  'OPERATION_UPDATE': 'OPERATION_UPDATE',
40
43
  'OPERATION_DELETE': 'OPERATION_DELETE',
@@ -59,7 +62,7 @@ const DEBUG_CATEGORY_MAP = {
59
62
  const MESSAGE_PREFIX_MAP = {
60
63
  'Hudu API Request': 'API_REQUEST',
61
64
  'Hudu API Response': 'API_RESPONSE',
62
- 'Hudu API Error': 'API_REQUEST',
65
+ 'Hudu API Error': 'API_ERROR',
63
66
  'Rate Limited': 'API_REQUEST',
64
67
  'Update Operation': 'OPERATION_UPDATE',
65
68
  'GetAll Operation': 'OPERATION_GET_ALL',
@@ -1 +1 @@
1
- {"version":3,"file":"debugConfig.js","sourceRoot":"","sources":["../../../../../src/nodes/Hudu/utils/debugConfig.ts"],"names":[],"mappings":";;;AAKa,QAAA,YAAY,GAAG;IAE1B,WAAW,EAAE,KAAK;IAClB,YAAY,EAAE,KAAK;IAGnB,gBAAgB,EAAE,KAAK;IACvB,gBAAgB,EAAE,KAAK;IACvB,gBAAgB,EAAE,KAAK;IACvB,aAAa,EAAE,KAAK;IACpB,iBAAiB,EAAE,KAAK;IACxB,iBAAiB,EAAE,KAAK;IAGxB,mBAAmB,EAAE,KAAK;IAC1B,eAAe,EAAE,KAAK;IACtB,kBAAkB,EAAE,KAAK;IACzB,gBAAgB,EAAE,KAAK;IAGvB,UAAU,EAAE,KAAK;IACjB,WAAW,EAAE,KAAK;IAGlB,oBAAoB,EAAE,KAAK;IAC3B,YAAY,EAAE,KAAK;IACnB,oBAAoB,EAAE,KAAK;IAG3B,aAAa,EAAE,KAAK;IACpB,kBAAkB,EAAE,KAAK;IAGzB,cAAc,EAAE,KAAK;CACb,CAAC;AAGX,MAAM,kBAAkB,GAA8C;IAEpE,kBAAkB,EAAE,kBAAkB;IACtC,iBAAiB,EAAE,kBAA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AI,CAAC;SACb;QACD,IAAI,KAAK,YAAY,KAAK,EAAE;YAC1B,OAAO;gBACL,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,KAAK,EAAE,KAAK,CAAC,KAAK;aACnB,CAAC;SACH;QACD,OAAO,KAAK,CAAC;IACf,CAAC,EAAE,KAAK,CAAC,CAAC;AACZ,CAAC;AAxBD,wCAwBC"}
@@ -5,13 +5,14 @@
5
5
 
6
6
  export const DEBUG_CONFIG = {
7
7
  // API Communication
8
- API_REQUEST: false, // Debug API request details
9
- API_RESPONSE: false, // Debug API response details
8
+ API_REQUEST: true, // Debug API request details
9
+ API_RESPONSE: true, // Debug API response details
10
+ API_ERROR: true, // Debug API error handling and parsing
10
11
 
11
12
  // Core Operations
12
13
  OPERATION_CREATE: false, // Debug create operations
13
14
  OPERATION_UPDATE: false, // Debug update operations
14
- OPERATION_DELETE: false, // Debug delete operations
15
+ OPERATION_DELETE: true, // Debug delete operations
15
16
  OPERATION_GET: false, // Debug get operations
16
17
  OPERATION_GET_ALL: false, // Debug getAll operations
17
18
  OPERATION_ARCHIVE: false, // Debug archive operations
@@ -37,6 +38,9 @@ export const DEBUG_CONFIG = {
37
38
 
38
39
  // Additional options
39
40
  OPTION_LOADING: false, // Debug option loading
41
+
42
+ // Diagnostic flags
43
+ DIAGNOSTIC_LOGGING: true,
40
44
  } as const;
41
45
 
42
46
  // Mapping for various debug message formats to standardized uppercase config keys
@@ -61,6 +65,7 @@ const DEBUG_CATEGORY_MAP: Record<string, keyof typeof DEBUG_CONFIG> = {
61
65
  // Additional mappings for other categories
62
66
  'API_REQUEST': 'API_REQUEST',
63
67
  'API_RESPONSE': 'API_RESPONSE',
68
+ 'API_ERROR': 'API_ERROR',
64
69
  'OPERATION_CREATE': 'OPERATION_CREATE',
65
70
  'OPERATION_UPDATE': 'OPERATION_UPDATE',
66
71
  'OPERATION_DELETE': 'OPERATION_DELETE',
@@ -87,7 +92,7 @@ const DEBUG_CATEGORY_MAP: Record<string, keyof typeof DEBUG_CONFIG> = {
87
92
  const MESSAGE_PREFIX_MAP: Record<string, keyof typeof DEBUG_CONFIG> = {
88
93
  'Hudu API Request': 'API_REQUEST',
89
94
  'Hudu API Response': 'API_RESPONSE',
90
- 'Hudu API Error': 'API_REQUEST',
95
+ 'Hudu API Error': 'API_ERROR',
91
96
  'Rate Limited': 'API_REQUEST',
92
97
  'Update Operation': 'OPERATION_UPDATE',
93
98
  'GetAll Operation': 'OPERATION_GET_ALL',
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseHuduApiErrorWithContext = exports.parseHuduApiError = void 0;
4
+ function parseHuduApiError(error) {
5
+ if (!error) {
6
+ return 'An unknown error occurred';
7
+ }
8
+ const message = error.description || error.message || 'An unknown error occurred';
9
+ const jsonMatch = message.match(/\{.*\}$/);
10
+ if (jsonMatch) {
11
+ try {
12
+ const errorData = JSON.parse(jsonMatch[0]);
13
+ if (errorData.error) {
14
+ let parsedMessage = errorData.error;
15
+ if (errorData.details && Array.isArray(errorData.details)) {
16
+ const detailsString = errorData.details.join(', ');
17
+ parsedMessage += `. Details: ${detailsString}`;
18
+ }
19
+ return parsedMessage;
20
+ }
21
+ }
22
+ catch (parseError) {
23
+ }
24
+ }
25
+ const statusMatch = message.match(/^(\d{3})\s*-\s*/);
26
+ if (statusMatch) {
27
+ const statusCode = statusMatch[1];
28
+ const remainingMessage = message.replace(statusMatch[0], '').trim();
29
+ if (remainingMessage && remainingMessage !== '{}') {
30
+ return `HTTP ${statusCode}: ${remainingMessage}`;
31
+ }
32
+ switch (statusCode) {
33
+ case '422':
34
+ return 'Unprocessable Entity: The request was well-formed but contains semantic errors';
35
+ case '400':
36
+ return 'Bad Request: The request was malformed or contains invalid parameters';
37
+ case '404':
38
+ return 'Not Found: The requested resource does not exist';
39
+ case '401':
40
+ return 'Unauthorized: Invalid or missing API credentials';
41
+ case '403':
42
+ return 'Forbidden: You do not have permission to access this resource';
43
+ default:
44
+ return `HTTP ${statusCode}: ${remainingMessage || 'An error occurred'}`;
45
+ }
46
+ }
47
+ return message;
48
+ }
49
+ exports.parseHuduApiError = parseHuduApiError;
50
+ function parseHuduApiErrorWithContext(error, operation, context) {
51
+ const baseMessage = parseHuduApiError(error);
52
+ const operationText = operation ? ` during ${operation} operation` : '';
53
+ const contextText = context ? ` (${context})` : '';
54
+ return `${baseMessage}${operationText}${contextText}`;
55
+ }
56
+ exports.parseHuduApiErrorWithContext = parseHuduApiErrorWithContext;
57
+ //# sourceMappingURL=errorParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorParser.js","sourceRoot":"","sources":["../../../../../src/nodes/Hudu/utils/errorParser.ts"],"names":[],"mappings":";;;AAOA,SAAgB,iBAAiB,CAAC,KAAmB;IACnD,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,2BAA2B,CAAC;KACpC;IAGD,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,OAAO,IAAI,2BAA2B,CAAC;IAIlF,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAE3C,IAAI,SAAS,EAAE;QACb,IAAI;YACF,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;YAE3C,IAAI,SAAS,CAAC,KAAK,EAAE;gBACnB,IAAI,aAAa,GAAG,SAAS,CAAC,KAAK,CAAC;gBAEpC,IAAI,SAAS,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;oBACzD,MAAM,aAAa,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBACnD,aAAa,IAAI,cAAc,aAAa,EAAE,CAAC;iBAChD;gBAED,OAAO,aAAa,CAAC;aACtB;SACF;QAAC,OAAO,UAAU,EAAE;S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