@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,17 +10,17 @@ 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.module.ts
13
+ // runtime/subsystems/integration/integration.module.ts
14
14
  import { Module } from "@nestjs/common";
15
15
 
16
- // runtime/subsystems/sync/sync.tokens.ts
17
- var SYNC_CURSOR_STORE = "SYNC_CURSOR_STORE";
18
- var SYNC_FIELD_DIFFER = "SYNC_FIELD_DIFFER";
19
- var SYNC_RUN_RECORDER = "SYNC_RUN_RECORDER";
20
- var SYNC_MODULE_OPTIONS = "SYNC_MODULE_OPTIONS";
21
- var SYNC_MULTI_TENANT = "SYNC_MULTI_TENANT";
16
+ // runtime/subsystems/integration/integration.tokens.ts
17
+ var INTEGRATION_CURSOR_STORE = "INTEGRATION_CURSOR_STORE";
18
+ var INTEGRATION_FIELD_DIFFER = "INTEGRATION_FIELD_DIFFER";
19
+ var INTEGRATION_RUN_RECORDER = "INTEGRATION_RUN_RECORDER";
20
+ var INTEGRATION_MODULE_OPTIONS = "INTEGRATION_MODULE_OPTIONS";
21
+ var INTEGRATION_MULTI_TENANT = "INTEGRATION_MULTI_TENANT";
22
22
 
23
- // runtime/subsystems/sync/sync-cursor-store.memory-backend.ts
23
+ // runtime/subsystems/integration/integration-cursor-store.memory-backend.ts
24
24
  import { Injectable } from "@nestjs/common";
25
25
  var MemoryCursorStore = class {
26
26
  /**
@@ -31,7 +31,7 @@ var MemoryCursorStore = class {
31
31
  /**
32
32
  * Seedable subscription metadata for `listAll` — the memory backend
33
33
  * stores only `subscriptionId → cursor` in its write path, so the
34
- * snapshot shape (`integrationId`, `adapter`, `domain`, `externalRef`,
34
+ * snapshot shape (`connectionId`, `adapter`, `domain`, `externalRef`,
35
35
  * timestamps) has no natural source without test seeding. Tests populate
36
36
  * this map; unseeded entries get empty-string metadata and `new Date(0)`
37
37
  * timestamps so the shape stays stable. Production paths go through the
@@ -51,12 +51,12 @@ var MemoryCursorStore = class {
51
51
  const meta = this.subscriptions.get(subscriptionId);
52
52
  snapshots.push({
53
53
  subscriptionId,
54
- integrationId: meta?.integrationId ?? "",
54
+ connectionId: meta?.connectionId ?? "",
55
55
  adapter: meta?.adapter ?? "",
56
56
  domain: meta?.domain ?? "",
57
57
  externalRef: meta?.externalRef ?? null,
58
58
  cursor: cursor ?? null,
59
- lastSyncAt: meta?.lastSyncAt ?? null,
59
+ lastIntegrationAt: meta?.lastIntegrationAt ?? null,
60
60
  updatedAt: meta?.updatedAt ?? /* @__PURE__ */ new Date(0),
61
61
  tenantId: null
62
62
  });
@@ -75,10 +75,10 @@ MemoryCursorStore = __decorateClass([
75
75
  Injectable()
76
76
  ], MemoryCursorStore);
77
77
 
78
- // runtime/subsystems/sync/sync-run-recorder.memory-backend.ts
78
+ // runtime/subsystems/integration/integration-run-recorder.memory-backend.ts
79
79
  import { Injectable as Injectable2 } from "@nestjs/common";
80
80
 
81
- // runtime/subsystems/sync/sync-field-diff.protocol.ts
81
+ // runtime/subsystems/integration/integration-field-diff.protocol.ts
82
82
  import { z } from "zod";
