semantic-network
Advanced tools
Comparing version 0.7.5 to 0.7.6
@@ -48,2 +48,9 @@ import { Status } from '../representation/status'; | ||
/** | ||
* Generate a resource from a feed item with a title from the given field attribute | ||
* | ||
* @default: title | ||
* @see SparseRepresentationFactory.mappedFromFeedItemFieldName | ||
*/ | ||
readonly mappedTitleFrom?: string; | ||
/** | ||
* The strategy used to create sparse {@link LinkedRepresentation} objects. This allows to caller | ||
@@ -50,0 +57,0 @@ * to plug in an alternative implementation (say to implement a pooled resource strategy). |
@@ -22,2 +22,3 @@ import { CollectionRepresentation, LinkedRepresentation, Uri } from 'semantic-link'; | ||
static mappedTitleAttributeName: "name"; | ||
static mappedFromFeedItemFieldName: "title"; | ||
/** | ||
@@ -24,0 +25,0 @@ * A simple facade to allow the make() method to be provided by an alternative strategy. |
@@ -147,3 +147,3 @@ "use strict"; | ||
_e = _c.title, // rather than populate with undefined, default to empty string (unclear why this is a good idea) | ||
title = _e === void 0 ? undefined : _e, _f = _c.status, status = _f === void 0 ? (options === null || options === void 0 ? void 0 : options.uri) ? status_1.Status.locationOnly : status_1.Status.virtual : _f, _g = _c.mappedTitle, mappedTitle = _g === void 0 ? this.mappedTitleAttributeName : _g, _h = _c.sparseType, sparseType = _h === void 0 ? 'singleton' : _h; | ||
title = _e === void 0 ? undefined : _e, _f = _c.status, status = _f === void 0 ? (options === null || options === void 0 ? void 0 : options.uri) ? status_1.Status.locationOnly : status_1.Status.virtual : _f, _g = _c.mappedTitle, mappedTitle = _g === void 0 ? this.mappedTitleAttributeName : _g, _h = _c.mappedTitleFrom, mappedTitleFrom = _h === void 0 ? this.mappedFromFeedItemFieldName : _h, _j = _c.sparseType, sparseType = _j === void 0 ? 'singleton' : _j; | ||
var sparseResource = (_a = {}, | ||
@@ -165,3 +165,3 @@ _a[types_1.state] = new state_1.State(status), | ||
else if (sparseType === 'collection') { | ||
var _j = __assign({}, options).defaultItems, defaultItems = _j === void 0 ? [] : _j; | ||
var _k = __assign({}, options).defaultItems, defaultItems = _k === void 0 ? [] : _k; | ||
var items = defaultItems.map(function (item) { | ||
@@ -172,3 +172,5 @@ if (typeof item === 'string' /* Uri */) { | ||
else { | ||
return _this.makeSparse({ uri: item.id, title: item.title }); | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
return _this.makeSparse({ uri: item.id, title: item[mappedTitleFrom] }); | ||
} | ||
@@ -182,3 +184,5 @@ }); | ||
if (feedItem) { | ||
return this.makeSparse({ uri: feedItem.id, title: feedItem.title }); | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
return this.makeSparse({ uri: feedItem.id, title: feedItem[mappedTitleFrom] }); | ||
} | ||
@@ -340,2 +344,3 @@ else { | ||
SparseRepresentationFactory.mappedTitleAttributeName = 'name'; | ||
SparseRepresentationFactory.mappedFromFeedItemFieldName = 'title'; | ||
return SparseRepresentationFactory; | ||
@@ -342,0 +347,0 @@ }()); |
@@ -32,3 +32,3 @@ import { CollectionRepresentation, LinkedRepresentation, RelationshipType } from 'semantic-link'; | ||
/** | ||
* Add to a (search) collection a new item. This is used where the current list is being added to independently | ||
* In-place add to a (search) collection a new item. This is used where the current list is being added to independently | ||
* of a newly added collection without returning the entire search collection | ||
@@ -38,3 +38,3 @@ * | ||
*/ | ||
static update(collection: CollectionRepresentation, item: LinkedRepresentation, equalityMatch?: RelationshipType): void; | ||
static update<T extends LinkedRepresentation = LinkedRepresentation>(collection: CollectionRepresentation<T>, item: T, equalityMatch?: RelationshipType): void; | ||
} |
@@ -157,3 +157,3 @@ "use strict"; | ||
/** | ||
* Add to a (search) collection a new item. This is used where the current list is being added to independently | ||
* In-place add to a (search) collection a new item. This is used where the current list is being added to independently | ||
* of a newly added collection without returning the entire search collection | ||
@@ -175,2 +175,5 @@ * | ||
} | ||
else { | ||
log.debug('No collection found to update'); | ||
} | ||
}; | ||
@@ -177,0 +180,0 @@ return SearchUtil; |
@@ -48,2 +48,9 @@ import { Status } from '../representation/status'; | ||
/** | ||
* Generate a resource from a feed item with a title from the given field attribute | ||
* | ||
* @default: title | ||
* @see SparseRepresentationFactory.mappedFromFeedItemFieldName | ||
*/ | ||
readonly mappedTitleFrom?: string; | ||
/** | ||
* The strategy used to create sparse {@link LinkedRepresentation} objects. This allows to caller | ||
@@ -50,0 +57,0 @@ * to plug in an alternative implementation (say to implement a pooled resource strategy). |
@@ -22,2 +22,3 @@ import { CollectionRepresentation, LinkedRepresentation, Uri } from 'semantic-link'; | ||
static mappedTitleAttributeName: "name"; | ||
static mappedFromFeedItemFieldName: "title"; | ||
/** | ||
@@ -24,0 +25,0 @@ * A simple facade to allow the make() method to be provided by an alternative strategy. |
@@ -88,3 +88,3 @@ import { __rest } from "tslib"; | ||
const { uri = '', // rather than populate with undefined, default to empty string (unclear why this is a good idea) | ||
title = undefined, status = (options === null || options === void 0 ? void 0 : options.uri) ? Status.locationOnly : Status.virtual, mappedTitle = this.mappedTitleAttributeName, sparseType = 'singleton', } = Object.assign({}, options); | ||
title = undefined, status = (options === null || options === void 0 ? void 0 : options.uri) ? Status.locationOnly : Status.virtual, mappedTitle = this.mappedTitleAttributeName, mappedTitleFrom = this.mappedFromFeedItemFieldName, sparseType = 'singleton', } = Object.assign({}, options); | ||
const sparseResource = { | ||
@@ -112,3 +112,5 @@ [state]: new State(status), | ||
else { | ||
return this.makeSparse({ uri: item.id, title: item.title }); | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
return this.makeSparse({ uri: item.id, title: item[mappedTitleFrom] }); | ||
} | ||
@@ -122,3 +124,5 @@ }); | ||
if (feedItem) { | ||
return this.makeSparse({ uri: feedItem.id, title: feedItem.title }); | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
return this.makeSparse({ uri: feedItem.id, title: feedItem[mappedTitleFrom] }); | ||
} | ||
@@ -279,2 +283,3 @@ else { | ||
SparseRepresentationFactory.mappedTitleAttributeName = 'name'; | ||
SparseRepresentationFactory.mappedFromFeedItemFieldName = 'title'; | ||
export const defaultMakeStrategy = SparseRepresentationFactory.defaultMakeStrategy; | ||
@@ -281,0 +286,0 @@ export const pooledCollectionMakeStrategy = SparseRepresentationFactory.pooledCollectionMakeStrategy; |
@@ -32,3 +32,3 @@ import { CollectionRepresentation, LinkedRepresentation, RelationshipType } from 'semantic-link'; | ||
/** | ||
* Add to a (search) collection a new item. This is used where the current list is being added to independently | ||
* In-place add to a (search) collection a new item. This is used where the current list is being added to independently | ||
* of a newly added collection without returning the entire search collection | ||
@@ -38,3 +38,3 @@ * | ||
*/ | ||
static update(collection: CollectionRepresentation, item: LinkedRepresentation, equalityMatch?: RelationshipType): void; | ||
static update<T extends LinkedRepresentation = LinkedRepresentation>(collection: CollectionRepresentation<T>, item: T, equalityMatch?: RelationshipType): void; | ||
} |
@@ -96,3 +96,3 @@ import { __awaiter } from "tslib"; | ||
/** | ||
* Add to a (search) collection a new item. This is used where the current list is being added to independently | ||
* In-place add to a (search) collection a new item. This is used where the current list is being added to independently | ||
* of a newly added collection without returning the entire search collection | ||
@@ -114,4 +114,7 @@ * | ||
} | ||
else { | ||
log.debug('No collection found to update'); | ||
} | ||
} | ||
} | ||
//# sourceMappingURL=searchUtil.js.map |
{ | ||
"name": "semantic-network", | ||
"version": "0.7.5", | ||
"version": "0.7.6", | ||
"description": "A utility library for manipulating a list of links that form a semantic interface to a network of resources.", | ||
@@ -5,0 +5,0 @@ "main": "lib/es5/index.js", |
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
Sorry, the diff of this file is not supported yet
1170077
19371