@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.
Files changed (279) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +214 -0
  3. package/dist/runtime/analytics/index.d.ts +6 -0
  4. package/dist/runtime/analytics/index.js +49 -0
  5. package/dist/runtime/analytics/index.js.map +1 -0
  6. package/dist/runtime/analytics/metrics.d.ts +75 -0
  7. package/dist/runtime/analytics/metrics.js +1 -0
  8. package/dist/runtime/analytics/metrics.js.map +1 -0
  9. package/dist/runtime/analytics/packs/crm-entity-measures.d.ts +21 -0
  10. package/dist/runtime/analytics/packs/crm-entity-measures.js +1 -0
  11. package/dist/runtime/analytics/packs/crm-entity-measures.js.map +1 -0
  12. package/dist/runtime/analytics/packs/index.d.ts +3 -0
  13. package/dist/runtime/analytics/packs/index.js +1 -0
  14. package/dist/runtime/analytics/packs/index.js.map +1 -0
  15. package/dist/runtime/analytics/packs/monetary-measures.d.ts +21 -0
  16. package/dist/runtime/analytics/packs/monetary-measures.js +1 -0
  17. package/dist/runtime/analytics/packs/monetary-measures.js.map +1 -0
  18. package/dist/runtime/analytics/specs.d.ts +49 -0
  19. package/dist/runtime/analytics/specs.js +1 -0
  20. package/dist/runtime/analytics/specs.js.map +1 -0
  21. package/dist/runtime/analytics/types.d.ts +85 -0
  22. package/dist/runtime/analytics/types.js +49 -0
  23. package/dist/runtime/analytics/types.js.map +1 -0
  24. package/dist/runtime/base-classes/activity-entity-repository.d.ts +26 -0
  25. package/dist/runtime/base-classes/activity-entity-repository.js +195 -0
  26. package/dist/runtime/base-classes/activity-entity-repository.js.map +1 -0
  27. package/dist/runtime/base-classes/activity-entity-service.d.ts +39 -0
  28. package/dist/runtime/base-classes/activity-entity-service.js +214 -0
  29. package/dist/runtime/base-classes/activity-entity-service.js.map +1 -0
  30. package/dist/runtime/base-classes/base-read-use-cases.d.ts +68 -0
  31. package/dist/runtime/base-classes/base-read-use-cases.js +32 -0
  32. package/dist/runtime/base-classes/base-read-use-cases.js.map +1 -0
  33. package/dist/runtime/base-classes/base-repository.d.ts +99 -0
  34. package/dist/runtime/base-classes/base-repository.js +160 -0
  35. package/dist/runtime/base-classes/base-repository.js.map +1 -0
  36. package/dist/runtime/base-classes/base-service.d.ts +98 -0
  37. package/dist/runtime/base-classes/base-service.js +186 -0
  38. package/dist/runtime/base-classes/base-service.js.map +1 -0
  39. package/dist/runtime/base-classes/index.d.ts +18 -0
  40. package/dist/runtime/base-classes/index.js +617 -0
  41. package/dist/runtime/base-classes/index.js.map +1 -0
  42. package/dist/runtime/base-classes/knowledge-entity-repository.d.ts +17 -0
  43. package/dist/runtime/base-classes/knowledge-entity-repository.js +166 -0
  44. package/dist/runtime/base-classes/knowledge-entity-repository.js.map +1 -0
  45. package/dist/runtime/base-classes/knowledge-entity-service.d.ts +15 -0
  46. package/dist/runtime/base-classes/knowledge-entity-service.js +192 -0
  47. package/dist/runtime/base-classes/knowledge-entity-service.js.map +1 -0
  48. package/dist/runtime/base-classes/lifecycle-events.d.ts +49 -0
  49. package/dist/runtime/base-classes/lifecycle-events.js +76 -0
  50. package/dist/runtime/base-classes/lifecycle-events.js.map +1 -0
  51. package/dist/runtime/base-classes/metadata-entity-repository.d.ts +27 -0
  52. package/dist/runtime/base-classes/metadata-entity-repository.js +212 -0
  53. package/dist/runtime/base-classes/metadata-entity-repository.js.map +1 -0
  54. package/dist/runtime/base-classes/metadata-entity-service.d.ts +39 -0
  55. package/dist/runtime/base-classes/metadata-entity-service.js +214 -0
  56. package/dist/runtime/base-classes/metadata-entity-service.js.map +1 -0
  57. package/dist/runtime/base-classes/synced-entity-repository.d.ts +32 -0
  58. package/dist/runtime/base-classes/synced-entity-repository.js +203 -0
  59. package/dist/runtime/base-classes/synced-entity-repository.js.map +1 -0
  60. package/dist/runtime/base-classes/synced-entity-service.d.ts +41 -0
  61. package/dist/runtime/base-classes/synced-entity-service.js +215 -0
  62. package/dist/runtime/base-classes/synced-entity-service.js.map +1 -0
  63. package/dist/runtime/base-classes/with-analytics.d.ts +18 -0
  64. package/dist/runtime/base-classes/with-analytics.js +11 -0
  65. package/dist/runtime/base-classes/with-analytics.js.map +1 -0
  66. package/dist/runtime/constants/tokens.d.ts +29 -0
  67. package/dist/runtime/constants/tokens.js +8 -0
  68. package/dist/runtime/constants/tokens.js.map +1 -0
  69. package/dist/runtime/subsystems/analytics/analytics-query.protocol.d.ts +30 -0
  70. package/dist/runtime/subsystems/analytics/analytics-query.protocol.js +1 -0
  71. package/dist/runtime/subsystems/analytics/analytics-query.protocol.js.map +1 -0
  72. package/dist/runtime/subsystems/analytics/analytics.module.d.ts +34 -0
  73. package/dist/runtime/subsystems/analytics/analytics.module.js +117 -0
  74. package/dist/runtime/subsystems/analytics/analytics.module.js.map +1 -0
  75. package/dist/runtime/subsystems/analytics/analytics.tokens.d.ts +24 -0
  76. package/dist/runtime/subsystems/analytics/analytics.tokens.js +10 -0
  77. package/dist/runtime/subsystems/analytics/analytics.tokens.js.map +1 -0
  78. package/dist/runtime/subsystems/analytics/cube-backend.d.ts +28 -0
  79. package/dist/runtime/subsystems/analytics/cube-backend.js +71 -0
  80. package/dist/runtime/subsystems/analytics/cube-backend.js.map +1 -0
  81. package/dist/runtime/subsystems/analytics/index.d.ts +6 -0
  82. package/dist/runtime/subsystems/analytics/index.js +122 -0
  83. package/dist/runtime/subsystems/analytics/index.js.map +1 -0
  84. package/dist/runtime/subsystems/analytics/noop-backend.d.ts +7 -0
  85. package/dist/runtime/subsystems/analytics/noop-backend.js +25 -0
  86. package/dist/runtime/subsystems/analytics/noop-backend.js.map +1 -0
  87. package/dist/runtime/subsystems/cache/cache.drizzle-backend.d.ts +43 -0
  88. package/dist/runtime/subsystems/cache/cache.drizzle-backend.js +133 -0
  89. package/dist/runtime/subsystems/cache/cache.drizzle-backend.js.map +1 -0
  90. package/dist/runtime/subsystems/cache/cache.memory-backend.d.ts +21 -0
  91. package/dist/runtime/subsystems/cache/cache.memory-backend.js +100 -0
  92. package/dist/runtime/subsystems/cache/cache.memory-backend.js.map +1 -0
  93. package/dist/runtime/subsystems/cache/cache.module.d.ts +37 -0
  94. package/dist/runtime/subsystems/cache/cache.module.js +272 -0
  95. package/dist/runtime/subsystems/cache/cache.module.js.map +1 -0
  96. package/dist/runtime/subsystems/cache/cache.protocol.d.ts +42 -0
  97. package/dist/runtime/subsystems/cache/cache.protocol.js +1 -0
  98. package/dist/runtime/subsystems/cache/cache.protocol.js.map +1 -0
  99. package/dist/runtime/subsystems/cache/cache.schema.d.ts +64 -0
  100. package/dist/runtime/subsystems/cache/cache.schema.js +18 -0
  101. package/dist/runtime/subsystems/cache/cache.schema.js.map +1 -0
  102. package/dist/runtime/subsystems/cache/cache.tokens.d.ts +18 -0
  103. package/dist/runtime/subsystems/cache/cache.tokens.js +8 -0
  104. package/dist/runtime/subsystems/cache/cache.tokens.js.map +1 -0
  105. package/dist/runtime/subsystems/cache/index.d.ts +11 -0
  106. package/dist/runtime/subsystems/cache/index.js +277 -0
  107. package/dist/runtime/subsystems/cache/index.js.map +1 -0
  108. package/dist/runtime/subsystems/events/domain-events.schema.d.ts +187 -0
  109. package/dist/runtime/subsystems/events/domain-events.schema.js +32 -0
  110. package/dist/runtime/subsystems/events/domain-events.schema.js.map +1 -0
  111. package/dist/runtime/subsystems/events/event-bus.drizzle-backend.d.ts +38 -0
  112. package/dist/runtime/subsystems/events/event-bus.drizzle-backend.js +199 -0
  113. package/dist/runtime/subsystems/events/event-bus.drizzle-backend.js.map +1 -0
  114. package/dist/runtime/subsystems/events/event-bus.memory-backend.d.ts +18 -0
  115. package/dist/runtime/subsystems/events/event-bus.memory-backend.js +71 -0
  116. package/dist/runtime/subsystems/events/event-bus.memory-backend.js.map +1 -0
  117. package/dist/runtime/subsystems/events/event-bus.protocol.d.ts +52 -0
  118. package/dist/runtime/subsystems/events/event-bus.protocol.js +1 -0
  119. package/dist/runtime/subsystems/events/event-bus.protocol.js.map +1 -0
  120. package/dist/runtime/subsystems/events/event-bus.redis-backend.d.ts +95 -0
  121. package/dist/runtime/subsystems/events/event-bus.redis-backend.js +229 -0
  122. package/dist/runtime/subsystems/events/event-bus.redis-backend.js.map +1 -0
  123. package/dist/runtime/subsystems/events/events.module.d.ts +46 -0
  124. package/dist/runtime/subsystems/events/events.module.js +531 -0
  125. package/dist/runtime/subsystems/events/events.module.js.map +1 -0
  126. package/dist/runtime/subsystems/events/events.tokens.d.ts +19 -0
  127. package/dist/runtime/subsystems/events/events.tokens.js +8 -0
  128. package/dist/runtime/subsystems/events/events.tokens.js.map +1 -0
  129. package/dist/runtime/subsystems/events/index.d.ts +12 -0
  130. package/dist/runtime/subsystems/events/index.js +536 -0
  131. package/dist/runtime/subsystems/events/index.js.map +1 -0
  132. package/dist/runtime/subsystems/index.d.ts +24 -0
  133. package/dist/runtime/subsystems/index.js +1643 -0
  134. package/dist/runtime/subsystems/index.js.map +1 -0
  135. package/dist/runtime/subsystems/jobs/index.d.ts +14 -0
  136. package/dist/runtime/subsystems/jobs/index.js +680 -0
  137. package/dist/runtime/subsystems/jobs/index.js.map +1 -0
  138. package/dist/runtime/subsystems/jobs/job-queue.bullmq-backend.d.ts +54 -0
  139. package/dist/runtime/subsystems/jobs/job-queue.bullmq-backend.js +186 -0
  140. package/dist/runtime/subsystems/jobs/job-queue.bullmq-backend.js.map +1 -0
  141. package/dist/runtime/subsystems/jobs/job-queue.drizzle-backend.d.ts +38 -0
  142. package/dist/runtime/subsystems/jobs/job-queue.drizzle-backend.js +228 -0
  143. package/dist/runtime/subsystems/jobs/job-queue.drizzle-backend.js.map +1 -0
  144. package/dist/runtime/subsystems/jobs/job-queue.memory-backend.d.ts +12 -0
  145. package/dist/runtime/subsystems/jobs/job-queue.memory-backend.js +44 -0
  146. package/dist/runtime/subsystems/jobs/job-queue.memory-backend.js.map +1 -0
  147. package/dist/runtime/subsystems/jobs/job-queue.protocol.d.ts +48 -0
  148. package/dist/runtime/subsystems/jobs/job-queue.protocol.js +1 -0
  149. package/dist/runtime/subsystems/jobs/job-queue.protocol.js.map +1 -0
  150. package/dist/runtime/subsystems/jobs/job-queue.redis-backend.d.ts +46 -0
  151. package/dist/runtime/subsystems/jobs/job-queue.redis-backend.js +187 -0
  152. package/dist/runtime/subsystems/jobs/job-queue.redis-backend.js.map +1 -0
  153. package/dist/runtime/subsystems/jobs/job-queue.schema.d.ts +237 -0
  154. package/dist/runtime/subsystems/jobs/job-queue.schema.js +44 -0
  155. package/dist/runtime/subsystems/jobs/job-queue.schema.js.map +1 -0
  156. package/dist/runtime/subsystems/jobs/jobs.module.d.ts +18 -0
  157. package/dist/runtime/subsystems/jobs/jobs.module.js +676 -0
  158. package/dist/runtime/subsystems/jobs/jobs.module.js.map +1 -0
  159. package/dist/runtime/subsystems/jobs/jobs.tokens.d.ts +13 -0
  160. package/dist/runtime/subsystems/jobs/jobs.tokens.js +8 -0
  161. package/dist/runtime/subsystems/jobs/jobs.tokens.js.map +1 -0
  162. package/dist/runtime/subsystems/storage/index.d.ts +6 -0
  163. package/dist/runtime/subsystems/storage/index.js +204 -0
  164. package/dist/runtime/subsystems/storage/index.js.map +1 -0
  165. package/dist/runtime/subsystems/storage/storage.local-backend.d.ts +18 -0
  166. package/dist/runtime/subsystems/storage/storage.local-backend.js +108 -0
  167. package/dist/runtime/subsystems/storage/storage.local-backend.js.map +1 -0
  168. package/dist/runtime/subsystems/storage/storage.memory-backend.d.ts +28 -0
  169. package/dist/runtime/subsystems/storage/storage.memory-backend.js +72 -0
  170. package/dist/runtime/subsystems/storage/storage.memory-backend.js.map +1 -0
  171. package/dist/runtime/subsystems/storage/storage.module.d.ts +40 -0
  172. package/dist/runtime/subsystems/storage/storage.module.js +201 -0
  173. package/dist/runtime/subsystems/storage/storage.module.js.map +1 -0
  174. package/dist/runtime/subsystems/storage/storage.protocol.d.ts +69 -0
  175. package/dist/runtime/subsystems/storage/storage.protocol.js +1 -0
  176. package/dist/runtime/subsystems/storage/storage.protocol.js.map +1 -0
  177. package/dist/runtime/subsystems/storage/storage.tokens.d.ts +11 -0
  178. package/dist/runtime/subsystems/storage/storage.tokens.js +6 -0
  179. package/dist/runtime/subsystems/storage/storage.tokens.js.map +1 -0
  180. package/dist/runtime/subsystems/storage/storage.utils.d.ts +9 -0
  181. package/dist/runtime/subsystems/storage/storage.utils.js +18 -0
  182. package/dist/runtime/subsystems/storage/storage.utils.js.map +1 -0
  183. package/dist/runtime/types/drizzle.d.ts +17 -0
  184. package/dist/runtime/types/drizzle.js +1 -0
  185. package/dist/runtime/types/drizzle.js.map +1 -0
  186. package/dist/src/cli/index.d.ts +1 -0
  187. package/dist/src/cli/index.js +7365 -0
  188. package/dist/src/cli/index.js.map +1 -0
  189. package/dist/src/index.d.ts +2384 -0
  190. package/dist/src/index.js +2198 -0
  191. package/dist/src/index.js.map +1 -0
  192. package/package.json +114 -0
  193. package/templates/broadcast/new/backend-interface.ejs.t +47 -0
  194. package/templates/broadcast/new/bridge-listener.ejs.t +67 -0
  195. package/templates/broadcast/new/channel.ejs.t +77 -0
  196. package/templates/broadcast/new/index.ejs.t +21 -0
  197. package/templates/broadcast/new/memory-backend.ejs.t +87 -0
  198. package/templates/broadcast/new/module.ejs.t +57 -0
  199. package/templates/broadcast/new/prompt.js +268 -0
  200. package/templates/broadcast/new/websocket-backend.ejs.t +259 -0
  201. package/templates/entity/new/backend/application/commands/create.ejs.t +55 -0
  202. package/templates/entity/new/backend/application/commands/delete.ejs.t +45 -0
  203. package/templates/entity/new/backend/application/commands/grouped-index.ejs.t +149 -0
  204. package/templates/entity/new/backend/application/commands/index.ejs.t +15 -0
  205. package/templates/entity/new/backend/application/commands/update.ejs.t +58 -0
  206. package/templates/entity/new/backend/application/queries/declarative-queries.ejs.t +36 -0
  207. package/templates/entity/new/backend/application/queries/get-by-id.ejs.t +42 -0
  208. package/templates/entity/new/backend/application/queries/grouped-index.ejs.t +81 -0
  209. package/templates/entity/new/backend/application/queries/index.ejs.t +14 -0
  210. package/templates/entity/new/backend/application/queries/list.ejs.t +36 -0
  211. package/templates/entity/new/backend/application/schemas/_inject-index.ejs.t +7 -0
  212. package/templates/entity/new/backend/application/schemas/dto.ejs.t +45 -0
  213. package/templates/entity/new/backend/database/_inject-index.ejs.t +7 -0
  214. package/templates/entity/new/backend/database/electric-migration.ejs.t +21 -0
  215. package/templates/entity/new/backend/database/repository.ejs.t +450 -0
  216. package/templates/entity/new/backend/database/schema.ejs.t +248 -0
  217. package/templates/entity/new/backend/domain/_inject-index.ejs.t +12 -0
  218. package/templates/entity/new/backend/domain/entity.ejs.t +108 -0
  219. package/templates/entity/new/backend/domain/grouped-index.ejs.t +163 -0
  220. package/templates/entity/new/backend/domain/index.ejs.t +15 -0
  221. package/templates/entity/new/backend/domain/repository-interface.ejs.t +71 -0
  222. package/templates/entity/new/backend/modules/core/_ensure-anchor-tokens.ejs.t +10 -0
  223. package/templates/entity/new/backend/modules/core/_inject-token.ejs.t +7 -0
  224. package/templates/entity/new/backend/modules/core/module.ejs.t +67 -0
  225. package/templates/entity/new/backend/modules/trpc/module.ejs.t +67 -0
  226. package/templates/entity/new/backend/presentation/controller.ejs.t +201 -0
  227. package/templates/entity/new/clean-lite-ps/controller.ejs.t +37 -0
  228. package/templates/entity/new/clean-lite-ps/dto/create.ejs.t +17 -0
  229. package/templates/entity/new/clean-lite-ps/dto/output.ejs.t +25 -0
  230. package/templates/entity/new/clean-lite-ps/dto/update.ejs.t +11 -0
  231. package/templates/entity/new/clean-lite-ps/entity.ejs.t +52 -0
  232. package/templates/entity/new/clean-lite-ps/index.ejs.t +20 -0
  233. package/templates/entity/new/clean-lite-ps/module.ejs.t +43 -0
  234. package/templates/entity/new/clean-lite-ps/prompt-extension.js +617 -0
  235. package/templates/entity/new/clean-lite-ps/repository.ejs.t +62 -0
  236. package/templates/entity/new/clean-lite-ps/service.ejs.t +34 -0
  237. package/templates/entity/new/clean-lite-ps/use-cases/declarative-queries.ejs.t +34 -0
  238. package/templates/entity/new/clean-lite-ps/use-cases/find-by-id.ejs.t +16 -0
  239. package/templates/entity/new/clean-lite-ps/use-cases/list.ejs.t +16 -0
  240. package/templates/entity/new/frontend/_inject-entities-entry.ejs.t +7 -0
  241. package/templates/entity/new/frontend/_inject-entities-import.ejs.t +7 -0
  242. package/templates/entity/new/frontend/collections/_ensure-anchor-collections.ejs.t +10 -0
  243. package/templates/entity/new/frontend/collections/_inject-index.ejs.t +9 -0
  244. package/templates/entity/new/frontend/collections/_inject-schema-import.ejs.t +9 -0
  245. package/templates/entity/new/frontend/collections/collection.ejs.t +61 -0
  246. package/templates/entity/new/frontend/collections/collections-base.ejs.t +24 -0
  247. package/templates/entity/new/frontend/entity/collection.ejs.t +172 -0
  248. package/templates/entity/new/frontend/entity/combined.ejs.t +474 -0
  249. package/templates/entity/new/frontend/entity/fields.ejs.t +104 -0
  250. package/templates/entity/new/frontend/entity/hooks.ejs.t +73 -0
  251. package/templates/entity/new/frontend/entity/index.ejs.t +21 -0
  252. package/templates/entity/new/frontend/entity/mutation-hooks.ejs.t +84 -0
  253. package/templates/entity/new/frontend/entity/mutations.ejs.t +38 -0
  254. package/templates/entity/new/frontend/entity/types.ejs.t +59 -0
  255. package/templates/entity/new/frontend/generated/_inject-index-export.ejs.t +7 -0
  256. package/templates/entity/new/frontend/generated/_inject-index-import.ejs.t +7 -0
  257. package/templates/entity/new/frontend/generated/_inject-index-registry.ejs.t +7 -0
  258. package/templates/entity/new/frontend/store/_inject-collection-import.ejs.t +9 -0
  259. package/templates/entity/new/frontend/store/_inject-collections.ejs.t +9 -0
  260. package/templates/entity/new/frontend/store/_inject-entity.ejs.t +9 -0
  261. package/templates/entity/new/frontend/store/_inject-import.ejs.t +9 -0
  262. package/templates/entity/new/frontend/store/_inject-lookups.ejs.t +9 -0
  263. package/templates/entity/new/frontend/store/_inject-resolve.ejs.t +10 -0
  264. package/templates/entity/new/frontend/store/hooks.ejs.t +72 -0
  265. package/templates/entity/new/frontend/unified-entity.ejs.t +28 -0
  266. package/templates/entity/new/prompt.js +1421 -0
  267. package/templates/relationship/new/controller.ejs.t +36 -0
  268. package/templates/relationship/new/dto/create.ejs.t +41 -0
  269. package/templates/relationship/new/dto/output.ejs.t +44 -0
  270. package/templates/relationship/new/dto/update.ejs.t +10 -0
  271. package/templates/relationship/new/entity.ejs.t +98 -0
  272. package/templates/relationship/new/index.ejs.t +19 -0
  273. package/templates/relationship/new/module.ejs.t +35 -0
  274. package/templates/relationship/new/prompt.js +682 -0
  275. package/templates/relationship/new/repository.ejs.t +54 -0
  276. package/templates/relationship/new/service.ejs.t +31 -0
  277. package/templates/relationship/new/use-cases/declarative-queries.ejs.t +34 -0
  278. package/templates/relationship/new/use-cases/find-by-id.ejs.t +16 -0
  279. package/templates/relationship/new/use-cases/list.ejs.t +16 -0
