@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: src/infrastructure/broadcast/broadcast-bridge.listener.ts
|
|
3
|
+
force: true
|
|
4
|
+
---
|
|
5
|
+
import { Injectable, Logger } from '@nestjs/common'
|
|
6
|
+
import { OnEvent } from '@nestjs/event-emitter'
|
|
7
|
+
import { WebSocketBroadcastBackend } from './websocket-broadcast.backend'
|
|
8
|
+
import { Channels } from './channel'
|
|
9
|
+
<% eventImports.forEach((imp) => { -%>
|
|
10
|
+
|
|
11
|
+
// <%= imp.file.charAt(0).toUpperCase() + imp.file.slice(1).replace('.events', '') %> Events
|
|
12
|
+
import {
|
|
13
|
+
<% imp.events.forEach((event, idx) => { -%>
|
|
14
|
+
<%= event %>,
|
|
15
|
+
<% }); -%>
|
|
16
|
+
} from '../../domain/events/<%= imp.file %>'
|
|
17
|
+
<% }); -%>
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Bridge between domain events (via EventEmitter2) and WebSocket broadcast.
|
|
21
|
+
* Listens to domain events and broadcasts them to subscribed WebSocket clients.
|
|
22
|
+
*/
|
|
23
|
+
@Injectable()
|
|
24
|
+
export class BroadcastBridgeListener {
|
|
25
|
+
private readonly logger = new Logger(BroadcastBridgeListener.name)
|
|
26
|
+
|
|
27
|
+
constructor(private readonly broadcast: WebSocketBroadcastBackend) {}
|
|
28
|
+
<% Object.entries(bridgeEventsByChannel).forEach(([channel, events]) => { -%>
|
|
29
|
+
|
|
30
|
+
// ============================================================
|
|
31
|
+
// <%= channel.charAt(0).toUpperCase() + channel.slice(1) %> Events
|
|
32
|
+
// ============================================================
|
|
33
|
+
<% events.forEach((event) => { -%>
|
|
34
|
+
|
|
35
|
+
@OnEvent(<%= event.className %>.eventName)
|
|
36
|
+
async handle<%= event.className %>(event: <%= event.className %>): Promise<void> {
|
|
37
|
+
await this.broadcastSafe(Channels.<%= channel.toUpperCase() %>, <%= event.className %>.eventName, {
|
|
38
|
+
<% event.fields.forEach((field) => { -%>
|
|
39
|
+
<% if (event.transforms[field]) { -%>
|
|
40
|
+
<%= field %>: <%= event.transforms[field] %>,
|
|
41
|
+
<% } else { -%>
|
|
42
|
+
<%= field %>: event.<%= field %>,
|
|
43
|
+
<% } -%>
|
|
44
|
+
<% }); -%>
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
<% }); -%>
|
|
48
|
+
<% }); -%>
|
|
49
|
+
|
|
50
|
+
// ============================================================
|
|
51
|
+
// Helper
|
|
52
|
+
// ============================================================
|
|
53
|
+
|
|
54
|
+
private async broadcastSafe(
|
|
55
|
+
channel: string,
|
|
56
|
+
eventType: string,
|
|
57
|
+
payload: Record<string, unknown>,
|
|
58
|
+
): Promise<void> {
|
|
59
|
+
try {
|
|
60
|
+
await this.broadcast.broadcast(channel, eventType, payload)
|
|
61
|
+
} catch (error) {
|
|
62
|
+
this.logger.error(
|
|
63
|
+
`Failed to broadcast ${eventType} on channel ${channel}: ${error}`,
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: src/infrastructure/broadcast/channel.ts
|
|
3
|
+
force: true
|
|
4
|
+
---
|
|
5
|
+
import type { BroadcastBackend, BroadcastHandler } from './broadcast-backend.interface'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Channel wrapper providing a scoped API for broadcasting and subscribing
|
|
9
|
+
* to events on a specific channel.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const sessionChannel = new Channel(backend, 'session')
|
|
14
|
+
* await sessionChannel.emit('session.running', { sessionId: '123', appUrl: 'http://...' })
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export class Channel {
|
|
18
|
+
constructor(
|
|
19
|
+
private readonly backend: BroadcastBackend,
|
|
20
|
+
public readonly name: string,
|
|
21
|
+
) {}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Emit an event to all subscribers of this channel
|
|
25
|
+
*/
|
|
26
|
+
async emit(eventType: string, payload: Record<string, unknown>): Promise<void> {
|
|
27
|
+
await this.backend.broadcast(this.name, eventType, payload)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Subscribe to events on this channel (server-side)
|
|
32
|
+
*/
|
|
33
|
+
async subscribe(handler: BroadcastHandler): Promise<void> {
|
|
34
|
+
await this.backend.subscribe(this.name, handler)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Unsubscribe all handlers from this channel (server-side)
|
|
39
|
+
*/
|
|
40
|
+
async unsubscribe(): Promise<void> {
|
|
41
|
+
await this.backend.unsubscribe(this.name)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Predefined channel names for domain events
|
|
47
|
+
*/
|
|
48
|
+
export const Channels = {
|
|
49
|
+
<% channels.forEach((ch) => { -%>
|
|
50
|
+
<%= ch.constName %>: '<%= ch.name %>',
|
|
51
|
+
<% }); -%>
|
|
52
|
+
} as const
|
|
53
|
+
|
|
54
|
+
export type ChannelName = (typeof Channels)[keyof typeof Channels]
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Factory for creating channel instances
|
|
58
|
+
*/
|
|
59
|
+
export class ChannelFactory {
|
|
60
|
+
constructor(private readonly backend: BroadcastBackend) {}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Create a channel instance for the given name
|
|
64
|
+
*/
|
|
65
|
+
channel(name: string): Channel {
|
|
66
|
+
return new Channel(this.backend, name)
|
|
67
|
+
}
|
|
68
|
+
<% channels.forEach((ch) => { -%>
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Get the <%= ch.name %> events channel
|
|
72
|
+
*/
|
|
73
|
+
<%= ch.name %>(): Channel {
|
|
74
|
+
return this.channel(Channels.<%= ch.constName %>)
|
|
75
|
+
}
|
|
76
|
+
<% }); -%>
|
|
77
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: src/infrastructure/broadcast/index.ts
|
|
3
|
+
force: true
|
|
4
|
+
---
|
|
5
|
+
// Interfaces
|
|
6
|
+
export type { BroadcastBackend, BroadcastHandler } from './broadcast-backend.interface'
|
|
7
|
+
export { BROADCAST_BACKEND } from './broadcast-backend.interface'
|
|
8
|
+
|
|
9
|
+
// Backends
|
|
10
|
+
export { MemoryBroadcastBackend } from './memory-broadcast.backend'
|
|
11
|
+
export { WebSocketBroadcastBackend } from './websocket-broadcast.backend'
|
|
12
|
+
|
|
13
|
+
// Channel API
|
|
14
|
+
export { Channel, ChannelFactory, Channels } from './channel'
|
|
15
|
+
export type { ChannelName } from './channel'
|
|
16
|
+
|
|
17
|
+
// Bridge
|
|
18
|
+
export { BroadcastBridgeListener } from './broadcast-bridge.listener'
|
|
19
|
+
|
|
20
|
+
// Module
|
|
21
|
+
export { BroadcastModule } from './broadcast.module'
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: src/infrastructure/broadcast/memory-broadcast.backend.ts
|
|
3
|
+
force: true
|
|
4
|
+
---
|
|
5
|
+
import { Injectable } from '@nestjs/common'
|
|
6
|
+
import type {
|
|
7
|
+
BroadcastBackend,
|
|
8
|
+
BroadcastHandler,
|
|
9
|
+
} from './broadcast-backend.interface'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* In-memory broadcast backend for testing and single-process scenarios.
|
|
13
|
+
* Events are delivered synchronously to registered handlers.
|
|
14
|
+
*/
|
|
15
|
+
@Injectable()
|
|
16
|
+
export class MemoryBroadcastBackend implements BroadcastBackend {
|
|
17
|
+
private handlers = new Map<string, Set<BroadcastHandler>>()
|
|
18
|
+
private closed = false
|
|
19
|
+
|
|
20
|
+
readonly supportsPush = false
|
|
21
|
+
|
|
22
|
+
async broadcast(
|
|
23
|
+
channel: string,
|
|
24
|
+
eventType: string,
|
|
25
|
+
payload: Record<string, unknown>,
|
|
26
|
+
): Promise<void> {
|
|
27
|
+
if (this.closed) {
|
|
28
|
+
throw new Error('Broadcast backend is closed')
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const channelHandlers = this.handlers.get(channel)
|
|
32
|
+
if (!channelHandlers || channelHandlers.size === 0) {
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const promises = Array.from(channelHandlers).map((handler) =>
|
|
37
|
+
handler(eventType, payload).catch((error) => {
|
|
38
|
+
console.error(
|
|
39
|
+
`[MemoryBroadcast] Handler error on channel "${channel}":`,
|
|
40
|
+
error,
|
|
41
|
+
)
|
|
42
|
+
}),
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
await Promise.all(promises)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async subscribe(channel: string, handler: BroadcastHandler): Promise<void> {
|
|
49
|
+
if (this.closed) {
|
|
50
|
+
throw new Error('Broadcast backend is closed')
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let channelHandlers = this.handlers.get(channel)
|
|
54
|
+
if (!channelHandlers) {
|
|
55
|
+
channelHandlers = new Set()
|
|
56
|
+
this.handlers.set(channel, channelHandlers)
|
|
57
|
+
}
|
|
58
|
+
channelHandlers.add(handler)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async unsubscribe(channel: string): Promise<void> {
|
|
62
|
+
this.handlers.delete(channel)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async healthCheck(): Promise<boolean> {
|
|
66
|
+
return !this.closed
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async close(): Promise<void> {
|
|
70
|
+
this.closed = true
|
|
71
|
+
this.handlers.clear()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Get the number of handlers for a channel (for testing)
|
|
76
|
+
*/
|
|
77
|
+
getHandlerCount(channel: string): number {
|
|
78
|
+
return this.handlers.get(channel)?.size ?? 0
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Get all subscribed channels (for testing)
|
|
83
|
+
*/
|
|
84
|
+
getChannels(): string[] {
|
|
85
|
+
return Array.from(this.handlers.keys())
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: src/infrastructure/broadcast/broadcast.module.ts
|
|
3
|
+
force: true
|
|
4
|
+
---
|
|
5
|
+
import { Module } from '@nestjs/common'
|
|
6
|
+
import { WebSocketBroadcastBackend } from './websocket-broadcast.backend'
|
|
7
|
+
import { MemoryBroadcastBackend } from './memory-broadcast.backend'
|
|
8
|
+
import { BroadcastBridgeListener } from './broadcast-bridge.listener'
|
|
9
|
+
import { BROADCAST_BACKEND } from './broadcast-backend.interface'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Broadcast module providing WebSocket-based real-time event broadcasting.
|
|
13
|
+
*
|
|
14
|
+
* This module:
|
|
15
|
+
* - Exposes a WebSocket gateway at <%= websocketPath %> for client connections
|
|
16
|
+
* - Bridges domain events (from EventEmitter2) to WebSocket clients
|
|
17
|
+
* - Supports channels: <%= channelNames.join(', ') %>
|
|
18
|
+
*
|
|
19
|
+
* Usage:
|
|
20
|
+
* ```typescript
|
|
21
|
+
* @Module({
|
|
22
|
+
* imports: [BroadcastModule],
|
|
23
|
+
* })
|
|
24
|
+
* export class AppModule {}
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* Client protocol:
|
|
28
|
+
* ```
|
|
29
|
+
* // Subscribe to channels
|
|
30
|
+
* socket.emit('subscribe', { channels: ['session', 'agent'] })
|
|
31
|
+
*
|
|
32
|
+
* // Receive broadcasts
|
|
33
|
+
* socket.on('broadcast', (msg) => {
|
|
34
|
+
* console.log(msg.channel, msg.event, msg.payload)
|
|
35
|
+
* })
|
|
36
|
+
*
|
|
37
|
+
* // Unsubscribe
|
|
38
|
+
* socket.emit('unsubscribe', { channels: ['session'] })
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
@Module({
|
|
42
|
+
providers: [
|
|
43
|
+
WebSocketBroadcastBackend,
|
|
44
|
+
MemoryBroadcastBackend,
|
|
45
|
+
BroadcastBridgeListener,
|
|
46
|
+
{
|
|
47
|
+
provide: BROADCAST_BACKEND,
|
|
48
|
+
useExisting: WebSocketBroadcastBackend,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
exports: [
|
|
52
|
+
WebSocketBroadcastBackend,
|
|
53
|
+
MemoryBroadcastBackend,
|
|
54
|
+
BROADCAST_BACKEND,
|
|
55
|
+
],
|
|
56
|
+
})
|
|
57
|
+
export class BroadcastModule {}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hygen prompt.js - Loads broadcast config and prepares template locals
|
|
3
|
+
*
|
|
4
|
+
* Usage: bunx hygen broadcast new [--yaml broadcast.yaml]
|
|
5
|
+
*
|
|
6
|
+
* If no YAML is provided, generates with sensible defaults.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import fs from 'node:fs'
|
|
10
|
+
import path from 'node:path'
|
|
11
|
+
import yaml from 'yaml'
|
|
12
|
+
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// Default Configuration
|
|
15
|
+
// ============================================================================
|
|
16
|
+
|
|
17
|
+
const defaultConfig = {
|
|
18
|
+
broadcast: {
|
|
19
|
+
name: 'default',
|
|
20
|
+
channels: ['session', 'agent', 'git'],
|
|
21
|
+
websocket: {
|
|
22
|
+
path: '/ws/broadcast',
|
|
23
|
+
cors: {
|
|
24
|
+
origin: '*',
|
|
25
|
+
credentials: true,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
bridge_events: {
|
|
29
|
+
session: [
|
|
30
|
+
'SessionProvisioning',
|
|
31
|
+
'SessionRunning',
|
|
32
|
+
'SessionPaused',
|
|
33
|
+
'SessionTerminating',
|
|
34
|
+
'SessionTerminated',
|
|
35
|
+
'SessionProvisionFailed',
|
|
36
|
+
],
|
|
37
|
+
agent: [
|
|
38
|
+
'AgentSpawned',
|
|
39
|
+
'AgentStatusChanged',
|
|
40
|
+
'AgentCompleted',
|
|
41
|
+
'AgentFailed',
|
|
42
|
+
'AgentRunStarted',
|
|
43
|
+
'AgentRunCompleted',
|
|
44
|
+
'AgentRunFailed',
|
|
45
|
+
],
|
|
46
|
+
git: [
|
|
47
|
+
'GitOperationStarted',
|
|
48
|
+
'GitOperationCompleted',
|
|
49
|
+
'GitOperationFailed',
|
|
50
|
+
'GitCommitCreated',
|
|
51
|
+
'GitPushCompleted',
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ============================================================================
|
|
58
|
+
// Event Metadata (field mappings for each domain event)
|
|
59
|
+
// ============================================================================
|
|
60
|
+
|
|
61
|
+
const eventMetadata = {
|
|
62
|
+
// Session Events
|
|
63
|
+
SessionProvisioning: {
|
|
64
|
+
eventName: 'session.provisioning',
|
|
65
|
+
channel: 'session',
|
|
66
|
+
file: 'session.events',
|
|
67
|
+
fields: ['sessionId', 'projectId', 'worktreeRef'],
|
|
68
|
+
},
|
|
69
|
+
SessionRunning: {
|
|
70
|
+
eventName: 'session.running',
|
|
71
|
+
channel: 'session',
|
|
72
|
+
file: 'session.events',
|
|
73
|
+
fields: ['sessionId', 'appUrl', 'vncUrl'],
|
|
74
|
+
},
|
|
75
|
+
SessionPaused: {
|
|
76
|
+
eventName: 'session.paused',
|
|
77
|
+
channel: 'session',
|
|
78
|
+
file: 'session.events',
|
|
79
|
+
fields: ['sessionId'],
|
|
80
|
+
},
|
|
81
|
+
SessionTerminating: {
|
|
82
|
+
eventName: 'session.terminating',
|
|
83
|
+
channel: 'session',
|
|
84
|
+
file: 'session.events',
|
|
85
|
+
fields: ['sessionId', 'reason'],
|
|
86
|
+
},
|
|
87
|
+
SessionTerminated: {
|
|
88
|
+
eventName: 'session.terminated',
|
|
89
|
+
channel: 'session',
|
|
90
|
+
file: 'session.events',
|
|
91
|
+
fields: ['sessionId', 'reason'],
|
|
92
|
+
},
|
|
93
|
+
SessionProvisionFailed: {
|
|
94
|
+
eventName: 'session.provision_failed',
|
|
95
|
+
channel: 'session',
|
|
96
|
+
file: 'session.events',
|
|
97
|
+
fields: ['sessionId', 'error', 'step'],
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
// Agent Events
|
|
101
|
+
AgentSpawned: {
|
|
102
|
+
eventName: 'agent.spawned',
|
|
103
|
+
channel: 'agent',
|
|
104
|
+
file: 'agent.events',
|
|
105
|
+
fields: ['agentId', 'sessionId', 'name', 'parentAgentId'],
|
|
106
|
+
},
|
|
107
|
+
AgentStatusChanged: {
|
|
108
|
+
eventName: 'agent.status_changed',
|
|
109
|
+
channel: 'agent',
|
|
110
|
+
file: 'agent.events',
|
|
111
|
+
fields: ['agentId', 'previousStatus', 'newStatus'],
|
|
112
|
+
},
|
|
113
|
+
AgentCompleted: {
|
|
114
|
+
eventName: 'agent.completed',
|
|
115
|
+
channel: 'agent',
|
|
116
|
+
file: 'agent.events',
|
|
117
|
+
fields: ['agentId', 'sessionId'],
|
|
118
|
+
},
|
|
119
|
+
AgentFailed: {
|
|
120
|
+
eventName: 'agent.failed',
|
|
121
|
+
channel: 'agent',
|
|
122
|
+
file: 'agent.events',
|
|
123
|
+
fields: ['agentId', 'sessionId', 'error'],
|
|
124
|
+
transforms: { error: 'String(event.error)' },
|
|
125
|
+
},
|
|
126
|
+
AgentRunStarted: {
|
|
127
|
+
eventName: 'agent.run.started',
|
|
128
|
+
channel: 'agent',
|
|
129
|
+
file: 'agent.events',
|
|
130
|
+
fields: ['agentRunId', 'agentId', 'sessionId', 'trigger', 'workingRef'],
|
|
131
|
+
},
|
|
132
|
+
AgentRunCompleted: {
|
|
133
|
+
eventName: 'agent.run.completed',
|
|
134
|
+
channel: 'agent',
|
|
135
|
+
file: 'agent.events',
|
|
136
|
+
fields: ['agentRunId', 'agentId', 'sessionId', 'tokenUsage'],
|
|
137
|
+
},
|
|
138
|
+
AgentRunFailed: {
|
|
139
|
+
eventName: 'agent.run.failed',
|
|
140
|
+
channel: 'agent',
|
|
141
|
+
file: 'agent.events',
|
|
142
|
+
fields: ['agentRunId', 'agentId', 'error'],
|
|
143
|
+
transforms: { error: 'String(event.error)' },
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
// Git Events
|
|
147
|
+
GitOperationStarted: {
|
|
148
|
+
eventName: 'git.operation.started',
|
|
149
|
+
channel: 'git',
|
|
150
|
+
file: 'git.events',
|
|
151
|
+
fields: ['operationId', 'sessionId', 'operationType', 'repositoryId'],
|
|
152
|
+
},
|
|
153
|
+
GitOperationCompleted: {
|
|
154
|
+
eventName: 'git.operation.completed',
|
|
155
|
+
channel: 'git',
|
|
156
|
+
file: 'git.events',
|
|
157
|
+
fields: ['operationId', 'sessionId', 'operationType', 'commitSha'],
|
|
158
|
+
},
|
|
159
|
+
GitOperationFailed: {
|
|
160
|
+
eventName: 'git.operation.failed',
|
|
161
|
+
channel: 'git',
|
|
162
|
+
file: 'git.events',
|
|
163
|
+
fields: ['operationId', 'sessionId', 'operationType', 'error'],
|
|
164
|
+
},
|
|
165
|
+
GitCommitCreated: {
|
|
166
|
+
eventName: 'git.commit.created',
|
|
167
|
+
channel: 'git',
|
|
168
|
+
file: 'git.events',
|
|
169
|
+
fields: ['operationId', 'sessionId', 'agentRunId', 'commitSha', 'message', 'filesChanged'],
|
|
170
|
+
},
|
|
171
|
+
GitPushCompleted: {
|
|
172
|
+
eventName: 'git.push.completed',
|
|
173
|
+
channel: 'git',
|
|
174
|
+
file: 'git.events',
|
|
175
|
+
fields: ['operationId', 'sessionId', 'ref', 'remote'],
|
|
176
|
+
},
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// ============================================================================
|
|
180
|
+
// Prompt Export
|
|
181
|
+
// ============================================================================
|
|
182
|
+
|
|
183
|
+
export default {
|
|
184
|
+
prompt: async ({ args }) => {
|
|
185
|
+
let config = defaultConfig
|
|
186
|
+
|
|
187
|
+
// Load custom config if provided
|
|
188
|
+
if (args.yaml) {
|
|
189
|
+
const fullPath = path.resolve(process.cwd(), args.yaml)
|
|
190
|
+
if (!fs.existsSync(fullPath)) {
|
|
191
|
+
throw new Error(`Config file not found: ${fullPath}`)
|
|
192
|
+
}
|
|
193
|
+
const content = fs.readFileSync(fullPath, 'utf-8')
|
|
194
|
+
const parsed = yaml.parse(content)
|
|
195
|
+
config = { broadcast: { ...defaultConfig.broadcast, ...parsed.broadcast } }
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const broadcast = config.broadcast
|
|
199
|
+
|
|
200
|
+
// Process channels
|
|
201
|
+
const channels = broadcast.channels.map((ch) => ({
|
|
202
|
+
name: ch,
|
|
203
|
+
constName: ch.toUpperCase(),
|
|
204
|
+
}))
|
|
205
|
+
|
|
206
|
+
// Process bridge events - group by channel and enrich with metadata
|
|
207
|
+
const bridgeEventsByChannel = {}
|
|
208
|
+
const allBridgeEvents = []
|
|
209
|
+
const eventImportsByFile = {}
|
|
210
|
+
|
|
211
|
+
for (const [channel, events] of Object.entries(broadcast.bridge_events)) {
|
|
212
|
+
bridgeEventsByChannel[channel] = []
|
|
213
|
+
|
|
214
|
+
for (const eventName of events) {
|
|
215
|
+
const meta = eventMetadata[eventName]
|
|
216
|
+
if (!meta) {
|
|
217
|
+
console.warn(`Warning: Unknown event ${eventName}, skipping`)
|
|
218
|
+
continue
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const eventInfo = {
|
|
222
|
+
className: eventName,
|
|
223
|
+
eventName: meta.eventName,
|
|
224
|
+
channel: meta.channel,
|
|
225
|
+
fields: meta.fields,
|
|
226
|
+
transforms: meta.transforms || {},
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
bridgeEventsByChannel[channel].push(eventInfo)
|
|
230
|
+
allBridgeEvents.push(eventInfo)
|
|
231
|
+
|
|
232
|
+
// Track imports by file
|
|
233
|
+
if (!eventImportsByFile[meta.file]) {
|
|
234
|
+
eventImportsByFile[meta.file] = []
|
|
235
|
+
}
|
|
236
|
+
eventImportsByFile[meta.file].push(eventName)
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Convert import map to array for template
|
|
241
|
+
const eventImports = Object.entries(eventImportsByFile).map(([file, events]) => ({
|
|
242
|
+
file,
|
|
243
|
+
events: events.sort(),
|
|
244
|
+
}))
|
|
245
|
+
|
|
246
|
+
return {
|
|
247
|
+
// Basic config
|
|
248
|
+
name: broadcast.name,
|
|
249
|
+
websocketPath: broadcast.websocket?.path ?? '/ws/broadcast',
|
|
250
|
+
corsOrigin: broadcast.websocket?.cors?.origin ?? '*',
|
|
251
|
+
corsCredentials: broadcast.websocket?.cors?.credentials ?? true,
|
|
252
|
+
|
|
253
|
+
// Channels
|
|
254
|
+
channels,
|
|
255
|
+
channelNames: broadcast.channels,
|
|
256
|
+
|
|
257
|
+
// Bridge events
|
|
258
|
+
bridgeEventsByChannel,
|
|
259
|
+
allBridgeEvents,
|
|
260
|
+
eventImports,
|
|
261
|
+
|
|
262
|
+
// Convenience flags
|
|
263
|
+
hasSessionEvents: !!bridgeEventsByChannel.session?.length,
|
|
264
|
+
hasAgentEvents: !!bridgeEventsByChannel.agent?.length,
|
|
265
|
+
hasGitEvents: !!bridgeEventsByChannel.git?.length,
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
}
|