@examplary/sdk 2.2.0 → 2.3.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/dist/index.d.mts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +39 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -5477,6 +5477,17 @@ interface operations {
|
|
|
5477
5477
|
};
|
|
5478
5478
|
}
|
|
5479
5479
|
|
|
5480
|
+
type Args$1 = {
|
|
5481
|
+
filename?: string;
|
|
5482
|
+
type?: string;
|
|
5483
|
+
contentType?: string;
|
|
5484
|
+
content?: Buffer | string;
|
|
5485
|
+
};
|
|
5486
|
+
type Response$1 = {
|
|
5487
|
+
publicUrl: string;
|
|
5488
|
+
uploadUrl: string;
|
|
5489
|
+
};
|
|
5490
|
+
|
|
5480
5491
|
interface _PathOverrides {
|
|
5481
5492
|
"questionTypes.get": {
|
|
5482
5493
|
id: string;
|
|
@@ -6036,7 +6047,7 @@ declare class Media {
|
|
|
6036
6047
|
*
|
|
6037
6048
|
* API endpoint: `GET /media/upload`
|
|
6038
6049
|
*/
|
|
6039
|
-
upload(args
|
|
6050
|
+
upload(args: Args$1, options?: ExamplaryRequestOptions): Promise<Response$1>;
|
|
6040
6051
|
}
|
|
6041
6052
|
declare class OrgCustomDomain {
|
|
6042
6053
|
private readonly ctx;
|
package/dist/index.d.ts
CHANGED
|
@@ -5477,6 +5477,17 @@ interface operations {
|
|
|
5477
5477
|
};
|
|
5478
5478
|
}
|
|
5479
5479
|
|
|
5480
|
+
type Args$1 = {
|
|
5481
|
+
filename?: string;
|
|
5482
|
+
type?: string;
|
|
5483
|
+
contentType?: string;
|
|
5484
|
+
content?: Buffer | string;
|
|
5485
|
+
};
|
|
5486
|
+
type Response$1 = {
|
|
5487
|
+
publicUrl: string;
|
|
5488
|
+
uploadUrl: string;
|
|
5489
|
+
};
|
|
5490
|
+
|
|
5480
5491
|
interface _PathOverrides {
|
|
5481
5492
|
"questionTypes.get": {
|
|
5482
5493
|
id: string;
|
|
@@ -6036,7 +6047,7 @@ declare class Media {
|
|
|
6036
6047
|
*
|
|
6037
6048
|
* API endpoint: `GET /media/upload`
|
|
6038
6049
|
*/
|
|
6039
|
-
upload(args
|
|
6050
|
+
upload(args: Args$1, options?: ExamplaryRequestOptions): Promise<Response$1>;
|
|
6040
6051
|
}
|
|
6041
6052
|
declare class OrgCustomDomain {
|
|
6042
6053
|
private readonly ctx;
|
package/dist/index.js
CHANGED
|
@@ -123,6 +123,36 @@ var request = async (ctx, method, pathTemplate, pathKeys, queryKeys, hasBody, ar
|
|
|
123
123
|
return response.data;
|
|
124
124
|
};
|
|
125
125
|
|
|
126
|
+
// src/overrides/media.upload.ts
|
|
127
|
+
var override = async (ctx, args, options) => {
|
|
128
|
+
const contentType = args.contentType ?? "application/octet-stream";
|
|
129
|
+
const { data } = await ctx.axios.request({
|
|
130
|
+
...options,
|
|
131
|
+
method: "GET",
|
|
132
|
+
url: "/media/upload",
|
|
133
|
+
params: {
|
|
134
|
+
contentType,
|
|
135
|
+
...args.filename ? { filename: args.filename } : {},
|
|
136
|
+
...args.type ? { type: args.type } : {}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
if (args.content) {
|
|
140
|
+
const body = typeof Buffer !== "undefined" && !Buffer.isBuffer(args.content) ? Buffer.from(args.content) : args.content;
|
|
141
|
+
const uploadRes = await fetch(data.uploadUrl, {
|
|
142
|
+
method: "PUT",
|
|
143
|
+
headers: { "Content-Type": contentType },
|
|
144
|
+
body
|
|
145
|
+
});
|
|
146
|
+
if (!uploadRes.ok) {
|
|
147
|
+
throw new ExamplaryError(
|
|
148
|
+
`Upload failed: ${await uploadRes.text()}`,
|
|
149
|
+
"UploadError"
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return data;
|
|
154
|
+
};
|
|
155
|
+
|
|
126
156
|
// generated/sdk.ts
|
|
127
157
|
var QuestionTypes = class {
|
|
128
158
|
constructor(ctx) {
|
|
@@ -275,9 +305,15 @@ var Media = class {
|
|
|
275
305
|
constructor(ctx) {
|
|
276
306
|
this.ctx = ctx;
|
|
277
307
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
308
|
+
/**
|
|
309
|
+
* Get file upload URL
|
|
310
|
+
*
|
|
311
|
+
* Returns a signed URL for uploading a file, and a public URL for accessing it afterwards.
|
|
312
|
+
*
|
|
313
|
+
* API endpoint: `GET /media/upload`
|
|
314
|
+
*/
|
|
315
|
+
upload(args, options) {
|
|
316
|
+
return override(this.ctx, args, options);
|
|
281
317
|
}
|
|
282
318
|
};
|
|
283
319
|
var OrgCustomDomain = class {
|