vidspotai-shared 1.0.82 → 1.0.83
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/lib/globals/aiModels/enums.d.ts +11 -1
- package/lib/globals/aiModels/enums.d.ts.map +1 -1
- package/lib/globals/aiModels/enums.js +24 -1
- package/lib/globals/aiModels/index.d.ts.map +1 -1
- package/lib/globals/aiModels/index.js +2 -0
- package/lib/globals/aiModels/providers/anthropic.d.ts +12 -0
- package/lib/globals/aiModels/providers/anthropic.d.ts.map +1 -0
- package/lib/globals/aiModels/providers/anthropic.js +88 -0
- package/lib/globals/aiModels/providers/google.d.ts.map +1 -1
- package/lib/globals/aiModels/providers/google.js +82 -0
- package/lib/globals/aiModels/providers/openai.d.ts.map +1 -1
- package/lib/globals/aiModels/providers/openai.js +63 -4
- package/lib/globals/aiModels/tierHelpers.d.ts +12 -0
- package/lib/globals/aiModels/tierHelpers.d.ts.map +1 -1
- package/lib/globals/aiModels/tierHelpers.js +83 -0
- package/lib/globals/aiModels/types.d.ts +19 -0
- package/lib/globals/aiModels/types.d.ts.map +1 -1
- package/lib/globals/types.d.ts +120 -1
- package/lib/globals/types.d.ts.map +1 -1
- package/lib/globals/types.js +135 -1
- package/lib/models/agent.model.d.ts +41 -1
- package/lib/models/agent.model.d.ts.map +1 -1
- package/lib/models/index.d.ts +1 -0
- package/lib/models/index.d.ts.map +1 -1
- package/lib/models/index.js +1 -0
- package/lib/models/social.model.d.ts +180 -0
- package/lib/models/social.model.d.ts.map +1 -0
- package/lib/models/social.model.js +2 -0
- package/lib/models/user.model.d.ts +10 -0
- package/lib/models/user.model.d.ts.map +1 -1
- package/lib/models/video.model.d.ts +6 -0
- package/lib/models/video.model.d.ts.map +1 -1
- package/lib/schemas/brief.schema.d.ts +46 -0
- package/lib/schemas/brief.schema.d.ts.map +1 -1
- package/lib/schemas/brief.schema.js +72 -1
- package/lib/schemas/index.d.ts +1 -0
- package/lib/schemas/index.d.ts.map +1 -1
- package/lib/schemas/index.js +1 -0
- package/lib/schemas/project.schema.d.ts +67 -0
- package/lib/schemas/project.schema.d.ts.map +1 -1
- package/lib/schemas/project.schema.js +12 -0
- package/lib/schemas/social.schema.d.ts +91 -0
- package/lib/schemas/social.schema.d.ts.map +1 -0
- package/lib/schemas/social.schema.js +114 -0
- package/lib/schemas/videoPlan.schema.d.ts +114 -0
- package/lib/schemas/videoPlan.schema.d.ts.map +1 -1
- package/lib/schemas/videoPlan.schema.js +141 -1
- package/lib/services/agent/chatAgent.d.ts +25 -1
- package/lib/services/agent/chatAgent.d.ts.map +1 -1
- package/lib/services/agent/chatAgent.js +145 -9
- package/lib/services/agent/costPreflight.d.ts +11 -1
- package/lib/services/agent/costPreflight.d.ts.map +1 -1
- package/lib/services/agent/costPreflight.js +18 -1
- package/lib/services/agent/covers/coverPlanner.d.ts +41 -0
- package/lib/services/agent/covers/coverPlanner.d.ts.map +1 -0
- package/lib/services/agent/covers/coverPlanner.js +278 -0
- package/lib/services/agent/covers/covers.schema.d.ts +158 -0
- package/lib/services/agent/covers/covers.schema.d.ts.map +1 -0
- package/lib/services/agent/covers/covers.schema.js +166 -0
- package/lib/services/agent/covers/index.d.ts +3 -0
- package/lib/services/agent/covers/index.d.ts.map +1 -0
- package/lib/services/agent/covers/index.js +18 -0
- package/lib/services/agent/critic.d.ts +10 -0
- package/lib/services/agent/critic.d.ts.map +1 -1
- package/lib/services/agent/critic.js +37 -1
- package/lib/services/agent/editClassifier.d.ts +2 -2
- package/lib/services/agent/editClassifier.js +2 -2
- package/lib/services/agent/editExisting/editAssembler.d.ts +78 -0
- package/lib/services/agent/editExisting/editAssembler.d.ts.map +1 -0
- package/lib/services/agent/editExisting/editAssembler.js +172 -0
- package/lib/services/agent/editExisting/editExisting.schema.d.ts +119 -0
- package/lib/services/agent/editExisting/editExisting.schema.d.ts.map +1 -0
- package/lib/services/agent/editExisting/editExisting.schema.js +157 -0
- package/lib/services/agent/editExisting/highlightPicker.d.ts +48 -0
- package/lib/services/agent/editExisting/highlightPicker.d.ts.map +1 -0
- package/lib/services/agent/editExisting/highlightPicker.js +199 -0
- package/lib/services/agent/editExisting/index.d.ts +4 -0
- package/lib/services/agent/editExisting/index.d.ts.map +1 -0
- package/lib/services/agent/editExisting/index.js +19 -0
- package/lib/services/agent/eval/seedBriefs.d.ts +4 -3
- package/lib/services/agent/eval/seedBriefs.d.ts.map +1 -1
- package/lib/services/agent/eval/seedBriefs.js +283 -3
- package/lib/services/agent/eval/types.d.ts +10 -0
- package/lib/services/agent/eval/types.d.ts.map +1 -1
- package/lib/services/agent/executor/core.d.ts +70 -0
- package/lib/services/agent/executor/core.d.ts.map +1 -0
- package/lib/services/agent/executor/core.js +250 -0
- package/lib/services/agent/executor/duration.d.ts +20 -0
- package/lib/services/agent/executor/duration.d.ts.map +1 -0
- package/lib/services/agent/executor/duration.js +46 -0
- package/lib/services/agent/executor/index.d.ts +15 -0
- package/lib/services/agent/executor/index.d.ts.map +1 -0
- package/lib/services/agent/executor/index.js +32 -0
- package/lib/services/agent/executor/types.d.ts +183 -0
- package/lib/services/agent/executor/types.d.ts.map +1 -0
- package/lib/services/agent/executor/types.js +29 -0
- package/lib/services/agent/executor/visual.d.ts +32 -0
- package/lib/services/agent/executor/visual.d.ts.map +1 -0
- package/lib/services/agent/executor/visual.js +400 -0
- package/lib/services/agent/executor/voice.d.ts +17 -0
- package/lib/services/agent/executor/voice.d.ts.map +1 -0
- package/lib/services/agent/executor/voice.js +119 -0
- package/lib/services/agent/extendChain.d.ts +101 -0
- package/lib/services/agent/extendChain.d.ts.map +1 -0
- package/lib/services/agent/extendChain.js +177 -0
- package/lib/services/agent/index.d.ts +11 -1
- package/lib/services/agent/index.d.ts.map +1 -1
- package/lib/services/agent/index.js +11 -1
- package/lib/services/agent/llmCaller.d.ts +7 -8
- package/lib/services/agent/llmCaller.d.ts.map +1 -1
- package/lib/services/agent/llmCallerAnthropic.d.ts +44 -31
- package/lib/services/agent/llmCallerAnthropic.d.ts.map +1 -1
- package/lib/services/agent/llmCallerAnthropic.js +135 -60
- package/lib/services/agent/llmCallerFactory.d.ts +34 -0
- package/lib/services/agent/llmCallerFactory.d.ts.map +1 -0
- package/lib/services/agent/llmCallerFactory.js +31 -0
- package/lib/services/agent/llmCallerGemini.d.ts +62 -0
- package/lib/services/agent/llmCallerGemini.d.ts.map +1 -0
- package/lib/services/agent/llmCallerGemini.js +235 -0
- package/lib/services/agent/llmCallerOpenai.d.ts +56 -0
- package/lib/services/agent/llmCallerOpenai.d.ts.map +1 -0
- package/lib/services/agent/llmCallerOpenai.js +230 -0
- package/lib/services/agent/llmCallerRegistry.d.ts.map +1 -1
- package/lib/services/agent/llmCallerRegistry.js +7 -7
- package/lib/services/agent/llmCallerRouting.d.ts +63 -0
- package/lib/services/agent/llmCallerRouting.d.ts.map +1 -0
- package/lib/services/agent/llmCallerRouting.js +124 -0
- package/lib/services/agent/llmModelRegistry.d.ts +59 -0
- package/lib/services/agent/llmModelRegistry.d.ts.map +1 -0
- package/lib/services/agent/llmModelRegistry.js +168 -0
- package/lib/services/agent/llmRetry.d.ts +57 -0
- package/lib/services/agent/llmRetry.d.ts.map +1 -0
- package/lib/services/agent/llmRetry.js +102 -0
- package/lib/services/agent/modelRouter.d.ts +3 -3
- package/lib/services/agent/modelRouter.d.ts.map +1 -1
- package/lib/services/agent/modelRouter.js +27 -13
- package/lib/services/agent/planMutations.d.ts +54 -1
- package/lib/services/agent/planMutations.d.ts.map +1 -1
- package/lib/services/agent/planMutations.js +78 -0
- package/lib/services/agent/planner/Planner.d.ts +0 -17
- package/lib/services/agent/planner/Planner.d.ts.map +1 -1
- package/lib/services/agent/planner/Planner.js +67 -303
- package/lib/services/agent/planner/overlayRegen.d.ts +38 -0
- package/lib/services/agent/planner/overlayRegen.d.ts.map +1 -0
- package/lib/services/agent/planner/overlayRegen.js +145 -0
- package/lib/services/agent/planner/plannerMessages.d.ts +34 -0
- package/lib/services/agent/planner/plannerMessages.d.ts.map +1 -0
- package/lib/services/agent/planner/plannerMessages.js +185 -0
- package/lib/services/agent/planner/promptSections.d.ts +12 -0
- package/lib/services/agent/planner/promptSections.d.ts.map +1 -1
- package/lib/services/agent/planner/promptSections.js +57 -0
- package/lib/services/agent/planner/scriptFirstPlanner.d.ts +35 -0
- package/lib/services/agent/planner/scriptFirstPlanner.d.ts.map +1 -0
- package/lib/services/agent/planner/scriptFirstPlanner.js +140 -0
- package/lib/services/agent/planner/structuralRules.d.ts +10 -0
- package/lib/services/agent/planner/structuralRules.d.ts.map +1 -1
- package/lib/services/agent/planner/structuralRules.js +92 -9
- package/lib/services/agent/planner/validators.d.ts +18 -0
- package/lib/services/agent/planner/validators.d.ts.map +1 -1
- package/lib/services/agent/planner/validators.js +97 -0
- package/lib/services/agent/planner.d.ts +2 -1
- package/lib/services/agent/planner.d.ts.map +1 -1
- package/lib/services/agent/planner.js +5 -1
- package/lib/services/agent/priorProject.d.ts +26 -0
- package/lib/services/agent/priorProject.d.ts.map +1 -0
- package/lib/services/agent/priorProject.js +51 -0
- package/lib/services/agent/providerFallback/chains.d.ts.map +1 -1
- package/lib/services/agent/providerFallback/chains.js +27 -15
- package/lib/services/agent/repurpose/index.d.ts +3 -0
- package/lib/services/agent/repurpose/index.d.ts.map +1 -0
- package/lib/services/agent/repurpose/index.js +18 -0
- package/lib/services/agent/repurpose/repurpose.schema.d.ts +132 -0
- package/lib/services/agent/repurpose/repurpose.schema.d.ts.map +1 -0
- package/lib/services/agent/repurpose/repurpose.schema.js +144 -0
- package/lib/services/agent/repurpose/shortsPicker.d.ts +25 -0
- package/lib/services/agent/repurpose/shortsPicker.d.ts.map +1 -0
- package/lib/services/agent/repurpose/shortsPicker.js +218 -0
- package/lib/services/agent/runHelpers.d.ts +21 -2
- package/lib/services/agent/runHelpers.d.ts.map +1 -1
- package/lib/services/agent/runHelpers.js +71 -2
- package/lib/services/agent/tools/animateImage.tool.d.ts +1 -0
- package/lib/services/agent/tools/animateImage.tool.d.ts.map +1 -1
- package/lib/services/agent/tools/animateImage.tool.js +12 -0
- package/lib/services/agent/tools/chapterOutline.tool.d.ts +42 -0
- package/lib/services/agent/tools/chapterOutline.tool.d.ts.map +1 -0
- package/lib/services/agent/tools/chapterOutline.tool.js +115 -0
- package/lib/services/agent/tools/composeScene.tool.d.ts +63 -0
- package/lib/services/agent/tools/composeScene.tool.d.ts.map +1 -1
- package/lib/services/agent/tools/estimateCost.tool.d.ts +27 -0
- package/lib/services/agent/tools/estimateCost.tool.d.ts.map +1 -1
- package/lib/services/agent/tools/estimateCost.tool.js +55 -7
- package/lib/services/agent/tools/extendVideo.tool.d.ts +26 -0
- package/lib/services/agent/tools/extendVideo.tool.d.ts.map +1 -0
- package/lib/services/agent/tools/extendVideo.tool.js +149 -0
- package/lib/services/agent/tools/generateScript.tool.d.ts +184 -0
- package/lib/services/agent/tools/generateScript.tool.d.ts.map +1 -0
- package/lib/services/agent/tools/generateScript.tool.js +123 -0
- package/lib/services/agent/tools/generateVideo.tool.d.ts +1 -0
- package/lib/services/agent/tools/generateVideo.tool.d.ts.map +1 -1
- package/lib/services/agent/tools/generateVideo.tool.js +20 -1
- package/lib/services/agent/tools/index.d.ts +4 -0
- package/lib/services/agent/tools/index.d.ts.map +1 -1
- package/lib/services/agent/tools/index.js +4 -0
- package/lib/services/agent/tools/matchBrollToScript.tool.d.ts +50 -0
- package/lib/services/agent/tools/matchBrollToScript.tool.d.ts.map +1 -0
- package/lib/services/agent/tools/matchBrollToScript.tool.js +139 -0
- package/lib/services/agent/tools/planVideo.tool.d.ts +56 -0
- package/lib/services/agent/tools/planVideo.tool.d.ts.map +1 -1
- package/lib/services/agent/tools/planVideo.tool.js +3 -3
- package/lib/services/agent/tools/render.tool.d.ts +21 -0
- package/lib/services/agent/tools/render.tool.d.ts.map +1 -1
- package/lib/services/aiGen/aiGenFactory.service.d.ts.map +1 -1
- package/lib/services/aiGen/aiGenFactory.service.js +18 -3
- package/lib/services/aiGen/providers/anthropic/anthropic.service.d.ts +26 -0
- package/lib/services/aiGen/providers/anthropic/anthropic.service.d.ts.map +1 -0
- package/lib/services/aiGen/providers/anthropic/anthropic.service.js +95 -0
- package/lib/services/aiGen/providers/google/google.service.d.ts +24 -1
- package/lib/services/aiGen/providers/google/google.service.d.ts.map +1 -1
- package/lib/services/aiGen/providers/google/google.service.js +87 -243
- package/lib/services/aiGen/providers/google/googleErrors.d.ts +13 -0
- package/lib/services/aiGen/providers/google/googleErrors.d.ts.map +1 -0
- package/lib/services/aiGen/providers/google/googleErrors.js +102 -0
- package/lib/services/aiGen/providers/google/googleFetch.d.ts +8 -0
- package/lib/services/aiGen/providers/google/googleFetch.d.ts.map +1 -0
- package/lib/services/aiGen/providers/google/googleFetch.js +96 -0
- package/lib/services/aiGen/providers/google/googleMusic.d.ts +15 -0
- package/lib/services/aiGen/providers/google/googleMusic.d.ts.map +1 -0
- package/lib/services/aiGen/providers/google/googleMusic.js +77 -0
- package/lib/services/aiGen/providers/kling/kling.service.d.ts +7 -3
- package/lib/services/aiGen/providers/kling/kling.service.d.ts.map +1 -1
- package/lib/services/aiGen/providers/kling/kling.service.js +23 -367
- package/lib/services/aiGen/providers/kling/klingCredits.d.ts +9 -0
- package/lib/services/aiGen/providers/kling/klingCredits.d.ts.map +1 -0
- package/lib/services/aiGen/providers/kling/klingCredits.js +63 -0
- package/lib/services/aiGen/providers/kling/klingRequests.d.ts +32 -0
- package/lib/services/aiGen/providers/kling/klingRequests.d.ts.map +1 -0
- package/lib/services/aiGen/providers/kling/klingRequests.js +194 -0
- package/lib/services/aiGen/providers/kling/klingStatus.d.ts +16 -0
- package/lib/services/aiGen/providers/kling/klingStatus.d.ts.map +1 -0
- package/lib/services/aiGen/providers/kling/klingStatus.js +173 -0
- package/lib/services/bullmq.service.d.ts +61 -0
- package/lib/services/bullmq.service.d.ts.map +1 -1
- package/lib/services/bullmq.service.js +101 -1
- package/lib/services/crypto/index.d.ts +2 -0
- package/lib/services/crypto/index.d.ts.map +1 -0
- package/lib/services/crypto/index.js +17 -0
- package/lib/services/crypto/tokenVault.d.ts +47 -0
- package/lib/services/crypto/tokenVault.d.ts.map +1 -0
- package/lib/services/crypto/tokenVault.js +179 -0
- package/lib/services/editor/captionStyleHint.d.ts +3 -0
- package/lib/services/editor/captionStyleHint.d.ts.map +1 -0
- package/lib/services/editor/captionStyleHint.js +112 -0
- package/lib/services/editor/planToProject.d.ts +7 -66
- package/lib/services/editor/planToProject.d.ts.map +1 -1
- package/lib/services/editor/planToProject.helpers.d.ts +40 -0
- package/lib/services/editor/planToProject.helpers.d.ts.map +1 -0
- package/lib/services/editor/planToProject.helpers.js +177 -0
- package/lib/services/editor/planToProject.js +197 -180
- package/lib/services/editor/planToProject.types.d.ts +94 -0
- package/lib/services/editor/planToProject.types.d.ts.map +1 -0
- package/lib/services/editor/planToProject.types.js +2 -0
- package/lib/services/firestore.service.d.ts +5 -0
- package/lib/services/firestore.service.d.ts.map +1 -1
- package/lib/services/firestore.service.js +13 -0
- package/lib/services/index.d.ts +12 -0
- package/lib/services/index.d.ts.map +1 -1
- package/lib/services/index.js +12 -0
- package/lib/services/promptEnhancer/index.d.ts +18 -0
- package/lib/services/promptEnhancer/index.d.ts.map +1 -0
- package/lib/services/promptEnhancer/index.js +33 -0
- package/lib/services/promptEnhancer/models.d.ts +54 -0
- package/lib/services/promptEnhancer/models.d.ts.map +1 -0
- package/lib/services/promptEnhancer/models.js +37 -0
- package/lib/services/promptEnhancer/profiles/agent.profile.d.ts +14 -0
- package/lib/services/promptEnhancer/profiles/agent.profile.d.ts.map +1 -0
- package/lib/services/promptEnhancer/profiles/agent.profile.js +40 -0
- package/lib/services/promptEnhancer/profiles/avatar.profile.d.ts +13 -0
- package/lib/services/promptEnhancer/profiles/avatar.profile.d.ts.map +1 -0
- package/lib/services/promptEnhancer/profiles/avatar.profile.js +40 -0
- package/lib/services/promptEnhancer/profiles/base.d.ts +28 -0
- package/lib/services/promptEnhancer/profiles/base.d.ts.map +1 -0
- package/lib/services/promptEnhancer/profiles/base.js +35 -0
- package/lib/services/promptEnhancer/profiles/image.profile.d.ts +11 -0
- package/lib/services/promptEnhancer/profiles/image.profile.d.ts.map +1 -0
- package/lib/services/promptEnhancer/profiles/image.profile.js +42 -0
- package/lib/services/promptEnhancer/profiles/index.d.ts +12 -0
- package/lib/services/promptEnhancer/profiles/index.d.ts.map +1 -0
- package/lib/services/promptEnhancer/profiles/index.js +33 -0
- package/lib/services/promptEnhancer/profiles/video.profile.d.ts +15 -0
- package/lib/services/promptEnhancer/profiles/video.profile.d.ts.map +1 -0
- package/lib/services/promptEnhancer/profiles/video.profile.js +81 -0
- package/lib/services/promptEnhancer/promptEnhancer.service.d.ts +45 -0
- package/lib/services/promptEnhancer/promptEnhancer.service.d.ts.map +1 -0
- package/lib/services/promptEnhancer/promptEnhancer.service.js +157 -0
- package/lib/services/promptEnhancer/schema.d.ts +19 -0
- package/lib/services/promptEnhancer/schema.d.ts.map +1 -0
- package/lib/services/promptEnhancer/schema.js +43 -0
- package/lib/services/promptEnhancer/types.d.ts +112 -0
- package/lib/services/promptEnhancer/types.d.ts.map +1 -0
- package/lib/services/promptEnhancer/types.js +2 -0
- package/lib/services/socialAI/captionGen.d.ts +81 -0
- package/lib/services/socialAI/captionGen.d.ts.map +1 -0
- package/lib/services/socialAI/captionGen.js +206 -0
- package/lib/services/socialAI/hookScore.d.ts +85 -0
- package/lib/services/socialAI/hookScore.d.ts.map +1 -0
- package/lib/services/socialAI/hookScore.js +170 -0
- package/lib/services/socialAI/index.d.ts +3 -0
- package/lib/services/socialAI/index.d.ts.map +1 -0
- package/lib/services/socialAI/index.js +18 -0
- package/lib/services/socialAccounts/index.d.ts +2 -0
- package/lib/services/socialAccounts/index.d.ts.map +1 -0
- package/lib/services/socialAccounts/index.js +17 -0
- package/lib/services/socialAccounts/socialAccountService.d.ts +25 -0
- package/lib/services/socialAccounts/socialAccountService.d.ts.map +1 -0
- package/lib/services/socialAccounts/socialAccountService.js +105 -0
- package/lib/services/socialEngage/factory.d.ts +7 -0
- package/lib/services/socialEngage/factory.d.ts.map +1 -0
- package/lib/services/socialEngage/factory.js +25 -0
- package/lib/services/socialEngage/index.d.ts +6 -0
- package/lib/services/socialEngage/index.d.ts.map +1 -0
- package/lib/services/socialEngage/index.js +21 -0
- package/lib/services/socialEngage/meta.engage.d.ts +17 -0
- package/lib/services/socialEngage/meta.engage.d.ts.map +1 -0
- package/lib/services/socialEngage/meta.engage.js +128 -0
- package/lib/services/socialEngage/metaWebhook.d.ts +50 -0
- package/lib/services/socialEngage/metaWebhook.d.ts.map +1 -0
- package/lib/services/socialEngage/metaWebhook.js +93 -0
- package/lib/services/socialEngage/types.d.ts +72 -0
- package/lib/services/socialEngage/types.d.ts.map +1 -0
- package/lib/services/socialEngage/types.js +10 -0
- package/lib/services/socialEngage/youtube.engage.d.ts +9 -0
- package/lib/services/socialEngage/youtube.engage.d.ts.map +1 -0
- package/lib/services/socialEngage/youtube.engage.js +87 -0
- package/lib/services/socialFormat/aspectGeometry.d.ts +74 -0
- package/lib/services/socialFormat/aspectGeometry.d.ts.map +1 -0
- package/lib/services/socialFormat/aspectGeometry.js +135 -0
- package/lib/services/socialFormat/index.d.ts +2 -0
- package/lib/services/socialFormat/index.d.ts.map +1 -0
- package/lib/services/socialFormat/index.js +19 -0
- package/lib/services/socialInsights/index.d.ts +3 -0
- package/lib/services/socialInsights/index.d.ts.map +1 -0
- package/lib/services/socialInsights/index.js +18 -0
- package/lib/services/socialInsights/recommendations.d.ts +131 -0
- package/lib/services/socialInsights/recommendations.d.ts.map +1 -0
- package/lib/services/socialInsights/recommendations.js +277 -0
- package/lib/services/socialInsights/timeBuckets.d.ts +35 -0
- package/lib/services/socialInsights/timeBuckets.d.ts.map +1 -0
- package/lib/services/socialInsights/timeBuckets.js +78 -0
- package/lib/services/socialMetrics/factory.d.ts +5 -0
- package/lib/services/socialMetrics/factory.d.ts.map +1 -0
- package/lib/services/socialMetrics/factory.js +24 -0
- package/lib/services/socialMetrics/index.d.ts +6 -0
- package/lib/services/socialMetrics/index.d.ts.map +1 -0
- package/lib/services/socialMetrics/index.js +21 -0
- package/lib/services/socialMetrics/meta.metrics.d.ts +22 -0
- package/lib/services/socialMetrics/meta.metrics.d.ts.map +1 -0
- package/lib/services/socialMetrics/meta.metrics.js +137 -0
- package/lib/services/socialMetrics/tiktok.metrics.d.ts +8 -0
- package/lib/services/socialMetrics/tiktok.metrics.d.ts.map +1 -0
- package/lib/services/socialMetrics/tiktok.metrics.js +43 -0
- package/lib/services/socialMetrics/types.d.ts +54 -0
- package/lib/services/socialMetrics/types.d.ts.map +1 -0
- package/lib/services/socialMetrics/types.js +2 -0
- package/lib/services/socialMetrics/youtube.metrics.d.ts +8 -0
- package/lib/services/socialMetrics/youtube.metrics.d.ts.map +1 -0
- package/lib/services/socialMetrics/youtube.metrics.js +43 -0
- package/lib/services/socialOAuth/factory.d.ts +7 -0
- package/lib/services/socialOAuth/factory.d.ts.map +1 -0
- package/lib/services/socialOAuth/factory.js +42 -0
- package/lib/services/socialOAuth/index.d.ts +11 -0
- package/lib/services/socialOAuth/index.d.ts.map +1 -0
- package/lib/services/socialOAuth/index.js +26 -0
- package/lib/services/socialOAuth/linkedin.oauth.d.ts +14 -0
- package/lib/services/socialOAuth/linkedin.oauth.d.ts.map +1 -0
- package/lib/services/socialOAuth/linkedin.oauth.js +127 -0
- package/lib/services/socialOAuth/meta.oauth.d.ts +31 -0
- package/lib/services/socialOAuth/meta.oauth.d.ts.map +1 -0
- package/lib/services/socialOAuth/meta.oauth.js +214 -0
- package/lib/services/socialOAuth/oauthState.d.ts +14 -0
- package/lib/services/socialOAuth/oauthState.d.ts.map +1 -0
- package/lib/services/socialOAuth/oauthState.js +66 -0
- package/lib/services/socialOAuth/pinterest.oauth.d.ts +15 -0
- package/lib/services/socialOAuth/pinterest.oauth.d.ts.map +1 -0
- package/lib/services/socialOAuth/pinterest.oauth.js +126 -0
- package/lib/services/socialOAuth/threads.oauth.d.ts +14 -0
- package/lib/services/socialOAuth/threads.oauth.d.ts.map +1 -0
- package/lib/services/socialOAuth/threads.oauth.js +129 -0
- package/lib/services/socialOAuth/tiktok.oauth.d.ts +15 -0
- package/lib/services/socialOAuth/tiktok.oauth.d.ts.map +1 -0
- package/lib/services/socialOAuth/tiktok.oauth.js +151 -0
- package/lib/services/socialOAuth/types.d.ts +67 -0
- package/lib/services/socialOAuth/types.d.ts.map +1 -0
- package/lib/services/socialOAuth/types.js +2 -0
- package/lib/services/socialOAuth/x.oauth.d.ts +17 -0
- package/lib/services/socialOAuth/x.oauth.d.ts.map +1 -0
- package/lib/services/socialOAuth/x.oauth.js +134 -0
- package/lib/services/socialOAuth/youtube.oauth.d.ts +15 -0
- package/lib/services/socialOAuth/youtube.oauth.d.ts.map +1 -0
- package/lib/services/socialOAuth/youtube.oauth.js +156 -0
- package/lib/services/socialPublish/factory.d.ts +5 -0
- package/lib/services/socialPublish/factory.d.ts.map +1 -0
- package/lib/services/socialPublish/factory.js +32 -0
- package/lib/services/socialPublish/index.d.ts +10 -0
- package/lib/services/socialPublish/index.d.ts.map +1 -0
- package/lib/services/socialPublish/index.js +25 -0
- package/lib/services/socialPublish/linkedin.publish.d.ts +9 -0
- package/lib/services/socialPublish/linkedin.publish.d.ts.map +1 -0
- package/lib/services/socialPublish/linkedin.publish.js +143 -0
- package/lib/services/socialPublish/meta.publish.d.ts +28 -0
- package/lib/services/socialPublish/meta.publish.d.ts.map +1 -0
- package/lib/services/socialPublish/meta.publish.js +149 -0
- package/lib/services/socialPublish/pinterest.publish.d.ts +13 -0
- package/lib/services/socialPublish/pinterest.publish.d.ts.map +1 -0
- package/lib/services/socialPublish/pinterest.publish.js +130 -0
- package/lib/services/socialPublish/threads.publish.d.ts +12 -0
- package/lib/services/socialPublish/threads.publish.d.ts.map +1 -0
- package/lib/services/socialPublish/threads.publish.js +96 -0
- package/lib/services/socialPublish/tiktok.publish.d.ts +13 -0
- package/lib/services/socialPublish/tiktok.publish.d.ts.map +1 -0
- package/lib/services/socialPublish/tiktok.publish.js +118 -0
- package/lib/services/socialPublish/types.d.ts +47 -0
- package/lib/services/socialPublish/types.d.ts.map +1 -0
- package/lib/services/socialPublish/types.js +2 -0
- package/lib/services/socialPublish/x.publish.d.ts +12 -0
- package/lib/services/socialPublish/x.publish.d.ts.map +1 -0
- package/lib/services/socialPublish/x.publish.js +147 -0
- package/lib/services/socialPublish/youtube.publish.d.ts +9 -0
- package/lib/services/socialPublish/youtube.publish.d.ts.map +1 -0
- package/lib/services/socialPublish/youtube.publish.js +107 -0
- package/lib/services/stock/index.d.ts +2 -0
- package/lib/services/stock/index.d.ts.map +1 -0
- package/lib/services/stock/index.js +17 -0
- package/lib/services/stock/realPersonSafety.d.ts +99 -0
- package/lib/services/stock/realPersonSafety.d.ts.map +1 -0
- package/lib/services/stock/realPersonSafety.js +248 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +1 -0
- package/lib/utils/renderTier.d.ts +26 -0
- package/lib/utils/renderTier.d.ts.map +1 -0
- package/lib/utils/renderTier.js +34 -0
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { VideoGenerationParams } from "../types";
|
|
2
|
+
import { KlingAvatarGenerateRequest, KlingImageToVideoRequest, KlingLipSyncRequest, KlingMotionControlRequest, KlingOmniVideoRequest, KlingVideoGenerateRequest } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Pure request-body builders mapping our provider-agnostic
|
|
5
|
+
* VideoGenerationParams onto Kling's per-endpoint request shapes. No I/O —
|
|
6
|
+
* KlingService calls these, then submits the result. Keeping them here makes
|
|
7
|
+
* the per-endpoint field wiring testable in isolation and the service class a
|
|
8
|
+
* thin dispatcher.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* text2video / image2video body. Routes by the presence of inputImageUrl and
|
|
12
|
+
* wires the shared optional fields (negative prompt, cfg, camera control,
|
|
13
|
+
* audio/sound tier) plus the i2v-only mask / tail-frame fields.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildVideoGenerateRequest(params: VideoGenerationParams, modelId: string): KlingVideoGenerateRequest | KlingImageToVideoRequest;
|
|
16
|
+
/** Video-extend body (continue a prior Kling task by its video_id). */
|
|
17
|
+
export declare function buildExtendBody(params: VideoGenerationParams): Record<string, unknown>;
|
|
18
|
+
/** OmniVideo body: start/end/reference frames, reference videos, multi-shot. */
|
|
19
|
+
export declare function buildOmniVideoBody(params: VideoGenerationParams, modelId: string): KlingOmniVideoRequest;
|
|
20
|
+
/** Motion-control body (character image + motion reference video). */
|
|
21
|
+
export declare function buildMotionControlBody(params: VideoGenerationParams, modelId: string): KlingMotionControlRequest;
|
|
22
|
+
/** Avatar (image+audio → lipsync video) body. */
|
|
23
|
+
export declare function buildAvatarRequest(params: VideoGenerationParams): KlingAvatarGenerateRequest;
|
|
24
|
+
/**
|
|
25
|
+
* Advanced-lip-sync body. Takes the resolved face (from identify-face) and the
|
|
26
|
+
* session id; auto-selects the first detected face's window for the audio.
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildLipSyncBody(params: VideoGenerationParams, sessionId: string, face: {
|
|
29
|
+
face_id: string;
|
|
30
|
+
start_time: number;
|
|
31
|
+
}): KlingLipSyncRequest;
|
|
32
|
+
//# sourceMappingURL=klingRequests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"klingRequests.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/kling/klingRequests.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD,OAAO,EAEL,0BAA0B,EAE1B,wBAAwB,EACxB,mBAAmB,EAEnB,yBAAyB,EACzB,qBAAqB,EACrB,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAEjB;;;;;;GAMG;AAEH;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,qBAAqB,EAC7B,OAAO,EAAE,MAAM,GACd,yBAAyB,GAAG,wBAAwB,CAmDtD;AAED,uEAAuE;AACvE,wBAAgB,eAAe,CAC7B,MAAM,EAAE,qBAAqB,GAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQzB;AAED,gFAAgF;AAChF,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,qBAAqB,EAC7B,OAAO,EAAE,MAAM,GACd,qBAAqB,CA8CvB;AAED,sEAAsE;AACtE,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,qBAAqB,EAC7B,OAAO,EAAE,MAAM,GACd,yBAAyB,CAW3B;AAED,iDAAiD;AACjD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,qBAAqB,GAC5B,0BAA0B,CAS5B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,qBAAqB,EAC7B,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAC5C,mBAAmB,CAgBrB"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildVideoGenerateRequest = buildVideoGenerateRequest;
|
|
4
|
+
exports.buildExtendBody = buildExtendBody;
|
|
5
|
+
exports.buildOmniVideoBody = buildOmniVideoBody;
|
|
6
|
+
exports.buildMotionControlBody = buildMotionControlBody;
|
|
7
|
+
exports.buildAvatarRequest = buildAvatarRequest;
|
|
8
|
+
exports.buildLipSyncBody = buildLipSyncBody;
|
|
9
|
+
const types_1 = require("../../types");
|
|
10
|
+
const cameraAdapter_1 = require("./cameraAdapter");
|
|
11
|
+
/**
|
|
12
|
+
* Pure request-body builders mapping our provider-agnostic
|
|
13
|
+
* VideoGenerationParams onto Kling's per-endpoint request shapes. No I/O —
|
|
14
|
+
* KlingService calls these, then submits the result. Keeping them here makes
|
|
15
|
+
* the per-endpoint field wiring testable in isolation and the service class a
|
|
16
|
+
* thin dispatcher.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* text2video / image2video body. Routes by the presence of inputImageUrl and
|
|
20
|
+
* wires the shared optional fields (negative prompt, cfg, camera control,
|
|
21
|
+
* audio/sound tier) plus the i2v-only mask / tail-frame fields.
|
|
22
|
+
*/
|
|
23
|
+
function buildVideoGenerateRequest(params, modelId) {
|
|
24
|
+
// Common optional fields shared by text2video and image2video endpoints.
|
|
25
|
+
const optional = {};
|
|
26
|
+
if (params.negativePrompt)
|
|
27
|
+
optional.negative_prompt = params.negativePrompt;
|
|
28
|
+
if (params.cfgScale !== undefined)
|
|
29
|
+
optional.cfg_scale = params.cfgScale;
|
|
30
|
+
if (params.callbackUrl)
|
|
31
|
+
optional.callback_url = params.callbackUrl;
|
|
32
|
+
if (params.externalTaskId)
|
|
33
|
+
optional.external_task_id = params.externalTaskId;
|
|
34
|
+
if (params.cameraControl) {
|
|
35
|
+
const cc = (0, cameraAdapter_1.toKlingCameraControl)(params.cameraControl);
|
|
36
|
+
if (cc)
|
|
37
|
+
optional.camera_control = cc;
|
|
38
|
+
}
|
|
39
|
+
// v2.6 uses `sound: "on"|"off"` as a pricing-tier toggle. v3 uses
|
|
40
|
+
// `generate_audio: boolean` for native audio synthesis. Route by model.
|
|
41
|
+
if (params.audio !== undefined) {
|
|
42
|
+
if (params.modelKey === "kling-v3.0") {
|
|
43
|
+
optional.generate_audio = Boolean(params.audio);
|
|
44
|
+
}
|
|
45
|
+
else if (params.modelKey === "kling-v2.6") {
|
|
46
|
+
optional.sound = params.audio ? "on" : "off";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const isImageToVideo = !!params.inputImageUrl;
|
|
50
|
+
if (isImageToVideo) {
|
|
51
|
+
const i2v = {
|
|
52
|
+
model_name: modelId,
|
|
53
|
+
prompt: params.prompt,
|
|
54
|
+
image: params.inputImageUrl,
|
|
55
|
+
duration: params.duration || 5,
|
|
56
|
+
mode: params.mode || types_1.EVideoMode.STANDARD,
|
|
57
|
+
...optional,
|
|
58
|
+
};
|
|
59
|
+
if (params.aspectRatio)
|
|
60
|
+
i2v.aspect_ratio = params.aspectRatio;
|
|
61
|
+
if (params.lastFrameImageUrl)
|
|
62
|
+
i2v.image_tail = params.lastFrameImageUrl;
|
|
63
|
+
if (params.staticMaskUrl)
|
|
64
|
+
i2v.static_mask = params.staticMaskUrl;
|
|
65
|
+
if (params.dynamicMasks?.length) {
|
|
66
|
+
i2v.dynamic_masks = params.dynamicMasks.slice(0, 6).map((d) => ({
|
|
67
|
+
mask: d.maskUrl,
|
|
68
|
+
trajectories: d.trajectories,
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
return i2v;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
model_name: modelId,
|
|
75
|
+
prompt: params.prompt,
|
|
76
|
+
aspect_ratio: params.aspectRatio || "16:9",
|
|
77
|
+
duration: params.duration || 5,
|
|
78
|
+
mode: params.mode || types_1.EVideoMode.STANDARD,
|
|
79
|
+
...optional,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** Video-extend body (continue a prior Kling task by its video_id). */
|
|
83
|
+
function buildExtendBody(params) {
|
|
84
|
+
const body = { video_id: params.sourceTaskId };
|
|
85
|
+
if (params.prompt)
|
|
86
|
+
body.prompt = params.prompt;
|
|
87
|
+
if (params.negativePrompt)
|
|
88
|
+
body.negative_prompt = params.negativePrompt;
|
|
89
|
+
if (params.cfgScale !== undefined)
|
|
90
|
+
body.cfg_scale = params.cfgScale;
|
|
91
|
+
if (params.callbackUrl)
|
|
92
|
+
body.callback_url = params.callbackUrl;
|
|
93
|
+
if (params.externalTaskId)
|
|
94
|
+
body.external_task_id = params.externalTaskId;
|
|
95
|
+
return body;
|
|
96
|
+
}
|
|
97
|
+
/** OmniVideo body: start/end/reference frames, reference videos, multi-shot. */
|
|
98
|
+
function buildOmniVideoBody(params, modelId) {
|
|
99
|
+
const body = {
|
|
100
|
+
model_name: modelId,
|
|
101
|
+
mode: params.mode || types_1.EVideoMode.STANDARD,
|
|
102
|
+
duration: String(params.duration ?? 5),
|
|
103
|
+
};
|
|
104
|
+
if (params.prompt)
|
|
105
|
+
body.prompt = params.prompt;
|
|
106
|
+
if (params.aspectRatio)
|
|
107
|
+
body.aspect_ratio = params.aspectRatio;
|
|
108
|
+
if (params.callbackUrl)
|
|
109
|
+
body.callback_url = params.callbackUrl;
|
|
110
|
+
if (params.externalTaskId)
|
|
111
|
+
body.external_task_id = params.externalTaskId;
|
|
112
|
+
if (params.audio !== undefined)
|
|
113
|
+
body.sound = params.audio ? "on" : "off";
|
|
114
|
+
// Build image_list: start frame, end frame, plain reference images.
|
|
115
|
+
const imageList = [];
|
|
116
|
+
if (params.inputImageUrl) {
|
|
117
|
+
imageList.push({ image_url: params.inputImageUrl, type: "first_frame" });
|
|
118
|
+
}
|
|
119
|
+
if (params.lastFrameImageUrl) {
|
|
120
|
+
imageList.push({ image_url: params.lastFrameImageUrl, type: "end_frame" });
|
|
121
|
+
}
|
|
122
|
+
for (const url of params.referenceImageUrls ?? []) {
|
|
123
|
+
imageList.push({ image_url: url });
|
|
124
|
+
}
|
|
125
|
+
if (imageList.length)
|
|
126
|
+
body.image_list = imageList;
|
|
127
|
+
// Build video_list: reference videos (feature type) or base videos (editing).
|
|
128
|
+
if (params.referenceVideoUrls?.length) {
|
|
129
|
+
body.video_list = params.referenceVideoUrls.map((url) => ({
|
|
130
|
+
video_url: url,
|
|
131
|
+
refer_type: "feature",
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
// Multi-shot support. MultiShot is Shot[] directly (not { shots: Shot[] }).
|
|
135
|
+
if (params.multiShot?.length) {
|
|
136
|
+
body.multi_shot = true;
|
|
137
|
+
body.shot_type = "customize";
|
|
138
|
+
body.multi_prompt = params.multiShot.map((s, i) => ({
|
|
139
|
+
index: i + 1,
|
|
140
|
+
prompt: s.prompt,
|
|
141
|
+
...(s.duration !== undefined ? { duration: String(s.duration) } : {}),
|
|
142
|
+
}));
|
|
143
|
+
}
|
|
144
|
+
return body;
|
|
145
|
+
}
|
|
146
|
+
/** Motion-control body (character image + motion reference video). */
|
|
147
|
+
function buildMotionControlBody(params, modelId) {
|
|
148
|
+
const body = {
|
|
149
|
+
model_name: modelId,
|
|
150
|
+
image_url: params.inputImageUrl,
|
|
151
|
+
video_url: params.inputVideoUrl,
|
|
152
|
+
};
|
|
153
|
+
if (params.prompt)
|
|
154
|
+
body.prompt = params.prompt;
|
|
155
|
+
if (params.mode)
|
|
156
|
+
body.mode = params.mode;
|
|
157
|
+
if (params.callbackUrl)
|
|
158
|
+
body.callback_url = params.callbackUrl;
|
|
159
|
+
if (params.externalTaskId)
|
|
160
|
+
body.external_task_id = params.externalTaskId;
|
|
161
|
+
return body;
|
|
162
|
+
}
|
|
163
|
+
/** Avatar (image+audio → lipsync video) body. */
|
|
164
|
+
function buildAvatarRequest(params) {
|
|
165
|
+
return {
|
|
166
|
+
image: params.inputImageUrl,
|
|
167
|
+
sound_file: params.inputAudioUrl,
|
|
168
|
+
prompt: params.prompt,
|
|
169
|
+
mode: params.mode || "std",
|
|
170
|
+
...(params.callbackUrl ? { callback_url: params.callbackUrl } : {}),
|
|
171
|
+
...(params.externalTaskId ? { external_task_id: params.externalTaskId } : {}),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Advanced-lip-sync body. Takes the resolved face (from identify-face) and the
|
|
176
|
+
* session id; auto-selects the first detected face's window for the audio.
|
|
177
|
+
*/
|
|
178
|
+
function buildLipSyncBody(params, sessionId, face) {
|
|
179
|
+
const audioDurationMs = params.audioDurationMs ?? 60000;
|
|
180
|
+
return {
|
|
181
|
+
session_id: sessionId,
|
|
182
|
+
face_choose: [{
|
|
183
|
+
face_id: face.face_id,
|
|
184
|
+
sound_file: params.inputAudioUrl,
|
|
185
|
+
sound_insert_time: face.start_time,
|
|
186
|
+
sound_start_time: 0,
|
|
187
|
+
sound_end_time: audioDurationMs,
|
|
188
|
+
sound_volume: 1,
|
|
189
|
+
original_audio_volume: 1,
|
|
190
|
+
}],
|
|
191
|
+
...(params.callbackUrl ? { callback_url: params.callbackUrl } : {}),
|
|
192
|
+
...(params.externalTaskId ? { external_task_id: params.externalTaskId } : {}),
|
|
193
|
+
};
|
|
194
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { VideoStatusParams, VideoStatusResult } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Kling status polling + result stashing. Extracted from KlingService so the
|
|
4
|
+
* class stays a thin transport/dispatch layer. These take a `request` dep (the
|
|
5
|
+
* service's bound requestWithTimeoutRetry) plus the submit timeout, so they
|
|
6
|
+
* reuse the JWT auth + IPv4-pinned agents without holding a class reference.
|
|
7
|
+
*/
|
|
8
|
+
export interface KlingStatusDeps {
|
|
9
|
+
/** Bound KlingService.requestWithTimeoutRetry. */
|
|
10
|
+
request: <T>(endpoint: string, method: "POST" | "GET", body?: any, maxAttempts?: number, timeout?: number) => Promise<T>;
|
|
11
|
+
/** Submit-endpoint timeout (also used for the potentially-large video download). */
|
|
12
|
+
generateTimeout: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function checkRegularVideoStatus(deps: KlingStatusDeps, { task, outputFilename, outputFilePath }: VideoStatusParams): Promise<VideoStatusResult>;
|
|
15
|
+
export declare function checkAvatarVideoStatus(deps: KlingStatusDeps, { task, outputFilename, outputFilePath }: VideoStatusParams): Promise<VideoStatusResult>;
|
|
16
|
+
//# sourceMappingURL=klingStatus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"klingStatus.d.ts","sourceRoot":"","sources":["../../../../../src/services/aiGen/providers/kling/klingStatus.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAGhE;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,kDAAkD;IAClD,OAAO,EAAE,CAAC,CAAC,EACT,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GAAG,KAAK,EACtB,IAAI,CAAC,EAAE,GAAG,EACV,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,MAAM,KACb,OAAO,CAAC,CAAC,CAAC,CAAC;IAChB,oFAAoF;IACpF,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,eAAe,EACrB,EAAE,IAAI,EAAE,cAAc,EAAE,cAAyB,EAAE,EAAE,iBAAiB,GACrE,OAAO,CAAC,iBAAiB,CAAC,CAyE5B;AAED,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,eAAe,EACrB,EAAE,IAAI,EAAE,cAAc,EAAE,cAAyB,EAAE,EAAE,iBAAiB,GACrE,OAAO,CAAC,iBAAiB,CAAC,CAqG5B"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.checkRegularVideoStatus = checkRegularVideoStatus;
|
|
7
|
+
exports.checkAvatarVideoStatus = checkAvatarVideoStatus;
|
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
|
+
const http_1 = __importDefault(require("http"));
|
|
10
|
+
const https_1 = __importDefault(require("https"));
|
|
11
|
+
const types_1 = require("../../../../globals/types");
|
|
12
|
+
const firebase_1 = require("../../../../libs/firebase");
|
|
13
|
+
const logger_1 = require("../../../../utils/logger");
|
|
14
|
+
async function checkRegularVideoStatus(deps, { task, outputFilename, outputFilePath = "videos" }) {
|
|
15
|
+
const startTime = Date.now();
|
|
16
|
+
// Try each Kling status endpoint in order until one returns non-404.
|
|
17
|
+
// We don't persist which endpoint was used at submit time, so we probe all of them.
|
|
18
|
+
const statusEndpoints = [
|
|
19
|
+
`/v1/videos/text2video/${task}`,
|
|
20
|
+
`/v1/videos/image2video/${task}`,
|
|
21
|
+
`/v1/videos/video-extend/${task}`,
|
|
22
|
+
`/v1/videos/omni-video/${task}`,
|
|
23
|
+
`/v1/videos/motion-control/${task}`,
|
|
24
|
+
`/v1/videos/advanced-lip-sync/${task}`,
|
|
25
|
+
];
|
|
26
|
+
let result;
|
|
27
|
+
for (const ep of statusEndpoints) {
|
|
28
|
+
try {
|
|
29
|
+
result = await deps.request(ep, "GET");
|
|
30
|
+
break; // found it
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
if (err.response?.status !== 404)
|
|
34
|
+
throw err;
|
|
35
|
+
// 404 → try next endpoint
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (!result) {
|
|
39
|
+
return {
|
|
40
|
+
status: types_1.EVideoSceneStatus.FAILED,
|
|
41
|
+
errorMessage: `Task ${task} not found on any Kling status endpoint`,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
logger_1.logger.info("Kling checkVideoStatus polled", { task, durationMs: Date.now() - startTime, status: result.data.task_status });
|
|
45
|
+
if (result.data.task_status === "succeed") {
|
|
46
|
+
const videoUrl = result.data.task_result?.videos?.[0]?.url;
|
|
47
|
+
if (!videoUrl) {
|
|
48
|
+
return {
|
|
49
|
+
status: types_1.EVideoSceneStatus.FAILED,
|
|
50
|
+
errorMessage: "No video URL in response",
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const filePath = `${outputFilePath}/${outputFilename}.mp4`;
|
|
54
|
+
const file = (0, firebase_1.getBucket)().file(filePath);
|
|
55
|
+
// Download video using axios — use generateTimeout since video files can be large
|
|
56
|
+
const videoResp = await axios_1.default.get(videoUrl, {
|
|
57
|
+
responseType: "arraybuffer",
|
|
58
|
+
timeout: deps.generateTimeout,
|
|
59
|
+
});
|
|
60
|
+
const buffer = Buffer.from(videoResp.data);
|
|
61
|
+
await file.save(buffer, { contentType: "video/mp4" });
|
|
62
|
+
const [signedUrl] = await file.getSignedUrl({
|
|
63
|
+
action: "read",
|
|
64
|
+
expires: "03-09-2491",
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
videoUrl: signedUrl,
|
|
68
|
+
status: types_1.EVideoSceneStatus.COMPLETED,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (result.data.task_status === "failed") {
|
|
72
|
+
return {
|
|
73
|
+
status: types_1.EVideoSceneStatus.FAILED,
|
|
74
|
+
errorMessage: result.data.task_status_msg || result.message || "Kling task failed (no reason provided)",
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return { status: types_1.EVideoSceneStatus.PENDING };
|
|
78
|
+
}
|
|
79
|
+
async function checkAvatarVideoStatus(deps, { task, outputFilename, outputFilePath = "videos" }) {
|
|
80
|
+
const startTime = Date.now();
|
|
81
|
+
const result = await deps.request(`/v1/videos/avatar/image2video/${task}`, "GET");
|
|
82
|
+
logger_1.logger.info("Kling checkAvatarVideoStatus polled", { task, durationMs: Date.now() - startTime, status: result?.data?.task_status, statusMsg: result?.data?.task_status_msg || undefined });
|
|
83
|
+
if (!result) {
|
|
84
|
+
return {
|
|
85
|
+
status: types_1.EVideoSceneStatus.FAILED,
|
|
86
|
+
errorMessage: "No response from Kling Avatar API",
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
if (result.data.task_status === "succeed") {
|
|
90
|
+
const videoUrl = result.data.task_result?.videos?.[0]?.url;
|
|
91
|
+
if (!videoUrl) {
|
|
92
|
+
return {
|
|
93
|
+
status: types_1.EVideoSceneStatus.FAILED,
|
|
94
|
+
errorMessage: "No video URL in avatar response",
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
// Kling task is done. Now download from Kling's CDN, push to GCS, and
|
|
98
|
+
// mint a signed URL. Any of these three can hiccup (Kling CDN slow,
|
|
99
|
+
// GCS 503, signedURL service blip) — historically the whole call threw
|
|
100
|
+
// and the outer TaskPoller burned a poll attempt re-asking Kling for a
|
|
101
|
+
// status that's already known. Wrap the post-success work in its own
|
|
102
|
+
// bounded retry so a transient blip doesn't poison the poll loop.
|
|
103
|
+
const filePath = `${outputFilePath}/${outputFilename}.mp4`;
|
|
104
|
+
const file = (0, firebase_1.getBucket)().file(filePath);
|
|
105
|
+
const maxAttempts = 3;
|
|
106
|
+
let lastErr;
|
|
107
|
+
// Force IPv4 on the download. The Kling-returned video URL frequently
|
|
108
|
+
// resolves to a CDN host where IPv6 is broken or routes us to a
|
|
109
|
+
// geo-blocked PoP, producing an AggregateError(ETIMEDOUT) where both
|
|
110
|
+
// happy-eyeballs sockets fail. Pinning v4 avoids the IPv6 dead-end.
|
|
111
|
+
const v4Http = new http_1.default.Agent({ family: 4, keepAlive: true });
|
|
112
|
+
const v4Https = new https_1.default.Agent({ family: 4, keepAlive: true });
|
|
113
|
+
// Parse host so we can log which CDN we couldn't reach.
|
|
114
|
+
let downloadHost = "unknown";
|
|
115
|
+
try {
|
|
116
|
+
downloadHost = new URL(videoUrl).host;
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
/* leave as unknown */
|
|
120
|
+
}
|
|
121
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
122
|
+
try {
|
|
123
|
+
const videoResp = await axios_1.default.get(videoUrl, {
|
|
124
|
+
responseType: "arraybuffer",
|
|
125
|
+
timeout: deps.generateTimeout,
|
|
126
|
+
httpAgent: v4Http,
|
|
127
|
+
httpsAgent: v4Https,
|
|
128
|
+
});
|
|
129
|
+
const buffer = Buffer.from(videoResp.data);
|
|
130
|
+
await file.save(buffer, { contentType: "video/mp4" });
|
|
131
|
+
const [signedUrl] = await file.getSignedUrl({
|
|
132
|
+
action: "read",
|
|
133
|
+
expires: "03-09-2491",
|
|
134
|
+
});
|
|
135
|
+
return {
|
|
136
|
+
videoUrl: signedUrl,
|
|
137
|
+
status: types_1.EVideoSceneStatus.COMPLETED,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
lastErr = err;
|
|
142
|
+
const isErr = err instanceof Error;
|
|
143
|
+
logger_1.logger.warn("Kling avatar post-success stash failed", {
|
|
144
|
+
task,
|
|
145
|
+
attempt,
|
|
146
|
+
maxAttempts,
|
|
147
|
+
downloadHost,
|
|
148
|
+
errName: isErr ? err.name : typeof err,
|
|
149
|
+
errCode: isErr ? err.code : undefined,
|
|
150
|
+
httpStatus: isErr ? err.response?.status : undefined,
|
|
151
|
+
msg: isErr ? err.message : String(err),
|
|
152
|
+
});
|
|
153
|
+
if (attempt < maxAttempts) {
|
|
154
|
+
await new Promise((r) => setTimeout(r, 2000 * 2 ** (attempt - 1)));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
// All internal retries exhausted — surface as pending so the outer
|
|
159
|
+
// TaskPoller retries the WHOLE checkVideoStatus call (with its own
|
|
160
|
+
// budget). Throwing here would burn an outer attempt with no extra
|
|
161
|
+
// signal beyond what we already logged.
|
|
162
|
+
throw lastErr instanceof Error
|
|
163
|
+
? lastErr
|
|
164
|
+
: new Error(`Kling avatar stash failed after ${maxAttempts} attempts`);
|
|
165
|
+
}
|
|
166
|
+
if (result.data.task_status === "failed") {
|
|
167
|
+
return {
|
|
168
|
+
status: types_1.EVideoSceneStatus.FAILED,
|
|
169
|
+
errorMessage: result.data.task_status_msg || result.message || "Kling avatar task failed (no reason provided)",
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
return { status: types_1.EVideoSceneStatus.PENDING };
|
|
173
|
+
}
|
|
@@ -42,11 +42,72 @@ declare class BullMQService {
|
|
|
42
42
|
private getConnection;
|
|
43
43
|
/** Initialize BullMQ service (like your initRedis) */
|
|
44
44
|
init(): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Dev enqueue gate (single source of truth for ALL queues).
|
|
47
|
+
*
|
|
48
|
+
* When iterating on the Firebase Functions locally you don't want every test
|
|
49
|
+
* request to drop a real job into Redis — the node worker (whenever it next
|
|
50
|
+
* runs) would drain the whole backlog and burn provider credits. In dev we
|
|
51
|
+
* therefore SKIP enqueue by default; opt back in by setting `ENABLE_QUEUE=true`
|
|
52
|
+
* (or the legacy `ENABLE_VIDEO_QUEUE=true`) in the env of whichever process is
|
|
53
|
+
* enqueuing — set it in BOTH functions + node when you want the full pipeline.
|
|
54
|
+
*
|
|
55
|
+
* In production this is always false (NODE_ENV=production), so prod always
|
|
56
|
+
* enqueues. Centralised here so it covers video, poster, render, image, agent
|
|
57
|
+
* and social queues uniformly rather than per-controller flags.
|
|
58
|
+
*/
|
|
59
|
+
private enqueueDisabledInDev;
|
|
45
60
|
/** Add a job */
|
|
46
61
|
addJob(queueName: string, data: JobData, opts?: {
|
|
47
62
|
jobId?: string;
|
|
48
63
|
delay?: number;
|
|
64
|
+
/** Retry attempts (default BullMQ = 1, i.e. no retry). */
|
|
65
|
+
attempts?: number;
|
|
66
|
+
/** Backoff between retries when `attempts` > 1. */
|
|
67
|
+
backoff?: {
|
|
68
|
+
type: "fixed" | "exponential";
|
|
69
|
+
delay: number;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Override the default completed/failed retention. Numbers cap by count;
|
|
73
|
+
* objects can cap by `{ age, count }`. Defaults below keep Redis from
|
|
74
|
+
* filling up on the 30MB Redis Cloud hobby plan.
|
|
75
|
+
*/
|
|
76
|
+
removeOnComplete?: number | {
|
|
77
|
+
age?: number;
|
|
78
|
+
count?: number;
|
|
79
|
+
};
|
|
80
|
+
removeOnFail?: number | {
|
|
81
|
+
age?: number;
|
|
82
|
+
count?: number;
|
|
83
|
+
};
|
|
49
84
|
}): Promise<void>;
|
|
85
|
+
/** Get (or lazily create) the Queue handle for a name, reusing the cache. */
|
|
86
|
+
private getQueue;
|
|
87
|
+
/**
|
|
88
|
+
* Admin: obliterate the given queues — removes ALL jobs in every state
|
|
89
|
+
* (wait/active/completed/failed/delayed) AND the leftover per-job hashes.
|
|
90
|
+
* `force` so it proceeds even if jobs are mid-flight. Used by the
|
|
91
|
+
* `queue:flush:*` scripts. Returns the queue names actually processed.
|
|
92
|
+
*/
|
|
93
|
+
obliterateQueues(queueNames: string[]): Promise<string[]>;
|
|
94
|
+
/** Admin: per-queue depth + orphaned per-job hash count (read-only). */
|
|
95
|
+
getQueueStats(queueNames: string[]): Promise<Array<{
|
|
96
|
+
queue: string;
|
|
97
|
+
wait: number;
|
|
98
|
+
active: number;
|
|
99
|
+
delayed: number;
|
|
100
|
+
completed: number;
|
|
101
|
+
failed: number;
|
|
102
|
+
hashes: number;
|
|
103
|
+
}>>;
|
|
104
|
+
/** Admin: Redis memory snapshot (read-only). */
|
|
105
|
+
redisMemoryInfo(): Promise<{
|
|
106
|
+
usedHuman: string;
|
|
107
|
+
usedRaw: number;
|
|
108
|
+
maxRaw: number;
|
|
109
|
+
dbsize: number;
|
|
110
|
+
}>;
|
|
50
111
|
startWorkers(queueNames: string[], processor: (job: Job) => Promise<void>, perQueueOptions?: Record<string, {
|
|
51
112
|
lockDuration?: number;
|
|
52
113
|
stalledInterval?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bullmq.service.d.ts","sourceRoot":"","sources":["../../src/services/bullmq.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAgB,EAAwB,YAAY,EAAE,MAAM,SAAS,CAAC;AAItE,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAc1C,UAAU,oBAAoB;IAC5B,YAAY,EAAE,YAAY,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,cAAM,aAAa;IACjB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAgB;IACvC,OAAO,CAAC,MAAM,CAAiC;IAC/C,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,YAAY,CAAgB;IAIpC,OAAO,CAAC,UAAU,CAAC,CAAc;IACjC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,YAAY,CAAS;IAE7B,OAAO;WAQO,WAAW,CAAC,OAAO,EAAE,oBAAoB;IAOvD;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,OAAO,CAAC,aAAa;IAOrB,sDAAsD;IACzC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBlC,gBAAgB;IACH,MAAM,CACjB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,OAAO,EACb,IAAI,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"bullmq.service.d.ts","sourceRoot":"","sources":["../../src/services/bullmq.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAgB,EAAwB,YAAY,EAAE,MAAM,SAAS,CAAC;AAItE,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAc1C,UAAU,oBAAoB;IAC5B,YAAY,EAAE,YAAY,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,cAAM,aAAa;IACjB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAgB;IACvC,OAAO,CAAC,MAAM,CAAiC;IAC/C,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,YAAY,CAAgB;IAIpC,OAAO,CAAC,UAAU,CAAC,CAAc;IACjC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,YAAY,CAAS;IAE7B,OAAO;WAQO,WAAW,CAAC,OAAO,EAAE,oBAAoB;IAOvD;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,OAAO,CAAC,aAAa;IAOrB,sDAAsD;IACzC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBlC;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,oBAAoB;IAQ5B,gBAAgB;IACH,MAAM,CACjB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,OAAO,EACb,IAAI,CAAC,EAAE;QACL,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,0DAA0D;QAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,mDAAmD;QACnD,OAAO,CAAC,EAAE;YAAE,IAAI,EAAE,OAAO,GAAG,aAAa,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC;QAC3D;;;;WAIG;QACH,gBAAgB,CAAC,EAAE,MAAM,GAAG;YAAE,GAAG,CAAC,EAAE,MAAM,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QAC7D,YAAY,CAAC,EAAE,MAAM,GAAG;YAAE,GAAG,CAAC,EAAE,MAAM,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;KAC1D;IA+BH,6EAA6E;IAC7E,OAAO,CAAC,QAAQ;IAQhB;;;;;OAKG;IACU,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAUtE,wEAAwE;IAC3D,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CACvD,KAAK,CAAC;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC,CACH;IAgCD,gDAAgD;IACnC,eAAe,IAAI,OAAO,CAAC;QACtC,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IAWK,YAAY,CACjB,UAAU,EAAE,MAAM,EAAE,EACpB,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,EACtC,eAAe,CAAC,EAAE,MAAM,CACtB,MAAM,EACN;QACE,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CACF;CAyIJ;AASD,eAAO,MAAM,MAAM,eAGjB,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,GAAG,CAAC"}
|
|
@@ -83,14 +83,114 @@ class BullMQService {
|
|
|
83
83
|
throw err;
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Dev enqueue gate (single source of truth for ALL queues).
|
|
88
|
+
*
|
|
89
|
+
* When iterating on the Firebase Functions locally you don't want every test
|
|
90
|
+
* request to drop a real job into Redis — the node worker (whenever it next
|
|
91
|
+
* runs) would drain the whole backlog and burn provider credits. In dev we
|
|
92
|
+
* therefore SKIP enqueue by default; opt back in by setting `ENABLE_QUEUE=true`
|
|
93
|
+
* (or the legacy `ENABLE_VIDEO_QUEUE=true`) in the env of whichever process is
|
|
94
|
+
* enqueuing — set it in BOTH functions + node when you want the full pipeline.
|
|
95
|
+
*
|
|
96
|
+
* In production this is always false (NODE_ENV=production), so prod always
|
|
97
|
+
* enqueues. Centralised here so it covers video, poster, render, image, agent
|
|
98
|
+
* and social queues uniformly rather than per-controller flags.
|
|
99
|
+
*/
|
|
100
|
+
enqueueDisabledInDev() {
|
|
101
|
+
if (process.env.NODE_ENV !== "development")
|
|
102
|
+
return false;
|
|
103
|
+
const enabled = process.env.ENABLE_QUEUE === "true" ||
|
|
104
|
+
process.env.ENABLE_VIDEO_QUEUE === "true";
|
|
105
|
+
return !enabled;
|
|
106
|
+
}
|
|
86
107
|
/** Add a job */
|
|
87
108
|
async addJob(queueName, data, opts) {
|
|
109
|
+
// Dev gate — skip the actual enqueue unless explicitly opted in. Logged so
|
|
110
|
+
// it's obvious in the emulator output why nothing showed up in the queue.
|
|
111
|
+
if (this.enqueueDisabledInDev()) {
|
|
112
|
+
logger_1.logger.info("[BullMQ] enqueue skipped (dev): set ENABLE_QUEUE=true to enqueue", { queueName, jobId: opts?.jobId });
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
88
115
|
if (!this.initialized)
|
|
89
116
|
await this.init();
|
|
90
117
|
const queue = this.queues.get(queueName) ??
|
|
91
118
|
new bullmq_1.Queue(queueName, { connection: this.getConnection() });
|
|
92
119
|
this.queues.set(queueName, queue);
|
|
93
|
-
await queue.add(opts?.jobId || "default", data, {
|
|
120
|
+
await queue.add(opts?.jobId || "default", data, {
|
|
121
|
+
delay: opts?.delay,
|
|
122
|
+
attempts: opts?.attempts,
|
|
123
|
+
backoff: opts?.backoff,
|
|
124
|
+
// Auto-evict finished jobs so their hashes don't accumulate forever.
|
|
125
|
+
// Without this BullMQ keeps every completed/failed job hash with no TTL
|
|
126
|
+
// (this is what filled prod Redis to ~75% of 30MB / 41k orphan keys).
|
|
127
|
+
// Completed: keep 1 day or last 1000. Failed: keep longer (7 days /
|
|
128
|
+
// last 5000) since failures are worth inspecting.
|
|
129
|
+
removeOnComplete: opts?.removeOnComplete ?? { age: 24 * 3600, count: 1000 },
|
|
130
|
+
removeOnFail: opts?.removeOnFail ?? { age: 7 * 24 * 3600, count: 5000 },
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/** Get (or lazily create) the Queue handle for a name, reusing the cache. */
|
|
134
|
+
getQueue(queueName) {
|
|
135
|
+
const queue = this.queues.get(queueName) ??
|
|
136
|
+
new bullmq_1.Queue(queueName, { connection: this.getConnection() });
|
|
137
|
+
this.queues.set(queueName, queue);
|
|
138
|
+
return queue;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Admin: obliterate the given queues — removes ALL jobs in every state
|
|
142
|
+
* (wait/active/completed/failed/delayed) AND the leftover per-job hashes.
|
|
143
|
+
* `force` so it proceeds even if jobs are mid-flight. Used by the
|
|
144
|
+
* `queue:flush:*` scripts. Returns the queue names actually processed.
|
|
145
|
+
*/
|
|
146
|
+
async obliterateQueues(queueNames) {
|
|
147
|
+
if (!this.initialized)
|
|
148
|
+
await this.init();
|
|
149
|
+
const done = [];
|
|
150
|
+
for (const name of queueNames) {
|
|
151
|
+
await this.getQueue(name).obliterate({ force: true });
|
|
152
|
+
done.push(name);
|
|
153
|
+
}
|
|
154
|
+
return done;
|
|
155
|
+
}
|
|
156
|
+
/** Admin: per-queue depth + orphaned per-job hash count (read-only). */
|
|
157
|
+
async getQueueStats(queueNames) {
|
|
158
|
+
if (!this.initialized)
|
|
159
|
+
await this.init();
|
|
160
|
+
const conn = this.getConnection();
|
|
161
|
+
const out = [];
|
|
162
|
+
for (const queue of queueNames) {
|
|
163
|
+
const [wait, active, delayed, completed, failed] = await Promise.all([
|
|
164
|
+
conn.llen(`bull:${queue}:wait`),
|
|
165
|
+
conn.llen(`bull:${queue}:active`),
|
|
166
|
+
conn.zcard(`bull:${queue}:delayed`),
|
|
167
|
+
conn.zcard(`bull:${queue}:completed`),
|
|
168
|
+
conn.zcard(`bull:${queue}:failed`),
|
|
169
|
+
]);
|
|
170
|
+
// Count bull:<queue>:<numericId> hashes — the orphans that accumulate
|
|
171
|
+
// when removeOnComplete/removeOnFail isn't set.
|
|
172
|
+
let hashes = 0;
|
|
173
|
+
let cursor = "0";
|
|
174
|
+
do {
|
|
175
|
+
const [next, keys] = await conn.scan(cursor, "MATCH", `bull:${queue}:*`, "COUNT", 1000);
|
|
176
|
+
cursor = next;
|
|
177
|
+
hashes += keys.filter((k) => /:\d+$/.test(k)).length;
|
|
178
|
+
} while (cursor !== "0");
|
|
179
|
+
out.push({ queue, wait, active, delayed, completed, failed, hashes });
|
|
180
|
+
}
|
|
181
|
+
return out;
|
|
182
|
+
}
|
|
183
|
+
/** Admin: Redis memory snapshot (read-only). */
|
|
184
|
+
async redisMemoryInfo() {
|
|
185
|
+
if (!this.initialized)
|
|
186
|
+
await this.init();
|
|
187
|
+
const conn = this.getConnection();
|
|
188
|
+
const mem = await conn.info("memory");
|
|
189
|
+
const usedHuman = /used_memory_human:(.+)/.exec(mem)?.[1]?.trim() ?? "?";
|
|
190
|
+
const usedRaw = Number(/used_memory:(\d+)/.exec(mem)?.[1] ?? 0);
|
|
191
|
+
const maxRaw = Number(/maxmemory:(\d+)/.exec(mem)?.[1] ?? 0);
|
|
192
|
+
const dbsize = await conn.dbsize();
|
|
193
|
+
return { usedHuman, usedRaw, maxRaw, dbsize };
|
|
94
194
|
}
|
|
95
195
|
startWorkers(queueNames, processor, perQueueOptions) {
|
|
96
196
|
const start = async () => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/crypto/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./tokenVault"), exports);
|