generated from graasp/graasp-repo
-
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.
feat(refactor): simplify the ShortLink types (#693)
- Loading branch information
Showing
3 changed files
with
11 additions
and
38 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,29 +1,26 @@ | ||
import { AnyOfExcept, UnionOfConst } from '@/typeUtils.js'; | ||
import { UnionOfConst } from '@/typeUtils.js'; | ||
|
||
// This const is used to define the allowed Platforms. | ||
// It is used in schema or database enums. | ||
/** | ||
* Represents the allowed platforms for which short links can be generated. | ||
*/ | ||
export const ShortLinkPlatform = { | ||
Builder: 'builder', | ||
Player: 'player', | ||
Library: 'library', | ||
} as const; | ||
|
||
export type ShortLink = { | ||
itemId: string; | ||
alias: string; | ||
platform: UnionOfConst<typeof ShortLinkPlatform>; | ||
item: { id: string }; | ||
createdAt: string; | ||
}; | ||
|
||
export type ShortLinkItemId = { | ||
itemId: string; | ||
}; | ||
export type UpdateShortLink = Pick<ShortLink, 'alias'>; | ||
|
||
export type ShortLinkPayload = Omit<ShortLink, 'createdAt' | 'item'> & | ||
ShortLinkItemId; | ||
export type ShortLinkPostPayload = ShortLinkPayload; | ||
export type ShortLinkPatchPayload = AnyOfExcept<ShortLinkPostPayload, 'itemId'>; | ||
export type ShortLinkPutPayload = Omit<ShortLinkPayload, 'itemId'>; | ||
export type ShortLinkAvailable = { | ||
available: boolean; | ||
}; | ||
|
||
export type ShortLinksOfItem = { | ||
[K in (typeof ShortLinkPlatform)[keyof typeof ShortLinkPlatform]]?: ShortLink['alias']; | ||
}; |
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