@yaks/sqlite 0.0.0-stage → 0.2.36

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 (289) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +1596 -2
  3. package/_dist/archetype.d.ts +75 -0
  4. package/_dist/archetype.d.ts.map +1 -0
  5. package/_dist/branches.d.ts +23 -0
  6. package/_dist/branches.d.ts.map +1 -0
  7. package/_dist/budget.d.ts +52 -0
  8. package/_dist/budget.d.ts.map +1 -0
  9. package/_dist/bundle.d.ts +2 -0
  10. package/_dist/bundle.d.ts.map +1 -0
  11. package/_dist/cache.d.ts +24 -0
  12. package/_dist/cache.d.ts.map +1 -0
  13. package/_dist/catalog.d.ts +9 -0
  14. package/_dist/catalog.d.ts.map +1 -0
  15. package/_dist/check.d.ts +4 -0
  16. package/_dist/check.d.ts.map +1 -0
  17. package/_dist/db.d.ts +36 -0
  18. package/_dist/db.d.ts.map +1 -0
  19. package/_dist/ddl.d.ts +143 -0
  20. package/_dist/ddl.d.ts.map +1 -0
  21. package/_dist/doom.d.ts +22 -0
  22. package/_dist/doom.d.ts.map +1 -0
  23. package/_dist/follow.d.ts +74 -0
  24. package/_dist/follow.d.ts.map +1 -0
  25. package/_dist/history-shapes.d.ts +3 -0
  26. package/_dist/history-shapes.d.ts.map +1 -0
  27. package/_dist/history.d.ts +18 -0
  28. package/_dist/history.d.ts.map +1 -0
  29. package/_dist/inspect.d.ts +43 -0
  30. package/_dist/inspect.d.ts.map +1 -0
  31. package/_dist/jsonb.d.ts +17 -0
  32. package/_dist/jsonb.d.ts.map +1 -0
  33. package/_dist/layout.d.ts +7 -0
  34. package/_dist/layout.d.ts.map +1 -0
  35. package/_dist/ledger.d.ts +41 -0
  36. package/_dist/ledger.d.ts.map +1 -0
  37. package/_dist/meta.d.ts +89 -0
  38. package/_dist/meta.d.ts.map +1 -0
  39. package/_dist/migration.d.ts +41 -0
  40. package/_dist/migration.d.ts.map +1 -0
  41. package/_dist/mod.d.ts +201 -0
  42. package/_dist/mod.d.ts.map +1 -0
  43. package/_dist/mode.d.ts +14 -0
  44. package/_dist/mode.d.ts.map +1 -0
  45. package/_dist/overlay.d.ts +30 -0
  46. package/_dist/overlay.d.ts.map +1 -0
  47. package/_dist/owe.d.ts +180 -0
  48. package/_dist/owe.d.ts.map +1 -0
  49. package/_dist/physical.d.ts +89 -0
  50. package/_dist/physical.d.ts.map +1 -0
  51. package/_dist/point.d.ts +10 -0
  52. package/_dist/point.d.ts.map +1 -0
  53. package/_dist/raise.d.ts +22 -0
  54. package/_dist/raise.d.ts.map +1 -0
  55. package/_dist/read-db.d.ts +9 -0
  56. package/_dist/read-db.d.ts.map +1 -0
  57. package/_dist/read-store.d.ts +10 -0
  58. package/_dist/read-store.d.ts.map +1 -0
  59. package/_dist/read.d.ts +59 -0
  60. package/_dist/read.d.ts.map +1 -0
  61. package/_dist/reader.d.ts +11 -0
  62. package/_dist/reader.d.ts.map +1 -0
  63. package/_dist/rules.d.ts +19 -0
  64. package/_dist/rules.d.ts.map +1 -0
  65. package/_dist/service.d.ts +12 -0
  66. package/_dist/service.d.ts.map +1 -0
  67. package/_dist/shape.d.ts +12 -0
  68. package/_dist/shape.d.ts.map +1 -0
  69. package/_dist/statements.d.ts +4 -0
  70. package/_dist/statements.d.ts.map +1 -0
  71. package/_dist/survey.d.ts +31 -0
  72. package/_dist/survey.d.ts.map +1 -0
  73. package/_dist/tools.d.ts +15 -0
  74. package/_dist/tools.d.ts.map +1 -0
  75. package/_dist/trash.d.ts +18 -0
  76. package/_dist/trash.d.ts.map +1 -0
  77. package/_dist/unit.d.ts +11 -0
  78. package/_dist/unit.d.ts.map +1 -0
  79. package/_dist/vocab.d.ts +6 -0
  80. package/_dist/vocab.d.ts.map +1 -0
  81. package/_dist/write.d.ts +169 -0
  82. package/_dist/write.d.ts.map +1 -0
  83. package/answer.js +110 -0
  84. package/answer.js.map +1 -0
  85. package/answer.ts +122 -0
  86. package/archetype.js +730 -0
  87. package/archetype.js.map +1 -0
  88. package/archetype.ts +790 -0
  89. package/binary_cases.ts +240 -0
  90. package/branches.js +195 -0
  91. package/branches.js.map +1 -0
  92. package/branches.ts +257 -0
  93. package/budget.js +89 -0
  94. package/budget.js.map +1 -0
  95. package/budget.ts +117 -0
  96. package/builtin.js +34 -0
  97. package/builtin.js.map +1 -0
  98. package/builtin.ts +31 -0
  99. package/bundle.js +21 -0
  100. package/bundle.js.map +1 -0
  101. package/bundle.ts +22 -0
  102. package/buried.js +95 -0
  103. package/buried.js.map +1 -0
  104. package/buried.ts +124 -0
  105. package/cache.js +153 -0
  106. package/cache.js.map +1 -0
  107. package/cache.ts +154 -0
  108. package/cache_worker.ts +16 -0
  109. package/catalog.js +173 -0
  110. package/catalog.js.map +1 -0
  111. package/catalog.ts +224 -0
  112. package/check.js +80 -0
  113. package/check.js.map +1 -0
  114. package/check.ts +92 -0
  115. package/checkpoint.js +98 -0
  116. package/checkpoint.js.map +1 -0
  117. package/checkpoint.ts +129 -0
  118. package/checkpoint_worker.ts +37 -0
  119. package/db.js +170 -0
  120. package/db.js.map +1 -0
  121. package/db.ts +173 -0
  122. package/ddl.js +1441 -0
  123. package/ddl.js.map +1 -0
  124. package/ddl.ts +1508 -0
  125. package/deno.json +1 -0
  126. package/doom.js +59 -0
  127. package/doom.js.map +1 -0
  128. package/doom.ts +75 -0
  129. package/driver.js +69 -0
  130. package/driver.js.map +1 -0
  131. package/driver.ts +101 -0
  132. package/error.js +30 -0
  133. package/error.js.map +1 -0
  134. package/error.ts +46 -0
  135. package/ffi/LICENSE +202 -0
  136. package/ffi/blob.js +99 -0
  137. package/ffi/blob.js.map +1 -0
  138. package/ffi/blob.ts +156 -0
  139. package/ffi/constants.js +65 -0
  140. package/ffi/constants.js.map +1 -0
  141. package/ffi/constants.ts +67 -0
  142. package/ffi/database.js +613 -0
  143. package/ffi/database.js.map +1 -0
  144. package/ffi/database.ts +931 -0
  145. package/ffi/ffi.js +535 -0
  146. package/ffi/ffi.js.map +1 -0
  147. package/ffi/ffi.ts +604 -0
  148. package/ffi/mod.js +15 -0
  149. package/ffi/mod.js.map +1 -0
  150. package/ffi/mod.ts +28 -0
  151. package/ffi/statement.js +555 -0
  152. package/ffi/statement.js.map +1 -0
  153. package/ffi/statement.ts +788 -0
  154. package/ffi/util.js +32 -0
  155. package/ffi/util.js.map +1 -0
  156. package/ffi/util.ts +48 -0
  157. package/follow.js +342 -0
  158. package/follow.js.map +1 -0
  159. package/follow.ts +401 -0
  160. package/history-branch.js +166 -0
  161. package/history-branch.js.map +1 -0
  162. package/history-branch.ts +140 -0
  163. package/history-shapes.js +254 -0
  164. package/history-shapes.js.map +1 -0
  165. package/history-shapes.ts +268 -0
  166. package/history.js +620 -0
  167. package/history.js.map +1 -0
  168. package/history.ts +674 -0
  169. package/inspect.js +120 -0
  170. package/inspect.js.map +1 -0
  171. package/inspect.ts +164 -0
  172. package/jsonb.js +73 -0
  173. package/jsonb.js.map +1 -0
  174. package/jsonb.ts +108 -0
  175. package/layout.js +22 -0
  176. package/layout.js.map +1 -0
  177. package/layout.ts +26 -0
  178. package/ledger.js +210 -0
  179. package/ledger.js.map +1 -0
  180. package/ledger.ts +210 -0
  181. package/legacy.js +4 -0
  182. package/legacy.js.map +1 -0
  183. package/legacy.ts +3 -0
  184. package/maintenance.js +148 -0
  185. package/maintenance.js.map +1 -0
  186. package/maintenance.ts +154 -0
  187. package/measure.js +133 -0
  188. package/measure.js.map +1 -0
  189. package/measure.ts +167 -0
  190. package/measure_worker.ts +18 -0
  191. package/memo.js +1250 -0
  192. package/memo.js.map +1 -0
  193. package/memo.ts +1480 -0
  194. package/meta.js +265 -0
  195. package/meta.js.map +1 -0
  196. package/meta.ts +321 -0
  197. package/migration.js +272 -0
  198. package/migration.js.map +1 -0
  199. package/migration.ts +286 -0
  200. package/mod.js +1103 -0
  201. package/mod.js.map +1 -0
  202. package/mod.ts +1762 -0
  203. package/mode.js +192 -0
  204. package/mode.js.map +1 -0
  205. package/mode.ts +207 -0
  206. package/native.js +544 -0
  207. package/native.js.map +1 -0
  208. package/native.ts +544 -0
  209. package/overlay.js +408 -0
  210. package/overlay.js.map +1 -0
  211. package/overlay.ts +485 -0
  212. package/owe.js +719 -0
  213. package/owe.js.map +1 -0
  214. package/owe.ts +873 -0
  215. package/package.json +99 -4
  216. package/physical.js +350 -0
  217. package/physical.js.map +1 -0
  218. package/physical.ts +434 -0
  219. package/plan.js +78 -0
  220. package/plan.js.map +1 -0
  221. package/plan.ts +104 -0
  222. package/point.js +81 -0
  223. package/point.js.map +1 -0
  224. package/point.ts +52 -0
  225. package/population.js +639 -0
  226. package/population.js.map +1 -0
  227. package/population.ts +630 -0
  228. package/purge.js +117 -0
  229. package/purge.js.map +1 -0
  230. package/purge.ts +127 -0
  231. package/raise.js +270 -0
  232. package/raise.js.map +1 -0
  233. package/raise.ts +316 -0
  234. package/read-db.js +381 -0
  235. package/read-db.js.map +1 -0
  236. package/read-db.ts +282 -0
  237. package/read-store.js +74 -0
  238. package/read-store.js.map +1 -0
  239. package/read-store.ts +86 -0
  240. package/read.js +1100 -0
  241. package/read.js.map +1 -0
  242. package/read.ts +1441 -0
  243. package/reader.js +141 -0
  244. package/reader.js.map +1 -0
  245. package/reader.ts +159 -0
  246. package/rules.js +88 -0
  247. package/rules.js.map +1 -0
  248. package/rules.ts +113 -0
  249. package/service.js +27 -0
  250. package/service.js.map +1 -0
  251. package/service.ts +41 -0
  252. package/shape.js +76 -0
  253. package/shape.js.map +1 -0
  254. package/shape.ts +108 -0
  255. package/sparse_presence_fixture.ts +45 -0
  256. package/sqlitepath.js +24 -0
  257. package/sqlitepath.js.map +1 -0
  258. package/sqlitepath.ts +29 -0
  259. package/statements.js +78 -0
  260. package/statements.js.map +1 -0
  261. package/statements.ts +96 -0
  262. package/survey.js +135 -0
  263. package/survey.js.map +1 -0
  264. package/survey.ts +196 -0
  265. package/tools.js +17 -0
  266. package/tools.js.map +1 -0
  267. package/tools.ts +50 -0
  268. package/trash.js +144 -0
  269. package/trash.js.map +1 -0
  270. package/trash.ts +187 -0
  271. package/unit.js +215 -0
  272. package/unit.js.map +1 -0
  273. package/unit.ts +211 -0
  274. package/versions.js +115 -0
  275. package/versions.js.map +1 -0
  276. package/versions.ts +110 -0
  277. package/vocab.js +19 -0
  278. package/vocab.js.map +1 -0
  279. package/vocab.json +27 -0
  280. package/vocab.ts +19 -0
  281. package/watch.js +33 -0
  282. package/watch.js.map +1 -0
  283. package/watch.ts +42 -0
  284. package/write.js +1164 -0
  285. package/write.js.map +1 -0
  286. package/write.ts +1356 -0
  287. package/written.js +200 -0
  288. package/written.js.map +1 -0
  289. package/written.ts +202 -0
