@moovio/sdk 0.16.5 → 0.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 +60 -45
- package/bin/mcp-server.js +1167 -551
- package/bin/mcp-server.js.map +23 -12
- package/docs/sdks/images/README.md +190 -0
- package/docs/sdks/products/README.md +32 -8
- package/examples/package-lock.json +1 -1
- package/funcs/imagesUpdate.d.ts +19 -0
- package/funcs/imagesUpdate.d.ts.map +1 -0
- package/funcs/imagesUpdate.js +170 -0
- package/funcs/imagesUpdate.js.map +1 -0
- package/funcs/imagesUpload.d.ts +16 -0
- package/funcs/imagesUpload.d.ts.map +1 -0
- package/funcs/imagesUpload.js +161 -0
- package/funcs/imagesUpload.js.map +1 -0
- 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/mcp-server/mcp-server.js +1 -1
- package/mcp-server/server.d.ts.map +1 -1
- package/mcp-server/server.js +5 -1
- package/mcp-server/server.js.map +1 -1
- package/mcp-server/tools/imagesUpdate.d.ts +8 -0
- package/mcp-server/tools/imagesUpdate.d.ts.map +1 -0
- package/mcp-server/tools/imagesUpdate.js +66 -0
- package/mcp-server/tools/imagesUpdate.js.map +1 -0
- package/mcp-server/tools/imagesUpload.d.ts +8 -0
- package/mcp-server/tools/imagesUpload.d.ts.map +1 -0
- package/mcp-server/tools/imagesUpload.js +63 -0
- package/mcp-server/tools/imagesUpload.js.map +1 -0
- package/models/components/createproductoption.d.ts +3 -2
- package/models/components/createproductoption.d.ts.map +1 -1
- package/models/components/createproductoption.js +3 -2
- package/models/components/createproductoption.js.map +1 -1
- package/models/components/imagemetadatarequest.d.ts +35 -0
- package/models/components/imagemetadatarequest.d.ts.map +1 -0
- package/models/components/imagemetadatarequest.js +69 -0
- package/models/components/imagemetadatarequest.js.map +1 -0
- package/models/components/imagemetadatavalidationerror.d.ts +29 -0
- package/models/components/imagemetadatavalidationerror.d.ts.map +1 -0
- package/models/components/imagemetadatavalidationerror.js +69 -0
- package/models/components/imagemetadatavalidationerror.js.map +1 -0
- package/models/components/imageupdaterequestmultipart.d.ts +103 -0
- package/models/components/imageupdaterequestmultipart.d.ts.map +1 -0
- package/models/components/imageupdaterequestmultipart.js +139 -0
- package/models/components/imageupdaterequestmultipart.js.map +1 -0
- package/models/components/imageuploadrequestmultipart.d.ts +65 -0
- package/models/components/imageuploadrequestmultipart.d.ts.map +1 -0
- package/models/components/imageuploadrequestmultipart.js +113 -0
- package/models/components/imageuploadrequestmultipart.js.map +1 -0
- package/models/components/index.d.ts +4 -0
- package/models/components/index.d.ts.map +1 -1
- package/models/components/index.js +4 -0
- package/models/components/index.js.map +1 -1
- package/models/components/productoption.d.ts +3 -2
- package/models/components/productoption.d.ts.map +1 -1
- package/models/components/productoption.js +3 -2
- package/models/components/productoption.js.map +1 -1
- package/models/components/productoptionvalidationerror.d.ts +3 -2
- package/models/components/productoptionvalidationerror.d.ts.map +1 -1
- package/models/components/productoptionvalidationerror.js +3 -2
- package/models/components/productoptionvalidationerror.js.map +1 -1
- package/models/errors/imagerequestvalidationerror.d.ts +40 -0
- package/models/errors/imagerequestvalidationerror.d.ts.map +1 -0
- package/models/errors/imagerequestvalidationerror.js +91 -0
- package/models/errors/imagerequestvalidationerror.js.map +1 -0
- package/models/errors/index.d.ts +1 -0
- package/models/errors/index.d.ts.map +1 -1
- package/models/errors/index.js +1 -0
- package/models/errors/index.js.map +1 -1
- package/models/operations/index.d.ts +2 -0
- package/models/operations/index.d.ts.map +1 -1
- package/models/operations/index.js +2 -0
- package/models/operations/index.js.map +1 -1
- package/models/operations/updateimage.d.ts +103 -0
- package/models/operations/updateimage.d.ts.map +1 -0
- package/models/operations/updateimage.js +157 -0
- package/models/operations/updateimage.js.map +1 -0
- package/models/operations/uploadimage.d.ts +101 -0
- package/models/operations/uploadimage.d.ts.map +1 -0
- package/models/operations/uploadimage.js +155 -0
- package/models/operations/uploadimage.js.map +1 -0
- package/package.json +1 -1
- package/sdk/images.d.ts +13 -0
- package/sdk/images.d.ts.map +1 -1
- package/sdk/images.js +19 -0
- package/sdk/images.js.map +1 -1
- package/src/funcs/imagesUpdate.ts +258 -0
- package/src/funcs/imagesUpload.ts +249 -0
- package/src/lib/config.ts +3 -3
- package/src/mcp-server/mcp-server.ts +1 -1
- package/src/mcp-server/server.ts +5 -1
- package/src/mcp-server/tools/imagesUpdate.ts +39 -0
- package/src/mcp-server/tools/imagesUpload.ts +36 -0
- package/src/models/components/createproductoption.ts +10 -4
- package/src/models/components/imagemetadatarequest.ts +72 -0
- package/src/models/components/imagemetadatavalidationerror.ts +68 -0
- package/src/models/components/imageupdaterequestmultipart.ts +224 -0
- package/src/models/components/imageuploadrequestmultipart.ts +150 -0
- package/src/models/components/index.ts +4 -0
- package/src/models/components/productoption.ts +10 -4
- package/src/models/components/productoptionvalidationerror.ts +10 -4
- package/src/models/errors/imagerequestvalidationerror.ts +86 -0
- package/src/models/errors/index.ts +1 -0
- package/src/models/operations/index.ts +2 -0
- package/src/models/operations/updateimage.ts +237 -0
- package/src/models/operations/uploadimage.ts +233 -0
- package/src/sdk/images.ts +35 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { MoovCore } from "../core.js";
|
|
6
|
+
import { appendForm, encodeJSON, encodeSimple } from "../lib/encodings.js";
|
|
7
|
+
import {
|
|
8
|
+
getContentTypeFromFileName,
|
|
9
|
+
readableStreamToArrayBuffer,
|
|
10
|
+
} from "../lib/files.js";
|
|
11
|
+
import * as M from "../lib/matchers.js";
|
|
12
|
+
import { compactMap } from "../lib/primitives.js";
|
|
13
|
+
import { safeParse } from "../lib/schemas.js";
|
|
14
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
15
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
16
|
+
import { pathToFunc } from "../lib/url.js";
|
|
17
|
+
import {
|
|
18
|
+
ConnectionError,
|
|
19
|
+
InvalidRequestError,
|
|
20
|
+
RequestAbortedError,
|
|
21
|
+
RequestTimeoutError,
|
|
22
|
+
UnexpectedClientError,
|
|
23
|
+
} from "../models/errors/httpclienterrors.js";
|
|
24
|
+
import * as errors from "../models/errors/index.js";
|
|
25
|
+
import { MoovError } from "../models/errors/mooverror.js";
|
|
26
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
27
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
28
|
+
import * as operations from "../models/operations/index.js";
|
|
29
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
30
|
+
import { isBlobLike } from "../types/blobs.js";
|
|
31
|
+
import { Result } from "../types/fp.js";
|
|
32
|
+
import { isReadableStream } from "../types/streams.js";
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Update an existing image and/or its metadata.
|
|
36
|
+
*
|
|
37
|
+
* Duplicate images, and requests larger than 16MB will be rejected. Omit any
|
|
38
|
+
* form parts you do not wish to update. Existing metadata can be cleared by
|
|
39
|
+
* sending `null` for the `metadata` form part.
|
|
40
|
+
*/
|
|
41
|
+
export function imagesUpdate(
|
|
42
|
+
client: MoovCore,
|
|
43
|
+
request: operations.UpdateImageRequest,
|
|
44
|
+
options?: RequestOptions,
|
|
45
|
+
): APIPromise<
|
|
46
|
+
Result<
|
|
47
|
+
operations.UpdateImageResponse,
|
|
48
|
+
| errors.GenericError
|
|
49
|
+
| errors.ImageRequestValidationError
|
|
50
|
+
| MoovError
|
|
51
|
+
| ResponseValidationError
|
|
52
|
+
| ConnectionError
|
|
53
|
+
| RequestAbortedError
|
|
54
|
+
| RequestTimeoutError
|
|
55
|
+
| InvalidRequestError
|
|
56
|
+
| UnexpectedClientError
|
|
57
|
+
| SDKValidationError
|
|
58
|
+
>
|
|
59
|
+
> {
|
|
60
|
+
return new APIPromise($do(
|
|
61
|
+
client,
|
|
62
|
+
request,
|
|
63
|
+
options,
|
|
64
|
+
));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function $do(
|
|
68
|
+
client: MoovCore,
|
|
69
|
+
request: operations.UpdateImageRequest,
|
|
70
|
+
options?: RequestOptions,
|
|
71
|
+
): Promise<
|
|
72
|
+
[
|
|
73
|
+
Result<
|
|
74
|
+
operations.UpdateImageResponse,
|
|
75
|
+
| errors.GenericError
|
|
76
|
+
| errors.ImageRequestValidationError
|
|
77
|
+
| MoovError
|
|
78
|
+
| ResponseValidationError
|
|
79
|
+
| ConnectionError
|
|
80
|
+
| RequestAbortedError
|
|
81
|
+
| RequestTimeoutError
|
|
82
|
+
| InvalidRequestError
|
|
83
|
+
| UnexpectedClientError
|
|
84
|
+
| SDKValidationError
|
|
85
|
+
>,
|
|
86
|
+
APICall,
|
|
87
|
+
]
|
|
88
|
+
> {
|
|
89
|
+
const parsed = safeParse(
|
|
90
|
+
request,
|
|
91
|
+
(value) => operations.UpdateImageRequest$outboundSchema.parse(value),
|
|
92
|
+
"Input validation failed",
|
|
93
|
+
);
|
|
94
|
+
if (!parsed.ok) {
|
|
95
|
+
return [parsed, { status: "invalid" }];
|
|
96
|
+
}
|
|
97
|
+
const payload = parsed.value;
|
|
98
|
+
const body = new FormData();
|
|
99
|
+
|
|
100
|
+
if (payload.ImageUpdateRequestMultiPart.image !== undefined) {
|
|
101
|
+
if (isBlobLike(payload.ImageUpdateRequestMultiPart.image)) {
|
|
102
|
+
appendForm(body, "image", payload.ImageUpdateRequestMultiPart.image);
|
|
103
|
+
} else if (
|
|
104
|
+
isReadableStream(payload.ImageUpdateRequestMultiPart.image.content)
|
|
105
|
+
) {
|
|
106
|
+
const buffer = await readableStreamToArrayBuffer(
|
|
107
|
+
payload.ImageUpdateRequestMultiPart.image.content,
|
|
108
|
+
);
|
|
109
|
+
const contentType =
|
|
110
|
+
getContentTypeFromFileName(
|
|
111
|
+
payload.ImageUpdateRequestMultiPart.image.fileName,
|
|
112
|
+
) || "application/octet-stream";
|
|
113
|
+
const blob = new Blob([buffer], { type: contentType });
|
|
114
|
+
appendForm(
|
|
115
|
+
body,
|
|
116
|
+
"image",
|
|
117
|
+
blob,
|
|
118
|
+
payload.ImageUpdateRequestMultiPart.image.fileName,
|
|
119
|
+
);
|
|
120
|
+
} else {
|
|
121
|
+
const contentType =
|
|
122
|
+
getContentTypeFromFileName(
|
|
123
|
+
payload.ImageUpdateRequestMultiPart.image.fileName,
|
|
124
|
+
) || "application/octet-stream";
|
|
125
|
+
appendForm(
|
|
126
|
+
body,
|
|
127
|
+
"image",
|
|
128
|
+
new Blob([payload.ImageUpdateRequestMultiPart.image.content], {
|
|
129
|
+
type: contentType,
|
|
130
|
+
}),
|
|
131
|
+
payload.ImageUpdateRequestMultiPart.image.fileName,
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (payload.ImageUpdateRequestMultiPart.metadata !== undefined) {
|
|
136
|
+
appendForm(
|
|
137
|
+
body,
|
|
138
|
+
"metadata",
|
|
139
|
+
encodeJSON("metadata", payload.ImageUpdateRequestMultiPart.metadata, {
|
|
140
|
+
explode: true,
|
|
141
|
+
}),
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const pathParams = {
|
|
146
|
+
accountID: encodeSimple("accountID", payload.accountID, {
|
|
147
|
+
explode: false,
|
|
148
|
+
charEncoding: "percent",
|
|
149
|
+
}),
|
|
150
|
+
imageID: encodeSimple("imageID", payload.imageID, {
|
|
151
|
+
explode: false,
|
|
152
|
+
charEncoding: "percent",
|
|
153
|
+
}),
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const path = pathToFunc("/accounts/{accountID}/images/{imageID}")(pathParams);
|
|
157
|
+
|
|
158
|
+
const headers = new Headers(compactMap({
|
|
159
|
+
Accept: "application/json",
|
|
160
|
+
"x-moov-version": encodeSimple(
|
|
161
|
+
"x-moov-version",
|
|
162
|
+
client._options.xMoovVersion,
|
|
163
|
+
{ explode: false, charEncoding: "none" },
|
|
164
|
+
),
|
|
165
|
+
}));
|
|
166
|
+
|
|
167
|
+
const securityInput = await extractSecurity(client._options.security);
|
|
168
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
169
|
+
|
|
170
|
+
const context = {
|
|
171
|
+
options: client._options,
|
|
172
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
173
|
+
operationID: "updateImage",
|
|
174
|
+
oAuth2Scopes: null,
|
|
175
|
+
|
|
176
|
+
resolvedSecurity: requestSecurity,
|
|
177
|
+
|
|
178
|
+
securitySource: client._options.security,
|
|
179
|
+
retryConfig: options?.retries
|
|
180
|
+
|| client._options.retryConfig
|
|
181
|
+
|| { strategy: "none" },
|
|
182
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const requestRes = client._createRequest(context, {
|
|
186
|
+
security: requestSecurity,
|
|
187
|
+
method: "PATCH",
|
|
188
|
+
baseURL: options?.serverURL,
|
|
189
|
+
path: path,
|
|
190
|
+
headers: headers,
|
|
191
|
+
body: body,
|
|
192
|
+
userAgent: client._options.userAgent,
|
|
193
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
194
|
+
}, options);
|
|
195
|
+
if (!requestRes.ok) {
|
|
196
|
+
return [requestRes, { status: "invalid" }];
|
|
197
|
+
}
|
|
198
|
+
const req = requestRes.value;
|
|
199
|
+
|
|
200
|
+
const doResult = await client._do(req, {
|
|
201
|
+
context,
|
|
202
|
+
errorCodes: [
|
|
203
|
+
"400",
|
|
204
|
+
"401",
|
|
205
|
+
"403",
|
|
206
|
+
"404",
|
|
207
|
+
"409",
|
|
208
|
+
"422",
|
|
209
|
+
"429",
|
|
210
|
+
"4XX",
|
|
211
|
+
"500",
|
|
212
|
+
"504",
|
|
213
|
+
"5XX",
|
|
214
|
+
],
|
|
215
|
+
retryConfig: context.retryConfig,
|
|
216
|
+
retryCodes: context.retryCodes,
|
|
217
|
+
});
|
|
218
|
+
if (!doResult.ok) {
|
|
219
|
+
return [doResult, { status: "request-error", request: req }];
|
|
220
|
+
}
|
|
221
|
+
const response = doResult.value;
|
|
222
|
+
|
|
223
|
+
const responseFields = {
|
|
224
|
+
HttpMeta: { Response: response, Request: req },
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
const [result] = await M.match<
|
|
228
|
+
operations.UpdateImageResponse,
|
|
229
|
+
| errors.GenericError
|
|
230
|
+
| errors.ImageRequestValidationError
|
|
231
|
+
| MoovError
|
|
232
|
+
| ResponseValidationError
|
|
233
|
+
| ConnectionError
|
|
234
|
+
| RequestAbortedError
|
|
235
|
+
| RequestTimeoutError
|
|
236
|
+
| InvalidRequestError
|
|
237
|
+
| UnexpectedClientError
|
|
238
|
+
| SDKValidationError
|
|
239
|
+
>(
|
|
240
|
+
M.json(200, operations.UpdateImageResponse$inboundSchema, {
|
|
241
|
+
hdrs: true,
|
|
242
|
+
key: "Result",
|
|
243
|
+
}),
|
|
244
|
+
M.jsonErr([400, 409], errors.GenericError$inboundSchema, { hdrs: true }),
|
|
245
|
+
M.jsonErr(422, errors.ImageRequestValidationError$inboundSchema, {
|
|
246
|
+
hdrs: true,
|
|
247
|
+
}),
|
|
248
|
+
M.fail([401, 403, 404, 429]),
|
|
249
|
+
M.fail([500, 504]),
|
|
250
|
+
M.fail("4XX"),
|
|
251
|
+
M.fail("5XX"),
|
|
252
|
+
)(response, req, { extraFields: responseFields });
|
|
253
|
+
if (!result.ok) {
|
|
254
|
+
return [result, { status: "complete", request: req, response }];
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return [result, { status: "complete", request: req, response }];
|
|
258
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { MoovCore } from "../core.js";
|
|
6
|
+
import { appendForm, encodeJSON, encodeSimple } from "../lib/encodings.js";
|
|
7
|
+
import {
|
|
8
|
+
getContentTypeFromFileName,
|
|
9
|
+
readableStreamToArrayBuffer,
|
|
10
|
+
} from "../lib/files.js";
|
|
11
|
+
import * as M from "../lib/matchers.js";
|
|
12
|
+
import { compactMap } from "../lib/primitives.js";
|
|
13
|
+
import { safeParse } from "../lib/schemas.js";
|
|
14
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
15
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
16
|
+
import { pathToFunc } from "../lib/url.js";
|
|
17
|
+
import {
|
|
18
|
+
ConnectionError,
|
|
19
|
+
InvalidRequestError,
|
|
20
|
+
RequestAbortedError,
|
|
21
|
+
RequestTimeoutError,
|
|
22
|
+
UnexpectedClientError,
|
|
23
|
+
} from "../models/errors/httpclienterrors.js";
|
|
24
|
+
import * as errors from "../models/errors/index.js";
|
|
25
|
+
import { MoovError } from "../models/errors/mooverror.js";
|
|
26
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
27
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
28
|
+
import * as operations from "../models/operations/index.js";
|
|
29
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
30
|
+
import { isBlobLike } from "../types/blobs.js";
|
|
31
|
+
import { Result } from "../types/fp.js";
|
|
32
|
+
import { isReadableStream } from "../types/streams.js";
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Upload a new PNG, JPEG, or WebP image with optional metadata.
|
|
36
|
+
* Duplicate images, and requests larger than 16MB will be rejected.
|
|
37
|
+
*/
|
|
38
|
+
export function imagesUpload(
|
|
39
|
+
client: MoovCore,
|
|
40
|
+
request: operations.UploadImageRequest,
|
|
41
|
+
options?: RequestOptions,
|
|
42
|
+
): APIPromise<
|
|
43
|
+
Result<
|
|
44
|
+
operations.UploadImageResponse,
|
|
45
|
+
| errors.GenericError
|
|
46
|
+
| errors.ImageRequestValidationError
|
|
47
|
+
| MoovError
|
|
48
|
+
| ResponseValidationError
|
|
49
|
+
| ConnectionError
|
|
50
|
+
| RequestAbortedError
|
|
51
|
+
| RequestTimeoutError
|
|
52
|
+
| InvalidRequestError
|
|
53
|
+
| UnexpectedClientError
|
|
54
|
+
| SDKValidationError
|
|
55
|
+
>
|
|
56
|
+
> {
|
|
57
|
+
return new APIPromise($do(
|
|
58
|
+
client,
|
|
59
|
+
request,
|
|
60
|
+
options,
|
|
61
|
+
));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function $do(
|
|
65
|
+
client: MoovCore,
|
|
66
|
+
request: operations.UploadImageRequest,
|
|
67
|
+
options?: RequestOptions,
|
|
68
|
+
): Promise<
|
|
69
|
+
[
|
|
70
|
+
Result<
|
|
71
|
+
operations.UploadImageResponse,
|
|
72
|
+
| errors.GenericError
|
|
73
|
+
| errors.ImageRequestValidationError
|
|
74
|
+
| MoovError
|
|
75
|
+
| ResponseValidationError
|
|
76
|
+
| ConnectionError
|
|
77
|
+
| RequestAbortedError
|
|
78
|
+
| RequestTimeoutError
|
|
79
|
+
| InvalidRequestError
|
|
80
|
+
| UnexpectedClientError
|
|
81
|
+
| SDKValidationError
|
|
82
|
+
>,
|
|
83
|
+
APICall,
|
|
84
|
+
]
|
|
85
|
+
> {
|
|
86
|
+
const parsed = safeParse(
|
|
87
|
+
request,
|
|
88
|
+
(value) => operations.UploadImageRequest$outboundSchema.parse(value),
|
|
89
|
+
"Input validation failed",
|
|
90
|
+
);
|
|
91
|
+
if (!parsed.ok) {
|
|
92
|
+
return [parsed, { status: "invalid" }];
|
|
93
|
+
}
|
|
94
|
+
const payload = parsed.value;
|
|
95
|
+
const body = new FormData();
|
|
96
|
+
|
|
97
|
+
if (isBlobLike(payload.ImageUploadRequestMultiPart.image)) {
|
|
98
|
+
appendForm(body, "image", payload.ImageUploadRequestMultiPart.image);
|
|
99
|
+
} else if (
|
|
100
|
+
isReadableStream(payload.ImageUploadRequestMultiPart.image.content)
|
|
101
|
+
) {
|
|
102
|
+
const buffer = await readableStreamToArrayBuffer(
|
|
103
|
+
payload.ImageUploadRequestMultiPart.image.content,
|
|
104
|
+
);
|
|
105
|
+
const contentType =
|
|
106
|
+
getContentTypeFromFileName(
|
|
107
|
+
payload.ImageUploadRequestMultiPart.image.fileName,
|
|
108
|
+
) || "application/octet-stream";
|
|
109
|
+
const blob = new Blob([buffer], { type: contentType });
|
|
110
|
+
appendForm(
|
|
111
|
+
body,
|
|
112
|
+
"image",
|
|
113
|
+
blob,
|
|
114
|
+
payload.ImageUploadRequestMultiPart.image.fileName,
|
|
115
|
+
);
|
|
116
|
+
} else {
|
|
117
|
+
const contentType =
|
|
118
|
+
getContentTypeFromFileName(
|
|
119
|
+
payload.ImageUploadRequestMultiPart.image.fileName,
|
|
120
|
+
) || "application/octet-stream";
|
|
121
|
+
appendForm(
|
|
122
|
+
body,
|
|
123
|
+
"image",
|
|
124
|
+
new Blob([payload.ImageUploadRequestMultiPart.image.content], {
|
|
125
|
+
type: contentType,
|
|
126
|
+
}),
|
|
127
|
+
payload.ImageUploadRequestMultiPart.image.fileName,
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
if (payload.ImageUploadRequestMultiPart.metadata !== undefined) {
|
|
131
|
+
appendForm(
|
|
132
|
+
body,
|
|
133
|
+
"metadata",
|
|
134
|
+
encodeJSON("metadata", payload.ImageUploadRequestMultiPart.metadata, {
|
|
135
|
+
explode: true,
|
|
136
|
+
}),
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const pathParams = {
|
|
141
|
+
accountID: encodeSimple("accountID", payload.accountID, {
|
|
142
|
+
explode: false,
|
|
143
|
+
charEncoding: "percent",
|
|
144
|
+
}),
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const path = pathToFunc("/accounts/{accountID}/images")(pathParams);
|
|
148
|
+
|
|
149
|
+
const headers = new Headers(compactMap({
|
|
150
|
+
Accept: "application/json",
|
|
151
|
+
"x-moov-version": encodeSimple(
|
|
152
|
+
"x-moov-version",
|
|
153
|
+
client._options.xMoovVersion,
|
|
154
|
+
{ explode: false, charEncoding: "none" },
|
|
155
|
+
),
|
|
156
|
+
}));
|
|
157
|
+
|
|
158
|
+
const securityInput = await extractSecurity(client._options.security);
|
|
159
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
160
|
+
|
|
161
|
+
const context = {
|
|
162
|
+
options: client._options,
|
|
163
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
164
|
+
operationID: "uploadImage",
|
|
165
|
+
oAuth2Scopes: null,
|
|
166
|
+
|
|
167
|
+
resolvedSecurity: requestSecurity,
|
|
168
|
+
|
|
169
|
+
securitySource: client._options.security,
|
|
170
|
+
retryConfig: options?.retries
|
|
171
|
+
|| client._options.retryConfig
|
|
172
|
+
|| { strategy: "none" },
|
|
173
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const requestRes = client._createRequest(context, {
|
|
177
|
+
security: requestSecurity,
|
|
178
|
+
method: "POST",
|
|
179
|
+
baseURL: options?.serverURL,
|
|
180
|
+
path: path,
|
|
181
|
+
headers: headers,
|
|
182
|
+
body: body,
|
|
183
|
+
userAgent: client._options.userAgent,
|
|
184
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
185
|
+
}, options);
|
|
186
|
+
if (!requestRes.ok) {
|
|
187
|
+
return [requestRes, { status: "invalid" }];
|
|
188
|
+
}
|
|
189
|
+
const req = requestRes.value;
|
|
190
|
+
|
|
191
|
+
const doResult = await client._do(req, {
|
|
192
|
+
context,
|
|
193
|
+
errorCodes: [
|
|
194
|
+
"400",
|
|
195
|
+
"401",
|
|
196
|
+
"403",
|
|
197
|
+
"404",
|
|
198
|
+
"409",
|
|
199
|
+
"422",
|
|
200
|
+
"429",
|
|
201
|
+
"4XX",
|
|
202
|
+
"500",
|
|
203
|
+
"504",
|
|
204
|
+
"5XX",
|
|
205
|
+
],
|
|
206
|
+
retryConfig: context.retryConfig,
|
|
207
|
+
retryCodes: context.retryCodes,
|
|
208
|
+
});
|
|
209
|
+
if (!doResult.ok) {
|
|
210
|
+
return [doResult, { status: "request-error", request: req }];
|
|
211
|
+
}
|
|
212
|
+
const response = doResult.value;
|
|
213
|
+
|
|
214
|
+
const responseFields = {
|
|
215
|
+
HttpMeta: { Response: response, Request: req },
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
const [result] = await M.match<
|
|
219
|
+
operations.UploadImageResponse,
|
|
220
|
+
| errors.GenericError
|
|
221
|
+
| errors.ImageRequestValidationError
|
|
222
|
+
| MoovError
|
|
223
|
+
| ResponseValidationError
|
|
224
|
+
| ConnectionError
|
|
225
|
+
| RequestAbortedError
|
|
226
|
+
| RequestTimeoutError
|
|
227
|
+
| InvalidRequestError
|
|
228
|
+
| UnexpectedClientError
|
|
229
|
+
| SDKValidationError
|
|
230
|
+
>(
|
|
231
|
+
M.json(201, operations.UploadImageResponse$inboundSchema, {
|
|
232
|
+
hdrs: true,
|
|
233
|
+
key: "Result",
|
|
234
|
+
}),
|
|
235
|
+
M.jsonErr([400, 409], errors.GenericError$inboundSchema, { hdrs: true }),
|
|
236
|
+
M.jsonErr(422, errors.ImageRequestValidationError$inboundSchema, {
|
|
237
|
+
hdrs: true,
|
|
238
|
+
}),
|
|
239
|
+
M.fail([401, 403, 404, 429]),
|
|
240
|
+
M.fail([500, 504]),
|
|
241
|
+
M.fail("4XX"),
|
|
242
|
+
M.fail("5XX"),
|
|
243
|
+
)(response, req, { extraFields: responseFields });
|
|
244
|
+
if (!result.ok) {
|
|
245
|
+
return [result, { status: "complete", request: req, response }];
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return [result, { status: "complete", request: req, response }];
|
|
249
|
+
}
|
package/src/lib/config.ts
CHANGED
|
@@ -73,7 +73,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
|
73
73
|
export const SDK_METADATA = {
|
|
74
74
|
language: "typescript",
|
|
75
75
|
openapiDocVersion: "latest",
|
|
76
|
-
sdkVersion: "0.
|
|
77
|
-
genVersion: "2.
|
|
78
|
-
userAgent: "speakeasy-sdk/typescript 0.
|
|
76
|
+
sdkVersion: "0.17.0",
|
|
77
|
+
genVersion: "2.727.4",
|
|
78
|
+
userAgent: "speakeasy-sdk/typescript 0.17.0 2.727.4 latest @moovio/sdk",
|
|
79
79
|
} as const;
|
package/src/mcp-server/server.ts
CHANGED
|
@@ -92,6 +92,8 @@ import { tool$imagesDelete } from "./tools/imagesDelete.js";
|
|
|
92
92
|
import { tool$imagesGetMetadata } from "./tools/imagesGetMetadata.js";
|
|
93
93
|
import { tool$imagesGetPublic } from "./tools/imagesGetPublic.js";
|
|
94
94
|
import { tool$imagesList } from "./tools/imagesList.js";
|
|
95
|
+
import { tool$imagesUpdate } from "./tools/imagesUpdate.js";
|
|
96
|
+
import { tool$imagesUpload } from "./tools/imagesUpload.js";
|
|
95
97
|
import { tool$industriesList } from "./tools/industriesList.js";
|
|
96
98
|
import { tool$institutionsSearch } from "./tools/institutionsSearch.js";
|
|
97
99
|
import { tool$institutionsSearchInstitutions } from "./tools/institutionsSearchInstitutions.js";
|
|
@@ -181,7 +183,7 @@ export function createMCPServer(deps: {
|
|
|
181
183
|
}) {
|
|
182
184
|
const server = new McpServer({
|
|
183
185
|
name: "Moov",
|
|
184
|
-
version: "0.
|
|
186
|
+
version: "0.17.0",
|
|
185
187
|
});
|
|
186
188
|
|
|
187
189
|
const client = new MoovCore({
|
|
@@ -272,7 +274,9 @@ export function createMCPServer(deps: {
|
|
|
272
274
|
tool(tool$filesList);
|
|
273
275
|
tool(tool$filesGet);
|
|
274
276
|
tool(tool$imagesList);
|
|
277
|
+
tool(tool$imagesUpload);
|
|
275
278
|
tool(tool$imagesGetMetadata);
|
|
279
|
+
tool(tool$imagesUpdate);
|
|
276
280
|
tool(tool$imagesDelete);
|
|
277
281
|
tool(tool$imagesGetPublic);
|
|
278
282
|
tool(tool$paymentLinksCreate);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { imagesUpdate } from "../../funcs/imagesUpdate.js";
|
|
6
|
+
import * as operations from "../../models/operations/index.js";
|
|
7
|
+
import { formatResult, ToolDefinition } from "../tools.js";
|
|
8
|
+
|
|
9
|
+
const args = {
|
|
10
|
+
request: operations.UpdateImageRequest$inboundSchema,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const tool$imagesUpdate: ToolDefinition<typeof args> = {
|
|
14
|
+
name: "images-update",
|
|
15
|
+
description: `Update an existing image and/or its metadata.
|
|
16
|
+
|
|
17
|
+
Duplicate images, and requests larger than 16MB will be rejected. Omit any
|
|
18
|
+
form parts you do not wish to update. Existing metadata can be cleared by
|
|
19
|
+
sending \`null\` for the \`metadata\` form part.`,
|
|
20
|
+
args,
|
|
21
|
+
tool: async (client, args, ctx) => {
|
|
22
|
+
const [result, apiCall] = await imagesUpdate(
|
|
23
|
+
client,
|
|
24
|
+
args.request,
|
|
25
|
+
{ fetchOptions: { signal: ctx.signal } },
|
|
26
|
+
).$inspect();
|
|
27
|
+
|
|
28
|
+
if (!result.ok) {
|
|
29
|
+
return {
|
|
30
|
+
content: [{ type: "text", text: result.error.message }],
|
|
31
|
+
isError: true,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const value = result.value.result;
|
|
36
|
+
|
|
37
|
+
return formatResult(value, apiCall);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { imagesUpload } from "../../funcs/imagesUpload.js";
|
|
6
|
+
import * as operations from "../../models/operations/index.js";
|
|
7
|
+
import { formatResult, ToolDefinition } from "../tools.js";
|
|
8
|
+
|
|
9
|
+
const args = {
|
|
10
|
+
request: operations.UploadImageRequest$inboundSchema,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const tool$imagesUpload: ToolDefinition<typeof args> = {
|
|
14
|
+
name: "images-upload",
|
|
15
|
+
description: ` Upload a new PNG, JPEG, or WebP image with optional metadata.
|
|
16
|
+
Duplicate images, and requests larger than 16MB will be rejected.`,
|
|
17
|
+
args,
|
|
18
|
+
tool: async (client, args, ctx) => {
|
|
19
|
+
const [result, apiCall] = await imagesUpload(
|
|
20
|
+
client,
|
|
21
|
+
args.request,
|
|
22
|
+
{ fetchOptions: { signal: ctx.signal } },
|
|
23
|
+
).$inspect();
|
|
24
|
+
|
|
25
|
+
if (!result.ok) {
|
|
26
|
+
return {
|
|
27
|
+
content: [{ type: "text", text: result.error.message }],
|
|
28
|
+
isError: true,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const value = result.value.result;
|
|
33
|
+
|
|
34
|
+
return formatResult(value, apiCall);
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -6,6 +6,12 @@ import * as z from "zod";
|
|
|
6
6
|
import { safeParse } from "../../lib/schemas.js";
|
|
7
7
|
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
8
8
|
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
9
|
+
import {
|
|
10
|
+
AmountDecimal,
|
|
11
|
+
AmountDecimal$inboundSchema,
|
|
12
|
+
AmountDecimal$Outbound,
|
|
13
|
+
AmountDecimal$outboundSchema,
|
|
14
|
+
} from "./amountdecimal.js";
|
|
9
15
|
import {
|
|
10
16
|
AssignProductImage,
|
|
11
17
|
AssignProductImage$inboundSchema,
|
|
@@ -31,7 +37,7 @@ export type CreateProductOption = {
|
|
|
31
37
|
/**
|
|
32
38
|
* The adjustment applied to a product's base price by this option. Can be negative, positive, or zero.
|
|
33
39
|
*/
|
|
34
|
-
priceModifier?:
|
|
40
|
+
priceModifier?: AmountDecimal | undefined;
|
|
35
41
|
/**
|
|
36
42
|
* Assign previously uploaded images to a product or option.
|
|
37
43
|
*/
|
|
@@ -46,7 +52,7 @@ export const CreateProductOption$inboundSchema: z.ZodType<
|
|
|
46
52
|
> = z.object({
|
|
47
53
|
name: z.string(),
|
|
48
54
|
description: z.string().optional(),
|
|
49
|
-
priceModifier:
|
|
55
|
+
priceModifier: AmountDecimal$inboundSchema.optional(),
|
|
50
56
|
images: z.array(AssignProductImage$inboundSchema).optional(),
|
|
51
57
|
});
|
|
52
58
|
|
|
@@ -54,7 +60,7 @@ export const CreateProductOption$inboundSchema: z.ZodType<
|
|
|
54
60
|
export type CreateProductOption$Outbound = {
|
|
55
61
|
name: string;
|
|
56
62
|
description?: string | undefined;
|
|
57
|
-
priceModifier?:
|
|
63
|
+
priceModifier?: AmountDecimal$Outbound | undefined;
|
|
58
64
|
images?: Array<AssignProductImage$Outbound> | undefined;
|
|
59
65
|
};
|
|
60
66
|
|
|
@@ -66,7 +72,7 @@ export const CreateProductOption$outboundSchema: z.ZodType<
|
|
|
66
72
|
> = z.object({
|
|
67
73
|
name: z.string(),
|
|
68
74
|
description: z.string().optional(),
|
|
69
|
-
priceModifier:
|
|
75
|
+
priceModifier: AmountDecimal$outboundSchema.optional(),
|
|
70
76
|
images: z.array(AssignProductImage$outboundSchema).optional(),
|
|
71
77
|
});
|
|
72
78
|
|