@spica-devkit/storage 0.9.12 → 0.9.16

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/index.mjs CHANGED
@@ -1,12 +1,33 @@
1
- import axios from 'axios';
1
+ import axios_1 from 'axios';
2
2
  import buffer from 'buffer';
3
3
 
4
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
5
+
6
+ function createCommonjsModule(fn, basedir, module) {
7
+ return module = {
8
+ path: basedir,
9
+ exports: {},
10
+ require: function (path, base) {
11
+ return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
12
+ }
13
+ }, fn(module, module.exports), module.exports;
14
+ }
15
+
16
+ function commonjsRequire () {
17
+ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
18
+ }
19
+
20
+ var request = createCommonjsModule(function (module, exports) {
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.Axios = exports.logWarning = void 0;
23
+
4
24
  function logWarning(response) {
5
25
  const warning = response.headers["warning"];
6
26
  if (warning) {
7
27
  console.warn(warning);
8
28
  }
9
29
  }
30
+ exports.logWarning = logWarning;
10
31
  class Axios {
11
32
  constructor(config) {
12
33
  this.interceptors = {
@@ -31,7 +52,7 @@ class Axios {
31
52
  }
32
53
  }
33
54
  };
34
- this.instance = axios.create(config);
55
+ this.instance = axios_1.default.create(config);
35
56
  this.instance.interceptors.request.use(this.interceptors.request.onFulfilled, this.interceptors.request.onRejected);
36
57
  this.instance.interceptors.response.use(this.interceptors.response.onFulfilled, this.interceptors.response.onRejected);
37
58
  this.baseUrl = this.instance.defaults.baseURL;
@@ -64,6 +85,13 @@ class Axios {
64
85
  return this.instance.delete(url, config);
65
86
  }
66
87
  }
88
+ exports.Axios = Axios;
89
+
90
+ });
91
+
92
+ var initialize_1 = createCommonjsModule(function (module, exports) {
93
+ Object.defineProperty(exports, "__esModule", { value: true });
94
+ exports.isPlatformBrowser = exports.checkInitialized = exports.initialize = void 0;
67
95
 
68
96
  let service;
69
97
  function initialize(options) {
@@ -80,7 +108,7 @@ function initialize(options) {
80
108
  throw new Error("Public url must be provided.");
81
109
  }
82
110
  if (!service) {
83
- service = new Axios({ baseURL: publicUrl, headers: { Authorization: authorization } });
111
+ service = new request.Axios({ baseURL: publicUrl, headers: { Authorization: authorization } });
84
112
  }
85
113
  else {
86
114
  service.setBaseUrl(publicUrl);
@@ -88,29 +116,91 @@ function initialize(options) {
88
116
  }
89
117
  return { authorization, publicUrl, service };
90
118
  }
119
+ exports.initialize = initialize;
91
120
  function checkInitialized(authorization) {
92
121
  if (!authorization) {
93
122
  throw new Error("You should call initialize method with a valid apikey or identity token.");
94
123
  }
95
124
  }
125
+ exports.checkInitialized = checkInitialized;
96
126
  function getPublicUrl() {
97
127
  return isPlatformBrowser() ? undefined : process.env.__INTERNAL__SPICA__PUBLIC_URL__;
98
128
  }
99
129
  function isPlatformBrowser() {
100
130
  return typeof window !== "undefined";
101
131
  }
132
+ exports.isPlatformBrowser = isPlatformBrowser;
102
133
 
103
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
134
+ });
135
+
136
+ var _interface = createCommonjsModule(function (module, exports) {
137
+ Object.defineProperty(exports, "__esModule", { value: true });
138
+
139
+ });
140
+
141
+ var url = createCommonjsModule(function (module, exports) {
142
+ Object.defineProperty(exports, "__esModule", { value: true });
143
+ exports.buildUrl = void 0;
144
+ function buildUrl(baseUrl, queryParams = {}) {
145
+ const url = new URL(baseUrl);
146
+ for (let [key, value] of Object.entries(queryParams)) {
147
+ if (typeof value != "string") {
148
+ value = JSON.stringify(value);
149
+ }
150
+ url.searchParams.set(key, value);
151
+ }
152
+ return url;
153
+ }
154
+ exports.buildUrl = buildUrl;
155
+
156
+ });
157
+
158
+ var src = createCommonjsModule(function (module, exports) {
159
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
160
+ if (k2 === undefined) k2 = k;
161
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
162
+ }) : (function(o, m, k, k2) {
163
+ if (k2 === undefined) k2 = k;
164
+ o[k2] = m[k];
165
+ }));
166
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
167
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
168
+ };
169
+ Object.defineProperty(exports, "__esModule", { value: true });
170
+ __exportStar(initialize_1, exports);
171
+ __exportStar(_interface, exports);
172
+ __exportStar(request, exports);
173
+ __exportStar(url, exports);
174
+
175
+ });
176
+
177
+ var internal_common = createCommonjsModule(function (module, exports) {
178
+ var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
179
+ if (k2 === undefined) k2 = k;
180
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
181
+ }) : (function(o, m, k, k2) {
182
+ if (k2 === undefined) k2 = k;
183
+ o[k2] = m[k];
184
+ }));
185
+ var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
186
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
187
+ };
188
+ Object.defineProperty(exports, "__esModule", { value: true });
189
+ __exportStar(src, exports);
190
+
191
+ });
192
+
193
+ var commonjsGlobal$1 = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
104
194
 
