recal-sdk 0.2.0 → 0.2.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.
Files changed (76) hide show
  1. package/README.md +27 -27
  2. package/dist/entities/organization.d.ts +2 -2
  3. package/dist/entities/organization.d.ts.map +1 -1
  4. package/dist/entities/organization.js +32 -0
  5. package/dist/entities/organization.js.map +1 -0
  6. package/dist/entities/user.d.ts +2 -2
  7. package/dist/entities/user.d.ts.map +1 -1
  8. package/dist/entities/user.js +45 -0
  9. package/dist/entities/user.js.map +1 -0
  10. package/dist/errors.js +36 -0
  11. package/dist/errors.js.map +1 -0
  12. package/dist/index.d.ts +4 -5
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +52 -7092
  15. package/dist/index.js.map +1 -1
  16. package/dist/services/calendar.service.d.ts +2 -2
  17. package/dist/services/calendar.service.d.ts.map +1 -1
  18. package/dist/services/calendar.service.js +292 -0
  19. package/dist/services/calendar.service.js.map +1 -0
  20. package/dist/services/oauth.service.js +168 -0
  21. package/dist/services/oauth.service.js.map +1 -0
  22. package/dist/services/organizations.service.d.ts +1 -1
  23. package/dist/services/organizations.service.d.ts.map +1 -1
  24. package/dist/services/organizations.service.js +132 -0
  25. package/dist/services/organizations.service.js.map +1 -0
  26. package/dist/services/scheduling.service.d.ts +2 -2
  27. package/dist/services/scheduling.service.d.ts.map +1 -1
  28. package/dist/services/scheduling.service.js +122 -0
  29. package/dist/services/scheduling.service.js.map +1 -0
  30. package/dist/services/users.service.js +93 -0
  31. package/dist/services/users.service.js.map +1 -0
  32. package/dist/typebox/calendar.tb.d.ts +5 -4
  33. package/dist/typebox/calendar.tb.d.ts.map +1 -1
  34. package/dist/typebox/calendar.tb.js +92 -0
  35. package/dist/typebox/calendar.tb.js.map +1 -0
  36. package/dist/typebox/oauth.tb.d.ts +2 -2
  37. package/dist/typebox/oauth.tb.js +16 -0
  38. package/dist/typebox/oauth.tb.js.map +1 -0
  39. package/dist/typebox/organization.stripped.tb.js +7 -0
  40. package/dist/typebox/organization.stripped.tb.js.map +1 -0
  41. package/dist/typebox/organization.tb.js +8 -0
  42. package/dist/typebox/organization.tb.js.map +1 -0
  43. package/dist/typebox/scheduling.tb.js +118 -0
  44. package/dist/typebox/scheduling.tb.js.map +1 -0
  45. package/dist/typebox/timeString.tb.js +7 -0
  46. package/dist/typebox/timeString.tb.js.map +1 -0
  47. package/dist/typebox/user.stripped.tb.js +6 -0
  48. package/dist/typebox/user.stripped.tb.js.map +1 -0
  49. package/dist/typebox/user.tb.d.ts +1 -1
  50. package/dist/typebox/user.tb.js +10 -0
  51. package/dist/typebox/user.tb.js.map +1 -0
  52. package/dist/types/calendar.types.d.ts +2 -4
  53. package/dist/types/calendar.types.d.ts.map +1 -1
  54. package/dist/types/calendar.types.js +27 -56
  55. package/dist/types/calendar.types.js.map +1 -1
  56. package/dist/types/internal.types.js +2 -0
  57. package/dist/types/internal.types.js.map +1 -0
  58. package/dist/types/oauth.types.d.ts +1 -1
  59. package/dist/types/oauth.types.d.ts.map +1 -1
  60. package/dist/types/oauth.types.js +2 -0
  61. package/dist/types/oauth.types.js.map +1 -0
  62. package/dist/types/scheduling.types.js +2 -0
  63. package/dist/types/scheduling.types.js.map +1 -0
  64. package/dist/utils/fetch.helper.d.ts +1 -1
  65. package/dist/utils/fetch.helper.d.ts.map +1 -1
  66. package/dist/utils/fetch.helper.js +93 -0
  67. package/dist/utils/fetch.helper.js.map +1 -0
  68. package/dist/utils/fetchErrorHandler.js +32 -0
  69. package/dist/utils/fetchErrorHandler.js.map +1 -0
  70. package/dist/utils/functionize.js +6 -0
  71. package/dist/utils/functionize.js.map +1 -0
  72. package/dist/utils/includes.helper.js +10 -0
  73. package/dist/utils/includes.helper.js.map +1 -0
  74. package/dist/utils/omit.js +4 -0
  75. package/dist/utils/omit.js.map +1 -0
  76. package/package.json +7 -5
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/types/calendar.types.ts"],"sourcesContent":["import type { Organization } from './types/entity.types'\n\ninterface RecalOptions {\n token?: string\n baseURL?: string\n}\n\n/**\n * Recal SDK\n * @description Recal SDK for Node.js\n * @version 0.1.0\n * @author Recal <team@recal.dev>\n * @license MIT\n */\nexport class Recal {\n // MARK: States\n private token: string\n private baseURL: string\n\n /**\n * Recal SDK constructor\n * @param token Recal API token\n */\n constructor(options?: RecalOptions) {\n let envToken: string\n if (!options?.token) {\n const _envToken = process.env.RECAL_TOKEN\n if (!_envToken)\n throw new Error('[Recal] No token provided by constructor or environment variable (RECAL_TOKEN)')\n envToken = _envToken\n }\n this.token = options?.token || envToken!\n this.baseURL = options?.baseURL || process.env.RECAL_BASE_URL || 'https://api.recal.dev'\n }\n\n // MARK: Functions\n /**\n * Fetch function with Recal authentication\n * @param input Request input\n * @param init Request init\n * @returns Promise<Response>\n */\n private _fetch = async (input: string, init?: RequestInit): Promise<Response> => {\n const url = new URL(`${this.baseURL}/v1${input.startsWith('/') ? '' : '/'}${input}`)\n return await fetch(url, {\n method: init?.method || 'GET',\n headers: {\n ...init?.headers,\n Authorization: `Bearer ${this.token}`,\n 'Content-Type': 'application/json',\n },\n credentials: 'include',\n mode: 'cors',\n ...init,\n }).catch((error) => {\n throw new Error(`[Recal] Fetch error: ${error}`)\n })\n }\n\n private fetch = (input: string, init?: RequestInit): Promise<Response> => {\n return this._fetch(input, init)\n }\n\n // Organization\n /**\n * Get all organizations\n * @returns Promise<PublicOrganization[]>\n */\n async listOrganizations(): Promise<Organization[]> {\n const response = await this.fetch('/organizations')\n if (!response.ok) throw new Error(`[Recal] HTTP error! status: ${response.status}`)\n return response.json() as Promise<Organization[]>\n }\n\n /**\n * Get organization by slug\n * @param slug Organization slug\n * @returns Promise<Organization>\n */\n async getOrganization(slug: string): Promise<Organization> {\n const response = await this.fetch(`/organizations/${slug}`)\n if (!response.ok) throw new Error(`[Recal] HTTP error! status: ${response.status}`)\n return response.json() as Promise<Organization>\n }\n\n // Member\n\n // Calendar\n}\n\nexport * from './types'\nexport default Recal\n\nconst test = new Recal()\ntest.listOrganizations().then((organizations) => console.log(organizations))\n","// Enums\nexport enum Provider {\n GOOGLE = 'google',\n MICROSOFT = 'microsoft',\n}\n\nexport enum CalendarAccessRoles {\n FreeBusyReader = 'freeBusyReader',\n Reader = 'reader',\n Writer = 'writer',\n Owner = 'owner',\n}\n\nexport enum AttendeeResponseStatus {\n NeedsAction = 'needsAction',\n Accepted = 'accepted',\n Tentative = 'tentative',\n Declined = 'declined',\n}\n\n// Types\n\nexport type Calendar = {\n id: string\n timeZone?: string\n subject?: string\n backgroundColor?: string\n foregroundColor?: string\n selected?: boolean\n accessRole?: CalendarAccessRoles\n original?: unknown\n}\n\nexport type Meeting = {\n url: string\n}\n\nexport type Attendee = {\n email: string\n original: unknown\n} & (\n | {\n responseStatus?: AttendeeResponseStatus\n }\n | {\n self: true\n }\n)\n\nexport type Event = {\n id: string\n metaId?: string\n subject?: string\n description?: string\n start?: Date\n end?: Date\n location?: string\n attendees: Attendee[]\n meeting?: Meeting\n original: unknown\n}\n\nexport type TimeRange = {\n start: Date\n end: Date\n}\n\nexport type FreeBusy = {\n calendarId: string\n busy: TimeRange[]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCO,IAAK,WAAL,kBAAKA,cAAL;AACH,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,eAAY;AAFJ,SAAAA;AAAA,GAAA;AAKL,IAAK,sBAAL,kBAAKC,yBAAL;AACH,EAAAA,qBAAA,oBAAiB;AACjB,EAAAA,qBAAA,YAAS;AACT,EAAAA,qBAAA,YAAS;AACT,EAAAA,qBAAA,WAAQ;AAJA,SAAAA;AAAA,GAAA;AAOL,IAAK,yBAAL,kBAAKC,4BAAL;AACH,EAAAA,wBAAA,iBAAc;AACd,EAAAA,wBAAA,cAAW;AACX,EAAAA,wBAAA,eAAY;AACZ,E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Range, UpdateEvent, UpdateEventAcrossCalendars } from 'src/types/calendar.types';
2
- import type { FetchHelper } from 'src/utils/fetch.helper';
1
+ import type { Busy, CreateEvent, CreateEventAcrossCalendars, Event, Provider, TimeRange, UpdateEvent, UpdateEventAcrossCalendars } from '../types/calendar.types';
2
+ import type { FetchHelper } from '../utils/fetch.helper';
3
3
  export declare class CalendarService {
4
4
  private fetchHelper;
5
5
  constructor(fetchHelper: FetchHelper);
@@ -1 +1 @@
1
- {"version":3,"file":"calendar.service.d.ts","sourceRoot":"","sources":["../../src/services/calendar.service.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACR,IAAI,EACJ,WAAW,EACX,0BAA0B,EAC1B,KAAK,EACL,QAAQ,EACR,SAAS,EACT,WAAW,EACX,0BAA0B,EAC7B,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAGzD,qBAAa,eAAe;IACZ,OAAO,CAAC,WAAW;gBAAX,WAAW,EAAE,WAAW;IAM5C;;;;;;OAMG;IACU,OAAO,CAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,EACb,OAAO,CAAC,EAAE;QACN,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE,CAAA;QAChC,QAAQ,CAAC,EAAE,MAAM,CAAA;KACpB,GACF,OAAO,CAAC,IAAI,CAAC;IAsBhB;;;;;;OAMG;IACU,SAAS,CAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,EACb,OAAO,CAAC,EAAE;QACN,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE,CAAA;QAChC,QAAQ,CAAC,EAAE,MAAM,CAAA;KACpB,GACF,OAAO,CAAC,KAAK,EAAE,CAAC;IA2BnB;;;;;OAKG;IACU,gBAAgB,CACzB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,O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typebox';
2
+ import { EventNotFoundError, OAuthConnectionNotFoundError, OrganizationNotFoundError, ProviderCredentialsNotSetError, UserNotFoundError, } from '../errors.js';
3
+ import { busySchema, eventSchema, timeRangeSchema } from '../typebox/calendar.tb.js';
4
+ import { errorHandler } from '../utils/fetch.helper.js';
5
+ export class CalendarService {
6
+ fetchHelper;
7
+ constructor(fetchHelper) {
8
+ this.fetchHelper = fetchHelper;
9
+ }
10
+ // ==========================================
11
+ // MARK: User Calendar - Busy & Events
12
+ // ==========================================
13
+ /**
14
+ * @param userId The ID of the user
15
+ * @param minDate The start date of the free/busy period
16
+ * @param maxDate The end date of the free/busy period
17
+ * @param options The options for the free/busy query (optional)
18
+ * @returns The free/busy period
19
+ */
20
+ async getBusy(userId, minDate, maxDate, options) {
21
+ const { provider, timeZone } = options || {};
22
+ return this.fetchHelper
23
+ .get(`/v1/users/${userId}/calendar/busy`, {
24
+ schema: busySchema,
25
+ searchParams: { minDate, maxDate, provider },
26
+ headers: timeZone ? { 'x-timezone': timeZone } : undefined,
27
+ })
28
+ .catch(errorHandler([
29
+ {
30
+ code: 400,
31
+ error: new OAuthConnectionNotFoundError(userId, Array.isArray(provider) ? provider.join(',') : provider || 'all'),
32
+ },
33
+ { code: 404, error: new UserNotFoundError(userId) },
34
+ ]));
35
+ }
36
+ /**
37
+ * @param userId The ID of the user
38
+ * @param minDate The start date of the events
39
+ * @param maxDate The end date of the events
40
+ * @param options The options for the events query (optional)
41
+ * @returns The events
42
+ */
43
+ async getEvents(userId, minDate, maxDate, options) {
44
+ const { provider, timeZone } = options || {};
45
+ return this.fetchHelper
46
+ .get(`/v1/users/${userId}/calendar/events`, {
47
+ schema: T.Array(eventSchema),
48
+ searchParams: { minDate, maxDate, provider },
49
+ headers: timeZone ? { 'x-timezone': timeZone } : undefined,
50
+ })
51
+ .catch(errorHandler([
52
+ {
53
+ code: 400,
54
+ error: new OAuthConnectionNotFoundError(userId, Array.isArray(provider) ? provider.join(',') : provider || 'unknown'),
55
+ statusTextInclFilter: 'User has not the needed calendars connected',
56
+ },
57
+ { code: 404, error: new UserNotFoundError(userId) },
58
+ ]));
59
+ }
60
+ // ==========================================
61
+ // MARK: Meta Event Operations (Cross-Calendar)
62
+ // ==========================================
63
+ /**
64
+ * @param userId The ID of the user
65
+ * @param metaId The meta ID of the event
66
+ * @param options The options for the event query (optional)
67
+ * @returns The event
68
+ */
69
+ async getEventByMetaId(userId, metaId, options) {
70
+ const { provider, timeZone } = options || {};
71
+ return this.fetchHelper
72
+ .get(`/v1/users/${userId}/calendar/events/meta/${metaId}`, {
73
+ schema: eventSchema,
74
+ searchParams: { provider },
75
+ headers: timeZone ? { 'x-timezone': timeZone } : undefined,
76
+ })
77
+ .catch(errorHandler([
78
+ {
79
+ code: 400,
80
+ error: new OAuthConnectionNotFoundError(userId, Array.isArray(provider) ? provider.join(',') : provider || 'unknown'),
81
+ },
82
+ { code: 404, error: new UserNotFoundError(userId), statusTextInclFilter: 'User not found' },
83
+ { code: 404, error: new EventNotFoundError(metaId) },
84
+ ]));
85
+ }
86
+ /**
87
+ * @param userId The ID of the user
88
+ * @param event The event to create
89
+ * @param options The options for the event creation (optional)
90
+ * @returns The created event
91
+ */
92
+ async createEventByMetaId(userId, event, options) {
93
+ const { provider, timeZone } = options || {};
94
+ return this.fetchHelper
95
+ .post(`/v1/users/${userId}/calendar/events/meta`, {
96
+ schema: eventSchema,
97
+ searchParams: { provider },
98
+ headers: timeZone ? { 'x-timezone': timeZone } : undefined,
99
+ body: { event },
100
+ })
101
+ .catch(errorHandler([
102
+ {
103
+ code: 400,
104
+ error: new OAuthConnectionNotFoundError(userId, Array.isArray(provider) ? provider.join(',') : provider || 'unknown'),
105
+ },
106
+ { code: 404, error: new UserNotFoundError(userId) },
107
+ ]));
108
+ }
109
+ /**
110
+ * @param userId The ID of the user
111
+ * @param metaId The meta ID of the event
112
+ * @param event The updated event
113
+ * @param options The options for the event update (optional)
114
+ * @returns The updated event
115
+ */
116
+ async updateEventByMetaId(userId, metaId, event, options) {
117
+ const { provider, timeZone } = options || {};
118
+ return this.fetchHelper
119
+ .put(`/v1/users/${userId}/calendar/events/meta/${metaId}`, {
120
+ schema: eventSchema,
121
+ searchParams: { provider },
122
+ headers: timeZone ? { 'x-timezone': timeZone } : undefined,
123
+ body: { event },
124
+ })
125
+ .catch(errorHandler([
126
+ {
127
+ code: 400,
128
+ error: new OAuthConnectionNotFoundError(userId, Array.isArray(provider) ? provider.join(',') : provider || 'unknown'),
129
+ },
130
+ { code: 404, error: new UserNotFoundError(userId), statusTextInclFilter: 'User not found' },
131
+ { code: 404, error: new EventNotFoundError(metaId) },
132
+ ]));
133
+ }
134
+ /**
135
+ * @param userId The ID of the user
136
+ * @param metaId The meta ID of the event
137
+ * @param options The options for the event deletion (optional)
138
+ * @returns void
139
+ */
140
+ async deleteEventByMetaId(userId, metaId, options) {
141
+ const { provider, timeZone } = options || {};
142
+ return this.fetchHelper
143
+ .delete(`/v1/users/${userId}/calendar/events/meta/${metaId}`, {
144
+ searchParams: { provider },
145
+ headers: timeZone ? { 'x-timezone': timeZone } : undefined,
146
+ schema: T.Void(),
147
+ })
148
+ .catch(errorHandler([
149
+ {
150
+ code: 400,
151
+ error: new OAuthConnectionNotFoundError(userId, Array.isArray(provider) ? provider.join(',') : provider || 'unknown'),
152
+ },
153
+ { code: 404, error: new UserNotFoundError(userId) },
154
+ ]));
155
+ }
156
+ // ==========================================
157
+ // MARK: Provider-Specific Event Operations
158
+ // ==========================================
159
+ /**
160
+ * @param userId The ID of the user
161
+ * @param provider The provider of the calendar
162
+ * @param calendarId The ID of the calendar
163
+ * @param eventId The ID of the event
164
+ * @param options The options for the event query (optional)
165
+ * @returns The event
166
+ */
167
+ async getEvent({ userId, provider, calendarId = 'primary', eventId, options, }) {
168
+ const { timeZone } = options || {};
169
+ return this.fetchHelper
170
+ .get(`/v1/users/${userId}/calendar/events/${provider}/${calendarId}/${eventId}`, {
171
+ schema: eventSchema,
172
+ headers: timeZone ? { 'x-timezone': timeZone } : undefined,
173
+ })
174
+ .catch(errorHandler([
175
+ {
176
+ code: 400,
177
+ error: new OAuthConnectionNotFoundError(userId, provider),
178
+ statusTextInclFilter: 'User has not connected this calendar provider',
179
+ },
180
+ { code: 404, error: new UserNotFoundError(userId), statusTextInclFilter: 'User not found' },
181
+ { code: 404, error: new EventNotFoundError(eventId), statusTextInclFilter: 'Event not found' },
182
+ { code: 404, error: new ProviderCredentialsNotSetError(provider) },
183
+ ]));
184
+ }
185
+ /**
186
+ * @param userId The ID of the user
187
+ * @param provider The provider of the calendar
188
+ * @param calendarId The ID of the calendar
189
+ * @param event The event to create
190
+ * @param options The options for the event creation (optional)
191
+ * @returns The created event
192
+ */
193
+ async createEvent({ userId, provider, calendarId = 'primary', event, options, }) {
194
+ const { timeZone } = options || {};
195
+ return this.fetchHelper
196
+ .post(`/v1/users/${userId}/calendar/events/${provider}/${calendarId}`, {
197
+ schema: eventSchema,
198
+ headers: timeZone ? { 'x-timezone': timeZone } : undefined,
199
+ body: { event },
200
+ })
201
+ .catch(errorHandler([
202
+ {
203
+ code: 400,
204
+ error: new OAuthConnectionNotFoundError(userId, provider),
205
+ statusTextInclFilter: 'User has not connected this calendar provider',
206
+ },
207
+ { code: 404, error: new UserNotFoundError(userId), statusTextInclFilter: 'User not found' },
208
+ { code: 404, error: new ProviderCredentialsNotSetError(provider) },
209
+ ]));
210
+ }
211
+ /**
212
+ * @param userId The ID of the user
213
+ * @param provider The provider of the calendar
214
+ * @param calendarId The ID of the calendar
215
+ * @param eventId The ID of the event
216
+ * @param event The updated event
217
+ * @param options The options for the event update (optional)
218
+ * @returns The updated event
219
+ */
220
+ async updateEvent({ userId, provider, calendarId = 'primary', eventId, event, options, }) {
221
+ const { timeZone } = options || {};
222
+ return this.fetchHelper
223
+ .put(`/v1/users/${userId}/calendar/events/${provider}/${calendarId}/${eventId}`, {
224
+ schema: eventSchema,
225
+ headers: timeZone ? { 'x-timezone': timeZone } : undefined,
226
+ body: { event },
227
+ })
228
+ .catch(errorHandler([
229
+ {
230
+ code: 400,
231
+ error: new OAuthConnectionNotFoundError(userId, provider),
232
+ statusTextInclFilter: 'User has not connected this calendar provider',
233
+ },
234
+ { code: 404, error: new UserNotFoundError(userId), statusTextInclFilter: 'User not found' },
235
+ { code: 404, error: new ProviderCredentialsNotSetError(provider) },
236
+ ]));
237
+ }
238
+ /**
239
+ * @param userId The ID of the user
240
+ * @param provider The provider of the calendar
241
+ * @param calendarId The ID of the calendar
242
+ * @param eventId The ID of the event
243
+ * @param options The options for the event deletion (optional)
244
+ * @returns void
245
+ */
246
+ async deleteEvent({ userId, provider, calendarId = 'primary', eventId, options, }) {
247
+ const { timeZone } = options || {};
248
+ return this.fetchHelper
249
+ .delete(`/v1/users/${userId}/calendar/events/${provider}/${calendarId}/${eventId}`, {
250
+ headers: timeZone ? { 'x-timezone': timeZone } : undefined,
251
+ schema: T.Void(),
252
+ })
253
+ .catch(errorHandler([
254
+ {
255
+ code: 400,
256
+ error: new OAuthConnectionNotFoundError(userId, provider),
257
+ statusTextInclFilter: 'User has not connected this calendar provider',
258
+ },
259
+ { code: 404, error: new UserNotFoundError(userId) },
260
+ { code: 404, error: new EventNotFoundError(eventId) },
261
+ ]));
262
+ }
263
+ // ==========================================
264
+ // MARK: Organization-Wide Operations
265
+ // ==========================================
266
+ /**
267
+ * Get the org-wide busy period
268
+ * @param slug The slug of the organization
269
+ * @param minDate The minimum date
270
+ * @param maxDate The maximum date
271
+ * @param primaryOnly Whether to only include the primary calendar (default: true)
272
+ * @param options The options for the org-wide free/busy query (optional)
273
+ * @returns The org-wide free/busy period
274
+ */
275
+ async getOrgWideBusy(slug, minDate, maxDate, primaryOnly, options) {
276
+ const { provider, timeZone } = options || {};
277
+ return this.fetchHelper
278
+ .get(`/v1/organizations/${slug}/calendar/busy`, {
279
+ schema: T.Array(timeRangeSchema),
280
+ searchParams: { minDate, maxDate, primaryOnly, provider },
281
+ headers: timeZone ? { 'x-timezone': timeZone } : undefined,
282
+ })
283
+ .catch(errorHandler([
284
+ {
285
+ code: 400,
286
+ error: new Error(`OAuth credentials for provider ${provider} not found for the user`),
287
+ },
288
+ { code: 404, error: new OrganizationNotFoundError(slug) },
289
+ ]));
290
+ }
291
+ }
292
+ //# sourceMappingURL=calendar.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar.service.js","sourceRoot":"","sources":["../../src/services/calendar.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,CAAC,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EACH,kBAAkB,EAClB,4BAA4B,EAC5B,yBAAyB,EACzB,8BAA8B,EAC9B,iBAAiB,GACpB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAYhF,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEnD,MAAM,OAAO,eAAe;IACJ;IAApB,YAAoB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAEhD,6CAA6C;IAC7C,sCAAsC;IACtC,6CAA6C;IAE7C;;;;;;OAMG;IACI,KAAK,CAAC,OAAO,CAChB,MAAc,EACd,OAAa,EACb,OAAa,EACb,OAGC;QAED,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;QAC5C,OAAO,IAAI,CAAC,WAAW;aAClB,GAAG,CAAC,aAAa,MAAM,gBAAgB,EAAE;YACtC,MAAM,EAAE,UAAU;YAClB,YAAY,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE;YAC5C,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS;SAC7D,CAAC;aACD,KAAK,CACF,YAAY,CAAC;YACT;gBACI,IAAI,EAAE,GAAG;gBACT,KAAK,EAAE,IAAI,4BAA4B,C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AY,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS;SAC7D,CAAC;aACD,KAAK,CACF,YAAY,CAAC;YACT;gBACI,IAAI,EAAE,GAAG;gBACT,KAAK,EAAE,IAAI,KAAK,CAAC,kCAAkC,QAAQ,yBAAyB,CAAC;aACxF;YACD,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,yBAAyB,CAAC,IAAI,CAAC,EAAE;SAC5D,CAAC,CACL,CAAA;IACT,CAAC;CACJ"}
@@ -0,0 +1,168 @@
1
+ import { Type as T } from '@sinclair/typebox';
2
+ import { OAuthConnectionNotFoundError, ProviderCredentialsNotSetError, UserNotFoundError } from '../errors.js';
3
+ import { oauthConnectionSchema, oauthLinkSchema } from '../typebox/oauth.tb.js';
4
+ import { errorHandler } from '../utils/fetch.helper.js';
5
+ export class OAuthService {
6
+ fetchHelper;
7
+ constructor(fetchHelper) {
8
+ this.fetchHelper = fetchHelper;
9
+ }
10
+ /**
11
+ * Get all OAuth connections for a user
12
+ * @param userId The ID of the user
13
+ * @param redacted Whether to redact the OAuth connections
14
+ * @returns An array of OAuth connections
15
+ */
16
+ async getAllConnections(userId, redacted = true) {
17
+ return this.fetchHelper
18
+ .get(`/v1/users/${userId}/oauth`, {
19
+ schema: T.Array(oauthConnectionSchema),
20
+ searchParams: { redacted },
21
+ })
22
+ .catch(errorHandler([{ code: 404, error: new UserNotFoundError(userId) }]));
23
+ }
24
+ /**
25
+ * Get OAuth connection for a specific provider
26
+ * @param userId The ID of the user
27
+ * @param provider The provider of the OAuth connection
28
+ * @param redacted Whether to redact the OAuth connection
29
+ * @returns The OAuth connection
30
+ */
31
+ async getConnection(userId, provider, redacted = true) {
32
+ return this.fetchHelper
33
+ .get(`/v1/users/${userId}/oauth/${provider}`, {
34
+ schema: oauthConnectionSchema,
35
+ searchParams: { redacted },
36
+ })
37
+ .catch(errorHandler([
38
+ {
39
+ code: 404,
40
+ statusTextInclFilter: 'OAuth connection not found',
41
+ error: new OAuthConnectionNotFoundError(userId, provider),
42
+ },
43
+ { code: 404, error: new UserNotFoundError(userId) },
44
+ ]));
45
+ }
46
+ /**
47
+ * Get OAuth authorization URLs for all providers
48
+ * @param userId The ID of the user
49
+ * @param options Options for the OAuth authorization URLs
50
+ * @returns An array of OAuth authorization URLs
51
+ */
52
+ async getBulkLinks(userId, options) {
53
+ return this.fetchHelper
54
+ .get(`/v1/users/${userId}/oauth/links`, {
55
+ schema: T.Array(oauthLinkSchema),
56
+ searchParams: {
57
+ provider: options?.provider,
58
+ scope: options?.scope,
59
+ accessType: options?.accessType,
60
+ },
61
+ })
62
+ .catch(errorHandler([{ code: 404, error: new UserNotFoundError(userId) }]));
63
+ }
64
+ /**
65
+ * Get OAuth authorization URL for a specific provider
66
+ * @param userId The ID of the user
67
+ * @param provider The provider of the OAuth connection
68
+ * @param options Options for the OAuth authorization URL
69
+ * @returns The OAuth authorization URL
70
+ */
71
+ async getLink(userId, provider, options) {
72
+ const response = await this.fetchHelper
73
+ .get(`/v1/users/${userId}/oauth/${provider}/link`, {
74
+ schema: T.Object({ url: T.String() }),
75
+ searchParams: {
76
+ scope: options?.scope,
77
+ accessType: options?.accessType,
78
+ redirectUrl: options?.redirectUrl,
79
+ },
80
+ })
81
+ .catch(errorHandler([
82
+ {
83
+ code: 404,
84
+ statusTextInclFilter: 'OAuth credentials not found',
85
+ error: new ProviderCredentialsNotSetError(provider),
86
+ },
87
+ { code: 404, error: new UserNotFoundError(userId) },
88
+ ]));
89
+ return { provider, url: response.url };
90
+ }
91
+ /**
92
+ * Set OAuth tokens for a provider
93
+ * @param userId The ID of the user
94
+ * @param provider The provider of the OAuth connection
95
+ * @param connection The OAuth connection to set
96
+ * @returns The OAuth connection
97
+ */
98
+ async setConnection(userId, provider, connection) {
99
+ return this.fetchHelper
100
+ .post(`/v1/users/${userId}/oauth/${provider}`, {
101
+ schema: oauthConnectionSchema,
102
+ body: connection,
103
+ })
104
+ .catch(errorHandler([
105
+ {
106
+ code: 404,
107
+ statusTextInclFilter: 'OAuth connection not found',
108
+ error: new OAuthConnectionNotFoundError(userId, provider),
109
+ },
110
+ { code: 404, error: new UserNotFoundError(userId) },
111
+ ]));
112
+ }
113
+ /**
114
+ * Delete OAuth connection for a provider
115
+ * @param userId The ID of the user
116
+ * @param provider The provider of the OAuth connection
117
+ * @returns Promise that resolves when the connection is deleted
118
+ */
119
+ async disconnect(userId, provider) {
120
+ await this.fetchHelper
121
+ .delete(`/v1/users/${userId}/oauth/${provider}`, {
122
+ schema: T.Object({ success: T.Boolean() }),
123
+ })
124
+ .catch(errorHandler([
125
+ {
126
+ code: 404,
127
+ statusTextInclFilter: 'OAuth connection not found',
128
+ error: new OAuthConnectionNotFoundError(userId, provider),
129
+ },
130
+ { code: 404, error: new UserNotFoundError(userId) },
131
+ ]));
132
+ }
133
+ /**
134
+ * Verify OAuth code (used in OAuth callback flow)
135
+ * @param provider The provider of the OAuth connection
136
+ * @param code The OAuth code
137
+ * @param scope The OAuth scope (free-busy or edit)
138
+ * @param state The OAuth state
139
+ * @param redirectUrl The redirect URL
140
+ * @returns The OAuth verification result
141
+ */
142
+ async verify(provider, code, scope, state, redirectUrl) {
143
+ return this.fetchHelper
144
+ .post(`/v1/users/oauth/${provider}/verify`, {
145
+ body: { code, scope, state },
146
+ schema: T.Object({ success: T.Boolean() }),
147
+ searchParams: { redirectUrl },
148
+ })
149
+ .catch(errorHandler([
150
+ {
151
+ code: 404,
152
+ statusTextInclFilter: 'OAuth authorization provider not found',
153
+ error: new ProviderCredentialsNotSetError(provider),
154
+ },
155
+ { code: 404, error: new UserNotFoundError('User not found in state parameter') },
156
+ {
157
+ code: 400,
158
+ statusTextInclFilter: 'OAuth credentials not configured',
159
+ error: new ProviderCredentialsNotSetError(provider),
160
+ },
161
+ {
162
+ code: 400,
163
+ error: new Error('Invalid OAuth verification request'),
164
+ },
165
+ ]));
166
+ }
167
+ }
168
+ //# sourceMappingURL=oauth.service.js.map
@@ -0,0 +1 @@
1
+ {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AAC,MAAM,CACf,QAAkB,EAClB,IAAY,EACZ,KAA2B,EAC3B,KAAa,EACb,WAAoB;QAEpB,OAAO,IAAI,CAAC,WAAW;aAClB,IAAI,CAAC,mBAAmB,QAAQ,SAAS,EAAE;YACxC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE;YAC5B,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;YAC1C,YAAY,EAAE,EAAE,WAAW,EAAE;SAChC,CAAC;aACD,KAAK,CACF,YAAY,CAAC;YACT;gBACI,IAAI,EAAE,GAAG;gBACT,oBAAoB,EAAE,wCAAwC;gBAC9D,KAAK,EAAE,IAAI,8BAA8B,CAAC,QAAQ,CAAC;aACtD;YACD,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,iBAAiB,CAAC,mCAAmC,CAAC,EAAE;YAChF;gBACI,IAAI,EAAE,GAAG;gBACT,oBAAoB,EAAE,kCAAkC;gBACxD,KAAK,EAAE,IAAI,8BAA8B,CAAC,QAAQ,CAAC;aACtD;YACD;gBACI,IAAI,EAAE,GAAG;gBACT,KAAK,EAAE,IAAI,KAAK,CAAC,oCAAoC,CAAC;aACzD;SACJ,CAAC,CACL,CAAA;IACT,CAAC;CACJ"}
@@ -1,4 +1,4 @@
1
- import { User } from 'src/entities/user';
1
+ import { User } from '../entities/user';
2
2
  import { Organization } from '../entities/organization';
3
3
  import { type FetchHelper } from '../utils/fetch.helper';
4
4
  export declare class OrganizationsService {
@@ -1 +1 @@
1
- {"version":3,"file":"organizations.service.d.ts","sourceRoot":"","sources":["../../src/services/organizations.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAGvD,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAA;AA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