@mspcopilot/n8n-nodes-connectwise 0.2.4-beta.1 → 0.3.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 (55) hide show
  1. package/{dist-beta → dist-community}/credentials/ConnectWisePsaApi.credentials.js +3 -17
  2. package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/ConnectWisePsa.node.js +2 -14
  3. package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/ConnectWisePsaTrigger.node.js +3 -3
  4. package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/descriptions/common.properties.js +1 -16
  5. package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/helpers/field-collector.js +10 -1
  6. package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/helpers/hint-collector.js +1 -1
  7. package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/methods/fieldOptions.js +0 -1
  8. package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/schema/resources/alert-consolidation.js +1 -3
  9. package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/schema/resources/custom.schema.js +1 -38
  10. package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/schema/resources/ticket.schema.js +1 -11
  11. package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/schema/resources/timeEntry.schema.js +7 -0
  12. package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/transport/cache.js +6 -84
  13. package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/transport/client.js +5 -46
  14. package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/transport/version-check.js +13 -9
  15. package/package.json +5 -6
  16. package/dist-beta/nodes/ConnectWise/PSA/IfSchedule.node.js +0 -333
  17. package/dist-beta/nodes/ConnectWise/PSA/schema/resources/diagnostics.schema.js +0 -103
  18. package/dist-beta/nodes/ConnectWise/PSA/schema/resources/reports.schema.js +0 -216
  19. /package/{dist-beta → dist-community}/LICENSE.md +0 -0
  20. /package/{dist-beta → dist-community}/credentials/connectwise-dark.svg +0 -0
  21. /package/{dist-beta → dist-community}/credentials/connectwise-light.svg +0 -0
  22. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/connectwise-dark.svg +0 -0
  23. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/connectwise-light.svg +0 -0
  24. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/descriptions/common.descriptions.js +0 -0
  25. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/descriptions/index.js +0 -0
  26. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/helpers/customFields.js +0 -0
  27. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/helpers/field-conditions.js +0 -0
  28. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/helpers/index.js +0 -0
  29. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/helpers/logging.js +0 -0
  30. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/helpers/utils.js +0 -0
  31. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/methods/generated.js +0 -0
  32. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/methods/index.js +0 -0
  33. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/schema/converter/index.js +0 -0
  34. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/schema/converter/reference.generator.js +0 -0
  35. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/schema/index.js +0 -0
  36. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/schema/references.js +0 -0
  37. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/schema/reports-descriptions.js +0 -0
  38. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/schema/resources/activity.schema.js +0 -0
  39. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/schema/resources/company.schema.js +0 -0
  40. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/schema/resources/contact.schema.js +0 -0
  41. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/schema/resources/index.js +0 -0
  42. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/schema/resources/members.schema.js +0 -0
  43. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/schema/resources/ticketNote.schema.js +0 -0
  44. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/schema/resources/ticketTask.schema.js +0 -0
  45. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/schema/static-fields.js +0 -0
  46. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/schema/transformer.js +0 -0
  47. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/schema/types/index.js +0 -0
  48. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/schema/types/reference.types.js +0 -0
  49. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/schema/types/resource.types.js +0 -0
  50. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/transport/access-key.js +0 -0
  51. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/transport/index.js +0 -0
  52. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/transport/operations.js +0 -0
  53. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/transport/response-transformer.js +0 -0
  54. /package/{dist-beta → dist-community}/nodes/ConnectWise/PSA/types/n8n-augmentation.d.js +0 -0
  55. /package/{dist-beta → dist-community}/nodes/ConnectWisePsa.node.json +0 -0
