aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStarscouts <starscouts@equestria.dev>2024-07-02 22:23:01 +0200
committerStarscouts <starscouts@equestria.dev>2024-07-02 22:23:01 +0200
commit04527db1831299fb3cba5c3127fd462939b448cf (patch)
treef4893e7b64faf9e23adf36f676fc6e30e745a784
parentce613801c07c90d3e886fd6002f6e8f833589632 (diff)
downloadfaunerie-04527db1831299fb3cba5c3127fd462939b448cf.tar.gz
faunerie-04527db1831299fb3cba5c3127fd462939b448cf.tar.bz2
faunerie-04527db1831299fb3cba5c3127fd462939b448cf.zip
Cancel Rust rewrite3.1.0
-rwxr-xr-x.gitignore2
-rwxr-xr-xpackage-lock.json5
-rwxr-xr-xsql/mac/LICENSE25
-rwxr-xr-xsql/mac/README.md249
-rwxr-xr-xsql/mac/binding.gyp58
-rwxr-xr-xsql/mac/deps/common-sqlite.gypi60
-rwxr-xr-xsql/mac/deps/extract.js10
-rwxr-xr-xsql/mac/deps/sqlite3.gyp121
-rwxr-xr-xsql/mac/lib/sqlite3-binding.js1
-rwxr-xr-xsql/mac/lib/sqlite3.d.ts205
-rwxr-xr-xsql/mac/lib/sqlite3.js207
-rwxr-xr-xsql/mac/lib/trace.js38
-rwxr-xr-xsql/mac/package.json89
-rwxr-xr-xsql/win/LICENSE25
-rwxr-xr-xsql/win/README.md249
-rwxr-xr-xsql/win/binding.gyp58
-rwxr-xr-xsql/win/deps/common-sqlite.gypi60
-rwxr-xr-xsql/win/deps/extract.js10
-rwxr-xr-xsql/win/deps/sqlite3.gyp121
-rwxr-xr-xsql/win/lib/sqlite3-binding.js1
-rwxr-xr-xsql/win/lib/sqlite3.d.ts205
-rwxr-xr-xsql/win/lib/sqlite3.js207
-rwxr-xr-xsql/win/lib/trace.js38
-rwxr-xr-xsql/win/package.json89
24 files changed, 2128 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index aa803ba..f13185f 100755
--- a/.gitignore
+++ b/.gitignore
@@ -8,8 +8,6 @@ updater/node_modules
ai/*.pt
src/*.js
src/*.js.map
-sql/mac
-sql/win
e621/*.csv
e621/tags.json
e621/tag_aliases.json
diff --git a/package-lock.json b/package-lock.json
index a1c7bc6..2650569 100755
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,11 @@
{
"name": "faunerie",
- "version": "3.0.4",
+ "version": "3.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
- "name": "faunerie",
- "version": "3.0.4",
+ "version": "3.1.0",
"hasInstallScript": true,
"dependencies": {
"@electron/remote": "^2.1.2",
diff --git a/sql/mac/LICENSE b/sql/mac/LICENSE
new file mode 100755
index 0000000..6c4ce40
--- /dev/null
+++ b/sql/mac/LICENSE
@@ -0,0 +1,25 @@
+Copyright (c) MapBox
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+- Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+- Redistributions in binary form must reproduce the above copyright notice, this
+ list of conditions and the following disclaimer in the documentation and/or
+ other materials provided with the distribution.
+- Neither the name "MapBox" nor the names of its contributors may be
+ used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file
diff --git a/sql/mac/README.md b/sql/mac/README.md
new file mode 100755
index 0000000..ffc1f04
--- /dev/null
+++ b/sql/mac/README.md
@@ -0,0 +1,249 @@
+# ⚙️ node-sqlite3
+
+Asynchronous, non-blocking [SQLite3](https://sqlite.org/) bindings for [Node.js](http://nodejs.org/).
+
+[![Latest release](https://img.shields.io/github/release/TryGhost/node-sqlite3.svg)](https://www.npmjs.com/package/sqlite3)
+![Build Status](https://github.com/TryGhost/node-sqlite3/workflows/CI/badge.svg?branch=master)
+[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmapbox%2Fnode-sqlite3.svg?type=shield)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmapbox%2Fnode-sqlite3?ref=badge_shield)
+[![N-API v3 Badge](https://img.shields.io/badge/N--API-v3-green.svg)](https://nodejs.org/dist/latest/docs/api/n-api.html#n_api_n_api)
+[![N-API v6 Badge](https://img.shields.io/badge/N--API-v6-green.svg)](https://nodejs.org/dist/latest/docs/api/n-api.html#n_api_n_api)
+
+# Features
+
+ - Straightforward query and parameter binding interface
+ - Full Buffer/Blob support
+ - Extensive [debugging support](https://github.com/tryghost/node-sqlite3/wiki/Debugging)
+ - [Query serialization](https://github.com/tryghost/node-sqlite3/wiki/Control-Flow) API
+ - [Extension support](https://github.com/TryGhost/node-sqlite3/wiki/API#databaseloadextensionpath-callback), including bundled support for the [json1 extension](https://www.sqlite.org/json1.html)
+ - Big test suite
+ - Written in modern C++ and tested for memory leaks
+ - Bundles SQLite v3.44.2, or you can build using a local SQLite
+
+# Installing
+
+You can use [`npm`](https://github.com/npm/cli) or [`yarn`](https://github.com/yarnpkg/yarn) to install `sqlite3`:
+
+* (recommended) Latest published package:
+```bash
+npm install sqlite3
+# or
+yarn add sqlite3
+```
+* GitHub's `master` branch: `npm install https://github.com/tryghost/node-sqlite3/tarball/master`
+
+### Prebuilt binaries
+
+`sqlite3` v5+ was rewritten to use [Node-API](https://nodejs.org/api/n-api.html) so prebuilt binaries do not need to be built for specific Node versions. `sqlite3` currently builds for both Node-API v3 and v6. Check the [Node-API version matrix](https://nodejs.org/api/n-api.html#node-api-version-matrix) to ensure your Node version supports one of these. The prebuilt binaries should be supported on Node v10+.
+
+The module uses [`prebuild-install`](https://github.com/prebuild/prebuild-install) to download the prebuilt binary for your platform, if it exists. These binaries are hosted on GitHub Releases for `sqlite3` versions above 5.0.2, and they are hosted on S3 otherwise. The following targets are currently provided:
+
+* `darwin-arm64`
+* `darwin-x64`
+* `linux-arm64`
+* `linux-x64`
+* `linuxmusl-arm64`
+* `linuxmusl-x64`
+* `win32-ia32`
+* `win32-x64`
+
+Unfortunately, [prebuild](https://github.com/prebuild/prebuild/issues/174) cannot differentiate between `armv6` and `armv7`, and instead uses `arm` as the `{arch}`. Until that is fixed, you will still need to install `sqlite3` from [source](#source-install).
+
+Support for other platforms and architectures may be added in the future if CI supports building on them.
+
+If your environment isn't supported, it'll use `node-gyp` to build SQLite, but you will need to install a C++ compiler and linker.
+
+### Other ways to install
+
+It is also possible to make your own build of `sqlite3` from its source instead of its npm package ([See below.](#source-install)).
+
+The `sqlite3` module also works with [node-webkit](https://github.com/rogerwang/node-webkit) if node-webkit contains a supported version of Node.js engine. [(See below.)](#building-for-node-webkit)
+
+SQLite's [SQLCipher extension](https://github.com/sqlcipher/sqlcipher) is also supported. [(See below.)](#building-for-sqlcipher)
+
+# API
+
+See the [API documentation](https://github.com/TryGhost/node-sqlite3/wiki/API) in the wiki.
+
+# Usage
+
+**Note:** the module must be [installed](#installing) before use.
+
+``` js
+const sqlite3 = require('sqlite3').verbose();
+const db = new sqlite3.Database(':memory:');
+
+db.serialize(() => {
+ db.run("CREATE TABLE lorem (info TEXT)");
+
+ const stmt = db.prepare("INSERT INTO lorem VALUES (?)");
+ for (let i = 0; i < 10; i++) {
+ stmt.run("Ipsum " + i);
+ }
+ stmt.finalize();
+
+ db.each("SELECT rowid AS id, info FROM lorem", (err, row) => {
+ console.log(row.id + ": " + row.info);
+ });
+});
+
+db.close();
+```
+
+## Source install
+
+To skip searching for pre-compiled binaries, and force a build from source, use
+
+```bash
+npm install --build-from-source
+```
+
+The sqlite3 module depends only on libsqlite3. However, by default, an internal/bundled copy of sqlite will be built and statically linked, so an externally installed sqlite3 is not required.
+
+If you wish to install against an external sqlite then you need to pass the `--sqlite` argument to `npm` wrapper:
+
+```bash
+npm install --build-from-source --sqlite=/usr/local
+```
+
+If building against an external sqlite3 make sure to have the development headers available. Mac OS X ships with these by default. If you don't have them installed, install the `-dev` package with your package manager, e.g. `apt-get install libsqlite3-dev` for Debian/Ubuntu. Make sure that you have at least `libsqlite3` >= 3.6.
+
+Note, if building against homebrew-installed sqlite on OS X you can do:
+
+```bash
+npm install --build-from-source --sqlite=/usr/local/opt/sqlite/
+```
+
+## Custom file header (magic)
+
+The default sqlite file header is "SQLite format 3". You can specify a different magic, though this will make standard tools and libraries unable to work with your files.
+
+```bash
+npm install --build-from-source --sqlite_magic="MyCustomMagic15"
+```
+
+Note that the magic *must* be exactly 15 characters long (16 bytes including null terminator).
+
+## Building for node-webkit
+
+Because of ABI differences, `sqlite3` must be built in a custom to be used with [node-webkit](https://github.com/rogerwang/node-webkit).
+
+To build `sqlite3` for node-webkit:
+
+1. Install [`nw-gyp`](https://github.com/rogerwang/nw-gyp) globally: `npm install nw-gyp -g` *(unless already installed)*
+
+2. Build the module with the custom flags of `--runtime`, `--target_arch`, and `--target`:
+
+```bash
+NODE_WEBKIT_VERSION="0.8.6" # see latest version at https://github.com/rogerwang/node-webkit#downloads
+npm install sqlite3 --build-from-source --runtime=node-webkit --target_arch=ia32 --target=$(NODE_WEBKIT_VERSION)
+```
+
+You can also run this command from within a `sqlite3` checkout:
+
+```bash
+npm install --build-from-source --runtime=node-webkit --target_arch=ia32 --target=$(NODE_WEBKIT_VERSION)
+```
+
+Remember the following:
+
+* You must provide the right `--target_arch` flag. `ia32` is needed to target 32bit node-webkit builds, while `x64` will target 64bit node-webkit builds (if available for your platform).
+
+* After the `sqlite3` package is built for node-webkit it cannot run in the vanilla Node.js (and vice versa).
+ * For example, `npm test` of the node-webkit's package would fail.
+
+Visit the “[Using Node modules](https://github.com/rogerwang/node-webkit/wiki/Using-Node-modules)” article in the node-webkit's wiki for more details.
+
+## Building for SQLCipher
+
+For instructions on building SQLCipher, see [Building SQLCipher for Node.js](https://coolaj86.com/articles/building-sqlcipher-for-node-js-on-raspberry-pi-2/). Alternatively, you can install it with your local package manager.
+
+To run against SQLCipher, you need to compile `sqlite3` from source by passing build options like:
+
+```bash
+npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=/usr/
+
+node -e 'require("sqlite3")'
+```
+
+If your SQLCipher is installed in a custom location (if you compiled and installed it yourself), you'll need to set some environment variables:
+
+### On OS X with Homebrew
+
+Set the location where `brew` installed it:
+
+```bash
+export LDFLAGS="-L`brew --prefix`/opt/sqlcipher/lib"
+export CPPFLAGS="-I`brew --prefix`/opt/sqlcipher/include/sqlcipher"
+npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=`brew --prefix`
+
+node -e 'require("sqlite3")'
+```
+
+### On most Linuxes (including Raspberry Pi)
+
+Set the location where `make` installed it:
+
+```bash
+export LDFLAGS="-L/usr/local/lib"
+export CPPFLAGS="-I/usr/local/include -I/usr/local/include/sqlcipher"
+export CXXFLAGS="$CPPFLAGS"
+npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=/usr/local --verbose
+
+node -e 'require("sqlite3")'
+```
+
+### Custom builds and Electron
+
+Running `sqlite3` through [electron-rebuild](https://github.com/electron/electron-rebuild) does not preserve the SQLCipher extension, so some additional flags are needed to make this build Electron compatible. Your `npm install sqlite3 --build-from-source` command needs these additional flags (be sure to replace the target version with the current Electron version you are working with):
+
+```bash
+--runtime=electron --target=18.2.1 --dist-url=https://electronjs.org/headers
+```
+
+In the case of MacOS with Homebrew, the command should look like the following:
+
+```bash
+npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=`brew --prefix` --runtime=electron --target=18.2.1 --dist-url=https://electronjs.org/headers
+```
+
+# Testing
+
+```bash
+npm test
+```
+
+# Contributors
+
+* [Daniel Lockyer](https://github.com/daniellockyer)
+* [Konstantin Käfer](https://github.com/kkaefer)
+* [Dane Springmeyer](https://github.com/springmeyer)
+* [Will White](https://github.com/willwhite)
+* [Orlando Vazquez](https://github.com/orlandov)
+* [Artem Kustikov](https://github.com/artiz)
+* [Eric Fredricksen](https://github.com/grumdrig)
+* [John Wright](https://github.com/mrjjwright)
+* [Ryan Dahl](https://github.com/ry)
+* [Tom MacWright](https://github.com/tmcw)
+* [Carter Thaxton](https://github.com/carter-thaxton)
+* [Audrius Kažukauskas](https://github.com/audriusk)
+* [Johannes Schauer](https://github.com/pyneo)
+* [Mithgol](https://github.com/Mithgol)
+* [Kewde](https://github.com/kewde)
+
+# Acknowledgments
+
+Thanks to [Orlando Vazquez](https://github.com/orlandov),
+[Eric Fredricksen](https://github.com/grumdrig) and
+[Ryan Dahl](https://github.com/ry) for their SQLite bindings for node, and to mraleph on Freenode's #v8 for answering questions.
+
+This module was originally created by [Mapbox](https://mapbox.com/) & is now maintained by [Ghost](https://ghost.org).
+
+# Changelog
+
+We use [GitHub releases](https://github.com/TryGhost/node-sqlite3/releases) for notes on the latest versions. See [CHANGELOG.md](https://github.com/TryGhost/node-sqlite3/blob/b05f4594cf8b0de64743561fcd2cfe6f4571754d/CHANGELOG.md) in git history for details on older versions.
+
+# License
+
+`node-sqlite3` is [BSD licensed](https://github.com/tryghost/node-sqlite3/raw/master/LICENSE).
+
+[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmapbox%2Fnode-sqlite3.svg?type=large)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmapbox%2Fnode-sqlite3?ref=badge_large)
diff --git a/sql/mac/binding.gyp b/sql/mac/binding.gyp
new file mode 100755
index 0000000..a8fccd0
--- /dev/null
+++ b/sql/mac/binding.gyp
@@ -0,0 +1,58 @@
+{
+ "includes": [ "deps/common-sqlite.gypi" ],
+ "variables": {
+ "sqlite%":"internal",
+ "sqlite_libname%":"sqlite3",
+ "module_name": "node_sqlite3",
+ },
+ "targets": [
+ {
+ "target_name": "<(module_name)",
+ "cflags!": [ "-fno-exceptions" ],
+ "cflags_cc!": [ "-fno-exceptions" ],
+ "xcode_settings": { "GCC_ENABLE_CPP_EXCEPTIONS": "YES",
+ "CLANG_CXX_LIBRARY": "libc++",
+ "MACOSX_DEPLOYMENT_TARGET": "10.7",
+ },
+ "msvs_settings": {
+ "VCCLCompilerTool": { "ExceptionHandling": 1 },
+ },
+ "include_dirs": [
+ "<!@(node -p \"require('node-addon-api').include\")"],
+ "conditions": [
+ ["sqlite != 'internal'", {
+ "include_dirs": [
+ "<!@(node -p \"require('node-addon-api').include\")", "<(sqlite)/include" ],
+ "libraries": [
+ "-l<(sqlite_libname)"
+ ],
+ "conditions": [
+ [ "OS=='linux'", {"libraries+":["-Wl,-rpath=<@(sqlite)/lib"]} ],
+ [ "OS!='win'", {"libraries+":["-L<@(sqlite)/lib"]} ]
+ ],
+ 'msvs_settings': {
+ 'VCLinkerTool': {
+ 'AdditionalLibraryDirectories': [
+ '<(sqlite)/lib'
+ ],
+ },
+ }
+ },
+ {
+ "dependencies": [
+ "<!(node -p \"require('node-addon-api').gyp\")",
+ "deps/sqlite3.gyp:sqlite3"
+ ]
+ }
+ ]
+ ],
+ "sources": [
+ "src/backup.cc",
+ "src/database.cc",
+ "src/node_sqlite3.cc",
+ "src/statement.cc"
+ ],
+ "defines": [ "NAPI_VERSION=<(napi_build_version)", "NAPI_DISABLE_CPP_EXCEPTIONS=1" ]
+ }
+ ]
+}
diff --git a/sql/mac/deps/common-sqlite.gypi b/sql/mac/deps/common-sqlite.gypi
new file mode 100755
index 0000000..a04b1d5
--- /dev/null
+++ b/sql/mac/deps/common-sqlite.gypi
@@ -0,0 +1,60 @@
+{
+ 'variables': {
+ 'sqlite_version%':'3440200',
+ "toolset%":'',
+ },
+ 'target_defaults': {
+ 'default_configuration': 'Release',
+ 'conditions': [
+ [ 'toolset!=""', {
+ 'msbuild_toolset':'<(toolset)'
+ }]
+ ],
+ 'configurations': {
+ 'Debug': {
+ 'defines!': [
+ 'NDEBUG'
+ ],
+ 'cflags_cc!': [
+ '-O3',
+ '-Os',
+ '-DNDEBUG'
+ ],
+ 'xcode_settings': {
+ 'OTHER_CPLUSPLUSFLAGS!': [
+ '-O3',
+ '-Os',
+ '-DDEBUG'
+ ],
+ 'GCC_OPTIMIZATION_LEVEL': '0',
+ 'GCC_GENERATE_DEBUGGING_SYMBOLS': 'YES'
+ },
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'ExceptionHandling': 1, # /EHsc
+ }
+ }
+ },
+ 'Release': {
+ 'defines': [
+ 'NDEBUG'
+ ],
+ 'xcode_settings': {
+ 'OTHER_CPLUSPLUSFLAGS!': [
+ '-Os',
+ '-O2'
+ ],
+ 'GCC_OPTIMIZATION_LEVEL': '3',
+ 'GCC_GENERATE_DEBUGGING_SYMBOLS': 'NO',
+ 'DEAD_CODE_STRIPPING': 'YES',
+ 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES'
+ },
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'ExceptionHandling': 1, # /EHsc
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/sql/mac/deps/extract.js b/sql/mac/deps/extract.js
new file mode 100755
index 0000000..46aed47
--- /dev/null
+++ b/sql/mac/deps/extract.js
@@ -0,0 +1,10 @@
+const tar = require("tar");
+const path = require("path");
+const tarball = path.resolve(process.argv[2]);
+const dirname = path.resolve(process.argv[3]);
+
+tar.extract({
+ sync: true,
+ file: tarball,
+ cwd: dirname,
+});
diff --git a/sql/mac/deps/sqlite3.gyp b/sql/mac/deps/sqlite3.gyp
new file mode 100755
index 0000000..660b3b0
--- /dev/null
+++ b/sql/mac/deps/sqlite3.gyp
@@ -0,0 +1,121 @@
+{
+ 'includes': [ 'common-sqlite.gypi' ],
+
+ 'variables': {
+ 'sqlite_magic%': '',
+ },
+
+ 'target_defaults': {
+ 'default_configuration': 'Release',
+ 'cflags':[
+ '-std=c99'
+ ],
+ 'configurations': {
+ 'Debug': {
+ 'defines': [ 'DEBUG', '_DEBUG' ],
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'RuntimeLibrary': 1, # static debug
+ },
+ },
+ },
+ 'Release': {
+ 'defines': [ 'NDEBUG' ],
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'RuntimeLibrary': 0, # static release
+ },
+ },
+ }
+ },
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ },
+ 'VCLibrarianTool': {
+ },
+ 'VCLinkerTool': {
+ 'GenerateDebugInformation': 'true',
+ },
+ },
+ 'conditions': [
+ ['OS == "win"', {
+ 'defines': [
+ 'WIN32'
+ ],
+ }]
+ ],
+ },
+
+ 'targets': [
+ {
+ 'target_name': 'action_before_build',
+ 'type': 'none',
+ 'hard_dependency': 1,
+ 'actions': [
+ {
+ 'action_name': 'unpack_sqlite_dep',
+ 'inputs': [
+ './sqlite-autoconf-<@(sqlite_version).tar.gz'
+ ],
+ 'outputs': [
+ '<(SHARED_INTERMEDIATE_DIR)/sqlite-autoconf-<@(sqlite_version)/sqlite3.c'
+ ],
+ 'action': ['node','./extract.js','./sqlite-autoconf-<@(sqlite_version).tar.gz','<(SHARED_INTERMEDIATE_DIR)']
+ }
+ ],
+ 'direct_dependent_settings': {
+ 'include_dirs': [
+ '<(SHARED_INTERMEDIATE_DIR)/sqlite-autoconf-<@(sqlite_version)/',
+ ]
+ },
+ },
+ {
+ 'target_name': 'sqlite3',
+ 'type': 'static_library',
+ 'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)/sqlite-autoconf-<@(sqlite_version)/' ],
+ 'dependencies': [
+ 'action_before_build'
+ ],
+ 'sources': [
+ '<(SHARED_INTERMEDIATE_DIR)/sqlite-autoconf-<@(sqlite_version)/sqlite3.c'
+ ],
+ 'direct_dependent_settings': {
+ 'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)/sqlite-autoconf-<@(sqlite_version)/' ],
+ 'defines': [
+ 'SQLITE_THREADSAFE=1',
+ 'HAVE_USLEEP=1',
+ 'SQLITE_ENABLE_FTS3',
+ 'SQLITE_ENABLE_FTS4',
+ 'SQLITE_ENABLE_FTS5',
+ 'SQLITE_ENABLE_RTREE',
+ 'SQLITE_ENABLE_DBSTAT_VTAB=1',
+ 'SQLITE_ENABLE_MATH_FUNCTIONS'
+ ],
+ },
+ 'cflags_cc': [
+ '-Wno-unused-value'
+ ],
+ 'defines': [
+ '_REENTRANT=1',
+ 'SQLITE_THREADSAFE=1',
+ 'HAVE_USLEEP=1',
+ 'SQLITE_ENABLE_FTS3',
+ 'SQLITE_ENABLE_FTS4',
+ 'SQLITE_ENABLE_FTS5',
+ 'SQLITE_ENABLE_RTREE',
+ 'SQLITE_ENABLE_DBSTAT_VTAB=1',
+ 'SQLITE_ENABLE_MATH_FUNCTIONS'
+ ],
+ 'export_dependent_settings': [
+ 'action_before_build',
+ ],
+ 'conditions': [
+ ["sqlite_magic != ''", {
+ 'defines': [
+ 'SQLITE_FILE_HEADER="<(sqlite_magic)"'
+ ]
+ }]
+ ],
+ }
+ ]
+}
diff --git a/sql/mac/lib/sqlite3-binding.js b/sql/mac/lib/sqlite3-binding.js
new file mode 100755
index 0000000..98d1b91
--- /dev/null
+++ b/sql/mac/lib/sqlite3-binding.js
@@ -0,0 +1 @@
+module.exports = require('bindings')('node_sqlite3.node');
diff --git a/sql/mac/lib/sqlite3.d.ts b/sql/mac/lib/sqlite3.d.ts
new file mode 100755
index 0000000..15e6623
--- /dev/null
+++ b/sql/mac/lib/sqlite3.d.ts
@@ -0,0 +1,205 @@
+// Type definitions for sqlite3
+// Project: http://github.com/tryghost/node-sqlite3
+
+/// <reference types="node" />
+
+import events = require("events");
+
+export const OPEN_READONLY: number;
+export const OPEN_READWRITE: number;
+export const OPEN_CREATE: number;
+export const OPEN_FULLMUTEX: number;
+export const OPEN_SHAREDCACHE: number;
+export const OPEN_PRIVATECACHE: number;
+export const OPEN_URI: number;
+
+export const VERSION: string;
+export const SOURCE_ID: string;
+export const VERSION_NUMBER: number;
+
+export const OK: number;
+export const ERROR: number;
+export const INTERNAL: number;
+export const PERM: number;
+export const ABORT: number;
+export const BUSY: number;
+export const LOCKED: number;
+export const NOMEM: number;
+export const READONLY: number;
+export const INTERRUPT: number
+export const IOERR: number;
+export const CORRUPT: number
+export const NOTFOUND: number;
+export const FULL: number;
+export const CANTOPEN: number;
+export const PROTOCOL: number;
+export const EMPTY: number;
+export const SCHEMA: number;
+export const TOOBIG: number
+export const CONSTRAINT: number
+export const MISMATCH: number;
+export const MISUSE: number;
+export const NOLFS: number;
+export const AUTH: number
+export const FORMAT: number;
+export const RANGE: number
+export const NOTADB: number;
+
+export const LIMIT_LENGTH: number;
+export const LIMIT_SQL_LENGTH: number;
+export const LIMIT_COLUMN: number;
+export const LIMIT_EXPR_DEPTH: number;
+export const LIMIT_COMPOUND_SELECT: number;
+export const LIMIT_VDBE_OP: number;
+export const LIMIT_FUNCTION_ARG: number;
+export const LIMIT_ATTACHED: number;
+export const LIMIT_LIKE_PATTERN_LENGTH: number;
+export const LIMIT_VARIABLE_NUMBER: number;
+export const LIMIT_TRIGGER_DEPTH: number;
+export const LIMIT_WORKER_THREADS: number;
+
+export const cached: {
+ Database(filename: string, callback?: (this: Database, err: Error | null) => void): Database;
+ Database(filename: string, mode?: number, callback?: (this: Database, err: Error | null) => void): Database;
+};
+
+export interface RunResult extends Statement {
+ lastID: number;
+ changes: number;
+}
+
+export class Statement extends events.EventEmitter {
+ bind(callback?: (err: Error | null) => void): this;
+ bind(...params: any[]): this;
+
+ reset(callback?: (err: null) => void): this;
+
+ finalize(callback?: (err: Error) => void): Database;
+
+ run(callback?: (err: Error | null) => void): this;
+ run(params: any, callback?: (this: RunResult, err: Error | null) => void): this;
+ run(...params: any[]): this;
+
+ get<T>(callback?: (err: Error | null, row?: T) => void): this;
+ get<T>(params: any, callback?: (this: RunResult, err: Error | null, row?: T) => void): this;
+ get(...params: any[]): this;
+
+ all<T>(callback?: (err: Error | null, rows: T[]) => void): this;
+ all<T>(params: any, callback?: (this: RunResult, err: Error | null, rows: T[]) => void): this;
+ all(...params: any[]): this;
+
+ each<T>(callback?: (err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this;
+ each<T>(params: any, callback?: (this: RunResult, err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this;
+ each(...params: any[]): this;
+}
+
+export class Database extends events.EventEmitter {
+ constructor(filename: string, callback?: (err: Error | null) => void);
+ constructor(filename: string, mode?: number, callback?: (err: Error | null) => void);
+
+ close(callback?: (err: Error | null) => void): void;
+
+ run(sql: string, callback?: (this: RunResult, err: Error | null) => void): this;
+ run(sql: string, params: any, callback?: (this: RunResult, err: Error | null) => void): this;
+ run(sql: string, ...params: any[]): this;
+
+ get<T>(sql: string, callback?: (this: Statement, err: Error | null, row: T) => void): this;
+ get<T>(sql: string, params: any, callback?: (this: Statement, err: Error | null, row: T) => void): this;
+ get(sql: string, ...params: any[]): this;
+
+ all<T>(sql: string, callback?: (this: Statement, err: Error | null, rows: T[]) => void): this;
+ all<T>(sql: string, params: any, callback?: (this: Statement, err: Error | null, rows: T[]) => void): this;
+ all(sql: string, ...params: any[]): this;
+
+ each<T>(sql: string, callback?: (this: Statement, err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this;
+ each<T>(sql: string, params: any, callback?: (this: Statement, err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this;
+ each(sql: string, ...params: any[]): this;
+
+ exec(sql: string, callback?: (this: Statement, err: Error | null) => void): this;
+
+ prepare(sql: string, callback?: (this: Statement, err: Error | null) => void): Statement;
+ prepare(sql: string, params: any, callback?: (this: Statement, err: Error | null) => void): Statement;
+ prepare(sql: string, ...params: any[]): Statement;
+
+ serialize(callback?: () => void): void;
+ parallelize(callback?: () => void): void;
+
+ on(event: "trace", listener: (sql: string) => void): this;
+ on(event: "profile", listener: (sql: string, time: number) => void): this;
+ on(event: "change", listener: (type: string, database: string, table: string, rowid: number) => void): this;
+ on(event: "error", listener: (err: Error) => void): this;
+ on(event: "open" | "close", listener: () => void): this;
+ on(event: string, listener: (...args: any[]) => void): this;
+
+ configure(option: "busyTimeout", value: number): void;
+ configure(option: "limit", id: number, value: number): void;
+
+ loadExtension(filename: string, callback?: (err: Error | null) => void): this;
+
+ wait(callback?: (param: null) => void): this;
+
+ interrupt(): void;
+}
+
+export function verbose(): sqlite3;
+
+export interface sqlite3 {
+ OPEN_READONLY: number;
+ OPEN_READWRITE: number;
+ OPEN_CREATE: number;
+ OPEN_FULLMUTEX: number;
+ OPEN_SHAREDCACHE: number;
+ OPEN_PRIVATECACHE: number;
+ OPEN_URI: number;
+
+ VERSION: string;
+ SOURCE_ID: string;
+ VERSION_NUMBER: number;
+
+ OK: number;
+ ERROR: number;
+ INTERNAL: number;
+ PERM: number;
+ ABORT: number;
+ BUSY: number;
+ LOCKED: number;
+ NOMEM: number;
+ READONLY: number;
+ INTERRUPT: number
+ IOERR: number;
+ CORRUPT: number
+ NOTFOUND: number;
+ FULL: number;
+ CANTOPEN: number;
+ PROTOCOL: number;
+ EMPTY: number;
+ SCHEMA: number;
+ TOOBIG: number
+ CONSTRAINT: number
+ MISMATCH: number;
+ MISUSE: number;
+ NOLFS: number;
+ AUTH: number
+ FORMAT: number;
+ RANGE: number
+ NOTADB: number;
+
+ LIMIT_LENGTH: number;
+ LIMIT_SQL_LENGTH: number;
+ LIMIT_COLUMN: number;
+ LIMIT_EXPR_DEPTH: number;
+ LIMIT_COMPOUND_SELECT: number;
+ LIMIT_VDBE_OP: number;
+ LIMIT_FUNCTION_ARG: number;
+ LIMIT_ATTACHED: number;
+ LIMIT_LIKE_PATTERN_LENGTH: number;
+ LIMIT_VARIABLE_NUMBER: number;
+ LIMIT_TRIGGER_DEPTH: number;
+ LIMIT_WORKER_THREADS: number;
+
+ cached: typeof cached;
+ RunResult: RunResult;
+ Statement: typeof Statement;
+ Database: typeof Database;
+ verbose(): this;
+} \ No newline at end of file
diff --git a/sql/mac/lib/sqlite3.js b/sql/mac/lib/sqlite3.js
new file mode 100755
index 0000000..430a2b8
--- /dev/null
+++ b/sql/mac/lib/sqlite3.js
@@ -0,0 +1,207 @@
+const path = require('path');
+const sqlite3 = require('./sqlite3-binding.js');
+const EventEmitter = require('events').EventEmitter;
+module.exports = exports = sqlite3;
+
+function normalizeMethod (fn) {
+ return function (sql) {
+ let errBack;
+ const args = Array.prototype.slice.call(arguments, 1);
+
+ if (typeof args[args.length - 1] === 'function') {
+ const callback = args[args.length - 1];
+ errBack = function(err) {
+ if (err) {
+ callback(err);
+ }
+ };
+ }
+ const statement = new Statement(this, sql, errBack);
+ return fn.call(this, statement, args);
+ };
+}
+
+function inherits(target, source) {
+ for (const k in source.prototype)
+ target.prototype[k] = source.prototype[k];
+}
+
+sqlite3.cached = {
+ Database: function(file, a, b) {
+ if (file === '' || file === ':memory:') {
+ // Don't cache special databases.
+ return new Database(file, a, b);
+ }
+
+ let db;
+ file = path.resolve(file);
+
+ if (!sqlite3.cached.objects[file]) {
+ db = sqlite3.cached.objects[file] = new Database(file, a, b);
+ }
+ else {
+ // Make sure the callback is called.
+ db = sqlite3.cached.objects[file];
+ const callback = (typeof a === 'number') ? b : a;
+ if (typeof callback === 'function') {
+ function cb() { callback.call(db, null); }
+ if (db.open) process.nextTick(cb);
+ else db.once('open', cb);
+ }
+ }
+
+ return db;
+ },
+ objects: {}
+};
+
+
+const Database = sqlite3.Database;
+const Statement = sqlite3.Statement;
+const Backup = sqlite3.Backup;
+
+inherits(Database, EventEmitter);
+inherits(Statement, EventEmitter);
+inherits(Backup, EventEmitter);
+
+// Database#prepare(sql, [bind1, bind2, ...], [callback])
+Database.prototype.prepare = normalizeMethod(function(statement, params) {
+ return params.length
+ ? statement.bind.apply(statement, params)
+ : statement;
+});
+
+// Database#run(sql, [bind1, bind2, ...], [callback])
+Database.prototype.run = normalizeMethod(function(statement, params) {
+ statement.run.apply(statement, params).finalize();
+ return this;
+});
+
+// Database#get(sql, [bind1, bind2, ...], [callback])
+Database.prototype.get = normalizeMethod(function(statement, params) {
+ statement.get.apply(statement, params).finalize();
+ return this;
+});
+
+// Database#all(sql, [bind1, bind2, ...], [callback])
+Database.prototype.all = normalizeMethod(function(statement, params) {
+ statement.all.apply(statement, params).finalize();
+ return this;
+});
+
+// Database#each(sql, [bind1, bind2, ...], [callback], [complete])
+Database.prototype.each = normalizeMethod(function(statement, params) {
+ statement.each.apply(statement, params).finalize();
+ return this;
+});
+
+Database.prototype.map = normalizeMethod(function(statement, params) {
+ statement.map.apply(statement, params).finalize();
+ return this;
+});
+
+// Database#backup(filename, [callback])
+// Database#backup(filename, destName, sourceName, filenameIsDest, [callback])
+Database.prototype.backup = function() {
+ let backup;
+ if (arguments.length <= 2) {
+ // By default, we write the main database out to the main database of the named file.
+ // This is the most likely use of the backup api.
+ backup = new Backup(this, arguments[0], 'main', 'main', true, arguments[1]);
+ } else {
+ // Otherwise, give the user full control over the sqlite3_backup_init arguments.
+ backup = new Backup(this, arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]);
+ }
+ // Per the sqlite docs, exclude the following errors as non-fatal by default.
+ backup.retryErrors = [sqlite3.BUSY, sqlite3.LOCKED];
+ return backup;
+};
+
+Statement.prototype.map = function() {
+ const params = Array.prototype.slice.call(arguments);
+ const callback = params.pop();
+ params.push(function(err, rows) {
+ if (err) return callback(err);
+ const result = {};
+ if (rows.length) {
+ const keys = Object.keys(rows[0]);
+ const key = keys[0];
+ if (keys.length > 2) {
+ // Value is an object
+ for (let i = 0; i < rows.length; i++) {
+ result[rows[i][key]] = rows[i];
+ }
+ } else {
+ const value = keys[1];
+ // Value is a plain value
+ for (let i = 0; i < rows.length; i++) {
+ result[rows[i][key]] = rows[i][value];
+ }
+ }
+ }
+ callback(err, result);
+ });
+ return this.all.apply(this, params);
+};
+
+let isVerbose = false;
+
+const supportedEvents = [ 'trace', 'profile', 'change' ];
+
+Database.prototype.addListener = Database.prototype.on = function(type) {
+ const val = EventEmitter.prototype.addListener.apply(this, arguments);
+ if (supportedEvents.indexOf(type) >= 0) {
+ this.configure(type, true);
+ }
+ return val;
+};
+
+Database.prototype.removeListener = function(type) {
+ const val = EventEmitter.prototype.removeListener.apply(this, arguments);
+ if (supportedEvents.indexOf(type) >= 0 && !this._events[type]) {
+ this.configure(type, false);
+ }
+ return val;
+};
+
+Database.prototype.removeAllListeners = function(type) {
+ const val = EventEmitter.prototype.removeAllListeners.apply(this, arguments);
+ if (supportedEvents.indexOf(type) >= 0) {
+ this.configure(type, false);
+ }
+ return val;
+};
+
+// Save the stack trace over EIO callbacks.
+sqlite3.verbose = function() {
+ if (!isVerbose) {
+ const trace = require('./trace');
+ [
+ 'prepare',
+ 'get',
+ 'run',
+ 'all',
+ 'each',
+ 'map',
+ 'close',
+ 'exec'
+ ].forEach(function (name) {
+ trace.extendTrace(Database.prototype, name);
+ });
+ [
+ 'bind',
+ 'get',
+ 'run',
+ 'all',
+ 'each',
+ 'map',
+ 'reset',
+ 'finalize',
+ ].forEach(function (name) {
+ trace.extendTrace(Statement.prototype, name);
+ });
+ isVerbose = true;
+ }
+
+ return sqlite3;
+};
diff --git a/sql/mac/lib/trace.js b/sql/mac/lib/trace.js
new file mode 100755
index 0000000..1d84cb0
--- /dev/null
+++ b/sql/mac/lib/trace.js
@@ -0,0 +1,38 @@
+// Inspired by https://github.com/tlrobinson/long-stack-traces
+const util = require('util');
+
+function extendTrace(object, property, pos) {
+ const old = object[property];
+ object[property] = function() {
+ const error = new Error();
+ const name = object.constructor.name + '#' + property + '(' +
+ Array.prototype.slice.call(arguments).map(function(el) {
+ return util.inspect(el, false, 0);
+ }).join(', ') + ')';
+
+ if (typeof pos === 'undefined') pos = -1;
+ if (pos < 0) pos += arguments.length;
+ const cb = arguments[pos];
+ if (typeof arguments[pos] === 'function') {
+ arguments[pos] = function replacement() {
+ const err = arguments[0];
+ if (err && err.stack && !err.__augmented) {
+ err.stack = filter(err).join('\n');
+ err.stack += '\n--> in ' + name;
+ err.stack += '\n' + filter(error).slice(1).join('\n');
+ err.__augmented = true;
+ }
+ return cb.apply(this, arguments);
+ };
+ }
+ return old.apply(this, arguments);
+ };
+}
+exports.extendTrace = extendTrace;
+
+
+function filter(error) {
+ return error.stack.split('\n').filter(function(line) {
+ return line.indexOf(__filename) < 0;
+ });
+}
diff --git a/sql/mac/package.json b/sql/mac/package.json
new file mode 100755
index 0000000..ab413ff
--- /dev/null
+++ b/sql/mac/package.json
@@ -0,0 +1,89 @@
+{
+ "name": "sqlite3",
+ "description": "Asynchronous, non-blocking SQLite3 bindings",
+ "version": "5.1.7",
+ "homepage": "https://github.com/TryGhost/node-sqlite3",
+ "author": {
+ "name": "Mapbox",
+ "url": "https://mapbox.com/"
+ },
+ "binary": {
+ "napi_versions": [
+ 3,
+ 6
+ ]
+ },
+ "contributors": [
+ "Daniel Lockyer <hi@daniellockyer.com>",
+ "Konstantin Käfer <mail@kkaefer.com>",
+ "Dane Springmeyer <dane@mapbox.com>",
+ "Will White <will@mapbox.com>",
+ "Orlando Vazquez <ovazquez@gmail.com>",
+ "Artem Kustikov <kustikoff@gmail.com>",
+ "Eric Fredricksen <efredricksen@gmail.com>",
+ "John Wright <mrjjwright@gmail.com>",
+ "Ryan Dahl <ry@tinyclouds.org>",
+ "Tom MacWright <tom@mapbox.com>",
+ "Carter Thaxton <carter.thaxton@gmail.com>",
+ "Audrius Kažukauskas <audrius@neutrino.lt>",
+ "Johannes Schauer <josch@pyneo.org>",
+ "Nathan Rajlich <nathan@tootallnate.net>",
+ "AJ ONeal <coolaj86@gmail.com>",
+ "Mithgol",
+ "Ben Noordhuis <ben@strongloop.com>"
+ ],
+ "files": [
+ "binding.gyp",
+ "deps/",
+ "lib/*.js",
+ "lib/*.d.ts",
+ "src/"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/TryGhost/node-sqlite3.git"
+ },
+ "dependencies": {
+ "bindings": "^1.5.0",
+ "node-addon-api": "^7.0.0",
+ "prebuild-install": "^7.1.1",
+ "tar": "^6.1.11"
+ },
+ "devDependencies": {
+ "eslint": "8.56.0",
+ "mocha": "10.2.0",
+ "prebuild": "12.1.0"
+ },
+ "peerDependencies": {
+ "node-gyp": "8.x"
+ },
+ "peerDependenciesMeta": {
+ "node-gyp": {
+ "optional": true
+ }
+ },
+ "optionalDependencies": {
+ "node-gyp": "8.x"
+ },
+ "scripts": {
+ "install": "prebuild-install -r napi || node-gyp rebuild",
+ "prebuild": "prebuild --runtime napi --all --verbose",
+ "rebuild": "node-gyp rebuild",
+ "upload": "prebuild --verbose --prerelease",
+ "test": "node test/support/createdb.js && mocha -R spec --timeout 480000"
+ },
+ "license": "BSD-3-Clause",
+ "keywords": [
+ "sql",
+ "sqlite",
+ "sqlite3",
+ "database"
+ ],
+ "main": "./lib/sqlite3",
+ "types": "./lib/sqlite3.d.ts",
+ "renovate": {
+ "extends": [
+ "@tryghost:base"
+ ]
+ }
+}
diff --git a/sql/win/LICENSE b/sql/win/LICENSE
new file mode 100755
index 0000000..6c4ce40
--- /dev/null
+++ b/sql/win/LICENSE
@@ -0,0 +1,25 @@
+Copyright (c) MapBox
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+- Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+- Redistributions in binary form must reproduce the above copyright notice, this
+ list of conditions and the following disclaimer in the documentation and/or
+ other materials provided with the distribution.
+- Neither the name "MapBox" nor the names of its contributors may be
+ used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file
diff --git a/sql/win/README.md b/sql/win/README.md
new file mode 100755
index 0000000..ffc1f04
--- /dev/null
+++ b/sql/win/README.md
@@ -0,0 +1,249 @@
+# ⚙️ node-sqlite3
+
+Asynchronous, non-blocking [SQLite3](https://sqlite.org/) bindings for [Node.js](http://nodejs.org/).
+
+[![Latest release](https://img.shields.io/github/release/TryGhost/node-sqlite3.svg)](https://www.npmjs.com/package/sqlite3)
+![Build Status](https://github.com/TryGhost/node-sqlite3/workflows/CI/badge.svg?branch=master)
+[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmapbox%2Fnode-sqlite3.svg?type=shield)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmapbox%2Fnode-sqlite3?ref=badge_shield)
+[![N-API v3 Badge](https://img.shields.io/badge/N--API-v3-green.svg)](https://nodejs.org/dist/latest/docs/api/n-api.html#n_api_n_api)
+[![N-API v6 Badge](https://img.shields.io/badge/N--API-v6-green.svg)](https://nodejs.org/dist/latest/docs/api/n-api.html#n_api_n_api)
+
+# Features
+
+ - Straightforward query and parameter binding interface
+ - Full Buffer/Blob support
+ - Extensive [debugging support](https://github.com/tryghost/node-sqlite3/wiki/Debugging)
+ - [Query serialization](https://github.com/tryghost/node-sqlite3/wiki/Control-Flow) API
+ - [Extension support](https://github.com/TryGhost/node-sqlite3/wiki/API#databaseloadextensionpath-callback), including bundled support for the [json1 extension](https://www.sqlite.org/json1.html)
+ - Big test suite
+ - Written in modern C++ and tested for memory leaks
+ - Bundles SQLite v3.44.2, or you can build using a local SQLite
+
+# Installing
+
+You can use [`npm`](https://github.com/npm/cli) or [`yarn`](https://github.com/yarnpkg/yarn) to install `sqlite3`:
+
+* (recommended) Latest published package:
+```bash
+npm install sqlite3
+# or
+yarn add sqlite3
+```
+* GitHub's `master` branch: `npm install https://github.com/tryghost/node-sqlite3/tarball/master`
+
+### Prebuilt binaries
+
+`sqlite3` v5+ was rewritten to use [Node-API](https://nodejs.org/api/n-api.html) so prebuilt binaries do not need to be built for specific Node versions. `sqlite3` currently builds for both Node-API v3 and v6. Check the [Node-API version matrix](https://nodejs.org/api/n-api.html#node-api-version-matrix) to ensure your Node version supports one of these. The prebuilt binaries should be supported on Node v10+.
+
+The module uses [`prebuild-install`](https://github.com/prebuild/prebuild-install) to download the prebuilt binary for your platform, if it exists. These binaries are hosted on GitHub Releases for `sqlite3` versions above 5.0.2, and they are hosted on S3 otherwise. The following targets are currently provided:
+
+* `darwin-arm64`
+* `darwin-x64`
+* `linux-arm64`
+* `linux-x64`
+* `linuxmusl-arm64`
+* `linuxmusl-x64`
+* `win32-ia32`
+* `win32-x64`
+
+Unfortunately, [prebuild](https://github.com/prebuild/prebuild/issues/174) cannot differentiate between `armv6` and `armv7`, and instead uses `arm` as the `{arch}`. Until that is fixed, you will still need to install `sqlite3` from [source](#source-install).
+
+Support for other platforms and architectures may be added in the future if CI supports building on them.
+
+If your environment isn't supported, it'll use `node-gyp` to build SQLite, but you will need to install a C++ compiler and linker.
+
+### Other ways to install
+
+It is also possible to make your own build of `sqlite3` from its source instead of its npm package ([See below.](#source-install)).
+
+The `sqlite3` module also works with [node-webkit](https://github.com/rogerwang/node-webkit) if node-webkit contains a supported version of Node.js engine. [(See below.)](#building-for-node-webkit)
+
+SQLite's [SQLCipher extension](https://github.com/sqlcipher/sqlcipher) is also supported. [(See below.)](#building-for-sqlcipher)
+
+# API
+
+See the [API documentation](https://github.com/TryGhost/node-sqlite3/wiki/API) in the wiki.
+
+# Usage
+
+**Note:** the module must be [installed](#installing) before use.
+
+``` js
+const sqlite3 = require('sqlite3').verbose();
+const db = new sqlite3.Database(':memory:');
+
+db.serialize(() => {
+ db.run("CREATE TABLE lorem (info TEXT)");
+
+ const stmt = db.prepare("INSERT INTO lorem VALUES (?)");
+ for (let i = 0; i < 10; i++) {
+ stmt.run("Ipsum " + i);
+ }
+ stmt.finalize();
+
+ db.each("SELECT rowid AS id, info FROM lorem", (err, row) => {
+ console.log(row.id + ": " + row.info);
+ });
+});
+
+db.close();
+```
+
+## Source install
+
+To skip searching for pre-compiled binaries, and force a build from source, use
+
+```bash
+npm install --build-from-source
+```
+
+The sqlite3 module depends only on libsqlite3. However, by default, an internal/bundled copy of sqlite will be built and statically linked, so an externally installed sqlite3 is not required.
+
+If you wish to install against an external sqlite then you need to pass the `--sqlite` argument to `npm` wrapper:
+
+```bash
+npm install --build-from-source --sqlite=/usr/local
+```
+
+If building against an external sqlite3 make sure to have the development headers available. Mac OS X ships with these by default. If you don't have them installed, install the `-dev` package with your package manager, e.g. `apt-get install libsqlite3-dev` for Debian/Ubuntu. Make sure that you have at least `libsqlite3` >= 3.6.
+
+Note, if building against homebrew-installed sqlite on OS X you can do:
+
+```bash
+npm install --build-from-source --sqlite=/usr/local/opt/sqlite/
+```
+
+## Custom file header (magic)
+
+The default sqlite file header is "SQLite format 3". You can specify a different magic, though this will make standard tools and libraries unable to work with your files.
+
+```bash
+npm install --build-from-source --sqlite_magic="MyCustomMagic15"
+```
+
+Note that the magic *must* be exactly 15 characters long (16 bytes including null terminator).
+
+## Building for node-webkit
+
+Because of ABI differences, `sqlite3` must be built in a custom to be used with [node-webkit](https://github.com/rogerwang/node-webkit).
+
+To build `sqlite3` for node-webkit:
+
+1. Install [`nw-gyp`](https://github.com/rogerwang/nw-gyp) globally: `npm install nw-gyp -g` *(unless already installed)*
+
+2. Build the module with the custom flags of `--runtime`, `--target_arch`, and `--target`:
+
+```bash
+NODE_WEBKIT_VERSION="0.8.6" # see latest version at https://github.com/rogerwang/node-webkit#downloads
+npm install sqlite3 --build-from-source --runtime=node-webkit --target_arch=ia32 --target=$(NODE_WEBKIT_VERSION)
+```
+
+You can also run this command from within a `sqlite3` checkout:
+
+```bash
+npm install --build-from-source --runtime=node-webkit --target_arch=ia32 --target=$(NODE_WEBKIT_VERSION)
+```
+
+Remember the following:
+
+* You must provide the right `--target_arch` flag. `ia32` is needed to target 32bit node-webkit builds, while `x64` will target 64bit node-webkit builds (if available for your platform).
+
+* After the `sqlite3` package is built for node-webkit it cannot run in the vanilla Node.js (and vice versa).
+ * For example, `npm test` of the node-webkit's package would fail.
+
+Visit the “[Using Node modules](https://github.com/rogerwang/node-webkit/wiki/Using-Node-modules)” article in the node-webkit's wiki for more details.
+
+## Building for SQLCipher
+
+For instructions on building SQLCipher, see [Building SQLCipher for Node.js](https://coolaj86.com/articles/building-sqlcipher-for-node-js-on-raspberry-pi-2/). Alternatively, you can install it with your local package manager.
+
+To run against SQLCipher, you need to compile `sqlite3` from source by passing build options like:
+
+```bash
+npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=/usr/
+
+node -e 'require("sqlite3")'
+```
+
+If your SQLCipher is installed in a custom location (if you compiled and installed it yourself), you'll need to set some environment variables:
+
+### On OS X with Homebrew
+
+Set the location where `brew` installed it:
+
+```bash
+export LDFLAGS="-L`brew --prefix`/opt/sqlcipher/lib"
+export CPPFLAGS="-I`brew --prefix`/opt/sqlcipher/include/sqlcipher"
+npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=`brew --prefix`
+
+node -e 'require("sqlite3")'
+```
+
+### On most Linuxes (including Raspberry Pi)
+
+Set the location where `make` installed it:
+
+```bash
+export LDFLAGS="-L/usr/local/lib"
+export CPPFLAGS="-I/usr/local/include -I/usr/local/include/sqlcipher"
+export CXXFLAGS="$CPPFLAGS"
+npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=/usr/local --verbose
+
+node -e 'require("sqlite3")'
+```
+
+### Custom builds and Electron
+
+Running `sqlite3` through [electron-rebuild](https://github.com/electron/electron-rebuild) does not preserve the SQLCipher extension, so some additional flags are needed to make this build Electron compatible. Your `npm install sqlite3 --build-from-source` command needs these additional flags (be sure to replace the target version with the current Electron version you are working with):
+
+```bash
+--runtime=electron --target=18.2.1 --dist-url=https://electronjs.org/headers
+```
+
+In the case of MacOS with Homebrew, the command should look like the following:
+
+```bash
+npm install sqlite3 --build-from-source --sqlite_libname=sqlcipher --sqlite=`brew --prefix` --runtime=electron --target=18.2.1 --dist-url=https://electronjs.org/headers
+```
+
+# Testing
+
+```bash
+npm test
+```
+
+# Contributors
+
+* [Daniel Lockyer](https://github.com/daniellockyer)
+* [Konstantin Käfer](https://github.com/kkaefer)
+* [Dane Springmeyer](https://github.com/springmeyer)
+* [Will White](https://github.com/willwhite)
+* [Orlando Vazquez](https://github.com/orlandov)
+* [Artem Kustikov](https://github.com/artiz)
+* [Eric Fredricksen](https://github.com/grumdrig)
+* [John Wright](https://github.com/mrjjwright)
+* [Ryan Dahl](https://github.com/ry)
+* [Tom MacWright](https://github.com/tmcw)
+* [Carter Thaxton](https://github.com/carter-thaxton)
+* [Audrius Kažukauskas](https://github.com/audriusk)
+* [Johannes Schauer](https://github.com/pyneo)
+* [Mithgol](https://github.com/Mithgol)
+* [Kewde](https://github.com/kewde)
+
+# Acknowledgments
+
+Thanks to [Orlando Vazquez](https://github.com/orlandov),
+[Eric Fredricksen](https://github.com/grumdrig) and
+[Ryan Dahl](https://github.com/ry) for their SQLite bindings for node, and to mraleph on Freenode's #v8 for answering questions.
+
+This module was originally created by [Mapbox](https://mapbox.com/) & is now maintained by [Ghost](https://ghost.org).
+
+# Changelog
+
+We use [GitHub releases](https://github.com/TryGhost/node-sqlite3/releases) for notes on the latest versions. See [CHANGELOG.md](https://github.com/TryGhost/node-sqlite3/blob/b05f4594cf8b0de64743561fcd2cfe6f4571754d/CHANGELOG.md) in git history for details on older versions.
+
+# License
+
+`node-sqlite3` is [BSD licensed](https://github.com/tryghost/node-sqlite3/raw/master/LICENSE).
+
+[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmapbox%2Fnode-sqlite3.svg?type=large)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fmapbox%2Fnode-sqlite3?ref=badge_large)
diff --git a/sql/win/binding.gyp b/sql/win/binding.gyp
new file mode 100755
index 0000000..a8fccd0
--- /dev/null
+++ b/sql/win/binding.gyp
@@ -0,0 +1,58 @@
+{
+ "includes": [ "deps/common-sqlite.gypi" ],
+ "variables": {
+ "sqlite%":"internal",
+ "sqlite_libname%":"sqlite3",
+ "module_name": "node_sqlite3",
+ },
+ "targets": [
+ {
+ "target_name": "<(module_name)",
+ "cflags!": [ "-fno-exceptions" ],
+ "cflags_cc!": [ "-fno-exceptions" ],
+ "xcode_settings": { "GCC_ENABLE_CPP_EXCEPTIONS": "YES",
+ "CLANG_CXX_LIBRARY": "libc++",
+ "MACOSX_DEPLOYMENT_TARGET": "10.7",
+ },
+ "msvs_settings": {
+ "VCCLCompilerTool": { "ExceptionHandling": 1 },
+ },
+ "include_dirs": [
+ "<!@(node -p \"require('node-addon-api').include\")"],
+ "conditions": [
+ ["sqlite != 'internal'", {
+ "include_dirs": [
+ "<!@(node -p \"require('node-addon-api').include\")", "<(sqlite)/include" ],
+ "libraries": [
+ "-l<(sqlite_libname)"
+ ],
+ "conditions": [
+ [ "OS=='linux'", {"libraries+":["-Wl,-rpath=<@(sqlite)/lib"]} ],
+ [ "OS!='win'", {"libraries+":["-L<@(sqlite)/lib"]} ]
+ ],
+ 'msvs_settings': {
+ 'VCLinkerTool': {
+ 'AdditionalLibraryDirectories': [
+ '<(sqlite)/lib'
+ ],
+ },
+ }
+ },
+ {
+ "dependencies": [
+ "<!(node -p \"require('node-addon-api').gyp\")",
+ "deps/sqlite3.gyp:sqlite3"
+ ]
+ }
+ ]
+ ],
+ "sources": [
+ "src/backup.cc",
+ "src/database.cc",
+ "src/node_sqlite3.cc",
+ "src/statement.cc"
+ ],
+ "defines": [ "NAPI_VERSION=<(napi_build_version)", "NAPI_DISABLE_CPP_EXCEPTIONS=1" ]
+ }
+ ]
+}
diff --git a/sql/win/deps/common-sqlite.gypi b/sql/win/deps/common-sqlite.gypi
new file mode 100755
index 0000000..a04b1d5
--- /dev/null
+++ b/sql/win/deps/common-sqlite.gypi
@@ -0,0 +1,60 @@
+{
+ 'variables': {
+ 'sqlite_version%':'3440200',
+ "toolset%":'',
+ },
+ 'target_defaults': {
+ 'default_configuration': 'Release',
+ 'conditions': [
+ [ 'toolset!=""', {
+ 'msbuild_toolset':'<(toolset)'
+ }]
+ ],
+ 'configurations': {
+ 'Debug': {
+ 'defines!': [
+ 'NDEBUG'
+ ],
+ 'cflags_cc!': [
+ '-O3',
+ '-Os',
+ '-DNDEBUG'
+ ],
+ 'xcode_settings': {
+ 'OTHER_CPLUSPLUSFLAGS!': [
+ '-O3',
+ '-Os',
+ '-DDEBUG'
+ ],
+ 'GCC_OPTIMIZATION_LEVEL': '0',
+ 'GCC_GENERATE_DEBUGGING_SYMBOLS': 'YES'
+ },
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'ExceptionHandling': 1, # /EHsc
+ }
+ }
+ },
+ 'Release': {
+ 'defines': [
+ 'NDEBUG'
+ ],
+ 'xcode_settings': {
+ 'OTHER_CPLUSPLUSFLAGS!': [
+ '-Os',
+ '-O2'
+ ],
+ 'GCC_OPTIMIZATION_LEVEL': '3',
+ 'GCC_GENERATE_DEBUGGING_SYMBOLS': 'NO',
+ 'DEAD_CODE_STRIPPING': 'YES',
+ 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES'
+ },
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'ExceptionHandling': 1, # /EHsc
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/sql/win/deps/extract.js b/sql/win/deps/extract.js
new file mode 100755
index 0000000..46aed47
--- /dev/null
+++ b/sql/win/deps/extract.js
@@ -0,0 +1,10 @@
+const tar = require("tar");
+const path = require("path");
+const tarball = path.resolve(process.argv[2]);
+const dirname = path.resolve(process.argv[3]);
+
+tar.extract({
+ sync: true,
+ file: tarball,
+ cwd: dirname,
+});
diff --git a/sql/win/deps/sqlite3.gyp b/sql/win/deps/sqlite3.gyp
new file mode 100755
index 0000000..660b3b0
--- /dev/null
+++ b/sql/win/deps/sqlite3.gyp
@@ -0,0 +1,121 @@
+{
+ 'includes': [ 'common-sqlite.gypi' ],
+
+ 'variables': {
+ 'sqlite_magic%': '',
+ },
+
+ 'target_defaults': {
+ 'default_configuration': 'Release',
+ 'cflags':[
+ '-std=c99'
+ ],
+ 'configurations': {
+ 'Debug': {
+ 'defines': [ 'DEBUG', '_DEBUG' ],
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'RuntimeLibrary': 1, # static debug
+ },
+ },
+ },
+ 'Release': {
+ 'defines': [ 'NDEBUG' ],
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ 'RuntimeLibrary': 0, # static release
+ },
+ },
+ }
+ },
+ 'msvs_settings': {
+ 'VCCLCompilerTool': {
+ },
+ 'VCLibrarianTool': {
+ },
+ 'VCLinkerTool': {
+ 'GenerateDebugInformation': 'true',
+ },
+ },
+ 'conditions': [
+ ['OS == "win"', {
+ 'defines': [
+ 'WIN32'
+ ],
+ }]
+ ],
+ },
+
+ 'targets': [
+ {
+ 'target_name': 'action_before_build',
+ 'type': 'none',
+ 'hard_dependency': 1,
+ 'actions': [
+ {
+ 'action_name': 'unpack_sqlite_dep',
+ 'inputs': [
+ './sqlite-autoconf-<@(sqlite_version).tar.gz'
+ ],
+ 'outputs': [
+ '<(SHARED_INTERMEDIATE_DIR)/sqlite-autoconf-<@(sqlite_version)/sqlite3.c'
+ ],
+ 'action': ['node','./extract.js','./sqlite-autoconf-<@(sqlite_version).tar.gz','<(SHARED_INTERMEDIATE_DIR)']
+ }
+ ],
+ 'direct_dependent_settings': {
+ 'include_dirs': [
+ '<(SHARED_INTERMEDIATE_DIR)/sqlite-autoconf-<@(sqlite_version)/',
+ ]
+ },
+ },
+ {
+ 'target_name': 'sqlite3',
+ 'type': 'static_library',
+ 'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)/sqlite-autoconf-<@(sqlite_version)/' ],
+ 'dependencies': [
+ 'action_before_build'
+ ],
+ 'sources': [
+ '<(SHARED_INTERMEDIATE_DIR)/sqlite-autoconf-<@(sqlite_version)/sqlite3.c'
+ ],
+ 'direct_dependent_settings': {
+ 'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)/sqlite-autoconf-<@(sqlite_version)/' ],
+ 'defines': [
+ 'SQLITE_THREADSAFE=1',
+ 'HAVE_USLEEP=1',
+ 'SQLITE_ENABLE_FTS3',
+ 'SQLITE_ENABLE_FTS4',
+ 'SQLITE_ENABLE_FTS5',
+ 'SQLITE_ENABLE_RTREE',
+ 'SQLITE_ENABLE_DBSTAT_VTAB=1',
+ 'SQLITE_ENABLE_MATH_FUNCTIONS'
+ ],
+ },
+ 'cflags_cc': [
+ '-Wno-unused-value'
+ ],
+ 'defines': [
+ '_REENTRANT=1',
+ 'SQLITE_THREADSAFE=1',
+ 'HAVE_USLEEP=1',
+ 'SQLITE_ENABLE_FTS3',
+ 'SQLITE_ENABLE_FTS4',
+ 'SQLITE_ENABLE_FTS5',
+ 'SQLITE_ENABLE_RTREE',
+ 'SQLITE_ENABLE_DBSTAT_VTAB=1',
+ 'SQLITE_ENABLE_MATH_FUNCTIONS'
+ ],
+ 'export_dependent_settings': [
+ 'action_before_build',
+ ],
+ 'conditions': [
+ ["sqlite_magic != ''", {
+ 'defines': [
+ 'SQLITE_FILE_HEADER="<(sqlite_magic)"'
+ ]
+ }]
+ ],
+ }
+ ]
+}
diff --git a/sql/win/lib/sqlite3-binding.js b/sql/win/lib/sqlite3-binding.js
new file mode 100755
index 0000000..98d1b91
--- /dev/null
+++ b/sql/win/lib/sqlite3-binding.js
@@ -0,0 +1 @@
+module.exports = require('bindings')('node_sqlite3.node');
diff --git a/sql/win/lib/sqlite3.d.ts b/sql/win/lib/sqlite3.d.ts
new file mode 100755
index 0000000..15e6623
--- /dev/null
+++ b/sql/win/lib/sqlite3.d.ts
@@ -0,0 +1,205 @@
+// Type definitions for sqlite3
+// Project: http://github.com/tryghost/node-sqlite3
+
+/// <reference types="node" />
+
+import events = require("events");
+
+export const OPEN_READONLY: number;
+export const OPEN_READWRITE: number;
+export const OPEN_CREATE: number;
+export const OPEN_FULLMUTEX: number;
+export const OPEN_SHAREDCACHE: number;
+export const OPEN_PRIVATECACHE: number;
+export const OPEN_URI: number;
+
+export const VERSION: string;
+export const SOURCE_ID: string;
+export const VERSION_NUMBER: number;
+
+export const OK: number;
+export const ERROR: number;
+export const INTERNAL: number;
+export const PERM: number;
+export const ABORT: number;
+export const BUSY: number;
+export const LOCKED: number;
+export const NOMEM: number;
+export const READONLY: number;
+export const INTERRUPT: number
+export const IOERR: number;
+export const CORRUPT: number
+export const NOTFOUND: number;
+export const FULL: number;
+export const CANTOPEN: number;
+export const PROTOCOL: number;
+export const EMPTY: number;
+export const SCHEMA: number;
+export const TOOBIG: number
+export const CONSTRAINT: number
+export const MISMATCH: number;
+export const MISUSE: number;
+export const NOLFS: number;
+export const AUTH: number
+export const FORMAT: number;
+export const RANGE: number
+export const NOTADB: number;
+
+export const LIMIT_LENGTH: number;
+export const LIMIT_SQL_LENGTH: number;
+export const LIMIT_COLUMN: number;
+export const LIMIT_EXPR_DEPTH: number;
+export const LIMIT_COMPOUND_SELECT: number;
+export const LIMIT_VDBE_OP: number;
+export const LIMIT_FUNCTION_ARG: number;
+export const LIMIT_ATTACHED: number;
+export const LIMIT_LIKE_PATTERN_LENGTH: number;
+export const LIMIT_VARIABLE_NUMBER: number;
+export const LIMIT_TRIGGER_DEPTH: number;
+export const LIMIT_WORKER_THREADS: number;
+
+export const cached: {
+ Database(filename: string, callback?: (this: Database, err: Error | null) => void): Database;
+ Database(filename: string, mode?: number, callback?: (this: Database, err: Error | null) => void): Database;
+};
+
+export interface RunResult extends Statement {
+ lastID: number;
+ changes: number;
+}
+
+export class Statement extends events.EventEmitter {
+ bind(callback?: (err: Error | null) => void): this;
+ bind(...params: any[]): this;
+
+ reset(callback?: (err: null) => void): this;
+
+ finalize(callback?: (err: Error) => void): Database;
+
+ run(callback?: (err: Error | null) => void): this;
+ run(params: any, callback?: (this: RunResult, err: Error | null) => void): this;
+ run(...params: any[]): this;
+
+ get<T>(callback?: (err: Error | null, row?: T) => void): this;
+ get<T>(params: any, callback?: (this: RunResult, err: Error | null, row?: T) => void): this;
+ get(...params: any[]): this;
+
+ all<T>(callback?: (err: Error | null, rows: T[]) => void): this;
+ all<T>(params: any, callback?: (this: RunResult, err: Error | null, rows: T[]) => void): this;
+ all(...params: any[]): this;
+
+ each<T>(callback?: (err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this;
+ each<T>(params: any, callback?: (this: RunResult, err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this;
+ each(...params: any[]): this;
+}
+
+export class Database extends events.EventEmitter {
+ constructor(filename: string, callback?: (err: Error | null) => void);
+ constructor(filename: string, mode?: number, callback?: (err: Error | null) => void);
+
+ close(callback?: (err: Error | null) => void): void;
+
+ run(sql: string, callback?: (this: RunResult, err: Error | null) => void): this;
+ run(sql: string, params: any, callback?: (this: RunResult, err: Error | null) => void): this;
+ run(sql: string, ...params: any[]): this;
+
+ get<T>(sql: string, callback?: (this: Statement, err: Error | null, row: T) => void): this;
+ get<T>(sql: string, params: any, callback?: (this: Statement, err: Error | null, row: T) => void): this;
+ get(sql: string, ...params: any[]): this;
+
+ all<T>(sql: string, callback?: (this: Statement, err: Error | null, rows: T[]) => void): this;
+ all<T>(sql: string, params: any, callback?: (this: Statement, err: Error | null, rows: T[]) => void): this;
+ all(sql: string, ...params: any[]): this;
+
+ each<T>(sql: string, callback?: (this: Statement, err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this;
+ each<T>(sql: string, params: any, callback?: (this: Statement, err: Error | null, row: T) => void, complete?: (err: Error | null, count: number) => void): this;
+ each(sql: string, ...params: any[]): this;
+
+ exec(sql: string, callback?: (this: Statement, err: Error | null) => void): this;
+
+ prepare(sql: string, callback?: (this: Statement, err: Error | null) => void): Statement;
+ prepare(sql: string, params: any, callback?: (this: Statement, err: Error | null) => void): Statement;
+ prepare(sql: string, ...params: any[]): Statement;
+
+ serialize(callback?: () => void): void;
+ parallelize(callback?: () => void): void;
+
+ on(event: "trace", listener: (sql: string) => void): this;
+ on(event: "profile", listener: (sql: string, time: number) => void): this;
+ on(event: "change", listener: (type: string, database: string, table: string, rowid: number) => void): this;
+ on(event: "error", listener: (err: Error) => void): this;
+ on(event: "open" | "close", listener: () => void): this;
+ on(event: string, listener: (...args: any[]) => void): this;
+
+ configure(option: "busyTimeout", value: number): void;
+ configure(option: "limit", id: number, value: number): void;
+
+ loadExtension(filename: string, callback?: (err: Error | null) => void): this;
+
+ wait(callback?: (param: null) => void): this;
+
+ interrupt(): void;
+}
+
+export function verbose(): sqlite3;
+
+export interface sqlite3 {
+ OPEN_READONLY: number;
+ OPEN_READWRITE: number;
+ OPEN_CREATE: number;
+ OPEN_FULLMUTEX: number;
+ OPEN_SHAREDCACHE: number;
+ OPEN_PRIVATECACHE: number;
+ OPEN_URI: number;
+
+ VERSION: string;
+ SOURCE_ID: string;
+ VERSION_NUMBER: number;
+
+ OK: number;
+ ERROR: number;
+ INTERNAL: number;
+ PERM: number;
+ ABORT: number;
+ BUSY: number;
+ LOCKED: number;
+ NOMEM: number;
+ READONLY: number;
+ INTERRUPT: number
+ IOERR: number;
+ CORRUPT: number
+ NOTFOUND: number;
+ FULL: number;
+ CANTOPEN: number;
+ PROTOCOL: number;
+ EMPTY: number;
+ SCHEMA: number;
+ TOOBIG: number
+ CONSTRAINT: number
+ MISMATCH: number;
+ MISUSE: number;
+ NOLFS: number;
+ AUTH: number
+ FORMAT: number;
+ RANGE: number
+ NOTADB: number;
+
+ LIMIT_LENGTH: number;
+ LIMIT_SQL_LENGTH: number;
+ LIMIT_COLUMN: number;
+ LIMIT_EXPR_DEPTH: number;
+ LIMIT_COMPOUND_SELECT: number;
+ LIMIT_VDBE_OP: number;
+ LIMIT_FUNCTION_ARG: number;
+ LIMIT_ATTACHED: number;
+ LIMIT_LIKE_PATTERN_LENGTH: number;
+ LIMIT_VARIABLE_NUMBER: number;
+ LIMIT_TRIGGER_DEPTH: number;
+ LIMIT_WORKER_THREADS: number;
+
+ cached: typeof cached;
+ RunResult: RunResult;
+ Statement: typeof Statement;
+ Database: typeof Database;
+ verbose(): this;
+} \ No newline at end of file
diff --git a/sql/win/lib/sqlite3.js b/sql/win/lib/sqlite3.js
new file mode 100755
index 0000000..430a2b8
--- /dev/null
+++ b/sql/win/lib/sqlite3.js
@@ -0,0 +1,207 @@
+const path = require('path');
+const sqlite3 = require('./sqlite3-binding.js');
+const EventEmitter = require('events').EventEmitter;
+module.exports = exports = sqlite3;
+
+function normalizeMethod (fn) {
+ return function (sql) {
+ let errBack;
+ const args = Array.prototype.slice.call(arguments, 1);
+
+ if (typeof args[args.length - 1] === 'function') {
+ const callback = args[args.length - 1];
+ errBack = function(err) {
+ if (err) {
+ callback(err);
+ }
+ };
+ }
+ const statement = new Statement(this, sql, errBack);
+ return fn.call(this, statement, args);
+ };
+}
+
+function inherits(target, source) {
+ for (const k in source.prototype)
+ target.prototype[k] = source.prototype[k];
+}
+
+sqlite3.cached = {
+ Database: function(file, a, b) {
+ if (file === '' || file === ':memory:') {
+ // Don't cache special databases.
+ return new Database(file, a, b);
+ }
+
+ let db;
+ file = path.resolve(file);
+
+ if (!sqlite3.cached.objects[file]) {
+ db = sqlite3.cached.objects[file] = new Database(file, a, b);
+ }
+ else {
+ // Make sure the callback is called.
+ db = sqlite3.cached.objects[file];
+ const callback = (typeof a === 'number') ? b : a;
+ if (typeof callback === 'function') {
+ function cb() { callback.call(db, null); }
+ if (db.open) process.nextTick(cb);
+ else db.once('open', cb);
+ }
+ }
+
+ return db;
+ },
+ objects: {}
+};
+
+
+const Database = sqlite3.Database;
+const Statement = sqlite3.Statement;
+const Backup = sqlite3.Backup;
+
+inherits(Database, EventEmitter);
+inherits(Statement, EventEmitter);
+inherits(Backup, EventEmitter);
+
+// Database#prepare(sql, [bind1, bind2, ...], [callback])
+Database.prototype.prepare = normalizeMethod(function(statement, params) {
+ return params.length
+ ? statement.bind.apply(statement, params)
+ : statement;
+});
+
+// Database#run(sql, [bind1, bind2, ...], [callback])
+Database.prototype.run = normalizeMethod(function(statement, params) {
+ statement.run.apply(statement, params).finalize();
+ return this;
+});
+
+// Database#get(sql, [bind1, bind2, ...], [callback])
+Database.prototype.get = normalizeMethod(function(statement, params) {
+ statement.get.apply(statement, params).finalize();
+ return this;
+});
+
+// Database#all(sql, [bind1, bind2, ...], [callback])
+Database.prototype.all = normalizeMethod(function(statement, params) {
+ statement.all.apply(statement, params).finalize();
+ return this;
+});
+
+// Database#each(sql, [bind1, bind2, ...], [callback], [complete])
+Database.prototype.each = normalizeMethod(function(statement, params) {
+ statement.each.apply(statement, params).finalize();
+ return this;
+});
+
+Database.prototype.map = normalizeMethod(function(statement, params) {
+ statement.map.apply(statement, params).finalize();
+ return this;
+});
+
+// Database#backup(filename, [callback])
+// Database#backup(filename, destName, sourceName, filenameIsDest, [callback])
+Database.prototype.backup = function() {
+ let backup;
+ if (arguments.length <= 2) {
+ // By default, we write the main database out to the main database of the named file.
+ // This is the most likely use of the backup api.
+ backup = new Backup(this, arguments[0], 'main', 'main', true, arguments[1]);
+ } else {
+ // Otherwise, give the user full control over the sqlite3_backup_init arguments.
+ backup = new Backup(this, arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]);
+ }
+ // Per the sqlite docs, exclude the following errors as non-fatal by default.
+ backup.retryErrors = [sqlite3.BUSY, sqlite3.LOCKED];
+ return backup;
+};
+
+Statement.prototype.map = function() {
+ const params = Array.prototype.slice.call(arguments);
+ const callback = params.pop();
+ params.push(function(err, rows) {
+ if (err) return callback(err);
+ const result = {};
+ if (rows.length) {
+ const keys = Object.keys(rows[0]);
+ const key = keys[0];
+ if (keys.length > 2) {
+ // Value is an object
+ for (let i = 0; i < rows.length; i++) {
+ result[rows[i][key]] = rows[i];
+ }
+ } else {
+ const value = keys[1];
+ // Value is a plain value
+ for (let i = 0; i < rows.length; i++) {
+ result[rows[i][key]] = rows[i][value];
+ }
+ }
+ }
+ callback(err, result);
+ });
+ return this.all.apply(this, params);
+};
+
+let isVerbose = false;
+
+const supportedEvents = [ 'trace', 'profile', 'change' ];
+
+Database.prototype.addListener = Database.prototype.on = function(type) {
+ const val = EventEmitter.prototype.addListener.apply(this, arguments);
+ if (supportedEvents.indexOf(type) >= 0) {
+ this.configure(type, true);
+ }
+ return val;
+};
+
+Database.prototype.removeListener = function(type) {
+ const val = EventEmitter.prototype.removeListener.apply(this, arguments);
+ if (supportedEvents.indexOf(type) >= 0 && !this._events[type]) {
+ this.configure(type, false);
+ }
+ return val;
+};
+
+Database.prototype.removeAllListeners = function(type) {
+ const val = EventEmitter.prototype.removeAllListeners.apply(this, arguments);
+ if (supportedEvents.indexOf(type) >= 0) {
+ this.configure(type, false);
+ }
+ return val;
+};
+
+// Save the stack trace over EIO callbacks.
+sqlite3.verbose = function() {
+ if (!isVerbose) {
+ const trace = require('./trace');
+ [
+ 'prepare',
+ 'get',
+ 'run',
+ 'all',
+ 'each',
+ 'map',
+ 'close',
+ 'exec'
+ ].forEach(function (name) {
+ trace.extendTrace(Database.prototype, name);
+ });
+ [
+ 'bind',
+ 'get',
+ 'run',
+ 'all',
+ 'each',
+ 'map',
+ 'reset',
+ 'finalize',
+ ].forEach(function (name) {
+ trace.extendTrace(Statement.prototype, name);
+ });
+ isVerbose = true;
+ }
+
+ return sqlite3;
+};
diff --git a/sql/win/lib/trace.js b/sql/win/lib/trace.js
new file mode 100755
index 0000000..1d84cb0
--- /dev/null
+++ b/sql/win/lib/trace.js
@@ -0,0 +1,38 @@
+// Inspired by https://github.com/tlrobinson/long-stack-traces
+const util = require('util');
+
+function extendTrace(object, property, pos) {
+ const old = object[property];
+ object[property] = function() {
+ const error = new Error();
+ const name = object.constructor.name + '#' + property + '(' +
+ Array.prototype.slice.call(arguments).map(function(el) {
+ return util.inspect(el, false, 0);
+ }).join(', ') + ')';
+
+ if (typeof pos === 'undefined') pos = -1;
+ if (pos < 0) pos += arguments.length;
+ const cb = arguments[pos];
+ if (typeof arguments[pos] === 'function') {
+ arguments[pos] = function replacement() {
+ const err = arguments[0];
+ if (err && err.stack && !err.__augmented) {
+ err.stack = filter(err).join('\n');
+ err.stack += '\n--> in ' + name;
+ err.stack += '\n' + filter(error).slice(1).join('\n');
+ err.__augmented = true;
+ }
+ return cb.apply(this, arguments);
+ };
+ }
+ return old.apply(this, arguments);
+ };
+}
+exports.extendTrace = extendTrace;
+
+
+function filter(error) {
+ return error.stack.split('\n').filter(function(line) {
+ return line.indexOf(__filename) < 0;
+ });
+}
diff --git a/sql/win/package.json b/sql/win/package.json
new file mode 100755
index 0000000..ab413ff
--- /dev/null
+++ b/sql/win/package.json
@@ -0,0 +1,89 @@
+{
+ "name": "sqlite3",
+ "description": "Asynchronous, non-blocking SQLite3 bindings",
+ "version": "5.1.7",
+ "homepage": "https://github.com/TryGhost/node-sqlite3",
+ "author": {
+ "name": "Mapbox",
+ "url": "https://mapbox.com/"
+ },
+ "binary": {
+ "napi_versions": [
+ 3,
+ 6
+ ]
+ },
+ "contributors": [
+ "Daniel Lockyer <hi@daniellockyer.com>",
+ "Konstantin Käfer <mail@kkaefer.com>",
+ "Dane Springmeyer <dane@mapbox.com>",
+ "Will White <will@mapbox.com>",
+ "Orlando Vazquez <ovazquez@gmail.com>",
+ "Artem Kustikov <kustikoff@gmail.com>",
+ "Eric Fredricksen <efredricksen@gmail.com>",
+ "John Wright <mrjjwright@gmail.com>",
+ "Ryan Dahl <ry@tinyclouds.org>",
+ "Tom MacWright <tom@mapbox.com>",
+ "Carter Thaxton <carter.thaxton@gmail.com>",
+ "Audrius Kažukauskas <audrius@neutrino.lt>",
+ "Johannes Schauer <josch@pyneo.org>",
+ "Nathan Rajlich <nathan@tootallnate.net>",
+ "AJ ONeal <coolaj86@gmail.com>",
+ "Mithgol",
+ "Ben Noordhuis <ben@strongloop.com>"
+ ],
+ "files": [
+ "binding.gyp",
+ "deps/",
+ "lib/*.js",
+ "lib/*.d.ts",
+ "src/"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/TryGhost/node-sqlite3.git"
+ },
+ "dependencies": {
+ "bindings": "^1.5.0",
+ "node-addon-api": "^7.0.0",
+ "prebuild-install": "^7.1.1",
+ "tar": "^6.1.11"
+ },
+ "devDependencies": {
+ "eslint": "8.56.0",
+ "mocha": "10.2.0",
+ "prebuild": "12.1.0"
+ },
+ "peerDependencies": {
+ "node-gyp": "8.x"
+ },
+ "peerDependenciesMeta": {
+ "node-gyp": {
+ "optional": true
+ }
+ },
+ "optionalDependencies": {
+ "node-gyp": "8.x"
+ },
+ "scripts": {
+ "install": "prebuild-install -r napi || node-gyp rebuild",
+ "prebuild": "prebuild --runtime napi --all --verbose",
+ "rebuild": "node-gyp rebuild",
+ "upload": "prebuild --verbose --prerelease",
+ "test": "node test/support/createdb.js && mocha -R spec --timeout 480000"
+ },
+ "license": "BSD-3-Clause",
+ "keywords": [
+ "sql",
+ "sqlite",
+ "sqlite3",
+ "database"
+ ],
+ "main": "./lib/sqlite3",
+ "types": "./lib/sqlite3.d.ts",
+ "renovate": {
+ "extends": [
+ "@tryghost:base"
+ ]
+ }
+}