Skip to content

Commit

Permalink
Merge pull request #643 from alpheios-project/al286-dts-api
Browse files Browse the repository at this point in the history
DTS API - pagination and entire text
  • Loading branch information
irina060981 authored Apr 5, 2021
2 parents a9f768c + 29e0f7f commit 01ce963
Show file tree
Hide file tree
Showing 21 changed files with 9,194 additions and 9,049 deletions.
38 changes: 22 additions & 16 deletions packages/client-adapters/dist/alpheios-client-adapters.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

38 changes: 22 additions & 16 deletions packages/client-adapters/dist/alpheios-client-adapters.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -4965,9 +4965,9 @@ class DTSAPIAdapter extends _clAdapters_adapters_base_adapter__WEBPACK_IMPORTED_
* @param {String} id - @id for the collection for example urn:alpheios:latinLit, if it is null would be retrieved the root collections
* @return {Collection}
*/
async getCollection (id) {
async getCollection (id, page) {
try {
const url = this.getCollectionUrl(id)
const url = this.getCollectionUrl(id, page)
const collections = await this.fetch(url)
if (collections) {
return this.convertToCollections(collections)
Expand All @@ -4981,7 +4981,7 @@ class DTSAPIAdapter extends _clAdapters_adapters_base_adapter__WEBPACK_IMPORTED_
/**
* Retrieves refs
* @param {String} id - @id for the Resource for example urn:cts:latinLit:phi0472.phi001.alpheios-text-lat1
* @param {Collection} collection - would be updated with retrieve data
* @param {Resource} resource - would be updated with retrieve data
*
*/
async getNavigation (id, resource) {
Expand All @@ -5007,7 +5007,7 @@ class DTSAPIAdapter extends _clAdapters_adapters_base_adapter__WEBPACK_IMPORTED_
* {String} end - an ending ref till it the text would be retrieved (if it is not defined - would be retrieved till the end of the text)
* @retunrs {String} - TEI xml document
*/
async getDocument (id, refParams = {}) {
async getDocument (id, refParams) {
try {
const url = this.getDocumentUrl(id, refParams)
if (!url) { return }
Expand All @@ -5024,11 +5024,14 @@ class DTSAPIAdapter extends _clAdapters_adapters_base_adapter__WEBPACK_IMPORTED_
* @param {String} id - @id
* @returns {string} - url for getting collections
*/
getCollectionUrl (id) {
getCollectionUrl (id, page) {
let url = `${this.config.baseUrl}collections`
if (id) {
url = `${url}?id=${id}`
}
if (page) {
url = `${url}&page=${page}`
}
return url
}

Expand All @@ -5051,21 +5054,22 @@ class DTSAPIAdapter extends _clAdapters_adapters_base_adapter__WEBPACK_IMPORTED_
* @returns {string} - url for getting document
*/
getDocumentUrl (id, refParams) {
const { ref, start, end } = refParams
let url = `${this.config.baseUrl}document`
if (!id || (!ref && !start)) {
const message = 'getDocumentUrl - not defined id or ref/start'
if (!id) {
const message = 'getDocumentUrl - not defined id'
this.addError(this.l10n.getMsg('DTSAPI_NO_OBLIGATORY_PROPS', { message }))
return
}

url = `${url}?id=${id}`

if (ref) { return `${url}&ref=${ref}` }

url = `${url}&start=${start}`
if (end) { return `${url}&end=${end}` }
if (refParams) {
const { ref, start, end } = refParams
if (ref) { return `${url}&ref=${ref}` }

url = `${url}&start=${start}`
if (end) { return `${url}&end=${end}` }
}
return url
}

Expand All @@ -5080,7 +5084,8 @@ class DTSAPIAdapter extends _clAdapters_adapters_base_adapter__WEBPACK_IMPORTED_
title: collectionsJSON.title !== 'None' ? collectionsJSON.title : 'Alpheios',
id: collectionsJSON['@id'] !== 'default' ? collectionsJSON['@id'] : null,
baseUrl: this.config.baseUrl,
description: collectionsJSON.description
description: collectionsJSON.description,
pagination: collectionsJSON.view
})

if (collectionsJSON.member) {
Expand All @@ -5091,7 +5096,8 @@ class DTSAPIAdapter extends _clAdapters_adapters_base_adapter__WEBPACK_IMPORTED_
id: collJson['@id'],
type: collJson['@type'],
description: collJson.description,
baseUrl: this.config.baseUrl
baseUrl: this.config.baseUrl,
pagination: collectionsJSON.view
})
})
}
Expand Down Expand Up @@ -7125,7 +7131,7 @@ class ClientAdapters {
})

if (options.method === 'getCollection') {
const res = await localDTSAPIAdapter.getCollection(options.params.id)
const res = await localDTSAPIAdapter.getCollection(options.params.id, options.params.page)
return { result: res, errors: localDTSAPIAdapter.errors }
}

Expand Down Expand Up @@ -7999,7 +8005,7 @@ class ImportMorphData {
/***/ ((module) => {

"use strict";
module.exports = JSON.parse("{\"morphology\":{\"alpheiosTreebank\":{\"adapter\":\"tbAdapter\",\"methods\":[\"getHomonym\"],\"params\":{\"getHomonym\":[\"languageID\",\"wordref\"]}},\"arethusaTreebank\":{\"adapter\":\"arethusaAdapter\",\"methods\":[\"getHomonym\",\"refreshView\",\"gotoSentence\",\"findWord\"],\"params\":{\"getHomonym\":[\"languageID\",\"word\",\"provider\",\"sentenceId\",\"wordId\"],\"refreshView\":[\"provider\"],\"gotoSentence\":[\"provider\",\"sentenceId\",\"wordIds\"],\"findWord\":[\"provider\",\"word\",\"prefix\",\"suffix\",\"sentenceId\"]}},\"tufts\":{\"adapter\":\"maAdapter\",\"methods\":[\"getHomonym\"],\"params\":{\"getHomonym\":[\"languageID\",\"word\"]}},\"chineseloc\":{\"adapter\":\"chineseAdapter\",\"methods\":[\"getHomonym\",\"loadData\"],\"params\":{\"getHomonym\":[\"languageID\",\"word\"],\"loadData\":[\"timeout\"]}}},\"lexicon\":{\"alpheios\":{\"adapter\":\"lexicons\",\"methods\":[\"fetchShortDefs\",\"fetchFullDefs\",\"checkCachedData\",\"getConfig\"],\"params\":{\"fetchShortDefs\":[\"homonym\",\"opts\"],\"fetchFullDefs\":[\"homonym\",\"opts\"],\"checkCachedData\":[\"url\",\"externalData\"],\"getConfig\":[]}}},\"lemmatranslation\":{\"alpheios\":{\"adapter\":\"lemmaTranslations\",\"methods\":\"fetchTranslations\",\"params\":{\"fetchTranslations\":[\"homonym\",\"browserLang\"]}}},\"wordusageExamples\":{\"concordance\":{\"adapter\":\"wordUsageExamples\",\"methods\":[\"getAuthorsWorks\",\"getWordUsageExamples\"],\"params\":{\"getAuthorsWorks\":[],\"getWordUsageExamples\":[\"homonym\"]}}},\"autocompleteWords\":{\"logeion\":{\"adapter\":\"autoCompleteWords\",\"methods\":\"getWords\",\"params\":{\"getWords\":[\"text\",\"lang\",\"fetchOptions\"]}}},\"tokenizationGroup\":{\"alpheios\":{\"adapter\":\"tokenizationMethod\",\"methods\":[\"getTokens\",\"getConfig\"],\"params\":{\"getTokens\":[\"text\"],\"getConfig\":[\"storage\"]}}},\"dtsapiGroup\":{\"dtsapi\":{\"adapter\":\"dtsApiMethod\",\"methods\":[\"getCollection\",\"getNavigation\",\"getDocument\"],\"params\":{\"getCollection\":[\"baseUrl\"],\"getNavigation\":[\"baseUrl\",\"id\",\"resource\"],\"getDocument\":[\"baseUrl\",\"id\",\"refParams\"]}}}}");
module.exports = JSON.parse("{\"morphology\":{\"alpheiosTreebank\":{\"adapter\":\"tbAdapter\",\"methods\":[\"getHomonym\"],\"params\":{\"getHomonym\":[\"languageID\",\"wordref\"]}},\"arethusaTreebank\":{\"adapter\":\"arethusaAdapter\",\"methods\":[\"getHomonym\",\"refreshView\",\"gotoSentence\",\"findWord\"],\"params\":{\"getHomonym\":[\"languageID\",\"word\",\"provider\",\"sentenceId\",\"wordId\"],\"refreshView\":[\"provider\"],\"gotoSentence\":[\"provider\",\"sentenceId\",\"wordIds\"],\"findWord\":[\"provider\",\"word\",\"prefix\",\"suffix\",\"sentenceId\"]}},\"tufts\":{\"adapter\":\"maAdapter\",\"methods\":[\"getHomonym\"],\"params\":{\"getHomonym\":[\"languageID\",\"word\"]}},\"chineseloc\":{\"adapter\":\"chineseAdapter\",\"methods\":[\"getHomonym\",\"loadData\"],\"params\":{\"getHomonym\":[\"languageID\",\"word\"],\"loadData\":[\"timeout\"]}}},\"lexicon\":{\"alpheios\":{\"adapter\":\"lexicons\",\"methods\":[\"fetchShortDefs\",\"fetchFullDefs\",\"checkCachedData\",\"getConfig\"],\"params\":{\"fetchShortDefs\":[\"homonym\",\"opts\"],\"fetchFullDefs\":[\"homonym\",\"opts\"],\"checkCachedData\":[\"url\",\"externalData\"],\"getConfig\":[]}}},\"lemmatranslation\":{\"alpheios\":{\"adapter\":\"lemmaTranslations\",\"methods\":\"fetchTranslations\",\"params\":{\"fetchTranslations\":[\"homonym\",\"browserLang\"]}}},\"wordusageExamples\":{\"concordance\":{\"adapter\":\"wordUsageExamples\",\"methods\":[\"getAuthorsWorks\",\"getWordUsageExamples\"],\"params\":{\"getAuthorsWorks\":[],\"getWordUsageExamples\":[\"homonym\"]}}},\"autocompleteWords\":{\"logeion\":{\"adapter\":\"autoCompleteWords\",\"methods\":\"getWords\",\"params\":{\"getWords\":[\"text\",\"lang\",\"fetchOptions\"]}}},\"tokenizationGroup\":{\"alpheios\":{\"adapter\":\"tokenizationMethod\",\"methods\":[\"getTokens\",\"getConfig\"],\"params\":{\"getTokens\":[\"text\"],\"getConfig\":[\"storage\"]}}},\"dtsapiGroup\":{\"dtsapi\":{\"adapter\":\"dtsApiMethod\",\"methods\":[\"getCollection\",\"getNavigation\",\"getDocument\"],\"params\":{\"getCollection\":[\"baseUrl\"],\"getNavigation\":[\"baseUrl\",\"id\",\"resource\"],\"getDocument\":[\"baseUrl\",\"id\"]}}}}");

/***/ }),

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/client-adapters/src/adapters/adapters-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"params": {
"getCollection": ["baseUrl"],
"getNavigation": ["baseUrl", "id", "resource"],
"getDocument": ["baseUrl", "id", "refParams"]
"getDocument": ["baseUrl", "id"]
}
}
}
Expand Down
Loading

0 comments on commit 01ce963

Please sign in to comment.