create-loadout 1.0.1 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,343 +1,345 @@
1
1
  export const neonDrizzleTemplates = {
2
- drizzleConfig: `import { defineConfig } from 'drizzle-kit';
3
- import { DATABASE_URL } from './lib/config';
4
-
5
- export default defineConfig({
6
- schema: './lib/db/schema.ts',
7
- out: './drizzle',
8
- dialect: 'postgresql',
9
- dbCredentials: {
10
- url: DATABASE_URL,
11
- },
12
- });
2
+ drizzleConfig: `import { defineConfig } from 'drizzle-kit';
3
+ import { DATABASE_URL } from './lib/config';
4
+
5
+ export default defineConfig({
6
+ schema: './lib/db/schema.ts',
7
+ out: './drizzle',
8
+ dialect: 'postgresql',
9
+ dbCredentials: {
10
+ url: DATABASE_URL,
11
+ },
12
+ });
13
13
  `,
14
- dbClient: `import { neon } from '@neondatabase/serverless';
15
- import { drizzle } from 'drizzle-orm/neon-http';
16
- import * as schema from './schema';
17
- import { DATABASE_URL } from '@/lib/config';
18
-
19
- const sql = neon(DATABASE_URL);
20
-
21
- export const db = drizzle({ client: sql, schema });
22
-
23
- export { sql };
14
+ dbClient: `import { neon } from '@neondatabase/serverless';
15
+ import { drizzle } from 'drizzle-orm/neon-http';
16
+ import * as schema from './schema';
17
+ import { DATABASE_URL } from '@/lib/config';
18
+
19
+ const sql = neon(DATABASE_URL);
20
+
21
+ export const db = drizzle({ client: sql, schema });
22
+
23
+ export { sql };
24
24
  `,
25
- schema: `import { boolean, pgTable, text, timestamp, uuid } from 'drizzle-orm/pg-core';
26
-
27
- export const todos = pgTable('todos', {
28
- id: uuid('id').primaryKey().defaultRandom(),
29
- title: text('title').notNull(),
30
- description: text('description'),
31
- completed: boolean('completed').notNull().default(false),
32
- createdAt: timestamp('created_at').defaultNow().notNull(),
33
- updatedAt: timestamp('updated_at').defaultNow().notNull(),
34
- });
25
+ schema: `import { boolean, pgTable, text, timestamp, uuid } from 'drizzle-orm/pg-core';
26
+
27
+ export const todos = pgTable('todos', {
28
+ id: uuid('id').primaryKey().defaultRandom(),
29
+ title: text('title').notNull(),
30
+ description: text('description'),
31
+ completed: boolean('completed').notNull().default(false),
32
+ createdAt: timestamp('created_at').defaultNow().notNull(),
33
+ updatedAt: timestamp('updated_at').defaultNow().notNull(),
34
+ });
35
35
  `,
36
- dbIndex: `export { db, sql } from './client';
37
- export * from './schema';
36
+ dbIndex: `export { db, sql } from './client';
37
+ export * from './schema';
38
38
  `,
39
- todoDto: `import { todos } from '@/lib/db/schema';
40
- import { InferInsertModel, InferSelectModel } from 'drizzle-orm';
41
-
42
- export type TodoInsertDto = InferInsertModel<typeof todos>;
43
- export type TodoDto = InferSelectModel<typeof todos>;
39
+ todoDto: `import { todos } from '@/lib/db/schema';
40
+ import { InferInsertModel, InferSelectModel } from 'drizzle-orm';
41
+
42
+ export type TodoInsertDto = InferInsertModel<typeof todos>;
43
+ export type TodoDto = InferSelectModel<typeof todos>;
44
44
  `,
45
- todoView: `export type TodoView = {
46
- id: string;
47
- title: string;
48
- description: string | null;
49
- completed: boolean;
50
- createdAt: Date;
51
- };
45
+ todoView: `export type TodoView = {
46
+ id: string;
47
+ title: string;
48
+ description: string | null;
49
+ completed: boolean;
50
+ createdAt: Date;
51
+ };
52
52
  `,
53
- todoCreateSchema: `import { z } from 'zod';
54
-
55
- export const TodoCreateFormSchema = z.object({
56
- title: z.string().min(1, 'Title is required'),
57
- description: z.string().optional(),
58
- });
59
-
60
- export type TodoCreateFormPayload = z.infer<typeof TodoCreateFormSchema>;
61
-
62
- export type TodoCreateServiceRequest = TodoCreateFormPayload;
63
-
64
- export type TodoCreateServiceResult = {
65
- todoId: string;
66
- };
53
+ todoCreateSchema: `import { z } from 'zod';
54
+
55
+ export const TodoCreateFormSchema = z.object({
56
+ title: z.string().min(1, 'Title is required'),
57
+ description: z.string().optional(),
58
+ });
59
+
60
+ export type TodoCreateFormPayload = z.infer<typeof TodoCreateFormSchema>;
61
+
62
+ export type TodoCreateServiceRequest = TodoCreateFormPayload;
63
+
64
+ export type TodoCreateServiceResult = {
65
+ todoId: string;
66
+ };
67
67
  `,
68
- todoCreateState: `export type TodoCreateState = {
69
- success: boolean;
70
- error: string | null;
71
- data: { todoId: string } | null;
72
- };
73
-
74
- export const initialTodoCreateState: TodoCreateState = {
75
- success: false,
76
- error: null,
77
- data: null,
78
- };
68
+ todoCreateState: `export type TodoCreateState = {
69
+ success: boolean;
70
+ error: string | null;
71
+ data: { todoId: string } | null;
72
+ };
73
+
74
+ export const initialTodoCreateState: TodoCreateState = {
75
+ success: false,
76
+ error: null,
77
+ data: null,
78
+ };
79
79
  `,
80
- todoUpdateSchema: `import { z } from 'zod';
81
-
82
- export const TodoUpdateFormSchema = z.object({
83
- id: z.string().uuid(),
84
- title: z.string().min(1, 'Title is required').optional(),
85
- description: z.string().optional(),
86
- completed: z
87
- .string()
88
- .transform((val) => val === 'true')
89
- .optional(),
90
- });
91
-
92
- export type TodoUpdateFormPayload = z.infer<typeof TodoUpdateFormSchema>;
93
-
94
- export type TodoUpdateServiceRequest = {
95
- id: string;
96
- title?: string;
97
- description?: string;
98
- completed?: boolean;
99
- };
100
-
101
- export type TodoUpdateServiceResult = {
102
- todoId: string;
103
- };
80
+ todoUpdateSchema: `import { z } from 'zod';
81
+
82
+ export const TodoUpdateFormSchema = z.object({
83
+ id: z.string().uuid(),
84
+ title: z.string().min(1, 'Title is required').optional(),
85
+ description: z.string().optional(),
86
+ completed: z
87
+ .string()
88
+ .transform((val) => val === 'true')
89
+ .optional(),
90
+ });
91
+
92
+ export type TodoUpdateFormPayload = z.infer<typeof TodoUpdateFormSchema>;
93
+
94
+ export type TodoUpdateServiceRequest = {
95
+ id: string;
96
+ title?: string;
97
+ description?: string;
98
+ completed?: boolean;
99
+ };
100
+
101
+ export type TodoUpdateServiceResult = {
102
+ todoId: string;
103
+ };
104
104
  `,
105
- todoUpdateState: `export type TodoUpdateState = {
106
- success: boolean;
107
- error: string | null;
108
- data: { todoId: string } | null;
109
- };
110
-
111
- export const initialTodoUpdateState: TodoUpdateState = {
112
- success: false,
113
- error: null,
114
- data: null,
115
- };
105
+ todoUpdateState: `export type TodoUpdateState = {
106
+ success: boolean;
107
+ error: string | null;
108
+ data: { todoId: string } | null;
109
+ };
110
+
111
+ export const initialTodoUpdateState: TodoUpdateState = {
112
+ success: false,
113
+ error: null,
114
+ data: null,
115
+ };
116
116
  `,
117
- todoDao: `import { eq } from 'drizzle-orm';
118
- import { db } from '@/lib/db/client';
119
- import { todos } from '@/lib/db/schema';
120
- import type { TodoDto, TodoInsertDto } from '@/models/todo.dto';
121
-
122
- export class TodoDAO {
123
- async create(dto: TodoInsertDto): Promise<TodoDto | undefined> {
124
- const [created] = await db.insert(todos).values(dto).returning();
125
- return created;
126
- }
127
-
128
- async getById(id: string): Promise<TodoDto | undefined> {
129
- return await db.query.todos.findFirst({
130
- where: eq(todos.id, id),
131
- });
132
- }
133
-
134
- async getAll(): Promise<TodoDto[]> {
135
- return await db.query.todos.findMany({
136
- orderBy: (todos, { desc }) => [desc(todos.createdAt)],
137
- });
138
- }
139
-
140
- async update(id: string, dto: Partial<TodoInsertDto>): Promise<TodoDto | undefined> {
141
- const [updated] = await db
142
- .update(todos)
143
- .set({ ...dto, updatedAt: new Date() })
144
- .where(eq(todos.id, id))
145
- .returning();
146
- return updated;
147
- }
148
-
149
- async delete(id: string): Promise<void> {
150
- await db.delete(todos).where(eq(todos.id, id));
151
- }
152
- }
153
-
154
- export const todoDAO = new TodoDAO();
117
+ todoDao: `import { eq } from 'drizzle-orm';
118
+ import { db } from '@/lib/db/client';
119
+ import { todos } from '@/lib/db/schema';
120
+ import type { TodoDto, TodoInsertDto } from '@/models/todo.dto';
121
+
122
+ export class TodoDAO {
123
+ async create(dto: TodoInsertDto): Promise<TodoDto | undefined> {
124
+ const [created] = await db.insert(todos).values(dto).returning();
125
+ return created;
126
+ }
127
+
128
+ async getById(id: string): Promise<TodoDto | undefined> {
129
+ return await db.query.todos.findFirst({
130
+ where: eq(todos.id, id),
131
+ });
132
+ }
133
+
134
+ async getAll(): Promise<TodoDto[]> {
135
+ return await db.query.todos.findMany({
136
+ orderBy: (todos, { desc }) => [desc(todos.createdAt)],
137
+ });
138
+ }
139
+
140
+ async update(id: string, dto: Partial<TodoInsertDto>): Promise<TodoDto | undefined> {
141
+ const [updated] = await db
142
+ .update(todos)
143
+ .set({ ...dto, updatedAt: new Date() })
144
+ .where(eq(todos.id, id))
145
+ .returning();
146
+ return updated;
147
+ }
148
+
149
+ async delete(id: string): Promise<void> {
150
+ await db.delete(todos).where(eq(todos.id, id));
151
+ }
152
+ }
153
+
154
+ export const todoDAO = new TodoDAO();
155
155
  `,
156
- todoMapper: `import type { TodoDto, TodoInsertDto } from '@/models/todo.dto';
157
- import type { TodoView } from '@/models/todo.view';
158
- import type { TodoCreateServiceRequest } from '@/models/todoCreate.schema';
159
-
160
- export class TodoMapper {
161
- toInsertDto(request: TodoCreateServiceRequest): TodoInsertDto {
162
- return {
163
- title: request.title,
164
- description: request.description ?? null,
165
- };
166
- }
167
-
168
- toView(dto: TodoDto): TodoView {
169
- return {
170
- id: dto.id,
171
- title: dto.title,
172
- description: dto.description,
173
- completed: dto.completed,
174
- createdAt: dto.createdAt,
175
- };
176
- }
177
-
178
- toViewList(dtos: TodoDto[]): TodoView[] {
179
- return dtos.map((dto) => this.toView(dto));
180
- }
181
- }
182
-
183
- export const todoMapper = new TodoMapper();
156
+ todoMapper: `import type { TodoDto, TodoInsertDto } from '@/models/todo.dto';
157
+ import type { TodoView } from '@/models/todo.view';
158
+ import type { TodoCreateServiceRequest } from '@/models/todoCreate.schema';
159
+
160
+ export class TodoMapper {
161
+ toInsertDto(request: TodoCreateServiceRequest): TodoInsertDto {
162
+ return {
163
+ title: request.title,
164
+ description: request.description ?? null,
165
+ };
166
+ }
167
+
168
+ toView(dto: TodoDto): TodoView {
169
+ return {
170
+ id: dto.id,
171
+ title: dto.title,
172
+ description: dto.description,
173
+ completed: dto.completed,
174
+ createdAt: dto.createdAt,
175
+ };
176
+ }
177
+
178
+ toViewList(dtos: TodoDto[]): TodoView[] {
179
+ return dtos.map((dto) => this.toView(dto));
180
+ }
181
+ }
182
+
183
+ export const todoMapper = new TodoMapper();
184
184
  `,
185
- todoService: `import { todoDAO, type TodoDAO } from '@/dao/todo.dao';
186
- import { todoMapper, type TodoMapper } from '@/mappers/todo.mapper';
187
- import type { TodoView } from '@/models/todo.view';
188
- import type { TodoCreateServiceRequest, TodoCreateServiceResult } from '@/models/todoCreate.schema';
189
- import type { TodoUpdateServiceRequest, TodoUpdateServiceResult } from '@/models/todoUpdate.schema';
190
-
191
- export class TodoService {
192
- constructor(
193
- private dao: TodoDAO,
194
- private mapper: TodoMapper
195
- ) {}
196
-
197
- async createTodo(request: TodoCreateServiceRequest): Promise<TodoCreateServiceResult> {
198
- const insertDto = this.mapper.toInsertDto(request);
199
- const created = await this.dao.create(insertDto);
200
-
201
- if (!created) {
202
- throw new Error('Failed to create todo');
203
- }
204
-
205
- return { todoId: created.id };
206
- }
207
-
208
- async getTodoById(id: string): Promise<TodoView | null> {
209
- const todo = await this.dao.getById(id);
210
- return todo ? this.mapper.toView(todo) : null;
211
- }
212
-
213
- async getAllTodos(): Promise<TodoView[]> {
214
- const todos = await this.dao.getAll();
215
- return this.mapper.toViewList(todos);
216
- }
217
-
218
- async updateTodo(request: TodoUpdateServiceRequest): Promise<TodoUpdateServiceResult> {
219
- const updated = await this.dao.update(request.id, {
220
- title: request.title,
221
- description: request.description,
222
- completed: request.completed,
223
- });
224
-
225
- if (!updated) {
226
- throw new Error('Todo not found');
227
- }
228
-
229
- return { todoId: updated.id };
230
- }
231
-
232
- async toggleTodo(id: string): Promise<TodoView> {
233
- const existing = await this.dao.getById(id);
234
-
235
- if (!existing) {
236
- throw new Error('Todo not found');
237
- }
238
-
239
- const updated = await this.dao.update(id, {
240
- completed: !existing.completed,
241
- });
242
-
243
- return this.mapper.toView(updated!);
244
- }
245
-
246
- async deleteTodo(id: string): Promise<void> {
247
- await this.dao.delete(id);
248
- }
249
- }
250
-
251
- export const todoService = new TodoService(todoDAO, todoMapper);
185
+ todoService: `import { todoDAO, type TodoDAO } from '@/dao/todo.dao';
186
+ import { todoMapper, type TodoMapper } from '@/mappers/todo.mapper';
187
+ import type { TodoDto } from '@/models/todo.dto';
188
+ import type { TodoCreateServiceRequest, TodoCreateServiceResult } from '@/models/todoCreate.schema';
189
+ import type { TodoUpdateServiceRequest, TodoUpdateServiceResult } from '@/models/todoUpdate.schema';
190
+
191
+ export class TodoService {
192
+ constructor(
193
+ private dao: TodoDAO,
194
+ private mapper: TodoMapper
195
+ ) {}
196
+
197
+ async createTodo(request: TodoCreateServiceRequest): Promise<TodoCreateServiceResult> {
198
+ const insertDto = this.mapper.toInsertDto(request);
199
+ const created = await this.dao.create(insertDto);
200
+
201
+ if (!created) {
202
+ throw new Error('Failed to create todo');
203
+ }
204
+
205
+ return { todoId: created.id };
206
+ }
207
+
208
+ async getTodoById(id: string): Promise<TodoDto | null> {
209
+ return (await this.dao.getById(id)) ?? null;
210
+ }
211
+
212
+ async getAllTodos(): Promise<TodoDto[]> {
213
+ return await this.dao.getAll();
214
+ }
215
+
216
+ async updateTodo(request: TodoUpdateServiceRequest): Promise<TodoUpdateServiceResult> {
217
+ const updated = await this.dao.update(request.id, {
218
+ title: request.title,
219
+ description: request.description,
220
+ completed: request.completed,
221
+ });
222
+
223
+ if (!updated) {
224
+ throw new Error('Todo not found');
225
+ }
226
+
227
+ return { todoId: updated.id };
228
+ }
229
+
230
+ async toggleTodo(id: string): Promise<TodoDto> {
231
+ const existing = await this.dao.getById(id);
232
+
233
+ if (!existing) {
234
+ throw new Error('Todo not found');
235
+ }
236
+
237
+ const updated = await this.dao.update(id, {
238
+ completed: !existing.completed,
239
+ });
240
+
241
+ if (!updated) {
242
+ throw new Error('Failed to update todo');
243
+ }
244
+
245
+ return updated;
246
+ }
247
+
248
+ async deleteTodo(id: string): Promise<void> {
249
+ await this.dao.delete(id);
250
+ }
251
+ }
252
+
253
+ export const todoService = new TodoService(todoDAO, todoMapper);
252
254
  `,
253
- todoActions: `'use server';
254
-
255
- import { revalidatePath } from 'next/cache';
256
- import { z } from 'zod';
257
- import { todoService } from '@/services/todo.service';
258
- import { TodoCreateFormSchema } from '@/models/todoCreate.schema';
259
- import { TodoUpdateFormSchema } from '@/models/todoUpdate.schema';
260
- import type { TodoCreateState } from '@/models/todoCreate.state';
261
- import type { TodoUpdateState } from '@/models/todoUpdate.state';
262
-
263
- export async function createTodo(
264
- state: TodoCreateState,
265
- formData: FormData
266
- ): Promise<TodoCreateState> {
267
- const rawData = Object.fromEntries(formData);
268
- const validated = TodoCreateFormSchema.safeParse(rawData);
269
-
270
- if (!validated.success) {
271
- return {
272
- success: false,
273
- error: z.prettifyError(validated.error),
274
- data: null,
275
- };
276
- }
277
-
278
- try {
279
- const result = await todoService.createTodo(validated.data);
280
-
281
- revalidatePath('/todos');
282
-
283
- return {
284
- success: true,
285
- error: null,
286
- data: result,
287
- };
288
- } catch (error) {
289
- console.error('Error creating todo:', error);
290
- return {
291
- success: false,
292
- error: error instanceof Error ? error.message : 'Failed to create todo',
293
- data: null,
294
- };
295
- }
296
- }
297
-
298
- export async function updateTodo(
299
- state: TodoUpdateState,
300
- formData: FormData
301
- ): Promise<TodoUpdateState> {
302
- const rawData = Object.fromEntries(formData);
303
- const validated = TodoUpdateFormSchema.safeParse(rawData);
304
-
305
- if (!validated.success) {
306
- return {
307
- success: false,
308
- error: z.prettifyError(validated.error),
309
- data: null,
310
- };
311
- }
312
-
313
- try {
314
- const result = await todoService.updateTodo(validated.data);
315
-
316
- revalidatePath('/todos');
317
-
318
- return {
319
- success: true,
320
- error: null,
321
- data: result,
322
- };
323
- } catch (error) {
324
- console.error('Error updating todo:', error);
325
- return {
326
- success: false,
327
- error: error instanceof Error ? error.message : 'Failed to update todo',
328
- data: null,
329
- };
330
- }
331
- }
332
-
333
- export async function toggleTodo(id: string): Promise<void> {
334
- await todoService.toggleTodo(id);
335
- revalidatePath('/todos');
336
- }
337
-
338
- export async function deleteTodo(id: string): Promise<void> {
339
- await todoService.deleteTodo(id);
340
- revalidatePath('/todos');
341
- }
255
+ todoActions: `'use server';
256
+
257
+ import { revalidatePath } from 'next/cache';
258
+ import { z } from 'zod';
259
+ import { todoService } from '@/services/todo.service';
260
+ import { TodoCreateFormSchema } from '@/models/todoCreate.schema';
261
+ import { TodoUpdateFormSchema } from '@/models/todoUpdate.schema';
262
+ import type { TodoCreateState } from '@/models/todoCreate.state';
263
+ import type { TodoUpdateState } from '@/models/todoUpdate.state';
264
+
265
+ export async function createTodo(
266
+ state: TodoCreateState,
267
+ formData: FormData
268
+ ): Promise<TodoCreateState> {
269
+ const rawData = Object.fromEntries(formData);
270
+ const validated = TodoCreateFormSchema.safeParse(rawData);
271
+
272
+ if (!validated.success) {
273
+ return {
274
+ success: false,
275
+ error: z.prettifyError(validated.error),
276
+ data: null,
277
+ };
278
+ }
279
+
280
+ try {
281
+ const result = await todoService.createTodo(validated.data);
282
+
283
+ revalidatePath('/todos');
284
+
285
+ return {
286
+ success: true,
287
+ error: null,
288
+ data: result,
289
+ };
290
+ } catch (error) {
291
+ console.error('Error creating todo:', error);
292
+ return {
293
+ success: false,
294
+ error: error instanceof Error ? error.message : 'Failed to create todo',
295
+ data: null,
296
+ };
297
+ }
298
+ }
299
+
300
+ export async function updateTodo(
301
+ state: TodoUpdateState,
302
+ formData: FormData
303
+ ): Promise<TodoUpdateState> {
304
+ const rawData = Object.fromEntries(formData);
305
+ const validated = TodoUpdateFormSchema.safeParse(rawData);
306
+
307
+ if (!validated.success) {
308
+ return {
309
+ success: false,
310
+ error: z.prettifyError(validated.error),
311
+ data: null,
312
+ };
313
+ }
314
+
315
+ try {
316
+ const result = await todoService.updateTodo(validated.data);
317
+
318
+ revalidatePath('/todos');
319
+
320
+ return {
321
+ success: true,
322
+ error: null,
323
+ data: result,
324
+ };
325
+ } catch (error) {
326
+ console.error('Error updating todo:', error);
327
+ return {
328
+ success: false,
329
+ error: error instanceof Error ? error.message : 'Failed to update todo',
330
+ data: null,
331
+ };
332
+ }
333
+ }
334
+
335
+ export async function toggleTodo(id: string): Promise<void> {
336
+ await todoService.toggleTodo(id);
337
+ revalidatePath('/todos');
338
+ }
339
+
340
+ export async function deleteTodo(id: string): Promise<void> {
341
+ await todoService.deleteTodo(id);
342
+ revalidatePath('/todos');
343
+ }
342
344
  `,
343
345
  };
@@ -1,6 +1,3 @@
1
1
  export declare const stripeTemplates: {
2
2
  paymentService: string;
3
- checkoutRoute: string;
4
- webhooksRoute: string;
5
- portalRoute: string;
6
3
  };