@breadstone/archipel-mcp 0.0.21 → 0.0.22

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 (136) hide show
  1. package/data/guides/cryptography-and-otp.md +2 -2
  2. package/data/guides/database-setup.md +4 -3
  3. package/data/guides/email-templates.md +3 -3
  4. package/data/guides/getting-started.md +6 -6
  5. package/data/guides/resource-management.md +9 -9
  6. package/data/packages/platform-blob-storage/api/Variable.AWS_S3_PROVIDER_OPTIONS.md +1 -1
  7. package/data/packages/platform-blob-storage/api/Variable.AZURE_BLOB_PROVIDER_OPTIONS.md +1 -1
  8. package/data/packages/platform-blob-storage/api/Variable.BLOB_PROVIDER.md +1 -1
  9. package/data/packages/platform-blob-storage/api/Variable.VERCEL_BLOB_PROVIDER_OPTIONS.md +1 -1
  10. package/data/packages/platform-core/api/Class.ErrorTemplateService.md +1 -1
  11. package/data/packages/platform-core/api/Class.HostService.md +1 -1
  12. package/data/packages/platform-core/api/Variable.ID_GENERATOR_TOKEN.md +1 -1
  13. package/data/packages/platform-core/api/index.md +0 -27
  14. package/data/packages/platform-core/index.md +7 -4
  15. package/data/packages/platform-cryptography/api/Class.BcryptService.md +4 -4
  16. package/data/packages/platform-cryptography/api/Class.OtpService.md +6 -6
  17. package/data/packages/platform-cryptography/api/Variable.BCRYPT_OPTIONS.md +2 -2
  18. package/data/packages/platform-cryptography/api/Variable.MAX_BCRYPT_PASSWORD_BYTES.md +1 -1
  19. package/data/packages/platform-cryptography/api/Variable.MIN_BCRYPT_ROUNDS.md +1 -1
  20. package/data/packages/platform-cryptography/api/Variable.OTP_OPTIONS.md +2 -2
  21. package/data/packages/platform-cryptography/api/Variable.OTP_SERVICE_TOKEN.md +2 -2
  22. package/data/packages/platform-cryptography/api/Variable.TOTP_EPOCH_TOLERANCE.md +1 -1
  23. package/data/packages/platform-cryptography/api/index.md +3 -3
  24. package/data/packages/platform-documents/api/Class.BaseDocumentRenderer.md +32 -1
  25. package/data/packages/platform-documents/api/Class.DocumentEngine.md +4 -4
  26. package/data/packages/platform-documents/api/Class.DocumentModule.md +2 -2
  27. package/data/packages/platform-documents/api/Class.DocxDocumentRenderer2.md +333 -0
  28. package/data/packages/platform-documents/api/Class.PdfDocumentRenderer.md +355 -0
  29. package/data/packages/platform-documents/api/Interface.IDocumentModuleOptions.md +31 -5
  30. package/data/packages/platform-documents/api/Variable.DOCUMENT_MODULE_OPTIONS.md +1 -1
  31. package/data/packages/platform-documents/api/Variable.DOCUMENT_PARSER_TOKEN.md +1 -1
  32. package/data/packages/platform-documents/api/Variable.DOCUMENT_RENDERER_TOKEN.md +1 -1
  33. package/data/packages/platform-documents/api/Variable.IMAGE_PROCESSOR_TOKEN.md +1 -1
  34. package/data/packages/platform-documents/api/index.md +2 -0
  35. package/data/packages/platform-esigning/api/Class.EsigningClientPort.md +1 -1
  36. package/data/packages/platform-health/index.md +128 -0
  37. package/data/packages/platform-mailing/api/Class.DeliveryStrategyBase.md +0 -1
  38. package/data/packages/platform-mailing/api/Class.MailModule.md +1 -1
  39. package/data/packages/platform-mailing/api/Class.TemplateFetchStrategyBase.md +0 -5
  40. package/data/packages/platform-mailing/api/Variable.SMTP_CONFIG_ENTRIES.md +14 -0
  41. package/data/packages/platform-mailing/api/Variable.SMTP_HOST.md +14 -0
  42. package/data/packages/platform-mailing/api/Variable.SMTP_PASSWORD.md +14 -0
  43. package/data/packages/platform-mailing/api/Variable.SMTP_PORT.md +14 -0
  44. package/data/packages/platform-mailing/api/Variable.SMTP_SECURE.md +14 -0
  45. package/data/packages/platform-mailing/api/Variable.SMTP_USER.md +14 -0
  46. package/data/packages/platform-mailing/api/index.md +6 -3
  47. package/data/packages/platform-mapping/index.md +121 -0
  48. package/data/packages/platform-mcp/api/Variable.MCP_MODULE_OPTIONS.md +1 -1
  49. package/data/packages/platform-openapi/api/Class.SwaggerMultiDocumentService.md +4 -4
  50. package/data/packages/platform-resources/index.md +135 -0
  51. package/data/packages/platform-telemetry/api/Variable.TELEMETRY_ENABLED.md +1 -1
  52. package/data/packages/platform-telemetry/api/Variable.TELEMETRY_FACADE.md +1 -1
  53. package/data/packages/platform-telemetry/api/Variable.TELEMETRY_OPTIONS.md +1 -1
  54. package/{src/knowledge/configPattern.js → data/patterns/config-pattern.md} +44 -47
  55. package/{src/knowledge/dtoPattern.js → data/patterns/dto-pattern.md} +58 -61
  56. package/{src/knowledge/errorHandlingPattern.js → data/patterns/error-handling-pattern.md} +35 -38
  57. package/{src/knowledge/guardPattern.js → data/patterns/guard-pattern.md} +35 -38
  58. package/{src/knowledge/mappingPattern.js → data/patterns/mapping-pattern.md} +43 -144
  59. package/data/patterns/module-pattern.md +182 -0
  60. package/data/patterns/query-pattern.md +137 -0
  61. package/data/patterns/repository-pattern.md +208 -0
  62. package/{src/knowledge/testingPattern.js → data/patterns/testing-pattern.md} +37 -40
  63. package/package.json +1 -1
  64. package/src/PatternsLoader.d.ts +12 -0
  65. package/src/PatternsLoader.js +65 -0
  66. package/src/generators/mappingPatternGenerator.d.ts +5 -0
  67. package/src/generators/mappingPatternGenerator.js +107 -0
  68. package/src/generators/modulePatternGenerator.d.ts +5 -0
  69. package/src/generators/modulePatternGenerator.js +107 -0
  70. package/src/generators/queryPatternGenerator.d.ts +4 -0
  71. package/src/generators/queryPatternGenerator.js +83 -0
  72. package/src/generators/repositoryPatternGenerator.d.ts +5 -0
  73. package/src/generators/repositoryPatternGenerator.js +165 -0
  74. package/src/main.js +15 -9
  75. package/src/models/IPatternDoc.d.ts +15 -0
  76. package/src/models/IPatternDoc.js +3 -0
  77. package/src/tools/registerGetConfigPatternTool.d.ts +2 -1
  78. package/src/tools/registerGetConfigPatternTool.js +4 -3
  79. package/src/tools/registerGetDtoPatternTool.d.ts +2 -1
  80. package/src/tools/registerGetDtoPatternTool.js +4 -3
  81. package/src/tools/registerGetErrorHandlingPatternTool.d.ts +2 -1
  82. package/src/tools/registerGetErrorHandlingPatternTool.js +4 -3
  83. package/src/tools/registerGetGuardPatternTool.d.ts +2 -1
  84. package/src/tools/registerGetGuardPatternTool.js +4 -3
  85. package/src/tools/registerGetMappingPatternTool.d.ts +2 -1
  86. package/src/tools/registerGetMappingPatternTool.js +5 -4
  87. package/src/tools/registerGetModulePatternTool.d.ts +2 -1
  88. package/src/tools/registerGetModulePatternTool.js +5 -4
  89. package/src/tools/registerGetQueryPatternTool.d.ts +2 -1
  90. package/src/tools/registerGetQueryPatternTool.js +5 -4
  91. package/src/tools/registerGetRepositoryPatternTool.d.ts +2 -1
  92. package/src/tools/registerGetRepositoryPatternTool.js +5 -4
  93. package/src/tools/registerGetTestingPatternTool.d.ts +2 -1
  94. package/src/tools/registerGetTestingPatternTool.js +4 -3
  95. package/data/packages/platform-core/api/Class.BlobResourceStrategy.md +0 -195
  96. package/data/packages/platform-core/api/Class.EmbeddedResourceStrategy.md +0 -215
  97. package/data/packages/platform-core/api/Class.FileResourceStrategy.md +0 -192
  98. package/data/packages/platform-core/api/Class.HealthModule.md +0 -42
  99. package/data/packages/platform-core/api/Class.HealthOrchestrator.md +0 -64
  100. package/data/packages/platform-core/api/Class.MappingBuilder.md +0 -110
  101. package/data/packages/platform-core/api/Class.MappingModule.md +0 -46
  102. package/data/packages/platform-core/api/Class.MappingNotRegisteredError.md +0 -56
  103. package/data/packages/platform-core/api/Class.MappingProfileBase.md +0 -52
  104. package/data/packages/platform-core/api/Class.MappingService.md +0 -284
  105. package/data/packages/platform-core/api/Class.ResourceManager.md +0 -565
  106. package/data/packages/platform-core/api/Class.ResourceModule.md +0 -46
  107. package/data/packages/platform-core/api/Class.TypeMappingNotRegisteredError.md +0 -57
  108. package/data/packages/platform-core/api/Function.createMappingKey.md +0 -39
  109. package/data/packages/platform-core/api/Interface.IBlobResourceStrategyConfig.md +0 -28
  110. package/data/packages/platform-core/api/Interface.IBlobServiceAdapter.md +0 -40
  111. package/data/packages/platform-core/api/Interface.IFileResourceStrategyConfig.md +0 -72
  112. package/data/packages/platform-core/api/Interface.IHealthCheckResult.md +0 -46
  113. package/data/packages/platform-core/api/Interface.IHealthIndicator.md +0 -41
  114. package/data/packages/platform-core/api/Interface.IMappingBuilder.md +0 -76
  115. package/data/packages/platform-core/api/Interface.IMappingKey.md +0 -58
  116. package/data/packages/platform-core/api/Interface.IMappingProfile.md +0 -32
  117. package/data/packages/platform-core/api/Interface.IResourceManagerConfig.md +0 -89
  118. package/data/packages/platform-core/api/Interface.IResourceMetadata.md +0 -94
  119. package/data/packages/platform-core/api/Interface.IResourceResult.md +0 -34
  120. package/data/packages/platform-core/api/Interface.IResourceStrategy.md +0 -134
  121. package/data/packages/platform-core/api/Variable.HEALTH_INDICATORS_TOKEN.md +0 -14
  122. package/data/packages/platform-mailing/api/Class.BlobTemplateFetchStrategy.md +0 -60
  123. package/data/packages/platform-mailing/api/Class.FileTemplateFetchStrategy.md +0 -58
  124. package/data/packages/platform-mailing/api/Class.LogDeliveryStrategy.md +0 -71
  125. package/src/knowledge/configPattern.d.ts +0 -5
  126. package/src/knowledge/dtoPattern.d.ts +0 -5
  127. package/src/knowledge/errorHandlingPattern.d.ts +0 -5
  128. package/src/knowledge/guardPattern.d.ts +0 -5
  129. package/src/knowledge/mappingPattern.d.ts +0 -6
  130. package/src/knowledge/modulePattern.d.ts +0 -6
  131. package/src/knowledge/modulePattern.js +0 -283
  132. package/src/knowledge/queryPattern.d.ts +0 -6
  133. package/src/knowledge/queryPattern.js +0 -215
  134. package/src/knowledge/repositoryPattern.d.ts +0 -6
  135. package/src/knowledge/repositoryPattern.js +0 -367
  136. package/src/knowledge/testingPattern.d.ts +0 -5
