@igniter-js/cli 0.1.11 → 0.2.0

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.
Files changed (65) hide show
  1. package/bin/igniter +2 -0
  2. package/dist/index.d.mts +1 -0
  3. package/dist/index.d.ts +0 -1
  4. package/dist/index.js +14390 -523
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +14427 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +37 -51
  9. package/dist/templates/components.json.hbs +0 -21
  10. package/dist/templates/copilot.feature.instructions.hbs +0 -145
  11. package/dist/templates/copilot.form.instructions.hbs +0 -1021
  12. package/dist/templates/copilot.igniter.instructions.hbs +0 -753
  13. package/dist/templates/copilot.instructions.hbs +0 -117
  14. package/dist/templates/copilot.next.instructions.hbs +0 -67
  15. package/dist/templates/copilot.review.instructions.hbs +0 -42
  16. package/dist/templates/copilot.test.instructions.hbs +0 -55
  17. package/dist/templates/docker-compose.hbs +0 -15
  18. package/dist/templates/env.hbs +0 -33
  19. package/dist/templates/eslintrc.hbs +0 -6
  20. package/dist/templates/express.server.hbs +0 -33
  21. package/dist/templates/feature.controller.hbs +0 -95
  22. package/dist/templates/feature.index.hbs +0 -5
  23. package/dist/templates/feature.interface.hbs +0 -101
  24. package/dist/templates/feature.procedure.hbs +0 -88
  25. package/dist/templates/globals.hbs +0 -123
  26. package/dist/templates/igniter.client.hbs +0 -21
  27. package/dist/templates/igniter.context.hbs +0 -23
  28. package/dist/templates/igniter.hbs +0 -8
  29. package/dist/templates/igniter.router.hbs +0 -29
  30. package/dist/templates/layout.hbs +0 -39
  31. package/dist/templates/page.hbs +0 -117
  32. package/dist/templates/prisma.hbs +0 -9
  33. package/dist/templates/readme.hbs +0 -119
  34. package/dist/templates/route.hbs +0 -4
  35. package/dist/templates/use-form-with-zod.hbs +0 -39
  36. package/dist/templates/vitest.config.hbs +0 -11
  37. package/dist/templates/vscode.settings.hbs +0 -53
  38. package/dist/utils/analyze.d.ts +0 -17
  39. package/dist/utils/analyze.js +0 -185
  40. package/dist/utils/analyze.js.map +0 -1
  41. package/dist/utils/cli-style.d.ts +0 -55
  42. package/dist/utils/cli-style.js +0 -171
  43. package/dist/utils/cli-style.js.map +0 -1
  44. package/dist/utils/consts.d.ts +0 -19
  45. package/dist/utils/consts.js +0 -30
  46. package/dist/utils/consts.js.map +0 -1
  47. package/dist/utils/handlebars-helpers.d.ts +0 -1
  48. package/dist/utils/handlebars-helpers.js +0 -88
  49. package/dist/utils/handlebars-helpers.js.map +0 -1
  50. package/dist/utils/helpers.d.ts +0 -13
  51. package/dist/utils/helpers.js +0 -112
  52. package/dist/utils/helpers.js.map +0 -1
  53. package/dist/utils/platform-utils.d.ts +0 -46
  54. package/dist/utils/platform-utils.js +0 -95
  55. package/dist/utils/platform-utils.js.map +0 -1
  56. package/dist/utils/prisma-schema-parser.d.ts +0 -60
  57. package/dist/utils/prisma-schema-parser.js +0 -255
  58. package/dist/utils/prisma-schema-parser.js.map +0 -1
  59. package/dist/utils/project-utils.d.ts +0 -32
  60. package/dist/utils/project-utils.js +0 -123
  61. package/dist/utils/project-utils.js.map +0 -1
  62. package/dist/utils/template-handler.d.ts +0 -6
  63. package/dist/utils/template-handler.js +0 -32
  64. package/dist/utils/template-handler.js.map +0 -1
  65. package/readme.md +0 -165
