magic-hour 0.36.0 → 0.38.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/README.md +202 -10
- package/dist/client.d.ts +1 -1
- package/dist/client.js +3 -3
- package/dist/environment.d.ts +1 -1
- package/dist/environment.js +1 -1
- package/dist/helpers/download.d.ts +5 -0
- package/dist/helpers/download.js +88 -0
- package/dist/helpers/generate-type.d.ts +51 -0
- package/dist/helpers/generate-type.js +2 -0
- package/dist/helpers/sleep.d.ts +4 -0
- package/dist/helpers/sleep.js +9 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/logger.d.ts +48 -0
- package/dist/logger.js +97 -0
- package/dist/resources/v1/ai-clothes-changer/request-types.js +3 -3
- package/dist/resources/v1/ai-clothes-changer/resource-client.d.ts +51 -1
- package/dist/resources/v1/ai-clothes-changer/resource-client.js +77 -2
- package/dist/resources/v1/ai-face-editor/request-types.js +3 -3
- package/dist/resources/v1/ai-face-editor/resource-client.d.ts +56 -1
- package/dist/resources/v1/ai-face-editor/resource-client.js +87 -2
- package/dist/resources/v1/ai-gif-generator/request-types.js +3 -3
- package/dist/resources/v1/ai-gif-generator/resource-client.d.ts +30 -1
- package/dist/resources/v1/ai-gif-generator/resource-client.js +62 -2
- package/dist/resources/v1/ai-headshot-generator/request-types.js +3 -3
- package/dist/resources/v1/ai-headshot-generator/resource-client.d.ts +39 -1
- package/dist/resources/v1/ai-headshot-generator/resource-client.js +70 -2
- package/dist/resources/v1/ai-image-editor/request-types.js +3 -3
- package/dist/resources/v1/ai-image-editor/resource-client.d.ts +40 -1
- package/dist/resources/v1/ai-image-editor/resource-client.js +71 -2
- package/dist/resources/v1/ai-image-generator/request-types.js +3 -3
- package/dist/resources/v1/ai-image-generator/resource-client.d.ts +32 -1
- package/dist/resources/v1/ai-image-generator/resource-client.js +64 -2
- package/dist/resources/v1/ai-image-upscaler/request-types.js +3 -3
- package/dist/resources/v1/ai-image-upscaler/resource-client.d.ts +41 -1
- package/dist/resources/v1/ai-image-upscaler/resource-client.js +72 -2
- package/dist/resources/v1/ai-meme-generator/request-types.js +3 -3
- package/dist/resources/v1/ai-meme-generator/resource-client.d.ts +34 -1
- package/dist/resources/v1/ai-meme-generator/resource-client.js +66 -2
- package/dist/resources/v1/ai-photo-editor/request-types.js +3 -3
- package/dist/resources/v1/ai-photo-editor/resource-client.d.ts +50 -1
- package/dist/resources/v1/ai-photo-editor/resource-client.js +81 -2
- package/dist/resources/v1/ai-qr-code-generator/request-types.js +3 -3
- package/dist/resources/v1/ai-qr-code-generator/resource-client.d.ts +31 -1
- package/dist/resources/v1/ai-qr-code-generator/resource-client.js +63 -2
- package/dist/resources/v1/ai-talking-photo/request-types.js +3 -3
- package/dist/resources/v1/ai-talking-photo/resource-client.d.ts +52 -1
- package/dist/resources/v1/ai-talking-photo/resource-client.js +78 -2
- package/dist/resources/v1/animation/request-types.js +3 -3
- package/dist/resources/v1/animation/resource-client.d.ts +62 -1
- package/dist/resources/v1/animation/resource-client.js +100 -2
- package/dist/resources/v1/auto-subtitle-generator/request-types.js +3 -3
- package/dist/resources/v1/auto-subtitle-generator/resource-client.d.ts +42 -1
- package/dist/resources/v1/auto-subtitle-generator/resource-client.js +73 -2
- package/dist/resources/v1/face-detection/request-types.js +5 -5
- package/dist/resources/v1/face-detection/resource-client.d.ts +31 -1
- package/dist/resources/v1/face-detection/resource-client.js +77 -2
- package/dist/resources/v1/face-swap/request-types.js +3 -3
- package/dist/resources/v1/face-swap/resource-client.d.ts +78 -1
- package/dist/resources/v1/face-swap/resource-client.js +127 -2
- package/dist/resources/v1/face-swap-photo/request-types.js +3 -3
- package/dist/resources/v1/face-swap-photo/resource-client.d.ts +74 -1
- package/dist/resources/v1/face-swap-photo/resource-client.js +119 -2
- package/dist/resources/v1/files/resource-client.d.ts +41 -1
- package/dist/resources/v1/files/resource-client.js +238 -2
- package/dist/resources/v1/files/resource-client.test.d.ts +1 -0
- package/dist/resources/v1/files/resource-client.test.js +422 -0
- package/dist/resources/v1/files/upload-urls/request-types.js +3 -3
- package/dist/resources/v1/files/upload-urls/resource-client.d.ts +1 -1
- package/dist/resources/v1/files/upload-urls/resource-client.js +2 -2
- package/dist/resources/v1/image-background-remover/request-types.js +3 -3
- package/dist/resources/v1/image-background-remover/resource-client.d.ts +50 -1
- package/dist/resources/v1/image-background-remover/resource-client.js +84 -2
- package/dist/resources/v1/image-projects/request-types.js +5 -5
- package/dist/resources/v1/image-projects/resource-client.d.ts +23 -1
- package/dist/resources/v1/image-projects/resource-client.js +70 -2
- package/dist/resources/v1/image-projects/resource-client.test.d.ts +1 -0
- package/dist/resources/v1/image-projects/resource-client.test.js +538 -0
- package/dist/resources/v1/image-to-video/request-types.js +3 -3
- package/dist/resources/v1/image-to-video/resource-client.d.ts +41 -1
- package/dist/resources/v1/image-to-video/resource-client.js +72 -2
- package/dist/resources/v1/lip-sync/request-types.js +3 -3
- package/dist/resources/v1/lip-sync/resource-client.d.ts +54 -1
- package/dist/resources/v1/lip-sync/resource-client.js +86 -2
- package/dist/resources/v1/photo-colorizer/request-types.js +3 -3
- package/dist/resources/v1/photo-colorizer/resource-client.d.ts +39 -1
- package/dist/resources/v1/photo-colorizer/resource-client.js +70 -2
- package/dist/resources/v1/resource-client.d.ts +1 -1
- package/dist/resources/v1/resource-client.js +2 -2
- package/dist/resources/v1/text-to-video/request-types.js +3 -3
- package/dist/resources/v1/text-to-video/resource-client.d.ts +33 -1
- package/dist/resources/v1/text-to-video/resource-client.js +65 -2
- package/dist/resources/v1/video-projects/request-types.js +5 -5
- package/dist/resources/v1/video-projects/resource-client.d.ts +23 -1
- package/dist/resources/v1/video-projects/resource-client.js +70 -2
- package/dist/resources/v1/video-projects/resource-client.test.d.ts +1 -0
- package/dist/resources/v1/video-projects/resource-client.test.js +713 -0
- package/dist/resources/v1/video-to-video/request-types.js +3 -3
- package/dist/resources/v1/video-to-video/resource-client.d.ts +49 -1
- package/dist/resources/v1/video-to-video/resource-client.js +86 -2
- package/dist/types/v1-ai-clothes-changer-create-body-assets.js +3 -3
- package/dist/types/v1-ai-clothes-changer-create-body.js +3 -3
- package/dist/types/v1-ai-clothes-changer-create-response.js +3 -3
- package/dist/types/v1-ai-clothes-changer-create-response400.js +3 -3
- package/dist/types/v1-ai-clothes-changer-create-response401.js +3 -3
- package/dist/types/v1-ai-clothes-changer-create-response404.js +3 -3
- package/dist/types/v1-ai-clothes-changer-create-response422.js +3 -3
- package/dist/types/v1-ai-face-editor-create-body-assets.js +3 -3
- package/dist/types/v1-ai-face-editor-create-body-style.js +3 -3
- package/dist/types/v1-ai-face-editor-create-body.js +3 -3
- package/dist/types/v1-ai-face-editor-create-response.js +3 -3
- package/dist/types/v1-ai-face-editor-create-response400.js +3 -3
- package/dist/types/v1-ai-face-editor-create-response401.js +3 -3
- package/dist/types/v1-ai-face-editor-create-response404.js +3 -3
- package/dist/types/v1-ai-face-editor-create-response422.js +3 -3
- package/dist/types/v1-ai-gif-generator-create-body-style.js +3 -3
- package/dist/types/v1-ai-gif-generator-create-body.js +3 -3
- package/dist/types/v1-ai-gif-generator-create-response.js +3 -3
- package/dist/types/v1-ai-gif-generator-create-response400.js +3 -3
- package/dist/types/v1-ai-gif-generator-create-response401.js +3 -3
- package/dist/types/v1-ai-gif-generator-create-response404.js +3 -3
- package/dist/types/v1-ai-gif-generator-create-response422.js +3 -3
- package/dist/types/v1-ai-headshot-generator-create-body-assets.js +3 -3
- package/dist/types/v1-ai-headshot-generator-create-body-style.js +3 -3
- package/dist/types/v1-ai-headshot-generator-create-body.js +3 -3
- package/dist/types/v1-ai-headshot-generator-create-response.js +3 -3
- package/dist/types/v1-ai-headshot-generator-create-response400.js +3 -3
- package/dist/types/v1-ai-headshot-generator-create-response401.js +3 -3
- package/dist/types/v1-ai-headshot-generator-create-response404.js +3 -3
- package/dist/types/v1-ai-headshot-generator-create-response422.js +3 -3
- package/dist/types/v1-ai-image-editor-create-body-assets.js +3 -3
- package/dist/types/v1-ai-image-editor-create-body-style.js +3 -3
- package/dist/types/v1-ai-image-editor-create-body.js +3 -3
- package/dist/types/v1-ai-image-editor-create-response.js +3 -3
- package/dist/types/v1-ai-image-editor-create-response400.js +3 -3
- package/dist/types/v1-ai-image-editor-create-response401.js +3 -3
- package/dist/types/v1-ai-image-editor-create-response404.js +3 -3
- package/dist/types/v1-ai-image-editor-create-response422.js +3 -3
- package/dist/types/v1-ai-image-generator-create-body-style.js +3 -3
- package/dist/types/v1-ai-image-generator-create-body.js +3 -3
- package/dist/types/v1-ai-image-generator-create-response.js +3 -3
- package/dist/types/v1-ai-image-generator-create-response400.js +3 -3
- package/dist/types/v1-ai-image-generator-create-response401.js +3 -3
- package/dist/types/v1-ai-image-generator-create-response404.js +3 -3
- package/dist/types/v1-ai-image-generator-create-response422.js +3 -3
- package/dist/types/v1-ai-image-upscaler-create-body-assets.js +3 -3
- package/dist/types/v1-ai-image-upscaler-create-body-style.js +3 -3
- package/dist/types/v1-ai-image-upscaler-create-body.js +3 -3
- package/dist/types/v1-ai-image-upscaler-create-response.js +3 -3
- package/dist/types/v1-ai-image-upscaler-create-response400.js +3 -3
- package/dist/types/v1-ai-image-upscaler-create-response401.js +3 -3
- package/dist/types/v1-ai-image-upscaler-create-response404.js +3 -3
- package/dist/types/v1-ai-image-upscaler-create-response422.js +3 -3
- package/dist/types/v1-ai-meme-generator-create-body-style.js +3 -3
- package/dist/types/v1-ai-meme-generator-create-body.js +3 -3
- package/dist/types/v1-ai-meme-generator-create-response.js +3 -3
- package/dist/types/v1-ai-meme-generator-create-response400.js +3 -3
- package/dist/types/v1-ai-meme-generator-create-response401.js +3 -3
- package/dist/types/v1-ai-meme-generator-create-response404.js +3 -3
- package/dist/types/v1-ai-meme-generator-create-response422.js +3 -3
- package/dist/types/v1-ai-photo-editor-create-body-assets.js +3 -3
- package/dist/types/v1-ai-photo-editor-create-body-style.js +3 -3
- package/dist/types/v1-ai-photo-editor-create-body.js +3 -3
- package/dist/types/v1-ai-photo-editor-create-response.js +3 -3
- package/dist/types/v1-ai-photo-editor-create-response400.js +3 -3
- package/dist/types/v1-ai-photo-editor-create-response401.js +3 -3
- package/dist/types/v1-ai-photo-editor-create-response404.js +3 -3
- package/dist/types/v1-ai-photo-editor-create-response422.js +3 -3
- package/dist/types/v1-ai-qr-code-generator-create-body-style.js +3 -3
- package/dist/types/v1-ai-qr-code-generator-create-body.js +3 -3
- package/dist/types/v1-ai-qr-code-generator-create-response.js +3 -3
- package/dist/types/v1-ai-qr-code-generator-create-response400.js +3 -3
- package/dist/types/v1-ai-qr-code-generator-create-response401.js +3 -3
- package/dist/types/v1-ai-qr-code-generator-create-response404.js +3 -3
- package/dist/types/v1-ai-qr-code-generator-create-response422.js +3 -3
- package/dist/types/v1-ai-talking-photo-create-body-assets.js +3 -3
- package/dist/types/v1-ai-talking-photo-create-body-style-generation-mode-enum.d.ts +3 -2
- package/dist/types/v1-ai-talking-photo-create-body-style.d.ts +4 -3
- package/dist/types/v1-ai-talking-photo-create-body-style.js +5 -5
- package/dist/types/v1-ai-talking-photo-create-body.js +3 -3
- package/dist/types/v1-ai-talking-photo-create-response.js +3 -3
- package/dist/types/v1-ai-talking-photo-create-response400.js +3 -3
- package/dist/types/v1-ai-talking-photo-create-response401.js +3 -3
- package/dist/types/v1-ai-talking-photo-create-response404.js +3 -3
- package/dist/types/v1-ai-talking-photo-create-response422.js +3 -3
- package/dist/types/v1-animation-create-body-assets.js +3 -3
- package/dist/types/v1-animation-create-body-style.js +3 -3
- package/dist/types/v1-animation-create-body.js +3 -3
- package/dist/types/v1-animation-create-response.js +3 -3
- package/dist/types/v1-animation-create-response400.js +3 -3
- package/dist/types/v1-animation-create-response401.js +3 -3
- package/dist/types/v1-animation-create-response404.js +3 -3
- package/dist/types/v1-animation-create-response422.js +3 -3
- package/dist/types/v1-auto-subtitle-generator-create-body-assets.js +3 -3
- package/dist/types/v1-auto-subtitle-generator-create-body-style-custom-config.js +3 -3
- package/dist/types/v1-auto-subtitle-generator-create-body-style.js +3 -3
- package/dist/types/v1-auto-subtitle-generator-create-body.js +3 -3
- package/dist/types/v1-auto-subtitle-generator-create-response.js +3 -3
- package/dist/types/v1-auto-subtitle-generator-create-response400.js +3 -3
- package/dist/types/v1-auto-subtitle-generator-create-response401.js +3 -3
- package/dist/types/v1-auto-subtitle-generator-create-response404.js +3 -3
- package/dist/types/v1-auto-subtitle-generator-create-response422.js +3 -3
- package/dist/types/v1-face-detection-create-body-assets.js +3 -3
- package/dist/types/v1-face-detection-create-body.js +3 -3
- package/dist/types/v1-face-detection-create-response.js +3 -3
- package/dist/types/v1-face-detection-create-response400.js +3 -3
- package/dist/types/v1-face-detection-create-response401.js +3 -3
- package/dist/types/v1-face-detection-create-response404.js +3 -3
- package/dist/types/v1-face-detection-create-response422.js +3 -3
- package/dist/types/v1-face-detection-get-response-faces-item.js +3 -3
- package/dist/types/v1-face-detection-get-response.js +3 -3
- package/dist/types/v1-face-detection-get-response400.js +3 -3
- package/dist/types/v1-face-detection-get-response401.js +3 -3
- package/dist/types/v1-face-detection-get-response404.js +3 -3
- package/dist/types/v1-face-detection-get-response422.js +3 -3
- package/dist/types/v1-face-swap-create-body-assets-face-mappings-item.js +3 -3
- package/dist/types/v1-face-swap-create-body-assets.js +3 -3
- package/dist/types/v1-face-swap-create-body-style.js +3 -3
- package/dist/types/v1-face-swap-create-body.js +3 -3
- package/dist/types/v1-face-swap-create-response.js +3 -3
- package/dist/types/v1-face-swap-create-response400.js +3 -3
- package/dist/types/v1-face-swap-create-response401.js +3 -3
- package/dist/types/v1-face-swap-create-response404.js +3 -3
- package/dist/types/v1-face-swap-create-response422.js +3 -3
- package/dist/types/v1-face-swap-photo-create-body-assets-face-mappings-item.js +3 -3
- package/dist/types/v1-face-swap-photo-create-body-assets.js +3 -3
- package/dist/types/v1-face-swap-photo-create-body.js +3 -3
- package/dist/types/v1-face-swap-photo-create-response.js +3 -3
- package/dist/types/v1-face-swap-photo-create-response400.js +3 -3
- package/dist/types/v1-face-swap-photo-create-response401.js +3 -3
- package/dist/types/v1-face-swap-photo-create-response404.js +3 -3
- package/dist/types/v1-face-swap-photo-create-response422.js +3 -3
- package/dist/types/v1-files-upload-urls-create-body-items-item.js +3 -3
- package/dist/types/v1-files-upload-urls-create-body.js +3 -3
- package/dist/types/v1-files-upload-urls-create-response-items-item.js +3 -3
- package/dist/types/v1-files-upload-urls-create-response.js +3 -3
- package/dist/types/v1-files-upload-urls-create-response400.js +3 -3
- package/dist/types/v1-files-upload-urls-create-response401.js +3 -3
- package/dist/types/v1-files-upload-urls-create-response404.js +3 -3
- package/dist/types/v1-files-upload-urls-create-response422.js +3 -3
- package/dist/types/v1-image-background-remover-create-body-assets.js +3 -3
- package/dist/types/v1-image-background-remover-create-body.js +3 -3
- package/dist/types/v1-image-background-remover-create-response.js +3 -3
- package/dist/types/v1-image-background-remover-create-response400.js +3 -3
- package/dist/types/v1-image-background-remover-create-response401.js +3 -3
- package/dist/types/v1-image-background-remover-create-response404.js +3 -3
- package/dist/types/v1-image-background-remover-create-response422.js +3 -3
- package/dist/types/v1-image-projects-delete-response400.js +3 -3
- package/dist/types/v1-image-projects-delete-response401.js +3 -3
- package/dist/types/v1-image-projects-delete-response404.js +3 -3
- package/dist/types/v1-image-projects-get-response-downloads-item.js +3 -3
- package/dist/types/v1-image-projects-get-response-error.js +3 -3
- package/dist/types/v1-image-projects-get-response.js +3 -3
- package/dist/types/v1-image-projects-get-response400.js +3 -3
- package/dist/types/v1-image-projects-get-response401.js +3 -3
- package/dist/types/v1-image-projects-get-response404.js +3 -3
- package/dist/types/v1-image-to-video-create-body-assets.js +3 -3
- package/dist/types/v1-image-to-video-create-body-style.js +3 -3
- package/dist/types/v1-image-to-video-create-body.js +3 -3
- package/dist/types/v1-image-to-video-create-response.js +3 -3
- package/dist/types/v1-image-to-video-create-response400.js +3 -3
- package/dist/types/v1-image-to-video-create-response401.js +3 -3
- package/dist/types/v1-image-to-video-create-response404.js +3 -3
- package/dist/types/v1-image-to-video-create-response422.js +3 -3
- package/dist/types/v1-lip-sync-create-body-assets.js +3 -3
- package/dist/types/v1-lip-sync-create-body.js +3 -3
- package/dist/types/v1-lip-sync-create-response.js +3 -3
- package/dist/types/v1-lip-sync-create-response400.js +3 -3
- package/dist/types/v1-lip-sync-create-response401.js +3 -3
- package/dist/types/v1-lip-sync-create-response404.js +3 -3
- package/dist/types/v1-lip-sync-create-response422.js +3 -3
- package/dist/types/v1-photo-colorizer-create-body-assets.js +3 -3
- package/dist/types/v1-photo-colorizer-create-body.js +3 -3
- package/dist/types/v1-photo-colorizer-create-response.js +3 -3
- package/dist/types/v1-photo-colorizer-create-response400.js +3 -3
- package/dist/types/v1-photo-colorizer-create-response401.js +3 -3
- package/dist/types/v1-photo-colorizer-create-response404.js +3 -3
- package/dist/types/v1-photo-colorizer-create-response422.js +3 -3
- package/dist/types/v1-text-to-video-create-body-style.js +3 -3
- package/dist/types/v1-text-to-video-create-body.js +3 -3
- package/dist/types/v1-text-to-video-create-response.js +3 -3
- package/dist/types/v1-text-to-video-create-response400.js +3 -3
- package/dist/types/v1-text-to-video-create-response401.js +3 -3
- package/dist/types/v1-text-to-video-create-response404.js +3 -3
- package/dist/types/v1-text-to-video-create-response422.js +3 -3
- package/dist/types/v1-video-projects-delete-response400.js +3 -3
- package/dist/types/v1-video-projects-delete-response401.js +3 -3
- package/dist/types/v1-video-projects-delete-response404.js +3 -3
- package/dist/types/v1-video-projects-delete-response422.js +3 -3
- package/dist/types/v1-video-projects-get-response-download.js +3 -3
- package/dist/types/v1-video-projects-get-response-downloads-item.js +3 -3
- package/dist/types/v1-video-projects-get-response-error.js +3 -3
- package/dist/types/v1-video-projects-get-response.js +3 -3
- package/dist/types/v1-video-projects-get-response400.js +3 -3
- package/dist/types/v1-video-projects-get-response401.js +3 -3
- package/dist/types/v1-video-projects-get-response404.js +3 -3
- package/dist/types/v1-video-to-video-create-body-assets.js +3 -3
- package/dist/types/v1-video-to-video-create-body-style.js +3 -3
- package/dist/types/v1-video-to-video-create-body.js +3 -3
- package/dist/types/v1-video-to-video-create-response.js +3 -3
- package/dist/types/v1-video-to-video-create-response400.js +3 -3
- package/dist/types/v1-video-to-video-create-response401.js +3 -3
- package/dist/types/v1-video-to-video-create-response404.js +3 -3
- package/dist/types/v1-video-to-video-create-response422.js +3 -3
- package/package.json +16 -21
- package/dist/core/api-error.d.ts +0 -6
- package/dist/core/api-error.js +0 -11
- package/dist/core/api-promise.d.ts +0 -28
- package/dist/core/api-promise.js +0 -252
- package/dist/core/auth.d.ts +0 -76
- package/dist/core/auth.js +0 -232
- package/dist/core/binary-response.d.ts +0 -6
- package/dist/core/binary-response.js +0 -10
- package/dist/core/content-type.d.ts +0 -4
- package/dist/core/content-type.js +0 -12
- package/dist/core/core-client.d.ts +0 -58
- package/dist/core/core-client.js +0 -168
- package/dist/core/form-data.d.ts +0 -26
- package/dist/core/form-data.js +0 -83
- package/dist/core/index.d.ts +0 -9
- package/dist/core/index.js +0 -28
- package/dist/core/query.d.ts +0 -8
- package/dist/core/query.js +0 -77
- package/dist/core/runtime.d.ts +0 -4
- package/dist/core/runtime.js +0 -20
- package/dist/core/zod.d.ts +0 -13
- package/dist/core/zod.js +0 -60
|
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.Schemas$V1VideoToVideoCreateResponse404 = void 0;
|
|
37
|
-
const
|
|
37
|
+
const make_api_request_js_1 = require("make-api-request-js");
|
|
38
38
|
const z = __importStar(require("zod"));
|
|
39
39
|
/**
|
|
40
40
|
* Takes network data, validates it, and transforms keys to match typescript object V1VideoToVideoCreateResponse404
|
|
@@ -44,7 +44,7 @@ const SchemaIn$V1VideoToVideoCreateResponse404 = z
|
|
|
44
44
|
message: z.enum(["Not Found"]),
|
|
45
45
|
})
|
|
46
46
|
.transform((obj) => {
|
|
47
|
-
return (0,
|
|
47
|
+
return (0, make_api_request_js_1.zodTransform)(obj, {
|
|
48
48
|
message: "message",
|
|
49
49
|
});
|
|
50
50
|
});
|
|
@@ -57,7 +57,7 @@ const SchemaOut$V1VideoToVideoCreateResponse404 = z
|
|
|
57
57
|
message: z.enum(["Not Found"]),
|
|
58
58
|
})
|
|
59
59
|
.transform((obj) => {
|
|
60
|
-
return (0,
|
|
60
|
+
return (0, make_api_request_js_1.zodTransform)(obj, {
|
|
61
61
|
message: "message",
|
|
62
62
|
});
|
|
63
63
|
});
|
|
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.Schemas$V1VideoToVideoCreateResponse422 = void 0;
|
|
37
|
-
const
|
|
37
|
+
const make_api_request_js_1 = require("make-api-request-js");
|
|
38
38
|
const z = __importStar(require("zod"));
|
|
39
39
|
/**
|
|
40
40
|
* Takes network data, validates it, and transforms keys to match typescript object V1VideoToVideoCreateResponse422
|
|
@@ -44,7 +44,7 @@ const SchemaIn$V1VideoToVideoCreateResponse422 = z
|
|
|
44
44
|
message: z.string(),
|
|
45
45
|
})
|
|
46
46
|
.transform((obj) => {
|
|
47
|
-
return (0,
|
|
47
|
+
return (0, make_api_request_js_1.zodTransform)(obj, {
|
|
48
48
|
message: "message",
|
|
49
49
|
});
|
|
50
50
|
});
|
|
@@ -57,7 +57,7 @@ const SchemaOut$V1VideoToVideoCreateResponse422 = z
|
|
|
57
57
|
message: z.string(),
|
|
58
58
|
})
|
|
59
59
|
.transform((obj) => {
|
|
60
|
-
return (0,
|
|
60
|
+
return (0, make_api_request_js_1.zodTransform)(obj, {
|
|
61
61
|
message: "message",
|
|
62
62
|
});
|
|
63
63
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magic-hour",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -19,46 +19,41 @@
|
|
|
19
19
|
"package.json"
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
|
-
"format": "prettier --write 'src/**/*.ts'",
|
|
23
22
|
"build": "tsc && tsc-alias",
|
|
24
|
-
"
|
|
25
|
-
"prepare": "npm run build"
|
|
23
|
+
"format": "prettier --write 'src/**/*.ts'",
|
|
24
|
+
"prepare": "npm run build",
|
|
25
|
+
"test": "jest -i --testPathPattern=test"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"js-base64": "^3.7.7",
|
|
31
|
-
"jsonpointer": "^5.0.1",
|
|
32
|
-
"node-fetch": "^2.7.0",
|
|
33
|
-
"qs": "^6.12.1",
|
|
34
|
-
"zod": "^3.23.8"
|
|
28
|
+
"make-api-request-js": "^0.2.1",
|
|
29
|
+
"node-fetch": "^2.7.0"
|
|
35
30
|
},
|
|
36
31
|
"devDependencies": {
|
|
32
|
+
"@biomejs/biome": "2.2.0",
|
|
33
|
+
"@types/glob": "^8.1.0",
|
|
37
34
|
"@types/jest": "^29.5.14",
|
|
38
35
|
"@types/node": "17.0.33",
|
|
39
36
|
"@types/node-fetch": "2.6.9",
|
|
40
|
-
"@types/qs": "6.9.8",
|
|
41
|
-
"@types/url-join": "4.0.1",
|
|
42
37
|
"jest": "^29.7.0",
|
|
43
|
-
"
|
|
38
|
+
"msw": "^2.10.5",
|
|
44
39
|
"ts-jest": "^29.2.5",
|
|
40
|
+
"ts-morph": "^26.0.0",
|
|
45
41
|
"ts-node": "^10.9.2",
|
|
46
42
|
"tsc-alias": "^1.8.10",
|
|
47
|
-
"typescript": "^5.2.0"
|
|
48
|
-
"@biomejs/biome": "2.2.0"
|
|
43
|
+
"typescript": "^5.2.0"
|
|
49
44
|
},
|
|
45
|
+
"bugs": "https://github.com/magichourhq/magic-hour-node/issues",
|
|
50
46
|
"description": "Node SDK for Magic Hour API",
|
|
47
|
+
"homepage": "https://github.com/magichourhq/magic-hour-node",
|
|
51
48
|
"keywords": [
|
|
52
49
|
"magic hour",
|
|
53
50
|
"AI video",
|
|
54
51
|
"AI image",
|
|
55
52
|
"api"
|
|
56
53
|
],
|
|
57
|
-
"
|
|
54
|
+
"license": "MIT",
|
|
58
55
|
"repository": {
|
|
59
56
|
"type": "git",
|
|
60
57
|
"url": "git://github.com/magichourhq/magic-hour-node.git"
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
"license": "MIT"
|
|
64
|
-
}
|
|
58
|
+
}
|
|
59
|
+
}
|
package/dist/core/api-error.d.ts
DELETED
package/dist/core/api-error.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApiError = void 0;
|
|
4
|
-
class ApiError extends Error {
|
|
5
|
-
constructor(request, response) {
|
|
6
|
-
super(`${response.status} was returned from ${request.method} ${request.path}`);
|
|
7
|
-
this.request = request;
|
|
8
|
-
this.response = response;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.ApiError = ApiError;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type * as z from "zod";
|
|
2
|
-
import type { ApiResponse } from "./core-client";
|
|
3
|
-
export interface ApiPromiseProps {
|
|
4
|
-
responsePromise: Promise<ApiResponse>;
|
|
5
|
-
responseStream: boolean;
|
|
6
|
-
responseRaw: boolean;
|
|
7
|
-
responseSchema?: z.Schema | undefined;
|
|
8
|
-
}
|
|
9
|
-
export type EventSourceResponse<T> = AsyncIterableIterator<T>;
|
|
10
|
-
export declare class ApiPromise<T> extends Promise<T> implements AsyncIterator<T>, AsyncIterable<T> {
|
|
11
|
-
private responseProps;
|
|
12
|
-
constructor(responseProps: ApiPromiseProps);
|
|
13
|
-
/**
|
|
14
|
-
* Gets the raw response as returned by `fetch` rather than automatically
|
|
15
|
-
* parsing the response.
|
|
16
|
-
*/
|
|
17
|
-
asResponse(): Promise<ApiResponse>;
|
|
18
|
-
private getResponseType;
|
|
19
|
-
private parseResponse;
|
|
20
|
-
private handleNodeStream;
|
|
21
|
-
private handleWebStream;
|
|
22
|
-
asEventStream(): AsyncIterableIterator<T>;
|
|
23
|
-
next(): Promise<IteratorResult<T>>;
|
|
24
|
-
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
25
|
-
then<Result1 = T, Result2 = never>(onfulfilled?: ((value: T) => Result1 | PromiseLike<Result1>) | undefined | null, onrejected?: ((reason: any) => Result2 | PromiseLike<Result2>) | undefined | null): Promise<Result1 | Result2>;
|
|
26
|
-
catch<Result = never>(onrejected?: ((reason: any) => Result | PromiseLike<Result>) | undefined | null): Promise<T | Result>;
|
|
27
|
-
finally(onfinally?: (() => void) | undefined | null): Promise<T>;
|
|
28
|
-
}
|
package/dist/core/api-promise.js
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
-
var m = o[Symbol.asyncIterator], i;
|
|
14
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
-
};
|
|
18
|
-
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
19
|
-
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
20
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
21
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
22
|
-
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
23
|
-
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
24
|
-
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
25
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
26
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
27
|
-
function fulfill(value) { resume("next", value); }
|
|
28
|
-
function reject(value) { resume("throw", value); }
|
|
29
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
30
|
-
};
|
|
31
|
-
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
|
32
|
-
var i, p;
|
|
33
|
-
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
34
|
-
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
|
|
35
|
-
};
|
|
36
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.ApiPromise = void 0;
|
|
38
|
-
const binary_response_1 = require("./binary-response");
|
|
39
|
-
const content_type_1 = require("./content-type");
|
|
40
|
-
class ApiPromise extends Promise {
|
|
41
|
-
constructor(responseProps) {
|
|
42
|
-
super((resolve) => {
|
|
43
|
-
resolve(null);
|
|
44
|
-
});
|
|
45
|
-
this.responseProps = responseProps;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Gets the raw response as returned by `fetch` rather than automatically
|
|
49
|
-
* parsing the response.
|
|
50
|
-
*/
|
|
51
|
-
asResponse() {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
return yield this.responseProps.responsePromise;
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
getResponseType(contentType) {
|
|
57
|
-
if (content_type_1.JSON_PATTERN.test(contentType)) {
|
|
58
|
-
return "json";
|
|
59
|
-
}
|
|
60
|
-
else if (content_type_1.TEXT_PATTERN.test(contentType)) {
|
|
61
|
-
return "text";
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
return "binary";
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
parseResponse() {
|
|
68
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
var _a;
|
|
70
|
-
const { responsePromise, responseSchema, responseRaw } = this.responseProps;
|
|
71
|
-
const response = yield responsePromise;
|
|
72
|
-
if (response.status === 204) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
else if (responseRaw) {
|
|
76
|
-
return response;
|
|
77
|
-
}
|
|
78
|
-
const contentType = (_a = response.headers.get("content-type")) !== null && _a !== void 0 ? _a : "";
|
|
79
|
-
switch (this.getResponseType(contentType)) {
|
|
80
|
-
case "json": {
|
|
81
|
-
const rawJson = yield response.json();
|
|
82
|
-
return responseSchema ? responseSchema.parse(rawJson) : rawJson;
|
|
83
|
-
}
|
|
84
|
-
case "text":
|
|
85
|
-
return (yield response.text());
|
|
86
|
-
case "binary":
|
|
87
|
-
default:
|
|
88
|
-
return new binary_response_1.BinaryResponse(yield response.blob(), contentType);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
handleNodeStream(stream) {
|
|
93
|
-
return __asyncGenerator(this, arguments, function* handleNodeStream_1() {
|
|
94
|
-
var _a, e_1, _b, _c;
|
|
95
|
-
const { responseSchema } = this.responseProps;
|
|
96
|
-
const parser = new EventSourceParser();
|
|
97
|
-
try {
|
|
98
|
-
for (var _d = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield __await(stream_1.next()), _a = stream_1_1.done, !_a; _d = true) {
|
|
99
|
-
_c = stream_1_1.value;
|
|
100
|
-
_d = false;
|
|
101
|
-
const chunk = _c;
|
|
102
|
-
const text = chunk.toString();
|
|
103
|
-
const messages = parser.parse(text);
|
|
104
|
-
for (const message of messages) {
|
|
105
|
-
if (message.data) {
|
|
106
|
-
const rawJson = { data: JSON.parse(message.data) };
|
|
107
|
-
yield yield __await(responseSchema ? responseSchema.parse(rawJson) : rawJson);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
113
|
-
finally {
|
|
114
|
-
try {
|
|
115
|
-
if (!_d && !_a && (_b = stream_1.return)) yield __await(_b.call(stream_1));
|
|
116
|
-
}
|
|
117
|
-
finally { if (e_1) throw e_1.error; }
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
handleWebStream(stream) {
|
|
122
|
-
return __asyncGenerator(this, arguments, function* handleWebStream_1() {
|
|
123
|
-
const { responseSchema } = this.responseProps;
|
|
124
|
-
const reader = stream.getReader();
|
|
125
|
-
const decoder = new TextDecoder();
|
|
126
|
-
const parser = new EventSourceParser();
|
|
127
|
-
try {
|
|
128
|
-
while (true) {
|
|
129
|
-
const { done, value } = yield __await(reader.read());
|
|
130
|
-
if (done) {
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
const chunk = decoder.decode(value, { stream: true });
|
|
134
|
-
const messages = parser.parse(chunk);
|
|
135
|
-
for (const message of messages) {
|
|
136
|
-
if (message.data) {
|
|
137
|
-
const rawJson = { data: JSON.parse(message.data) };
|
|
138
|
-
yield yield __await(responseSchema ? responseSchema.parse(rawJson) : rawJson);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
finally {
|
|
144
|
-
reader.releaseLock();
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
asEventStream() {
|
|
149
|
-
return __asyncGenerator(this, arguments, function* asEventStream_1() {
|
|
150
|
-
const { responsePromise, responseStream } = this.responseProps;
|
|
151
|
-
if (!responseStream) {
|
|
152
|
-
throw new Error("Response is not an event stream");
|
|
153
|
-
}
|
|
154
|
-
const response = yield __await(responsePromise);
|
|
155
|
-
if (!response.body) {
|
|
156
|
-
throw new Error("Response body is undefined");
|
|
157
|
-
}
|
|
158
|
-
// Check if we're in Node.js environment
|
|
159
|
-
if ("pipe" in response.body && typeof response.body.pipe === "function") {
|
|
160
|
-
yield __await(yield* __asyncDelegator(__asyncValues(this.handleNodeStream(response.body))));
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
yield __await(yield* __asyncDelegator(__asyncValues(this.handleWebStream(response.body))));
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
next() {
|
|
168
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
169
|
-
const { responseStream } = this.responseProps;
|
|
170
|
-
if (responseStream) {
|
|
171
|
-
const iterator = this.asEventStream();
|
|
172
|
-
const result = yield iterator.next();
|
|
173
|
-
return result;
|
|
174
|
-
}
|
|
175
|
-
const value = yield this.parseResponse();
|
|
176
|
-
return { value, done: true };
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
[Symbol.asyncIterator]() {
|
|
180
|
-
const iterator = {
|
|
181
|
-
next: () => __awaiter(this, void 0, void 0, function* () {
|
|
182
|
-
const { responseStream } = this.responseProps;
|
|
183
|
-
if (responseStream) {
|
|
184
|
-
const stream = this.asEventStream();
|
|
185
|
-
return stream.next();
|
|
186
|
-
}
|
|
187
|
-
const value = yield this.parseResponse();
|
|
188
|
-
return { value, done: true };
|
|
189
|
-
}),
|
|
190
|
-
};
|
|
191
|
-
return iterator;
|
|
192
|
-
}
|
|
193
|
-
then(onfulfilled, onrejected) {
|
|
194
|
-
if (this.responseProps.responseStream) {
|
|
195
|
-
return Promise.resolve(this.asEventStream());
|
|
196
|
-
}
|
|
197
|
-
return this.parseResponse().then(onfulfilled, onrejected);
|
|
198
|
-
}
|
|
199
|
-
catch(onrejected) {
|
|
200
|
-
return this.parseResponse().catch(onrejected);
|
|
201
|
-
}
|
|
202
|
-
finally(onfinally) {
|
|
203
|
-
return this.parseResponse().finally(onfinally);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
exports.ApiPromise = ApiPromise;
|
|
207
|
-
class EventSourceParser {
|
|
208
|
-
constructor() {
|
|
209
|
-
this.buffer = "";
|
|
210
|
-
}
|
|
211
|
-
parse(chunk) {
|
|
212
|
-
this.buffer += chunk;
|
|
213
|
-
const messages = [];
|
|
214
|
-
const lines = this.buffer.split("\n");
|
|
215
|
-
// Keep the last line in buffer if it's not complete
|
|
216
|
-
this.buffer = lines.pop() || "";
|
|
217
|
-
let currentMessage = {};
|
|
218
|
-
for (const line of lines) {
|
|
219
|
-
if (line.trim() === "") {
|
|
220
|
-
if (currentMessage.data) {
|
|
221
|
-
const message = {
|
|
222
|
-
event: currentMessage.event,
|
|
223
|
-
data: currentMessage.data,
|
|
224
|
-
id: currentMessage.id,
|
|
225
|
-
};
|
|
226
|
-
messages.push(message);
|
|
227
|
-
}
|
|
228
|
-
currentMessage = {};
|
|
229
|
-
continue;
|
|
230
|
-
}
|
|
231
|
-
const [fieldName, ...fieldValue] = line.split(":");
|
|
232
|
-
const value = fieldValue.join(":").trim();
|
|
233
|
-
switch (fieldName) {
|
|
234
|
-
case "event":
|
|
235
|
-
currentMessage.event = value;
|
|
236
|
-
break;
|
|
237
|
-
case "data":
|
|
238
|
-
currentMessage.data = currentMessage.data
|
|
239
|
-
? currentMessage.data + "\n" + value
|
|
240
|
-
: value;
|
|
241
|
-
break;
|
|
242
|
-
case "id":
|
|
243
|
-
currentMessage.id = value;
|
|
244
|
-
break;
|
|
245
|
-
case "retry":
|
|
246
|
-
// Handle retry if needed
|
|
247
|
-
break;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
return messages;
|
|
251
|
-
}
|
|
252
|
-
}
|
package/dist/core/auth.d.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { RequestConfig } from "./core-client";
|
|
2
|
-
export interface AuthProvider {
|
|
3
|
-
applyAuth: (cfg: RequestConfig) => Promise<RequestConfig>;
|
|
4
|
-
setValue: (val?: string | undefined) => void;
|
|
5
|
-
}
|
|
6
|
-
export declare class AuthBasic implements AuthProvider {
|
|
7
|
-
username: string | null;
|
|
8
|
-
password: string | null;
|
|
9
|
-
constructor(username?: string, password?: string);
|
|
10
|
-
applyAuth(cfg: RequestConfig): Promise<RequestConfig>;
|
|
11
|
-
setValue(val?: string | undefined): void;
|
|
12
|
-
}
|
|
13
|
-
export declare class AuthBearer implements AuthProvider {
|
|
14
|
-
token: string | null;
|
|
15
|
-
constructor(token?: string);
|
|
16
|
-
applyAuth(cfg: RequestConfig): Promise<RequestConfig>;
|
|
17
|
-
setValue(val?: string | undefined): void;
|
|
18
|
-
}
|
|
19
|
-
export declare class AuthKey implements AuthProvider {
|
|
20
|
-
name: string;
|
|
21
|
-
location: "query" | "header" | "cookie";
|
|
22
|
-
key: string | null;
|
|
23
|
-
constructor(name: string, location: "query" | "header" | "cookie", key?: string);
|
|
24
|
-
applyAuth(cfg: RequestConfig): Promise<RequestConfig>;
|
|
25
|
-
setValue(val?: string | undefined): void;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* OAuth2 authentication props for a password flow
|
|
29
|
-
*
|
|
30
|
-
* Details:
|
|
31
|
-
* https://datatracker.ietf.org/doc/html/rfc6749#section-4.3
|
|
32
|
-
*/
|
|
33
|
-
export type OAuth2Password = {
|
|
34
|
-
username: string;
|
|
35
|
-
password: string;
|
|
36
|
-
clientId?: string | undefined;
|
|
37
|
-
clientSecret?: string | undefined;
|
|
38
|
-
grantType?: "password" | string | undefined;
|
|
39
|
-
scope?: string[] | undefined;
|
|
40
|
-
tokenUrl?: string | undefined;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* OAuth2 authentication props for a client credentials flow
|
|
44
|
-
*
|
|
45
|
-
* Details:
|
|
46
|
-
* https://datatracker.ietf.org/doc/html/rfc6749#section-4.4
|
|
47
|
-
*/
|
|
48
|
-
export type OAuth2ClientCredentials = {
|
|
49
|
-
clientId: string;
|
|
50
|
-
clientSecret: string;
|
|
51
|
-
grantType?: "client_credentials" | string | undefined;
|
|
52
|
-
scope?: string[] | undefined;
|
|
53
|
-
tokenUrl?: string | undefined;
|
|
54
|
-
};
|
|
55
|
-
export type OAuth2ProviderProps = {
|
|
56
|
-
baseUrl: string;
|
|
57
|
-
defaultTokenUrl: string;
|
|
58
|
-
accessTokenPointer: string;
|
|
59
|
-
expiresInPointer: string;
|
|
60
|
-
credentialsLocation: "request_body" | "basic_authorization_header";
|
|
61
|
-
bodyContent: "form" | "json";
|
|
62
|
-
requestMutator: AuthProvider;
|
|
63
|
-
form?: OAuth2Password | OAuth2ClientCredentials | undefined;
|
|
64
|
-
};
|
|
65
|
-
export declare class OAuth2 implements AuthProvider {
|
|
66
|
-
props: OAuth2ProviderProps;
|
|
67
|
-
accessToken?: string | undefined;
|
|
68
|
-
expiresAt?: Date;
|
|
69
|
-
constructor(props: OAuth2ProviderProps);
|
|
70
|
-
refresh(form: OAuth2Password | OAuth2ClientCredentials): Promise<{
|
|
71
|
-
accessToken: string;
|
|
72
|
-
expiresAt: Date;
|
|
73
|
-
}>;
|
|
74
|
-
applyAuth(cfg: RequestConfig): Promise<RequestConfig>;
|
|
75
|
-
setValue(val?: string | undefined): void;
|
|
76
|
-
}
|