elarian
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -94,3 +94,2 @@ ## Classes | ||
* [.generateAuthToken()](#Elarian+generateAuthToken) ⇒ <code>AuthToken</code> | ||
* [.createHuman(id)](#Elarian+createHuman) ⇒ <code>Reply</code> | ||
* [.addReminder(id, reminder)](#Elarian+addReminder) ⇒ <code>Reply</code> | ||
@@ -129,13 +128,2 @@ * [.addGroupReminder(group, reminder)](#Elarian+addGroupReminder) ⇒ <code>Reply</code> | ||
**Kind**: instance method of [<code>Elarian</code>](#Elarian) | ||
<a name="Elarian+createHuman"></a> | ||
### elarian.createHuman(id) ⇒ <code>Reply</code> | ||
<p>Create a human</p> | ||
**Kind**: instance method of [<code>Elarian</code>](#Elarian) | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| id | <code>string</code> | <p>human id</p> | | ||
<a name="Elarian+addReminder"></a> | ||
@@ -142,0 +130,0 @@ |
@@ -19,4 +19,2 @@ const Client = require('./client'); | ||
CreateHumanCommand, | ||
AddReminderCommand, | ||
@@ -59,45 +57,2 @@ AddGroupReminderCommand, | ||
/** | ||
* Create a human | ||
* @param {string} id human id | ||
* @returns {Reply} | ||
* @memberof Elarian | ||
*/ | ||
Elarian.prototype.createHuman = function createHuman(id) { | ||
const socket = this.getSocket(); | ||
if (!id) { | ||
throw new Error('An id is required'); | ||
} | ||
let cmd = new CreateHumanCommand(); | ||
cmd = cmd.setHumanId(id); | ||
const req = new AppToServerCommand() | ||
.setCreateHuman(cmd); | ||
return new Promise((resolve, reject) => { | ||
socket | ||
.requestResponse({ | ||
data: Buffer.from(req.serializeBinary()), | ||
}) | ||
.subscribe({ | ||
onComplete: (value) => { | ||
try { | ||
const res = AppToServerCommandReply | ||
.deserializeBinary(value.data) | ||
.getUpdateState(); | ||
const result = { | ||
status: res.getStatus(), | ||
description: res.getDescription(), | ||
}; | ||
resolve(result); | ||
} catch (ex) { | ||
reject(ex); | ||
} | ||
}, | ||
onError: (error) => reject(error), | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Add a reminder | ||
@@ -544,6 +499,15 @@ * @param {string} id human id | ||
.getLeaseAppState(); | ||
let state = res.getState(); | ||
if (state) { | ||
state = { | ||
stringVal: state.getStringVal(), | ||
bytesVal: state.getBytesVal(), | ||
}; | ||
} | ||
const result = { | ||
state, | ||
status: res.getStatus(), | ||
description: res.getDescription(), | ||
state: res.getState(), | ||
}; | ||
@@ -550,0 +514,0 @@ resolve(result); |
{ | ||
"name": "elarian", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Elarian JavaScript SDK", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -39,12 +39,10 @@ # Elarian | ||
const humanId = 'abc'; | ||
const data = await elarian.leaseAppData(humanId); | ||
await elarian.updateAppData(humanId, { ...data, status: 'good boy' }); | ||
await elarian.updateMetadata(humanId, { name: 'alice', age: 25 }); | ||
const { name } = await elarian.getMetadata(humanId); | ||
const userId = 'abc...'; | ||
const { state } = await elarian.leaseAppState(userId); | ||
const data = JSON.parse(state.stringVal); | ||
await elarian.updateAppState(userId, { stringVal: JSON.stringify({ ...data, status: 'good boy' }) }); | ||
await elarian.updateMetadata(userId, { bio: { bytesVal: Buffer.from('age=29;gender=female') }}); | ||
``` | ||
See [example](example/) for a full sample app. | ||
## Documentation | ||
@@ -78,2 +76,3 @@ | ||
- Missing method to lease/get/fetch user metadata | ||
- `resumable` connection options prevents app from connecting |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
3610178
15654
77