tinybase 4.0.0-beta.4 → 4.0.0-beta.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. package/lib/cjs/persisters/persister-automerge.cjs +1 -0
  2. package/lib/cjs/persisters/persister-automerge.cjs.gz +0 -0
  3. package/lib/cjs/persisters/persister-browser.cjs +1 -0
  4. package/lib/cjs/persisters/persister-browser.cjs.gz +0 -0
  5. package/lib/cjs/persisters/persister-cr-sqlite-wasm.cjs +1 -0
  6. package/lib/cjs/persisters/persister-cr-sqlite-wasm.cjs.gz +0 -0
  7. package/lib/cjs/persisters/persister-file.cjs +1 -0
  8. package/lib/cjs/persisters/persister-file.cjs.gz +0 -0
  9. package/lib/cjs/persisters/persister-remote.cjs +1 -0
  10. package/lib/cjs/persisters/persister-remote.cjs.gz +0 -0
  11. package/lib/cjs/persisters/persister-sqlite-wasm.cjs +1 -0
  12. package/lib/cjs/persisters/persister-sqlite-wasm.cjs.gz +0 -0
  13. package/lib/cjs/persisters/persister-sqlite3.cjs +1 -0
  14. package/lib/cjs/persisters/persister-sqlite3.cjs.gz +0 -0
  15. package/lib/cjs/persisters/persister-yjs.cjs +1 -0
  16. package/lib/cjs/persisters/persister-yjs.cjs.gz +0 -0
  17. package/lib/cjs/persisters.cjs +1 -1
  18. package/lib/cjs/persisters.cjs.gz +0 -0
  19. package/lib/cjs/store.cjs +1 -1
  20. package/lib/cjs/store.cjs.gz +0 -0
  21. package/lib/cjs/tinybase.cjs +1 -1
  22. package/lib/cjs/tinybase.cjs.gz +0 -0
  23. package/lib/cjs/tools.cjs +1 -1
  24. package/lib/cjs/tools.cjs.gz +0 -0
  25. package/lib/cjs/ui-react.cjs +1 -1
  26. package/lib/cjs/ui-react.cjs.gz +0 -0
  27. package/lib/cjs-es6/persisters/persister-automerge.cjs +1 -0
  28. package/lib/cjs-es6/persisters/persister-automerge.cjs.gz +0 -0
  29. package/lib/cjs-es6/persisters/persister-browser.cjs +1 -0
  30. package/lib/cjs-es6/persisters/persister-browser.cjs.gz +0 -0
  31. package/lib/cjs-es6/persisters/persister-cr-sqlite-wasm.cjs +1 -0
  32. package/lib/cjs-es6/persisters/persister-cr-sqlite-wasm.cjs.gz +0 -0
  33. package/lib/cjs-es6/persisters/persister-file.cjs +1 -0
  34. package/lib/cjs-es6/persisters/persister-file.cjs.gz +0 -0
  35. package/lib/cjs-es6/persisters/persister-remote.cjs +1 -0
  36. package/lib/cjs-es6/persisters/persister-remote.cjs.gz +0 -0
  37. package/lib/cjs-es6/persisters/persister-sqlite-wasm.cjs +1 -0
  38. package/lib/cjs-es6/persisters/persister-sqlite-wasm.cjs.gz +0 -0
  39. package/lib/cjs-es6/persisters/persister-sqlite3.cjs +1 -0
  40. package/lib/cjs-es6/persisters/persister-sqlite3.cjs.gz +0 -0
  41. package/lib/cjs-es6/persisters/persister-yjs.cjs +1 -0
  42. package/lib/cjs-es6/persisters/persister-yjs.cjs.gz +0 -0
  43. package/lib/cjs-es6/persisters.cjs +1 -1
  44. package/lib/cjs-es6/persisters.cjs.gz +0 -0
  45. package/lib/cjs-es6/store.cjs +1 -1
  46. package/lib/cjs-es6/store.cjs.gz +0 -0
  47. package/lib/cjs-es6/tinybase.cjs +1 -1
  48. package/lib/cjs-es6/tinybase.cjs.gz +0 -0
  49. package/lib/cjs-es6/tools.cjs +1 -1
  50. package/lib/cjs-es6/tools.cjs.gz +0 -0
  51. package/lib/cjs-es6/ui-react.cjs +1 -1
  52. package/lib/cjs-es6/ui-react.cjs.gz +0 -0
  53. package/lib/debug/{persister-automerge.js → persisters/persister-automerge.js} +58 -31
  54. package/lib/debug/{persister-browser.js → persisters/persister-browser.js} +49 -20
  55. package/lib/debug/persisters/persister-cr-sqlite-wasm.js +665 -0
  56. package/lib/debug/{persister-file.js → persisters/persister-file.js} +51 -25
  57. package/lib/debug/{persister-remote.js → persisters/persister-remote.js} +48 -19
  58. package/lib/debug/persisters/persister-sqlite-wasm.js +673 -0
  59. package/lib/debug/persisters/persister-sqlite3.js +676 -0
  60. package/lib/debug/{persister-yjs.js → persisters/persister-yjs.js} +49 -20
  61. package/lib/debug/persisters.js +47 -18
  62. package/lib/debug/store.js +79 -29
  63. package/lib/debug/tinybase.js +123 -46
  64. package/lib/debug/tools.js +121 -27
  65. package/lib/debug/ui-react.js +24 -0
  66. package/lib/es6/persisters/persister-automerge.js +1 -0
  67. package/lib/es6/persisters/persister-automerge.js.gz +0 -0
  68. package/lib/es6/persisters/persister-browser.js +1 -0
  69. package/lib/es6/persisters/persister-browser.js.gz +0 -0
  70. package/lib/es6/persisters/persister-cr-sqlite-wasm.js +1 -0
  71. package/lib/es6/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
  72. package/lib/es6/persisters/persister-file.js +1 -0
  73. package/lib/es6/persisters/persister-file.js.gz +0 -0
  74. package/lib/es6/persisters/persister-remote.js +1 -0
  75. package/lib/es6/persisters/persister-remote.js.gz +0 -0
  76. package/lib/es6/persisters/persister-sqlite-wasm.js +1 -0
  77. package/lib/es6/persisters/persister-sqlite-wasm.js.gz +0 -0
  78. package/lib/es6/persisters/persister-sqlite3.js +1 -0
  79. package/lib/es6/persisters/persister-sqlite3.js.gz +0 -0
  80. package/lib/es6/persisters/persister-yjs.js +1 -0
  81. package/lib/es6/persisters/persister-yjs.js.gz +0 -0
  82. package/lib/es6/persisters.js +1 -1
  83. package/lib/es6/persisters.js.gz +0 -0
  84. package/lib/es6/store.js +1 -1
  85. package/lib/es6/store.js.gz +0 -0
  86. package/lib/es6/tinybase.js +1 -1
  87. package/lib/es6/tinybase.js.gz +0 -0
  88. package/lib/es6/tools.js +1 -1
  89. package/lib/es6/tools.js.gz +0 -0
  90. package/lib/es6/ui-react.js +1 -1
  91. package/lib/es6/ui-react.js.gz +0 -0
  92. package/lib/persisters/persister-automerge.js +1 -0
  93. package/lib/persisters/persister-automerge.js.gz +0 -0
  94. package/lib/persisters/persister-browser.js +1 -0
  95. package/lib/persisters/persister-browser.js.gz +0 -0
  96. package/lib/persisters/persister-cr-sqlite-wasm.js +1 -0
  97. package/lib/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
  98. package/lib/persisters/persister-file.js +1 -0
  99. package/lib/persisters/persister-file.js.gz +0 -0
  100. package/lib/persisters/persister-remote.js +1 -0
  101. package/lib/persisters/persister-remote.js.gz +0 -0
  102. package/lib/persisters/persister-sqlite-wasm.js +1 -0
  103. package/lib/persisters/persister-sqlite-wasm.js.gz +0 -0
  104. package/lib/persisters/persister-sqlite3.js +1 -0
  105. package/lib/persisters/persister-sqlite3.js.gz +0 -0
  106. package/lib/persisters/persister-yjs.js +1 -0
  107. package/lib/persisters/persister-yjs.js.gz +0 -0
  108. package/lib/persisters.js +1 -1
  109. package/lib/persisters.js.gz +0 -0
  110. package/lib/store.js +1 -1
  111. package/lib/store.js.gz +0 -0
  112. package/lib/tinybase.js +1 -1
  113. package/lib/tinybase.js.gz +0 -0
  114. package/lib/tools.js +1 -1
  115. package/lib/tools.js.gz +0 -0
  116. package/lib/types/checkpoints.d.ts +0 -27
  117. package/lib/types/common.d.ts +0 -9
  118. package/lib/types/indexes.d.ts +0 -26
  119. package/lib/types/metrics.d.ts +0 -23
  120. package/lib/types/{persister-automerge.d.ts → persisters/persister-automerge.d.ts} +4 -6
  121. package/lib/types/{persister-browser.d.ts → persisters/persister-browser.d.ts} +2 -5
  122. package/lib/types/persisters/persister-cr-sqlite-wasm.d.ts +95 -0
  123. package/lib/types/{persister-file.d.ts → persisters/persister-file.d.ts} +3 -5
  124. package/lib/types/{persister-remote.d.ts → persisters/persister-remote.d.ts} +2 -4
  125. package/lib/types/persisters/persister-sqlite-wasm.d.ts +102 -0
  126. package/lib/types/persisters/persister-sqlite3.d.ts +109 -0
  127. package/lib/types/{persister-yjs.d.ts → persisters/persister-yjs.d.ts} +4 -6
  128. package/lib/types/persisters.d.ts +517 -27
  129. package/lib/types/queries.d.ts +52 -127
  130. package/lib/types/relationships.d.ts +0 -26
  131. package/lib/types/store.d.ts +347 -196
  132. package/lib/types/tinybase.d.ts +0 -1
  133. package/lib/types/tools.d.ts +15 -28
  134. package/lib/types/ui-react.d.ts +196 -181
  135. package/lib/types/with-schemas/checkpoints.d.ts +5 -32
  136. package/lib/types/with-schemas/common.d.ts +0 -9
  137. package/lib/types/with-schemas/indexes.d.ts +9 -35
  138. package/lib/types/with-schemas/metrics.d.ts +9 -32
  139. package/lib/types/with-schemas/{persister-automerge.d.ts → persisters/persister-automerge.d.ts} +4 -6
  140. package/lib/types/with-schemas/{persister-browser.d.ts → persisters/persister-browser.d.ts} +2 -5
  141. package/lib/types/with-schemas/persisters/persister-cr-sqlite-wasm.d.ts +105 -0
  142. package/lib/types/with-schemas/{persister-file.d.ts → persisters/persister-file.d.ts} +3 -5
  143. package/lib/types/with-schemas/{persister-remote.d.ts → persisters/persister-remote.d.ts} +2 -4
  144. package/lib/types/with-schemas/persisters/persister-sqlite-wasm.d.ts +113 -0
  145. package/lib/types/with-schemas/persisters/persister-sqlite3.d.ts +119 -0
  146. package/lib/types/with-schemas/{persister-yjs.d.ts → persisters/persister-yjs.d.ts} +4 -6
  147. package/lib/types/with-schemas/persisters.d.ts +534 -29
  148. package/lib/types/with-schemas/queries.d.ts +61 -224
  149. package/lib/types/with-schemas/relationships.d.ts +9 -35
  150. package/lib/types/with-schemas/store.d.ts +488 -239
  151. package/lib/types/with-schemas/tinybase.d.ts +0 -1
  152. package/lib/types/with-schemas/tools.d.ts +19 -32
  153. package/lib/types/with-schemas/ui-react.d.ts +221 -186
  154. package/lib/ui-react.js +1 -1
  155. package/lib/ui-react.js.gz +0 -0
  156. package/lib/umd/persisters/persister-automerge.js +1 -0
  157. package/lib/umd/persisters/persister-automerge.js.gz +0 -0
  158. package/lib/umd/persisters/persister-browser.js +1 -0
  159. package/lib/umd/persisters/persister-browser.js.gz +0 -0
  160. package/lib/umd/persisters/persister-cr-sqlite-wasm.js +1 -0
  161. package/lib/umd/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
  162. package/lib/umd/persisters/persister-file.js +1 -0
  163. package/lib/umd/persisters/persister-file.js.gz +0 -0
  164. package/lib/umd/persisters/persister-remote.js +1 -0
  165. package/lib/umd/persisters/persister-remote.js.gz +0 -0
  166. package/lib/umd/persisters/persister-sqlite-wasm.js +1 -0
  167. package/lib/umd/persisters/persister-sqlite-wasm.js.gz +0 -0
  168. package/lib/umd/persisters/persister-sqlite3.js +1 -0
  169. package/lib/umd/persisters/persister-sqlite3.js.gz +0 -0
  170. package/lib/umd/persisters/persister-yjs.js +1 -0
  171. package/lib/umd/persisters/persister-yjs.js.gz +0 -0
  172. package/lib/umd/persisters.js +1 -1
  173. package/lib/umd/persisters.js.gz +0 -0
  174. package/lib/umd/store.js +1 -1
  175. package/lib/umd/store.js.gz +0 -0
  176. package/lib/umd/tinybase.js +1 -1
  177. package/lib/umd/tinybase.js.gz +0 -0
  178. package/lib/umd/tools.js +1 -1
  179. package/lib/umd/tools.js.gz +0 -0
  180. package/lib/umd/ui-react.js +1 -1
  181. package/lib/umd/ui-react.js.gz +0 -0
  182. package/lib/umd-es6/persisters/persister-automerge.js +1 -0
  183. package/lib/umd-es6/persisters/persister-automerge.js.gz +0 -0
  184. package/lib/umd-es6/persisters/persister-browser.js +1 -0
  185. package/lib/umd-es6/persisters/persister-browser.js.gz +0 -0
  186. package/lib/umd-es6/persisters/persister-cr-sqlite-wasm.js +1 -0
  187. package/lib/umd-es6/persisters/persister-cr-sqlite-wasm.js.gz +0 -0
  188. package/lib/umd-es6/persisters/persister-file.js +1 -0
  189. package/lib/umd-es6/persisters/persister-file.js.gz +0 -0
  190. package/lib/umd-es6/persisters/persister-remote.js +1 -0
  191. package/lib/umd-es6/persisters/persister-remote.js.gz +0 -0
  192. package/lib/umd-es6/persisters/persister-sqlite-wasm.js +1 -0
  193. package/lib/umd-es6/persisters/persister-sqlite-wasm.js.gz +0 -0
  194. package/lib/umd-es6/persisters/persister-sqlite3.js +1 -0
  195. package/lib/umd-es6/persisters/persister-sqlite3.js.gz +0 -0
  196. package/lib/umd-es6/persisters/persister-yjs.js +1 -0
  197. package/lib/umd-es6/persisters/persister-yjs.js.gz +0 -0
  198. package/lib/umd-es6/persisters.js +1 -1
  199. package/lib/umd-es6/persisters.js.gz +0 -0
  200. package/lib/umd-es6/store.js +1 -1
  201. package/lib/umd-es6/store.js.gz +0 -0
  202. package/lib/umd-es6/tinybase.js +1 -1
  203. package/lib/umd-es6/tinybase.js.gz +0 -0
  204. package/lib/umd-es6/tools.js +1 -1
  205. package/lib/umd-es6/tools.js.gz +0 -0
  206. package/lib/umd-es6/ui-react.js +1 -1
  207. package/lib/umd-es6/ui-react.js.gz +0 -0
  208. package/package.json +39 -22
  209. package/readme.md +3 -3
  210. package/lib/cjs/persister-automerge.cjs +0 -1
  211. package/lib/cjs/persister-automerge.cjs.gz +0 -0
  212. package/lib/cjs/persister-browser.cjs +0 -1
  213. package/lib/cjs/persister-browser.cjs.gz +0 -0
  214. package/lib/cjs/persister-file.cjs +0 -1
  215. package/lib/cjs/persister-file.cjs.gz +0 -0
  216. package/lib/cjs/persister-remote.cjs +0 -1
  217. package/lib/cjs/persister-remote.cjs.gz +0 -0
  218. package/lib/cjs/persister-yjs.cjs +0 -1
  219. package/lib/cjs/persister-yjs.cjs.gz +0 -0
  220. package/lib/cjs-es6/persister-automerge.cjs +0 -1
  221. package/lib/cjs-es6/persister-automerge.cjs.gz +0 -0
  222. package/lib/cjs-es6/persister-browser.cjs +0 -1
  223. package/lib/cjs-es6/persister-browser.cjs.gz +0 -0
  224. package/lib/cjs-es6/persister-file.cjs +0 -1
  225. package/lib/cjs-es6/persister-file.cjs.gz +0 -0
  226. package/lib/cjs-es6/persister-remote.cjs +0 -1
  227. package/lib/cjs-es6/persister-remote.cjs.gz +0 -0
  228. package/lib/cjs-es6/persister-yjs.cjs +0 -1
  229. package/lib/cjs-es6/persister-yjs.cjs.gz +0 -0
  230. package/lib/es6/persister-automerge.js +0 -1
  231. package/lib/es6/persister-automerge.js.gz +0 -0
  232. package/lib/es6/persister-browser.js +0 -1
  233. package/lib/es6/persister-browser.js.gz +0 -0
  234. package/lib/es6/persister-file.js +0 -1
  235. package/lib/es6/persister-file.js.gz +0 -0
  236. package/lib/es6/persister-remote.js +0 -1
  237. package/lib/es6/persister-remote.js.gz +0 -0
  238. package/lib/es6/persister-yjs.js +0 -1
  239. package/lib/es6/persister-yjs.js.gz +0 -0
  240. package/lib/persister-automerge.js +0 -1
  241. package/lib/persister-automerge.js.gz +0 -0
  242. package/lib/persister-browser.js +0 -1
  243. package/lib/persister-browser.js.gz +0 -0
  244. package/lib/persister-file.js +0 -1
  245. package/lib/persister-file.js.gz +0 -0
  246. package/lib/persister-remote.js +0 -1
  247. package/lib/persister-remote.js.gz +0 -0
  248. package/lib/persister-yjs.js +0 -1
  249. package/lib/persister-yjs.js.gz +0 -0
  250. package/lib/umd/persister-automerge.js +0 -1
  251. package/lib/umd/persister-automerge.js.gz +0 -0
  252. package/lib/umd/persister-browser.js +0 -1
  253. package/lib/umd/persister-browser.js.gz +0 -0
  254. package/lib/umd/persister-file.js +0 -1
  255. package/lib/umd/persister-file.js.gz +0 -0
  256. package/lib/umd/persister-remote.js +0 -1
  257. package/lib/umd/persister-remote.js.gz +0 -0
  258. package/lib/umd/persister-yjs.js +0 -1
  259. package/lib/umd/persister-yjs.js.gz +0 -0
  260. package/lib/umd-es6/persister-automerge.js +0 -1
  261. package/lib/umd-es6/persister-automerge.js.gz +0 -0
  262. package/lib/umd-es6/persister-browser.js +0 -1
  263. package/lib/umd-es6/persister-browser.js.gz +0 -0
  264. package/lib/umd-es6/persister-file.js +0 -1
  265. package/lib/umd-es6/persister-file.js.gz +0 -0
  266. package/lib/umd-es6/persister-remote.js +0 -1
  267. package/lib/umd-es6/persister-remote.js.gz +0 -0
  268. package/lib/umd-es6/persister-yjs.js +0 -1
  269. package/lib/umd-es6/persister-yjs.js.gz +0 -0
@@ -6,7 +6,6 @@
6
6
  * returns a new Indexes object. From there, you can create new Index
7
7
  * definitions, access the contents of those Indexes directly, and register
8
8
  * listeners for when they change.
9
- *
10
9
  * @packageDocumentation
11
10
  * @module indexes
12
11
  */
@@ -24,7 +23,6 @@ import {Id, IdOrNull, Ids, SortKey} from './common.d';
24
23
  * Note that the Index type is not actually used in the API, and you instead
25
24
  * enumerate and access its structure with the getSliceIds method and
26
25
  * getSliceRowIds method.
27
- *
28
26
  * @category Concept
29
27
  */
30
28
  export type Index = {[sliceId: Id]: Slice};
@@ -38,7 +36,6 @@ export type Index = {[sliceId: Id]: Slice};
38
36
  *
39
37
  * Note that the Slice type is not actually used in the API, and you instead get
40
38
  * Row Ids directly with the getSliceRowIds method.
41
- *
42
39
  * @category Concept
43
40
  */
44
41
  export type Slice = Ids;
@@ -50,7 +47,6 @@ export type Slice = Ids;
50
47
  * A IndexCallback is provided when using the forEachIndex method, so that you
51
48
  * can do something based on every Index in the Indexes object. See that method
52
49
  * for specific examples.
