Function
Static Public Summary | ||
public |
capable(capabilities: Array<String>): Function Generates a decorator function ensuring that the specified capabilities are available on the server before executing it. |
|
public |
checkVersion(version: String, minVersion: String, maxVersion: String) Checks if a version is within the provided range. |
|
public |
createFormData(dataURL: String, body: Object, options: Object): FormData Creates a FormData instance from a data url and an existing JSON response body. |
|
public |
delay(ms: *): * Returns a Promise always resolving after the specified amount in milliseconds. |
|
public |
extractFileInfo(dataURL: String): Object Extracts file information from a data url. |
|
public |
isObject(thing: Object): bool Returns true if the specified value is an object (i.e. |
|
public |
nobatch(message: String): Function Generates a decorator function ensuring an operation is not performed from within a batch request. |
|
public |
parseDataURL(dataURL: String): Object Parses a data url. |
|
public |
qsify(obj: Object): String Transforms an object into an URL query string, stripping out any undefined values. |
|
public |
support(min: String, max: String): Function Generates a decorator function ensuring a version check is performed against the provided requirements before executing it. |
Static Private Summary | ||
private |
addAttachmentRequest(path: *, dataURI: *, objectPattern2: {"data": *, "permissions": *}, options: {}): {"method": string, "path": *, "headers": *, "body": *} |
|
private |
aggregate(responses: Array, requests: Array): Object Exports batch responses as a result object. |
|
private |
cleanUndefinedProperties(obj: *): * Clones an object with all its undefined keys removed. |
|
private |
createRequest(path: *, objectPattern1: {"data": *, "permissions": *}, options: {}): {"method": *, "path": *, "headers": *, "body": *} |
|
private |
deleteRequest(path: *, options: {}): {"method": string, "path": *, "headers": *} |
|
private |
endpoint(name: String, args: ...string): String Retrieves a server enpoint by its name. |
|
private |
jsonPatchPermissionsRequest(path: *, permissions: *, opType: *, options: {}): {"method": string, "path": *, "headers": *, "body": *} |
|
private |
omit(obj: Object, keys: ...String): Object Takes an object and returns a copy of it with the provided keys omitted. |
|
private |
async pMap(list: Array, fn: Function): Promise Maps a list to promises using the provided mapping function, executes them sequentially then returns a Promise resolving with ordered results obtained. |
|
private |
partition(array: Array, n: Number): Array Chunks an array into n pieces. |
|
private |
safeHeader(safe: *, last_modified: *): {"If-None-Match": string} |
|
private |
toDataBody(resource: Object | String): Object Always returns a resource data object from the provided argument. |
|
private |
updateRequest(path: *, objectPattern1: {"data": *, "permissions": *}, options: {}): {"method": *, "path": *, "headers": *, "body": *} |
Static Public
public capable(capabilities: Array<String>): Function source
import {capable} from 'kinto-http/lib/utils.js'
Generates a decorator function ensuring that the specified capabilities are available on the server before executing it.
Params:
Name | Type | Attribute | Description |
capabilities | Array<String> | The required capabilities. |
Return:
Function |
public checkVersion(version: String, minVersion: String, maxVersion: String) source
import {checkVersion} from 'kinto-http/lib/utils.js'
Checks if a version is within the provided range.
Params:
Name | Type | Attribute | Description |
version | String | The version to check. |
|
minVersion | String | The minimum supported version (inclusive). |
|
maxVersion | String | The minimum supported version (exclusive). |
Throw:
Error |
If the version is outside of the provided range. |
public createFormData(dataURL: String, body: Object, options: Object): FormData source
import {createFormData} from 'kinto-http/lib/utils.js'
Creates a FormData instance from a data url and an existing JSON response body.
Params:
Name | Type | Attribute | Description |
dataURL | String | The data url. |
|
body | Object | The response body. |
|
options | Object |
|
The options object. |
options.filename | Object |
|
Force attachment file name. |
Return:
FormData |
public delay(ms: *): * source
import {delay} from 'kinto-http/lib/utils.js'
Returns a Promise always resolving after the specified amount in milliseconds.
Params:
Name | Type | Attribute | Description |
ms | * |
Return:
* | Promise<void> |
Test:
public extractFileInfo(dataURL: String): Object source
import {extractFileInfo} from 'kinto-http/lib/utils.js'
Extracts file information from a data url.
Params:
Name | Type | Attribute | Description |
dataURL | String | The data url. |
Return:
Object |
public isObject(thing: Object): bool source
import {isObject} from 'kinto-http/lib/utils.js'
Returns true if the specified value is an object (i.e. not an array nor null).
Params:
Name | Type | Attribute | Description |
thing | Object | The value to inspect. |
Return:
bool |
public nobatch(message: String): Function source
import {nobatch} from 'kinto-http/lib/utils.js'
Generates a decorator function ensuring an operation is not performed from within a batch request.
Params:
Name | Type | Attribute | Description |
message | String | The error message to throw. |
Return:
Function |
public parseDataURL(dataURL: String): Object source
import {parseDataURL} from 'kinto-http/lib/utils.js'
Parses a data url.
Params:
Name | Type | Attribute | Description |
dataURL | String | The data url. |
Return:
Object |
public qsify(obj: Object): String source
import {qsify} from 'kinto-http/lib/utils.js'
Transforms an object into an URL query string, stripping out any undefined values.
Params:
Name | Type | Attribute | Description |
obj | Object |
Return:
String |
Test:
public support(min: String, max: String): Function source
import {support} from 'kinto-http/lib/utils.js'
Generates a decorator function ensuring a version check is performed against the provided requirements before executing it.
Params:
Name | Type | Attribute | Description |
min | String | The required min version (inclusive). |
|
max | String | The required max version (inclusive). |
Return:
Function |
Static Private
private addAttachmentRequest(path: *, dataURI: *, objectPattern2: {"data": *, "permissions": *}, options: {}): {"method": string, "path": *, "headers": *, "body": *} source
import {addAttachmentRequest} from 'kinto-http/lib/requests.js'
Params:
Name | Type | Attribute | Description |
path | * | ||
dataURI | * | ||
objectPattern2 | {"data": *, "permissions": *} |
|
|
options | {} |
|
Return:
{"method": string, "path": *, "headers": *, "body": *} |
private aggregate(responses: Array, requests: Array): Object source
import {aggregate} from 'kinto-http/lib/batch.js'
Exports batch responses as a result object.
Params:
Name | Type | Attribute | Description |
responses | Array | The batch subrequest responses. |
|
requests | Array | The initial issued requests. |
Return:
Object |
private cleanUndefinedProperties(obj: *): * source
import {cleanUndefinedProperties} from 'kinto-http/lib/utils.js'
Clones an object with all its undefined keys removed.
Params:
Name | Type | Attribute | Description |
obj | * |
Return:
* |
private createRequest(path: *, objectPattern1: {"data": *, "permissions": *}, options: {}): {"method": *, "path": *, "headers": *, "body": *} source
import {createRequest} from 'kinto-http/lib/requests.js'
Params:
Name | Type | Attribute | Description |
path | * | ||
objectPattern1 | {"data": *, "permissions": *} |
|
|
options | {} |
|
Return:
{"method": *, "path": *, "headers": *, "body": *} |
private deleteRequest(path: *, options: {}): {"method": string, "path": *, "headers": *} source
import {deleteRequest} from 'kinto-http/lib/requests.js'
Params:
Name | Type | Attribute | Description |
path | * | ||
options | {} |
|
Return:
{"method": string, "path": *, "headers": *} |
private endpoint(name: String, args: ...string): String source
import endpoint from 'kinto-http/lib/endpoint.js'
Retrieves a server enpoint by its name.
Params:
Name | Type | Attribute | Description |
name | String | The endpoint name. |
|
args | ...string | The endpoint parameters. |
Return:
String |
Test:
private jsonPatchPermissionsRequest(path: *, permissions: *, opType: *, options: {}): {"method": string, "path": *, "headers": *, "body": *} source
import {jsonPatchPermissionsRequest} from 'kinto-http/lib/requests.js'
Params:
Name | Type | Attribute | Description |
path | * | ||
permissions | * | ||
opType | * | ||
options | {} |
|
Return:
{"method": string, "path": *, "headers": *, "body": *} |
private omit(obj: Object, keys: ...String): Object source
import {omit} from 'kinto-http/lib/utils.js'
Takes an object and returns a copy of it with the provided keys omitted.
Params:
Name | Type | Attribute | Description |
obj | Object | The source object. |
|
keys | ...String | The keys to omit. |
Return:
Object |
Test:
private async pMap(list: Array, fn: Function): Promise source
import {pMap} from 'kinto-http/lib/utils.js'
Maps a list to promises using the provided mapping function, executes them sequentially then returns a Promise resolving with ordered results obtained. Think of this as a sequential Promise.all.
Params:
Name | Type | Attribute | Description |
list | Array | The list to map. |
|
fn | Function | The mapping function. |
Return:
Promise |
Test:
private partition(array: Array, n: Number): Array source
import {partition} from 'kinto-http/lib/utils.js'
Chunks an array into n pieces.
Params:
Name | Type | Attribute | Description |
array | Array | ||
n | Number |
Return:
Array |
Test:
private safeHeader(safe: *, last_modified: *): {"If-None-Match": string} source
Params:
Name | Type | Attribute | Description |
safe | * | ||
last_modified | * |
Return:
{"If-None-Match": string} |
private toDataBody(resource: Object | String): Object source
import {toDataBody} from 'kinto-http/lib/utils.js'
Always returns a resource data object from the provided argument.
Params:
Name | Type | Attribute | Description |
resource | Object | String |
Return:
Object |
private updateRequest(path: *, objectPattern1: {"data": *, "permissions": *}, options: {}): {"method": *, "path": *, "headers": *, "body": *} source
import {updateRequest} from 'kinto-http/lib/requests.js'
Params:
Name | Type | Attribute | Description |
path | * | ||
objectPattern1 | {"data": *, "permissions": *} |
|
|
options | {} |
|
Return:
{"method": *, "path": *, "headers": *, "body": *} |