transloadit 4.13.1 → 5.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/README.md +58 -6
- package/dist/ApiError.d.ts +6 -2
- package/dist/ApiError.d.ts.map +1 -1
- package/dist/ApiError.js +6 -2
- package/dist/ApiError.js.map +1 -1
- package/dist/Transloadit.d.ts +2 -0
- package/dist/Transloadit.d.ts.map +1 -1
- package/dist/Transloadit.js +15 -4
- package/dist/Transloadit.js.map +1 -1
- package/dist/alphalib/aiMessages.d.ts +33254 -0
- package/dist/alphalib/aiMessages.d.ts.map +1 -0
- package/dist/alphalib/aiMessages.js +479 -0
- package/dist/alphalib/aiMessages.js.map +1 -0
- package/dist/alphalib/assembly-linter.d.ts.map +1 -1
- package/dist/alphalib/assembly-linter.js +20 -15
- package/dist/alphalib/assembly-linter.js.map +1 -1
- package/dist/alphalib/englishList.d.ts +3 -0
- package/dist/alphalib/englishList.d.ts.map +1 -0
- package/dist/alphalib/englishList.js +12 -0
- package/dist/alphalib/englishList.js.map +1 -0
- package/dist/alphalib/errors.d.ts +16 -0
- package/dist/alphalib/errors.d.ts.map +1 -1
- package/dist/alphalib/errors.js +124 -13
- package/dist/alphalib/errors.js.map +1 -1
- package/dist/alphalib/imagemagickDensity.d.ts.map +1 -1
- package/dist/alphalib/imagemagickDensity.js +2 -2
- package/dist/alphalib/imagemagickDensity.js.map +1 -1
- package/dist/alphalib/lib/zodInputSemantics.d.ts +18 -0
- package/dist/alphalib/lib/zodInputSemantics.d.ts.map +1 -0
- package/dist/alphalib/lib/zodInputSemantics.js +86 -0
- package/dist/alphalib/lib/zodInputSemantics.js.map +1 -0
- package/dist/alphalib/object.d.ts +42 -2
- package/dist/alphalib/object.d.ts.map +1 -1
- package/dist/alphalib/object.js +133 -0
- package/dist/alphalib/object.js.map +1 -1
- package/dist/alphalib/stepParsing.d.ts +1 -0
- package/dist/alphalib/stepParsing.d.ts.map +1 -1
- package/dist/alphalib/stepParsing.js +9 -1
- package/dist/alphalib/stepParsing.js.map +1 -1
- package/dist/alphalib/types/apiParameterDescription.d.ts +14 -0
- package/dist/alphalib/types/apiParameterDescription.d.ts.map +1 -0
- package/dist/alphalib/types/apiParameterDescription.js +20 -0
- package/dist/alphalib/types/apiParameterDescription.js.map +1 -0
- package/dist/alphalib/types/assembliesGet.d.ts +1 -1
- package/dist/alphalib/types/assemblyReplay.d.ts +4 -4
- package/dist/alphalib/types/assemblyStatus.d.ts +7196 -64686
- package/dist/alphalib/types/assemblyStatus.d.ts.map +1 -1
- package/dist/alphalib/types/assemblyStatus.js +74 -55
- package/dist/alphalib/types/assemblyStatus.js.map +1 -1
- package/dist/alphalib/types/errorReason.d.ts +7 -0
- package/dist/alphalib/types/errorReason.d.ts.map +1 -0
- package/dist/alphalib/types/errorReason.js +14 -0
- package/dist/alphalib/types/errorReason.js.map +1 -0
- package/dist/alphalib/types/file.d.ts +7 -0
- package/dist/alphalib/types/file.d.ts.map +1 -1
- package/dist/alphalib/types/file.js +15 -0
- package/dist/alphalib/types/file.js.map +1 -1
- package/dist/alphalib/types/fileHash.d.ts +16 -0
- package/dist/alphalib/types/fileHash.d.ts.map +1 -0
- package/dist/alphalib/types/fileHash.js +10 -0
- package/dist/alphalib/types/fileHash.js.map +1 -0
- package/dist/alphalib/types/responseErrors/HttpImportRobot.d.ts +23 -0
- package/dist/alphalib/types/responseErrors/HttpImportRobot.d.ts.map +1 -0
- package/dist/alphalib/types/responseErrors/HttpImportRobot.js +23 -0
- package/dist/alphalib/types/responseErrors/HttpImportRobot.js.map +1 -0
- package/dist/alphalib/types/robots/_ai-models.d.ts +28 -0
- package/dist/alphalib/types/robots/_ai-models.d.ts.map +1 -0
- package/dist/alphalib/types/robots/_ai-models.js +80 -0
- package/dist/alphalib/types/robots/_ai-models.js.map +1 -0
- package/dist/alphalib/types/robots/_index.d.ts +713 -1329
- package/dist/alphalib/types/robots/_index.d.ts.map +1 -1
- package/dist/alphalib/types/robots/_index.js +4 -0
- package/dist/alphalib/types/robots/_index.js.map +1 -1
- package/dist/alphalib/types/robots/_instructions-primitives.d.ts +504 -129
- package/dist/alphalib/types/robots/_instructions-primitives.d.ts.map +1 -1
- package/dist/alphalib/types/robots/_instructions-primitives.js +629 -280
- package/dist/alphalib/types/robots/_instructions-primitives.js.map +1 -1
- package/dist/alphalib/types/robots/ai-chat.d.ts +952 -2189
- package/dist/alphalib/types/robots/ai-chat.d.ts.map +1 -1
- package/dist/alphalib/types/robots/ai-chat.js +235 -367
- package/dist/alphalib/types/robots/ai-chat.js.map +1 -1
- package/dist/alphalib/types/robots/assembly-savejson.d.ts +28 -16
- package/dist/alphalib/types/robots/assembly-savejson.d.ts.map +1 -1
- package/dist/alphalib/types/robots/assembly-savejson.js +2 -11
- package/dist/alphalib/types/robots/assembly-savejson.js.map +1 -1
- package/dist/alphalib/types/robots/audio-artwork.d.ts +80 -67
- package/dist/alphalib/types/robots/audio-artwork.d.ts.map +1 -1
- package/dist/alphalib/types/robots/audio-artwork.js +9 -38
- package/dist/alphalib/types/robots/audio-artwork.js.map +1 -1
- package/dist/alphalib/types/robots/audio-concat.d.ts +94 -81
- package/dist/alphalib/types/robots/audio-concat.d.ts.map +1 -1
- package/dist/alphalib/types/robots/audio-concat.js +11 -25
- package/dist/alphalib/types/robots/audio-concat.js.map +1 -1
- package/dist/alphalib/types/robots/audio-encode.d.ts +80 -67
- package/dist/alphalib/types/robots/audio-encode.d.ts.map +1 -1
- package/dist/alphalib/types/robots/audio-encode.js +13 -43
- package/dist/alphalib/types/robots/audio-encode.js.map +1 -1
- package/dist/alphalib/types/robots/audio-loop.d.ts +80 -67
- package/dist/alphalib/types/robots/audio-loop.d.ts.map +1 -1
- package/dist/alphalib/types/robots/audio-loop.js +12 -40
- package/dist/alphalib/types/robots/audio-loop.js.map +1 -1
- package/dist/alphalib/types/robots/audio-merge.d.ts +94 -81
- package/dist/alphalib/types/robots/audio-merge.d.ts.map +1 -1
- package/dist/alphalib/types/robots/audio-merge.js +11 -25
- package/dist/alphalib/types/robots/audio-merge.js.map +1 -1
- package/dist/alphalib/types/robots/audio-split.d.ts +80 -67
- package/dist/alphalib/types/robots/audio-split.d.ts.map +1 -1
- package/dist/alphalib/types/robots/audio-split.js +15 -45
- package/dist/alphalib/types/robots/audio-split.js.map +1 -1
- package/dist/alphalib/types/robots/audio-waveform.d.ts +120 -107
- package/dist/alphalib/types/robots/audio-waveform.d.ts.map +1 -1
- package/dist/alphalib/types/robots/audio-waveform.js +15 -39
- package/dist/alphalib/types/robots/audio-waveform.js.map +1 -1
- package/dist/alphalib/types/robots/azure-import.d.ts +48 -35
- package/dist/alphalib/types/robots/azure-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/azure-import.js +5 -35
- package/dist/alphalib/types/robots/azure-import.js.map +1 -1
- package/dist/alphalib/types/robots/azure-store.d.ts +87 -71
- package/dist/alphalib/types/robots/azure-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/azure-store.js +11 -50
- package/dist/alphalib/types/robots/azure-store.js.map +1 -1
- package/dist/alphalib/types/robots/backblaze-import.d.ts +48 -35
- package/dist/alphalib/types/robots/backblaze-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/backblaze-import.js +6 -39
- package/dist/alphalib/types/robots/backblaze-import.js.map +1 -1
- package/dist/alphalib/types/robots/backblaze-store.d.ts +80 -67
- package/dist/alphalib/types/robots/backblaze-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/backblaze-store.js +8 -44
- package/dist/alphalib/types/robots/backblaze-store.js.map +1 -1
- package/dist/alphalib/types/robots/box-import.d.ts +44 -27
- package/dist/alphalib/types/robots/box-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/box-import.js +7 -33
- package/dist/alphalib/types/robots/box-import.js.map +1 -1
- package/dist/alphalib/types/robots/box-store.d.ts +85 -68
- package/dist/alphalib/types/robots/box-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/box-store.js +8 -40
- package/dist/alphalib/types/robots/box-store.js.map +1 -1
- package/dist/alphalib/types/robots/cloudfiles-import.d.ts +48 -35
- package/dist/alphalib/types/robots/cloudfiles-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/cloudfiles-import.js +8 -45
- package/dist/alphalib/types/robots/cloudfiles-import.js.map +1 -1
- package/dist/alphalib/types/robots/cloudfiles-store.d.ts +80 -67
- package/dist/alphalib/types/robots/cloudfiles-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/cloudfiles-store.js +5 -36
- package/dist/alphalib/types/robots/cloudfiles-store.js.map +1 -1
- package/dist/alphalib/types/robots/cloudflare-import.d.ts +48 -35
- package/dist/alphalib/types/robots/cloudflare-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/cloudflare-import.js +10 -57
- package/dist/alphalib/types/robots/cloudflare-import.js.map +1 -1
- package/dist/alphalib/types/robots/cloudflare-store.d.ts +80 -67
- package/dist/alphalib/types/robots/cloudflare-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/cloudflare-store.js +11 -54
- package/dist/alphalib/types/robots/cloudflare-store.js.map +1 -1
- package/dist/alphalib/types/robots/digitalocean-import.d.ts +56 -43
- package/dist/alphalib/types/robots/digitalocean-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/digitalocean-import.js +8 -49
- package/dist/alphalib/types/robots/digitalocean-import.js.map +1 -1
- package/dist/alphalib/types/robots/digitalocean-store.d.ts +88 -75
- package/dist/alphalib/types/robots/digitalocean-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/digitalocean-store.js +8 -56
- package/dist/alphalib/types/robots/digitalocean-store.js.map +1 -1
- package/dist/alphalib/types/robots/document-autorotate.d.ts +80 -67
- package/dist/alphalib/types/robots/document-autorotate.d.ts.map +1 -1
- package/dist/alphalib/types/robots/document-autorotate.js +5 -32
- package/dist/alphalib/types/robots/document-autorotate.js.map +1 -1
- package/dist/alphalib/types/robots/document-convert.d.ts +84 -71
- package/dist/alphalib/types/robots/document-convert.d.ts.map +1 -1
- package/dist/alphalib/types/robots/document-convert.js +7 -33
- package/dist/alphalib/types/robots/document-convert.js.map +1 -1
- package/dist/alphalib/types/robots/document-extract.d.ts +80 -67
- package/dist/alphalib/types/robots/document-extract.d.ts.map +1 -1
- package/dist/alphalib/types/robots/document-extract.js +10 -36
- package/dist/alphalib/types/robots/document-extract.js.map +1 -1
- package/dist/alphalib/types/robots/document-merge.d.ts +80 -67
- package/dist/alphalib/types/robots/document-merge.d.ts.map +1 -1
- package/dist/alphalib/types/robots/document-merge.js +4 -25
- package/dist/alphalib/types/robots/document-merge.js.map +1 -1
- package/dist/alphalib/types/robots/document-ocr.d.ts +80 -67
- package/dist/alphalib/types/robots/document-ocr.d.ts.map +1 -1
- package/dist/alphalib/types/robots/document-ocr.js +10 -47
- package/dist/alphalib/types/robots/document-ocr.js.map +1 -1
- package/dist/alphalib/types/robots/document-optimize.d.ts +80 -67
- package/dist/alphalib/types/robots/document-optimize.d.ts.map +1 -1
- package/dist/alphalib/types/robots/document-optimize.js +7 -31
- package/dist/alphalib/types/robots/document-optimize.js.map +1 -1
- package/dist/alphalib/types/robots/document-split.d.ts +80 -67
- package/dist/alphalib/types/robots/document-split.d.ts.map +1 -1
- package/dist/alphalib/types/robots/document-split.js +7 -34
- package/dist/alphalib/types/robots/document-split.js.map +1 -1
- package/dist/alphalib/types/robots/document-thumbs.d.ts +120 -101
- package/dist/alphalib/types/robots/document-thumbs.d.ts.map +1 -1
- package/dist/alphalib/types/robots/document-thumbs.js +24 -31
- package/dist/alphalib/types/robots/document-thumbs.js.map +1 -1
- package/dist/alphalib/types/robots/dropbox-import.d.ts +40 -27
- package/dist/alphalib/types/robots/dropbox-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/dropbox-import.js +5 -35
- package/dist/alphalib/types/robots/dropbox-import.js.map +1 -1
- package/dist/alphalib/types/robots/dropbox-store.d.ts +84 -68
- package/dist/alphalib/types/robots/dropbox-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/dropbox-store.js +8 -42
- package/dist/alphalib/types/robots/dropbox-store.js.map +1 -1
- package/dist/alphalib/types/robots/edgly-deliver.d.ts +32 -19
- package/dist/alphalib/types/robots/edgly-deliver.d.ts.map +1 -1
- package/dist/alphalib/types/robots/edgly-deliver.js +4 -24
- package/dist/alphalib/types/robots/edgly-deliver.js.map +1 -1
- package/dist/alphalib/types/robots/file-compress.d.ts +80 -67
- package/dist/alphalib/types/robots/file-compress.d.ts.map +1 -1
- package/dist/alphalib/types/robots/file-compress.js +4 -20
- package/dist/alphalib/types/robots/file-compress.js.map +1 -1
- package/dist/alphalib/types/robots/file-decompress.d.ts +96 -83
- package/dist/alphalib/types/robots/file-decompress.d.ts.map +1 -1
- package/dist/alphalib/types/robots/file-decompress.js +10 -41
- package/dist/alphalib/types/robots/file-decompress.js.map +1 -1
- package/dist/alphalib/types/robots/file-filter.d.ts +99 -87
- package/dist/alphalib/types/robots/file-filter.d.ts.map +1 -1
- package/dist/alphalib/types/robots/file-filter.js +11 -40
- package/dist/alphalib/types/robots/file-filter.js.map +1 -1
- package/dist/alphalib/types/robots/file-hash.d.ts +84 -71
- package/dist/alphalib/types/robots/file-hash.d.ts.map +1 -1
- package/dist/alphalib/types/robots/file-hash.js +12 -43
- package/dist/alphalib/types/robots/file-hash.js.map +1 -1
- package/dist/alphalib/types/robots/file-preview.d.ts +113 -100
- package/dist/alphalib/types/robots/file-preview.d.ts.map +1 -1
- package/dist/alphalib/types/robots/file-preview.js +14 -39
- package/dist/alphalib/types/robots/file-preview.js.map +1 -1
- package/dist/alphalib/types/robots/file-read.d.ts +80 -67
- package/dist/alphalib/types/robots/file-read.d.ts.map +1 -1
- package/dist/alphalib/types/robots/file-read.js +5 -26
- package/dist/alphalib/types/robots/file-read.js.map +1 -1
- package/dist/alphalib/types/robots/file-serve.d.ts +81 -68
- package/dist/alphalib/types/robots/file-serve.d.ts.map +1 -1
- package/dist/alphalib/types/robots/file-serve.js +4 -21
- package/dist/alphalib/types/robots/file-serve.js.map +1 -1
- package/dist/alphalib/types/robots/file-verify.d.ts +88 -75
- package/dist/alphalib/types/robots/file-verify.d.ts.map +1 -1
- package/dist/alphalib/types/robots/file-verify.js +11 -41
- package/dist/alphalib/types/robots/file-verify.js.map +1 -1
- package/dist/alphalib/types/robots/file-virusscan.d.ts +83 -67
- package/dist/alphalib/types/robots/file-virusscan.d.ts.map +1 -1
- package/dist/alphalib/types/robots/file-virusscan.js +16 -42
- package/dist/alphalib/types/robots/file-virusscan.js.map +1 -1
- package/dist/alphalib/types/robots/file-watermark.d.ts +81 -67
- package/dist/alphalib/types/robots/file-watermark.d.ts.map +1 -1
- package/dist/alphalib/types/robots/file-watermark.js +10 -29
- package/dist/alphalib/types/robots/file-watermark.js.map +1 -1
- package/dist/alphalib/types/robots/ftp-import.d.ts +40 -27
- package/dist/alphalib/types/robots/ftp-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/ftp-import.js +5 -33
- package/dist/alphalib/types/robots/ftp-import.js.map +1 -1
- package/dist/alphalib/types/robots/ftp-store.d.ts +85 -67
- package/dist/alphalib/types/robots/ftp-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/ftp-store.js +7 -34
- package/dist/alphalib/types/robots/ftp-store.js.map +1 -1
- package/dist/alphalib/types/robots/google-import.d.ts +48 -35
- package/dist/alphalib/types/robots/google-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/google-import.js +10 -43
- package/dist/alphalib/types/robots/google-import.js.map +1 -1
- package/dist/alphalib/types/robots/google-store.d.ts +80 -67
- package/dist/alphalib/types/robots/google-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/google-store.js +10 -41
- package/dist/alphalib/types/robots/google-store.js.map +1 -1
- package/dist/alphalib/types/robots/html-convert.d.ts +107 -89
- package/dist/alphalib/types/robots/html-convert.d.ts.map +1 -1
- package/dist/alphalib/types/robots/html-convert.js +6 -22
- package/dist/alphalib/types/robots/html-convert.js.map +1 -1
- package/dist/alphalib/types/robots/http-import.d.ts +76 -63
- package/dist/alphalib/types/robots/http-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/http-import.js +14 -19
- package/dist/alphalib/types/robots/http-import.js.map +1 -1
- package/dist/alphalib/types/robots/http-request.d.ts +538 -0
- package/dist/alphalib/types/robots/http-request.d.ts.map +1 -0
- package/dist/alphalib/types/robots/http-request.js +162 -0
- package/dist/alphalib/types/robots/http-request.js.map +1 -0
- package/dist/alphalib/types/robots/image-bgremove.d.ts +80 -67
- package/dist/alphalib/types/robots/image-bgremove.d.ts.map +1 -1
- package/dist/alphalib/types/robots/image-bgremove.js +6 -33
- package/dist/alphalib/types/robots/image-bgremove.js.map +1 -1
- package/dist/alphalib/types/robots/image-copyrightdetect.d.ts +92 -79
- package/dist/alphalib/types/robots/image-copyrightdetect.d.ts.map +1 -1
- package/dist/alphalib/types/robots/image-copyrightdetect.js +9 -33
- package/dist/alphalib/types/robots/image-copyrightdetect.js.map +1 -1
- package/dist/alphalib/types/robots/image-describe.d.ts +80 -67
- package/dist/alphalib/types/robots/image-describe.d.ts.map +1 -1
- package/dist/alphalib/types/robots/image-describe.js +8 -37
- package/dist/alphalib/types/robots/image-describe.js.map +1 -1
- package/dist/alphalib/types/robots/image-enhance.d.ts +80 -67
- package/dist/alphalib/types/robots/image-enhance.d.ts.map +1 -1
- package/dist/alphalib/types/robots/image-enhance.js +7 -31
- package/dist/alphalib/types/robots/image-enhance.js.map +1 -1
- package/dist/alphalib/types/robots/image-facedetect.d.ts +88 -75
- package/dist/alphalib/types/robots/image-facedetect.d.ts.map +1 -1
- package/dist/alphalib/types/robots/image-facedetect.js +16 -44
- package/dist/alphalib/types/robots/image-facedetect.js.map +1 -1
- package/dist/alphalib/types/robots/image-generate.d.ts +96 -86
- package/dist/alphalib/types/robots/image-generate.d.ts.map +1 -1
- package/dist/alphalib/types/robots/image-generate.js +20 -25
- package/dist/alphalib/types/robots/image-generate.js.map +1 -1
- package/dist/alphalib/types/robots/image-merge.d.ts +96 -83
- package/dist/alphalib/types/robots/image-merge.d.ts.map +1 -1
- package/dist/alphalib/types/robots/image-merge.js +9 -40
- package/dist/alphalib/types/robots/image-merge.js.map +1 -1
- package/dist/alphalib/types/robots/image-ocr.d.ts +80 -67
- package/dist/alphalib/types/robots/image-ocr.d.ts.map +1 -1
- package/dist/alphalib/types/robots/image-ocr.js +11 -47
- package/dist/alphalib/types/robots/image-ocr.js.map +1 -1
- package/dist/alphalib/types/robots/image-optimize.d.ts +88 -75
- package/dist/alphalib/types/robots/image-optimize.d.ts.map +1 -1
- package/dist/alphalib/types/robots/image-optimize.js +6 -32
- package/dist/alphalib/types/robots/image-optimize.js.map +1 -1
- package/dist/alphalib/types/robots/image-resize.d.ts +217 -112
- package/dist/alphalib/types/robots/image-resize.d.ts.map +1 -1
- package/dist/alphalib/types/robots/image-resize.js +15 -42
- package/dist/alphalib/types/robots/image-resize.js.map +1 -1
- package/dist/alphalib/types/robots/image-upscale.d.ts +97 -81
- package/dist/alphalib/types/robots/image-upscale.d.ts.map +1 -1
- package/dist/alphalib/types/robots/image-upscale.js +23 -42
- package/dist/alphalib/types/robots/image-upscale.js.map +1 -1
- package/dist/alphalib/types/robots/mega-import.d.ts +48 -35
- package/dist/alphalib/types/robots/mega-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/mega-import.js +12 -59
- package/dist/alphalib/types/robots/mega-import.js.map +1 -1
- package/dist/alphalib/types/robots/mega-store.d.ts +80 -67
- package/dist/alphalib/types/robots/mega-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/mega-store.js +14 -60
- package/dist/alphalib/types/robots/mega-store.js.map +1 -1
- package/dist/alphalib/types/robots/meta-read.d.ts +30 -16
- package/dist/alphalib/types/robots/meta-read.d.ts.map +1 -1
- package/dist/alphalib/types/robots/meta-read.js +4 -20
- package/dist/alphalib/types/robots/meta-read.js.map +1 -1
- package/dist/alphalib/types/robots/meta-write.d.ts +80 -67
- package/dist/alphalib/types/robots/meta-write.d.ts.map +1 -1
- package/dist/alphalib/types/robots/meta-write.js +9 -32
- package/dist/alphalib/types/robots/meta-write.js.map +1 -1
- package/dist/alphalib/types/robots/minio-import.d.ts +48 -35
- package/dist/alphalib/types/robots/minio-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/minio-import.js +9 -60
- package/dist/alphalib/types/robots/minio-import.js.map +1 -1
- package/dist/alphalib/types/robots/minio-store.d.ts +80 -67
- package/dist/alphalib/types/robots/minio-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/minio-store.js +9 -50
- package/dist/alphalib/types/robots/minio-store.js.map +1 -1
- package/dist/alphalib/types/robots/progress-simulate.d.ts +34 -28
- package/dist/alphalib/types/robots/progress-simulate.d.ts.map +1 -1
- package/dist/alphalib/types/robots/progress-simulate.js +8 -28
- package/dist/alphalib/types/robots/progress-simulate.js.map +1 -1
- package/dist/alphalib/types/robots/s3-import.d.ts +48 -35
- package/dist/alphalib/types/robots/s3-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/s3-import.js +7 -38
- package/dist/alphalib/types/robots/s3-import.js.map +1 -1
- package/dist/alphalib/types/robots/s3-store.d.ts +84 -68
- package/dist/alphalib/types/robots/s3-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/s3-store.js +14 -44
- package/dist/alphalib/types/robots/s3-store.js.map +1 -1
- package/dist/alphalib/types/robots/script-run.d.ts +83 -67
- package/dist/alphalib/types/robots/script-run.d.ts.map +1 -1
- package/dist/alphalib/types/robots/script-run.js +9 -27
- package/dist/alphalib/types/robots/script-run.js.map +1 -1
- package/dist/alphalib/types/robots/sftp-import.d.ts +51 -35
- package/dist/alphalib/types/robots/sftp-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/sftp-import.js +7 -36
- package/dist/alphalib/types/robots/sftp-import.js.map +1 -1
- package/dist/alphalib/types/robots/sftp-store.d.ts +83 -67
- package/dist/alphalib/types/robots/sftp-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/sftp-store.js +9 -41
- package/dist/alphalib/types/robots/sftp-store.js.map +1 -1
- package/dist/alphalib/types/robots/speech-transcribe.d.ts +102 -85
- package/dist/alphalib/types/robots/speech-transcribe.d.ts.map +1 -1
- package/dist/alphalib/types/robots/speech-transcribe.js +23 -44
- package/dist/alphalib/types/robots/speech-transcribe.js.map +1 -1
- package/dist/alphalib/types/robots/supabase-import.d.ts +48 -35
- package/dist/alphalib/types/robots/supabase-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/supabase-import.js +12 -59
- package/dist/alphalib/types/robots/supabase-import.js.map +1 -1
- package/dist/alphalib/types/robots/supabase-store.d.ts +80 -79
- package/dist/alphalib/types/robots/supabase-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/supabase-store.js +12 -56
- package/dist/alphalib/types/robots/supabase-store.js.map +1 -1
- package/dist/alphalib/types/robots/swift-import.d.ts +48 -47
- package/dist/alphalib/types/robots/swift-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/swift-import.js +14 -55
- package/dist/alphalib/types/robots/swift-import.js.map +1 -1
- package/dist/alphalib/types/robots/swift-store.d.ts +80 -79
- package/dist/alphalib/types/robots/swift-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/swift-store.js +14 -62
- package/dist/alphalib/types/robots/swift-store.js.map +1 -1
- package/dist/alphalib/types/robots/text-speak.d.ts +80 -67
- package/dist/alphalib/types/robots/text-speak.d.ts.map +1 -1
- package/dist/alphalib/types/robots/text-speak.js +11 -37
- package/dist/alphalib/types/robots/text-speak.js.map +1 -1
- package/dist/alphalib/types/robots/text-translate.d.ts +92 -79
- package/dist/alphalib/types/robots/text-translate.d.ts.map +1 -1
- package/dist/alphalib/types/robots/text-translate.js +9 -36
- package/dist/alphalib/types/robots/text-translate.js.map +1 -1
- package/dist/alphalib/types/robots/tigris-import.d.ts +48 -35
- package/dist/alphalib/types/robots/tigris-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/tigris-import.js +9 -60
- package/dist/alphalib/types/robots/tigris-import.js.map +1 -1
- package/dist/alphalib/types/robots/tigris-store.d.ts +80 -67
- package/dist/alphalib/types/robots/tigris-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/tigris-store.js +7 -48
- package/dist/alphalib/types/robots/tigris-store.js.map +1 -1
- package/dist/alphalib/types/robots/tlcdn-deliver.d.ts +32 -19
- package/dist/alphalib/types/robots/tlcdn-deliver.d.ts.map +1 -1
- package/dist/alphalib/types/robots/tlcdn-deliver.js +4 -25
- package/dist/alphalib/types/robots/tlcdn-deliver.js.map +1 -1
- package/dist/alphalib/types/robots/transloadit-import.d.ts +58 -45
- package/dist/alphalib/types/robots/transloadit-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/transloadit-import.js +17 -21
- package/dist/alphalib/types/robots/transloadit-import.js.map +1 -1
- package/dist/alphalib/types/robots/transloadit-store.d.ts +70 -57
- package/dist/alphalib/types/robots/transloadit-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/transloadit-store.js +14 -6
- package/dist/alphalib/types/robots/transloadit-store.js.map +1 -1
- package/dist/alphalib/types/robots/tus-store.d.ts +84 -71
- package/dist/alphalib/types/robots/tus-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/tus-store.js +8 -37
- package/dist/alphalib/types/robots/tus-store.js.map +1 -1
- package/dist/alphalib/types/robots/upload-handle.d.ts +32 -19
- package/dist/alphalib/types/robots/upload-handle.d.ts.map +1 -1
- package/dist/alphalib/types/robots/upload-handle.js +4 -19
- package/dist/alphalib/types/robots/upload-handle.js.map +1 -1
- package/dist/alphalib/types/robots/video-adaptive.d.ts +112 -99
- package/dist/alphalib/types/robots/video-adaptive.d.ts.map +1 -1
- package/dist/alphalib/types/robots/video-adaptive.js +4 -26
- package/dist/alphalib/types/robots/video-adaptive.js.map +1 -1
- package/dist/alphalib/types/robots/video-artwork.d.ts +80 -67
- package/dist/alphalib/types/robots/video-artwork.d.ts.map +1 -1
- package/dist/alphalib/types/robots/video-artwork.js +7 -32
- package/dist/alphalib/types/robots/video-artwork.js.map +1 -1
- package/dist/alphalib/types/robots/video-concat.d.ts +104 -91
- package/dist/alphalib/types/robots/video-concat.d.ts.map +1 -1
- package/dist/alphalib/types/robots/video-concat.js +6 -27
- package/dist/alphalib/types/robots/video-concat.js.map +1 -1
- package/dist/alphalib/types/robots/video-encode.d.ts +121 -103
- package/dist/alphalib/types/robots/video-encode.d.ts.map +1 -1
- package/dist/alphalib/types/robots/video-encode.js +13 -38
- package/dist/alphalib/types/robots/video-encode.js.map +1 -1
- package/dist/alphalib/types/robots/video-generate.d.ts +96 -86
- package/dist/alphalib/types/robots/video-generate.d.ts.map +1 -1
- package/dist/alphalib/types/robots/video-generate.js +11 -18
- package/dist/alphalib/types/robots/video-generate.js.map +1 -1
- package/dist/alphalib/types/robots/video-merge.d.ts +135 -119
- package/dist/alphalib/types/robots/video-merge.d.ts.map +1 -1
- package/dist/alphalib/types/robots/video-merge.js +12 -32
- package/dist/alphalib/types/robots/video-merge.js.map +1 -1
- package/dist/alphalib/types/robots/video-ondemand.d.ts +156 -139
- package/dist/alphalib/types/robots/video-ondemand.d.ts.map +1 -1
- package/dist/alphalib/types/robots/video-ondemand.js +11 -27
- package/dist/alphalib/types/robots/video-ondemand.js.map +1 -1
- package/dist/alphalib/types/robots/video-split.d.ts +104 -91
- package/dist/alphalib/types/robots/video-split.d.ts.map +1 -1
- package/dist/alphalib/types/robots/video-split.js +11 -39
- package/dist/alphalib/types/robots/video-split.js.map +1 -1
- package/dist/alphalib/types/robots/video-subtitle.d.ts +104 -91
- package/dist/alphalib/types/robots/video-subtitle.d.ts.map +1 -1
- package/dist/alphalib/types/robots/video-subtitle.js +7 -30
- package/dist/alphalib/types/robots/video-subtitle.js.map +1 -1
- package/dist/alphalib/types/robots/video-thumbs.d.ts +112 -95
- package/dist/alphalib/types/robots/video-thumbs.d.ts.map +1 -1
- package/dist/alphalib/types/robots/video-thumbs.js +46 -53
- package/dist/alphalib/types/robots/video-thumbs.js.map +1 -1
- package/dist/alphalib/types/robots/vimeo-import.d.ts +30 -17
- package/dist/alphalib/types/robots/vimeo-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/vimeo-import.js +7 -17
- package/dist/alphalib/types/robots/vimeo-import.js.map +1 -1
- package/dist/alphalib/types/robots/vimeo-store.d.ts +83 -67
- package/dist/alphalib/types/robots/vimeo-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/vimeo-store.js +11 -37
- package/dist/alphalib/types/robots/vimeo-store.js.map +1 -1
- package/dist/alphalib/types/robots/wasabi-import.d.ts +48 -35
- package/dist/alphalib/types/robots/wasabi-import.d.ts.map +1 -1
- package/dist/alphalib/types/robots/wasabi-import.js +9 -56
- package/dist/alphalib/types/robots/wasabi-import.js.map +1 -1
- package/dist/alphalib/types/robots/wasabi-store.d.ts +80 -67
- package/dist/alphalib/types/robots/wasabi-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/wasabi-store.js +10 -52
- package/dist/alphalib/types/robots/wasabi-store.js.map +1 -1
- package/dist/alphalib/types/robots/youtube-store.d.ts +98 -85
- package/dist/alphalib/types/robots/youtube-store.d.ts.map +1 -1
- package/dist/alphalib/types/robots/youtube-store.js +42 -63
- package/dist/alphalib/types/robots/youtube-store.js.map +1 -1
- package/dist/alphalib/types/stackVersions.d.ts +40 -1
- package/dist/alphalib/types/stackVersions.d.ts.map +1 -1
- package/dist/alphalib/types/stackVersions.js +25 -3
- package/dist/alphalib/types/stackVersions.js.map +1 -1
- package/dist/alphalib/types/storageAsset.d.ts +55 -23
- package/dist/alphalib/types/storageAsset.d.ts.map +1 -1
- package/dist/alphalib/types/storageAsset.js +33 -9
- package/dist/alphalib/types/storageAsset.js.map +1 -1
- package/dist/alphalib/types/template.d.ts +16 -16
- package/dist/alphalib/types/templateCredential.d.ts +2 -2
- package/dist/alphalib/types/utility.d.ts +22 -0
- package/dist/alphalib/types/utility.d.ts.map +1 -0
- package/dist/alphalib/types/utility.js +2 -0
- package/dist/alphalib/types/utility.js.map +1 -0
- package/dist/cli/commands/storage.d.ts +1 -0
- package/dist/cli/commands/storage.d.ts.map +1 -1
- package/dist/cli/commands/storage.js +27 -2
- package/dist/cli/commands/storage.js.map +1 -1
- package/dist/cli/semanticIntents/imageGenerate.d.ts +2 -2
- package/dist/cli/semanticIntents/imageGenerate.js +4 -4
- package/dist/cli/semanticIntents/imageGenerate.js.map +1 -1
- package/dist/cli/storageReceipts.d.ts.map +1 -1
- package/dist/cli/storageReceipts.js +4 -1
- package/dist/cli/storageReceipts.js.map +1 -1
- package/dist/storageImage.d.ts +6 -3
- package/dist/storageImage.d.ts.map +1 -1
- package/dist/storageImage.js +13 -0
- package/dist/storageImage.js.map +1 -1
- package/package.json +1 -2
- package/src/ApiError.ts +11 -4
- package/src/Transloadit.ts +24 -5
- package/src/alphalib/aiMessages.ts +554 -0
- package/src/alphalib/assembly-linter.ts +9 -2
- package/src/alphalib/englishList.ts +11 -0
- package/src/alphalib/errors.ts +159 -13
- package/src/alphalib/imagemagickDensity.ts +2 -1
- package/src/alphalib/lib/zodInputSemantics.ts +114 -0
- package/src/alphalib/object.ts +178 -3
- package/src/alphalib/stepParsing.ts +10 -2
- package/src/alphalib/types/apiParameterDescription.ts +41 -0
- package/src/alphalib/types/assemblyStatus.ts +121 -83
- package/src/alphalib/types/errorReason.ts +14 -0
- package/src/alphalib/types/file.ts +18 -0
- package/src/alphalib/types/fileHash.ts +10 -0
- package/src/alphalib/types/responseErrors/HttpImportRobot.ts +22 -0
- package/src/alphalib/types/robots/_ai-models.ts +91 -0
- package/src/alphalib/types/robots/_index.ts +14 -0
- package/src/alphalib/types/robots/_instructions-primitives.ts +841 -308
- package/src/alphalib/types/robots/ai-chat.ts +358 -459
- package/src/alphalib/types/robots/assembly-savejson.ts +2 -11
- package/src/alphalib/types/robots/audio-artwork.ts +35 -61
- package/src/alphalib/types/robots/audio-concat.ts +17 -25
- package/src/alphalib/types/robots/audio-encode.ts +35 -65
- package/src/alphalib/types/robots/audio-loop.ts +34 -61
- package/src/alphalib/types/robots/audio-merge.ts +17 -25
- package/src/alphalib/types/robots/audio-split.ts +37 -67
- package/src/alphalib/types/robots/audio-waveform.ts +42 -65
- package/src/alphalib/types/robots/azure-import.ts +26 -57
- package/src/alphalib/types/robots/azure-store.ts +48 -72
- package/src/alphalib/types/robots/backblaze-import.ts +30 -63
- package/src/alphalib/types/robots/backblaze-store.ts +37 -66
- package/src/alphalib/types/robots/box-import.ts +32 -55
- package/src/alphalib/types/robots/box-store.ts +40 -63
- package/src/alphalib/types/robots/cloudfiles-import.ts +34 -70
- package/src/alphalib/types/robots/cloudfiles-store.ts +28 -59
- package/src/alphalib/types/robots/cloudflare-import.ts +37 -83
- package/src/alphalib/types/robots/cloudflare-store.ts +37 -77
- package/src/alphalib/types/robots/digitalocean-import.ts +35 -75
- package/src/alphalib/types/robots/digitalocean-store.ts +35 -79
- package/src/alphalib/types/robots/document-autorotate.ts +36 -58
- package/src/alphalib/types/robots/document-convert.ts +37 -59
- package/src/alphalib/types/robots/document-extract.ts +45 -62
- package/src/alphalib/types/robots/document-merge.ts +25 -47
- package/src/alphalib/types/robots/document-ocr.ts +32 -70
- package/src/alphalib/types/robots/document-optimize.ts +38 -57
- package/src/alphalib/types/robots/document-split.ts +33 -56
- package/src/alphalib/types/robots/document-thumbs.ts +66 -67
- package/src/alphalib/types/robots/dropbox-import.ts +27 -57
- package/src/alphalib/types/robots/dropbox-store.ts +39 -65
- package/src/alphalib/types/robots/edgly-deliver.ts +26 -49
- package/src/alphalib/types/robots/file-compress.ts +31 -45
- package/src/alphalib/types/robots/file-decompress.ts +41 -68
- package/src/alphalib/types/robots/file-filter.ts +36 -65
- package/src/alphalib/types/robots/file-hash.ts +37 -64
- package/src/alphalib/types/robots/file-preview.ts +39 -65
- package/src/alphalib/types/robots/file-read.ts +33 -50
- package/src/alphalib/types/robots/file-serve.ts +32 -46
- package/src/alphalib/types/robots/file-verify.ts +37 -63
- package/src/alphalib/types/robots/file-virusscan.ts +49 -67
- package/src/alphalib/types/robots/file-watermark.ts +35 -54
- package/src/alphalib/types/robots/ftp-import.ts +26 -54
- package/src/alphalib/types/robots/ftp-store.ts +44 -63
- package/src/alphalib/types/robots/google-import.ts +32 -66
- package/src/alphalib/types/robots/google-store.ts +37 -63
- package/src/alphalib/types/robots/html-convert.ts +38 -49
- package/src/alphalib/types/robots/http-import.ts +21 -19
- package/src/alphalib/types/robots/http-request.ts +196 -0
- package/src/alphalib/types/robots/image-bgremove.ts +28 -55
- package/src/alphalib/types/robots/image-copyrightdetect.ts +38 -56
- package/src/alphalib/types/robots/image-describe.ts +31 -60
- package/src/alphalib/types/robots/image-enhance.ts +30 -56
- package/src/alphalib/types/robots/image-facedetect.ts +43 -71
- package/src/alphalib/types/robots/image-generate.ts +32 -25
- package/src/alphalib/types/robots/image-merge.ts +34 -65
- package/src/alphalib/types/robots/image-ocr.ts +33 -69
- package/src/alphalib/types/robots/image-optimize.ts +28 -54
- package/src/alphalib/types/robots/image-resize.ts +72 -96
- package/src/alphalib/types/robots/image-upscale.ts +52 -64
- package/src/alphalib/types/robots/mega-import.ts +36 -84
- package/src/alphalib/types/robots/mega-store.ts +44 -81
- package/src/alphalib/types/robots/meta-read.ts +21 -36
- package/src/alphalib/types/robots/meta-write.ts +35 -53
- package/src/alphalib/types/robots/minio-import.ts +34 -86
- package/src/alphalib/types/robots/minio-store.ts +37 -72
- package/src/alphalib/types/robots/progress-simulate.ts +14 -28
- package/src/alphalib/types/robots/s3-import.ts +32 -63
- package/src/alphalib/types/robots/s3-store.ts +53 -74
- package/src/alphalib/types/robots/script-run.ts +44 -55
- package/src/alphalib/types/robots/sftp-import.ts +34 -61
- package/src/alphalib/types/robots/sftp-store.ts +42 -65
- package/src/alphalib/types/robots/speech-transcribe.ts +53 -71
- package/src/alphalib/types/robots/supabase-import.ts +37 -84
- package/src/alphalib/types/robots/supabase-store.ts +41 -78
- package/src/alphalib/types/robots/swift-import.ts +38 -80
- package/src/alphalib/types/robots/swift-store.ts +44 -84
- package/src/alphalib/types/robots/text-speak.ts +36 -62
- package/src/alphalib/types/robots/text-translate.ts +35 -62
- package/src/alphalib/types/robots/tigris-import.ts +34 -86
- package/src/alphalib/types/robots/tigris-store.ts +35 -70
- package/src/alphalib/types/robots/tlcdn-deliver.ts +23 -47
- package/src/alphalib/types/robots/transloadit-import.ts +24 -29
- package/src/alphalib/types/robots/transloadit-store.ts +20 -7
- package/src/alphalib/types/robots/tus-store.ts +34 -58
- package/src/alphalib/types/robots/upload-handle.ts +23 -41
- package/src/alphalib/types/robots/video-adaptive.ts +28 -51
- package/src/alphalib/types/robots/video-artwork.ts +28 -54
- package/src/alphalib/types/robots/video-concat.ts +29 -52
- package/src/alphalib/types/robots/video-encode.ts +39 -62
- package/src/alphalib/types/robots/video-generate.ts +20 -18
- package/src/alphalib/types/robots/video-merge.ts +36 -55
- package/src/alphalib/types/robots/video-ondemand.ts +48 -62
- package/src/alphalib/types/robots/video-split.ts +32 -61
- package/src/alphalib/types/robots/video-subtitle.ts +30 -52
- package/src/alphalib/types/robots/video-thumbs.ts +74 -78
- package/src/alphalib/types/robots/vimeo-import.ts +12 -17
- package/src/alphalib/types/robots/vimeo-store.ts +46 -65
- package/src/alphalib/types/robots/wasabi-import.ts +33 -81
- package/src/alphalib/types/robots/wasabi-store.ts +38 -74
- package/src/alphalib/types/robots/youtube-store.ts +81 -91
- package/src/alphalib/types/stackVersions.ts +26 -3
- package/src/alphalib/types/storageAsset.ts +85 -29
- package/src/alphalib/types/utility.ts +52 -0
- package/src/cli/commands/storage.ts +28 -2
- package/src/cli/semanticIntents/imageGenerate.ts +4 -4
- package/src/cli/storageReceipts.ts +4 -1
- package/src/storageImage.ts +18 -3
package/src/alphalib/errors.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getRecordProperty, isRecord } from './object.ts'
|
|
1
|
+
import { getRecordProperty, isPresent, isRecord } from './object.ts'
|
|
2
2
|
|
|
3
3
|
export function normalizeError(err: unknown): Error {
|
|
4
4
|
if (err instanceof Error) {
|
|
@@ -8,26 +8,147 @@ export function normalizeError(err: unknown): Error {
|
|
|
8
8
|
return new Error(`Was thrown a non-error: ${String(err)}`, { cause: err })
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
/** Log a normalized terminal error and stop the current CLI process. */
|
|
12
|
+
export function exitWithError(error: unknown): never {
|
|
13
|
+
console.error(normalizeError(error))
|
|
14
|
+
process.exit(1)
|
|
15
|
+
}
|
|
16
|
+
|
|
11
17
|
export function getErrorMessage(err: unknown): string {
|
|
12
18
|
return err instanceof Error ? err.message : String(err)
|
|
13
19
|
}
|
|
14
20
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
interface ErrorBranchSummary {
|
|
22
|
+
issueCount: number
|
|
23
|
+
messages: string[]
|
|
24
|
+
stackFrames: string[]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Cycle-safe summary of unique errors and non-error values in one error graph. */
|
|
28
|
+
export interface ErrorTreeSummary {
|
|
29
|
+
issueCount: number
|
|
30
|
+
message: string
|
|
31
|
+
stackFrames: string[]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getExpectedErrorStackMessageLines(error: Error): string[] {
|
|
35
|
+
const [firstMessageLine = '', ...remainingMessageLines] = error.message.split('\n')
|
|
36
|
+
const headline =
|
|
37
|
+
error.name === ''
|
|
38
|
+
? firstMessageLine
|
|
39
|
+
: firstMessageLine === ''
|
|
40
|
+
? error.name
|
|
41
|
+
: `${error.name}: ${firstMessageLine}`
|
|
42
|
+
return [headline, ...remainingMessageLines]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function getStackWithoutMessageDetails(error: Error): string | undefined {
|
|
46
|
+
const { stack } = error
|
|
47
|
+
if (stack === undefined) return
|
|
48
|
+
|
|
49
|
+
const lines = stack.split('\n')
|
|
50
|
+
const headline = lines[0]
|
|
51
|
+
if (headline === undefined) return
|
|
52
|
+
|
|
53
|
+
const expectedMessageLines = getExpectedErrorStackMessageLines(error)
|
|
54
|
+
const hasExpectedMessage = expectedMessageLines.every(
|
|
55
|
+
(expectedLine, index) => lines[index] === expectedLine,
|
|
56
|
+
)
|
|
57
|
+
if (!hasExpectedMessage) return stack
|
|
58
|
+
|
|
59
|
+
return [headline, ...lines.slice(expectedMessageLines.length)].join('\n')
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getStackFrameDetails(error: Error): string | undefined {
|
|
63
|
+
const stack = getStackWithoutMessageDetails(error)
|
|
64
|
+
if (stack === undefined) return
|
|
65
|
+
|
|
66
|
+
const [expectedHeadline] = getExpectedErrorStackMessageLines(error)
|
|
67
|
+
if (stack === expectedHeadline) return
|
|
68
|
+
return expectedHeadline !== undefined && stack.startsWith(`${expectedHeadline}\n`)
|
|
69
|
+
? stack.slice(expectedHeadline.length + 1)
|
|
70
|
+
: stack
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function summarizeErrorBranch(value: unknown, visited: Set<Error>): ErrorBranchSummary | undefined {
|
|
74
|
+
if (!(value instanceof Error)) {
|
|
75
|
+
return { issueCount: 1, messages: [String(value)], stackFrames: [] }
|
|
20
76
|
}
|
|
77
|
+
if (visited.has(value)) return
|
|
78
|
+
visited.add(value)
|
|
21
79
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
80
|
+
const nestedValues =
|
|
81
|
+
value instanceof AggregateError ? value.errors : value.cause == null ? [] : [value.cause]
|
|
82
|
+
const nestedSummaries = nestedValues
|
|
83
|
+
.map((nestedValue) => summarizeErrorBranch(nestedValue, visited))
|
|
84
|
+
.filter(isPresent)
|
|
85
|
+
let nestedIssueCount = 0
|
|
86
|
+
for (const summary of nestedSummaries) {
|
|
87
|
+
nestedIssueCount += summary.issueCount
|
|
88
|
+
}
|
|
89
|
+
const nestedStackFrames = nestedSummaries.flatMap(({ stackFrames }) => stackFrames)
|
|
90
|
+
const ownMessages =
|
|
91
|
+
value instanceof AggregateError
|
|
92
|
+
? [value.message]
|
|
93
|
+
: [value.name && value.name !== 'Error' ? value.name : '', value.message]
|
|
94
|
+
const ownStack = getStackFrameDetails(value)
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
issueCount: Math.max(1, nestedIssueCount),
|
|
98
|
+
messages: [...ownMessages, ...nestedSummaries.flatMap(({ messages }) => messages)].filter(
|
|
99
|
+
(message) => message !== '',
|
|
100
|
+
),
|
|
101
|
+
stackFrames: nestedStackFrames.length > 0 ? nestedStackFrames : [ownStack].filter(isPresent),
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Summarize an error graph once, deduplicating shared Error object references by identity. */
|
|
106
|
+
export function summarizeErrorTree(errors: readonly unknown[]): ErrorTreeSummary {
|
|
107
|
+
const visited = new Set<Error>()
|
|
108
|
+
const summaries = errors.map((error) => summarizeErrorBranch(error, visited)).filter(isPresent)
|
|
109
|
+
let issueCount = 0
|
|
110
|
+
for (const summary of summaries) {
|
|
111
|
+
issueCount += summary.issueCount
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
issueCount,
|
|
116
|
+
message: summaries.flatMap(({ messages }) => messages).join('\n'),
|
|
117
|
+
stackFrames: summaries.flatMap(({ stackFrames }) => stackFrames),
|
|
28
118
|
}
|
|
119
|
+
}
|
|
29
120
|
|
|
30
|
-
|
|
121
|
+
export function getErrorMessageWithCauses(err: unknown): string {
|
|
122
|
+
return summarizeErrorTree([err]).message
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Create one contextual AggregateError from independently collected failures. */
|
|
126
|
+
export function createCollectedError(
|
|
127
|
+
errors: readonly Error[],
|
|
128
|
+
context: string,
|
|
129
|
+
includeDetails = false,
|
|
130
|
+
): AggregateError {
|
|
131
|
+
const errorTree = summarizeErrorTree(errors)
|
|
132
|
+
const summary = `${context} found ${errorTree.issueCount} ${errorTree.issueCount === 1 ? 'issue' : 'issues'}`
|
|
133
|
+
const message = includeDetails ? [summary, errorTree.message].filter(Boolean).join('\n') : summary
|
|
134
|
+
const aggregateError = new AggregateError(errors, message)
|
|
135
|
+
if (includeDetails) {
|
|
136
|
+
aggregateError.stack = [getStackWithoutMessageDetails(aggregateError), ...errorTree.stackFrames]
|
|
137
|
+
.filter(isPresent)
|
|
138
|
+
.join('\nCollected error:\n')
|
|
139
|
+
}
|
|
140
|
+
return aggregateError
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Throw a contextual AggregateError when at least one collected failure exists. */
|
|
144
|
+
export function throwCollectedErrors(
|
|
145
|
+
errors: readonly Error[],
|
|
146
|
+
context: string,
|
|
147
|
+
includeDetails = false,
|
|
148
|
+
): void {
|
|
149
|
+
if (errors.length === 0) return
|
|
150
|
+
|
|
151
|
+
throw createCollectedError(errors, context, includeDetails)
|
|
31
152
|
}
|
|
32
153
|
|
|
33
154
|
export function getErrorCode(err: unknown): unknown {
|
|
@@ -43,6 +164,31 @@ export function getNodeErrorCode(err: unknown): string | undefined {
|
|
|
43
164
|
return typeof code === 'string' ? code : undefined
|
|
44
165
|
}
|
|
45
166
|
|
|
167
|
+
/** Summarize bounded error names and codes without retaining messages, stacks, or response data. */
|
|
168
|
+
export function summarizeErrorForDiagnostics(error: unknown): string {
|
|
169
|
+
const pending: unknown[] = [error]
|
|
170
|
+
const seen = new Set<unknown>()
|
|
171
|
+
const reasons: string[] = []
|
|
172
|
+
|
|
173
|
+
// Error messages, stacks and response objects can contain credentials.
|
|
174
|
+
for (let index = 0; index < pending.length && index < 8; index += 1) {
|
|
175
|
+
const current = pending[index]
|
|
176
|
+
if (!isRecord(current) || seen.has(current)) continue
|
|
177
|
+
seen.add(current)
|
|
178
|
+
const name =
|
|
179
|
+
typeof current.name === 'string' && /^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(current.name)
|
|
180
|
+
? current.name
|
|
181
|
+
: 'Error'
|
|
182
|
+
const code = getNodeErrorCode(current)
|
|
183
|
+
const reason = code && /^[A-Z][A-Z0-9_]{0,63}$/.test(code) ? `${name} (${code})` : name
|
|
184
|
+
if (!reasons.includes(reason)) reasons.push(reason)
|
|
185
|
+
if (current.cause != null) pending.push(current.cause)
|
|
186
|
+
if (current instanceof AggregateError) pending.push(...current.errors.slice(0, 8))
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return (reasons.join(' → ') || 'UnknownError').slice(0, 220)
|
|
190
|
+
}
|
|
191
|
+
|
|
46
192
|
export function isErrnoException(err: unknown): err is NodeJS.ErrnoException {
|
|
47
193
|
return isRecord(err) && 'code' in err
|
|
48
194
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
const positiveDecimalDensityPart = String.raw`(?:0*[1-9]
|
|
1
|
+
const positiveDecimalDensityPart = String.raw`(?:0*[1-9][0-9]*(?:\.[0-9]+)?|0+\.[0-9]*[1-9][0-9]*)`
|
|
2
2
|
|
|
3
3
|
const imagemagickDensityPattern = new RegExp(
|
|
4
4
|
`^${positiveDecimalDensityPart}(?:x${positiveDecimalDensityPart})?$`,
|
|
5
|
+
'u',
|
|
5
6
|
)
|
|
6
7
|
|
|
7
8
|
function isValidImagemagickDensity(value: unknown): boolean {
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
export interface ZodCodePointLengthOptions {
|
|
4
|
+
readonly max?: number
|
|
5
|
+
readonly min?: number
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** ECMAScript whitespace for the runtime regular expressions in shared Robot schemas. */
|
|
9
|
+
export const ecmaWhitespaceCharacterClass = String.raw`[\s]`
|
|
10
|
+
|
|
11
|
+
/** Apply the Robot's output transform using the public Zod API. */
|
|
12
|
+
export function zodInputPreservingTransform<Schema extends z.ZodTypeAny, Output>(
|
|
13
|
+
schema: Schema,
|
|
14
|
+
transform: (value: z.output<Schema>) => Output,
|
|
15
|
+
) {
|
|
16
|
+
// Inference retains each Zod version's native effect/pipe type for generated schema consumers.
|
|
17
|
+
return schema.transform(transform)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** JSON input projections belong to API2's publisher; the SDK validates with the original schema. */
|
|
21
|
+
export function zodWithJsonInputSchema<Schema extends z.ZodTypeAny>(
|
|
22
|
+
schema: Schema,
|
|
23
|
+
_jsonInputSchema: z.ZodTypeAny,
|
|
24
|
+
): Schema {
|
|
25
|
+
return schema
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Conservative publication annotations likewise leave runtime validation and transforms intact. */
|
|
29
|
+
export function zodWithConservativeJsonInputSchema<Schema extends z.ZodTypeAny>(
|
|
30
|
+
schema: Schema,
|
|
31
|
+
_jsonInputSchema: z.ZodTypeAny,
|
|
32
|
+
): Schema {
|
|
33
|
+
return schema
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function isStableJsonValue(value: unknown, ancestors = new Set<object>()): boolean {
|
|
37
|
+
if (value === null || typeof value === 'boolean' || typeof value === 'string') return true
|
|
38
|
+
if (typeof value === 'number') return Number.isFinite(value)
|
|
39
|
+
if (typeof value !== 'object' || ancestors.has(value)) return false
|
|
40
|
+
|
|
41
|
+
ancestors.add(value)
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
44
|
+
if (!Object.hasOwn(value, index) || !isStableJsonValue(value[index], ancestors)) return false
|
|
45
|
+
}
|
|
46
|
+
ancestors.delete(value)
|
|
47
|
+
return true
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const stable =
|
|
51
|
+
(Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null) &&
|
|
52
|
+
Object.values(value).every((entry) => isStableJsonValue(entry, ancestors))
|
|
53
|
+
ancestors.delete(value)
|
|
54
|
+
return stable
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Snapshot a JSON default and parse a fresh copy for each omitted input. */
|
|
58
|
+
export function zodStableJsonDefault<Schema extends z.ZodTypeAny>(
|
|
59
|
+
schema: Schema,
|
|
60
|
+
defaultValue: Exclude<z.input<Schema>, undefined>,
|
|
61
|
+
) {
|
|
62
|
+
if (!isStableJsonValue(defaultValue)) {
|
|
63
|
+
throw new Error('A stable JSON default must contain only finite JSON values')
|
|
64
|
+
}
|
|
65
|
+
if (!schema.safeParse(defaultValue).success) {
|
|
66
|
+
throw new Error('A stable JSON default must satisfy its schema')
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const snapshot = structuredClone(defaultValue)
|
|
70
|
+
// The Zod 4 generator must use prefault here so defaults still run validation and transforms.
|
|
71
|
+
return schema.default(() => structuredClone(snapshot))
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function assertLengthBoundary(name: 'max' | 'min', value: number | undefined): void {
|
|
75
|
+
if (value !== undefined && (!Number.isSafeInteger(value) || value < 0)) {
|
|
76
|
+
throw new Error(`Zod code-point ${name} must be a nonnegative safe integer`)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Validate Unicode code points, so supplementary characters count as one character. */
|
|
81
|
+
export function zodCodePointLength<Schema extends z.ZodString>(
|
|
82
|
+
schema: Schema,
|
|
83
|
+
{ max, min }: ZodCodePointLengthOptions,
|
|
84
|
+
) {
|
|
85
|
+
assertLengthBoundary('max', max)
|
|
86
|
+
assertLengthBoundary('min', min)
|
|
87
|
+
if (max === undefined && min === undefined) {
|
|
88
|
+
throw new Error('Zod code-point length requires a minimum or maximum')
|
|
89
|
+
}
|
|
90
|
+
if (max !== undefined && min !== undefined && min > max) {
|
|
91
|
+
throw new Error('Zod code-point minimum cannot exceed its maximum')
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return schema.superRefine((value, context) => {
|
|
95
|
+
let length = 0
|
|
96
|
+
for (const _character of value) {
|
|
97
|
+
length += 1
|
|
98
|
+
if (max !== undefined && length > max) {
|
|
99
|
+
context.addIssue({
|
|
100
|
+
code: 'custom',
|
|
101
|
+
message: `Must contain at most ${max} Unicode code points`,
|
|
102
|
+
})
|
|
103
|
+
return
|
|
104
|
+
}
|
|
105
|
+
if (max === undefined && min !== undefined && length >= min) return
|
|
106
|
+
}
|
|
107
|
+
if (min !== undefined && length < min) {
|
|
108
|
+
context.addIssue({
|
|
109
|
+
code: 'custom',
|
|
110
|
+
message: `Must contain at least ${min} Unicode code points`,
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
}
|
package/src/alphalib/object.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ObjectEntries } from './types/utility.ts'
|
|
2
2
|
|
|
3
3
|
export type UnknownRecord = Record<PropertyKey, unknown>
|
|
4
4
|
|
|
@@ -7,6 +7,34 @@ export type UnknownRecord = Record<PropertyKey, unknown>
|
|
|
7
7
|
* some background on why this exists and why this isn't in TypeScript by default.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Create a predicate that narrows an object property to a present value.
|
|
12
|
+
*/
|
|
13
|
+
export function hasPresentKey<K extends PropertyKey>(key: K) {
|
|
14
|
+
return <T, V>(
|
|
15
|
+
value: T & { [Property in K]?: V | null | undefined },
|
|
16
|
+
): value is T & { [Property in K]: V } => value[key] !== undefined && value[key] !== null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a predicate that narrows an object property to one exact value.
|
|
21
|
+
*/
|
|
22
|
+
export function hasValueAtKey<K extends PropertyKey, V>(key: K, expectedValue: V) {
|
|
23
|
+
return <T extends Record<K, unknown>>(value: T): value is T & Record<K, V> =>
|
|
24
|
+
value[key] === expectedValue
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Return whether a value is not undefined. */
|
|
28
|
+
export function isDefined<T>(value: T | undefined): value is T {
|
|
29
|
+
return value !== undefined
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Return whether a value is neither null nor undefined. */
|
|
33
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: Shared callers filter results from callbacks that may return void.
|
|
34
|
+
export function isPresent<T>(value: T | null | undefined | void): value is T {
|
|
35
|
+
return value !== undefined && value !== null
|
|
36
|
+
}
|
|
37
|
+
|
|
10
38
|
export function isRecord(value: unknown): value is UnknownRecord {
|
|
11
39
|
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
12
40
|
}
|
|
@@ -27,6 +55,94 @@ export function isStringRecord(value: unknown): value is Record<string, string>
|
|
|
27
55
|
return Object.values(value).every((entry) => typeof entry === 'string')
|
|
28
56
|
}
|
|
29
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Return the enumerable entries of a record except for the requested keys.
|
|
60
|
+
*
|
|
61
|
+
* This intentionally targets data records rather than preserving prototypes, symbols, or property
|
|
62
|
+
* descriptors.
|
|
63
|
+
*/
|
|
64
|
+
export function omitRecordKeys(
|
|
65
|
+
record: object,
|
|
66
|
+
omittedKeys: readonly PropertyKey[],
|
|
67
|
+
): Record<string, unknown> {
|
|
68
|
+
const omitted = new Set(omittedKeys)
|
|
69
|
+
return Object.fromEntries(Object.entries(record).filter(([key]) => !omitted.has(key)))
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const unsafeRecordPathSegments = new Set(['__proto__', 'constructor', 'prototype'])
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Set a dot-delimited path on a data record, creating missing record segments along the way.
|
|
76
|
+
*/
|
|
77
|
+
export function setRecordPath(record: object, path: string, value: unknown): void {
|
|
78
|
+
const segments = path.split('.')
|
|
79
|
+
if (segments.some((segment) => segment === '')) {
|
|
80
|
+
throw new Error(`Invalid record path: ${path}`)
|
|
81
|
+
}
|
|
82
|
+
if (segments.some((segment) => unsafeRecordPathSegments.has(segment))) {
|
|
83
|
+
throw new Error(`Unsafe record path: ${path}`)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (!isRecord(record)) {
|
|
87
|
+
throw new Error('Expected a data record')
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
let current = record
|
|
91
|
+
for (const [index, segment] of segments.entries()) {
|
|
92
|
+
if (index === segments.length - 1) {
|
|
93
|
+
current[segment] = value
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const child = current[segment]
|
|
98
|
+
if (isRecord(child)) {
|
|
99
|
+
current = child
|
|
100
|
+
continue
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const newChild: UnknownRecord = {}
|
|
104
|
+
current[segment] = newChild
|
|
105
|
+
current = newChild
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function isFlattenable(value: unknown): value is object {
|
|
110
|
+
return (
|
|
111
|
+
Array.isArray(value) ||
|
|
112
|
+
(typeof value === 'object' &&
|
|
113
|
+
value !== null &&
|
|
114
|
+
Object.prototype.toString.call(value) === '[object Object]')
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Flatten nested objects and arrays into delimiter-separated keys.
|
|
120
|
+
*
|
|
121
|
+
* Empty containers and non-plain objects remain leaf values.
|
|
122
|
+
*/
|
|
123
|
+
export function flattenObject(value: object, delimiter = '.'): Record<string, unknown> {
|
|
124
|
+
const flattened: Record<string, unknown> = {}
|
|
125
|
+
|
|
126
|
+
function visit(currentValue: unknown, keyPath: string): void {
|
|
127
|
+
const childEntries = isFlattenable(currentValue) ? Object.entries(currentValue) : []
|
|
128
|
+
|
|
129
|
+
if (childEntries.length === 0) {
|
|
130
|
+
flattened[keyPath] = currentValue
|
|
131
|
+
return
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
for (const [key, childValue] of childEntries) {
|
|
135
|
+
visit(childValue, keyPath ? `${keyPath}${delimiter}${key}` : key)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
for (const [key, childValue] of Object.entries(value)) {
|
|
140
|
+
visit(childValue, key)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return flattened
|
|
144
|
+
}
|
|
145
|
+
|
|
30
146
|
export function getRecordProperty(value: unknown, property: PropertyKey): unknown {
|
|
31
147
|
if (!isRecord(value)) {
|
|
32
148
|
return undefined
|
|
@@ -35,6 +151,17 @@ export function getRecordProperty(value: unknown, property: PropertyKey): unknow
|
|
|
35
151
|
return value[property]
|
|
36
152
|
}
|
|
37
153
|
|
|
154
|
+
/** Read a nested property from own data-record keys without traversing arrays or prototypes. */
|
|
155
|
+
export function getPropertyByPath(value: unknown, properties: readonly PropertyKey[]): unknown {
|
|
156
|
+
let result = value
|
|
157
|
+
for (const property of properties) {
|
|
158
|
+
if (!isRecord(result) || !Object.hasOwn(result, property)) return undefined
|
|
159
|
+
result = result[property]
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return result
|
|
163
|
+
}
|
|
164
|
+
|
|
38
165
|
export function getNestedRecordProperty(
|
|
39
166
|
value: unknown,
|
|
40
167
|
first: PropertyKey,
|
|
@@ -74,8 +201,9 @@ export function getNestedNumberProperty(
|
|
|
74
201
|
/**
|
|
75
202
|
* Returns properly typed entries of an object
|
|
76
203
|
*/
|
|
77
|
-
export function entries<T extends { [K in keyof T]: T[K] }>(object: T):
|
|
78
|
-
|
|
204
|
+
export function entries<T extends { [K in keyof T]: T[K] }>(object: T): ObjectEntries<T> {
|
|
205
|
+
// Object.entries loses the relationship between T's keys and values in the standard library.
|
|
206
|
+
return Object.entries(object) as ObjectEntries<T>
|
|
79
207
|
}
|
|
80
208
|
|
|
81
209
|
/**
|
|
@@ -91,3 +219,50 @@ export function values<T extends object>(object: T): T[keyof T][] {
|
|
|
91
219
|
export function keys<T extends object>(object: T): (keyof T)[] {
|
|
92
220
|
return Object.keys(object) as (keyof T)[]
|
|
93
221
|
}
|
|
222
|
+
|
|
223
|
+
type SortPriorities = Record<string, (RegExp | string)[]>
|
|
224
|
+
|
|
225
|
+
/** Return a shallow object copy with its string keys sorted. */
|
|
226
|
+
export function sortObject<T extends Record<string, unknown>>(
|
|
227
|
+
object: T,
|
|
228
|
+
compare?: (firstKey: string, secondKey: string) => number,
|
|
229
|
+
): T {
|
|
230
|
+
const sortedEntries = Object.keys(object)
|
|
231
|
+
.sort(compare)
|
|
232
|
+
.map((key) => [key, object[key]])
|
|
233
|
+
|
|
234
|
+
// Object.fromEntries cannot express that reordering entries preserves T's keys and values.
|
|
235
|
+
return Object.fromEntries(sortedEntries) as T
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Sort object keys alphabetically while pulling `_` matches forward and pushing other prefixes
|
|
240
|
+
* backward in their configured order.
|
|
241
|
+
*/
|
|
242
|
+
export function sortObjectByPrio<T extends Record<string, unknown>>(
|
|
243
|
+
object: T,
|
|
244
|
+
priorities: SortPriorities,
|
|
245
|
+
): T {
|
|
246
|
+
return sortObject(object, (firstKey, secondKey) => {
|
|
247
|
+
let firstSortableKey = firstKey
|
|
248
|
+
let secondSortableKey = secondKey
|
|
249
|
+
|
|
250
|
+
for (const [prefix, matchers] of Object.entries(priorities)) {
|
|
251
|
+
for (const [index, matcher] of matchers.entries()) {
|
|
252
|
+
const modifier = prefix === '_' ? matchers.length - index : index
|
|
253
|
+
const sortablePrefix = prefix.repeat(2 + modifier)
|
|
254
|
+
const matches = (key: string): boolean =>
|
|
255
|
+
matcher instanceof RegExp ? matcher.test(key) : key === matcher
|
|
256
|
+
|
|
257
|
+
if (matches(firstSortableKey)) {
|
|
258
|
+
firstSortableKey = `${sortablePrefix}${firstSortableKey}`
|
|
259
|
+
}
|
|
260
|
+
if (matches(secondSortableKey)) {
|
|
261
|
+
secondSortableKey = `${sortablePrefix}${secondSortableKey}`
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return firstSortableKey.localeCompare(secondSortableKey)
|
|
267
|
+
})
|
|
268
|
+
}
|
|
@@ -529,13 +529,19 @@ export const parseSafeTemplate = (
|
|
|
529
529
|
return [null, safe, indent]
|
|
530
530
|
}
|
|
531
531
|
|
|
532
|
-
|
|
532
|
+
/** Whether the Robot requires input, independent of any declared Step dependencies. */
|
|
533
|
+
export function botNeedsInput(robotName: string, stepName?: string, step?: StepInput): boolean {
|
|
533
534
|
if (robotName.endsWith('/import')) {
|
|
534
535
|
return false
|
|
535
536
|
}
|
|
536
537
|
if (robotName === '/upload/handle') {
|
|
537
538
|
return false
|
|
538
539
|
}
|
|
540
|
+
if (robotName === '/http/request') {
|
|
541
|
+
// Match HttpRequestRobot's no-input mode; interpolated payloads remain conservative.
|
|
542
|
+
const payload = step && 'payload' in step ? step.payload : undefined
|
|
543
|
+
return !(payload == null || payload === 'none' || payload === 'metadata')
|
|
544
|
+
}
|
|
539
545
|
if (robotName === '/html/convert') {
|
|
540
546
|
if (step && 'url' in step && typeof step.url === 'string' && step.url) {
|
|
541
547
|
return false
|
|
@@ -596,6 +602,8 @@ const getFirstStepNameThatDoesNotNeedInputFromSteps = (
|
|
|
596
602
|
step !== null &&
|
|
597
603
|
typeof step.robot === 'string' &&
|
|
598
604
|
!botNeedsInput(step.robot, stepName, step) &&
|
|
605
|
+
// Reuse the SDK's use parser: optional input does not make a dependent Step a root.
|
|
606
|
+
getLastUsedStepName(step) === undefined &&
|
|
599
607
|
!excludeBots.includes(step.robot)
|
|
600
608
|
)
|
|
601
609
|
}) ?? ''
|
|
@@ -821,7 +829,7 @@ export function addFilePreviewRobot(templateContent: string): string {
|
|
|
821
829
|
|
|
822
830
|
// Identify steps and extract width
|
|
823
831
|
for (const [stepName, step] of entries(steps)) {
|
|
824
|
-
if (!botNeedsInput(step.robot)) {
|
|
832
|
+
if (!botNeedsInput(step.robot, stepName, step)) {
|
|
825
833
|
importStepName = stepName
|
|
826
834
|
} else if (['/image/resize', '/video/thumb'].includes(step.robot)) {
|
|
827
835
|
if ('width' in step && (typeof step.width === 'number' || typeof step.width === 'string')) {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
/** Portable copy paired with the publisher's richer glossary rendering. */
|
|
4
|
+
export interface ApiParameterDescriptionSource {
|
|
5
|
+
readonly commonMark: string
|
|
6
|
+
readonly referenceMarkdown: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type ApiParameterDescription = string | ApiParameterDescriptionSource
|
|
10
|
+
|
|
11
|
+
/** Keep useful parameter help without importing API2's translation identity registry. */
|
|
12
|
+
export function describeApiParameter<Schema extends z.ZodTypeAny>(
|
|
13
|
+
_descriptionId: string,
|
|
14
|
+
schema: Schema,
|
|
15
|
+
description: ApiParameterDescription,
|
|
16
|
+
): Schema {
|
|
17
|
+
return schema.describe(typeof description === 'string' ? description : description.commonMark)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Preserve portable help when rebuilding a schema, without publication-only metadata. */
|
|
21
|
+
export function inheritApiParameterDescription<Schema extends z.ZodTypeAny>(
|
|
22
|
+
source: z.ZodTypeAny,
|
|
23
|
+
target: Schema,
|
|
24
|
+
): Schema {
|
|
25
|
+
return source.description === undefined ? target : target.describe(source.description)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Attach available field help while retaining the original shape's types and runtime behavior. */
|
|
29
|
+
export function describeApiParameterFields<Shape extends Record<string, z.ZodTypeAny>>(
|
|
30
|
+
scope: string,
|
|
31
|
+
shape: Shape,
|
|
32
|
+
descriptions: Readonly<Partial<Record<string, ApiParameterDescription>>>,
|
|
33
|
+
): Shape {
|
|
34
|
+
const describedShape = { ...shape }
|
|
35
|
+
for (const field in describedShape) {
|
|
36
|
+
const description = Object.hasOwn(descriptions, field) ? descriptions[field] : undefined
|
|
37
|
+
if (description === undefined) continue
|
|
38
|
+
describedShape[field] = describeApiParameter(scope, describedShape[field], description)
|
|
39
|
+
}
|
|
40
|
+
return describedShape
|
|
41
|
+
}
|