-
-
Notifications
You must be signed in to change notification settings - Fork 132
type: change ResourceDescriptor and Link interfaces
#403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
554421e
d2af1f0
be98dc7
713ff70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ export interface ResourceDescriptor { | |
| /** | ||
| * Links to other resources. | ||
| */ | ||
| links?: Link[]; | ||
| links?: Array<Link | OStatusSubscribeLink>; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -44,7 +44,7 @@ export interface Link { | |
| /** | ||
| * A URI pointing to the target resource. | ||
| */ | ||
| href: string; | ||
| href?: string; | ||
|
dodok8 marked this conversation as resolved.
|
||
|
|
||
| /** | ||
| * Human-readable titles describing the link relation. If the language is | ||
|
|
@@ -57,3 +57,52 @@ export interface Link { | |
| */ | ||
| properties?: Record<string, string>; | ||
| } | ||
|
|
||
| /** | ||
| * References a link. See also | ||
| * [OStatus 1.0 Draft 2](https://www.w3.org/community/ostatus/wiki/images/9/93/OStatus_1.0_Draft_2.pdf) | ||
| */ | ||
| export interface OStatusSubscribeLink { | ||
| rel: "http://ostatus.org/schema/1.0/subscribe"; | ||
| /** | ||
| * A URI template (RFC 6570) that can be used to construct URIs by | ||
| * substituting variables. Used primarily for subscription endpoints | ||
| * where parameters like account URIs need to be dynamically inserted. | ||
| */ | ||
| template: string; | ||
| } | ||
|
dodok8 marked this conversation as resolved.
Comment on lines
+61
to
+73
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of declaring a separate
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This way seems right; however, this PR and branch are mainly about separating types, so I'll close this PR and make a new PR after adding the |
||
|
|
||
| export function isOStatusSubscribeLink( | ||
| link: Link | OStatusSubscribeLink, | ||
| ): link is OStatusSubscribeLink { | ||
| if ( | ||
| "template" in link && | ||
| link.rel === "http://ostatus.org/schema/1.0/subscribe" && | ||
| typeof link.template === "string" | ||
| ) return true; | ||
| return false; | ||
| } | ||
|
|
||
| isOStatusSubscribeLink.withCondition = ( | ||
| condition: (link: OStatusSubscribeLink) => boolean, | ||
| ) => | ||
| (link: Link | OStatusSubscribeLink): link is OStatusSubscribeLink => { | ||
| return isOStatusSubscribeLink(link) && condition(link); | ||
| }; | ||
|
|
||
| export function isLink( | ||
| link: Link | OStatusSubscribeLink, | ||
| ): link is Link { | ||
| if ( | ||
| "rel" in link && | ||
| typeof link.rel === "string" | ||
| ) return true; | ||
| return false; | ||
| } | ||
|
|
||
| isLink.withCondition = ( | ||
| condition: (link: Link) => boolean, | ||
| ) => | ||
| (link: Link | Link): link is Link => { | ||
| return isLink(link) && condition(link); | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.