Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@e-mc/cloud

Package Overview
Dependencies
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@e-mc/cloud - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

0

index.d.ts

@@ -0,0 +0,0 @@ import type { CloudConstructor, IFileManager } from '../types/lib';

104

index.js

@@ -5,5 +5,5 @@ "use strict";

const fs = require("fs");
const types_1 = require("../types");
const core_1 = require("../core");
const util_1 = require("./util");
const types_1 = require("@e-mc/types");
const core_1 = require("@e-mc/core");
const util_1 = require("@e-mc/cloud/util");
const SERVICE_CLIENT = new Map();

@@ -66,3 +66,3 @@ const SERVICE_UPLOAD = {};

if (await instance.commit()) {
instance.writeTimeElapsed(instance.moduleName, "Transactions were committed" /* VAL_MESSAGE.COMMIT_TRANSACTION */, startTime, { type: 64 /* LOG_TYPE.CLOUD */, ...Cloud.LOG_STYLE_SUCCESS });
instance.writeTimeElapsed(instance.moduleName, "Transactions were committed", startTime, { type: 64, ...Cloud.LOG_STYLE_SUCCESS });
}

@@ -76,3 +76,3 @@ for (const { instance: document } of this.Document) {

if (item.invalid) {
cloudStorage.forEach(storage => instance.formatMessage(64 /* LOG_TYPE.CLOUD */, storage.service, ["Upload failed" /* ERR_CLOUD.UPLOAD_FAIL */, storage.bucket], (0, types_1.errorValue)("File not found" /* ERR_MESSAGE.NOTFOUND_FILE */, item.uri || item.filename || "Unknown" /* ERR_MESSAGE.UNKNOWN */), { ...Cloud.LOG_CLOUD_WARN }));
cloudStorage.forEach(storage => instance.formatMessage(64, storage.service, ["Upload failed", storage.bucket], (0, types_1.errorValue)("File not found", item.uri || item.filename || "Unknown"), { ...Cloud.LOG_CLOUD_WARN }));
continue;

@@ -126,3 +126,3 @@ }

const [credential, recursive] = map[bucket];
tasks.push(instance.deleteObjects(service, credential, bucket, recursive).catch(err => instance.writeFail(["Unable to empty bucket" /* ERR_CLOUD.DELETE_BUCKET */, service + ': ' + bucket], err, { type: 64 /* LOG_TYPE.CLOUD */, startTime })));
tasks.push(instance.deleteObjects(service, credential, bucket, recursive).catch(err => instance.writeFail(["Unable to empty bucket", service + ': ' + bucket], err, { type: 64, startTime })));
}

@@ -149,3 +149,3 @@ }

const params = map[bucket];
tasks.push(instance.setBucketPolicy(...params).catch(err => instance.writeFail(["Unable to update bucket policy" /* ERR_CLOUD.POLICY_BUCKET */, params[0] + ': ' + params[2]], err, { type: 64 /* LOG_TYPE.CLOUD */, startTime })));
tasks.push(instance.setBucketPolicy(...params).catch(err => instance.writeFail(["Unable to update bucket policy", params[0] + ': ' + params[2]], err, { type: 64, startTime })));
}

@@ -162,3 +162,3 @@ }

