Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .claude/skills/release/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Every publishable package must have a `## $ARGUMENTS` entry in its CHANGELOG.md.
| 2 | dart_node_express |
| 2 | dart_node_ws |
| 2 | dart_node_better_sqlite3 |
| 2 | dart_node_sql_js |
| 2 | dart_node_mcp |
| 3 | dart_node_react |
| 3 | dart_node_react_native |
Expand All @@ -93,7 +94,7 @@ Check each changelog:

```bash
VERSION="$ARGUMENTS"
for pkg in dart_logging dart_node_core reflux dart_node_express dart_node_ws dart_node_better_sqlite3 dart_node_mcp dart_node_react dart_node_react_native; do
for pkg in dart_logging dart_node_core reflux dart_node_express dart_node_ws dart_node_better_sqlite3 dart_node_sql_js dart_node_mcp dart_node_react dart_node_react_native; do
if grep -q "^## $VERSION" "packages/$pkg/CHANGELOG.md" 2>/dev/null; then
echo "✅ $pkg"
else
Expand All @@ -109,7 +110,7 @@ If any are missing, **stop and update the changelogs** before proceeding.
Each package should have a README.md. Quick sanity check:

```bash
for pkg in dart_logging dart_node_core reflux dart_node_express dart_node_ws dart_node_better_sqlite3 dart_node_mcp dart_node_react dart_node_react_native; do
for pkg in dart_logging dart_node_core reflux dart_node_express dart_node_ws dart_node_better_sqlite3 dart_node_sql_js dart_node_mcp dart_node_react dart_node_react_native; do
if [[ -f "packages/$pkg/README.md" ]]; then
LINES=$(wc -l < "packages/$pkg/README.md")
echo "✅ $pkg - $LINES lines"
Expand All @@ -124,7 +125,7 @@ done
Verify which versions are currently published:

```bash
for pkg in dart_logging dart_node_core reflux dart_node_express dart_node_ws dart_node_better_sqlite3 dart_node_mcp dart_node_react dart_node_react_native; do
for pkg in dart_logging dart_node_core reflux dart_node_express dart_node_ws dart_node_better_sqlite3 dart_node_sql_js dart_node_mcp dart_node_react dart_node_react_native; do
LATEST=$(curl -s "https://pub.dev/api/packages/$pkg" | grep -o '"version":"[^"]*"' | head -1 | cut -d'"' -f4)
echo "$pkg: $LATEST"
done
Expand Down Expand Up @@ -185,7 +186,7 @@ git tag "Release-Tier2/$ARGUMENTS"
git push origin "Release-Tier2/$ARGUMENTS"
```

Publishes: reflux, dart_node_express, dart_node_ws, dart_node_better_sqlite3, dart_node_mcp
Publishes: reflux, dart_node_express, dart_node_ws, dart_node_better_sqlite3, dart_node_sql_js, dart_node_mcp

## Step 10: Tier 3 publishing

Expand Down Expand Up @@ -214,7 +215,7 @@ After release, verify all packages are available:

```bash
VERSION="$ARGUMENTS"
for pkg in dart_logging dart_node_core reflux dart_node_express dart_node_ws dart_node_better_sqlite3 dart_node_mcp dart_node_react dart_node_react_native; do
for pkg in dart_logging dart_node_core reflux dart_node_express dart_node_ws dart_node_better_sqlite3 dart_node_sql_js dart_node_mcp dart_node_react dart_node_react_native; do
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "https://pub.dev/api/packages/$pkg/versions/$VERSION")
if [[ "$HTTP_CODE" == "200" ]]; then
echo "✅ $pkg@$VERSION published"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish-tier1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ jobs:
"dart_node_express"
"dart_node_ws"
"dart_node_better_sqlite3"
"dart_node_sql_js"
"dart_node_mcp"
"dart_node_react"
"dart_node_react_native"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-tier2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ jobs:
- name: Publish packages
run: |
chmod +x .github/scripts/publish-packages.sh
.github/scripts/publish-packages.sh "${{ steps.version.outputs.VERSION }}" reflux dart_node_express dart_node_ws dart_node_better_sqlite3 dart_node_mcp
.github/scripts/publish-packages.sh "${{ steps.version.outputs.VERSION }}" reflux dart_node_express dart_node_ws dart_node_better_sqlite3 dart_node_sql_js dart_node_mcp
1 change: 1 addition & 0 deletions coverage-thresholds.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"dart_node_express": 100.0,
"dart_node_ws": 100.0,
"dart_node_better_sqlite3": 100.0,
"dart_node_sql_js": 100.0,
"dart_node_mcp": 100.0,
"dart_node_react_native": 100.0,
"dart_jsx": 82.5,
Expand Down
8 changes: 8 additions & 0 deletions packages/dart_node_sql_js/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

## 0.13.0-beta

- Initial beta release
- Typed Dart bindings for sql.js (SQLite compiled to WebAssembly)
- Synchronous in-memory SQLite with file persistence on Node.js
- `Result`-based API: open, prepare, exec, run, get, all, pragma
28 changes: 28 additions & 0 deletions packages/dart_node_sql_js/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
BSD 3-Clause License

Copyright (c) 2025, Christian Findlay

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. 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.

3. Neither the name of the copyright holder 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.
105 changes: 105 additions & 0 deletions packages/dart_node_sql_js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
Typed Dart bindings for [sql.js](https://github.com/sql-js/sql.js) — SQLite
compiled to WebAssembly. Provides synchronous, in-memory SQLite for Node.js
applications, with explicit persistence to disk.

Unlike native bindings, sql.js needs no compilation and runs the same
everywhere WebAssembly does. The database lives in memory; you persist it to a
file with `save` or `close`.

## Installation

```yaml
dependencies:
dart_node_sql_js: ^0.13.0-beta
nadz: ^0.0.7-beta
```

Also install the npm package:

```bash
npm install sql.js
```

## Quick Start

```dart
import 'package:dart_node_sql_js/dart_node_sql_js.dart';
import 'package:nadz/nadz.dart';

