@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 { 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 return a single init image
|
|
29
29
|
*/
|
|
30
30
|
export async function initImagesGetInitImageById(
|
|
31
|
-
client
|
|
31
|
+
client: LeonardoCore,
|
|
32
32
|
id: string,
|
|
33
33
|
options?: RequestOptions,
|
|
34
34
|
): Promise<
|
|
@@ -43,61 +43,61 @@ export async function initImagesGetInitImageById(
|
|
|
43
43
|
| ConnectionError
|
|
44
44
|
>
|
|
45
45
|
> {
|
|
46
|
-
const input
|
|
46
|
+
const input: operations.GetInitImageByIdRequest = {
|
|
47
47
|
id: id,
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
const parsed
|
|
51
|
-
input
|
|
52
|
-
(value
|
|
50
|
+
const parsed = safeParse(
|
|
51
|
+
input,
|
|
52
|
+
(value) => operations.GetInitImageByIdRequest$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("/init-image/{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: "getInitImageById",
|
|
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 initImagesGetInitImageById(
|
|
|
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 initImagesGetInitImageById(
|
|
|
113
113
|
Headers: {},
|
|
114
114
|
};
|
|
115
115
|
|
|
116
|
-
const [result
|
|
116
|
+
const [result] = await M.match<
|
|
117
117
|
operations.GetInitImageByIdResponse,
|
|
118
118
|
| SDKError
|
|
119
119
|
| SDKValidationError
|
|
@@ -123,13 +123,13 @@ export async function initImagesGetInitImageById(
|
|
|
123
123
|
| RequestTimeoutError
|
|
124
124
|
| ConnectionError
|
|
125
125
|
>(
|
|
126
|
-
|
|
126
|
+
M.json(200, operations.GetInitImageByIdResponse$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
|
}
|
|
@@ -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 returns presigned details to upload an init image and a mask image to S3
|
|
29
29
|
*/
|
|
30
30
|
export async function initImagesUploadCanvasInitImage(
|
|
31
|
-
client
|
|
31
|
+
client: LeonardoCore,
|
|
32
32
|
request: operations.UploadCanvasInitImageRequestBody,
|
|
33
33
|
options?: RequestOptions,
|
|
34
34
|
): Promise<
|
|
@@ -43,54 +43,54 @@ export async function initImagesUploadCanvasInitImage(
|
|
|
43
43
|
| ConnectionError
|
|
44
44
|
>
|
|
45
45
|
> {
|
|
46
|
-
const input
|
|
46
|
+
const input = request;
|
|
47
47
|
|
|
48
|
-
const parsed
|
|
49
|
-
input
|
|
50
|
-
(value
|
|
51
|
-
operations.UploadCanvasInitImageRequestBody$outboundSchema.parse(value
|
|
48
|
+
const parsed = safeParse(
|
|
49
|
+
input,
|
|
50
|
+
(value) =>
|
|
51
|
+
operations.UploadCanvasInitImageRequestBody$outboundSchema.parse(value),
|
|
52
52
|
"Input validation failed",
|
|
53
53
|
);
|
|
54
|
-
if (!parsed
|
|
55
|
-
return parsed
|
|
54
|
+
if (!parsed.ok) {
|
|
55
|
+
return parsed;
|
|
56
56
|
}
|
|
57
|
-
const payload
|
|
58
|
-
const body
|
|
57
|
+
const payload = parsed.value;
|
|
58
|
+
const body = encodeJSON("body", payload, { explode: true });
|
|
59
59
|
|
|
60
|
-
const path
|
|
60
|
+
const path = pathToFunc("/canvas-init-image")();
|
|
61
61
|
|
|
62
|
-
const headers
|
|
62
|
+
const headers = new Headers({
|
|
63
63
|
"Content-Type": "application/json",
|
|
64
64
|
Accept: "application/json",
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
const
|
|
68
|
-
const
|
|
67
|
+
const secConfig = await extractSecurity(client._options.bearerAuth);
|
|
68
|
+
const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
|
|
69
69
|
const context = {
|
|
70
70
|
operationID: "uploadCanvasInitImage",
|
|
71
71
|
oAuth2Scopes: [],
|
|
72
|
-
securitySource: client
|
|
72
|
+
securitySource: client._options.bearerAuth,
|
|
73
73
|
};
|
|
74
|
-
const
|
|
74
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
75
75
|
|
|
76
|
-
const requestRes = client
|
|
77
|
-
security:
|
|
76
|
+
const requestRes = client._createRequest(context, {
|
|
77
|
+
security: requestSecurity,
|
|
78
78
|
method: "POST",
|
|
79
|
-
path: path
|
|
80
|
-
headers: headers
|
|
81
|
-
body: body
|
|
82
|
-
timeoutMs: options?.timeoutMs || client
|
|
79
|
+
path: path,
|
|
80
|
+
headers: headers,
|
|
81
|
+
body: body,
|
|
82
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
83
83
|
}, options);
|
|
84
84
|
if (!requestRes.ok) {
|
|
85
85
|
return requestRes;
|
|
86
86
|
}
|
|
87
|
-
const
|
|
87
|
+
const req = requestRes.value;
|
|
88
88
|
|
|
89
|
-
const doResult = await client
|
|
89
|
+
const doResult = await client._do(req, {
|
|
90
90
|
context,
|
|
91
91
|
errorCodes: [],
|
|
92
92
|
retryConfig: options?.retries
|
|
93
|
-
|| client
|
|
93
|
+
|| client._options.retryConfig,
|
|
94
94
|
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
95
95
|
});
|
|
96
96
|
if (!doResult.ok) {
|
|
@@ -98,7 +98,7 @@ export async function initImagesUploadCanvasInitImage(
|
|
|
98
98
|
}
|
|
99
99
|
const response = doResult.value;
|
|
100
100
|
|
|
101
|
-
const responseFields
|
|
101
|
+
const responseFields = {
|
|
102
102
|
ContentType: response.headers.get("content-type")
|
|
103
103
|
?? "application/octet-stream",
|
|
104
104
|
StatusCode: response.status,
|
|
@@ -106,7 +106,7 @@ export async function initImagesUploadCanvasInitImage(
|
|
|
106
106
|
Headers: {},
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
const [result
|
|
109
|
+
const [result] = await M.match<
|
|
110
110
|
operations.UploadCanvasInitImageResponse,
|
|
111
111
|
| SDKError
|
|
112
112
|
| SDKValidationError
|
|
@@ -116,13 +116,13 @@ export async function initImagesUploadCanvasInitImage(
|
|
|
116
116
|
| RequestTimeoutError
|
|
117
117
|
| ConnectionError
|
|
118
118
|
>(
|
|
119
|
-
|
|
119
|
+
M.json(200, operations.UploadCanvasInitImageResponse$inboundSchema, {
|
|
120
120
|
key: "object",
|
|
121
121
|
}),
|
|
122
|
-
)(response, { extraFields: responseFields
|
|
123
|
-
if (!result
|
|
124
|
-
return result
|
|
122
|
+
)(response, { extraFields: responseFields });
|
|
123
|
+
if (!result.ok) {
|
|
124
|
+
return result;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
return result
|
|
127
|
+
return result;
|
|
128
128
|
}
|
|
@@ -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 returns presigned details to upload an init image to S3
|
|
29
29
|
*/
|
|
30
30
|
export async function initImagesUploadInitImage(
|
|
31
|
-
client
|
|
31
|
+
client: LeonardoCore,
|
|
32
32
|
request: operations.UploadInitImageRequestBody,
|
|
33
33
|
options?: RequestOptions,
|
|
34
34
|
): Promise<
|
|
@@ -43,54 +43,54 @@ export async function initImagesUploadInitImage(
|
|
|
43
43
|
| ConnectionError
|
|
44
44
|
>
|
|
45
45
|
> {
|
|
46
|
-
const input
|
|
46
|
+
const input = request;
|
|
47
47
|
|
|
48
|
-
const parsed
|
|
49
|
-
input
|
|
50
|
-
(value
|
|
51
|
-
operations.UploadInitImageRequestBody$outboundSchema.parse(value
|
|
48
|
+
const parsed = safeParse(
|
|
49
|
+
input,
|
|
50
|
+
(value) =>
|
|
51
|
+
operations.UploadInitImageRequestBody$outboundSchema.parse(value),
|
|
52
52
|
"Input validation failed",
|
|
53
53
|
);
|
|
54
|
-
if (!parsed
|
|
55
|
-
return parsed
|
|
54
|
+
if (!parsed.ok) {
|
|
55
|
+
return parsed;
|
|
56
56
|
}
|
|
57
|
-
const payload
|
|
58
|
-
const body
|
|
57
|
+
const payload = parsed.value;
|
|
58
|
+
const body = encodeJSON("body", payload, { explode: true });
|
|
59
59
|
|
|
60
|
-
const path
|
|
60
|
+
const path = pathToFunc("/init-image")();
|
|
61
61
|
|
|
62
|
-
const headers
|
|
62
|
+
const headers = new Headers({
|
|
63
63
|
"Content-Type": "application/json",
|
|
64
64
|
Accept: "application/json",
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
const
|
|
68
|
-
const
|
|
67
|
+
const secConfig = await extractSecurity(client._options.bearerAuth);
|
|
68
|
+
const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
|
|
69
69
|
const context = {
|
|
70
70
|
operationID: "uploadInitImage",
|
|
71
71
|
oAuth2Scopes: [],
|
|
72
|
-
securitySource: client
|
|
72
|
+
securitySource: client._options.bearerAuth,
|
|
73
73
|
};
|
|
74
|
-
const
|
|
74
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
75
75
|
|
|
76
|
-
const requestRes = client
|
|
77
|
-
security:
|
|
76
|
+
const requestRes = client._createRequest(context, {
|
|
77
|
+
security: requestSecurity,
|
|
78
78
|
method: "POST",
|
|
79
|
-
path: path
|
|
80
|
-
headers: headers
|
|
81
|
-
body: body
|
|
82
|
-
timeoutMs: options?.timeoutMs || client
|
|
79
|
+
path: path,
|
|
80
|
+
headers: headers,
|
|
81
|
+
body: body,
|
|
82
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
83
83
|
}, options);
|
|
84
84
|
if (!requestRes.ok) {
|
|
85
85
|
return requestRes;
|
|
86
86
|
}
|
|
87
|
-
const
|
|
87
|
+
const req = requestRes.value;
|
|
88
88
|
|
|
89
|
-
const doResult = await client
|
|
89
|
+
const doResult = await client._do(req, {
|
|
90
90
|
context,
|
|
91
91
|
errorCodes: [],
|
|
92
92
|
retryConfig: options?.retries
|
|
93
|
-
|| client
|
|
93
|
+
|| client._options.retryConfig,
|
|
94
94
|
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
95
95
|
});
|
|
96
96
|
if (!doResult.ok) {
|
|
@@ -98,7 +98,7 @@ export async function initImagesUploadInitImage(
|
|
|
98
98
|
}
|
|
99
99
|
const response = doResult.value;
|
|
100
100
|
|
|
101
|
-
const responseFields
|
|
101
|
+
const responseFields = {
|
|
102
102
|
ContentType: response.headers.get("content-type")
|
|
103
103
|
?? "application/octet-stream",
|
|
104
104
|
StatusCode: response.status,
|
|
@@ -106,7 +106,7 @@ export async function initImagesUploadInitImage(
|
|
|
106
106
|
Headers: {},
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
const [result
|
|
109
|
+
const [result] = await M.match<
|
|
110
110
|
operations.UploadInitImageResponse,
|
|
111
111
|
| SDKError
|
|
112
112
|
| SDKValidationError
|
|
@@ -116,13 +116,13 @@ export async function initImagesUploadInitImage(
|
|
|
116
116
|
| RequestTimeoutError
|
|
117
117
|
| ConnectionError
|
|
118
118
|
>(
|
|
119
|
-
|
|
119
|
+
M.json(200, operations.UploadInitImageResponse$inboundSchema, {
|
|
120
120
|
key: "object",
|
|
121
121
|
}),
|
|
122
|
-
)(response, { extraFields: responseFields
|
|
123
|
-
if (!result
|
|
124
|
-
return result
|
|
122
|
+
)(response, { extraFields: responseFields });
|
|
123
|
+
if (!result.ok) {
|
|
124
|
+
return result;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
return result
|
|
127
|
+
return result;
|
|
128
128
|
}
|
|
@@ -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 train a new custom model
|
|
29
29
|
*/
|
|
30
30
|
export async function modelsCreateModel(
|
|
31
|
-
client
|
|
31
|
+
client: LeonardoCore,
|
|
32
32
|
request: operations.CreateModelRequestBody,
|
|
33
33
|
options?: RequestOptions,
|
|
34
34
|
): Promise<
|
|
@@ -43,53 +43,53 @@ export async function modelsCreateModel(
|
|
|
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) => operations.CreateModelRequestBody$outboundSchema.parse(value),
|
|
51
51
|
"Input validation failed",
|
|
52
52
|
);
|
|
53
|
-
if (!parsed
|
|
54
|
-
return parsed
|
|
53
|
+
if (!parsed.ok) {
|
|
54
|
+
return parsed;
|
|
55
55
|
}
|
|
56
|
-
const payload
|
|
57
|
-
const body
|
|
56
|
+
const payload = parsed.value;
|
|
57
|
+
const body = encodeJSON("body", payload, { explode: true });
|
|
58
58
|
|
|
59
|
-
const path
|
|
59
|
+
const path = pathToFunc("/models")();
|
|
60
60
|
|
|
61
|
-
const headers
|
|
61
|
+
const headers = new Headers({
|
|
62
62
|
"Content-Type": "application/json",
|
|
63
63
|
Accept: "application/json",
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
const
|
|
67
|
-
const
|
|
66
|
+
const secConfig = await extractSecurity(client._options.bearerAuth);
|
|
67
|
+
const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
|
|
68
68
|
const context = {
|
|
69
69
|
operationID: "createModel",
|
|
70
70
|
oAuth2Scopes: [],
|
|
71
|
-
securitySource: client
|
|
71
|
+
securitySource: client._options.bearerAuth,
|
|
72
72
|
};
|
|
73
|
-
const
|
|
73
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
74
74
|
|
|
75
|
-
const requestRes = client
|
|
76
|
-
security:
|
|
75
|
+
const requestRes = client._createRequest(context, {
|
|
76
|
+
security: requestSecurity,
|
|
77
77
|
method: "POST",
|
|
78
|
-
path: path
|
|
79
|
-
headers: headers
|
|
80
|
-
body: body
|
|
81
|
-
timeoutMs: options?.timeoutMs || client
|
|
78
|
+
path: path,
|
|
79
|
+
headers: headers,
|
|
80
|
+
body: body,
|
|
81
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
82
82
|
}, options);
|
|
83
83
|
if (!requestRes.ok) {
|
|
84
84
|
return requestRes;
|
|
85
85
|
}
|
|
86
|
-
const
|
|
86
|
+
const req = requestRes.value;
|
|
87
87
|
|
|
88
|
-
const doResult = await client
|
|
88
|
+
const doResult = await client._do(req, {
|
|
89
89
|
context,
|
|
90
90
|
errorCodes: [],
|
|
91
91
|
retryConfig: options?.retries
|
|
92
|
-
|| client
|
|
92
|
+
|| client._options.retryConfig,
|
|
93
93
|
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
94
94
|
});
|
|
95
95
|
if (!doResult.ok) {
|
|
@@ -97,7 +97,7 @@ export async function modelsCreateModel(
|
|
|
97
97
|
}
|
|
98
98
|
const response = doResult.value;
|
|
99
99
|
|
|
100
|
-
const responseFields
|
|
100
|
+
const responseFields = {
|
|
101
101
|
ContentType: response.headers.get("content-type")
|
|
102
102
|
?? "application/octet-stream",
|
|
103
103
|
StatusCode: response.status,
|
|
@@ -105,7 +105,7 @@ export async function modelsCreateModel(
|
|
|
105
105
|
Headers: {},
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
-
const [result
|
|
108
|
+
const [result] = await M.match<
|
|
109
109
|
operations.CreateModelResponse,
|
|
110
110
|
| SDKError
|
|
111
111
|
| SDKValidationError
|
|
@@ -115,13 +115,13 @@ export async function modelsCreateModel(
|
|
|
115
115
|
| RequestTimeoutError
|
|
116
116
|
| ConnectionError
|
|
117
117
|
>(
|
|
118
|
-
|
|
118
|
+
M.json(200, operations.CreateModelResponse$inboundSchema, {
|
|
119
119
|
key: "object",
|
|
120
120
|
}),
|
|
121
|
-
)(response, { extraFields: responseFields
|
|
122
|
-
if (!result
|
|
123
|
-
return result
|
|
121
|
+
)(response, { extraFields: responseFields });
|
|
122
|
+
if (!result.ok) {
|
|
123
|
+
return result;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
return result
|
|
126
|
+
return result;
|
|
127
127
|
}
|