@shrkcrft/presets 0.1.0-alpha.2 → 0.1.0-alpha.20
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/dist/builtin/angular21-presets.d.ts +9 -0
- package/dist/builtin/angular21-presets.d.ts.map +1 -0
- package/dist/builtin/angular21-presets.js +218 -0
- package/dist/builtin/angular21-snippets.d.ts +28 -0
- package/dist/builtin/angular21-snippets.d.ts.map +1 -0
- package/dist/builtin/angular21-snippets.js +243 -0
- package/dist/builtin/builtin-presets.d.ts.map +1 -1
- package/dist/builtin/builtin-presets.js +40 -19
- package/dist/builtin/nest11-presets.d.ts +11 -0
- package/dist/builtin/nest11-presets.d.ts.map +1 -0
- package/dist/builtin/nest11-presets.js +257 -0
- package/dist/builtin/nest11-snippets.d.ts +32 -0
- package/dist/builtin/nest11-snippets.d.ts.map +1 -0
- package/dist/builtin/nest11-snippets.js +270 -0
- package/dist/builtin/r26-presets.d.ts +1 -3
- package/dist/builtin/r26-presets.d.ts.map +1 -1
- package/dist/builtin/r26-presets.js +5 -33
- package/dist/builtin/r26-snippets.d.ts +0 -2
- package/dist/builtin/r26-snippets.d.ts.map +1 -1
- package/dist/builtin/r26-snippets.js +0 -16
- package/dist/builtin/r45-presets.d.ts +1 -1
- package/dist/builtin/r45-presets.d.ts.map +1 -1
- package/dist/builtin/r45-presets.js +5 -5
- package/dist/builtin/r47-presets.d.ts +1 -1
- package/dist/builtin/r47-presets.d.ts.map +1 -1
- package/dist/builtin/r47-presets.js +4 -4
- package/dist/builtin/react19-presets.d.ts +12 -0
- package/dist/builtin/react19-presets.d.ts.map +1 -0
- package/dist/builtin/react19-presets.js +299 -0
- package/dist/builtin/react19-snippets.d.ts +43 -0
- package/dist/builtin/react19-snippets.d.ts.map +1 -0
- package/dist/builtin/react19-snippets.js +363 -0
- package/dist/builtin/shared-snippets.d.ts +25 -3
- package/dist/builtin/shared-snippets.d.ts.map +1 -1
- package/dist/builtin/shared-snippets.js +265 -0
- package/dist/emit/synthesize-files.d.ts.map +1 -1
- package/dist/emit/synthesize-files.js +76 -17
- package/dist/registry/recommend.d.ts.map +1 -1
- package/dist/registry/recommend.js +7 -3
- package/package.json +5 -5
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { WorkspaceProfile } from '@shrkcrft/workspace';
|
|
2
2
|
import { definePreset } from "../define/define-preset.js";
|
|
3
|
-
import { COMMON_AGENT_BRIEFING, COMMON_PATH_SERVICES, COMMON_PATH_TESTS, COMMON_PATH_UTILS, COMMON_PIPELINE_CONTEXT_ONLY, COMMON_PIPELINE_FEATURE_DEV, COMMON_PIPELINE_UNIT_TEST, COMMON_RULE_INTERFACE_PREFIX, COMMON_RULE_NO_LOGIC_CONSTRUCTORS, COMMON_RULE_ONE_EXPORT, COMMON_SAFETY_RULE, COMMON_TEMPLATE_SERVICE, COMMON_TEMPLATE_TEST, COMMON_TEMPLATE_UTILITY, OVERVIEW_DOC, } from "./shared-snippets.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { ANGULAR_PATH_APP, ANGULAR_PATH_COMPONENTS, ANGULAR_PATH_SERVICES, COMMON_AGENT_BRIEFING, COMMON_PATH_SERVICES, COMMON_PATH_TESTS, COMMON_PATH_UTILS, COMMON_PIPELINE_CONTEXT_ONLY, COMMON_PIPELINE_FEATURE_DEV, COMMON_PIPELINE_UNIT_TEST, COMMON_RULE_INTERFACE_PREFIX, COMMON_RULE_NO_LOGIC_CONSTRUCTORS, COMMON_RULE_ONE_EXPORT, COMMON_SAFETY_RULE, COMMON_TEMPLATE_SERVICE, COMMON_TEMPLATE_TEST, COMMON_TEMPLATE_UTILITY, GO_PATH_CMD, GO_PATH_INTERNAL, GO_PATH_PKG, JAVA_MAVEN_PATH_MAIN, JAVA_MAVEN_PATH_TESTS, NX_PATH_APPS, NX_PATH_LIBS, OVERVIEW_DOC, PYTHON_PATH_SRC, PYTHON_PATH_TESTS, RUST_PATH_SRC, RUST_PATH_TESTS, } from "./shared-snippets.js";
|
|
4
|
+
import { MULTI_STACK_PRESETS } from "./r26-presets.js";
|
|
5
|
+
import { UNIVERSAL_ADOPTION_PRESETS } from "./r45-presets.js";
|
|
6
|
+
import { CANONICAL_ALIAS_PRESETS } from "./r47-presets.js";
|
|
7
|
+
import { ANGULAR_21_PRESETS } from "./angular21-presets.js";
|
|
8
|
+
import { NEST_11_PRESETS } from "./nest11-presets.js";
|
|
9
|
+
import { REACT_19_PRESETS } from "./react19-presets.js";
|
|
7
10
|
const GENERIC = definePreset({
|
|
8
11
|
id: 'generic',
|
|
9
12
|
title: 'Generic SharkCraft setup',
|
|
@@ -133,7 +136,7 @@ const ANGULAR_APP = definePreset({
|
|
|
133
136
|
includes: {
|
|
134
137
|
knowledge: [COMMON_AGENT_BRIEFING],
|
|
135
138
|
rules: [COMMON_SAFETY_RULE, COMMON_RULE_ONE_EXPORT],
|
|
136
|
-
paths: [
|
|
139
|
+
paths: [ANGULAR_PATH_APP, ANGULAR_PATH_COMPONENTS, ANGULAR_PATH_SERVICES],
|
|
137
140
|
templates: [COMMON_TEMPLATE_UTILITY, COMMON_TEMPLATE_TEST],
|
|
138
141
|
pipelines: [COMMON_PIPELINE_CONTEXT_ONLY, COMMON_PIPELINE_FEATURE_DEV],
|
|
139
142
|
docs: {
|
|
@@ -150,7 +153,7 @@ const ANGULAR_APP = definePreset({
|
|
|
150
153
|
const NX_MONOREPO = definePreset({
|
|
151
154
|
id: 'nx-monorepo',
|
|
152
155
|
title: 'Nx monorepo',
|
|
153
|
-
description: 'Conventions for Nx workspaces:
|
|
156
|
+
description: 'Conventions for Nx workspaces: public entrypoints, no relative cross-lib imports, affected build/test commands.',
|
|
154
157
|
tags: ['nx', 'monorepo'],
|
|
155
158
|
appliesTo: [WorkspaceProfile.HasNx, WorkspaceProfile.IsMonorepo],
|
|
156
159
|
weight: 8,
|
|
@@ -158,13 +161,13 @@ const NX_MONOREPO = definePreset({
|
|
|
158
161
|
knowledge: [
|
|
159
162
|
COMMON_AGENT_BRIEFING,
|
|
160
163
|
`defineKnowledgeEntry({
|
|
161
|
-
id: 'nx.
|
|
162
|
-
title: 'Nx
|
|
164
|
+
id: 'nx.boundary-tags',
|
|
165
|
+
title: 'Respect Nx boundary tags',
|
|
163
166
|
type: KnowledgeType.Rule,
|
|
164
167
|
priority: KnowledgePriority.Critical,
|
|
165
168
|
tags: ['nx', 'architecture'],
|
|
166
169
|
appliesWhen: ['generate-code', 'refactor'],
|
|
167
|
-
content: 'Respect the
|
|
170
|
+
content: 'Respect the boundary tags declared on each project (scope, type). The enforce-module-boundaries lint rule must stay green.',
|
|
168
171
|
})`,
|
|
169
172
|
`defineKnowledgeEntry({
|
|
170
173
|
id: 'nx.public-entrypoints',
|
|
@@ -177,11 +180,11 @@ const NX_MONOREPO = definePreset({
|
|
|
177
180
|
})`,
|
|
178
181
|
],
|
|
179
182
|
rules: [COMMON_SAFETY_RULE, COMMON_RULE_INTERFACE_PREFIX, COMMON_RULE_ONE_EXPORT],
|
|
180
|
-
paths: [
|
|
183
|
+
paths: [NX_PATH_LIBS, NX_PATH_APPS],
|
|
181
184
|
templates: [COMMON_TEMPLATE_SERVICE, COMMON_TEMPLATE_UTILITY, COMMON_TEMPLATE_TEST],
|
|
182
185
|
pipelines: [COMMON_PIPELINE_CONTEXT_ONLY, COMMON_PIPELINE_FEATURE_DEV, COMMON_PIPELINE_UNIT_TEST],
|
|
183
186
|
docs: {
|
|
184
|
-
'overview.md': OVERVIEW_DOC('Nx monorepo', 'Many libraries. Layer order is enforced.'),
|
|
187
|
+
'overview.md': OVERVIEW_DOC('Nx monorepo', 'Many libraries. Layer order is enforced. Code lives under libs/<area>/src/lib/; apps under apps/<app>/.'),
|
|
185
188
|
},
|
|
186
189
|
},
|
|
187
190
|
recommendedNextCommands: [
|
|
@@ -374,7 +377,7 @@ const JAVA_MAVEN_SERVICE = definePreset({
|
|
|
374
377
|
includes: {
|
|
375
378
|
knowledge: [COMMON_AGENT_BRIEFING],
|
|
376
379
|
rules: [COMMON_SAFETY_RULE],
|
|
377
|
-
paths: [],
|
|
380
|
+
paths: [JAVA_MAVEN_PATH_MAIN, JAVA_MAVEN_PATH_TESTS],
|
|
378
381
|
templates: [],
|
|
379
382
|
pipelines: [],
|
|
380
383
|
docs: {
|
|
@@ -392,7 +395,7 @@ const JAVA_GRADLE_SERVICE = definePreset({
|
|
|
392
395
|
includes: {
|
|
393
396
|
knowledge: [COMMON_AGENT_BRIEFING],
|
|
394
397
|
rules: [COMMON_SAFETY_RULE],
|
|
395
|
-
paths: [],
|
|
398
|
+
paths: [JAVA_MAVEN_PATH_MAIN, JAVA_MAVEN_PATH_TESTS],
|
|
396
399
|
templates: [],
|
|
397
400
|
pipelines: [],
|
|
398
401
|
docs: {
|
|
@@ -428,7 +431,7 @@ const PYTHON_SERVICE = definePreset({
|
|
|
428
431
|
includes: {
|
|
429
432
|
knowledge: [COMMON_AGENT_BRIEFING],
|
|
430
433
|
rules: [COMMON_SAFETY_RULE],
|
|
431
|
-
paths: [],
|
|
434
|
+
paths: [PYTHON_PATH_SRC, PYTHON_PATH_TESTS],
|
|
432
435
|
templates: [],
|
|
433
436
|
pipelines: [],
|
|
434
437
|
docs: {
|
|
@@ -446,7 +449,7 @@ const GO_MODULE = definePreset({
|
|
|
446
449
|
includes: {
|
|
447
450
|
knowledge: [COMMON_AGENT_BRIEFING],
|
|
448
451
|
rules: [COMMON_SAFETY_RULE],
|
|
449
|
-
paths: [],
|
|
452
|
+
paths: [GO_PATH_CMD, GO_PATH_PKG, GO_PATH_INTERNAL],
|
|
450
453
|
templates: [],
|
|
451
454
|
pipelines: [],
|
|
452
455
|
docs: {
|
|
@@ -464,7 +467,7 @@ const RUST_CRATE = definePreset({
|
|
|
464
467
|
includes: {
|
|
465
468
|
knowledge: [COMMON_AGENT_BRIEFING],
|
|
466
469
|
rules: [COMMON_SAFETY_RULE],
|
|
467
|
-
paths: [],
|
|
470
|
+
paths: [RUST_PATH_SRC, RUST_PATH_TESTS],
|
|
468
471
|
templates: [],
|
|
469
472
|
pipelines: [],
|
|
470
473
|
docs: {
|
|
@@ -512,9 +515,27 @@ export const BUILTIN_PRESETS = Object.freeze([
|
|
|
512
515
|
RUST_CRATE,
|
|
513
516
|
POLYGLOT_MONOREPO,
|
|
514
517
|
// Modern Angular, strict TypeScript, frontend/backend/testing variants
|
|
515
|
-
...
|
|
518
|
+
...MULTI_STACK_PRESETS,
|
|
516
519
|
// Universal adoption: next-app, turborepo, package-workspace, clean-architecture-ts
|
|
517
|
-
...
|
|
520
|
+
...UNIVERSAL_ADOPTION_PRESETS,
|
|
518
521
|
// Universal adoption top-5: nest-service, angular-app canonical aliases
|
|
519
|
-
...
|
|
522
|
+
...CANONICAL_ALIAS_PRESETS,
|
|
523
|
+
// Angular 18 / 19 / 20 / 21 — signal queries, signal I/O, zoneless,
|
|
524
|
+
// @if/@for/@defer/@let, resource() / httpResource(), inject(), no
|
|
525
|
+
// NgModules. Weight 11-12 so the recommender prefers these over
|
|
526
|
+
// R26 `modern-angular` (weight 9) when the workspace is Angular.
|
|
527
|
+
...ANGULAR_21_PRESETS,
|
|
528
|
+
// NestJS 11+ — thin controllers, global ValidationPipe + class-validator,
|
|
529
|
+
// async lifecycle, Fastify + cache + throttler, helmet + JWT guards,
|
|
530
|
+
// structured logging + terminus health, TestingModule + supertest e2e.
|
|
531
|
+
// Weight 11-12 so the recommender prefers these over R26 `nestjs-service`
|
|
532
|
+
// (weight 7) and R47 `nest-service` (weight 9) when the workspace is Nest.
|
|
533
|
+
...NEST_11_PRESETS,
|
|
534
|
+
// React 19+ — function components + ref-as-prop, hooks discipline,
|
|
535
|
+
// Actions / useActionState / useOptimistic, TanStack Query for server
|
|
536
|
+
// state, React Compiler + lazy + virtualization, useTransition /
|
|
537
|
+
// Suspense, Vitest + RTL + userEvent + MSW, RSC + 'use client' +
|
|
538
|
+
// Server Actions. Weight 11-12 so the recommender prefers these over
|
|
539
|
+
// the legacy `frontend-app` (weight 6) when the workspace is React.
|
|
540
|
+
...REACT_19_PRESETS,
|
|
520
541
|
]);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IPreset } from '../model/preset.js';
|
|
2
|
+
export declare const NEST_11_ARCHITECTURE: IPreset;
|
|
3
|
+
export declare const NEST_11_VALIDATION: IPreset;
|
|
4
|
+
export declare const NEST_11_ASYNC_LIFECYCLE: IPreset;
|
|
5
|
+
export declare const NEST_11_PERFORMANCE: IPreset;
|
|
6
|
+
export declare const NEST_11_SECURITY: IPreset;
|
|
7
|
+
export declare const NEST_11_OBSERVABILITY: IPreset;
|
|
8
|
+
export declare const NEST_11_TESTING: IPreset;
|
|
9
|
+
export declare const NEST_11_MODERN: IPreset;
|
|
10
|
+
export declare const NEST_11_PRESETS: readonly IPreset[];
|
|
11
|
+
//# sourceMappingURL=nest11-presets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest11-presets.d.ts","sourceRoot":"","sources":["../../src/builtin/nest11-presets.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAsDlD,eAAO,MAAM,oBAAoB,EAAE,OA+BjC,CAAC;AAIH,eAAO,MAAM,kBAAkB,EAAE,OA6B/B,CAAC;AAIH,eAAO,MAAM,uBAAuB,EAAE,OA2BpC,CAAC;AAIH,eAAO,MAAM,mBAAmB,EAAE,OA4BhC,CAAC;AAIH,eAAO,MAAM,gBAAgB,EAAE,OA8B7B,CAAC;AAIH,eAAO,MAAM,qBAAqB,EAAE,OA4BlC,CAAC;AAIH,eAAO,MAAM,eAAe,EAAE,OA2B5B,CAAC;AAIH,eAAO,MAAM,cAAc,EAAE,OA4C3B,CAAC;AAEH,eAAO,MAAM,eAAe,EAAE,SAAS,OAAO,EAS5C,CAAC"}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
// NestJS 11+ preset family.
|
|
2
|
+
//
|
|
3
|
+
// Seven focused presets covering modern Nest practice — architecture,
|
|
4
|
+
// validation, async lifecycle, performance, security, observability,
|
|
5
|
+
// testing — plus one comprehensive `nest-11-modern` that composes them.
|
|
6
|
+
// Targets HasNestJS workspaces with weight set above the legacy R26
|
|
7
|
+
// `nestjs-service` (weight 7) and R47 `nest-service` canonical alias
|
|
8
|
+
// (weight 9), so the recommender prefers these when the workspace
|
|
9
|
+
// declares HasNestJS.
|
|
10
|
+
import { WorkspaceProfile } from '@shrkcrft/workspace';
|
|
11
|
+
import { definePreset } from "../define/define-preset.js";
|
|
12
|
+
import { COMMON_AGENT_BRIEFING, COMMON_PIPELINE_CONTEXT_ONLY, COMMON_PIPELINE_FEATURE_DEV, COMMON_PIPELINE_UNIT_TEST, COMMON_SAFETY_RULE, NEST_PATH_E2E, NEST_PATH_SRC, OVERVIEW_DOC, } from "./shared-snippets.js";
|
|
13
|
+
import { NEST11_API_VERSIONING, NEST11_ASYNC_PROVIDERS, NEST11_CACHE_MANAGER, NEST11_CLASS_VALIDATOR_DTO, NEST11_DTO_AT_BOUNDARY, NEST11_E2E_SUPERTEST, NEST11_ENABLE_SHUTDOWN_HOOKS, NEST11_EXPLICIT_CORS, NEST11_FASTIFY_ADAPTER, NEST11_GLOBAL_VALIDATION_PIPE, NEST11_HELMET, NEST11_JWT_GUARDS, NEST11_LIFECYCLE_HOOKS, NEST11_LOGGER_WITH_CONTEXT, NEST11_MODULE_PER_FEATURE, NEST11_MODULE_PUBLIC_API, NEST11_NO_CIRCULAR_MODULES, NEST11_NO_LOG_SECRETS, NEST11_NO_QUERY_IN_CONTROLLER, NEST11_NO_SECRETS_IN_CODE, NEST11_PAGINATION_BY_DEFAULT, NEST11_REQUEST_RESPONSE_DTOS, NEST11_SERVICE_OWNS_DOMAIN, NEST11_STRUCTURED_LOGS, NEST11_SWAGGER_DECORATORS, NEST11_TERMINUS_HEALTH, NEST11_TEST_FILE_LAYOUT, NEST11_TESTING_MODULE, NEST11_THIN_CONTROLLERS, NEST11_THROTTLER, NEST11_TRUST_PROXY_AWARE, } from "./nest11-snippets.js";
|
|
14
|
+
const NEST11_TAGS = ['nestjs', 'nest-11', 'backend'];
|
|
15
|
+
const NEST11_NEXT_COMMANDS = [
|
|
16
|
+
'shrk doctor',
|
|
17
|
+
'shrk task "<task>"',
|
|
18
|
+
'shrk ci scaffold github-actions --quickstart',
|
|
19
|
+
];
|
|
20
|
+
// ─── 1) Architecture — modules, controllers, services, repos ─────────────
|
|
21
|
+
export const NEST_11_ARCHITECTURE = definePreset({
|
|
22
|
+
id: 'nest-11-architecture',
|
|
23
|
+
title: 'NestJS 11 — module + controller + service architecture',
|
|
24
|
+
description: 'Module-per-feature, thin controllers (validate + delegate, nothing more), services own domain logic, repositories abstract data access, DTOs at every HTTP boundary, no circular module dependencies. The structural backbone of a maintainable Nest service.',
|
|
25
|
+
tags: [...NEST11_TAGS, 'architecture'],
|
|
26
|
+
appliesTo: [WorkspaceProfile.HasNestJS, WorkspaceProfile.IsBackend],
|
|
27
|
+
weight: 11,
|
|
28
|
+
includes: {
|
|
29
|
+
knowledge: [COMMON_AGENT_BRIEFING],
|
|
30
|
+
rules: [
|
|
31
|
+
COMMON_SAFETY_RULE,
|
|
32
|
+
NEST11_THIN_CONTROLLERS,
|
|
33
|
+
NEST11_SERVICE_OWNS_DOMAIN,
|
|
34
|
+
NEST11_MODULE_PER_FEATURE,
|
|
35
|
+
NEST11_MODULE_PUBLIC_API,
|
|
36
|
+
NEST11_NO_CIRCULAR_MODULES,
|
|
37
|
+
NEST11_DTO_AT_BOUNDARY,
|
|
38
|
+
NEST11_NO_QUERY_IN_CONTROLLER,
|
|
39
|
+
],
|
|
40
|
+
paths: [NEST_PATH_SRC, NEST_PATH_E2E],
|
|
41
|
+
templates: [],
|
|
42
|
+
pipelines: [COMMON_PIPELINE_CONTEXT_ONLY, COMMON_PIPELINE_FEATURE_DEV],
|
|
43
|
+
docs: {
|
|
44
|
+
'overview.md': OVERVIEW_DOC('NestJS 11 architecture', 'Module per feature under src/<feature>/. Controllers parse + delegate. Services own domain logic; data access goes through repositories. Modules export only their public providers. DTOs at every boundary; entities never leave the service layer.'),
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
recommendedNextCommands: NEST11_NEXT_COMMANDS,
|
|
48
|
+
});
|
|
49
|
+
// ─── 2) Validation — ValidationPipe + class-validator + DTOs ─────────────
|
|
50
|
+
export const NEST_11_VALIDATION = definePreset({
|
|
51
|
+
id: 'nest-11-validation',
|
|
52
|
+
title: 'NestJS 11 — strict validation at the boundary',
|
|
53
|
+
description: 'Global ValidationPipe with whitelist + forbidNonWhitelisted + transform, class-validator decorators on every DTO field, separated request and response DTOs, @ApiProperty annotations for the OpenAPI contract.',
|
|
54
|
+
tags: [...NEST11_TAGS, 'validation'],
|
|
55
|
+
appliesTo: [WorkspaceProfile.HasNestJS, WorkspaceProfile.IsBackend],
|
|
56
|
+
weight: 11,
|
|
57
|
+
includes: {
|
|
58
|
+
knowledge: [COMMON_AGENT_BRIEFING],
|
|
59
|
+
rules: [
|
|
60
|
+
COMMON_SAFETY_RULE,
|
|
61
|
+
NEST11_GLOBAL_VALIDATION_PIPE,
|
|
62
|
+
NEST11_CLASS_VALIDATOR_DTO,
|
|
63
|
+
NEST11_REQUEST_RESPONSE_DTOS,
|
|
64
|
+
NEST11_DTO_AT_BOUNDARY,
|
|
65
|
+
NEST11_SWAGGER_DECORATORS,
|
|
66
|
+
],
|
|
67
|
+
paths: [NEST_PATH_SRC],
|
|
68
|
+
templates: [],
|
|
69
|
+
pipelines: [COMMON_PIPELINE_CONTEXT_ONLY, COMMON_PIPELINE_FEATURE_DEV],
|
|
70
|
+
docs: {
|
|
71
|
+
'overview.md': OVERVIEW_DOC('NestJS 11 validation', 'ValidationPipe is registered globally with strict options. Every DTO is a class with class-validator decorators; @Type() wires nested objects through class-transformer. Request and response DTOs are separate classes — input is whitelisted, output is projected.'),
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
recommendedNextCommands: NEST11_NEXT_COMMANDS,
|
|
75
|
+
});
|
|
76
|
+
// ─── 3) Async lifecycle + graceful shutdown ──────────────────────────────
|
|
77
|
+
export const NEST_11_ASYNC_LIFECYCLE = definePreset({
|
|
78
|
+
id: 'nest-11-async-lifecycle',
|
|
79
|
+
title: 'NestJS 11 — async providers + graceful shutdown',
|
|
80
|
+
description: 'Async configuration providers via useFactory, OnModuleInit / OnApplicationBootstrap / OnModuleDestroy / OnApplicationShutdown lifecycle hooks, enableShutdownHooks() at bootstrap so SIGTERM cleanly tears down DB pools and message clients.',
|
|
81
|
+
tags: [...NEST11_TAGS, 'lifecycle'],
|
|
82
|
+
appliesTo: [WorkspaceProfile.HasNestJS, WorkspaceProfile.IsBackend],
|
|
83
|
+
weight: 11,
|
|
84
|
+
includes: {
|
|
85
|
+
knowledge: [COMMON_AGENT_BRIEFING],
|
|
86
|
+
rules: [
|
|
87
|
+
COMMON_SAFETY_RULE,
|
|
88
|
+
NEST11_LIFECYCLE_HOOKS,
|
|
89
|
+
NEST11_ENABLE_SHUTDOWN_HOOKS,
|
|
90
|
+
NEST11_ASYNC_PROVIDERS,
|
|
91
|
+
],
|
|
92
|
+
paths: [NEST_PATH_SRC],
|
|
93
|
+
templates: [],
|
|
94
|
+
pipelines: [COMMON_PIPELINE_CONTEXT_ONLY, COMMON_PIPELINE_FEATURE_DEV],
|
|
95
|
+
docs: {
|
|
96
|
+
'overview.md': OVERVIEW_DOC('NestJS 11 lifecycle', 'enableShutdownHooks() in main.ts so the OnModuleDestroy / OnApplicationShutdown hooks fire on SIGTERM. Configuration that must resolve at boot uses { useFactory } async providers — not lazy init from inside a service.'),
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
recommendedNextCommands: NEST11_NEXT_COMMANDS,
|
|
100
|
+
});
|
|
101
|
+
// ─── 4) Performance — Fastify, cache, throttler, pagination ──────────────
|
|
102
|
+
export const NEST_11_PERFORMANCE = definePreset({
|
|
103
|
+
id: 'nest-11-performance',
|
|
104
|
+
title: 'NestJS 11 — Fastify, caching, throttling, pagination',
|
|
105
|
+
description: 'NestFastifyApplication adapter for ~2× throughput vs. Express, @nestjs/cache-manager for hot reads, @nestjs/throttler for per-IP rate limiting, mandatory pagination on every list endpoint.',
|
|
106
|
+
tags: [...NEST11_TAGS, 'performance'],
|
|
107
|
+
appliesTo: [WorkspaceProfile.HasNestJS, WorkspaceProfile.IsBackend],
|
|
108
|
+
weight: 11,
|
|
109
|
+
includes: {
|
|
110
|
+
knowledge: [COMMON_AGENT_BRIEFING],
|
|
111
|
+
rules: [
|
|
112
|
+
COMMON_SAFETY_RULE,
|
|
113
|
+
NEST11_FASTIFY_ADAPTER,
|
|
114
|
+
NEST11_CACHE_MANAGER,
|
|
115
|
+
NEST11_THROTTLER,
|
|
116
|
+
NEST11_PAGINATION_BY_DEFAULT,
|
|
117
|
+
],
|
|
118
|
+
paths: [NEST_PATH_SRC],
|
|
119
|
+
templates: [],
|
|
120
|
+
pipelines: [COMMON_PIPELINE_CONTEXT_ONLY, COMMON_PIPELINE_FEATURE_DEV],
|
|
121
|
+
docs: {
|
|
122
|
+
'overview.md': OVERVIEW_DOC('NestJS 11 performance', 'Fastify adapter for high-throughput HTTP. Idempotent GETs cached via CacheInterceptor with explicit per-route TTLs. Global ThrottlerModule with sane defaults (60 req/min/IP); per-route overrides via @Throttle. List endpoints paginate by default; pageSize is capped server-side.'),
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
recommendedNextCommands: NEST11_NEXT_COMMANDS,
|
|
126
|
+
});
|
|
127
|
+
// ─── 5) Security — helmet, CORS, auth, secrets, trust-proxy ──────────────
|
|
128
|
+
export const NEST_11_SECURITY = definePreset({
|
|
129
|
+
id: 'nest-11-security',
|
|
130
|
+
title: 'NestJS 11 — security baseline',
|
|
131
|
+
description: 'helmet middleware for HTTP security headers, explicit CORS allowlist (never `origin: true`), JWT auth via @nestjs/passport guards, no-secrets-in-source enforcement, trust-proxy configured for load-balanced deployments, throttler for abuse protection.',
|
|
132
|
+
tags: [...NEST11_TAGS, 'security'],
|
|
133
|
+
appliesTo: [WorkspaceProfile.HasNestJS, WorkspaceProfile.IsBackend],
|
|
134
|
+
weight: 11,
|
|
135
|
+
includes: {
|
|
136
|
+
knowledge: [COMMON_AGENT_BRIEFING],
|
|
137
|
+
rules: [
|
|
138
|
+
COMMON_SAFETY_RULE,
|
|
139
|
+
NEST11_HELMET,
|
|
140
|
+
NEST11_EXPLICIT_CORS,
|
|
141
|
+
NEST11_JWT_GUARDS,
|
|
142
|
+
NEST11_NO_SECRETS_IN_CODE,
|
|
143
|
+
NEST11_TRUST_PROXY_AWARE,
|
|
144
|
+
NEST11_THROTTLER,
|
|
145
|
+
],
|
|
146
|
+
paths: [NEST_PATH_SRC],
|
|
147
|
+
templates: [],
|
|
148
|
+
pipelines: [COMMON_PIPELINE_CONTEXT_ONLY, COMMON_PIPELINE_FEATURE_DEV],
|
|
149
|
+
docs: {
|
|
150
|
+
'overview.md': OVERVIEW_DOC('NestJS 11 security', 'helmet registered before any route. CORS allowlist explicit. Authentication runs through Guards (JwtAuthGuard + @UseGuards), not middleware. Secrets come from ConfigService.get only. trust-proxy configured. Throttler in place.'),
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
recommendedNextCommands: NEST11_NEXT_COMMANDS,
|
|
154
|
+
});
|
|
155
|
+
// ─── 6) Observability — Logger, structured logs, terminus ────────────────
|
|
156
|
+
export const NEST_11_OBSERVABILITY = definePreset({
|
|
157
|
+
id: 'nest-11-observability',
|
|
158
|
+
title: 'NestJS 11 — structured logging + health checks',
|
|
159
|
+
description: 'Per-provider Logger instances with context names, structured JSON logs in production (pino / nest-winston), redact-list for secrets and PII, @nestjs/terminus health checks with separated liveness and readiness endpoints.',
|
|
160
|
+
tags: [...NEST11_TAGS, 'observability'],
|
|
161
|
+
appliesTo: [WorkspaceProfile.HasNestJS, WorkspaceProfile.IsBackend],
|
|
162
|
+
weight: 11,
|
|
163
|
+
includes: {
|
|
164
|
+
knowledge: [COMMON_AGENT_BRIEFING],
|
|
165
|
+
rules: [
|
|
166
|
+
COMMON_SAFETY_RULE,
|
|
167
|
+
NEST11_LOGGER_WITH_CONTEXT,
|
|
168
|
+
NEST11_STRUCTURED_LOGS,
|
|
169
|
+
NEST11_NO_LOG_SECRETS,
|
|
170
|
+
NEST11_TERMINUS_HEALTH,
|
|
171
|
+
],
|
|
172
|
+
paths: [NEST_PATH_SRC],
|
|
173
|
+
templates: [],
|
|
174
|
+
pipelines: [COMMON_PIPELINE_CONTEXT_ONLY, COMMON_PIPELINE_FEATURE_DEV],
|
|
175
|
+
docs: {
|
|
176
|
+
'overview.md': OVERVIEW_DOC('NestJS 11 observability', 'Each provider holds its own Logger(MyService.name). Production logger is structured JSON via pino or nest-winston with a redact list for tokens / passwords / PII. /health/liveness and /health/readiness are separate endpoints; readiness fails 503 when a critical dep is down.'),
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
recommendedNextCommands: NEST11_NEXT_COMMANDS,
|
|
180
|
+
});
|
|
181
|
+
// ─── 7) Testing — TestingModule + e2e ───────────────────────────────────
|
|
182
|
+
export const NEST_11_TESTING = definePreset({
|
|
183
|
+
id: 'nest-11-testing',
|
|
184
|
+
title: 'NestJS 11 — TestingModule + supertest e2e',
|
|
185
|
+
description: 'Unit tests via Test.createTestingModule + overrideProvider for slow deps, co-located *.spec.ts files; e2e under test/*.e2e-spec.ts driving the real AppModule through supertest with the validation pipeline live.',
|
|
186
|
+
tags: [...NEST11_TAGS, 'testing'],
|
|
187
|
+
appliesTo: [WorkspaceProfile.HasNestJS, WorkspaceProfile.IsBackend],
|
|
188
|
+
weight: 11,
|
|
189
|
+
includes: {
|
|
190
|
+
knowledge: [COMMON_AGENT_BRIEFING],
|
|
191
|
+
rules: [
|
|
192
|
+
COMMON_SAFETY_RULE,
|
|
193
|
+
NEST11_TESTING_MODULE,
|
|
194
|
+
NEST11_E2E_SUPERTEST,
|
|
195
|
+
NEST11_TEST_FILE_LAYOUT,
|
|
196
|
+
],
|
|
197
|
+
paths: [NEST_PATH_SRC, NEST_PATH_E2E],
|
|
198
|
+
templates: [],
|
|
199
|
+
pipelines: [COMMON_PIPELINE_CONTEXT_ONLY, COMMON_PIPELINE_UNIT_TEST],
|
|
200
|
+
docs: {
|
|
201
|
+
'overview.md': OVERVIEW_DOC('NestJS 11 testing', 'Unit specs are co-located beside their unit; they use Test.createTestingModule + overrideProvider to fake the expensive deps. E2E specs live under test/, drive AppModule through supertest, and keep the real validation pipeline + guards + interceptors active — that is the contract being tested.'),
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
recommendedNextCommands: NEST11_NEXT_COMMANDS,
|
|
205
|
+
});
|
|
206
|
+
// ─── 8) The whole stack — composes 1-7 ──────────────────────────────────
|
|
207
|
+
export const NEST_11_MODERN = definePreset({
|
|
208
|
+
id: 'nest-11-modern',
|
|
209
|
+
title: 'NestJS 11 — modern stack (architecture + validation + lifecycle + perf + security + obs + testing)',
|
|
210
|
+
description: 'The canonical preset for a new NestJS 11+ service. Composes the seven focused presets, then layers on API versioning. Use this unless you specifically want a narrower slice.',
|
|
211
|
+
tags: [...NEST11_TAGS, 'comprehensive'],
|
|
212
|
+
appliesTo: [WorkspaceProfile.HasNestJS, WorkspaceProfile.IsBackend, WorkspaceProfile.IsService],
|
|
213
|
+
weight: 12,
|
|
214
|
+
composes: [
|
|
215
|
+
'nest-11-architecture',
|
|
216
|
+
'nest-11-validation',
|
|
217
|
+
'nest-11-async-lifecycle',
|
|
218
|
+
'nest-11-performance',
|
|
219
|
+
'nest-11-security',
|
|
220
|
+
'nest-11-observability',
|
|
221
|
+
'nest-11-testing',
|
|
222
|
+
],
|
|
223
|
+
includes: {
|
|
224
|
+
knowledge: [COMMON_AGENT_BRIEFING],
|
|
225
|
+
rules: [
|
|
226
|
+
COMMON_SAFETY_RULE,
|
|
227
|
+
// Extras that don't fit any single focused preset:
|
|
228
|
+
NEST11_API_VERSIONING,
|
|
229
|
+
],
|
|
230
|
+
paths: [NEST_PATH_SRC, NEST_PATH_E2E],
|
|
231
|
+
templates: [],
|
|
232
|
+
pipelines: [
|
|
233
|
+
COMMON_PIPELINE_CONTEXT_ONLY,
|
|
234
|
+
COMMON_PIPELINE_FEATURE_DEV,
|
|
235
|
+
COMMON_PIPELINE_UNIT_TEST,
|
|
236
|
+
],
|
|
237
|
+
docs: {
|
|
238
|
+
'overview.md': OVERVIEW_DOC('NestJS 11 modern stack', 'Module-per-feature architecture. Thin controllers, services own domain, repositories abstract data. Global ValidationPipe + class-validator. Fastify adapter, cache-manager, throttler, mandatory pagination. helmet + CORS allowlist + JWT guards + no-secrets. Per-provider Logger + structured JSON logs + terminus health. TestingModule unit specs + supertest e2e. URI versioning when the API has external consumers.'),
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
recommendedNextCommands: [
|
|
242
|
+
'shrk doctor',
|
|
243
|
+
'shrk task "<task>"',
|
|
244
|
+
'shrk ci scaffold github-actions --quickstart',
|
|
245
|
+
'nest g resource <feature>',
|
|
246
|
+
],
|
|
247
|
+
});
|
|
248
|
+
export const NEST_11_PRESETS = Object.freeze([
|
|
249
|
+
NEST_11_ARCHITECTURE,
|
|
250
|
+
NEST_11_VALIDATION,
|
|
251
|
+
NEST_11_ASYNC_LIFECYCLE,
|
|
252
|
+
NEST_11_PERFORMANCE,
|
|
253
|
+
NEST_11_SECURITY,
|
|
254
|
+
NEST_11_OBSERVABILITY,
|
|
255
|
+
NEST_11_TESTING,
|
|
256
|
+
NEST_11_MODERN,
|
|
257
|
+
]);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare const NEST11_THIN_CONTROLLERS: string;
|
|
2
|
+
export declare const NEST11_SERVICE_OWNS_DOMAIN: string;
|
|
3
|
+
export declare const NEST11_MODULE_PER_FEATURE: string;
|
|
4
|
+
export declare const NEST11_MODULE_PUBLIC_API: string;
|
|
5
|
+
export declare const NEST11_NO_CIRCULAR_MODULES: string;
|
|
6
|
+
export declare const NEST11_DTO_AT_BOUNDARY: string;
|
|
7
|
+
export declare const NEST11_GLOBAL_VALIDATION_PIPE: string;
|
|
8
|
+
export declare const NEST11_CLASS_VALIDATOR_DTO: string;
|
|
9
|
+
export declare const NEST11_REQUEST_RESPONSE_DTOS: string;
|
|
10
|
+
export declare const NEST11_SWAGGER_DECORATORS: string;
|
|
11
|
+
export declare const NEST11_LIFECYCLE_HOOKS: string;
|
|
12
|
+
export declare const NEST11_ENABLE_SHUTDOWN_HOOKS: string;
|
|
13
|
+
export declare const NEST11_ASYNC_PROVIDERS: string;
|
|
14
|
+
export declare const NEST11_FASTIFY_ADAPTER: string;
|
|
15
|
+
export declare const NEST11_CACHE_MANAGER: string;
|
|
16
|
+
export declare const NEST11_THROTTLER: string;
|
|
17
|
+
export declare const NEST11_PAGINATION_BY_DEFAULT: string;
|
|
18
|
+
export declare const NEST11_HELMET: string;
|
|
19
|
+
export declare const NEST11_EXPLICIT_CORS: string;
|
|
20
|
+
export declare const NEST11_JWT_GUARDS: string;
|
|
21
|
+
export declare const NEST11_NO_SECRETS_IN_CODE: string;
|
|
22
|
+
export declare const NEST11_TRUST_PROXY_AWARE: string;
|
|
23
|
+
export declare const NEST11_LOGGER_WITH_CONTEXT: string;
|
|
24
|
+
export declare const NEST11_STRUCTURED_LOGS: string;
|
|
25
|
+
export declare const NEST11_NO_LOG_SECRETS: string;
|
|
26
|
+
export declare const NEST11_TERMINUS_HEALTH: string;
|
|
27
|
+
export declare const NEST11_TESTING_MODULE: string;
|
|
28
|
+
export declare const NEST11_E2E_SUPERTEST: string;
|
|
29
|
+
export declare const NEST11_TEST_FILE_LAYOUT: string;
|
|
30
|
+
export declare const NEST11_API_VERSIONING: string;
|
|
31
|
+
export declare const NEST11_NO_QUERY_IN_CONTROLLER: string;
|
|
32
|
+
//# sourceMappingURL=nest11-snippets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nest11-snippets.d.ts","sourceRoot":"","sources":["../../src/builtin/nest11-snippets.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,uBAAuB,QAQlC,CAAC;AAEH,eAAO,MAAM,0BAA0B,QAQrC,CAAC;AAEH,eAAO,MAAM,yBAAyB,QAQpC,CAAC;AAEH,eAAO,MAAM,wBAAwB,QAQnC,CAAC;AAEH,eAAO,MAAM,0BAA0B,QAQrC,CAAC;AAEH,eAAO,MAAM,sBAAsB,QAQjC,CAAC;AAIH,eAAO,MAAM,6BAA6B,QAQxC,CAAC;AAEH,eAAO,MAAM,0BAA0B,QAQrC,CAAC;AAEH,eAAO,MAAM,4BAA4B,QAQvC,CAAC;AAEH,eAAO,MAAM,yBAAyB,QAQpC,CAAC;AAIH,eAAO,MAAM,sBAAsB,QAQjC,CAAC;AAEH,eAAO,MAAM,4BAA4B,QAQvC,CAAC;AAEH,eAAO,MAAM,sBAAsB,QAQjC,CAAC;AAIH,eAAO,MAAM,sBAAsB,QAQjC,CAAC;AAEH,eAAO,MAAM,oBAAoB,QAQ/B,CAAC;AAEH,eAAO,MAAM,gBAAgB,QAQ3B,CAAC;AAEH,eAAO,MAAM,4BAA4B,QAQvC,CAAC;AAIH,eAAO,MAAM,aAAa,QAQxB,CAAC;AAEH,eAAO,MAAM,oBAAoB,QAQ/B,CAAC;AAEH,eAAO,MAAM,iBAAiB,QAQ5B,CAAC;AAEH,eAAO,MAAM,yBAAyB,QAQpC,CAAC;AAEH,eAAO,MAAM,wBAAwB,QAQnC,CAAC;AAIH,eAAO,MAAM,0BAA0B,QAQrC,CAAC;AAEH,eAAO,MAAM,sBAAsB,QAQjC,CAAC;AAEH,eAAO,MAAM,qBAAqB,QAQhC,CAAC;AAEH,eAAO,MAAM,sBAAsB,QAQjC,CAAC;AAIH,eAAO,MAAM,qBAAqB,QAQhC,CAAC;AAEH,eAAO,MAAM,oBAAoB,QAQ/B,CAAC;AAEH,eAAO,MAAM,uBAAuB,QAQlC,CAAC;AAIH,eAAO,MAAM,qBAAqB,QAQhC,CAAC;AAEH,eAAO,MAAM,6BAA6B,QAQxC,CAAC"}
|