openloops 0.1.9 → 0.1.10
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.
- package/dist/chunk-XRJFNASX.mjs +14 -0
- package/dist/common/clients/index.d.ts +3 -0
- package/dist/common/clients/index.js +26 -0
- package/dist/common/clients/index.mjs +3 -0
- package/dist/common/clients/llm-client.d.ts +30 -0
- package/dist/common/clients/llm-client.js +159 -0
- package/dist/common/clients/llm-client.mjs +126 -0
- package/dist/common/clients/sentry-client.d.ts +10 -0
- package/dist/common/clients/sentry-client.js +87 -0
- package/dist/common/clients/sentry-client.mjs +53 -0
- package/dist/common/clients/serper-client.d.ts +66 -0
- package/dist/common/clients/serper-client.js +74 -0
- package/dist/common/clients/serper-client.mjs +41 -0
- package/dist/common/core/base.app.d.ts +12 -0
- package/dist/common/core/base.app.js +57 -0
- package/dist/common/core/base.app.mjs +34 -0
- package/dist/common/core/base.entity.d.ts +55 -0
- package/dist/common/core/base.entity.js +208 -0
- package/dist/common/core/base.entity.mjs +179 -0
- package/dist/common/core/base.use-case.d.ts +15 -0
- package/dist/common/core/base.use-case.js +30 -0
- package/dist/common/core/base.use-case.mjs +7 -0
- package/dist/common/core/index.d.ts +1 -0
- package/dist/common/core/index.js +1 -0
- package/dist/common/core/index.mjs +0 -0
- package/dist/common/core/utils/delete-empty-fields.d.ts +1 -0
- package/dist/common/core/utils/delete-empty-fields.js +66 -0
- package/dist/common/core/utils/delete-empty-fields.mjs +43 -0
- package/dist/common/core/utils/flatten-object.d.ts +1 -0
- package/dist/common/core/utils/flatten-object.js +45 -0
- package/dist/common/core/utils/flatten-object.mjs +22 -0
- package/dist/common/core/utils/index.d.ts +3 -0
- package/dist/common/core/utils/index.js +26 -0
- package/dist/common/core/utils/index.mjs +3 -0
- package/dist/common/core/utils/is-plain-object.d.ts +1 -0
- package/dist/common/core/utils/is-plain-object.js +32 -0
- package/dist/common/core/utils/is-plain-object.mjs +9 -0
- package/dist/common/decorators/admin-only/admin-only.d.ts +2 -0
- package/dist/common/decorators/admin-only/admin-only.js +52 -0
- package/dist/common/decorators/admin-only/admin-only.mjs +28 -0
- package/dist/common/decorators/admin-only/index.d.ts +1 -0
- package/dist/common/decorators/admin-only/index.js +22 -0
- package/dist/common/decorators/admin-only/index.mjs +1 -0
- package/dist/common/decorators/index.d.ts +3 -0
- package/dist/common/decorators/index.js +26 -0
- package/dist/common/decorators/index.mjs +3 -0
- package/dist/common/decorators/mask-in-logs/index.d.ts +1 -0
- package/dist/common/decorators/mask-in-logs/index.js +22 -0
- package/dist/common/decorators/mask-in-logs/index.mjs +1 -0
- package/dist/common/decorators/mask-in-logs/mask-in-logs.d.ts +2 -0
- package/dist/common/decorators/mask-in-logs/mask-in-logs.js +53 -0
- package/dist/common/decorators/mask-in-logs/mask-in-logs.mjs +29 -0
- package/dist/common/decorators/owner-only/index.d.ts +1 -0
- package/dist/common/decorators/owner-only/index.js +22 -0
- package/dist/common/decorators/owner-only/index.mjs +1 -0
- package/dist/common/decorators/owner-only/owner-only.d.ts +2 -0
- package/dist/common/decorators/owner-only/owner-only.js +52 -0
- package/dist/common/decorators/owner-only/owner-only.mjs +28 -0
- package/dist/common/error/http-error.d.ts +11 -0
- package/dist/common/error/http-error.js +37 -0
- package/dist/common/error/http-error.mjs +14 -0
- package/dist/common/error/index.d.ts +2 -0
- package/dist/common/error/index.js +24 -0
- package/dist/common/error/index.mjs +2 -0
- package/dist/common/error/reportError.d.ts +2 -0
- package/dist/common/error/reportError.js +51 -0
- package/dist/common/error/reportError.mjs +28 -0
- package/dist/common/helpers/extract-json-from-text.d.ts +1 -0
- package/dist/common/helpers/extract-json-from-text.js +63 -0
- package/dist/common/helpers/extract-json-from-text.mjs +40 -0
- package/dist/common/helpers/index.d.ts +2 -0
- package/dist/common/helpers/index.js +24 -0
- package/dist/common/helpers/index.mjs +2 -0
- package/dist/common/helpers/sanitize-string.d.ts +1 -0
- package/dist/common/helpers/sanitize-string.js +45 -0
- package/dist/common/helpers/sanitize-string.mjs +12 -0
- package/dist/common/logger/index.d.ts +1 -0
- package/dist/common/logger/index.js +22 -0
- package/dist/common/logger/index.mjs +1 -0
- package/dist/common/logger/pino.d.ts +12 -0
- package/dist/common/logger/pino.js +70 -0
- package/dist/common/logger/pino.mjs +36 -0
- package/dist/common/repositories/index.d.ts +2 -0
- package/dist/common/repositories/index.js +24 -0
- package/dist/common/repositories/index.mjs +2 -0
- package/dist/common/repositories/mongo-db.client.d.ts +11 -0
- package/dist/common/repositories/mongo-db.client.js +79 -0
- package/dist/common/repositories/mongo-db.client.mjs +57 -0
- package/dist/common/repositories/mongo-db.repository.d.ts +87 -0
- package/dist/common/repositories/mongo-db.repository.js +219 -0
- package/dist/common/repositories/mongo-db.repository.mjs +196 -0
- package/dist/common/utils/secret-manager.d.ts +15 -0
- package/dist/common/utils/secret-manager.js +105 -0
- package/dist/common/utils/secret-manager.mjs +71 -0
- package/dist/index.d.ts +1 -10
- package/dist/index.js +22 -7
- package/dist/index.mjs +1 -1
- package/dist/services/agent/core/agent-loop.d.ts +38 -0
- package/dist/services/agent/core/agent-loop.js +29 -0
- package/dist/services/agent/core/agent-loop.mjs +6 -0
- package/dist/services/agent/core/agent-state.d.ts +42 -0
- package/dist/services/agent/core/agent-state.js +102 -0
- package/dist/services/agent/core/agent-state.mjs +78 -0
- package/dist/services/agent/core/agent.d.ts +70 -0
- package/dist/services/agent/core/agent.js +351 -0
- package/dist/services/agent/core/agent.mjs +327 -0
- package/dist/services/agent/core/index.d.ts +3 -122
- package/dist/services/agent/core/index.js +26 -7
- package/dist/services/agent/core/index.mjs +3 -1
- package/dist/services/agent/loops/index.d.ts +2 -116
- package/dist/services/agent/loops/index.js +24 -10
- package/dist/services/agent/loops/index.mjs +2 -4
- package/dist/services/agent/loops/plan-execute/index.d.ts +1 -0
- package/dist/services/agent/loops/plan-execute/index.js +22 -0
- package/dist/services/agent/loops/plan-execute/index.mjs +1 -0
- package/dist/services/agent/loops/plan-execute/plan-execute-loop.d.ts +27 -0
- package/dist/services/agent/loops/plan-execute/plan-execute-loop.js +242 -0
- package/dist/services/agent/loops/plan-execute/plan-execute-loop.mjs +226 -0
- package/dist/services/agent/loops/shared/index.d.ts +1 -0
- package/dist/services/agent/loops/shared/index.js +22 -0
- package/dist/services/agent/loops/shared/index.mjs +1 -0
- package/dist/services/agent/loops/shared/skills/action-planner.d.ts +35 -0
- package/dist/services/agent/loops/shared/skills/action-planner.js +68 -0
- package/dist/services/agent/loops/shared/skills/action-planner.mjs +45 -0
- package/dist/services/agent/loops/shared/skills/confirmation-gate.d.ts +9 -0
- package/dist/services/agent/loops/shared/skills/confirmation-gate.js +53 -0
- package/dist/services/agent/loops/shared/skills/confirmation-gate.mjs +30 -0
- package/dist/services/agent/loops/shared/skills/fast-responder.d.ts +9 -0
- package/dist/services/agent/loops/shared/skills/fast-responder.js +70 -0
- package/dist/services/agent/loops/shared/skills/fast-responder.mjs +47 -0
- package/dist/services/agent/loops/shared/skills/final-responder.d.ts +7 -0
- package/dist/services/agent/loops/shared/skills/final-responder.js +57 -0
- package/dist/services/agent/loops/shared/skills/final-responder.mjs +34 -0
- package/dist/services/agent/loops/shared/skills/index.d.ts +6 -0
- package/dist/services/agent/loops/shared/skills/index.js +32 -0
- package/dist/services/agent/loops/shared/skills/index.mjs +6 -0
- package/dist/services/agent/loops/shared/skills/state-observer.d.ts +10 -0
- package/dist/services/agent/loops/shared/skills/state-observer.js +57 -0
- package/dist/services/agent/loops/shared/skills/state-observer.mjs +34 -0
- package/dist/services/agent/loops/shared/skills/strategy-engine.d.ts +15 -0
- package/dist/services/agent/loops/shared/skills/strategy-engine.js +60 -0
- package/dist/services/agent/loops/shared/skills/strategy-engine.mjs +37 -0
- package/dist/services/agent/modules/chats/entities/agent-action.entity.d.ts +58 -0
- package/dist/services/agent/modules/chats/entities/agent-action.entity.js +151 -0
- package/dist/services/agent/modules/chats/entities/agent-action.entity.mjs +128 -0
- package/dist/services/agent/modules/chats/entities/agent-task.entity.d.ts +59 -0
- package/dist/services/agent/modules/chats/entities/agent-task.entity.js +231 -0
- package/dist/services/agent/modules/chats/entities/agent-task.entity.mjs +207 -0
- package/dist/services/agent/modules/chats/entities/chat-context.entity.d.ts +39 -0
- package/dist/services/agent/modules/chats/entities/chat-context.entity.js +70 -0
- package/dist/services/agent/modules/chats/entities/chat-context.entity.mjs +47 -0
- package/dist/services/agent/modules/chats/entities/chat-message.entity.d.ts +16 -0
- package/dist/services/agent/modules/chats/entities/chat-message.entity.js +58 -0
- package/dist/services/agent/modules/chats/entities/chat-message.entity.mjs +35 -0
- package/dist/services/agent/modules/chats/entities/chat-settings.entity.d.ts +17 -0
- package/dist/services/agent/modules/chats/entities/chat-settings.entity.js +63 -0
- package/dist/services/agent/modules/chats/entities/chat-settings.entity.mjs +40 -0
- package/dist/services/agent/modules/chats/entities/chat.entity.d.ts +50 -0
- package/dist/services/agent/modules/chats/entities/chat.entity.js +163 -0
- package/dist/services/agent/modules/chats/entities/chat.entity.mjs +140 -0
- package/dist/services/agent/modules/chats/entities/index.d.ts +1 -0
- package/dist/services/agent/modules/chats/entities/index.js +22 -0
- package/dist/services/agent/modules/chats/entities/index.mjs +1 -0
- package/dist/services/agent/modules/chats/lambdas/create-chat/create-chat.use-case.d.ts +14 -0
- package/dist/services/agent/modules/chats/lambdas/create-chat/create-chat.use-case.js +56 -0
- package/dist/services/agent/modules/chats/lambdas/create-chat/create-chat.use-case.mjs +27 -0
- package/dist/services/agent/modules/chats/lambdas/create-chat/index.d.ts +1 -0
- package/dist/services/agent/modules/chats/lambdas/create-chat/index.js +22 -0
- package/dist/services/agent/modules/chats/lambdas/create-chat/index.mjs +1 -0
- package/dist/services/agent/modules/chats/lambdas/delete-chat/delete-chat.use-case.d.ts +15 -0
- package/dist/services/agent/modules/chats/lambdas/delete-chat/delete-chat.use-case.js +61 -0
- package/dist/services/agent/modules/chats/lambdas/delete-chat/delete-chat.use-case.mjs +32 -0
- package/dist/services/agent/modules/chats/lambdas/delete-chat/index.d.ts +1 -0
- package/dist/services/agent/modules/chats/lambdas/delete-chat/index.js +22 -0
- package/dist/services/agent/modules/chats/lambdas/delete-chat/index.mjs +1 -0
- package/dist/services/agent/modules/chats/lambdas/get-chat-by-id/get-chat-by-id.use-case.d.ts +14 -0
- package/dist/services/agent/modules/chats/lambdas/get-chat-by-id/get-chat-by-id.use-case.js +52 -0
- package/dist/services/agent/modules/chats/lambdas/get-chat-by-id/get-chat-by-id.use-case.mjs +23 -0
- package/dist/services/agent/modules/chats/lambdas/get-chat-by-id/index.d.ts +1 -0
- package/dist/services/agent/modules/chats/lambdas/get-chat-by-id/index.js +22 -0
- package/dist/services/agent/modules/chats/lambdas/get-chat-by-id/index.mjs +1 -0
- package/dist/services/agent/modules/chats/lambdas/interrupt-execution/index.d.ts +1 -0
- package/dist/services/agent/modules/chats/lambdas/interrupt-execution/index.js +22 -0
- package/dist/services/agent/modules/chats/lambdas/interrupt-execution/index.mjs +1 -0
- package/dist/services/agent/modules/chats/lambdas/interrupt-execution/interrupt-execution.use-case.d.ts +14 -0
- package/dist/services/agent/modules/chats/lambdas/interrupt-execution/interrupt-execution.use-case.js +64 -0
- package/dist/services/agent/modules/chats/lambdas/interrupt-execution/interrupt-execution.use-case.mjs +35 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-props/index.d.ts +1 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-props/index.js +22 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-props/index.mjs +1 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-props/list-chats-by-props.use-case.d.ts +16 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-props/list-chats-by-props.use-case.js +52 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-props/list-chats-by-props.use-case.mjs +23 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-user/index.d.ts +1 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-user/index.js +22 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-user/index.mjs +1 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-user/list-chats-by-user.use-case.d.ts +16 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-user/list-chats-by-user.use-case.js +59 -0
- package/dist/services/agent/modules/chats/lambdas/list-chats-by-user/list-chats-by-user.use-case.mjs +30 -0
- package/dist/services/agent/modules/chats/lambdas/update-chat/index.d.ts +1 -0
- package/dist/services/agent/modules/chats/lambdas/update-chat/index.js +22 -0
- package/dist/services/agent/modules/chats/lambdas/update-chat/index.mjs +1 -0
- package/dist/services/agent/modules/chats/lambdas/update-chat/update-chat.use-case.d.ts +15 -0
- package/dist/services/agent/modules/chats/lambdas/update-chat/update-chat.use-case.js +64 -0
- package/dist/services/agent/modules/chats/lambdas/update-chat/update-chat.use-case.mjs +35 -0
- package/dist/services/agent/modules/chats/repositories/chat.repository.d.ts +10 -0
- package/dist/services/agent/modules/chats/repositories/chat.repository.js +67 -0
- package/dist/services/agent/modules/chats/repositories/chat.repository.mjs +38 -0
- package/dist/services/agent/modules/chats/repositories/index.d.ts +1 -0
- package/dist/services/agent/modules/chats/repositories/index.js +22 -0
- package/dist/services/agent/modules/chats/repositories/index.mjs +1 -0
- package/dist/services/agent/modules/llmcalls/entities/index.d.ts +1 -0
- package/dist/services/agent/modules/llmcalls/entities/index.js +22 -0
- package/dist/services/agent/modules/llmcalls/entities/index.mjs +1 -0
- package/dist/services/agent/modules/llmcalls/entities/llmcall.entity.d.ts +23 -0
- package/dist/services/agent/modules/llmcalls/entities/llmcall.entity.js +71 -0
- package/dist/services/agent/modules/llmcalls/entities/llmcall.entity.mjs +48 -0
- package/dist/services/agent/modules/llmcalls/lambdas/create-llmcall/create-llmcall.use-case.d.ts +14 -0
- package/dist/services/agent/modules/llmcalls/lambdas/create-llmcall/create-llmcall.use-case.js +56 -0
- package/dist/services/agent/modules/llmcalls/lambdas/create-llmcall/create-llmcall.use-case.mjs +27 -0
- package/dist/services/agent/modules/llmcalls/lambdas/create-llmcall/index.d.ts +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/create-llmcall/index.js +22 -0
- package/dist/services/agent/modules/llmcalls/lambdas/create-llmcall/index.mjs +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/delete-llmcall/delete-llmcall.use-case.d.ts +15 -0
- package/dist/services/agent/modules/llmcalls/lambdas/delete-llmcall/delete-llmcall.use-case.js +61 -0
- package/dist/services/agent/modules/llmcalls/lambdas/delete-llmcall/delete-llmcall.use-case.mjs +32 -0
- package/dist/services/agent/modules/llmcalls/lambdas/delete-llmcall/index.d.ts +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/delete-llmcall/index.js +22 -0
- package/dist/services/agent/modules/llmcalls/lambdas/delete-llmcall/index.mjs +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llm-usage/get-llm-usage.use-case.d.ts +21 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llm-usage/get-llm-usage.use-case.js +123 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llm-usage/get-llm-usage.use-case.mjs +94 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llm-usage/index.d.ts +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llm-usage/index.js +22 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llm-usage/index.mjs +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llmcall-by-id/get-llmcall-by-id.use-case.d.ts +14 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llmcall-by-id/get-llmcall-by-id.use-case.js +52 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llmcall-by-id/get-llmcall-by-id.use-case.mjs +23 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llmcall-by-id/index.d.ts +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llmcall-by-id/index.js +22 -0
- package/dist/services/agent/modules/llmcalls/lambdas/get-llmcall-by-id/index.mjs +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/list-llmcalls-by-props/index.d.ts +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/list-llmcalls-by-props/index.js +22 -0
- package/dist/services/agent/modules/llmcalls/lambdas/list-llmcalls-by-props/index.mjs +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/list-llmcalls-by-props/list-llmcalls-by-props.use-case.d.ts +16 -0
- package/dist/services/agent/modules/llmcalls/lambdas/list-llmcalls-by-props/list-llmcalls-by-props.use-case.js +52 -0
- package/dist/services/agent/modules/llmcalls/lambdas/list-llmcalls-by-props/list-llmcalls-by-props.use-case.mjs +23 -0
- package/dist/services/agent/modules/llmcalls/lambdas/update-llmcall/index.d.ts +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/update-llmcall/index.js +22 -0
- package/dist/services/agent/modules/llmcalls/lambdas/update-llmcall/index.mjs +1 -0
- package/dist/services/agent/modules/llmcalls/lambdas/update-llmcall/update-llmcall.use-case.d.ts +15 -0
- package/dist/services/agent/modules/llmcalls/lambdas/update-llmcall/update-llmcall.use-case.js +62 -0
- package/dist/services/agent/modules/llmcalls/lambdas/update-llmcall/update-llmcall.use-case.mjs +33 -0
- package/dist/services/agent/modules/llmcalls/repositories/index.d.ts +1 -0
- package/dist/services/agent/modules/llmcalls/repositories/index.js +22 -0
- package/dist/services/agent/modules/llmcalls/repositories/index.mjs +1 -0
- package/dist/services/agent/modules/llmcalls/repositories/llmcall.repository.d.ts +10 -0
- package/dist/services/agent/modules/llmcalls/repositories/llmcall.repository.js +67 -0
- package/dist/services/agent/modules/llmcalls/repositories/llmcall.repository.mjs +38 -0
- package/dist/services/agent/modules/mcp-servers/entities/index.d.ts +1 -0
- package/dist/services/agent/modules/mcp-servers/entities/index.js +22 -0
- package/dist/services/agent/modules/mcp-servers/entities/index.mjs +1 -0
- package/dist/services/agent/modules/mcp-servers/entities/mcpserver.entity.d.ts +23 -0
- package/dist/services/agent/modules/mcp-servers/entities/mcpserver.entity.js +79 -0
- package/dist/services/agent/modules/mcp-servers/entities/mcpserver.entity.mjs +56 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/create-mcpserver/create-mcpserver.use-case.d.ts +14 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/create-mcpserver/create-mcpserver.use-case.js +56 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/create-mcpserver/create-mcpserver.use-case.mjs +27 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/create-mcpserver/index.d.ts +1 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/create-mcpserver/index.js +22 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/create-mcpserver/index.mjs +1 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/delete-mcpserver/delete-mcpserver.use-case.d.ts +15 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/delete-mcpserver/delete-mcpserver.use-case.js +61 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/delete-mcpserver/delete-mcpserver.use-case.mjs +32 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/delete-mcpserver/index.d.ts +1 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/delete-mcpserver/index.js +22 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/delete-mcpserver/index.mjs +1 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/get-mcpserver-by-id/get-mcpserver-by-id.use-case.d.ts +14 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/get-mcpserver-by-id/get-mcpserver-by-id.use-case.js +52 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/get-mcpserver-by-id/get-mcpserver-by-id.use-case.mjs +23 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/get-mcpserver-by-id/index.d.ts +1 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/get-mcpserver-by-id/index.js +22 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/get-mcpserver-by-id/index.mjs +1 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/list-mcpservers-by-user/index.d.ts +1 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/list-mcpservers-by-user/index.js +22 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/list-mcpservers-by-user/index.mjs +1 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/list-mcpservers-by-user/list-mcpservers-by-user.use-case.d.ts +16 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/list-mcpservers-by-user/list-mcpservers-by-user.use-case.js +59 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/list-mcpservers-by-user/list-mcpservers-by-user.use-case.mjs +30 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/update-mcpserver/index.d.ts +1 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/update-mcpserver/index.js +22 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/update-mcpserver/index.mjs +1 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/update-mcpserver/update-mcpserver.use-case.d.ts +15 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/update-mcpserver/update-mcpserver.use-case.js +61 -0
- package/dist/services/agent/modules/mcp-servers/lambdas/update-mcpserver/update-mcpserver.use-case.mjs +32 -0
- package/dist/services/agent/modules/mcp-servers/repositories/index.d.ts +1 -0
- package/dist/services/agent/modules/mcp-servers/repositories/index.js +22 -0
- package/dist/services/agent/modules/mcp-servers/repositories/index.mjs +1 -0
- package/dist/services/agent/modules/mcp-servers/repositories/mcpserver.repository.d.ts +10 -0
- package/dist/services/agent/modules/mcp-servers/repositories/mcpserver.repository.js +67 -0
- package/dist/services/agent/modules/mcp-servers/repositories/mcpserver.repository.mjs +38 -0
- package/dist/services/agent/skills/index.d.ts +2 -14
- package/dist/services/agent/skills/index.js +24 -7
- package/dist/services/agent/skills/index.mjs +2 -1
- package/dist/services/agent/skills/shared/index.d.ts +1 -0
- package/dist/services/agent/skills/shared/index.js +22 -0
- package/dist/services/agent/skills/shared/index.mjs +1 -0
- package/dist/services/agent/skills/shared/shared-rules.d.ts +4 -0
- package/dist/services/agent/skills/shared/shared-rules.js +37 -0
- package/dist/services/agent/skills/shared/shared-rules.mjs +11 -0
- package/dist/services/agent/skills/skill-runner.d.ts +31 -0
- package/dist/services/agent/skills/skill-runner.js +121 -0
- package/dist/services/agent/skills/skill-runner.mjs +92 -0
- package/dist/services/agent/skills/skill.d.ts +33 -0
- package/dist/services/agent/skills/skill.js +128 -0
- package/dist/services/agent/skills/skill.mjs +105 -0
- package/dist/services/agent/tools/core/call-ai/call-ai.skill.d.ts +6 -0
- package/dist/services/agent/tools/core/call-ai/call-ai.skill.js +54 -0
- package/dist/services/agent/tools/core/call-ai/call-ai.skill.mjs +31 -0
- package/dist/services/agent/tools/core/call-ai/call-ai.tool.d.ts +2 -0
- package/dist/services/agent/tools/core/call-ai/call-ai.tool.js +68 -0
- package/dist/services/agent/tools/core/call-ai/call-ai.tool.mjs +45 -0
- package/dist/services/agent/tools/core/call-ai/index.d.ts +1 -0
- package/dist/services/agent/tools/core/call-ai/index.js +22 -0
- package/dist/services/agent/tools/core/call-ai/index.mjs +1 -0
- package/dist/services/agent/tools/core/index.d.ts +2 -0
- package/dist/services/agent/tools/core/index.js +24 -0
- package/dist/services/agent/tools/core/index.mjs +2 -0
- package/dist/services/agent/tools/core/web-search/index.d.ts +1 -0
- package/dist/services/agent/tools/core/web-search/index.js +22 -0
- package/dist/services/agent/tools/core/web-search/index.mjs +1 -0
- package/dist/services/agent/tools/core/web-search/web-search.tool.d.ts +2 -0
- package/dist/services/agent/tools/core/web-search/web-search.tool.js +51 -0
- package/dist/services/agent/tools/core/web-search/web-search.tool.mjs +30 -0
- package/dist/services/agent/tools/index.d.ts +2 -12
- package/dist/services/agent/tools/index.js +24 -7
- package/dist/services/agent/tools/index.mjs +2 -1
- package/dist/{tool-DMR_ZdjP.d.ts → services/agent/tools/tool.d.ts} +7 -9
- package/dist/services/agent/tools/tool.js +57 -0
- package/dist/services/agent/tools/tool.mjs +34 -0
- package/dist/services/agent/utils/rank-tools-by-keywords.d.ts +12 -0
- package/dist/services/agent/utils/rank-tools-by-keywords.js +65 -0
- package/dist/services/agent/utils/rank-tools-by-keywords.mjs +42 -0
- package/dist/services/app/core/app.d.ts +14 -0
- package/dist/services/app/core/app.js +60 -0
- package/dist/services/app/core/app.mjs +47 -0
- package/dist/{current-session-DC-SF7rl.d.mts → services/app/core/current-session.d.ts} +4 -5
- package/dist/services/app/core/current-session.js +124 -0
- package/dist/services/app/core/current-session.mjs +104 -0
- package/dist/services/app/core/current-user.d.ts +16 -0
- package/dist/services/app/core/current-user.js +84 -0
- package/dist/services/app/core/current-user.mjs +61 -0
- package/dist/services/app/core/index.d.ts +3 -60
- package/dist/services/app/core/index.js +26 -7
- package/dist/services/app/core/index.mjs +3 -1
- package/dist/services/app/modules/authentication/lambdas/login/index.d.ts +1 -0
- package/dist/services/app/modules/authentication/lambdas/login/index.js +22 -0
- package/dist/services/app/modules/authentication/lambdas/login/index.mjs +1 -0
- package/dist/services/app/modules/authentication/lambdas/login/login.use-case.d.ts +21 -0
- package/dist/services/app/modules/authentication/lambdas/login/login.use-case.js +89 -0
- package/dist/services/app/modules/authentication/lambdas/login/login.use-case.mjs +50 -0
- package/dist/services/app/modules/users/entities/index.d.ts +1 -0
- package/dist/services/app/modules/users/entities/index.js +22 -0
- package/dist/services/app/modules/users/entities/index.mjs +1 -0
- package/dist/services/app/modules/users/entities/user-acquisition.d.ts +12 -0
- package/dist/services/app/modules/users/entities/user-acquisition.js +55 -0
- package/dist/services/app/modules/users/entities/user-acquisition.mjs +26 -0
- package/dist/services/app/modules/users/entities/user-country.d.ts +11 -0
- package/dist/services/app/modules/users/entities/user-country.js +44 -0
- package/dist/services/app/modules/users/entities/user-country.mjs +21 -0
- package/dist/services/app/modules/users/entities/user-currency.d.ts +13 -0
- package/dist/services/app/modules/users/entities/user-currency.js +44 -0
- package/dist/services/app/modules/users/entities/user-currency.mjs +21 -0
- package/dist/services/app/modules/users/entities/user-email.value-object.d.ts +6 -0
- package/dist/services/app/modules/users/entities/user-email.value-object.js +43 -0
- package/dist/services/app/modules/users/entities/user-email.value-object.mjs +20 -0
- package/dist/services/app/modules/users/entities/user-language.d.ts +11 -0
- package/dist/services/app/modules/users/entities/user-language.js +44 -0
- package/dist/services/app/modules/users/entities/user-language.mjs +21 -0
- package/dist/services/app/modules/users/entities/user-marketing.d.ts +9 -0
- package/dist/services/app/modules/users/entities/user-marketing.js +53 -0
- package/dist/services/app/modules/users/entities/user-marketing.mjs +24 -0
- package/dist/services/app/modules/users/entities/user-notification-preferences.d.ts +11 -0
- package/dist/services/app/modules/users/entities/user-notification-preferences.js +41 -0
- package/dist/services/app/modules/users/entities/user-notification-preferences.mjs +18 -0
- package/dist/services/app/modules/users/entities/user-password.value-object.d.ts +8 -0
- package/dist/services/app/modules/users/entities/user-password.value-object.js +69 -0
- package/dist/services/app/modules/users/entities/user-password.value-object.mjs +36 -0
- package/dist/services/app/modules/users/entities/user-permissions.d.ts +21 -0
- package/dist/services/app/modules/users/entities/user-permissions.js +59 -0
- package/dist/services/app/modules/users/entities/user-permissions.mjs +36 -0
- package/dist/services/app/modules/users/entities/user-preferences.d.ts +25 -0
- package/dist/services/app/modules/users/entities/user-preferences.js +69 -0
- package/dist/services/app/modules/users/entities/user-preferences.mjs +46 -0
- package/dist/services/app/modules/users/entities/user-report-preferences.d.ts +16 -0
- package/dist/services/app/modules/users/entities/user-report-preferences.js +56 -0
- package/dist/services/app/modules/users/entities/user-report-preferences.mjs +33 -0
- package/dist/services/app/modules/users/entities/user-report-schedule.d.ts +11 -0
- package/dist/services/app/modules/users/entities/user-report-schedule.js +41 -0
- package/dist/services/app/modules/users/entities/user-report-schedule.mjs +18 -0
- package/dist/services/app/modules/users/entities/user-timezone.d.ts +11 -0
- package/dist/services/app/modules/users/entities/user-timezone.js +44 -0
- package/dist/services/app/modules/users/entities/user-timezone.mjs +21 -0
- package/dist/services/app/modules/users/entities/user.entity.d.ts +41 -0
- package/dist/services/app/modules/users/entities/user.entity.js +133 -0
- package/dist/services/app/modules/users/entities/user.entity.mjs +103 -0
- package/dist/services/app/modules/users/lambdas/create-user/create-user.use-case.d.ts +14 -0
- package/dist/services/app/modules/users/lambdas/create-user/create-user.use-case.js +58 -0
- package/dist/services/app/modules/users/lambdas/create-user/create-user.use-case.mjs +29 -0
- package/dist/services/app/modules/users/lambdas/create-user/index.d.ts +1 -0
- package/dist/services/app/modules/users/lambdas/create-user/index.js +22 -0
- package/dist/services/app/modules/users/lambdas/create-user/index.mjs +1 -0
- package/dist/services/app/modules/users/lambdas/delete-user/delete-user.use-case.d.ts +16 -0
- package/dist/services/app/modules/users/lambdas/delete-user/delete-user.use-case.js +61 -0
- package/dist/services/app/modules/users/lambdas/delete-user/delete-user.use-case.mjs +32 -0
- package/dist/services/app/modules/users/lambdas/delete-user/index.d.ts +1 -0
- package/dist/services/app/modules/users/lambdas/delete-user/index.js +22 -0
- package/dist/services/app/modules/users/lambdas/delete-user/index.mjs +1 -0
- package/dist/services/app/modules/users/lambdas/get-user-by-id/get-user-by-id.use-case.d.ts +14 -0
- package/dist/services/app/modules/users/lambdas/get-user-by-id/get-user-by-id.use-case.js +52 -0
- package/dist/services/app/modules/users/lambdas/get-user-by-id/get-user-by-id.use-case.mjs +23 -0
- package/dist/services/app/modules/users/lambdas/get-user-by-id/index.d.ts +1 -0
- package/dist/services/app/modules/users/lambdas/get-user-by-id/index.js +22 -0
- package/dist/services/app/modules/users/lambdas/get-user-by-id/index.mjs +1 -0
- package/dist/services/app/modules/users/lambdas/list-users-by-props/index.d.ts +1 -0
- package/dist/services/app/modules/users/lambdas/list-users-by-props/index.js +22 -0
- package/dist/services/app/modules/users/lambdas/list-users-by-props/index.mjs +1 -0
- package/dist/services/app/modules/users/lambdas/list-users-by-props/list-users-by-props.use-case.d.ts +16 -0
- package/dist/services/app/modules/users/lambdas/list-users-by-props/list-users-by-props.use-case.js +52 -0
- package/dist/services/app/modules/users/lambdas/list-users-by-props/list-users-by-props.use-case.mjs +23 -0
- package/dist/services/app/modules/users/lambdas/update-user/index.d.ts +1 -0
- package/dist/services/app/modules/users/lambdas/update-user/index.js +22 -0
- package/dist/services/app/modules/users/lambdas/update-user/index.mjs +1 -0
- package/dist/services/app/modules/users/lambdas/update-user/update-user.use-case.d.ts +15 -0
- package/dist/services/app/modules/users/lambdas/update-user/update-user.use-case.js +62 -0
- package/dist/services/app/modules/users/lambdas/update-user/update-user.use-case.mjs +33 -0
- package/dist/services/app/modules/users/repositories/index.d.ts +1 -0
- package/dist/services/app/modules/users/repositories/index.js +22 -0
- package/dist/services/app/modules/users/repositories/index.mjs +1 -0
- package/dist/services/app/modules/users/repositories/user.repository.d.ts +12 -0
- package/dist/services/app/modules/users/repositories/user.repository.js +83 -0
- package/dist/services/app/modules/users/repositories/user.repository.mjs +54 -0
- package/package.json +1 -1
- package/dist/agent-loop-C41Y1CGp.d.mts +0 -60
- package/dist/agent-loop-ZH4GRi4A.d.ts +0 -60
- package/dist/base.use-case-8K6_Ods0.d.mts +0 -14
- package/dist/base.use-case-ChEb3nh6.d.ts +0 -14
- package/dist/chunk-6PCVBY5G.mjs +0 -1
- package/dist/chunk-7WJ3XXSP.mjs +0 -7
- package/dist/chunk-CCRMOWMO.mjs +0 -1
- package/dist/chunk-ISOEJA2L.mjs +0 -1
- package/dist/chunk-XXB52O7H.mjs +0 -1
- package/dist/current-session-DC-SF7rl.d.ts +0 -130
- package/dist/current-user-4BppBUBP.d.mts +0 -264
- package/dist/current-user-4BppBUBP.d.ts +0 -264
- package/dist/index.d.mts +0 -10
- package/dist/services/agent/core/index.d.mts +0 -122
- package/dist/services/agent/loops/index.d.mts +0 -116
- package/dist/services/agent/skills/index.d.mts +0 -14
- package/dist/services/agent/tools/index.d.mts +0 -12
- package/dist/services/app/core/index.d.mts +0 -60
- package/dist/skill-CtYQbG6-.d.ts +0 -308
- package/dist/skill-DXNkK5FG.d.mts +0 -308
- package/dist/tool-BaG2a8Np.d.mts +0 -42
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import "../../chunk-XRJFNASX.mjs";
|
|
2
|
+
import {
|
|
3
|
+
MongoClient as BaseMongoCLient
|
|
4
|
+
} from "mongodb";
|
|
5
|
+
import { secretManager } from "@common/utils/secret-manager";
|
|
6
|
+
import { logger } from "@common/logger";
|
|
7
|
+
import { reportError } from "@common/error";
|
|
8
|
+
class MongoClient {
|
|
9
|
+
client;
|
|
10
|
+
logger = logger;
|
|
11
|
+
isConnected = false;
|
|
12
|
+
constructor(uri, options) {
|
|
13
|
+
if (!uri) throw new Error("[Mongo Client]: uri parameter is required");
|
|
14
|
+
this.client = new BaseMongoCLient(uri, {
|
|
15
|
+
...options,
|
|
16
|
+
connectTimeoutMS: 5e3,
|
|
17
|
+
serverSelectionTimeoutMS: 5e3
|
|
18
|
+
});
|
|
19
|
+
this.logger.info("[Mongo Client] Client initialized");
|
|
20
|
+
}
|
|
21
|
+
async connect() {
|
|
22
|
+
if (!this.client) throw new Error("[Mongo Client]: Client is not initialized");
|
|
23
|
+
if (!this.isConnected) {
|
|
24
|
+
await this.client.connect();
|
|
25
|
+
this.isConnected = true;
|
|
26
|
+
this.logger.info("[Mongo Client]: Connected to MongoDB");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async close(force) {
|
|
30
|
+
await this.client.close(force || false);
|
|
31
|
+
this.isConnected = false;
|
|
32
|
+
}
|
|
33
|
+
async db(dbName, options) {
|
|
34
|
+
try {
|
|
35
|
+
await this.connect();
|
|
36
|
+
} catch (error) {
|
|
37
|
+
this.logger.error("[Mongo Client]: Error connecting to MongoDB");
|
|
38
|
+
await reportError(`Error connecting to MongoDB: ${error.message}`, { error });
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
return this.client.db(dbName, options);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const mongoDBClients = /* @__PURE__ */ new Map();
|
|
45
|
+
function getMongoDBClient(envVarName = "OPENLOOPS_DB_URI") {
|
|
46
|
+
if (!mongoDBClients.has(envVarName)) {
|
|
47
|
+
const connString = secretManager.get(envVarName);
|
|
48
|
+
if (connString) {
|
|
49
|
+
mongoDBClients.set(envVarName, new MongoClient(connString, {}));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return mongoDBClients.get(envVarName);
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
MongoClient,
|
|
56
|
+
getMongoDBClient
|
|
57
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { ObjectId } from 'mongodb';
|
|
2
|
+
export declare class MongoRepository<T> {
|
|
3
|
+
private readonly database;
|
|
4
|
+
private readonly collection;
|
|
5
|
+
private readonly dbClient;
|
|
6
|
+
private readonly _where;
|
|
7
|
+
private readonly report;
|
|
8
|
+
constructor(props: {
|
|
9
|
+
database: string;
|
|
10
|
+
collection: string;
|
|
11
|
+
envvar?: string;
|
|
12
|
+
});
|
|
13
|
+
parseId(id: string | undefined): ObjectId | undefined;
|
|
14
|
+
cleanInput(value: string): string;
|
|
15
|
+
private clampLimit;
|
|
16
|
+
findOne({ where, select, options }: QueryParams<T>): Promise<T | null>;
|
|
17
|
+
findMany({ where, select, options }: QueryParams<T>): Promise<T[]>;
|
|
18
|
+
findAll({ where, select }: QueryParams<T>): Promise<T[]>;
|
|
19
|
+
createOne({ payload }: CommandParams<T>): Promise<ObjectId>;
|
|
20
|
+
createMany({ payload }: CommandParams<T>): Promise<CreateManyResponse>;
|
|
21
|
+
updateOne({ where, payload, options }: CommandParams<T>): Promise<T>;
|
|
22
|
+
updateMany({ where, payload }: CommandParams<T>): Promise<number>;
|
|
23
|
+
deleteOne({ where }: CommandParams<T>): Promise<number>;
|
|
24
|
+
deleteMany({ where }: CommandParams<T>): Promise<number>;
|
|
25
|
+
count({ where, options }: QueryParams<T>): Promise<number>;
|
|
26
|
+
aggregate(pipeline: PipelineStage[]): Promise<T[]>;
|
|
27
|
+
distinct(field: string, where?: Record<string, unknown>): Promise<T[]>;
|
|
28
|
+
}
|
|
29
|
+
export type PipelineStage = {
|
|
30
|
+
$addFields: Record<string, unknown>;
|
|
31
|
+
} | {
|
|
32
|
+
$project: Record<string, unknown>;
|
|
33
|
+
} | {
|
|
34
|
+
$lookup: Record<string, unknown>;
|
|
35
|
+
} | {
|
|
36
|
+
$match: Record<string, unknown>;
|
|
37
|
+
} | {
|
|
38
|
+
$facet: Record<string, unknown>;
|
|
39
|
+
} | {
|
|
40
|
+
$group: Record<string, unknown>;
|
|
41
|
+
} | {
|
|
42
|
+
$merge: Record<string, unknown>;
|
|
43
|
+
} | {
|
|
44
|
+
$sort: Record<string, unknown>;
|
|
45
|
+
} | {
|
|
46
|
+
$set: Record<string, unknown>;
|
|
47
|
+
} | {
|
|
48
|
+
$sample: {
|
|
49
|
+
size: number;
|
|
50
|
+
};
|
|
51
|
+
} | {
|
|
52
|
+
$unwind: string;
|
|
53
|
+
} | {
|
|
54
|
+
$count: string;
|
|
55
|
+
} | {
|
|
56
|
+
$limit: number;
|
|
57
|
+
} | {
|
|
58
|
+
$skip: number;
|
|
59
|
+
} | {
|
|
60
|
+
$out: string;
|
|
61
|
+
};
|
|
62
|
+
type CreateManyResponse = {
|
|
63
|
+
[key: number]: ObjectId;
|
|
64
|
+
};
|
|
65
|
+
export interface QueryParams<T> {
|
|
66
|
+
where?: Partial<T>;
|
|
67
|
+
select?: {
|
|
68
|
+
[K in keyof T]?: 1 | 0;
|
|
69
|
+
};
|
|
70
|
+
options?: QueryOptions;
|
|
71
|
+
}
|
|
72
|
+
export interface QueryOptions {
|
|
73
|
+
page?: number;
|
|
74
|
+
limit?: number;
|
|
75
|
+
offset?: number;
|
|
76
|
+
sortBy?: {
|
|
77
|
+
[key: string]: 1 | -1;
|
|
78
|
+
};
|
|
79
|
+
aggregate?: boolean;
|
|
80
|
+
includeDeleted?: boolean;
|
|
81
|
+
}
|
|
82
|
+
export interface CommandParams<T> {
|
|
83
|
+
where?: Partial<T>;
|
|
84
|
+
payload?: Partial<T> | Partial<T>[];
|
|
85
|
+
options?: Record<string, unknown>;
|
|
86
|
+
}
|
|
87
|
+
export {};
|
|
@@ -0,0 +1,219 @@
|
|
|
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 mongo_db_repository_exports = {};
|
|
20
|
+
__export(mongo_db_repository_exports, {
|
|
21
|
+
MongoRepository: () => MongoRepository
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(mongo_db_repository_exports);
|
|
24
|
+
var import_mongodb = require("mongodb");
|
|
25
|
+
var import_error = require("@common/error");
|
|
26
|
+
var import_mongo_db = require("./mongo-db.client");
|
|
27
|
+
const DEFAULT_LIMIT = 10;
|
|
28
|
+
class MongoRepository {
|
|
29
|
+
database;
|
|
30
|
+
collection;
|
|
31
|
+
dbClient;
|
|
32
|
+
_where = { deletedAt: null, archivedAt: null };
|
|
33
|
+
report = import_error.reportError;
|
|
34
|
+
constructor(props) {
|
|
35
|
+
const { database, collection, envvar } = props || {};
|
|
36
|
+
if (!database) throw new Error("[Mongo Repository] Database name is required");
|
|
37
|
+
if (!collection) throw new Error("[Mongo Repository] Collection name is required");
|
|
38
|
+
this.dbClient = (0, import_mongo_db.getMongoDBClient)(envvar);
|
|
39
|
+
if (!this.dbClient) throw new Error("[Mongo Repository] Database client not found");
|
|
40
|
+
this.database = database;
|
|
41
|
+
this.collection = collection;
|
|
42
|
+
}
|
|
43
|
+
parseId(id) {
|
|
44
|
+
return typeof id === "string" && import_mongodb.ObjectId.isValid(id) ? new import_mongodb.ObjectId(id) : void 0;
|
|
45
|
+
}
|
|
46
|
+
cleanInput(value) {
|
|
47
|
+
return value?.replace(/[{}[\]()\/\\]/g, "");
|
|
48
|
+
}
|
|
49
|
+
clampLimit(limit) {
|
|
50
|
+
const n = Number(limit);
|
|
51
|
+
return !Number.isFinite(n) || n <= 0 ? DEFAULT_LIMIT : n;
|
|
52
|
+
}
|
|
53
|
+
async findOne({ where, select, options }) {
|
|
54
|
+
try {
|
|
55
|
+
const db = await this.dbClient.db(this.database);
|
|
56
|
+
const collection = db.collection(this.collection);
|
|
57
|
+
const result = await collection.findOne(
|
|
58
|
+
{ ...where, ...this._where },
|
|
59
|
+
{
|
|
60
|
+
...select ? { projection: select } : {},
|
|
61
|
+
...options
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
return result;
|
|
65
|
+
} catch (error) {
|
|
66
|
+
await this.report(error);
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async findMany({ where, select, options }) {
|
|
71
|
+
try {
|
|
72
|
+
const db = await this.dbClient.db(this.database);
|
|
73
|
+
const collection = db.collection(this.collection);
|
|
74
|
+
const { page = 1, limit = 10 } = options || {};
|
|
75
|
+
const _limit = this.clampLimit(limit);
|
|
76
|
+
const _skip = +page > 0 ? (+page - 1) * _limit : 0;
|
|
77
|
+
const result = await collection.find({ ...where, ...this._where }, { projection: select }).sort(options?.sortBy || { _id: -1 }).skip(_skip).limit(_limit).toArray();
|
|
78
|
+
return result;
|
|
79
|
+
} catch (error) {
|
|
80
|
+
await this.report(error);
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async findAll({ where, select }) {
|
|
85
|
+
try {
|
|
86
|
+
const db = await this.dbClient.db(this.database);
|
|
87
|
+
const collection = db.collection(this.collection);
|
|
88
|
+
const result = await collection.find({ ...where, ...this._where }, { projection: select }).toArray();
|
|
89
|
+
return result;
|
|
90
|
+
} catch (error) {
|
|
91
|
+
await this.report(error);
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async createOne({ payload }) {
|
|
96
|
+
if (!payload || Object.keys(payload).length === 0) throw new Error("[Mongo Repository] Payload is required for createOne operation");
|
|
97
|
+
try {
|
|
98
|
+
const db = await this.dbClient.db(this.database);
|
|
99
|
+
const collection = db.collection(this.collection);
|
|
100
|
+
const { insertedId } = await collection.insertOne({ ...payload, __v: 1 });
|
|
101
|
+
return insertedId;
|
|
102
|
+
} catch (error) {
|
|
103
|
+
await this.report(error);
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async createMany({ payload }) {
|
|
108
|
+
try {
|
|
109
|
+
const db = await this.dbClient.db(this.database);
|
|
110
|
+
const collection = db.collection(this.collection);
|
|
111
|
+
const { insertedIds } = await collection.insertMany(payload);
|
|
112
|
+
return insertedIds;
|
|
113
|
+
} catch (error) {
|
|
114
|
+
await this.report(error);
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async updateOne({ where, payload, options }) {
|
|
119
|
+
if (!where || Object.keys(where).length === 0) throw new Error("[Mongo Repository] Where is required for updateOne operation");
|
|
120
|
+
if (!payload || Object.keys(payload).length === 0) throw new Error("[Mongo Repository] Payload is required for updateOne operation");
|
|
121
|
+
try {
|
|
122
|
+
const db = await this.dbClient.db(this.database);
|
|
123
|
+
const collection = db.collection(this.collection);
|
|
124
|
+
const { _id, __v, createdAt, createdBy, toUnset, ...toSet } = payload;
|
|
125
|
+
const __payload = {
|
|
126
|
+
...toSet ? { $set: toSet } : {},
|
|
127
|
+
...toUnset ? { $unset: toUnset } : {}
|
|
128
|
+
};
|
|
129
|
+
const result = await collection.findOneAndUpdate(
|
|
130
|
+
{ ...where, ...this._where },
|
|
131
|
+
{
|
|
132
|
+
$inc: { __v: 1 },
|
|
133
|
+
...__payload
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
returnDocument: "after"
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
return result;
|
|
140
|
+
} catch (error) {
|
|
141
|
+
await this.report(error);
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async updateMany({ where, payload }) {
|
|
146
|
+
try {
|
|
147
|
+
const db = await this.dbClient.db(this.database);
|
|
148
|
+
const collection = db.collection(this.collection);
|
|
149
|
+
const result = await collection.updateMany(
|
|
150
|
+
{ ...where, ...this._where },
|
|
151
|
+
{ $set: payload }
|
|
152
|
+
);
|
|
153
|
+
const countUpdated = result.modifiedCount;
|
|
154
|
+
return countUpdated;
|
|
155
|
+
} catch (error) {
|
|
156
|
+
await this.report(error);
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
async deleteOne({ where }) {
|
|
161
|
+
try {
|
|
162
|
+
const db = await this.dbClient.db(this.database);
|
|
163
|
+
const collection = db.collection(this.collection);
|
|
164
|
+
const { deletedCount } = await collection.deleteOne({ ...where });
|
|
165
|
+
return deletedCount;
|
|
166
|
+
} catch (error) {
|
|
167
|
+
await this.report(error);
|
|
168
|
+
throw error;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
async deleteMany({ where }) {
|
|
172
|
+
try {
|
|
173
|
+
const db = await this.dbClient.db(this.database);
|
|
174
|
+
const collection = db.collection(this.collection);
|
|
175
|
+
const { deletedCount } = await collection.deleteMany({ ...where });
|
|
176
|
+
return deletedCount;
|
|
177
|
+
} catch (error) {
|
|
178
|
+
await this.report(error);
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
async count({ where, options }) {
|
|
183
|
+
try {
|
|
184
|
+
const db = await this.dbClient.db(this.database);
|
|
185
|
+
const collection = db.collection(this.collection);
|
|
186
|
+
const result = await collection.countDocuments({ ...where, ...options?.includeDeleted ? {} : this._where });
|
|
187
|
+
return result;
|
|
188
|
+
} catch (error) {
|
|
189
|
+
await this.report(error);
|
|
190
|
+
throw error;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
async aggregate(pipeline) {
|
|
194
|
+
try {
|
|
195
|
+
const db = await this.dbClient.db(this.database);
|
|
196
|
+
const collection = db.collection(this.collection);
|
|
197
|
+
const result = await collection.aggregate(pipeline).toArray();
|
|
198
|
+
return result;
|
|
199
|
+
} catch (error) {
|
|
200
|
+
await this.report(error);
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
async distinct(field, where) {
|
|
205
|
+
try {
|
|
206
|
+
const db = await this.dbClient.db(this.database);
|
|
207
|
+
const collection = db.collection(this.collection);
|
|
208
|
+
const result = await collection.distinct(field, { ...where, ...this._where });
|
|
209
|
+
return result;
|
|
210
|
+
} catch (error) {
|
|
211
|
+
await this.report(error);
|
|
212
|
+
throw error;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
217
|
+
0 && (module.exports = {
|
|
218
|
+
MongoRepository
|
|
219
|
+
});
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import "../../chunk-XRJFNASX.mjs";
|
|
2
|
+
import { ObjectId } from "mongodb";
|
|
3
|
+
import { reportError } from "@common/error";
|
|
4
|
+
import { getMongoDBClient } from "./mongo-db.client";
|
|
5
|
+
const DEFAULT_LIMIT = 10;
|
|
6
|
+
class MongoRepository {
|
|
7
|
+
database;
|
|
8
|
+
collection;
|
|
9
|
+
dbClient;
|
|
10
|
+
_where = { deletedAt: null, archivedAt: null };
|
|
11
|
+
report = reportError;
|
|
12
|
+
constructor(props) {
|
|
13
|
+
const { database, collection, envvar } = props || {};
|
|
14
|
+
if (!database) throw new Error("[Mongo Repository] Database name is required");
|
|
15
|
+
if (!collection) throw new Error("[Mongo Repository] Collection name is required");
|
|
16
|
+
this.dbClient = getMongoDBClient(envvar);
|
|
17
|
+
if (!this.dbClient) throw new Error("[Mongo Repository] Database client not found");
|
|
18
|
+
this.database = database;
|
|
19
|
+
this.collection = collection;
|
|
20
|
+
}
|
|
21
|
+
parseId(id) {
|
|
22
|
+
return typeof id === "string" && ObjectId.isValid(id) ? new ObjectId(id) : void 0;
|
|
23
|
+
}
|
|
24
|
+
cleanInput(value) {
|
|
25
|
+
return value?.replace(/[{}[\]()\/\\]/g, "");
|
|
26
|
+
}
|
|
27
|
+
clampLimit(limit) {
|
|
28
|
+
const n = Number(limit);
|
|
29
|
+
return !Number.isFinite(n) || n <= 0 ? DEFAULT_LIMIT : n;
|
|
30
|
+
}
|
|
31
|
+
async findOne({ where, select, options }) {
|
|
32
|
+
try {
|
|
33
|
+
const db = await this.dbClient.db(this.database);
|
|
34
|
+
const collection = db.collection(this.collection);
|
|
35
|
+
const result = await collection.findOne(
|
|
36
|
+
{ ...where, ...this._where },
|
|
37
|
+
{
|
|
38
|
+
...select ? { projection: select } : {},
|
|
39
|
+
...options
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
return result;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
await this.report(error);
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async findMany({ where, select, options }) {
|
|
49
|
+
try {
|
|
50
|
+
const db = await this.dbClient.db(this.database);
|
|
51
|
+
const collection = db.collection(this.collection);
|
|
52
|
+
const { page = 1, limit = 10 } = options || {};
|
|
53
|
+
const _limit = this.clampLimit(limit);
|
|
54
|
+
const _skip = +page > 0 ? (+page - 1) * _limit : 0;
|
|
55
|
+
const result = await collection.find({ ...where, ...this._where }, { projection: select }).sort(options?.sortBy || { _id: -1 }).skip(_skip).limit(_limit).toArray();
|
|
56
|
+
return result;
|
|
57
|
+
} catch (error) {
|
|
58
|
+
await this.report(error);
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async findAll({ where, select }) {
|
|
63
|
+
try {
|
|
64
|
+
const db = await this.dbClient.db(this.database);
|
|
65
|
+
const collection = db.collection(this.collection);
|
|
66
|
+
const result = await collection.find({ ...where, ...this._where }, { projection: select }).toArray();
|
|
67
|
+
return result;
|
|
68
|
+
} catch (error) {
|
|
69
|
+
await this.report(error);
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async createOne({ payload }) {
|
|
74
|
+
if (!payload || Object.keys(payload).length === 0) throw new Error("[Mongo Repository] Payload is required for createOne operation");
|
|
75
|
+
try {
|
|
76
|
+
const db = await this.dbClient.db(this.database);
|
|
77
|
+
const collection = db.collection(this.collection);
|
|
78
|
+
const { insertedId } = await collection.insertOne({ ...payload, __v: 1 });
|
|
79
|
+
return insertedId;
|
|
80
|
+
} catch (error) {
|
|
81
|
+
await this.report(error);
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async createMany({ payload }) {
|
|
86
|
+
try {
|
|
87
|
+
const db = await this.dbClient.db(this.database);
|
|
88
|
+
const collection = db.collection(this.collection);
|
|
89
|
+
const { insertedIds } = await collection.insertMany(payload);
|
|
90
|
+
return insertedIds;
|
|
91
|
+
} catch (error) {
|
|
92
|
+
await this.report(error);
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async updateOne({ where, payload, options }) {
|
|
97
|
+
if (!where || Object.keys(where).length === 0) throw new Error("[Mongo Repository] Where is required for updateOne operation");
|
|
98
|
+
if (!payload || Object.keys(payload).length === 0) throw new Error("[Mongo Repository] Payload is required for updateOne operation");
|
|
99
|
+
try {
|
|
100
|
+
const db = await this.dbClient.db(this.database);
|
|
101
|
+
const collection = db.collection(this.collection);
|
|
102
|
+
const { _id, __v, createdAt, createdBy, toUnset, ...toSet } = payload;
|
|
103
|
+
const __payload = {
|
|
104
|
+
...toSet ? { $set: toSet } : {},
|
|
105
|
+
...toUnset ? { $unset: toUnset } : {}
|
|
106
|
+
};
|
|
107
|
+
const result = await collection.findOneAndUpdate(
|
|
108
|
+
{ ...where, ...this._where },
|
|
109
|
+
{
|
|
110
|
+
$inc: { __v: 1 },
|
|
111
|
+
...__payload
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
returnDocument: "after"
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
return result;
|
|
118
|
+
} catch (error) {
|
|
119
|
+
await this.report(error);
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async updateMany({ where, payload }) {
|
|
124
|
+
try {
|
|
125
|
+
const db = await this.dbClient.db(this.database);
|
|
126
|
+
const collection = db.collection(this.collection);
|
|
127
|
+
const result = await collection.updateMany(
|
|
128
|
+
{ ...where, ...this._where },
|
|
129
|
+
{ $set: payload }
|
|
130
|
+
);
|
|
131
|
+
const countUpdated = result.modifiedCount;
|
|
132
|
+
return countUpdated;
|
|
133
|
+
} catch (error) {
|
|
134
|
+
await this.report(error);
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async deleteOne({ where }) {
|
|
139
|
+
try {
|
|
140
|
+
const db = await this.dbClient.db(this.database);
|
|
141
|
+
const collection = db.collection(this.collection);
|
|
142
|
+
const { deletedCount } = await collection.deleteOne({ ...where });
|
|
143
|
+
return deletedCount;
|
|
144
|
+
} catch (error) {
|
|
145
|
+
await this.report(error);
|
|
146
|
+
throw error;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
async deleteMany({ where }) {
|
|
150
|
+
try {
|
|
151
|
+
const db = await this.dbClient.db(this.database);
|
|
152
|
+
const collection = db.collection(this.collection);
|
|
153
|
+
const { deletedCount } = await collection.deleteMany({ ...where });
|
|
154
|
+
return deletedCount;
|
|
155
|
+
} catch (error) {
|
|
156
|
+
await this.report(error);
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
async count({ where, options }) {
|
|
161
|
+
try {
|
|
162
|
+
const db = await this.dbClient.db(this.database);
|
|
163
|
+
const collection = db.collection(this.collection);
|
|
164
|
+
const result = await collection.countDocuments({ ...where, ...options?.includeDeleted ? {} : this._where });
|
|
165
|
+
return result;
|
|
166
|
+
} catch (error) {
|
|
167
|
+
await this.report(error);
|
|
168
|
+
throw error;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
async aggregate(pipeline) {
|
|
172
|
+
try {
|
|
173
|
+
const db = await this.dbClient.db(this.database);
|
|
174
|
+
const collection = db.collection(this.collection);
|
|
175
|
+
const result = await collection.aggregate(pipeline).toArray();
|
|
176
|
+
return result;
|
|
177
|
+
} catch (error) {
|
|
178
|
+
await this.report(error);
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
async distinct(field, where) {
|
|
183
|
+
try {
|
|
184
|
+
const db = await this.dbClient.db(this.database);
|
|
185
|
+
const collection = db.collection(this.collection);
|
|
186
|
+
const result = await collection.distinct(field, { ...where, ...this._where });
|
|
187
|
+
return result;
|
|
188
|
+
} catch (error) {
|
|
189
|
+
await this.report(error);
|
|
190
|
+
throw error;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
export {
|
|
195
|
+
MongoRepository
|
|
196
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import 'dotenv/config';
|
|
2
|
+
export declare class SecretManager {
|
|
3
|
+
private static instance;
|
|
4
|
+
private cache;
|
|
5
|
+
private cryptr;
|
|
6
|
+
static getInstance(): SecretManager;
|
|
7
|
+
static encrypt(value: string): string;
|
|
8
|
+
private constructor();
|
|
9
|
+
get(key: string): string;
|
|
10
|
+
private getEnvVar;
|
|
11
|
+
private decryptEnvVar;
|
|
12
|
+
private isStringEncrypted;
|
|
13
|
+
private logElapsed;
|
|
14
|
+
}
|
|
15
|
+
export declare const secretManager: SecretManager;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var secret_manager_exports = {};
|
|
30
|
+
__export(secret_manager_exports, {
|
|
31
|
+
SecretManager: () => SecretManager,
|
|
32
|
+
secretManager: () => secretManager
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(secret_manager_exports);
|
|
35
|
+
var import_config = require("dotenv/config");
|
|
36
|
+
var import_cryptr = __toESM(require("cryptr"));
|
|
37
|
+
var import_logger = require("@common/logger");
|
|
38
|
+
class SecretManager {
|
|
39
|
+
static instance;
|
|
40
|
+
cache = /* @__PURE__ */ new Map();
|
|
41
|
+
cryptr;
|
|
42
|
+
static getInstance() {
|
|
43
|
+
if (!SecretManager.instance) {
|
|
44
|
+
SecretManager.instance = new SecretManager();
|
|
45
|
+
}
|
|
46
|
+
return SecretManager.instance;
|
|
47
|
+
}
|
|
48
|
+
static encrypt(value) {
|
|
49
|
+
if (!value) throw new Error("[Secret manager] Value to encrypt cannot be empty");
|
|
50
|
+
return `ENC:${SecretManager.getInstance().cryptr.encrypt(value)}`;
|
|
51
|
+
}
|
|
52
|
+
constructor() {
|
|
53
|
+
const secretKey = process.env.SECRET_MANAGER_KEY;
|
|
54
|
+
if (!secretKey) {
|
|
55
|
+
throw new Error("[Secret manager] SSUID environment variable is not set");
|
|
56
|
+
}
|
|
57
|
+
this.cryptr = new import_cryptr.default(secretKey, {
|
|
58
|
+
pbkdf2Iterations: 1e3,
|
|
59
|
+
saltLength: 16
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
get(key) {
|
|
63
|
+
const startTime = process.hrtime.bigint();
|
|
64
|
+
if (this.cache.has(key)) {
|
|
65
|
+
const decryptedValue2 = this.cache.get(key);
|
|
66
|
+
this.logElapsed(key, startTime, true);
|
|
67
|
+
return decryptedValue2;
|
|
68
|
+
}
|
|
69
|
+
const encryptedValue = this.getEnvVar(key);
|
|
70
|
+
const decryptedValue = this.decryptEnvVar(encryptedValue);
|
|
71
|
+
this.cache.set(key, decryptedValue);
|
|
72
|
+
this.logElapsed(key, startTime, false);
|
|
73
|
+
return decryptedValue;
|
|
74
|
+
}
|
|
75
|
+
getEnvVar(key) {
|
|
76
|
+
const value = process.env[key];
|
|
77
|
+
if (!value) throw new Error(`[Secret manager] Environment variable ${key} is not set`);
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
decryptEnvVar(encryptedValue) {
|
|
81
|
+
if (!encryptedValue) throw new Error("[Secret manager] Encrypted value cannot be empty");
|
|
82
|
+
if (!this.isStringEncrypted(encryptedValue)) {
|
|
83
|
+
import_logger.logger.debug("[Secret Manager] Value is not encrypted");
|
|
84
|
+
return encryptedValue;
|
|
85
|
+
}
|
|
86
|
+
const valueWithoutPrefix = encryptedValue.replace(/^ENC:/, "");
|
|
87
|
+
return this.cryptr.decrypt(valueWithoutPrefix);
|
|
88
|
+
}
|
|
89
|
+
isStringEncrypted(value) {
|
|
90
|
+
if (!value) return false;
|
|
91
|
+
return value.startsWith("ENC:");
|
|
92
|
+
}
|
|
93
|
+
logElapsed(key, startTime, cached) {
|
|
94
|
+
const endTime = process.hrtime.bigint();
|
|
95
|
+
const elapsedTimeInMs = Number(endTime - startTime) / 1e6;
|
|
96
|
+
const suffix = cached ? " (cached)" : "";
|
|
97
|
+
import_logger.logger.debug(`[Secret Manager] GET: ${key} | ${elapsedTimeInMs.toFixed(3)} ms${suffix}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const secretManager = SecretManager.getInstance();
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
SecretManager,
|
|
104
|
+
secretManager
|
|
105
|
+
});
|