53
- *
54
50
  * @param indexId The Id of the Index that the callback can operate on.
55
51
  * @param forEachRow A function that will let you iterate over the Slice objects
56
52
  * in this Index.
@@ -68,7 +64,6 @@ export type IndexCallback = (
68
64
  * A SliceCallback is provided when using the forEachSlice method, so that you
69
65
  * can do something based on every Slice in an Index. See that method for
70
66
  * specific examples.
71
- *
72
67
  * @param sliceId The Id of the Slice that the callback can operate on.
73
68
  * @param forEachRow A function that will let you iterate over the Row objects
74
69
  * in this Slice.
@@ -88,7 +83,6 @@ export type SliceCallback = (
88
83
  *
89
84
  * When called, a SliceIdsListener is given a reference to the Indexes object,
90
85
  * and the Id of the Index that changed.
91
- *
92
86
  * @param indexes A reference to the Indexes object that changed.
93
87
  * @param indexId The Id of the Index that changed.
94
88
  * @category Listener
@@ -105,7 +99,6 @@ export type SliceIdsListener = (indexes: Indexes, indexId: Id) => void;
105
99
  * When called, a SliceRowIdsListener is given a reference to the Indexes
106
100
  * object, the Id of the Index that changed, and the Id of the Slice whose Row
107
101
  * Ids changed.
108
- *
109
102
  * @param indexes A reference to the Indexes object that changed.
110
103
  * @param indexId The Id of the Index that changed.
111
104
  * @param sliceId The Id of the Slice that changed.
@@ -123,7 +116,6 @@ export type SliceRowIdsListener = (
123
116
  *
124
117
  * A IndexesListenerStats object is returned from the getListenerStats method,
125
118
  * and is only populated in a debug build.
126
- *
127
119
  * @category Development
128
120
  */
129
121
  export type IndexesListenerStats = {
@@ -154,7 +146,6 @@ export type IndexesListenerStats = {
154
146
  *
155
147
  * This module defaults to indexing Row objects by one of their Cell values.
156
148
  * However, far more complex indexes can be configured with a custom function.
157
- *
158
149
  * @example
159
150
  * This example shows a very simple lifecycle of an Indexes object: from
160
151
  * creation, to adding a definition, getting its contents, and then registering
@@ -241,7 +232,6 @@ export interface Indexes {
241
232
  * Slice Id parameter, in case you want to sort Row Ids differently in each
242
233
  * Slice. You can use the convenient defaultSorter function to default this to
243
234
  * be alphanumeric.
244
- *
245
235
  * @param indexId The Id of the Index to define.
246
236
  * @param tableId The Id of the Table the Index will be generated from.
247
237
  * @param getSliceIdOrIds Either the Id of the Cell containing, or a function
@@ -360,7 +350,6 @@ export interface Indexes {
360
350
 
361
351
  /**
362
352
  * The delIndexDefinition method removes an existing Index definition.
363
- *
364
353
  * @param indexId The Id of the Index to remove.
365
354
  * @returns A reference to the Indexes object.
366
355
  * @example
@@ -390,7 +379,6 @@ export interface Indexes {
390
379
  /**
391
380
  * The getStore method returns a reference to the underlying Store that is
392
381
  * backing this Indexes object.
393
- *
394
382
  * @returns A reference to the Store.
395
383
  * @example
396
384
  * This example creates an Indexes object against a newly-created Store and
@@ -410,7 +398,6 @@ export interface Indexes {
410
398
  /**
411
399
  * The getIndexIds method returns an array of the Index Ids registered with
412
400
  * this Indexes object.
413
- *
414
401
  * @returns An array of Ids.
415
402
  * @example
416
403
  * This example creates an Indexes object with two definitions, and then gets
@@ -437,7 +424,6 @@ export interface Indexes {
437
424
  * IndexCallback function that will be called with the Id of each Index, and
438
425
  * with a function that can then be used to iterate over each Slice of the
439
426
  * Index, should you wish.
440
- *
441
427
  * @param indexCallback The function that should be called for every Index.
442
428
  * @example
443
429
  * This example iterates over each Index in an Indexes object, and lists each
@@ -476,7 +462,6 @@ export interface Indexes {
476
462
  * in a functional style. The `rowCallback` parameter is a RowCallback
477
463
  * function that will be called with the Id and value of each Row in the
478
464
  * Slice.
479
- *
480
465
  * @param indexId The Id of the Index to iterate over.
481
466
  * @param sliceCallback The function that should be called for every Slice.
482
467
  * @example
@@ -508,7 +493,6 @@ export interface Indexes {
508
493
  /**
509
494
  * The hasIndex method returns a boolean indicating whether a given Index
510
495
  * exists in the Indexes object.
511
- *
512
496
  * @param indexId The Id of a possible Index in the Indexes object.
513
497
  * @returns Whether an Index with that Id exists.
514
498
  * @example
@@ -529,7 +513,6 @@ export interface Indexes {
529
513
  /**
530
514
  * The hasSlice method returns a boolean indicating whether a given Slice
531
515
  * exists in the Indexes object.
532
- *
533
516
  * @param indexId The Id of a possible Index in the Indexes object.
534
517
  * @param sliceId The Id of a possible Slice in the Index.
535
518
  * @returns Whether a Slice with that Id exists.
@@ -558,7 +541,6 @@ export interface Indexes {
558
541
  * backing an Index.
559
542
  *
560
543
  * If the Index Id is invalid, the method returns `undefined`.
561
- *
562
544
  * @param indexId The Id of an Index.
563
545
  * @returns The Id of the Table backing the Index, or `undefined`.
564
546
  * @example
@@ -583,7 +565,6 @@ export interface Indexes {
583
565
  *
584
566
  * If the identified Index does not exist (or if the definition references a
585
567
  * Table that does not exist) then an empty array is returned.
586
- *
587
568
  * @param indexId The Id of the Index.
588
569
  * @returns The Slice Ids in the Index, or an empty array.
589
570
  * @example
@@ -616,7 +597,6 @@ export interface Indexes {
616
597
  *
617
598
  * If the identified Index or Slice do not exist (or if the definition
618
599
  * references a Table that does not exist) then an empty array is returned.
619
- *
620
600
  * @param indexId The Id of the Index.
621
601
  * @param sliceId The Id of the Slice in the Index.
622
602
  * @returns The Row Ids in the Slice, or an empty array.
@@ -658,7 +638,6 @@ export interface Indexes {
658
638
  * The provided listener is a SliceIdsListener function, and will be called
659
639
  * with a reference to the Indexes object, and the Id of the Index that
660
640
  * changed.
661
- *
662
641
  * @param indexId The Id of the Index to listen to, or `null` as a wildcard.
663
642
  * @param listener The function that will be called whenever the Slice Ids in
664
643
  * the Index change.
@@ -742,7 +721,6 @@ export interface Indexes {
742
721
  * The provided listener is a SliceRowIdsListener function, and will be called
743
722
  * with a reference to the Indexes object, the Id of the Index, and the Id of
744
723
  * the Slice that changed.
745
- *
746
724
  * @param indexId The Id of the Index to listen to, or `null` as a wildcard.
747
725
  * @param sliceId The Id of the Slice to listen to, or `null` as a wildcard.
748
726
  * @param listener The function that will be called whenever the Row Ids in
@@ -826,7 +804,6 @@ export interface Indexes {
826
804
  * Use the Id returned by whichever method was used to add the listener. Note
827
805
  * that the Indexes object may re-use this Id for future listeners added to
828
806
  * it.
829
- *
830
807
  * @param listenerId The Id of the listener to remove.
831
808
  * @returns A reference to the Indexes object.
832
809
  * @example
@@ -869,7 +846,6 @@ export interface Indexes {
869
846
  *
870
847
  * This guarantees that all of the listeners that the object registered with
871
848
  * the underlying Store are removed and it can be correctly garbage collected.
872
- *
873
849
  * @example
874
850
  * This example creates a Store, adds an Indexes object with a
875
851
  * definition (that registers a RowListener with the underlying Store),
@@ -908,7 +884,6 @@ export interface Indexes {
908
884
  * return an empty object. The method is intended to be used during
909
885
  * development to ensure your application is not leaking listener
910
886
  * registrations, for example.
911
- *
912
887
  * @returns A IndexesListenerStats object containing Indexes listener
913
888
  * statistics.
914
889
  * @example
@@ -940,7 +915,6 @@ export interface Indexes {
940
915
  * A given Store can only have one Indexes object associated with it. If you
941
916
  * call this function twice on the same Store, your second call will return a
942
917
  * reference to the Indexes object created by the first.
943
- *
944
918
  * @param store The Store for which to register Index definitions.
945
919
  * @returns A reference to the new Indexes object.
946
920
  * @example
@@ -6,7 +6,6 @@
6
6
  * returns a new Metrics object. From there, you can create new Metric
7
7
  * definitions, access the values of those Metrics directly, and register
8
8
  * listeners for when they change.
9
- *
10
9
  * @packageDocumentation
11
10
  * @module metrics
12
11
  */
@@ -17,7 +16,6 @@ import {Id, IdOrNull, Ids} from './common.d';
17
16
  /**
18
17
  * The Metric type is simply an alias, but represents a number formed by
19
18
  * aggregating multiple other numbers together.
20
- *
21
19
  * @category Metric
22
20
  */
23
21
  export type Metric = number;
@@ -29,7 +27,6 @@ export type Metric = number;
29
27
  * A MetricCallback is provided when using the forEachMetric method, so that you
30
28
  * can do something based on every Metric in the Metrics object. See that method
31
29
  * for specific examples.
32
- *
33
30
  * @param metricId The Id of the Metric that the callback can operate on.
34
31
  * @param metric The value of the Metric.
35
32
  * @category Callback
@@ -44,7 +41,6 @@ export type MetricCallback = (metricId: Id, metric?: Metric) => void;
44
41
  * summing, and averaging values. This type is instead used for when you wish to
45
42
  * use a more complex aggregation of your own devising. See the
46
43
  * setMetricDefinition method for more examples.
47
- *
48
44
  * @param numbers The array of numbers in the Metric's aggregation.
49
45
  * @param length The length of the array of numbers in the Metric's aggregation.
50
46
  * @returns The value of the Metric.
@@ -69,7 +65,6 @@ export type MetricAggregate = (numbers: number[], length: number) => Metric;
69
65
  * implementation of an MetricAggregateAdd function that can reduce the
70
66
  * complexity cost of growing the input data set. See the setMetricDefinition
71
67
  * method for more examples.
72
- *
73
68
  * @param metric The current value of the Metric.
74
69
  * @param add The number being added to the Metric's aggregation.
75
70
  * @param length The length of the array of numbers in the Metric's aggregation.
@@ -102,7 +97,6 @@ export type MetricAggregateAdd = (
102
97
  * implementation of an MetricAggregateRemove function that can reduce the
103
98
  * complexity cost of shrinking the input data set. See the setMetricDefinition
104
99
  * method for more examples.
105
- *
106
100
  * @param metric The current value of the Metric.
107
101
  * @param remove The number being removed from the Metric's aggregation.
108
102
  * @param length The length of the array of numbers in the Metric's aggregation.
@@ -132,7 +126,6 @@ export type MetricAggregateRemove = (
132
126
  * implementation of an MetricAggregateReplace function that can reduce the
133
127
  * complexity cost of changing the input data set in place. See the
134
128
  * setMetricDefinition method for more examples.
135
- *
136
129
  * @param metric The current value of the Metric.
137
130
  * @param add The number being added to the Metric's aggregation.
138
131
  * @param remove The number being removed from the Metric's aggregation.
@@ -160,7 +153,6 @@ export type MetricAggregateReplace = (
160
153
  * If this is the first time that a Metric has had a value (such as when a table
161
154
  * has gained its first row), the old value will be `undefined`. If a Metric now
162
155
  * no longer has a value, the new value will be `undefined`.
163
- *
164
156
  * @param metrics A reference to the Metrics object that changed.
165
157
  * @param metricId The Id of the Metric that changed.
166
158
  * @param newMetric The new value of the Metric that changed.
@@ -180,7 +172,6 @@ export type MetricListener = (
180
172
  *
181
173
  * A MetricsListenerStats object is returned from the getListenerStats method,
182
174
  * and is only populated in a debug build.
183
- *
184
175
  * @category Development
185
176
  */
186
177
  export type MetricsListenerStats = {
@@ -206,7 +197,6 @@ export type MetricsListenerStats = {
206
197
  * ('sum', 'avg', 'min', and 'max'), and defaults to counting Row objects when
207
198
  * using the setMetricDefinition method. However, far more complex aggregations
208
199
  * can be configured with custom functions.
209
- *
210
200
  * @example
211
201
  * This example shows a very simple lifecycle of a Metrics object: from
212
202
  * creation, to adding a definition, getting a Metric, and then registering and
@@ -274,7 +264,6 @@ export interface Metrics {
274
264
  * function's algorithmic complexity by providing shortcuts that can nudge an
275
265
  * aggregation result when a single value is added, removed, or replaced in
276
266
  * the input values.
277
- *
278
267
  * @param metricId The Id of the Metric to define.
279
268
  * @param tableId The Id of the Table the Metric will be calculated from.
280
269
  * @param aggregate Either a string representing one of a set of common
@@ -424,7 +413,6 @@ export interface Metrics {
424
413
 
425
414
  /**
426
415
  * The delMetricDefinition method removes an existing Metric definition.
427
- *
428
416
  * @param metricId The Id of the Metric to remove.
429
417
  * @returns A reference to the Metrics object.
430
418
  * @example
@@ -454,7 +442,6 @@ export interface Metrics {
454
442
  /**
455
443
  * The getStore method returns a reference to the underlying Store that is
456
444
  * backing this Metrics object.
457
- *
458
445
  * @returns A reference to the Store.
459
446
  * @example
460
447
  * This example creates a Metrics object against a newly-created Store and
@@ -474,7 +461,6 @@ export interface Metrics {
474
461
  /**
475
462
  * The getMetricIds method returns an array of the Metric Ids registered with
476
463
  * this Metrics object.
477
- *
478
464
  * @returns An array of Ids.
479
465
  * @example
480
466
  * This example creates a Metrics object with two definitions, and then gets
@@ -499,7 +485,6 @@ export interface Metrics {
499
485
  * This method is useful for iterating over all the Metrics in a functional
500
486
  * style. The `metricCallback` parameter is a MetricCallback function that
501
487
  * will be called with the Id of each Metric and its value.
502
- *
503
488
  * @param metricCallback The function that should be called for every Metric.
504
489
  * @example
505
490
  * This example iterates over each Metric in a Metrics object.
@@ -527,7 +512,6 @@ export interface Metrics {
527
512
  /**
528
513
  * The hasMetric method returns a boolean indicating whether a given Metric
529
514
  * exists in the Metrics object, and has a value.
530
- *
531
515
  * @param metricId The Id of a possible Metric in the Metrics object.
532
516
  * @returns Whether a Metric with that Id exists.
533
517
  * @example
@@ -555,7 +539,6 @@ export interface Metrics {
555
539
  * backing a Metric.
556
540
  *
557
541
  * If the Metric Id is invalid, the method returns `undefined`.
558
- *
559
542
  * @param metricId The Id of a Metric.
560
543
  * @returns The Id of the Table backing the Metric, or `undefined`.
561
544
  * @example
@@ -580,7 +563,6 @@ export interface Metrics {
580
563
  *
581
564
  * If the identified Metric does not exist (or if the definition references a
582
565
  * Table or Cell value that does not exist) then `undefined` is returned.
583
- *
584
566
  * @param metricId The Id of the Metric.
585
567
  * @returns The numeric value of the Metric, or `undefined`.
586
568
  * @example
@@ -620,7 +602,6 @@ export interface Metrics {
620
602
  * The provided listener is a MetricListener function, and will be called with
621
603
  * a reference to the Metrics object, the Id of the Metric that changed, the
622
604
  * new Metric value, and the old Metric value.
623
- *
624
605
  * @param metricId The Id of the Metric to listen to, or `null` as a wildcard.
625
606
  * @param listener The function that will be called whenever the Metric
626
607
  * changes.
@@ -694,7 +675,6 @@ export interface Metrics {
694
675
  *
695
676
  * Use the Id returned by the addMetricListener method. Note that the Metrics
696
677
  * object may re-use this Id for future listeners added to it.
697
- *
698
678
  * @param listenerId The Id of the listener to remove.
699
679
  * @returns A reference to the Metrics object.
700
680
  * @example
@@ -737,7 +717,6 @@ export interface Metrics {
737
717
  *
738
718
  * This guarantees that all of the listeners that the object registered with
739
719
  * the underlying Store are removed and it can be correctly garbage collected.
740
- *
741
720
  * @example
742
721
  * This example creates a Store, adds a Metrics object with a definition (that
743
722
  * registers a RowListener with the underlying Store), and then destroys it
@@ -773,7 +752,6 @@ export interface Metrics {
773
752
  * return an empty object. The method is intended to be used during
774
753
  * development to ensure your application is not leaking listener
775
754
  * registrations, for example.
776
- *
777
755
  * @returns A MetricsListenerStats object containing Metrics listener
778
756
  * statistics.
779
757
  * @example
@@ -800,7 +778,6 @@ export interface Metrics {
800
778
  * A given Store can only have one Metrics object associated with it. If you
801
779
  * call this function twice on the same Store, your second call will return a
802
780
  * reference to the Metrics object created by the first.
803
- *
804
781
  * @param store The Store for which to register Metric definitions.
805
782
  * @returns A reference to the new Metrics object.
806
783
  * @example
@@ -5,16 +5,15 @@
5
5
  * A single entry point, the createAutomergePersister function, is provided,
6
6
  * which returns a new Persister object that can bind a Store to a provided
7
7
  * Automerge document handle (and in turn, its document).
8
- *
9
8
  * @see Synchronizing Data guide
10
9
  * @packageDocumentation
11
10
  * @module persister-automerge
12
- * @since v4.0
11
+ * @since v4.0.0
13
12
  */
14
13
 
15
14
  import {DocHandle} from 'automerge-repo';
16
- import {Persister} from './persisters';
17
- import {Store} from './store';
15
+ import {Persister} from '../persisters';
16
+ import {Store} from '../store';
18
17
 
19
18
  /**
20
19
  * The createAutomergePersister function creates a Persister object that can
@@ -22,7 +21,6 @@ import {Store} from './store';
22
21
  *
23
22
  * As well as providing a reference to the Store to persist, you must provide
24
23
  * the Automerge document handler to persist it with.
25
- *
26
24
  * @param store The Store to persist.
27
25
  * @param docHandle The Automerge document handler to persist the Store with.
28
26
  * @param docMapName The name of the map used inside the Automerge document to
@@ -101,7 +99,7 @@ import {Store} from './store';
101
99
  * persister2.destroy();
102
100
  * ```
103
101
  * @category Creation
104
- * @since v4.0
102
+ * @since v4.0.0
105
103
  */
106
104
  export function createAutomergePersister(
107
105
  store: Store,
@@ -9,14 +9,13 @@
9
9
  * browser's session storage.
10
10
  * - The createLocalPersister function returns a Persister that uses the
11
11
  * browser's local storage.
12
- *
13
12
  * @see Persisting Data guide
14
13
  * @packageDocumentation
15
14
  * @module persister-browser
16
15
  */
17
16
 
18
- import {Persister} from './persisters';
19
- import {Store} from './store';
17
+ import {Persister} from '../persisters';
18
+ import {Store} from '../store';
20
19
 
21
20
  /**
22
21
  * The createSessionPersister function creates a Persister object that can
@@ -25,7 +24,6 @@ import {Store} from './store';
25
24
  * As well as providing a reference to the Store to persist, you must provide a
26
25
  * `storageName` parameter which is unique to your application. This is the key
27
26
  * that the browser uses to identify the storage location.
28
- *
29
27
  * @param store The Store to persist.
30
28
  * @param storageName The unique key to identify the storage location.
31
29
  * @returns A reference to the new Persister object.
@@ -58,7 +56,6 @@ export function createSessionPersister(
58
56
  * As well as providing a reference to the Store to persist, you must provide a
59
57
  * `storageName` parameter which is unique to your application. This is the key
60
58
  * that the browser uses to identify the storage location.
61
- *
62
59
  * @param store The Store to persist.
63
60
  * @param storageName The unique key to identify the storage location.
64
61
  * @returns A reference to the new Persister object.
@@ -0,0 +1,95 @@
1
+ /**
2
+ * The persister-cr-sqlite-wasm module of the TinyBase project lets you save and
3
+ * load Store data to and from a local CR-SQLite database (in an appropriate
4
+ * environment).
5
+ * @see Persisting Data guide
6
+ * @packageDocumentation
7
+ * @module persister-cr-sqlite-wasm
8
+ */
9
+
10
+ import {DatabasePersisterConfig, Persister} from '../persisters';
11
+ import {DB} from '@vlcn.io/crsqlite-wasm';
12
+ import {Store} from '../store';
13
+
14
+ /**
15
+ * The createCrSqliteWasmPersister function creates a Persister object that can
16
+ * persist the Store to a local CR-SQLite database (in an appropriate
17
+ * environment).
18
+ *
19
+ * As well as providing a reference to the Store to persist, you must provide
20
+ * a `db` parameter which identifies the database instance.
21
+ *
22
+ * A database Persister uses one of two modes: either a JSON serialization of
23
+ * the whole Store stored in a single row of a table (the default), or a tabular
24
+ * mapping of Table Ids to database table names and vice-versa).
25
+ *
26
+ * The third argument is a DatabasePersisterConfig object that configures which
27
+ * of those modes to use, and settings for each. If the third argument is simply
28
+ * a string, it is used as the `storeTableName` property of the JSON
29
+ * serialization.
30
+ *
31
+ * See the documentation for the DpcJson and DpcTabular types for more
32
+ * information on how both of those modes can be configured.
33
+ * @param store The Store to persist.
34
+ * @param db The database instance that was returned from `crSqlite3.open(...)`.
35
+ * @param configOrStoreTableName A DatabasePersisterConfig to configure the
36
+ * persistence mode (or a string to set the `storeTableName` property of the
37
+ * JSON serialization).
38
+ * @returns A reference to the new Persister object.
39
+ * @example
40
+ * This example creates a Persister object and persists the Store to a local
41
+ * CR-SQLite database as a JSON serialization into the `my_tinybase` table. It
42
+ * makes a change to the database directly and then reloads it back into the
43
+ * Store.
44
+ *
45
+ * ```js
46
+ * const crSqlite3 = await initWasm();
47
+ * const db = await crSqlite3.open();
48
+ * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
49
+ * const persister = createCrSqliteWasmPersister(store, db, 'my_tinybase');
50
+ *
51
+ * await persister.save();
52
+ * console.log(await db.execO('SELECT * FROM my_tinybase;'));
53
+ * // -> [{_id: '_', store: '[{"pets":{"fido":{"species":"dog"}}},{}]'}]
54
+ *
55
+ * await db.exec(
56
+ * 'UPDATE my_tinybase SET store = ' +
57
+ * `'[{"pets":{"felix":{"species":"cat"}}},{}]' WHERE _id = '_';`,
58
+ * );
59
+ * await persister.load();
60
+ * console.log(store.getTables());
61
+ * // -> {pets: {felix: {species: 'cat'}}}
62
+ *
63
+ * persister.destroy();
64
+ * ```
65
+ * @example
66
+ * This example creates a Persister object and persists the Store to a local
67
+ * SQLite database with tabular mapping.
68
+ *
69
+ * ```js
70
+ * const crSqlite3 = await initWasm();
71
+ * const db = await crSqlite3.open();
72
+ * const store = createStore().setTables({pets: {fido: {species: 'dog'}}});
73
+ * const persister = createCrSqliteWasmPersister(store, db, {
74
+ * mode: 'tabular',
75
+ * tables: {load: {pets: 'pets'}, save: {pets: 'pets'}},
76
+ * });
77
+ *
78
+ * await persister.save();
79
+ * console.log(await db.execO('SELECT * FROM pets;'));
80
+ * // -> [{_id: 'fido', species: 'dog'}]
81
+ *
82
+ * await db.exec(`INSERT INTO pets (_id, species) VALUES ('felix', 'cat')`);
83
+ * await persister.load();
84
+ * console.log(store.getTables());
85
+ * // -> {pets: {fido: {species: 'dog'}, felix: {species: 'cat'}}}
86
+ *
87
+ * persister.destroy();
88
+ * ```
89
+ * @category Creation
90
+ */
91
+ export function createCrSqliteWasmPersister(
92
+ store: Store,
93
+ db: DB,
94
+ configOrStoreTableName?: DatabasePersisterConfig | string,
95
+ ): Persister;
@@ -1,22 +1,20 @@
1
1
  /**
2
2
  * The persister-file module of the TinyBase project lets you save and load
3
3
  * Store data to and from a local file system (in an appropriate environment).
4
- *
5
4
  * @see Persisting Data guide
6
5
  * @packageDocumentation
7
6
  * @module persister-file
8
7
  */
9
8
 
10
- import {Persister} from './persisters';
11
- import {Store} from './store';
9
+ import {Persister} from '../persisters';
10
+ import {Store} from '../store';
12
11
 
13
12
  /**
14
13
  * The createFilePersister function creates a Persister object that can persist
15
14
  * the Store to a local file (in an appropriate environment).
16
15
  *
17
- * As well as providing a reference to the Store to persist, you must provide
16
+ * As well as providing a reference to the Store to persist, you must provide a
18
17
  * `filePath` parameter which identifies the file to persist it to.
19
- *
20
18
  * @param store The Store to persist.
21
19
  * @param filePath The location of the local file to persist the Store to.
22
20
  * @returns A reference to the new Persister object.
@@ -1,14 +1,13 @@
1
1
  /**
2
2
  * The persister-remote module of the TinyBase project lets you save and load
3
3
  * Store data to and from a remote server.
4
- *
5
4
  * @see Persisting Data guide
6
5
  * @packageDocumentation
7
6
  * @module persister-remote
8
7
  */
9
8
 
10
- import {Persister} from './persisters';
11
- import {Store} from './store';
9
+ import {Persister} from '../persisters';
10
+ import {Store} from '../store';
12
11
 
13
12
  /**
14
13
  * The createRemotePersister function creates a Persister object that can
@@ -22,7 +21,6 @@ import {Store} from './store';
22
21
  * For when you choose to enable automatic loading for the Persister (with the
23
22
  * startAutoLoad method), it will poll the loadUrl for changes. The
24
23
  * `autoLoadIntervalSeconds` method is used to indicate how often to do this.
25
- *
26
24
  * @param store The Store to persist.
27
25
  * @param loadUrl The endpoint that supports a `GET` method to load JSON.
28
26
  * @param saveUrl The endpoint that supports a `POST` method to save JSON.