@spica-devkit/storage 0.9.15 → 0.9.18

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.js CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var axios_1 = require('axios');
4
6
  var buffer = require('buffer');
5
7
 
@@ -10,10 +12,6 @@ var buffer__default = /*#__PURE__*/_interopDefaultLegacy(buffer);
10
12
 
11
13
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
12
14
 
13
- function getDefaultExportFromCjs (x) {
14
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
15
- }
16
-
17
15
  function createCommonjsModule(fn, basedir, module) {
18
16
  return module = {
19
17
  path: basedir,
@@ -24,21 +22,6 @@ function createCommonjsModule(fn, basedir, module) {
24
22
  }, fn(module, module.exports), module.exports;
25
23
  }
26
24
 
27
- function getAugmentedNamespace(n) {
28
- if (n.__esModule) return n;
29
- var a = Object.defineProperty({}, '__esModule', {value: true});
30
- Object.keys(n).forEach(function (k) {
31
- var d = Object.getOwnPropertyDescriptor(n, k);
32
- Object.defineProperty(a, k, d.get ? d : {
33
- enumerable: true,
34
- get: function () {
35
- return n[k];
36
- }
37
- });
38
- });
39
- return a;
40
- }
41
-
42
25
  function commonjsRequire () {
43
26
  throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
44
27
  }
@@ -6137,74 +6120,6 @@ var bson_55 = bson.BSON_BINARY_SUBTYPE_FUNCTION;
6137
6120
  var bson_56 = bson.BSON_BINARY_SUBTYPE_DEFAULT;
6138
6121
  var bson_57 = bson.BSON_BINARY_SUBTYPE_BYTE_ARRAY;
6139
6122
 
6140
- var bson_esm = /*#__PURE__*/Object.freeze({
6141
- __proto__: null,
6142
- 'default': bson$1,
6143
- BSONRegExp: bson_9,
6144
- BSONSymbol: bson_19,
6145
- BSON_BINARY_SUBTYPE_BYTE_ARRAY: bson_57,
6146
- BSON_BINARY_SUBTYPE_DEFAULT: bson_56,
6147
- BSON_BINARY_SUBTYPE_FUNCTION: bson_55,
6148
- BSON_BINARY_SUBTYPE_MD5: bson_54,
6149
- BSON_BINARY_SUBTYPE_USER_DEFINED: bson_53,
6150
- BSON_BINARY_SUBTYPE_UUID: bson_52,
6151
- BSON_BINARY_SUBTYPE_UUID_NEW: bson_51,
6152
- BSON_DATA_ARRAY: bson_50,
6153
- BSON_DATA_BINARY: bson_49,
6154
- BSON_DATA_BOOLEAN: bson_48,
6155
- BSON_DATA_CODE: bson_47,
6156
- BSON_DATA_CODE_W_SCOPE: bson_46,
6157
- BSON_DATA_DATE: bson_45,
6158
- BSON_DATA_DBPOINTER: bson_44,
6159
- BSON_DATA_DECIMAL128: bson_43,
6160
- BSON_DATA_INT: bson_42,
6161
- BSON_DATA_LONG: bson_41,
6162
- BSON_DATA_MAX_KEY: bson_40,
6163
- BSON_DATA_MIN_KEY: bson_39,
6164
- BSON_DATA_NULL: bson_38,
6165
- BSON_DATA_NUMBER: bson_37,
6166
- BSON_DATA_OBJECT: bson_36,
6167
- BSON_DATA_OID: bson_35,
6168
- BSON_DATA_REGEXP: bson_34,
6169
- BSON_DATA_STRING: bson_33,
6170
- BSON_DATA_SYMBOL: bson_32,
6171
- BSON_DATA_TIMESTAMP: bson_31,
6172
- BSON_DATA_UNDEFINED: bson_30,
6173
- BSON_INT32_MAX: bson_29,
6174
- BSON_INT32_MIN: bson_28,
6175
- BSON_INT64_MAX: bson_27,
6176
- BSON_INT64_MIN: bson_26,
6177
- Binary: bson_17,
6178
- Code: bson_21,
6179
- DBRef: bson_18,
6180
- Decimal128: bson_8,
6181
- Double: bson_13,
6182
- EJSON: bson_23,
6183
- Int32: bson_12,
6184
- JS_INT_MAX: bson_25,
6185
- JS_INT_MIN: bson_24,
6186
- Long: bson_15,
6187
- LongWithoutOverridesClass: bson_22,
6188
- Map: bson_20,
6189
- MaxKey: bson_10,
6190
- MinKey: bson_11,
6191
- ObjectID: bson_7,
6192
- ObjectId: bson_16,
6193
- Timestamp: bson_14,
6194
- calculateObjectSize: bson_2,
6195
- deserialize: bson_3,
6196
- deserializeStream: bson_1,
6197
- serialize: bson_5,
6198
- serializeWithBufferAndIndex: bson_4,
6199
- setInternalBufferSize: bson_6
6200
- });
6201
-
6202
- var BSON = /*@__PURE__*/getAugmentedNamespace(bson_esm);
6203
-
6204
- var utility = createCommonjsModule(function (module, exports) {
6205
- Object.defineProperty(exports, "__esModule", { value: true });
6206
- exports.jsonToArrayBuffer = exports.preparePutBody = exports.preparePostBody = exports.fileToBuffer = void 0;
6207
-
6208
6123
  function fileToBuffer(file) {
6209
6124
  return new Promise((resolve, reject) => {
6210
6125
  const reader = new FileReader();
@@ -6213,10 +6128,10 @@ function fileToBuffer(file) {
6213
6128
  reader.onerror = error => reject(error);
6214
6129
  });
6215
6130
  }
6216
- exports.fileToBuffer = fileToBuffer;
6217
6131
  async function preparePostBody(objects) {
6218
6132
  let files;
6219
6133
  const contents = [];
6134
+ // FileList to File array
6220
6135
  if (!Array.isArray(objects)) {
6221
6136
  files = Array.from(objects);
6222
6137
  }
@@ -6232,12 +6147,10 @@ async function preparePostBody(objects) {
6232
6147
  };
6233
6148
  return jsonToArrayBuffer(body);
6234
6149
  }
6235
- exports.preparePostBody = preparePostBody;
6236
6150
  async function preparePutBody(object) {
6237
6151
  const body = await getContent(object);
6238
6152
  return jsonToArrayBuffer(body);
6239
6153
  }
6240
- exports.preparePutBody = preparePutBody;
6241
6154
  async function getContent(file) {
6242
6155
  let data;
6243
6156
  let name;
@@ -6255,28 +6168,20 @@ async function getContent(file) {
6255
6168
  return {
6256
6169
  name,
6257
6170
  content: {
6258
- data: new BSON.Binary(data),
6171
+ data: new bson_17(data),
6259
6172
  type
6260
6173
  }
6261
6174
  };
6262
6175
  }
6263
6176
  function jsonToArrayBuffer(body) {
6264
- const size = BSON.calculateObjectSize(body);
6265
- const buffer = BSON.serialize(body, { minInternalBufferSize: size });
6177
+ const size = bson_2(body);
6178
+ const buffer = bson_5(body, { minInternalBufferSize: size });
6266
6179
  return buffer.buffer;
6267
6180
  }
6268
- exports.jsonToArrayBuffer = jsonToArrayBuffer;
6269
6181
  function instanceOfBufferWithMeta(value) {
6270
6182
  return "data" in value && "name" in value && "contentType" in value;
6271
6183
  }
6272
6184
 
6273
- });
6274
-
6275
- var storage = createCommonjsModule(function (module, exports) {
6276
- Object.defineProperty(exports, "__esModule", { value: true });
6277
- exports.remove = exports.update = exports.getAll = exports.download = exports.get = exports.insertMany = exports.insert = exports.initialize = void 0;
6278
-
6279
-
6280
6185
  let authorization;
6281
6186
  let service;
6282
6187
  function initialize(options) {
@@ -6289,28 +6194,27 @@ function initialize(options) {
6289
6194
  }
6290
6195
  });
6291
6196
  }
6292
- exports.initialize = initialize;
6293
6197
  async function insert(object, onUploadProgress) {
6294
6198
  internal_common.checkInitialized(authorization);
6295
- const body = await utility.preparePostBody([object]);
6199
+ const body = await preparePostBody([object]);
6296
6200
  return service.post("storage", body, {
6297
6201
  onUploadProgress
6298
6202
  });
6299
6203
  }
6300
- exports.insert = insert;
6301
6204
  async function insertMany(objects, onUploadProgress) {
6302
6205
  internal_common.checkInitialized(authorization);
6303
- const body = await utility.preparePostBody(objects);
6206
+ const body = await preparePostBody(objects);
6304
6207
  return service.post("storage", body, {
6305
6208
  onUploadProgress
6306
6209
  });
6307
6210
  }
6308
- exports.insertMany = insertMany;
6309
6211
  function get(id) {
6310
6212
  internal_common.checkInitialized(authorization);
6311
6213
  return service.get(`storage/${id}`);
6312
6214
  }
6313
- exports.get = get;
6215
+ /**
6216
+ * Returns Blob for browser environment, ReadableStream for Nodejs environment
6217
+ */
6314
6218
  function download(id, options = {}) {
6315
6219
  internal_common.checkInitialized(authorization);
6316
6220
  return service.get(`storage/${id}/view`, {
@@ -6319,69 +6223,30 @@ function download(id, options = {}) {
6319
6223
  responseType: internal_common.isPlatformBrowser() ? "blob" : "stream"
6320
6224
  });
6321
6225
  }
6322
- exports.download = download;
6323
6226
  function getAll(queryParams) {
6324
6227
  internal_common.checkInitialized(authorization);
6325
6228
  return service.get(`storage`, {
6326
6229
  params: queryParams
6327
6230
  });
6328
6231
  }
6329
- exports.getAll = getAll;
6330
6232
  async function update(id, object, onUploadProgress) {
6331
6233
  internal_common.checkInitialized(authorization);
6332
- const body = await utility.preparePutBody(object);
6234
+ const body = await preparePutBody(object);
6333
6235
  return service.put(`storage/${id}`, body, {
6334
6236
  onUploadProgress
6335
6237
  });
6336
6238
  }
6337
- exports.update = update;
6338
6239
  function remove(id) {
6339
6240
  internal_common.checkInitialized(authorization);
6340
6241
  return service.delete(`storage/${id}`);
6341
6242
  }
6342
- exports.remove = remove;
6343
6243
 
6344
- });
6345
-
6346
- var _interface$1 = createCommonjsModule(function (module, exports) {
6347
- Object.defineProperty(exports, "__esModule", { value: true });
6348
-
6349
- });
6350
-
6351
- var src$1 = createCommonjsModule(function (module, exports) {
6352
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6353
- if (k2 === undefined) k2 = k;
6354
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
6355
- }) : (function(o, m, k, k2) {
6356
- if (k2 === undefined) k2 = k;
6357
- o[k2] = m[k];
6358
- }));
6359
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
6360
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
6361
- };
6362
- Object.defineProperty(exports, "__esModule", { value: true });
6363
- __exportStar(storage, exports);
6364
- __exportStar(_interface$1, exports);
6365
-
6366
- });
6367
-
6368
- var storage$1 = createCommonjsModule(function (module, exports) {
6369
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6370
- if (k2 === undefined) k2 = k;
6371
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
6372
- }) : (function(o, m, k, k2) {
6373
- if (k2 === undefined) k2 = k;
6374
- o[k2] = m[k];
6375
- }));
6376
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
6377
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
6378
- };
6379
- Object.defineProperty(exports, "__esModule", { value: true });
6380
- __exportStar(src$1, exports);
6381
-
6382
- });
6383
-
6384
- var index = /*@__PURE__*/getDefaultExportFromCjs(storage$1);
6385
-
6386
- module.exports = index;
6244
+ exports.download = download;
6245
+ exports.get = get;
6246
+ exports.getAll = getAll;
6247
+ exports.initialize = initialize;
6248
+ exports.insert = insert;
6249
+ exports.insertMany = insertMany;
6250
+ exports.remove = remove;
6251
+ exports.update = update;
6387
6252
  //# sourceMappingURL=index.js.map