@pattern-stack/codegen 0.10.0 → 0.11.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 (307) hide show
  1. package/CHANGELOG.md +135 -0
  2. package/README.md +5 -5
  3. package/consumer-skills/codegen/SKILL.md +2 -2
  4. package/consumer-skills/events/typed-bus-and-outbox.md +1 -1
  5. package/consumer-skills/{sync → integration}/SKILL.md +29 -29
  6. package/consumer-skills/{sync → integration}/audit-and-detection.md +22 -22
  7. package/consumer-skills/{sync → integration}/change-sources-and-sinks.md +60 -60
  8. package/consumer-skills/subsystems/SKILL.md +64 -8
  9. package/consumer-skills/subsystems/wiring-and-order.md +7 -7
  10. package/dist/runtime/base-classes/index.d.ts +4 -4
  11. package/dist/runtime/base-classes/index.js +35 -35
  12. package/dist/runtime/base-classes/index.js.map +1 -1
  13. package/dist/runtime/base-classes/{synced-entity-repository.d.ts → integrated-entity-repository.d.ts} +15 -15
  14. package/dist/runtime/base-classes/{synced-entity-repository.js → integrated-entity-repository.js} +21 -21
  15. package/dist/runtime/base-classes/integrated-entity-repository.js.map +1 -0
  16. package/dist/runtime/base-classes/{synced-entity-service.d.ts → integrated-entity-service.d.ts} +6 -6
  17. package/dist/runtime/base-classes/{synced-entity-service.js → integrated-entity-service.js} +4 -4
  18. package/dist/runtime/base-classes/integrated-entity-service.js.map +1 -0
  19. package/dist/runtime/base-classes/{sync-upsert-config.d.ts → integration-upsert-config.d.ts} +13 -13
  20. package/dist/runtime/base-classes/integration-upsert-config.js +1 -0
  21. package/dist/runtime/base-classes/{junction-sync-repository.d.ts → junction-integration-repository.d.ts} +11 -11
  22. package/dist/runtime/base-classes/{junction-sync-repository.js → junction-integration-repository.js} +15 -15
  23. package/dist/runtime/base-classes/junction-integration-repository.js.map +1 -0
  24. package/dist/runtime/subsystems/auth/auth-oauth-state.schema.js.map +1 -1
  25. package/dist/runtime/subsystems/auth/auth.module.d.ts +4 -4
  26. package/dist/runtime/subsystems/auth/auth.module.js +3 -3
  27. package/dist/runtime/subsystems/auth/auth.module.js.map +1 -1
  28. package/dist/runtime/subsystems/auth/auth.tokens.d.ts +8 -8
  29. package/dist/runtime/subsystems/auth/auth.tokens.js +6 -6
  30. package/dist/runtime/subsystems/auth/auth.tokens.js.map +1 -1
  31. package/dist/runtime/subsystems/auth/backends/state-store.drizzle-backend.js.map +1 -1
  32. package/dist/runtime/subsystems/auth/controllers/auth.controller.d.ts +2 -2
  33. package/dist/runtime/subsystems/auth/controllers/auth.controller.js +3 -3
  34. package/dist/runtime/subsystems/auth/controllers/auth.controller.js.map +1 -1
  35. package/dist/runtime/subsystems/auth/index.d.ts +3 -3
  36. package/dist/runtime/subsystems/auth/index.js +40 -40
  37. package/dist/runtime/subsystems/auth/index.js.map +1 -1
  38. package/dist/runtime/subsystems/auth/middleware/requester-context.js.map +1 -1
  39. package/dist/runtime/subsystems/auth/protocols/auth-strategy.d.ts +3 -3
  40. package/dist/runtime/subsystems/auth/protocols/{integration-store.d.ts → connection-store.d.ts} +20 -20
  41. package/dist/runtime/subsystems/auth/protocols/connection-store.js +1 -0
  42. package/dist/runtime/subsystems/auth/protocols/provider-strategy.d.ts +3 -3
  43. package/dist/runtime/subsystems/auth/runtime/{integration-broken.error.d.ts → connection-broken.error.d.ts} +5 -5
  44. package/dist/runtime/subsystems/auth/runtime/connection-broken.error.js +19 -0
  45. package/dist/runtime/subsystems/auth/runtime/connection-broken.error.js.map +1 -0
  46. package/dist/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.d.ts +10 -10
  47. package/dist/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.js +28 -28
  48. package/dist/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.js.map +1 -1
  49. package/dist/runtime/subsystems/auth/runtime/with-auth-retry.d.ts +1 -1
  50. package/dist/runtime/subsystems/auth/runtime/with-auth-retry.js +3 -3
  51. package/dist/runtime/subsystems/auth/runtime/with-auth-retry.js.map +1 -1
  52. package/dist/runtime/subsystems/bridge/bridge.module.d.ts +0 -1
  53. package/dist/runtime/subsystems/bridge/bridge.module.js +294 -710
  54. package/dist/runtime/subsystems/bridge/bridge.module.js.map +1 -1
  55. package/dist/runtime/subsystems/bridge/index.d.ts +0 -1
  56. package/dist/runtime/subsystems/bridge/index.js +248 -664
  57. package/dist/runtime/subsystems/bridge/index.js.map +1 -1
  58. package/dist/runtime/subsystems/events/event-bus.drizzle-backend.js +18 -10
  59. package/dist/runtime/subsystems/events/event-bus.drizzle-backend.js.map +1 -1
  60. package/dist/runtime/subsystems/events/events.module.js +43 -244
  61. package/dist/runtime/subsystems/events/events.module.js.map +1 -1
  62. package/dist/runtime/subsystems/events/index.d.ts +0 -1
  63. package/dist/runtime/subsystems/events/index.js +39 -241
  64. package/dist/runtime/subsystems/events/index.js.map +1 -1
  65. package/dist/runtime/subsystems/index.d.ts +7 -7
  66. package/dist/runtime/subsystems/index.js +222 -839
  67. package/dist/runtime/subsystems/index.js.map +1 -1
  68. package/dist/runtime/subsystems/{sync → integration}/build-change-source.d.ts +3 -3
  69. package/dist/runtime/subsystems/{sync → integration}/build-change-source.js +3 -3
  70. package/dist/runtime/subsystems/integration/build-change-source.js.map +1 -0
  71. package/dist/runtime/subsystems/{sync → integration}/deep-equal.differ.d.ts +2 -2
  72. package/dist/runtime/subsystems/{sync → integration}/deep-equal.differ.js +1 -1
  73. package/dist/runtime/subsystems/integration/deep-equal.differ.js.map +1 -0
  74. package/dist/runtime/subsystems/{sync → integration}/detection-config.schema.d.ts +3 -3
  75. package/dist/runtime/subsystems/{sync → integration}/detection-config.schema.js +1 -1
  76. package/dist/runtime/subsystems/integration/detection-config.schema.js.map +1 -0
  77. package/dist/runtime/subsystems/{sync/execute-sync.use-case.d.ts → integration/execute-integration.use-case.d.ts} +13 -13
  78. package/dist/runtime/subsystems/{sync/execute-sync.use-case.js → integration/execute-integration.use-case.js} +30 -30
  79. package/dist/runtime/subsystems/integration/execute-integration.use-case.js.map +1 -0
  80. package/dist/runtime/subsystems/integration/index.d.ts +28 -0
  81. package/dist/runtime/subsystems/{sync → integration}/index.js +171 -171
  82. package/dist/runtime/subsystems/integration/index.js.map +1 -0
  83. package/dist/runtime/subsystems/{sync/sync-audit.schema.d.ts → integration/integration-audit.schema.d.ts} +64 -64
  84. package/dist/runtime/subsystems/{sync/sync-audit.schema.js → integration/integration-audit.schema.js} +47 -47
  85. package/dist/runtime/subsystems/integration/integration-audit.schema.js.map +1 -0
  86. package/dist/runtime/subsystems/{sync/sync-change-source.protocol.d.ts → integration/integration-change-source.protocol.d.ts} +10 -10
  87. package/dist/runtime/subsystems/integration/integration-change-source.protocol.js +1 -0
  88. package/dist/runtime/subsystems/{sync/sync-cursor-store.drizzle-backend.d.ts → integration/integration-cursor-store.drizzle-backend.d.ts} +1 -1
  89. package/dist/runtime/subsystems/{sync/sync-cursor-store.drizzle-backend.js → integration/integration-cursor-store.drizzle-backend.js} +65 -65
  90. package/dist/runtime/subsystems/integration/integration-cursor-store.drizzle-backend.js.map +1 -0
  91. package/dist/runtime/subsystems/{sync/sync-cursor-store.memory-backend.d.ts → integration/integration-cursor-store.memory-backend.d.ts} +6 -6
  92. package/dist/runtime/subsystems/{sync/sync-cursor-store.memory-backend.js → integration/integration-cursor-store.memory-backend.js} +5 -5
  93. package/dist/runtime/subsystems/integration/integration-cursor-store.memory-backend.js.map +1 -0
  94. package/dist/runtime/subsystems/{sync/sync-cursor-store.protocol.d.ts → integration/integration-cursor-store.protocol.d.ts} +13 -13
  95. package/dist/runtime/subsystems/integration/integration-cursor-store.protocol.js +1 -0
  96. package/dist/runtime/subsystems/{sync/sync-errors.d.ts → integration/integration-errors.d.ts} +2 -2
  97. package/dist/runtime/subsystems/{sync/sync-errors.js → integration/integration-errors.js} +3 -3
  98. package/dist/runtime/subsystems/integration/integration-errors.js.map +1 -0
  99. package/dist/runtime/subsystems/{sync/sync-field-diff.protocol.d.ts → integration/integration-field-diff.protocol.d.ts} +2 -2
  100. package/dist/runtime/subsystems/{sync/sync-field-diff.protocol.js → integration/integration-field-diff.protocol.js} +2 -2
  101. package/dist/runtime/subsystems/integration/integration-field-diff.protocol.js.map +1 -0
  102. package/dist/runtime/subsystems/{sync/sync-loopback.protocol.d.ts → integration/integration-loopback.protocol.d.ts} +2 -2
  103. package/dist/runtime/subsystems/integration/integration-loopback.protocol.js +1 -0
  104. package/dist/runtime/subsystems/{sync/sync-middleware.protocol.d.ts → integration/integration-middleware.protocol.d.ts} +5 -5
  105. package/dist/runtime/subsystems/integration/integration-middleware.protocol.js +1 -0
  106. package/dist/runtime/subsystems/{sync/sync-run-recorder.drizzle-backend.d.ts → integration/integration-run-recorder.drizzle-backend.d.ts} +5 -5
  107. package/dist/runtime/subsystems/{sync/sync-run-recorder.drizzle-backend.js → integration/integration-run-recorder.drizzle-backend.js} +73 -73
  108. package/dist/runtime/subsystems/integration/integration-run-recorder.drizzle-backend.js.map +1 -0
  109. package/dist/runtime/subsystems/{sync/sync-run-recorder.memory-backend.d.ts → integration/integration-run-recorder.memory-backend.d.ts} +15 -15
  110. package/dist/runtime/subsystems/{sync/sync-run-recorder.memory-backend.js → integration/integration-run-recorder.memory-backend.js} +11 -11
  111. package/dist/runtime/subsystems/integration/integration-run-recorder.memory-backend.js.map +1 -0
  112. package/dist/runtime/subsystems/{sync/sync-run-recorder.protocol.d.ts → integration/integration-run-recorder.protocol.d.ts} +25 -25
  113. package/dist/runtime/subsystems/integration/integration-run-recorder.protocol.js +1 -0
  114. package/dist/runtime/subsystems/{sync/sync-sink.protocol.d.ts → integration/integration-sink.protocol.d.ts} +5 -5
  115. package/dist/runtime/subsystems/integration/integration-sink.protocol.js +1 -0
  116. package/dist/runtime/subsystems/{sync/sync.module.d.ts → integration/integration.module.d.ts} +24 -24
  117. package/dist/runtime/subsystems/{sync/sync.module.js → integration/integration.module.js} +132 -132
  118. package/dist/runtime/subsystems/integration/integration.module.js.map +1 -0
  119. package/dist/runtime/subsystems/integration/integration.tokens.d.ts +47 -0
  120. package/dist/runtime/subsystems/integration/integration.tokens.js +18 -0
  121. package/dist/runtime/subsystems/integration/integration.tokens.js.map +1 -0
  122. package/dist/runtime/subsystems/{sync → integration}/loopback.middleware.d.ts +5 -5
  123. package/dist/runtime/subsystems/{sync → integration}/loopback.middleware.js +1 -1
  124. package/dist/runtime/subsystems/integration/loopback.middleware.js.map +1 -0
  125. package/dist/runtime/subsystems/{sync → integration}/poll-change-source.d.ts +5 -5
  126. package/dist/runtime/subsystems/{sync → integration}/poll-change-source.js +1 -1
  127. package/dist/runtime/subsystems/integration/poll-change-source.js.map +1 -0
  128. package/dist/runtime/subsystems/{sync → integration}/webhook-change-source.d.ts +5 -5
  129. package/dist/runtime/subsystems/{sync → integration}/webhook-change-source.js +1 -1
  130. package/dist/runtime/subsystems/integration/webhook-change-source.js.map +1 -0
  131. package/dist/runtime/subsystems/jobs/bullmq.config.d.ts +22 -3
  132. package/dist/runtime/subsystems/jobs/bullmq.config.js.map +1 -1
  133. package/dist/runtime/subsystems/jobs/index.d.ts +1 -4
  134. package/dist/runtime/subsystems/jobs/index.js +87 -506
  135. package/dist/runtime/subsystems/jobs/index.js.map +1 -1
  136. package/dist/runtime/subsystems/jobs/job-orchestrator.bullmq-backend.js.map +1 -1
  137. package/dist/runtime/subsystems/jobs/job-worker.bullmq-backend.js +3 -0
  138. package/dist/runtime/subsystems/jobs/job-worker.bullmq-backend.js.map +1 -1
  139. package/dist/runtime/subsystems/jobs/job-worker.module.d.ts +10 -3
  140. package/dist/runtime/subsystems/jobs/job-worker.module.js +248 -664
  141. package/dist/runtime/subsystems/jobs/job-worker.module.js.map +1 -1
  142. package/dist/runtime/subsystems/jobs/jobs-domain.module.d.ts +0 -1
  143. package/dist/runtime/subsystems/jobs/jobs-domain.module.js +89 -391
  144. package/dist/runtime/subsystems/jobs/jobs-domain.module.js.map +1 -1
  145. package/dist/runtime/subsystems/observability/index.d.ts +4 -4
  146. package/dist/runtime/subsystems/observability/index.js +11 -11
  147. package/dist/runtime/subsystems/observability/index.js.map +1 -1
  148. package/dist/runtime/subsystems/observability/observability.module.d.ts +2 -2
  149. package/dist/runtime/subsystems/observability/observability.module.js +11 -11
  150. package/dist/runtime/subsystems/observability/observability.module.js.map +1 -1
  151. package/dist/runtime/subsystems/observability/observability.protocol.d.ts +11 -11
  152. package/dist/runtime/subsystems/observability/observability.service.d.ts +6 -6
  153. package/dist/runtime/subsystems/observability/observability.service.js +11 -11
  154. package/dist/runtime/subsystems/observability/observability.service.js.map +1 -1
  155. package/dist/runtime/subsystems/observability/observability.tokens.d.ts +1 -1
  156. package/dist/runtime/subsystems/observability/observability.tokens.js.map +1 -1
  157. package/dist/runtime/subsystems/observability/reporters/bridge-metrics.reporter.d.ts +3 -3
  158. package/dist/runtime/subsystems/observability/reporters/bridge-metrics.reporter.js.map +1 -1
  159. package/dist/runtime/subsystems/observability/reporters/index.d.ts +3 -3
  160. package/dist/runtime/subsystems/observability/reporters/index.js.map +1 -1
  161. package/dist/src/cli/index.js +412 -302
  162. package/dist/src/cli/index.js.map +1 -1
  163. package/dist/src/index.d.ts +22 -22
  164. package/dist/src/index.js +191 -191
  165. package/dist/src/index.js.map +1 -1
  166. package/examples/auth-integrations/README.md +32 -32
  167. package/examples/auth-integrations/definitions/entities/{integration.yaml → connection.yaml} +10 -10
  168. package/examples/auth-integrations/runtime/{integrations/adapters/integration-grant-sink.adapter.ts → connections/adapters/connection-grant-sink.adapter.ts} +7 -7
  169. package/examples/auth-integrations/runtime/{integrations/adapters/integration-reader.adapter.ts → connections/adapters/connection-reader.adapter.ts} +10 -10
  170. package/examples/auth-integrations/runtime/{integrations/adapters/integration-token-writer.adapter.ts → connections/adapters/connection-token-writer.adapter.ts} +11 -11
  171. package/examples/auth-integrations/runtime/connections/connections-auth.module.ts +81 -0
  172. package/examples/auth-integrations/runtime/{integrations/facade/integrations.service.ts → connections/facade/connections.service.ts} +35 -35
  173. package/examples/auth-integrations/runtime/{integrations → connections}/oauth/use-cases/create-or-update-from-oauth-grant.use-case.ts +11 -11
  174. package/examples/auth-integrations/runtime/{integrations/oauth/use-cases/disconnect-integration.use-case.ts → connections/oauth/use-cases/disconnect-connection.use-case.ts} +6 -6
  175. package/examples/auth-integrations/runtime/connections/oauth/use-cases/list-user-connections.use-case.ts +21 -0
  176. package/examples/auth-integrations/runtime/connections/oauth/use-cases/mark-connection-requires-reauth.use-case.ts +21 -0
  177. package/package.json +1 -1
  178. package/runtime/base-classes/index.ts +8 -8
  179. package/runtime/base-classes/{synced-entity-repository.ts → integrated-entity-repository.ts} +36 -36
  180. package/runtime/base-classes/{synced-entity-service.ts → integrated-entity-service.ts} +6 -6
  181. package/runtime/base-classes/{sync-upsert-config.ts → integration-upsert-config.ts} +12 -12
  182. package/runtime/base-classes/{junction-sync-repository.ts → junction-integration-repository.ts} +28 -28
  183. package/runtime/subsystems/auth/auth-oauth-state.schema.ts +1 -1
  184. package/runtime/subsystems/auth/auth.module.ts +4 -4
  185. package/runtime/subsystems/auth/auth.tokens.ts +7 -7
  186. package/runtime/subsystems/auth/controllers/auth.controller.ts +7 -7
  187. package/runtime/subsystems/auth/index.ts +19 -19
  188. package/runtime/subsystems/auth/protocols/auth-strategy.ts +3 -3
  189. package/runtime/subsystems/auth/protocols/{integration-store.ts → connection-store.ts} +19 -19
  190. package/runtime/subsystems/auth/protocols/provider-strategy.ts +2 -2
  191. package/runtime/subsystems/auth/runtime/{integration-broken.error.ts → connection-broken.error.ts} +5 -5
  192. package/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.ts +35 -35
  193. package/runtime/subsystems/auth/runtime/with-auth-retry.ts +3 -3
  194. package/runtime/subsystems/events/event-bus.drizzle-backend.ts +32 -10
  195. package/runtime/subsystems/events/events.module.ts +38 -6
  196. package/runtime/subsystems/events/index.ts +7 -1
  197. package/runtime/subsystems/index.ts +11 -11
  198. package/runtime/subsystems/{sync → integration}/build-change-source.ts +3 -3
  199. package/runtime/subsystems/{sync → integration}/deep-equal.differ.ts +7 -7
  200. package/runtime/subsystems/{sync → integration}/detection-config.schema.ts +3 -3
  201. package/runtime/subsystems/{sync/execute-sync.use-case.ts → integration/execute-integration.use-case.ts} +40 -40
  202. package/runtime/subsystems/{sync → integration}/index.ts +47 -47
  203. package/runtime/subsystems/{sync/sync-audit.schema.ts → integration/integration-audit.schema.ts} +61 -61
  204. package/runtime/subsystems/{sync/sync-change-source.protocol.ts → integration/integration-change-source.protocol.ts} +9 -9
  205. package/runtime/subsystems/{sync/sync-cursor-store.drizzle-backend.ts → integration/integration-cursor-store.drizzle-backend.ts} +30 -30
  206. package/runtime/subsystems/{sync/sync-cursor-store.memory-backend.ts → integration/integration-cursor-store.memory-backend.ts} +9 -9
  207. package/runtime/subsystems/{sync/sync-cursor-store.protocol.ts → integration/integration-cursor-store.protocol.ts} +13 -13
  208. package/runtime/subsystems/{sync/sync-errors.ts → integration/integration-errors.ts} +3 -3
  209. package/runtime/subsystems/{sync/sync-field-diff.protocol.ts → integration/integration-field-diff.protocol.ts} +2 -2
  210. package/runtime/subsystems/{sync/sync-loopback.protocol.ts → integration/integration-loopback.protocol.ts} +2 -2
  211. package/runtime/subsystems/{sync/sync-middleware.protocol.ts → integration/integration-middleware.protocol.ts} +6 -6
  212. package/runtime/subsystems/{sync/sync-run-recorder.drizzle-backend.ts → integration/integration-run-recorder.drizzle-backend.ts} +39 -39
  213. package/runtime/subsystems/{sync/sync-run-recorder.memory-backend.ts → integration/integration-run-recorder.memory-backend.ts} +23 -23
  214. package/runtime/subsystems/{sync/sync-run-recorder.protocol.ts → integration/integration-run-recorder.protocol.ts} +25 -25
  215. package/runtime/subsystems/{sync/sync-sink.protocol.ts → integration/integration-sink.protocol.ts} +4 -4
  216. package/runtime/subsystems/{sync/sync.module.ts → integration/integration.module.ts} +48 -48
  217. package/runtime/subsystems/integration/integration.tokens.ts +49 -0
  218. package/runtime/subsystems/{sync → integration}/loopback.middleware.ts +5 -5
  219. package/runtime/subsystems/{sync → integration}/poll-change-source.ts +7 -7
  220. package/runtime/subsystems/{sync → integration}/webhook-change-source.ts +7 -7
  221. package/runtime/subsystems/jobs/bullmq.config.ts +23 -3
  222. package/runtime/subsystems/jobs/index.ts +13 -8
  223. package/runtime/subsystems/jobs/job-worker.bullmq-backend.ts +5 -2
  224. package/runtime/subsystems/jobs/job-worker.module.ts +27 -7
  225. package/runtime/subsystems/jobs/jobs-domain.module.ts +27 -2
  226. package/runtime/subsystems/observability/index.ts +1 -1
  227. package/runtime/subsystems/observability/observability.module.ts +2 -2
  228. package/runtime/subsystems/observability/observability.protocol.ts +11 -11
  229. package/runtime/subsystems/observability/observability.service.ts +13 -13
  230. package/runtime/subsystems/observability/observability.tokens.ts +1 -1
  231. package/src/patterns/library/index.ts +4 -4
  232. package/src/patterns/library/{synced.pattern.ts → integrated.pattern.ts} +12 -12
  233. package/src/patterns/library/junction.pattern.ts +1 -1
  234. package/src/patterns/pattern-definition.ts +3 -3
  235. package/templates/entity/new/backend/modules/core/{sync-source.ejs.t → integration-source.ejs.t} +6 -6
  236. package/templates/entity/new/backend/modules/core/{sync-source.providers.ejs.t → integration-source.providers.ejs.t} +2 -2
  237. package/templates/entity/new/clean-lite-ps/entity.ejs.t +1 -1
  238. package/templates/entity/new/clean-lite-ps/module.ejs.t +1 -1
  239. package/templates/entity/new/clean-lite-ps/prompt-extension.js +33 -33
  240. package/templates/entity/new/clean-lite-ps/repository.ejs.t +27 -27
  241. package/templates/entity/new/frontend/collections/collection.ejs.t +26 -1
  242. package/templates/entity/new/frontend/collections/collections-base.ejs.t +11 -0
  243. package/templates/entity/new/frontend/entity/combined.ejs.t +31 -1
  244. package/templates/entity/new/prompt.js +27 -15
  245. package/templates/junction/new/entity.ejs.t +1 -1
  246. package/templates/junction/new/prompt.js +24 -24
  247. package/templates/junction/new/repository.ejs.t +19 -19
  248. package/templates/subsystem/auth/auth-oauth-state.schema.ejs.t +2 -2
  249. package/templates/subsystem/auth-config/prompt.js +1 -1
  250. package/templates/subsystem/auth-integrations/app-module-hook.ejs.t +5 -5
  251. package/templates/subsystem/bridge/prompt.js +1 -1
  252. package/templates/subsystem/events/domain-events.schema.ejs.t +43 -2
  253. package/templates/subsystem/integration/integration-audit.schema.ejs.t +192 -0
  254. package/templates/subsystem/{sync → integration}/prompt.js +12 -12
  255. package/templates/subsystem/{sync-config/codegen-config-sync-block.ejs.t → integration-config/codegen-config-integration-block.ejs.t} +7 -7
  256. package/templates/subsystem/integration-config/prompt.js +22 -0
  257. package/templates/subsystem/jobs/worker.ejs.t +2 -2
  258. package/templates/subsystem/observability/main-hook.ejs.t +1 -1
  259. package/templates/subsystem/observability/prompt.js +1 -1
  260. package/templates/subsystem/openapi-config/prompt.js +1 -1
  261. package/dist/runtime/base-classes/junction-sync-repository.js.map +0 -1
  262. package/dist/runtime/base-classes/sync-upsert-config.js +0 -1
  263. package/dist/runtime/base-classes/synced-entity-repository.js.map +0 -1
  264. package/dist/runtime/base-classes/synced-entity-service.js.map +0 -1
  265. package/dist/runtime/subsystems/auth/protocols/integration-store.js +0 -1
  266. package/dist/runtime/subsystems/auth/runtime/integration-broken.error.js +0 -19
  267. package/dist/runtime/subsystems/auth/runtime/integration-broken.error.js.map +0 -1
  268. package/dist/runtime/subsystems/sync/build-change-source.js.map +0 -1
  269. package/dist/runtime/subsystems/sync/deep-equal.differ.js.map +0 -1
  270. package/dist/runtime/subsystems/sync/detection-config.schema.js.map +0 -1
  271. package/dist/runtime/subsystems/sync/execute-sync.use-case.js.map +0 -1
  272. package/dist/runtime/subsystems/sync/index.d.ts +0 -28
  273. package/dist/runtime/subsystems/sync/index.js.map +0 -1
  274. package/dist/runtime/subsystems/sync/loopback.middleware.js.map +0 -1
  275. package/dist/runtime/subsystems/sync/poll-change-source.js.map +0 -1
  276. package/dist/runtime/subsystems/sync/sync-audit.schema.js.map +0 -1
  277. package/dist/runtime/subsystems/sync/sync-change-source.protocol.js +0 -1
  278. package/dist/runtime/subsystems/sync/sync-cursor-store.drizzle-backend.js.map +0 -1
  279. package/dist/runtime/subsystems/sync/sync-cursor-store.memory-backend.js.map +0 -1
  280. package/dist/runtime/subsystems/sync/sync-cursor-store.protocol.js +0 -1
  281. package/dist/runtime/subsystems/sync/sync-errors.js.map +0 -1
  282. package/dist/runtime/subsystems/sync/sync-field-diff.protocol.js.map +0 -1
  283. package/dist/runtime/subsystems/sync/sync-loopback.protocol.js +0 -1
  284. package/dist/runtime/subsystems/sync/sync-middleware.protocol.js +0 -1
  285. package/dist/runtime/subsystems/sync/sync-run-recorder.drizzle-backend.js.map +0 -1
  286. package/dist/runtime/subsystems/sync/sync-run-recorder.memory-backend.js.map +0 -1
  287. package/dist/runtime/subsystems/sync/sync-run-recorder.protocol.js +0 -1
  288. package/dist/runtime/subsystems/sync/sync-sink.protocol.js +0 -1
  289. package/dist/runtime/subsystems/sync/sync.module.js.map +0 -1
  290. package/dist/runtime/subsystems/sync/sync.tokens.d.ts +0 -47
  291. package/dist/runtime/subsystems/sync/sync.tokens.js +0 -18
  292. package/dist/runtime/subsystems/sync/sync.tokens.js.map +0 -1
  293. package/dist/runtime/subsystems/sync/webhook-change-source.js.map +0 -1
  294. package/examples/auth-integrations/runtime/integrations/integrations-auth.module.ts +0 -81
  295. package/examples/auth-integrations/runtime/integrations/oauth/use-cases/list-user-integrations.use-case.ts +0 -21
  296. package/examples/auth-integrations/runtime/integrations/oauth/use-cases/mark-integration-requires-reauth.use-case.ts +0 -21
  297. package/runtime/subsystems/sync/sync.tokens.ts +0 -49
  298. package/templates/subsystem/sync/sync-audit.schema.ejs.t +0 -192
  299. package/templates/subsystem/sync-config/prompt.js +0 -22
  300. /package/dist/runtime/base-classes/{sync-upsert-config.js.map → integration-upsert-config.js.map} +0 -0
  301. /package/dist/runtime/subsystems/auth/protocols/{integration-store.js.map → connection-store.js.map} +0 -0
  302. /package/dist/runtime/subsystems/{sync/sync-change-source.protocol.js.map → integration/integration-change-source.protocol.js.map} +0 -0
  303. /package/dist/runtime/subsystems/{sync/sync-cursor-store.protocol.js.map → integration/integration-cursor-store.protocol.js.map} +0 -0
  304. /package/dist/runtime/subsystems/{sync/sync-loopback.protocol.js.map → integration/integration-loopback.protocol.js.map} +0 -0
  305. /package/dist/runtime/subsystems/{sync/sync-middleware.protocol.js.map → integration/integration-middleware.protocol.js.map} +0 -0
  306. /package/dist/runtime/subsystems/{sync/sync-run-recorder.protocol.js.map → integration/integration-run-recorder.protocol.js.map} +0 -0
  307. /package/dist/runtime/subsystems/{sync/sync-sink.protocol.js.map → integration/integration-sink.protocol.js.map} +0 -0
