feat(time-entry-templates): Wiederverwendbare TimeEntry-Templates (gespeicherte descript [tsc:fail]
This commit is contained in:
parent
ce80e5d637
commit
44ffc813c7
@ -1,9 +1,10 @@
|
|||||||
{
|
{
|
||||||
"completed_features": [],
|
"completed_features": [],
|
||||||
"current_feature": "recent-projects-quick-access",
|
"current_feature": "time-entry-templates",
|
||||||
"started_at": "2026-05-23T07:08:48.804883",
|
"started_at": "2026-05-23T07:08:48.804883",
|
||||||
"attempted_features": [
|
"attempted_features": [
|
||||||
"pinned-customers",
|
"pinned-customers",
|
||||||
"smart-suggestions"
|
"smart-suggestions",
|
||||||
|
"recent-projects-quick-access"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -1939,3 +1939,22 @@ src/index.ts(27,25): error TS2769: No overload matches this call.
|
|||||||
Overload 2 of 3, '(plugin: FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
|
Overload 2 of 3, '(plugin: FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
|
||||||
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
|
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
|
||||||
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTy
|
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTy
|
||||||
|
- `07:15:09` **INFO** Committed feature recent-projects-quick-access
|
||||||
|
- `07:15:09` **INFO** Pushed: rc=0
|
||||||
|
|
||||||
|
## Phase-3 Feature: time-entry-templates (2026-05-23 07:15:09)
|
||||||
|
|
||||||
|
- `07:15:09` **INFO** Description: Wiederverwendbare TimeEntry-Templates (gespeicherte description+project)
|
||||||
|
- `07:15:09` **INFO** Generating apps/api/src/db/schema.ts (ERWEITERT — füge `timeEntryTemplates` pgTable: id, userId, name (label…)
|
||||||
|
- `07:15:48` **INFO** wrote 4609 chars in 39.3s (attempt 1)
|
||||||
|
- `07:15:48` **INFO** Generating apps/api/src/routes/time-entry-templates.ts (Fastify-Plugin /api/time-entry-templates. CRUD GET/POST/PATCH/DELETE. …)
|
||||||
|
- `07:16:14` **INFO** wrote 2845 chars in 25.2s (attempt 1)
|
||||||
|
- `07:16:14` **INFO** Running tsc --noEmit on api…
|
||||||
|
- `07:16:15` **WARN** tsc errors:
|
||||||
|
src/index.ts(27,25): error TS2769: No overload matches this call.
|
||||||
|
Overload 1 of 3, '(plugin: FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
|
||||||
|
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
|
||||||
|
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProvider>, opts: { ...; }, done: (err?: Error | undefined) => void): void'.
|
||||||
|
Overload 2 of 3, '(plugin: FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
|
||||||
|
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
|
||||||
|
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTy
|
||||||
|
|||||||
@ -51,6 +51,16 @@ export const timeEntries = pgTable("time_entries", {
|
|||||||
createdAt: timestamp("created_at").notNull().defaultNow()
|
createdAt: timestamp("created_at").notNull().defaultNow()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const timeEntryTemplates = pgTable("time_entry_templates", {
|
||||||
|
id: uuid("id").primaryKey().defaultRandom(),
|
||||||
|
userId: uuid("user_id").references(() => users.id, { onDelete: "cascade" }),
|
||||||
|
name: text("name").notNull(),
|
||||||
|
description: text("description"),
|
||||||
|
projectId: uuid("project_id").references(() => projects.id, { onDelete: "set null" }),
|
||||||
|
defaultDurationMinutes: integer("default_duration_minutes"),
|
||||||
|
createdAt: timestamp("created_at").notNull().defaultNow()
|
||||||
|
})
|
||||||
|
|
||||||
export const appSettings = pgTable("app_settings", {
|
export const appSettings = pgTable("app_settings", {
|
||||||
id: uuid("id").primaryKey().defaultRandom(),
|
id: uuid("id").primaryKey().defaultRandom(),
|
||||||
workspaceName: text("workspace_name").notNull().default("EmberClone"),
|
workspaceName: text("workspace_name").notNull().default("EmberClone"),
|
||||||
@ -103,11 +113,3 @@ export const savedViews = pgTable("saved_views", {
|
|||||||
config: text("config").notNull(),
|
config: text("config").notNull(),
|
||||||
createdAt: timestamp("created_at").notNull().defaultNow()
|
createdAt: timestamp("created_at").notNull().defaultNow()
|
||||||
})
|
})
|
||||||
export const passwordResetTokens = pgTable("password_reset_tokens", {
|
|
||||||
id: uuid("id").primaryKey().defaultRandom(),
|
|
||||||
userId: uuid("user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
|
|
||||||
tokenHash: text("token_hash").notNull(),
|
|
||||||
expiresAt: timestamp("expires_at").notNull(),
|
|
||||||
usedAt: timestamp("used_at"),
|
|
||||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
||||||
})
|
|
||||||
|
|||||||
106
apps/api/src/routes/time-entry-templates.ts
Normal file
106
apps/api/src/routes/time-entry-templates.ts
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
import { FastifyInstance } from "fastify"
|
||||||
|
import { db } from "../db"
|
||||||
|
import { timeEntryTemplates } from "../db/schema"
|
||||||
|
import { eq, and, desc } from "drizzle-orm"
|
||||||
|
import { z } from "zod"
|
||||||
|
|
||||||
|
const TemplateSchema = z.object({
|
||||||
|
name: z.string().min(1),
|
||||||
|
description: z.string().optional(),
|
||||||
|
durationMinutes: z.number().int().positive()
|
||||||
|
})
|
||||||
|
|
||||||
|
const TemplateUpdateSchema = TemplateSchema.partial()
|
||||||
|
|
||||||
|
export default async function timeEntryTemplateRoutes(fastify: FastifyInstance) {
|
||||||
|
fastify.addHook("preHandler", async (request, reply) => {
|
||||||
|
try {
|
||||||
|
await request.jwtVerify()
|
||||||
|
} catch (err) {
|
||||||
|
return reply.code(401).send({ message: "Unauthorized" })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
fastify.get("/", async (request, reply) => {
|
||||||
|
const user = request.user as any
|
||||||
|
const userId = user?.id
|
||||||
|
|
||||||
|
const results = await db
|
||||||
|
.select()
|
||||||
|
.from(timeEntryTemplates)
|
||||||
|
.where(eq(timeEntryTemplates.userId, userId))
|
||||||
|
.orderBy(timeEntryTemplates.name)
|
||||||
|
|
||||||
|
return results
|
||||||
|
})
|
||||||
|
|
||||||
|
fastify.get("/:id", async (request, reply) => {
|
||||||
|
const { id } = request.params as { id: string }
|
||||||
|
const user = request.user as any
|
||||||
|
const userId = user?.id
|
||||||
|
|
||||||
|
const [template] = await db
|
||||||
|
.select()
|
||||||
|
.from(timeEntryTemplates)
|
||||||
|
.where(and(eq(timeEntryTemplates.id, id), eq(timeEntryTemplates.userId, userId)))
|
||||||
|
.limit(1)
|
||||||
|
|
||||||
|
if (!template) {
|
||||||
|
return reply.code(404).send({ message: "Template not found" })
|
||||||
|
}
|
||||||
|
|
||||||
|
return template
|
||||||
|
})
|
||||||
|
|
||||||
|
fastify.post("/", async (request, reply) => {
|
||||||
|
const user = request.user as any
|
||||||
|
const userId = user?.id
|
||||||
|
const body = TemplateSchema.parse(request.body)
|
||||||
|
|
||||||
|
const [template] = await db
|
||||||
|
.insert(timeEntryTemplates)
|
||||||
|
.values({
|
||||||
|
...body,
|
||||||
|
userId: userId
|
||||||
|
})
|
||||||
|
.returning()
|
||||||
|
|
||||||
|
return reply.code(201).send(template)
|
||||||
|
})
|
||||||
|
|
||||||
|
fastify.patch("/:id", async (request, reply) => {
|
||||||
|
const { id } = request.params as { id: string }
|
||||||
|
const user = request.user as any
|
||||||
|
const userId = user?.id
|
||||||
|
const body = TemplateUpdateSchema.parse(request.body)
|
||||||
|
|
||||||
|
const [template] = await db
|
||||||
|
.update(timeEntryTemplates)
|
||||||
|
.set(body)
|
||||||
|
.where(and(eq(timeEntryTemplates.id, id), eq(timeEntryTemplates.userId, userId)))
|
||||||
|
.returning()
|
||||||
|
|
||||||
|
if (!template) {
|
||||||
|
return reply.code(404).send({ message: "Template not found" })
|
||||||
|
}
|
||||||
|
|
||||||
|
return template
|
||||||
|
})
|
||||||
|
|
||||||
|
fastify.delete("/:id", async (request, reply) => {
|
||||||
|
const { id } = request.params as { id: string }
|
||||||
|
const user = request.user as any
|
||||||
|
const userId = user?.id
|
||||||
|
|
||||||
|
const [template] = await db
|
||||||
|
.delete(timeEntryTemplates)
|
||||||
|
.where(and(eq(timeEntryTemplates.id, id), eq(timeEntryTemplates.userId, userId)))
|
||||||
|
.returning()
|
||||||
|
|
||||||
|
if (!template) {
|
||||||
|
return reply.code(404).send({ message: "Template not found" })
|
||||||
|
}
|
||||||
|
|
||||||
|
return reply.code(204).send()
|
||||||
|
})
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user