@lenne.tech/nest-server 11.21.3 → 11.22.1
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.
- package/.claude/rules/architecture.md +79 -0
- package/.claude/rules/better-auth.md +262 -0
- package/.claude/rules/configurable-features.md +308 -0
- package/.claude/rules/core-modules.md +205 -0
- package/.claude/rules/framework-compatibility.md +79 -0
- package/.claude/rules/migration-guides.md +149 -0
- package/.claude/rules/module-deprecation.md +214 -0
- package/.claude/rules/module-inheritance.md +97 -0
- package/.claude/rules/package-management.md +112 -0
- package/.claude/rules/role-system.md +146 -0
- package/.claude/rules/testing.md +120 -0
- package/.claude/rules/versioning.md +53 -0
- package/CLAUDE.md +174 -0
- package/FRAMEWORK-API.md +231 -0
- package/dist/core/common/interfaces/server-options.interface.d.ts +10 -0
- package/dist/core/modules/error-code/error-code.module.js.map +1 -1
- package/dist/core.module.d.ts +3 -3
- package/dist/core.module.js +17 -4
- package/dist/core.module.js.map +1 -1
- package/dist/server/modules/file/file-info.model.d.ts +1 -5
- package/dist/server/modules/user/user.model.d.ts +1 -5
- package/dist/server/server.module.js +6 -6
- package/dist/server/server.module.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/docs/REQUEST-LIFECYCLE.md +1256 -0
- package/docs/error-codes.md +446 -0
- package/migration-guides/11.10.x-to-11.11.x.md +266 -0
- package/migration-guides/11.11.x-to-11.12.x.md +323 -0
- package/migration-guides/11.12.x-to-11.13.0.md +612 -0
- package/migration-guides/11.13.x-to-11.14.0.md +348 -0
- package/migration-guides/11.14.x-to-11.15.0.md +262 -0
- package/migration-guides/11.15.0-to-11.15.3.md +118 -0
- package/migration-guides/11.15.x-to-11.16.0.md +497 -0
- package/migration-guides/11.16.x-to-11.17.0.md +130 -0
- package/migration-guides/11.17.x-to-11.18.0.md +393 -0
- package/migration-guides/11.18.x-to-11.19.0.md +151 -0
- package/migration-guides/11.19.x-to-11.20.0.md +170 -0
- package/migration-guides/11.20.x-to-11.21.0.md +216 -0
- package/migration-guides/11.21.0-to-11.21.1.md +194 -0
- package/migration-guides/11.21.1-to-11.21.2.md +114 -0
- package/migration-guides/11.21.2-to-11.21.3.md +175 -0
- package/migration-guides/11.21.x-to-11.22.0.md +224 -0
- package/migration-guides/11.22.0-to-11.22.1.md +105 -0
- package/migration-guides/11.3.x-to-11.4.x.md +233 -0
- package/migration-guides/11.6.x-to-11.7.x.md +394 -0
- package/migration-guides/11.7.x-to-11.8.x.md +318 -0
- package/migration-guides/11.8.x-to-11.9.x.md +322 -0
- package/migration-guides/11.9.x-to-11.10.x.md +571 -0
- package/migration-guides/TEMPLATE.md +113 -0
- package/package.json +25 -18
- package/src/core/common/interfaces/server-options.interface.ts +83 -16
- package/src/core/modules/better-auth/CUSTOMIZATION.md +24 -17
- package/src/core/modules/better-auth/INTEGRATION-CHECKLIST.md +5 -5
- package/src/core/modules/error-code/INTEGRATION-CHECKLIST.md +42 -12
- package/src/core/modules/error-code/error-code.module.ts +4 -9
- package/src/core.module.ts +52 -10
- package/src/server/server.module.ts +7 -9
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
---
|
|
2
|
+
paths: src/core/modules/**
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Core Module Development Rules
|
|
6
|
+
|
|
7
|
+
These rules apply when working in `src/core/modules/`.
|
|
8
|
+
|
|
9
|
+
## Naming Conventions
|
|
10
|
+
|
|
11
|
+
- Base classes: `Core` prefix (e.g., `CoreAuthService`, `CoreBetterAuthResolver`)
|
|
12
|
+
- Interfaces: `I` prefix (e.g., `IBetterAuth`, `IServerOptions`)
|
|
13
|
+
- Models: `*Model` suffix for GraphQL types
|
|
14
|
+
- Inputs: `*Input` suffix for input types
|
|
15
|
+
- Args: `*Args` suffix for query arguments
|
|
16
|
+
|
|
17
|
+
## Method Visibility
|
|
18
|
+
|
|
19
|
+
- Use `protected` for methods that should be overridable
|
|
20
|
+
- Use `public` for API methods
|
|
21
|
+
- Avoid `private` for methods that projects might need to customize
|
|
22
|
+
|
|
23
|
+
## Module Registration
|
|
24
|
+
|
|
25
|
+
### Override Pattern (Recommended)
|
|
26
|
+
|
|
27
|
+
Core modules that support customization should accept `controller`/`resolver`/`service` parameters
|
|
28
|
+
in their `forRoot()` method. `CoreModule.forRoot()` passes these through via the `ICoreModuleOverrides` parameter:
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
// In core module
|
|
32
|
+
static forRoot(config?: { controller?: Type; service?: Type }): DynamicModule {
|
|
33
|
+
const ControllerClass = config?.controller || CoreDefaultController;
|
|
34
|
+
const ServiceClass = config?.service || CoreDefaultService;
|
|
35
|
+
return { module: MyModule, controllers: [ControllerClass], providers: [...] };
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
New modules must add their override fields to `ICoreModuleOverrides` in `server-options.interface.ts`
|
|
40
|
+
and pass them through in `CoreModule.forRoot()`.
|
|
41
|
+
|
|
42
|
+
### Auto-Registration
|
|
43
|
+
|
|
44
|
+
Always support both registration modes:
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
// In module class
|
|
48
|
+
static forRoot(options: ModuleOptions): DynamicModule {
|
|
49
|
+
// Check autoRegister option
|
|
50
|
+
if (options.config?.autoRegister === true) {
|
|
51
|
+
// Auto-registration logic
|
|
52
|
+
}
|
|
53
|
+
// Manual registration is default
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Export Requirements
|
|
58
|
+
|
|
59
|
+
All public classes must be exported in `src/index.ts`:
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
// src/index.ts
|
|
63
|
+
export { CoreAuthService } from './core/modules/auth/services/core-auth.service';
|
|
64
|
+
export { CoreBetterAuthResolver } from './core/modules/better-auth/core-better-auth.resolver';
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Documentation
|
|
68
|
+
|
|
69
|
+
Each core module should have:
|
|
70
|
+
|
|
71
|
+
1. README.md in module directory
|
|
72
|
+
2. JSDoc comments on public methods
|
|
73
|
+
3. Interface documentation in `server-options.interface.ts`
|
|
74
|
+
|
|
75
|
+
## Logging
|
|
76
|
+
|
|
77
|
+
Use NestJS Logger with module name:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
private readonly logger = new Logger(ModuleName.name);
|
|
81
|
+
|
|
82
|
+
// Use appropriate log levels
|
|
83
|
+
this.logger.log('Important info'); // Normal operations
|
|
84
|
+
this.logger.warn('Warning message'); // Potential issues
|
|
85
|
+
this.logger.error('Error occurred'); // Errors
|
|
86
|
+
this.logger.debug('Debug info'); // Development only (sparingly)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Optional Constructor Parameters
|
|
90
|
+
|
|
91
|
+
Use the **options object pattern** for optional constructor parameters in Core classes:
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
// Define options interface
|
|
95
|
+
export interface CoreUserServiceOptions {
|
|
96
|
+
betterAuthUserMapper?: BetterAuthUserMapper;
|
|
97
|
+
// Future optional params can be added without breaking changes
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Core class constructor
|
|
101
|
+
protected constructor(
|
|
102
|
+
// Required params first
|
|
103
|
+
protected readonly configService: ConfigService,
|
|
104
|
+
protected readonly emailService: EmailService,
|
|
105
|
+
// Options object last
|
|
106
|
+
protected readonly options?: CoreUserServiceOptions,
|
|
107
|
+
) {
|
|
108
|
+
super();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Usage in methods
|
|
112
|
+
if (this.options?.betterAuthUserMapper) {
|
|
113
|
+
await this.options.betterAuthUserMapper.syncEmail(...);
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Why this pattern:**
|
|
118
|
+
- New optional parameters can be added without breaking existing implementations
|
|
119
|
+
- No need to pass `null` or `undefined` for unused optional parameters
|
|
120
|
+
- Order of optional parameters doesn't matter
|
|
121
|
+
- Clear distinction between required and optional dependencies
|
|
122
|
+
|
|
123
|
+
**Implementation in extending classes:**
|
|
124
|
+
```typescript
|
|
125
|
+
constructor(
|
|
126
|
+
// ... required params ...
|
|
127
|
+
@Optional() private readonly betterAuthUserMapper?: BetterAuthUserMapper,
|
|
128
|
+
) {
|
|
129
|
+
super(configService, emailService, mainDbModel, mainModelConstructor, { betterAuthUserMapper });
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Testing
|
|
134
|
+
|
|
135
|
+
- Create story tests in `tests/stories/`
|
|
136
|
+
- Test through API (REST/GraphQL), not direct service calls
|
|
137
|
+
- Include security tests for authentication/authorization
|
|
138
|
+
|
|
139
|
+
## Integration Documentation (Required for All Core Modules)
|
|
140
|
+
|
|
141
|
+
Every core module that requires project integration MUST have an `INTEGRATION-CHECKLIST.md` file.
|
|
142
|
+
|
|
143
|
+
### Purpose
|
|
144
|
+
|
|
145
|
+
This checklist helps developers (and AI assistants like Claude Code) integrate the module into their projects. It should be optimized for:
|
|
146
|
+
- Quick understanding of required steps
|
|
147
|
+
- Clear references to working code (no duplicates)
|
|
148
|
+
- Critical "WHY" explanations for non-obvious steps
|
|
149
|
+
|
|
150
|
+
### Required Structure
|
|
151
|
+
|
|
152
|
+
```markdown
|
|
153
|
+
# [ModuleName] Integration Checklist
|
|
154
|
+
|
|
155
|
+
## Reference Implementation
|
|
156
|
+
- Local: `node_modules/@lenne.tech/nest-server/src/server/modules/[module]/`
|
|
157
|
+
- GitHub: https://github.com/lenneTech/nest-server/tree/develop/src/server/modules/[module]
|
|
158
|
+
|
|
159
|
+
## Required Files (Create in Order)
|
|
160
|
+
### 1. [FileName]
|
|
161
|
+
**Create:** `src/server/modules/[module]/[file].ts`
|
|
162
|
+
**Copy from:** Reference implementation
|
|
163
|
+
[Optional: WHY explanation for critical/non-obvious steps]
|
|
164
|
+
|
|
165
|
+
## Verification Checklist
|
|
166
|
+
- [ ] Build succeeds
|
|
167
|
+
- [ ] Tests pass
|
|
168
|
+
- [ ] [Module-specific checks]
|
|
169
|
+
|
|
170
|
+
## Common Mistakes
|
|
171
|
+
| Mistake | Symptom | Fix |
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Key Principles
|
|
175
|
+
|
|
176
|
+
1. **No Code Duplication**: Never include full code examples that duplicate `src/server/`
|
|
177
|
+
- Reference files exist in `src/server/modules/` and are included in the npm package
|
|
178
|
+
- Claude Code can read these files directly from `node_modules/`
|
|
179
|
+
- Only include small code snippets for DIFFs (changes to existing files)
|
|
180
|
+
|
|
181
|
+
2. **Single Source of Truth**: The reference implementation in `src/server/` is always current
|
|
182
|
+
- Documentation never becomes outdated
|
|
183
|
+
- Copy-paste from reference is always correct
|
|
184
|
+
|
|
185
|
+
3. **WHY Explanations**: Include for critical/non-obvious steps
|
|
186
|
+
- Example: "WHY must decorators be re-declared?" → GraphQL schema registration
|
|
187
|
+
- Example: "WHY inject this mapper?" → Bidirectional sync between systems
|
|
188
|
+
|
|
189
|
+
4. **Verification Checklist**: Help verify successful integration
|
|
190
|
+
- Build/test commands
|
|
191
|
+
- Module-specific functional checks
|
|
192
|
+
|
|
193
|
+
5. **Common Mistakes Table**: Document known pitfalls with symptoms and fixes
|
|
194
|
+
|
|
195
|
+
### Example
|
|
196
|
+
|
|
197
|
+
See `src/core/modules/better-auth/INTEGRATION-CHECKLIST.md` as the reference template.
|
|
198
|
+
|
|
199
|
+
### When to Create
|
|
200
|
+
|
|
201
|
+
Create an `INTEGRATION-CHECKLIST.md` when the module:
|
|
202
|
+
- Requires files to be created in the consuming project
|
|
203
|
+
- Has non-obvious integration steps
|
|
204
|
+
- Extends Core classes that need decorator re-declaration
|
|
205
|
+
- Requires changes to existing project files (UserService, ServerModule, etc.)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Framework Compatibility for Claude Code
|
|
2
|
+
|
|
3
|
+
This document defines the maintenance obligations that ensure Claude Code can effectively work with `@lenne.tech/nest-server` in consuming projects.
|
|
4
|
+
|
|
5
|
+
## Architecture Overview
|
|
6
|
+
|
|
7
|
+
The framework ships documentation alongside source code so that Claude Code can read it from `node_modules/`. Three layers work together:
|
|
8
|
+
|
|
9
|
+
1. **npm package** ships `CLAUDE.md`, `FRAMEWORK-API.md`, `.claude/rules/`, `docs/`, `migration-guides/`
|
|
10
|
+
2. **Consuming project** `CLAUDE.md` points Claude to read `node_modules/@lenne.tech/nest-server/`
|
|
11
|
+
3. **Claude Code plugin** (`lt-dev`) detects nest-server and injects concrete source paths via hooks
|
|
12
|
+
|
|
13
|
+
## Maintenance Obligations
|
|
14
|
+
|
|
15
|
+
### When Adding/Changing Interfaces in `server-options.interface.ts`
|
|
16
|
+
|
|
17
|
+
1. `FRAMEWORK-API.md` is auto-generated during `pnpm run build` via `scripts/generate-framework-api.ts`
|
|
18
|
+
2. Verify the generated output includes the new interface and all fields
|
|
19
|
+
3. Add JSDoc with `@default` tags for all config fields — these appear in the API reference
|
|
20
|
+
|
|
21
|
+
### When Adding New Core Modules (`src/core/modules/`)
|
|
22
|
+
|
|
23
|
+
1. Create `README.md` and `INTEGRATION-CHECKLIST.md` in the module directory
|
|
24
|
+
2. The generator script automatically picks up new modules for the "Core Modules" table
|
|
25
|
+
3. If the module has `forRoot()` config, add the interface to `server-options.interface.ts`
|
|
26
|
+
4. Run `pnpm run build` to regenerate `FRAMEWORK-API.md`
|
|
27
|
+
|
|
28
|
+
### When Changing CrudService Methods
|
|
29
|
+
|
|
30
|
+
1. Add JSDoc to new methods — the generator extracts the first line as description
|
|
31
|
+
2. Run `pnpm run build` to regenerate `FRAMEWORK-API.md`
|
|
32
|
+
3. If the method signature pattern changes (standard/Force/Raw), update the "Variants" note
|
|
33
|
+
|
|
34
|
+
### When Changing `CoreModule.forRoot()` Signatures
|
|
35
|
+
|
|
36
|
+
1. Ensure JSDoc is complete on the new overload
|
|
37
|
+
2. Run `pnpm run build` to regenerate `FRAMEWORK-API.md`
|
|
38
|
+
3. If adding a new parameter, update the consuming project template (`nest-server-starter/CLAUDE.md`)
|
|
39
|
+
|
|
40
|
+
### When Releasing New Versions
|
|
41
|
+
|
|
42
|
+
1. Run `pnpm run build` — this regenerates `FRAMEWORK-API.md` with the new version number
|
|
43
|
+
2. The file is included in the npm package via `package.json` `files` array
|
|
44
|
+
3. Migration guides are separate (see `.claude/rules/migration-guides.md`)
|
|
45
|
+
|
|
46
|
+
## Files Shipped with npm Package
|
|
47
|
+
|
|
48
|
+
| File | Purpose | Auto-Updated |
|
|
49
|
+
|------|---------|:------------:|
|
|
50
|
+
| `CLAUDE.md` | Framework rules, architecture, debugging guide | Manual |
|
|
51
|
+
| `FRAMEWORK-API.md` | Compact API reference (interfaces, methods) | Yes (`pnpm run build`) |
|
|
52
|
+
| `.claude/rules/*.md` | 12 rule files covering all aspects | Manual |
|
|
53
|
+
| `docs/REQUEST-LIFECYCLE.md` | Complete request lifecycle | Manual |
|
|
54
|
+
| `migration-guides/*.md` | Version migration guides | Per release |
|
|
55
|
+
|
|
56
|
+
## Generator Script
|
|
57
|
+
|
|
58
|
+
`scripts/generate-framework-api.ts` extracts via ts-morph:
|
|
59
|
+
- `CoreModule.forRoot()` overload signatures
|
|
60
|
+
- All config interfaces (`IServerOptions`, `IBetterAuth`, `IMultiTenancy`, etc.)
|
|
61
|
+
- `ServiceOptions` interface
|
|
62
|
+
- `CrudService` public method signatures
|
|
63
|
+
- Core module listing with documentation status
|
|
64
|
+
|
|
65
|
+
Run manually: `npx tsx scripts/generate-framework-api.ts`
|
|
66
|
+
|
|
67
|
+
## Cross-Repository Dependencies
|
|
68
|
+
|
|
69
|
+
This framework compatibility strategy spans multiple repositories:
|
|
70
|
+
|
|
71
|
+
| Repository | Role |
|
|
72
|
+
|-----------|------|
|
|
73
|
+
| `nest-server` | Ships documentation with npm package (this repo) |
|
|
74
|
+
| `nest-server-starter` | `CLAUDE.md` points Claude to `node_modules/` source |
|
|
75
|
+
| `nuxt-extensions` | Same pattern: `CLAUDE.md` shipped with npm package |
|
|
76
|
+
| `nuxt-base-starter` | `CLAUDE.md` points Claude to nuxt-extensions source |
|
|
77
|
+
| `claude-code/plugins/lt-dev` | Hooks detect frameworks, Skills reference source paths |
|
|
78
|
+
|
|
79
|
+
The full strategy document is maintained in the claude-code plugin repository.
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Migration Guide Creation Process
|
|
2
|
+
|
|
3
|
+
This document describes the process for creating migration guides when releasing new versions of @lenne.tech/nest-server.
|
|
4
|
+
|
|
5
|
+
## When to Create a Migration Guide
|
|
6
|
+
|
|
7
|
+
**Versioning Context:** The MAJOR version mirrors NestJS (e.g., `11.x.x` = NestJS 11). This means MINOR can contain breaking changes and PATCH can contain new features.
|
|
8
|
+
|
|
9
|
+
**Create a migration guide when consuming projects need to:**
|
|
10
|
+
- Change code, configuration, or usage to use new features
|
|
11
|
+
- Modify anything to keep the application working after update
|
|
12
|
+
- Adapt to breaking changes or new requirements
|
|
13
|
+
|
|
14
|
+
**Examples:**
|
|
15
|
+
- `11.6.x → 11.7.x` - Required (new BetterAuth module, new CoreModule signature)
|
|
16
|
+
- `11.7.0 → 11.7.1` - Required if new features need configuration changes
|
|
17
|
+
- `11.7.1 → 11.7.2` - Not required if purely internal bugfixes with no user action needed
|
|
18
|
+
|
|
19
|
+
**Rule of thumb:** If a developer needs to do anything beyond `pnpm update` to benefit from or accommodate the changes, create a migration guide.
|
|
20
|
+
|
|
21
|
+
## Migration Guide Location
|
|
22
|
+
|
|
23
|
+
All migration guides are stored in `migration-guides/`:
|
|
24
|
+
- `migration-guides/11.6.x-to-11.7.x.md`
|
|
25
|
+
- `migration-guides/TEMPLATE.md` - Template for new guides
|
|
26
|
+
|
|
27
|
+
## Creation Process
|
|
28
|
+
|
|
29
|
+
### Step 1: Gather Project Information
|
|
30
|
+
|
|
31
|
+
**Always analyze these sources:**
|
|
32
|
+
1. Local `src/server/` - Internal test implementation
|
|
33
|
+
2. [nest-server-starter](https://github.com/lenneTech/nest-server-starter) - Reference project
|
|
34
|
+
|
|
35
|
+
**Ask developer for additional projects:**
|
|
36
|
+
```
|
|
37
|
+
Which projects should I analyze for migration compatibility?
|
|
38
|
+
Please provide paths to projects using @lenne.tech/nest-server.
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Step 2: Analyze Projects
|
|
42
|
+
|
|
43
|
+
Focus on files affected by the version changes:
|
|
44
|
+
- Module files (`*.module.ts`)
|
|
45
|
+
- Service files (`*.service.ts`)
|
|
46
|
+
- Resolver files (`*.resolver.ts`)
|
|
47
|
+
- Controller files (`*.controller.ts`)
|
|
48
|
+
- Configuration files (`config.env.ts`)
|
|
49
|
+
|
|
50
|
+
Look for:
|
|
51
|
+
- Module inheritance patterns (extending Core* classes)
|
|
52
|
+
- Method overrides
|
|
53
|
+
- Custom implementations
|
|
54
|
+
- Version-specific features in use
|
|
55
|
+
|
|
56
|
+
### Step 3: Identify Changes
|
|
57
|
+
|
|
58
|
+
Categorize all changes:
|
|
59
|
+
|
|
60
|
+
| Category | Description |
|
|
61
|
+
|----------|-------------|
|
|
62
|
+
| **Breaking Changes** | Changes that require code modifications |
|
|
63
|
+
| **New Features** | New functionality (opt-in) |
|
|
64
|
+
| **Bugfixes** | Corrections to existing behavior |
|
|
65
|
+
| **Deprecations** | Features marked for future removal |
|
|
66
|
+
|
|
67
|
+
### Step 4: Write the Guide
|
|
68
|
+
|
|
69
|
+
Use `migration-guides/TEMPLATE.md` as starting point.
|
|
70
|
+
|
|
71
|
+
**Required Sections:**
|
|
72
|
+
1. **Overview** - Summary table with categories and effort
|
|
73
|
+
2. **Quick Migration** - For non-breaking updates
|
|
74
|
+
3. **What's New** - New features with examples
|
|
75
|
+
4. **Breaking Changes** - Before/after code samples
|
|
76
|
+
5. **Compatibility Notes** - Common patterns and their status
|
|
77
|
+
6. **Troubleshooting** - Known issues and solutions
|
|
78
|
+
7. **Module Documentation** - Links to affected module docs (README.md, INTEGRATION-CHECKLIST.md)
|
|
79
|
+
|
|
80
|
+
**Rules:**
|
|
81
|
+
- **Write ALL content in English** - This includes section titles, descriptions, explanations, and code comments. Technical terms and code identifiers remain unchanged.
|
|
82
|
+
- Do NOT name specific customer projects (except nest-server-starter as reference)
|
|
83
|
+
- Keep information general and pattern-based
|
|
84
|
+
- Include code examples for all changes
|
|
85
|
+
- Mention `npm run update` if package.json dependencies changed
|
|
86
|
+
|
|
87
|
+
### Step 5: Update References
|
|
88
|
+
|
|
89
|
+
After creating the guide, verify references in:
|
|
90
|
+
- `CLAUDE.md` - Should link to migration-guides/
|
|
91
|
+
- `CHANGELOG.md` - If it exists
|
|
92
|
+
|
|
93
|
+
### Step 6: Link Module Documentation
|
|
94
|
+
|
|
95
|
+
For each affected module, check for and link to:
|
|
96
|
+
- `src/core/modules/<module>/README.md` - Module overview and usage
|
|
97
|
+
- `src/core/modules/<module>/INTEGRATION-CHECKLIST.md` - Integration steps
|
|
98
|
+
- `src/server/modules/<module>/` - Reference implementation
|
|
99
|
+
|
|
100
|
+
Find existing documentation:
|
|
101
|
+
```bash
|
|
102
|
+
# Find all module READMEs
|
|
103
|
+
ls src/core/modules/**/README.md
|
|
104
|
+
|
|
105
|
+
# Find all integration checklists
|
|
106
|
+
ls src/core/modules/**/INTEGRATION-CHECKLIST.md
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Guide Quality Checklist
|
|
110
|
+
|
|
111
|
+
- [ ] **Written entirely in English**
|
|
112
|
+
- [ ] Overview table is complete
|
|
113
|
+
- [ ] Quick migration path provided
|
|
114
|
+
- [ ] All breaking changes documented with before/after
|
|
115
|
+
- [ ] New features have usage examples
|
|
116
|
+
- [ ] Compatibility notes cover common patterns
|
|
117
|
+
- [ ] Troubleshooting section addresses likely issues
|
|
118
|
+
- [ ] Module documentation section links to affected modules
|
|
119
|
+
- [ ] No customer project names mentioned
|
|
120
|
+
- [ ] Code examples are tested
|
|
121
|
+
|
|
122
|
+
## Example Analysis Output
|
|
123
|
+
|
|
124
|
+
```markdown
|
|
125
|
+
## Analysis Summary
|
|
126
|
+
|
|
127
|
+
### Pattern: AuthResolver Extension
|
|
128
|
+
- Found in: 4/4 analyzed projects
|
|
129
|
+
- Status: Compatible
|
|
130
|
+
- Notes: Projects override signIn() calling authService directly
|
|
131
|
+
|
|
132
|
+
### Pattern: Custom Role Enums
|
|
133
|
+
- Found in: 1/4 analyzed projects
|
|
134
|
+
- Status: Compatible
|
|
135
|
+
- Notes: CompanyRoles used instead of RoleEnum
|
|
136
|
+
|
|
137
|
+
### Potential Issues: None identified
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Automation
|
|
141
|
+
|
|
142
|
+
When asked to create a migration guide, Claude Code should:
|
|
143
|
+
|
|
144
|
+
1. Prompt for project paths (unless already provided)
|
|
145
|
+
2. Read auth, user, and configuration files from each project
|
|
146
|
+
3. Compare patterns against new version requirements
|
|
147
|
+
4. Generate compatibility report
|
|
148
|
+
5. Create migration guide using template
|
|
149
|
+
6. Verify all tests pass with new version
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# Module Deprecation & Migration Roadmap
|
|
2
|
+
|
|
3
|
+
This document describes the deprecation strategy for Legacy Auth and the migration path to BetterAuth (IAM).
|
|
4
|
+
|
|
5
|
+
## Authentication System Roadmap
|
|
6
|
+
|
|
7
|
+
### v11.x (Current - Backward Compatible)
|
|
8
|
+
|
|
9
|
+
- **Legacy Auth** (CoreAuthService) is available for backwards compatibility
|
|
10
|
+
- **BetterAuth** (IAM) can run standalone or alongside Legacy Auth
|
|
11
|
+
- **GraphQL Subscriptions** work with both systems (IAM uses BetterAuth sessions)
|
|
12
|
+
- Both systems share the same user database with bidirectional sync
|
|
13
|
+
- Password hashes use different algorithms (Legacy: `bcrypt(sha256(pw))`, IAM: `scrypt(sha256(pw))`)
|
|
14
|
+
|
|
15
|
+
**Key Configuration:**
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
// config.env.ts
|
|
19
|
+
{
|
|
20
|
+
// Legacy Auth configuration (optional, for backwards compatibility)
|
|
21
|
+
jwt: {
|
|
22
|
+
secret: 'YOUR_JWT_SECRET',
|
|
23
|
+
refresh: { secret: 'YOUR_REFRESH_SECRET' }
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
// BetterAuth configuration (optional, runs in parallel)
|
|
27
|
+
betterAuth: {
|
|
28
|
+
enabled: true,
|
|
29
|
+
secret: 'YOUR_BETTERAUTH_SECRET',
|
|
30
|
+
// ...
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
// NEW in v11.7.x: Disable legacy endpoints after migration
|
|
34
|
+
auth: {
|
|
35
|
+
legacyEndpoints: {
|
|
36
|
+
enabled: true // Set to false after all users migrated
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**CoreModule.forRoot Signatures:**
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
// IAM-Only (recommended for new projects)
|
|
46
|
+
CoreModule.forRoot(envConfig)
|
|
47
|
+
|
|
48
|
+
// Legacy + IAM (for existing projects during migration)
|
|
49
|
+
CoreModule.forRoot(CoreAuthService, AuthModule.forRoot(envConfig.jwt), envConfig)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Future Version (Planned - Breaking Change)
|
|
53
|
+
|
|
54
|
+
- **BetterAuth** (IAM) becomes the default authentication system
|
|
55
|
+
- **Legacy Auth** becomes optional (must be explicitly enabled)
|
|
56
|
+
- Simplified CoreModule.forRoot signature becomes the only option
|
|
57
|
+
- Legacy Auth removed from codebase
|
|
58
|
+
|
|
59
|
+
**New Configuration:**
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
// config.env.ts
|
|
63
|
+
{
|
|
64
|
+
// BetterAuth is now the default
|
|
65
|
+
betterAuth: {
|
|
66
|
+
secret: 'YOUR_BETTERAUTH_SECRET',
|
|
67
|
+
// ...
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
// Legacy Auth is optional (enable only if needed)
|
|
71
|
+
auth: {
|
|
72
|
+
legacy: {
|
|
73
|
+
enabled: false // Explicitly enable if still needed
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Simplified CoreModule.forRoot Signature:**
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
// Future version: Single parameter
|
|
83
|
+
CoreModule.forRoot(envConfig)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Migration Path for Projects
|
|
87
|
+
|
|
88
|
+
### Phase 1: Enable BetterAuth (v11.x)
|
|
89
|
+
|
|
90
|
+
1. Ensure `betterAuth` is configured in `config.env.ts`
|
|
91
|
+
2. Integrate BetterAuthModule in your project (see INTEGRATION-CHECKLIST.md)
|
|
92
|
+
3. Both auth systems run in parallel
|
|
93
|
+
|
|
94
|
+
### Phase 2: Monitor Migration
|
|
95
|
+
|
|
96
|
+
Use the `betterAuthMigrationStatus` GraphQL query (admin only):
|
|
97
|
+
|
|
98
|
+
```graphql
|
|
99
|
+
query {
|
|
100
|
+
betterAuthMigrationStatus {
|
|
101
|
+
totalUsers
|
|
102
|
+
fullyMigratedUsers
|
|
103
|
+
pendingMigrationUsers
|
|
104
|
+
migrationPercentage
|
|
105
|
+
canDisableLegacyAuth
|
|
106
|
+
pendingUserEmails
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Users migrate automatically when they:
|
|
112
|
+
- Sign in via BetterAuth (IAM) endpoints
|
|
113
|
+
- Use social login (if configured)
|
|
114
|
+
- Use passkey authentication (if configured)
|
|
115
|
+
|
|
116
|
+
### Phase 3: Disable Legacy Endpoints
|
|
117
|
+
|
|
118
|
+
Once `canDisableLegacyAuth` is `true`:
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
// config.env.ts
|
|
122
|
+
auth: {
|
|
123
|
+
legacyEndpoints: {
|
|
124
|
+
enabled: false // Disable all legacy endpoints
|
|
125
|
+
// Or disable selectively:
|
|
126
|
+
// graphql: false // Disable only GraphQL endpoints
|
|
127
|
+
// rest: false // Disable only REST endpoints
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Legacy endpoint calls will return HTTP 410 Gone.
|
|
133
|
+
|
|
134
|
+
### Phase 4: Upgrade to Future Version
|
|
135
|
+
|
|
136
|
+
When upgrading to the future version with BetterAuth as default:
|
|
137
|
+
|
|
138
|
+
1. Update `package.json` dependency
|
|
139
|
+
2. Simplify `CoreModule.forRoot` call:
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
// Before (v11.x)
|
|
143
|
+
CoreModule.forRoot(CoreAuthService, AuthModule.forRoot(envConfig.jwt), envConfig)
|
|
144
|
+
|
|
145
|
+
// After (future version)
|
|
146
|
+
CoreModule.forRoot(envConfig)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
3. Remove Legacy Auth configuration if no longer needed
|
|
150
|
+
|
|
151
|
+
## Password Hash Incompatibility
|
|
152
|
+
|
|
153
|
+
**Why parallel operation is necessary:**
|
|
154
|
+
|
|
155
|
+
| System | Hash Algorithm |
|
|
156
|
+
|--------|----------------|
|
|
157
|
+
| Legacy Auth | `bcrypt(sha256(password))` |
|
|
158
|
+
| BetterAuth | `scrypt(sha256(password))` |
|
|
159
|
+
|
|
160
|
+
These algorithms are **one-way** - there is no migration script possible.
|
|
161
|
+
Users must sign in at least once via BetterAuth to create a new hash.
|
|
162
|
+
|
|
163
|
+
## Configuration Reference
|
|
164
|
+
|
|
165
|
+
### auth.legacyEndpoints (v11.7.x+)
|
|
166
|
+
|
|
167
|
+
| Property | Type | Default | Description |
|
|
168
|
+
|----------|------|---------|-------------|
|
|
169
|
+
| `enabled` | boolean | `true` | Enable/disable all legacy endpoints |
|
|
170
|
+
| `graphql` | boolean | inherits `enabled` | Enable/disable GraphQL endpoints only |
|
|
171
|
+
| `rest` | boolean | inherits `enabled` | Enable/disable REST endpoints only |
|
|
172
|
+
|
|
173
|
+
### Legacy Endpoints Affected
|
|
174
|
+
|
|
175
|
+
**GraphQL Mutations:**
|
|
176
|
+
- `signIn` - Sign in via email/password
|
|
177
|
+
- `signUp` - Register new account
|
|
178
|
+
- `logout` - Sign out
|
|
179
|
+
- `refreshToken` - Refresh JWT tokens
|
|
180
|
+
|
|
181
|
+
**REST Endpoints:**
|
|
182
|
+
- `POST /auth/signin` - Sign in via email/password
|
|
183
|
+
- `POST /auth/signup` - Register new account
|
|
184
|
+
- `GET /auth/logout` - Sign out
|
|
185
|
+
- `GET /auth/refresh-token` - Refresh JWT tokens
|
|
186
|
+
|
|
187
|
+
## IAuthProvider Interface (v11.7.x+)
|
|
188
|
+
|
|
189
|
+
The `IAuthProvider` interface abstracts authentication operations:
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
interface IAuthProvider {
|
|
193
|
+
decodeJwt(token: string): JwtPayload;
|
|
194
|
+
validateUser(payload: JwtPayload): Promise<any>;
|
|
195
|
+
signToken(user: any, expiresIn?: string): string;
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
In a future version, this interface will be used by CoreModule.forRoot to support
|
|
200
|
+
both Legacy Auth and BetterAuth transparently.
|
|
201
|
+
|
|
202
|
+
## Timeline
|
|
203
|
+
|
|
204
|
+
| Version | Status | Changes |
|
|
205
|
+
|---------|--------|---------|
|
|
206
|
+
| v11.6.x | Released | BetterAuth introduced |
|
|
207
|
+
| v11.7.x | Current | Legacy endpoint controls, IAuthProvider, migration status |
|
|
208
|
+
| Future | Planned | BetterAuth default, simplified API, Legacy optional |
|
|
209
|
+
|
|
210
|
+
## Related Documentation
|
|
211
|
+
|
|
212
|
+
- [BetterAuth Integration Checklist](../../src/core/modules/better-auth/INTEGRATION-CHECKLIST.md)
|
|
213
|
+
- [Module Inheritance Pattern](./module-inheritance.md)
|
|
214
|
+
- [Role System](./role-system.md)
|