83
83
  var FieldDiffValueSchema = z.object({
84
84
  from: z.unknown(),
@@ -86,7 +86,7 @@ var FieldDiffValueSchema = z.object({
86
86
  });
87
87
  var FieldDiffSchema = z.record(z.string(), FieldDiffValueSchema);
88
88
 
89
- // runtime/subsystems/sync/sync-run-recorder.memory-backend.ts
89
+ // runtime/subsystems/integration/integration-run-recorder.memory-backend.ts
90
90
  var MemoryRunRecorder = class {
91
91
  /**
92
92
  * All started runs keyed by id. Public so tests can inspect lifecycle
@@ -94,14 +94,14 @@ var MemoryRunRecorder = class {
94
94
  */
95
95
  runs = /* @__PURE__ */ new Map();
96
96
  /**
97
- * Items keyed by `sync_run_id`, array order matches insertion order —
98
- * mirrors the timeline the `(sync_run_id, created_at)` index produces
97
+ * Items keyed by `integration_run_id`, array order matches insertion order —
98
+ * mirrors the timeline the `(integration_run_id, created_at)` index produces
99
99
  * in Postgres.
100
100
  */
101
101
  items = /* @__PURE__ */ new Map();
102
102
  /**
103
103
  * Seedable subscription metadata — tests populate this to make
104
- * `listRecent` return meaningful `integrationId` values. The memory
104
+ * `listRecent` return meaningful `connectionId` values. The memory
105
105
  * backend doesn't track subscriptions on its own (only runs + items), so
106
106
  * this map is the intentional extension point: tests write entries for
107
107
  * the subscription ids they use, production code never touches it.
@@ -130,10 +130,10 @@ var MemoryRunRecorder = class {
130
130
  }
131
131
  async recordItem(input) {
132
132
  FieldDiffSchema.parse(input.changedFields);
133
- const bucket = this.items.get(input.syncRunId);
133
+ const bucket = this.items.get(input.integrationRunId);
134
134
  if (!bucket) {
135
135
  throw new Error(
136
- `MemoryRunRecorder.recordItem: no run started for id '${input.syncRunId}'. Call startRun(...) first.`
136
+ `MemoryRunRecorder.recordItem: no run started for id '${input.integrationRunId}'. Call startRun(...) first.`
137
137
  );
138
138
  }
139
139
  bucket.push(input);
@@ -159,10 +159,10 @@ var MemoryRunRecorder = class {
159
159
  return filtered.sort((a, b) => b.startedAt.getTime() - a.startedAt.getTime()).slice(0, limit).map((r) => ({
160
160
  id: r.id,
161
161
  subscriptionId: r.subscriptionId,
162
- // integrationId is only knowable if the test seeded subscriptions
162
+ // connectionId is only knowable if the test seeded subscriptions
163
163
  // metadata; empty string otherwise. The Drizzle backend resolves
164
164
  // it via JOIN, which is the production path.
165
- integrationId: this.subscriptions.get(r.subscriptionId)?.integrationId ?? "",
165
+ connectionId: this.subscriptions.get(r.subscriptionId)?.connectionId ?? "",
166
166
  status: r.status,
167
167
  startedAt: r.startedAt,
168
168
  completedAt: r.completedAt,
@@ -190,14 +190,14 @@ MemoryRunRecorder = __decorateClass([
190
190
  Injectable2()
191
191
  ], MemoryRunRecorder);
192
192
 
193
- // runtime/subsystems/sync/sync-cursor-store.drizzle-backend.ts
193
+ // runtime/subsystems/integration/integration-cursor-store.drizzle-backend.ts
194
194
  import { Inject, Injectable as Injectable3, Optional } from "@nestjs/common";
195
195
  import { and, desc, eq } from "drizzle-orm";
196
196
 
197
197
  // runtime/constants/tokens.ts
198
198
  var DRIZZLE = "DRIZZLE";
199
199
 
200
- // runtime/subsystems/sync/sync-audit.schema.ts
200
+ // runtime/subsystems/integration/integration-audit.schema.ts
201
201
  import {
202
202
  pgEnum,
203
203
  pgTable,
@@ -210,39 +210,39 @@ import {
210
210
  index,
211
211
  uniqueIndex
212
212
  } from "drizzle-orm/pg-core";
213
- var syncRunDirectionEnum = pgEnum("sync_run_direction", [
213
+ var integrationRunDirectionEnum = pgEnum("integration_run_direction", [
214
214
  "inbound",
215
215
  "outbound"
216
216
  ]);
217
- var syncRunActionEnum = pgEnum("sync_run_action", [
217
+ var integrationRunActionEnum = pgEnum("integration_run_action", [
218
218
  "poll",
219
219
  "cdc",
220
220
  "webhook",
221
221
  "manual",
222
222
  "writeback"
223
223
  ]);
224
- var syncRunStatusEnum = pgEnum("sync_run_status", [
224
+ var integrationRunStatusEnum = pgEnum("integration_run_status", [
225
225
  "running",
226
226
  "success",
227
227
  "no_changes",
228
228
  "failed"
229
229
  ]);
230
- var syncRunItemOperationEnum = pgEnum("sync_run_item_operation", [
230
+ var integrationRunItemOperationEnum = pgEnum("integration_run_item_operation", [
231
231
  "created",
232
232
  "updated",
233
233
  "deleted",
234
234
  "noop"
235
235
  ]);
236
- var syncRunItemStatusEnum = pgEnum("sync_run_item_status", [
236
+ var integrationRunItemStatusEnum = pgEnum("integration_run_item_status", [
237
237
  "success",
238
238
  "failed",
239
239
  "skipped"
240
240
  ]);
241
- var syncSubscriptions = pgTable(
242
- "sync_subscriptions",
241
+ var integrationSubscriptions = pgTable(
242
+ "integration_subscriptions",
243
243
  {
244
244
  id: uuid("id").primaryKey().defaultRandom(),
245
- integrationId: text("integration_id").notNull(),
245
+ connectionId: text("connection_id").notNull(),
246
246
  adapter: text("adapter").notNull(),
247
247
  domain: text("domain").notNull(),
248
248
  externalRef: text("external_ref"),
@@ -257,8 +257,8 @@ var syncSubscriptions = pgTable(
257
257
  * successful run advances it.
258
258
  */
259
259
  cursor: jsonb("cursor").$type(),
260
- lastSyncAt: timestamp("last_sync_at", { withTimezone: true }),
261
- /** Runtime-enforced when `SYNC_MULTI_TENANT` is true; see SYNC-6. */
260
+ lastIntegrationAt: timestamp("last_integration_at", { withTimezone: true }),
261
+ /** Runtime-enforced when `INTEGRATION_MULTI_TENANT` is true; see SYNC-6. */
262
262
  tenantId: text("tenant_id"),
263
263
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
264
264
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
@@ -267,31 +267,31 @@ var syncSubscriptions = pgTable(
267
267
  /**
268
268
  * Composite uniqueness per the epic shape. `external_ref` is nullable;
269
269
  * Postgres treats NULLs as distinct in a UNIQUE constraint, which means
270
- * two rows with the same `(integration_id, adapter, domain)` and NULL
270
+ * two rows with the same `(connection_id, adapter, domain)` and NULL
271
271
  * external_ref are allowed. That's intentional — a subscription with
272
272
  * NULL external_ref covers the full domain, and duplicates there would
273
273
  * be a consumer-layer modeling issue, not a schema concern.
274
274
  */
275
- uqSyncSubscriptionTuple: uniqueIndex("uq_sync_subscriptions_tuple").on(
276
- t.integrationId,
275
+ uqIntegrationSubscriptionTuple: uniqueIndex("uq_integration_subscriptions_tuple").on(
276
+ t.connectionId,
277
277
  t.adapter,
278
278
  t.domain,
279
279
  t.externalRef
280
280
  ),
281
281
  /** Scheduling query: list enabled subscriptions ordered by staleness. */
282
- idxSyncSubscriptionsEnabledLastSync: index(
283
- "idx_sync_subscriptions_enabled_last_sync"
284
- ).on(t.enabled, t.lastSyncAt)
282
+ idxIntegrationSubscriptionsEnabledLastIntegration: index(
283
+ "idx_integration_subscriptions_enabled_last_integration"
284
+ ).on(t.enabled, t.lastIntegrationAt)
285
285
  })
286
286
  );
287
- var syncRuns = pgTable(
288
- "sync_runs",
287
+ var integrationRuns = pgTable(
288
+ "integration_runs",
289
289
  {
290
290
  id: uuid("id").primaryKey().defaultRandom(),
291
- subscriptionId: uuid("subscription_id").notNull().references(() => syncSubscriptions.id, { onDelete: "cascade" }),
292
- direction: syncRunDirectionEnum("direction").notNull(),
293
- action: syncRunActionEnum("action").notNull(),
294
- status: syncRunStatusEnum("status").notNull().default("running"),
291
+ subscriptionId: uuid("subscription_id").notNull().references(() => integrationSubscriptions.id, { onDelete: "cascade" }),
292
+ direction: integrationRunDirectionEnum("direction").notNull(),
293
+ action: integrationRunActionEnum("action").notNull(),
294
+ status: integrationRunStatusEnum("status").notNull().default("running"),
295
295
  recordsFound: integer("records_found").notNull().default(0),
296
296
  recordsProcessed: integer("records_processed").notNull().default(0),
297
297
  cursorBefore: jsonb("cursor_before").$type(),
@@ -300,31 +300,31 @@ var syncRuns = pgTable(
300
300
  error: text("error"),
301
301
  startedAt: timestamp("started_at", { withTimezone: true }).notNull().defaultNow(),
302
302
  completedAt: timestamp("completed_at", { withTimezone: true }),
303
- /** Runtime-enforced when `SYNC_MULTI_TENANT` is true; see SYNC-6. */
303
+ /** Runtime-enforced when `INTEGRATION_MULTI_TENANT` is true; see SYNC-6. */
304
304
  tenantId: text("tenant_id")
305
305
  },
306
306
  (t) => ({
307
307
  /** Timeline read: "most recent runs for this subscription". */
308
- idxSyncRunsSubscriptionStartedAt: index(
309
- "idx_sync_runs_subscription_started_at"
308
+ idxIntegrationRunsSubscriptionStartedAt: index(
309
+ "idx_integration_runs_subscription_started_at"
310
310
  ).on(t.subscriptionId, t.startedAt),
311
311
  /** Stale-run sweeper: "runs that started > N minutes ago and are still running". */
312
- idxSyncRunsStatusStartedAt: index("idx_sync_runs_status_started_at").on(
312
+ idxIntegrationRunsStatusStartedAt: index("idx_integration_runs_status_started_at").on(
313
313
  t.status,
314
314
  t.startedAt
315
315
  )
316
316
  })
317
317
  );
318
- var syncRunItems = pgTable(
319
- "sync_run_items",
318
+ var integrationRunItems = pgTable(
319
+ "integration_run_items",
320
320
  {
321
321
  id: uuid("id").primaryKey().defaultRandom(),
322
- syncRunId: uuid("sync_run_id").notNull().references(() => syncRuns.id, { onDelete: "cascade" }),
322
+ integrationRunId: uuid("integration_run_id").notNull().references(() => integrationRuns.id, { onDelete: "cascade" }),
323
323
  entityType: text("entity_type").notNull(),
324
324
  externalId: text("external_id").notNull(),
325
325
  localId: text("local_id"),
326
- operation: syncRunItemOperationEnum("operation").notNull(),
327
- status: syncRunItemStatusEnum("status").notNull(),
326
+ operation: integrationRunItemOperationEnum("operation").notNull(),
327
+ status: integrationRunItemStatusEnum("status").notNull(),
328
328
  /**
329
329
  * Structured per-field diff — ADR-0003 shape enforced by
330
330
  * `FieldDiffSchema.parse` at the recorder service layer.
@@ -338,28 +338,28 @@ var syncRunItems = pgTable(
338
338
  title: text("title"),
339
339
  error: text("error"),
340
340
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
341
- /** Runtime-enforced when `SYNC_MULTI_TENANT` is true; see SYNC-6. */
341
+ /** Runtime-enforced when `INTEGRATION_MULTI_TENANT` is true; see SYNC-6. */
342
342
  tenantId: text("tenant_id")
343
343
  },
344
344
  (t) => ({
345
345
  /** Ordered timeline within a run. */
346
- idxSyncRunItemsRunCreatedAt: index("idx_sync_run_items_run_created_at").on(
347
- t.syncRunId,
346
+ idxIntegrationRunItemsRunCreatedAt: index("idx_integration_run_items_run_created_at").on(
347
+ t.integrationRunId,
348
348
  t.createdAt
349
349
  ),
350
- /** Per-record history: "every sync that touched opportunity/$extId". */
351
- idxSyncRunItemsEntityExternal: index(
352
- "idx_sync_run_items_entity_external"
350
+ /** Per-record history: "every integration that touched opportunity/$extId". */
351
+ idxIntegrationRunItemsEntityExternal: index(
352
+ "idx_integration_run_items_entity_external"
353
353
  ).on(t.entityType, t.externalId)
354
354
  })
355
355
  );
356
356
 
357
- // runtime/subsystems/sync/sync-errors.ts
357
+ // runtime/subsystems/integration/integration-errors.ts
358
358
  var MissingTenantIdError = class extends Error {
359
359
  name = "MissingTenantIdError";
360
360
  constructor(operation) {
361
361
  super(
362
- `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.`
362
+ `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.`
363
363
  );
364
364
  }
365
365
  };
@@ -370,7 +370,7 @@ function assertTenantId(tenantId, options) {
370
370
  }
371
371
  }
372
372
 
373
- // runtime/subsystems/sync/sync-cursor-store.drizzle-backend.ts
373
+ // runtime/subsystems/integration/integration-cursor-store.drizzle-backend.ts
374
374
  var PostgresCursorStore = class {
375
375
  constructor(db, multiTenant) {
376
376
  this.db = db;
@@ -380,15 +380,15 @@ var PostgresCursorStore = class {
380
380
  multiTenant;
381
381
  async get(subscriptionId, tenantId) {
382
382
  const where = this.buildWhere(subscriptionId, tenantId, "cursor.get");
383
- const rows = await this.db.select({ cursor: syncSubscriptions.cursor }).from(syncSubscriptions).where(where).limit(1);
383
+ const rows = await this.db.select({ cursor: integrationSubscriptions.cursor }).from(integrationSubscriptions).where(where).limit(1);
384
384
  if (rows.length === 0) return null;
385
385
  return rows[0]?.cursor ?? null;
386
386
  }
387
387
  async put(subscriptionId, cursor, tenantId) {
388
388
  const where = this.buildWhere(subscriptionId, tenantId, "cursor.put");
389
- await this.db.update(syncSubscriptions).set({
389
+ await this.db.update(integrationSubscriptions).set({
390
390
  cursor,
391
- lastSyncAt: /* @__PURE__ */ new Date(),
391
+ lastIntegrationAt: /* @__PURE__ */ new Date(),
392
392
  updatedAt: /* @__PURE__ */ new Date()
393
393
  }).where(where);
394
394
  }
@@ -397,26 +397,26 @@ var PostgresCursorStore = class {
397
397
  multiTenant: this.multiTenant,
398
398
  operation: "cursor.listAll"
399
399
  });
400
- const where = this.multiTenant ? eq(syncSubscriptions.tenantId, tenantId) : void 0;
400
+ const where = this.multiTenant ? eq(integrationSubscriptions.tenantId, tenantId) : void 0;
401
401
  const rows = await this.db.select({
402
- id: syncSubscriptions.id,
403
- integrationId: syncSubscriptions.integrationId,
404
- adapter: syncSubscriptions.adapter,
405
- domain: syncSubscriptions.domain,
406
- externalRef: syncSubscriptions.externalRef,
407
- cursor: syncSubscriptions.cursor,
408
- lastSyncAt: syncSubscriptions.lastSyncAt,
409
- updatedAt: syncSubscriptions.updatedAt,
410
- tenantId: syncSubscriptions.tenantId
411
- }).from(syncSubscriptions).where(where).orderBy(desc(syncSubscriptions.updatedAt));
402
+ id: integrationSubscriptions.id,
403
+ connectionId: integrationSubscriptions.connectionId,
404
+ adapter: integrationSubscriptions.adapter,
405
+ domain: integrationSubscriptions.domain,
406
+ externalRef: integrationSubscriptions.externalRef,
407
+ cursor: integrationSubscriptions.cursor,
408
+ lastIntegrationAt: integrationSubscriptions.lastIntegrationAt,
409
+ updatedAt: integrationSubscriptions.updatedAt,
410
+ tenantId: integrationSubscriptions.tenantId
411
+ }).from(integrationSubscriptions).where(where).orderBy(desc(integrationSubscriptions.updatedAt));
412
412
  return rows.map((row) => ({
413
413
  subscriptionId: row.id,
414
- integrationId: row.integrationId,
414
+ connectionId: row.connectionId,
415
415
  adapter: row.adapter,
416
416
  domain: row.domain,
417
417
  externalRef: row.externalRef,
418
418
  cursor: row.cursor ?? null,
419
- lastSyncAt: row.lastSyncAt,
419
+ lastIntegrationAt: row.lastIntegrationAt,
420
420
  updatedAt: row.updatedAt,
421
421
  tenantId: row.tenantId
422
422
  }));
@@ -433,24 +433,24 @@ var PostgresCursorStore = class {
433
433
  });
434
434
  if (this.multiTenant) {
435
435
  return and(
436
- eq(syncSubscriptions.id, subscriptionId),
437
- eq(syncSubscriptions.tenantId, tenantId)
436
+ eq(integrationSubscriptions.id, subscriptionId),
437
+ eq(integrationSubscriptions.tenantId, tenantId)
438
438
  );
439
439
  }
440
- return eq(syncSubscriptions.id, subscriptionId);
440
+ return eq(integrationSubscriptions.id, subscriptionId);
441
441
  }
442
442
  };
443
443
  PostgresCursorStore = __decorateClass([
444
444
  Injectable3(),
445
445
  __decorateParam(0, Inject(DRIZZLE)),
446
446
  __decorateParam(1, Optional()),
447
- __decorateParam(1, Inject(SYNC_MULTI_TENANT))
447
+ __decorateParam(1, Inject(INTEGRATION_MULTI_TENANT))
448
448
  ], PostgresCursorStore);
449
449
 
450
- // runtime/subsystems/sync/sync-run-recorder.drizzle-backend.ts
450
+ // runtime/subsystems/integration/integration-run-recorder.drizzle-backend.ts
451
451
  import { Inject as Inject2, Injectable as Injectable4, Optional as Optional2 } from "@nestjs/common";
452
452
  import { and as and2, desc as desc2, eq as eq2 } from "drizzle-orm";
453
- var DrizzleSyncRunRecorder = class {
453
+ var DrizzleIntegrationRunRecorder = class {
454
454
  constructor(db, multiTenant) {
455
455
  this.db = db;
456
456
  this.multiTenant = multiTenant ?? false;
@@ -462,17 +462,17 @@ var DrizzleSyncRunRecorder = class {
462
462
  multiTenant: this.multiTenant,
463
463
  operation: "startRun"
464
464
  });
465
- const rows = await this.db.insert(syncRuns).values({
465
+ const rows = await this.db.insert(integrationRuns).values({
466
466
  subscriptionId: input.subscriptionId,
467
467
  direction: input.direction,
468
468
  action: input.action,
469
469
  status: "running",
470
470
  cursorBefore: input.cursorBefore ?? null,
471
471
  tenantId: input.tenantId ?? null
472
- }).returning({ id: syncRuns.id });
472
+ }).returning({ id: integrationRuns.id });
473
473
  const id = rows[0]?.id;
474
474
  if (!id) {
475
- throw new Error("DrizzleSyncRunRecorder: INSERT RETURNING produced no id");
475
+ throw new Error("DrizzleIntegrationRunRecorder: INSERT RETURNING produced no id");
476
476
  }
477
477
  return { id };
478
478
  }
@@ -482,8 +482,8 @@ var DrizzleSyncRunRecorder = class {
482
482
  operation: "recordItem"
483
483
  });
484
484
  FieldDiffSchema.parse(input.changedFields);
485
- await this.db.insert(syncRunItems).values({
486
- syncRunId: input.syncRunId,
485
+ await this.db.insert(integrationRunItems).values({
486
+ integrationRunId: input.integrationRunId,
487
487
  entityType: input.entityType,
488
488
  externalId: input.externalId,
489
489
  localId: input.localId ?? null,
@@ -502,29 +502,29 @@ var DrizzleSyncRunRecorder = class {
502
502
  });
503
503
  const conditions = [];
504
504
  if (subscriptionId !== void 0) {
505
- conditions.push(eq2(syncRuns.subscriptionId, subscriptionId));
505
+ conditions.push(eq2(integrationRuns.subscriptionId, subscriptionId));
506
506
  }
507
507
  if (this.multiTenant) {
508
- conditions.push(eq2(syncRuns.tenantId, tenantId));
508
+ conditions.push(eq2(integrationRuns.tenantId, tenantId));
509
509
  }
510
510
  const where = conditions.length === 0 ? void 0 : conditions.length === 1 ? conditions[0] : and2(...conditions);
511
511
  const rows = await this.db.select({
512
- id: syncRuns.id,
513
- subscriptionId: syncRuns.subscriptionId,
514
- integrationId: syncSubscriptions.integrationId,
515
- status: syncRuns.status,
516
- startedAt: syncRuns.startedAt,
517
- completedAt: syncRuns.completedAt,
518
- recordsProcessed: syncRuns.recordsProcessed,
519
- tenantId: syncRuns.tenantId
520
- }).from(syncRuns).innerJoin(
521
- syncSubscriptions,
522
- eq2(syncRuns.subscriptionId, syncSubscriptions.id)
523
- ).where(where).orderBy(desc2(syncRuns.startedAt)).limit(limit);
512
+ id: integrationRuns.id,
513
+ subscriptionId: integrationRuns.subscriptionId,
514
+ connectionId: integrationSubscriptions.connectionId,
515
+ status: integrationRuns.status,
516
+ startedAt: integrationRuns.startedAt,
517
+ completedAt: integrationRuns.completedAt,
518
+ recordsProcessed: integrationRuns.recordsProcessed,
519
+ tenantId: integrationRuns.tenantId
520
+ }).from(integrationRuns).innerJoin(
521
+ integrationSubscriptions,
522
+ eq2(integrationRuns.subscriptionId, integrationSubscriptions.id)
523
+ ).where(where).orderBy(desc2(integrationRuns.startedAt)).limit(limit);
524
524
  return rows.map((row) => ({
525
525
  id: row.id,
526
526
  subscriptionId: row.subscriptionId,
527
- integrationId: row.integrationId,
527
+ connectionId: row.connectionId,
528
528
  status: row.status,
529
529
  startedAt: row.startedAt,
530
530
  completedAt: row.completedAt,
@@ -533,7 +533,7 @@ var DrizzleSyncRunRecorder = class {
533
533
  }));
534
534
  }
535
535
  async completeRun(runId, input) {
536
- await this.db.update(syncRuns).set({
536
+ await this.db.update(integrationRuns).set({
537
537
  status: input.status,
538
538
  recordsFound: input.recordsFound,
539
539
  recordsProcessed: input.recordsProcessed,
@@ -541,17 +541,17 @@ var DrizzleSyncRunRecorder = class {
541
541
  durationMs: input.durationMs,
542
542
  error: input.error ?? null,
543
543
  completedAt: /* @__PURE__ */ new Date()
544
- }).where(eq2(syncRuns.id, runId));
544
+ }).where(eq2(integrationRuns.id, runId));
545
545
  }
546
546
  };
547
- DrizzleSyncRunRecorder = __decorateClass([
547
+ DrizzleIntegrationRunRecorder = __decorateClass([
548
548
  Injectable4(),
549
549
  __decorateParam(0, Inject2(DRIZZLE)),
550
550
  __decorateParam(1, Optional2()),
551
- __decorateParam(1, Inject2(SYNC_MULTI_TENANT))
552
- ], DrizzleSyncRunRecorder);
551
+ __decorateParam(1, Inject2(INTEGRATION_MULTI_TENANT))
552
+ ], DrizzleIntegrationRunRecorder);
553
553
 
554
- // runtime/subsystems/sync/deep-equal.differ.ts
554
+ // runtime/subsystems/integration/deep-equal.differ.ts
555
555
  import { Injectable as Injectable5 } from "@nestjs/common";
556
556
  var DEFAULT_IGNORE_FIELDS = /* @__PURE__ */ new Set([
557
557
  "id",
@@ -650,16 +650,16 @@ function deepEqualObject(a, b) {
650
650
  return true;
651
651
  }
652
652
 
653
- // runtime/subsystems/sync/sync.module.ts
654
- var SyncModule = class {
653
+ // runtime/subsystems/integration/integration.module.ts
654
+ var IntegrationModule = class {
655
655
  static forRoot(options) {
656
656
  const multiTenant = options.multiTenant ?? false;
657
657
  const sharedProviders = [
658
- { provide: SYNC_MODULE_OPTIONS, useValue: options },
659
- { provide: SYNC_MULTI_TENANT, useValue: multiTenant },
658
+ { provide: INTEGRATION_MODULE_OPTIONS, useValue: options },
659
+ { provide: INTEGRATION_MULTI_TENANT, useValue: multiTenant },
660
660
  // Default differ — consumers can override by binding a different
661
- // `IFieldDiffer<T>` to `SYNC_FIELD_DIFFER` in their feature module.
662
- { provide: SYNC_FIELD_DIFFER, useValue: new DeepEqualDiffer() }
661
+ // `IFieldDiffer<T>` to `INTEGRATION_FIELD_DIFFER` in their feature module.
662
+ { provide: INTEGRATION_FIELD_DIFFER, useValue: new DeepEqualDiffer() }
663
663
  ];
664
664
  const backendProviders = options.backend === "memory" ? [
665
665
  // Wired as singletons via `useValue` so tests can pull
@@ -667,39 +667,39 @@ var SyncModule = class {
667
667
  // direct assertions. Matches JOB-4 / MemoryJobStore shape.
668
668
  { provide: MemoryCursorStore, useValue: new MemoryCursorStore() },
669
669
  {
670
- provide: SYNC_CURSOR_STORE,
670
+ provide: INTEGRATION_CURSOR_STORE,
671
671
  useExisting: MemoryCursorStore
672
672
  },
673
673
  { provide: MemoryRunRecorder, useValue: new MemoryRunRecorder() },
674
674
  {
675
- provide: SYNC_RUN_RECORDER,
675
+ provide: INTEGRATION_RUN_RECORDER,
676
676
  useExisting: MemoryRunRecorder
677
677
  }
678
678
  ] : [
679
679
  // Drizzle backends — injected with DRIZZLE (provided by the
680
- // consumer's DrizzleModule) + the SYNC_MULTI_TENANT flag
680
+ // consumer's DrizzleModule) + the INTEGRATION_MULTI_TENANT flag
681
681
  // we bound above.
682
- { provide: SYNC_CURSOR_STORE, useClass: PostgresCursorStore },
683
- { provide: SYNC_RUN_RECORDER, useClass: DrizzleSyncRunRecorder }
682
+ { provide: INTEGRATION_CURSOR_STORE, useClass: PostgresCursorStore },
683
+ { provide: INTEGRATION_RUN_RECORDER, useClass: DrizzleIntegrationRunRecorder }
684
684
  ];
685
685
  return {
686
- module: SyncModule,
686
+ module: IntegrationModule,
687
687
  global: true,
688
688
  providers: [...sharedProviders, ...backendProviders],
689
689
  exports: [
690
- SYNC_MODULE_OPTIONS,
691
- SYNC_MULTI_TENANT,
692
- SYNC_FIELD_DIFFER,
693
- SYNC_CURSOR_STORE,
694
- SYNC_RUN_RECORDER
690
+ INTEGRATION_MODULE_OPTIONS,
691
+ INTEGRATION_MULTI_TENANT,
692
+ INTEGRATION_FIELD_DIFFER,
693
+ INTEGRATION_CURSOR_STORE,
694
+ INTEGRATION_RUN_RECORDER
695
695
  ]
696
696
  };
697
697
  }
698
698
  };
699
- SyncModule = __decorateClass([
699
+ IntegrationModule = __decorateClass([
700
700
  Module({})
701
- ], SyncModule);
701
+ ], IntegrationModule);
702
702
  export {
703
- SyncModule
703
+ IntegrationModule
704
704
  };
705
- //# sourceMappingURL=sync.module.js.map
705
+ //# sourceMappingURL=integration.module.js.map