Skip to main content

Spectral 3.x Upgrade Guide

With Spectral 3.x, you can now specify authorization methods (Basic Auth, OAuth2, etc.) at the action level rather than at the component level. Let's explore this change and how to upgrade your component from Spectral 2.x to Spectral 3.x.

To start, update @prismatic-io/spectral to ^3.0.0 in your package.json file and then run npm install or yarn install:

{
"dependencies": {
"@prismatic-io/spectral": "^3.0.0"
}
}

Next, remove the authorization block from your component definition:

export default component({
key: "sampleComponent",
public: false,
display: {
label: "Sample Component",
description: "sampleComponent",
iconPath: "icon.png",
},
actions: { myAction },
authorization: {
required: true,
methods: ["basic", "api_key"],
},
});

Finally, add an authorization block to any action definition that requires credentials:

export const myAction = action({
display: {
label: "My Action",
description: "This is my action",
},
perform: async ({ credential }, { myInput }) => {
// Do something with the credential ...
},
inputs: { myInput: myInputField },
authorization: {
required: true,
methods: ["basic", "api_key"],
},
});