@leonardo-ai/sdk 4.21.1 → 4.21.2
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 +9 -0
- package/funcs/blueprintsGetBlueprintById.js.map +1 -1
- package/funcs/blueprintsGetBlueprintExecution.js.map +1 -1
- package/funcs/blueprintsGetBlueprintExecutionGenerations.js.map +1 -1
- package/funcs/blueprintsGetBlueprintVersionsByBlueprintId.js.map +1 -1
- package/funcs/datasetDeleteDatasetById.js.map +1 -1
- package/funcs/datasetGetDatasetById.js.map +1 -1
- package/funcs/datasetUploadDatasetImage.js.map +1 -1
- package/funcs/datasetUploadDatasetImageFromGen.js.map +1 -1
- package/funcs/elementsDeleteElementById.js.map +1 -1
- package/funcs/elementsGetCustomElementsByUserId.js.map +1 -1
- package/funcs/elementsGetElementById.js.map +1 -1
- package/funcs/imageDeleteGenerationById.js.map +1 -1
- package/funcs/imageGetGenerationById.js.map +1 -1
- package/funcs/imageGetGenerationsByUserId.js.map +1 -1
- package/funcs/initImagesDeleteInitImageById.js.map +1 -1
- package/funcs/initImagesGetInitImageById.js.map +1 -1
- package/funcs/mediaDeleteUploadedMediaById.d.ts +17 -0
- package/funcs/mediaDeleteUploadedMediaById.d.ts.map +1 -0
- package/funcs/mediaDeleteUploadedMediaById.js +131 -0
- package/funcs/mediaDeleteUploadedMediaById.js.map +1 -0
- package/funcs/mediaGetUploadedMediaById.d.ts +17 -0
- package/funcs/mediaGetUploadedMediaById.d.ts.map +1 -0
- package/funcs/mediaGetUploadedMediaById.js +131 -0
- package/funcs/mediaGetUploadedMediaById.js.map +1 -0
- package/funcs/mediaUploadMedia.d.ts +17 -0
- package/funcs/mediaUploadMedia.d.ts.map +1 -0
- package/funcs/mediaUploadMedia.js +123 -0
- package/funcs/mediaUploadMedia.js.map +1 -0
- package/funcs/modelsDeleteModelById.js.map +1 -1
- package/funcs/modelsGetCustomModelsByUserId.js.map +1 -1
- package/funcs/modelsGetModelById.js.map +1 -1
- package/funcs/textureDeleteTextureGenerationById.js.map +1 -1
- package/funcs/threeDModelAssetsDelete3DModelById.js.map +1 -1
- package/funcs/variationGetMotionVariationById.js.map +1 -1
- package/funcs/variationGetVariationById.js.map +1 -1
- package/jsr.json +1 -1
- package/lib/config.d.ts +3 -3
- package/lib/config.js +3 -3
- package/lib/config.js.map +1 -1
- package/lib/encodings.d.ts +1 -0
- package/lib/encodings.d.ts.map +1 -1
- package/lib/encodings.js +27 -5
- package/lib/encodings.js.map +1 -1
- package/lib/files.d.ts +13 -0
- package/lib/files.d.ts.map +1 -1
- package/lib/files.js +19 -0
- package/lib/files.js.map +1 -1
- package/lib/matchers.d.ts.map +1 -1
- package/lib/matchers.js +0 -1
- package/lib/matchers.js.map +1 -1
- package/lib/sdks.d.ts.map +1 -1
- package/lib/sdks.js +8 -4
- package/lib/sdks.js.map +1 -1
- package/lib/security.d.ts +1 -1
- package/lib/security.d.ts.map +1 -1
- package/lib/security.js +20 -10
- package/lib/security.js.map +1 -1
- package/lib/url.d.ts.map +1 -1
- package/lib/url.js +4 -2
- package/lib/url.js.map +1 -1
- package/package.json +1 -1
- package/sdk/media.d.ts +26 -0
- package/sdk/media.d.ts.map +1 -0
- package/sdk/media.js +42 -0
- package/sdk/media.js.map +1 -0
- package/sdk/models/operations/deleteuploadedmediabyid.d.ts +53 -0
- package/sdk/models/operations/deleteuploadedmediabyid.d.ts.map +1 -0
- package/sdk/models/operations/deleteuploadedmediabyid.js +89 -0
- package/sdk/models/operations/deleteuploadedmediabyid.js.map +1 -0
- package/sdk/models/operations/getuploadedmediabyid.d.ts +63 -0
- package/sdk/models/operations/getuploadedmediabyid.d.ts.map +1 -0
- package/sdk/models/operations/getuploadedmediabyid.js +103 -0
- package/sdk/models/operations/getuploadedmediabyid.js.map +1 -0
- package/sdk/models/operations/index.d.ts +3 -0
- package/sdk/models/operations/index.d.ts.map +1 -1
- package/sdk/models/operations/index.js +3 -0
- package/sdk/models/operations/index.js.map +1 -1
- package/sdk/models/operations/uploadmedia.d.ts +58 -0
- package/sdk/models/operations/uploadmedia.d.ts.map +1 -0
- package/sdk/models/operations/uploadmedia.js +87 -0
- package/sdk/models/operations/uploadmedia.js.map +1 -0
- package/sdk/sdk.d.ts +3 -0
- package/sdk/sdk.d.ts.map +1 -1
- package/sdk/sdk.js +4 -0
- package/sdk/sdk.js.map +1 -1
- package/src/funcs/blueprintsGetBlueprintById.ts +0 -1
- package/src/funcs/blueprintsGetBlueprintExecution.ts +0 -1
- package/src/funcs/blueprintsGetBlueprintExecutionGenerations.ts +0 -1
- package/src/funcs/blueprintsGetBlueprintVersionsByBlueprintId.ts +0 -1
- package/src/funcs/datasetDeleteDatasetById.ts +0 -1
- package/src/funcs/datasetGetDatasetById.ts +0 -1
- package/src/funcs/datasetUploadDatasetImage.ts +0 -1
- package/src/funcs/datasetUploadDatasetImageFromGen.ts +0 -1
- package/src/funcs/elementsDeleteElementById.ts +0 -1
- package/src/funcs/elementsGetCustomElementsByUserId.ts +0 -1
- package/src/funcs/elementsGetElementById.ts +0 -1
- package/src/funcs/imageDeleteGenerationById.ts +0 -1
- package/src/funcs/imageGetGenerationById.ts +0 -1
- package/src/funcs/imageGetGenerationsByUserId.ts +0 -1
- package/src/funcs/initImagesDeleteInitImageById.ts +0 -1
- package/src/funcs/initImagesGetInitImageById.ts +0 -1
- package/src/funcs/mediaDeleteUploadedMediaById.ts +178 -0
- package/src/funcs/mediaGetUploadedMediaById.ts +178 -0
- package/src/funcs/mediaUploadMedia.ts +168 -0
- package/src/funcs/modelsDeleteModelById.ts +0 -1
- package/src/funcs/modelsGetCustomModelsByUserId.ts +0 -1
- package/src/funcs/modelsGetModelById.ts +0 -1
- package/src/funcs/textureDeleteTextureGenerationById.ts +0 -1
- package/src/funcs/threeDModelAssetsDelete3DModelById.ts +0 -1
- package/src/funcs/variationGetMotionVariationById.ts +0 -1
- package/src/funcs/variationGetVariationById.ts +0 -1
- package/src/lib/config.ts +3 -3
- package/src/lib/encodings.ts +32 -4
- package/src/lib/files.ts +22 -0
- package/src/lib/matchers.ts +3 -2
- package/src/lib/sdks.ts +7 -5
- package/src/lib/security.ts +15 -4
- package/src/lib/url.ts +16 -14
- package/src/sdk/media.ts +63 -0
- package/src/sdk/models/operations/deleteuploadedmediabyid.ts +144 -0
- package/src/sdk/models/operations/getuploadedmediabyid.ts +167 -0
- package/src/sdk/models/operations/index.ts +3 -0
- package/src/sdk/models/operations/uploadmedia.ts +142 -0
- package/src/sdk/sdk.ts +6 -0
- package/.devcontainer/devcontainer.json +0 -45
- package/_speakeasy/.github/action-inputs-config.json +0 -53
- package/_speakeasy/.github/action-security-config.json +0 -88
- package/examples/package-lock.json +0 -610
- package/examples/package.json +0 -18
- package/tsconfig.json +0 -40
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { LeonardoCore } from "../core.js";
|
|
6
|
+
import { encodeSimple } from "../lib/encodings.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
11
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import {
|
|
14
|
+
ConnectionError,
|
|
15
|
+
InvalidRequestError,
|
|
16
|
+
RequestAbortedError,
|
|
17
|
+
RequestTimeoutError,
|
|
18
|
+
UnexpectedClientError,
|
|
19
|
+
} from "../sdk/models/errors/httpclienterrors.js";
|
|
20
|
+
import { LeonardoError } from "../sdk/models/errors/leonardoerror.js";
|
|
21
|
+
import { ResponseValidationError } from "../sdk/models/errors/responsevalidationerror.js";
|
|
22
|
+
import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js";
|
|
23
|
+
import * as operations from "../sdk/models/operations/index.js";
|
|
24
|
+
import { APICall, APIPromise } from "../sdk/types/async.js";
|
|
25
|
+
import { Result } from "../sdk/types/fp.js";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Delete uploaded media
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* This endpoint deletes an uploaded media record and removes the associated file from S3
|
|
32
|
+
*/
|
|
33
|
+
export function mediaDeleteUploadedMediaById(
|
|
34
|
+
client: LeonardoCore,
|
|
35
|
+
id: string,
|
|
36
|
+
options?: RequestOptions,
|
|
37
|
+
): APIPromise<
|
|
38
|
+
Result<
|
|
39
|
+
operations.DeleteUploadedMediaByIdResponse,
|
|
40
|
+
| LeonardoError
|
|
41
|
+
| ResponseValidationError
|
|
42
|
+
| ConnectionError
|
|
43
|
+
| RequestAbortedError
|
|
44
|
+
| RequestTimeoutError
|
|
45
|
+
| InvalidRequestError
|
|
46
|
+
| UnexpectedClientError
|
|
47
|
+
| SDKValidationError
|
|
48
|
+
>
|
|
49
|
+
> {
|
|
50
|
+
return new APIPromise($do(
|
|
51
|
+
client,
|
|
52
|
+
id,
|
|
53
|
+
options,
|
|
54
|
+
));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function $do(
|
|
58
|
+
client: LeonardoCore,
|
|
59
|
+
id: string,
|
|
60
|
+
options?: RequestOptions,
|
|
61
|
+
): Promise<
|
|
62
|
+
[
|
|
63
|
+
Result<
|
|
64
|
+
operations.DeleteUploadedMediaByIdResponse,
|
|
65
|
+
| LeonardoError
|
|
66
|
+
| ResponseValidationError
|
|
67
|
+
| ConnectionError
|
|
68
|
+
| RequestAbortedError
|
|
69
|
+
| RequestTimeoutError
|
|
70
|
+
| InvalidRequestError
|
|
71
|
+
| UnexpectedClientError
|
|
72
|
+
| SDKValidationError
|
|
73
|
+
>,
|
|
74
|
+
APICall,
|
|
75
|
+
]
|
|
76
|
+
> {
|
|
77
|
+
const input: operations.DeleteUploadedMediaByIdRequest = {
|
|
78
|
+
id: id,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const parsed = safeParse(
|
|
82
|
+
input,
|
|
83
|
+
(value) =>
|
|
84
|
+
operations.DeleteUploadedMediaByIdRequest$outboundSchema.parse(value),
|
|
85
|
+
"Input validation failed",
|
|
86
|
+
);
|
|
87
|
+
if (!parsed.ok) {
|
|
88
|
+
return [parsed, { status: "invalid" }];
|
|
89
|
+
}
|
|
90
|
+
const payload = parsed.value;
|
|
91
|
+
const body = null;
|
|
92
|
+
|
|
93
|
+
const pathParams = {
|
|
94
|
+
id: encodeSimple("id", payload.id, {
|
|
95
|
+
explode: false,
|
|
96
|
+
charEncoding: "percent",
|
|
97
|
+
}),
|
|
98
|
+
};
|
|
99
|
+
const path = pathToFunc("/media/{id}")(pathParams);
|
|
100
|
+
|
|
101
|
+
const headers = new Headers(compactMap({
|
|
102
|
+
Accept: "application/json",
|
|
103
|
+
}));
|
|
104
|
+
|
|
105
|
+
const secConfig = await extractSecurity(client._options.bearerAuth);
|
|
106
|
+
const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
|
|
107
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
108
|
+
|
|
109
|
+
const context = {
|
|
110
|
+
options: client._options,
|
|
111
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
112
|
+
operationID: "deleteUploadedMediaById",
|
|
113
|
+
oAuth2Scopes: null,
|
|
114
|
+
|
|
115
|
+
resolvedSecurity: requestSecurity,
|
|
116
|
+
|
|
117
|
+
securitySource: client._options.bearerAuth,
|
|
118
|
+
retryConfig: options?.retries
|
|
119
|
+
|| client._options.retryConfig
|
|
120
|
+
|| { strategy: "none" },
|
|
121
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const requestRes = client._createRequest(context, {
|
|
125
|
+
security: requestSecurity,
|
|
126
|
+
method: "DELETE",
|
|
127
|
+
baseURL: options?.serverURL,
|
|
128
|
+
path: path,
|
|
129
|
+
headers: headers,
|
|
130
|
+
body: body,
|
|
131
|
+
userAgent: client._options.userAgent,
|
|
132
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
133
|
+
}, options);
|
|
134
|
+
if (!requestRes.ok) {
|
|
135
|
+
return [requestRes, { status: "invalid" }];
|
|
136
|
+
}
|
|
137
|
+
const req = requestRes.value;
|
|
138
|
+
|
|
139
|
+
const doResult = await client._do(req, {
|
|
140
|
+
context,
|
|
141
|
+
errorCodes: [],
|
|
142
|
+
retryConfig: context.retryConfig,
|
|
143
|
+
retryCodes: context.retryCodes,
|
|
144
|
+
});
|
|
145
|
+
if (!doResult.ok) {
|
|
146
|
+
return [doResult, { status: "request-error", request: req }];
|
|
147
|
+
}
|
|
148
|
+
const response = doResult.value;
|
|
149
|
+
|
|
150
|
+
const responseFields = {
|
|
151
|
+
ContentType: response.headers.get("content-type")
|
|
152
|
+
?? "application/octet-stream",
|
|
153
|
+
StatusCode: response.status,
|
|
154
|
+
RawResponse: response,
|
|
155
|
+
Headers: {},
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const [result] = await M.match<
|
|
159
|
+
operations.DeleteUploadedMediaByIdResponse,
|
|
160
|
+
| LeonardoError
|
|
161
|
+
| ResponseValidationError
|
|
162
|
+
| ConnectionError
|
|
163
|
+
| RequestAbortedError
|
|
164
|
+
| RequestTimeoutError
|
|
165
|
+
| InvalidRequestError
|
|
166
|
+
| UnexpectedClientError
|
|
167
|
+
| SDKValidationError
|
|
168
|
+
>(
|
|
169
|
+
M.json(200, operations.DeleteUploadedMediaByIdResponse$inboundSchema, {
|
|
170
|
+
key: "object",
|
|
171
|
+
}),
|
|
172
|
+
)(response, req, { extraFields: responseFields });
|
|
173
|
+
if (!result.ok) {
|
|
174
|
+
return [result, { status: "complete", request: req, response }];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return [result, { status: "complete", request: req, response }];
|
|
178
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { LeonardoCore } from "../core.js";
|
|
6
|
+
import { encodeSimple } from "../lib/encodings.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
11
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import {
|
|
14
|
+
ConnectionError,
|
|
15
|
+
InvalidRequestError,
|
|
16
|
+
RequestAbortedError,
|
|
17
|
+
RequestTimeoutError,
|
|
18
|
+
UnexpectedClientError,
|
|
19
|
+
} from "../sdk/models/errors/httpclienterrors.js";
|
|
20
|
+
import { LeonardoError } from "../sdk/models/errors/leonardoerror.js";
|
|
21
|
+
import { ResponseValidationError } from "../sdk/models/errors/responsevalidationerror.js";
|
|
22
|
+
import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js";
|
|
23
|
+
import * as operations from "../sdk/models/operations/index.js";
|
|
24
|
+
import { APICall, APIPromise } from "../sdk/types/async.js";
|
|
25
|
+
import { Result } from "../sdk/types/fp.js";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Get uploaded media
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* This endpoint returns details of an uploaded media record
|
|
32
|
+
*/
|
|
33
|
+
export function mediaGetUploadedMediaById(
|
|
34
|
+
client: LeonardoCore,
|
|
35
|
+
id: string,
|
|
36
|
+
options?: RequestOptions,
|
|
37
|
+
): APIPromise<
|
|
38
|
+
Result<
|
|
39
|
+
operations.GetUploadedMediaByIdResponse,
|
|
40
|
+
| LeonardoError
|
|
41
|
+
| ResponseValidationError
|
|
42
|
+
| ConnectionError
|
|
43
|
+
| RequestAbortedError
|
|
44
|
+
| RequestTimeoutError
|
|
45
|
+
| InvalidRequestError
|
|
46
|
+
| UnexpectedClientError
|
|
47
|
+
| SDKValidationError
|
|
48
|
+
>
|
|
49
|
+
> {
|
|
50
|
+
return new APIPromise($do(
|
|
51
|
+
client,
|
|
52
|
+
id,
|
|
53
|
+
options,
|
|
54
|
+
));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function $do(
|
|
58
|
+
client: LeonardoCore,
|
|
59
|
+
id: string,
|
|
60
|
+
options?: RequestOptions,
|
|
61
|
+
): Promise<
|
|
62
|
+
[
|
|
63
|
+
Result<
|
|
64
|
+
operations.GetUploadedMediaByIdResponse,
|
|
65
|
+
| LeonardoError
|
|
66
|
+
| ResponseValidationError
|
|
67
|
+
| ConnectionError
|
|
68
|
+
| RequestAbortedError
|
|
69
|
+
| RequestTimeoutError
|
|
70
|
+
| InvalidRequestError
|
|
71
|
+
| UnexpectedClientError
|
|
72
|
+
| SDKValidationError
|
|
73
|
+
>,
|
|
74
|
+
APICall,
|
|
75
|
+
]
|
|
76
|
+
> {
|
|
77
|
+
const input: operations.GetUploadedMediaByIdRequest = {
|
|
78
|
+
id: id,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const parsed = safeParse(
|
|
82
|
+
input,
|
|
83
|
+
(value) =>
|
|
84
|
+
operations.GetUploadedMediaByIdRequest$outboundSchema.parse(value),
|
|
85
|
+
"Input validation failed",
|
|
86
|
+
);
|
|
87
|
+
if (!parsed.ok) {
|
|
88
|
+
return [parsed, { status: "invalid" }];
|
|
89
|
+
}
|
|
90
|
+
const payload = parsed.value;
|
|
91
|
+
const body = null;
|
|
92
|
+
|
|
93
|
+
const pathParams = {
|
|
94
|
+
id: encodeSimple("id", payload.id, {
|
|
95
|
+
explode: false,
|
|
96
|
+
charEncoding: "percent",
|
|
97
|
+
}),
|
|
98
|
+
};
|
|
99
|
+
const path = pathToFunc("/media/{id}")(pathParams);
|
|
100
|
+
|
|
101
|
+
const headers = new Headers(compactMap({
|
|
102
|
+
Accept: "application/json",
|
|
103
|
+
}));
|
|
104
|
+
|
|
105
|
+
const secConfig = await extractSecurity(client._options.bearerAuth);
|
|
106
|
+
const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
|
|
107
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
108
|
+
|
|
109
|
+
const context = {
|
|
110
|
+
options: client._options,
|
|
111
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
112
|
+
operationID: "getUploadedMediaById",
|
|
113
|
+
oAuth2Scopes: null,
|
|
114
|
+
|
|
115
|
+
resolvedSecurity: requestSecurity,
|
|
116
|
+
|
|
117
|
+
securitySource: client._options.bearerAuth,
|
|
118
|
+
retryConfig: options?.retries
|
|
119
|
+
|| client._options.retryConfig
|
|
120
|
+
|| { strategy: "none" },
|
|
121
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const requestRes = client._createRequest(context, {
|
|
125
|
+
security: requestSecurity,
|
|
126
|
+
method: "GET",
|
|
127
|
+
baseURL: options?.serverURL,
|
|
128
|
+
path: path,
|
|
129
|
+
headers: headers,
|
|
130
|
+
body: body,
|
|
131
|
+
userAgent: client._options.userAgent,
|
|
132
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
133
|
+
}, options);
|
|
134
|
+
if (!requestRes.ok) {
|
|
135
|
+
return [requestRes, { status: "invalid" }];
|
|
136
|
+
}
|
|
137
|
+
const req = requestRes.value;
|
|
138
|
+
|
|
139
|
+
const doResult = await client._do(req, {
|
|
140
|
+
context,
|
|
141
|
+
errorCodes: [],
|
|
142
|
+
retryConfig: context.retryConfig,
|
|
143
|
+
retryCodes: context.retryCodes,
|
|
144
|
+
});
|
|
145
|
+
if (!doResult.ok) {
|
|
146
|
+
return [doResult, { status: "request-error", request: req }];
|
|
147
|
+
}
|
|
148
|
+
const response = doResult.value;
|
|
149
|
+
|
|
150
|
+
const responseFields = {
|
|
151
|
+
ContentType: response.headers.get("content-type")
|
|
152
|
+
?? "application/octet-stream",
|
|
153
|
+
StatusCode: response.status,
|
|
154
|
+
RawResponse: response,
|
|
155
|
+
Headers: {},
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const [result] = await M.match<
|
|
159
|
+
operations.GetUploadedMediaByIdResponse,
|
|
160
|
+
| LeonardoError
|
|
161
|
+
| ResponseValidationError
|
|
162
|
+
| ConnectionError
|
|
163
|
+
| RequestAbortedError
|
|
164
|
+
| RequestTimeoutError
|
|
165
|
+
| InvalidRequestError
|
|
166
|
+
| UnexpectedClientError
|
|
167
|
+
| SDKValidationError
|
|
168
|
+
>(
|
|
169
|
+
M.json(200, operations.GetUploadedMediaByIdResponse$inboundSchema, {
|
|
170
|
+
key: "object",
|
|
171
|
+
}),
|
|
172
|
+
)(response, req, { extraFields: responseFields });
|
|
173
|
+
if (!result.ok) {
|
|
174
|
+
return [result, { status: "complete", request: req, response }];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return [result, { status: "complete", request: req, response }];
|
|
178
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { LeonardoCore } from "../core.js";
|
|
6
|
+
import { encodeJSON } from "../lib/encodings.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
11
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import {
|
|
14
|
+
ConnectionError,
|
|
15
|
+
InvalidRequestError,
|
|
16
|
+
RequestAbortedError,
|
|
17
|
+
RequestTimeoutError,
|
|
18
|
+
UnexpectedClientError,
|
|
19
|
+
} from "../sdk/models/errors/httpclienterrors.js";
|
|
20
|
+
import { LeonardoError } from "../sdk/models/errors/leonardoerror.js";
|
|
21
|
+
import { ResponseValidationError } from "../sdk/models/errors/responsevalidationerror.js";
|
|
22
|
+
import { SDKValidationError } from "../sdk/models/errors/sdkvalidationerror.js";
|
|
23
|
+
import * as operations from "../sdk/models/operations/index.js";
|
|
24
|
+
import { APICall, APIPromise } from "../sdk/types/async.js";
|
|
25
|
+
import { Result } from "../sdk/types/fp.js";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Upload media
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* This endpoint returns presigned details to upload a media file to S3
|
|
32
|
+
*/
|
|
33
|
+
export function mediaUploadMedia(
|
|
34
|
+
client: LeonardoCore,
|
|
35
|
+
request: operations.UploadMediaRequestBody,
|
|
36
|
+
options?: RequestOptions,
|
|
37
|
+
): APIPromise<
|
|
38
|
+
Result<
|
|
39
|
+
operations.UploadMediaResponse,
|
|
40
|
+
| LeonardoError
|
|
41
|
+
| ResponseValidationError
|
|
42
|
+
| ConnectionError
|
|
43
|
+
| RequestAbortedError
|
|
44
|
+
| RequestTimeoutError
|
|
45
|
+
| InvalidRequestError
|
|
46
|
+
| UnexpectedClientError
|
|
47
|
+
| SDKValidationError
|
|
48
|
+
>
|
|
49
|
+
> {
|
|
50
|
+
return new APIPromise($do(
|
|
51
|
+
client,
|
|
52
|
+
request,
|
|
53
|
+
options,
|
|
54
|
+
));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function $do(
|
|
58
|
+
client: LeonardoCore,
|
|
59
|
+
request: operations.UploadMediaRequestBody,
|
|
60
|
+
options?: RequestOptions,
|
|
61
|
+
): Promise<
|
|
62
|
+
[
|
|
63
|
+
Result<
|
|
64
|
+
operations.UploadMediaResponse,
|
|
65
|
+
| LeonardoError
|
|
66
|
+
| ResponseValidationError
|
|
67
|
+
| ConnectionError
|
|
68
|
+
| RequestAbortedError
|
|
69
|
+
| RequestTimeoutError
|
|
70
|
+
| InvalidRequestError
|
|
71
|
+
| UnexpectedClientError
|
|
72
|
+
| SDKValidationError
|
|
73
|
+
>,
|
|
74
|
+
APICall,
|
|
75
|
+
]
|
|
76
|
+
> {
|
|
77
|
+
const parsed = safeParse(
|
|
78
|
+
request,
|
|
79
|
+
(value) => operations.UploadMediaRequestBody$outboundSchema.parse(value),
|
|
80
|
+
"Input validation failed",
|
|
81
|
+
);
|
|
82
|
+
if (!parsed.ok) {
|
|
83
|
+
return [parsed, { status: "invalid" }];
|
|
84
|
+
}
|
|
85
|
+
const payload = parsed.value;
|
|
86
|
+
const body = encodeJSON("body", payload, { explode: true });
|
|
87
|
+
|
|
88
|
+
const path = pathToFunc("/media")();
|
|
89
|
+
|
|
90
|
+
const headers = new Headers(compactMap({
|
|
91
|
+
"Content-Type": "application/json",
|
|
92
|
+
Accept: "application/json",
|
|
93
|
+
}));
|
|
94
|
+
|
|
95
|
+
const secConfig = await extractSecurity(client._options.bearerAuth);
|
|
96
|
+
const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
|
|
97
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
98
|
+
|
|
99
|
+
const context = {
|
|
100
|
+
options: client._options,
|
|
101
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
102
|
+
operationID: "uploadMedia",
|
|
103
|
+
oAuth2Scopes: null,
|
|
104
|
+
|
|
105
|
+
resolvedSecurity: requestSecurity,
|
|
106
|
+
|
|
107
|
+
securitySource: client._options.bearerAuth,
|
|
108
|
+
retryConfig: options?.retries
|
|
109
|
+
|| client._options.retryConfig
|
|
110
|
+
|| { strategy: "none" },
|
|
111
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const requestRes = client._createRequest(context, {
|
|
115
|
+
security: requestSecurity,
|
|
116
|
+
method: "POST",
|
|
117
|
+
baseURL: options?.serverURL,
|
|
118
|
+
path: path,
|
|
119
|
+
headers: headers,
|
|
120
|
+
body: body,
|
|
121
|
+
userAgent: client._options.userAgent,
|
|
122
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
123
|
+
}, options);
|
|
124
|
+
if (!requestRes.ok) {
|
|
125
|
+
return [requestRes, { status: "invalid" }];
|
|
126
|
+
}
|
|
127
|
+
const req = requestRes.value;
|
|
128
|
+
|
|
129
|
+
const doResult = await client._do(req, {
|
|
130
|
+
context,
|
|
131
|
+
errorCodes: [],
|
|
132
|
+
retryConfig: context.retryConfig,
|
|
133
|
+
retryCodes: context.retryCodes,
|
|
134
|
+
});
|
|
135
|
+
if (!doResult.ok) {
|
|
136
|
+
return [doResult, { status: "request-error", request: req }];
|
|
137
|
+
}
|
|
138
|
+
const response = doResult.value;
|
|
139
|
+
|
|
140
|
+
const responseFields = {
|
|
141
|
+
ContentType: response.headers.get("content-type")
|
|
142
|
+
?? "application/octet-stream",
|
|
143
|
+
StatusCode: response.status,
|
|
144
|
+
RawResponse: response,
|
|
145
|
+
Headers: {},
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const [result] = await M.match<
|
|
149
|
+
operations.UploadMediaResponse,
|
|
150
|
+
| LeonardoError
|
|
151
|
+
| ResponseValidationError
|
|
152
|
+
| ConnectionError
|
|
153
|
+
| RequestAbortedError
|
|
154
|
+
| RequestTimeoutError
|
|
155
|
+
| InvalidRequestError
|
|
156
|
+
| UnexpectedClientError
|
|
157
|
+
| SDKValidationError
|
|
158
|
+
>(
|
|
159
|
+
M.json(200, operations.UploadMediaResponse$inboundSchema, {
|
|
160
|
+
key: "object",
|
|
161
|
+
}),
|
|
162
|
+
)(response, req, { extraFields: responseFields });
|
|
163
|
+
if (!result.ok) {
|
|
164
|
+
return [result, { status: "complete", request: req, response }];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return [result, { status: "complete", request: req, response }];
|
|
168
|
+
}
|
package/src/lib/config.ts
CHANGED
|
@@ -61,7 +61,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
|
61
61
|
export const SDK_METADATA = {
|
|
62
62
|
language: "typescript",
|
|
63
63
|
openapiDocVersion: "v1.0.0",
|
|
64
|
-
sdkVersion: "4.21.
|
|
65
|
-
genVersion: "2.
|
|
66
|
-
userAgent: "speakeasy-sdk/typescript 4.21.
|
|
64
|
+
sdkVersion: "4.21.2",
|
|
65
|
+
genVersion: "2.879.13",
|
|
66
|
+
userAgent: "speakeasy-sdk/typescript 4.21.2 2.879.13 v1.0.0 @leonardo-ai/sdk",
|
|
67
67
|
} as const;
|
package/src/lib/encodings.ts
CHANGED
|
@@ -479,6 +479,23 @@ export const encodeSpaceDelimitedQuery = queryEncoder(encodeSpaceDelimited);
|
|
|
479
479
|
export const encodePipeDelimitedQuery = queryEncoder(encodePipeDelimited);
|
|
480
480
|
export const encodeDeepObjectQuery = queryEncoder(encodeDeepObject);
|
|
481
481
|
|
|
482
|
+
function isBlobLike(val: unknown): val is Blob {
|
|
483
|
+
if (val instanceof Blob) {
|
|
484
|
+
return true;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
if (typeof val !== "object" || val == null || !(Symbol.toStringTag in val)) {
|
|
488
|
+
return false;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
const tag = val[Symbol.toStringTag];
|
|
492
|
+
if (tag !== "Blob" && tag !== "File") {
|
|
493
|
+
return false;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
return "stream" in val && typeof val.stream === "function";
|
|
497
|
+
}
|
|
498
|
+
|
|
482
499
|
export function appendForm(
|
|
483
500
|
fd: FormData,
|
|
484
501
|
key: string,
|
|
@@ -487,11 +504,22 @@ export function appendForm(
|
|
|
487
504
|
): void {
|
|
488
505
|
if (value == null) {
|
|
489
506
|
return;
|
|
490
|
-
} else if (value
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
507
|
+
} else if (isBlobLike(value)) {
|
|
508
|
+
if (fileName) {
|
|
509
|
+
fd.append(key, value as Blob, fileName);
|
|
510
|
+
} else {
|
|
511
|
+
fd.append(key, value as Blob);
|
|
512
|
+
}
|
|
494
513
|
} else {
|
|
495
514
|
fd.append(key, String(value));
|
|
496
515
|
}
|
|
497
516
|
}
|
|
517
|
+
|
|
518
|
+
export async function normalizeBlob(
|
|
519
|
+
value: Pick<Blob, "arrayBuffer" | "type">,
|
|
520
|
+
): Promise<Blob> {
|
|
521
|
+
if (value instanceof Blob) {
|
|
522
|
+
return value;
|
|
523
|
+
}
|
|
524
|
+
return new Blob([await value.arrayBuffer()], { type: value.type });
|
|
525
|
+
}
|
package/src/lib/files.ts
CHANGED
|
@@ -80,3 +80,25 @@ export function getContentTypeFromFileName(fileName: string): string | null {
|
|
|
80
80
|
|
|
81
81
|
return mimeTypes[ext] || null;
|
|
82
82
|
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Creates a Blob from file content with the given MIME type.
|
|
86
|
+
*
|
|
87
|
+
* Node.js Buffers are Uint8Array subclasses that may share a pooled
|
|
88
|
+
* ArrayBuffer (byteOffset > 0, byteLength < buffer.byteLength). Passing
|
|
89
|
+
* such a Buffer directly to `new Blob([buf])` can include the entire
|
|
90
|
+
* underlying pool on some runtimes, producing a Blob with extra bytes
|
|
91
|
+
* that corrupts multipart uploads.
|
|
92
|
+
*
|
|
93
|
+
* Copying into a standalone Uint8Array ensures the Blob receives only the
|
|
94
|
+
* intended bytes regardless of runtime behaviour.
|
|
95
|
+
*/
|
|
96
|
+
export function bytesToBlob(
|
|
97
|
+
content: Uint8Array<ArrayBufferLike> | ArrayBuffer | Blob | string,
|
|
98
|
+
contentType: string,
|
|
99
|
+
): Blob {
|
|
100
|
+
if (content instanceof Uint8Array) {
|
|
101
|
+
return new Blob([new Uint8Array(content)], { type: contentType });
|
|
102
|
+
}
|
|
103
|
+
return new Blob([content as BlobPart], { type: contentType });
|
|
104
|
+
}
|
package/src/lib/matchers.ts
CHANGED
|
@@ -248,8 +248,9 @@ export function match<T, E>(
|
|
|
248
248
|
raw = body;
|
|
249
249
|
break;
|
|
250
250
|
default:
|
|
251
|
-
|
|
252
|
-
|
|
251
|
+
throw new Error(
|
|
252
|
+
`Unsupported response type: ${encoding satisfies never}`,
|
|
253
|
+
);
|
|
253
254
|
}
|
|
254
255
|
|
|
255
256
|
if (matcher.enc === "fail") {
|