@@ -1,24 +1,23 @@
1
- "use strict";
2
- /**
3
- * Static knowledge content for the Archipel DTO & validation pattern.
4
- * Returned by the get-dto-pattern tool.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.DTO_PATTERN_KNOWLEDGE = void 0;
8
- exports.DTO_PATTERN_KNOWLEDGE = `# Archipel DTO & Validation Pattern
1
+ ---
2
+ title: DTO & Validation Pattern
3
+ description: Request/Response DTOs, class-validator decorators, cross-field validation, query parameter DTOs, OpenAPI integration, and naming conventions.
4
+ order: 2
5
+ ---
6
+
7
+ # Archipel DTO & Validation Pattern
9
8
 
10
9
  ## Overview
11
10
 
12
11
  Archipel uses **class-based DTOs** with **class-validator** decorators for input validation
13
- and **class-transformer** decorators for serialization control. A global \`ValidationPipe\`
12
+ and **class-transformer** decorators for serialization control. A global `ValidationPipe`
14
13
  enforces validation on all incoming requests automatically.
15
14
 
16
15
  Request DTOs validate input; Response classes define the output shape with
17
- \`@ApiProperty\` decorators for OpenAPI documentation.
16
+ `@ApiProperty` decorators for OpenAPI documentation.
18
17
 
19
18
  ## Global Validation Pipe
20
19
 
21
- \`\`\`typescript
20
+ ```typescript
22
21
  // In main.ts bootstrap:
23
22
  app.useGlobalPipes(
24
23
  new ValidationPipe({
@@ -27,11 +26,11 @@ app.useGlobalPipes(
27
26
  transform: true, // Auto-transform payloads to DTO instances
28
27
  }),
29
28
  );
30
- \`\`\`
29
+ ```
31
30
 
32
31
  ## Request DTO (Input Validation)
33
32
 
34
- \`\`\`typescript
33
+ ```typescript
35
34
  // dtos/CreateUserRequest.ts
36
35
  import { Expose } from 'class-transformer';
37
36
  import { IsEmail, IsString, MinLength, MaxLength } from 'class-validator';
@@ -58,11 +57,11 @@ export class CreateUserRequest {
58
57
  public password!: string;
59
58
 
60
59
  }
61
- \`\`\`
60
+ ```
62
61
 
63
62
  ## Response DTO (Output Shape)
64
63
 
65
- \`\`\`typescript
64
+ ```typescript
66
65
  // dtos/UserResponse.ts
67
66
  import { Expose } from 'class-transformer';
68
67
  import { ApiProperty } from '@nestjs/swagger';
@@ -88,7 +87,7 @@ export class UserResponse {
88
87
  // Note: password is intentionally NOT exposed
89
88
 
90
89
  }
91
- \`\`\`
90
+ ```
92
91
 
93
92
  ## Common Validators
94
93
 
@@ -96,48 +95,48 @@ export class UserResponse {
96
95
 
97
96
  | Decorator | Purpose |
98
97
  |-----------|---------|
99
- | \`@IsString()\` | Must be a string |
100
- | \`@IsNumber()\` | Must be a number |
101
- | \`@IsBoolean()\` | Must be a boolean |
102
- | \`@IsEmail()\` | Must be a valid email |
103
- | \`@IsUUID()\` | Must be a valid UUID |
104
- | \`@IsDate()\` | Must be a Date instance |
105
- | \`@IsEnum(MyEnum)\` | Must be a value from the enum |
106
- | \`@IsOptional()\` | Field is optional (skip validation if undefined) |
98
+ | `@IsString()` | Must be a string |
99
+ | `@IsNumber()` | Must be a number |
100
+ | `@IsBoolean()` | Must be a boolean |
101
+ | `@IsEmail()` | Must be a valid email |
102
+ | `@IsUUID()` | Must be a valid UUID |
103
+ | `@IsDate()` | Must be a Date instance |
104
+ | `@IsEnum(MyEnum)` | Must be a value from the enum |
105
+ | `@IsOptional()` | Field is optional (skip validation if undefined) |
107
106
 
108
107
  ### String Constraints
109
108
 
110
109
  | Decorator | Purpose |
111
110
  |-----------|---------|
112
- | \`@MinLength(n)\` | Minimum string length |
113
- | \`@MaxLength(n)\` | Maximum string length |
114
- | \`@Matches(regex)\` | Must match a regex pattern |
115
- | \`@IsNotEmpty()\` | Must not be empty string |
111
+ | `@MinLength(n)` | Minimum string length |
112
+ | `@MaxLength(n)` | Maximum string length |
113
+ | `@Matches(regex)` | Must match a regex pattern |
114
+ | `@IsNotEmpty()` | Must not be empty string |
116
115
 
117
116
  ### Number Constraints
118
117
 
119
118
  | Decorator | Purpose |
120
119
  |-----------|---------|
121
- | \`@Min(n)\` | Minimum value |
122
- | \`@Max(n)\` | Maximum value |
123
- | \`@IsPositive()\` | Must be > 0 |
124
- | \`@IsInt()\` | Must be integer |
120
+ | `@Min(n)` | Minimum value |
121
+ | `@Max(n)` | Maximum value |
122
+ | `@IsPositive()` | Must be > 0 |
123
+ | `@IsInt()` | Must be integer |
125
124
 
126
125
  ### Nested & Array
127
126
 
128
127
  | Decorator | Purpose |
129
128
  |-----------|---------|
130
- | \`@ValidateNested()\` | Validate nested objects |
131
- | \`@Type(() => Cls)\` | Transform to class instance (class-transformer) |
132
- | \`@IsArray()\` | Must be an array |
133
- | \`@ArrayMinSize(n)\` | Minimum array length |
134
- | \`@ArrayMaxSize(n)\` | Maximum array length |
129
+ | `@ValidateNested()` | Validate nested objects |
130
+ | `@Type(() => Cls)` | Transform to class instance (class-transformer) |
131
+ | `@IsArray()` | Must be an array |
132
+ | `@ArrayMinSize(n)` | Minimum array length |
133
+ | `@ArrayMaxSize(n)` | Maximum array length |
135
134
 
136
135
  ## Cross-Field Validation
137
136
 
138
137
  For fields that depend on each other, use custom class-level validators:
139
138
 
140
- \`\`\`typescript
139
+ ```typescript
141
140
  import { ValidatorConstraint, ValidatorConstraintInterface, ValidationArguments, Validate } from 'class-validator';
142
141
 
143
142
  @ValidatorConstraint({ name: 'Match', async: false })
@@ -153,7 +152,7 @@ export class MatchConstraint implements ValidatorConstraintInterface {
153
152
  public defaultMessage(args: ValidationArguments): string {
154
153
  const [relatedPropertyName] = args.constraints;
155
154
 
156
- return \\\`\\\${args.property} must match \\\${relatedPropertyName}\\\`;
155
+ return `${args.property} must match ${relatedPropertyName}`;
157
156
  }
158
157
 
159
158
  }
@@ -172,13 +171,13 @@ export class ResetPasswordRequest {
172
171
  public confirmPassword!: string;
173
172
 
174
173
  }
175
- \`\`\`
174
+ ```
176
175
 
177
176
  ## Query Parameter DTOs
178
177
 
179
- For GET request query parameters, use \`@Transform()\` and \`@Type()\` for type coercion:
178
+ For GET request query parameters, use `@Transform()` and `@Type()` for type coercion:
180
179
 
181
- \`\`\`typescript
180
+ ```typescript
182
181
  import { Type } from 'class-transformer';
183
182
  import { IsOptional, IsInt, Min, Max, IsString } from 'class-validator';
184
183
  import { ApiPropertyOptional } from '@nestjs/swagger';
@@ -206,13 +205,13 @@ export class PaginationQuery {
206
205
  public search?: string;
207
206
 
208
207
  }
209
- \`\`\`
208
+ ```
210
209
 
211
210
  ## OpenAPI / Swagger Integration
212
211
 
213
212
  ### @ApiProperty Decorators
214
213
 
215
- \`\`\`typescript
214
+ ```typescript
216
215
  @ApiProperty({
217
216
  description: 'User email address',
218
217
  example: 'user@example.com',
@@ -225,11 +224,11 @@ public email!: string;
225
224
  maxLength: 500,
226
225
  })
227
226
  public bio?: string;
228
- \`\`\`
227
+ ```
229
228
 
230
229
  ### Controller Response Decorators
231
230
 
232
- \`\`\`typescript
231
+ ```typescript
233
232
  @Controller('/users')
234
233
  @ApiTags('Users')
235
234
  export class UsersController {
@@ -244,23 +243,23 @@ export class UsersController {
244
243
  }
245
244
 
246
245
  }
247
- \`\`\`
246
+ ```
248
247
 
249
248
  ## Naming Conventions
250
249
 
251
250
  | Type | Naming Pattern | Example |
252
251
  |------|---------------|---------|
253
- | Create input | \`Create{Entity}Request\` | \`CreateUserRequest\` |
254
- | Update input | \`Update{Entity}Request\` | \`UpdateUserRequest\` |
255
- | Query params | \`{Entity}Query\` or \`Pagination{Entity}Query\` | \`UserQuery\` |
256
- | Response | \`{Entity}Response\` | \`UserResponse\` |
257
- | List response | \`{Entity}ListResponse\` | \`UserListResponse\` |
252
+ | Create input | `Create{Entity}Request` | `CreateUserRequest` |
253
+ | Update input | `Update{Entity}Request` | `UpdateUserRequest` |
254
+ | Query params | `{Entity}Query` or `Pagination{Entity}Query` | `UserQuery` |
255
+ | Response | `{Entity}Response` | `UserResponse` |
256
+ | List response | `{Entity}ListResponse` | `UserListResponse` |
258
257
 
259
258
  ## Constants for Bounds
260
259
 
261
260
  Define and reuse constants for upper limits:
262
261
 
263
- \`\`\`typescript
262
+ ```typescript
264
263
  // constants/ValidationConstants.ts
265
264
  export const MAX_PAGE_SIZE = 100;
266
265
  export const MAX_SEARCH_LIMIT = 50;
@@ -270,17 +269,15 @@ export const MAX_BIO_LENGTH = 500;
270
269
  // In DTO:
271
270
  @Max(MAX_PAGE_SIZE)
272
271
  public perPage?: number;
273
- \`\`\`
272
+ ```
274
273
 
275
274
  ## Rules
276
275
 
277
- 1. **Every field has \`@Expose()\`** for serialization control.
278
- 2. **Every field has \`@ApiProperty()\`** for OpenAPI documentation.
276
+ 1. **Every field has `@Expose()`** for serialization control.
277
+ 2. **Every field has `@ApiProperty()`** for OpenAPI documentation.
279
278
  3. **Request DTOs use class-validator decorators** — validation is automatic via global pipe.
280
279
  4. **Response DTOs have no validation decorators** — they're output-only shapes.
281
280
  5. **Cross-field validation uses custom class-level validators** — never imperative checks in services.
282
- 6. **Query parameters use \`@Type(() => Number)\`** for type coercion from strings.
283
- 7. **Upper bounds (\`@Max\`, \`@MaxLength\`) defined as exported constants** — never inline magic numbers.
284
- 8. **\`whitelist: true\` + \`forbidNonWhitelisted: true\`** strips and rejects unknown properties.
285
- `;
286
- //# sourceMappingURL=dtoPattern.js.map
281
+ 6. **Query parameters use `@Type(() => Number)`** for type coercion from strings.
282
+ 7. **Upper bounds (`@Max`, `@MaxLength`) defined as exported constants** — never inline magic numbers.
283
+ 8. **`whitelist: true` + `forbidNonWhitelisted: true`** strips and rejects unknown properties.
@@ -1,11 +1,10 @@
1
- "use strict";
2
- /**
3
- * Static knowledge content for the Archipel error handling pattern.
4
- * Returned by the get-error-handling-pattern tool.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.ERROR_HANDLING_PATTERN_KNOWLEDGE = void 0;
8
- exports.ERROR_HANDLING_PATTERN_KNOWLEDGE = `# Archipel Error Handling Pattern
1
+ ---
2
+ title: Error Handling Pattern
3
+ description: Domain errors, RepositoryError, exception filters, and structured error response envelopes.
4
+ order: 3
5
+ ---
6
+
7
+ # Archipel Error Handling Pattern
9
8
 
10
9
  ## Overview
11
10
 
@@ -15,17 +14,17 @@ the HTTP translation. This keeps business logic clean and error responses consis
15
14
 
16
15
  ## Layer Architecture
17
16
 
18
- \`\`\`
17
+ ```
19
18
  Service → throws DomainError → ExceptionFilter → HTTP Response Envelope
20
- \`\`\`
19
+ ```
21
20
 
22
21
  ## Base Error Classes
23
22
 
24
23
  ### RepositoryError
25
24
 
26
- Thrown when any Prisma operation fails. Automatically wrapped by \`RepositoryBase.tryCatch()\`.
25
+ Thrown when any Prisma operation fails. Automatically wrapped by `RepositoryBase.tryCatch()`.
27
26
 
28
- \`\`\`typescript
27
+ ```typescript
29
28
  // models/errors/RepositoryError.ts
30
29
  export class RepositoryError extends Error {
31
30
 
@@ -46,13 +45,13 @@ export class RepositoryError extends Error {
46
45
  }
47
46
 
48
47
  }
49
- \`\`\`
48
+ ```
50
49
 
51
50
  ### MappingError (abstract)
52
51
 
53
52
  Base for mapping-related errors.
54
53
 
55
- \`\`\`typescript
54
+ ```typescript
56
55
  export abstract class MappingError extends Error {
57
56
  public readonly code: string;
58
57
 
@@ -61,17 +60,17 @@ export abstract class MappingError extends Error {
61
60
  this.code = code;
62
61
  }
63
62
  }
64
- \`\`\`
63
+ ```
65
64
 
66
65
  Concrete variants:
67
- - \`MappingNotRegisteredError\` — code: \`'MAPPING_NOT_REGISTERED'\`
68
- - \`TypeMappingNotRegisteredError\` — code: \`'TYPE_MAPPING_NOT_REGISTERED'\`
66
+ - `MappingNotRegisteredError` — code: `'MAPPING_NOT_REGISTERED'`
67
+ - `TypeMappingNotRegisteredError` — code: `'TYPE_MAPPING_NOT_REGISTERED'`
69
68
 
70
69
  ## Exception Filters
71
70
 
72
71
  ### RepositoryExceptionFilter
73
72
 
74
- \`\`\`typescript
73
+ ```typescript
75
74
  import { ArgumentsHost, Catch, ExceptionFilter, HttpStatus } from '@nestjs/common';
76
75
  import { Request, Response } from 'express';
77
76
  import { RepositoryError } from '../models/errors/RepositoryError';
@@ -93,19 +92,19 @@ export class RepositoryExceptionFilter implements ExceptionFilter<RepositoryErro
93
92
  }
94
93
 
95
94
  }
96
- \`\`\`
95
+ ```
97
96
 
98
97
  ### Registration (in main.ts or AppModule)
99
98
 
100
- \`\`\`typescript
99
+ ```typescript
101
100
  app.useGlobalFilters(new RepositoryExceptionFilter());
102
- \`\`\`
101
+ ```
103
102
 
104
103
  ## How to Create a Domain Error
105
104
 
106
105
  ### Step 1: Define the error class
107
106
 
108
- \`\`\`typescript
107
+ ```typescript
109
108
  // models/errors/UserNotFoundError.ts
110
109
  export class UserNotFoundError extends Error {
111
110
 
@@ -113,7 +112,7 @@ export class UserNotFoundError extends Error {
113
112
  public readonly userId: string;
114
113
 
115
114
  public constructor(userId: string) {
116
- super(\\\`User not found: \\\${userId}\\\`);
115
+ super(`User not found: ${userId}`);
117
116
  Object.setPrototypeOf(this, UserNotFoundError.prototype);
118
117
  this.name = 'UserNotFoundError';
119
118
  this.userId = userId;
@@ -124,11 +123,11 @@ export class UserNotFoundError extends Error {
124
123
  }
125
124
 
126
125
  }
127
- \`\`\`
126
+ ```
128
127
 
129
128
  ### Step 2: Create an exception filter
130
129
 
131
- \`\`\`typescript
130
+ ```typescript
132
131
  // filters/UserNotFoundExceptionFilter.ts
133
132
  import { ArgumentsHost, Catch, ExceptionFilter, HttpStatus } from '@nestjs/common';
134
133
  import { Request, Response } from 'express';
@@ -152,20 +151,20 @@ export class UserNotFoundExceptionFilter implements ExceptionFilter<UserNotFound
152
151
  }
153
152
 
154
153
  }
155
- \`\`\`
154
+ ```
156
155
 
157
156
  ### Step 3: Register the filter globally
158
157
 
159
- \`\`\`typescript
158
+ ```typescript
160
159
  app.useGlobalFilters(
161
160
  new RepositoryExceptionFilter(),
162
161
  new UserNotFoundExceptionFilter(),
163
162
  );
164
- \`\`\`
163
+ ```
165
164
 
166
165
  ### Step 4: Throw from a service
167
166
 
168
- \`\`\`typescript
167
+ ```typescript
169
168
  @Injectable()
170
169
  export class UserService {
171
170
 
@@ -180,13 +179,13 @@ export class UserService {
180
179
  }
181
180
 
182
181
  }
183
- \`\`\`
182
+ ```
184
183
 
185
184
  ## Response Envelope Convention
186
185
 
187
186
  All error responses follow the same shape:
188
187
 
189
- \`\`\`json
188
+ ```json
190
189
  {
191
190
  "statusCode": 404,
192
191
  "timestamp": "2026-04-05T12:00:00.000Z",
@@ -194,11 +193,11 @@ All error responses follow the same shape:
194
193
  "message": "User not found: abc-123",
195
194
  "path": "/api/v1/users/abc-123"
196
195
  }
197
- \`\`\`
196
+ ```
198
197
 
199
198
  ## Prisma Error Code Reference
200
199
 
201
- Common Prisma error codes wrapped by \`RepositoryError\`:
200
+ Common Prisma error codes wrapped by `RepositoryError`:
202
201
 
203
202
  | Code | Meaning |
204
203
  |------|---------|
@@ -211,9 +210,7 @@ Common Prisma error codes wrapped by \`RepositoryError\`:
211
210
 
212
211
  1. **Services throw domain errors** — never raw NestJS HttpException in service layer.
213
212
  2. **Exception filters map to HTTP** — one filter per domain error type.
214
- 3. **Error classes include a machine-readable \`code\`** — used for client-side error handling.
215
- 4. **Use \`Object.setPrototypeOf\`** and \`Error.captureStackTrace\` in custom Error subclasses.
213
+ 3. **Error classes include a machine-readable `code`** — used for client-side error handling.
214
+ 4. **Use `Object.setPrototypeOf`** and `Error.captureStackTrace` in custom Error subclasses.
216
215
  5. **Don't leak internal details** — the filter should not expose Prisma error codes or stack traces.
217
- 6. **Register filters globally** in the bootstrap function or via \`APP_FILTER\` provider.
218
- `;
219
- //# sourceMappingURL=errorHandlingPattern.js.map
216
+ 6. **Register filters globally** in the bootstrap function or via `APP_FILTER` provider.
@@ -1,11 +1,10 @@
1
- "use strict";
2
- /**
3
- * Static knowledge content for the Archipel guard & interceptor pattern.
4
- * Returned by the get-guard-pattern tool.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.GUARD_PATTERN_KNOWLEDGE = void 0;
8
- exports.GUARD_PATTERN_KNOWLEDGE = `# Archipel Guard & Interceptor Pattern
1
+ ---
2
+ title: Guard & Interceptor Pattern
3
+ description: Metadata decorators, FeatureGuard, RolesGuard, FeatureUsageInterceptor, and the full decorator-guard-interceptor trio.
4
+ order: 4
5
+ ---
6
+
7
+ # Archipel Guard & Interceptor Pattern
9
8
 
10
9
  ## Overview
11
10
 
@@ -18,39 +17,39 @@ This creates a reusable trio: **Decorator → Guard → Interceptor**.
18
17
 
19
18
  ## Guard Architecture
20
19
 
21
- \`\`\`
20
+ ```
22
21
  @RequiresFeature('create-posts') ← Decorator sets metadata
23
22
  @UseGuards(JwtAuthGuard, FeatureGuard) ← Guard reads metadata, checks access
24
23
  @UseInterceptors(FeatureUsageInterceptor) ← Interceptor records usage after success
25
- \`\`\`
24
+ ```
26
25
 
27
26
  ## Available Guards
28
27
 
29
28
  | Guard | Strategy | Purpose |
30
29
  |-------|----------|---------|
31
- | \`JwtAuthGuard\` | jwt | Validates JWT bearer token |
32
- | \`LocalAuthGuard\` | local | Validates username + password |
33
- | \`AnonymousAuthGuard\` | anonymous | Allows unauthenticated access with a seed user |
34
- | \`GithubAuthGuard\` | github | OAuth via GitHub |
35
- | \`RolesGuard\` | metadata | Checks user roles against required roles |
36
- | \`FeatureGuard\` | metadata + port | Checks feature access via FeatureAccessPort |
30
+ | `JwtAuthGuard` | jwt | Validates JWT bearer token |
31
+ | `LocalAuthGuard` | local | Validates username + password |
32
+ | `AnonymousAuthGuard` | anonymous | Allows unauthenticated access with a seed user |
33
+ | `GithubAuthGuard` | github | OAuth via GitHub |
34
+ | `RolesGuard` | metadata | Checks user roles against required roles |
35
+ | `FeatureGuard` | metadata + port | Checks feature access via FeatureAccessPort |
37
36
 
38
37
  ## The Feature Guard Pattern (Full Example)
39
38
 
40
39
  ### Step 1: Metadata Decorator
41
40
 
42
- \`\`\`typescript
41
+ ```typescript
43
42
  import { SetMetadata } from '@nestjs/common';
44
43
 
45
44
  export const FEATURE_KEY_METADATA = 'feature_key';
46
45
 
47
46
  export const RequiresFeature = (featureKey: string) =>
48
47
  SetMetadata(FEATURE_KEY_METADATA, featureKey);
49
- \`\`\`
48
+ ```
50
49
 
51
50
  ### Step 2: Guard
52
51
 
53
- \`\`\`typescript
52
+ ```typescript
54
53
  import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common';
55
54
  import { Reflector } from '@nestjs/core';
56
55
  import { FeatureAccessPort } from '../contracts/FeatureAccessPort';
@@ -99,11 +98,11 @@ export class FeatureGuard implements CanActivate {
99
98
  // #endregion
100
99
 
101
100
  }
102
- \`\`\`
101
+ ```
103
102
 
104
103
  ### Step 3: Interceptor (records usage after success)
105
104
 
106
- \`\`\`typescript
105
+ ```typescript
107
106
  import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nestjs/common';
108
107
  import { Reflector } from '@nestjs/core';
109
108
  import { Observable } from 'rxjs';
@@ -152,11 +151,11 @@ export class FeatureUsageInterceptor implements NestInterceptor {
152
151
  // #endregion
153
152
 
154
153
  }
155
- \`\`\`
154
+ ```
156
155
 
157
156
  ### Step 4: Controller Usage
158
157
 
159
- \`\`\`typescript
158
+ ```typescript
160
159
  @Controller('/posts')
161
160
  export class PostsController {
162
161
 
@@ -171,11 +170,11 @@ export class PostsController {
171
170
  }
172
171
 
173
172
  }
174
- \`\`\`
173
+ ```
175
174
 
176
175
  ## Roles Guard Pattern
177
176
 
178
- \`\`\`typescript
177
+ ```typescript
179
178
  // Decorator
180
179
  export const Roles = (...roles: string[]) => SetMetadata('roles', roles);
181
180
 
@@ -202,11 +201,11 @@ export class RolesGuard implements CanActivate {
202
201
  @Roles('admin', 'superadmin')
203
202
  @UseGuards(JwtAuthGuard, RolesGuard)
204
203
  public async getAdminPanel(): Promise<AdminResponse> { ... }
205
- \`\`\`
204
+ ```
206
205
 
207
206
  ## Telemetry Interceptor
208
207
 
209
- \`\`\`typescript
208
+ ```typescript
210
209
  @Injectable()
211
210
  export class OperationTelemetryInterceptor implements NestInterceptor {
212
211
 
@@ -220,24 +219,24 @@ export class OperationTelemetryInterceptor implements NestInterceptor {
220
219
  }
221
220
 
222
221
  }
223
- \`\`\`
222
+ ```
224
223
 
225
224
  ## How to Create a Custom Guard + Interceptor Pair
226
225
 
227
226
  ### Step 1: Define the metadata key and decorator
228
227
 
229
- \`\`\`typescript
228
+ ```typescript
230
229
  export const RATE_LIMIT_METADATA = 'rate_limit';
231
230
  export const RateLimit = (maxRequests: number) => SetMetadata(RATE_LIMIT_METADATA, maxRequests);
232
- \`\`\`
231
+ ```
233
232
 
234
233
  ### Step 2: Create the guard
235
234
 
236
- Read metadata via \`Reflector\`, check the condition, return boolean.
235
+ Read metadata via `Reflector`, check the condition, return boolean.
237
236
 
238
237
  ### Step 3: Create the interceptor (optional)
239
238
 
240
- Use \`tap()\` in the RxJS pipeline to perform post-handler side effects.
239
+ Use `tap()` in the RxJS pipeline to perform post-handler side effects.
241
240
 
242
241
  ### Step 4: Register in the module
243
242
 
@@ -245,12 +244,10 @@ Export guard and interceptor from the library module so consumers can apply them
245
244
 
246
245
  ## Rules
247
246
 
248
- 1. **Guards decide access** — return \`true\` or \`false\`, never throw directly.
247
+ 1. **Guards decide access** — return `true` or `false`, never throw directly.
249
248
  2. **Interceptors handle side effects** — recording, logging, transforming responses.
250
249
  3. **Metadata decorators are the glue** — they attach config to handlers, read by guards/interceptors.
251
- 4. **Auth guards extend Passport's AuthGuard** — e.g. \`AuthGuard('jwt')\`.
250
+ 4. **Auth guards extend Passport's AuthGuard** — e.g. `AuthGuard('jwt')`.
252
251
  5. **Feature guards delegate to ports** — the guard itself holds no business logic.
253
- 6. **Guard order matters** — \`@UseGuards(AuthGuard, FeatureGuard)\`: auth runs first.
254
- 7. **Interceptors use \`tap()\`** for post-handler logic, \`map()\` for response transformation.
255
- `;
256
- //# sourceMappingURL=guardPattern.js.map
252
+ 6. **Guard order matters** — `@UseGuards(AuthGuard, FeatureGuard)`: auth runs first.
253
+ 7. **Interceptors use `tap()`** for post-handler logic, `map()` for response transformation.