Comparing version 1.0.0-beta.2 to 1.0.0-beta.3
@@ -18,3 +18,3 @@ /// <reference types="rdfjs__sink-map" /> | ||
baseUri?: string; | ||
rootSelectors: RootSelector[]; | ||
rootSelectors: [string, RootSelector][]; | ||
parsers: SinkMap<EventEmitter, Stream>; | ||
@@ -30,3 +30,3 @@ loadResource<T extends RdfResource = HydraResource>(uri: string | NamedNode, headers?: HeadersInit): Promise<HydraResponse<T>>; | ||
interface AlcaeusInit<R extends HydraResource = never, D extends DatasetIndexed = DatasetIndexed> { | ||
rootSelectors: RootSelector[]; | ||
rootSelectors: [string, RootSelector][]; | ||
factory: ResourceFactory<DatasetCore, R>; | ||
@@ -37,3 +37,3 @@ dataset: D; | ||
baseUri?: string; | ||
rootSelectors: RootSelector[]; | ||
rootSelectors: [string, RootSelector][]; | ||
parsers: Parsers<EventEmitter, Stream<import("rdf-js").Quad>>; | ||
@@ -40,0 +40,0 @@ defaultHeaders: HeadersInit | (() => HeadersInit); |
@@ -9,2 +9,3 @@ import Parsers from '@rdfjs/sink-map'; | ||
import RdfProcessor from './RdfProcessor'; | ||
import { wrappedViewSelector } from './RootSelectors'; | ||
function stripContentTypeParameters(mediaType) { | ||
@@ -39,3 +40,3 @@ return mediaType.split(';').shift() || ''; | ||
this.__apiDocumentations = new Map(); | ||
this.rootSelectors = rootSelectors; | ||
this.rootSelectors = rootSelectors.map(([name, selector]) => [name, wrappedViewSelector(selector)]); | ||
this.factory = factory; | ||
@@ -42,0 +43,0 @@ this.dataset = dataset; |
@@ -5,2 +5,14 @@ # Changelog | ||
## [1.0.0-beta.3](https://github.com/wikibus/alcaeus/compare/v1.0.0-beta.2...v1.0.0-beta.3) (2020-04-25) | ||
### ⚠ BREAKING CHANGES | ||
* root selectors are now simple functions, initialized through an array of [string, func] | ||
### Bug Fixes | ||
* getting links failed if any object was Literal ([38ce61a](https://github.com/wikibus/alcaeus/commit/38ce61a62fec49a83caad02979d4014f0be2d4f4)) | ||
* selecting root only work for hydra:PartialCollectionView ([18d637a](https://github.com/wikibus/alcaeus/commit/18d637aae1ad3c60d5bdf6cc55467ad62c36a8a4)) | ||
## [1.0.0-beta.2](https://github.com/wikibus/alcaeus/compare/v1.0.0-beta.1...v1.0.0-beta.2) (2020-04-24) | ||
@@ -7,0 +19,0 @@ |
@@ -27,3 +27,3 @@ import cf from 'clownface'; | ||
const potentialRoots = alcaeus.rootSelectors.reduceRight((candidates, selector) => { | ||
const candidate = selector.selectRoot(resources, this); | ||
const candidate = selector[1](resources, this); | ||
if (candidate) { | ||
@@ -30,0 +30,0 @@ return [...candidates, candidate]; |
@@ -13,3 +13,3 @@ /// <reference types="rdfjs__sink-map" /> | ||
interface AlcaeusInit<D extends DatasetIndexed = DatasetIndexed> { | ||
rootSelectors?: RootSelector[]; | ||
rootSelectors?: [string, RootSelector][]; | ||
parsers?: SinkMap<EventEmitter, Stream>; | ||
@@ -16,0 +16,0 @@ dataset?: D; |
@@ -17,3 +17,3 @@ import RdfResource from '@tpluscode/rdfine'; | ||
const alcaeus = new Alcaeus({ | ||
rootSelectors: rootSelectors || Object.values(defaultSelectors), | ||
rootSelectors: Object.entries(rootSelectors || defaultSelectors), | ||
factory, | ||
@@ -20,0 +20,0 @@ dataset: dataset || createDataset(), |
{ | ||
"name": "alcaeus", | ||
"version": "1.0.0-beta.2", | ||
"version": "1.0.0-beta.3", | ||
"description": "Hydra Core hypermedia-aware client library", | ||
@@ -42,3 +42,3 @@ "main": "main.js", | ||
"@tpluscode/rdf-ns-builders": "^0.1", | ||
"@tpluscode/rdfine": "^0.4.8", | ||
"@tpluscode/rdfine": "^0.4.9", | ||
"clownface": "^0.12.3", | ||
@@ -72,3 +72,3 @@ "es6-url-template": "^1.0.3", | ||
"@types/rdf-dataset-indexed": "^0.4.4", | ||
"@types/rdf-ext": "^1.3.6", | ||
"@types/rdf-ext": "^1.3.7", | ||
"@types/rdf-js": "^2.0.12", | ||
@@ -75,0 +75,0 @@ "@types/rdfjs__namespace": "^1.1.1", |
@@ -5,12 +5,18 @@ import { HydraResponse } from '../HydraResponse'; | ||
import { ResponseWrapper } from '../ResponseWrapper'; | ||
import { canonicalLink } from './canonicalLink'; | ||
import { exactId } from './exactId'; | ||
import { locationHeader201 } from './locationHeader201'; | ||
import { redirectTarget } from './redirectTarget'; | ||
import { trailingSlash } from './trailingSlash'; | ||
export interface RootSelector { | ||
selectRoot(resources: ResourceGraph, response: ResponseWrapper & HydraResponse): HydraResource | undefined; | ||
(resources: ResourceGraph, response: ResponseWrapper & HydraResponse): HydraResource | undefined; | ||
} | ||
export { wrappedViewSelector } from './view'; | ||
export declare const defaultSelectors: { | ||
CanonicalLink: RootSelector; | ||
LocationHeader: RootSelector; | ||
ExactId: RootSelector; | ||
TrailingSlash: RootSelector; | ||
Redirect: RootSelector; | ||
canonicalLink: typeof canonicalLink; | ||
locationHeader201: typeof locationHeader201; | ||
exactId: typeof exactId; | ||
trailingSlash: typeof trailingSlash; | ||
redirectTarget: typeof redirectTarget; | ||
}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,13 +0,13 @@ | ||
import CanonicalLinkSelector from './CanonicalLinkSelector'; | ||
import ExactIdMatchSelector from './ExactIdMatchSelector'; | ||
import LocationSelector from './201LocationSelector'; | ||
import PartialCollectionViewSelector from './PartialCollectionViewSelector'; | ||
import RedirectTargetSelector from './RedirectTargetSelector'; | ||
import TrailingSlashSelector from './TrailingSlashSelector'; | ||
import { canonicalLink } from './canonicalLink'; | ||
import { exactId } from './exactId'; | ||
import { locationHeader201 } from './locationHeader201'; | ||
import { redirectTarget } from './redirectTarget'; | ||
import { trailingSlash } from './trailingSlash'; | ||
export { wrappedViewSelector } from './view'; | ||
export const defaultSelectors = { | ||
'CanonicalLink': PartialCollectionViewSelector(CanonicalLinkSelector), | ||
'LocationHeader': PartialCollectionViewSelector(LocationSelector), | ||
'ExactId': PartialCollectionViewSelector(ExactIdMatchSelector), | ||
'TrailingSlash': PartialCollectionViewSelector(TrailingSlashSelector), | ||
'Redirect': PartialCollectionViewSelector(RedirectTargetSelector), | ||
canonicalLink, | ||
locationHeader201, | ||
exactId, | ||
trailingSlash, | ||
redirectTarget, | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
245594
3038
Updated@tpluscode/rdfine@^0.4.9