A NodeJS wrapper around ezMESURE API.
npm install -g @ezpaarse-project/ezmesure
The module provides an ezmesure
command (aliased ezm
).
Name | Type | Description |
---|---|---|
-u, --base-url | String | API URL (ex: https://ezmesure-preprod.couperin.org/api) |
-t, --token | String | The auth token to use |
-k, --insecure | String | Allow connections to SSL without certs |
-m, --timeout | Number | Request timeout in milliseconds |
--version | Boolean | Print the version number |
--help | Boolean | Show some help |
You can get help for any command by typing ezmesure <command> help
.
When using node-ezmesure on the command line, any .ezmesurerc
file located in the current directory or any of its parents will be used as default
List available indices
Delete <index>
Insert <files> into an <index>. Directories are also supported, in which case all files matching --ext
are inserted.
Name | Type | Description |
---|---|---|
-z, --gunzip | String | Uncompress Gzip files locally |
-n, --no-store | String | Disable storing uploaded data in your online space |
-s, --split | String | Split a multivalued field. Format: "fieldname(delimitor)" |
-r, --recursive | Boolean | Look for files in subdirectories |
--ext | String | Specify file extensions - default: .csv,.csv.gz |
# Insert CSV files from ezpaarse-results into univ-foobar
ezmesure indices insert univ-foobar ezpaarse-results/*.csv
Get overall metrics from the API
Delete consultation events from <index>
Name | Type | Description |
---|---|---|
--from | String | Minimum date of the events that should be removed. Can be either a date or datetime in ISO format. |
--to | String | Maximum date of the events that should be removed. Can be either a date or datetime in ISO format. |
# Remove consultations from univ-foobar in 2018
ezmesure events delete univ-foobar --from 2018-01-01T00:00:00 --to 2019-01-01T00:00:00
Give top metrics for a given <index>
Name | Type | Description |
---|---|---|
-s, --size | Number | Size of the tops |
-p, --period | String | Period of the tops. Possible values: today, yesterday, current_week, last_week, current_month, last_month, current_year, last_year, all (default) |
# Get a top 10 for the last month
ezmesure tops univ-foo -s 10 -p last_month
# Get a top 3 for the whole index
ezmesure tops univ-foo -s 10 -p all
Refresh the depositors list
const ezmesure = require('ezmesure');
ezmesure.indices.list().then(indiceList => {
console.log(indiceList);
}).catch(err => {
console.error(err);
});
Name | Type | Description |
---|---|---|
baseUrl | String | URL to the API endpoint (ex: https://ezmesure.couperin.org/api) |
token | String | JWT auth token |
strictSSL | Boolean | enable or disable SSL cert verification |
headers | Object | custom headers to send along with the request |
Returns an array of all indices with their name and the number of documents.
Example of result:
[
{ name: 'univ-fcomte', docs: 35133 },
{ name: 'univ-test2', docs: 31923 },
{ name: 'univ-test3', docs: 15 }
]
Inserts a file (given either a path or a readable stream) into an indice. Returns an object with the following properties:
inserted
: number of documents successfuly inserted.updated
: number of documents successfuly updated.failed
: number of documents that failed to be inserted.errors
: an array containing the 10 first errors generated during the insertion.
Deletes an indice. Returns an object with the following property:
acknowledged
: boolean, will betrue
in case of success,false
otherwise.
Returns an array of all indices with their name and the number of documents.
Example of result:
{
"took": 148,
"docs": 344381732,
"dateCoverage": {
"min": 1375225410000,
"max": 1542326387000
},
"metrics": {
"days": 1935,
"titles": 1730487,
"platforms": 173,
"indices": 86
}
}
Returns an array of all indices with their name and the number of documents.
Name | Type | Description |
---|---|---|
size | Number | Size of the tops |
period | String | Period of the tops. Possible values: today, yesterday, current_week, last_week, current_month, last_month, current_year, last_year, all (default) |
Example of result:
{
"took": 847,
"docs": 3411691,
"dateCoverage": {
"min": 1483225472000,
"max": 1542322684000
},
"tops": {
"titles": [
{
"key": "Organometallics",
"doc_count": 45174
}
],
"publishers": [
{
"key": "Steinkopff",
"doc_count": 1146437
}
],
"indices": [
{
"key": "univ-foobar",
"doc_count": 3411691
}
]
}
}
Remove consultation events from an index.
Name | Type | Description |
---|---|---|
from | String | Minimum date of the events that should be removed. Can be either a date or datetime in ISO format. |
to | String | Maximum date of the events that should be removed. Can be either a date or datetime in ISO format. |
Refresh the depositor list and return an array of all indices with their name and the number of documents.
Example of result:
[
{ name: 'University of Foobar', prefix: 'univ-foobar', count: 35133, result: 'created' },
{ name: 'University of Barfoo', prefix: 'univ-barfoo', count: 31923, result: 'created' }
]
Looks for a .ezmesurerc
file in the given directory (defaulting to the working directory) and all its parents.
Returns the path of the config file, or null
if not found.
Loads a default config, using either an object or a path to a config file.