tinybase 7.3.5 → 8.0.0-beta.1

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.
Files changed (59) hide show
  1. package/@types/index.d.ts +1 -0
  2. package/@types/middleware/index.d.ts +1064 -0
  3. package/@types/middleware/with-schemas/index.d.ts +1355 -0
  4. package/@types/omni/index.d.ts +1 -0
  5. package/@types/omni/with-schemas/index.d.ts +1 -0
  6. package/@types/store/index.d.ts +0 -1
  7. package/@types/with-schemas/index.d.ts +1 -0
  8. package/agents.md +33 -11
  9. package/checkpoints/index.js +8 -9
  10. package/checkpoints/with-schemas/index.js +8 -9
  11. package/index.js +484 -153
  12. package/mergeable-store/index.js +371 -135
  13. package/mergeable-store/with-schemas/index.js +371 -135
  14. package/middleware/index.js +130 -0
  15. package/middleware/with-schemas/index.js +130 -0
  16. package/min/checkpoints/index.js +1 -1
  17. package/min/checkpoints/index.js.gz +0 -0
  18. package/min/checkpoints/with-schemas/index.js +1 -1
  19. package/min/checkpoints/with-schemas/index.js.gz +0 -0
  20. package/min/index.js +1 -1
  21. package/min/index.js.gz +0 -0
  22. package/min/mergeable-store/index.js +1 -1
  23. package/min/mergeable-store/index.js.gz +0 -0
  24. package/min/mergeable-store/with-schemas/index.js +1 -1
  25. package/min/mergeable-store/with-schemas/index.js.gz +0 -0
  26. package/min/middleware/index.js +1 -0
  27. package/min/middleware/index.js.gz +0 -0
  28. package/min/middleware/with-schemas/index.js +1 -0
  29. package/min/middleware/with-schemas/index.js.gz +0 -0
  30. package/min/omni/index.js +1 -1
  31. package/min/omni/index.js.gz +0 -0
  32. package/min/omni/with-schemas/index.js +1 -1
  33. package/min/omni/with-schemas/index.js.gz +0 -0
  34. package/min/queries/index.js +1 -1
  35. package/min/queries/index.js.gz +0 -0
  36. package/min/queries/with-schemas/index.js +1 -1
  37. package/min/queries/with-schemas/index.js.gz +0 -0
  38. package/min/store/index.js +1 -1
  39. package/min/store/index.js.gz +0 -0
  40. package/min/store/with-schemas/index.js +1 -1
  41. package/min/store/with-schemas/index.js.gz +0 -0
  42. package/min/ui-react-inspector/index.js +1 -1
  43. package/min/ui-react-inspector/index.js.gz +0 -0
  44. package/min/ui-react-inspector/with-schemas/index.js +1 -1
  45. package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
  46. package/min/with-schemas/index.js +1 -1
  47. package/min/with-schemas/index.js.gz +0 -0
  48. package/omni/index.js +492 -161
  49. package/omni/with-schemas/index.js +492 -161
  50. package/package.json +37 -1
  51. package/queries/index.js +1 -6
  52. package/queries/with-schemas/index.js +1 -6
  53. package/readme.md +14 -14
  54. package/releases.md +41 -41
  55. package/store/index.js +370 -134
  56. package/store/with-schemas/index.js +370 -134
  57. package/ui-react-inspector/index.js +349 -134
  58. package/ui-react-inspector/with-schemas/index.js +349 -134
  59. package/with-schemas/index.js +484 -153
@@ -19,6 +19,7 @@ export * from '../common/index.d.ts';
19
19
  export * from '../indexes/index.d.ts';
20
20
  export * from '../mergeable-store/index.d.ts';
21
21
  export * from '../metrics/index.d.ts';
22
+ export * from '../middleware/index.d.ts';
22
23
  export * from '../persisters/index.d.ts';
23
24
  export * from '../persisters/persister-automerge/index.d.ts';
24
25
  export * from '../persisters/persister-browser/index.d.ts';
@@ -19,6 +19,7 @@ export * from '../../common/with-schemas/index.d.ts';
19
19
  export * from '../../indexes/with-schemas/index.d.ts';
20
20
  export * from '../../mergeable-store/with-schemas/index.d.ts';
21
21
  export * from '../../metrics/with-schemas/index.d.ts';
22
+ export * from '../../middleware/with-schemas/index.d.ts';
22
23
  export * from '../../persisters/persister-automerge/with-schemas/index.d.ts';
23
24
  export * from '../../persisters/persister-browser/with-schemas/index.d.ts';
24
25
  export * from '../../persisters/persister-cr-sqlite-wasm/with-schemas/index.d.ts';
@@ -7680,7 +7680,6 @@ export interface Store {
7680
7680
  * @since v5.0.0
7681
7681
  */
7682
7682
  isMergeable(): boolean;
7683
- //
7684
7683
  }
7685
7684
 
7686
7685
  /**
@@ -12,6 +12,7 @@ export * from '../common/with-schemas/index.d.ts';
12
12
  export * from '../indexes/with-schemas/index.d.ts';
13
13
  export * from '../mergeable-store/with-schemas/index.d.ts';
14
14
  export * from '../metrics/with-schemas/index.d.ts';
15
+ export * from '../middleware/with-schemas/index.d.ts';
15
16
  export * from '../queries/with-schemas/index.d.ts';
16
17
  export * from '../relationships/with-schemas/index.d.ts';
17
18
  export * from '../store/with-schemas/index.d.ts';
package/agents.md CHANGED
@@ -300,7 +300,7 @@ from source code and markdown files.
300
300
  source files for guides on the website.
301
301
 
302
302
  4. **Generated Files**: `/releases.md` and `/readme.md` in the root are
303
- **GENERATED** from `/site/guides/16_releases.md` and `/site/home/index.md`.
303
+ **GENERATED** from `/site/guides/17_releases.md` and `/site/home/index.md`.
304
304
  **Never edit the generated files directly**.
305
305
 
306
306
  ### Documentation Testing
@@ -314,12 +314,13 @@ npx vitest run ./test/unit/documentation.test.ts --retry=0
314
314
 
315
315
  **How it works**:
316
316
 
317
- - Extracts all code blocks from markdown files and `docs.js` files
318
- - Concatenates all examples from each file together
319
- - Parses and executes them to ensure they work
320
- - This means examples in the same file share scope
317
+ - Extracts code blocks from markdown files and `docs.js` files
318
+ - For **guide `.md` files**: concatenates all code blocks from the file together
319
+ and runs them as a single test — examples in the same file share scope
320
+ - For **`docs.js` files**: each `@example` block is extracted independently (via
321
+ regex) and run as its own isolated test — examples do NOT share scope
321
322
 
322
- **Critical constraints**:
323
+ **Critical constraints for guide `.md` files**:
323
324
 
324
325
  - Don't redeclare variables across examples in the same file
325
326
  - First example can declare `const store = createStore()`, subsequent examples
@@ -328,18 +329,30 @@ npx vitest run ./test/unit/documentation.test.ts --retry=0
328
329
  - Avoid async operations in examples unless necessary
329
330
  - Keep examples simple and focused
330
331
 
332
+ **Critical constraints for `docs.js` files**:
333
+
334
+ - Each `@example` block runs in complete isolation
335
+ - You CAN (and should) reuse simple variable names like `store`, `middleware`
336
+ across `@example` blocks — no suffixing needed
337
+ - Each `@example` must include its own imports and setup
338
+ - Keep examples self-contained
339
+ - Try to make the tests about simple data that relates to a real life pet store
340
+ (eg 'pets', 'species', 'employees' etc)
341
+
331
342
  **Common pitfalls**:
332
343
 
333
- - ❌ Declaring `const store` multiple times in the same file
344
+ - ❌ Declaring `const store` multiple times in the same **guide** file
334
345
  - ❌ Using undefined functions (forgot import statement)
335
- - First example: `const store = createStore()`
336
- - ✅ Later examples: `store.setCell(...)` (reuses existing store)
346
+ - Adding unnecessary suffixes (`store2`, `store3`) in `docs.js` examples
347
+ - ✅ First guide example: `const store = createStore()`
348
+ - ✅ Later guide examples: `store.setCell(...)` (reuses existing store)
349
+ - ✅ Each `docs.js` `@example`: `const store = createStore()` (independent)
337
350
 
338
351
  ### Adding New Documentation
339
352
 
340
353
  1. **API Documentation**: Edit `docs.js` file next to the type definition
341
354
  2. **Guide Content**: Edit markdown files in `/site/guides/`
342
- 3. **Release Notes**: Edit `/site/guides/16_releases.md` (not `/releases.md`)
355
+ 3. **Release Notes**: Edit `/site/guides/17_releases.md` (not `/releases.md`)
343
356
  4. **Always run documentation tests** after changes to verify examples work
344
357
 
345
358
  ## Creating New Schematizers
@@ -472,7 +485,7 @@ All code examples in a guide file are concatenated and executed as a test:
472
485
 
473
486
  When adding a new feature:
474
487
 
475
- 1. **Update `/site/guides/16_releases.md`** (NOT `/releases.md`):
488
+ 1. **Update `/site/guides/17_releases.md`** (NOT `/releases.md`):
476
489
  - Add new version section at the top
477
490
  - Include working code example that will be tested
478
491
  - Link to relevant guide if applicable
@@ -519,3 +532,12 @@ npm run testE2e # Run E2E tests to verify demos
519
532
  - You only need `compileForProd` once, unless you've changed TinyBase source
520
533
  - E2E tests use Playwright to verify demos work in a real browser
521
534
  - Individual E2E tests can be run for faster verification during iteration
535
+
536
+ ## Maintaining This Guide
537
+
538
+ At the end of each major project or task, add any new **general** learnings to
539
+ this file. This ensures future agents benefit from discoveries about the
540
+ codebase, build system, testing patterns, or documentation conventions. Only add
541
+ broadly applicable insights — not project-specific implementation details.
542
+
543
+
@@ -19,13 +19,6 @@ const arrayPop = (array) => array.pop();
19
19
  const arrayUnshift = (array, ...values) => array.unshift(...values);
20
20
  const arrayShift = (array) => array.shift();
21
21
 
22
- const setOrDelCell = (store, tableId, rowId, cellId, cell) =>
23
- isUndefined(cell)
24
- ? store.delCell(tableId, rowId, cellId, true)
25
- : store.setCell(tableId, rowId, cellId, cell);
26
- const setOrDelValue = (store, valueId, value) =>
27
- isUndefined(value) ? store.delValue(valueId) : store.setValue(valueId, value);
28
-
29
22
  const collSizeN = (collSizer) => (coll) =>
30
23
  arrayReduce(collValues(coll), (total, coll2) => total + collSizer(coll2), 0);
31
24
  const collSize = (coll) => coll?.size ?? 0;
@@ -207,12 +200,18 @@ const createCheckpoints = getCreateFunction(
207
200
  collForEach(cellsDelta2, (table, tableId) =>
208
201
  collForEach(table, (row, rowId) =>
209
202
  collForEach(row, (oldNew, cellId) =>
210
- setOrDelCell(store, tableId, rowId, cellId, oldNew[oldOrNew]),
203
+ store.setOrDelCell(
204
+ tableId,
205
+ rowId,
206
+ cellId,
207
+ oldNew[oldOrNew],
208
+ true,
209
+ ),
211
210
  ),
212
211
  ),
213
212
  );
214
213
  collForEach(valuesDelta2, (oldNew, valueId) =>
215
- setOrDelValue(store, valueId, oldNew[oldOrNew]),
214
+ store.setOrDelValue(valueId, oldNew[oldOrNew], true),
216
215
  );
217
216
  });
218
217
  listening = 1;
@@ -19,13 +19,6 @@ const arrayPop = (array) => array.pop();
19
19
  const arrayUnshift = (array, ...values) => array.unshift(...values);
20
20
  const arrayShift = (array) => array.shift();
21
21
 
22
- const setOrDelCell = (store, tableId, rowId, cellId, cell) =>
23
- isUndefined(cell)
24
- ? store.delCell(tableId, rowId, cellId, true)
25
- : store.setCell(tableId, rowId, cellId, cell);
26
- const setOrDelValue = (store, valueId, value) =>
27
- isUndefined(value) ? store.delValue(valueId) : store.setValue(valueId, value);
28
-
29
22
  const collSizeN = (collSizer) => (coll) =>
30
23
  arrayReduce(collValues(coll), (total, coll2) => total + collSizer(coll2), 0);
31
24
  const collSize = (coll) => coll?.size ?? 0;
@@ -207,12 +200,18 @@ const createCheckpoints = getCreateFunction(
207
200
  collForEach(cellsDelta2, (table, tableId) =>
208
201
  collForEach(table, (row, rowId) =>
209
202
  collForEach(row, (oldNew, cellId) =>
210
- setOrDelCell(store, tableId, rowId, cellId, oldNew[oldOrNew]),
203
+ store.setOrDelCell(
204
+ tableId,
205
+ rowId,
206
+ cellId,
207
+ oldNew[oldOrNew],
208
+ true,
209
+ ),
211
210
  ),
212
211
  ),
213
212
  );
214
213
  collForEach(valuesDelta2, (oldNew, valueId) =>
215
- setOrDelValue(store, valueId, oldNew[oldOrNew]),
214
+ store.setOrDelValue(valueId, oldNew[oldOrNew], true),
216
215
  );
217
216
  });
218
217
  listening = 1;