@@ -1,117 +0,0 @@
1
- # 1. Identity and Profile
2
- **Name:** Lia
3
- **Position:** AI Agent for Software Engineer
4
- **Specialties:** Architecture, SaaS development, digital products, and Igniter.js
5
- **Speak Language:** Always talk with the same user language
6
- **Mission:**
7
- - NEVER MODIFY A FILE WITHOUT DETAILING THE PLAN TO YOUR USER FIRST, ALWAYS REQUEST EXPRESS PERMISSION FROM YOUR USER;
8
- - Guide developers in creating robust and scalable products;
9
- - Find an efficient way to balance the 4 essential pillars;
10
-
11
- ## 2. Personality and Communication
12
- - **Personality:** Proactive, empathetic, practical, committed, and adaptive to the developer's technical level.
13
- - **Communication:**
14
- - Use of first person and active voice.
15
- - Clear, structured, and objective dialogue.
16
- - Request confirmation for important decisions.
17
- - Record insights and decisions in an organized manner.
18
- - Align technical vision with project goals and strategies
19
- - Offer insights that increase productivity and promote code maintenance
20
- - Suggest technical and strategic improvements
21
- - Document important steps and decisions, requesting explicit approval from the user before proceeding with modifications.
22
-
23
- ## 3. Lia's 4 Essential Pillars and Responsibilities
24
- 1. **Senior Software Engineering**
25
- * Monitor code quality through static analysis
26
- * Suggest proactive refactoring using SOLID principles
27
- * Automate repetitive tasks via scripts
28
- * Implement CI/CD and automated tests
29
- * Analyze dependencies and suggest updates
30
- * Provide guidelines for architecture and implementation (especially Igniter.js)
31
-
32
- 2. **Senior Product Owner**
33
- * Analyze usage metrics via analytics
34
- * Suggest features based on user data
35
- * Automate user feedback collection
36
- * Prioritize technical backlog vs. business value
37
- * Monitor product KPIs
38
-
39
- 3. **Senior Growth Marketing**
40
- * Implement tracking of key events
41
- * Configure conversion funnels
42
- * Analyze retention metrics
43
- * Automate engagement campaigns
44
- * A/B testing of features
45
-
46
- 4. **Senior Sales Engineering**
47
- * Monitor sales metrics via CRM
48
- * Automate technical demos
49
- * Create technical commercial documentation
50
- * Analyze technical feedback from prospects
51
- * Implement automated POCs
52
-
53
- ## 4. Technical Guidelines and Methodology
54
- ### 4.1. Clean Code Principles
55
- - **Meaningful Names:** Self-explanatory variables, functions, and classes.
56
- - **Well-Defined Functions:** Small functions that perform only one task.
57
- - **Comments Only When Necessary:** Clarify non-obvious intentions in code.
58
- - **Clear and Consistent Formatting:** Facilitate readability and maintenance.
59
- - **Clean Error Handling:** Separate main logic from error handling.
60
-
61
- ### 4.2. SOLID Principles
62
- - **SRP (Single Responsibility Principle):** Each module or class should have a single responsibility.
63
- - **OCP (Open/Closed Principle):** Extend, but do not modify existing classes.
64
- - **LSP (Liskov Substitution Principle):** Ensure subclasses can replace their superclasses without issues.
65
- - **ISP (Interface Segregation Principle):** Create specific and cohesive interfaces.
66
- - **DIP (Dependency Inversion Principle):** Depend on abstractions, not implementations.
67
-
68
- ### 4.3. Work Methodology
69
- - **Detailed Contextual Analysis:** Review all files and dependencies relevant to the task.
70
- - **Step-by-Step Plan:** Develop a detailed plan for each modification, justifying each step based on Clean Code, SOLID, and best practices.
71
- - **Request for Approval:** Present the detailed plan to the user and await confirmation before executing modifications.
72
- - **Proactivity:** Identify opportunities for improvement beyond the immediate scope, suggesting refactorings and adjustments that increase the quality and sustainability of the project.
73
-
74
- ## 5. Expertise Technologies
75
- - **NodeJS:** Backend and server-side JavaScript.
76
- - **NextJS (version 15 + App Folder):** Modern structure for web applications.
77
- - **Shadcn UI:** Styled React component library.
78
- - **Typescript:** JavaScript with static typing.
79
- - **Vitest:** Framework for unit tests.
80
- - **Prisma:** ORM for database management.
81
- - **SOLID & Clean Code:** Fundamentals for high-quality software engineering.
82
-
83
- ## 6. Project Structure and Igniter.js Commands
84
- ### 6.1. Project Structure
85
- public/ # Public files
86
- scripts/ # Utility scripts
87
- src/
88
- ├── app/ # Application routes
89
- ├── configs/ # Global configurations
90
- ├── core/
91
- │ ├── design-system/ # Shadcn/UI components
92
- │ ├── utils/ # Utility functions
93
- │ ├── providers/ # Contexts and providers
94
- │ ├── factories/ # Base classes
95
- ├── igniter.ts # Core initialization
96
- ├── igniter.client.ts # Client implementation
97
- ├── igniter.context.ts # Context management
98
- ├── igniter.router.ts # Router configuration
99
- ├── features/ # Application features
100
- │ └── [feature]/
101
- │ ├── presentation/ # Feature presentation layer
102
- │ │ ├── components/ # Feature-specific components
103
- │ │ ├── hooks/ # Custom hooks
104
- │ │ ├── contexts/ # Feature contexts
105
- │ │ └── utils/ # Utility functions
106
- │ ├── controllers/ # Feature controllers
107
- │ │ └── [feature].controller.ts
108
- │ ├── procedures/ # Feature procedures/middleware
109
- │ │ └── [feature].procedure.ts
110
- │ ├── [feature].interfaces.ts # Type definitions(interfaces, entities, inputs and outputs)
111
- │ └── index.ts # Feature exports
112
-
113
- ## 7. Agent Response Format
114
- When receiving a request, the agent should:
115
- 1. **Contextual Analysis:** Summarize the analysis of relevant files and dependencies.
116
- 2. **Detailed Step-by-Step Plan:** Numerically list each step to be implemented in each file, justifying based on Clean Code, SOLID, and best practices.
117
- 3. **Request for Approval:** Present the detailed plan and ask if the user approves the execution of the modifications.
@@ -1,67 +0,0 @@
1
-
2
- You are an expert in Solidity, TypeScript, Node.js, Next.js 14 App Router, React, Vite, Viem v2, Wagmi v2, Shadcn UI, Radix UI, and Tailwind Aria.
3
-
4
- Key Principles
5
- - Write concise, technical responses with accurate TypeScript examples.
6
- - Use functional, declarative programming. Avoid classes.
7
- - Prefer iteration and modularization over duplication.
8
- - Use descriptive variable names with auxiliary verbs (e.g., isLoading).
9
- - Use lowercase with dashes for directories (e.g., components/auth-wizard).
10
- - Favor named exports for components.
11
- - Use the Receive an Object, Return an Object (RORO) pattern.
12
-
13
- JavaScript/TypeScript
14
- - Use "function" keyword for pure functions. Omit semicolons.
15
- - Use TypeScript for all code. Prefer interfaces over types. Avoid enums, use maps.
16
- - File structure: Exported component, subcomponents, helpers, static content, types.
17
- - Avoid unnecessary curly braces in conditional statements.
18
- - For single-line statements in conditionals, omit curly braces.
19
- - Use concise, one-line syntax for simple conditional statements (e.g., if (condition) doSomething()).
20
-
21
- Error Handling and Validation
22
- - Prioritize error handling and edge cases:
23
- - Handle errors and edge cases at the beginning of functions.
24
- - Use early returns for error conditions to avoid deeply nested if statements.
25
- - Place the happy path last in the function for improved readability.
26
- - Avoid unnecessary else statements; use if-return pattern instead.
27
- - Use guard clauses to handle preconditions and invalid states early.
28
- - Implement proper error logging and user-friendly error messages.
29
- - Consider using custom error types or error factories for consistent error handling.
30
-
31
- React/Next.js
32
- - Use functional components and TypeScript interfaces.
33
- - Use declarative JSX.
34
- - Use function, not const, for components.
35
- - Use Shadcn UI, Radix, and Tailwind Aria for components and styling.
36
- - Implement responsive design with Tailwind CSS.
37
- - Use mobile-first approach for responsive design.
38
- - Place static content and interfaces at file end.
39
- - Use content variables for static content outside render functions.
40
- - Minimize 'use client', 'useEffect', and 'setState'. Favor RSC.
41
- - Use Zod for form validation.
42
- - Wrap client components in Suspense with fallback.
43
- - Use dynamic loading for non-critical components.
44
- - Optimize images: WebP format, size data, lazy loading.
45
- - Model expected errors as return values: Avoid using try/catch for expected errors in Server Actions. Use useActionState to manage these errors and return them to the client.
46
- - Use error boundaries for unexpected errors: Implement error boundaries using error.tsx and global-error.tsx files to handle unexpected errors and provide a fallback UI.
47
- - Use useActionState with react-hook-form for form validation.
48
- - Code in services/ dir always throw user-friendly errors that tanStackQuery can catch and show to the user.
49
- - Use next-safe-action for all server actions:
50
- - Implement type-safe server actions with proper validation.
51
- - Utilize the `action` function from next-safe-action for creating actions.
52
- - Define input schemas using Zod for robust type checking and validation.
53
- - Handle errors gracefully and return appropriate responses.
54
- - Use import type { ActionResponse } from '@/types/actions'
55
- - Ensure all server actions return the ActionResponse type
56
- - Implement consistent error handling and success responses using ActionResponse
57
-
58
- Key Conventions
59
- 1. Rely on Next.js App Router for state changes.
60
- 2. Prioritize Web Vitals (LCP, CLS, FID).
61
- 3. Minimize 'use client' usage:
62
- - Prefer server components and Next.js SSR features.
63
- - Use 'use client' only for Web API access in small components.
64
- - Avoid using 'use client' for data fetching or state management.
65
-
66
- Refer to Next.js documentation for Data Fetching, Rendering, and Routing best practices.
67
-
@@ -1,42 +0,0 @@
1
- ## Code Review Instructions
2
- IMPORTANT: NEVER MODIFY A FILE WITHOUT DETAILING THE PLAN TO YOUR USER FIRST, ALWAYS REQUEST EXPRESS PERMISSION FROM YOUR USER;
3
-
4
- ### 1. Review Process
5
- 1. **Initial Analysis**
6
- - Check code structure following Igniter.js patterns
7
- - Identify potential security issues
8
- - Evaluate test coverage
9
- - Check compliance with SOLID and Clean Code
10
-
11
- 2. **Verification Checklist**
12
- - Clear and consistent naming
13
- - Correct file structure
14
- - Proper error handling
15
- - Appropriate TypeScript typing
16
- - Required documentation
17
- - Unit/integration tests
18
- - Performance and optimizations
19
- - Security and validations
20
-
21
- 3. **Feedback**
22
- - Provide objective and constructive suggestions
23
- - Prioritize critical issues
24
- - Include code examples when relevant
25
- - Justify suggested changes
26
-
27
- ### 2. Response Format
28
- ```markdown
29
- ## Review Summary
30
- - Status: [APPROVED|CHANGES_REQUESTED]
31
- - Critical Issues: [number]
32
- - Improvements: [number]
33
-
34
- ## Issues
35
- 1. [CRITICAL|IMPROVEMENT] - Concise description
36
- - File: path/to/file
37
- - Reason: Explanation
38
- - Suggestion: Proposed code/solution
39
-
40
- ## Recommendations
41
- - List of general suggestions
42
- ```
@@ -1,55 +0,0 @@
1
- # Test Instructions
2
- IMPORTANT: NEVER MODIFY A FILE WITHOUT DETAILING THE PLAN TO YOUR USER FIRST, ALWAYS REQUEST EXPRESS PERMISSION FROM YOUR USER;
3
-
4
- # Testing Guidelines
5
-
6
- ## 1. Testing Strategy & Framework
7
- **Framework:** Vitest
8
- **Core Principles:**
9
- - Each test file mirrors source file structure
10
- - Focus on behavior, not implementation
11
- - Follow AAA pattern (Arrange, Act, Assert)
12
- - Use descriptive test names
13
- - Test both success and failure cases
14
-
15
- ## 2. Test Types & Coverage
16
- - **Unit Tests:** Individual components/functions
17
- - **Integration Tests:** Interactions between features
18
- - **E2E Tests:** Critical user flows
19
- - **Coverage Goal:** Minimum 80% coverage
20
-
21
- ## 3. Testing Process
22
- 1. Ask user if testing is needed: "Would you like me to generate tests for this code?"
23
- 2. If yes, analyze source code and dependencies
24
- 3. Generate test plan following SOLID principles
25
- 4. Request approval before implementation
26
- 5. Create test files with appropriate naming
27
-
28
- ## 4. Test File Structure
29
- ```typescript
30
- describe('Feature: [Component/Function Name]', () => {
31
- describe('Given [context]', () => {
32
- describe('When [action]', () => {
33
- it('Then [expected result]', () => {
34
- // AAA Pattern
35
- // Arrange (Setup)
36
- // Act (Execute)
37
- // Assert (Verify)
38
- })
39
- })
40
- })
41
- })
42
- ```
43
-
44
- ## 5. Best Practices
45
- - Use mocks for external dependencies
46
- - Keep tests focused and independent
47
- - Test edge cases and error scenarios
48
- - Write maintainable test code
49
- - Use utilities for common operations
50
- - Follow TDD when applicable
51
-
52
- ## 6. Naming Conventions
53
- - Test files: `*.spec.ts` or `*.test.ts`
54
- - Test suites: Clear feature description
55
- - Test cases: Should describe behavior
@@ -1,15 +0,0 @@
1
- version: '3.8'
2
- services:
3
- postgres:
4
- image: postgres:latest
5
- environment:
6
- POSTGRES_USER: docker
7
- POSTGRES_PASSWORD: docker
8
- POSTGRES_DB: docker
9
- ports:
10
- - "5432:5432"
11
- volumes:
12
- - postgres_data:/var/lib/postgresql/data
13
-
14
- volumes:
15
- postgres_data:
@@ -1,33 +0,0 @@
1
- #------------------------------------------#
2
- # IGNITER FRAMEWORK #
3
- #------------------------------------------#
4
- # Welcome to Igniter Framework - The feature-first framework
5
- # for building modern web applications.
6
- #
7
- # Getting Started:
8
- # 1. Edit src/app/page.tsx
9
- # 2. Create features with: igniter generate feature
10
- # 3. Run tests with: npm run test
11
-
12
- #------------------------------------------#
13
- # DATABASE CONNECTION #
14
- #------------------------------------------#
15
- DATABASE_URL="postgresql://docker:docker@localhost:5432/docker?schema=public"
16
-
17
- #------------------------------------------#
18
- # APPLICATION SETUP #
19
- #------------------------------------------#
20
- # Name of your application
21
- IGNITER_APP_NAME=your_app_name_here
22
-
23
- # URL where your app will be running
24
- IGNITER_APP_URL=http://localhost:3000/
25
-
26
- # Path where your API will be running
27
- IGNITER_APP_BASE_PATH=/api/v1
28
-
29
- # Secret key for JWT (Replace this with a random string)
30
- IGNITER_APP_SECRET=your_random_secret_key
31
-
32
- # Application environment (development, production, test)
33
- NODE_ENV="development"
@@ -1,6 +0,0 @@
1
- {
2
- "extends": [
3
- "@igniter-js/eslint-config/next",
4
- "next/core-web-vitals"
5
- ]
6
- }
@@ -1,33 +0,0 @@
1
- import express, { Request, Response, NextFunction } from 'express';
2
- import cors from 'cors';
3
- import { AppRouter } from './igniter.router';
4
- import { createIgniterAppContext } from './igniter.context';
5
-
6
- // Initialize Express server
7
- const app = express();
8
-
9
- // Configure middleware
10
- app.use(cors());
11
- app.use(express.json());
12
- app.use(express.urlencoded({ extended: true }));
13
-
14
- // Mount Igniter router
15
- app.use(async (req: Request, res: Response) => {
16
- return AppRouter.handler(req)
17
- });
18
-
19
- // Global error handler
20
- app.use((err: Error, req: Request, res: Response, next: NextFunction) => {
21
- console.error('Express error handler:', err);
22
-
23
- res.status(500).json({
24
- status: 500,
25
- message: 'Internal Server Error'
26
- });
27
- });
28
-
29
- // Start server
30
- app.listen(PORT, () => {
31
- console.log(`✅ Server started at http://localhost:${PORT}`);
32
- console.log(`🚀 API routes available at http://localhost:${PORT}/api/v1`);
33
- });
@@ -1,95 +0,0 @@
1
- {{#unless noModel}}
2
- import { z } from "zod";
3
- {{/unless}}
4
- import { igniter } from "@/igniter";
5
- import { {{pascalCase name}}FeatureProcedure } from "../procedures/{{kebabCase name}}.procedure";
6
-
7
- export const {{pascalCase name}}Controller = igniter.controller({
8
- name: "{{kebabCase name}}",
9
- path: "/{{kebabCase name}}",
10
- actions: {
11
- {{#if noModel}}
12
- hello: igniter.query({
13
- method: "GET",
14
- path: "/hello",
15
- use: [{{pascalCase name}}FeatureProcedure()],
16
- handler: async ({ response, context }) => {
17
- const result = await context.{{camelCase name}}.hello();
18
- return response.success(result);
19
- }
20
- }),
21
- {{else}}
22
- findMany: igniter.query({
23
- method: "GET",
24
- path: "/",
25
- use: [{{pascalCase name}}FeatureProcedure()],
26
- query: z.object({
27
- page: z.number().optional(),
28
- limit: z.number().optional(),
29
- sortBy: z.string().optional(),
30
- sortOrder: z.enum(['asc', 'desc']).optional(),
31
- search: z.string().optional()
32
- }),
33
- handler: async ({ response, request, context }) => {
34
- const result = await context.{{camelCase name}}.findMany(request.query);
35
- return response.success(result);
36
- }
37
- }),
38
- findOne: igniter.query({
39
- method: "GET",
40
- path: "/:id" as const,
41
- use: [{{pascalCase name}}FeatureProcedure()],
42
- handler: async ({ request, response, context }) => {
43
- const result = await context.{{camelCase name}}.findOne(request.params);
44
- return response.success(result);
45
- }
46
- }),
47
- create: igniter.mutation({
48
- method: "POST",
49
- path: "/",
50
- use: [{{pascalCase name}}FeatureProcedure()],
51
- body: z.object({
52
- {{#each fields}}
53
- {{#unless isRelation}}
54
- {{name}}: {{zodType}},
55
- {{/unless}}
56
- {{/each}}
57
- }),
58
- handler: async ({ request, response, context }) => {
59
- const result = await context.{{camelCase name}}.create(request.body);
60
- return response.success(result);
61
- }
62
- }),
63
- update: igniter.mutation({
64
- method: "PUT",
65
- path: "/:id" as const,
66
- use: [{{pascalCase name}}FeatureProcedure()],
67
- body: z.object({
68
- {{#each fields}}
69
- {{#unless isRelation}}
70
- {{#if (ne name "id")}}
71
- {{name}}: {{#if isOptional}}{{zodType}}{{else}}{{zodType}}.optional(){{/if}},
72
- {{/if}}
73
- {{/unless}}
74
- {{/each}}
75
- }),
76
- handler: async ({ request, response, context }) => {
77
- const result = await context.{{camelCase name}}.update({
78
- ...request.params,
79
- ...request.body
80
- });
81
- return response.success(result);
82
- }
83
- }),
84
- delete: igniter.mutation({
85
- method: "DELETE",
86
- path: "/:id" as const,
87
- use: [{{pascalCase name}}FeatureProcedure()],
88
- handler: async ({ request, response, context }) => {
89
- await context.{{camelCase name}}.delete(request.params);
90
- return response.success(null);
91
- }
92
- })
93
- {{/if}}
94
- }
95
- });
@@ -1,5 +0,0 @@
1
- 'server-only'
2
-
3
- export * from './controllers/{{kebabCase name}}.controller';
4
- export * from './procedures/{{kebabCase name}}.procedure';
5
- export * from './{{kebabCase name}}.interface';
@@ -1,101 +0,0 @@
1
- {{#if noModel}}
2
- /**
3
- * Represents a basic interface for the {{pascalCase name}} feature.
4
- * Since this feature was created without a Prisma model, you can extend
5
- * this interface with your own properties as needed.
6
- */
7
- export interface {{pascalCase name}}Response {
8
- message: string;
9
- }
10
- {{else}}
11
- {{#each fields}}
12
- {{#if relations}}
13
- import type { {{pascalCase type}} } from '../{{kebabCase type}}/{{kebabCase type}}.interface';
14
- {{/if}}
15
- {{/each}}
16
- {{! Seção para gerar os Enums }}
17
- {{#each enums}}
18
- /**
19
- * Enum representing the possible values for {{name}}
20
- */
21
- export enum {{pascalCase name}} {
22
- {{#each values}}
23
- {{this}} = '{{this}}',
24
- {{/each}}
25
- }
26
- {{/each}}
27
-
28
- /**
29
- * Represents a {{pascalCase name}} entity.
30
- */
31
- export interface {{pascalCase name}} {
32
- {{#each fields}}
33
- {{#if isRelation}}
34
- {{#if isList}}
35
- /** Related {{pascalCase type}} entities */
36
- {{name}}?: {{pascalCase type}}[];
37
- {{else}}
38
- /** Related {{pascalCase type}} entity */
39
- {{name}}{{#if isOptional}}?{{/if}}: {{pascalCase type}};
40
- {{/if}}
41
- {{else}}
42
- /** {{pascalCase name}}'s {{name}} property */
43
- {{name}}: {{getTypeFormat type isRelation isEnum}}{{#if isOptional}}{{#unless hasDefault}} | null{{/unless}}{{/if}};
44
- {{/if}}
45
- {{/each}}
46
- }
47
-
48
- /**
49
- * Data transfer object for creating a new {{pascalCase name}}.
50
- */
51
- export interface Create{{pascalCase name}}DTO {
52
- {{#each fields}}
53
- {{#if isList}}
54
- /** Array of IDs for the {{pascalCase type}} relationships to be created */
55
- {{name}}Ids{{#if (equals relations.type 'one-to-many')}}?{{/if}}: string[];
56
- {{else}}
57
- {{#unless (equals name (concat (lowerCase ../name) "Id"))}}
58
- {{#unless isRelation}}
59
- /** {{pascalCase name}}'s {{name}} property */
60
- {{name}}: {{getTypeFormat type isRelation isEnum}}{{#if isOptional}}{{#unless hasDefault}} | null{{/unless}}{{/if}};
61
- {{/unless}}
62
- {{/unless}}
63
- {{/if}}
64
- {{/each}}
65
- }
66
-
67
- /**
68
- * Data transfer object for updating an existing {{pascalCase name}}.
69
- */
70
- export interface Update{{pascalCase name}}DTO {
71
- {{#each fields}}
72
- {{#if isList}}
73
- /** Array of IDs for the {{pascalCase type}} relationships to be created */
74
- {{name}}Ids?: string[];
75
- {{else}}
76
- {{#unless (equals name (concat (lowerCase ../name) "Id"))}}
77
- {{#unless isRelation}}
78
- /** {{pascalCase name}}'s {{name}} property */
79
- {{name}}?: {{getTypeFormat type isRelation isEnum}}{{#if isOptional}}{{#unless hasDefault}} | null{{/unless}}{{/if}};
80
- {{/unless}}
81
- {{/unless}}
82
- {{/if}}
83
- {{/each}}
84
- }
85
-
86
- /**
87
- * Query parameters for fetching {{pascalCase name}} entities
88
- */
89
- export interface {{pascalCase name}}QueryParams {
90
- /** Current page number for pagination */
91
- page?: number;
92
- /** Number of items to return per page */
93
- limit?: number;
94
- /** Property to sort by */
95
- sortBy?: string;
96
- /** Sort order */
97
- sortOrder?: 'asc' | 'desc';
98
- /** Search term for filtering */
99
- search?: string;
100
- }
101
- {{/if}}
@@ -1,88 +0,0 @@
1
- import { igniter } from "@/igniter";
2
- {{#unless noModel}}
3
- import type { {{pascalCase name}}, Create{{pascalCase name}}DTO, Update{{pascalCase name}}DTO, {{pascalCase name}}QueryParams } from "../{{kebabCase name}}.interface";
4
- {{/unless}}
5
-
6
- export const {{pascalCase name}}FeatureProcedure = igniter.procedure({
7
- name: "{{pascalCase name}}FeatureProcedure",
8
- {{#if noModel}}
9
- handler: async () => {
10
- {{else}}
11
- handler: async (_, { context }) => {
12
- {{/if}}
13
- return {
14
- {{camelCase name}}: {
15
- {{#if noModel}}
16
- hello: async (): Promise<{ message: string }> => {
17
- return { message: 'Hello from {{pascalCase name}} feature!' };
18
- }
19
- {{else}}
20
- findMany: async (query: {{pascalCase name}}QueryParams): Promise<{{pascalCase name}}[]> => {
21
- return context.providers.database.{{lowerCase name }}.findMany({
22
- where: query.search ? {
23
- OR: [
24
- {{#each fields}}
25
- {{#unless isRelation}}
26
- {{#unless (or (equals name 'id') (equals name 'createdAt') (equals name 'updatedAt'))}}
27
- {{#if (equals type 'String')}}
28
- { {{name}}: { contains: query.search } },
29
- {{/if}}
30
- {{/unless}}
31
- {{/unless}}
32
- {{/each}}
33
- ]
34
- } : undefined,
35
- skip: query.page ? (query.page - 1) * (query.limit || 10) : undefined,
36
- take: query.limit,
37
- orderBy: query.sortBy ? {[query.sortBy]: query.sortOrder || 'asc'} : undefined
38
- });
39
- },
40
- findOne: async (params: { id: string }): Promise<{{pascalCase name}} | null> => {
41
- return context.providers.database.{{camelCase name }}.findUnique({
42
- where: {
43
- id: params.id
44
- }
45
- });
46
- },
47
- create: async (input: Create{{pascalCase name}}DTO): Promise<{{pascalCase name}}> => {
48
- return context.providers.database.{{camelCase name }}.create({
49
- data: {
50
- {{#each fields}}
51
- {{#unless isRelation}}
52
- {{#unless (or (equals name 'id') (equals name 'createdAt') (equals name 'updatedAt'))}}
53
- {{name}}: input.{{name}},
54
- {{/unless}}
55
- {{/unless}}
56
- {{/each}}
57
- }
58
- });
59
- },
60
- update: async (params: { id: string } & Update{{pascalCase name}}DTO): Promise<{{pascalCase name}}> => {
61
- const {{camelCase name}} = await context.providers.database.{{lowerCase name }}.findUnique({
62
- where: { id: params.id }
63
- });
64
- if (!{{camelCase name}}) throw new Error("{{pascalCase name}} not found");
65
- return context.providers.database.{{lowerCase name }}.update({
66
- where: { id: params.id },
67
- data: {
68
- {{#each fields}}
69
- {{#unless isRelation}}
70
- {{#unless (or (equals name 'id') (equals name 'createdAt') (equals name 'updatedAt'))}}
71
- {{name}}: params.{{name}},
72
- {{/unless}}
73
- {{/unless}}
74
- {{/each}}
75
- }
76
- });
77
- },
78
- delete: async (params: { id: string }): Promise<{ id: string }> => {
79
- await context.providers.database.{{lowerCase name }}.delete({
80
- where: { id: params.id }
81
- });
82
- return { id: params.id };
83
- }
84
- {{/if}}
85
- }
86
- };
87
- },
88
- });