Skip to content
Last updated

The schema that defines the resources that your app needs. Most of the time these things include dynamic values that your app needs which will be provided by some external api. Resources can be Dynamic or hard coded. In the example below, we are taking group and channel by calling some api. These values will be stored and accessed from resources.group and resources.channel.

interface ResourceTypes {
    [key: string]: ResourceTypeSchema
}

Properties ResourceTypeSchema

PropertyDescriptionValue Type
idIdentifier of the resourcestring
performThe perform function that returns the value of resource in arrayarray

Example

module.exports = {
    group: {
        id: "group",
        perform: async (sdk, bundle) => {
            const response = await sdk.request({
                method: "GET",
                url: `https://${bundle.authData.host}/v2/groups`,
            });
            return response.data.groups;
        },
    },
    channel: {
        id: "channel",
        perform: async (sdk, bundle) => {
            const response = await sdk.request({
                method: "GET",
                url: `https://${bundle.authData.host}/v2/channels`,
            });
            return response.data.channels;
        },
    },
    userType: {
        id: 'userType',
        perform: (sdk, bundle) => {
            return [
                'User',
                'Bot'
            ]
        }
    }
};
const resources = require("./src/resources");

module.exports = {
    ...,
    resources: resources,
};