@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
@@ -5,7 +5,7 @@
5
5
  * Every method:
6
6
  * - Accepts an optional `tenantId`, passed VERBATIM to the owning sibling
7
7
  * port. Observability never re-implements tenant filtering — that is
8
- * the owning subsystem's job (jobs / bridge / sync). See
8
+ * the owning subsystem's job (jobs / bridge / integration). See
9
9
  * `.claude/skills/observability/SKILL.md` §3.
10
10
  * - `undefined` — "not provided"; sibling default semantics apply.
11
11
  * - `null` — explicit cross-tenant match (sibling-specific).
@@ -32,8 +32,8 @@ import type {
32
32
  ListEventsQuery,
33
33
  } from '../events/event-read.protocol';
34
34
  import type { StatusHistogram } from '../bridge/bridge.protocol';
35
- import type { SyncRunSummary } from '../sync/sync-run-recorder.protocol';
36
- import type { CursorSnapshot } from '../sync/sync-cursor-store.protocol';
35
+ import type { IntegrationRunSummary } from '../integration/integration-run-recorder.protocol';
36
+ import type { CursorSnapshot } from '../integration/integration-cursor-store.protocol';
37
37
 
38
38
  /**
39
39
  * One chronological entry in a correlation timeline (OBS-LIST-1). Either a
@@ -98,22 +98,22 @@ export interface IObservability {
98
98
  ): Promise<StatusHistogram>;
99
99
 
100
100
  /**
101
- * Recent `sync_runs` (optionally filtered by subscription). Delegates to
102
- * `ISyncRunRecorder.listRecent`.
101
+ * Recent `integration_runs` (optionally filtered by subscription). Delegates to
102
+ * `IIntegrationRunRecorder.listRecent`.
103
103
  *
104
- * Empty array when the sync subsystem is not installed.
104
+ * Empty array when the integration subsystem is not installed.
105
105
  */
106
- getRecentSyncRuns(
106
+ getRecentIntegrationRuns(
107
107
  limit: number,
108
108
  subscriptionId?: string,
109
109
  tenantId?: string | null,
110
- ): Promise<SyncRunSummary[]>;
110
+ ): Promise<IntegrationRunSummary[]>;
111
111
 
112
112
  /**
113
- * Cursor state per enabled `sync_subscriptions` row. Delegates to
113
+ * Cursor state per enabled `integration_subscriptions` row. Delegates to
114
114
  * `ICursorStore.listAll`.
115
115
  *
116
- * Empty array when the sync subsystem is not installed.
116
+ * Empty array when the integration subsystem is not installed.
117
117
  */
118
118
  getCursors(tenantId?: string | null): Promise<CursorSnapshot[]>;
119
119
 
@@ -163,6 +163,6 @@ export type {
163
163
  EventPage,
164
164
  ListEventsQuery,
165
165
  StatusHistogram,
166
- SyncRunSummary,
166
+ IntegrationRunSummary,
167
167
  CursorSnapshot,
168
168
  };
@@ -2,7 +2,7 @@
2
2
  * ObservabilityService — `IObservability` combiner implementation
3
3
  * (ADR-025, OBS-5).
4
4
  *
5
- * Composes read methods across the jobs, bridge, and sync subsystems via
5
+ * Composes read methods across the jobs, bridge, and integration subsystems via
6
6
  * DI. Owns no state, no schema, no SQL. Every method is a one-line
7
7
  * delegation to the sibling port that already encodes the semantics.
8
8
  *
@@ -50,15 +50,15 @@ import type {
50
50
  import { BRIDGE_DELIVERY_REPO } from '../bridge/bridge.tokens';
51
51
  import type { IJobBridge, StatusHistogram } from '../bridge/bridge.protocol';
52
52
 
53
- import { SYNC_CURSOR_STORE, SYNC_RUN_RECORDER } from '../sync/sync.tokens';
53
+ import { INTEGRATION_CURSOR_STORE, INTEGRATION_RUN_RECORDER } from '../integration/integration.tokens';
54
54
  import type {
55
- ISyncRunRecorder,
56
- SyncRunSummary,
57
- } from '../sync/sync-run-recorder.protocol';
55
+ IIntegrationRunRecorder,
56
+ IntegrationRunSummary,
57
+ } from '../integration/integration-run-recorder.protocol';
58
58
  import type {
59
59
  CursorSnapshot,
60
60
  ICursorStore,
61
- } from '../sync/sync-cursor-store.protocol';
61
+ } from '../integration/integration-cursor-store.protocol';
62
62
 
