@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
@@ -1,21 +0,0 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { IntegrationService } from '../../integration.service';
3
- import type { Integration } from '../../integration.entity';
4
-
5
- /**
6
- * Lists a user's integrations newest-first. Used by the settings page
7
- * (`GET /integrations`) and any "which providers are connected?" UI.
8
- *
9
- * Returns rows with ciphertexts intact — callers should NOT pass these
10
- * to the frontend. Use `IntegrationsService.listByUser` if you need
11
- * the consumer-facing facade behavior (which strips ciphertexts before
12
- * returning).
13
- */
14
- @Injectable()
15
- export class ListUserIntegrationsUseCase {
16
- constructor(private readonly integrations: IntegrationService) {}
17
-
18
- async execute(userId: string): Promise<Integration[]> {
19
- return this.integrations.findByUserId(userId);
20
- }
21
- }
@@ -1,21 +0,0 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { IntegrationService } from '../../integration.service';
3
- import type { Integration } from '../../integration.entity';
4
-
5
- /**
6
- * Flips an integration's status to `requires_reauth`. Called when the
7
- * refresh path raises `IntegrationBrokenError` (refresh token rejected,
8
- * scopes revoked, etc.) — see `OAuth2RefreshStrategy` + `withAuthRetry`.
9
- *
10
- * Idempotent: calling on an already-broken row is a no-op write.
11
- */
12
- @Injectable()
13
- export class MarkIntegrationRequiresReauthUseCase {
14
- constructor(private readonly integrations: IntegrationService) {}
15
-
16
- async execute(integrationId: string): Promise<Integration> {
17
- return this.integrations.update(integrationId, {
18
- status: 'requires_reauth',
19
- });
20
- }
21
- }
@@ -1,49 +0,0 @@
1
- /**
2
- * Sync subsystem — DI tokens
3
- *
4
- * String constants (not Symbols) so they match by value across import
5
- * boundaries — same convention as the events subsystem (`EVENT_BUS`). The
6
- * jobs subsystem uses Symbols for its analogous tokens; events and sync
7
- * stay internally consistent with strings.
8
- *
9
- * Usage in use cases:
10
- * ```ts
11
- * constructor(
12
- * @Inject(SYNC_CHANGE_SOURCE) private readonly source: IChangeSource<CanonicalOpportunity>,
13
- * @Inject(SYNC_CURSOR_STORE) private readonly cursors: ICursorStore,
14
- * @Inject(SYNC_FIELD_DIFFER) private readonly differ: IFieldDiffer<CanonicalOpportunity>,
15
- * @Inject(SYNC_SINK) private readonly sink: ISyncSink<CanonicalOpportunity>,
16
- * @Inject(SYNC_RUN_RECORDER) private readonly recorder: ISyncRunRecorder,
17
- * ) {}
18
- * ```
19
- *
20
- * Concrete bindings are registered by `SyncModule.forRoot(...)` (SYNC-6).
21
- */
22
-
23
- export const SYNC_CHANGE_SOURCE = 'SYNC_CHANGE_SOURCE' as const;
24
- export const SYNC_CURSOR_STORE = 'SYNC_CURSOR_STORE' as const;
25
- export const SYNC_FIELD_DIFFER = 'SYNC_FIELD_DIFFER' as const;
26
- export const SYNC_SINK = 'SYNC_SINK' as const;
27
-
28
- /**
29
- * Run-recorder token (SYNC-5). Backed by `ISyncRunRecorder`. Drizzle impl
30
- * lands in SYNC-4; tests provide inline fakes.
31
- */
32
- export const SYNC_RUN_RECORDER = 'SYNC_RUN_RECORDER' as const;
33
-
34
- /**
35
- * Injection token for the resolved `SyncModuleOptions` object (SYNC-6).
36
- *
37
- * Backends that need to observe module configuration (e.g. `multiTenant`
38
- * flag, pool filters) inject via this token. Provided automatically by
39
- * `SyncModule.forRoot(...)` / `SyncModule.forRootAsync(...)`.
40
- */
41
- export const SYNC_MODULE_OPTIONS = 'SYNC_MODULE_OPTIONS' as const;
42
-
43
- /**
44
- * Injection token for the resolved multi-tenancy flag (SYNC-6).
45
- *
46
- * Provided by `SyncModule.forRoot(...)` as `options.multiTenant ?? false`.
47
- * Consumed by `ExecuteSyncUseCase` to enforce the tenantId-is-required rule.
48
- */
49
- export const SYNC_MULTI_TENANT = 'SYNC_MULTI_TENANT' as const;
@@ -1,192 +0,0 @@
1
- ---
2
- to: "<%= schemaPath %>"
3
- force: true
4
- ---
5
- <%- typeof generatedBanner !== 'undefined' ? generatedBanner : '' %>
6
- /**
7
- * Drizzle schema for the sync subsystem audit/observability tables (SYNC-1).
8
- *
9
- * Three tables model end-to-end sync observability, keyed by the single
10
- * port every sync adapter implements (`IChangeSource<T>` from SYNC-2):
11
- *
12
- * - `sync_subscriptions` — owns the cursor per
13
- * `(integration_id, adapter, domain, external_ref)` tuple. Addressed
14
- * by id by `ICursorStore` (SYNC-3/SYNC-4).
15
- * - `sync_runs` — per-run audit log: start/complete, status,
16
- * cursor before/after, counts, direction + action.
17
- * - `sync_run_items` — per-record change log with structured
18
- * `changed_fields` jsonb (ADR-0003). The `FieldDiff` type alias
19
- * is owned by the sync subsystem's runtime protocol
20
- * (`sync-field-diff.protocol.ts` from SYNC-2).
21
- *
22
- * ## `tenant_id` columns — always emitted
23
- *
24
- * `tenant_id` is emitted as a nullable text column on all three tables
25
- * REGARDLESS of `sync.multi_tenant` — the runtime sync code (cursor store +
26
- * run recorder) references `tenant_id` unconditionally, so a `multi_tenant:
27
- * false` consumer that omitted the column failed to type-check (the column
28
- * was referenced but absent). The `SYNC_MULTI_TENANT` DI flag (SYNC-6) gates
29
- * non-null *enforcement* at runtime; it does not gate the column's existence
30
- * (mirrors the jobs subsystem). Under `multi_tenant: false` the column simply
31
- * stays null.
32
- *
33
- * See SYNC-1 / SYNC-6 in epic #60 for the decision rationale.
34
- */
35
- import {
36
- pgEnum,
37
- pgTable,
38
- uuid,
39
- text,
40
- jsonb,
41
- integer,
42
- boolean,
43
- timestamp,
44
- index,
45
- uniqueIndex,
46
- } from 'drizzle-orm/pg-core';
47
- import type { InferSelectModel } from 'drizzle-orm';
48
-
49
- // NOTE: the `FieldDiff` type alias is imported from the runtime protocol
50
- // shipped by `subsystem install sync`. If you moved that file, fix this
51
- // import to point at the new location.
52
- import type { FieldDiff } from './sync-field-diff.protocol';
53
-
54
- // ─── Enums ──────────────────────────────────────────────────────────────────
55
-
56
- export const syncRunDirectionEnum = pgEnum('sync_run_direction', [
57
- 'inbound',
58
- 'outbound',
59
- ]);
60
-
61
- export const syncRunActionEnum = pgEnum('sync_run_action', [
62
- 'poll',
63
- 'cdc',
64
- 'webhook',
65
- 'manual',
66
- 'writeback',
67
- ]);
68
-
69
- export const syncRunStatusEnum = pgEnum('sync_run_status', [
70
- 'running',
71
- 'success',
72
- 'no_changes',
73
- 'failed',
74
- ]);
75
-
76
- export const syncRunItemOperationEnum = pgEnum('sync_run_item_operation', [
77
- 'created',
78
- 'updated',
79
- 'deleted',
80
- 'noop',
81
- ]);
82
-
83
- export const syncRunItemStatusEnum = pgEnum('sync_run_item_status', [
84
- 'success',
85
- 'failed',
86
- 'skipped',
87
- ]);
88
-
89
- // ─── sync_subscriptions ─────────────────────────────────────────────────────
90
-
91
- export const syncSubscriptions = pgTable(
92
- 'sync_subscriptions',
93
- {
94
- id: uuid('id').primaryKey().defaultRandom(),
95
- integrationId: text('integration_id').notNull(),
96
- adapter: text('adapter').notNull(),
97
- domain: text('domain').notNull(),
98
- externalRef: text('external_ref'),
99
- enabled: boolean('enabled').notNull().default(true),
100
- config: jsonb('config').notNull().default({}).$type<Record<string, unknown>>(),
101
- cursor: jsonb('cursor').$type<unknown>(),
102
- lastSyncAt: timestamp('last_sync_at', { withTimezone: true }),
103
- tenantId: text('tenant_id'), // always emitted — the runtime sync code (cursor store + run recorder) references tenant_id unconditionally; SYNC_MULTI_TENANT gates enforcement, not the column's existence (mirrors jobs)
104
- createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
105
- updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
106
- },
107
- (t) => ({
108
- uqSyncSubscriptionTuple: uniqueIndex('uq_sync_subscriptions_tuple').on(
109
- t.integrationId,
110
- t.adapter,
111
- t.domain,
112
- t.externalRef,
113
- ),
114
- idxSyncSubscriptionsEnabledLastSync: index(
115
- 'idx_sync_subscriptions_enabled_last_sync',
116
- ).on(t.enabled, t.lastSyncAt),
117
- }),
118
- );
119
-
120
- export type SyncSubscriptionRow = InferSelectModel<typeof syncSubscriptions>;
121
-
122
- // ─── sync_runs ──────────────────────────────────────────────────────────────
123
-
124
- export const syncRuns = pgTable(
125
- 'sync_runs',
126
- {
127
- id: uuid('id').primaryKey().defaultRandom(),
128
- subscriptionId: uuid('subscription_id')
129
- .notNull()
130
- .references(() => syncSubscriptions.id, { onDelete: 'cascade' }),
131
- direction: syncRunDirectionEnum('direction').notNull(),
132
- action: syncRunActionEnum('action').notNull(),
133
- status: syncRunStatusEnum('status').notNull().default('running'),
134
- recordsFound: integer('records_found').notNull().default(0),
135
- recordsProcessed: integer('records_processed').notNull().default(0),
136
- cursorBefore: jsonb('cursor_before').$type<unknown>(),
137
- cursorAfter: jsonb('cursor_after').$type<unknown>(),
138
- durationMs: integer('duration_ms'),
139
- error: text('error'),
140
- startedAt: timestamp('started_at', { withTimezone: true })
141
- .notNull()
142
- .defaultNow(),
143
- completedAt: timestamp('completed_at', { withTimezone: true }),
144
- tenantId: text('tenant_id'), // always emitted — the runtime sync code (cursor store + run recorder) references tenant_id unconditionally; SYNC_MULTI_TENANT gates enforcement, not the column's existence (mirrors jobs)
145
- },
146
- (t) => ({
147
- idxSyncRunsSubscriptionStartedAt: index(
148
- 'idx_sync_runs_subscription_started_at',
149
- ).on(t.subscriptionId, t.startedAt),
150
- idxSyncRunsStatusStartedAt: index('idx_sync_runs_status_started_at').on(
151
- t.status,
152
- t.startedAt,
153
- ),
154
- }),
155
- );
156
-
157
- export type SyncRunRow = InferSelectModel<typeof syncRuns>;
158
-
159
- // ─── sync_run_items ─────────────────────────────────────────────────────────
160
-
161
- export const syncRunItems = pgTable(
162
- 'sync_run_items',
163
- {
164
- id: uuid('id').primaryKey().defaultRandom(),
165
- syncRunId: uuid('sync_run_id')
166
- .notNull()
167
- .references(() => syncRuns.id, { onDelete: 'cascade' }),
168
- entityType: text('entity_type').notNull(),
169
- externalId: text('external_id').notNull(),
170
- localId: text('local_id'),
171
- operation: syncRunItemOperationEnum('operation').notNull(),
172
- status: syncRunItemStatusEnum('status').notNull(),
173
- changedFields: jsonb('changed_fields').notNull().default({}).$type<FieldDiff>(),
174
- title: text('title'),
175
- error: text('error'),
176
- createdAt: timestamp('created_at', { withTimezone: true })
177
- .notNull()
178
- .defaultNow(),
179
- tenantId: text('tenant_id'), // always emitted — the runtime sync code (cursor store + run recorder) references tenant_id unconditionally; SYNC_MULTI_TENANT gates enforcement, not the column's existence (mirrors jobs)
180
- },
181
- (t) => ({
182
- idxSyncRunItemsRunCreatedAt: index('idx_sync_run_items_run_created_at').on(
183
- t.syncRunId,
184
- t.createdAt,
185
- ),
186
- idxSyncRunItemsEntityExternal: index(
187
- 'idx_sync_run_items_entity_external',
188
- ).on(t.entityType, t.externalId),
189
- }),
190
- );
191
-
192
- export type SyncRunItemRow = InferSelectModel<typeof syncRunItems>;
@@ -1,22 +0,0 @@
1
- /**
2
- * Hygen prompt.js — SYNC-7 sync config-block scaffold.
3
- *
4
- * Split from `templates/subsystem/sync/` so the CLI can invoke the
5
- * config-block inject step independently of the rest of the sync scaffold.
6
- * This lets `subsystem install sync --force` preserve an existing `sync:`
7
- * block by skipping this action entirely, while `--force-config` opts in
8
- * to regenerating it.
9
- *
10
- * Mirrors `events-config` exactly.
11
- *
12
- * Invoked via:
13
- * bunx hygen subsystem sync-config --configPath <abs>
14
- */
15
-
16
- export default {
17
- prompt: async ({ args }) => {
18
- return {
19
- configPath: args.configPath ?? "codegen.config.yaml",
20
- };
21
- },
22
- };