@docbox-nz/hapi-gateway 0.1.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.
Files changed (45) hide show
  1. package/.eslintignore +6 -0
  2. package/.eslintrc +131 -0
  3. package/.prettierignore +11 -0
  4. package/.prettierrc +6 -0
  5. package/LICENSE.md +21 -0
  6. package/README.md +152 -0
  7. package/cspell.json +6 -0
  8. package/dist/api/adminService.d.ts +16 -0
  9. package/dist/api/boxService.d.ts +43 -0
  10. package/dist/api/client.d.ts +45 -0
  11. package/dist/api/docboxFile.d.ts +15 -0
  12. package/dist/api/fileService.d.ts +251 -0
  13. package/dist/api/folderService.d.ts +45 -0
  14. package/dist/api/linkService.d.ts +115 -0
  15. package/dist/api/taskService.d.ts +23 -0
  16. package/dist/api/utils.d.ts +1 -0
  17. package/dist/error.d.ts +11 -0
  18. package/dist/index.browser.cjs +988 -0
  19. package/dist/index.browser.cjs.map +1 -0
  20. package/dist/index.browser.esm.js +984 -0
  21. package/dist/index.browser.esm.js.map +1 -0
  22. package/dist/index.browser.js +4390 -0
  23. package/dist/index.browser.js.map +1 -0
  24. package/dist/index.d.ts +4 -0
  25. package/dist/index.node.cjs +22660 -0
  26. package/dist/index.node.cjs.map +1 -0
  27. package/dist/index.node.esm.js +22657 -0
  28. package/dist/index.node.esm.js.map +1 -0
  29. package/dist/index.node.js +20809 -0
  30. package/dist/index.node.js.map +1 -0
  31. package/dist/options.d.ts +79 -0
  32. package/dist/types/box.d.ts +59 -0
  33. package/dist/types/file.d.ts +371 -0
  34. package/dist/types/folder.d.ts +153 -0
  35. package/dist/types/index.d.ts +22 -0
  36. package/dist/types/link.d.ts +136 -0
  37. package/dist/types/search.d.ts +177 -0
  38. package/dist/types/shared.d.ts +94 -0
  39. package/dist/types/user.d.ts +20 -0
  40. package/package.json +56 -0
  41. package/rollup.config.js +36 -0
  42. package/src/error.ts +46 -0
  43. package/src/index.ts +244 -0
  44. package/src/options.ts +95 -0
  45. package/tsconfig.json +15 -0
@@ -0,0 +1,988 @@
1
+ 'use strict';
2
+
3
+ var axios = require('axios');
4
+
5
+ /**
6
+ * Types of generated files
7
+ */
8
+ exports.GeneratedFileType = void 0;
9
+ (function (GeneratedFileType) {
10
+ GeneratedFileType["PDF"] = "Pdf";
11
+ GeneratedFileType["COVER_PAGE"] = "CoverPage";
12
+ GeneratedFileType["SMALL_THUMBNAIL"] = "SmallThumbnail";
13
+ GeneratedFileType["LARGE_THUMBNAIL"] = "LargeThumbnail";
14
+ GeneratedFileType["TEXT_CONTENT"] = "TextContent";
15
+ GeneratedFileType["HTML_CONTENT"] = "HtmlContent";
16
+ GeneratedFileType["METADATA"] = "Metadata";
17
+ })(exports.GeneratedFileType || (exports.GeneratedFileType = {}));
18
+ /**
19
+ * Statuses that a presigned upload task can have
20
+ */
21
+ exports.PresignedUploadStatus = void 0;
22
+ (function (PresignedUploadStatus) {
23
+ PresignedUploadStatus["Pending"] = "Pending";
24
+ PresignedUploadStatus["Complete"] = "Complete";
25
+ PresignedUploadStatus["Failed"] = "Failed";
26
+ })(exports.PresignedUploadStatus || (exports.PresignedUploadStatus = {}));
27
+ exports.DocboxTaskStatus = void 0;
28
+ (function (DocboxTaskStatus) {
29
+ DocboxTaskStatus["Pending"] = "Pending";
30
+ DocboxTaskStatus["Completed"] = "Completed";
31
+ DocboxTaskStatus["Failed"] = "Failed";
32
+ })(exports.DocboxTaskStatus || (exports.DocboxTaskStatus = {}));
33
+
34
+ /**
35
+ * Possible search result item types
36
+ */
37
+ exports.SearchResultItemType = void 0;
38
+ (function (SearchResultItemType) {
39
+ SearchResultItemType["FILE"] = "File";
40
+ SearchResultItemType["FOLDER"] = "Folder";
41
+ SearchResultItemType["LINK"] = "Link";
42
+ })(exports.SearchResultItemType || (exports.SearchResultItemType = {}));
43
+
44
+ exports.EditHistoryType = void 0;
45
+ (function (EditHistoryType) {
46
+ EditHistoryType["MoveToFolder"] = "MoveToFolder";
47
+ EditHistoryType["Rename"] = "Rename";
48
+ EditHistoryType["LinkValue"] = "LinkValue";
49
+ })(exports.EditHistoryType || (exports.EditHistoryType = {}));
50
+
51
+ exports.DocboxItemType = void 0;
52
+ (function (DocboxItemType) {
53
+ DocboxItemType["File"] = "File";
54
+ DocboxItemType["Folder"] = "Folder";
55
+ DocboxItemType["Link"] = "Link";
56
+ })(exports.DocboxItemType || (exports.DocboxItemType = {}));
57
+
58
+ function sleep(timeout) {
59
+ return new Promise((resolve) => setTimeout(resolve, timeout));
60
+ }
61
+
62
+ /******************************************************************************
63
+ Copyright (c) Microsoft Corporation.
64
+
65
+ Permission to use, copy, modify, and/or distribute this software for any
66
+ purpose with or without fee is hereby granted.
67
+
68
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
69
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
70
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
71
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
72
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
73
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
74
+ PERFORMANCE OF THIS SOFTWARE.
75
+ ***************************************************************************** */
76
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
77
+
78
+
79
+ function __awaiter(thisArg, _arguments, P, generator) {
80
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
81
+ return new (P || (P = Promise))(function (resolve, reject) {
82
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
83
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
84
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
85
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
86
+ });
87
+ }
88
+
89
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
90
+ var e = new Error(message);
91
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
92
+ };
93
+
94
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
95
+
96
+ var formdata_min = {};
97
+
98
+ /*! formdata-polyfill. MIT License. Jimmy W?rting <https://jimmy.warting.se/opensource> */
99
+
100
+ var hasRequiredFormdata_min;
101
+
102
+ function requireFormdata_min () {
103
+ if (hasRequiredFormdata_min) return formdata_min;
104
+ hasRequiredFormdata_min = 1;
105
+ (function(){var h;function l(a){var b=0;return function(){return b<a.length?{done:false,value:a[b++]}:{done:true}}}var m="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(a==Array.prototype||a==Object.prototype)return a;a[b]=c.value;return a};
106
+ function n(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof commonjsGlobal&&commonjsGlobal];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");}var q=n(this);function r(a,b){if(b)a:{var c=q;a=a.split(".");for(var d=0;d<a.length-1;d++){var e=a[d];if(!(e in c))break a;c=c[e];}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&m(c,a,{configurable:true,writable:true,value:b});}}
107
+ r("Symbol",function(a){function b(f){if(this instanceof b)throw new TypeError("Symbol is not a constructor");return new c(d+(f||"")+"_"+e++,f)}function c(f,g){this.A=f;m(this,"description",{configurable:true,writable:true,value:g});}if(a)return a;c.prototype.toString=function(){return this.A};var d="jscomp_symbol_"+(1E9*Math.random()>>>0)+"_",e=0;return b});
108
+ r("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");for(var b="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),c=0;c<b.length;c++){var d=q[b[c]];"function"===typeof d&&"function"!=typeof d.prototype[a]&&m(d.prototype,a,{configurable:true,writable:true,value:function(){return u(l(this))}});}return a});function u(a){a={next:a};a[Symbol.iterator]=function(){return this};return a}
109
+ function v(a){var b="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];return b?b.call(a):{next:l(a)}}var w;if("function"==typeof Object.setPrototypeOf)w=Object.setPrototypeOf;else {var y;a:{var z={a:true},A={};try{A.__proto__=z;y=A.a;break a}catch(a){}y=false;}w=y?function(a,b){a.__proto__=b;if(a.__proto__!==b)throw new TypeError(a+" is not extensible");return a}:null;}var B=w;function C(){this.m=false;this.j=null;this.v=void 0;this.h=1;this.u=this.C=0;this.l=null;}
110
+ function D(a){if(a.m)throw new TypeError("Generator is already running");a.m=true;}C.prototype.o=function(a){this.v=a;};C.prototype.s=function(a){this.l={D:a,F:true};this.h=this.C||this.u;};C.prototype.return=function(a){this.l={return:a};this.h=this.u;};function E(a,b){a.h=3;return {value:b}}function F(a){this.g=new C;this.G=a;}F.prototype.o=function(a){D(this.g);if(this.g.j)return G(this,this.g.j.next,a,this.g.o);this.g.o(a);return H(this)};
111
+ function I(a,b){D(a.g);var c=a.g.j;if(c)return G(a,"return"in c?c["return"]:function(d){return {value:d,done:true}},b,a.g.return);a.g.return(b);return H(a)}F.prototype.s=function(a){D(this.g);if(this.g.j)return G(this,this.g.j["throw"],a,this.g.o);this.g.s(a);return H(this)};
112
+ function G(a,b,c,d){try{var e=b.call(a.g.j,c);if(!(e instanceof Object))throw new TypeError("Iterator result "+e+" is not an object");if(!e.done)return a.g.m=!1,e;var f=e.value;}catch(g){return a.g.j=null,a.g.s(g),H(a)}a.g.j=null;d.call(a.g,f);return H(a)}function H(a){for(;a.g.h;)try{var b=a.G(a.g);if(b)return a.g.m=!1,{value:b.value,done:!1}}catch(c){a.g.v=void 0,a.g.s(c);}a.g.m=false;if(a.g.l){b=a.g.l;a.g.l=null;if(b.F)throw b.D;return {value:b.return,done:true}}return {value:void 0,done:true}}
113
+ function J(a){this.next=function(b){return a.o(b)};this.throw=function(b){return a.s(b)};this.return=function(b){return I(a,b)};this[Symbol.iterator]=function(){return this};}function K(a,b){b=new J(new F(b));B&&a.prototype&&B(b,a.prototype);return b}function L(a,b){a instanceof String&&(a+="");var c=0,d=false,e={next:function(){if(!d&&c<a.length){var f=c++;return {value:b(f,a[f]),done:false}}d=true;return {done:true,value:void 0}}};e[Symbol.iterator]=function(){return e};return e}
114
+ r("Array.prototype.entries",function(a){return a?a:function(){return L(this,function(b,c){return [b,c]})}});
115
+ if("undefined"!==typeof Blob&&("undefined"===typeof FormData||!FormData.prototype.keys)){var M=function(a,b){for(var c=0;c<a.length;c++)b(a[c]);},N=function(a){return a.replace(/\r?\n|\r/g,"\r\n")},O=function(a,b,c){if(b instanceof Blob){c=void 0!==c?String(c+""):"string"===typeof b.name?b.name:"blob";if(b.name!==c||"[object Blob]"===Object.prototype.toString.call(b))b=new File([b],c);return [String(a),b]}return [String(a),String(b)]},P=function(a,b){if(a.length<b)throw new TypeError(b+" argument required, but only "+
116
+ a.length+" present.");},Q="object"===typeof globalThis?globalThis:"object"===typeof window?window:"object"===typeof self?self:this,R=Q.FormData,S=Q.XMLHttpRequest&&Q.XMLHttpRequest.prototype.send,T=Q.Request&&Q.fetch,U=Q.navigator&&Q.navigator.sendBeacon,V=Q.Element&&Q.Element.prototype,W=Q.Symbol&&Symbol.toStringTag;W&&(Blob.prototype[W]||(Blob.prototype[W]="Blob"),"File"in Q&&!File.prototype[W]&&(File.prototype[W]="File"));try{new File([],"");}catch(a){Q.File=function(b,c,d){b=new Blob(b,d||{});
117
+ Object.defineProperties(b,{name:{value:c},lastModified:{value:+(d&&void 0!==d.lastModified?new Date(d.lastModified):new Date)},toString:{value:function(){return "[object File]"}}});W&&Object.defineProperty(b,W,{value:"File"});return b};}var escape=function(a){return a.replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/"/g,"%22")},X=function(a){this.i=[];var b=this;a&&M(a.elements,function(c){if(c.name&&!c.disabled&&"submit"!==c.type&&"button"!==c.type&&!c.matches("form fieldset[disabled] *"))if("file"===
118
+ c.type){var d=c.files&&c.files.length?c.files:[new File([],"",{type:"application/octet-stream"})];M(d,function(e){b.append(c.name,e);});}else "select-multiple"===c.type||"select-one"===c.type?M(c.options,function(e){!e.disabled&&e.selected&&b.append(c.name,e.value);}):"checkbox"===c.type||"radio"===c.type?c.checked&&b.append(c.name,c.value):(d="textarea"===c.type?N(c.value):c.value,b.append(c.name,d));});};h=X.prototype;h.append=function(a,b,c){P(arguments,2);this.i.push(O(a,b,c));};h.delete=function(a){P(arguments,
119
+ 1);var b=[];a=String(a);M(this.i,function(c){c[0]!==a&&b.push(c);});this.i=b;};h.entries=function b(){var c,d=this;return K(b,function(e){1==e.h&&(c=0);if(3!=e.h)return c<d.i.length?e=E(e,d.i[c]):(e.h=0,e=void 0),e;c++;e.h=2;})};h.forEach=function(b,c){P(arguments,1);for(var d=v(this),e=d.next();!e.done;e=d.next()){var f=v(e.value);e=f.next().value;f=f.next().value;b.call(c,f,e,this);}};h.get=function(b){P(arguments,1);var c=this.i;b=String(b);for(var d=0;d<c.length;d++)if(c[d][0]===b)return c[d][1];
120
+ return null};h.getAll=function(b){P(arguments,1);var c=[];b=String(b);M(this.i,function(d){d[0]===b&&c.push(d[1]);});return c};h.has=function(b){P(arguments,1);b=String(b);for(var c=0;c<this.i.length;c++)if(this.i[c][0]===b)return true;return false};h.keys=function c(){var d=this,e,f,g,k,p;return K(c,function(t){1==t.h&&(e=v(d),f=e.next());if(3!=t.h){if(f.done){t.h=0;return}g=f.value;k=v(g);p=k.next().value;return E(t,p)}f=e.next();t.h=2;})};h.set=function(c,d,e){P(arguments,2);c=String(c);var f=[],g=O(c,
121
+ d,e),k=true;M(this.i,function(p){p[0]===c?k&&(k=!f.push(g)):f.push(p);});k&&f.push(g);this.i=f;};h.values=function d(){var e=this,f,g,k,p,t;return K(d,function(x){1==x.h&&(f=v(e),g=f.next());if(3!=x.h){if(g.done){x.h=0;return}k=g.value;p=v(k);p.next();t=p.next().value;return E(x,t)}g=f.next();x.h=2;})};X.prototype._asNative=function(){for(var d=new R,e=v(this),f=e.next();!f.done;f=e.next()){var g=v(f.value);f=g.next().value;g=g.next().value;d.append(f,g);}return d};X.prototype._blob=function(){var d="----formdata-polyfill-"+
122
+ Math.random(),e=[],f="--"+d+'\r\nContent-Disposition: form-data; name="';this.forEach(function(g,k){return "string"==typeof g?e.push(f+escape(N(k))+('"\r\n\r\n'+N(g)+"\r\n")):e.push(f+escape(N(k))+('"; filename="'+escape(g.name)+'"\r\nContent-Type: '+(g.type||"application/octet-stream")+"\r\n\r\n"),g,"\r\n")});e.push("--"+d+"--");return new Blob(e,{type:"multipart/form-data; boundary="+d})};X.prototype[Symbol.iterator]=function(){return this.entries()};X.prototype.toString=function(){return "[object FormData]"};
123
+ V&&!V.matches&&(V.matches=V.matchesSelector||V.mozMatchesSelector||V.msMatchesSelector||V.oMatchesSelector||V.webkitMatchesSelector||function(d){d=(this.document||this.ownerDocument).querySelectorAll(d);for(var e=d.length;0<=--e&&d.item(e)!==this;);return -1<e});W&&(X.prototype[W]="FormData");if(S){var Y=Q.XMLHttpRequest.prototype.setRequestHeader;Q.XMLHttpRequest.prototype.setRequestHeader=function(d,e){Y.call(this,d,e);"content-type"===d.toLowerCase()&&(this.B=true);};Q.XMLHttpRequest.prototype.send=
124
+ function(d){d instanceof X?(d=d._blob(),this.B||this.setRequestHeader("Content-Type",d.type),S.call(this,d)):S.call(this,d);};}T&&(Q.fetch=function(d,e){e&&e.body&&e.body instanceof X&&(e.body=e.body._blob());return T.call(this,d,e)});U&&(Q.navigator.sendBeacon=function(d,e){e instanceof X&&(e=e._asNative());return U.call(this,d,e)});Q.FormData=X;}})();
125
+ return formdata_min;
126
+ }
127
+
128
+ requireFormdata_min();
129
+
130
+ class FileService {
131
+ constructor(client) {
132
+ this.client = client;
133
+ }
134
+ /**
135
+ * Get a URL to a raw version of a file
136
+ *
137
+ * @param scope Scope the file is within
138
+ * @param id ID of the file
139
+ * @returns The file URL
140
+ */
141
+ rawURL(scope, id) {
142
+ return `box/${scope}/file/${id}/raw`;
143
+ }
144
+ /**
145
+ * Get a URL to a raw version of a file with an additional
146
+ * cosmetic name shown in browser viewers
147
+ *
148
+ * @param scope Scope the file is within
149
+ * @param id ID of the file
150
+ * @param name Name to provide the file
151
+ * @returns The file URL
152
+ */
153
+ rawNamedURL(scope, id, name) {
154
+ return `box/${scope}/file/${id}/raw/${encodeURIComponent(name)}`;
155
+ }
156
+ /**
157
+ * Get a URL to a generated version of a file
158
+ *
159
+ * @param scope Scope the file is within
160
+ * @param id ID of the main file
161
+ * @param type Type of generated file to get
162
+ * @returns The URL to the generated file
163
+ */
164
+ generatedRawURL(scope, id, type) {
165
+ return `box/${scope}/file/${id}/generated/${type}/raw`;
166
+ }
167
+ /**
168
+ * Get a URL to a generated version of a file with an additional
169
+ * cosmetic name shown in browser viewers
170
+ *
171
+ * @param scope Scope the file is within
172
+ * @param id ID of the main file
173
+ * @param type Type of generated file to get
174
+ * @param name Name to provide the file
175
+ * @returns The URL to the generated file
176
+ */
177
+ generatedRawNamedURL(scope, id, type, name) {
178
+ return `box/${scope}/file/${id}/generated/${type}/raw/${encodeURIComponent(name)}`;
179
+ }
180
+ /**
181
+ * Direct upload
182
+ *
183
+ * @deprecated When behind the proxy service this will often encounter timeout issues
184
+ * its recommended you use another upload method
185
+ *
186
+ * Prefer {@link FileService.uploadAsync}
187
+ *
188
+ * @param scope Scope to upload the file into
189
+ * @param name Name of the file
190
+ * @param folder_id Folder to store the file in
191
+ * @param file File to store
192
+ * @returns File upload response
193
+ */
194
+ upload(scope, name, folder_id, file) {
195
+ return __awaiter(this, void 0, void 0, function* () {
196
+ // Create form data
197
+ const data = new FormData();
198
+ data.append('name', name);
199
+ data.append('folder_id', folder_id);
200
+ data.append('file', file);
201
+ return this.client.httpPost(`box/${scope}/file`, data, {
202
+ // Clear default JSON content type (We need the browser to set multipart headers properly)
203
+ headers: { 'Content-Type': undefined },
204
+ });
205
+ });
206
+ }
207
+ /**
208
+ * Asynchronous direct upload
209
+ *
210
+ * (File is uploaded directly but processed asynchronously)
211
+ *
212
+ * If you are handling reasonably sized files prefer {@link FileService.uploadPresigned} to
213
+ * prevent running into browser timeouts as the file is transferred between services
214
+ *
215
+ * @param request Upload request data
216
+ * @returns The uploaded file response
217
+ */
218
+ uploadAsync(request) {
219
+ return __awaiter(this, void 0, void 0, function* () {
220
+ // Create form data
221
+ const data = new FormData();
222
+ data.append('name', request.name);
223
+ data.append('folder_id', request.folder_id);
224
+ data.append('file', request.file);
225
+ data.append('asynchronous', 'true');
226
+ if (request.fixed_id) {
227
+ data.append('fixed_id', request.fixed_id);
228
+ }
229
+ if (request.parent_id) {
230
+ data.append('fixed_id', request.parent_id);
231
+ }
232
+ if (request.processing_config) {
233
+ data.append('processing_config', JSON.stringify(request.processing_config));
234
+ }
235
+ const taskResponse = yield this.client.httpPost(`box/${request.scope}/file`, data, {
236
+ // Clear default JSON content type (We need the browser to set multipart headers properly)
237
+ headers: { 'Content-Type': undefined },
238
+ });
239
+ return yield this.client.task.finished(request.scope, taskResponse.task_id, 1000, request.abort);
240
+ });
241
+ }
242
+ /**
243
+ * Performs a pre-signed file upload
244
+ *
245
+ * @param scope Scope to upload the file into
246
+ * @param folderId ID of the folder to store the file within
247
+ * @param file File to upload
248
+ * @param options Request options
249
+ * @returns File upload response
250
+ */
251
+ uploadPresigned(scope, folderId, file, options) {
252
+ return __awaiter(this, void 0, void 0, function* () {
253
+ if (options && options.onProgress) {
254
+ options.onProgress('Preparing');
255
+ }
256
+ const presigned = yield this.createPresignedUpload(scope, {
257
+ name: file.name,
258
+ folder_id: folderId,
259
+ size: file.size,
260
+ mime: file.type,
261
+ parent_id: options === null || options === void 0 ? void 0 : options.parent_id,
262
+ processing_config: options === null || options === void 0 ? void 0 : options.processing_config,
263
+ });
264
+ yield this.performPresignedUpload(file, presigned, options);
265
+ if (options && options.onProgress) {
266
+ options.onProgress('Processing');
267
+ }
268
+ const taskId = presigned.task_id;
269
+ const response = yield this.presignedFinished(scope, taskId, 1000, options === null || options === void 0 ? void 0 : options.abort);
270
+ if (options && options.onProgress) {
271
+ options.onProgress('Complete', 1);
272
+ }
273
+ return response;
274
+ });
275
+ }
276
+ performPresignedUpload(file, presigned, options) {
277
+ return __awaiter(this, void 0, void 0, function* () {
278
+ if (options && options.onProgress) {
279
+ options.onProgress('Starting');
280
+ }
281
+ // Browser is not allowed to set this header
282
+ delete presigned.headers['content-length'];
283
+ const config = {
284
+ method: presigned.method,
285
+ url: presigned.uri,
286
+ headers: Object.assign({ 'Content-Type': file.type }, presigned.headers),
287
+ data: file,
288
+ };
289
+ if (options) {
290
+ if (options.onProgress) {
291
+ const onProgress = options.onProgress;
292
+ config.onUploadProgress = (event) => {
293
+ if (!event.progress) {
294
+ onProgress('Uploading');
295
+ return;
296
+ }
297
+ if (event.progress === 1) {
298
+ onProgress('Uploaded', 1);
299
+ }
300
+ else {
301
+ onProgress('Uploading', event.progress);
302
+ }
303
+ };
304
+ }
305
+ // Apply abort signal
306
+ if (options.abort) {
307
+ config.signal = options.abort.signal;
308
+ }
309
+ }
310
+ // Upload the file to the presigned target
311
+ yield axios.request(config);
312
+ });
313
+ }
314
+ /**
315
+ * Creates a new presigned upload
316
+ *
317
+ * @param scope Scope to upload the file within
318
+ * @param request The presigned upload request
319
+ * @returns The presigned upload details
320
+ */
321
+ createPresignedUpload(scope, request) {
322
+ return this.client.httpPost(`box/${scope}/file/presigned`, request);
323
+ }
324
+ /**
325
+ * Request the status of a presigned upload task
326
+ *
327
+ * @param scope Scope the upload file task is within
328
+ * @param taskId ID of the uploading task
329
+ * @param abort Abort handle to abort the request
330
+ * @returns The task status
331
+ */
332
+ presignedStatus(scope, taskId, abort) {
333
+ return this.client.httpGet(`box/${scope}/file/presigned/${taskId}`, { signal: abort === null || abort === void 0 ? void 0 : abort.signal });
334
+ }
335
+ /**
336
+ * Polls for the completion of a presigned upload task
337
+ *
338
+ * @param scope Scope the upload file task is within
339
+ * @param task_id ID of the uploading task
340
+ * @param interval Rate at which to poll for completion
341
+ * @param abort Abort handle that can abort the polling
342
+ * @returns The uploaded file response
343
+ */
344
+ presignedFinished(scope_1, task_id_1) {
345
+ return __awaiter(this, arguments, void 0, function* (scope, task_id, interval = 1000, abort) {
346
+ var _a;
347
+ while (abort === undefined ? true : !abort.signal.aborted) {
348
+ const task = yield this.presignedStatus(scope, task_id, abort);
349
+ if (task.status === 'Complete') {
350
+ return { file: task.file, generated: task.generated };
351
+ }
352
+ if (task.status === 'Failed') {
353
+ const error = (_a = task.error) !== null && _a !== void 0 ? _a : 'Unknown error';
354
+ throw new Error(error);
355
+ }
356
+ yield sleep(interval);
357
+ }
358
+ throw new Error('upload tracking aborted');
359
+ });
360
+ }
361
+ /**
362
+ * Request the details of a file using its ID and scope
363
+ *
364
+ * @param scope Scope the file resides within
365
+ * @param file_id ID of the file
366
+ * @returns The full file details
367
+ */
368
+ get(scope, file_id) {
369
+ return this.client.httpGet(`box/${scope}/file/${file_id}`);
370
+ }
371
+ /**
372
+ * Search within the contents of a file
373
+ *
374
+ * @param scope Scope the file resides within
375
+ * @param file_id ID of the file
376
+ * @param request The search request
377
+ * @returns The full file details
378
+ */
379
+ search(scope, file_id, request) {
380
+ return this.client.httpPost(`box/${scope}/file/${file_id}/search`, request);
381
+ }
382
+ /**
383
+ * Request children of the file, in the case of .eml email files this
384
+ * would provide a list of files for the attachments associated with
385
+ * the email
386
+ *
387
+ * @param scope Scope the file resides within
388
+ * @param file_id ID of the file to find the children of
389
+ * @returns The files that are children
390
+ */
391
+ children(scope, file_id) {
392
+ return this.client.httpGet(`box/${scope}/file/${file_id}/children`);
393
+ }
394
+ /**
395
+ * Request the history of edits to the file
396
+ *
397
+ * @param scope Scope the file resides within
398
+ * @param file_id ID of the file to get the history for
399
+ * @returns The edit history
400
+ */
401
+ editHistory(scope, file_id) {
402
+ return this.client.httpGet(`box/${scope}/file/${file_id}/edit-history`);
403
+ }
404
+ /**
405
+ * Update the details about the file
406
+ *
407
+ * @param scope Scope the file resides within
408
+ * @param file_id ID of the file to update
409
+ * @param data The updates to perform
410
+ */
411
+ update(scope, file_id, data) {
412
+ return this.client.httpPut(`box/${scope}/file/${file_id}`, data);
413
+ }
414
+ /**
415
+ * Gets the raw file contents of the provided file
416
+ *
417
+ * On node this returns an {@link ArrayBuffer} not a blob
418
+ *
419
+ * @param scope Scope the file resides within
420
+ * @param file_id ID of the file to retrieve
421
+ * @returns The raw contents of the file
422
+ */
423
+ raw(scope, file_id) {
424
+ return this.client.httpGet(this.rawURL(scope, file_id), {
425
+ responseType: typeof window === 'undefined' ? 'arraybuffer' : 'blob',
426
+ });
427
+ }
428
+ /**
429
+ * Gets the raw file contents of the provided file
430
+ *
431
+ * This function is the same as {@link FileService.raw} just
432
+ * it has the correct return type for Node
433
+ *
434
+ * @param scope Scope the file resides within
435
+ * @param file_id ID of the file to retrieve
436
+ * @returns The raw contents of the file
437
+ */
438
+ rawNode(scope, file_id) {
439
+ return this.client.httpGet(this.rawURL(scope, file_id), {
440
+ responseType: 'arraybuffer',
441
+ });
442
+ }
443
+ /**
444
+ * Gets the raw file contents of the provided file in
445
+ * JSON format (Will only work if the actual file is JSON)
446
+ *
447
+ * @param scope Scope the file resides within
448
+ * @param file_id ID of the file to retrieve
449
+ * @returns The JSON contents of the file
450
+ */
451
+ json(scope, file_id) {
452
+ return this.client.httpGet(this.rawURL(scope, file_id), {
453
+ responseType: 'json',
454
+ });
455
+ }
456
+ /**
457
+ * Gets the raw file contents of the provided file as text
458
+ * (Will only work if the actual file is text)
459
+ *
460
+ * @param scope Scope the file resides within
461
+ * @param file_id ID of the file to retrieve
462
+ * @returns The text contents of the file
463
+ */
464
+ text(scope, file_id) {
465
+ return this.client.httpGet(this.rawURL(scope, file_id), {
466
+ responseType: 'text',
467
+ });
468
+ }
469
+ /**
470
+ * Deletes a file
471
+ *
472
+ * @param scope Scope the file resides within
473
+ * @param file_id ID of the file to delete
474
+ */
475
+ delete(scope, file_id) {
476
+ return this.client.httpDelete(`box/${scope}/file/${file_id}`);
477
+ }
478
+ /**
479
+ * Gets a generated file details
480
+ *
481
+ * @param scope Scope the file resides within
482
+ * @param file_id ID of the file to query
483
+ * @param type Type of the generated file
484
+ * @returns The generated file details
485
+ */
486
+ generated(scope, file_id, type) {
487
+ return this.client.httpGet(`box/${scope}/file/${file_id}/generated/${type}`);
488
+ }
489
+ /**
490
+ * Gets a generated file raw contents
491
+ *
492
+ * On node this returns an {@link ArrayBuffer} not a blob
493
+ *
494
+ * @param scope Scope the file resides within
495
+ * @param file_id ID of the file to query
496
+ * @param type Type of the generated file
497
+ * @returns The Blob/ArrayBuffer content of the file (Blob within a browser, ArrayBuffer on node)
498
+ */
499
+ generatedRaw(scope, file_id, type) {
500
+ return this.client.httpGet(this.generatedRawURL(scope, file_id, type), {
501
+ responseType: typeof window === 'undefined' ? 'arraybuffer' : 'blob',
502
+ });
503
+ }
504
+ /**
505
+ * Gets a generated file raw contents
506
+ *
507
+ * This function is the same as {@link FileService.generatedRaw} just
508
+ * it has the correct return type for Node and will only return an
509
+ * ArrayBuffer
510
+ *
511
+ * @param scope Scope the file resides within
512
+ * @param file_id ID of the file to query
513
+ * @param type Type of the generated file
514
+ * @returns The ArrayBuffer content of the generated file
515
+ */
516
+ generatedRawNode(scope, file_id, type) {
517
+ return this.client.httpGet(this.generatedRawURL(scope, file_id, type), {
518
+ responseType: 'arraybuffer',
519
+ });
520
+ }
521
+ /**
522
+ * Gets a generated file raw contents as text
523
+ *
524
+ * @param scope Scope the file resides within
525
+ * @param file_id ID of the file to query
526
+ * @param type Type of the generated file
527
+ * @returns The text content of the generated file
528
+ */
529
+ generatedText(scope, file_id, type) {
530
+ return this.client.httpGet(this.generatedRawURL(scope, file_id, type), {
531
+ responseType: 'text',
532
+ });
533
+ }
534
+ /**
535
+ * Gets a generated file raw contents as JSON
536
+ *
537
+ * @param scope Scope the file resides within
538
+ * @param file_id ID of the file to query
539
+ * @param type Type of the generated file
540
+ * @returns The JSON content of the generated file
541
+ */
542
+ generatedJson(scope, file_id, type) {
543
+ return this.client.httpGet(this.generatedRawURL(scope, file_id, type), {
544
+ responseType: 'json',
545
+ });
546
+ }
547
+ }
548
+
549
+ class BoxService {
550
+ constructor(client) {
551
+ this.client = client;
552
+ }
553
+ /**
554
+ * Get a document box for a scope
555
+ *
556
+ * @param scope Scope of the document box to get
557
+ * @param createIfMissing Whether to create the document box if it doesn't exist
558
+ */
559
+ get(scope_1) {
560
+ return __awaiter(this, arguments, void 0, function* (scope, createIfMissing = false) {
561
+ var _a;
562
+ try {
563
+ return yield this.client.httpGet(`box/${scope}`);
564
+ }
565
+ catch (err) {
566
+ // Handle a document box not being created yet
567
+ if (createIfMissing && axios.isAxiosError(err) && ((_a = err.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
568
+ // Attempt to create the document box
569
+ return this.create(scope, false);
570
+ }
571
+ throw err;
572
+ }
573
+ });
574
+ }
575
+ /**
576
+ * Creates a new document box optional returning an existing one if there is one available
577
+ *
578
+ * @param scope Scope for the document box to create
579
+ * @param allowExisting Whether to allow returning an existing document box (If one is present)
580
+ * @returns The created document box
581
+ */
582
+ create(scope_1) {
583
+ return __awaiter(this, arguments, void 0, function* (scope, allowExisting = true) {
584
+ var _a;
585
+ try {
586
+ return yield this.client.httpPost('box', { scope });
587
+ }
588
+ catch (err) {
589
+ // Handle document box already exists response
590
+ if (allowExisting && axios.isAxiosError(err) && ((_a = err.response) === null || _a === void 0 ? void 0 : _a.status) === 409) {
591
+ return this.get(scope);
592
+ }
593
+ throw err;
594
+ }
595
+ });
596
+ }
597
+ /**
598
+ * Delete a specific document vox
599
+ *
600
+ * @param scope Scope of the document box to delete
601
+ * @returns
602
+ */
603
+ delete(scope) {
604
+ return __awaiter(this, void 0, void 0, function* () {
605
+ var _a;
606
+ try {
607
+ return this.client.httpDelete(`box/${scope}`);
608
+ }
609
+ catch (err) {
610
+ // Handle document box never existed
611
+ if (axios.isAxiosError(err) && ((_a = err.response) === null || _a === void 0 ? void 0 : _a.status) === 404) {
612
+ return {};
613
+ }
614
+ throw err;
615
+ }
616
+ });
617
+ }
618
+ /**
619
+ * Search within the provided document box
620
+ *
621
+ * @param scope The scope of the document box to search
622
+ * @param data Search request data
623
+ * @returns The search results
624
+ */
625
+ search(scope, data) {
626
+ return __awaiter(this, void 0, void 0, function* () {
627
+ return yield this.client.httpPost(`box/${scope}/search`, data);
628
+ });
629
+ }
630
+ /**
631
+ * Get statistics for the provided document box
632
+ *
633
+ * @param scope The scope of the document box
634
+ * @returns The box stats
635
+ */
636
+ stats(scope) {
637
+ return __awaiter(this, void 0, void 0, function* () {
638
+ return yield this.client.httpGet(`box/${scope}/stats`);
639
+ });
640
+ }
641
+ }
642
+
643
+ class LinkService {
644
+ constructor(client) {
645
+ this.client = client;
646
+ }
647
+ /**
648
+ * Get a link to the favicon image for the provided link
649
+ *
650
+ * @param scope Scope the link resides within
651
+ * @param id ID of the link to request
652
+ * @returns The favicon image URL
653
+ */
654
+ faviconURL(scope, id) {
655
+ return `box/${scope}/link/${id}/favicon`;
656
+ }
657
+ /**
658
+ * Get a link to the OGP image for the provided link
659
+ *
660
+ * @param scope Scope the link resides within
661
+ * @param id ID of the link to request
662
+ * @returns The OGP image URL
663
+ */
664
+ imageURL(scope, id) {
665
+ return `box/${scope}/link/${id}/image`;
666
+ }
667
+ /**
668
+ * Creates a new link within the provided document box
669
+ *
670
+ * @param scope Scope to create the link within
671
+ * @param data Link creation data
672
+ * @returns The created link
673
+ */
674
+ create(scope, data) {
675
+ return this.client.httpPost(`box/${scope}/link`, data);
676
+ }
677
+ /**
678
+ * Request a specific link by ID
679
+ *
680
+ * @param scope Scope the link resides within
681
+ * @param link_id ID of the link to request
682
+ * @returns The requested link
683
+ */
684
+ get(scope, link_id) {
685
+ return this.client.httpGet(`box/${scope}/link/${link_id}`);
686
+ }
687
+ /**
688
+ * Requests metadata for the link. This will make a request to the site at
689
+ * the link value to extract metadata from the website itself such as title,
690
+ * and OGP metadata
691
+ *
692
+ * @param scope Scope the link resides within
693
+ * @param link_id ID of the link to request
694
+ * @returns The link website metadata
695
+ */
696
+ metadata(scope, link_id) {
697
+ return this.client.httpGet(`box/${scope}/link/${link_id}/metadata`);
698
+ }
699
+ /**
700
+ * Get the raw favicon content for a link
701
+ *
702
+ * On node this returns an {@link ArrayBuffer} not a blob
703
+ *
704
+ * @param scope Scope the link resides within
705
+ * @param link_id ID of the link to request
706
+ * @returns The link raw favicon
707
+ */
708
+ favicon(scope, link_id) {
709
+ return this.client.httpGet(this.faviconURL(scope, link_id), {
710
+ responseType: typeof window === 'undefined' ? 'arraybuffer' : 'blob',
711
+ });
712
+ }
713
+ /**
714
+ * Get the raw favicon content for a link
715
+ *
716
+ * This function is the same as {@link LinkService.favicon} just
717
+ * it has the correct return type for Node and will only return an
718
+ * ArrayBuffer
719
+ *
720
+ * @param scope Scope the link resides within
721
+ * @param link_id ID of the link to request
722
+ * @returns The link raw favicon
723
+ */
724
+ faviconNode(scope, link_id) {
725
+ return this.client.httpGet(this.faviconURL(scope, link_id), {
726
+ responseType: 'arraybuffer',
727
+ });
728
+ }
729
+ /**
730
+ * Get the raw social image for a link
731
+ *
732
+ * On node this returns an {@link ArrayBuffer} not a blob
733
+ *
734
+ * @param scope Scope the link resides within
735
+ * @param link_id ID of the link to request
736
+ * @returns The link raw social image
737
+ */
738
+ image(scope, link_id) {
739
+ return this.client.httpGet(this.imageURL(scope, link_id), {
740
+ responseType: typeof window === 'undefined' ? 'arraybuffer' : 'blob',
741
+ });
742
+ }
743
+ /**
744
+ * Get the raw social image for a link
745
+ *
746
+ * This function is the same as {@link LinkService.image} just
747
+ * it has the correct return type for Node and will only return an
748
+ * ArrayBuffer
749
+ *
750
+ * @param scope Scope the link resides within
751
+ * @param link_id ID of the link to request
752
+ * @returns
753
+ */
754
+ imageNode(scope, link_id) {
755
+ return this.client.httpGet(this.imageURL(scope, link_id), {
756
+ responseType: 'arraybuffer',
757
+ });
758
+ }
759
+ /**
760
+ * Get the edit history for a link
761
+ *
762
+ * @param scope Scope the link resides within
763
+ * @param link_id ID of the link to request
764
+ * @returns Edit history for the link
765
+ */
766
+ editHistory(scope, link_id) {
767
+ return this.client.httpGet(`box/${scope}/link/${link_id}/edit-history`);
768
+ }
769
+ /**
770
+ * Updates a link
771
+ *
772
+ * @param scope Scope the link resides within
773
+ * @param link_id ID of the link to request
774
+ * @param data The update request
775
+ */
776
+ update(scope, link_id, data) {
777
+ return this.client.httpPut(`box/${scope}/link/${link_id}`, data);
778
+ }
779
+ /**
780
+ * Deletes the provided link
781
+ *
782
+ * @param scope Scope the link resides within
783
+ * @param link_id ID of the link to request
784
+ */
785
+ delete(scope, link_id) {
786
+ return this.client.httpDelete(`box/${scope}/link/${link_id}`);
787
+ }
788
+ }
789
+
790
+ class FolderService {
791
+ constructor(client) {
792
+ this.client = client;
793
+ }
794
+ /**
795
+ * Create a new folder
796
+ *
797
+ * @param scope Scope to create the folder within
798
+ * @param data Configuration for creating the folder
799
+ * @returns The created folder
800
+ */
801
+ create(scope, data) {
802
+ return this.client.httpPost(`box/${scope}/folder`, data);
803
+ }
804
+ /**
805
+ * Loads a specific folder
806
+ *
807
+ * @param scope Scope the folder resides within
808
+ * @param folder_id ID of the folder to request
809
+ * @returns The resolved folder
810
+ */
811
+ get(scope, folder_id) {
812
+ return this.client.httpGet(`box/${scope}/folder/${folder_id}`);
813
+ }
814
+ /**
815
+ * Update a folder details
816
+ *
817
+ * @param scope Scope the folder resides within
818
+ * @param folder_id ID of the folder to update
819
+ * @param data The folder update data
820
+ */
821
+ update(scope, folder_id, data) {
822
+ return this.client.httpPut(`box/${scope}/folder/${folder_id}`, data);
823
+ }
824
+ /**
825
+ * Deletes the provided folder
826
+ *
827
+ * @param scope Scope the folder resides within
828
+ * @param folder_id ID of the folder to delete
829
+ */
830
+ delete(scope, folder_id) {
831
+ return this.client.httpDelete(`box/${scope}/folder/${folder_id}`);
832
+ }
833
+ /**
834
+ * Load the edit history of a folder
835
+ *
836
+ * @param scope Scope the folder resides within
837
+ * @param folder_id ID of the folder to query
838
+ * @returns The folder edit history
839
+ */
840
+ editHistory(scope, folder_id) {
841
+ return this.client.httpGet(`box/${scope}/folder/${folder_id}/edit-history`);
842
+ }
843
+ }
844
+
845
+ class TaskService {
846
+ constructor(client) {
847
+ this.client = client;
848
+ }
849
+ /**
850
+ * Get the current status of a specific task
851
+ *
852
+ * @param scope
853
+ * @param task_id
854
+ * @returns
855
+ */
856
+ get(scope, task_id, abort) {
857
+ return __awaiter(this, void 0, void 0, function* () {
858
+ return this.client.httpGet(`box/${scope}/task/${task_id}`, {
859
+ signal: abort === null || abort === void 0 ? void 0 : abort.signal,
860
+ });
861
+ });
862
+ }
863
+ /**
864
+ * Polls for the completion of a task
865
+ *
866
+ * @param scope
867
+ * @param task_id
868
+ * @param abort
869
+ * @returns
870
+ */
871
+ finished(scope_1, task_id_1) {
872
+ return __awaiter(this, arguments, void 0, function* (scope, task_id, interval = 1000, abort) {
873
+ var _a, _b;
874
+ while (abort === undefined ? true : !abort.signal.aborted) {
875
+ const task = yield this.get(scope, task_id, abort);
876
+ if (task.status === exports.DocboxTaskStatus.Completed) {
877
+ const response = task.output_data;
878
+ return response;
879
+ }
880
+ if (task.status === exports.DocboxTaskStatus.Failed) {
881
+ const error = (_b = (_a = task.output_data) === null || _a === void 0 ? void 0 : _a.error) !== null && _b !== void 0 ? _b : 'Unknown Error';
882
+ throw new Error(error);
883
+ }
884
+ yield sleep(interval);
885
+ }
886
+ throw new Error('upload tracking aborted');
887
+ });
888
+ }
889
+ }
890
+
891
+ class AdminService {
892
+ constructor(client) {
893
+ this.client = client;
894
+ }
895
+ /**
896
+ * Perform an admin search across multiple document boxes.
897
+ *
898
+ * This function will only work on your server handling authentication
899
+ * you should not allow the frontend to access these endpoints
900
+ *
901
+ * @param data Search request data
902
+ * @returns The search results
903
+ */
904
+ search(data) {
905
+ return __awaiter(this, void 0, void 0, function* () {
906
+ return yield this.client.httpPost(`admin/search`, data);
907
+ });
908
+ }
909
+ }
910
+
911
+ class DocboxClient {
912
+ /**
913
+ * Creates a new docbox
914
+ *
915
+ * @param client
916
+ */
917
+ constructor(client) {
918
+ this.client = client;
919
+ this.documentBox = new BoxService(this);
920
+ this.task = new TaskService(this);
921
+ this.file = new FileService(this);
922
+ this.link = new LinkService(this);
923
+ this.folder = new FolderService(this);
924
+ this.admin = new AdminService(this);
925
+ }
926
+ httpGet(url, config) {
927
+ return __awaiter(this, void 0, void 0, function* () {
928
+ const { data } = yield this.client.get(url, config);
929
+ return data;
930
+ });
931
+ }
932
+ httpPost(url, data, config) {
933
+ return __awaiter(this, void 0, void 0, function* () {
934
+ const { data: responseData } = yield this.client.post(url, data, config);
935
+ return responseData;
936
+ });
937
+ }
938
+ httpPut(url, data, config) {
939
+ return __awaiter(this, void 0, void 0, function* () {
940
+ const { data: responseData } = yield this.client.put(url, data, config);
941
+ return responseData;
942
+ });
943
+ }
944
+ httpPatch(url, data, config) {
945
+ return __awaiter(this, void 0, void 0, function* () {
946
+ const { data: responseData } = yield this.client.patch(url, data, config);
947
+ return responseData;
948
+ });
949
+ }
950
+ httpDelete(url, config) {
951
+ return __awaiter(this, void 0, void 0, function* () {
952
+ const { data: responseData } = yield this.client.delete(url, config);
953
+ return responseData;
954
+ });
955
+ }
956
+ }
957
+
958
+ let FileGlobal = File;
959
+ // Node targets don't have this available, just mock it.
960
+ // this type should not be used in a node env
961
+ if (FileGlobal === undefined) {
962
+ class MockFile {
963
+ constructor(name, fileParts, options) {
964
+ this.name = name;
965
+ this.fileParts = fileParts;
966
+ this.options = options;
967
+ }
968
+ }
969
+ FileGlobal = MockFile;
970
+ }
971
+ /**
972
+ * Wrapper around the browser File type to allow using a docbox file
973
+ * in place when handling already uploaded files in a form
974
+ */
975
+ class DocboxFile extends FileGlobal {
976
+ get size() {
977
+ return this.file.size;
978
+ }
979
+ constructor(file) {
980
+ super([], file.name, { type: file.mime });
981
+ this.file = file;
982
+ }
983
+ }
984
+
985
+ exports.DocboxClient = DocboxClient;
986
+ exports.DocboxFile = DocboxFile;
987
+ exports.sleep = sleep;
988
+ //# sourceMappingURL=index.browser.cjs.map