Warnings
How calsdk reports parts of a request a provider could not honor, without failing the call.
Sometimes a provider can do most of what you asked but not all of it. Failing the whole call over an event color would be unhelpful, and dropping the color silently would be worse, so calsdk saves what it can and tells you what it couldn't. A warning means the call succeeded, but not exactly as asked. Every result has a warnings array:
const { event, warnings } = await createEvent({
calendar, // microsoft(...)
event: { title: 'Launch', start, end, color: '#d50000' },
});
console.log(warnings);
// [{ type: 'unsupported', feature: 'color', details: 'Outlook events have no color of their own. Use providerOptions.microsoft.categories instead.' }]Three types
type | Meaning | Fields |
|---|---|---|
unsupported | The provider ignored part of the request it cannot honor | feature, details? |
compatibility | calsdk or the provider used a fallback that may behave a little differently | feature, details? |
other | Anything else worth knowing | message |
Some warnings you'll see:
compatibilityongetFreeBusyandfindFreeTimefor providers without a free/busy endpoint. Busy times were computed from events.compatibilityon Google when a color is not one of its 11 event colors. The nearest one was saved.unsupportedwhensendUpdatesasks for something a provider cannot do, such as Cal.com, which always emails attendees.unsupportedfor aproviderOptionskey the provider does not know.
Where warnings go
Warnings are also logged, since it's easy to never look at a result's warnings array. Set globalThis.CALSDK_WARNINGS once, at startup, to choose where they go:
// Default: console.warn each distinct warning once per process.
globalThis.CALSDK_WARNINGS = 'console';
// Only return them on results.
globalThis.CALSDK_WARNINGS = 'silent';
// Send them somewhere else.
globalThis.CALSDK_WARNINGS = (warnings, { provider, operation }) => {
logger.warn({ provider, operation, warnings }, 'calsdk warnings');
};A function you set here runs for every call that has warnings. iterateEvents yields events, not results, so this setting is the only place its warnings reach.
Warning or error?
calsdk warns when the rest of the request still did what you asked. It throws UnsupportedFunctionalityError instead when going ahead would save a different schedule or lose data, such as a recurrence rule the provider cannot repeat. See Errors.