@pattern-stack/codegen 0.10.1 → 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 (271) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/README.md +5 -5
  3. package/consumer-skills/codegen/SKILL.md +2 -2
  4. package/consumer-skills/{sync → integration}/SKILL.md +29 -29
  5. package/consumer-skills/{sync → integration}/audit-and-detection.md +22 -22
  6. package/consumer-skills/{sync → integration}/change-sources-and-sinks.md +60 -60
  7. package/consumer-skills/subsystems/SKILL.md +8 -8
  8. package/consumer-skills/subsystems/wiring-and-order.md +7 -7
  9. package/dist/runtime/base-classes/index.d.ts +4 -4
  10. package/dist/runtime/base-classes/index.js +35 -35
  11. package/dist/runtime/base-classes/index.js.map +1 -1
  12. package/dist/runtime/base-classes/{synced-entity-repository.d.ts → integrated-entity-repository.d.ts} +15 -15
  13. package/dist/runtime/base-classes/{synced-entity-repository.js → integrated-entity-repository.js} +21 -21
  14. package/dist/runtime/base-classes/integrated-entity-repository.js.map +1 -0
  15. package/dist/runtime/base-classes/{synced-entity-service.d.ts → integrated-entity-service.d.ts} +6 -6
  16. package/dist/runtime/base-classes/{synced-entity-service.js → integrated-entity-service.js} +4 -4
  17. package/dist/runtime/base-classes/integrated-entity-service.js.map +1 -0
  18. package/dist/runtime/base-classes/{sync-upsert-config.d.ts → integration-upsert-config.d.ts} +13 -13
  19. package/dist/runtime/base-classes/integration-upsert-config.js +1 -0
  20. package/dist/runtime/base-classes/{junction-sync-repository.d.ts → junction-integration-repository.d.ts} +11 -11
  21. package/dist/runtime/base-classes/{junction-sync-repository.js → junction-integration-repository.js} +15 -15
  22. package/dist/runtime/base-classes/junction-integration-repository.js.map +1 -0
  23. package/dist/runtime/subsystems/auth/auth-oauth-state.schema.js.map +1 -1
  24. package/dist/runtime/subsystems/auth/auth.module.d.ts +4 -4
  25. package/dist/runtime/subsystems/auth/auth.module.js +3 -3
  26. package/dist/runtime/subsystems/auth/auth.module.js.map +1 -1
  27. package/dist/runtime/subsystems/auth/auth.tokens.d.ts +8 -8
  28. package/dist/runtime/subsystems/auth/auth.tokens.js +6 -6
  29. package/dist/runtime/subsystems/auth/auth.tokens.js.map +1 -1
  30. package/dist/runtime/subsystems/auth/backends/state-store.drizzle-backend.js.map +1 -1
  31. package/dist/runtime/subsystems/auth/controllers/auth.controller.d.ts +2 -2
  32. package/dist/runtime/subsystems/auth/controllers/auth.controller.js +3 -3
  33. package/dist/runtime/subsystems/auth/controllers/auth.controller.js.map +1 -1
  34. package/dist/runtime/subsystems/auth/index.d.ts +3 -3
  35. package/dist/runtime/subsystems/auth/index.js +40 -40
  36. package/dist/runtime/subsystems/auth/index.js.map +1 -1
  37. package/dist/runtime/subsystems/auth/middleware/requester-context.js.map +1 -1
  38. package/dist/runtime/subsystems/auth/protocols/auth-strategy.d.ts +3 -3
  39. package/dist/runtime/subsystems/auth/protocols/{integration-store.d.ts → connection-store.d.ts} +20 -20
  40. package/dist/runtime/subsystems/auth/protocols/connection-store.js +1 -0
  41. package/dist/runtime/subsystems/auth/protocols/provider-strategy.d.ts +3 -3
  42. package/dist/runtime/subsystems/auth/runtime/{integration-broken.error.d.ts → connection-broken.error.d.ts} +5 -5
  43. package/dist/runtime/subsystems/auth/runtime/connection-broken.error.js +19 -0
  44. package/dist/runtime/subsystems/auth/runtime/connection-broken.error.js.map +1 -0
  45. package/dist/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.d.ts +10 -10
  46. package/dist/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.js +28 -28
  47. package/dist/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.js.map +1 -1
  48. package/dist/runtime/subsystems/auth/runtime/with-auth-retry.d.ts +1 -1
  49. package/dist/runtime/subsystems/auth/runtime/with-auth-retry.js +3 -3
  50. package/dist/runtime/subsystems/auth/runtime/with-auth-retry.js.map +1 -1
  51. package/dist/runtime/subsystems/index.d.ts +7 -7
  52. package/dist/runtime/subsystems/index.js +51 -51
  53. package/dist/runtime/subsystems/index.js.map +1 -1
  54. package/dist/runtime/subsystems/{sync → integration}/build-change-source.d.ts +3 -3
  55. package/dist/runtime/subsystems/{sync → integration}/build-change-source.js +3 -3
  56. package/dist/runtime/subsystems/integration/build-change-source.js.map +1 -0
  57. package/dist/runtime/subsystems/{sync → integration}/deep-equal.differ.d.ts +2 -2
  58. package/dist/runtime/subsystems/{sync → integration}/deep-equal.differ.js +1 -1
  59. package/dist/runtime/subsystems/integration/deep-equal.differ.js.map +1 -0
  60. package/dist/runtime/subsystems/{sync → integration}/detection-config.schema.d.ts +3 -3
  61. package/dist/runtime/subsystems/{sync → integration}/detection-config.schema.js +1 -1
  62. package/dist/runtime/subsystems/integration/detection-config.schema.js.map +1 -0
  63. package/dist/runtime/subsystems/{sync/execute-sync.use-case.d.ts → integration/execute-integration.use-case.d.ts} +13 -13
  64. package/dist/runtime/subsystems/{sync/execute-sync.use-case.js → integration/execute-integration.use-case.js} +30 -30
  65. package/dist/runtime/subsystems/integration/execute-integration.use-case.js.map +1 -0
  66. package/dist/runtime/subsystems/integration/index.d.ts +28 -0
  67. package/dist/runtime/subsystems/{sync → integration}/index.js +171 -171
  68. package/dist/runtime/subsystems/integration/index.js.map +1 -0
  69. package/dist/runtime/subsystems/{sync/sync-audit.schema.d.ts → integration/integration-audit.schema.d.ts} +64 -64
  70. package/dist/runtime/subsystems/{sync/sync-audit.schema.js → integration/integration-audit.schema.js} +47 -47
  71. package/dist/runtime/subsystems/integration/integration-audit.schema.js.map +1 -0
  72. package/dist/runtime/subsystems/{sync/sync-change-source.protocol.d.ts → integration/integration-change-source.protocol.d.ts} +10 -10
  73. package/dist/runtime/subsystems/integration/integration-change-source.protocol.js +1 -0
  74. package/dist/runtime/subsystems/{sync/sync-cursor-store.drizzle-backend.d.ts → integration/integration-cursor-store.drizzle-backend.d.ts} +1 -1
  75. package/dist/runtime/subsystems/{sync/sync-cursor-store.drizzle-backend.js → integration/integration-cursor-store.drizzle-backend.js} +65 -65
  76. package/dist/runtime/subsystems/integration/integration-cursor-store.drizzle-backend.js.map +1 -0
  77. package/dist/runtime/subsystems/{sync/sync-cursor-store.memory-backend.d.ts → integration/integration-cursor-store.memory-backend.d.ts} +6 -6
  78. package/dist/runtime/subsystems/{sync/sync-cursor-store.memory-backend.js → integration/integration-cursor-store.memory-backend.js} +5 -5
  79. package/dist/runtime/subsystems/integration/integration-cursor-store.memory-backend.js.map +1 -0
  80. package/dist/runtime/subsystems/{sync/sync-cursor-store.protocol.d.ts → integration/integration-cursor-store.protocol.d.ts} +13 -13
  81. package/dist/runtime/subsystems/integration/integration-cursor-store.protocol.js +1 -0
  82. package/dist/runtime/subsystems/{sync/sync-errors.d.ts → integration/integration-errors.d.ts} +2 -2
  83. package/dist/runtime/subsystems/{sync/sync-errors.js → integration/integration-errors.js} +3 -3
  84. package/dist/runtime/subsystems/integration/integration-errors.js.map +1 -0
  85. package/dist/runtime/subsystems/{sync/sync-field-diff.protocol.d.ts → integration/integration-field-diff.protocol.d.ts} +2 -2
  86. package/dist/runtime/subsystems/{sync/sync-field-diff.protocol.js → integration/integration-field-diff.protocol.js} +2 -2
  87. package/dist/runtime/subsystems/integration/integration-field-diff.protocol.js.map +1 -0
  88. package/dist/runtime/subsystems/{sync/sync-loopback.protocol.d.ts → integration/integration-loopback.protocol.d.ts} +2 -2
  89. package/dist/runtime/subsystems/integration/integration-loopback.protocol.js +1 -0
  90. package/dist/runtime/subsystems/{sync/sync-middleware.protocol.d.ts → integration/integration-middleware.protocol.d.ts} +5 -5
  91. package/dist/runtime/subsystems/integration/integration-middleware.protocol.js +1 -0
  92. package/dist/runtime/subsystems/{sync/sync-run-recorder.drizzle-backend.d.ts → integration/integration-run-recorder.drizzle-backend.d.ts} +5 -5
  93. package/dist/runtime/subsystems/{sync/sync-run-recorder.drizzle-backend.js → integration/integration-run-recorder.drizzle-backend.js} +73 -73
  94. package/dist/runtime/subsystems/integration/integration-run-recorder.drizzle-backend.js.map +1 -0
  95. package/dist/runtime/subsystems/{sync/sync-run-recorder.memory-backend.d.ts → integration/integration-run-recorder.memory-backend.d.ts} +15 -15
  96. package/dist/runtime/subsystems/{sync/sync-run-recorder.memory-backend.js → integration/integration-run-recorder.memory-backend.js} +11 -11
  97. package/dist/runtime/subsystems/integration/integration-run-recorder.memory-backend.js.map +1 -0
  98. package/dist/runtime/subsystems/{sync/sync-run-recorder.protocol.d.ts → integration/integration-run-recorder.protocol.d.ts} +25 -25
  99. package/dist/runtime/subsystems/integration/integration-run-recorder.protocol.js +1 -0
  100. package/dist/runtime/subsystems/{sync/sync-sink.protocol.d.ts → integration/integration-sink.protocol.d.ts} +5 -5
  101. package/dist/runtime/subsystems/integration/integration-sink.protocol.js +1 -0
  102. package/dist/runtime/subsystems/{sync/sync.module.d.ts → integration/integration.module.d.ts} +24 -24
  103. package/dist/runtime/subsystems/{sync/sync.module.js → integration/integration.module.js} +132 -132
  104. package/dist/runtime/subsystems/integration/integration.module.js.map +1 -0
  105. package/dist/runtime/subsystems/integration/integration.tokens.d.ts +47 -0
  106. package/dist/runtime/subsystems/integration/integration.tokens.js +18 -0
  107. package/dist/runtime/subsystems/integration/integration.tokens.js.map +1 -0
  108. package/dist/runtime/subsystems/{sync → integration}/loopback.middleware.d.ts +5 -5
  109. package/dist/runtime/subsystems/{sync → integration}/loopback.middleware.js +1 -1
  110. package/dist/runtime/subsystems/integration/loopback.middleware.js.map +1 -0
  111. package/dist/runtime/subsystems/{sync → integration}/poll-change-source.d.ts +5 -5
  112. package/dist/runtime/subsystems/{sync → integration}/poll-change-source.js +1 -1
  113. package/dist/runtime/subsystems/integration/poll-change-source.js.map +1 -0
  114. package/dist/runtime/subsystems/{sync → integration}/webhook-change-source.d.ts +5 -5
  115. package/dist/runtime/subsystems/{sync → integration}/webhook-change-source.js +1 -1
  116. package/dist/runtime/subsystems/integration/webhook-change-source.js.map +1 -0
  117. package/dist/runtime/subsystems/jobs/job-worker.module.d.ts +1 -1
  118. package/dist/runtime/subsystems/observability/index.d.ts +4 -4
  119. package/dist/runtime/subsystems/observability/index.js +11 -11
  120. package/dist/runtime/subsystems/observability/index.js.map +1 -1
  121. package/dist/runtime/subsystems/observability/observability.module.d.ts +2 -2
  122. package/dist/runtime/subsystems/observability/observability.module.js +11 -11
  123. package/dist/runtime/subsystems/observability/observability.module.js.map +1 -1
  124. package/dist/runtime/subsystems/observability/observability.protocol.d.ts +11 -11
  125. package/dist/runtime/subsystems/observability/observability.service.d.ts +6 -6
  126. package/dist/runtime/subsystems/observability/observability.service.js +11 -11
  127. package/dist/runtime/subsystems/observability/observability.service.js.map +1 -1
  128. package/dist/runtime/subsystems/observability/observability.tokens.d.ts +1 -1
  129. package/dist/runtime/subsystems/observability/observability.tokens.js.map +1 -1
  130. package/dist/runtime/subsystems/observability/reporters/bridge-metrics.reporter.d.ts +3 -3
  131. package/dist/runtime/subsystems/observability/reporters/bridge-metrics.reporter.js.map +1 -1
  132. package/dist/runtime/subsystems/observability/reporters/index.d.ts +3 -3
  133. package/dist/runtime/subsystems/observability/reporters/index.js.map +1 -1
  134. package/dist/src/cli/index.js +262 -269
  135. package/dist/src/cli/index.js.map +1 -1
  136. package/dist/src/index.d.ts +22 -22
  137. package/dist/src/index.js +191 -191
  138. package/dist/src/index.js.map +1 -1
  139. package/examples/auth-integrations/README.md +32 -32
  140. package/examples/auth-integrations/definitions/entities/{integration.yaml → connection.yaml} +10 -10
  141. package/examples/auth-integrations/runtime/{integrations/adapters/integration-grant-sink.adapter.ts → connections/adapters/connection-grant-sink.adapter.ts} +7 -7
  142. package/examples/auth-integrations/runtime/{integrations/adapters/integration-reader.adapter.ts → connections/adapters/connection-reader.adapter.ts} +10 -10
  143. package/examples/auth-integrations/runtime/{integrations/adapters/integration-token-writer.adapter.ts → connections/adapters/connection-token-writer.adapter.ts} +11 -11
  144. package/examples/auth-integrations/runtime/connections/connections-auth.module.ts +81 -0
  145. package/examples/auth-integrations/runtime/{integrations/facade/integrations.service.ts → connections/facade/connections.service.ts} +35 -35
  146. package/examples/auth-integrations/runtime/{integrations → connections}/oauth/use-cases/create-or-update-from-oauth-grant.use-case.ts +11 -11
  147. 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
  148. package/examples/auth-integrations/runtime/connections/oauth/use-cases/list-user-connections.use-case.ts +21 -0
  149. package/examples/auth-integrations/runtime/connections/oauth/use-cases/mark-connection-requires-reauth.use-case.ts +21 -0
  150. package/package.json +1 -1
  151. package/runtime/base-classes/index.ts +8 -8
  152. package/runtime/base-classes/{synced-entity-repository.ts → integrated-entity-repository.ts} +36 -36
  153. package/runtime/base-classes/{synced-entity-service.ts → integrated-entity-service.ts} +6 -6
  154. package/runtime/base-classes/{sync-upsert-config.ts → integration-upsert-config.ts} +12 -12
  155. package/runtime/base-classes/{junction-sync-repository.ts → junction-integration-repository.ts} +28 -28
  156. package/runtime/subsystems/auth/auth-oauth-state.schema.ts +1 -1
  157. package/runtime/subsystems/auth/auth.module.ts +4 -4
  158. package/runtime/subsystems/auth/auth.tokens.ts +7 -7
  159. package/runtime/subsystems/auth/controllers/auth.controller.ts +7 -7
  160. package/runtime/subsystems/auth/index.ts +19 -19
  161. package/runtime/subsystems/auth/protocols/auth-strategy.ts +3 -3
  162. package/runtime/subsystems/auth/protocols/{integration-store.ts → connection-store.ts} +19 -19
  163. package/runtime/subsystems/auth/protocols/provider-strategy.ts +2 -2
  164. package/runtime/subsystems/auth/runtime/{integration-broken.error.ts → connection-broken.error.ts} +5 -5
  165. package/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.ts +35 -35
  166. package/runtime/subsystems/auth/runtime/with-auth-retry.ts +3 -3
  167. package/runtime/subsystems/index.ts +11 -11
  168. package/runtime/subsystems/{sync → integration}/build-change-source.ts +3 -3
  169. package/runtime/subsystems/{sync → integration}/deep-equal.differ.ts +7 -7
  170. package/runtime/subsystems/{sync → integration}/detection-config.schema.ts +3 -3
  171. package/runtime/subsystems/{sync/execute-sync.use-case.ts → integration/execute-integration.use-case.ts} +40 -40
  172. package/runtime/subsystems/{sync → integration}/index.ts +47 -47
  173. package/runtime/subsystems/{sync/sync-audit.schema.ts → integration/integration-audit.schema.ts} +61 -61
  174. package/runtime/subsystems/{sync/sync-change-source.protocol.ts → integration/integration-change-source.protocol.ts} +9 -9
  175. package/runtime/subsystems/{sync/sync-cursor-store.drizzle-backend.ts → integration/integration-cursor-store.drizzle-backend.ts} +30 -30
  176. package/runtime/subsystems/{sync/sync-cursor-store.memory-backend.ts → integration/integration-cursor-store.memory-backend.ts} +9 -9
  177. package/runtime/subsystems/{sync/sync-cursor-store.protocol.ts → integration/integration-cursor-store.protocol.ts} +13 -13
  178. package/runtime/subsystems/{sync/sync-errors.ts → integration/integration-errors.ts} +3 -3
  179. package/runtime/subsystems/{sync/sync-field-diff.protocol.ts → integration/integration-field-diff.protocol.ts} +2 -2
  180. package/runtime/subsystems/{sync/sync-loopback.protocol.ts → integration/integration-loopback.protocol.ts} +2 -2
  181. package/runtime/subsystems/{sync/sync-middleware.protocol.ts → integration/integration-middleware.protocol.ts} +6 -6
  182. package/runtime/subsystems/{sync/sync-run-recorder.drizzle-backend.ts → integration/integration-run-recorder.drizzle-backend.ts} +39 -39
  183. package/runtime/subsystems/{sync/sync-run-recorder.memory-backend.ts → integration/integration-run-recorder.memory-backend.ts} +23 -23
  184. package/runtime/subsystems/{sync/sync-run-recorder.protocol.ts → integration/integration-run-recorder.protocol.ts} +25 -25
  185. package/runtime/subsystems/{sync/sync-sink.protocol.ts → integration/integration-sink.protocol.ts} +4 -4
  186. package/runtime/subsystems/{sync/sync.module.ts → integration/integration.module.ts} +48 -48
  187. package/runtime/subsystems/integration/integration.tokens.ts +49 -0
  188. package/runtime/subsystems/{sync → integration}/loopback.middleware.ts +5 -5
  189. package/runtime/subsystems/{sync → integration}/poll-change-source.ts +7 -7
  190. package/runtime/subsystems/{sync → integration}/webhook-change-source.ts +7 -7
  191. package/runtime/subsystems/observability/index.ts +1 -1
  192. package/runtime/subsystems/observability/observability.module.ts +2 -2
  193. package/runtime/subsystems/observability/observability.protocol.ts +11 -11
  194. package/runtime/subsystems/observability/observability.service.ts +13 -13
  195. package/runtime/subsystems/observability/observability.tokens.ts +1 -1
  196. package/src/patterns/library/index.ts +4 -4
  197. package/src/patterns/library/{synced.pattern.ts → integrated.pattern.ts} +12 -12
  198. package/src/patterns/library/junction.pattern.ts +1 -1
  199. package/src/patterns/pattern-definition.ts +3 -3
  200. package/templates/entity/new/backend/modules/core/{sync-source.ejs.t → integration-source.ejs.t} +6 -6
  201. package/templates/entity/new/backend/modules/core/{sync-source.providers.ejs.t → integration-source.providers.ejs.t} +2 -2
  202. package/templates/entity/new/clean-lite-ps/entity.ejs.t +1 -1
  203. package/templates/entity/new/clean-lite-ps/module.ejs.t +1 -1
  204. package/templates/entity/new/clean-lite-ps/prompt-extension.js +33 -33
  205. package/templates/entity/new/clean-lite-ps/repository.ejs.t +27 -27
  206. package/templates/entity/new/frontend/collections/collection.ejs.t +26 -1
  207. package/templates/entity/new/frontend/collections/collections-base.ejs.t +11 -0
  208. package/templates/entity/new/frontend/entity/combined.ejs.t +31 -1
  209. package/templates/entity/new/prompt.js +27 -15
  210. package/templates/junction/new/entity.ejs.t +1 -1
  211. package/templates/junction/new/prompt.js +24 -24
  212. package/templates/junction/new/repository.ejs.t +19 -19
  213. package/templates/subsystem/auth/auth-oauth-state.schema.ejs.t +2 -2
  214. package/templates/subsystem/auth-config/prompt.js +1 -1
  215. package/templates/subsystem/auth-integrations/app-module-hook.ejs.t +5 -5
  216. package/templates/subsystem/bridge/prompt.js +1 -1
  217. package/templates/subsystem/integration/integration-audit.schema.ejs.t +192 -0
  218. package/templates/subsystem/{sync → integration}/prompt.js +12 -12
  219. package/templates/subsystem/{sync-config/codegen-config-sync-block.ejs.t → integration-config/codegen-config-integration-block.ejs.t} +7 -7
  220. package/templates/subsystem/integration-config/prompt.js +22 -0
  221. package/templates/subsystem/jobs/worker.ejs.t +2 -2
  222. package/templates/subsystem/observability/main-hook.ejs.t +1 -1
  223. package/templates/subsystem/observability/prompt.js +1 -1
  224. package/templates/subsystem/openapi-config/prompt.js +1 -1
  225. package/dist/runtime/base-classes/junction-sync-repository.js.map +0 -1
  226. package/dist/runtime/base-classes/sync-upsert-config.js +0 -1
  227. package/dist/runtime/base-classes/synced-entity-repository.js.map +0 -1
  228. package/dist/runtime/base-classes/synced-entity-service.js.map +0 -1
  229. package/dist/runtime/subsystems/auth/protocols/integration-store.js +0 -1
  230. package/dist/runtime/subsystems/auth/runtime/integration-broken.error.js +0 -19
  231. package/dist/runtime/subsystems/auth/runtime/integration-broken.error.js.map +0 -1
  232. package/dist/runtime/subsystems/sync/build-change-source.js.map +0 -1
  233. package/dist/runtime/subsystems/sync/deep-equal.differ.js.map +0 -1
  234. package/dist/runtime/subsystems/sync/detection-config.schema.js.map +0 -1
  235. package/dist/runtime/subsystems/sync/execute-sync.use-case.js.map +0 -1
  236. package/dist/runtime/subsystems/sync/index.d.ts +0 -28
  237. package/dist/runtime/subsystems/sync/index.js.map +0 -1
  238. package/dist/runtime/subsystems/sync/loopback.middleware.js.map +0 -1
  239. package/dist/runtime/subsystems/sync/poll-change-source.js.map +0 -1
  240. package/dist/runtime/subsystems/sync/sync-audit.schema.js.map +0 -1
  241. package/dist/runtime/subsystems/sync/sync-change-source.protocol.js +0 -1
  242. package/dist/runtime/subsystems/sync/sync-cursor-store.drizzle-backend.js.map +0 -1
  243. package/dist/runtime/subsystems/sync/sync-cursor-store.memory-backend.js.map +0 -1
  244. package/dist/runtime/subsystems/sync/sync-cursor-store.protocol.js +0 -1
  245. package/dist/runtime/subsystems/sync/sync-errors.js.map +0 -1
  246. package/dist/runtime/subsystems/sync/sync-field-diff.protocol.js.map +0 -1
  247. package/dist/runtime/subsystems/sync/sync-loopback.protocol.js +0 -1
  248. package/dist/runtime/subsystems/sync/sync-middleware.protocol.js +0 -1
  249. package/dist/runtime/subsystems/sync/sync-run-recorder.drizzle-backend.js.map +0 -1
  250. package/dist/runtime/subsystems/sync/sync-run-recorder.memory-backend.js.map +0 -1
  251. package/dist/runtime/subsystems/sync/sync-run-recorder.protocol.js +0 -1
  252. package/dist/runtime/subsystems/sync/sync-sink.protocol.js +0 -1
  253. package/dist/runtime/subsystems/sync/sync.module.js.map +0 -1
  254. package/dist/runtime/subsystems/sync/sync.tokens.d.ts +0 -47
  255. package/dist/runtime/subsystems/sync/sync.tokens.js +0 -18
  256. package/dist/runtime/subsystems/sync/sync.tokens.js.map +0 -1
  257. package/dist/runtime/subsystems/sync/webhook-change-source.js.map +0 -1
  258. package/examples/auth-integrations/runtime/integrations/integrations-auth.module.ts +0 -81
  259. package/examples/auth-integrations/runtime/integrations/oauth/use-cases/list-user-integrations.use-case.ts +0 -21
  260. package/examples/auth-integrations/runtime/integrations/oauth/use-cases/mark-integration-requires-reauth.use-case.ts +0 -21
  261. package/runtime/subsystems/sync/sync.tokens.ts +0 -49
  262. package/templates/subsystem/sync/sync-audit.schema.ejs.t +0 -192
  263. package/templates/subsystem/sync-config/prompt.js +0 -22
  264. /package/dist/runtime/base-classes/{sync-upsert-config.js.map → integration-upsert-config.js.map} +0 -0
  265. /package/dist/runtime/subsystems/auth/protocols/{integration-store.js.map → connection-store.js.map} +0 -0
  266. /package/dist/runtime/subsystems/{sync/sync-change-source.protocol.js.map → integration/integration-change-source.protocol.js.map} +0 -0
  267. /package/dist/runtime/subsystems/{sync/sync-cursor-store.protocol.js.map → integration/integration-cursor-store.protocol.js.map} +0 -0
  268. /package/dist/runtime/subsystems/{sync/sync-loopback.protocol.js.map → integration/integration-loopback.protocol.js.map} +0 -0
  269. /package/dist/runtime/subsystems/{sync/sync-middleware.protocol.js.map → integration/integration-middleware.protocol.js.map} +0 -0
  270. /package/dist/runtime/subsystems/{sync/sync-run-recorder.protocol.js.map → integration/integration-run-recorder.protocol.js.map} +0 -0
  271. /package/dist/runtime/subsystems/{sync/sync-sink.protocol.js.map → integration/integration-sink.protocol.js.map} +0 -0
