sdk
sdk copied to clipboard
Change "integrationConfigFields.json" to be JSON schema compatible
Currently, integrations perform a lot of basic validation on IntegrationInstance config that could be shifted to automatic validation in the SDK. We could do this by changing our existing integrationConfigFields.json to be JSON schema compatible.
For example, many integrations have validation like this:
const apiKey = instance.config?.apiKey;
if (!apiKey) {
throw new Error(
'Configuration option "apiKey" is missing on the integration instance config',
);
}
// More simple validation...
Proposed:
integrationConfigFields.json:
{
// We assume that every `integrationConfigFields.json` is type "object". If it is specified, we
// will just ignore it.
// type: "object",
"properties": {
"apiKey": {
"type": "string",
"format": "masked"
},
"myNumberField": {
"type": "number",
"minimum": 1,
"maximum": 5
}
},
"required": ["apiKey"]
}
The apiKey property above has a "format" property. We will write a custom ajv formatter for masked properties.
I think it still a good idea to have a JSON Schema for the config, but now that we have moved projects to integrationConfigFields.ts, we'd likely want to generate the schema.