@sprucelabs/spruce-file-utils 15.1.23 → 15.1.25

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.
@@ -4,7 +4,7 @@ import { MercuryEventEmitter } from '@sprucelabs/mercury-types';
4
4
  import { UploadedFile } from '../files.types';
5
5
  export default class ChunkingUploaderImpl extends AbstractEventEmitter<ChunkingUploaderEventContract> implements ChunkingUploader {
6
6
  private connectToApi;
7
- static fetch: typeof fetch;
7
+ static fetch: (...args: any[]) => Promise<Response>;
8
8
  static chunkSizeKb: number;
9
9
  static Class?: new (connectToApi: MercuryConnectFactory) => ChunkingUploader;
10
10
  private restEndpointUrl?;
@@ -122,7 +122,8 @@ class ChunkingUploaderImpl extends AbstractEventEmitter {
122
122
  }
123
123
  post(path, postBody, headers) {
124
124
  return __awaiter(this, void 0, void 0, function* () {
125
- const response = yield this.fetch(this.restEndpointUrl + path, {
125
+ const url = this.restEndpointUrl + '/v1/uploads' + path;
126
+ const response = yield this.fetch(url, {
126
127
  headers: Object.assign({ 'Content-Type': 'application/json' }, headers),
127
128
  method: 'POST',
128
129
  body: JSON.stringify(postBody),
@@ -132,7 +133,7 @@ class ChunkingUploaderImpl extends AbstractEventEmitter {
132
133
  throw new SpruceError({
133
134
  code: response.status === 400 ? 'BAD_REQUEST' : 'UNAUTHORIZED',
134
135
  friendlyMessage: body.errorMessage,
135
- endpoint: this.restEndpointUrl + path,
136
+ endpoint: url,
136
137
  });
137
138
  }
138
139
  return body;
@@ -142,7 +143,8 @@ class ChunkingUploaderImpl extends AbstractEventEmitter {
142
143
  return ChunkingUploaderImpl.fetch;
143
144
  }
144
145
  }
145
- ChunkingUploaderImpl.fetch = fetch;
146
+ //@ts-ignore
147
+ ChunkingUploaderImpl.fetch = (...args) => fetch(...args);
146
148
  ChunkingUploaderImpl.chunkSizeKb = 1024;
147
149
  export default ChunkingUploaderImpl;
148
150
  export const chunkingUploaderEventContract = buildEventContract({
@@ -4,7 +4,7 @@ import { MercuryEventEmitter } from '@sprucelabs/mercury-types';
4
4
  import { UploadedFile } from '../files.types';
5
5
  export default class ChunkingUploaderImpl extends AbstractEventEmitter<ChunkingUploaderEventContract> implements ChunkingUploader {
6
6
  private connectToApi;
7
- static fetch: typeof fetch;
7
+ static fetch: (...args: any[]) => Promise<Response>;
8
8
  static chunkSizeKb: number;
9
9
  static Class?: new (connectToApi: MercuryConnectFactory) => ChunkingUploader;
10
10
  private restEndpointUrl?;
@@ -107,7 +107,8 @@ class ChunkingUploaderImpl extends mercury_event_emitter_1.AbstractEventEmitter
107
107
  return client;
108
108
  }
109
109
  async post(path, postBody, headers) {
110
- const response = await this.fetch(this.restEndpointUrl + path, {
110
+ const url = this.restEndpointUrl + '/v1/uploads' + path;
111
+ const response = await this.fetch(url, {
111
112
  headers: {
112
113
  'Content-Type': 'application/json',
113
114
  ...headers,
@@ -120,7 +121,7 @@ class ChunkingUploaderImpl extends mercury_event_emitter_1.AbstractEventEmitter
120
121
  throw new SpruceError_1.default({
121
122
  code: response.status === 400 ? 'BAD_REQUEST' : 'UNAUTHORIZED',
122
123
  friendlyMessage: body.errorMessage,
123
- endpoint: this.restEndpointUrl + path,
124
+ endpoint: url,
124
125
  });
125
126
  }
126
127
  return body;
@@ -129,7 +130,8 @@ class ChunkingUploaderImpl extends mercury_event_emitter_1.AbstractEventEmitter
129
130
  return ChunkingUploaderImpl.fetch;
130
131
  }
131
132
  }
132
- ChunkingUploaderImpl.fetch = fetch;
133
+ //@ts-ignore
134
+ ChunkingUploaderImpl.fetch = (...args) => fetch(...args);
133
135
  ChunkingUploaderImpl.chunkSizeKb = 1024;
134
136
  exports.default = ChunkingUploaderImpl;
135
137
  exports.chunkingUploaderEventContract = (0, mercury_types_1.buildEventContract)({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sprucelabs/spruce-file-utils",
3
3
  "description": "Utils for working with files and Sprucebot.",
4
- "version": "15.1.23",
4
+ "version": "15.1.25",
5
5
  "skill": {
6
6
  "namespace": "files"
7
7
  },