@nylas/web-elements 1.0.0-prealpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/cjs/_commonjsHelpers-0a7b82d9.js +23 -0
- package/dist/cjs/_commonjsHelpers-0a7b82d9.js.map +1 -0
- package/dist/cjs/app-globals-d58ac016.js +11 -0
- package/dist/cjs/app-globals-d58ac016.js.map +1 -0
- package/dist/cjs/archive-icon_7.cjs.entry.js +120 -0
- package/dist/cjs/archive-icon_7.cjs.entry.js.map +1 -0
- package/dist/cjs/arrow-icon.cjs.entry.js +24 -0
- package/dist/cjs/arrow-icon.cjs.entry.js.map +1 -0
- package/dist/cjs/bold-icon_3.cjs.entry.js +56 -0
- package/dist/cjs/bold-icon_3.cjs.entry.js.map +1 -0
- package/dist/cjs/calendar-cancel-icon.cjs.entry.js +24 -0
- package/dist/cjs/calendar-cancel-icon.cjs.entry.js.map +1 -0
- package/dist/cjs/calendar-check-icon_3.cjs.entry.js +56 -0
- package/dist/cjs/calendar-check-icon_3.cjs.entry.js.map +1 -0
- package/dist/cjs/calendar-icon.cjs.entry.js +24 -0
- package/dist/cjs/calendar-icon.cjs.entry.js.map +1 -0
- package/dist/cjs/chevron-icon.cjs.entry.js +24 -0
- package/dist/cjs/chevron-icon.cjs.entry.js.map +1 -0
- package/dist/cjs/close-icon_2.cjs.entry.js +40 -0
- package/dist/cjs/close-icon_2.cjs.entry.js.map +1 -0
- package/dist/cjs/document-refresh-icon.cjs.entry.js +24 -0
- package/dist/cjs/document-refresh-icon.cjs.entry.js.map +1 -0
- package/dist/cjs/duration-18b22d1b.js +84 -0
- package/dist/cjs/duration-18b22d1b.js.map +1 -0
- package/dist/cjs/elements-b06c817b.js +21585 -0
- package/dist/cjs/elements-b06c817b.js.map +1 -0
- package/dist/cjs/flow-d922fbd4.js +891 -0
- package/dist/cjs/flow-d922fbd4.js.map +1 -0
- package/dist/cjs/focus-visible-857fc8f9.js +327 -0
- package/dist/cjs/focus-visible-857fc8f9.js.map +1 -0
- package/dist/cjs/forward-icon_6.cjs.entry.js +2216 -0
- package/dist/cjs/forward-icon_6.cjs.entry.js.map +1 -0
- package/dist/cjs/globe-icon.cjs.entry.js +24 -0
- package/dist/cjs/globe-icon.cjs.entry.js.map +1 -0
- package/dist/cjs/index-34e64e2d.js +2173 -0
- package/dist/cjs/index-34e64e2d.js.map +1 -0
- package/dist/cjs/index-e869130c.js +198 -0
- package/dist/cjs/index-e869130c.js.map +1 -0
- package/dist/cjs/index.cjs.js +12 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/index.es-e78884f5.js +3217 -0
- package/dist/cjs/index.es-e78884f5.js.map +1 -0
- package/dist/cjs/loader.cjs.js +17 -0
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/cjs/loading-icon.cjs.entry.js +24 -0
- package/dist/cjs/loading-icon.cjs.entry.js.map +1 -0
- package/dist/cjs/mailbox-store-0b1636fa.js +529 -0
- package/dist/cjs/mailbox-store-0b1636fa.js.map +1 -0
- package/dist/cjs/nylas-booked-event-card_9.cjs.entry.js +8127 -0
- package/dist/cjs/nylas-booked-event-card_9.cjs.entry.js.map +1 -0
- package/dist/cjs/nylas-if-state_3.cjs.entry.js +409 -0
- package/dist/cjs/nylas-if-state_3.cjs.entry.js.map +1 -0
- package/dist/cjs/nylas-list-folders.cjs.entry.js +120 -0
- package/dist/cjs/nylas-list-folders.cjs.entry.js.map +1 -0
- package/dist/cjs/nylas-list-threads.cjs.entry.js +89 -0
- package/dist/cjs/nylas-list-threads.cjs.entry.js.map +1 -0
- package/dist/cjs/nylas-mailbox-pagination.cjs.entry.js +140 -0
- package/dist/cjs/nylas-mailbox-pagination.cjs.entry.js.map +1 -0
- package/dist/cjs/nylas-mailbox-toolbar-button.cjs.entry.js +100 -0
- package/dist/cjs/nylas-mailbox-toolbar-button.cjs.entry.js.map +1 -0
- package/dist/cjs/nylas-open-hours-picker.cjs.entry.js +333 -0
- package/dist/cjs/nylas-open-hours-picker.cjs.entry.js.map +1 -0
- package/dist/cjs/nylas-provider.cjs.entry.js +184 -0
- package/dist/cjs/nylas-provider.cjs.entry.js.map +1 -0
- package/dist/cjs/nylas-scheduler.cjs.entry.js +242 -0
- package/dist/cjs/nylas-scheduler.cjs.entry.js.map +1 -0
- package/dist/cjs/nylas-threads-refresh.cjs.entry.js +118 -0
- package/dist/cjs/nylas-threads-refresh.cjs.entry.js.map +1 -0
- package/dist/cjs/nylas-threads-search.cjs.entry.js +84 -0
- package/dist/cjs/nylas-threads-search.cjs.entry.js.map +1 -0
- package/dist/cjs/nylas-view-thread.cjs.entry.js +234 -0
- package/dist/cjs/nylas-view-thread.cjs.entry.js.map +1 -0
- package/dist/cjs/nylas-web-elements.cjs.js +27 -0
- package/dist/cjs/nylas-web-elements.cjs.js.map +1 -0
- package/dist/cjs/play-icon_2.cjs.entry.js +40 -0
- package/dist/cjs/play-icon_2.cjs.entry.js.map +1 -0
- package/dist/cjs/property-d934a711.js +47 -0
- package/dist/cjs/property-d934a711.js.map +1 -0
- package/dist/cjs/refresh-icon.cjs.entry.js +24 -0
- package/dist/cjs/refresh-icon.cjs.entry.js.map +1 -0
- package/dist/cjs/register-component-f76b61a6.js +140 -0
- package/dist/cjs/register-component-f76b61a6.js.map +1 -0
- package/dist/cjs/scheduler-store-e9822441.js +254 -0
- package/dist/cjs/scheduler-store-e9822441.js.map +1 -0
- package/dist/cjs/translate-icon.cjs.entry.js +24 -0
- package/dist/cjs/translate-icon.cjs.entry.js.map +1 -0
- package/dist/cjs/utils-f91d4c73.js +161 -0
- package/dist/cjs/utils-f91d4c73.js.map +1 -0
- package/dist/collection/assets/icons/chevron.svg +3 -0
- package/dist/collection/collection-manifest.json +66 -0
- package/dist/collection/common/abstract-provider.js +231 -0
- package/dist/collection/common/abstract-provider.js.map +1 -0
- package/dist/collection/common/component-types.js +2 -0
- package/dist/collection/common/component-types.js.map +1 -0
- package/dist/collection/common/constants.js +12 -0
- package/dist/collection/common/constants.js.map +1 -0
- package/dist/collection/common/global.js +4 -0
- package/dist/collection/common/global.js.map +1 -0
- package/dist/collection/common/icons/archive.js +63 -0
- package/dist/collection/common/icons/archive.js.map +1 -0
- package/dist/collection/common/icons/arrow.js +63 -0
- package/dist/collection/common/icons/arrow.js.map +1 -0
- package/dist/collection/common/icons/bold.js +63 -0
- package/dist/collection/common/icons/bold.js.map +1 -0
- package/dist/collection/common/icons/calendar-cancel.js +63 -0
- package/dist/collection/common/icons/calendar-cancel.js.map +1 -0
- package/dist/collection/common/icons/calendar-check.js +63 -0
- package/dist/collection/common/icons/calendar-check.js.map +1 -0
- package/dist/collection/common/icons/calendar.js +63 -0
- package/dist/collection/common/icons/calendar.js.map +1 -0
- package/dist/collection/common/icons/checkmark-circle.js +63 -0
- package/dist/collection/common/icons/checkmark-circle.js.map +1 -0
- package/dist/collection/common/icons/chevron.js +63 -0
- package/dist/collection/common/icons/chevron.js.map +1 -0
- package/dist/collection/common/icons/close.js +63 -0
- package/dist/collection/common/icons/close.js.map +1 -0
- package/dist/collection/common/icons/document-refresh.js +63 -0
- package/dist/collection/common/icons/document-refresh.js.map +1 -0
- package/dist/collection/common/icons/folder.js +63 -0
- package/dist/collection/common/icons/folder.js.map +1 -0
- package/dist/collection/common/icons/forward.js +63 -0
- package/dist/collection/common/icons/forward.js.map +1 -0
- package/dist/collection/common/icons/globe.js +63 -0
- package/dist/collection/common/icons/globe.js.map +1 -0
- package/dist/collection/common/icons/icon.css +3 -0
- package/dist/collection/common/icons/inbox.js +63 -0
- package/dist/collection/common/icons/inbox.js.map +1 -0
- package/dist/collection/common/icons/italic.js +63 -0
- package/dist/collection/common/icons/italic.js.map +1 -0
- package/dist/collection/common/icons/loading.css +33 -0
- package/dist/collection/common/icons/loading.js +63 -0
- package/dist/collection/common/icons/loading.js.map +1 -0
- package/dist/collection/common/icons/nylas-logo.js +63 -0
- package/dist/collection/common/icons/nylas-logo.js.map +1 -0
- package/dist/collection/common/icons/people.js +63 -0
- package/dist/collection/common/icons/people.js.map +1 -0
- package/dist/collection/common/icons/play.js +63 -0
- package/dist/collection/common/icons/play.js.map +1 -0
- package/dist/collection/common/icons/refresh.js +63 -0
- package/dist/collection/common/icons/refresh.js.map +1 -0
- package/dist/collection/common/icons/reply-all.js +63 -0
- package/dist/collection/common/icons/reply-all.js.map +1 -0
- package/dist/collection/common/icons/reply.js +63 -0
- package/dist/collection/common/icons/reply.js.map +1 -0
- package/dist/collection/common/icons/sent.js +63 -0
- package/dist/collection/common/icons/sent.js.map +1 -0
- package/dist/collection/common/icons/spam.js +63 -0
- package/dist/collection/common/icons/spam.js.map +1 -0
- package/dist/collection/common/icons/star.js +63 -0
- package/dist/collection/common/icons/star.js.map +1 -0
- package/dist/collection/common/icons/stop.js +63 -0
- package/dist/collection/common/icons/stop.js.map +1 -0
- package/dist/collection/common/icons/translate.js +63 -0
- package/dist/collection/common/icons/translate.js.map +1 -0
- package/dist/collection/common/icons/trash.js +63 -0
- package/dist/collection/common/icons/trash.js.map +1 -0
- package/dist/collection/common/icons/underline.js +63 -0
- package/dist/collection/common/icons/underline.js.map +1 -0
- package/dist/collection/common/icons/warning.js +63 -0
- package/dist/collection/common/icons/warning.js.map +1 -0
- package/dist/collection/common/mocks/threads.js +57 -0
- package/dist/collection/common/mocks/threads.js.map +1 -0
- package/dist/collection/common/nylas-theme/index.js +4 -0
- package/dist/collection/common/nylas-theme/index.js.map +1 -0
- package/dist/collection/common/register-component.js +134 -0
- package/dist/collection/common/register-component.js.map +1 -0
- package/dist/collection/common/types.js +2 -0
- package/dist/collection/common/types.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-composer/nylas-composer.css +89 -0
- package/dist/collection/components/mailbox/nylas-composer/nylas-composer.js +241 -0
- package/dist/collection/components/mailbox/nylas-composer/nylas-composer.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-composer/test/nylas-composer.e2e.js +10 -0
- package/dist/collection/components/mailbox/nylas-composer/test/nylas-composer.e2e.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-composer/test/nylas-composer.spec-disabled.js +12 -0
- package/dist/collection/components/mailbox/nylas-composer/test/nylas-composer.spec-disabled.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-list-folders/nylas-list-folders.css +37 -0
- package/dist/collection/components/mailbox/nylas-list-folders/nylas-list-folders.js +193 -0
- package/dist/collection/components/mailbox/nylas-list-folders/nylas-list-folders.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-list-folders/test/nylas-list-folders.e2e.js +10 -0
- package/dist/collection/components/mailbox/nylas-list-folders/test/nylas-list-folders.e2e.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-list-folders/test/nylas-list-folders.spec.js +12 -0
- package/dist/collection/components/mailbox/nylas-list-folders/test/nylas-list-folders.spec.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-list-threads/nylas-list-threads.css +156 -0
- package/dist/collection/components/mailbox/nylas-list-threads/nylas-list-threads.js +218 -0
- package/dist/collection/components/mailbox/nylas-list-threads/nylas-list-threads.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-list-threads/test/nylas-list-threads.e2e.js +22 -0
- package/dist/collection/components/mailbox/nylas-list-threads/test/nylas-list-threads.e2e.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-list-threads/test/nylas-list-threads.spec.js +25 -0
- package/dist/collection/components/mailbox/nylas-list-threads/test/nylas-list-threads.spec.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-mailbox/nylas-mailbox.css +3 -0
- package/dist/collection/components/mailbox/nylas-mailbox/nylas-mailbox.js +474 -0
- package/dist/collection/components/mailbox/nylas-mailbox/nylas-mailbox.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-mailbox/test/nylas-mailbox.e2e.js +16 -0
- package/dist/collection/components/mailbox/nylas-mailbox/test/nylas-mailbox.e2e.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-mailbox/test/nylas-mailbox.spec.js +32 -0
- package/dist/collection/components/mailbox/nylas-mailbox/test/nylas-mailbox.spec.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-mailbox-pagination/nylas-mailbox-pagination.css +55 -0
- package/dist/collection/components/mailbox/nylas-mailbox-pagination/nylas-mailbox-pagination.js +371 -0
- package/dist/collection/components/mailbox/nylas-mailbox-pagination/nylas-mailbox-pagination.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-mailbox-pagination/test/nylas-mailbox-pagination.e2e.js +10 -0
- package/dist/collection/components/mailbox/nylas-mailbox-pagination/test/nylas-mailbox-pagination.e2e.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-mailbox-pagination/test/nylas-mailbox-pagination.spec.js +12 -0
- package/dist/collection/components/mailbox/nylas-mailbox-pagination/test/nylas-mailbox-pagination.spec.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-mailbox-toolbar-button/nylas-mailbox-toolbar-button.css +18 -0
- package/dist/collection/components/mailbox/nylas-mailbox-toolbar-button/nylas-mailbox-toolbar-button.js +182 -0
- package/dist/collection/components/mailbox/nylas-mailbox-toolbar-button/nylas-mailbox-toolbar-button.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-summarize-message-button/nylas-summarize-message-button.css +61 -0
- package/dist/collection/components/mailbox/nylas-summarize-message-button/nylas-summarize-message-button.js +329 -0
- package/dist/collection/components/mailbox/nylas-summarize-message-button/nylas-summarize-message-button.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-summarize-message-button/test/nylas-summarize-message-button.e2e.js +10 -0
- package/dist/collection/components/mailbox/nylas-summarize-message-button/test/nylas-summarize-message-button.e2e.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-summarize-message-button/test/nylas-summarize-message-button.spec.js +12 -0
- package/dist/collection/components/mailbox/nylas-summarize-message-button/test/nylas-summarize-message-button.spec.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-threads-refresh/nylas-threads-refresh.css +53 -0
- package/dist/collection/components/mailbox/nylas-threads-refresh/nylas-threads-refresh.js +172 -0
- package/dist/collection/components/mailbox/nylas-threads-refresh/nylas-threads-refresh.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-threads-refresh/test/nylas-threads-refresh.e2e.js +10 -0
- package/dist/collection/components/mailbox/nylas-threads-refresh/test/nylas-threads-refresh.e2e.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-threads-refresh/test/nylas-threads-refresh.spec.js +12 -0
- package/dist/collection/components/mailbox/nylas-threads-refresh/test/nylas-threads-refresh.spec.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-threads-search/nylas-threads-search.css +8 -0
- package/dist/collection/components/mailbox/nylas-threads-search/nylas-threads-search.js +130 -0
- package/dist/collection/components/mailbox/nylas-threads-search/nylas-threads-search.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-threads-search/test/nylas-threads-search.e2e.js +10 -0
- package/dist/collection/components/mailbox/nylas-threads-search/test/nylas-threads-search.e2e.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-threads-search/test/nylas-threads-search.spec.js +12 -0
- package/dist/collection/components/mailbox/nylas-threads-search/test/nylas-threads-search.spec.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-view-email/nylas-view-email.css +43 -0
- package/dist/collection/components/mailbox/nylas-view-email/nylas-view-email.js +282 -0
- package/dist/collection/components/mailbox/nylas-view-email/nylas-view-email.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-view-thread/nylas-view-thread.css +243 -0
- package/dist/collection/components/mailbox/nylas-view-thread/nylas-view-thread.js +342 -0
- package/dist/collection/components/mailbox/nylas-view-thread/nylas-view-thread.js.map +1 -0
- package/dist/collection/components/mailbox/nylas-view-thread/view-thread-message.js +25 -0
- package/dist/collection/components/mailbox/nylas-view-thread/view-thread-message.js.map +1 -0
- package/dist/collection/components/nylas-if-state/nylas-if-state.css +84 -0
- package/dist/collection/components/nylas-if-state/nylas-if-state.js +241 -0
- package/dist/collection/components/nylas-if-state/nylas-if-state.js.map +1 -0
- package/dist/collection/components/nylas-if-state/test/nylas-if-state.e2e.js +10 -0
- package/dist/collection/components/nylas-if-state/test/nylas-if-state.e2e.js.map +1 -0
- package/dist/collection/components/nylas-if-state/test/nylas-if-state.spec.js +12 -0
- package/dist/collection/components/nylas-if-state/test/nylas-if-state.spec.js.map +1 -0
- package/dist/collection/components/nylas-login/nylas-login.css +94 -0
- package/dist/collection/components/nylas-login/nylas-login.js +289 -0
- package/dist/collection/components/nylas-login/nylas-login.js.map +1 -0
- package/dist/collection/components/nylas-login/test/nylas-login.e2e.js +10 -0
- package/dist/collection/components/nylas-login/test/nylas-login.e2e.js.map +1 -0
- package/dist/collection/components/nylas-login/test/nylas-login.spec.js +12 -0
- package/dist/collection/components/nylas-login/test/nylas-login.spec.js.map +1 -0
- package/dist/collection/components/nylas-provider/nylas-provider.css +3 -0
- package/dist/collection/components/nylas-provider/nylas-provider.js +423 -0
- package/dist/collection/components/nylas-provider/nylas-provider.js.map +1 -0
- package/dist/collection/components/nylas-provider/test/nylas-provider.e2e.js +10 -0
- package/dist/collection/components/nylas-provider/test/nylas-provider.e2e.js.map +1 -0
- package/dist/collection/components/nylas-provider/test/nylas-provider.spec.js +32 -0
- package/dist/collection/components/nylas-provider/test/nylas-provider.spec.js.map +1 -0
- package/dist/collection/components/scheduler/nylas-booked-event-card/nylas-booked-event-card.css +155 -0
- package/dist/collection/components/scheduler/nylas-booked-event-card/nylas-booked-event-card.js +178 -0
- package/dist/collection/components/scheduler/nylas-booked-event-card/nylas-booked-event-card.js.map +1 -0
- package/dist/collection/components/scheduler/nylas-booking-form/nylas-booking-form.css +129 -0
- package/dist/collection/components/scheduler/nylas-booking-form/nylas-booking-form.js +323 -0
- package/dist/collection/components/scheduler/nylas-booking-form/nylas-booking-form.js.map +1 -0
- package/dist/collection/components/scheduler/nylas-cancelled-event-card/nylas-cancelled-event-card.css +78 -0
- package/dist/collection/components/scheduler/nylas-cancelled-event-card/nylas-cancelled-event-card.js +107 -0
- package/dist/collection/components/scheduler/nylas-cancelled-event-card/nylas-cancelled-event-card.js.map +1 -0
- package/dist/collection/components/scheduler/nylas-date-picker/nylas-date-picker.css +150 -0
- package/dist/collection/components/scheduler/nylas-date-picker/nylas-date-picker.js +213 -0
- package/dist/collection/components/scheduler/nylas-date-picker/nylas-date-picker.js.map +1 -0
- package/dist/collection/components/scheduler/nylas-locale-switch/nylas-locale-switch.css +72 -0
- package/dist/collection/components/scheduler/nylas-locale-switch/nylas-locale-switch.js +147 -0
- package/dist/collection/components/scheduler/nylas-locale-switch/nylas-locale-switch.js.map +1 -0
- package/dist/collection/components/scheduler/nylas-notification/nylas-notification.css +63 -0
- package/dist/collection/components/scheduler/nylas-notification/nylas-notification.js +132 -0
- package/dist/collection/components/scheduler/nylas-notification/nylas-notification.js.map +1 -0
- package/dist/collection/components/scheduler/nylas-open-hours-picker/nylas-open-hours-picker.css +105 -0
- package/dist/collection/components/scheduler/nylas-open-hours-picker/nylas-open-hours-picker.js +460 -0
- package/dist/collection/components/scheduler/nylas-open-hours-picker/nylas-open-hours-picker.js.map +1 -0
- package/dist/collection/components/scheduler/nylas-open-hours-picker/test/nylas-open-hours-picker.e2e.js +10 -0
- package/dist/collection/components/scheduler/nylas-open-hours-picker/test/nylas-open-hours-picker.e2e.js.map +1 -0
- package/dist/collection/components/scheduler/nylas-open-hours-picker/test/nylas-open-hours-picker.spec.js +12 -0
- package/dist/collection/components/scheduler/nylas-open-hours-picker/test/nylas-open-hours-picker.spec.js.map +1 -0
- package/dist/collection/components/scheduler/nylas-scheduler/nylas-scheduler.css +182 -0
- package/dist/collection/components/scheduler/nylas-scheduler/nylas-scheduler.js +533 -0
- package/dist/collection/components/scheduler/nylas-scheduler/nylas-scheduler.js.map +1 -0
- package/dist/collection/components/scheduler/nylas-scheduler/scheduler-view.js +6 -0
- package/dist/collection/components/scheduler/nylas-scheduler/scheduler-view.js.map +1 -0
- package/dist/collection/components/scheduler/nylas-selected-event-card/nylas-selected-event-card.css +63 -0
- package/dist/collection/components/scheduler/nylas-selected-event-card/nylas-selected-event-card.js +150 -0
- package/dist/collection/components/scheduler/nylas-selected-event-card/nylas-selected-event-card.js.map +1 -0
- package/dist/collection/components/scheduler/nylas-timeslot-picker/nylas-timeslot-picker.css +115 -0
- package/dist/collection/components/scheduler/nylas-timeslot-picker/nylas-timeslot-picker.js +311 -0
- package/dist/collection/components/scheduler/nylas-timeslot-picker/nylas-timeslot-picker.js.map +1 -0
- package/dist/collection/connector/connector-interface.js +2 -0
- package/dist/collection/connector/connector-interface.js.map +1 -0
- package/dist/collection/connector/nylas-connector/index.js +78 -0
- package/dist/collection/connector/nylas-connector/index.js.map +1 -0
- package/dist/collection/connector/nylas-mailbox-connector/index.js +62 -0
- package/dist/collection/connector/nylas-mailbox-connector/index.js.map +1 -0
- package/dist/collection/connector/nylas-scheduler-connector/index.js +43 -0
- package/dist/collection/connector/nylas-scheduler-connector/index.js.map +1 -0
- package/dist/collection/connector/shared/api/auth.js +60 -0
- package/dist/collection/connector/shared/api/auth.js.map +1 -0
- package/dist/collection/connector/shared/api/folders.js +33 -0
- package/dist/collection/connector/shared/api/folders.js.map +1 -0
- package/dist/collection/connector/shared/api/messages.js +95 -0
- package/dist/collection/connector/shared/api/messages.js.map +1 -0
- package/dist/collection/connector/shared/api/scheduler.js +203 -0
- package/dist/collection/connector/shared/api/scheduler.js.map +1 -0
- package/dist/collection/connector/shared/api/threads.js +165 -0
- package/dist/collection/connector/shared/api/threads.js.map +1 -0
- package/dist/collection/index.js +4 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/routers/hash-router.js +109 -0
- package/dist/collection/routers/hash-router.js.map +1 -0
- package/dist/collection/routers/router-interface.js +2 -0
- package/dist/collection/routers/router-interface.js.map +1 -0
- package/dist/collection/stores/auth-store.js +18 -0
- package/dist/collection/stores/auth-store.js.map +1 -0
- package/dist/collection/stores/mailbox-store.js +42 -0
- package/dist/collection/stores/mailbox-store.js.map +1 -0
- package/dist/collection/stores/scheduler-store.js +44 -0
- package/dist/collection/stores/scheduler-store.js.map +1 -0
- package/dist/collection/utils/color-utils.js +161 -0
- package/dist/collection/utils/color-utils.js.map +1 -0
- package/dist/collection/utils/utils.js +157 -0
- package/dist/collection/utils/utils.js.map +1 -0
- package/dist/collection/utils/utils.spec.js +16 -0
- package/dist/collection/utils/utils.spec.js.map +1 -0
- package/dist/components/_commonjsHelpers.js +20 -0
- package/dist/components/_commonjsHelpers.js.map +1 -0
- package/dist/components/archive-icon.d.ts +11 -0
- package/dist/components/archive-icon.js +8 -0
- package/dist/components/archive-icon.js.map +1 -0
- package/dist/components/archive.js +37 -0
- package/dist/components/archive.js.map +1 -0
- package/dist/components/arrow-icon.d.ts +11 -0
- package/dist/components/arrow-icon.js +8 -0
- package/dist/components/arrow-icon.js.map +1 -0
- package/dist/components/arrow.js +37 -0
- package/dist/components/arrow.js.map +1 -0
- package/dist/components/assets/chevron.svg +3 -0
- package/dist/components/bold-icon.d.ts +11 -0
- package/dist/components/bold-icon.js +8 -0
- package/dist/components/bold-icon.js.map +1 -0
- package/dist/components/bold.js +37 -0
- package/dist/components/bold.js.map +1 -0
- package/dist/components/calendar-cancel-icon.d.ts +11 -0
- package/dist/components/calendar-cancel-icon.js +8 -0
- package/dist/components/calendar-cancel-icon.js.map +1 -0
- package/dist/components/calendar-cancel.js +37 -0
- package/dist/components/calendar-cancel.js.map +1 -0
- package/dist/components/calendar-check-icon.d.ts +11 -0
- package/dist/components/calendar-check-icon.js +8 -0
- package/dist/components/calendar-check-icon.js.map +1 -0
- package/dist/components/calendar-check.js +37 -0
- package/dist/components/calendar-check.js.map +1 -0
- package/dist/components/calendar-icon.d.ts +11 -0
- package/dist/components/calendar-icon.js +8 -0
- package/dist/components/calendar-icon.js.map +1 -0
- package/dist/components/calendar.js +37 -0
- package/dist/components/calendar.js.map +1 -0
- package/dist/components/checkmark-circle-icon.d.ts +11 -0
- package/dist/components/checkmark-circle-icon.js +8 -0
- package/dist/components/checkmark-circle-icon.js.map +1 -0
- package/dist/components/checkmark-circle.js +37 -0
- package/dist/components/checkmark-circle.js.map +1 -0
- package/dist/components/chevron-icon.d.ts +11 -0
- package/dist/components/chevron-icon.js +8 -0
- package/dist/components/chevron-icon.js.map +1 -0
- package/dist/components/chevron.js +37 -0
- package/dist/components/chevron.js.map +1 -0
- package/dist/components/close-icon.d.ts +11 -0
- package/dist/components/close-icon.js +8 -0
- package/dist/components/close-icon.js.map +1 -0
- package/dist/components/close.js +37 -0
- package/dist/components/close.js.map +1 -0
- package/dist/components/constants.js +7296 -0
- package/dist/components/constants.js.map +1 -0
- package/dist/components/define-element.js +40 -0
- package/dist/components/define-element.js.map +1 -0
- package/dist/components/document-refresh-icon.d.ts +11 -0
- package/dist/components/document-refresh-icon.js +40 -0
- package/dist/components/document-refresh-icon.js.map +1 -0
- package/dist/components/duration.js +78 -0
- package/dist/components/duration.js.map +1 -0
- package/dist/components/elements.js +21583 -0
- package/dist/components/elements.js.map +1 -0
- package/dist/components/flow.js +888 -0
- package/dist/components/flow.js.map +1 -0
- package/dist/components/focus-visible.js +325 -0
- package/dist/components/focus-visible.js.map +1 -0
- package/dist/components/folder-icon.d.ts +11 -0
- package/dist/components/folder-icon.js +8 -0
- package/dist/components/folder-icon.js.map +1 -0
- package/dist/components/folder.js +37 -0
- package/dist/components/folder.js.map +1 -0
- package/dist/components/forward-icon.d.ts +11 -0
- package/dist/components/forward-icon.js +8 -0
- package/dist/components/forward-icon.js.map +1 -0
- package/dist/components/forward.js +37 -0
- package/dist/components/forward.js.map +1 -0
- package/dist/components/globe-icon.d.ts +11 -0
- package/dist/components/globe-icon.js +8 -0
- package/dist/components/globe-icon.js.map +1 -0
- package/dist/components/globe.js +37 -0
- package/dist/components/globe.js.map +1 -0
- package/dist/components/inbox-icon.d.ts +11 -0
- package/dist/components/inbox-icon.js +8 -0
- package/dist/components/inbox-icon.js.map +1 -0
- package/dist/components/inbox.js +37 -0
- package/dist/components/inbox.js.map +1 -0
- package/dist/components/index.d.ts +33 -0
- package/dist/components/index.es.js +3211 -0
- package/dist/components/index.es.js.map +1 -0
- package/dist/components/index.js +16 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index2.js +196 -0
- package/dist/components/index2.js.map +1 -0
- package/dist/components/italic-icon.d.ts +11 -0
- package/dist/components/italic-icon.js +8 -0
- package/dist/components/italic-icon.js.map +1 -0
- package/dist/components/italic.js +37 -0
- package/dist/components/italic.js.map +1 -0
- package/dist/components/loading-icon.d.ts +11 -0
- package/dist/components/loading-icon.js +8 -0
- package/dist/components/loading-icon.js.map +1 -0
- package/dist/components/loading.js +38 -0
- package/dist/components/loading.js.map +1 -0
- package/dist/components/mailbox-store.js +521 -0
- package/dist/components/mailbox-store.js.map +1 -0
- package/dist/components/nylas-booked-event-card.d.ts +11 -0
- package/dist/components/nylas-booked-event-card.js +8 -0
- package/dist/components/nylas-booked-event-card.js.map +1 -0
- package/dist/components/nylas-booked-event-card2.js +121 -0
- package/dist/components/nylas-booked-event-card2.js.map +1 -0
- package/dist/components/nylas-booking-form.d.ts +11 -0
- package/dist/components/nylas-booking-form.js +8 -0
- package/dist/components/nylas-booking-form.js.map +1 -0
- package/dist/components/nylas-booking-form2.js +224 -0
- package/dist/components/nylas-booking-form2.js.map +1 -0
- package/dist/components/nylas-cancelled-event-card.d.ts +11 -0
- package/dist/components/nylas-cancelled-event-card.js +8 -0
- package/dist/components/nylas-cancelled-event-card.js.map +1 -0
- package/dist/components/nylas-cancelled-event-card2.js +85 -0
- package/dist/components/nylas-cancelled-event-card2.js.map +1 -0
- package/dist/components/nylas-composer.d.ts +11 -0
- package/dist/components/nylas-composer.js +8 -0
- package/dist/components/nylas-composer.js.map +1 -0
- package/dist/components/nylas-composer2.js +186 -0
- package/dist/components/nylas-composer2.js.map +1 -0
- package/dist/components/nylas-date-picker.d.ts +11 -0
- package/dist/components/nylas-date-picker.js +8 -0
- package/dist/components/nylas-date-picker.js.map +1 -0
- package/dist/components/nylas-date-picker2.js +150 -0
- package/dist/components/nylas-date-picker2.js.map +1 -0
- package/dist/components/nylas-if-state.d.ts +11 -0
- package/dist/components/nylas-if-state.js +153 -0
- package/dist/components/nylas-if-state.js.map +1 -0
- package/dist/components/nylas-list-folders.d.ts +11 -0
- package/dist/components/nylas-list-folders.js +183 -0
- package/dist/components/nylas-list-folders.js.map +1 -0
- package/dist/components/nylas-list-threads.d.ts +11 -0
- package/dist/components/nylas-list-threads.js +109 -0
- package/dist/components/nylas-list-threads.js.map +1 -0
- package/dist/components/nylas-locale-switch.d.ts +11 -0
- package/dist/components/nylas-locale-switch.js +8 -0
- package/dist/components/nylas-locale-switch.js.map +1 -0
- package/dist/components/nylas-locale-switch2.js +103 -0
- package/dist/components/nylas-locale-switch2.js.map +1 -0
- package/dist/components/nylas-login.d.ts +11 -0
- package/dist/components/nylas-login.js +127 -0
- package/dist/components/nylas-login.js.map +1 -0
- package/dist/components/nylas-logo.d.ts +11 -0
- package/dist/components/nylas-logo.js +8 -0
- package/dist/components/nylas-logo.js.map +1 -0
- package/dist/components/nylas-logo2.js +37 -0
- package/dist/components/nylas-logo2.js.map +1 -0
- package/dist/components/nylas-mailbox-pagination.d.ts +11 -0
- package/dist/components/nylas-mailbox-pagination.js +175 -0
- package/dist/components/nylas-mailbox-pagination.js.map +1 -0
- package/dist/components/nylas-mailbox-toolbar-button.d.ts +11 -0
- package/dist/components/nylas-mailbox-toolbar-button.js +119 -0
- package/dist/components/nylas-mailbox-toolbar-button.js.map +1 -0
- package/dist/components/nylas-mailbox.d.ts +11 -0
- package/dist/components/nylas-mailbox.js +219 -0
- package/dist/components/nylas-mailbox.js.map +1 -0
- package/dist/components/nylas-notification.d.ts +11 -0
- package/dist/components/nylas-notification.js +8 -0
- package/dist/components/nylas-notification.js.map +1 -0
- package/dist/components/nylas-notification2.js +90 -0
- package/dist/components/nylas-notification2.js.map +1 -0
- package/dist/components/nylas-open-hours-picker.d.ts +11 -0
- package/dist/components/nylas-open-hours-picker.js +365 -0
- package/dist/components/nylas-open-hours-picker.js.map +1 -0
- package/dist/components/nylas-provider.d.ts +11 -0
- package/dist/components/nylas-provider.js +206 -0
- package/dist/components/nylas-provider.js.map +1 -0
- package/dist/components/nylas-scheduler.d.ts +11 -0
- package/dist/components/nylas-scheduler.js +392 -0
- package/dist/components/nylas-scheduler.js.map +1 -0
- package/dist/components/nylas-selected-event-card.d.ts +11 -0
- package/dist/components/nylas-selected-event-card.js +8 -0
- package/dist/components/nylas-selected-event-card.js.map +1 -0
- package/dist/components/nylas-selected-event-card2.js +110 -0
- package/dist/components/nylas-selected-event-card2.js.map +1 -0
- package/dist/components/nylas-summarize-message-button.d.ts +11 -0
- package/dist/components/nylas-summarize-message-button.js +8 -0
- package/dist/components/nylas-summarize-message-button.js.map +1 -0
- package/dist/components/nylas-summarize-message-button2.js +233 -0
- package/dist/components/nylas-summarize-message-button2.js.map +1 -0
- package/dist/components/nylas-threads-refresh.d.ts +11 -0
- package/dist/components/nylas-threads-refresh.js +149 -0
- package/dist/components/nylas-threads-refresh.js.map +1 -0
- package/dist/components/nylas-threads-search.d.ts +11 -0
- package/dist/components/nylas-threads-search.js +103 -0
- package/dist/components/nylas-threads-search.js.map +1 -0
- package/dist/components/nylas-timeslot-picker.d.ts +11 -0
- package/dist/components/nylas-timeslot-picker.js +8 -0
- package/dist/components/nylas-timeslot-picker.js.map +1 -0
- package/dist/components/nylas-timeslot-picker2.js +174 -0
- package/dist/components/nylas-timeslot-picker2.js.map +1 -0
- package/dist/components/nylas-view-email.d.ts +11 -0
- package/dist/components/nylas-view-email.js +8 -0
- package/dist/components/nylas-view-email.js.map +1 -0
- package/dist/components/nylas-view-email2.js +1859 -0
- package/dist/components/nylas-view-email2.js.map +1 -0
- package/dist/components/nylas-view-thread.d.ts +11 -0
- package/dist/components/nylas-view-thread.js +338 -0
- package/dist/components/nylas-view-thread.js.map +1 -0
- package/dist/components/people-icon.d.ts +11 -0
- package/dist/components/people-icon.js +8 -0
- package/dist/components/people-icon.js.map +1 -0
- package/dist/components/people.js +37 -0
- package/dist/components/people.js.map +1 -0
- package/dist/components/play-icon.d.ts +11 -0
- package/dist/components/play-icon.js +8 -0
- package/dist/components/play-icon.js.map +1 -0
- package/dist/components/play.js +37 -0
- package/dist/components/play.js.map +1 -0
- package/dist/components/property.js +36 -0
- package/dist/components/property.js.map +1 -0
- package/dist/components/refresh-icon.d.ts +11 -0
- package/dist/components/refresh-icon.js +8 -0
- package/dist/components/refresh-icon.js.map +1 -0
- package/dist/components/refresh.js +37 -0
- package/dist/components/refresh.js.map +1 -0
- package/dist/components/register-component.js +138 -0
- package/dist/components/register-component.js.map +1 -0
- package/dist/components/reply-all-icon.d.ts +11 -0
- package/dist/components/reply-all-icon.js +8 -0
- package/dist/components/reply-all-icon.js.map +1 -0
- package/dist/components/reply-all.js +37 -0
- package/dist/components/reply-all.js.map +1 -0
- package/dist/components/reply-icon.d.ts +11 -0
- package/dist/components/reply-icon.js +8 -0
- package/dist/components/reply-icon.js.map +1 -0
- package/dist/components/reply.js +37 -0
- package/dist/components/reply.js.map +1 -0
- package/dist/components/scheduler-store.js +251 -0
- package/dist/components/scheduler-store.js.map +1 -0
- package/dist/components/sent-icon.d.ts +11 -0
- package/dist/components/sent-icon.js +8 -0
- package/dist/components/sent-icon.js.map +1 -0
- package/dist/components/sent.js +37 -0
- package/dist/components/sent.js.map +1 -0
- package/dist/components/sp-icon-chevron-left.js +23 -0
- package/dist/components/sp-icon-chevron-left.js.map +1 -0
- package/dist/components/spam-icon.d.ts +11 -0
- package/dist/components/spam-icon.js +8 -0
- package/dist/components/spam-icon.js.map +1 -0
- package/dist/components/spam.js +37 -0
- package/dist/components/spam.js.map +1 -0
- package/dist/components/star-icon.d.ts +11 -0
- package/dist/components/star-icon.js +8 -0
- package/dist/components/star-icon.js.map +1 -0
- package/dist/components/star.js +37 -0
- package/dist/components/star.js.map +1 -0
- package/dist/components/stop-icon.d.ts +11 -0
- package/dist/components/stop-icon.js +8 -0
- package/dist/components/stop-icon.js.map +1 -0
- package/dist/components/stop.js +37 -0
- package/dist/components/stop.js.map +1 -0
- package/dist/components/translate-icon.d.ts +11 -0
- package/dist/components/translate-icon.js +8 -0
- package/dist/components/translate-icon.js.map +1 -0
- package/dist/components/translate.js +37 -0
- package/dist/components/translate.js.map +1 -0
- package/dist/components/trash-icon.d.ts +11 -0
- package/dist/components/trash-icon.js +8 -0
- package/dist/components/trash-icon.js.map +1 -0
- package/dist/components/trash.js +37 -0
- package/dist/components/trash.js.map +1 -0
- package/dist/components/underline-icon.d.ts +11 -0
- package/dist/components/underline-icon.js +8 -0
- package/dist/components/underline-icon.js.map +1 -0
- package/dist/components/underline.js +37 -0
- package/dist/components/underline.js.map +1 -0
- package/dist/components/utils.js +140 -0
- package/dist/components/utils.js.map +1 -0
- package/dist/components/warning-icon.d.ts +11 -0
- package/dist/components/warning-icon.js +8 -0
- package/dist/components/warning-icon.js.map +1 -0
- package/dist/components/warning.js +37 -0
- package/dist/components/warning.js.map +1 -0
- package/dist/esm/_commonjsHelpers-57e89916.js +20 -0
- package/dist/esm/_commonjsHelpers-57e89916.js.map +1 -0
- package/dist/esm/app-globals-47969cee.js +9 -0
- package/dist/esm/app-globals-47969cee.js.map +1 -0
- package/dist/esm/archive-icon_7.entry.js +110 -0
- package/dist/esm/archive-icon_7.entry.js.map +1 -0
- package/dist/esm/arrow-icon.entry.js +20 -0
- package/dist/esm/arrow-icon.entry.js.map +1 -0
- package/dist/esm/bold-icon_3.entry.js +50 -0
- package/dist/esm/bold-icon_3.entry.js.map +1 -0
- package/dist/esm/calendar-cancel-icon.entry.js +20 -0
- package/dist/esm/calendar-cancel-icon.entry.js.map +1 -0
- package/dist/esm/calendar-check-icon_3.entry.js +50 -0
- package/dist/esm/calendar-check-icon_3.entry.js.map +1 -0
- package/dist/esm/calendar-icon.entry.js +20 -0
- package/dist/esm/calendar-icon.entry.js.map +1 -0
- package/dist/esm/chevron-icon.entry.js +20 -0
- package/dist/esm/chevron-icon.entry.js.map +1 -0
- package/dist/esm/close-icon_2.entry.js +35 -0
- package/dist/esm/close-icon_2.entry.js.map +1 -0
- package/dist/esm/document-refresh-icon.entry.js +20 -0
- package/dist/esm/document-refresh-icon.entry.js.map +1 -0
- package/dist/esm/duration-bddc4a13.js +78 -0
- package/dist/esm/duration-bddc4a13.js.map +1 -0
- package/dist/esm/elements-60ebdb01.js +21583 -0
- package/dist/esm/elements-60ebdb01.js.map +1 -0
- package/dist/esm/flow-40ff9cea.js +888 -0
- package/dist/esm/flow-40ff9cea.js.map +1 -0
- package/dist/esm/focus-visible-e8093c16.js +325 -0
- package/dist/esm/focus-visible-e8093c16.js.map +1 -0
- package/dist/esm/forward-icon_6.entry.js +2207 -0
- package/dist/esm/forward-icon_6.entry.js.map +1 -0
- package/dist/esm/globe-icon.entry.js +20 -0
- package/dist/esm/globe-icon.entry.js.map +1 -0
- package/dist/esm/index-2b85580a.js +196 -0
- package/dist/esm/index-2b85580a.js.map +1 -0
- package/dist/esm/index-b2270b4a.js +2141 -0
- package/dist/esm/index-b2270b4a.js.map +1 -0
- package/dist/esm/index.es-6f3582a1.js +3211 -0
- package/dist/esm/index.es-6f3582a1.js.map +1 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/loader.js +13 -0
- package/dist/esm/loader.js.map +1 -0
- package/dist/esm/loading-icon.entry.js +20 -0
- package/dist/esm/loading-icon.entry.js.map +1 -0
- package/dist/esm/mailbox-store-0019772c.js +521 -0
- package/dist/esm/mailbox-store-0019772c.js.map +1 -0
- package/dist/esm/nylas-booked-event-card_9.entry.js +8115 -0
- package/dist/esm/nylas-booked-event-card_9.entry.js.map +1 -0
- package/dist/esm/nylas-if-state_3.entry.js +403 -0
- package/dist/esm/nylas-if-state_3.entry.js.map +1 -0
- package/dist/esm/nylas-list-folders.entry.js +116 -0
- package/dist/esm/nylas-list-folders.entry.js.map +1 -0
- package/dist/esm/nylas-list-threads.entry.js +85 -0
- package/dist/esm/nylas-list-threads.entry.js.map +1 -0
- package/dist/esm/nylas-mailbox-pagination.entry.js +136 -0
- package/dist/esm/nylas-mailbox-pagination.entry.js.map +1 -0
- package/dist/esm/nylas-mailbox-toolbar-button.entry.js +96 -0
- package/dist/esm/nylas-mailbox-toolbar-button.entry.js.map +1 -0
- package/dist/esm/nylas-open-hours-picker.entry.js +329 -0
- package/dist/esm/nylas-open-hours-picker.entry.js.map +1 -0
- package/dist/esm/nylas-provider.entry.js +180 -0
- package/dist/esm/nylas-provider.entry.js.map +1 -0
- package/dist/esm/nylas-scheduler.entry.js +238 -0
- package/dist/esm/nylas-scheduler.entry.js.map +1 -0
- package/dist/esm/nylas-threads-refresh.entry.js +114 -0
- package/dist/esm/nylas-threads-refresh.entry.js.map +1 -0
- package/dist/esm/nylas-threads-search.entry.js +80 -0
- package/dist/esm/nylas-threads-search.entry.js.map +1 -0
- package/dist/esm/nylas-view-thread.entry.js +230 -0
- package/dist/esm/nylas-view-thread.entry.js.map +1 -0
- package/dist/esm/nylas-web-elements.js +22 -0
- package/dist/esm/nylas-web-elements.js.map +1 -0
- package/dist/esm/play-icon_2.entry.js +35 -0
- package/dist/esm/play-icon_2.entry.js.map +1 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/esm/property-0065dde7.js +36 -0
- package/dist/esm/property-0065dde7.js.map +1 -0
- package/dist/esm/refresh-icon.entry.js +20 -0
- package/dist/esm/refresh-icon.entry.js.map +1 -0
- package/dist/esm/register-component-55376f31.js +138 -0
- package/dist/esm/register-component-55376f31.js.map +1 -0
- package/dist/esm/scheduler-store-5a39585a.js +251 -0
- package/dist/esm/scheduler-store-5a39585a.js.map +1 -0
- package/dist/esm/translate-icon.entry.js +20 -0
- package/dist/esm/translate-icon.entry.js.map +1 -0
- package/dist/esm/utils-5074a070.js +140 -0
- package/dist/esm/utils-5074a070.js.map +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/nylas-web-elements/index.esm.js +2 -0
- package/dist/nylas-web-elements/index.esm.js.map +1 -0
- package/dist/nylas-web-elements/nylas-web-elements.css +239 -0
- package/dist/nylas-web-elements/nylas-web-elements.esm.js +2 -0
- package/dist/nylas-web-elements/nylas-web-elements.esm.js.map +1 -0
- package/dist/nylas-web-elements/p-06974d68.js +2 -0
- package/dist/nylas-web-elements/p-06974d68.js.map +1 -0
- package/dist/nylas-web-elements/p-113fe52e.entry.js +2 -0
- package/dist/nylas-web-elements/p-113fe52e.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-16fb3c85.entry.js +2 -0
- package/dist/nylas-web-elements/p-16fb3c85.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-24c42c37.entry.js +2 -0
- package/dist/nylas-web-elements/p-24c42c37.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-2881b62f.js +16519 -0
- package/dist/nylas-web-elements/p-2881b62f.js.map +1 -0
- package/dist/nylas-web-elements/p-33da6cf1.entry.js +2 -0
- package/dist/nylas-web-elements/p-33da6cf1.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-37f99b96.entry.js +2 -0
- package/dist/nylas-web-elements/p-37f99b96.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-3bc3426e.entry.js +2 -0
- package/dist/nylas-web-elements/p-3bc3426e.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-3c8822f1.entry.js +2 -0
- package/dist/nylas-web-elements/p-3c8822f1.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-5770704d.js +2 -0
- package/dist/nylas-web-elements/p-5770704d.js.map +1 -0
- package/dist/nylas-web-elements/p-5862975b.js +2 -0
- package/dist/nylas-web-elements/p-5862975b.js.map +1 -0
- package/dist/nylas-web-elements/p-647cf7be.entry.js +2 -0
- package/dist/nylas-web-elements/p-647cf7be.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-663edeb8.entry.js +2 -0
- package/dist/nylas-web-elements/p-663edeb8.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-67c9158e.entry.js +2 -0
- package/dist/nylas-web-elements/p-67c9158e.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-6ba7a037.js +2 -0
- package/dist/nylas-web-elements/p-6ba7a037.js.map +1 -0
- package/dist/nylas-web-elements/p-6da0b8f0.entry.js +2 -0
- package/dist/nylas-web-elements/p-6da0b8f0.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-6df00ba0.js +27 -0
- package/dist/nylas-web-elements/p-6df00ba0.js.map +1 -0
- package/dist/nylas-web-elements/p-74141ef6.entry.js +2 -0
- package/dist/nylas-web-elements/p-74141ef6.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-85d41197.entry.js +2 -0
- package/dist/nylas-web-elements/p-85d41197.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-97518578.entry.js +2 -0
- package/dist/nylas-web-elements/p-97518578.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-98ec4a7a.js +2 -0
- package/dist/nylas-web-elements/p-98ec4a7a.js.map +1 -0
- package/dist/nylas-web-elements/p-998d25d5.entry.js +2 -0
- package/dist/nylas-web-elements/p-998d25d5.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-a7bfd3af.entry.js +77 -0
- package/dist/nylas-web-elements/p-a7bfd3af.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-a95208c7.js +2 -0
- package/dist/nylas-web-elements/p-a95208c7.js.map +1 -0
- package/dist/nylas-web-elements/p-adacdaeb.entry.js +2 -0
- package/dist/nylas-web-elements/p-adacdaeb.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-b7d4b7b5.entry.js +2 -0
- package/dist/nylas-web-elements/p-b7d4b7b5.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-b85dfeac.entry.js +2 -0
- package/dist/nylas-web-elements/p-b85dfeac.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-b96b37f1.entry.js +2 -0
- package/dist/nylas-web-elements/p-b96b37f1.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-c2e69618.entry.js +2 -0
- package/dist/nylas-web-elements/p-c2e69618.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-c440f148.entry.js +2 -0
- package/dist/nylas-web-elements/p-c440f148.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-c66e27d0.js +3 -0
- package/dist/nylas-web-elements/p-c66e27d0.js.map +1 -0
- package/dist/nylas-web-elements/p-c685e944.entry.js +3 -0
- package/dist/nylas-web-elements/p-c685e944.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-cb65c223.js +2 -0
- package/dist/nylas-web-elements/p-cb65c223.js.map +1 -0
- package/dist/nylas-web-elements/p-cc21d351.js +17 -0
- package/dist/nylas-web-elements/p-cc21d351.js.map +1 -0
- package/dist/nylas-web-elements/p-d4b1e3e4.entry.js +2 -0
- package/dist/nylas-web-elements/p-d4b1e3e4.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-db24cc70.entry.js +2 -0
- package/dist/nylas-web-elements/p-db24cc70.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-de1bcc4a.js +2 -0
- package/dist/nylas-web-elements/p-de1bcc4a.js.map +1 -0
- package/dist/nylas-web-elements/p-df9f71ea.js +2 -0
- package/dist/nylas-web-elements/p-df9f71ea.js.map +1 -0
- package/dist/nylas-web-elements/p-eeb0a591.js +2 -0
- package/dist/nylas-web-elements/p-eeb0a591.js.map +1 -0
- package/dist/nylas-web-elements/p-f029c1b7.entry.js +2 -0
- package/dist/nylas-web-elements/p-f029c1b7.entry.js.map +1 -0
- package/dist/nylas-web-elements/p-f9a4758a.entry.js +2 -0
- package/dist/nylas-web-elements/p-f9a4758a.entry.js.map +1 -0
- package/dist/types/common/abstract-provider.d.ts +52 -0
- package/dist/types/common/component-types.d.ts +22 -0
- package/dist/types/common/constants.d.ts +6 -0
- package/dist/types/common/global.d.ts +1 -0
- package/dist/types/common/icons/archive.d.ts +5 -0
- package/dist/types/common/icons/arrow.d.ts +5 -0
- package/dist/types/common/icons/bold.d.ts +5 -0
- package/dist/types/common/icons/calendar-cancel.d.ts +5 -0
- package/dist/types/common/icons/calendar-check.d.ts +5 -0
- package/dist/types/common/icons/calendar.d.ts +5 -0
- package/dist/types/common/icons/checkmark-circle.d.ts +5 -0
- package/dist/types/common/icons/chevron.d.ts +5 -0
- package/dist/types/common/icons/close.d.ts +5 -0
- package/dist/types/common/icons/document-refresh.d.ts +5 -0
- package/dist/types/common/icons/folder.d.ts +5 -0
- package/dist/types/common/icons/forward.d.ts +5 -0
- package/dist/types/common/icons/globe.d.ts +5 -0
- package/dist/types/common/icons/inbox.d.ts +5 -0
- package/dist/types/common/icons/italic.d.ts +5 -0
- package/dist/types/common/icons/loading.d.ts +5 -0
- package/dist/types/common/icons/nylas-logo.d.ts +5 -0
- package/dist/types/common/icons/people.d.ts +5 -0
- package/dist/types/common/icons/play.d.ts +5 -0
- package/dist/types/common/icons/refresh.d.ts +5 -0
- package/dist/types/common/icons/reply-all.d.ts +5 -0
- package/dist/types/common/icons/reply.d.ts +5 -0
- package/dist/types/common/icons/sent.d.ts +5 -0
- package/dist/types/common/icons/spam.d.ts +5 -0
- package/dist/types/common/icons/star.d.ts +5 -0
- package/dist/types/common/icons/stop.d.ts +5 -0
- package/dist/types/common/icons/translate.d.ts +5 -0
- package/dist/types/common/icons/trash.d.ts +5 -0
- package/dist/types/common/icons/underline.d.ts +5 -0
- package/dist/types/common/icons/warning.d.ts +5 -0
- package/dist/types/common/mocks/threads.d.ts +3 -0
- package/dist/types/common/nylas-theme/index.d.ts +27 -0
- package/dist/types/common/register-component.d.ts +29 -0
- package/dist/types/common/types.d.ts +108 -0
- package/dist/types/components/mailbox/nylas-composer/nylas-composer.d.ts +22 -0
- package/dist/types/components/mailbox/nylas-composer/test/nylas-composer.spec-disabled.d.ts +1 -0
- package/dist/types/components/mailbox/nylas-list-folders/nylas-list-folders.d.ts +19 -0
- package/dist/types/components/mailbox/nylas-list-threads/nylas-list-threads.d.ts +19 -0
- package/dist/types/components/mailbox/nylas-mailbox/nylas-mailbox.d.ts +35 -0
- package/dist/types/components/mailbox/nylas-mailbox-pagination/nylas-mailbox-pagination.d.ts +30 -0
- package/dist/types/components/mailbox/nylas-mailbox-toolbar-button/nylas-mailbox-toolbar-button.d.ts +26 -0
- package/dist/types/components/mailbox/nylas-summarize-message-button/nylas-summarize-message-button.d.ts +25 -0
- package/dist/types/components/mailbox/nylas-threads-refresh/nylas-threads-refresh.d.ts +23 -0
- package/dist/types/components/mailbox/nylas-threads-search/nylas-threads-search.d.ts +13 -0
- package/dist/types/components/mailbox/nylas-view-email/nylas-view-email.d.ts +25 -0
- package/dist/types/components/mailbox/nylas-view-thread/nylas-view-thread.d.ts +30 -0
- package/dist/types/components/mailbox/nylas-view-thread/view-thread-message.d.ts +12 -0
- package/dist/types/components/nylas-if-state/nylas-if-state.d.ts +22 -0
- package/dist/types/components/nylas-login/nylas-login.d.ts +26 -0
- package/dist/types/components/nylas-provider/nylas-provider.d.ts +35 -0
- package/dist/types/components/scheduler/nylas-booked-event-card/nylas-booked-event-card.d.ts +22 -0
- package/dist/types/components/scheduler/nylas-booking-form/nylas-booking-form.d.ts +33 -0
- package/dist/types/components/scheduler/nylas-cancelled-event-card/nylas-cancelled-event-card.d.ts +13 -0
- package/dist/types/components/scheduler/nylas-date-picker/nylas-date-picker.d.ts +19 -0
- package/dist/types/components/scheduler/nylas-locale-switch/nylas-locale-switch.d.ts +13 -0
- package/dist/types/components/scheduler/nylas-notification/nylas-notification.d.ts +13 -0
- package/dist/types/components/scheduler/nylas-open-hours-picker/nylas-open-hours-picker.d.ts +40 -0
- package/dist/types/components/scheduler/nylas-scheduler/nylas-scheduler.d.ts +41 -0
- package/dist/types/components/scheduler/nylas-scheduler/scheduler-view.d.ts +6 -0
- package/dist/types/components/scheduler/nylas-selected-event-card/nylas-selected-event-card.d.ts +15 -0
- package/dist/types/components/scheduler/nylas-timeslot-picker/nylas-timeslot-picker.d.ts +28 -0
- package/dist/types/components.d.ts +2123 -0
- package/dist/types/connector/connector-interface.d.ts +35 -0
- package/dist/types/connector/nylas-connector/index.d.ts +59 -0
- package/dist/types/connector/nylas-mailbox-connector/index.d.ts +52 -0
- package/dist/types/connector/nylas-scheduler-connector/index.d.ts +24 -0
- package/dist/types/connector/shared/api/auth.d.ts +13 -0
- package/dist/types/connector/shared/api/folders.d.ts +10 -0
- package/dist/types/connector/shared/api/messages.d.ts +13 -0
- package/dist/types/connector/shared/api/scheduler.d.ts +29 -0
- package/dist/types/connector/shared/api/threads.d.ts +20 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/routers/hash-router.d.ts +21 -0
- package/dist/types/routers/router-interface.d.ts +16 -0
- package/dist/types/stencil-public-runtime.d.ts +1681 -0
- package/dist/types/stores/auth-store.d.ts +9 -0
- package/dist/types/stores/mailbox-store.d.ts +19 -0
- package/dist/types/stores/scheduler-store.d.ts +32 -0
- package/dist/types/utils/color-utils.d.ts +9 -0
- package/dist/types/utils/utils.d.ts +28 -0
- package/loader/cdn.js +3 -0
- package/loader/index.cjs.js +3 -0
- package/loader/index.d.ts +21 -0
- package/loader/index.es2017.js +3 -0
- package/loader/index.js +4 -0
- package/loader/package.json +11 -0
- package/package.json +69 -0
- package/readme.md +42 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
export class NylaSchedulerAPIConnector {
|
|
2
|
+
constructor({ schedulerAPIURL, schedulerStore, sessionId }) {
|
|
3
|
+
this.schedulerStore = schedulerStore;
|
|
4
|
+
this.schedulerAPIURL = schedulerAPIURL;
|
|
5
|
+
this.sessionId = sessionId;
|
|
6
|
+
}
|
|
7
|
+
async makeAPIRequest(path, method, body, headers = {}) {
|
|
8
|
+
try {
|
|
9
|
+
const schedulerURL = new URL(this.schedulerAPIURL);
|
|
10
|
+
schedulerURL.pathname = path;
|
|
11
|
+
const response = await fetch(decodeURIComponent(schedulerURL.toString()), {
|
|
12
|
+
method,
|
|
13
|
+
headers: {
|
|
14
|
+
'Content-Type': 'application/json',
|
|
15
|
+
...headers,
|
|
16
|
+
},
|
|
17
|
+
body,
|
|
18
|
+
});
|
|
19
|
+
if (response.status === 204) {
|
|
20
|
+
return { data: null };
|
|
21
|
+
}
|
|
22
|
+
const data = await response.json();
|
|
23
|
+
return data;
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
return { error };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
selectDate(date) {
|
|
30
|
+
this.schedulerStore.set('selectedDate', date);
|
|
31
|
+
this.schedulerStore.set('selectedTimeslot', null);
|
|
32
|
+
}
|
|
33
|
+
selectTime(time) {
|
|
34
|
+
this.schedulerStore.set('selectedTimeslot', time);
|
|
35
|
+
}
|
|
36
|
+
selectTimezone(timezone) {
|
|
37
|
+
this.schedulerStore.set('selectedTimezone', timezone);
|
|
38
|
+
}
|
|
39
|
+
toggleAdditionalData(value) {
|
|
40
|
+
this.schedulerStore.set('showBookingForm', value);
|
|
41
|
+
}
|
|
42
|
+
setParticipantName(name) {
|
|
43
|
+
const { bookingInfo } = this.schedulerStore.state;
|
|
44
|
+
this.schedulerStore.set('bookingInfo', {
|
|
45
|
+
...bookingInfo,
|
|
46
|
+
primaryParticipant: {
|
|
47
|
+
...bookingInfo?.primaryParticipant,
|
|
48
|
+
name,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
setParticipantEmail(email) {
|
|
53
|
+
const { bookingInfo } = this.schedulerStore.state;
|
|
54
|
+
this.schedulerStore.set('bookingInfo', {
|
|
55
|
+
...bookingInfo,
|
|
56
|
+
primaryParticipant: {
|
|
57
|
+
...bookingInfo?.primaryParticipant,
|
|
58
|
+
email,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async setReschedule(bookingID) {
|
|
63
|
+
const today = new Date();
|
|
64
|
+
this.schedulerStore.set('rescheduleId', bookingID);
|
|
65
|
+
this.schedulerStore.set('selectedTimeslot', null);
|
|
66
|
+
this.schedulerStore.set('showThankYouMessage', false);
|
|
67
|
+
this.schedulerStore.set('showBookingForm', false);
|
|
68
|
+
const startTime = new Date(today.getFullYear(), today.getMonth(), 1).getTime() / 1000;
|
|
69
|
+
const endTime = new Date(today.getFullYear(), today.getMonth() + 1, 1).getTime() / 1000;
|
|
70
|
+
await this.getAvailability(startTime, endTime);
|
|
71
|
+
const firstAvailableDate = this.schedulerStore.get('availability').find((timeslot) => new Date(timeslot.start_time) > new Date());
|
|
72
|
+
let _selectedDate = today;
|
|
73
|
+
if (firstAvailableDate) {
|
|
74
|
+
_selectedDate = firstAvailableDate.start_time;
|
|
75
|
+
}
|
|
76
|
+
this.schedulerStore.set('selectedDate', _selectedDate);
|
|
77
|
+
}
|
|
78
|
+
async bookTimeslot(data) {
|
|
79
|
+
this.schedulerStore.set('bookedEventLoading', true);
|
|
80
|
+
this.schedulerStore.set('bookedEventError', null);
|
|
81
|
+
const { selectedTimeslot, bookingInfo } = this.schedulerStore.state;
|
|
82
|
+
if (!data && !bookingInfo) {
|
|
83
|
+
return { error: { message: 'No booking info provided' } };
|
|
84
|
+
}
|
|
85
|
+
const timeslot = data?.timeslot || selectedTimeslot;
|
|
86
|
+
if (!timeslot) {
|
|
87
|
+
return { error: { message: 'No time slot selected' } };
|
|
88
|
+
}
|
|
89
|
+
const primaryParticipant = data ? data?.primaryParticipant : bookingInfo?.primaryParticipant;
|
|
90
|
+
const guests = data ? data?.guests || [] : bookingInfo?.guests || [];
|
|
91
|
+
const additional_fields = data ? { ...data?.additionalFields } : { ...bookingInfo?.additionalFields };
|
|
92
|
+
const headers = {
|
|
93
|
+
Authorization: `Bearer ${this.sessionId}`,
|
|
94
|
+
};
|
|
95
|
+
const url = `/schedule/bookings`;
|
|
96
|
+
const response = await this.makeAPIRequest(decodeURIComponent(url), 'POST', JSON.stringify({
|
|
97
|
+
participants: [primaryParticipant, ...guests],
|
|
98
|
+
additional_fields,
|
|
99
|
+
start_time: timeslot.start_time.getTime() / 1000,
|
|
100
|
+
end_time: timeslot.end_time.getTime() / 1000,
|
|
101
|
+
}), headers);
|
|
102
|
+
if ('error' in response)
|
|
103
|
+
this.schedulerStore.set('bookedEventError', response?.error);
|
|
104
|
+
if ('data' in response)
|
|
105
|
+
this.schedulerStore.set('eventInfo', response?.data);
|
|
106
|
+
this.schedulerStore.set('bookedEventLoading', false);
|
|
107
|
+
return response;
|
|
108
|
+
}
|
|
109
|
+
async getAvailability(startTime = 0, endTime = 0) {
|
|
110
|
+
this.schedulerStore.set('loadingState', { api: 'availability' });
|
|
111
|
+
const params = new URLSearchParams();
|
|
112
|
+
const now = new Date();
|
|
113
|
+
const nowTime = now.getTime();
|
|
114
|
+
if (endTime && endTime < nowTime / 1000) {
|
|
115
|
+
const error = { title: 'Availability error', message: 'endTime should be in the future', category: 'vaidation' };
|
|
116
|
+
this.schedulerStore.set('availabilityTimeslotsError', error);
|
|
117
|
+
return { error };
|
|
118
|
+
}
|
|
119
|
+
if (startTime)
|
|
120
|
+
params.append('start_time', encodeURIComponent(startTime));
|
|
121
|
+
if (endTime)
|
|
122
|
+
params.append('end_time', encodeURIComponent(endTime));
|
|
123
|
+
const queryString = params.toString();
|
|
124
|
+
const url = `/schedule/availability${queryString ? `?${queryString}` : ''}`;
|
|
125
|
+
const headers = {
|
|
126
|
+
Authorization: `Bearer ${this.sessionId}`,
|
|
127
|
+
};
|
|
128
|
+
const response = await this.makeAPIRequest(decodeURIComponent(url), 'GET', undefined, headers);
|
|
129
|
+
if ('error' in response) {
|
|
130
|
+
this.schedulerStore.set('availability', []);
|
|
131
|
+
}
|
|
132
|
+
if ('data' in response) {
|
|
133
|
+
const availability = response.data?.time_slots?.map(timeslot => {
|
|
134
|
+
return {
|
|
135
|
+
...timeslot,
|
|
136
|
+
start_time: new Date(timeslot.start_time * 1000),
|
|
137
|
+
end_time: new Date(timeslot.end_time * 1000),
|
|
138
|
+
};
|
|
139
|
+
}) || [];
|
|
140
|
+
const availabilityTimeslotsFiltered = availability.filter(timeslot => timeslot.start_time.getTime() > nowTime);
|
|
141
|
+
this.schedulerStore.set('availability', availabilityTimeslotsFiltered);
|
|
142
|
+
}
|
|
143
|
+
this.schedulerStore.set('loadingState', null);
|
|
144
|
+
return response;
|
|
145
|
+
}
|
|
146
|
+
async cancelBooking(bookingId) {
|
|
147
|
+
this.schedulerStore.set('bookedEventLoading', true);
|
|
148
|
+
this.schedulerStore.set('bookedEventError', null);
|
|
149
|
+
const url = `/schedule/bookings/${bookingId}`;
|
|
150
|
+
const headers = {
|
|
151
|
+
Authorization: `Bearer ${this.sessionId}`,
|
|
152
|
+
};
|
|
153
|
+
const response = await this.makeAPIRequest(decodeURIComponent(url), 'PUT', JSON.stringify({
|
|
154
|
+
action: 'cancel',
|
|
155
|
+
}), headers);
|
|
156
|
+
if ('error' in response)
|
|
157
|
+
this.schedulerStore.set('bookedEventError', response?.error);
|
|
158
|
+
if ('data' in response)
|
|
159
|
+
this.schedulerStore.set('cancelledEvent', response?.data);
|
|
160
|
+
this.schedulerStore.set('bookedEventLoading', false);
|
|
161
|
+
return response;
|
|
162
|
+
}
|
|
163
|
+
async rescheduleBooking(bookingId, data) {
|
|
164
|
+
this.schedulerStore.set('bookedEventLoading', true);
|
|
165
|
+
this.schedulerStore.set('bookedEventError', null);
|
|
166
|
+
const { bookingInfo, selectedTimeslot, selectedTimezone } = this.schedulerStore.state;
|
|
167
|
+
const { startTime, endTime, timezone } = data;
|
|
168
|
+
const start_time = startTime || selectedTimeslot?.start_time;
|
|
169
|
+
const generalError = { error: { title: 'Reschedule error', message: '', type: 'validation' } };
|
|
170
|
+
if (!start_time) {
|
|
171
|
+
return { error: { ...generalError, message: `Please pass 'startTime' in data or set 'selectedTimeslot in the defaultSchedulerStoreState.` } };
|
|
172
|
+
}
|
|
173
|
+
const end_time = endTime || selectedTimeslot?.end_time;
|
|
174
|
+
if (!end_time) {
|
|
175
|
+
return { error: { ...generalError, message: `Please pass 'endTime' in data or set 'selectedTimeslot' in the defaultSchedulerStoreState.` } };
|
|
176
|
+
}
|
|
177
|
+
const time_zone = timezone || selectedTimezone;
|
|
178
|
+
if (!time_zone) {
|
|
179
|
+
return { error: { ...generalError, message: `Please pass 'timezone' in data or set 'selectedTimezone' in the defaultSchedulerStoreState.` } };
|
|
180
|
+
}
|
|
181
|
+
const primaryParticipant = data ? data?.primaryParticipant : bookingInfo?.primaryParticipant;
|
|
182
|
+
const guests = data ? data?.guests || [] : bookingInfo?.guests || [];
|
|
183
|
+
const additional_fields = data ? { ...data?.additionalFields } : { ...bookingInfo?.additionalFields };
|
|
184
|
+
const url = `/schedule/bookings/${bookingId}`;
|
|
185
|
+
const headers = {
|
|
186
|
+
Authorization: `Bearer ${this.sessionId}`,
|
|
187
|
+
};
|
|
188
|
+
const response = await this.makeAPIRequest(decodeURIComponent(url), 'PATCH', JSON.stringify({
|
|
189
|
+
start_time: start_time.getTime() / 1000,
|
|
190
|
+
end_time: end_time.getTime() / 1000,
|
|
191
|
+
time_zone,
|
|
192
|
+
participants: [primaryParticipant, ...guests],
|
|
193
|
+
additional_fields,
|
|
194
|
+
}), headers);
|
|
195
|
+
if ('error' in response)
|
|
196
|
+
this.schedulerStore.set('bookedEventError', { error: { ...response?.error, category: 'api' } });
|
|
197
|
+
if ('data' in response)
|
|
198
|
+
this.schedulerStore.set('eventInfo', response?.data);
|
|
199
|
+
this.schedulerStore.set('bookedEventLoading', false);
|
|
200
|
+
return response;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=scheduler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../../../../src/connector/shared/api/scheduler.ts"],"names":[],"mappings":"AAcA,MAAM,OAAO,yBAAyB;IAKpC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,SAAS,EAAqC;QAC3F,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,SAAS,CA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AAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAwB,CAAC,CAAC;QAE/I,IAAI,MAAM,IAAI,QAAQ;YAAE,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;QAE7E,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;QACrD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF","sourcesContent":["import { AvailabilityResponse, NylasEvent } from '@/common/types';\nimport { NylasSchedulerStoreType } from '../../../components';\nimport type { NylasErrorResponse, NylasResponse, NylasSchedulerBookingData, Timeslot } from '@nylas/core';\n\ntype NylasSchedulerAPIConnectorOptions = {\n schedulerAPIURL: string;\n schedulerStore: NylasSchedulerStoreType;\n sessionId?: string;\n};\n\n/**\n * NylaSchedulerConnector\n * This class is used to make API requests to the scheduler.\n */\nexport class NylaSchedulerAPIConnector {\n private schedulerStore: NylasSchedulerStoreType;\n private schedulerAPIURL: string;\n private sessionId: string | undefined;\n\n constructor({ schedulerAPIURL, schedulerStore, sessionId }: NylasSchedulerAPIConnectorOptions) {\n this.schedulerStore = schedulerStore;\n this.schedulerAPIURL = schedulerAPIURL;\n this.sessionId = sessionId;\n }\n\n /**\n * Makes an API request to the scheduler.\n * @param path The path to the API endpoint.\n * @param method The HTTP method.\n * @param body The request body (if any).\n * @returns {Promise<T>}\n */\n public async makeAPIRequest<T>(path: string, method: string, body: string | undefined, headers = {}): Promise<NylasResponse<T>> {\n try {\n const schedulerURL = new URL(this.schedulerAPIURL);\n schedulerURL.pathname = path;\n const response = await fetch(decodeURIComponent(schedulerURL.toString()), {\n method,\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n body,\n });\n\n if (response.status === 204) {\n return { data: null } as NylasResponse<T>;\n }\n\n const data = await response.json();\n return data as NylasResponse<T>;\n } catch (error) {\n // NOTE: current server implementation doesn't return a JSON object for errors on some endpoints\n // handle this case by returning the error response as a string to be handled downstream\n return { error } as NylasErrorResponse;\n }\n }\n\n /**\n * Selects a date in the scheduler.\n */\n public selectDate(date: Date) {\n this.schedulerStore.set('selectedDate', date);\n this.schedulerStore.set('selectedTimeslot', null);\n }\n\n /**\n * Selects a time in the scheduler.\n */\n public selectTime(time: Timeslot) {\n this.schedulerStore.set('selectedTimeslot', time);\n }\n\n /**\n * Sets the timezone in the scheduler.\n */\n public selectTimezone(timezone: string) {\n this.schedulerStore.set('selectedTimezone', timezone);\n }\n\n /**\n * Toggles showBookingForm\n * @param value boolean\n */\n public toggleAdditionalData(value: boolean) {\n this.schedulerStore.set('showBookingForm', value);\n }\n\n /**\n * Set/update the name of the participant booking the event.\n */\n public setParticipantName(name: string) {\n const { bookingInfo } = this.schedulerStore.state;\n this.schedulerStore.set('bookingInfo', {\n ...bookingInfo,\n primaryParticipant: {\n ...(bookingInfo?.primaryParticipant as NylasSchedulerBookingData['primaryParticipant']),\n name,\n },\n });\n }\n\n /**\n * Set/update the email of the participant booking the event.\n */\n public setParticipantEmail(email: string) {\n const { bookingInfo } = this.schedulerStore.state;\n this.schedulerStore.set('bookingInfo', {\n ...bookingInfo,\n primaryParticipant: {\n ...(bookingInfo?.primaryParticipant as NylasSchedulerBookingData['primaryParticipant']),\n email,\n },\n });\n }\n\n /**\n * Set reschedule booking id\n */\n public async setReschedule(bookingID: string) {\n const today = new Date();\n // Set reschedule booking id\n this.schedulerStore.set('rescheduleId', bookingID);\n // Reset store state\n this.schedulerStore.set('selectedTimeslot', null);\n this.schedulerStore.set('showThankYouMessage', false);\n this.schedulerStore.set('showBookingForm', false);\n // Refetch availability\n const startTime = new Date(today.getFullYear(), today.getMonth(), 1).getTime() / 1000;\n const endTime = new Date(today.getFullYear(), today.getMonth() + 1, 1).getTime() / 1000;\n await this.getAvailability(startTime, endTime);\n // Set selected date to first available date\n const firstAvailableDate = this.schedulerStore.get('availability').find((timeslot: any) => new Date(timeslot.start_time) > new Date());\n let _selectedDate = today;\n if (firstAvailableDate) {\n _selectedDate = firstAvailableDate.start_time;\n }\n this.schedulerStore.set('selectedDate', _selectedDate);\n }\n\n /**\n * Book the selected timeslot.\n * @param data The booking info.\n * @returns {Promise<NylasResponse<NylasEvent>>}\n */\n public async bookTimeslot(data?: NylasSchedulerBookingData & { timeslot?: Timeslot }): Promise<NylasResponse<NylasEvent>> {\n this.schedulerStore.set('bookedEventLoading', true);\n this.schedulerStore.set('bookedEventError', null);\n const { selectedTimeslot, bookingInfo } = this.schedulerStore.state;\n if (!data && !bookingInfo) {\n return { error: { message: 'No booking info provided' } } as NylasErrorResponse;\n }\n\n const timeslot = data?.timeslot || selectedTimeslot;\n if (!timeslot) {\n return { error: { message: 'No time slot selected' } } as NylasErrorResponse;\n }\n\n const primaryParticipant = data ? data?.primaryParticipant : bookingInfo?.primaryParticipant;\n const guests = data ? data?.guests || [] : bookingInfo?.guests || [];\n const additional_fields = data ? { ...data?.additionalFields } : { ...bookingInfo?.additionalFields };\n\n const headers = {\n Authorization: `Bearer ${this.sessionId}`,\n };\n const url = `/schedule/bookings`;\n\n const response = await this.makeAPIRequest<NylasEvent>(\n decodeURIComponent(url),\n 'POST',\n JSON.stringify({\n participants: [primaryParticipant, ...guests],\n additional_fields,\n start_time: timeslot.start_time.getTime() / 1000,\n end_time: timeslot.end_time.getTime() / 1000,\n }),\n headers,\n );\n\n if ('error' in response) this.schedulerStore.set('bookedEventError', response?.error as NylasErrorResponse);\n\n if ('data' in response) this.schedulerStore.set('eventInfo', response?.data);\n\n this.schedulerStore.set('bookedEventLoading', false);\n return response;\n }\n\n /**\n * Gets the availability for a page.\n * @param startTime The start time.\n * @param endTime The end time.\n * @returns {Promise<AvailabilityResponse>}\n */\n public async getAvailability(startTime: number = 0, endTime: number = 0): Promise<NylasResponse<AvailabilityResponse>> {\n this.schedulerStore.set('loadingState', { api: 'availability' });\n const params = new URLSearchParams();\n const now = new Date();\n const nowTime = now.getTime();\n\n if (endTime && endTime < nowTime / 1000) {\n const error = { title: 'Availability error', message: 'endTime should be in the future', category: 'vaidation' };\n this.schedulerStore.set('availabilityTimeslotsError', error as NylasErrorResponse);\n return { error } as NylasErrorResponse;\n }\n\n if (startTime) params.append('start_time', encodeURIComponent(startTime));\n if (endTime) params.append('end_time', encodeURIComponent(endTime));\n\n const queryString = params.toString();\n const url = `/schedule/availability${queryString ? `?${queryString}` : ''}`;\n const headers = {\n Authorization: `Bearer ${this.sessionId}`,\n };\n const response = await this.makeAPIRequest<AvailabilityResponse>(decodeURIComponent(url), 'GET', undefined, headers);\n\n if ('error' in response) {\n this.schedulerStore.set('availability', []);\n }\n\n if ('data' in response) {\n const availability =\n response.data?.time_slots?.map(timeslot => {\n return {\n ...timeslot,\n start_time: new Date(timeslot.start_time * 1000),\n end_time: new Date(timeslot.end_time * 1000),\n };\n }) || [];\n\n // Filter out timeslots that are in the past\n const availabilityTimeslotsFiltered = availability.filter(timeslot => timeslot.start_time.getTime() > nowTime);\n this.schedulerStore.set('availability', availabilityTimeslotsFiltered);\n }\n\n this.schedulerStore.set('loadingState', null);\n return response;\n }\n\n /**\n * Cancels a booking.\n * @param bookingId The booking ID.\n */\n public async cancelBooking(bookingId: string): Promise<NylasResponse<null>> {\n this.schedulerStore.set('bookedEventLoading', true);\n this.schedulerStore.set('bookedEventError', null);\n const url = `/schedule/bookings/${bookingId}`;\n const headers = {\n Authorization: `Bearer ${this.sessionId}`,\n };\n const response = await this.makeAPIRequest<NylasEvent>(\n decodeURIComponent(url),\n 'PUT',\n JSON.stringify({\n action: 'cancel',\n }),\n headers,\n );\n\n if ('error' in response) this.schedulerStore.set('bookedEventError', response?.error as NylasErrorResponse);\n\n if ('data' in response) this.schedulerStore.set('cancelledEvent', response?.data);\n\n this.schedulerStore.set('bookedEventLoading', false);\n return response;\n }\n\n /**\n * Reschedules a booking.\n * @param bookingId The booking ID.\n * @param data The booking info.\n * @returns {Promise<NylasResponse<NylasEvent>>}\n */\n public async rescheduleBooking(bookingId: string, data: NylasSchedulerBookingData): Promise<NylasResponse<NylasEvent>> {\n this.schedulerStore.set('bookedEventLoading', true);\n this.schedulerStore.set('bookedEventError', null);\n const { bookingInfo, selectedTimeslot, selectedTimezone } = this.schedulerStore.state;\n // Validate data\n const { startTime, endTime, timezone } = data;\n const start_time = startTime || selectedTimeslot?.start_time;\n const generalError = { error: { title: 'Reschedule error', message: '', type: 'validation' } } as NylasErrorResponse;\n if (!start_time) {\n return { error: { ...generalError, message: `Please pass 'startTime' in data or set 'selectedTimeslot in the defaultSchedulerStoreState.` } } as NylasErrorResponse;\n }\n const end_time = endTime || selectedTimeslot?.end_time;\n if (!end_time) {\n return { error: { ...generalError, message: `Please pass 'endTime' in data or set 'selectedTimeslot' in the defaultSchedulerStoreState.` } } as NylasErrorResponse;\n }\n const time_zone = timezone || selectedTimezone;\n if (!time_zone) {\n return { error: { ...generalError, message: `Please pass 'timezone' in data or set 'selectedTimezone' in the defaultSchedulerStoreState.` } } as NylasErrorResponse;\n }\n\n const primaryParticipant = data ? data?.primaryParticipant : bookingInfo?.primaryParticipant;\n const guests = data ? data?.guests || [] : bookingInfo?.guests || [];\n const additional_fields = data ? { ...data?.additionalFields } : { ...bookingInfo?.additionalFields };\n\n const url = `/schedule/bookings/${bookingId}`;\n const headers = {\n Authorization: `Bearer ${this.sessionId}`,\n };\n const response = await this.makeAPIRequest<NylasEvent>(\n decodeURIComponent(url),\n 'PATCH',\n JSON.stringify({\n start_time: start_time.getTime() / 1000,\n end_time: end_time.getTime() / 1000,\n time_zone,\n participants: [primaryParticipant, ...guests],\n additional_fields,\n }),\n headers,\n );\n\n if ('error' in response) this.schedulerStore.set('bookedEventError', { error: { ...response?.error, category: 'api' } } as NylasErrorResponse);\n\n if ('data' in response) this.schedulerStore.set('eventInfo', response?.data);\n\n this.schedulerStore.set('bookedEventLoading', false);\n return response;\n }\n}\n"]}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { debug } from "../../../utils/utils";
|
|
2
|
+
import { NylasAPIError, isNylasErrorResponse } from "@nylas/core";
|
|
3
|
+
export class NylasThreadsConnector {
|
|
4
|
+
constructor(nylasAuth, nylasAuthStore, nylasMailboxStore, router) {
|
|
5
|
+
this.nylasAuth = nylasAuth;
|
|
6
|
+
this.nylasAuthStore = nylasAuthStore;
|
|
7
|
+
this.nylasMailboxStore = nylasMailboxStore;
|
|
8
|
+
this.router = router;
|
|
9
|
+
}
|
|
10
|
+
async getThreads(overrideQueryParams, updateMethod = 'overwrite', updateState = true) {
|
|
11
|
+
if (!this.nylasAuthStore.state.isAuthenticated) {
|
|
12
|
+
throw new Error('Not authenticated');
|
|
13
|
+
}
|
|
14
|
+
if (!this.nylasAuth.hasScopeByType('email', ['read-only', 'modify'])) {
|
|
15
|
+
throw new Error('Missing thread:read-only scope');
|
|
16
|
+
}
|
|
17
|
+
if (updateState) {
|
|
18
|
+
this.nylasMailboxStore.state.state = 'loading';
|
|
19
|
+
}
|
|
20
|
+
const queryParams = overrideQueryParams || this.nylasMailboxStore.state.threadsQueryParams;
|
|
21
|
+
const params = new URLSearchParams();
|
|
22
|
+
for (const key in queryParams) {
|
|
23
|
+
const value = queryParams[key]?.toString();
|
|
24
|
+
if (typeof value !== 'undefined' && value !== null) {
|
|
25
|
+
params.append(key, value);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (queryParams.search_query_native) {
|
|
29
|
+
this.router.navigate(`/?query=${queryParams.search_query_native}`, true);
|
|
30
|
+
}
|
|
31
|
+
else if (this.nylasMailboxStore.state.threadsQueryParams.search_query_native && !queryParams.search_query_native) {
|
|
32
|
+
this.router.navigate('/', true);
|
|
33
|
+
}
|
|
34
|
+
if (!queryParams.page_token) {
|
|
35
|
+
this.nylasMailboxStore.state.previousThreadPageTokens = [];
|
|
36
|
+
}
|
|
37
|
+
this.nylasMailboxStore.state.threadsQueryParams = queryParams;
|
|
38
|
+
const path = `/v3/grants/me/threads?${params.toString()}`;
|
|
39
|
+
const response = await this.nylasAuth.nylasAPIRequest(path);
|
|
40
|
+
if (isNylasErrorResponse(response)) {
|
|
41
|
+
throw new NylasAPIError(response.error);
|
|
42
|
+
}
|
|
43
|
+
const threads = response.data;
|
|
44
|
+
switch (updateMethod) {
|
|
45
|
+
case 'prepend':
|
|
46
|
+
this.nylasMailboxStore.state.threads = [...threads, ...this.nylasMailboxStore.state.threads];
|
|
47
|
+
break;
|
|
48
|
+
case 'append':
|
|
49
|
+
this.nylasMailboxStore.state.threads = [...this.nylasMailboxStore.state.threads, ...threads];
|
|
50
|
+
break;
|
|
51
|
+
case 'overwrite':
|
|
52
|
+
default:
|
|
53
|
+
this.nylasMailboxStore.state.threads = threads;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
if (response.next_cursor) {
|
|
57
|
+
this.nylasMailboxStore.state.nextThreadPageToken = response.next_cursor;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
this.nylasMailboxStore.state.nextThreadPageToken = null;
|
|
61
|
+
}
|
|
62
|
+
if (updateState) {
|
|
63
|
+
this.nylasMailboxStore.state.state = 'ready';
|
|
64
|
+
}
|
|
65
|
+
return threads;
|
|
66
|
+
}
|
|
67
|
+
async getThread(threadId) {
|
|
68
|
+
if (!this.nylasAuthStore.state.isAuthenticated) {
|
|
69
|
+
throw new Error('Not authenticated');
|
|
70
|
+
}
|
|
71
|
+
if (!this.nylasAuth.hasScopeByType('email', ['read-only', 'modify'])) {
|
|
72
|
+
throw new Error('Missing thread:read-only scope');
|
|
73
|
+
}
|
|
74
|
+
const storeThread = this.nylasMailboxStore.state.threads.find(t => t.id === threadId);
|
|
75
|
+
if (storeThread) {
|
|
76
|
+
return storeThread;
|
|
77
|
+
}
|
|
78
|
+
this.nylasMailboxStore.state.state = 'loading';
|
|
79
|
+
const path = `/v3/grants/me/threads/${threadId}`;
|
|
80
|
+
const response = await this.nylasAuth.nylasAPIRequest(path);
|
|
81
|
+
if (isNylasErrorResponse(response)) {
|
|
82
|
+
throw new NylasAPIError(response.error);
|
|
83
|
+
}
|
|
84
|
+
const thread = response.data;
|
|
85
|
+
this.nylasMailboxStore.state.threads = this.nylasMailboxStore.state.threads.map(t => {
|
|
86
|
+
if (t.id === thread.id) {
|
|
87
|
+
return thread;
|
|
88
|
+
}
|
|
89
|
+
return t;
|
|
90
|
+
});
|
|
91
|
+
this.nylasMailboxStore.state.state = 'ready';
|
|
92
|
+
return thread;
|
|
93
|
+
}
|
|
94
|
+
async nextThreadPage(updateMethod = 'overwrite', updateLoadingState = true) {
|
|
95
|
+
if (!this.nylasMailboxStore.state.nextThreadPageToken) {
|
|
96
|
+
throw new Error('No next page token');
|
|
97
|
+
}
|
|
98
|
+
this.nylasMailboxStore.state.previousThreadPageTokens = Array.from(new Set([...this.nylasMailboxStore.state.previousThreadPageTokens, this.nylasMailboxStore.state.threadsQueryParams.page_token ?? null]));
|
|
99
|
+
const nextPageToken = this.nylasMailboxStore.state.nextThreadPageToken;
|
|
100
|
+
return this.getThreads({
|
|
101
|
+
...this.nylasMailboxStore.state.threadsQueryParams,
|
|
102
|
+
page_token: nextPageToken,
|
|
103
|
+
}, updateMethod, updateLoadingState);
|
|
104
|
+
}
|
|
105
|
+
async previousThreadPage(aupdateMethod = 'overwrite', updateLoadingState = true) {
|
|
106
|
+
if (!this.nylasMailboxStore.state.previousThreadPageTokens.length) {
|
|
107
|
+
throw new Error('No previous page token');
|
|
108
|
+
}
|
|
109
|
+
const previousThreadPageTokens = [...this.nylasMailboxStore.state.previousThreadPageTokens];
|
|
110
|
+
const pageToken = previousThreadPageTokens.pop();
|
|
111
|
+
this.nylasMailboxStore.state.previousThreadPageTokens = previousThreadPageTokens;
|
|
112
|
+
return this.getThreads({
|
|
113
|
+
...this.nylasMailboxStore.state.threadsQueryParams,
|
|
114
|
+
page_token: pageToken ?? undefined,
|
|
115
|
+
}, aupdateMethod, updateLoadingState);
|
|
116
|
+
}
|
|
117
|
+
updateThreadQueryParams(params) {
|
|
118
|
+
this.nylasMailboxStore.state.threadsQueryParams = {
|
|
119
|
+
...this.nylasMailboxStore.state.threadsQueryParams,
|
|
120
|
+
...params,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
back() {
|
|
124
|
+
this.router.navigate('/', true);
|
|
125
|
+
this.nylasMailboxStore.state.selectedThread = null;
|
|
126
|
+
}
|
|
127
|
+
unSelectThread() {
|
|
128
|
+
this.nylasMailboxStore.state.selectedThread = null;
|
|
129
|
+
}
|
|
130
|
+
async selectThread(thread) {
|
|
131
|
+
this.router.navigate(`/thread/${thread.id}`, true);
|
|
132
|
+
this.nylasMailboxStore.state.selectedThread = thread;
|
|
133
|
+
if (thread.unread) {
|
|
134
|
+
this.markThreadAsRead(thread).catch(error => {
|
|
135
|
+
debug('Error marking thread as read', error);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async markThreadAsRead(thread) {
|
|
140
|
+
return this.updateThread(thread, { unread: false });
|
|
141
|
+
}
|
|
142
|
+
async updateThread(thread, updateThread) {
|
|
143
|
+
if (!this.nylasAuthStore.state.isAuthenticated) {
|
|
144
|
+
throw new Error('Not authenticated');
|
|
145
|
+
}
|
|
146
|
+
if (!this.nylasAuth.hasScopeByType('email', 'modify')) {
|
|
147
|
+
throw new Error('Missing thread:modify scope');
|
|
148
|
+
}
|
|
149
|
+
const path = `/v3/grants/me/threads/${thread.id}`;
|
|
150
|
+
const response = await this.nylasAuth.nylasAPIRequest(path, 'PUT', updateThread);
|
|
151
|
+
if (isNylasErrorResponse(response)) {
|
|
152
|
+
throw new NylasAPIError(response.error);
|
|
153
|
+
}
|
|
154
|
+
const updatedThread = response.data;
|
|
155
|
+
this.nylasMailboxStore.state.threads = this.nylasMailboxStore.state.threads.map(t => {
|
|
156
|
+
if (t.id === updatedThread.id) {
|
|
157
|
+
return updatedThread;
|
|
158
|
+
}
|
|
159
|
+
return t;
|
|
160
|
+
});
|
|
161
|
+
this.nylasMailboxStore.state.selectedThread = updatedThread;
|
|
162
|
+
return updatedThread;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=threads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"threads.js","sourceRoot":"","sources":["../../../../src/connector/shared/api/threads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,aAAa,EAA+D,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAI/H,MAAM,OAAO,qBAAqB;IAMhC,YAAY,SAAwB,EAAE,cAAkC,EAAE,iBAAwC,EAAE,MAAuB;QACzI,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAUM,KAAK,CAAC,UAAU,CACrB,mBAAoD,EACpD,eAAmD,WAAW,EAC9D,cAAuB,IAAI;QAE3B,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACvC,CAAC;QAGD,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC;YACrE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACpD,CAAC;QAGD,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC;QACjD,CAAC;QAGD,MAAM,WAAW,GAAG,mBAAmB,IAAI,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,kBAAkB,CAAC;QAC3F,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;QACrC,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;YAC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MAAM,IAAI,CAAC,SAAS,CAAC,eAAe,CAAwB,IAAI,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;QACxG,IAAI,oBAAoB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC1C,CAAC;QAGD,MAAM,aAAa,GAAG,QAAQ,CAAC,IAAI,CAAC;QACpC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YAClF,IAAI,CAAC,CAAC,EAAE,KAAK,aAAa,CAAC,EAAE,EAAE,CAAC;gBAC9B,OAAO,aAAa,CAAC;YACvB,CAAC;YACD,OAAO,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,cAAc,GAAG,aAAa,CAAC;QAE5D,OAAO,aAAa,CAAC;IACvB,CAAC;CACF","sourcesContent":["import { debug } from '@/utils/utils';\nimport { NylasAPIError, NylasAuthType, NylasResponse, Thread, ThreadQueryParameters, isNylasErrorResponse } from '@nylas/core';\nimport { NylasAuthStoreType, NylasMailboxStoreType } from '../../../components';\nimport { RouterInterface } from '@/routers/router-interface';\n\nexport class NylasThreadsConnector {\n private nylasAuth: NylasAuthType;\n private nylasAuthStore: NylasAuthStoreType;\n private nylasMailboxStore: NylasMailboxStoreType;\n private router: RouterInterface;\n\n constructor(nylasAuth: NylasAuthType, nylasAuthStore: NylasAuthStoreType, nylasMailboxStore: NylasMailboxStoreType, router: RouterInterface) {\n this.nylasAuth = nylasAuth;\n this.nylasAuthStore = nylasAuthStore;\n this.nylasMailboxStore = nylasMailboxStore;\n this.router = router;\n }\n\n /**\n * Returns the list of threads.\n * @todo Re-think how we handle pagination (previous/next page tokens) - there is a separation of logic here that might be confusing.\n * @param {Partial<ThreadQueryParameters> | undefined} overrideQueryParams The query parameters to override from the store.\n * @param {'prepend' | 'append' | 'overwrite'} updateMethod How to update the store with the threads (default: overwrite).\n * @param {boolean} updateState Whether to update the state or not (default: true).\n * @returns {Promise<Thread[]>}\n */\n public async getThreads(\n overrideQueryParams?: Partial<ThreadQueryParameters>,\n updateMethod: 'prepend' | 'append' | 'overwrite' = 'overwrite',\n updateState: boolean = true,\n ): Promise<Thread[]> {\n if (!this.nylasAuthStore.state.isAuthenticated) {\n throw new Error('Not authenticated');\n }\n\n // Now make sure we have a read-only or modify scopes\n if (!this.nylasAuth.hasScopeByType('email', ['read-only', 'modify'])) {\n throw new Error('Missing thread:read-only scope');\n }\n\n // Set the state to loading.\n if (updateState) {\n this.nylasMailboxStore.state.state = 'loading';\n }\n\n // Build the URL with the query parameters\n const queryParams = overrideQueryParams || this.nylasMailboxStore.state.threadsQueryParams;\n const params = new URLSearchParams();\n for (const key in queryParams) {\n const value = queryParams[key as keyof typeof queryParams]?.toString();\n if (typeof value !== 'undefined' && value !== null) {\n params.append(key, value);\n }\n }\n\n // TODO: Re-think how to update the router, this seems wrong\n if (queryParams.search_query_native) {\n this.router.navigate(`/?query=${queryParams.search_query_native}`, true);\n } else if (this.nylasMailboxStore.state.threadsQueryParams.search_query_native && !queryParams.search_query_native) {\n this.router.navigate('/', true);\n }\n\n // If page_token is not set, reset the previous page tokens.\n if (!queryParams.page_token) {\n this.nylasMailboxStore.state.previousThreadPageTokens = [];\n }\n\n this.nylasMailboxStore.state.threadsQueryParams = queryParams;\n\n // Make the API request.\n const path = `/v3/grants/me/threads?${params.toString()}`;\n const response = await this.nylasAuth.nylasAPIRequest<NylasResponse<Thread[]>>(path);\n if (isNylasErrorResponse(response)) {\n throw new NylasAPIError(response.error);\n }\n\n // Set the threads in the store.\n const threads = response.data;\n switch (updateMethod) {\n case 'prepend':\n this.nylasMailboxStore.state.threads = [...threads, ...this.nylasMailboxStore.state.threads];\n break;\n case 'append':\n this.nylasMailboxStore.state.threads = [...this.nylasMailboxStore.state.threads, ...threads];\n break;\n case 'overwrite':\n default:\n this.nylasMailboxStore.state.threads = threads;\n break;\n }\n\n // If we have a next cursor, set it in the store.\n if (response.next_cursor) {\n this.nylasMailboxStore.state.nextThreadPageToken = response.next_cursor;\n } else {\n this.nylasMailboxStore.state.nextThreadPageToken = null;\n }\n\n // Set the state to ready.\n if (updateState) {\n this.nylasMailboxStore.state.state = 'ready';\n }\n\n return threads;\n }\n\n public async getThread(threadId: string): Promise<Thread> {\n if (!this.nylasAuthStore.state.isAuthenticated) {\n throw new Error('Not authenticated');\n }\n\n // Now make sure we have a read-only or modify scopes\n if (!this.nylasAuth.hasScopeByType('email', ['read-only', 'modify'])) {\n throw new Error('Missing thread:read-only scope');\n }\n\n // Check if we have the thread in the store already.\n const storeThread = this.nylasMailboxStore.state.threads.find(t => t.id === threadId);\n if (storeThread) {\n return storeThread;\n }\n\n // Set the state to loading.\n this.nylasMailboxStore.state.state = 'loading';\n\n // Make the API request.\n const path = `/v3/grants/me/threads/${threadId}`;\n const response = await this.nylasAuth.nylasAPIRequest<NylasResponse<Thread>>(path);\n if (isNylasErrorResponse(response)) {\n throw new NylasAPIError(response.error);\n }\n\n // Set the threads in the store.\n const thread = response.data;\n this.nylasMailboxStore.state.threads = this.nylasMailboxStore.state.threads.map(t => {\n if (t.id === thread.id) {\n return thread;\n }\n return t;\n });\n\n // Set the state to ready.\n this.nylasMailboxStore.state.state = 'ready';\n\n return thread;\n }\n\n /**\n * Returns the next page of threads.\n * @param {'prepend' | 'append' | 'overwrite'} updateMethod How to update the store with the threads (default: overwrite).\n * @param {boolean} updateLoadingState Whether to update the loading state or not.\n * @returns {Promise<Thread[]>} The previous page of threads.\n */\n public async nextThreadPage(updateMethod: 'prepend' | 'append' | 'overwrite' = 'overwrite', updateLoadingState: boolean = true): Promise<Thread[]> {\n if (!this.nylasMailboxStore.state.nextThreadPageToken) {\n throw new Error('No next page token');\n }\n\n // If we have a next page token, add it to the previous page tokens.\n this.nylasMailboxStore.state.previousThreadPageTokens = Array.from(\n new Set([...this.nylasMailboxStore.state.previousThreadPageTokens, this.nylasMailboxStore.state.threadsQueryParams.page_token ?? null]),\n );\n\n // Get the last next page token.\n const nextPageToken = this.nylasMailboxStore.state.nextThreadPageToken;\n\n return this.getThreads(\n {\n ...this.nylasMailboxStore.state.threadsQueryParams,\n page_token: nextPageToken,\n },\n updateMethod,\n updateLoadingState,\n );\n }\n\n /**\n * Returns the previous page of threads.\n * @param {'prepend' | 'append' | 'overwrite'} updateMethod How to update the store with the threads (default: overwrite).\n * @param {boolean} updateLoadingState Whether to update the loading state or not.\n * @returns {Promise<Thread[]>} The previous page of threads.\n */\n public async previousThreadPage(aupdateMethod: 'prepend' | 'append' | 'overwrite' = 'overwrite', updateLoadingState: boolean = true): Promise<Thread[]> {\n if (!this.nylasMailboxStore.state.previousThreadPageTokens.length) {\n throw new Error('No previous page token');\n }\n\n // Remove the the last two next page tokens.\n const previousThreadPageTokens = [...this.nylasMailboxStore.state.previousThreadPageTokens];\n const pageToken = previousThreadPageTokens.pop();\n\n // Update the store.\n this.nylasMailboxStore.state.previousThreadPageTokens = previousThreadPageTokens;\n\n return this.getThreads(\n {\n ...this.nylasMailboxStore.state.threadsQueryParams,\n page_token: pageToken ?? undefined,\n },\n aupdateMethod,\n updateLoadingState,\n );\n }\n\n /**\n * Updates the thread query parameters in the store.\n * @param params Partial<ThreadQueryParameters>\n * @returns {void}\n */\n public updateThreadQueryParams(params: Partial<ThreadQueryParameters>): void {\n this.nylasMailboxStore.state.threadsQueryParams = {\n ...this.nylasMailboxStore.state.threadsQueryParams,\n ...params,\n };\n }\n\n /**\n * Back to the mailbox.\n */\n public back(): void {\n this.router.navigate('/', true);\n this.nylasMailboxStore.state.selectedThread = null;\n }\n\n /**\n * Unselects a thread.\n */\n public unSelectThread(): void {\n this.nylasMailboxStore.state.selectedThread = null;\n }\n\n /**\n * Selects a thread.\n * @param {Thread} thread The thread to select.\n * @returns {Promise<void>}\n */\n public async selectThread(thread: Thread): Promise<void> {\n this.router.navigate(`/thread/${thread.id}`, true);\n this.nylasMailboxStore.state.selectedThread = thread;\n\n // Mark the thread as read (async) if it is unread.\n if (thread.unread) {\n this.markThreadAsRead(thread).catch(error => {\n debug('Error marking thread as read', error);\n });\n }\n }\n\n /**\n * Marks a thread as read.\n * @param thread\n * @returns {Promise<Thread>}\n */\n public async markThreadAsRead(thread: Thread): Promise<Thread> {\n return this.updateThread(thread, { unread: false });\n }\n\n /**\n * Updates a thread.\n * @param thread The thread to update.\n * @returns {Promise<Thread>}\n */\n public async updateThread(thread: Thread, updateThread: Partial<Thread>): Promise<Thread> {\n // Make sure we have an authenticated user.\n if (!this.nylasAuthStore.state.isAuthenticated) {\n throw new Error('Not authenticated');\n }\n\n // Now make sure we have a modify scope at least.\n if (!this.nylasAuth.hasScopeByType('email', 'modify')) {\n throw new Error('Missing thread:modify scope');\n }\n\n // Make the API request.\n const path = `/v3/grants/me/threads/${thread.id}`;\n const response = await this.nylasAuth.nylasAPIRequest<NylasResponse<Thread>>(path, 'PUT', updateThread);\n if (isNylasErrorResponse(response)) {\n throw new NylasAPIError(response.error);\n }\n\n // Update the thread in the store.\n const updatedThread = response.data;\n this.nylasMailboxStore.state.threads = this.nylasMailboxStore.state.threads.map(t => {\n if (t.id === updatedThread.id) {\n return updatedThread;\n }\n return t;\n });\n this.nylasMailboxStore.state.selectedThread = updatedThread;\n\n return updatedThread;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAE7B,OAAO,eAA+B,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAc,CAAC","sourcesContent":["export * from './components';\nexport { ObservableMap } from '@stencil/store';\nimport NylasThemeStore, { NylasTheme } from './common/nylas-theme';\nexport { NylasThemeStore, NylasTheme };\n"]}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { debug } from "../utils/utils";
|
|
2
|
+
export class PolyFillHashChangeEvent extends Event {
|
|
3
|
+
constructor(type, eventInitDict) {
|
|
4
|
+
super(type, eventInitDict);
|
|
5
|
+
this.oldURL = eventInitDict.oldURL;
|
|
6
|
+
this.newURL = eventInitDict.newURL;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export class HashRouter {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.routeChangeListeners = [];
|
|
12
|
+
debug('HashRouter constructor');
|
|
13
|
+
}
|
|
14
|
+
destroy() {
|
|
15
|
+
debug('HashRouter destroy');
|
|
16
|
+
window.removeEventListener('hashchange', this.onRouteChange.bind(this));
|
|
17
|
+
}
|
|
18
|
+
init() {
|
|
19
|
+
debug('HashRouter init');
|
|
20
|
+
window.addEventListener('hashchange', this.onRouteChange.bind(this));
|
|
21
|
+
if (typeof HashChangeEvent !== 'undefined') {
|
|
22
|
+
const event = new HashChangeEvent('hashchange', { oldURL: '', newURL: window.location.href });
|
|
23
|
+
this.onRouteChange(event);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const event = new PolyFillHashChangeEvent('hashchange', { oldURL: '', newURL: window.location.href });
|
|
27
|
+
this.onRouteChange(event);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
addRouteChangeListener(route, listener) {
|
|
31
|
+
debug('HashRouter addRouteChangeListener');
|
|
32
|
+
this.routeChangeListeners.push([route, listener]);
|
|
33
|
+
}
|
|
34
|
+
navigate(route, shallow) {
|
|
35
|
+
debug('HashRouter navigate');
|
|
36
|
+
if (shallow) {
|
|
37
|
+
return window.history.pushState(null, '', `#${route}`);
|
|
38
|
+
}
|
|
39
|
+
window.location.hash = route;
|
|
40
|
+
}
|
|
41
|
+
setRoute(route) {
|
|
42
|
+
debug('HashRouter setRoute');
|
|
43
|
+
window.location.hash = route;
|
|
44
|
+
}
|
|
45
|
+
matchRoute(route, path) {
|
|
46
|
+
const routeParts = route.split('/');
|
|
47
|
+
const pathParts = path.split('/');
|
|
48
|
+
debug(`HashRouter matchRoute route=${route} path=${path}`, { routeParts, pathParts });
|
|
49
|
+
if (routeParts[1] === '' && pathParts[0] === '') {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
if (routeParts.length !== pathParts.length) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
for (let i = 0; i < routeParts.length; i++) {
|
|
56
|
+
const routePart = routeParts[i];
|
|
57
|
+
const pathPart = pathParts[i];
|
|
58
|
+
if (routePart.startsWith(':')) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (routePart !== pathPart) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
getRouteParams(route) {
|
|
68
|
+
debug('HashRouter getRouteParams');
|
|
69
|
+
const routeParams = {};
|
|
70
|
+
const routeParts = route.split('/');
|
|
71
|
+
const routeConfigParts = window.location.hash.split('/');
|
|
72
|
+
routeParts.forEach((routePart, index) => {
|
|
73
|
+
if (routePart.startsWith(':')) {
|
|
74
|
+
const key = routePart.substring(1);
|
|
75
|
+
routeParams[key] = routeConfigParts[index];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return routeParams;
|
|
79
|
+
}
|
|
80
|
+
getRouteWithParams(route, routeParams) {
|
|
81
|
+
debug('HashRouter getRouteWithParams');
|
|
82
|
+
let routeWithParams = route;
|
|
83
|
+
Object.keys(routeParams).forEach(key => {
|
|
84
|
+
routeWithParams = routeWithParams.replace(`:${key}`, routeParams[key]);
|
|
85
|
+
});
|
|
86
|
+
return routeWithParams;
|
|
87
|
+
}
|
|
88
|
+
getRoute() {
|
|
89
|
+
debug('HashRouter getRoute');
|
|
90
|
+
return window.location.hash;
|
|
91
|
+
}
|
|
92
|
+
onRouteChange(event) {
|
|
93
|
+
this.routeChangeListeners.forEach(async ([route, listener]) => {
|
|
94
|
+
const path = event.newURL.indexOf('#') === -1 ? '' : event.newURL.substring(event.newURL.indexOf('#') + 1);
|
|
95
|
+
debug(`HashRouter onRouteChange route=${route} path=${path}`, { event });
|
|
96
|
+
if (!this.matchRoute(route, path)) {
|
|
97
|
+
debug(`HashRouter onRouteChange route=${route} path=${path} does not match`);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const routeParams = this.getRouteParams(route);
|
|
101
|
+
await listener(route, path, routeParams);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
getBasePath() {
|
|
105
|
+
debug('HashRouter getBasePath');
|
|
106
|
+
return '';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=hash-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash-router.js","sourceRoot":"","sources":["../../src/routers/hash-router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGtC,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAIhD,YAAY,IAAY,EAAE,aAAkC;QAC1D,KAAK,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;IACrC,CAAC;CACF;AAED,MAAM,OAAO,UAAU;IAGrB;QAFQ,yBAAoB,GAA6C,EAAE,CAAC;QAG1E,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAClC,CAAC;IAGM,OAAO;QACZ,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAC5B,MAAM,CAAC,mBAAmB,CAAC,YAAY,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1E,CAAC;IAGM,IAAI;QACT,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACzB,MAAM,CAAC,gBAAgB,CAAC,YAAY,EAAE,IAAI,CAAC,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,CAAC,kCAAkC,KAAK,SAAS,IAAI,iBAAiB,CAAC,CAAC;gBAC7E,OAAO;YACT,CAAC;YACD,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAA2B,CAAC;YACzE,MAAM,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,WAAW;QAChB,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAChC,OAAO,EAAE,CAAC;IACZ,CAAC;CACF","sourcesContent":["import { debug } from '@/utils/utils';\nimport { RouteListener, RouteParams, RoutePath, RouterInterface } from './router-interface';\n\nexport class PolyFillHashChangeEvent extends Event {\n oldURL?: string;\n newURL?: string;\n\n constructor(type: string, eventInitDict: HashChangeEventInit) {\n super(type, eventInitDict);\n this.oldURL = eventInitDict.oldURL;\n this.newURL = eventInitDict.newURL;\n }\n}\n\nexport class HashRouter implements RouterInterface {\n private routeChangeListeners: [route: RoutePath, RouteListener<any>][] = [];\n\n constructor() {\n debug('HashRouter constructor');\n }\n\n // Destroy the router\n public destroy(): void {\n debug('HashRouter destroy');\n window.removeEventListener('hashchange', this.onRouteChange.bind(this));\n }\n\n // Initialize the router\n public init(): void {\n debug('HashRouter init');\n window.addEventListener('hashchange', this.onRouteChange.bind(this));\n\n // Trigger the initial route change\n if (typeof HashChangeEvent !== 'undefined') {\n const event: HashChangeEvent = new HashChangeEvent('hashchange', { oldURL: '', newURL: window.location.href });\n this.onRouteChange(event);\n } else {\n const event: Event = new PolyFillHashChangeEvent('hashchange', { oldURL: '', newURL: window.location.href });\n this.onRouteChange(event as HashChangeEvent);\n }\n }\n\n public addRouteChangeListener<Path extends RoutePath>(route: Path, listener: RouteListener<Path>): void {\n debug('HashRouter addRouteChangeListener');\n this.routeChangeListeners.push([route, listener]);\n }\n\n public navigate(route: string, shallow: boolean): void {\n debug('HashRouter navigate');\n\n // If we're navigating shallow, don't add a new history entry\n if (shallow) {\n return window.history.pushState(null, '', `#${route}`);\n }\n\n window.location.hash = route;\n }\n\n public setRoute(route: string): void {\n debug('HashRouter setRoute');\n window.location.hash = route;\n }\n\n // Matches a route and executes the callback\n public matchRoute(route: string, path: string): boolean {\n const routeParts = route.split('/');\n const pathParts = path.split('/');\n\n // If the route is `/` an the hash is empty, match the route\n debug(`HashRouter matchRoute route=${route} path=${path}`, { routeParts, pathParts });\n if (routeParts[1] === '' && pathParts[0] === '') {\n return true;\n }\n\n if (routeParts.length !== pathParts.length) {\n return false;\n }\n\n for (let i = 0; i < routeParts.length; i++) {\n const routePart = routeParts[i];\n const pathPart = pathParts[i];\n if (routePart.startsWith(':')) {\n continue;\n }\n if (routePart !== pathPart) {\n return false;\n }\n }\n\n return true;\n }\n\n // Parse the route and return the route params\n public getRouteParams<Path extends RoutePath>(route: Path): RouteParams<Path> {\n debug('HashRouter getRouteParams');\n const routeParams: RouteParams<Path> = {} as RouteParams<Path>;\n const routeParts = route.split('/');\n const routeConfigParts = window.location.hash.split('/');\n routeParts.forEach((routePart, index) => {\n if (routePart.startsWith(':')) {\n const key = routePart.substring(1) as keyof RouteParams<Path>;\n routeParams[key] = routeConfigParts[index] as RouteParams<Path>[keyof RouteParams<Path>]; // Cast the value to string\n }\n });\n return routeParams;\n }\n\n public getRouteWithParams(route: string, routeParams: Record<string, any>): string {\n debug('HashRouter getRouteWithParams');\n let routeWithParams = route;\n Object.keys(routeParams).forEach(key => {\n routeWithParams = routeWithParams.replace(`:${key}`, routeParams[key]);\n });\n return routeWithParams;\n }\n\n public getRoute(): string {\n debug('HashRouter getRoute');\n return window.location.hash;\n }\n\n public onRouteChange(event: HashChangeEvent): void {\n this.routeChangeListeners.forEach(async ([route, listener]) => {\n const path = event.newURL.indexOf('#') === -1 ? '' : event.newURL.substring(event.newURL.indexOf('#') + 1);\n debug(`HashRouter onRouteChange route=${route} path=${path}`, { event });\n if (!this.matchRoute(route, path)) {\n debug(`HashRouter onRouteChange route=${route} path=${path} does not match`);\n return;\n }\n const routeParams = this.getRouteParams(route) as RouteParams<RoutePath>;\n await listener(route, path, routeParams);\n });\n }\n\n public getBasePath(): string {\n debug('HashRouter getBasePath');\n return '';\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router-interface.js","sourceRoot":"","sources":["../../src/routers/router-interface.ts"],"names":[],"mappings":"","sourcesContent":["export type RoutePath = string;\n// RouteParams is a type that takes a RoutePath and returns an object with the route params as keys\n// and the value of the route param as the value of the key\n// Example:\n// RoutePath: '/:mailboxId/:messageId'\nexport type RouteParams<Path extends string> = Path extends `${infer _Start}:${infer Param}/${infer Rest}`\n ? { [key in Param | keyof RouteParams<Rest>]: string }\n : Path extends `${infer _Start}:${infer Param}`\n ? { [key in Param]: string }\n : {};\nexport type RouteListener<Path extends string> = (route: Path, path: string, routeParams: RouteParams<Path>) => Promise<void>;\n\nexport interface RouterInterface {\n init(): void;\n addRouteChangeListener<Path extends RoutePath>(route: Path, listener: RouteListener<Path>): void;\n setRoute(route: string): void;\n navigate(route: string, shallow: boolean): void;\n getRoute(): string;\n getBasePath(): string;\n matchRoute(route: string, path: string): boolean;\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createStore } from "@stencil/store";
|
|
2
|
+
export function CreateNylasAuthStore(defaultState = {}) {
|
|
3
|
+
const defaultNylasStoreState = {
|
|
4
|
+
isAuthenticated: false,
|
|
5
|
+
tokenInfo: null,
|
|
6
|
+
state: 'ready',
|
|
7
|
+
...defaultState,
|
|
8
|
+
};
|
|
9
|
+
const store = createStore(defaultNylasStoreState);
|
|
10
|
+
store.reset = () => {
|
|
11
|
+
for (const key in defaultNylasStoreState) {
|
|
12
|
+
const value = defaultNylasStoreState[key];
|
|
13
|
+
store.set(key, value);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
return store;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=auth-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-store.js","sourceRoot":"","sources":["../../src/stores/auth-store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAW7C,MAAM,UAAU,oBAAoB,CAAC,eAA6C,EAAE;IAClF,MAAM,sBAAsB,GAAwB;QAClD,eAAe,EAAE,KAAK;QACtB,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,OAAO;QACd,GAAG,YAAY;KAChB,CAAC;IACF,MAAM,KAAK,GAAG,WAAW,CAAsB,sBAAsB,CAAC,CAAC;IAOvE,KAAK,CAAC,KAAK,GAAG,GAAG,EAAE;QACjB,KAAK,MAAM,GAAG,IAAI,sBAAsB,EAAE,CAAC;YACzC,MAAM,KAAK,GAAG,sBAAsB,CAAC,GAA0C,CAAC,CAAC;YACjF,KAAK,CAAC,GAAG,CAAC,GAAU,EAAE,KAAK,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { TokenInfo } from '@nylas/core/dist/auth';\nimport { createStore } from '@stencil/store';\nimport { DataState } from '..';\n\nexport interface NylasAuthStoreState {\n isAuthenticated: boolean;\n tokenInfo: TokenInfo | null;\n state: DataState;\n}\n\nexport type NylasAuthStoreType = ReturnType<typeof CreateNylasAuthStore>;\n\nexport function CreateNylasAuthStore(defaultState: Partial<NylasAuthStoreState> = {}) {\n const defaultNylasStoreState: NylasAuthStoreState = {\n isAuthenticated: false,\n tokenInfo: null,\n state: 'ready',\n ...defaultState,\n };\n const store = createStore<NylasAuthStoreState>(defaultNylasStoreState);\n\n /**\n * Reset the Nylas store to its default state.\n * There is something wrong with the stencil/store reset method,\n * so we have to do it via this hack.\n */\n store.reset = () => {\n for (const key in defaultNylasStoreState) {\n const value = defaultNylasStoreState[key as keyof typeof defaultNylasStoreState];\n store.set(key as any, value);\n }\n };\n\n return store;\n}\n"]}
|