tinybase 7.1.0-beta.2 → 7.1.0-beta.3

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 (30) hide show
  1. package/@types/schematizers/index.d.ts +57 -0
  2. package/@types/schematizers/schematizer-valibot/index.d.ts +114 -0
  3. package/@types/schematizers/schematizer-valibot/with-schemas/index.d.ts +8 -0
  4. package/min/schematizers/index.js +1 -1
  5. package/min/schematizers/index.js.gz +0 -0
  6. package/min/schematizers/schematizer-typebox/index.js +1 -1
  7. package/min/schematizers/schematizer-typebox/index.js.gz +0 -0
  8. package/min/schematizers/schematizer-typebox/with-schemas/index.js +1 -1
  9. package/min/schematizers/schematizer-typebox/with-schemas/index.js.gz +0 -0
  10. package/min/schematizers/schematizer-valibot/index.js +1 -0
  11. package/min/schematizers/schematizer-valibot/index.js.gz +0 -0
  12. package/min/schematizers/schematizer-valibot/with-schemas/index.js +1 -0
  13. package/min/schematizers/schematizer-valibot/with-schemas/index.js.gz +0 -0
  14. package/min/schematizers/schematizer-zod/index.js +1 -1
  15. package/min/schematizers/schematizer-zod/index.js.gz +0 -0
  16. package/min/schematizers/schematizer-zod/with-schemas/index.js +1 -1
  17. package/min/schematizers/schematizer-zod/with-schemas/index.js.gz +0 -0
  18. package/min/schematizers/with-schemas/index.js +1 -1
  19. package/min/schematizers/with-schemas/index.js.gz +0 -0
  20. package/package.json +41 -1
  21. package/readme.md +3 -3
  22. package/releases.md +2 -2
  23. package/schematizers/index.js +89 -0
  24. package/schematizers/schematizer-typebox/index.js +39 -38
  25. package/schematizers/schematizer-typebox/with-schemas/index.js +39 -38
  26. package/schematizers/schematizer-valibot/index.js +106 -0
  27. package/schematizers/schematizer-valibot/with-schemas/index.js +106 -0
  28. package/schematizers/schematizer-zod/index.js +39 -35
  29. package/schematizers/schematizer-zod/with-schemas/index.js +39 -35
  30. package/schematizers/with-schemas/index.js +89 -0
@@ -39,3 +39,60 @@ export interface Schematizer {
39
39
  */
40
40
  toValuesSchema(schemas: any): ValuesSchema;
41
41
  }
42
+
43
+ /**
44
+ * The createCustomSchematizer function creates a custom Schematizer that can
45
+ * convert schemas from any validation library into TinyBase schemas.
46
+ *
47
+ * This function allows you to build schematizers for validation libraries not
48
+ * natively supported by TinyBase. You provide two functions: one to unwrap
49
+ * optional/nullable/default wrappers from your library's schemas, and one to
50
+ * extract object properties.
51
+ * @param unwrapSchema - A function that unwraps a schema to extract the base
52
+ * type, default value, and nullable flag. It should recursively unwrap
53
+ * optional/nullable wrappers and return a tuple of [schema, defaultValue,
54
+ * allowNull].
55
+ * @param getProperties - A function that extracts the properties/entries/shape
56
+ * from an object schema. Returns undefined if the schema is not an object.
57
+ * @returns A new Schematizer instance.
58
+ * @example
59
+ * This example creates a custom schematizer for a hypothetical validation
60
+ * library.
61
+ *
62
+ * ```js
63
+ * import {createCustomSchematizer} from 'tinybase/schematizers';
64
+ *
65
+ * // Hypothetical library has schemas like:
66
+ * // {type: 'string'}, {type: 'optional', inner: ...}, etc.
67
+ *
68
+ * const unwrapSchema = (schema, defaultValue, allowNull) => {
69
+ * if (schema.type === 'optional') {
70
+ * return unwrapSchema(schema.inner, defaultValue, allowNull);
71
+ * }
72
+ * if (schema.type === 'nullable') {
73
+ * return unwrapSchema(schema.inner, defaultValue, true);
74
+ * }
75
+ * return [schema, defaultValue ?? schema.default, allowNull ?? false];
76
+ * };
77
+ *
78
+ * const getProperties = (schema) => schema.fields;
79
+ *
80
+ * const schematizer = createCustomSchematizer(unwrapSchema, getProperties);
81
+ *
82
+ * const tablesSchema = schematizer.toTablesSchema({
83
+ * pets: {type: 'object', fields: {name: {type: 'string'}}},
84
+ * });
85
+ * console.log(tablesSchema);
86
+ * // -> {pets: {name: {type: 'string'}}}
87
+ * ```
88
+ * @category Creation
89
+ * @since v7.1.0
90
+ */
91
+ export function createCustomSchematizer(
92
+ unwrapSchema: (
93
+ schema: any,
94
+ defaultValue?: any,
95
+ allowNull?: boolean,
96
+ ) => [any, any, boolean],
97
+ getProperties: (schema: any) => any | undefined,
98
+ ): Schematizer;
@@ -0,0 +1,114 @@
1
+ /**
2
+ * The schematizer-valibot module provides conversion utilities for Valibot
3
+ * schemas.
4
+ * @packageDocumentation
5
+ * @module schematizer-valibot
6
+ * @since v7.1.0
7
+ */
8
+ import type {TablesSchema, ValuesSchema} from '../../store/index.d.ts';
9
+ import type {Schematizer} from '../index.d.ts';
10
+
11
+ /**
12
+ * The ValibotSchematizer interface represents a schematizer specifically for
13
+ * converting Valibot schemas into TinyBase schemas.
14
+ * @category Schematizer
15
+ * @since v7.1.0
16
+ */
17
+ export interface ValibotSchematizer extends Schematizer {
18
+ /**
19
+ * The toTablesSchema method converts a mapping of Valibot object schemas into a
20
+ * TinyBase TablesSchema.
21
+ *
22
+ * This method extracts basic type information (string, number, boolean),
23
+ * fallback values, and nullable flags from Valibot schemas. Complex validation
24
+ * rules like min/max, regex patterns, refinements, and transforms are ignored.
25
+ * @param schemas - A mapping of table IDs to Valibot object schemas.
26
+ * @returns A TinyBase TablesSchema.
27
+ * @example
28
+ * This example converts Valibot schemas to TinyBase format.
29
+ *
30
+ * ```js
31
+ * import {createStore} from 'tinybase';
32
+ * import {createValibotSchematizer} from 'tinybase/schematizers/schematizer-valibot';
33
+ * import {boolean, fallback, number, object, string} from 'valibot';
34
+ *
35
+ * const schematizer = createValibotSchematizer();
36
+ *
37
+ * const tablesSchema = schematizer.toTablesSchema({
38
+ * pets: object({
39
+ * species: string(),
40
+ * age: number(),
41
+ * sold: fallback(boolean(), false),
42
+ * }),
43
+ * });
44
+ *
45
+ * const store = createStore().setTablesSchema(tablesSchema);
46
+ * store.setRow('pets', 'fido', {species: 'dog', age: 3});
47
+ * console.log(store.getRow('pets', 'fido'));
48
+ * // -> {species: 'dog', age: 3, sold: false}
49
+ * ```
50
+ * @category Conversion
51
+ * @since v7.1.0
52
+ */
53
+ toTablesSchema(schemas: {[tableId: string]: any}): TablesSchema;
54
+
55
+ /**
56
+ * The toValuesSchema method converts a mapping of Valibot schemas into a
57
+ * TinyBase ValuesSchema.
58
+ *
59
+ * This method extracts basic type information and fallback values from Valibot
60
+ * schemas.
61
+ * @param schemas - A mapping of value IDs to Valibot schemas.
62
+ * @returns A TinyBase ValuesSchema.
63
+ * @example
64
+ * This example converts Valibot value schemas.
65
+ *
66
+ * ```js
67
+ * import {createStore} from 'tinybase';
68
+ * import {createValibotSchematizer} from 'tinybase/schematizers/schematizer-valibot';
69
+ * import {fallback, number, string} from 'valibot';
70
+ *
71
+ * const schematizer = createValibotSchematizer();
72
+ *
73
+ * const valuesSchema = schematizer.toValuesSchema({
74
+ * theme: fallback(string(), 'light'),
75
+ * count: number(),
76
+ * });
77
+ *
78
+ * const store = createStore().setValuesSchema(valuesSchema);
79
+ * console.log(store.getValues());
80
+ * // -> {theme: 'light'}
81
+ * ```
82
+ * @category Conversion
83
+ * @since v7.1.0
84
+ */
85
+ toValuesSchema(schemas: {[valueId: string]: any}): ValuesSchema;
86
+ }
87
+
88
+ /**
89
+ * The createValibotSchematizer function creates a ValibotSchematizer object
90
+ * that can convert Valibot schemas into TinyBase schemas.
91
+ *
92
+ * The schematizer is stateless and can be reused for multiple conversions.
93
+ * @returns A new ValibotSchematizer instance.
94
+ * @example
95
+ * This example creates a Valibot schematizer and uses it to convert schemas.
96
+ *
97
+ * ```js
98
+ * import {createValibotSchematizer} from 'tinybase/schematizers/schematizer-valibot';
99
+ * import {object, string} from 'valibot';
100
+ *
101
+ * const schematizer = createValibotSchematizer();
102
+ *
103
+ * const tablesSchema = schematizer.toTablesSchema({
104
+ * pets: object({
105
+ * species: string(),
106
+ * }),
107
+ * });
108
+ * console.log(tablesSchema);
109
+ * // -> {pets: {species: {type: 'string'}}}
110
+ * ```
111
+ * @category Creation
112
+ * @since v7.1.0
113
+ */
114
+ export function createValibotSchematizer(): ValibotSchematizer;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The schematizer-valibot module provides conversion utilities for Valibot
3
+ * schemas.
4
+ * @packageDocumentation
5
+ * @module schematizer-valibot
6
+ * @since v7.1.0
7
+ */
8
+ export type {ValibotSchematizer} from '../index.d.ts';
@@ -1 +1 @@
1
-
1
+ const t=t=>typeof t,e=t(""),o=t(!0),r=t(0),n="type",s=t=>(e,o,r)=>t(e)?r?.():o(e),c=t=>null==t,l=s(c),u=s(t=>void 0===t),a=Object,f=t=>a.getPrototypeOf(t),p=a.entries,y=a.keys,h=a.freeze,i=(t=[])=>a.fromEntries(t),m=(t,e)=>((t,e)=>t.forEach(e))(p(t),([t,o])=>e(o,t)),b=(t,s)=>{const p=s=>{const[c,l,a]=t(s),f=c?.type;if(f!==e&&f!==r&&f!==o)return;const p={[n]:f};return u(l,t=>{p.default=t}),a&&(p.allowNull=!0),p};return h({toTablesSchema:t=>{const e=i();return m(t,(t,o)=>{const r=i();var n;u(s(t),t=>m(t,(t,e)=>u(p(t),t=>{r[e]=t}))),(t=>!c(t)&&l(f(t),t=>t==a.prototype||c(f(t)),()=>!0))(n=r)&&0==(t=>y(t).length)(n)||(e[o]=r)}),e},toValuesSchema:t=>{const e=i();return m(t,(t,o)=>u(p(t),t=>{e[o]=t})),e}})};export{b as createCustomSchematizer};
Binary file
@@ -1 +1 @@
1
- const t=t=>typeof t,e=t(""),r=t(!0),n=t(0),o="type",s="default",c="null",l=t=>(e,r,n)=>t(e)?n?.():r(e),u=t=>null==t,f=l(u),p=l(t=>void 0===t),a=Object,y=t=>a.getPrototypeOf(t),i=a.entries,h=a.keys,m=a.freeze,d=(t=[])=>a.fromEntries(t),O=(t,e)=>((t,e)=>t.forEach(e))(i(t),([t,r])=>e(r,t)),b="anyOf",g=(t,e,r)=>{if(t?.[b]){const r=t[b],n=r.some(t=>t?.type===c),o=r.find(t=>t?.type!==c);if(n&&o)return g(o,e??t?.[s],!0)}return[t,e??t?.[s],r??!1]},v=()=>{const t=t=>{const[c,l,u]=g(t),f=c?.type;if(f!==e&&f!==n&&f!==r)return;const a={[o]:f};return p(l,t=>{a[s]=t}),u&&(a.allowNull=!0),a};return m({toTablesSchema:e=>{const r=d();return O(e,(e,n)=>{const o=d();var s;p(e?.properties,e=>O(e,(e,r)=>p(t(e),t=>{o[r]=t}))),(t=>!u(t)&&f(y(t),t=>t==a.prototype||u(y(t)),()=>!0))(s=o)&&0==(t=>h(t).length)(s)||(r[n]=o)}),r},toValuesSchema:e=>{const r=d();return O(e,(e,n)=>p(t(e),t=>{r[n]=t})),r}})};export{v as createTypeBoxSchematizer};
1
+ const t=t=>typeof t,e=t(""),r=t(!0),n=t(0),o="type",s="default",c="null",l=t=>(e,r,n)=>t(e)?n?.():r(e),u=t=>null==t,f=l(u),p=l(t=>void 0===t),a=Object,y=t=>a.getPrototypeOf(t),i=a.entries,h=a.keys,m=a.freeze,d=(t=[])=>a.fromEntries(t),O=(t,e)=>((t,e)=>t.forEach(e))(i(t),([t,r])=>e(r,t)),b="anyOf",g=(t,e,r)=>{if(t?.[b]){const r=t[b],n=r.some(t=>t?.type===c),o=r.find(t=>t?.type!==c);if(n&&o)return g(o,e??t?.[s],!0)}return[t,e??t?.[s],r??!1]},v=t=>t?.properties,E=()=>((t,c)=>{const l=c=>{const[l,u,f]=t(c),a=l?.type;if(a!==e&&a!==n&&a!==r)return;const y={[o]:a};return p(u,t=>{y[s]=t}),f&&(y.allowNull=!0),y};return m({toTablesSchema:t=>{const e=d();return O(t,(t,r)=>{const n=d();var o;p(c(t),t=>O(t,(t,e)=>p(l(t),t=>{n[e]=t}))),(t=>!u(t)&&f(y(t),t=>t==a.prototype||u(y(t)),()=>!0))(o=n)&&0==(t=>h(t).length)(o)||(e[r]=n)}),e},toValuesSchema:t=>{const e=d();return O(t,(t,r)=>p(l(t),t=>{e[r]=t})),e}})})(g,v);export{E as createTypeBoxSchematizer};
@@ -1 +1 @@
1
- const t=t=>typeof t,e=t(""),r=t(!0),n=t(0),o="type",s="default",c="null",l=t=>(e,r,n)=>t(e)?n?.():r(e),u=t=>null==t,f=l(u),p=l(t=>void 0===t),a=Object,y=t=>a.getPrototypeOf(t),i=a.entries,h=a.keys,m=a.freeze,d=(t=[])=>a.fromEntries(t),O=(t,e)=>((t,e)=>t.forEach(e))(i(t),([t,r])=>e(r,t)),b="anyOf",g=(t,e,r)=>{if(t?.[b]){const r=t[b],n=r.some(t=>t?.type===c),o=r.find(t=>t?.type!==c);if(n&&o)return g(o,e??t?.[s],!0)}return[t,e??t?.[s],r??!1]},v=()=>{const t=t=>{const[c,l,u]=g(t),f=c?.type;if(f!==e&&f!==n&&f!==r)return;const a={[o]:f};return p(l,t=>{a[s]=t}),u&&(a.allowNull=!0),a};return m({toTablesSchema:e=>{const r=d();return O(e,(e,n)=>{const o=d();var s;p(e?.properties,e=>O(e,(e,r)=>p(t(e),t=>{o[r]=t}))),(t=>!u(t)&&f(y(t),t=>t==a.prototype||u(y(t)),()=>!0))(s=o)&&0==(t=>h(t).length)(s)||(r[n]=o)}),r},toValuesSchema:e=>{const r=d();return O(e,(e,n)=>p(t(e),t=>{r[n]=t})),r}})};export{v as createTypeBoxSchematizer};
1
+ const t=t=>typeof t,e=t(""),r=t(!0),n=t(0),o="type",s="default",c="null",l=t=>(e,r,n)=>t(e)?n?.():r(e),u=t=>null==t,f=l(u),p=l(t=>void 0===t),a=Object,y=t=>a.getPrototypeOf(t),i=a.entries,h=a.keys,m=a.freeze,d=(t=[])=>a.fromEntries(t),O=(t,e)=>((t,e)=>t.forEach(e))(i(t),([t,r])=>e(r,t)),b="anyOf",g=(t,e,r)=>{if(t?.[b]){const r=t[b],n=r.some(t=>t?.type===c),o=r.find(t=>t?.type!==c);if(n&&o)return g(o,e??t?.[s],!0)}return[t,e??t?.[s],r??!1]},v=t=>t?.properties,E=()=>((t,c)=>{const l=c=>{const[l,u,f]=t(c),a=l?.type;if(a!==e&&a!==n&&a!==r)return;const y={[o]:a};return p(u,t=>{y[s]=t}),f&&(y.allowNull=!0),y};return m({toTablesSchema:t=>{const e=d();return O(t,(t,r)=>{const n=d();var o;p(c(t),t=>O(t,(t,e)=>p(l(t),t=>{n[e]=t}))),(t=>!u(t)&&f(y(t),t=>t==a.prototype||u(y(t)),()=>!0))(o=n)&&0==(t=>h(t).length)(o)||(e[r]=n)}),e},toValuesSchema:t=>{const e=d();return O(t,(t,r)=>p(l(t),t=>{e[r]=t})),e}})})(g,v);export{E as createTypeBoxSchematizer};
@@ -0,0 +1 @@
1
+ const t=t=>typeof t,e=t(""),r=t(!0),o=t(0),n="type",l=t=>(e,r,o)=>t(e)?o?.():r(e),s=t=>null==t,a=l(s),c=l(t=>void 0===t),p=Object,u=t=>p.getPrototypeOf(t),f=p.entries,y=p.keys,i=p.freeze,b=(t=[])=>p.fromEntries(t),h=(t,e)=>((t,e)=>t.forEach(e))(f(t),([t,r])=>e(r,t)),d="wrapped",m=(t,e,r)=>{const o=t?.type;return"optional"===o?m(t[d],e,r):"nullable"===o?m(t[d],e,!0):[t,e??t?.fallback,r??!1]},g=t=>t?.entries,k=()=>((t,l)=>{const f=l=>{const[s,a,p]=t(l),u=s?.type;if(u!==e&&u!==o&&u!==r)return;const f={[n]:u};return c(a,t=>{f.default=t}),p&&(f.allowNull=!0),f};return i({toTablesSchema:t=>{const e=b();return h(t,(t,r)=>{const o=b();var n;c(l(t),t=>h(t,(t,e)=>c(f(t),t=>{o[e]=t}))),(t=>!s(t)&&a(u(t),t=>t==p.prototype||s(u(t)),()=>!0))(n=o)&&0==(t=>y(t).length)(n)||(e[r]=o)}),e},toValuesSchema:t=>{const e=b();return h(t,(t,r)=>c(f(t),t=>{e[r]=t})),e}})})(m,g);export{k as createValibotSchematizer};
@@ -0,0 +1 @@
1
+ const t=t=>typeof t,e=t(""),r=t(!0),o=t(0),n="type",l=t=>(e,r,o)=>t(e)?o?.():r(e),s=t=>null==t,a=l(s),c=l(t=>void 0===t),p=Object,u=t=>p.getPrototypeOf(t),f=p.entries,y=p.keys,i=p.freeze,b=(t=[])=>p.fromEntries(t),h=(t,e)=>((t,e)=>t.forEach(e))(f(t),([t,r])=>e(r,t)),d="wrapped",m=(t,e,r)=>{const o=t?.type;return"optional"===o?m(t[d],e,r):"nullable"===o?m(t[d],e,!0):[t,e??t?.fallback,r??!1]},g=t=>t?.entries,k=()=>((t,l)=>{const f=l=>{const[s,a,p]=t(l),u=s?.type;if(u!==e&&u!==o&&u!==r)return;const f={[n]:u};return c(a,t=>{f.default=t}),p&&(f.allowNull=!0),f};return i({toTablesSchema:t=>{const e=b();return h(t,(t,r)=>{const o=b();var n;c(l(t),t=>h(t,(t,e)=>c(f(t),t=>{o[e]=t}))),(t=>!s(t)&&a(u(t),t=>t==p.prototype||s(u(t)),()=>!0))(n=o)&&0==(t=>y(t).length)(n)||(e[r]=o)}),e},toValuesSchema:t=>{const e=b();return h(t,(t,r)=>c(f(t),t=>{e[r]=t})),e}})})(m,g);export{k as createValibotSchematizer};
@@ -1 +1 @@
1
- const e=e=>typeof e,t=e(""),n=e(!0),r=e(0),o="type",l="default",f=e=>(t,n,r)=>e(t)?r?.():n(t),s=e=>null==e,a=f(s),p=f(e=>void 0===e),u=Object,c=e=>u.getPrototypeOf(e),y=u.entries,d=u.keys,i=u.freeze,h=(e=[])=>u.fromEntries(e),T=(e,t)=>((e,t)=>e.forEach(t))(y(e),([e,n])=>t(n,e)),b=(e,t,n)=>{const r=e?.def?.type;return"optional"===r?b(e.def.innerType,t,n):"nullable"===r?b(e.def.innerType,t,!0):r===l?b(e.def.innerType,e.def.defaultValue,n):[e,t,n??!1]},m=()=>{const e=e=>{const[f,s,a]=b(e),u=f?.type;if(u!==t&&u!==r&&u!==n)return;const c={[o]:u};return p(s,e=>{c[l]=e}),a&&(c.allowNull=!0),c};return i({toTablesSchema:t=>{const n=h();return T(t,(t,r)=>{const o=h();var l;p(t?.def?.shape,t=>T(t,(t,n)=>p(e(t),e=>{o[n]=e}))),(e=>!s(e)&&a(c(e),e=>e==u.prototype||s(c(e)),()=>!0))(l=o)&&0==(e=>d(e).length)(l)||(n[r]=o)}),n},toValuesSchema:t=>{const n=h();return T(t,(t,r)=>p(e(t),e=>{n[r]=e})),n}})};export{m as createZodSchematizer};
1
+ const e=e=>typeof e,t=e(""),n=e(!0),r=e(0),o="type",l="default",f=e=>(t,n,r)=>e(t)?r?.():n(t),s=e=>null==e,a=f(s),p=f(e=>void 0===e),u=Object,c=e=>u.getPrototypeOf(e),y=u.entries,d=u.keys,i=u.freeze,h=(e=[])=>u.fromEntries(e),T=(e,t)=>((e,t)=>e.forEach(t))(y(e),([e,n])=>t(n,e)),b=(e,t,n)=>{const r=e?.def?.type;return"optional"===r?b(e.def.innerType,t,n):"nullable"===r?b(e.def.innerType,t,!0):r===l?b(e.def.innerType,e.def.defaultValue,n):[e,t,n??!1]},m=e=>e?.def?.shape,g=()=>((e,f)=>{const y=f=>{const[s,a,u]=e(f),c=s?.type;if(c!==t&&c!==r&&c!==n)return;const y={[o]:c};return p(a,e=>{y[l]=e}),u&&(y.allowNull=!0),y};return i({toTablesSchema:e=>{const t=h();return T(e,(e,n)=>{const r=h();var o;p(f(e),e=>T(e,(e,t)=>p(y(e),e=>{r[t]=e}))),(e=>!s(e)&&a(c(e),e=>e==u.prototype||s(c(e)),()=>!0))(o=r)&&0==(e=>d(e).length)(o)||(t[n]=r)}),t},toValuesSchema:e=>{const t=h();return T(e,(e,n)=>p(y(e),e=>{t[n]=e})),t}})})(b,m);export{g as createZodSchematizer};
@@ -1 +1 @@
1
- const e=e=>typeof e,t=e(""),n=e(!0),r=e(0),o="type",l="default",f=e=>(t,n,r)=>e(t)?r?.():n(t),s=e=>null==e,a=f(s),p=f(e=>void 0===e),u=Object,c=e=>u.getPrototypeOf(e),y=u.entries,d=u.keys,i=u.freeze,h=(e=[])=>u.fromEntries(e),T=(e,t)=>((e,t)=>e.forEach(t))(y(e),([e,n])=>t(n,e)),b=(e,t,n)=>{const r=e?.def?.type;return"optional"===r?b(e.def.innerType,t,n):"nullable"===r?b(e.def.innerType,t,!0):r===l?b(e.def.innerType,e.def.defaultValue,n):[e,t,n??!1]},m=()=>{const e=e=>{const[f,s,a]=b(e),u=f?.type;if(u!==t&&u!==r&&u!==n)return;const c={[o]:u};return p(s,e=>{c[l]=e}),a&&(c.allowNull=!0),c};return i({toTablesSchema:t=>{const n=h();return T(t,(t,r)=>{const o=h();var l;p(t?.def?.shape,t=>T(t,(t,n)=>p(e(t),e=>{o[n]=e}))),(e=>!s(e)&&a(c(e),e=>e==u.prototype||s(c(e)),()=>!0))(l=o)&&0==(e=>d(e).length)(l)||(n[r]=o)}),n},toValuesSchema:t=>{const n=h();return T(t,(t,r)=>p(e(t),e=>{n[r]=e})),n}})};export{m as createZodSchematizer};
1
+ const e=e=>typeof e,t=e(""),n=e(!0),r=e(0),o="type",l="default",f=e=>(t,n,r)=>e(t)?r?.():n(t),s=e=>null==e,a=f(s),p=f(e=>void 0===e),u=Object,c=e=>u.getPrototypeOf(e),y=u.entries,d=u.keys,i=u.freeze,h=(e=[])=>u.fromEntries(e),T=(e,t)=>((e,t)=>e.forEach(t))(y(e),([e,n])=>t(n,e)),b=(e,t,n)=>{const r=e?.def?.type;return"optional"===r?b(e.def.innerType,t,n):"nullable"===r?b(e.def.innerType,t,!0):r===l?b(e.def.innerType,e.def.defaultValue,n):[e,t,n??!1]},m=e=>e?.def?.shape,g=()=>((e,f)=>{const y=f=>{const[s,a,u]=e(f),c=s?.type;if(c!==t&&c!==r&&c!==n)return;const y={[o]:c};return p(a,e=>{y[l]=e}),u&&(y.allowNull=!0),y};return i({toTablesSchema:e=>{const t=h();return T(e,(e,n)=>{const r=h();var o;p(f(e),e=>T(e,(e,t)=>p(y(e),e=>{r[t]=e}))),(e=>!s(e)&&a(c(e),e=>e==u.prototype||s(c(e)),()=>!0))(o=r)&&0==(e=>d(e).length)(o)||(t[n]=r)}),t},toValuesSchema:e=>{const t=h();return T(e,(e,n)=>p(y(e),e=>{t[n]=e})),t}})})(b,m);export{g as createZodSchematizer};
@@ -1 +1 @@
1
-
1
+ const t=t=>typeof t,e=t(""),o=t(!0),r=t(0),n="type",s=t=>(e,o,r)=>t(e)?r?.():o(e),c=t=>null==t,l=s(c),u=s(t=>void 0===t),a=Object,f=t=>a.getPrototypeOf(t),p=a.entries,y=a.keys,h=a.freeze,i=(t=[])=>a.fromEntries(t),m=(t,e)=>((t,e)=>t.forEach(e))(p(t),([t,o])=>e(o,t)),b=(t,s)=>{const p=s=>{const[c,l,a]=t(s),f=c?.type;if(f!==e&&f!==r&&f!==o)return;const p={[n]:f};return u(l,t=>{p.default=t}),a&&(p.allowNull=!0),p};return h({toTablesSchema:t=>{const e=i();return m(t,(t,o)=>{const r=i();var n;u(s(t),t=>m(t,(t,e)=>u(p(t),t=>{r[e]=t}))),(t=>!c(t)&&l(f(t),t=>t==a.prototype||c(f(t)),()=>!0))(n=r)&&0==(t=>y(t).length)(n)||(e[o]=r)}),e},toValuesSchema:t=>{const e=i();return m(t,(t,o)=>u(p(t),t=>{e[o]=t})),e}})};export{b as createCustomSchematizer};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinybase",
3
- "version": "7.1.0-beta.2",
3
+ "version": "7.1.0-beta.3",
4
4
  "author": "jamesgpearce",
5
5
  "repository": "github:tinyplex/tinybase",
6
6
  "license": "MIT",
@@ -41,6 +41,7 @@
41
41
  "react-native-mmkv": "4.1.0",
42
42
  "react-native-sqlite-storage": "^6.0.1",
43
43
  "sqlite3": "^5.1.7",
44
+ "valibot": "^1.2.0",
44
45
  "ws": "^8.18.3",
45
46
  "yjs": "^13.6.27",
46
47
  "zod": "^4.1.13"
@@ -106,6 +107,9 @@
106
107
  "sqlite3": {
107
108
  "optional": true
108
109
  },
110
+ "valibot": {
111
+ "optional": true
112
+ },
109
113
  "ws": {
110
114
  "optional": true
111
115
  },
@@ -324,6 +328,12 @@
324
328
  "schematizers/schematizer-typebox/with-schemas": [
325
329
  "./@types/schematizers/schematizer-typebox/with-schemas/index.d.ts"
326
330
  ],
331
+ "schematizers/schematizer-valibot": [
332
+ "./@types/schematizers/schematizer-valibot/index.d.ts"
333
+ ],
334
+ "schematizers/schematizer-valibot/with-schemas": [
335
+ "./@types/schematizers/schematizer-valibot/with-schemas/index.d.ts"
336
+ ],
327
337
  "schematizers/schematizer-zod": [
328
338
  "./@types/schematizers/schematizer-zod/index.d.ts"
329
339
  ],
@@ -600,6 +610,12 @@
600
610
  "min/schematizers/schematizer-typebox/with-schemas": [
601
611
  "./@types/schematizers/schematizer-typebox/with-schemas/index.d.ts"
602
612
  ],
613
+ "min/schematizers/schematizer-valibot": [
614
+ "./@types/schematizers/schematizer-valibot/index.d.ts"
615
+ ],
616
+ "min/schematizers/schematizer-valibot/with-schemas": [
617
+ "./@types/schematizers/schematizer-valibot/with-schemas/index.d.ts"
618
+ ],
603
619
  "min/schematizers/schematizer-zod": [
604
620
  "./@types/schematizers/schematizer-zod/index.d.ts"
605
621
  ],
@@ -1083,6 +1099,18 @@
1083
1099
  "default": "./schematizers/schematizer-typebox/index.js"
1084
1100
  }
1085
1101
  },
1102
+ "./schematizers/schematizer-valibot": {
1103
+ "default": {
1104
+ "types": "./@types/schematizers/schematizer-valibot/index.d.ts",
1105
+ "default": "./schematizers/schematizer-valibot/index.js"
1106
+ }
1107
+ },
1108
+ "./schematizers/schematizer-valibot/with-schemas": {
1109
+ "default": {
1110
+ "types": "./@types/schematizers/schematizer-valibot/with-schemas/index.d.ts",
1111
+ "default": "./schematizers/schematizer-valibot/index.js"
1112
+ }
1113
+ },
1086
1114
  "./schematizers/schematizer-zod": {
1087
1115
  "default": {
1088
1116
  "types": "./@types/schematizers/schematizer-zod/index.d.ts",
@@ -1635,6 +1663,18 @@
1635
1663
  "default": "./min/schematizers/schematizer-typebox/index.js"
1636
1664
  }
1637
1665
  },
1666
+ "./min/schematizers/schematizer-valibot": {
1667
+ "default": {
1668
+ "types": "./@types/schematizers/schematizer-valibot/index.d.ts",
1669
+ "default": "./min/schematizers/schematizer-valibot/index.js"
1670
+ }
1671
+ },
1672
+ "./min/schematizers/schematizer-valibot/with-schemas": {
1673
+ "default": {
1674
+ "types": "./@types/schematizers/schematizer-valibot/with-schemas/index.d.ts",
1675
+ "default": "./min/schematizers/schematizer-valibot/index.js"
1676
+ }
1677
+ },
1638
1678
  "./min/schematizers/schematizer-zod": {
1639
1679
  "default": {
1640
1680
  "types": "./@types/schematizers/schematizer-zod/index.d.ts",
package/readme.md CHANGED
@@ -1,4 +1,4 @@
1
- <link rel="preload" as="image" href="https://beta.tinybase.org/react.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/indexeddb.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/browser.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/cloudflare.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/postgresql.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/pglite.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/sqlite.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/bun.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/expo.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/electric.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/turso.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/powersync.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/partykit.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/yjs.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/crsqlite.png"><link rel="preload" as="image" href="https://beta.tinybase.org/automerge.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/zod.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/typebox.svg?asImg"><link rel="preload" as="image" href="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/badge/Bluesky-Follow-blue?style=for-the-badge&amp;logo=bluesky&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%230285FF"><link rel="preload" as="image" href="https://img.shields.io/badge/%2F%20Twitter-Follow-blue?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%23000"><link rel="preload" as="image" href="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=Vitest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"><link rel="preload" as="image" href="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"><link rel="preload" as="image" href="https://beta.tinybase.org/ui-react-dom.webp"><link rel="preload" as="image" href="https://beta.tinybase.org/inspector.webp"><link rel="preload" as="image" href="https://github.com/cpojer.png?size=48"><link rel="preload" as="image" href="https://github.com/expo.png?size=48"><link rel="preload" as="image" href="https://github.com/beekeeb.png?size=48"><link rel="preload" as="image" href="https://github.com/cancelself.png?size=48"><link rel="preload" as="image" href="https://github.com/WonderPanda.png?size=48"><link rel="preload" as="image" href="https://github.com/arpitBhalla.png?size=48"><link rel="preload" as="image" href="https://github.com/behrends.png?size=48"><link rel="preload" as="image" href="https://github.com/betomoedano.png?size=48"><link rel="preload" as="image" href="https://github.com/brentvatne.png?size=48"><link rel="preload" as="image" href="https://github.com/byCedric.png?size=48"><link rel="preload" as="image" href="https://github.com/circadian-risk.png?size=48"><link rel="preload" as="image" href="https://github.com/cubecull.png?size=48"><link rel="preload" as="image" href="https://github.com/erwinkn.png?size=48"><link rel="preload" as="image" href="https://github.com/ezra-en.png?size=48"><link rel="preload" as="image" href="https://github.com/feychenie.png?size=48"><link rel="preload" as="image" href="https://github.com/flaming-codes.png?size=48"><link rel="preload" as="image" href="https://github.com/fostertheweb.png?size=48"><link rel="preload" as="image" href="https://github.com/Giulio987.png?size=48"><link rel="preload" as="image" href="https://github.com/hi-ogawa.png?size=48"><link rel="preload" as="image" href="https://github.com/itsdevcoffee.png?size=48"><link rel="preload" as="image" href="https://github.com/jbolda.png?size=48"><link rel="preload" as="image" href="https://github.com/Kayoo-asso.png?size=48"><link rel="preload" as="image" href="https://github.com/kotofurumiya.png?size=48"><link rel="preload" as="image" href="https://github.com/Kudo.png?size=48"><link rel="preload" as="image" href="https://github.com/learn-anything.png?size=48"><link rel="preload" as="image" href="https://github.com/lluc.png?size=48"><link rel="preload" as="image" href="https://github.com/marksteve.png?size=48"><link rel="preload" as="image" href="https://github.com/miking-the-viking.png?size=48"><link rel="preload" as="image" href="https://github.com/mjamesderocher.png?size=48"><link rel="preload" as="image" href="https://github.com/mouktardev.png?size=48"><link rel="preload" as="image" href="https://github.com/nickmessing.png?size=48"><link rel="preload" as="image" href="https://github.com/nikitavoloboev.png?size=48"><link rel="preload" as="image" href="https://github.com/nkzw-tech.png?size=48"><link rel="preload" as="image" href="https://github.com/palerdot.png?size=48"><link rel="preload" as="image" href="https://github.com/PorcoRosso85.png?size=48"><link rel="preload" as="image" href="https://github.com/primodiumxyz.png?size=48"><link rel="preload" as="image" href="https://github.com/shaneosullivan.png?size=48"><link rel="preload" as="image" href="https://github.com/sudo-self.png?size=48"><link rel="preload" as="image" href="https://github.com/SuperSonicHub1.png?size=48"><link rel="preload" as="image" href="https://github.com/threepointone.png?size=48"><link rel="preload" as="image" href="https://github.com/uptonking.png?size=48"><link rel="preload" as="image" href="https://github.com/ViktorZhurbin.png?size=48"><link rel="preload" as="image" href="https://github.com/wilkerlucio.png?size=48"><link rel="preload" as="image" href="https://synclets.org/favicon.svg?asImg"><link rel="preload" as="image" href="https://tinywidgets.org/favicon.svg?asImg"><link rel="preload" as="image" href="https://tinytick.org/favicon.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/youtube.webp"><section id="hero"><h2 id="a-reactive-data-store-sync-engine">A <em>reactive</em> data store &amp; <span><em>sync</em> engine</span></h2></section><p><a href="https://beta.tinybase.org/guides/releases/#v7-1"><em>NEW!</em> v7.1 release</a></p><p><span id="one-with">&quot;The one with Schematizers!&quot;</span></p><p><a class="start" href="https://beta.tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://beta.tinybase.org/demos/">Try the demos</a></p><p><a href="https://beta.tinybase.org/api/the-essentials/creating-stores/store/">Read the docs</a></p><hr><section><h2 id="it-s-reactive">It&#x27;s <em>Reactive</em></h2><p>TinyBase lets you <a href="#register-granular-listeners">listen to changes</a> made to any part of your data. This means your app will be fast, since you only spend rendering cycles on things that change. The optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and <a href="#pre-built-reactive-components">pre-built components</a> let you easily build fully reactive UIs on top of TinyBase. You even get a built-in <a href="#set-checkpoints-for-an-undo-stack">undo stack</a>, and <a href="#an-inspector-for-your-data">developer tools</a>!</p></section><section><h2 id="it-s-database-like">It&#x27;s <em>Database-Like</em></h2><p>Consumer app? Enterprise app? Or even a game? Model <a href="#start-with-a-simple-key-value-store">key-value data</a> and <a href="#level-up-to-use-tabular-data">tabular data</a> with optional typed <a href="#apply-schemas-to-tables-values">schematization</a>, whatever its data structures. There are built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, and tabular <a href="#model-table-relationships">relationships</a> APIs - and a powerful <a href="#build-complex-queries-with-tinyql">query engine</a> to select, join, filter, and group data (reactively!) without SQL.</p></section><section><h2 id="it-synchronizes">It <em>Synchronizes</em></h2><p>TinyBase has <a href="#synchronize-between-devices">native CRDT</a> support, meaning that you can deterministically <a href="https://beta.tinybase.org/guides/synchronization/">synchronize</a> and merge data across multiple sources, clients, and servers. And although TinyBase is an in-memory data store, you can easily <a href="#persist-to-storage-databases-more">persist</a> your data to file, <a href="https://beta.tinybase.org/api/persister-browser">browser storage</a>, <a href="https://beta.tinybase.org/api/persister-indexed-db">IndexedDB</a>, <a href="https://beta.tinybase.org/guides/persistence/database-persistence/">SQLite or PostgreSQL databases</a>, and <a href="https://beta.tinybase.org/guides/persistence/third-party-crdt-persistence/">more</a>.</p></section><section><h2 id="it-s-built-for-a-local-first-world">It&#x27;s Built For A <em>Local-First</em> World</h2><p>TinyBase works anywhere that JavaScript does, but it&#x27;s especially great for local-first apps: where data is stored locally on the user&#x27;s device and that can be run offline. It&#x27;s tiny by name, tiny by nature: just <a href="#did-we-say-tiny">5.4kB - 11.8kB</a> and with no dependencies - yet <a href="#well-tested-and-documented">100% tested</a>, <a href="https://beta.tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</p></section><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">TinyBase works great on its own, but also plays well with friends.</h2><div><a href="https://beta.tinybase.org/guides/building-uis/getting-started-with-ui-react"><img src="https://beta.tinybase.org/react.svg?asImg" width="48"> React</a></div><div><a href="https://beta.tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img src="https://beta.tinybase.org/indexeddb.svg?asImg" width="48"> IndexedDB</a></div><div><a href="https://beta.tinybase.org/api/persister-browser"><img src="https://beta.tinybase.org/browser.svg?asImg" width="48"> OPFS</a></div><div><a href="https://beta.tinybase.org/guides/integrations/cloudflare-durable-objects"><img src="https://beta.tinybase.org/cloudflare.svg?asImg" width="48"> Cloudflare</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/postgresql.svg?asImg" width="48"> PostgreSQL</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/pglite.svg?asImg" width="48"> PGlite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/sqlite.svg?asImg" width="48"> SQLite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/bun.svg?asImg" width="48"> Bun SQLite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/expo.svg?asImg" width="48"> Expo SQLite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/electric.svg?asImg" width="48"> ElectricSQL</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/turso.svg?asImg" width="48"> Turso</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/powersync.svg?asImg" width="48"> PowerSync</a></div><div><a href="https://beta.tinybase.org/api/persister-partykit-client"><img src="https://beta.tinybase.org/partykit.svg?asImg" width="48"> PartyKit</a></div><div><a href="https://beta.tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img src="https://beta.tinybase.org/yjs.svg?asImg" width="48"> YJS</a></div><div><a href="https://beta.tinybase.org/api/persister-cr-sqlite-wasm"><img src="https://beta.tinybase.org/crsqlite.png" width="48"> CR-SQLite</a></div><div><a href="https://beta.tinybase.org/api/persister-automerge"><img src="https://beta.tinybase.org/automerge.svg?asImg" width="48"> Automerge</a></div><div><a href="https://beta.tinybase.org/api/schematizer-zod/functions/creation/createzodschematizer"><img src="https://beta.tinybase.org/zod.svg?asImg" width="48"> Zod</a></div><div><a href="https://beta.tinybase.org/api/schematizer-typebox/functions/creation/createtypeboxschematizer"><img src="https://beta.tinybase.org/typebox.svg?asImg" width="48"> TypeBox</a></div><p>(Baffled by all these logos? Check out our <a href="https://beta.tinybase.org/guides/the-basics/architectural-options">architectural options</a> guide to make sense of it all!)</p></section><hr><section id="follow"><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://bsky.app/profile/tinybase.bsky.social"><img src="https://img.shields.io/badge/Bluesky-Follow-blue?style=for-the-badge&amp;logo=bluesky&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%230285FF"> </a><a href="https://x.com/tinybasejs" target="_blank"><img src="https://img.shields.io/badge/%2F%20Twitter-Follow-blue?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%23000"> </a><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"></a><br><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"> </a><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=Vitest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"> </a><a href="https://www.npmjs.com/package/tinybase/v/7.1.0-beta.1" target="_blank"><img src="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"></a></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://beta.tinybase.org/api/the-essentials/creating-stores/store/"><code>Store</code></a> requires just a simple call to the <a href="https://beta.tinybase.org/api/the-essentials/creating-stores/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://beta.tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://beta.tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://beta.tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
1
+ <link rel="preload" as="image" href="https://beta.tinybase.org/react.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/indexeddb.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/browser.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/cloudflare.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/postgresql.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/pglite.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/sqlite.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/bun.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/expo.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/electric.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/turso.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/powersync.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/partykit.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/yjs.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/crsqlite.png"><link rel="preload" as="image" href="https://beta.tinybase.org/automerge.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/typebox.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/valibot.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/zod.svg?asImg"><link rel="preload" as="image" href="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/badge/Bluesky-Follow-blue?style=for-the-badge&amp;logo=bluesky&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%230285FF"><link rel="preload" as="image" href="https://img.shields.io/badge/%2F%20Twitter-Follow-blue?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%23000"><link rel="preload" as="image" href="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"><link rel="preload" as="image" href="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=Vitest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"><link rel="preload" as="image" href="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"><link rel="preload" as="image" href="https://beta.tinybase.org/ui-react-dom.webp"><link rel="preload" as="image" href="https://beta.tinybase.org/inspector.webp"><link rel="preload" as="image" href="https://github.com/cpojer.png?size=48"><link rel="preload" as="image" href="https://github.com/expo.png?size=48"><link rel="preload" as="image" href="https://github.com/beekeeb.png?size=48"><link rel="preload" as="image" href="https://github.com/cancelself.png?size=48"><link rel="preload" as="image" href="https://github.com/WonderPanda.png?size=48"><link rel="preload" as="image" href="https://github.com/arpitBhalla.png?size=48"><link rel="preload" as="image" href="https://github.com/behrends.png?size=48"><link rel="preload" as="image" href="https://github.com/betomoedano.png?size=48"><link rel="preload" as="image" href="https://github.com/brentvatne.png?size=48"><link rel="preload" as="image" href="https://github.com/byCedric.png?size=48"><link rel="preload" as="image" href="https://github.com/circadian-risk.png?size=48"><link rel="preload" as="image" href="https://github.com/cubecull.png?size=48"><link rel="preload" as="image" href="https://github.com/erwinkn.png?size=48"><link rel="preload" as="image" href="https://github.com/ezra-en.png?size=48"><link rel="preload" as="image" href="https://github.com/feychenie.png?size=48"><link rel="preload" as="image" href="https://github.com/flaming-codes.png?size=48"><link rel="preload" as="image" href="https://github.com/fostertheweb.png?size=48"><link rel="preload" as="image" href="https://github.com/Giulio987.png?size=48"><link rel="preload" as="image" href="https://github.com/hi-ogawa.png?size=48"><link rel="preload" as="image" href="https://github.com/itsdevcoffee.png?size=48"><link rel="preload" as="image" href="https://github.com/jbolda.png?size=48"><link rel="preload" as="image" href="https://github.com/Kayoo-asso.png?size=48"><link rel="preload" as="image" href="https://github.com/kotofurumiya.png?size=48"><link rel="preload" as="image" href="https://github.com/Kudo.png?size=48"><link rel="preload" as="image" href="https://github.com/learn-anything.png?size=48"><link rel="preload" as="image" href="https://github.com/lluc.png?size=48"><link rel="preload" as="image" href="https://github.com/marksteve.png?size=48"><link rel="preload" as="image" href="https://github.com/miking-the-viking.png?size=48"><link rel="preload" as="image" href="https://github.com/mjamesderocher.png?size=48"><link rel="preload" as="image" href="https://github.com/mouktardev.png?size=48"><link rel="preload" as="image" href="https://github.com/nickmessing.png?size=48"><link rel="preload" as="image" href="https://github.com/nikitavoloboev.png?size=48"><link rel="preload" as="image" href="https://github.com/nkzw-tech.png?size=48"><link rel="preload" as="image" href="https://github.com/palerdot.png?size=48"><link rel="preload" as="image" href="https://github.com/PorcoRosso85.png?size=48"><link rel="preload" as="image" href="https://github.com/primodiumxyz.png?size=48"><link rel="preload" as="image" href="https://github.com/shaneosullivan.png?size=48"><link rel="preload" as="image" href="https://github.com/sudo-self.png?size=48"><link rel="preload" as="image" href="https://github.com/SuperSonicHub1.png?size=48"><link rel="preload" as="image" href="https://github.com/threepointone.png?size=48"><link rel="preload" as="image" href="https://github.com/uptonking.png?size=48"><link rel="preload" as="image" href="https://github.com/ViktorZhurbin.png?size=48"><link rel="preload" as="image" href="https://github.com/wilkerlucio.png?size=48"><link rel="preload" as="image" href="https://synclets.org/favicon.svg?asImg"><link rel="preload" as="image" href="https://tinywidgets.org/favicon.svg?asImg"><link rel="preload" as="image" href="https://tinytick.org/favicon.svg?asImg"><link rel="preload" as="image" href="https://beta.tinybase.org/youtube.webp"><section id="hero"><h2 id="a-reactive-data-store-sync-engine">A <em>reactive</em> data store &amp; <span><em>sync</em> engine</span></h2></section><p><a href="https://beta.tinybase.org/guides/releases/#v7-1"><em>NEW!</em> v7.1 release</a></p><p><span id="one-with">&quot;The one with Schematizers!&quot;</span></p><p><a class="start" href="https://beta.tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://beta.tinybase.org/demos/">Try the demos</a></p><p><a href="https://beta.tinybase.org/api/the-essentials/creating-stores/store/">Read the docs</a></p><hr><section><h2 id="it-s-reactive">It&#x27;s <em>Reactive</em></h2><p>TinyBase lets you <a href="#register-granular-listeners">listen to changes</a> made to any part of your data. This means your app will be fast, since you only spend rendering cycles on things that change. The optional <a href="#call-hooks-to-bind-to-data">bindings to React</a> and <a href="#pre-built-reactive-components">pre-built components</a> let you easily build fully reactive UIs on top of TinyBase. You even get a built-in <a href="#set-checkpoints-for-an-undo-stack">undo stack</a>, and <a href="#an-inspector-for-your-data">developer tools</a>!</p></section><section><h2 id="it-s-database-like">It&#x27;s <em>Database-Like</em></h2><p>Consumer app? Enterprise app? Or even a game? Model <a href="#start-with-a-simple-key-value-store">key-value data</a> and <a href="#level-up-to-use-tabular-data">tabular data</a> with optional typed <a href="#apply-schemas-to-tables-values">schematization</a>, whatever its data structures. There are built-in <a href="#create-indexes-for-fast-lookups">indexing</a>, <a href="#define-metrics-and-aggregations">metric aggregation</a>, and tabular <a href="#model-table-relationships">relationships</a> APIs - and a powerful <a href="#build-complex-queries-with-tinyql">query engine</a> to select, join, filter, and group data (reactively!) without SQL.</p></section><section><h2 id="it-synchronizes">It <em>Synchronizes</em></h2><p>TinyBase has <a href="#synchronize-between-devices">native CRDT</a> support, meaning that you can deterministically <a href="https://beta.tinybase.org/guides/synchronization/">synchronize</a> and merge data across multiple sources, clients, and servers. And although TinyBase is an in-memory data store, you can easily <a href="#persist-to-storage-databases-more">persist</a> your data to file, <a href="https://beta.tinybase.org/api/persister-browser">browser storage</a>, <a href="https://beta.tinybase.org/api/persister-indexed-db">IndexedDB</a>, <a href="https://beta.tinybase.org/guides/persistence/database-persistence/">SQLite or PostgreSQL databases</a>, and <a href="https://beta.tinybase.org/guides/persistence/third-party-crdt-persistence/">more</a>.</p></section><section><h2 id="it-s-built-for-a-local-first-world">It&#x27;s Built For A <em>Local-First</em> World</h2><p>TinyBase works anywhere that JavaScript does, but it&#x27;s especially great for local-first apps: where data is stored locally on the user&#x27;s device and that can be run offline. It&#x27;s tiny by name, tiny by nature: just <a href="#did-we-say-tiny">5.4kB - 11.8kB</a> and with no dependencies - yet <a href="#well-tested-and-documented">100% tested</a>, <a href="https://beta.tinybase.org/guides/the-basics/getting-started/">fully documented</a>, and of course, <a href="https://github.com/tinyplex/tinybase">open source</a>!</p></section><hr><section id="friends"><h2 id="tinybase-works-great-on-its-own-but-also-plays-well-with-friends">TinyBase works great on its own, but also plays well with friends.</h2><div><a href="https://beta.tinybase.org/guides/building-uis/getting-started-with-ui-react"><img src="https://beta.tinybase.org/react.svg?asImg" width="48"> React</a></div><div><a href="https://beta.tinybase.org/api/persister-indexed-db/functions/creation/createindexeddbpersister"><img src="https://beta.tinybase.org/indexeddb.svg?asImg" width="48"> IndexedDB</a></div><div><a href="https://beta.tinybase.org/api/persister-browser"><img src="https://beta.tinybase.org/browser.svg?asImg" width="48"> OPFS</a></div><div><a href="https://beta.tinybase.org/guides/integrations/cloudflare-durable-objects"><img src="https://beta.tinybase.org/cloudflare.svg?asImg" width="48"> Cloudflare</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/postgresql.svg?asImg" width="48"> PostgreSQL</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/pglite.svg?asImg" width="48"> PGlite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/sqlite.svg?asImg" width="48"> SQLite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/bun.svg?asImg" width="48"> Bun SQLite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/expo.svg?asImg" width="48"> Expo SQLite</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/electric.svg?asImg" width="48"> ElectricSQL</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/turso.svg?asImg" width="48"> Turso</a></div><div><a href="https://beta.tinybase.org/guides/schemas-and-persistence/database-persistence"><img src="https://beta.tinybase.org/powersync.svg?asImg" width="48"> PowerSync</a></div><div><a href="https://beta.tinybase.org/api/persister-partykit-client"><img src="https://beta.tinybase.org/partykit.svg?asImg" width="48"> PartyKit</a></div><div><a href="https://beta.tinybase.org/api/persister-yjs/functions/creation/createyjspersister"><img src="https://beta.tinybase.org/yjs.svg?asImg" width="48"> YJS</a></div><div><a href="https://beta.tinybase.org/api/persister-cr-sqlite-wasm"><img src="https://beta.tinybase.org/crsqlite.png" width="48"> CR-SQLite</a></div><div><a href="https://beta.tinybase.org/api/persister-automerge"><img src="https://beta.tinybase.org/automerge.svg?asImg" width="48"> Automerge</a></div><div><a href="https://beta.tinybase.org/api/schematizer-typebox/functions/creation/createtypeboxschematizer"><img src="https://beta.tinybase.org/typebox.svg?asImg" width="48"> TypeBox</a></div><div><a href="https://beta.tinybase.org/api/schematizer-valibot/functions/creation/createvalibotschematizer"><img src="https://beta.tinybase.org/valibot.svg?asImg" width="48"> Valibot</a></div><div><a href="https://beta.tinybase.org/api/schematizer-zod/functions/creation/createzodschematizer"><img src="https://beta.tinybase.org/zod.svg?asImg" width="48"> Zod</a></div><p>(Baffled by all these logos? Check out our <a href="https://beta.tinybase.org/guides/the-basics/architectural-options">architectural options</a> guide to make sense of it all!)</p></section><hr><section id="follow"><p><a href="https://github.com/tinyplex/tinybase" target="_blank"><img src="https://img.shields.io/github/stars/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=GitHub&amp;labelColor=%23d81b60&amp;color=%23333"></a></p><p><a href="https://bsky.app/profile/tinybase.bsky.social"><img src="https://img.shields.io/badge/Bluesky-Follow-blue?style=for-the-badge&amp;logo=bluesky&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%230285FF"></a></p><p><a href="https://x.com/tinybasejs" target="_blank"><img src="https://img.shields.io/badge/%2F%20Twitter-Follow-blue?style=for-the-badge&amp;logo=x&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%23000"></a></p><p><a href="https://discord.com/invite/mGz3mevwP8" target="_blank"><img src="https://img.shields.io/discord/1027918215323590676?style=for-the-badge&amp;logo=discord&amp;logoColor=%23fff&amp;label=Discord&amp;labelColor=%233131e8&amp;color=%23333"></a></p><br><p><a href="https://github.com/tinyplex/tinybase/discussions" target="_blank"><img src="https://img.shields.io/github/discussions/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Ideas&amp;labelColor=%23d81b60&amp;color=%23333"></a></p><p><a href="https://github.com/tinyplex/tinybase/issues" target="_blank"><img src="https://img.shields.io/github/issues/tinyplex/tinybase?style=for-the-badge&amp;logo=GitHub&amp;logoColor=%23fff&amp;label=Issues&amp;labelColor=%23d81b60&amp;color=%23333"></a></p><p><a href="#well-tested-and-documented"><img src="https://img.shields.io/badge/Tests-100%25-green?style=for-the-badge&amp;logo=Vitest&amp;logoColor=%23fff&amp;color=%23333&amp;labelColor=%2387c305"></a></p><p><a href="https://www.npmjs.com/package/tinybase/v/7.1.0-beta.2" target="_blank"><img src="https://img.shields.io/npm/v/tinybase?style=for-the-badge&amp;logo=npm&amp;logoColor=%23fff&amp;labelColor=%23bd0005&amp;color=%23333"></a></p></section><hr><section><h2 id="start-with-a-simple-key-value-store">Start with a simple key-value store.</h2><p>Creating a <a href="https://beta.tinybase.org/api/the-essentials/creating-stores/store/"><code>Store</code></a> requires just a simple call to the <a href="https://beta.tinybase.org/api/the-essentials/creating-stores/createstore/"><code>createStore</code></a> function. Once you have one, you can easily set <a href="https://beta.tinybase.org/api/store/type-aliases/store/values/"><code>Values</code></a> in it by unique <a href="https://beta.tinybase.org/api/common/type-aliases/identity/id/"><code>Id</code></a>. And of course you can easily get them back out again.</p><p>Read more about using keyed value data in <a href="https://beta.tinybase.org/guides/the-basics/">The Basics</a> guide.</p></section>
2
2
 
3
3
  ```js
4
4
  import {createStore} from 'tinybase';
@@ -60,7 +60,7 @@ console.log(app.innerHTML);
60
60
  root.unmount();
61
61
  ```
62
62
 
63
- <section><h2 id="pre-built-reactive-components">Pre-built reactive components.</h2><p>The <a href="https://beta.tinybase.org/api/ui-react/"><code>ui-react</code></a> module provides bare React components that let you build up a fully reactive user interface based on a <a href="https://beta.tinybase.org/api/the-essentials/creating-stores/store/"><code>Store</code></a>.</p><p>For web applications in particular, the new <a href="https://beta.tinybase.org/api/ui-react-dom/"><code>ui-react-dom</code></a> module provides pre-built components for tabular display of your data, with lots of customization and interactivity options.</p><p>Try them out in the <a href="https://beta.tinybase.org/demos/ui-components/">UI Components</a> demos, and read more about the underlying <a href="https://beta.tinybase.org/api/ui-react/"><code>ui-react</code></a> module in the <a href="https://beta.tinybase.org/guides/building-uis/">Building UIs</a> guides.</p></section><img src="https://beta.tinybase.org/ui-react-dom.webp"><section><h2 id="an-inspector-for-your-data">An inspector for your data.</h2><p>If you are building a web application, the new <a href="https://beta.tinybase.org/api/the-essentials/using-react/inspector/"><code>Inspector</code></a> component lets you overlay a view of the data in your <a href="https://beta.tinybase.org/api/the-essentials/creating-stores/store/"><code>Store</code></a>, <a href="https://beta.tinybase.org/api/indexes/interfaces/indexes/indexes/"><code>Indexes</code></a>, <a href="https://beta.tinybase.org/api/relationships/interfaces/relationships/relationships/"><code>Relationships</code></a>, and so on. You can even edit the data in place and see it update in your app immediately.</p><p>Read more about this powerful new tool in the <a href="https://beta.tinybase.org/guides/inspecting-data/">Inspecting Data</a> guide.</p></section><img src="https://beta.tinybase.org/inspector.webp"><section><h2 id="apply-schemas-to-tables-values">Apply schemas to tables &amp; values.</h2><p>By default, a <a href="https://beta.tinybase.org/api/the-essentials/creating-stores/store/"><code>Store</code></a> can contain any arbitrary <a href="https://beta.tinybase.org/api/store/type-aliases/store/value/"><code>Value</code></a>, and a <a href="https://beta.tinybase.org/api/store/type-aliases/store/row/"><code>Row</code></a> can contain any arbitrary <a href="https://beta.tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a>. But you can add a <a href="https://beta.tinybase.org/api/store/type-aliases/schema/valuesschema/"><code>ValuesSchema</code></a> or a <a href="https://beta.tinybase.org/api/store/type-aliases/schema/tablesschema/"><code>TablesSchema</code></a> to a <a href="https://beta.tinybase.org/api/the-essentials/creating-stores/store/"><code>Store</code></a> to ensure that the values are always what you expect: constraining their types, and providing defaults. There are even TypeScript definitions that infer API types from the data schemas you apply.</p><p>In this example, we set a new <a href="https://beta.tinybase.org/api/store/type-aliases/store/row/"><code>Row</code></a> without the <code>sold</code> <a href="https://beta.tinybase.org/api/store/type-aliases/store/cell/"><code>Cell</code></a> in it. The schema ensures it&#x27;s present with default of <code>false</code>.</p><p>Read more about schemas in the <a href="https://beta.tinybase.org/guides/schemas/">Schemas</a> guide.</p></section>
63
+ <section><h2 id="pre-built-reactive-components">Pre-built reactive components.</h2><p>The <a href="https://beta.tinybase.org/api/ui-react/"><code>ui-react</code></a> module provides bare React components that let you build up a fully reactive user interface based on a <a href="https://beta.tinybase.org/api/the-essentials/creating-stores/store/"><code>Store</code></a>.</p><p>For web applications in particular, the new <a href="https://beta.tinybase.org/api/ui-react-dom/"><code>ui-react-dom</code></a> module provides pre-built components for tabular display of your data, with lots of customization and interactivity options.</p><p>Try them out in the <a href="https://beta.tinybase.org/demos/ui-components/">UI Components</a> demos, and read more about the underlying <a href="https://beta.tinybase.org/api/ui-react/"><code>ui-react</code></a> module in the <a href="https://beta.tinybase.org/guides/building-uis/">Building UIs</a> guides.</p></section><img src="https://beta.tinybase.org/ui-react-dom.webp"><section><h2 id="an-inspector-for-your-data">An inspector for your data.</h2><p>If you are building a web application, the new <a href="https://beta.tinybase.org/api/the-essentials/using-react/inspector/"><code>Inspector</code></a> component lets you overlay a view of the data in your <a href="https://beta.tinybase.org/api/the-essentials/creating-stores/store/"><code>Store</code></a>, <a href="https://beta.tinybase.org/api/indexes/interfaces/indexes/indexes/"><code>Indexes</code></a>, <a href="https://beta.tinybase.org/api/relationships/interfaces/relationships/relationships/"><code>Relationships</code></a>, and so on. You can even edit the data in place and see it update in your app immediately.</p><p>Read more about this powerful new tool in the <a href="https://beta.tinybase.org/guides/inspecting-data/">Inspecting Data</a> guide.</p></section><img src="https://beta.tinybase.org/inspector.webp"><section><h2 id="apply-schemas-to-tables-values">Apply schemas to tables &amp; values.</h2><p>Want clean data? You can add a <a href="https://beta.tinybase.org/api/store/type-aliases/schema/valuesschema/"><code>ValuesSchema</code></a> or a <a href="https://beta.tinybase.org/api/store/type-aliases/schema/tablesschema/"><code>TablesSchema</code></a> to a <a href="https://beta.tinybase.org/api/the-essentials/creating-stores/store/"><code>Store</code></a> to ensure that they are always what you expect by constraining types, and providing defaults. There are even TypeScript definitions that infer API types from the data schemas you apply.</p><p>And our &#x27;schematizer&#x27; modules let you convert schemas from libraries like Zod, TypeBox, and Valibot into TinyBase at runtime.</p><p>Read more about schemas in the <a href="https://beta.tinybase.org/guides/schemas/">Schemas</a> guide.</p></section>
64
64
 
65
65
  ```js
66
66
  store.setTablesSchema({
@@ -275,4 +275,4 @@ console.log(store.getCell('pets', 'felix', 'sold'));
275
275
  // -> false
276
276
  ```
277
277
 
278
- <section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://beta.tinybase.org/api/store/"><code>store</code></a> module alone, you&#x27;ll only add a gzipped <em>5.4kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>11.8kB</em>.</p><p>The optional <a href="https://beta.tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just <em>5.2kB</em>, the ui-react-dom components are another <em>3.7kB</em>, and everything is super fast. Life is easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured and packaged in the <a href="https://beta.tinybase.org/guides/how-tinybase-is-built/architecture/">Architecture</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th> </th><th>Minified .js.gz</th><th>Source .js</th></tr><tr><th class="right"><a href="https://beta.tinybase.org/api/store/">tinybase/store</a> (minimal)</th><td>5.4kB</td><td>54.6kB</td></tr><tr><th class="right">tinybase (complete)</th><td>11.8kB</td><td>123.4kB</td></tr><tr><th class="right"><a href="https://beta.tinybase.org/api/ui-react/">ui-react</a></th><td>5.2kB</td><td>55.6kB</td></tr><tr><th class="right"><a href="https://beta.tinybase.org/api/ui-react-dom/">ui-react-dom</a></th><td>3.7kB</td><td>32.8kB</td></tr></tbody></table></div><section><h2 id="well-tested-and-documented">Well tested and documented.</h2><p>TinyBase has <em>100.0%</em> test coverage, including the code throughout the documentation - even on this page! The guides, demos, and API examples are designed to make it as easy as possible for you to get your TinyBase-powered app up and running.</p><p>Read more about how TinyBase is tested in the Unit <a href="https://beta.tinybase.org/guides/how-tinybase-is-built/testing/">Testing</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>Total</th><th>Tested</th><th>Coverage</th></tr><tr><th class="right">Lines</th><td>2,341</td><td>2,341</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>2,534</td><td>2,534</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>1,010</td><td>1,010</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>892</td><td>892</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">7,128</td></tr><tr><th class="right">Assertions</th><td colspan="3">31,997</td></tr></tbody></table></div><hr><section id="sponsors"><h2 id="proud-to-be-sponsored-by">Proud to be sponsored by:</h2><a href="https://github.com/cpojer" target="_blank"><img src="https://github.com/cpojer.png?size=48" title="cpojer" width="48" height="48"></a><a href="https://github.com/expo" target="_blank"><img src="https://github.com/expo.png?size=48" title="expo" width="48" height="48"></a><a href="https://github.com/beekeeb" target="_blank"><img src="https://github.com/beekeeb.png?size=48" title="beekeeb" width="48" height="48"></a><a href="https://github.com/cancelself" target="_blank"><img src="https://github.com/cancelself.png?size=48" title="cancelself" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img src="https://github.com/WonderPanda.png?size=48" title="WonderPanda" width="48" height="48"></a><a href="https://github.com/arpitBhalla" target="_blank"><img src="https://github.com/arpitBhalla.png?size=48" title="arpitBhalla" width="48" height="48"></a></section><section id="users"><h2 id="excited-to-be-used-by">Excited to be used by:</h2><a href="https://github.com/behrends" target="_blank"><img src="https://github.com/behrends.png?size=48" title="behrends" width="48" height="48"></a><a href="https://github.com/betomoedano" target="_blank"><img src="https://github.com/betomoedano.png?size=48" title="betomoedano" width="48" height="48"></a><a href="https://github.com/brentvatne" target="_blank"><img src="https://github.com/brentvatne.png?size=48" title="brentvatne" width="48" height="48"></a><a href="https://github.com/byCedric" target="_blank"><img src="https://github.com/byCedric.png?size=48" title="byCedric" width="48" height="48"></a><a href="https://github.com/circadian-risk" target="_blank"><img src="https://github.com/circadian-risk.png?size=48" title="circadian-risk" width="48" height="48"></a><a href="https://github.com/cpojer" target="_blank"><img src="https://github.com/cpojer.png?size=48" title="cpojer" width="48" height="48"></a><a href="https://github.com/cubecull" target="_blank"><img src="https://github.com/cubecull.png?size=48" title="cubecull" width="48" height="48"></a><a href="https://github.com/erwinkn" target="_blank"><img src="https://github.com/erwinkn.png?size=48" title="erwinkn" width="48" height="48"></a><a href="https://github.com/expo" target="_blank"><img src="https://github.com/expo.png?size=48" title="expo" width="48" height="48"></a><a href="https://github.com/ezra-en" target="_blank"><img src="https://github.com/ezra-en.png?size=48" title="ezra-en" width="48" height="48"></a><a href="https://github.com/feychenie" target="_blank"><img src="https://github.com/feychenie.png?size=48" title="feychenie" width="48" height="48"></a><a href="https://github.com/flaming-codes" target="_blank"><img src="https://github.com/flaming-codes.png?size=48" title="flaming-codes" width="48" height="48"></a><a href="https://github.com/fostertheweb" target="_blank"><img src="https://github.com/fostertheweb.png?size=48" title="fostertheweb" width="48" height="48"></a><a href="https://github.com/Giulio987" target="_blank"><img src="https://github.com/Giulio987.png?size=48" title="Giulio987" width="48" height="48"></a><a href="https://github.com/hi-ogawa" target="_blank"><img src="https://github.com/hi-ogawa.png?size=48" title="hi-ogawa" width="48" height="48"></a><a href="https://github.com/itsdevcoffee" target="_blank"><img src="https://github.com/itsdevcoffee.png?size=48" title="itsdevcoffee" width="48" height="48"></a><a href="https://github.com/jbolda" target="_blank"><img src="https://github.com/jbolda.png?size=48" title="jbolda" width="48" height="48"></a><a href="https://github.com/Kayoo-asso" target="_blank"><img src="https://github.com/Kayoo-asso.png?size=48" title="Kayoo-asso" width="48" height="48"></a><a href="https://github.com/kotofurumiya" target="_blank"><img src="https://github.com/kotofurumiya.png?size=48" title="kotofurumiya" width="48" height="48"></a><a href="https://github.com/Kudo" target="_blank"><img src="https://github.com/Kudo.png?size=48" title="Kudo" width="48" height="48"></a><a href="https://github.com/learn-anything" target="_blank"><img src="https://github.com/learn-anything.png?size=48" title="learn-anything" width="48" height="48"></a><a href="https://github.com/lluc" target="_blank"><img src="https://github.com/lluc.png?size=48" title="lluc" width="48" height="48"></a><a href="https://github.com/marksteve" target="_blank"><img src="https://github.com/marksteve.png?size=48" title="marksteve" width="48" height="48"></a><a href="https://github.com/miking-the-viking" target="_blank"><img src="https://github.com/miking-the-viking.png?size=48" title="miking-the-viking" width="48" height="48"></a><a href="https://github.com/mjamesderocher" target="_blank"><img src="https://github.com/mjamesderocher.png?size=48" title="mjamesderocher" width="48" height="48"></a><a href="https://github.com/mouktardev" target="_blank"><img src="https://github.com/mouktardev.png?size=48" title="mouktardev" width="48" height="48"></a><a href="https://github.com/nickmessing" target="_blank"><img src="https://github.com/nickmessing.png?size=48" title="nickmessing" width="48" height="48"></a><a href="https://github.com/nikitavoloboev" target="_blank"><img src="https://github.com/nikitavoloboev.png?size=48" title="nikitavoloboev" width="48" height="48"></a><a href="https://github.com/nkzw-tech" target="_blank"><img src="https://github.com/nkzw-tech.png?size=48" title="nkzw-tech" width="48" height="48"></a><a href="https://github.com/palerdot" target="_blank"><img src="https://github.com/palerdot.png?size=48" title="palerdot" width="48" height="48"></a><a href="https://github.com/PorcoRosso85" target="_blank"><img src="https://github.com/PorcoRosso85.png?size=48" title="PorcoRosso85" width="48" height="48"></a><a href="https://github.com/primodiumxyz" target="_blank"><img src="https://github.com/primodiumxyz.png?size=48" title="primodiumxyz" width="48" height="48"></a><a href="https://github.com/shaneosullivan" target="_blank"><img src="https://github.com/shaneosullivan.png?size=48" title="shaneosullivan" width="48" height="48"></a><a href="https://github.com/sudo-self" target="_blank"><img src="https://github.com/sudo-self.png?size=48" title="sudo-self" width="48" height="48"></a><a href="https://github.com/SuperSonicHub1" target="_blank"><img src="https://github.com/SuperSonicHub1.png?size=48" title="SuperSonicHub1" width="48" height="48"></a><a href="https://github.com/threepointone" target="_blank"><img src="https://github.com/threepointone.png?size=48" title="threepointone" width="48" height="48"></a><a href="https://github.com/uptonking" target="_blank"><img src="https://github.com/uptonking.png?size=48" title="uptonking" width="48" height="48"></a><a href="https://github.com/ViktorZhurbin" target="_blank"><img src="https://github.com/ViktorZhurbin.png?size=48" title="ViktorZhurbin" width="48" height="48"></a><a href="https://github.com/wilkerlucio" target="_blank"><img src="https://github.com/wilkerlucio.png?size=48" title="wilkerlucio" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img src="https://github.com/WonderPanda.png?size=48" title="WonderPanda" width="48" height="48"></a></section><hr><p><a class="start" href="https://beta.tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://beta.tinybase.org/demos/">Try the demos</a></p><p><a href="https://beta.tinybase.org/api/the-essentials/creating-stores/store/">Read the docs</a></p><hr><section id="family"><h2 id="meet-the-family">Meet the family</h2><p>TinyBase is part of a group of small libraries designed to help make rich client and local-first apps easier to build. Check out the others!</p><p><a href="https://synclets.org" target="_blank"><img src="https://synclets.org/favicon.svg?asImg" width="48"><br><b>Synclets</b></a><br>An open, storage-agnostic, sync engine development kit.</p><p><a href="https://tinywidgets.org" target="_blank"><img src="https://tinywidgets.org/favicon.svg?asImg" width="48"><br><b>TinyWidgets</b></a><br>A collection of tiny, reusable, UI components.</p><p><a href="https://tinytick.org" target="_blank"><img src="https://tinytick.org/favicon.svg?asImg" width="48"><br><b>TinyTick</b></a><br>A tiny but very useful task orchestrator.</p></section><hr><section id="about"><h2 id="about">About</h2><p>Modern apps deserve better. Why trade reactive user experiences to be able to use relational data? Or sacrifice features for bundle size? And why does the cloud do all the work <a href="https://localfirstweb.dev/" target="_blank">anyway</a>?</p><p>Building TinyBase was originally an interesting exercise for <a rel="me" href="https://tripleodeon.com">me</a> in API design, minification, and documentation. But now it has taken on a life of its own, and has grown beyond my wildest expectations.</p><p>It could not have been built without these great <a href="https://beta.tinybase.org/guides/how-tinybase-is-built/credits/#giants">projects</a> and <a href="https://beta.tinybase.org/guides/how-tinybase-is-built/credits/#and-friends">friends</a>, and I hope you enjoy using it as much as I do building it!</p></section><section id="story"><h2 id="the-story">The story</h2><a href="https://youtu.be/hXL7OkW-Prk?t=1232" target="_blank"><img src="https://beta.tinybase.org/youtube.webp"></a></section>
278
+ <section><h2 id="did-we-say-tiny">Did we say tiny?</h2><p>If you use the basic <a href="https://beta.tinybase.org/api/store/"><code>store</code></a> module alone, you&#x27;ll only add a gzipped <em>5.4kB</em> to your app. Incrementally add the other modules as you need more functionality, or get it all for <em>11.8kB</em>.</p><p>The optional <a href="https://beta.tinybase.org/api/ui-react/"><code>ui-react</code></a> module is just <em>5.2kB</em>, the ui-react-dom components are another <em>3.7kB</em>, and everything is super fast. Life is easy when you have zero dependencies!</p><p>Read more about how TinyBase is structured and packaged in the <a href="https://beta.tinybase.org/guides/how-tinybase-is-built/architecture/">Architecture</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th> </th><th>Minified .js.gz</th><th>Source .js</th></tr><tr><th class="right"><a href="https://beta.tinybase.org/api/store/">tinybase/store</a> (minimal)</th><td>5.4kB</td><td>54.6kB</td></tr><tr><th class="right">tinybase (complete)</th><td>11.8kB</td><td>123.4kB</td></tr><tr><th class="right"><a href="https://beta.tinybase.org/api/ui-react/">ui-react</a></th><td>5.2kB</td><td>55.6kB</td></tr><tr><th class="right"><a href="https://beta.tinybase.org/api/ui-react-dom/">ui-react-dom</a></th><td>3.7kB</td><td>32.8kB</td></tr></tbody></table></div><section><h2 id="well-tested-and-documented">Well tested and documented.</h2><p>TinyBase has <em>100.0%</em> test coverage, including the code throughout the documentation - even on this page! The guides, demos, and API examples are designed to make it as easy as possible for you to get your TinyBase-powered app up and running.</p><p>Read more about how TinyBase is tested in the Unit <a href="https://beta.tinybase.org/guides/how-tinybase-is-built/testing/">Testing</a> guide.</p></section><div class="table"><table class="fixed"><tbody><tr><th width="30%"> </th><th>Total</th><th>Tested</th><th>Coverage</th></tr><tr><th class="right">Lines</th><td>2,341</td><td>2,341</td><td>100.0%</td></tr><tr><th class="right">Statements</th><td>2,534</td><td>2,534</td><td>100.0%</td></tr><tr><th class="right">Functions</th><td>1,010</td><td>1,010</td><td>100.0%</td></tr><tr><th class="right">Branches</th><td>892</td><td>892</td><td>100.0%</td></tr><tr><th class="right">Tests</th><td colspan="3">7,142</td></tr><tr><th class="right">Assertions</th><td colspan="3">32,013</td></tr></tbody></table></div><hr><section id="sponsors"><h2 id="proud-to-be-sponsored-by">Proud to be sponsored by:</h2><a href="https://github.com/cpojer" target="_blank"><img src="https://github.com/cpojer.png?size=48" title="cpojer" width="48" height="48"></a><a href="https://github.com/expo" target="_blank"><img src="https://github.com/expo.png?size=48" title="expo" width="48" height="48"></a><a href="https://github.com/beekeeb" target="_blank"><img src="https://github.com/beekeeb.png?size=48" title="beekeeb" width="48" height="48"></a><a href="https://github.com/cancelself" target="_blank"><img src="https://github.com/cancelself.png?size=48" title="cancelself" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img src="https://github.com/WonderPanda.png?size=48" title="WonderPanda" width="48" height="48"></a><a href="https://github.com/arpitBhalla" target="_blank"><img src="https://github.com/arpitBhalla.png?size=48" title="arpitBhalla" width="48" height="48"></a></section><section id="users"><h2 id="excited-to-be-used-by">Excited to be used by:</h2><a href="https://github.com/behrends" target="_blank"><img src="https://github.com/behrends.png?size=48" title="behrends" width="48" height="48"></a><a href="https://github.com/betomoedano" target="_blank"><img src="https://github.com/betomoedano.png?size=48" title="betomoedano" width="48" height="48"></a><a href="https://github.com/brentvatne" target="_blank"><img src="https://github.com/brentvatne.png?size=48" title="brentvatne" width="48" height="48"></a><a href="https://github.com/byCedric" target="_blank"><img src="https://github.com/byCedric.png?size=48" title="byCedric" width="48" height="48"></a><a href="https://github.com/circadian-risk" target="_blank"><img src="https://github.com/circadian-risk.png?size=48" title="circadian-risk" width="48" height="48"></a><a href="https://github.com/cpojer" target="_blank"><img src="https://github.com/cpojer.png?size=48" title="cpojer" width="48" height="48"></a><a href="https://github.com/cubecull" target="_blank"><img src="https://github.com/cubecull.png?size=48" title="cubecull" width="48" height="48"></a><a href="https://github.com/erwinkn" target="_blank"><img src="https://github.com/erwinkn.png?size=48" title="erwinkn" width="48" height="48"></a><a href="https://github.com/expo" target="_blank"><img src="https://github.com/expo.png?size=48" title="expo" width="48" height="48"></a><a href="https://github.com/ezra-en" target="_blank"><img src="https://github.com/ezra-en.png?size=48" title="ezra-en" width="48" height="48"></a><a href="https://github.com/feychenie" target="_blank"><img src="https://github.com/feychenie.png?size=48" title="feychenie" width="48" height="48"></a><a href="https://github.com/flaming-codes" target="_blank"><img src="https://github.com/flaming-codes.png?size=48" title="flaming-codes" width="48" height="48"></a><a href="https://github.com/fostertheweb" target="_blank"><img src="https://github.com/fostertheweb.png?size=48" title="fostertheweb" width="48" height="48"></a><a href="https://github.com/Giulio987" target="_blank"><img src="https://github.com/Giulio987.png?size=48" title="Giulio987" width="48" height="48"></a><a href="https://github.com/hi-ogawa" target="_blank"><img src="https://github.com/hi-ogawa.png?size=48" title="hi-ogawa" width="48" height="48"></a><a href="https://github.com/itsdevcoffee" target="_blank"><img src="https://github.com/itsdevcoffee.png?size=48" title="itsdevcoffee" width="48" height="48"></a><a href="https://github.com/jbolda" target="_blank"><img src="https://github.com/jbolda.png?size=48" title="jbolda" width="48" height="48"></a><a href="https://github.com/Kayoo-asso" target="_blank"><img src="https://github.com/Kayoo-asso.png?size=48" title="Kayoo-asso" width="48" height="48"></a><a href="https://github.com/kotofurumiya" target="_blank"><img src="https://github.com/kotofurumiya.png?size=48" title="kotofurumiya" width="48" height="48"></a><a href="https://github.com/Kudo" target="_blank"><img src="https://github.com/Kudo.png?size=48" title="Kudo" width="48" height="48"></a><a href="https://github.com/learn-anything" target="_blank"><img src="https://github.com/learn-anything.png?size=48" title="learn-anything" width="48" height="48"></a><a href="https://github.com/lluc" target="_blank"><img src="https://github.com/lluc.png?size=48" title="lluc" width="48" height="48"></a><a href="https://github.com/marksteve" target="_blank"><img src="https://github.com/marksteve.png?size=48" title="marksteve" width="48" height="48"></a><a href="https://github.com/miking-the-viking" target="_blank"><img src="https://github.com/miking-the-viking.png?size=48" title="miking-the-viking" width="48" height="48"></a><a href="https://github.com/mjamesderocher" target="_blank"><img src="https://github.com/mjamesderocher.png?size=48" title="mjamesderocher" width="48" height="48"></a><a href="https://github.com/mouktardev" target="_blank"><img src="https://github.com/mouktardev.png?size=48" title="mouktardev" width="48" height="48"></a><a href="https://github.com/nickmessing" target="_blank"><img src="https://github.com/nickmessing.png?size=48" title="nickmessing" width="48" height="48"></a><a href="https://github.com/nikitavoloboev" target="_blank"><img src="https://github.com/nikitavoloboev.png?size=48" title="nikitavoloboev" width="48" height="48"></a><a href="https://github.com/nkzw-tech" target="_blank"><img src="https://github.com/nkzw-tech.png?size=48" title="nkzw-tech" width="48" height="48"></a><a href="https://github.com/palerdot" target="_blank"><img src="https://github.com/palerdot.png?size=48" title="palerdot" width="48" height="48"></a><a href="https://github.com/PorcoRosso85" target="_blank"><img src="https://github.com/PorcoRosso85.png?size=48" title="PorcoRosso85" width="48" height="48"></a><a href="https://github.com/primodiumxyz" target="_blank"><img src="https://github.com/primodiumxyz.png?size=48" title="primodiumxyz" width="48" height="48"></a><a href="https://github.com/shaneosullivan" target="_blank"><img src="https://github.com/shaneosullivan.png?size=48" title="shaneosullivan" width="48" height="48"></a><a href="https://github.com/sudo-self" target="_blank"><img src="https://github.com/sudo-self.png?size=48" title="sudo-self" width="48" height="48"></a><a href="https://github.com/SuperSonicHub1" target="_blank"><img src="https://github.com/SuperSonicHub1.png?size=48" title="SuperSonicHub1" width="48" height="48"></a><a href="https://github.com/threepointone" target="_blank"><img src="https://github.com/threepointone.png?size=48" title="threepointone" width="48" height="48"></a><a href="https://github.com/uptonking" target="_blank"><img src="https://github.com/uptonking.png?size=48" title="uptonking" width="48" height="48"></a><a href="https://github.com/ViktorZhurbin" target="_blank"><img src="https://github.com/ViktorZhurbin.png?size=48" title="ViktorZhurbin" width="48" height="48"></a><a href="https://github.com/wilkerlucio" target="_blank"><img src="https://github.com/wilkerlucio.png?size=48" title="wilkerlucio" width="48" height="48"></a><a href="https://github.com/WonderPanda" target="_blank"><img src="https://github.com/WonderPanda.png?size=48" title="WonderPanda" width="48" height="48"></a></section><hr><p><a class="start" href="https://beta.tinybase.org/guides/the-basics/getting-started/">Get started</a></p><p><a href="https://beta.tinybase.org/demos/">Try the demos</a></p><p><a href="https://beta.tinybase.org/api/the-essentials/creating-stores/store/">Read the docs</a></p><hr><section id="family"><h2 id="meet-the-family">Meet the family</h2><p>TinyBase is part of a group of small libraries designed to help make rich client and local-first apps easier to build. Check out the others!</p><p><a href="https://synclets.org" target="_blank"><img src="https://synclets.org/favicon.svg?asImg" width="48"><br><b>Synclets</b></a><br>An open, storage-agnostic, sync engine development kit.</p><p><a href="https://tinywidgets.org" target="_blank"><img src="https://tinywidgets.org/favicon.svg?asImg" width="48"><br><b>TinyWidgets</b></a><br>A collection of tiny, reusable, UI components.</p><p><a href="https://tinytick.org" target="_blank"><img src="https://tinytick.org/favicon.svg?asImg" width="48"><br><b>TinyTick</b></a><br>A tiny but very useful task orchestrator.</p></section><hr><section id="about"><h2 id="about">About</h2><p>Modern apps deserve better. Why trade reactive user experiences to be able to use relational data? Or sacrifice features for bundle size? And why does the cloud do all the work <a href="https://localfirstweb.dev/" target="_blank">anyway</a>?</p><p>Building TinyBase was originally an interesting exercise for <a rel="me" href="https://tripleodeon.com">me</a> in API design, minification, and documentation. But now it has taken on a life of its own, and has grown beyond my wildest expectations.</p><p>It could not have been built without these great <a href="https://beta.tinybase.org/guides/how-tinybase-is-built/credits/#giants">projects</a> and <a href="https://beta.tinybase.org/guides/how-tinybase-is-built/credits/#and-friends">friends</a>, and I hope you enjoy using it as much as I do building it!</p></section><section id="story"><h2 id="the-story">The story</h2><a href="https://youtu.be/hXL7OkW-Prk?t=1232" target="_blank"><img src="https://beta.tinybase.org/youtube.webp"></a></section>