Skip to content

Commit a42e565

Browse files
Merge pull request #6 from LeafyShadow696/copilot/fix-and-improve-application
Stabilize server action validation API usage and remove unstable message list derivation
2 parents f54b950 + 4e92beb commit a42e565

8 files changed

Lines changed: 8420 additions & 36 deletions

File tree

‎package-lock.json‎

Lines changed: 8242 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/lib/events.functions.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const CreateInput = z.object({
6161
});
6262

6363
export const createEvent = createServerFn({ method: "POST" })
64-
.inputValidator((input: unknown) => CreateInput.parse(input))
64+
.validator((input: unknown) => CreateInput.parse(input))
6565
.handler(async ({ data }) =>
6666
withSession(async ({ pair, role }) => {
6767
const supabase = await adminClient();
@@ -81,7 +81,7 @@ export const createEvent = createServerFn({ method: "POST" })
8181
);
8282

8383
export const deleteEvent = createServerFn({ method: "POST" })
84-
.inputValidator((input: unknown) => z.object({ id: z.string().uuid() }).parse(input))
84+
.validator((input: unknown) => z.object({ id: z.string().uuid() }).parse(input))
8585
.handler(async ({ data }) =>
8686
withSession(async ({ pair }) => {
8787
const supabase = await adminClient();

‎src/lib/invite.functions.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const createInvite = createServerFn({ method: "POST" }).handler(async ()
3535
const RevokeInput = z.object({ invite_id: z.string().uuid() });
3636

3737
export const revokeInvite = createServerFn({ method: "POST" })
38-
.inputValidator((input: unknown) => RevokeInput.parse(input))
38+
.validator((input: unknown) => RevokeInput.parse(input))
3939
.handler(async ({ data }) =>
4040
withSession(async ({ pair, role }): Promise<{ ok: true }> => {
4141
if (role !== "owner") throw new Error(OWNER_ONLY_MESSAGE);

‎src/lib/messages.functions.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const CreateInput = z.object({
5252
});
5353

5454
export const createMessage = createServerFn({ method: "POST" })
55-
.inputValidator((input: unknown) => CreateInput.parse(input))
55+
.validator((input: unknown) => CreateInput.parse(input))
5656
.handler(async ({ data }) =>
5757
withSession(async ({ pair, role }) => {
5858
const supabase = await adminClient();
@@ -74,7 +74,7 @@ const UpdateInput = z.object({
7474
});
7575

7676
export const updateMessage = createServerFn({ method: "POST" })
77-
.inputValidator((input: unknown) => UpdateInput.parse(input))
77+
.validator((input: unknown) => UpdateInput.parse(input))
7878
.handler(async ({ data }) =>
7979
withSession(async ({ pair }) => {
8080
const supabase = await adminClient();
@@ -92,7 +92,7 @@ export const updateMessage = createServerFn({ method: "POST" })
9292
);
9393

9494
export const deleteMessage = createServerFn({ method: "POST" })
95-
.inputValidator((input: unknown) => z.object({ id: z.string().uuid() }).parse(input))
95+
.validator((input: unknown) => z.object({ id: z.string().uuid() }).parse(input))
9696
.handler(async ({ data }) =>
9797
withSession(async ({ pair }) => {
9898
const supabase = await adminClient();

‎src/lib/pair.functions.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const CreateInput = z.object({
4242
});
4343

4444
export const createPair = createServerFn({ method: "POST" })
45-
.inputValidator((input: unknown) => CreateInput.parse(input))
45+
.validator((input: unknown) => CreateInput.parse(input))
4646
.handler(async ({ data }) => {
4747
const supabase = await adminClient();
4848
const ownerToken = randomToken();
@@ -87,7 +87,7 @@ async function discardSession(sessionId: string): Promise<void> {
8787
}
8888

8989
export const joinPair = createServerFn({ method: "POST" })
90-
.inputValidator((input: unknown) => JoinInput.parse(input))
90+
.validator((input: unknown) => JoinInput.parse(input))
9191
.handler(async ({ data }) => {
9292
const code = normalizeManualCode(data.code);
9393
if (!code) throw new Error(INVITE_INVALID_MESSAGE);
@@ -155,7 +155,7 @@ const UpdateInput = z.object({
155155
});
156156

157157
export const updatePair = createServerFn({ method: "POST" })
158-
.inputValidator((input: unknown) => UpdateInput.parse(input ?? {}))
158+
.validator((input: unknown) => UpdateInput.parse(input ?? {}))
159159
.handler(async ({ data }) =>
160160
withSession(async ({ pair, role }) => {
161161
const patch: { owner_name?: string; partner_name?: string; anniversary?: string } = {};
@@ -193,7 +193,7 @@ export type ResumeResult =
193193
| { status: "gone" };
194194

195195
export const resumeSession = createServerFn({ method: "POST" })
196-
.inputValidator((input: unknown) => ResumeInput.parse(input ?? {}))
196+
.validator((input: unknown) => ResumeInput.parse(input ?? {}))
197197
.handler(async ({ data }): Promise<ResumeResult> => {
198198
const current = await resolveSessionFromCookie();
199199
if (current) {

‎src/lib/photos.functions.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const listPhotos = createServerFn({ method: "POST" }).handler(
3535
);
3636

3737
export const deletePhoto = createServerFn({ method: "POST" })
38-
.inputValidator((input: unknown) => z.object({ id: z.string().uuid() }).parse(input))
38+
.validator((input: unknown) => z.object({ id: z.string().uuid() }).parse(input))
3939
.handler(async ({ data }) =>
4040
withSession(async ({ pair }) => {
4141
const supabase = await adminClient();

‎src/routeTree.gen.ts‎

Lines changed: 165 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,176 @@ import { Route as VzkazyRouteImport } from './routes/vzkazy'
1717
import { Route as ApiPublicUploadRouteImport } from './routes/api/public/upload'
1818
import { Route as ApiPublicCalendarKeyRouteImport } from './routes/api/public/calendar/$key'
1919

20-
const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRouteImport } as any)
21-
const GalerieRoute = GalerieRouteImport.update({ id: '/galerie', path: '/galerie', getParentRoute: () => rootRouteImport } as any)
22-
const KalendarRoute = KalendarRouteImport.update({ id: '/kalendar', path: '/kalendar', getParentRoute: () => rootRouteImport } as any)
23-
const NastaveniRoute = NastaveniRouteImport.update({ id: '/nastaveni', path: '/nastaveni', getParentRoute: () => rootRouteImport } as any)
24-
const VzkazyRoute = VzkazyRouteImport.update({ id: '/vzkazy', path: '/vzkazy', getParentRoute: () => rootRouteImport } as any)
25-
const ApiPublicUploadRoute = ApiPublicUploadRouteImport.update({ id: '/api/public/upload', path: '/api/public/upload', getParentRoute: () => rootRouteImport } as any)
26-
const ApiPublicCalendarKeyRoute = ApiPublicCalendarKeyRouteImport.update({ id: '/api/public/calendar/$key', path: '/api/public/calendar/$key', getParentRoute: () => rootRouteImport } as any)
27-
28-
export interface FileRoutesByFullPath { '/': typeof IndexRoute; '/galerie': typeof GalerieRoute; '/kalendar': typeof KalendarRoute; '/nastaveni': typeof NastaveniRoute; '/vzkazy': typeof VzkazyRoute; '/api/public/upload': typeof ApiPublicUploadRoute; '/api/public/calendar/$key': typeof ApiPublicCalendarKeyRoute }
29-
export interface FileRoutesByTo extends FileRoutesByFullPath {}
30-
export interface FileRoutesById { __root__: typeof rootRouteImport; '/': typeof IndexRoute; '/galerie': typeof GalerieRoute; '/kalendar': typeof KalendarRoute; '/nastaveni': typeof NastaveniRoute; '/vzkazy': typeof VzkazyRoute; '/api/public/upload': typeof ApiPublicUploadRoute; '/api/public/calendar/$key': typeof ApiPublicCalendarKeyRoute }
31-
export interface FileRouteTypes { fileRoutesByFullPath: FileRoutesByFullPath; fullPaths: '/' | '/galerie' | '/kalendar' | '/nastaveni' | '/vzkazy' | '/api/public/upload' | '/api/public/calendar/$key'; fileRoutesByTo: FileRoutesByTo; to: '/' | '/galerie' | '/kalendar' | '/nastaveni' | '/vzkazy' | '/api/public/upload' | '/api/public/calendar/$key'; id: '__root__' | '/' | '/galerie' | '/kalendar' | '/nastaveni' | '/vzkazy' | '/api/public/upload' | '/api/public/calendar/$key'; fileRoutesById: FileRoutesById }
32-
export interface RootRouteChildren { IndexRoute: typeof IndexRoute; GalerieRoute: typeof GalerieRoute; KalendarRoute: typeof KalendarRoute; NastaveniRoute: typeof NastaveniRoute; VzkazyRoute: typeof VzkazyRoute; ApiPublicUploadRoute: typeof ApiPublicUploadRoute; ApiPublicCalendarKeyRoute: typeof ApiPublicCalendarKeyRoute }
20+
const IndexRoute = IndexRouteImport.update({
21+
id: '/',
22+
path: '/',
23+
getParentRoute: () => rootRouteImport,
24+
} as any)
25+
const GalerieRoute = GalerieRouteImport.update({
26+
id: '/galerie',
27+
path: '/galerie',
28+
getParentRoute: () => rootRouteImport,
29+
} as any)
30+
const KalendarRoute = KalendarRouteImport.update({
31+
id: '/kalendar',
32+
path: '/kalendar',
33+
getParentRoute: () => rootRouteImport,
34+
} as any)
35+
const NastaveniRoute = NastaveniRouteImport.update({
36+
id: '/nastaveni',
37+
path: '/nastaveni',
38+
getParentRoute: () => rootRouteImport,
39+
} as any)
40+
const VzkazyRoute = VzkazyRouteImport.update({
41+
id: '/vzkazy',
42+
path: '/vzkazy',
43+
getParentRoute: () => rootRouteImport,
44+
} as any)
45+
const ApiPublicUploadRoute = ApiPublicUploadRouteImport.update({
46+
id: '/api/public/upload',
47+
path: '/api/public/upload',
48+
getParentRoute: () => rootRouteImport,
49+
} as any)
50+
const ApiPublicCalendarKeyRoute = ApiPublicCalendarKeyRouteImport.update({
51+
id: '/api/public/calendar/$key',
52+
path: '/api/public/calendar/$key',
53+
getParentRoute: () => rootRouteImport,
54+
} as any)
55+
56+
export interface FileRoutesByFullPath {
57+
'/': typeof IndexRoute
58+
'/galerie': typeof GalerieRoute
59+
'/kalendar': typeof KalendarRoute
60+
'/nastaveni': typeof NastaveniRoute
61+
'/vzkazy': typeof VzkazyRoute
62+
'/api/public/upload': typeof ApiPublicUploadRoute
63+
'/api/public/calendar/$key': typeof ApiPublicCalendarKeyRoute
64+
}
65+
export interface FileRoutesByTo {
66+
'/': typeof IndexRoute
67+
'/galerie': typeof GalerieRoute
68+
'/kalendar': typeof KalendarRoute
69+
'/nastaveni': typeof NastaveniRoute
70+
'/vzkazy': typeof VzkazyRoute
71+
'/api/public/upload': typeof ApiPublicUploadRoute
72+
'/api/public/calendar/$key': typeof ApiPublicCalendarKeyRoute
73+
}
74+
export interface FileRoutesById {
75+
__root__: typeof rootRouteImport
76+
'/': typeof IndexRoute
77+
'/galerie': typeof GalerieRoute
78+
'/kalendar': typeof KalendarRoute
79+
'/nastaveni': typeof NastaveniRoute
80+
'/vzkazy': typeof VzkazyRoute
81+
'/api/public/upload': typeof ApiPublicUploadRoute
82+
'/api/public/calendar/$key': typeof ApiPublicCalendarKeyRoute
83+
}
84+
export interface FileRouteTypes {
85+
fileRoutesByFullPath: FileRoutesByFullPath
86+
fullPaths:
87+
| '/'
88+
| '/galerie'
89+
| '/kalendar'
90+
| '/nastaveni'
91+
| '/vzkazy'
92+
| '/api/public/upload'
93+
| '/api/public/calendar/$key'
94+
fileRoutesByTo: FileRoutesByTo
95+
to:
96+
| '/'
97+
| '/galerie'
98+
| '/kalendar'
99+
| '/nastaveni'
100+
| '/vzkazy'
101+
| '/api/public/upload'
102+
| '/api/public/calendar/$key'
103+
id:
104+
| '__root__'
105+
| '/'
106+
| '/galerie'
107+
| '/kalendar'
108+
| '/nastaveni'
109+
| '/vzkazy'
110+
| '/api/public/upload'
111+
| '/api/public/calendar/$key'
112+
fileRoutesById: FileRoutesById
113+
}
114+
export interface RootRouteChildren {
115+
IndexRoute: typeof IndexRoute
116+
GalerieRoute: typeof GalerieRoute
117+
KalendarRoute: typeof KalendarRoute
118+
NastaveniRoute: typeof NastaveniRoute
119+
VzkazyRoute: typeof VzkazyRoute
120+
ApiPublicUploadRoute: typeof ApiPublicUploadRoute
121+
ApiPublicCalendarKeyRoute: typeof ApiPublicCalendarKeyRoute
122+
}
33123

34124
declare module '@tanstack/react-router' {
35125
interface FileRoutesByPath {
36-
'/': { id: '/'; path: '/'; fullPath: '/'; preLoaderRoute: typeof IndexRouteImport; parentRoute: typeof rootRouteImport }
37-
'/galerie': { id: '/galerie'; path: '/galerie'; fullPath: '/galerie'; preLoaderRoute: typeof GalerieRouteImport; parentRoute: typeof rootRouteImport }
38-
'/kalendar': { id: '/kalendar'; path: '/kalendar'; fullPath: '/kalendar'; preLoaderRoute: typeof KalendarRouteImport; parentRoute: typeof rootRouteImport }
39-
'/nastaveni': { id: '/nastaveni'; path: '/nastaveni'; fullPath: '/nastaveni'; preLoaderRoute: typeof NastaveniRouteImport; parentRoute: typeof rootRouteImport }
40-
'/vzkazy': { id: '/vzkazy'; path: '/vzkazy'; fullPath: '/vzkazy'; preLoaderRoute: typeof VzkazyRouteImport; parentRoute: typeof rootRouteImport }
41-
'/api/public/upload': { id: '/api/public/upload'; path: '/api/public/upload'; fullPath: '/api/public/upload'; preLoaderRoute: typeof ApiPublicUploadRouteImport; parentRoute: typeof rootRouteImport }
42-
'/api/public/calendar/$key': { id: '/api/public/calendar/$key'; path: '/api/public/calendar/$key'; fullPath: '/api/public/calendar/$key'; preLoaderRoute: typeof ApiPublicCalendarKeyRouteImport; parentRoute: typeof rootRouteImport }
126+
'/': {
127+
id: '/'
128+
path: '/'
129+
fullPath: '/'
130+
preLoaderRoute: typeof IndexRouteImport
131+
parentRoute: typeof rootRouteImport
132+
}
133+
'/galerie': {
134+
id: '/galerie'
135+
path: '/galerie'
136+
fullPath: '/galerie'
137+
preLoaderRoute: typeof GalerieRouteImport
138+
parentRoute: typeof rootRouteImport
139+
}
140+
'/kalendar': {
141+
id: '/kalendar'
142+
path: '/kalendar'
143+
fullPath: '/kalendar'
144+
preLoaderRoute: typeof KalendarRouteImport
145+
parentRoute: typeof rootRouteImport
146+
}
147+
'/nastaveni': {
148+
id: '/nastaveni'
149+
path: '/nastaveni'
150+
fullPath: '/nastaveni'
151+
preLoaderRoute: typeof NastaveniRouteImport
152+
parentRoute: typeof rootRouteImport
153+
}
154+
'/vzkazy': {
155+
id: '/vzkazy'
156+
path: '/vzkazy'
157+
fullPath: '/vzkazy'
158+
preLoaderRoute: typeof VzkazyRouteImport
159+
parentRoute: typeof rootRouteImport
160+
}
161+
'/api/public/upload': {
162+
id: '/api/public/upload'
163+
path: '/api/public/upload'
164+
fullPath: '/api/public/upload'
165+
preLoaderRoute: typeof ApiPublicUploadRouteImport
166+
parentRoute: typeof rootRouteImport
167+
}
168+
'/api/public/calendar/$key': {
169+
id: '/api/public/calendar/$key'
170+
path: '/api/public/calendar/$key'
171+
fullPath: '/api/public/calendar/$key'
172+
preLoaderRoute: typeof ApiPublicCalendarKeyRouteImport
173+
parentRoute: typeof rootRouteImport
174+
}
43175
}
44176
}
45177

46-
const rootRouteChildren: RootRouteChildren = { IndexRoute, GalerieRoute, KalendarRoute, NastaveniRoute, VzkazyRoute, ApiPublicUploadRoute, ApiPublicCalendarKeyRoute }
47-
export const routeTree = rootRouteImport._addFileChildren(rootRouteChildren)._addFileTypes<FileRouteTypes>()
178+
const rootRouteChildren: RootRouteChildren = {
179+
IndexRoute: IndexRoute,
180+
GalerieRoute: GalerieRoute,
181+
KalendarRoute: KalendarRoute,
182+
NastaveniRoute: NastaveniRoute,
183+
VzkazyRoute: VzkazyRoute,
184+
ApiPublicUploadRoute: ApiPublicUploadRoute,
185+
ApiPublicCalendarKeyRoute: ApiPublicCalendarKeyRoute,
186+
}
187+
export const routeTree = rootRouteImport
188+
._addFileChildren(rootRouteChildren)
189+
._addFileTypes<FileRouteTypes>()
48190

49191
import type { getRouter } from './router.tsx'
50192
import type { startInstance } from './start.ts'
@@ -54,4 +196,4 @@ declare module '@tanstack/react-start' {
54196
router: Awaited<ReturnType<typeof getRouter>>
55197
config: Awaited<ReturnType<typeof startInstance.getOptions>>
56198
}
57-
}
199+
}

‎src/routes/vzkazy.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ function MessagesPage() {
143143
send.mutate({ text, deliver: capsule ? new Date(capsule).toISOString() : null });
144144
};
145145

146-
const all = messages.data ?? [];
147-
const pinned = all.filter((message) => message.pinned);
146+
const all = useMemo(() => messages.data ?? [], [messages.data]);
147+
const pinned = useMemo(() => all.filter((message) => message.pinned), [all]);
148148
const today = new Date().toISOString().slice(0, 10);
149149
const timeline = useMemo(() => {
150150
const ordered = [...all].reverse();

0 commit comments

Comments
 (0)