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
|
@@ -1,7 +1,24 @@
|
|
|
1
|
-
"use strict";var Ve=Object.create;var ft=Object.defineProperty;var Xt=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var Ye=Object.getPrototypeOf,He=Object.prototype.hasOwnProperty;var We=(e,t)=>{for(var n in t)ft(e,n,{get:t[n],enumerable:!0})},vt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Je(t))!He.call(e,s)&&s!==n&&ft(e,s,{get:()=>t[s],enumerable:!(r=Xt(t,s))||r.enumerable});return e};var X=(e,t,n)=>(n=e!=null?Ve(Ye(e)):{},vt(t||!e||!e.__esModule?ft(n,"default",{value:e,enumerable:!0}):n,e)),qe=e=>vt(ft({},"__esModule",{value:!0}),e),_=(e,t,n,r)=>{for(var s=r>1?void 0:r?Xt(t,n):t,i=e.length-1,o;i>=0;i--)(o=e[i])&&(s=(r?o(t,n,s):o(s))||s);return r&&s&&ft(t,n,s),s};var Jn={};We(Jn,{Tool:()=>v,callAiTool:()=>Vn,webSearchTool:()=>Ge});module.exports=qe(Jn);var v=class e{name;description;destructive;parameters;handler;constructor(t){this.name=t.name,this.description=t.description,this.destructive=t.destructive??!1,this.parameters=t.parameters,this.handler=t.handler}async run(...t){return this.handler(...t)}static fromMcp(t,n,r){return new e({name:`${r.namespace}__${t.name}`,description:t.description??"",destructive:t.annotations?.destructiveHint??!1,parameters:t.inputSchema,handler:async(s={})=>{let{currentUser:i,sessionId:o,answerId:a,...h}=s;return{data:await n.callTool({name:t.name,arguments:h})}}})}};var ee=X(require("axios"));var Wn=require("dotenv/config"),Dt=X(require("pino")),Qt=X(require("pino-pretty")),Ke=(0,Qt.default)({colorize:!0}),Y=class{IS_LOCAL=process.env.IS_LOCAL==="true"||process.env.NODE_ENV==="development";logger=this.IS_LOCAL?(0,Dt.default)({level:"debug"},Ke):(0,Dt.default)({level:"info"});log(t,n,r){typeof n=="string"&&(r=n,n=void 0),this.logger[t](n??{},r||"")}info(t,n){this.log("info",t,n)}warn(t,n){this.log("warn",t,n)}debug(t,n){this.log("debug",t,n)}error(t,n){this.log("error",t,n)}fatal(t,n){this.log("fatal",t,n)}},P=new Y;var Zn=require("dotenv/config"),te=X(require("cryptr"));var Ct=class e{static instance;cache=new Map;cryptr;static getInstance(){return e.instance||(e.instance=new e),e.instance}static encrypt(t){if(!t)throw new Error("[Secret manager] Value to encrypt cannot be empty");return`ENC:${e.getInstance().cryptr.encrypt(t)}`}constructor(){if(!process.env.SSUID)throw new Error("[Secret manager] SSUID environment variable is not set");this.cryptr=new te.default(process.env.SSUID,{pbkdf2Iterations:1e3,saltLength:16})}get(t){let n=process.hrtime.bigint();if(this.cache.has(t)){let i=this.cache.get(t);return this.logElapsed(t,n,!0),i}let r=this.getEnvVar(t),s=this.decryptEnvVar(r);return this.cache.set(t,s),this.logElapsed(t,n,!1),s}getEnvVar(t){let n=process.env[t];if(!n)throw new Error(`[Secret manager] Environment variable ${t} is not set`);return n}decryptEnvVar(t){if(!t)throw new Error("[Secret manager] Encrypted value cannot be empty");if(!this.isStringEncrypted(t))return P.debug("[Secret Manager] Value is not encrypted"),t;let n=t.replace(/^ENC:/,"");return this.cryptr.decrypt(n)}isStringEncrypted(t){return t?t.startsWith("ENC:"):!1}logElapsed(t,n,r){let s=process.hrtime.bigint(),i=Number(s-n)/1e6,o=r?" (cached)":"";P.debug(`[Secret Manager] GET: ${t} | ${i.toFixed(3)} ms${o}`)}},z=Ct.getInstance();var St=class{logger=new Y;async searchOnGoogle(t){let{query:n,type:r,page:s,num:i,countryCode:o,languageCode:a}=t,h=z.get("SERPER_API_KEY"),p={q:n,type:r,page:s,num:i,...o?{gl:o}:{},...a?{hl:a}:{},engine:"google"},g={method:"post",maxBodyLength:1/0,url:"https://google.serper.dev/search",headers:{"X-API-KEY":h,"Content-Type":"application/json"},data:p};try{this.logger.debug({...p},"[Serper Client] Searching on internet...");let{data:u}=await ee.default.request(g);return this.logger.debug({...u},"[Serper Client] Search results"),u}catch(u){this.logger.error(u)}}};var Ge=new v({name:"web_search",description:"Search on web",destructive:!1,parameters:{type:"object",properties:{query:{type:"string",description:"search query"}},required:["query"]},handler:async e=>{if(!e)throw new Error("[web_search] params is required");let{currentUser:t,sessionId:n,answerId:r,...s}=e;return{data:await new St().searchOnGoogle(s)}}});var Pe=require("tsyringe");function Ot(e){if(!e)return{};let t=e.indexOf("{");if(t===-1)return{};let n=0,r=!1,s=!1;for(let i=t;i<e.length;i++){let o=e[i];if(s){s=!1;continue}if(o==="\\"){s=!0;continue}if(o==='"'){r=!r;continue}if(!r&&(o==="{"?n++:o==="}"&&n--,n===0))try{return JSON.parse(e.substring(t,i+1))}catch{return{}}}return{}}var ne=X(require("sanitize-html"));function re(e=""){if(e)return(0,ne.default)(e,{allowedTags:[],allowedAttributes:{}})}var Us=require("reflect-metadata"),De=require("tsyringe"),Ce=require("langfuse");var xe=require("tsyringe");var K=class{statusCode;errorMessage;errorDetails;constructor(t){this.statusCode=t.statusCode,this.errorMessage=t.errorMessage,this.errorDetails=t.errorDetails}};var F=X(require("@sentry/node"));var Pt=class e{static instance;enabled;static getInstance(){return e.instance||(e.instance=new e),e.instance}constructor(){let t=this.resolveDsn();if(this.enabled=!!t,!t){P.warn("[Sentry Client] Sentry DSN is not configured. Skipping error reporting.");return}F.init({dsn:t,environment:process.env.NODE_ENV||"production",tracesSampleRate:0}),P.debug("[Sentry Client] Sentry client initialized")}async captureError(t,n){if(this.enabled){F.withScope(r=>{n&&r.setExtras(n),F.captureException(t)});try{await F.flush(2e3),P.debug("[Sentry Client] Error reported to Sentry successfully")}catch(r){P.error(r,"[Sentry Client] Failed to flush Sentry events")}}}setUser(t){this.enabled&&F.setUser({id:t})}resolveDsn(){try{return z.get("SENTRY_DSN")}catch{return}}},se=Pt.getInstance();var Mt=async(e,t)=>{e=typeof e=="string"?new Error(e):e;let n=(e instanceof K?e?.errorMessage:e?.message)||"Unknown error",r=(e instanceof K?e?.errorDetails:e?.stack)||"No stack trace available",s=e instanceof K?e?.statusCode:500;P.debug({error:t,message:n},"[Report Error] Reporting new error");let i=process.env.IS_LOCAL==="true"||process.env.NODE_ENV==="development";try{!i&&await se.captureError(e,{statusCode:s,errorMessage:n,errorDetails:r,...t})}catch(o){P.error({error:o},"[Report Error] Failed to report error to Sentry")}};var It=class{logger=new Y;secretManager=z;reportError=Mt;async onCatch(t){throw await Mt(t),t}throwHttpError(t){throw new K(t)}throwError401(t){this.throwHttpError({statusCode:401,errorMessage:"{{invalid_token}}: {{not_authenticated_error_details}}",errorDetails:JSON.stringify(t??{})})}throwError403(t){this.throwHttpError({statusCode:403,errorMessage:"{{forbidden_error}}: {{forbidden_error_details}}",errorDetails:JSON.stringify(t??{})})}};var Nt=class extends It{};var cs=require("reflect-metadata");var we=require("crypto"),Ze=(()=>{let e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),Symbol.toStringTag).get;return t=>e.call(t)})();function be(e){return Ze(e)==="Uint8Array"}function Xe(e){return typeof e=="object"&&e!=null&&Symbol.toStringTag in e&&(e[Symbol.toStringTag]==="ArrayBuffer"||e[Symbol.toStringTag]==="SharedArrayBuffer")}function ve(e){return e instanceof RegExp||Object.prototype.toString.call(e)==="[object RegExp]"}function Se(e){return typeof e=="object"&&e!=null&&Symbol.toStringTag in e&&e[Symbol.toStringTag]==="Map"}function Qe(e){return e instanceof Date||Object.prototype.toString.call(e)==="[object Date]"}function D(e,t){return JSON.stringify(e,(n,r)=>typeof r=="bigint"?{$numberLong:`${r}`}:Se(r)?Object.fromEntries(r):r)}function tn(e){if(e!=null&&typeof e=="object"&&"stylize"in e&&typeof e.stylize=="function")return e.stylize}var Yt=6,Oe=Symbol.for("@@mdb.bson.version"),Ht=2147483647,Wt=-2147483648,Ie=Math.pow(2,63)-1,Ne=-Math.pow(2,63),en=Math.pow(2,53),nn=-Math.pow(2,53);var Ee=4,Dr=Object.freeze({double:1,string:2,object:3,array:4,binData:5,undefined:6,objectId:7,bool:8,date:9,null:10,regex:11,dbPointer:12,javascript:13,symbol:14,javascriptWithScope:15,int:16,timestamp:17,long:18,decimal:19,minKey:-1,maxKey:127}),c=class extends Error{get bsonError(){return!0}get name(){return"BSONError"}constructor(t,n){super(t,n)}static isBSONError(t){return t!=null&&typeof t=="object"&&"bsonError"in t&&t.bsonError===!0&&"name"in t&&"message"in t&&"stack"in t}},Jt=class extends c{get name(){return"BSONVersionError"}constructor(){super(`Unsupported BSON version, bson types must be from bson ${Yt}.x.x`)}},Et=class extends c{get name(){return"BSONRuntimeError"}constructor(t){super(t)}},k=class extends c{get name(){return"BSONOffsetError"}constructor(t,n,r){super(`${t}. offset: ${n}`,r),this.offset=n}},ie,oe;function Be(e,t,n,r){if(r){ie??=new TextDecoder("utf8",{fatal:!0});try{return ie.decode(e.subarray(t,n))}catch(s){throw new c("Invalid UTF-8 string in BSON document",{cause:s})}}return oe??=new TextDecoder("utf8",{fatal:!1}),oe.decode(e.subarray(t,n))}function Te(e,t,n){if(e.length===0)return"";let r=n-t;if(r===0)return"";if(r>20)return null;if(r===1&&e[t]<128)return String.fromCharCode(e[t]);if(r===2&&e[t]<128&&e[t+1]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1]);if(r===3&&e[t]<128&&e[t+1]<128&&e[t+2]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1])+String.fromCharCode(e[t+2]);let s=[];for(let i=t;i<n;i++){let o=e[i];if(o>127)return null;s.push(o)}return String.fromCharCode(...s)}function rn(e,t,n){if(t.length===0)return 0;if(t.length>25||e.length-n<t.length)return null;for(let r=0,s=n;r<t.length;r++,s++){let i=t.charCodeAt(r);if(i>127)return null;e[s]=i}return t.length}var Z={toLocalBufferType(e){if(Buffer.isBuffer(e))return e;if(ArrayBuffer.isView(e))return Buffer.from(e.buffer,e.byteOffset,e.byteLength);let t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if(t==="ArrayBuffer"||t==="SharedArrayBuffer"||t==="[object ArrayBuffer]"||t==="[object SharedArrayBuffer]")return Buffer.from(e);throw new c("Cannot create Buffer from the passed potentialBuffer.")},allocate(e){return Buffer.alloc(e)},allocateUnsafe(e){return Buffer.allocUnsafe(e)},equals(e,t){return Z.toLocalBufferType(e).equals(t)},fromNumberArray(e){return Buffer.from(e)},fromBase64(e){return Buffer.from(e,"base64")},toBase64(e){return Z.toLocalBufferType(e).toString("base64")},fromISO88591(e){return Buffer.from(e,"binary")},toISO88591(e){return Z.toLocalBufferType(e).toString("binary")},fromHex(e){return Buffer.from(e,"hex")},toHex(e){return Z.toLocalBufferType(e).toString("hex")},toUTF8(e,t,n,r){let s=n-t<=20?Te(e,t,n):null;if(s!=null)return s;let i=Z.toLocalBufferType(e).toString("utf8",t,n);if(r){for(let o=0;o<i.length;o++)if(i.charCodeAt(o)===65533){Be(e,t,n,!0);break}}return i},utf8ByteLength(e){return Buffer.byteLength(e,"utf8")},encodeUTF8Into(e,t,n){let r=rn(e,t,n);return r??Z.toLocalBufferType(e).write(t,n,void 0,"utf8")},randomBytes:we.randomBytes,swap32(e){return Z.toLocalBufferType(e).swap32()}};function sn(){let{navigator:e}=globalThis;return typeof e=="object"&&e.product==="ReactNative"}function on(e){if(e<0)throw new RangeError(`The argument 'byteLength' is invalid. Received ${e}`);return mt.fromNumberArray(Array.from({length:e},()=>Math.floor(Math.random()*256)))}var an=(()=>{let{crypto:e}=globalThis;if(e!=null&&typeof e.getRandomValues=="function")return t=>e.getRandomValues(mt.allocate(t));if(sn()){let{console:t}=globalThis;t?.warn?.("BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.")}return on})(),ae=/(\d|[a-f])/i,mt={toLocalBufferType(e){let t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if(t==="Uint8Array")return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));if(t==="ArrayBuffer"||t==="SharedArrayBuffer"||t==="[object ArrayBuffer]"||t==="[object SharedArrayBuffer]")return new Uint8Array(e);throw new c("Cannot make a Uint8Array from passed potentialBuffer.")},allocate(e){if(typeof e!="number")throw new TypeError(`The "size" argument must be of type number. Received ${String(e)}`);return new Uint8Array(e)},allocateUnsafe(e){return mt.allocate(e)},equals(e,t){if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0},fromNumberArray(e){return Uint8Array.from(e)},fromBase64(e){return Uint8Array.from(atob(e),t=>t.charCodeAt(0))},toBase64(e){return btoa(mt.toISO88591(e))},fromISO88591(e){return Uint8Array.from(e,t=>t.charCodeAt(0)&255)},toISO88591(e){return Array.from(Uint16Array.from(e),t=>String.fromCharCode(t)).join("")},fromHex(e){let t=e.length%2===0?e:e.slice(0,e.length-1),n=[];for(let r=0;r<t.length;r+=2){let s=t[r],i=t[r+1];if(!ae.test(s)||!ae.test(i))break;let o=Number.parseInt(`${s}${i}`,16);n.push(o)}return Uint8Array.from(n)},toHex(e){return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")},toUTF8(e,t,n,r){let s=n-t<=20?Te(e,t,n):null;return s??Be(e,t,n,r)},utf8ByteLength(e){return new TextEncoder().encode(e).byteLength},encodeUTF8Into(e,t,n){let r=new TextEncoder().encode(t);return e.set(r,n),r.byteLength},randomBytes:an,swap32(e){if(e.length%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let t=0;t<e.length;t+=4){let n=e[t],r=e[t+1],s=e[t+2],i=e[t+3];e[t]=i,e[t+1]=s,e[t+2]=r,e[t+3]=n}return e}},cn=typeof Buffer=="function"&&Buffer.prototype?._isBuffer!==!0,m=cn?Z:mt,$=class{get[Oe](){return Yt}[Symbol.for("nodejs.util.inspect.custom")](t,n,r){return this.inspect(t,n,r)}},st=new Float64Array(1),w=new Uint8Array(st.buffer,0,8);st[0]=-1;var jt=w[7]===0,tt={isBigEndian:jt,getNonnegativeInt32LE(e,t){if(e[t+3]>127)throw new RangeError(`Size cannot be negative at offset: ${t}`);return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24},getInt32LE(e,t){return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24},getUint32LE(e,t){return e[t]+e[t+1]*256+e[t+2]*65536+e[t+3]*16777216},getUint32BE(e,t){return e[t+3]+e[t+2]*256+e[t+1]*65536+e[t]*16777216},getBigInt64LE(e,t){let n=BigInt(e[t+4]+e[t+5]*256+e[t+6]*65536+(e[t+7]<<24)),r=BigInt(e[t]+e[t+1]*256+e[t+2]*65536+e[t+3]*16777216);return(n<<BigInt(32))+r},getFloat64LE:jt?(e,t)=>(w[7]=e[t],w[6]=e[t+1],w[5]=e[t+2],w[4]=e[t+3],w[3]=e[t+4],w[2]=e[t+5],w[1]=e[t+6],w[0]=e[t+7],st[0]):(e,t)=>(w[0]=e[t],w[1]=e[t+1],w[2]=e[t+2],w[3]=e[t+3],w[4]=e[t+4],w[5]=e[t+5],w[6]=e[t+6],w[7]=e[t+7],st[0]),setInt32BE(e,t,n){return e[t+3]=n,n>>>=8,e[t+2]=n,n>>>=8,e[t+1]=n,n>>>=8,e[t]=n,4},setInt32LE(e,t,n){return e[t]=n,n>>>=8,e[t+1]=n,n>>>=8,e[t+2]=n,n>>>=8,e[t+3]=n,4},setBigInt64LE(e,t,n){let r=BigInt(4294967295),s=Number(n&r);e[t]=s,s>>=8,e[t+1]=s,s>>=8,e[t+2]=s,s>>=8,e[t+3]=s;let i=Number(n>>BigInt(32)&r);return e[t+4]=i,i>>=8,e[t+5]=i,i>>=8,e[t+6]=i,i>>=8,e[t+7]=i,8},setFloat64LE:jt?(e,t,n)=>(st[0]=n,e[t]=w[7],e[t+1]=w[6],e[t+2]=w[5],e[t+3]=w[4],e[t+4]=w[3],e[t+5]=w[2],e[t+6]=w[1],e[t+7]=w[0],8):(e,t,n)=>(st[0]=n,e[t]=w[0],e[t+1]=w[1],e[t+2]=w[2],e[t+3]=w[3],e[t+4]=w[4],e[t+5]=w[5],e[t+6]=w[6],e[t+7]=w[7],8)},B=class e extends ${get _bsontype(){return"Binary"}constructor(t,n){if(super(),t!=null&&typeof t=="string"&&!ArrayBuffer.isView(t)&&!Xe(t)&&!Array.isArray(t))throw new c("Binary can only be constructed from Uint8Array or number[]");this.sub_type=n??e.BSON_BINARY_SUBTYPE_DEFAULT,t==null?(this.buffer=m.allocate(e.BUFFER_SIZE),this.position=0):(this.buffer=Array.isArray(t)?m.fromNumberArray(t):m.toLocalBufferType(t),this.position=this.buffer.byteLength)}put(t){if(typeof t=="string"&&t.length!==1)throw new c("only accepts single character String");if(typeof t!="number"&&t.length!==1)throw new c("only accepts single character Uint8Array or Array");let n;if(typeof t=="string"?n=t.charCodeAt(0):typeof t=="number"?n=t:n=t[0],n<0||n>255)throw new c("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.byteLength>this.position)this.buffer[this.position++]=n;else{let r=m.allocate(e.BUFFER_SIZE+this.buffer.length);r.set(this.buffer,0),this.buffer=r,this.buffer[this.position++]=n}}write(t,n){if(n=typeof n=="number"?n:this.position,this.buffer.byteLength<n+t.length){let r=m.allocate(this.buffer.byteLength+t.length);r.set(this.buffer,0),this.buffer=r}if(ArrayBuffer.isView(t))this.buffer.set(m.toLocalBufferType(t),n),this.position=n+t.byteLength>this.position?n+t.length:this.position;else if(typeof t=="string")throw new c("input cannot be string")}read(t,n){n=n&&n>0?n:this.position;let r=t+n;return this.buffer.subarray(t,r>this.position?this.position:r)}value(){return this.buffer.length===this.position?this.buffer:this.buffer.subarray(0,this.position)}length(){return this.position}toJSON(){return m.toBase64(this.buffer.subarray(0,this.position))}toString(t){return t==="hex"?m.toHex(this.buffer.subarray(0,this.position)):t==="base64"?m.toBase64(this.buffer.subarray(0,this.position)):t==="utf8"||t==="utf-8"?m.toUTF8(this.buffer,0,this.position,!1):m.toUTF8(this.buffer,0,this.position,!1)}toExtendedJSON(t){t=t||{},this.sub_type===e.SUBTYPE_VECTOR&&G(this);let n=m.toBase64(this.buffer),r=Number(this.sub_type).toString(16);return t.legacy?{$binary:n,$type:r.length===1?"0"+r:r}:{$binary:{base64:n,subType:r.length===1?"0"+r:r}}}toUUID(){if(this.sub_type===e.SUBTYPE_UUID)return new gt(this.buffer.subarray(0,this.position));throw new c(`Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only "${e.SUBTYPE_UUID}" is currently supported.`)}static createFromHexString(t,n){return new e(m.fromHex(t),n)}static createFromBase64(t,n){return new e(m.fromBase64(t),n)}static fromExtendedJSON(t,n){n=n||{};let r,s;if("$binary"in t?n.legacy&&typeof t.$binary=="string"&&"$type"in t?(s=t.$type?parseInt(t.$type,16):0,r=m.fromBase64(t.$binary)):typeof t.$binary!="string"&&(s=t.$binary.subType?parseInt(t.$binary.subType,16):0,r=m.fromBase64(t.$binary.base64)):"$uuid"in t&&(s=4,r=gt.bytesFromString(t.$uuid)),!r)throw new c(`Unexpected Binary Extended JSON format ${JSON.stringify(t)}`);return s===Ee?new gt(r):new e(r,s)}inspect(t,n,r){r??=D;let s=m.toBase64(this.buffer.subarray(0,this.position)),i=r(s,n),o=r(this.sub_type,n);return`Binary.createFromBase64(${i}, ${o})`}toInt8Array(){if(this.sub_type!==e.SUBTYPE_VECTOR)throw new c("Binary sub_type is not Vector");if(this.buffer[0]!==e.VECTOR_TYPE.Int8)throw new c("Binary datatype field is not Int8");return G(this),new Int8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position))}toFloat32Array(){if(this.sub_type!==e.SUBTYPE_VECTOR)throw new c("Binary sub_type is not Vector");if(this.buffer[0]!==e.VECTOR_TYPE.Float32)throw new c("Binary datatype field is not Float32");G(this);let t=new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position));return tt.isBigEndian&&m.swap32(t),new Float32Array(t.buffer)}toPackedBits(){if(this.sub_type!==e.SUBTYPE_VECTOR)throw new c("Binary sub_type is not Vector");if(this.buffer[0]!==e.VECTOR_TYPE.PackedBit)throw new c("Binary datatype field is not packed bit");return G(this),new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset+2,this.buffer.byteOffset+this.position))}toBits(){if(this.sub_type!==e.SUBTYPE_VECTOR)throw new c("Binary sub_type is not Vector");if(this.buffer[0]!==e.VECTOR_TYPE.PackedBit)throw new c("Binary datatype field is not packed bit");G(this);let n=(this.length()-2)*8-this.buffer[1],r=new Int8Array(n);for(let s=0;s<r.length;s++){let i=s/8|0,o=this.buffer[i+2],a=7-s%8,h=o>>a&1;r[s]=h}return r}static fromInt8Array(t){let n=m.allocate(t.byteLength+2);n[0]=e.VECTOR_TYPE.Int8,n[1]=0;let r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);n.set(r,2);let s=new this(n,this.SUBTYPE_VECTOR);return G(s),s}static fromFloat32Array(t){let n=m.allocate(t.byteLength+2);n[0]=e.VECTOR_TYPE.Float32,n[1]=0;let r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);n.set(r,2),tt.isBigEndian&&m.swap32(new Uint8Array(n.buffer,2));let s=new this(n,this.SUBTYPE_VECTOR);return G(s),s}static fromPackedBits(t,n=0){let r=m.allocate(t.byteLength+2);r[0]=e.VECTOR_TYPE.PackedBit,r[1]=n,r.set(t,2);let s=new this(r,this.SUBTYPE_VECTOR);return G(s),s}static fromBits(t){let n=t.length+7>>>3,r=new Uint8Array(n+2);r[0]=e.VECTOR_TYPE.PackedBit;let s=t.length%8;r[1]=s===0?0:8-s;for(let i=0;i<t.length;i++){let o=i>>>3,a=t[i];if(a!==0&&a!==1)throw new c(`Invalid bit value at ${i}: must be 0 or 1, found ${t[i]}`);if(a===0)continue;let h=7-i%8;r[o+2]|=a<<h}return new this(r,e.SUBTYPE_VECTOR)}};B.BSON_BINARY_SUBTYPE_DEFAULT=0;B.BUFFER_SIZE=256;B.SUBTYPE_DEFAULT=0;B.SUBTYPE_FUNCTION=1;B.SUBTYPE_BYTE_ARRAY=2;B.SUBTYPE_UUID_OLD=3;B.SUBTYPE_UUID=4;B.SUBTYPE_MD5=5;B.SUBTYPE_ENCRYPTED=6;B.SUBTYPE_COLUMN=7;B.SUBTYPE_SENSITIVE=8;B.SUBTYPE_VECTOR=9;B.SUBTYPE_USER_DEFINED=128;B.VECTOR_TYPE=Object.freeze({Int8:3,Float32:39,PackedBit:16});function G(e){if(e.sub_type!==B.SUBTYPE_VECTOR)return;let t=e.position,n=e.buffer[0],r=e.buffer[1];if((n===B.VECTOR_TYPE.Float32||n===B.VECTOR_TYPE.Int8)&&r!==0)throw new c("Invalid Vector: padding must be zero for int8 and float32 vectors");if(n===B.VECTOR_TYPE.Float32&&t!==0&&t-2!==0&&(t-2)%4!==0)throw new c("Invalid Vector: Float32 vector must contain a multiple of 4 bytes");if(n===B.VECTOR_TYPE.PackedBit&&r!==0&&t===2)throw new c("Invalid Vector: padding must be zero for packed bit vectors that are empty");if(n===B.VECTOR_TYPE.PackedBit&&r>7)throw new c(`Invalid Vector: padding must be a value between 0 and 7. found: ${r}`)}var zt=16,ln=/^[0-9A-F]{32}$/i,fn=/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i,gt=class e extends B{constructor(t){let n;if(t==null)n=e.generate();else if(t instanceof e)n=m.toLocalBufferType(new Uint8Array(t.buffer));else if(ArrayBuffer.isView(t)&&t.byteLength===zt)n=m.toLocalBufferType(t);else if(typeof t=="string")n=e.bytesFromString(t);else throw new c("Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).");super(n,Ee)}get id(){return this.buffer}set id(t){this.buffer=t}toHexString(t=!0){return t?[m.toHex(this.buffer.subarray(0,4)),m.toHex(this.buffer.subarray(4,6)),m.toHex(this.buffer.subarray(6,8)),m.toHex(this.buffer.subarray(8,10)),m.toHex(this.buffer.subarray(10,16))].join("-"):m.toHex(this.buffer)}toString(t){return t==="hex"?m.toHex(this.id):t==="base64"?m.toBase64(this.id):this.toHexString()}toJSON(){return this.toHexString()}equals(t){if(!t)return!1;if(t instanceof e)return m.equals(t.id,this.id);try{return m.equals(new e(t).id,this.id)}catch{return!1}}toBinary(){return new B(this.id,B.SUBTYPE_UUID)}static generate(){let t=m.randomBytes(zt);return t[6]=t[6]&15|64,t[8]=t[8]&63|128,t}static isValid(t){return t?typeof t=="string"?e.isValidUUIDString(t):be(t)?t.byteLength===zt:t._bsontype==="Binary"&&t.sub_type===this.SUBTYPE_UUID&&t.buffer.byteLength===16:!1}static createFromHexString(t){let n=e.bytesFromString(t);return new e(n)}static createFromBase64(t){return new e(m.fromBase64(t))}static bytesFromString(t){if(!e.isValidUUIDString(t))throw new c("UUID string representation must be 32 hex digits or canonical hyphenated representation");return m.fromHex(t.replace(/-/g,""))}static isValidUUIDString(t){return ln.test(t)||fn.test(t)}inspect(t,n,r){return r??=D,`new UUID(${r(this.toHexString(),n)})`}},pt=class e extends ${get _bsontype(){return"Code"}constructor(t,n){super(),this.code=t.toString(),this.scope=n??null}toJSON(){return this.scope!=null?{code:this.code,scope:this.scope}:{code:this.code}}toExtendedJSON(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}}static fromExtendedJSON(t){return new e(t.$code,t.$scope)}inspect(t,n,r){r??=D;let s=r(this.code,n),i=s.includes(`
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
`:""})`}};function un(e){return e!=null&&typeof e=="object"&&"$id"in e&&e.$id!=null&&"$ref"in e&&typeof e.$ref=="string"&&(!("$db"in e)||"$db"in e&&typeof e.$db=="string")}var ot=class e extends ${get _bsontype(){return"DBRef"}constructor(t,n,r,s){super();let i=t.split(".");i.length===2&&(r=i.shift(),t=i.shift()),this.collection=t,this.oid=n,this.db=r,this.fields=s||{}}get namespace(){return this.collection}set namespace(t){this.collection=t}toJSON(){let t=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return this.db!=null&&(t.$db=this.db),t}toExtendedJSON(t){t=t||{};let n={$ref:this.collection,$id:this.oid};return t.legacy||(this.db&&(n.$db=this.db),n=Object.assign(n,this.fields)),n}static fromExtendedJSON(t){let n=Object.assign({},t);return delete n.$ref,delete n.$id,delete n.$db,new e(t.$ref,t.$id,t.$db,n)}inspect(t,n,r){r??=D;let s=[r(this.namespace,n),r(this.oid,n),...this.db?[r(this.db,n)]:[],...Object.keys(this.fields).length>0?[r(this.fields,n)]:[]];return s[1]=r===D?`new ObjectId(${s[1]})`:s[1],`new DBRef(${s.join(", ")})`}};function Ae(e){if(e==="")return e;let t=0,n=e[t]==="-",r=e[t]==="+";(r||n)&&(t+=1);let s=!1;for(;t<e.length&&e[t]==="0";++t)s=!0;return s?`${n?"-":""}${e.length===t?"0":e.slice(t)}`:r?e.slice(1):e}function hn(e,t){t=t??10;let n="0123456789abcdefghijklmnopqrstuvwxyz".slice(0,t);return new RegExp(`[^-+${n}]`,"i").test(e)?!1:e}var C;try{C=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}var ce=65536,gn=1<<24,it=ce*ce,Le=it*it,mn=Le/2,le={},fe={},pn=20,yn=/^(\+?0|(\+|-)?[1-9][0-9]*)$/,l=class e extends ${get _bsontype(){return"Long"}get __isLong__(){return!0}constructor(t=0,n,r){super();let s=typeof n=="boolean"?n:!!r,i=typeof n=="number"?n:0,o=typeof t=="string"?e.fromString(t,s):typeof t=="bigint"?e.fromBigInt(t,s):{low:t|0,high:i|0,unsigned:s};this.low=o.low,this.high=o.high,this.unsigned=o.unsigned}static fromBits(t,n,r){return new e(t,n,r)}static fromInt(t,n){let r,s,i;return n?(t>>>=0,(i=0<=t&&t<256)&&(s=fe[t],s)?s:(r=e.fromBits(t,(t|0)<0?-1:0,!0),i&&(fe[t]=r),r)):(t|=0,(i=-128<=t&&t<128)&&(s=le[t],s)?s:(r=e.fromBits(t,t<0?-1:0,!1),i&&(le[t]=r),r))}static fromNumber(t,n){if(isNaN(t))return n?e.UZERO:e.ZERO;if(n){if(t<0)return e.UZERO;if(t>=Le)return e.MAX_UNSIGNED_VALUE}else{if(t<=-9223372036854776e3)return e.MIN_VALUE;if(t+1>=mn)return e.MAX_VALUE}return t<0?e.fromNumber(-t,n).neg():e.fromBits(t%it|0,t/it|0,n)}static fromBigInt(t,n){let r=BigInt(4294967295),s=BigInt(32);return new e(Number(t&r),Number(t>>s&r),n)}static _fromString(t,n,r){if(t.length===0)throw new c("empty string");if(r<2||36<r)throw new c("radix");let s;if((s=t.indexOf("-"))>0)throw new c("interior hyphen");if(s===0)return e._fromString(t.substring(1),n,r).neg();let i=e.fromNumber(Math.pow(r,8)),o=e.ZERO;for(let a=0;a<t.length;a+=8){let h=Math.min(8,t.length-a),p=parseInt(t.substring(a,a+h),r);if(h<8){let g=e.fromNumber(Math.pow(r,h));o=o.mul(g).add(e.fromNumber(p))}else o=o.mul(i),o=o.add(e.fromNumber(p))}return o.unsigned=n,o}static fromStringStrict(t,n,r){let s=!1;if(typeof n=="number"?(r=n,n=!1):s=!!n,r??=10,t.trim()!==t)throw new c(`Input: '${t}' contains leading and/or trailing whitespace`);if(!hn(t,r))throw new c(`Input: '${t}' contains invalid characters for radix: ${r}`);let i=Ae(t),o=e._fromString(i,s,r);if(o.toString(r).toLowerCase()!==i.toLowerCase())throw new c(`Input: ${t} is not representable as ${o.unsigned?"an unsigned":"a signed"} 64-bit Long ${r!=null?`with radix: ${r}`:""}`);return o}static fromString(t,n,r){let s=!1;return typeof n=="number"?(r=n,n=!1):s=!!n,r??=10,t==="NaN"&&r<24||(t==="Infinity"||t==="+Infinity"||t==="-Infinity")&&r<35?e.ZERO:e._fromString(t,s,r)}static fromBytes(t,n,r){return r?e.fromBytesLE(t,n):e.fromBytesBE(t,n)}static fromBytesLE(t,n){return new e(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,n)}static fromBytesBE(t,n){return new e(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],n)}static isLong(t){return t!=null&&typeof t=="object"&&"__isLong__"in t&&t.__isLong__===!0}static fromValue(t,n){return typeof t=="number"?e.fromNumber(t,n):typeof t=="string"?e.fromString(t,n):e.fromBits(t.low,t.high,typeof n=="boolean"?n:t.unsigned)}add(t){e.isLong(t)||(t=e.fromValue(t));let n=this.high>>>16,r=this.high&65535,s=this.low>>>16,i=this.low&65535,o=t.high>>>16,a=t.high&65535,h=t.low>>>16,p=t.low&65535,g=0,u=0,y=0,N=0;return N+=i+p,y+=N>>>16,N&=65535,y+=s+h,u+=y>>>16,y&=65535,u+=r+a,g+=u>>>16,u&=65535,g+=n+o,g&=65535,e.fromBits(y<<16|N,g<<16|u,this.unsigned)}and(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low&t.low,this.high&t.high,this.unsigned)}compare(t){if(e.isLong(t)||(t=e.fromValue(t)),this.eq(t))return 0;let n=this.isNegative(),r=t.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1}comp(t){return this.compare(t)}divide(t){if(e.isLong(t)||(t=e.fromValue(t)),t.isZero())throw new c("division by zero");if(C){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;let i=(this.unsigned?C.div_u:C.div_s)(this.low,this.high,t.low,t.high);return e.fromBits(i,C.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?e.UZERO:e.ZERO;let n,r,s;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return e.UZERO;if(t.gt(this.shru(1)))return e.UONE;s=e.UZERO}else{if(this.eq(e.MIN_VALUE))return t.eq(e.ONE)||t.eq(e.NEG_ONE)?e.MIN_VALUE:t.eq(e.MIN_VALUE)?e.ONE:(n=this.shr(1).div(t).shl(1),n.eq(e.ZERO)?t.isNegative()?e.ONE:e.NEG_ONE:(r=this.sub(t.mul(n)),s=n.add(r.div(t)),s));if(t.eq(e.MIN_VALUE))return this.unsigned?e.UZERO:e.ZERO;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();s=e.ZERO}for(r=this;r.gte(t);){n=Math.max(1,Math.floor(r.toNumber()/t.toNumber()));let i=Math.ceil(Math.log(n)/Math.LN2),o=i<=48?1:Math.pow(2,i-48),a=e.fromNumber(n),h=a.mul(t);for(;h.isNegative()||h.gt(r);)n-=o,a=e.fromNumber(n,this.unsigned),h=a.mul(t);a.isZero()&&(a=e.ONE),s=s.add(a),r=r.sub(h)}return s}div(t){return this.divide(t)}equals(t){return e.isLong(t)||(t=e.fromValue(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low}eq(t){return this.equals(t)}getHighBits(){return this.high}getHighBitsUnsigned(){return this.high>>>0}getLowBits(){return this.low}getLowBitsUnsigned(){return this.low>>>0}getNumBitsAbs(){if(this.isNegative())return this.eq(e.MIN_VALUE)?64:this.neg().getNumBitsAbs();let t=this.high!==0?this.high:this.low,n;for(n=31;n>0&&(t&1<<n)===0;n--);return this.high!==0?n+33:n+1}greaterThan(t){return this.comp(t)>0}gt(t){return this.greaterThan(t)}greaterThanOrEqual(t){return this.comp(t)>=0}gte(t){return this.greaterThanOrEqual(t)}ge(t){return this.greaterThanOrEqual(t)}isEven(){return(this.low&1)===0}isNegative(){return!this.unsigned&&this.high<0}isOdd(){return(this.low&1)===1}isPositive(){return this.unsigned||this.high>=0}isZero(){return this.high===0&&this.low===0}lessThan(t){return this.comp(t)<0}lt(t){return this.lessThan(t)}lessThanOrEqual(t){return this.comp(t)<=0}lte(t){return this.lessThanOrEqual(t)}modulo(t){if(e.isLong(t)||(t=e.fromValue(t)),C){let n=(this.unsigned?C.rem_u:C.rem_s)(this.low,this.high,t.low,t.high);return e.fromBits(n,C.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))}mod(t){return this.modulo(t)}rem(t){return this.modulo(t)}multiply(t){if(this.isZero())return e.ZERO;if(e.isLong(t)||(t=e.fromValue(t)),C){let R=C.mul(this.low,this.high,t.low,t.high);return e.fromBits(R,C.get_high(),this.unsigned)}if(t.isZero())return e.ZERO;if(this.eq(e.MIN_VALUE))return t.isOdd()?e.MIN_VALUE:e.ZERO;if(t.eq(e.MIN_VALUE))return this.isOdd()?e.MIN_VALUE:e.ZERO;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(e.TWO_PWR_24)&&t.lt(e.TWO_PWR_24))return e.fromNumber(this.toNumber()*t.toNumber(),this.unsigned);let n=this.high>>>16,r=this.high&65535,s=this.low>>>16,i=this.low&65535,o=t.high>>>16,a=t.high&65535,h=t.low>>>16,p=t.low&65535,g=0,u=0,y=0,N=0;return N+=i*p,y+=N>>>16,N&=65535,y+=s*p,u+=y>>>16,y&=65535,y+=i*h,u+=y>>>16,y&=65535,u+=r*p,g+=u>>>16,u&=65535,u+=s*h,g+=u>>>16,u&=65535,u+=i*a,g+=u>>>16,u&=65535,g+=n*p+r*h+s*a+i*o,g&=65535,e.fromBits(y<<16|N,g<<16|u,this.unsigned)}mul(t){return this.multiply(t)}negate(){return!this.unsigned&&this.eq(e.MIN_VALUE)?e.MIN_VALUE:this.not().add(e.ONE)}neg(){return this.negate()}not(){return e.fromBits(~this.low,~this.high,this.unsigned)}notEquals(t){return!this.equals(t)}neq(t){return this.notEquals(t)}ne(t){return this.notEquals(t)}or(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low|t.low,this.high|t.high,this.unsigned)}shiftLeft(t){return e.isLong(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?e.fromBits(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):e.fromBits(0,this.low<<t-32,this.unsigned)}shl(t){return this.shiftLeft(t)}shiftRight(t){return e.isLong(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?e.fromBits(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):e.fromBits(this.high>>t-32,this.high>=0?0:-1,this.unsigned)}shr(t){return this.shiftRight(t)}shiftRightUnsigned(t){if(e.isLong(t)&&(t=t.toInt()),t&=63,t===0)return this;{let n=this.high;if(t<32){let r=this.low;return e.fromBits(r>>>t|n<<32-t,n>>>t,this.unsigned)}else return t===32?e.fromBits(n,0,this.unsigned):e.fromBits(n>>>t-32,0,this.unsigned)}}shr_u(t){return this.shiftRightUnsigned(t)}shru(t){return this.shiftRightUnsigned(t)}subtract(t){return e.isLong(t)||(t=e.fromValue(t)),this.add(t.neg())}sub(t){return this.subtract(t)}toInt(){return this.unsigned?this.low>>>0:this.low}toNumber(){return this.unsigned?(this.high>>>0)*it+(this.low>>>0):this.high*it+(this.low>>>0)}toBigInt(){return BigInt(this.toString())}toBytes(t){return t?this.toBytesLE():this.toBytesBE()}toBytesLE(){let t=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]}toBytesBE(){let t=this.high,n=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,n>>>24,n>>>16&255,n>>>8&255,n&255]}toSigned(){return this.unsigned?e.fromBits(this.low,this.high,!1):this}toString(t){if(t=t||10,t<2||36<t)throw new c("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(e.MIN_VALUE)){let i=e.fromNumber(t),o=this.div(i),a=o.mul(i).sub(this);return o.toString(t)+a.toInt().toString(t)}else return"-"+this.neg().toString(t);let n=e.fromNumber(Math.pow(t,6),this.unsigned),r=this,s="";for(;;){let i=r.div(n),a=(r.sub(i.mul(n)).toInt()>>>0).toString(t);if(r=i,r.isZero())return a+s;for(;a.length<6;)a="0"+a;s=""+a+s}}toUnsigned(){return this.unsigned?this:e.fromBits(this.low,this.high,!0)}xor(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low^t.low,this.high^t.high,this.unsigned)}eqz(){return this.isZero()}le(t){return this.lessThanOrEqual(t)}toExtendedJSON(t){return t&&t.relaxed?this.toNumber():{$numberLong:this.toString()}}static fromExtendedJSON(t,n){let{useBigInt64:r=!1,relaxed:s=!0}={...n};if(t.$numberLong.length>pn)throw new c("$numberLong string is too long");if(!yn.test(t.$numberLong))throw new c(`$numberLong string "${t.$numberLong}" is in an invalid format`);if(r){let o=BigInt(t.$numberLong);return BigInt.asIntN(64,o)}let i=e.fromString(t.$numberLong);return s?i.toNumber():i}inspect(t,n,r){r??=D;let s=r(this.toString(),n),i=this.unsigned?`, ${r(this.unsigned,n)}`:"";return`new Long(${s}${i})`}};l.TWO_PWR_24=l.fromInt(gn);l.MAX_UNSIGNED_VALUE=l.fromBits(-1,-1,!0);l.ZERO=l.fromInt(0);l.UZERO=l.fromInt(0,!0);l.ONE=l.fromInt(1);l.UONE=l.fromInt(1,!0);l.NEG_ONE=l.fromInt(-1);l.MAX_VALUE=l.fromBits(-1,2147483647,!1);l.MIN_VALUE=l.fromBits(0,-2147483648,!1);var dn=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,wn=/^(\+|-)?(Infinity|inf)$/i,bn=/^(\+|-)?NaN$/i,rt=6111,ut=-6176,ue=6176,he=34,Ft=m.fromNumberArray([124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),ge=m.fromNumberArray([248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),me=m.fromNumberArray([120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),Sn=/^([-+])?(\d+)?$/,On=31,pe=16383,In=30,Nn=31;function ye(e){return!isNaN(parseInt(e,10))}function En(e){let t=l.fromNumber(1e9),n=l.fromNumber(0);if(!e.parts[0]&&!e.parts[1]&&!e.parts[2]&&!e.parts[3])return{quotient:e,rem:n};for(let r=0;r<=3;r++)n=n.shiftLeft(32),n=n.add(new l(e.parts[r],0)),e.parts[r]=n.div(t).low,n=n.modulo(t);return{quotient:e,rem:n}}function Bn(e,t){if(!e&&!t)return{high:l.fromNumber(0),low:l.fromNumber(0)};let n=e.shiftRightUnsigned(32),r=new l(e.getLowBits(),0),s=t.shiftRightUnsigned(32),i=new l(t.getLowBits(),0),o=n.multiply(s),a=n.multiply(i),h=r.multiply(s),p=r.multiply(i);return o=o.add(a.shiftRightUnsigned(32)),a=new l(a.getLowBits(),0).add(h).add(p.shiftRightUnsigned(32)),o=o.add(a.shiftRightUnsigned(32)),p=a.shiftLeft(32).add(new l(p.getLowBits(),0)),{high:o,low:p}}function Tn(e,t){let n=e.high>>>0,r=t.high>>>0;if(n<r)return!0;if(n===r){let s=e.low>>>0,i=t.low>>>0;if(s<i)return!0}return!1}function M(e,t){throw new c(`"${e}" is not a valid Decimal128 string - ${t}`)}var Bt=class e extends ${get _bsontype(){return"Decimal128"}constructor(t){if(super(),typeof t=="string")this.bytes=e.fromString(t).bytes;else if(t instanceof Uint8Array||be(t)){if(t.byteLength!==16)throw new c("Decimal128 must take a Buffer of 16 bytes");this.bytes=t}else throw new c("Decimal128 must take a Buffer or string")}static fromString(t){return e._fromString(t,{allowRounding:!1})}static fromStringWithRounding(t){return e._fromString(t,{allowRounding:!0})}static _fromString(t,n){let r=!1,s=!1,i=!1,o=!1,a=0,h=0,p=0,g=0,u=0,y=[0],N=0,R=0,d=0,b=0,O=new l(0,0),T=new l(0,0),V=0,f=0;if(t.length>=7e3)throw new c(""+t+" not a valid Decimal128 string");let U=t.match(dn),Fe=t.match(wn),ke=t.match(bn);if(!U&&!Fe&&!ke||t.length===0)throw new c(""+t+" not a valid Decimal128 string");if(U){let E=U[2],et=U[4],nt=U[5],x=U[6];et&&x===void 0&&M(t,"missing exponent power"),et&&E===void 0&&M(t,"missing exponent base"),et===void 0&&(nt||x)&&M(t,"missing e before exponent")}if((t[f]==="+"||t[f]==="-")&&(s=!0,r=t[f++]==="-"),!ye(t[f])&&t[f]!=="."){if(t[f]==="i"||t[f]==="I")return new e(r?ge:me);if(t[f]==="N")return new e(Ft)}for(;ye(t[f])||t[f]===".";){if(t[f]==="."){i&&M(t,"contains multiple periods"),i=!0,f=f+1;continue}N<he&&(t[f]!=="0"||o)&&(o||(u=h),o=!0,y[R++]=parseInt(t[f],10),N=N+1),o&&(p=p+1),i&&(g=g+1),h=h+1,f=f+1}if(i&&!h)throw new c(""+t+" not a valid Decimal128 string");if(t[f]==="e"||t[f]==="E"){let E=t.substr(++f).match(Sn);if(!E||!E[2])return new e(Ft);b=parseInt(E[0],10),f=f+E[0].length}if(t[f])return new e(Ft);if(!N)y[0]=0,p=1,N=1,a=0;else if(d=N-1,a=p,a!==1)for(;t[u+a-1+Number(s)+Number(i)]==="0";)a=a-1;for(b<=g&&g>b+16384?b=ut:b=b-g;b>rt;){if(d=d+1,d>=he){if(a===0){b=rt;break}M(t,"overflow")}b=b-1}if(n.allowRounding){for(;b<ut||N<p;){if(d===0&&a<N){b=ut,a=0;break}if(N<p?p=p-1:d=d-1,b<rt)b=b+1;else{if(y.join("").match(/^0+$/)){b=rt;break}M(t,"overflow")}}if(d+1<a){let E=h;i&&(u=u+1,E=E+1),s&&(u=u+1,E=E+1);let et=parseInt(t[u+d+1],10),nt=0;if(et>=5&&(nt=1,et===5)){nt=y[d]%2===1?1:0;for(let x=u+d+2;x<E;x++)if(parseInt(t[x],10)){nt=1;break}}if(nt){let x=d;for(;x>=0&&++y[x]>9;x--)if(y[x]=0,x===0)if(b<rt)b=b+1,y[x]=1;else return new e(r?ge:me)}}}else{for(;b<ut||N<p;){if(d===0){if(a===0){b=ut;break}M(t,"exponent underflow")}N<p?(t[p-1+Number(s)+Number(i)]!=="0"&&a!==0&&M(t,"inexact rounding"),p=p-1):(y[d]!==0&&M(t,"inexact rounding"),d=d-1),b<rt?b=b+1:M(t,"overflow")}d+1<a&&(i&&(u=u+1),s&&(u=u+1),parseInt(t[u+d+1],10)!==0&&M(t,"inexact rounding"))}if(O=l.fromNumber(0),T=l.fromNumber(0),a===0)O=l.fromNumber(0),T=l.fromNumber(0);else if(d<17){let E=0;for(T=l.fromNumber(y[E++]),O=new l(0,0);E<=d;E++)T=T.multiply(l.fromNumber(10)),T=T.add(l.fromNumber(y[E]))}else{let E=0;for(O=l.fromNumber(y[E++]);E<=d-17;E++)O=O.multiply(l.fromNumber(10)),O=O.add(l.fromNumber(y[E]));for(T=l.fromNumber(y[E++]);E<=d;E++)T=T.multiply(l.fromNumber(10)),T=T.add(l.fromNumber(y[E]))}let J=Bn(O,l.fromString("100000000000000000"));J.low=J.low.add(T),Tn(J.low,T)&&(J.high=J.high.add(l.fromNumber(1))),V=b+ue;let I={low:l.fromNumber(0),high:l.fromNumber(0)};J.high.shiftRightUnsigned(49).and(l.fromNumber(1)).equals(l.fromNumber(1))?(I.high=I.high.or(l.fromNumber(3).shiftLeft(61)),I.high=I.high.or(l.fromNumber(V).and(l.fromNumber(16383).shiftLeft(47))),I.high=I.high.or(J.high.and(l.fromNumber(0x7fffffffffff)))):(I.high=I.high.or(l.fromNumber(V&16383).shiftLeft(49)),I.high=I.high.or(J.high.and(l.fromNumber(562949953421311)))),I.low=J.low,r&&(I.high=I.high.or(l.fromString("9223372036854775808")));let L=m.allocateUnsafe(16);return f=0,L[f++]=I.low.low&255,L[f++]=I.low.low>>8&255,L[f++]=I.low.low>>16&255,L[f++]=I.low.low>>24&255,L[f++]=I.low.high&255,L[f++]=I.low.high>>8&255,L[f++]=I.low.high>>16&255,L[f++]=I.low.high>>24&255,L[f++]=I.high.low&255,L[f++]=I.high.low>>8&255,L[f++]=I.high.low>>16&255,L[f++]=I.high.low>>24&255,L[f++]=I.high.high&255,L[f++]=I.high.high>>8&255,L[f++]=I.high.high>>16&255,L[f++]=I.high.high>>24&255,new e(L)}toString(){let t,n=0,r=new Array(36);for(let f=0;f<r.length;f++)r[f]=0;let s=0,i=!1,o,a={parts:[0,0,0,0]},h,p,g=[];s=0;let u=this.bytes,y=u[s++]|u[s++]<<8|u[s++]<<16|u[s++]<<24,N=u[s++]|u[s++]<<8|u[s++]<<16|u[s++]<<24,R=u[s++]|u[s++]<<8|u[s++]<<16|u[s++]<<24,d=u[s++]|u[s++]<<8|u[s++]<<16|u[s++]<<24;s=0,{low:new l(y,N),high:new l(R,d)}.high.lessThan(l.ZERO)&&g.push("-");let O=d>>26&On;if(O>>3===3){if(O===In)return g.join("")+"Infinity";if(O===Nn)return"NaN";t=d>>15&pe,o=8+(d>>14&1)}else o=d>>14&7,t=d>>17&pe;let T=t-ue;if(a.parts[0]=(d&16383)+((o&15)<<14),a.parts[1]=R,a.parts[2]=N,a.parts[3]=y,a.parts[0]===0&&a.parts[1]===0&&a.parts[2]===0&&a.parts[3]===0)i=!0;else for(p=3;p>=0;p--){let f=0,U=En(a);if(a=U.quotient,f=U.rem.low,!!f)for(h=8;h>=0;h--)r[p*9+h]=f%10,f=Math.floor(f/10)}if(i)n=1,r[s]=0;else for(n=36;!r[s];)n=n-1,s=s+1;let V=n-1+T;if(V>=34||V<=-7||T>0){if(n>34)return g.push("0"),T>0?g.push(`E+${T}`):T<0&&g.push(`E${T}`),g.join("");g.push(`${r[s++]}`),n=n-1,n&&g.push(".");for(let f=0;f<n;f++)g.push(`${r[s++]}`);g.push("E"),V>0?g.push(`+${V}`):g.push(`${V}`)}else if(T>=0)for(let f=0;f<n;f++)g.push(`${r[s++]}`);else{let f=n+T;if(f>0)for(let U=0;U<f;U++)g.push(`${r[s++]}`);else g.push("0");for(g.push(".");f++<0;)g.push("0");for(let U=0;U<n-Math.max(f-1,0);U++)g.push(`${r[s++]}`)}return g.join("")}toJSON(){return{$numberDecimal:this.toString()}}toExtendedJSON(){return{$numberDecimal:this.toString()}}static fromExtendedJSON(t){return e.fromString(t.$numberDecimal)}inspect(t,n,r){return r??=D,`new Decimal128(${r(this.toString(),n)})`}},yt=class e extends ${get _bsontype(){return"Double"}constructor(t){super(),t instanceof Number&&(t=t.valueOf()),this.value=+t}static fromString(t){let n=Number(t);if(t==="NaN")return new e(NaN);if(t==="Infinity")return new e(1/0);if(t==="-Infinity")return new e(-1/0);if(!Number.isFinite(n))throw new c(`Input: ${t} is not representable as a Double`);if(t.trim()!==t)throw new c(`Input: '${t}' contains whitespace`);if(t==="")throw new c("Input is an empty string");if(/[^-0-9.+eE]/.test(t))throw new c(`Input: '${t}' is not in decimal or exponential notation`);return new e(n)}valueOf(){return this.value}toJSON(){return this.value}toString(t){return this.value.toString(t)}toExtendedJSON(t){return t&&(t.legacy||t.relaxed&&isFinite(this.value))?this.value:Object.is(Math.sign(this.value),-0)?{$numberDouble:"-0.0"}:{$numberDouble:Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}}static fromExtendedJSON(t,n){let r=parseFloat(t.$numberDouble);return n&&n.relaxed?r:new e(r)}inspect(t,n,r){return r??=D,`new Double(${r(this.value,n)})`}},dt=class e extends ${get _bsontype(){return"Int32"}constructor(t){super(),t instanceof Number&&(t=t.valueOf()),this.value=+t|0}static fromString(t){let n=Ae(t),r=Number(t);if(Ht<r)throw new c(`Input: '${t}' is larger than the maximum value for Int32`);if(Wt>r)throw new c(`Input: '${t}' is smaller than the minimum value for Int32`);if(Number.isSafeInteger(r)){if(r.toString()!==n)throw new c(`Input: '${t}' is not a valid Int32 string`)}else throw new c(`Input: '${t}' is not a safe integer`);return new e(r)}valueOf(){return this.value}toString(t){return this.value.toString(t)}toJSON(){return this.value}toExtendedJSON(t){return t&&(t.relaxed||t.legacy)?this.value:{$numberInt:this.value.toString()}}static fromExtendedJSON(t,n){return n&&n.relaxed?parseInt(t.$numberInt,10):new e(t.$numberInt)}inspect(t,n,r){return r??=D,`new Int32(${r(this.value,n)})`}},Tt=class e extends ${get _bsontype(){return"MaxKey"}toExtendedJSON(){return{$maxKey:1}}static fromExtendedJSON(){return new e}inspect(){return"new MaxKey()"}},At=class e extends ${get _bsontype(){return"MinKey"}toExtendedJSON(){return{$minKey:1}}static fromExtendedJSON(){return new e}inspect(){return"new MinKey()"}},Q=null,ht=new WeakMap,W=class e extends ${get _bsontype(){return"ObjectId"}constructor(t){super();let n;if(typeof t=="object"&&t&&"id"in t){if(typeof t.id!="string"&&!ArrayBuffer.isView(t.id))throw new c("Argument passed in must have an id that is of type string or Buffer");"toHexString"in t&&typeof t.toHexString=="function"?n=m.fromHex(t.toHexString()):n=t.id}else n=t;if(n==null||typeof n=="number")this.buffer=e.generate(typeof n=="number"?n:void 0);else if(ArrayBuffer.isView(n)&&n.byteLength===12)this.buffer=m.toLocalBufferType(n);else if(typeof n=="string")if(e.validateHexString(n))this.buffer=m.fromHex(n),e.cacheHexString&&ht.set(this,n);else throw new c("input must be a 24 character hex string, 12 byte Uint8Array, or an integer");else throw new c("Argument passed in does not match the accepted types")}get id(){return this.buffer}set id(t){this.buffer=t,e.cacheHexString&&ht.set(this,m.toHex(t))}static validateHexString(t){if(t?.length!==24)return!1;for(let n=0;n<24;n++){let r=t.charCodeAt(n);if(!(r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=70))return!1}return!0}toHexString(){if(e.cacheHexString){let n=ht.get(this);if(n)return n}let t=m.toHex(this.id);return e.cacheHexString&&ht.set(this,t),t}static getInc(){return e.index=(e.index+1)%16777215}static generate(t){typeof t!="number"&&(t=Math.floor(Date.now()/1e3));let n=e.getInc(),r=m.allocateUnsafe(12);return tt.setInt32BE(r,0,t),Q===null&&(Q=m.randomBytes(5)),r[4]=Q[0],r[5]=Q[1],r[6]=Q[2],r[7]=Q[3],r[8]=Q[4],r[11]=n&255,r[10]=n>>8&255,r[9]=n>>16&255,r}toString(t){return t==="base64"?m.toBase64(this.id):t==="hex"?this.toHexString():this.toHexString()}toJSON(){return this.toHexString()}static is(t){return t!=null&&typeof t=="object"&&"_bsontype"in t&&t._bsontype==="ObjectId"}equals(t){if(t==null)return!1;if(e.is(t))return this.buffer[11]===t.buffer[11]&&m.equals(this.buffer,t.buffer);if(typeof t=="string")return t.toLowerCase()===this.toHexString();if(typeof t=="object"&&typeof t.toHexString=="function"){let n=t.toHexString(),r=this.toHexString();return typeof n=="string"&&n.toLowerCase()===r}return!1}getTimestamp(){let t=new Date,n=tt.getUint32BE(this.buffer,0);return t.setTime(Math.floor(n)*1e3),t}static createPk(){return new e}serializeInto(t,n){return t[n]=this.buffer[0],t[n+1]=this.buffer[1],t[n+2]=this.buffer[2],t[n+3]=this.buffer[3],t[n+4]=this.buffer[4],t[n+5]=this.buffer[5],t[n+6]=this.buffer[6],t[n+7]=this.buffer[7],t[n+8]=this.buffer[8],t[n+9]=this.buffer[9],t[n+10]=this.buffer[10],t[n+11]=this.buffer[11],12}static createFromTime(t){let n=m.allocate(12);for(let r=11;r>=4;r--)n[r]=0;return tt.setInt32BE(n,0,t),new e(n)}static createFromHexString(t){if(t?.length!==24)throw new c("hex string must be 24 characters");return new e(m.fromHex(t))}static createFromBase64(t){if(t?.length!==16)throw new c("base64 string must be 16 characters");return new e(m.fromBase64(t))}static isValid(t){if(t==null)return!1;if(typeof t=="string")return e.validateHexString(t);try{return new e(t),!0}catch{return!1}}toExtendedJSON(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}}static fromExtendedJSON(t){return new e(t.$oid)}isCached(){return e.cacheHexString&&ht.has(this)}inspect(t,n,r){return r??=D,`new ObjectId(${r(this.toHexString(),n)})`}};W.index=Math.floor(Math.random()*16777215);function An(e){return e.split("").sort().join("")}var at=class e extends ${get _bsontype(){return"BSONRegExp"}constructor(t,n){if(super(),this.pattern=t,this.options=An(n??""),this.pattern.indexOf("\0")!==-1)throw new c(`BSON Regex patterns cannot contain null bytes, found: ${JSON.stringify(this.pattern)}`);if(this.options.indexOf("\0")!==-1)throw new c(`BSON Regex options cannot contain null bytes, found: ${JSON.stringify(this.options)}`);for(let r=0;r<this.options.length;r++)if(!(this.options[r]==="i"||this.options[r]==="m"||this.options[r]==="x"||this.options[r]==="l"||this.options[r]==="s"||this.options[r]==="u"))throw new c(`The regular expression option [${this.options[r]}] is not supported`)}static parseOptions(t){return t?t.split("").sort().join(""):""}toExtendedJSON(t){return t=t||{},t.legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}}static fromExtendedJSON(t){if("$regex"in t)if(typeof t.$regex!="string"){if(t.$regex._bsontype==="BSONRegExp")return t}else return new e(t.$regex,e.parseOptions(t.$options));if("$regularExpression"in t)return new e(t.$regularExpression.pattern,e.parseOptions(t.$regularExpression.options));throw new c(`Unexpected BSONRegExp EJSON object form: ${JSON.stringify(t)}`)}inspect(t,n,r){let s=tn(n)??(a=>a);r??=D;let i=s(r(this.pattern),"regexp"),o=s(r(this.options),"regexp");return`new BSONRegExp(${i}, ${o})`}},Lt=class e extends ${get _bsontype(){return"BSONSymbol"}constructor(t){super(),this.value=t}valueOf(){return this.value}toString(){return this.value}toJSON(){return this.value}toExtendedJSON(){return{$symbol:this.value}}static fromExtendedJSON(t){return new e(t.$symbol)}inspect(t,n,r){return r??=D,`new BSONSymbol(${r(this.value,n)})`}},Ln=l,wt=class e extends Ln{get _bsontype(){return"Timestamp"}get i(){return this.low>>>0}get t(){return this.high>>>0}constructor(t){if(t==null)super(0,0,!0);else if(typeof t=="bigint")super(t,!0);else if(l.isLong(t))super(t.low,t.high,!0);else if(typeof t=="object"&&"t"in t&&"i"in t){if(typeof t.t!="number"&&(typeof t.t!="object"||t.t._bsontype!=="Int32"))throw new c("Timestamp constructed from { t, i } must provide t as a number");if(typeof t.i!="number"&&(typeof t.i!="object"||t.i._bsontype!=="Int32"))throw new c("Timestamp constructed from { t, i } must provide i as a number");let n=Number(t.t),r=Number(t.i);if(n<0||Number.isNaN(n))throw new c("Timestamp constructed from { t, i } must provide a positive t");if(r<0||Number.isNaN(r))throw new c("Timestamp constructed from { t, i } must provide a positive i");if(n>4294967295)throw new c("Timestamp constructed from { t, i } must provide t equal or less than uint32 max");if(r>4294967295)throw new c("Timestamp constructed from { t, i } must provide i equal or less than uint32 max");super(r,n,!0)}else throw new c("A Timestamp can only be constructed with: bigint, Long, or { t: number; i: number }")}toJSON(){return{$timestamp:this.toString()}}static fromInt(t){return new e(l.fromInt(t,!0))}static fromNumber(t){return new e(l.fromNumber(t,!0))}static fromBits(t,n){return new e({i:t,t:n})}static fromString(t,n){return new e(l.fromString(t,!0,n))}toExtendedJSON(){return{$timestamp:{t:this.t,i:this.i}}}static fromExtendedJSON(t){let n=l.isLong(t.$timestamp.i)?t.$timestamp.i.getLowBitsUnsigned():t.$timestamp.i,r=l.isLong(t.$timestamp.t)?t.$timestamp.t.getLowBitsUnsigned():t.$timestamp.t;return new e({t:r,i:n})}inspect(t,n,r){r??=D;let s=r(this.t,n),i=r(this.i,n);return`new Timestamp({ t: ${s}, i: ${i} })`}};wt.MAX_VALUE=l.MAX_UNSIGNED_VALUE;var Cr=l.fromNumber(en),Pr=l.fromNumber(nn);function Un(e){return e!=null&&typeof e=="object"&&"_bsontype"in e&&typeof e._bsontype=="string"}var _n={$oid:W,$binary:B,$uuid:B,$symbol:Lt,$numberInt:dt,$numberDecimal:Bt,$numberDouble:yt,$numberLong:l,$minKey:At,$maxKey:Tt,$regex:at,$regularExpression:at,$timestamp:wt};function Ue(e,t={}){if(typeof e=="number"){let r=e<=Ht&&e>=Wt,s=e<=Ie&&e>=Ne;if(t.relaxed||t.legacy)return e;if(Number.isInteger(e)&&!Object.is(e,-0)){if(r)return new dt(e);if(s)return t.useBigInt64?BigInt(e):l.fromNumber(e)}return new yt(e)}if(e==null||typeof e!="object")return e;if(e.$undefined)return null;let n=Object.keys(e).filter(r=>r.startsWith("$")&&e[r]!=null);for(let r=0;r<n.length;r++){let s=_n[n[r]];if(s)return s.fromExtendedJSON(e,t)}if(e.$date!=null){let r=e.$date,s=new Date;if(t.legacy)if(typeof r=="number")s.setTime(r);else if(typeof r=="string")s.setTime(Date.parse(r));else if(typeof r=="bigint")s.setTime(Number(r));else throw new Et(`Unrecognized type for EJSON date: ${typeof r}`);else if(typeof r=="string")s.setTime(Date.parse(r));else if(l.isLong(r))s.setTime(r.toNumber());else if(typeof r=="number"&&t.relaxed)s.setTime(r);else if(typeof r=="bigint")s.setTime(Number(r));else throw new Et(`Unrecognized type for EJSON date: ${typeof r}`);return s}if(e.$code!=null){let r=Object.assign({},e);return e.$scope&&(r.$scope=Ue(e.$scope)),pt.fromExtendedJSON(e)}if(un(e)||e.$dbPointer){let r=e.$ref?e:e.$dbPointer;if(r instanceof ot)return r;let s=Object.keys(r).filter(o=>o.startsWith("$")),i=!0;if(s.forEach(o=>{["$ref","$id","$db"].indexOf(o)===-1&&(i=!1)}),i)return ot.fromExtendedJSON(r)}return e}function $n(e,t){return e.map((n,r)=>{t.seenObjects.push({propertyName:`index ${r}`,obj:null});try{return H(n,t)}finally{t.seenObjects.pop()}})}function de(e){let t=e.toISOString();return e.getUTCMilliseconds()!==0?t:t.slice(0,-5)+"Z"}function H(e,t){if(e instanceof Map||Se(e)){let n=Object.create(null);for(let[r,s]of e){if(typeof r!="string")throw new c("Can only serialize maps with string keys");n[r]=s}return H(n,t)}if((typeof e=="object"||typeof e=="function")&&e!==null){let n=t.seenObjects.findIndex(r=>r.obj===e);if(n!==-1){let r=t.seenObjects.map(g=>g.propertyName),s=r.slice(0,n).map(g=>`${g} -> `).join(""),i=r[n],o=" -> "+r.slice(n+1,r.length-1).map(g=>`${g} -> `).join(""),a=r[r.length-1],h=" ".repeat(s.length+i.length/2),p="-".repeat(o.length+(i.length+a.length)/2-1);throw new c(`Converting circular structure to EJSON:
|
|
6
|
-
|
|
7
|
-
${h}\\${p}/`)}t.seenObjects[t.seenObjects.length-1].obj=e}if(Array.isArray(e))return $n(e,t);if(e===void 0)return null;if(e instanceof Date||Qe(e)){let n=e.getTime(),r=n>-1&&n<2534023188e5;return t.legacy?t.relaxed&&r?{$date:e.getTime()}:{$date:de(e)}:t.relaxed&&r?{$date:de(e)}:{$date:{$numberLong:e.getTime().toString()}}}if(typeof e=="number"&&(!t.relaxed||!isFinite(e))){if(Number.isInteger(e)&&!Object.is(e,-0)){if(e>=Wt&&e<=Ht)return{$numberInt:e.toString()};if(e>=Ne&&e<=Ie)return{$numberLong:e.toString()}}return{$numberDouble:Object.is(e,-0)?"-0.0":e.toString()}}if(typeof e=="bigint")return t.relaxed?Number(BigInt.asIntN(64,e)):{$numberLong:BigInt.asIntN(64,e).toString()};if(e instanceof RegExp||ve(e)){let n=e.flags;if(n===void 0){let s=e.toString().match(/[gimuy]*$/);s&&(n=s[0])}return new at(e.source,n).toExtendedJSON(t)}return e!=null&&typeof e=="object"?xn(e,t):e}var Rn={Binary:e=>new B(e.value(),e.sub_type),Code:e=>new pt(e.code,e.scope),DBRef:e=>new ot(e.collection||e.namespace,e.oid,e.db,e.fields),Decimal128:e=>new Bt(e.bytes),Double:e=>new yt(e.value),Int32:e=>new dt(e.value),Long:e=>l.fromBits(e.low!=null?e.low:e.low_,e.low!=null?e.high:e.high_,e.low!=null?e.unsigned:e.unsigned_),MaxKey:()=>new Tt,MinKey:()=>new At,ObjectId:e=>new W(e),BSONRegExp:e=>new at(e.pattern,e.options),BSONSymbol:e=>new Lt(e.value),Timestamp:e=>wt.fromBits(e.low,e.high)};function xn(e,t){if(e==null||typeof e!="object")throw new c("not an object instance");let n=e._bsontype;if(typeof n>"u"){let r={};for(let s of Object.keys(e)){t.seenObjects.push({propertyName:s,obj:null});try{let i=H(e[s],t);s==="__proto__"?Object.defineProperty(r,s,{value:i,writable:!0,enumerable:!0,configurable:!0}):r[s]=i}finally{t.seenObjects.pop()}}return r}else{if(e!=null&&typeof e=="object"&&typeof e._bsontype=="string"&&e[Oe]!==Yt)throw new Jt;if(Un(e)){let r=e;if(typeof r.toExtendedJSON!="function"){let s=Rn[e._bsontype];if(!s)throw new c("Unrecognized or invalid _bsontype: "+e._bsontype);r=s(r)}return n==="Code"&&r.scope?r=new pt(r.code,H(r.scope,t)):n==="DBRef"&&r.oid&&(r=new ot(H(r.collection,t),H(r.oid,t),H(r.db,t),H(r.fields,t))),r.toExtendedJSON(t)}else throw new c("_bsontype must be a string, but was: "+typeof n)}}function _e(e,t){let n={useBigInt64:t?.useBigInt64??!1,relaxed:t?.relaxed??!0,legacy:t?.legacy??!1};return JSON.parse(e,(r,s)=>{if(r.indexOf("\0")!==-1)throw new c(`BSON Document field names cannot contain null bytes, found: ${JSON.stringify(r)}`);return Ue(s,n)})}function $e(e,t,n,r){n!=null&&typeof n=="object"&&(r=n,n=0),t!=null&&typeof t=="object"&&!Array.isArray(t)&&(r=t,t=void 0,n=0);let s=Object.assign({relaxed:!0,legacy:!1},r,{seenObjects:[{propertyName:"(root)",obj:null}]}),i=H(e,s);return JSON.stringify(i,t,n)}function Dn(e,t){return t=t||{},JSON.parse($e(e,t))}function Cn(e,t){return t=t||{},_e(JSON.stringify(e),t)}var bt=Object.create(null);bt.parse=_e;bt.stringify=$e;bt.serialize=Dn;bt.deserialize=Cn;Object.freeze(bt);var A={double:1,string:2,object:3,array:4,binData:5,undefined:6,objectId:7,bool:8,date:9,null:10,regex:11,dbPointer:12,javascript:13,symbol:14,javascriptWithScope:15,int:16,timestamp:17,long:18,decimal:19,minKey:255,maxKey:127};function kt(e,t){try{return tt.getNonnegativeInt32LE(e,t)}catch(n){throw new k("BSON size cannot be negative",t,{cause:n})}}function Vt(e,t){let n=t;for(;e[n]!==0;n++);if(n===e.length-1)throw new k("Null terminator not found",t);return n}function Pn(e,t=0){if(t??=0,e.length<5)throw new k(`Input must be at least 5 bytes, got ${e.length} bytes`,t);let n=kt(e,t);if(n>e.length-t)throw new k(`Parsed documentSize (${n} bytes) does not match input length (${e.length} bytes)`,t);if(e[t+n-1]!==0)throw new k("BSON documents must end in 0x00",t+n);let r=[],s=t+4;for(;s<=n+t;){let i=e[s];if(s+=1,i===0){if(s-t!==n)throw new k("Invalid 0x00 type byte",s);break}let o=s,a=Vt(e,s)-o;s+=a+1;let h;if(i===A.double||i===A.long||i===A.date||i===A.timestamp)h=8;else if(i===A.int)h=4;else if(i===A.objectId)h=12;else if(i===A.decimal)h=16;else if(i===A.bool)h=1;else if(i===A.null||i===A.undefined||i===A.maxKey||i===A.minKey)h=0;else if(i===A.regex)h=Vt(e,Vt(e,s)+1)+1-s;else if(i===A.object||i===A.array||i===A.javascriptWithScope)h=kt(e,s);else if(i===A.string||i===A.binData||i===A.dbPointer||i===A.javascript||i===A.symbol)h=kt(e,s)+4,i===A.binData&&(h+=1),i===A.dbPointer&&(h+=12);else throw new k(`Invalid 0x${i.toString(16).padStart(2,"0")} type byte`,s);if(h>n)throw new k("value reports length larger than document",s);r.push([i,o,a,s,h]),s+=h}return r}var Ut=Object.create(null);Ut.parseToElements=Pn;Ut.ByteUtils=m;Ut.NumberUtils=tt;Object.freeze(Ut);var Mn=1024*1024*17,Mr=m.allocate(Mn);function q(e){if(typeof e!="object"||e===null)return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function qt(e){if(Array.isArray(e))return e.map(qt);if(q(e)){let t={};for(let n of Object.keys(e))t[n]=qt(e[n]);return t}return e}function Kt(e){let t=r=>{if(Array.isArray(r)){r.forEach(t);return}q(r)&&Object.keys(r).forEach(s=>{let i=r[s];Array.isArray(i)?t(i):q(i)?(t(i),Object.keys(i).length===0&&delete r[s]):i==null&&delete r[s]})},n=qt(e);return t(n),n}function Gt(e,t="",n={}){if(!q(e))return{};for(let r in e)if(e.hasOwnProperty(r)){let s=t?`${t}.${r}`:r,i=e[r];q(i)?Gt(i,s,n):n[s]=i}return n}var jn="maskInLogs";var zn=(e,t)=>Reflect.getMetadata(jn,e,t);function _t(e){if(e&&q(e)){let t={};for(let[n,r]of Object.entries(e))zn(e,n)?t[n]="[HIDDEN]":Array.isArray(r)?t[n]=r.map(s=>_t(s)):typeof r=="object"?t[n]=_t(r):t[n]=r;return t}return e}var Fn="adminOnly";function j(e,t){Reflect.defineMetadata(Fn,!0,e,t)}var kn="ownerOnly";function Re(e,t){Reflect.defineMetadata(kn,!0,e,t)}var S=class S{_id;__v;ownerId;createdAt;createdBy;updatedAt;updatedBy;deletedAt;deletedBy;deletedReason;archivedAt;archivedBy;sharedWith;toUnset;static toObjectId(t){if(t){if(t instanceof W)return t;if(!W.isValid(t))throw new Error(`Invalid ObjectId: ${t}`);return new W(t)}}static toDate(t){if(!t)return;let n=new Date(t);if(isNaN(n.getTime()))throw new Error("{{value_must_be_a_date}}");return n}static toNumber(t){if(t!=null){if(typeof t!="number")throw new Error("{{value_must_be_a_number}}");return t}}static clean(t){return Kt(t)}constructor(t){this._id=S.toObjectId(t._id),this.__v=S.toNumber(t.__v),this.ownerId=S.toObjectId(t.ownerId),this.createdAt=S.toDate(t.createdAt),this.createdBy=S.toObjectId(t.createdBy),this.updatedAt=S.toDate(t.updatedAt),this.updatedBy=S.toObjectId(t.updatedBy),this.deletedAt=S.toDate(t.deletedAt),this.deletedBy=S.toObjectId(t.deletedBy),this.deletedReason=re(t.deletedReason),this.archivedAt=S.toDate(t.archivedAt),this.archivedBy=S.toObjectId(t.archivedBy),this.sharedWith=t.sharedWith?.length?t.sharedWith.map(n=>S.toObjectId(n)):void 0}toJSON(){return{_id:this._id,__v:this.__v,ownerId:this.ownerId,createdAt:this.createdAt,createdBy:this.createdBy,updatedAt:this.updatedAt,updatedBy:this.updatedBy,deletedAt:this.deletedAt,deletedBy:this.deletedBy,deletedReason:this.deletedReason,archivedAt:this.archivedAt,archivedBy:this.archivedBy,sharedWith:this.sharedWith?.length?this.sharedWith.map(t=>t.toHexString()):void 0,toUnset:this.toUnset}}setDefaults(){}setId(t){this._id=S.toObjectId(t)}setOwner(t){t&&(this.ownerId=S.toObjectId(t.userId))}setCreatedBy(t){t&&(this.sanitize(t),this.createdAt=new Date,this.createdBy=S.toObjectId(t.userId),this.setDefaults())}setUpdatedBy(t){t&&(this.sanitize(t),this.updatedAt=new Date,this.updatedBy=S.toObjectId(t.userId))}setDeletedBy(t){t&&(this.sanitize(t),this.deletedAt=new Date,this.deletedBy=S.toObjectId(t.userId))}setArchivedBy(t){t&&(this.sanitize(t),this.archivedAt=new Date,this.archivedBy=S.toObjectId(t.userId))}toDocument(){return Kt(this.toJSON())}toFlatDocument(){let{toUnset:t,...n}=this.toDocument();return{...Gt(n),toUnset:t}}stringify(){return JSON.stringify(_t(this),null,2)}unset(t){let n=Array.from(new Set(t.map(r=>String(r))));if(!n||!Array.isArray(n))return{};this.toUnset=n.reduce((r,s)=>(r[s]="",r),{}),t.forEach(r=>{delete this[r]})}sanitize(t){if(!t?.isAdmin())for(let n in this)Reflect.getMetadata("adminOnly",this.constructor.prototype,n)&&delete this[n]}};_([j],S.prototype,"__v",2),_([j],S.prototype,"ownerId",2),_([j],S.prototype,"createdAt",2),_([j],S.prototype,"createdBy",2),_([j],S.prototype,"updatedAt",2),_([j],S.prototype,"updatedBy",2),_([j],S.prototype,"deletedAt",2),_([j],S.prototype,"deletedBy",2),_([j],S.prototype,"archivedAt",2),_([j],S.prototype,"archivedBy",2),_([Re],S.prototype,"sharedWith",2);var ct=S;var $t=class e extends ct{constructor(n,r,s,i,o,a){super(n);this.props=n;this.taskName=r;this.answerId=s;this.sessionId=i;this.costInUsd=o;this.response=a}props;taskName;answerId;sessionId;costInUsd;response;static fromJSON(n){return new e(n,n.taskName||void 0,ct.toObjectId(n.answerId),ct.toObjectId(n.sessionId),n.costInUsd?Number(n.costInUsd):void 0,n.response||void 0)}toJSON(){return{...super.toJSON(),taskName:this.taskName,answerId:this.answerId,sessionId:this.sessionId,costInUsd:this.costInUsd,response:this.response}}setResponse(n){this.response=n}setTaskName(n){this.taskName=n}};var lt=class extends Nt{constructor(n){super();this.llmCallRepository=n}llmCallRepository;async execute(n){let{payload:r,currentUser:s}=n,i=$t.fromJSON({...r});i.setCreatedBy(s),i.setOwner(s);let o=await this.llmCallRepository.create(i);return{data:i.toJSON()}}};lt=_([(0,xe.autoInjectable)()],lt);var Rt=class{logger=new Y;langfuse;constructor(){process.env.OPENAI_API_KEY=z.get("OPENAI_API_KEY"),this.langfuse=new Ce.Langfuse({publicKey:z.get("LANGFUSE_PUBLIC_KEY"),secretKey:z.get("LANGFUSE_SECRET_KEY"),baseUrl:process.env.LANGFUSE_BASE_URL})}async complete(t){let{getModel:n,complete:r}=await import("@mariozechner/pi-ai"),{taskName:s,sessionId:i,answerId:o,currentUser:a,systemPrompt:h,messages:p,provider:g="openai",modelName:u="gpt-4o-mini",temperature:y=.7}=t??{},N=n(g,u),R={systemPrompt:h,messages:p};this.logger.debug({taskName:s,context:{...R,messages:this.formatMessagesForLog(p)}},"[LLM Service] context");let b=this.langfuse.trace({sessionId:i,name:s,userId:a?.userId,metadata:{taskName:s,email:a?.email,sessionId:i}}).generation({name:"llm-completion",model:u,modelParameters:{temperature:y,provider:g},input:R});try{let O=await r(N,R,{temperature:y});return b.end({output:O,usage:O.usage?{promptTokens:O.usage.input,completionTokens:O.usage.output,totalTokens:O.usage.totalTokens}:void 0}),await this.langfuse.flushAsync(),this.logger.debug({taskName:s,response:{...O,content:this.formatContentForLog(O?.content)}},"[LLM Service] Response"),await this.postResponse({taskName:s,sessionId:i,answerId:o,currentUser:a,response:O}),O}catch(O){throw b.end({level:"ERROR",statusMessage:O.message}),await this.langfuse.flushAsync(),O}}async postResponse(t){let{taskName:n,sessionId:r,answerId:s,currentUser:i,response:o}=t??{};await De.container.resolve(lt).execute({payload:{taskName:n,sessionId:r,answerId:s,response:o,costInUsd:o?.usage?.cost?.total},currentUser:i})}formatContentForLog(t){return t?.map(n=>{let r=n?.text,s=Ot(r),i=Object.keys(s).length>0;return{...n,text:i?s:r}})}formatMessagesForLog(t){return t.map(n=>({...n,content:this.formatContentForLog(n?.content)??n?.content}))}};var xt=class{name;version;description;temperature;systemInstructions;constructor(t){this.name=t.name,this.version=t.version,this.description=t.description,this.temperature=t.temperature,this.systemInstructions=t.systemInstructions}async run(t){let{sessionId:n,answerId:r,userMessage:s,currentUser:i,currentSession:o,contextInjection:a={},input:h={},chat:p}=t;try{let g=Pe.container.resolve(Rt),u=o?.location?.country,y=o?.currencyCode,N=new Date,R=o?.location?.timezone,d=R?N.toLocaleString("sv-SE",{timeZone:R}):void 0,b={SYSTEM_INSTRUCTIONS:{...this.systemInstructions},CONTEXT:{now_utc:new Date().toISOString(),now_local:d,timezone:o?.location?.timezone,day_of_week:new Date().toLocaleDateString("en-US",{weekday:"long"}),...p?.state?.language?{detected_language:p.state.language}:{},...i?{user_details:{first_name:i?.firstName,last_name:i?.lastName,preferred_language:i?.language,residence_country_code:i?.preferences?.country?.isoCode,preferred_currency_code:i?.preferences?.currency?.isoCode}}:{},...o?{session_details:{current_location:{country_code:u,currency_code:y,timezone_offset:o?.timezoneOffset},client_info:{platform:o?.device?.os,brand:o?.device?.brand,model:o?.device?.model}}}:{},...a},INPUT:{...s?{user_message:s}:{},...h}},O=await g.complete({sessionId:n,answerId:r,taskName:this.name,currentUser:i,messages:[{role:"user",timestamp:Date.now(),content:[{type:"text",text:JSON.stringify(b)}]}],temperature:this.temperature??.7}),T={...this.parseJsonResponse(O),responseId:O.responseId??"",costInUsd:O?.usage?.cost?.total};return p?.addTrace({node:this.name,reasoning:T?.reasoning}),T}catch(g){throw p?.addTrace({node:this.name,reasoning:`Failed: ${g?.message??g}`}),g}}parseJsonResponse(t){let n=t?.content??[],r=n[0]?.type==="text"?n[0].text:void 0;if(!r)throw new Error("LLM response text is empty or invalid");let s=Ot(r);if(!s)throw new Error("Failed to extract JSON from LLM response");return s}};var Me="FORMATTING: Present information in a clear, professional, and friendly manner. Use Markdown formatting (lists, bold text, code blocks) when appropriate to improve readability.",je="LATEX_FORMATTING: When outputting mathematical formulas or equations, use inline LaTeX with single dollar signs (e.g., $G_{\\mu\\nu}$) for inline expressions, and display block LaTeX (e.g., \\[ ... \\] or $$ ... $$) for standalone equations. Never wrap LaTeX inline symbols inside Markdown bold (**).",ze="CITATION_FORMATTING: Always includes source links in Markdown format whenever available or relevant.";var Zt=new xt({name:"call-ai",version:"1.0.0",description:"Executes custom AI analysis, summarization, extraction, or transformation tasks using dynamic agent-provided instructions and input context.",temperature:.3,systemInstructions:{instruction_set:{goal:"Execute the given task according to the specified instruction prompt, analyzing or processing the provided input to produce a clear, high-quality result.",role:"Flexible AI reasoning, analysis, summarization, and task execution engine",logic_rules:["INSTRUCTION_EXECUTION: Strictly follow the custom guidelines, criteria, and role instructions defined in 'systemPrompt'.","TASK_PROCESSING: Process the provided 'input_data' or context thoroughly, applying reasoning, extraction, or summarization as requested.","REASONING_LOG: Provide a concise, step-by-step logical justification of the proposed strategy in 'reasoning' strictly in English.",Me,je,ze,"STRICT_OUTPUT: Return ONLY the JSON object matching response_schema."],response_schema:{result:"string",reasoning:"string"}}}});var Vn=new v({name:"call_ai",description:Zt.description??"",destructive:!1,parameters:{type:"object",properties:{instructions:{type:"string",description:"System instructions or guidelines to perform the analysis, extraction, or transformation task."},input_data:{type:"string",description:"The raw text, data, or context to be processed."},temperature:{type:"number",description:"Optional sampling temperature (0.0 to 1.0) to control creativity or precision."}},required:["instructions","input_data"]},handler:async e=>{let{payload:t,currentUser:n,sessionId:r,answerId:s}=e,{instructions:i,input_data:o}=t;if(!i)throw new Error("[call_ai_tool] Param instructions is required");if(!o)throw new Error("[call_ai_tool] Param input_data is required");return{data:await Zt.run({sessionId:r,answerId:s,input:o,contextInjection:{systemPrompt:i},currentUser:n})}}});0&&(module.exports={Tool,callAiTool,webSearchTool});
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var tools_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(tools_exports);
|
|
18
|
+
__reExport(tools_exports, require("./core"), module.exports);
|
|
19
|
+
__reExport(tools_exports, require("./tool"), module.exports);
|
|
20
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
21
|
+
0 && (module.exports = {
|
|
22
|
+
...require("./core"),
|
|
23
|
+
...require("./tool")
|
|
24
|
+
});
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export * from "./core";
|
|
2
|
+
export * from "./tool";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
3
|
-
import { Tool as
|
|
4
|
-
|
|
1
|
+
import { CurrentUser } from '@services/app/core';
|
|
2
|
+
import type { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
3
|
+
import type { Tool as McpTool } from '@modelcontextprotocol/sdk/types.js';
|
|
5
4
|
interface InputSchema {
|
|
6
5
|
type: 'object';
|
|
7
6
|
properties: Record<string, {
|
|
@@ -15,12 +14,12 @@ interface InputSchema {
|
|
|
15
14
|
interface Output {
|
|
16
15
|
data: any;
|
|
17
16
|
}
|
|
18
|
-
interface BaseParams {
|
|
17
|
+
export interface BaseParams {
|
|
19
18
|
currentUser: CurrentUser;
|
|
20
19
|
sessionId: string;
|
|
21
20
|
answerId: string;
|
|
22
21
|
}
|
|
23
|
-
declare class Tool {
|
|
22
|
+
export declare class Tool {
|
|
24
23
|
readonly name: string;
|
|
25
24
|
readonly description: string;
|
|
26
25
|
readonly destructive: boolean;
|
|
@@ -34,9 +33,8 @@ declare class Tool {
|
|
|
34
33
|
handler: (...args: any[]) => Promise<Output>;
|
|
35
34
|
});
|
|
36
35
|
run(...args: any[]): Promise<Output>;
|
|
37
|
-
static fromMcp(mcpTool:
|
|
36
|
+
static fromMcp(mcpTool: McpTool, mcpClient: Client, opts: {
|
|
38
37
|
namespace: string;
|
|
39
38
|
}): Tool;
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
export { type BaseParams as B, Tool as T };
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
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 tool_exports = {};
|
|
20
|
+
__export(tool_exports, {
|
|
21
|
+
Tool: () => Tool
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(tool_exports);
|
|
24
|
+
class Tool {
|
|
25
|
+
name;
|
|
26
|
+
description;
|
|
27
|
+
destructive;
|
|
28
|
+
parameters;
|
|
29
|
+
handler;
|
|
30
|
+
constructor(props) {
|
|
31
|
+
this.name = props.name;
|
|
32
|
+
this.description = props.description;
|
|
33
|
+
this.destructive = props.destructive ?? false;
|
|
34
|
+
this.parameters = props.parameters;
|
|
35
|
+
this.handler = props.handler;
|
|
36
|
+
}
|
|
37
|
+
async run(...args) {
|
|
38
|
+
return this.handler(...args);
|
|
39
|
+
}
|
|
40
|
+
static fromMcp(mcpTool, mcpClient, opts) {
|
|
41
|
+
return new Tool({
|
|
42
|
+
name: `${opts.namespace}__${mcpTool.name}`,
|
|
43
|
+
description: mcpTool.description ?? "",
|
|
44
|
+
destructive: mcpTool.annotations?.destructiveHint ?? false,
|
|
45
|
+
parameters: mcpTool.inputSchema,
|
|
46
|
+
handler: async (params = {}) => {
|
|
47
|
+
const { currentUser, sessionId, answerId, ...args } = params;
|
|
48
|
+
const result = await mcpClient.callTool({ name: mcpTool.name, arguments: args });
|
|
49
|
+
return { data: result };
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
Tool
|
|
57
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import "../../../chunk-XRJFNASX.mjs";
|
|
2
|
+
class Tool {
|
|
3
|
+
name;
|
|
4
|
+
description;
|
|
5
|
+
destructive;
|
|
6
|
+
parameters;
|
|
7
|
+
handler;
|
|
8
|
+
constructor(props) {
|
|
9
|
+
this.name = props.name;
|
|
10
|
+
this.description = props.description;
|
|
11
|
+
this.destructive = props.destructive ?? false;
|
|
12
|
+
this.parameters = props.parameters;
|
|
13
|
+
this.handler = props.handler;
|
|
14
|
+
}
|
|
15
|
+
async run(...args) {
|
|
16
|
+
return this.handler(...args);
|
|
17
|
+
}
|
|
18
|
+
static fromMcp(mcpTool, mcpClient, opts) {
|
|
19
|
+
return new Tool({
|
|
20
|
+
name: `${opts.namespace}__${mcpTool.name}`,
|
|
21
|
+
description: mcpTool.description ?? "",
|
|
22
|
+
destructive: mcpTool.annotations?.destructiveHint ?? false,
|
|
23
|
+
parameters: mcpTool.inputSchema,
|
|
24
|
+
handler: async (params = {}) => {
|
|
25
|
+
const { currentUser, sessionId, answerId, ...args } = params;
|
|
26
|
+
const result = await mcpClient.callTool({ name: mcpTool.name, arguments: args });
|
|
27
|
+
return { data: result };
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
Tool
|
|
34
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Tool } from "../tools/tool";
|
|
2
|
+
export interface WeightedKeyword {
|
|
3
|
+
keyword: string;
|
|
4
|
+
weight: number;
|
|
5
|
+
}
|
|
6
|
+
export interface ScoredTool {
|
|
7
|
+
toolName: string;
|
|
8
|
+
score: number;
|
|
9
|
+
matchedKeywords: string[];
|
|
10
|
+
tool: Tool;
|
|
11
|
+
}
|
|
12
|
+
export declare function rankToolsByKeywords(keywords: WeightedKeyword[], tools: Tool[], minScoreThreshold?: number): ScoredTool[];
|
|
@@ -0,0 +1,65 @@
|
|
|
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 rank_tools_by_keywords_exports = {};
|
|
20
|
+
__export(rank_tools_by_keywords_exports, {
|
|
21
|
+
rankToolsByKeywords: () => rankToolsByKeywords
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(rank_tools_by_keywords_exports);
|
|
24
|
+
function escapeRegExp(text) {
|
|
25
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
26
|
+
}
|
|
27
|
+
function rankToolsByKeywords(keywords, tools, minScoreThreshold = 0.1) {
|
|
28
|
+
const NAME_WEIGHT_MULTIPLIER = 2.5;
|
|
29
|
+
const DESCRIPTION_WEIGHT_MULTIPLIER = 1;
|
|
30
|
+
const results = [];
|
|
31
|
+
for (const tool of tools) {
|
|
32
|
+
let totalScore = 0;
|
|
33
|
+
const matchedKeywordsSet = /* @__PURE__ */ new Set();
|
|
34
|
+
const normalizedName = tool.name.replace(/_/g, " ");
|
|
35
|
+
const normalizedDescription = tool.description || "";
|
|
36
|
+
for (const { keyword, weight } of keywords) {
|
|
37
|
+
if (!keyword || weight <= 0) continue;
|
|
38
|
+
const cleanKeyword = keyword.trim();
|
|
39
|
+
const escapedKeyword = escapeRegExp(cleanKeyword);
|
|
40
|
+
const regex = new RegExp(`\\b${escapedKeyword}\\b`, "gi");
|
|
41
|
+
const nameMatches = (normalizedName.match(regex) || []).length;
|
|
42
|
+
const descMatches = (normalizedDescription.match(regex) || []).length;
|
|
43
|
+
if (nameMatches > 0 || descMatches > 0) {
|
|
44
|
+
matchedKeywordsSet.add(cleanKeyword);
|
|
45
|
+
const nameScore = Math.sqrt(nameMatches) * NAME_WEIGHT_MULTIPLIER;
|
|
46
|
+
const descScore = Math.sqrt(descMatches) * DESCRIPTION_WEIGHT_MULTIPLIER;
|
|
47
|
+
const keywordContribution = (nameScore + descScore) * weight;
|
|
48
|
+
totalScore += keywordContribution;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (totalScore >= minScoreThreshold) {
|
|
52
|
+
results.push({
|
|
53
|
+
toolName: tool.name,
|
|
54
|
+
score: Number(totalScore.toFixed(4)),
|
|
55
|
+
matchedKeywords: Array.from(matchedKeywordsSet),
|
|
56
|
+
tool
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return results.sort((a, b) => b.score - a.score);
|
|
61
|
+
}
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
rankToolsByKeywords
|
|
65
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import "../../../chunk-XRJFNASX.mjs";
|
|
2
|
+
function escapeRegExp(text) {
|
|
3
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4
|
+
}
|
|
5
|
+
function rankToolsByKeywords(keywords, tools, minScoreThreshold = 0.1) {
|
|
6
|
+
const NAME_WEIGHT_MULTIPLIER = 2.5;
|
|
7
|
+
const DESCRIPTION_WEIGHT_MULTIPLIER = 1;
|
|
8
|
+
const results = [];
|
|
9
|
+
for (const tool of tools) {
|
|
10
|
+
let totalScore = 0;
|
|
11
|
+
const matchedKeywordsSet = /* @__PURE__ */ new Set();
|
|
12
|
+
const normalizedName = tool.name.replace(/_/g, " ");
|
|
13
|
+
const normalizedDescription = tool.description || "";
|
|
14
|
+
for (const { keyword, weight } of keywords) {
|
|
15
|
+
if (!keyword || weight <= 0) continue;
|
|
16
|
+
const cleanKeyword = keyword.trim();
|
|
17
|
+
const escapedKeyword = escapeRegExp(cleanKeyword);
|
|
18
|
+
const regex = new RegExp(`\\b${escapedKeyword}\\b`, "gi");
|
|
19
|
+
const nameMatches = (normalizedName.match(regex) || []).length;
|
|
20
|
+
const descMatches = (normalizedDescription.match(regex) || []).length;
|
|
21
|
+
if (nameMatches > 0 || descMatches > 0) {
|
|
22
|
+
matchedKeywordsSet.add(cleanKeyword);
|
|
23
|
+
const nameScore = Math.sqrt(nameMatches) * NAME_WEIGHT_MULTIPLIER;
|
|
24
|
+
const descScore = Math.sqrt(descMatches) * DESCRIPTION_WEIGHT_MULTIPLIER;
|
|
25
|
+
const keywordContribution = (nameScore + descScore) * weight;
|
|
26
|
+
totalScore += keywordContribution;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (totalScore >= minScoreThreshold) {
|
|
30
|
+
results.push({
|
|
31
|
+
toolName: tool.name,
|
|
32
|
+
score: Number(totalScore.toFixed(4)),
|
|
33
|
+
matchedKeywords: Array.from(matchedKeywordsSet),
|
|
34
|
+
tool
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return results.sort((a, b) => b.score - a.score);
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
rankToolsByKeywords
|
|
42
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { Params as CParams, Output as COutput } from '../modules/users/lambdas/create-user';
|
|
3
|
+
import { Params as UParams, Output as UOutput } from '../modules/users/lambdas/update-user';
|
|
4
|
+
import { Params as DParams, Output as DOutput } from '../modules/users/lambdas/delete-user';
|
|
5
|
+
import { Params as GParams, Output as GOutput } from '../modules/users/lambdas/get-user-by-id';
|
|
6
|
+
import { Params as LParams, Output as LOutput } from '../modules/authentication/lambdas/login';
|
|
7
|
+
export declare class App {
|
|
8
|
+
static createUser(params: CParams): Promise<COutput>;
|
|
9
|
+
static updateUser(params: UParams): Promise<UOutput>;
|
|
10
|
+
static deleteUser(params: DParams): Promise<DOutput>;
|
|
11
|
+
static getUser(params: GParams): Promise<GOutput>;
|
|
12
|
+
static getUserByExternalId(params: GParams): Promise<GOutput>;
|
|
13
|
+
static authenticateUser(params: LParams): Promise<LOutput>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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 app_exports = {};
|
|
20
|
+
__export(app_exports, {
|
|
21
|
+
App: () => App
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(app_exports);
|
|
24
|
+
var import_reflect_metadata = require("reflect-metadata");
|
|
25
|
+
var import_tsyringe = require("tsyringe");
|
|
26
|
+
var import_create_user = require("../modules/users/lambdas/create-user");
|
|
27
|
+
var import_update_user = require("../modules/users/lambdas/update-user");
|
|
28
|
+
var import_delete_user = require("../modules/users/lambdas/delete-user");
|
|
29
|
+
var import_get_user_by_id = require("../modules/users/lambdas/get-user-by-id");
|
|
30
|
+
var import_login = require("../modules/authentication/lambdas/login");
|
|
31
|
+
class App {
|
|
32
|
+
static async createUser(params) {
|
|
33
|
+
const createUserUseCase = import_tsyringe.container.resolve(import_create_user.CreateUserUseCase);
|
|
34
|
+
return await createUserUseCase.execute(params);
|
|
35
|
+
}
|
|
36
|
+
static async updateUser(params) {
|
|
37
|
+
const updateUserUseCase = import_tsyringe.container.resolve(import_update_user.UpdateUserUseCase);
|
|
38
|
+
return await updateUserUseCase.execute(params);
|
|
39
|
+
}
|
|
40
|
+
static async deleteUser(params) {
|
|
41
|
+
const deleteUserUseCase = import_tsyringe.container.resolve(import_delete_user.DeleteUserUseCase);
|
|
42
|
+
return await deleteUserUseCase.execute(params);
|
|
43
|
+
}
|
|
44
|
+
static async getUser(params) {
|
|
45
|
+
const getUserByIdUseCase = import_tsyringe.container.resolve(import_get_user_by_id.GetUserByIdUseCase);
|
|
46
|
+
return await getUserByIdUseCase.execute(params);
|
|
47
|
+
}
|
|
48
|
+
static async getUserByExternalId(params) {
|
|
49
|
+
const getUserByIdUseCase = import_tsyringe.container.resolve(import_get_user_by_id.GetUserByIdUseCase);
|
|
50
|
+
return await getUserByIdUseCase.execute(params);
|
|
51
|
+
}
|
|
52
|
+
static async authenticateUser(params) {
|
|
53
|
+
const loginUseCase = import_tsyringe.container.resolve(import_login.LoginUseCase);
|
|
54
|
+
return await loginUseCase.execute(params);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
App
|
|
60
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import "../../../chunk-XRJFNASX.mjs";
|
|
2
|
+
import "reflect-metadata";
|
|
3
|
+
import { container } from "tsyringe";
|
|
4
|
+
import {
|
|
5
|
+
CreateUserUseCase
|
|
6
|
+
} from "../modules/users/lambdas/create-user";
|
|
7
|
+
import {
|
|
8
|
+
UpdateUserUseCase
|
|
9
|
+
} from "../modules/users/lambdas/update-user";
|
|
10
|
+
import {
|
|
11
|
+
DeleteUserUseCase
|
|
12
|
+
} from "../modules/users/lambdas/delete-user";
|
|
13
|
+
import {
|
|
14
|
+
GetUserByIdUseCase
|
|
15
|
+
} from "../modules/users/lambdas/get-user-by-id";
|
|
16
|
+
import {
|
|
17
|
+
LoginUseCase
|
|
18
|
+
} from "../modules/authentication/lambdas/login";
|
|
19
|
+
class App {
|
|
20
|
+
static async createUser(params) {
|
|
21
|
+
const createUserUseCase = container.resolve(CreateUserUseCase);
|
|
22
|
+
return await createUserUseCase.execute(params);
|
|
23
|
+
}
|
|
24
|
+
static async updateUser(params) {
|
|
25
|
+
const updateUserUseCase = container.resolve(UpdateUserUseCase);
|
|
26
|
+
return await updateUserUseCase.execute(params);
|
|
27
|
+
}
|
|
28
|
+
static async deleteUser(params) {
|
|
29
|
+
const deleteUserUseCase = container.resolve(DeleteUserUseCase);
|
|
30
|
+
return await deleteUserUseCase.execute(params);
|
|
31
|
+
}
|
|
32
|
+
static async getUser(params) {
|
|
33
|
+
const getUserByIdUseCase = container.resolve(GetUserByIdUseCase);
|
|
34
|
+
return await getUserByIdUseCase.execute(params);
|
|
35
|
+
}
|
|
36
|
+
static async getUserByExternalId(params) {
|
|
37
|
+
const getUserByIdUseCase = container.resolve(GetUserByIdUseCase);
|
|
38
|
+
return await getUserByIdUseCase.execute(params);
|
|
39
|
+
}
|
|
40
|
+
static async authenticateUser(params) {
|
|
41
|
+
const loginUseCase = container.resolve(LoginUseCase);
|
|
42
|
+
return await loginUseCase.execute(params);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
App
|
|
47
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare class CurrentSession {
|
|
1
|
+
export declare class CurrentSession {
|
|
2
2
|
clientType?: ClientType | undefined;
|
|
3
3
|
environment?: ClientEnvironment | undefined;
|
|
4
4
|
app?: {
|
|
@@ -68,7 +68,7 @@ declare class CurrentSession {
|
|
|
68
68
|
xCurrentSessionHeader: string;
|
|
69
69
|
}): CurrentSession;
|
|
70
70
|
}
|
|
71
|
-
interface CurrentSessionProps {
|
|
71
|
+
export interface CurrentSessionProps {
|
|
72
72
|
clientType?: ClientType;
|
|
73
73
|
environment?: ClientEnvironment;
|
|
74
74
|
app?: {
|
|
@@ -112,7 +112,7 @@ declare enum ClientType {
|
|
|
112
112
|
DESKTOP = "desktop",
|
|
113
113
|
API = "api"
|
|
114
114
|
}
|
|
115
|
-
declare enum ClientEnvironment {
|
|
115
|
+
export declare enum ClientEnvironment {
|
|
116
116
|
PRODUCTION = "production",
|
|
117
117
|
STAGING = "staging",
|
|
118
118
|
DEVELOPMENT = "development"
|
|
@@ -126,5 +126,4 @@ declare enum DevicePlatform {
|
|
|
126
126
|
LAPTOP = "laptop",
|
|
127
127
|
TV = "tv"
|
|
128
128
|
}
|
|
129
|
-
|
|
130
|
-
export { CurrentSession as C, ClientEnvironment as a, type CurrentSessionProps as b };
|
|
129
|
+
export {};
|