if (document.cloudFinalize) {
await document.cloudFinalize(state).catch(err => document.writeFail(["Handled rejection" /* ERR_MESSAGE.HANDLED_REJECTION */, document.moduleName], err, { type: 64 /* LOG_TYPE.CLOUD */, startTime }));
await document.cloudFinalize(state).catch(err => document.writeFail(["Handled rejection", document.moduleName], err, { type: 64, startTime }));
if (document.aborted) {

@@ -190,3 +190,3 @@ return Promise.reject((0, types_1.createAbortError)());

if (!Cloud.isPath(downloadUri) && !this.canWrite(pathname)) {
instance.writeFail(["Unable to download file" /* ERR_MESSAGE.DOWNLOAD_FILE */, filename], (0, types_1.errorValue)("Unsupported access" /* ERR_MESSAGE.UNSUPPORTED_ACCESS */, pathname), { type: 64 /* LOG_TYPE.CLOUD */, fatal: !!active, startTime });
instance.writeFail(["Unable to download file", filename], (0, types_1.errorValue)("Unsupported access", pathname), { type: 64, fatal: !!active, startTime });
continue;

@@ -224,3 +224,3 @@ }

download.admin = data.admin;
const task = instance.downloadObject(data.service, instance.getCredential(data), data.bucket, download, (value) => {
const task = instance.downloadObject(data.service, instance.getCredential(data), data.bucket, download, async (value) => {
let result;

@@ -246,3 +246,3 @@ if (value && !instance.aborted) {

this.add(destUri);
this.formatMessage(64 /* LOG_TYPE.CLOUD */, data.service, ["Download success" /* VAL_CLOUD.DOWNLOAD_FILE */, (0, types_1.formatSize)(size)], destUri, { ...Cloud.LOG_CLOUD_DOWNLOAD });
this.formatMessage(64, data.service, ["Download success", (0, types_1.formatSize)(size)], destUri, { ...Cloud.LOG_CLOUD_DOWNLOAD });
result || (result = destUri);

@@ -256,3 +256,3 @@ }

else {
instance.writeFail(["Unable to write file" /* ERR_MESSAGE.WRITE_FILE */, path.basename(destUri)], err, { type: 32 /* LOG_TYPE.FILE */, fatal: !!active, startTime });
instance.writeFail(["Unable to write file", path.basename(destUri)], err, { type: 32, fatal: !!active, startTime });
}

@@ -264,3 +264,3 @@ }

})
.catch(err => instance.writeFail(["Download failed" /* ERR_CLOUD.DOWNLOAD_FAIL */, path.basename(downloadUri)], err, { type: 64 /* LOG_TYPE.CLOUD */, startTime }));
.catch(err => instance.writeFail(["Download failed", path.basename(downloadUri)], err, { type: 64, startTime }));
if (active || waitStatus || this.incremental === 'staging') {

@@ -327,3 +327,3 @@ tasks.push(task);

catch (err) {
instance.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, path.basename(value)], err, { type: 32 /* LOG_TYPE.FILE */, fatal: false });
instance.writeFail(["Unable to read file", path.basename(value)], err, { type: 32, fatal: false });
}

@@ -337,3 +337,3 @@ }

if (!exists || !instance.canRead(localUri, { ownPermissionOnly: true })) {
instance.writeFail(["Unable to read file" /* ERR_MESSAGE.READ_FILE */, path.basename(localUri)], (0, types_1.errorValue)(exists ? "Not permitted to read file" /* ERR_MESSAGE.UNSUPPORTED_READ */ : "File not found" /* ERR_MESSAGE.NOTFOUND_FILE */, localUri), { type: 64 /* LOG_TYPE.CLOUD */, fatal: index === 0 });
instance.writeFail(["Unable to read file", path.basename(localUri)], (0, types_1.errorValue)(exists ? "Not permitted to read file" : "File not found", localUri), { type: 64, fatal: index === 0 });
continue;

@@ -362,6 +362,6 @@ }

uploading.push(instance.uploadObject(service, { ...credential }, bucket, options, localUri, callback)
.catch(err => instance.writeFail(["Upload failed" /* ERR_CLOUD.UPLOAD_FAIL */, path.basename(localUri)], err, { type: 64 /* LOG_TYPE.CLOUD */, fatal: index === 0 })));
.catch(err => instance.writeFail(["Upload failed", path.basename(localUri)], err, { type: 64, fatal: index === 0 })));
}
});
instance.allSettled(uploading, [`Upload file "${contentType || "Unknown" /* ERR_MESSAGE.UNKNOWN */}"`, storage.service + ': ' + path.basename(file.localUri)]).then(() => resolve());
instance.allSettled(uploading, [`Upload file "${contentType || "Unknown"}"`, storage.service + ': ' + path.basename(file.localUri)]).then(() => resolve());
});

