Base Services
Wakanda-Client is built on a n-tier architecture:
- Presentation: what is exposed to the developer who uses Wakanda-Client
- Business: the logic of Wakanda-Client
- Data access: handle the communication with Wakanda Server REST API
The DataAccess layer, in our case, is split into two parts. Services, which are used by the business layer, and Base Services, which are used by services.
The point of this separation is because Services carry little information on their instances, like "This collection is an entity set, so some details are to be handle while talking to the REST API".
But, we want to be able to use services outside of Wakanda-Client (without this extra information), so that we can have the benefit of the communication with REST API handled, without having to use the whole ORM.
That's why Base Services exists, they're basically static classes, with static methods. It's a raw wrapper to the REST API. No less, no more.
Base services are on src/data-access/service/base
directory. All methods return a Promise.
Retrieve a Catalog with all the dataClasses, or only the one given in parameter.
-
httpClient
: instance ofHttpClient
, usually got onWakandaClient
instance (for examplewakandaClient._httpClient
) -
dataClasses
: (optional) string or string array representing the name of the dataClasses to retrieve
Find an entity of the dataClass with the given key and options.
-
httpClient
: instance ofHttpClient
, usually got onWakandaClient
instance (for examplewakandaClient._httpClient
) -
key
: entity key -
options
: Object that contains options to filter the request (attribute expanding, ordering, filtering, etc.) -
dataClassName
: name of the dataClass on which the query will be performed
Find multiple entities according to options on the given dataClass.
-
httpClient
: instance ofHttpClient
, usually got onWakandaClient
instance (for examplewakandaClient._httpClient
) -
options
: Object that contains options to filter the request (attribute expanding, ordering, filtering, etc.) -
dataClassName
: name of the dataClass on which the query will be performed
Call a method defined on a dataClass
-
httpClient
: instance ofHttpClient
, usually got onWakandaClient
instance (for examplewakandaClient._httpClient
) -
methodName
: name of the method -
parameters
: array (may be empty) of parameters to pass to the method -
options
: Object that contains options to filter the request (attribute expanding, ordering, filtering, etc.) -
dataClassName
: name of the dataClass on which the query will be performed
Perform a save of the given entity on data
parameter. If a key and a stamp are provided, it will perform an update. Either way, a new entity will be created.
-
httpClient
: instance ofHttpClient
, usually got onWakandaClient
instance (for examplewakandaClient._httpClient
) -
data
: object containing properties of the entity to save (including key and stamp if needed) -
expand
: (optional) string of the attributes to expand when the server returns the entity after save -
dataClassName
: name of the dataClass on which the query will be performed
Execute server-side logic by simulating a save of the entity. The entity will be modified the following way:
- Calculated attributes are filled
-
init
event is triggered if recompute is called on a new entity (eg. that has never been saved yet) -
clientrefresh
event is triggered
The entity is not saved, and all server-side computation that occured won't be persisted.
-
httpClient
: instance ofHttpClient
, usually got onWakandaClient
instance (for examplewakandaClient._httpClient
) -
data
: object containing properties of the entity to save (including key and stamp if needed) -
dataClassName
: name of the dataClass on which the query will be performed
Call a method defined on the entity
-
httpClient
: instance ofHttpClient
, usually got onWakandaClient
instance (for examplewakandaClient._httpClient
) -
methodName
: name of the method -
parameters
: array (may be empty) of parameters to pass to the method -
entityKey
: key of the entity on which the method is called -
dataClassName
: name of the dataClass on which the query will be performed
Delete the entity.
-
httpClient
: instance ofHttpClient
, usually got onWakandaClient
instance (for examplewakandaClient._httpClient
) -
entityKey
: key of the entity on which the method is called -
dataClassName
: name of the dataClass on which the query will be performed
Fetch a collection with given options.
-
httpClient
: instance ofHttpClient
, usually got onWakandaClient
instance (for examplewakandaClient._httpClient
) -
collectionUri
: URI of the collection previously returned by REST API when retrieving it (or the entity owning it) for the first time -
isEntitySet
: boolean indicating if thecollectionUri
is an EntitySet URI or not -
options
: Object that contains options to filter the request (attribute expanding, ordering, filtering, etc.)
Call a method defined on the collection.
-
httpClient
: instance ofHttpClient
, usually got onWakandaClient
instance (for examplewakandaClient._httpClient
) -
collectionUri
: URI of the collection previously returned by REST API when retrieving it (or the entity owning it) for the first time -
isEntitySet
: boolean indicating if thecollectionUri
is an EntitySet URI or not -
methodName
: name of the method -
parameters
: array (may be empty) of parameters to pass to the method
Upload a file to an entity blob
or image
attribute.
-
httpClient
: instance ofHttpClient
, usually got onWakandaClient
instance (for examplewakandaClient._httpClient
) -
dataClassName
: name of the dataClass on which the query will be performed -
entityKey
: key of the entity to upload the file to -
attributeName
: name of the file attribute to upload the file to -
file
: file to upload -
isImage
: boolean indicating if the filed to upload the file to is of typeimage
Delete the existing file of blob
or image
attribute.
-
httpClient
: instance ofHttpClient
, usually got onWakandaClient
instance (for examplewakandaClient._httpClient
) -
dataClassName
: name of the dataClass on which the query will be performed -
entityKey
: key of the entity to remove the file from -
entityStamp
: stamp of the entity -
attributeName
: name of the file attribute to remove the file from
Login with given credentials.
-
httpClient
: instance ofHttpClient
, usually got onWakandaClient
instance (for examplewakandaClient._httpClient
) -
username
: Username -
password
: Password -
duration
: Duration (in seconds) of the session
Logout from Wakanda Server.
-
httpClient
: instance ofHttpClient
, usually got onWakandaClient
instance (for examplewakandaClient._httpClient
)
Get the current user if any.
-
httpClient
: instance ofHttpClient
, usually got onWakandaClient
instance (for examplewakandaClient._httpClient
)
Check if the current user belongs to the given group.
-
httpClient
: instance ofHttpClient
, usually got onWakandaClient
instance (for examplewakandaClient._httpClient
) -
group
: name of the group to check