✅ Complete Astro migration - PDPA compliant website
- Migrated all pages from Next.js to Astro - Added PDPA-compliant Privacy Policy (Thai) - Added PDPA-compliant Terms & Conditions (Thai) - Added Cookie Policy with disclosure (Thai) - Implemented cookie consent banner (client-side) - Integrated Umami Analytics placeholder - Blog system with 3 posts - Optimized Docker configuration for production - Static site build (184KB, 11 pages) - Ready for Easypanel deployment Backup: /Users/kunthawatgreethong/Gitea/dealplustech-backup-nextjs-20260309.tar.gz
This commit is contained in:
22
dealplustech-astro/node_modules/libsql/LICENSE
generated
vendored
Normal file
22
dealplustech-astro/node_modules/libsql/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Joshua Wise
|
||||
Copyright (c) 2023 Pekka Enberg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
164
dealplustech-astro/node_modules/libsql/README.md
generated
vendored
Normal file
164
dealplustech-astro/node_modules/libsql/README.md
generated
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
# libSQL API for JavaScript/TypeScript
|
||||
|
||||
[](https://badge.fury.io/js/libsql)
|
||||
[](https://www.phorm.ai/query?projectId=3c9a471f-4a47-469f-81f6-4ea1ff9ab418)
|
||||
|
||||
[libSQL](https://github.com/libsql/libsql) is an open source, open contribution fork of SQLite.
|
||||
This source repository contains libSQL API bindings for Node, which aims to be compatible with [better-sqlite3](https://github.com/WiseLibs/better-sqlite3/), but with opt-in promise API.
|
||||
|
||||
*Please note that there is also the [libSQL SDK](https://github.com/libsql/libsql-client-ts), which is useful if you don't need `better-sqlite3` compatibility or use libSQL in environments like serverless functions that require `fetch()`-based database access protocol.*
|
||||
|
||||
## Features
|
||||
|
||||
* In-memory and local libSQL/SQLite databases
|
||||
* Remote libSQL databases
|
||||
* Embedded, in-app replica that syncs with a remote libSQL database
|
||||
* Supports Bun, Deno, and Node on macOS, Linux, and Windows.
|
||||
|
||||
## Installing
|
||||
|
||||
You can install the package with:
|
||||
|
||||
**Node:**
|
||||
|
||||
```sh
|
||||
npm i libsql
|
||||
```
|
||||
|
||||
**Bun:**
|
||||
|
||||
```sh
|
||||
bun add libsql
|
||||
```
|
||||
|
||||
**Deno:**
|
||||
|
||||
Use the `npm:` prefix for package import:
|
||||
|
||||
```typescript
|
||||
import Database from 'npm:libsql';
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
* [API reference](docs/api.md)
|
||||
|
||||
## Getting Started
|
||||
|
||||
To try out your first libsql program, type the following in `hello.js`:
|
||||
|
||||
```javascript
|
||||
import Database from 'libsql';
|
||||
|
||||
const db = new Database(':memory:');
|
||||
|
||||
db.exec("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)");
|
||||
db.exec("INSERT INTO users (id, name, email) VALUES (1, 'Alice', 'alice@example.org')");
|
||||
|
||||
const row = db.prepare("SELECT * FROM users WHERE id = ?").get(1);
|
||||
|
||||
console.log(`Name: ${row.name}, email: ${row.email}`);
|
||||
```
|
||||
|
||||
and then run:
|
||||
|
||||
```shell
|
||||
$ node hello.js
|
||||
```
|
||||
|
||||
To use the promise API, import `libsql/promise`:
|
||||
|
||||
```javascript
|
||||
import Database from 'libsql/promise';
|
||||
|
||||
const db = new Database(':memory:');
|
||||
|
||||
await db.exec("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)");
|
||||
await db.exec("INSERT INTO users (id, name, email) VALUES (1, 'Alice', 'alice@example.org')");
|
||||
|
||||
const stmt = await db.prepare("SELECT * FROM users WHERE id = ?");
|
||||
const row = stmt.get(1);
|
||||
|
||||
console.log(`Name: ${row.name}, email: ${row.email}`);
|
||||
```
|
||||
|
||||
#### Connecting to a local database file
|
||||
|
||||
```javascript
|
||||
import Database from 'libsql';
|
||||
|
||||
const db = new Database('hello.db');
|
||||
````
|
||||
|
||||
#### Connecting to a Remote libSQL server
|
||||
|
||||
```javascript
|
||||
import Database from 'libsql';
|
||||
|
||||
const url = process.env.LIBSQL_URL;
|
||||
const authToken = process.env.LIBSQL_AUTH_TOKEN;
|
||||
|
||||
const opts = {
|
||||
authToken: authToken,
|
||||
};
|
||||
|
||||
const db = new Database(url, opts);
|
||||
```
|
||||
|
||||
#### Creating an in-app replica and syncing it
|
||||
|
||||
```javascript
|
||||
import libsql
|
||||
|
||||
const opts = { syncUrl: "<url>", authToken: "<optional auth token>" };
|
||||
const db = new Database('hello.db', opts);
|
||||
db.sync();
|
||||
```
|
||||
|
||||
#### Creating a table
|
||||
|
||||
```javascript
|
||||
db.exec("CREATE TABLE users (id INTEGER, email TEXT);")
|
||||
```
|
||||
|
||||
#### Inserting rows into a table
|
||||
|
||||
```javascript
|
||||
db.exec("INSERT INTO users VALUES (1, 'alice@example.org')")
|
||||
```
|
||||
|
||||
#### Querying rows from a table
|
||||
|
||||
```javascript
|
||||
const row = db.prepare("SELECT * FROM users WHERE id = ?").get(1);
|
||||
```
|
||||
|
||||
## Developing
|
||||
|
||||
To build the `libsql` package, run:
|
||||
|
||||
```console
|
||||
LIBSQL_JS_DEV=1 npm run build
|
||||
```
|
||||
|
||||
You can then run the integration tests with:
|
||||
|
||||
```console
|
||||
export LIBSQL_JS_DEV=1
|
||||
npm link
|
||||
cd integration-tests
|
||||
npm link libsql
|
||||
npm test
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the [MIT license].
|
||||
|
||||
### Contribution
|
||||
|
||||
Unless you explicitly state otherwise, any contribution intentionally submitted
|
||||
for inclusion in libSQL by you, shall be licensed as MIT, without any additional
|
||||
terms or conditions.
|
||||
|
||||
[MIT license]: https://github.com/libsql/libsql-node/blob/main/LICENSE
|
||||
22
dealplustech-astro/node_modules/libsql/auth.js
generated
vendored
Normal file
22
dealplustech-astro/node_modules/libsql/auth.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Authorization outcome.
|
||||
*
|
||||
* @readonly
|
||||
* @enum {number}
|
||||
* @property {number} ALLOW - Allow access to a resource.
|
||||
* @property {number} DENY - Deny access to a resource and throw an error.
|
||||
*/
|
||||
const Authorization = {
|
||||
/**
|
||||
* Allow access to a resource.
|
||||
* @type {number}
|
||||
*/
|
||||
ALLOW: 0,
|
||||
|
||||
/**
|
||||
* Deny access to a resource and throw an error in `prepare()`.
|
||||
* @type {number}
|
||||
*/
|
||||
DENY: 1,
|
||||
};
|
||||
module.exports = Authorization;
|
||||
441
dealplustech-astro/node_modules/libsql/index.js
generated
vendored
Normal file
441
dealplustech-astro/node_modules/libsql/index.js
generated
vendored
Normal file
@@ -0,0 +1,441 @@
|
||||
"use strict";
|
||||
|
||||
const { load, currentTarget } = require("@neon-rs/load");
|
||||
const { familySync, GLIBC, MUSL } = require("detect-libc");
|
||||
|
||||
function requireNative() {
|
||||
if (process.env.LIBSQL_JS_DEV) {
|
||||
return load(__dirname)
|
||||
}
|
||||
let target = currentTarget();
|
||||
// Workaround for Bun, which reports a musl target, but really wants glibc...
|
||||
if (familySync() == GLIBC) {
|
||||
switch (target) {
|
||||
case "linux-x64-musl":
|
||||
target = "linux-x64-gnu";
|
||||
break;
|
||||
case "linux-arm64-musl":
|
||||
target = "linux-arm64-gnu";
|
||||
break;
|
||||
}
|
||||
}
|
||||
// @neon-rs/load doesn't detect arm musl
|
||||
if (target === "linux-arm-gnueabihf" && familySync() == MUSL) {
|
||||
target = "linux-arm-musleabihf";
|
||||
}
|
||||
return require(`@libsql/${target}`);
|
||||
}
|
||||
|
||||
const {
|
||||
databaseOpen,
|
||||
databaseOpenWithSync,
|
||||
databaseInTransaction,
|
||||
databaseInterrupt,
|
||||
databaseClose,
|
||||
databaseSyncSync,
|
||||
databaseSyncUntilSync,
|
||||
databaseExecSync,
|
||||
databasePrepareSync,
|
||||
databaseDefaultSafeIntegers,
|
||||
databaseAuthorizer,
|
||||
databaseLoadExtension,
|
||||
databaseMaxWriteReplicationIndex,
|
||||
statementRaw,
|
||||
statementIsReader,
|
||||
statementGet,
|
||||
statementRun,
|
||||
statementInterrupt,
|
||||
statementRowsSync,
|
||||
statementColumns,
|
||||
statementSafeIntegers,
|
||||
rowsNext,
|
||||
} = requireNative();
|
||||
|
||||
const Authorization = require("./auth");
|
||||
const SqliteError = require("./sqlite-error");
|
||||
|
||||
function convertError(err) {
|
||||
if (err.libsqlError) {
|
||||
return new SqliteError(err.message, err.code, err.rawCode);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* Database represents a connection that can prepare and execute SQL statements.
|
||||
*/
|
||||
class Database {
|
||||
/**
|
||||
* Creates a new database connection. If the database file pointed to by `path` does not exists, it will be created.
|
||||
*
|
||||
* @constructor
|
||||
* @param {string} path - Path to the database file.
|
||||
*/
|
||||
constructor(path, opts) {
|
||||
const encryptionCipher = opts?.encryptionCipher ?? "aes256cbc";
|
||||
if (opts && opts.syncUrl) {
|
||||
var authToken = "";
|
||||
if (opts.syncAuth) {
|
||||
console.warn("Warning: The `syncAuth` option is deprecated, please use `authToken` option instead.");
|
||||
authToken = opts.syncAuth;
|
||||
} else if (opts.authToken) {
|
||||
authToken = opts.authToken;
|
||||
}
|
||||
const encryptionKey = opts?.encryptionKey ?? "";
|
||||
const syncPeriod = opts?.syncPeriod ?? 0.0;
|
||||
const readYourWrites = opts?.readYourWrites ?? true;
|
||||
const offline = opts?.offline ?? false;
|
||||
const remoteEncryptionKey = opts?.remoteEncryptionKey ?? "";
|
||||
this.db = databaseOpenWithSync(path, opts.syncUrl, authToken, encryptionCipher, encryptionKey, syncPeriod, readYourWrites, offline, remoteEncryptionKey);
|
||||
} else {
|
||||
const authToken = opts?.authToken ?? "";
|
||||
const encryptionKey = opts?.encryptionKey ?? "";
|
||||
const timeout = opts?.timeout ?? 0.0;
|
||||
const remoteEncryptionKey = opts?.remoteEncryptionKey ?? "";
|
||||
this.db = databaseOpen(path, authToken, encryptionCipher, encryptionKey, timeout, remoteEncryptionKey);
|
||||
}
|
||||
// TODO: Use a libSQL API for this?
|
||||
this.memory = path === ":memory:";
|
||||
this.readonly = false;
|
||||
this.name = "";
|
||||
this.open = true;
|
||||
|
||||
const db = this.db;
|
||||
Object.defineProperties(this, {
|
||||
inTransaction: {
|
||||
get() {
|
||||
return databaseInTransaction(db);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
sync() {
|
||||
return databaseSyncSync.call(this.db);
|
||||
}
|
||||
|
||||
syncUntil(replicationIndex) {
|
||||
return databaseSyncUntilSync.call(this.db, replicationIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a SQL statement for execution.
|
||||
*
|
||||
* @param {string} sql - The SQL statement string to prepare.
|
||||
*/
|
||||
prepare(sql) {
|
||||
try {
|
||||
const stmt = databasePrepareSync.call(this.db, sql);
|
||||
return new Statement(stmt);
|
||||
} catch (err) {
|
||||
throw convertError(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a function that executes the given function in a transaction.
|
||||
*
|
||||
* @param {function} fn - The function to wrap in a transaction.
|
||||
*/
|
||||
transaction(fn) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError("Expected first argument to be a function");
|
||||
|
||||
const db = this;
|
||||
const wrapTxn = (mode) => {
|
||||
return (...bindParameters) => {
|
||||
db.exec("BEGIN " + mode);
|
||||
try {
|
||||
const result = fn(...bindParameters);
|
||||
db.exec("COMMIT");
|
||||
return result;
|
||||
} catch (err) {
|
||||
db.exec("ROLLBACK");
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
};
|
||||
const properties = {
|
||||
default: { value: wrapTxn("") },
|
||||
deferred: { value: wrapTxn("DEFERRED") },
|
||||
immediate: { value: wrapTxn("IMMEDIATE") },
|
||||
exclusive: { value: wrapTxn("EXCLUSIVE") },
|
||||
database: { value: this, enumerable: true },
|
||||
};
|
||||
Object.defineProperties(properties.default.value, properties);
|
||||
Object.defineProperties(properties.deferred.value, properties);
|
||||
Object.defineProperties(properties.immediate.value, properties);
|
||||
Object.defineProperties(properties.exclusive.value, properties);
|
||||
return properties.default.value;
|
||||
}
|
||||
|
||||
pragma(source, options) {
|
||||
if (options == null) options = {};
|
||||
if (typeof source !== 'string') throw new TypeError('Expected first argument to be a string');
|
||||
if (typeof options !== 'object') throw new TypeError('Expected second argument to be an options object');
|
||||
const simple = options['simple'];
|
||||
const stmt = this.prepare(`PRAGMA ${source}`, this, true);
|
||||
return simple ? stmt.pluck().get() : stmt.all();
|
||||
}
|
||||
|
||||
backup(filename, options) {
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
serialize(options) {
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
function(name, options, fn) {
|
||||
// Apply defaults
|
||||
if (options == null) options = {};
|
||||
if (typeof options === "function") {
|
||||
fn = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
// Validate arguments
|
||||
if (typeof name !== "string")
|
||||
throw new TypeError("Expected first argument to be a string");
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError("Expected last argument to be a function");
|
||||
if (typeof options !== "object")
|
||||
throw new TypeError("Expected second argument to be an options object");
|
||||
if (!name)
|
||||
throw new TypeError(
|
||||
"User-defined function name cannot be an empty string"
|
||||
);
|
||||
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
aggregate(name, options) {
|
||||
// Validate arguments
|
||||
if (typeof name !== "string")
|
||||
throw new TypeError("Expected first argument to be a string");
|
||||
if (typeof options !== "object" || options === null)
|
||||
throw new TypeError("Expected second argument to be an options object");
|
||||
if (!name)
|
||||
throw new TypeError(
|
||||
"User-defined function name cannot be an empty string"
|
||||
);
|
||||
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
table(name, factory) {
|
||||
// Validate arguments
|
||||
if (typeof name !== "string")
|
||||
throw new TypeError("Expected first argument to be a string");
|
||||
if (!name)
|
||||
throw new TypeError(
|
||||
"Virtual table module name cannot be an empty string"
|
||||
);
|
||||
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
authorizer(rules) {
|
||||
databaseAuthorizer.call(this.db, rules);
|
||||
}
|
||||
|
||||
loadExtension(...args) {
|
||||
databaseLoadExtension.call(this.db, ...args);
|
||||
}
|
||||
|
||||
maxWriteReplicationIndex() {
|
||||
return databaseMaxWriteReplicationIndex.call(this.db)
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a SQL statement.
|
||||
*
|
||||
* @param {string} sql - The SQL statement string to execute.
|
||||
*/
|
||||
exec(sql) {
|
||||
try {
|
||||
databaseExecSync.call(this.db, sql);
|
||||
} catch (err) {
|
||||
throw convertError(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interrupts the database connection.
|
||||
*/
|
||||
interrupt() {
|
||||
databaseInterrupt.call(this.db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the database connection.
|
||||
*/
|
||||
close() {
|
||||
databaseClose.call(this.db);
|
||||
this.open = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle 64-bit integer support.
|
||||
*/
|
||||
defaultSafeIntegers(toggle) {
|
||||
databaseDefaultSafeIntegers.call(this.db, toggle ?? true);
|
||||
return this;
|
||||
}
|
||||
|
||||
unsafeMode(...args) {
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Statement represents a prepared SQL statement that can be executed.
|
||||
*/
|
||||
class Statement {
|
||||
constructor(stmt) {
|
||||
this.stmt = stmt;
|
||||
this.pluckMode = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle raw mode.
|
||||
*
|
||||
* @param raw Enable or disable raw mode. If you don't pass the parameter, raw mode is enabled.
|
||||
*/
|
||||
raw(raw) {
|
||||
statementRaw.call(this.stmt, raw ?? true);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle pluck mode.
|
||||
*
|
||||
* @param pluckMode Enable or disable pluck mode. If you don't pass the parameter, pluck mode is enabled.
|
||||
*/
|
||||
pluck(pluckMode) {
|
||||
this.pluckMode = pluckMode ?? true;
|
||||
return this;
|
||||
}
|
||||
|
||||
get reader() {
|
||||
return statementIsReader.call(this.stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the SQL statement and returns an info object.
|
||||
*/
|
||||
run(...bindParameters) {
|
||||
try {
|
||||
if (bindParameters.length == 1 && typeof bindParameters[0] === "object") {
|
||||
return statementRun.call(this.stmt, bindParameters[0]);
|
||||
} else {
|
||||
return statementRun.call(this.stmt, bindParameters.flat());
|
||||
}
|
||||
} catch (err) {
|
||||
throw convertError(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the SQL statement and returns the first row.
|
||||
*
|
||||
* @param bindParameters - The bind parameters for executing the statement.
|
||||
*/
|
||||
get(...bindParameters) {
|
||||
try {
|
||||
if (bindParameters.length == 1 && typeof bindParameters[0] === "object") {
|
||||
return statementGet.call(this.stmt, bindParameters[0]);
|
||||
} else {
|
||||
return statementGet.call(this.stmt, bindParameters.flat());
|
||||
}
|
||||
} catch (err) {
|
||||
throw convertError(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the SQL statement and returns an iterator to the resulting rows.
|
||||
*
|
||||
* @param bindParameters - The bind parameters for executing the statement.
|
||||
*/
|
||||
iterate(...bindParameters) {
|
||||
var rows = undefined;
|
||||
if (bindParameters.length == 1 && typeof bindParameters[0] === "object") {
|
||||
rows = statementRowsSync.call(this.stmt, bindParameters[0]);
|
||||
} else {
|
||||
rows = statementRowsSync.call(this.stmt, bindParameters.flat());
|
||||
}
|
||||
const iter = {
|
||||
nextRows: Array(100),
|
||||
nextRowIndex: 100,
|
||||
next() {
|
||||
try {
|
||||
if (this.nextRowIndex === 100) {
|
||||
rowsNext.call(rows, this.nextRows);
|
||||
this.nextRowIndex = 0;
|
||||
}
|
||||
const row = this.nextRows[this.nextRowIndex];
|
||||
this.nextRows[this.nextRowIndex] = undefined;
|
||||
if (!row) {
|
||||
return { done: true };
|
||||
}
|
||||
this.nextRowIndex++;
|
||||
return { value: row, done: false };
|
||||
} catch (err) {
|
||||
throw convertError(err);
|
||||
}
|
||||
},
|
||||
[Symbol.iterator]() {
|
||||
return this;
|
||||
},
|
||||
};
|
||||
return iter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the SQL statement and returns an array of the resulting rows.
|
||||
*
|
||||
* @param bindParameters - The bind parameters for executing the statement.
|
||||
*/
|
||||
all(...bindParameters) {
|
||||
try {
|
||||
const result = [];
|
||||
for (const row of this.iterate(...bindParameters)) {
|
||||
if (this.pluckMode) {
|
||||
result.push(row[Object.keys(row)[0]]);
|
||||
} else {
|
||||
result.push(row);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} catch (err) {
|
||||
throw convertError(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interrupts the statement.
|
||||
*/
|
||||
interrupt() {
|
||||
statementInterrupt.call(this.stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the columns in the result set returned by this prepared statement.
|
||||
*/
|
||||
columns() {
|
||||
return statementColumns.call(this.stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle 64-bit integer support.
|
||||
*/
|
||||
safeIntegers(toggle) {
|
||||
statementSafeIntegers.call(this.stmt, toggle ?? true);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Database;
|
||||
module.exports.Authorization = Authorization;
|
||||
module.exports.SqliteError = SqliteError;
|
||||
201
dealplustech-astro/node_modules/libsql/node_modules/detect-libc/LICENSE
generated
vendored
Normal file
201
dealplustech-astro/node_modules/libsql/node_modules/detect-libc/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
163
dealplustech-astro/node_modules/libsql/node_modules/detect-libc/README.md
generated
vendored
Normal file
163
dealplustech-astro/node_modules/libsql/node_modules/detect-libc/README.md
generated
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
# detect-libc
|
||||
|
||||
Node.js module to detect details of the C standard library (libc)
|
||||
implementation provided by a given Linux system.
|
||||
|
||||
Currently supports detection of GNU glibc and MUSL libc.
|
||||
|
||||
Provides asychronous and synchronous functions for the
|
||||
family (e.g. `glibc`, `musl`) and version (e.g. `1.23`, `1.2.3`).
|
||||
|
||||
The version numbers of libc implementations
|
||||
are not guaranteed to be semver-compliant.
|
||||
|
||||
For previous v1.x releases, please see the
|
||||
[v1](https://github.com/lovell/detect-libc/tree/v1) branch.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install detect-libc
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### GLIBC
|
||||
|
||||
```ts
|
||||
const GLIBC: string = 'glibc';
|
||||
```
|
||||
|
||||
A String constant containing the value `glibc`.
|
||||
|
||||
### MUSL
|
||||
|
||||
```ts
|
||||
const MUSL: string = 'musl';
|
||||
```
|
||||
|
||||
A String constant containing the value `musl`.
|
||||
|
||||
### family
|
||||
|
||||
```ts
|
||||
function family(): Promise<string | null>;
|
||||
```
|
||||
|
||||
Resolves asychronously with:
|
||||
|
||||
* `glibc` or `musl` when the libc family can be determined
|
||||
* `null` when the libc family cannot be determined
|
||||
* `null` when run on a non-Linux platform
|
||||
|
||||
```js
|
||||
const { family, GLIBC, MUSL } = require('detect-libc');
|
||||
|
||||
switch (await family()) {
|
||||
case GLIBC: ...
|
||||
case MUSL: ...
|
||||
case null: ...
|
||||
}
|
||||
```
|
||||
|
||||
### familySync
|
||||
|
||||
```ts
|
||||
function familySync(): string | null;
|
||||
```
|
||||
|
||||
Synchronous version of `family()`.
|
||||
|
||||
```js
|
||||
const { familySync, GLIBC, MUSL } = require('detect-libc');
|
||||
|
||||
switch (familySync()) {
|
||||
case GLIBC: ...
|
||||
case MUSL: ...
|
||||
case null: ...
|
||||
}
|
||||
```
|
||||
|
||||
### version
|
||||
|
||||
```ts
|
||||
function version(): Promise<string | null>;
|
||||
```
|
||||
|
||||
Resolves asychronously with:
|
||||
|
||||
* The version when it can be determined
|
||||
* `null` when the libc family cannot be determined
|
||||
* `null` when run on a non-Linux platform
|
||||
|
||||
```js
|
||||
const { version } = require('detect-libc');
|
||||
|
||||
const v = await version();
|
||||
if (v) {
|
||||
const [major, minor, patch] = v.split('.');
|
||||
}
|
||||
```
|
||||
|
||||
### versionSync
|
||||
|
||||
```ts
|
||||
function versionSync(): string | null;
|
||||
```
|
||||
|
||||
Synchronous version of `version()`.
|
||||
|
||||
```js
|
||||
const { versionSync } = require('detect-libc');
|
||||
|
||||
const v = versionSync();
|
||||
if (v) {
|
||||
const [major, minor, patch] = v.split('.');
|
||||
}
|
||||
```
|
||||
|
||||
### isNonGlibcLinux
|
||||
|
||||
```ts
|
||||
function isNonGlibcLinux(): Promise<boolean>;
|
||||
```
|
||||
|
||||
Resolves asychronously with:
|
||||
|
||||
* `false` when the libc family is `glibc`
|
||||
* `true` when the libc family is not `glibc`
|
||||
* `false` when run on a non-Linux platform
|
||||
|
||||
```js
|
||||
const { isNonGlibcLinux } = require('detect-libc');
|
||||
|
||||
if (await isNonGlibcLinux()) { ... }
|
||||
```
|
||||
|
||||
### isNonGlibcLinuxSync
|
||||
|
||||
```ts
|
||||
function isNonGlibcLinuxSync(): boolean;
|
||||
```
|
||||
|
||||
Synchronous version of `isNonGlibcLinux()`.
|
||||
|
||||
```js
|
||||
const { isNonGlibcLinuxSync } = require('detect-libc');
|
||||
|
||||
if (isNonGlibcLinuxSync()) { ... }
|
||||
```
|
||||
|
||||
## Licensing
|
||||
|
||||
Copyright 2017 Lovell Fuller and others.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0.html)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
14
dealplustech-astro/node_modules/libsql/node_modules/detect-libc/index.d.ts
generated
vendored
Normal file
14
dealplustech-astro/node_modules/libsql/node_modules/detect-libc/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
// Copyright 2017 Lovell Fuller and others.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export const GLIBC: 'glibc';
|
||||
export const MUSL: 'musl';
|
||||
|
||||
export function family(): Promise<string | null>;
|
||||
export function familySync(): string | null;
|
||||
|
||||
export function isNonGlibcLinux(): Promise<boolean>;
|
||||
export function isNonGlibcLinuxSync(): boolean;
|
||||
|
||||
export function version(): Promise<string | null>;
|
||||
export function versionSync(): string | null;
|
||||
279
dealplustech-astro/node_modules/libsql/node_modules/detect-libc/lib/detect-libc.js
generated
vendored
Normal file
279
dealplustech-astro/node_modules/libsql/node_modules/detect-libc/lib/detect-libc.js
generated
vendored
Normal file
@@ -0,0 +1,279 @@
|
||||
// Copyright 2017 Lovell Fuller and others.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
'use strict';
|
||||
|
||||
const childProcess = require('child_process');
|
||||
const { isLinux, getReport } = require('./process');
|
||||
const { LDD_PATH, readFile, readFileSync } = require('./filesystem');
|
||||
|
||||
let cachedFamilyFilesystem;
|
||||
let cachedVersionFilesystem;
|
||||
|
||||
const command = 'getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true';
|
||||
let commandOut = '';
|
||||
|
||||
const safeCommand = () => {
|
||||
if (!commandOut) {
|
||||
return new Promise((resolve) => {
|
||||
childProcess.exec(command, (err, out) => {
|
||||
commandOut = err ? ' ' : out;
|
||||
resolve(commandOut);
|
||||
});
|
||||
});
|
||||
}
|
||||
return commandOut;
|
||||
};
|
||||
|
||||
const safeCommandSync = () => {
|
||||
if (!commandOut) {
|
||||
try {
|
||||
commandOut = childProcess.execSync(command, { encoding: 'utf8' });
|
||||
} catch (_err) {
|
||||
commandOut = ' ';
|
||||
}
|
||||
}
|
||||
return commandOut;
|
||||
};
|
||||
|
||||
/**
|
||||
* A String constant containing the value `glibc`.
|
||||
* @type {string}
|
||||
* @public
|
||||
*/
|
||||
const GLIBC = 'glibc';
|
||||
|
||||
/**
|
||||
* A Regexp constant to get the GLIBC Version.
|
||||
* @type {string}
|
||||
*/
|
||||
const RE_GLIBC_VERSION = /GLIBC\s(\d+\.\d+)/;
|
||||
|
||||
/**
|
||||
* A String constant containing the value `musl`.
|
||||
* @type {string}
|
||||
* @public
|
||||
*/
|
||||
const MUSL = 'musl';
|
||||
|
||||
/**
|
||||
* This string is used to find if the {@link LDD_PATH} is GLIBC
|
||||
* @type {string}
|
||||
*/
|
||||
const GLIBC_ON_LDD = GLIBC.toUpperCase();
|
||||
|
||||
/**
|
||||
* This string is used to find if the {@link LDD_PATH} is musl
|
||||
* @type {string}
|
||||
*/
|
||||
const MUSL_ON_LDD = MUSL.toLowerCase();
|
||||
|
||||
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-');
|
||||
|
||||
const familyFromReport = () => {
|
||||
const report = getReport();
|
||||
if (report.header && report.header.glibcVersionRuntime) {
|
||||
return GLIBC;
|
||||
}
|
||||
if (Array.isArray(report.sharedObjects)) {
|
||||
if (report.sharedObjects.some(isFileMusl)) {
|
||||
return MUSL;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const familyFromCommand = (out) => {
|
||||
const [getconf, ldd1] = out.split(/[\r\n]+/);
|
||||
if (getconf && getconf.includes(GLIBC)) {
|
||||
return GLIBC;
|
||||
}
|
||||
if (ldd1 && ldd1.includes(MUSL)) {
|
||||
return MUSL;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const getFamilyFromLddContent = (content) => {
|
||||
if (content.includes(MUSL_ON_LDD)) {
|
||||
return MUSL;
|
||||
}
|
||||
if (content.includes(GLIBC_ON_LDD)) {
|
||||
return GLIBC;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const familyFromFilesystem = async () => {
|
||||
if (cachedFamilyFilesystem !== undefined) {
|
||||
return cachedFamilyFilesystem;
|
||||
}
|
||||
cachedFamilyFilesystem = null;
|
||||
try {
|
||||
const lddContent = await readFile(LDD_PATH);
|
||||
cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
|
||||
} catch (e) {}
|
||||
return cachedFamilyFilesystem;
|
||||
};
|
||||
|
||||
const familyFromFilesystemSync = () => {
|
||||
if (cachedFamilyFilesystem !== undefined) {
|
||||
return cachedFamilyFilesystem;
|
||||
}
|
||||
cachedFamilyFilesystem = null;
|
||||
try {
|
||||
const lddContent = readFileSync(LDD_PATH);
|
||||
cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);
|
||||
} catch (e) {}
|
||||
return cachedFamilyFilesystem;
|
||||
};
|
||||
|
||||
/**
|
||||
* Resolves with the libc family when it can be determined, `null` otherwise.
|
||||
* @returns {Promise<?string>}
|
||||
*/
|
||||
const family = async () => {
|
||||
let family = null;
|
||||
if (isLinux()) {
|
||||
family = await familyFromFilesystem();
|
||||
if (!family) {
|
||||
family = familyFromReport();
|
||||
}
|
||||
if (!family) {
|
||||
const out = await safeCommand();
|
||||
family = familyFromCommand(out);
|
||||
}
|
||||
}
|
||||
return family;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the libc family when it can be determined, `null` otherwise.
|
||||
* @returns {?string}
|
||||
*/
|
||||
const familySync = () => {
|
||||
let family = null;
|
||||
if (isLinux()) {
|
||||
family = familyFromFilesystemSync();
|
||||
if (!family) {
|
||||
family = familyFromReport();
|
||||
}
|
||||
if (!family) {
|
||||
const out = safeCommandSync();
|
||||
family = familyFromCommand(out);
|
||||
}
|
||||
}
|
||||
return family;
|
||||
};
|
||||
|
||||
/**
|
||||
* Resolves `true` only when the platform is Linux and the libc family is not `glibc`.
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
const isNonGlibcLinux = async () => isLinux() && await family() !== GLIBC;
|
||||
|
||||
/**
|
||||
* Returns `true` only when the platform is Linux and the libc family is not `glibc`.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
const isNonGlibcLinuxSync = () => isLinux() && familySync() !== GLIBC;
|
||||
|
||||
const versionFromFilesystem = async () => {
|
||||
if (cachedVersionFilesystem !== undefined) {
|
||||
return cachedVersionFilesystem;
|
||||
}
|
||||
cachedVersionFilesystem = null;
|
||||
try {
|
||||
const lddContent = await readFile(LDD_PATH);
|
||||
const versionMatch = lddContent.match(RE_GLIBC_VERSION);
|
||||
if (versionMatch) {
|
||||
cachedVersionFilesystem = versionMatch[1];
|
||||
}
|
||||
} catch (e) {}
|
||||
return cachedVersionFilesystem;
|
||||
};
|
||||
|
||||
const versionFromFilesystemSync = () => {
|
||||
if (cachedVersionFilesystem !== undefined) {
|
||||
return cachedVersionFilesystem;
|
||||
}
|
||||
cachedVersionFilesystem = null;
|
||||
try {
|
||||
const lddContent = readFileSync(LDD_PATH);
|
||||
const versionMatch = lddContent.match(RE_GLIBC_VERSION);
|
||||
if (versionMatch) {
|
||||
cachedVersionFilesystem = versionMatch[1];
|
||||
}
|
||||
} catch (e) {}
|
||||
return cachedVersionFilesystem;
|
||||
};
|
||||
|
||||
const versionFromReport = () => {
|
||||
const report = getReport();
|
||||
if (report.header && report.header.glibcVersionRuntime) {
|
||||
return report.header.glibcVersionRuntime;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const versionSuffix = (s) => s.trim().split(/\s+/)[1];
|
||||
|
||||
const versionFromCommand = (out) => {
|
||||
const [getconf, ldd1, ldd2] = out.split(/[\r\n]+/);
|
||||
if (getconf && getconf.includes(GLIBC)) {
|
||||
return versionSuffix(getconf);
|
||||
}
|
||||
if (ldd1 && ldd2 && ldd1.includes(MUSL)) {
|
||||
return versionSuffix(ldd2);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Resolves with the libc version when it can be determined, `null` otherwise.
|
||||
* @returns {Promise<?string>}
|
||||
*/
|
||||
const version = async () => {
|
||||
let version = null;
|
||||
if (isLinux()) {
|
||||
version = await versionFromFilesystem();
|
||||
if (!version) {
|
||||
version = versionFromReport();
|
||||
}
|
||||
if (!version) {
|
||||
const out = await safeCommand();
|
||||
version = versionFromCommand(out);
|
||||
}
|
||||
}
|
||||
return version;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the libc version when it can be determined, `null` otherwise.
|
||||
* @returns {?string}
|
||||
*/
|
||||
const versionSync = () => {
|
||||
let version = null;
|
||||
if (isLinux()) {
|
||||
version = versionFromFilesystemSync();
|
||||
if (!version) {
|
||||
version = versionFromReport();
|
||||
}
|
||||
if (!version) {
|
||||
const out = safeCommandSync();
|
||||
version = versionFromCommand(out);
|
||||
}
|
||||
}
|
||||
return version;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
GLIBC,
|
||||
MUSL,
|
||||
family,
|
||||
familySync,
|
||||
isNonGlibcLinux,
|
||||
isNonGlibcLinuxSync,
|
||||
version,
|
||||
versionSync
|
||||
};
|
||||
41
dealplustech-astro/node_modules/libsql/node_modules/detect-libc/lib/filesystem.js
generated
vendored
Normal file
41
dealplustech-astro/node_modules/libsql/node_modules/detect-libc/lib/filesystem.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright 2017 Lovell Fuller and others.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
/**
|
||||
* The path where we can find the ldd
|
||||
*/
|
||||
const LDD_PATH = '/usr/bin/ldd';
|
||||
|
||||
/**
|
||||
* Read the content of a file synchronous
|
||||
*
|
||||
* @param {string} path
|
||||
* @returns {string}
|
||||
*/
|
||||
const readFileSync = (path) => fs.readFileSync(path, 'utf-8');
|
||||
|
||||
/**
|
||||
* Read the content of a file
|
||||
*
|
||||
* @param {string} path
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
const readFile = (path) => new Promise((resolve, reject) => {
|
||||
fs.readFile(path, 'utf-8', (err, data) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
LDD_PATH,
|
||||
readFileSync,
|
||||
readFile
|
||||
};
|
||||
19
dealplustech-astro/node_modules/libsql/node_modules/detect-libc/lib/process.js
generated
vendored
Normal file
19
dealplustech-astro/node_modules/libsql/node_modules/detect-libc/lib/process.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// Copyright 2017 Lovell Fuller and others.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
'use strict';
|
||||
|
||||
const isLinux = () => process.platform === 'linux';
|
||||
|
||||
let report = null;
|
||||
const getReport = () => {
|
||||
if (!report) {
|
||||
/* istanbul ignore next */
|
||||
report = isLinux() && process.report
|
||||
? process.report.getReport()
|
||||
: {};
|
||||
}
|
||||
return report;
|
||||
};
|
||||
|
||||
module.exports = { isLinux, getReport };
|
||||
40
dealplustech-astro/node_modules/libsql/node_modules/detect-libc/package.json
generated
vendored
Normal file
40
dealplustech-astro/node_modules/libsql/node_modules/detect-libc/package.json
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "detect-libc",
|
||||
"version": "2.0.2",
|
||||
"description": "Node.js module to detect the C standard library (libc) implementation family and version",
|
||||
"main": "lib/detect-libc.js",
|
||||
"files": [
|
||||
"lib/",
|
||||
"index.d.ts"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "semistandard && nyc --reporter=lcov --check-coverage --branches=100 ava test/unit.js",
|
||||
"bench": "node benchmark/detect-libc",
|
||||
"bench:calls": "node benchmark/call-familySync.js && sleep 1 && node benchmark/call-isNonGlibcLinuxSync.js && sleep 1 && node benchmark/call-versionSync.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/lovell/detect-libc"
|
||||
},
|
||||
"keywords": [
|
||||
"libc",
|
||||
"glibc",
|
||||
"musl"
|
||||
],
|
||||
"author": "Lovell Fuller <npm@lovell.info>",
|
||||
"contributors": [
|
||||
"Niklas Salmoukas <niklas@salmoukas.com>",
|
||||
"Vinícius Lourenço <vinyygamerlol@gmail.com>"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"ava": "^2.4.0",
|
||||
"benchmark": "^2.1.4",
|
||||
"nyc": "^15.1.0",
|
||||
"proxyquire": "^2.1.3",
|
||||
"semistandard": "^14.2.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
}
|
||||
92
dealplustech-astro/node_modules/libsql/package.json
generated
vendored
Normal file
92
dealplustech-astro/node_modules/libsql/package.json
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"name": "libsql",
|
||||
"version": "0.5.22",
|
||||
"description": "A better-sqlite3 compatible API for libSQL that supports Bun, Deno, and Node",
|
||||
"os": [
|
||||
"darwin",
|
||||
"linux",
|
||||
"win32"
|
||||
],
|
||||
"cpu": [
|
||||
"x64",
|
||||
"arm64",
|
||||
"wasm32",
|
||||
"arm"
|
||||
],
|
||||
"main": "index.js",
|
||||
"types": "types/index.d.ts",
|
||||
"files": [
|
||||
"auth.js",
|
||||
"index.js",
|
||||
"sqlite-error.js",
|
||||
"promise.js",
|
||||
"types/index.d.ts",
|
||||
"types/promise.d.ts"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./types/index.d.ts",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"./promise": {
|
||||
"types": "./types/promise.d.ts",
|
||||
"default": "./promise.js"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": "cargo test",
|
||||
"debug": "cargo build --message-format=json | npm exec neon dist",
|
||||
"build": "npx tsc && cargo build --message-format=json --release | npm exec neon dist -- --name libsql-js",
|
||||
"cross": "cross build --message-format=json --release | npm exec neon dist -- --name libsql-js -m /target",
|
||||
"pack-build": "neon pack-build",
|
||||
"prepack": "neon install-builds",
|
||||
"postversion": "git push --follow-tags"
|
||||
},
|
||||
"author": "Pekka Enberg <penberg@iki.fi>",
|
||||
"license": "MIT",
|
||||
"neon": {
|
||||
"type": "source",
|
||||
"org": "@libsql",
|
||||
"targets": {
|
||||
"darwin-arm64": "aarch64-apple-darwin",
|
||||
"linux-arm64-gnu": "aarch64-unknown-linux-gnu",
|
||||
"linux-arm64-musl": "aarch64-unknown-linux-musl",
|
||||
"darwin-x64": "x86_64-apple-darwin",
|
||||
"win32-x64-msvc": "x86_64-pc-windows-msvc",
|
||||
"linux-x64-gnu": "x86_64-unknown-linux-gnu",
|
||||
"linux-x64-musl": "x86_64-unknown-linux-musl",
|
||||
"linux-arm-gnueabihf": "arm-unknown-linux-gnueabihf",
|
||||
"linux-arm-musleabihf": "arm-unknown-linux-musleabihf"
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/tursodatabase/libsql-js.git"
|
||||
},
|
||||
"keywords": [
|
||||
"libsql"
|
||||
],
|
||||
"bugs": {
|
||||
"url": "https://github.com/tursodatabase/libsql-js/issues"
|
||||
},
|
||||
"homepage": "https://github.com/tursodatabase/libsql-js",
|
||||
"devDependencies": {
|
||||
"@neon-rs/cli": "^0.0.165",
|
||||
"typescript": "^5.4.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@neon-rs/load": "^0.0.4",
|
||||
"detect-libc": "2.0.2"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@libsql/darwin-arm64": "0.5.22",
|
||||
"@libsql/darwin-x64": "0.5.22",
|
||||
"@libsql/linux-arm-gnueabihf": "0.5.22",
|
||||
"@libsql/linux-arm-musleabihf": "0.5.22",
|
||||
"@libsql/linux-arm64-gnu": "0.5.22",
|
||||
"@libsql/linux-arm64-musl": "0.5.22",
|
||||
"@libsql/linux-x64-gnu": "0.5.22",
|
||||
"@libsql/linux-x64-musl": "0.5.22",
|
||||
"@libsql/win32-x64-msvc": "0.5.22"
|
||||
}
|
||||
}
|
||||
445
dealplustech-astro/node_modules/libsql/promise.js
generated
vendored
Normal file
445
dealplustech-astro/node_modules/libsql/promise.js
generated
vendored
Normal file
@@ -0,0 +1,445 @@
|
||||
"use strict";
|
||||
|
||||
const { load, currentTarget } = require("@neon-rs/load");
|
||||
const { familySync, GLIBC, MUSL } = require("detect-libc");
|
||||
|
||||
// Static requires for bundlers.
|
||||
if (0) {
|
||||
require("./.targets");
|
||||
}
|
||||
|
||||
const Authorization = require("./auth");
|
||||
const SqliteError = require("./sqlite-error");
|
||||
|
||||
function convertError(err) {
|
||||
if (err.libsqlError) {
|
||||
return new SqliteError(err.message, err.code, err.rawCode);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
function requireNative() {
|
||||
if (process.env.LIBSQL_JS_DEV) {
|
||||
return load(__dirname)
|
||||
}
|
||||
let target = currentTarget();
|
||||
// Workaround for Bun, which reports a musl target, but really wants glibc...
|
||||
if (familySync() == GLIBC) {
|
||||
switch (target) {
|
||||
case "linux-x64-musl":
|
||||
target = "linux-x64-gnu";
|
||||
break;
|
||||
case "linux-arm64-musl":
|
||||
target = "linux-arm64-gnu";
|
||||
break;
|
||||
}
|
||||
}
|
||||
// @neon-rs/load doesn't detect arm musl
|
||||
if (target === "linux-arm-gnueabihf" && familySync() == MUSL) {
|
||||
target = "linux-arm-musleabihf";
|
||||
}
|
||||
return require(`@libsql/${target}`);
|
||||
}
|
||||
|
||||
const {
|
||||
databaseOpen,
|
||||
databaseOpenWithSync,
|
||||
databaseInTransaction,
|
||||
databaseInterrupt,
|
||||
databaseClose,
|
||||
databaseSyncAsync,
|
||||
databaseSyncUntilAsync,
|
||||
databaseExecAsync,
|
||||
databasePrepareAsync,
|
||||
databaseMaxWriteReplicationIndex,
|
||||
databaseDefaultSafeIntegers,
|
||||
databaseAuthorizer,
|
||||
databaseLoadExtension,
|
||||
statementRaw,
|
||||
statementIsReader,
|
||||
statementGet,
|
||||
statementRun,
|
||||
statementInterrupt,
|
||||
statementRowsAsync,
|
||||
statementColumns,
|
||||
statementSafeIntegers,
|
||||
rowsNext,
|
||||
} = requireNative();
|
||||
|
||||
/**
|
||||
* Database represents a connection that can prepare and execute SQL statements.
|
||||
*/
|
||||
class Database {
|
||||
/**
|
||||
* Creates a new database connection. If the database file pointed to by `path` does not exists, it will be created.
|
||||
*
|
||||
* @constructor
|
||||
* @param {string} path - Path to the database file.
|
||||
*/
|
||||
constructor(path, opts) {
|
||||
const encryptionCipher = opts?.encryptionCipher ?? "aes256cbc";
|
||||
if (opts && opts.syncUrl) {
|
||||
var authToken = "";
|
||||
if (opts.syncAuth) {
|
||||
console.warn("Warning: The `syncAuth` option is deprecated, please use `authToken` option instead.");
|
||||
authToken = opts.syncAuth;
|
||||
} else if (opts.authToken) {
|
||||
authToken = opts.authToken;
|
||||
}
|
||||
const encryptionKey = opts?.encryptionKey ?? "";
|
||||
const syncPeriod = opts?.syncPeriod ?? 0.0;
|
||||
const offline = opts?.offline ?? false;
|
||||
const remoteEncryptionKey = opts?.remoteEncryptionKey ?? "";
|
||||
this.db = databaseOpenWithSync(path, opts.syncUrl, authToken, encryptionCipher, encryptionKey, syncPeriod, offline, remoteEncryptionKey);
|
||||
} else {
|
||||
const authToken = opts?.authToken ?? "";
|
||||
const encryptionKey = opts?.encryptionKey ?? "";
|
||||
const timeout = opts?.timeout ?? 0.0;
|
||||
const remoteEncryptionKey = opts?.remoteEncryptionKey ?? "";
|
||||
this.db = databaseOpen(path, authToken, encryptionCipher, encryptionKey, timeout, remoteEncryptionKey);
|
||||
}
|
||||
// TODO: Use a libSQL API for this?
|
||||
this.memory = path === ":memory:";
|
||||
this.readonly = false;
|
||||
this.name = "";
|
||||
this.open = true;
|
||||
|
||||
const db = this.db;
|
||||
Object.defineProperties(this, {
|
||||
inTransaction: {
|
||||
get() {
|
||||
return databaseInTransaction(db);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
sync() {
|
||||
return databaseSyncAsync.call(this.db);
|
||||
}
|
||||
|
||||
syncUntil(replicationIndex) {
|
||||
return databaseSyncUntilAsync.call(this.db, replicationIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares a SQL statement for execution.
|
||||
*
|
||||
* @param {string} sql - The SQL statement string to prepare.
|
||||
*/
|
||||
prepare(sql) {
|
||||
return databasePrepareAsync.call(this.db, sql).then((stmt) => {
|
||||
return new Statement(stmt);
|
||||
}).catch((err) => {
|
||||
throw convertError(err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a function that executes the given function in a transaction.
|
||||
*
|
||||
* @param {function} fn - The function to wrap in a transaction.
|
||||
*/
|
||||
transaction(fn) {
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError("Expected first argument to be a function");
|
||||
|
||||
const db = this;
|
||||
const wrapTxn = (mode) => {
|
||||
return async (...bindParameters) => {
|
||||
await db.exec("BEGIN " + mode);
|
||||
try {
|
||||
const result = fn(...bindParameters);
|
||||
await db.exec("COMMIT");
|
||||
return result;
|
||||
} catch (err) {
|
||||
await db.exec("ROLLBACK");
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
};
|
||||
const properties = {
|
||||
default: { value: wrapTxn("") },
|
||||
deferred: { value: wrapTxn("DEFERRED") },
|
||||
immediate: { value: wrapTxn("IMMEDIATE") },
|
||||
exclusive: { value: wrapTxn("EXCLUSIVE") },
|
||||
database: { value: this, enumerable: true },
|
||||
};
|
||||
Object.defineProperties(properties.default.value, properties);
|
||||
Object.defineProperties(properties.deferred.value, properties);
|
||||
Object.defineProperties(properties.immediate.value, properties);
|
||||
Object.defineProperties(properties.exclusive.value, properties);
|
||||
return properties.default.value;
|
||||
}
|
||||
|
||||
pragma(source, options) {
|
||||
if (options == null) options = {};
|
||||
if (typeof source !== 'string') throw new TypeError('Expected first argument to be a string');
|
||||
if (typeof options !== 'object') throw new TypeError('Expected second argument to be an options object');
|
||||
const simple = options['simple'];
|
||||
return this.prepare(`PRAGMA ${source}`, this, true).then(async (stmt) => {
|
||||
return simple ? await stmt.pluck().get() : await stmt.all();
|
||||
});
|
||||
}
|
||||
|
||||
backup(filename, options) {
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
serialize(options) {
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
function(name, options, fn) {
|
||||
// Apply defaults
|
||||
if (options == null) options = {};
|
||||
if (typeof options === "function") {
|
||||
fn = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
// Validate arguments
|
||||
if (typeof name !== "string")
|
||||
throw new TypeError("Expected first argument to be a string");
|
||||
if (typeof fn !== "function")
|
||||
throw new TypeError("Expected last argument to be a function");
|
||||
if (typeof options !== "object")
|
||||
throw new TypeError("Expected second argument to be an options object");
|
||||
if (!name)
|
||||
throw new TypeError(
|
||||
"User-defined function name cannot be an empty string"
|
||||
);
|
||||
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
aggregate(name, options) {
|
||||
// Validate arguments
|
||||
if (typeof name !== "string")
|
||||
throw new TypeError("Expected first argument to be a string");
|
||||
if (typeof options !== "object" || options === null)
|
||||
throw new TypeError("Expected second argument to be an options object");
|
||||
if (!name)
|
||||
throw new TypeError(
|
||||
"User-defined function name cannot be an empty string"
|
||||
);
|
||||
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
table(name, factory) {
|
||||
// Validate arguments
|
||||
if (typeof name !== "string")
|
||||
throw new TypeError("Expected first argument to be a string");
|
||||
if (!name)
|
||||
throw new TypeError(
|
||||
"Virtual table module name cannot be an empty string"
|
||||
);
|
||||
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
|
||||
authorizer(rules) {
|
||||
databaseAuthorizer.call(this.db, rules);
|
||||
}
|
||||
|
||||
loadExtension(...args) {
|
||||
databaseLoadExtension.call(this.db, ...args);
|
||||
}
|
||||
|
||||
maxWriteReplicationIndex() {
|
||||
return databaseMaxWriteReplicationIndex.call(this.db)
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a SQL statement.
|
||||
*
|
||||
* @param {string} sql - The SQL statement string to execute.
|
||||
*/
|
||||
exec(sql) {
|
||||
return databaseExecAsync.call(this.db, sql).catch((err) => {
|
||||
throw convertError(err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Interrupts the database connection.
|
||||
*/
|
||||
interrupt() {
|
||||
databaseInterrupt.call(this.db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the database connection.
|
||||
*/
|
||||
close() {
|
||||
databaseClose.call(this.db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle 64-bit integer support.
|
||||
*/
|
||||
defaultSafeIntegers(toggle) {
|
||||
databaseDefaultSafeIntegers.call(this.db, toggle ?? true);
|
||||
return this;
|
||||
}
|
||||
|
||||
unsafeMode(...args) {
|
||||
throw new Error("not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Statement represents a prepared SQL statement that can be executed.
|
||||
*/
|
||||
class Statement {
|
||||
constructor(stmt) {
|
||||
this.stmt = stmt;
|
||||
this.pluckMode = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle raw mode.
|
||||
*
|
||||
* @param raw Enable or disable raw mode. If you don't pass the parameter, raw mode is enabled.
|
||||
*/
|
||||
raw(raw) {
|
||||
statementRaw.call(this.stmt, raw ?? true);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle pluck mode.
|
||||
*
|
||||
* @param pluckMode Enable or disable pluck mode. If you don't pass the parameter, pluck mode is enabled.
|
||||
*/
|
||||
pluck(pluckMode) {
|
||||
this.pluckMode = pluckMode ?? true;
|
||||
return this;
|
||||
}
|
||||
|
||||
get reader() {
|
||||
return statementIsReader.call(this.stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the SQL statement and returns an info object.
|
||||
*/
|
||||
run(...bindParameters) {
|
||||
try {
|
||||
if (bindParameters.length == 1 && typeof bindParameters[0] === "object") {
|
||||
return statementRun.call(this.stmt, bindParameters[0]);
|
||||
} else {
|
||||
return statementRun.call(this.stmt, bindParameters.flat());
|
||||
}
|
||||
} catch (err) {
|
||||
throw convertError(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the SQL statement and returns the first row.
|
||||
*
|
||||
* @param bindParameters - The bind parameters for executing the statement.
|
||||
*/
|
||||
get(...bindParameters) {
|
||||
try {
|
||||
if (bindParameters.length == 1 && typeof bindParameters[0] === "object") {
|
||||
return statementGet.call(this.stmt, bindParameters[0]);
|
||||
} else {
|
||||
return statementGet.call(this.stmt, bindParameters.flat());
|
||||
}
|
||||
} catch (e) {
|
||||
throw convertError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the SQL statement and returns an iterator to the resulting rows.
|
||||
*
|
||||
* @param bindParameters - The bind parameters for executing the statement.
|
||||
*/
|
||||
async iterate(...bindParameters) {
|
||||
var rows = undefined;
|
||||
if (bindParameters.length == 1 && typeof bindParameters[0] === "object") {
|
||||
rows = await statementRowsAsync.call(this.stmt, bindParameters[0]);
|
||||
} else {
|
||||
rows = await statementRowsAsync.call(this.stmt, bindParameters.flat());
|
||||
}
|
||||
const iter = {
|
||||
nextRows: Array(100),
|
||||
nextRowIndex: 100,
|
||||
next() {
|
||||
try {
|
||||
if (this.nextRowIndex === 100) {
|
||||
this.nextRows.fill(null);
|
||||
rowsNext.call(rows, this.nextRows);
|
||||
this.nextRowIndex = 0;
|
||||
}
|
||||
const row = this.nextRows[this.nextRowIndex];
|
||||
this.nextRows[this.nextRowIndex] = null;
|
||||
if (!row) {
|
||||
return { done: true };
|
||||
}
|
||||
this.nextRowIndex++;
|
||||
return { value: row, done: false };
|
||||
} catch (e) {
|
||||
throw convertError(e);
|
||||
}
|
||||
},
|
||||
[Symbol.iterator]() {
|
||||
return this;
|
||||
},
|
||||
};
|
||||
return iter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the SQL statement and returns an array of the resulting rows.
|
||||
*
|
||||
* @param bindParameters - The bind parameters for executing the statement.
|
||||
*/
|
||||
async all(...bindParameters) {
|
||||
try {
|
||||
const result = [];
|
||||
const it = await this.iterate(...bindParameters);
|
||||
for (const row of it) {
|
||||
if (this.pluckMode) {
|
||||
result.push(row[Object.keys(row)[0]]);
|
||||
} else {
|
||||
result.push(row);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} catch (e) {
|
||||
throw convertError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interrupts the statement.
|
||||
*/
|
||||
interrupt() {
|
||||
statementInterrupt.call(this.stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the columns in the result set returned by this prepared statement.
|
||||
*/
|
||||
columns() {
|
||||
return statementColumns.call(this.stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle 64-bit integer support.
|
||||
*/
|
||||
safeIntegers(toggle) {
|
||||
statementSafeIntegers.call(this.stmt, toggle ?? true);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Database;
|
||||
module.exports.Authorization = Authorization;
|
||||
module.exports.SqliteError = SqliteError;
|
||||
21
dealplustech-astro/node_modules/libsql/sqlite-error.js
generated
vendored
Normal file
21
dealplustech-astro/node_modules/libsql/sqlite-error.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
const descriptor = { value: 'SqliteError', writable: true, enumerable: false, configurable: true };
|
||||
|
||||
function SqliteError(message, code, rawCode) {
|
||||
if (new.target !== SqliteError) {
|
||||
return new SqliteError(message, code);
|
||||
}
|
||||
if (typeof code !== 'string') {
|
||||
throw new TypeError('Expected second argument to be a string');
|
||||
}
|
||||
Error.call(this, message);
|
||||
descriptor.value = '' + message;
|
||||
Object.defineProperty(this, 'message', descriptor);
|
||||
Error.captureStackTrace(this, SqliteError);
|
||||
this.code = code;
|
||||
this.rawCode = rawCode
|
||||
}
|
||||
Object.setPrototypeOf(SqliteError, Error);
|
||||
Object.setPrototypeOf(SqliteError.prototype, Error.prototype);
|
||||
Object.defineProperty(SqliteError.prototype, 'name', descriptor);
|
||||
module.exports = SqliteError;
|
||||
162
dealplustech-astro/node_modules/libsql/types/index.d.ts
generated
vendored
Normal file
162
dealplustech-astro/node_modules/libsql/types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
// Type definitions for better-sqlite3 7.6
|
||||
// Project: https://github.com/JoshuaWise/better-sqlite3
|
||||
// Definitions by: Ben Davies <https://github.com/Morfent>
|
||||
// Mathew Rumsey <https://github.com/matrumz>
|
||||
// Santiago Aguilar <https://github.com/sant123>
|
||||
// Alessandro Vergani <https://github.com/loghorn>
|
||||
// Andrew Kaiser <https://github.com/andykais>
|
||||
// Mark Stewart <https://github.com/mrkstwrt>
|
||||
// Florian Stamer <https://github.com/stamerf>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.8
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
// FIXME: Is this `any` really necessary?
|
||||
type VariableArgFunction = (...params: any[]) => unknown;
|
||||
type ArgumentTypes<F extends VariableArgFunction> = F extends (...args: infer A) => unknown ? A : never;
|
||||
type ElementOf<T> = T extends Array<infer E> ? E : T;
|
||||
|
||||
declare namespace Libsql {
|
||||
interface Statement<BindParameters extends unknown[]> {
|
||||
database: Database;
|
||||
source: string;
|
||||
reader: boolean;
|
||||
readonly: boolean;
|
||||
busy: boolean;
|
||||
|
||||
run(...params: BindParameters): Database.RunResult;
|
||||
get(...params: BindParameters): unknown;
|
||||
all(...params: BindParameters): unknown[];
|
||||
iterate(...params: BindParameters): IterableIterator<unknown>;
|
||||
pluck(toggleState?: boolean): this;
|
||||
expand(toggleState?: boolean): this;
|
||||
raw(toggleState?: boolean): this;
|
||||
bind(...params: BindParameters): this;
|
||||
columns(): ColumnDefinition[];
|
||||
safeIntegers(toggleState?: boolean): this;
|
||||
}
|
||||
|
||||
interface ColumnDefinition {
|
||||
name: string;
|
||||
column: string | null;
|
||||
table: string | null;
|
||||
database: string | null;
|
||||
type: string | null;
|
||||
}
|
||||
|
||||
interface Transaction<F extends VariableArgFunction> {
|
||||
(...params: ArgumentTypes<F>): ReturnType<F>;
|
||||
default(...params: ArgumentTypes<F>): ReturnType<F>;
|
||||
deferred(...params: ArgumentTypes<F>): ReturnType<F>;
|
||||
immediate(...params: ArgumentTypes<F>): ReturnType<F>;
|
||||
exclusive(...params: ArgumentTypes<F>): ReturnType<F>;
|
||||
}
|
||||
|
||||
interface VirtualTableOptions {
|
||||
rows: () => Generator;
|
||||
columns: string[];
|
||||
parameters?: string[] | undefined;
|
||||
safeIntegers?: boolean | undefined;
|
||||
directOnly?: boolean | undefined;
|
||||
}
|
||||
|
||||
interface Database {
|
||||
memory: boolean;
|
||||
readonly: boolean;
|
||||
name: string;
|
||||
open: boolean;
|
||||
inTransaction: boolean;
|
||||
|
||||
prepare<BindParameters extends unknown[] | {} = unknown[]>(
|
||||
source: string,
|
||||
): BindParameters extends unknown[] ? Statement<BindParameters> : Statement<[BindParameters]>;
|
||||
transaction<F extends VariableArgFunction>(fn: F): Transaction<F>;
|
||||
sync(): any;
|
||||
exec(source: string): this;
|
||||
pragma(source: string, options?: Database.PragmaOptions): unknown;
|
||||
function(name: string, cb: (...params: unknown[]) => unknown): this;
|
||||
function(name: string, options: Database.RegistrationOptions, cb: (...params: unknown[]) => unknown): this;
|
||||
aggregate<T>(name: string, options: Database.RegistrationOptions & {
|
||||
start?: T | (() => T);
|
||||
step: (total: T, next: ElementOf<T>) => T | void;
|
||||
inverse?: ((total: T, dropped: T) => T) | undefined;
|
||||
result?: ((total: T) => unknown) | undefined;
|
||||
}): this;
|
||||
loadExtension(path: string): this;
|
||||
close(): this;
|
||||
defaultSafeIntegers(toggleState?: boolean): this;
|
||||
backup(destinationFile: string, options?: Database.BackupOptions): Promise<Database.BackupMetadata>;
|
||||
table(name: string, options: VirtualTableOptions): this;
|
||||
unsafeMode(unsafe?: boolean): this;
|
||||
serialize(options?: Database.SerializeOptions): Buffer;
|
||||
}
|
||||
|
||||
interface DatabaseConstructor {
|
||||
new (filename: string | Buffer, options?: Database.Options): Database;
|
||||
(filename: string, options?: Database.Options): Database;
|
||||
prototype: Database;
|
||||
|
||||
SqliteError: typeof SqliteError;
|
||||
}
|
||||
}
|
||||
|
||||
declare class SqliteError extends Error {
|
||||
name: string;
|
||||
message: string;
|
||||
code: string;
|
||||
rawCode?: number;
|
||||
constructor(message: string, code: string, rawCode?: number);
|
||||
}
|
||||
|
||||
declare namespace Database {
|
||||
interface RunResult {
|
||||
changes: number;
|
||||
lastInsertRowid: number | bigint;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
readonly?: boolean | undefined;
|
||||
fileMustExist?: boolean | undefined;
|
||||
timeout?: number | undefined;
|
||||
verbose?: ((message?: unknown, ...additionalArgs: unknown[]) => void) | undefined;
|
||||
nativeBinding?: string | undefined;
|
||||
syncUrl?: string | undefined;
|
||||
}
|
||||
|
||||
interface SerializeOptions {
|
||||
attached?: string;
|
||||
}
|
||||
|
||||
interface PragmaOptions {
|
||||
simple?: boolean | undefined;
|
||||
}
|
||||
|
||||
interface RegistrationOptions {
|
||||
varargs?: boolean | undefined;
|
||||
deterministic?: boolean | undefined;
|
||||
safeIntegers?: boolean | undefined;
|
||||
directOnly?: boolean | undefined;
|
||||
}
|
||||
|
||||
type AggregateOptions = Parameters<Libsql.Database["aggregate"]>[1];
|
||||
|
||||
interface BackupMetadata {
|
||||
totalPages: number;
|
||||
remainingPages: number;
|
||||
}
|
||||
interface BackupOptions {
|
||||
progress: (info: BackupMetadata) => number;
|
||||
}
|
||||
|
||||
type SqliteError = typeof SqliteError;
|
||||
type Statement<BindParameters extends unknown[] | {} = unknown[]> = BindParameters extends unknown[]
|
||||
? Libsql.Statement<BindParameters>
|
||||
: Libsql.Statement<[BindParameters]>;
|
||||
type ColumnDefinition = Libsql.ColumnDefinition;
|
||||
type Transaction<T extends VariableArgFunction = VariableArgFunction> = Libsql.Transaction<T>;
|
||||
type Database = Libsql.Database;
|
||||
}
|
||||
|
||||
declare const Database: Libsql.DatabaseConstructor;
|
||||
export = Database;
|
||||
66
dealplustech-astro/node_modules/libsql/types/promise.d.ts
generated
vendored
Normal file
66
dealplustech-astro/node_modules/libsql/types/promise.d.ts
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
export = Database;
|
||||
/**
|
||||
* Database represents a connection that can prepare and execute SQL statements.
|
||||
*/
|
||||
declare class Database {
|
||||
/**
|
||||
* Creates a new database connection. If the database file pointed to by `path` does not exists, it will be created.
|
||||
*
|
||||
* @constructor
|
||||
* @param {string} path - Path to the database file.
|
||||
*/
|
||||
constructor(path: string, opts: any);
|
||||
db: any;
|
||||
memory: boolean;
|
||||
readonly: boolean;
|
||||
name: string;
|
||||
open: boolean;
|
||||
sync(): any;
|
||||
syncUntil(replicationIndex: any): any;
|
||||
/**
|
||||
* Prepares a SQL statement for execution.
|
||||
*
|
||||
* @param {string} sql - The SQL statement string to prepare.
|
||||
*/
|
||||
prepare(sql: string): any;
|
||||
/**
|
||||
* Returns a function that executes the given function in a transaction.
|
||||
*
|
||||
* @param {function} fn - The function to wrap in a transaction.
|
||||
*/
|
||||
transaction(fn: Function): (...bindParameters: any[]) => Promise<any>;
|
||||
pragma(source: any, options: any): any;
|
||||
backup(filename: any, options: any): void;
|
||||
serialize(options: any): void;
|
||||
function(name: any, options: any, fn: any): void;
|
||||
aggregate(name: any, options: any): void;
|
||||
table(name: any, factory: any): void;
|
||||
authorizer(rules: any): void;
|
||||
loadExtension(...args: any[]): void;
|
||||
maxWriteReplicationIndex(): any;
|
||||
/**
|
||||
* Executes a SQL statement.
|
||||
*
|
||||
* @param {string} sql - The SQL statement string to execute.
|
||||
*/
|
||||
exec(sql: string): any;
|
||||
/**
|
||||
* Interrupts the database connection.
|
||||
*/
|
||||
interrupt(): void;
|
||||
/**
|
||||
* Closes the database connection.
|
||||
*/
|
||||
close(): void;
|
||||
/**
|
||||
* Toggle 64-bit integer support.
|
||||
*/
|
||||
defaultSafeIntegers(toggle: any): this;
|
||||
unsafeMode(...args: any[]): void;
|
||||
}
|
||||
declare namespace Database {
|
||||
export { Authorization, SqliteError };
|
||||
}
|
||||
import Authorization = require("./auth");
|
||||
import SqliteError = require("./sqlite-error");
|
||||
//# sourceMappingURL=promise.d.ts.map
|
||||
Reference in New Issue
Block a user