n8n-nodes-servicem8-jobcreation 1.0.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 (153) hide show
  1. package/README.md +517 -0
  2. package/dist/credentials/ServiceM8Api.credentials.d.ts +9 -0
  3. package/dist/credentials/ServiceM8Api.credentials.js +38 -0
  4. package/dist/credentials/ServiceM8Api.credentials.js.map +1 -0
  5. package/dist/index.d.ts +3 -0
  6. package/dist/index.js +8 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/nodes/ServiceM8JobCreation/ServiceM8JobCreation.node.d.ts +18 -0
  9. package/dist/nodes/ServiceM8JobCreation/ServiceM8JobCreation.node.js +39 -0
  10. package/dist/nodes/ServiceM8JobCreation/ServiceM8JobCreation.node.js.map +1 -0
  11. package/dist/nodes/ServiceM8JobCreation/execute.d.ts +6 -0
  12. package/dist/nodes/ServiceM8JobCreation/execute.js +47 -0
  13. package/dist/nodes/ServiceM8JobCreation/execute.js.map +1 -0
  14. package/dist/nodes/ServiceM8JobCreation/helpers/addressUtils.d.ts +56 -0
  15. package/dist/nodes/ServiceM8JobCreation/helpers/addressUtils.js +124 -0
  16. package/dist/nodes/ServiceM8JobCreation/helpers/addressUtils.js.map +1 -0
  17. package/dist/nodes/ServiceM8JobCreation/helpers/api.d.ts +180 -0
  18. package/dist/nodes/ServiceM8JobCreation/helpers/api.js +418 -0
  19. package/dist/nodes/ServiceM8JobCreation/helpers/api.js.map +1 -0
  20. package/dist/nodes/ServiceM8JobCreation/helpers/clientMatcher.d.ts +67 -0
  21. package/dist/nodes/ServiceM8JobCreation/helpers/clientMatcher.js +216 -0
  22. package/dist/nodes/ServiceM8JobCreation/helpers/clientMatcher.js.map +1 -0
  23. package/dist/nodes/ServiceM8JobCreation/helpers/phoneUtils.d.ts +35 -0
  24. package/dist/nodes/ServiceM8JobCreation/helpers/phoneUtils.js +122 -0
  25. package/dist/nodes/ServiceM8JobCreation/helpers/phoneUtils.js.map +1 -0
  26. package/dist/nodes/ServiceM8JobCreation/methods/index.d.ts +13 -0
  27. package/dist/nodes/ServiceM8JobCreation/methods/index.js +17 -0
  28. package/dist/nodes/ServiceM8JobCreation/methods/index.js.map +1 -0
  29. package/dist/nodes/ServiceM8JobCreation/methods/loadOptions.d.ts +9 -0
  30. package/dist/nodes/ServiceM8JobCreation/methods/loadOptions.js +61 -0
  31. package/dist/nodes/ServiceM8JobCreation/methods/loadOptions.js.map +1 -0
  32. package/dist/nodes/ServiceM8JobCreation/operations/create/categoryAssign.d.ts +22 -0
  33. package/dist/nodes/ServiceM8JobCreation/operations/create/categoryAssign.js +61 -0
  34. package/dist/nodes/ServiceM8JobCreation/operations/create/categoryAssign.js.map +1 -0
  35. package/dist/nodes/ServiceM8JobCreation/operations/create/clientCreate.d.ts +36 -0
  36. package/dist/nodes/ServiceM8JobCreation/operations/create/clientCreate.js +66 -0
  37. package/dist/nodes/ServiceM8JobCreation/operations/create/clientCreate.js.map +1 -0
  38. package/dist/nodes/ServiceM8JobCreation/operations/create/clientLookup.d.ts +28 -0
  39. package/dist/nodes/ServiceM8JobCreation/operations/create/clientLookup.js +46 -0
  40. package/dist/nodes/ServiceM8JobCreation/operations/create/clientLookup.js.map +1 -0
  41. package/dist/nodes/ServiceM8JobCreation/operations/create/contactLookup.d.ts +18 -0
  42. package/dist/nodes/ServiceM8JobCreation/operations/create/contactLookup.js +48 -0
  43. package/dist/nodes/ServiceM8JobCreation/operations/create/contactLookup.js.map +1 -0
  44. package/dist/nodes/ServiceM8JobCreation/operations/create/index.d.ts +12 -0
  45. package/dist/nodes/ServiceM8JobCreation/operations/create/index.js +40 -0
  46. package/dist/nodes/ServiceM8JobCreation/operations/create/index.js.map +1 -0
  47. package/dist/nodes/ServiceM8JobCreation/operations/create/inputProcessor.d.ts +63 -0
  48. package/dist/nodes/ServiceM8JobCreation/operations/create/inputProcessor.js +176 -0
  49. package/dist/nodes/ServiceM8JobCreation/operations/create/inputProcessor.js.map +1 -0
  50. package/dist/nodes/ServiceM8JobCreation/operations/create/jobCreate.d.ts +43 -0
  51. package/dist/nodes/ServiceM8JobCreation/operations/create/jobCreate.js +82 -0
  52. package/dist/nodes/ServiceM8JobCreation/operations/create/jobCreate.js.map +1 -0
  53. package/dist/nodes/ServiceM8JobCreation/operations/create/notifications.d.ts +38 -0
  54. package/dist/nodes/ServiceM8JobCreation/operations/create/notifications.js +123 -0
  55. package/dist/nodes/ServiceM8JobCreation/operations/create/notifications.js.map +1 -0
  56. package/dist/nodes/ServiceM8JobCreation/operations/create/orchestrator.d.ts +12 -0
  57. package/dist/nodes/ServiceM8JobCreation/operations/create/orchestrator.js +192 -0
  58. package/dist/nodes/ServiceM8JobCreation/operations/create/orchestrator.js.map +1 -0
  59. package/dist/nodes/ServiceM8JobCreation/operations/create/queueAssign.d.ts +22 -0
  60. package/dist/nodes/ServiceM8JobCreation/operations/create/queueAssign.js +61 -0
  61. package/dist/nodes/ServiceM8JobCreation/operations/create/queueAssign.js.map +1 -0
  62. package/dist/nodes/ServiceM8JobCreation/operations/index.d.ts +8 -0
  63. package/dist/nodes/ServiceM8JobCreation/operations/index.js +35 -0
  64. package/dist/nodes/ServiceM8JobCreation/operations/index.js.map +1 -0
  65. package/dist/nodes/ServiceM8JobCreation/operations/shared/attachmentsUpload.d.ts +41 -0
  66. package/dist/nodes/ServiceM8JobCreation/operations/shared/attachmentsUpload.js +243 -0
  67. package/dist/nodes/ServiceM8JobCreation/operations/shared/attachmentsUpload.js.map +1 -0
  68. package/dist/nodes/ServiceM8JobCreation/operations/shared/badgesAssign.d.ts +21 -0
  69. package/dist/nodes/ServiceM8JobCreation/operations/shared/badgesAssign.js +65 -0
  70. package/dist/nodes/ServiceM8JobCreation/operations/shared/badgesAssign.js.map +1 -0
  71. package/dist/nodes/ServiceM8JobCreation/operations/shared/index.d.ts +7 -0
  72. package/dist/nodes/ServiceM8JobCreation/operations/shared/index.js +15 -0
  73. package/dist/nodes/ServiceM8JobCreation/operations/shared/index.js.map +1 -0
  74. package/dist/nodes/ServiceM8JobCreation/operations/shared/notesCreate.d.ts +42 -0
  75. package/dist/nodes/ServiceM8JobCreation/operations/shared/notesCreate.js +103 -0
  76. package/dist/nodes/ServiceM8JobCreation/operations/shared/notesCreate.js.map +1 -0
  77. package/dist/nodes/ServiceM8JobCreation/operations/update/index.d.ts +5 -0
  78. package/dist/nodes/ServiceM8JobCreation/operations/update/index.js +9 -0
  79. package/dist/nodes/ServiceM8JobCreation/operations/update/index.js.map +1 -0
  80. package/dist/nodes/ServiceM8JobCreation/operations/update/jobUpdate.d.ts +10 -0
  81. package/dist/nodes/ServiceM8JobCreation/operations/update/jobUpdate.js +239 -0
  82. package/dist/nodes/ServiceM8JobCreation/operations/update/jobUpdate.js.map +1 -0
  83. package/dist/nodes/ServiceM8JobCreation/properties/create/address.d.ts +5 -0
  84. package/dist/nodes/ServiceM8JobCreation/properties/create/address.js +145 -0
  85. package/dist/nodes/ServiceM8JobCreation/properties/create/address.js.map +1 -0
  86. package/dist/nodes/ServiceM8JobCreation/properties/create/business.d.ts +5 -0
  87. package/dist/nodes/ServiceM8JobCreation/properties/create/business.js +22 -0
  88. package/dist/nodes/ServiceM8JobCreation/properties/create/business.js.map +1 -0
  89. package/dist/nodes/ServiceM8JobCreation/properties/create/contact.d.ts +5 -0
  90. package/dist/nodes/ServiceM8JobCreation/properties/create/contact.js +85 -0
  91. package/dist/nodes/ServiceM8JobCreation/properties/create/contact.js.map +1 -0
  92. package/dist/nodes/ServiceM8JobCreation/properties/create/index.d.ts +10 -0
  93. package/dist/nodes/ServiceM8JobCreation/properties/create/index.js +30 -0
  94. package/dist/nodes/ServiceM8JobCreation/properties/create/index.js.map +1 -0
  95. package/dist/nodes/ServiceM8JobCreation/properties/create/job.d.ts +5 -0
  96. package/dist/nodes/ServiceM8JobCreation/properties/create/job.js +43 -0
  97. package/dist/nodes/ServiceM8JobCreation/properties/create/job.js.map +1 -0
  98. package/dist/nodes/ServiceM8JobCreation/properties/create/options/additionalOptions.d.ts +5 -0
  99. package/dist/nodes/ServiceM8JobCreation/properties/create/options/additionalOptions.js +49 -0
  100. package/dist/nodes/ServiceM8JobCreation/properties/create/options/additionalOptions.js.map +1 -0
  101. package/dist/nodes/ServiceM8JobCreation/properties/create/options/attachments.d.ts +5 -0
  102. package/dist/nodes/ServiceM8JobCreation/properties/create/options/attachments.js +151 -0
  103. package/dist/nodes/ServiceM8JobCreation/properties/create/options/attachments.js.map +1 -0
  104. package/dist/nodes/ServiceM8JobCreation/properties/create/options/badges.d.ts +5 -0
  105. package/dist/nodes/ServiceM8JobCreation/properties/create/options/badges.js +65 -0
  106. package/dist/nodes/ServiceM8JobCreation/properties/create/options/badges.js.map +1 -0
  107. package/dist/nodes/ServiceM8JobCreation/properties/create/options/category.d.ts +5 -0
  108. package/dist/nodes/ServiceM8JobCreation/properties/create/options/category.js +65 -0
  109. package/dist/nodes/ServiceM8JobCreation/properties/create/options/category.js.map +1 -0
  110. package/dist/nodes/ServiceM8JobCreation/properties/create/options/index.d.ts +12 -0
  111. package/dist/nodes/ServiceM8JobCreation/properties/create/options/index.js +38 -0
  112. package/dist/nodes/ServiceM8JobCreation/properties/create/options/index.js.map +1 -0
  113. package/dist/nodes/ServiceM8JobCreation/properties/create/options/notes.d.ts +5 -0
  114. package/dist/nodes/ServiceM8JobCreation/properties/create/options/notes.js +49 -0
  115. package/dist/nodes/ServiceM8JobCreation/properties/create/options/notes.js.map +1 -0
  116. package/dist/nodes/ServiceM8JobCreation/properties/create/options/notifications.d.ts +5 -0
  117. package/dist/nodes/ServiceM8JobCreation/properties/create/options/notifications.js +197 -0
  118. package/dist/nodes/ServiceM8JobCreation/properties/create/options/notifications.js.map +1 -0
  119. package/dist/nodes/ServiceM8JobCreation/properties/create/options/queue.d.ts +5 -0
  120. package/dist/nodes/ServiceM8JobCreation/properties/create/options/queue.js +65 -0
  121. package/dist/nodes/ServiceM8JobCreation/properties/create/options/queue.js.map +1 -0
  122. package/dist/nodes/ServiceM8JobCreation/properties/index.d.ts +9 -0
  123. package/dist/nodes/ServiceM8JobCreation/properties/index.js +23 -0
  124. package/dist/nodes/ServiceM8JobCreation/properties/index.js.map +1 -0
  125. package/dist/nodes/ServiceM8JobCreation/properties/operation.d.ts +5 -0
  126. package/dist/nodes/ServiceM8JobCreation/properties/operation.js +28 -0
  127. package/dist/nodes/ServiceM8JobCreation/properties/operation.js.map +1 -0
  128. package/dist/nodes/ServiceM8JobCreation/properties/update/fields.d.ts +5 -0
  129. package/dist/nodes/ServiceM8JobCreation/properties/update/fields.js +74 -0
  130. package/dist/nodes/ServiceM8JobCreation/properties/update/fields.js.map +1 -0
  131. package/dist/nodes/ServiceM8JobCreation/properties/update/index.d.ts +8 -0
  132. package/dist/nodes/ServiceM8JobCreation/properties/update/index.js +22 -0
  133. package/dist/nodes/ServiceM8JobCreation/properties/update/index.js.map +1 -0
  134. package/dist/nodes/ServiceM8JobCreation/properties/update/jobSelection.d.ts +5 -0
  135. package/dist/nodes/ServiceM8JobCreation/properties/update/jobSelection.js +63 -0
  136. package/dist/nodes/ServiceM8JobCreation/properties/update/jobSelection.js.map +1 -0
  137. package/dist/nodes/ServiceM8JobCreation/properties/update/options.d.ts +5 -0
  138. package/dist/nodes/ServiceM8JobCreation/properties/update/options.js +142 -0
  139. package/dist/nodes/ServiceM8JobCreation/properties/update/options.js.map +1 -0
  140. package/dist/nodes/ServiceM8JobCreation/servicem8.svg +75 -0
  141. package/dist/nodes/ServiceM8JobCreation/types/api.d.ts +59 -0
  142. package/dist/nodes/ServiceM8JobCreation/types/api.js +34 -0
  143. package/dist/nodes/ServiceM8JobCreation/types/api.js.map +1 -0
  144. package/dist/nodes/ServiceM8JobCreation/types/index.d.ts +7 -0
  145. package/dist/nodes/ServiceM8JobCreation/types/index.js +21 -0
  146. package/dist/nodes/ServiceM8JobCreation/types/index.js.map +1 -0
  147. package/dist/nodes/ServiceM8JobCreation/types/input.d.ts +119 -0
  148. package/dist/nodes/ServiceM8JobCreation/types/input.js +6 -0
  149. package/dist/nodes/ServiceM8JobCreation/types/input.js.map +1 -0
  150. package/dist/nodes/ServiceM8JobCreation/types/result.d.ts +79 -0
  151. package/dist/nodes/ServiceM8JobCreation/types/result.js +96 -0
  152. package/dist/nodes/ServiceM8JobCreation/types/result.js.map +1 -0
  153. package/package.json +66 -0
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Attachment Upload Operations
3
+ * Two-step attachment upload process for ServiceM8
4
+ * Step 1: Create attachment metadata record
5
+ * Step 2: Upload binary file content
6
+ *
7
+ * Supports three modes:
8
+ * - allBinary: Automatically upload all binary properties from the item
9
+ * - urlList: Download and upload from a list of URLs
10
+ * - manual: Manually specified attachments
11
+ */
12
+ import type { IExecuteFunctions } from 'n8n-workflow';
13
+ export type AttachmentMode = 'allBinary' | 'urlList' | 'manual';
14
+ export interface AttachmentInput {
15
+ sourceType: 'binary' | 'url';
16
+ binaryPropertyName?: string;
17
+ fileUrl?: string;
18
+ fileName?: string;
19
+ fileType?: string;
20
+ }
21
+ export interface AttachmentUploadResult {
22
+ uuid: string;
23
+ fileName: string;
24
+ }
25
+ export interface AttachmentsResult {
26
+ attachmentsUploaded: string[];
27
+ attachmentsFailed: string[];
28
+ attachmentUuids: string[];
29
+ }
30
+ export interface AttachmentsConfig {
31
+ enableAttachments: boolean;
32
+ attachmentMode: AttachmentMode;
33
+ attachmentUrlList: string;
34
+ attachmentsInput: {
35
+ attachment?: AttachmentInput[];
36
+ };
37
+ }
38
+ /**
39
+ * Upload attachments to a job - handles all three modes
40
+ */
41
+ export declare function uploadAttachments(context: IExecuteFunctions, itemIndex: number, jobUuid: string, config: AttachmentsConfig): Promise<AttachmentsResult>;
@@ -0,0 +1,243 @@
1
+ "use strict";
2
+ /**
3
+ * Attachment Upload Operations
4
+ * Two-step attachment upload process for ServiceM8
5
+ * Step 1: Create attachment metadata record
6
+ * Step 2: Upload binary file content
7
+ *
8
+ * Supports three modes:
9
+ * - allBinary: Automatically upload all binary properties from the item
10
+ * - urlList: Download and upload from a list of URLs
11
+ * - manual: Manually specified attachments
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.uploadAttachments = void 0;
15
+ const api_1 = require("../../helpers/api");
16
+ /**
17
+ * Get file extension from filename or mime type
18
+ */
19
+ function getFileExtension(fileName, mimeType) {
20
+ // Try to get extension from filename
21
+ const parts = fileName.split('.');
22
+ if (parts.length > 1) {
23
+ return '.' + parts.pop().toLowerCase();
24
+ }
25
+ // Fall back to mime type mapping
26
+ if (mimeType) {
27
+ const mimeToExt = {
28
+ 'application/pdf': '.pdf',
29
+ 'image/jpeg': '.jpg',
30
+ 'image/png': '.png',
31
+ 'image/gif': '.gif',
32
+ 'image/webp': '.webp',
33
+ 'application/msword': '.doc',
34
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': '.docx',
35
+ 'application/vnd.ms-excel': '.xls',
36
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': '.xlsx',
37
+ 'text/plain': '.txt',
38
+ 'text/csv': '.csv',
39
+ };
40
+ if (mimeToExt[mimeType]) {
41
+ return mimeToExt[mimeType];
42
+ }
43
+ }
44
+ return '.bin';
45
+ }
46
+ /**
47
+ * Upload a single binary property to a job
48
+ */
49
+ async function uploadBinaryProperty(context, itemIndex, jobUuid, binaryPropertyName) {
50
+ const binaryData = context.helpers.assertBinaryData(itemIndex, binaryPropertyName);
51
+ const buffer = await context.helpers.getBinaryDataBuffer(itemIndex, binaryPropertyName);
52
+ let fileName = binaryData.fileName || `${binaryPropertyName}_${Date.now()}`;
53
+ const mimeType = binaryData.mimeType || 'application/octet-stream';
54
+ const fileType = getFileExtension(fileName, mimeType);
55
+ // Ensure filename has extension
56
+ if (!fileName.includes('.')) {
57
+ fileName = fileName + fileType;
58
+ }
59
+ // Step 1: Create attachment metadata record
60
+ const metadataResponse = await (0, api_1.serviceM8Request)(context, {
61
+ method: 'POST',
62
+ endpoint: '/api_1.0/Attachment.json',
63
+ body: {
64
+ related_object: 'job',
65
+ related_object_uuid: jobUuid,
66
+ attachment_name: fileName,
67
+ file_type: fileType,
68
+ active: 1,
69
+ },
70
+ returnFullResponse: true,
71
+ });
72
+ const attachmentUuid = (0, api_1.extractUuidFromResponse)(metadataResponse);
73
+ if (!attachmentUuid) {
74
+ throw new Error(`Failed to create attachment metadata for ${fileName}`);
75
+ }
76
+ // Step 2: Upload binary file content
77
+ await (0, api_1.uploadAttachmentBinary)(context, attachmentUuid, buffer, fileName, mimeType);
78
+ return {
79
+ uuid: attachmentUuid,
80
+ fileName,
81
+ };
82
+ }
83
+ /**
84
+ * Upload a file from URL to a job
85
+ */
86
+ async function uploadFromUrl(context, jobUuid, fileUrl, customFileName) {
87
+ // Download file from URL
88
+ const response = await context.helpers.httpRequest({
89
+ method: 'GET',
90
+ url: fileUrl,
91
+ encoding: 'arraybuffer',
92
+ });
93
+ const buffer = Buffer.from(response);
94
+ // Extract filename from URL or use provided
95
+ let fileName;
96
+ if (customFileName) {
97
+ fileName = customFileName;
98
+ }
99
+ else {
100
+ const urlPath = new URL(fileUrl).pathname;
101
+ fileName = urlPath.split('/').pop() || `download_${Date.now()}`;
102
+ }
103
+ const mimeType = 'application/octet-stream';
104
+ const fileType = getFileExtension(fileName, mimeType);
105
+ // Ensure filename has extension
106
+ if (!fileName.includes('.')) {
107
+ fileName = fileName + fileType;
108
+ }
109
+ // Step 1: Create attachment metadata record
110
+ const metadataResponse = await (0, api_1.serviceM8Request)(context, {
111
+ method: 'POST',
112
+ endpoint: '/api_1.0/Attachment.json',
113
+ body: {
114
+ related_object: 'job',
115
+ related_object_uuid: jobUuid,
116
+ attachment_name: fileName,
117
+ file_type: fileType,
118
+ active: 1,
119
+ },
120
+ returnFullResponse: true,
121
+ });
122
+ const attachmentUuid = (0, api_1.extractUuidFromResponse)(metadataResponse);
123
+ if (!attachmentUuid) {
124
+ throw new Error(`Failed to create attachment metadata for ${fileName}`);
125
+ }
126
+ // Step 2: Upload binary file content
127
+ await (0, api_1.uploadAttachmentBinary)(context, attachmentUuid, buffer, fileName, mimeType);
128
+ return {
129
+ uuid: attachmentUuid,
130
+ fileName,
131
+ };
132
+ }
133
+ /**
134
+ * Upload a single attachment to a job (manual mode)
135
+ */
136
+ async function uploadManualAttachment(context, itemIndex, jobUuid, attachment) {
137
+ if (attachment.sourceType === 'binary') {
138
+ return uploadBinaryProperty(context, itemIndex, jobUuid, attachment.binaryPropertyName || 'data');
139
+ }
140
+ else {
141
+ return uploadFromUrl(context, jobUuid, attachment.fileUrl, attachment.fileName);
142
+ }
143
+ }
144
+ /**
145
+ * Parse URL list - handles both comma-separated string and array
146
+ */
147
+ function parseUrlList(urlListInput) {
148
+ if (Array.isArray(urlListInput)) {
149
+ return urlListInput.map(u => u.trim()).filter(u => u);
150
+ }
151
+ if (typeof urlListInput === 'string' && urlListInput.trim()) {
152
+ return urlListInput
153
+ .split(',')
154
+ .map(u => u.trim())
155
+ .filter(u => u);
156
+ }
157
+ return [];
158
+ }
159
+ /**
160
+ * Get all binary property names from an item
161
+ */
162
+ function getAllBinaryPropertyNames(context, itemIndex) {
163
+ const items = context.getInputData();
164
+ const item = items[itemIndex];
165
+ if (!item.binary) {
166
+ return [];
167
+ }
168
+ return Object.keys(item.binary);
169
+ }
170
+ /**
171
+ * Upload attachments to a job - handles all three modes
172
+ */
173
+ async function uploadAttachments(context, itemIndex, jobUuid, config) {
174
+ const uploaded = [];
175
+ const failed = [];
176
+ const uuids = [];
177
+ if (!config.enableAttachments) {
178
+ return { attachmentsUploaded: uploaded, attachmentsFailed: failed, attachmentUuids: uuids };
179
+ }
180
+ const mode = config.attachmentMode || 'allBinary';
181
+ if (mode === 'allBinary') {
182
+ // Upload all binary properties from the item
183
+ const binaryPropertyNames = getAllBinaryPropertyNames(context, itemIndex);
184
+ if (binaryPropertyNames.length === 0) {
185
+ return { attachmentsUploaded: uploaded, attachmentsFailed: failed, attachmentUuids: uuids };
186
+ }
187
+ for (const propertyName of binaryPropertyNames) {
188
+ try {
189
+ const result = await uploadBinaryProperty(context, itemIndex, jobUuid, propertyName);
190
+ uploaded.push(result.fileName);
191
+ uuids.push(result.uuid);
192
+ }
193
+ catch (error) {
194
+ failed.push(propertyName);
195
+ }
196
+ }
197
+ }
198
+ else if (mode === 'urlList') {
199
+ // Download and upload from URL list
200
+ const urls = parseUrlList(config.attachmentUrlList);
201
+ if (urls.length === 0) {
202
+ return { attachmentsUploaded: uploaded, attachmentsFailed: failed, attachmentUuids: uuids };
203
+ }
204
+ for (const url of urls) {
205
+ try {
206
+ const result = await uploadFromUrl(context, jobUuid, url);
207
+ uploaded.push(result.fileName);
208
+ uuids.push(result.uuid);
209
+ }
210
+ catch (error) {
211
+ failed.push(url);
212
+ }
213
+ }
214
+ }
215
+ else {
216
+ // Manual mode - use the fixed collection
217
+ const attachments = config.attachmentsInput.attachment || [];
218
+ if (attachments.length === 0) {
219
+ return { attachmentsUploaded: uploaded, attachmentsFailed: failed, attachmentUuids: uuids };
220
+ }
221
+ for (const attachment of attachments) {
222
+ try {
223
+ const result = await uploadManualAttachment(context, itemIndex, jobUuid, attachment);
224
+ uploaded.push(result.fileName);
225
+ uuids.push(result.uuid);
226
+ }
227
+ catch (error) {
228
+ const name = attachment.fileName ||
229
+ attachment.binaryPropertyName ||
230
+ attachment.fileUrl ||
231
+ 'unknown';
232
+ failed.push(name);
233
+ }
234
+ }
235
+ }
236
+ return {
237
+ attachmentsUploaded: uploaded,
238
+ attachmentsFailed: failed,
239
+ attachmentUuids: uuids,
240
+ };
241
+ }
242
+ exports.uploadAttachments = uploadAttachments;
243
+ //# sourceMappingURL=attachmentsUpload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachmentsUpload.js","sourceRoot":"","sources":["../../../../../nodes/ServiceM8JobCreation/operations/shared/attachmentsUpload.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAGH,2CAI2B;AA8B3B;;GAEG;AACH,SAAS,gBAAgB,CAAC,QAAgB,EAAE,QAAiB;IAC5D,qCAA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C"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Badges Assignment Operations
3
+ * Assign badges to job (static or dynamic)
4
+ */
5
+ import type { IExecuteFunctions } from 'n8n-workflow';
6
+ export interface BadgesAssignInput {
7
+ jobUuid: string;
8
+ enableBadges: boolean;
9
+ badgesDynamic: boolean;
10
+ badgeUuidsInput: string[];
11
+ badgeNamesInput: string;
12
+ }
13
+ export interface BadgesAssignResult {
14
+ badgesAssigned: string[];
15
+ badgesMissing: string[];
16
+ }
17
+ /**
18
+ * Assign badges to a job
19
+ * Handles both static (UUIDs from dropdown) and dynamic (name lookup) modes
20
+ */
21
+ export declare function assignBadges(context: IExecuteFunctions, input: BadgesAssignInput): Promise<BadgesAssignResult>;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ /**
3
+ * Badges Assignment Operations
4
+ * Assign badges to job (static or dynamic)
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.assignBadges = void 0;
8
+ const api_1 = require("../../helpers/api");
9
+ /**
10
+ * Assign badges to a job
11
+ * Handles both static (UUIDs from dropdown) and dynamic (name lookup) modes
12
+ */
13
+ async function assignBadges(context, input) {
14
+ const badgesAssigned = [];
15
+ const badgesMissing = [];
16
+ if (!input.enableBadges) {
17
+ return { badgesAssigned, badgesMissing };
18
+ }
19
+ // Get all badges for lookup
20
+ const badgesResponse = await (0, api_1.serviceM8Request)(context, {
21
+ method: 'GET',
22
+ endpoint: '/api_1.0/badge.json',
23
+ query: { $filter: 'active eq 1' },
24
+ });
25
+ const allBadges = (0, api_1.parseArrayResponse)(badgesResponse);
26
+ const badgeMap = new Map(allBadges.map((b) => [b.uuid, b.name]));
27
+ let badgeUuidsToApply = [];
28
+ if (input.badgesDynamic && input.badgeNamesInput) {
29
+ // Dynamic mode: parse comma-separated names and look them up
30
+ const badgeNames = input.badgeNamesInput
31
+ .split(',')
32
+ .map((n) => n.trim())
33
+ .filter((n) => n);
34
+ for (const name of badgeNames) {
35
+ const foundBadge = (0, api_1.findBadgeByName)(allBadges, name);
36
+ if (foundBadge) {
37
+ badgeUuidsToApply.push(foundBadge.uuid);
38
+ }
39
+ else {
40
+ badgesMissing.push(name);
41
+ }
42
+ }
43
+ }
44
+ else {
45
+ // Static mode: use UUIDs directly
46
+ badgeUuidsToApply = input.badgeUuidsInput;
47
+ }
48
+ // Assign badges (all at once via job update)
49
+ if (badgeUuidsToApply.length > 0) {
50
+ await (0, api_1.assignBadgesToJob)(context, input.jobUuid, badgeUuidsToApply);
51
+ // Record which badges were assigned
52
+ for (const badgeUuid of badgeUuidsToApply) {
53
+ const badgeName = badgeMap.get(badgeUuid);
54
+ if (badgeName) {
55
+ badgesAssigned.push(badgeName);
56
+ }
57
+ }
58
+ }
59
+ return {
60
+ badgesAssigned,
61
+ badgesMissing,
62
+ };
63
+ }
64
+ exports.assignBadges = assignBadges;
65
+ //# sourceMappingURL=badgesAssign.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"badgesAssign.js","sourceRoot":"","sources":["../../../../../nodes/ServiceM8JobCreation/operations/shared/badgesAssign.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,2CAK2B;AAe3B;;;GAGG;AACI,KAAK,UAAU,YAAY,CACjC,OAA0B,EAC1B,KAAwB;IAExB,MAAM,cAAc,GAAa,EAAE,CAAC;IACpC,MAAM,aAAa,GAAa,EAAE,CAAC;IAEnC,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;QACxB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC;KACzC;IAED,4BAA4B;IAC5B,MAAM,cAAc,GAAG,MAAM,IAAA,sBAAgB,EAAC,OAAO,EAAE;QACtD,MAAM,EAAE,KAAK;QACb,QAAQ,EAAE,qBAAqB;QAC/B,KAAK,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE;KACjC,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,IAAA,wBAAkB,EAAiB,cAAc,CAAC,CAAC;IACrE,MAAM,QAAQ,GAAG,I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KACb,CAAC;AACH,CAAC;AA3DD,oCA2DC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Shared Operations Index
3
+ * Operations used by both Create and Update
4
+ */
5
+ export { uploadAttachments, type AttachmentMode, type AttachmentInput, type AttachmentUploadResult, type AttachmentsResult, type AttachmentsConfig, } from './attachmentsUpload';
6
+ export { assignBadges, type BadgesAssignInput, type BadgesAssignResult, } from './badgesAssign';
7
+ export { buildSystemReportNote, createNotes, type SystemReportInput, type NotesCreateResult, } from './notesCreate';
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ /**
3
+ * Shared Operations Index
4
+ * Operations used by both Create and Update
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.createNotes = exports.buildSystemReportNote = exports.assignBadges = exports.uploadAttachments = void 0;
8
+ var attachmentsUpload_1 = require("./attachmentsUpload");
9
+ Object.defineProperty(exports, "uploadAttachments", { enumerable: true, get: function () { return attachmentsUpload_1.uploadAttachments; } });
10
+ var badgesAssign_1 = require("./badgesAssign");
11
+ Object.defineProperty(exports, "assignBadges", { enumerable: true, get: function () { return badgesAssign_1.assignBadges; } });
12
+ var notesCreate_1 = require("./notesCreate");
13
+ Object.defineProperty(exports, "buildSystemReportNote", { enumerable: true, get: function () { return notesCreate_1.buildSystemReportNote; } });
14
+ Object.defineProperty(exports, "createNotes", { enumerable: true, get: function () { return notesCreate_1.createNotes; } });
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../nodes/ServiceM8JobCreation/operations/shared/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yDAO6B;AAN5B,sHAAA,iBAAiB,OAAA;AAQlB,+CAIwB;AAHvB,4GAAA,YAAY,OAAA;AAKb,6CAKuB;AAJtB,oHAAA,qBAAqB,OAAA;AACrB,0GAAA,WAAW,OAAA"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Notes Creation Operations
3
+ * Create system report and custom notes
4
+ */
5
+ import type { IExecuteFunctions } from 'n8n-workflow';
6
+ export interface SystemReportInput {
7
+ jobUuid: string;
8
+ clientCreated: boolean;
9
+ contactCreated: boolean;
10
+ matchReason: string;
11
+ enableCategory: boolean;
12
+ categoryAssigned: boolean;
13
+ categoryName?: string;
14
+ categoryMissing?: string;
15
+ enableBadges: boolean;
16
+ badgesAssigned: string[];
17
+ badgesMissing: string[];
18
+ enableQueue: boolean;
19
+ queueAssigned: boolean;
20
+ queueName?: string;
21
+ queueMissing?: string;
22
+ enableNotifications: boolean;
23
+ emailsSent: number;
24
+ smsSent: number;
25
+ enableAttachments: boolean;
26
+ attachmentsUploaded: string[];
27
+ attachmentsFailed: string[];
28
+ }
29
+ export interface NotesCreateResult {
30
+ systemNoteAdded: boolean;
31
+ customNoteAdded: boolean;
32
+ systemNoteUuid: string;
33
+ customNoteUuid: string;
34
+ }
35
+ /**
36
+ * Build the system report note content
37
+ */
38
+ export declare function buildSystemReportNote(input: SystemReportInput): string;
39
+ /**
40
+ * Create the system report note and optional custom note
41
+ */
42
+ export declare function createNotes(context: IExecuteFunctions, jobUuid: string, systemReportInput: SystemReportInput, enableCustomNote: boolean, customNoteContent: string): Promise<NotesCreateResult>;
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ /**
3
+ * Notes Creation Operations
4
+ * Create system report and custom notes
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.createNotes = exports.buildSystemReportNote = void 0;
8
+ const api_1 = require("../../helpers/api");
9
+ /**
10
+ * Build the system report note content
11
+ */
12
+ function buildSystemReportNote(input) {
13
+ const reportLines = [];
14
+ reportLines.push('πŸ“‹ JOB CREATION REPORT');
15
+ reportLines.push('─'.repeat(30));
16
+ reportLines.push('');
17
+ // Client/Contact status
18
+ if (input.clientCreated) {
19
+ reportLines.push('βœ… New client created');
20
+ }
21
+ else {
22
+ reportLines.push(`βœ… Matched existing client: ${input.matchReason}`);
23
+ }
24
+ if (input.contactCreated) {
25
+ reportLines.push('βœ… New contact created');
26
+ }
27
+ else {
28
+ reportLines.push('βœ… Using existing contact');
29
+ }
30
+ // Category status
31
+ if (input.enableCategory) {
32
+ if (input.categoryAssigned && input.categoryName) {
33
+ reportLines.push(`βœ… Category: ${input.categoryName}`);
34
+ }
35
+ else if (input.categoryMissing) {
36
+ reportLines.push(`⚠️ Category not found: "${input.categoryMissing}"`);
37
+ }
38
+ }
39
+ // Badges status
40
+ if (input.enableBadges) {
41
+ if (input.badgesAssigned.length > 0) {
42
+ reportLines.push(`βœ… Badges: ${input.badgesAssigned.join(', ')}`);
43
+ }
44
+ if (input.badgesMissing.length > 0) {
45
+ reportLines.push(`⚠️ Badges not found: ${input.badgesMissing.join(', ')}`);
46
+ }
47
+ }
48
+ // Queue status
49
+ if (input.enableQueue) {
50
+ if (input.queueAssigned && input.queueName) {
51
+ reportLines.push(`βœ… Queue: ${input.queueName}`);
52
+ }
53
+ else if (input.queueMissing) {
54
+ reportLines.push(`⚠️ Queue not found: "${input.queueMissing}"`);
55
+ }
56
+ }
57
+ // Notifications status
58
+ if (input.enableNotifications) {
59
+ if (input.emailsSent > 0 || input.smsSent > 0) {
60
+ reportLines.push(`βœ… Notifications: ${input.emailsSent} email(s), ${input.smsSent} SMS`);
61
+ }
62
+ }
63
+ // Attachments status
64
+ if (input.enableAttachments) {
65
+ if (input.attachmentsUploaded.length > 0) {
66
+ reportLines.push(`βœ… Attachments: ${input.attachmentsUploaded.join(', ')}`);
67
+ }
68
+ if (input.attachmentsFailed.length > 0) {
69
+ reportLines.push(`⚠️ Attachments failed: ${input.attachmentsFailed.join(', ')}`);
70
+ }
71
+ }
72
+ // Branding footer
73
+ reportLines.push('');
74
+ reportLines.push('─'.repeat(30));
75
+ reportLines.push('n8n ServiceM8 Smart Job Creator');
76
+ reportLines.push('Created by Trade Magnet🧲');
77
+ reportLines.push('www.trademagnet.com.au');
78
+ return reportLines.join('\n');
79
+ }
80
+ exports.buildSystemReportNote = buildSystemReportNote;
81
+ /**
82
+ * Create the system report note and optional custom note
83
+ */
84
+ async function createNotes(context, jobUuid, systemReportInput, enableCustomNote, customNoteContent) {
85
+ // Create system report note
86
+ const systemReportNote = buildSystemReportNote(systemReportInput);
87
+ const systemNoteUuid = await (0, api_1.createJobNote)(context, jobUuid, systemReportNote);
88
+ // Create custom note if enabled
89
+ let customNoteAdded = false;
90
+ let customNoteUuid = '';
91
+ if (enableCustomNote && customNoteContent) {
92
+ customNoteUuid = await (0, api_1.createJobNote)(context, jobUuid, customNoteContent);
93
+ customNoteAdded = true;
94
+ }
95
+ return {
96
+ systemNoteAdded: true,
97
+ customNoteAdded,
98
+ systemNoteUuid,
99
+ customNoteUuid,
100
+ };
101
+ }
102
+ exports.createNotes = createNotes;
103
+ //# sourceMappingURL=notesCreate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notesCreate.js","sourceRoot":"","sources":["../../../../../nodes/ServiceM8JobCreation/operations/shared/notesCreate.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2CAAkD;AA2ClD;;GAEG;AACH,SAAgB,qBAAqB,CAAC,KAAwB;IAC7D,MAAM,WAAW,GAAa,EAAE,CAAC;IAEjC,WAAW,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IAC3C,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IACjC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAErB,wBAAwB;IACxB,IAAI,KAAK,CAAC,aAAa,EAAE;QACxB,WAAW,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;KACzC;SAAM;QACN,WAAW,CAAC,IAAI,CAAC,8BAA8B,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;KACpE;IAED,IAAI,KAAK,CAAC,cAAc,EAAE;QACzB,WAAW,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;KAC1C;SAAM;QACN,WAAW,CAAC,IAAI,CAAC,0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BAAiB,EAAE;QAC1C,cAAc,GAAG,MAAM,IAAA,mBAAa,EAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAC;QAC1E,eAAe,GAAG,IAAI,CAAC;KACvB;IAED,OAAO;QACN,eAAe,EAAE,IAAI;QACrB,eAAe;QACf,cAAc;QACd,cAAc;KACd,CAAC;AACH,CAAC;AAzBD,kCAyBC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Update Job Operations Index
3
+ */
4
+ export { executeJobUpdate } from './jobUpdate';
5
+ export { type JobUpdateResult } from '../../types';
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /**
3
+ * Update Job Operations Index
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.executeJobUpdate = void 0;
7
+ var jobUpdate_1 = require("./jobUpdate");
8
+ Object.defineProperty(exports, "executeJobUpdate", { enumerable: true, get: function () { return jobUpdate_1.executeJobUpdate; } });
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../nodes/ServiceM8JobCreation/operations/update/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,yCAA+C;AAAtC,6GAAA,gBAAgB,OAAA"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Job Update Orchestrator
3
+ * Coordinates all operations for updating an existing ServiceM8 job
4
+ */
5
+ import type { IExecuteFunctions } from 'n8n-workflow';
6
+ import type { JobUpdateResult } from '../../types';
7
+ /**
8
+ * Execute job update for a single item
9
+ */
10
+ export declare function executeJobUpdate(context: IExecuteFunctions, itemIndex: number): Promise<JobUpdateResult>;