@@ -1,333 +0,0 @@
1
- var __create = Object.create;
2
-
3
- var __defProp = Object.defineProperty;
4
-
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
-
7
- var __getOwnPropNames = Object.getOwnPropertyNames;
8
-
9
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
10
-
11
- var __export = (target, all) => {
12
- for (var name in all) __defProp(target, name, {
13
- get: all[name],
14
- enumerable: !0
15
- });
16
- }, __copyProps = (to, from, except, desc) => {
17
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
18
- get: () => from[key],
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
- });
21
- return to;
22
- };
23
-
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {},
25
- __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)), __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
29
- value: !0
30
- }), mod);
31
-
32
- var IfSchedule_node_exports = {};
33
-
34
- __export(IfSchedule_node_exports, {
35
- IfSchedule: () => IfSchedule
36
- });
37
-
38
- module.exports = __toCommonJS(IfSchedule_node_exports);
39
-
40
- var import_luxon = require("luxon"), import_client = require("./transport/client"), import_methods = require("./methods"), import_utils = require("./helpers/utils");
41
-
42
- const WINDOWS_TO_IANA_TIMEZONE = {
43
- "Morocco Standard Time": "Africa/Casablanca",
44
- "W. Central Africa Standard Time": "Africa/Lagos",
45
- "South Africa Standard Time": "Africa/Johannesburg",
46
- "Namibia Standard Time": "Africa/Windhoek",
47
- "Egypt Standard Time": "Africa/Cairo",
48
- "E. Africa Standard Time": "Africa/Nairobi",
49
- "Alaskan Standard Time": "America/Anchorage",
50
- "Hawaiian Standard Time": "Pacific/Honolulu",
51
- "Pacific Standard Time": "America/Los_Angeles",
52
- "Pacific Standard Time (Mexico)": "America/Tijuana",
53
- "US Mountain Standard Time": "America/Phoenix",
54
- "Mountain Standard Time": "America/Denver",
55
- "Mountain Standard Time (Mexico)": "America/Chihuahua",
56
- "Central Standard Time": "America/Chicago",
57
- "Central Standard Time (Mexico)": "America/Mexico_City",
58
- "Canada Central Standard Time": "America/Regina",
59
- "Central America Standard Time": "America/Guatemala",
60
- "Eastern Standard Time": "America/New_York",
61
- "US Eastern Standard Time": "America/Indianapolis",
62
- "Atlantic Standard Time": "America/Halifax",
63
- "Newfoundland Standard Time": "America/St_Johns",
64
- "SA Pacific Standard Time": "America/Bogota",
65
- "Venezuela Standard Time": "America/Caracas",
66
- "SA Western Standard Time": "America/La_Paz",
67
- "Pacific SA Standard Time": "America/Santiago",
68
- "E. South America Standard Time": "America/Sao_Paulo",
69
- "Central Brazilian Standard Time": "America/Cuiaba",
70
- "Argentina Standard Time": "America/Buenos_Aires",
71
- "SA Eastern Standard Time": "America/Cayenne",
72
- "Montevideo Standard Time": "America/Montevideo",
73
- "Azores Standard Time": "Atlantic/Azores",
74
- "Cape Verde Standard Time": "Atlantic/Cape_Verde",
75
- "Mid-Atlantic Standard Time": "Atlantic/South_Georgia",
76
- "Greenland Standard Time": "America/Godthab",
77
- "Jordan Standard Time": "Asia/Amman",
78
- "Middle East Standard Time": "Asia/Beirut",
79
- "Israel Standard Time": "Asia/Jerusalem",
80
- "Arabic Standard Time": "Asia/Baghdad",
81
- "Arab Standard Time": "Asia/Riyadh",
82
- "Arabian Standard Time": "Asia/Dubai",
83
- "Iran Standard Time": "Asia/Tehran",
84
- "Afghanistan Standard Time": "Asia/Kabul",
85
- "Georgian Standard Time": "Asia/Tbilisi",
86
- "Caucasus Standard Time": "Asia/Yerevan",
87
- "Azerbaijan Standard Time": "Asia/Baku",
88
- "West Asia Standard Time": "Asia/Tashkent",
89
- "Pakistan Standard Time": "Asia/Karachi",
90
- "India Standard Time": "Asia/Kolkata",
91
- "Sri Lanka Standard Time": "Asia/Colombo",
92
- "Nepal Standard Time": "Asia/Kathmandu",
93
- "Central Asia Standard Time": "Asia/Almaty",
94
- "Myanmar Standard Time": "Asia/Yangon",
95
- "SE Asia Standard Time": "Asia/Bangkok",
96
- "China Standard Time": "Asia/Shanghai",
97
- "Singapore Standard Time": "Asia/Singapore",
98
- "Taipei Standard Time": "Asia/Taipei",
99
- "Tokyo Standard Time": "Asia/Tokyo",
100
- "Korea Standard Time": "Asia/Seoul",
101
- "Russian Standard Time": "Europe/Moscow",
102
- "Ekaterinburg Standard Time": "Asia/Yekaterinburg",
103
- "N. Central Asia Standard Time": "Asia/Novosibirsk",
104
- "North Asia Standard Time": "Asia/Krasnoyarsk",
105
- "North Asia East Standard Time": "Asia/Irkutsk",
106
- "Yakutsk Standard Time": "Asia/Yakutsk",
107
- "Vladivostok Standard Time": "Asia/Vladivostok",
108
- "W. Australia Standard Time": "Australia/Perth",
109
- "AUS Central Standard Time": "Australia/Darwin",
110
- "Cen. Australia Standard Time": "Australia/Adelaide",
111
- "E. Australia Standard Time": "Australia/Brisbane",
112
- "AUS Eastern Standard Time": "Australia/Sydney",
113
- "Tasmania Standard Time": "Australia/Hobart",
114
- "West Pacific Standard Time": "Pacific/Port_Moresby",
115
- "Central Pacific Standard Time": "Pacific/Guadalcanal",
116
- "Fiji Standard Time": "Pacific/Fiji",
117
- "New Zealand Standard Time": "Pacific/Auckland",
118
- "Tonga Standard Time": "Pacific/Tongatapu",
119
- "GMT Standard Time": "Europe/London",
120
- "Greenwich Standard Time": "Atlantic/Reykjavik",
121
- "W. Europe Standard Time": "Europe/Berlin",
122
- "Central Europe Standard Time": "Europe/Budapest",
123
- "Romance Standard Time": "Europe/Paris",
124
- "Central European Standard Time": "Europe/Warsaw",
125
- "GTB Standard Time": "Europe/Bucharest",
126
- "E. Europe Standard Time": "Europe/Minsk",
127
- "FLE Standard Time": "Europe/Kiev",
128
- "UTC-11": "Pacific/Midway",
129
- "Dateline Standard Time": "Etc/GMT+12",
130
- "Mauritius Standard Time": "Indian/Mauritius"
131
- };
132
-
133
- class IfSchedule {
134
- description={
135
- hidden: process.env.MSPCOPILOT_BETA !== "true",
136
- displayName: "If ConnectWise Schedule ✨",
137
- name: "ifConnectWiseSchedule",
138
- icon: {
139
- light: "file:connectwise-light.svg",
140
- dark: "file:connectwise-dark.svg"
141
- },
142
- group: [ "transform" ],
143
- version: 1,
144
- description: "Check if timestamp is during business hours or is a workday based on calendar and holidays",
145
- defaults: {
146
- name: "If Business Hours"
147
- },
148
- inputs: [ "main" ],
149
- outputs: [ "main", "main" ],
150
- outputNames: [ "true", "false" ],
151
- credentials: [ {
152
- name: "connectWisePsaApi",
153
- required: !0
154
- } ],
155
- properties: [ {
156
- displayName: "Calendar Name or ID",
157
- name: "calendarId",
158
- type: "options",
159
- required: !0,
160
- typeOptions: {
161
- loadOptionsMethod: "loadOptions_schedule_calendars"
162
- },
163
- default: "",
164
- description: 'Select the business hours calendar to check against. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/" target="_blank">expression</a>.'
165
- }, {
166
- displayName: "Time Zone Name or ID",
167
- name: "timeZoneSetupId",
168
- type: "options",
169
- required: !0,
170
- typeOptions: {
171
- loadOptionsMethod: "loadTimeZoneOptions"
172
- },
173
- default: "",
174
- description: 'Select the time zone for interpreting the calendar business hours. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/" target="_blank">expression</a>.'
175
- }, {
176
- displayName: "Check Day Only",
177
- name: "checkDateOnly",
178
- type: "boolean",
179
- default: !1,
180
- description: "Whether to only check if the date is a workday, ignoring specific business hours and partial-day holidays",
181
- hint: "When enabled, returns true if the date has business hours defined and is not an all-day holiday"
182
- }, {
183
- displayName: "Use Current Time",
184
- name: "useNow",
185
- type: "boolean",
186
- default: !1,
187
- description: "Whether to use the current date/time for checking"
188
- }, {
189
- displayName: "Timestamp",
190
- name: "timestamp",
191
- type: "dateTime",
192
- required: !0,
193
- displayOptions: {
194
- show: {
195
- useNow: [ !1 ]
196
- }
197
- },
198
- default: "",
199
- hint: "Use UTC time or specify timezone",
200
- description: "The date/time to check against business hours"
201
- } ]
202
- };
203
- methods={
204
- loadOptions: {
205
- ...import_methods.loadOptions,
206
- async loadTimeZoneOptions() {
207
- const timeZones = await import_client.connectWiseApiRequest.call(this, "GET", "/system/timeZoneSetups", {}, {
208
- pageSize: 1e3
209
- }, {
210
- returnAll: !0,
211
- optionsCache: !0
212
- }), defaultTimeZone = timeZones.find(tz => tz.defaultFlag === !0);
213
- return [ ...timeZones ].sort((a, b) => a.defaultFlag === !0 ? -1 : b.defaultFlag === !0 ? 1 : a.name.localeCompare(b.name)).map(tz => ({
214
- name: tz.defaultFlag ? `${tz.name} (Default)` : tz.name,
215
- value: tz.id
216
- }));
217
- }
218
- }
219
- };
220
- async execute() {
221
- const items = this.getInputData();
222
- if (process.env.MSPCOPILOT_BETA === "true") {
223
- const {requireAccessKey: requireAccessKey} = await import("./transport/access-key.js");
224
- if (!await requireAccessKey(this, "beta")) return (0, import_utils.returnAccessKeyRequired)(this, 0),
225
- [ [], [] ];
226
- } else return [ [], [] ];
227
- const trueItems = [], falseItems = [], calendarIds = /* @__PURE__ */ new Set, calendarDateRanges = /* @__PURE__ */ new Map, itemConfigs = [];
228
- for (let i = 0; i < items.length; i++) {
229
- const calendarId = this.getNodeParameter("calendarId", i), timeZoneSetupId = this.getNodeParameter("timeZoneSetupId", i), useNow = this.getNodeParameter("useNow", i), checkDateOnly = this.getNodeParameter("checkDateOnly", i), timestamp = useNow ? /* @__PURE__ */ new Date : new Date(this.getNodeParameter("timestamp", i));
230
- if (!calendarDateRanges.has(calendarId)) calendarDateRanges.set(calendarId, {
231
- min: timestamp,
232
- max: timestamp
233
- }); else {
234
- const range = calendarDateRanges.get(calendarId);
235
- timestamp < range.min && (range.min = timestamp), timestamp > range.max && (range.max = timestamp);
236
- }
237
- calendarIds.add(calendarId), itemConfigs.push({
238
- timestamp: timestamp,
239
- calendarId: calendarId,
240
- timeZoneSetupId: timeZoneSetupId,
241
- checkDateOnly: checkDateOnly,
242
- useNow: useNow
243
- });
244
- }
245
- const calendarsMap = /* @__PURE__ */ new Map, timeZonesMap = /* @__PURE__ */ new Map, holidaysByCalendarAndDate = /* @__PURE__ */ new Map, allTimeZones = await import_client.connectWiseApiRequest.call(this, "GET", "/system/timeZoneSetups", {}, {
246
- pageSize: 1e3
247
- }, {
248
- returnAll: !0,
249
- optionsCache: !0
250
- });
251
- for (const tz of allTimeZones) {
252
- const windowsTimeZone = tz.timeZone?.name, ianaTimeZone = windowsTimeZone ? WINDOWS_TO_IANA_TIMEZONE[windowsTimeZone] : void 0;
253
- ianaTimeZone ? timeZonesMap.set(tz.id, ianaTimeZone) : (console.warn(`No IANA timezone mapping found for Windows timezone: ${windowsTimeZone} (ID: ${tz.id}). Using UTC as fallback.`),
254
- timeZonesMap.set(tz.id, "UTC"));
255
- }
256
- for (const calendarId of calendarIds) {
257
- const calendar = await import_client.connectWiseApiRequest.call(this, "GET", `/schedule/calendars/${calendarId}`, {}, {}, {
258
- optionsCache: !0
259
- });
260
- if (calendarsMap.set(calendarId, calendar), calendar.holidayList?.id) {
261
- const dateRange = calendarDateRanges.get(calendarId), minDateStr = dateRange.min.toISOString().split("T")[0], maxDateStr = dateRange.max.toISOString().split("T")[0], holidays = await import_client.connectWiseApiRequest.call(this, "GET", `/schedule/holidayLists/${calendar.holidayList.id}/holidays`, {}, {
262
- conditions: `date>=[${minDateStr}] and date<=[${maxDateStr}]`,
263
- pageSize: 1e3
264
- }, {
265
- returnAll: !0,
266
- optionsCache: !0
267
- }), holidayMap = /* @__PURE__ */ new Map;
268
- if (holidays && Array.isArray(holidays)) for (const holiday of holidays) {
269
- const dateKey = holiday.date;
270
- holidayMap.has(dateKey) || holidayMap.set(dateKey, []), holidayMap.get(dateKey).push(holiday);
271
- }
272
- holidaysByCalendarAndDate.set(calendarId, holidayMap);
273
- }
274
- }
275
- for (let i = 0; i < items.length; i++) {
276
- const config = itemConfigs[i], calendar = calendarsMap.get(config.calendarId), ianaTimeZone = timeZonesMap.get(config.timeZoneSetupId) || "UTC";
277
- if (!calendar) {
278
- falseItems.push(items[i]);
279
- continue;
280
- }
281
- const dateTimeInZone = import_luxon.DateTime.fromJSDate(config.timestamp).setZone(ianaTimeZone), dateStr = dateTimeInZone.toISODate();
282
- let isHoliday = !1, holidayName = null;
283
- const holidaysForDate = holidaysByCalendarAndDate.get(config.calendarId)?.get(dateStr) || [];
284
- if (holidaysForDate.length > 0) {
285
- for (const holiday of holidaysForDate) if (holiday.allDayFlag) {
286
- isHoliday = !0, holidayName = holiday.name;
287
- break;
288
- } else if (!config.checkDateOnly) {
289
- const holidayStart = import_luxon.DateTime.fromISO(`${dateStr}T${holiday.timeStart}`, {
290
- zone: ianaTimeZone
291
- }), holidayEnd = import_luxon.DateTime.fromISO(`${dateStr}T${holiday.timeEnd}`, {
292
- zone: ianaTimeZone
293
- });
294
- if (dateTimeInZone >= holidayStart && dateTimeInZone < holidayEnd) {
295
- isHoliday = !0, holidayName = holiday.name;
296
- break;
297
- }
298
- }
299
- }
300
- const dayName = dateTimeInZone.toFormat("cccc").toLowerCase(), startTimeField = `${dayName}StartTime`, endTimeField = `${dayName}EndTime`;
301
- let isDuringBusinessHours = !1;
302
- if (!isHoliday && calendar[startTimeField] && calendar[endTimeField]) if (config.checkDateOnly) isDuringBusinessHours = !0; else {
303
- const startTime = import_luxon.DateTime.fromISO(`${dateStr}T${calendar[startTimeField]}`, {
304
- zone: ianaTimeZone
305
- }), endTime = import_luxon.DateTime.fromISO(`${dateStr}T${calendar[endTimeField]}`, {
306
- zone: ianaTimeZone
307
- });
308
- isDuringBusinessHours = dateTimeInZone >= startTime && dateTimeInZone < endTime;
309
- }
310
- const itemWithMetadata = {
311
- ...items[i],
312
- json: {
313
- ...items[i].json,
314
- __schedule: {
315
- isDuringBusinessHours: isDuringBusinessHours,
316
- isHoliday: isHoliday,
317
- holidayName: holidayName,
318
- businessHours: calendar[startTimeField] ? `${calendar[startTimeField]} - ${calendar[endTimeField]}` : "Closed",
319
- checkDateOnly: config.checkDateOnly,
320
- timezone: ianaTimeZone,
321
- localTime: dateTimeInZone.toFormat("yyyy-MM-dd HH:mm:ss")
322
- }
323
- }
324
- };
325
- isDuringBusinessHours ? trueItems.push(itemWithMetadata) : falseItems.push(itemWithMetadata);
326
- }
327
- return [ trueItems, falseItems ];
328
- }
329
- }
330
-
331
- 0 && (module.exports = {
332
- IfSchedule: IfSchedule
333
- });
@@ -1,103 +0,0 @@
1
- var __create = Object.create;
2
-
3
- var __defProp = Object.defineProperty;
4
-
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
-
7
- var __getOwnPropNames = Object.getOwnPropertyNames;
8
-
9
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
10
-
11
- var __export = (target, all) => {
12
- for (var name in all) __defProp(target, name, {
13
- get: all[name],
14
- enumerable: !0
15
- });
16
- }, __copyProps = (to, from, except, desc) => {
17
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
18
- get: () => from[key],
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
- });
21
- return to;
22
- };
23
-
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {},
25
- __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)), __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
29
- value: !0
30
- }), mod);
31
-
32
- var diagnostics_schema_exports = {};
33
-
34
- __export(diagnostics_schema_exports, {
35
- diagnosticsSchema: () => diagnosticsSchema,
36
- execute: () => execute
37
- });
38
-
39
- module.exports = __toCommonJS(diagnostics_schema_exports);
40
-
41
- var import_hint_collector = require("../../helpers/hint-collector");
42
-
43
- const diagnosticsFields = [ {
44
- displayName: "Operation",
45
- name: "operation",
46
- type: "options",
47
- noDataExpression: !0,
48
- displayOptions: {
49
- show: {
50
- resource: [ "diagnostics" ]
51
- }
52
- },
53
- options: [ {
54
- name: "Clear Cache",
55
- value: "clearCache",
56
- description: "Clear all cached ConnectWise PSA data",
57
- action: "Clear all cache entries"
58
- } ],
59
- default: "clearCache"
60
- } ], diagnosticsSchema = {
61
- resource: "diagnostics",
62
- displayName: "Diagnostics",
63
- description: "Diagnostic and maintenance operations",
64
- endpoints: {},
65
- fields: diagnosticsFields
66
- };
67
-
68
- async function execute(operation, i) {
69
- if (operation === "clearCache") try {
70
- const {clearAllCached: clearAllCached} = await import("../../transport/cache.js"), clearedCount = await clearAllCached(), result = {
71
- success: !0,
72
- clearedCount: clearedCount,
73
- message: `Cleared ${clearedCount} cache entries`
74
- };
75
- return (0, import_hint_collector.hint)(this, "custom", `Cache cleared: ${clearedCount} entries removed`),
76
- this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(result), {
77
- itemData: {
78
- item: i
79
- }
80
- });
81
- } catch (error) {
82
- const originalError = error.message || "Unknown error occurred";
83
- let friendlyMessage;
84
- originalError.includes("isn't writeable") || originalError.includes("ECONNREFUSED") || originalError.includes("Connection is closed") || originalError.includes("Redis cache is not available") ? friendlyMessage = "Redis cache server is not running or not accessible. Please start Redis and ensure it is configured correctly (check QUEUE_BULL_REDIS_HOST and QUEUE_BULL_REDIS_PORT environment variables)." : originalError.includes("only available in the pro version") ? friendlyMessage = "Cache clearing requires the pro version of this node." : friendlyMessage = "Failed to clear cache. Please check the error details and your Redis configuration.";
85
- const result = {
86
- success: !1,
87
- clearedCount: 0,
88
- error: originalError,
89
- message: friendlyMessage
90
- };
91
- return (0, import_hint_collector.hint)(this, "custom", friendlyMessage), this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(result), {
92
- itemData: {
93
- item: i
94
- }
95
- });
96
- }
97
- throw new Error(`Unsupported operation: ${operation}`);
98
- }
99
-
100
- 0 && (module.exports = {
101
- diagnosticsSchema: diagnosticsSchema,
102
- execute: execute
103
- });
@@ -1,216 +0,0 @@
1
- var __create = Object.create;
2
-
3
- var __defProp = Object.defineProperty;
4
-
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
-
7
- var __getOwnPropNames = Object.getOwnPropertyNames;
8
-
9
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
10
-
11
- var __export = (target, all) => {
12
- for (var name in all) __defProp(target, name, {
13
- get: all[name],
14
- enumerable: !0
15
- });
16
- }, __copyProps = (to, from, except, desc) => {
17
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
18
- get: () => from[key],
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
- });
21
- return to;
22
- };
23
-
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {},
25
- __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)), __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
29
- value: !0
30
- }), mod);
31
-
32
- var reports_schema_exports = {};
33
-
34
- __export(reports_schema_exports, {
35
- execute: () => execute,
36
- loadReportColumns: () => loadReportColumns,
37
- reportsSchema: () => reportsSchema,
38
- transformReportData: () => transformReportData
39
- });
40
-
41
- module.exports = __toCommonJS(reports_schema_exports);
42
-
43
- var import_transport = require("../../transport"), import_utils = require("../../helpers/utils"), import_common = require("../../descriptions/common.properties"), import_common2 = require("../../descriptions/common.descriptions");
44
-
45
- function transformReportData(columnDefinitions, rowValues) {
46
- if (process.env.MSPCOPILOT_BETA !== "true") return [];
47
- const columnNames = columnDefinitions.map(def => Object.keys(def)[0]);
48
- return rowValues.map(row => {
49
- const obj = {};
50
- return columnNames.forEach((col, index) => {
51
- obj[col] = row[index];
52
- }), obj;
53
- });
54
- }
55
-
56
- async function loadReportColumns() {
57
- const reportName = this.getCurrentNodeParameter("reportName");
58
- if (!reportName) return [];
59
- try {
60
- const sampleData = await import_transport.connectWiseApiRequest.call(this, "GET", `/system/reports/${reportName}`, {}, {
61
- pageSize: 1
62
- });
63
- if (!sampleData.column_definitions) return [];
64
- const columns = sampleData.column_definitions.map(def => {
65
- const columnName = Object.keys(def)[0], columnInfo = def[columnName], details = [ columnInfo.type ];
66
- for (const [key, value] of Object.entries(columnInfo)) if (key !== "type") {
67
- if (typeof value == "boolean") {
68
- if (value === !0) {
69
- let displayKey = key.replace(/^is/, "").replace(/([A-Z])/g, " $1").trim();
70
- displayKey = displayKey.charAt(0).toUpperCase() + displayKey.slice(1), details.push(displayKey);
71
- }
72
- } else if (value != null && value !== "") {
73
- let displayKey = key.replace(/([A-Z])/g, " $1").trim();
74
- displayKey = displayKey.charAt(0).toUpperCase() + displayKey.slice(1), details.push(`${displayKey}: ${value}`);
75
- }
76
- }
77
- return {
78
- name: columnName,
79
- value: columnName,
80
- description: details.join(", ")
81
- };
82
- });
83
- return columns.unshift({
84
- name: "All Fields (Override Selection)",
85
- value: "__ALL_FIELDS_OVERRIDE__"
86
- }), columns;
87
- } catch (error) {
88
- return console.error("Error loading report columns:", error), [];
89
- }
90
- }
91
-
92
- const reportsFields = [ {
93
- displayName: "Operation",
94
- name: "operation",
95
- type: "options",
96
- noDataExpression: !0,
97
- displayOptions: {
98
- show: {
99
- resource: [ "reports" ]
100
- }
101
- },
102
- options: [ {
103
- name: "Get Report",
104
- value: "getReport",
105
- description: "Retrieve report data",
106
- action: "Get a report"
107
- } ],
108
- default: "getReport"
109
- }, {
110
- displayName: `Browse the <a href="https://${import_common2.DOCURL_PREFIX}/reports${import_common2.DOCURL_SUFFIX}" target="_blank">report list</a> to search all available reports and their columns.`,
111
- name: "reportsNotice",
112
- type: "notice",
113
- default: "",
114
- displayOptions: {
115
- show: {
116
- resource: [ "reports" ]
117
- }
118
- }
119
- }, {
120
- displayName: "Report Name",
121
- name: "reportName",
122
- type: "options",
123
- required: !0,
124
- displayOptions: {
125
- show: {
126
- resource: [ "reports" ],
127
- operation: [ "getReport" ]
128
- }
129
- },
130
- typeOptions: {
131
- loadOptionsMethod: "loadOptions_system_reports"
132
- },
133
- default: "",
134
- description: "Select the report to retrieve"
135
- }, {
136
- displayName: "Transform Output",
137
- name: "transformOutput",
138
- type: "boolean",
139
- displayOptions: {
140
- show: {
141
- resource: [ "reports" ],
142
- operation: [ "getReport" ]
143
- }
144
- },
145
- default: !0,
146
- hint: "Transform matrix format (column_definitions + row_values) to array of objects"
147
- }, ...(0, import_common.getCommonFields)({
148
- overrides: {
149
- fields: {
150
- typeOptions: {
151
- loadOptionsMethod: "loadReportColumns",
152
- loadOptionsDependsOn: [ "reportName" ]
153
- },
154
- description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/" target="_blank">expression</a>. Leave empty to return all columns.'
155
- },
156
- orderBy: {
157
- type: "string",
158
- typeOptions: void 0,
159
- placeholder: "e.g., Date_Created or Company_Name",
160
- hint: "Use exact column name from the report"
161
- },
162
- descending: {
163
- displayOptions: {
164
- show: {
165
- operation: [ "getReport" ],
166
- orderBy: [ {
167
- _cnd: {
168
- not: ""
169
- }
170
- } ]
171
- }
172
- }
173
- }
174
- }
175
- }) ], reportsSchema = {
176
- resource: "reports",
177
- displayName: "Report ✨",
178
- pluralDisplayName: "Reports",
179
- description: "Access ConnectWise system reports",
180
- identifierField: "name",
181
- nameField: "reportName",
182
- endpoints: {
183
- getReport: {
184
- method: "GET",
185
- path: params => `/system/reports/${params.reportName}`
186
- }
187
- },
188
- fields: reportsFields
189
- };
190
-
191
- async function execute(operation, i) {
192
- {
193
- if (process.env.MSPCOPILOT_BETA !== "true") return (0, import_utils.returnProOnlyMessage)(this, i);
194
- const {requireAccessKey: requireAccessKey} = await import("../../transport/access-key.js");
195
- if (!await requireAccessKey(this, "beta")) return (0, import_utils.returnAccessKeyRequired)(this, i);
196
- }
197
- const reportName = this.getNodeParameter("reportName", i), transformOutput = this.getNodeParameter("transformOutput", i, !0), returnAll = this.getNodeParameter("returnAll", i, !1), limit = this.getNodeParameter("limit", i, 50), qs = (0,
198
- import_utils.buildQueryOptions)(this, i, []), endpoint = `/system/reports/${reportName}`;
199
- let result = await import_transport.connectWiseApiRequest.call(this, "GET", endpoint, {}, qs, {
200
- returnAll: returnAll,
201
- limit: returnAll ? void 0 : limit
202
- });
203
- return transformOutput && result && result.column_definitions && result.row_values && (result = transformReportData(result.column_definitions, result.row_values)),
204
- this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(result), {
205
- itemData: {
206
- item: i
207
- }
208
- });
209
- }
210
-
211
- 0 && (module.exports = {
212
- execute: execute,
213
- loadReportColumns: loadReportColumns,
214
- reportsSchema: reportsSchema,
215
- transformReportData: transformReportData
216
- });
File without changes