getScheduledActions

The getScheduledActions method is responsible for retrieving scheduled publish events from the content source

Return Value
[ScheduledAction[]](/content-sources/scheduled-action)

This method controls how scheduled publishing should be handled by the content source. If supported and properly implemented, Netlify Create adds additional controls for editors to be able to schedule publish events.

Parameters

No parameters are used in this method.

Example

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
import type { ContentSourceInterface, ScheduledAction } from '@stackbit/types'
import { convertAndFilterScheduledActions } from './utils'

export class MyContentSource implements ContentSourceInterface<UserContext> {
  async getScheduledActions(): Promise<ScheduledAction[]> {
    this.logger.debug('getScheduledPublishes')
    const cmsSchedules = await this.apiClient.fetchScheduledActions()
    // convert schedules from your underlying CMS's format to Netlify Create's ScheduledAction type and filter irrelevant schedules
    return convertAndFilterScheduledActions(cmsSchedules)
  }

  // other methods ...
}

Scheduled Publishing Controls

This implementation must rely on the content source (or some other external mechanism) for handling the schedule queue and actions.

Scheduled publishing is not always available in content source providers, in which case the feature will be disabled in Netlify Create. See below for additional details and scenarios.

Disabling Scheduled Publishing

To determine if scheduled publishing is supported in the the CSI module, Netlify Create checks for the presence of all scheduled action methods. (See below)

If those methods are implemented, Netlify Create will then call this method during the initialization process. If this method throws an error, the feature will be marked as disabled.

Sources Without Schedules

When a source does not support scheduled publishing, simply don't implement the methods and Netlify Create will consider the feature disabled. Editors will not be able to schedule publish events.

Handling User Tiers

In some cases, a content source and its corresponding CSI module may support scheduled publishing events, but they may be available based on permissions or project/user tier.

If a user doesn't have access to scheduled publishing in the content source, this method should throw an error, in which case scheduled events will be disabled for that user.

Logging

Because a failure in this method may just mean the feature is disabled, feedback from the method is logged to the console (logs) in Netlify Create.

All other scheduling methods will show notifications in the UI if the methods fail.

This method should be implemented alongside the other scheduled action methods: