@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
package/dist/src/index.js CHANGED
@@ -43,7 +43,7 @@ import { parse as parseYaml } from "yaml";
43
43
  // src/schema/entity-definition.schema.ts
44
44
  import { z as z3 } from "zod";
45
45
 
46
- // runtime/subsystems/sync/sync-field-diff.protocol.ts
46
+ // runtime/subsystems/integration/integration-field-diff.protocol.ts
47
47
  import { z } from "zod";
48
48
  var FieldDiffValueSchema = z.object({
49
49
  from: z.unknown(),
@@ -51,7 +51,7 @@ var FieldDiffValueSchema = z.object({
51
51
  });
52
52
  var FieldDiffSchema = z.record(z.string(), FieldDiffValueSchema);
53
53
 
54
- // runtime/subsystems/sync/detection-config.schema.ts
54
+ // runtime/subsystems/integration/detection-config.schema.ts
55
55
  import { z as z2 } from "zod";
56
56
  var FieldMappingSchema = z2.object({
57
57
  source: z2.string().min(1),
@@ -109,21 +109,21 @@ var DetectionConfigSchema = z2.discriminatedUnion("mode", [
109
109
  WebhookModeSchema
110
110
  ]);
111
111
 
112
- // runtime/subsystems/sync/sync.tokens.ts
113
- var SYNC_CHANGE_SOURCE = "SYNC_CHANGE_SOURCE";
114
- var SYNC_CURSOR_STORE = "SYNC_CURSOR_STORE";
115
- var SYNC_FIELD_DIFFER = "SYNC_FIELD_DIFFER";
116
- var SYNC_SINK = "SYNC_SINK";
117
- var SYNC_RUN_RECORDER = "SYNC_RUN_RECORDER";
118
- var SYNC_MODULE_OPTIONS = "SYNC_MODULE_OPTIONS";
119
- var SYNC_MULTI_TENANT = "SYNC_MULTI_TENANT";
112
+ // runtime/subsystems/integration/integration.tokens.ts
113
+ var INTEGRATION_CHANGE_SOURCE = "INTEGRATION_CHANGE_SOURCE";
114
+ var INTEGRATION_CURSOR_STORE = "INTEGRATION_CURSOR_STORE";
115
+ var INTEGRATION_FIELD_DIFFER = "INTEGRATION_FIELD_DIFFER";
116
+ var INTEGRATION_SINK = "INTEGRATION_SINK";
117
+ var INTEGRATION_RUN_RECORDER = "INTEGRATION_RUN_RECORDER";
118
+ var INTEGRATION_MODULE_OPTIONS = "INTEGRATION_MODULE_OPTIONS";
119
+ var INTEGRATION_MULTI_TENANT = "INTEGRATION_MULTI_TENANT";
120
120
 
121
- // runtime/subsystems/sync/sync-errors.ts
121
+ // runtime/subsystems/integration/integration-errors.ts
122
122
  var MissingTenantIdError = class extends Error {
123
123
  name = "MissingTenantIdError";
124
124
  constructor(operation) {
125
125
  super(
126
- `Missing tenantId for sync operation '${operation}'. SyncModule is configured with multiTenant: true \u2014 every call must include a non-null tenantId. Either pass the tenantId or disable multi-tenancy on the module.`
126
+ `Missing tenantId for integration operation '${operation}'. IntegrationModule is configured with multiTenant: true \u2014 every call must include a non-null tenantId. Either pass the tenantId or disable multi-tenancy on the module.`
127
127
  );
128
128
  }
129
129
  };
@@ -134,7 +134,7 @@ function assertTenantId(tenantId, options) {
134
134
  }
135
135
  }
136
136
 
137
- // runtime/subsystems/sync/sync-audit.schema.ts
137
+ // runtime/subsystems/integration/integration-audit.schema.ts
138
138
  import {
139
139
  pgEnum,
140
140
  pgTable,
@@ -147,39 +147,39 @@ import {
147
147
  index,
148
148
  uniqueIndex
149
149
  } from "drizzle-orm/pg-core";
150
- var syncRunDirectionEnum = pgEnum("sync_run_direction", [
150
+ var integrationRunDirectionEnum = pgEnum("integration_run_direction", [
151
151
  "inbound",
152
152
  "outbound"
153
153
  ]);
154
- var syncRunActionEnum = pgEnum("sync_run_action", [
154
+ var integrationRunActionEnum = pgEnum("integration_run_action", [
155
155
  "poll",
156
156
  "cdc",
157
157
  "webhook",
158
158
  "manual",
159
159
  "writeback"
160
160
  ]);
161
- var syncRunStatusEnum = pgEnum("sync_run_status", [
161
+ var integrationRunStatusEnum = pgEnum("integration_run_status", [
162
162
  "running",
163
163
  "success",
164
164
  "no_changes",
165
165
  "failed"
166
166
  ]);
167
- var syncRunItemOperationEnum = pgEnum("sync_run_item_operation", [
167
+ var integrationRunItemOperationEnum = pgEnum("integration_run_item_operation", [
168
168
  "created",
169
169
  "updated",
170
170
  "deleted",
171
171
  "noop"
172
172
  ]);
173
- var syncRunItemStatusEnum = pgEnum("sync_run_item_status", [
173
+ var integrationRunItemStatusEnum = pgEnum("integration_run_item_status", [
174
174
  "success",
175
175
  "failed",
176
176
  "skipped"
177
177
  ]);
178
- var syncSubscriptions = pgTable(
179
- "sync_subscriptions",
178
+ var integrationSubscriptions = pgTable(
179
+ "integration_subscriptions",
180
180
  {
181
181
  id: uuid("id").primaryKey().defaultRandom(),
182
- integrationId: text("integration_id").notNull(),
182
+ connectionId: text("connection_id").notNull(),
183
183
  adapter: text("adapter").notNull(),
184
184
  domain: text("domain").notNull(),
185
185
  externalRef: text("external_ref"),
@@ -194,8 +194,8 @@ var syncSubscriptions = pgTable(
194
194
  * successful run advances it.
195
195
  */
196
196
  cursor: jsonb("cursor").$type(),
197
- lastSyncAt: timestamp("last_sync_at", { withTimezone: true }),
198
- /** Runtime-enforced when `SYNC_MULTI_TENANT` is true; see SYNC-6. */
197
+ lastIntegrationAt: timestamp("last_integration_at", { withTimezone: true }),
198
+ /** Runtime-enforced when `INTEGRATION_MULTI_TENANT` is true; see SYNC-6. */
199
199
  tenantId: text("tenant_id"),
200
200
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
201
201
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
@@ -204,31 +204,31 @@ var syncSubscriptions = pgTable(
204
204
  /**
205
205
  * Composite uniqueness per the epic shape. `external_ref` is nullable;
206
206
  * Postgres treats NULLs as distinct in a UNIQUE constraint, which means
207
- * two rows with the same `(integration_id, adapter, domain)` and NULL
207
+ * two rows with the same `(connection_id, adapter, domain)` and NULL
208
208
  * external_ref are allowed. That's intentional — a subscription with
209
209
  * NULL external_ref covers the full domain, and duplicates there would
210
210
  * be a consumer-layer modeling issue, not a schema concern.
211
211
  */
212
- uqSyncSubscriptionTuple: uniqueIndex("uq_sync_subscriptions_tuple").on(
213
- t.integrationId,
212
+ uqIntegrationSubscriptionTuple: uniqueIndex("uq_integration_subscriptions_tuple").on(
213
+ t.connectionId,
214
214
  t.adapter,
215
215
  t.domain,
216
216
  t.externalRef
217
217
  ),
218
218
  /** Scheduling query: list enabled subscriptions ordered by staleness. */
219
- idxSyncSubscriptionsEnabledLastSync: index(
220
- "idx_sync_subscriptions_enabled_last_sync"
221
- ).on(t.enabled, t.lastSyncAt)
219
+ idxIntegrationSubscriptionsEnabledLastIntegration: index(
220
+ "idx_integration_subscriptions_enabled_last_integration"
221
+ ).on(t.enabled, t.lastIntegrationAt)
222
222
  })
223
223
  );
224
- var syncRuns = pgTable(
225
- "sync_runs",
224
+ var integrationRuns = pgTable(
225
+ "integration_runs",
226
226
  {
227
227
  id: uuid("id").primaryKey().defaultRandom(),
228
- subscriptionId: uuid("subscription_id").notNull().references(() => syncSubscriptions.id, { onDelete: "cascade" }),
229
- direction: syncRunDirectionEnum("direction").notNull(),
230
- action: syncRunActionEnum("action").notNull(),
231
- status: syncRunStatusEnum("status").notNull().default("running"),
228
+ subscriptionId: uuid("subscription_id").notNull().references(() => integrationSubscriptions.id, { onDelete: "cascade" }),
229
+ direction: integrationRunDirectionEnum("direction").notNull(),
230
+ action: integrationRunActionEnum("action").notNull(),
231
+ status: integrationRunStatusEnum("status").notNull().default("running"),
232
232
  recordsFound: integer("records_found").notNull().default(0),
233
233
  recordsProcessed: integer("records_processed").notNull().default(0),
234
234
  cursorBefore: jsonb("cursor_before").$type(),
@@ -237,31 +237,31 @@ var syncRuns = pgTable(
237
237
  error: text("error"),
238
238
  startedAt: timestamp("started_at", { withTimezone: true }).notNull().defaultNow(),
239
239
  completedAt: timestamp("completed_at", { withTimezone: true }),
240
- /** Runtime-enforced when `SYNC_MULTI_TENANT` is true; see SYNC-6. */
240
+ /** Runtime-enforced when `INTEGRATION_MULTI_TENANT` is true; see SYNC-6. */
241
241
  tenantId: text("tenant_id")
242
242
  },
243
243
  (t) => ({
244
244
  /** Timeline read: "most recent runs for this subscription". */
245
- idxSyncRunsSubscriptionStartedAt: index(
246
- "idx_sync_runs_subscription_started_at"
245
+ idxIntegrationRunsSubscriptionStartedAt: index(
246
+ "idx_integration_runs_subscription_started_at"
247
247
  ).on(t.subscriptionId, t.startedAt),
248
248
  /** Stale-run sweeper: "runs that started > N minutes ago and are still running". */
249
- idxSyncRunsStatusStartedAt: index("idx_sync_runs_status_started_at").on(
249
+ idxIntegrationRunsStatusStartedAt: index("idx_integration_runs_status_started_at").on(
250
250
  t.status,
251
251
  t.startedAt
252
252
  )
253
253
  })
254
254
  );
255
- var syncRunItems = pgTable(
256
- "sync_run_items",
255
+ var integrationRunItems = pgTable(
256
+ "integration_run_items",
257
257
  {
258
258
  id: uuid("id").primaryKey().defaultRandom(),
259
- syncRunId: uuid("sync_run_id").notNull().references(() => syncRuns.id, { onDelete: "cascade" }),
259
+ integrationRunId: uuid("integration_run_id").notNull().references(() => integrationRuns.id, { onDelete: "cascade" }),
260
260
  entityType: text("entity_type").notNull(),
261
261
  externalId: text("external_id").notNull(),
262
262
  localId: text("local_id"),
263
- operation: syncRunItemOperationEnum("operation").notNull(),
264
- status: syncRunItemStatusEnum("status").notNull(),
263
+ operation: integrationRunItemOperationEnum("operation").notNull(),
264
+ status: integrationRunItemStatusEnum("status").notNull(),
265
265
  /**
266
266
  * Structured per-field diff — ADR-0003 shape enforced by
267
267
  * `FieldDiffSchema.parse` at the recorder service layer.
@@ -275,23 +275,23 @@ var syncRunItems = pgTable(
275
275
  title: text("title"),
276
276
  error: text("error"),
277
277
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
278
- /** Runtime-enforced when `SYNC_MULTI_TENANT` is true; see SYNC-6. */
278
+ /** Runtime-enforced when `INTEGRATION_MULTI_TENANT` is true; see SYNC-6. */
279
279
  tenantId: text("tenant_id")
280
280
  },
281
281
  (t) => ({
282
282
  /** Ordered timeline within a run. */
283
- idxSyncRunItemsRunCreatedAt: index("idx_sync_run_items_run_created_at").on(
284
- t.syncRunId,
283
+ idxIntegrationRunItemsRunCreatedAt: index("idx_integration_run_items_run_created_at").on(
284
+ t.integrationRunId,
285
285
  t.createdAt
286
286
  ),
287
- /** Per-record history: "every sync that touched opportunity/$extId". */
288
- idxSyncRunItemsEntityExternal: index(
289
- "idx_sync_run_items_entity_external"
287
+ /** Per-record history: "every integration that touched opportunity/$extId". */
288
+ idxIntegrationRunItemsEntityExternal: index(
289
+ "idx_integration_run_items_entity_external"
290
290
  ).on(t.entityType, t.externalId)
291
291
  })
292
292
  );
293
293
 
294
- // runtime/subsystems/sync/sync-cursor-store.memory-backend.ts
294
+ // runtime/subsystems/integration/integration-cursor-store.memory-backend.ts
295
295
  import { Injectable } from "@nestjs/common";
296
296
  var MemoryCursorStore = class {
297
297
  /**
@@ -302,7 +302,7 @@ var MemoryCursorStore = class {
302
302
  /**
303
303
  * Seedable subscription metadata for `listAll` — the memory backend
304
304
  * stores only `subscriptionId → cursor` in its write path, so the
305
- * snapshot shape (`integrationId`, `adapter`, `domain`, `externalRef`,
305
+ * snapshot shape (`connectionId`, `adapter`, `domain`, `externalRef`,
306
306
  * timestamps) has no natural source without test seeding. Tests populate
307
307
  * this map; unseeded entries get empty-string metadata and `new Date(0)`
308
308
  * timestamps so the shape stays stable. Production paths go through the
@@ -322,12 +322,12 @@ var MemoryCursorStore = class {
322
322
  const meta = this.subscriptions.get(subscriptionId);
323
323
  snapshots.push({
324
324
  subscriptionId,
325
- integrationId: meta?.integrationId ?? "",
325
+ connectionId: meta?.connectionId ?? "",
326
326
  adapter: meta?.adapter ?? "",
327
327
  domain: meta?.domain ?? "",
328
328
  externalRef: meta?.externalRef ?? null,
329
329
  cursor: cursor ?? null,
330
- lastSyncAt: meta?.lastSyncAt ?? null,
330
+ lastIntegrationAt: meta?.lastIntegrationAt ?? null,
331
331
  updatedAt: meta?.updatedAt ?? /* @__PURE__ */ new Date(0),
332
332
  tenantId: null
333
333
  });
@@ -346,7 +346,7 @@ MemoryCursorStore = __decorateClass([
346
346
  Injectable()
347
347
  ], MemoryCursorStore);
348
348
 
349
- // runtime/subsystems/sync/sync-run-recorder.memory-backend.ts
349
+ // runtime/subsystems/integration/integration-run-recorder.memory-backend.ts
350
350
  import { Injectable as Injectable2 } from "@nestjs/common";
351
351
  var MemoryRunRecorder = class {
352
352
  /**
@@ -355,14 +355,14 @@ var MemoryRunRecorder = class {
355
355
  */
356
356
  runs = /* @__PURE__ */ new Map();
357
357
  /**
358
- * Items keyed by `sync_run_id`, array order matches insertion order —
359
- * mirrors the timeline the `(sync_run_id, created_at)` index produces
358
+ * Items keyed by `integration_run_id`, array order matches insertion order —
359
+ * mirrors the timeline the `(integration_run_id, created_at)` index produces
360
360
  * in Postgres.
361
361
  */
362
362
  items = /* @__PURE__ */ new Map();
363
363
  /**
364
364
  * Seedable subscription metadata — tests populate this to make
365
- * `listRecent` return meaningful `integrationId` values. The memory
365
+ * `listRecent` return meaningful `connectionId` values. The memory
366
366
  * backend doesn't track subscriptions on its own (only runs + items), so
367
367
  * this map is the intentional extension point: tests write entries for
368
368
  * the subscription ids they use, production code never touches it.
@@ -391,10 +391,10 @@ var MemoryRunRecorder = class {
391
391
  }
392
392
  async recordItem(input) {
393
393
  FieldDiffSchema.parse(input.changedFields);
394
- const bucket = this.items.get(input.syncRunId);
394
+ const bucket = this.items.get(input.integrationRunId);
395
395
  if (!bucket) {
396
396
  throw new Error(
397
- `MemoryRunRecorder.recordItem: no run started for id '${input.syncRunId}'. Call startRun(...) first.`
397
+ `MemoryRunRecorder.recordItem: no run started for id '${input.integrationRunId}'. Call startRun(...) first.`
398
398
  );
399
399
  }
400
400
  bucket.push(input);
@@ -420,10 +420,10 @@ var MemoryRunRecorder = class {
420
420
  return filtered.sort((a, b) => b.startedAt.getTime() - a.startedAt.getTime()).slice(0, limit).map((r) => ({
421
421
  id: r.id,
422
422
  subscriptionId: r.subscriptionId,
423
- // integrationId is only knowable if the test seeded subscriptions
423
+ // connectionId is only knowable if the test seeded subscriptions
424
424
  // metadata; empty string otherwise. The Drizzle backend resolves
425
425
  // it via JOIN, which is the production path.
426
- integrationId: this.subscriptions.get(r.subscriptionId)?.integrationId ?? "",
426
+ connectionId: this.subscriptions.get(r.subscriptionId)?.connectionId ?? "",
427
427
  status: r.status,
428
428
  startedAt: r.startedAt,
429
429
  completedAt: r.completedAt,
@@ -451,7 +451,7 @@ MemoryRunRecorder = __decorateClass([
451
451
  Injectable2()
452
452
  ], MemoryRunRecorder);
453
453
 
454
- // runtime/subsystems/sync/deep-equal.differ.ts
454
+ // runtime/subsystems/integration/deep-equal.differ.ts
455
455
  import { Injectable as Injectable3 } from "@nestjs/common";
456
456
  var DEFAULT_IGNORE_FIELDS = /* @__PURE__ */ new Set([
457
457
  "id",
@@ -550,9 +550,9 @@ function deepEqualObject(a, b) {
550
550
  return true;
551
551
  }
552
552
 
553
- // runtime/subsystems/sync/execute-sync.use-case.ts
553
+ // runtime/subsystems/integration/execute-integration.use-case.ts
554
554
  import { Inject, Injectable as Injectable4, Logger, Optional } from "@nestjs/common";
555
- var ExecuteSyncUseCase = class {
555
+ var ExecuteIntegrationUseCase = class {
556
556
  constructor(source, cursors, differ, sink, recorder, multiTenant = false) {
557
557
  this.source = source;
558
558
  this.cursors = cursors;
@@ -567,7 +567,7 @@ var ExecuteSyncUseCase = class {
567
567
  sink;
568
568
  recorder;
569
569
  multiTenant;
570
- logger = new Logger(ExecuteSyncUseCase.name);
570
+ logger = new Logger(ExecuteIntegrationUseCase.name);
571
571
  async execute(input) {
572
572
  assertTenantId(input.tenantId, {
573
573
  multiTenant: this.multiTenant,
@@ -602,10 +602,10 @@ var ExecuteSyncUseCase = class {
602
602
  recordsFailed++;
603
603
  const message = err instanceof Error ? err.message : String(err);
604
604
  this.logger.warn(
605
- `sync item failed: subscription=${input.subscription.id} externalId=${change.externalId}: ${message}`
605
+ `integration item failed: subscription=${input.subscription.id} externalId=${change.externalId}: ${message}`
606
606
  );
607
607
  await this.recorder.recordItem({
608
- syncRunId: runId,
608
+ integrationRunId: runId,
609
609
  entityType: input.subscription.domain,
610
610
  externalId: change.externalId,
611
611
  operation: change.operation === "deleted" ? "deleted" : "updated",
@@ -628,7 +628,7 @@ var ExecuteSyncUseCase = class {
628
628
  status = "failed";
629
629
  runError = err instanceof Error ? err.message : String(err);
630
630
  this.logger.error(
631
- `sync source failed: subscription=${input.subscription.id}: ${runError}`
631
+ `integration source failed: subscription=${input.subscription.id}: ${runError}`
632
632
  );
633
633
  }
634
634
  if (cursorAdvanced && latestCursor !== null && latestCursor !== void 0) {
@@ -673,7 +673,7 @@ var ExecuteSyncUseCase = class {
673
673
  change.externalId
674
674
  );
675
675
  await this.recorder.recordItem({
676
- syncRunId: runId,
676
+ integrationRunId: runId,
677
677
  entityType: input.subscription.domain,
678
678
  externalId: change.externalId,
679
679
  localId: result?.id ?? null,
@@ -696,7 +696,7 @@ var ExecuteSyncUseCase = class {
696
696
  if (diff === "noop") {
697
697
  if (!this.sink.reprojectsOnNoop) {
698
698
  await this.recorder.recordItem({
699
- syncRunId: runId,
699
+ integrationRunId: runId,
700
700
  entityType: input.subscription.domain,
701
701
  externalId: change.externalId,
702
702
  localId: null,
@@ -713,7 +713,7 @@ var ExecuteSyncUseCase = class {
713
713
  input.provider
714
714
  );
715
715
  await this.recorder.recordItem({
716
- syncRunId: runId,
716
+ integrationRunId: runId,
717
717
  entityType: input.subscription.domain,
718
718
  externalId: change.externalId,
719
719
  localId: noopLocalId,
@@ -730,7 +730,7 @@ var ExecuteSyncUseCase = class {
730
730
  input.provider
731
731
  );
732
732
  await this.recorder.recordItem({
733
- syncRunId: runId,
733
+ integrationRunId: runId,
734
734
  entityType: input.subscription.domain,
735
735
  externalId: change.externalId,
736
736
  localId,
@@ -741,25 +741,25 @@ var ExecuteSyncUseCase = class {
741
741
  });
742
742
  }
743
743
  };
744
- ExecuteSyncUseCase = __decorateClass([
744
+ ExecuteIntegrationUseCase = __decorateClass([
745
745
  Injectable4(),
746
- __decorateParam(0, Inject(SYNC_CHANGE_SOURCE)),
747
- __decorateParam(1, Inject(SYNC_CURSOR_STORE)),
748
- __decorateParam(2, Inject(SYNC_FIELD_DIFFER)),
749
- __decorateParam(3, Inject(SYNC_SINK)),
750
- __decorateParam(4, Inject(SYNC_RUN_RECORDER)),
746
+ __decorateParam(0, Inject(INTEGRATION_CHANGE_SOURCE)),
747
+ __decorateParam(1, Inject(INTEGRATION_CURSOR_STORE)),
748
+ __decorateParam(2, Inject(INTEGRATION_FIELD_DIFFER)),
749
+ __decorateParam(3, Inject(INTEGRATION_SINK)),
750
+ __decorateParam(4, Inject(INTEGRATION_RUN_RECORDER)),
751
751
  __decorateParam(5, Optional()),
752
- __decorateParam(5, Inject(SYNC_MULTI_TENANT))
753
- ], ExecuteSyncUseCase);
752
+ __decorateParam(5, Inject(INTEGRATION_MULTI_TENANT))
753
+ ], ExecuteIntegrationUseCase);
754
754
 
755
- // runtime/subsystems/sync/sync-cursor-store.drizzle-backend.ts
755
+ // runtime/subsystems/integration/integration-cursor-store.drizzle-backend.ts
756
756
  import { Inject as Inject2, Injectable as Injectable5, Optional as Optional2 } from "@nestjs/common";
757
757
  import { and, desc, eq } from "drizzle-orm";
758
758
 
759
759
  // runtime/constants/tokens.ts
760
760
  var DRIZZLE = "DRIZZLE";
761
761
 
762
- // runtime/subsystems/sync/sync-cursor-store.drizzle-backend.ts
762
+ // runtime/subsystems/integration/integration-cursor-store.drizzle-backend.ts
763
763
  var PostgresCursorStore = class {
764
764
  constructor(db, multiTenant) {
765
765
  this.db = db;
@@ -769,15 +769,15 @@ var PostgresCursorStore = class {
769
769
  multiTenant;
770
770
  async get(subscriptionId, tenantId) {
771
771
  const where = this.buildWhere(subscriptionId, tenantId, "cursor.get");
772
- const rows = await this.db.select({ cursor: syncSubscriptions.cursor }).from(syncSubscriptions).where(where).limit(1);
772
+ const rows = await this.db.select({ cursor: integrationSubscriptions.cursor }).from(integrationSubscriptions).where(where).limit(1);
773
773
  if (rows.length === 0) return null;
774
774
  return rows[0]?.cursor ?? null;
775
775
  }
776
776
  async put(subscriptionId, cursor, tenantId) {
777
777
  const where = this.buildWhere(subscriptionId, tenantId, "cursor.put");
778
- await this.db.update(syncSubscriptions).set({
778
+ await this.db.update(integrationSubscriptions).set({
779
779
  cursor,
780
- lastSyncAt: /* @__PURE__ */ new Date(),
780
+ lastIntegrationAt: /* @__PURE__ */ new Date(),
781
781
  updatedAt: /* @__PURE__ */ new Date()
782
782
  }).where(where);
783
783
  }
@@ -786,26 +786,26 @@ var PostgresCursorStore = class {
786
786
  multiTenant: this.multiTenant,
787
787
  operation: "cursor.listAll"
788
788
  });
789
- const where = this.multiTenant ? eq(syncSubscriptions.tenantId, tenantId) : void 0;
789
+ const where = this.multiTenant ? eq(integrationSubscriptions.tenantId, tenantId) : void 0;
790
790
  const rows = await this.db.select({
791
- id: syncSubscriptions.id,
792
- integrationId: syncSubscriptions.integrationId,
793
- adapter: syncSubscriptions.adapter,
794
- domain: syncSubscriptions.domain,
795
- externalRef: syncSubscriptions.externalRef,
796
- cursor: syncSubscriptions.cursor,
797
- lastSyncAt: syncSubscriptions.lastSyncAt,
798
- updatedAt: syncSubscriptions.updatedAt,
799
- tenantId: syncSubscriptions.tenantId
800
- }).from(syncSubscriptions).where(where).orderBy(desc(syncSubscriptions.updatedAt));
791
+ id: integrationSubscriptions.id,
792
+ connectionId: integrationSubscriptions.connectionId,
793
+ adapter: integrationSubscriptions.adapter,
794
+ domain: integrationSubscriptions.domain,
795
+ externalRef: integrationSubscriptions.externalRef,
796
+ cursor: integrationSubscriptions.cursor,
797
+ lastIntegrationAt: integrationSubscriptions.lastIntegrationAt,
798
+ updatedAt: integrationSubscriptions.updatedAt,
799
+ tenantId: integrationSubscriptions.tenantId
800
+ }).from(integrationSubscriptions).where(where).orderBy(desc(integrationSubscriptions.updatedAt));
801
801
  return rows.map((row) => ({
802
802
  subscriptionId: row.id,
803
- integrationId: row.integrationId,
803
+ connectionId: row.connectionId,
804
804
  adapter: row.adapter,
805
805
  domain: row.domain,
806
806
  externalRef: row.externalRef,
807
807
  cursor: row.cursor ?? null,
808
- lastSyncAt: row.lastSyncAt,
808
+ lastIntegrationAt: row.lastIntegrationAt,
809
809
  updatedAt: row.updatedAt,
810
810
  tenantId: row.tenantId
811
811
  }));
@@ -822,24 +822,24 @@ var PostgresCursorStore = class {
822
822
  });
823
823
  if (this.multiTenant) {
824
824
  return and(
825
- eq(syncSubscriptions.id, subscriptionId),
826
- eq(syncSubscriptions.tenantId, tenantId)
825
+ eq(integrationSubscriptions.id, subscriptionId),
826
+ eq(integrationSubscriptions.tenantId, tenantId)
827
827
  );
828
828
  }
829
- return eq(syncSubscriptions.id, subscriptionId);
829
+ return eq(integrationSubscriptions.id, subscriptionId);
830
830
  }
831
831
  };
832
832
  PostgresCursorStore = __decorateClass([
833
833
  Injectable5(),
834
834
  __decorateParam(0, Inject2(DRIZZLE)),
835
835
  __decorateParam(1, Optional2()),
836
- __decorateParam(1, Inject2(SYNC_MULTI_TENANT))
836
+ __decorateParam(1, Inject2(INTEGRATION_MULTI_TENANT))
837
837
  ], PostgresCursorStore);
838
838
 
839
- // runtime/subsystems/sync/sync-run-recorder.drizzle-backend.ts
839
+ // runtime/subsystems/integration/integration-run-recorder.drizzle-backend.ts
840
840
  import { Inject as Inject3, Injectable as Injectable6, Optional as Optional3 } from "@nestjs/common";
841
841
  import { and as and2, desc as desc2, eq as eq2 } from "drizzle-orm";
842
- var DrizzleSyncRunRecorder = class {
842
+ var DrizzleIntegrationRunRecorder = class {
843
843
  constructor(db, multiTenant) {
844
844
  this.db = db;
845
845
  this.multiTenant = multiTenant ?? false;
@@ -851,17 +851,17 @@ var DrizzleSyncRunRecorder = class {
851
851
  multiTenant: this.multiTenant,
852
852
  operation: "startRun"
853
853
  });
854
- const rows = await this.db.insert(syncRuns).values({
854
+ const rows = await this.db.insert(integrationRuns).values({
855
855
  subscriptionId: input.subscriptionId,
856
856
  direction: input.direction,
857
857
  action: input.action,
858
858
  status: "running",
859
859
  cursorBefore: input.cursorBefore ?? null,
860
860
  tenantId: input.tenantId ?? null
861
- }).returning({ id: syncRuns.id });
861
+ }).returning({ id: integrationRuns.id });
862
862
  const id = rows[0]?.id;
863
863
  if (!id) {
864
- throw new Error("DrizzleSyncRunRecorder: INSERT RETURNING produced no id");
864
+ throw new Error("DrizzleIntegrationRunRecorder: INSERT RETURNING produced no id");
865
865
  }
866
866
  return { id };
867
867
  }
@@ -871,8 +871,8 @@ var DrizzleSyncRunRecorder = class {
871
871
  operation: "recordItem"
872
872
  });
873
873
  FieldDiffSchema.parse(input.changedFields);
874
- await this.db.insert(syncRunItems).values({
875
- syncRunId: input.syncRunId,
874
+ await this.db.insert(integrationRunItems).values({
875
+ integrationRunId: input.integrationRunId,
876
876
  entityType: input.entityType,
877
877
  externalId: input.externalId,
878
878
  localId: input.localId ?? null,
@@ -891,29 +891,29 @@ var DrizzleSyncRunRecorder = class {
891
891
  });
892
892
  const conditions = [];
893
893
  if (subscriptionId !== void 0) {
894
- conditions.push(eq2(syncRuns.subscriptionId, subscriptionId));
894
+ conditions.push(eq2(integrationRuns.subscriptionId, subscriptionId));
895
895
  }
896
896
  if (this.multiTenant) {
897
- conditions.push(eq2(syncRuns.tenantId, tenantId));
897
+ conditions.push(eq2(integrationRuns.tenantId, tenantId));
898
898
  }
899
899
  const where = conditions.length === 0 ? void 0 : conditions.length === 1 ? conditions[0] : and2(...conditions);
900
900
  const rows = await this.db.select({
901
- id: syncRuns.id,
902
- subscriptionId: syncRuns.subscriptionId,
903
- integrationId: syncSubscriptions.integrationId,
904
- status: syncRuns.status,
905
- startedAt: syncRuns.startedAt,
906
- completedAt: syncRuns.completedAt,
907
- recordsProcessed: syncRuns.recordsProcessed,
908
- tenantId: syncRuns.tenantId
909
- }).from(syncRuns).innerJoin(
910
- syncSubscriptions,
911
- eq2(syncRuns.subscriptionId, syncSubscriptions.id)
912
- ).where(where).orderBy(desc2(syncRuns.startedAt)).limit(limit);
901
+ id: integrationRuns.id,
902
+ subscriptionId: integrationRuns.subscriptionId,
903
+ connectionId: integrationSubscriptions.connectionId,
904
+ status: integrationRuns.status,
905
+ startedAt: integrationRuns.startedAt,
906
+ completedAt: integrationRuns.completedAt,
907
+ recordsProcessed: integrationRuns.recordsProcessed,
908
+ tenantId: integrationRuns.tenantId
909
+ }).from(integrationRuns).innerJoin(
910
+ integrationSubscriptions,
911
+ eq2(integrationRuns.subscriptionId, integrationSubscriptions.id)
912
+ ).where(where).orderBy(desc2(integrationRuns.startedAt)).limit(limit);
913
913
  return rows.map((row) => ({
914
914
  id: row.id,
915
915
  subscriptionId: row.subscriptionId,
916
- integrationId: row.integrationId,
916
+ connectionId: row.connectionId,
917
917
  status: row.status,
918
918
  startedAt: row.startedAt,
919
919
  completedAt: row.completedAt,
@@ -922,7 +922,7 @@ var DrizzleSyncRunRecorder = class {
922
922
  }));
923
923
  }
924
924
  async completeRun(runId, input) {
925
- await this.db.update(syncRuns).set({
925
+ await this.db.update(integrationRuns).set({
926
926
  status: input.status,
927
927
  recordsFound: input.recordsFound,
928
928
  recordsProcessed: input.recordsProcessed,
@@ -930,27 +930,27 @@ var DrizzleSyncRunRecorder = class {
930
930
  durationMs: input.durationMs,
931
931
  error: input.error ?? null,
932
932
  completedAt: /* @__PURE__ */ new Date()
933
- }).where(eq2(syncRuns.id, runId));
933
+ }).where(eq2(integrationRuns.id, runId));
934
934
  }
935
935
  };
936
- DrizzleSyncRunRecorder = __decorateClass([
936
+ DrizzleIntegrationRunRecorder = __decorateClass([
937
937
  Injectable6(),
938
938
  __decorateParam(0, Inject3(DRIZZLE)),
939
939
  __decorateParam(1, Optional3()),
940
- __decorateParam(1, Inject3(SYNC_MULTI_TENANT))
941
- ], DrizzleSyncRunRecorder);
940
+ __decorateParam(1, Inject3(INTEGRATION_MULTI_TENANT))
941
+ ], DrizzleIntegrationRunRecorder);
942
942
 
943
- // runtime/subsystems/sync/sync.module.ts
943
+ // runtime/subsystems/integration/integration.module.ts
944
944
  import { Module } from "@nestjs/common";
945
- var SyncModule = class {
945
+ var IntegrationModule = class {
946
946
  static forRoot(options) {
947
947
  const multiTenant = options.multiTenant ?? false;
948
948
  const sharedProviders = [
949
- { provide: SYNC_MODULE_OPTIONS, useValue: options },
950
- { provide: SYNC_MULTI_TENANT, useValue: multiTenant },
949
+ { provide: INTEGRATION_MODULE_OPTIONS, useValue: options },
950
+ { provide: INTEGRATION_MULTI_TENANT, useValue: multiTenant },
951
951
  // Default differ — consumers can override by binding a different
952
- // `IFieldDiffer<T>` to `SYNC_FIELD_DIFFER` in their feature module.
953
- { provide: SYNC_FIELD_DIFFER, useValue: new DeepEqualDiffer() }
952
+ // `IFieldDiffer<T>` to `INTEGRATION_FIELD_DIFFER` in their feature module.
953
+ { provide: INTEGRATION_FIELD_DIFFER, useValue: new DeepEqualDiffer() }
954
954
  ];
955
955
  const backendProviders = options.backend === "memory" ? [
956
956
  // Wired as singletons via `useValue` so tests can pull
@@ -958,38 +958,38 @@ var SyncModule = class {
958
958
  // direct assertions. Matches JOB-4 / MemoryJobStore shape.
959
959
  { provide: MemoryCursorStore, useValue: new MemoryCursorStore() },
960
960
  {
961
- provide: SYNC_CURSOR_STORE,
961
+ provide: INTEGRATION_CURSOR_STORE,
962
962
  useExisting: MemoryCursorStore
963
963
  },
964
964
  { provide: MemoryRunRecorder, useValue: new MemoryRunRecorder() },
965
965
  {
966
- provide: SYNC_RUN_RECORDER,
966
+ provide: INTEGRATION_RUN_RECORDER,
967
967
  useExisting: MemoryRunRecorder
968
968
  }
969
969
  ] : [
970
970
  // Drizzle backends — injected with DRIZZLE (provided by the
971
- // consumer's DrizzleModule) + the SYNC_MULTI_TENANT flag
971
+ // consumer's DrizzleModule) + the INTEGRATION_MULTI_TENANT flag
972
972
  // we bound above.
973
- { provide: SYNC_CURSOR_STORE, useClass: PostgresCursorStore },
974
- { provide: SYNC_RUN_RECORDER, useClass: DrizzleSyncRunRecorder }
973
+ { provide: INTEGRATION_CURSOR_STORE, useClass: PostgresCursorStore },
974
+ { provide: INTEGRATION_RUN_RECORDER, useClass: DrizzleIntegrationRunRecorder }
975
975
  ];
976
976
  return {
977
- module: SyncModule,
977
+ module: IntegrationModule,
978
978
  global: true,
979
979
  providers: [...sharedProviders, ...backendProviders],
980
980
  exports: [
981
- SYNC_MODULE_OPTIONS,
982
- SYNC_MULTI_TENANT,
983
- SYNC_FIELD_DIFFER,
984
- SYNC_CURSOR_STORE,
985
- SYNC_RUN_RECORDER
981
+ INTEGRATION_MODULE_OPTIONS,
982
+ INTEGRATION_MULTI_TENANT,
983
+ INTEGRATION_FIELD_DIFFER,
984
+ INTEGRATION_CURSOR_STORE,
985
+ INTEGRATION_RUN_RECORDER
986
986
  ]
987
987
  };
988
988
  }
989
989
  };
990
- SyncModule = __decorateClass([
990
+ IntegrationModule = __decorateClass([
991
991
  Module({})
992
- ], SyncModule);
992
+ ], IntegrationModule);
993
993
 
994
994
  // src/schema/entity-definition.schema.ts
995
995
  var FieldTypeSchema = z3.enum([
@@ -1297,21 +1297,21 @@ var AnyQueryDeclarationSchema = z3.union([
1297
1297
  SearchQueryDeclarationSchema,
1298
1298
  QueryDeclarationSchema
1299
1299
  ]);
1300
- var SyncDirectionSchema = z3.enum([
1300
+ var IntegrationDirectionSchema = z3.enum([
1301
1301
  "inbound",
1302
1302
  "outbound",
1303
1303
  "bidirectional"
1304
1304
  ]);
1305
- var ProviderSyncSchema = z3.object({
1305
+ var ProviderIntegrationSchema = z3.object({
1306
1306
  remote_entity: z3.string(),
1307
- direction: SyncDirectionSchema,
1307
+ direction: IntegrationDirectionSchema,
1308
1308
  cdc: z3.boolean().optional().default(false),
1309
1309
  field_mapping: z3.record(z3.string(), z3.string()).optional(),
1310
1310
  read_only_fields: z3.array(z3.string()).optional()
1311
1311
  });
1312
- var SyncConfigSchema = z3.object({
1312
+ var IntegrationConfigSchema = z3.object({
1313
1313
  electric: z3.boolean().optional().default(false),
1314
- providers: z3.record(z3.string(), ProviderSyncSchema).optional()
1314
+ providers: z3.record(z3.string(), ProviderIntegrationSchema).optional()
1315
1315
  });
1316
1316
  var EventDeclarationSchema = z3.object({
1317
1317
  name: z3.string().regex(/^[a-z][a-z0-9_]*$/, "Event name must be snake_case"),
@@ -1411,20 +1411,20 @@ var EntityDefinitionSchema = z3.object({
1411
1411
  // v2: Declarative query generation (ADR-005)
1412
1412
  // Generates repository + service + use case methods from declarations
1413
1413
  queries: z3.array(AnyQueryDeclarationSchema).optional(),
1414
- // v2: Integration sync configuration (CODEGEN-EVOLUTION-PLAN Phase 2)
1415
- // Electric SQL + provider sync (Salesforce, HubSpot, etc.)
1416
- sync: SyncConfigSchema.optional(),
1414
+ // v2: Integration integration configuration (CODEGEN-EVOLUTION-PLAN Phase 2)
1415
+ // Electric SQL + provider integration (Salesforce, HubSpot, etc.)
1416
+ integration: IntegrationConfigSchema.optional(),
1417
1417
  // ADR-033.1: Provider-keyed change-source detection.
1418
1418
  //
1419
1419
  // Map of provider name → DetectionConfig. Single-provider entities use
1420
1420
  // a one-key map; multi-provider entities list each provider as a
1421
1421
  // separate key. Each value is an independent `DetectionConfig` (its
1422
1422
  // own mode/cursor/mapping/filters) sourced from the canonical schema
1423
- // in `runtime/subsystems/sync` so this validator and the runtime
1423
+ // in `runtime/subsystems/integration` so this validator and the runtime
1424
1424
  // parser stay in lockstep.
1425
1425
  //
1426
1426
  // Within-file cross-check (ADR-033.1 §6): every key here must also
1427
- // appear in `sync.providers` — see the superRefine on
1427
+ // appear in `integration.providers` — see the superRefine on
1428
1428
  // `EntityDefinitionSchema` below.
1429
1429
  detection: z3.record(z3.string(), DetectionConfigSchema).optional(),
1430
1430
  // v2: Domain event declarations (CODEGEN-EVOLUTION-PLAN Phase 2)
@@ -1454,13 +1454,13 @@ var EntityDefinitionSchema = z3.object({
1454
1454
  }
1455
1455
  ).superRefine((entity, ctx) => {
1456
1456
  if (!entity.detection) return;
1457
- const declared = new Set(Object.keys(entity.sync?.providers ?? {}));
1457
+ const declared = new Set(Object.keys(entity.integration?.providers ?? {}));
1458
1458
  for (const provider of Object.keys(entity.detection)) {
1459
1459
  if (!declared.has(provider)) {
1460
1460
  ctx.addIssue({
1461
1461
  code: "custom",
1462
1462
  path: ["detection", provider],
1463
- message: `Provider '${provider}' used in detection: but not declared in sync.providers. Known providers: ${[...declared].join(", ")}`
1463
+ message: `Provider '${provider}' used in detection: but not declared in integration.providers. Known providers: ${[...declared].join(", ")}`
1464
1464
  });
1465
1465
  }
1466
1466
  }
@@ -2094,14 +2094,14 @@ function transformToEntity(result) {
2094
2094
  entity.relationships.set(name, relationship);
2095
2095
  }
2096
2096
  }
2097
- if (definition.sync) {
2098
- const syncDef = definition.sync;
2099
- const parsedSync = {
2100
- electric: syncDef.electric ?? false
2097
+ if (definition.integration) {
2098
+ const integrationDef = definition.integration;
2099
+ const parsedIntegration = {
2100
+ electric: integrationDef.electric ?? false
2101
2101
  };
2102
- if (syncDef.providers) {
2103
- parsedSync.providers = {};
2104
- for (const [providerName, providerDef] of Object.entries(syncDef.providers)) {
2102
+ if (integrationDef.providers) {
2103
+ parsedIntegration.providers = {};
2104
+ for (const [providerName, providerDef] of Object.entries(integrationDef.providers)) {
2105
2105
  const parsedProvider = {
2106
2106
  remoteEntity: providerDef.remote_entity,
2107
2107
  direction: providerDef.direction,
@@ -2113,10 +2113,10 @@ function transformToEntity(result) {
2113
2113
  if (providerDef.read_only_fields) {
2114
2114
  parsedProvider.readOnlyFields = providerDef.read_only_fields;
2115
2115
  }
2116
- parsedSync.providers[providerName] = parsedProvider;
2116
+ parsedIntegration.providers[providerName] = parsedProvider;
2117
2117
  }
2118
2118
  }
2119
- entity.sync = parsedSync;
2119
+ entity.integration = parsedIntegration;
2120
2120
  }
2121
2121
  if (definition.events) {
2122
2122
  entity.events = definition.events.map((ev) => ({
@@ -2770,8 +2770,8 @@ function checkConsistency(graph) {
2770
2770
  if (entity.queries !== void 0) {
2771
2771
  issues.push(...checkQueryFieldReferences(entity));
2772
2772
  }
2773
- if (entity.sync !== void 0) {
2774
- issues.push(...checkSyncFieldMappingReferences(entity));
2773
+ if (entity.integration !== void 0) {
2774
+ issues.push(...checkIntegrationFieldMappingReferences(entity));
2775
2775
  issues.push(...checkExternalIdTrackingCollision(entity));
2776
2776
  }
2777
2777
  }
@@ -3007,19 +3007,19 @@ function checkQueryFieldReferences(entity) {
3007
3007
  }
3008
3008
  return issues;
3009
3009
  }
3010
- function checkSyncFieldMappingReferences(entity) {
3010
+ function checkIntegrationFieldMappingReferences(entity) {
3011
3011
  const issues = [];
3012
3012
  const availableFields = getAvailableFieldNames(entity);
3013
3013
  const availableSet = new Set(availableFields);
3014
- for (const [providerName, provider] of Object.entries(entity.sync?.providers ?? {})) {
3014
+ for (const [providerName, provider] of Object.entries(entity.integration?.providers ?? {})) {
3015
3015
  for (const fieldName of Object.keys(provider.fieldMapping ?? {})) {
3016
3016
  if (!availableSet.has(fieldName)) {
3017
3017
  issues.push({
3018
3018
  severity: "warning",
3019
- type: "unknown_sync_field_mapping",
3019
+ type: "unknown_integration_field_mapping",
3020
3020
  entity: entity.name,
3021
3021
  field: fieldName,
3022
- message: `Sync field mapping references unknown field "${fieldName}" for provider "${providerName}" in entity "${entity.name}"`
3022
+ message: `Integration field mapping references unknown field "${fieldName}" for provider "${providerName}" in entity "${entity.name}"`
3023
3023
  });
3024
3024
  }
3025
3025
  }
@@ -3027,10 +3027,10 @@ function checkSyncFieldMappingReferences(entity) {
3027
3027
  if (!availableSet.has(fieldName)) {
3028
3028
  issues.push({
3029
3029
  severity: "warning",
3030
- type: "unknown_sync_field_mapping",
3030
+ type: "unknown_integration_field_mapping",
3031
3031
  entity: entity.name,
3032
3032
  field: fieldName,
3033
- message: `Sync field mapping references unknown field "${fieldName}" for provider "${providerName}" in entity "${entity.name}"`
3033
+ message: `Integration field mapping references unknown field "${fieldName}" for provider "${providerName}" in entity "${entity.name}"`
3034
3034
  });
3035
3035
  }
3036
3036
  }
@@ -3041,14 +3041,14 @@ function checkExternalIdTrackingCollision(entity) {
3041
3041
  const issues = [];
3042
3042
  const hasExternalIdTracking = entity.behaviors.includes("external_id_tracking");
3043
3043
  if (!hasExternalIdTracking) return issues;
3044
- for (const [providerName, provider] of Object.entries(entity.sync?.providers ?? {})) {
3044
+ for (const [providerName, provider] of Object.entries(entity.integration?.providers ?? {})) {
3045
3045
  if (provider.fieldMapping && "external_id" in provider.fieldMapping) {
3046
3046
  issues.push({
3047
3047
  severity: "warning",
3048
3048
  type: "external_id_tracking_collision",
3049
3049
  entity: entity.name,
3050
3050
  field: "external_id",
3051
- message: `Entity "${entity.name}" has external_id_tracking behavior and also maps "external_id" in sync field_mapping for provider "${providerName}". The behavior-added field may collide with the mapped field.`
3051
+ message: `Entity "${entity.name}" has external_id_tracking behavior and also maps "external_id" in integration field_mapping for provider "${providerName}". The behavior-added field may collide with the mapped field.`
3052
3052
  });
3053
3053
  }
3054
3054
  }
@@ -3975,30 +3975,30 @@ var MetadataPattern = definePattern({
3975
3975
  description: "History-tracked metadata rows \u2014 entity-id + type scoped lookups"
3976
3976
  });
3977
3977
 
3978
- // src/patterns/library/synced.pattern.ts
3979
- var SyncedPattern = definePattern({
3980
- name: "Synced",
3978
+ // src/patterns/library/integrated.pattern.ts
3979
+ var IntegratedPattern = definePattern({
3980
+ name: "Integrated",
3981
3981
  extends: ["Base"],
3982
- repositoryClass: "SyncedEntityRepository",
3983
- serviceClass: "SyncedEntityService",
3984
- repositoryImport: "@shared/base-classes/synced-entity-repository",
3985
- serviceImport: "@shared/base-classes/synced-entity-service",
3982
+ repositoryClass: "IntegratedEntityRepository",
3983
+ serviceClass: "IntegratedEntityService",
3984
+ repositoryImport: "@shared/base-classes/integrated-entity-repository",
3985
+ serviceImport: "@shared/base-classes/integrated-entity-service",
3986
3986
  repositoryInheritedMethods: [
3987
3987
  "findById, findByIds, list, count, exists, create, update, delete, upsertMany",
3988
3988
  "findByExternalId, findManyByExternalIds, findAllByUserId, findVisibleByUserId",
3989
- "syncUpsertOne, findByExternalIdProjected, softDeleteByExternalId, syncUpsert"
3989
+ "integrationUpsertOne, findByExternalIdProjected, softDeleteByExternalId, integrationUpsert"
3990
3990
  ],
3991
3991
  serviceInheritedMethods: [
3992
3992
  "findById, findByIds, list, count, exists, create, update, delete",
3993
3993
  "findByExternalId, findAllByUserId, findVisibleByUserId"
3994
3994
  ],
3995
3995
  impliedBehaviors: ["external_id_tracking"],
3996
- description: "External CRM/system sync columns and syncUpsert methods"
3996
+ description: "External CRM/system integration columns and integrationUpsert methods"
3997
3997
  });
3998
3998
 
3999
3999
  // src/patterns/library/index.ts
4000
4000
  registerLibraryPattern(BasePattern);
4001
- registerLibraryPattern(SyncedPattern);
4001
+ registerLibraryPattern(IntegratedPattern);
4002
4002
  registerLibraryPattern(ActivityPattern);
4003
4003
  registerLibraryPattern(KnowledgePattern);
4004
4004
  registerLibraryPattern(MetadataPattern);
@@ -4060,11 +4060,11 @@ export {
4060
4060
  BASE_JUNCTION_FIELD_NAMES,
4061
4061
  BaseJunctionFields,
4062
4062
  BasePattern,
4063
+ IntegratedPattern,
4063
4064
  JunctionDefinitionSchema,
4064
4065
  JunctionPattern,
4065
4066
  KnowledgePattern,
4066
4067
  MetadataPattern,
4067
- SyncedPattern,
4068
4068
  analyzeDomain,
4069
4069
  buildDomainGraph,
4070
4070
  checkConsistency,