@@ -452,3 +452,3 @@ if (active) {

}
createBucket(service, credential, bucket, publicRead, options) {
async createBucket(service, credential, bucket, publicRead, options) {
if (this.aborted) {

@@ -472,6 +472,6 @@ return Promise.reject((0, types_1.createAbortError)());

}
return Promise.reject((0, types_1.errorMessage)(service, "Create bucket not supported" /* ERR_CLOUD.CREATE_BUCKET_SUPPORT */));
return Promise.reject((0, types_1.errorMessage)(service, "Create bucket not supported"));
}
catch (err) {
this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["Unable to create bucket" /* ERR_CLOUD.CREATE_BUCKET */, bucket], err, { ...Cloud.LOG_CLOUD_WARN });
this.formatMessage(64, service, ["Unable to create bucket", bucket], err, { ...Cloud.LOG_CLOUD_WARN });
return Promise.reject(err);

@@ -484,3 +484,3 @@ }

}
setBucketPolicy(service, credential, bucket, options) {
async setBucketPolicy(service, credential, bucket, options) {
if (this.aborted) {

@@ -496,7 +496,7 @@ return Promise.reject((0, types_1.createAbortError)());

catch (err) {
this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["Unable to update bucket policy" /* ERR_CLOUD.POLICY_BUCKET */, bucket], err, { ...Cloud.LOG_CLOUD_WARN });
this.formatMessage(64, service, ["Unable to update bucket policy", bucket], err, { ...Cloud.LOG_CLOUD_WARN });
return Promise.reject(err);
}
}
return Promise.reject((0, types_1.errorMessage)(service, "Bucket policy not supported" /* ERR_CLOUD.BUCKET_POLICY_SUPPORT */));
return Promise.reject((0, types_1.errorMessage)(service, "Bucket policy not supported"));
}

@@ -507,3 +507,3 @@ catch (err) {

}
setBucketWebsite(service, credential, bucket, options) {
async setBucketWebsite(service, credential, bucket, options) {
if (this.aborted) {

@@ -519,7 +519,7 @@ return Promise.reject((0, types_1.createAbortError)());

catch (err) {
this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["Unable to configure bucket" /* ERR_CLOUD.CONFIGURE_BUCKET */, bucket], err, { ...Cloud.LOG_CLOUD_WARN });
this.formatMessage(64, service, ["Unable to configure bucket", bucket], err, { ...Cloud.LOG_CLOUD_WARN });
return Promise.reject(err);
}
}
return Promise.reject((0, types_1.errorMessage)(service, "Set bucket website not supported" /* ERR_CLOUD.BUCKET_WEBSITE_SUPPORT */));
return Promise.reject((0, types_1.errorMessage)(service, "Set bucket website not supported"));
}

@@ -530,3 +530,3 @@ catch (err) {

}
deleteObjects(service, credential, bucket, recursive = true) {
async deleteObjects(service, credential, bucket, recursive = true) {
if (this.aborted) {

@@ -536,3 +536,3 @@ return Promise.reject((0, types_1.createAbortError)());

try {
const errorResponse = (err) => this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["Unable to empty bucket" /* ERR_CLOUD.DELETE_BUCKET */, bucket], err, { ...Cloud.LOG_CLOUD_WARN });
const errorResponse = (err) => this.formatMessage(64, service, ["Unable to empty bucket", bucket], err, { ...Cloud.LOG_CLOUD_WARN });
const client = this.getClient(service);

@@ -547,3 +547,3 @@ const handlerV2 = client.deleteObjectsV2?.bind(this);

}
return Promise.reject((0, types_1.errorMessage)(service, "Delete objects not supported" /* ERR_CLOUD.DELETE_OBJECTS_SUPPORT */));
return Promise.reject((0, types_1.errorMessage)(service, "Delete objects not supported"));
}

@@ -554,3 +554,3 @@ catch (err) {

}
uploadObject(service, credential, bucket, upload, localUri, beforeResolve) {
async uploadObject(service, credential, bucket, upload, localUri, beforeResolve) {
if (this.aborted) {

@@ -564,3 +564,3 @@ return Promise.reject((0, types_1.createAbortError)());

catch (err) {
this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["Upload function not supported" /* ERR_CLOUD.UPLOAD_SUPPORT */, bucket], localUri, { ...Cloud.LOG_CLOUD_WARN });
this.formatMessage(64, service, ["Upload function not supported", bucket], localUri, { ...Cloud.LOG_CLOUD_WARN });
return Promise.reject(err);

@@ -572,3 +572,3 @@ }

if (err) {
reject(errorObject(err, service, "Upload failed" /* ERR_CLOUD.UPLOAD_FAIL */));
reject(errorObject(err, service, "Upload failed"));
}

@@ -583,3 +583,3 @@ else if (value) {

else {
reject((0, types_1.errorMessage)(service, "Upload failed" /* ERR_CLOUD.UPLOAD_FAIL */));
reject((0, types_1.errorMessage)(service, "Upload failed"));
}

@@ -593,3 +593,3 @@ });

}
downloadObject(service, credential, bucket, download, beforeResolve) {
async downloadObject(service, credential, bucket, download, beforeResolve) {
if (this.aborted) {

@@ -606,3 +606,3 @@ return Promise.reject((0, types_1.createAbortError)());

catch (err) {
this.formatMessage(64 /* LOG_TYPE.CLOUD */, service, ["Download function not supported" /* ERR_CLOUD.DOWNLOAD_SUPPORT */, bucket], Cloud.joinPath(download.pathname, download.filename), { ...Cloud.LOG_CLOUD_WARN });
this.formatMessage(64, service, ["Download function not supported", bucket], Cloud.joinPath(download.pathname, download.filename), { ...Cloud.LOG_CLOUD_WARN });
return Promise.reject(err);

@@ -614,3 +614,3 @@ }

if (err) {
reject(errorObject(err, service, "Download failed" /* ERR_CLOUD.DOWNLOAD_FAIL */));
reject(errorObject(err, service, "Download failed"));
}

@@ -631,3 +631,3 @@ else if (value) {

else {
reject((0, types_1.errorMessage)(service, "Download failed" /* ERR_CLOUD.DOWNLOAD_FAIL */));
reject((0, types_1.errorMessage)(service, "Download failed"));
}

@@ -664,9 +664,9 @@ });

catch (err) {
this.formatFail(64 /* LOG_TYPE.CLOUD */, service, "Unable to execute query" /* ERR_DB.EXEC_QUERY */, err, { ...Cloud.LOG_CLOUD_FAIL });
this.formatFail(64, service, "Unable to execute query", err, { ...Cloud.LOG_CLOUD_FAIL });
return Promise.reject(err);
}
}
return Promise.reject((0, types_1.errorMessage)(service, "Execute query not supported" /* ERR_CLOUD.EXECUTE_QUERY_SUPPORT */));
return Promise.reject((0, types_1.errorMessage)(service, "Execute query not supported"));
}
return Promise.reject((0, types_1.errorMessage)(service, "Invalid credentials" /* ERR_DB.CREDENTIALS */));
return Promise.reject((0, types_1.errorMessage)(service, "Invalid credentials"));
}

@@ -697,9 +697,9 @@ async getDatabaseBatchRows(batch, ignoreErrors, sessionKey) {

catch (err) {
this.formatFail(64 /* LOG_TYPE.CLOUD */, service, "Unable to execute query" /* ERR_DB.EXEC_QUERY */, err, { ...Cloud.LOG_CLOUD_FAIL });
this.formatFail(64, service, "Unable to execute query", err, { ...Cloud.LOG_CLOUD_FAIL });
return Promise.reject(err);
}
}
return Promise.reject((0, types_1.errorMessage)(service, "Execute query not supported" /* ERR_CLOUD.EXECUTE_QUERY_SUPPORT */));
return Promise.reject((0, types_1.errorMessage)(service, "Execute query not supported"));
}
return Promise.reject((0, types_1.errorMessage)(service, "Invalid credentials" /* ERR_DB.CREDENTIALS */));
return Promise.reject((0, types_1.errorMessage)(service, "Invalid credentials"));
}

