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,66 @@
1
+ "use strict";
2
+ /**
3
+ * Client Creation Operations
4
+ * Create client and company contact
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.createCompanyContactIfNeeded = exports.createClientIfNeeded = void 0;
8
+ const api_1 = require("../../helpers/api");
9
+ const contactLookup_1 = require("./contactLookup");
10
+ /**
11
+ * Create a new client if needed
12
+ */
13
+ async function createClientIfNeeded(context, needsClient, existingClientUuid, input) {
14
+ if (!needsClient && existingClientUuid) {
15
+ return {
16
+ clientUuid: existingClientUuid,
17
+ clientCreated: false,
18
+ };
19
+ }
20
+ const clientUuid = await (0, api_1.createClient)(context, {
21
+ name: input.clientName,
22
+ is_individual: input.isIndividual,
23
+ address: input.clientAddress,
24
+ address_street: input.clientAddressParts.street,
25
+ address_city: input.clientAddressParts.city,
26
+ address_state: input.clientAddressParts.state,
27
+ address_postcode: input.clientAddressParts.postcode,
28
+ address_country: input.clientAddressParts.country,
29
+ });
30
+ return {
31
+ clientUuid,
32
+ clientCreated: true,
33
+ };
34
+ }
35
+ exports.createClientIfNeeded = createClientIfNeeded;
36
+ /**
37
+ * Create a company contact if needed
38
+ */
39
+ async function createCompanyContactIfNeeded(context, needsContact, clientUuid, contactLookupField, input) {
40
+ // Check if contact already exists on target client
41
+ if (needsContact && contactLookupField) {
42
+ const identifier = input.email || input.mobile || input.phone || '';
43
+ const exists = await (0, contactLookup_1.checkContactExistsOnClient)(context, clientUuid, contactLookupField, identifier);
44
+ if (exists) {
45
+ return { contactCreated: false };
46
+ }
47
+ }
48
+ if (!needsContact) {
49
+ return { contactCreated: false };
50
+ }
51
+ const contactUuid = await (0, api_1.createCompanyContact)(context, {
52
+ company_uuid: clientUuid,
53
+ first: input.firstName,
54
+ last: input.lastName,
55
+ email: input.email || undefined,
56
+ phone: input.phone || undefined,
57
+ mobile: input.mobile || undefined,
58
+ type: 'BILLING',
59
+ });
60
+ return {
61
+ contactUuid,
62
+ contactCreated: true,
63
+ };
64
+ }
65
+ exports.createCompanyContactIfNeeded = createCompanyContactIfNeeded;
66
+ //# sourceMappingURL=clientCreate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientCreate.js","sourceRoot":"","sources":["../../../../../nodes/ServiceM8JobCreation/operations/create/clientCreate.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,2CAAuE;AACvE,mDAA6D;AA4B7D;;GAEG;AACI,KAAK,UAAU,oBAAoB,CACzC,OAA0B,EAC1B,WAAoB,EACpB,kBAAiC,EACjC,KAAwB;IAExB,IAAI,CAAC,WAAW,IAAI,kBAAkB,EAAE;QACvC,OAAO;YACN,UAAU,EAAE,kBAAkB;YAC9B,aAAa,EAAE,KAAK;SACpB,CAAC;KACF;IAED,MAAM,UAAU,GAAG,MAAM,IAAA,kBAAY,EAAC,OAAO,EAAE;QAC9C,IAAI,EAAE,KAAK,CAAC,UAAU;QACtB,aAAa,EAAE,KAAK,CAAC,YAAY;QACjC,OAAO,EAAE,KAAK,CAAC,aAAa;QAC5B,cAAc,EAAE,KAAK,CAAC,kBAAkB,CAAC,MAAM;QAC/C,YAAY,EAAE,KAAK,CAAC,kBAAkB,CAAC,IAAI;QAC3C,aAAa,EAAE,KAAK,CAAC,kBAAkB,CAAC,KAAK;QAC7C,gBAAgB,EAAE,KAAK,CAAC,kBAAkB,CAAC,QAAQ;QACnD,eAAe,EAAE,KAAK,CAAC,kBAAkB,CAAC,OAAO;KACjD,CAAC,CAAC;IAEH,OAAO;QACN,UAAU;QACV,aAAa,EAAE,IAAI;KACnB,CAAC;AACH,CAAC;AA5BD,oDA4BC;AAED;;GAEG;AACI,KAAK,UAAU,4BAA4B,CACjD,OAA0B,EAC1B,YAAqB,EACrB,UAAkB,EAClB,kBAAuD,EACvD,KAAyB;IAEzB,mDAAmD;IACnD,IAAI,YAAY,IAAI,kBAAkB,EAAE;QACvC,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;QACpE,MAAM,MAAM,GAAG,MAAM,IAAA,0CAA0B,EAC9C,OAAO,EACP,UAAU,EACV,kBAAkB,EAClB,UAAU,CACV,CAAC;QACF,IAAI,MAAM,EAAE;YACX,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;SACjC;KACD;IAED,IAAI,CAAC,YAAY,EAAE;QAClB,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;KACjC;IAED,MAAM,WAAW,GAAG,MAAM,IAAA,0BAAoB,EAAC,OAAO,EAAE;QACvD,YAAY,EAAE,UAAU;QACxB,KAAK,EAAE,KAAK,CAAC,SAAS;QACtB,IAAI,EAAE,KAAK,CAAC,QAAQ;QACpB,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,SAAS;QAC/B,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,SAAS;QAC/B,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,SAAS;QACjC,IAAI,EAAE,SAAS;KACf,CAAC,CAAC;IAEH,OAAO;QACN,WAAW;QACX,cAAc,EAAE,IAAI;KACpB,CAAC;AACH,CAAC;AAvCD,oEAuCC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Client Lookup Operations
3
+ * Find and match existing clients with decision logic
4
+ */
5
+ import type { IExecuteFunctions } from 'n8n-workflow';
6
+ import type { ServiceM8Client, ServiceM8Contact, AddressParts, MatchResult } from '../../types';
7
+ import { type ActionDecisionResult } from '../../helpers/clientMatcher';
8
+ export interface ClientLookupResult {
9
+ allClients: ServiceM8Client[];
10
+ matchResult: {
11
+ client: ServiceM8Client | null;
12
+ matchType: MatchResult;
13
+ reason: string;
14
+ };
15
+ }
16
+ export interface ActionResult extends ActionDecisionResult {
17
+ matchType: MatchResult;
18
+ matchReason: string;
19
+ clientsChecked: number;
20
+ }
21
+ /**
22
+ * Look up clients of a specific type (business or individual)
23
+ */
24
+ export declare function lookupClients(context: IExecuteFunctions, isIndividual: number): Promise<ServiceM8Client[]>;
25
+ /**
26
+ * Find the best matching client and determine action to take
27
+ */
28
+ export declare function findMatchingClientAndDetermineAction(clientName: string, clientAddressParts: AddressParts, allClients: ServiceM8Client[], isBusiness: boolean, kind: 'business' | 'person', existingContact: ServiceM8Contact | null): ActionResult;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ /**
3
+ * Client Lookup Operations
4
+ * Find and match existing clients with decision logic
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.findMatchingClientAndDetermineAction = exports.lookupClients = void 0;
8
+ const api_1 = require("../../helpers/api");
9
+ const clientMatcher_1 = require("../../helpers/clientMatcher");
10
+ /**
11
+ * Look up clients of a specific type (business or individual)
12
+ */
13
+ async function lookupClients(context, isIndividual) {
14
+ const clientsResponse = await (0, api_1.serviceM8Request)(context, {
15
+ method: 'GET',
16
+ endpoint: '/api_1.0/company.json',
17
+ query: { $filter: `active eq 1 and is_individual eq ${isIndividual}` },
18
+ });
19
+ return (0, api_1.parseArrayResponse)(clientsResponse);
20
+ }
21
+ exports.lookupClients = lookupClients;
22
+ /**
23
+ * Find the best matching client and determine action to take
24
+ */
25
+ function findMatchingClientAndDetermineAction(clientName, clientAddressParts, allClients, isBusiness, kind, existingContact) {
26
+ // Find the best matching client
27
+ const matchResult = (0, clientMatcher_1.findBestMatchingClient)(clientName, clientAddressParts, allClients, isBusiness);
28
+ // Determine what action to take
29
+ const actionResult = (0, clientMatcher_1.determineAction)({
30
+ contactExists: existingContact !== null,
31
+ existingContactClientUuid: (existingContact === null || existingContact === void 0 ? void 0 : existingContact.company_uuid) || null,
32
+ matchedClient: matchResult.client,
33
+ matchType: matchResult.matchType,
34
+ matchReason: matchResult.reason,
35
+ isBusiness,
36
+ kind,
37
+ });
38
+ return {
39
+ ...actionResult,
40
+ matchType: matchResult.matchType,
41
+ matchReason: matchResult.reason,
42
+ clientsChecked: allClients.length,
43
+ };
44
+ }
45
+ exports.findMatchingClientAndDetermineAction = findMatchingClientAndDetermineAction;
46
+ //# sourceMappingURL=clientLookup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientLookup.js","sourceRoot":"","sources":["../../../../../nodes/ServiceM8JobCreation/operations/create/clientLookup.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,2CAAyE;AACzE,+DAIqC;AAiBrC;;GAEG;AACI,KAAK,UAAU,aAAa,CAClC,OAA0B,EAC1B,YAAoB;IAEpB,MAAM,eAAe,GAAG,MAAM,IAAA,sBAAgB,EAAC,OAAO,EAAE;QACvD,MAAM,EAAE,KAAK;QACb,QAAQ,EAAE,uBAAuB;QACjC,KAAK,EAAE,EAAE,OAAO,EAAE,oCAAoC,YAAY,EAAE,EAAE;KACtE,CAAC,CAAC;IAEH,OAAO,IAAA,wBAAkB,EAAkB,eAAe,CAAC,CAAC;AAC7D,CAAC;AAXD,sCAWC;AAED;;GAEG;AACH,SAAgB,oCAAoC,CACnD,UAAkB,EAClB,kBAAgC,EAChC,UAA6B,EAC7B,UAAmB,EACnB,IAA2B,EAC3B,eAAwC;IAExC,gCAAgC;IAChC,MAAM,WAAW,GAAG,IAAA,sCAAsB,EACzC,UAAU,EACV,kBAAkB,EAClB,UAAU,EACV,UAAU,CACV,CAAC;IAEF,gCAAgC;IAChC,MAAM,YAAY,GAAG,IAAA,+BAAe,EAAC;QACpC,aAAa,EAAE,eAAe,KAAK,IAAI;QACvC,yBAAyB,EAAE,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,YAAY,KAAI,IAAI;QAChE,aAAa,EAAE,WAAW,CAAC,MAAM;QACjC,SAAS,EAAE,WAAW,CAAC,SAAS;QAChC,WAAW,EAAE,WAAW,CAAC,MAAM;QAC/B,UAAU;QACV,IAAI;KACJ,CAAC,CAAC;IAEH,OAAO;QACN,GAAG,YAAY;QACf,SAAS,EAAE,WAAW,CAAC,SAAS;QAChC,WAAW,EAAE,WAAW,CAAC,MAAM;QAC/B,cAAc,EAAE,UAAU,CAAC,MAAM;KACjC,CAAC;AACH,CAAC;AAjCD,oFAiCC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Contact Lookup Operations
3
+ * Find existing contact by email/mobile/phone
4
+ */
5
+ import type { IExecuteFunctions } from 'n8n-workflow';
6
+ import type { ServiceM8Contact } from '../../types';
7
+ export interface ContactLookupResult {
8
+ existingContact: ServiceM8Contact | null;
9
+ foundByField: 'email' | 'mobile' | 'phone' | null;
10
+ }
11
+ /**
12
+ * Look up an existing contact by email, mobile, or phone
13
+ */
14
+ export declare function lookupContact(context: IExecuteFunctions, contactLookupFilter: string | null, contactLookupField: 'email' | 'mobile' | 'phone' | null): Promise<ContactLookupResult>;
15
+ /**
16
+ * Check if a contact already exists on a specific client
17
+ */
18
+ export declare function checkContactExistsOnClient(context: IExecuteFunctions, clientUuid: string, contactLookupField: 'email' | 'mobile' | 'phone' | null, identifier: string): Promise<boolean>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ /**
3
+ * Contact Lookup Operations
4
+ * Find existing contact by email/mobile/phone
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.checkContactExistsOnClient = exports.lookupContact = void 0;
8
+ const api_1 = require("../../helpers/api");
9
+ /**
10
+ * Look up an existing contact by email, mobile, or phone
11
+ */
12
+ async function lookupContact(context, contactLookupFilter, contactLookupField) {
13
+ if (!contactLookupFilter) {
14
+ return {
15
+ existingContact: null,
16
+ foundByField: null,
17
+ };
18
+ }
19
+ const contactResponse = await (0, api_1.serviceM8Request)(context, {
20
+ method: 'GET',
21
+ endpoint: '/api_1.0/companycontact.json',
22
+ query: { $filter: contactLookupFilter },
23
+ });
24
+ const contacts = (0, api_1.parseArrayResponse)(contactResponse);
25
+ return {
26
+ existingContact: contacts.length > 0 ? contacts[0] : null,
27
+ foundByField: contacts.length > 0 ? contactLookupField : null,
28
+ };
29
+ }
30
+ exports.lookupContact = lookupContact;
31
+ /**
32
+ * Check if a contact already exists on a specific client
33
+ */
34
+ async function checkContactExistsOnClient(context, clientUuid, contactLookupField, identifier) {
35
+ if (!contactLookupField || !identifier) {
36
+ return false;
37
+ }
38
+ const dupeFilter = `active eq 1 and company_uuid eq '${clientUuid}' and ${contactLookupField} eq '${(0, api_1.escapeOData)(identifier)}'`;
39
+ const dupeResponse = await (0, api_1.serviceM8Request)(context, {
40
+ method: 'GET',
41
+ endpoint: '/api_1.0/companycontact.json',
42
+ query: { $filter: dupeFilter },
43
+ });
44
+ const dupeContacts = (0, api_1.parseArrayResponse)(dupeResponse);
45
+ return dupeContacts.length > 0;
46
+ }
47
+ exports.checkContactExistsOnClient = checkContactExistsOnClient;
48
+ //# sourceMappingURL=contactLookup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contactLookup.js","sourceRoot":"","sources":["../../../../../nodes/ServiceM8JobCreation/operations/create/contactLookup.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,2CAAsF;AAOtF;;GAEG;AACI,KAAK,UAAU,aAAa,CAClC,OAA0B,EAC1B,mBAAkC,EAClC,kBAAuD;IAEvD,IAAI,CAAC,mBAAmB,EAAE;QACzB,OAAO;YACN,eAAe,EAAE,IAAI;YACrB,YAAY,EAAE,IAAI;SAClB,CAAC;KACF;IAED,MAAM,eAAe,GAAG,MAAM,IAAA,sBAAgB,EAAC,OAAO,EAAE;QACvD,MAAM,EAAE,KAAK;QACb,QAAQ,EAAE,8BAA8B;QACxC,KAAK,EAAE,EAAE,OAAO,EAAE,mBAAmB,EAAE;KACvC,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,IAAA,wBAAkB,EAAmB,eAAe,CAAC,CAAC;IAEvE,OAAO;QACN,eAAe,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI;QACzD,YAAY,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI;KAC7D,CAAC;AACH,CAAC;AAxBD,sCAwBC;AAED;;GAEG;AACI,KAAK,UAAU,0BAA0B,CAC/C,OAA0B,EAC1B,UAAkB,EAClB,kBAAuD,EACvD,UAAkB;IAElB,IAAI,CAAC,kBAAkB,IAAI,CAAC,UAAU,EAAE;QACvC,OAAO,KAAK,CAAC;KACb;IAED,MAAM,UAAU,GAAG,oCAAoC,UAAU,SAAS,kBAAkB,QAAQ,IAAA,iBAAW,EAAC,UAAU,CAAC,GAAG,CAAC;IAE/H,MAAM,YAAY,GAAG,MAAM,IAAA,sBAAgB,EAAC,OAAO,EAAE;QACpD,MAAM,EAAE,KAAK;QACb,QAAQ,EAAE,8BAA8B;QACxC,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE;KAC9B,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,IAAA,wBAAkB,EAAmB,YAAY,CAAC,CAAC;IACxE,OAAO,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;AAChC,CAAC;AApBD,gEAoBC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Create Job Operations Index
3
+ */
4
+ export { executeJobCreation } from './orchestrator';
5
+ export { processInput, type ProcessedInput, type AttachmentMode, type AttachmentInputParams, } from './inputProcessor';
6
+ export { lookupContact, checkContactExistsOnClient, type ContactLookupResult, } from './contactLookup';
7
+ export { lookupClients, findMatchingClientAndDetermineAction, type ClientLookupResult, type ActionResult, } from './clientLookup';
8
+ export { createClientIfNeeded, createCompanyContactIfNeeded, type ClientCreateInput, type ContactCreateInput, type ClientCreateResult, type ContactCreateResult, } from './clientCreate';
9
+ export { createNewJob, createNewJobContact, cleanupEmptyJobContacts, createJobWithContact, type JobCreateInput, type JobContactInput, type JobCreateResult, } from './jobCreate';
10
+ export { assignCategory, type CategoryAssignInput, type CategoryAssignResult, } from './categoryAssign';
11
+ export { assignQueue, type QueueAssignInput, type QueueAssignResult, } from './queueAssign';
12
+ export { sendNotifications, type NotificationRecipient, type NotificationsInput, type NotificationsResult, } from './notifications';
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /**
3
+ * Create Job Operations Index
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.sendNotifications = exports.assignQueue = exports.assignCategory = exports.createJobWithContact = exports.cleanupEmptyJobContacts = exports.createNewJobContact = exports.createNewJob = exports.createCompanyContactIfNeeded = exports.createClientIfNeeded = exports.findMatchingClientAndDetermineAction = exports.lookupClients = exports.checkContactExistsOnClient = exports.lookupContact = exports.processInput = exports.executeJobCreation = void 0;
7
+ // Orchestrator (main entry point)
8
+ var orchestrator_1 = require("./orchestrator");
9
+ Object.defineProperty(exports, "executeJobCreation", { enumerable: true, get: function () { return orchestrator_1.executeJobCreation; } });
10
+ // Input processing
11
+ var inputProcessor_1 = require("./inputProcessor");
12
+ Object.defineProperty(exports, "processInput", { enumerable: true, get: function () { return inputProcessor_1.processInput; } });
13
+ // Contact operations
14
+ var contactLookup_1 = require("./contactLookup");
15
+ Object.defineProperty(exports, "lookupContact", { enumerable: true, get: function () { return contactLookup_1.lookupContact; } });
16
+ Object.defineProperty(exports, "checkContactExistsOnClient", { enumerable: true, get: function () { return contactLookup_1.checkContactExistsOnClient; } });
17
+ // Client operations
18
+ var clientLookup_1 = require("./clientLookup");
19
+ Object.defineProperty(exports, "lookupClients", { enumerable: true, get: function () { return clientLookup_1.lookupClients; } });
20
+ Object.defineProperty(exports, "findMatchingClientAndDetermineAction", { enumerable: true, get: function () { return clientLookup_1.findMatchingClientAndDetermineAction; } });
21
+ // Client/Contact creation
22
+ var clientCreate_1 = require("./clientCreate");
23
+ Object.defineProperty(exports, "createClientIfNeeded", { enumerable: true, get: function () { return clientCreate_1.createClientIfNeeded; } });
24
+ Object.defineProperty(exports, "createCompanyContactIfNeeded", { enumerable: true, get: function () { return clientCreate_1.createCompanyContactIfNeeded; } });
25
+ // Job creation
26
+ var jobCreate_1 = require("./jobCreate");
27
+ Object.defineProperty(exports, "createNewJob", { enumerable: true, get: function () { return jobCreate_1.createNewJob; } });
28
+ Object.defineProperty(exports, "createNewJobContact", { enumerable: true, get: function () { return jobCreate_1.createNewJobContact; } });
29
+ Object.defineProperty(exports, "cleanupEmptyJobContacts", { enumerable: true, get: function () { return jobCreate_1.cleanupEmptyJobContacts; } });
30
+ Object.defineProperty(exports, "createJobWithContact", { enumerable: true, get: function () { return jobCreate_1.createJobWithContact; } });
31
+ // Category assignment
32
+ var categoryAssign_1 = require("./categoryAssign");
33
+ Object.defineProperty(exports, "assignCategory", { enumerable: true, get: function () { return categoryAssign_1.assignCategory; } });
34
+ // Queue assignment
35
+ var queueAssign_1 = require("./queueAssign");
36
+ Object.defineProperty(exports, "assignQueue", { enumerable: true, get: function () { return queueAssign_1.assignQueue; } });
37
+ // Notifications
38
+ var notifications_1 = require("./notifications");
39
+ Object.defineProperty(exports, "sendNotifications", { enumerable: true, get: function () { return notifications_1.sendNotifications; } });
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../nodes/ServiceM8JobCreation/operations/create/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,kCAAkC;AAClC,+CAAoD;AAA3C,kHAAA,kBAAkB,OAAA;AAE3B,mBAAmB;AACnB,mDAK0B;AAJzB,8GAAA,YAAY,OAAA;AAMb,qBAAqB;AACrB,iDAIyB;AAHxB,8GAAA,aAAa,OAAA;AACb,2HAAA,0BAA0B,OAAA;AAI3B,oBAAoB;AACpB,+CAKwB;AAJvB,6GAAA,aAAa,OAAA;AACb,oIAAA,oCAAoC,OAAA;AAKrC,0BAA0B;AAC1B,+CAOwB;AANvB,oHAAA,oBAAoB,OAAA;AACpB,4HAAA,4BAA4B,OAAA;AAO7B,eAAe;AACf,yCAQqB;AAPpB,yGAAA,YAAY,OAAA;AACZ,gHAAA,mBAAmB,OAAA;AACnB,oHAAA,uBAAuB,OAAA;AACvB,iHAAA,oBAAoB,OAAA;AAMrB,sBAAsB;AACtB,mDAI0B;AAHzB,gHAAA,cAAc,OAAA;AAKf,mBAAmB;AACnB,6CAIuB;AAHtB,0GAAA,WAAW,OAAA;AAKZ,gBAAgB;AAChB,iDAKyB;AAJxB,kHAAA,iBAAiB,OAAA"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Input Processing Operations
3
+ * Extracts and normalizes input parameters, classifies business/person
4
+ */
5
+ import type { IExecuteFunctions } from 'n8n-workflow';
6
+ import type { AddressParts } from '../../types';
7
+ import { type NameFormat } from '../../helpers/clientMatcher';
8
+ export type AttachmentMode = 'allBinary' | 'urlList' | 'manual';
9
+ export interface AttachmentInputParams {
10
+ sourceType: 'binary' | 'url';
11
+ binaryPropertyName?: string;
12
+ fileUrl?: string;
13
+ fileName?: string;
14
+ fileType?: string;
15
+ }
16
+ export interface ProcessedInput {
17
+ firstName: string;
18
+ lastName: string;
19
+ email: string;
20
+ phone: string | null;
21
+ mobile: string | null;
22
+ businessName: string;
23
+ clientName: string;
24
+ isBusiness: boolean;
25
+ kind: 'business' | 'person';
26
+ isIndividual: number;
27
+ clientAddressParts: AddressParts;
28
+ clientAddress: string;
29
+ jobAddressParts: AddressParts;
30
+ jobAddress: string;
31
+ jobDetails: string;
32
+ jobStatus: string;
33
+ contactLookupField: 'email' | 'mobile' | 'phone' | null;
34
+ contactLookupFilter: string | null;
35
+ enableCategory: boolean;
36
+ categoryDynamic: boolean;
37
+ categoryUuidInput: string;
38
+ categoryNameInput: string;
39
+ enableBadges: boolean;
40
+ badgesDynamic: boolean;
41
+ badgeUuidsInput: string[];
42
+ badgeNamesInput: string;
43
+ enableQueue: boolean;
44
+ queueDynamic: boolean;
45
+ queueUuidInput: string;
46
+ queueNameInput: string;
47
+ enableNotifications: boolean;
48
+ notificationRecipientsInput: any;
49
+ enableAttachments: boolean;
50
+ attachmentMode: AttachmentMode;
51
+ attachmentUrlList: string;
52
+ attachmentsInput: {
53
+ attachment?: AttachmentInputParams[];
54
+ };
55
+ enableCustomNote: boolean;
56
+ customNoteContent: string;
57
+ nameFormat: NameFormat;
58
+ returnHeaders: boolean;
59
+ }
60
+ /**
61
+ * Extract and process all input parameters for a single item
62
+ */
63
+ export declare function processInput(context: IExecuteFunctions, itemIndex: number): ProcessedInput;
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ /**
3
+ * Input Processing Operations
4
+ * Extracts and normalizes input parameters, classifies business/person
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.processInput = void 0;
8
+ const phoneUtils_1 = require("../../helpers/phoneUtils");
9
+ const addressUtils_1 = require("../../helpers/addressUtils");
10
+ const clientMatcher_1 = require("../../helpers/clientMatcher");
11
+ const api_1 = require("../../helpers/api");
12
+ /**
13
+ * Extract and process all input parameters for a single item
14
+ */
15
+ function processInput(context, itemIndex) {
16
+ var _a, _b;
17
+ // ========== EXTRACT BASIC PARAMETERS ==========
18
+ const firstName = context.getNodeParameter('firstName', itemIndex, '');
19
+ const lastName = context.getNodeParameter('lastName', itemIndex, '');
20
+ const email = context.getNodeParameter('email', itemIndex, '').trim().toLowerCase();
21
+ const inputPhone = context.getNodeParameter('phone', itemIndex, '');
22
+ const inputMobile = context.getNodeParameter('mobile', itemIndex, '');
23
+ const businessName = context.getNodeParameter('businessName', itemIndex, '');
24
+ const clientAddressInput = context.getNodeParameter('clientAddress', itemIndex, {});
25
+ const jobAddressSameAsClient = context.getNodeParameter('jobAddressSameAsClient', itemIndex, true);
26
+ const jobAddressInput = context.getNodeParameter('jobAddress', itemIndex, {});
27
+ const jobDetails = context.getNodeParameter('jobDetails', itemIndex, '');
28
+ const jobStatus = context.getNodeParameter('jobStatus', itemIndex, 'Quote');
29
+ // ========== OPTIONAL FEATURES ==========
30
+ const enableCategory = context.getNodeParameter('enableCategory', itemIndex, false);
31
+ const categoryDynamic = enableCategory
32
+ ? context.getNodeParameter('categoryDynamic', itemIndex, false)
33
+ : false;
34
+ const categoryUuidInput = enableCategory && !categoryDynamic
35
+ ? context.getNodeParameter('category', itemIndex, '')
36
+ : '';
37
+ const categoryNameInput = enableCategory && categoryDynamic
38
+ ? context.getNodeParameter('categoryName', itemIndex, '')
39
+ : '';
40
+ const enableBadges = context.getNodeParameter('enableBadges', itemIndex, false);
41
+ const badgesDynamic = enableBadges
42
+ ? context.getNodeParameter('badgesDynamic', itemIndex, false)
43
+ : false;
44
+ const badgeUuidsInput = enableBadges && !badgesDynamic
45
+ ? context.getNodeParameter('badges', itemIndex, [])
46
+ : [];
47
+ const badgeNamesInput = enableBadges && badgesDynamic
48
+ ? context.getNodeParameter('badgeNames', itemIndex, '')
49
+ : '';
50
+ const enableQueue = context.getNodeParameter('enableQueue', itemIndex, false);
51
+ const queueDynamic = enableQueue
52
+ ? context.getNodeParameter('queueDynamic', itemIndex, false)
53
+ : false;
54
+ const queueUuidInput = enableQueue && !queueDynamic
55
+ ? context.getNodeParameter('queue', itemIndex, '')
56
+ : '';
57
+ const queueNameInput = enableQueue && queueDynamic
58
+ ? context.getNodeParameter('queueName', itemIndex, '')
59
+ : '';
60
+ const enableNotifications = context.getNodeParameter('enableNotifications', itemIndex, false);
61
+ const notificationRecipientsInput = context.getNodeParameter('notificationRecipients', itemIndex, {});
62
+ const enableAttachments = context.getNodeParameter('enableAttachments', itemIndex, false);
63
+ const attachmentMode = enableAttachments
64
+ ? context.getNodeParameter('attachmentMode', itemIndex, 'allBinary')
65
+ : 'allBinary';
66
+ const attachmentUrlList = enableAttachments && attachmentMode === 'urlList'
67
+ ? context.getNodeParameter('attachmentUrlList', itemIndex, '')
68
+ : '';
69
+ const attachmentsInput = enableAttachments && attachmentMode === 'manual'
70
+ ? context.getNodeParameter('attachments', itemIndex, {})
71
+ : {};
72
+ const enableCustomNote = context.getNodeParameter('enableCustomNote', itemIndex, false);
73
+ const customNoteContent = enableCustomNote
74
+ ? context.getNodeParameter('customNoteContent', itemIndex, '')
75
+ : '';
76
+ // ========== ADDITIONAL OPTIONS ==========
77
+ const additionalOptions = context.getNodeParameter('additionalOptions', itemIndex, {});
78
+ const nameFormat = (_a = additionalOptions.nameFormat) !== null && _a !== void 0 ? _a : 'firstLast';
79
+ const returnHeaders = (_b = additionalOptions.returnHeaders) !== null && _b !== void 0 ? _b : false;
80
+ // ========== VALIDATE REQUIRED FIELDS ==========
81
+ // First name is required (unless business name is provided)
82
+ const trimmedFirstName = firstName.trim();
83
+ const trimmedBusinessName = businessName.trim();
84
+ if (!trimmedFirstName && !trimmedBusinessName) {
85
+ throw new Error('First Name is required (or provide a Business Name for business clients)');
86
+ }
87
+ // At least one contact method is required for deduplication
88
+ const hasContactMethod = email.trim() || inputPhone.trim() || inputMobile.trim();
89
+ if (!hasContactMethod) {
90
+ throw new Error('At least one contact method is required (Email, Phone, or Mobile) for contact deduplication');
91
+ }
92
+ // ========== NORMALIZE PHONES ==========
93
+ const { mobile, phone } = (0, phoneUtils_1.derivePhones)(inputPhone, inputMobile);
94
+ // ========== PROCESS ADDRESSES ==========
95
+ const clientAddressParts = (0, addressUtils_1.parseAddressFromInput)(clientAddressInput);
96
+ const clientAddress = (0, addressUtils_1.buildAddressString)(clientAddressParts);
97
+ let jobAddressParts = clientAddressParts;
98
+ let jobAddress = clientAddress;
99
+ if (!jobAddressSameAsClient) {
100
+ jobAddressParts = (0, addressUtils_1.parseAddressFromInput)(jobAddressInput);
101
+ if ((0, addressUtils_1.hasAddressContent)(jobAddressParts)) {
102
+ jobAddress = (0, addressUtils_1.buildAddressString)(jobAddressParts);
103
+ }
104
+ }
105
+ // ========== CLASSIFY BUSINESS/PERSON ==========
106
+ const { name: clientName, isBusiness } = (0, clientMatcher_1.buildClientName)(firstName, lastName, businessName, email, nameFormat);
107
+ const kind = isBusiness ? 'business' : 'person';
108
+ const isIndividual = isBusiness ? 0 : 1;
109
+ // ========== DETERMINE CONTACT LOOKUP ==========
110
+ let contactLookupField = null;
111
+ let contactLookupFilter = null;
112
+ if (email) {
113
+ contactLookupField = 'email';
114
+ contactLookupFilter = `active eq 1 and email eq '${(0, api_1.escapeOData)(email)}'`;
115
+ }
116
+ else if (mobile) {
117
+ contactLookupField = 'mobile';
118
+ contactLookupFilter = `active eq 1 and mobile eq '${(0, api_1.escapeOData)(mobile)}'`;
119
+ }
120
+ else if (phone) {
121
+ contactLookupField = 'phone';
122
+ contactLookupFilter = `active eq 1 and phone eq '${(0, api_1.escapeOData)(phone)}'`;
123
+ }
124
+ return {
125
+ // Contact info
126
+ firstName,
127
+ lastName,
128
+ email,
129
+ phone,
130
+ mobile,
131
+ // Business info
132
+ businessName,
133
+ // Classification
134
+ clientName,
135
+ isBusiness,
136
+ kind,
137
+ isIndividual,
138
+ // Addresses
139
+ clientAddressParts,
140
+ clientAddress,
141
+ jobAddressParts,
142
+ jobAddress,
143
+ // Job info
144
+ jobDetails,
145
+ jobStatus,
146
+ // Contact lookup
147
+ contactLookupField,
148
+ contactLookupFilter,
149
+ // Optional features
150
+ enableCategory,
151
+ categoryDynamic,
152
+ categoryUuidInput,
153
+ categoryNameInput,
154
+ enableBadges,
155
+ badgesDynamic,
156
+ badgeUuidsInput,
157
+ badgeNamesInput,
158
+ enableQueue,
159
+ queueDynamic,
160
+ queueUuidInput,
161
+ queueNameInput,
162
+ enableNotifications,
163
+ notificationRecipientsInput,
164
+ enableAttachments,
165
+ attachmentMode,
166
+ attachmentUrlList,
167
+ attachmentsInput,
168
+ enableCustomNote,
169
+ customNoteContent,
170
+ // Additional options
171
+ nameFormat,
172
+ returnHeaders,
173
+ };
174
+ }
175
+ exports.processInput = processInput;
176
+ //# sourceMappingURL=inputProcessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputProcessor.js","sourceRoot":"","sources":["../../../../../nodes/ServiceM8JobCreation/operations/create/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;QAEZ,iBAAiB;QACjB,UAAU;QACV,UAAU;QACV,IAAI;QACJ,YAAY;QAEZ,YAAY;QACZ,kBAAkB;QAClB,aAAa;QACb,eAAe;QACf,UAAU;QAEV,WAAW;QACX,UAAU;QACV,SAAS;QAET,iBAAiB;QACjB,kBAAkB;QAClB,mBAAmB;QAEnB,oBAAoB;QACpB,cAAc;QACd,eAAe;QACf,iBAAiB;QACjB,iBAAiB;QAEjB,YAAY;QACZ,aAAa;QACb,eAAe;QACf,eAAe;QAEf,WAAW;QACX,YAAY;QACZ,cAAc;QACd,cAAc;QAEd,mBAAmB;QACnB,2BAA2B;QAE3B,iBAAiB;QACjB,cAAc;QACd,iBAAiB;QACjB,gBAAgB;QAEhB,gBAAgB;QAChB,iBAAiB;QAEjB,qBAAqB;QACrB,UAAU;QACV,aAAa;KACb,CAAC;AACH,CAAC;AArMD,oCAqMC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Job Creation Operations
3
+ * Create job and job contact, clean up empty contacts
4
+ */
5
+ import type { IExecuteFunctions } from 'n8n-workflow';
6
+ export interface JobCreateInput {
7
+ clientUuid: string;
8
+ jobStatus: string;
9
+ jobAddress: string;
10
+ clientAddress: string;
11
+ jobDetails: string;
12
+ }
13
+ export interface JobContactInput {
14
+ jobUuid: string;
15
+ firstName: string;
16
+ lastName: string;
17
+ email?: string;
18
+ phone?: string | null;
19
+ mobile?: string | null;
20
+ }
21
+ export interface JobCreateResult {
22
+ jobUuid: string;
23
+ }
24
+ /**
25
+ * Create a new job
26
+ */
27
+ export declare function createNewJob(context: IExecuteFunctions, input: JobCreateInput): Promise<JobCreateResult>;
28
+ /**
29
+ * Create a job contact
30
+ */
31
+ export declare function createNewJobContact(context: IExecuteFunctions, input: JobContactInput): Promise<string>;
32
+ /**
33
+ * Clean up empty auto-created job contacts
34
+ * ServiceM8 sometimes auto-creates empty contacts when creating a job
35
+ */
36
+ export declare function cleanupEmptyJobContacts(context: IExecuteFunctions, jobUuid: string): Promise<number>;
37
+ /**
38
+ * Create a complete job with contact and cleanup
39
+ */
40
+ export declare function createJobWithContact(context: IExecuteFunctions, jobInput: JobCreateInput, contactInput: Omit<JobContactInput, 'jobUuid'>): Promise<{
41
+ jobUuid: string;
42
+ jobContactUuid: string;
43
+ }>;