screenshotone-api-sdk 1.0.29 → 1.0.30

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.
@@ -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<void>;
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;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "screenshotone-api-sdk",
3
3
  "homepage": "https://screenshotone.com",
4
- "version": "1.0.29",
4
+ "version": "1.0.30",
5
5
  "description": "Use ScreenshotOne.com API to generate screenshots of any website.",
6
6
  "repository": {
7
7
  "type": "git",
package/src/main.ts CHANGED
@@ -121,10 +121,17 @@ export class Client {
121
121
  * @param options
122
122
  * @returns
123
123
  */
124
- async store(options: AnimateOptions | TakeOptions, path: string, bucket?: string, acl?: "public-read" | "", storageClass?: string) {
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