@rljson/db 0.0.11 → 0.0.13
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/README.architecture.md +859 -1
- package/README.contributors.md +534 -20
- package/README.public.md +943 -4
- package/README.trouble.md +49 -0
- package/dist/README.architecture.md +859 -1
- package/dist/README.contributors.md +534 -20
- package/dist/README.public.md +943 -4
- package/dist/README.trouble.md +49 -0
- package/dist/controller/controller.d.ts +2 -2
- package/dist/controller/tree-controller.d.ts +18 -0
- package/dist/db.d.ts +0 -6
- package/dist/db.js +317 -110
- package/dist/db.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/package.json +16 -16
|
@@ -1,32 +1,546 @@
|
|
|
1
|
-
|
|
2
|
-
@license
|
|
3
|
-
Copyright (c) 2025 Rljson
|
|
1
|
+
# @rljson/db - Contributors Guide
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
found in the LICENSE file in the root of this package.
|
|
7
|
-
-->
|
|
3
|
+
Welcome, contributor! This guide helps you get started with development, testing, and contributing to @rljson/db.
|
|
8
4
|
|
|
9
|
-
|
|
5
|
+
## Table of Contents
|
|
10
6
|
|
|
11
|
-
- [
|
|
12
|
-
- [
|
|
13
|
-
- [
|
|
14
|
-
- [
|
|
7
|
+
- [Getting Started](#getting-started)
|
|
8
|
+
- [Development Workflow](#development-workflow)
|
|
9
|
+
- [Project Structure](#project-structure)
|
|
10
|
+
- [Testing](#testing)
|
|
11
|
+
- [Code Quality](#code-quality)
|
|
12
|
+
- [Contributing Guidelines](#contributing-guidelines)
|
|
13
|
+
- [Release Process](#release-process)
|
|
14
|
+
- [Useful Commands](#useful-commands)
|
|
15
|
+
- [Architecture Overview](#architecture-overview)
|
|
16
|
+
- [Debugging](#debugging)
|
|
15
17
|
|
|
16
|
-
##
|
|
18
|
+
## Getting Started
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
### Prerequisites
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
- **Node.js:** >= 22.14.0
|
|
23
|
+
- **pnpm:** 10.6.3+ (package manager)
|
|
24
|
+
- **Git:** For version control
|
|
21
25
|
|
|
22
|
-
|
|
26
|
+
### Initial Setup
|
|
23
27
|
|
|
24
|
-
|
|
28
|
+
```bash
|
|
29
|
+
# Clone the repository
|
|
30
|
+
git clone https://github.com/rljson/db.git
|
|
31
|
+
cd db
|
|
25
32
|
|
|
26
|
-
|
|
33
|
+
# Install dependencies
|
|
34
|
+
pnpm install
|
|
27
35
|
|
|
28
|
-
|
|
36
|
+
# Run tests to verify setup
|
|
37
|
+
pnpm test
|
|
38
|
+
```
|
|
29
39
|
|
|
30
|
-
|
|
40
|
+
See also: [doc/workflows/prepare.md](doc/workflows/prepare.md)
|
|
31
41
|
|
|
32
|
-
|
|
42
|
+
## Development Workflow
|
|
43
|
+
|
|
44
|
+
### 1. Create a Feature Branch
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Create and switch to a new branch
|
|
48
|
+
git checkout -b feature/my-feature
|
|
49
|
+
|
|
50
|
+
# Or use the script
|
|
51
|
+
node scripts/create-branch.js feature/my-feature
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 2. Make Changes
|
|
55
|
+
|
|
56
|
+
Edit source files in `src/`:
|
|
57
|
+
- `src/core.ts` - Low-level Core class
|
|
58
|
+
- `src/db.ts` - High-level Db class
|
|
59
|
+
- `src/controller/` - Controller implementations
|
|
60
|
+
- `src/join/` - Join system
|
|
61
|
+
- `src/edit/` - Multi-edit system
|
|
62
|
+
- `src/notify.ts` - Notification system
|
|
63
|
+
- `src/tools/` - Utility functions
|
|
64
|
+
|
|
65
|
+
### 3. Write Tests
|
|
66
|
+
|
|
67
|
+
Add tests in `test/`:
|
|
68
|
+
- `test/db.spec.ts` - Db class tests (74 tests)
|
|
69
|
+
- `test/core.spec.ts` - Core class tests
|
|
70
|
+
- `test/controller.spec.ts` - Controller tests (45 tests)
|
|
71
|
+
- `test/join/` - Join system tests
|
|
72
|
+
- `test/edit/` - Edit system tests
|
|
73
|
+
|
|
74
|
+
**Test Pattern:**
|
|
75
|
+
```typescript
|
|
76
|
+
import { describe, it, expect } from 'vitest';
|
|
77
|
+
import { Db } from '../src/db.ts';
|
|
78
|
+
import { IoMem } from '@rljson/io';
|
|
79
|
+
|
|
80
|
+
describe('MyFeature', () => {
|
|
81
|
+
let db: Db;
|
|
82
|
+
|
|
83
|
+
beforeEach(async () => {
|
|
84
|
+
const io = new IoMem();
|
|
85
|
+
await io.init();
|
|
86
|
+
db = new Db(io);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('should do something', async () => {
|
|
90
|
+
// Arrange
|
|
91
|
+
const input = { ... };
|
|
92
|
+
|
|
93
|
+
// Act
|
|
94
|
+
const result = await db.someMethod(input);
|
|
95
|
+
|
|
96
|
+
// Assert
|
|
97
|
+
expect(result).toEqual(expected);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### 4. Run Tests
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Run all tests with coverage
|
|
106
|
+
pnpm test
|
|
107
|
+
|
|
108
|
+
# Run tests in watch mode (development)
|
|
109
|
+
pnpm run test -- --watch
|
|
110
|
+
|
|
111
|
+
# Run specific test file
|
|
112
|
+
pnpm run test -- db.spec.ts
|
|
113
|
+
|
|
114
|
+
# Run with specific pattern
|
|
115
|
+
pnpm run test -- --grep "tree INSERT"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 5. Lint and Format
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Run linter
|
|
122
|
+
pnpm run lint
|
|
123
|
+
|
|
124
|
+
# TypeScript type checking is automatic during build
|
|
125
|
+
pnpm run build
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 6. Update Documentation
|
|
129
|
+
|
|
130
|
+
If your changes affect the public API or behavior:
|
|
131
|
+
- Update [README.public.md](./README.public.md)
|
|
132
|
+
- Update [README.architecture.md](./README.architecture.md) for design changes
|
|
133
|
+
- Add troubleshooting entries to [README.trouble.md](./README.trouble.md) if needed
|
|
134
|
+
- Update [CHANGELOG.md](./CHANGELOG.md)
|
|
135
|
+
|
|
136
|
+
### 7. Commit and Push
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Add changes
|
|
140
|
+
git add .
|
|
141
|
+
|
|
142
|
+
# Commit with descriptive message
|
|
143
|
+
git commit -m "feat: add tree conditional expansion
|
|
144
|
+
|
|
145
|
+
- Add path parameter to TreeController.get()
|
|
146
|
+
- Prevent infinite recursion on large trees
|
|
147
|
+
- Update tests and documentation"
|
|
148
|
+
|
|
149
|
+
# Push to remote
|
|
150
|
+
git push origin feature/my-feature
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 8. Create Pull Request
|
|
154
|
+
|
|
155
|
+
Push your branch and create a pull request on GitHub.
|
|
156
|
+
|
|
157
|
+
See also: [doc/workflows/develop.md](doc/workflows/develop.md)
|
|
158
|
+
|
|
159
|
+
## Project Structure
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
rljson-db/
|
|
163
|
+
├── src/ # Source code
|
|
164
|
+
│ ├── core.ts # Core class (149 lines)
|
|
165
|
+
│ ├── db.ts # Db class (1822 lines)
|
|
166
|
+
│ ├── index.ts # Public exports
|
|
167
|
+
│ ├── notify.ts # Notification system (103 lines)
|
|
168
|
+
│ ├── connector/ # Connector implementations
|
|
169
|
+
│ │ └── connector.ts
|
|
170
|
+
│ ├── controller/ # Controller implementations
|
|
171
|
+
│ │ ├── base-controller.ts # Abstract base (159 lines)
|
|
172
|
+
│ │ ├── component-controller.ts # Components (504 lines)
|
|
173
|
+
│ │ ├── tree-controller.ts # Trees (394 lines)
|
|
174
|
+
│ │ ├── cake-controller.ts # Cakes (203 lines)
|
|
175
|
+
│ │ ├── layer-controller.ts # Layers
|
|
176
|
+
│ │ ├── slice-id-controller.ts # SliceIds
|
|
177
|
+
│ │ └── controller.ts # Factory and types
|
|
178
|
+
│ ├── edit/ # Multi-edit system
|
|
179
|
+
│ │ ├── edit-action.ts
|
|
180
|
+
│ │ ├── edit.ts
|
|
181
|
+
│ │ ├── multi-edit-manager.ts # Manager (262 lines)
|
|
182
|
+
│ │ └── multi-edit-processor.ts
|
|
183
|
+
│ ├── join/ # Join system
|
|
184
|
+
│ │ ├── join.ts # Main Join class (589 lines)
|
|
185
|
+
│ │ ├── filter/ # Row filtering
|
|
186
|
+
│ │ ├── selection/ # Column selection
|
|
187
|
+
│ │ ├── set-value/ # Value mutation
|
|
188
|
+
│ │ └── sort/ # Row sorting
|
|
189
|
+
│ └── tools/ # Utility functions
|
|
190
|
+
│ ├── inject.ts # Path-based injection
|
|
191
|
+
│ ├── isolate.ts # Path-based isolation
|
|
192
|
+
│ ├── make-unique.ts # Array deduplication
|
|
193
|
+
│ └── merge-trees.ts # Tree merging
|
|
194
|
+
├── test/ # Test suite
|
|
195
|
+
│ ├── test-setup.ts # Vitest configuration
|
|
196
|
+
│ ├── db.spec.ts # Db tests (74 tests)
|
|
197
|
+
│ ├── core.spec.ts # Core tests
|
|
198
|
+
│ ├── controller.spec.ts # Controller tests (45 tests)
|
|
199
|
+
│ ├── io-multi-tree-cascade.spec.ts # IoMulti tests (7 tests)
|
|
200
|
+
│ ├── mass-data.spec.ts # Performance tests
|
|
201
|
+
│ ├── connector/ # Connector tests
|
|
202
|
+
│ ├── edit/ # Edit system tests
|
|
203
|
+
│ ├── join/ # Join system tests
|
|
204
|
+
│ ├── goldens/ # Golden file tests
|
|
205
|
+
│ └── setup/ # Test setup utilities
|
|
206
|
+
├── doc/ # Documentation
|
|
207
|
+
│ ├── install/ # Installation guides
|
|
208
|
+
│ └── workflows/ # Development workflows
|
|
209
|
+
│ ├── prepare.md # Environment setup
|
|
210
|
+
│ ├── develop.md # Development guide
|
|
211
|
+
│ ├── debug-with-vscode.md # Debugging
|
|
212
|
+
│ ├── tools.md # Available tools
|
|
213
|
+
│ └── ...
|
|
214
|
+
├── scripts/ # Build and automation scripts
|
|
215
|
+
│ ├── publish-to-npm.js # NPM publishing
|
|
216
|
+
│ ├── add-version-tag.js # Git tagging
|
|
217
|
+
│ ├── run-in-all-repos.js # Monorepo utilities
|
|
218
|
+
│ └── ...
|
|
219
|
+
├── coverage/ # Test coverage reports
|
|
220
|
+
├── package.json # Dependencies and scripts
|
|
221
|
+
├── tsconfig.json # TypeScript configuration
|
|
222
|
+
├── vite.config.mts # Vite build configuration
|
|
223
|
+
├── vitest.config.mts # Vitest test configuration
|
|
224
|
+
├── eslint.config.js # ESLint configuration
|
|
225
|
+
└── README*.md # Documentation files
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## Testing
|
|
229
|
+
|
|
230
|
+
### Test Coverage
|
|
231
|
+
|
|
232
|
+
We maintain **100% code coverage**. All new code must include tests.
|
|
233
|
+
|
|
234
|
+
Current stats (361 tests):
|
|
235
|
+
- **db.spec.ts:** 74 tests (Db class operations)
|
|
236
|
+
- **controller.spec.ts:** 45 tests (All controllers)
|
|
237
|
+
- **io-multi-tree-cascade.spec.ts:** 7 tests (IoMulti integration)
|
|
238
|
+
- **core.spec.ts:** Core functionality
|
|
239
|
+
- **join tests:** Join system operations
|
|
240
|
+
- **edit tests:** Multi-edit operations
|
|
241
|
+
|
|
242
|
+
### Running Tests
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
# Run all tests with coverage
|
|
246
|
+
pnpm test
|
|
247
|
+
|
|
248
|
+
# Run in watch mode (auto-reruns on changes)
|
|
249
|
+
pnpm run test -- --watch
|
|
250
|
+
|
|
251
|
+
# Run specific file
|
|
252
|
+
pnpm run test -- controller.spec.ts
|
|
253
|
+
|
|
254
|
+
# Run with pattern matching
|
|
255
|
+
pnpm run test -- --grep "tree INSERT"
|
|
256
|
+
|
|
257
|
+
# Update golden files (test fixtures)
|
|
258
|
+
pnpm run updateGoldens
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Test Structure
|
|
262
|
+
|
|
263
|
+
Tests use Vitest with the following patterns:
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
describe('Feature', () => {
|
|
267
|
+
// Setup
|
|
268
|
+
let db: Db;
|
|
269
|
+
|
|
270
|
+
beforeEach(async () => {
|
|
271
|
+
const io = new IoMem();
|
|
272
|
+
await io.init();
|
|
273
|
+
db = new Db(io);
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
// Tests
|
|
277
|
+
it('should handle basic case', async () => {
|
|
278
|
+
// Test implementation
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it('should handle edge case', async () => {
|
|
282
|
+
// Test implementation
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Golden Files
|
|
288
|
+
|
|
289
|
+
Tests use golden files in `test/goldens/` for complex expected outputs:
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
import { readGolden, writeGolden } from './setup/golden.ts';
|
|
293
|
+
|
|
294
|
+
const result = await db.get(route, where);
|
|
295
|
+
const golden = await readGolden('path/to/golden.json');
|
|
296
|
+
expect(result).toEqual(golden);
|
|
297
|
+
|
|
298
|
+
// Update goldens (when intentional changes made)
|
|
299
|
+
if (process.env.UPDATE_GOLDENS) {
|
|
300
|
+
await writeGolden('path/to/golden.json', result);
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
## Code Quality
|
|
305
|
+
|
|
306
|
+
### TypeScript
|
|
307
|
+
|
|
308
|
+
All code is written in TypeScript with strict type checking:
|
|
309
|
+
|
|
310
|
+
```typescript
|
|
311
|
+
// Always specify return types
|
|
312
|
+
async function myFunction(param: string): Promise<Rljson> {
|
|
313
|
+
// ...
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Use type imports for types only
|
|
317
|
+
import type { Component, Tree } from '@rljson/rljson';
|
|
318
|
+
|
|
319
|
+
// Avoid 'any' - use specific types
|
|
320
|
+
const data: Rljson = await db.core.dump(); // Good
|
|
321
|
+
const data: any = await db.core.dump(); // Bad
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### ESLint
|
|
325
|
+
|
|
326
|
+
We use ESLint with TypeScript support:
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
# Run linter
|
|
330
|
+
pnpm run lint
|
|
331
|
+
|
|
332
|
+
# Configuration in eslint.config.js
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### Code Style
|
|
336
|
+
|
|
337
|
+
- Use **async/await** (not callbacks or raw promises)
|
|
338
|
+
- Add **JSDoc comments** for public APIs
|
|
339
|
+
- Keep functions **focused and small**
|
|
340
|
+
- Use **descriptive variable names**
|
|
341
|
+
- Prefer **const** over let
|
|
342
|
+
- Use **optional chaining** (`?.`) and **nullish coalescing** (`??`)
|
|
343
|
+
|
|
344
|
+
Example:
|
|
345
|
+
```typescript
|
|
346
|
+
/**
|
|
347
|
+
* Fetches data from the database by route
|
|
348
|
+
* @param route - The route to query
|
|
349
|
+
* @param where - Optional filter criteria
|
|
350
|
+
* @returns Container with query results
|
|
351
|
+
*/
|
|
352
|
+
async get(route: Route, where: Json): Promise<Container> {
|
|
353
|
+
// Implementation
|
|
354
|
+
}
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
## Contributing Guidelines
|
|
358
|
+
|
|
359
|
+
### Branch Naming
|
|
360
|
+
|
|
361
|
+
- `feature/description` - New features
|
|
362
|
+
- `fix/description` - Bug fixes
|
|
363
|
+
- `docs/description` - Documentation only
|
|
364
|
+
- `refactor/description` - Code refactoring
|
|
365
|
+
- `test/description` - Test improvements
|
|
366
|
+
|
|
367
|
+
### Commit Messages
|
|
368
|
+
|
|
369
|
+
Follow conventional commits:
|
|
370
|
+
|
|
371
|
+
```
|
|
372
|
+
type(scope): short description
|
|
373
|
+
|
|
374
|
+
Longer description if needed.
|
|
375
|
+
|
|
376
|
+
- Bullet points for details
|
|
377
|
+
- Multiple lines OK
|
|
378
|
+
|
|
379
|
+
Fixes #123
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
**Types:**
|
|
383
|
+
- `feat:` - New feature
|
|
384
|
+
- `fix:` - Bug fix
|
|
385
|
+
- `docs:` - Documentation
|
|
386
|
+
- `test:` - Tests
|
|
387
|
+
- `refactor:` - Code restructuring
|
|
388
|
+
- `perf:` - Performance improvement
|
|
389
|
+
- `chore:` - Maintenance
|
|
390
|
+
|
|
391
|
+
### Pull Requests
|
|
392
|
+
|
|
393
|
+
1. Create PR with clear title and description
|
|
394
|
+
2. Link related issues
|
|
395
|
+
3. Ensure all tests pass
|
|
396
|
+
4. Request review from maintainers
|
|
397
|
+
5. Address review feedback
|
|
398
|
+
6. Squash commits if requested
|
|
399
|
+
|
|
400
|
+
## Release Process
|
|
401
|
+
|
|
402
|
+
Releases are managed by maintainers. The process:
|
|
403
|
+
|
|
404
|
+
1. Update version in `package.json`
|
|
405
|
+
2. Update `CHANGELOG.md`
|
|
406
|
+
3. Create git tag: `node scripts/add-version-tag.js`
|
|
407
|
+
4. Publish to npm: `node scripts/publish-to-npm.js`
|
|
408
|
+
|
|
409
|
+
Version scheme: `MAJOR.MINOR.PATCH` (semver)
|
|
410
|
+
|
|
411
|
+
## Useful Commands
|
|
412
|
+
|
|
413
|
+
```bash
|
|
414
|
+
# Development
|
|
415
|
+
pnpm install # Install dependencies
|
|
416
|
+
pnpm test # Run tests with coverage
|
|
417
|
+
pnpm run build # Build for production
|
|
418
|
+
pnpm run lint # Run linter
|
|
419
|
+
|
|
420
|
+
# Testing
|
|
421
|
+
pnpm run test -- --watch # Watch mode
|
|
422
|
+
pnpm run test -- db.spec.ts # Specific file
|
|
423
|
+
pnpm run test -- --grep "pattern" # Pattern match
|
|
424
|
+
pnpm run updateGoldens # Update golden files
|
|
425
|
+
|
|
426
|
+
# Scripts
|
|
427
|
+
node scripts/create-branch.js feature/name # Create branch
|
|
428
|
+
node scripts/is-clean-repo.js # Check git status
|
|
429
|
+
node scripts/run-in-all-repos.js "command" # Run in all repos
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
## Architecture Overview
|
|
433
|
+
|
|
434
|
+
### Layer Diagram
|
|
435
|
+
|
|
436
|
+
```
|
|
437
|
+
Application
|
|
438
|
+
↓
|
|
439
|
+
Db (High-level API)
|
|
440
|
+
↓
|
|
441
|
+
Controllers (Type-specific logic)
|
|
442
|
+
↓
|
|
443
|
+
Core (Data management)
|
|
444
|
+
↓
|
|
445
|
+
Io (Storage backends)
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### Key Classes
|
|
449
|
+
|
|
450
|
+
- **Db:** Main entry point, route resolution, caching, notifications
|
|
451
|
+
- **Core:** Table management, data import/export, validation
|
|
452
|
+
- **Controller:** Abstract interface for table types
|
|
453
|
+
- TreeController - Hierarchical structures
|
|
454
|
+
- ComponentController - Flat tables
|
|
455
|
+
- CakeController - Multi-dimensional data
|
|
456
|
+
- LayerController - Layered configurations
|
|
457
|
+
- **Join:** SQL-like operations (select, filter, sort)
|
|
458
|
+
- **MultiEditManager:** Transactional editing
|
|
459
|
+
|
|
460
|
+
### Design Patterns
|
|
461
|
+
|
|
462
|
+
- **Controller Pattern:** Polymorphic table operations
|
|
463
|
+
- **Content-Addressing:** Data identified by hash
|
|
464
|
+
- **Immutability:** All mutations create new versions
|
|
465
|
+
- **Recursion with Safety:** Depth limits and memoization
|
|
466
|
+
- **Caching:** Query result memoization
|
|
467
|
+
|
|
468
|
+
See [README.architecture.md](./README.architecture.md) for deep dive.
|
|
469
|
+
|
|
470
|
+
## Debugging
|
|
471
|
+
|
|
472
|
+
### VS Code Debugging
|
|
473
|
+
|
|
474
|
+
See [doc/workflows/debug-with-vscode.md](doc/workflows/debug-with-vscode.md)
|
|
475
|
+
|
|
476
|
+
Launch configuration example:
|
|
477
|
+
```json
|
|
478
|
+
{
|
|
479
|
+
"type": "node",
|
|
480
|
+
"request": "launch",
|
|
481
|
+
"name": "Debug Tests",
|
|
482
|
+
"runtimeExecutable": "pnpm",
|
|
483
|
+
"runtimeArgs": ["test", "--", "--run"],
|
|
484
|
+
"console": "integratedTerminal"
|
|
485
|
+
}
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
### Debug Logging
|
|
489
|
+
|
|
490
|
+
Add strategic console.log statements (remove before commit):
|
|
491
|
+
|
|
492
|
+
```typescript
|
|
493
|
+
// Trace route resolution
|
|
494
|
+
console.log('Route:', route.flat);
|
|
495
|
+
console.log('Where:', JSON.stringify(where));
|
|
496
|
+
|
|
497
|
+
// Trace tree expansion
|
|
498
|
+
console.log(`Tree: ${tree.id}, path=${path}, expand=${path !== undefined}`);
|
|
499
|
+
|
|
500
|
+
// Trace cache behavior
|
|
501
|
+
console.log('Cache hit:', this._cache.has(cacheKey));
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
### Test Debugging
|
|
505
|
+
|
|
506
|
+
Run specific failing test:
|
|
507
|
+
```bash
|
|
508
|
+
pnpm run test -- --grep "exact test name"
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
Use `it.only` to isolate tests:
|
|
512
|
+
```typescript
|
|
513
|
+
it.only('should test specific thing', async () => {
|
|
514
|
+
// Only this test runs
|
|
515
|
+
});
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
### Common Issues
|
|
519
|
+
|
|
520
|
+
**Issue:** Tests fail with "Maximum recursion depth"
|
|
521
|
+
**Solution:** Check TreeController path parameter handling
|
|
522
|
+
|
|
523
|
+
**Issue:** Cache not clearing after insert
|
|
524
|
+
**Solution:** Verify notify callbacks are registered
|
|
525
|
+
|
|
526
|
+
**Issue:** Golden file mismatch
|
|
527
|
+
**Solution:** Run `pnpm run updateGoldens` if changes are intentional
|
|
528
|
+
|
|
529
|
+
## Additional Resources
|
|
530
|
+
|
|
531
|
+
- [README.architecture.md](./README.architecture.md) - Technical architecture deep dive
|
|
532
|
+
- [README.trouble.md](./README.trouble.md) - Troubleshooting guide
|
|
533
|
+
- [doc/workflows/](./doc/workflows/) - Detailed workflow guides
|
|
534
|
+
- [GitHub Issues](https://github.com/rljson/db/issues) - Bug reports and feature requests
|
|
535
|
+
|
|
536
|
+
## Getting Help
|
|
537
|
+
|
|
538
|
+
- **Issues:** Report bugs via [GitHub Issues](https://github.com/rljson/db/issues)
|
|
539
|
+
- **Discussions:** Ask questions in GitHub Discussions
|
|
540
|
+
- **Code Review:** Request maintainer review on PRs
|
|
541
|
+
|
|
542
|
+
## License
|
|
543
|
+
|
|
544
|
+
MIT - See [LICENSE](./LICENSE)
|
|
545
|
+
|
|
546
|
+
Thank you for contributing to @rljson/db!
|