openloops 0.6.0 → 0.7.2

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 (538) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +1 -1
  3. package/dist/clients/llm/llm-client.mjs +0 -1
  4. package/dist/clients/llm/llm-error.mjs +0 -1
  5. package/dist/clients/llm/llm-types.mjs +0 -1
  6. package/dist/clients/llm/model-resolution.mjs +0 -1
  7. package/dist/clients/llm/pi-ai-adapter.mjs +0 -1
  8. package/dist/clients/llm/sampling-rules.mjs +0 -1
  9. package/dist/clients/serper/serper-client.mjs +0 -1
  10. package/dist/clients/slack/slack-client.mjs +0 -1
  11. package/dist/common/base/base.app.d.ts +3 -3
  12. package/dist/common/base/base.app.mjs +0 -1
  13. package/dist/common/base/base.entity.d.ts +4 -16
  14. package/dist/common/base/base.entity.js +11 -39
  15. package/dist/common/base/base.entity.mjs +11 -40
  16. package/dist/common/base/base.use-case.d.ts +1 -7
  17. package/dist/common/base/base.use-case.mjs +0 -1
  18. package/dist/common/base/current-session.mjs +0 -1
  19. package/dist/common/base/current-user.mjs +0 -1
  20. package/dist/common/base/share.mjs +0 -1
  21. package/dist/common/base/utils/index.d.ts +1 -2
  22. package/dist/common/base/utils/index.js +2 -4
  23. package/dist/common/base/utils/index.mjs +1 -2
  24. package/dist/common/base/utils/is-plain-object.mjs +0 -1
  25. package/dist/common/base/utils/to-patch.d.ts +9 -0
  26. package/dist/common/base/utils/to-patch.js +46 -0
  27. package/dist/common/base/utils/to-patch.mjs +21 -0
  28. package/dist/common/constants/harness.mjs +0 -1
  29. package/dist/common/error/http-error.mjs +0 -1
  30. package/dist/common/error/reportError.mjs +0 -1
  31. package/dist/common/error/sentry-client.mjs +0 -1
  32. package/dist/common/helpers/escape-regex.mjs +0 -1
  33. package/dist/common/helpers/extract-json-from-text.mjs +0 -1
  34. package/dist/common/helpers/sanitize-string.mjs +0 -1
  35. package/dist/common/logger/pino.mjs +0 -1
  36. package/dist/common/repositories/mongo-db.client.mjs +0 -1
  37. package/dist/common/repositories/mongo-db.repository.d.ts +15 -4
  38. package/dist/common/repositories/mongo-db.repository.js +44 -15
  39. package/dist/common/repositories/mongo-db.repository.mjs +44 -16
  40. package/dist/common/repositories/scope.mjs +0 -1
  41. package/dist/common/utils/database-name.mjs +0 -1
  42. package/dist/common/utils/number-setting.mjs +0 -1
  43. package/dist/common/utils/secret-manager.mjs +0 -1
  44. package/dist/db/indexes/agent-actions.mjs +0 -1
  45. package/dist/db/indexes/agent-tasks.mjs +0 -1
  46. package/dist/db/indexes/agent-traces.mjs +0 -1
  47. package/dist/db/indexes/automation-runs.mjs +0 -1
  48. package/dist/db/indexes/automations.mjs +0 -1
  49. package/dist/db/indexes/chats.mjs +0 -1
  50. package/dist/db/indexes/index.js +3 -1
  51. package/dist/db/indexes/index.mjs +3 -2
  52. package/dist/db/indexes/llm-calls.mjs +0 -1
  53. package/dist/db/indexes/mcp-servers.js +2 -1
  54. package/dist/db/indexes/mcp-servers.mjs +2 -2
  55. package/dist/db/indexes/refresh-tokens.d.ts +2 -0
  56. package/dist/{common/decorators/mask-in-logs/index.js → db/indexes/refresh-tokens.js} +16 -5
  57. package/dist/db/indexes/refresh-tokens.mjs +9 -0
  58. package/dist/db/indexes/revoked-tokens.mjs +0 -1
  59. package/dist/db/indexes/workspace-items.mjs +0 -1
  60. package/dist/db/migrations/automations.mjs +0 -1
  61. package/dist/guardrails/guard.mjs +0 -1
  62. package/dist/guardrails/index.mjs +0 -1
  63. package/dist/guardrails/input/block-card.mjs +0 -1
  64. package/dist/guardrails/input/block-code.mjs +0 -1
  65. package/dist/guardrails/input/block-email.mjs +0 -1
  66. package/dist/guardrails/input/create-block-input-oversize.mjs +0 -1
  67. package/dist/guardrails/input/diagnostic-sanity.mjs +0 -1
  68. package/dist/guardrails/input/input-check.mjs +0 -1
  69. package/dist/harness/agent-loop.mjs +0 -1
  70. package/dist/harness/agent-state.mjs +0 -1
  71. package/dist/harness/agent.d.ts +1 -3
  72. package/dist/harness/agent.js +29 -23
  73. package/dist/harness/agent.mjs +29 -24
  74. package/dist/harness/native-tools.mjs +0 -1
  75. package/dist/harness/skills/approval-request.mjs +0 -1
  76. package/dist/harness/skills/autonomous-answer.mjs +0 -1
  77. package/dist/harness/skills/confirmation-gate.mjs +0 -1
  78. package/dist/harness/skills/mcp-change-review.mjs +0 -1
  79. package/dist/harness/tool-catalog.mjs +0 -1
  80. package/dist/harness/tool-pipeline.mjs +0 -1
  81. package/dist/harness/utils/activity.mjs +0 -1
  82. package/dist/harness/utils/describe-shape.mjs +0 -1
  83. package/dist/harness/utils/grounding.mjs +0 -1
  84. package/dist/harness/utils/rank-tools-by-keywords.mjs +0 -1
  85. package/dist/harness/workspace.js +7 -7
  86. package/dist/harness/workspace.mjs +7 -8
  87. package/dist/loops/agi/loop.mjs +0 -1
  88. package/dist/loops/agi/skills/reasoning-engine.mjs +0 -1
  89. package/dist/loops/shared/skills/fast-responder.mjs +0 -1
  90. package/dist/services/authentication/entities/index.d.ts +1 -0
  91. package/dist/services/authentication/entities/index.js +3 -1
  92. package/dist/services/authentication/entities/index.mjs +1 -0
  93. package/dist/services/authentication/entities/refresh-token.entity.d.ts +25 -0
  94. package/dist/services/authentication/entities/refresh-token.entity.js +75 -0
  95. package/dist/services/authentication/entities/refresh-token.entity.mjs +51 -0
  96. package/dist/services/authentication/entities/revoked-token.entity.mjs +0 -1
  97. package/dist/services/authentication/helpers/auth-config.d.ts +9 -0
  98. package/dist/services/authentication/helpers/auth-config.js +36 -0
  99. package/dist/services/authentication/helpers/auth-config.mjs +12 -0
  100. package/dist/services/authentication/helpers/session-tokens.d.ts +16 -0
  101. package/dist/services/authentication/helpers/session-tokens.js +60 -0
  102. package/dist/services/authentication/helpers/session-tokens.mjs +35 -0
  103. package/dist/services/authentication/helpers/tokens.d.ts +43 -0
  104. package/dist/services/authentication/helpers/tokens.js +113 -0
  105. package/dist/services/authentication/helpers/tokens.mjs +71 -0
  106. package/dist/services/authentication/index.d.ts +3 -0
  107. package/dist/services/authentication/index.js +23 -0
  108. package/dist/services/authentication/index.mjs +11 -0
  109. package/dist/services/authentication/module.d.ts +12 -3
  110. package/dist/services/authentication/module.js +40 -7
  111. package/dist/services/authentication/module.mjs +34 -7
  112. package/dist/services/authentication/repositories/index.d.ts +1 -0
  113. package/dist/services/authentication/repositories/index.js +3 -1
  114. package/dist/services/authentication/repositories/index.mjs +1 -0
  115. package/dist/services/authentication/repositories/refresh-token.repository.d.ts +10 -0
  116. package/dist/services/authentication/repositories/refresh-token.repository.js +60 -0
  117. package/dist/services/authentication/repositories/refresh-token.repository.mjs +36 -0
  118. package/dist/services/authentication/repositories/revoked-token.repository.js +3 -15
  119. package/dist/services/authentication/repositories/revoked-token.repository.mjs +3 -10
  120. package/dist/services/authentication/use-cases/claim-refresh-token.use-case.d.ts +12 -0
  121. package/dist/services/authentication/use-cases/claim-refresh-token.use-case.js +40 -0
  122. package/dist/services/authentication/use-cases/claim-refresh-token.use-case.mjs +16 -0
  123. package/dist/services/authentication/use-cases/create-refresh-token.use-case.d.ts +11 -0
  124. package/dist/services/authentication/use-cases/create-refresh-token.use-case.js +43 -0
  125. package/dist/services/authentication/use-cases/create-refresh-token.use-case.mjs +19 -0
  126. package/dist/services/authentication/use-cases/find-refresh-token-by-hash.use-case.d.ts +11 -0
  127. package/dist/services/authentication/use-cases/find-refresh-token-by-hash.use-case.js +40 -0
  128. package/dist/services/authentication/use-cases/find-refresh-token-by-hash.use-case.mjs +16 -0
  129. package/dist/services/authentication/use-cases/is-token-revoked.use-case.d.ts +6 -8
  130. package/dist/services/authentication/use-cases/is-token-revoked.use-case.js +4 -18
  131. package/dist/services/authentication/use-cases/is-token-revoked.use-case.mjs +4 -13
  132. package/dist/services/authentication/use-cases/issue-password-reset-token.use-case.d.ts +18 -0
  133. package/dist/services/authentication/use-cases/issue-password-reset-token.use-case.js +49 -0
  134. package/dist/services/authentication/use-cases/issue-password-reset-token.use-case.mjs +25 -0
  135. package/dist/services/authentication/use-cases/issue-session.use-case.d.ts +13 -0
  136. package/dist/services/authentication/use-cases/issue-session.use-case.js +48 -0
  137. package/dist/services/authentication/use-cases/issue-session.use-case.mjs +24 -0
  138. package/dist/services/authentication/use-cases/login.use-case.d.ts +11 -11
  139. package/dist/services/authentication/use-cases/login.use-case.js +18 -54
  140. package/dist/services/authentication/use-cases/login.use-case.mjs +17 -38
  141. package/dist/services/authentication/use-cases/logout.use-case.d.ts +14 -0
  142. package/dist/services/authentication/use-cases/logout.use-case.js +48 -0
  143. package/dist/services/authentication/use-cases/logout.use-case.mjs +24 -0
  144. package/dist/services/authentication/use-cases/refresh.use-case.d.ts +23 -0
  145. package/dist/services/authentication/use-cases/refresh.use-case.js +84 -0
  146. package/dist/services/authentication/use-cases/refresh.use-case.mjs +60 -0
  147. package/dist/services/authentication/use-cases/reset-password.use-case.d.ts +15 -0
  148. package/dist/services/authentication/use-cases/reset-password.use-case.js +61 -0
  149. package/dist/services/authentication/use-cases/reset-password.use-case.mjs +37 -0
  150. package/dist/services/authentication/use-cases/revoke-refresh-token-family.use-case.d.ts +11 -0
  151. package/dist/services/authentication/use-cases/revoke-refresh-token-family.use-case.js +40 -0
  152. package/dist/services/authentication/use-cases/revoke-refresh-token-family.use-case.mjs +16 -0
  153. package/dist/services/authentication/use-cases/revoke-token.use-case.d.ts +4 -6
  154. package/dist/services/authentication/use-cases/revoke-token.use-case.js +12 -26
  155. package/dist/services/authentication/use-cases/revoke-token.use-case.mjs +10 -19
  156. package/dist/services/authentication/use-cases/revoke-user-refresh-tokens.use-case.d.ts +13 -0
  157. package/dist/services/authentication/use-cases/revoke-user-refresh-tokens.use-case.js +40 -0
  158. package/dist/services/authentication/use-cases/revoke-user-refresh-tokens.use-case.mjs +16 -0
  159. package/dist/services/automations/entities/automation-run.entity.mjs +0 -1
  160. package/dist/services/automations/entities/automation.entity.d.ts +1 -0
  161. package/dist/services/automations/entities/automation.entity.js +2 -1
  162. package/dist/services/automations/entities/automation.entity.mjs +2 -2
  163. package/dist/services/automations/entities/recurrence.mjs +0 -1
  164. package/dist/services/automations/entities/trigger.mjs +0 -1
  165. package/dist/services/automations/module.d.ts +0 -1
  166. package/dist/services/automations/module.js +20 -22
  167. package/dist/services/automations/module.mjs +20 -23
  168. package/dist/services/automations/repositories/automation-run.repository.js +7 -22
  169. package/dist/services/automations/repositories/automation-run.repository.mjs +7 -17
  170. package/dist/services/automations/repositories/automation.repository.js +25 -39
  171. package/dist/services/automations/repositories/automation.repository.mjs +25 -34
  172. package/dist/services/automations/runner/automation-runner.js +9 -12
  173. package/dist/services/automations/runner/automation-runner.mjs +9 -13
  174. package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.d.ts +4 -6
  175. package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.js +5 -19
  176. package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.mjs +5 -14
  177. package/dist/services/automations/use-cases/claim-due-automations.use-case.d.ts +9 -11
  178. package/dist/services/automations/use-cases/claim-due-automations.use-case.js +4 -20
  179. package/dist/services/automations/use-cases/claim-due-automations.use-case.mjs +4 -15
  180. package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.d.ts +9 -11
  181. package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.js +4 -20
  182. package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.mjs +4 -15
  183. package/dist/services/automations/use-cases/create-automation.use-case.d.ts +4 -6
  184. package/dist/services/automations/use-cases/create-automation.use-case.js +5 -19
  185. package/dist/services/automations/use-cases/create-automation.use-case.mjs +5 -14
  186. package/dist/services/automations/use-cases/delete-automation.use-case.d.ts +6 -6
  187. package/dist/services/automations/use-cases/delete-automation.use-case.js +8 -22
  188. package/dist/services/automations/use-cases/delete-automation.use-case.mjs +8 -17
  189. package/dist/services/automations/use-cases/finish-automation-run.use-case.d.ts +5 -7
  190. package/dist/services/automations/use-cases/finish-automation-run.use-case.js +5 -20
  191. package/dist/services/automations/use-cases/finish-automation-run.use-case.mjs +5 -15
  192. package/dist/services/automations/use-cases/get-automation-by-id.use-case.d.ts +4 -6
  193. package/dist/services/automations/use-cases/get-automation-by-id.use-case.js +5 -19
  194. package/dist/services/automations/use-cases/get-automation-by-id.use-case.mjs +5 -14
  195. package/dist/services/automations/use-cases/issue-automation-event-token.use-case.d.ts +7 -9
  196. package/dist/services/automations/use-cases/issue-automation-event-token.use-case.js +6 -20
  197. package/dist/services/automations/use-cases/issue-automation-event-token.use-case.mjs +6 -15
  198. package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.d.ts +6 -6
  199. package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.js +5 -19
  200. package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.mjs +5 -14
  201. package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.d.ts +6 -6
  202. package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.js +5 -19
  203. package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.mjs +5 -14
  204. package/dist/services/automations/use-cases/list-automations-by-user.use-case.d.ts +6 -6
  205. package/dist/services/automations/use-cases/list-automations-by-user.use-case.js +5 -19
  206. package/dist/services/automations/use-cases/list-automations-by-user.use-case.mjs +5 -14
  207. package/dist/services/automations/use-cases/preview-automation-runs.use-case.d.ts +4 -6
  208. package/dist/services/automations/use-cases/preview-automation-runs.use-case.js +3 -15
  209. package/dist/services/automations/use-cases/preview-automation-runs.use-case.mjs +3 -10
  210. package/dist/services/automations/use-cases/receive-automation-event.use-case.d.ts +8 -10
  211. package/dist/services/automations/use-cases/receive-automation-event.use-case.js +8 -23
  212. package/dist/services/automations/use-cases/receive-automation-event.use-case.mjs +8 -18
  213. package/dist/services/automations/use-cases/renew-automation-lease.use-case.d.ts +6 -8
  214. package/dist/services/automations/use-cases/renew-automation-lease.use-case.js +4 -18
  215. package/dist/services/automations/use-cases/renew-automation-lease.use-case.mjs +4 -13
  216. package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.d.ts +6 -8
  217. package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.js +8 -21
  218. package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.mjs +9 -17
  219. package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.d.ts +4 -6
  220. package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.js +8 -22
  221. package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.mjs +8 -17
  222. package/dist/services/automations/use-cases/start-automation-run.use-case.d.ts +8 -10
  223. package/dist/services/automations/use-cases/start-automation-run.use-case.js +5 -20
  224. package/dist/services/automations/use-cases/start-automation-run.use-case.mjs +5 -15
  225. package/dist/services/automations/use-cases/sync-automation-run.use-case.d.ts +5 -7
  226. package/dist/services/automations/use-cases/sync-automation-run.use-case.js +12 -27
  227. package/dist/services/automations/use-cases/sync-automation-run.use-case.mjs +12 -22
  228. package/dist/services/automations/use-cases/sync-automation-runs.use-case.d.ts +8 -10
  229. package/dist/services/automations/use-cases/sync-automation-runs.use-case.js +7 -22
  230. package/dist/services/automations/use-cases/sync-automation-runs.use-case.mjs +7 -17
  231. package/dist/services/automations/use-cases/update-automation.use-case.d.ts +4 -6
  232. package/dist/services/automations/use-cases/update-automation.use-case.js +10 -24
  233. package/dist/services/automations/use-cases/update-automation.use-case.mjs +10 -19
  234. package/dist/services/automations/utils/automation-event-error.mjs +0 -1
  235. package/dist/services/automations/utils/automation-fields.mjs +0 -1
  236. package/dist/services/automations/utils/event-message.mjs +0 -1
  237. package/dist/services/automations/utils/event-token.d.ts +1 -2
  238. package/dist/services/automations/utils/event-token.js +9 -35
  239. package/dist/services/automations/utils/event-token.mjs +9 -25
  240. package/dist/services/automations/utils/next-run.mjs +0 -1
  241. package/dist/services/automations/utils/open-run.mjs +0 -1
  242. package/dist/services/automations/utils/previous-run.js +1 -1
  243. package/dist/services/automations/utils/previous-run.mjs +1 -2
  244. package/dist/services/automations/utils/runner-scope.mjs +0 -1
  245. package/dist/services/automations/utils/settings.mjs +0 -1
  246. package/dist/services/chats/entities/chat-message.entity.mjs +0 -1
  247. package/dist/services/chats/entities/chat-settings.entity.mjs +0 -1
  248. package/dist/services/chats/entities/chat.entity.d.ts +1 -0
  249. package/dist/services/chats/entities/chat.entity.js +3 -2
  250. package/dist/services/chats/entities/chat.entity.mjs +3 -3
  251. package/dist/services/chats/module.d.ts +0 -1
  252. package/dist/services/chats/module.js +5 -7
  253. package/dist/services/chats/module.mjs +5 -8
  254. package/dist/services/chats/repositories/chat.repository.js +5 -20
  255. package/dist/services/chats/repositories/chat.repository.mjs +5 -15
  256. package/dist/services/chats/use-cases/create-chat.use-case.d.ts +4 -6
  257. package/dist/services/chats/use-cases/create-chat.use-case.js +5 -19
  258. package/dist/services/chats/use-cases/create-chat.use-case.mjs +5 -14
  259. package/dist/services/chats/use-cases/delete-chat.use-case.d.ts +6 -6
  260. package/dist/services/chats/use-cases/delete-chat.use-case.js +8 -22
  261. package/dist/services/chats/use-cases/delete-chat.use-case.mjs +8 -17
  262. package/dist/services/chats/use-cases/get-chat-by-id.use-case.d.ts +4 -6
  263. package/dist/services/chats/use-cases/get-chat-by-id.use-case.js +6 -20
  264. package/dist/services/chats/use-cases/get-chat-by-id.use-case.mjs +6 -15
  265. package/dist/services/chats/use-cases/interrupt-execution.use-case.d.ts +4 -6
  266. package/dist/services/chats/use-cases/interrupt-execution.use-case.js +6 -20
  267. package/dist/services/chats/use-cases/interrupt-execution.use-case.mjs +6 -15
  268. package/dist/services/chats/use-cases/list-chats-by-props.use-case.d.ts +6 -6
  269. package/dist/services/chats/use-cases/list-chats-by-props.use-case.js +5 -19
  270. package/dist/services/chats/use-cases/list-chats-by-props.use-case.mjs +5 -14
  271. package/dist/services/chats/use-cases/list-chats-by-user.use-case.d.ts +6 -6
  272. package/dist/services/chats/use-cases/list-chats-by-user.use-case.js +5 -19
  273. package/dist/services/chats/use-cases/list-chats-by-user.use-case.mjs +5 -14
  274. package/dist/services/chats/use-cases/update-chat.use-case.d.ts +5 -6
  275. package/dist/services/chats/use-cases/update-chat.use-case.js +8 -26
  276. package/dist/services/chats/use-cases/update-chat.use-case.mjs +8 -21
  277. package/dist/services/chats/utils/deprecated-activity.mjs +0 -1
  278. package/dist/services/llmcalls/entities/llmcall.entity.mjs +0 -1
  279. package/dist/services/llmcalls/module.d.ts +0 -1
  280. package/dist/services/llmcalls/module.js +4 -6
  281. package/dist/services/llmcalls/module.mjs +4 -7
  282. package/dist/services/llmcalls/repositories/llmcall.repository.js +5 -20
  283. package/dist/services/llmcalls/repositories/llmcall.repository.mjs +5 -15
  284. package/dist/services/llmcalls/use-cases/create-llmcall.use-case.d.ts +4 -6
  285. package/dist/services/llmcalls/use-cases/create-llmcall.use-case.js +5 -19
  286. package/dist/services/llmcalls/use-cases/create-llmcall.use-case.mjs +5 -14
  287. package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.d.ts +6 -6
  288. package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.js +8 -22
  289. package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.mjs +8 -17
  290. package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.d.ts +4 -6
  291. package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.js +5 -19
  292. package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.mjs +5 -14
  293. package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.d.ts +4 -6
  294. package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.js +5 -19
  295. package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.mjs +5 -14
  296. package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.d.ts +4 -6
  297. package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.js +5 -19
  298. package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.mjs +5 -14
  299. package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.d.ts +4 -6
  300. package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.js +6 -20
  301. package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.mjs +6 -15
  302. package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.d.ts +6 -6
  303. package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.js +5 -19
  304. package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.mjs +5 -14
  305. package/dist/services/llmcalls/use-cases/update-llmcall.use-case.d.ts +4 -6
  306. package/dist/services/llmcalls/use-cases/update-llmcall.use-case.js +7 -21
  307. package/dist/services/llmcalls/use-cases/update-llmcall.use-case.mjs +7 -16
  308. package/dist/services/llmcalls/utils/usage-periods.mjs +0 -1
  309. package/dist/services/llmcalls/utils/usage-totals.mjs +0 -1
  310. package/dist/services/mcp-servers/admin/index.d.ts +1 -0
  311. package/dist/{common/decorators → services/mcp-servers/admin}/index.js +4 -4
  312. package/dist/services/mcp-servers/admin/index.mjs +1 -0
  313. package/dist/services/mcp-servers/admin/module.d.ts +10 -0
  314. package/dist/services/mcp-servers/admin/module.js +55 -0
  315. package/dist/services/mcp-servers/admin/module.mjs +27 -0
  316. package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.d.ts +12 -0
  317. package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.js +50 -0
  318. package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.mjs +26 -0
  319. package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.d.ts +13 -0
  320. package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.js +44 -0
  321. package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.mjs +20 -0
  322. package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.d.ts +12 -0
  323. package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.js +41 -0
  324. package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.mjs +17 -0
  325. package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.d.ts +16 -0
  326. package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.js +42 -0
  327. package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.mjs +18 -0
  328. package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.d.ts +13 -0
  329. package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.js +59 -0
  330. package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.mjs +35 -0
  331. package/dist/services/mcp-servers/entities/mcp-manifest.mjs +0 -1
  332. package/dist/services/mcp-servers/entities/mcpserver.entity.d.ts +10 -1
  333. package/dist/services/mcp-servers/entities/mcpserver.entity.js +28 -3
  334. package/dist/services/mcp-servers/entities/mcpserver.entity.mjs +28 -4
  335. package/dist/services/mcp-servers/internal.d.ts +7 -0
  336. package/dist/{common/base/utils/flatten-object.js → services/mcp-servers/internal.js} +9 -22
  337. package/dist/services/mcp-servers/internal.mjs +8 -0
  338. package/dist/services/mcp-servers/module.d.ts +0 -1
  339. package/dist/services/mcp-servers/module.js +8 -10
  340. package/dist/services/mcp-servers/module.mjs +8 -11
  341. package/dist/services/mcp-servers/repositories/mcpserver.repository.d.ts +8 -0
  342. package/dist/services/mcp-servers/repositories/mcpserver.repository.js +28 -24
  343. package/dist/services/mcp-servers/repositories/mcpserver.repository.mjs +29 -20
  344. package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.d.ts +5 -7
  345. package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.js +5 -21
  346. package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.mjs +5 -16
  347. package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.d.ts +4 -6
  348. package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.js +7 -21
  349. package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.mjs +7 -16
  350. package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.d.ts +6 -6
  351. package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.js +8 -22
  352. package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.mjs +8 -17
  353. package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.d.ts +4 -6
  354. package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.js +5 -19
  355. package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.mjs +5 -14
  356. package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.d.ts +6 -6
  357. package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.js +5 -19
  358. package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.mjs +5 -14
  359. package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.d.ts +6 -6
  360. package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.js +7 -19
  361. package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.mjs +7 -14
  362. package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.d.ts +5 -7
  363. package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.js +10 -26
  364. package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.mjs +10 -21
  365. package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.d.ts +4 -6
  366. package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.js +9 -23
  367. package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.mjs +9 -18
  368. package/dist/services/tasks/entities/agent-action.entity.mjs +0 -1
  369. package/dist/services/tasks/entities/agent-task.entity.mjs +0 -1
  370. package/dist/services/tasks/module.d.ts +0 -1
  371. package/dist/services/tasks/module.js +7 -9
  372. package/dist/services/tasks/module.mjs +7 -10
  373. package/dist/services/tasks/repositories/agent-action.repository.js +5 -21
  374. package/dist/services/tasks/repositories/agent-action.repository.mjs +5 -16
  375. package/dist/services/tasks/repositories/agent-task.repository.js +5 -21
  376. package/dist/services/tasks/repositories/agent-task.repository.mjs +5 -16
  377. package/dist/services/tasks/use-cases/create-agent-action.use-case.d.ts +4 -6
  378. package/dist/services/tasks/use-cases/create-agent-action.use-case.js +5 -19
  379. package/dist/services/tasks/use-cases/create-agent-action.use-case.mjs +5 -14
  380. package/dist/services/tasks/use-cases/create-agent-task.use-case.d.ts +4 -6
  381. package/dist/services/tasks/use-cases/create-agent-task.use-case.js +5 -19
  382. package/dist/services/tasks/use-cases/create-agent-task.use-case.mjs +5 -14
  383. package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.d.ts +4 -6
  384. package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.js +5 -19
  385. package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.mjs +5 -14
  386. package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.d.ts +6 -6
  387. package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.js +5 -19
  388. package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.mjs +5 -14
  389. package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.d.ts +6 -6
  390. package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.js +5 -19
  391. package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.mjs +5 -14
  392. package/dist/services/tasks/use-cases/update-agent-action.use-case.d.ts +4 -6
  393. package/dist/services/tasks/use-cases/update-agent-action.use-case.js +6 -20
  394. package/dist/services/tasks/use-cases/update-agent-action.use-case.mjs +6 -15
  395. package/dist/services/tasks/use-cases/update-agent-task.use-case.d.ts +4 -6
  396. package/dist/services/tasks/use-cases/update-agent-task.use-case.js +6 -20
  397. package/dist/services/tasks/use-cases/update-agent-task.use-case.mjs +6 -15
  398. package/dist/services/traces/entities/agent-trace-entry.entity.mjs +0 -1
  399. package/dist/services/traces/module.d.ts +0 -1
  400. package/dist/services/traces/module.js +2 -4
  401. package/dist/services/traces/module.mjs +2 -5
  402. package/dist/services/traces/repositories/agent-trace.repository.js +3 -15
  403. package/dist/services/traces/repositories/agent-trace.repository.mjs +3 -10
  404. package/dist/services/traces/use-cases/create-agent-traces.use-case.d.ts +6 -8
  405. package/dist/services/traces/use-cases/create-agent-traces.use-case.js +5 -19
  406. package/dist/services/traces/use-cases/create-agent-traces.use-case.mjs +5 -14
  407. package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.d.ts +6 -6
  408. package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.js +5 -19
  409. package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.mjs +5 -14
  410. package/dist/services/users/entities/user-acquisition.js +2 -2
  411. package/dist/services/users/entities/user-acquisition.mjs +2 -3
  412. package/dist/services/users/entities/user-country.js +2 -2
  413. package/dist/services/users/entities/user-country.mjs +2 -3
  414. package/dist/services/users/entities/user-currency.js +2 -2
  415. package/dist/services/users/entities/user-currency.mjs +2 -3
  416. package/dist/services/users/entities/user-default-model.js +2 -2
  417. package/dist/services/users/entities/user-default-model.mjs +2 -3
  418. package/dist/services/users/entities/user-email.value-object.mjs +0 -1
  419. package/dist/services/users/entities/user-language.js +2 -2
  420. package/dist/services/users/entities/user-language.mjs +2 -3
  421. package/dist/services/users/entities/user-marketing.js +2 -2
  422. package/dist/services/users/entities/user-marketing.mjs +2 -3
  423. package/dist/services/users/entities/user-notification-preferences.mjs +0 -1
  424. package/dist/services/users/entities/user-password.value-object.mjs +0 -1
  425. package/dist/services/users/entities/user-permissions.mjs +0 -1
  426. package/dist/services/users/entities/user-preferences.mjs +0 -1
  427. package/dist/services/users/entities/user-report-preferences.mjs +0 -1
  428. package/dist/services/users/entities/user-report-schedule.mjs +0 -1
  429. package/dist/services/users/entities/user-timezone.js +2 -2
  430. package/dist/services/users/entities/user-timezone.mjs +2 -3
  431. package/dist/services/users/entities/user.entity.d.ts +1 -0
  432. package/dist/services/users/entities/user.entity.js +9 -22
  433. package/dist/services/users/entities/user.entity.mjs +9 -17
  434. package/dist/services/users/module.d.ts +2 -1
  435. package/dist/services/users/module.js +12 -7
  436. package/dist/services/users/module.mjs +11 -8
  437. package/dist/services/users/repositories/user.repository.d.ts +2 -0
  438. package/dist/services/users/repositories/user.repository.js +11 -20
  439. package/dist/services/users/repositories/user.repository.mjs +11 -15
  440. package/dist/services/users/use-cases/change-password.use-case.d.ts +15 -0
  441. package/dist/services/users/use-cases/change-password.use-case.js +52 -0
  442. package/dist/services/users/use-cases/change-password.use-case.mjs +28 -0
  443. package/dist/services/users/use-cases/create-user.use-case.d.ts +4 -6
  444. package/dist/services/users/use-cases/create-user.use-case.js +5 -19
  445. package/dist/services/users/use-cases/create-user.use-case.mjs +5 -14
  446. package/dist/services/users/use-cases/delete-user.use-case.d.ts +6 -6
  447. package/dist/services/users/use-cases/delete-user.use-case.js +8 -22
  448. package/dist/services/users/use-cases/delete-user.use-case.mjs +8 -17
  449. package/dist/services/users/use-cases/get-user-by-id.use-case.d.ts +4 -6
  450. package/dist/services/users/use-cases/get-user-by-id.use-case.js +6 -20
  451. package/dist/services/users/use-cases/get-user-by-id.use-case.mjs +6 -15
  452. package/dist/services/users/use-cases/list-users-by-props.use-case.d.ts +6 -6
  453. package/dist/services/users/use-cases/list-users-by-props.use-case.js +5 -19
  454. package/dist/services/users/use-cases/list-users-by-props.use-case.mjs +5 -14
  455. package/dist/services/users/use-cases/update-user.use-case.d.ts +4 -6
  456. package/dist/services/users/use-cases/update-user.use-case.js +9 -22
  457. package/dist/services/users/use-cases/update-user.use-case.mjs +9 -17
  458. package/dist/services/users/utils/default-model.mjs +0 -1
  459. package/dist/services/workspaces/entities/workspace-item.entity.mjs +0 -1
  460. package/dist/services/workspaces/module.d.ts +0 -1
  461. package/dist/services/workspaces/module.js +5 -7
  462. package/dist/services/workspaces/module.mjs +5 -8
  463. package/dist/services/workspaces/repositories/workspace-item.repository.js +5 -20
  464. package/dist/services/workspaces/repositories/workspace-item.repository.mjs +5 -15
  465. package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.d.ts +6 -8
  466. package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.js +7 -21
  467. package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.mjs +7 -16
  468. package/dist/services/workspaces/use-cases/get-workspace-item.use-case.d.ts +4 -6
  469. package/dist/services/workspaces/use-cases/get-workspace-item.use-case.js +6 -20
  470. package/dist/services/workspaces/use-cases/get-workspace-item.use-case.mjs +6 -15
  471. package/dist/services/workspaces/use-cases/list-workspace-items.use-case.d.ts +6 -6
  472. package/dist/services/workspaces/use-cases/list-workspace-items.use-case.js +5 -19
  473. package/dist/services/workspaces/use-cases/list-workspace-items.use-case.mjs +5 -14
  474. package/dist/services/workspaces/use-cases/save-workspace-item.use-case.d.ts +4 -6
  475. package/dist/services/workspaces/use-cases/save-workspace-item.use-case.js +10 -24
  476. package/dist/services/workspaces/use-cases/save-workspace-item.use-case.mjs +10 -19
  477. package/dist/services/workspaces/use-cases/search-workspace-items.use-case.d.ts +6 -6
  478. package/dist/services/workspaces/use-cases/search-workspace-items.use-case.js +5 -19
  479. package/dist/services/workspaces/use-cases/search-workspace-items.use-case.mjs +5 -14
  480. package/dist/skills/call-modes.mjs +0 -1
  481. package/dist/skills/runtime-context.mjs +0 -1
  482. package/dist/skills/shared/shared-rules.mjs +0 -1
  483. package/dist/skills/skill.js +1 -2
  484. package/dist/skills/skill.mjs +1 -3
  485. package/dist/tools/core/call-ai/call-ai.skill.mjs +0 -1
  486. package/dist/tools/core/call-ai/call-ai.tool.mjs +0 -1
  487. package/dist/tools/core/slack/send-slack-message.tool.mjs +0 -1
  488. package/dist/tools/core/web-search/web-search.tool.mjs +0 -1
  489. package/dist/tools/tool.mjs +0 -1
  490. package/docs/agent.md +1 -1
  491. package/docs/authentication.md +95 -16
  492. package/docs/authorization.md +1 -1
  493. package/docs/automations.md +29 -11
  494. package/docs/chats.md +1 -1
  495. package/docs/configuration.md +1 -2
  496. package/docs/integration-guide.md +2 -2
  497. package/docs/mcp-servers.md +85 -2
  498. package/docs/usage.md +5 -5
  499. package/docs/users.md +1 -1
  500. package/examples/authentication/login.ts +1 -1
  501. package/examples/automations/create-automation.ts +1 -1
  502. package/examples/automations/create-event-automation.ts +2 -2
  503. package/examples/automations/list-automation-runs.ts +2 -2
  504. package/examples/automations/list-automations.ts +1 -1
  505. package/examples/automations/preview-automation-runs.ts +1 -1
  506. package/examples/automations/receive-automation-event.ts +1 -1
  507. package/examples/automations/revoke-automation-event-token.ts +2 -2
  508. package/examples/automations/run-automation-worker.ts +8 -0
  509. package/examples/automations/update-automation.ts +2 -2
  510. package/examples/chats/get-chat-by-id.ts +2 -2
  511. package/examples/chats/list-autonomous-chats.ts +1 -1
  512. package/examples/chats/list-chats.ts +1 -1
  513. package/examples/mcps/create-mcp.ts +1 -0
  514. package/examples/mcps/decide-mcp.ts +3 -3
  515. package/examples/mcps/internal-mcp-admin.ts +43 -0
  516. package/examples/mcps/internal-mcp.ts +14 -3
  517. package/examples/mcps/list-all-mcps.ts +1 -1
  518. package/examples/mcps/update-mcp.ts +1 -1
  519. package/examples/mcps/verify-mcp.ts +1 -1
  520. package/examples/usage/get-chat-usage.ts +2 -2
  521. package/examples/usage/get-message-usage.ts +2 -2
  522. package/examples/usage/get-usage-stats-by-range.ts +1 -1
  523. package/examples/usage/get-usage-stats.ts +3 -3
  524. package/examples/users/set-default-model.ts +1 -1
  525. package/package.json +6 -4
  526. package/dist/chunk-CF3WOMB3.mjs +0 -16
  527. package/dist/common/base/utils/delete-empty-fields.d.ts +0 -1
  528. package/dist/common/base/utils/delete-empty-fields.js +0 -66
  529. package/dist/common/base/utils/delete-empty-fields.mjs +0 -43
  530. package/dist/common/base/utils/flatten-object.d.ts +0 -1
  531. package/dist/common/base/utils/flatten-object.mjs +0 -22
  532. package/dist/common/decorators/index.d.ts +0 -1
  533. package/dist/common/decorators/index.mjs +0 -1
  534. package/dist/common/decorators/mask-in-logs/index.d.ts +0 -1
  535. package/dist/common/decorators/mask-in-logs/index.mjs +0 -1
  536. package/dist/common/decorators/mask-in-logs/mask-in-logs.d.ts +0 -2
  537. package/dist/common/decorators/mask-in-logs/mask-in-logs.js +0 -53
  538. package/dist/common/decorators/mask-in-logs/mask-in-logs.mjs +0 -29
