@azure-iot/hal
Advanced tools
Comparing version 1.0.0-rc.14 to 1.0.0-rc.15
{ | ||
"name": "@azure-iot/hal", | ||
"description": "Decorator library for HAL-based routes", | ||
"version": "1.0.0-rc.14", | ||
"version": "1.0.0-rc.15", | ||
"scripts": { | ||
@@ -6,0 +6,0 @@ "prebuild": "npm run lint", |
@@ -43,6 +43,7 @@ # @azure-iot/hal | ||
* `discoverable` [boolean]: Indicates whether this handler should be included in the discoverability API; default is false. | ||
* `description` [string]: The description that will be used for this rel and this route in automatically-generated documentation. | ||
* `params` [any]: URI parameters to explicitly force for this rel. This allows, for example, a route with an optional parameter to have a separate rel explicitly for when that parameter is empty. | ||
* `array` [boolean]: The rel will be forced to be an array, even if it only contains one link. | ||
* `id` [string]: The name of the ID parameter. This will fill out the 'name' in any links to this rel from the corresponding entry in the params object. | ||
* `title` [string]: The value to be placed in the 'title' parameter in any links to this rel. | ||
* `description` [string]: The description that will be used for this rel and this route in automatically-generated documentation. | ||
@@ -71,6 +72,6 @@ #### `@middleware(handler)` | ||
* `href` [string]: The HAL response will use the provided href for this rel, rather than the server-provided one. | ||
* `server` [Object]: The server class used for non-namespaced and standard rels. | ||
* `links` [Array<string | LinkRelation>]: The array of rels associated with this link. This corresponds to the array of rels provided to the `@hal` decorator for this link, plus the 'self' rel if it would typically be present, and is used for link embedding when necessary. | ||
* `params` [any]: The href will be populated using this params object, rather than the one from the request. | ||
* `server` [Object]: The server class used for non-namespaced and standard rels. | ||
* `array` [boolean]: The rel will be forced to be an array, even if it only contains one link. | ||
* `links` [Array<string | LinkRelation>]: The array of rels associated with this link. This corresponds to the array of rels provided to the `@hal` decorator for this link, plus the 'self' rel if it would typically be present, and is used for link embedding when necessary. | ||
* `id` [string]: The 'name' parameter for this link will be set to this member of the params object. | ||
@@ -77,0 +78,0 @@ * `title` [string]: The 'title' parameter for this link will be set to this value. |
export declare enum Method { | ||
GET = 0, | ||
PUT = 1, | ||
POST = 2, | ||
DELETE = 3, | ||
PATCH = 4, | ||
GET = 1, | ||
PUT = 2, | ||
POST = 3, | ||
DELETE = 4, | ||
PATCH = 5, | ||
} | ||
export declare type Verb = string | Method; | ||
export declare enum LinkRelation { | ||
About = 0, | ||
Alternate = 1, | ||
Appendix = 2, | ||
Archives = 3, | ||
Author = 4, | ||
BlockedBy = 5, | ||
Bookmark = 6, | ||
Canonical = 7, | ||
Chapter = 8, | ||
Collection = 9, | ||
Contents = 10, | ||
Copyright = 11, | ||
CreateForm = 12, | ||
Current = 13, | ||
Derivedfrom = 14, | ||
Describedby = 15, | ||
Describes = 16, | ||
Disclosure = 17, | ||
DnsPrefetch = 18, | ||
Duplicate = 19, | ||
Edit = 20, | ||
EditForm = 21, | ||
EditMedia = 22, | ||
Enclosure = 23, | ||
First = 24, | ||
Glossary = 25, | ||
Help = 26, | ||
Hosts = 27, | ||
Hub = 28, | ||
Icon = 29, | ||
Index = 30, | ||
Item = 31, | ||
Last = 32, | ||
LatestVersion = 33, | ||
License = 34, | ||
Lrdd = 35, | ||
Memento = 36, | ||
Monitor = 37, | ||
MonitorGroup = 38, | ||
Next = 39, | ||
NextArchive = 40, | ||
Nofollow = 41, | ||
Noreferrer = 42, | ||
Original = 43, | ||
Payment = 44, | ||
Pingback = 45, | ||
Preconnect = 46, | ||
PredecessorVersion = 47, | ||
Prefetch = 48, | ||
Preload = 49, | ||
Prerender = 50, | ||
Prev = 51, | ||
Preview = 52, | ||
Previous = 53, | ||
PrevArchive = 54, | ||
PrivacyPolicy = 55, | ||
Profile = 56, | ||
Related = 57, | ||
Replies = 58, | ||
Search = 59, | ||
Section = 60, | ||
Self = 61, | ||
Service = 62, | ||
Start = 63, | ||
Stylesheet = 64, | ||
Subsection = 65, | ||
SuccessorVersion = 66, | ||
Tag = 67, | ||
TermsOfService = 68, | ||
Timegate = 69, | ||
Timemap = 70, | ||
Type = 71, | ||
Up = 72, | ||
VersionHistory = 73, | ||
Via = 74, | ||
WorkingCopy = 75, | ||
WorkingCopyOf = 76, | ||
About = 1, | ||
Alternate = 2, | ||
Appendix = 3, | ||
Archives = 4, | ||
Author = 5, | ||
BlockedBy = 6, | ||
Bookmark = 7, | ||
Canonical = 8, | ||
Chapter = 9, | ||
Collection = 10, | ||
Contents = 11, | ||
Copyright = 12, | ||
CreateForm = 13, | ||
Current = 14, | ||
Derivedfrom = 15, | ||
Describedby = 16, | ||
Describes = 17, | ||
Disclosure = 18, | ||
DnsPrefetch = 19, | ||
Duplicate = 20, | ||
Edit = 21, | ||
EditForm = 22, | ||
EditMedia = 23, | ||
Enclosure = 24, | ||
First = 25, | ||
Glossary = 26, | ||
Help = 27, | ||
Hosts = 28, | ||
Hub = 29, | ||
Icon = 30, | ||
Index = 31, | ||
Item = 32, | ||
Last = 33, | ||
LatestVersion = 34, | ||
License = 35, | ||
Lrdd = 36, | ||
Memento = 37, | ||
Monitor = 38, | ||
MonitorGroup = 39, | ||
Next = 40, | ||
NextArchive = 41, | ||
Nofollow = 42, | ||
Noreferrer = 43, | ||
Original = 44, | ||
Payment = 45, | ||
Pingback = 46, | ||
Preconnect = 47, | ||
PredecessorVersion = 48, | ||
Prefetch = 49, | ||
Preload = 50, | ||
Prerender = 51, | ||
Prev = 52, | ||
Preview = 53, | ||
Previous = 54, | ||
PrevArchive = 55, | ||
PrivacyPolicy = 56, | ||
Profile = 57, | ||
Related = 58, | ||
Replies = 59, | ||
Search = 60, | ||
Section = 61, | ||
Self = 62, | ||
Service = 63, | ||
Start = 64, | ||
Stylesheet = 65, | ||
Subsection = 66, | ||
SuccessorVersion = 67, | ||
Tag = 68, | ||
TermsOfService = 69, | ||
Timegate = 70, | ||
Timemap = 71, | ||
Type = 72, | ||
Up = 73, | ||
VersionHistory = 74, | ||
Via = 75, | ||
WorkingCopy = 76, | ||
WorkingCopyOf = 77, | ||
} | ||
@@ -92,2 +92,3 @@ export declare type Rel = string | LinkRelation; | ||
const Curies: string; | ||
function stringify(rel: Rel): string; | ||
} | ||
@@ -94,0 +95,0 @@ export declare namespace Hal { |
"use strict"; | ||
(function (Method) { | ||
Method[Method["GET"] = 0] = "GET"; | ||
Method[Method["PUT"] = 1] = "PUT"; | ||
Method[Method["POST"] = 2] = "POST"; | ||
Method[Method["DELETE"] = 3] = "DELETE"; | ||
Method[Method["PATCH"] = 4] = "PATCH"; | ||
Method[Method["GET"] = 1] = "GET"; | ||
Method[Method["PUT"] = 2] = "PUT"; | ||
Method[Method["POST"] = 3] = "POST"; | ||
Method[Method["DELETE"] = 4] = "DELETE"; | ||
Method[Method["PATCH"] = 5] = "PATCH"; | ||
})(exports.Method || (exports.Method = {})); | ||
@@ -12,79 +12,79 @@ var Method = exports.Method; | ||
(function (LinkRelation) { | ||
LinkRelation[LinkRelation["About"] = 0] = "About"; | ||
LinkRelation[LinkRelation["Alternate"] = 1] = "Alternate"; | ||
LinkRelation[LinkRelation["Appendix"] = 2] = "Appendix"; | ||
LinkRelation[LinkRelation["Archives"] = 3] = "Archives"; | ||
LinkRelation[LinkRelation["Author"] = 4] = "Author"; | ||
LinkRelation[LinkRelation["BlockedBy"] = 5] = "BlockedBy"; | ||
LinkRelation[LinkRelation["Bookmark"] = 6] = "Bookmark"; | ||
LinkRelation[LinkRelation["Canonical"] = 7] = "Canonical"; | ||
LinkRelation[LinkRelation["Chapter"] = 8] = "Chapter"; | ||
LinkRelation[LinkRelation["Collection"] = 9] = "Collection"; | ||
LinkRelation[LinkRelation["Contents"] = 10] = "Contents"; | ||
LinkRelation[LinkRelation["Copyright"] = 11] = "Copyright"; | ||
LinkRelation[LinkRelation["CreateForm"] = 12] = "CreateForm"; | ||
LinkRelation[LinkRelation["Current"] = 13] = "Current"; | ||
LinkRelation[LinkRelation["Derivedfrom"] = 14] = "Derivedfrom"; | ||
LinkRelation[LinkRelation["Describedby"] = 15] = "Describedby"; | ||
LinkRelation[LinkRelation["Describes"] = 16] = "Describes"; | ||
LinkRelation[LinkRelation["Disclosure"] = 17] = "Disclosure"; | ||
LinkRelation[LinkRelation["DnsPrefetch"] = 18] = "DnsPrefetch"; | ||
LinkRelation[LinkRelation["Duplicate"] = 19] = "Duplicate"; | ||
LinkRelation[LinkRelation["Edit"] = 20] = "Edit"; | ||
LinkRelation[LinkRelation["EditForm"] = 21] = "EditForm"; | ||
LinkRelation[LinkRelation["EditMedia"] = 22] = "EditMedia"; | ||
LinkRelation[LinkRelation["Enclosure"] = 23] = "Enclosure"; | ||
LinkRelation[LinkRelation["First"] = 24] = "First"; | ||
LinkRelation[LinkRelation["Glossary"] = 25] = "Glossary"; | ||
LinkRelation[LinkRelation["Help"] = 26] = "Help"; | ||
LinkRelation[LinkRelation["Hosts"] = 27] = "Hosts"; | ||
LinkRelation[LinkRelation["Hub"] = 28] = "Hub"; | ||
LinkRelation[LinkRelation["Icon"] = 29] = "Icon"; | ||
LinkRelation[LinkRelation["Index"] = 30] = "Index"; | ||
LinkRelation[LinkRelation["Item"] = 31] = "Item"; | ||
LinkRelation[LinkRelation["Last"] = 32] = "Last"; | ||
LinkRelation[LinkRelation["LatestVersion"] = 33] = "LatestVersion"; | ||
LinkRelation[LinkRelation["License"] = 34] = "License"; | ||
LinkRelation[LinkRelation["Lrdd"] = 35] = "Lrdd"; | ||
LinkRelation[LinkRelation["Memento"] = 36] = "Memento"; | ||
LinkRelation[LinkRelation["Monitor"] = 37] = "Monitor"; | ||
LinkRelation[LinkRelation["MonitorGroup"] = 38] = "MonitorGroup"; | ||
LinkRelation[LinkRelation["Next"] = 39] = "Next"; | ||
LinkRelation[LinkRelation["NextArchive"] = 40] = "NextArchive"; | ||
LinkRelation[LinkRelation["Nofollow"] = 41] = "Nofollow"; | ||
LinkRelation[LinkRelation["Noreferrer"] = 42] = "Noreferrer"; | ||
LinkRelation[LinkRelation["Original"] = 43] = "Original"; | ||
LinkRelation[LinkRelation["Payment"] = 44] = "Payment"; | ||
LinkRelation[LinkRelation["Pingback"] = 45] = "Pingback"; | ||
LinkRelation[LinkRelation["Preconnect"] = 46] = "Preconnect"; | ||
LinkRelation[LinkRelation["PredecessorVersion"] = 47] = "PredecessorVersion"; | ||
LinkRelation[LinkRelation["Prefetch"] = 48] = "Prefetch"; | ||
LinkRelation[LinkRelation["Preload"] = 49] = "Preload"; | ||
LinkRelation[LinkRelation["Prerender"] = 50] = "Prerender"; | ||
LinkRelation[LinkRelation["Prev"] = 51] = "Prev"; | ||
LinkRelation[LinkRelation["Preview"] = 52] = "Preview"; | ||
LinkRelation[LinkRelation["Previous"] = 53] = "Previous"; | ||
LinkRelation[LinkRelation["PrevArchive"] = 54] = "PrevArchive"; | ||
LinkRelation[LinkRelation["PrivacyPolicy"] = 55] = "PrivacyPolicy"; | ||
LinkRelation[LinkRelation["Profile"] = 56] = "Profile"; | ||
LinkRelation[LinkRelation["Related"] = 57] = "Related"; | ||
LinkRelation[LinkRelation["Replies"] = 58] = "Replies"; | ||
LinkRelation[LinkRelation["Search"] = 59] = "Search"; | ||
LinkRelation[LinkRelation["Section"] = 60] = "Section"; | ||
LinkRelation[LinkRelation["Self"] = 61] = "Self"; | ||
LinkRelation[LinkRelation["Service"] = 62] = "Service"; | ||
LinkRelation[LinkRelation["Start"] = 63] = "Start"; | ||
LinkRelation[LinkRelation["Stylesheet"] = 64] = "Stylesheet"; | ||
LinkRelation[LinkRelation["Subsection"] = 65] = "Subsection"; | ||
LinkRelation[LinkRelation["SuccessorVersion"] = 66] = "SuccessorVersion"; | ||
LinkRelation[LinkRelation["Tag"] = 67] = "Tag"; | ||
LinkRelation[LinkRelation["TermsOfService"] = 68] = "TermsOfService"; | ||
LinkRelation[LinkRelation["Timegate"] = 69] = "Timegate"; | ||
LinkRelation[LinkRelation["Timemap"] = 70] = "Timemap"; | ||
LinkRelation[LinkRelation["Type"] = 71] = "Type"; | ||
LinkRelation[LinkRelation["Up"] = 72] = "Up"; | ||
LinkRelation[LinkRelation["VersionHistory"] = 73] = "VersionHistory"; | ||
LinkRelation[LinkRelation["Via"] = 74] = "Via"; | ||
LinkRelation[LinkRelation["WorkingCopy"] = 75] = "WorkingCopy"; | ||
LinkRelation[LinkRelation["WorkingCopyOf"] = 76] = "WorkingCopyOf"; | ||
LinkRelation[LinkRelation["About"] = 1] = "About"; | ||
LinkRelation[LinkRelation["Alternate"] = 2] = "Alternate"; | ||
LinkRelation[LinkRelation["Appendix"] = 3] = "Appendix"; | ||
LinkRelation[LinkRelation["Archives"] = 4] = "Archives"; | ||
LinkRelation[LinkRelation["Author"] = 5] = "Author"; | ||
LinkRelation[LinkRelation["BlockedBy"] = 6] = "BlockedBy"; | ||
LinkRelation[LinkRelation["Bookmark"] = 7] = "Bookmark"; | ||
LinkRelation[LinkRelation["Canonical"] = 8] = "Canonical"; | ||
LinkRelation[LinkRelation["Chapter"] = 9] = "Chapter"; | ||
LinkRelation[LinkRelation["Collection"] = 10] = "Collection"; | ||
LinkRelation[LinkRelation["Contents"] = 11] = "Contents"; | ||
LinkRelation[LinkRelation["Copyright"] = 12] = "Copyright"; | ||
LinkRelation[LinkRelation["CreateForm"] = 13] = "CreateForm"; | ||
LinkRelation[LinkRelation["Current"] = 14] = "Current"; | ||
LinkRelation[LinkRelation["Derivedfrom"] = 15] = "Derivedfrom"; | ||
LinkRelation[LinkRelation["Describedby"] = 16] = "Describedby"; | ||
LinkRelation[LinkRelation["Describes"] = 17] = "Describes"; | ||
LinkRelation[LinkRelation["Disclosure"] = 18] = "Disclosure"; | ||
LinkRelation[LinkRelation["DnsPrefetch"] = 19] = "DnsPrefetch"; | ||
LinkRelation[LinkRelation["Duplicate"] = 20] = "Duplicate"; | ||
LinkRelation[LinkRelation["Edit"] = 21] = "Edit"; | ||
LinkRelation[LinkRelation["EditForm"] = 22] = "EditForm"; | ||
LinkRelation[LinkRelation["EditMedia"] = 23] = "EditMedia"; | ||
LinkRelation[LinkRelation["Enclosure"] = 24] = "Enclosure"; | ||
LinkRelation[LinkRelation["First"] = 25] = "First"; | ||
LinkRelation[LinkRelation["Glossary"] = 26] = "Glossary"; | ||
LinkRelation[LinkRelation["Help"] = 27] = "Help"; | ||
LinkRelation[LinkRelation["Hosts"] = 28] = "Hosts"; | ||
LinkRelation[LinkRelation["Hub"] = 29] = "Hub"; | ||
LinkRelation[LinkRelation["Icon"] = 30] = "Icon"; | ||
LinkRelation[LinkRelation["Index"] = 31] = "Index"; | ||
LinkRelation[LinkRelation["Item"] = 32] = "Item"; | ||
LinkRelation[LinkRelation["Last"] = 33] = "Last"; | ||
LinkRelation[LinkRelation["LatestVersion"] = 34] = "LatestVersion"; | ||
LinkRelation[LinkRelation["License"] = 35] = "License"; | ||
LinkRelation[LinkRelation["Lrdd"] = 36] = "Lrdd"; | ||
LinkRelation[LinkRelation["Memento"] = 37] = "Memento"; | ||
LinkRelation[LinkRelation["Monitor"] = 38] = "Monitor"; | ||
LinkRelation[LinkRelation["MonitorGroup"] = 39] = "MonitorGroup"; | ||
LinkRelation[LinkRelation["Next"] = 40] = "Next"; | ||
LinkRelation[LinkRelation["NextArchive"] = 41] = "NextArchive"; | ||
LinkRelation[LinkRelation["Nofollow"] = 42] = "Nofollow"; | ||
LinkRelation[LinkRelation["Noreferrer"] = 43] = "Noreferrer"; | ||
LinkRelation[LinkRelation["Original"] = 44] = "Original"; | ||
LinkRelation[LinkRelation["Payment"] = 45] = "Payment"; | ||
LinkRelation[LinkRelation["Pingback"] = 46] = "Pingback"; | ||
LinkRelation[LinkRelation["Preconnect"] = 47] = "Preconnect"; | ||
LinkRelation[LinkRelation["PredecessorVersion"] = 48] = "PredecessorVersion"; | ||
LinkRelation[LinkRelation["Prefetch"] = 49] = "Prefetch"; | ||
LinkRelation[LinkRelation["Preload"] = 50] = "Preload"; | ||
LinkRelation[LinkRelation["Prerender"] = 51] = "Prerender"; | ||
LinkRelation[LinkRelation["Prev"] = 52] = "Prev"; | ||
LinkRelation[LinkRelation["Preview"] = 53] = "Preview"; | ||
LinkRelation[LinkRelation["Previous"] = 54] = "Previous"; | ||
LinkRelation[LinkRelation["PrevArchive"] = 55] = "PrevArchive"; | ||
LinkRelation[LinkRelation["PrivacyPolicy"] = 56] = "PrivacyPolicy"; | ||
LinkRelation[LinkRelation["Profile"] = 57] = "Profile"; | ||
LinkRelation[LinkRelation["Related"] = 58] = "Related"; | ||
LinkRelation[LinkRelation["Replies"] = 59] = "Replies"; | ||
LinkRelation[LinkRelation["Search"] = 60] = "Search"; | ||
LinkRelation[LinkRelation["Section"] = 61] = "Section"; | ||
LinkRelation[LinkRelation["Self"] = 62] = "Self"; | ||
LinkRelation[LinkRelation["Service"] = 63] = "Service"; | ||
LinkRelation[LinkRelation["Start"] = 64] = "Start"; | ||
LinkRelation[LinkRelation["Stylesheet"] = 65] = "Stylesheet"; | ||
LinkRelation[LinkRelation["Subsection"] = 66] = "Subsection"; | ||
LinkRelation[LinkRelation["SuccessorVersion"] = 67] = "SuccessorVersion"; | ||
LinkRelation[LinkRelation["Tag"] = 68] = "Tag"; | ||
LinkRelation[LinkRelation["TermsOfService"] = 69] = "TermsOfService"; | ||
LinkRelation[LinkRelation["Timegate"] = 70] = "Timegate"; | ||
LinkRelation[LinkRelation["Timemap"] = 71] = "Timemap"; | ||
LinkRelation[LinkRelation["Type"] = 72] = "Type"; | ||
LinkRelation[LinkRelation["Up"] = 73] = "Up"; | ||
LinkRelation[LinkRelation["VersionHistory"] = 74] = "VersionHistory"; | ||
LinkRelation[LinkRelation["Via"] = 75] = "Via"; | ||
LinkRelation[LinkRelation["WorkingCopy"] = 76] = "WorkingCopy"; | ||
LinkRelation[LinkRelation["WorkingCopyOf"] = 77] = "WorkingCopyOf"; | ||
})(exports.LinkRelation || (exports.LinkRelation = {})); | ||
@@ -96,3 +96,7 @@ var LinkRelation = exports.LinkRelation; | ||
Rel.Curies = 'curies'; | ||
function stringify(rel) { | ||
return typeof rel === 'string' ? rel : LinkRelation[rel].replace(/([A-Z])/g, '-$1').toLowerCase().substring(1); | ||
} | ||
Rel.stringify = stringify; | ||
})(Rel = exports.Rel || (exports.Rel = {})); | ||
//# sourceMappingURL=constants.js.map |
@@ -7,7 +7,4 @@ import * as express from 'express'; | ||
namespace Options { | ||
interface Rel { | ||
interface Rel extends hal.Metadata { | ||
discoverable?: boolean; | ||
params?: any; | ||
id?: string; | ||
title?: string; | ||
description?: string; | ||
@@ -27,12 +24,14 @@ } | ||
} | ||
interface Overrides { | ||
rel?: Rel; | ||
href?: string; | ||
interface Metadata { | ||
params?: any; | ||
server?: Object; | ||
array?: boolean; | ||
links?: Rel[]; | ||
id?: string; | ||
title?: string; | ||
} | ||
interface Overrides extends Metadata { | ||
rel?: Rel; | ||
href?: string; | ||
server?: Object; | ||
links?: Rel[]; | ||
} | ||
interface Response { | ||
@@ -39,0 +38,0 @@ link(rel: Rel, overrides?: Overrides): void; |
"use strict"; | ||
const server_1 = require('./server'); | ||
const constants_1 = require('./constants'); | ||
function provides(rel, options) { | ||
return function (target, methodName, descriptor) { | ||
if (target instanceof Function) { | ||
server_1.Server.api(true, target.prototype).provides(rel && rel.toString(), options); | ||
server_1.Server.api(true, target.prototype).provides(rel && constants_1.Rel.stringify(rel), options); | ||
return target; | ||
@@ -8,0 +9,0 @@ } |
@@ -8,3 +8,3 @@ import { Rel } from './constants'; | ||
handle<T>(base: Object, rel: Rel, callback: (server: Object, route: string, links: hal.Overrides[]) => T): T[]; | ||
normalize(base: Object, rel: Rel): string; | ||
normalize(base: Object, rel: Rel): Rel; | ||
getDocs(base: Object, rel: Rel): Linker.Docs; | ||
@@ -11,0 +11,0 @@ getLinks(base: Object, rel: Rel): hal.Overrides[]; |
"use strict"; | ||
const constants_1 = require('./constants'); | ||
function first(items, property) { | ||
@@ -21,9 +20,4 @@ const first = items.find(value => typeof value[property] !== 'undefined'); | ||
} | ||
else { | ||
return callback(base, parts[1], ''); | ||
} | ||
} | ||
else { | ||
return callback(base, constants_1.LinkRelation[rel], undefined); | ||
} | ||
return callback(base, rel, ''); | ||
} | ||
@@ -39,14 +33,7 @@ handle(base, rel, callback) { | ||
normalize(base, rel) { | ||
return this.parse(base, rel, (server, parsed, ns) => { | ||
return typeof ns === 'string' ? parsed : | ||
parsed.replace(/([A-Z])/g, '-$1').toLowerCase().substring(1); | ||
}); | ||
return this.parse(base, rel, (server, parsed) => parsed); | ||
} | ||
getDocs(base, rel) { | ||
return this.parse(base, rel, (server, parsed, ns) => { | ||
const namespace = ns || ''; | ||
return Data.from(server).docsCb({ | ||
name: namespace, | ||
href: namespace && Data.from(server).docs[namespace].href | ||
}); | ||
return Data.from(server).docsCb(Data.from(server).docs[ns] || { name: '', href: '' }); | ||
}); | ||
@@ -61,2 +48,3 @@ } | ||
links: Array.from(new Set(links.reduce((links, link) => links.concat(link.links || []), []))), | ||
array: links.reduce((array, link) => link.array || array, false), | ||
id: first(links, 'id'), | ||
@@ -81,3 +69,3 @@ title: first(links, 'title'), | ||
href, | ||
rel: typeof ns === 'string' ? parsed : rel | ||
rel: parsed | ||
}, overrides)); | ||
@@ -84,0 +72,0 @@ }); |
@@ -81,8 +81,9 @@ "use strict"; | ||
if (resolved.rel && resolved.href) { | ||
let str = constants_1.Rel.stringify(resolved.rel); | ||
_private(this).docs(resolved); | ||
_private(this).hal.addLink(resolved.rel.toString(), template_1.Template.link(resolved)); | ||
ensureArray(_private(this).hal._links, resolved.rel, overrides.array); | ||
_private(this).hal.addLink(str, template_1.Template.link(resolved)); | ||
ensureArray(_private(this).hal._links, str, resolved.array); | ||
} | ||
else { | ||
console.error(`Cannot find rel: ${server_1.Server.linker.normalize(_private(this).server, rel)}`); | ||
console.error(`Cannot find rel: ${constants_1.Rel.stringify(server_1.Server.linker.normalize(_private(this).server, rel))}`); | ||
} | ||
@@ -94,6 +95,7 @@ }); | ||
if (resolved.rel) { | ||
let str = constants_1.Rel.stringify(resolved.rel); | ||
let resource = Response.resource(resolved, _private(this).root, value); | ||
_private(this).docs(resolved); | ||
_private(this).hal.addEmbed(resolved.rel.toString(), _private(resource).hal); | ||
ensureArray(_private(this).hal._embedded, resolved.rel, overrides.array); | ||
_private(this).hal.addEmbed(str, _private(resource).hal); | ||
ensureArray(_private(this).hal._embedded, str, resolved.array); | ||
return resource; | ||
@@ -100,0 +102,0 @@ } |
57866
154
996