@mspcopilot/n8n-nodes-connectwise 0.2.3 → 0.2.4-beta.1
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.
- package/{dist-community → dist-beta}/credentials/ConnectWisePsaApi.credentials.js +17 -3
- package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/ConnectWisePsa.node.js +14 -2
- package/dist-beta/nodes/ConnectWise/PSA/ConnectWisePsaTrigger.node.js +506 -0
- package/dist-beta/nodes/ConnectWise/PSA/IfSchedule.node.js +333 -0
- package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/descriptions/common.properties.js +16 -1
- package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/methods/fieldOptions.js +1 -0
- package/dist-beta/nodes/ConnectWise/PSA/schema/resources/alert-consolidation.js +451 -0
- package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/schema/resources/custom.schema.js +38 -1
- package/dist-beta/nodes/ConnectWise/PSA/schema/resources/diagnostics.schema.js +103 -0
- package/dist-beta/nodes/ConnectWise/PSA/schema/resources/reports.schema.js +216 -0
- package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/schema/resources/ticket.schema.js +11 -1
- package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/transport/cache.js +84 -6
- package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/transport/client.js +46 -5
- package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/transport/version-check.js +9 -13
- package/package.json +6 -4
- package/dist-community/nodes/ConnectWise/PSA/schema/resources/alert-consolidation.js +0 -42
- /package/{dist-community → dist-beta}/LICENSE.md +0 -0
- /package/{dist-community → dist-beta}/credentials/connectwise-dark.svg +0 -0
- /package/{dist-community → dist-beta}/credentials/connectwise-light.svg +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/connectwise-dark.svg +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/connectwise-light.svg +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/descriptions/common.descriptions.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/descriptions/index.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/helpers/customFields.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/helpers/field-collector.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/helpers/field-conditions.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/helpers/hint-collector.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/helpers/index.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/helpers/logging.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/helpers/utils.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/methods/generated.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/methods/index.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/schema/converter/index.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/schema/converter/reference.generator.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/schema/index.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/schema/references.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/schema/reports-descriptions.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/schema/resources/activity.schema.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/schema/resources/company.schema.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/schema/resources/contact.schema.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/schema/resources/index.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/schema/resources/members.schema.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/schema/resources/ticketNote.schema.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/schema/resources/ticketTask.schema.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/schema/resources/timeEntry.schema.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/schema/static-fields.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/schema/transformer.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/schema/types/index.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/schema/types/reference.types.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/schema/types/resource.types.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/transport/access-key.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/transport/index.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/transport/operations.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/transport/response-transformer.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/types/n8n-augmentation.d.js +0 -0
- /package/{dist-community → dist-beta}/nodes/ConnectWisePsa.node.json +0 -0
|
@@ -0,0 +1,333 @@
|
|
|
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
|
+
});
|
package/{dist-community → dist-beta}/nodes/ConnectWise/PSA/descriptions/common.properties.js
RENAMED
|
@@ -336,7 +336,22 @@ function getCommonFields(options) {
|
|
|
336
336
|
operation: [ "getAll", "getReport" ]
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
|
-
}
|
|
339
|
+
}, ...queryOptions.cacheResponse ? [ {
|
|
340
|
+
...queryOptions.cacheResponse,
|
|
341
|
+
displayOptions: {
|
|
342
|
+
show: {
|
|
343
|
+
operation: [ "get", "getAll", "getReport" ]
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}, {
|
|
347
|
+
...queryOptions.cacheDuration,
|
|
348
|
+
displayOptions: {
|
|
349
|
+
show: {
|
|
350
|
+
operation: [ "get", "getAll", "getReport" ],
|
|
351
|
+
cacheResponse: [ !0 ]
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
} ] : [] ];
|
|
340
355
|
return options?.only ? fields = fields.filter(f => options.only.includes(f.name)) : options?.exclude && (fields = fields.filter(f => !options.exclude.includes(f.name))),
|
|
341
356
|
options?.overrides && (fields = fields.map(field => options.overrides[field.name] ? {
|
|
342
357
|
...field,
|
|
@@ -44,6 +44,7 @@ const resourceSchemas = {
|
|
|
44
44
|
ticketNote: import_ticketNote.ticketNoteSchema,
|
|
45
45
|
ticketTask: import_ticketTask.ticketTaskSchema,
|
|
46
46
|
timeEntry: import_timeEntry.timeEntrySchema,
|
|
47
|
+
reports: require("../schema/resources/reports.schema").reportsSchema,
|
|
47
48
|
custom: import_custom.customSchema
|
|
48
49
|
};
|
|
49
50
|
|