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
}| Property | Description | Value Type |
|---|---|---|
| id | Identifier of the resource | string |
| perform | The perform function that returns the value of resource in array | array |
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,
};