@joystick.js/db-canary 0.0.0-canary.2212 → 0.0.0-canary.2216
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/API_KEY +0 -1
- package/data/data.mdb +0 -0
- package/data/lock.mdb +0 -0
- package/logs/.013e15b54597d05db4b4b53ecc37b10c92a72927-audit.json +0 -20
- package/logs/.02de550a67ea0f5961faa2dfd458a4d06f59ebd1-audit.json +0 -20
- package/logs/.03494ba24eb3c72214b4068a77d54b8993bee651-audit.json +0 -20
- package/logs/.06309ec60b339be1259a7993dd09c732f8907fbc-audit.json +0 -20
- package/logs/.0663a04dcfa17285661e5e1b8cfa51f41523b210-audit.json +0 -20
- package/logs/.0f06e6c4c9b824622729e13927587479e5060391-audit.json +0 -20
- package/logs/.16ccf58682ecb22b3e3ec63f0da1b7fe9be56528-audit.json +0 -20
- package/logs/.1fa1a5d02f496474b1ab473524c65c984146a9ad-audit.json +0 -20
- package/logs/.2223c0ae3bea6f0d62c62b1d319cc8634856abb7-audit.json +0 -20
- package/logs/.23dc79ffda3e083665e6f5993f59397adcbf4a46-audit.json +0 -20
- package/logs/.28104f49b03906b189eefd1cd462cb46c3c0af22-audit.json +0 -20
- package/logs/.29cdbf13808abe6a0ce70ee2f2efdd680ce3fd8e-audit.json +0 -20
- package/logs/.2a9889afd071f77f41f5170d08703a0afca866b7-audit.json +0 -20
- package/logs/.2acec3d1940a2bbed487528b703ee5948959a599-audit.json +0 -20
- package/logs/.2fb60ff326338c02bfedbcd0e936444e4a216750-audit.json +0 -20
- package/logs/.318fc7a19530d76a345f030f7cad00dda15300e7-audit.json +0 -20
- package/logs/.3cf27043e19085f908cedc7701e6d013463208ee-audit.json +0 -25
- package/logs/.3d90d785415817fc443402843b7c95f8371adc9b-audit.json +0 -20
- package/logs/.4074bca620375f72966fc52dfd439577727671e5-audit.json +0 -20
- package/logs/.40eecf018417ea80a70ea8ec7a3cc9406bc6334b-audit.json +0 -20
- package/logs/.50e974f1ef7c365fca6a1251b2e2c2252914cb5e-audit.json +0 -20
- package/logs/.52cb7d9e4223cf26ba36006ac26b949a97c7923c-audit.json +0 -20
- package/logs/.54befcdb84c15aad980705a31bcc9f555c3577ab-audit.json +0 -20
- package/logs/.57dfb70e22eddb84db2e3c0ceeefac5c0b9baffa-audit.json +0 -20
- package/logs/.5f0b24705a1eaad4eca4968f2d86f91b3f9be683-audit.json +0 -20
- package/logs/.61ba98fdda7db58576b382fee07904e5db1169d6-audit.json +0 -20
- package/logs/.6235017727ef6b199d569a99d6aa8c8e80a1b475-audit.json +0 -20
- package/logs/.63db16193699219489d218a1ddea5dde3750cae4-audit.json +0 -20
- package/logs/.64fb67dfe14149c9eef728d79bf30a54da809c60-audit.json +0 -20
- package/logs/.669137453368987c1f311b5345342527afb54e50-audit.json +0 -20
- package/logs/.7a71f8c89ea28ae266d356aeff6306e876a30fbb-audit.json +0 -20
- package/logs/.7afbaa90fe9dc3a7d682676f9bb79f9a1b1fd9a6-audit.json +0 -20
- package/logs/.7ca29e322cd05327035de850099e7610864f2347-audit.json +0 -20
- package/logs/.83335ab3347e449dae03455a110aaf7f120d4802-audit.json +0 -20
- package/logs/.8c2487b5fd445d2c8e5c483c80b9fa99bbf1ca58-audit.json +0 -20
- package/logs/.8c8b9dc386922c9f3b4c13251af7052aac1d24c0-audit.json +0 -20
- package/logs/.8d6155d94640c4863301ae0fee5e4e7372a21446-audit.json +0 -20
- package/logs/.944a3119a243deea7c8270d5d9e582bb1d0eaa10-audit.json +0 -20
- package/logs/.9816a845c30fb2909f3b26a23eeb3538ebcad5db-audit.json +0 -20
- package/logs/.9dc08784e38b865488177c26d4af5934555e0323-audit.json +0 -20
- package/logs/.9dd27d2e0e454ac0a37600206d1cac5493b0d7ee-audit.json +0 -20
- package/logs/.a3d486feeac7654c59b547de96600e8849a06d4f-audit.json +0 -20
- package/logs/.a5b811f4def22250f86cc18870d7c4573625df22-audit.json +0 -20
- package/logs/.a61648eb5f830e0b6f508ac35e4f8f629d2ad4c7-audit.json +0 -20
- package/logs/.a89016d507045771b4b5a65656944a9c0f1e528b-audit.json +0 -20
- package/logs/.a99bee160a1c590be959af46bacc02724803f691-audit.json +0 -20
- package/logs/.ada7906d6243fd7da802f03d86c4ae5dd9df6236-audit.json +0 -20
- package/logs/.b518339ee942143b6af983af167f5bbb6983b4de-audit.json +0 -20
- package/logs/.b51b124b166d53c9519017856ea610d61d65fabe-audit.json +0 -20
- package/logs/.b7a6aee19f58e55633d5e4a3709041c47dfff975-audit.json +0 -20
- package/logs/.bd7a8a6ba9c55d557a4867ab53f02e3ec2e1553d-audit.json +0 -20
- package/logs/.c1435dafe453b169d6392b25065f3cf4ab6fbb21-audit.json +0 -20
- package/logs/.c17e1ce043109f77dc2f0e2aa290a9d1ed842c03-audit.json +0 -20
- package/logs/.ca62637ce9540e5a38a2fbedb2115febb6ad308a-audit.json +0 -20
- package/logs/.ccee67b9c176967f8977071409a41f5cb5cd6ad4-audit.json +0 -20
- package/logs/.db24043417ea79a6f14cd947476399e53930b48d-audit.json +0 -20
- package/logs/.e0f12acccb57829f5f33712bb2e2607ecd808147-audit.json +0 -20
- package/logs/.e9b6cc33d0bbd2e644c4e2bf44d177f850016557-audit.json +0 -20
- package/logs/.f15291d434808e3bdca7963ccd2e73893be027e6-audit.json +0 -20
- package/logs/.f4bdf9e21ef84f8a3fae3ffb32bbc39275991351-audit.json +0 -20
- package/logs/.fbac3aefac1e81b4230df5aa50667cb90d51024f-audit.json +0 -20
- package/logs/.fcfd495c0a9169db243f4a4f21878ee02b76413c-audit.json +0 -20
- package/logs/admin-2025-09-12.log +0 -580
- package/logs/admin-2025-09-15.log +0 -283
- package/logs/admin-error-2025-09-12.log +0 -22
- package/logs/admin-error-2025-09-15.log +0 -10
- package/logs/api_key_manager-2025-09-12.log +0 -658
- package/logs/api_key_manager-2025-09-15.log +0 -295
- package/logs/api_key_manager-error-2025-09-12.log +0 -0
- package/logs/api_key_manager-error-2025-09-15.log +0 -0
- package/logs/auth_manager-2025-09-12.log +0 -4432
- package/logs/auth_manager-2025-09-15.log +0 -2000
- package/logs/auth_manager-error-2025-09-12.log +0 -11
- package/logs/auth_manager-error-2025-09-15.log +0 -5
- package/logs/auto_index_manager-2025-09-12.log +0 -84
- package/logs/auto_index_manager-2025-09-15.log +0 -45
- package/logs/auto_index_manager-error-2025-09-12.log +0 -6
- package/logs/auto_index_manager-error-2025-09-15.log +0 -0
- package/logs/backup_manager-2025-09-12.log +0 -198
- package/logs/backup_manager-2025-09-15.log +0 -90
- package/logs/backup_manager-error-2025-09-12.log +0 -198
- package/logs/backup_manager-error-2025-09-15.log +0 -90
- package/logs/bulk_write-2025-09-12.log +0 -66
- package/logs/bulk_write-2025-09-15.log +0 -38
- package/logs/bulk_write-error-2025-09-12.log +0 -0
- package/logs/bulk_write-error-2025-09-15.log +0 -0
- package/logs/connection_manager-2025-09-12.log +0 -2412
- package/logs/connection_manager-2025-09-15.log +0 -1132
- package/logs/connection_manager-error-2025-09-12.log +0 -0
- package/logs/connection_manager-error-2025-09-15.log +0 -0
- package/logs/create_index-2025-09-12.log +0 -302
- package/logs/create_index-2025-09-15.log +0 -158
- package/logs/create_index-error-2025-09-12.log +0 -30
- package/logs/create_index-error-2025-09-15.log +0 -13
- package/logs/delete_one-2025-09-12.log +0 -73
- package/logs/delete_one-2025-09-15.log +0 -43
- package/logs/delete_one-error-2025-09-12.log +0 -0
- package/logs/delete_one-error-2025-09-15.log +0 -0
- package/logs/disk_utils-2025-09-12.log +0 -4954
- package/logs/disk_utils-2025-09-15.log +0 -2446
- package/logs/disk_utils-error-2025-09-12.log +0 -0
- package/logs/disk_utils-error-2025-09-15.log +0 -0
- package/logs/drop_index-2025-09-12.log +0 -41
- package/logs/drop_index-2025-09-15.log +0 -23
- package/logs/drop_index-error-2025-09-12.log +0 -11
- package/logs/drop_index-error-2025-09-15.log +0 -5
- package/logs/find-2025-09-12.log +0 -1050
- package/logs/find-2025-09-15.log +0 -592
- package/logs/find-error-2025-09-12.log +0 -1
- package/logs/find-error-2025-09-15.log +0 -0
- package/logs/find_one-2025-09-12.log +0 -425
- package/logs/find_one-2025-09-15.log +0 -264
- package/logs/find_one-error-2025-09-12.log +0 -5
- package/logs/find_one-error-2025-09-15.log +0 -0
- package/logs/get_indexes-2025-09-12.log +0 -84
- package/logs/get_indexes-2025-09-15.log +0 -56
- package/logs/get_indexes-error-2025-09-12.log +0 -6
- package/logs/get_indexes-error-2025-09-15.log +0 -0
- package/logs/http_server-2025-09-12.log +0 -2772
- package/logs/http_server-2025-09-15.log +0 -1276
- package/logs/http_server-error-2025-09-12.log +0 -212
- package/logs/http_server-error-2025-09-15.log +0 -44
- package/logs/index_manager-2025-09-12.log +0 -5031
- package/logs/index_manager-2025-09-15.log +0 -2909
- package/logs/index_manager-error-2025-09-12.log +0 -80
- package/logs/index_manager-error-2025-09-15.log +0 -38
- package/logs/insert_one-2025-09-12.log +0 -2181
- package/logs/insert_one-2025-09-15.log +0 -1293
- package/logs/insert_one-error-2025-09-12.log +0 -0
- package/logs/insert_one-error-2025-09-15.log +0 -0
- package/logs/master-2025-09-12.log +0 -1882
- package/logs/master-2025-09-15.log +0 -910
- package/logs/master-error-2025-09-12.log +0 -80
- package/logs/master-error-2025-09-15.log +0 -0
- package/logs/operation_dispatcher-2025-09-12.log +0 -751
- package/logs/operation_dispatcher-2025-09-15.log +0 -359
- package/logs/operation_dispatcher-error-2025-09-12.log +0 -33
- package/logs/operation_dispatcher-error-2025-09-15.log +0 -11
- package/logs/performance_monitor-2025-09-12.log +0 -14889
- package/logs/performance_monitor-2025-09-15.log +0 -6803
- package/logs/performance_monitor-error-2025-09-12.log +0 -0
- package/logs/performance_monitor-error-2025-09-15.log +0 -0
- package/logs/query_engine-2025-09-12.log +0 -5310
- package/logs/query_engine-2025-09-15.log +0 -2639
- package/logs/query_engine-error-2025-09-12.log +0 -0
- package/logs/query_engine-error-2025-09-15.log +0 -0
- package/logs/recovery_manager-2025-09-12.log +0 -462
- package/logs/recovery_manager-2025-09-15.log +0 -210
- package/logs/recovery_manager-error-2025-09-12.log +0 -22
- package/logs/recovery_manager-error-2025-09-15.log +0 -10
- package/logs/replication-2025-09-12.log +0 -1923
- package/logs/replication-2025-09-15.log +0 -917
- package/logs/replication-error-2025-09-12.log +0 -33
- package/logs/replication-error-2025-09-15.log +0 -15
- package/logs/server-2025-09-12.log +0 -2601
- package/logs/server-2025-09-15.log +0 -1191
- package/logs/server-error-2025-09-12.log +0 -0
- package/logs/server-error-2025-09-15.log +0 -0
- package/logs/tcp_protocol-2025-09-12.log +0 -22
- package/logs/tcp_protocol-2025-09-15.log +0 -10
- package/logs/tcp_protocol-error-2025-09-12.log +0 -22
- package/logs/tcp_protocol-error-2025-09-15.log +0 -10
- package/logs/test-2025-09-12.log +0 -0
- package/logs/test-2025-09-15.log +0 -0
- package/logs/test-error-2025-09-12.log +0 -0
- package/logs/test-error-2025-09-15.log +0 -0
- package/logs/update_one-2025-09-12.log +0 -173
- package/logs/update_one-2025-09-15.log +0 -118
- package/logs/update_one-error-2025-09-12.log +0 -0
- package/logs/update_one-error-2025-09-15.log +0 -0
- package/logs/worker-2025-09-12.log +0 -1457
- package/logs/worker-2025-09-15.log +0 -695
- package/logs/worker-error-2025-09-12.log +0 -0
- package/logs/worker-error-2025-09-15.log +0 -0
- package/logs/write_forwarder-2025-09-12.log +0 -1956
- package/logs/write_forwarder-2025-09-15.log +0 -932
- package/logs/write_forwarder-error-2025-09-12.log +0 -66
- package/logs/write_forwarder-error-2025-09-15.log +0 -30
- package/logs/write_queue-2025-09-12.log +0 -612
- package/logs/write_queue-2025-09-15.log +0 -301
- package/logs/write_queue-error-2025-09-12.log +0 -184
- package/logs/write_queue-error-2025-09-15.log +0 -83
- package/prompts/01-core-infrastructure.md +0 -56
- package/prompts/02-secondary-indexing.md +0 -65
- package/prompts/03-write-serialization.md +0 -63
- package/prompts/04-enhanced-authentication.md +0 -75
- package/prompts/05-comprehensive-admin-operations.md +0 -75
- package/prompts/06-backup-and-restore-system.md +0 -106
- package/prompts/07-production-safety-features.md +0 -107
- package/prompts/08-tcp-client-library.md +0 -121
- package/prompts/09-api-method-chaining.md +0 -134
- package/prompts/10-automatic-index-creation.md +0 -223
- package/prompts/11-operation-naming-consistency.md +0 -268
- package/prompts/12-tcp-replication-system.md +0 -333
- package/prompts/13-master-read-write-operations.md +0 -57
- package/prompts/14-index-upsert-operations.md +0 -68
- package/prompts/15-client-api-return-types.md +0 -81
- package/prompts/16-server-setup-ui.md +0 -97
- package/prompts/17-emergency-password-change.md +0 -108
- package/prompts/18-joystick-framework-integration.md +0 -116
- package/prompts/19-api-key-authentication-system.md +0 -137
- package/prompts/20-configurable-server-port.md +0 -105
- package/prompts/21-multi-database-support.md +0 -161
- package/prompts/22-build-script-integration.md +0 -129
- package/prompts/23-cli-integration.md +0 -268
- package/prompts/FULL_TEXT_SEARCH.md +0 -293
- package/prompts/PROMPTS.md +0 -158
- package/prompts/README.md +0 -221
- package/prompts/TYPESCRIPT_GENERATION.md +0 -179
- package/test_data/data.mdb +0 -0
- package/test_data/lock.mdb +0 -0
package/prompts/PROMPTS.md
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
# Prompt 1: Build JoystickDB TCP Server (Production-Grade, Secure, Reliable)
|
|
2
|
-
|
|
3
|
-
You are building a Node.js app that acts as the **JoystickDB TCP server**.
|
|
4
|
-
|
|
5
|
-
Requirements:
|
|
6
|
-
- Use ESM syntax (`import`).
|
|
7
|
-
- Follow coding conventions: snake_case for variables/functions/keys, arrow functions preferred.
|
|
8
|
-
- Install dependencies: `lmdb`, `msgpack-lite`, `bcrypt`, `@aws-sdk/client-s3`, `crypto`, plus standard Node libs.
|
|
9
|
-
- The server should:
|
|
10
|
-
|
|
11
|
-
### Core
|
|
12
|
-
1. **Auto-calculate map_size at bootstrap**:
|
|
13
|
-
- Detect total disk size (e.g. via `df -k .`).
|
|
14
|
-
- Set `map_size = disk_size * 0.8`.
|
|
15
|
-
- Example: 3 TB disk → map_size = ~2.4 TB.
|
|
16
|
-
- This ensures JoystickDB never consumes 100% of disk, leaving margin for OS, swap, logs, and backups.
|
|
17
|
-
- Map_size must be **grown automatically** if data approaches 80% of current map_size (double it, capped at 80% of total disk).
|
|
18
|
-
2. Open an LMDB environment at `./data` with that map_size.
|
|
19
|
-
3. Start a TCP server on port `6000` (Node `net` module).
|
|
20
|
-
4. Each message = 4-byte length prefix + MessagePack payload.
|
|
21
|
-
5. Decode MessagePack payload into JSON-like object:
|
|
22
|
-
```json
|
|
23
|
-
{
|
|
24
|
-
"op": "auth" | "find_one" | "find" | "insert_one" | "update_one" | "delete_one" | "bulk_write" | "admin" | "ping",
|
|
25
|
-
"collection": "string",
|
|
26
|
-
"filter": { ... },
|
|
27
|
-
"update": { ... },
|
|
28
|
-
"options": { ... },
|
|
29
|
-
"operations": [ ... ],
|
|
30
|
-
"admin_action": "stats" | "list_collections" | "create_index" | "drop_index" | "get_indexes" | "list_documents" | "get_document" | "query_documents" | "insert_document" | "update_document" | "delete_document" | "backup_now" | "restore_backup" | "list_backups",
|
|
31
|
-
"password": "string"
|
|
32
|
-
}
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### Query Language
|
|
36
|
-
6. Implement a **MongoDB-style query language** (1:1 with MongoDB except no aggregation pipeline).
|
|
37
|
-
7. **Secondary indexing**:
|
|
38
|
-
- Maintain sub-databases for indexed fields.
|
|
39
|
-
- Keys: `index:<collection>:<field>:<value> → [document_ids...]`.
|
|
40
|
-
- Update indexes on insert/update.
|
|
41
|
-
- Use indexes for queries when filters match indexed fields.
|
|
42
|
-
|
|
43
|
-
### Writes
|
|
44
|
-
8. **Bulk writes**:
|
|
45
|
-
- Accept array of insert/update/delete ops.
|
|
46
|
-
- Run in a single LMDB write transaction (atomic).
|
|
47
|
-
- Roll back entire batch if any fail.
|
|
48
|
-
9. **Write serialization**:
|
|
49
|
-
- Only one LMDB write transaction at a time.
|
|
50
|
-
- Queue concurrent writes.
|
|
51
|
-
|
|
52
|
-
### Authentication
|
|
53
|
-
10. **Auth flow**:
|
|
54
|
-
- Bootstrap: provision 32-char password via SSH.
|
|
55
|
-
- Store `bcrypt.hash(password)` in `./auth.json`.
|
|
56
|
-
- First op must be `{ op: "auth", password: "..." }`.
|
|
57
|
-
- Rate-limit failures (5/min per IP).
|
|
58
|
-
|
|
59
|
-
### Admin Operations
|
|
60
|
-
11. **Admin actions**:
|
|
61
|
-
- Metadata: `stats`, `list_collections`, `create_index`, `drop_index`, `get_indexes`.
|
|
62
|
-
- Data: `list_documents`, `get_document`, `query_documents`, `insert_document`, `update_document`, `delete_document`.
|
|
63
|
-
- Backups: `backup_now`, `list_backups`, `restore_backup`.
|
|
64
|
-
|
|
65
|
-
### Backups & Restore
|
|
66
|
-
12. **Automatic backups**:
|
|
67
|
-
- If S3 configured in `settings.json`, run `backup_now` hourly.
|
|
68
|
-
- Store compressed sparse backup (`tar --sparse`) in `./backups` and S3.
|
|
69
|
-
- Retention: keep 24 hourly + 30 daily, rotate older.
|
|
70
|
-
- Backup includes SHA256 checksum file.
|
|
71
|
-
13. **restore_from one-shot**:
|
|
72
|
-
- If `settings.json` has `"restore_from": "<backup_file>"`:
|
|
73
|
-
- Download from S3 (or local).
|
|
74
|
-
- Verify SHA256 checksum.
|
|
75
|
-
- Replace `./data/data.mdb`.
|
|
76
|
-
- If restore fails: log + boot fresh LMDB.
|
|
77
|
-
- If restore succeeds: rewrite `settings.json` without `restore_from`.
|
|
78
|
-
|
|
79
|
-
### Safety
|
|
80
|
-
14. **Health**:
|
|
81
|
-
- `ping` always returns `{ ok: 1 }`.
|
|
82
|
-
- `stats` includes: memory, disk, ops/sec, doc count, map_size usage %.
|
|
83
|
-
15. **Timeouts**:
|
|
84
|
-
- Max 5s per request.
|
|
85
|
-
16. **Connections**:
|
|
86
|
-
- Max ~1000 connections.
|
|
87
|
-
- Drop idle after 10m.
|
|
88
|
-
17. **Logging**:
|
|
89
|
-
- Structured logs: `{ ts, client_id, op, collection, duration_ms, status }`.
|
|
90
|
-
18. **Protocol versioning**:
|
|
91
|
-
- After auth: `{ ok: 1, version: "1.0.0" }`.
|
|
92
|
-
- API never changes; future changes must remain backward-compatible.
|
|
93
|
-
|
|
94
|
-
---
|
|
95
|
-
|
|
96
|
-
# Prompt 2: Build JoystickDB TCP Client
|
|
97
|
-
|
|
98
|
-
- ESM + snake_case.
|
|
99
|
-
- Install `msgpack-lite`.
|
|
100
|
-
- Export `create_client({ host, port, password })`.
|
|
101
|
-
- On connect: send `{ op: "auth", password: "..." }`.
|
|
102
|
-
- Methods:
|
|
103
|
-
- CRUD: `insert_one`, `find_one`, `find`, `update_one`, `delete_one`.
|
|
104
|
-
- Bulk: `bulk_write`.
|
|
105
|
-
- Admin Metadata: `get_stats`, `list_collections`, `create_index`, `drop_index`, `get_indexes`.
|
|
106
|
-
- Admin Data: `list_documents`, `get_document`, `query_documents`, `insert_document`, `update_document`, `delete_document`.
|
|
107
|
-
- Backups: `backup_now`, `list_backups`, `restore_backup`.
|
|
108
|
-
- Health: `ping`.
|
|
109
|
-
- Per-request timeout: 5s.
|
|
110
|
-
- Auto reconnect + queueing.
|
|
111
|
-
|
|
112
|
-
---
|
|
113
|
-
|
|
114
|
-
# Prompt 3: NGINX TLS Termination
|
|
115
|
-
|
|
116
|
-
```nginx
|
|
117
|
-
stream {
|
|
118
|
-
upstream joystickdb_backend {
|
|
119
|
-
server 127.0.0.1:6000;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
server {
|
|
123
|
-
listen 443 ssl;
|
|
124
|
-
proxy_pass joystickdb_backend;
|
|
125
|
-
|
|
126
|
-
ssl_certificate /etc/letsencrypt/live/db.cheatcode.co/fullchain.pem;
|
|
127
|
-
ssl_certificate_key /etc/letsencrypt/live/db.cheatcode.co/privkey.pem;
|
|
128
|
-
|
|
129
|
-
ssl_protocols TLSv1.3;
|
|
130
|
-
ssl_ciphers HIGH:!aNULL:!MD5;
|
|
131
|
-
ssl_prefer_server_ciphers on;
|
|
132
|
-
ssl_session_cache shared:SSL:10m;
|
|
133
|
-
ssl_session_timeout 10m;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
---
|
|
139
|
-
|
|
140
|
-
# Prompt 4: settings.json Schema
|
|
141
|
-
|
|
142
|
-
```json
|
|
143
|
-
{
|
|
144
|
-
"s3": {
|
|
145
|
-
"bucket": "joystickdb-backups",
|
|
146
|
-
"region": "us-east-1",
|
|
147
|
-
"access_key": "AKIA...",
|
|
148
|
-
"secret_key": "abcd...",
|
|
149
|
-
"endpoint": "https://s3.amazonaws.com"
|
|
150
|
-
},
|
|
151
|
-
"backup_schedule": "hourly",
|
|
152
|
-
"restore_from": "joystickdb-backup-2025-08-28T12:00:00.mdb"
|
|
153
|
-
}
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
- `s3`: optional.
|
|
157
|
-
- `backup_schedule`: default hourly if omitted.
|
|
158
|
-
- `restore_from`: one-shot restore, auto-cleared after success.
|
package/prompts/README.md
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
# JoystickDB Implementation Tasks
|
|
2
|
-
|
|
3
|
-
This directory contains detailed prompts for implementing the complete production-grade JoystickDB TCP server. Each task builds upon the previous ones and should be completed in order.
|
|
4
|
-
|
|
5
|
-
## Current Status
|
|
6
|
-
✅ **COMPLETED**: Basic query engine with CRUD operations, authentication, and admin/reload operations (119 tests passing)
|
|
7
|
-
✅ **COMPLETED**: Task 1 - Core Infrastructure Upgrades (153 tests passing)
|
|
8
|
-
✅ **COMPLETED**: Task 2 - Secondary Indexing System (196 tests passing)
|
|
9
|
-
✅ **COMPLETED**: Task 3 - Write Serialization and Queuing (214 tests passing)
|
|
10
|
-
✅ **COMPLETED**: Task 4 - Enhanced Authentication System (251 tests passing)
|
|
11
|
-
✅ **COMPLETED**: Task 5 - Comprehensive Admin Operations (266 tests passing)
|
|
12
|
-
✅ **COMPLETED**: Task 6 - Backup and Restore System (296 tests passing)
|
|
13
|
-
✅ **COMPLETED**: Task 7 - Production Safety Features (316 tests passing)
|
|
14
|
-
✅ **COMPLETED**: Task 8 - TCP Client Library (All original tasks complete)
|
|
15
|
-
|
|
16
|
-
## Next Phase: API and Infrastructure Enhancements
|
|
17
|
-
✅ **COMPLETED**: Task 9 - API Method Chaining Enhancement (347 tests passing)
|
|
18
|
-
✅ **COMPLETED**: Task 10 - Automatic Index Creation (381 tests passing)
|
|
19
|
-
✅ **COMPLETED**: Task 11 - Operation Naming Consistency (383 tests passing)
|
|
20
|
-
✅ **COMPLETED**: Task 12 - TCP Replication System (423 tests passing)
|
|
21
|
-
|
|
22
|
-
## Phase 3: Core Improvements and User Experience
|
|
23
|
-
✅ **COMPLETED**: Task 13 - Master Node Read and Write Operations (420 tests passing)
|
|
24
|
-
✅ **COMPLETED**: Task 14 - Index Upsert Operations (428 tests passing)
|
|
25
|
-
✅ **COMPLETED**: Task 15 - Client API Return Types Enhancement (428 tests passing)
|
|
26
|
-
✅ **COMPLETED**: Task 16 - Server Setup UI (451 tests passing - Test Suite Stabilized)
|
|
27
|
-
✅ **COMPLETED**: Task 17 - Emergency Password Change System (474 tests passing)
|
|
28
|
-
|
|
29
|
-
## All Core Tasks Complete
|
|
30
|
-
🎉 **ALL TASKS COMPLETED**: JoystickDB production-grade implementation is complete with comprehensive emergency password recovery system.
|
|
31
|
-
|
|
32
|
-
## Task Overview
|
|
33
|
-
|
|
34
|
-
### 1. Core Infrastructure Upgrades
|
|
35
|
-
**File**: `01-core-infrastructure.md`
|
|
36
|
-
**Priority**: High
|
|
37
|
-
**Dependencies**: None
|
|
38
|
-
**Description**: Implement auto-calculating LMDB map_size, proper TCP protocol with length prefixing, connection limits, timeouts, and enhanced logging.
|
|
39
|
-
|
|
40
|
-
### 2. Secondary Indexing System
|
|
41
|
-
**File**: `02-secondary-indexing.md`
|
|
42
|
-
**Priority**: High
|
|
43
|
-
**Dependencies**: Task 1
|
|
44
|
-
**Description**: Build comprehensive indexing system for query optimization with index management operations and automatic index maintenance.
|
|
45
|
-
|
|
46
|
-
### 3. Write Serialization and Queuing
|
|
47
|
-
**File**: `03-write-serialization.md`
|
|
48
|
-
**Priority**: High
|
|
49
|
-
**Dependencies**: Task 1
|
|
50
|
-
**Description**: Implement write queue system to ensure only one LMDB write transaction at a time with proper concurrent read support.
|
|
51
|
-
|
|
52
|
-
### 4. Enhanced Authentication System
|
|
53
|
-
**File**: `04-enhanced-authentication.md`
|
|
54
|
-
**Priority**: Medium
|
|
55
|
-
**Dependencies**: Task 1
|
|
56
|
-
**Description**: Add setup command for password generation, rate limiting, protocol versioning, and secure authentication.json file management.
|
|
57
|
-
|
|
58
|
-
### 5. Comprehensive Admin Operations
|
|
59
|
-
**File**: `05-comprehensive-admin-operations.md`
|
|
60
|
-
**Priority**: Medium
|
|
61
|
-
**Dependencies**: Tasks 1, 2
|
|
62
|
-
**Description**: Expand admin operations with metadata management, data operations, and system monitoring capabilities.
|
|
63
|
-
|
|
64
|
-
### 6. Backup and Restore System
|
|
65
|
-
**File**: `06-backup-and-restore-system.md`
|
|
66
|
-
**Priority**: Medium
|
|
67
|
-
**Dependencies**: Tasks 1, 5
|
|
68
|
-
**Description**: Implement S3-integrated backup system with automatic scheduling, retention management, and one-shot restore capabilities.
|
|
69
|
-
|
|
70
|
-
### 7. Production Safety Features
|
|
71
|
-
**File**: `07-production-safety-features.md`
|
|
72
|
-
**Priority**: High
|
|
73
|
-
**Dependencies**: Tasks 1, 3
|
|
74
|
-
**Description**: Add comprehensive health monitoring, request timeouts, connection management, and enhanced structured logging.
|
|
75
|
-
|
|
76
|
-
### 8. TCP Client Library
|
|
77
|
-
**File**: `08-tcp-client-library.md`
|
|
78
|
-
**Priority**: Medium
|
|
79
|
-
**Dependencies**: Tasks 1, 4, 5
|
|
80
|
-
**Description**: Create Node.js client library with auto-reconnection, full operation support, and comprehensive error handling.
|
|
81
|
-
|
|
82
|
-
### 9. API Method Chaining Enhancement
|
|
83
|
-
**File**: `09-api-method-chaining.md`
|
|
84
|
-
**Priority**: High
|
|
85
|
-
**Dependencies**: Task 8
|
|
86
|
-
**Description**: Update the client API to chain methods off of `collection()` instead of passing collection names as the first argument, providing a more intuitive and fluent API interface.
|
|
87
|
-
|
|
88
|
-
### 10. Automatic Index Creation
|
|
89
|
-
**File**: `10-automatic-index-creation.md`
|
|
90
|
-
**Priority**: Medium
|
|
91
|
-
**Dependencies**: Task 2
|
|
92
|
-
**Description**: Implement automatic index creation based on query patterns to optimize database performance without requiring manual index management.
|
|
93
|
-
|
|
94
|
-
### 11. Operation Naming Consistency
|
|
95
|
-
**File**: `11-operation-naming-consistency.md`
|
|
96
|
-
**Priority**: Medium
|
|
97
|
-
**Dependencies**: Task 9
|
|
98
|
-
**Description**: Standardize the operation object structure to use snake_case naming consistently across the entire codebase and API.
|
|
99
|
-
|
|
100
|
-
### 12. TCP Replication System
|
|
101
|
-
**File**: `12-tcp-replication-system.md`
|
|
102
|
-
**Priority**: High
|
|
103
|
-
**Dependencies**: Tasks 1, 8
|
|
104
|
-
**Description**: Implement TCP-based replication to read-only secondary nodes with write forwarding, providing high availability and read scaling capabilities.
|
|
105
|
-
|
|
106
|
-
### 13. Master Node Read and Write Operations
|
|
107
|
-
**File**: `13-master-read-write-operations.md`
|
|
108
|
-
**Priority**: Medium
|
|
109
|
-
**Dependencies**: Task 12
|
|
110
|
-
**Description**: Ensure that master nodes in the cluster can handle both read and write operations, not just writes, improving load distribution and eliminating artificial restrictions.
|
|
111
|
-
|
|
112
|
-
### 14. Index Upsert Operations
|
|
113
|
-
**File**: `14-index-upsert-operations.md`
|
|
114
|
-
**Priority**: Medium
|
|
115
|
-
**Dependencies**: Task 2
|
|
116
|
-
**Description**: Implement index upsert functionality where indexes are created if they don't exist or updated if they do exist, providing seamless "create or update" operations for index management.
|
|
117
|
-
|
|
118
|
-
### 15. Client API Return Types Enhancement
|
|
119
|
-
**File**: `15-client-api-return-types.md`
|
|
120
|
-
**Priority**: High
|
|
121
|
-
**Dependencies**: Task 9
|
|
122
|
-
**Description**: Update the client API so that `find()` returns an array of matching documents and `find_one()` returns a single document (or null), providing more intuitive return types for developers.
|
|
123
|
-
|
|
124
|
-
### 16. Server Setup UI
|
|
125
|
-
**File**: `16-server-setup-ui.md`
|
|
126
|
-
**Priority**: Medium
|
|
127
|
-
**Dependencies**: Task 4
|
|
128
|
-
**Description**: Implement a minimalist web UI hosted by the server that provides a secure setup interface using randomly generated tokens, eliminating the need to connect a separate client for initial setup.
|
|
129
|
-
|
|
130
|
-
### 17. Emergency Password Change System
|
|
131
|
-
**File**: `17-emergency-password-change.md`
|
|
132
|
-
**Priority**: High
|
|
133
|
-
**Dependencies**: Tasks 4, 16
|
|
134
|
-
**Description**: Implement a secure emergency password change system using CLI-generated recovery tokens, allowing administrators to quickly change passwords in case of security breaches with minimal downtime.
|
|
135
|
-
|
|
136
|
-
## Implementation Guidelines
|
|
137
|
-
|
|
138
|
-
### Code Standards
|
|
139
|
-
- Use ESM syntax (`import`/`export`)
|
|
140
|
-
- Follow snake_case for variables, functions, and keys
|
|
141
|
-
- Prefer arrow functions
|
|
142
|
-
- Two-space indentation
|
|
143
|
-
- Minimal comments (only when necessary for clarity)
|
|
144
|
-
|
|
145
|
-
### Testing Requirements
|
|
146
|
-
- All existing tests must continue to pass (currently 119 tests)
|
|
147
|
-
- Add comprehensive test suites for each new feature
|
|
148
|
-
- Use AVA test runner with `--serial` flag
|
|
149
|
-
- Include both unit and integration tests
|
|
150
|
-
|
|
151
|
-
### Dependencies
|
|
152
|
-
- Keep existing: `lmdb`, `msgpackr`, `bcrypt`
|
|
153
|
-
- Add as needed: `@aws-sdk/client-s3`, `crypto`
|
|
154
|
-
- Maintain compatibility with existing codebase
|
|
155
|
-
|
|
156
|
-
## Getting Started
|
|
157
|
-
|
|
158
|
-
1. Choose a task based on priority and dependencies
|
|
159
|
-
2. Read the detailed prompt in the corresponding `.md` file
|
|
160
|
-
3. Create a new branch for the task (see Git Workflow below)
|
|
161
|
-
4. Implement the features following the specifications
|
|
162
|
-
5. Ensure all existing tests continue to pass
|
|
163
|
-
6. Add comprehensive tests for new functionality
|
|
164
|
-
7. Debug and fix any failing tests (no shortcuts or hacks allowed)
|
|
165
|
-
8. Merge branch to main only when all tests pass
|
|
166
|
-
9. Move to the next task
|
|
167
|
-
|
|
168
|
-
## Git Workflow
|
|
169
|
-
|
|
170
|
-
Each task must be implemented in a separate branch to maintain code quality and enable proper review:
|
|
171
|
-
|
|
172
|
-
### Branch Management
|
|
173
|
-
- **Branch Naming**: Use format `task-N-description` (e.g., `task-1-core-infrastructure`)
|
|
174
|
-
- **Create Branch**: `git checkout -b task-N-description` from main
|
|
175
|
-
- **Work Isolation**: All development for a task happens in its dedicated branch
|
|
176
|
-
- **No Partial Merges**: Only merge when task is 100% complete with all tests passing
|
|
177
|
-
|
|
178
|
-
### Development Process
|
|
179
|
-
1. **Start Task**: Create new branch from main
|
|
180
|
-
2. **Implement Features**: Follow task specifications exactly
|
|
181
|
-
3. **Write Tests**: Comprehensive test coverage for all new functionality
|
|
182
|
-
4. **Debug Thoroughly**: Fix all failing tests without shortcuts or hacks
|
|
183
|
-
5. **Verify Quality**: Run full test suite (`npm test`) - all 119+ tests must pass
|
|
184
|
-
6. **Merge to Main**: Only when everything works perfectly
|
|
185
|
-
|
|
186
|
-
### Quality Gates
|
|
187
|
-
- ✅ All existing tests continue to pass (119 baseline tests)
|
|
188
|
-
- ✅ New comprehensive tests for implemented features
|
|
189
|
-
- ✅ No failing tests (debug and fix, don't skip or hack)
|
|
190
|
-
- ✅ Code follows established patterns and standards
|
|
191
|
-
- ✅ No temporary workarounds or incomplete implementations
|
|
192
|
-
|
|
193
|
-
### Merge Requirements
|
|
194
|
-
```bash
|
|
195
|
-
# Before merging, verify:
|
|
196
|
-
npm test # All tests pass
|
|
197
|
-
git status # Clean working directory
|
|
198
|
-
git checkout main # Switch to main
|
|
199
|
-
git merge task-N-description # Merge completed task
|
|
200
|
-
git branch -d task-N-description # Clean up branch
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
## Cline Chat Management
|
|
204
|
-
|
|
205
|
-
This project is being developed using Cline, an AI coding assistant. To manage context window limits:
|
|
206
|
-
|
|
207
|
-
- **Context Threshold**: When context usage exceeds 50K tokens during development
|
|
208
|
-
- **Task Completion Rule**: Always complete the current task before starting a new chat
|
|
209
|
-
- **New Chat Process**: Once a task is complete and context > 50K tokens:
|
|
210
|
-
1. Update this README.md with task completion status
|
|
211
|
-
2. Generate a detailed prompt for the next task
|
|
212
|
-
3. Use Cline's "new task" feature to start fresh with the next task prompt
|
|
213
|
-
4. Include full context about completed work and current project state
|
|
214
|
-
|
|
215
|
-
## Notes
|
|
216
|
-
|
|
217
|
-
- Tasks 1, 3, and 7 are critical for production readiness
|
|
218
|
-
- Task 2 (indexing) significantly improves query performance
|
|
219
|
-
- Tasks 4, 5, 6, and 8 add important functionality but are less critical
|
|
220
|
-
- Each task is designed to be completed independently while building on previous work
|
|
221
|
-
- Context management ensures efficient development without losing important project context
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
# TypeScript Definition Generation from JSDoc
|
|
2
|
-
|
|
3
|
-
This document explains how to generate TypeScript definition files (.d.ts) from the JSDoc comments in the JoystickDB project.
|
|
4
|
-
|
|
5
|
-
## Prerequisites
|
|
6
|
-
|
|
7
|
-
Make sure you have TypeScript installed as a dev dependency:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install --save-dev typescript
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Configuration Files
|
|
14
|
-
|
|
15
|
-
### tsconfig.json
|
|
16
|
-
The TypeScript configuration file is set up to:
|
|
17
|
-
- Allow JavaScript files (`allowJs: true`)
|
|
18
|
-
- Generate only declaration files (`emitDeclarationOnly: true`)
|
|
19
|
-
- Output to the `./types` directory
|
|
20
|
-
- Include all files in `src/**/*.js`
|
|
21
|
-
- Exclude test files and node_modules
|
|
22
|
-
|
|
23
|
-
### package.json Scripts
|
|
24
|
-
Three npm scripts are available for type generation:
|
|
25
|
-
|
|
26
|
-
```json
|
|
27
|
-
{
|
|
28
|
-
"build:types": "tsc --declaration --emitDeclarationOnly --allowJs --outDir types src/**/*.js",
|
|
29
|
-
"build:types:client": "tsc --declaration --emitDeclarationOnly --allowJs --outDir types/client src/client/*.js",
|
|
30
|
-
"build:types:server": "tsc --declaration --emitDeclarationOnly --allowJs --outDir types/server src/server/**/*.js"
|
|
31
|
-
}
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Generating TypeScript Definitions
|
|
35
|
-
|
|
36
|
-
### Generate All Types
|
|
37
|
-
```bash
|
|
38
|
-
npm run build:types
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Generate Client Types Only
|
|
42
|
-
```bash
|
|
43
|
-
npm run build:types:client
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### Generate Server Types Only
|
|
47
|
-
```bash
|
|
48
|
-
npm run build:types:server
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### Manual Generation
|
|
52
|
-
You can also run TypeScript compiler directly:
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
# Generate all types
|
|
56
|
-
npx tsc
|
|
57
|
-
|
|
58
|
-
# Generate specific files
|
|
59
|
-
npx tsc --declaration --emitDeclarationOnly --allowJs --outDir types src/client/index.js
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Output Structure
|
|
63
|
-
|
|
64
|
-
After running the type generation, you'll find the TypeScript definition files in the `types/` directory:
|
|
65
|
-
|
|
66
|
-
```
|
|
67
|
-
types/
|
|
68
|
-
├── client/
|
|
69
|
-
│ └── index.d.ts # Client library types
|
|
70
|
-
└── server/
|
|
71
|
-
├── index.d.ts # Main server types
|
|
72
|
-
├── cluster/
|
|
73
|
-
│ ├── index.d.ts # Cluster management types
|
|
74
|
-
│ └── master.d.ts # Cluster master types
|
|
75
|
-
└── lib/
|
|
76
|
-
├── logger.d.ts # Logger types
|
|
77
|
-
├── tcp_protocol.d.ts # TCP protocol types
|
|
78
|
-
└── operations/
|
|
79
|
-
├── insert_one.d.ts # Insert operation types
|
|
80
|
-
├── find_one.d.ts # Find operation types
|
|
81
|
-
└── ... # Other operation types
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## Using the Generated Types
|
|
85
|
-
|
|
86
|
-
### In TypeScript Projects
|
|
87
|
-
```typescript
|
|
88
|
-
import { JoystickDBClient, ClientOptions } from './types/client/index.js';
|
|
89
|
-
|
|
90
|
-
const client: JoystickDBClient = joystickdb.client({
|
|
91
|
-
host: 'localhost',
|
|
92
|
-
port: 1983,
|
|
93
|
-
authentication: {
|
|
94
|
-
password: 'your-password'
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
### In JavaScript Projects with JSDoc
|
|
100
|
-
```javascript
|
|
101
|
-
/**
|
|
102
|
-
* @typedef {import('./types/client/index.js').ClientOptions} ClientOptions
|
|
103
|
-
* @typedef {import('./types/client/index.js').JoystickDBClient} JoystickDBClient
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
|
-
/** @type {ClientOptions} */
|
|
107
|
-
const options = {
|
|
108
|
-
host: 'localhost',
|
|
109
|
-
port: 1983
|
|
110
|
-
};
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
## Troubleshooting
|
|
114
|
-
|
|
115
|
-
### Common Issues
|
|
116
|
-
|
|
117
|
-
1. **"No inputs were found" error**: Make sure your JavaScript files have proper JSDoc comments and are in the correct directories.
|
|
118
|
-
|
|
119
|
-
2. **Import/Export issues**: Ensure your JavaScript files use proper ES module syntax (`import`/`export`).
|
|
120
|
-
|
|
121
|
-
3. **Missing types**: Check that your JSDoc comments use proper syntax:
|
|
122
|
-
- `@param {Type} name - description`
|
|
123
|
-
- `@returns {Type} description`
|
|
124
|
-
- `@typedef {Object} TypeName`
|
|
125
|
-
|
|
126
|
-
### Validating Generated Types
|
|
127
|
-
|
|
128
|
-
You can validate the generated types by creating a test TypeScript file:
|
|
129
|
-
|
|
130
|
-
```typescript
|
|
131
|
-
// test-types.ts
|
|
132
|
-
import { JoystickDBClient } from './types/client/index.js';
|
|
133
|
-
|
|
134
|
-
// This should compile without errors if types are correct
|
|
135
|
-
const client = new JoystickDBClient({
|
|
136
|
-
host: 'localhost',
|
|
137
|
-
port: 1983
|
|
138
|
-
});
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
Then compile it:
|
|
142
|
-
```bash
|
|
143
|
-
npx tsc test-types.ts --noEmit
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
## Continuous Integration
|
|
147
|
-
|
|
148
|
-
Add type generation to your CI/CD pipeline:
|
|
149
|
-
|
|
150
|
-
```yaml
|
|
151
|
-
# .github/workflows/ci.yml
|
|
152
|
-
- name: Generate TypeScript definitions
|
|
153
|
-
run: npm run build:types
|
|
154
|
-
|
|
155
|
-
- name: Validate generated types
|
|
156
|
-
run: npx tsc --noEmit types/**/*.d.ts
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
## Updating Types
|
|
160
|
-
|
|
161
|
-
When you modify JSDoc comments in your source files:
|
|
162
|
-
|
|
163
|
-
1. Run the type generation script again
|
|
164
|
-
2. Commit the updated `.d.ts` files to version control
|
|
165
|
-
3. Update version numbers if publishing to npm
|
|
166
|
-
|
|
167
|
-
## Publishing Types
|
|
168
|
-
|
|
169
|
-
If publishing to npm, include the types in your package.json:
|
|
170
|
-
|
|
171
|
-
```json
|
|
172
|
-
{
|
|
173
|
-
"main": "src/server/index.js",
|
|
174
|
-
"types": "types/server/index.d.ts",
|
|
175
|
-
"files": [
|
|
176
|
-
"src/",
|
|
177
|
-
"types/"
|
|
178
|
-
]
|
|
179
|
-
}
|
package/test_data/data.mdb
DELETED
|
Binary file
|
package/test_data/lock.mdb
DELETED
|
Binary file
|