105
195
  function unwrapExports (x) {
106
196
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
107
197
  }
108
198
 
109
- function createCommonjsModule(fn, module) {
199
+ function createCommonjsModule$1(fn, module) {
110
200
  return module = { exports: {} }, fn(module, module.exports), module.exports;
111
201
  }
112
202
 
113
- var ensure_buffer = createCommonjsModule(function (module, exports) {
203
+ var ensure_buffer = createCommonjsModule$1(function (module, exports) {
114
204
  Object.defineProperty(exports, "__esModule", { value: true });
115
205
  exports.ensureBuffer = void 0;
116
206
 
@@ -141,7 +231,7 @@ exports.ensureBuffer = ensureBuffer;
141
231
  unwrapExports(ensure_buffer);
142
232
  var ensure_buffer_1 = ensure_buffer.ensureBuffer;
143
233
 
144
- var uuid = createCommonjsModule(function (module, exports) {
234
+ var uuid = createCommonjsModule$1(function (module, exports) {
145
235
  Object.defineProperty(exports, "__esModule", { value: true });
146
236
  exports.parseUUID = void 0;
147
237
  /**
@@ -194,7 +284,7 @@ exports.parseUUID = parseUUID;
194
284
  unwrapExports(uuid);
195
285
  var uuid_1 = uuid.parseUUID;
196
286
 
197
- var binary = createCommonjsModule(function (module, exports) {
287
+ var binary = createCommonjsModule$1(function (module, exports) {
198
288
  Object.defineProperty(exports, "__esModule", { value: true });
199
289
  exports.Binary = void 0;
200
290
 
@@ -417,7 +507,7 @@ Object.defineProperty(Binary.prototype, '_bsontype', { value: 'Binary' });
417
507
  unwrapExports(binary);
418
508
  var binary_1 = binary.Binary;
419
509
 
420
- var code = createCommonjsModule(function (module, exports) {
510
+ var code = createCommonjsModule$1(function (module, exports) {
421
511
  Object.defineProperty(exports, "__esModule", { value: true });
422
512
  exports.Code = void 0;
423
513
  /**
@@ -1011,7 +1101,7 @@ var require$$1 = {
1011
1101
  debuglog: debuglog
1012
1102
  };
1013
1103
 
1014
- var utils = createCommonjsModule(function (module, exports) {
1104
+ var utils = createCommonjsModule$1(function (module, exports) {
1015
1105
  Object.defineProperty(exports, "__esModule", { value: true });
1016
1106
  exports.deprecate = exports.isObjectLike = exports.isDate = exports.isBuffer = exports.haveBuffer = exports.isBigUInt64Array = exports.isBigInt64Array = exports.isUint8Array = exports.randomBytes = exports.normalizedFunctionString = void 0;
1017
1107
 
@@ -1060,7 +1150,7 @@ function isBigUInt64Array(value) {
1060
1150
  exports.isBigUInt64Array = isBigUInt64Array;
1061
1151
  /** Call to check if your environment has `Buffer` */
1062
1152
  function haveBuffer() {
1063
- return typeof commonjsGlobal !== 'undefined' && typeof commonjsGlobal.Buffer !== 'undefined';
1153
+ return typeof commonjsGlobal$1 !== 'undefined' && typeof commonjsGlobal$1.Buffer !== 'undefined';
1064
1154
  }
1065
1155
  exports.haveBuffer = haveBuffer;
1066
1156
  /** Callable in any environment to check if value is a Buffer */
@@ -1113,7 +1203,7 @@ var utils_8 = utils.isUint8Array;
1113
1203
  var utils_9 = utils.randomBytes;
1114
1204
  var utils_10 = utils.normalizedFunctionString;
1115
1205
 
1116
- var db_ref = createCommonjsModule(function (module, exports) {
1206
+ var db_ref = createCommonjsModule$1(function (module, exports) {
1117
1207
  Object.defineProperty(exports, "__esModule", { value: true });
1118
1208
  exports.DBRef = exports.isDBRefLike = void 0;
1119
1209
 
@@ -1197,7 +1287,7 @@ unwrapExports(db_ref);
1197
1287
  var db_ref_1 = db_ref.DBRef;
1198
1288
  var db_ref_2 = db_ref.isDBRefLike;
1199
1289
 
1200
- var long_1 = createCommonjsModule(function (module, exports) {
1290
+ var long_1 = createCommonjsModule$1(function (module, exports) {
1201
1291
  Object.defineProperty(exports, "__esModule", { value: true });
1202
1292
  exports.Long = void 0;
1203
1293
 
@@ -2033,7 +2123,7 @@ Object.defineProperty(Long.prototype, '_bsontype', { value: 'Long' });
2033
2123
  unwrapExports(long_1);
2034
2124
  var long_2 = long_1.Long;
2035
2125
 
2036
- var decimal128 = createCommonjsModule(function (module, exports) {
2126
+ var decimal128 = createCommonjsModule$1(function (module, exports) {
2037
2127
  Object.defineProperty(exports, "__esModule", { value: true });
2038
2128
  exports.Decimal128 = void 0;
2039
2129
 
@@ -2725,7 +2815,7 @@ Object.defineProperty(Decimal128.prototype, '_bsontype', { value: 'Decimal128' }
2725
2815
  unwrapExports(decimal128);
2726
2816
  var decimal128_1 = decimal128.Decimal128;
2727
2817
 
2728
- var double_1 = createCommonjsModule(function (module, exports) {
2818
+ var double_1 = createCommonjsModule$1(function (module, exports) {
2729
2819
  Object.defineProperty(exports, "__esModule", { value: true });
2730
2820
  exports.Double = void 0;
2731
2821
  /**
@@ -2792,7 +2882,7 @@ Object.defineProperty(Double.prototype, '_bsontype', { value: 'Double' });
2792
2882
  unwrapExports(double_1);
2793
2883
  var double_2 = double_1.Double;
2794
2884
 
2795
- var int_32 = createCommonjsModule(function (module, exports) {
2885
+ var int_32 = createCommonjsModule$1(function (module, exports) {
2796
2886
  Object.defineProperty(exports, "__esModule", { value: true });
2797
2887
  exports.Int32 = void 0;
2798
2888
  /**
@@ -2842,7 +2932,7 @@ Object.defineProperty(Int32.prototype, '_bsontype', { value: 'Int32' });
2842
2932
  unwrapExports(int_32);
2843
2933
  var int_32_1 = int_32.Int32;
2844
2934
 
2845
- var map = createCommonjsModule(function (module, exports) {
2935
+ var map = createCommonjsModule$1(function (module, exports) {
2846
2936
  /* eslint-disable @typescript-eslint/no-explicit-any */
2847
2937
  // We have an ES6 Map available, return the native instance
2848
2938
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -2860,7 +2950,7 @@ function getGlobal() {
2860
2950
  return (check(typeof globalThis === 'object' && globalThis) ||
2861
2951
  check(typeof window === 'object' && window) ||
2862
2952
  check(typeof self === 'object' && self) ||
2863
- check(typeof commonjsGlobal === 'object' && commonjsGlobal) ||
2953
+ check(typeof commonjsGlobal$1 === 'object' && commonjsGlobal$1) ||
2864
2954
  Function('return this')());
2865
2955
  }
2866
2956
  const bsonGlobal = getGlobal();
@@ -2973,7 +3063,7 @@ else {
2973
3063
  unwrapExports(map);
2974
3064
  var map_1 = map.Map;
2975
3065
 
2976
- var max_key = createCommonjsModule(function (module, exports) {
3066
+ var max_key = createCommonjsModule$1(function (module, exports) {
2977
3067
  Object.defineProperty(exports, "__esModule", { value: true });
2978
3068
  exports.MaxKey = void 0;
2979
3069
  /**
@@ -2998,7 +3088,7 @@ Object.defineProperty(MaxKey.prototype, '_bsontype', { value: 'MaxKey' });
2998
3088
  unwrapExports(max_key);
2999
3089
  var max_key_1 = max_key.MaxKey;
3000
3090
 
3001
- var min_key = createCommonjsModule(function (module, exports) {
3091
+ var min_key = createCommonjsModule$1(function (module, exports) {
3002
3092
  Object.defineProperty(exports, "__esModule", { value: true });
3003
3093
  exports.MinKey = void 0;
3004
3094
  /**
@@ -3023,7 +3113,7 @@ Object.defineProperty(MinKey.prototype, '_bsontype', { value: 'MinKey' });
3023
3113
  unwrapExports(min_key);
3024
3114
  var min_key_1 = min_key.MinKey;
3025
3115
 
3026
- var objectid = createCommonjsModule(function (module, exports) {
3116
+ var objectid = createCommonjsModule$1(function (module, exports) {
3027
3117
  Object.defineProperty(exports, "__esModule", { value: true });
3028
3118
  exports.ObjectId = void 0;
3029
3119
 
@@ -3326,7 +3416,7 @@ Object.defineProperty(ObjectId.prototype, '_bsontype', { value: 'ObjectID' });
3326
3416
  unwrapExports(objectid);
3327
3417
  var objectid_1 = objectid.ObjectId;
3328
3418
 
3329
- var constants = createCommonjsModule(function (module, exports) {
3419
+ var constants = createCommonjsModule$1(function (module, exports) {
3330
3420
  Object.defineProperty(exports, "__esModule", { value: true });
3331
3421
  exports.BSON_BINARY_SUBTYPE_USER_DEFINED = exports.BSON_BINARY_SUBTYPE_MD5 = exports.BSON_BINARY_SUBTYPE_UUID_NEW = exports.BSON_BINARY_SUBTYPE_UUID = exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY = exports.BSON_BINARY_SUBTYPE_FUNCTION = exports.BSON_BINARY_SUBTYPE_DEFAULT = exports.BSON_DATA_MAX_KEY = exports.BSON_DATA_MIN_KEY = exports.BSON_DATA_DECIMAL128 = exports.BSON_DATA_LONG = exports.BSON_DATA_TIMESTAMP = exports.BSON_DATA_INT = exports.BSON_DATA_CODE_W_SCOPE = exports.BSON_DATA_SYMBOL = exports.BSON_DATA_CODE = exports.BSON_DATA_DBPOINTER = exports.BSON_DATA_REGEXP = exports.BSON_DATA_NULL = exports.BSON_DATA_DATE = exports.BSON_DATA_BOOLEAN = exports.BSON_DATA_OID = exports.BSON_DATA_UNDEFINED = exports.BSON_DATA_BINARY = exports.BSON_DATA_ARRAY = exports.BSON_DATA_OBJECT = exports.BSON_DATA_STRING = exports.BSON_DATA_NUMBER = exports.JS_INT_MIN = exports.JS_INT_MAX = exports.BSON_INT64_MIN = exports.BSON_INT64_MAX = exports.BSON_INT32_MIN = exports.BSON_INT32_MAX = void 0;
3332
3422
  /** @internal */
@@ -3442,7 +3532,7 @@ var constants_32 = constants.BSON_INT64_MAX;
3442
3532
  var constants_33 = constants.BSON_INT32_MIN;
3443
3533
  var constants_34 = constants.BSON_INT32_MAX;
3444
3534
 
3445
- var calculate_size = createCommonjsModule(function (module, exports) {
3535
+ var calculate_size = createCommonjsModule$1(function (module, exports) {
3446
3536
  Object.defineProperty(exports, "__esModule", { value: true });
3447
3537
  exports.calculateObjectSize = void 0;
3448
3538
 
@@ -3638,7 +3728,7 @@ value, serializeFunctions = false, isArray = false, ignoreUndefined = false) {
3638
3728
  unwrapExports(calculate_size);
3639
3729
  var calculate_size_1 = calculate_size.calculateObjectSize;
3640
3730
 
3641
- var regexp = createCommonjsModule(function (module, exports) {
3731
+ var regexp = createCommonjsModule$1(function (module, exports) {
3642
3732
  Object.defineProperty(exports, "__esModule", { value: true });
3643
3733
  exports.BSONRegExp = void 0;
3644
3734
  function alphabetize(str) {
@@ -3708,7 +3798,7 @@ Object.defineProperty(BSONRegExp.prototype, '_bsontype', { value: 'BSONRegExp' }
3708
3798
  unwrapExports(regexp);
3709
3799
  var regexp_1 = regexp.BSONRegExp;
3710
3800
 
3711
- var symbol = createCommonjsModule(function (module, exports) {
3801
+ var symbol = createCommonjsModule$1(function (module, exports) {
3712
3802
  Object.defineProperty(exports, "__esModule", { value: true });
3713
3803
  exports.BSONSymbol = void 0;
3714
3804
  /**
@@ -3755,7 +3845,7 @@ Object.defineProperty(BSONSymbol.prototype, '_bsontype', { value: 'Symbol' });
3755
3845
  unwrapExports(symbol);
3756
3846
  var symbol_1 = symbol.BSONSymbol;
3757
3847
 
3758
- var timestamp$1 = createCommonjsModule(function (module, exports) {
3848
+ var timestamp$1 = createCommonjsModule$1(function (module, exports) {
3759
3849
  Object.defineProperty(exports, "__esModule", { value: true });
3760
3850
  exports.Timestamp = exports.LongWithoutOverridesClass = void 0;
3761
3851
 
@@ -3826,7 +3916,7 @@ unwrapExports(timestamp$1);
3826
3916
  var timestamp_1 = timestamp$1.Timestamp;
3827
3917
  var timestamp_2 = timestamp$1.LongWithoutOverridesClass;
3828
3918
 
3829
- var validate_utf8 = createCommonjsModule(function (module, exports) {
3919
+ var validate_utf8 = createCommonjsModule$1(function (module, exports) {
3830
3920
  Object.defineProperty(exports, "__esModule", { value: true });
3831
3921
  exports.validateUtf8 = void 0;
3832
3922
  const FIRST_BIT = 0x80;
@@ -3878,7 +3968,7 @@ exports.validateUtf8 = validateUtf8;
3878
3968
  unwrapExports(validate_utf8);
3879
3969
  var validate_utf8_1 = validate_utf8.validateUtf8;
3880
3970
 
3881
- var deserializer = createCommonjsModule(function (module, exports) {
3971
+ var deserializer = createCommonjsModule$1(function (module, exports) {
3882
3972
  Object.defineProperty(exports, "__esModule", { value: true });
3883
3973
  exports.deserialize = void 0;
3884
3974
 
@@ -4446,7 +4536,7 @@ function isolateEval(functionString, functionCache, object) {
4446
4536
  unwrapExports(deserializer);
4447
4537
  var deserializer_1 = deserializer.deserialize;
4448
4538
 
4449
- var extended_json = createCommonjsModule(function (module, exports) {
4539
+ var extended_json = createCommonjsModule$1(function (module, exports) {
4450
4540
  Object.defineProperty(exports, "__esModule", { value: true });
4451
4541
  exports.EJSON = exports.isBSONType = void 0;
4452
4542
 
@@ -4759,7 +4849,7 @@ unwrapExports(extended_json);
4759
4849
  var extended_json_1 = extended_json.EJSON;
4760
4850
  var extended_json_2 = extended_json.isBSONType;
4761
4851
 
4762
- var float_parser = createCommonjsModule(function (module, exports) {
4852
+ var float_parser = createCommonjsModule$1(function (module, exports) {
4763
4853
  // Copyright (c) 2008, Fair Oaks Labs, Inc.
4764
4854
  // All rights reserved.
4765
4855
  //
@@ -4902,7 +4992,7 @@ unwrapExports(float_parser);
4902
4992
  var float_parser_1 = float_parser.writeIEEE754;
4903
4993
  var float_parser_2 = float_parser.readIEEE754;
4904
4994
 
4905
- var serializer = createCommonjsModule(function (module, exports) {
4995
+ var serializer = createCommonjsModule$1(function (module, exports) {
4906
4996
  Object.defineProperty(exports, "__esModule", { value: true });
4907
4997
  exports.serializeInto = void 0;
4908
4998
 
@@ -5756,7 +5846,7 @@ exports.serializeInto = serializeInto;
5756
5846
  unwrapExports(serializer);
5757
5847
  var serializer_1 = serializer.serializeInto;
5758
5848
 
5759
- var bson = createCommonjsModule(function (module, exports) {
5849
+ var bson = createCommonjsModule$1(function (module, exports) {
5760
5850
  Object.defineProperty(exports, "__esModule", { value: true });
5761
5851
  exports.deserializeStream = exports.calculateObjectSize = exports.deserialize = exports.serializeWithBufferAndIndex = exports.serialize = exports.setInternalBufferSize = exports.ObjectID = exports.Decimal128 = exports.BSONRegExp = exports.MaxKey = exports.MinKey = exports.Int32 = exports.Double = exports.Timestamp = exports.Long = exports.ObjectId = exports.Binary = exports.DBRef = exports.BSONSymbol = exports.Map = exports.Code = exports.LongWithoutOverridesClass = exports.EJSON = exports.JS_INT_MIN = exports.JS_INT_MAX = exports.BSON_INT64_MIN = exports.BSON_INT64_MAX = exports.BSON_INT32_MIN = exports.BSON_INT32_MAX = exports.BSON_DATA_UNDEFINED = exports.BSON_DATA_TIMESTAMP = exports.BSON_DATA_SYMBOL = exports.BSON_DATA_STRING = exports.BSON_DATA_REGEXP = exports.BSON_DATA_OID = exports.BSON_DATA_OBJECT = exports.BSON_DATA_NUMBER = exports.BSON_DATA_NULL = exports.BSON_DATA_MIN_KEY = exports.BSON_DATA_MAX_KEY = exports.BSON_DATA_LONG = exports.BSON_DATA_INT = exports.BSON_DATA_DECIMAL128 = exports.BSON_DATA_DBPOINTER = exports.BSON_DATA_DATE = exports.BSON_DATA_CODE_W_SCOPE = exports.BSON_DATA_CODE = exports.BSON_DATA_BOOLEAN = exports.BSON_DATA_BINARY = exports.BSON_DATA_ARRAY = exports.BSON_BINARY_SUBTYPE_UUID_NEW = exports.BSON_BINARY_SUBTYPE_UUID = exports.BSON_BINARY_SUBTYPE_USER_DEFINED = exports.BSON_BINARY_SUBTYPE_MD5 = exports.BSON_BINARY_SUBTYPE_FUNCTION = exports.BSON_BINARY_SUBTYPE_DEFAULT = exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY = void 0;
5762
5852
 
@@ -6021,15 +6111,6 @@ var bson_55 = bson.BSON_BINARY_SUBTYPE_FUNCTION;
6021
6111
  var bson_56 = bson.BSON_BINARY_SUBTYPE_DEFAULT;
6022
6112
  var bson_57 = bson.BSON_BINARY_SUBTYPE_BYTE_ARRAY;
6023
6113
 
6024
- var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
6025
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6026
- return new (P || (P = Promise))(function (resolve, reject) {
6027
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6028
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6029
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
6030
- step((generator = generator.apply(thisArg, _arguments || [])).next());
6031
- });
6032
- };
6033
6114
  function fileToBuffer(file) {
6034
6115
  return new Promise((resolve, reject) => {
6035
6116
  const reader = new FileReader();
@@ -6038,56 +6119,50 @@ function fileToBuffer(file) {
6038
6119
  reader.onerror = error => reject(error);
6039
6120
  });
6040
6121
  }
6041
- function preparePostBody(objects) {
6042
- return __awaiter(this, void 0, void 0, function* () {
6043
- let files;
6044
- const contents = [];
6045
- // FileList to File array
6046
- if (!Array.isArray(objects)) {
6047
- files = Array.from(objects);
6048
- }
6049
- else {
6050
- files = objects;
6051
- }
6052
- for (const file of files) {
6053
- const content = yield getContent(file);
6054
- contents.push(content);
6055
- }
6056
- const body = {
6057
- content: contents
6058
- };
6059
- return jsonToArrayBuffer(body);
6060
- });
6122
+ async function preparePostBody(objects) {
6123
+ let files;
6124
+ const contents = [];
6125
+ // FileList to File array
6126
+ if (!Array.isArray(objects)) {
6127
+ files = Array.from(objects);
6128
+ }
6129
+ else {
6130
+ files = objects;
6131
+ }
6132
+ for (const file of files) {
6133
+ const content = await getContent(file);
6134
+ contents.push(content);
6135
+ }
6136
+ const body = {
6137
+ content: contents
6138
+ };
6139
+ return jsonToArrayBuffer(body);
6061
6140
  }
6062
- function preparePutBody(object) {
6063
- return __awaiter(this, void 0, void 0, function* () {
6064
- const body = yield getContent(object);
6065
- return jsonToArrayBuffer(body);
6066
- });
6141
+ async function preparePutBody(object) {
6142
+ const body = await getContent(object);
6143
+ return jsonToArrayBuffer(body);
6067
6144
  }
6068
- function getContent(file) {
6069
- return __awaiter(this, void 0, void 0, function* () {
6070
- let data;
6071
- let name;
6072
- let type;
6073
- if (instanceOfBufferWithMeta(file)) {
6074
- data = file.data;
6075
- name = file.name;
6076
- type = file.contentType;
6077
- }
6078
- else {
6079
- data = yield fileToBuffer(file);
6080
- name = file.name;
6081
- type = file.type;
6145
+ async function getContent(file) {
6146
+ let data;
6147
+ let name;
6148
+ let type;
6149
+ if (instanceOfBufferWithMeta(file)) {
6150
+ data = file.data;
6151
+ name = file.name;
6152
+ type = file.contentType;
6153
+ }
6154
+ else {
6155
+ data = await fileToBuffer(file);
6156
+ name = file.name;
6157
+ type = file.type;
6158
+ }
6159
+ return {
6160
+ name,
6161
+ content: {
6162
+ data: new bson_17(data),
6163
+ type
6082
6164
  }
6083
- return {
6084
- name,
6085
- content: {
6086
- data: new bson_17(data),
6087
- type
6088
- }
6089
- };
6090
- });
6165
+ };
6091
6166
  }
6092
6167
  function jsonToArrayBuffer(body) {
6093
6168
  const size = bson_2(body);
@@ -6098,79 +6173,64 @@ function instanceOfBufferWithMeta(value) {
6098
6173
  return "data" in value && "name" in value && "contentType" in value;
6099
6174
  }
6100
6175
 
6101
- var __awaiter$1 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
6102
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6103
- return new (P || (P = Promise))(function (resolve, reject) {
6104
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6105
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6106
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
6107
- step((generator = generator.apply(thisArg, _arguments || [])).next());
6108
- });
6109
- };
6110
6176
  let authorization;
6111
- let service$1;
6112
- function initialize$1(options) {
6113
- const { authorization: _authorization, service: _service } = initialize(options);
6177
+ let service;
6178
+ function initialize(options) {
6179
+ const { authorization: _authorization, service: _service } = internal_common.initialize(options);
6114
6180
  authorization = _authorization;
6115
- service$1 = _service;
6116
- service$1.setWriteDefaults({
6181
+ service = _service;
6182
+ service.setWriteDefaults({
6117
6183
  headers: {
6118
6184
  "Content-Type": "application/bson"
6119
6185
  }
6120
6186
  });
6121
6187
  }
6122
- function insert(object, onUploadProgress) {
6123
- return __awaiter$1(this, void 0, void 0, function* () {
6124
- checkInitialized(authorization);
6125
- const body = yield preparePostBody([object]);
6126
- return service$1.post("storage", body, {
6127
- onUploadProgress
6128
- });
6188
+ async function insert(object, onUploadProgress) {
6189
+ internal_common.checkInitialized(authorization);
6190
+ const body = await preparePostBody([object]);
6191
+ return service.post("storage", body, {
6192
+ onUploadProgress
6129
6193
  });
6130
6194
  }
6131
- function insertMany(objects, onUploadProgress) {
6132
- return __awaiter$1(this, void 0, void 0, function* () {
6133
- checkInitialized(authorization);
6134
- const body = yield preparePostBody(objects);
6135
- return service$1.post("storage", body, {
6136
- onUploadProgress
6137
- });
6195
+ async function insertMany(objects, onUploadProgress) {
6196
+ internal_common.checkInitialized(authorization);
6197
+ const body = await preparePostBody(objects);
6198
+ return service.post("storage", body, {
6199
+ onUploadProgress
6138
6200
  });
6139
6201
  }
6140
6202
  function get(id) {
6141
- checkInitialized(authorization);
6142
- return service$1.get(`storage/${id}`);
6203
+ internal_common.checkInitialized(authorization);
6204
+ return service.get(`storage/${id}`);
6143
6205
  }
6144
6206
  /**
6145
6207
  * Returns Blob for browser environment, ReadableStream for Nodejs environment
6146
6208
  */
6147
6209
  function download(id, options = {}) {
6148
- checkInitialized(authorization);
6149
- return service$1.get(`storage/${id}/view`, {
6210
+ internal_common.checkInitialized(authorization);
6211
+ return service.get(`storage/${id}/view`, {
6150
6212
  headers: options.headers,
6151
6213
  onDownloadProgress: options.onDownloadProgress,
6152
- responseType: isPlatformBrowser() ? "blob" : "stream"
6214
+ responseType: internal_common.isPlatformBrowser() ? "blob" : "stream"
6153
6215
  });
6154
6216
  }
6155
6217
  function getAll(queryParams) {
6156
- checkInitialized(authorization);
6157
- return service$1.get(`storage`, {
6218
+ internal_common.checkInitialized(authorization);
6219
+ return service.get(`storage`, {
6158
6220
  params: queryParams
6159
6221
  });
6160
6222
  }
6161
- function update(id, object, onUploadProgress) {
6162
- return __awaiter$1(this, void 0, void 0, function* () {
6163
- checkInitialized(authorization);
6164
- const body = yield preparePutBody(object);
6165
- return service$1.put(`storage/${id}`, body, {
6166
- onUploadProgress
6167
- });
6223
+ async function update(id, object, onUploadProgress) {
6224
+ internal_common.checkInitialized(authorization);
6225
+ const body = await preparePutBody(object);
6226
+ return service.put(`storage/${id}`, body, {
6227
+ onUploadProgress
6168
6228
  });
6169
6229
  }
6170
6230
  function remove(id) {
6171
- checkInitialized(authorization);
6172
- return service$1.delete(`storage/${id}`);
6231
+ internal_common.checkInitialized(authorization);
6232
+ return service.delete(`storage/${id}`);
6173
6233
  }
6174
6234
 
6175
- export { download, get, getAll, initialize$1 as initialize, insert, insertMany, remove, update };
6235
+ export { download, get, getAll, initialize, insert, insertMany, remove, update };
6176
6236
  //# sourceMappingURL=index.mjs.map