mobiletto-base
Advanced tools
Comparing version 2.0.29 to 2.0.30
import { MobilettoOptions } from "mobiletto-common"; | ||
import { MobilettoConnection, MobilettoQueue } from "./types.js"; | ||
import { MobilettoConnection, MobilettoQueue, MobilettoDriverParameter } from "./types.js"; | ||
import { MobilettoEncryptionSettings } from "./crypt.js"; | ||
export declare const ALL_MQ: Record<string, MobilettoQueue>; | ||
export declare function mobiletto(driverPath: string, key: string, secret?: string | null, opts?: MobilettoOptions | null, encryption?: MobilettoEncryptionSettings): Promise<MobilettoConnection>; | ||
export declare function mobiletto(driverPath: string | MobilettoDriverParameter, key: string, secret?: string | null, opts?: MobilettoOptions | null, encryption?: MobilettoEncryptionSettings): Promise<MobilettoConnection>; | ||
export declare function connect(driverPath: string, key: string, secret?: string | null, opts?: MobilettoOptions | null, encryption?: MobilettoEncryptionSettings): Promise<MobilettoConnection>; |
@@ -35,14 +35,25 @@ "use strict"; | ||
let driver; | ||
if (register_js_1.ALL_DRIVERS[driverPath]) { | ||
driver = register_js_1.ALL_DRIVERS[driverPath]; | ||
if (typeof driverPath === "string") { | ||
if (register_js_1.ALL_DRIVERS[driverPath]) { | ||
driver = register_js_1.ALL_DRIVERS[driverPath]; | ||
} | ||
else if (require) { | ||
driver = require(driverPath.includes("/") ? driverPath : `./drivers/${driverPath}/index.js`); | ||
} | ||
else { | ||
throw new mobiletto_common_1.MobilettoError(`mobiletto: error resolving driver (require not supported): ${driverPath} (try an ES import of the driver package)`); | ||
} | ||
} | ||
else if (require) { | ||
driver = require(driverPath.includes("/") ? driverPath : `./drivers/${driverPath}/index.js`); | ||
else if (typeof driverPath === "function") { | ||
driver = { storageClient: driverPath }; | ||
} | ||
else if (typeof driverPath === "object" && typeof driverPath.storageClient === "function") { | ||
driver = driverPath; | ||
} | ||
else { | ||
throw new mobiletto_common_1.MobilettoError(`mobiletto: error resolving driver (require not supported): ${driverPath} (try an ES import of the driver package)`); | ||
throw new mobiletto_common_1.MobilettoError(`mobiletto: expected registered driver name or a MobilettoDriverParameter, received a ${typeof driverPath} with value ${driverPath}`); | ||
} | ||
let client; | ||
try { | ||
client = driver.storageClient(key, secret, opts); | ||
client = driver.storageClient(key, secret || undefined, opts || undefined); | ||
} | ||
@@ -49,0 +60,0 @@ catch (e) { |
import { MobilettoOptions } from "mobiletto-common"; | ||
import { MobilettoConnection, MobilettoQueue } from "./types.js"; | ||
import { MobilettoConnection, MobilettoQueue, MobilettoDriverParameter } from "./types.js"; | ||
import { MobilettoEncryptionSettings } from "./crypt.js"; | ||
export declare const ALL_MQ: Record<string, MobilettoQueue>; | ||
export declare function mobiletto(driverPath: string, key: string, secret?: string | null, opts?: MobilettoOptions | null, encryption?: MobilettoEncryptionSettings): Promise<MobilettoConnection>; | ||
export declare function mobiletto(driverPath: string | MobilettoDriverParameter, key: string, secret?: string | null, opts?: MobilettoOptions | null, encryption?: MobilettoEncryptionSettings): Promise<MobilettoConnection>; | ||
export declare function connect(driverPath: string, key: string, secret?: string | null, opts?: MobilettoOptions | null, encryption?: MobilettoEncryptionSettings): Promise<MobilettoConnection>; |
@@ -29,14 +29,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
let driver; | ||
if (ALL_DRIVERS[driverPath]) { | ||
driver = ALL_DRIVERS[driverPath]; | ||
if (typeof driverPath === "string") { | ||
if (ALL_DRIVERS[driverPath]) { | ||
driver = ALL_DRIVERS[driverPath]; | ||
} | ||
else if (require) { | ||
driver = require(driverPath.includes("/") ? driverPath : `./drivers/${driverPath}/index.js`); | ||
} | ||
else { | ||
throw new MobilettoError(`mobiletto: error resolving driver (require not supported): ${driverPath} (try an ES import of the driver package)`); | ||
} | ||
} | ||
else if (require) { | ||
driver = require(driverPath.includes("/") ? driverPath : `./drivers/${driverPath}/index.js`); | ||
else if (typeof driverPath === "function") { | ||
driver = { storageClient: driverPath }; | ||
} | ||
else if (typeof driverPath === "object" && typeof driverPath.storageClient === "function") { | ||
driver = driverPath; | ||
} | ||
else { | ||
throw new MobilettoError(`mobiletto: error resolving driver (require not supported): ${driverPath} (try an ES import of the driver package)`); | ||
throw new MobilettoError(`mobiletto: expected registered driver name or a MobilettoDriverParameter, received a ${typeof driverPath} with value ${driverPath}`); | ||
} | ||
let client; | ||
try { | ||
client = driver.storageClient(key, secret, opts); | ||
client = driver.storageClient(key, secret || undefined, opts || undefined); | ||
} | ||
@@ -43,0 +54,0 @@ catch (e) { |
{ | ||
"name": "mobiletto-base", | ||
"version": "2.0.29", | ||
"version": "2.0.30", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "A storage layer that presents a uniform interface to Amazon S3, Backblaze B2, local and other storage systems.", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
158959
3018