@leonardo-ai/sdk 4.16.0 → 4.17.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 +16 -5
- package/docs/sdks/dataset/README.md +25 -29
- package/docs/sdks/elements/README.md +5 -5
- package/docs/sdks/image/README.md +20 -23
- package/docs/sdks/initimages/README.md +20 -23
- package/docs/sdks/models/README.md +20 -23
- package/docs/sdks/motion/README.md +5 -5
- package/docs/sdks/pricingcalculator/README.md +5 -5
- package/docs/sdks/prompt/README.md +10 -11
- package/docs/sdks/realtimecanvas/README.md +20 -23
- package/docs/sdks/texture/README.md +10 -11
- package/docs/sdks/threedmodelassets/README.md +10 -11
- package/docs/sdks/user/README.md +5 -5
- package/docs/sdks/variation/README.md +25 -29
- package/funcs/datasetCreateDataset.d.ts +1 -1
- package/funcs/datasetCreateDataset.d.ts.map +1 -1
- package/funcs/datasetCreateDataset.js +30 -30
- package/funcs/datasetCreateDataset.js.map +1 -1
- package/funcs/datasetDeleteDatasetById.d.ts +1 -1
- package/funcs/datasetDeleteDatasetById.d.ts.map +1 -1
- package/funcs/datasetDeleteDatasetById.js +32 -32
- package/funcs/datasetDeleteDatasetById.js.map +1 -1
- package/funcs/datasetGetDatasetById.d.ts +1 -1
- package/funcs/datasetGetDatasetById.d.ts.map +1 -1
- package/funcs/datasetGetDatasetById.js +32 -32
- package/funcs/datasetGetDatasetById.js.map +1 -1
- package/funcs/datasetUploadDatasetImage.d.ts +1 -1
- package/funcs/datasetUploadDatasetImage.d.ts.map +1 -1
- package/funcs/datasetUploadDatasetImage.js +32 -32
- package/funcs/datasetUploadDatasetImage.js.map +1 -1
- package/funcs/datasetUploadDatasetImageFromGen.d.ts +1 -1
- package/funcs/datasetUploadDatasetImageFromGen.d.ts.map +1 -1
- package/funcs/datasetUploadDatasetImageFromGen.js +32 -32
- package/funcs/datasetUploadDatasetImageFromGen.js.map +1 -1
- package/funcs/elementsListElements.d.ts +1 -1
- package/funcs/elementsListElements.d.ts.map +1 -1
- package/funcs/elementsListElements.js +22 -22
- package/funcs/elementsListElements.js.map +1 -1
- package/funcs/imageCreateGeneration.d.ts +1 -1
- package/funcs/imageCreateGeneration.d.ts.map +1 -1
- package/funcs/imageCreateGeneration.js +30 -30
- package/funcs/imageCreateGeneration.js.map +1 -1
- package/funcs/imageDeleteGenerationById.d.ts +1 -1
- package/funcs/imageDeleteGenerationById.d.ts.map +1 -1
- package/funcs/imageDeleteGenerationById.js +32 -32
- package/funcs/imageDeleteGenerationById.js.map +1 -1
- package/funcs/imageGetGenerationById.d.ts +1 -1
- package/funcs/imageGetGenerationById.d.ts.map +1 -1
- package/funcs/imageGetGenerationById.js +32 -32
- package/funcs/imageGetGenerationById.js.map +1 -1
- package/funcs/imageGetGenerationsByUserId.d.ts +1 -1
- package/funcs/imageGetGenerationsByUserId.d.ts.map +1 -1
- package/funcs/imageGetGenerationsByUserId.js +36 -36
- package/funcs/imageGetGenerationsByUserId.js.map +1 -1
- package/funcs/initImagesDeleteInitImageById.d.ts +1 -1
- package/funcs/initImagesDeleteInitImageById.d.ts.map +1 -1
- package/funcs/initImagesDeleteInitImageById.js +32 -32
- package/funcs/initImagesDeleteInitImageById.js.map +1 -1
- package/funcs/initImagesGetInitImageById.d.ts +1 -1
- package/funcs/initImagesGetInitImageById.d.ts.map +1 -1
- package/funcs/initImagesGetInitImageById.js +32 -32
- package/funcs/initImagesGetInitImageById.js.map +1 -1
- package/funcs/initImagesUploadCanvasInitImage.d.ts +1 -1
- package/funcs/initImagesUploadCanvasInitImage.d.ts.map +1 -1
- package/funcs/initImagesUploadCanvasInitImage.js +30 -30
- package/funcs/initImagesUploadCanvasInitImage.js.map +1 -1
- package/funcs/initImagesUploadInitImage.d.ts +1 -1
- package/funcs/initImagesUploadInitImage.d.ts.map +1 -1
- package/funcs/initImagesUploadInitImage.js +30 -30
- package/funcs/initImagesUploadInitImage.js.map +1 -1
- package/funcs/modelsCreateModel.d.ts +1 -1
- package/funcs/modelsCreateModel.d.ts.map +1 -1
- package/funcs/modelsCreateModel.js +30 -30
- package/funcs/modelsCreateModel.js.map +1 -1
- package/funcs/modelsDeleteModelById.d.ts +1 -1
- package/funcs/modelsDeleteModelById.d.ts.map +1 -1
- package/funcs/modelsDeleteModelById.js +32 -32
- package/funcs/modelsDeleteModelById.js.map +1 -1
- package/funcs/modelsGetModelById.d.ts +1 -1
- package/funcs/modelsGetModelById.d.ts.map +1 -1
- package/funcs/modelsGetModelById.js +32 -32
- package/funcs/modelsGetModelById.js.map +1 -1
- package/funcs/modelsListPlatformModels.d.ts +1 -1
- package/funcs/modelsListPlatformModels.d.ts.map +1 -1
- package/funcs/modelsListPlatformModels.js +22 -22
- package/funcs/modelsListPlatformModels.js.map +1 -1
- package/funcs/motionCreateSVDMotionGeneration.d.ts +1 -1
- package/funcs/motionCreateSVDMotionGeneration.d.ts.map +1 -1
- package/funcs/motionCreateSVDMotionGeneration.js +32 -32
- package/funcs/motionCreateSVDMotionGeneration.js.map +1 -1
- package/funcs/pricingCalculatorPricingCalculator.d.ts +1 -1
- package/funcs/pricingCalculatorPricingCalculator.d.ts.map +1 -1
- package/funcs/pricingCalculatorPricingCalculator.js +31 -31
- package/funcs/pricingCalculatorPricingCalculator.js.map +1 -1
- package/funcs/promptPromptImprove.d.ts +1 -1
- package/funcs/promptPromptImprove.d.ts.map +1 -1
- package/funcs/promptPromptImprove.js +30 -30
- package/funcs/promptPromptImprove.js.map +1 -1
- package/funcs/promptPromptRandom.d.ts +1 -1
- package/funcs/promptPromptRandom.d.ts.map +1 -1
- package/funcs/promptPromptRandom.js +22 -22
- package/funcs/promptPromptRandom.js.map +1 -1
- package/funcs/realtimeCanvasCreateLCMGeneration.d.ts +1 -1
- package/funcs/realtimeCanvasCreateLCMGeneration.d.ts.map +1 -1
- package/funcs/realtimeCanvasCreateLCMGeneration.js +31 -31
- package/funcs/realtimeCanvasCreateLCMGeneration.js.map +1 -1
- package/funcs/realtimeCanvasPerformAlchemyUpscaleLCM.d.ts +1 -1
- package/funcs/realtimeCanvasPerformAlchemyUpscaleLCM.d.ts.map +1 -1
- package/funcs/realtimeCanvasPerformAlchemyUpscaleLCM.js +32 -32
- package/funcs/realtimeCanvasPerformAlchemyUpscaleLCM.js.map +1 -1
- package/funcs/realtimeCanvasPerformInpaintingLCM.d.ts +1 -1
- package/funcs/realtimeCanvasPerformInpaintingLCM.d.ts.map +1 -1
- package/funcs/realtimeCanvasPerformInpaintingLCM.js +32 -32
- package/funcs/realtimeCanvasPerformInpaintingLCM.js.map +1 -1
- package/funcs/realtimeCanvasPerformInstantRefine.d.ts +1 -1
- package/funcs/realtimeCanvasPerformInstantRefine.d.ts.map +1 -1
- package/funcs/realtimeCanvasPerformInstantRefine.js +32 -32
- package/funcs/realtimeCanvasPerformInstantRefine.js.map +1 -1
- package/funcs/textureCreateTextureGeneration.d.ts +1 -1
- package/funcs/textureCreateTextureGeneration.d.ts.map +1 -1
- package/funcs/textureCreateTextureGeneration.js +32 -32
- package/funcs/textureCreateTextureGeneration.js.map +1 -1
- package/funcs/textureDeleteTextureGenerationById.d.ts +1 -1
- package/funcs/textureDeleteTextureGenerationById.d.ts.map +1 -1
- package/funcs/textureDeleteTextureGenerationById.js +32 -32
- package/funcs/textureDeleteTextureGenerationById.js.map +1 -1
- package/funcs/threeDModelAssetsDelete3DModelById.d.ts +1 -1
- package/funcs/threeDModelAssetsDelete3DModelById.d.ts.map +1 -1
- package/funcs/threeDModelAssetsDelete3DModelById.js +32 -32
- package/funcs/threeDModelAssetsDelete3DModelById.js.map +1 -1
- package/funcs/threeDModelAssetsUploadModelAsset.d.ts +1 -1
- package/funcs/threeDModelAssetsUploadModelAsset.d.ts.map +1 -1
- package/funcs/threeDModelAssetsUploadModelAsset.js +31 -31
- package/funcs/threeDModelAssetsUploadModelAsset.js.map +1 -1
- package/funcs/userGetUserSelf.d.ts +1 -1
- package/funcs/userGetUserSelf.d.ts.map +1 -1
- package/funcs/userGetUserSelf.js +22 -22
- package/funcs/userGetUserSelf.js.map +1 -1
- package/funcs/variationCreateUniversalUpscalerJob.d.ts +1 -1
- package/funcs/variationCreateUniversalUpscalerJob.d.ts.map +1 -1
- package/funcs/variationCreateUniversalUpscalerJob.js +30 -30
- package/funcs/variationCreateUniversalUpscalerJob.js.map +1 -1
- package/funcs/variationCreateVariationNoBG.d.ts +1 -1
- package/funcs/variationCreateVariationNoBG.d.ts.map +1 -1
- package/funcs/variationCreateVariationNoBG.js +30 -30
- package/funcs/variationCreateVariationNoBG.js.map +1 -1
- package/funcs/variationCreateVariationUnzoom.d.ts +1 -1
- package/funcs/variationCreateVariationUnzoom.d.ts.map +1 -1
- package/funcs/variationCreateVariationUnzoom.js +32 -32
- package/funcs/variationCreateVariationUnzoom.js.map +1 -1
- package/funcs/variationCreateVariationUpscale.d.ts +1 -1
- package/funcs/variationCreateVariationUpscale.d.ts.map +1 -1
- package/funcs/variationCreateVariationUpscale.js +32 -32
- package/funcs/variationCreateVariationUpscale.js.map +1 -1
- package/funcs/variationGetVariationById.d.ts +1 -1
- package/funcs/variationGetVariationById.d.ts.map +1 -1
- package/funcs/variationGetVariationById.js +32 -32
- package/funcs/variationGetVariationById.js.map +1 -1
- package/lib/config.d.ts +3 -3
- package/lib/config.js +3 -3
- package/lib/sdks.d.ts +5 -8
- package/lib/sdks.d.ts.map +1 -1
- package/lib/sdks.js +34 -18
- package/lib/sdks.js.map +1 -1
- package/package.json +1 -1
- package/sdk/models/operations/creategeneration.d.ts +2 -2
- package/sdk/sdk.js +13 -13
- package/src/funcs/datasetCreateDataset.ts +34 -35
- package/src/funcs/datasetDeleteDatasetById.ts +36 -37
- package/src/funcs/datasetGetDatasetById.ts +36 -36
- package/src/funcs/datasetUploadDatasetImage.ts +36 -40
- package/src/funcs/datasetUploadDatasetImageFromGen.ts +37 -40
- package/src/funcs/elementsListElements.ts +23 -23
- package/src/funcs/imageCreateGeneration.ts +35 -35
- package/src/funcs/imageDeleteGenerationById.ts +37 -37
- package/src/funcs/imageGetGenerationById.ts +36 -37
- package/src/funcs/imageGetGenerationsByUserId.ts +41 -44
- package/src/funcs/initImagesDeleteInitImageById.ts +37 -37
- package/src/funcs/initImagesGetInitImageById.ts +36 -36
- package/src/funcs/initImagesUploadCanvasInitImage.ts +35 -35
- package/src/funcs/initImagesUploadInitImage.ts +35 -35
- package/src/funcs/modelsCreateModel.ts +34 -34
- package/src/funcs/modelsDeleteModelById.ts +36 -36
- package/src/funcs/modelsGetModelById.ts +36 -36
- package/src/funcs/modelsListPlatformModels.ts +23 -23
- package/src/funcs/motionCreateSVDMotionGeneration.ts +36 -36
- package/src/funcs/pricingCalculatorPricingCalculator.ts +36 -36
- package/src/funcs/promptPromptImprove.ts +34 -35
- package/src/funcs/promptPromptRandom.ts +23 -23
- package/src/funcs/realtimeCanvasCreateLCMGeneration.ts +36 -36
- package/src/funcs/realtimeCanvasPerformAlchemyUpscaleLCM.ts +36 -36
- package/src/funcs/realtimeCanvasPerformInpaintingLCM.ts +36 -36
- package/src/funcs/realtimeCanvasPerformInstantRefine.ts +36 -36
- package/src/funcs/textureCreateTextureGeneration.ts +36 -36
- package/src/funcs/textureDeleteTextureGenerationById.ts +37 -42
- package/src/funcs/threeDModelAssetsDelete3DModelById.ts +36 -40
- package/src/funcs/threeDModelAssetsUploadModelAsset.ts +36 -36
- package/src/funcs/userGetUserSelf.ts +23 -23
- package/src/funcs/variationCreateUniversalUpscalerJob.ts +35 -35
- package/src/funcs/variationCreateVariationNoBG.ts +35 -35
- package/src/funcs/variationCreateVariationUnzoom.ts +36 -36
- package/src/funcs/variationCreateVariationUpscale.ts +36 -36
- package/src/funcs/variationGetVariationById.ts +36 -36
- package/src/lib/config.ts +3 -3
- package/src/lib/sdks.ts +24 -24
- package/src/sdk/models/operations/creategeneration.ts +2 -2
- package/src/sdk/sdk.ts +13 -13
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { LeonardoCore } from "../core.js";
|
|
6
|
-
import { encodeJSON
|
|
7
|
-
import * as
|
|
8
|
-
import
|
|
6
|
+
import { encodeJSON } from "../lib/encodings.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { safeParse } from "../lib/schemas.js";
|
|
9
9
|
import { RequestOptions } from "../lib/sdks.js";
|
|
10
10
|
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
11
11
|
import { pathToFunc } from "../lib/url.js";
|
|
@@ -28,7 +28,7 @@ import { Result } from "../sdk/types/fp.js";
|
|
|
28
28
|
* This endpoint will create an upscale for the provided image ID
|
|
29
29
|
*/
|
|
30
30
|
export async function variationCreateVariationUpscale(
|
|
31
|
-
client
|
|
31
|
+
client: LeonardoCore,
|
|
32
32
|
request?: operations.CreateVariationUpscaleRequestBody | undefined,
|
|
33
33
|
options?: RequestOptions,
|
|
34
34
|
): Promise<
|
|
@@ -43,57 +43,57 @@ export async function variationCreateVariationUpscale(
|
|
|
43
43
|
| ConnectionError
|
|
44
44
|
>
|
|
45
45
|
> {
|
|
46
|
-
const input
|
|
46
|
+
const input = request;
|
|
47
47
|
|
|
48
|
-
const parsed
|
|
49
|
-
input
|
|
50
|
-
(value
|
|
48
|
+
const parsed = safeParse(
|
|
49
|
+
input,
|
|
50
|
+
(value) =>
|
|
51
51
|
operations.CreateVariationUpscaleRequestBody$outboundSchema.optional()
|
|
52
|
-
.parse(value
|
|
52
|
+
.parse(value),
|
|
53
53
|
"Input validation failed",
|
|
54
54
|
);
|
|
55
|
-
if (!parsed
|
|
56
|
-
return parsed
|
|
55
|
+
if (!parsed.ok) {
|
|
56
|
+
return parsed;
|
|
57
57
|
}
|
|
58
|
-
const payload
|
|
59
|
-
const body
|
|
58
|
+
const payload = parsed.value;
|
|
59
|
+
const body = payload === undefined
|
|
60
60
|
? null
|
|
61
|
-
: encodeJSON
|
|
61
|
+
: encodeJSON("body", payload, { explode: true });
|
|
62
62
|
|
|
63
|
-
const path
|
|
63
|
+
const path = pathToFunc("/variations/upscale")();
|
|
64
64
|
|
|
65
|
-
const headers
|
|
65
|
+
const headers = new Headers({
|
|
66
66
|
"Content-Type": "application/json",
|
|
67
67
|
Accept: "application/json",
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
const
|
|
71
|
-
const
|
|
70
|
+
const secConfig = await extractSecurity(client._options.bearerAuth);
|
|
71
|
+
const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
|
|
72
72
|
const context = {
|
|
73
73
|
operationID: "createVariationUpscale",
|
|
74
74
|
oAuth2Scopes: [],
|
|
75
|
-
securitySource: client
|
|
75
|
+
securitySource: client._options.bearerAuth,
|
|
76
76
|
};
|
|
77
|
-
const
|
|
77
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
78
78
|
|
|
79
|
-
const requestRes = client
|
|
80
|
-
security:
|
|
79
|
+
const requestRes = client._createRequest(context, {
|
|
80
|
+
security: requestSecurity,
|
|
81
81
|
method: "POST",
|
|
82
|
-
path: path
|
|
83
|
-
headers: headers
|
|
84
|
-
body: body
|
|
85
|
-
timeoutMs: options?.timeoutMs || client
|
|
82
|
+
path: path,
|
|
83
|
+
headers: headers,
|
|
84
|
+
body: body,
|
|
85
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
86
86
|
}, options);
|
|
87
87
|
if (!requestRes.ok) {
|
|
88
88
|
return requestRes;
|
|
89
89
|
}
|
|
90
|
-
const
|
|
90
|
+
const req = requestRes.value;
|
|
91
91
|
|
|
92
|
-
const doResult = await client
|
|
92
|
+
const doResult = await client._do(req, {
|
|
93
93
|
context,
|
|
94
94
|
errorCodes: [],
|
|
95
95
|
retryConfig: options?.retries
|
|
96
|
-
|| client
|
|
96
|
+
|| client._options.retryConfig,
|
|
97
97
|
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
98
98
|
});
|
|
99
99
|
if (!doResult.ok) {
|
|
@@ -101,7 +101,7 @@ export async function variationCreateVariationUpscale(
|
|
|
101
101
|
}
|
|
102
102
|
const response = doResult.value;
|
|
103
103
|
|
|
104
|
-
const responseFields
|
|
104
|
+
const responseFields = {
|
|
105
105
|
ContentType: response.headers.get("content-type")
|
|
106
106
|
?? "application/octet-stream",
|
|
107
107
|
StatusCode: response.status,
|
|
@@ -109,7 +109,7 @@ export async function variationCreateVariationUpscale(
|
|
|
109
109
|
Headers: {},
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
-
const [result
|
|
112
|
+
const [result] = await M.match<
|
|
113
113
|
operations.CreateVariationUpscaleResponse,
|
|
114
114
|
| SDKError
|
|
115
115
|
| SDKValidationError
|
|
@@ -119,13 +119,13 @@ export async function variationCreateVariationUpscale(
|
|
|
119
119
|
| RequestTimeoutError
|
|
120
120
|
| ConnectionError
|
|
121
121
|
>(
|
|
122
|
-
|
|
122
|
+
M.json(200, operations.CreateVariationUpscaleResponse$inboundSchema, {
|
|
123
123
|
key: "object",
|
|
124
124
|
}),
|
|
125
|
-
)(response, { extraFields: responseFields
|
|
126
|
-
if (!result
|
|
127
|
-
return result
|
|
125
|
+
)(response, { extraFields: responseFields });
|
|
126
|
+
if (!result.ok) {
|
|
127
|
+
return result;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
return result
|
|
130
|
+
return result;
|
|
131
131
|
}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { LeonardoCore } from "../core.js";
|
|
6
|
-
import { encodeSimple
|
|
7
|
-
import * as
|
|
8
|
-
import
|
|
6
|
+
import { encodeSimple } from "../lib/encodings.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { safeParse } from "../lib/schemas.js";
|
|
9
9
|
import { RequestOptions } from "../lib/sdks.js";
|
|
10
10
|
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
11
11
|
import { pathToFunc } from "../lib/url.js";
|
|
@@ -28,7 +28,7 @@ import { Result } from "../sdk/types/fp.js";
|
|
|
28
28
|
* This endpoint will get the variation by ID
|
|
29
29
|
*/
|
|
30
30
|
export async function variationGetVariationById(
|
|
31
|
-
client
|
|
31
|
+
client: LeonardoCore,
|
|
32
32
|
id: string,
|
|
33
33
|
options?: RequestOptions,
|
|
34
34
|
): Promise<
|
|
@@ -43,61 +43,61 @@ export async function variationGetVariationById(
|
|
|
43
43
|
| ConnectionError
|
|
44
44
|
>
|
|
45
45
|
> {
|
|
46
|
-
const input
|
|
46
|
+
const input: operations.GetVariationByIdRequest = {
|
|
47
47
|
id: id,
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
const parsed
|
|
51
|
-
input
|
|
52
|
-
(value
|
|
50
|
+
const parsed = safeParse(
|
|
51
|
+
input,
|
|
52
|
+
(value) => operations.GetVariationByIdRequest$outboundSchema.parse(value),
|
|
53
53
|
"Input validation failed",
|
|
54
54
|
);
|
|
55
|
-
if (!parsed
|
|
56
|
-
return parsed
|
|
55
|
+
if (!parsed.ok) {
|
|
56
|
+
return parsed;
|
|
57
57
|
}
|
|
58
|
-
const payload
|
|
59
|
-
const body
|
|
58
|
+
const payload = parsed.value;
|
|
59
|
+
const body = null;
|
|
60
60
|
|
|
61
|
-
const pathParams
|
|
62
|
-
id: encodeSimple
|
|
61
|
+
const pathParams = {
|
|
62
|
+
id: encodeSimple("id", payload.id, {
|
|
63
63
|
explode: false,
|
|
64
64
|
charEncoding: "percent",
|
|
65
65
|
}),
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
const path
|
|
68
|
+
const path = pathToFunc("/variations/{id}")(pathParams);
|
|
69
69
|
|
|
70
|
-
const headers
|
|
70
|
+
const headers = new Headers({
|
|
71
71
|
Accept: "application/json",
|
|
72
72
|
});
|
|
73
73
|
|
|
74
|
-
const
|
|
75
|
-
const
|
|
74
|
+
const secConfig = await extractSecurity(client._options.bearerAuth);
|
|
75
|
+
const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
|
|
76
76
|
const context = {
|
|
77
77
|
operationID: "getVariationById",
|
|
78
78
|
oAuth2Scopes: [],
|
|
79
|
-
securitySource: client
|
|
79
|
+
securitySource: client._options.bearerAuth,
|
|
80
80
|
};
|
|
81
|
-
const
|
|
81
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
82
82
|
|
|
83
|
-
const requestRes = client
|
|
84
|
-
security:
|
|
83
|
+
const requestRes = client._createRequest(context, {
|
|
84
|
+
security: requestSecurity,
|
|
85
85
|
method: "GET",
|
|
86
|
-
path: path
|
|
87
|
-
headers: headers
|
|
88
|
-
body: body
|
|
89
|
-
timeoutMs: options?.timeoutMs || client
|
|
86
|
+
path: path,
|
|
87
|
+
headers: headers,
|
|
88
|
+
body: body,
|
|
89
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
90
90
|
}, options);
|
|
91
91
|
if (!requestRes.ok) {
|
|
92
92
|
return requestRes;
|
|
93
93
|
}
|
|
94
|
-
const
|
|
94
|
+
const req = requestRes.value;
|
|
95
95
|
|
|
96
|
-
const doResult = await client
|
|
96
|
+
const doResult = await client._do(req, {
|
|
97
97
|
context,
|
|
98
98
|
errorCodes: [],
|
|
99
99
|
retryConfig: options?.retries
|
|
100
|
-
|| client
|
|
100
|
+
|| client._options.retryConfig,
|
|
101
101
|
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
102
102
|
});
|
|
103
103
|
if (!doResult.ok) {
|
|
@@ -105,7 +105,7 @@ export async function variationGetVariationById(
|
|
|
105
105
|
}
|
|
106
106
|
const response = doResult.value;
|
|
107
107
|
|
|
108
|
-
const responseFields
|
|
108
|
+
const responseFields = {
|
|
109
109
|
ContentType: response.headers.get("content-type")
|
|
110
110
|
?? "application/octet-stream",
|
|
111
111
|
StatusCode: response.status,
|
|
@@ -113,7 +113,7 @@ export async function variationGetVariationById(
|
|
|
113
113
|
Headers: {},
|
|
114
114
|
};
|
|
115
115
|
|
|
116
|
-
const [result
|
|
116
|
+
const [result] = await M.match<
|
|
117
117
|
operations.GetVariationByIdResponse,
|
|
118
118
|
| SDKError
|
|
119
119
|
| SDKValidationError
|
|
@@ -123,13 +123,13 @@ export async function variationGetVariationById(
|
|
|
123
123
|
| RequestTimeoutError
|
|
124
124
|
| ConnectionError
|
|
125
125
|
>(
|
|
126
|
-
|
|
126
|
+
M.json(200, operations.GetVariationByIdResponse$inboundSchema, {
|
|
127
127
|
key: "object",
|
|
128
128
|
}),
|
|
129
|
-
)(response, { extraFields: responseFields
|
|
130
|
-
if (!result
|
|
131
|
-
return result
|
|
129
|
+
)(response, { extraFields: responseFields });
|
|
130
|
+
if (!result.ok) {
|
|
131
|
+
return result;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
return result
|
|
134
|
+
return result;
|
|
135
135
|
}
|
package/src/lib/config.ts
CHANGED
|
@@ -57,7 +57,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
|
57
57
|
export const SDK_METADATA = {
|
|
58
58
|
language: "typescript",
|
|
59
59
|
openapiDocVersion: "v1.0.0",
|
|
60
|
-
sdkVersion: "4.
|
|
61
|
-
genVersion: "2.
|
|
62
|
-
userAgent: "speakeasy-sdk/typescript 4.
|
|
60
|
+
sdkVersion: "4.17.0",
|
|
61
|
+
genVersion: "2.428.1",
|
|
62
|
+
userAgent: "speakeasy-sdk/typescript 4.17.0 2.428.1 v1.0.0 @leonardo-ai/sdk",
|
|
63
63
|
} as const;
|
package/src/lib/sdks.ts
CHANGED
|
@@ -71,11 +71,11 @@ const isBrowserLike = webWorkerLike
|
|
|
71
71
|
|| (typeof window === "object" && typeof window.document !== "undefined");
|
|
72
72
|
|
|
73
73
|
export class ClientSDK {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
protected readonly
|
|
78
|
-
public readonly
|
|
74
|
+
readonly #httpClient: HTTPClient;
|
|
75
|
+
readonly #hooks: SDKHooks;
|
|
76
|
+
readonly #logger?: Logger | undefined;
|
|
77
|
+
protected readonly _baseURL: URL | null;
|
|
78
|
+
public readonly _options: SDKOptions & { hooks?: SDKHooks };
|
|
79
79
|
|
|
80
80
|
constructor(options: SDKOptions = {}) {
|
|
81
81
|
const opt = options as unknown;
|
|
@@ -85,33 +85,33 @@ export class ClientSDK {
|
|
|
85
85
|
&& "hooks" in opt
|
|
86
86
|
&& opt.hooks instanceof SDKHooks
|
|
87
87
|
) {
|
|
88
|
-
this
|
|
88
|
+
this.#hooks = opt.hooks;
|
|
89
89
|
} else {
|
|
90
|
-
this
|
|
90
|
+
this.#hooks = new SDKHooks();
|
|
91
91
|
}
|
|
92
|
-
this.
|
|
92
|
+
this._options = { ...options, hooks: this.#hooks };
|
|
93
93
|
|
|
94
94
|
const url = serverURLFromOptions(options);
|
|
95
95
|
if (url) {
|
|
96
96
|
url.pathname = url.pathname.replace(/\/+$/, "") + "/";
|
|
97
97
|
}
|
|
98
|
-
const { baseURL, client } = this.
|
|
98
|
+
const { baseURL, client } = this.#hooks.sdkInit({
|
|
99
99
|
baseURL: url,
|
|
100
100
|
client: options.httpClient || new HTTPClient(),
|
|
101
101
|
});
|
|
102
|
-
this.
|
|
103
|
-
this
|
|
104
|
-
this
|
|
102
|
+
this._baseURL = baseURL;
|
|
103
|
+
this.#httpClient = client;
|
|
104
|
+
this.#logger = options.debugLogger;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
public
|
|
107
|
+
public _createRequest(
|
|
108
108
|
context: HookContext,
|
|
109
109
|
conf: RequestConfig,
|
|
110
110
|
options?: RequestOptions,
|
|
111
111
|
): Result<Request, InvalidRequestError | UnexpectedClientError> {
|
|
112
112
|
const { method, path, query, headers: opHeaders, security } = conf;
|
|
113
113
|
|
|
114
|
-
const base = conf.baseURL ?? this.
|
|
114
|
+
const base = conf.baseURL ?? this._baseURL;
|
|
115
115
|
if (!base) {
|
|
116
116
|
return ERR(new InvalidRequestError("No base URL provided for operation"));
|
|
117
117
|
}
|
|
@@ -195,7 +195,7 @@ export class ClientSDK {
|
|
|
195
195
|
|
|
196
196
|
let input;
|
|
197
197
|
try {
|
|
198
|
-
input = this.
|
|
198
|
+
input = this.#hooks.beforeCreateRequest(context, {
|
|
199
199
|
url: reqURL,
|
|
200
200
|
options: {
|
|
201
201
|
...fetchOptions,
|
|
@@ -215,7 +215,7 @@ export class ClientSDK {
|
|
|
215
215
|
return OK(new Request(input.url, input.options));
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
public async
|
|
218
|
+
public async _do(
|
|
219
219
|
request: Request,
|
|
220
220
|
options: {
|
|
221
221
|
context: HookContext;
|
|
@@ -238,25 +238,25 @@ export class ClientSDK {
|
|
|
238
238
|
|
|
239
239
|
return retry(
|
|
240
240
|
async () => {
|
|
241
|
-
const req = await this.
|
|
242
|
-
await logRequest(this
|
|
243
|
-
this
|
|
241
|
+
const req = await this.#hooks.beforeRequest(context, request.clone());
|
|
242
|
+
await logRequest(this.#logger, req).catch((e) =>
|
|
243
|
+
this.#logger?.log("Failed to log request:", e)
|
|
244
244
|
);
|
|
245
245
|
|
|
246
|
-
let response = await this
|
|
246
|
+
let response = await this.#httpClient.request(req);
|
|
247
247
|
|
|
248
248
|
if (matchStatusCode(response, errorCodes)) {
|
|
249
|
-
const result = await this.
|
|
249
|
+
const result = await this.#hooks.afterError(context, response, null);
|
|
250
250
|
if (result.error) {
|
|
251
251
|
throw result.error;
|
|
252
252
|
}
|
|
253
253
|
response = result.response || response;
|
|
254
254
|
} else {
|
|
255
|
-
response = await this.
|
|
255
|
+
response = await this.#hooks.afterSuccess(context, response);
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
-
await logResponse(this
|
|
259
|
-
.catch(e => this
|
|
258
|
+
await logResponse(this.#logger, response, req)
|
|
259
|
+
.catch(e => this.#logger?.log("Failed to log response:", e));
|
|
260
260
|
|
|
261
261
|
return response;
|
|
262
262
|
},
|
|
@@ -69,7 +69,7 @@ export type CreateGenerationRequestBody = {
|
|
|
69
69
|
*/
|
|
70
70
|
guidanceScale?: number | null | undefined;
|
|
71
71
|
/**
|
|
72
|
-
* The input height of the images. Must be between 32 and
|
|
72
|
+
* The input height of the images. Must be between 32 and 1536 and be a multiple of 8. Note: Input resolution is not always the same as output resolution due to upscaling from other features.
|
|
73
73
|
*/
|
|
74
74
|
height?: number | null | undefined;
|
|
75
75
|
/**
|
|
@@ -186,7 +186,7 @@ export type CreateGenerationRequestBody = {
|
|
|
186
186
|
*/
|
|
187
187
|
weighting?: number | null | undefined;
|
|
188
188
|
/**
|
|
189
|
-
* The input width of the images. Must be between 32 and
|
|
189
|
+
* The input width of the images. Must be between 32 and 1536 and be a multiple of 8. Note: Input resolution is not always the same as output resolution due to upscaling from other features.
|
|
190
190
|
*/
|
|
191
191
|
width?: number | null | undefined;
|
|
192
192
|
};
|
package/src/sdk/sdk.ts
CHANGED
|
@@ -20,66 +20,66 @@ import { Variation } from "./variation.js";
|
|
|
20
20
|
export class Leonardo extends ClientSDK {
|
|
21
21
|
private _initImages?: InitImages;
|
|
22
22
|
get initImages(): InitImages {
|
|
23
|
-
return (this._initImages ??= new InitImages(this.
|
|
23
|
+
return (this._initImages ??= new InitImages(this._options));
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
private _dataset?: Dataset;
|
|
27
27
|
get dataset(): Dataset {
|
|
28
|
-
return (this._dataset ??= new Dataset(this.
|
|
28
|
+
return (this._dataset ??= new Dataset(this._options));
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
private _elements?: Elements;
|
|
32
32
|
get elements(): Elements {
|
|
33
|
-
return (this._elements ??= new Elements(this.
|
|
33
|
+
return (this._elements ??= new Elements(this._options));
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
private _image?: Image;
|
|
37
37
|
get image(): Image {
|
|
38
|
-
return (this._image ??= new Image(this.
|
|
38
|
+
return (this._image ??= new Image(this._options));
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
private _realtimeCanvas?: RealtimeCanvas;
|
|
42
42
|
get realtimeCanvas(): RealtimeCanvas {
|
|
43
|
-
return (this._realtimeCanvas ??= new RealtimeCanvas(this.
|
|
43
|
+
return (this._realtimeCanvas ??= new RealtimeCanvas(this._options));
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
private _motion?: Motion;
|
|
47
47
|
get motion(): Motion {
|
|
48
|
-
return (this._motion ??= new Motion(this.
|
|
48
|
+
return (this._motion ??= new Motion(this._options));
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
private _texture?: Texture;
|
|
52
52
|
get texture(): Texture {
|
|
53
|
-
return (this._texture ??= new Texture(this.
|
|
53
|
+
return (this._texture ??= new Texture(this._options));
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
private _user?: User;
|
|
57
57
|
get user(): User {
|
|
58
|
-
return (this._user ??= new User(this.
|
|
58
|
+
return (this._user ??= new User(this._options));
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
private _models?: Models;
|
|
62
62
|
get models(): Models {
|
|
63
|
-
return (this._models ??= new Models(this.
|
|
63
|
+
return (this._models ??= new Models(this._options));
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
private _threeDModelAssets?: ThreeDModelAssets;
|
|
67
67
|
get threeDModelAssets(): ThreeDModelAssets {
|
|
68
|
-
return (this._threeDModelAssets ??= new ThreeDModelAssets(this.
|
|
68
|
+
return (this._threeDModelAssets ??= new ThreeDModelAssets(this._options));
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
private _pricingCalculator?: PricingCalculator;
|
|
72
72
|
get pricingCalculator(): PricingCalculator {
|
|
73
|
-
return (this._pricingCalculator ??= new PricingCalculator(this.
|
|
73
|
+
return (this._pricingCalculator ??= new PricingCalculator(this._options));
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
private _prompt?: Prompt;
|
|
77
77
|
get prompt(): Prompt {
|
|
78
|
-
return (this._prompt ??= new Prompt(this.
|
|
78
|
+
return (this._prompt ??= new Prompt(this._options));
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
private _variation?: Variation;
|
|
82
82
|
get variation(): Variation {
|
|
83
|
-
return (this._variation ??= new Variation(this.
|
|
83
|
+
return (this._variation ??= new Variation(this._options));
|
|
84
84
|
}
|
|
85
85
|
}
|