@pipedream/microsoft_outlook_calendar 0.6.1 → 0.7.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.
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook_calendar.app.mjs";
3
3
  export default {
4
4
  type: "action",
5
5
  key: "microsoft_outlook_calendar-create-calendar-event",
6
- version: "0.0.11",
6
+ version: "0.0.12",
7
7
  annotations: {
8
8
  destructiveHint: false,
9
9
  openWorldHint: true,
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook_calendar.app.mjs";
3
3
  export default {
4
4
  type: "action",
5
5
  key: "microsoft_outlook_calendar-delete-calendar-event",
6
- version: "0.0.6",
6
+ version: "0.0.7",
7
7
  annotations: {
8
8
  destructiveHint: true,
9
9
  openWorldHint: true,
@@ -4,7 +4,7 @@ import { ConfigurationError } from "@pipedream/platform";
4
4
  export default {
5
5
  type: "action",
6
6
  key: "microsoft_outlook_calendar-delete-recurring-event-instance",
7
- version: "0.0.3",
7
+ version: "0.0.4",
8
8
  annotations: {
9
9
  destructiveHint: true,
10
10
  openWorldHint: true,
@@ -8,7 +8,7 @@ export default {
8
8
  key: "microsoft_outlook_calendar-get-schedule",
9
9
  name: "Get Free/Busy Schedule",
10
10
  description: "Get the free/busy availability information for a collection of users, distributions lists, or resources (rooms or equipment) for a specified time period. [See the documentation](https://learn.microsoft.com/en-us/graph/api/calendar-getschedule)",
11
- version: "0.0.8",
11
+ version: "0.0.9",
12
12
  annotations: {
13
13
  destructiveHint: false,
14
14
  openWorldHint: true,
@@ -48,13 +48,6 @@ export default {
48
48
  },
49
49
  },
50
50
  methods: {
51
- getSchedule(opts = {}) {
52
- return this.microsoftOutlook._makeRequest({
53
- method: "POST",
54
- path: "/me/calendar/getSchedule",
55
- ...opts,
56
- });
57
- },
58
51
  convertWorkingHoursToItemTimezone(response) {
59
52
  const workingHours = response?.workingHours;
60
53
 
@@ -93,8 +86,8 @@ export default {
93
86
 
94
87
  const schedules = utils.parseArray(this.schedules);
95
88
 
96
- const { value } = await this.getSchedule({
97
- $,
89
+ const { value } = await this.microsoftOutlook.getSchedule({
90
+ timeZone: this.timeZone,
98
91
  data: {
99
92
  schedules,
100
93
  startTime: {
@@ -107,9 +100,6 @@ export default {
107
100
  },
108
101
  availabilityViewInterval: this.availabilityViewInterval,
109
102
  },
110
- headers: {
111
- Prefer: `outlook.timezone="${this.timeZone}"`,
112
- },
113
103
  });
114
104
 
115
105
  if (value?.length > 0 && value[0].workingHours) {
@@ -1,10 +1,11 @@
1
+ import { ConfigurationError } from "@pipedream/platform";
1
2
  import microsoftOutlook from "../../microsoft_outlook_calendar.app.mjs";
2
3
 
3
4
  export default {
4
5
  key: "microsoft_outlook_calendar-list-events",
5
6
  name: "List Events",
6
7
  description: "Get a list of event objects in the user's mailbox. [See the documentation](https://learn.microsoft.com/en-us/graph/api/user-list-events)",
7
- version: "0.0.7",
8
+ version: "0.0.9",
8
9
  annotations: {
9
10
  destructiveHint: false,
10
11
  openWorldHint: true,
@@ -37,25 +38,19 @@ export default {
37
38
  label: "Include Recurring",
38
39
  description: "Whether to include recurring events",
39
40
  optional: true,
40
- reloadProps: true,
41
41
  },
42
- },
43
- additionalProps() {
44
- if (!this.includeRecurring) {
45
- return {};
46
- }
47
- return {
48
- startDateTime: {
49
- type: "string",
50
- label: "Start Date Time",
51
- description: "The start date and time of the time range, represented in ISO 8601 format. For example, `2019-11-08T19:00:00-08:00`",
52
- },
53
- endDateTime: {
54
- type: "string",
55
- label: "End Date Time",
56
- description: "The end date and time of the time range, represented in ISO 8601 format. For example, `2019-11-08T20:00:00-08:00`",
57
- },
58
- };
42
+ startDateTime: {
43
+ type: "string",
44
+ label: "Start Date Time",
45
+ description: "If `Include Recurring` is true, this is the start date and time of the time range, represented in ISO 8601 format. For example, `2019-11-08T19:00:00-08:00`.",
46
+ optional: true,
47
+ },
48
+ endDateTime: {
49
+ type: "string",
50
+ label: "End Date Time",
51
+ description: "If `Include Recurring` is true, this is the end date and time of the time range, represented in ISO 8601 format. For example, `2019-11-08T20:00:00-08:00`.",
52
+ optional: true,
53
+ },
59
54
  },
60
55
  async run({ $ }) {
61
56
  const params = {
@@ -64,7 +59,12 @@ export default {
64
59
  "$top": this.maxResults,
65
60
  };
66
61
 
67
- const { value = [] } = !this.includeRecurring
62
+ const { includeRecurring } = this;
63
+ if (includeRecurring && (!this.startDateTime || !this.endDateTime)) {
64
+ throw new ConfigurationError("`Start Date Time` and `End Date Time` are required when `Include Recurring` is true");
65
+ }
66
+
67
+ const { value = [] } = !includeRecurring
68
68
  ? await this.microsoftOutlook.listCalendarEvents({
69
69
  $,
70
70
  params,
@@ -78,7 +78,7 @@ export default {
78
78
  },
79
79
  });
80
80
 
81
- const events = !this.includeRecurring
81
+ const events = !includeRecurring
82
82
  ? value.filter((event) => !event.recurrence)
83
83
  : value;
84
84
 
@@ -4,7 +4,7 @@ export default {
4
4
  key: "microsoft_outlook_calendar-search-contacts",
5
5
  name: "Search Contacts",
6
6
  description: "Search for contacts by name from your saved contacts list and retrieve their email addresses. [See the documentation](https://learn.microsoft.com/en-us/graph/api/user-list-contacts)",
7
- version: "0.0.2",
7
+ version: "0.0.3",
8
8
  type: "action",
9
9
  annotations: {
10
10
  destructiveHint: false,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "microsoft_outlook_calendar-search-people",
5
5
  name: "Search People",
6
6
  description: "Retrieve a collection of person objects ordered by their relevance to the user, based on communication and collaboration patterns and business relationships. [See the documentation](https://learn.microsoft.com/en-us/graph/api/user-list-people)",
7
- version: "0.0.2",
7
+ version: "0.0.3",
8
8
  type: "action",
9
9
  annotations: {
10
10
  destructiveHint: false,
@@ -3,7 +3,7 @@ import microsoftOutlook from "../../microsoft_outlook_calendar.app.mjs";
3
3
  export default {
4
4
  type: "action",
5
5
  key: "microsoft_outlook_calendar-update-calendar-event",
6
- version: "0.0.6",
6
+ version: "0.0.7",
7
7
  annotations: {
8
8
  destructiveHint: true,
9
9
  openWorldHint: true,
@@ -4,7 +4,7 @@ import { ConfigurationError } from "@pipedream/platform";
4
4
  export default {
5
5
  type: "action",
6
6
  key: "microsoft_outlook_calendar-update-recurring-event-instance",
7
- version: "0.0.3",
7
+ version: "0.0.4",
8
8
  annotations: {
9
9
  destructiveHint: false,
10
10
  openWorldHint: true,
@@ -1,6 +1,6 @@
1
- import {
2
- axios, ConfigurationError,
3
- } from "@pipedream/platform";
1
+ import { Client } from "@microsoft/microsoft-graph-client";
2
+ import "isomorphic-fetch";
3
+ import pickBy from "lodash.pickby";
4
4
 
5
5
  export default {
6
6
  type: "app",
@@ -122,139 +122,85 @@ export default {
122
122
  },
123
123
  },
124
124
  methods: {
125
- _getUrl(path) {
126
- return `https://graph.microsoft.com/v1.0${path}`;
127
- },
128
- _getHeaders(headers = {}) {
129
- return {
130
- "Authorization": `Bearer ${this.$auth.oauth_access_token}`,
131
- "accept": "application/json",
132
- "Content-Type": "application/json",
133
- ...headers,
134
- };
135
- },
136
- async _makeRequest({
137
- $,
138
- path,
139
- headers,
140
- ...otherConfig
141
- } = {}) {
142
- try {
143
- const config = {
144
- url: this._getUrl(path),
145
- headers: this._getHeaders(headers),
146
- ...otherConfig,
147
- };
148
- return await axios($ ?? this, config);
149
- } catch (error) {
150
- throw new ConfigurationError(error.message);
151
- }
152
- },
153
- async createHook(args = {}) {
154
- const response = await this._makeRequest({
155
- method: "POST",
156
- path: "/subscriptions",
157
- ...args,
125
+ client() {
126
+ return Client.init({
127
+ authProvider: (done) => {
128
+ done(null, this.$auth.oauth_access_token);
129
+ },
158
130
  });
159
- return response;
131
+ },
132
+ async createHook({ data = {} } = {}) {
133
+ return await this.client().api("/subscriptions")
134
+ .post(data);
160
135
  },
161
136
  async renewHook({
162
- hookId,
163
- ...args
137
+ hookId, data = {},
164
138
  } = {}) {
165
- return this._makeRequest({
166
- method: "PATCH",
167
- path: `/subscriptions/${hookId}`,
168
- ...args,
169
- });
139
+ return await this.client().api(`/subscriptions/${hookId}`)
140
+ .patch(data);
170
141
  },
171
- async deleteHook({
172
- hookId,
173
- ...args
174
- } = {}) {
175
- return this._makeRequest({
176
- method: "DELETE",
177
- path: `/subscriptions/${hookId}`,
178
- ...args,
179
- });
142
+ async deleteHook({ hookId } = {}) {
143
+ return await this.client().api(`/subscriptions/${hookId}`)
144
+ .delete();
180
145
  },
181
146
  async getSupportedTimeZones() {
182
- return this._makeRequest({
183
- method: "GET",
184
- path: "/me/outlook/supportedTimeZones",
185
- });
147
+ return await this.client().api("/me/outlook/supportedTimeZones")
148
+ .get();
186
149
  },
187
- async createCalendarEvent(args = {}) {
188
- return this._makeRequest({
189
- method: "POST",
190
- path: "/me/events",
191
- ...args,
192
- });
150
+ async createCalendarEvent({ data = {} } = {}) {
151
+ return await this.client().api("/me/events")
152
+ .post(data);
193
153
  },
194
154
  async updateCalendarEvent({
195
- eventId, ...args
196
- }) {
197
- return this._makeRequest({
198
- method: "PATCH",
199
- path: `/me/events/${eventId}`,
200
- ...args,
201
- });
155
+ eventId, data = {},
156
+ } = {}) {
157
+ return await this.client().api(`/me/events/${eventId}`)
158
+ .patch(data);
202
159
  },
203
- async deleteCalendarEvent({
204
- eventId, ...args
205
- }) {
206
- return this._makeRequest({
207
- method: "DELETE",
208
- path: `/me/events/${eventId}`,
209
- ...args,
210
- });
160
+ async deleteCalendarEvent({ eventId } = {}) {
161
+ return await this.client().api(`/me/events/${eventId}`)
162
+ .delete();
211
163
  },
212
- async listCalendarEvents(args = {}) {
213
- return this._makeRequest({
214
- method: "GET",
215
- path: "/me/events",
216
- ...args,
217
- });
164
+ async listCalendarEvents({ params = {} } = {}) {
165
+ return await this.client().api("/me/events")
166
+ .query(pickBy(params))
167
+ .get();
218
168
  },
219
169
  async getCalendarEvent({
220
- eventId,
221
- ...args
170
+ eventId, params = {},
222
171
  } = {}) {
223
- return this._makeRequest({
224
- method: "GET",
225
- path: `/me/events/${eventId}`,
226
- ...args,
227
- });
172
+ return await this.client().api(`/me/events/${eventId}`)
173
+ .query(pickBy(params))
174
+ .get();
228
175
  },
229
- async listCalendarView(args = {}) {
230
- return this._makeRequest({
231
- method: "GET",
232
- path: "/me/calendar/calendarView",
233
- ...args,
234
- });
176
+ async listCalendarView({ params = {} } = {}) {
177
+ return await this.client().api("/me/calendar/calendarView")
178
+ .query(pickBy(params))
179
+ .get();
235
180
  },
236
181
  async listEventInstances({
237
- eventId, ...args
238
- }) {
239
- return this._makeRequest({
240
- method: "GET",
241
- path: `/me/events/${eventId}/instances`,
242
- ...args,
243
- });
244
- },
245
- async listContacts(args = {}) {
246
- return this._makeRequest({
247
- method: "GET",
248
- path: "/me/contacts",
249
- ...args,
250
- });
251
- },
252
- async listPeople(args = {}) {
253
- return this._makeRequest({
254
- method: "GET",
255
- path: "/me/people",
256
- ...args,
257
- });
182
+ eventId, params = {},
183
+ } = {}) {
184
+ return await this.client().api(`/me/events/${eventId}/instances`)
185
+ .query(pickBy(params))
186
+ .get();
187
+ },
188
+ async listContacts({ params = {} } = {}) {
189
+ return await this.client().api("/me/contacts")
190
+ .query(pickBy(params))
191
+ .get();
192
+ },
193
+ async listPeople({ params = {} } = {}) {
194
+ return await this.client().api("/me/people")
195
+ .query(pickBy(params))
196
+ .get();
197
+ },
198
+ async getSchedule({
199
+ timeZone, data = {},
200
+ } = {}) {
201
+ return await this.client().api("/me/calendar/getSchedule")
202
+ .header("Prefer", `outlook.timezone="${timeZone}"`)
203
+ .post(data);
258
204
  },
259
205
  },
260
206
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/microsoft_outlook_calendar",
3
- "version": "0.6.1",
3
+ "version": "0.7.1",
4
4
  "description": "Pipedream Microsoft Outlook Calendar Components",
5
5
  "main": "microsoft_outlook_calendar.app.mjs",
6
6
  "keywords": [
@@ -15,9 +15,12 @@
15
15
  "access": "public"
16
16
  },
17
17
  "dependencies": {
18
+ "@microsoft/microsoft-graph-client": "^3.0.7",
18
19
  "@pipedream/microsoft_outlook": "^1.7.3",
19
20
  "@pipedream/pipedream": "^0.4.2",
20
21
  "@pipedream/platform": "^3.1.1",
22
+ "isomorphic-fetch": "^3.0.0",
23
+ "lodash.pickby": "^4.6.0",
21
24
  "luxon": "^3.7.2",
22
25
  "windows-iana": "^5.1.0"
23
26
  }
@@ -5,7 +5,7 @@ export default {
5
5
  key: "microsoft_outlook_calendar-new-calendar-event",
6
6
  name: "New Calendar Event (Instant)",
7
7
  description: "Emit new event when a new Calendar event is created",
8
- version: "0.0.11",
8
+ version: "0.0.12",
9
9
  type: "source",
10
10
  hooks: {
11
11
  ...common.hooks,
@@ -6,7 +6,7 @@ export default {
6
6
  key: "microsoft_outlook_calendar-new-upcoming-event",
7
7
  name: "New Upcoming Calendar Event",
8
8
  description: "Emit new event when a Calendar event is upcoming, this source is using `reminderMinutesBeforeStart` property of the event to determine the time it should emit.",
9
- version: "0.0.7",
9
+ version: "0.0.8",
10
10
  type: "source",
11
11
  props: {
12
12
  ...common.props,
@@ -5,7 +5,7 @@ export default {
5
5
  key: "microsoft_outlook_calendar-new-upcoming-event-polling",
6
6
  name: "New Upcoming Calendar Event (Polling)",
7
7
  description: "Emit new event based on a time interval before an upcoming calendar event. [See the documentation](https://docs.microsoft.com/en-us/graph/api/user-list-events)",
8
- version: "0.0.3",
8
+ version: "0.0.4",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  props: {
@@ -5,7 +5,7 @@ export default {
5
5
  key: "microsoft_outlook_calendar-updated-calendar-event",
6
6
  name: "New Calendar Event Update (Instant)",
7
7
  description: "Emit new event when a Calendar event is updated",
8
- version: "0.0.11",
8
+ version: "0.0.12",
9
9
  type: "source",
10
10
  hooks: {
11
11
  ...common.hooks,