Skip to content

scheduledActions

For use with Netlify Visual Editor only.

connector.scheduledActions(opts)

Used to add support in Visual Editor for scheduled publishing with your data source.

After you define the functions for creating and modifying scheduled events on your data source, Netlify will expose a models.ScheduledAction interface that you can use in connector.sync().

Note that this only works if your data source offers support for scheduled publishing or scheduled actions.

Takes an object where the keys are functions defined by your connector. The object contains the following properties:

ParameterDescription
createUsed to create a new scheduled event in your data source.
deleteUsed to delete a previously scheduled event in your data source.
updateUsed to update a previously scheduled event in your data source.

create

Receives a function to create a new scheduled event in your data source. The function is passed an object as the first parameter with the following properties:

PropertyDescription
scheduledActionObject representing the action to schedule.
stateObject containing data stored in initState when addConnector runs.

Usage example

const connector = extension.addConnector({
initState: () => {
const myCMSClient = new MyCMSClient();
return { myCMSClient };
},
});
connector.scheduledActions({
create: ({ scheduledAction, state: { myCMSClient } }) => {
const result = await state.apiClient.createScheduledAction({
action: scheduledAction.action,
documentIds: scheduledAction.documentIds,
executeAt: scheduledAction.executeAt,
name: scheduledAction.name,
});
return { id: result.id };
},
});

delete

Receives a function to delete a previously scheduled event in your data source. The function is passed an object as the first parameter with the following properties:

PropertyDescription
scheduledActionObject representing the action to delete.
stateObject containing data stored in initState when addConnector runs.

Usage example

const connector = extension.addConnector({
initState: () => {
const myCMSClient = new MyCMSClient();
return { myCMSClient };
},
});
connector.scheduledActions({
delete: ({ scheduledAction, state: { myCMSClient } }) => {
const result = await state.apiClient.deleteScheduledAction({
id: scheduledAction.id,
});
return { id: result.id };
},
});

update

Receives a function to update a previously scheduled event in your data source. The function is passed an object as the first parameter with the following properties:

PropertyDescription
scheduledActionObject representing the action to update.
stateObject containing data stored in initState when addConnector runs.

Usage example

const connector = extension.addConnector({
initState: () => {
const myCMSClient = new MyCMSClient();
return { myCMSClient };
},
});
connector.scheduledActions({
update: ({ scheduledAction, state: { myCMSClient } }) => {
const result = await state.apiClient.updateScheduledAction({
id: scheduledAction.id,
documentIds: scheduledAction.documentIds,
executeAt: scheduledAction.executeAt,
name: scheduledAction.name,
});
return { id: result.id };
},
});

scheduledAction

Object representing the action to schedule on the data source. The object contains the following properties:

ParameterDescription
nameString representing the name of the action to be scheduled.
actionConnectorScheduledActionActionType representing the type of action.
documentIdsArray of strings representing the Document ID values to be scheduled.
executeAtISO-formatted string used to determine the time at which the event should be triggered.

Got it!

Your feedback helps us improve our docs.