mergestory 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +48 -2
- package/assets/kokoro-plugin/package-lock.json +1139 -0
- package/dist/analyzer/analyze.d.ts +8 -0
- package/dist/analyzer/analyze.js +328 -0
- package/dist/analyzer/components.d.ts +18 -0
- package/dist/analyzer/components.js +266 -0
- package/dist/analyzer/dependencies.d.ts +13 -0
- package/dist/analyzer/dependencies.js +349 -0
- package/dist/analyzer/evidence.d.ts +15 -0
- package/dist/analyzer/evidence.js +73 -0
- package/dist/analyzer/hunks.d.ts +21 -0
- package/dist/analyzer/hunks.js +88 -0
- package/dist/analyzer/imports.d.ts +46 -0
- package/dist/analyzer/imports.js +87 -0
- package/dist/analyzer/index.d.ts +14 -0
- package/dist/analyzer/index.js +16 -0
- package/dist/analyzer/languages/go.d.ts +2 -0
- package/dist/analyzer/languages/go.js +76 -0
- package/dist/analyzer/languages/index.d.ts +18 -0
- package/dist/analyzer/languages/index.js +72 -0
- package/dist/analyzer/languages/javascript.d.ts +2 -0
- package/dist/analyzer/languages/javascript.js +336 -0
- package/dist/analyzer/languages/jvm.d.ts +2 -0
- package/dist/analyzer/languages/jvm.js +157 -0
- package/dist/analyzer/languages/others.d.ts +2 -0
- package/dist/analyzer/languages/others.js +40 -0
- package/dist/analyzer/languages/php.d.ts +2 -0
- package/dist/analyzer/languages/php.js +81 -0
- package/dist/analyzer/languages/python.d.ts +2 -0
- package/dist/analyzer/languages/python.js +180 -0
- package/dist/analyzer/languages/ruby.d.ts +2 -0
- package/dist/analyzer/languages/ruby.js +99 -0
- package/dist/analyzer/languages/rust.d.ts +2 -0
- package/dist/analyzer/languages/rust.js +164 -0
- package/dist/analyzer/languages/shared.d.ts +35 -0
- package/dist/analyzer/languages/shared.js +43 -0
- package/dist/analyzer/languages/types.d.ts +78 -0
- package/dist/analyzer/languages/types.js +2 -0
- package/dist/analyzer/pack-format.d.ts +27 -0
- package/dist/analyzer/pack-format.js +139 -0
- package/dist/analyzer/pack.d.ts +26 -0
- package/dist/analyzer/pack.js +498 -0
- package/dist/analyzer/relationships.d.ts +17 -0
- package/dist/analyzer/relationships.js +34 -0
- package/dist/analyzer/risk-rules.d.ts +287 -0
- package/dist/analyzer/risk-rules.js +373 -0
- package/dist/analyzer/risks.d.ts +36 -0
- package/dist/analyzer/risks.js +480 -0
- package/dist/analyzer/roles.d.ts +11 -0
- package/dist/analyzer/roles.js +280 -0
- package/dist/analyzer/scan.d.ts +26 -0
- package/dist/analyzer/scan.js +157 -0
- package/dist/analyzer/signals.d.ts +20 -0
- package/dist/analyzer/signals.js +51 -0
- package/dist/analyzer/symbol-changes.d.ts +11 -0
- package/dist/analyzer/symbol-changes.js +101 -0
- package/dist/analyzer/symbol-types.d.ts +17 -0
- package/dist/analyzer/symbol-types.js +9 -0
- package/dist/analyzer/symbols.d.ts +4 -0
- package/dist/analyzer/symbols.js +16 -0
- package/dist/analyzer/trivial.d.ts +13 -0
- package/dist/analyzer/trivial.js +137 -0
- package/dist/analyzer/util.d.ts +6 -0
- package/dist/analyzer/util.js +24 -0
- package/dist/cli/commands/authoring.d.ts +9 -0
- package/dist/cli/commands/authoring.js +98 -0
- package/dist/cli/commands/cache.d.ts +4 -0
- package/dist/cli/commands/cache.js +37 -0
- package/dist/cli/commands/doctor.d.ts +5 -0
- package/dist/cli/commands/doctor.js +37 -0
- package/dist/cli/commands/generate.d.ts +8 -0
- package/dist/cli/commands/generate.js +69 -0
- package/dist/cli/commands/jobs.d.ts +8 -0
- package/dist/cli/commands/jobs.js +70 -0
- package/dist/cli/commands/publish.d.ts +8 -0
- package/dist/cli/commands/publish.js +120 -0
- package/dist/cli/commands/serve.d.ts +4 -0
- package/dist/cli/commands/serve.js +69 -0
- package/dist/cli/commands/setup.d.ts +14 -0
- package/dist/cli/commands/setup.js +108 -0
- package/dist/cli/commands/shared.d.ts +18 -0
- package/dist/cli/commands/shared.js +24 -0
- package/dist/cli/files.d.ts +26 -0
- package/dist/cli/files.js +98 -0
- package/dist/cli/format.d.ts +55 -0
- package/dist/cli/format.js +295 -0
- package/dist/cli/inputs.d.ts +23 -0
- package/dist/cli/inputs.js +96 -0
- package/dist/cli/io.d.ts +19 -0
- package/dist/cli/io.js +31 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +15 -0
- package/dist/cli/options.d.ts +105 -0
- package/dist/cli/options.js +324 -0
- package/dist/cli/program.d.ts +12 -0
- package/dist/cli/program.js +146 -0
- package/dist/cli/runtime.d.ts +59 -0
- package/dist/cli/runtime.js +83 -0
- package/dist/cli/style.d.ts +13 -0
- package/dist/cli/style.js +27 -0
- package/dist/core/binaries.d.ts +7 -0
- package/dist/core/binaries.js +33 -0
- package/dist/core/binary-paths.d.ts +5 -0
- package/dist/core/binary-paths.js +92 -0
- package/dist/core/cache.d.ts +14 -0
- package/dist/core/cache.js +43 -0
- package/dist/core/child-env.d.ts +9 -0
- package/dist/core/child-env.js +61 -0
- package/dist/core/concurrency.d.ts +13 -0
- package/dist/core/concurrency.js +58 -0
- package/dist/core/config.d.ts +223 -0
- package/dist/core/config.js +454 -0
- package/dist/core/context.d.ts +39 -0
- package/dist/core/context.js +44 -0
- package/dist/core/cost.d.ts +46 -0
- package/dist/core/cost.js +108 -0
- package/dist/core/diagram-metrics.d.ts +57 -0
- package/dist/core/diagram-metrics.js +63 -0
- package/dist/core/diff-view.d.ts +44 -0
- package/dist/core/diff-view.js +136 -0
- package/dist/core/errors.d.ts +47 -0
- package/dist/core/errors.js +94 -0
- package/dist/core/ids.d.ts +11 -0
- package/dist/core/ids.js +36 -0
- package/dist/core/json.d.ts +8 -0
- package/dist/core/json.js +17 -0
- package/dist/core/languages.d.ts +19 -0
- package/dist/core/languages.js +292 -0
- package/dist/core/logger.d.ts +29 -0
- package/dist/core/logger.js +68 -0
- package/dist/core/net.d.ts +16 -0
- package/dist/core/net.js +80 -0
- package/dist/core/path-policy.d.ts +20 -0
- package/dist/core/path-policy.js +202 -0
- package/dist/core/paths.d.ts +18 -0
- package/dist/core/paths.js +53 -0
- package/dist/core/posix.d.ts +12 -0
- package/dist/core/posix.js +50 -0
- package/dist/core/process.d.ts +22 -0
- package/dist/core/process.js +117 -0
- package/dist/core/providers.d.ts +204 -0
- package/dist/core/providers.js +2 -0
- package/dist/core/redact.d.ts +11 -0
- package/dist/core/redact.js +70 -0
- package/dist/core/render-plan.d.ts +307 -0
- package/dist/core/render-plan.js +7 -0
- package/dist/core/retry.d.ts +54 -0
- package/dist/core/retry.js +116 -0
- package/dist/core/run-folder.d.ts +74 -0
- package/dist/core/run-folder.js +129 -0
- package/dist/core/secrets.d.ts +56 -0
- package/dist/core/secrets.js +301 -0
- package/dist/core/storyboard-facts.d.ts +22 -0
- package/dist/core/storyboard-facts.js +61 -0
- package/dist/core/storyboard-schema.d.ts +1279 -0
- package/dist/core/storyboard-schema.js +342 -0
- package/dist/core/text.d.ts +43 -0
- package/dist/core/text.js +94 -0
- package/dist/core/types.d.ts +459 -0
- package/dist/core/types.js +17 -0
- package/dist/doctor/check.d.ts +6 -0
- package/dist/doctor/check.js +18 -0
- package/dist/doctor/deps.d.ts +2 -0
- package/dist/doctor/deps.js +90 -0
- package/dist/doctor/format.d.ts +9 -0
- package/dist/doctor/format.js +19 -0
- package/dist/doctor/github.d.ts +2 -0
- package/dist/doctor/github.js +13 -0
- package/dist/doctor/home.d.ts +2 -0
- package/dist/doctor/home.js +26 -0
- package/dist/doctor/index.d.ts +18 -0
- package/dist/doctor/index.js +81 -0
- package/dist/doctor/llm.d.ts +2 -0
- package/dist/doctor/llm.js +32 -0
- package/dist/doctor/publish.d.ts +2 -0
- package/dist/doctor/publish.js +16 -0
- package/dist/doctor/s3.d.ts +2 -0
- package/dist/doctor/s3.js +125 -0
- package/dist/doctor/speech.d.ts +2 -0
- package/dist/doctor/speech.js +112 -0
- package/dist/doctor/tools.d.ts +5 -0
- package/dist/doctor/tools.js +58 -0
- package/dist/doctor/types.d.ts +92 -0
- package/dist/doctor/types.js +2 -0
- package/dist/doctor/youtube.d.ts +2 -0
- package/dist/doctor/youtube.js +73 -0
- package/dist/github/client.d.ts +108 -0
- package/dist/github/client.js +499 -0
- package/dist/github/errors.d.ts +37 -0
- package/dist/github/errors.js +155 -0
- package/dist/github/index.d.ts +13 -0
- package/dist/github/index.js +9 -0
- package/dist/github/linked-issues.d.ts +37 -0
- package/dist/github/linked-issues.js +131 -0
- package/dist/github/model.d.ts +81 -0
- package/dist/github/model.js +114 -0
- package/dist/github/notify.d.ts +27 -0
- package/dist/github/notify.js +118 -0
- package/dist/github/pr-url.d.ts +27 -0
- package/dist/github/pr-url.js +122 -0
- package/dist/github/token.d.ts +16 -0
- package/dist/github/token.js +69 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +19 -0
- package/dist/jobs/input-rules.d.ts +20 -0
- package/dist/jobs/input-rules.js +100 -0
- package/dist/jobs/model.d.ts +47 -0
- package/dist/jobs/model.js +18 -0
- package/dist/jobs/runner.d.ts +43 -0
- package/dist/jobs/runner.js +165 -0
- package/dist/jobs/store.d.ts +67 -0
- package/dist/jobs/store.js +314 -0
- package/dist/jobs/view.d.ts +48 -0
- package/dist/jobs/view.js +111 -0
- package/dist/jobs/worker.d.ts +24 -0
- package/dist/jobs/worker.js +47 -0
- package/dist/llm/anthropic.d.ts +11 -0
- package/dist/llm/anthropic.js +225 -0
- package/dist/llm/index.d.ts +10 -0
- package/dist/llm/index.js +27 -0
- package/dist/llm/openai-compatible.d.ts +33 -0
- package/dist/llm/openai-compatible.js +378 -0
- package/dist/llm/prices.d.ts +26 -0
- package/dist/llm/prices.js +41 -0
- package/dist/llm/shared.d.ts +30 -0
- package/dist/llm/shared.js +115 -0
- package/dist/narration/assemble.d.ts +36 -0
- package/dist/narration/assemble.js +282 -0
- package/dist/narration/audio.d.ts +61 -0
- package/dist/narration/audio.js +301 -0
- package/dist/narration/captions.d.ts +37 -0
- package/dist/narration/captions.js +195 -0
- package/dist/narration/chunking.d.ts +6 -0
- package/dist/narration/chunking.js +46 -0
- package/dist/narration/convert.d.ts +9 -0
- package/dist/narration/convert.js +90 -0
- package/dist/narration/elevenlabs.d.ts +5 -0
- package/dist/narration/elevenlabs.js +53 -0
- package/dist/narration/http-errors.d.ts +14 -0
- package/dist/narration/http-errors.js +74 -0
- package/dist/narration/index.d.ts +21 -0
- package/dist/narration/index.js +22 -0
- package/dist/narration/kokoro-install.d.ts +30 -0
- package/dist/narration/kokoro-install.js +284 -0
- package/dist/narration/kokoro-model.d.ts +54 -0
- package/dist/narration/kokoro-model.js +168 -0
- package/dist/narration/kokoro-plugin.d.ts +78 -0
- package/dist/narration/kokoro-plugin.js +245 -0
- package/dist/narration/kokoro.d.ts +22 -0
- package/dist/narration/kokoro.js +231 -0
- package/dist/narration/openai.d.ts +4 -0
- package/dist/narration/openai.js +54 -0
- package/dist/narration/pricing.d.ts +8 -0
- package/dist/narration/pricing.js +17 -0
- package/dist/narration/remote-speech.d.ts +53 -0
- package/dist/narration/remote-speech.js +100 -0
- package/dist/narration/say.d.ts +28 -0
- package/dist/narration/say.js +178 -0
- package/dist/narration/select.d.ts +27 -0
- package/dist/narration/select.js +80 -0
- package/dist/narration/silent.d.ts +2 -0
- package/dist/narration/silent.js +18 -0
- package/dist/narration/speakable.d.ts +20 -0
- package/dist/narration/speakable.js +398 -0
- package/dist/narration/synthesize.d.ts +25 -0
- package/dist/narration/synthesize.js +220 -0
- package/dist/narration/wav.d.ts +37 -0
- package/dist/narration/wav.js +170 -0
- package/dist/pipeline/authoring.d.ts +8 -0
- package/dist/pipeline/authoring.js +117 -0
- package/dist/pipeline/commands.d.ts +9 -0
- package/dist/pipeline/commands.js +21 -0
- package/dist/pipeline/fit-duration.d.ts +41 -0
- package/dist/pipeline/fit-duration.js +150 -0
- package/dist/pipeline/index.d.ts +9 -0
- package/dist/pipeline/index.js +9 -0
- package/dist/pipeline/inputs.d.ts +42 -0
- package/dist/pipeline/inputs.js +171 -0
- package/dist/pipeline/plan.d.ts +8 -0
- package/dist/pipeline/plan.js +85 -0
- package/dist/pipeline/planned-egress.d.ts +21 -0
- package/dist/pipeline/planned-egress.js +43 -0
- package/dist/pipeline/prepare.d.ts +26 -0
- package/dist/pipeline/prepare.js +84 -0
- package/dist/pipeline/presentation.d.ts +26 -0
- package/dist/pipeline/presentation.js +110 -0
- package/dist/pipeline/publish-run.d.ts +71 -0
- package/dist/pipeline/publish-run.js +295 -0
- package/dist/pipeline/run.d.ts +7 -0
- package/dist/pipeline/run.js +196 -0
- package/dist/pipeline/storyboard-choice.d.ts +34 -0
- package/dist/pipeline/storyboard-choice.js +129 -0
- package/dist/pipeline/types.d.ts +76 -0
- package/dist/pipeline/types.js +2 -0
- package/dist/publish/access-probe.d.ts +55 -0
- package/dist/publish/access-probe.js +249 -0
- package/dist/publish/bundle.d.ts +20 -0
- package/dist/publish/bundle.js +57 -0
- package/dist/publish/comment.d.ts +10 -0
- package/dist/publish/comment.js +184 -0
- package/dist/publish/content-types.d.ts +15 -0
- package/dist/publish/content-types.js +41 -0
- package/dist/publish/index.d.ts +18 -0
- package/dist/publish/index.js +30 -0
- package/dist/publish/keys.d.ts +10 -0
- package/dist/publish/keys.js +30 -0
- package/dist/publish/local.d.ts +33 -0
- package/dist/publish/local.js +143 -0
- package/dist/publish/privacy.d.ts +20 -0
- package/dist/publish/privacy.js +21 -0
- package/dist/publish/s3/bucket.d.ts +22 -0
- package/dist/publish/s3/bucket.js +82 -0
- package/dist/publish/s3/client.d.ts +33 -0
- package/dist/publish/s3/client.js +134 -0
- package/dist/publish/s3/failures.d.ts +22 -0
- package/dist/publish/s3/failures.js +110 -0
- package/dist/publish/s3/index.d.ts +5 -0
- package/dist/publish/s3/index.js +6 -0
- package/dist/publish/s3/links.d.ts +38 -0
- package/dist/publish/s3/links.js +60 -0
- package/dist/publish/s3/protected-links.d.ts +29 -0
- package/dist/publish/s3/protected-links.js +67 -0
- package/dist/publish/s3/publisher.d.ts +32 -0
- package/dist/publish/s3/publisher.js +123 -0
- package/dist/publish/s3/settings.d.ts +29 -0
- package/dist/publish/s3/settings.js +64 -0
- package/dist/publish/s3/upload.d.ts +29 -0
- package/dist/publish/s3/upload.js +145 -0
- package/dist/publish/severity.d.ts +9 -0
- package/dist/publish/severity.js +18 -0
- package/dist/publish/text.d.ts +23 -0
- package/dist/publish/text.js +94 -0
- package/dist/publish/types.d.ts +67 -0
- package/dist/publish/types.js +12 -0
- package/dist/publish/vtt.d.ts +9 -0
- package/dist/publish/vtt.js +43 -0
- package/dist/publish/watch-page.d.ts +4 -0
- package/dist/publish/watch-page.js +463 -0
- package/dist/publish/youtube/credentials.d.ts +33 -0
- package/dist/publish/youtube/credentials.js +162 -0
- package/dist/publish/youtube/description.d.ts +56 -0
- package/dist/publish/youtube/description.js +197 -0
- package/dist/publish/youtube/google-api.d.ts +95 -0
- package/dist/publish/youtube/google-api.js +339 -0
- package/dist/publish/youtube/index.d.ts +7 -0
- package/dist/publish/youtube/index.js +8 -0
- package/dist/publish/youtube/loopback.d.ts +13 -0
- package/dist/publish/youtube/loopback.js +144 -0
- package/dist/publish/youtube/oauth.d.ts +68 -0
- package/dist/publish/youtube/oauth.js +159 -0
- package/dist/publish/youtube/prompt.d.ts +27 -0
- package/dist/publish/youtube/prompt.js +94 -0
- package/dist/publish/youtube/publisher.d.ts +38 -0
- package/dist/publish/youtube/publisher.js +346 -0
- package/dist/publish/youtube/scopes.d.ts +32 -0
- package/dist/publish/youtube/scopes.js +55 -0
- package/dist/publish/youtube/sign-in.d.ts +37 -0
- package/dist/publish/youtube/sign-in.js +137 -0
- package/dist/publish/youtube/upload.d.ts +43 -0
- package/dist/publish/youtube/upload.js +210 -0
- package/dist/render/browser.d.ts +23 -0
- package/dist/render/browser.js +219 -0
- package/dist/render/chromium-renderer.d.ts +56 -0
- package/dist/render/chromium-renderer.js +519 -0
- package/dist/render/ffmpeg.d.ts +55 -0
- package/dist/render/ffmpeg.js +212 -0
- package/dist/render/fonts.d.ts +10 -0
- package/dist/render/fonts.js +42 -0
- package/dist/render/index.d.ts +9 -0
- package/dist/render/index.js +11 -0
- package/dist/render/page.d.ts +46 -0
- package/dist/render/page.js +123 -0
- package/dist/render/playwright.d.ts +3 -0
- package/dist/render/playwright.js +6 -0
- package/dist/render/runtime-bundle.d.ts +2 -0
- package/dist/render/runtime-bundle.js +72 -0
- package/dist/runtime/runtime.js +1626 -0
- package/dist/server/auth.d.ts +17 -0
- package/dist/server/auth.js +58 -0
- package/dist/server/http.d.ts +43 -0
- package/dist/server/http.js +119 -0
- package/dist/server/index.d.ts +46 -0
- package/dist/server/index.js +310 -0
- package/dist/server/queue.d.ts +30 -0
- package/dist/server/queue.js +76 -0
- package/dist/server/schema.d.ts +103 -0
- package/dist/server/schema.js +121 -0
- package/dist/server/source.d.ts +17 -0
- package/dist/server/source.js +100 -0
- package/dist/sources/assemble.d.ts +86 -0
- package/dist/sources/assemble.js +117 -0
- package/dist/sources/diff-parser.d.ts +14 -0
- package/dist/sources/diff-parser.js +84 -0
- package/dist/sources/git.d.ts +28 -0
- package/dist/sources/git.js +108 -0
- package/dist/sources/github.d.ts +20 -0
- package/dist/sources/github.js +192 -0
- package/dist/sources/hunk-selection.d.ts +25 -0
- package/dist/sources/hunk-selection.js +46 -0
- package/dist/sources/index.d.ts +23 -0
- package/dist/sources/index.js +62 -0
- package/dist/sources/limits.d.ts +27 -0
- package/dist/sources/limits.js +22 -0
- package/dist/sources/local.d.ts +34 -0
- package/dist/sources/local.js +555 -0
- package/dist/sources/reader.d.ts +13 -0
- package/dist/sources/reader.js +45 -0
- package/dist/sources/remote.d.ts +13 -0
- package/dist/sources/remote.js +41 -0
- package/dist/sources/repo-context.d.ts +34 -0
- package/dist/sources/repo-context.js +144 -0
- package/dist/sources/text.d.ts +25 -0
- package/dist/sources/text.js +71 -0
- package/dist/storyboard/authoring.d.ts +108 -0
- package/dist/storyboard/authoring.js +196 -0
- package/dist/storyboard/claims.d.ts +35 -0
- package/dist/storyboard/claims.js +318 -0
- package/dist/storyboard/coderef.d.ts +28 -0
- package/dist/storyboard/coderef.js +118 -0
- package/dist/storyboard/generate.d.ts +25 -0
- package/dist/storyboard/generate.js +194 -0
- package/dist/storyboard/heuristic-code.d.ts +91 -0
- package/dist/storyboard/heuristic-code.js +524 -0
- package/dist/storyboard/heuristic-context.d.ts +42 -0
- package/dist/storyboard/heuristic-context.js +102 -0
- package/dist/storyboard/heuristic-facts.d.ts +106 -0
- package/dist/storyboard/heuristic-facts.js +415 -0
- package/dist/storyboard/heuristic-overview.d.ts +4 -0
- package/dist/storyboard/heuristic-overview.js +151 -0
- package/dist/storyboard/heuristic-review.d.ts +10 -0
- package/dist/storyboard/heuristic-review.js +158 -0
- package/dist/storyboard/heuristic-scenes.d.ts +8 -0
- package/dist/storyboard/heuristic-scenes.js +357 -0
- package/dist/storyboard/heuristic-shared.d.ts +43 -0
- package/dist/storyboard/heuristic-shared.js +136 -0
- package/dist/storyboard/heuristic.d.ts +15 -0
- package/dist/storyboard/heuristic.js +324 -0
- package/dist/storyboard/identifiers.d.ts +51 -0
- package/dist/storyboard/identifiers.js +195 -0
- package/dist/storyboard/index.d.ts +10 -0
- package/dist/storyboard/index.js +10 -0
- package/dist/storyboard/prompts.d.ts +16 -0
- package/dist/storyboard/prompts.js +61 -0
- package/dist/storyboard/run.d.ts +82 -0
- package/dist/storyboard/run.js +332 -0
- package/dist/storyboard/text.d.ts +16 -0
- package/dist/storyboard/text.js +103 -0
- package/dist/storyboard/types.d.ts +47 -0
- package/dist/storyboard/types.js +2 -0
- package/dist/storyboard/urls.d.ts +15 -0
- package/dist/storyboard/urls.js +83 -0
- package/dist/storyboard/validate.d.ts +8 -0
- package/dist/storyboard/validate.js +525 -0
- package/dist/storyboard/visuals.d.ts +23 -0
- package/dist/storyboard/visuals.js +324 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +3 -0
- package/dist/visuals/code.d.ts +68 -0
- package/dist/visuals/code.js +385 -0
- package/dist/visuals/highlight.d.ts +17 -0
- package/dist/visuals/highlight.js +85 -0
- package/dist/visuals/image.d.ts +12 -0
- package/dist/visuals/image.js +96 -0
- package/dist/visuals/index.d.ts +10 -0
- package/dist/visuals/index.js +10 -0
- package/dist/visuals/layout.d.ts +89 -0
- package/dist/visuals/layout.js +506 -0
- package/dist/visuals/plan.d.ts +33 -0
- package/dist/visuals/plan.js +511 -0
- package/dist/visuals/timeline.d.ts +31 -0
- package/dist/visuals/timeline.js +96 -0
- package/package.json +74 -4
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** What went wrong when a storage service refused or dropped a request, in words for the person who ran it. */
|
|
2
|
+
import type { RunContext } from '../../core/context.ts';
|
|
3
|
+
import { MergeStoryError } from '../../core/errors.ts';
|
|
4
|
+
interface FailureShape {
|
|
5
|
+
name?: string;
|
|
6
|
+
code?: string;
|
|
7
|
+
message?: string;
|
|
8
|
+
retryable?: boolean;
|
|
9
|
+
$retryable?: unknown;
|
|
10
|
+
$metadata?: {
|
|
11
|
+
httpStatusCode?: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare function shapeOf(err: unknown): FailureShape;
|
|
15
|
+
/** Errors that are worth another attempt: network trouble, throttling and server errors. */
|
|
16
|
+
export declare function isTransient(err: unknown): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The error for a failed request. What the service said is never repeated, because it could hold a
|
|
19
|
+
* secret: the message names the kind of failure only.
|
|
20
|
+
*/
|
|
21
|
+
export declare function toPublishError(err: unknown, ctx: RunContext, action: string): MergeStoryError;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/** What went wrong when a storage service refused or dropped a request, in words for the person who ran it. */
|
|
2
|
+
import { MergeStoryError, toMergeStoryError } from '../../core/errors.js';
|
|
3
|
+
const TRANSIENT_CODES = new Set(['ECONNRESET', 'ETIMEDOUT', 'EPIPE', 'ECONNABORTED', 'EAI_AGAIN']);
|
|
4
|
+
const TRANSIENT_NAMES = new Set([
|
|
5
|
+
'TimeoutError',
|
|
6
|
+
'RequestTimeout',
|
|
7
|
+
'SlowDown',
|
|
8
|
+
'ServiceUnavailable',
|
|
9
|
+
'InternalError',
|
|
10
|
+
]);
|
|
11
|
+
export function shapeOf(err) {
|
|
12
|
+
return err && typeof err === 'object' ? err : {};
|
|
13
|
+
}
|
|
14
|
+
/** Errors that are worth another attempt: network trouble, throttling and server errors. */
|
|
15
|
+
export function isTransient(err) {
|
|
16
|
+
const e = shapeOf(err);
|
|
17
|
+
if (e.name === 'AbortError')
|
|
18
|
+
return false;
|
|
19
|
+
if (e.retryable === true || e.$retryable)
|
|
20
|
+
return true;
|
|
21
|
+
const status = e.$metadata?.httpStatusCode;
|
|
22
|
+
// 501 means the service lacks the feature, so asking again cannot help.
|
|
23
|
+
if (status !== undefined && (status === 408 || status === 429 || (status >= 500 && status !== 501)))
|
|
24
|
+
return true;
|
|
25
|
+
return ((e.name !== undefined && TRANSIENT_NAMES.has(e.name)) ||
|
|
26
|
+
(e.code !== undefined && TRANSIENT_CODES.has(e.code)));
|
|
27
|
+
}
|
|
28
|
+
function describeFailure(err) {
|
|
29
|
+
const e = shapeOf(err);
|
|
30
|
+
const name = e.name ?? 'Error';
|
|
31
|
+
const code = e.code ?? '';
|
|
32
|
+
const status = e.$metadata?.httpStatusCode;
|
|
33
|
+
if ([
|
|
34
|
+
'InvalidAccessKeyId',
|
|
35
|
+
'SignatureDoesNotMatch',
|
|
36
|
+
'InvalidToken',
|
|
37
|
+
'ExpiredToken',
|
|
38
|
+
'InvalidClientTokenId',
|
|
39
|
+
].includes(name)) {
|
|
40
|
+
return {
|
|
41
|
+
message: 'the storage service rejected the credentials.',
|
|
42
|
+
hint: 'Check the access key and secret, and that the region matches the bucket.',
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (name === 'AccessDenied' || name === 'Forbidden' || status === 403) {
|
|
46
|
+
return {
|
|
47
|
+
message: 'access to the bucket was denied.',
|
|
48
|
+
hint: 'The key needs permission to write objects (s3:PutObject) and read them (s3:GetObject) in this bucket.',
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
if (name === 'NoSuchBucket') {
|
|
52
|
+
return {
|
|
53
|
+
message: 'the bucket was not found.',
|
|
54
|
+
hint: 'Check the bucket name, the endpoint and the region.',
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (name === 'PermanentRedirect' || name === 'AuthorizationHeaderMalformed' || status === 301) {
|
|
58
|
+
return {
|
|
59
|
+
message: 'the bucket is in a different region or at a different endpoint.',
|
|
60
|
+
hint: 'Set MERGESTORY_S3_REGION (and MERGESTORY_S3_ENDPOINT for services other than AWS) to match the bucket.',
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
if (code === 'ENOTFOUND' || code === 'EAI_AGAIN') {
|
|
64
|
+
return {
|
|
65
|
+
message: 'the storage endpoint could not be found.',
|
|
66
|
+
hint: 'Check MERGESTORY_S3_ENDPOINT and your network connection.',
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if (name === 'EntityTooLarge') {
|
|
70
|
+
return {
|
|
71
|
+
message: 'the video is larger than the bucket allows.',
|
|
72
|
+
hint: 'Use a shorter video or a lower quality preset, or raise the size limit of the bucket.',
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (name === 'NotImplemented' || status === 501) {
|
|
76
|
+
return {
|
|
77
|
+
message: 'the storage service does not support a request that MergeStory sends.',
|
|
78
|
+
hint: 'Check that MERGESTORY_S3_ENDPOINT is the S3 address of your provider, for example https://<account-id>.r2.cloudflarestorage.com for Cloudflare R2.',
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (isTransient(err) || code === 'ECONNREFUSED') {
|
|
82
|
+
return {
|
|
83
|
+
message: 'the storage service could not be reached or had a temporary problem.',
|
|
84
|
+
hint: 'Check the endpoint and your network connection, then try again.',
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
message: `the storage service returned ${name}${status ? ` (HTTP ${status})` : ''}.`,
|
|
89
|
+
hint: 'Check the bucket, endpoint, region and credentials.',
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The error for a failed request. What the service said is never repeated, because it could hold a
|
|
94
|
+
* secret: the message names the kind of failure only.
|
|
95
|
+
*/
|
|
96
|
+
export function toPublishError(err, ctx, action) {
|
|
97
|
+
if (err instanceof MergeStoryError)
|
|
98
|
+
return err;
|
|
99
|
+
if (err instanceof Error && err.name === 'AbortError')
|
|
100
|
+
return toMergeStoryError(err);
|
|
101
|
+
const { message, hint } = describeFailure(err);
|
|
102
|
+
const status = shapeOf(err).$metadata?.httpStatusCode;
|
|
103
|
+
return new MergeStoryError('PUBLISH_FAILED', ctx.redactor.redact(`${action} failed: ${message}`), {
|
|
104
|
+
hint,
|
|
105
|
+
cause: err,
|
|
106
|
+
retryable: isTransient(err),
|
|
107
|
+
details: { error: shapeOf(err).name ?? 'Error', ...(status ? { status } : {}) },
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=failures.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** S3-compatible publisher, split by concept. This is the part of it that the rest of the engine uses. */
|
|
2
|
+
export { type BucketCheck, checkBucket } from './bucket.ts';
|
|
3
|
+
export { addressMistake } from './protected-links.ts';
|
|
4
|
+
export { S3Publisher } from './publisher.ts';
|
|
5
|
+
export { findS3Problems, type S3Problems } from './settings.ts';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** S3-compatible publisher, split by concept. This is the part of it that the rest of the engine uses. */
|
|
2
|
+
export { checkBucket } from './bucket.js';
|
|
3
|
+
export { addressMistake } from './protected-links.js';
|
|
4
|
+
export { S3Publisher } from './publisher.js';
|
|
5
|
+
export { findS3Problems } from './settings.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The addresses of an upload, for the watch page and the result. Direct links go through a public
|
|
3
|
+
* base URL (public and protected links): nothing is signed and nothing expires. Signed links (private
|
|
4
|
+
* links) are presigned requests for each object, and they stop working after a while.
|
|
5
|
+
*/
|
|
6
|
+
import type { S3Client } from '@aws-sdk/client-s3';
|
|
7
|
+
import type { RunContext } from '../../core/context.ts';
|
|
8
|
+
import type { AssetUrls } from '../../core/providers.ts';
|
|
9
|
+
import { type ClassifiedBundle } from '../bundle.ts';
|
|
10
|
+
import type { S3Libs } from './client.ts';
|
|
11
|
+
/**
|
|
12
|
+
* Link lifetime in seconds: the requested one, within SigV4 limits and the lifetime of the
|
|
13
|
+
* credentials (a signed link stops working when the credentials that signed it expire).
|
|
14
|
+
*/
|
|
15
|
+
export declare function linkLifetime(requested: number, credentialsExpire: Date | undefined, ctx: Pick<RunContext, 'logger'>, now?: number): number;
|
|
16
|
+
export interface Links {
|
|
17
|
+
/** The address of each file, and when the links stop working (null: never). */
|
|
18
|
+
urls: AssetUrls;
|
|
19
|
+
/** The address of the watch page itself, which is uploaded last. */
|
|
20
|
+
watchUrl: string;
|
|
21
|
+
}
|
|
22
|
+
/** Permanent links on the public base URL. */
|
|
23
|
+
export declare function directLinks(publicBase: string, keyPrefix: string, files: ClassifiedBundle): Links;
|
|
24
|
+
interface SignedLinkOptions {
|
|
25
|
+
libs: S3Libs;
|
|
26
|
+
client: S3Client;
|
|
27
|
+
bucket: string;
|
|
28
|
+
keyPrefix: string;
|
|
29
|
+
files: ClassifiedBundle;
|
|
30
|
+
/** The lifetime that was asked for, in seconds (publish.linkExpirySec). */
|
|
31
|
+
lifetimeSec: number;
|
|
32
|
+
/** When the credentials that sign the links expire, if they do. */
|
|
33
|
+
credentialsExpire: Date | undefined;
|
|
34
|
+
ctx: Pick<RunContext, 'logger'>;
|
|
35
|
+
}
|
|
36
|
+
/** Presigned links that stop working after their lifetime. */
|
|
37
|
+
export declare function signedLinks(options: SignedLinkOptions): Promise<Links>;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { MergeStoryError } from '../../core/errors.js';
|
|
2
|
+
import { WATCH_PAGE_NAME } from '../bundle.js';
|
|
3
|
+
/** Longest lifetime of a SigV4 signed link: seven days. */
|
|
4
|
+
const MAX_LINK_SEC = 604_800;
|
|
5
|
+
const MIN_LINK_SEC = 60;
|
|
6
|
+
/**
|
|
7
|
+
* Link lifetime in seconds: the requested one, within SigV4 limits and the lifetime of the
|
|
8
|
+
* credentials (a signed link stops working when the credentials that signed it expire).
|
|
9
|
+
*/
|
|
10
|
+
export function linkLifetime(requested, credentialsExpire, ctx, now = Date.now()) {
|
|
11
|
+
const wanted = Number.isFinite(requested) ? Math.floor(requested) : MAX_LINK_SEC;
|
|
12
|
+
let seconds = Math.min(MAX_LINK_SEC, Math.max(MIN_LINK_SEC, wanted));
|
|
13
|
+
if (credentialsExpire) {
|
|
14
|
+
const left = Math.floor((credentialsExpire.getTime() - now) / 1000);
|
|
15
|
+
if (left < MIN_LINK_SEC) {
|
|
16
|
+
throw new MergeStoryError('PUBLISH_FAILED', 'The storage credentials expire too soon to create a useful link.', {
|
|
17
|
+
hint: 'Refresh the credentials (for example sign in again) and retry.',
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (left < seconds) {
|
|
21
|
+
ctx.logger.warn('Links will stop working when the storage credentials expire', { seconds: left });
|
|
22
|
+
seconds = left;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return seconds;
|
|
26
|
+
}
|
|
27
|
+
/** Permanent links on the public base URL. */
|
|
28
|
+
export function directLinks(publicBase, keyPrefix, files) {
|
|
29
|
+
const address = (name) => `${publicBase}/${`${keyPrefix}${name}`.split('/').map(encodeURIComponent).join('/')}`;
|
|
30
|
+
return {
|
|
31
|
+
urls: {
|
|
32
|
+
video: address(files.video.file.name),
|
|
33
|
+
poster: files.poster ? address(files.poster.file.name) : null,
|
|
34
|
+
captions: files.captions ? address(files.captions.file.name) : null,
|
|
35
|
+
linkExpiresAt: null,
|
|
36
|
+
},
|
|
37
|
+
watchUrl: address(WATCH_PAGE_NAME),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** Presigned links that stop working after their lifetime. */
|
|
41
|
+
export async function signedLinks(options) {
|
|
42
|
+
const { libs, client, bucket, keyPrefix, files } = options;
|
|
43
|
+
const expiresIn = linkLifetime(options.lifetimeSec, options.credentialsExpire, options.ctx);
|
|
44
|
+
// One signing time for every link, so the expiry shown to people is exact.
|
|
45
|
+
const signingDate = new Date();
|
|
46
|
+
const sign = (name) => libs.getSignedUrl(client, new libs.GetObjectCommand({ Bucket: bucket, Key: `${keyPrefix}${name}` }), {
|
|
47
|
+
expiresIn,
|
|
48
|
+
signingDate,
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
urls: {
|
|
52
|
+
video: await sign(files.video.file.name),
|
|
53
|
+
poster: files.poster ? await sign(files.poster.file.name) : null,
|
|
54
|
+
captions: files.captions ? await sign(files.captions.file.name) : null,
|
|
55
|
+
linkExpiresAt: new Date(signingDate.getTime() + expiresIn * 1000).toISOString(),
|
|
56
|
+
},
|
|
57
|
+
watchUrl: await sign(WATCH_PAGE_NAME),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=links.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Protected links are permanent links on a public base URL that sits behind an access proxy such as
|
|
3
|
+
* Cloudflare Access. They are only safe when that address asks for a sign-in, so it is checked before
|
|
4
|
+
* anything is uploaded.
|
|
5
|
+
*/
|
|
6
|
+
import type { RunContext } from '../../core/context.ts';
|
|
7
|
+
import type { AccessProbe } from '../access-probe.ts';
|
|
8
|
+
import type { S3Settings } from './settings.ts';
|
|
9
|
+
/**
|
|
10
|
+
* Two common mistakes with the public base URL of protected links, which show without a network call:
|
|
11
|
+
* an address that cannot be put behind Cloudflare Access, and the storage API address itself (no
|
|
12
|
+
* access proxy sits in front of it). `host` is the host of the address, with its port.
|
|
13
|
+
*/
|
|
14
|
+
export declare function addressMistake(host: string, endpoint: string | null): 'r2-dev' | 'storage-api' | null;
|
|
15
|
+
interface ProtectionCheck {
|
|
16
|
+
/** The public base URL that the links are built on. */
|
|
17
|
+
publicBase: string;
|
|
18
|
+
/** The folder of the upload: the check asks for a file in it, so the answer is about that folder. */
|
|
19
|
+
keyPrefix: string;
|
|
20
|
+
settings: S3Settings;
|
|
21
|
+
probe: AccessProbe;
|
|
22
|
+
ctx: RunContext;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Asks the address anonymously for a file that does not exist, and refuses to continue unless it is
|
|
26
|
+
* clearly protected.
|
|
27
|
+
*/
|
|
28
|
+
export declare function assertProtected({ publicBase, keyPrefix, settings, probe, ctx, }: ProtectionCheck): Promise<void>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { MergeStoryError } from '../../core/errors.js';
|
|
2
|
+
import { isLoopbackHost } from '../../core/net.js';
|
|
3
|
+
/**
|
|
4
|
+
* Two common mistakes with the public base URL of protected links, which show without a network call:
|
|
5
|
+
* an address that cannot be put behind Cloudflare Access, and the storage API address itself (no
|
|
6
|
+
* access proxy sits in front of it). `host` is the host of the address, with its port.
|
|
7
|
+
*/
|
|
8
|
+
export function addressMistake(host, endpoint) {
|
|
9
|
+
if (host.replace(/:\d+$/, '').toLowerCase().endsWith('.r2.dev'))
|
|
10
|
+
return 'r2-dev';
|
|
11
|
+
let endpointHost = '';
|
|
12
|
+
try {
|
|
13
|
+
endpointHost = endpoint ? new URL(endpoint).host.toLowerCase() : '';
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
endpointHost = '';
|
|
17
|
+
}
|
|
18
|
+
return endpointHost && host.toLowerCase() === endpointHost ? 'storage-api' : null;
|
|
19
|
+
}
|
|
20
|
+
/** Extra advice for those two mistakes. */
|
|
21
|
+
function addressAdvice(host, settings) {
|
|
22
|
+
const mistake = addressMistake(host, settings.endpoint);
|
|
23
|
+
if (mistake === 'r2-dev') {
|
|
24
|
+
return ' Addresses that end in r2.dev cannot be put behind Cloudflare Access: connect a custom domain to the bucket and use that.';
|
|
25
|
+
}
|
|
26
|
+
if (mistake === 'storage-api') {
|
|
27
|
+
return ' This is the storage API address, which no access proxy sits in front of: use the custom domain of the bucket as the public base URL.';
|
|
28
|
+
}
|
|
29
|
+
return '';
|
|
30
|
+
}
|
|
31
|
+
/** The error for an address that did not prove to be behind a sign-in. Holds no secret and no full address. */
|
|
32
|
+
function protectionBlocked(result, settings) {
|
|
33
|
+
const open = result.verdict === 'not-protected';
|
|
34
|
+
const fix = open
|
|
35
|
+
? 'Put the address behind an access proxy such as Cloudflare Access before you upload (see docs/hosting.md in the MergeStory repository), or use private links that expire (--visibility private).'
|
|
36
|
+
: 'Check that the address is the custom domain of the bucket and that an access policy covers it (see docs/hosting.md in the MergeStory repository), or use private links that expire (--visibility private).';
|
|
37
|
+
return new MergeStoryError('PRIVACY_BLOCKED', open
|
|
38
|
+
? `Protected links are blocked: ${result.host} is not behind a sign-in.`
|
|
39
|
+
: `Protected links are blocked: MergeStory could not confirm that ${result.host} needs a sign-in.`, {
|
|
40
|
+
hint: `Seen: ${result.host} ${result.detail}. ${fix}${addressAdvice(result.host, settings)} ` +
|
|
41
|
+
'If this machine cannot reach the address (for example a domain that only works on a VPN), set ' +
|
|
42
|
+
'publish.s3.verifyProtection to false (MERGESTORY_S3_VERIFY_PROTECTION=false) to skip this check.',
|
|
43
|
+
details: { host: result.host, verdict: result.verdict, reason: result.reason, status: result.status },
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Asks the address anonymously for a file that does not exist, and refuses to continue unless it is
|
|
48
|
+
* clearly protected.
|
|
49
|
+
*/
|
|
50
|
+
export async function assertProtected({ publicBase, keyPrefix, settings, probe, ctx, }) {
|
|
51
|
+
const url = new URL(publicBase);
|
|
52
|
+
if (url.protocol === 'http:' && !isLoopbackHost(url.hostname)) {
|
|
53
|
+
ctx.logger.warn('The public base URL uses http, so the sign-in and the video are not encrypted');
|
|
54
|
+
}
|
|
55
|
+
const result = await probe(publicBase, { pathPrefix: keyPrefix, signal: ctx.signal });
|
|
56
|
+
// The request carries no content, but it is still a connection to the address, so it is reported.
|
|
57
|
+
ctx.egress.record(result.host.replace(/:\d+$/, ''), 'protection check', 0, []);
|
|
58
|
+
ctx.logger.debug('Checked the link address', { reason: result.reason, status: result.status });
|
|
59
|
+
if (result.verdict !== 'protected')
|
|
60
|
+
throw protectionBlocked(result, settings);
|
|
61
|
+
ctx.progress({
|
|
62
|
+
stage: 'publish',
|
|
63
|
+
status: 'progress',
|
|
64
|
+
message: 'Checked that the link address needs a sign-in',
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=protected-links.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* S3-compatible publisher: Amazon S3, Cloudflare R2, Backblaze B2, Google Cloud Storage,
|
|
3
|
+
* self-hosted servers such as Garage or SeaweedFS, and similar services.
|
|
4
|
+
*
|
|
5
|
+
* Each upload brings its own random key prefix (see buildKeyPrefix), so uploads of different runs
|
|
6
|
+
* never collide. The kind of links comes from the settings (publish.visibility):
|
|
7
|
+
* - private (the default): signed links that expire;
|
|
8
|
+
* - protected: permanent links through a public base URL that sits behind an access proxy such
|
|
9
|
+
* as Cloudflare Access. The address is checked before anything is uploaded;
|
|
10
|
+
* - public: permanent links through a public base URL that anyone can open.
|
|
11
|
+
*/
|
|
12
|
+
import type { Config } from '../../core/config.ts';
|
|
13
|
+
import type { RunContext } from '../../core/context.ts';
|
|
14
|
+
import { MergeStoryError } from '../../core/errors.ts';
|
|
15
|
+
import type { PublishBundle, PublishCheckContext, Publisher } from '../../core/providers.ts';
|
|
16
|
+
import type { EgressRecord, PublishResult } from '../../core/types.ts';
|
|
17
|
+
import { type AccessProbe } from '../access-probe.ts';
|
|
18
|
+
/** Things the publisher uses that tests can replace. */
|
|
19
|
+
interface S3PublisherOptions {
|
|
20
|
+
/** The check that an address needs a sign-in, used for protected links. */
|
|
21
|
+
probeAccess?: AccessProbe;
|
|
22
|
+
}
|
|
23
|
+
export declare class S3Publisher implements Publisher {
|
|
24
|
+
readonly id = "s3";
|
|
25
|
+
private readonly config;
|
|
26
|
+
private readonly probeAccess;
|
|
27
|
+
constructor(config: Config, options?: S3PublisherOptions);
|
|
28
|
+
check(ctx: PublishCheckContext, repoIsPrivate: boolean | null): Promise<MergeStoryError | null>;
|
|
29
|
+
plannedEgress(estimatedBytes: number): EgressRecord[];
|
|
30
|
+
publish(bundle: PublishBundle, ctx: RunContext): Promise<PublishResult>;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { assertNotAborted, MergeStoryError } from '../../core/errors.js';
|
|
2
|
+
import { probeAccessProtection } from '../access-probe.js';
|
|
3
|
+
import { classifyBundle } from '../bundle.js';
|
|
4
|
+
import { buildKeyPrefix } from '../keys.js';
|
|
5
|
+
import { assertNotDryRun } from '../privacy.js';
|
|
6
|
+
import { BUNDLE_CONTAINS } from '../types.js';
|
|
7
|
+
import { configuredRegion, createClient, egressHost, loadLibs, resolveCredentials, resolveRegion, } from './client.js';
|
|
8
|
+
import { directLinks, signedLinks } from './links.js';
|
|
9
|
+
import { assertProtected } from './protected-links.js';
|
|
10
|
+
import { findS3Problems, firstProblem, publicBaseOf } from './settings.js';
|
|
11
|
+
import { uploadBundle } from './upload.js';
|
|
12
|
+
export class S3Publisher {
|
|
13
|
+
id = 's3';
|
|
14
|
+
config;
|
|
15
|
+
probeAccess;
|
|
16
|
+
constructor(config, options = {}) {
|
|
17
|
+
this.config = config;
|
|
18
|
+
this.probeAccess = options.probeAccess ?? probeAccessProtection;
|
|
19
|
+
}
|
|
20
|
+
async check(ctx, repoIsPrivate) {
|
|
21
|
+
return firstProblem(findS3Problems(this.config, ctx.secrets, this.config.publish.visibility, repoIsPrivate));
|
|
22
|
+
}
|
|
23
|
+
plannedEgress(estimatedBytes) {
|
|
24
|
+
const { visibility, s3 } = this.config.publish;
|
|
25
|
+
const bucket = s3.bucket?.trim();
|
|
26
|
+
if (!bucket)
|
|
27
|
+
return [];
|
|
28
|
+
// Without an endpoint the upload goes to the bucket's own address, which names the region. When the
|
|
29
|
+
// settings name none, the AWS SDK finds it in the environment, so that is where the plan looks.
|
|
30
|
+
const region = configuredRegion(s3) ?? process.env.AWS_REGION ?? process.env.AWS_DEFAULT_REGION ?? '';
|
|
31
|
+
const records = [
|
|
32
|
+
{
|
|
33
|
+
destination: egressHost(s3, bucket, region),
|
|
34
|
+
purpose: 'video upload',
|
|
35
|
+
bytes: estimatedBytes,
|
|
36
|
+
contains: [...BUNDLE_CONTAINS],
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
const publicBase = publicBaseOf(s3.publicBaseUrl);
|
|
40
|
+
if (visibility === 'protected' && s3.verifyProtection && publicBase) {
|
|
41
|
+
// An anonymous request that checks the sign-in step; it carries nothing from the change.
|
|
42
|
+
records.push({
|
|
43
|
+
destination: new URL(publicBase).hostname,
|
|
44
|
+
purpose: 'protection check',
|
|
45
|
+
bytes: 0,
|
|
46
|
+
contains: [],
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return records;
|
|
50
|
+
}
|
|
51
|
+
async publish(bundle, ctx) {
|
|
52
|
+
const config = this.config;
|
|
53
|
+
const { visibility, linkExpirySec, s3: settings } = config.publish;
|
|
54
|
+
assertNotDryRun(ctx);
|
|
55
|
+
// Checked first, before any network activity, so a blocked upload never touches storage. The kind of
|
|
56
|
+
// links decides which rules apply. Protected links are allowed for private repositories: that is
|
|
57
|
+
// what they are for.
|
|
58
|
+
const problem = firstProblem(findS3Problems(config, ctx.secrets, visibility, bundle.repoIsPrivate));
|
|
59
|
+
if (problem)
|
|
60
|
+
throw problem;
|
|
61
|
+
const bucket = settings.bucket?.trim();
|
|
62
|
+
// Protected and public links both go through the public base URL. Anything else gets signed links.
|
|
63
|
+
const publicBase = visibility === 'public' || visibility === 'protected' ? publicBaseOf(settings.publicBaseUrl) : null;
|
|
64
|
+
const files = await classifyBundle(bundle);
|
|
65
|
+
// The prefix holds the random part that keeps links unguessable.
|
|
66
|
+
const keyPrefix = buildKeyPrefix(settings.prefix);
|
|
67
|
+
assertNotAborted(ctx.signal);
|
|
68
|
+
const libs = await loadLibs();
|
|
69
|
+
const client = createClient(libs, settings, ctx.secrets);
|
|
70
|
+
try {
|
|
71
|
+
const region = await resolveRegion(client);
|
|
72
|
+
const credentials = await resolveCredentials(client);
|
|
73
|
+
// Before anything is uploaded: a video of private code must not land behind an open address.
|
|
74
|
+
if (visibility === 'protected' && publicBase && settings.verifyProtection) {
|
|
75
|
+
await assertProtected({ publicBase, keyPrefix, settings, probe: this.probeAccess, ctx });
|
|
76
|
+
}
|
|
77
|
+
const links = publicBase
|
|
78
|
+
? directLinks(publicBase, keyPrefix, files)
|
|
79
|
+
: await signedLinks({
|
|
80
|
+
libs,
|
|
81
|
+
client,
|
|
82
|
+
bucket,
|
|
83
|
+
keyPrefix,
|
|
84
|
+
files,
|
|
85
|
+
lifetimeSec: linkExpirySec,
|
|
86
|
+
credentialsExpire: credentials.expiration,
|
|
87
|
+
ctx,
|
|
88
|
+
});
|
|
89
|
+
const html = bundle.buildWatchPage(links.urls);
|
|
90
|
+
if (typeof html !== 'string' || html.length === 0) {
|
|
91
|
+
throw new MergeStoryError('PUBLISH_FAILED', 'The watch page is empty.', {
|
|
92
|
+
hint: 'The watch page builder returned no HTML.',
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
await uploadBundle({
|
|
96
|
+
libs,
|
|
97
|
+
client,
|
|
98
|
+
bucket,
|
|
99
|
+
host: egressHost(settings, bucket, region),
|
|
100
|
+
keyPrefix,
|
|
101
|
+
files,
|
|
102
|
+
page: Buffer.from(html, 'utf8'),
|
|
103
|
+
visibility,
|
|
104
|
+
contains: bundle.contains,
|
|
105
|
+
ctx,
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
provider: 's3',
|
|
109
|
+
watchUrl: links.watchUrl,
|
|
110
|
+
videoUrl: links.urls.video,
|
|
111
|
+
posterUrl: links.urls.poster,
|
|
112
|
+
captionsUrl: links.urls.captions,
|
|
113
|
+
expiresAt: links.urls.linkExpiresAt,
|
|
114
|
+
visibility,
|
|
115
|
+
location: `s3://${bucket}/${keyPrefix}`,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
finally {
|
|
119
|
+
client.destroy();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=publisher.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the storage settings allow. These rules read settings and secrets and make no network call, so
|
|
3
|
+
* an upload can be refused before it touches storage. `findS3Problems` returns every problem by cause
|
|
4
|
+
* (`mergestory doctor` shows each on its own line); a publisher stops at the first one.
|
|
5
|
+
*/
|
|
6
|
+
import type { Config, Secrets } from '../../core/config.ts';
|
|
7
|
+
import { MergeStoryError } from '../../core/errors.ts';
|
|
8
|
+
export type S3Settings = Config['publish']['s3'];
|
|
9
|
+
/** Who may open the links of an upload. */
|
|
10
|
+
export type Visibility = Config['publish']['visibility'];
|
|
11
|
+
/** One of the two storage key variables without the other: both are needed, or neither. */
|
|
12
|
+
export declare function keysProblem(secrets: Pick<Secrets, 'get'>): MergeStoryError | null;
|
|
13
|
+
/** The address that links are built on: the usable public base URL without query, fragment and trailing slashes. */
|
|
14
|
+
export declare function publicBaseOf(value: string | null): string | null;
|
|
15
|
+
export declare function bucketProblem(s3: S3Settings): MergeStoryError | null;
|
|
16
|
+
/** What an upload refuses about the settings, by cause. An upload stops at the first one, in this order. */
|
|
17
|
+
export interface S3Problems {
|
|
18
|
+
/** Public links for a private repository (or one that cannot be told apart from it). */
|
|
19
|
+
privacy: MergeStoryError | null;
|
|
20
|
+
bucket: MergeStoryError | null;
|
|
21
|
+
/** Public and protected links need an address to be built on. */
|
|
22
|
+
publicBase: MergeStoryError | null;
|
|
23
|
+
/** Half of the storage key pair. */
|
|
24
|
+
keys: MergeStoryError | null;
|
|
25
|
+
}
|
|
26
|
+
/** Every problem with the storage settings for links of this visibility. */
|
|
27
|
+
export declare function findS3Problems(config: Config, secrets: Pick<Secrets, 'get'>, visibility: Visibility, repoIsPrivate: boolean | null): S3Problems;
|
|
28
|
+
/** The problem that an upload stops at. */
|
|
29
|
+
export declare function firstProblem(problems: S3Problems): MergeStoryError | null;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { MergeStoryError } from '../../core/errors.js';
|
|
2
|
+
import { exposureProblem } from '../privacy.js';
|
|
3
|
+
import { safeHttpUrl } from '../text.js';
|
|
4
|
+
/** One of the two storage key variables without the other: both are needed, or neither. */
|
|
5
|
+
export function keysProblem(secrets) {
|
|
6
|
+
const hasKeyId = secrets.get('MERGESTORY_S3_ACCESS_KEY_ID') !== null;
|
|
7
|
+
if (hasKeyId === (secrets.get('MERGESTORY_S3_SECRET_ACCESS_KEY') !== null))
|
|
8
|
+
return null;
|
|
9
|
+
return new MergeStoryError('CONFIG_INVALID', 'Only one of the two storage credential variables is set.', {
|
|
10
|
+
hint: 'Set both MERGESTORY_S3_ACCESS_KEY_ID and MERGESTORY_S3_SECRET_ACCESS_KEY, or neither to use the AWS credential chain.',
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
/** Public and protected links go through a public base URL. The problem when the setting holds no usable one. */
|
|
14
|
+
function publicBaseProblem(value, visibility) {
|
|
15
|
+
if (visibility !== 'public' && visibility !== 'protected')
|
|
16
|
+
return null;
|
|
17
|
+
if (value && safeHttpUrl(value))
|
|
18
|
+
return null;
|
|
19
|
+
if (visibility === 'protected') {
|
|
20
|
+
return new MergeStoryError('CONFIG_INVALID', 'Protected links need a public base URL.', {
|
|
21
|
+
hint: 'Set MERGESTORY_S3_PUBLIC_BASE_URL (publish.s3.publicBaseUrl) to the custom domain of the bucket, the one that ' +
|
|
22
|
+
'sits behind your access proxy, for example https://videos.example.com. See docs/hosting.md in the MergeStory repository. ' +
|
|
23
|
+
'Or use private links, which are signed and expire.',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return new MergeStoryError('CONFIG_INVALID', 'Public links need a public base URL.', {
|
|
27
|
+
hint: 'Set MERGESTORY_S3_PUBLIC_BASE_URL to the address that serves the bucket (a CDN, a custom domain or a public bucket URL), ' +
|
|
28
|
+
'or use private links.',
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** The address that links are built on: the usable public base URL without query, fragment and trailing slashes. */
|
|
32
|
+
export function publicBaseOf(value) {
|
|
33
|
+
const url = value ? safeHttpUrl(value) : null;
|
|
34
|
+
return url ? url.replace(/[?#].*$/, '').replace(/\/+$/, '') : null;
|
|
35
|
+
}
|
|
36
|
+
export function bucketProblem(s3) {
|
|
37
|
+
if (s3.bucket?.trim())
|
|
38
|
+
return null;
|
|
39
|
+
return new MergeStoryError('CONFIG_INVALID', 'No storage bucket is configured.', {
|
|
40
|
+
hint: 'Set MERGESTORY_S3_BUCKET, or publish.s3.bucket in the config file.',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/** The refusal of public links for a repository that is private, or that cannot be told apart from one. */
|
|
44
|
+
const PUBLIC_LINKS_BLOCKED = {
|
|
45
|
+
isPrivate: 'This repository is private, so public video links are blocked.',
|
|
46
|
+
unknown: 'MergeStory cannot tell whether this repository is private, so public video links are blocked.',
|
|
47
|
+
hint: 'Use private links (signed links that expire), or set publish.allowPublicForPrivateRepos to true ' +
|
|
48
|
+
'if anyone with the link may watch the video.',
|
|
49
|
+
};
|
|
50
|
+
/** Every problem with the storage settings for links of this visibility. */
|
|
51
|
+
export function findS3Problems(config, secrets, visibility, repoIsPrivate) {
|
|
52
|
+
const { s3 } = config.publish;
|
|
53
|
+
return {
|
|
54
|
+
privacy: exposureProblem(config, visibility === 'public', repoIsPrivate, PUBLIC_LINKS_BLOCKED),
|
|
55
|
+
bucket: bucketProblem(s3),
|
|
56
|
+
publicBase: publicBaseProblem(s3.publicBaseUrl, visibility),
|
|
57
|
+
keys: keysProblem(secrets),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** The problem that an upload stops at. */
|
|
61
|
+
export function firstProblem(problems) {
|
|
62
|
+
return problems.privacy ?? problems.bucket ?? problems.publicBase ?? problems.keys;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { S3Client } from '@aws-sdk/client-s3';
|
|
2
|
+
import type { RunContext } from '../../core/context.ts';
|
|
3
|
+
import type { EgressContent } from '../../core/types.ts';
|
|
4
|
+
import { type ClassifiedBundle } from '../bundle.ts';
|
|
5
|
+
import type { S3Libs } from './client.ts';
|
|
6
|
+
import type { Visibility } from './settings.ts';
|
|
7
|
+
interface BundleUpload {
|
|
8
|
+
libs: S3Libs;
|
|
9
|
+
client: S3Client;
|
|
10
|
+
bucket: string;
|
|
11
|
+
/** Host name that receives the upload, for the egress report. */
|
|
12
|
+
host: string;
|
|
13
|
+
/** The folder of this upload in the bucket, ending in "/". */
|
|
14
|
+
keyPrefix: string;
|
|
15
|
+
files: ClassifiedBundle;
|
|
16
|
+
/** The watch page. It goes last, so it never points at files that are not there yet. */
|
|
17
|
+
page: Buffer;
|
|
18
|
+
/** The kind of links decides the cache headers. */
|
|
19
|
+
visibility: Visibility;
|
|
20
|
+
/** What the files contain, for the egress report. */
|
|
21
|
+
contains: EgressContent[];
|
|
22
|
+
ctx: RunContext;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Upload the files and then the watch page, in that order. Stops at the first file that cannot be sent
|
|
26
|
+
* and then removes the files that were already sent.
|
|
27
|
+
*/
|
|
28
|
+
export declare function uploadBundle(upload: BundleUpload): Promise<void>;
|
|
29
|
+
export {};
|