63
63
  import type {
64
64
  CorrelationTimeline,
@@ -106,10 +106,10 @@ export class ObservabilityService implements IObservability {
106
106
  @Inject(BRIDGE_DELIVERY_REPO)
107
107
  private readonly bridge?: IJobBridge,
108
108
  @Optional()
109
- @Inject(SYNC_RUN_RECORDER)
110
- private readonly syncRuns?: ISyncRunRecorder,
109
+ @Inject(INTEGRATION_RUN_RECORDER)
110
+ private readonly integrationRuns?: IIntegrationRunRecorder,
111
111
  @Optional()
112
- @Inject(SYNC_CURSOR_STORE)
112
+ @Inject(INTEGRATION_CURSOR_STORE)
113
113
  private readonly cursors?: ICursorStore,
114
114
  @Optional()
115
115
  @Inject(EVENT_READ_PORT)
@@ -137,13 +137,13 @@ export class ObservabilityService implements IObservability {
137
137
  return this.bridge.getStatusHistogram(windowHours, tenantId);
138
138
  }
139
139
 
140
- async getRecentSyncRuns(
140
+ async getRecentIntegrationRuns(
141
141
  limit: number,
142
142
  subscriptionId?: string,
143
143
  tenantId?: string | null,
144
- ): Promise<SyncRunSummary[]> {
145
- if (!this.syncRuns) return [];
146
- return this.syncRuns.listRecent(limit, subscriptionId, tenantId);
144
+ ): Promise<IntegrationRunSummary[]> {
145
+ if (!this.integrationRuns) return [];
146
+ return this.integrationRuns.listRecent(limit, subscriptionId, tenantId);
147
147
  }
148
148
 
149
149
  async getCursors(tenantId?: string | null): Promise<CursorSnapshot[]> {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Observability combiner subsystem — DI tokens (ADR-025, OBS-5).
3
3
  *
4
- * String constants (not Symbols), matching the events / bridge / sync
4
+ * String constants (not Symbols), matching the events / bridge / integration
5
5
  * convention. The jobs subsystem uses Symbols for its analogous tokens;
6
6
  * observability stays internally consistent with its sibling combiner
7
7
  * (bridge) because the two are structurally paired (ADR-025).
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Library pattern bootstrap — imports every shipped pattern and registers
3
3
  * it with the shared library registry. Side-effect-only module: importing
4
- * this barrel is what pre-registers `Base`, `Synced`, `Activity`,
4
+ * this barrel is what pre-registers `Base`, `Integrated`, `Activity`,
5
5
  * `Knowledge`, and `Metadata`.
6
6
  *
7
7
  * Adding a new library pattern is two edits: create the `*.pattern.ts`
@@ -14,10 +14,10 @@ import { BasePattern } from './base.pattern.js';
14
14
  import { JunctionPattern } from './junction.pattern.js';
15
15
  import { KnowledgePattern } from './knowledge.pattern.js';
16
16
  import { MetadataPattern } from './metadata.pattern.js';
17
- import { SyncedPattern } from './synced.pattern.js';
17
+ import { IntegratedPattern } from './integrated.pattern.js';
18
18
 
19
19
  registerLibraryPattern(BasePattern);
20
- registerLibraryPattern(SyncedPattern);
20
+ registerLibraryPattern(IntegratedPattern);
21
21
  registerLibraryPattern(ActivityPattern);
22
22
  registerLibraryPattern(KnowledgePattern);
23
23
  registerLibraryPattern(MetadataPattern);
@@ -29,7 +29,7 @@ export {
29
29
  JunctionPattern,
30
30
  KnowledgePattern,
31
31
  MetadataPattern,
32
- SyncedPattern,
32
+ IntegratedPattern,
33
33
  };
34
34
  export {
35
35
  BaseJunctionFields,
@@ -1,35 +1,35 @@
1
1
  /**
2
- * SyncedPattern — adds external-system sync columns and methods.
2
+ * IntegratedPattern — adds external-system integration columns and methods.
3
3
  *
4
- * Replaces the legacy `family: synced` entry in
4
+ * Replaces the legacy `family: integrated` entry in
5
5
  * `templates/entity/new/clean-lite-ps/prompt-extension.js`. Class names,
6
6
  * import paths, and inherited-method comment lines are preserved verbatim
7
7
  * so PATTERN-5's template swap produces byte-identical output for
8
- * pre-existing `family: synced` fixtures.
8
+ * pre-existing `family: integrated` fixtures.
9
9
  *
10
10
  * Implies `external_id_tracking` — the behavior that contributes the
11
11
  * `external_id`, `provider`, and `provider_metadata` columns to the table.
12
- * An entity declaring `pattern: Synced` need not re-declare the behavior.
12
+ * An entity declaring `pattern: Integrated` need not re-declare the behavior.
13
13
  */
14
14
 
15
15
  import { definePattern } from '../pattern-definition.js';
16
16
 
17
- export const SyncedPattern = definePattern({
18
- name: 'Synced',
17
+ export const IntegratedPattern = definePattern({
18
+ name: 'Integrated',
19
19
  extends: ['Base'],
20
- repositoryClass: 'SyncedEntityRepository',
21
- serviceClass: 'SyncedEntityService',
22
- repositoryImport: '@shared/base-classes/synced-entity-repository',
23
- serviceImport: '@shared/base-classes/synced-entity-service',
20
+ repositoryClass: 'IntegratedEntityRepository',
21
+ serviceClass: 'IntegratedEntityService',
22
+ repositoryImport: '@shared/base-classes/integrated-entity-repository',
23
+ serviceImport: '@shared/base-classes/integrated-entity-service',
24
24
  repositoryInheritedMethods: [
25
25
  'findById, findByIds, list, count, exists, create, update, delete, upsertMany',
26
26
  'findByExternalId, findManyByExternalIds, findAllByUserId, findVisibleByUserId',
27
- 'syncUpsertOne, findByExternalIdProjected, softDeleteByExternalId, syncUpsert',
27
+ 'integrationUpsertOne, findByExternalIdProjected, softDeleteByExternalId, integrationUpsert',
28
28
  ],
29
29
  serviceInheritedMethods: [
30
30
  'findById, findByIds, list, count, exists, create, update, delete',
31
31
  'findByExternalId, findAllByUserId, findVisibleByUserId',
32
32
  ],
33
33
  impliedBehaviors: ['external_id_tracking'],
34
- description: 'External CRM/system sync columns and syncUpsert methods',
34
+ description: 'External CRM/system integration columns and integrationUpsert methods',
35
35
  });
@@ -2,7 +2,7 @@
2
2
  * JunctionPattern — top-level discriminator for explicit many-to-many
3
3
  * junction YAML files.
4
4
  *
5
- * Unlike `Activity` / `Synced` / `Metadata` (which attach to an entity via
5
+ * Unlike `Activity` / `Integrated` / `Metadata` (which attach to an entity via
6
6
  * `pattern:` / `patterns:`), `Junction` IS the top-level YAML shape — a
7
7
  * junction file's discriminator is `pattern: Junction`, not `entity:`.
8
8
  * It therefore does not declare `repositoryClass` / `serviceClass`: the
@@ -52,7 +52,7 @@ export type PatternKind = 'domain' | 'orchestration';
52
52
  * store these and look them up by `name`.
53
53
  */
54
54
  export interface PatternDefinition<TConfig = unknown> {
55
- /** Unique name used in YAML — e.g. `pattern: Synced` */
55
+ /** Unique name used in YAML — e.g. `pattern: Integrated` */
56
56
  name: string;
57
57
 
58
58
  /**
@@ -65,7 +65,7 @@ export interface PatternDefinition<TConfig = unknown> {
65
65
 
66
66
  /**
67
67
  * Built-in patterns this extends, by name. Phase 1 supports single-depth
68
- * chains only — a pattern may `extends: ['Synced']` but the transitive
68
+ * chains only — a pattern may `extends: ['Integrated']` but the transitive
69
69
  * chain is not yet resolved. Multi-depth inheritance is deferred until
70
70
  * a real consumer asks.
71
71
  */
@@ -79,7 +79,7 @@ export interface PatternDefinition<TConfig = unknown> {
79
79
  /**
80
80
  * Fully-qualified TypeScript path alias the consumer's tsconfig resolves.
81
81
  * Library patterns use the consumer-installed runtime base class path
82
- * (e.g. `@shared/base-classes/synced-entity-repository`); app patterns
82
+ * (e.g. `@shared/base-classes/integrated-entity-repository`); app patterns
83
83
  * use whatever alias the consumer has configured (e.g. `@/patterns/...`).
84
84
  */
85
85
  repositoryImport?: string;
@@ -1,17 +1,17 @@
1
1
  ---
2
- to: "<%= hasDetection ? (isCleanLitePs ? clpOutputPaths.syncSourceModule : `${basePaths.backendSrc}/${paths.modules}/${name}-sync-source.module.ts`) : null %>"
2
+ to: "<%= hasDetection ? (isCleanLitePs ? clpOutputPaths.integrationSourceModule : `${basePaths.backendSrc}/${paths.modules}/${name}-integration-source.module.ts`) : null %>"
3
3
  skip_if: <%= !hasDetection %>
4
4
  force: true
5
5
  ---
6
6
  <%- typeof generatedBanner !== 'undefined' ? generatedBanner : '' %>
7
7
  import { Module } from '@nestjs/common';
8
- import { buildChangeSource } from '@shared/subsystems/sync';
8
+ import { buildChangeSource } from '@shared/subsystems/integration';
9
9
  import type {
10
10
  DetectionConfig,
11
11
  IChangeSource,
12
12
  PollFetchCallback,
13
- } from '@shared/subsystems/sync';
14
- import type { <%= className %> } from '<%= isCleanLitePs ? clpImports.syncSourceToEntity : imports.moduleToDomain %>';
13
+ } from '@shared/subsystems/integration';
14
+ import type { <%= className %> } from '<%= isCleanLitePs ? clpImports.integrationSourceToEntity : imports.moduleToDomain %>';
15
15
 
16
16
  const <%= name.toUpperCase() %>_DETECTION_CONFIGS: Record<string, DetectionConfig> = <%- detectionConfigsLiteral %>;
17
17
 
@@ -31,7 +31,7 @@ export const <%= name.toUpperCase() %>_CHANGE_SOURCES = Symbol('<%= name.toUpper
31
31
  const fetch = fetches[provider];
32
32
  if (!fetch) {
33
33
  throw new Error(
34
- `<%= className %>SyncSourceModule: missing fetch callback for provider '${provider}' in <%= name.toUpperCase() %>_POLL_FETCH_REGISTRY`,
34
+ `<%= className %>IntegrationSourceModule: missing fetch callback for provider '${provider}' in <%= name.toUpperCase() %>_POLL_FETCH_REGISTRY`,
35
35
  );
36
36
  }
37
37
  return [provider, buildChangeSource(cfg, fetch)];
@@ -41,4 +41,4 @@ export const <%= name.toUpperCase() %>_CHANGE_SOURCES = Symbol('<%= name.toUpper
41
41
  ],
42
42
  exports: [<%= name.toUpperCase() %>_CHANGE_SOURCES],
43
43
  })
44
- export class <%= className %>SyncSourceModule {}
44
+ export class <%= className %>IntegrationSourceModule {}
@@ -1,11 +1,11 @@
1
1
  ---
2
- to: "<%= hasDetection ? (isCleanLitePs ? clpOutputPaths.syncSourceProviders : `${basePaths.backendSrc}/${paths.modules}/${name}-sync-source.providers.ts`) : null %>"
2
+ to: "<%= hasDetection ? (isCleanLitePs ? clpOutputPaths.integrationSourceProviders : `${basePaths.backendSrc}/${paths.modules}/${name}-integration-source.providers.ts`) : null %>"
3
3
  skip_if: <%= !hasDetection %>
4
4
  force: true
5
5
  ---
6
6
  <%- typeof generatedBanner !== 'undefined' ? generatedBanner : '' %>
7
7
  /**
8
- * <%= className %> sync-source providers
8
+ * <%= className %> integration-source providers
9
9
  * Generated by entity codegen — do not edit directly.
10
10
  *
11
11
  * ADR-033.2: typed provider artifacts. Consumers type their registry as
@@ -67,7 +67,7 @@ export const <%= entityNamePlural %> = pgTable(
67
67
  },
68
68
  <%_ if (hasExternalIdTracking) { _%>
69
69
  (t) => [
70
- // external_id_tracking behavior — ON CONFLICT target for syncUpsert
70
+ // external_id_tracking behavior — ON CONFLICT target for integrationUpsert
71
71
  uniqueIndex('uq_<%= entityNamePlural %>_provider_external_id').on(t.provider, t.externalId),
72
72
  ],
73
73
  <%_ } _%>
@@ -116,7 +116,7 @@ import { <%= classNames.searchController %> } from './<%= entityName %>-search.c
116
116
  // exported so sibling modules that compose this entity cross-module (junction
117
117
  // `.list()`, EAV value→definition resolution) inject the home-module instance
118
118
  // — the only place the repo's own deps are wired (e.g. an EAV entity's repo
119
- // injects FieldValueService for the #374 sync dual-write tx). Local-providing
119
+ // injects FieldValueService for the #374 integration dual-write tx). Local-providing
120
120
  // such a repo elsewhere can't satisfy those deps. Use-case internals stay unexported.
121
121
  exports: [<%= classNames.service %>, <%= classNames.repository %>],
122
122
  })
@@ -9,7 +9,7 @@ import fs from 'node:fs';
9
9
  import path from 'node:path';
10
10
  import pluralizePkg from 'pluralize';
11
11
  // The patterns barrel has the side effect of pre-registering the five
12
- // library-shipped patterns (Base / Synced / Activity / Knowledge /
12
+ // library-shipped patterns (Base / Integrated / Activity / Knowledge /
13
13
  // Metadata). App-defined patterns are loaded separately in the parent
14
14
  // prompt.js via loadAppPatterns() against `codegen.config.yaml patterns:`
15
15
  // globs before this helper runs — we only read the registry here.
@@ -108,7 +108,7 @@ export function resolvePatternBaseClasses(entity) {
108
108
  /**
109
109
  * Resolve the behaviors implied by an entity's declared pattern(s).
110
110
  *
111
- * A pattern (e.g. `Synced`) may declare `impliedBehaviors` — behaviors the
111
+ * A pattern (e.g. `Integrated`) may declare `impliedBehaviors` — behaviors the
112
112
  * entity gets for free without re-declaring them in its `behaviors:` array.
113
113
  * Walks every declared pattern (both the `pattern: X` and `patterns: [...]`
114
114
  * shapes), unions their `impliedBehaviors`, and returns a deduped list.
@@ -475,7 +475,7 @@ function collectDrizzleImports(processedFields, belongsTo, hasTimestamps, hasSof
475
475
 
476
476
  // external_id_tracking behavior injects varchar + jsonb columns plus a
477
477
  // unique index over (provider, external_id) — the ON CONFLICT target the
478
- // sync sink's syncUpsert relies on.
478
+ // integration sink's integrationUpsert relies on.
479
479
  if (hasExternalIdTracking) {
480
480
  imports.add('varchar');
481
481
  imports.add('jsonb');
@@ -725,16 +725,16 @@ function processSearchQueries(queriesBlock, processedFields, belongsTo, entityNa
725
725
  }
726
726
 
727
727
  // ============================================================================
728
- // Sync write-surface derivation (#374)
728
+ // Integration write-surface derivation (#374)
729
729
  // ============================================================================
730
730
 
731
731
  /**
732
- * Pre-compute the inbound-sync write surface for a `pattern: Synced` entity.
733
- * Keeps the EJS thin + unit-testable: the template hand-emits the syncConfig
732
+ * Pre-compute the inbound-integration write surface for a `pattern: Integrated` entity.
733
+ * Keeps the EJS thin + unit-testable: the template hand-emits the integrationConfig
734
734
  * literal (so `refTable` can carry a LIVE Drizzle table handle, which
735
735
  * renderPatternConfigLiteral cannot express) using these locals.
736
736
  *
737
- * Returns null when the entity is not Synced.
737
+ * Returns null when the entity is not Integrated.
738
738
  *
739
739
  * @param {string} patternName resolved pattern name
740
740
  * @param {object[]} processedFields nonFkFields (camel + tsType + nullable)
@@ -743,8 +743,8 @@ function processSearchQueries(queriesBlock, processedFields, belongsTo, entityNa
743
743
  * @param {boolean} eavEnabled
744
744
  * @param {boolean} hasSoftDelete
745
745
  */
746
- export function buildSyncSurface(patternName, processedFields, belongsTo, hasTimestamps, eavEnabled, hasSoftDelete, fields) {
747
- if (patternName !== 'Synced') return null;
746
+ export function buildIntegrationSurface(patternName, processedFields, belongsTo, hasTimestamps, eavEnabled, hasSoftDelete, fields) {
747
+ if (patternName !== 'Integrated') return null;
748
748
 
749
749
  // Copy-through columns: every non-FK declared field. external_id_tracking
750
750
  // columns (external_id/provider/provider_metadata) are injected by the
@@ -782,10 +782,10 @@ export function buildSyncSurface(patternName, processedFields, belongsTo, hasTim
782
782
  ...(hasTimestamps ? ['createdAt', 'updatedAt'] : []),
783
783
  ];
784
784
 
785
- // The syncConfig object literal the template hand-emits. fkResolvers carry a
785
+ // The integrationConfig object literal the template hand-emits. fkResolvers carry a
786
786
  // sentinel so the template can swap `refTable` to either 'self' or the live
787
787
  // table identifier.
788
- const syncConfig = {
788
+ const integrationConfig = {
789
789
  conflictTarget: ['provider', 'externalId'],
790
790
  writeColumns,
791
791
  projectionColumns,
@@ -793,7 +793,7 @@ export function buildSyncSurface(patternName, processedFields, belongsTo, hasTim
793
793
  softDelete: !!hasSoftDelete,
794
794
  };
795
795
 
796
- // TSyncWrite fields: externalId:string, copy-through (typed, nullable-aware),
796
+ // TIntegrationWrite fields: externalId:string, copy-through (typed, nullable-aware),
797
797
  // one `<writeKey>?: string | null` per FK, fields?: Record<string, unknown>.
798
798
  const writeFields = processedFields.map((f) => ({
799
799
  camelName: f.camelName,
@@ -804,7 +804,7 @@ export function buildSyncSurface(patternName, processedFields, belongsTo, hasTim
804
804
  tsType: 'string | null',
805
805
  }));
806
806
 
807
- // TSyncProjection fields: id + externalId + copy-through (typed) + each local
807
+ // TIntegrationProjection fields: id + externalId + copy-through (typed) + each local
808
808
  // FK column (typed string, nullable per rel) + createdAt/updatedAt.
809
809
  const projectionFields = [
810
810
  { camelName: 'id', tsType: 'string' },
@@ -841,7 +841,7 @@ export function buildSyncSurface(patternName, processedFields, belongsTo, hasTim
841
841
  const parentTableImports = Array.from(parentImportMap.values());
842
842
 
843
843
  return {
844
- syncConfig,
844
+ integrationConfig,
845
845
  fkResolvers,
846
846
  writeFields,
847
847
  writeFkFields,
@@ -953,7 +953,7 @@ export function buildCleanLitePsLocals(definition, baseLocals) {
953
953
  // Behavior flags (re-read from behaviors array for clean-lite-ps use).
954
954
  //
955
955
  // Fold in the resolved pattern's `impliedBehaviors` (ADR-031): an entity
956
- // declaring e.g. `pattern: Synced` need not re-declare the
956
+ // declaring e.g. `pattern: Integrated` need not re-declare the
957
957
  // `external_id_tracking` behavior — the pattern contributes it. Deduped
958
958
  // with any explicit `behaviors:` entries, explicit-first so order is
959
959
  // stable for pre-existing fixtures. Mirrors the dedup in
@@ -1087,17 +1087,17 @@ export function buildCleanLitePsLocals(definition, baseLocals) {
1087
1087
  declarativeQueries: hasDeclarativeQueries
1088
1088
  ? `${srcRoot}/modules/${entityNamePlural}/use-cases/declarative-queries.ts`
1089
1089
  : null,
1090
- // ADR-033.1 §8 — sync-source module emission for clean-lite-ps. Co-located
1090
+ // ADR-033.1 §8 — integration-source module emission for clean-lite-ps. Co-located
1091
1091
  // with the entity feature module under src/modules/<plural>/. Closes #267.
1092
- syncSourceModule: `${srcRoot}/modules/${entityNamePlural}/${entityName}-sync-source.module.ts`,
1093
- syncSourceProviders: `${srcRoot}/modules/${entityNamePlural}/${entityName}-sync-source.providers.ts`,
1092
+ integrationSourceModule: `${srcRoot}/modules/${entityNamePlural}/${entityName}-integration-source.module.ts`,
1093
+ integrationSourceProviders: `${srcRoot}/modules/${entityNamePlural}/${entityName}-integration-source.providers.ts`,
1094
1094
  };
1095
1095
 
1096
- // Architecture-specific imports for clean-lite-ps. The sync-source module
1096
+ // Architecture-specific imports for clean-lite-ps. The integration-source module
1097
1097
  // imports the entity type sibling-style (`./<entity>.entity`) since the
1098
1098
  // module file lives next to the entity file in the same feature folder.
1099
1099
  const clpImports = {
1100
- syncSourceToEntity: `./${entityName}.entity`,
1100
+ integrationSourceToEntity: `./${entityName}.entity`,
1101
1101
  };
1102
1102
 
1103
1103
  // Class names
@@ -1156,8 +1156,8 @@ export function buildCleanLitePsLocals(definition, baseLocals) {
1156
1156
  zodChainOutput: zodChainForOutput(f),
1157
1157
  }));
1158
1158
 
1159
- // Sync write-surface derivation (#374) — null unless pattern: Synced.
1160
- const syncSurface = buildSyncSurface(
1159
+ // Integration write-surface derivation (#374) — null unless pattern: Integrated.
1160
+ const integrationSurface = buildIntegrationSurface(
1161
1161
  patternName,
1162
1162
  nonFkFields,
1163
1163
  belongsTo,
@@ -1211,16 +1211,16 @@ export function buildCleanLitePsLocals(definition, baseLocals) {
1211
1211
  renderPatternConfigLiteral,
1212
1212
  ...patternConfigClasses,
1213
1213
 
1214
- // Sync write-surface (#374) — emitted only for pattern: Synced. The
1215
- // template hand-emits the syncConfig literal (live refTable handles) +
1216
- // TSyncWrite/TSyncProjection from these.
1217
- hasSyncSurface: syncSurface !== null,
1218
- clpSyncConfig: syncSurface?.syncConfig ?? null,
1219
- clpSyncFkResolvers: syncSurface?.fkResolvers ?? [],
1220
- clpSyncWriteFields: syncSurface?.writeFields ?? [],
1221
- clpSyncWriteFkFields: syncSurface?.writeFkFields ?? [],
1222
- clpSyncProjectionFields: syncSurface?.projectionFields ?? [],
1223
- clpSyncParentTableImports: syncSurface?.parentTableImports ?? [],
1214
+ // Integration write-surface (#374) — emitted only for pattern: Integrated. The
1215
+ // template hand-emits the integrationConfig literal (live refTable handles) +
1216
+ // TIntegrationWrite/TIntegrationProjection from these.
1217
+ hasIntegrationSurface: integrationSurface !== null,
1218
+ clpIntegrationConfig: integrationSurface?.integrationConfig ?? null,
1219
+ clpIntegrationFkResolvers: integrationSurface?.fkResolvers ?? [],
1220
+ clpIntegrationWriteFields: integrationSurface?.writeFields ?? [],
1221
+ clpIntegrationWriteFkFields: integrationSurface?.writeFkFields ?? [],
1222
+ clpIntegrationProjectionFields: integrationSurface?.projectionFields ?? [],
1223
+ clpIntegrationParentTableImports: integrationSurface?.parentTableImports ?? [],
1224
1224
 
1225
1225
  // Behavior flags (also exposed at top level for template use)
1226
1226
  hasTimestamps,
@@ -1248,7 +1248,7 @@ export function buildCleanLitePsLocals(definition, baseLocals) {
1248
1248
  // Output paths
1249
1249
  clpOutputPaths: outputPaths,
1250
1250
 
1251
- // Architecture-specific imports (ADR-033.1 §8 — sync-source closes #267)
1251
+ // Architecture-specific imports (ADR-033.1 §8 — integration-source closes #267)
1252
1252
  clpImports,
1253
1253
 
1254
1254
  // Class names
@@ -22,10 +22,10 @@ import { eq<%= hasMultiFieldQuery ? ', and' : '' %><%= hasOrderedQuery ? ', desc
22
22
  import { sql } from 'drizzle-orm';
23
23
  <% } -%>
24
24
  import { DRIZZLE } from '@shared/constants/tokens';
25
- import type { DrizzleClient<% if (eavValueTable || (typeof hasSyncSurface !== 'undefined' && hasSyncSurface)) { %>, DrizzleTx<% } %> } from '@shared/types/drizzle';
25
+ import type { DrizzleClient<% if (eavValueTable || (typeof hasIntegrationSurface !== 'undefined' && hasIntegrationSurface)) { %>, DrizzleTx<% } %> } from '@shared/types/drizzle';
26
26
  import { <%= repositoryBaseClass %> } from '<%= repositoryBaseImport %>';
27
- <% if (typeof hasSyncSurface !== 'undefined' && hasSyncSurface) { -%>
28
- import type { SyncUpsertConfig } from '@shared/base-classes/sync-upsert-config';
27
+ <% if (typeof hasIntegrationSurface !== 'undefined' && hasIntegrationSurface) { -%>
28
+ import type { IntegrationUpsertConfig } from '@shared/base-classes/integration-upsert-config';
29
29
  <% } -%>
30
30
  <% if (hasTimestamps || hasSoftDelete || hasUserTracking) { -%>
31
31
  import type { BehaviorConfig } from '@shared/base-classes/base-repository';
@@ -34,25 +34,25 @@ import type { BehaviorConfig } from '@shared/base-classes/base-repository';
34
34
  import { FieldValueService } from '../field_values/field_value.service';
35
35
  <% } -%>
36
36
  import { <%= entityNamePlural %>, type <%= classNames.entity %> } from './<%= entityName %>.entity';
37
- <%_ if (typeof hasSyncSurface !== 'undefined' && hasSyncSurface) { _%>
38
- <%_ clpSyncParentTableImports.forEach((imp) => { _%>
37
+ <%_ if (typeof hasIntegrationSurface !== 'undefined' && hasIntegrationSurface) { _%>
38
+ <%_ clpIntegrationParentTableImports.forEach((imp) => { _%>
39
39
  import { <%= imp.table %> } from '<%= imp.importPath %>';
40
40
  <%_ }); _%>
41
41
  <%_ } _%>
42
- <%_ if (typeof hasSyncSurface !== 'undefined' && hasSyncSurface) { _%>
42
+ <%_ if (typeof hasIntegrationSurface !== 'undefined' && hasIntegrationSurface) { _%>
43
43
 
44
44
  /**
45
- * Canonical fields a synced <%= entityName %> write carries (#374). Copy-through
45
+ * Canonical fields a integrated <%= entityName %> write carries (#374). Copy-through
46
46
  * columns are typed from the entity; each FK is named by its parent's external
47
- * id and resolved <%= clpSyncFkResolvers.length > 0 ? 'in syncUpsertOne' : 'as configured' %>. Provider/providerMetadata are persistence
47
+ * id and resolved <%= clpIntegrationFkResolvers.length > 0 ? 'in integrationUpsertOne' : 'as configured' %>. Provider/providerMetadata are persistence
48
48
  * seam, not carried here.
49
49
  */
50
- export interface <%= classNames.entity %>SyncWrite {
50
+ export interface <%= classNames.entity %>IntegrationWrite {
51
51
  readonly externalId: string;
52
- <%_ clpSyncWriteFields.forEach((f) => { _%>
52
+ <%_ clpIntegrationWriteFields.forEach((f) => { _%>
53
53
  readonly <%= f.camelName %>: <%- f.tsType %>;
54
54
  <%_ }); _%>
55
- <%_ clpSyncWriteFkFields.forEach((f) => { _%>
55
+ <%_ clpIntegrationWriteFkFields.forEach((f) => { _%>
56
56
  readonly <%= f.name %>?: <%- f.tsType %>;
57
57
  <%_ }); _%>
58
58
  /** Flat custom-field bag (EAV). */
@@ -60,23 +60,23 @@ export interface <%= classNames.entity %>SyncWrite {
60
60
  }
61
61
 
62
62
  /**
63
- * Canonical-projected view of a <%= entityName %> row, keyed for the sync differ
63
+ * Canonical-projected view of a <%= entityName %> row, keyed for the integration differ
64
64
  * (#374). external_id_tracking columns (provider/providerMetadata) are OMITTED;
65
65
  * externalId is kept.
66
66
  */
67
- export interface <%= classNames.entity %>SyncProjection {
68
- <%_ clpSyncProjectionFields.forEach((f) => { _%>
67
+ export interface <%= classNames.entity %>IntegrationProjection {
68
+ <%_ clpIntegrationProjectionFields.forEach((f) => { _%>
69
69
  readonly <%= f.camelName %>: <%- f.tsType %>;
70
70
  <%_ }); _%>
71
71
  }
72
72
  <%_ } _%>
73
73
 
74
74
  @Injectable()
75
- <%_ if (typeof hasSyncSurface !== 'undefined' && hasSyncSurface) { _%>
75
+ <%_ if (typeof hasIntegrationSurface !== 'undefined' && hasIntegrationSurface) { _%>
76
76
  export class <%= classNames.repository %> extends <%= repositoryBaseClass %><
77
77
  <%= classNames.entity %>,
78
- <%= classNames.entity %>SyncWrite,
79
- <%= classNames.entity %>SyncProjection
78
+ <%= classNames.entity %>IntegrationWrite,
79
+ <%= classNames.entity %>IntegrationProjection
80
80
  > {
81
81
  <%_ } else { _%>
82
82
  export class <%= classNames.repository %> extends <%= repositoryBaseClass %><<%= classNames.entity %>> {
@@ -99,22 +99,22 @@ export class <%= classNames.repository %> extends <%= repositoryBaseClass %><<%=
99
99
  // runtime (identical shape to `behaviors: BehaviorConfig`).
100
100
  protected override readonly patternConfig = <%- renderPatternConfigLiteral(patternConfig, ' ', ' ') %> as const;
101
101
  <% } -%>
102
- <%_ if (typeof hasSyncSurface !== 'undefined' && hasSyncSurface) { _%>
102
+ <%_ if (typeof hasIntegrationSurface !== 'undefined' && hasIntegrationSurface) { _%>
103
103
 
104
- // Inbound-sync write surface (#374). Drives the generic syncUpsertOne /
104
+ // Inbound-integration write surface (#374). Drives the generic integrationUpsertOne /
105
105
  // findByExternalIdProjected / softDeleteByExternalId on the base. FK
106
106
  // resolvers carry LIVE Drizzle table handles ('self' → this.table).
107
- protected readonly syncConfig: SyncUpsertConfig = {
108
- conflictTarget: [<%- clpSyncConfig.conflictTarget.map((c) => `'${c}'`).join(', ') %>],
109
- writeColumns: [<%- clpSyncConfig.writeColumns.map((c) => `'${c}'`).join(', ') %>],
107
+ protected readonly integrationConfig: IntegrationUpsertConfig = {
108
+ conflictTarget: [<%- clpIntegrationConfig.conflictTarget.map((c) => `'${c}'`).join(', ') %>],
109
+ writeColumns: [<%- clpIntegrationConfig.writeColumns.map((c) => `'${c}'`).join(', ') %>],
110
110
  fkResolvers: [
111
- <%_ clpSyncFkResolvers.forEach((fk) => { _%>
111
+ <%_ clpIntegrationFkResolvers.forEach((fk) => { _%>
112
112
  { column: '<%= fk.column %>', writeKey: '<%= fk.writeKey %>', refTable: <%- fk.isSelfFk ? "'self'" : fk.refTable %><%= fk.strict ? ', strict: true' : '' %> },
113
113
  <%_ }); _%>
114
114
  ],
115
- projectionColumns: [<%- clpSyncConfig.projectionColumns.map((c) => `'${c}'`).join(', ') %>],
116
- eav: <%= clpSyncConfig.eav %>,
117
- softDelete: <%= clpSyncConfig.softDelete %>,
115
+ projectionColumns: [<%- clpIntegrationConfig.projectionColumns.map((c) => `'${c}'`).join(', ') %>],
116
+ eav: <%= clpIntegrationConfig.eav %>,
117
+ softDelete: <%= clpIntegrationConfig.softDelete %>,
118
118
  };
119
119
  <%_ } _%>
120
120
 
@@ -128,7 +128,7 @@ export class <%= classNames.repository %> extends <%= repositoryBaseClass %><<%=
128
128
 
129
129
  /**
130
130
  * EAV dual-write override (#374 seam → #124 live path). Delegates to the
131
- * shared FieldValueService so the inbound-sync write joins the same tx.
131
+ * shared FieldValueService so the inbound-integration write joins the same tx.
132
132
  */
133
133
  protected override async writeCustomFields(
134
134
  db: DrizzleTx,