@pattern-stack/codegen 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +67 -0
- package/README.md +214 -0
- package/dist/runtime/analytics/index.d.ts +6 -0
- package/dist/runtime/analytics/index.js +49 -0
- package/dist/runtime/analytics/index.js.map +1 -0
- package/dist/runtime/analytics/metrics.d.ts +75 -0
- package/dist/runtime/analytics/metrics.js +1 -0
- package/dist/runtime/analytics/metrics.js.map +1 -0
- package/dist/runtime/analytics/packs/crm-entity-measures.d.ts +21 -0
- package/dist/runtime/analytics/packs/crm-entity-measures.js +1 -0
- package/dist/runtime/analytics/packs/crm-entity-measures.js.map +1 -0
- package/dist/runtime/analytics/packs/index.d.ts +3 -0
- package/dist/runtime/analytics/packs/index.js +1 -0
- package/dist/runtime/analytics/packs/index.js.map +1 -0
- package/dist/runtime/analytics/packs/monetary-measures.d.ts +21 -0
- package/dist/runtime/analytics/packs/monetary-measures.js +1 -0
- package/dist/runtime/analytics/packs/monetary-measures.js.map +1 -0
- package/dist/runtime/analytics/specs.d.ts +49 -0
- package/dist/runtime/analytics/specs.js +1 -0
- package/dist/runtime/analytics/specs.js.map +1 -0
- package/dist/runtime/analytics/types.d.ts +85 -0
- package/dist/runtime/analytics/types.js +49 -0
- package/dist/runtime/analytics/types.js.map +1 -0
- package/dist/runtime/base-classes/activity-entity-repository.d.ts +26 -0
- package/dist/runtime/base-classes/activity-entity-repository.js +195 -0
- package/dist/runtime/base-classes/activity-entity-repository.js.map +1 -0
- package/dist/runtime/base-classes/activity-entity-service.d.ts +39 -0
- package/dist/runtime/base-classes/activity-entity-service.js +214 -0
- package/dist/runtime/base-classes/activity-entity-service.js.map +1 -0
- package/dist/runtime/base-classes/base-read-use-cases.d.ts +68 -0
- package/dist/runtime/base-classes/base-read-use-cases.js +32 -0
- package/dist/runtime/base-classes/base-read-use-cases.js.map +1 -0
- package/dist/runtime/base-classes/base-repository.d.ts +99 -0
- package/dist/runtime/base-classes/base-repository.js +160 -0
- package/dist/runtime/base-classes/base-repository.js.map +1 -0
- package/dist/runtime/base-classes/base-service.d.ts +98 -0
- package/dist/runtime/base-classes/base-service.js +186 -0
- package/dist/runtime/base-classes/base-service.js.map +1 -0
- package/dist/runtime/base-classes/index.d.ts +18 -0
- package/dist/runtime/base-classes/index.js +617 -0
- package/dist/runtime/base-classes/index.js.map +1 -0
- package/dist/runtime/base-classes/knowledge-entity-repository.d.ts +17 -0
- package/dist/runtime/base-classes/knowledge-entity-repository.js +166 -0
- package/dist/runtime/base-classes/knowledge-entity-repository.js.map +1 -0
- package/dist/runtime/base-classes/knowledge-entity-service.d.ts +15 -0
- package/dist/runtime/base-classes/knowledge-entity-service.js +192 -0
- package/dist/runtime/base-classes/knowledge-entity-service.js.map +1 -0
- package/dist/runtime/base-classes/lifecycle-events.d.ts +49 -0
- package/dist/runtime/base-classes/lifecycle-events.js +76 -0
- package/dist/runtime/base-classes/lifecycle-events.js.map +1 -0
- package/dist/runtime/base-classes/metadata-entity-repository.d.ts +27 -0
- package/dist/runtime/base-classes/metadata-entity-repository.js +212 -0
- package/dist/runtime/base-classes/metadata-entity-repository.js.map +1 -0
- package/dist/runtime/base-classes/metadata-entity-service.d.ts +39 -0
- package/dist/runtime/base-classes/metadata-entity-service.js +214 -0
- package/dist/runtime/base-classes/metadata-entity-service.js.map +1 -0
- package/dist/runtime/base-classes/synced-entity-repository.d.ts +32 -0
- package/dist/runtime/base-classes/synced-entity-repository.js +203 -0
- package/dist/runtime/base-classes/synced-entity-repository.js.map +1 -0
- package/dist/runtime/base-classes/synced-entity-service.d.ts +41 -0
- package/dist/runtime/base-classes/synced-entity-service.js +215 -0
- package/dist/runtime/base-classes/synced-entity-service.js.map +1 -0
- package/dist/runtime/base-classes/with-analytics.d.ts +18 -0
- package/dist/runtime/base-classes/with-analytics.js +11 -0
- package/dist/runtime/base-classes/with-analytics.js.map +1 -0
- package/dist/runtime/constants/tokens.d.ts +29 -0
- package/dist/runtime/constants/tokens.js +8 -0
- package/dist/runtime/constants/tokens.js.map +1 -0
- package/dist/runtime/subsystems/analytics/analytics-query.protocol.d.ts +30 -0
- package/dist/runtime/subsystems/analytics/analytics-query.protocol.js +1 -0
- package/dist/runtime/subsystems/analytics/analytics-query.protocol.js.map +1 -0
- package/dist/runtime/subsystems/analytics/analytics.module.d.ts +34 -0
- package/dist/runtime/subsystems/analytics/analytics.module.js +117 -0
- package/dist/runtime/subsystems/analytics/analytics.module.js.map +1 -0
- package/dist/runtime/subsystems/analytics/analytics.tokens.d.ts +24 -0
- package/dist/runtime/subsystems/analytics/analytics.tokens.js +10 -0
- package/dist/runtime/subsystems/analytics/analytics.tokens.js.map +1 -0
- package/dist/runtime/subsystems/analytics/cube-backend.d.ts +28 -0
- package/dist/runtime/subsystems/analytics/cube-backend.js +71 -0
- package/dist/runtime/subsystems/analytics/cube-backend.js.map +1 -0
- package/dist/runtime/subsystems/analytics/index.d.ts +6 -0
- package/dist/runtime/subsystems/analytics/index.js +122 -0
- package/dist/runtime/subsystems/analytics/index.js.map +1 -0
- package/dist/runtime/subsystems/analytics/noop-backend.d.ts +7 -0
- package/dist/runtime/subsystems/analytics/noop-backend.js +25 -0
- package/dist/runtime/subsystems/analytics/noop-backend.js.map +1 -0
- package/dist/runtime/subsystems/cache/cache.drizzle-backend.d.ts +43 -0
- package/dist/runtime/subsystems/cache/cache.drizzle-backend.js +133 -0
- package/dist/runtime/subsystems/cache/cache.drizzle-backend.js.map +1 -0
- package/dist/runtime/subsystems/cache/cache.memory-backend.d.ts +21 -0
- package/dist/runtime/subsystems/cache/cache.memory-backend.js +100 -0
- package/dist/runtime/subsystems/cache/cache.memory-backend.js.map +1 -0
- package/dist/runtime/subsystems/cache/cache.module.d.ts +37 -0
- package/dist/runtime/subsystems/cache/cache.module.js +272 -0
- package/dist/runtime/subsystems/cache/cache.module.js.map +1 -0
- package/dist/runtime/subsystems/cache/cache.protocol.d.ts +42 -0
- package/dist/runtime/subsystems/cache/cache.protocol.js +1 -0
- package/dist/runtime/subsystems/cache/cache.protocol.js.map +1 -0
- package/dist/runtime/subsystems/cache/cache.schema.d.ts +64 -0
- package/dist/runtime/subsystems/cache/cache.schema.js +18 -0
- package/dist/runtime/subsystems/cache/cache.schema.js.map +1 -0
- package/dist/runtime/subsystems/cache/cache.tokens.d.ts +18 -0
- package/dist/runtime/subsystems/cache/cache.tokens.js +8 -0
- package/dist/runtime/subsystems/cache/cache.tokens.js.map +1 -0
- package/dist/runtime/subsystems/cache/index.d.ts +11 -0
- package/dist/runtime/subsystems/cache/index.js +277 -0
- package/dist/runtime/subsystems/cache/index.js.map +1 -0
- package/dist/runtime/subsystems/events/domain-events.schema.d.ts +187 -0
- package/dist/runtime/subsystems/events/domain-events.schema.js +32 -0
- package/dist/runtime/subsystems/events/domain-events.schema.js.map +1 -0
- package/dist/runtime/subsystems/events/event-bus.drizzle-backend.d.ts +38 -0
- package/dist/runtime/subsystems/events/event-bus.drizzle-backend.js +199 -0
- package/dist/runtime/subsystems/events/event-bus.drizzle-backend.js.map +1 -0
- package/dist/runtime/subsystems/events/event-bus.memory-backend.d.ts +18 -0
- package/dist/runtime/subsystems/events/event-bus.memory-backend.js +71 -0
- package/dist/runtime/subsystems/events/event-bus.memory-backend.js.map +1 -0
- package/dist/runtime/subsystems/events/event-bus.protocol.d.ts +52 -0
- package/dist/runtime/subsystems/events/event-bus.protocol.js +1 -0
- package/dist/runtime/subsystems/events/event-bus.protocol.js.map +1 -0
- package/dist/runtime/subsystems/events/event-bus.redis-backend.d.ts +95 -0
- package/dist/runtime/subsystems/events/event-bus.redis-backend.js +229 -0
- package/dist/runtime/subsystems/events/event-bus.redis-backend.js.map +1 -0
- package/dist/runtime/subsystems/events/events.module.d.ts +46 -0
- package/dist/runtime/subsystems/events/events.module.js +531 -0
- package/dist/runtime/subsystems/events/events.module.js.map +1 -0
- package/dist/runtime/subsystems/events/events.tokens.d.ts +19 -0
- package/dist/runtime/subsystems/events/events.tokens.js +8 -0
- package/dist/runtime/subsystems/events/events.tokens.js.map +1 -0
- package/dist/runtime/subsystems/events/index.d.ts +12 -0
- package/dist/runtime/subsystems/events/index.js +536 -0
- package/dist/runtime/subsystems/events/index.js.map +1 -0
- package/dist/runtime/subsystems/index.d.ts +24 -0
- package/dist/runtime/subsystems/index.js +1643 -0
- package/dist/runtime/subsystems/index.js.map +1 -0
- package/dist/runtime/subsystems/jobs/index.d.ts +14 -0
- package/dist/runtime/subsystems/jobs/index.js +680 -0
- package/dist/runtime/subsystems/jobs/index.js.map +1 -0
- package/dist/runtime/subsystems/jobs/job-queue.bullmq-backend.d.ts +54 -0
- package/dist/runtime/subsystems/jobs/job-queue.bullmq-backend.js +186 -0
- package/dist/runtime/subsystems/jobs/job-queue.bullmq-backend.js.map +1 -0
- package/dist/runtime/subsystems/jobs/job-queue.drizzle-backend.d.ts +38 -0
- package/dist/runtime/subsystems/jobs/job-queue.drizzle-backend.js +228 -0
- package/dist/runtime/subsystems/jobs/job-queue.drizzle-backend.js.map +1 -0
- package/dist/runtime/subsystems/jobs/job-queue.memory-backend.d.ts +12 -0
- package/dist/runtime/subsystems/jobs/job-queue.memory-backend.js +44 -0
- package/dist/runtime/subsystems/jobs/job-queue.memory-backend.js.map +1 -0
- package/dist/runtime/subsystems/jobs/job-queue.protocol.d.ts +48 -0
- package/dist/runtime/subsystems/jobs/job-queue.protocol.js +1 -0
- package/dist/runtime/subsystems/jobs/job-queue.protocol.js.map +1 -0
- package/dist/runtime/subsystems/jobs/job-queue.redis-backend.d.ts +46 -0
- package/dist/runtime/subsystems/jobs/job-queue.redis-backend.js +187 -0
- package/dist/runtime/subsystems/jobs/job-queue.redis-backend.js.map +1 -0
- package/dist/runtime/subsystems/jobs/job-queue.schema.d.ts +237 -0
- package/dist/runtime/subsystems/jobs/job-queue.schema.js +44 -0
- package/dist/runtime/subsystems/jobs/job-queue.schema.js.map +1 -0
- package/dist/runtime/subsystems/jobs/jobs.module.d.ts +18 -0
- package/dist/runtime/subsystems/jobs/jobs.module.js +676 -0
- package/dist/runtime/subsystems/jobs/jobs.module.js.map +1 -0
- package/dist/runtime/subsystems/jobs/jobs.tokens.d.ts +13 -0
- package/dist/runtime/subsystems/jobs/jobs.tokens.js +8 -0
- package/dist/runtime/subsystems/jobs/jobs.tokens.js.map +1 -0
- package/dist/runtime/subsystems/storage/index.d.ts +6 -0
- package/dist/runtime/subsystems/storage/index.js +204 -0
- package/dist/runtime/subsystems/storage/index.js.map +1 -0
- package/dist/runtime/subsystems/storage/storage.local-backend.d.ts +18 -0
- package/dist/runtime/subsystems/storage/storage.local-backend.js +108 -0
- package/dist/runtime/subsystems/storage/storage.local-backend.js.map +1 -0
- package/dist/runtime/subsystems/storage/storage.memory-backend.d.ts +28 -0
- package/dist/runtime/subsystems/storage/storage.memory-backend.js +72 -0
- package/dist/runtime/subsystems/storage/storage.memory-backend.js.map +1 -0
- package/dist/runtime/subsystems/storage/storage.module.d.ts +40 -0
- package/dist/runtime/subsystems/storage/storage.module.js +201 -0
- package/dist/runtime/subsystems/storage/storage.module.js.map +1 -0
- package/dist/runtime/subsystems/storage/storage.protocol.d.ts +69 -0
- package/dist/runtime/subsystems/storage/storage.protocol.js +1 -0
- package/dist/runtime/subsystems/storage/storage.protocol.js.map +1 -0
- package/dist/runtime/subsystems/storage/storage.tokens.d.ts +11 -0
- package/dist/runtime/subsystems/storage/storage.tokens.js +6 -0
- package/dist/runtime/subsystems/storage/storage.tokens.js.map +1 -0
- package/dist/runtime/subsystems/storage/storage.utils.d.ts +9 -0
- package/dist/runtime/subsystems/storage/storage.utils.js +18 -0
- package/dist/runtime/subsystems/storage/storage.utils.js.map +1 -0
- package/dist/runtime/types/drizzle.d.ts +17 -0
- package/dist/runtime/types/drizzle.js +1 -0
- package/dist/runtime/types/drizzle.js.map +1 -0
- package/dist/src/cli/index.d.ts +1 -0
- package/dist/src/cli/index.js +7365 -0
- package/dist/src/cli/index.js.map +1 -0
- package/dist/src/index.d.ts +2384 -0
- package/dist/src/index.js +2198 -0
- package/dist/src/index.js.map +1 -0
- package/package.json +114 -0
- package/templates/broadcast/new/backend-interface.ejs.t +47 -0
- package/templates/broadcast/new/bridge-listener.ejs.t +67 -0
- package/templates/broadcast/new/channel.ejs.t +77 -0
- package/templates/broadcast/new/index.ejs.t +21 -0
- package/templates/broadcast/new/memory-backend.ejs.t +87 -0
- package/templates/broadcast/new/module.ejs.t +57 -0
- package/templates/broadcast/new/prompt.js +268 -0
- package/templates/broadcast/new/websocket-backend.ejs.t +259 -0
- package/templates/entity/new/backend/application/commands/create.ejs.t +55 -0
- package/templates/entity/new/backend/application/commands/delete.ejs.t +45 -0
- package/templates/entity/new/backend/application/commands/grouped-index.ejs.t +149 -0
- package/templates/entity/new/backend/application/commands/index.ejs.t +15 -0
- package/templates/entity/new/backend/application/commands/update.ejs.t +58 -0
- package/templates/entity/new/backend/application/queries/declarative-queries.ejs.t +36 -0
- package/templates/entity/new/backend/application/queries/get-by-id.ejs.t +42 -0
- package/templates/entity/new/backend/application/queries/grouped-index.ejs.t +81 -0
- package/templates/entity/new/backend/application/queries/index.ejs.t +14 -0
- package/templates/entity/new/backend/application/queries/list.ejs.t +36 -0
- package/templates/entity/new/backend/application/schemas/_inject-index.ejs.t +7 -0
- package/templates/entity/new/backend/application/schemas/dto.ejs.t +45 -0
- package/templates/entity/new/backend/database/_inject-index.ejs.t +7 -0
- package/templates/entity/new/backend/database/electric-migration.ejs.t +21 -0
- package/templates/entity/new/backend/database/repository.ejs.t +450 -0
- package/templates/entity/new/backend/database/schema.ejs.t +248 -0
- package/templates/entity/new/backend/domain/_inject-index.ejs.t +12 -0
- package/templates/entity/new/backend/domain/entity.ejs.t +108 -0
- package/templates/entity/new/backend/domain/grouped-index.ejs.t +163 -0
- package/templates/entity/new/backend/domain/index.ejs.t +15 -0
- package/templates/entity/new/backend/domain/repository-interface.ejs.t +71 -0
- package/templates/entity/new/backend/modules/core/_ensure-anchor-tokens.ejs.t +10 -0
- package/templates/entity/new/backend/modules/core/_inject-token.ejs.t +7 -0
- package/templates/entity/new/backend/modules/core/module.ejs.t +67 -0
- package/templates/entity/new/backend/modules/trpc/module.ejs.t +67 -0
- package/templates/entity/new/backend/presentation/controller.ejs.t +201 -0
- package/templates/entity/new/clean-lite-ps/controller.ejs.t +37 -0
- package/templates/entity/new/clean-lite-ps/dto/create.ejs.t +17 -0
- package/templates/entity/new/clean-lite-ps/dto/output.ejs.t +25 -0
- package/templates/entity/new/clean-lite-ps/dto/update.ejs.t +11 -0
- package/templates/entity/new/clean-lite-ps/entity.ejs.t +52 -0
- package/templates/entity/new/clean-lite-ps/index.ejs.t +20 -0
- package/templates/entity/new/clean-lite-ps/module.ejs.t +43 -0
- package/templates/entity/new/clean-lite-ps/prompt-extension.js +617 -0
- package/templates/entity/new/clean-lite-ps/repository.ejs.t +62 -0
- package/templates/entity/new/clean-lite-ps/service.ejs.t +34 -0
- package/templates/entity/new/clean-lite-ps/use-cases/declarative-queries.ejs.t +34 -0
- package/templates/entity/new/clean-lite-ps/use-cases/find-by-id.ejs.t +16 -0
- package/templates/entity/new/clean-lite-ps/use-cases/list.ejs.t +16 -0
- package/templates/entity/new/frontend/_inject-entities-entry.ejs.t +7 -0
- package/templates/entity/new/frontend/_inject-entities-import.ejs.t +7 -0
- package/templates/entity/new/frontend/collections/_ensure-anchor-collections.ejs.t +10 -0
- package/templates/entity/new/frontend/collections/_inject-index.ejs.t +9 -0
- package/templates/entity/new/frontend/collections/_inject-schema-import.ejs.t +9 -0
- package/templates/entity/new/frontend/collections/collection.ejs.t +61 -0
- package/templates/entity/new/frontend/collections/collections-base.ejs.t +24 -0
- package/templates/entity/new/frontend/entity/collection.ejs.t +172 -0
- package/templates/entity/new/frontend/entity/combined.ejs.t +474 -0
- package/templates/entity/new/frontend/entity/fields.ejs.t +104 -0
- package/templates/entity/new/frontend/entity/hooks.ejs.t +73 -0
- package/templates/entity/new/frontend/entity/index.ejs.t +21 -0
- package/templates/entity/new/frontend/entity/mutation-hooks.ejs.t +84 -0
- package/templates/entity/new/frontend/entity/mutations.ejs.t +38 -0
- package/templates/entity/new/frontend/entity/types.ejs.t +59 -0
- package/templates/entity/new/frontend/generated/_inject-index-export.ejs.t +7 -0
- package/templates/entity/new/frontend/generated/_inject-index-import.ejs.t +7 -0
- package/templates/entity/new/frontend/generated/_inject-index-registry.ejs.t +7 -0
- package/templates/entity/new/frontend/store/_inject-collection-import.ejs.t +9 -0
- package/templates/entity/new/frontend/store/_inject-collections.ejs.t +9 -0
- package/templates/entity/new/frontend/store/_inject-entity.ejs.t +9 -0
- package/templates/entity/new/frontend/store/_inject-import.ejs.t +9 -0
- package/templates/entity/new/frontend/store/_inject-lookups.ejs.t +9 -0
- package/templates/entity/new/frontend/store/_inject-resolve.ejs.t +10 -0
- package/templates/entity/new/frontend/store/hooks.ejs.t +72 -0
- package/templates/entity/new/frontend/unified-entity.ejs.t +28 -0
- package/templates/entity/new/prompt.js +1421 -0
- package/templates/relationship/new/controller.ejs.t +36 -0
- package/templates/relationship/new/dto/create.ejs.t +41 -0
- package/templates/relationship/new/dto/output.ejs.t +44 -0
- package/templates/relationship/new/dto/update.ejs.t +10 -0
- package/templates/relationship/new/entity.ejs.t +98 -0
- package/templates/relationship/new/index.ejs.t +19 -0
- package/templates/relationship/new/module.ejs.t +35 -0
- package/templates/relationship/new/prompt.js +682 -0
- package/templates/relationship/new/repository.ejs.t +54 -0
- package/templates/relationship/new/service.ejs.t +31 -0
- package/templates/relationship/new/use-cases/declarative-queries.ejs.t +34 -0
- package/templates/relationship/new/use-cases/find-by-id.ejs.t +16 -0
- package/templates/relationship/new/use-cases/list.ejs.t +16 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: <%= outputPaths.module %>
|
|
3
|
+
skip_if: <%= !isCleanArchitecture %>
|
|
4
|
+
force: true
|
|
5
|
+
---
|
|
6
|
+
/**
|
|
7
|
+
* <%= classNamePlural %> Module
|
|
8
|
+
* Generated by entity codegen - do not edit directly
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { Module } from '@nestjs/common';
|
|
12
|
+
import { <%= repositoryToken %> } from '<%= imports.moduleToConstants %>';
|
|
13
|
+
import { <%= getByIdQueryClass %> } from '<%= imports.moduleToGetByIdQuery %>';
|
|
14
|
+
<% if (!exposeElectric) { -%>
|
|
15
|
+
import { <%= listQueryClass %> } from '<%= imports.moduleToListQuery %>';
|
|
16
|
+
<% } -%>
|
|
17
|
+
import { <%= createCommandClass %> } from '<%= imports.moduleToCreateCommand %>';
|
|
18
|
+
import { <%= deleteCommandClass %> } from '<%= imports.moduleToDeleteCommand %>';
|
|
19
|
+
import { <%= updateCommandClass %> } from '<%= imports.moduleToUpdateCommand %>';
|
|
20
|
+
import { DatabaseModule } from '<%= imports.moduleToDatabaseModule %>';
|
|
21
|
+
<% if (exposeElectric) { -%>
|
|
22
|
+
import { ElectricModule } from '<%= imports.moduleToElectricModule %>/electric.module';
|
|
23
|
+
<% } -%>
|
|
24
|
+
import { <%= className %>Repository } from '<%= imports.moduleToRepository %>';
|
|
25
|
+
<% if (hasDeclarativeQueries) { -%>
|
|
26
|
+
import { declarativeQueryClasses } from '<%= imports.moduleToDeclarativeQueries %>';
|
|
27
|
+
<% } -%>
|
|
28
|
+
<% if (exposeRest || exposeElectric) { -%>
|
|
29
|
+
import { <%= classNamePlural %>Controller } from '<%= imports.moduleToController %>';
|
|
30
|
+
<% } -%>
|
|
31
|
+
|
|
32
|
+
@Module({
|
|
33
|
+
imports: [DatabaseModule<%= exposeElectric ? ', ElectricModule' : '' %>],
|
|
34
|
+
<% if (exposeRest || exposeElectric) { -%>
|
|
35
|
+
controllers: [<%= classNamePlural %>Controller],
|
|
36
|
+
<% } -%>
|
|
37
|
+
providers: [
|
|
38
|
+
{ provide: <%= repositoryToken %>, useClass: <%= className %>Repository },
|
|
39
|
+
// Queries
|
|
40
|
+
<%= getByIdQueryClass %>,
|
|
41
|
+
<% if (!exposeElectric) { -%>
|
|
42
|
+
<%= listQueryClass %>,
|
|
43
|
+
<% } -%>
|
|
44
|
+
// Use Cases
|
|
45
|
+
<%= createCommandClass %>,
|
|
46
|
+
<%= updateCommandClass %>,
|
|
47
|
+
<%= deleteCommandClass %>,
|
|
48
|
+
<% if (hasDeclarativeQueries) { -%>
|
|
49
|
+
// Declarative queries
|
|
50
|
+
...declarativeQueryClasses,
|
|
51
|
+
<% } -%>
|
|
52
|
+
],
|
|
53
|
+
exports: [
|
|
54
|
+
<%= repositoryToken %>,
|
|
55
|
+
<%= getByIdQueryClass %>,
|
|
56
|
+
<% if (!exposeElectric) { -%>
|
|
57
|
+
<%= listQueryClass %>,
|
|
58
|
+
<% } -%>
|
|
59
|
+
<%= createCommandClass %>,
|
|
60
|
+
<%= updateCommandClass %>,
|
|
61
|
+
<%= deleteCommandClass %>,
|
|
62
|
+
<% if (hasDeclarativeQueries) { -%>
|
|
63
|
+
...declarativeQueryClasses,
|
|
64
|
+
<% } -%>
|
|
65
|
+
],
|
|
66
|
+
})
|
|
67
|
+
export class <%= classNamePlural %>Module {}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= exposeTrpc ? `${basePaths.backendSrc}/presentation/trpc/${plural}.router.ts` : '' %>"
|
|
3
|
+
skip_if: <%= !isCleanArchitecture %>
|
|
4
|
+
force: true
|
|
5
|
+
---
|
|
6
|
+
<% if (exposeTrpc) { -%>
|
|
7
|
+
/**
|
|
8
|
+
* <%= classNamePlural %> tRPC Router
|
|
9
|
+
* Generated by entity codegen - do not edit directly
|
|
10
|
+
*
|
|
11
|
+
* Add this router to TrpcModule providers:
|
|
12
|
+
* providers: [..., <%= classNamePlural %>Router],
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { Injectable } from '@nestjs/common';
|
|
16
|
+
import { Router, Query, Mutation, Input } from '@mguay/nestjs-trpc';
|
|
17
|
+
import { z } from 'zod';
|
|
18
|
+
import {
|
|
19
|
+
create<%= className %>Schema,
|
|
20
|
+
update<%= className %>Schema,
|
|
21
|
+
} from '<%= imports.controllerToSchemas %>';
|
|
22
|
+
import { <%= getByIdQueryClass %> } from '<%= imports.controllerToGetByIdQuery %>';
|
|
23
|
+
import { <%= listQueryClass %> } from '<%= imports.controllerToListQuery %>';
|
|
24
|
+
import { <%= createCommandClass %> } from '<%= imports.controllerToCreateCommand %>';
|
|
25
|
+
import { <%= updateCommandClass %> } from '<%= imports.controllerToUpdateCommand %>';
|
|
26
|
+
import { <%= deleteCommandClass %> } from '<%= imports.controllerToDeleteCommand %>';
|
|
27
|
+
|
|
28
|
+
@Injectable()
|
|
29
|
+
@Router({ alias: '<%= plural %>' })
|
|
30
|
+
export class <%= classNamePlural %>Router {
|
|
31
|
+
constructor(
|
|
32
|
+
private readonly get<%= className %>ById: <%= getByIdQueryClass %>,
|
|
33
|
+
private readonly list<%= classNamePlural %>: <%= listQueryClass %>,
|
|
34
|
+
private readonly create<%= className %>: <%= createCommandClass %>,
|
|
35
|
+
private readonly update<%= className %>: <%= updateCommandClass %>,
|
|
36
|
+
private readonly delete<%= className %>: <%= deleteCommandClass %>,
|
|
37
|
+
) {}
|
|
38
|
+
|
|
39
|
+
@Query()
|
|
40
|
+
async list() {
|
|
41
|
+
return this.list<%= classNamePlural %>.execute();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@Query({ input: z.object({ id: z.string().uuid() }) })
|
|
45
|
+
async getById(@Input('id') id: string) {
|
|
46
|
+
return this.get<%= className %>ById.execute(id);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@Mutation({ input: create<%= className %>Schema })
|
|
50
|
+
async create(@Input() input: z.infer<typeof create<%= className %>Schema>) {
|
|
51
|
+
return this.create<%= className %>.execute(input);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@Mutation({ input: z.object({ id: z.string().uuid(), data: update<%= className %>Schema }) })
|
|
55
|
+
async update(
|
|
56
|
+
@Input('id') id: string,
|
|
57
|
+
@Input('data') data: z.infer<typeof update<%= className %>Schema>,
|
|
58
|
+
) {
|
|
59
|
+
return this.update<%= className %>.execute(id, data);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@Mutation({ input: z.object({ id: z.string().uuid() }) })
|
|
63
|
+
async delete(@Input('id') id: string) {
|
|
64
|
+
return this.delete<%= className %>.execute(id);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
<% } -%>
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= (exposeRest || exposeElectric) ? `${basePaths.backendSrc}/${paths.controllers}/${plural}.controller.ts` : '' %>"
|
|
3
|
+
skip_if: <%= !isCleanArchitecture %>
|
|
4
|
+
force: true
|
|
5
|
+
---
|
|
6
|
+
<% if (exposeRest) { -%>
|
|
7
|
+
/**
|
|
8
|
+
* <%= classNamePlural %> Controller
|
|
9
|
+
* Generated by entity codegen - do not edit directly
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
Body,
|
|
14
|
+
Controller,
|
|
15
|
+
Delete,
|
|
16
|
+
Get,
|
|
17
|
+
Param,
|
|
18
|
+
ParseUUIDPipe,
|
|
19
|
+
Post,
|
|
20
|
+
Put,
|
|
21
|
+
<% if (hasRelationships) { -%>
|
|
22
|
+
Query,
|
|
23
|
+
<% } -%>
|
|
24
|
+
UsePipes,
|
|
25
|
+
} from '@nestjs/common';
|
|
26
|
+
import { <%= getByIdQueryClass %> } from '<%= imports.controllerToGetByIdQuery %>';
|
|
27
|
+
import { <%= listQueryClass %> } from '<%= imports.controllerToListQuery %>';
|
|
28
|
+
import {
|
|
29
|
+
type Create<%= className %>Dto,
|
|
30
|
+
create<%= className %>Schema,
|
|
31
|
+
type Update<%= className %>Dto,
|
|
32
|
+
update<%= className %>Schema,
|
|
33
|
+
} from '<%= imports.controllerToSchemas %>';
|
|
34
|
+
import { <%= createCommandClass %> } from '<%= imports.controllerToCreateCommand %>';
|
|
35
|
+
import { <%= deleteCommandClass %> } from '<%= imports.controllerToDeleteCommand %>';
|
|
36
|
+
import { <%= updateCommandClass %> } from '<%= imports.controllerToUpdateCommand %>';
|
|
37
|
+
import { ZodValidationPipe } from '../../core/pipes/zod-validation.pipe';
|
|
38
|
+
import { <%= className %> } from '<%= imports.controllerToDomain %>';
|
|
39
|
+
<% if (hasRelationships) { -%>
|
|
40
|
+
import type { <%= className %>With } from '<%= imports.controllerToDomain %>';
|
|
41
|
+
<% } -%>
|
|
42
|
+
|
|
43
|
+
@Controller('<%= plural %>')
|
|
44
|
+
export class <%= classNamePlural %>Controller {
|
|
45
|
+
constructor(
|
|
46
|
+
private readonly get<%= className %>ByIdQuery: <%= getByIdQueryClass %>,
|
|
47
|
+
private readonly list<%= classNamePlural %>Query: <%= listQueryClass %>,
|
|
48
|
+
private readonly create<%= className %>Command: <%= createCommandClass %>,
|
|
49
|
+
private readonly update<%= className %>Command: <%= updateCommandClass %>,
|
|
50
|
+
private readonly delete<%= className %>Command: <%= deleteCommandClass %>,
|
|
51
|
+
) {}
|
|
52
|
+
|
|
53
|
+
@Get()
|
|
54
|
+
async findAll(<%- hasRelationships ? `@Query('include') include?: string` : '' %>): Promise<<%= className %>[]> {
|
|
55
|
+
<% if (hasRelationships) { -%>
|
|
56
|
+
return this.list<%= classNamePlural %>Query.execute(this.parseInclude(include));
|
|
57
|
+
<% } else { -%>
|
|
58
|
+
return this.list<%= classNamePlural %>Query.execute();
|
|
59
|
+
<% } -%>
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@Get(':id')
|
|
63
|
+
async findById(
|
|
64
|
+
@Param('id', ParseUUIDPipe) id: string,
|
|
65
|
+
<% if (hasRelationships) { -%>
|
|
66
|
+
@Query('include') include?: string,
|
|
67
|
+
<% } -%>
|
|
68
|
+
): Promise<<%= className %>> {
|
|
69
|
+
<% if (hasRelationships) { -%>
|
|
70
|
+
return this.get<%= className %>ByIdQuery.execute(id, this.parseInclude(include));
|
|
71
|
+
<% } else { -%>
|
|
72
|
+
return this.get<%= className %>ByIdQuery.execute(id);
|
|
73
|
+
<% } -%>
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@Post()
|
|
77
|
+
@UsePipes(new ZodValidationPipe(create<%= className %>Schema))
|
|
78
|
+
async create(@Body() dto: Create<%= className %>Dto): Promise<<%= className %>> {
|
|
79
|
+
return this.create<%= className %>Command.execute(dto);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@Put(':id')
|
|
83
|
+
async update(
|
|
84
|
+
@Param('id', ParseUUIDPipe) id: string,
|
|
85
|
+
@Body(new ZodValidationPipe(update<%= className %>Schema)) dto: Update<%= className %>Dto,
|
|
86
|
+
): Promise<<%= className %>> {
|
|
87
|
+
return this.update<%= className %>Command.execute(id, dto);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@Delete(':id')
|
|
91
|
+
async delete(@Param('id', ParseUUIDPipe) id: string): Promise<<%= className %>> {
|
|
92
|
+
return this.delete<%= className %>Command.execute(id);
|
|
93
|
+
}
|
|
94
|
+
<% if (hasRelationships) { -%>
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Parse comma-separated include query param into typed options.
|
|
98
|
+
* Example: ?include=account,owner → { account: true, owner: true }
|
|
99
|
+
*/
|
|
100
|
+
private parseInclude(include?: string): <%= className %>With | undefined {
|
|
101
|
+
if (!include) return undefined;
|
|
102
|
+
const parts = include.split(',').map((s) => s.trim());
|
|
103
|
+
return {
|
|
104
|
+
<% relationships.forEach((rel) => { -%>
|
|
105
|
+
<%= rel.name %>: parts.includes('<%= rel.name %>'),
|
|
106
|
+
<% }) -%>
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
<% } -%>
|
|
110
|
+
}
|
|
111
|
+
<% } -%>
|
|
112
|
+
<% if (exposeElectric) { -%>
|
|
113
|
+
/**
|
|
114
|
+
* <%= classNamePlural %> Controller (Electric SQL)
|
|
115
|
+
* Generated by entity codegen - do not edit directly
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
import {
|
|
119
|
+
Controller,
|
|
120
|
+
Get,
|
|
121
|
+
Body,
|
|
122
|
+
Delete,
|
|
123
|
+
Param,
|
|
124
|
+
ParseUUIDPipe,
|
|
125
|
+
Post,
|
|
126
|
+
Put,
|
|
127
|
+
Req,
|
|
128
|
+
Res,
|
|
129
|
+
UseGuards,
|
|
130
|
+
UsePipes,
|
|
131
|
+
} from '@nestjs/common';
|
|
132
|
+
import type { Request, Response } from 'express';
|
|
133
|
+
import { AuthGuard } from '<%= imports.controllerToAuthGuard %>/auth.guard';
|
|
134
|
+
import { CurrentUser } from '<%= imports.controllerToCurrentUser %>/current-user.decorator';
|
|
135
|
+
import { User } from '<%= imports.controllerToDomain %>/user';
|
|
136
|
+
import { ElectricService } from '<%= imports.controllerToElectricService %>/electric.service';
|
|
137
|
+
import { <%= plural %>Columns } from '<%= locations.dbSchemaClient.import %>';
|
|
138
|
+
import {
|
|
139
|
+
type Create<%= className %>Dto,
|
|
140
|
+
create<%= className %>Schema,
|
|
141
|
+
type Update<%= className %>Dto,
|
|
142
|
+
update<%= className %>Schema,
|
|
143
|
+
} from '<%= imports.controllerToSchemas %>';
|
|
144
|
+
import { <%= createCommandClass %> } from '<%= imports.controllerToCreateCommand %>';
|
|
145
|
+
import { <%= deleteCommandClass %> } from '<%= imports.controllerToDeleteCommand %>';
|
|
146
|
+
import { <%= updateCommandClass %> } from '<%= imports.controllerToUpdateCommand %>';
|
|
147
|
+
import { <%= getByIdQueryClass %> } from '<%= imports.controllerToGetByIdQuery %>';
|
|
148
|
+
import { ZodValidationPipe } from '../../core/pipes/zod-validation.pipe';
|
|
149
|
+
import { <%= className %> } from '<%= imports.controllerToDomain %>';
|
|
150
|
+
|
|
151
|
+
@Controller('<%= plural %>')
|
|
152
|
+
@UseGuards(AuthGuard)
|
|
153
|
+
export class <%= classNamePlural %>Controller {
|
|
154
|
+
constructor(
|
|
155
|
+
private readonly electricService: ElectricService,
|
|
156
|
+
private readonly get<%= className %>ByIdQuery: <%= getByIdQueryClass %>,
|
|
157
|
+
private readonly create<%= className %>Command: <%= createCommandClass %>,
|
|
158
|
+
private readonly update<%= className %>Command: <%= updateCommandClass %>,
|
|
159
|
+
private readonly delete<%= className %>Command: <%= deleteCommandClass %>,
|
|
160
|
+
) {}
|
|
161
|
+
|
|
162
|
+
@Get()
|
|
163
|
+
async findAll(
|
|
164
|
+
@CurrentUser() user: User,
|
|
165
|
+
@Req() req: Request,
|
|
166
|
+
@Res() res: Response,
|
|
167
|
+
): Promise<void> {
|
|
168
|
+
return this.electricService.proxyRequest({
|
|
169
|
+
req,
|
|
170
|
+
res,
|
|
171
|
+
table: '<%= table %>',
|
|
172
|
+
columns: <%= plural %>Columns,
|
|
173
|
+
where: `"<%= electricWhereColumn %>" = '${<%= electricWhereValue %>}'`,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
@Get(':id')
|
|
178
|
+
async findById(@Param('id', ParseUUIDPipe) id: string): Promise<<%= className %>> {
|
|
179
|
+
return this.get<%= className %>ByIdQuery.execute(id);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@Post()
|
|
183
|
+
@UsePipes(new ZodValidationPipe(create<%= className %>Schema))
|
|
184
|
+
async create(@Body() dto: Create<%= className %>Dto): Promise<<%= className %>> {
|
|
185
|
+
return this.create<%= className %>Command.execute(dto);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
@Put(':id')
|
|
189
|
+
async update(
|
|
190
|
+
@Param('id', ParseUUIDPipe) id: string,
|
|
191
|
+
@Body(new ZodValidationPipe(update<%= className %>Schema)) dto: Update<%= className %>Dto,
|
|
192
|
+
): Promise<<%= className %>> {
|
|
193
|
+
return this.update<%= className %>Command.execute(id, dto);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
@Delete(':id')
|
|
197
|
+
async delete(@Param('id', ParseUUIDPipe) id: string): Promise<<%= className %>> {
|
|
198
|
+
return this.delete<%= className %>Command.execute(id);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
<% } -%>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= typeof clpOutputPaths !== 'undefined' ? clpOutputPaths.controller : null %>"
|
|
3
|
+
skip_if: "<%= typeof clpOutputPaths === 'undefined' %>"
|
|
4
|
+
force: true
|
|
5
|
+
---
|
|
6
|
+
import { Controller, Get, Param } from '@nestjs/common';
|
|
7
|
+
import { <%= classNames.findByIdUseCase %> } from './use-cases/find-<%= entityName %>-by-id.use-case';
|
|
8
|
+
import { <%= classNames.listUseCase %> } from './use-cases/list-<%= entityNamePlural %>.use-case';
|
|
9
|
+
import type { <%= classNames.entity %> } from './<%= entityName %>.entity';
|
|
10
|
+
// Write use cases must be hand-written. Import them here when ready.
|
|
11
|
+
|
|
12
|
+
@Controller('<%= entityNamePlural %>')
|
|
13
|
+
export class <%= classNames.controller %> {
|
|
14
|
+
constructor(
|
|
15
|
+
// All routes go through use cases (ADR-003 — no controller → service shortcuts)
|
|
16
|
+
private readonly findByIdUseCase: <%= classNames.findByIdUseCase %>,
|
|
17
|
+
private readonly listUseCase: <%= classNames.listUseCase %>,
|
|
18
|
+
// TODO: inject hand-written write use cases here
|
|
19
|
+
) {}
|
|
20
|
+
|
|
21
|
+
@Get()
|
|
22
|
+
async getAll(): Promise<<%= classNames.entity %>[]> {
|
|
23
|
+
return this.listUseCase.execute();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@Get(':id')
|
|
27
|
+
async getById(@Param('id') id: string): Promise<<%= classNames.entity %> | null> {
|
|
28
|
+
return this.findByIdUseCase.execute(id);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// TODO: Add write routes. Each must call a hand-written use case, not the service.
|
|
32
|
+
// Example:
|
|
33
|
+
// @Post()
|
|
34
|
+
// async create(@Body() dto: Create<%= classNames.entity %>Dto): Promise<<%= classNames.entity %>> {
|
|
35
|
+
// return this.createUseCase.execute(dto);
|
|
36
|
+
// }
|
|
37
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= typeof clpOutputPaths !== 'undefined' ? clpOutputPaths.createDto : null %>"
|
|
3
|
+
skip_if: "<%= typeof clpOutputPaths === 'undefined' %>"
|
|
4
|
+
force: true
|
|
5
|
+
---
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
|
|
8
|
+
export const <%= classNames.createSchema %> = z.object({
|
|
9
|
+
<%_ clpBelongsToFkFields.forEach(fk => { _%>
|
|
10
|
+
<%= fk.camelName %>: <%- fk.zodChainCreate %>,
|
|
11
|
+
<%_ }) _%>
|
|
12
|
+
<%_ clpCreateDtoFields.forEach(field => { _%>
|
|
13
|
+
<%= field.camelName %>: <%- field.zodChainCreate %>,
|
|
14
|
+
<%_ }) _%>
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export type <%= classNames.createDto %> = z.infer<typeof <%= classNames.createSchema %>>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= typeof clpOutputPaths !== 'undefined' ? clpOutputPaths.outputDto : null %>"
|
|
3
|
+
skip_if: "<%= typeof clpOutputPaths === 'undefined' %>"
|
|
4
|
+
force: true
|
|
5
|
+
---
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
|
|
8
|
+
export const <%= classNames.outputSchema %> = z.object({
|
|
9
|
+
id: z.string().uuid(),
|
|
10
|
+
<%_ clpBelongsToFkFields.forEach(fk => { _%>
|
|
11
|
+
<%= fk.camelName %>: <%- fk.zodChainOutput %>,
|
|
12
|
+
<%_ }) _%>
|
|
13
|
+
<%_ clpOutputDtoFields.forEach(field => { _%>
|
|
14
|
+
<%= field.camelName %>: <%- field.zodChainOutput %>,
|
|
15
|
+
<%_ }) _%>
|
|
16
|
+
<%_ if (hasTimestamps) { _%>
|
|
17
|
+
createdAt: z.coerce.date(),
|
|
18
|
+
updatedAt: z.coerce.date(),
|
|
19
|
+
<%_ } _%>
|
|
20
|
+
<%_ if (hasSoftDelete) { _%>
|
|
21
|
+
deletedAt: z.coerce.date().nullable(),
|
|
22
|
+
<%_ } _%>
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export type <%= classNames.outputDto %> = z.infer<typeof <%= classNames.outputSchema %>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= typeof clpOutputPaths !== 'undefined' ? clpOutputPaths.updateDto : null %>"
|
|
3
|
+
skip_if: "<%= typeof clpOutputPaths === 'undefined' %>"
|
|
4
|
+
force: true
|
|
5
|
+
---
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { <%= classNames.createSchema %> } from './create-<%= entityName %>.dto';
|
|
8
|
+
|
|
9
|
+
export const <%= classNames.updateSchema %> = <%= classNames.createSchema %>.partial();
|
|
10
|
+
|
|
11
|
+
export type <%= classNames.updateDto %> = z.infer<typeof <%= classNames.updateSchema %>>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= typeof clpOutputPaths !== 'undefined' ? clpOutputPaths.entity : null %>"
|
|
3
|
+
skip_if: "<%= typeof clpOutputPaths === 'undefined' %>"
|
|
4
|
+
force: true
|
|
5
|
+
---
|
|
6
|
+
import {
|
|
7
|
+
<%_ clpDrizzleImports.filter(i => i !== 'relations').forEach(i => { _%>
|
|
8
|
+
<%= i %>,
|
|
9
|
+
<%_ }) _%>
|
|
10
|
+
} from 'drizzle-orm/pg-core';
|
|
11
|
+
<%_ if (clpHasRelationsBlock) { _%>
|
|
12
|
+
import { relations, type InferSelectModel } from 'drizzle-orm';
|
|
13
|
+
<%_ } else { _%>
|
|
14
|
+
import { type InferSelectModel } from 'drizzle-orm';
|
|
15
|
+
<%_ } _%>
|
|
16
|
+
<%_ clpBelongsTo.forEach(rel => { _%>
|
|
17
|
+
import { <%= rel.relatedTable %> } from '<%= rel.importPath %>';
|
|
18
|
+
<%_ }) _%>
|
|
19
|
+
|
|
20
|
+
export const <%= entityNamePlural %> = pgTable(
|
|
21
|
+
'<%= entityNamePlural %>',
|
|
22
|
+
{
|
|
23
|
+
id: uuid('id').primaryKey().defaultRandom(),
|
|
24
|
+
<%_ clpBelongsTo.forEach(rel => { _%>
|
|
25
|
+
<%= rel.camelField %>: uuid('<%= rel.field %>')<%= rel.nullable ? '' : '.notNull()' %>,
|
|
26
|
+
<%_ }) _%>
|
|
27
|
+
<%_ clpProcessedFields.forEach(field => { _%>
|
|
28
|
+
<%= field.camelName %>: <%- field.drizzleChain %>,
|
|
29
|
+
<%_ }) _%>
|
|
30
|
+
<%_ if (hasTimestamps) { _%>
|
|
31
|
+
createdAt: timestamp('created_at').notNull().defaultNow(),
|
|
32
|
+
updatedAt: timestamp('updated_at').notNull().defaultNow(),
|
|
33
|
+
<%_ } _%>
|
|
34
|
+
<%_ if (hasSoftDelete) { _%>
|
|
35
|
+
deletedAt: timestamp('deleted_at'),
|
|
36
|
+
<%_ } _%>
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
<%_ if (clpHasRelationsBlock) { _%>
|
|
40
|
+
|
|
41
|
+
export const <%= entityNamePlural %>Relations = relations(<%= entityNamePlural %>, ({ one }) => ({
|
|
42
|
+
<%_ clpBelongsTo.forEach(rel => { _%>
|
|
43
|
+
<%= rel.relatedEntity %>: one(<%= rel.relatedTable %>, {
|
|
44
|
+
fields: [<%= entityNamePlural %>.<%= rel.camelField %>],
|
|
45
|
+
references: [<%= rel.relatedTable %>.id],
|
|
46
|
+
}),
|
|
47
|
+
<%_ }) _%>
|
|
48
|
+
}));
|
|
49
|
+
<%_ } _%>
|
|
50
|
+
|
|
51
|
+
export type <%= classNames.entity %> = InferSelectModel<typeof <%= entityNamePlural %>>;
|
|
52
|
+
export type <%= classNames.entity %>Insert = typeof <%= entityNamePlural %>.$inferInsert;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= typeof clpOutputPaths !== 'undefined' ? `modules/${entityNamePlural}/index.ts` : null %>"
|
|
3
|
+
skip_if: "<%= typeof clpOutputPaths === 'undefined' %>"
|
|
4
|
+
force: true
|
|
5
|
+
---
|
|
6
|
+
/**
|
|
7
|
+
* <%= classNames.entity %> module barrel export
|
|
8
|
+
* Generated by entity codegen - do not edit directly
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// Value exports (module, service, controller)
|
|
12
|
+
export { <%= classNames.module %> } from './<%= entityNamePlural %>.module';
|
|
13
|
+
export { <%= classNames.service %> } from './<%= entityName %>.service';
|
|
14
|
+
export { <%= classNames.controller %> } from './<%= entityName %>.controller';
|
|
15
|
+
|
|
16
|
+
// Type-only exports (entity, DTOs)
|
|
17
|
+
export type { <%= classNames.entity %> } from './<%= entityName %>.entity';
|
|
18
|
+
export type { <%= classNames.createDto %> } from './dto/create-<%= entityName %>.dto';
|
|
19
|
+
export type { <%= classNames.updateDto %> } from './dto/update-<%= entityName %>.dto';
|
|
20
|
+
export type { <%= classNames.outputDto %> } from './dto/<%= entityName %>-output.dto';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= typeof clpOutputPaths !== 'undefined' ? clpOutputPaths.module : null %>"
|
|
3
|
+
skip_if: "<%= typeof clpOutputPaths === 'undefined' %>"
|
|
4
|
+
force: true
|
|
5
|
+
---
|
|
6
|
+
import { Module } from '@nestjs/common';
|
|
7
|
+
import { DatabaseModule } from '@shared/database/database.module';
|
|
8
|
+
<%_ clpBelongsTo.forEach(rel => { _%>
|
|
9
|
+
// import { <%= rel.relatedEntityPascal %>sModule } from '../<%= rel.relatedPlural %>/<%= rel.relatedPlural %>.module';
|
|
10
|
+
<%_ }) _%>
|
|
11
|
+
|
|
12
|
+
import { <%= classNames.repository %> } from './<%= entityName %>.repository';
|
|
13
|
+
import { <%= classNames.service %> } from './<%= entityName %>.service';
|
|
14
|
+
import { <%= classNames.controller %> } from './<%= entityName %>.controller';
|
|
15
|
+
import { <%= classNames.findByIdUseCase %> } from './use-cases/find-<%= entityName %>-by-id.use-case';
|
|
16
|
+
import { <%= classNames.listUseCase %> } from './use-cases/list-<%= entityNamePlural %>.use-case';
|
|
17
|
+
<% if (hasDeclarativeQueries) { -%>
|
|
18
|
+
import { declarativeQueryClasses } from './use-cases/declarative-queries';
|
|
19
|
+
<% } -%>
|
|
20
|
+
|
|
21
|
+
@Module({
|
|
22
|
+
imports: [
|
|
23
|
+
DatabaseModule,
|
|
24
|
+
// TODO: Add subsystem modules as needed (EventsSubsystemModule, IntegrationsSubsystemModule, etc.)
|
|
25
|
+
// Cross-domain modules from relationships:
|
|
26
|
+
<%_ clpBelongsTo.forEach(rel => { _%>
|
|
27
|
+
// <%= rel.relatedEntityPascal %>sModule,
|
|
28
|
+
<%_ }) _%>
|
|
29
|
+
],
|
|
30
|
+
controllers: [<%= classNames.controller %>],
|
|
31
|
+
providers: [
|
|
32
|
+
<%= classNames.repository %>,
|
|
33
|
+
<%= classNames.service %>,
|
|
34
|
+
<%= classNames.findByIdUseCase %>,
|
|
35
|
+
<%= classNames.listUseCase %>,
|
|
36
|
+
<% if (hasDeclarativeQueries) { -%>
|
|
37
|
+
...declarativeQueryClasses,
|
|
38
|
+
<% } -%>
|
|
39
|
+
// TODO: Register hand-written use cases here
|
|
40
|
+
],
|
|
41
|
+
exports: [<%= classNames.service %>], // Only service is exported (ADR-002)
|
|
42
|
+
})
|
|
43
|
+
export class <%= classNames.module %> {}
|