@@ -732,3 +732,3 @@ getCredential(item, unused) {

const service = this.hasStorage(action, item);
if (service && service.active) { // eslint-disable-line @typescript-eslint/prefer-optional-chain
if (service && service.active) {
return item;

@@ -765,3 +765,3 @@ }

catch (err) {
this.formatFail(64 /* LOG_TYPE.CLOUD */, data.service, "Cloud provider not found" /* ERR_CLOUD.PROVIDER_NOTFOUND */, err, { ...Cloud.LOG_CLOUD_FAIL });
this.formatFail(64, data.service, "Cloud provider not found", err, { ...Cloud.LOG_CLOUD_FAIL });
}

@@ -778,6 +778,6 @@ return false;

let result;
if (service[0] !== '@') {
if (!service.startsWith('@')) {
result = this.settings.imports?.[service] || util_1.IMPORTS[service];
}
else if (!folder && !service.startsWith("@squared-functions/" /* NAMESPACE.SQUARED_FUNCTIONS */)) {
else if (!folder && !service.startsWith("@squared-functions/")) {
folder = 'client';

@@ -795,7 +795,7 @@ }

}
const items = this.pending.filter(item => !item.document).map(data => {
const items = this.pending.filter(item => !item.document).map(async (data) => {
data.ignoreCache ?? (data.ignoreCache = true);
return this.getDatabaseRows(data, true);
});
return items.length === 0 ? Promise.resolve(false) : this.allSettled(items, ["Execute unassigned queries" /* VAL_DB.EXEC_QUERYUNASSIGNED */, this.moduleName]).then(result => result.length > 0).catch(() => false);
return items.length === 0 ? Promise.resolve(false) : this.allSettled(items, ["Execute unassigned queries", this.moduleName]).then(result => result.length > 0).catch(() => false);
}

@@ -816,7 +816,7 @@ getClient(service) {

}
throw (0, types_1.errorMessage)(service, "Cloud provider not found" /* ERR_CLOUD.PROVIDER_NOTFOUND */);
throw (0, types_1.errorMessage)(service, "Cloud provider not found");
}
}
Cloud.STORE_RESULT_PARTITION_SIZE = 16 /* CACHE_SIZE.CLOUD_PARTITION_SIZE */;
Cloud.STORE_RESULT_PARTITION_MULT = 2 /* CACHE_SIZE.CLOUD_PARTITION_MULT */;
Cloud.STORE_RESULT_PARTITION_SIZE = 16;
Cloud.STORE_RESULT_PARTITION_MULT = 2;
Cloud.LOG_CLOUD_FAIL = core_1.ClientDb.LOG_STYLE_FAIL;

@@ -823,0 +823,0 @@ Cloud.LOG_CLOUD_COMMAND = Object.freeze({ titleColor: 'blue' });

{
"name": "@e-mc/cloud",
"version": "0.6.0",
"version": "0.6.1",
"description": "Cloud constructor for E-mc.",

@@ -20,9 +20,9 @@ "main": "index.js",

"author": "An Pham <anpham6@gmail.com>",
"license": "BSD 3-Clause",
"license": "MIT",
"homepage": "https://github.com/anpham6/e-mc#readme",
"dependencies": {
"@e-mc/core": "0.6.0",
"@e-mc/db": "0.6.0",
"@e-mc/types": "0.6.0"
"@e-mc/core": "0.6.1",
"@e-mc/db": "0.6.1",
"@e-mc/types": "0.6.1"
}
}

@@ -1,5 +0,7 @@

### @e-mc/cloud
# @e-mc/cloud
### LICENSE
PEP 402 - Forever Ryuko
BSD 3-Clause
## LICENSE
MIT

@@ -5,4 +5,4 @@ "use strict";

const path = require("path");
const types_1 = require("../types");
const util_1 = require("../db/util");
const types_1 = require("@e-mc/types");
const util_1 = require("@e-mc/db/util");
Object.defineProperty(exports, "getBasicAuth", { enumerable: true, get: function () { return util_1.getBasicAuth; } });

@@ -22,3 +22,3 @@ Object.defineProperty(exports, "hasBasicAuth", { enumerable: true, get: function () { return util_1.hasBasicAuth; } });

};
function readableAsBuffer(stream) {
async function readableAsBuffer(stream) {
return new Promise((resolve, reject) => {

@@ -40,5 +40,6 @@ let result = null;

if (i === 1) {
const j = filename.indexOf('.');
const type = /\.[a-z0-9]+\.[a-z0-9]+$/i.exec(filename);
const j = type ? type.index : filename.lastIndexOf('.');
if (j !== -1) {
const match = /^([\S\s]+?)_(\d+)$/.exec(basename = filename.substring(0, j));
const match = /^(.+)_(\d+)$/.exec(basename = filename.substring(0, j));
if (match) {

@@ -45,0 +46,0 @@ basename = match[1];

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc