filestack-js 4.1.4 → 4.2.4

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.
Files changed (70) hide show
  1. package/build/browser/filestack.esm.js +1 -1
  2. package/build/browser/filestack.esm.js.map +1 -1
  3. package/build/browser/filestack.min.js +1 -1
  4. package/build/browser/filestack.min.js.map +1 -1
  5. package/build/browser/filestack.umd.js +1 -1
  6. package/build/browser/filestack.umd.js.map +1 -1
  7. package/build/browser/manifest.json +2 -2
  8. package/build/main/config.js +2 -2
  9. package/build/main/index.d.ts +1 -1
  10. package/build/main/index.js +2 -2
  11. package/build/main/lib/api/store.js +9 -1
  12. package/build/main/lib/api/upload/file_tools.browser.d.ts +1 -1
  13. package/build/main/lib/api/upload/file_tools.browser.js +3 -3
  14. package/build/main/lib/api/upload/file_tools.node.d.ts +1 -1
  15. package/build/main/lib/api/upload/file_tools.node.js +4 -4
  16. package/build/main/lib/api/upload/types.d.ts +8 -1
  17. package/build/main/lib/api/upload/types.js +1 -1
  18. package/build/main/lib/api/upload/upload.d.ts +15 -2
  19. package/build/main/lib/api/upload/upload.js +17 -7
  20. package/build/main/lib/client.js +2 -2
  21. package/build/main/lib/client.spec.js +5 -7
  22. package/build/main/lib/picker.d.ts +5 -0
  23. package/build/main/lib/picker.js +1 -1
  24. package/build/main/lib/utils/index.browser.js +1 -1
  25. package/build/main/lib/utils/index.node.js +1 -1
  26. package/build/main/lib/utils/index.spec.browser.js +1 -1
  27. package/build/main/schema/picker.schema.d.ts +3 -4
  28. package/build/main/schema/picker.schema.js +4 -1
  29. package/build/main/schema/store.schema.d.ts +8 -0
  30. package/build/main/schema/store.schema.js +9 -1
  31. package/build/main/schema/upload.schema.d.ts +0 -4
  32. package/build/main/schema/upload.schema.js +1 -5
  33. package/build/module/config.js +2 -2
  34. package/build/module/index.d.ts +1 -1
  35. package/build/module/index.js +2 -2
  36. package/build/module/lib/api/store.js +9 -1
  37. package/build/module/lib/api/upload/file_tools.browser.d.ts +1 -1
  38. package/build/module/lib/api/upload/file_tools.browser.js +3 -3
  39. package/build/module/lib/api/upload/file_tools.node.d.ts +1 -1
  40. package/build/module/lib/api/upload/file_tools.node.js +4 -4
  41. package/build/module/lib/api/upload/types.d.ts +8 -1
  42. package/build/module/lib/api/upload/types.js +1 -1
  43. package/build/module/lib/api/upload/upload.d.ts +15 -2
  44. package/build/module/lib/api/upload/upload.js +17 -7
  45. package/build/module/lib/client.js +2 -2
  46. package/build/module/lib/client.spec.js +5 -7
  47. package/build/module/lib/picker.d.ts +5 -0
  48. package/build/module/lib/picker.js +1 -1
  49. package/build/module/lib/utils/index.browser.js +1 -1
  50. package/build/module/lib/utils/index.node.js +1 -1
  51. package/build/module/lib/utils/index.spec.browser.js +1 -1
  52. package/build/module/schema/picker.schema.d.ts +3 -4
  53. package/build/module/schema/picker.schema.js +4 -1
  54. package/build/module/schema/store.schema.d.ts +8 -0
  55. package/build/module/schema/store.schema.js +9 -1
  56. package/build/module/schema/upload.schema.d.ts +0 -4
  57. package/build/module/schema/upload.schema.js +1 -5
  58. package/package.json +1 -1
  59. package/src/config.ts +1 -1
  60. package/src/lib/api/store.ts +10 -1
  61. package/src/lib/api/upload/file_tools.browser.ts +2 -2
  62. package/src/lib/api/upload/file_tools.node.ts +3 -3
  63. package/src/lib/api/upload/types.ts +10 -2
  64. package/src/lib/api/upload/upload.ts +37 -6
  65. package/src/lib/client.spec.ts +4 -6
  66. package/src/lib/client.ts +1 -1
  67. package/src/lib/picker.ts +5 -0
  68. package/src/schema/picker.schema.ts +3 -0
  69. package/src/schema/store.schema.ts +8 -0
  70. package/src/schema/upload.schema.ts +0 -4
@@ -67,6 +67,22 @@ export class Upload extends EventEmitter {
67
67
  */
68
68
  private overrideFileName;
69
69
 
70
+ /**
71
+ * Mimetype of the file
72
+ *
73
+ * @private
74
+ * @memberof Upload
75
+ */
76
+ private mimetype;
77
+
78
+ /**
79
+ * Alt Text of the file
80
+ *
81
+ * @private
82
+ * @memberof Upload
83
+ */
84
+ private altText;
85
+
70
86
  private lastProgress: ProgressEvent = {
71
87
  totalBytes: 0,
72
88
  totalPercent: 0,
@@ -102,6 +118,16 @@ export class Upload extends EventEmitter {
102
118
  delete this.storeOptions.sanitizer;
103
119
  }
104
120
 
121
+ if (storeOptions.altText) {
122
+ this.altText = storeOptions.altText;
123
+ delete this.storeOptions.altText;
124
+ }
125
+
126
+ if (storeOptions.mimetype) {
127
+ this.mimetype = storeOptions.mimetype;
128
+ delete this.storeOptions.mimetype;
129
+ }
130
+
105
131
  this.uploader = new S3Uploader(this.storeOptions, options.concurrency);
106
132
 
107
133
  this.uploader.setRetryConfig({
@@ -199,16 +225,16 @@ export class Upload extends EventEmitter {
199
225
  * Upload single file
200
226
  *
201
227
  * @param {(InputFile)} file
202
- * @param {(string)} altText
203
228
  * @returns {Promise<any>}
204
229
  * @memberof Upload
205
230
  */
206
- async upload(input: InputFile, altText?: string): Promise<any> {
231
+ async upload(input: InputFile): Promise<any> {
207
232
 
208
- const f = await getFile(input, this.sanitizerOptions);
233
+ const f = await getFile(input, this.sanitizerOptions, this.mimetype);
209
234
  f.customName = this.overrideFileName;
210
- if (altText) {
211
- f.alt = altText;
235
+
236
+ if (this.altText) {
237
+ f.alt = this.altText
212
238
  }
213
239
 
214
240
  this.uploader.addFile(f);
@@ -240,8 +266,13 @@ export class Upload extends EventEmitter {
240
266
  continue;
241
267
  }
242
268
 
243
- const f = await getFile(input[i], this.sanitizerOptions);
269
+ const f = await getFile(input[i], this.sanitizerOptions, this.mimetype);
244
270
  f.customName = this.overrideFileName;
271
+
272
+ if (this.altText) {
273
+ f.alt = this.altText
274
+ }
275
+
245
276
  this.uploader.addFile(f);
246
277
  }
247
278
 
@@ -210,15 +210,13 @@ describe('client', () => {
210
210
 
211
211
  expect(Upload.prototype.setToken).toHaveBeenCalledWith(token);
212
212
  expect(Upload.prototype.setSecurity).toHaveBeenCalledWith(defaultSecurity);
213
- expect(Upload.prototype.upload).toHaveBeenCalledWith(file, undefined);
213
+ expect(Upload.prototype.upload).toHaveBeenCalledWith(file);
214
214
  });
215
215
 
216
216
  it('should be able to upload file with alt text', async () => {
217
217
  const client = new Client(defaultApikey);
218
218
  const file = 'anyFile';
219
- const uploadOptions = {
220
- altText: 'alt',
221
- };
219
+ const uploadOptions = {};
222
220
  const storeOptions = {};
223
221
  const token = {};
224
222
 
@@ -233,7 +231,7 @@ describe('client', () => {
233
231
 
234
232
  expect(Upload.prototype.setToken).toHaveBeenCalledWith(token);
235
233
  expect(Upload.prototype.setSecurity).toHaveBeenCalledWith(defaultSecurity);
236
- expect(Upload.prototype.upload).toHaveBeenCalledWith(file, uploadOptions.altText);
234
+ expect(Upload.prototype.upload).toHaveBeenCalledWith(file);
237
235
  });
238
236
 
239
237
  it('should be able to upload file without token and security', async () => {
@@ -251,7 +249,7 @@ describe('client', () => {
251
249
  urls: sessionURls,
252
250
  });
253
251
 
254
- expect(Upload.prototype.upload).toHaveBeenCalledWith(file, undefined);
252
+ expect(Upload.prototype.upload).toHaveBeenCalledWith(file);
255
253
  });
256
254
 
257
255
  it('should emit error', async () => {
package/src/lib/client.ts CHANGED
@@ -474,7 +474,7 @@ export class Client extends EventEmitter {
474
474
  this.emit('upload.error', e);
475
475
  });
476
476
 
477
- return upload.upload(file, options && options.altText);
477
+ return upload.upload(file);
478
478
  }
479
479
 
480
480
  /**
package/src/lib/picker.ts CHANGED
@@ -736,6 +736,11 @@ export interface PickerOptions {
736
736
  * Enable/Disable possibility to multiple file upload
737
737
  */
738
738
  multipleFileUpload?: boolean;
739
+ /**
740
+ * Set your own Google Drive Picker App ID. Defaults to Filestack's.
741
+ * This is your Project Number from the Google Cloud console.
742
+ */
743
+ googleDriveAppID?: string;
739
744
  }
740
745
 
741
746
  export interface PickerCropOptions {
@@ -473,5 +473,8 @@ export const PickerParamsSchema = {
473
473
  multipleFileUpload: {
474
474
  type: 'boolean',
475
475
  },
476
+ googleDriveAppID: {
477
+ type: 'string',
478
+ },
476
479
  },
477
480
  };
@@ -28,6 +28,14 @@ export const StoreParamsSchema = {
28
28
  format: 'callback',
29
29
  }],
30
30
  },
31
+ mimetype: {
32
+ type: ['string', 'null'],
33
+ maxLength: 255,
34
+ },
35
+ altText: {
36
+ type: ['string', 'null'],
37
+ maxLength: 125,
38
+ },
31
39
  location: {
32
40
  '$ref': 'locationsDef',
33
41
  },
@@ -81,9 +81,5 @@ export const UploadParamsSchema = {
81
81
  maxlength: 256,
82
82
  },
83
83
  },
84
- altText: {
85
- type: ['string', 'null'],
86
- maxLength: 60,
87
- },
88
84
  },
89
85
  };