Comparing version 2.44.0 to 3.1.0
@@ -7,7 +7,4 @@ "use strict"; | ||
exports["default"] = void 0; | ||
var _nanoid = require("nanoid"); | ||
var _utils = require("./utils"); | ||
var defaults = { | ||
@@ -14,0 +11,0 @@ title: 'Untitled event', |
@@ -9,7 +9,4 @@ "use strict"; | ||
exports.createEvents = createEvents; | ||
var _nanoid = require("nanoid"); | ||
var _pipeline = require("./pipeline"); | ||
function assignUniqueId(event) { | ||
@@ -19,11 +16,8 @@ event.uid = event.uid || (0, _nanoid.nanoid)(); | ||
} | ||
function validateAndBuildEvent(event) { | ||
return (0, _pipeline.validateEvent)((0, _pipeline.buildEvent)(event)); | ||
} | ||
function applyInitialFormatting(_ref) { | ||
var error = _ref.error, | ||
value = _ref.value; | ||
value = _ref.value; | ||
if (error) { | ||
@@ -35,3 +29,2 @@ return { | ||
} | ||
return { | ||
@@ -42,6 +35,5 @@ error: null, | ||
} | ||
function reformatEventsByPosition(_ref2, idx, list) { | ||
var error = _ref2.error, | ||
value = _ref2.value; | ||
value = _ref2.value; | ||
if (error) return { | ||
@@ -51,3 +43,2 @@ error: error, | ||
}; | ||
if (idx === 0) { | ||
@@ -60,3 +51,2 @@ // beginning of list | ||
} | ||
if (idx === list.length - 1) { | ||
@@ -69,3 +59,2 @@ // end of list | ||
} | ||
return { | ||
@@ -76,7 +65,5 @@ error: null, | ||
} | ||
function catenateEvents(accumulator, _ref3, idx) { | ||
var error = _ref3.error, | ||
value = _ref3.value; | ||
value = _ref3.value; | ||
if (error) { | ||
@@ -87,3 +74,2 @@ accumulator.error = error; | ||
} | ||
if (accumulator.value) { | ||
@@ -93,7 +79,5 @@ accumulator.value = accumulator.value.concat(value); | ||
} | ||
accumulator.value = value; | ||
return accumulator; | ||
} | ||
function convertTimestampToArray(timestamp) { | ||
@@ -110,3 +94,2 @@ var inputType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'local'; | ||
} | ||
function createEvent(attributes, cb) { | ||
@@ -116,11 +99,8 @@ if (!attributes) { | ||
} | ||
assignUniqueId(attributes); | ||
if (!cb) { | ||
// No callback, so return error or value in an object | ||
var _validateAndBuildEven = validateAndBuildEvent(attributes), | ||
_error = _validateAndBuildEven.error, | ||
_value = _validateAndBuildEven.value; | ||
_error = _validateAndBuildEven.error, | ||
_value = _validateAndBuildEven.value; | ||
if (_error) return { | ||
@@ -131,3 +111,2 @@ error: _error, | ||
var event = ''; | ||
try { | ||
@@ -141,3 +120,2 @@ event = (0, _pipeline.formatEvent)(_value); | ||
} | ||
return { | ||
@@ -147,13 +125,11 @@ error: null, | ||
}; | ||
} // Return a node-style callback | ||
} | ||
// Return a node-style callback | ||
var _validateAndBuildEven2 = validateAndBuildEvent(attributes), | ||
error = _validateAndBuildEven2.error, | ||
value = _validateAndBuildEven2.value; | ||
error = _validateAndBuildEven2.error, | ||
value = _validateAndBuildEven2.value; | ||
if (error) return cb(error); | ||
return cb(null, (0, _pipeline.formatEvent)(value)); | ||
} | ||
function createEvents(events, cb) { | ||
@@ -166,14 +142,29 @@ if (!events) { | ||
} | ||
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 (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; | ||
error: null, | ||
value: null | ||
}), | ||
error = _events$map$map$map$m.error, | ||
value = _events$map$map$map$m.value; | ||
if (!cb) { | ||
@@ -185,4 +176,3 @@ return { | ||
} | ||
return cb(error, value); | ||
} |
@@ -7,37 +7,38 @@ "use strict"; | ||
exports["default"] = buildEvent; | ||
var _defaults = _interopRequireDefault(require("../defaults")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
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 _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 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 | ||
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; | ||
var output = Object.assign({}, _defaults["default"], attributes); // remove undefined values | ||
// fill in default values where necessary | ||
var output = Object.assign({}, _defaults["default"], attributes); | ||
// remove undefined values | ||
return Object.entries(output).reduce(function (clean, entry) { | ||
@@ -44,0 +45,0 @@ return typeof entry[1] !== 'undefined' ? Object.assign(clean, _defineProperty({}, entry[0], entry[1])) : clean; |
@@ -7,37 +7,35 @@ "use strict"; | ||
exports["default"] = formatEvent; | ||
var _utils = require("../utils"); | ||
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, | ||
sequence = attributes.sequence, | ||
timestamp = attributes.timestamp, | ||
start = attributes.start, | ||
startType = attributes.startType, | ||
startInputType = attributes.startInputType, | ||
startOutputType = attributes.startOutputType, | ||
duration = attributes.duration, | ||
end = attributes.end, | ||
endInputType = attributes.endInputType, | ||
endOutputType = attributes.endOutputType, | ||
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, | ||
busyStatus = attributes.busyStatus, | ||
classification = attributes.classification, | ||
created = attributes.created, | ||
lastModified = attributes.lastModified, | ||
calName = attributes.calName, | ||
htmlContent = attributes.htmlContent; | ||
productId = attributes.productId, | ||
method = attributes.method, | ||
uid = attributes.uid, | ||
sequence = attributes.sequence, | ||
timestamp = attributes.timestamp, | ||
start = attributes.start, | ||
startType = attributes.startType, | ||
startInputType = attributes.startInputType, | ||
startOutputType = attributes.startOutputType, | ||
duration = attributes.duration, | ||
end = attributes.end, | ||
endInputType = attributes.endInputType, | ||
endOutputType = attributes.endOutputType, | ||
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, | ||
busyStatus = attributes.busyStatus, | ||
classification = attributes.classification, | ||
created = attributes.created, | ||
lastModified = attributes.lastModified, | ||
calName = attributes.calName, | ||
htmlContent = attributes.htmlContent; | ||
var icsFormat = ''; | ||
@@ -54,6 +52,8 @@ icsFormat += 'BEGIN:VCALENDAR\r\n'; | ||
icsFormat += (0, _utils.foldLine)("SUMMARY:".concat(title ? (0, _utils.setSummary)(title) : title)) + '\r\n'; | ||
icsFormat += "DTSTAMP:".concat(timestamp, "\r\n"); // All day events like anniversaries must be specified as VALUE type DATE | ||
icsFormat += "DTSTAMP:".concat(timestamp, "\r\n"); | ||
icsFormat += "DTSTART".concat(start && start.length == 3 ? ";VALUE=DATE" : "", ":").concat((0, _utils.formatDate)(start, startOutputType || startType, startInputType), "\r\n"); // End is not required for all day events on single days (like anniversaries) | ||
// 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"); | ||
// End is not required for all day events on single days (like anniversaries) | ||
if (!end || end.length !== 3 || start.length !== end.length || start.some(function (val, i) { | ||
@@ -66,3 +66,2 @@ return val !== end[i]; | ||
} | ||
icsFormat += typeof sequence !== 'undefined' ? "SEQUENCE:".concat(sequence, "\r\n") : ''; | ||
@@ -81,3 +80,2 @@ icsFormat += description ? (0, _utils.foldLine)("DESCRIPTION:".concat((0, _utils.setDescription)(description))) + '\r\n' : ''; | ||
icsFormat += htmlContent ? (0, _utils.foldLine)("X-ALT-DESC;FMTTYPE=text/html:".concat(htmlContent)) + '\r\n' : ''; | ||
if (attendees) { | ||
@@ -88,6 +86,4 @@ attendees.map(function (attendee) { | ||
} | ||
icsFormat += recurrenceRule ? "RRULE:".concat(recurrenceRule, "\r\n") : ''; | ||
icsFormat += duration ? "DURATION:".concat((0, _utils.formatDuration)(duration), "\r\n") : ''; | ||
if (alarms) { | ||
@@ -98,3 +94,2 @@ alarms.map(function (alarm) { | ||
} | ||
icsFormat += "END:VEVENT\r\n"; | ||
@@ -101,0 +96,0 @@ icsFormat += "END:VCALENDAR\r\n"; |
@@ -24,9 +24,5 @@ "use strict"; | ||
}); | ||
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 }; } |
@@ -7,8 +7,5 @@ "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; |
"use strict"; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
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", { | ||
@@ -9,9 +8,5 @@ value: true | ||
exports["default"] = validateEvent; | ||
var yup = _interopRequireWildcard(require("yup")); | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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 _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; } | ||
// yup url validation blocks localhost, so use a more flexible regex instead | ||
@@ -46,3 +41,4 @@ // taken from https://github.com/jquense/yup/issues/224#issuecomment-417172609 | ||
email: yup.string().email(), | ||
dir: yup.string() | ||
dir: yup.string(), | ||
sentBy: yup.string() | ||
}).noUnknown(); | ||
@@ -102,3 +98,2 @@ var alarmSchema = yup.object().shape({ | ||
}).noUnknown(); | ||
function validateEvent(candidate) { | ||
@@ -105,0 +100,0 @@ try { |
@@ -7,7 +7,5 @@ "use strict"; | ||
exports["default"] = foldLine; | ||
function foldLine(line) { | ||
var parts = []; | ||
var length = 75; | ||
while (line.length > length) { | ||
@@ -18,5 +16,4 @@ parts.push(line.slice(0, length)); | ||
} | ||
parts.push(line); | ||
return parts.join('\r\n\t'); | ||
} |
@@ -7,19 +7,11 @@ "use strict"; | ||
exports["default"] = formatDate; | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } | ||
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
var pad = function pad(n) { | ||
return n < 10 ? "0".concat(n) : "".concat(n); | ||
}; | ||
function formatDate() { | ||
@@ -29,26 +21,21 @@ var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
var inputType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'local'; | ||
if (Array.isArray(args) && args.length === 3) { | ||
var _args = _slicedToArray(args, 3), | ||
year = _args[0], | ||
month = _args[1], | ||
date = _args[2]; | ||
year = _args[0], | ||
month = _args[1], | ||
date = _args[2]; | ||
return "".concat(year).concat(pad(month)).concat(pad(date)); | ||
} | ||
var outDate = new Date(new Date().setUTCSeconds(0, 0)); | ||
var outDate = new Date(); | ||
if (Array.isArray(args) && args.length > 0 && args[0]) { | ||
var _args2 = _slicedToArray(args, 6), | ||
_year = _args2[0], | ||
_month = _args2[1], | ||
_date = _args2[2], | ||
_args2$ = _args2[3], | ||
hours = _args2$ === void 0 ? 0 : _args2$, | ||
_args2$2 = _args2[4], | ||
minutes = _args2$2 === void 0 ? 0 : _args2$2, | ||
_args2$3 = _args2[5], | ||
seconds = _args2$3 === void 0 ? 0 : _args2$3; | ||
_year = _args2[0], | ||
_month = _args2[1], | ||
_date = _args2[2], | ||
_args2$ = _args2[3], | ||
hours = _args2$ === void 0 ? 0 : _args2$, | ||
_args2$2 = _args2[4], | ||
minutes = _args2$2 === void 0 ? 0 : _args2$2, | ||
_args2$3 = _args2[5], | ||
seconds = _args2$3 === void 0 ? 0 : _args2$3; | ||
if (inputType === 'local') { | ||
@@ -60,8 +47,6 @@ outDate = new Date(_year, _month - 1, _date, hours, minutes, seconds); | ||
} | ||
if (outputType === 'local') { | ||
return [outDate.getFullYear(), pad(outDate.getMonth() + 1), pad(outDate.getDate()), 'T', pad(outDate.getHours()), pad(outDate.getMinutes()), pad(outDate.getSeconds())].join(''); | ||
} | ||
return [outDate.getUTCFullYear(), pad(outDate.getUTCMonth() + 1), pad(outDate.getUTCDate()), 'T', pad(outDate.getUTCHours()), pad(outDate.getUTCMinutes()), pad(outDate.getUTCSeconds()), 'Z'].join(''); | ||
} |
@@ -7,10 +7,9 @@ "use strict"; | ||
exports["default"] = formatDuration; | ||
function formatDuration() { | ||
var attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var weeks = attributes.weeks, | ||
days = attributes.days, | ||
hours = attributes.hours, | ||
minutes = attributes.minutes, | ||
seconds = attributes.seconds; | ||
days = attributes.days, | ||
hours = attributes.hours, | ||
minutes = attributes.minutes, | ||
seconds = attributes.seconds; | ||
var formattedDuration = 'P'; | ||
@@ -17,0 +16,0 @@ formattedDuration += weeks ? "".concat(weeks, "W") : ''; |
@@ -7,5 +7,4 @@ "use strict"; | ||
exports["default"] = formatText; | ||
function formatText(text) { | ||
return text.replace(/\\/gm, "\\\\").replace(/\r?\n/gm, "\\n").replace(/;/gm, "\\;").replace(/,/gm, "\\,"); | ||
} |
@@ -6,30 +6,30 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "formatDate", { | ||
Object.defineProperty(exports, "foldLine", { | ||
enumerable: true, | ||
get: function get() { | ||
return _formatDate["default"]; | ||
return _foldLine["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "setGeolocation", { | ||
Object.defineProperty(exports, "formatDate", { | ||
enumerable: true, | ||
get: function get() { | ||
return _setGeolocation["default"]; | ||
return _formatDate["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "setContact", { | ||
Object.defineProperty(exports, "formatDuration", { | ||
enumerable: true, | ||
get: function get() { | ||
return _setContact["default"]; | ||
return _formatDuration["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "setOrganizer", { | ||
Object.defineProperty(exports, "setAlarm", { | ||
enumerable: true, | ||
get: function get() { | ||
return _setOrganizer["default"]; | ||
return _setAlarm["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "setAlarm", { | ||
Object.defineProperty(exports, "setContact", { | ||
enumerable: true, | ||
get: function get() { | ||
return _setAlarm["default"]; | ||
return _setContact["default"]; | ||
} | ||
@@ -43,47 +43,36 @@ }); | ||
}); | ||
Object.defineProperty(exports, "setSummary", { | ||
Object.defineProperty(exports, "setGeolocation", { | ||
enumerable: true, | ||
get: function get() { | ||
return _setSummary["default"]; | ||
return _setGeolocation["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "formatDuration", { | ||
Object.defineProperty(exports, "setLocation", { | ||
enumerable: true, | ||
get: function get() { | ||
return _formatDuration["default"]; | ||
return _setLocation["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "foldLine", { | ||
Object.defineProperty(exports, "setOrganizer", { | ||
enumerable: true, | ||
get: function get() { | ||
return _foldLine["default"]; | ||
return _setOrganizer["default"]; | ||
} | ||
}); | ||
Object.defineProperty(exports, "setLocation", { | ||
Object.defineProperty(exports, "setSummary", { | ||
enumerable: true, | ||
get: function get() { | ||
return _setLocation["default"]; | ||
return _setSummary["default"]; | ||
} | ||
}); | ||
var _formatDate = _interopRequireDefault(require("./format-date")); | ||
var _setGeolocation = _interopRequireDefault(require("./set-geolocation")); | ||
var _setContact = _interopRequireDefault(require("./set-contact")); | ||
var _setOrganizer = _interopRequireDefault(require("./set-organizer")); | ||
var _setAlarm = _interopRequireDefault(require("./set-alarm")); | ||
var _setDescription = _interopRequireDefault(require("./set-description")); | ||
var _setSummary = _interopRequireDefault(require("./set-summary")); | ||
var _formatDuration = _interopRequireDefault(require("./format-duration")); | ||
var _foldLine = _interopRequireDefault(require("./fold-line")); | ||
var _setLocation = _interopRequireDefault(require("./set-location")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } |
@@ -7,15 +7,11 @@ "use strict"; | ||
exports["default"] = setAlarm; | ||
var _formatDate = _interopRequireDefault(require("./format-date")); | ||
var _foldLine = _interopRequireDefault(require("./fold-line")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function setDuration(_ref) { | ||
var weeks = _ref.weeks, | ||
days = _ref.days, | ||
hours = _ref.hours, | ||
minutes = _ref.minutes, | ||
seconds = _ref.seconds; | ||
days = _ref.days, | ||
hours = _ref.hours, | ||
minutes = _ref.minutes, | ||
seconds = _ref.seconds; | ||
var formattedString = 'P'; | ||
@@ -30,6 +26,4 @@ formattedString += weeks ? "".concat(weeks, "W") : ''; | ||
} | ||
function setTrigger(trigger) { | ||
var formattedString = ''; | ||
if (Array.isArray(trigger)) { | ||
@@ -41,20 +35,17 @@ formattedString = "TRIGGER;VALUE=DATE-TIME:".concat((0, _formatDate["default"])(trigger), "\r\n"); | ||
} | ||
return formattedString; | ||
} | ||
function setAction(action) { | ||
return action.toUpperCase(); | ||
} | ||
function setAlarm() { | ||
var attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var action = attributes.action, | ||
repeat = attributes.repeat, | ||
description = attributes.description, | ||
duration = attributes.duration, | ||
attach = attributes.attach, | ||
attachType = attributes.attachType, | ||
trigger = attributes.trigger, | ||
summary = attributes.summary; | ||
repeat = attributes.repeat, | ||
description = attributes.description, | ||
duration = attributes.duration, | ||
attach = attributes.attach, | ||
attachType = attributes.attachType, | ||
trigger = attributes.trigger, | ||
summary = attributes.summary; | ||
var formattedString = 'BEGIN:VALARM\r\n'; | ||
@@ -71,5 +62,10 @@ formattedString += (0, _foldLine["default"])("ACTION:".concat(setAction(action))) + '\r\n'; | ||
return formattedString; | ||
} // Example: A duration of 15 days, 5 hours, and 20 seconds would be: | ||
} | ||
// Example: A duration of 15 days, 5 hours, and 20 seconds would be: | ||
// P15DT5H0M20S | ||
// A duration of 7 weeks would be: | ||
// P7W |
@@ -7,10 +7,9 @@ "use strict"; | ||
exports["default"] = setContact; | ||
function setContact(_ref) { | ||
var name = _ref.name, | ||
email = _ref.email, | ||
rsvp = _ref.rsvp, | ||
dir = _ref.dir, | ||
partstat = _ref.partstat, | ||
role = _ref.role; | ||
email = _ref.email, | ||
rsvp = _ref.rsvp, | ||
dir = _ref.dir, | ||
partstat = _ref.partstat, | ||
role = _ref.role; | ||
var formattedAttendee = ''; | ||
@@ -17,0 +16,0 @@ formattedAttendee += rsvp ? 'RSVP=TRUE;' : 'RSVP=FALSE;'; |
@@ -7,9 +7,6 @@ "use strict"; | ||
exports["default"] = setDescription; | ||
var _formatText = _interopRequireDefault(require("./format-text")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function setDescription(description) { | ||
return (0, _formatText["default"])(description); | ||
} |
@@ -7,7 +7,6 @@ "use strict"; | ||
exports["default"] = setGeolocation; | ||
function setGeolocation(_ref) { | ||
var lat = _ref.lat, | ||
lon = _ref.lon; | ||
lon = _ref.lon; | ||
return "".concat(lat, ";").concat(lon); | ||
} |
@@ -7,9 +7,6 @@ "use strict"; | ||
exports["default"] = setLocation; | ||
var _formatText = _interopRequireDefault(require("./format-text")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function setLocation(location) { | ||
return (0, _formatText["default"])(location); | ||
} |
@@ -7,13 +7,14 @@ "use strict"; | ||
exports["default"] = setOrganizer; | ||
function setOrganizer(_ref) { | ||
var name = _ref.name, | ||
email = _ref.email, | ||
dir = _ref.dir; | ||
email = _ref.email, | ||
dir = _ref.dir, | ||
sentBy = _ref.sentBy; | ||
var formattedOrganizer = ''; | ||
formattedOrganizer += dir ? "DIR=\"".concat(dir, "\";") : ''; | ||
formattedOrganizer += sentBy ? "SENT-BY=\"MAILTO:".concat(sentBy, "\";") : ''; | ||
formattedOrganizer += 'CN='; | ||
formattedOrganizer += name || 'Organizer'; | ||
formattedOrganizer += email ? ":mailto:".concat(email) : ''; | ||
formattedOrganizer += email ? ":MAILTO:".concat(email) : ''; | ||
return formattedOrganizer; | ||
} |
@@ -7,9 +7,6 @@ "use strict"; | ||
exports["default"] = setSummary; | ||
var _formatText = _interopRequireDefault(require("./format-text")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function setSummary(summary) { | ||
return (0, _formatText["default"])(summary); | ||
} |
{ | ||
"name": "ics", | ||
"version": "2.44.0", | ||
"version": "3.1.0", | ||
"description": "iCal (ics) file generator", | ||
"exports": { | ||
"require": "./index.js", | ||
"types": "./index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"main": "index.js", | ||
"module": "./dist/index.js", | ||
"main": "./dist/index.js", | ||
"types": "index.d.ts", | ||
@@ -12,0 +11,0 @@ "scripts": { |
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
49294
846
23