Rename storage app index functions to getAppIndexFile and putAppIndexFile. #312 #313

This commit is contained in:
Ken
2017-12-17 20:34:31 -05:00
parent 7e97ad6c2b
commit 6ce7ae38a2
5 changed files with 284 additions and 22 deletions

16
dist/blockstack.js vendored
View File

@@ -3560,7 +3560,8 @@ Object.defineProperty(exports, "__esModule", {
exports.GaiaHubConfig = exports.BLOCKSTACK_GAIA_HUB_LABEL = exports.uploadToGaiaHub = exports.connectToGaiaHub = undefined;
exports.getFile = getFile;
exports.putFile = putFile;
exports.putIndexFile = putIndexFile;
exports.getAppIndexFile = getAppIndexFile;
exports.putAppIndexFile = putAppIndexFile;
exports.deleteFile = deleteFile;
var _hub = require('./hub');
@@ -3636,6 +3637,16 @@ function putFile(path, content) {
});
}
/**
* Retrieves the app index file from the app's data store.
* @returns {Promise} that resolves to the raw data in the file
* or rejects with an error
*/
function getAppIndexFile() {
return this.getFile(_hub.APP_INDEX_FILE_NAME);
}
/**
* Stores the app index file which enables multi-reader storage. This file
* will be written to the user's profile and publicly visible if the `appIndex`
@@ -3644,8 +3655,7 @@ function putFile(path, content) {
* @return {Promise} that resolves if the operation succeed and rejects
* if it failed
*/
function putIndexFile(content) {
var filename = _hub.APP_INDEX_FILE_NAME;
function putAppIndexFile(content) {
return this.putFile(_hub.APP_INDEX_FILE_NAME, content, false);
}

198
docs.json
View File

@@ -6397,6 +6397,182 @@
],
"namespace": "putFile"
},
{
"description": {
"type": "root",
"children": [
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "Retrieves the app index file from the app's data store.",
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 1,
"column": 56,
"offset": 55
},
"indent": []
}
}
],
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 1,
"column": 56,
"offset": 55
},
"indent": []
}
}
],
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 1,
"column": 56,
"offset": 55
}
}
},
"tags": [
{
"title": "returns",
"description": "that resolves to the raw data in the file\nor rejects with an error",
"lineNumber": 2,
"type": {
"type": "NameExpression",
"name": "Promise"
}
}
],
"loc": {
"start": {
"line": 74,
"column": 0
},
"end": {
"line": 78,
"column": 3
}
},
"context": {
"loc": {
"start": {
"line": 80,
"column": 0
},
"end": {
"line": 83,
"column": 1
}
},
"file": "/Users/Yukan/Desktop/work/blockstack/blockstack.js/src/storage/index.js"
},
"augments": [],
"examples": [],
"params": [],
"properties": [],
"returns": [
{
"description": {
"type": "root",
"children": [
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "that resolves to the raw data in the file\nor rejects with an error",
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 2,
"column": 25,
"offset": 66
},
"indent": [
1
]
}
}
],
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 2,
"column": 25,
"offset": 66
},
"indent": [
1
]
}
}
],
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 2,
"column": 25,
"offset": 66
}
}
},
"title": "returns",
"type": {
"type": "NameExpression",
"name": "Promise"
}
}
],
"sees": [],
"throws": [],
"todos": [],
"name": "getAppIndexFile",
"kind": "function",
"members": {
"global": [],
"inner": [],
"instance": [],
"events": [],
"static": []
},
"path": [
{
"name": "getAppIndexFile",
"kind": "function"
}
],
"namespace": "getAppIndexFile"
},
{
"description": {
"type": "root",
@@ -6523,22 +6699,22 @@
],
"loc": {
"start": {
"line": 74,
"line": 85,
"column": 0
},
"end": {
"line": 81,
"line": 92,
"column": 3
}
},
"context": {
"loc": {
"start": {
"line": 82,
"line": 93,
"column": 0
},
"end": {
"line": 85,
"line": 96,
"column": 1
}
},
@@ -6687,7 +6863,7 @@
"sees": [],
"throws": [],
"todos": [],
"name": "putIndexFile",
"name": "putAppIndexFile",
"kind": "function",
"members": {
"global": [],
@@ -6698,11 +6874,11 @@
},
"path": [
{
"name": "putIndexFile",
"name": "putAppIndexFile",
"kind": "function"
}
],
"namespace": "putIndexFile"
"namespace": "putAppIndexFile"
},
{
"description": {
@@ -7622,22 +7798,22 @@
],
"loc": {
"start": {
"line": 87,
"line": 98,
"column": 0
},
"end": {
"line": 92,
"line": 103,
"column": 3
}
},
"context": {
"loc": {
"start": {
"line": 93,
"line": 104,
"column": 0
},
"end": {
"line": 95,
"line": 106,
"column": 1
}
},

View File

@@ -215,9 +215,19 @@
<li><a
href='#putindexfile'
href='#getappindexfile'
class="">
putIndexFile
getAppIndexFile
</a>
</li>
<li><a
href='#putappindexfile'
class="">
putAppIndexFile
</a>
@@ -1654,8 +1664,64 @@ if it failed
<div class='clearfix'>
<h3 class='fl m0' id='putindexfile'>
putIndexFile
<h3 class='fl m0' id='getappindexfile'>
getAppIndexFile
</h3>
</div>
<p>Retrieves the app index file from the app's data store.</p>
<div class='pre p1 fill-light mt0'>getAppIndexFile(): <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>:
that resolves to the raw data in the file
or rejects with an error
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='putappindexfile'>
putAppIndexFile
</h3>
@@ -1667,7 +1733,7 @@ will be written to the user's profile and publicly visible if the <code>appIndex
scope was requested during authentication.</p>
<div class='pre p1 fill-light mt0'>putIndexFile(content: (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">String</a> | <a href="https://nodejs.org/api/buffer.html">Buffer</a>)): <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></div>
<div class='pre p1 fill-light mt0'>putAppIndexFile(content: (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">String</a> | <a href="https://nodejs.org/api/buffer.html">Buffer</a>)): <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></div>

View File

@@ -37,4 +37,5 @@ toc:
[Read more about storage](https://github.com/blockstack/blockstack.js/blob/master/src/storage/README.md)
- getFile
- putFile
- putIndexFile
- getAppIndexFile
- putAppIndexFile

View File

@@ -71,6 +71,16 @@ export function putFile(path: string, content: string | Buffer, encrypt: boolean
.then((gaiaHubConfig) => uploadToGaiaHub(path, content, gaiaHubConfig, contentType))
}
/**
* Retrieves the app index file from the app's data store.
* @returns {Promise} that resolves to the raw data in the file
* or rejects with an error
*/
export function getAppIndexFile() {
return this.getFile(APP_INDEX_FILE_NAME)
}
/**
* Stores the app index file which enables multi-reader storage. This file
* will be written to the user's profile and publicly visible if the `appIndex`
@@ -79,8 +89,7 @@ export function putFile(path: string, content: string | Buffer, encrypt: boolean
* @return {Promise} that resolves if the operation succeed and rejects
* if it failed
*/
export function putIndexFile(content: string | Buffer) {
const filename = APP_INDEX_FILE_NAME
export function putAppIndexFile(content: string | Buffer) {
return this.putFile(APP_INDEX_FILE_NAME, content, false)
}