@alwaysai/cloud-infrastructure-schemas
v0.1.2
Published
AlwaysAI Cloud Infrastructure Schemas
Keywords
Readme
AlwaysAI Cloud Infrastructure Schemas
Contents
The AlwaysAI Cloud Infrastructure Schemas package provides interfaces that represent the messaging interface for communication with the alwaysAI Cloud Infrastructure, as well as functions for validating JSON data that are being used in cloud infrastructure.
The provided interfaces are:
- aai-agent update interface
- AgentUpdateSetSettingsReqValidationStrategy
- AgentUpdateSetSettingsRespValidationStrategy
- AgentUpdateGetSettingsReqValidationStrategy
- AgentUpdateGetSettingsRespValidationStrategy
- AgentUpdateManualTriggerReqValidationStrategy
- AgentUpdateManualTriggerRespValidationStrategy
- BYOA pipeline interface
- ByoaEc2ParametersValidationStrategy
- TrainingSessionValidationStrategy
- TrainingSessionReqValidationStrategy
- Legacy pipeline interface
- LegacyEc2ParametersValidationStrategy
Use the provided interfaces as type guards in your development to ensure that proper messages are generated.
Usage
import {
AgentUpdateSetSettingsReqValidationStrategy,
AgentUpdateSetSettingsRespValidationStrategy,
ValidationContext
} from '@alwaysai/cloud-infrastructure-schemas';
const VALID_AGENT_UPDATE_SET_SETTINGS_REQ = {
txId: '8f9ac7fc-4735-4bf4-9b4b-00ee785722b8',
devices: [
'dc6762f3-412d-4926-ac55-3bfbc9ca8503',
'978fca67-178c-4a0e-8f0d-79f4e950b937',
'cc18883b-8137-4c68-bf8e-32403384f3fd',
'818e61b3-6630-473e-8d53-9740196977c5'
],
updateSettings: {
autoUpdate: 'patch',
autoUpdateUtcHour: 0,
autoUpdateWeekDay: 0
}
};
const VALID_AGENT_UPDATE_SET_SETTINGS_RESP = {
txId: '8f9ac7fc-4735-4bf4-9b4b-00ee785722b9'
};
const schemaValidationContext = new ValidationContext()
const setSettingsReqStrategy = new AgentUpdateSetSettingsReqValidationStrategy();
try{
schemaValidationContext.setStrategy(setSettingsReqStrategy)
schemaValidationContext.validate(VALID_AGENT_UPDATE_SET_SETTINGS_REQ)
// you can easily change the validation strategy to validate the resp as example
schemaValidationContext.setStrategy(new AgentUpdateSetSettingsRespValidationStrategy())
schemaValidationContext.validate(VALID_AGENT_UPDATE_SET_SETTINGS_RESP)
} catch (e) {
console.log(`validation failed ${e}`)
}
The Advantage of using Strategy pattern is that it is closed to modification of interface, but open to extensions without breaking functionality to earlier versions.
Release procedure
To release the package to npmjs.org follow the steps:
- publish new version: npm run publish:<major|minor|patch>
- watch the bitbucket pipeline running, if successful a new version will be created and published to npmjs.org
- to get the auto-generated commit and tags, simply pull: git pull