@@ -0,0 +1,32 @@
1
+ // runtime/base-classes/base-read-use-cases.ts
2
+ var BaseFindByIdUseCase = class {
3
+ constructor(service) {
4
+ this.service = service;
5
+ }
6
+ service;
7
+ /**
8
+ * Find a single entity by its primary key.
9
+ * Returns null if not found.
10
+ */
11
+ execute(id) {
12
+ return this.service.findById(id);
13
+ }
14
+ };
15
+ var BaseListUseCase = class {
16
+ constructor(service) {
17
+ this.service = service;
18
+ }
19
+ service;
20
+ /**
21
+ * List all entities (no filters).
22
+ * Controllers that need filtered lists should use a dedicated use case.
23
+ */
24
+ execute() {
25
+ return this.service.list();
26
+ }
27
+ };
28
+ export {
29
+ BaseFindByIdUseCase,
30
+ BaseListUseCase
31
+ };
32
+ //# sourceMappingURL=base-read-use-cases.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../runtime/base-classes/base-read-use-cases.ts"],"sourcesContent":["/**\n * Base read use cases\n *\n * Abstract base classes for auto-generated per-entity read use cases.\n * Controllers always import use case classes — never services directly (ADR-003).\n *\n * Each entity gets a single generated file with two named exports:\n * - ContactFindByIdUseCase extends BaseFindByIdUseCase<ContactService, Contact>\n * - ContactListUseCase extends BaseListUseCase<ContactService, Contact>\n *\n * Note: @Injectable() is applied on concrete use case classes (not here),\n * matching the pattern established by BaseRepository and BaseService.\n */\n\n// ============================================================================\n// BaseFindByIdUseCase\n// ============================================================================\n\n/**\n * Structural interface for any service that supports findById.\n * Keeps base use cases decoupled from concrete service implementations.\n */\nexport interface IFindByIdService<TEntity> {\n findById(id: string): Promise<TEntity | null>;\n}\n\n/**\n * Base class for generated FindById use cases.\n *\n * Generated usage:\n * ```typescript\n * @Injectable()\n * export class ContactFindByIdUseCase extends BaseFindByIdUseCase<ContactService, Contact> {\n * constructor(service: ContactService) { super(service); }\n * }\n * ```\n */\nexport abstract class BaseFindByIdUseCase<\n TService extends IFindByIdService<TEntity>,\n TEntity,\n> {\n constructor(protected readonly service: TService) {}\n\n /**\n * Find a single entity by its primary key.\n * Returns null if not found.\n */\n execute(id: string): Promise<TEntity | null> {\n return this.service.findById(id);\n }\n}\n\n// ============================================================================\n// BaseListUseCase\n// ============================================================================\n\n/**\n * Structural interface for any service that supports list.\n */\nexport interface IListService<TEntity> {\n list(options?: unknown): Promise<TEntity[]>;\n}\n\n/**\n * Base class for generated List use cases.\n *\n * Generated usage:\n * ```typescript\n * @Injectable()\n * export class ContactListUseCase extends BaseListUseCase<ContactService, Contact> {\n * constructor(service: ContactService) { super(service); }\n * }\n * ```\n */\nexport abstract class BaseListUseCase<\n TService extends IListService<TEntity>,\n TEntity,\n> {\n constructor(protected readonly service: TService) {}\n\n /**\n * List all entities (no filters).\n * Controllers that need filtered lists should use a dedicated use case.\n */\n execute(): Promise<TEntity[]> {\n return this.service.list();\n }\n}\n"],"mappings":";AAqCO,IAAe,sBAAf,MAGL;AAAA,EACA,YAA+B,SAAmB;AAAnB;AAAA,EAAoB;AAAA,EAApB;AAAA;AAAA;AAAA;AAAA;AAAA,EAM/B,QAAQ,IAAqC;AAC3C,WAAO,KAAK,QAAQ,SAAS,EAAE;AAAA,EACjC;AACF;AAwBO,IAAe,kBAAf,MAGL;AAAA,EACA,YAA+B,SAAmB;AAAnB;AAAA,EAAoB;AAAA,EAApB;AAAA;AAAA;AAAA;AAAA;AAAA,EAM/B,UAA8B;AAC5B,WAAO,KAAK,QAAQ,KAAK;AAAA,EAC3B;AACF;","names":[]}
@@ -0,0 +1,99 @@
1
+ import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
2
+ import { PgTableWithColumns, PgColumn } from 'drizzle-orm/pg-core';
3
+ import { SQL } from 'drizzle-orm';
4
+ import { DrizzleClient } from '../types/drizzle.js';
5
+ import 'drizzle-orm/node-postgres';
6
+
7
+ /**
8
+ * Behavior flags for the repository. Controls automatic timestamp injection
9
+ * and soft-delete filtering.
10
+ */
11
+ interface BehaviorConfig {
12
+ timestamps: boolean;
13
+ softDelete: boolean;
14
+ userTracking: boolean;
15
+ }
16
+ /**
17
+ * Options for the list() method.
18
+ */
19
+ interface ListOptions {
20
+ where?: SQL;
21
+ limit?: number;
22
+ offset?: number;
23
+ orderBy?: PgColumn | SQL;
24
+ }
25
+ declare abstract class BaseRepository<TEntity> {
26
+ /**
27
+ * The Drizzle table schema for this entity.
28
+ * Concrete repositories declare this as a class property.
29
+ */
30
+ protected abstract readonly table: PgTableWithColumns<any>;
31
+ /**
32
+ * Behavior flags controlling automatic behavior injection.
33
+ * Override in concrete repositories to enable behaviors.
34
+ */
35
+ protected readonly behaviors: BehaviorConfig;
36
+ protected readonly db: DrizzleClient;
37
+ constructor(db: DrizzleClient);
38
+ /**
39
+ * Find a single entity by its primary key.
40
+ * Returns null if not found (or soft-deleted when softDelete=true).
41
+ */
42
+ findById(id: string): Promise<TEntity | null>;
43
+ /**
44
+ * Find multiple entities by their primary keys.
45
+ * Returns empty array immediately for empty input (avoids DB errors).
46
+ */
47
+ findByIds(ids: string[]): Promise<TEntity[]>;
48
+ /**
49
+ * List entities with optional filtering, pagination, and ordering.
50
+ */
51
+ list(options?: ListOptions): Promise<TEntity[]>;
52
+ /**
53
+ * Count entities matching an optional WHERE clause.
54
+ * Soft-deleted rows are always excluded when softDelete=true.
55
+ */
56
+ count(where?: SQL): Promise<number>;
57
+ /**
58
+ * Check whether an entity with the given id exists.
59
+ */
60
+ exists(id: string): Promise<boolean>;
61
+ /**
62
+ * Insert a new entity. Timestamps are auto-injected when timestamps=true.
63
+ */
64
+ create(input: Partial<TEntity>): Promise<TEntity>;
65
+ /**
66
+ * Update an existing entity by id. updatedAt is auto-injected when timestamps=true.
67
+ * Returns the updated entity.
68
+ */
69
+ update(id: string, input: Partial<TEntity>): Promise<TEntity>;
70
+ /**
71
+ * Delete an entity by id.
72
+ * - softDelete=true: sets deletedAt to current timestamp
73
+ * - softDelete=false: hard-deletes the row
74
+ */
75
+ delete(id: string): Promise<void>;
76
+ /**
77
+ * Insert or update multiple entities.
78
+ * Default naive implementation — family repositories override with
79
+ * proper conflict-target upsert (e.g., CrmEntityRepository).
80
+ */
81
+ upsertMany(inputs: Array<Partial<TEntity>>): Promise<TEntity[]>;
82
+ /**
83
+ * Base SELECT query that automatically excludes soft-deleted rows
84
+ * when softDelete behavior is enabled.
85
+ */
86
+ protected baseQuery(): drizzle_orm_pg_core.PgSelectBase<any, any, "single", {} | Record<any, "not-null">, true, never, {
87
+ [x: string]: any;
88
+ }[], any>;
89
+ /**
90
+ * Merge timestamp fields into an input object.
91
+ * - mode='create': adds createdAt and updatedAt
92
+ * - mode='update': adds updatedAt only
93
+ *
94
+ * No-op when timestamps behavior is disabled.
95
+ */
96
+ protected withTimestamps(input: Record<string, unknown>, mode: 'create' | 'update'): Record<string, unknown>;
97
+ }
98
+
99
+ export { BaseRepository, type BehaviorConfig, type ListOptions };
@@ -0,0 +1,160 @@
1
+ // runtime/base-classes/base-repository.ts
2
+ import { eq, inArray, isNull, sql } from "drizzle-orm";
3
+ var BaseRepository = class {
4
+ // eslint-disable-line @typescript-eslint/no-explicit-any
5
+ /**
6
+ * Behavior flags controlling automatic behavior injection.
7
+ * Override in concrete repositories to enable behaviors.
8
+ */
9
+ behaviors = {
10
+ timestamps: false,
11
+ softDelete: false,
12
+ userTracking: false
13
+ };
14
+ db;
15
+ constructor(db) {
16
+ this.db = db;
17
+ }
18
+ // ============================================================================
19
+ // Read Operations
20
+ // ============================================================================
21
+ /**
22
+ * Find a single entity by its primary key.
23
+ * Returns null if not found (or soft-deleted when softDelete=true).
24
+ */
25
+ async findById(id) {
26
+ const rows = await this.baseQuery().where(eq(this.table["id"], id)).limit(1);
27
+ return rows[0] ?? null;
28
+ }
29
+ /**
30
+ * Find multiple entities by their primary keys.
31
+ * Returns empty array immediately for empty input (avoids DB errors).
32
+ */
33
+ async findByIds(ids) {
34
+ if (ids.length === 0) return [];
35
+ const rows = await this.baseQuery().where(inArray(this.table["id"], ids));
36
+ return rows;
37
+ }
38
+ /**
39
+ * List entities with optional filtering, pagination, and ordering.
40
+ */
41
+ async list(options) {
42
+ let query = this.baseQuery();
43
+ if (options?.where) {
44
+ query = query.where(options.where);
45
+ }
46
+ if (options?.orderBy) {
47
+ query = query.orderBy(options.orderBy);
48
+ }
49
+ if (options?.limit !== void 0) {
50
+ query = query.limit(options.limit);
51
+ }
52
+ if (options?.offset !== void 0) {
53
+ query = query.offset(options.offset);
54
+ }
55
+ const rows = await query;
56
+ return rows;
57
+ }
58
+ /**
59
+ * Count entities matching an optional WHERE clause.
60
+ * Soft-deleted rows are always excluded when softDelete=true.
61
+ */
62
+ async count(where) {
63
+ let query = this.db.select({ count: sql`cast(count(*) as integer)` }).from(this.table);
64
+ const conditions = [];
65
+ if (this.behaviors.softDelete) {
66
+ conditions.push(isNull(this.table["deletedAt"]));
67
+ }
68
+ if (where) {
69
+ conditions.push(where);
70
+ }
71
+ if (conditions.length === 1) {
72
+ query = query.where(conditions[0]);
73
+ } else if (conditions.length > 1) {
74
+ const { and } = await import("drizzle-orm");
75
+ query = query.where(and(...conditions));
76
+ }
77
+ const rows = await query;
78
+ return rows[0]?.count ?? 0;
79
+ }
80
+ /**
81
+ * Check whether an entity with the given id exists.
82
+ */
83
+ async exists(id) {
84
+ const result = await this.findById(id);
85
+ return result !== null;
86
+ }
87
+ // ============================================================================
88
+ // Write Operations
89
+ // ============================================================================
90
+ /**
91
+ * Insert a new entity. Timestamps are auto-injected when timestamps=true.
92
+ */
93
+ async create(input) {
94
+ const data = this.withTimestamps(input, "create");
95
+ const rows = await this.db.insert(this.table).values(data).returning();
96
+ return rows[0];
97
+ }
98
+ /**
99
+ * Update an existing entity by id. updatedAt is auto-injected when timestamps=true.
100
+ * Returns the updated entity.
101
+ */
102
+ async update(id, input) {
103
+ const data = this.withTimestamps(input, "update");
104
+ const rows = await this.db.update(this.table).set(data).where(eq(this.table["id"], id)).returning();
105
+ return rows[0];
106
+ }
107
+ /**
108
+ * Delete an entity by id.
109
+ * - softDelete=true: sets deletedAt to current timestamp
110
+ * - softDelete=false: hard-deletes the row
111
+ */
112
+ async delete(id) {
113
+ if (this.behaviors.softDelete) {
114
+ await this.db.update(this.table).set({ deletedAt: /* @__PURE__ */ new Date() }).where(eq(this.table["id"], id));
115
+ } else {
116
+ await this.db.delete(this.table).where(eq(this.table["id"], id));
117
+ }
118
+ }
119
+ /**
120
+ * Insert or update multiple entities.
121
+ * Default naive implementation — family repositories override with
122
+ * proper conflict-target upsert (e.g., CrmEntityRepository).
123
+ */
124
+ async upsertMany(inputs) {
125
+ return Promise.all(inputs.map((input) => this.create(input)));
126
+ }
127
+ // ============================================================================
128
+ // Protected Helpers
129
+ // ============================================================================
130
+ /**
131
+ * Base SELECT query that automatically excludes soft-deleted rows
132
+ * when softDelete behavior is enabled.
133
+ */
134
+ baseQuery() {
135
+ const query = this.db.select().from(this.table).$dynamic();
136
+ if (this.behaviors.softDelete) {
137
+ return query.where(isNull(this.table["deletedAt"]));
138
+ }
139
+ return query;
140
+ }
141
+ /**
142
+ * Merge timestamp fields into an input object.
143
+ * - mode='create': adds createdAt and updatedAt
144
+ * - mode='update': adds updatedAt only
145
+ *
146
+ * No-op when timestamps behavior is disabled.
147
+ */
148
+ withTimestamps(input, mode) {
149
+ if (!this.behaviors.timestamps) return input;
150
+ const now = /* @__PURE__ */ new Date();
151
+ if (mode === "create") {
152
+ return { ...input, createdAt: now, updatedAt: now };
153
+ }
154
+ return { ...input, updatedAt: now };
155
+ }
156
+ };
157
+ export {
158
+ BaseRepository
159
+ };
160
+ //# sourceMappingURL=base-repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../runtime/base-classes/base-repository.ts"],"sourcesContent":["/**\n * BaseRepository<TEntity>\n *\n * Abstract base class providing standard CRUD operations via Drizzle ORM.\n * Every generated repository extends this class.\n *\n * Family-specific bases (CrmEntityRepository, etc.) extend this in v0.1\n * without any changes to BaseRepository.\n *\n * NOT @Injectable — concrete repositories are @Injectable and inject DRIZZLE.\n */\nimport { eq, inArray, isNull, sql } from 'drizzle-orm';\nimport type { PgTableWithColumns, PgColumn } from 'drizzle-orm/pg-core';\nimport type { SQL } from 'drizzle-orm';\nimport type { DrizzleClient } from '../types/drizzle';\n\n// ============================================================================\n// Interfaces\n// ============================================================================\n\n/**\n * Behavior flags for the repository. Controls automatic timestamp injection\n * and soft-delete filtering.\n */\nexport interface BehaviorConfig {\n timestamps: boolean;\n softDelete: boolean;\n userTracking: boolean;\n}\n\n/**\n * Options for the list() method.\n */\nexport interface ListOptions {\n where?: SQL;\n limit?: number;\n offset?: number;\n orderBy?: PgColumn | SQL;\n}\n\n// ============================================================================\n// BaseRepository\n// ============================================================================\n\nexport abstract class BaseRepository<TEntity> {\n /**\n * The Drizzle table schema for this entity.\n * Concrete repositories declare this as a class property.\n */\n protected abstract readonly table: PgTableWithColumns<any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n /**\n * Behavior flags controlling automatic behavior injection.\n * Override in concrete repositories to enable behaviors.\n */\n protected readonly behaviors: BehaviorConfig = {\n timestamps: false,\n softDelete: false,\n userTracking: false,\n };\n\n protected readonly db: DrizzleClient;\n\n constructor(db: DrizzleClient) {\n this.db = db;\n }\n\n // ============================================================================\n // Read Operations\n // ============================================================================\n\n /**\n * Find a single entity by its primary key.\n * Returns null if not found (or soft-deleted when softDelete=true).\n */\n async findById(id: string): Promise<TEntity | null> {\n const rows = await this.baseQuery()\n .where(eq(this.table['id'], id))\n .limit(1);\n return (rows[0] as TEntity) ?? null;\n }\n\n /**\n * Find multiple entities by their primary keys.\n * Returns empty array immediately for empty input (avoids DB errors).\n */\n async findByIds(ids: string[]): Promise<TEntity[]> {\n if (ids.length === 0) return [];\n const rows = await this.baseQuery().where(inArray(this.table['id'], ids));\n return rows as TEntity[];\n }\n\n /**\n * List entities with optional filtering, pagination, and ordering.\n */\n async list(options?: ListOptions): Promise<TEntity[]> {\n let query = this.baseQuery();\n\n if (options?.where) {\n query = query.where(options.where) as typeof query;\n }\n if (options?.orderBy) {\n query = query.orderBy(options.orderBy as SQL) as typeof query;\n }\n if (options?.limit !== undefined) {\n query = query.limit(options.limit) as typeof query;\n }\n if (options?.offset !== undefined) {\n query = query.offset(options.offset) as typeof query;\n }\n\n const rows = await query;\n return rows as TEntity[];\n }\n\n /**\n * Count entities matching an optional WHERE clause.\n * Soft-deleted rows are always excluded when softDelete=true.\n */\n async count(where?: SQL): Promise<number> {\n let query = this.db\n .select({ count: sql<number>`cast(count(*) as integer)` })\n .from(this.table);\n\n const conditions: SQL[] = [];\n if (this.behaviors.softDelete) {\n conditions.push(isNull(this.table['deletedAt']));\n }\n if (where) {\n conditions.push(where);\n }\n\n if (conditions.length === 1) {\n query = query.where(conditions[0]) as typeof query;\n } else if (conditions.length > 1) {\n // Combine with AND by building the condition inline\n const { and } = await import('drizzle-orm');\n query = query.where(and(...conditions)) as typeof query;\n }\n\n const rows = await query;\n return rows[0]?.count ?? 0;\n }\n\n /**\n * Check whether an entity with the given id exists.\n */\n async exists(id: string): Promise<boolean> {\n const result = await this.findById(id);\n return result !== null;\n }\n\n // ============================================================================\n // Write Operations\n // ============================================================================\n\n /**\n * Insert a new entity. Timestamps are auto-injected when timestamps=true.\n */\n async create(input: Partial<TEntity>): Promise<TEntity> {\n const data = this.withTimestamps(input as Record<string, unknown>, 'create');\n const rows = await this.db\n .insert(this.table)\n .values(data as any) // eslint-disable-line @typescript-eslint/no-explicit-any\n .returning();\n return rows[0] as TEntity;\n }\n\n /**\n * Update an existing entity by id. updatedAt is auto-injected when timestamps=true.\n * Returns the updated entity.\n */\n async update(id: string, input: Partial<TEntity>): Promise<TEntity> {\n const data = this.withTimestamps(input as Record<string, unknown>, 'update');\n const rows = await this.db\n .update(this.table)\n .set(data as any) // eslint-disable-line @typescript-eslint/no-explicit-any\n .where(eq(this.table['id'], id))\n .returning();\n return rows[0] as TEntity;\n }\n\n /**\n * Delete an entity by id.\n * - softDelete=true: sets deletedAt to current timestamp\n * - softDelete=false: hard-deletes the row\n */\n async delete(id: string): Promise<void> {\n if (this.behaviors.softDelete) {\n await this.db\n .update(this.table)\n .set({ deletedAt: new Date() } as any) // eslint-disable-line @typescript-eslint/no-explicit-any\n .where(eq(this.table['id'], id));\n } else {\n await this.db\n .delete(this.table)\n .where(eq(this.table['id'], id));\n }\n }\n\n /**\n * Insert or update multiple entities.\n * Default naive implementation — family repositories override with\n * proper conflict-target upsert (e.g., CrmEntityRepository).\n */\n async upsertMany(inputs: Array<Partial<TEntity>>): Promise<TEntity[]> {\n return Promise.all(inputs.map((input) => this.create(input)));\n }\n\n // ============================================================================\n // Protected Helpers\n // ============================================================================\n\n /**\n * Base SELECT query that automatically excludes soft-deleted rows\n * when softDelete behavior is enabled.\n */\n protected baseQuery() {\n const query = this.db.select().from(this.table).$dynamic();\n if (this.behaviors.softDelete) {\n return query.where(isNull(this.table['deletedAt']));\n }\n return query;\n }\n\n /**\n * Merge timestamp fields into an input object.\n * - mode='create': adds createdAt and updatedAt\n * - mode='update': adds updatedAt only\n *\n * No-op when timestamps behavior is disabled.\n */\n protected withTimestamps(\n input: Record<string, unknown>,\n mode: 'create' | 'update',\n ): Record<string, unknown> {\n if (!this.behaviors.timestamps) return input;\n const now = new Date();\n if (mode === 'create') {\n return { ...input, createdAt: now, updatedAt: now };\n }\n return { ...input, updatedAt: now };\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QAAI,KAAK,UAAU,YAAY;AAC7B,YAAM,KAAK,GACR,OAAO,KAAK,KAAK,EACjB,IAAI,EAAE,WAAW,oBAAI,KAAK,EAAE,CAAQ,EACpC,MAAM,GAAG,KAAK,MAAM,IAAI,GAAG,EAAE,CAAC;AAAA,IACnC,OAAO;AACL,YAAM,KAAK,GACR,OAAO,KAAK,KAAK,EACjB,MAAM,GAAG,KAAK,MAAM,IAAI,GAAG,EAAE,CAAC;AAAA,IACnC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,WAAW,QAAqD;AACpE,WAAO,QAAQ,IAAI,OAAO,IAAI,CAAC,UAAU,KAAK,OAAO,KAAK,CAAC,CAAC;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUU,YAAY;AACpB,UAAM,QAAQ,KAAK,GAAG,OAAO,EAAE,KAAK,KAAK,KAAK,EAAE,SAAS;AACzD,QAAI,KAAK,UAAU,YAAY;AAC7B,aAAO,MAAM,MAAM,OAAO,KAAK,MAAM,WAAW,CAAC,CAAC;AAAA,IACpD;AACA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASU,eACR,OACA,MACyB;AACzB,QAAI,CAAC,KAAK,UAAU,WAAY,QAAO;AACvC,UAAM,MAAM,oBAAI,KAAK;AACrB,QAAI,SAAS,UAAU;AACrB,aAAO,EAAE,GAAG,OAAO,WAAW,KAAK,WAAW,IAAI;AAAA,IACpD;AACA,WAAO,EAAE,GAAG,OAAO,WAAW,IAAI;AAAA,EACpC;AACF;","names":[]}
@@ -0,0 +1,98 @@
1
+ import { IEventBus } from '../subsystems/events/event-bus.protocol.js';
2
+ import '../types/drizzle.js';
3
+ import 'drizzle-orm/node-postgres';
4
+
5
+ /**
6
+ * BaseService<TRepo, TEntity>
7
+ *
8
+ * Abstract base class providing 8 CRUD pass-through methods delegating to
9
+ * an injected repository. Every generated service extends this class.
10
+ *
11
+ * Lifecycle event emission (LIFECYCLE + CHANGE categories) is built into
12
+ * create/update/delete — matching pattern-stack's BaseService. Events are
13
+ * fire-and-forget: emission never fails the CRUD operation. If no IEventBus
14
+ * is injected (eventBus is undefined), emission is silently skipped.
15
+ *
16
+ * Generated services set `entityName` and optionally inject `eventBus` via
17
+ * NestJS property injection (@Inject(EVENT_BUS) @Optional()).
18
+ *
19
+ * Note: @Injectable() is applied on concrete services (not here) so that
20
+ * NestJS DI metadata is emitted at the concrete class level. This matches
21
+ * the pattern established by BaseRepository.
22
+ */
23
+
24
+ /**
25
+ * Structural interface that BaseRepository satisfies.
26
+ * Use this as the TRepo constraint so BaseService is not coupled to the
27
+ * concrete Drizzle-backed BaseRepository.
28
+ */
29
+ interface IBaseRepository<TEntity> {
30
+ findById(id: string): Promise<TEntity | null>;
31
+ findByIds(ids: string[]): Promise<TEntity[]>;
32
+ list(options?: unknown): Promise<TEntity[]>;
33
+ count(where?: unknown): Promise<number>;
34
+ exists(id: string): Promise<boolean>;
35
+ create(input: Partial<TEntity>): Promise<TEntity>;
36
+ update(id: string, input: Partial<TEntity>): Promise<TEntity>;
37
+ delete(id: string): Promise<void>;
38
+ }
39
+ declare abstract class BaseService<TRepo extends IBaseRepository<TEntity>, TEntity> {
40
+ protected readonly repository: TRepo;
41
+ /**
42
+ * Entity name for event types (e.g., 'account' → 'account.created').
43
+ * Set by generated services. If empty, lifecycle events are skipped.
44
+ */
45
+ protected entityName?: string;
46
+ /**
47
+ * Event bus for lifecycle/change event emission.
48
+ * Injected via @Inject(EVENT_BUS) @Optional() on generated services.
49
+ * If undefined (no events subsystem installed), emission is silently skipped.
50
+ */
51
+ protected eventBus?: IEventBus;
52
+ /**
53
+ * Whether to emit lifecycle events. Default: true.
54
+ * Override to false in entity YAML via behaviors or in the service class.
55
+ */
56
+ protected emitLifecycleEvents: boolean;
57
+ constructor(repository: TRepo);
58
+ /**
59
+ * Find a single entity by its primary key.
60
+ * Returns null if not found.
61
+ */
62
+ findById(id: string): Promise<TEntity | null>;
63
+ /**
64
+ * Find multiple entities by their primary keys.
65
+ */
66
+ findByIds(ids: string[]): Promise<TEntity[]>;
67
+ /**
68
+ * List entities with optional filtering/pagination options.
69
+ */
70
+ list(options?: unknown): Promise<TEntity[]>;
71
+ /**
72
+ * Count entities matching an optional filter.
73
+ */
74
+ count(where?: unknown): Promise<number>;
75
+ /**
76
+ * Check whether an entity with the given id exists.
77
+ */
78
+ exists(id: string): Promise<boolean>;
79
+ /**
80
+ * Insert a new entity.
81
+ * Emits a LIFECYCLE 'created' event with entity snapshot.
82
+ */
83
+ create(input: Partial<TEntity>): Promise<TEntity>;
84
+ /**
85
+ * Update an existing entity by id.
86
+ * Emits a LIFECYCLE 'updated' event + CHANGE events for each modified field.
87
+ */
88
+ update(id: string, input: Partial<TEntity>): Promise<TEntity>;
89
+ /**
90
+ * Delete an entity by id.
91
+ * Emits a LIFECYCLE 'deleted' event.
92
+ */
93
+ delete(id: string): Promise<void>;
94
+ /** Check whether lifecycle event emission is active. */
95
+ private _shouldEmit;
96
+ }
97
+
98
+ export { BaseService, type IBaseRepository };
@@ -0,0 +1,186 @@
1
+ // runtime/base-classes/lifecycle-events.ts
2
+ import { randomUUID } from "crypto";
3
+ var SYSTEM_FIELDS = /* @__PURE__ */ new Set([
4
+ "id",
5
+ "createdAt",
6
+ "updatedAt",
7
+ "deletedAt"
8
+ ]);
9
+ function entitySnapshot(entity) {
10
+ const snap = {};
11
+ for (const [key, value] of Object.entries(entity)) {
12
+ if (!SYSTEM_FIELDS.has(key)) {
13
+ snap[key] = value;
14
+ }
15
+ }
16
+ return snap;
17
+ }
18
+ function diffSnapshots(before, after) {
19
+ const changes = [];
20
+ const allKeys = /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)]);
21
+ for (const key of allKeys) {
22
+ if (SYSTEM_FIELDS.has(key)) continue;
23
+ const oldVal = before[key];
24
+ const newVal = after[key];
25
+ if (oldVal !== newVal && JSON.stringify(oldVal) !== JSON.stringify(newVal)) {
26
+ changes.push({ field: key, oldValue: oldVal, newValue: newVal });
27
+ }
28
+ }
29
+ return changes;
30
+ }
31
+ function buildLifecycleEvent(entityName, action, entityId, snapshot) {
32
+ return {
33
+ id: randomUUID(),
34
+ type: `${entityName}.${action}`,
35
+ aggregateId: entityId,
36
+ aggregateType: entityName,
37
+ payload: snapshot ? { snapshot } : {},
38
+ occurredAt: /* @__PURE__ */ new Date(),
39
+ metadata: { category: "lifecycle" }
40
+ };
41
+ }
42
+ function buildChangeEvents(entityName, entityId, changes) {
43
+ return changes.map((c) => ({
44
+ id: randomUUID(),
45
+ type: `${entityName}.field_changed`,
46
+ aggregateId: entityId,
47
+ aggregateType: entityName,
48
+ payload: {
49
+ fieldName: c.field,
50
+ oldValue: c.oldValue,
51
+ newValue: c.newValue
52
+ },
53
+ occurredAt: /* @__PURE__ */ new Date(),
54
+ metadata: { category: "change" }
55
+ }));
56
+ }
57
+ async function emitSafely(eventBus, events) {
58
+ if (!eventBus || events.length === 0) return;
59
+ try {
60
+ if (events.length === 1) {
61
+ await eventBus.publish(events[0]);
62
+ } else {
63
+ await eventBus.publishMany(events);
64
+ }
65
+ } catch {
66
+ console.warn(`[lifecycle-events] failed to emit ${events.length} event(s)`);
67
+ }
68
+ }
69
+
70
+ // runtime/base-classes/base-service.ts
71
+ var BaseService = class {
72
+ constructor(repository) {
73
+ this.repository = repository;
74
+ }
75
+ repository;
76
+ /**
77
+ * Entity name for event types (e.g., 'account' → 'account.created').
78
+ * Set by generated services. If empty, lifecycle events are skipped.
79
+ */
80
+ entityName;
81
+ /**
82
+ * Event bus for lifecycle/change event emission.
83
+ * Injected via @Inject(EVENT_BUS) @Optional() on generated services.
84
+ * If undefined (no events subsystem installed), emission is silently skipped.
85
+ */
86
+ eventBus;
87
+ /**
88
+ * Whether to emit lifecycle events. Default: true.
89
+ * Override to false in entity YAML via behaviors or in the service class.
90
+ */
91
+ emitLifecycleEvents = true;
92
+ /**
93
+ * Find a single entity by its primary key.
94
+ * Returns null if not found.
95
+ */
96
+ findById(id) {
97
+ return this.repository.findById(id);
98
+ }
99
+ /**
100
+ * Find multiple entities by their primary keys.
101
+ */
102
+ findByIds(ids) {
103
+ return this.repository.findByIds(ids);
104
+ }
105
+ /**
106
+ * List entities with optional filtering/pagination options.
107
+ */
108
+ list(options) {
109
+ return this.repository.list(options);
110
+ }
111
+ /**
112
+ * Count entities matching an optional filter.
113
+ */
114
+ count(where) {
115
+ return this.repository.count(where);
116
+ }
117
+ /**
118
+ * Check whether an entity with the given id exists.
119
+ */
120
+ exists(id) {
121
+ return this.repository.exists(id);
122
+ }
123
+ /**
124
+ * Insert a new entity.
125
+ * Emits a LIFECYCLE 'created' event with entity snapshot.
126
+ */
127
+ async create(input) {
128
+ const result = await this.repository.create(input);
129
+ if (this._shouldEmit()) {
130
+ const snap = entitySnapshot(result);
131
+ const id = result.id;
132
+ const event = buildLifecycleEvent(this.entityName, "created", id, snap);
133
+ void emitSafely(this.eventBus, [event]);
134
+ }
135
+ return result;
136
+ }
137
+ /**
138
+ * Update an existing entity by id.
139
+ * Emits a LIFECYCLE 'updated' event + CHANGE events for each modified field.
140
+ */
141
+ async update(id, input) {
142
+ let before;
143
+ if (this._shouldEmit()) {
144
+ const existing = await this.repository.findById(id);
145
+ if (existing) {
146
+ before = entitySnapshot(existing);
147
+ }
148
+ }
149
+ const result = await this.repository.update(id, input);
150
+ if (this._shouldEmit()) {
151
+ const after = entitySnapshot(result);
152
+ const events = [
153
+ buildLifecycleEvent(this.entityName, "updated", id, after)
154
+ ];
155
+ if (before) {
156
+ const changes = diffSnapshots(before, after);
157
+ if (changes.length > 0) {
158
+ events.push(...buildChangeEvents(this.entityName, id, changes));
159
+ }
160
+ }
161
+ void emitSafely(this.eventBus, events);
162
+ }
163
+ return result;
164
+ }
165
+ /**
166
+ * Delete an entity by id.
167
+ * Emits a LIFECYCLE 'deleted' event.
168
+ */
169
+ async delete(id) {
170
+ await this.repository.delete(id);
171
+ if (this._shouldEmit()) {
172
+ const event = buildLifecycleEvent(this.entityName, "deleted", id);
173
+ void emitSafely(this.eventBus, [event]);
174
+ }
175
+ }
176
+ /** Check whether lifecycle event emission is active. */
177
+ _shouldEmit() {
178
+ return Boolean(
179
+ this.emitLifecycleEvents && this.entityName && this.eventBus
180
+ );
181
+ }
182
+ };
183
+ export {
184
+ BaseService
185
+ };
186
+ //# sourceMappingURL=base-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../runtime/base-classes/lifecycle-events.ts","../../../runtime/base-classes/base-service.ts"],"sourcesContent":["/**\n * Lifecycle event emission for BaseService.\n *\n * Ported from pattern-stack/atoms/patterns/services/base.py — the Python\n * BaseService emits LIFECYCLE and CHANGE events on every CRUD operation.\n * This module provides the same capability for the TypeScript codegen stack.\n *\n * Design:\n * - Fire-and-forget: event emission never fails the CRUD operation.\n * - IEventBus is optional: if no EVENT_BUS is injected, emission is silently\n * skipped. This means base classes work in projects that haven't installed\n * the events subsystem.\n * - LIFECYCLE events carry an entity snapshot in payload.\n * - CHANGE events carry per-field old/new diffs.\n * - Controlled per-entity via `emitLifecycleEvents` flag (default: true).\n */\n\nimport { randomUUID } from 'crypto';\nimport type { IEventBus, DomainEvent } from '../subsystems/events/event-bus.protocol';\n\n// ============================================================================\n// Event categories (subset of pattern-stack's EventCategory)\n// ============================================================================\n\nexport type EventCategory = 'lifecycle' | 'change';\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\n/** System fields excluded from entity snapshots and change diffs. */\nconst SYSTEM_FIELDS = new Set([\n\t'id',\n\t'createdAt',\n\t'updatedAt',\n\t'deletedAt',\n]);\n\n/**\n * Snapshot an entity's field values, excluding system fields.\n * Mirrors pattern-stack's `_get_entity_snapshot()`.\n */\nexport function entitySnapshot(entity: Record<string, unknown>): Record<string, unknown> {\n\tconst snap: Record<string, unknown> = {};\n\tfor (const [key, value] of Object.entries(entity)) {\n\t\tif (!SYSTEM_FIELDS.has(key)) {\n\t\t\tsnap[key] = value;\n\t\t}\n\t}\n\treturn snap;\n}\n\n/**\n * Diff two entity snapshots, returning per-field old/new pairs.\n * Only includes fields that actually changed.\n */\nexport function diffSnapshots(\n\tbefore: Record<string, unknown>,\n\tafter: Record<string, unknown>,\n): Array<{ field: string; oldValue: unknown; newValue: unknown }> {\n\tconst changes: Array<{ field: string; oldValue: unknown; newValue: unknown }> = [];\n\tconst allKeys = new Set([...Object.keys(before), ...Object.keys(after)]);\n\n\tfor (const key of allKeys) {\n\t\tif (SYSTEM_FIELDS.has(key)) continue;\n\t\tconst oldVal = before[key];\n\t\tconst newVal = after[key];\n\t\t// Simple equality — good enough for primitives and nulls.\n\t\t// For deep objects, JSON.stringify comparison.\n\t\tif (oldVal !== newVal && JSON.stringify(oldVal) !== JSON.stringify(newVal)) {\n\t\t\tchanges.push({ field: key, oldValue: oldVal, newValue: newVal });\n\t\t}\n\t}\n\n\treturn changes;\n}\n\n// ============================================================================\n// Event builders\n// ============================================================================\n\nexport function buildLifecycleEvent(\n\tentityName: string,\n\taction: 'created' | 'updated' | 'deleted',\n\tentityId: string,\n\tsnapshot?: Record<string, unknown>,\n): DomainEvent {\n\treturn {\n\t\tid: randomUUID(),\n\t\ttype: `${entityName}.${action}`,\n\t\taggregateId: entityId,\n\t\taggregateType: entityName,\n\t\tpayload: snapshot ? { snapshot } : {},\n\t\toccurredAt: new Date(),\n\t\tmetadata: { category: 'lifecycle' as EventCategory },\n\t};\n}\n\nexport function buildChangeEvents(\n\tentityName: string,\n\tentityId: string,\n\tchanges: Array<{ field: string; oldValue: unknown; newValue: unknown }>,\n): DomainEvent[] {\n\treturn changes.map((c) => ({\n\t\tid: randomUUID(),\n\t\ttype: `${entityName}.field_changed`,\n\t\taggregateId: entityId,\n\t\taggregateType: entityName,\n\t\tpayload: {\n\t\t\tfieldName: c.field,\n\t\t\toldValue: c.oldValue,\n\t\t\tnewValue: c.newValue,\n\t\t},\n\t\toccurredAt: new Date(),\n\t\tmetadata: { category: 'change' as EventCategory },\n\t}));\n}\n\n// ============================================================================\n// Emission helper (fire-and-forget)\n// ============================================================================\n\n/**\n * Emit events to the bus, swallowing errors.\n * Mirrors pattern-stack's `_emit_lifecycle_event()` try/except.\n */\nexport async function emitSafely(\n\teventBus: IEventBus | undefined,\n\tevents: DomainEvent[],\n): Promise<void> {\n\tif (!eventBus || events.length === 0) return;\n\ttry {\n\t\tif (events.length === 1) {\n\t\t\tawait eventBus.publish(events[0]);\n\t\t} else {\n\t\t\tawait eventBus.publishMany(events);\n\t\t}\n\t} catch {\n\t\t// Log but never fail the CRUD operation.\n\t\t// In production, this would use a structured logger.\n\t\tconsole.warn(`[lifecycle-events] failed to emit ${events.length} event(s)`);\n\t}\n}\n","/**\n * BaseService<TRepo, TEntity>\n *\n * Abstract base class providing 8 CRUD pass-through methods delegating to\n * an injected repository. Every generated service extends this class.\n *\n * Lifecycle event emission (LIFECYCLE + CHANGE categories) is built into\n * create/update/delete — matching pattern-stack's BaseService. Events are\n * fire-and-forget: emission never fails the CRUD operation. If no IEventBus\n * is injected (eventBus is undefined), emission is silently skipped.\n *\n * Generated services set `entityName` and optionally inject `eventBus` via\n * NestJS property injection (@Inject(EVENT_BUS) @Optional()).\n *\n * Note: @Injectable() is applied on concrete services (not here) so that\n * NestJS DI metadata is emitted at the concrete class level. This matches\n * the pattern established by BaseRepository.\n */\n\nimport type { IEventBus } from '../subsystems/events/event-bus.protocol';\nimport {\n entitySnapshot,\n diffSnapshots,\n buildLifecycleEvent,\n buildChangeEvents,\n emitSafely,\n} from './lifecycle-events';\n\n// ============================================================================\n// IBaseRepository interface\n// ============================================================================\n\n/**\n * Structural interface that BaseRepository satisfies.\n * Use this as the TRepo constraint so BaseService is not coupled to the\n * concrete Drizzle-backed BaseRepository.\n */\nexport interface IBaseRepository<TEntity> {\n findById(id: string): Promise<TEntity | null>;\n findByIds(ids: string[]): Promise<TEntity[]>;\n list(options?: unknown): Promise<TEntity[]>;\n count(where?: unknown): Promise<number>;\n exists(id: string): Promise<boolean>;\n create(input: Partial<TEntity>): Promise<TEntity>;\n update(id: string, input: Partial<TEntity>): Promise<TEntity>;\n delete(id: string): Promise<void>;\n}\n\n// ============================================================================\n// BaseService\n// ============================================================================\n\nexport abstract class BaseService<TRepo extends IBaseRepository<TEntity>, TEntity> {\n /**\n * Entity name for event types (e.g., 'account' → 'account.created').\n * Set by generated services. If empty, lifecycle events are skipped.\n */\n protected entityName?: string;\n\n /**\n * Event bus for lifecycle/change event emission.\n * Injected via @Inject(EVENT_BUS) @Optional() on generated services.\n * If undefined (no events subsystem installed), emission is silently skipped.\n */\n protected eventBus?: IEventBus;\n\n /**\n * Whether to emit lifecycle events. Default: true.\n * Override to false in entity YAML via behaviors or in the service class.\n */\n protected emitLifecycleEvents = true;\n\n constructor(protected readonly repository: TRepo) {}\n\n /**\n * Find a single entity by its primary key.\n * Returns null if not found.\n */\n findById(id: string): Promise<TEntity | null> {\n return this.repository.findById(id);\n }\n\n /**\n * Find multiple entities by their primary keys.\n */\n findByIds(ids: string[]): Promise<TEntity[]> {\n return this.repository.findByIds(ids);\n }\n\n /**\n * List entities with optional filtering/pagination options.\n */\n list(options?: unknown): Promise<TEntity[]> {\n return this.repository.list(options);\n }\n\n /**\n * Count entities matching an optional filter.\n */\n count(where?: unknown): Promise<number> {\n return this.repository.count(where);\n }\n\n /**\n * Check whether an entity with the given id exists.\n */\n exists(id: string): Promise<boolean> {\n return this.repository.exists(id);\n }\n\n /**\n * Insert a new entity.\n * Emits a LIFECYCLE 'created' event with entity snapshot.\n */\n async create(input: Partial<TEntity>): Promise<TEntity> {\n const result = await this.repository.create(input);\n\n if (this._shouldEmit()) {\n const snap = entitySnapshot(result as Record<string, unknown>);\n const id = (result as Record<string, unknown>).id as string;\n const event = buildLifecycleEvent(this.entityName!, 'created', id, snap);\n void emitSafely(this.eventBus, [event]);\n }\n\n return result;\n }\n\n /**\n * Update an existing entity by id.\n * Emits a LIFECYCLE 'updated' event + CHANGE events for each modified field.\n */\n async update(id: string, input: Partial<TEntity>): Promise<TEntity> {\n // Snapshot before for change diffing\n let before: Record<string, unknown> | undefined;\n if (this._shouldEmit()) {\n const existing = await this.repository.findById(id);\n if (existing) {\n before = entitySnapshot(existing as Record<string, unknown>);\n }\n }\n\n const result = await this.repository.update(id, input);\n\n if (this._shouldEmit()) {\n const after = entitySnapshot(result as Record<string, unknown>);\n const events = [\n buildLifecycleEvent(this.entityName!, 'updated', id, after),\n ];\n // Append per-field CHANGE events\n if (before) {\n const changes = diffSnapshots(before, after);\n if (changes.length > 0) {\n events.push(...buildChangeEvents(this.entityName!, id, changes));\n }\n }\n void emitSafely(this.eventBus, events);\n }\n\n return result;\n }\n\n /**\n * Delete an entity by id.\n * Emits a LIFECYCLE 'deleted' event.\n */\n async delete(id: string): Promise<void> {\n await this.repository.delete(id);\n\n if (this._shouldEmit()) {\n const event = buildLifecycleEvent(this.entityName!, 'deleted', id);\n void emitSafely(this.eventBus, [event]);\n }\n }\n\n /** Check whether lifecycle event emission is active. */\n private _shouldEmit(): boolean {\n return Boolean(\n this.emitLifecycleEvents &&\n this.entityName &&\n this.eventBus,\n );\n }\n}\n"],"mappings":";AAiBA,SAAS,kBAAkB;AAc3B,IAAM,gBAAgB,oBAAI,IAAI;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAC;AAMM,SAAS,eAAe,QAA0D;AACxF,QAAM,OAAgC,CAAC;AACvC,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAClD,QAAI,CAAC,cAAc,IAAI,GAAG,GAAG;AAC5B,WAAK,GAAG,IAAI;AAAA,IACb;AAAA,EACD;AACA,SAAO;AACR;AAMO,SAAS,cACf,QACA,OACiE;AACjE,QAAM,UAA0E,CAAC;AACjF,QAAM,UAAU,oBAAI,IAAI,CAAC,GAAG,OAAO,KAAK,MAAM,GAAG,GAAG,OAAO,KAAK,KAAK,CAAC,CAAC;AAEvE,aAAW,OAAO,SAAS;AAC1B,QAAI,c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,OAAO,IAAI,KAAK;AAErD,QAAI,KAAK,YAAY,GAAG;AACtB,YAAM,QAAQ,eAAe,MAAiC;AAC9D,YAAM,SAAS;AAAA,QACb,oBAAoB,KAAK,YAAa,WAAW,IAAI,KAAK;AAAA,MAC5D;AAEA,UAAI,QAAQ;AACV,cAAM,UAAU,cAAc,QAAQ,KAAK;AAC3C,YAAI,QAAQ,SAAS,GAAG;AACtB,iBAAO,KAAK,GAAG,kBAAkB,KAAK,YAAa,IAAI,OAAO,CAAC;AAAA,QACjE;AAAA,MACF;AACA,WAAK,WAAW,KAAK,UAAU,MAAM;AAAA,IACvC;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAO,IAA2B;AACtC,UAAM,KAAK,WAAW,OAAO,EAAE;AAE/B,QAAI,KAAK,YAAY,GAAG;AACtB,YAAM,QAAQ,oBAAoB,KAAK,YAAa,WAAW,EAAE;AACjE,WAAK,WAAW,KAAK,UAAU,CAAC,KAAK,CAAC;AAAA,IACxC;AAAA,EACF;AAAA;AAAA,EAGQ,cAAuB;AAC7B,WAAO;AAAA,MACL,KAAK,uBACL,KAAK,cACL,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,18 @@
1
+ export { BaseRepository, BehaviorConfig, ListOptions } from './base-repository.js';
2
+ export { BaseService, IBaseRepository } from './base-service.js';
3
+ export { EventCategory, buildChangeEvents, buildLifecycleEvent, diffSnapshots, emitSafely, entitySnapshot } from './lifecycle-events.js';
4
+ export { BaseFindByIdUseCase, BaseListUseCase, IFindByIdService, IListService } from './base-read-use-cases.js';
5
+ export { SyncedEntityRepository } from './synced-entity-repository.js';
6
+ export { ActivityEntityRepository } from './activity-entity-repository.js';
7
+ export { MetadataEntityRepository } from './metadata-entity-repository.js';
8
+ export { KnowledgeEntityRepository } from './knowledge-entity-repository.js';
9
+ export { ISyncedEntityRepository, SyncedEntityService } from './synced-entity-service.js';
10
+ export { ActivityEntityService, IActivityEntityRepository } from './activity-entity-service.js';
11
+ export { IMetadataEntityRepository, MetadataEntityService } from './metadata-entity-service.js';
12
+ export { KnowledgeEntityService } from './knowledge-entity-service.js';
13
+ export { WithAnalytics } from './with-analytics.js';
14
+ import 'drizzle-orm/pg-core';
15
+ import 'drizzle-orm';
16
+ import '../types/drizzle.js';
17
+ import 'drizzle-orm/node-postgres';
18
+ import '../subsystems/events/event-bus.protocol.js';