-
Notifications
You must be signed in to change notification settings - Fork 5
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
16 changed files
with
56 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export const APP_NAME = 'next-frourio-starter'; | ||
|
||
export const BRANDED_ID_NAMES = ['user', 'task'] as const; |
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,8 +1,10 @@ | ||
import type { BRANDED_ID_NAMES } from 'api/@constants'; | ||
import type { z } from 'zod'; | ||
|
||
type Branded<T extends string> = string & z.BRAND<T>; | ||
export type IdName = (typeof BRANDED_ID_NAMES)[number]; | ||
|
||
export type Maybe<T> = T | Branded<'Maybe'>; | ||
type Branded<T extends string> = string & z.BRAND<T>; | ||
type Entity<T extends IdName> = string & z.BRAND<`${T}EntityId`>; | ||
|
||
export type UserId = Branded<'UserId'>; | ||
export type TaskId = Branded<'TaskId'>; | ||
export type EntityId = { [T in IdName]: Entity<T> }; | ||
export type MaybeId = { [T in IdName]: Entity<T> | Branded<'maybe'> }; |
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,14 +1,14 @@ | ||
import type { Maybe, TaskId, UserId } from './brandedId'; | ||
import type { EntityId, MaybeId } from './brandedId'; | ||
|
||
export type TaskEntity = { | ||
id: TaskId; | ||
id: EntityId['task']; | ||
label: string; | ||
done: boolean; | ||
createdTime: number; | ||
image: { url: string; s3Key: string } | undefined; | ||
author: { id: UserId; displayName: string | undefined }; | ||
author: { id: EntityId['user']; displayName: string | undefined }; | ||
}; | ||
|
||
export type TaskCreateVal = { label: string; image?: Blob }; | ||
|
||
export type TaskUpdateVal = { taskId: Maybe<TaskId>; label?: string; done?: boolean }; | ||
export type TaskUpdateVal = { taskId: MaybeId['task']; label?: string; done?: boolean }; |
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
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
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
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,13 @@ | ||
import { BRANDED_ID_NAMES } from 'api/@constants'; | ||
import type { EntityId, IdName, MaybeId } from 'api/@types/brandedId'; | ||
import { z } from 'zod'; | ||
|
||
export const brandedId = BRANDED_ID_NAMES.reduce( | ||
(dict, current) => ({ | ||
...dict, | ||
[current]: { entity: z.string(), maybe: z.string() }, | ||
}), | ||
{} as { | ||
[Name in IdName]: { entity: z.ZodType<EntityId[Name]>; maybe: z.ZodType<MaybeId[Name]> }; | ||
}, | ||
); |
This file was deleted.
Oops, something went wrong.
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