-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
86 changed files
with
2,156 additions
and
2,188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,75 @@ | ||
/* eslint-disable @typescript-eslint/no-namespace,no-inner-declarations */ | ||
// tslint:disable:no-namespace object-literal-sort-keys | ||
|
||
export type HydraTerm = 'apiDocumentation' | | ||
'ApiDocumentation' | | ||
'title' | | ||
'description' | | ||
'method' | | ||
'Class' | | ||
'member' | | ||
'PartialCollectionView' | | ||
'Collection' | | ||
'view' | | ||
'first' | | ||
'next' | | ||
'last' | | ||
'previous' | | ||
'entrypoint' | | ||
'SupportedProperty' | | ||
'supportedProperty' | | ||
'SupportedOperation' | | ||
'supportedClass' | | ||
'supportedOperation' | | ||
'expects' | | ||
'returns' | | ||
'readable' | | ||
'writable' | | ||
'required' | | ||
'property' | | ||
'statusCodes' | | ||
'operation' | | ||
'Operation' | | ||
'mapping' | | ||
'StatusCodeDescription' | | ||
'IriTemplate' | | ||
'IriTemplateMapping' | | ||
'code' | | ||
'variable' | | ||
'variableRepresentation' | | ||
'template' | | ||
'BasicRepresentation' | | ||
'ExplicitRepresentation' | | ||
'totalItems' | | ||
'Link' | | ||
'collection' | | ||
'manages' | | ||
'subject' | | ||
'object' | | ||
'search'; | ||
'ApiDocumentation' | | ||
'title' | | ||
'description' | | ||
'method' | | ||
'Class' | | ||
'member' | | ||
'PartialCollectionView' | | ||
'Collection' | | ||
'view' | | ||
'first' | | ||
'next' | | ||
'last' | | ||
'previous' | | ||
'entrypoint' | | ||
'SupportedProperty' | | ||
'supportedProperty' | | ||
'SupportedOperation' | | ||
'supportedClass' | | ||
'supportedOperation' | | ||
'expects' | | ||
'returns' | | ||
'readable' | | ||
'writable' | | ||
'required' | | ||
'property' | | ||
'statusCodes' | | ||
'operation' | | ||
'Operation' | | ||
'mapping' | | ||
'StatusCodeDescription' | | ||
'IriTemplate' | | ||
'IriTemplateMapping' | | ||
'code' | | ||
'variable' | | ||
'variableRepresentation' | | ||
'template' | | ||
'BasicRepresentation' | | ||
'ExplicitRepresentation' | | ||
'totalItems' | | ||
'Link' | | ||
'collection' | | ||
'manages' | | ||
'subject' | | ||
'object' | | ||
'search'; | ||
|
||
export namespace Core { | ||
export function Vocab(term?: HydraTerm) { | ||
return 'http://www.w3.org/ns/hydra/core#' + (term || ''); | ||
export function Vocab (term?: HydraTerm) { | ||
return 'http://www.w3.org/ns/hydra/core#' + (term || '') | ||
} | ||
} | ||
|
||
export namespace JsonLd { | ||
export let Graph = '@graph'; | ||
export const Context = '@context'; | ||
export let Id = '@id'; | ||
export let Value = '@value'; | ||
export let Type = '@type'; | ||
export let Language = '@language'; | ||
export let Graph = '@graph' | ||
export const Context = '@context' | ||
export let Id = '@id' | ||
export let Value = '@value' | ||
export let Type = '@type' | ||
export let Language = '@language' | ||
} | ||
|
||
export namespace MediaTypes { | ||
export let jsonLd = 'application/ld+json'; | ||
export let ntriples = 'application/n-triples'; | ||
export let nquads = 'application/n-quads'; | ||
export let jsonLd = 'application/ld+json' | ||
export let ntriples = 'application/n-triples' | ||
export let nquads = 'application/n-quads' | ||
} | ||
|
||
export namespace Headers { | ||
export let Link = 'Link'; | ||
export let ContentType = 'Content-Type'; | ||
export let Link = 'Link' | ||
export let ContentType = 'Content-Type' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,33 @@ | ||
import 'isomorphic-fetch'; | ||
import * as Constants from './Constants'; | ||
import {ResponseWrapper} from './ResponseWrapper'; | ||
import 'isomorphic-fetch' | ||
import * as Constants from './Constants' | ||
import { ResponseWrapper } from './ResponseWrapper' | ||
|
||
// tslint:disable:max-line-length | ||
const requestAcceptHeaders = Constants.MediaTypes.jsonLd + ', ' + Constants.MediaTypes.ntriples + ', ' + Constants.MediaTypes.nquads; | ||
const requestAcceptHeaders = Constants.MediaTypes.jsonLd + ', ' + Constants.MediaTypes.ntriples + ', ' + Constants.MediaTypes.nquads | ||
|
||
export async function fetchResource(uri: string): Promise<ResponseWrapper> { | ||
export async function fetchResource (uri: string): Promise<ResponseWrapper> { | ||
const res = await fetch(uri, { | ||
headers: new Headers({ | ||
accept: requestAcceptHeaders, | ||
}), | ||
}); | ||
}) | ||
|
||
return new ResponseWrapper(uri, res); | ||
return new ResponseWrapper(uri, res) | ||
} | ||
|
||
export async function invokeOperation( | ||
export async function invokeOperation ( | ||
method: string, | ||
uri: string, | ||
body?: BodyInit, | ||
mediaType = Constants.MediaTypes.jsonLd): Promise<ResponseWrapper> { | ||
|
||
const res = await fetch(uri, { | ||
body, | ||
headers: new Headers({ | ||
'Accept': requestAcceptHeaders, | ||
'Content-Type': mediaType, | ||
}), | ||
method, | ||
}); | ||
}) | ||
|
||
return new ResponseWrapper(uri, res); | ||
return new ResponseWrapper(uri, res) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
export class JsonLdUtil { | ||
public static trimTrailingSlash(uri: string): string { | ||
public static trimTrailingSlash (uri: string): string { | ||
if (!uri || !uri.replace) { | ||
return null; | ||
return null | ||
} | ||
|
||
// todo: is this really correct to ignore trailing slash? | ||
return uri.replace(/\/$/, ''); | ||
return uri.replace(/\/$/, '') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
export function forOwn(obj: object, iteratee) { | ||
export function forOwn (obj: object, iteratee) { | ||
for (const key in obj) { | ||
if (!obj.hasOwnProperty(key)) { continue; } | ||
if (!Object.prototype.hasOwnProperty.call(obj, key)) { continue } | ||
|
||
iteratee(obj[key], key, obj); | ||
iteratee(obj[key], key, obj) | ||
} | ||
} | ||
|
||
export function values(obj: object): any[] { | ||
const result = []; | ||
export function values (obj: object): any[] { | ||
const result = [] | ||
|
||
forOwn(obj, (o) => { | ||
result.push(o); | ||
}); | ||
result.push(o) | ||
}) | ||
|
||
return result; | ||
return result | ||
} |
Oops, something went wrong.