@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,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= typeof clpOutputPaths !== 'undefined' ? clpOutputPaths.service : null %>"
|
|
3
|
+
skip_if: "<%= typeof clpOutputPaths === 'undefined' %>"
|
|
4
|
+
force: true
|
|
5
|
+
---
|
|
6
|
+
import { Injectable, Inject, Optional } from '@nestjs/common';
|
|
7
|
+
import { WithAnalytics } from '@shared/base-classes/with-analytics';
|
|
8
|
+
import { EVENT_BUS } from '@shared/constants/tokens';
|
|
9
|
+
import { <%= serviceBaseClass %> } from '<%= serviceBaseImport %>';
|
|
10
|
+
import { <%= classNames.repository %> } from './<%= entityName %>.repository';
|
|
11
|
+
import type { <%= classNames.entity %> } from './<%= entityName %>.entity';
|
|
12
|
+
|
|
13
|
+
@Injectable()
|
|
14
|
+
export class <%= classNames.service %> extends WithAnalytics(
|
|
15
|
+
<%= serviceBaseClass %><<%= classNames.repository %>, <%= classNames.entity %>>,
|
|
16
|
+
) {
|
|
17
|
+
protected override readonly entityName = '<%= entityName %>';
|
|
18
|
+
|
|
19
|
+
/** Injected by NestJS when EventsModule is registered. */
|
|
20
|
+
@Optional() @Inject(EVENT_BUS)
|
|
21
|
+
protected override eventBus: any = undefined;
|
|
22
|
+
|
|
23
|
+
constructor(protected readonly repository: <%= classNames.repository %>) {
|
|
24
|
+
super(repository);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Lifecycle events (created/updated/deleted + per-field changes) are emitted
|
|
28
|
+
// automatically by BaseService when the events subsystem is installed.
|
|
29
|
+
//
|
|
30
|
+
// Inherited from <%= serviceBaseClass %>:
|
|
31
|
+
<%_ serviceInheritedMethods.forEach(line => { _%>
|
|
32
|
+
// <%= line %>
|
|
33
|
+
<%_ }) _%>
|
|
34
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= (typeof clpOutputPaths !== 'undefined' && hasDeclarativeQueries) ? clpOutputPaths.declarativeQueries : null %>"
|
|
3
|
+
force: true
|
|
4
|
+
---
|
|
5
|
+
<% if (hasDeclarativeQueries) { -%>
|
|
6
|
+
/**
|
|
7
|
+
* Declarative Query Use Cases for <%= classNames.entity %>
|
|
8
|
+
* Generated from queries: block in entity YAML — do not edit directly.
|
|
9
|
+
*
|
|
10
|
+
* Each query is an injectable use case class that delegates to the repository.
|
|
11
|
+
* Register all via `declarativeQueryClasses` in the module providers.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { Injectable } from '@nestjs/common';
|
|
15
|
+
import { <%= classNames.repository %> } from '../<%= entityName %>.repository';
|
|
16
|
+
import type { <%= classNames.entity %> } from '../<%= entityName %>.entity';
|
|
17
|
+
|
|
18
|
+
<% processedQueries.forEach((q) => { -%>
|
|
19
|
+
@Injectable()
|
|
20
|
+
export class <%= q.useCaseClassName %> {
|
|
21
|
+
constructor(private readonly repository: <%= classNames.repository %>) {}
|
|
22
|
+
|
|
23
|
+
async execute(<%- q.params.map(p => `${p.camelName}: ${p.tsType}`).join(', ') %>): Promise<<%- q.returnType %>> {
|
|
24
|
+
return this.repository.<%= q.methodName %>(<%= q.params.map(p => p.camelName).join(', ') %>);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
<% }) -%>
|
|
29
|
+
export const declarativeQueryClasses = [
|
|
30
|
+
<% processedQueries.forEach((q) => { -%>
|
|
31
|
+
<%= q.useCaseClassName %>,
|
|
32
|
+
<% }) -%>
|
|
33
|
+
];
|
|
34
|
+
<% } -%>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= typeof clpOutputPaths !== 'undefined' ? clpOutputPaths.findByIdUseCase : null %>"
|
|
3
|
+
force: true
|
|
4
|
+
---
|
|
5
|
+
import { Injectable } from '@nestjs/common';
|
|
6
|
+
import { <%= classNames.service %> } from '../<%= entityName %>.service';
|
|
7
|
+
import type { <%= classNames.entity %> } from '../<%= entityName %>.entity';
|
|
8
|
+
|
|
9
|
+
@Injectable()
|
|
10
|
+
export class <%= classNames.findByIdUseCase %> {
|
|
11
|
+
constructor(private readonly service: <%= classNames.service %>) {}
|
|
12
|
+
|
|
13
|
+
async execute(id: string): Promise<<%= classNames.entity %> | null> {
|
|
14
|
+
return this.service.findById(id);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= typeof clpOutputPaths !== 'undefined' ? clpOutputPaths.listUseCase : null %>"
|
|
3
|
+
force: true
|
|
4
|
+
---
|
|
5
|
+
import { Injectable } from '@nestjs/common';
|
|
6
|
+
import { <%= classNames.service %> } from '../<%= entityName %>.service';
|
|
7
|
+
import type { <%= classNames.entity %> } from '../<%= entityName %>.entity';
|
|
8
|
+
|
|
9
|
+
@Injectable()
|
|
10
|
+
export class <%= classNames.listUseCase %> {
|
|
11
|
+
constructor(private readonly service: <%= classNames.service %>) {}
|
|
12
|
+
|
|
13
|
+
async execute(): Promise<<%= classNames.entity %>[]> {
|
|
14
|
+
return this.service.list();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= frontendEnabled ? (generate.collections ? `${locations.frontendCollections.path}/collections.ts` : '') : '' %>"
|
|
3
|
+
inject: true
|
|
4
|
+
append: true
|
|
5
|
+
skip_if: "// Codegen collections"
|
|
6
|
+
---
|
|
7
|
+
<% if (generate.collections) { -%>
|
|
8
|
+
|
|
9
|
+
// Codegen collections
|
|
10
|
+
<% } -%>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= frontendEnabled ? (generate.collectionsIndex ? `${locations.frontendCollections.path}/index.ts` : '') : '' %>"
|
|
3
|
+
inject: true
|
|
4
|
+
after: "// Generated entity collections"
|
|
5
|
+
skip_if: "from './collections'"
|
|
6
|
+
---
|
|
7
|
+
<% if (generate.collectionsIndex) { -%>
|
|
8
|
+
export * from './collections';
|
|
9
|
+
<% } -%>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= frontendEnabled ? (generate.collections && !frontend.collections?.schemaPrefix ? `${locations.frontendCollections.path}/collections.ts` : '') : '' %>"
|
|
3
|
+
inject: true
|
|
4
|
+
after: "// Codegen schema imports"
|
|
5
|
+
skip_if: <%= camelName %>Schema
|
|
6
|
+
---
|
|
7
|
+
<% if (generate.collections && !frontend.collections?.schemaPrefix) { -%>
|
|
8
|
+
<%= camelName %>Schema,
|
|
9
|
+
<% } -%>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= frontendEnabled ? (generate.collections ? `${locations.frontendCollections.path}/collections.ts` : '') : '' %>"
|
|
3
|
+
inject: true
|
|
4
|
+
after: "// Codegen collections"
|
|
5
|
+
skip_if: <%= camelName %>Collection
|
|
6
|
+
---
|
|
7
|
+
<% if (generate.collections) { -%>
|
|
8
|
+
<%
|
|
9
|
+
// Determine the URL expression based on config
|
|
10
|
+
const hasApiBaseUrl = !!frontend.sync.apiBaseUrlImport;
|
|
11
|
+
// For the URL path, use API_BASE_URL if configured
|
|
12
|
+
const shapeUrlExpr = hasApiBaseUrl
|
|
13
|
+
? '`${API_BASE_URL}/' + plural + '`'
|
|
14
|
+
: '`' + frontend.sync.shapeUrl + '/' + plural + '`';
|
|
15
|
+
-%>
|
|
16
|
+
export const <%= camelName %>Collection = createCollection(
|
|
17
|
+
electricCollectionOptions({
|
|
18
|
+
id: '<%= plural %>',
|
|
19
|
+
shapeOptions: {
|
|
20
|
+
<% if (frontend.sync.useTableParam) { -%>
|
|
21
|
+
url: new URL(
|
|
22
|
+
'<%= frontend.sync.shapeUrl %>',
|
|
23
|
+
window.location.origin,
|
|
24
|
+
).toString(),
|
|
25
|
+
params: {
|
|
26
|
+
table: '<%= plural %>',
|
|
27
|
+
},
|
|
28
|
+
<% } else { -%>
|
|
29
|
+
<% if (frontend.sync.wrapInUrlConstructor !== false) { -%>
|
|
30
|
+
url: new URL(
|
|
31
|
+
<%- shapeUrlExpr %>,
|
|
32
|
+
window.location.origin,
|
|
33
|
+
).toString(),
|
|
34
|
+
<% } else { -%>
|
|
35
|
+
url: <%- shapeUrlExpr %>,
|
|
36
|
+
<% } -%>
|
|
37
|
+
<% } -%>
|
|
38
|
+
<% if (frontend.auth.function) { -%>
|
|
39
|
+
headers: {
|
|
40
|
+
Authorization: <%= frontend.auth.function %>(),
|
|
41
|
+
},
|
|
42
|
+
<% } -%>
|
|
43
|
+
parser: {
|
|
44
|
+
<% Object.entries(frontend.parsers).forEach(([type, fn]) => { -%>
|
|
45
|
+
<%- type %>: <%- fn %>,
|
|
46
|
+
<% }); -%>
|
|
47
|
+
},
|
|
48
|
+
<% if (frontend.sync.columnMapper) { -%>
|
|
49
|
+
<% if (frontend.sync.columnMapperNeedsCall !== false) { -%>
|
|
50
|
+
columnMapper: <%= frontend.sync.columnMapper %>(),
|
|
51
|
+
<% } else { -%>
|
|
52
|
+
columnMapper: <%= frontend.sync.columnMapper %>,
|
|
53
|
+
<% } -%>
|
|
54
|
+
<% } -%>
|
|
55
|
+
},
|
|
56
|
+
<% const schemaPrefix = frontend.collections?.schemaPrefix ?? 'schema.'; -%>
|
|
57
|
+
schema: <%= schemaPrefix %><%= camelName %>Schema,
|
|
58
|
+
getKey: (item) => item.id,
|
|
59
|
+
}),
|
|
60
|
+
);
|
|
61
|
+
<% } -%>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: <%= locations.frontendCollections.path %>/collections.ts
|
|
3
|
+
skip_if: <%= !frontendEnabled %>
|
|
4
|
+
force: false
|
|
5
|
+
---
|
|
6
|
+
/**
|
|
7
|
+
* Electric SQL Collections
|
|
8
|
+
* Generated by entity codegen - do not edit directly
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { electricCollectionOptions } from '@tanstack/electric-db-collection';
|
|
12
|
+
import { createCollection } from '@tanstack/react-db';
|
|
13
|
+
<% if (frontend.sync.columnMapper) { -%>
|
|
14
|
+
import { <%= frontend.sync.columnMapper %> } from '@electric-sql/client';
|
|
15
|
+
<% } -%>
|
|
16
|
+
<% if (frontend.auth.function) { -%>
|
|
17
|
+
import { <%= frontend.auth.function %> } from '<%= locations.frontendCollectionsAuth.import %>';
|
|
18
|
+
<% } -%>
|
|
19
|
+
<% if (frontend.sync.apiBaseUrlImport) { -%>
|
|
20
|
+
import { API_BASE_URL } from '<%= frontend.sync.apiBaseUrlImport %>';
|
|
21
|
+
<% } -%>
|
|
22
|
+
import * as schema from '<%= locations.dbSchemaClient.import %>';
|
|
23
|
+
|
|
24
|
+
// Codegen collections
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: "<%= generate.structure === 'entity-first' ? `${locations.frontendGenerated.path}/${generate.fileNaming === 'plural' ? plural : name}/collection.ts` : generate.structure === 'concern-first' ? `${locations.frontendGenerated.path}/collections/${generate.fileNaming === 'plural' ? plural : name}.ts` : '' %>"
|
|
3
|
+
skip_if: <%= !frontendEnabled || (generate.structure === 'monolithic') %>
|
|
4
|
+
force: true
|
|
5
|
+
---
|
|
6
|
+
/**
|
|
7
|
+
* <%= className %> Collection
|
|
8
|
+
* Generated by entity codegen - do not edit directly
|
|
9
|
+
*
|
|
10
|
+
* Real-time synced collection using Electric SQL
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
<% if (frontend.sync.columnMapper) { -%>
|
|
14
|
+
import { <%= frontend.sync.columnMapper %> } from '@electric-sql/client';
|
|
15
|
+
<% } -%>
|
|
16
|
+
import { <%= camelName %>Schema } from '<%= locations.dbEntities.import %><% if (!locations.dbEntities.barrelExport) { %>/<%= name %><% } %>';
|
|
17
|
+
<% if (exposeTrpc) { -%>
|
|
18
|
+
import { trpc } from '<%= locations.trpcClient.import %>';
|
|
19
|
+
<% } -%>
|
|
20
|
+
import { electricCollectionOptions } from '@tanstack/electric-db-collection';
|
|
21
|
+
import { createCollection } from '@tanstack/react-db';
|
|
22
|
+
<% if (frontend.auth.function) { -%>
|
|
23
|
+
import { <%= frontend.auth.function %> } from '<%= locations.frontendCollectionsAuth.import %>';
|
|
24
|
+
<% } -%>
|
|
25
|
+
<% if (frontend.sync.apiBaseUrlImport) { -%>
|
|
26
|
+
import { API_BASE_URL } from '<%= frontend.sync.apiBaseUrlImport %>';
|
|
27
|
+
<% } -%>
|
|
28
|
+
<%
|
|
29
|
+
// Collection variable name depends on collectionNaming config
|
|
30
|
+
const collectionVar = generate.collectionNaming === 'plural' ? collectionVarNamePlural : collectionVarName;
|
|
31
|
+
// File name for imports depends on fileNaming config
|
|
32
|
+
const fileName = generate.fileNaming === 'plural' ? plural : name;
|
|
33
|
+
-%>
|
|
34
|
+
<% if (hasSoftDelete) { -%>
|
|
35
|
+
|
|
36
|
+
// TODO: Backend Electric shape endpoint should filter soft-deleted records
|
|
37
|
+
// by including WHERE deleted_at IS NULL in the shape configuration.
|
|
38
|
+
// Without this filter, soft-deleted records will reappear after Electric sync.
|
|
39
|
+
<% } -%>
|
|
40
|
+
|
|
41
|
+
export const <%= collectionVar %> = createCollection(
|
|
42
|
+
electricCollectionOptions({
|
|
43
|
+
id: '<%= plural %>',
|
|
44
|
+
shapeOptions: {
|
|
45
|
+
<% if (frontend.sync.useTableParam) { -%>
|
|
46
|
+
<% if (frontend.sync.wrapInUrlConstructor !== false) { -%>
|
|
47
|
+
url: new URL(
|
|
48
|
+
'<%= frontend.sync.shapeUrl %>',
|
|
49
|
+
typeof window !== 'undefined'
|
|
50
|
+
? window.location.origin
|
|
51
|
+
: 'http://localhost:5173',
|
|
52
|
+
).toString(),
|
|
53
|
+
<% } else { -%>
|
|
54
|
+
url: '<%= frontend.sync.shapeUrl %>',
|
|
55
|
+
<% } -%>
|
|
56
|
+
params: {
|
|
57
|
+
table: '<%= plural %>',
|
|
58
|
+
},
|
|
59
|
+
<% } else { -%>
|
|
60
|
+
<% if (frontend.sync.wrapInUrlConstructor !== false) { -%>
|
|
61
|
+
url: new URL(
|
|
62
|
+
`<%= frontend.sync.shapeUrl %>/<%= plural %>`,
|
|
63
|
+
typeof window !== 'undefined'
|
|
64
|
+
? window.location.origin
|
|
65
|
+
: 'http://localhost:5173',
|
|
66
|
+
).toString(),
|
|
67
|
+
<% } else { -%>
|
|
68
|
+
url: `<%= frontend.sync.shapeUrl %>/<%= plural %>`,
|
|
69
|
+
<% } -%>
|
|
70
|
+
<% } -%>
|
|
71
|
+
<% if (frontend.auth.function) { -%>
|
|
72
|
+
headers: {
|
|
73
|
+
Authorization: <%= frontend.auth.function %>(),
|
|
74
|
+
},
|
|
75
|
+
<% } -%>
|
|
76
|
+
parser: {
|
|
77
|
+
<% Object.entries(frontend.parsers).forEach(([type, fn]) => { -%>
|
|
78
|
+
<%- type %>: <%- fn %>,
|
|
79
|
+
<% }); -%>
|
|
80
|
+
},
|
|
81
|
+
<% if (frontend.sync.columnMapper) { -%>
|
|
82
|
+
<% if (frontend.sync.columnMapperNeedsCall !== false) { -%>
|
|
83
|
+
columnMapper: <%= frontend.sync.columnMapper %>(),
|
|
84
|
+
<% } else { -%>
|
|
85
|
+
columnMapper: <%= frontend.sync.columnMapper %>,
|
|
86
|
+
<% } -%>
|
|
87
|
+
<% } -%>
|
|
88
|
+
},
|
|
89
|
+
schema: <%= camelName %>Schema,
|
|
90
|
+
getKey: (item) => item.id,
|
|
91
|
+
<% if (generate.mutations && (exposeTrpc || exposeRepository)) { -%>
|
|
92
|
+
<% if (exposeTrpc) { -%>
|
|
93
|
+
onInsert: async ({ transaction }) => {
|
|
94
|
+
const { modified } = transaction.mutations[0];
|
|
95
|
+
const result = await trpc.<%= plural %>.create.mutate(modified);
|
|
96
|
+
return { txid: result.txid };
|
|
97
|
+
},
|
|
98
|
+
onUpdate: async ({ transaction }) => {
|
|
99
|
+
const { modified } = transaction.mutations[0];
|
|
100
|
+
const result = await trpc.<%= plural %>.update.mutate({ id: modified.id, data: modified });
|
|
101
|
+
return { txid: result.txid };
|
|
102
|
+
},
|
|
103
|
+
onDelete: async ({ transaction }) => {
|
|
104
|
+
const { original } = transaction.mutations[0];
|
|
105
|
+
const result = await trpc.<%= plural %>.delete.mutate({ id: original.id });
|
|
106
|
+
return { txid: result.txid };
|
|
107
|
+
},
|
|
108
|
+
<% } -%>
|
|
109
|
+
<% } -%>
|
|
110
|
+
}),
|
|
111
|
+
);
|
|
112
|
+
<%
|
|
113
|
+
// Collect unique belongs_to targets for imports (FK resolution)
|
|
114
|
+
// Only import if fkResolution is enabled (default: true)
|
|
115
|
+
const importedEntities = new Set();
|
|
116
|
+
if (generate.fkResolution !== false) {
|
|
117
|
+
existingBelongsTo.forEach((rel) => {
|
|
118
|
+
if (rel.target !== name) {
|
|
119
|
+
importedEntities.add(rel.target);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
-%>
|
|
124
|
+
<% if (importedEntities.size > 0) { -%>
|
|
125
|
+
|
|
126
|
+
// Import related collections for FK resolution
|
|
127
|
+
<% importedEntities.forEach((target) => {
|
|
128
|
+
const targetCamel = target.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
129
|
+
// Simple pluralization matching prompt.js pluralize function
|
|
130
|
+
const targetPlural = target.endsWith('y') ? target.slice(0, -1) + 'ies' :
|
|
131
|
+
(target.endsWith('s') || target.endsWith('x') || target.endsWith('ch') || target.endsWith('sh')) ? target + 'es' : target + 's';
|
|
132
|
+
const targetFileName = generate.fileNaming === 'plural' ? targetPlural : target;
|
|
133
|
+
const targetCamelPlural = targetCamel.endsWith('y') ? targetCamel.slice(0, -1) + 'ies' : targetCamel + 's';
|
|
134
|
+
-%>
|
|
135
|
+
import { <%= generate.collectionNaming === 'plural' ? targetCamelPlural : targetCamel %>Collection } from '<% if (generate.structure === 'entity-first') { %>./<%= targetFileName %>/collection<% } else { %>./<%= targetFileName %><% } %>';
|
|
136
|
+
<% }); -%>
|
|
137
|
+
<% } -%>
|
|
138
|
+
<% if (generate.structure === 'entity-first') { -%>
|
|
139
|
+
|
|
140
|
+
// Import types from sibling module
|
|
141
|
+
import type { <%= className %>, <%= className %>Resolved } from './types';
|
|
142
|
+
<% } else { -%>
|
|
143
|
+
|
|
144
|
+
// Import types
|
|
145
|
+
import type { <%= className %>, <%= className %>Resolved } from '<% if (generate.structure === 'concern-first') { %>../types/<%= fileName %><% } %>';
|
|
146
|
+
<% } -%>
|
|
147
|
+
|
|
148
|
+
// ============================================================================
|
|
149
|
+
// Resolution (FK lookup - internal use)
|
|
150
|
+
// ============================================================================
|
|
151
|
+
<% if (existingBelongsTo.length > 0 && generate.fkResolution !== false) { -%>
|
|
152
|
+
|
|
153
|
+
export function resolveRelations(entity: <%= className %>): <%= className %>Resolved {
|
|
154
|
+
return {
|
|
155
|
+
...entity,
|
|
156
|
+
<% existingBelongsTo.forEach((rel) => {
|
|
157
|
+
const targetCamel = rel.target.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
158
|
+
const targetCamelPlural = targetCamel.endsWith('y') ? targetCamel.slice(0, -1) + 'ies' : targetCamel + 's';
|
|
159
|
+
const targetCollectionVar = generate.collectionNaming === 'plural' ? targetCamelPlural : targetCamel;
|
|
160
|
+
-%>
|
|
161
|
+
<%= rel.name %>: entity.<%= rel.foreignKeyCamel %>
|
|
162
|
+
? <%= targetCollectionVar %>Collection.state.get(entity.<%= rel.foreignKeyCamel %>)
|
|
163
|
+
: undefined,
|
|
164
|
+
<% }); -%>
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
<% } else { -%>
|
|
168
|
+
|
|
169
|
+
export function resolveRelations(entity: <%= className %>): <%= className %>Resolved {
|
|
170
|
+
return entity;
|
|
171
|
+
}
|
|
172
|
+
<% } -%>
|