Skip to content

Commit

Permalink
resource services as IService
Browse files Browse the repository at this point in the history
  • Loading branch information
edsilv committed Jul 31, 2015
1 parent befef96 commit 916e0d6
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "manifesto",
"version": "0.1.6",
"version": "0.1.7",
"homepage": "https://github.com/edsilv/manifesto",
"authors": [
"edsilv <[email protected]>"
Expand Down
10 changes: 5 additions & 5 deletions dist/client/manifesto.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,8 @@ var Manifesto;
resolve(clickThrough(resource));
}
else {
login(resource.loginService).then(function () {
getAccessToken(resource.tokenService).then(function (token) {
login(resource.loginService.id).then(function () {
getAccessToken(resource.tokenService.id).then(function (token) {
resource.getData(token).then(function () {
resolve(handleResourceResponse(resource));
});
Expand Down Expand Up @@ -629,7 +629,7 @@ var Manifesto;
return new Promise(function (resolve, reject) {
resource.getData().then(function () {
if (resource.isAccessControlled) {
getStoredAccessToken(resource.tokenService).then(function (storedAccessToken) {
getStoredAccessToken(resource.tokenService.id).then(function (storedAccessToken) {
if (storedAccessToken) {
// try using the stored access token
resource.getData(storedAccessToken).then(function () {
Expand All @@ -643,8 +643,8 @@ var Manifesto;
}
else {
// get an access token
login(resource.loginService).then(function () {
getAccessToken(resource.tokenService).then(function (accessToken) {
login(resource.loginService.id).then(function () {
getAccessToken(resource.tokenService.id).then(function (accessToken) {
storeAccessToken(resource, accessToken).then(function () {
resource.getData(accessToken).then(function () {
resolve(resource);
Expand Down
18 changes: 9 additions & 9 deletions dist/manifesto.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ declare module Manifesto {
getTree(): TreeNode;
private _parseTreeNode(node, range);
isMultiSequence(): boolean;
loadResource(resource: IResource, clickThrough: (resource: IResource) => void, login: (loginService: string) => Promise<void>, getAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>, storeAccessToken: (resource: IResource, token: IAccessToken) => Promise<void>, getStoredAccessToken: (tokenService: string) => Promise<IAccessToken>, handleResourceResponse: (resource: IResource) => Promise<any>): Promise<any>;
authorize(resource: IResource, clickThrough: (resource: IResource) => void, login: (loginService: string) => Promise<void>, getAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>, storeAccessToken: (resource: IResource, token: IAccessToken) => Promise<void>, getStoredAccessToken: (tokenService: string) => Promise<IAccessToken>): Promise<IResource>;
loadResources(resources: IResource[], clickThrough: (resource: IResource) => void, login: (loginService: string) => Promise<void>, getAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>, storeAccessToken: (resource: IResource, token: IAccessToken) => Promise<void>, getStoredAccessToken: (tokenService: string) => Promise<IAccessToken>, handleResourceResponse: (resource: IResource) => Promise<any>): Promise<IResource[]>;
loadResource(resource: IResource, clickThrough: (resource: IResource) => void, login: (loginServiceUrl: string) => Promise<void>, getAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>, storeAccessToken: (resource: IResource, token: IAccessToken) => Promise<void>, getStoredAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>, handleResourceResponse: (resource: IResource) => Promise<any>): Promise<any>;
authorize(resource: IResource, clickThrough: (resource: IResource) => void, login: (loginServiceUrl: string) => Promise<void>, getAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>, storeAccessToken: (resource: IResource, token: IAccessToken) => Promise<void>, getStoredAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>): Promise<IResource>;
loadResources(resources: IResource[], clickThrough: (resource: IResource) => void, login: (loginServiceUrl: string) => Promise<void>, getAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>, storeAccessToken: (resource: IResource, token: IAccessToken) => Promise<void>, getStoredAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>, handleResourceResponse: (resource: IResource) => Promise<any>): Promise<IResource[]>;
}
}
declare module Manifesto {
Expand Down Expand Up @@ -300,8 +300,8 @@ declare module Manifesto {
getTotalSequences(): number;
getTree(): TreeNode;
isMultiSequence(): boolean;
loadResource(resource: IResource, clickThrough: (resource: IResource) => void, login: (loginService: string) => Promise<void>, getAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>, storeAccessToken: (resource: IResource, token: IAccessToken) => Promise<void>, getStoredAccessToken: (tokenService: string) => Promise<IAccessToken>, handleResourceResponse: (resource: IResource) => Promise<any>): Promise<IResource>;
loadResources(resources: IResource[], clickThrough: (resource: IResource) => void, login: (loginService: string) => Promise<void>, getAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>, storeAccessToken: (resource: IResource, token: IAccessToken) => Promise<void>, getStoredAccessToken: (tokenService: string) => Promise<IAccessToken>, handleResourceResponse: (resource: IResource) => Promise<any>): Promise<IResource[]>;
loadResource(resource: IResource, clickThrough: (resource: IResource) => void, login: (loginServiceUrl: string) => Promise<void>, getAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>, storeAccessToken: (resource: IResource, token: IAccessToken) => Promise<void>, getStoredAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>, handleResourceResponse: (resource: IResource) => Promise<any>): Promise<IResource>;
loadResources(resources: IResource[], clickThrough: (resource: IResource) => void, login: (loginServiceUrl: string) => Promise<void>, getAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>, storeAccessToken: (resource: IResource, token: IAccessToken) => Promise<void>, getStoredAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>, handleResourceResponse: (resource: IResource) => Promise<any>): Promise<IResource[]>;
options: IManifestoOptions;
rootRange: IRange;
sequences: ISequence[];
Expand Down Expand Up @@ -343,15 +343,15 @@ declare module Manifesto {
}
declare module Manifesto {
interface IResource {
clickThroughService: string;
clickThroughService: IService;
data: any;
dataUri: string;
error: any;
isAccessControlled: boolean;
loginService: string;
logoutService: string;
loginService: IService;
logoutService: IService;
status: number;
tokenService: string;
tokenService: IService;
getData(accessToken?: IAccessToken): Promise<IResource>;
}
}
Expand Down
10 changes: 5 additions & 5 deletions dist/server/manifesto.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,8 @@ var Manifesto;
resolve(clickThrough(resource));
}
else {
login(resource.loginService).then(function () {
getAccessToken(resource.tokenService).then(function (token) {
login(resource.loginService.id).then(function () {
getAccessToken(resource.tokenService.id).then(function (token) {
resource.getData(token).then(function () {
resolve(handleResourceResponse(resource));
});
Expand Down Expand Up @@ -628,7 +628,7 @@ var Manifesto;
return new Promise(function (resolve, reject) {
resource.getData().then(function () {
if (resource.isAccessControlled) {
getStoredAccessToken(resource.tokenService).then(function (storedAccessToken) {
getStoredAccessToken(resource.tokenService.id).then(function (storedAccessToken) {
if (storedAccessToken) {
// try using the stored access token
resource.getData(storedAccessToken).then(function () {
Expand All @@ -642,8 +642,8 @@ var Manifesto;
}
else {
// get an access token
login(resource.loginService).then(function () {
getAccessToken(resource.tokenService).then(function (accessToken) {
login(resource.loginService.id).then(function () {
getAccessToken(resource.tokenService.id).then(function (accessToken) {
storeAccessToken(resource, accessToken).then(function () {
resource.getData(accessToken).then(function () {
resolve(resource);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "manifesto",
"version": "0.1.6",
"version": "0.1.7",
"description": "IIIF Presentation API utility library for client and server",
"main": "dist/server/manifesto.js",
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions src/IManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ module Manifesto {
isMultiSequence(): boolean;
loadResource(resource: IResource,
clickThrough: (resource: IResource) => void,
login: (loginService: string) => Promise<void>,
login: (loginServiceUrl: string) => Promise<void>,
getAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>,
storeAccessToken: (resource: IResource, token: IAccessToken) => Promise<void>,
getStoredAccessToken: (tokenService: string) => Promise<IAccessToken>,
getStoredAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>,
handleResourceResponse: (resource: IResource) => Promise<any>): Promise<IResource>;
loadResources(resources: IResource[],
clickThrough: (resource: IResource) => void,
login: (loginService: string) => Promise<void>,
login: (loginServiceUrl: string) => Promise<void>,
getAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>,
storeAccessToken: (resource: IResource, token: IAccessToken) => Promise<void>,
getStoredAccessToken: (tokenService: string) => Promise<IAccessToken>,
getStoredAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>,
handleResourceResponse: (resource: IResource) => Promise<any>): Promise<IResource[]>;
options: IManifestoOptions;
rootRange: IRange;
Expand Down
8 changes: 4 additions & 4 deletions src/IResource.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module Manifesto {
export interface IResource {
clickThroughService: string;
clickThroughService: IService;
data: any;
dataUri: string;
error: any;
isAccessControlled: boolean;
loginService: string;
logoutService: string;
loginService: IService;
logoutService: IService;
status: number;
tokenService: string;
tokenService: IService;

getData(accessToken?: IAccessToken): Promise<IResource>;
}
Expand Down
22 changes: 11 additions & 11 deletions src/Manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,10 @@ module Manifesto {

loadResource(resource: IResource,
clickThrough: (resource: IResource) => void,
login: (loginService: string) => Promise<void>,
login: (loginServiceUrl: string) => Promise<void>,
getAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>,
storeAccessToken: (resource: IResource, token: IAccessToken) => Promise<void>,
getStoredAccessToken: (tokenService: string) => Promise<IAccessToken>,
getStoredAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>,
handleResourceResponse: (resource: IResource) => Promise<any>): Promise<any> {

var options: IManifestoOptions = this.options;
Expand All @@ -341,8 +341,8 @@ module Manifesto {
if (resource.clickThroughService){
resolve(clickThrough(resource));
} else {
login(resource.loginService).then(() => {
getAccessToken(resource.tokenService).then((token: IAccessToken) => {
login(resource.loginService.id).then(() => {
getAccessToken(resource.tokenService.id).then((token: IAccessToken) => {
resource.getData(token).then(() => {
resolve(handleResourceResponse(resource));
});
Expand Down Expand Up @@ -407,16 +407,16 @@ module Manifesto {

authorize(resource: IResource,
clickThrough: (resource: IResource) => void,
login: (loginService: string) => Promise<void>,
login: (loginServiceUrl: string) => Promise<void>,
getAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>,
storeAccessToken: (resource: IResource, token: IAccessToken) => Promise<void>,
getStoredAccessToken: (tokenService: string) => Promise<IAccessToken>): Promise<IResource> {
getStoredAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>): Promise<IResource> {

return new Promise<IResource>((resolve, reject) => {

resource.getData().then(() => {
if (resource.isAccessControlled) {
getStoredAccessToken(resource.tokenService).then((storedAccessToken: IAccessToken) => {
getStoredAccessToken(resource.tokenService.id).then((storedAccessToken: IAccessToken) => {
if (storedAccessToken) {
// try using the stored access token
resource.getData(storedAccessToken).then(() => {
Expand All @@ -428,8 +428,8 @@ module Manifesto {
clickThrough(resource);
} else {
// get an access token
login(resource.loginService).then(() => {
getAccessToken(resource.tokenService).then((accessToken) => {
login(resource.loginService.id).then(() => {
getAccessToken(resource.tokenService.id).then((accessToken) => {
storeAccessToken(resource, accessToken).then(() => {
resource.getData(accessToken).then(() => {
resolve(resource);
Expand All @@ -450,10 +450,10 @@ module Manifesto {

loadResources(resources: IResource[],
clickThrough: (resource: IResource) => void,
login: (loginService: string) => Promise<void>,
login: (loginServiceUrl: string) => Promise<void>,
getAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>,
storeAccessToken: (resource: IResource, token: IAccessToken) => Promise<void>,
getStoredAccessToken: (tokenService: string) => Promise<IAccessToken>,
getStoredAccessToken: (tokenServiceUrl: string) => Promise<IAccessToken>,
handleResourceResponse: (resource: IResource) => Promise<any>): Promise<IResource[]> {

var that = this;
Expand Down

0 comments on commit 916e0d6

Please sign in to comment.