@leonardo-ai/sdk 4.14.2 → 4.15.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 +104 -7
- package/core.d.ts +10 -0
- package/core.d.ts.map +1 -0
- package/core.js +17 -0
- package/core.js.map +1 -0
- package/docs/sdks/dataset/README.md +169 -7
- package/docs/sdks/elements/README.md +33 -1
- package/docs/sdks/image/README.md +132 -7
- package/docs/sdks/initimages/README.md +136 -6
- package/docs/sdks/leonardo/README.md +1 -5
- package/docs/sdks/models/README.md +135 -6
- package/docs/sdks/motion/README.md +34 -4
- package/docs/sdks/pricingcalculator/README.md +34 -2
- package/docs/sdks/prompt/README.md +67 -2
- package/docs/sdks/realtimecanvas/README.md +133 -21
- package/docs/sdks/texture/README.md +67 -4
- package/docs/sdks/threedmodelassets/README.md +67 -4
- package/docs/sdks/user/README.md +33 -1
- package/docs/sdks/variation/README.md +166 -10
- package/funcs/datasetCreateDataset.d.ts +15 -0
- package/funcs/datasetCreateDataset.d.ts.map +1 -0
- package/funcs/datasetCreateDataset.js +101 -0
- package/funcs/datasetCreateDataset.js.map +1 -0
- package/funcs/datasetDeleteDatasetById.d.ts +15 -0
- package/funcs/datasetDeleteDatasetById.d.ts.map +1 -0
- package/funcs/datasetDeleteDatasetById.js +103 -0
- package/funcs/datasetDeleteDatasetById.js.map +1 -0
- package/funcs/datasetGetDatasetById.d.ts +15 -0
- package/funcs/datasetGetDatasetById.d.ts.map +1 -0
- package/funcs/datasetGetDatasetById.js +105 -0
- package/funcs/datasetGetDatasetById.js.map +1 -0
- package/funcs/datasetUploadDatasetImage.d.ts +15 -0
- package/funcs/datasetUploadDatasetImage.d.ts.map +1 -0
- package/funcs/datasetUploadDatasetImage.js +108 -0
- package/funcs/datasetUploadDatasetImage.js.map +1 -0
- package/funcs/datasetUploadDatasetImageFromGen.d.ts +15 -0
- package/funcs/datasetUploadDatasetImageFromGen.d.ts.map +1 -0
- package/funcs/datasetUploadDatasetImageFromGen.js +108 -0
- package/funcs/datasetUploadDatasetImageFromGen.js.map +1 -0
- package/funcs/elementsListElements.d.ts +15 -0
- package/funcs/elementsListElements.d.ts.map +1 -0
- package/funcs/elementsListElements.js +90 -0
- package/funcs/elementsListElements.js.map +1 -0
- package/funcs/imageCreateGeneration.d.ts +15 -0
- package/funcs/imageCreateGeneration.d.ts.map +1 -0
- package/funcs/imageCreateGeneration.js +99 -0
- package/funcs/imageCreateGeneration.js.map +1 -0
- package/funcs/imageDeleteGenerationById.d.ts +15 -0
- package/funcs/imageDeleteGenerationById.d.ts.map +1 -0
- package/funcs/imageDeleteGenerationById.js +103 -0
- package/funcs/imageDeleteGenerationById.js.map +1 -0
- package/funcs/imageGetGenerationById.d.ts +15 -0
- package/funcs/imageGetGenerationById.d.ts.map +1 -0
- package/funcs/imageGetGenerationById.js +103 -0
- package/funcs/imageGetGenerationById.js.map +1 -0
- package/funcs/imageGetGenerationsByUserId.d.ts +15 -0
- package/funcs/imageGetGenerationsByUserId.d.ts.map +1 -0
- package/funcs/imageGetGenerationsByUserId.js +113 -0
- package/funcs/imageGetGenerationsByUserId.js.map +1 -0
- package/funcs/initImagesDeleteInitImageById.d.ts +15 -0
- package/funcs/initImagesDeleteInitImageById.d.ts.map +1 -0
- package/funcs/initImagesDeleteInitImageById.js +103 -0
- package/funcs/initImagesDeleteInitImageById.js.map +1 -0
- package/funcs/initImagesGetInitImageById.d.ts +15 -0
- package/funcs/initImagesGetInitImageById.d.ts.map +1 -0
- package/funcs/initImagesGetInitImageById.js +103 -0
- package/funcs/initImagesGetInitImageById.js.map +1 -0
- package/funcs/initImagesUploadCanvasInitImage.d.ts +15 -0
- package/funcs/initImagesUploadCanvasInitImage.d.ts.map +1 -0
- package/funcs/initImagesUploadCanvasInitImage.js +99 -0
- package/funcs/initImagesUploadCanvasInitImage.js.map +1 -0
- package/funcs/initImagesUploadInitImage.d.ts +15 -0
- package/funcs/initImagesUploadInitImage.d.ts.map +1 -0
- package/funcs/initImagesUploadInitImage.js +101 -0
- package/funcs/initImagesUploadInitImage.js.map +1 -0
- package/funcs/modelsCreateModel.d.ts +15 -0
- package/funcs/modelsCreateModel.d.ts.map +1 -0
- package/funcs/modelsCreateModel.js +101 -0
- package/funcs/modelsCreateModel.js.map +1 -0
- package/funcs/modelsDeleteModelById.d.ts +15 -0
- package/funcs/modelsDeleteModelById.d.ts.map +1 -0
- package/funcs/modelsDeleteModelById.js +105 -0
- package/funcs/modelsDeleteModelById.js.map +1 -0
- package/funcs/modelsGetModelById.d.ts +15 -0
- package/funcs/modelsGetModelById.d.ts.map +1 -0
- package/funcs/modelsGetModelById.js +105 -0
- package/funcs/modelsGetModelById.js.map +1 -0
- package/funcs/modelsListPlatformModels.d.ts +15 -0
- package/funcs/modelsListPlatformModels.d.ts.map +1 -0
- package/funcs/modelsListPlatformModels.js +88 -0
- package/funcs/modelsListPlatformModels.js.map +1 -0
- package/funcs/motionCreateSVDMotionGeneration.d.ts +15 -0
- package/funcs/motionCreateSVDMotionGeneration.d.ts.map +1 -0
- package/funcs/motionCreateSVDMotionGeneration.js +99 -0
- package/funcs/motionCreateSVDMotionGeneration.js.map +1 -0
- package/funcs/pricingCalculatorPricingCalculator.d.ts +15 -0
- package/funcs/pricingCalculatorPricingCalculator.d.ts.map +1 -0
- package/funcs/pricingCalculatorPricingCalculator.js +99 -0
- package/funcs/pricingCalculatorPricingCalculator.js.map +1 -0
- package/funcs/promptPromptImprove.d.ts +15 -0
- package/funcs/promptPromptImprove.d.ts.map +1 -0
- package/funcs/promptPromptImprove.js +101 -0
- package/funcs/promptPromptImprove.js.map +1 -0
- package/funcs/promptPromptRandom.d.ts +15 -0
- package/funcs/promptPromptRandom.d.ts.map +1 -0
- package/funcs/promptPromptRandom.js +90 -0
- package/funcs/promptPromptRandom.js.map +1 -0
- package/funcs/realtimeCanvasCreateLCMGeneration.d.ts +15 -0
- package/funcs/realtimeCanvasCreateLCMGeneration.d.ts.map +1 -0
- package/funcs/realtimeCanvasCreateLCMGeneration.js +99 -0
- package/funcs/realtimeCanvasCreateLCMGeneration.js.map +1 -0
- package/funcs/realtimeCanvasPerformAlchemyUpscaleLCM.d.ts +15 -0
- package/funcs/realtimeCanvasPerformAlchemyUpscaleLCM.d.ts.map +1 -0
- package/funcs/realtimeCanvasPerformAlchemyUpscaleLCM.js +99 -0
- package/funcs/realtimeCanvasPerformAlchemyUpscaleLCM.js.map +1 -0
- package/funcs/realtimeCanvasPerformInpaintingLCM.d.ts +15 -0
- package/funcs/realtimeCanvasPerformInpaintingLCM.d.ts.map +1 -0
- package/funcs/realtimeCanvasPerformInpaintingLCM.js +99 -0
- package/funcs/realtimeCanvasPerformInpaintingLCM.js.map +1 -0
- package/funcs/realtimeCanvasPerformInstantRefine.d.ts +15 -0
- package/funcs/realtimeCanvasPerformInstantRefine.d.ts.map +1 -0
- package/funcs/realtimeCanvasPerformInstantRefine.js +99 -0
- package/funcs/realtimeCanvasPerformInstantRefine.js.map +1 -0
- package/funcs/textureCreateTextureGeneration.d.ts +15 -0
- package/funcs/textureCreateTextureGeneration.d.ts.map +1 -0
- package/funcs/textureCreateTextureGeneration.js +99 -0
- package/funcs/textureCreateTextureGeneration.js.map +1 -0
- package/funcs/textureDeleteTextureGenerationById.d.ts +15 -0
- package/funcs/textureDeleteTextureGenerationById.d.ts.map +1 -0
- package/funcs/textureDeleteTextureGenerationById.js +107 -0
- package/funcs/textureDeleteTextureGenerationById.js.map +1 -0
- package/funcs/threeDModelAssetsDelete3DModelById.d.ts +15 -0
- package/funcs/threeDModelAssetsDelete3DModelById.d.ts.map +1 -0
- package/funcs/threeDModelAssetsDelete3DModelById.js +105 -0
- package/funcs/threeDModelAssetsDelete3DModelById.js.map +1 -0
- package/funcs/threeDModelAssetsUploadModelAsset.d.ts +15 -0
- package/funcs/threeDModelAssetsUploadModelAsset.d.ts.map +1 -0
- package/funcs/threeDModelAssetsUploadModelAsset.js +99 -0
- package/funcs/threeDModelAssetsUploadModelAsset.js.map +1 -0
- package/funcs/userGetUserSelf.d.ts +15 -0
- package/funcs/userGetUserSelf.d.ts.map +1 -0
- package/funcs/userGetUserSelf.js +90 -0
- package/funcs/userGetUserSelf.js.map +1 -0
- package/funcs/variationCreateUniversalUpscalerJob.d.ts +15 -0
- package/funcs/variationCreateUniversalUpscalerJob.d.ts.map +1 -0
- package/funcs/variationCreateUniversalUpscalerJob.js +99 -0
- package/funcs/variationCreateUniversalUpscalerJob.js.map +1 -0
- package/funcs/variationCreateVariationNoBG.d.ts +15 -0
- package/funcs/variationCreateVariationNoBG.d.ts.map +1 -0
- package/funcs/variationCreateVariationNoBG.js +99 -0
- package/funcs/variationCreateVariationNoBG.js.map +1 -0
- package/funcs/variationCreateVariationUnzoom.d.ts +15 -0
- package/funcs/variationCreateVariationUnzoom.d.ts.map +1 -0
- package/funcs/variationCreateVariationUnzoom.js +99 -0
- package/funcs/variationCreateVariationUnzoom.js.map +1 -0
- package/funcs/variationCreateVariationUpscale.d.ts +15 -0
- package/funcs/variationCreateVariationUpscale.d.ts.map +1 -0
- package/funcs/variationCreateVariationUpscale.js +99 -0
- package/funcs/variationCreateVariationUpscale.js.map +1 -0
- package/funcs/variationGetVariationById.d.ts +15 -0
- package/funcs/variationGetVariationById.d.ts.map +1 -0
- package/funcs/variationGetVariationById.js +103 -0
- package/funcs/variationGetVariationById.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +14 -0
- package/index.js.map +1 -1
- package/lib/config.d.ts +5 -3
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +3 -3
- package/lib/config.js.map +1 -1
- package/lib/dlv.d.ts +14 -0
- package/lib/dlv.d.ts.map +1 -0
- package/lib/dlv.js +50 -0
- package/lib/dlv.js.map +1 -0
- package/lib/files.d.ts +12 -0
- package/lib/files.d.ts.map +1 -0
- package/lib/files.js +52 -0
- package/lib/files.js.map +1 -0
- package/lib/http.d.ts +11 -52
- package/lib/http.d.ts.map +1 -1
- package/lib/http.js +49 -173
- package/lib/http.js.map +1 -1
- package/lib/logger.d.ts +6 -0
- package/lib/logger.d.ts.map +1 -0
- package/lib/logger.js +6 -0
- package/lib/logger.js.map +1 -0
- package/lib/matchers.d.ts +64 -0
- package/lib/matchers.d.ts.map +1 -0
- package/lib/matchers.js +206 -0
- package/lib/matchers.js.map +1 -0
- package/lib/retries.d.ts.map +1 -1
- package/lib/retries.js +2 -28
- package/lib/retries.js.map +1 -1
- package/lib/schemas.d.ts +8 -0
- package/lib/schemas.d.ts.map +1 -1
- package/lib/schemas.js +16 -1
- package/lib/schemas.js.map +1 -1
- package/lib/sdks.d.ts +14 -16
- package/lib/sdks.d.ts.map +1 -1
- package/lib/sdks.js +144 -27
- package/lib/sdks.js.map +1 -1
- package/lib/security.d.ts +7 -1
- package/lib/security.d.ts.map +1 -1
- package/lib/security.js +13 -1
- package/lib/security.js.map +1 -1
- package/package.json +2 -1
- package/sdk/dataset.d.ts +0 -3
- package/sdk/dataset.d.ts.map +1 -1
- package/sdk/dataset.js +11 -332
- package/sdk/dataset.js.map +1 -1
- package/sdk/elements.d.ts +0 -3
- package/sdk/elements.d.ts.map +1 -1
- package/sdk/elements.js +3 -93
- package/sdk/elements.js.map +1 -1
- package/sdk/image.d.ts +0 -3
- package/sdk/image.d.ts.map +1 -1
- package/sdk/image.js +9 -273
- package/sdk/image.js.map +1 -1
- package/sdk/initimages.d.ts +0 -3
- package/sdk/initimages.d.ts.map +1 -1
- package/sdk/initimages.js +9 -261
- package/sdk/initimages.js.map +1 -1
- package/sdk/models/errors/httpclienterrors.d.ts +44 -0
- package/sdk/models/errors/httpclienterrors.d.ts.map +1 -0
- package/sdk/models/errors/httpclienterrors.js +78 -0
- package/sdk/models/errors/httpclienterrors.js.map +1 -0
- package/sdk/models/errors/index.d.ts +1 -0
- package/sdk/models/errors/index.d.ts.map +1 -1
- package/sdk/models/errors/index.js +1 -0
- package/sdk/models/errors/index.js.map +1 -1
- package/sdk/models/errors/sdkvalidationerror.d.ts +4 -1
- package/sdk/models/errors/sdkvalidationerror.d.ts.map +1 -1
- package/sdk/models/errors/sdkvalidationerror.js +3 -5
- package/sdk/models/errors/sdkvalidationerror.js.map +1 -1
- package/sdk/models/operations/pricingcalculator.d.ts +5 -0
- package/sdk/models/operations/pricingcalculator.d.ts.map +1 -1
- package/sdk/models/operations/pricingcalculator.js +2 -0
- package/sdk/models/operations/pricingcalculator.js.map +1 -1
- package/sdk/models.d.ts +0 -3
- package/sdk/models.d.ts.map +1 -1
- package/sdk/models.js +9 -256
- package/sdk/models.js.map +1 -1
- package/sdk/motion.d.ts +0 -3
- package/sdk/motion.d.ts.map +1 -1
- package/sdk/motion.js +3 -102
- package/sdk/motion.js.map +1 -1
- package/sdk/pricingcalculator.d.ts +0 -3
- package/sdk/pricingcalculator.d.ts.map +1 -1
- package/sdk/pricingcalculator.js +3 -100
- package/sdk/pricingcalculator.js.map +1 -1
- package/sdk/prompt.d.ts +0 -3
- package/sdk/prompt.d.ts.map +1 -1
- package/sdk/prompt.js +5 -146
- package/sdk/prompt.js.map +1 -1
- package/sdk/realtimecanvas.d.ts +0 -3
- package/sdk/realtimecanvas.d.ts.map +1 -1
- package/sdk/realtimecanvas.js +9 -253
- package/sdk/realtimecanvas.js.map +1 -1
- package/sdk/sdk.d.ts +0 -3
- package/sdk/sdk.d.ts.map +1 -1
- package/sdk/sdk.js +0 -23
- package/sdk/sdk.js.map +1 -1
- package/sdk/texture.d.ts +0 -3
- package/sdk/texture.d.ts.map +1 -1
- package/sdk/texture.js +5 -159
- package/sdk/texture.js.map +1 -1
- package/sdk/threedmodelassets.d.ts +0 -3
- package/sdk/threedmodelassets.d.ts.map +1 -1
- package/sdk/threedmodelassets.js +5 -157
- package/sdk/threedmodelassets.js.map +1 -1
- package/sdk/types/constdatetime.d.ts +3 -0
- package/sdk/types/constdatetime.d.ts.map +1 -0
- package/sdk/types/constdatetime.js +37 -0
- package/sdk/types/constdatetime.js.map +1 -0
- package/sdk/types/fp.d.ts +31 -0
- package/sdk/types/fp.d.ts.map +1 -0
- package/sdk/types/fp.js +38 -0
- package/sdk/types/fp.js.map +1 -0
- package/sdk/types/index.d.ts +1 -0
- package/sdk/types/index.d.ts.map +1 -1
- package/sdk/types/operations.d.ts +22 -8
- package/sdk/types/operations.d.ts.map +1 -1
- package/sdk/types/operations.js +64 -2
- package/sdk/types/operations.js.map +1 -1
- package/sdk/types/streams.d.ts +2 -0
- package/sdk/types/streams.d.ts.map +1 -0
- package/sdk/types/streams.js +19 -0
- package/sdk/types/streams.js.map +1 -0
- package/sdk/user.d.ts +0 -3
- package/sdk/user.d.ts.map +1 -1
- package/sdk/user.js +3 -93
- package/sdk/user.js.map +1 -1
- package/sdk/variation.d.ts +0 -3
- package/sdk/variation.d.ts.map +1 -1
- package/sdk/variation.js +11 -310
- package/sdk/variation.js.map +1 -1
- package/src/core.ts +13 -0
- package/src/funcs/datasetCreateDataset.ts +127 -0
- package/src/funcs/datasetDeleteDatasetById.ts +133 -0
- package/src/funcs/datasetGetDatasetById.ts +132 -0
- package/src/funcs/datasetUploadDatasetImage.ts +139 -0
- package/src/funcs/datasetUploadDatasetImageFromGen.ts +139 -0
- package/src/funcs/elementsListElements.ts +109 -0
- package/src/funcs/imageCreateGeneration.ts +128 -0
- package/src/funcs/imageDeleteGenerationById.ts +133 -0
- package/src/funcs/imageGetGenerationById.ts +133 -0
- package/src/funcs/imageGetGenerationsByUserId.ts +149 -0
- package/src/funcs/initImagesDeleteInitImageById.ts +133 -0
- package/src/funcs/initImagesGetInitImageById.ts +133 -0
- package/src/funcs/initImagesUploadCanvasInitImage.ts +128 -0
- package/src/funcs/initImagesUploadInitImage.ts +127 -0
- package/src/funcs/modelsCreateModel.ts +127 -0
- package/src/funcs/modelsDeleteModelById.ts +132 -0
- package/src/funcs/modelsGetModelById.ts +132 -0
- package/src/funcs/modelsListPlatformModels.ts +110 -0
- package/src/funcs/motionCreateSVDMotionGeneration.ts +129 -0
- package/src/funcs/pricingCalculatorPricingCalculator.ts +128 -0
- package/src/funcs/promptPromptImprove.ts +127 -0
- package/src/funcs/promptPromptRandom.ts +109 -0
- package/src/funcs/realtimeCanvasCreateLCMGeneration.ts +129 -0
- package/src/funcs/realtimeCanvasPerformAlchemyUpscaleLCM.ts +129 -0
- package/src/funcs/realtimeCanvasPerformInpaintingLCM.ts +129 -0
- package/src/funcs/realtimeCanvasPerformInstantRefine.ts +129 -0
- package/src/funcs/textureCreateTextureGeneration.ts +129 -0
- package/src/funcs/textureDeleteTextureGenerationById.ts +137 -0
- package/src/funcs/threeDModelAssetsDelete3DModelById.ts +136 -0
- package/src/funcs/threeDModelAssetsUploadModelAsset.ts +128 -0
- package/src/funcs/userGetUserSelf.ts +109 -0
- package/src/funcs/variationCreateUniversalUpscalerJob.ts +128 -0
- package/src/funcs/variationCreateVariationNoBG.ts +128 -0
- package/src/funcs/variationCreateVariationUnzoom.ts +129 -0
- package/src/funcs/variationCreateVariationUpscale.ts +129 -0
- package/src/funcs/variationGetVariationById.ts +133 -0
- package/src/index.ts +1 -0
- package/src/lib/config.ts +5 -3
- package/src/lib/dlv.ts +53 -0
- package/src/lib/files.ts +58 -0
- package/src/lib/http.ts +255 -438
- package/src/lib/logger.ts +9 -0
- package/src/lib/matchers.ts +305 -0
- package/src/lib/retries.ts +2 -41
- package/src/lib/schemas.ts +18 -0
- package/src/lib/sdks.ts +194 -35
- package/src/lib/security.ts +22 -1
- package/src/sdk/dataset.ts +11 -389
- package/src/sdk/elements.ts +3 -84
- package/src/sdk/image.ts +9 -319
- package/src/sdk/initimages.ts +9 -303
- package/src/sdk/models/errors/httpclienterrors.ts +62 -0
- package/src/sdk/models/errors/index.ts +1 -0
- package/src/sdk/models/errors/sdkvalidationerror.ts +8 -6
- package/src/sdk/models/operations/pricingcalculator.ts +7 -0
- package/src/sdk/models.ts +9 -292
- package/src/sdk/motion.ts +3 -103
- package/src/sdk/pricingcalculator.ts +3 -99
- package/src/sdk/prompt.ts +5 -152
- package/src/sdk/realtimecanvas.ts +9 -305
- package/src/sdk/sdk.ts +0 -29
- package/src/sdk/texture.ts +5 -175
- package/src/sdk/threedmodelassets.ts +5 -171
- package/src/sdk/types/constdatetime.ts +15 -0
- package/src/sdk/types/fp.ts +50 -0
- package/src/sdk/types/index.ts +1 -0
- package/src/sdk/types/operations.ts +81 -7
- package/src/sdk/types/streams.ts +21 -0
- package/src/sdk/user.ts +3 -84
- package/src/sdk/variation.ts +11 -374
package/src/sdk/texture.ts
CHANGED
|
@@ -2,41 +2,13 @@
|
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { encodeJSON as encodeJSON$, encodeSimple as encodeSimple$ } from "../lib/encodings.js";
|
|
8
|
-
import { HTTPClient } from "../lib/http.js";
|
|
9
|
-
import * as schemas$ from "../lib/schemas.js";
|
|
5
|
+
import { textureCreateTextureGeneration } from "../funcs/textureCreateTextureGeneration.js";
|
|
6
|
+
import { textureDeleteTextureGenerationById } from "../funcs/textureDeleteTextureGenerationById.js";
|
|
10
7
|
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
|
|
11
8
|
import * as operations from "./models/operations/index.js";
|
|
9
|
+
import { unwrapAsync } from "./types/fp.js";
|
|
12
10
|
|
|
13
11
|
export class Texture extends ClientSDK {
|
|
14
|
-
private readonly options$: SDKOptions & { hooks?: SDKHooks };
|
|
15
|
-
|
|
16
|
-
constructor(options: SDKOptions = {}) {
|
|
17
|
-
const opt = options as unknown;
|
|
18
|
-
let hooks: SDKHooks;
|
|
19
|
-
if (
|
|
20
|
-
typeof opt === "object" &&
|
|
21
|
-
opt != null &&
|
|
22
|
-
"hooks" in opt &&
|
|
23
|
-
opt.hooks instanceof SDKHooks
|
|
24
|
-
) {
|
|
25
|
-
hooks = opt.hooks;
|
|
26
|
-
} else {
|
|
27
|
-
hooks = new SDKHooks();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
super({
|
|
31
|
-
client: options.httpClient || new HTTPClient(),
|
|
32
|
-
baseURL: serverURLFromOptions(options),
|
|
33
|
-
hooks,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
this.options$ = { ...options, hooks };
|
|
37
|
-
void this.options$;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
12
|
/**
|
|
41
13
|
* Create Texture Generation
|
|
42
14
|
*
|
|
@@ -47,76 +19,7 @@ export class Texture extends ClientSDK {
|
|
|
47
19
|
request?: operations.CreateTextureGenerationRequestBody | undefined,
|
|
48
20
|
options?: RequestOptions
|
|
49
21
|
): Promise<operations.CreateTextureGenerationResponse> {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const payload$ = schemas$.parse(
|
|
53
|
-
input$,
|
|
54
|
-
(value$) =>
|
|
55
|
-
operations.CreateTextureGenerationRequestBody$outboundSchema.optional().parse(
|
|
56
|
-
value$
|
|
57
|
-
),
|
|
58
|
-
"Input validation failed"
|
|
59
|
-
);
|
|
60
|
-
const body$ =
|
|
61
|
-
payload$ === undefined ? null : encodeJSON$("body", payload$, { explode: true });
|
|
62
|
-
|
|
63
|
-
const path$ = this.templateURLComponent("/generations-texture")();
|
|
64
|
-
|
|
65
|
-
const query$ = "";
|
|
66
|
-
|
|
67
|
-
const headers$ = new Headers({
|
|
68
|
-
"Content-Type": "application/json",
|
|
69
|
-
Accept: "application/json",
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
let security$;
|
|
73
|
-
if (typeof this.options$.bearerAuth === "function") {
|
|
74
|
-
security$ = { bearerAuth: await this.options$.bearerAuth() };
|
|
75
|
-
} else if (this.options$.bearerAuth) {
|
|
76
|
-
security$ = { bearerAuth: this.options$.bearerAuth };
|
|
77
|
-
} else {
|
|
78
|
-
security$ = {};
|
|
79
|
-
}
|
|
80
|
-
const context = {
|
|
81
|
-
operationID: "createTextureGeneration",
|
|
82
|
-
oAuth2Scopes: [],
|
|
83
|
-
securitySource: this.options$.bearerAuth,
|
|
84
|
-
};
|
|
85
|
-
const securitySettings$ = this.resolveGlobalSecurity(security$);
|
|
86
|
-
|
|
87
|
-
const request$ = this.createRequest$(
|
|
88
|
-
context,
|
|
89
|
-
{
|
|
90
|
-
security: securitySettings$,
|
|
91
|
-
method: "POST",
|
|
92
|
-
path: path$,
|
|
93
|
-
headers: headers$,
|
|
94
|
-
query: query$,
|
|
95
|
-
body: body$,
|
|
96
|
-
timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1,
|
|
97
|
-
},
|
|
98
|
-
options
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
const response = await this.do$(request$, {
|
|
102
|
-
context,
|
|
103
|
-
errorCodes: [],
|
|
104
|
-
retryConfig: options?.retries || this.options$.retryConfig,
|
|
105
|
-
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
const responseFields$ = {
|
|
109
|
-
ContentType: response.headers.get("content-type") ?? "application/octet-stream",
|
|
110
|
-
StatusCode: response.status,
|
|
111
|
-
RawResponse: response,
|
|
112
|
-
Headers: {},
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const [result$] = await this.matcher<operations.CreateTextureGenerationResponse>()
|
|
116
|
-
.json(200, operations.CreateTextureGenerationResponse$inboundSchema, { key: "object" })
|
|
117
|
-
.match(response, { extraFields: responseFields$ });
|
|
118
|
-
|
|
119
|
-
return result$;
|
|
22
|
+
return unwrapAsync(textureCreateTextureGeneration(this, request, options));
|
|
120
23
|
}
|
|
121
24
|
|
|
122
25
|
/**
|
|
@@ -130,79 +33,6 @@ export class Texture extends ClientSDK {
|
|
|
130
33
|
requestBody?: operations.DeleteTextureGenerationByIdRequestBody | undefined,
|
|
131
34
|
options?: RequestOptions
|
|
132
35
|
): Promise<operations.DeleteTextureGenerationByIdResponse> {
|
|
133
|
-
|
|
134
|
-
requestBody: requestBody,
|
|
135
|
-
id: id,
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
const payload$ = schemas$.parse(
|
|
139
|
-
input$,
|
|
140
|
-
(value$) => operations.DeleteTextureGenerationByIdRequest$outboundSchema.parse(value$),
|
|
141
|
-
"Input validation failed"
|
|
142
|
-
);
|
|
143
|
-
const body$ = encodeJSON$("body", payload$.RequestBody, { explode: true });
|
|
144
|
-
|
|
145
|
-
const pathParams$ = {
|
|
146
|
-
id: encodeSimple$("id", payload$.id, { explode: false, charEncoding: "percent" }),
|
|
147
|
-
};
|
|
148
|
-
const path$ = this.templateURLComponent("/generations-texture/{id}")(pathParams$);
|
|
149
|
-
|
|
150
|
-
const query$ = "";
|
|
151
|
-
|
|
152
|
-
const headers$ = new Headers({
|
|
153
|
-
"Content-Type": "application/json",
|
|
154
|
-
Accept: "application/json",
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
let security$;
|
|
158
|
-
if (typeof this.options$.bearerAuth === "function") {
|
|
159
|
-
security$ = { bearerAuth: await this.options$.bearerAuth() };
|
|
160
|
-
} else if (this.options$.bearerAuth) {
|
|
161
|
-
security$ = { bearerAuth: this.options$.bearerAuth };
|
|
162
|
-
} else {
|
|
163
|
-
security$ = {};
|
|
164
|
-
}
|
|
165
|
-
const context = {
|
|
166
|
-
operationID: "deleteTextureGenerationById",
|
|
167
|
-
oAuth2Scopes: [],
|
|
168
|
-
securitySource: this.options$.bearerAuth,
|
|
169
|
-
};
|
|
170
|
-
const securitySettings$ = this.resolveGlobalSecurity(security$);
|
|
171
|
-
|
|
172
|
-
const request$ = this.createRequest$(
|
|
173
|
-
context,
|
|
174
|
-
{
|
|
175
|
-
security: securitySettings$,
|
|
176
|
-
method: "DELETE",
|
|
177
|
-
path: path$,
|
|
178
|
-
headers: headers$,
|
|
179
|
-
query: query$,
|
|
180
|
-
body: body$,
|
|
181
|
-
timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1,
|
|
182
|
-
},
|
|
183
|
-
options
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
const response = await this.do$(request$, {
|
|
187
|
-
context,
|
|
188
|
-
errorCodes: [],
|
|
189
|
-
retryConfig: options?.retries || this.options$.retryConfig,
|
|
190
|
-
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
const responseFields$ = {
|
|
194
|
-
ContentType: response.headers.get("content-type") ?? "application/octet-stream",
|
|
195
|
-
StatusCode: response.status,
|
|
196
|
-
RawResponse: response,
|
|
197
|
-
Headers: {},
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
const [result$] = await this.matcher<operations.DeleteTextureGenerationByIdResponse>()
|
|
201
|
-
.json(200, operations.DeleteTextureGenerationByIdResponse$inboundSchema, {
|
|
202
|
-
key: "object",
|
|
203
|
-
})
|
|
204
|
-
.match(response, { extraFields: responseFields$ });
|
|
205
|
-
|
|
206
|
-
return result$;
|
|
36
|
+
return unwrapAsync(textureDeleteTextureGenerationById(this, id, requestBody, options));
|
|
207
37
|
}
|
|
208
38
|
}
|
|
@@ -2,41 +2,13 @@
|
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { encodeJSON as encodeJSON$, encodeSimple as encodeSimple$ } from "../lib/encodings.js";
|
|
8
|
-
import { HTTPClient } from "../lib/http.js";
|
|
9
|
-
import * as schemas$ from "../lib/schemas.js";
|
|
5
|
+
import { threeDModelAssetsDelete3DModelById } from "../funcs/threeDModelAssetsDelete3DModelById.js";
|
|
6
|
+
import { threeDModelAssetsUploadModelAsset } from "../funcs/threeDModelAssetsUploadModelAsset.js";
|
|
10
7
|
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
|
|
11
8
|
import * as operations from "./models/operations/index.js";
|
|
9
|
+
import { unwrapAsync } from "./types/fp.js";
|
|
12
10
|
|
|
13
11
|
export class ThreeDModelAssets extends ClientSDK {
|
|
14
|
-
private readonly options$: SDKOptions & { hooks?: SDKHooks };
|
|
15
|
-
|
|
16
|
-
constructor(options: SDKOptions = {}) {
|
|
17
|
-
const opt = options as unknown;
|
|
18
|
-
let hooks: SDKHooks;
|
|
19
|
-
if (
|
|
20
|
-
typeof opt === "object" &&
|
|
21
|
-
opt != null &&
|
|
22
|
-
"hooks" in opt &&
|
|
23
|
-
opt.hooks instanceof SDKHooks
|
|
24
|
-
) {
|
|
25
|
-
hooks = opt.hooks;
|
|
26
|
-
} else {
|
|
27
|
-
hooks = new SDKHooks();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
super({
|
|
31
|
-
client: options.httpClient || new HTTPClient(),
|
|
32
|
-
baseURL: serverURLFromOptions(options),
|
|
33
|
-
hooks,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
this.options$ = { ...options, hooks };
|
|
37
|
-
void this.options$;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
12
|
/**
|
|
41
13
|
* Delete 3D Model by ID
|
|
42
14
|
*
|
|
@@ -48,78 +20,7 @@ export class ThreeDModelAssets extends ClientSDK {
|
|
|
48
20
|
requestBody?: operations.Delete3DModelByIdRequestBody | undefined,
|
|
49
21
|
options?: RequestOptions
|
|
50
22
|
): Promise<operations.Delete3DModelByIdResponse> {
|
|
51
|
-
|
|
52
|
-
requestBody: requestBody,
|
|
53
|
-
id: id,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const payload$ = schemas$.parse(
|
|
57
|
-
input$,
|
|
58
|
-
(value$) => operations.Delete3DModelByIdRequest$outboundSchema.parse(value$),
|
|
59
|
-
"Input validation failed"
|
|
60
|
-
);
|
|
61
|
-
const body$ = encodeJSON$("body", payload$.RequestBody, { explode: true });
|
|
62
|
-
|
|
63
|
-
const pathParams$ = {
|
|
64
|
-
id: encodeSimple$("id", payload$.id, { explode: false, charEncoding: "percent" }),
|
|
65
|
-
};
|
|
66
|
-
const path$ = this.templateURLComponent("/models-3d/{id}")(pathParams$);
|
|
67
|
-
|
|
68
|
-
const query$ = "";
|
|
69
|
-
|
|
70
|
-
const headers$ = new Headers({
|
|
71
|
-
"Content-Type": "application/json",
|
|
72
|
-
Accept: "application/json",
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
let security$;
|
|
76
|
-
if (typeof this.options$.bearerAuth === "function") {
|
|
77
|
-
security$ = { bearerAuth: await this.options$.bearerAuth() };
|
|
78
|
-
} else if (this.options$.bearerAuth) {
|
|
79
|
-
security$ = { bearerAuth: this.options$.bearerAuth };
|
|
80
|
-
} else {
|
|
81
|
-
security$ = {};
|
|
82
|
-
}
|
|
83
|
-
const context = {
|
|
84
|
-
operationID: "delete3DModelById",
|
|
85
|
-
oAuth2Scopes: [],
|
|
86
|
-
securitySource: this.options$.bearerAuth,
|
|
87
|
-
};
|
|
88
|
-
const securitySettings$ = this.resolveGlobalSecurity(security$);
|
|
89
|
-
|
|
90
|
-
const request$ = this.createRequest$(
|
|
91
|
-
context,
|
|
92
|
-
{
|
|
93
|
-
security: securitySettings$,
|
|
94
|
-
method: "DELETE",
|
|
95
|
-
path: path$,
|
|
96
|
-
headers: headers$,
|
|
97
|
-
query: query$,
|
|
98
|
-
body: body$,
|
|
99
|
-
timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1,
|
|
100
|
-
},
|
|
101
|
-
options
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
const response = await this.do$(request$, {
|
|
105
|
-
context,
|
|
106
|
-
errorCodes: [],
|
|
107
|
-
retryConfig: options?.retries || this.options$.retryConfig,
|
|
108
|
-
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
const responseFields$ = {
|
|
112
|
-
ContentType: response.headers.get("content-type") ?? "application/octet-stream",
|
|
113
|
-
StatusCode: response.status,
|
|
114
|
-
RawResponse: response,
|
|
115
|
-
Headers: {},
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const [result$] = await this.matcher<operations.Delete3DModelByIdResponse>()
|
|
119
|
-
.json(200, operations.Delete3DModelByIdResponse$inboundSchema, { key: "object" })
|
|
120
|
-
.match(response, { extraFields: responseFields$ });
|
|
121
|
-
|
|
122
|
-
return result$;
|
|
23
|
+
return unwrapAsync(threeDModelAssetsDelete3DModelById(this, id, requestBody, options));
|
|
123
24
|
}
|
|
124
25
|
|
|
125
26
|
/**
|
|
@@ -132,73 +33,6 @@ export class ThreeDModelAssets extends ClientSDK {
|
|
|
132
33
|
request?: operations.UploadModelAssetRequestBody | undefined,
|
|
133
34
|
options?: RequestOptions
|
|
134
35
|
): Promise<operations.UploadModelAssetResponse> {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const payload$ = schemas$.parse(
|
|
138
|
-
input$,
|
|
139
|
-
(value$) =>
|
|
140
|
-
operations.UploadModelAssetRequestBody$outboundSchema.optional().parse(value$),
|
|
141
|
-
"Input validation failed"
|
|
142
|
-
);
|
|
143
|
-
const body$ =
|
|
144
|
-
payload$ === undefined ? null : encodeJSON$("body", payload$, { explode: true });
|
|
145
|
-
|
|
146
|
-
const path$ = this.templateURLComponent("/models-3d/upload")();
|
|
147
|
-
|
|
148
|
-
const query$ = "";
|
|
149
|
-
|
|
150
|
-
const headers$ = new Headers({
|
|
151
|
-
"Content-Type": "application/json",
|
|
152
|
-
Accept: "application/json",
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
let security$;
|
|
156
|
-
if (typeof this.options$.bearerAuth === "function") {
|
|
157
|
-
security$ = { bearerAuth: await this.options$.bearerAuth() };
|
|
158
|
-
} else if (this.options$.bearerAuth) {
|
|
159
|
-
security$ = { bearerAuth: this.options$.bearerAuth };
|
|
160
|
-
} else {
|
|
161
|
-
security$ = {};
|
|
162
|
-
}
|
|
163
|
-
const context = {
|
|
164
|
-
operationID: "uploadModelAsset",
|
|
165
|
-
oAuth2Scopes: [],
|
|
166
|
-
securitySource: this.options$.bearerAuth,
|
|
167
|
-
};
|
|
168
|
-
const securitySettings$ = this.resolveGlobalSecurity(security$);
|
|
169
|
-
|
|
170
|
-
const request$ = this.createRequest$(
|
|
171
|
-
context,
|
|
172
|
-
{
|
|
173
|
-
security: securitySettings$,
|
|
174
|
-
method: "POST",
|
|
175
|
-
path: path$,
|
|
176
|
-
headers: headers$,
|
|
177
|
-
query: query$,
|
|
178
|
-
body: body$,
|
|
179
|
-
timeoutMs: options?.timeoutMs || this.options$.timeoutMs || -1,
|
|
180
|
-
},
|
|
181
|
-
options
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
const response = await this.do$(request$, {
|
|
185
|
-
context,
|
|
186
|
-
errorCodes: [],
|
|
187
|
-
retryConfig: options?.retries || this.options$.retryConfig,
|
|
188
|
-
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
const responseFields$ = {
|
|
192
|
-
ContentType: response.headers.get("content-type") ?? "application/octet-stream",
|
|
193
|
-
StatusCode: response.status,
|
|
194
|
-
RawResponse: response,
|
|
195
|
-
Headers: {},
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
const [result$] = await this.matcher<operations.UploadModelAssetResponse>()
|
|
199
|
-
.json(200, operations.UploadModelAssetResponse$inboundSchema, { key: "object" })
|
|
200
|
-
.match(response, { extraFields: responseFields$ });
|
|
201
|
-
|
|
202
|
-
return result$;
|
|
36
|
+
return unwrapAsync(threeDModelAssetsUploadModelAsset(this, request, options));
|
|
203
37
|
}
|
|
204
38
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
|
|
7
|
+
export function constDateTime(
|
|
8
|
+
val: string,
|
|
9
|
+
): z.ZodType<string, z.ZodTypeDef, unknown> {
|
|
10
|
+
return z.custom<string>((v) => {
|
|
11
|
+
return (
|
|
12
|
+
typeof v === "string" && new Date(v).getTime() === new Date(val).getTime()
|
|
13
|
+
);
|
|
14
|
+
}, `Value must be equivelant to ${val}`);
|
|
15
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A monad that captures the result of a function call or an error if it was not
|
|
7
|
+
* successful. Railway programming, enabled by this type, can be a nicer
|
|
8
|
+
* alternative to traditional exception throwing because it allows functions to
|
|
9
|
+
* declare all _known_ errors with static types and then check for them
|
|
10
|
+
* exhaustively in application code. Thrown exception have a type of `unknown`
|
|
11
|
+
* and break out of regular control flow of programs making them harder to
|
|
12
|
+
* inspect and more verbose work with due to try-catch blocks.
|
|
13
|
+
*/
|
|
14
|
+
export type Result<T, E = unknown> =
|
|
15
|
+
| { ok: true; value: T; error?: never }
|
|
16
|
+
| { ok: false; value?: never; error: E };
|
|
17
|
+
|
|
18
|
+
export function OK<V>(value: V): Result<V, never> {
|
|
19
|
+
return { ok: true, value };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function ERR<E>(error: E): Result<never, E> {
|
|
23
|
+
return { ok: false, error };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* unwrap is a convenience function for extracting a value from a result or
|
|
28
|
+
* throwing if there was an error.
|
|
29
|
+
*/
|
|
30
|
+
export function unwrap<T>(r: Result<T, unknown>): T {
|
|
31
|
+
if (!r.ok) {
|
|
32
|
+
throw r.error;
|
|
33
|
+
}
|
|
34
|
+
return r.value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* unwrapAsync is a convenience function for resolving a value from a Promise
|
|
39
|
+
* of a result or rejecting if an error occurred.
|
|
40
|
+
*/
|
|
41
|
+
export async function unwrapAsync<T>(
|
|
42
|
+
pr: Promise<Result<T, unknown>>,
|
|
43
|
+
): Promise<T> {
|
|
44
|
+
const r = await pr;
|
|
45
|
+
if (!r.ok) {
|
|
46
|
+
throw r.error;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return r.value;
|
|
50
|
+
}
|
package/src/sdk/types/index.ts
CHANGED
|
@@ -8,3 +8,4 @@ export type { Paginator, PageIterator } from "./operations.js";
|
|
|
8
8
|
export { createPageIterator } from "./operations.js";
|
|
9
9
|
export { catchUnrecognizedEnum } from "./enums.js";
|
|
10
10
|
export type { OpenEnum, ClosedEnum, Unrecognized } from "./enums.js";
|
|
11
|
+
export type { Result } from "./fp.js";
|
|
@@ -2,24 +2,98 @@
|
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import { Result } from "./fp.js";
|
|
6
6
|
|
|
7
|
-
export type
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export type Paginator<V> = () => Promise<V & { next: Paginator<V> }> | null;
|
|
8
|
+
|
|
9
|
+
export type PageIterator<V> = V & {
|
|
10
|
+
next: Paginator<V>;
|
|
11
|
+
[Symbol.asyncIterator]: () => AsyncIterableIterator<V>;
|
|
10
12
|
};
|
|
11
13
|
|
|
12
|
-
export function createPageIterator<
|
|
13
|
-
page:
|
|
14
|
-
|
|
14
|
+
export function createPageIterator<V>(
|
|
15
|
+
page: V & { next: Paginator<V> },
|
|
16
|
+
halt: (v: V) => boolean,
|
|
17
|
+
): {
|
|
18
|
+
[Symbol.asyncIterator]: () => AsyncIterableIterator<V>;
|
|
19
|
+
} {
|
|
15
20
|
return {
|
|
16
21
|
[Symbol.asyncIterator]: async function* paginator() {
|
|
17
22
|
yield page;
|
|
23
|
+
if (halt(page)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
18
26
|
|
|
19
27
|
let p: typeof page | null = page;
|
|
20
28
|
for (p = await p.next(); p != null; p = await p.next()) {
|
|
21
29
|
yield p;
|
|
30
|
+
if (halt(p)) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
22
33
|
}
|
|
23
34
|
},
|
|
24
35
|
};
|
|
25
36
|
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* This utility create a special iterator that yields a single value and
|
|
40
|
+
* terminates. It is useful in paginated SDK functions that have early return
|
|
41
|
+
* paths when things go wrong.
|
|
42
|
+
*/
|
|
43
|
+
export function haltIterator<V extends object>(v: V): PageIterator<V> {
|
|
44
|
+
return {
|
|
45
|
+
...v,
|
|
46
|
+
next: () => null,
|
|
47
|
+
[Symbol.asyncIterator]: async function* paginator() {
|
|
48
|
+
yield v;
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Converts an async iterator of `Result<V, E>` into an async iterator of `V`.
|
|
55
|
+
* When error results occur, the underlying error value is thrown.
|
|
56
|
+
*/
|
|
57
|
+
export async function unwrapResultIterator<V>(
|
|
58
|
+
iteratorPromise: Promise<PageIterator<Result<V, unknown>>>,
|
|
59
|
+
): Promise<PageIterator<V>> {
|
|
60
|
+
const resultIter = await iteratorPromise;
|
|
61
|
+
|
|
62
|
+
if (!resultIter.ok) {
|
|
63
|
+
throw resultIter.error;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
...resultIter.value,
|
|
68
|
+
next: unwrapPaginator(resultIter.next),
|
|
69
|
+
[Symbol.asyncIterator]: async function* paginator() {
|
|
70
|
+
for await (const page of resultIter) {
|
|
71
|
+
if (!page.ok) {
|
|
72
|
+
throw page.error;
|
|
73
|
+
}
|
|
74
|
+
yield page.value;
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function unwrapPaginator<V>(
|
|
81
|
+
paginator: Paginator<Result<V, unknown>>,
|
|
82
|
+
): Paginator<V> {
|
|
83
|
+
return () => {
|
|
84
|
+
const nextResult = paginator();
|
|
85
|
+
if (nextResult == null) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
return nextResult.then((res) => {
|
|
89
|
+
if (!res.ok) {
|
|
90
|
+
throw res.error;
|
|
91
|
+
}
|
|
92
|
+
const out = {
|
|
93
|
+
...res.value,
|
|
94
|
+
next: unwrapPaginator(res.next),
|
|
95
|
+
};
|
|
96
|
+
return out;
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export function isReadableStream<T = Uint8Array>(
|
|
6
|
+
val: unknown,
|
|
7
|
+
): val is ReadableStream<T> {
|
|
8
|
+
if (typeof val !== "object" || val === null) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Check for the presence of methods specific to ReadableStream
|
|
13
|
+
const stream = val as ReadableStream<Uint8Array>;
|
|
14
|
+
|
|
15
|
+
// ReadableStream has methods like getReader, cancel, and tee
|
|
16
|
+
return (
|
|
17
|
+
typeof stream.getReader === "function" &&
|
|
18
|
+
typeof stream.cancel === "function" &&
|
|
19
|
+
typeof stream.tee === "function"
|
|
20
|
+
);
|
|
21
|
+
}
|