aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/models')
-rw-r--r--src/models/Group.ts4
-rw-r--r--src/models/Trip.ts14
-rw-r--r--src/models/index.guard.ts7
3 files changed, 21 insertions, 4 deletions
diff --git a/src/models/Group.ts b/src/models/Group.ts
index 9b3aa6d..c0d281d 100644
--- a/src/models/Group.ts
+++ b/src/models/Group.ts
@@ -19,7 +19,7 @@ export default interface Group {
description?: string;
/**
- * Medias in the group.
+ * Media in the group.
*/
media: MediaItem[];
@@ -32,4 +32,6 @@ export default interface Group {
* Metadata that can be displayed in the description.
*/
metadata?: { [key: string]: string | number };
+
+ [key: string]: any;
}
diff --git a/src/models/Trip.ts b/src/models/Trip.ts
index 7f92669..46c462d 100644
--- a/src/models/Trip.ts
+++ b/src/models/Trip.ts
@@ -19,10 +19,22 @@ export default interface Trip {
/**
* URL to a JSON file containing data for the trip.
*/
- url: string;
+ url?: string;
/**
* Property indicating if the trip data has been already downloaded.
*/
downloaded: boolean;
+
+ /**
+ * A group property to use while sorting groups.
+ * Nested properties should be delimited with a dot.
+ * Default: name.
+ */
+ sortProperty?: string;
+
+ /**
+ * Sort order. true = descending, false = ascending.
+ */
+ sortOrder?: boolean;
}
diff --git a/src/models/index.guard.ts b/src/models/index.guard.ts
index d564ff9..6e9265f 100644
--- a/src/models/index.guard.ts
+++ b/src/models/index.guard.ts
@@ -47,8 +47,11 @@ export function isTrip(obj: unknown): obj is Trip {
typeof typedObj.id === 'string' &&
typeof typedObj.name === 'string' &&
(typeof typedObj.groups === 'undefined' ||
- (Array.isArray(typedObj.groups) && typedObj.groups.every((e: any) => isGroup(e)))
- );
+ (Array.isArray(typedObj.groups) && typedObj.groups.every((e: any) => isGroup(e)))) &&
+ (typeof typedObj.url === 'undefined' || typeof typedObj.url === 'string') &&
+ (typeof typedObj.downloaded === 'undefined' || typeof typedObj.downloaded === 'boolean') &&
+ (typeof typedObj.sortProperty === 'undefined' || typeof typedObj.sortProperty === 'string') &&
+ (typeof typedObj.sortOrder === 'undefined' || typeof typedObj.sortOrder === 'boolean');
if (!isValid) {
throw new Error(`Invalid object: ${JSON.stringify(obj)}`);