Future<void> main() async {
// Initialize the WebAssembly runtime once at startup.
final runtime = switch (await initializeSqlJs()) {
Success(:final value) => value,
Error(:final error) => throw Exception(error),
};

// Opens ./my.db if it exists, otherwise creates a new database.
final db = switch (openDatabase('./my.db', sqlJs: runtime)) {
Success(:final value) => value,
Error(:final error) => throw Exception(error),
};

db.exec('CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT)');

final insert = switch (db.prepare('INSERT INTO users (name) VALUES (?)')) {
Success(:final value) => value,
Error(:final error) => throw Exception(error),
};
insert.run(['Alice']);

final query = switch (db.prepare('SELECT * FROM users')) {
Success(:final value) => value,
Error(:final error) => throw Exception(error),
};
final rows = switch (query.all()) {
Success(:final value) => value,
Error(:final error) => throw Exception(error),
};
print(rows); // [{id: 1, name: Alice}]

// Persist the in-memory database to ./my.db.
db.close();
}
```

## Persistence

sql.js is entirely in-memory. The only way to serialize it (`export()`) frees
every live prepared statement, so this binding does **not** write to disk after
each statement. Instead:

- `db.save()` flushes the current state to the backing file on demand.
- `db.close()` saves and then releases the database.

Reopening the same path loads the persisted bytes.

## API

`initializeSqlJs()` returns a `Future<Result<SqlJsRuntime, String>>`. Pass the
runtime to every `openDatabase` call.

`openDatabase(path, sqlJs: runtime)` returns a `Result<Database, String>` with:

| Member | Description |
|--------|-------------|
| `prepare(sql)` | Prepare a reusable statement. |
| `exec(sql)` | Run one or more statements, ignoring results. |
| `pragma(value)` | Run a `PRAGMA`. |
| `save()` | Persist the in-memory database to its file. |
| `close()` | Persist, then close. |
| `isOpen()` | Whether the database is still open. |

A prepared `Statement` exposes:

| Member | Description |
|--------|-------------|
| `all([params])` | All rows as a list of column-keyed maps. |
| `get([params])` | The first row, or null. |
| `run([params])` | Execute, returning `changes` and `lastInsertRowid`. |

Every operation returns a `Result` (from [nadz](https://pub.dev/packages/nadz))
instead of throwing.

## License

BSD 3-Clause. See [LICENSE](LICENSE).
7 changes: 7 additions & 0 deletions packages/dart_node_sql_js/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include: package:austerity/analysis_options.yaml

analyzer:
errors:
avoid_catches_without_on_clauses: ignore
require_trailing_commas: ignore
public_member_api_docs: error
1 change: 1 addition & 0 deletions packages/dart_node_sql_js/dart_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
platforms: [node]
2 changes: 1 addition & 1 deletion packages/dart_node_sql_js/lib/dart_node_sql_js.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// Typed Dart bindings for sql.js (SQLite compiled to WebAssembly).
///
/// Provides synchronous SQLite3 access via WebAssembly.
/// Call [initializeSqlJs] once at startup, then use [openDatabase].
/// Call `initializeSqlJs` once at startup, then use `openDatabase`.
library;

export 'src/database.dart';
Expand Down
Loading
Loading