package/vocab.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocab.js","sources":["./vocab.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,8EAA8E;AAC9E,+EAA+E;AAC/E,2EAA2E;AAC3E,wEAAwE;AACxE,+EAA+E;AAE/E,OAAO,SAAS,oBAAoB;EAAE,MAAM;AAAO,EAAC;AACpD,OAAO,cAAc,sBAAsB;EAAE,MAAM;AAAO,EAAC;AAE3D,mDAAmD,GACnD,OAAO,IAAI,YAAsB,IAAG;AAEpC;uDACuD,GACvD,OAAO,IAAI,cAAsB,SAAS,WAAW,CAAA;AAErD,yCAAyC,GACzC,OAAO,IAAI,OAAmB;EAAC;CAAU,CAAA"}
package/vocab.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "$id": "urn:uuid:7db60ead-fba7-419e-b1cc-4e1e5e56feda",
3
+ "$vocabulary": {
4
+ "https://yak.sh/vocab/core": true
5
+ },
6
+ "title": "sqlite",
7
+ "$defs": {
8
+ "storage_check": {
9
+ "tool": true,
10
+ "noun": "storage",
11
+ "verb": "check",
12
+ "title": "Check the database file",
13
+ "description": "Check that the SQLite file holds no component row without its parent record (entity) and no reference to a nonexistent entity. These can be missed by ordinary entity queries, so this asks the connection directly: whether foreign keys are enforced, which rows violate one, and what SQLite’s own integrity_check reports. Takes no arguments. Returns a report in content.body, with warning or failure findings when present; it does not repair the records or configuration.",
14
+ "input": {},
15
+ "readOnly": true
16
+ },
17
+ "archetype_check": {
18
+ "tool": true,
19
+ "noun": "archetype",
20
+ "verb": "check",
21
+ "title": "Check entity component sets",
22
+ "description": "Check that each entity’s archetype pointer matches the components it actually has. An entity is a stored record; its components are named groups of fields, and its archetype pointer identifies the set of component types present. Direct database writes that bypass the graph can leave these pointers stale, causing reads and query planning to use the wrong component set. Takes no arguments. Returns a report in content.body, with warning or failure findings when present; it does not repair the records or configuration.",
23
+ "input": {},
24
+ "readOnly": true
25
+ }
26
+ }
27
+ }
package/vocab.ts ADDED
@@ -0,0 +1,19 @@
1
+ // The component and tool declarations, and only those: the module exported as
2
+ // `@yaks/sqlite/vocab`. This package declares no component — a store is not a
3
+ // domain, and nothing here is sent to a client. What it declares is two tools,
4
+ // the checks in ./tools.ts, because a tool is declared in a vocabulary and
5
+ // listed by the application the same way a component is: the file's own
6
+ // invariants are checked through the same mechanism every other package's are.
7
+ import type { VocabDoc } from 'jsr:@yaks/vocab@0.2.36'
8
+ import doc from './vocab.json' with { type: 'json' }
9
+ import manifest from './package.json' with { type: 'json' }
10
+
11
+ /** The tool declarations this plugin contributes. */
12
+ export let sqliteDoc: VocabDoc = doc
13
+
14
+ /** What this package is: its manifest's description, the one place it is
15
+ * written, which a host stamps on each document here. */
16
+ export let description: string = manifest.description
17
+
18
+ /** Every document this plugin declares. */
19
+ export let docs: VocabDoc[] = [sqliteDoc]
package/watch.js ADDED
@@ -0,0 +1,33 @@
1
+ // Rows other connections add, heard as they land. The driver hears its file
2
+ // change (@yaks/sql `Driver.watch`); the component's table then answers its
3
+ // newest row from the end of its key, one seek, and one newer than the last
4
+ // it answered is a row added since. An entity's id is never reused, so a
5
+ // newer row has a higher one. A driver that owns its database alone hears
6
+ // nothing: what it adds, its own writer already knows.
7
+ import { as, col, fn, select, table } from "@yaks/sql";
8
+ import { tables } from "./layout.js";
9
+ /** The newest row of `comp`'s table, one seek: a higher one is a row added
10
+ * since. 0 where nothing has written the table yet, or it names no table. */ export let newest = (driver, vocab, comp)=>// A table nothing has written yet stands once a write first names it
11
+ // (./raise.ts); until then it has no newest row.
12
+ tables(vocab).includes(comp) && driver.query({
13
+ t: 'pragma',
14
+ name: 'table_info',
15
+ arg: comp
16
+ }).length ? Number(driver.query(select({
17
+ cols: [
18
+ as(fn('max', col('entity')), 'newest')
19
+ ],
20
+ from: table(comp)
21
+ }))[0]?.newest ?? 0) : 0;
22
+ /** Call `heard` soon after another connection commits a new row of
23
+ * `comp`. */ export let watch = (driver, vocab, comp, heard)=>{
24
+ if (!driver.watch || !tables(vocab).includes(comp)) return ()=>{};
25
+ let last = newest(driver, vocab, comp);
26
+ return driver.watch(()=>{
27
+ let now = newest(driver, vocab, comp);
28
+ let more = now > last;
29
+ last = now;
30
+ if (more) heard();
31
+ });
32
+ };
33
+ //# sourceMappingURL=watch.js.map
package/watch.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch.js","sources":["./watch.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAC5E,yEAAyE;AACzE,0EAA0E;AAC1E,uDAAuD;AACvD,SAAS,EAAE,EAAE,GAAG,EAAe,EAAE,EAAE,MAAM,EAAE,KAAK,yBAA8B;AAE9E,SAAS,MAAM,sBAAqB;AAEpC;2EAC2E,GAC3E,OAAO,IAAI,SAAS,CAAC,QAAgB,OAAc,OACjD,qEAAqE;EACrE,iDAAiD;EACjD,OAAO,OAAO,QAAQ,CAAC,SACrB,OAAO,KAAK,CAAC;IAAE,GAAG;IAAU,MAAM;IAAc,KAAK;EAAK,GAAG,MAAM,GACjE,OACA,OAAO,KAAK,CAAC,OAAO;IAClB,MAAM;MAAC,GAAG,GAAG,OAAO,IAAI,YAAY;KAAU;IAC9C,MAAM,MAAM;EACd,GAAG,CAAC,EAAE,EAAE,UAAU,KAElB,EAAC;AAEP;WACW,GACX,OAAO,IAAI,QAAQ,CACjB,QACA,OACA,MACA;EAEA,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,OAAO,OAAO,QAAQ,CAAC,OAAO,OAAO,KAAO;EAClE,IAAI,OAAO,OAAO,QAAQ,OAAO;EACjC,OAAO,OAAO,KAAK,CAAC;IAClB,IAAI,MAAM,OAAO,QAAQ,OAAO;IAChC,IAAI,OAAO,MAAM;IACjB,OAAO;IACP,IAAI,MAAM;EACZ;AACF,EAAC"}
package/watch.ts ADDED
@@ -0,0 +1,42 @@
1
+ // Rows other connections add, heard as they land. The driver hears its file
2
+ // change (@yaks/sql `Driver.watch`); the component's table then answers its
3
+ // newest row from the end of its key, one seek, and one newer than the last
4
+ // it answered is a row added since. An entity's id is never reused, so a
5
+ // newer row has a higher one. A driver that owns its database alone hears
6
+ // nothing: what it adds, its own writer already knows.
7
+ import { as, col, type Driver, fn, select, table } from '@yaks/sql'
8
+ import type { Vocab } from 'jsr:@yaks/vocab@0.2.36'
9
+ import { tables } from './layout.js'
10
+
11
+ /** The newest row of `comp`'s table, one seek: a higher one is a row added
12
+ * since. 0 where nothing has written the table yet, or it names no table. */
13
+ export let newest = (driver: Driver, vocab: Vocab, comp: string): number =>
14
+ // A table nothing has written yet stands once a write first names it
15
+ // (./raise.ts); until then it has no newest row.
16
+ tables(vocab).includes(comp) &&
17
+ driver.query({ t: 'pragma', name: 'table_info', arg: comp }).length
18
+ ? Number(
19
+ driver.query(select({
20
+ cols: [as(fn('max', col('entity')), 'newest')],
21
+ from: table(comp),
22
+ }))[0]?.newest ?? 0,
23
+ )
24
+ : 0
25
+
26
+ /** Call `heard` soon after another connection commits a new row of
27
+ * `comp`. */
28
+ export let watch = (
29
+ driver: Driver,
30
+ vocab: Vocab,
31
+ comp: string,
32
+ heard: () => void,
33
+ ): () => void => {
34
+ if (!driver.watch || !tables(vocab).includes(comp)) return () => {}
35
+ let last = newest(driver, vocab, comp)
36
+ return driver.watch(() => {
37
+ let now = newest(driver, vocab, comp)
38
+ let more = now > last
39
+ last = now
40
+ if (more) heard()
41
+ })
42
+ }