screenshotone-api-sdk 1.0.29 → 1.0.31
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/@types/main.d.ts +4 -1
- package/dist/main.js +17 -2
- package/package.json +1 -1
- package/src/main.ts +26 -3
package/dist/@types/main.d.ts
CHANGED
|
@@ -50,7 +50,10 @@ export declare class Client {
|
|
|
50
50
|
* @param options
|
|
51
51
|
* @returns
|
|
52
52
|
*/
|
|
53
|
-
store(options: AnimateOptions | TakeOptions, path: string, bucket?: string, acl?: "public-read" | "", storageClass?: string): Promise<
|
|
53
|
+
store(options: AnimateOptions | TakeOptions, path: string, bucket?: string, acl?: "public-read" | "", storageClass?: string): Promise<{
|
|
54
|
+
bucket: string | null;
|
|
55
|
+
key: string | null;
|
|
56
|
+
}>;
|
|
54
57
|
}
|
|
55
58
|
/**
|
|
56
59
|
* Represents options for taking screenshots.
|
package/dist/main.js
CHANGED
|
@@ -132,7 +132,8 @@ class Client {
|
|
|
132
132
|
async store(options, path, bucket, acl, storageClass) {
|
|
133
133
|
options
|
|
134
134
|
.store(true)
|
|
135
|
-
.storagePath(path)
|
|
135
|
+
.storagePath(path)
|
|
136
|
+
.responseType('empty');
|
|
136
137
|
if (bucket) {
|
|
137
138
|
options.storageBucket(bucket);
|
|
138
139
|
}
|
|
@@ -145,6 +146,15 @@ class Client {
|
|
|
145
146
|
const url = (options instanceof TakeOptions)
|
|
146
147
|
? this.generateSignedTakeURL(options)
|
|
147
148
|
: this.generateSignedAnimateURL(options);
|
|
149
|
+
const response = await (0, cross_fetch_1.default)(url);
|
|
150
|
+
if (response.ok) {
|
|
151
|
+
return {
|
|
152
|
+
key: response.headers.get('X-ScreenshotOne-Store-Key'),
|
|
153
|
+
bucket: response.headers.get('X-ScreenshotOne-Store-Bucket'),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
const data = await response.json();
|
|
157
|
+
throw new Error(`failed to take screenshot, response returned ${response.status} ${response.statusText}: ${data?.message}`);
|
|
148
158
|
}
|
|
149
159
|
}
|
|
150
160
|
exports.Client = Client;
|
|
@@ -601,7 +611,12 @@ class AnimateOptions {
|
|
|
601
611
|
}
|
|
602
612
|
put(key, ...values) {
|
|
603
613
|
for (const value of values) {
|
|
604
|
-
|
|
614
|
+
if (values.length == 1) {
|
|
615
|
+
this.query.set(key, value);
|
|
616
|
+
}
|
|
617
|
+
else {
|
|
618
|
+
this.query.append(key, value);
|
|
619
|
+
}
|
|
605
620
|
}
|
|
606
621
|
}
|
|
607
622
|
;
|
package/package.json
CHANGED
package/src/main.ts
CHANGED
|
@@ -121,10 +121,17 @@ export class Client {
|
|
|
121
121
|
* @param options
|
|
122
122
|
* @returns
|
|
123
123
|
*/
|
|
124
|
-
async store(
|
|
124
|
+
async store(
|
|
125
|
+
options: AnimateOptions | TakeOptions,
|
|
126
|
+
path: string,
|
|
127
|
+
bucket?: string,
|
|
128
|
+
acl?: "public-read" | "",
|
|
129
|
+
storageClass?: string
|
|
130
|
+
): Promise<{ bucket: string | null, key: string | null }> {
|
|
125
131
|
options
|
|
126
132
|
.store(true)
|
|
127
|
-
.storagePath(path)
|
|
133
|
+
.storagePath(path)
|
|
134
|
+
.responseType('empty');
|
|
128
135
|
|
|
129
136
|
if (bucket) {
|
|
130
137
|
options.storageBucket(bucket);
|
|
@@ -139,6 +146,18 @@ export class Client {
|
|
|
139
146
|
const url = (options instanceof TakeOptions)
|
|
140
147
|
? this.generateSignedTakeURL(options)
|
|
141
148
|
: this.generateSignedAnimateURL(options);
|
|
149
|
+
|
|
150
|
+
const response = await fetch(url);
|
|
151
|
+
if (response.ok) {
|
|
152
|
+
return {
|
|
153
|
+
key: response.headers.get('X-ScreenshotOne-Store-Key'),
|
|
154
|
+
bucket: response.headers.get('X-ScreenshotOne-Store-Bucket'),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const data = await response.json();
|
|
159
|
+
|
|
160
|
+
throw new Error(`failed to take screenshot, response returned ${response.status} ${response.statusText}: ${data?.message}`);
|
|
142
161
|
}
|
|
143
162
|
}
|
|
144
163
|
|
|
@@ -715,7 +734,11 @@ export class AnimateOptions {
|
|
|
715
734
|
|
|
716
735
|
private put(key: string, ...values: string[]) {
|
|
717
736
|
for (const value of values) {
|
|
718
|
-
|
|
737
|
+
if (values.length == 1) {
|
|
738
|
+
this.query.set(key, value);
|
|
739
|
+
} else {
|
|
740
|
+
this.query.append(key, value);
|
|
741
|
+
}
|
|
719
742
|
}
|
|
720
743
|
};
|
|
721
744
|
|