-
Notifications
You must be signed in to change notification settings - Fork 1
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
4 changed files
with
90 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,41 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "Collection", | ||
"description": "Description of the collection object (Collection class)", | ||
"description": "Collection details.", | ||
"type": "object", | ||
"additionalProperties": false, | ||
"required": ["uid"], | ||
"properties": { | ||
"uid": { | ||
"type": "string", | ||
"minLength": 2, | ||
"maxLength": 50 | ||
"description": "Unique identifier of the collection." | ||
}, | ||
"title": { | ||
"type": "string", | ||
"description": "Title of the collection." | ||
}, | ||
"description": { | ||
"type": "string", | ||
"description": "Description of the collection." | ||
}, | ||
"accessLevel": { | ||
"type": "string", | ||
"description": "Access level of the collection.", | ||
"enum": ["public", "private"] | ||
}, | ||
"createdAt": { | ||
"type": "string", | ||
"description": "Creation date of the collection.", | ||
"format": "date-time" | ||
}, | ||
"updatedAt": { | ||
"type": "string", | ||
"description": "Last update date of the collection.", | ||
"format": "date-time" | ||
}, | ||
"totalItems": { | ||
"type": "integer", | ||
"description": "Total number of items in the collection." | ||
} | ||
} | ||
}, | ||
"required": ["uid", "title", "description", "accessLevel", "createdAt", "updatedAt", "totalItems"] | ||
} |
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,23 @@ | ||
import { Collection as CollectionInternal } from '../models/generated/schemas' | ||
import { Collection as CollectionPublic } from '../models/generated/schemasPublic' | ||
|
||
const toAccessLevel = (status: string): CollectionPublic['accessLevel'] => { | ||
switch (status.toUpperCase()) { | ||
case 'PUB': | ||
return 'public' | ||
default: | ||
return 'private' | ||
} | ||
} | ||
|
||
export const transformCollection = (input: CollectionInternal): CollectionPublic => { | ||
return { | ||
uid: input.uid, | ||
title: input.name, | ||
description: input.description, | ||
createdAt: input.creationDate, | ||
updatedAt: input.lastModifiedDate, | ||
totalItems: Number(input.countItems), | ||
accessLevel: toAccessLevel(input.status), | ||
} | ||
} |