Compare commits
No commits in common. "35af57732e00873be92ee9508fd45397d3c24d4d" and "5517a0ba1d0adf076dceaea2d128d3390bec05dd" have entirely different histories.
35af57732e
...
5517a0ba1d
423
lib/pawsqlite.js
423
lib/pawsqlite.js
@ -1,70 +1,102 @@
|
|||||||
/******/ (() => { // webpackBootstrap
|
module.exports =
|
||||||
/******/ "use strict";
|
/******/ (function(modules) { // webpackBootstrap
|
||||||
/******/ var __webpack_modules__ = ({
|
/******/ // The module cache
|
||||||
|
/******/ var installedModules = {};
|
||||||
/***/ "./src/adapter_wrapper.mjs":
|
/******/
|
||||||
/*!*********************************!*\
|
/******/ // The require function
|
||||||
!*** ./src/adapter_wrapper.mjs ***!
|
/******/ function __webpack_require__(moduleId) {
|
||||||
\*********************************/
|
/******/
|
||||||
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
/******/ // Check if module is in cache
|
||||||
|
/******/ if(installedModules[moduleId]) {
|
||||||
__webpack_require__.r(__webpack_exports__);
|
/******/ return installedModules[moduleId].exports;
|
||||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
/******/ }
|
||||||
/* harmony export */ "wrapAdapter": () => (/* binding */ wrapAdapter)
|
/******/ // Create a new module (and put it into the cache)
|
||||||
/* harmony export */ });
|
/******/ var module = installedModules[moduleId] = {
|
||||||
/* harmony import */ var _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pawsqlite_error.mjs */ "./src/pawsqlite_error.mjs");
|
/******/ i: moduleId,
|
||||||
|
/******/ l: false,
|
||||||
|
/******/ exports: {}
|
||||||
|
/******/ };
|
||||||
function wrapAdapter(adapter) {
|
/******/
|
||||||
const wrapped = {};
|
/******/ // Execute the module function
|
||||||
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||||
["name", "open", "close", "delete", "sql"].forEach((prop) => {
|
/******/
|
||||||
if (!(prop in adapter)) {
|
/******/ // Flag the module as loaded
|
||||||
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_0__.PawSQLiteError(`Invalid adapter: missing property: ${ prop }`);
|
/******/ module.l = true;
|
||||||
}
|
/******/
|
||||||
|
/******/ // Return the exports of the module
|
||||||
if (
|
/******/ return module.exports;
|
||||||
prop === "name" && !(
|
/******/ }
|
||||||
typeof adapter[prop] === "string" ||
|
/******/
|
||||||
adapter[prop] instanceof String
|
/******/
|
||||||
) ||
|
/******/ // expose the modules object (__webpack_modules__)
|
||||||
prop !== "name" && (
|
/******/ __webpack_require__.m = modules;
|
||||||
typeof adapter[prop] !== "function"
|
/******/
|
||||||
)
|
/******/ // expose the module cache
|
||||||
) {
|
/******/ __webpack_require__.c = installedModules;
|
||||||
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_0__.PawSQLiteError("Invalid adapter: invalid type for property: " +
|
/******/
|
||||||
prop);
|
/******/ // define getter function for harmony exports
|
||||||
}
|
/******/ __webpack_require__.d = function(exports, name, getter) {
|
||||||
|
/******/ if(!__webpack_require__.o(exports, name)) {
|
||||||
if (typeof adapter[prop] === "function") {
|
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
||||||
wrapped[prop] = async (...args) => {
|
/******/ }
|
||||||
try {
|
/******/ };
|
||||||
return await adapter[prop](...args);
|
/******/
|
||||||
} catch (err) {
|
/******/ // define __esModule on exports
|
||||||
throw _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_0__.PawSQLiteError.from(err);
|
/******/ __webpack_require__.r = function(exports) {
|
||||||
}
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||||
};
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||||
} else {
|
/******/ }
|
||||||
wrapped[prop] = adapter[prop];
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
}
|
/******/ };
|
||||||
});
|
/******/
|
||||||
|
/******/ // create a fake namespace object
|
||||||
return wrapped;
|
/******/ // mode & 1: value is a module id, require it
|
||||||
}
|
/******/ // mode & 2: merge all properties of value into the ns
|
||||||
|
/******/ // mode & 4: return value when already ns object
|
||||||
/***/ }),
|
/******/ // mode & 8|1: behave like require
|
||||||
|
/******/ __webpack_require__.t = function(value, mode) {
|
||||||
|
/******/ if(mode & 1) value = __webpack_require__(value);
|
||||||
|
/******/ if(mode & 8) return value;
|
||||||
|
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
||||||
|
/******/ var ns = Object.create(null);
|
||||||
|
/******/ __webpack_require__.r(ns);
|
||||||
|
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
||||||
|
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
||||||
|
/******/ return ns;
|
||||||
|
/******/ };
|
||||||
|
/******/
|
||||||
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||||
|
/******/ __webpack_require__.n = function(module) {
|
||||||
|
/******/ var getter = module && module.__esModule ?
|
||||||
|
/******/ function getDefault() { return module['default']; } :
|
||||||
|
/******/ function getModuleExports() { return module; };
|
||||||
|
/******/ __webpack_require__.d(getter, 'a', getter);
|
||||||
|
/******/ return getter;
|
||||||
|
/******/ };
|
||||||
|
/******/
|
||||||
|
/******/ // Object.prototype.hasOwnProperty.call
|
||||||
|
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
||||||
|
/******/
|
||||||
|
/******/ // __webpack_public_path__
|
||||||
|
/******/ __webpack_require__.p = "";
|
||||||
|
/******/
|
||||||
|
/******/
|
||||||
|
/******/ // Load entry module and return exports
|
||||||
|
/******/ return __webpack_require__(__webpack_require__.s = "./src/pawsqlite.mjs");
|
||||||
|
/******/ })
|
||||||
|
/************************************************************************/
|
||||||
|
/******/ ({
|
||||||
|
|
||||||
/***/ "./src/database.mjs":
|
/***/ "./src/database.mjs":
|
||||||
/*!**************************!*\
|
/*!**************************!*\
|
||||||
!*** ./src/database.mjs ***!
|
!*** ./src/database.mjs ***!
|
||||||
\**************************/
|
\**************************/
|
||||||
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
/*! exports provided: Database */
|
||||||
|
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
__webpack_require__.r(__webpack_exports__);
|
__webpack_require__.r(__webpack_exports__);
|
||||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
|
||||||
/* harmony export */ "Database": () => (/* binding */ Database)
|
|
||||||
/* harmony export */ });
|
|
||||||
/* harmony import */ var _transaction_manager_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./transaction_manager.mjs */ "./src/transaction_manager.mjs");
|
/* harmony import */ var _transaction_manager_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./transaction_manager.mjs */ "./src/transaction_manager.mjs");
|
||||||
|
|
||||||
|
|
||||||
@ -76,7 +108,7 @@ class Database {
|
|||||||
this.version = null;
|
this.version = null;
|
||||||
this.path = null;
|
this.path = null;
|
||||||
|
|
||||||
this.transactionManager = new _transaction_manager_mjs__WEBPACK_IMPORTED_MODULE_0__.TransactionManager(dbName, this.adapter);
|
this.transactionManager = new _transaction_manager_mjs__WEBPACK_IMPORTED_MODULE_0__["TransactionManager"](dbName, this.adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
async open() {
|
async open() {
|
||||||
@ -137,13 +169,13 @@ class Database {
|
|||||||
/*!*********************!*\
|
/*!*********************!*\
|
||||||
!*** ./src/log.mjs ***!
|
!*** ./src/log.mjs ***!
|
||||||
\*********************/
|
\*********************/
|
||||||
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
/*! exports provided: log, enableDebug */
|
||||||
|
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
__webpack_require__.r(__webpack_exports__);
|
__webpack_require__.r(__webpack_exports__);
|
||||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "log", function() { return log; });
|
||||||
/* harmony export */ "log": () => (/* binding */ log),
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "enableDebug", function() { return enableDebug; });
|
||||||
/* harmony export */ "enableDebug": () => (/* binding */ enableDebug)
|
|
||||||
/* harmony export */ });
|
|
||||||
let DEBUG = false;
|
let DEBUG = false;
|
||||||
|
|
||||||
function log(...args) {
|
function log(...args) {
|
||||||
@ -164,16 +196,107 @@ function enableDebug(active) {
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ "./src/pawsqlite.mjs":
|
||||||
|
/*!***************************!*\
|
||||||
|
!*** ./src/pawsqlite.mjs ***!
|
||||||
|
\***************************/
|
||||||
|
/*! exports provided: default */
|
||||||
|
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
__webpack_require__.r(__webpack_exports__);
|
||||||
|
/* harmony import */ var _database_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database.mjs */ "./src/database.mjs");
|
||||||
|
/* harmony import */ var _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pawsqlite_error.mjs */ "./src/pawsqlite_error.mjs");
|
||||||
|
/* harmony import */ var _log_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./log.mjs */ "./src/log.mjs");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const adapters = [];
|
||||||
|
|
||||||
|
|
||||||
|
/* harmony default export */ __webpack_exports__["default"] = ({
|
||||||
|
open: async function(dbName, options = {}) {
|
||||||
|
const adapter = getAdapter(options.adapter);
|
||||||
|
|
||||||
|
let db = new _database_mjs__WEBPACK_IMPORTED_MODULE_0__["Database"](dbName, adapter);
|
||||||
|
await db.open();
|
||||||
|
return db;
|
||||||
|
},
|
||||||
|
delete: function(dbName, options = {}) {
|
||||||
|
const adapter = getAdapter(options.adapter);
|
||||||
|
|
||||||
|
return adapter.delete(dbName);
|
||||||
|
},
|
||||||
|
registerAdapter: function(adapter) {
|
||||||
|
adapters.push(wrapAdapter(adapter));
|
||||||
|
},
|
||||||
|
debug: _log_mjs__WEBPACK_IMPORTED_MODULE_2__["enableDebug"],
|
||||||
|
Error: _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"]
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function wrapAdapter() {
|
||||||
|
const wrapped = {};
|
||||||
|
|
||||||
|
["name", "open", "close", "delete", "sql"].forEach((prop) => {
|
||||||
|
if (!(prop in adapter)) {
|
||||||
|
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"](`Invalid adapter: missing property: ${ prop }`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
prop === "name" && !(
|
||||||
|
typeof adapter[prop] === "string" ||
|
||||||
|
adapter[prop] instanceof String
|
||||||
|
) ||
|
||||||
|
prop !== "name" && (
|
||||||
|
typeof adapter[prop] !== "function"
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"]("Invalid adapter: invalid type for property: " +
|
||||||
|
prop);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof adapter[prop] === "function") {
|
||||||
|
wrapped[prop] = async (...args) => {
|
||||||
|
try {
|
||||||
|
return await adapter[prop](...args);
|
||||||
|
} catch (err) {
|
||||||
|
throw _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"].from(err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
wrapped[prop] = adapter[prop];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return wrapped;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getAdapter(adapterName) {
|
||||||
|
const adapter = adapters.find((a) => a.name === adapterName);
|
||||||
|
|
||||||
|
if (!adapter) {
|
||||||
|
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"](`Unknown Adapter: ${adapterName}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return adapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
/***/ "./src/pawsqlite_error.mjs":
|
/***/ "./src/pawsqlite_error.mjs":
|
||||||
/*!*********************************!*\
|
/*!*********************************!*\
|
||||||
!*** ./src/pawsqlite_error.mjs ***!
|
!*** ./src/pawsqlite_error.mjs ***!
|
||||||
\*********************************/
|
\*********************************/
|
||||||
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
/*! exports provided: PawSQLiteError */
|
||||||
|
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
__webpack_require__.r(__webpack_exports__);
|
__webpack_require__.r(__webpack_exports__);
|
||||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PawSQLiteError", function() { return PawSQLiteError; });
|
||||||
/* harmony export */ "PawSQLiteError": () => (/* binding */ PawSQLiteError)
|
|
||||||
/* harmony export */ });
|
|
||||||
class PawSQLiteError extends Error {
|
class PawSQLiteError extends Error {
|
||||||
static from(err) {
|
static from(err) {
|
||||||
const p_err = new PawSQLiteError(err.toString());
|
const p_err = new PawSQLiteError(err.toString());
|
||||||
@ -193,12 +316,12 @@ class PawSQLiteError extends Error {
|
|||||||
/*!************************!*\
|
/*!************************!*\
|
||||||
!*** ./src/result.mjs ***!
|
!*** ./src/result.mjs ***!
|
||||||
\************************/
|
\************************/
|
||||||
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
/*! exports provided: Result */
|
||||||
|
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
__webpack_require__.r(__webpack_exports__);
|
__webpack_require__.r(__webpack_exports__);
|
||||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Result", function() { return Result; });
|
||||||
/* harmony export */ "Result": () => (/* binding */ Result)
|
|
||||||
/* harmony export */ });
|
|
||||||
/* harmony import */ var _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pawsqlite_error.mjs */ "./src/pawsqlite_error.mjs");
|
/* harmony import */ var _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pawsqlite_error.mjs */ "./src/pawsqlite_error.mjs");
|
||||||
|
|
||||||
|
|
||||||
@ -226,12 +349,12 @@ class Result extends Array {
|
|||||||
/*!*****************************!*\
|
/*!*****************************!*\
|
||||||
!*** ./src/transaction.mjs ***!
|
!*** ./src/transaction.mjs ***!
|
||||||
\*****************************/
|
\*****************************/
|
||||||
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
/*! exports provided: Transaction */
|
||||||
|
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
__webpack_require__.r(__webpack_exports__);
|
__webpack_require__.r(__webpack_exports__);
|
||||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Transaction", function() { return Transaction; });
|
||||||
/* harmony export */ "Transaction": () => (/* binding */ Transaction)
|
|
||||||
/* harmony export */ });
|
|
||||||
/* harmony import */ var _result_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./result.mjs */ "./src/result.mjs");
|
/* harmony import */ var _result_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./result.mjs */ "./src/result.mjs");
|
||||||
/* harmony import */ var _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pawsqlite_error.mjs */ "./src/pawsqlite_error.mjs");
|
/* harmony import */ var _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pawsqlite_error.mjs */ "./src/pawsqlite_error.mjs");
|
||||||
|
|
||||||
@ -254,7 +377,7 @@ class Transaction {
|
|||||||
|
|
||||||
async sql(sql, ...args) {
|
async sql(sql, ...args) {
|
||||||
if (this._finalized) {
|
if (this._finalized) {
|
||||||
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__.PawSQLiteError("Transaction has already completed");
|
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"]("Transaction has already completed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this._ready) {
|
if (!this._ready) {
|
||||||
@ -282,7 +405,7 @@ class Transaction {
|
|||||||
.filter(Array.isArray)
|
.filter(Array.isArray)
|
||||||
.map((a) => a.length);
|
.map((a) => a.length);
|
||||||
if (parts.length !== subParamLengths.length + 1) {
|
if (parts.length !== subParamLengths.length + 1) {
|
||||||
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__.PawSQLiteError("Unable to build query: sub-" +
|
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"]("Unable to build query: sub-" +
|
||||||
"paramters do not match sub-paramters in query");
|
"paramters do not match sub-paramters in query");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,14 +451,14 @@ class Transaction {
|
|||||||
const match = reg.exec(sql);
|
const match = reg.exec(sql);
|
||||||
if (match) {
|
if (match) {
|
||||||
const statement = match[1].toUpperCase();
|
const statement = match[1].toUpperCase();
|
||||||
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__.PawSQLiteError("Manually managing transactions is " +
|
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"]("Manually managing transactions is " +
|
||||||
"forbidden. Found: \"" + statement + "\" statement.");
|
"forbidden. Found: \"" + statement + "\" statement.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await this.adapter.sql(this.dbName,
|
const result = await this.adapter.sql(this.dbName,
|
||||||
...this.buildQuery(sql, ...args));
|
...this.buildQuery(sql, ...args));
|
||||||
|
|
||||||
return new _result_mjs__WEBPACK_IMPORTED_MODULE_0__.Result(result);
|
return new _result_mjs__WEBPACK_IMPORTED_MODULE_0__["Result"](result);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _begin() {
|
async _begin() {
|
||||||
@ -344,7 +467,7 @@ class Transaction {
|
|||||||
|
|
||||||
async _complete(sql) {
|
async _complete(sql) {
|
||||||
if (this._finalized) {
|
if (this._finalized) {
|
||||||
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__.PawSQLiteError("Transaction has already completed");
|
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_1__["PawSQLiteError"]("Transaction has already completed");
|
||||||
}
|
}
|
||||||
this._finalized = true;
|
this._finalized = true;
|
||||||
|
|
||||||
@ -369,7 +492,7 @@ class Transaction {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new _result_mjs__WEBPACK_IMPORTED_MODULE_0__.Result(result);
|
return new _result_mjs__WEBPACK_IMPORTED_MODULE_0__["Result"](result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,12 +502,12 @@ class Transaction {
|
|||||||
/*!*************************************!*\
|
/*!*************************************!*\
|
||||||
!*** ./src/transaction_manager.mjs ***!
|
!*** ./src/transaction_manager.mjs ***!
|
||||||
\*************************************/
|
\*************************************/
|
||||||
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
/*! exports provided: TransactionManager */
|
||||||
|
/***/ (function(__webpack_module__, __webpack_exports__, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
__webpack_require__.r(__webpack_exports__);
|
__webpack_require__.r(__webpack_exports__);
|
||||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransactionManager", function() { return TransactionManager; });
|
||||||
/* harmony export */ "TransactionManager": () => (/* binding */ TransactionManager)
|
|
||||||
/* harmony export */ });
|
|
||||||
/* harmony import */ var _transaction_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./transaction.mjs */ "./src/transaction.mjs");
|
/* harmony import */ var _transaction_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./transaction.mjs */ "./src/transaction.mjs");
|
||||||
|
|
||||||
|
|
||||||
@ -397,7 +520,7 @@ class TransactionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
transaction() {
|
transaction() {
|
||||||
return new _transaction_mjs__WEBPACK_IMPORTED_MODULE_0__.Transaction(this.dbName, this.adapter,
|
return new _transaction_mjs__WEBPACK_IMPORTED_MODULE_0__["Transaction"](this.dbName, this.adapter,
|
||||||
this.enqueue.bind(this));
|
this.enqueue.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,125 +567,5 @@ class TransactionManager {
|
|||||||
|
|
||||||
/***/ })
|
/***/ })
|
||||||
|
|
||||||
/******/ });
|
/******/ })["default"];
|
||||||
/************************************************************************/
|
|
||||||
/******/ // The module cache
|
|
||||||
/******/ var __webpack_module_cache__ = {};
|
|
||||||
/******/
|
|
||||||
/******/ // The require function
|
|
||||||
/******/ function __webpack_require__(moduleId) {
|
|
||||||
/******/ // Check if module is in cache
|
|
||||||
/******/ if(__webpack_module_cache__[moduleId]) {
|
|
||||||
/******/ return __webpack_module_cache__[moduleId].exports;
|
|
||||||
/******/ }
|
|
||||||
/******/ // Create a new module (and put it into the cache)
|
|
||||||
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
||||||
/******/ // no module.id needed
|
|
||||||
/******/ // no module.loaded needed
|
|
||||||
/******/ exports: {}
|
|
||||||
/******/ };
|
|
||||||
/******/
|
|
||||||
/******/ // Execute the module function
|
|
||||||
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
||||||
/******/
|
|
||||||
/******/ // Return the exports of the module
|
|
||||||
/******/ return module.exports;
|
|
||||||
/******/ }
|
|
||||||
/******/
|
|
||||||
/************************************************************************/
|
|
||||||
/******/ /* webpack/runtime/define property getters */
|
|
||||||
/******/ (() => {
|
|
||||||
/******/ // define getter functions for harmony exports
|
|
||||||
/******/ __webpack_require__.d = (exports, definition) => {
|
|
||||||
/******/ for(var key in definition) {
|
|
||||||
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
||||||
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
||||||
/******/ }
|
|
||||||
/******/ }
|
|
||||||
/******/ };
|
|
||||||
/******/ })();
|
|
||||||
/******/
|
|
||||||
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
||||||
/******/ (() => {
|
|
||||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
||||||
/******/ })();
|
|
||||||
/******/
|
|
||||||
/******/ /* webpack/runtime/make namespace object */
|
|
||||||
/******/ (() => {
|
|
||||||
/******/ // define __esModule on exports
|
|
||||||
/******/ __webpack_require__.r = (exports) => {
|
|
||||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
||||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
||||||
/******/ }
|
|
||||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
||||||
/******/ };
|
|
||||||
/******/ })();
|
|
||||||
/******/
|
|
||||||
/************************************************************************/
|
|
||||||
var __webpack_exports__ = {};
|
|
||||||
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
||||||
(() => {
|
|
||||||
/*!***************************!*\
|
|
||||||
!*** ./src/pawsqlite.mjs ***!
|
|
||||||
\***************************/
|
|
||||||
__webpack_require__.r(__webpack_exports__);
|
|
||||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
||||||
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
||||||
/* harmony export */ });
|
|
||||||
/* harmony import */ var _database_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database.mjs */ "./src/database.mjs");
|
|
||||||
/* harmony import */ var _adapter_wrapper_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./adapter_wrapper.mjs */ "./src/adapter_wrapper.mjs");
|
|
||||||
/* harmony import */ var _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pawsqlite_error.mjs */ "./src/pawsqlite_error.mjs");
|
|
||||||
/* harmony import */ var _log_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./log.mjs */ "./src/log.mjs");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const adapters = [];
|
|
||||||
|
|
||||||
|
|
||||||
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
|
|
||||||
open: async function(dbName, options = {}) {
|
|
||||||
const adapter = getAdapter(options.adapter);
|
|
||||||
|
|
||||||
let db = new _database_mjs__WEBPACK_IMPORTED_MODULE_0__.Database(dbName, adapter);
|
|
||||||
await db.open();
|
|
||||||
return db;
|
|
||||||
},
|
|
||||||
delete: function(dbName, options = {}) {
|
|
||||||
const adapter = getAdapter(options.adapter);
|
|
||||||
|
|
||||||
return adapter.delete(dbName);
|
|
||||||
},
|
|
||||||
registerAdapter: function(adapter) {
|
|
||||||
const wrapped = (0,_adapter_wrapper_mjs__WEBPACK_IMPORTED_MODULE_1__.wrapAdapter)(adapter);
|
|
||||||
|
|
||||||
if (getAdapter(wrapped.name)) {
|
|
||||||
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_2__.PawSQLiteError(`An adapter with the name: ${ wrapped.name } ` +
|
|
||||||
`Already exists`);
|
|
||||||
}
|
|
||||||
|
|
||||||
adapters.push(wrapped);
|
|
||||||
},
|
|
||||||
debug: _log_mjs__WEBPACK_IMPORTED_MODULE_3__.enableDebug,
|
|
||||||
Error: _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_2__.PawSQLiteError
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function getAdapter(adapterName, silent=false) {
|
|
||||||
const adapter = adapters.find((a) => a.name === adapterName);
|
|
||||||
|
|
||||||
if (!(silent || adapter)) {
|
|
||||||
throw new _pawsqlite_error_mjs__WEBPACK_IMPORTED_MODULE_2__.PawSQLiteError(`Unknown Adapter: ${adapterName}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return adapter;
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
module.exports = __webpack_exports__.default;
|
|
||||||
/******/ })()
|
|
||||||
;
|
|
||||||
//# sourceMappingURL=pawsqlite.js.map
|
//# sourceMappingURL=pawsqlite.js.map
|
File diff suppressed because one or more lines are too long
3732
package-lock.json
generated
3732
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,7 @@
|
|||||||
"author": "Ben Ashton",
|
"author": "Ben Ashton",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"webpack": "5.x",
|
"webpack": "^4.44.1",
|
||||||
"webpack-cli": "4.x"
|
"webpack-cli": "^3.3.12"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ export default {
|
|||||||
registerAdapter: function(adapter) {
|
registerAdapter: function(adapter) {
|
||||||
const wrapped = wrapAdapter(adapter);
|
const wrapped = wrapAdapter(adapter);
|
||||||
|
|
||||||
if (getAdapter(wrapped.name, true)) {
|
if (getAdapter(wrapped.name)) {
|
||||||
throw new PawSQLiteError(`An adapter with the name: ${ wrapped.name } ` +
|
throw new PawSQLiteError(`An adapter with the name: ${ wrapped.name } ` +
|
||||||
`Already exists`);
|
`Already exists`);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ var config = {
|
|||||||
output: {
|
output: {
|
||||||
path: __dirname + '/lib',
|
path: __dirname + '/lib',
|
||||||
filename: outputFile,
|
filename: outputFile,
|
||||||
|
library: libraryName,
|
||||||
libraryExport: 'default',
|
libraryExport: 'default',
|
||||||
libraryTarget: 'commonjs2',
|
libraryTarget: 'commonjs2',
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user