package/CHANGELOG.md CHANGED
@@ -2,6 +2,61 @@
2
2
 
3
3
  All notable changes to `openloops` are written here, newest first. The format follows [Keep a Changelog](https://keepachangelog.com) and the versions follow [semantic versioning](https://semver.org), where a minor version can still break the API while the package is in beta. Changes before 0.4.0 are not recorded here, see the commits and the tags.
4
4
 
5
+ ## Unreleased
6
+
7
+ This version breaks the API of the internal MCP servers in automations. Before, the runner sent one token for the whole deployment, from `INTERNAL_MCP_TOKEN`. Now each internal server declares its own. To migrate: delete `INTERNAL_MCP_TOKEN` and, in each internal server that used `{{token}}` in automations, add `autonomousToken: process.env.<YOUR_VARIABLE>` with the token of the service account that it needs. Read [automations](docs/automations.md#internal-mcp-servers-in-an-automation).
8
+
9
+ ### Added
10
+
11
+ - **Internal MCP servers stored in the database**, managed from a back office. `createInternalMcp`, `updateInternalMcp`, `getInternalMcpById`, `listInternalMcps` and `deleteInternalMcp` in the new entry point `openloops/mcps/admin`, all for admins only. The agent loads the enabled ones in every run next to the ones declared in code, with the same rules: trusted, no manifest review, destructive tools still ask. `{{token}}` in a header uses the token of the run, a token written in the header is sent as it is. Read [MCP servers](docs/mcp-servers.md#internal-servers-stored-in-the-database).
12
+ - `internal` and `enabled` in `McpServerProps`. A record without them is a normal server, so no migration is needed.
13
+ - A unique index on the name of the internal servers: run `ensureIndexes`.
14
+ - `autonomousToken` in the internal MCP servers, declared in code (`InternalMcp`) or stored (`createInternalMcp` and `updateInternalMcp`). It is the token of a service account, used for `{{token}}` only in an autonomous run that brings no token for that server, and then the agent sends the id of the user in `X-User-Id`. An interactive run never uses it. It is temporary, until the integrations give the runner the token of the owner.
15
+ - `environment` in `McpServerProps`, an optional text for every MCP server, internal or not, to say which environment it belongs to. It is only a label. The functions of `openloops/mcps` and of `openloops/mcps/admin` accept it, and a blank text removes it.
16
+
17
+ ### Removed
18
+
19
+ - `INTERNAL_MCP_TOKEN` and the `serviceToken` parameter of `Agent.run`. Use `autonomousToken` in each internal MCP server.
20
+
21
+ ### Changed
22
+
23
+ - The functions of `openloops/mcps` never see an internal server, not even for an admin, and ignore `internal` and `enabled` in the payload of a user.
24
+ - `listMcpServersByUser` failed because it sent no scope to the repository, now it lists the servers of the user.
25
+ - The connection errors of an internal server mask the values of its headers in the logs.
26
+
27
+ ## 0.7.0
28
+
29
+ This version breaks the API of the entities, of the repository, of the results of the use cases and of the authentication, and removes `tsyringe`. The tokens that 0.6 issued (logins and event automations) stop working: issue new ones. Read [authentication](docs/authentication.md). The parameters of the use cases do not change, except for `updateChat`, which accepts `unset`.
30
+
31
+ ### Added
32
+
33
+ - **Sessions with refresh.** `refreshSession`, `logout` and `revokeUserSessions` in `openloops/authentication`, and the collection `refresh_tokens` (the index is created by `ensureIndexes`). The refresh token rotates in each use, a token that is used again after 10 seconds closes the whole session, and a session ends at 90 days at most (7 for an admin).
34
+ - **Password reset.** `issuePasswordResetToken` and `resetPassword` in `openloops/authentication`, and `changePassword` in `openloops/users`, which closes the other sessions. The package does not send the email, and does not limit the attempts: your backend does both.
35
+ - `verifySessionToken`, `signToken`, `verifyToken`, `TokenError` and the audiences, to read the tokens in your backend.
36
+ - `MongoRepository.patchOne`, `archiveByPatch` and `claimOne`. `patchOne` takes `set` and `unset` (paths with dots), stamps who and when, drops the paths of control of a user scope, never writes `_id`, `__v`, `createdAt` nor `createdBy`, and accepts `expectedVersion` to detect conflicts. `claimOne` gives back the document as it was before the change.
37
+ - `softDelete` accepts `unset`.
38
+ - `toPatch` and `entityPatch` in `@common/base/utils`: the first turns an object into `set` and `unset` (a `null` or a blank text removes the field), the second adds the `clearedFields` of an entity.
39
+ - `clearedFields` in `Chat`, `Automation` and `User`, for the fields that an entity removes from the stored document.
40
+ - `updateChat` accepts `unset`, with the paths to remove.
41
+
42
+ ### Changed
43
+
44
+ - **One convention for every token.** They are signed with `HS256`, carry `iss: openloops`, an `aud` (`session`, `password-reset` or `automation-event`) and `sub`, and are refused if any of them is wrong. The tokens of event automations follow it too.
45
+ - **`login` gives `{ accessToken, refreshToken, expiresIn, refreshExpiresAt, user }`**, not `{ token, user }`. The access token lasts 1 hour for everyone. An unknown user and a wrong password fail with the same 401 (`{{invalid_credentials}}`), before it was 404 and 401.
46
+ - `revokeToken` answers `true` the first time and `false` if the `jti` was already revoked, and not the record.
47
+ - `updateUser` refuses a `password` (400): use `changePassword`.
48
+ - **The use cases and the functions of the services return the result itself, no longer `{ data }`.** `const { data } = await getChatById(...)` becomes `const chat = await getChatById(...)`. The lists return `{ items, hasMore }` (`hasMore` is always there), the functions that delete return the record, or `{ deletedCount }` on a hard delete, and `execute` does not return an `HttpError` anymore: it throws. `BaseUseCaseOutput` is gone. `Agent.run` and the tools are not affected, they still use `{ data, error }` and `{ data }`.
49
+ - A getter that finds nothing answers `null`, also `getChatById`, which answered `{}`.
50
+ - `BaseEntity` is the one with `toJSON` only. Its static `toDate` and `toNumber` are public, an invalid id, date or number is a 400 `HttpError` and not a plain `Error`, and `toText` answers `undefined` for a blank text (it answered `''`).
51
+ - The repositories save with `patchOne`, so a text that is blank inside a document is removed and not stored as `''`, and the inserts and the patches ignore the `undefined` values, also inside arrays.
52
+ - The use cases take their repositories as default parameters of the constructor (`new XUseCase(repository)` still works).
53
+
54
+ ### Removed
55
+
56
+ - `tsyringe`, `reflect-metadata`, the `MaskInLogs` decorator and `BaseUseCaseOutput`.
57
+ - `toDocument`, `toFlatDocument`, `toUnset`, `unset`, `setId`, `setDefaults`, `stringify` and `clean` of `BaseEntity`, and the `Document` type.
58
+ - `MongoRepository.updateOne`, replaced by `patchOne`.
59
+
5
60
  ## 0.6.0
6
61
 
7
62
  This version breaks the API of the use cases. The functions that read or write the records of a user need the `currentUser` or a `scope` (login, the tokens, the preview of runs, the events and the functions of the runner do not), creating a record takes its owner from the scope and not from the payload, and the ownership of the records is checked by the repository. Follow the [migration steps](docs/authorization.md#migrating-from-05) when you update.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # openloops
2
2
 
3
- **Build production-grade enterprise agents in minutes, not days, weeks, or months.**
3
+ **Build production-grade enterprise agents in minutes, not days, weeks, or months.** · [openloops.xyz](https://openloops.xyz)
4
4
 
5
5
  `openloops` is an open source **harness** for AI agents. An agent is three things: a **model** that thinks (the engine), a **harness** that gives it hands, memory and rules (the chassis), and a **loop** that decides what it is for (the body). `openloops` is the harness, and it ships the loop. Change the model, or the loop, and the rest stays the same.
6
6
 
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  import { Langfuse } from "langfuse";
3
2
  import { secretManager } from "../../common/utils/secret-manager.js";
4
3
  import { Logger } from "../../common/logger/index.js";
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  const USER_MESSAGES = {
3
2
  LLM_RATE_LIMITED: "The model is receiving too many requests right now. Please try again in a few seconds.",
4
3
  LLM_QUOTA_EXCEEDED: "The usage quota of the model provider has been exhausted. Please check the plan and billing of the provider.",
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  const SELECTABLE_THINKING_EFFORTS = ["low", "medium", "high"];
3
2
  const isSelectableThinkingEffort = (value) => SELECTABLE_THINKING_EFFORTS.includes(value);
4
3
  export {
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  import { secretManager } from "../../common/utils/secret-manager.js";
3
2
  import { logger } from "../../common/logger/index.js";
4
3
  const CLIENT_FALLBACK_MODEL = { provider: "anthropic", model: "claude-haiku-5-5" };
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  const ZERO_USAGE = {
3
2
  input: 0,
4
3
  output: 0,
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  const NO_TEMPERATURE = [
3
2
  { provider: "amazon-bedrock", model: /claude/, withThinking: true }
4
3
  ];
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  import { Logger } from "../../common/logger/index.js";
3
2
  import { secretManager } from "../../common/utils/secret-manager.js";
4
3
  class SerperClient {
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  import { secretManager } from "../../common/utils/secret-manager.js";
3
2
  class SlackClient {
4
3
  async sendMessage({ channel, text }) {
@@ -6,7 +6,7 @@ export declare abstract class BaseApp {
6
6
  secretManager: import("../utils/secret-manager.js").SecretManager;
7
7
  reportError: (error: Error | HttpError | string, details?: object) => Promise<void>;
8
8
  onCatch(error: Error): Promise<void>;
9
- throwHttpError(error: HttpErrorProps): void;
10
- throwError401(currentSession?: CurrentSessionProps): void;
11
- throwError403(currentSession?: CurrentSessionProps): void;
9
+ throwHttpError(error: HttpErrorProps): never;
10
+ throwError401(currentSession?: CurrentSessionProps): never;
11
+ throwError403(currentSession?: CurrentSessionProps): never;
12
12
  }
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  import { Logger } from "../logger/index.js";
3
2
  import { reportError } from "../error/index.js";
4
3
  import { HttpError } from "../error/index.js";
@@ -1,4 +1,3 @@
1
- import 'reflect-metadata';
2
1
  import { ObjectId } from 'bson';
3
2
  import { Share, ShareProps } from './share';
4
3
  export interface BaseEntityProps {
@@ -15,10 +14,6 @@ export interface BaseEntityProps {
15
14
  archivedAt?: string | Date;
16
15
  archivedBy?: string | ObjectId;
17
16
  sharedWith?: ShareProps[];
18
- toUnset?: Record<string, unknown>;
19
- }
20
- export interface Document extends BaseEntityProps {
21
- toUnset?: Record<string, unknown>;
22
17
  }
23
18
  export declare class BaseEntity {
24
19
  _id?: ObjectId;
@@ -34,17 +29,10 @@ export declare class BaseEntity {
34
29
  archivedAt?: Date;
35
30
  archivedBy?: ObjectId;
36
31
  sharedWith?: Share[];
37
- toUnset?: Record<string, unknown>;
38
32
  static toObjectId(id?: string | ObjectId): ObjectId | undefined;
39
- private static toDate;
40
- private static toNumber;
41
- static clean(json: any): any;
33
+ static toText(value?: string): string | undefined;
34
+ static toDate(value?: string | Date): Date | undefined;
35
+ static toNumber(value?: number): number | undefined;
42
36
  constructor(props: BaseEntityProps);
43
- toJSON(): Document;
44
- setDefaults(): void;
45
- setId(id: string | ObjectId): void;
46
- toDocument(): Document;
47
- toFlatDocument(): Document;
48
- stringify(): string;
49
- unset(fields: (keyof this)[]): {} | undefined;
37
+ toJSON(): BaseEntityProps;
50
38
  }
@@ -21,11 +21,9 @@ __export(base_entity_exports, {
21
21
  BaseEntity: () => BaseEntity
22
22
  });
23
23
  module.exports = __toCommonJS(base_entity_exports);
24
- var import_reflect_metadata = require("reflect-metadata");
25
24
  var import_bson = require("bson");
26
- var import_decorators = require("../decorators/index.js");
25
+ var import_error = require("../error/index.js");
27
26
  var import_helpers = require("../helpers/index.js");
28
- var import_utils = require("./utils");
29
27
  var import_share = require("./share");
30
28
  class BaseEntity {
31
29
  _id;
@@ -41,27 +39,28 @@ class BaseEntity {
41
39
  archivedAt;
42
40
  archivedBy;
43
41
  sharedWith;
44
- toUnset;
45
42
  static toObjectId(id) {
46
43
  if (!id) return void 0;
47
44
  if (id instanceof import_bson.ObjectId) return id;
48
- if (!import_bson.ObjectId.isValid(id)) throw new Error(`Invalid ObjectId: ${id}`);
45
+ if (!import_bson.ObjectId.isValid(id)) throw new import_error.HttpError({ statusCode: 400, errorMessage: "{{invalid_object_id}}", errorDetails: { id } });
49
46
  return new import_bson.ObjectId(id);
50
47
  }
48
+ static toText(value) {
49
+ if (value === void 0 || value === null) return void 0;
50
+ if (typeof value !== "string") throw new import_error.HttpError({ statusCode: 400, errorMessage: "{{value_must_be_a_string}}" });
51
+ return (0, import_helpers.sanitizeString)(value.trim()) || void 0;
52
+ }
51
53
  static toDate(value) {
52
54
  if (!value) return void 0;
53
55
  const date = new Date(value);
54
- if (isNaN(date.getTime())) throw new Error("{{value_must_be_a_date}}");
56
+ if (isNaN(date.getTime())) throw new import_error.HttpError({ statusCode: 400, errorMessage: "{{value_must_be_a_date}}" });
55
57
  return date;
56
58
  }
57
59
  static toNumber(value) {
58
60
  if (value === void 0 || value === null) return void 0;
59
- if (typeof value !== "number") throw new Error("{{value_must_be_a_number}}");
61
+ if (typeof value !== "number") throw new import_error.HttpError({ statusCode: 400, errorMessage: "{{value_must_be_a_number}}" });
60
62
  return value;
61
63
  }
62
- static clean(json) {
63
- return (0, import_utils.deleteEmptyFields)(json);
64
- }
65
64
  constructor(props) {
66
65
  this._id = BaseEntity.toObjectId(props._id);
67
66
  this.__v = BaseEntity.toNumber(props.__v);
@@ -72,7 +71,7 @@ class BaseEntity {
72
71
  this.updatedBy = BaseEntity.toObjectId(props.updatedBy);
73
72
  this.deletedAt = BaseEntity.toDate(props.deletedAt);
74
73
  this.deletedBy = BaseEntity.toObjectId(props.deletedBy);
75
- this.deletedReason = (0, import_helpers.sanitizeString)(props.deletedReason);
74
+ this.deletedReason = BaseEntity.toText(props.deletedReason);
76
75
  this.archivedAt = BaseEntity.toDate(props.archivedAt);
77
76
  this.archivedBy = BaseEntity.toObjectId(props.archivedBy);
78
77
  this.sharedWith = (0, import_share.createShares)(props.sharedWith);
@@ -91,36 +90,9 @@ class BaseEntity {
91
90
  deletedReason: this.deletedReason,
92
91
  archivedAt: this.archivedAt,
93
92
  archivedBy: this.archivedBy,
94
- sharedWith: this.sharedWith?.length ? this.sharedWith : void 0,
95
- toUnset: this.toUnset
93
+ sharedWith: this.sharedWith?.length ? this.sharedWith : void 0
96
94
  };
97
95
  }
98
- setDefaults() {
99
- }
100
- setId(id) {
101
- this._id = BaseEntity.toObjectId(id);
102
- }
103
- toDocument() {
104
- return (0, import_utils.deleteEmptyFields)(this.toJSON());
105
- }
106
- toFlatDocument() {
107
- const { toUnset, ...doc } = this.toDocument();
108
- return { ...(0, import_utils.flattenObject)(doc), toUnset };
109
- }
110
- stringify() {
111
- return JSON.stringify((0, import_decorators.handleMaskInLogs)(this), null, 2);
112
- }
113
- unset(fields) {
114
- const toUnset = Array.from(new Set(fields.map((field) => String(field))));
115
- if (!toUnset || !Array.isArray(toUnset)) return {};
116
- this.toUnset = toUnset.reduce((acc, field) => {
117
- acc[field] = "";
118
- return acc;
119
- }, {});
120
- fields.forEach((field) => {
121
- delete this[field];
122
- });
123
- }
124
96
  }
125
97
  // Annotate the CommonJS export names for ESM import in node:
126
98
  0 && (module.exports = {
@@ -1,9 +1,6 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
- import "reflect-metadata";
3
1
  import { ObjectId } from "bson";
4
- import { handleMaskInLogs } from "../decorators/index.js";
2
+ import { HttpError } from "../error/index.js";
5
3
  import { sanitizeString } from "../helpers/index.js";
6
- import { deleteEmptyFields, flattenObject } from "./utils";
7
4
  import { createShares } from "./share";
8
5
  class BaseEntity {
9
6
  _id;
@@ -19,27 +16,28 @@ class BaseEntity {
19
16
  archivedAt;
20
17
  archivedBy;
21
18
  sharedWith;
22
- toUnset;
23
19
  static toObjectId(id) {
24
20
  if (!id) return void 0;
25
21
  if (id instanceof ObjectId) return id;
26
- if (!ObjectId.isValid(id)) throw new Error(`Invalid ObjectId: ${id}`);
22
+ if (!ObjectId.isValid(id)) throw new HttpError({ statusCode: 400, errorMessage: "{{invalid_object_id}}", errorDetails: { id } });
27
23
  return new ObjectId(id);
28
24
  }
25
+ static toText(value) {
26
+ if (value === void 0 || value === null) return void 0;
27
+ if (typeof value !== "string") throw new HttpError({ statusCode: 400, errorMessage: "{{value_must_be_a_string}}" });
28
+ return sanitizeString(value.trim()) || void 0;
29
+ }
29
30
  static toDate(value) {
30
31
  if (!value) return void 0;
31
32
  const date = new Date(value);
32
- if (isNaN(date.getTime())) throw new Error("{{value_must_be_a_date}}");
33
+ if (isNaN(date.getTime())) throw new HttpError({ statusCode: 400, errorMessage: "{{value_must_be_a_date}}" });
33
34
  return date;
34
35
  }
35
36
  static toNumber(value) {
36
37
  if (value === void 0 || value === null) return void 0;
37
- if (typeof value !== "number") throw new Error("{{value_must_be_a_number}}");
38
+ if (typeof value !== "number") throw new HttpError({ statusCode: 400, errorMessage: "{{value_must_be_a_number}}" });
38
39
  return value;
39
40
  }
40
- static clean(json) {
41
- return deleteEmptyFields(json);
42
- }
43
41
  constructor(props) {
44
42
  this._id = BaseEntity.toObjectId(props._id);
45
43
  this.__v = BaseEntity.toNumber(props.__v);
@@ -50,7 +48,7 @@ class BaseEntity {
50
48
  this.updatedBy = BaseEntity.toObjectId(props.updatedBy);
51
49
  this.deletedAt = BaseEntity.toDate(props.deletedAt);
52
50
  this.deletedBy = BaseEntity.toObjectId(props.deletedBy);
53
- this.deletedReason = sanitizeString(props.deletedReason);
51
+ this.deletedReason = BaseEntity.toText(props.deletedReason);
54
52
  this.archivedAt = BaseEntity.toDate(props.archivedAt);
55
53
  this.archivedBy = BaseEntity.toObjectId(props.archivedBy);
56
54
  this.sharedWith = createShares(props.sharedWith);
@@ -69,36 +67,9 @@ class BaseEntity {
69
67
  deletedReason: this.deletedReason,
70
68
  archivedAt: this.archivedAt,
71
69
  archivedBy: this.archivedBy,
72
- sharedWith: this.sharedWith?.length ? this.sharedWith : void 0,
73
- toUnset: this.toUnset
70
+ sharedWith: this.sharedWith?.length ? this.sharedWith : void 0
74
71
  };
75
72
  }
76
- setDefaults() {
77
- }
78
- setId(id) {
79
- this._id = BaseEntity.toObjectId(id);
80
- }
81
- toDocument() {
82
- return deleteEmptyFields(this.toJSON());
83
- }
84
- toFlatDocument() {
85
- const { toUnset, ...doc } = this.toDocument();
86
- return { ...flattenObject(doc), toUnset };
87
- }
88
- stringify() {
89
- return JSON.stringify(handleMaskInLogs(this), null, 2);
90
- }
91
- unset(fields) {
92
- const toUnset = Array.from(new Set(fields.map((field) => String(field))));
93
- if (!toUnset || !Array.isArray(toUnset)) return {};
94
- this.toUnset = toUnset.reduce((acc, field) => {
95
- acc[field] = "";
96
- return acc;
97
- }, {});
98
- fields.forEach((field) => {
99
- delete this[field];
100
- });
101
- }
102
73
  }
103
74
  export {
104
75
  BaseEntity
@@ -1,5 +1,4 @@
1
1
  import { CurrentUser, CurrentSession } from './index.js';
2
- import { HttpError } from '../error/index.js';
3
2
  import { Scope } from '../repositories/index.js';
4
3
  import { BaseApp } from './base.app';
5
4
  export interface BaseUseCaseParams {
@@ -7,11 +6,6 @@ export interface BaseUseCaseParams {
7
6
  currentSession?: CurrentSession;
8
7
  scope?: Scope;
9
8
  }
10
- export interface BaseUseCaseOutput {
11
- message?: string;
12
- data?: any;
13
- error?: any;
14
- }
15
9
  export declare abstract class BaseUseCase<TReq, TRes> extends BaseApp {
16
- abstract execute(params?: TReq): Promise<TRes | HttpError>;
10
+ abstract execute(params?: TReq): Promise<TRes>;
17
11
  }
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  import { BaseApp } from "./base.app";
3
2
  class BaseUseCase extends BaseApp {
4
3
  }
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  import { getCountry, getTimezone } from "iso-data";
3
2
  class CurrentSession {
4
3
  constructor(clientType, environment, app, device, preferences, location, request) {
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  import { ObjectId } from "mongodb";
3
2
  import { getTimezone } from "iso-data";
4
3
  import { getMongoDBClient } from "../repositories/mongo-db.client.js";
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  import { ObjectId } from "bson";
3
2
  const SHARE_PERMISSIONS = ["read", "write", "manage"];
4
3
  const createShares = (props) => {
@@ -1,3 +1,2 @@
1
- export * from './delete-empty-fields';
2
1
  export * from './is-plain-object';
3
- export * from './flatten-object';
2
+ export * from './to-patch';
@@ -15,12 +15,10 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
15
15
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
16
  var utils_exports = {};
17
17
  module.exports = __toCommonJS(utils_exports);
18
- __reExport(utils_exports, require("./delete-empty-fields"), module.exports);
19
18
  __reExport(utils_exports, require("./is-plain-object"), module.exports);
20
- __reExport(utils_exports, require("./flatten-object"), module.exports);
19
+ __reExport(utils_exports, require("./to-patch"), module.exports);
21
20
  // Annotate the CommonJS export names for ESM import in node:
22
21
  0 && (module.exports = {
23
- ...require("./delete-empty-fields"),
24
22
  ...require("./is-plain-object"),
25
- ...require("./flatten-object")
23
+ ...require("./to-patch")
26
24
  });
@@ -1,3 +1,2 @@
1
- export * from "./delete-empty-fields";
2
1
  export * from "./is-plain-object";
3
- export * from "./flatten-object";
2
+ export * from "./to-patch";
@@ -1,4 +1,3 @@
1
- import "../../../chunk-CF3WOMB3.mjs";
2
1
  function isPlainObject(value) {
3
2
  if (typeof value !== "object" || value === null) return false;
4
3
  const proto = Object.getPrototypeOf(value);
@@ -0,0 +1,9 @@
1
+ export interface Patch {
2
+ set: Record<string, unknown>;
3
+ unset: Record<string, unknown>;
4
+ }
5
+ export declare function toPatch(obj: unknown, parentKey?: string, patch?: Patch): Patch;
6
+ export declare function entityPatch(entity: {
7
+ toJSON(): unknown;
8
+ clearedFields?: Record<string, ''>;
9
+ }): Patch;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var to_patch_exports = {};
20
+ __export(to_patch_exports, {
21
+ entityPatch: () => entityPatch,
22
+ toPatch: () => toPatch
23
+ });
24
+ module.exports = __toCommonJS(to_patch_exports);
25
+ var import_is_plain_object = require("./is-plain-object");
26
+ function toPatch(obj, parentKey = "", patch = { set: {}, unset: {} }) {
27
+ if (!(0, import_is_plain_object.isPlainObject)(obj)) return patch;
28
+ for (const [key, value] of Object.entries(obj)) {
29
+ const path = parentKey ? `${parentKey}.${key}` : key;
30
+ if (value === void 0) continue;
31
+ if (value === null || typeof value === "string" && !value.trim()) patch.unset[path] = "";
32
+ else if ((0, import_is_plain_object.isPlainObject)(value)) toPatch(value, path, patch);
33
+ else patch.set[path] = value;
34
+ }
35
+ return patch;
36
+ }
37
+ function entityPatch(entity) {
38
+ const patch = toPatch(entity.toJSON());
39
+ const unset = Object.fromEntries(Object.entries({ ...patch.unset, ...entity.clearedFields }).filter(([path]) => !(path in patch.set)));
40
+ return { set: patch.set, unset };
41
+ }
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ entityPatch,
45
+ toPatch
46
+ });
@@ -0,0 +1,21 @@
1
+ import { isPlainObject } from "./is-plain-object";
2
+ function toPatch(obj, parentKey = "", patch = { set: {}, unset: {} }) {
3
+ if (!isPlainObject(obj)) return patch;
4
+ for (const [key, value] of Object.entries(obj)) {
5
+ const path = parentKey ? `${parentKey}.${key}` : key;
6
+ if (value === void 0) continue;
7
+ if (value === null || typeof value === "string" && !value.trim()) patch.unset[path] = "";
8
+ else if (isPlainObject(value)) toPatch(value, path, patch);
9
+ else patch.set[path] = value;
10
+ }
11
+ return patch;
12
+ }
13
+ function entityPatch(entity) {
14
+ const patch = toPatch(entity.toJSON());
15
+ const unset = Object.fromEntries(Object.entries({ ...patch.unset, ...entity.clearedFields }).filter(([path]) => !(path in patch.set)));
16
+ return { set: patch.set, unset };
17
+ }
18
+ export {
19
+ entityPatch,
20
+ toPatch
21
+ };
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  const DEFAULT_MAX_INPUT_LENGTH = 1e5;
3
2
  const SIGNATURE = "YkhwMWFpNTJiMjV1TG1OMGVHd3ZhWFppYUM1eGVXWnhMbXQyWTNRdmVXcHhkeTU2YkdwaExubHlkWGM9";
4
3
  const GUARD_FAILURE_REPLY = "The request could not be processed.";
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  class HttpError {
3
2
  statusCode;
4
3
  errorMessage;
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  import { sentryClient } from "./sentry-client";
3
2
  import { HttpError } from "./http-error";
4
3
  import { logger } from "../logger";
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  import * as Sentry from "@sentry/node";
3
2
  import { logger } from "../logger";
4
3
  import { secretManager } from "../utils/secret-manager.js";
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  function escapeRegex(input = "") {
3
2
  return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4
3
  }
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  function extractJSON(plainText) {
3
2
  if (!plainText) {
4
3
  return {};
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  import sanitizeHtml from "sanitize-html";
3
2
  function sanitizeString(input = "") {
4
3
  if (!input) return void 0;
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  import "dotenv/config";
3
2
  import pino from "pino";
4
3
  import pretty from "pino-pretty";
@@ -1,4 +1,3 @@
1
- import "../../chunk-CF3WOMB3.mjs";
2
1
  import {
3
2
  MongoClient as BaseMongoCLient
4
3
  } from "mongodb";
@@ -1,5 +1,5 @@
1
1
  import { ObjectId } from 'mongodb';
2
- import { Document } from '../base/base.entity.js';
2
+ import type { BaseEntityProps } from '../base/base.entity.js';
3
3
  import { Scope } from './scope';
4
4
  export declare class VersionConflictError extends Error {
5
5
  readonly code = "VERSION_CONFLICT";
@@ -40,12 +40,16 @@ export declare class MongoRepository<T> {
40
40
  }>;
41
41
  private query;
42
42
  findAll({ where, select, options, scope }: QueryParams<T>): Promise<T[]>;
43
- createOne({ payload, scope }: CommandParams<T>): Promise<Document & {
43
+ createOne({ payload, scope }: CommandParams<T>): Promise<BaseEntityProps & {
44
44
  _id: ObjectId;
45
45
  }>;
46
46
  createMany({ payload, scope }: CommandParams<T>): Promise<CreateManyResponse>;
47
- updateOne({ where, payload, expectedVersion, scope }: CommandParams<T>): Promise<T>;
48
- softDelete({ where, payload, scope }: CommandParams<T>): Promise<T | null>;
47
+ patchOne({ where, set, unset, expectedVersion, scope }: PatchParams<T>): Promise<T | null>;
48
+ archiveByPatch(params: PatchParams<T>): Promise<T | null>;
49
+ private applyPatch;
50
+ claimOne({ where, set, scope }: PatchParams<T>): Promise<T | null>;
51
+ private withoutProtectedPaths;
52
+ softDelete({ where, payload, unset, scope }: CommandParams<T>): Promise<T | null>;
49
53
  private modifyOne;
50
54
  updateMany({ where, payload, scope }: CommandParams<T>): Promise<number>;
51
55
  deleteOne({ where, scope }: CommandParams<T>): Promise<number>;
@@ -112,7 +116,14 @@ export interface CommandParams<T> {
112
116
  scope?: Scope;
113
117
  where?: Partial<T>;
114
118
  payload?: Partial<T> | Partial<T>[];
119
+ unset?: Record<string, unknown>;
115
120
  options?: Record<string, unknown>;
121
+ }
122
+ export interface PatchParams<T> {
123
+ scope?: Scope;
124
+ where?: Partial<T>;
125
+ set?: Record<string, unknown>;
126
+ unset?: Record<string, unknown>;
116
127
  expectedVersion?: number;
117
128
  }
118
129
  export {};