@@ -10,7 +10,7 @@ var __decorateClass = (decorators, target, key, kind) => {
10
10
  };
11
11
  var __decorateParam = (index2, decorator) => (target, key) => decorator(target, key, index2);
12
12
 
13
- // runtime/subsystems/sync/sync-field-diff.protocol.ts
13
+ // runtime/subsystems/integration/integration-field-diff.protocol.ts
14
14
  import { z } from "zod";
15
15
  var FieldDiffValueSchema = z.object({
16
16
  from: z.unknown(),
@@ -18,7 +18,7 @@ var FieldDiffValueSchema = z.object({
18
18
  });
19
19
  var FieldDiffSchema = z.record(z.string(), FieldDiffValueSchema);
20
20
 
21
- // runtime/subsystems/sync/detection-config.schema.ts
21
+ // runtime/subsystems/integration/detection-config.schema.ts
22
22
  import { z as z2 } from "zod";
23
23
  var FieldMappingSchema = z2.object({
24
24
  source: z2.string().min(1),
@@ -76,7 +76,7 @@ var DetectionConfigSchema = z2.discriminatedUnion("mode", [
76
76
  WebhookModeSchema
77
77
  ]);
78
78
 
79
- // runtime/subsystems/sync/loopback.middleware.ts
79
+ // runtime/subsystems/integration/loopback.middleware.ts
80
80
  function createLoopbackMiddleware(store) {
81
81
  return (next) => {
82
82
  return async function* (subscription, cursor) {
@@ -93,7 +93,7 @@ function createLoopbackMiddleware(store) {
93
93
  };
94
94
  }
95
95
 
96
- // runtime/subsystems/sync/poll-change-source.ts
96
+ // runtime/subsystems/integration/poll-change-source.ts
97
97
  var PollChangeSource = class {
98
98
  label;
99
99
  adapter;
@@ -183,7 +183,7 @@ var PollChangeSource = class {
183
183
  }
184
184
  };
185
185
 
186
- // runtime/subsystems/sync/webhook-change-source.ts
186
+ // runtime/subsystems/integration/webhook-change-source.ts
187
187
  var WebhookChangeSource = class {
188
188
  label;
189
189
  queue;
@@ -254,7 +254,7 @@ var WebhookChangeSource = class {
254
254
  }
255
255
  };
256
256
 
257
- // runtime/subsystems/sync/build-change-source.ts
257
+ // runtime/subsystems/integration/build-change-source.ts
258
258
  function buildChangeSource(cfg, fetch, middlewares = []) {
259
259
  switch (cfg.mode) {
260
260
  case "poll":
@@ -272,21 +272,21 @@ function buildChangeSource(cfg, fetch, middlewares = []) {
272
272
  }
273
273
  }
274
274
 
275
- // runtime/subsystems/sync/sync.tokens.ts
276
- var SYNC_CHANGE_SOURCE = "SYNC_CHANGE_SOURCE";
277
- var SYNC_CURSOR_STORE = "SYNC_CURSOR_STORE";
278
- var SYNC_FIELD_DIFFER = "SYNC_FIELD_DIFFER";
279
- var SYNC_SINK = "SYNC_SINK";
280
- var SYNC_RUN_RECORDER = "SYNC_RUN_RECORDER";
281
- var SYNC_MODULE_OPTIONS = "SYNC_MODULE_OPTIONS";
282
- var SYNC_MULTI_TENANT = "SYNC_MULTI_TENANT";
275
+ // runtime/subsystems/integration/integration.tokens.ts
276
+ var INTEGRATION_CHANGE_SOURCE = "INTEGRATION_CHANGE_SOURCE";
277
+ var INTEGRATION_CURSOR_STORE = "INTEGRATION_CURSOR_STORE";
278
+ var INTEGRATION_FIELD_DIFFER = "INTEGRATION_FIELD_DIFFER";
279
+ var INTEGRATION_SINK = "INTEGRATION_SINK";
280
+ var INTEGRATION_RUN_RECORDER = "INTEGRATION_RUN_RECORDER";
281
+ var INTEGRATION_MODULE_OPTIONS = "INTEGRATION_MODULE_OPTIONS";
282
+ var INTEGRATION_MULTI_TENANT = "INTEGRATION_MULTI_TENANT";
283
283
 
284
- // runtime/subsystems/sync/sync-errors.ts
284
+ // runtime/subsystems/integration/integration-errors.ts
285
285
  var MissingTenantIdError = class extends Error {
286
286
  name = "MissingTenantIdError";
287
287
  constructor(operation) {
288
288
  super(
289
- `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.`
289
+ `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.`
290
290
  );
291
291
  }
292
292
  };
@@ -297,7 +297,7 @@ function assertTenantId(tenantId, options) {
297
297
  }
298
298
  }
299
299
 
300
- // runtime/subsystems/sync/sync-audit.schema.ts
300
+ // runtime/subsystems/integration/integration-audit.schema.ts
301
301
  import {
302
302
  pgEnum,
303
303
  pgTable,
@@ -310,39 +310,39 @@ import {
310
310
  index,
311
311
  uniqueIndex
312
312
  } from "drizzle-orm/pg-core";
313
- var syncRunDirectionEnum = pgEnum("sync_run_direction", [
313
+ var integrationRunDirectionEnum = pgEnum("integration_run_direction", [
314
314
  "inbound",
315
315
  "outbound"
316
316
  ]);
317
- var syncRunActionEnum = pgEnum("sync_run_action", [
317
+ var integrationRunActionEnum = pgEnum("integration_run_action", [
318
318
  "poll",
319
319
  "cdc",
320
320
  "webhook",
321
321
  "manual",
322
322
  "writeback"
323
323
  ]);
324
- var syncRunStatusEnum = pgEnum("sync_run_status", [
324
+ var integrationRunStatusEnum = pgEnum("integration_run_status", [
325
325
  "running",
326
326
  "success",
327
327
  "no_changes",
328
328
  "failed"
329
329
  ]);
330
- var syncRunItemOperationEnum = pgEnum("sync_run_item_operation", [
330
+ var integrationRunItemOperationEnum = pgEnum("integration_run_item_operation", [
331
331
  "created",
332
332
  "updated",
333
333
  "deleted",
334
334
  "noop"
335
335
  ]);
336
- var syncRunItemStatusEnum = pgEnum("sync_run_item_status", [
336
+ var integrationRunItemStatusEnum = pgEnum("integration_run_item_status", [
337
337
  "success",
338
338
  "failed",
339
339
  "skipped"
340
340
  ]);
341
- var syncSubscriptions = pgTable(
342
- "sync_subscriptions",
341
+ var integrationSubscriptions = pgTable(
342
+ "integration_subscriptions",
343
343
  {
344
344
  id: uuid("id").primaryKey().defaultRandom(),
345
- integrationId: text("integration_id").notNull(),
345
+ connectionId: text("connection_id").notNull(),
346
346
  adapter: text("adapter").notNull(),
347
347
  domain: text("domain").notNull(),
348
348
  externalRef: text("external_ref"),
@@ -357,8 +357,8 @@ var syncSubscriptions = pgTable(
357
357
  * successful run advances it.
358
358
  */
359
359
  cursor: jsonb("cursor").$type(),
360
- lastSyncAt: timestamp("last_sync_at", { withTimezone: true }),
361
- /** Runtime-enforced when `SYNC_MULTI_TENANT` is true; see SYNC-6. */
360
+ lastIntegrationAt: timestamp("last_integration_at", { withTimezone: true }),
361
+ /** Runtime-enforced when `INTEGRATION_MULTI_TENANT` is true; see SYNC-6. */
362
362
  tenantId: text("tenant_id"),
363
363
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
364
364
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
@@ -367,31 +367,31 @@ var syncSubscriptions = pgTable(
367
367
  /**
368
368
  * Composite uniqueness per the epic shape. `external_ref` is nullable;
369
369
  * Postgres treats NULLs as distinct in a UNIQUE constraint, which means
370
- * two rows with the same `(integration_id, adapter, domain)` and NULL
370
+ * two rows with the same `(connection_id, adapter, domain)` and NULL
371
371
  * external_ref are allowed. That's intentional — a subscription with
372
372
  * NULL external_ref covers the full domain, and duplicates there would
373
373
  * be a consumer-layer modeling issue, not a schema concern.
374
374
  */
375
- uqSyncSubscriptionTuple: uniqueIndex("uq_sync_subscriptions_tuple").on(
376
- t.integrationId,
375
+ uqIntegrationSubscriptionTuple: uniqueIndex("uq_integration_subscriptions_tuple").on(
376
+ t.connectionId,
377
377
  t.adapter,
378
378
  t.domain,
379
379
  t.externalRef
380
380
  ),
381
381
  /** Scheduling query: list enabled subscriptions ordered by staleness. */
382
- idxSyncSubscriptionsEnabledLastSync: index(
383
- "idx_sync_subscriptions_enabled_last_sync"
384
- ).on(t.enabled, t.lastSyncAt)
382
+ idxIntegrationSubscriptionsEnabledLastIntegration: index(
383
+ "idx_integration_subscriptions_enabled_last_integration"
384
+ ).on(t.enabled, t.lastIntegrationAt)
385
385
  })
386
386
  );
387
- var syncRuns = pgTable(
388
- "sync_runs",
387
+ var integrationRuns = pgTable(
388
+ "integration_runs",
389
389
  {
390
390
  id: uuid("id").primaryKey().defaultRandom(),
391
- subscriptionId: uuid("subscription_id").notNull().references(() => syncSubscriptions.id, { onDelete: "cascade" }),
392
- direction: syncRunDirectionEnum("direction").notNull(),
393
- action: syncRunActionEnum("action").notNull(),
394
- status: syncRunStatusEnum("status").notNull().default("running"),
391
+ subscriptionId: uuid("subscription_id").notNull().references(() => integrationSubscriptions.id, { onDelete: "cascade" }),
392
+ direction: integrationRunDirectionEnum("direction").notNull(),
393
+ action: integrationRunActionEnum("action").notNull(),
394
+ status: integrationRunStatusEnum("status").notNull().default("running"),
395
395
  recordsFound: integer("records_found").notNull().default(0),
396
396
  recordsProcessed: integer("records_processed").notNull().default(0),
397
397
  cursorBefore: jsonb("cursor_before").$type(),
@@ -400,31 +400,31 @@ var syncRuns = pgTable(
400
400
  error: text("error"),
401
401
  startedAt: timestamp("started_at", { withTimezone: true }).notNull().defaultNow(),
402
402
  completedAt: timestamp("completed_at", { withTimezone: true }),
403
- /** Runtime-enforced when `SYNC_MULTI_TENANT` is true; see SYNC-6. */
403
+ /** Runtime-enforced when `INTEGRATION_MULTI_TENANT` is true; see SYNC-6. */
404
404
  tenantId: text("tenant_id")
405
405
  },
406
406
  (t) => ({
407
407
  /** Timeline read: "most recent runs for this subscription". */
408
- idxSyncRunsSubscriptionStartedAt: index(
409
- "idx_sync_runs_subscription_started_at"
408
+ idxIntegrationRunsSubscriptionStartedAt: index(
409
+ "idx_integration_runs_subscription_started_at"
410
410
  ).on(t.subscriptionId, t.startedAt),
411
411
  /** Stale-run sweeper: "runs that started > N minutes ago and are still running". */
412
- idxSyncRunsStatusStartedAt: index("idx_sync_runs_status_started_at").on(
412
+ idxIntegrationRunsStatusStartedAt: index("idx_integration_runs_status_started_at").on(
413
413
  t.status,
414
414
  t.startedAt
415
415
  )
416
416
  })
417
417
  );
418
- var syncRunItems = pgTable(
419
- "sync_run_items",
418
+ var integrationRunItems = pgTable(
419
+ "integration_run_items",
420
420
  {
421
421
  id: uuid("id").primaryKey().defaultRandom(),
422
- syncRunId: uuid("sync_run_id").notNull().references(() => syncRuns.id, { onDelete: "cascade" }),
422
+ integrationRunId: uuid("integration_run_id").notNull().references(() => integrationRuns.id, { onDelete: "cascade" }),
423
423
  entityType: text("entity_type").notNull(),
424
424
  externalId: text("external_id").notNull(),
425
425
  localId: text("local_id"),
426
- operation: syncRunItemOperationEnum("operation").notNull(),
427
- status: syncRunItemStatusEnum("status").notNull(),
426
+ operation: integrationRunItemOperationEnum("operation").notNull(),
427
+ status: integrationRunItemStatusEnum("status").notNull(),
428
428
  /**
429
429
  * Structured per-field diff — ADR-0003 shape enforced by
430
430
  * `FieldDiffSchema.parse` at the recorder service layer.
@@ -438,23 +438,23 @@ var syncRunItems = pgTable(
438
438
  title: text("title"),
439
439
  error: text("error"),
440
440
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
441
- /** Runtime-enforced when `SYNC_MULTI_TENANT` is true; see SYNC-6. */
441
+ /** Runtime-enforced when `INTEGRATION_MULTI_TENANT` is true; see SYNC-6. */
442
442
  tenantId: text("tenant_id")
443
443
  },
444
444
  (t) => ({
445
445
  /** Ordered timeline within a run. */
446
- idxSyncRunItemsRunCreatedAt: index("idx_sync_run_items_run_created_at").on(
447
- t.syncRunId,
446
+ idxIntegrationRunItemsRunCreatedAt: index("idx_integration_run_items_run_created_at").on(
447
+ t.integrationRunId,
448
448
  t.createdAt
449
449
  ),
450
- /** Per-record history: "every sync that touched opportunity/$extId". */
451
- idxSyncRunItemsEntityExternal: index(
452
- "idx_sync_run_items_entity_external"
450
+ /** Per-record history: "every integration that touched opportunity/$extId". */
451
+ idxIntegrationRunItemsEntityExternal: index(
452
+ "idx_integration_run_items_entity_external"
453
453
  ).on(t.entityType, t.externalId)
454
454
  })
455
455
  );
456
456
 
457
- // runtime/subsystems/sync/sync-cursor-store.memory-backend.ts
457
+ // runtime/subsystems/integration/integration-cursor-store.memory-backend.ts
458
458
  import { Injectable } from "@nestjs/common";
459
459
  var MemoryCursorStore = class {
460
460
  /**
@@ -465,7 +465,7 @@ var MemoryCursorStore = class {
465
465
  /**
466
466
  * Seedable subscription metadata for `listAll` — the memory backend
467
467
  * stores only `subscriptionId → cursor` in its write path, so the
468
- * snapshot shape (`integrationId`, `adapter`, `domain`, `externalRef`,
468
+ * snapshot shape (`connectionId`, `adapter`, `domain`, `externalRef`,
469
469
  * timestamps) has no natural source without test seeding. Tests populate
470
470
  * this map; unseeded entries get empty-string metadata and `new Date(0)`
471
471
  * timestamps so the shape stays stable. Production paths go through the
@@ -485,12 +485,12 @@ var MemoryCursorStore = class {
485
485
  const meta = this.subscriptions.get(subscriptionId);
486
486
  snapshots.push({
487
487
  subscriptionId,
488
- integrationId: meta?.integrationId ?? "",
488
+ connectionId: meta?.connectionId ?? "",
489
489
  adapter: meta?.adapter ?? "",
490
490
  domain: meta?.domain ?? "",
491
491
  externalRef: meta?.externalRef ?? null,
492
492
  cursor: cursor ?? null,
493
- lastSyncAt: meta?.lastSyncAt ?? null,
493
+ lastIntegrationAt: meta?.lastIntegrationAt ?? null,
494
494
  updatedAt: meta?.updatedAt ?? /* @__PURE__ */ new Date(0),
495
495
  tenantId: null
496
496
  });
@@ -509,7 +509,7 @@ MemoryCursorStore = __decorateClass([
509
509
  Injectable()
510
510
  ], MemoryCursorStore);
511
511
 
512
- // runtime/subsystems/sync/sync-run-recorder.memory-backend.ts
512
+ // runtime/subsystems/integration/integration-run-recorder.memory-backend.ts
513
513
  import { Injectable as Injectable2 } from "@nestjs/common";
514
514
  var MemoryRunRecorder = class {
515
515
  /**
@@ -518,14 +518,14 @@ var MemoryRunRecorder = class {
518
518
  */
519
519
  runs = /* @__PURE__ */ new Map();
520
520
  /**
521
- * Items keyed by `sync_run_id`, array order matches insertion order —
522
- * mirrors the timeline the `(sync_run_id, created_at)` index produces
521
+ * Items keyed by `integration_run_id`, array order matches insertion order —
522
+ * mirrors the timeline the `(integration_run_id, created_at)` index produces
523
523
  * in Postgres.
524
524
  */
525
525
  items = /* @__PURE__ */ new Map();
526
526
  /**
527
527
  * Seedable subscription metadata — tests populate this to make
528
- * `listRecent` return meaningful `integrationId` values. The memory
528
+ * `listRecent` return meaningful `connectionId` values. The memory
529
529
  * backend doesn't track subscriptions on its own (only runs + items), so
530
530
  * this map is the intentional extension point: tests write entries for
531
531
  * the subscription ids they use, production code never touches it.
@@ -554,10 +554,10 @@ var MemoryRunRecorder = class {
554
554
  }
555
555
  async recordItem(input) {
556
556
  FieldDiffSchema.parse(input.changedFields);
557
- const bucket = this.items.get(input.syncRunId);
557
+ const bucket = this.items.get(input.integrationRunId);
558
558
  if (!bucket) {
559
559
  throw new Error(
560
- `MemoryRunRecorder.recordItem: no run started for id '${input.syncRunId}'. Call startRun(...) first.`
560
+ `MemoryRunRecorder.recordItem: no run started for id '${input.integrationRunId}'. Call startRun(...) first.`
561
561
  );
562
562
  }
563
563
  bucket.push(input);
@@ -583,10 +583,10 @@ var MemoryRunRecorder = class {
583
583
  return filtered.sort((a, b) => b.startedAt.getTime() - a.startedAt.getTime()).slice(0, limit).map((r) => ({
584
584
  id: r.id,
585
585
  subscriptionId: r.subscriptionId,
586
- // integrationId is only knowable if the test seeded subscriptions
586
+ // connectionId is only knowable if the test seeded subscriptions
587
587
  // metadata; empty string otherwise. The Drizzle backend resolves
588
588
  // it via JOIN, which is the production path.
589
- integrationId: this.subscriptions.get(r.subscriptionId)?.integrationId ?? "",
589
+ connectionId: this.subscriptions.get(r.subscriptionId)?.connectionId ?? "",
590
590
  status: r.status,
591
591
  startedAt: r.startedAt,
592
592
  completedAt: r.completedAt,
@@ -614,7 +614,7 @@ MemoryRunRecorder = __decorateClass([
614
614
  Injectable2()
615
615
  ], MemoryRunRecorder);
616
616
 
617
- // runtime/subsystems/sync/deep-equal.differ.ts
617
+ // runtime/subsystems/integration/deep-equal.differ.ts
618
618
  import { Injectable as Injectable3 } from "@nestjs/common";
619
619
  var DEFAULT_IGNORE_FIELDS = /* @__PURE__ */ new Set([
620
620
  "id",
@@ -713,9 +713,9 @@ function deepEqualObject(a, b) {
713
713
  return true;
714
714
  }
715
715
 
716
- // runtime/subsystems/sync/execute-sync.use-case.ts
716
+ // runtime/subsystems/integration/execute-integration.use-case.ts
717
717
  import { Inject, Injectable as Injectable4, Logger, Optional } from "@nestjs/common";
718
- var ExecuteSyncUseCase = class {
718
+ var ExecuteIntegrationUseCase = class {
719
719
  constructor(source, cursors, differ, sink, recorder, multiTenant = false) {
720
720
  this.source = source;
721
721
  this.cursors = cursors;
@@ -730,7 +730,7 @@ var ExecuteSyncUseCase = class {
730
730
  sink;
731
731
  recorder;
732
732
  multiTenant;
733
- logger = new Logger(ExecuteSyncUseCase.name);
733
+ logger = new Logger(ExecuteIntegrationUseCase.name);
734
734
  async execute(input) {
735
735
  assertTenantId(input.tenantId, {
736
736
  multiTenant: this.multiTenant,
@@ -765,10 +765,10 @@ var ExecuteSyncUseCase = class {
765
765
  recordsFailed++;
766
766
  const message = err instanceof Error ? err.message : String(err);
767
767
  this.logger.warn(
768
- `sync item failed: subscription=${input.subscription.id} externalId=${change.externalId}: ${message}`
768
+ `integration item failed: subscription=${input.subscription.id} externalId=${change.externalId}: ${message}`
769
769
  );
770
770
  await this.recorder.recordItem({
771
- syncRunId: runId,
771
+ integrationRunId: runId,
772
772
  entityType: input.subscription.domain,
773
773
  externalId: change.externalId,
774
774
  operation: change.operation === "deleted" ? "deleted" : "updated",
@@ -791,7 +791,7 @@ var ExecuteSyncUseCase = class {
791
791
  status = "failed";
792
792
  runError = err instanceof Error ? err.message : String(err);
793
793
  this.logger.error(
794
- `sync source failed: subscription=${input.subscription.id}: ${runError}`
794
+ `integration source failed: subscription=${input.subscription.id}: ${runError}`
795
795
  );
796
796
  }
797
797
  if (cursorAdvanced && latestCursor !== null && latestCursor !== void 0) {
@@ -836,7 +836,7 @@ var ExecuteSyncUseCase = class {
836
836
  change.externalId
837
837
  );
838
838
  await this.recorder.recordItem({
839
- syncRunId: runId,
839
+ integrationRunId: runId,
840
840
  entityType: input.subscription.domain,
841
841
  externalId: change.externalId,
842
842
  localId: result?.id ?? null,
@@ -859,7 +859,7 @@ var ExecuteSyncUseCase = class {
859
859
  if (diff === "noop") {
860
860
  if (!this.sink.reprojectsOnNoop) {
861
861
  await this.recorder.recordItem({
862
- syncRunId: runId,
862
+ integrationRunId: runId,
863
863
  entityType: input.subscription.domain,
864
864
  externalId: change.externalId,
865
865
  localId: null,
@@ -876,7 +876,7 @@ var ExecuteSyncUseCase = class {
876
876
  input.provider
877
877
  );
878
878
  await this.recorder.recordItem({
879
- syncRunId: runId,
879
+ integrationRunId: runId,
880
880
  entityType: input.subscription.domain,
881
881
  externalId: change.externalId,
882
882
  localId: noopLocalId,
@@ -893,7 +893,7 @@ var ExecuteSyncUseCase = class {
893
893
  input.provider
894
894
  );
895
895
  await this.recorder.recordItem({
896
- syncRunId: runId,
896
+ integrationRunId: runId,
897
897
  entityType: input.subscription.domain,
898
898
  externalId: change.externalId,
899
899
  localId,
@@ -904,25 +904,25 @@ var ExecuteSyncUseCase = class {
904
904
  });
905
905
  }
906
906
  };
907
- ExecuteSyncUseCase = __decorateClass([
907
+ ExecuteIntegrationUseCase = __decorateClass([
908
908
  Injectable4(),
909
- __decorateParam(0, Inject(SYNC_CHANGE_SOURCE)),
910
- __decorateParam(1, Inject(SYNC_CURSOR_STORE)),
911
- __decorateParam(2, Inject(SYNC_FIELD_DIFFER)),
912
- __decorateParam(3, Inject(SYNC_SINK)),
913
- __decorateParam(4, Inject(SYNC_RUN_RECORDER)),
909
+ __decorateParam(0, Inject(INTEGRATION_CHANGE_SOURCE)),
910
+ __decorateParam(1, Inject(INTEGRATION_CURSOR_STORE)),
911
+ __decorateParam(2, Inject(INTEGRATION_FIELD_DIFFER)),
912
+ __decorateParam(3, Inject(INTEGRATION_SINK)),
913
+ __decorateParam(4, Inject(INTEGRATION_RUN_RECORDER)),
914
914
  __decorateParam(5, Optional()),
915
- __decorateParam(5, Inject(SYNC_MULTI_TENANT))
916
- ], ExecuteSyncUseCase);
915
+ __decorateParam(5, Inject(INTEGRATION_MULTI_TENANT))
916
+ ], ExecuteIntegrationUseCase);
917
917
 
918
- // runtime/subsystems/sync/sync-cursor-store.drizzle-backend.ts
918
+ // runtime/subsystems/integration/integration-cursor-store.drizzle-backend.ts
919
919
  import { Inject as Inject2, Injectable as Injectable5, Optional as Optional2 } from "@nestjs/common";
920
920
  import { and, desc, eq } from "drizzle-orm";
921
921
 
922
922
  // runtime/constants/tokens.ts
923
923
  var DRIZZLE = "DRIZZLE";
924
924
 
925
- // runtime/subsystems/sync/sync-cursor-store.drizzle-backend.ts
925
+ // runtime/subsystems/integration/integration-cursor-store.drizzle-backend.ts
926
926
  var PostgresCursorStore = class {
927
927
  constructor(db, multiTenant) {
928
928
  this.db = db;
@@ -932,15 +932,15 @@ var PostgresCursorStore = class {
932
932
  multiTenant;
933
933
  async get(subscriptionId, tenantId) {
934
934
  const where = this.buildWhere(subscriptionId, tenantId, "cursor.get");
935
- const rows = await this.db.select({ cursor: syncSubscriptions.cursor }).from(syncSubscriptions).where(where).limit(1);
935
+ const rows = await this.db.select({ cursor: integrationSubscriptions.cursor }).from(integrationSubscriptions).where(where).limit(1);
936
936
  if (rows.length === 0) return null;
937
937
  return rows[0]?.cursor ?? null;
938
938
  }
939
939
  async put(subscriptionId, cursor, tenantId) {
940
940
  const where = this.buildWhere(subscriptionId, tenantId, "cursor.put");
941
- await this.db.update(syncSubscriptions).set({
941
+ await this.db.update(integrationSubscriptions).set({
942
942
  cursor,
943
- lastSyncAt: /* @__PURE__ */ new Date(),
943
+ lastIntegrationAt: /* @__PURE__ */ new Date(),
944
944
  updatedAt: /* @__PURE__ */ new Date()
945
945
  }).where(where);
946
946
  }
@@ -949,26 +949,26 @@ var PostgresCursorStore = class {
949
949
  multiTenant: this.multiTenant,
950
950
  operation: "cursor.listAll"
951
951
  });
952
- const where = this.multiTenant ? eq(syncSubscriptions.tenantId, tenantId) : void 0;
952
+ const where = this.multiTenant ? eq(integrationSubscriptions.tenantId, tenantId) : void 0;
953
953
  const rows = await this.db.select({
954
- id: syncSubscriptions.id,
955
- integrationId: syncSubscriptions.integrationId,
956
- adapter: syncSubscriptions.adapter,
957
- domain: syncSubscriptions.domain,
958
- externalRef: syncSubscriptions.externalRef,
959
- cursor: syncSubscriptions.cursor,
960
- lastSyncAt: syncSubscriptions.lastSyncAt,
961
- updatedAt: syncSubscriptions.updatedAt,
962
- tenantId: syncSubscriptions.tenantId
963
- }).from(syncSubscriptions).where(where).orderBy(desc(syncSubscriptions.updatedAt));
954
+ id: integrationSubscriptions.id,
955
+ connectionId: integrationSubscriptions.connectionId,
956
+ adapter: integrationSubscriptions.adapter,
957
+ domain: integrationSubscriptions.domain,
958
+ externalRef: integrationSubscriptions.externalRef,
959
+ cursor: integrationSubscriptions.cursor,
960
+ lastIntegrationAt: integrationSubscriptions.lastIntegrationAt,
961
+ updatedAt: integrationSubscriptions.updatedAt,
962
+ tenantId: integrationSubscriptions.tenantId
963
+ }).from(integrationSubscriptions).where(where).orderBy(desc(integrationSubscriptions.updatedAt));
964
964
  return rows.map((row) => ({
965
965
  subscriptionId: row.id,
966
- integrationId: row.integrationId,
966
+ connectionId: row.connectionId,
967
967
  adapter: row.adapter,
968
968
  domain: row.domain,
969
969
  externalRef: row.externalRef,
970
970
  cursor: row.cursor ?? null,
971
- lastSyncAt: row.lastSyncAt,
971
+ lastIntegrationAt: row.lastIntegrationAt,
972
972
  updatedAt: row.updatedAt,
973
973
  tenantId: row.tenantId
974
974
  }));
@@ -985,24 +985,24 @@ var PostgresCursorStore = class {
985
985
  });
986
986
  if (this.multiTenant) {
987
987
  return and(
988
- eq(syncSubscriptions.id, subscriptionId),
989
- eq(syncSubscriptions.tenantId, tenantId)
988
+ eq(integrationSubscriptions.id, subscriptionId),
989
+ eq(integrationSubscriptions.tenantId, tenantId)
990
990
  );
991
991
  }
992
- return eq(syncSubscriptions.id, subscriptionId);
992
+ return eq(integrationSubscriptions.id, subscriptionId);
993
993
  }
994
994
  };
995
995
  PostgresCursorStore = __decorateClass([
996
996
  Injectable5(),
997
997
  __decorateParam(0, Inject2(DRIZZLE)),
998
998
  __decorateParam(1, Optional2()),
999
- __decorateParam(1, Inject2(SYNC_MULTI_TENANT))
999
+ __decorateParam(1, Inject2(INTEGRATION_MULTI_TENANT))
1000
1000
  ], PostgresCursorStore);
1001
1001
 
1002
- // runtime/subsystems/sync/sync-run-recorder.drizzle-backend.ts
1002
+ // runtime/subsystems/integration/integration-run-recorder.drizzle-backend.ts
1003
1003
  import { Inject as Inject3, Injectable as Injectable6, Optional as Optional3 } from "@nestjs/common";
1004
1004
  import { and as and2, desc as desc2, eq as eq2 } from "drizzle-orm";
1005
- var DrizzleSyncRunRecorder = class {
1005
+ var DrizzleIntegrationRunRecorder = class {
1006
1006
  constructor(db, multiTenant) {
1007
1007
  this.db = db;
1008
1008
  this.multiTenant = multiTenant ?? false;
@@ -1014,17 +1014,17 @@ var DrizzleSyncRunRecorder = class {
1014
1014
  multiTenant: this.multiTenant,
1015
1015
  operation: "startRun"
1016
1016
  });
1017
- const rows = await this.db.insert(syncRuns).values({
1017
+ const rows = await this.db.insert(integrationRuns).values({
1018
1018
  subscriptionId: input.subscriptionId,
1019
1019
  direction: input.direction,
1020
1020
  action: input.action,
1021
1021
  status: "running",
1022
1022
  cursorBefore: input.cursorBefore ?? null,
1023
1023
  tenantId: input.tenantId ?? null
1024
- }).returning({ id: syncRuns.id });
1024
+ }).returning({ id: integrationRuns.id });
1025
1025
  const id = rows[0]?.id;
1026
1026
  if (!id) {
1027
- throw new Error("DrizzleSyncRunRecorder: INSERT RETURNING produced no id");
1027
+ throw new Error("DrizzleIntegrationRunRecorder: INSERT RETURNING produced no id");
1028
1028
  }
1029
1029
  return { id };
1030
1030
  }
@@ -1034,8 +1034,8 @@ var DrizzleSyncRunRecorder = class {
1034
1034
  operation: "recordItem"
1035
1035
  });
1036
1036
  FieldDiffSchema.parse(input.changedFields);
1037
- await this.db.insert(syncRunItems).values({
1038
- syncRunId: input.syncRunId,
1037
+ await this.db.insert(integrationRunItems).values({
1038
+ integrationRunId: input.integrationRunId,
1039
1039
  entityType: input.entityType,
1040
1040
  externalId: input.externalId,
1041
1041
  localId: input.localId ?? null,
@@ -1054,29 +1054,29 @@ var DrizzleSyncRunRecorder = class {
1054
1054
  });
1055
1055
  const conditions = [];
1056
1056
  if (subscriptionId !== void 0) {
1057
- conditions.push(eq2(syncRuns.subscriptionId, subscriptionId));
1057
+ conditions.push(eq2(integrationRuns.subscriptionId, subscriptionId));
1058
1058
  }
1059
1059
  if (this.multiTenant) {
1060
- conditions.push(eq2(syncRuns.tenantId, tenantId));
1060
+ conditions.push(eq2(integrationRuns.tenantId, tenantId));
1061
1061
  }
1062
1062
  const where = conditions.length === 0 ? void 0 : conditions.length === 1 ? conditions[0] : and2(...conditions);
1063
1063
  const rows = await this.db.select({
1064
- id: syncRuns.id,
1065
- subscriptionId: syncRuns.subscriptionId,
1066
- integrationId: syncSubscriptions.integrationId,
1067
- status: syncRuns.status,
1068
- startedAt: syncRuns.startedAt,
1069
- completedAt: syncRuns.completedAt,
1070
- recordsProcessed: syncRuns.recordsProcessed,
1071
- tenantId: syncRuns.tenantId
1072
- }).from(syncRuns).innerJoin(
1073
- syncSubscriptions,
1074
- eq2(syncRuns.subscriptionId, syncSubscriptions.id)
1075
- ).where(where).orderBy(desc2(syncRuns.startedAt)).limit(limit);
1064
+ id: integrationRuns.id,
1065
+ subscriptionId: integrationRuns.subscriptionId,
1066
+ connectionId: integrationSubscriptions.connectionId,
1067
+ status: integrationRuns.status,
1068
+ startedAt: integrationRuns.startedAt,
1069
+ completedAt: integrationRuns.completedAt,
1070
+ recordsProcessed: integrationRuns.recordsProcessed,
1071
+ tenantId: integrationRuns.tenantId
1072
+ }).from(integrationRuns).innerJoin(
1073
+ integrationSubscriptions,
1074
+ eq2(integrationRuns.subscriptionId, integrationSubscriptions.id)
1075
+ ).where(where).orderBy(desc2(integrationRuns.startedAt)).limit(limit);
1076
1076
  return rows.map((row) => ({
1077
1077
  id: row.id,
1078
1078
  subscriptionId: row.subscriptionId,
1079
- integrationId: row.integrationId,
1079
+ connectionId: row.connectionId,
1080
1080
  status: row.status,
1081
1081
  startedAt: row.startedAt,
1082
1082
  completedAt: row.completedAt,
@@ -1085,7 +1085,7 @@ var DrizzleSyncRunRecorder = class {
1085
1085
  }));
1086
1086
  }
1087
1087
  async completeRun(runId, input) {
1088
- await this.db.update(syncRuns).set({
1088
+ await this.db.update(integrationRuns).set({
1089
1089
  status: input.status,
1090
1090
  recordsFound: input.recordsFound,
1091
1091
  recordsProcessed: input.recordsProcessed,
@@ -1093,27 +1093,27 @@ var DrizzleSyncRunRecorder = class {
1093
1093
  durationMs: input.durationMs,
1094
1094
  error: input.error ?? null,
1095
1095
  completedAt: /* @__PURE__ */ new Date()
1096
- }).where(eq2(syncRuns.id, runId));
1096
+ }).where(eq2(integrationRuns.id, runId));
1097
1097
  }
1098
1098
  };
1099
- DrizzleSyncRunRecorder = __decorateClass([
1099
+ DrizzleIntegrationRunRecorder = __decorateClass([
1100
1100
  Injectable6(),
1101
1101
  __decorateParam(0, Inject3(DRIZZLE)),
1102
1102
  __decorateParam(1, Optional3()),
1103
- __decorateParam(1, Inject3(SYNC_MULTI_TENANT))
1104
- ], DrizzleSyncRunRecorder);
1103
+ __decorateParam(1, Inject3(INTEGRATION_MULTI_TENANT))
1104
+ ], DrizzleIntegrationRunRecorder);
1105
1105
 
1106
- // runtime/subsystems/sync/sync.module.ts
1106
+ // runtime/subsystems/integration/integration.module.ts
1107
1107
  import { Module } from "@nestjs/common";
1108
- var SyncModule = class {
1108
+ var IntegrationModule = class {
1109
1109
  static forRoot(options) {
1110
1110
  const multiTenant = options.multiTenant ?? false;
1111
1111
  const sharedProviders = [
1112
- { provide: SYNC_MODULE_OPTIONS, useValue: options },
1113
- { provide: SYNC_MULTI_TENANT, useValue: multiTenant },
1112
+ { provide: INTEGRATION_MODULE_OPTIONS, useValue: options },
1113
+ { provide: INTEGRATION_MULTI_TENANT, useValue: multiTenant },
1114
1114
  // Default differ — consumers can override by binding a different
1115
- // `IFieldDiffer<T>` to `SYNC_FIELD_DIFFER` in their feature module.
1116
- { provide: SYNC_FIELD_DIFFER, useValue: new DeepEqualDiffer() }
1115
+ // `IFieldDiffer<T>` to `INTEGRATION_FIELD_DIFFER` in their feature module.
1116
+ { provide: INTEGRATION_FIELD_DIFFER, useValue: new DeepEqualDiffer() }
1117
1117
  ];
1118
1118
  const backendProviders = options.backend === "memory" ? [
1119
1119
  // Wired as singletons via `useValue` so tests can pull
@@ -1121,47 +1121,55 @@ var SyncModule = class {
1121
1121
  // direct assertions. Matches JOB-4 / MemoryJobStore shape.
1122
1122
  { provide: MemoryCursorStore, useValue: new MemoryCursorStore() },
1123
1123
  {
1124
- provide: SYNC_CURSOR_STORE,
1124
+ provide: INTEGRATION_CURSOR_STORE,
1125
1125
  useExisting: MemoryCursorStore
1126
1126
  },
1127
1127
  { provide: MemoryRunRecorder, useValue: new MemoryRunRecorder() },
1128
1128
  {
1129
- provide: SYNC_RUN_RECORDER,
1129
+ provide: INTEGRATION_RUN_RECORDER,
1130
1130
  useExisting: MemoryRunRecorder
1131
1131
  }
1132
1132
  ] : [
1133
1133
  // Drizzle backends — injected with DRIZZLE (provided by the
1134
- // consumer's DrizzleModule) + the SYNC_MULTI_TENANT flag
1134
+ // consumer's DrizzleModule) + the INTEGRATION_MULTI_TENANT flag
1135
1135
  // we bound above.
1136
- { provide: SYNC_CURSOR_STORE, useClass: PostgresCursorStore },
1137
- { provide: SYNC_RUN_RECORDER, useClass: DrizzleSyncRunRecorder }
1136
+ { provide: INTEGRATION_CURSOR_STORE, useClass: PostgresCursorStore },
1137
+ { provide: INTEGRATION_RUN_RECORDER, useClass: DrizzleIntegrationRunRecorder }
1138
1138
  ];
1139
1139
  return {
1140
- module: SyncModule,
1140
+ module: IntegrationModule,
1141
1141
  global: true,
1142
1142
  providers: [...sharedProviders, ...backendProviders],
1143
1143
  exports: [
1144
- SYNC_MODULE_OPTIONS,
1145
- SYNC_MULTI_TENANT,
1146
- SYNC_FIELD_DIFFER,
1147
- SYNC_CURSOR_STORE,
1148
- SYNC_RUN_RECORDER
1144
+ INTEGRATION_MODULE_OPTIONS,
1145
+ INTEGRATION_MULTI_TENANT,
1146
+ INTEGRATION_FIELD_DIFFER,
1147
+ INTEGRATION_CURSOR_STORE,
1148
+ INTEGRATION_RUN_RECORDER
1149
1149
  ]
1150
1150
  };
1151
1151
  }
1152
1152
  };
1153
- SyncModule = __decorateClass([
1153
+ IntegrationModule = __decorateClass([
1154
1154
  Module({})
1155
- ], SyncModule);
1155
+ ], IntegrationModule);
1156
1156
  export {
1157
1157
  CursorStrategySchema,
1158
1158
  DeepEqualDiffer,
1159
1159
  DetectionConfigSchema,
1160
- DrizzleSyncRunRecorder,
1161
- ExecuteSyncUseCase,
1160
+ DrizzleIntegrationRunRecorder,
1161
+ ExecuteIntegrationUseCase,
1162
1162
  FieldDiffSchema,
1163
1163
  FieldDiffValueSchema,
1164
1164
  FieldMappingSchema,
1165
+ INTEGRATION_CHANGE_SOURCE,
1166
+ INTEGRATION_CURSOR_STORE,
1167
+ INTEGRATION_FIELD_DIFFER,
1168
+ INTEGRATION_MODULE_OPTIONS,
1169
+ INTEGRATION_MULTI_TENANT,
1170
+ INTEGRATION_RUN_RECORDER,
1171
+ INTEGRATION_SINK,
1172
+ IntegrationModule,
1165
1173
  MemoryCursorStore,
1166
1174
  MemoryRunRecorder,
1167
1175
  MissingTenantIdError,
@@ -1169,26 +1177,18 @@ export {
1169
1177
  PollDetectionSchema,
1170
1178
  PostgresCursorStore,
1171
1179
  ResolvedFilterSchema,
1172
- SYNC_CHANGE_SOURCE,
1173
- SYNC_CURSOR_STORE,
1174
- SYNC_FIELD_DIFFER,
1175
- SYNC_MODULE_OPTIONS,
1176
- SYNC_MULTI_TENANT,
1177
- SYNC_RUN_RECORDER,
1178
- SYNC_SINK,
1179
- SyncModule,
1180
1180
  WebhookChangeSource,
1181
1181
  WebhookDetectionSchema,
1182
1182
  assertTenantId,
1183
1183
  buildChangeSource,
1184
1184
  createLoopbackMiddleware,
1185
- syncRunActionEnum,
1186
- syncRunDirectionEnum,
1187
- syncRunItemOperationEnum,
1188
- syncRunItemStatusEnum,
1189
- syncRunItems,
1190
- syncRunStatusEnum,
1191
- syncRuns,
1192
- syncSubscriptions
1185
+ integrationRunActionEnum,
1186
+ integrationRunDirectionEnum,
1187
+ integrationRunItemOperationEnum,
1188
+ integrationRunItemStatusEnum,
1189
+ integrationRunItems,
1190
+ integrationRunStatusEnum,
1191
+ integrationRuns,
1192
+ integrationSubscriptions
1193
1193
  };
1194
1194
  //# sourceMappingURL=index.js.map