Comparing version 3.6.2 to 3.6.3
@@ -6,14 +6,18 @@ "use strict"; | ||
}); | ||
exports["default"] = void 0; | ||
exports.headerDefaults = exports.eventDefaults = void 0; | ||
var _nanoid = require("nanoid"); | ||
var _utils = require("./utils"); | ||
var defaults = { | ||
title: 'Untitled event', | ||
productId: 'adamgibbons/ics', | ||
method: 'PUBLISH', | ||
uid: (0, _nanoid.nanoid)(), | ||
timestamp: (0, _utils.formatDate)(null, 'utc'), | ||
start: (0, _utils.formatDate)(null, 'utc') | ||
var headerDefaults = function headerDefaults() { | ||
return { | ||
productId: 'adamgibbons/ics', | ||
method: 'PUBLISH' | ||
}; | ||
}; | ||
var _default = defaults; | ||
exports["default"] = _default; | ||
exports.headerDefaults = headerDefaults; | ||
var eventDefaults = function eventDefaults() { | ||
return { | ||
title: 'Untitled event', | ||
uid: (0, _nanoid.nanoid)(), | ||
timestamp: Date.now() | ||
}; | ||
}; | ||
exports.eventDefaults = eventDefaults; |
@@ -9,66 +9,15 @@ "use strict"; | ||
exports.createEvents = createEvents; | ||
var _nanoid = require("nanoid"); | ||
var _pipeline = require("./pipeline"); | ||
function assignUniqueId(event) { | ||
event.uid = event.uid || (0, _nanoid.nanoid)(); | ||
return event; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function buildHeaderAndValidate(header) { | ||
return (0, _pipeline.validateHeader)((0, _pipeline.buildHeader)(header)); | ||
} | ||
function validateAndBuildEvent(event) { | ||
return (0, _pipeline.validateEvent)((0, _pipeline.buildEvent)(event)); | ||
function buildHeaderAndEventAndValidate(event) { | ||
return (0, _pipeline.validateHeaderAndEvent)(_objectSpread(_objectSpread({}, (0, _pipeline.buildHeader)(event)), (0, _pipeline.buildEvent)(event))); | ||
} | ||
function applyInitialFormatting(_ref) { | ||
var error = _ref.error, | ||
value = _ref.value; | ||
if (error) { | ||
return { | ||
error: error, | ||
value: null | ||
}; | ||
} | ||
return { | ||
error: null, | ||
value: (0, _pipeline.formatEvent)(value) | ||
}; | ||
} | ||
function reformatEventsByPosition(_ref2, idx, list) { | ||
var error = _ref2.error, | ||
value = _ref2.value; | ||
if (error) return { | ||
error: error, | ||
value: value | ||
}; | ||
if (idx === 0) { | ||
// beginning of list | ||
return { | ||
value: value.slice(0, value.indexOf('END:VCALENDAR')), | ||
error: null | ||
}; | ||
} | ||
if (idx === list.length - 1) { | ||
// end of list | ||
return { | ||
value: value.slice(value.indexOf('BEGIN:VEVENT')), | ||
error: null | ||
}; | ||
} | ||
return { | ||
error: null, | ||
value: value.slice(value.indexOf('BEGIN:VEVENT'), value.indexOf('END:VEVENT') + 12) | ||
}; | ||
} | ||
function catenateEvents(accumulator, _ref3, idx) { | ||
var error = _ref3.error, | ||
value = _ref3.value; | ||
if (error) { | ||
accumulator.error = error; | ||
accumulator.value = null; | ||
return accumulator; | ||
} | ||
if (accumulator.value) { | ||
accumulator.value = accumulator.value.concat(value); | ||
return accumulator; | ||
} | ||
accumulator.value = value; | ||
return accumulator; | ||
} | ||
function convertTimestampToArray(timestamp) { | ||
@@ -86,78 +35,54 @@ var inputType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'local'; | ||
function createEvent(attributes, cb) { | ||
if (!attributes) { | ||
Error('Attributes argument is required'); | ||
} | ||
assignUniqueId(attributes); | ||
if (!cb) { | ||
// No callback, so return error or value in an object | ||
var _validateAndBuildEven = validateAndBuildEvent(attributes), | ||
_error = _validateAndBuildEven.error, | ||
_value = _validateAndBuildEven.value; | ||
if (_error) return { | ||
error: _error, | ||
value: _value | ||
}; | ||
var event = ''; | ||
try { | ||
event = (0, _pipeline.formatEvent)(_value); | ||
} catch (error) { | ||
return createEvents([attributes], cb); | ||
} | ||
function createEvents(events, headerAttributesOrCb, cb) { | ||
var resolvedHeaderAttributes = _typeof(headerAttributesOrCb) === 'object' ? headerAttributesOrCb : {}; | ||
var resolvedCb = arguments.length === 3 ? cb : typeof headerAttributesOrCb === 'function' ? headerAttributesOrCb : null; | ||
var run = function run() { | ||
if (!events) { | ||
return { | ||
error: error, | ||
error: new Error('one argument is required'), | ||
value: null | ||
}; | ||
} | ||
var _ref = events.length === 0 ? buildHeaderAndValidate(resolvedHeaderAttributes) : buildHeaderAndEventAndValidate(_objectSpread(_objectSpread({}, events[0]), resolvedHeaderAttributes)), | ||
headerError = _ref.error, | ||
headerValue = _ref.value; | ||
if (headerError) { | ||
return { | ||
error: headerError, | ||
value: null | ||
}; | ||
} | ||
var value = ''; | ||
value += (0, _pipeline.formatHeader)(headerValue); | ||
for (var i = 0; i < events.length; i++) { | ||
var _buildHeaderAndEventA = buildHeaderAndEventAndValidate(events[i]), | ||
eventError = _buildHeaderAndEventA.error, | ||
eventValue = _buildHeaderAndEventA.value; | ||
if (eventError) return { | ||
error: eventError, | ||
value: null | ||
}; | ||
value += (0, _pipeline.formatEvent)(eventValue); | ||
} | ||
value += (0, _pipeline.formatFooter)(); | ||
return { | ||
error: null, | ||
value: event | ||
value: value | ||
}; | ||
} | ||
// Return a node-style callback | ||
var _validateAndBuildEven2 = validateAndBuildEvent(attributes), | ||
error = _validateAndBuildEven2.error, | ||
value = _validateAndBuildEven2.value; | ||
if (error) return cb(error); | ||
return cb(null, (0, _pipeline.formatEvent)(value)); | ||
} | ||
function createEvents(events, cb) { | ||
if (!events) { | ||
return { | ||
error: Error('one argument is required'), | ||
}; | ||
var returnValue; | ||
try { | ||
returnValue = run(); | ||
} catch (e) { | ||
returnValue = { | ||
error: e, | ||
value: null | ||
}; | ||
} | ||
if (events.length === 0) { | ||
var _createEvent = createEvent({ | ||
start: [2000, 10, 5, 5, 0], | ||
duration: { | ||
hours: 1 | ||
} | ||
}), | ||
_error2 = _createEvent.error, | ||
dummy = _createEvent.value; | ||
if (_error2) return { | ||
error: _error2, | ||
value: null | ||
}; | ||
return { | ||
error: null, | ||
value: dummy.slice(0, dummy.indexOf('BEGIN:VEVENT')) + dummy.slice(dummy.indexOf('END:VEVENT') + 10 + 2) | ||
}; | ||
if (!resolvedCb) { | ||
return returnValue; | ||
} | ||
if (events.length === 1) { | ||
return createEvent(events[0], cb); | ||
} | ||
var _events$map$map$map$m = events.map(assignUniqueId).map(validateAndBuildEvent).map(applyInitialFormatting).map(reformatEventsByPosition).reduce(catenateEvents, { | ||
error: null, | ||
value: null | ||
}), | ||
error = _events$map$map$map$m.error, | ||
value = _events$map$map$map$m.value; | ||
if (!cb) { | ||
return { | ||
error: error, | ||
value: value | ||
}; | ||
} | ||
return cb(error, value); | ||
return resolvedCb(returnValue.error, returnValue.value); | ||
} |
@@ -6,5 +6,5 @@ "use strict"; | ||
}); | ||
exports["default"] = buildEvent; | ||
var _defaults = _interopRequireDefault(require("../defaults")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
exports.buildEvent = buildEvent; | ||
exports.buildHeader = buildHeader; | ||
var _defaults = require("../defaults"); | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
@@ -14,35 +14,18 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function removeUndefined(input) { | ||
return Object.entries(input).reduce(function (clean, entry) { | ||
return typeof entry[1] !== 'undefined' ? Object.assign(clean, _defineProperty({}, entry[0], entry[1])) : clean; | ||
}, {}); | ||
} | ||
function buildHeader() { | ||
var attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
// fill in default values where necessary | ||
var output = Object.assign({}, (0, _defaults.headerDefaults)(), attributes); | ||
return removeUndefined(output); | ||
} | ||
function buildEvent() { | ||
var attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var title = attributes.title, | ||
productId = attributes.productId, | ||
method = attributes.method, | ||
uid = attributes.uid, | ||
sequence = attributes.sequence, | ||
start = attributes.start, | ||
startType = attributes.startType, | ||
duration = attributes.duration, | ||
end = attributes.end, | ||
description = attributes.description, | ||
url = attributes.url, | ||
geo = attributes.geo, | ||
location = attributes.location, | ||
status = attributes.status, | ||
categories = attributes.categories, | ||
organizer = attributes.organizer, | ||
attendees = attributes.attendees, | ||
alarms = attributes.alarms, | ||
recurrenceRule = attributes.recurrenceRule, | ||
created = attributes.created, | ||
lastModified = attributes.lastModified, | ||
calName = attributes.calName, | ||
htmlContent = attributes.htmlContent; | ||
// fill in default values where necessary | ||
var output = Object.assign({}, _defaults["default"], attributes); | ||
// remove undefined values | ||
return Object.entries(output).reduce(function (clean, entry) { | ||
return typeof entry[1] !== 'undefined' ? Object.assign(clean, _defineProperty({}, entry[0], entry[1])) : clean; | ||
}, {}); | ||
var output = Object.assign({}, (0, _defaults.eventDefaults)(), attributes); | ||
return removeUndefined(output); | ||
} |
@@ -6,9 +6,29 @@ "use strict"; | ||
}); | ||
exports["default"] = formatEvent; | ||
exports.formatEvent = formatEvent; | ||
exports.formatFooter = formatFooter; | ||
exports.formatHeader = formatHeader; | ||
var _utils = require("../utils"); | ||
var _encodeNewLines = _interopRequireDefault(require("../utils/encode-new-lines")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function formatHeader() { | ||
var attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var productId = attributes.productId, | ||
method = attributes.method, | ||
calName = attributes.calName; | ||
var icsFormat = ''; | ||
icsFormat += 'BEGIN:VCALENDAR\r\n'; | ||
icsFormat += 'VERSION:2.0\r\n'; | ||
icsFormat += 'CALSCALE:GREGORIAN\r\n'; | ||
icsFormat += (0, _utils.foldLine)("PRODID:".concat((0, _encodeNewLines["default"])(productId))) + '\r\n'; | ||
icsFormat += (0, _utils.foldLine)("METHOD:".concat((0, _encodeNewLines["default"])(method))) + '\r\n'; | ||
icsFormat += calName ? (0, _utils.foldLine)("X-WR-CALNAME:".concat((0, _encodeNewLines["default"])(calName))) + '\r\n' : ''; | ||
icsFormat += "X-PUBLISHED-TTL:PT1H\r\n"; | ||
return icsFormat; | ||
} | ||
function formatFooter() { | ||
return "END:VCALENDAR\r\n"; | ||
} | ||
function formatEvent() { | ||
var attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var title = attributes.title, | ||
productId = attributes.productId, | ||
method = attributes.method, | ||
uid = attributes.uid, | ||
@@ -41,19 +61,11 @@ sequence = attributes.sequence, | ||
lastModified = attributes.lastModified, | ||
calName = attributes.calName, | ||
htmlContent = attributes.htmlContent; | ||
var icsFormat = ''; | ||
icsFormat += 'BEGIN:VCALENDAR\r\n'; | ||
icsFormat += 'VERSION:2.0\r\n'; | ||
icsFormat += 'CALSCALE:GREGORIAN\r\n'; | ||
icsFormat += (0, _utils.foldLine)("PRODID:".concat(productId)) + '\r\n'; | ||
icsFormat += (0, _utils.foldLine)("METHOD:".concat(method)) + '\r\n'; | ||
icsFormat += calName ? (0, _utils.foldLine)("X-WR-CALNAME:".concat(calName)) + '\r\n' : ''; | ||
icsFormat += "X-PUBLISHED-TTL:PT1H\r\n"; | ||
icsFormat += 'BEGIN:VEVENT\r\n'; | ||
icsFormat += "UID:".concat(uid, "\r\n"); | ||
icsFormat += (0, _utils.foldLine)("SUMMARY:".concat(title ? (0, _utils.setSummary)(title) : title)) + '\r\n'; | ||
icsFormat += "DTSTAMP:".concat(timestamp, "\r\n"); | ||
icsFormat += (0, _utils.foldLine)("UID:".concat((0, _encodeNewLines["default"])(uid))) + '\r\n'; | ||
icsFormat += title ? (0, _utils.foldLine)("SUMMARY:".concat((0, _encodeNewLines["default"])((0, _utils.setSummary)(title)))) + '\r\n' : ''; | ||
icsFormat += (0, _utils.foldLine)("DTSTAMP:".concat((0, _encodeNewLines["default"])((0, _utils.formatDate)(timestamp)))) + '\r\n'; | ||
// All day events like anniversaries must be specified as VALUE type DATE | ||
icsFormat += "DTSTART".concat(start && start.length == 3 ? ";VALUE=DATE" : "", ":").concat((0, _utils.formatDate)(start, startOutputType || startType, startInputType), "\r\n"); | ||
icsFormat += (0, _utils.foldLine)("DTSTART".concat(start && start.length == 3 ? ";VALUE=DATE" : "", ":").concat((0, _encodeNewLines["default"])((0, _utils.formatDate)(start, startOutputType || startType, startInputType)))) + '\r\n'; | ||
@@ -65,29 +77,31 @@ // End is not required for all day events on single days (like anniversaries) | ||
if (end) { | ||
icsFormat += "DTEND".concat(end.length === 3 ? ";VALUE=DATE" : "", ":").concat((0, _utils.formatDate)(end, endOutputType || startOutputType || startType, endInputType || startInputType), "\r\n"); | ||
icsFormat += (0, _utils.foldLine)("DTEND".concat(end.length === 3 ? ";VALUE=DATE" : "", ":").concat((0, _encodeNewLines["default"])((0, _utils.formatDate)(end, endOutputType || startOutputType || startType, endInputType || startInputType)))) + '\r\n'; | ||
} | ||
} | ||
icsFormat += typeof sequence !== 'undefined' ? "SEQUENCE:".concat(sequence, "\r\n") : ''; | ||
icsFormat += description ? (0, _utils.foldLine)("DESCRIPTION:".concat((0, _utils.setDescription)(description))) + '\r\n' : ''; | ||
icsFormat += url ? (0, _utils.foldLine)("URL:".concat(url)) + '\r\n' : ''; | ||
icsFormat += description ? (0, _utils.foldLine)("DESCRIPTION:".concat((0, _encodeNewLines["default"])((0, _utils.setDescription)(description)))) + '\r\n' : ''; | ||
icsFormat += url ? (0, _utils.foldLine)("URL:".concat((0, _encodeNewLines["default"])(url))) + '\r\n' : ''; | ||
icsFormat += geo ? (0, _utils.foldLine)("GEO:".concat((0, _utils.setGeolocation)(geo))) + '\r\n' : ''; | ||
icsFormat += location ? (0, _utils.foldLine)("LOCATION:".concat((0, _utils.setLocation)(location))) + '\r\n' : ''; | ||
icsFormat += status ? (0, _utils.foldLine)("STATUS:".concat(status)) + '\r\n' : ''; | ||
icsFormat += categories ? (0, _utils.foldLine)("CATEGORIES:".concat(categories)) + '\r\n' : ''; | ||
icsFormat += location ? (0, _utils.foldLine)("LOCATION:".concat((0, _encodeNewLines["default"])((0, _utils.setLocation)(location)))) + '\r\n' : ''; | ||
icsFormat += status ? (0, _utils.foldLine)("STATUS:".concat((0, _encodeNewLines["default"])(status))) + '\r\n' : ''; | ||
icsFormat += categories ? (0, _utils.foldLine)("CATEGORIES:".concat((0, _encodeNewLines["default"])(categories.join(',')))) + '\r\n' : ''; | ||
icsFormat += organizer ? (0, _utils.foldLine)("ORGANIZER;".concat((0, _utils.setOrganizer)(organizer))) + '\r\n' : ''; | ||
icsFormat += busyStatus ? (0, _utils.foldLine)("X-MICROSOFT-CDO-BUSYSTATUS:".concat(busyStatus)) + '\r\n' : ''; | ||
icsFormat += transp ? (0, _utils.foldLine)("TRANSP:".concat(transp)) + '\r\n' : ''; | ||
icsFormat += classification ? (0, _utils.foldLine)("CLASS:".concat(classification)) + '\r\n' : ''; | ||
icsFormat += created ? 'CREATED:' + (0, _utils.formatDate)(created) + '\r\n' : ''; | ||
icsFormat += lastModified ? 'LAST-MODIFIED:' + (0, _utils.formatDate)(lastModified) + '\r\n' : ''; | ||
icsFormat += htmlContent ? (0, _utils.foldLine)("X-ALT-DESC;FMTTYPE=text/html:".concat(htmlContent)) + '\r\n' : ''; | ||
icsFormat += busyStatus ? (0, _utils.foldLine)("X-MICROSOFT-CDO-BUSYSTATUS:".concat((0, _encodeNewLines["default"])(busyStatus))) + '\r\n' : ''; | ||
icsFormat += transp ? (0, _utils.foldLine)("TRANSP:".concat((0, _encodeNewLines["default"])(transp))) + '\r\n' : ''; | ||
icsFormat += classification ? (0, _utils.foldLine)("CLASS:".concat((0, _encodeNewLines["default"])(classification))) + '\r\n' : ''; | ||
icsFormat += created ? 'CREATED:' + (0, _encodeNewLines["default"])((0, _utils.formatDate)(created)) + '\r\n' : ''; | ||
icsFormat += lastModified ? 'LAST-MODIFIED:' + (0, _encodeNewLines["default"])((0, _utils.formatDate)(lastModified)) + '\r\n' : ''; | ||
icsFormat += htmlContent ? (0, _utils.foldLine)("X-ALT-DESC;FMTTYPE=text/html:".concat((0, _encodeNewLines["default"])(htmlContent))) + '\r\n' : ''; | ||
if (attendees) { | ||
attendees.map(function (attendee) { | ||
icsFormat += (0, _utils.foldLine)("ATTENDEE;".concat((0, _utils.setContact)(attendee))) + '\r\n'; | ||
attendees.forEach(function (attendee) { | ||
icsFormat += (0, _utils.foldLine)("ATTENDEE;".concat((0, _encodeNewLines["default"])((0, _utils.setContact)(attendee)))) + '\r\n'; | ||
}); | ||
} | ||
icsFormat += recurrenceRule ? "RRULE:".concat(recurrenceRule, "\r\n") : ''; | ||
icsFormat += exclusionDates ? "EXDATE:".concat(exclusionDates, "\r\n") : ''; | ||
icsFormat += duration ? "DURATION:".concat((0, _utils.formatDuration)(duration), "\r\n") : ''; | ||
icsFormat += recurrenceRule ? (0, _utils.foldLine)("RRULE:".concat((0, _encodeNewLines["default"])(recurrenceRule))) + '\r\n' : ''; | ||
icsFormat += exclusionDates ? (0, _utils.foldLine)("EXDATE:".concat((0, _encodeNewLines["default"])(exclusionDates.map(function (a) { | ||
return (0, _utils.formatDate)(a); | ||
}).join(',')))) + '\r\n' : ''; | ||
icsFormat += duration ? (0, _utils.foldLine)("DURATION:".concat((0, _utils.formatDuration)(duration))) + '\r\n' : ''; | ||
if (alarms) { | ||
alarms.map(function (alarm) { | ||
alarms.forEach(function (alarm) { | ||
icsFormat += (0, _utils.setAlarm)(alarm); | ||
@@ -97,4 +111,3 @@ }); | ||
icsFormat += "END:VEVENT\r\n"; | ||
icsFormat += "END:VCALENDAR\r\n"; | ||
return icsFormat; | ||
} |
@@ -9,20 +9,43 @@ "use strict"; | ||
get: function get() { | ||
return _build["default"]; | ||
return _build.buildEvent; | ||
} | ||
}); | ||
Object.defineProperty(exports, "buildHeader", { | ||
enumerable: true, | ||
get: function get() { | ||
return _build.buildHeader; | ||
} | ||
}); | ||
Object.defineProperty(exports, "formatEvent", { | ||
enumerable: true, | ||
get: function get() { | ||
return _format["default"]; | ||
return _format.formatEvent; | ||
} | ||
}); | ||
Object.defineProperty(exports, "validateEvent", { | ||
Object.defineProperty(exports, "formatFooter", { | ||
enumerable: true, | ||
get: function get() { | ||
return _validate["default"]; | ||
return _format.formatFooter; | ||
} | ||
}); | ||
var _build = _interopRequireDefault(require("./build")); | ||
var _format = _interopRequireDefault(require("./format")); | ||
var _validate = _interopRequireDefault(require("./validate")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
Object.defineProperty(exports, "formatHeader", { | ||
enumerable: true, | ||
get: function get() { | ||
return _format.formatHeader; | ||
} | ||
}); | ||
Object.defineProperty(exports, "validateHeader", { | ||
enumerable: true, | ||
get: function get() { | ||
return _validate.validateHeader; | ||
} | ||
}); | ||
Object.defineProperty(exports, "validateHeaderAndEvent", { | ||
enumerable: true, | ||
get: function get() { | ||
return _validate.validateHeaderAndEvent; | ||
} | ||
}); | ||
var _build = require("./build"); | ||
var _format = require("./format"); | ||
var _validate = require("./validate"); |
@@ -6,6 +6,12 @@ "use strict"; | ||
}); | ||
exports["default"] = void 0; | ||
var _schema = _interopRequireDefault(require("../schema")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
var _default = _schema["default"]; | ||
exports["default"] = _default; | ||
var _schema = require("../schema"); | ||
Object.keys(_schema).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (key in exports && exports[key] === _schema[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function get() { | ||
return _schema[key]; | ||
} | ||
}); | ||
}); |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports["default"] = validateEvent; | ||
exports.validateHeader = validateHeader; | ||
exports.validateHeaderAndEvent = validateHeaderAndEvent; | ||
var yup = _interopRequireWildcard(require("yup")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
// yup url validation blocks localhost, so use a more flexible regex instead | ||
@@ -16,6 +22,20 @@ // taken from https://github.com/jquense/yup/issues/224#issuecomment-417172609 | ||
var urlRegex = /^(?:([a-z0-9+.-]+):\/\/)(?:\S+(?::\S*)?@)?(?:(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*\.?)(?::\d{2,5})?(?:[/?#]\S*)?$/; | ||
var dateTimeSchema = yup.array().min(3).max(7).of(yup.lazy(function (item, options) { | ||
var itemIndex = options.parent.indexOf(options.value); | ||
return [yup.number().integer(), yup.number().integer().min(1).max(12), yup.number().integer().min(1).max(31), yup.number().integer().min(0).max(23), yup.number().integer().min(0).max(60), yup.number().integer().min(0).max(60)][itemIndex]; | ||
})); | ||
var dateTimeSchema = function dateTimeSchema(_ref) { | ||
var required = _ref.required; | ||
return yup.lazy(function (value) { | ||
if (typeof value === 'number') { | ||
return yup.number().integer().min(0); | ||
} | ||
if (typeof value === 'string') { | ||
return yup.string().required(); | ||
} | ||
if (!required && typeof value === 'undefined') { | ||
return yup.mixed().oneOf([undefined]); | ||
} | ||
return yup.array().required().min(3).max(7).of(yup.lazy(function (item, options) { | ||
var itemIndex = options.parent.indexOf(options.value); | ||
return [yup.number().integer(), yup.number().integer().min(1).max(12), yup.number().integer().min(1).max(31), yup.number().integer().min(0).max(23), yup.number().integer().min(0).max(60), yup.number().integer().min(0).max(60)][itemIndex]; | ||
})); | ||
}); | ||
}; | ||
var durationSchema = yup.object().shape({ | ||
@@ -47,3 +67,3 @@ before: yup["boolean"](), | ||
var alarmSchema = yup.object().shape({ | ||
action: yup.string().matches(/audio|display|email/).required(), | ||
action: yup.string().matches(/^(audio|display|email)$/).required(), | ||
trigger: yup.mixed().required(), | ||
@@ -60,18 +80,28 @@ description: yup.string(), | ||
}).noUnknown(); | ||
var schema = yup.object().shape({ | ||
var headerShape = { | ||
productId: yup.string(), | ||
method: yup.string(), | ||
calName: yup.string() | ||
}; | ||
var headerSchema = yup.object().shape(headerShape).noUnknown(); | ||
var eventShape = { | ||
summary: yup.string(), | ||
timestamp: yup.mixed(), | ||
timestamp: dateTimeSchema({ | ||
required: false | ||
}), | ||
title: yup.string(), | ||
productId: yup.string(), | ||
method: yup.string(), | ||
uid: yup.string().required(), | ||
uid: yup.string(), | ||
sequence: yup.number().integer().max(2147483647), | ||
start: dateTimeSchema.required(), | ||
start: dateTimeSchema({ | ||
required: true | ||
}), | ||
duration: durationSchema, | ||
startType: yup.string().matches(/utc|local/), | ||
startInputType: yup.string().matches(/utc|local/), | ||
startOutputType: yup.string().matches(/utc|local/), | ||
end: dateTimeSchema, | ||
endInputType: yup.string().matches(/utc|local/), | ||
endOutputType: yup.string().matches(/utc|local/), | ||
startType: yup.string().matches(/^(utc|local)$/), | ||
startInputType: yup.string().matches(/^(utc|local)$/), | ||
startOutputType: yup.string().matches(/^(utc|local)$/), | ||
end: dateTimeSchema({ | ||
required: false | ||
}), | ||
endInputType: yup.string().matches(/^(utc|local)$/), | ||
endOutputType: yup.string().matches(/^(utc|local)$/), | ||
description: yup.string(), | ||
@@ -84,3 +114,3 @@ url: yup.string().matches(urlRegex), | ||
location: yup.string(), | ||
status: yup.string().matches(/TENTATIVE|CANCELLED|CONFIRMED/i), | ||
status: yup.string().matches(/^(TENTATIVE|CANCELLED|CONFIRMED)$/i), | ||
categories: yup.array().of(yup.string()), | ||
@@ -91,10 +121,17 @@ organizer: organizerSchema, | ||
recurrenceRule: yup.string(), | ||
busyStatus: yup.string().matches(/TENTATIVE|FREE|BUSY|OOF/i), | ||
transp: yup.string().matches(/TRANSPARENT|OPAQUE/i), | ||
busyStatus: yup.string().matches(/^(TENTATIVE|FREE|BUSY|OOF)$/i), | ||
transp: yup.string().matches(/^(TRANSPARENT|OPAQUE)$/i), | ||
classification: yup.string(), | ||
created: dateTimeSchema, | ||
lastModified: dateTimeSchema, | ||
calName: yup.string(), | ||
created: dateTimeSchema({ | ||
required: false | ||
}), | ||
lastModified: dateTimeSchema({ | ||
required: false | ||
}), | ||
exclusionDates: yup.array().of(dateTimeSchema({ | ||
required: true | ||
})), | ||
htmlContent: yup.string() | ||
}).test('xor', "object should have end or duration (but not both)", function (val) { | ||
}; | ||
var headerAndEventSchema = yup.object().shape(_objectSpread(_objectSpread({}, headerShape), eventShape)).test('xor', "object should have end or duration (but not both)", function (val) { | ||
var hasEnd = !!val.end; | ||
@@ -104,5 +141,5 @@ var hasDuration = !!val.duration; | ||
}).noUnknown(); | ||
function validateEvent(candidate) { | ||
function validateHeader(candidate) { | ||
try { | ||
var value = schema.validateSync(candidate, { | ||
var value = headerSchema.validateSync(candidate, { | ||
abortEarly: false, | ||
@@ -121,2 +158,19 @@ strict: true | ||
} | ||
} | ||
function validateHeaderAndEvent(candidate) { | ||
try { | ||
var value = headerAndEventSchema.validateSync(candidate, { | ||
abortEarly: false, | ||
strict: true | ||
}); | ||
return { | ||
error: null, | ||
value: value | ||
}; | ||
} catch (error) { | ||
return { | ||
error: Object.assign({}, error), | ||
value: undefined | ||
}; | ||
} | ||
} |
@@ -20,2 +20,5 @@ "use strict"; | ||
var inputType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'local'; | ||
if (typeof args === 'string') { | ||
return args; | ||
} | ||
if (Array.isArray(args) && args.length === 3) { | ||
@@ -45,2 +48,5 @@ var _args = _slicedToArray(args, 3), | ||
} | ||
} else if (!Array.isArray(args)) { | ||
// it's a unix time stamp (ms) | ||
outDate = new Date(args); | ||
} | ||
@@ -47,0 +53,0 @@ if (outputType === 'local') { |
@@ -6,2 +6,8 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "encodeParamValue", { | ||
enumerable: true, | ||
get: function get() { | ||
return _encodeParamValue["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "foldLine", { | ||
@@ -77,2 +83,3 @@ enumerable: true, | ||
var _setLocation = _interopRequireDefault(require("./set-location")); | ||
var _encodeParamValue = _interopRequireDefault(require("./encode-param-value")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } |
@@ -9,2 +9,3 @@ "use strict"; | ||
var _foldLine = _interopRequireDefault(require("./fold-line")); | ||
var _encodeNewLines = _interopRequireDefault(require("./encode-new-lines")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -28,7 +29,7 @@ function setDuration(_ref) { | ||
var formattedString = ''; | ||
if (Array.isArray(trigger)) { | ||
formattedString = "TRIGGER;VALUE=DATE-TIME:".concat((0, _formatDate["default"])(trigger), "\r\n"); | ||
if (Array.isArray(trigger) || typeof trigger === 'number' || typeof trigger === 'string') { | ||
formattedString = "TRIGGER;VALUE=DATE-TIME:".concat((0, _encodeNewLines["default"])((0, _formatDate["default"])(trigger)), "\r\n"); | ||
} else { | ||
var alert = trigger.before ? '-' : ''; | ||
formattedString = "TRIGGER:".concat(alert + setDuration(trigger), "\r\n"); | ||
formattedString = "TRIGGER:".concat((0, _encodeNewLines["default"])(alert + setDuration(trigger)), "\r\n"); | ||
} | ||
@@ -51,10 +52,10 @@ return formattedString; | ||
var formattedString = 'BEGIN:VALARM\r\n'; | ||
formattedString += (0, _foldLine["default"])("ACTION:".concat(setAction(action))) + '\r\n'; | ||
formattedString += (0, _foldLine["default"])("ACTION:".concat((0, _encodeNewLines["default"])(setAction(action)))) + '\r\n'; | ||
formattedString += repeat ? (0, _foldLine["default"])("REPEAT:".concat(repeat)) + '\r\n' : ''; | ||
formattedString += description ? (0, _foldLine["default"])("DESCRIPTION:".concat(description)) + '\r\n' : ''; | ||
formattedString += description ? (0, _foldLine["default"])("DESCRIPTION:".concat((0, _encodeNewLines["default"])(description))) + '\r\n' : ''; | ||
formattedString += duration ? (0, _foldLine["default"])("DURATION:".concat(setDuration(duration))) + '\r\n' : ''; | ||
var attachInfo = attachType ? attachType : 'FMTTYPE=audio/basic'; | ||
formattedString += attach ? (0, _foldLine["default"])("ATTACH;".concat(attachInfo, ":").concat(attach)) + '\r\n' : ''; | ||
formattedString += trigger ? setTrigger(trigger) : ''; | ||
formattedString += summary ? (0, _foldLine["default"])("SUMMARY:".concat(summary)) + '\r\n' : ''; | ||
formattedString += attach ? (0, _foldLine["default"])((0, _encodeNewLines["default"])("ATTACH;".concat(attachInfo, ":").concat(attach))) + '\r\n' : ''; | ||
formattedString += trigger ? (0, _encodeNewLines["default"])(setTrigger(trigger)) : ''; | ||
formattedString += summary ? (0, _foldLine["default"])("SUMMARY:".concat((0, _encodeNewLines["default"])(summary))) + '\r\n' : ''; | ||
formattedString += 'END:VALARM\r\n'; | ||
@@ -61,0 +62,0 @@ return formattedString; |
@@ -7,2 +7,4 @@ "use strict"; | ||
exports["default"] = setContact; | ||
var _encodeParamValue = _interopRequireDefault(require("./encode-param-value")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function setContact(_ref) { | ||
@@ -22,3 +24,3 @@ var name = _ref.name, | ||
if (cutype) { | ||
formattedParts.push("CUTYPE=".concat(cutype)); | ||
formattedParts.push("CUTYPE=".concat((0, _encodeParamValue["default"])(cutype))); | ||
} | ||
@@ -29,13 +31,13 @@ if (xNumGuests !== undefined) { | ||
if (role) { | ||
formattedParts.push("ROLE=".concat(role)); | ||
formattedParts.push("ROLE=".concat((0, _encodeParamValue["default"])(role))); | ||
} | ||
if (partstat) { | ||
formattedParts.push("PARTSTAT=".concat(partstat)); | ||
formattedParts.push("PARTSTAT=".concat((0, _encodeParamValue["default"])(partstat))); | ||
} | ||
if (dir) { | ||
formattedParts.push("DIR=".concat(dir)); | ||
formattedParts.push("DIR=".concat((0, _encodeParamValue["default"])(dir))); | ||
} | ||
formattedParts.push('CN='.concat(name || 'Unnamed attendee')); | ||
formattedParts.push('CN='.concat((0, _encodeParamValue["default"])(name || 'Unnamed attendee'))); | ||
var formattedAttendee = formattedParts.join(';').concat(email ? ":mailto:".concat(email) : ''); | ||
return formattedAttendee; | ||
} |
@@ -7,2 +7,4 @@ "use strict"; | ||
exports["default"] = setOrganizer; | ||
var _encodeParamValue = _interopRequireDefault(require("./encode-param-value")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function setOrganizer(_ref) { | ||
@@ -14,8 +16,8 @@ var name = _ref.name, | ||
var formattedOrganizer = ''; | ||
formattedOrganizer += dir ? "DIR=\"".concat(dir, "\";") : ''; | ||
formattedOrganizer += sentBy ? "SENT-BY=\"MAILTO:".concat(sentBy, "\";") : ''; | ||
formattedOrganizer += dir ? "DIR=".concat((0, _encodeParamValue["default"])(dir), ";") : ''; | ||
formattedOrganizer += sentBy ? "SENT-BY=".concat((0, _encodeParamValue["default"])("MAILTO:".concat(sentBy)), ";") : ''; | ||
formattedOrganizer += 'CN='; | ||
formattedOrganizer += name || 'Organizer'; | ||
formattedOrganizer += (0, _encodeParamValue["default"])(name || 'Organizer'); | ||
formattedOrganizer += email ? ":MAILTO:".concat(email) : ''; | ||
return formattedOrganizer; | ||
} |
@@ -0,1 +1,3 @@ | ||
export type DateTime = DateArray | number | string; | ||
export type DateArray = | ||
@@ -70,3 +72,3 @@ | [number, number, number, number, number] | ||
duration?: DurationObject; | ||
trigger?: DurationObject; // @todo DateArray | DurationObject; | ||
trigger?: DurationObject | DateTime; | ||
repeat?: number; | ||
@@ -77,4 +79,10 @@ attachType?: string; | ||
export type HeaderAttributes = { | ||
productId?: string; | ||
method?: string; | ||
calName?: string; | ||
} | ||
export type EventAttributes = { | ||
start: DateArray; | ||
start: DateTime; | ||
startInputType?: 'local' | 'utc'; | ||
@@ -105,14 +113,14 @@ startOutputType?: 'local' | 'utc'; | ||
productId?: string; | ||
productId?: HeaderAttributes['productId']; | ||
uid?: string; | ||
method?: string; | ||
method?: HeaderAttributes['method']; | ||
recurrenceRule?: string; | ||
exclusionDates?: string; | ||
sequence?: number; | ||
calName?: string; | ||
calName?: HeaderAttributes['calName']; | ||
classification?: classificationType; | ||
created?: DateArray; | ||
lastModified?: DateArray; | ||
created?: DateTime; | ||
lastModified?: DateTime; | ||
htmlContent?: string; | ||
} & ({ end: DateArray } | { duration: DurationObject }); | ||
} & ({ end: DateTime } | { duration: DurationObject }); | ||
@@ -128,5 +136,5 @@ export type ReturnObject = { error?: Error; value?: string }; | ||
export function createEvents(events: EventAttributes[], callback: NodeCallback): void; | ||
export function createEvents(events: EventAttributes[], headerAttributes?: HeaderAttributes): ReturnObject; | ||
export function createEvents(events: EventAttributes[], headerAttributes: HeaderAttributes, callback: NodeCallback): void; | ||
export function createEvents(events: EventAttributes[]): ReturnObject; | ||
export function convertTimestampToArray(timestamp: Number, inputType: String): DateArray; |
{ | ||
"name": "ics", | ||
"version": "3.6.2", | ||
"version": "3.6.3", | ||
"description": "iCal (ics) file generator", | ||
@@ -5,0 +5,0 @@ "exports": { |
@@ -124,14 +124,16 @@ ics | ||
// PRODID:adamgibbons/ics | ||
// METHOD:PUBLISH | ||
// X-PUBLISHED-TTL:PT1H | ||
// BEGIN:VEVENT | ||
// UID:mPfHOGi_sif_xO493Mgi6 | ||
// UID:pP83XzQPo5RlvjDCMIINs | ||
// SUMMARY:Lunch | ||
// DTSTAMP:20180210T093900Z | ||
// DTSTART:20180115T191500Z | ||
// DTSTAMP:20230917T142209Z | ||
// DTSTART:20180115T121500Z | ||
// DURATION:PT45M | ||
// END:VEVENT | ||
// BEGIN:VEVENT | ||
// UID:ho-KcKyhNaQVDqJCcGfXD | ||
// UID:gy5vfUVv6wjyBeNkkFmBX | ||
// SUMMARY:Dinner | ||
// DTSTAMP:20180210T093900Z | ||
// DTSTART:20180115T191500Z | ||
// DTSTAMP:20230917T142209Z | ||
// DTSTART:20180115T121500Z | ||
// DURATION:PT1H30M | ||
@@ -149,4 +151,4 @@ // END:VEVENT | ||
let start = moment().format('YYYY-M-D-H-m').split("-") | ||
let end = moment().add({'hours':2, "minutes":30}).format("YYYY-M-D-H-m").split("-") | ||
let start = moment().format('YYYY-M-D-H-m').split("-").map((a) => parseInt(a)) | ||
let end = moment().add({'hours':2, "minutes":30}).format("YYYY-M-D-H-m").split("-").map((a) => parseInt(a)) | ||
@@ -172,3 +174,3 @@ alarms.push({ | ||
events.push(event) | ||
console.log(ics.createEvents(events)) | ||
console.log(ics.createEvents(events).value) | ||
@@ -178,25 +180,19 @@ // BEGIN:VCALENDAR | ||
// CALSCALE:GREGORIAN | ||
// PRODID:MyCalendarId | ||
// PRODID:myCalendarId | ||
// METHOD:PUBLISH | ||
// X-PUBLISHED-TTL:PT1H | ||
// BEGIN:VEVENT | ||
// UID:123@MyCalendarIdics.com | ||
// UID:123@ics.com | ||
// SUMMARY:test here | ||
// DTSTAMP:20180409T072100Z | ||
// DTSTART:20180409 | ||
// DTEND:20180409 | ||
// DTSTAMP:20230917T142621Z | ||
// DTSTART:20230917T152600 | ||
// DTEND:20230917T175600 | ||
// BEGIN:VALARM | ||
// ACTION:DISPLAY | ||
// DESCRIPTION:Reminder | ||
// TRIGGER:-PT2H30M | ||
// END:VALARM | ||
// BEGIN:VALARM | ||
// ACTION:AUDIO | ||
// REPEAT:2 | ||
// DESCRIPTION:Reminder | ||
// ATTACH;VALUE=URI:Glass | ||
// TRIGGER:PT2H | ||
// END:VALARM | ||
// TRIGGER:-PT2H30M\nEND:VALARM | ||
// END:VEVENT | ||
// END:VCALENDAR | ||
``` | ||
@@ -253,2 +249,5 @@ | ||
Only the `start` property is required. | ||
Note all date/time fields can be the array form, or a number representing the unix timestamp in milliseconds (e.g. `getTime()` on a `Date`). | ||
The following properties are accepted: | ||
@@ -258,6 +257,6 @@ | ||
| ------------- | ------------- | ---------- | ||
| start | **Required**. Date and time at which the event begins. | `[2000, 1, 5, 10, 0]` (January 5, 2000) | ||
| start | **Required**. Date and time at which the event begins. | `[2000, 1, 5, 10, 0]` (January 5, 2000) or a `number` | ||
| startInputType | Type of the date/time data in `start`:<br>`local` (default): passed data is in local time.<br>`utc`: passed data is UTC | | ||
| startOutputType | Format of the start date/time in the output:<br>`utc` (default): the start date will be sent in UTC format.<br>`local`: the start date will be sent as "floating" (form #1 in [RFC 5545](https://tools.ietf.org/html/rfc5545#section-3.3.5)) | | ||
| end | Time at which event ends. *Either* `end` or `duration` is required, but *not* both. | `[2000, 1, 5, 13, 5]` (January 5, 2000 at 1pm) | ||
| end | Time at which event ends. *Either* `end` or `duration` is required, but *not* both. | `[2000, 1, 5, 13, 5]` (January 5, 2000 at 1pm) or a `number` | ||
| endInputType | Type of the date/time data in `end`:<br>`local`: passed data is in local time.<br>`utc`: passed data is UTC.<br>The default is the value of `startInputType` | | ||
@@ -280,3 +279,3 @@ | endOutputType | Format of the start date/time in the output:<br>`utc`: the start date will be sent in UTC format.<br>`local`: the start date will be sent as "floating" (form #1 in [RFC 5545](https://tools.ietf.org/html/rfc5545#section-3.3.5)).<br>The default is the value of `startOutputType` | | ||
| recurrenceRule | A recurrence rule, commonly referred to as an RRULE, defines the repeat pattern or rule for to-dos, journal entries and events. If specified, RRULE can be used to compute the recurrence set (the complete set of recurrence instances in a calendar component). You can use a generator like this [one](https://www.textmagic.com/free-tools/rrule-generator). | `FREQ=DAILY` | ||
| exclusionDates| This property defines the list of DATE-TIME exceptions for recurring events, to-dos, journal entries, or time zone definitions. Uses a comma-delimited list of [Date-Time](https://tools.ietf.org/html/rfc5545#section-3.3.5) values. See [EXDATE spec](https://tools.ietf.org/html/rfc5545#section-3.8.5.1).|`'20230620T131500Z,20230621T131500'` (June 20th, 2023 at 1:15pm UTC and June 21st, 2000 at 1:15pm LOCAL) | ||
| exclusionDates | Array of date-time exceptions for recurring events, to-dos, journal entries, or time zone definitions. | `[[2000, 1, 5, 10, 0], [2000, 2, 5, 10, 0]]` OR `[1694941727477, 1694945327477]` | ||
| sequence | For sending an update for an event (with the same uid), defines the revision sequence number. | `2` | ||
@@ -286,4 +285,4 @@ | busyStatus | Used to specify busy status for Microsoft applications, like Outlook. See [Microsoft spec](https://docs.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-oxcical/cd68eae7-ed65-4dd3-8ea7-ad585c76c736). | `'BUSY'` OR `'FREE'` OR `'TENTATIVE`' OR `'OOF'` | ||
| classification | This property defines the access classification for a calendar component. See [iCalender spec](https://icalendar.org/iCalendar-RFC-5545/3-8-1-3-classification.html). | `'PUBLIC'` OR `'PRIVATE'` OR `'CONFIDENTIAL`' OR any non-standard string | ||
| created | Date-time representing event's creation date. Provide a date-time in UTC | [2000, 1, 5, 10, 0] (January 5, 2000 GMT +00:00) | ||
| lastModified | Date-time representing date when event was last modified. Provide a date-time in UTC | [2000, 1, 5, 10, 0] (January 5, 2000 GMT +00:00) | ||
| created | Date-time representing event's creation date. Provide a date-time in local time | `[2000, 1, 5, 10, 0]` or a `number` | ||
| lastModified | Date-time representing date when event was last modified. Provide a date-time in local time | [2000, 1, 5, 10, 0] or a `number` | ||
| calName | Specifies the _calendar_ (not event) name. Used by Apple iCal and Microsoft Outlook; see [Open Specification](https://docs.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-oxcical/1da58449-b97e-46bd-b018-a1ce576f3e6d) | `'Example Calendar'` | | ||
@@ -319,6 +318,8 @@ | htmlContent | Used to include HTML markup in an event's description. Standard DESCRIPTION tag should contain non-HTML version. | `<!DOCTYPE html><html><body><p>This is<br>test<br>html code.</p></body></html>` | | ||
### `createEvents(events[, callback])` | ||
### `createEvents(events[, headerParams, callback])` | ||
Generates an iCal-compliant VCALENDAR string with multiple VEVENTS. | ||
`headerParams` may be omitted, and in this case they will be read from the first event. | ||
If a callback is not provided, returns an object having the form `{ error, value }`, where value is an iCal-compliant text string | ||
@@ -325,0 +326,0 @@ if `error` is `null`. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57674
25
935
362