Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-google-calendar-api

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-google-calendar-api - npm Package Compare versions

Comparing version 2.2.2 to 2.3.0

9

dist/ApiCalendar.d.ts

@@ -13,5 +13,9 @@ interface ConfigApiCalendar {

interface ExtendedTokenClient extends google.accounts.oauth2.TokenClient {
callback?: (resp: any) => void;
error_callback?: (resp: any) => void;
}
declare class ApiCalendar {
config: ConfigApiCalendar;
tokenClient: google.accounts.oauth2.TokenClient | null;
tokenClient: ExtendedTokenClient | null;
onLoadCallback: any;

@@ -32,4 +36,5 @@ calendar: string;

* Sign in Google user account
* @returns {Promise<void>} Promise resolved if authentication is successful, rejected if unsuccessful.
*/
handleAuthClick(): void;
handleAuthClick(): Promise<void>;
/**

@@ -36,0 +41,0 @@ * Set the default attribute calendar

@@ -0,1 +1,2 @@

"use strict";
var __defProp = Object.defineProperty;

@@ -35,2 +36,22 @@ var __defProps = Object.defineProperties;

var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};

@@ -72,2 +93,5 @@ // src/ApiCalendar.ts

}
/**
* Auth to the google Api.
*/
initGapiClient() {

@@ -86,2 +110,6 @@ gapi.client.init({

}
/**
* Init Google Api
* And create gapi in global
*/
handleClientLoad() {

@@ -101,4 +129,4 @@ const scriptGoogle = document.createElement("script");

};
scriptGoogle.onload = async () => {
this.tokenClient = await google.accounts.oauth2.initTokenClient({
scriptGoogle.onload = () => __async(this, null, function* () {
this.tokenClient = yield google.accounts.oauth2.initTokenClient({
client_id: this.config.clientId,

@@ -110,21 +138,45 @@ scope: this.config.scope,

});
};
});
}
/**
* Sign in Google user account
* @returns {Promise<void>} Promise resolved if authentication is successful, rejected if unsuccessful.
*/
handleAuthClick() {
if (gapi && this.tokenClient) {
if (gapi.client.getToken() === null) {
this.tokenClient.requestAccessToken({ prompt: "consent" });
return __async(this, null, function* () {
if (gapi && this.tokenClient) {
return new Promise((resolve, reject) => {
this.tokenClient.callback = (resp) => {
if (resp.error) {
reject(resp);
} else {
resolve(resp);
}
};
this.tokenClient.error_callback = (resp) => {
reject(resp);
};
if (gapi.client.getToken() === null) {
this.tokenClient.requestAccessToken({ prompt: "consent" });
} else {
this.tokenClient.requestAccessToken({ prompt: "" });
}
});
} else {
this.tokenClient.requestAccessToken({
prompt: ""
});
console.error("Error: this.gapi not loaded");
return Promise.reject(new Error("Error: this.gapi not loaded"));
}
} else {
console.error("Error: this.gapi not loaded");
new Error("Error: this.gapi not loaded");
}
});
}
/**
* Set the default attribute calendar
* @param {string} newCalendar
*/
setCalendar(newCalendar) {
this.calendar = newCalendar;
}
/**
* Execute the callback function when gapi is loaded
* @param callback
*/
onLoad(callback) {

@@ -137,2 +189,5 @@ if (gapi) {

}
/**
* Sign out user google account
*/
handleSignoutClick() {

@@ -151,2 +206,8 @@ if (gapi) {

}
/**
* List all events in the calendar
* @param {number} maxResults to see
* @param {string} calendarId to see by default use the calendar attribute
* @returns {any}
*/
listUpcomingEvents(maxResults, calendarId = this.calendar) {

@@ -156,3 +217,3 @@ if (gapi) {

calendarId,
timeMin: new Date().toISOString(),
timeMin: (/* @__PURE__ */ new Date()).toISOString(),
showDeleted: false,

@@ -168,2 +229,9 @@ singleEvents: true,

}
/**
* List all events in the calendar queried by custom query options
* See all available options here https://developers.google.com/calendar/v3/reference/events/list
* @param {object} queryOptions to see
* @param {string} calendarId to see by default use the calendar attribute
* @returns {any}
*/
listEvents(queryOptions, calendarId = this.calendar) {

@@ -179,2 +247,11 @@ if (gapi) {

}
/**
* Create an event from the current time for a certain period
* @param {number} time in minutes for the event
* @param {string} summary of the event
* @param {string} description of the event
* @param {string} calendarId
* @param {string} timeZone The time zone in which the time is specified. (Formatted as an IANA Time Zone Database name, e.g. "Europe/Zurich".)
* @returns {any}
*/
createEventFromNow({ time, summary, description = "" }, calendarId = this.calendar, timeZone = "Europe/Paris") {

@@ -185,7 +262,7 @@ const event = {

start: {
dateTime: new Date().toISOString(),
dateTime: (/* @__PURE__ */ new Date()).toISOString(),
timeZone
},
end: {
dateTime: new Date(new Date().getTime() + time * 6e4).toISOString(),
dateTime: new Date((/* @__PURE__ */ new Date()).getTime() + time * 6e4).toISOString(),
timeZone

@@ -196,2 +273,9 @@ }

}
/**
* Create Calendar event
* @param {string} calendarId for the event.
* @param {object} event with start and end dateTime
* @param {string} sendUpdates Acceptable values are: "all", "externalOnly", "none"
* @returns {any}
*/
createEvent(event, calendarId = this.calendar, sendUpdates = "none") {

@@ -202,2 +286,3 @@ if (gapi.client.getToken()) {

resource: event,
//@ts-ignore the @types/gapi.calendar package is not up to date(https://developers.google.com/calendar/api/v3/reference/events/insert)
sendUpdates,

@@ -211,14 +296,31 @@ conferenceDataVersion: 1

}
/**
* Create Calendar event with video conference
* @param {string} calendarId for the event.
* @param {object} event with start and end dateTime
* @param {string} sendUpdates Acceptable values are: "all", "externalOnly", "none"
* @returns {any}
*/
createEventWithVideoConference(event, calendarId = this.calendar, sendUpdates = "none") {
return this.createEvent(__spreadProps(__spreadValues({}, event), {
conferenceData: {
createRequest: {
requestId: crypto.randomUUID(),
conferenceSolutionKey: {
type: "hangoutsMeet"
return this.createEvent(
__spreadProps(__spreadValues({}, event), {
conferenceData: {
createRequest: {
requestId: crypto.randomUUID(),
conferenceSolutionKey: {
type: "hangoutsMeet"
}
}
}
}
}), calendarId, sendUpdates);
}),
calendarId,
sendUpdates
);
}
/**
* Delete an event in the calendar.
* @param {string} eventId of the event to delete.
* @param {string} calendarId where the event is.
* @returns {any} Promise resolved when the event is deleted.
*/
deleteEvent(eventId, calendarId = this.calendar) {

@@ -235,2 +337,10 @@ if (gapi) {

}
/**
* Update Calendar event
* @param {string} calendarId for the event.
* @param {string} eventId of the event.
* @param {object} event with details to update, e.g. summary
* @param {string} sendUpdates Acceptable values are: "all", "externalOnly", "none"
* @returns {any}
*/
updateEvent(event, eventId, calendarId = this.calendar, sendUpdates = "none") {

@@ -249,2 +359,8 @@ if (gapi) {

}
/**
* Get Calendar event
* @param {string} calendarId for the event.
* @param {string} eventId specifies individual event
* @returns {any}
*/
getEvent(eventId, calendarId = this.calendar) {

@@ -261,2 +377,6 @@ if (gapi) {

}
/**
* Get Calendar List
* @returns {any}
*/
listCalendars() {

@@ -270,2 +390,7 @@ if (gapi) {

}
/**
* Create Calendar
* @param {string} summary, title of the calendar.
* @returns {any}
*/
createCalendar(summary) {

@@ -272,0 +397,0 @@ if (gapi) {

{
"name": "react-google-calendar-api",
"version": "2.2.2",
"version": "2.3.0",
"description": "An api to manage your google calendar",

@@ -5,0 +5,0 @@ "main": "./dist/ApiCalendar.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc