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.
- package/@types/index.d.ts +1 -0
- package/@types/middleware/index.d.ts +1064 -0
- package/@types/middleware/with-schemas/index.d.ts +1355 -0
- package/@types/omni/index.d.ts +1 -0
- package/@types/omni/with-schemas/index.d.ts +1 -0
- package/@types/store/index.d.ts +0 -1
- package/@types/with-schemas/index.d.ts +1 -0
- package/agents.md +33 -11
- package/checkpoints/index.js +8 -9
- package/checkpoints/with-schemas/index.js +8 -9
- package/index.js +484 -153
- package/mergeable-store/index.js +371 -135
- package/mergeable-store/with-schemas/index.js +371 -135
- package/middleware/index.js +130 -0
- package/middleware/with-schemas/index.js +130 -0
- package/min/checkpoints/index.js +1 -1
- package/min/checkpoints/index.js.gz +0 -0
- package/min/checkpoints/with-schemas/index.js +1 -1
- package/min/checkpoints/with-schemas/index.js.gz +0 -0
- package/min/index.js +1 -1
- package/min/index.js.gz +0 -0
- package/min/mergeable-store/index.js +1 -1
- package/min/mergeable-store/index.js.gz +0 -0
- package/min/mergeable-store/with-schemas/index.js +1 -1
- package/min/mergeable-store/with-schemas/index.js.gz +0 -0
- package/min/middleware/index.js +1 -0
- package/min/middleware/index.js.gz +0 -0
- package/min/middleware/with-schemas/index.js +1 -0
- package/min/middleware/with-schemas/index.js.gz +0 -0
- package/min/omni/index.js +1 -1
- package/min/omni/index.js.gz +0 -0
- package/min/omni/with-schemas/index.js +1 -1
- package/min/omni/with-schemas/index.js.gz +0 -0
- package/min/queries/index.js +1 -1
- package/min/queries/index.js.gz +0 -0
- package/min/queries/with-schemas/index.js +1 -1
- package/min/queries/with-schemas/index.js.gz +0 -0
- package/min/store/index.js +1 -1
- package/min/store/index.js.gz +0 -0
- package/min/store/with-schemas/index.js +1 -1
- package/min/store/with-schemas/index.js.gz +0 -0
- package/min/ui-react-inspector/index.js +1 -1
- package/min/ui-react-inspector/index.js.gz +0 -0
- package/min/ui-react-inspector/with-schemas/index.js +1 -1
- package/min/ui-react-inspector/with-schemas/index.js.gz +0 -0
- package/min/with-schemas/index.js +1 -1
- package/min/with-schemas/index.js.gz +0 -0
- package/omni/index.js +492 -161
- package/omni/with-schemas/index.js +492 -161
- package/package.json +37 -1
- package/queries/index.js +1 -6
- package/queries/with-schemas/index.js +1 -6
- package/readme.md +14 -14
- package/releases.md +41 -41
- package/store/index.js +370 -134
- package/store/with-schemas/index.js +370 -134
- package/ui-react-inspector/index.js +349 -134
- package/ui-react-inspector/with-schemas/index.js +349 -134
- package/with-schemas/index.js +484 -153
package/@types/omni/index.d.ts
CHANGED
|
@@ -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';
|
package/@types/store/index.d.ts
CHANGED
|
@@ -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/
|
|
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
|
|
318
|
-
-
|
|
319
|
-
|
|
320
|
-
-
|
|
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
|
-
-
|
|
336
|
-
- ✅
|
|
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/
|
|
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/
|
|
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
|
+
|
package/checkpoints/index.js
CHANGED
|
@@ -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(
|
|
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(
|
|
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(
|
|
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(
|
|
214
|
+
store.setOrDelValue(valueId, oldNew[oldOrNew], true),
|
|
216
215
|
);
|
|
217
216
|
});
|
|
218
217
|
listening = 1;
|