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

addcal

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

addcal - npm Package Compare versions

Comparing version 1.0.2 to 2.0.0

.babelrc

18

package.json
{
"name": "addcal",
"version": "1.0.2",
"version": "2.0.0",
"description": "Open-source web application utility for adding calendar events via certain platform API's (Google, etc.)",
"main": "src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jest"
},

@@ -18,3 +18,15 @@ "repository": {

},
"homepage": "https://github.com/daleyjem/addcal#readme"
"homepage": "https://github.com/daleyjem/addcal#readme",
"devDependencies": {
"@babel/core": "^7.2.0",
"@babel/preset-env": "^7.2.0",
"globby": "^8.0.1",
"jest": "^23.6.0"
},
"resolutions": {
"babel-core": "7.0.0-bridge.0"
},
"dependencies": {
"ics-browser-es": "https://github.com/daleyjem/ics.git"
}
}

2

README.md

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

# AddCal
# AddCal [![Build Status](https://travis-ci.org/daleyjem/addcal.svg?branch=master)](https://travis-ci.org/daleyjem/addcal)

@@ -3,0 +3,0 @@ Open-source web application utility for adding calendar events via certain platform API's (Google, etc.)

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

import GoogleCalendar from "./lib/services/google";
import GoogleCalendar from './lib/services/platforms/google';
import ICalTransformer from './lib/transformers/ical';

@@ -14,3 +15,12 @@ export default {

}
},
generators: {
ical: {
transformer: ICalTransformer,
charset: 'utf-8',
extension: 'ics',
mimetype: 'text/calendar'
}
}
}
import appConfig from './config';
import download from './lib/utils/downloader';

@@ -8,4 +9,4 @@ export default class AddCal {

*/
constructor(config) {
this.config = config;
constructor(apiConfig) {
this.apiConfig = apiConfig;
this.activeServices = {};

@@ -21,8 +22,9 @@ this.servicesReady = [];

init() {
for (const [service, serviceConfig] of Object.entries(this.config)){
const _class = new appConfig.services[service].class(serviceConfig);
this.activeServices[service] = _class;
for (const [service, apiConfig] of Object.entries(this.apiConfig)){
const serviceConfig = appConfig.services[service];
const _class = new serviceConfig.class(serviceConfig, apiConfig);
_class.onAPIReady = this.onServiceAPIReady.bind(this);
_class.onAPIFailed = this.onServiceAPIFailed.bind(this);
_class.init(this.onServiceAPIReady.bind(this));
this.activeServices[service] = _class;
}

@@ -34,3 +36,3 @@ }

* @param {string} service The service to add the event to ('google', 'yahoo', etc.)
* @param {*} eventParams The data to add to the user's calendar service
* @param {EventParms} eventParams The data to add to the user's calendar service
*/

@@ -48,2 +50,21 @@ async addEvent(service, eventParams) {

/**
* Forces the browser to download a calendar event of type specified by `generator` param
* @param {string} generator The generator to use for creating the file to download
* @param {EventParams} eventParams The data to add to the event file
* @param {*} options Options for download
* @param {string} options.filename Filename of file being downloaded
*/
static download(generator, eventParams, options = {}) {
const _generator = appConfig.generators[generator];
const transformer = _generator.transformer;
const fileData = transformer(eventParams);
download(fileData, {
filename: `${options.filename || 'event'}.${_generator.extension}`,
charset: _generator.charset,
mimetype: _generator.mimetype
});
}
/**
* @private

@@ -67,1 +88,6 @@ * @param {string} service The service who's API is ready to interact with (i.e. 'google', 'yahoo', etc.)

}
export {default as EventParams} from './lib/models/event-params';
export const generators = {
ICALENDAR: 'ical'
};

@@ -1,3 +0,1 @@

import appConfig from '../../config';
/**

@@ -9,12 +7,10 @@ * @typedef Calendar

* Base calendar object to extend from for calendar service API's (i.e. google, yahoo, etc.)
* @param {string} service Name of the service that matches key in root `config.js`
* @param {object} config Developer configuration options for the service API
* @param {object} serviceConfig App configuration options for service
* @param {object} apiConfig Developer configuration options for the service API
*/
constructor(service, config){
constructor(serviceConfig, apiConfig){
// App config options for service
this.serviceConfig = serviceConfig;
// Dev API config options (API_KEY, etc.)
this.config = config;
// Name of service (google, yahoo, etc.)
this.service = service;
// App config options
this.serviceConfig = appConfig.services[this.service];
this.apiConfig = apiConfig;

@@ -42,5 +38,5 @@ /**

}
script.src = appConfig.services[this.service].src;
script.src = this.serviceConfig.src;
head.appendChild(script);
}
}

@@ -1,22 +0,36 @@

export default (eventConfig) => {
/**
* @param {EventParams} eventParams The EventParams object to transform
*/
export default (eventParams) => {
eventParams.extra = eventParams.extra || {};
const _dur = eventParams.duration / 60;
const durHours = Math.floor(_dur / 60);
const durMinutes = (_dur - durHours) * 60;
let endDate = eventParams.start;
endDate.setHours(endDate.getHours() + durHours);
endDate.setMinutes(endDate.getMinutes() + durMinutes);
const config = {
calendarId: eventConfig.calendarId || 'primary',
summary: eventConfig.title,
description: eventConfig.description,
calendarId: eventParams.extra.calendarId || 'primary',
summary: eventParams.summary,
description: eventParams.description,
start: {
dateTime: eventConfig.start
dateTime: eventParams.start
},
end: {
dateTime: eventConfig.end
dateTime: endDate
},
reminders: {
useDefault: eventConfig.reminders === undefined
}
useDefault: eventParams.reminders === undefined
},
url: eventParams.url
};
if (eventConfig.recurrence) {
config.recurrence = generateRecurrence(eventConfig.recurrence);
if (eventParams.recurrence) {
config.recurrence = generateRecurrence(eventParams.recurrence);
}
if (eventConfig.reminders) {
if (eventParams.reminders) {
config.reminders.useDefault = false;

@@ -23,0 +37,0 @@ /**

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