AbstractBeAdapter
On this page
- title: AbstractBeAdapter
- Classes
- AbstractBeAdapter ⇐
Abstract- AbstractBeAdapter()
- AbstractBeAdapter()
- _buildRestRequest(action, parameters) ⇒
String - _buildRequestId(url, params, config) ⇒
String - _getCommonParameters() ⇒
Promise.<Object> - _getMergedParams(query) ⇒
Promise.<Object> - _getCommonRequestQuery() ⇒
Promise.<Object> - _getCommonRequestData() ⇒
Promise.<Object> - _getXhrHeaders() ⇒
Promise.<Object> - _getXhrConfiguration() ⇒
Promise.<Object> - _head(url, [query], [config]) ⇒
Promise.<object> - _get(url, [query], [config], [force]) ⇒
Promise.<object> - _post(url, [jsonPayload], [config], [query]) ⇒
Promise.<object> - _put(url, [jsonPayload], [config], [query]) ⇒
Promise.<object> - _patch(url, [jsonPayload], [config], [query]) ⇒
Promise.<object> - _delete(url, [query], [config]) ⇒
Promise.<object> - _manageXhrResponse(xhrResponse) ⇒
Promise.<Object> - _manageXhrError(error)
- REQUEST_HEADERS :
Object
- AbstractBeAdapter
- AbstractBeAdapter()
- AbstractBeAdapter()
- _buildRestRequest(action, parameters) ⇒
String - _buildRequestId(url, params, config) ⇒
String - _getCommonParameters() ⇒
Promise.<Object> - _getMergedParams(query) ⇒
Promise.<Object> - _getCommonRequestQuery() ⇒
Promise.<Object> - _getCommonRequestData() ⇒
Promise.<Object> - _getXhrHeaders() ⇒
Promise.<Object> - _getXhrConfiguration() ⇒
Promise.<Object> - _head(url, [query], [config]) ⇒
Promise.<object> - _get(url, [query], [config], [force]) ⇒
Promise.<object> - _post(url, [jsonPayload], [config], [query]) ⇒
Promise.<object> - _put(url, [jsonPayload], [config], [query]) ⇒
Promise.<object> - _patch(url, [jsonPayload], [config], [query]) ⇒
Promise.<object> - _delete(url, [query], [config]) ⇒
Promise.<object> - _manageXhrResponse(xhrResponse) ⇒
Promise.<Object> - _manageXhrError(error)
- REQUEST_HEADERS :
Object
title: AbstractBeAdapter
Classes
- AbstractBeAdapter ⇐
Abstract - AbstractBeAdapter
AbstractBeAdapter ⇐ Abstract
Kind: global abstract class
Extends: Abstract
Singleton:
Properties
| Name | Type | Default | Description |
|---|---|---|---|
| xhrService | XhrService | A reference on the AJAX Xhr manager. | |
| baseUrl | String | Rest server url (only used for _buildRestRequest) | |
| timeout | Number | 5000 | Request timeout |
- AbstractBeAdapter ⇐
Abstract- new AbstractBeAdapter()
- new AbstractBeAdapter()
- instance
- ._buildRestRequest(action, parameters) ⇒
String - ._buildRequestId(url, params, config) ⇒
String - ._getCommonParameters() ⇒
Promise.<Object> - ._getMergedParams(query) ⇒
Promise.<Object> - ._getCommonRequestQuery() ⇒
Promise.<Object> - ._getCommonRequestData() ⇒
Promise.<Object> - ._getXhrHeaders() ⇒
Promise.<Object> - ._getXhrConfiguration() ⇒
Promise.<Object> - ._head(url, [query], [config]) ⇒
Promise.<object> - ._get(url, [query], [config], [force]) ⇒
Promise.<object> - ._post(url, [jsonPayload], [config], [query]) ⇒
Promise.<object> - ._put(url, [jsonPayload], [config], [query]) ⇒
Promise.<object> - ._patch(url, [jsonPayload], [config], [query]) ⇒
Promise.<object> - ._delete(url, [query], [config]) ⇒
Promise.<object> - ._manageXhrResponse(xhrResponse) ⇒
Promise.<Object> - ._manageXhrError(error)
- ._buildRestRequest(action, parameters) ⇒
- static
- .REQUEST_HEADERS :
Object
- .REQUEST_HEADERS :
AbstractBeAdapter()
Abstract class dealing with Back-End transactions as an adapter.
AbstractBeAdapter()
Create clean empty fields inside this adapter at startup.
_buildRestRequest(action, parameters) ⇒ String
create an url with baseUrl+action
action="rest/model/{modelId}"
parameters={modelId: 123}
return "http://baseUrl/rest/model/123"Kind: instance method of AbstractBeAdapter
Returns: String - rest url
Access: protected
| Param | Type | Description |
|---|---|---|
| action | String | Rest api |
| parameters | Object | Rest parameters |
_buildRequestId(url, params, config) ⇒ String
Create an id with url+params
Kind: instance method of AbstractBeAdapter
Returns: String - id
Access: protected
| Param | Type | Description |
|---|---|---|
| url | String | url of request |
| params | Object | parameters of request |
| config | object |
_getCommonParameters() ⇒ Promise.<Object>
Should return a promise with the common query to all GET requests Promise result will be cached through _getMergedParams (this method will only be called once)
Kind: instance method of AbstractBeAdapter
Access: protected
_getMergedParams(query) ⇒ Promise.<Object>
Merge on-call query with common query (retrieved from _getCommonParameters). This function also cache common query result.
Kind: instance method of AbstractBeAdapter
Access: protected
| Param | Type | Description |
|---|---|---|
| query | Object | on-call query |
_getCommonRequestQuery() ⇒ Promise.<Object>
Should return a promise with the common query (applied as query string for HEAD/GET/PATCH/PUT/POST/DELETE) Promise result wont be cached unlike the one in _getCommonParameters
Kind: instance method of AbstractBeAdapter
Access: protected
_getCommonRequestData() ⇒ Promise.<Object>
Should return a promise with the common “data” (applied as query string for HEAD/GETs or request payload for PATCH/PUT/POST/DELETE) Promise result wont be cached unlike the one in _getCommonParameters
Kind: instance method of AbstractBeAdapter
Access: protected
_getXhrHeaders() ⇒ Promise.<Object>
Return xhr headers, by default a copy of static REQUEST_HEADERS
Kind: instance method of AbstractBeAdapter
Access: protected
_getXhrConfiguration() ⇒ Promise.<Object>
Generate Xhr configuration with headers
Kind: instance method of AbstractBeAdapter
Access: protected
_head(url, [query], [config]) ⇒ Promise.<object>
Make a HEAD request to the specified URL
Kind: instance method of AbstractBeAdapter
Returns: Promise.<object> - The promise resolves with an object similar to the XHR object, or rejects with an error object.
See: AbstractXhrService#head
Will invoke _getCommonRequestQuery, _getCommonRequestData and _getXhrConfiguration. Might invoke _manageXhrResponse or _manageXhrError or both (in case first one returns a rejected promise)
| Param | Type | Description |
|---|---|---|
| url | string | Request URL (w/o fragment nor query if query arg is defined) |
| [query] | object | Request URL query (as an object) |
| [config] | object | Request extra XHR config |
_get(url, [query], [config], [force]) ⇒ Promise.<object>
Make a (optionally debounced) GET request to the specified URL
Kind: instance method of AbstractBeAdapter
Returns: Promise.<object> - The promise resolves with an object similar to the XHR object, or rejects with an error object.
See: AbstractXhrService#get
Will invoke _getMergedParams, _getCommonRequestQuery, _getCommonRequestData and _getXhrConfiguration Might invoke _manageXhrResponse or _manageXhrError or both (in case first one returns a rejected promise)
| Param | Type | Default | Description |
|---|---|---|---|
| url | string | Request URL (w/o fragment nor query if query arg is defined) | |
| [query] | object | Request URL query (as an object) | |
| [config] | object | Request extra XHR config | |
| [force] | boolean | false | If true, will execute the request outside of debouncing |
_post(url, [jsonPayload], [config], [query]) ⇒ Promise.<object>
Make a POST request to the specified URL
Kind: instance method of AbstractBeAdapter
Returns: Promise.<object> - The promise resolves with an object similar to the XHR object, or rejects with an error object.
See: AbstractXhrService#post
Will invoke _getCommonRequestQuery, _getCommonRequestData and _getXhrConfiguration. Might invoke _manageXhrResponse or _manageXhrError or both (in case first one returns a rejected promise)
| Param | Type | Description |
|---|---|---|
| url | string | Request URL (w/o fragment nor query if query arg is defined) |
| [jsonPayload] | * | Payload to send as application/json |
| [config] | object | Request extra XHR config |
| [query] | object | Request URL query (as an object) |
_put(url, [jsonPayload], [config], [query]) ⇒ Promise.<object>
Make a PUT request to the specified URL
Kind: instance method of AbstractBeAdapter
Returns: Promise.<object> - The promise resolves with an object similar to the XHR object, or rejects with an error object.
See: AbstractXhrService#put
Will invoke _getCommonRequestQuery, _getCommonRequestData and _getXhrConfiguration. Might invoke _manageXhrResponse or _manageXhrError or both (in case first one returns a rejected promise)
| Param | Type | Description |
|---|---|---|
| url | string | Request URL (w/o fragment nor query if query arg is defined) |
| [jsonPayload] | * | Payload to send as application/json |
| [config] | object | Request extra XHR config |
| [query] | object | Request URL query (as an object) |
_patch(url, [jsonPayload], [config], [query]) ⇒ Promise.<object>
Make a PATCH request to the specified URL
Kind: instance method of AbstractBeAdapter
Returns: Promise.<object> - The promise resolves with an object similar to the XHR object, or rejects with an error object.
See: AbstractXhrService#patch
Will invoke _getCommonRequestQuery, _getCommonRequestData and _getXhrConfiguration. Might invoke _manageXhrResponse or _manageXhrError or both (in case first one returns a rejected promise)
| Param | Type | Description |
|---|---|---|
| url | string | Request URL (w/o fragment nor query if query arg is defined) |
| [jsonPayload] | * | Payload to send as application/json |
| [config] | object | Request extra XHR config |
| [query] | object | Request URL query (as an object) |
_delete(url, [query], [config]) ⇒ Promise.<object>
Make a DELETE request to the specified URL
Kind: instance method of AbstractBeAdapter
Returns: Promise.<object> - The promise resolves with an object similar to the XHR object, or rejects with an error object.
See: AbstractXhrService#del
Will invoke _getCommonRequestQuery, _getCommonRequestData
and _getXhrConfiguration.
Might invoke _manageXhrResponse or _manageXhrError or
both (in case first one returns a rejected promise)
Todo
- Add the jsonPayload parameter. In the meanwhile, you can set config to
{json: [jsonPayload]}}.
| Param | Type | Description |
|---|---|---|
| url | string | Request URL (w/o fragment nor query if query arg is defined) |
| [query] | object | Request URL query (as an object) |
| [config] | object | Request extra XHR config |
_manageXhrResponse(xhrResponse) ⇒ Promise.<Object>
Method dealing by default with the current XHR request response.
Kind: instance method of AbstractBeAdapter
Returns: Promise.<Object> - A promise properly handling previous XHR response
Access: protected
| Param | Type | Description |
|---|---|---|
| xhrResponse | Object | Needed AJAX Xhr response |
_manageXhrError(error)
Method dealing by default with current XHR error response.
Kind: instance method of AbstractBeAdapter
Access: protected
| Param | Type | Description |
|---|---|---|
| error | string | Needed AJAX Xhr error field |
REQUEST_HEADERS : Object
Request Headers
Kind: static property of AbstractBeAdapter
AbstractBeAdapter
Kind: global class
- AbstractBeAdapter
- new AbstractBeAdapter()
- new AbstractBeAdapter()
- instance
- ._buildRestRequest(action, parameters) ⇒
String - ._buildRequestId(url, params, config) ⇒
String - ._getCommonParameters() ⇒
Promise.<Object> - ._getMergedParams(query) ⇒
Promise.<Object> - ._getCommonRequestQuery() ⇒
Promise.<Object> - ._getCommonRequestData() ⇒
Promise.<Object> - ._getXhrHeaders() ⇒
Promise.<Object> - ._getXhrConfiguration() ⇒
Promise.<Object> - ._head(url, [query], [config]) ⇒
Promise.<object> - ._get(url, [query], [config], [force]) ⇒
Promise.<object> - ._post(url, [jsonPayload], [config], [query]) ⇒
Promise.<object> - ._put(url, [jsonPayload], [config], [query]) ⇒
Promise.<object> - ._patch(url, [jsonPayload], [config], [query]) ⇒
Promise.<object> - ._delete(url, [query], [config]) ⇒
Promise.<object> - ._manageXhrResponse(xhrResponse) ⇒
Promise.<Object> - ._manageXhrError(error)
- ._buildRestRequest(action, parameters) ⇒
- static
- .REQUEST_HEADERS :
Object
- .REQUEST_HEADERS :
AbstractBeAdapter()
Abstract class dealing with Back-End transactions as an adapter.
AbstractBeAdapter()
Create clean empty fields inside this adapter at startup.
_buildRestRequest(action, parameters) ⇒ String
create an url with baseUrl+action
action="rest/model/{modelId}"
parameters={modelId: 123}
return "http://baseUrl/rest/model/123"Kind: instance method of AbstractBeAdapter
Returns: String - rest url
Access: protected
| Param | Type | Description |
|---|---|---|
| action | String | Rest api |
| parameters | Object | Rest parameters |
_buildRequestId(url, params, config) ⇒ String
Create an id with url+params
Kind: instance method of AbstractBeAdapter
Returns: String - id
Access: protected
| Param | Type | Description |
|---|---|---|
| url | String | url of request |
| params | Object | parameters of request |
| config | object |
_getCommonParameters() ⇒ Promise.<Object>
Should return a promise with the common query to all GET requests Promise result will be cached through _getMergedParams (this method will only be called once)
Kind: instance method of AbstractBeAdapter
Access: protected
_getMergedParams(query) ⇒ Promise.<Object>
Merge on-call query with common query (retrieved from _getCommonParameters). This function also cache common query result.
Kind: instance method of AbstractBeAdapter
Access: protected
| Param | Type | Description |
|---|---|---|
| query | Object | on-call query |
_getCommonRequestQuery() ⇒ Promise.<Object>
Should return a promise with the common query (applied as query string for HEAD/GET/PATCH/PUT/POST/DELETE) Promise result wont be cached unlike the one in _getCommonParameters
Kind: instance method of AbstractBeAdapter
Access: protected
_getCommonRequestData() ⇒ Promise.<Object>
Should return a promise with the common “data” (applied as query string for HEAD/GETs or request payload for PATCH/PUT/POST/DELETE) Promise result wont be cached unlike the one in _getCommonParameters
Kind: instance method of AbstractBeAdapter
Access: protected
_getXhrHeaders() ⇒ Promise.<Object>
Return xhr headers, by default a copy of static REQUEST_HEADERS
Kind: instance method of AbstractBeAdapter
Access: protected
_getXhrConfiguration() ⇒ Promise.<Object>
Generate Xhr configuration with headers
Kind: instance method of AbstractBeAdapter
Access: protected
_head(url, [query], [config]) ⇒ Promise.<object>
Make a HEAD request to the specified URL
Kind: instance method of AbstractBeAdapter
Returns: Promise.<object> - The promise resolves with an object similar to the XHR object, or rejects with an error object.
See: AbstractXhrService#head
Will invoke _getCommonRequestQuery, _getCommonRequestData and _getXhrConfiguration. Might invoke _manageXhrResponse or _manageXhrError or both (in case first one returns a rejected promise)
| Param | Type | Description |
|---|---|---|
| url | string | Request URL (w/o fragment nor query if query arg is defined) |
| [query] | object | Request URL query (as an object) |
| [config] | object | Request extra XHR config |
_get(url, [query], [config], [force]) ⇒ Promise.<object>
Make a (optionally debounced) GET request to the specified URL
Kind: instance method of AbstractBeAdapter
Returns: Promise.<object> - The promise resolves with an object similar to the XHR object, or rejects with an error object.
See: AbstractXhrService#get
Will invoke _getMergedParams, _getCommonRequestQuery, _getCommonRequestData and _getXhrConfiguration Might invoke _manageXhrResponse or _manageXhrError or both (in case first one returns a rejected promise)
| Param | Type | Default | Description |
|---|---|---|---|
| url | string | Request URL (w/o fragment nor query if query arg is defined) | |
| [query] | object | Request URL query (as an object) | |
| [config] | object | Request extra XHR config | |
| [force] | boolean | false | If true, will execute the request outside of debouncing |
_post(url, [jsonPayload], [config], [query]) ⇒ Promise.<object>
Make a POST request to the specified URL
Kind: instance method of AbstractBeAdapter
Returns: Promise.<object> - The promise resolves with an object similar to the XHR object, or rejects with an error object.
See: AbstractXhrService#post
Will invoke _getCommonRequestQuery, _getCommonRequestData and _getXhrConfiguration. Might invoke _manageXhrResponse or _manageXhrError or both (in case first one returns a rejected promise)
| Param | Type | Description |
|---|---|---|
| url | string | Request URL (w/o fragment nor query if query arg is defined) |
| [jsonPayload] | * | Payload to send as application/json |
| [config] | object | Request extra XHR config |
| [query] | object | Request URL query (as an object) |
_put(url, [jsonPayload], [config], [query]) ⇒ Promise.<object>
Make a PUT request to the specified URL
Kind: instance method of AbstractBeAdapter
Returns: Promise.<object> - The promise resolves with an object similar to the XHR object, or rejects with an error object.
See: AbstractXhrService#put
Will invoke _getCommonRequestQuery, _getCommonRequestData and _getXhrConfiguration. Might invoke _manageXhrResponse or _manageXhrError or both (in case first one returns a rejected promise)
| Param | Type | Description |
|---|---|---|
| url | string | Request URL (w/o fragment nor query if query arg is defined) |
| [jsonPayload] | * | Payload to send as application/json |
| [config] | object | Request extra XHR config |
| [query] | object | Request URL query (as an object) |
_patch(url, [jsonPayload], [config], [query]) ⇒ Promise.<object>
Make a PATCH request to the specified URL
Kind: instance method of AbstractBeAdapter
Returns: Promise.<object> - The promise resolves with an object similar to the XHR object, or rejects with an error object.
See: AbstractXhrService#patch
Will invoke _getCommonRequestQuery, _getCommonRequestData and _getXhrConfiguration. Might invoke _manageXhrResponse or _manageXhrError or both (in case first one returns a rejected promise)
| Param | Type | Description |
|---|---|---|
| url | string | Request URL (w/o fragment nor query if query arg is defined) |
| [jsonPayload] | * | Payload to send as application/json |
| [config] | object | Request extra XHR config |
| [query] | object | Request URL query (as an object) |
_delete(url, [query], [config]) ⇒ Promise.<object>
Make a DELETE request to the specified URL
Kind: instance method of AbstractBeAdapter
Returns: Promise.<object> - The promise resolves with an object similar to the XHR object, or rejects with an error object.
See: AbstractXhrService#del
Will invoke _getCommonRequestQuery, _getCommonRequestData
and _getXhrConfiguration.
Might invoke _manageXhrResponse or _manageXhrError or
both (in case first one returns a rejected promise)
Todo
- Add the jsonPayload parameter. In the meanwhile, you can set config to
{json: [jsonPayload]}}.
| Param | Type | Description |
|---|---|---|
| url | string | Request URL (w/o fragment nor query if query arg is defined) |
| [query] | object | Request URL query (as an object) |
| [config] | object | Request extra XHR config |
_manageXhrResponse(xhrResponse) ⇒ Promise.<Object>
Method dealing by default with the current XHR request response.
Kind: instance method of AbstractBeAdapter
Returns: Promise.<Object> - A promise properly handling previous XHR response
Access: protected
| Param | Type | Description |
|---|---|---|
| xhrResponse | Object | Needed AJAX Xhr response |
_manageXhrError(error)
Method dealing by default with current XHR error response.
Kind: instance method of AbstractBeAdapter
Access: protected
| Param | Type | Description |
|---|---|---|
| error | string | Needed AJAX Xhr error field |
REQUEST_HEADERS : Object
Request Headers
Kind: static property of AbstractBeAdapter