//native
export type DynSelect_calendar = string
export async function calendar(auth: RT.MsOutlook) {
const r = await fetch(
"https://graph.microsoft.com/v1.0/me/calendars?$top=100&$select=id,name",
{
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/json",
},
}
)
if (!r.ok) throw new Error(`${r.status} ${await r.text()}`)
const { value } = (await r.json()) as {
value: { id: string; name: string }[]
}
return value.map((c) => ({ value: c.id, label: c.name }))
}
/**
* Create Calendar Event
* Create an event in the default calendar or a chosen one. `start` and `end` are local times in `time_zone` (`2026-01-15T14:00:00`); attendees receive an invitation. `recurrence` takes a Graph patternedRecurrence object, e.g. `{"pattern":{"type":"weekly","interval":1,"daysOfWeek":["monday"]},"range":{"type":"noEnd","startDate":"2026-01-19"}}`; `extra` takes any other event property. Requires Calendars.ReadWrite (a connection default).
*/
export async function main(
auth: RT.MsOutlook,
subject: string,
start: string,
end: string,
time_zone: string = "UTC",
body: string | undefined,
content_type: "HTML" | "Text" = "HTML",
location: string | undefined,
attendees: string[] | undefined,
is_all_day: boolean = false,
is_online_meeting: boolean = false,
calendar: DynSelect_calendar | undefined,
recurrence: { [key: string]: any } | undefined,
extra: { [key: string]: any } | undefined
) {
const base = `https://graph.microsoft.com/v1.0/me${
calendar != null && calendar !== ""
? `/calendars/${encodeURIComponent(calendar)}`
: ""
}`
const event: { [key: string]: any } = {
...(extra ?? {}),
subject,
start: { dateTime: start, timeZone: time_zone },
end: { dateTime: end, timeZone: time_zone },
isAllDay: is_all_day,
isOnlineMeeting: is_online_meeting,
}
if (body != null && body !== "") {
event.body = { contentType: content_type, content: body }
}
if (location != null && location !== "") {
event.location = { displayName: location }
}
if (attendees?.length) {
event.attendees = attendees.map((address) => ({
emailAddress: { address },
type: "required",
}))
}
if (recurrence != null && Object.keys(recurrence).length > 0) {
event.recurrence = recurrence
}
const response = await fetch(`${base}/events`, {
method: "POST",
headers: {
Authorization: `Bearer ${auth.token}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify(event),
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 2 hours ago
//native
export type DynSelect_calendar = string
export async function calendar(auth: RT.Outlook) {
const r = await fetch(
"https://graph.microsoft.com/v1.0/me/calendars?$top=100&$select=id,name",
{
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/json",
},
}
)
if (!r.ok) throw new Error(`${r.status} ${await r.text()}`)
const { value } = (await r.json()) as {
value: { id: string; name: string }[]
}
return value.map((c) => ({ value: c.id, label: c.name }))
}
/**
* Create Calendar Event
* Create an event in the default calendar or a chosen one. `start` and `end` are local times in `time_zone` (`2026-01-15T14:00:00`); attendees receive an invitation. `recurrence` takes a Graph patternedRecurrence object, e.g. `{"pattern":{"type":"weekly","interval":1,"daysOfWeek":["monday"]},"range":{"type":"noEnd","startDate":"2026-01-19"}}`; `extra` takes any other event property. Requires Calendars.ReadWrite (a connection default).
*/
export async function main(
auth: RT.Outlook,
subject: string,
start: string,
end: string,
time_zone: string = "UTC",
body: string | undefined,
content_type: "HTML" | "Text" = "HTML",
location: string | undefined,
attendees: string[] | undefined,
is_all_day: boolean = false,
is_online_meeting: boolean = false,
calendar: DynSelect_calendar | undefined,
recurrence: { [key: string]: any } | undefined,
extra: { [key: string]: any } | undefined
) {
const base = `https://graph.microsoft.com/v1.0/me${
calendar != null && calendar !== ""
? `/calendars/${encodeURIComponent(calendar)}`
: ""
}`
const event: { [key: string]: any } = {
...(extra ?? {}),
subject,
start: { dateTime: start, timeZone: time_zone },
end: { dateTime: end, timeZone: time_zone },
isAllDay: is_all_day,
isOnlineMeeting: is_online_meeting,
}
if (body != null && body !== "") {
event.body = { contentType: content_type, content: body }
}
if (location != null && location !== "") {
event.location = { displayName: location }
}
if (attendees?.length) {
event.attendees = attendees.map((address) => ({
emailAddress: { address },
type: "required",
}))
}
if (recurrence != null && Object.keys(recurrence).length > 0) {
event.recurrence = recurrence
}
const response = await fetch(`${base}/events`, {
method: "POST",
headers: {
Authorization: `Bearer ${auth.token}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify(event),
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 11 hours ago
//native
export type DynSelect_calendar = string
export async function calendar(auth: RT.Outlook) {
const r = await fetch(
"https://graph.microsoft.com/v1.0/me/calendars?$top=100&$select=id,name",
{
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/json",
},
}
)
if (!r.ok) throw new Error(`${r.status} ${await r.text()}`)
const { value } = (await r.json()) as {
value: { id: string; name: string }[]
}
return value.map((c) => ({ value: c.id, label: c.name }))
}
/**
* Create Calendar Event
* Create an event in the default calendar or a chosen one. `start` and `end` are local times in `time_zone` (`2026-01-15T14:00:00`); attendees receive an invitation. `recurrence` takes a Graph patternedRecurrence object, e.g. `{"pattern":{"type":"weekly","interval":1,"daysOfWeek":["monday"]},"range":{"type":"noEnd","startDate":"2026-01-19"}}`; `extra` takes any other event property. Requires Calendars.ReadWrite on the connection.
*/
export async function main(
auth: RT.Outlook,
subject: string,
start: string,
end: string,
time_zone: string = "UTC",
body: string | undefined,
content_type: "HTML" | "Text" = "HTML",
location: string | undefined,
attendees: string[] | undefined,
is_all_day: boolean = false,
is_online_meeting: boolean = false,
calendar: DynSelect_calendar | undefined,
recurrence: { [key: string]: any } | undefined,
extra: { [key: string]: any } | undefined
) {
const base = `https://graph.microsoft.com/v1.0/me${
calendar != null && calendar !== ""
? `/calendars/${encodeURIComponent(calendar)}`
: ""
}`
const event: { [key: string]: any } = {
...(extra ?? {}),
subject,
start: { dateTime: start, timeZone: time_zone },
end: { dateTime: end, timeZone: time_zone },
isAllDay: is_all_day,
isOnlineMeeting: is_online_meeting,
}
if (body != null && body !== "") {
event.body = { contentType: content_type, content: body }
}
if (location != null && location !== "") {
event.location = { displayName: location }
}
if (attendees?.length) {
event.attendees = attendees.map((address) => ({
emailAddress: { address },
type: "required",
}))
}
if (recurrence != null && Object.keys(recurrence).length > 0) {
event.recurrence = recurrence
}
const response = await fetch(`${base}/events`, {
method: "POST",
headers: {
Authorization: `Bearer ${auth.token}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify(event),
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 11 hours ago