git clone https://github.com/refinio/one.models
cd one.models
npm install
Main models used in one built in one package
As said we use TypeScript above JavaScript ES6 meaning we use import,export statements instead of require. And have the newest javascript features available
Additional we use prettier.js for automatic code styling. Here you should also copy an existing .prettierc form an existing project.
Most modern IDEs support to file watchers which then can execute scripts on changes. Setup prettier.js and build.js te be run on file changes.
The file @OneCoreTypes.d.ts defines the types this project uses as well as exports
import One from '@refinio/one.models/lib/api/One.js';
async function startOne() {
const oneConfig = {commServerUrl: 'wss://comm10.dev.refinio.one'};
const one = new One(oneConfig);
await one.init();
// can start using one now
const myInfo = await one.getLeuteApi().getMyInfo();
console.log(myInfo);
}
startOne().catch(console.error);
import One from '@refinio/one.models/lib/api/One.js';
async function startOne() {
// external to ONE.js models
const commServerUrl = 'wss://comm10.dev.refinio.one';
const leuteModel = new LeuteModel(commServerUrl, true);
const channelManager = new ChannelManager(leuteModel);
const questionnaireModel = new QuestionnaireModel(channelManager);
const documentModel = new DocumentModel(channelManager);
const iom = new IomManager(leuteModel, commServerUrl);
const topicModel = new TopicModel(channelManager, leuteModel);
// ONE.js with external models
const oneConfig = {commServerUrl, useExternalModels: true};
const one = new One(oneConfig);
await one.init({
initedModels: {
leuteModel: leuteModel,
channelManager: channelManager,
questionnaireModel: questionnaireModel,
documentModel: documentModel,
iomManager: iom,
topicModel: topicModel
}
});
}
## Tools
To build the `CommServer`, `PasswordRecoveryServer` and `GenerateIdentity` tools run
```bash
npm run bundle