tinybase-zod 0.1.0
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/LICENSE +21 -0
- package/README.md +228 -0
- package/dist/codec.d.ts +29 -0
- package/dist/codec.d.ts.map +1 -0
- package/dist/codec.js +42 -0
- package/dist/codec.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/store.d.ts +5 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +509 -0
- package/dist/store.js.map +1 -0
- package/dist/type.d.ts +107 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js +2 -0
- package/dist/type.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 dpeek
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
## tinybase-zod
|
|
2
|
+
|
|
3
|
+
A small TypeScript library that wraps a TinyBase `Store` with a **Zod-backed typed API**.
|
|
4
|
+
|
|
5
|
+
You describe your data model once as a Zod schema:
|
|
6
|
+
|
|
7
|
+
- **Tables**: `tables: { [tableId]: z.object({ ...cells }) }`
|
|
8
|
+
- **Values**: `values: z.object({ ...valueIds })`
|
|
9
|
+
|
|
10
|
+
…and `createTypedStore(store, schema)` returns a `typedStore` whose `get*` methods **decode** and whose `set*` methods **encode**, while keeping **TinyBase’s API shape** (tables/rows/cells/values + listeners + transactions).
|
|
11
|
+
|
|
12
|
+
### Status
|
|
13
|
+
|
|
14
|
+
Public entrypoint: `src/index.ts` (re-exports `codec`, `store`, and `type`).
|
|
15
|
+
|
|
16
|
+
## The core idea (storage contract)
|
|
17
|
+
|
|
18
|
+
TinyBase cells are expected to be scalars, so this wrapper enforces a simple contract:
|
|
19
|
+
|
|
20
|
+
- **Every schema used in a table cell or value must encode to:**
|
|
21
|
+
- `string | number | boolean | null | undefined`
|
|
22
|
+
- `undefined` means “delete / absent”
|
|
23
|
+
|
|
24
|
+
If a schema encodes to a non-primitive (for example a plain `z.object(...)`, `z.array(...)`, `z.date()`, `z.bigint()`, etc.), writes will throw with a message like:
|
|
25
|
+
|
|
26
|
+
- `Invalid encoded value for TinyBase storage at ... Expected string|number|boolean|null (or undefined to delete), got object.`
|
|
27
|
+
|
|
28
|
+
To store structured data, you must wrap it in an explicit codec.
|
|
29
|
+
|
|
30
|
+
## Quick start
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { createStore } from "tinybase";
|
|
34
|
+
import z from "zod";
|
|
35
|
+
import {
|
|
36
|
+
createTypedStore,
|
|
37
|
+
json,
|
|
38
|
+
dateAsIso,
|
|
39
|
+
dateAsNumberMs,
|
|
40
|
+
} from "tinybase-zod";
|
|
41
|
+
|
|
42
|
+
const userRow = z.object({
|
|
43
|
+
name: z.string(),
|
|
44
|
+
age: z.number(),
|
|
45
|
+
|
|
46
|
+
// Structured cells must be wrapped so they encode to strings.
|
|
47
|
+
prefs: json(z.object({ theme: z.enum(["light", "dark"]) })),
|
|
48
|
+
tags: json(z.array(z.string())),
|
|
49
|
+
|
|
50
|
+
// Non-JSON types should use explicit codecs too.
|
|
51
|
+
createdAt: dateAsIso,
|
|
52
|
+
|
|
53
|
+
// Or persist as numbers (ms since epoch).
|
|
54
|
+
createdAtMs: dateAsNumberMs,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const schema = {
|
|
58
|
+
tables: {
|
|
59
|
+
users: userRow,
|
|
60
|
+
},
|
|
61
|
+
values: z.object({
|
|
62
|
+
selectedUserId: z.string().nullable(),
|
|
63
|
+
}),
|
|
64
|
+
} as const;
|
|
65
|
+
|
|
66
|
+
const store = createStore();
|
|
67
|
+
const typed = createTypedStore(store, schema);
|
|
68
|
+
|
|
69
|
+
// Tests typically initialize tables/values explicitly.
|
|
70
|
+
store.setTables({ users: {} });
|
|
71
|
+
store.setValues({});
|
|
72
|
+
|
|
73
|
+
typed.setRow("users", "u1", {
|
|
74
|
+
name: "Ava",
|
|
75
|
+
age: 34,
|
|
76
|
+
prefs: { theme: "dark" },
|
|
77
|
+
tags: ["admin"],
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Reads are decoded.
|
|
81
|
+
console.log(typed.getCell("users", "u1", "prefs")); // { theme: "dark" }
|
|
82
|
+
|
|
83
|
+
// Underlying TinyBase storage contains JSON strings for json(...) fields.
|
|
84
|
+
console.log(store.getCell("users", "u1", "prefs")); // '{"theme":"dark"}'
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## How it works
|
|
88
|
+
|
|
89
|
+
### 1) You provide a schema
|
|
90
|
+
|
|
91
|
+
A `StoreSchema` is:
|
|
92
|
+
|
|
93
|
+
- **`tables`**: a map of table ids to `z.object({...})` row schemas
|
|
94
|
+
- **`values`**: a single `z.object({...})` for global values
|
|
95
|
+
|
|
96
|
+
`createTypedStore` does not auto-modify your schema. It uses it as-is.
|
|
97
|
+
|
|
98
|
+
### 2) Reads decode, writes encode
|
|
99
|
+
|
|
100
|
+
- **Tables** are encoded/decoded via `z.record(z.string(), rowSchema)`.
|
|
101
|
+
- `getTable`, `getRow`, `getCell`, `getValue` return decoded values.
|
|
102
|
+
- `setTable`, `setRow`, `setCell`, `setValue` encode before writing.
|
|
103
|
+
|
|
104
|
+
On every write, the wrapper validates that encoded cells are storage scalars.
|
|
105
|
+
|
|
106
|
+
### 3) `undefined` is treated as deletion
|
|
107
|
+
|
|
108
|
+
- When writing rows/tables, any encoded `undefined` cells are stripped.
|
|
109
|
+
- When writing a single cell/value, if the encoded result is `undefined`, the wrapper deletes it.
|
|
110
|
+
|
|
111
|
+
This means you can model “optional deletes” using codecs that sometimes encode to `undefined`.
|
|
112
|
+
|
|
113
|
+
### 4) Listener payloads are decoded
|
|
114
|
+
|
|
115
|
+
Listener callbacks wrap the underlying TinyBase listener and:
|
|
116
|
+
|
|
117
|
+
- pass `typedStore` instead of the raw store
|
|
118
|
+
- decode `new`/`old` values
|
|
119
|
+
- decode `getCellChange(...)` / `getValueChange(...)` results when those helper functions are available
|
|
120
|
+
|
|
121
|
+
Mutator listeners (`mutator: true`) behave like TinyBase: they run before non-mutators and can safely update state.
|
|
122
|
+
|
|
123
|
+
## How to store structured data
|
|
124
|
+
|
|
125
|
+
### JSON strings via `json(...)`
|
|
126
|
+
|
|
127
|
+
`src/codec.ts` exports a helper:
|
|
128
|
+
|
|
129
|
+
- `json(schema)` wraps any JSON-serializable schema and stores it as a JSON string.
|
|
130
|
+
|
|
131
|
+
It is implemented via `z.codec(...)` with `JSON.stringify` / `JSON.parse`.
|
|
132
|
+
|
|
133
|
+
If you need `null`/`undefined` support, apply wrappers outside the codec:
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
const maybePrefs = json(z.object({ theme: z.string() })).optional();
|
|
137
|
+
const nullablePrefs = json(z.object({ theme: z.string() })).nullable();
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Use it for:
|
|
141
|
+
|
|
142
|
+
- objects (`z.object(...)`)
|
|
143
|
+
- arrays (`z.array(...)`)
|
|
144
|
+
- tuples / records / unions that decode to JSON data
|
|
145
|
+
|
|
146
|
+
### Custom codecs (dates, bigints, etc.)
|
|
147
|
+
|
|
148
|
+
For non-JSON types, define your own storage representation:
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
import { z } from "zod";
|
|
152
|
+
|
|
153
|
+
export const bigintAsString = z.codec(z.string(), z.bigint(), {
|
|
154
|
+
encode: (b) => b.toString(),
|
|
155
|
+
decode: (s) => BigInt(s),
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
This repo also ships date codecs in `src/codec.ts`:
|
|
160
|
+
|
|
161
|
+
- `dateAsIso` (ISO string)
|
|
162
|
+
- `dateAsNumberMs` / `dateAsNumberSeconds` (numbers)
|
|
163
|
+
|
|
164
|
+
## TinyBase limitations / gotchas
|
|
165
|
+
|
|
166
|
+
### No partial rows (important)
|
|
167
|
+
|
|
168
|
+
This wrapper intentionally avoids a common TinyBase behavior: **creating/patching rows implicitly via `setCell`**.
|
|
169
|
+
|
|
170
|
+
- **`typed.setCell(...)` throws if the row does not already exist**.
|
|
171
|
+
|
|
172
|
+
- This prevents accidentally creating a “partial” row that does not satisfy your Zod row schema.
|
|
173
|
+
- Create rows with `setRow(...)` first.
|
|
174
|
+
|
|
175
|
+
- **`typed.setRow(...)` expects a schema-valid row**.
|
|
176
|
+
- If you want “partial row updates”, model that explicitly:
|
|
177
|
+
- make fields optional in your Zod schema, or
|
|
178
|
+
- update individual cells with `setCell(...)` after creating the row.
|
|
179
|
+
|
|
180
|
+
### Underlying storage is not your runtime shape
|
|
181
|
+
|
|
182
|
+
If you access the underlying TinyBase `store` directly, you’ll see encoded storage values (for example JSON strings), not decoded runtime objects.
|
|
183
|
+
|
|
184
|
+
## Zod limitations / gotchas
|
|
185
|
+
|
|
186
|
+
### Schemas must be encodable
|
|
187
|
+
|
|
188
|
+
Because writes call `.encode()`, any schema that can’t encode will fail at runtime.
|
|
189
|
+
|
|
190
|
+
Common causes:
|
|
191
|
+
|
|
192
|
+
- **Plain structured schemas** (`z.object`, `z.array`, etc.) encode to objects/arrays → wrap with `json(...)`.
|
|
193
|
+
- **Unidirectional transforms** (`z.preprocess`, `.transform`) are not encodable in Zod v4 → use a bidirectional `z.codec(...)` instead.
|
|
194
|
+
|
|
195
|
+
## Development
|
|
196
|
+
|
|
197
|
+
### Install
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
bun install
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Run tests
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
bun test
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Typecheck
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
bun run check
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Build (for publishing)
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
bun run build
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Files to look at
|
|
222
|
+
|
|
223
|
+
- `src/store.ts`: implementation of `createTypedStore`
|
|
224
|
+
- `src/codec.ts`: storage codecs like `json(...)` and `dateAsIso`
|
|
225
|
+
- `src/type.ts`: the TypeScript type-level surface for `TypedStore<Schema>`
|
|
226
|
+
- `src/example.ts`: a small usage sketch
|
|
227
|
+
- `src/*.test.ts`: runtime behavior tests
|
|
228
|
+
- `src/*.type.test.ts`: type-level tests
|
package/dist/codec.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { SomeType } from "zod/v4/core";
|
|
3
|
+
/**
|
|
4
|
+
* Store JSON-serializable values as JSON strings.
|
|
5
|
+
*
|
|
6
|
+
* Use wrappers *outside* the codec for nullish/optional behavior:
|
|
7
|
+
* - json(schema).optional()
|
|
8
|
+
* - json(schema).nullable()
|
|
9
|
+
*/
|
|
10
|
+
export declare function json<B extends SomeType>(schema: B): z.ZodCodec<z.ZodString, B>;
|
|
11
|
+
/**
|
|
12
|
+
* Store Dates as ISO-8601 strings.
|
|
13
|
+
*/
|
|
14
|
+
export declare const dateAsIso: z.ZodCodec<z.ZodString, z.ZodDate>;
|
|
15
|
+
/**
|
|
16
|
+
* Store Dates as numbers (milliseconds since Unix epoch).
|
|
17
|
+
*/
|
|
18
|
+
export declare const dateAsNumberMs: z.ZodCodec<z.ZodNumber, z.ZodDate>;
|
|
19
|
+
/**
|
|
20
|
+
* Store Dates as numbers (seconds since Unix epoch).
|
|
21
|
+
*
|
|
22
|
+
* Note: This intentionally truncates sub-second precision.
|
|
23
|
+
*/
|
|
24
|
+
export declare const dateAsNumberSeconds: z.ZodCodec<z.ZodNumber, z.ZodDate>;
|
|
25
|
+
/**
|
|
26
|
+
* Alias for `dateAsNumberMs`.
|
|
27
|
+
*/
|
|
28
|
+
export declare const dateAsNumber: z.ZodCodec<z.ZodNumber, z.ZodDate>;
|
|
29
|
+
//# sourceMappingURL=codec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,QAAQ,EAAS,MAAM,aAAa,CAAC;AAEnD;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,QAAQ,EAAE,MAAM,EAAE,CAAC,8BAKjD;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,oCAGpB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc,oCAGzB,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,oCAG9B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,YAAY,oCAAiB,CAAC"}
|
package/dist/codec.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Store JSON-serializable values as JSON strings.
|
|
4
|
+
*
|
|
5
|
+
* Use wrappers *outside* the codec for nullish/optional behavior:
|
|
6
|
+
* - json(schema).optional()
|
|
7
|
+
* - json(schema).nullable()
|
|
8
|
+
*/
|
|
9
|
+
export function json(schema) {
|
|
10
|
+
return z.codec(z.string(), schema, {
|
|
11
|
+
decode: (stored) => JSON.parse(stored),
|
|
12
|
+
encode: (value) => JSON.stringify(value),
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Store Dates as ISO-8601 strings.
|
|
17
|
+
*/
|
|
18
|
+
export const dateAsIso = z.codec(z.string(), z.date(), {
|
|
19
|
+
encode: (d) => d.toISOString(),
|
|
20
|
+
decode: (s) => new Date(s),
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Store Dates as numbers (milliseconds since Unix epoch).
|
|
24
|
+
*/
|
|
25
|
+
export const dateAsNumberMs = z.codec(z.number(), z.date(), {
|
|
26
|
+
encode: (d) => d.getTime(),
|
|
27
|
+
decode: (ms) => new Date(ms),
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Store Dates as numbers (seconds since Unix epoch).
|
|
31
|
+
*
|
|
32
|
+
* Note: This intentionally truncates sub-second precision.
|
|
33
|
+
*/
|
|
34
|
+
export const dateAsNumberSeconds = z.codec(z.number(), z.date(), {
|
|
35
|
+
encode: (d) => Math.trunc(d.getTime() / 1000),
|
|
36
|
+
decode: (seconds) => new Date(seconds * 1000),
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Alias for `dateAsNumberMs`.
|
|
40
|
+
*/
|
|
41
|
+
export const dateAsNumber = dateAsNumberMs;
|
|
42
|
+
//# sourceMappingURL=codec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAAqB,MAAS;IAChD,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE;QACjC,MAAM,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAa;QAC1D,MAAM,EAAE,CAAC,KAAe,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;KACnD,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE;IACrD,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE;IAC9B,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;CAC3B,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE;IAC1D,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE;IAC1B,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC;CAC7B,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE;IAC/D,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;IAC7C,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;CAC9C,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
|
package/dist/store.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Store } from "tinybase";
|
|
2
|
+
import type { StoreSchema, TypedStore } from "./type";
|
|
3
|
+
export { json } from "./codec";
|
|
4
|
+
export declare function createTypedStore<Schema extends StoreSchema>(store: Store, schema: Schema): TypedStore<Schema>;
|
|
5
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,KAAK,EAEX,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEtD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAkD/B,wBAAgB,gBAAgB,CAAC,MAAM,SAAS,WAAW,EACzD,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,sBAs0Bf"}
|
package/dist/store.js
ADDED
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
import {} from "tinybase";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export { json } from "./codec";
|
|
4
|
+
function isStorageCell(value) {
|
|
5
|
+
return (value === null ||
|
|
6
|
+
typeof value === "string" ||
|
|
7
|
+
typeof value === "number" ||
|
|
8
|
+
typeof value === "boolean");
|
|
9
|
+
}
|
|
10
|
+
function assertStorageCell(value, context) {
|
|
11
|
+
if (value === undefined) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (isStorageCell(value)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
throw new Error(`Invalid encoded value for TinyBase storage at ${context}. ` +
|
|
18
|
+
`Expected string|number|boolean|null (or undefined to delete), got ${typeof value}. ` +
|
|
19
|
+
`Wrap non-primitive schemas with an explicit codec (e.g. json(schema), isoDate, bigintString).`);
|
|
20
|
+
}
|
|
21
|
+
function encodeRow(encoded, context) {
|
|
22
|
+
const out = {};
|
|
23
|
+
for (const [cellId, cell] of Object.entries(encoded)) {
|
|
24
|
+
assertStorageCell(cell, `${context}.${cellId}`);
|
|
25
|
+
if (cell !== undefined) {
|
|
26
|
+
out[cellId] = cell;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
function encodeTable(encoded, context) {
|
|
32
|
+
const out = {};
|
|
33
|
+
for (const [rowId, row] of Object.entries(encoded)) {
|
|
34
|
+
out[rowId] = encodeRow(row, `${context}.${rowId}`);
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
export function createTypedStore(store, schema) {
|
|
39
|
+
const mapped = schema;
|
|
40
|
+
function getRowSchema(tableId) {
|
|
41
|
+
const schema = mapped.tables[tableId];
|
|
42
|
+
if (!schema) {
|
|
43
|
+
throw new Error(`Unknown tableId: ${tableId}`);
|
|
44
|
+
}
|
|
45
|
+
return schema;
|
|
46
|
+
}
|
|
47
|
+
function getCellSchema(tableId, cellId) {
|
|
48
|
+
const tableSchema = mapped.tables[tableId];
|
|
49
|
+
if (!tableSchema) {
|
|
50
|
+
throw new Error(`Unknown tableId: ${tableId}`);
|
|
51
|
+
}
|
|
52
|
+
const cellSchema = tableSchema.shape[cellId];
|
|
53
|
+
if (!cellSchema) {
|
|
54
|
+
throw new Error(`Unknown cellId: ${tableId}.${cellId}`);
|
|
55
|
+
}
|
|
56
|
+
return cellSchema;
|
|
57
|
+
}
|
|
58
|
+
function tryGetCellSchema(tableId, cellId) {
|
|
59
|
+
return mapped.tables[tableId]?.shape?.[cellId];
|
|
60
|
+
}
|
|
61
|
+
function getValueSchema(valueId) {
|
|
62
|
+
const valueSchema = mapped.values.shape[valueId];
|
|
63
|
+
if (!valueSchema) {
|
|
64
|
+
throw new Error(`Unknown valueId: ${valueId}`);
|
|
65
|
+
}
|
|
66
|
+
return valueSchema;
|
|
67
|
+
}
|
|
68
|
+
function tryGetValueSchema(valueId) {
|
|
69
|
+
return mapped.values.shape?.[valueId];
|
|
70
|
+
}
|
|
71
|
+
function getTables() {
|
|
72
|
+
const tables = store.getTables();
|
|
73
|
+
const decoded = {};
|
|
74
|
+
for (const [tableId, table] of Object.entries(tables)) {
|
|
75
|
+
const schema = mapped.tables[tableId];
|
|
76
|
+
if (!schema) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
decoded[tableId] = z.record(z.string(), schema).decode(table);
|
|
80
|
+
}
|
|
81
|
+
return decoded;
|
|
82
|
+
}
|
|
83
|
+
function setTables(tables) {
|
|
84
|
+
const encoded = {};
|
|
85
|
+
for (const [tableId, table] of Object.entries(tables)) {
|
|
86
|
+
const schema = mapped.tables[tableId];
|
|
87
|
+
if (!schema) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const encodedTable = z
|
|
91
|
+
.record(z.string(), schema)
|
|
92
|
+
.encode(table);
|
|
93
|
+
encoded[tableId] = encodeTable(encodedTable, `tables.${tableId}`);
|
|
94
|
+
}
|
|
95
|
+
store.setTables(encoded);
|
|
96
|
+
return typedStore;
|
|
97
|
+
}
|
|
98
|
+
function delTables() {
|
|
99
|
+
store.delTables();
|
|
100
|
+
return typedStore;
|
|
101
|
+
}
|
|
102
|
+
function getTable(tableId) {
|
|
103
|
+
const table = store.getTable(tableId);
|
|
104
|
+
const schema = getRowSchema(tableId);
|
|
105
|
+
return z.record(z.string(), schema).decode(table);
|
|
106
|
+
}
|
|
107
|
+
function setTable(tableId, table) {
|
|
108
|
+
const schema = getRowSchema(tableId);
|
|
109
|
+
const encodedTable = z
|
|
110
|
+
.record(z.string(), schema)
|
|
111
|
+
.encode(table);
|
|
112
|
+
store.setTable(tableId, encodeTable(encodedTable, `tables.${tableId}`));
|
|
113
|
+
return typedStore;
|
|
114
|
+
}
|
|
115
|
+
function delTable(tableId) {
|
|
116
|
+
store.delTable(tableId);
|
|
117
|
+
return typedStore;
|
|
118
|
+
}
|
|
119
|
+
function getRow(tableId, rowId) {
|
|
120
|
+
const schema = getRowSchema(tableId);
|
|
121
|
+
const row = store.getRow(tableId, rowId);
|
|
122
|
+
if (row === undefined || Object.keys(row).length === 0) {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
return schema.decode(row);
|
|
126
|
+
}
|
|
127
|
+
function setRow(tableId, rowId, row) {
|
|
128
|
+
const schema = getRowSchema(tableId);
|
|
129
|
+
const encoded = schema.encode(row);
|
|
130
|
+
store.setRow(tableId, rowId, encodeRow(encoded, `tables.${tableId}.${rowId}`));
|
|
131
|
+
return typedStore;
|
|
132
|
+
}
|
|
133
|
+
function delRow(tableId, rowId) {
|
|
134
|
+
store.delRow(tableId, rowId);
|
|
135
|
+
return typedStore;
|
|
136
|
+
}
|
|
137
|
+
function getCell(tableId, rowId, cellId) {
|
|
138
|
+
const schema = getCellSchema(tableId, cellId);
|
|
139
|
+
const cell = store.getCell(tableId, rowId, cellId);
|
|
140
|
+
if (cell === undefined) {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
return schema.decode(cell);
|
|
144
|
+
}
|
|
145
|
+
function setCell(tableId, rowId, cellId, cell) {
|
|
146
|
+
if (!store.hasRow(tableId, rowId)) {
|
|
147
|
+
throw new Error(`Cannot set cell on missing row: ${tableId}/${rowId}. Create the row with setRow() first.`);
|
|
148
|
+
}
|
|
149
|
+
const schema = getCellSchema(tableId, cellId);
|
|
150
|
+
if (typeof cell === "function") {
|
|
151
|
+
const mapCell = (encoded) => {
|
|
152
|
+
const decoded = encoded === undefined ? undefined : schema.decode(encoded);
|
|
153
|
+
const nextDecoded = cell(decoded);
|
|
154
|
+
if (nextDecoded === undefined) {
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
const nextEncoded = schema.encode(nextDecoded);
|
|
158
|
+
assertStorageCell(nextEncoded, `tables.${tableId}.${rowId}.${cellId}`);
|
|
159
|
+
return nextEncoded;
|
|
160
|
+
};
|
|
161
|
+
store.setCell(tableId, rowId, cellId, mapCell);
|
|
162
|
+
return typedStore;
|
|
163
|
+
}
|
|
164
|
+
const encoded = schema.encode(cell);
|
|
165
|
+
assertStorageCell(encoded, `tables.${tableId}.${rowId}.${cellId}`);
|
|
166
|
+
if (encoded === undefined) {
|
|
167
|
+
store.delCell(tableId, rowId, cellId);
|
|
168
|
+
return typedStore;
|
|
169
|
+
}
|
|
170
|
+
store.setCell(tableId, rowId, cellId, encoded);
|
|
171
|
+
return typedStore;
|
|
172
|
+
}
|
|
173
|
+
function delCell(tableId, rowId, cellId) {
|
|
174
|
+
store.delCell(tableId, rowId, cellId);
|
|
175
|
+
return typedStore;
|
|
176
|
+
}
|
|
177
|
+
function hasTables() {
|
|
178
|
+
return store.hasTables();
|
|
179
|
+
}
|
|
180
|
+
function hasTable(tableId) {
|
|
181
|
+
return store.hasTable(tableId);
|
|
182
|
+
}
|
|
183
|
+
function hasTableCell(tableId, cellId) {
|
|
184
|
+
return store.hasTableCell(tableId, cellId);
|
|
185
|
+
}
|
|
186
|
+
function hasRow(tableId, rowId) {
|
|
187
|
+
return store.hasRow(tableId, rowId);
|
|
188
|
+
}
|
|
189
|
+
function hasCell(tableId, rowId, cellId) {
|
|
190
|
+
return store.hasCell(tableId, rowId, cellId);
|
|
191
|
+
}
|
|
192
|
+
function getTableIds() {
|
|
193
|
+
return store.getTableIds();
|
|
194
|
+
}
|
|
195
|
+
function getRowIds(tableId) {
|
|
196
|
+
return store.getRowIds(tableId);
|
|
197
|
+
}
|
|
198
|
+
function getCellIds(tableId, rowId) {
|
|
199
|
+
return store.getCellIds(tableId, rowId);
|
|
200
|
+
}
|
|
201
|
+
function getTableCellIds(tableId) {
|
|
202
|
+
return store.getTableCellIds(tableId);
|
|
203
|
+
}
|
|
204
|
+
function getSortedRowIds(tableIdOrArgs, cellId, descending, offset, limit) {
|
|
205
|
+
return typeof tableIdOrArgs === "string"
|
|
206
|
+
? store.getSortedRowIds(tableIdOrArgs, cellId, descending, offset, limit)
|
|
207
|
+
: store.getSortedRowIds(tableIdOrArgs);
|
|
208
|
+
}
|
|
209
|
+
function transaction(actions, doRollback) {
|
|
210
|
+
return store.transaction(actions, doRollback);
|
|
211
|
+
}
|
|
212
|
+
function startTransaction() {
|
|
213
|
+
store.startTransaction();
|
|
214
|
+
return typedStore;
|
|
215
|
+
}
|
|
216
|
+
function finishTransaction(doRollback) {
|
|
217
|
+
store.finishTransaction(doRollback);
|
|
218
|
+
return typedStore;
|
|
219
|
+
}
|
|
220
|
+
function callListener(listenerId) {
|
|
221
|
+
store.callListener(listenerId);
|
|
222
|
+
return typedStore;
|
|
223
|
+
}
|
|
224
|
+
function delListener(listenerId) {
|
|
225
|
+
store.delListener(listenerId);
|
|
226
|
+
return typedStore;
|
|
227
|
+
}
|
|
228
|
+
function getJson() {
|
|
229
|
+
return store.getJson();
|
|
230
|
+
}
|
|
231
|
+
function setJson(tablesAndValuesJson) {
|
|
232
|
+
store.setJson(tablesAndValuesJson);
|
|
233
|
+
return typedStore;
|
|
234
|
+
}
|
|
235
|
+
function getValues() {
|
|
236
|
+
const values = store.getValues();
|
|
237
|
+
const decoded = {};
|
|
238
|
+
for (const valueId of Object.keys(mapped.values.shape)) {
|
|
239
|
+
if (Object.prototype.hasOwnProperty.call(values, valueId)) {
|
|
240
|
+
const valueSchema = mapped.values.shape[valueId];
|
|
241
|
+
decoded[valueId] = valueSchema.decode(values[valueId]);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return decoded;
|
|
245
|
+
}
|
|
246
|
+
function setValues(values) {
|
|
247
|
+
const encoded = {};
|
|
248
|
+
for (const [valueId, value] of Object.entries(values)) {
|
|
249
|
+
const valueSchema = tryGetValueSchema(valueId);
|
|
250
|
+
if (!valueSchema) {
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
const encodedValue = valueSchema.encode(value);
|
|
254
|
+
assertStorageCell(encodedValue, `values.${valueId}`);
|
|
255
|
+
if (encodedValue !== undefined) {
|
|
256
|
+
encoded[valueId] = encodedValue;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
store.setValues(encoded);
|
|
260
|
+
return typedStore;
|
|
261
|
+
}
|
|
262
|
+
function delValues() {
|
|
263
|
+
store.delValues();
|
|
264
|
+
return typedStore;
|
|
265
|
+
}
|
|
266
|
+
function getValue(valueId) {
|
|
267
|
+
const value = store.getValue(valueId);
|
|
268
|
+
if (value === undefined) {
|
|
269
|
+
return undefined;
|
|
270
|
+
}
|
|
271
|
+
const valueSchema = tryGetValueSchema(valueId);
|
|
272
|
+
// If schema is present, ignore unknown value ids (Option A).
|
|
273
|
+
if (!valueSchema) {
|
|
274
|
+
return undefined;
|
|
275
|
+
}
|
|
276
|
+
return valueSchema.decode(value);
|
|
277
|
+
}
|
|
278
|
+
function setValue(valueId, value) {
|
|
279
|
+
const valueSchema = tryGetValueSchema(valueId);
|
|
280
|
+
// If schema is present, ignore unknown value ids (Option A).
|
|
281
|
+
if (!valueSchema) {
|
|
282
|
+
return typedStore;
|
|
283
|
+
}
|
|
284
|
+
if (typeof value === "function") {
|
|
285
|
+
const mapValue = (encoded) => {
|
|
286
|
+
const decoded = encoded === undefined ? undefined : valueSchema.decode(encoded);
|
|
287
|
+
const nextDecoded = value(decoded);
|
|
288
|
+
if (nextDecoded === undefined) {
|
|
289
|
+
return undefined;
|
|
290
|
+
}
|
|
291
|
+
const nextEncoded = valueSchema.encode(nextDecoded);
|
|
292
|
+
assertStorageCell(nextEncoded, `values.${valueId}`);
|
|
293
|
+
return nextEncoded;
|
|
294
|
+
};
|
|
295
|
+
store.setValue(valueId, mapValue);
|
|
296
|
+
return typedStore;
|
|
297
|
+
}
|
|
298
|
+
const encoded = valueSchema.encode(value);
|
|
299
|
+
assertStorageCell(encoded, `values.${valueId}`);
|
|
300
|
+
if (encoded === undefined) {
|
|
301
|
+
store.delValue(valueId);
|
|
302
|
+
return typedStore;
|
|
303
|
+
}
|
|
304
|
+
store.setValue(valueId, encoded);
|
|
305
|
+
return typedStore;
|
|
306
|
+
}
|
|
307
|
+
function delValue(valueId) {
|
|
308
|
+
store.delValue(valueId);
|
|
309
|
+
return typedStore;
|
|
310
|
+
}
|
|
311
|
+
function hasValues() {
|
|
312
|
+
return store.hasValues();
|
|
313
|
+
}
|
|
314
|
+
function hasValue(valueId) {
|
|
315
|
+
return store.hasValue(valueId);
|
|
316
|
+
}
|
|
317
|
+
function getValueIds() {
|
|
318
|
+
const ids = store.getValueIds();
|
|
319
|
+
if (!mapped.values) {
|
|
320
|
+
return ids;
|
|
321
|
+
}
|
|
322
|
+
const known = new Set(Object.keys(mapped.values.shape));
|
|
323
|
+
return ids.filter((id) => known.has(id));
|
|
324
|
+
}
|
|
325
|
+
function addValuesListener(listener, mutator) {
|
|
326
|
+
return store.addValuesListener((_store) => listener(typedStore), mutator);
|
|
327
|
+
}
|
|
328
|
+
function addValueListener(valueId, listener, mutator) {
|
|
329
|
+
return store.addValueListener(valueId, (_store, changedValueId, newValue, oldValue, getValueChange) => {
|
|
330
|
+
const valueSchema = tryGetValueSchema(changedValueId);
|
|
331
|
+
const decodedNewValue = newValue === undefined
|
|
332
|
+
? undefined
|
|
333
|
+
: valueSchema
|
|
334
|
+
? valueSchema.decode(newValue)
|
|
335
|
+
: newValue;
|
|
336
|
+
const decodedOldValue = oldValue === undefined
|
|
337
|
+
? undefined
|
|
338
|
+
: valueSchema
|
|
339
|
+
? valueSchema.decode(oldValue)
|
|
340
|
+
: oldValue;
|
|
341
|
+
let getTypedValueChange = undefined;
|
|
342
|
+
if (getValueChange) {
|
|
343
|
+
getTypedValueChange = (valueId) => {
|
|
344
|
+
const [changed, oldV, newV] = getValueChange(valueId);
|
|
345
|
+
const schema = tryGetValueSchema(valueId);
|
|
346
|
+
const decodedNewV = newV === undefined
|
|
347
|
+
? undefined
|
|
348
|
+
: schema
|
|
349
|
+
? schema.decode(newV)
|
|
350
|
+
: newV;
|
|
351
|
+
const decodedOldV = oldV === undefined
|
|
352
|
+
? undefined
|
|
353
|
+
: schema
|
|
354
|
+
? schema.decode(oldV)
|
|
355
|
+
: oldV;
|
|
356
|
+
return [changed, decodedOldV, decodedNewV];
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
listener(typedStore, changedValueId, decodedNewValue, decodedOldValue, getTypedValueChange);
|
|
360
|
+
}, mutator);
|
|
361
|
+
}
|
|
362
|
+
function addValueIdsListener(listener, mutator) {
|
|
363
|
+
return store.addValueIdsListener((_store, getIdChanges) => listener(typedStore, getIdChanges), mutator);
|
|
364
|
+
}
|
|
365
|
+
function addHasValuesListener(listener, mutator) {
|
|
366
|
+
return store.addHasValuesListener((_store, hasValues) => listener(typedStore, hasValues), mutator);
|
|
367
|
+
}
|
|
368
|
+
function addHasValueListener(valueId, listener, mutator) {
|
|
369
|
+
return store.addHasValueListener(valueId, (_store, changedValueId, hasValue) => listener(typedStore, changedValueId, hasValue), mutator);
|
|
370
|
+
}
|
|
371
|
+
function addTablesListener(listener, mutator) {
|
|
372
|
+
return store.addTablesListener((_store) => listener(typedStore), mutator);
|
|
373
|
+
}
|
|
374
|
+
function addTableListener(tableId, listener, mutator) {
|
|
375
|
+
return store.addTableListener(tableId, (_store, changedTableId) => listener(typedStore, changedTableId), mutator);
|
|
376
|
+
}
|
|
377
|
+
function addRowListener(tableId, rowId, listener, mutator) {
|
|
378
|
+
return store.addRowListener(tableId, rowId, (_store, changedTableId, changedRowId) => listener(typedStore, changedTableId, changedRowId), mutator);
|
|
379
|
+
}
|
|
380
|
+
function addTableIdsListener(listener, mutator) {
|
|
381
|
+
return store.addTableIdsListener((_store, getIdChanges) => listener(typedStore, getIdChanges), mutator);
|
|
382
|
+
}
|
|
383
|
+
function addTableCellIdsListener(tableId, listener, mutator) {
|
|
384
|
+
return store.addTableCellIdsListener(tableId, (_store, changedTableId, getIdChanges) => listener(typedStore, changedTableId, getIdChanges), mutator);
|
|
385
|
+
}
|
|
386
|
+
function addRowIdsListener(tableId, listener, mutator) {
|
|
387
|
+
return store.addRowIdsListener(tableId, (_store, changedTableId, getIdChanges) => listener(typedStore, changedTableId, getIdChanges), mutator);
|
|
388
|
+
}
|
|
389
|
+
function addCellIdsListener(tableId, rowId, listener, mutator) {
|
|
390
|
+
return store.addCellIdsListener(tableId, rowId, (_store, changedTableId, changedRowId, getIdChanges) => listener(typedStore, changedTableId, changedRowId, getIdChanges), mutator);
|
|
391
|
+
}
|
|
392
|
+
function addSortedRowIdsListener(...args) {
|
|
393
|
+
// Signatures (TinyBase):
|
|
394
|
+
// - (tableId, cellId, descending, offset, limit, listener, mutator?)
|
|
395
|
+
// - (args, listener, mutator?)
|
|
396
|
+
if (typeof args[0] === "object") {
|
|
397
|
+
const [sortedArgs, listener, mutator] = args;
|
|
398
|
+
return store.addSortedRowIdsListener(sortedArgs, (_store, tableId, cellId, descending, offset, limit, sortedRowIds) => listener(typedStore, tableId, cellId, descending, offset, limit, sortedRowIds), mutator);
|
|
399
|
+
}
|
|
400
|
+
const [tableId, cellId, descending, offset, limit, listener, mutator] = args;
|
|
401
|
+
return store.addSortedRowIdsListener(tableId, cellId, descending, offset ?? 0, limit, (_store, tableId, cellId, descending, offset, limit, sortedRowIds) => listener(typedStore, tableId, cellId, descending, offset, limit, sortedRowIds), mutator);
|
|
402
|
+
}
|
|
403
|
+
function addHasTablesListener(listener, mutator) {
|
|
404
|
+
return store.addHasTablesListener((_store, hasTables) => listener(typedStore, hasTables), mutator);
|
|
405
|
+
}
|
|
406
|
+
function addHasTableListener(tableId, listener, mutator) {
|
|
407
|
+
return store.addHasTableListener(tableId, (_store, changedTableId, hasTable) => listener(typedStore, changedTableId, hasTable), mutator);
|
|
408
|
+
}
|
|
409
|
+
function addHasRowListener(tableId, rowId, listener, mutator) {
|
|
410
|
+
return store.addHasRowListener(tableId, rowId, (_store, changedTableId, changedRowId, hasRow) => listener(typedStore, changedTableId, changedRowId, hasRow), mutator);
|
|
411
|
+
}
|
|
412
|
+
function addHasCellListener(tableId, rowId, cellId, listener, mutator) {
|
|
413
|
+
return store.addHasCellListener(tableId, rowId, cellId, (_store, changedTableId, changedRowId, changedCellId, hasCell) => listener(typedStore, changedTableId, changedRowId, changedCellId, hasCell), mutator);
|
|
414
|
+
}
|
|
415
|
+
function addCellListener(tableId, rowId, cellId, listener, mutator) {
|
|
416
|
+
return store.addCellListener(tableId, rowId, cellId, (_store, tableId, rowId, cellId, newCell, oldCell, getCellChange) => {
|
|
417
|
+
const cellSchema = tryGetCellSchema(tableId, cellId);
|
|
418
|
+
const decodedNewCell = newCell === undefined
|
|
419
|
+
? undefined
|
|
420
|
+
: cellSchema
|
|
421
|
+
? cellSchema.decode(newCell)
|
|
422
|
+
: newCell;
|
|
423
|
+
const decodedOldCell = oldCell === undefined
|
|
424
|
+
? undefined
|
|
425
|
+
: cellSchema
|
|
426
|
+
? cellSchema.decode(oldCell)
|
|
427
|
+
: oldCell;
|
|
428
|
+
let getTypedCellChange = undefined;
|
|
429
|
+
if (getCellChange) {
|
|
430
|
+
getTypedCellChange = (tableId, rowId, cellId) => {
|
|
431
|
+
const [changed, oldCell, newCell] = getCellChange(tableId, rowId, cellId);
|
|
432
|
+
const schema = tryGetCellSchema(tableId, cellId);
|
|
433
|
+
const decodedNewCell = newCell === undefined
|
|
434
|
+
? undefined
|
|
435
|
+
: schema
|
|
436
|
+
? schema.decode(newCell)
|
|
437
|
+
: newCell;
|
|
438
|
+
const decodedOldCell = oldCell === undefined
|
|
439
|
+
? undefined
|
|
440
|
+
: schema
|
|
441
|
+
? schema.decode(oldCell)
|
|
442
|
+
: oldCell;
|
|
443
|
+
return [changed, decodedOldCell, decodedNewCell];
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
listener(typedStore, tableId, rowId, cellId, decodedNewCell, decodedOldCell, getTypedCellChange);
|
|
447
|
+
}, mutator);
|
|
448
|
+
}
|
|
449
|
+
const typedStore = {
|
|
450
|
+
getTables,
|
|
451
|
+
setTables,
|
|
452
|
+
delTables,
|
|
453
|
+
getTable,
|
|
454
|
+
setTable,
|
|
455
|
+
delTable,
|
|
456
|
+
getRow,
|
|
457
|
+
setRow,
|
|
458
|
+
delRow,
|
|
459
|
+
getCell,
|
|
460
|
+
setCell,
|
|
461
|
+
delCell,
|
|
462
|
+
hasTables,
|
|
463
|
+
hasTable,
|
|
464
|
+
hasTableCell,
|
|
465
|
+
hasRow,
|
|
466
|
+
hasCell,
|
|
467
|
+
getTableIds,
|
|
468
|
+
getRowIds,
|
|
469
|
+
getCellIds,
|
|
470
|
+
getTableCellIds,
|
|
471
|
+
getSortedRowIds,
|
|
472
|
+
transaction,
|
|
473
|
+
startTransaction,
|
|
474
|
+
finishTransaction,
|
|
475
|
+
callListener,
|
|
476
|
+
delListener,
|
|
477
|
+
getJson,
|
|
478
|
+
setJson,
|
|
479
|
+
getValues,
|
|
480
|
+
setValues,
|
|
481
|
+
delValues,
|
|
482
|
+
getValue,
|
|
483
|
+
setValue,
|
|
484
|
+
delValue,
|
|
485
|
+
hasValues,
|
|
486
|
+
hasValue,
|
|
487
|
+
getValueIds,
|
|
488
|
+
addValuesListener,
|
|
489
|
+
addValueListener,
|
|
490
|
+
addValueIdsListener,
|
|
491
|
+
addHasValuesListener,
|
|
492
|
+
addHasValueListener,
|
|
493
|
+
addTablesListener,
|
|
494
|
+
addTableListener,
|
|
495
|
+
addTableIdsListener,
|
|
496
|
+
addTableCellIdsListener,
|
|
497
|
+
addRowIdsListener,
|
|
498
|
+
addCellIdsListener,
|
|
499
|
+
addSortedRowIdsListener,
|
|
500
|
+
addHasTablesListener,
|
|
501
|
+
addHasTableListener,
|
|
502
|
+
addRowListener,
|
|
503
|
+
addHasRowListener,
|
|
504
|
+
addHasCellListener,
|
|
505
|
+
addCellListener,
|
|
506
|
+
};
|
|
507
|
+
return typedStore;
|
|
508
|
+
}
|
|
509
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAYN,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,CACL,KAAK,KAAK,IAAI;QACd,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,SAAS,CAC3B,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CACxB,KAAc,EACd,OAAe;IAEf,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO;IACT,CAAC;IACD,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO;IACT,CAA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AO,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;gBACnD,CAAC,CAAC;YACJ,CAAC;YACD,QAAQ,CACN,UAAU,EACV,OAAO,EACP,KAAK,EACL,MAAM,EACN,cAAc,EACd,cAAc,EACd,kBAAkB,CACnB,CAAC;QACJ,CAAC,EACD,OAAO,CACR,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG;QACjB,SAAS;QACT,SAAS;QACT,SAAS;QACT,QAAQ;QACR,QAAQ;QACR,QAAQ;QACR,MAAM;QACN,MAAM;QACN,MAAM;QACN,OAAO;QACP,OAAO;QACP,OAAO;QACP,SAAS;QACT,QAAQ;QACR,YAAY;QACZ,MAAM;QACN,OAAO;QACP,WAAW;QACX,SAAS;QACT,UAAU;QACV,eAAe;QACf,eAAe;QACf,WAAW;QACX,gBAAgB;QAChB,iBAAiB;QACjB,YAAY;QACZ,WAAW;QACX,OAAO;QACP,OAAO;QACP,SAAS;QACT,SAAS;QACT,SAAS;QACT,QAAQ;QACR,QAAQ;QACR,QAAQ;QACR,SAAS;QACT,QAAQ;QACR,WAAW;QACX,iBAAiB;QACjB,gBAAgB;QAChB,mBAAmB;QACnB,oBAAoB;QACpB,mBAAmB;QACnB,iBAAiB;QACjB,gBAAgB;QAChB,mBAAmB;QACnB,uBAAuB;QACvB,iBAAiB;QACjB,kBAAkB;QAClB,uBAAuB;QACvB,oBAAoB;QACpB,mBAAmB;QACnB,cAAc;QACd,iBAAiB;QACjB,kBAAkB;QAClB,eAAe;KACiB,CAAC;IAEnC,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
package/dist/type.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { DoRollback, GetIdChanges, Id, IdOrNull, Json, SortedRowIdsArgs } from "tinybase";
|
|
2
|
+
import z from "zod";
|
|
3
|
+
type Simplify<T> = {
|
|
4
|
+
[KeyType in keyof T]: T[KeyType];
|
|
5
|
+
} & {};
|
|
6
|
+
export type StoreTablesSchema = Record<string, z.ZodObject>;
|
|
7
|
+
export type StoreValuesSchema = z.ZodObject;
|
|
8
|
+
export type StoreSchema = {
|
|
9
|
+
tables: StoreTablesSchema;
|
|
10
|
+
values: StoreValuesSchema;
|
|
11
|
+
};
|
|
12
|
+
type TableIdOf<Schema extends StoreSchema> = Extract<keyof Schema["tables"], string>;
|
|
13
|
+
type CellIdOf<Schema extends StoreSchema, TableId extends TableIdOf<Schema>> = Extract<keyof RowOf<Schema, TableId>, string>;
|
|
14
|
+
type TableIdOfOrNull<Schema extends StoreSchema> = TableIdOf<Schema> | null;
|
|
15
|
+
type KeysOfUnion<T> = T extends any ? keyof T : never;
|
|
16
|
+
type CellIdOrUnionOf<Schema extends StoreSchema, TableIdOrNull extends TableIdOfOrNull<Schema>> = Extract<KeysOfUnion<RowOf<Schema, TableIdOrNull extends TableIdOf<Schema> ? TableIdOrNull : TableIdOf<Schema>>>, string>;
|
|
17
|
+
type CellIdOrUnionOfOrNull<Schema extends StoreSchema, TableIdOrNull extends TableIdOfOrNull<Schema>> = CellIdOrUnionOf<Schema, TableIdOrNull> | null;
|
|
18
|
+
type ResolveTableId<Schema extends StoreSchema, TableIdOrNull extends TableIdOfOrNull<Schema>> = TableIdOrNull extends TableIdOf<Schema> ? TableIdOrNull : TableIdOf<Schema>;
|
|
19
|
+
type ResolveCellId<Schema extends StoreSchema, TableIdOrNull extends TableIdOfOrNull<Schema>, CellIdOrNull extends CellIdOrUnionOfOrNull<Schema, TableIdOrNull>> = CellIdOrNull extends null ? CellIdOrUnionOf<Schema, TableIdOrNull> : CellIdOrNull;
|
|
20
|
+
type CellOf<Schema extends StoreSchema, TableId extends TableIdOf<Schema>, CellId extends CellIdOf<Schema, TableId>> = RowOf<Schema, TableId>[CellId];
|
|
21
|
+
type RowOf<Schema extends StoreSchema, TableId extends TableIdOf<Schema>> = z.infer<Schema["tables"][TableId]>;
|
|
22
|
+
type TableOf<Schema extends StoreSchema, TableId extends TableIdOf<Schema>> = Simplify<Record<string, RowOf<Schema, TableId>>>;
|
|
23
|
+
type TablesOf<Schema extends StoreSchema> = Simplify<{
|
|
24
|
+
[TableId in TableIdOf<Schema>]: TableOf<Schema, TableId>;
|
|
25
|
+
}>;
|
|
26
|
+
type CellUnionInTable<Schema extends StoreSchema, TableId extends TableIdOf<Schema>> = RowOf<Schema, TableId>[CellIdOf<Schema, TableId>];
|
|
27
|
+
type AnyCellInSchema<Schema extends StoreSchema> = {
|
|
28
|
+
[TableId in TableIdOf<Schema>]: CellUnionInTable<Schema, TableId>;
|
|
29
|
+
}[TableIdOf<Schema>];
|
|
30
|
+
type CellForCellIdAcrossTables<Schema extends StoreSchema, CellId extends string> = {
|
|
31
|
+
[TableId in TableIdOf<Schema>]: CellId extends CellIdOf<Schema, TableId> ? RowOf<Schema, TableId>[CellId] : never;
|
|
32
|
+
}[TableIdOf<Schema>];
|
|
33
|
+
type CellOrUnionOf<Schema extends StoreSchema, TableIdOrNull extends TableIdOfOrNull<Schema>, CellIdOrNull extends CellIdOrUnionOfOrNull<Schema, TableIdOrNull>> = TableIdOrNull extends TableIdOf<Schema> ? CellIdOrNull extends CellIdOf<Schema, TableIdOrNull> ? CellOf<Schema, TableIdOrNull, CellIdOrNull> : CellIdOrNull extends null ? CellUnionInTable<Schema, TableIdOrNull> : never : TableIdOrNull extends null ? CellIdOrNull extends null ? AnyCellInSchema<Schema> : CellIdOrNull extends string ? CellForCellIdAcrossTables<Schema, CellIdOrNull> : never : never;
|
|
34
|
+
type CellListener<Schema extends StoreSchema, TableIdOrNull extends TableIdOfOrNull<Schema>, CellIdOrNull extends CellIdOrUnionOfOrNull<Schema, TableIdOrNull>> = (store: TypedStore<Schema>, tableId: ResolveTableId<Schema, TableIdOrNull>, rowId: Id, cellId: ResolveCellId<Schema, TableIdOrNull, CellIdOrNull>, newCell: CellOrUnionOf<Schema, TableIdOrNull, CellIdOrNull> | undefined, oldCell: CellOrUnionOf<Schema, TableIdOrNull, CellIdOrNull> | undefined, getCellChange: ((tableId: ResolveTableId<Schema, TableIdOrNull>, rowId: Id, cellId: ResolveCellId<Schema, TableIdOrNull, CellIdOrNull>) => [
|
|
35
|
+
changed: boolean,
|
|
36
|
+
oldCell: CellOrUnionOf<Schema, TableIdOrNull, CellIdOrNull> | undefined,
|
|
37
|
+
newCell: CellOrUnionOf<Schema, TableIdOrNull, CellIdOrNull> | undefined
|
|
38
|
+
]) | undefined) => void;
|
|
39
|
+
type ValueIdOf<Schema extends StoreSchema> = Schema["values"] extends StoreValuesSchema ? Extract<keyof z.infer<Schema["values"]>, string> : string;
|
|
40
|
+
type ValueIdOfOrNull<Schema extends StoreSchema> = ValueIdOf<Schema> | null;
|
|
41
|
+
type ValuesOf<Schema extends StoreSchema> = Schema["values"] extends StoreValuesSchema ? z.infer<Schema["values"]> : Record<string, unknown>;
|
|
42
|
+
type ValueOf<Schema extends StoreSchema, ValueId extends string> = Schema["values"] extends StoreValuesSchema ? ValueId extends ValueIdOf<Schema> ? z.infer<Schema["values"]>[ValueId] : unknown : unknown;
|
|
43
|
+
type AnyValueInSchema<Schema extends StoreSchema> = Schema["values"] extends StoreValuesSchema ? ValuesOf<Schema>[ValueIdOf<Schema>] : unknown;
|
|
44
|
+
type ResolveValueId<Schema extends StoreSchema, ValueIdOrNull extends ValueIdOfOrNull<Schema>> = ValueIdOrNull extends ValueIdOf<Schema> ? ValueIdOrNull : ValueIdOf<Schema>;
|
|
45
|
+
type ValueOrUnionOf<Schema extends StoreSchema, ValueIdOrNull extends ValueIdOfOrNull<Schema>> = ValueIdOrNull extends ValueIdOf<Schema> ? ValueOf<Schema, ValueIdOrNull> : AnyValueInSchema<Schema>;
|
|
46
|
+
export interface TypedStore<Schema extends StoreSchema> {
|
|
47
|
+
getTables(): Partial<TablesOf<Schema>>;
|
|
48
|
+
setTables(tables: Partial<TablesOf<Schema>>): TypedStore<Schema>;
|
|
49
|
+
delTables(): TypedStore<Schema>;
|
|
50
|
+
getTable<TableId extends TableIdOf<Schema>>(tableId: TableId): TableOf<Schema, TableId>;
|
|
51
|
+
setTable<TableId extends TableIdOf<Schema>>(tableId: TableId, table: TableOf<Schema, TableId>): TypedStore<Schema>;
|
|
52
|
+
delTable<TableId extends TableIdOf<Schema>>(tableId: TableId): TypedStore<Schema>;
|
|
53
|
+
getRow<TableId extends TableIdOf<Schema>>(tableId: TableId, rowId: Id): RowOf<Schema, TableId> | undefined;
|
|
54
|
+
setRow<TableId extends TableIdOf<Schema>>(tableId: TableId, rowId: Id, row: RowOf<Schema, TableId>): TypedStore<Schema>;
|
|
55
|
+
delRow<TableId extends TableIdOf<Schema>>(tableId: TableId, rowId: Id): TypedStore<Schema>;
|
|
56
|
+
getCell<TableId extends TableIdOf<Schema>, CellId extends CellIdOf<Schema, TableId>>(tableId: TableId, rowId: Id, cellId: CellId): CellOf<Schema, TableId, CellId> | undefined;
|
|
57
|
+
setCell<TableId extends TableIdOf<Schema>, CellId extends CellIdOf<Schema, TableId>, Cell extends CellOf<Schema, TableId, CellId>, MapCell extends (cell: Cell | undefined) => Cell>(tableId: TableId, rowId: Id, cellId: CellId, cell: Cell | MapCell): TypedStore<Schema>;
|
|
58
|
+
delCell<TableId extends TableIdOf<Schema>, CellId extends CellIdOf<Schema, TableId>>(tableId: TableId, rowId: Id, cellId: CellId): TypedStore<Schema>;
|
|
59
|
+
addCellListener<TableIdOrNull extends TableIdOfOrNull<Schema>, CellIdOrNull extends CellIdOrUnionOfOrNull<Schema, TableIdOrNull>, Listener extends CellListener<Schema, TableIdOrNull, CellIdOrNull>>(tableId: TableIdOrNull, rowId: IdOrNull, cellId: CellIdOrNull, listener: Listener, mutator?: boolean): Id;
|
|
60
|
+
hasTables(): boolean;
|
|
61
|
+
hasTable<TableId extends TableIdOf<Schema>>(tableId: TableId): boolean;
|
|
62
|
+
hasTableCell<TableId extends TableIdOf<Schema>>(tableId: TableId, cellId: CellIdOf<Schema, TableId>): boolean;
|
|
63
|
+
hasRow<TableId extends TableIdOf<Schema>>(tableId: TableId, rowId: Id): boolean;
|
|
64
|
+
hasCell<TableId extends TableIdOf<Schema>>(tableId: TableId, rowId: Id, cellId: CellIdOf<Schema, TableId>): boolean;
|
|
65
|
+
getTableIds(): TableIdOf<Schema>[];
|
|
66
|
+
getRowIds<TableId extends TableIdOf<Schema>>(tableId: TableId): Id[];
|
|
67
|
+
getCellIds<TableId extends TableIdOf<Schema>>(tableId: TableId, rowId: Id): CellIdOf<Schema, TableId>[];
|
|
68
|
+
getTableCellIds<TableId extends TableIdOf<Schema>>(tableId: TableId): CellIdOf<Schema, TableId>[];
|
|
69
|
+
getSortedRowIds<TableId extends TableIdOf<Schema>>(tableId: TableId, cellId?: CellIdOf<Schema, TableId>, descending?: boolean, offset?: number, limit?: number): Id[];
|
|
70
|
+
getSortedRowIds(args: SortedRowIdsArgs): Id[];
|
|
71
|
+
transaction<Return>(actions: () => Return, doRollback?: DoRollback): Return;
|
|
72
|
+
startTransaction(): TypedStore<Schema>;
|
|
73
|
+
finishTransaction(doRollback?: DoRollback): TypedStore<Schema>;
|
|
74
|
+
callListener(listenerId: Id): TypedStore<Schema>;
|
|
75
|
+
delListener(listenerId: Id): TypedStore<Schema>;
|
|
76
|
+
getJson(): Json;
|
|
77
|
+
setJson(tablesAndValuesJson: Json): TypedStore<Schema>;
|
|
78
|
+
getValues(): Partial<ValuesOf<Schema>>;
|
|
79
|
+
setValues(values: Partial<ValuesOf<Schema>>): TypedStore<Schema>;
|
|
80
|
+
delValues(): TypedStore<Schema>;
|
|
81
|
+
getValue<ValueId extends ValueIdOf<Schema>>(valueId: ValueId): ValueOf<Schema, ValueId> | undefined;
|
|
82
|
+
setValue<ValueId extends ValueIdOf<Schema>, Value extends ValueOf<Schema, ValueId>, MapValue extends (value: Value | undefined) => Value>(valueId: ValueId, value: Value | MapValue): TypedStore<Schema>;
|
|
83
|
+
delValue<ValueId extends ValueIdOf<Schema>>(valueId: ValueId): TypedStore<Schema>;
|
|
84
|
+
hasValues(): boolean;
|
|
85
|
+
hasValue<ValueId extends ValueIdOf<Schema>>(valueId: ValueId): boolean;
|
|
86
|
+
getValueIds(): ValueIdOf<Schema>[];
|
|
87
|
+
addValuesListener(listener: (store: TypedStore<Schema>) => void, mutator?: boolean): Id;
|
|
88
|
+
addValueListener<ValueIdOrNull extends ValueIdOfOrNull<Schema>>(valueId: ValueIdOrNull, listener: (store: TypedStore<Schema>, valueId: ResolveValueId<Schema, ValueIdOrNull>, newValue: ValueOrUnionOf<Schema, ValueIdOrNull>, oldValue: ValueOrUnionOf<Schema, ValueIdOrNull>, getValueChange: unknown) => void, mutator?: boolean): Id;
|
|
89
|
+
addValueIdsListener(listener: (store: TypedStore<Schema>, getIdChanges: GetIdChanges | undefined) => void, mutator?: boolean): Id;
|
|
90
|
+
addHasValuesListener(listener: (store: TypedStore<Schema>, hasValues: boolean) => void, mutator?: boolean): Id;
|
|
91
|
+
addHasValueListener<ValueIdOrNull extends ValueIdOfOrNull<Schema>>(valueId: ValueIdOrNull, listener: (store: TypedStore<Schema>, valueId: ResolveValueId<Schema, ValueIdOrNull>, hasValue: boolean) => void, mutator?: boolean): Id;
|
|
92
|
+
addTableIdsListener(listener: (store: TypedStore<Schema>, getIdChanges: GetIdChanges | undefined) => void, mutator?: boolean): Id;
|
|
93
|
+
addTableCellIdsListener<TableIdOrNull extends TableIdOfOrNull<Schema>>(tableId: TableIdOrNull, listener: (store: TypedStore<Schema>, tableId: TableIdOf<Schema>, getIdChanges: GetIdChanges | undefined) => void, mutator?: boolean): Id;
|
|
94
|
+
addRowIdsListener<TableIdOrNull extends TableIdOfOrNull<Schema>>(tableId: TableIdOrNull, listener: (store: TypedStore<Schema>, tableId: ResolveTableId<Schema, TableIdOrNull>, getIdChanges: GetIdChanges | undefined) => void, mutator?: boolean): Id;
|
|
95
|
+
addCellIdsListener<TableIdOrNull extends TableIdOfOrNull<Schema>>(tableId: TableIdOrNull, rowId: IdOrNull, listener: (store: TypedStore<Schema>, tableId: TableIdOf<Schema>, rowId: Id, getIdChanges: GetIdChanges | undefined) => void, mutator?: boolean): Id;
|
|
96
|
+
addSortedRowIdsListener<TableId extends TableIdOf<Schema>>(tableId: TableId, cellId: CellIdOf<Schema, TableId> | undefined, descending: boolean, offset: number, limit: number | undefined, listener: (store: TypedStore<Schema>, tableId: TableId, cellId: CellIdOf<Schema, TableId> | undefined, descending: boolean, offset: number, limit: number | undefined, sortedRowIds: Id[]) => void, mutator?: boolean): Id;
|
|
97
|
+
addSortedRowIdsListener<TableId extends TableIdOf<Schema>>(args: SortedRowIdsArgs, listener: (store: TypedStore<Schema>, tableId: TableId, cellId: CellIdOf<Schema, TableId> | undefined, descending: boolean, offset: number, limit: number | undefined, sortedRowIds: Id[]) => void, mutator?: boolean): Id;
|
|
98
|
+
addHasTablesListener(listener: (store: TypedStore<Schema>, hasTables: boolean) => void, mutator?: boolean): Id;
|
|
99
|
+
addHasTableListener<TableIdOrNull extends TableIdOfOrNull<Schema>>(tableId: TableIdOrNull, listener: (store: TypedStore<Schema>, tableId: ResolveTableId<Schema, TableIdOrNull>, hasTable: boolean) => void, mutator?: boolean): Id;
|
|
100
|
+
addHasRowListener<TableIdOrNull extends TableIdOfOrNull<Schema>>(tableId: TableIdOrNull, rowId: IdOrNull, listener: (store: TypedStore<Schema>, tableId: ResolveTableId<Schema, TableIdOrNull>, rowId: Id, hasRow: boolean) => void, mutator?: boolean): Id;
|
|
101
|
+
addHasCellListener<TableIdOrNull extends TableIdOfOrNull<Schema>, CellIdOrNull extends CellIdOrUnionOfOrNull<Schema, TableIdOrNull>>(tableId: TableIdOrNull, rowId: IdOrNull, cellId: CellIdOrNull, listener: (store: TypedStore<Schema>, tableId: ResolveTableId<Schema, TableIdOrNull>, rowId: Id, cellId: ResolveCellId<Schema, TableIdOrNull, CellIdOrNull>, hasCell: boolean) => void, mutator?: boolean): Id;
|
|
102
|
+
addTablesListener(listener: (store: TypedStore<Schema>) => void, mutator?: boolean): Id;
|
|
103
|
+
addTableListener<TableIdOrNull extends TableIdOfOrNull<Schema>>(tableId: TableIdOrNull, listener: (store: TypedStore<Schema>, tableId: ResolveTableId<Schema, TableIdOrNull>) => void, mutator?: boolean): Id;
|
|
104
|
+
addRowListener<TableIdOrNull extends TableIdOfOrNull<Schema>>(tableId: TableIdOrNull, rowId: IdOrNull, listener: (store: TypedStore<Schema>, tableId: ResolveTableId<Schema, TableIdOrNull>, rowId: Id) => void, mutator?: boolean): Id;
|
|
105
|
+
}
|
|
106
|
+
export {};
|
|
107
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,EAAE,EACF,QAAQ,EACR,IAAI,EACJ,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAClB,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,KAAK,QAAQ,CAAC,CAAC,IAAI;KAAG,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;CAAE,GAAG,EAAE,CAAC;AAE7D,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC;AAC5D,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,SAAS,CAAC;AAE5C,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,MAAM,EAAE,iBAAiB,CAAC;CAC3B,CAAC;AAEF,KAAK,SAAS,CAAC,MAAM,SAAS,WAAW,IAAI,OAAO,CAClD,MAAM,MAAM,CAAC,QAAQ,CAAC,EACtB,MAAM,CACP,CAAC;AAEF,KAAK,QAAQ,CACX,MAAM,SAAS,WAAW,EAC1B,OAAO,SAAS,SAAS,CAAC,MAAM,CAAC,IAC/B,OAAO,CAAC,MAAM,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC;AAElD,KAAK,eAAe,CAAC,M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gBAAgB,CAAC,aAAa,SAAS,eAAe,CAAC,MAAM,CAAC,EAC5D,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,CACR,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,EACzB,OAAO,EAAE,cAAc,CAAC,MAAM,EAAE,aAAa,CAAC,KAC3C,IAAI,EACT,OAAO,CAAC,EAAE,OAAO,GAChB,EAAE,CAAC;IAEN,cAAc,CAAC,aAAa,SAAS,eAAe,CAAC,MAAM,CAAC,EAC1D,OAAO,EAAE,aAAa,EACtB,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,CACR,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,EACzB,OAAO,EAAE,cAAc,CAAC,MAAM,EAAE,aAAa,CAAC,EAC9C,KAAK,EAAE,EAAE,KACN,IAAI,EACT,OAAO,CAAC,EAAE,OAAO,GAChB,EAAE,CAAC;CACP"}
|
package/dist/type.js
ADDED
package/dist/type.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../src/type.ts"],"names":[],"mappings":"AAQA,OAAO,CAAC,MAAM,KAAK,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tinybase-zod",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A typed TinyBase Store wrapper with a Zod-backed encode/decode API.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "David Peek <team@opensurf.ai>",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/opensurfai/tinybase-zod.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/opensurfai/tinybase-zod/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/opensurfai/tinybase-zod#readme",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"tinybase",
|
|
17
|
+
"zod",
|
|
18
|
+
"typescript",
|
|
19
|
+
"schema",
|
|
20
|
+
"typed-store"
|
|
21
|
+
],
|
|
22
|
+
"type": "module",
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"main": "./dist/index.js",
|
|
34
|
+
"module": "./dist/index.js",
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"private": false,
|
|
37
|
+
"scripts": {
|
|
38
|
+
"test": "bun test",
|
|
39
|
+
"check": "tsc --noEmit",
|
|
40
|
+
"build": "tsc -p tsconfig.build.json",
|
|
41
|
+
"prepublishOnly": "bun run test && bun run check && bun run build"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/bun": "latest",
|
|
45
|
+
"tinybase": "^7.1.0",
|
|
46
|
+
"zod": "^4.1.13",
|
|
47
|
+
"typescript": "^5.0.0"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"tinybase": "^7.1.0",
|
|
51
|
+
"zod": "^4.1.13"
|
|
52
|
+
}
|
|
53
|
+
}
|