{"_id":"@cernytomas/time-slots-finder","name":"@cernytomas/time-slots-finder","dist-tags":{"latest":"0.5.6"},"versions":{"0.5.6":{"name":"@cernytomas/time-slots-finder","version":"0.5.6","description":"A module to extract available time slots from a calendar.","main":"lib/index.js","repository":{"type":"git","url":"git+https://github.com/cernytomas/time-slots-finder.git"},"bugs":{"url":"https://github.com/PINPODEV/time-slots-finder/issues"},"keywords":["calendar","ical","time","slots","timeslots","intervals","appointments","bookings","available"],"homepage":"https://github.com/PINPODEV/time-slots-finder#readme","author":{"name":"Pinpo Team","email":"contact@pinpo.fr"},"license":"MIT","private":false,"scripts":{"test":"jest","build":"tsc","prepublishOnly":"yarn build","preversion":"sh ./scripts/preversion.sh","postversion":"git push && git push --tags && sh ./scripts/changesloglink.sh"},"devDependencies":{"@types/jest":"^26.0.15","@types/node":"^14.11.8","@typescript-eslint/eslint-plugin":"^4.4.1","@typescript-eslint/parser":"^4.4.1","eslint":"^7.11.0","jest":"^26.5.3","jest-junit":"^12.0.0","mockdate":"^3.0.2","ts-jest":"^26.4.1","ts-node":"^9.0.0","typescript":"^4.0.3"},"dependencies":{"dayjs":"^1.9.3","ical2json":"^3.0.0"},"directories":{"lib":"lib","test":"tests"},"gitHead":"a98018dea43c885d5cf4872a492f97042362cde4","_id":"@cernytomas/time-slots-finder@0.5.6","_nodeVersion":"12.6.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-nIXYJrNjgH/fopN70ohNaob8EcHU46Nq5lDDL7/2wKJlA1VtHUo63TPCdKNWAKvw39C+3PB8J6zYlFrUWzx5YQ==","shasum":"0e17425221f97c6b79f97b95b5933a7f5df0d41b","tarball":"https://registry.npmjs.org/@cernytomas/time-slots-finder/-/time-slots-finder-0.5.6.tgz","fileCount":19,"unpackedSize":43865,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC3DgHp27iZhuVZyIZ06N+THNJi8s96ADfGf8AxSr7y1wIhAMayAUimImLG79xW2WemntreGOMJNjcmnXWyU4nXtOId"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkU8LGACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrMUw/+M8XGO49zxWFWGlMzMC9TgSddfOUySNKobKbnQFXXIhghjf/O\r\nbHbiZkOYSU2WXpbL/i/L+iKx5vuD2o5v2NC+ktrCsL01HlGAI85l4nA1LPXZ\r\n+NsUuuMxMWieeNwg08SrH+Tcbq1HSh9U+tEsSOqysX1iIEGlzo/2xlemKVMt\r\nWEL7vmRGuihOM+muMILmoT49KwA2lk8qO4NxuIuOAZ++ylaNE3CjW9/lLv5u\r\nMQJqf4HN9bScdCaK5dJ88czl9atvnalAWClCWCw0Ggj44RjjVGxFB1UtLkAx\r\neDmGvOkgHmtM2/iJXZIJwvoBAXa3cU/kYu+rbKPhVXYFZaclJ4H+XMrr4qui\r\n0yXitA5pbQuIiOJ8tIWn4BZscdqV56jsmrA8og/XUSmLuvldaUwtI9OtjzbW\r\nxCXjV/VfmD3aX6pCACUNY8vpxC/C4utrKADmFiXrl+FUpvgqKndUUkFHT0BP\r\numk2Hurg3Bxfuk1BQVL7TFo5bL97xIBgfDaphh+dB3zceItYdf+p3ZHgUBAd\r\nTcn2zWUZyMzwdaHc/VunWaCyIAyNEv3qcL4FrYFChOf0uLURuTo5khHnGBR1\r\nX+gSMlI9bZKONipW0MHRM5Gc6AvbAuCydOETgViSyEo6RDMnBD+BBh2vYUvP\r\nCx7T8jWxIbRNhMLF+9iFGu//JAxqcESKRAI=\r\n=RNnU\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"cernytomas","email":"cernytomasj@gmail.com"},"maintainers":[{"name":"cernytomas","email":"cernytomasj@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/time-slots-finder_0.5.6_1683210949899_0.976934942940709"},"_hasShrinkwrap":false}},"time":{"created":"2023-05-04T14:35:49.841Z","0.5.6":"2023-05-04T14:35:50.040Z","modified":"2023-05-04T14:35:50.225Z"},"maintainers":[{"name":"cernytomas","email":"cernytomasj@gmail.com"}],"description":"A module to extract available time slots from a calendar.","homepage":"https://github.com/PINPODEV/time-slots-finder#readme","keywords":["calendar","ical","time","slots","timeslots","intervals","appointments","bookings","available"],"repository":{"type":"git","url":"git+https://github.com/cernytomas/time-slots-finder.git"},"author":{"name":"Pinpo Team","email":"contact@pinpo.fr"},"bugs":{"url":"https://github.com/PINPODEV/time-slots-finder/issues"},"license":"MIT","readme":"# Time Slots Finder\n\n![Module Version](https://badgen.net/npm/v/time-slots-finder)\n![License](https://badgen.net/npm/license/time-slots-finder)\n![Bundle Size](https://badgen.net/bundlephobia/minzip/time-slots-finder)\n[![Maintainability](https://api.codeclimate.com/v1/badges/d725b8e849c5cb063866/maintainability)](https://codeclimate.com/repos/5f89a743f73a06460500078a/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/d725b8e849c5cb063866/test_coverage)](https://codeclimate.com/repos/5f89a743f73a06460500078a/test_coverage)\n\nAn API to get available time slots. It's possible to provide a calendar\ncontaining existing events.\n\n**Disclaimer**\n> This module is currently still in pre-version. **BREAKING CHANGES may occurs in MINOR\n> versions**. Use it with care.\n\n## Features\n- Define slots duration\n- Require free time before and/or after slots\n- Define bookable shifts for day of the week\n- Work with or without calendar data\n- Handle iCal format for calendar data\n- Take time zones in account when parsing calendar and for the configuration\n- Includes **TypeScript definitions**\n- High test coverage\n\n## Install\n\n```shell script\nnpm install --save time-slots-finder\n```\n```shell script\nyarn add time-slots-finder\n```\n\n## Documentation\n### Usage\n```typescript\nimport * as TimeSlotsFinder from \"time-slots-finder\"\n\nconst slots = TimeSlotsFinder.getAvailableTimeSlotsInCalendar({\n    calendarData: \"SOME ICAL DATA\",\n    calendarFormat: TimeSlotsFinder.TimeSlotsFinderCalendarFormat.iCal,\n    configuration: {\n        timeSlotDuration: 15,\n        minAvailableTimeBeforeSlot: 5,\n        minTimeBeforeFirstSlot: 48 * 60, // 48 hours in minutes\n        availablePeriods: [{\n            isoWeekDay: 5,\n            shifts: [{ startTime: \"10:00\", endTime: \"20:00\" }] \n        }, {\n            isoWeekDay: 6,\n            shifts: [\n                { startTime: \"10:00\", endTime: \"20:00\" },\n                { startTime: \"10:00\", endTime: \"13:00\" },\n            ]\n        }],\n        timeZone: \"Europe/Paris\",   \n    },\n    from: new Date(\"2020-09-21T00:00:00.000+02:00\"),\n    to: new Date(\"2020-11-12T23:59:59.999+02:00\"),\n})\n\n/**\n * This will returns all free time slots between September's 21th and\n * November's 12th, only for all Friday from 10 AM to 8 PM (Paris time) and\n * Satursday from 10 AM to 1 PM. All slots will be 15 minutes long with 5\n * minutes free before each. If we were the 21th of September the first slot\n * would have been on the the 23th (since we require 48 hours before the first\n * availabilities.\n */\n```\n\nA **TimeSlot** is represented as follows:\n```typescript\n{\n    /* The start date of the period */\n    startAt: Date\n    /* The end date of the period */\n    endAt: Date\n    /* The duration of the slot in minutes */\n    duration: number\n}\n```\n\n### Configuration options\n\n```typescript\n/* Required. The length of the time slots in minutes. */\ntimeSlotDuration: number\n```\n```typescript\n/**\n * A number indicating the step for the start minute of a slot.\n * E.g. if the multiple is 15, slots can only begin at XX:00, XX:15, XX:30 or XX:45.\n * Default value is 5.\n */\nslotStartMinuteStep: number\n```\n```typescript\n/* Required. Bookable periods for each day of the week. */\navailablePeriods: [{\n    isoWeekDay: number, // 1 (Monday) - 7 (Sunday)\n    shifts: [{\n        startTime: string, // Format \"HH:mm\"\n        endTime: string, // Format \"HH:mm\"\n    }]\n}]\n```\n```typescript\n/**\n * Periods where no booking is allowed.\n * \n * Objet containing at least month and day values.\n * If years are ommited, event repeat every years.\n * If hour are ommited, all day is included: hour 00:00 is used for startAt and 23:59 is used for\n * endAt.\n * Month are 0 indexed, i.e. January is 0 and December is 11. \n * An unavailable period MUST have year defined for BOTH OR NONE of startAt and endAt.\n */\nunavailablePeriods: [{\n    startAt: { year?: number, month: number, day: number, hour?: number, minute?: number },\n    endAt: { year?: number, month: number, day: number, hour?: number, minute?: number },\n}]\n```\n```typescript\n/* The minimum number of free minutes required before a slot. */\nminAvailableTimeBeforeSlot: number\n```\n```typescript\n/* The minimum number of free minutes required after a slot. */\nminAvailableTimeAfterSlot: number\n```\n```typescript\n/**\n * The minimum number of minutes between the time of the search and the first slot\n * returned.\n */\nminTimeBeforeFirstSlot: number\n```\n```typescript\n/* The maximum days from now before slots cannot be returned anymore. */\nmaxDaysBeforeLastSlot: number\n```\n```typescript\n/* Required. The time zone used through all the configuration. */\ntimeZone: string\n```\n[See the time zones list here.](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)\n\n### Advanced usage\nIf you want to check that a configuration is valid without running a search,\n you can use the `isConfigurationValid` function as follows:\n\n```typescript\nimport * as TimeSlotsFinder from \"time-slots-finder\"\n\nconst config = {\n    timeSlotDuration: 15,\n    availablePeriods: [{\n        isoWeekDay: 5,\n        shifts: [{ startTime: \"20:00\", endTime: \"10:00\" }] \n    }, {\n        isoWeekDay: 6,\n        shifts: [\n            { startTime: \"10:00\", endTime: \"20:00\" },\n            { startTime: \"10:00\", endTime: \"13:00\" },\n        ]\n    }],\n    timeZone: \"Europe/Paris\",   \n}\n\ntry {\n    TimeSlotsFinder.isConfigurationValid(config) // returns true is valid\n} catch (error) {\n    /**\n     * Throws error if configuration is invalid.\n     * The error indicate why and where the configuration is invalid.\n     *\n     * Here the error is:\n     * \"TimeSlotsFinderError: Daily shift 20:00 - 10:00 for work period nº1 is invalid\"\n     */\n}\n```\n\n## What's next?\n- We consider handling more calendar formats in the future.\n- The API may change until the first version (v1.0.0) is released \n","readmeFilename":"README.md"}