@@ -510,9 +510,9 @@ var BaseListUseCase = class {
510
510
  }
511
511
  };
512
512
 
513
- // runtime/base-classes/synced-entity-repository.ts
513
+ // runtime/base-classes/integrated-entity-repository.ts
514
514
  import { and as and2, eq as eq2, inArray as inArray2 } from "drizzle-orm";
515
- var SyncedEntityRepository = class extends BaseRepository {
515
+ var IntegratedEntityRepository = class extends BaseRepository {
516
516
  /**
517
517
  * Find a single entity by its external CRM identifier.
518
518
  */
@@ -536,20 +536,20 @@ var SyncedEntityRepository = class extends BaseRepository {
536
536
  return rows;
537
537
  }
538
538
  // ==========================================================================
539
- // Inbound sync (#374) — canonical→Drizzle write + provider-scoped FK
539
+ // Inbound integration (#374) — canonical→Drizzle write + provider-scoped FK
540
540
  // resolution + EAV dual-write seam, all inside a SINGLE transaction.
541
- // Driven entirely by `this.syncConfig`; the per-entity shape lives there.
541
+ // Driven entirely by `this.integrationConfig`; the per-entity shape lives there.
542
542
  // ==========================================================================
543
543
  /**
544
544
  * Upsert ONE entity by its `(provider, externalId)` identity, in a single
545
545
  * transaction:
546
- * 1. resolve each `syncConfig.fkResolvers` FK (provider-scoped). Strict
546
+ * 1. resolve each `integrationConfig.fkResolvers` FK (provider-scoped). Strict
547
547
  * resolvers throw on unresolved; non-strict leave the column null.
548
548
  * 2. insert-or-update the canonical columns via `onConflictDoUpdate` on the
549
549
  * `conflictTarget`. Resolved FKs are only written into `set` when
550
550
  * non-null this run (no-clobber).
551
551
  * 3. EAV dual-write of `write.fields` via `writeCustomFields` when
552
- * `syncConfig.eav` and the bag is non-empty (same tx).
552
+ * `integrationConfig.eav` and the bag is non-empty (same tx).
553
553
  *
554
554
  * Idempotent: a second call with the same identity updates in place. Returns
555
555
  * the canonical projection (so the orchestrator records `local_id`).
@@ -558,8 +558,8 @@ var SyncedEntityRepository = class extends BaseRepository {
558
558
  * @param provider adapter/provider label persisted + used to scope lookups
559
559
  * @param tx optional outer transaction; when omitted we open our own
560
560
  */
561
- async syncUpsertOne(write, provider, tx) {
562
- const cfg = this.syncConfig;
561
+ async integrationUpsertOne(write, provider, tx) {
562
+ const cfg = this.integrationConfig;
563
563
  const w = write;
564
564
  const run = async (db) => {
565
565
  const resolvedFks = {};
@@ -617,14 +617,14 @@ var SyncedEntityRepository = class extends BaseRepository {
617
617
  return row ? this.toProjection(row) : null;
618
618
  }
619
619
  /**
620
- * Sync "delete" by external id, provider-scoped. When `softDelete: true`,
620
+ * Integration "delete" by external id, provider-scoped. When `softDelete: true`,
621
621
  * sets `deletedAt`. When `softDelete: false`, tombstone-by-clearing: null out
622
622
  * `external_id`/`provider` so the row no longer matches future inbound
623
623
  * changes while preserving local-id references. Returns `{ id }` or `null`.
624
624
  */
625
625
  async softDeleteByExternalId(externalId, provider, tx) {
626
626
  const db = this.runner(tx);
627
- const set = this.syncConfig.softDelete ? { deletedAt: /* @__PURE__ */ new Date(), updatedAt: /* @__PURE__ */ new Date() } : { externalId: null, provider: null, updatedAt: /* @__PURE__ */ new Date() };
627
+ const set = this.integrationConfig.softDelete ? { deletedAt: /* @__PURE__ */ new Date(), updatedAt: /* @__PURE__ */ new Date() } : { externalId: null, provider: null, updatedAt: /* @__PURE__ */ new Date() };
628
628
  const rows = await db.update(this.table).set(set).where(
629
629
  and2(
630
630
  eq2(this.table["provider"], provider),
@@ -634,19 +634,19 @@ var SyncedEntityRepository = class extends BaseRepository {
634
634
  return rows[0] ? { id: rows[0].id } : null;
635
635
  }
636
636
  /**
637
- * Batch sync upsert — concretizes the former abstract stub. Delegates to
638
- * `syncUpsertOne` per input inside one transaction. Inputs are raw partial
637
+ * Batch integration upsert — concretizes the former abstract stub. Delegates to
638
+ * `integrationUpsertOne` per input inside one transaction. Inputs are raw partial
639
639
  * rows: provider is read from each input's own `provider` column; rows
640
640
  * missing `externalId`/`provider` are skipped.
641
641
  */
642
- async syncUpsert(inputs) {
642
+ async integrationUpsert(inputs) {
643
643
  if (inputs.length === 0) return [];
644
644
  return this.db.transaction(async (tx) => {
645
645
  const out = [];
646
646
  for (const input of inputs) {
647
647
  const rec = input;
648
648
  if (!rec["externalId"] || !rec["provider"]) continue;
649
- const proj = await this.syncUpsertOne(
649
+ const proj = await this.integrationUpsertOne(
650
650
  input,
651
651
  rec["provider"],
652
652
  tx
@@ -660,13 +660,13 @@ var SyncedEntityRepository = class extends BaseRepository {
660
660
  }
661
661
  /**
662
662
  * Project a raw row to the canonical differ shape — a generic pick over
663
- * `syncConfig.projectionColumns`. Override only for synthesized projections
663
+ * `integrationConfig.projectionColumns`. Override only for synthesized projections
664
664
  * (e.g. junctions); entities use this verbatim.
665
665
  */
666
666
  toProjection(row) {
667
667
  const r = row;
668
668
  const out = {};
669
- for (const col of this.syncConfig.projectionColumns) out[col] = r[col];
669
+ for (const col of this.integrationConfig.projectionColumns) out[col] = r[col];
670
670
  return out;
671
671
  }
672
672
  /**
@@ -688,7 +688,7 @@ var SyncedEntityRepository = class extends BaseRepository {
688
688
  if (!parentExternalId) {
689
689
  if (fk.strict) {
690
690
  throw new Error(
691
- `${this.constructor.name}.syncUpsertOne: missing required parent external id for '${fk.column}' (writeKey '${fk.writeKey}')`
691
+ `${this.constructor.name}.integrationUpsertOne: missing required parent external id for '${fk.column}' (writeKey '${fk.writeKey}')`
692
692
  );
693
693
  }
694
694
  return null;
@@ -703,7 +703,7 @@ var SyncedEntityRepository = class extends BaseRepository {
703
703
  const id = rows[0]?.id ?? null;
704
704
  if (id === null && fk.strict) {
705
705
  throw new Error(
706
- `${this.constructor.name}.syncUpsertOne: unresolved parent '${parentExternalId}' (provider '${provider}') for '${fk.column}' \u2014 parent not synced yet`
706
+ `${this.constructor.name}.integrationUpsertOne: unresolved parent '${parentExternalId}' (provider '${provider}') for '${fk.column}' \u2014 parent not integrated yet`
707
707
  );
708
708
  }
709
709
  return id;
@@ -717,9 +717,9 @@ var SyncedEntityRepository = class extends BaseRepository {
717
717
  }
718
718
  };
719
719
 
720
- // runtime/base-classes/junction-sync-repository.ts
720
+ // runtime/base-classes/junction-integration-repository.ts
721
721
  import { and as and3, eq as eq3 } from "drizzle-orm";
722
- var JunctionSyncRepository = class extends BaseRepository {
722
+ var JunctionIntegrationRepository = class extends BaseRepository {
723
723
  /**
724
724
  * Upsert ONE junction row by its composite identity, in a single transaction:
725
725
  * 1. resolve the REQUIRED left FK (provider-scoped) — STRICT: missing → throws;
@@ -733,8 +733,8 @@ var JunctionSyncRepository = class extends BaseRepository {
733
733
  * @param provider adapter/provider label used to scope the parent lookups
734
734
  * @param tx optional outer transaction; when omitted we open our own
735
735
  */
736
- async syncUpsertOne(write, provider, tx) {
737
- const cfg = this.syncConfig;
736
+ async integrationUpsertOne(write, provider, tx) {
737
+ const cfg = this.integrationConfig;
738
738
  const w = write;
739
739
  const leftWriteKey = `${cfg.left.column.replace(/Id$/, "")}ExternalId`;
740
740
  const rightWriteKey = `${cfg.right.column.replace(/Id$/, "")}ExternalId`;
@@ -778,7 +778,7 @@ var JunctionSyncRepository = class extends BaseRepository {
778
778
  * parent / no row (a missing "before" side is a create from the differ's view).
779
779
  */
780
780
  async findByExternalIdProjected(externalId, provider) {
781
- const cfg = this.syncConfig;
781
+ const cfg = this.integrationConfig;
782
782
  const parsed = parseCompositeExternalId(externalId, cfg.roleColumn !== null);
783
783
  if (!parsed) return null;
784
784
  const leftId = await this.resolveLoose(this.db, cfg.left.refTable, parsed.left, provider);
@@ -798,12 +798,12 @@ var JunctionSyncRepository = class extends BaseRepository {
798
798
  }
799
799
  /**
800
800
  * Hard-delete the junction by composite externalId. Junctions have no
801
- * `deleted_at` and no external-linkage columns to clear, so a sync "delete"
801
+ * `deleted_at` and no external-linkage columns to clear, so a integration "delete"
802
802
  * removes the row. Resolves both parents NON-throwing, then deletes by the
803
803
  * identity tuple. Returns the composite id, or `null` when nothing matched.
804
804
  */
805
805
  async softDeleteByExternalId(externalId, provider, tx) {
806
- const cfg = this.syncConfig;
806
+ const cfg = this.integrationConfig;
807
807
  const parsed = parseCompositeExternalId(externalId, cfg.roleColumn !== null);
808
808
  if (!parsed) return null;
809
809
  const db = this.runner(tx);
@@ -818,12 +818,12 @@ var JunctionSyncRepository = class extends BaseRepository {
818
818
  * Project a raw junction row to the differ shape: the COMPOSITE externalId
819
819
  * `id` (junctions have no surrogate id) plus the local FK columns, role (when
820
820
  * role-bearing) and timestamps — matching the emitted
821
- * `<Junction>SyncProjection` interface (id + leftId + rightId + role? +
821
+ * `<Junction>IntegrationProjection` interface (id + leftId + rightId + role? +
822
822
  * createdAt + updatedAt). Junction projections are purely structural, so this
823
- * is fully generic over `syncConfig` — no per-junction override is emitted.
823
+ * is fully generic over `integrationConfig` — no per-junction override is emitted.
824
824
  */
825
825
  toProjection(row, write, _provider) {
826
- const cfg = this.syncConfig;
826
+ const cfg = this.integrationConfig;
827
827
  const r = row;
828
828
  const leftExt = write[`${cfg.left.column.replace(/Id$/, "")}ExternalId`];
829
829
  const rightExt = write[`${cfg.right.column.replace(/Id$/, "")}ExternalId`];
@@ -840,7 +840,7 @@ var JunctionSyncRepository = class extends BaseRepository {
840
840
  }
841
841
  /** Build the identity WHERE clause `(left, right[, role])`. */
842
842
  identityWhere(leftId, rightId, role) {
843
- const cfg = this.syncConfig;
843
+ const cfg = this.integrationConfig;
844
844
  const conds = [
845
845
  eq3(this.table[cfg.left.column], leftId),
846
846
  eq3(this.table[cfg.right.column], rightId)
@@ -855,7 +855,7 @@ var JunctionSyncRepository = class extends BaseRepository {
855
855
  const id = await this.resolveLoose(db, refTable, parentExternalId, provider);
856
856
  if (!id) {
857
857
  throw new Error(
858
- `${this.constructor.name}.syncUpsertOne: unresolved parent '${parentExternalId}' (provider '${provider}') for '${column}' \u2014 parent not synced yet`
858
+ `${this.constructor.name}.integrationUpsertOne: unresolved parent '${parentExternalId}' (provider '${provider}') for '${column}' \u2014 parent not integrated yet`
859
859
  );
860
860
  }
861
861
  return id;
@@ -976,8 +976,8 @@ var KnowledgeEntityRepository = class extends BaseRepository {
976
976
  // semanticSearch, findPendingByOpportunityId, updateStatus, updateStatusBatch
977
977
  };
978
978
 
979
- // runtime/base-classes/synced-entity-service.ts
980
- var SyncedEntityService = class extends BaseService {
979
+ // runtime/base-classes/integrated-entity-service.ts
980
+ var IntegratedEntityService = class extends BaseService {
981
981
  /**
982
982
  * Find a single entity by its external CRM identifier.
983
983
  */
@@ -1081,13 +1081,13 @@ export {
1081
1081
  BaseListUseCase,
1082
1082
  BaseRepository,
1083
1083
  BaseService,
1084
- JunctionSyncRepository,
1084
+ IntegratedEntityRepository,
1085
+ IntegratedEntityService,
1086
+ JunctionIntegrationRepository,
1085
1087
  KnowledgeEntityRepository,
1086
1088
  KnowledgeEntityService,
1087
1089
  MetadataEntityRepository,
1088
1090
  MetadataEntityService,
1089
- SyncedEntityRepository,
1090
- SyncedEntityService,
1091
1091
  WithAnalytics,
1092
1092
  buildChangeEvents,
1093
1093
  buildCompositeExternalId,