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