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
1 parent
578c6d6
commit aee1ab8
Showing
7 changed files
with
268 additions
and
8 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
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import halfred from 'halfred'; | ||
|
||
import { getSchema } from '../../helper'; | ||
import ListResource from '../ListResource'; | ||
import EntryResource from './EntryResource'; | ||
|
||
/** | ||
* Entry list class | ||
* | ||
* @class | ||
*/ | ||
export default class EntryList extends ListResource { | ||
/** | ||
* Creates a new {@link EntryList}. | ||
* | ||
* @param {object} resource resource loaded from the API. | ||
* @param {string} environment the environment this resource is associated to. | ||
* @param {string} name name of the embedded items. | ||
* @param {object} schema JSON Schema for list items. | ||
* @param {object?} traversal traversal from which traverson can continue. | ||
*/ | ||
constructor(resource, environment, name, schema, traversal) { | ||
super(resource, environment, name, traversal, EntryList, EntryResource, schema); | ||
} | ||
} | ||
|
||
/** | ||
* Asynchronously create a new {@link EntryList}. This can be used when the schema is not known | ||
* before creating the EntryList. | ||
* | ||
* @param {object} resource loaded resource | ||
* @param {environment} environment the environment of this resource | ||
* @param {string} name name of the embedded items | ||
* @param {object?} traversal traversal for continuing | ||
* @returns {Promise<EntryResource>} {@link Promise} resolving to the newly created {@link | ||
* EntryResource} | ||
*/ | ||
export function create(resource, environment, name, traversal) { | ||
return Promise.resolve() | ||
.then(() => { | ||
const res = halfred.parse(resource); | ||
return getSchema(res.link('self').profile); | ||
}) | ||
.then(schema => new EntryList(resource, environment, name, schema, traversal)); | ||
} |
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
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,170 @@ | ||
{ | ||
"count": 1, | ||
"total": 1, | ||
"_links": { | ||
"collection": { | ||
"profile": "https://datamanager.entrecode.de/api/schema/beefbeef/allFields", | ||
"href": "https://datamanager.entrecode.de/api/beefbeef" | ||
}, | ||
"curies": { | ||
"name": "Test DM", | ||
"href": "https://datamanager.entrecode.de/api/doc/beefbeef/{rel}", | ||
"templated": true | ||
}, | ||
"self": { | ||
"profile": "https://datamanager.entrecode.de/api/schema/beefbeef/allFields", | ||
"href": "https://datamanager.entrecode.de/api/beefbeef/allFields" | ||
}, | ||
"beefbeef:allFields/options": { | ||
"href": "https://datamanager.entrecode.de/api/beefbeef/allFields{?_created,_createdFrom,_createdTo,_creator,_fields,_id,_levels,_modified,_modifiedFrom,_modifiedTo,_private,account,asset,assets,assets~,boolean,created,createdFrom,createdTo,datetime,datetimeFrom,datetimeTo,decimal,decimalFrom,decimalTo,email,email~,entries,entries~,entry,formattedText~,id,location,locationFrom,locationTo,modified,modifiedFrom,modifiedTo,number,numberFrom,numberTo,page,phone,phone~,private,role,size,sort,text,text~,url,url~}", | ||
"templated": true | ||
} | ||
}, | ||
"_embedded": { | ||
"beefbeef:allFields": { | ||
"_id": "B17u3r5lx-", | ||
"_created": "2017-05-10T13:29:19.893Z", | ||
"_creator": null, | ||
"_modified": "2017-05-10T13:29:19.893Z", | ||
"id": "B17u3r5lx-", | ||
"created": "2017-05-10T13:29:19.893Z", | ||
"modified": "2017-05-10T13:29:19.893Z", | ||
"private": false, | ||
"text": "asdf", | ||
"formattedText": "asdf", | ||
"number": 1, | ||
"decimal": 1, | ||
"boolean": true, | ||
"datetime": "2017-04-29T22:00:00.000Z", | ||
"location": { | ||
"latitude": 4, | ||
"longitude": 3 | ||
}, | ||
"email": "me@what.com", | ||
"url": "example.com", | ||
"phone": "+49 5555 5521", | ||
"json": {}, | ||
"entry": "EJlJtSrkgl", | ||
"entries": [ | ||
"EJlJtSrkgl" | ||
], | ||
"asset": "03685901-8bbe-40a2-89f2-a7c9a5db5bf8", | ||
"assets": [ | ||
"03685901-8bbe-40a2-89f2-a7c9a5db5bf8" | ||
], | ||
"account": null, | ||
"role": null, | ||
"_links": { | ||
"collection": { | ||
"profile": "https://datamanager.entrecode.de/api/schema/beefbeef/allFields", | ||
"href": "https://datamanager.entrecode.de/api/beefbeef/allFields" | ||
}, | ||
"self": { | ||
"profile": "https://datamanager.entrecode.de/api/schema/beefbeef/allFields", | ||
"href": "https://datamanager.entrecode.de/api/beefbeef/allFields?_id=B17u3r5lx-" | ||
}, | ||
"beefbeef:allFields/asset": { | ||
"profile": "https://entrecode.de/schema/asset", | ||
"title": "dafuq", | ||
"href": "https://datamanager.entrecode.de/files/03685901-8bbe-40a2-89f2-a7c9a5db5bf8" | ||
}, | ||
"beefbeef:allFields/assets": { | ||
"profile": "https://entrecode.de/schema/asset", | ||
"title": "dafuq", | ||
"href": "https://datamanager.entrecode.de/files/03685901-8bbe-40a2-89f2-a7c9a5db5bf8" | ||
}, | ||
"beefbeef:allFields/entry": { | ||
"profile": "https://datamanager.entrecode.de/api/schema/beefbeef/contains_entries", | ||
"href": "https://datamanager.entrecode.de/api/beefbeef/contains_entries?id=EJlJtSrkgl", | ||
"name": "contains_entries", | ||
"title": "EJlJtSrkgl" | ||
}, | ||
"beefbeef:allFields/entries": { | ||
"profile": "https://datamanager.entrecode.de/api/schema/beefbeef/contains_entries", | ||
"href": "https://datamanager.entrecode.de/api/beefbeef/contains_entries?id=EJlJtSrkgl", | ||
"name": "contains_entries", | ||
"title": "EJlJtSrkgl" | ||
} | ||
}, | ||
"_embedded": { | ||
"beefbeef:allFields/asset/asset": { | ||
"assetID": "03685901-8bbe-40a2-89f2-a7c9a5db5bf8", | ||
"title": "dafuq", | ||
"type": "image", | ||
"created": "2017-04-05T11:29:22.974Z", | ||
"deleted": null, | ||
"files": [ | ||
{ | ||
"url": "https://cdn2.entrecode.de/files/beefbeef/PdQoDSKVaujMjvCm9j4G3fEF.gif", | ||
"mimetype": "image/gif", | ||
"size": 121190, | ||
"resolution": { | ||
"width": 784, | ||
"height": 487 | ||
}, | ||
"locale": null, | ||
"created": "2017-04-05T11:29:22.968+00:00", | ||
"modified": "2017-04-05T11:29:22.968+00:00", | ||
"assetID": "03685901-8bbe-40a2-89f2-a7c9a5db5bf8" | ||
} | ||
], | ||
"_links": { | ||
"self": { | ||
"profile": "https://entrecode.de/schema/asset", | ||
"href": "https://datamanager.entrecode.de/asset/beefbeef?assetID=03685901-8bbe-40a2-89f2-a7c9a5db5bf8", | ||
"title": "dafuq" | ||
}, | ||
"collection": { | ||
"profile": "https://entrecode.de/schema/assets", | ||
"href": "https://datamanager.entrecode.de/asset/beefbeef" | ||
}, | ||
"ec:asset/best-file": { | ||
"href": "https://datamanager.entrecode.de/files/03685901-8bbe-40a2-89f2-a7c9a5db5bf8{?size,thumb}", | ||
"templated": true | ||
} | ||
} | ||
}, | ||
"beefbeef:allFields/assets/asset": { | ||
"assetID": "03685901-8bbe-40a2-89f2-a7c9a5db5bf8", | ||
"title": "dafuq", | ||
"type": "image", | ||
"created": "2017-04-05T11:29:22.974Z", | ||
"deleted": null, | ||
"files": [ | ||
{ | ||
"url": "https://cdn2.entrecode.de/files/beefbeef/PdQoDSKVaujMjvCm9j4G3fEF.gif", | ||
"mimetype": "image/gif", | ||
"size": 121190, | ||
"resolution": { | ||
"width": 784, | ||
"height": 487 | ||
}, | ||
"locale": null, | ||
"created": "2017-04-05T11:29:22.968+00:00", | ||
"modified": "2017-04-05T11:29:22.968+00:00", | ||
"assetID": "03685901-8bbe-40a2-89f2-a7c9a5db5bf8" | ||
} | ||
], | ||
"_links": { | ||
"self": { | ||
"profile": "https://entrecode.de/schema/asset", | ||
"href": "https://datamanager.entrecode.de/asset/beefbeef?assetID=03685901-8bbe-40a2-89f2-a7c9a5db5bf8", | ||
"title": "dafuq" | ||
}, | ||
"collection": { | ||
"profile": "https://entrecode.de/schema/assets", | ||
"href": "https://datamanager.entrecode.de/asset/beefbeef" | ||
}, | ||
"ec:asset/best-file": { | ||
"href": "https://datamanager.entrecode.de/files/03685901-8bbe-40a2-89f2-a7c9a5db5bf8{?size,thumb}", | ||
"templated": true | ||
} | ||
} | ||
} | ||
}, | ||
"_modelTitleField": "_id", | ||
"_modelTitle": "allFields", | ||
"_entryTitle": "B17u3r5lx-" | ||
} | ||
} | ||
} |
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