API to work with resources.
Methods
-
<static> add(resource)
-
Add data about a resource into the list of available resources.
Parameters:
Name Type Description resource
Object Represents data about a resource that should be added. Object should contain the following fields (name - type - description): name
-String
- resource name (required)description
-String
- resource descriptionurl
-String
- URL of resource's sitetag
-Array of String
- tags/keywords of resourcenote
-String
- additional information about resource usagemodule
-String
- path to the module that should be used to work with resource; the module should implement necessary APIapi
-Object
- object that implements necessary API to work with resource
name
. Alsomodule
orapi
field should be specified.- See:
Throws:
-
Will throw an error if resource name is not specified.
-
Will throw an error if resource API object and path to resource module are not specified.
-
Will throw an error if there is a resource with the same name.
Returns:
Object that represents moduleexports
.- Type
- Object
-
<static> checkResourceTags(resource, tagList [, checkAllTags])
-
Check resource on presence or absence of specified tags.
Parameters:
Name Type Argument Description resource
Object Represents data about a resource that should be checked. tagList
Array List of tags (in lower case) that should be checked on presence or absence in resource tags. Tag in form "name" (without quotes; a positive tag) means that resource should be checked on presence of "name" tag. Tag in form "-name" (without quotes; a negative tag) means that resource should be checked on absence of "name" tag. checkAllTags
Boolean <optional>
Whether all tags specified in tagList
should be checked on presence/absence in resource tags. When parameter hastrue
value it means that resource should have all positive tags and should not have any negative tag. When parameter hasfalse
value (by default) it means that resource should have one of positive tags and should not have one of negative tags.Returns:
true
if resource tags satisfy to specified tags (depending oncheckAllTags
value),false
otherwise.- Type
- Boolean
-
<static> filterList( [settings])
-
Apply filter on list of currently available resources.
After operation only resources conforming to filter will be available.
In essence, this method is a wrapper for the following code:
setList( getList(settings) )
Parameters:
Name Type Argument Description settings
Object <optional>
Specifies which resources should be selected. The following settings can be used to select resources: selectName, selectTag, checkAllTags
. See getList for details.Returns:
Object that represents moduleexports
.- Type
- Object
-
<static> getAllNameList()
-
Return list that contains names of all available resources.
- See:
Returns:
List that contains names of all available resources.- Type
- Array
-
<static> getIdByName(name)
-
Return identifier of resource with given name.
Parameters:
Name Type Description name
String A resource name (case-insensitive). Returns:
Identifier of resource that has the given name ornull
if no one of available resources has the specified name.- Type
- String | null
-
<static> getList( [settings])
-
Return list of specified resources. If no selection criteria is set then returns list of all available resources.
Parameters:
Name Type Argument Description settings
Object <optional>
Specifies which data items should be returned. The following settings are supported (name - type - description): includeApi
-Boolean
- whether API object for resource should be included into data item underapi
field;false
by defaultselectName
-Array | String
- specifies filter for available resources by name; list of names of resources or name of resource (case-insensitive) that should be included into resultselectTag
-Array | String
- specifies filter for available resources by tag; list of tags or tag (case-insensitive) that should be used to select resources into result; resources that satisfy to specified tags (depending oncheckAllTags
setting) will be included in result; see checkResourceTags for detailscheckAllTags
-Boolean
- whether all tags specified inselectTag
should be checked; see checkResourceTags for details
selectName
) and filter by tag (selectTag
) can be used separately or together. If no filter is specified, all resources will be included into result.- See:
Returns:
List that contains objects presenting data about selected resources.- Type
- Array
-
<static> getMap( [settings])
-
Return object that represents specified resources. If no selection criteria is set then returns object that contains data about all available resources.
Parameters:
Name Type Argument Description settings
Object <optional>
Specifies which data items should be returned. See getList for details. - See:
Returns:
Object that contains data about selected resources. Fields are resource keys, values are objects representing data about resources.- Type
- Object
-
<static> getNameList( [settings])
-
Return list that contains names of selected resources.
If no selection criteria is set then returns list of names of all available resources.Parameters:
Name Type Argument Description settings
Object <optional>
Specifies selection criteria. The following settings can be used to select resources: selectName, selectTag, checkAllTags
. See getList for details.- See:
Returns:
List that contains names of selected resources.- Type
- Array
-
<static> initList(list)
-
Set initial list of all available resources.
This list is used to reset to initial state.Parameters:
Name Type Description list
Array | Object List that contains objects presenting data about resources, or object with data about an resource. Returns:
Object that represents moduleexports
.- Type
- Object
-
<static> isAvailable(name)
-
Check whether there is a resource with given name.
Parameters:
Name Type Description name
String A name that should be checked (case-insensitive). Returns:
true
if there is a resource with the given name,false
if no one of available resources has the specified name.- Type
- Boolean
-
<static> remove(name)
-
Remove resource with given name from list of resources.
Parameters:
Name Type Description name
String Name of resource that should be removed (case-insensitive). Returns:
Object that represents removed resource ornull
if no one of resources from list has the specified name.- Type
- Object | null
-
<static> removeAll()
-
Clear list of resources.
- See:
Returns:
Object that represents moduleexports
.- Type
- Object
-
<static> resetList()
-
Set list of resources to initial state containing data about all available resources.
- See:
Returns:
Object that represents moduleexports
.- Type
- Object
-
<static> setList(list)
-
Change list of available resources.
In essence this method removes all available resources and adds data about each given resource into the list of available resources.Parameters:
Name Type Description list
Array | Object List that contains objects presenting data about resources, or object with data about an resource. Returns:
Object that represents moduleexports
.- Type
- Object