@pattern-stack/codegen 0.10.1 → 0.12.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 (279) hide show
  1. package/CHANGELOG.md +122 -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 +11 -7
  52. package/dist/runtime/subsystems/index.js +1041 -67
  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/integration/entity-change-source-registry.memory.d.ts +25 -0
  64. package/dist/runtime/subsystems/integration/entity-change-source-registry.memory.js +34 -0
  65. package/dist/runtime/subsystems/integration/entity-change-source-registry.memory.js.map +1 -0
  66. package/dist/runtime/subsystems/integration/entity-change-source-registry.protocol.d.ts +53 -0
  67. package/dist/runtime/subsystems/integration/entity-change-source-registry.protocol.js +13 -0
  68. package/dist/runtime/subsystems/integration/entity-change-source-registry.protocol.js.map +1 -0
  69. package/dist/runtime/subsystems/{sync/execute-sync.use-case.d.ts → integration/execute-integration.use-case.d.ts} +13 -13
  70. package/dist/runtime/subsystems/{sync/execute-sync.use-case.js → integration/execute-integration.use-case.js} +30 -30
  71. package/dist/runtime/subsystems/integration/execute-integration.use-case.js.map +1 -0
  72. package/dist/runtime/subsystems/integration/index.d.ts +30 -0
  73. package/dist/runtime/subsystems/{sync → integration}/index.js +206 -171
  74. package/dist/runtime/subsystems/integration/index.js.map +1 -0
  75. package/dist/runtime/subsystems/{sync/sync-audit.schema.d.ts → integration/integration-audit.schema.d.ts} +64 -64
  76. package/dist/runtime/subsystems/{sync/sync-audit.schema.js → integration/integration-audit.schema.js} +47 -47
  77. package/dist/runtime/subsystems/integration/integration-audit.schema.js.map +1 -0
  78. package/dist/runtime/subsystems/{sync/sync-change-source.protocol.d.ts → integration/integration-change-source.protocol.d.ts} +10 -10
  79. package/dist/runtime/subsystems/integration/integration-change-source.protocol.js +1 -0
  80. package/dist/runtime/subsystems/{sync/sync-cursor-store.drizzle-backend.d.ts → integration/integration-cursor-store.drizzle-backend.d.ts} +1 -1
  81. package/dist/runtime/subsystems/{sync/sync-cursor-store.drizzle-backend.js → integration/integration-cursor-store.drizzle-backend.js} +65 -65
  82. package/dist/runtime/subsystems/integration/integration-cursor-store.drizzle-backend.js.map +1 -0
  83. package/dist/runtime/subsystems/{sync/sync-cursor-store.memory-backend.d.ts → integration/integration-cursor-store.memory-backend.d.ts} +6 -6
  84. package/dist/runtime/subsystems/{sync/sync-cursor-store.memory-backend.js → integration/integration-cursor-store.memory-backend.js} +5 -5
  85. package/dist/runtime/subsystems/integration/integration-cursor-store.memory-backend.js.map +1 -0
  86. package/dist/runtime/subsystems/{sync/sync-cursor-store.protocol.d.ts → integration/integration-cursor-store.protocol.d.ts} +13 -13
  87. package/dist/runtime/subsystems/integration/integration-cursor-store.protocol.js +1 -0
  88. package/dist/runtime/subsystems/{sync/sync-errors.d.ts → integration/integration-errors.d.ts} +2 -2
  89. package/dist/runtime/subsystems/{sync/sync-errors.js → integration/integration-errors.js} +3 -3
  90. package/dist/runtime/subsystems/integration/integration-errors.js.map +1 -0
  91. package/dist/runtime/subsystems/{sync/sync-field-diff.protocol.d.ts → integration/integration-field-diff.protocol.d.ts} +2 -2
  92. package/dist/runtime/subsystems/{sync/sync-field-diff.protocol.js → integration/integration-field-diff.protocol.js} +2 -2
  93. package/dist/runtime/subsystems/integration/integration-field-diff.protocol.js.map +1 -0
  94. package/dist/runtime/subsystems/{sync/sync-loopback.protocol.d.ts → integration/integration-loopback.protocol.d.ts} +2 -2
  95. package/dist/runtime/subsystems/integration/integration-loopback.protocol.js +1 -0
  96. package/dist/runtime/subsystems/{sync/sync-middleware.protocol.d.ts → integration/integration-middleware.protocol.d.ts} +5 -5
  97. package/dist/runtime/subsystems/integration/integration-middleware.protocol.js +1 -0
  98. package/dist/runtime/subsystems/{sync/sync-run-recorder.drizzle-backend.d.ts → integration/integration-run-recorder.drizzle-backend.d.ts} +5 -5
  99. package/dist/runtime/subsystems/{sync/sync-run-recorder.drizzle-backend.js → integration/integration-run-recorder.drizzle-backend.js} +73 -73
  100. package/dist/runtime/subsystems/integration/integration-run-recorder.drizzle-backend.js.map +1 -0
  101. package/dist/runtime/subsystems/{sync/sync-run-recorder.memory-backend.d.ts → integration/integration-run-recorder.memory-backend.d.ts} +15 -15
  102. package/dist/runtime/subsystems/{sync/sync-run-recorder.memory-backend.js → integration/integration-run-recorder.memory-backend.js} +11 -11
  103. package/dist/runtime/subsystems/integration/integration-run-recorder.memory-backend.js.map +1 -0
  104. package/dist/runtime/subsystems/{sync/sync-run-recorder.protocol.d.ts → integration/integration-run-recorder.protocol.d.ts} +25 -25
  105. package/dist/runtime/subsystems/integration/integration-run-recorder.protocol.js +1 -0
  106. package/dist/runtime/subsystems/{sync/sync-sink.protocol.d.ts → integration/integration-sink.protocol.d.ts} +5 -5
  107. package/dist/runtime/subsystems/integration/integration-sink.protocol.js +1 -0
  108. package/dist/runtime/subsystems/{sync/sync.module.d.ts → integration/integration.module.d.ts} +24 -24
  109. package/dist/runtime/subsystems/{sync/sync.module.js → integration/integration.module.js} +132 -132
  110. package/dist/runtime/subsystems/integration/integration.module.js.map +1 -0
  111. package/dist/runtime/subsystems/integration/integration.tokens.d.ts +60 -0
  112. package/dist/runtime/subsystems/integration/integration.tokens.js +20 -0
  113. package/dist/runtime/subsystems/integration/integration.tokens.js.map +1 -0
  114. package/dist/runtime/subsystems/{sync → integration}/loopback.middleware.d.ts +5 -5
  115. package/dist/runtime/subsystems/{sync → integration}/loopback.middleware.js +1 -1
  116. package/dist/runtime/subsystems/integration/loopback.middleware.js.map +1 -0
  117. package/dist/runtime/subsystems/{sync → integration}/poll-change-source.d.ts +5 -5
  118. package/dist/runtime/subsystems/{sync → integration}/poll-change-source.js +1 -1
  119. package/dist/runtime/subsystems/integration/poll-change-source.js.map +1 -0
  120. package/dist/runtime/subsystems/{sync → integration}/webhook-change-source.d.ts +5 -5
  121. package/dist/runtime/subsystems/{sync → integration}/webhook-change-source.js +1 -1
  122. package/dist/runtime/subsystems/integration/webhook-change-source.js.map +1 -0
  123. package/dist/runtime/subsystems/jobs/job-worker.module.d.ts +1 -1
  124. package/dist/runtime/subsystems/observability/index.d.ts +4 -4
  125. package/dist/runtime/subsystems/observability/index.js +11 -11
  126. package/dist/runtime/subsystems/observability/index.js.map +1 -1
  127. package/dist/runtime/subsystems/observability/observability.module.d.ts +2 -2
  128. package/dist/runtime/subsystems/observability/observability.module.js +11 -11
  129. package/dist/runtime/subsystems/observability/observability.module.js.map +1 -1
  130. package/dist/runtime/subsystems/observability/observability.protocol.d.ts +11 -11
  131. package/dist/runtime/subsystems/observability/observability.service.d.ts +6 -6
  132. package/dist/runtime/subsystems/observability/observability.service.js +11 -11
  133. package/dist/runtime/subsystems/observability/observability.service.js.map +1 -1
  134. package/dist/runtime/subsystems/observability/observability.tokens.d.ts +1 -1
  135. package/dist/runtime/subsystems/observability/observability.tokens.js.map +1 -1
  136. package/dist/runtime/subsystems/observability/reporters/bridge-metrics.reporter.d.ts +3 -3
  137. package/dist/runtime/subsystems/observability/reporters/bridge-metrics.reporter.js.map +1 -1
  138. package/dist/runtime/subsystems/observability/reporters/index.d.ts +3 -3
  139. package/dist/runtime/subsystems/observability/reporters/index.js.map +1 -1
  140. package/dist/src/cli/index.js +1336 -376
  141. package/dist/src/cli/index.js.map +1 -1
  142. package/dist/src/index.d.ts +70 -22
  143. package/dist/src/index.js +290 -194
  144. package/dist/src/index.js.map +1 -1
  145. package/examples/auth-integrations/README.md +32 -32
  146. package/examples/auth-integrations/definitions/entities/{integration.yaml → connection.yaml} +10 -10
  147. package/examples/auth-integrations/runtime/{integrations/adapters/integration-grant-sink.adapter.ts → connections/adapters/connection-grant-sink.adapter.ts} +7 -7
  148. package/examples/auth-integrations/runtime/{integrations/adapters/integration-reader.adapter.ts → connections/adapters/connection-reader.adapter.ts} +10 -10
  149. package/examples/auth-integrations/runtime/{integrations/adapters/integration-token-writer.adapter.ts → connections/adapters/connection-token-writer.adapter.ts} +11 -11
  150. package/examples/auth-integrations/runtime/connections/connections-auth.module.ts +81 -0
  151. package/examples/auth-integrations/runtime/{integrations/facade/integrations.service.ts → connections/facade/connections.service.ts} +35 -35
  152. package/examples/auth-integrations/runtime/{integrations → connections}/oauth/use-cases/create-or-update-from-oauth-grant.use-case.ts +11 -11
  153. 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
  154. package/examples/auth-integrations/runtime/connections/oauth/use-cases/list-user-connections.use-case.ts +21 -0
  155. package/examples/auth-integrations/runtime/connections/oauth/use-cases/mark-connection-requires-reauth.use-case.ts +21 -0
  156. package/package.json +9 -1
  157. package/runtime/base-classes/index.ts +8 -8
  158. package/runtime/base-classes/{synced-entity-repository.ts → integrated-entity-repository.ts} +36 -36
  159. package/runtime/base-classes/{synced-entity-service.ts → integrated-entity-service.ts} +6 -6
  160. package/runtime/base-classes/{sync-upsert-config.ts → integration-upsert-config.ts} +12 -12
  161. package/runtime/base-classes/{junction-sync-repository.ts → junction-integration-repository.ts} +28 -28
  162. package/runtime/subsystems/auth/auth-oauth-state.schema.ts +1 -1
  163. package/runtime/subsystems/auth/auth.module.ts +4 -4
  164. package/runtime/subsystems/auth/auth.tokens.ts +7 -7
  165. package/runtime/subsystems/auth/controllers/auth.controller.ts +7 -7
  166. package/runtime/subsystems/auth/index.ts +19 -19
  167. package/runtime/subsystems/auth/protocols/auth-strategy.ts +3 -3
  168. package/runtime/subsystems/auth/protocols/{integration-store.ts → connection-store.ts} +19 -19
  169. package/runtime/subsystems/auth/protocols/provider-strategy.ts +2 -2
  170. package/runtime/subsystems/auth/runtime/{integration-broken.error.ts → connection-broken.error.ts} +5 -5
  171. package/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.ts +35 -35
  172. package/runtime/subsystems/auth/runtime/with-auth-retry.ts +3 -3
  173. package/runtime/subsystems/index.ts +26 -11
  174. package/runtime/subsystems/{sync → integration}/build-change-source.ts +3 -3
  175. package/runtime/subsystems/{sync → integration}/deep-equal.differ.ts +7 -7
  176. package/runtime/subsystems/{sync → integration}/detection-config.schema.ts +3 -3
  177. package/runtime/subsystems/integration/entity-change-source-registry.memory.ts +40 -0
  178. package/runtime/subsystems/integration/entity-change-source-registry.protocol.ts +59 -0
  179. package/runtime/subsystems/{sync/execute-sync.use-case.ts → integration/execute-integration.use-case.ts} +40 -40
  180. package/runtime/subsystems/{sync → integration}/index.ts +56 -47
  181. package/runtime/subsystems/{sync/sync-audit.schema.ts → integration/integration-audit.schema.ts} +61 -61
  182. package/runtime/subsystems/{sync/sync-change-source.protocol.ts → integration/integration-change-source.protocol.ts} +9 -9
  183. package/runtime/subsystems/{sync/sync-cursor-store.drizzle-backend.ts → integration/integration-cursor-store.drizzle-backend.ts} +30 -30
  184. package/runtime/subsystems/{sync/sync-cursor-store.memory-backend.ts → integration/integration-cursor-store.memory-backend.ts} +9 -9
  185. package/runtime/subsystems/{sync/sync-cursor-store.protocol.ts → integration/integration-cursor-store.protocol.ts} +13 -13
  186. package/runtime/subsystems/{sync/sync-errors.ts → integration/integration-errors.ts} +3 -3
  187. package/runtime/subsystems/{sync/sync-field-diff.protocol.ts → integration/integration-field-diff.protocol.ts} +2 -2
  188. package/runtime/subsystems/{sync/sync-loopback.protocol.ts → integration/integration-loopback.protocol.ts} +2 -2
  189. package/runtime/subsystems/{sync/sync-middleware.protocol.ts → integration/integration-middleware.protocol.ts} +6 -6
  190. package/runtime/subsystems/{sync/sync-run-recorder.drizzle-backend.ts → integration/integration-run-recorder.drizzle-backend.ts} +39 -39
  191. package/runtime/subsystems/{sync/sync-run-recorder.memory-backend.ts → integration/integration-run-recorder.memory-backend.ts} +23 -23
  192. package/runtime/subsystems/{sync/sync-run-recorder.protocol.ts → integration/integration-run-recorder.protocol.ts} +25 -25
  193. package/runtime/subsystems/{sync/sync-sink.protocol.ts → integration/integration-sink.protocol.ts} +4 -4
  194. package/runtime/subsystems/{sync/sync.module.ts → integration/integration.module.ts} +48 -48
  195. package/runtime/subsystems/integration/integration.tokens.ts +63 -0
  196. package/runtime/subsystems/{sync → integration}/loopback.middleware.ts +5 -5
  197. package/runtime/subsystems/{sync → integration}/poll-change-source.ts +7 -7
  198. package/runtime/subsystems/{sync → integration}/webhook-change-source.ts +7 -7
  199. package/runtime/subsystems/observability/index.ts +1 -1
  200. package/runtime/subsystems/observability/observability.module.ts +2 -2
  201. package/runtime/subsystems/observability/observability.protocol.ts +11 -11
  202. package/runtime/subsystems/observability/observability.service.ts +13 -13
  203. package/runtime/subsystems/observability/observability.tokens.ts +1 -1
  204. package/src/patterns/library/index.ts +4 -4
  205. package/src/patterns/library/{synced.pattern.ts → integrated.pattern.ts} +12 -12
  206. package/src/patterns/library/junction.pattern.ts +1 -1
  207. package/src/patterns/pattern-definition.ts +3 -3
  208. package/templates/entity/new/backend/modules/core/{sync-source.ejs.t → integration-source.ejs.t} +6 -6
  209. package/templates/entity/new/clean-lite-ps/entity.ejs.t +12 -3
  210. package/templates/entity/new/clean-lite-ps/module.ejs.t +1 -1
  211. package/templates/entity/new/clean-lite-ps/prompt-extension.js +243 -60
  212. package/templates/entity/new/clean-lite-ps/repository.ejs.t +27 -27
  213. package/templates/entity/new/frontend/collections/collection.ejs.t +26 -1
  214. package/templates/entity/new/frontend/collections/collections-base.ejs.t +11 -0
  215. package/templates/entity/new/frontend/entity/combined.ejs.t +31 -1
  216. package/templates/entity/new/prompt.js +27 -15
  217. package/templates/junction/new/entity.ejs.t +1 -1
  218. package/templates/junction/new/prompt.js +24 -24
  219. package/templates/junction/new/repository.ejs.t +19 -19
  220. package/templates/subsystem/auth/auth-oauth-state.schema.ejs.t +2 -2
  221. package/templates/subsystem/auth-config/prompt.js +1 -1
  222. package/templates/subsystem/auth-integrations/app-module-hook.ejs.t +5 -5
  223. package/templates/subsystem/bridge/prompt.js +1 -1
  224. package/templates/subsystem/integration/integration-audit.schema.ejs.t +192 -0
  225. package/templates/subsystem/{sync → integration}/prompt.js +12 -12
  226. package/templates/subsystem/{sync-config/codegen-config-sync-block.ejs.t → integration-config/codegen-config-integration-block.ejs.t} +7 -7
  227. package/templates/subsystem/integration-config/prompt.js +22 -0
  228. package/templates/subsystem/jobs/worker.ejs.t +2 -2
  229. package/templates/subsystem/observability/main-hook.ejs.t +1 -1
  230. package/templates/subsystem/observability/prompt.js +1 -1
  231. package/templates/subsystem/openapi-config/prompt.js +1 -1
  232. package/dist/runtime/base-classes/junction-sync-repository.js.map +0 -1
  233. package/dist/runtime/base-classes/sync-upsert-config.js +0 -1
  234. package/dist/runtime/base-classes/synced-entity-repository.js.map +0 -1
  235. package/dist/runtime/base-classes/synced-entity-service.js.map +0 -1
  236. package/dist/runtime/subsystems/auth/protocols/integration-store.js +0 -1
  237. package/dist/runtime/subsystems/auth/runtime/integration-broken.error.js +0 -19
  238. package/dist/runtime/subsystems/auth/runtime/integration-broken.error.js.map +0 -1
  239. package/dist/runtime/subsystems/sync/build-change-source.js.map +0 -1
  240. package/dist/runtime/subsystems/sync/deep-equal.differ.js.map +0 -1
  241. package/dist/runtime/subsystems/sync/detection-config.schema.js.map +0 -1
  242. package/dist/runtime/subsystems/sync/execute-sync.use-case.js.map +0 -1
  243. package/dist/runtime/subsystems/sync/index.d.ts +0 -28
  244. package/dist/runtime/subsystems/sync/index.js.map +0 -1
  245. package/dist/runtime/subsystems/sync/loopback.middleware.js.map +0 -1
  246. package/dist/runtime/subsystems/sync/poll-change-source.js.map +0 -1
  247. package/dist/runtime/subsystems/sync/sync-audit.schema.js.map +0 -1
  248. package/dist/runtime/subsystems/sync/sync-change-source.protocol.js +0 -1
  249. package/dist/runtime/subsystems/sync/sync-cursor-store.drizzle-backend.js.map +0 -1
  250. package/dist/runtime/subsystems/sync/sync-cursor-store.memory-backend.js.map +0 -1
  251. package/dist/runtime/subsystems/sync/sync-cursor-store.protocol.js +0 -1
  252. package/dist/runtime/subsystems/sync/sync-errors.js.map +0 -1
  253. package/dist/runtime/subsystems/sync/sync-field-diff.protocol.js.map +0 -1
  254. package/dist/runtime/subsystems/sync/sync-loopback.protocol.js +0 -1
  255. package/dist/runtime/subsystems/sync/sync-middleware.protocol.js +0 -1
  256. package/dist/runtime/subsystems/sync/sync-run-recorder.drizzle-backend.js.map +0 -1
  257. package/dist/runtime/subsystems/sync/sync-run-recorder.memory-backend.js.map +0 -1
  258. package/dist/runtime/subsystems/sync/sync-run-recorder.protocol.js +0 -1
  259. package/dist/runtime/subsystems/sync/sync-sink.protocol.js +0 -1
  260. package/dist/runtime/subsystems/sync/sync.module.js.map +0 -1
  261. package/dist/runtime/subsystems/sync/sync.tokens.d.ts +0 -47
  262. package/dist/runtime/subsystems/sync/sync.tokens.js +0 -18
  263. package/dist/runtime/subsystems/sync/sync.tokens.js.map +0 -1
  264. package/dist/runtime/subsystems/sync/webhook-change-source.js.map +0 -1
  265. package/examples/auth-integrations/runtime/integrations/integrations-auth.module.ts +0 -81
  266. package/examples/auth-integrations/runtime/integrations/oauth/use-cases/list-user-integrations.use-case.ts +0 -21
  267. package/examples/auth-integrations/runtime/integrations/oauth/use-cases/mark-integration-requires-reauth.use-case.ts +0 -21
  268. package/runtime/subsystems/sync/sync.tokens.ts +0 -49
  269. package/templates/entity/new/backend/modules/core/sync-source.providers.ejs.t +0 -18
  270. package/templates/subsystem/sync/sync-audit.schema.ejs.t +0 -192
  271. package/templates/subsystem/sync-config/prompt.js +0 -22
  272. /package/dist/runtime/base-classes/{sync-upsert-config.js.map → integration-upsert-config.js.map} +0 -0
  273. /package/dist/runtime/subsystems/auth/protocols/{integration-store.js.map → connection-store.js.map} +0 -0
  274. /package/dist/runtime/subsystems/{sync/sync-change-source.protocol.js.map → integration/integration-change-source.protocol.js.map} +0 -0
  275. /package/dist/runtime/subsystems/{sync/sync-cursor-store.protocol.js.map → integration/integration-cursor-store.protocol.js.map} +0 -0
  276. /package/dist/runtime/subsystems/{sync/sync-loopback.protocol.js.map → integration/integration-loopback.protocol.js.map} +0 -0
  277. /package/dist/runtime/subsystems/{sync/sync-middleware.protocol.js.map → integration/integration-middleware.protocol.js.map} +0 -0
  278. /package/dist/runtime/subsystems/{sync/sync-run-recorder.protocol.js.map → integration/integration-run-recorder.protocol.js.map} +0 -0
  279. /package/dist/runtime/subsystems/{sync/sync-sink.protocol.js.map → integration/integration-sink.protocol.js.map} +0 -0
@@ -22,10 +22,10 @@ import { eq<%= hasMultiFieldQuery ? ', and' : '' %><%= hasOrderedQuery ? ', desc
22
22
  import { sql } from 'drizzle-orm';
23
23
  <% } -%>
24
24
  import { DRIZZLE } from '@shared/constants/tokens';
25
- import type { DrizzleClient<% if (eavValueTable || (typeof hasSyncSurface !== 'undefined' && hasSyncSurface)) { %>, DrizzleTx<% } %> } from '@shared/types/drizzle';
25
+ import type { DrizzleClient<% if (eavValueTable || (typeof hasIntegrationSurface !== 'undefined' && hasIntegrationSurface)) { %>, DrizzleTx<% } %> } from '@shared/types/drizzle';
26
26
  import { <%= repositoryBaseClass %> } from '<%= repositoryBaseImport %>';
27
- <% if (typeof hasSyncSurface !== 'undefined' && hasSyncSurface) { -%>
28
- import type { SyncUpsertConfig } from '@shared/base-classes/sync-upsert-config';
27
+ <% if (typeof hasIntegrationSurface !== 'undefined' && hasIntegrationSurface) { -%>
28
+ import type { IntegrationUpsertConfig } from '@shared/base-classes/integration-upsert-config';
29
29
  <% } -%>
30
30
  <% if (hasTimestamps || hasSoftDelete || hasUserTracking) { -%>
31
31
  import type { BehaviorConfig } from '@shared/base-classes/base-repository';
@@ -34,25 +34,25 @@ import type { BehaviorConfig } from '@shared/base-classes/base-repository';
34
34
  import { FieldValueService } from '../field_values/field_value.service';
35
35
  <% } -%>
36
36
  import { <%= entityNamePlural %>, type <%= classNames.entity %> } from './<%= entityName %>.entity';
37
- <%_ if (typeof hasSyncSurface !== 'undefined' && hasSyncSurface) { _%>
38
- <%_ clpSyncParentTableImports.forEach((imp) => { _%>
37
+ <%_ if (typeof hasIntegrationSurface !== 'undefined' && hasIntegrationSurface) { _%>
38
+ <%_ clpIntegrationParentTableImports.forEach((imp) => { _%>
39
39
  import { <%= imp.table %> } from '<%= imp.importPath %>';
40
40
  <%_ }); _%>
41
41
  <%_ } _%>
42
- <%_ if (typeof hasSyncSurface !== 'undefined' && hasSyncSurface) { _%>
42
+ <%_ if (typeof hasIntegrationSurface !== 'undefined' && hasIntegrationSurface) { _%>
43
43
 
44
44
  /**
45
- * Canonical fields a synced <%= entityName %> write carries (#374). Copy-through
45
+ * Canonical fields a integrated <%= entityName %> write carries (#374). Copy-through
46
46
  * columns are typed from the entity; each FK is named by its parent's external
47
- * id and resolved <%= clpSyncFkResolvers.length > 0 ? 'in syncUpsertOne' : 'as configured' %>. Provider/providerMetadata are persistence
47
+ * id and resolved <%= clpIntegrationFkResolvers.length > 0 ? 'in integrationUpsertOne' : 'as configured' %>. Provider/providerMetadata are persistence
48
48
  * seam, not carried here.
49
49
  */
50
- export interface <%= classNames.entity %>SyncWrite {
50
+ export interface <%= classNames.entity %>IntegrationWrite {
51
51
  readonly externalId: string;
52
- <%_ clpSyncWriteFields.forEach((f) => { _%>
52
+ <%_ clpIntegrationWriteFields.forEach((f) => { _%>
53
53
  readonly <%= f.camelName %>: <%- f.tsType %>;
54
54
  <%_ }); _%>
55
- <%_ clpSyncWriteFkFields.forEach((f) => { _%>
55
+ <%_ clpIntegrationWriteFkFields.forEach((f) => { _%>
56
56
  readonly <%= f.name %>?: <%- f.tsType %>;
57
57
  <%_ }); _%>
58
58
  /** Flat custom-field bag (EAV). */
@@ -60,23 +60,23 @@ export interface <%= classNames.entity %>SyncWrite {
60
60
  }
61
61
 
62
62
  /**
63
- * Canonical-projected view of a <%= entityName %> row, keyed for the sync differ
63
+ * Canonical-projected view of a <%= entityName %> row, keyed for the integration differ
64
64
  * (#374). external_id_tracking columns (provider/providerMetadata) are OMITTED;
65
65
  * externalId is kept.
66
66
  */
67
- export interface <%= classNames.entity %>SyncProjection {
68
- <%_ clpSyncProjectionFields.forEach((f) => { _%>
67
+ export interface <%= classNames.entity %>IntegrationProjection {
68
+ <%_ clpIntegrationProjectionFields.forEach((f) => { _%>
69
69
  readonly <%= f.camelName %>: <%- f.tsType %>;
70
70
  <%_ }); _%>
71
71
  }
72
72
  <%_ } _%>
73
73
 
74
74
  @Injectable()
75
- <%_ if (typeof hasSyncSurface !== 'undefined' && hasSyncSurface) { _%>
75
+ <%_ if (typeof hasIntegrationSurface !== 'undefined' && hasIntegrationSurface) { _%>
76
76
  export class <%= classNames.repository %> extends <%= repositoryBaseClass %><
77
77
  <%= classNames.entity %>,
78
- <%= classNames.entity %>SyncWrite,
79
- <%= classNames.entity %>SyncProjection
78
+ <%= classNames.entity %>IntegrationWrite,
79
+ <%= classNames.entity %>IntegrationProjection
80
80
  > {
81
81
  <%_ } else { _%>
82
82
  export class <%= classNames.repository %> extends <%= repositoryBaseClass %><<%= classNames.entity %>> {
@@ -99,22 +99,22 @@ export class <%= classNames.repository %> extends <%= repositoryBaseClass %><<%=
99
99
  // runtime (identical shape to `behaviors: BehaviorConfig`).
100
100
  protected override readonly patternConfig = <%- renderPatternConfigLiteral(patternConfig, ' ', ' ') %> as const;
101
101
  <% } -%>
102
- <%_ if (typeof hasSyncSurface !== 'undefined' && hasSyncSurface) { _%>
102
+ <%_ if (typeof hasIntegrationSurface !== 'undefined' && hasIntegrationSurface) { _%>
103
103
 
104
- // Inbound-sync write surface (#374). Drives the generic syncUpsertOne /
104
+ // Inbound-integration write surface (#374). Drives the generic integrationUpsertOne /
105
105
  // findByExternalIdProjected / softDeleteByExternalId on the base. FK
106
106
  // resolvers carry LIVE Drizzle table handles ('self' → this.table).
107
- protected readonly syncConfig: SyncUpsertConfig = {
108
- conflictTarget: [<%- clpSyncConfig.conflictTarget.map((c) => `'${c}'`).join(', ') %>],
109
- writeColumns: [<%- clpSyncConfig.writeColumns.map((c) => `'${c}'`).join(', ') %>],
107
+ protected readonly integrationConfig: IntegrationUpsertConfig = {
108
+ conflictTarget: [<%- clpIntegrationConfig.conflictTarget.map((c) => `'${c}'`).join(', ') %>],
109
+ writeColumns: [<%- clpIntegrationConfig.writeColumns.map((c) => `'${c}'`).join(', ') %>],
110
110
  fkResolvers: [
111
- <%_ clpSyncFkResolvers.forEach((fk) => { _%>
111
+ <%_ clpIntegrationFkResolvers.forEach((fk) => { _%>
112
112
  { column: '<%= fk.column %>', writeKey: '<%= fk.writeKey %>', refTable: <%- fk.isSelfFk ? "'self'" : fk.refTable %><%= fk.strict ? ', strict: true' : '' %> },
113
113
  <%_ }); _%>
114
114
  ],
115
- projectionColumns: [<%- clpSyncConfig.projectionColumns.map((c) => `'${c}'`).join(', ') %>],
116
- eav: <%= clpSyncConfig.eav %>,
117
- softDelete: <%= clpSyncConfig.softDelete %>,
115
+ projectionColumns: [<%- clpIntegrationConfig.projectionColumns.map((c) => `'${c}'`).join(', ') %>],
116
+ eav: <%= clpIntegrationConfig.eav %>,
117
+ softDelete: <%= clpIntegrationConfig.softDelete %>,
118
118
  };
119
119
  <%_ } _%>
120
120
 
@@ -128,7 +128,7 @@ export class <%= classNames.repository %> extends <%= repositoryBaseClass %><<%=
128
128
 
129
129
  /**
130
130
  * EAV dual-write override (#374 seam → #124 live path). Delegates to the
131
- * shared FieldValueService so the inbound-sync write joins the same tx.
131
+ * shared FieldValueService so the inbound-integration write joins the same tx.
132
132
  */
133
133
  protected override async writeCustomFields(
134
134
  db: DrizzleTx,
@@ -12,7 +12,32 @@ const hasApiBaseUrl = !!frontend.sync.apiBaseUrlImport;
12
12
  const shapeUrlExpr = hasApiBaseUrl
13
13
  ? '`${API_BASE_URL}/' + plural + '`'
14
14
  : '`' + frontend.sync.shapeUrl + '/' + plural + '`';
15
+ // REST list endpoint for 'api' sync mode
16
+ const apiUrlExpr = hasApiBaseUrl
17
+ ? '`${API_BASE_URL}/' + plural + '`'
18
+ : '`' + frontend.sync.apiUrl + '/' + plural + '`';
19
+ const schemaPrefix = frontend.collections?.schemaPrefix ?? 'schema.';
15
20
  -%>
21
+ <% if (frontend.sync.mode === 'api') { -%>
22
+ export const <%= camelName %>Collection = createCollection(
23
+ queryCollectionOptions({
24
+ id: '<%= plural %>',
25
+ queryKey: ['<%= plural %>'],
26
+ queryClient,
27
+ queryFn: async () => {
28
+ const res = await fetch(<%- apiUrlExpr %><% if (frontend.auth.function) { %>, {
29
+ headers: { Authorization: <%= frontend.auth.function %>() },
30
+ }<% } %>);
31
+ if (!res.ok) {
32
+ throw new Error(`GET <%= plural %> → ${res.status} ${res.statusText}`);
33
+ }
34
+ return res.json();
35
+ },
36
+ getKey: (item) => item.id,
37
+ schema: <%= schemaPrefix %><%= camelName %>Schema,
38
+ }),
39
+ );
40
+ <% } else { -%>
16
41
  export const <%= camelName %>Collection = createCollection(
17
42
  electricCollectionOptions({
18
43
  id: '<%= plural %>',
@@ -53,9 +78,9 @@ export const <%= camelName %>Collection = createCollection(
53
78
  <% } -%>
54
79
  <% } -%>
55
80
  },
56
- <% const schemaPrefix = frontend.collections?.schemaPrefix ?? 'schema.'; -%>
57
81
  schema: <%= schemaPrefix %><%= camelName %>Schema,
58
82
  getKey: (item) => item.id,
59
83
  }),
60
84
  );
61
85
  <% } -%>
86
+ <% } -%>
@@ -3,6 +3,16 @@ to: <%= locations.frontendCollections.path %>/collections.ts
3
3
  skip_if: <%= !frontendEnabled %>
4
4
  force: false
5
5
  ---
6
+ <% if (frontend.sync.mode === 'api') { -%>
7
+ /**
8
+ * REST-backed Collections (TanStack Query)
9
+ * Generated by entity codegen - do not edit directly
10
+ */
11
+
12
+ import { queryCollectionOptions } from '@tanstack/query-db-collection';
13
+ import { createCollection } from '@tanstack/react-db';
14
+ import { queryClient } from '<%= frontend.sync.queryClientImport ?? './query-client' %>';
15
+ <% } else { -%>
6
16
  /**
7
17
  * Electric SQL Collections
8
18
  * Generated by entity codegen - do not edit directly
@@ -13,6 +23,7 @@ import { createCollection } from '@tanstack/react-db';
13
23
  <% if (frontend.sync.columnMapper) { -%>
14
24
  import { <%= frontend.sync.columnMapper %> } from '@electric-sql/client';
15
25
  <% } -%>
26
+ <% } -%>
16
27
  <% if (frontend.auth.function) { -%>
17
28
  import { <%= frontend.auth.function %> } from '<%= locations.frontendCollectionsAuth.import %>';
18
29
  <% } -%>
@@ -31,14 +31,19 @@ const returnKeySingular = generate.hookReturnStyle === 'named' ? camelName : 'da
31
31
  <% if (generate.mutations && (exposeTrpc || exposeRepository)) { -%>
32
32
  import { useState, useCallback } from 'react';
33
33
  <% } -%>
34
- <% if (frontend.sync.columnMapper) { -%>
34
+ <% if (frontend.sync.mode !== 'api' && frontend.sync.columnMapper) { -%>
35
35
  import { <%= frontend.sync.columnMapper %> } from '@electric-sql/client';
36
36
  <% } -%>
37
37
  import { <%= camelName %>Schema, type <%= importedTypeName %> } from '<%= locations.dbEntities.import %><% if (!locations.dbEntities.barrelExport) { %>/<%= name %><% } %>';
38
38
  <% if (exposeTrpc) { -%>
39
39
  import { trpc } from '<%= locations.trpcClient.import %>';
40
40
  <% } -%>
41
+ <% if (frontend.sync.mode === 'api') { -%>
42
+ import { queryCollectionOptions } from '@tanstack/query-db-collection';
43
+ import { queryClient } from '<%= frontend.sync.queryClientImport ?? './query-client' %>';
44
+ <% } else { -%>
41
45
  import { electricCollectionOptions } from '@tanstack/electric-db-collection';
46
+ <% } -%>
42
47
  import { createCollection<% if (generate.hookStyle === 'useLiveQuery') { %>, useLiveQuery, eq<% } %> } from '@tanstack/react-db';
43
48
  <% if (generate.fieldMetadata) { -%>
44
49
  import type { FieldMeta, FieldType, FieldImportance } from '<%= locations.frontendFieldMetaTypes.import %>/field-meta';
@@ -118,7 +123,31 @@ export type <%= className %>Resolved = <%= className %>;
118
123
  // Without this filter, soft-deleted records will reappear after Electric sync.
119
124
  <% } -%>
120
125
 
126
+ <%
127
+ // REST list endpoint for 'api' sync mode
128
+ const hasApiBaseUrl = !!frontend.sync.apiBaseUrlImport;
129
+ const apiUrlExpr = hasApiBaseUrl
130
+ ? '`${API_BASE_URL}/' + plural + '`'
131
+ : '`' + frontend.sync.apiUrl + '/' + plural + '`';
132
+ -%>
121
133
  export const <%= collectionVar %> = createCollection(
134
+ <% if (frontend.sync.mode === 'api') { -%>
135
+ queryCollectionOptions({
136
+ id: '<%= plural %>',
137
+ queryKey: ['<%= plural %>'],
138
+ queryClient,
139
+ queryFn: async () => {
140
+ const res = await fetch(<%- apiUrlExpr %><% if (frontend.auth.function) { %>, {
141
+ headers: { Authorization: <%= frontend.auth.function %>() },
142
+ }<% } %>);
143
+ if (!res.ok) {
144
+ throw new Error(`GET <%= plural %> → ${res.status} ${res.statusText}`);
145
+ }
146
+ return res.json();
147
+ },
148
+ getKey: (item) => item.id,
149
+ schema: <%= camelName %>Schema,
150
+ <% } else { -%>
122
151
  electricCollectionOptions({
123
152
  id: '<%= plural %>',
124
153
  shapeOptions: {
@@ -168,6 +197,7 @@ export const <%= collectionVar %> = createCollection(
168
197
  },
169
198
  schema: <%= camelName %>Schema,
170
199
  getKey: (item) => item.id,
200
+ <% } -%>
171
201
  <% if (generate.mutations && (exposeTrpc || exposeRepository)) { -%>
172
202
  <% if (exposeTrpc) { -%>
173
203
  onInsert: async ({ transaction }) => {
@@ -305,7 +305,7 @@ export default {
305
305
 
306
306
  // v2 blocks (optional — absent in v1 entities)
307
307
  const queriesBlock = definition.queries || null;
308
- const syncBlock = definition.sync || null;
308
+ const integrationBlock = definition.integration || null;
309
309
  const eventsBlock = definition.events || null;
310
310
  // EVT-7: emits is semantically 3-valued — undefined (fallback path),
311
311
  // [] (explicit opt-out), or string[] (typed emission). Preserve the
@@ -579,7 +579,7 @@ export default {
579
579
  moduleToController: importHelpers.moduleToController(fileNames.controller.replace('.ts', '')),
580
580
  // OPENAPI-2: module imports DTO file to register Zod schemas at onModuleInit.
581
581
  moduleToDto: importHelpers.moduleToDto(fileNames.dto.replace('.ts', '')),
582
- // ADR-033.1: sync-source module imports the entity type from the
582
+ // ADR-033.1: integration-source module imports the entity type from the
583
583
  // domain barrel for the IChangeSource<T> type parameter.
584
584
  moduleToDomain: importHelpers.moduleToDomain(),
585
585
  // From controller (presentation/rest/) to queries/commands
@@ -1136,7 +1136,7 @@ export default {
1136
1136
  const hasOrderedQuery = processedQueries.some((q) => q.hasOrder);
1137
1137
 
1138
1138
  // ============================================================================
1139
- // v2: Sync
1139
+ // v2: Integration
1140
1140
  // ============================================================================
1141
1141
 
1142
1142
  // ADR-033.1 / ADR-033.2: provider-keyed detection block.
@@ -1150,18 +1150,18 @@ export default {
1150
1150
  // Render the per-entity DetectionConfigs map as a TS object literal.
1151
1151
  // JSON.stringify produces valid TS for the canonical DetectionConfig shape
1152
1152
  // (strings, numbers, booleans, arrays, plain objects). Provider keys keep
1153
- // YAML insertion order. Used by sync-source.ejs.t.
1153
+ // YAML insertion order. Used by integration-source.ejs.t.
1154
1154
  const detectionConfigsLiteral = hasDetection
1155
1155
  ? JSON.stringify(detectionBlock, null, 2)
1156
1156
  : '{}';
1157
1157
 
1158
- const hasSyncBlock = syncBlock != null;
1159
- const syncElectric = hasSyncBlock ? (syncBlock.electric ?? false) : false;
1160
- const rawSyncProviders = hasSyncBlock ? (syncBlock.providers ?? {}) : {};
1161
- const hasSyncProviders = Object.keys(rawSyncProviders).length > 0;
1158
+ const hasIntegrationBlock = integrationBlock != null;
1159
+ const integrationElectric = hasIntegrationBlock ? (integrationBlock.electric ?? false) : false;
1160
+ const rawIntegrationProviders = hasIntegrationBlock ? (integrationBlock.providers ?? {}) : {};
1161
+ const hasIntegrationProviders = Object.keys(rawIntegrationProviders).length > 0;
1162
1162
 
1163
- const syncProviders = hasSyncProviders
1164
- ? Object.entries(rawSyncProviders).map(([providerName, cfg]) => {
1163
+ const integrationProviders = hasIntegrationProviders
1164
+ ? Object.entries(rawIntegrationProviders).map(([providerName, cfg]) => {
1165
1165
  // Normalize field_mapping: { local: key, remote: value }[]
1166
1166
  const rawMapping = cfg.field_mapping ?? {};
1167
1167
  const fieldMapping = Object.entries(rawMapping).map(([local, remote]) => ({
@@ -1488,6 +1488,18 @@ export default {
1488
1488
  : 'getAuthorizationHeader',
1489
1489
  },
1490
1490
  sync: {
1491
+ // Read transport for the generated collection:
1492
+ // 'electric' (default) → electricCollectionOptions (real-time shape sync)
1493
+ // 'api' → queryCollectionOptions (REST via TanStack Query)
1494
+ // Additive + default-off: existing consumers are unaffected. The rest of
1495
+ // the store (hooks/useLiveQuery, resolve, mutations) is mode-agnostic.
1496
+ mode: frontendSync.mode ?? 'electric',
1497
+ // 'api' mode only: REST base path; the list endpoint is `${apiUrl}/${plural}`
1498
+ // (or `${API_BASE_URL}/${plural}` when apiBaseUrlImport is set).
1499
+ apiUrl: frontendSync.apiUrl ?? '/api',
1500
+ // 'api' mode only: import path for the shared TanStack QueryClient.
1501
+ // null → a sibling './query-client' is assumed (consumer-provided).
1502
+ queryClientImport: frontendSync.queryClientImport ?? null,
1491
1503
  shapeUrl: frontendSync.shapeUrl ?? '/v1/shape',
1492
1504
  useTableParam: frontendSync.useTableParam ?? true,
1493
1505
  // Column mapper for snake_case to camelCase conversion (e.g., 'snakeCamelMapper')
@@ -1609,11 +1621,11 @@ export default {
1609
1621
  hasMultiFieldQuery,
1610
1622
  hasOrderedQuery,
1611
1623
 
1612
- // Sync
1613
- hasSyncBlock,
1614
- syncElectric,
1615
- hasSyncProviders,
1616
- syncProviders,
1624
+ // Integration
1625
+ hasIntegrationBlock,
1626
+ integrationElectric,
1627
+ hasIntegrationProviders,
1628
+ integrationProviders,
1617
1629
 
1618
1630
  // Detection (ADR-033.1 / ADR-033.2 typed provider artifacts)
1619
1631
  hasDetection,
@@ -91,7 +91,7 @@ export const <%= tableVarName %> = pgTable(
91
91
  // surrogate id). Role is part of the junction's identity — the same pair
92
92
  // with two different roles is two distinct rows (e.g. a contact who is both
93
93
  // `champion` and `decision_maker` on one opportunity). This is the
94
- // ON CONFLICT target for syncUpsert on role-bearing junctions.
94
+ // ON CONFLICT target for integrationUpsert on role-bearing junctions.
95
95
  primaryKey({ columns: [table.<%= leftColumnCamel %>, table.<%= rightColumnCamel %>, table.role] }),
96
96
  <%_ } else { _%>
97
97
  // Composite primary key on the two FK columns (Q4 resolution: no surrogate id)
@@ -378,23 +378,23 @@ export default {
378
378
  const rightEntityCamel = camelCase(rightEntity);
379
379
 
380
380
  // ======================================================================
381
- // Inbound-sync write surface (#374)
381
+ // Inbound-integration write surface (#374)
382
382
  // ======================================================================
383
- // The junction sync identity is the tuple (leftId, rightId[, role]); its
383
+ // The junction integration identity is the tuple (leftId, rightId[, role]); its
384
384
  // externalId is a COMPOSITE string. Both parent FKs resolve strictly. FK
385
385
  // write-keys use `${camelCase(entity)}ExternalId` (matches the reference).
386
386
 
387
- const leftSyncWriteKey = `${leftEntityCamel}ExternalId`;
388
- const rightSyncWriteKey = `${rightEntityCamel}ExternalId`;
387
+ const leftIntegrationWriteKey = `${leftEntityCamel}ExternalId`;
388
+ const rightIntegrationWriteKey = `${rightEntityCamel}ExternalId`;
389
389
  const roleColumnCamel = hasRole ? 'role' : null;
390
390
  // Role TS type — literal union from the enum choices, else absent.
391
391
  const roleTsType = hasRole
392
392
  ? roleChoices.map((c) => `'${c}'`).join(' | ')
393
393
  : null;
394
394
 
395
- // JunctionSyncConfig literal fields. refTable is emitted as a live table
395
+ // JunctionIntegrationConfig literal fields. refTable is emitted as a live table
396
396
  // identifier (leftTable/rightTable) by the template.
397
- const syncConfig = {
397
+ const integrationConfig = {
398
398
  leftColumn: leftColumnCamel,
399
399
  leftRefTable: leftTable,
400
400
  rightColumn: rightColumnCamel,
@@ -402,17 +402,17 @@ export default {
402
402
  roleColumn: roleColumnCamel,
403
403
  };
404
404
 
405
- // TSyncWrite fields: both parent external ids + optional role + userId.
406
- const syncWriteFields = [
407
- { name: leftSyncWriteKey, tsType: 'string' },
408
- { name: rightSyncWriteKey, tsType: 'string' },
405
+ // TIntegrationWrite fields: both parent external ids + optional role + userId.
406
+ const integrationWriteFields = [
407
+ { name: leftIntegrationWriteKey, tsType: 'string' },
408
+ { name: rightIntegrationWriteKey, tsType: 'string' },
409
409
  ...(hasRole ? [{ name: 'role', tsType: roleTsType }] : []),
410
410
  { name: 'userId', tsType: 'string' },
411
411
  ];
412
412
 
413
- // TSyncProjection fields: composite id + local FK columns + optional role +
413
+ // TIntegrationProjection fields: composite id + local FK columns + optional role +
414
414
  // timestamps. No surrogate id column on a junction.
415
- const syncProjectionFields = [
415
+ const integrationProjectionFields = [
416
416
  { name: 'id', tsType: 'string' },
417
417
  { name: leftColumnCamel, tsType: 'string' },
418
418
  { name: rightColumnCamel, tsType: 'string' },
@@ -423,15 +423,15 @@ export default {
423
423
 
424
424
  // Parent-table imports for the FK resolvers, deduped (#368). Junction
425
425
  // endpoints are distinct by schema, so two imports unless they collide.
426
- const syncParentImports = [];
427
- const seenSyncImports = new Set();
426
+ const integrationParentImports = [];
427
+ const seenIntegrationImports = new Set();
428
428
  for (const imp of [
429
429
  { table: leftTable, importPath: leftEntityImportFromJunction },
430
430
  { table: rightTable, importPath: rightEntityImportFromJunction },
431
431
  ]) {
432
- if (seenSyncImports.has(imp.table)) continue;
433
- seenSyncImports.add(imp.table);
434
- syncParentImports.push(imp);
432
+ if (seenIntegrationImports.has(imp.table)) continue;
433
+ seenIntegrationImports.add(imp.table);
434
+ integrationParentImports.push(imp);
435
435
  }
436
436
 
437
437
  // ======================================================================
@@ -523,16 +523,16 @@ export default {
523
523
  rightTable,
524
524
 
525
525
  // ──────────────────────────────────────────────────────────────────
526
- // Inbound-sync write surface (#374)
526
+ // Inbound-integration write surface (#374)
527
527
  // ──────────────────────────────────────────────────────────────────
528
- leftSyncWriteKey,
529
- rightSyncWriteKey,
528
+ leftIntegrationWriteKey,
529
+ rightIntegrationWriteKey,
530
530
  roleColumnCamel,
531
531
  roleTsType,
532
- junctionSyncConfig: syncConfig,
533
- syncWriteFields,
534
- syncProjectionFields,
535
- syncParentImports,
532
+ junctionIntegrationConfig: integrationConfig,
533
+ integrationWriteFields,
534
+ integrationProjectionFields,
535
+ integrationParentImports,
536
536
 
537
537
  // ──────────────────────────────────────────────────────────────────
538
538
  // CGP-60 — fan-out locals
@@ -7,41 +7,41 @@ import { Injectable, Inject } from '@nestjs/common';
7
7
  import { eq } from 'drizzle-orm';
8
8
  import { DRIZZLE } from '@shared/constants/tokens';
9
9
  import type { DrizzleClient } from '@shared/types/drizzle';
10
- import { JunctionSyncRepository } from '@shared/base-classes/junction-sync-repository';
11
- import type { JunctionSyncConfig } from '@shared/base-classes/junction-sync-repository';
12
- <%_ syncParentImports.forEach((imp) => { _%>
10
+ import { JunctionIntegrationRepository } from '@shared/base-classes/junction-integration-repository';
11
+ import type { JunctionIntegrationConfig } from '@shared/base-classes/junction-integration-repository';
12
+ <%_ integrationParentImports.forEach((imp) => { _%>
13
13
  import { <%= imp.table %> } from '<%= imp.importPath %>';
14
14
  <%_ }); _%>
15
15
  import { <%= tableVarName %>, type <%= classNames.entity %> } from './<%= name %>.entity';
16
16
 
17
17
  /**
18
- * Canonical fields a synced <%= name %> junction write carries (#374). BOTH
18
+ * Canonical fields a integrated <%= name %> junction write carries (#374). BOTH
19
19
  * parent FKs are named by their vendor external ids and resolved STRICTLY in
20
20
  * the tx (a missing parent throws → the orchestrator records a failed item and
21
21
  * continues). `userId` is run context (no column on the junction).
22
22
  */
23
- export interface <%= classNames.entity %>SyncWrite {
24
- <%_ syncWriteFields.forEach((f) => { _%>
23
+ export interface <%= classNames.entity %>IntegrationWrite {
24
+ <%_ integrationWriteFields.forEach((f) => { _%>
25
25
  readonly <%= f.name %>: <%- f.tsType %>;
26
26
  <%_ }); _%>
27
27
  }
28
28
 
29
29
  /**
30
- * Canonical-projected view of a <%= name %> junction row, keyed for the sync
30
+ * Canonical-projected view of a <%= name %> junction row, keyed for the integration
31
31
  * differ (#374). `id` is the COMPOSITE externalId (the junction has no
32
32
  * surrogate id); the FKs are the LOCAL resolved uuids.
33
33
  */
34
- export interface <%= classNames.entity %>SyncProjection {
35
- <%_ syncProjectionFields.forEach((f) => { _%>
34
+ export interface <%= classNames.entity %>IntegrationProjection {
35
+ <%_ integrationProjectionFields.forEach((f) => { _%>
36
36
  readonly <%= f.name %>: <%- f.tsType %>;
37
37
  <%_ }); _%>
38
38
  }
39
39
 
40
40
  @Injectable()
41
- export class <%= classNames.repository %> extends JunctionSyncRepository<
41
+ export class <%= classNames.repository %> extends JunctionIntegrationRepository<
42
42
  <%= classNames.entity %>,
43
- <%= classNames.entity %>SyncWrite,
44
- <%= classNames.entity %>SyncProjection
43
+ <%= classNames.entity %>IntegrationWrite,
44
+ <%= classNames.entity %>IntegrationProjection
45
45
  > {
46
46
  readonly table = <%= tableVarName %>;
47
47
 
@@ -53,12 +53,12 @@ export class <%= classNames.repository %> extends JunctionSyncRepository<
53
53
  userTracking: false,
54
54
  };
55
55
 
56
- // Inbound-sync write surface (#374). Both endpoints resolve strictly against
56
+ // Inbound-integration write surface (#374). Both endpoints resolve strictly against
57
57
  // the live parent tables; role-bearing junctions conflict on (left,right,role).
58
- protected readonly syncConfig: JunctionSyncConfig = {
59
- left: { column: '<%= junctionSyncConfig.leftColumn %>', refTable: <%= junctionSyncConfig.leftRefTable %> },
60
- right: { column: '<%= junctionSyncConfig.rightColumn %>', refTable: <%= junctionSyncConfig.rightRefTable %> },
61
- roleColumn: <%- junctionSyncConfig.roleColumn ? `'${junctionSyncConfig.roleColumn}'` : 'null' %>,
58
+ protected readonly integrationConfig: JunctionIntegrationConfig = {
59
+ left: { column: '<%= junctionIntegrationConfig.leftColumn %>', refTable: <%= junctionIntegrationConfig.leftRefTable %> },
60
+ right: { column: '<%= junctionIntegrationConfig.rightColumn %>', refTable: <%= junctionIntegrationConfig.rightRefTable %> },
61
+ roleColumn: <%- junctionIntegrationConfig.roleColumn ? `'${junctionIntegrationConfig.roleColumn}'` : 'null' %>,
62
62
  };
63
63
 
64
64
  constructor(@Inject(DRIZZLE) db: DrizzleClient) {
@@ -102,7 +102,7 @@ export class <%= classNames.repository %> extends JunctionSyncRepository<
102
102
  return rows as <%= classNames.entity %>[];
103
103
  }
104
104
 
105
- // Inherited from JunctionSyncRepository (+ BaseRepository):
105
+ // Inherited from JunctionIntegrationRepository (+ BaseRepository):
106
106
  // findById, findByIds, list, count, exists, create, update, delete, upsertMany
107
- // syncUpsertOne, findByExternalIdProjected, softDeleteByExternalId
107
+ // integrationUpsertOne, findByExternalIdProjected, softDeleteByExternalId
108
108
  }
@@ -3,7 +3,7 @@ to: "<%= schemaPath %>"
3
3
  force: true
4
4
  ---
5
5
  <%- typeof generatedBanner !== 'undefined' ? generatedBanner : '' %>
6
- // Schema barrel append tracked in #284 — same gap as events/jobs/sync today.
6
+ // Schema barrel append tracked in #284 — same gap as events/jobs/integration today.
7
7
  /**
8
8
  * Drizzle schema for the `auth_oauth_state` table — backs the
9
9
  * `DrizzleOAuthStateStore` (`state-store.drizzle-backend.ts`).
@@ -21,7 +21,7 @@ force: true
21
21
  * - `expires_at` — TTL boundary; entries past this are treated as absent.
22
22
  *
23
23
  * Convention: schema files live at the root of the subsystem dir
24
- * (mirrors `cache.schema.ts`, `sync-audit.schema.ts`, `domain-events.schema.ts`).
24
+ * (mirrors `cache.schema.ts`, `integration-audit.schema.ts`, `domain-events.schema.ts`).
25
25
  */
26
26
  import { pgTable, text, timestamp } from 'drizzle-orm/pg-core';
27
27
  import type { InferSelectModel } from 'drizzle-orm';
@@ -5,7 +5,7 @@
5
5
  * config-block inject step independently — `subsystem install auth --force`
6
6
  * preserves an existing `auth:` block by skipping this action; pass
7
7
  * `--force-config` to opt into regeneration. Mirrors `events-config` /
8
- * `sync-config` / `observability-config` exactly.
8
+ * `integration-config` / `observability-config` exactly.
9
9
  *
10
10
  * Invoked via:
11
11
  * bunx hygen subsystem auth-config --configPath <abs>
@@ -2,15 +2,15 @@
2
2
  to: "<%= appModulePath %>"
3
3
  inject: true
4
4
  append: true
5
- skip_if: "IntegrationsAuthModule"
5
+ skip_if: "ConnectionsAuthModule"
6
6
  ---
7
7
 
8
- // TODO: Register IntegrationsAuthModule (vendored from auth-integrations starter)
8
+ // TODO: Register ConnectionsAuthModule (vendored from auth-integrations starter)
9
9
  // Add to AppModule.imports AFTER AuthModule:
10
10
  //
11
- // import { IntegrationsAuthModule } from '@shared/integrations/integrations-auth.module';
11
+ // import { ConnectionsAuthModule } from '@shared/connections/connections-auth.module';
12
12
  // // ...
13
- // IntegrationsAuthModule,
13
+ // ConnectionsAuthModule,
14
14
  //
15
15
  // Requires AuthModule.forRoot(...) registered first (provides ENCRYPTION_KEY).
16
- // Run `cdp entity new integration` to scaffold the codegen layer the adapters import.
16
+ // Run `cdp entity new connection` to scaffold the codegen layer the adapters import.
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Locals resolved by the CLI (src/cli/shared/bridge-scaffold-locals.ts) and
5
5
  * forwarded as CLI args. This prompt.js coerces boolean-ish strings back into
6
- * JS booleans for parity with events / sync (Hygen args arrive as strings).
6
+ * JS booleans for parity with events / integration (Hygen args arrive as strings).
7
7
  *
8
8
  * Invoked via:
9
9
  * bunx hygen subsystem bridge \